@suveren/gateway 0.7.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/dist/control-plane/index.mjs +65 -6
- package/dist/ui/assets/index-DdJeSfV9.js +110 -0
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/index-DHT9QCrE.js +0 -110
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
var tp=Object.defineProperty;var np=(e,t,n)=>t in e?tp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Da=(e,t,n)=>np(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var ru={exports:{}},ja={},su={exports:{}},ae={};/**
|
|
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 os=Symbol.for("react.element"),rp=Symbol.for("react.portal"),sp=Symbol.for("react.fragment"),ap=Symbol.for("react.strict_mode"),op=Symbol.for("react.profiler"),ip=Symbol.for("react.provider"),lp=Symbol.for("react.context"),cp=Symbol.for("react.forward_ref"),up=Symbol.for("react.suspense"),dp=Symbol.for("react.memo"),fp=Symbol.for("react.lazy"),Tl=Symbol.iterator;function pp(e){return e===null||typeof e!="object"?null:(e=Tl&&e[Tl]||e["@@iterator"],typeof e=="function"?e:null)}var au={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ou=Object.assign,iu={};function fr(e,t,n){this.props=e,this.context=t,this.refs=iu,this.updater=n||au}fr.prototype.isReactComponent={};fr.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")};fr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function lu(){}lu.prototype=fr.prototype;function bi(e,t,n){this.props=e,this.context=t,this.refs=iu,this.updater=n||au}var Ci=bi.prototype=new lu;Ci.constructor=bi;ou(Ci,fr.prototype);Ci.isPureReactComponent=!0;var zl=Array.isArray,cu=Object.prototype.hasOwnProperty,Ni={current:null},uu={key:!0,ref:!0,__self:!0,__source:!0};function du(e,t,n){var r,s={},o=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(o=""+t.key),t)cu.call(t,r)&&!uu.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var c=Array(l),d=0;d<l;d++)c[d]=arguments[d+2];s.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)s[r]===void 0&&(s[r]=l[r]);return{$$typeof:os,type:e,key:o,ref:i,props:s,_owner:Ni.current}}function mp(e,t){return{$$typeof:os,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ei(e){return typeof e=="object"&&e!==null&&e.$$typeof===os}function hp(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Il=/\/+/g;function Ua(e,t){return typeof e=="object"&&e!==null&&e.key!=null?hp(""+e.key):t.toString(36)}function As(e,t,n,r,s){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var i=!1;if(e===null)i=!0;else switch(o){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case os:case rp:i=!0}}if(i)return i=e,s=s(i),e=r===""?"."+Ua(i,0):r,zl(s)?(n="",e!=null&&(n=e.replace(Il,"$&/")+"/"),As(s,t,n,"",function(d){return d})):s!=null&&(Ei(s)&&(s=mp(s,n+(!s.key||i&&i.key===s.key?"":(""+s.key).replace(Il,"$&/")+"/")+e)),t.push(s)),1;if(i=0,r=r===""?".":r+":",zl(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+Ua(o,l);i+=As(o,t,n,c,s)}else if(c=pp(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+Ua(o,l++),i+=As(o,t,n,c,s);else if(o==="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 ps(e,t,n){if(e==null)return e;var r=[],s=0;return As(e,r,"","",function(o){return t.call(n,o,s++)}),r}function gp(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 Xe={current:null},$s={transition:null},vp={ReactCurrentDispatcher:Xe,ReactCurrentBatchConfig:$s,ReactCurrentOwner:Ni};function fu(){throw Error("act(...) is not supported in production builds of React.")}ae.Children={map:ps,forEach:function(e,t,n){ps(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ps(e,function(){t++}),t},toArray:function(e){return ps(e,function(t){return t})||[]},only:function(e){if(!Ei(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ae.Component=fr;ae.Fragment=sp;ae.Profiler=op;ae.PureComponent=bi;ae.StrictMode=ap;ae.Suspense=up;ae.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=vp;ae.act=fu;ae.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=ou({},e.props),s=e.key,o=e.ref,i=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,i=Ni.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)cu.call(t,c)&&!uu.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 d=0;d<c;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:os,type:e.type,key:s,ref:o,props:r,_owner:i}};ae.createContext=function(e){return e={$$typeof:lp,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:ip,_context:e},e.Consumer=e};ae.createElement=du;ae.createFactory=function(e){var t=du.bind(null,e);return t.type=e,t};ae.createRef=function(){return{current:null}};ae.forwardRef=function(e){return{$$typeof:cp,render:e}};ae.isValidElement=Ei;ae.lazy=function(e){return{$$typeof:fp,_payload:{_status:-1,_result:e},_init:gp}};ae.memo=function(e,t){return{$$typeof:dp,type:e,compare:t===void 0?null:t}};ae.startTransition=function(e){var t=$s.transition;$s.transition={};try{e()}finally{$s.transition=t}};ae.unstable_act=fu;ae.useCallback=function(e,t){return Xe.current.useCallback(e,t)};ae.useContext=function(e){return Xe.current.useContext(e)};ae.useDebugValue=function(){};ae.useDeferredValue=function(e){return Xe.current.useDeferredValue(e)};ae.useEffect=function(e,t){return Xe.current.useEffect(e,t)};ae.useId=function(){return Xe.current.useId()};ae.useImperativeHandle=function(e,t,n){return Xe.current.useImperativeHandle(e,t,n)};ae.useInsertionEffect=function(e,t){return Xe.current.useInsertionEffect(e,t)};ae.useLayoutEffect=function(e,t){return Xe.current.useLayoutEffect(e,t)};ae.useMemo=function(e,t){return Xe.current.useMemo(e,t)};ae.useReducer=function(e,t,n){return Xe.current.useReducer(e,t,n)};ae.useRef=function(e){return Xe.current.useRef(e)};ae.useState=function(e){return Xe.current.useState(e)};ae.useSyncExternalStore=function(e,t,n){return Xe.current.useSyncExternalStore(e,t,n)};ae.useTransition=function(){return Xe.current.useTransition()};ae.version="18.3.1";su.exports=ae;var u=su.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 yp=u,xp=Symbol.for("react.element"),wp=Symbol.for("react.fragment"),Sp=Object.prototype.hasOwnProperty,jp=yp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,kp={key:!0,ref:!0,__self:!0,__source:!0};function pu(e,t,n){var r,s={},o=null,i=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(i=t.ref);for(r in t)Sp.call(t,r)&&!kp.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:xp,type:e,key:o,ref:i,props:s,_owner:jp.current}}ja.Fragment=wp;ja.jsx=pu;ja.jsxs=pu;ru.exports=ja;var a=ru.exports,mu={exports:{}},ft={},hu={exports:{}},gu={};/**
|
|
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($,_){var W=$.length;$.push(_);e:for(;0<W;){var R=W-1>>>1,D=$[R];if(0<s(D,_))$[R]=_,$[W]=D,W=R;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var _=$[0],W=$.pop();if(W!==_){$[0]=W;e:for(var R=0,D=$.length,L=D>>>1;R<L;){var U=2*(R+1)-1,ee=$[U],q=U+1,me=$[q];if(0>s(ee,W))q<D&&0>s(me,ee)?($[R]=me,$[q]=W,R=q):($[R]=ee,$[U]=W,R=U);else if(q<D&&0>s(me,W))$[R]=me,$[q]=W,R=q;else break e}}return _}function s($,_){var W=$.sortIndex-_.sortIndex;return W!==0?W:$.id-_.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var c=[],d=[],f=1,h=null,m=3,x=!1,w=!1,y=!1,j=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,p=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v($){for(var _=n(d);_!==null;){if(_.callback===null)r(d);else if(_.startTime<=$)r(d),_.sortIndex=_.expirationTime,t(c,_);else break;_=n(d)}}function S($){if(y=!1,v($),!w)if(n(c)!==null)w=!0,J(k);else{var _=n(d);_!==null&&ne(S,_.startTime-$)}}function k($,_){w=!1,y&&(y=!1,g(P),P=-1),x=!0;var W=m;try{for(v(_),h=n(c);h!==null&&(!(h.expirationTime>_)||$&&!O());){var R=h.callback;if(typeof R=="function"){h.callback=null,m=h.priorityLevel;var D=R(h.expirationTime<=_);_=e.unstable_now(),typeof D=="function"?h.callback=D:h===n(c)&&r(c),v(_)}else r(c);h=n(c)}if(h!==null)var L=!0;else{var U=n(d);U!==null&&ne(S,U.startTime-_),L=!1}return L}finally{h=null,m=W,x=!1}}var I=!1,T=null,P=-1,b=5,N=-1;function O(){return!(e.unstable_now()-N<b)}function Y(){if(T!==null){var $=e.unstable_now();N=$;var _=!0;try{_=T(!0,$)}finally{_?V():(I=!1,T=null)}}else I=!1}var V;if(typeof p=="function")V=function(){p(Y)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,C=H.port2;H.port1.onmessage=Y,V=function(){C.postMessage(null)}}else V=function(){j(Y,0)};function J($){T=$,I||(I=!0,V())}function ne($,_){P=j(function(){$(e.unstable_now())},_)}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($){$.callback=null},e.unstable_continueExecution=function(){w||x||(w=!0,J(k))},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):b=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function($){switch(m){case 1:case 2:case 3:var _=3;break;default:_=m}var W=m;m=_;try{return $()}finally{m=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,_){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var W=m;m=$;try{return _()}finally{m=W}},e.unstable_scheduleCallback=function($,_,W){var R=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?R+W:R):W=R,$){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=W+D,$={id:f++,callback:_,priorityLevel:$,startTime:W,expirationTime:D,sortIndex:-1},W>R?($.sortIndex=W,t(d,$),n(c)===null&&$===n(d)&&(y?(g(P),P=-1):y=!0,ne(S,W-R))):($.sortIndex=D,t(c,$),w||x||(w=!0,J(k))),$},e.unstable_shouldYield=O,e.unstable_wrapCallback=function($){var _=m;return function(){var W=m;m=_;try{return $.apply(this,arguments)}finally{m=W}}}})(gu);hu.exports=gu;var bp=hu.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 Cp=u,dt=bp;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 vu=new Set,Ur={};function Mn(e,t){ar(e,t),ar(e+"Capture",t)}function ar(e,t){for(Ur[e]=t,e=0;e<t.length;e++)vu.add(t[e])}var Gt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ko=Object.prototype.hasOwnProperty,Np=/^[: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]*$/,Pl={},Rl={};function Ep(e){return ko.call(Rl,e)?!0:ko.call(Pl,e)?!1:Np.test(e)?Rl[e]=!0:(Pl[e]=!0,!1)}function Tp(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 zp(e,t,n,r){if(t===null||typeof t>"u"||Tp(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 qe(e,t,n,r,s,o,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=i}var We={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){We[e]=new qe(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];We[t]=new qe(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){We[e]=new qe(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){We[e]=new qe(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){We[e]=new qe(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){We[e]=new qe(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){We[e]=new qe(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){We[e]=new qe(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){We[e]=new qe(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ti=/[\-:]([a-z])/g;function zi(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(Ti,zi);We[t]=new qe(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(Ti,zi);We[t]=new qe(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(Ti,zi);We[t]=new qe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){We[e]=new qe(e,1,!1,e.toLowerCase(),null,!1,!1)});We.xlinkHref=new qe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){We[e]=new qe(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ii(e,t,n,r){var s=We.hasOwnProperty(t)?We[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(zp(t,n,s,r)&&(n=null),r||s===null?Ep(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):s.mustUseProperty?e[s.propertyName]=n===null?s.type===3?!1:"":n:(t=s.attributeName,r=s.attributeNamespace,n===null?e.removeAttribute(t):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Xt=Cp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ms=Symbol.for("react.element"),Dn=Symbol.for("react.portal"),Un=Symbol.for("react.fragment"),Pi=Symbol.for("react.strict_mode"),bo=Symbol.for("react.profiler"),yu=Symbol.for("react.provider"),xu=Symbol.for("react.context"),Ri=Symbol.for("react.forward_ref"),Co=Symbol.for("react.suspense"),No=Symbol.for("react.suspense_list"),_i=Symbol.for("react.memo"),en=Symbol.for("react.lazy"),wu=Symbol.for("react.offscreen"),_l=Symbol.iterator;function yr(e){return e===null||typeof e!="object"?null:(e=_l&&e[_l]||e["@@iterator"],typeof e=="function"?e:null)}var Ne=Object.assign,Wa;function Er(e){if(Wa===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Wa=t&&t[1]||""}return`
|
|
34
|
-
`+Wa+e}var Ha=!1;function Va(e,t){if(!e||Ha)return"";Ha=!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(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var s=d.stack.split(`
|
|
35
|
-
`),o=r.stack.split(`
|
|
36
|
-
`),i=s.length-1,l=o.length-1;1<=i&&0<=l&&s[i]!==o[l];)l--;for(;1<=i&&0<=l;i--,l--)if(s[i]!==o[l]){if(i!==1||l!==1)do if(i--,l--,0>l||s[i]!==o[l]){var c=`
|
|
37
|
-
`+s[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{Ha=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Er(e):""}function Ip(e){switch(e.tag){case 5:return Er(e.type);case 16:return Er("Lazy");case 13:return Er("Suspense");case 19:return Er("SuspenseList");case 0:case 2:case 15:return e=Va(e.type,!1),e;case 11:return e=Va(e.type.render,!1),e;case 1:return e=Va(e.type,!0),e;default:return""}}function Eo(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 Un:return"Fragment";case Dn:return"Portal";case bo:return"Profiler";case Pi:return"StrictMode";case Co:return"Suspense";case No:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case xu:return(e.displayName||"Context")+".Consumer";case yu:return(e._context.displayName||"Context")+".Provider";case Ri:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case _i:return t=e.displayName||null,t!==null?t:Eo(e.type)||"Memo";case en:t=e._payload,e=e._init;try{return Eo(e(t))}catch{}}return null}function Pp(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 Eo(t);case 8:return t===Pi?"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 gn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Su(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Rp(e){var t=Su(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 s=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(i){r=""+i,o.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 hs(e){e._valueTracker||(e._valueTracker=Rp(e))}function ju(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Su(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Qs(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 To(e,t){var n=t.checked;return Ne({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Al(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=gn(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 ku(e,t){t=t.checked,t!=null&&Ii(e,"checked",t,!1)}function zo(e,t){ku(e,t);var n=gn(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")?Io(e,t.type,n):t.hasOwnProperty("defaultValue")&&Io(e,t.type,gn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function $l(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 Io(e,t,n){(t!=="number"||Qs(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Tr=Array.isArray;function Zn(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&r&&(e[n].defaultSelected=!0)}else{for(n=""+gn(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function Po(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(F(91));return Ne({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ll(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(Tr(n)){if(1<n.length)throw Error(F(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:gn(n)}}function bu(e,t){var n=gn(t.value),r=gn(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 Ml(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Cu(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 Ro(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Cu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var gs,Nu=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,s){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,s)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(gs=gs||document.createElement("div"),gs.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=gs.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Wr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Rr={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},_p=["Webkit","ms","Moz","O"];Object.keys(Rr).forEach(function(e){_p.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Rr[t]=Rr[e]})});function Eu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Rr.hasOwnProperty(e)&&Rr[e]?(""+t).trim():t+"px"}function Tu(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Eu(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Ap=Ne({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 _o(e,t){if(t){if(Ap[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 Ao(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 $o=null;function Ai(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Lo=null,er=null,tr=null;function Fl(e){if(e=cs(e)){if(typeof Lo!="function")throw Error(F(280));var t=e.stateNode;t&&(t=Ea(t),Lo(e.stateNode,e.type,t))}}function zu(e){er?tr?tr.push(e):tr=[e]:er=e}function Iu(){if(er){var e=er,t=tr;if(tr=er=null,Fl(e),t)for(e=0;e<t.length;e++)Fl(t[e])}}function Pu(e,t){return e(t)}function Ru(){}var Ga=!1;function _u(e,t,n){if(Ga)return e(t,n);Ga=!0;try{return Pu(e,t,n)}finally{Ga=!1,(er!==null||tr!==null)&&(Ru(),Iu())}}function Hr(e,t){var n=e.stateNode;if(n===null)return null;var r=Ea(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 Mo=!1;if(Gt)try{var xr={};Object.defineProperty(xr,"passive",{get:function(){Mo=!0}}),window.addEventListener("test",xr,xr),window.removeEventListener("test",xr,xr)}catch{Mo=!1}function $p(e,t,n,r,s,o,i,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(f){this.onError(f)}}var _r=!1,Js=null,Xs=!1,Fo=null,Lp={onError:function(e){_r=!0,Js=e}};function Mp(e,t,n,r,s,o,i,l,c){_r=!1,Js=null,$p.apply(Lp,arguments)}function Fp(e,t,n,r,s,o,i,l,c){if(Mp.apply(this,arguments),_r){if(_r){var d=Js;_r=!1,Js=null}else throw Error(F(198));Xs||(Xs=!0,Fo=d)}}function Fn(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 Au(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 Ol(e){if(Fn(e)!==e)throw Error(F(188))}function Op(e){var t=e.alternate;if(!t){if(t=Fn(e),t===null)throw Error(F(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var o=s.alternate;if(o===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===o.child){for(o=s.child;o;){if(o===n)return Ol(s),e;if(o===r)return Ol(s),t;o=o.sibling}throw Error(F(188))}if(n.return!==r.return)n=s,r=o;else{for(var i=!1,l=s.child;l;){if(l===n){i=!0,n=s,r=o;break}if(l===r){i=!0,r=s,n=o;break}l=l.sibling}if(!i){for(l=o.child;l;){if(l===n){i=!0,n=o,r=s;break}if(l===r){i=!0,r=o,n=s;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 $u(e){return e=Op(e),e!==null?Lu(e):null}function Lu(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Lu(e);if(t!==null)return t;e=e.sibling}return null}var Mu=dt.unstable_scheduleCallback,Bl=dt.unstable_cancelCallback,Bp=dt.unstable_shouldYield,Dp=dt.unstable_requestPaint,Ie=dt.unstable_now,Up=dt.unstable_getCurrentPriorityLevel,$i=dt.unstable_ImmediatePriority,Fu=dt.unstable_UserBlockingPriority,qs=dt.unstable_NormalPriority,Wp=dt.unstable_LowPriority,Ou=dt.unstable_IdlePriority,ka=null,Mt=null;function Hp(e){if(Mt&&typeof Mt.onCommitFiberRoot=="function")try{Mt.onCommitFiberRoot(ka,e,void 0,(e.current.flags&128)===128)}catch{}}var Tt=Math.clz32?Math.clz32:Kp,Vp=Math.log,Gp=Math.LN2;function Kp(e){return e>>>=0,e===0?32:31-(Vp(e)/Gp|0)|0}var vs=64,ys=4194304;function zr(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 Zs(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var l=i&~s;l!==0?r=zr(l):(o&=i,o!==0&&(r=zr(o)))}else i=n&~s,i!==0?r=zr(i):o!==0&&(r=zr(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,o=t&-t,s>=o||s===16&&(o&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-Tt(t),s=1<<n,r|=e[n],t&=~s;return r}function Yp(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 Qp(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var i=31-Tt(o),l=1<<i,c=s[i];c===-1?(!(l&n)||l&r)&&(s[i]=Yp(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function Oo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Bu(){var e=vs;return vs<<=1,!(vs&4194240)&&(vs=64),e}function Ka(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function is(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Tt(t),e[t]=n}function Jp(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 s=31-Tt(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function Li(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Tt(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var pe=0;function Du(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Uu,Mi,Wu,Hu,Vu,Bo=!1,xs=[],ln=null,cn=null,un=null,Vr=new Map,Gr=new Map,rn=[],Xp="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 Dl(e,t){switch(e){case"focusin":case"focusout":ln=null;break;case"dragenter":case"dragleave":cn=null;break;case"mouseover":case"mouseout":un=null;break;case"pointerover":case"pointerout":Vr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Gr.delete(t.pointerId)}}function wr(e,t,n,r,s,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[s]},t!==null&&(t=cs(t),t!==null&&Mi(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function qp(e,t,n,r,s){switch(t){case"focusin":return ln=wr(ln,e,t,n,r,s),!0;case"dragenter":return cn=wr(cn,e,t,n,r,s),!0;case"mouseover":return un=wr(un,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return Vr.set(o,wr(Vr.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,Gr.set(o,wr(Gr.get(o)||null,e,t,n,r,s)),!0}return!1}function Gu(e){var t=Nn(e.target);if(t!==null){var n=Fn(t);if(n!==null){if(t=n.tag,t===13){if(t=Au(n),t!==null){e.blockedOn=t,Vu(e.priority,function(){Wu(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 Ls(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Do(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);$o=r,n.target.dispatchEvent(r),$o=null}else return t=cs(n),t!==null&&Mi(t),e.blockedOn=n,!1;t.shift()}return!0}function Ul(e,t,n){Ls(e)&&n.delete(t)}function Zp(){Bo=!1,ln!==null&&Ls(ln)&&(ln=null),cn!==null&&Ls(cn)&&(cn=null),un!==null&&Ls(un)&&(un=null),Vr.forEach(Ul),Gr.forEach(Ul)}function Sr(e,t){e.blockedOn===t&&(e.blockedOn=null,Bo||(Bo=!0,dt.unstable_scheduleCallback(dt.unstable_NormalPriority,Zp)))}function Kr(e){function t(s){return Sr(s,e)}if(0<xs.length){Sr(xs[0],e);for(var n=1;n<xs.length;n++){var r=xs[n];r.blockedOn===e&&(r.blockedOn=null)}}for(ln!==null&&Sr(ln,e),cn!==null&&Sr(cn,e),un!==null&&Sr(un,e),Vr.forEach(t),Gr.forEach(t),n=0;n<rn.length;n++)r=rn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<rn.length&&(n=rn[0],n.blockedOn===null);)Gu(n),n.blockedOn===null&&rn.shift()}var nr=Xt.ReactCurrentBatchConfig,ea=!0;function em(e,t,n,r){var s=pe,o=nr.transition;nr.transition=null;try{pe=1,Fi(e,t,n,r)}finally{pe=s,nr.transition=o}}function tm(e,t,n,r){var s=pe,o=nr.transition;nr.transition=null;try{pe=4,Fi(e,t,n,r)}finally{pe=s,nr.transition=o}}function Fi(e,t,n,r){if(ea){var s=Do(e,t,n,r);if(s===null)ro(e,t,r,ta,n),Dl(e,r);else if(qp(s,e,t,n,r))r.stopPropagation();else if(Dl(e,r),t&4&&-1<Xp.indexOf(e)){for(;s!==null;){var o=cs(s);if(o!==null&&Uu(o),o=Do(e,t,n,r),o===null&&ro(e,t,r,ta,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else ro(e,t,r,null,n)}}var ta=null;function Do(e,t,n,r){if(ta=null,e=Ai(r),e=Nn(e),e!==null)if(t=Fn(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Au(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 ta=e,null}function Ku(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(Up()){case $i:return 1;case Fu:return 4;case qs:case Wp:return 16;case Ou:return 536870912;default:return 16}default:return 16}}var an=null,Oi=null,Ms=null;function Yu(){if(Ms)return Ms;var e,t=Oi,n=t.length,r,s="value"in an?an.value:an.textContent,o=s.length;for(e=0;e<n&&t[e]===s[e];e++);var i=n-e;for(r=1;r<=i&&t[n-r]===s[o-r];r++);return Ms=s.slice(e,1<r?1-r:void 0)}function Fs(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 ws(){return!0}function Wl(){return!1}function pt(e){function t(n,r,s,o,i){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=o,this.target=i,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(o):o[l]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?ws:Wl,this.isPropagationStopped=Wl,this}return Ne(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=ws)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=ws)},persist:function(){},isPersistent:ws}),t}var pr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bi=pt(pr),ls=Ne({},pr,{view:0,detail:0}),nm=pt(ls),Ya,Qa,jr,ba=Ne({},ls,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Di,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!==jr&&(jr&&e.type==="mousemove"?(Ya=e.screenX-jr.screenX,Qa=e.screenY-jr.screenY):Qa=Ya=0,jr=e),Ya)},movementY:function(e){return"movementY"in e?e.movementY:Qa}}),Hl=pt(ba),rm=Ne({},ba,{dataTransfer:0}),sm=pt(rm),am=Ne({},ls,{relatedTarget:0}),Ja=pt(am),om=Ne({},pr,{animationName:0,elapsedTime:0,pseudoElement:0}),im=pt(om),lm=Ne({},pr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),cm=pt(lm),um=Ne({},pr,{data:0}),Vl=pt(um),dm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fm={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"},pm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mm(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=pm[e])?!!t[e]:!1}function Di(){return mm}var hm=Ne({},ls,{key:function(e){if(e.key){var t=dm[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Fs(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?fm[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Di,charCode:function(e){return e.type==="keypress"?Fs(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Fs(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),gm=pt(hm),vm=Ne({},ba,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gl=pt(vm),ym=Ne({},ls,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Di}),xm=pt(ym),wm=Ne({},pr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Sm=pt(wm),jm=Ne({},ba,{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}),km=pt(jm),bm=[9,13,27,32],Ui=Gt&&"CompositionEvent"in window,Ar=null;Gt&&"documentMode"in document&&(Ar=document.documentMode);var Cm=Gt&&"TextEvent"in window&&!Ar,Qu=Gt&&(!Ui||Ar&&8<Ar&&11>=Ar),Kl=" ",Yl=!1;function Ju(e,t){switch(e){case"keyup":return bm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Wn=!1;function Nm(e,t){switch(e){case"compositionend":return Xu(t);case"keypress":return t.which!==32?null:(Yl=!0,Kl);case"textInput":return e=t.data,e===Kl&&Yl?null:e;default:return null}}function Em(e,t){if(Wn)return e==="compositionend"||!Ui&&Ju(e,t)?(e=Yu(),Ms=Oi=an=null,Wn=!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 Qu&&t.locale!=="ko"?null:t.data;default:return null}}var Tm={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 Ql(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Tm[e.type]:t==="textarea"}function qu(e,t,n,r){zu(r),t=na(t,"onChange"),0<t.length&&(n=new Bi("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var $r=null,Yr=null;function zm(e){cd(e,0)}function Ca(e){var t=Gn(e);if(ju(t))return e}function Im(e,t){if(e==="change")return t}var Zu=!1;if(Gt){var Xa;if(Gt){var qa="oninput"in document;if(!qa){var Jl=document.createElement("div");Jl.setAttribute("oninput","return;"),qa=typeof Jl.oninput=="function"}Xa=qa}else Xa=!1;Zu=Xa&&(!document.documentMode||9<document.documentMode)}function Xl(){$r&&($r.detachEvent("onpropertychange",ed),Yr=$r=null)}function ed(e){if(e.propertyName==="value"&&Ca(Yr)){var t=[];qu(t,Yr,e,Ai(e)),_u(zm,t)}}function Pm(e,t,n){e==="focusin"?(Xl(),$r=t,Yr=n,$r.attachEvent("onpropertychange",ed)):e==="focusout"&&Xl()}function Rm(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ca(Yr)}function _m(e,t){if(e==="click")return Ca(t)}function Am(e,t){if(e==="input"||e==="change")return Ca(t)}function $m(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var It=typeof Object.is=="function"?Object.is:$m;function Qr(e,t){if(It(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 s=n[r];if(!ko.call(t,s)||!It(e[s],t[s]))return!1}return!0}function ql(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Zl(e,t){var n=ql(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=ql(n)}}function td(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?td(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function nd(){for(var e=window,t=Qs();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Qs(e.document)}return t}function Wi(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 Lm(e){var t=nd(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&td(n.ownerDocument.documentElement,n)){if(r!==null&&Wi(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 s=n.textContent.length,o=Math.min(r.start,s);r=r.end===void 0?o:Math.min(r.end,s),!e.extend&&o>r&&(s=r,r=o,o=s),s=Zl(n,o);var i=Zl(n,r);s&&i&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),o>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 Mm=Gt&&"documentMode"in document&&11>=document.documentMode,Hn=null,Uo=null,Lr=null,Wo=!1;function ec(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Wo||Hn==null||Hn!==Qs(r)||(r=Hn,"selectionStart"in r&&Wi(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}),Lr&&Qr(Lr,r)||(Lr=r,r=na(Uo,"onSelect"),0<r.length&&(t=new Bi("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Hn)))}function Ss(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Vn={animationend:Ss("Animation","AnimationEnd"),animationiteration:Ss("Animation","AnimationIteration"),animationstart:Ss("Animation","AnimationStart"),transitionend:Ss("Transition","TransitionEnd")},Za={},rd={};Gt&&(rd=document.createElement("div").style,"AnimationEvent"in window||(delete Vn.animationend.animation,delete Vn.animationiteration.animation,delete Vn.animationstart.animation),"TransitionEvent"in window||delete Vn.transitionend.transition);function Na(e){if(Za[e])return Za[e];if(!Vn[e])return e;var t=Vn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in rd)return Za[e]=t[n];return e}var sd=Na("animationend"),ad=Na("animationiteration"),od=Na("animationstart"),id=Na("transitionend"),ld=new Map,tc="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 yn(e,t){ld.set(e,t),Mn(t,[e])}for(var eo=0;eo<tc.length;eo++){var to=tc[eo],Fm=to.toLowerCase(),Om=to[0].toUpperCase()+to.slice(1);yn(Fm,"on"+Om)}yn(sd,"onAnimationEnd");yn(ad,"onAnimationIteration");yn(od,"onAnimationStart");yn("dblclick","onDoubleClick");yn("focusin","onFocus");yn("focusout","onBlur");yn(id,"onTransitionEnd");ar("onMouseEnter",["mouseout","mouseover"]);ar("onMouseLeave",["mouseout","mouseover"]);ar("onPointerEnter",["pointerout","pointerover"]);ar("onPointerLeave",["pointerout","pointerover"]);Mn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Mn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Mn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Mn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Mn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Mn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ir="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(" "),Bm=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ir));function nc(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Fp(r,t,void 0,e),e.currentTarget=null}function cd(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],s=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var i=r.length-1;0<=i;i--){var l=r[i],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==o&&s.isPropagationStopped())break e;nc(s,l,d),o=c}else for(i=0;i<r.length;i++){if(l=r[i],c=l.instance,d=l.currentTarget,l=l.listener,c!==o&&s.isPropagationStopped())break e;nc(s,l,d),o=c}}}if(Xs)throw e=Fo,Xs=!1,Fo=null,e}function we(e,t){var n=t[Yo];n===void 0&&(n=t[Yo]=new Set);var r=e+"__bubble";n.has(r)||(ud(t,e,2,!1),n.add(r))}function no(e,t,n){var r=0;t&&(r|=4),ud(n,e,r,t)}var js="_reactListening"+Math.random().toString(36).slice(2);function Jr(e){if(!e[js]){e[js]=!0,vu.forEach(function(n){n!=="selectionchange"&&(Bm.has(n)||no(n,!1,e),no(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[js]||(t[js]=!0,no("selectionchange",!1,t))}}function ud(e,t,n,r){switch(Ku(t)){case 1:var s=em;break;case 4:s=tm;break;default:s=Fi}n=s.bind(null,t,n,e),s=void 0,!Mo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),r?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}function ro(e,t,n,r,s){var o=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===s||l.nodeType===8&&l.parentNode===s)break;if(i===4)for(i=r.return;i!==null;){var c=i.tag;if((c===3||c===4)&&(c=i.stateNode.containerInfo,c===s||c.nodeType===8&&c.parentNode===s))return;i=i.return}for(;l!==null;){if(i=Nn(l),i===null)return;if(c=i.tag,c===5||c===6){r=o=i;continue e}l=l.parentNode}}r=r.return}_u(function(){var d=o,f=Ai(n),h=[];e:{var m=ld.get(e);if(m!==void 0){var x=Bi,w=e;switch(e){case"keypress":if(Fs(n)===0)break e;case"keydown":case"keyup":x=gm;break;case"focusin":w="focus",x=Ja;break;case"focusout":w="blur",x=Ja;break;case"beforeblur":case"afterblur":x=Ja;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":x=Hl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=sm;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=xm;break;case sd:case ad:case od:x=im;break;case id:x=Sm;break;case"scroll":x=nm;break;case"wheel":x=km;break;case"copy":case"cut":case"paste":x=cm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=Gl}var y=(t&4)!==0,j=!y&&e==="scroll",g=y?m!==null?m+"Capture":null:m;y=[];for(var p=d,v;p!==null;){v=p;var S=v.stateNode;if(v.tag===5&&S!==null&&(v=S,g!==null&&(S=Hr(p,g),S!=null&&y.push(Xr(p,S,v)))),j)break;p=p.return}0<y.length&&(m=new x(m,w,null,n,f),h.push({event:m,listeners:y}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",m&&n!==$o&&(w=n.relatedTarget||n.fromElement)&&(Nn(w)||w[Kt]))break e;if((x||m)&&(m=f.window===f?f:(m=f.ownerDocument)?m.defaultView||m.parentWindow:window,x?(w=n.relatedTarget||n.toElement,x=d,w=w?Nn(w):null,w!==null&&(j=Fn(w),w!==j||w.tag!==5&&w.tag!==6)&&(w=null)):(x=null,w=d),x!==w)){if(y=Hl,S="onMouseLeave",g="onMouseEnter",p="mouse",(e==="pointerout"||e==="pointerover")&&(y=Gl,S="onPointerLeave",g="onPointerEnter",p="pointer"),j=x==null?m:Gn(x),v=w==null?m:Gn(w),m=new y(S,p+"leave",x,n,f),m.target=j,m.relatedTarget=v,S=null,Nn(f)===d&&(y=new y(g,p+"enter",w,n,f),y.target=v,y.relatedTarget=j,S=y),j=S,x&&w)t:{for(y=x,g=w,p=0,v=y;v;v=Bn(v))p++;for(v=0,S=g;S;S=Bn(S))v++;for(;0<p-v;)y=Bn(y),p--;for(;0<v-p;)g=Bn(g),v--;for(;p--;){if(y===g||g!==null&&y===g.alternate)break t;y=Bn(y),g=Bn(g)}y=null}else y=null;x!==null&&rc(h,m,x,y,!1),w!==null&&j!==null&&rc(h,j,w,y,!0)}}e:{if(m=d?Gn(d):window,x=m.nodeName&&m.nodeName.toLowerCase(),x==="select"||x==="input"&&m.type==="file")var k=Im;else if(Ql(m))if(Zu)k=Am;else{k=Rm;var I=Pm}else(x=m.nodeName)&&x.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(k=_m);if(k&&(k=k(e,d))){qu(h,k,n,f);break e}I&&I(e,m,d),e==="focusout"&&(I=m._wrapperState)&&I.controlled&&m.type==="number"&&Io(m,"number",m.value)}switch(I=d?Gn(d):window,e){case"focusin":(Ql(I)||I.contentEditable==="true")&&(Hn=I,Uo=d,Lr=null);break;case"focusout":Lr=Uo=Hn=null;break;case"mousedown":Wo=!0;break;case"contextmenu":case"mouseup":case"dragend":Wo=!1,ec(h,n,f);break;case"selectionchange":if(Mm)break;case"keydown":case"keyup":ec(h,n,f)}var T;if(Ui)e:{switch(e){case"compositionstart":var P="onCompositionStart";break e;case"compositionend":P="onCompositionEnd";break e;case"compositionupdate":P="onCompositionUpdate";break e}P=void 0}else Wn?Ju(e,n)&&(P="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(P="onCompositionStart");P&&(Qu&&n.locale!=="ko"&&(Wn||P!=="onCompositionStart"?P==="onCompositionEnd"&&Wn&&(T=Yu()):(an=f,Oi="value"in an?an.value:an.textContent,Wn=!0)),I=na(d,P),0<I.length&&(P=new Vl(P,e,null,n,f),h.push({event:P,listeners:I}),T?P.data=T:(T=Xu(n),T!==null&&(P.data=T)))),(T=Cm?Nm(e,n):Em(e,n))&&(d=na(d,"onBeforeInput"),0<d.length&&(f=new Vl("onBeforeInput","beforeinput",null,n,f),h.push({event:f,listeners:d}),f.data=T))}cd(h,t)})}function Xr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function na(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=Hr(e,n),o!=null&&r.unshift(Xr(e,o,s)),o=Hr(e,t),o!=null&&r.push(Xr(e,o,s))),e=e.return}return r}function Bn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function rc(e,t,n,r,s){for(var o=t._reactName,i=[];n!==null&&n!==r;){var l=n,c=l.alternate,d=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&d!==null&&(l=d,s?(c=Hr(n,o),c!=null&&i.unshift(Xr(n,c,l))):s||(c=Hr(n,o),c!=null&&i.push(Xr(n,c,l)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var Dm=/\r\n?/g,Um=/\u0000|\uFFFD/g;function sc(e){return(typeof e=="string"?e:""+e).replace(Dm,`
|
|
38
|
-
`).replace(Um,"")}function ks(e,t,n){if(t=sc(t),sc(e)!==t&&n)throw Error(F(425))}function ra(){}var Ho=null,Vo=null;function Go(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 Ko=typeof setTimeout=="function"?setTimeout:void 0,Wm=typeof clearTimeout=="function"?clearTimeout:void 0,ac=typeof Promise=="function"?Promise:void 0,Hm=typeof queueMicrotask=="function"?queueMicrotask:typeof ac<"u"?function(e){return ac.resolve(null).then(e).catch(Vm)}:Ko;function Vm(e){setTimeout(function(){throw e})}function so(e,t){var n=t,r=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){e.removeChild(s),Kr(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Kr(t)}function dn(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 oc(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 mr=Math.random().toString(36).slice(2),$t="__reactFiber$"+mr,qr="__reactProps$"+mr,Kt="__reactContainer$"+mr,Yo="__reactEvents$"+mr,Gm="__reactListeners$"+mr,Km="__reactHandles$"+mr;function Nn(e){var t=e[$t];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Kt]||n[$t]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=oc(e);e!==null;){if(n=e[$t])return n;e=oc(e)}return t}e=n,n=e.parentNode}return null}function cs(e){return e=e[$t]||e[Kt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Gn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(F(33))}function Ea(e){return e[qr]||null}var Qo=[],Kn=-1;function xn(e){return{current:e}}function Se(e){0>Kn||(e.current=Qo[Kn],Qo[Kn]=null,Kn--)}function ye(e,t){Kn++,Qo[Kn]=e.current,e.current=t}var vn={},Ke=xn(vn),rt=xn(!1),Rn=vn;function or(e,t){var n=e.type.contextTypes;if(!n)return vn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in n)s[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function st(e){return e=e.childContextTypes,e!=null}function sa(){Se(rt),Se(Ke)}function ic(e,t,n){if(Ke.current!==vn)throw Error(F(168));ye(Ke,t),ye(rt,n)}function dd(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(F(108,Pp(e)||"Unknown",s));return Ne({},n,r)}function aa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||vn,Rn=Ke.current,ye(Ke,e),ye(rt,rt.current),!0}function lc(e,t,n){var r=e.stateNode;if(!r)throw Error(F(169));n?(e=dd(e,t,Rn),r.__reactInternalMemoizedMergedChildContext=e,Se(rt),Se(Ke),ye(Ke,e)):Se(rt),ye(rt,n)}var Ut=null,Ta=!1,ao=!1;function fd(e){Ut===null?Ut=[e]:Ut.push(e)}function Ym(e){Ta=!0,fd(e)}function wn(){if(!ao&&Ut!==null){ao=!0;var e=0,t=pe;try{var n=Ut;for(pe=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ut=null,Ta=!1}catch(s){throw Ut!==null&&(Ut=Ut.slice(e+1)),Mu($i,wn),s}finally{pe=t,ao=!1}}return null}var Yn=[],Qn=0,oa=null,ia=0,ht=[],gt=0,_n=null,Wt=1,Ht="";function kn(e,t){Yn[Qn++]=ia,Yn[Qn++]=oa,oa=e,ia=t}function pd(e,t,n){ht[gt++]=Wt,ht[gt++]=Ht,ht[gt++]=_n,_n=e;var r=Wt;e=Ht;var s=32-Tt(r)-1;r&=~(1<<s),n+=1;var o=32-Tt(t)+s;if(30<o){var i=s-s%5;o=(r&(1<<i)-1).toString(32),r>>=i,s-=i,Wt=1<<32-Tt(t)+s|n<<s|r,Ht=o+e}else Wt=1<<o|n<<s|r,Ht=e}function Hi(e){e.return!==null&&(kn(e,1),pd(e,1,0))}function Vi(e){for(;e===oa;)oa=Yn[--Qn],Yn[Qn]=null,ia=Yn[--Qn],Yn[Qn]=null;for(;e===_n;)_n=ht[--gt],ht[gt]=null,Ht=ht[--gt],ht[gt]=null,Wt=ht[--gt],ht[gt]=null}var ut=null,ct=null,je=!1,Et=null;function md(e,t){var n=vt(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 cc(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,ut=e,ct=dn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ut=e,ct=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=_n!==null?{id:Wt,overflow:Ht}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=vt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ut=e,ct=null,!0):!1;default:return!1}}function Jo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Xo(e){if(je){var t=ct;if(t){var n=t;if(!cc(e,t)){if(Jo(e))throw Error(F(418));t=dn(n.nextSibling);var r=ut;t&&cc(e,t)?md(r,n):(e.flags=e.flags&-4097|2,je=!1,ut=e)}}else{if(Jo(e))throw Error(F(418));e.flags=e.flags&-4097|2,je=!1,ut=e}}}function uc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ut=e}function bs(e){if(e!==ut)return!1;if(!je)return uc(e),je=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Go(e.type,e.memoizedProps)),t&&(t=ct)){if(Jo(e))throw hd(),Error(F(418));for(;t;)md(e,t),t=dn(t.nextSibling)}if(uc(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){ct=dn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ct=null}}else ct=ut?dn(e.stateNode.nextSibling):null;return!0}function hd(){for(var e=ct;e;)e=dn(e.nextSibling)}function ir(){ct=ut=null,je=!1}function Gi(e){Et===null?Et=[e]:Et.push(e)}var Qm=Xt.ReactCurrentBatchConfig;function kr(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 s=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(i){var l=s.refs;i===null?delete l[o]:l[o]=i},t._stringRef=o,t)}if(typeof e!="string")throw Error(F(284));if(!n._owner)throw Error(F(290,e))}return e}function Cs(e,t){throw e=Object.prototype.toString.call(t),Error(F(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function dc(e){var t=e._init;return t(e._payload)}function gd(e){function t(g,p){if(e){var v=g.deletions;v===null?(g.deletions=[p],g.flags|=16):v.push(p)}}function n(g,p){if(!e)return null;for(;p!==null;)t(g,p),p=p.sibling;return null}function r(g,p){for(g=new Map;p!==null;)p.key!==null?g.set(p.key,p):g.set(p.index,p),p=p.sibling;return g}function s(g,p){return g=hn(g,p),g.index=0,g.sibling=null,g}function o(g,p,v){return g.index=v,e?(v=g.alternate,v!==null?(v=v.index,v<p?(g.flags|=2,p):v):(g.flags|=2,p)):(g.flags|=1048576,p)}function i(g){return e&&g.alternate===null&&(g.flags|=2),g}function l(g,p,v,S){return p===null||p.tag!==6?(p=po(v,g.mode,S),p.return=g,p):(p=s(p,v),p.return=g,p)}function c(g,p,v,S){var k=v.type;return k===Un?f(g,p,v.props.children,S,v.key):p!==null&&(p.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===en&&dc(k)===p.type)?(S=s(p,v.props),S.ref=kr(g,p,v),S.return=g,S):(S=Vs(v.type,v.key,v.props,null,g.mode,S),S.ref=kr(g,p,v),S.return=g,S)}function d(g,p,v,S){return p===null||p.tag!==4||p.stateNode.containerInfo!==v.containerInfo||p.stateNode.implementation!==v.implementation?(p=mo(v,g.mode,S),p.return=g,p):(p=s(p,v.children||[]),p.return=g,p)}function f(g,p,v,S,k){return p===null||p.tag!==7?(p=Pn(v,g.mode,S,k),p.return=g,p):(p=s(p,v),p.return=g,p)}function h(g,p,v){if(typeof p=="string"&&p!==""||typeof p=="number")return p=po(""+p,g.mode,v),p.return=g,p;if(typeof p=="object"&&p!==null){switch(p.$$typeof){case ms:return v=Vs(p.type,p.key,p.props,null,g.mode,v),v.ref=kr(g,null,p),v.return=g,v;case Dn:return p=mo(p,g.mode,v),p.return=g,p;case en:var S=p._init;return h(g,S(p._payload),v)}if(Tr(p)||yr(p))return p=Pn(p,g.mode,v,null),p.return=g,p;Cs(g,p)}return null}function m(g,p,v,S){var k=p!==null?p.key:null;if(typeof v=="string"&&v!==""||typeof v=="number")return k!==null?null:l(g,p,""+v,S);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case ms:return v.key===k?c(g,p,v,S):null;case Dn:return v.key===k?d(g,p,v,S):null;case en:return k=v._init,m(g,p,k(v._payload),S)}if(Tr(v)||yr(v))return k!==null?null:f(g,p,v,S,null);Cs(g,v)}return null}function x(g,p,v,S,k){if(typeof S=="string"&&S!==""||typeof S=="number")return g=g.get(v)||null,l(p,g,""+S,k);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case ms:return g=g.get(S.key===null?v:S.key)||null,c(p,g,S,k);case Dn:return g=g.get(S.key===null?v:S.key)||null,d(p,g,S,k);case en:var I=S._init;return x(g,p,v,I(S._payload),k)}if(Tr(S)||yr(S))return g=g.get(v)||null,f(p,g,S,k,null);Cs(p,S)}return null}function w(g,p,v,S){for(var k=null,I=null,T=p,P=p=0,b=null;T!==null&&P<v.length;P++){T.index>P?(b=T,T=null):b=T.sibling;var N=m(g,T,v[P],S);if(N===null){T===null&&(T=b);break}e&&T&&N.alternate===null&&t(g,T),p=o(N,p,P),I===null?k=N:I.sibling=N,I=N,T=b}if(P===v.length)return n(g,T),je&&kn(g,P),k;if(T===null){for(;P<v.length;P++)T=h(g,v[P],S),T!==null&&(p=o(T,p,P),I===null?k=T:I.sibling=T,I=T);return je&&kn(g,P),k}for(T=r(g,T);P<v.length;P++)b=x(T,g,P,v[P],S),b!==null&&(e&&b.alternate!==null&&T.delete(b.key===null?P:b.key),p=o(b,p,P),I===null?k=b:I.sibling=b,I=b);return e&&T.forEach(function(O){return t(g,O)}),je&&kn(g,P),k}function y(g,p,v,S){var k=yr(v);if(typeof k!="function")throw Error(F(150));if(v=k.call(v),v==null)throw Error(F(151));for(var I=k=null,T=p,P=p=0,b=null,N=v.next();T!==null&&!N.done;P++,N=v.next()){T.index>P?(b=T,T=null):b=T.sibling;var O=m(g,T,N.value,S);if(O===null){T===null&&(T=b);break}e&&T&&O.alternate===null&&t(g,T),p=o(O,p,P),I===null?k=O:I.sibling=O,I=O,T=b}if(N.done)return n(g,T),je&&kn(g,P),k;if(T===null){for(;!N.done;P++,N=v.next())N=h(g,N.value,S),N!==null&&(p=o(N,p,P),I===null?k=N:I.sibling=N,I=N);return je&&kn(g,P),k}for(T=r(g,T);!N.done;P++,N=v.next())N=x(T,g,P,N.value,S),N!==null&&(e&&N.alternate!==null&&T.delete(N.key===null?P:N.key),p=o(N,p,P),I===null?k=N:I.sibling=N,I=N);return e&&T.forEach(function(Y){return t(g,Y)}),je&&kn(g,P),k}function j(g,p,v,S){if(typeof v=="object"&&v!==null&&v.type===Un&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case ms:e:{for(var k=v.key,I=p;I!==null;){if(I.key===k){if(k=v.type,k===Un){if(I.tag===7){n(g,I.sibling),p=s(I,v.props.children),p.return=g,g=p;break e}}else if(I.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===en&&dc(k)===I.type){n(g,I.sibling),p=s(I,v.props),p.ref=kr(g,I,v),p.return=g,g=p;break e}n(g,I);break}else t(g,I);I=I.sibling}v.type===Un?(p=Pn(v.props.children,g.mode,S,v.key),p.return=g,g=p):(S=Vs(v.type,v.key,v.props,null,g.mode,S),S.ref=kr(g,p,v),S.return=g,g=S)}return i(g);case Dn:e:{for(I=v.key;p!==null;){if(p.key===I)if(p.tag===4&&p.stateNode.containerInfo===v.containerInfo&&p.stateNode.implementation===v.implementation){n(g,p.sibling),p=s(p,v.children||[]),p.return=g,g=p;break e}else{n(g,p);break}else t(g,p);p=p.sibling}p=mo(v,g.mode,S),p.return=g,g=p}return i(g);case en:return I=v._init,j(g,p,I(v._payload),S)}if(Tr(v))return w(g,p,v,S);if(yr(v))return y(g,p,v,S);Cs(g,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,p!==null&&p.tag===6?(n(g,p.sibling),p=s(p,v),p.return=g,g=p):(n(g,p),p=po(v,g.mode,S),p.return=g,g=p),i(g)):n(g,p)}return j}var lr=gd(!0),vd=gd(!1),la=xn(null),ca=null,Jn=null,Ki=null;function Yi(){Ki=Jn=ca=null}function Qi(e){var t=la.current;Se(la),e._currentValue=t}function qo(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 rr(e,t){ca=e,Ki=Jn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(nt=!0),e.firstContext=null)}function xt(e){var t=e._currentValue;if(Ki!==e)if(e={context:e,memoizedValue:t,next:null},Jn===null){if(ca===null)throw Error(F(308));Jn=e,ca.dependencies={lanes:0,firstContext:e}}else Jn=Jn.next=e;return t}var En=null;function Ji(e){En===null?En=[e]:En.push(e)}function yd(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Ji(t)):(n.next=s.next,s.next=n),t.interleaved=n,Yt(e,r)}function Yt(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 tn=!1;function Xi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function xd(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 Vt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function fn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ie&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Yt(e,n)}return s=r.interleaved,s===null?(t.next=t,Ji(r)):(t.next=s.next,s.next=t),r.interleaved=t,Yt(e,n)}function Os(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,Li(e,n)}}function fc(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,o=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};o===null?s=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?s=o=t:o=o.next=t}else s=o=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:o,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 ua(e,t,n,r){var s=e.updateQueue;tn=!1;var o=s.firstBaseUpdate,i=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,d=c.next;c.next=null,i===null?o=d:i.next=d,i=c;var f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==i&&(l===null?f.firstBaseUpdate=d:l.next=d,f.lastBaseUpdate=c))}if(o!==null){var h=s.baseState;i=0,f=d=c=null,l=o;do{var m=l.lane,x=l.eventTime;if((r&m)===m){f!==null&&(f=f.next={eventTime:x,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var w=e,y=l;switch(m=t,x=n,y.tag){case 1:if(w=y.payload,typeof w=="function"){h=w.call(x,h,m);break e}h=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=y.payload,m=typeof w=="function"?w.call(x,h,m):w,m==null)break e;h=Ne({},h,m);break e;case 2:tn=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,m=s.effects,m===null?s.effects=[l]:m.push(l))}else x={eventTime:x,lane:m,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(d=f=x,c=h):f=f.next=x,i|=m;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;m=l,l=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(f===null&&(c=h),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=f,t=s.shared.interleaved,t!==null){s=t;do i|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);$n|=i,e.lanes=i,e.memoizedState=h}}function pc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(F(191,s));s.call(r)}}}var us={},Ft=xn(us),Zr=xn(us),es=xn(us);function Tn(e){if(e===us)throw Error(F(174));return e}function qi(e,t){switch(ye(es,t),ye(Zr,e),ye(Ft,us),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ro(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Ro(t,e)}Se(Ft),ye(Ft,t)}function cr(){Se(Ft),Se(Zr),Se(es)}function wd(e){Tn(es.current);var t=Tn(Ft.current),n=Ro(t,e.type);t!==n&&(ye(Zr,e),ye(Ft,n))}function Zi(e){Zr.current===e&&(Se(Ft),Se(Zr))}var be=xn(0);function da(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 oo=[];function el(){for(var e=0;e<oo.length;e++)oo[e]._workInProgressVersionPrimary=null;oo.length=0}var Bs=Xt.ReactCurrentDispatcher,io=Xt.ReactCurrentBatchConfig,An=0,Ce=null,_e=null,Me=null,fa=!1,Mr=!1,ts=0,Jm=0;function He(){throw Error(F(321))}function tl(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!It(e[n],t[n]))return!1;return!0}function nl(e,t,n,r,s,o){if(An=o,Ce=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Bs.current=e===null||e.memoizedState===null?eh:th,e=n(r,s),Mr){o=0;do{if(Mr=!1,ts=0,25<=o)throw Error(F(301));o+=1,Me=_e=null,t.updateQueue=null,Bs.current=nh,e=n(r,s)}while(Mr)}if(Bs.current=pa,t=_e!==null&&_e.next!==null,An=0,Me=_e=Ce=null,fa=!1,t)throw Error(F(300));return e}function rl(){var e=ts!==0;return ts=0,e}function _t(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Me===null?Ce.memoizedState=Me=e:Me=Me.next=e,Me}function wt(){if(_e===null){var e=Ce.alternate;e=e!==null?e.memoizedState:null}else e=_e.next;var t=Me===null?Ce.memoizedState:Me.next;if(t!==null)Me=t,_e=e;else{if(e===null)throw Error(F(310));_e=e,e={memoizedState:_e.memoizedState,baseState:_e.baseState,baseQueue:_e.baseQueue,queue:_e.queue,next:null},Me===null?Ce.memoizedState=Me=e:Me=Me.next=e}return Me}function ns(e,t){return typeof t=="function"?t(e):t}function lo(e){var t=wt(),n=t.queue;if(n===null)throw Error(F(311));n.lastRenderedReducer=e;var r=_e,s=r.baseQueue,o=n.pending;if(o!==null){if(s!==null){var i=s.next;s.next=o.next,o.next=i}r.baseQueue=s=o,n.pending=null}if(s!==null){o=s.next,r=r.baseState;var l=i=null,c=null,d=o;do{var f=d.lane;if((An&f)===f)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var h={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=h,i=r):c=c.next=h,Ce.lanes|=f,$n|=f}d=d.next}while(d!==null&&d!==o);c===null?i=r:c.next=l,It(r,t.memoizedState)||(nt=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do o=s.lane,Ce.lanes|=o,$n|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function co(e){var t=wt(),n=t.queue;if(n===null)throw Error(F(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,o=t.memoizedState;if(s!==null){n.pending=null;var i=s=s.next;do o=e(o,i.action),i=i.next;while(i!==s);It(o,t.memoizedState)||(nt=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Sd(){}function jd(e,t){var n=Ce,r=wt(),s=t(),o=!It(r.memoizedState,s);if(o&&(r.memoizedState=s,nt=!0),r=r.queue,sl(Cd.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||Me!==null&&Me.memoizedState.tag&1){if(n.flags|=2048,rs(9,bd.bind(null,n,r,s,t),void 0,null),Fe===null)throw Error(F(349));An&30||kd(n,t,s)}return s}function kd(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ce.updateQueue,t===null?(t={lastEffect:null,stores:null},Ce.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function bd(e,t,n,r){t.value=n,t.getSnapshot=r,Nd(t)&&Ed(e)}function Cd(e,t,n){return n(function(){Nd(t)&&Ed(e)})}function Nd(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!It(e,n)}catch{return!0}}function Ed(e){var t=Yt(e,1);t!==null&&zt(t,e,1,-1)}function mc(e){var t=_t();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ns,lastRenderedState:e},t.queue=e,e=e.dispatch=Zm.bind(null,Ce,e),[t.memoizedState,e]}function rs(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Ce.updateQueue,t===null?(t={lastEffect:null,stores:null},Ce.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 Td(){return wt().memoizedState}function Ds(e,t,n,r){var s=_t();Ce.flags|=e,s.memoizedState=rs(1|t,n,void 0,r===void 0?null:r)}function za(e,t,n,r){var s=wt();r=r===void 0?null:r;var o=void 0;if(_e!==null){var i=_e.memoizedState;if(o=i.destroy,r!==null&&tl(r,i.deps)){s.memoizedState=rs(t,n,o,r);return}}Ce.flags|=e,s.memoizedState=rs(1|t,n,o,r)}function hc(e,t){return Ds(8390656,8,e,t)}function sl(e,t){return za(2048,8,e,t)}function zd(e,t){return za(4,2,e,t)}function Id(e,t){return za(4,4,e,t)}function Pd(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 Rd(e,t,n){return n=n!=null?n.concat([e]):null,za(4,4,Pd.bind(null,t,e),n)}function al(){}function _d(e,t){var n=wt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&tl(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ad(e,t){var n=wt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&tl(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function $d(e,t,n){return An&21?(It(n,t)||(n=Bu(),Ce.lanes|=n,$n|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,nt=!0),e.memoizedState=n)}function Xm(e,t){var n=pe;pe=n!==0&&4>n?n:4,e(!0);var r=io.transition;io.transition={};try{e(!1),t()}finally{pe=n,io.transition=r}}function Ld(){return wt().memoizedState}function qm(e,t,n){var r=mn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Md(e))Fd(t,n);else if(n=yd(e,t,n,r),n!==null){var s=Je();zt(n,e,r,s),Od(n,t,r)}}function Zm(e,t,n){var r=mn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Md(e))Fd(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,l=o(i,n);if(s.hasEagerState=!0,s.eagerState=l,It(l,i)){var c=t.interleaved;c===null?(s.next=s,Ji(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=yd(e,t,s,r),n!==null&&(s=Je(),zt(n,e,r,s),Od(n,t,r))}}function Md(e){var t=e.alternate;return e===Ce||t!==null&&t===Ce}function Fd(e,t){Mr=fa=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Od(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Li(e,n)}}var pa={readContext:xt,useCallback:He,useContext:He,useEffect:He,useImperativeHandle:He,useInsertionEffect:He,useLayoutEffect:He,useMemo:He,useReducer:He,useRef:He,useState:He,useDebugValue:He,useDeferredValue:He,useTransition:He,useMutableSource:He,useSyncExternalStore:He,useId:He,unstable_isNewReconciler:!1},eh={readContext:xt,useCallback:function(e,t){return _t().memoizedState=[e,t===void 0?null:t],e},useContext:xt,useEffect:hc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ds(4194308,4,Pd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ds(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ds(4,2,e,t)},useMemo:function(e,t){var n=_t();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=_t();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=qm.bind(null,Ce,e),[r.memoizedState,e]},useRef:function(e){var t=_t();return e={current:e},t.memoizedState=e},useState:mc,useDebugValue:al,useDeferredValue:function(e){return _t().memoizedState=e},useTransition:function(){var e=mc(!1),t=e[0];return e=Xm.bind(null,e[1]),_t().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ce,s=_t();if(je){if(n===void 0)throw Error(F(407));n=n()}else{if(n=t(),Fe===null)throw Error(F(349));An&30||kd(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,hc(Cd.bind(null,r,o,e),[e]),r.flags|=2048,rs(9,bd.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=_t(),t=Fe.identifierPrefix;if(je){var n=Ht,r=Wt;n=(r&~(1<<32-Tt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ts++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Jm++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},th={readContext:xt,useCallback:_d,useContext:xt,useEffect:sl,useImperativeHandle:Rd,useInsertionEffect:zd,useLayoutEffect:Id,useMemo:Ad,useReducer:lo,useRef:Td,useState:function(){return lo(ns)},useDebugValue:al,useDeferredValue:function(e){var t=wt();return $d(t,_e.memoizedState,e)},useTransition:function(){var e=lo(ns)[0],t=wt().memoizedState;return[e,t]},useMutableSource:Sd,useSyncExternalStore:jd,useId:Ld,unstable_isNewReconciler:!1},nh={readContext:xt,useCallback:_d,useContext:xt,useEffect:sl,useImperativeHandle:Rd,useInsertionEffect:zd,useLayoutEffect:Id,useMemo:Ad,useReducer:co,useRef:Td,useState:function(){return co(ns)},useDebugValue:al,useDeferredValue:function(e){var t=wt();return _e===null?t.memoizedState=e:$d(t,_e.memoizedState,e)},useTransition:function(){var e=co(ns)[0],t=wt().memoizedState;return[e,t]},useMutableSource:Sd,useSyncExternalStore:jd,useId:Ld,unstable_isNewReconciler:!1};function Ct(e,t){if(e&&e.defaultProps){t=Ne({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Zo(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ne({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ia={isMounted:function(e){return(e=e._reactInternals)?Fn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Je(),s=mn(e),o=Vt(r,s);o.payload=t,n!=null&&(o.callback=n),t=fn(e,o,s),t!==null&&(zt(t,e,s,r),Os(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Je(),s=mn(e),o=Vt(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=fn(e,o,s),t!==null&&(zt(t,e,s,r),Os(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Je(),r=mn(e),s=Vt(n,r);s.tag=2,t!=null&&(s.callback=t),t=fn(e,s,r),t!==null&&(zt(t,e,r,n),Os(t,e,r))}};function gc(e,t,n,r,s,o,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,i):t.prototype&&t.prototype.isPureReactComponent?!Qr(n,r)||!Qr(s,o):!0}function Bd(e,t,n){var r=!1,s=vn,o=t.contextType;return typeof o=="object"&&o!==null?o=xt(o):(s=st(t)?Rn:Ke.current,r=t.contextTypes,o=(r=r!=null)?or(e,s):vn),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ia,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function vc(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&&Ia.enqueueReplaceState(t,t.state,null)}function ei(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},Xi(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=xt(o):(o=st(t)?Rn:Ke.current,s.context=or(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(Zo(e,t,o,n),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&Ia.enqueueReplaceState(s,s.state,null),ua(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function ur(e,t){try{var n="",r=t;do n+=Ip(r),r=r.return;while(r);var s=n}catch(o){s=`
|
|
39
|
-
Error generating stack: `+o.message+`
|
|
40
|
-
`+o.stack}return{value:e,source:t,stack:s,digest:null}}function uo(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ti(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var rh=typeof WeakMap=="function"?WeakMap:Map;function Dd(e,t,n){n=Vt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){ha||(ha=!0,di=r),ti(e,t)},n}function Ud(e,t,n){n=Vt(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var s=t.value;n.payload=function(){return r(s)},n.callback=function(){ti(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){ti(e,t),typeof r!="function"&&(pn===null?pn=new Set([this]):pn.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function yc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new rh;var s=new Set;r.set(t,s)}else s=r.get(t),s===void 0&&(s=new Set,r.set(t,s));s.has(n)||(s.add(n),e=vh.bind(null,e,t,n),t.then(e,e))}function xc(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 wc(e,t,n,r,s){return e.mode&1?(e.flags|=65536,e.lanes=s,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=Vt(-1,1),t.tag=2,fn(n,t,1))),n.lanes|=1),e)}var sh=Xt.ReactCurrentOwner,nt=!1;function Ye(e,t,n,r){t.child=e===null?vd(t,null,n,r):lr(t,e.child,n,r)}function Sc(e,t,n,r,s){n=n.render;var o=t.ref;return rr(t,s),r=nl(e,t,n,r,o,s),n=rl(),e!==null&&!nt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Qt(e,t,s)):(je&&n&&Hi(t),t.flags|=1,Ye(e,t,r,s),t.child)}function jc(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!pl(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,Wd(e,t,o,r,s)):(e=Vs(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&s)){var i=o.memoizedProps;if(n=n.compare,n=n!==null?n:Qr,n(i,r)&&e.ref===t.ref)return Qt(e,t,s)}return t.flags|=1,e=hn(o,r),e.ref=t.ref,e.return=t,t.child=e}function Wd(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(Qr(o,r)&&e.ref===t.ref)if(nt=!1,t.pendingProps=r=o,(e.lanes&s)!==0)e.flags&131072&&(nt=!0);else return t.lanes=e.lanes,Qt(e,t,s)}return ni(e,t,n,r,s)}function Hd(e,t,n){var r=t.pendingProps,s=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ye(qn,lt),lt|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,ye(qn,lt),lt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,ye(qn,lt),lt|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,ye(qn,lt),lt|=r;return Ye(e,t,s,n),t.child}function Vd(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function ni(e,t,n,r,s){var o=st(n)?Rn:Ke.current;return o=or(t,o),rr(t,s),n=nl(e,t,n,r,o,s),r=rl(),e!==null&&!nt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Qt(e,t,s)):(je&&r&&Hi(t),t.flags|=1,Ye(e,t,n,s),t.child)}function kc(e,t,n,r,s){if(st(n)){var o=!0;aa(t)}else o=!1;if(rr(t,s),t.stateNode===null)Us(e,t),Bd(t,n,r),ei(t,n,r,s),r=!0;else if(e===null){var i=t.stateNode,l=t.memoizedProps;i.props=l;var c=i.context,d=n.contextType;typeof d=="object"&&d!==null?d=xt(d):(d=st(n)?Rn:Ke.current,d=or(t,d));var f=n.getDerivedStateFromProps,h=typeof f=="function"||typeof i.getSnapshotBeforeUpdate=="function";h||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==r||c!==d)&&vc(t,i,r,d),tn=!1;var m=t.memoizedState;i.state=m,ua(t,r,i,s),c=t.memoizedState,l!==r||m!==c||rt.current||tn?(typeof f=="function"&&(Zo(t,n,f,r),c=t.memoizedState),(l=tn||gc(t,n,l,r,m,c,d))?(h||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=d,r=l):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,xd(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Ct(t.type,l),i.props=d,h=t.pendingProps,m=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=xt(c):(c=st(n)?Rn:Ke.current,c=or(t,c));var x=n.getDerivedStateFromProps;(f=typeof x=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==h||m!==c)&&vc(t,i,r,c),tn=!1,m=t.memoizedState,i.state=m,ua(t,r,i,s);var w=t.memoizedState;l!==h||m!==w||rt.current||tn?(typeof x=="function"&&(Zo(t,n,x,r),w=t.memoizedState),(d=tn||gc(t,n,d,r,m,w,c)||!1)?(f||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,w,c),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,w,c)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=w),i.props=r,i.state=w,i.context=c,r=d):(typeof i.componentDidUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return ri(e,t,n,r,o,s)}function ri(e,t,n,r,s,o){Vd(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return s&&lc(t,n,!1),Qt(e,t,o);r=t.stateNode,sh.current=t;var l=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=lr(t,e.child,null,o),t.child=lr(t,null,l,o)):Ye(e,t,l,o),t.memoizedState=r.state,s&&lc(t,n,!0),t.child}function Gd(e){var t=e.stateNode;t.pendingContext?ic(e,t.pendingContext,t.pendingContext!==t.context):t.context&&ic(e,t.context,!1),qi(e,t.containerInfo)}function bc(e,t,n,r,s){return ir(),Gi(s),t.flags|=256,Ye(e,t,n,r),t.child}var si={dehydrated:null,treeContext:null,retryLane:0};function ai(e){return{baseLanes:e,cachePool:null,transitions:null}}function Kd(e,t,n){var r=t.pendingProps,s=be.current,o=!1,i=(t.flags&128)!==0,l;if((l=i)||(l=e!==null&&e.memoizedState===null?!1:(s&2)!==0),l?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),ye(be,s&1),e===null)return Xo(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,o?(r=t.mode,o=t.child,i={mode:"hidden",children:i},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=i):o=_a(i,r,0,null),e=Pn(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=ai(n),t.memoizedState=si,e):ol(t,i));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return ah(e,t,i,r,l,s,n);if(o){o=r.fallback,i=t.mode,s=e.child,l=s.sibling;var c={mode:"hidden",children:r.children};return!(i&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=hn(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=hn(l,o):(o=Pn(o,i,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,i=e.child.memoizedState,i=i===null?ai(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},o.memoizedState=i,o.childLanes=e.childLanes&~n,t.memoizedState=si,r}return o=e.child,e=o.sibling,r=hn(o,{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 ol(e,t){return t=_a({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ns(e,t,n,r){return r!==null&&Gi(r),lr(t,e.child,null,n),e=ol(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function ah(e,t,n,r,s,o,i){if(n)return t.flags&256?(t.flags&=-257,r=uo(Error(F(422))),Ns(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=_a({mode:"visible",children:r.children},s,0,null),o=Pn(o,s,i,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&lr(t,e.child,null,i),t.child.memoizedState=ai(i),t.memoizedState=si,o);if(!(t.mode&1))return Ns(e,t,i,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(F(419)),r=uo(o,r,void 0),Ns(e,t,i,r)}if(l=(i&e.childLanes)!==0,nt||l){if(r=Fe,r!==null){switch(i&-i){case 4:s=2;break;case 16:s=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:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|i)?0:s,s!==0&&s!==o.retryLane&&(o.retryLane=s,Yt(e,s),zt(r,e,s,-1))}return fl(),r=uo(Error(F(421))),Ns(e,t,i,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=yh.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,ct=dn(s.nextSibling),ut=t,je=!0,Et=null,e!==null&&(ht[gt++]=Wt,ht[gt++]=Ht,ht[gt++]=_n,Wt=e.id,Ht=e.overflow,_n=t),t=ol(t,r.children),t.flags|=4096,t)}function Cc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),qo(e.return,t,n)}function fo(e,t,n,r,s){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=s)}function Yd(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(Ye(e,t,r.children,n),r=be.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&&Cc(e,n,t);else if(e.tag===19)Cc(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(ye(be,r),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&da(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),fo(t,!1,s,n,o);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&da(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}fo(t,!0,n,null,o);break;case"together":fo(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Us(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Qt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),$n|=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=hn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=hn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function oh(e,t,n){switch(t.tag){case 3:Gd(t),ir();break;case 5:wd(t);break;case 1:st(t.type)&&aa(t);break;case 4:qi(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;ye(la,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(ye(be,be.current&1),t.flags|=128,null):n&t.child.childLanes?Kd(e,t,n):(ye(be,be.current&1),e=Qt(e,t,n),e!==null?e.sibling:null);ye(be,be.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Yd(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),ye(be,be.current),r)break;return null;case 22:case 23:return t.lanes=0,Hd(e,t,n)}return Qt(e,t,n)}var Qd,oi,Jd,Xd;Qd=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}};oi=function(){};Jd=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Tn(Ft.current);var o=null;switch(n){case"input":s=To(e,s),r=To(e,r),o=[];break;case"select":s=Ne({},s,{value:void 0}),r=Ne({},r,{value:void 0}),o=[];break;case"textarea":s=Po(e,s),r=Po(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=ra)}_o(n,r);var i;n=null;for(d in s)if(!r.hasOwnProperty(d)&&s.hasOwnProperty(d)&&s[d]!=null)if(d==="style"){var l=s[d];for(i in l)l.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Ur.hasOwnProperty(d)?o||(o=[]):(o=o||[]).push(d,null));for(d in r){var c=r[d];if(l=s!=null?s[d]:void 0,r.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="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||(o||(o=[]),o.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(o=o||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Ur.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&we("scroll",e),o||l===c||(o=[])):(o=o||[]).push(d,c))}n&&(o=o||[]).push("style",n);var d=o;(t.updateQueue=d)&&(t.flags|=4)}};Xd=function(e,t,n,r){n!==r&&(t.flags|=4)};function br(e,t){if(!je)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 Ve(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function ih(e,t,n){var r=t.pendingProps;switch(Vi(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ve(t),null;case 1:return st(t.type)&&sa(),Ve(t),null;case 3:return r=t.stateNode,cr(),Se(rt),Se(Ke),el(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(bs(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Et!==null&&(mi(Et),Et=null))),oi(e,t),Ve(t),null;case 5:Zi(t);var s=Tn(es.current);if(n=t.type,e!==null&&t.stateNode!=null)Jd(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(F(166));return Ve(t),null}if(e=Tn(Ft.current),bs(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[$t]=t,r[qr]=o,e=(t.mode&1)!==0,n){case"dialog":we("cancel",r),we("close",r);break;case"iframe":case"object":case"embed":we("load",r);break;case"video":case"audio":for(s=0;s<Ir.length;s++)we(Ir[s],r);break;case"source":we("error",r);break;case"img":case"image":case"link":we("error",r),we("load",r);break;case"details":we("toggle",r);break;case"input":Al(r,o),we("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},we("invalid",r);break;case"textarea":Ll(r,o),we("invalid",r)}_o(n,o),s=null;for(var i in o)if(o.hasOwnProperty(i)){var l=o[i];i==="children"?typeof l=="string"?r.textContent!==l&&(o.suppressHydrationWarning!==!0&&ks(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&ks(r.textContent,l,e),s=["children",""+l]):Ur.hasOwnProperty(i)&&l!=null&&i==="onScroll"&&we("scroll",r)}switch(n){case"input":hs(r),$l(r,o,!0);break;case"textarea":hs(r),Ml(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=ra)}r=s,t.updateQueue=r,r!==null&&(t.flags|=4)}else{i=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Cu(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[$t]=t,e[qr]=r,Qd(e,t,!1,!1),t.stateNode=e;e:{switch(i=Ao(n,r),n){case"dialog":we("cancel",e),we("close",e),s=r;break;case"iframe":case"object":case"embed":we("load",e),s=r;break;case"video":case"audio":for(s=0;s<Ir.length;s++)we(Ir[s],e);s=r;break;case"source":we("error",e),s=r;break;case"img":case"image":case"link":we("error",e),we("load",e),s=r;break;case"details":we("toggle",e),s=r;break;case"input":Al(e,r),s=To(e,r),we("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Ne({},r,{value:void 0}),we("invalid",e);break;case"textarea":Ll(e,r),s=Po(e,r),we("invalid",e);break;default:s=r}_o(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?Tu(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Nu(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Wr(e,c):typeof c=="number"&&Wr(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Ur.hasOwnProperty(o)?c!=null&&o==="onScroll"&&we("scroll",e):c!=null&&Ii(e,o,c,i))}switch(n){case"input":hs(e),$l(e,r,!1);break;case"textarea":hs(e),Ml(e);break;case"option":r.value!=null&&e.setAttribute("value",""+gn(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?Zn(e,!!r.multiple,o,!1):r.defaultValue!=null&&Zn(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=ra)}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 Ve(t),null;case 6:if(e&&t.stateNode!=null)Xd(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(F(166));if(n=Tn(es.current),Tn(Ft.current),bs(t)){if(r=t.stateNode,n=t.memoizedProps,r[$t]=t,(o=r.nodeValue!==n)&&(e=ut,e!==null))switch(e.tag){case 3:ks(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&ks(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[$t]=t,t.stateNode=r}return Ve(t),null;case 13:if(Se(be),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(je&&ct!==null&&t.mode&1&&!(t.flags&128))hd(),ir(),t.flags|=98560,o=!1;else if(o=bs(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(F(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(F(317));o[$t]=t}else ir(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ve(t),o=!1}else Et!==null&&(mi(Et),Et=null),o=!0;if(!o)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||be.current&1?Ae===0&&(Ae=3):fl())),t.updateQueue!==null&&(t.flags|=4),Ve(t),null);case 4:return cr(),oi(e,t),e===null&&Jr(t.stateNode.containerInfo),Ve(t),null;case 10:return Qi(t.type._context),Ve(t),null;case 17:return st(t.type)&&sa(),Ve(t),null;case 19:if(Se(be),o=t.memoizedState,o===null)return Ve(t),null;if(r=(t.flags&128)!==0,i=o.rendering,i===null)if(r)br(o,!1);else{if(Ae!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=da(e),i!==null){for(t.flags|=128,br(o,!1),r=i.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,i=o.alternate,i===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=i.childLanes,o.lanes=i.lanes,o.child=i.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=i.memoizedProps,o.memoizedState=i.memoizedState,o.updateQueue=i.updateQueue,o.type=i.type,e=i.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return ye(be,be.current&1|2),t.child}e=e.sibling}o.tail!==null&&Ie()>dr&&(t.flags|=128,r=!0,br(o,!1),t.lanes=4194304)}else{if(!r)if(e=da(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),br(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!je)return Ve(t),null}else 2*Ie()-o.renderingStartTime>dr&&n!==1073741824&&(t.flags|=128,r=!0,br(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Ie(),t.sibling=null,n=be.current,ye(be,r?n&1|2:n&1),t):(Ve(t),null);case 22:case 23:return dl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?lt&1073741824&&(Ve(t),t.subtreeFlags&6&&(t.flags|=8192)):Ve(t),null;case 24:return null;case 25:return null}throw Error(F(156,t.tag))}function lh(e,t){switch(Vi(t),t.tag){case 1:return st(t.type)&&sa(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return cr(),Se(rt),Se(Ke),el(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Zi(t),null;case 13:if(Se(be),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(F(340));ir()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Se(be),null;case 4:return cr(),null;case 10:return Qi(t.type._context),null;case 22:case 23:return dl(),null;case 24:return null;default:return null}}var Es=!1,Ge=!1,ch=typeof WeakSet=="function"?WeakSet:Set,K=null;function Xn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Te(e,t,r)}else n.current=null}function ii(e,t,n){try{n()}catch(r){Te(e,t,r)}}var Nc=!1;function uh(e,t){if(Ho=ea,e=nd(),Wi(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 s=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,l=-1,c=-1,d=0,f=0,h=e,m=null;t:for(;;){for(var x;h!==n||s!==0&&h.nodeType!==3||(l=i+s),h!==o||r!==0&&h.nodeType!==3||(c=i+r),h.nodeType===3&&(i+=h.nodeValue.length),(x=h.firstChild)!==null;)m=h,h=x;for(;;){if(h===e)break t;if(m===n&&++d===s&&(l=i),m===o&&++f===r&&(c=i),(x=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=x}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Vo={focusedElem:e,selectionRange:n},ea=!1,K=t;K!==null;)if(t=K,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,K=e;else for(;K!==null;){t=K;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var y=w.memoizedProps,j=w.memoizedState,g=t.stateNode,p=g.getSnapshotBeforeUpdate(t.elementType===t.type?y:Ct(t.type,y),j);g.__reactInternalSnapshotBeforeUpdate=p}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(F(163))}}catch(S){Te(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,K=e;break}K=t.return}return w=Nc,Nc=!1,w}function Fr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var o=s.destroy;s.destroy=void 0,o!==void 0&&ii(t,n,o)}s=s.next}while(s!==r)}}function Pa(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 li(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 qd(e){var t=e.alternate;t!==null&&(e.alternate=null,qd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[$t],delete t[qr],delete t[Yo],delete t[Gm],delete t[Km])),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 Zd(e){return e.tag===5||e.tag===3||e.tag===4}function Ec(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Zd(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 ci(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=ra));else if(r!==4&&(e=e.child,e!==null))for(ci(e,t,n),e=e.sibling;e!==null;)ci(e,t,n),e=e.sibling}function ui(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(ui(e,t,n),e=e.sibling;e!==null;)ui(e,t,n),e=e.sibling}var De=null,Nt=!1;function Zt(e,t,n){for(n=n.child;n!==null;)ef(e,t,n),n=n.sibling}function ef(e,t,n){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(ka,n)}catch{}switch(n.tag){case 5:Ge||Xn(n,t);case 6:var r=De,s=Nt;De=null,Zt(e,t,n),De=r,Nt=s,De!==null&&(Nt?(e=De,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):De.removeChild(n.stateNode));break;case 18:De!==null&&(Nt?(e=De,n=n.stateNode,e.nodeType===8?so(e.parentNode,n):e.nodeType===1&&so(e,n),Kr(e)):so(De,n.stateNode));break;case 4:r=De,s=Nt,De=n.stateNode.containerInfo,Nt=!0,Zt(e,t,n),De=r,Nt=s;break;case 0:case 11:case 14:case 15:if(!Ge&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var o=s,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&ii(n,t,i),s=s.next}while(s!==r)}Zt(e,t,n);break;case 1:if(!Ge&&(Xn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Te(n,t,l)}Zt(e,t,n);break;case 21:Zt(e,t,n);break;case 22:n.mode&1?(Ge=(r=Ge)||n.memoizedState!==null,Zt(e,t,n),Ge=r):Zt(e,t,n);break;default:Zt(e,t,n)}}function Tc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new ch),t.forEach(function(r){var s=xh.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function bt(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var o=e,i=t,l=i;e:for(;l!==null;){switch(l.tag){case 5:De=l.stateNode,Nt=!1;break e;case 3:De=l.stateNode.containerInfo,Nt=!0;break e;case 4:De=l.stateNode.containerInfo,Nt=!0;break e}l=l.return}if(De===null)throw Error(F(160));ef(o,i,s),De=null,Nt=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){Te(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)tf(t,e),t=t.sibling}function tf(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(bt(t,e),Rt(e),r&4){try{Fr(3,e,e.return),Pa(3,e)}catch(y){Te(e,e.return,y)}try{Fr(5,e,e.return)}catch(y){Te(e,e.return,y)}}break;case 1:bt(t,e),Rt(e),r&512&&n!==null&&Xn(n,n.return);break;case 5:if(bt(t,e),Rt(e),r&512&&n!==null&&Xn(n,n.return),e.flags&32){var s=e.stateNode;try{Wr(s,"")}catch(y){Te(e,e.return,y)}}if(r&4&&(s=e.stateNode,s!=null)){var o=e.memoizedProps,i=n!==null?n.memoizedProps:o,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&o.type==="radio"&&o.name!=null&&ku(s,o),Ao(l,i);var d=Ao(l,o);for(i=0;i<c.length;i+=2){var f=c[i],h=c[i+1];f==="style"?Tu(s,h):f==="dangerouslySetInnerHTML"?Nu(s,h):f==="children"?Wr(s,h):Ii(s,f,h,d)}switch(l){case"input":zo(s,o);break;case"textarea":bu(s,o);break;case"select":var m=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var x=o.value;x!=null?Zn(s,!!o.multiple,x,!1):m!==!!o.multiple&&(o.defaultValue!=null?Zn(s,!!o.multiple,o.defaultValue,!0):Zn(s,!!o.multiple,o.multiple?[]:"",!1))}s[qr]=o}catch(y){Te(e,e.return,y)}}break;case 6:if(bt(t,e),Rt(e),r&4){if(e.stateNode===null)throw Error(F(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(y){Te(e,e.return,y)}}break;case 3:if(bt(t,e),Rt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Kr(t.containerInfo)}catch(y){Te(e,e.return,y)}break;case 4:bt(t,e),Rt(e);break;case 13:bt(t,e),Rt(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(cl=Ie())),r&4&&Tc(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Ge=(d=Ge)||f,bt(t,e),Ge=d):bt(t,e),Rt(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(K=e,f=e.child;f!==null;){for(h=K=f;K!==null;){switch(m=K,x=m.child,m.tag){case 0:case 11:case 14:case 15:Fr(4,m,m.return);break;case 1:Xn(m,m.return);var w=m.stateNode;if(typeof w.componentWillUnmount=="function"){r=m,n=m.return;try{t=r,w.props=t.memoizedProps,w.state=t.memoizedState,w.componentWillUnmount()}catch(y){Te(r,n,y)}}break;case 5:Xn(m,m.return);break;case 22:if(m.memoizedState!==null){Ic(h);continue}}x!==null?(x.return=m,K=x):Ic(h)}f=f.sibling}e:for(f=null,h=e;;){if(h.tag===5){if(f===null){f=h;try{s=h.stateNode,d?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=h.stateNode,c=h.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=Eu("display",i))}catch(y){Te(e,e.return,y)}}}else if(h.tag===6){if(f===null)try{h.stateNode.nodeValue=d?"":h.memoizedProps}catch(y){Te(e,e.return,y)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===e)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;h.sibling===null;){if(h.return===null||h.return===e)break e;f===h&&(f=null),h=h.return}f===h&&(f=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:bt(t,e),Rt(e),r&4&&Tc(e);break;case 21:break;default:bt(t,e),Rt(e)}}function Rt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Zd(n)){var r=n;break e}n=n.return}throw Error(F(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Wr(s,""),r.flags&=-33);var o=Ec(e);ui(e,o,s);break;case 3:case 4:var i=r.stateNode.containerInfo,l=Ec(e);ci(e,l,i);break;default:throw Error(F(161))}}catch(c){Te(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function dh(e,t,n){K=e,nf(e)}function nf(e,t,n){for(var r=(e.mode&1)!==0;K!==null;){var s=K,o=s.child;if(s.tag===22&&r){var i=s.memoizedState!==null||Es;if(!i){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Ge;l=Es;var d=Ge;if(Es=i,(Ge=c)&&!d)for(K=s;K!==null;)i=K,c=i.child,i.tag===22&&i.memoizedState!==null?Pc(s):c!==null?(c.return=i,K=c):Pc(s);for(;o!==null;)K=o,nf(o),o=o.sibling;K=s,Es=l,Ge=d}zc(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,K=o):zc(e)}}function zc(e){for(;K!==null;){var t=K;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ge||Pa(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Ge)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Ct(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&pc(t,o,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}pc(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 d=t.alternate;if(d!==null){var f=d.memoizedState;if(f!==null){var h=f.dehydrated;h!==null&&Kr(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(F(163))}Ge||t.flags&512&&li(t)}catch(m){Te(t,t.return,m)}}if(t===e){K=null;break}if(n=t.sibling,n!==null){n.return=t.return,K=n;break}K=t.return}}function Ic(e){for(;K!==null;){var t=K;if(t===e){K=null;break}var n=t.sibling;if(n!==null){n.return=t.return,K=n;break}K=t.return}}function Pc(e){for(;K!==null;){var t=K;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Pa(4,t)}catch(c){Te(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){Te(t,s,c)}}var o=t.return;try{li(t)}catch(c){Te(t,o,c)}break;case 5:var i=t.return;try{li(t)}catch(c){Te(t,i,c)}}}catch(c){Te(t,t.return,c)}if(t===e){K=null;break}var l=t.sibling;if(l!==null){l.return=t.return,K=l;break}K=t.return}}var fh=Math.ceil,ma=Xt.ReactCurrentDispatcher,il=Xt.ReactCurrentOwner,yt=Xt.ReactCurrentBatchConfig,ie=0,Fe=null,Re=null,Ue=0,lt=0,qn=xn(0),Ae=0,ss=null,$n=0,Ra=0,ll=0,Or=null,tt=null,cl=0,dr=1/0,Dt=null,ha=!1,di=null,pn=null,Ts=!1,on=null,ga=0,Br=0,fi=null,Ws=-1,Hs=0;function Je(){return ie&6?Ie():Ws!==-1?Ws:Ws=Ie()}function mn(e){return e.mode&1?ie&2&&Ue!==0?Ue&-Ue:Qm.transition!==null?(Hs===0&&(Hs=Bu()),Hs):(e=pe,e!==0||(e=window.event,e=e===void 0?16:Ku(e.type)),e):1}function zt(e,t,n,r){if(50<Br)throw Br=0,fi=null,Error(F(185));is(e,n,r),(!(ie&2)||e!==Fe)&&(e===Fe&&(!(ie&2)&&(Ra|=n),Ae===4&&sn(e,Ue)),at(e,r),n===1&&ie===0&&!(t.mode&1)&&(dr=Ie()+500,Ta&&wn()))}function at(e,t){var n=e.callbackNode;Qp(e,t);var r=Zs(e,e===Fe?Ue:0);if(r===0)n!==null&&Bl(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Bl(n),t===1)e.tag===0?Ym(Rc.bind(null,e)):fd(Rc.bind(null,e)),Hm(function(){!(ie&6)&&wn()}),n=null;else{switch(Du(r)){case 1:n=$i;break;case 4:n=Fu;break;case 16:n=qs;break;case 536870912:n=Ou;break;default:n=qs}n=df(n,rf.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function rf(e,t){if(Ws=-1,Hs=0,ie&6)throw Error(F(327));var n=e.callbackNode;if(sr()&&e.callbackNode!==n)return null;var r=Zs(e,e===Fe?Ue:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=va(e,r);else{t=r;var s=ie;ie|=2;var o=af();(Fe!==e||Ue!==t)&&(Dt=null,dr=Ie()+500,In(e,t));do try{hh();break}catch(l){sf(e,l)}while(!0);Yi(),ma.current=o,ie=s,Re!==null?t=0:(Fe=null,Ue=0,t=Ae)}if(t!==0){if(t===2&&(s=Oo(e),s!==0&&(r=s,t=pi(e,s))),t===1)throw n=ss,In(e,0),sn(e,r),at(e,Ie()),n;if(t===6)sn(e,r);else{if(s=e.current.alternate,!(r&30)&&!ph(s)&&(t=va(e,r),t===2&&(o=Oo(e),o!==0&&(r=o,t=pi(e,o))),t===1))throw n=ss,In(e,0),sn(e,r),at(e,Ie()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(F(345));case 2:bn(e,tt,Dt);break;case 3:if(sn(e,r),(r&130023424)===r&&(t=cl+500-Ie(),10<t)){if(Zs(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Je(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Ko(bn.bind(null,e,tt,Dt),t);break}bn(e,tt,Dt);break;case 4:if(sn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var i=31-Tt(r);o=1<<i,i=t[i],i>s&&(s=i),r&=~o}if(r=s,r=Ie()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*fh(r/1960))-r,10<r){e.timeoutHandle=Ko(bn.bind(null,e,tt,Dt),r);break}bn(e,tt,Dt);break;case 5:bn(e,tt,Dt);break;default:throw Error(F(329))}}}return at(e,Ie()),e.callbackNode===n?rf.bind(null,e):null}function pi(e,t){var n=Or;return e.current.memoizedState.isDehydrated&&(In(e,t).flags|=256),e=va(e,t),e!==2&&(t=tt,tt=n,t!==null&&mi(t)),e}function mi(e){tt===null?tt=e:tt.push.apply(tt,e)}function ph(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 s=n[r],o=s.getSnapshot;s=s.value;try{if(!It(o(),s))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 sn(e,t){for(t&=~ll,t&=~Ra,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Tt(t),r=1<<n;e[n]=-1,t&=~r}}function Rc(e){if(ie&6)throw Error(F(327));sr();var t=Zs(e,0);if(!(t&1))return at(e,Ie()),null;var n=va(e,t);if(e.tag!==0&&n===2){var r=Oo(e);r!==0&&(t=r,n=pi(e,r))}if(n===1)throw n=ss,In(e,0),sn(e,t),at(e,Ie()),n;if(n===6)throw Error(F(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,bn(e,tt,Dt),at(e,Ie()),null}function ul(e,t){var n=ie;ie|=1;try{return e(t)}finally{ie=n,ie===0&&(dr=Ie()+500,Ta&&wn())}}function Ln(e){on!==null&&on.tag===0&&!(ie&6)&&sr();var t=ie;ie|=1;var n=yt.transition,r=pe;try{if(yt.transition=null,pe=1,e)return e()}finally{pe=r,yt.transition=n,ie=t,!(ie&6)&&wn()}}function dl(){lt=qn.current,Se(qn)}function In(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Wm(n)),Re!==null)for(n=Re.return;n!==null;){var r=n;switch(Vi(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&sa();break;case 3:cr(),Se(rt),Se(Ke),el();break;case 5:Zi(r);break;case 4:cr();break;case 13:Se(be);break;case 19:Se(be);break;case 10:Qi(r.type._context);break;case 22:case 23:dl()}n=n.return}if(Fe=e,Re=e=hn(e.current,null),Ue=lt=t,Ae=0,ss=null,ll=Ra=$n=0,tt=Or=null,En!==null){for(t=0;t<En.length;t++)if(n=En[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,o=n.pending;if(o!==null){var i=o.next;o.next=s,r.next=i}n.pending=r}En=null}return e}function sf(e,t){do{var n=Re;try{if(Yi(),Bs.current=pa,fa){for(var r=Ce.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}fa=!1}if(An=0,Me=_e=Ce=null,Mr=!1,ts=0,il.current=null,n===null||n.return===null){Ae=1,ss=t,Re=null;break}e:{var o=e,i=n.return,l=n,c=t;if(t=Ue,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,f=l,h=f.tag;if(!(f.mode&1)&&(h===0||h===11||h===15)){var m=f.alternate;m?(f.updateQueue=m.updateQueue,f.memoizedState=m.memoizedState,f.lanes=m.lanes):(f.updateQueue=null,f.memoizedState=null)}var x=xc(i);if(x!==null){x.flags&=-257,wc(x,i,l,o,t),x.mode&1&&yc(o,d,t),t=x,c=d;var w=t.updateQueue;if(w===null){var y=new Set;y.add(c),t.updateQueue=y}else w.add(c);break e}else{if(!(t&1)){yc(o,d,t),fl();break e}c=Error(F(426))}}else if(je&&l.mode&1){var j=xc(i);if(j!==null){!(j.flags&65536)&&(j.flags|=256),wc(j,i,l,o,t),Gi(ur(c,l));break e}}o=c=ur(c,l),Ae!==4&&(Ae=2),Or===null?Or=[o]:Or.push(o),o=i;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=Dd(o,c,t);fc(o,g);break e;case 1:l=c;var p=o.type,v=o.stateNode;if(!(o.flags&128)&&(typeof p.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(pn===null||!pn.has(v)))){o.flags|=65536,t&=-t,o.lanes|=t;var S=Ud(o,l,t);fc(o,S);break e}}o=o.return}while(o!==null)}lf(n)}catch(k){t=k,Re===n&&n!==null&&(Re=n=n.return);continue}break}while(!0)}function af(){var e=ma.current;return ma.current=pa,e===null?pa:e}function fl(){(Ae===0||Ae===3||Ae===2)&&(Ae=4),Fe===null||!($n&268435455)&&!(Ra&268435455)||sn(Fe,Ue)}function va(e,t){var n=ie;ie|=2;var r=af();(Fe!==e||Ue!==t)&&(Dt=null,In(e,t));do try{mh();break}catch(s){sf(e,s)}while(!0);if(Yi(),ie=n,ma.current=r,Re!==null)throw Error(F(261));return Fe=null,Ue=0,Ae}function mh(){for(;Re!==null;)of(Re)}function hh(){for(;Re!==null&&!Bp();)of(Re)}function of(e){var t=uf(e.alternate,e,lt);e.memoizedProps=e.pendingProps,t===null?lf(e):Re=t,il.current=null}function lf(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=lh(n,t),n!==null){n.flags&=32767,Re=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Ae=6,Re=null;return}}else if(n=ih(n,t,lt),n!==null){Re=n;return}if(t=t.sibling,t!==null){Re=t;return}Re=t=e}while(t!==null);Ae===0&&(Ae=5)}function bn(e,t,n){var r=pe,s=yt.transition;try{yt.transition=null,pe=1,gh(e,t,n,r)}finally{yt.transition=s,pe=r}return null}function gh(e,t,n,r){do sr();while(on!==null);if(ie&6)throw Error(F(327));n=e.finishedWork;var s=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 o=n.lanes|n.childLanes;if(Jp(e,o),e===Fe&&(Re=Fe=null,Ue=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Ts||(Ts=!0,df(qs,function(){return sr(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=yt.transition,yt.transition=null;var i=pe;pe=1;var l=ie;ie|=4,il.current=null,uh(e,n),tf(n,e),Lm(Vo),ea=!!Ho,Vo=Ho=null,e.current=n,dh(n),Dp(),ie=l,pe=i,yt.transition=o}else e.current=n;if(Ts&&(Ts=!1,on=e,ga=s),o=e.pendingLanes,o===0&&(pn=null),Hp(n.stateNode),at(e,Ie()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)s=t[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(ha)throw ha=!1,e=di,di=null,e;return ga&1&&e.tag!==0&&sr(),o=e.pendingLanes,o&1?e===fi?Br++:(Br=0,fi=e):Br=0,wn(),null}function sr(){if(on!==null){var e=Du(ga),t=yt.transition,n=pe;try{if(yt.transition=null,pe=16>e?16:e,on===null)var r=!1;else{if(e=on,on=null,ga=0,ie&6)throw Error(F(331));var s=ie;for(ie|=4,K=e.current;K!==null;){var o=K,i=o.child;if(K.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(K=d;K!==null;){var f=K;switch(f.tag){case 0:case 11:case 15:Fr(8,f,o)}var h=f.child;if(h!==null)h.return=f,K=h;else for(;K!==null;){f=K;var m=f.sibling,x=f.return;if(qd(f),f===d){K=null;break}if(m!==null){m.return=x,K=m;break}K=x}}}var w=o.alternate;if(w!==null){var y=w.child;if(y!==null){w.child=null;do{var j=y.sibling;y.sibling=null,y=j}while(y!==null)}}K=o}}if(o.subtreeFlags&2064&&i!==null)i.return=o,K=i;else e:for(;K!==null;){if(o=K,o.flags&2048)switch(o.tag){case 0:case 11:case 15:Fr(9,o,o.return)}var g=o.sibling;if(g!==null){g.return=o.return,K=g;break e}K=o.return}}var p=e.current;for(K=p;K!==null;){i=K;var v=i.child;if(i.subtreeFlags&2064&&v!==null)v.return=i,K=v;else e:for(i=p;K!==null;){if(l=K,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Pa(9,l)}}catch(k){Te(l,l.return,k)}if(l===i){K=null;break e}var S=l.sibling;if(S!==null){S.return=l.return,K=S;break e}K=l.return}}if(ie=s,wn(),Mt&&typeof Mt.onPostCommitFiberRoot=="function")try{Mt.onPostCommitFiberRoot(ka,e)}catch{}r=!0}return r}finally{pe=n,yt.transition=t}}return!1}function _c(e,t,n){t=ur(n,t),t=Dd(e,t,1),e=fn(e,t,1),t=Je(),e!==null&&(is(e,1,t),at(e,t))}function Te(e,t,n){if(e.tag===3)_c(e,e,n);else for(;t!==null;){if(t.tag===3){_c(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(pn===null||!pn.has(r))){e=ur(n,e),e=Ud(t,e,1),t=fn(t,e,1),e=Je(),t!==null&&(is(t,1,e),at(t,e));break}}t=t.return}}function vh(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Je(),e.pingedLanes|=e.suspendedLanes&n,Fe===e&&(Ue&n)===n&&(Ae===4||Ae===3&&(Ue&130023424)===Ue&&500>Ie()-cl?In(e,0):ll|=n),at(e,t)}function cf(e,t){t===0&&(e.mode&1?(t=ys,ys<<=1,!(ys&130023424)&&(ys=4194304)):t=1);var n=Je();e=Yt(e,t),e!==null&&(is(e,t,n),at(e,n))}function yh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),cf(e,n)}function xh(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(F(314))}r!==null&&r.delete(t),cf(e,n)}var uf;uf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||rt.current)nt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return nt=!1,oh(e,t,n);nt=!!(e.flags&131072)}else nt=!1,je&&t.flags&1048576&&pd(t,ia,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Us(e,t),e=t.pendingProps;var s=or(t,Ke.current);rr(t,n),s=nl(null,t,r,e,s,n);var o=rl();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,st(r)?(o=!0,aa(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Xi(t),s.updater=Ia,t.stateNode=s,s._reactInternals=t,ei(t,r,e,n),t=ri(null,t,r,!0,o,n)):(t.tag=0,je&&o&&Hi(t),Ye(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Us(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=Sh(r),e=Ct(r,e),s){case 0:t=ni(null,t,r,e,n);break e;case 1:t=kc(null,t,r,e,n);break e;case 11:t=Sc(null,t,r,e,n);break e;case 14:t=jc(null,t,r,Ct(r.type,e),n);break e}throw Error(F(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),ni(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),kc(e,t,r,s,n);case 3:e:{if(Gd(t),e===null)throw Error(F(387));r=t.pendingProps,o=t.memoizedState,s=o.element,xd(e,t),ua(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){s=ur(Error(F(423)),t),t=bc(e,t,r,n,s);break e}else if(r!==s){s=ur(Error(F(424)),t),t=bc(e,t,r,n,s);break e}else for(ct=dn(t.stateNode.containerInfo.firstChild),ut=t,je=!0,Et=null,n=vd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(ir(),r===s){t=Qt(e,t,n);break e}Ye(e,t,r,n)}t=t.child}return t;case 5:return wd(t),e===null&&Xo(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,i=s.children,Go(r,s)?i=null:o!==null&&Go(r,o)&&(t.flags|=32),Vd(e,t),Ye(e,t,i,n),t.child;case 6:return e===null&&Xo(t),null;case 13:return Kd(e,t,n);case 4:return qi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=lr(t,null,r,n):Ye(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),Sc(e,t,r,s,n);case 7:return Ye(e,t,t.pendingProps,n),t.child;case 8:return Ye(e,t,t.pendingProps.children,n),t.child;case 12:return Ye(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,o=t.memoizedProps,i=s.value,ye(la,r._currentValue),r._currentValue=i,o!==null)if(It(o.value,i)){if(o.children===s.children&&!rt.current){t=Qt(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var l=o.dependencies;if(l!==null){i=o.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(o.tag===1){c=Vt(-1,n&-n),c.tag=2;var d=o.updateQueue;if(d!==null){d=d.shared;var f=d.pending;f===null?c.next=c:(c.next=f.next,f.next=c),d.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),qo(o.return,n,t),l.lanes|=n;break}c=c.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(F(341));i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),qo(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}Ye(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,rr(t,n),s=xt(s),r=r(s),t.flags|=1,Ye(e,t,r,n),t.child;case 14:return r=t.type,s=Ct(r,t.pendingProps),s=Ct(r.type,s),jc(e,t,r,s,n);case 15:return Wd(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ct(r,s),Us(e,t),t.tag=1,st(r)?(e=!0,aa(t)):e=!1,rr(t,n),Bd(t,r,s),ei(t,r,s,n),ri(null,t,r,!0,e,n);case 19:return Yd(e,t,n);case 22:return Hd(e,t,n)}throw Error(F(156,t.tag))};function df(e,t){return Mu(e,t)}function wh(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 vt(e,t,n,r){return new wh(e,t,n,r)}function pl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Sh(e){if(typeof e=="function")return pl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ri)return 11;if(e===_i)return 14}return 2}function hn(e,t){var n=e.alternate;return n===null?(n=vt(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 Vs(e,t,n,r,s,o){var i=2;if(r=e,typeof e=="function")pl(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Un:return Pn(n.children,s,o,t);case Pi:i=8,s|=8;break;case bo:return e=vt(12,n,t,s|2),e.elementType=bo,e.lanes=o,e;case Co:return e=vt(13,n,t,s),e.elementType=Co,e.lanes=o,e;case No:return e=vt(19,n,t,s),e.elementType=No,e.lanes=o,e;case wu:return _a(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case yu:i=10;break e;case xu:i=9;break e;case Ri:i=11;break e;case _i:i=14;break e;case en:i=16,r=null;break e}throw Error(F(130,e==null?e:typeof e,""))}return t=vt(i,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function Pn(e,t,n,r){return e=vt(7,e,r,t),e.lanes=n,e}function _a(e,t,n,r){return e=vt(22,e,r,t),e.elementType=wu,e.lanes=n,e.stateNode={isHidden:!1},e}function po(e,t,n){return e=vt(6,e,null,t),e.lanes=n,e}function mo(e,t,n){return t=vt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function jh(e,t,n,r,s){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=Ka(0),this.expirationTimes=Ka(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ka(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function ml(e,t,n,r,s,o,i,l,c){return e=new jh(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=vt(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Xi(o),e}function kh(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Dn,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function ff(e){if(!e)return vn;e=e._reactInternals;e:{if(Fn(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(st(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(st(n))return dd(e,n,t)}return t}function pf(e,t,n,r,s,o,i,l,c){return e=ml(n,r,!0,e,s,o,i,l,c),e.context=ff(null),n=e.current,r=Je(),s=mn(n),o=Vt(r,s),o.callback=t??null,fn(n,o,s),e.current.lanes=s,is(e,s,r),at(e,r),e}function Aa(e,t,n,r){var s=t.current,o=Je(),i=mn(s);return n=ff(n),t.context===null?t.context=n:t.pendingContext=n,t=Vt(o,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=fn(s,t,i),e!==null&&(zt(e,s,i,o),Os(e,s,i)),i}function ya(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 Ac(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function hl(e,t){Ac(e,t),(e=e.alternate)&&Ac(e,t)}function bh(){return null}var mf=typeof reportError=="function"?reportError:function(e){console.error(e)};function gl(e){this._internalRoot=e}$a.prototype.render=gl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(F(409));Aa(e,t,null,null)};$a.prototype.unmount=gl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ln(function(){Aa(null,e,null,null)}),t[Kt]=null}};function $a(e){this._internalRoot=e}$a.prototype.unstable_scheduleHydration=function(e){if(e){var t=Hu();e={blockedOn:null,target:e,priority:t};for(var n=0;n<rn.length&&t!==0&&t<rn[n].priority;n++);rn.splice(n,0,e),n===0&&Gu(e)}};function vl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function La(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function $c(){}function Ch(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var d=ya(i);o.call(d)}}var i=pf(t,r,e,0,null,!1,!1,"",$c);return e._reactRootContainer=i,e[Kt]=i.current,Jr(e.nodeType===8?e.parentNode:e),Ln(),i}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=ya(c);l.call(d)}}var c=ml(e,0,!1,null,null,!1,!1,"",$c);return e._reactRootContainer=c,e[Kt]=c.current,Jr(e.nodeType===8?e.parentNode:e),Ln(function(){Aa(t,c,n,r)}),c}function Ma(e,t,n,r,s){var o=n._reactRootContainer;if(o){var i=o;if(typeof s=="function"){var l=s;s=function(){var c=ya(i);l.call(c)}}Aa(t,i,e,s)}else i=Ch(n,t,e,s,r);return ya(i)}Uu=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=zr(t.pendingLanes);n!==0&&(Li(t,n|1),at(t,Ie()),!(ie&6)&&(dr=Ie()+500,wn()))}break;case 13:Ln(function(){var r=Yt(e,1);if(r!==null){var s=Je();zt(r,e,1,s)}}),hl(e,1)}};Mi=function(e){if(e.tag===13){var t=Yt(e,134217728);if(t!==null){var n=Je();zt(t,e,134217728,n)}hl(e,134217728)}};Wu=function(e){if(e.tag===13){var t=mn(e),n=Yt(e,t);if(n!==null){var r=Je();zt(n,e,t,r)}hl(e,t)}};Hu=function(){return pe};Vu=function(e,t){var n=pe;try{return pe=e,t()}finally{pe=n}};Lo=function(e,t,n){switch(t){case"input":if(zo(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 s=Ea(r);if(!s)throw Error(F(90));ju(r),zo(r,s)}}}break;case"textarea":bu(e,n);break;case"select":t=n.value,t!=null&&Zn(e,!!n.multiple,t,!1)}};Pu=ul;Ru=Ln;var Nh={usingClientEntryPoint:!1,Events:[cs,Gn,Ea,zu,Iu,ul]},Cr={findFiberByHostInstance:Nn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Eh={bundleType:Cr.bundleType,version:Cr.version,rendererPackageName:Cr.rendererPackageName,rendererConfig:Cr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Xt.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=$u(e),e===null?null:e.stateNode},findFiberByHostInstance:Cr.findFiberByHostInstance||bh,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 zs=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zs.isDisabled&&zs.supportsFiber)try{ka=zs.inject(Eh),Mt=zs}catch{}}ft.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Nh;ft.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!vl(t))throw Error(F(200));return kh(e,t,null,n)};ft.createRoot=function(e,t){if(!vl(e))throw Error(F(299));var n=!1,r="",s=mf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=ml(e,1,!1,null,null,n,!1,r,s),e[Kt]=t.current,Jr(e.nodeType===8?e.parentNode:e),new gl(t)};ft.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=$u(t),e=e===null?null:e.stateNode,e};ft.flushSync=function(e){return Ln(e)};ft.hydrate=function(e,t,n){if(!La(t))throw Error(F(200));return Ma(null,e,t,!0,n)};ft.hydrateRoot=function(e,t,n){if(!vl(e))throw Error(F(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",i=mf;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=pf(t,null,e,1,n??null,s,!1,o,i),e[Kt]=t.current,Jr(e),r)for(e=0;e<r.length;e++)n=r[e],s=n._getVersion,s=s(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,s]:t.mutableSourceEagerHydrationData.push(n,s);return new $a(t)};ft.render=function(e,t,n){if(!La(t))throw Error(F(200));return Ma(null,e,t,!1,n)};ft.unmountComponentAtNode=function(e){if(!La(e))throw Error(F(40));return e._reactRootContainer?(Ln(function(){Ma(null,null,e,!1,function(){e._reactRootContainer=null,e[Kt]=null})}),!0):!1};ft.unstable_batchedUpdates=ul;ft.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!La(n))throw Error(F(200));if(e==null||e._reactInternals===void 0)throw Error(F(38));return Ma(e,t,n,!1,r)};ft.version="18.3.1-next-f1338f8080-20240426";function hf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(hf)}catch(e){console.error(e)}}hf(),mu.exports=ft;var gf=mu.exports,vf,Lc=gf;vf=Lc.createRoot,Lc.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 Mc="popstate";function Fc(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Th(e={}){function t(r,s){var d;let o=(d=s.state)==null?void 0:d.masked,{pathname:i,search:l,hash:c}=o||r.location;return hi("",{pathname:i,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default",o?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,s){return typeof s=="string"?s:as(s)}return Ih(t,n,null,e)}function ke(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function St(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function zh(){return Math.random().toString(36).substring(2,10)}function Oc(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 hi(e,t,n=null,r,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?hr(t):t,state:n,key:t&&t.key||r||zh(),unstable_mask:s}}function as({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 hr(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 Ih(e,t,n,r={}){let{window:s=document.defaultView,v5Compat:o=!1}=r,i=s.history,l="POP",c=null,d=f();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function f(){return(i.state||{idx:null}).idx}function h(){l="POP";let j=f(),g=j==null?null:j-d;d=j,c&&c({action:l,location:y.location,delta:g})}function m(j,g){l="PUSH";let p=Fc(j)?j:hi(y.location,j,g);d=f()+1;let v=Oc(p,d),S=y.createHref(p.unstable_mask||p);try{i.pushState(v,"",S)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;s.location.assign(S)}o&&c&&c({action:l,location:y.location,delta:1})}function x(j,g){l="REPLACE";let p=Fc(j)?j:hi(y.location,j,g);d=f();let v=Oc(p,d),S=y.createHref(p.unstable_mask||p);i.replaceState(v,"",S),o&&c&&c({action:l,location:y.location,delta:0})}function w(j){return Ph(j)}let y={get action(){return l},get location(){return e(s,i)},listen(j){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(Mc,h),c=j,()=>{s.removeEventListener(Mc,h),c=null}},createHref(j){return t(s,j)},createURL:w,encodeLocation(j){let g=w(j);return{pathname:g.pathname,search:g.search,hash:g.hash}},push:m,replace:x,go(j){return i.go(j)}};return y}function Ph(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ke(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:as(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function yf(e,t,n="/"){return Rh(e,t,n,!1)}function Rh(e,t,n,r){let s=typeof t=="string"?hr(t):t,o=Jt(s.pathname||"/",n);if(o==null)return null;let i=xf(e);_h(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let d=Hh(o);l=Uh(i[c],d,r)}return l}function xf(e,t=[],n=[],r="",s=!1){let o=(i,l,c=s,d)=>{let f={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&c)return;ke(f.relativePath.startsWith(r),`Absolute route path "${f.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(r.length)}let h=Ot([r,f.relativePath]),m=n.concat(f);i.children&&i.children.length>0&&(ke(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),xf(i.children,t,m,h,c)),!(i.path==null&&!i.index)&&t.push({path:h,score:Bh(h,i.index),routesMeta:m})};return e.forEach((i,l)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))o(i,l);else for(let d of wf(i.path))o(i,l,!0,d)}),t}function wf(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return s?[o,""]:[o];let i=wf(r.join("/")),l=[];return l.push(...i.map(c=>c===""?o:[o,c].join("/"))),s&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function _h(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Dh(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Ah=/^:[\w-]+$/,$h=3,Lh=2,Mh=1,Fh=10,Oh=-2,Bc=e=>e==="*";function Bh(e,t){let n=e.split("/"),r=n.length;return n.some(Bc)&&(r+=Oh),t&&(r+=Lh),n.filter(s=>!Bc(s)).reduce((s,o)=>s+(Ah.test(o)?$h:o===""?Mh:Fh),r)}function Dh(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function Uh(e,t,n=!1){let{routesMeta:r}=e,s={},o="/",i=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,f=o==="/"?t:t.slice(o.length)||"/",h=xa({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),m=c.route;if(!h&&d&&n&&!r[r.length-1].route.index&&(h=xa({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!h)return null;Object.assign(s,h.params),i.push({params:s,pathname:Ot([o,h.pathname]),pathnameBase:Yh(Ot([o,h.pathnameBase])),route:m}),h.pathnameBase!=="/"&&(o=Ot([o,h.pathnameBase]))}return i}function xa(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Wh(e.path,e.caseSensitive,e.end),s=t.match(n);if(!s)return null;let o=s[0],i=o.replace(/(.)\/+$/,"$1"),l=s.slice(1);return{params:r.reduce((d,{paramName:f,isOptional:h},m)=>{if(f==="*"){let w=l[m]||"";i=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const x=l[m];return h&&!x?d[f]=void 0:d[f]=(x||"").replace(/%2F/g,"/"),d},{}),pathname:o,pathnameBase:i,pattern:e}}function Wh(e,t=!1,n=!0){St(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=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,d,f)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let h=f.charAt(d+i.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Hh(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return St(!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 Jt(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 Vh=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Gh(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?hr(e):e,o;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?o=Dc(n.substring(1),"/"):o=Dc(n,t)):o=t,{pathname:o,search:Qh(r),hash:Jh(s)}}function Dc(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function ho(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 Kh(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function yl(e){let t=Kh(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Fa(e,t,n,r=!1){let s;typeof e=="string"?s=hr(e):(s={...e},ke(!s.pathname||!s.pathname.includes("?"),ho("?","pathname","search",s)),ke(!s.pathname||!s.pathname.includes("#"),ho("#","pathname","hash",s)),ke(!s.search||!s.search.includes("#"),ho("#","search","hash",s)));let o=e===""||s.pathname==="",i=o?"/":s.pathname,l;if(i==null)l=n;else{let h=t.length-1;if(!r&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),h-=1;s.pathname=m.join("/")}l=h>=0?t[h]:"/"}let c=Gh(s,l),d=i&&i!=="/"&&i.endsWith("/"),f=(o||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Ot=e=>e.join("/").replace(/\/\/+/g,"/"),Yh=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Qh=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Jh=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Xh=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 qh(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Zh(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Sf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function jf(e,t){let n=e;if(typeof n!="string"||!Vh.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,s=!1;if(Sf)try{let o=new URL(window.location.href),i=n.startsWith("//")?new URL(o.protocol+n):new URL(n),l=Jt(i.pathname,t);i.origin===o.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{St(!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:s,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var kf=["POST","PUT","PATCH","DELETE"];new Set(kf);var eg=["GET",...kf];new Set(eg);var gr=u.createContext(null);gr.displayName="DataRouter";var Oa=u.createContext(null);Oa.displayName="DataRouterState";var tg=u.createContext(!1),bf=u.createContext({isTransitioning:!1});bf.displayName="ViewTransition";var ng=u.createContext(new Map);ng.displayName="Fetchers";var rg=u.createContext(null);rg.displayName="Await";var mt=u.createContext(null);mt.displayName="Navigation";var ds=u.createContext(null);ds.displayName="Location";var Pt=u.createContext({outlet:null,matches:[],isDataRoute:!1});Pt.displayName="Route";var xl=u.createContext(null);xl.displayName="RouteError";var Cf="REACT_ROUTER_ERROR",sg="REDIRECT",ag="ROUTE_ERROR_RESPONSE";function og(e){if(e.startsWith(`${Cf}:${sg}:{`))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 ig(e){if(e.startsWith(`${Cf}:${ag}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Xh(t.status,t.statusText,t.data)}catch{}}function lg(e,{relative:t}={}){ke(vr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=u.useContext(mt),{hash:s,pathname:o,search:i}=fs(e,{relative:t}),l=o;return n!=="/"&&(l=o==="/"?n:Ot([n,o])),r.createHref({pathname:l,search:i,hash:s})}function vr(){return u.useContext(ds)!=null}function jt(){return ke(vr(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(ds).location}var Nf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ef(e){u.useContext(mt).static||u.useLayoutEffect(e)}function qt(){let{isDataRoute:e}=u.useContext(Pt);return e?kg():cg()}function cg(){ke(vr(),"useNavigate() may be used only in the context of a <Router> component.");let e=u.useContext(gr),{basename:t,navigator:n}=u.useContext(mt),{matches:r}=u.useContext(Pt),{pathname:s}=jt(),o=JSON.stringify(yl(r)),i=u.useRef(!1);return Ef(()=>{i.current=!0}),u.useCallback((c,d={})=>{if(St(i.current,Nf),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=Fa(c,JSON.parse(o),s,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Ot([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,o,s,e])}var ug=u.createContext(null);function dg(e){let t=u.useContext(Pt).outlet;return u.useMemo(()=>t&&u.createElement(ug.Provider,{value:e},t),[t,e])}function fs(e,{relative:t}={}){let{matches:n}=u.useContext(Pt),{pathname:r}=jt(),s=JSON.stringify(yl(n));return u.useMemo(()=>Fa(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function fg(e,t){return Tf(e,t)}function Tf(e,t,n){var j;ke(vr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=u.useContext(mt),{matches:s}=u.useContext(Pt),o=s[s.length-1],i=o?o.params:{},l=o?o.pathname:"/",c=o?o.pathnameBase:"/",d=o&&o.route;{let g=d&&d.path||"";If(l,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${g}">) 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="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let f=jt(),h;if(t){let g=typeof t=="string"?hr(t):t;ke(c==="/"||((j=g.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 "${g.pathname}" was given in the \`location\` prop.`),h=g}else h=f;let m=h.pathname||"/",x=m;if(c!=="/"){let g=c.replace(/^\//,"").split("/");x="/"+m.replace(/^\//,"").split("/").slice(g.length).join("/")}let w=yf(e,{pathname:x});St(d||w!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),St(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.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 y=vg(w&&w.map(g=>Object.assign({},g,{params:Object.assign({},i,g.params),pathname:Ot([c,r.encodeLocation?r.encodeLocation(g.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:Ot([c,r.encodeLocation?r.encodeLocation(g.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),s,n);return t&&y?u.createElement(ds.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...h},navigationType:"POP"}},y):y}function pg(){let e=jg(),t=qh(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)",s={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=u.createElement(u.Fragment,null,u.createElement("p",null,"💿 Hey developer 👋"),u.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",u.createElement("code",{style:o},"ErrorBoundary")," or"," ",u.createElement("code",{style:o},"errorElement")," prop on your route.")),u.createElement(u.Fragment,null,u.createElement("h2",null,"Unexpected Application Error!"),u.createElement("h3",{style:{fontStyle:"italic"}},t),n?u.createElement("pre",{style:s},n):null,i)}var mg=u.createElement(pg,null),zf=class extends u.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=ig(e.digest);n&&(e=n)}let t=e!==void 0?u.createElement(Pt.Provider,{value:this.props.routeContext},u.createElement(xl.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?u.createElement(hg,{error:e},t):t}};zf.contextType=tg;var go=new WeakMap;function hg({children:e,error:t}){let{basename:n}=u.useContext(mt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=og(t.digest);if(r){let s=go.get(t);if(s)throw s;let o=jf(r.location,n);if(Sf&&!go.get(t))if(o.isExternal||r.reloadDocument)window.location.href=o.absoluteURL||o.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:r.replace}));throw go.set(t,i),i}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return e}function gg({routeContext:e,match:t,children:n}){let r=u.useContext(gr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),u.createElement(Pt.Provider,{value:e},n)}function vg(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 s=e,o=r==null?void 0:r.errors;if(o!=null){let f=s.findIndex(h=>h.route.id&&(o==null?void 0:o[h.route.id])!==void 0);ke(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),s=s.slice(0,Math.min(s.length,f+1))}let i=!1,l=-1;if(n&&r){i=r.renderFallback;for(let f=0;f<s.length;f++){let h=s[f];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(l=f),h.route.id){let{loaderData:m,errors:x}=r,w=h.route.loader&&!m.hasOwnProperty(h.route.id)&&(!x||x[h.route.id]===void 0);if(h.route.lazy||w){n.isStatic&&(i=!0),l>=0?s=s.slice(0,l+1):s=[s[0]];break}}}}let c=n==null?void 0:n.onError,d=r&&c?(f,h)=>{var m,x;c(f,{location:r.location,params:((x=(m=r.matches)==null?void 0:m[0])==null?void 0:x.params)??{},unstable_pattern:Zh(r.matches),errorInfo:h})}:void 0;return s.reduceRight((f,h,m)=>{let x,w=!1,y=null,j=null;r&&(x=o&&h.route.id?o[h.route.id]:void 0,y=h.route.errorElement||mg,i&&(l<0&&m===0?(If("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),w=!0,j=null):l===m&&(w=!0,j=h.route.hydrateFallbackElement||null)));let g=t.concat(s.slice(0,m+1)),p=()=>{let v;return x?v=y:w?v=j:h.route.Component?v=u.createElement(h.route.Component,null):h.route.element?v=h.route.element:v=f,u.createElement(gg,{match:h,routeContext:{outlet:f,matches:g,isDataRoute:r!=null},children:v})};return r&&(h.route.ErrorBoundary||h.route.errorElement||m===0)?u.createElement(zf,{location:r.location,revalidation:r.revalidation,component:y,error:x,children:p(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:d}):p()},null)}function wl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function yg(e){let t=u.useContext(gr);return ke(t,wl(e)),t}function xg(e){let t=u.useContext(Oa);return ke(t,wl(e)),t}function wg(e){let t=u.useContext(Pt);return ke(t,wl(e)),t}function Sl(e){let t=wg(e),n=t.matches[t.matches.length-1];return ke(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Sg(){return Sl("useRouteId")}function jg(){var r;let e=u.useContext(xl),t=xg("useRouteError"),n=Sl("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function kg(){let{router:e}=yg("useNavigate"),t=Sl("useNavigate"),n=u.useRef(!1);return Ef(()=>{n.current=!0}),u.useCallback(async(s,o={})=>{St(n.current,Nf),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...o}))},[e,t])}var Uc={};function If(e,t,n){!t&&!Uc[e]&&(Uc[e]=!0,St(!1,n))}u.memo(bg);function bg({routes:e,future:t,state:n,isStatic:r,onError:s}){return Tf(e,void 0,{state:n,isStatic:r,onError:s})}function nn({to:e,replace:t,state:n,relative:r}){ke(vr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=u.useContext(mt);St(!s,"<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:o}=u.useContext(Pt),{pathname:i}=jt(),l=qt(),c=Fa(e,yl(o),i,r==="path"),d=JSON.stringify(c);return u.useEffect(()=>{l(JSON.parse(d),{replace:t,state:n,relative:r})},[l,d,r,t,n]),null}function Cg(e){return dg(e.context)}function Le(e){ke(!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 Ng({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:o=!1,unstable_useTransitions:i}){ke(!vr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=u.useMemo(()=>({basename:l,navigator:s,static:o,unstable_useTransitions:i,future:{}}),[l,s,o,i]);typeof n=="string"&&(n=hr(n));let{pathname:d="/",search:f="",hash:h="",state:m=null,key:x="default",unstable_mask:w}=n,y=u.useMemo(()=>{let j=Jt(d,l);return j==null?null:{location:{pathname:j,search:f,hash:h,state:m,key:x,unstable_mask:w},navigationType:r}},[l,d,f,h,m,x,r,w]);return St(y!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${h}" because it does not start with the basename, so the <Router> won't render anything.`),y==null?null:u.createElement(mt.Provider,{value:c},u.createElement(ds.Provider,{children:t,value:y}))}function Eg({children:e,location:t}){return fg(gi(e),t)}function gi(e,t=[]){let n=[];return u.Children.forEach(e,(r,s)=>{if(!u.isValidElement(r))return;let o=[...t,s];if(r.type===u.Fragment){n.push.apply(n,gi(r.props.children,o));return}ke(r.type===Le,`[${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>`),ke(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||o.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=gi(r.props.children,o)),n.push(i)}),n}var Gs="get",Ks="application/x-www-form-urlencoded";function Ba(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Tg(e){return Ba(e)&&e.tagName.toLowerCase()==="button"}function zg(e){return Ba(e)&&e.tagName.toLowerCase()==="form"}function Ig(e){return Ba(e)&&e.tagName.toLowerCase()==="input"}function Pg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Rg(e,t){return e.button===0&&(!t||t==="_self")&&!Pg(e)}function vi(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(s=>[n,s]):[[n,r]])},[]))}function _g(e,t){let n=vi(e);return t&&t.forEach((r,s)=>{n.has(s)||t.getAll(s).forEach(o=>{n.append(s,o)})}),n}var Is=null;function Ag(){if(Is===null)try{new FormData(document.createElement("form"),0),Is=!1}catch{Is=!0}return Is}var $g=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function vo(e){return e!=null&&!$g.has(e)?(St(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ks}"`),null):e}function Lg(e,t){let n,r,s,o,i;if(zg(e)){let l=e.getAttribute("action");r=l?Jt(l,t):null,n=e.getAttribute("method")||Gs,s=vo(e.getAttribute("enctype"))||Ks,o=new FormData(e)}else if(Tg(e)||Ig(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?Jt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Gs,s=vo(e.getAttribute("formenctype"))||vo(l.getAttribute("enctype"))||Ks,o=new FormData(l,e),!Ag()){let{name:d,type:f,value:h}=e;if(f==="image"){let m=d?`${d}.`:"";o.append(`${m}x`,"0"),o.append(`${m}y`,"0")}else d&&o.append(d,h)}}else{if(Ba(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Gs,r=null,s=Ks,i=e}return o&&s==="text/plain"&&(i=o,o=void 0),{action:r,method:n.toLowerCase(),encType:s,formData:o,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function jl(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Mg(e,t,n,r){let s=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${r}`:s.pathname=`${s.pathname}.${r}`:s.pathname==="/"?s.pathname=`_root.${r}`:t&&Jt(s.pathname,t)==="/"?s.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${r}`,s}async function Fg(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 Og(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 Bg(e,t,n){let r=await Promise.all(e.map(async s=>{let o=t.routes[s.route.id];if(o){let i=await Fg(o,n);return i.links?i.links():[]}return[]}));return Hg(r.flat(1).filter(Og).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function Wc(e,t,n,r,s,o){let i=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,l=(c,d)=>{var f;return n[d].pathname!==c.pathname||((f=n[d].route.path)==null?void 0:f.endsWith("*"))&&n[d].params["*"]!==c.params["*"]};return o==="assets"?t.filter((c,d)=>i(c,d)||l(c,d)):o==="data"?t.filter((c,d)=>{var h;let f=r.routes[c.route.id];if(!f||!f.hasLoader)return!1;if(i(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let m=c.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:((h=n[0])==null?void 0:h.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function Dg(e,t,{includeHydrateFallback:n}={}){return Ug(e.map(r=>{let s=t.routes[r.route.id];if(!s)return[];let o=[s.module];return s.clientActionModule&&(o=o.concat(s.clientActionModule)),s.clientLoaderModule&&(o=o.concat(s.clientLoaderModule)),n&&s.hydrateFallbackModule&&(o=o.concat(s.hydrateFallbackModule)),s.imports&&(o=o.concat(s.imports)),o}).flat(1))}function Ug(e){return[...new Set(e)]}function Wg(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Hg(e,t){let n=new Set;return new Set(t),e.reduce((r,s)=>{let o=JSON.stringify(Wg(s));return n.has(o)||(n.add(o),r.push({key:o,link:s})),r},[])}function Pf(){let e=u.useContext(gr);return jl(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Vg(){let e=u.useContext(Oa);return jl(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var kl=u.createContext(void 0);kl.displayName="FrameworkContext";function Rf(){let e=u.useContext(kl);return jl(e,"You must render this element inside a <HydratedRouter> element"),e}function Gg(e,t){let n=u.useContext(kl),[r,s]=u.useState(!1),[o,i]=u.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:h}=t,m=u.useRef(null);u.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let y=g=>{g.forEach(p=>{i(p.isIntersecting)})},j=new IntersectionObserver(y,{threshold:.5});return m.current&&j.observe(m.current),()=>{j.disconnect()}}},[e]),u.useEffect(()=>{if(r){let y=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(y)}}},[r]);let x=()=>{s(!0)},w=()=>{s(!1),i(!1)};return n?e!=="intent"?[o,m,{}]:[o,m,{onFocus:Nr(l,x),onBlur:Nr(c,w),onMouseEnter:Nr(d,x),onMouseLeave:Nr(f,w),onTouchStart:Nr(h,x)}]:[!1,m,{}]}function Nr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Kg({page:e,...t}){let{router:n}=Pf(),r=u.useMemo(()=>yf(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?u.createElement(Qg,{page:e,matches:r,...t}):null}function Yg(e){let{manifest:t,routeModules:n}=Rf(),[r,s]=u.useState([]);return u.useEffect(()=>{let o=!1;return Bg(e,t,n).then(i=>{o||s(i)}),()=>{o=!0}},[e,t,n]),r}function Qg({page:e,matches:t,...n}){let r=jt(),{future:s,manifest:o,routeModules:i}=Rf(),{basename:l}=Pf(),{loaderData:c,matches:d}=Vg(),f=u.useMemo(()=>Wc(e,t,d,o,r,"data"),[e,t,d,o,r]),h=u.useMemo(()=>Wc(e,t,d,o,r,"assets"),[e,t,d,o,r]),m=u.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let y=new Set,j=!1;if(t.forEach(p=>{var S;let v=o.routes[p.route.id];!v||!v.hasLoader||(!f.some(k=>k.route.id===p.route.id)&&p.route.id in c&&((S=i[p.route.id])!=null&&S.shouldRevalidate)||v.hasClientLoader?j=!0:y.add(p.route.id))}),y.size===0)return[];let g=Mg(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return j&&y.size>0&&g.searchParams.set("_routes",t.filter(p=>y.has(p.route.id)).map(p=>p.route.id).join(",")),[g.pathname+g.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,r,o,f,t,e,i]),x=u.useMemo(()=>Dg(h,o),[h,o]),w=Yg(h);return u.createElement(u.Fragment,null,m.map(y=>u.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),x.map(y=>u.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),w.map(({key:y,link:j})=>u.createElement("link",{key:y,nonce:n.nonce,...j,crossOrigin:j.crossOrigin??n.crossOrigin})))}function Jg(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Xg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Xg&&(window.__reactRouterVersion="7.13.1")}catch{}function qg({basename:e,children:t,unstable_useTransitions:n,window:r}){let s=u.useRef();s.current==null&&(s.current=Th({window:r,v5Compat:!0}));let o=s.current,[i,l]=u.useState({action:o.action,location:o.location}),c=u.useCallback(d=>{n===!1?l(d):u.startTransition(()=>l(d))},[n]);return u.useLayoutEffect(()=>o.listen(c),[o,c]),u.createElement(Ng,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o,unstable_useTransitions:n})}var _f=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Qe=u.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:s,reloadDocument:o,replace:i,unstable_mask:l,state:c,target:d,to:f,preventScrollReset:h,viewTransition:m,unstable_defaultShouldRevalidate:x,...w},y){let{basename:j,navigator:g,unstable_useTransitions:p}=u.useContext(mt),v=typeof f=="string"&&_f.test(f),S=jf(f,j);f=S.to;let k=lg(f,{relative:s}),I=jt(),T=null;if(l){let C=Fa(l,[],I.unstable_mask?I.unstable_mask.pathname:"/",!0);j!=="/"&&(C.pathname=C.pathname==="/"?j:Ot([j,C.pathname])),T=g.createHref(C)}let[P,b,N]=Gg(r,w),O=tv(f,{replace:i,unstable_mask:l,state:c,target:d,preventScrollReset:h,relative:s,viewTransition:m,unstable_defaultShouldRevalidate:x,unstable_useTransitions:p});function Y(C){t&&t(C),C.defaultPrevented||O(C)}let V=!(S.isExternal||o),H=u.createElement("a",{...w,...N,href:(V?T:void 0)||S.absoluteURL||k,onClick:V?Y:t,ref:Jg(y,b),target:d,"data-discover":!v&&n==="render"?"true":void 0});return P&&!v?u.createElement(u.Fragment,null,H,u.createElement(Kg,{page:k})):H});Qe.displayName="Link";var bl=u.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:s=!1,style:o,to:i,viewTransition:l,children:c,...d},f){let h=fs(i,{relative:d.relative}),m=jt(),x=u.useContext(Oa),{navigator:w,basename:y}=u.useContext(mt),j=x!=null&&ov(h)&&l===!0,g=w.encodeLocation?w.encodeLocation(h).pathname:h.pathname,p=m.pathname,v=x&&x.navigation&&x.navigation.location?x.navigation.location.pathname:null;n||(p=p.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&y&&(v=Jt(v,y)||v);const S=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let k=p===g||!s&&p.startsWith(g)&&p.charAt(S)==="/",I=v!=null&&(v===g||!s&&v.startsWith(g)&&v.charAt(g.length)==="/"),T={isActive:k,isPending:I,isTransitioning:j},P=k?t:void 0,b;typeof r=="function"?b=r(T):b=[r,k?"active":null,I?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let N=typeof o=="function"?o(T):o;return u.createElement(Qe,{...d,"aria-current":P,className:b,ref:f,style:N,to:i,viewTransition:l},typeof c=="function"?c(T):c)});bl.displayName="NavLink";var Zg=u.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:s,state:o,method:i=Gs,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:h,unstable_defaultShouldRevalidate:m,...x},w)=>{let{unstable_useTransitions:y}=u.useContext(mt),j=sv(),g=av(l,{relative:d}),p=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&_f.test(l),S=k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let I=k.nativeEvent.submitter,T=(I==null?void 0:I.getAttribute("formmethod"))||i,P=()=>j(I||k.currentTarget,{fetcherKey:t,method:T,navigate:n,replace:s,state:o,relative:d,preventScrollReset:f,viewTransition:h,unstable_defaultShouldRevalidate:m});y&&n!==!1?u.startTransition(()=>P()):P()};return u.createElement("form",{ref:w,method:p,action:g,onSubmit:r?c:S,...x,"data-discover":!v&&e==="render"?"true":void 0})});Zg.displayName="Form";function ev(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Af(e){let t=u.useContext(gr);return ke(t,ev(e)),t}function tv(e,{target:t,replace:n,unstable_mask:r,state:s,preventScrollReset:o,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c,unstable_useTransitions:d}={}){let f=qt(),h=jt(),m=fs(e,{relative:i});return u.useCallback(x=>{if(Rg(x,t)){x.preventDefault();let w=n!==void 0?n:as(h)===as(m),y=()=>f(e,{replace:w,unstable_mask:r,state:s,preventScrollReset:o,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c});d?u.startTransition(()=>y()):y()}},[h,f,m,n,r,s,t,e,o,i,l,c,d])}function $f(e){St(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=u.useRef(vi(e)),n=u.useRef(!1),r=jt(),s=u.useMemo(()=>_g(r.search,n.current?null:t.current),[r.search]),o=qt(),i=u.useCallback((l,c)=>{const d=vi(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,o("?"+d,c)},[o,s]);return[s,i]}var nv=0,rv=()=>`__${String(++nv)}__`;function sv(){let{router:e}=Af("useSubmit"),{basename:t}=u.useContext(mt),n=Sg(),r=e.fetch,s=e.navigate;return u.useCallback(async(o,i={})=>{let{action:l,method:c,encType:d,formData:f,body:h}=Lg(o,t);if(i.navigate===!1){let m=i.fetcherKey||rv();await r(m,n,i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:h,formMethod:i.method||c,formEncType:i.encType||d,flushSync:i.flushSync})}else await s(i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:h,formMethod:i.method||c,formEncType:i.encType||d,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[r,s,t,n])}function av(e,{relative:t}={}){let{basename:n}=u.useContext(mt),r=u.useContext(Pt);ke(r,"useFormAction must be used inside a RouteContext");let[s]=r.matches.slice(-1),o={...fs(e||".",{relative:t})},i=jt();if(e==null){o.search=i.search;let l=new URLSearchParams(o.search),c=l.getAll("index");if(c.some(f=>f==="")){l.delete("index"),c.filter(h=>h).forEach(h=>l.append("index",h));let f=l.toString();o.search=f?`?${f}`:""}}return(!e||e===".")&&s.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(o.pathname=o.pathname==="/"?n:Ot([n,o.pathname])),as(o)}function ov(e,{relative:t}={}){let n=u.useContext(bf);ke(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Af("useViewTransitionState"),s=fs(e,{relative:t});if(!n.isTransitioning)return!1;let o=Jt(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=Jt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return xa(s.pathname,i)!=null||xa(s.pathname,o)!=null}class Lf extends Error{constructor(n){super("different_account");Da(this,"summary");this.name="DifferentAccountError",this.summary=n}}class iv{constructor(){Da(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 o=await r.json().catch(()=>({}));if(o!=null&&o.wouldWipe)throw new Lf(o.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!r.ok){const o=await r.json().catch(()=>({error:"Invalid API key"}));throw new Error(o.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(o=>{var i,l;return{authorization_id:o.authorization_id,profile_id:o.profileId,path:o.path,title:o.title??null,sp_status:o.status??null,frame:o.bounds??o.frame??{},required_domains:o.requiredDomains??[],attested_domains:o.attestedDomains??[],missing_domains:(o.requiredDomains??[]).filter(c=>!(o.attestedDomains??[]).includes(c)),deferred_commitment_domains:o.deferredCommitmentDomains??[],approvers_frozen:o.approversFrozen??[],above_cap:o.aboveCap??!1,created_at:o.createdAt?new Date(o.createdAt*1e3).toISOString():"",earliest_expiry:(i=o.attestations)!=null&&i.length?new Date(Math.min(...o.attestations.map(c=>c.expiresAt))*1e3).toISOString():null,remaining_seconds:(l=o.attestations)!=null&&l.length?Math.max(0,Math.min(...o.attestations.map(c=>c.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(t){const n=new URLSearchParams;t!=null&&t.since&&n.set("since",String(t.since)),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString()?`?${n.toString()}`:"",s=await this.fetch(`/denials${r}`);if(!s.ok)throw new Error(`Failed to fetch denials: ${s.status}`);return s.json()}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(),s=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!s.ok)throw new Error(`Failed to fetch receipts: ${s.status}`);return(await s.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 s=await r.json().catch(()=>({error:"Failed to revoke"}));throw new Error(s.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 o=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(o.error||`Create group failed: ${n.status}`)}const r=await n.json(),s=r.group||r;return{id:s.id,name:s.name,myDomains:s.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 o=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(o.error||`Join group failed: ${n.status}`)}const r=await n.json(),s=r.group||r;return{id:s.id,name:s.name,myDomains:s.myDomains||[],isAdmin:s.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 getGatewaySettings(){const t=await this.fetch("/api/gateway-settings");if(!t.ok)throw new Error(`Failed to load settings: ${t.status}`);return t.json()}async setGatewaySettings(t){const n=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`Failed to save settings: ${n.status}`);return n.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 aiModels(t){const n=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(t??{})});if(!n.ok)throw new Error(`Model list 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 s=await r.json().catch(()=>({error:`Discovery failed: ${r.status}`}));throw new Error(s.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 setReadPolicy(t,n){const r=await this.fetch(`/integrations/${encodeURIComponent(t)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:n})});if(!r.ok){const s=await r.json().catch(()=>({error:`HTTP ${r.status}`}));throw new Error(s.error)}}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 s=await r.json();return(s==null?void 0:s.config)??null}async setTeamProfileConfig(t,n,r){const s=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify(r)});if(!s.ok){const o=await s.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(o.error||`setTeamProfileConfig failed: ${s.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 s=await r.json().catch(()=>({error:"Encryption failed"}));throw new Error(s.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 s=await r.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(s.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 s=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/resolve`,{method:"POST",body:JSON.stringify({action:n,domain:r})});if(!s.ok){const o=await s.json().catch(()=>({error:"Failed"}));throw new Error(o.error||`Failed: ${s.status}`)}return s.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 s=await r.json().catch(()=>({error:"Failed"}));throw new Error(s.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 s=await n.json().catch(()=>({error:"Decryption failed"}));throw new Error(s.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 s=await r.json().catch(()=>({error:"Failed"}));throw new Error(s.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(s=>{var l,c;const o=s.owner??{userId:""};return{authorization_id:s.authorization_id??s.authorizationId,profile_id:s.profileId??s.profile_id,path:s.path??"",title:s.title??null,sp_status:s.status??s.sp_status??null,frame:s.bounds??s.frame??{},required_domains:s.requiredDomains??s.required_domains??[],attested_domains:s.attestedDomains??s.attested_domains??[],missing_domains:(s.requiredDomains??s.required_domains??[]).filter(d=>!(s.attestedDomains??s.attested_domains??[]).includes(d)),deferred_commitment_domains:s.deferredCommitmentDomains??s.deferred_commitment_domains??[],approvers_frozen:s.approversFrozen??s.approvers_frozen??[],above_cap:s.aboveCap??s.above_cap??!1,created_at:s.createdAt?new Date(s.createdAt*1e3).toISOString():s.created_at??"",earliest_expiry:(l=s.attestations)!=null&&l.length?new Date(Math.min(...s.attestations.map(d=>d.expiresAt))*1e3).toISOString():null,remaining_seconds:(c=s.attestations)!=null&&c.length?Math.max(0,Math.min(...s.attestations.map(d=>d.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:o}})}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(),s=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!s.ok)throw new Error(`Failed to fetch receipts: ${s.status}`);const o=await s.json();return{receipts:o.receipts??[],nextBefore:o.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 s=r.toString(),o=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts${s?"?"+s:""}`);if(!o.ok)throw new Error(`Failed to fetch team receipts: ${o.status}`);const i=await o.json();return{receipts:i.receipts??[],nextBefore:i.nextBefore??null}}async getThread(t){const n=t.sinceDays??7,r=t.status??"pending",s=t.domain||"owner",o=await this.getProposals(s);let i=[];if(r==="all"){const l=[],c=new Date;for(let f=0;f<n;f++){const h=new Date(c);h.setUTCDate(c.getUTCDate()-f),l.push(h.toISOString().slice(0,10))}i=(await Promise.all(l.map(f=>this.getMyReceipts({date:f,profile:t.profile})))).flat()}return{proposals:o,receipts:i}}async getAutostart(){const t=await this.fetch("/autostart");if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}async setAutostart(t){const n=await this.fetch("/autostart",{method:t?"POST":"DELETE"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.message||`HTTP ${n.status}`)}}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 s=await r.json().catch(()=>({error:"Save failed"}));throw new Error(s.error||`Save failed: ${r.status}`)}}}const A=new iv,Mf=u.createContext(null);function lv({children:e}){const[t,n]=u.useState(null),[r,s]=u.useState("personal"),[o,i]=u.useState(null),[l,c]=u.useState(""),[d,f]=u.useState(null),[h,m]=u.useState(null),[x,w]=u.useState(!1),[y,j]=u.useState(""),g=u.useRef(!1),p=u.useRef(null),v=u.useCallback(async()=>{if(g.current)try{const P=await A.getMyTeam();if(P){const{group:b,membership:N}=P;f(b),m(N),s("team"),i(b);const O=p.current??N.domains[0]??"owner";c(O)}else f(null),m(null),s("personal")}catch{}},[]);u.useEffect(()=>{const P=()=>{document.visibilityState==="visible"&&v()};return document.addEventListener("visibilitychange",P),()=>document.removeEventListener("visibilitychange",P)},[v]);const S=u.useCallback(async(P,b={})=>{w(!0),j("");try{A.setApiKey(P),g.current=!0;const N=await A.login(P,b);n(N),p.current=N.id;const O=await A.getGroups(),Y=O.find(V=>V.isPersonal)??O[0]??null;i(Y),c("owner"),await v()}catch(N){throw A.clearApiKey(),g.current=!1,j(N instanceof Error?N.message:"Login failed"),N}finally{w(!1)}},[v]),k=u.useCallback(async()=>{await A.logout(),A.clearApiKey(),g.current=!1,p.current=null,n(null),i(null),c(""),f(null),m(null),s("personal"),j("")},[]),I=u.useCallback(()=>j(""),[]),T=u.useCallback((P,b)=>{i(P),c(b)},[]);return a.jsx(Mf.Provider,{value:{user:t,mode:r,group:o,domain:l,groupId:(o==null?void 0:o.id)??null,activeTeam:d,activeMembership:h,isLoading:x,error:y,login:S,logout:k,clearError:I,activeGroup:o,activeDomain:l,groups:o?[o]:[],setActiveContext:T,refreshGroups:v},children:e})}function Oe(){const e=u.useContext(Mf);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Ff=u.createContext(null);function cv({children:e}){const{user:t}=Oe(),n=u.useRef(null),[r,s]=u.useState(!1),o=u.useRef(new Map),i=u.useCallback((l,c)=>{const d=o.current;return d.has(l)||d.set(l,new Set),d.get(l).add(c),()=>{var f;(f=d.get(l))==null||f.delete(c)}},[]);return u.useEffect(()=>{if(!t){n.current&&(n.current.close(),n.current=null,s(!1));return}if(n.current)return;const l=A.getApiKey();if(!l)return;const c=new EventSource(`/events?key=${encodeURIComponent(l)}`);n.current=c,c.onopen=()=>s(!0),c.onerror=()=>s(!1);const d=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected"];for(const f of d)c.addEventListener(f,h=>{let m;try{m=JSON.parse(h.data)}catch{m=null}const x=o.current.get(f);if(x)for(const w of x)try{w(m)}catch(y){console.error(`[EventSource] handler for "${f}" threw:`,y)}});return()=>{c.close(),n.current=null,s(!1)}},[t]),a.jsx(Ff.Provider,{value:{connected:r,addListener:i},children:e})}function fe(e,t){const n=u.useContext(Ff);if(!n)return;const{addListener:r}=n;u.useEffect(()=>r(e,t),[e,t,r])}const Dr="suveren-theme",Hc="hap-theme";function Ps(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(Hc);t!==null&&localStorage.getItem(Dr)===null&&localStorage.setItem(Dr,t),t!==null&&localStorage.removeItem(Hc)})();function Of(){const[e,t]=u.useState(()=>{const o=localStorage.getItem(Dr);return o==="light"||o==="dark"?o:"system"}),[n,r]=u.useState(()=>Ps(e));u.useEffect(()=>{const o=document.documentElement,i=Ps(e);o.setAttribute("data-theme",i),e==="system"?localStorage.removeItem(Dr):localStorage.setItem(Dr,e),r(Ps(e))},[e]),u.useEffect(()=>{if(e!=="system")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>r(Ps("system"));return o.addEventListener("change",i),()=>o.removeEventListener("change",i)},[e]);const s=u.useCallback(()=>{t(o=>o==="system"?"light":o==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:n,toggle:s}}const uv=5*60*1e3,dv=2e3;function Cl(){const[e,t]=u.useState(!1),[n,r]=u.useState("docker"),[s,o]=u.useState(""),[i,l]=u.useState(null),[c,d]=u.useState(!1),[f,h]=u.useState(!1),[m,x]=u.useState(!1),w=u.useRef(null);return u.useEffect(()=>{let y=!1;const j=(v=!1)=>{fetch(v?"/health?refresh=1":"/health").then(S=>S.json()).then(S=>{y||(S.installMethod&&r(S.installMethod),typeof S.latestVersion<"u"&&l(S.latestVersion),S.updateAvailable&&t(!0),S.version&&(o(S.version),w.current===null?w.current=S.version:S.version!==w.current&&S.version!=="dev"&&d(!0)))}).catch(()=>{})};j(!0);const g=setInterval(()=>j(!1),m?dv:uv),p=()=>{document.visibilityState==="visible"&&j(!1)};return document.addEventListener("visibilitychange",p),window.addEventListener("focus",p),()=>{y=!0,clearInterval(g),document.removeEventListener("visibilitychange",p),window.removeEventListener("focus",p)}},[m]),{updateAvailable:e&&!f,installMethod:n,version:s,latestVersion:i,serverRestarted:c,startFastPolling:()=>x(!0),dismiss:()=>h(!0)}}function fv({size:e=20}){return a.jsxs("svg",{width:e,height:e,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),a.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function pv(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Vc={system:"◑",light:"☀",dark:"☾"};function Nl({onMenuToggle:e}){const{user:t,logout:n}=Oe(),{theme:r,toggle:s}=Of(),{version:o,updateAvailable:i,latestVersion:l}=Cl(),c=pv(o);return a.jsx("nav",{className:"top-nav",children:a.jsxs("div",{className:"top-nav-inner",children:[a.jsxs("div",{className:"logo-group",children:[a.jsx(fv,{size:20}),a.jsx("span",{className:"logo",children:"Suveren"}),a.jsx("span",{className:"version-badge",children:"Local Gateway"}),c&&a.jsxs("span",{className:"gw-version",title:i&&l?`Running v${c} — v${l} is available`:"Running gateway version","data-stale":i?"true":void 0,children:["v",c,i&&l?` → ${l}`:""]})]}),a.jsx("div",{className:"nav-spacer"}),a.jsx("div",{className:"nav-actions nav-actions-desktop",children:t?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"user-chip",children:a.jsx("strong",{children:t.name})}),a.jsx("button",{className:"theme-toggle",onClick:s,title:`Theme: ${r}`,children:Vc[r]}),a.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):a.jsx("button",{className:"theme-toggle",onClick:s,title:`Theme: ${r}`,children:Vc[r]})}),t&&e&&a.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function At(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 Bf(e,t){const n={active:[],pending:[],expired:[],revoked:[]};for(const r of e)n[At(r,t)].push(r);return n}function Lt(e,t,n){const r=u.useRef(e);r.current=e,u.useEffect(()=>{let s=null;const o=()=>typeof document>"u"?!0:document.visibilityState==="visible",i=()=>{o()&&r.current()},l=()=>{s===null&&(s=setInterval(i,t))},c=()=>{s!==null&&(clearInterval(s),s=null)},d=()=>{o()?(r.current(),l()):c()};return o()&&(r.current(),l()),document.addEventListener("visibilitychange",d),()=>{c(),document.removeEventListener("visibilitychange",d)}},[t,n])}const Df=u.createContext(null),mv=3e4,hv=5e3,gv=3e5;function vv(e,t,n){return t===0?"loading":e!=null&&e.running?"running":e!=null&&e.error?"error":e&&n?"starting":"not-running"}function yv({children:e}){const[t,n]=u.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),r=u.useRef(null),s=u.useCallback(async()=>{let d=!1;const[f,h]=await Promise.all([A.getIntegrationManifests().catch(()=>(d=!0,{manifests:[]})),A.getMcpHealth().catch(()=>null)]);n(x=>({...x,manifests:f.manifests,integrations:(h==null?void 0:h.integrations)??x.integrations,activeSessions:(h==null?void 0:h.activeSessions)??x.activeSessions,mcpServerUp:!!h,manifestsError:d,fetchCount:x.fetchCount+1}));const m=f.manifests.filter(x=>x.oauth);if(m.length>0){const x=await Promise.all(m.map(async w=>[w.id,await A.getOAuthHealth(w.id)]));n(w=>({...w,authHealth:Object.fromEntries(x)}))}},[]),o=t.fetchCount>0&&t.manifests.some(d=>{const f=t.integrations.find(h=>h.id===d.id);return f&&!f.running});fe("integration-changed",s),Lt(s,o?hv:gv);const i=u.useMemo(()=>{const d=new Map(t.integrations.map(m=>[m.id,m])),f=Date.now();o&&r.current===null?r.current=f:o||(r.current=null);const h=r.current!==null&&f-r.current<mv;return t.manifests.map(m=>{const x=d.get(m.id),w=vv(x,t.fetchCount,h),y=t.authHealth[m.id];return{id:m.id,manifest:m,integration:x,state:w,authStatus:y==null?void 0:y.status,authAccount:y==null?void 0:y.account,authError:y==null?void 0:y.error}})},[t,o]),l=u.useMemo(()=>i.filter(d=>d.state==="not-running"||d.state==="error"||d.authStatus==="failed").length,[i]),c={loading:t.fetchCount===0,mcpServerUp:t.mcpServerUp,manifestsError:t.manifestsError,entries:i,attentionCount:l,activeSessions:t.activeSessions,refresh:s};return a.jsx(Df.Provider,{value:c,children:e})}function El(){const e=u.useContext(Df);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const xv=[{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 wv(){const{activeDomain:e}=Oe(),[t,n]=u.useState({}),r=u.useCallback(async()=>{try{const[s,o,i,l,c]=await Promise.all([A.getCredential("ai-config").catch(()=>null),A.getMyAttestations().catch(()=>null),A.getProposals(e||"owner").catch(()=>null),A.getProposalsForApprover().catch(()=>null),A.getAgentContext().catch(()=>"")]),d={};if(s&&!s.configured&&(d.assistant=1),o){const x=Bf(o).expired.length;x>0&&(d.authorizations=x)}const f=(i==null?void 0:i.length)??0,h=(l==null?void 0:l.length)??0,m=f+h;m>0&&(d.proposals=m),(!c||!c.trim())&&(d.brief=1),n(d)}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),Lt(r,3e5,e),t}const Sv={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},jv={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 kv(){const{mode:e,group:t,domain:n,activeTeam:r}=Oe(),s=wv(),{attentionCount:o}=El(),i={...s};o>0&&(i.integrations=o);const l=xv.filter(m=>!m.teamOnly||e==="team"),c=u.useRef(null),[d,f]=u.useState(null),h=jt();return u.useEffect(()=>{if(c.current===null){c.current=e;return}c.current!==e&&(e==="team"&&r?f(`You are now acting in team context — ${r.name}`):e==="personal"&&f("You have left the team — back to personal context"),c.current=e)},[e,r]),u.useEffect(()=>{f(null)},[h.pathname]),a.jsxs("div",{className:"sidebar",children:[a.jsx("ul",{className:"sidebar-nav",children:l.map(m=>{const x=m.statusKey?i[m.statusKey]:0;return a.jsx("li",{children:a.jsxs(bl,{to:m.to,end:m.to==="/",className:({isActive:w})=>`sidebar-item${w?" active":""}`,children:[a.jsx("span",{className:"icon",children:m.icon}),m.label,x?a.jsx("span",{style:Sv,children:x}):null]})},m.to)})}),a.jsxs("div",{className:"sidebar-context",children:[a.jsx("div",{className:"ctx-label",children:"Active context"}),a.jsx("div",{className:"ctx-value",children:e==="personal"?"personal":t?`${t.name} / ${n}`:n})]}),d&&a.jsx("div",{style:jv,role:"status","aria-live":"polite",children:d})]})}const yo="suveren:updatedTo";function bv(e){return e==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":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 Cv(){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 Uf(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:s,startFastPolling:o,dismiss:i}=Cl(),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[h,m]=u.useState(()=>{try{const v=sessionStorage.getItem(yo);if(v)return sessionStorage.removeItem(yo),v}catch{}return null}),x=bv(t),w=u.useRef(null),y=v=>{try{sessionStorage.setItem(yo,v||r||"✓")}catch{}window.location.reload()};u.useEffect(()=>{if(!h)return;const v=setTimeout(()=>m(null),6e3);return()=>clearTimeout(v)},[h]),u.useEffect(()=>{if(!l||!s)return;const v=()=>Cv()?!1:(y(n),!0);if(v())return;const S=setInterval(v,1500);return()=>clearInterval(S)},[l,s,n]),u.useEffect(()=>(document.body.classList.toggle("is-updating",l),()=>document.body.classList.remove("is-updating")),[l]);const j=e&&!l&&!h||!!h&&!l;u.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 v=()=>{var I;const k=((I=w.current)==null?void 0:I.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${k}px`)};v();const S=new ResizeObserver(v);return w.current&&S.observe(w.current),()=>{S.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[j]);const g=()=>{c(!0),o()},p=async()=>{try{await navigator.clipboard.writeText(x),f(!0),setTimeout(()=>f(!1),1800)}catch{}};return a.jsxs(a.Fragment,{children:[h&&!l&&a.jsx("div",{ref:w,className:"update-banner is-live",role:"status","aria-live":"polite",children:a.jsxs("div",{className:"update-banner-row",children:[a.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",h&&h!=="✓"?` — ${h} is live`:" — now live","."]}),a.jsx("button",{className:"update-banner-x",onClick:()=>m(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!h&&a.jsx("div",{ref:w,className:"update-banner",role:"status","aria-live":"polite",children:a.jsxs("div",{className:"update-banner-row",children:[a.jsx("span",{className:"update-banner-text",children:"Update available."}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsx("button",{className:"btn btn-sm btn-secondary",onClick:g,children:"Update"}),a.jsx("button",{className:"update-banner-x",onClick:i,"aria-label":"Dismiss",children:"×"})]})]})}),l&&a.jsx("div",{className:"update-overlay",children:a.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[a.jsx("div",{className:"update-spinner"}),a.jsxs("h2",{children:["Finishing the update","…"]}),a.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",a.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),a.jsxs("div",{className:"update-cmd-row",children:[a.jsx("code",{className:"update-cmd",children:x}),a.jsx("button",{className:"btn btn-sm btn-primary",onClick:p,children:d?"Copied":"Copy"})]}),a.jsxs("div",{className:"update-status",children:[a.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),a.jsxs("div",{className:"update-overlay-actions",children:[a.jsx("button",{className:"btn btn-primary",onClick:()=>y(n),children:"Reload now"}),a.jsx("button",{className:"btn btn-secondary",onClick:()=>c(!1),children:"Cancel"})]})]})})]})}const Nv={system:"◑",light:"☀",dark:"☾"},Ev=[{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 Tv({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:s,logout:o}=Oe(),{theme:i,toggle:l}=Of(),c=jt();return u.useEffect(()=>{t()},[c.pathname]),e?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mobile-menu-backdrop",onClick:t}),a.jsxs("div",{className:"mobile-menu-panel",children:[n&&a.jsxs("div",{className:"mobile-menu-header",children:[a.jsx("strong",{children:n.name}),a.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:r?`${r.name} / ${s}`:s||"personal"})]}),a.jsx("nav",{className:"mobile-menu-nav",children:Ev.map(d=>a.jsxs(bl,{to:d.to,end:d.to==="/",className:({isActive:f})=>`mobile-menu-item${f?" active":""}`,onClick:t,children:[a.jsx("span",{className:"icon",children:d.icon}),d.label]},d.to))}),a.jsxs("div",{className:"mobile-menu-footer",children:[a.jsxs("button",{className:"mobile-menu-action",onClick:()=>{l()},children:[a.jsx("span",{className:"icon",children:Nv[i]}),"Theme: ",i]}),a.jsx("button",{className:"mobile-menu-action",onClick:()=>{o(),t()},children:"Logout"})]})]})]}):null}function Wf(e){return e.status==="pending"}function zv(e,t){return e.filter(Wf).length+t.length}const jn=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],Iv=500;function Pv(){const{user:e,domain:t}=Oe(),[n,r]=u.useState(0),s=u.useRef(null),o=u.useCallback(async()=>{if(!e){r(0);return}try{const[l,c]=await Promise.all([A.getProposals(t||"owner").catch(()=>[]),A.getProposalsForApprover().catch(()=>[])]);r(zv(l,c))}catch{r(0)}},[e,t]),i=u.useCallback(()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o()},Iv)},[o]);return u.useEffect(()=>(o(),()=>{s.current&&clearTimeout(s.current)}),[o]),fe(jn[0],i),fe(jn[1],i),fe(jn[2],i),fe(jn[3],i),fe(jn[4],i),fe(jn[5],i),fe(jn[6],i),n}const Gc="Suveren",Rv="/favicon.svg",_v="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Rs={x1:74.54,y1:22.74,x2:94.46,y2:34.24},Av=14,$v="#f59e0b";function Lv(e){const t=Hf(e);return t>0?`(${t}) ${Gc}`:Gc}function Hf(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function Mv(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
52
|
-
<path class="m" d="${_v}"/>
|
|
53
|
-
<line class="m" x1="${Rs.x1}" y1="${Rs.y1}" x2="${Rs.x2}" y2="${Rs.y2}"/>
|
|
54
|
-
<circle cx="103" cy="103" r="25" fill="${$v}"/>
|
|
55
|
-
<style>.m{stroke:#111111;stroke-width:${Av};fill:none;stroke-linecap:round}@media (prefers-color-scheme:dark){.m{stroke:#ffffff;stroke-width:13.3}}</style>
|
|
56
|
-
</svg>`;return`data:image/svg+xml,${encodeURIComponent(e)}`}function Fv(){return document.querySelector('link[rel="icon"]')}function Vf(e){const t=Hf(e);document.title=Lv(t);const n=Fv();if(!n)return;const r=t>0?Mv():Rv;n.getAttribute("href")!==r&&n.setAttribute("href",r)}function Ov(){Vf(0)}function Bv(){const e=Pv();return u.useEffect(()=>{Vf(e)},[e]),u.useEffect(()=>Ov,[]),null}function Dv(){const[e,t]=u.useState(!1);return a.jsxs(yv,{children:[a.jsx(Bv,{}),a.jsx(Nl,{onMenuToggle:()=>t(!e)}),a.jsx(Uf,{}),a.jsx(kv,{}),a.jsx(Tv,{open:e,onClose:()=>t(!1)}),a.jsx("div",{className:"main-content",children:a.jsx("div",{className:"page-inner",children:a.jsx(Cg,{})})})]})}function Uv(){const[e,t]=u.useState(""),{login:n,isLoading:r,error:s,clearError:o}=Oe(),[i,l]=u.useState(null),c=async()=>{if(e.trim()){o();try{await n(e)}catch(h){if(h instanceof Lf){l(h.summary);return}}}},d=async()=>{l(null),o();try{await n(e,{confirmWipe:!0})}catch{}},f=()=>{l(null)};return a.jsxs(a.Fragment,{children:[a.jsx(Nl,{}),a.jsx(Uf,{}),a.jsxs("div",{className:"login-split",children:[a.jsx("div",{className:"login-split-left",children:a.jsxs("div",{style:{maxWidth:"28rem"},children:[a.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."}),a.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."})]})}),a.jsx("div",{className:"login-split-right",children:a.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[a.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[a.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),a.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage authorizations."})]}),s&&a.jsx("div",{className:"error-message",children:s}),a.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[a.jsx("label",{className:"form-label",children:"API Key"}),a.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:h=>t(h.target.value),onKeyDown:h=>h.key==="Enter"&&c(),disabled:r,style:{padding:"0.75rem"}}),a.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),a.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:c,disabled:r,style:{marginBottom:"2rem"},children:r?"Signing in...":"Sign In"}),a.jsx("div",{className:"login-divider",children:"New here?"}),a.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[a.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",a.jsx("br",{}),"then come back to sign in."]}),a.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"})]}),a.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[a.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),a.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[a.jsxs(a.Fragment,{children:["Create an account at ",a.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((h,m)=>a.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:m<2?"0.5rem":0},children:[a.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[m+1,"."]}),h]},m))})]})]})})]}),i&&a.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:f,children:a.jsxs("div",{className:"card",onClick:h=>h.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[a.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),a.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 ",a.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),a.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[a.jsxs("li",{children:[i.credentialCount," stored service credential",i.credentialCount===1?"":"s",i.credentialIds.length>0&&a.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`:"",")"]})]}),a.jsxs("li",{children:[i.serviceCount," configured integration",i.serviceCount===1?"":"s"]}),a.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),a.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),a.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."}),a.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."}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[a.jsx("button",{className:"btn btn-ghost",onClick:f,disabled:r,children:"Cancel"}),a.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:d,disabled:r,children:r?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function Wv(){const{setActiveContext:e}=Oe(),t=qt(),[n,r]=u.useState(""),[s,o]=u.useState(""),[i,l]=u.useState(""),[c,d]=u.useState(!1),f=async()=>{if(n.trim()){d(!0),l("");try{const m=await A.joinGroup(n.trim());e(m,m.myDomains[0]||""),t("/")}catch(m){l(m instanceof Error?m.message:"Failed to join group")}finally{d(!1)}}},h=async()=>{if(s.trim()){d(!0),l("");try{const m=await A.createGroup(s.trim());e(m,m.myDomains[0]||""),t("/")}catch(m){l(m instanceof Error?m.message:"Failed to create group")}finally{d(!1)}}};return a.jsxs(a.Fragment,{children:[a.jsx(Nl,{}),a.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:a.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[a.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[a.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join Your Team"}),a.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&&a.jsx("div",{className:"error-message",children:i}),a.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[a.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing group"}),a.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),a.jsxs("div",{className:"invite-input-row",children:[a.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:n,onChange:m=>r(m.target.value),onKeyDown:m=>m.key==="Enter"&&f(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:c}),a.jsx("button",{className:"btn btn-primary",onClick:f,disabled:c,children:"Join"})]})]}),a.jsxs("div",{className:"card",children:[a.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new group"}),a.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members. Assign domains after creation."}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("input",{className:"form-input",placeholder:"Group name (e.g., Acme Corp)",value:s,onChange:m=>o(m.target.value),onKeyDown:m=>m.key==="Enter"&&h(),style:{flex:1},disabled:c}),a.jsx("button",{className:"btn btn-secondary",onClick:h,disabled:c,children:"Create"})]})]})]})})]})}const yi="suveren-setup-ai-skipped",xi="suveren-setup-agent-done",wi="suveren-setup-dismissed",Hv={"hap-setup-ai-skipped":yi,"hap-setup-agent-done":xi,"hap-setup-dismissed":wi};function Vv(){for(const[e,t]of Object.entries(Hv)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}Vv();const xo={"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:
|
|
57
|
-
|
|
58
|
-
${JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)}`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
|
|
59
|
-
SSE transport: GET ${e}/sse
|
|
60
|
-
Health check: GET ${e}/health`}};function Gv({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:s}){const[o,i]=u.useState(()=>localStorage.getItem(yi)==="true"),[l,c]=u.useState(()=>localStorage.getItem(xi)==="true"),[d,f]=u.useState(()=>localStorage.getItem(wi)==="true"),[h,m]=u.useState(null),[x,w]=u.useState("claude-code"),[y,j]=u.useState(!1),g=[{label:"AI Assistant",detail:"A trusted AI helps you think through authorizations — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":o?"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"}],p=g.filter(b=>b.status==="done"||b.status==="skipped").length,v=p===g.length,S=u.useCallback(()=>{localStorage.setItem(yi,"true"),i(!0)},[]),k=u.useCallback(()=>{localStorage.setItem(xi,"true"),c(!0),m(null)},[]),I=u.useCallback(()=>{localStorage.setItem(wi,"true"),f(!0)},[]),T=u.useCallback(async b=>{try{await navigator.clipboard.writeText(b),j(!0),setTimeout(()=>j(!1),2e3)}catch{}},[]);if(d||v)return null;const P=g.findIndex(b=>b.status==="pending");return a.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[a.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),a.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:"×"})]}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:g.map((b,N)=>{const O=N===P,Y=b.status==="done"||b.status==="skipped"?"●":"○",V=b.status==="done"?"var(--success)":b.status==="skipped"?"var(--text-tertiary)":O?"var(--accent)":"var(--text-tertiary)";return a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:O?"0.75rem":"0.25rem 0",borderRadius:O?"0.5rem":void 0,background:O?"var(--accent-subtle)":void 0},children:[a.jsx("span",{style:{color:V,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:Y}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[b.to&&b.status==="pending"?a.jsx(Qe,{to:b.to,style:{fontSize:"0.9rem",fontWeight:O?600:500,color:O?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:b.label}):b.status==="pending"&&N===3?a.jsx("button",{onClick:()=>m(h===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:O?600:500,color:O?"var(--accent)":"var(--text-primary)"},children:b.label}):a.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:b.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:b.label}),b.optional&&b.status==="pending"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),b.status==="skipped"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),b.detail&&b.status==="pending"&&O&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:b.detail})]}),b.optional&&b.status==="pending"&&a.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"}),b.to&&b.status==="pending"&&a.jsx(Qe,{to:b.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),N===3&&h===3&&a.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[a.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem",color:"var(--text-primary)"},children:"MCP Endpoint"}),a.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:s}),a.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"0.75rem"},children:Object.entries(xo).map(([H,C])=>a.jsx("button",{onClick:()=>w(H),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:x===H?600:400,background:x===H?"var(--accent-subtle)":"transparent",color:x===H?"var(--accent)":"var(--text-secondary)",border:`1px solid ${x===H?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:C.label},H))}),a.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:xo[x].snippet(s)}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>T(xo[x].snippet(s)),children:y?"Copied":"Copy"}),a.jsx("button",{className:"btn btn-primary btn-sm",onClick:k,children:"Done"})]})]})]},N)})}),a.jsxs("div",{style:{marginTop:"1.25rem"},children:[a.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:a.jsx("div",{style:{height:"100%",width:`${p/g.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),a.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[p," of ",g.length," complete"]})]})]})}function zn({variant:e="base",style:t,className:n,...r}){const s=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return a.jsx("span",{className:`${s}${n?` ${n}`:""}`,style:t,role:"status","aria-busy":"true","aria-label":r["aria-label"]??"Loading"})}function wo(){return a.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[a.jsx(zn,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),a.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[a.jsx(zn,{variant:"line",style:{width:"35%"}}),a.jsx(zn,{variant:"line-sm",style:{width:"65%"}})]})]})}const Kv={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Gf=e=>Kv[e]??e,Yv={resource:{chip:"Restricted",sev:"warn"},spam:{chip:"Spam / Trash",sev:"info"},age:{chip:"Too old",sev:"warn"},unset_age:{chip:"Needs setup",sev:"act",fixTo:"/integrations"},read_gate:{chip:"Not granted",sev:"act",fixTo:"/authorizations"},ungoverned:{chip:"Unconfigured",sev:"act"},query_unsafe:{chip:"Unsafe search",sev:"info"}};function Qv(e){return Yv[e]??{chip:"Blocked",sev:"info"}}function Jv(e){const t=Gf(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?a.jsxs(a.Fragment,{children:["Tried to read your ",a.jsx("b",{children:e.target??"restricted"})," calendar"]}):a.jsxs(a.Fragment,{children:["Tried to read a restricted location in ",t]});case"spam":return a.jsxs(a.Fragment,{children:["Tried to open a message in ",a.jsx("b",{children:"spam or trash"})]});case"age":return a.jsxs(a.Fragment,{children:["Tried to read ",t," older than your read window"]});case"unset_age":return a.jsxs(a.Fragment,{children:["Your ",t," has ",a.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return a.jsxs(a.Fragment,{children:["Read access isn't granted on your ",t," authorization"]});case"ungoverned":return a.jsxs(a.Fragment,{children:["A ",t," tool isn't configured for safe reading"]});case"query_unsafe":return a.jsx(a.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return a.jsx(a.Fragment,{children:e.detail})}}function Xv(e,t){const n=Math.max(0,(t-e)/1e3);if(n<60)return"Just now";if(n<3600)return`${Math.floor(n/60)} min ago`;if(n<86400)return`${Math.floor(n/3600)} hr ago`;const r=Math.floor(n/86400);return r===1?"Yesterday":`${r} days ago`}const qv=5;function Zv(){const[e,t]=u.useState(null),[n,r]=u.useState(0),[s,o]=u.useState(!1),[i,l]=u.useState(!1),c=u.useCallback(()=>{A.getDenials({limit:s?200:qv}).then(({count:f,records:h})=>{r(f),t(h),l(!1)}).catch(()=>l(!0))},[s]);if(u.useEffect(()=>{c()},[c]),Lt(c,12e4),i||e===null)return null;const d=(f,h)=>{const m=Qv(f.reason);return a.jsxs("div",{className:"rb-row",children:[a.jsx("span",{className:`rb-dot ${m.sev==="act"?"act":m.sev==="info"?"info":""}`,"aria-hidden":"true"}),a.jsxs("div",{className:"rb-body",children:[a.jsx("div",{className:"rb-line",children:Jv(f)}),a.jsxs("div",{className:"rb-meta",children:[a.jsx("span",{className:`rb-chip ${m.sev==="act"?"act":m.sev==="warn"?"warn":""}`,children:m.chip}),a.jsx("span",{className:"rb-via",children:Gf(f.integrationId)})]}),m.fixTo&&a.jsx(Qe,{className:"rb-fix",to:m.fixTo,children:"Set a read window →"})]}),a.jsx("div",{className:"rb-when",children:Xv(f.ts,Date.now())})]},`${f.ts}-${h}`)};return a.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[a.jsxs("div",{className:"card-header",children:[a.jsx("h2",{className:"card-title",children:"Recent blocks"}),n>0&&a.jsx("span",{className:"rb-count",children:n})]}),e.length===0?a.jsxs("div",{className:"rb-empty",children:[a.jsx("span",{className:"rb-mark","aria-hidden":"true",children:a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M20 6 9 17l-5-5"})})}),a.jsx("h3",{children:"Nothing blocked"}),a.jsx("p",{children:"Your agent has stayed within every limit you set."})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"rb-sub",children:"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."}),a.jsx("div",{className:"rb-rows",children:e.map(d)}),!s&&n>e.length&&a.jsx("div",{className:"rb-foot",children:a.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!0),children:["View all ",n," blocks"]})})]})]})}const ey=30*60;function So(e){return e.replace(/@.*$/,"").split("/").pop()??e}function ty(){var H;const{domain:e}=Oe(),[t,n]=u.useState([]),[r,s]=u.useState([]),[o,i]=u.useState([]),[l,c]=u.useState(!0),[d,f]=u.useState(!1),[h,m]=u.useState(!1),[x,w]=u.useState(!1),{entries:y,activeSessions:j,loading:g}=El(),p=!g,v=u.useCallback(()=>{A.getMyAttestations().then(C=>{n(C),f(!0)}).catch(()=>f(!0)),A.getProposals(e||"owner").then(C=>{s(C),m(!0)}).catch(()=>m(!0)),A.getProposalsForApprover().then(C=>i(C)).catch(()=>i([])),A.getCredential("ai-config").then(C=>{c(C.configured),w(!0)}).catch(()=>w(!0))},[e]);fe("attestation-changed",v),fe("proposal-added",v),fe("proposal-resolved",v),fe("proposal-approved",v),fe("proposal-rejected",v),Lt(v,3e5,e);const S=d&&h&&x&&p,k=Bf(t),I=k.active,T=k.expired,P=I.filter(C=>C.remaining_seconds!==null&&C.remaining_seconds<=ey),b=r.filter(Wf),N=y.filter(C=>C.state==="running"),O=y.filter(C=>C.state==="starting"),Y=y.filter(C=>C.state==="not-running"||C.state==="error"),V=[];for(const C of o)V.push({label:"Approval needed",detail:`${C.tool} — above-cap action under ${So(C.profileId)}`,to:"/proposals",color:"var(--warning)"});for(const C of b)V.push({label:"Approval pending",detail:`${C.tool} awaiting your approval`,to:"/proposals",color:"var(--warning)"});for(const C of P){const J=Math.ceil((C.remaining_seconds??0)/60);V.push({label:"Expiring soon",detail:`${C.title??So(C.profile_id)} — ${J} min remaining`,to:"/authorizations",color:"var(--warning)"})}for(const C of T)V.push({label:"Expired",detail:C.title??So(C.profile_id),to:"/authorizations",color:"var(--danger)"});for(const C of Y)V.push({label:C.state==="error"?"Integration error":"Integration stopped",detail:C.state==="error"&&((H=C.integration)!=null&&H.error)?`${C.manifest.name}: ${C.integration.error}`:`${C.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"});for(const C of O)V.push({label:"Integration starting",detail:`${C.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const C of y)C.authStatus==="failed"&&C.state!=="not-running"&&C.state!=="error"&&V.push({label:"Reconnect needed",detail:`${C.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return l||V.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"page-header",children:a.jsx("h1",{className:"page-title",children:"Dashboard"})}),S&&a.jsx(Gv,{aiConfigured:l,hasRunningIntegration:N.length>0,hasActiveAuth:I.length>0,hasAgentConnected:j>0,mcpEndpoint:`http://localhost:${window.location.port==="3400"?"3430":"7430"}`}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[a.jsx(Qe,{to:"/authorizations",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[d?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:I.length>0?"var(--success)":"var(--text-tertiary)"},children:I.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),a.jsx(Qe,{to:"/proposals",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[h?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:b.length>0?"var(--warning)":"var(--text-tertiary)"},children:b.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),a.jsx(Qe,{to:"/authorizations",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[d?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:T.length>0?"var(--danger)":"var(--text-tertiary)"},children:T.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),a.jsx(Qe,{to:"/integrations",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[p?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:N.length>0?"var(--success)":"var(--text-tertiary)"},children:N.length}):a.jsx(zn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),V.length>0?a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:V.map((C,J)=>a.jsx(Qe,{to:C.to,style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"0.75rem 1rem",display:"flex",alignItems:"center",gap:"0.75rem"},children:[a.jsx("span",{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",background:C.color,flexShrink:0}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:C.label}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.detail})]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]})},J))}):S?a.jsx("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:a.jsx("div",{style:{fontSize:"0.9rem",color:"var(--text-secondary)"},children:"All clear. Nothing needs your attention."})}):a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[a.jsx(wo,{}),a.jsx(wo,{}),a.jsx(wo,{})]}),a.jsx(Zv,{})]})}const ny=["Scope & Limits","Intent","Authorize"];function Kf({currentStep:e,onStepClick:t}){const n=qt();return a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",marginBottom:"2.5rem"},children:[a.jsx("div",{style:{display:"flex",alignItems:"center",flex:1,overflow:"hidden"},children:ny.map((r,s)=>{const o=s+2,i=o<e,l=o===e;return a.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[s>0&&a.jsx("div",{style:{width:"1.5rem",height:"2px",background:i?"var(--accent)":"var(--border)",flexShrink:1}}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:[a.jsx("div",{className:`step-circle${i?" completed":""}${l?" current":""}`,onClick:i&&t?()=>t(o):void 0,style:i&&t?{cursor:"pointer"}:void 0,children:i?"✓":s+1}),a.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})]})]},o)})}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>n("/agent/new"),style:{flexShrink:0,fontSize:"0.8rem",marginTop:"0.15rem"},children:"Cancel"})]})}const ry=40;function $e(e,t){const n=e.lastIndexOf("/"),r=n>=0?e.slice(n+1):e,s=r.indexOf("@"),o=s>=0?r.slice(0,s):r;return(o.charAt(0).toUpperCase()+o.slice(1)).slice(0,ry)}function sy({profileId:e,bounds:t,groupName:n,domain:r,onSwitch:s}){return a.jsxs("div",{className:"context-strip",children:[n&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"context-strip-label",children:"Team:"}),a.jsxs("span",{children:[a.jsx("strong",{children:n}),r?` / ${r}`:""]})]}),e&&a.jsxs("span",{children:[a.jsx("strong",{children:"Profile:"})," ",$e(e)]}),t&&a.jsxs("span",{children:[a.jsx("strong",{children:"Bounds:"})," ",t]}),s&&a.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:s,children:"Switch"})]})}function ay({integrationId:e,field:t,value:n,onChange:r,disabled:s,onLabels:o}){const[i,l]=u.useState(null),[c,d]=u.useState(null),[f,h]=u.useState(!0);u.useEffect(()=>{let w=!1;return A.discoverScopeField(e,t).then(y=>{var j;w||(l(y.options),h(!1),(j=y.options)!=null&&j.length&&(o==null||o(Object.fromEntries(y.options.map(g=>[g.value,g.label])))))}).catch(y=>{w||(d(y instanceof Error?y.message:String(y)),h(!1))}),()=>{w=!0}},[e,t]);const m=new Set(n.split(",").map(w=>w.trim()).filter(Boolean)),x=w=>{const y=new Set(m);y.has(w)?y.delete(w):y.add(w),r(Array.from(y).join(","))};return f?a.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):c||!i?a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",c??"no response","). Enter values manually, separated by commas."]}),a.jsx("input",{className:"form-input",type:"text",value:n,onChange:w=>r(w.target.value),disabled:s})]}):i.length===0?a.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:i.map(w=>{const y=w.extras??{},j=typeof y.access=="string"?y.access:void 0,g=j==="reader",p=y.primary===!0;return a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:g?"var(--text-tertiary)":"var(--text-primary)",cursor:s||g?"not-allowed":"pointer"},title:g?"Read-only — you can authorize list/read but not writes":void 0,children:[a.jsx("input",{type:"checkbox",checked:m.has(String(w.value)),onChange:()=>x(String(w.value)),disabled:s||g}),a.jsx("span",{children:w.label||w.value}),p&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),j&&a.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",j]})]},w.value)})})}function oy(e){return e.replace(/@.*$/,"").split("/").pop()??e}function iy(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function ly(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function cy(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function Kc(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 uy(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function dy(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function fy(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 py(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),s=n%60;return s===0?`${r} hour${r!==1?"s":""}`:`${r}h ${s}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 my({id:e,value:t,onChange:n,disabled:r,placeholder:s,unit:o}){const i=dy(o),l=fy(o),c=uy(o),d=py(t,o),f=t===""?null:Number(t),h=()=>{const x=t===""?0:Number(t),w=x%i,y=w===0?x+i:x+(i-w);n(String(y))},m=()=>{const x=t===""?0:Number(t);if(x<=0)return;const w=x%i,y=w===0?x-i:x-w;n(String(Math.max(0,y)))};return a.jsxs("div",{className:"bounded-input",children:[a.jsxs("div",{className:"bounded-input-field",children:[a.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:m,disabled:r||t===""||Number(t)<=0,"aria-label":"Decrease",children:"−"}),a.jsx("input",{id:e,className:"stepper-input",type:"number",min:0,step:i,value:t,placeholder:s??"0",onChange:x=>n(x.target.value),onFocus:x=>x.target.select(),disabled:r}),a.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:h,disabled:r,"aria-label":"Increase",children:"+"}),c&&a.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:c})]}),l.length>0&&!r&&a.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:l.map(x=>a.jsx("button",{type:"button",className:`preset-chip${f===x.value?" preset-chip-selected":""}`,onClick:()=>n(String(x.value)),children:x.label},x.value))}),d&&a.jsxs("div",{className:"bounded-input-echo",children:["≈ ",d]})]})}function Yc({htmlFor:e,label:t,description:n}){const[r,s]=u.useState(!1);return a.jsxs("div",{className:"field-label-with-tip",children:[a.jsx("label",{className:"form-label",htmlFor:e,children:t}),n&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${t}" mean?`,"aria-expanded":r,onClick:()=>s(o=>!o),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onBlur:()=>s(!1),children:"i"}),r&&a.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:n})]})]})}function hy({id:e,value:t,onChange:n,disabled:r,format:s,placeholder:o}){const[i,l]=u.useState(""),[c,d]=u.useState(!1),f=u.useRef(null),h=t?t.split(",").map(g=>g.trim()).filter(Boolean):[],m=g=>{const p=g.trim();if(!p)return;if(!Kc(p,s)){d(!0);return}d(!1);const v=h.includes(p)?h:[...h,p];n(v.join(",")),l("")},x=g=>{const p=h.filter((v,S)=>S!==g);n(p.join(","))},w=g=>{g.key==="Enter"||g.key===","||g.key==="Tab"?i.trim()&&(g.preventDefault(),m(i)):g.key==="Backspace"&&!i&&h.length>0&&x(h.length-1)},y=g=>{const p=g.clipboardData.getData("text");if(p.includes(",")){g.preventDefault();const S=p.split(",").map(I=>I.trim()).filter(Boolean).filter(I=>Kc(I,s)),k=[...new Set([...h,...S])];n(k.join(",")),l(""),d(!1)}},j=s==="email"?"Type email and press Enter...":"Type domain and press Enter...";return a.jsxs("div",{className:`tag-input${c?" tag-input-invalid":""}`,onClick:()=>{var g;return(g=f.current)==null?void 0:g.focus()},children:[h.map((g,p)=>a.jsxs("span",{className:"tag-pill",children:[g,!r&&a.jsx("button",{type:"button",className:"tag-remove",onClick:v=>{v.stopPropagation(),x(p)},"aria-label":`Remove ${g}`,children:"×"})]},g)),!r&&a.jsx("input",{ref:f,id:e,className:"tag-input-field",type:"text",value:i,onChange:g=>{l(g.target.value),d(!1)},onKeyDown:w,onPaste:y,onBlur:()=>{i.trim()&&m(i)},placeholder:h.length===0?o??j:""})]})}function gy({id:e,options:t,value:n,onChange:r,disabled:s}){const o=n?n.split(",").map(l=>l.trim()).filter(Boolean):[],i=l=>{const c=o.includes(l)?o.filter(d=>d!==l):[...o,l];r(c.join(","))};return a.jsx("div",{className:"checkbox-group",id:e,children:t.map(l=>a.jsxs("label",{className:`checkbox-pill${o.includes(l)?" checkbox-pill-selected":""}`,children:[a.jsx("input",{type:"checkbox",checked:o.includes(l),onChange:()=>i(l),disabled:s}),a.jsx("span",{children:l})]},l))})}function Qc({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:s,readOnly:o,twoColumn:i,discoveryIntegrationId:l,onLabels:c}){const d=iy(e,t),f=`${s}-field-${e}`,h=a.jsx(a.Fragment,{children:cy(t)?a.jsx(gy,{id:f,options:t.enum,value:n,onChange:m=>r(e,m),disabled:o}):(()=>{const m=t.boundType;return(m==null?void 0:m.kind)==="enum"&&Array.isArray(m.values)})()?a.jsxs("select",{id:f,className:"form-select",value:n,onChange:m=>r(e,m.target.value),disabled:o,children:[a.jsx("option",{value:"",children:"Select..."}),t.boundType.values.map(m=>a.jsx("option",{value:m,children:m},m))]}):"enum"in t&&t.enum?a.jsxs("select",{id:f,className:"form-select",value:n,onChange:m=>r(e,m.target.value),disabled:o,children:[a.jsx("option",{value:"",children:"Select..."}),t.enum.map(m=>a.jsx("option",{value:m,children:m},m))]}):t.type==="number"?a.jsx(my,{id:f,value:n,onChange:m=>r(e,m),disabled:o,unit:t.unit}):ly(t)?a.jsx(hy,{id:f,value:n,onChange:m=>r(e,m),disabled:o,format:t.format}):l?a.jsx(ay,{integrationId:l,field:e,value:n,onChange:m=>r(e,m),disabled:o,onLabels:m=>c==null?void 0:c(e,m)}):a.jsx("input",{id:f,className:"form-input",type:"text",value:n,onChange:m=>r(e,m.target.value),disabled:o})});return i?a.jsxs("div",{className:"bounds-field-row",children:[a.jsx("div",{className:"bounds-field-label",children:a.jsx(Yc,{htmlFor:f,label:d,description:t.description})}),a.jsx("div",{className:"bounds-field-input",children:h})]},`${s}-${e}`):a.jsxs("div",{className:"form-group",children:[a.jsx(Yc,{htmlFor:f,label:d,description:t.description}),h]},`${s}-${e}`)}function vy(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 o=!1;for(const[i,l]of Object.entries(n)){const c=e[i];if(c===""||c===void 0)continue;const d=Number(c);if(!isNaN(d)&&d>l){o=!0;break}}return o?r?"above-approvers":"hard-ceiling":"within-cap"}function yy(e,t){const n=new Set;if(!t)return n;for(const[r,s]of Object.entries(t)){const o=e[r];if(o===""||o===void 0)continue;const i=Number(o);!isNaN(i)&&i>s&&n.add(r)}return n}function xy({profile:e,onConfirm:t,onCancel:n,readOnly:r,initialBounds:s,initialContext:o,initialFrame:i,profileConfig:l,approverNames:c,adminName:d}){const f=e.boundsSchema??e.frameSchema,h=e.contextSchema,m=f?Object.entries(f.fields).filter(([R,D])=>!(R==="profile"||R==="path"||D.enforced===!1||D.enforcedBy==="gatekeeper")):[],x=f?Object.entries(f.fields).filter(([,R])=>R.enforcedBy==="gatekeeper").filter(([,R])=>R.enforced!==!1).map(([R,D])=>D.displayName??R):[],w=h&&h.keyOrder.length>0?Object.entries(h.fields):[],y=s??i??{},j=o??{},g={};for(const[R]of m)g[R]=y[R]!==void 0?String(y[R]):"";const p={};for(const[R]of w)p[R]=j[R]!==void 0?String(j[R]):"";const[v,S]=u.useState(g),[k,I]=u.useState(p),[T,P]=u.useState({}),[b,N]=u.useState(null);u.useEffect(()=>{const R=oy(e.id);A.getIntegrationManifests().then(({manifests:D})=>{const L=D.find(U=>U.profile===R&&U.contextDiscovery&&Object.keys(U.contextDiscovery).length>0);N(L??null)}).catch(()=>N(null))},[e.id]);const O=vy(v,l),Y=yy(v,l==null?void 0:l.caps),V=(R,D)=>{S(L=>({...L,[R]:D}))},H=(R,D)=>{I(L=>({...L,[R]:D}))},C=()=>{const R={profile:e.id};for(const[L,U]of m)U.type==="number"?R[L]=v[L]===""?0:Number(v[L]):R[L]=v[L];const D={};for(const[L,U]of w)U.type==="number"?D[L]=k[L]===""?0:Number(k[L]):D[L]=k[L];return[R,D]},J=()=>{const[R,D]=C();t(R,D,T)},ne=()=>{const R=(l==null?void 0:l.caps)??{},D={...v};for(const ee of Y)R[ee]!==void 0&&(D[ee]=String(R[ee]));S(D);const L={profile:e.id};for(const[ee,q]of m)if(q.type==="number"){const me=D[ee]??"";L[ee]=me===""?0:Number(me)}else L[ee]=D[ee]??"";const U={};for(const[ee,q]of w)q.type==="number"?U[ee]=k[ee]===""?0:Number(k[ee]):U[ee]=k[ee];t(L,U,T)},$=R=>{const D=l==null?void 0:l.caps;if(!D||D[R]===void 0)return null;const L=D[R],U=Y.has(R);return O==="hard-ceiling"&&U?a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",L," — exceeds team ceiling"]}):O==="above-approvers"&&U?a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",L," — above cap"]}):a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",L," ok"]})},_=()=>{var R;if(O==="no-config")return null;if(O==="approvers-dormant"){const D=c&&c.length>0?c.join(", "):"the configured approvers";return a.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:[a.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",D]}),a.jsxs("div",{children:["No caps are set on this profile, so ",D," 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(O==="within-cap")return a.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:a.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(O==="above-approvers"){const D=c&&c.length>0?c.join(", "):"the required approvers";return a.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:[a.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),a.jsxs("div",{children:[a.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",D,". Within-cap actions run per the mode you choose."]})]})}if(O==="hard-ceiling"){const D=Array.from(Y)[0],L=D?(R=l==null?void 0:l.caps)==null?void 0:R[D]:void 0,U=d??"the team admin";return a.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:[a.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),a.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",L??"the configured limit",". Lower your bound or ask ",U," to add an approver path above the cap."]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ne,children:"Save below cap"}),n&&a.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},W=O==="hard-ceiling";return a.jsxs("div",{children:[w.length>0&&a.jsxs("div",{className:"context-section",children:[a.jsxs("div",{className:"bounds-section-header",children:[a.jsx("span",{className:"bounds-section-icon",children:"🛡"}),a.jsxs("div",{children:[a.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),a.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the SP"})]})]}),w.map(([R,D])=>{var U;const L=!!((U=b==null?void 0:b.contextDiscovery)!=null&&U[R]);return a.jsx(Qc,{fieldKey:R,fieldDef:D,value:k[R],onChange:H,prefix:"context",readOnly:r,discoveryIntegrationId:L?b.id:void 0,onLabels:(ee,q)=>P(me=>({...me,[ee]:q}))},`context-${R}`)})]}),m.length>0&&a.jsxs("div",{className:"bounds-section",children:[a.jsxs("div",{className:"bounds-section-header",children:[a.jsx("span",{className:"bounds-section-icon",children:"🔒"}),a.jsxs("div",{children:[a.jsx("div",{className:"bounds-section-title",children:"Limits"}),a.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Service Provider"})]})]}),a.jsx("div",{className:"bounds-fields-grid",children:m.map(([R,D])=>{var L;return a.jsxs("div",{style:{display:"contents"},children:[a.jsx(Qc,{fieldKey:R,fieldDef:D,value:v[R],onChange:V,prefix:"bounds",readOnly:r,twoColumn:!0}),O!=="no-config"&&((L=l==null?void 0:l.caps)==null?void 0:L[R])!==void 0&&a.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:$(R)})]},`bounds-${R}`)})}),_(),x.length>0&&a.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[x.join(", ")," ",x.length===1?"is":"are"," set on the integration, not here — reads are checked on this device, so the limit applies immediately and can be changed any time under"," ",a.jsx(Qe,{to:"/integrations",children:"Integrations"}),"."]})]}),a.jsx("button",{className:"btn btn-primary",onClick:J,disabled:W,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function wy(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 Sy(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const jy="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 wa({target:e,currentText:t,onApply:n,greeting:r,placeholder:s,title:o}){const[i,l]=u.useState([{role:"assistant",content:r??jy}]),[c,d]=u.useState(""),[f,h]=u.useState(!1),[m,x]=u.useState(null),w=u.useRef(null);u.useEffect(()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},[i,f]);const y=async()=>{const g=c.trim();if(!g||f)return;const p=[...i,{role:"user",content:g}];l(p),d(""),x(null),h(!0);try{const v=await A.aiChat({target:e,currentText:t,messages:p.filter((S,k)=>!(k===0&&S.role==="assistant"))});v.success&&v.reply?l(S=>[...S,{role:"assistant",content:v.reply}]):x(v.error??"AI returned no reply")}catch(v){x(v instanceof Error?v.message:"Chat failed")}finally{h(!1)}},j=g=>{g.key==="Enter"&&!g.shiftKey&&!g.nativeEvent.isComposing&&(g.preventDefault(),y())};return a.jsxs("div",{className:"intent-chat",children:[a.jsx("h3",{className:"card-title",children:o??"AI Assistant"}),a.jsxs("div",{ref:w,className:"chat-messages",children:[i.map((g,p)=>{const v=g.role==="assistant"?wy(g.content):null,S=v?Sy(g.content):g.content;return a.jsx("div",{className:`chat-msg ${g.role}`,children:a.jsxs("div",{className:"chat-msg-body",children:[S&&a.jsx("div",{className:"chat-msg-prose",children:S}),v!==null&&a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:"chat-fenced-block",children:v}),a.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(v),children:"Apply this draft"})]})]})},p)}),f&&a.jsx("div",{className:"chat-msg assistant",children:a.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),m&&a.jsx("div",{className:"error-message",children:m}),a.jsxs("div",{className:"chat-composer",children:[a.jsxs("div",{className:"chat-composer-pill",children:[a.jsx("textarea",{className:"chat-input",value:c,onChange:g=>d(g.target.value),onKeyDown:j,placeholder:s??"Ask for help articulating the intent…",rows:1,disabled:f}),a.jsx("button",{type:"button",className:"chat-send-btn",onClick:y,disabled:f||!c.trim(),"aria-label":"Send",children:"↑"})]}),a.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Yf({open:e,onClose:t,children:n,ariaLabel:r}){const s=u.useRef(null),o=u.useRef(null);return u.useEffect(()=>{var l;if(!e)return;o.current=document.activeElement,document.body.style.overflow="hidden";const i=c=>{c.key==="Escape"&&t()};return document.addEventListener("keydown",i),(l=s.current)==null||l.focus(),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="",o.current instanceof HTMLElement&&o.current.focus()}},[e,t]),gf.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:t,"aria-hidden":"true"}),a.jsxs("aside",{ref:s,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":r,tabIndex:-1,children:[a.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),a.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:t,"aria-label":"Close",children:"×"}),n]})]}),document.body)}function ky(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function by(e,t,n){if(t.length===0)return[{text:e,label:e,matched:null}];const r=[],s=new Set;for(const c of t)if(!(!c.scope||c.scope==="all (unscoped)"))for(const d of[c.scope,...c.scope.split(",").map(f=>f.trim())]){const f=d.toLowerCase();d&&!s.has(f)&&(s.add(f),r.push(d))}r.sort((c,d)=>d.length-c.length);const o=c=>{const d=c.toLowerCase();return t.filter(f=>{var h,m;return((h=f.scope)==null?void 0:h.toLowerCase())===d||((m=f.scope)==null?void 0:m.split(",").map(x=>x.trim().toLowerCase()).includes(d))})},i=["\\[\\d+\\]",...r.map(ky)],l=new RegExp(`(${i.join("|")})`,"gi");return e.split(l).filter(c=>c!=="").map(c=>{const d=/^\[(\d+)\]$/.exec(c);if(d){const f=t[Number(d[1])-1];if(f){const h=f.scope&&f.scope!=="all (unscoped)"?f.scope:"all recipients",m=n?`${n}: ${h}`:h;return{text:c,label:m,matched:[f]}}}else if(r.some(f=>f.toLowerCase()===c.toLowerCase())){const f=o(c);if(f.length>0)return{text:c,label:c,matched:f}}return{text:c,label:c,matched:null}})}const Jc=`Why — What's the situation? Why does this need to happen?
|
|
61
|
-
|
|
62
|
-
Goal — What should the agent try to achieve?
|
|
63
|
-
|
|
64
|
-
Watch out — What should the agent avoid or be careful about?`;function Cy(e,t,n,r){return by(e,t,r).map((s,o)=>{if(!s.matched)return a.jsx("span",{children:s.text},o);const i=s.matched;return a.jsx("button",{type:"button",onClick:()=>n(i),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:s.label},o)})}function Ny(){var z;const e=qt(),[t]=$f(),n=Number(t.get("step"))||2,[r,s]=u.useState(null),[o,i]=u.useState(null),[l,c]=u.useState(n),[d,f]=u.useState(null),[h,m]=u.useState(null),[x,w]=u.useState({}),[y,j]=u.useState(Jc),[g,p]=u.useState(!1),[v,S]=u.useState(!0),[k,I]=u.useState(null),[T,P]=u.useState([]),[b,N]=u.useState(void 0),[O,Y]=u.useState(!1),[V,H]=u.useState(null),[C,J]=u.useState(null),[ne,$]=u.useState(null),[_,W]=u.useState([]),[R,D]=u.useState(null);u.useEffect(()=>{var xe;const E=sessionStorage.getItem("agentAuth");if(!E){e("/agent/new");return}const B=JSON.parse(E);s(B);const te=sessionStorage.getItem("agentGate");if(te){const Ee=JSON.parse(te);Ee.bounds&&f(Ee.bounds),Ee.context&&m(Ee.context),(xe=Ee.gateContent)!=null&&xe.intent&&j(Ee.gateContent.intent)}A.getProfile(B.profileId).then(Ee=>i(Ee)).catch(()=>e("/agent/new")).finally(()=>S(!1)),B.groupId&&Promise.all([A.getTeamProfileConfig(B.groupId,B.profileId).catch(()=>null),A.getGroupById(B.groupId).catch(()=>null),A.listUsers().catch(()=>[])]).then(([Ee,Q,re])=>{if(I(Ee),Ee){const he=new Map;for(const ue of re){const kt=ue.name&&ue.email?`${ue.name} (${ue.email})`:ue.name||ue.email||ue.id;he.set(ue.id,kt)}const se=(Q==null?void 0:Q.members)??[];for(const ue of se){const kt=ue.userId??ue.id;kt&&(ue.name&&ue.email?he.set(kt,`${ue.name} (${ue.email})`):ue.name&&he.set(kt,ue.name))}const ce=(Ee.approvers??[]).map(ue=>he.get(ue)??ue);P(ce);const ot=se.find(ue=>ue.role==="admin");if(ot){const ue=ot.userId??ot.id;ue&&N(he.get(ue)??ot.name)}}})},[e]);const L=d?Object.entries(d).filter(([E])=>E!=="profile"&&E!=="path").map(([E,B])=>`${E} = ${B}`).join(", "):"",U=(E,B,te)=>{f(E),m(B),te&&w(te),c(3)},ee=y.trim()!==Jc.trim()&&y.trim()!=="",q=E=>{ee&&!confirm("Replace your current intent with the AI draft?")||j(E)},me=()=>{const E=o==null?void 0:o.ttl,B={intent:y},te=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...te,bounds:d,context:h,contextLabels:x,gateContent:B,ttlConfig:E})),e("/agent/review")},ze=async()=>{if(r){Y(!0),H(null),J(null),$(null),W([]),D(null);try{const E=await A.aiIntentReview({profileId:r.profileId,newIntent:y,context:h??void 0});W(E.grants??[]),E.success?E.review?H(E.review):J(E.note??"No other authorizations on this profile to compare against."):$(E.error??"Check failed.")}catch(E){$(E instanceof Error?E.message:"Check failed.")}finally{Y(!1)}}},Be=E=>{j(E),(V||C||ne)&&(H(null),J(null),$(null),W([]),D(null))};return v||!r||!o?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):a.jsxs(a.Fragment,{children:[a.jsx(Kf,{currentStep:l,onStepClick:E=>{E>=2&&c(E)}}),a.jsx(sy,{profileId:r.profileId,bounds:L||void 0,groupName:r.groupName,domain:r.domain}),l===2&&a.jsx("div",{className:"card",children:a.jsx(xy,{profile:o,onConfirm:U,onCancel:()=>e("/agent/new"),initialBounds:d||void 0,initialContext:h||void 0,profileConfig:k,approverNames:T,adminName:b})}),l===3&&a.jsxs("div",{className:"intent-layout",children:[a.jsx("div",{className:"card intent-pane chat tool",children:a.jsx(wa,{target:{kind:"intent",profileId:r.profileId,bounds:L||void 0},currentText:y,onApply:q})}),a.jsxs("div",{className:"card intent-pane document",children:[a.jsx("h3",{className:"card-title",children:"What should your agent know?"}),a.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[a.jsxs("div",{className:"field-label",children:[a.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),a.jsx("textarea",{className:"intent-textarea",value:y,onChange:E=>Be(E.target.value)}),a.jsxs("div",{className:"char-counter",children:[y.length," / 2000"]})]}),a.jsxs("div",{style:{marginTop:"0.5rem"},children:[a.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:ze,disabled:O||!ee,children:O?"Checking…":"Check against my other grants"}),ne&&a.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeftColor:"var(--danger)"},children:[a.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),a.jsx("div",{className:"hint-body",children:ne})]}),C&&a.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[a.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),a.jsx("div",{className:"hint-body",children:C})]}),V&&a.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[a.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),a.jsxs("div",{className:"hint-body",children:[a.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),a.jsx("div",{style:{whiteSpace:"pre-wrap"},children:Cy(V,_,D,$e(r.profileId))}),a.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),a.jsxs("div",{className:"intent-footer",children:[a.jsx("button",{className:"btn btn-ghost",onClick:()=>c(2),children:"Back"}),a.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:me,disabled:!ee,children:"Continue to Review"})]}),(((z=k==null?void 0:k.approvers)==null?void 0:z.length)??0)>0&&a.jsxs("div",{className:"hint-box",role:"note",children:[a.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),a.jsxs("div",{className:"hint-body",children:[a.jsxs("div",{className:"hint-head",children:["Visible to ",T.length>0?T.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",T.length>0?T.join(", "):"this profile's required approvers",". Only they can decrypt it — your Service Provider cannot. Each approver stores a copy as their accountability record."]})]})]}),a.jsx("button",{type:"button",className:"floating-help",onClick:()=>p(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),a.jsx(Yf,{open:g,onClose:()=>p(!1),ariaLabel:"Intent assistant",children:a.jsx(wa,{target:{kind:"intent",profileId:r.profileId,bounds:L||void 0},currentText:y,onApply:E=>{q(E),p(!1)}})}),R&&a.jsx("div",{className:"modal-backdrop",onClick:E=>E.target===E.currentTarget&&D(null),children:a.jsxs("div",{className:"modal",children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h3",{className:"modal-title",children:R.length>1?`Existing authorizations (${R.length})`:"Existing authorization"}),a.jsx("button",{className:"modal-close",onClick:()=>D(null),children:"×"})]}),a.jsx("div",{className:"modal-body",children:R.map((E,B)=>{var te;return a.jsxs("div",{style:{marginBottom:B<R.length-1?"1rem":0,paddingBottom:B<R.length-1?"1rem":0,borderBottom:B<R.length-1?"1px solid var(--border)":"none"},children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),a.jsx("div",{style:{marginBottom:"0.75rem"},children:E.scope}),a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),a.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((te=E.intent)==null?void 0:te.trim())||"(no intent recorded)"}),Object.entries(E.bounds).filter(([xe])=>xe!=="profile"&&xe!=="path").length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),a.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(E.bounds).filter(([xe])=>xe!=="profile"&&xe!=="path").map(([xe,Ee])=>`${xe}: ${Ee}`).join(" · ")})]})]},B)})})]})})]})]})}function Ey(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
65
|
-
`).split(`
|
|
66
|
-
`).map(s=>s.replace(/[ \t]+$/,"")).join(`
|
|
67
|
-
`).replace(/\n+$/,"")}async function Si(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")}async function Ys(e,t){const n=t.boundsSchema??t.frameSchema;if(!n)throw new Error("Profile has no boundsSchema or frameSchema");const s=n.keyOrder.map(i=>`${i}=${String(e[i])}`).join(`
|
|
68
|
-
`);return`sha256:${await Si(s)}`}async function Qf(e,t){if(!t.contextSchema||t.contextSchema.keyOrder.length===0)return`sha256:${await Si("")}`;const r=t.contextSchema.keyOrder.map(o=>`${o}=${String(e[o])}`).join(`
|
|
69
|
-
`);return`sha256:${await Si(r)}`}async function Sa(e){const t=new TextEncoder().encode(Ey(e)),n=await crypto.subtle.digest("SHA-256",t);return`sha256:${Array.from(new Uint8Array(n)).map(o=>o.toString(16).padStart(2,"0")).join("")}`}function Jf(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,...t.contextLabels&&Object.keys(t.contextLabels).length>0?{contextLabels:t.contextLabels}:{},gateContent:t.gateContent,...t.path?{path:t.path}:{}}}function Xc(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function Ty(e,t){for(const n of e)if(t.has(n))return!0;return!1}function zy(e,t,n){for(const r of e){const s=Xc(t[r]),o=Xc(n[r]);if(!(s.size===0||o.size===0)&&!Ty(s,o))return!1}return!0}function Iy(e){return e.length>24?`${e.slice(0,10)}…`:e}function Xf(e,t,n){const r=n==null?void 0:n[e];return String(t).split(",").map(o=>o.trim()).filter(Boolean).map(o=>{const i=r==null?void 0:r[o];return i?`${i} (${Iy(o)})`:o}).join(", ")}function Py(){var ot,ue,kt;const e=qt(),{user:t,mode:n,domain:r}=Oe(),[s,o]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(null),[f,h]=u.useState("per-action"),[m,x]=u.useState(1800),[w,y]=u.useState(86400),[j,g]=u.useState(""),[p,v]=u.useState("hours"),[S,k]=u.useState(""),[I,T]=u.useState(!0),[P,b]=u.useState(!1),[N,O]=u.useState(""),[Y,V]=u.useState(null),[H,C]=u.useState([]),[J,ne]=u.useState(!1),[$,_]=u.useState([]),[W,R]=u.useState(0);u.useEffect(()=>{var de;const X=sessionStorage.getItem("agentAuth"),ve=sessionStorage.getItem("agentGate");if(!X||!ve){e("/agent/new");return}const M=JSON.parse(X),G=JSON.parse(ve),Z={bounds:G.bounds??{},context:G.context??{},contextLabels:G.contextLabels??void 0,gateContent:G.gateContent};o(M),l(Z),G.ttlConfig&&(x(G.ttlConfig.default??1800),y(G.ttlConfig.max??86400)),G.templateMode==="automatic"?h("immediate"):G.templateMode==="review"&&h("per-action");const ge=((de=G.ttlConfig)==null?void 0:de.max)??86400;if(typeof G.templateTtl=="number"&&G.templateTtl>0){const le=Math.min(G.templateTtl,ge);x(le),[3600,86400,604800,2592e3,31536e3].includes(le)||(le%86400===0?(g(String(le/86400)),v("days")):(g(String(Math.max(1,Math.round(le/3600)))),v("hours")))}A.getProfile(M.profileId).then(le=>{var Pe;if(d(le),!S){const Ze=le.name??((Pe=M.profileId.split("/").pop())==null?void 0:Pe.replace(/@.*$/,""))??"",et=[];if(Z.context&&le.contextSchema)for(const it of le.contextSchema.keyOrder){const oe=Z.context[it];if(oe!==void 0&&oe!==""){const Bt=String(oe).split(",").map(On=>On.trim()).filter(Boolean);et.push(Bt.join(", "))}}const Sn=et.length>0?`${Ze}: ${et.join(" · ")}`:Ze;k(Sn)}}).catch(()=>{}),M.groupId?Promise.all([A.getTeamProfileConfig(M.groupId,M.profileId).catch(()=>null),A.getGroupById(M.groupId).catch(()=>null),A.listUsers().catch(()=>[])]).then(([le,Pe,Ze])=>{if(V(le),le){const et=new Map;for(const oe of Ze){const Bt=oe.name&&oe.email?`${oe.name} (${oe.email})`:oe.name||oe.email||oe.id;et.set(oe.id,Bt)}const Sn=(Pe==null?void 0:Pe.members)??[];for(const oe of Sn){const Bt=oe.userId??oe.id;Bt&&(oe.name&&oe.email?et.set(Bt,`${oe.name} (${oe.email})`):oe.name&&et.set(Bt,oe.name))}const it=(le.approvers??[]).map(oe=>et.get(oe)??oe);C(it)}}).finally(()=>{ne(!0)}):ne(!0)},[e]),u.useEffect(()=>{if(!(s!=null&&s.profileId))return;const X=s.profileId,ve=sessionStorage.getItem("agentEditReplaces");A.getEnrichedAuthorizations().then(M=>{const G=M.filter(Z=>Z.profileId===X&&Z.authorizationId!==ve).map(Z=>({authorizationId:Z.authorizationId,bounds:Z.bounds,context:Z.context??{},intent:Z.intent}));_(G)}).catch(()=>_([]))},[s==null?void 0:s.profileId]),u.useEffect(()=>{if(!i||!c||$.length===0){R(0);return}let X=!1;return(async()=>{const ve=await Ys(i.bounds,c),M=await Promise.all($.map(G=>Ys(G.bounds,c).catch(()=>null)));X||R(M.filter(G=>G===ve).length)})().catch(()=>{X||R(0)}),()=>{X=!0}},[i,c,$]);const D=async()=>{if(!(!s||!i||!c||!t)){if(!s.groupId){O("No active group; cannot create authorization.");return}b(!0),O("");try{const X=r||s.domain||"owner",ve=await Ys(i.bounds,c),M=await Qf(i.context,c),[G,Z]=await Promise.all([Sa(i.gateContent.intent),Sa(JSON.stringify({profile:s.profileId,domain:X,group:s.groupId}))]);let ge,de,le,Pe;if(s.isTeam){const it=await A.getApproversPubkeys(s.groupId,s.profileId);if(it.length>0){const oe=await A.encryptIntent(i.gateContent.intent,it);ge=oe.intentCiphertext,de=oe.encryptedKeys,le=oe.approversFrozen,Pe=oe.intentDisclosureHash}}const Ze=`authz_${crypto.randomUUID()}`,et=sessionStorage.getItem("agentEditReplaces")||void 0,Sn=await A.attest({authorization_id:Ze,replaces:et,profile_id:s.profileId,bounds:i.bounds,bounds_hash:ve,context_hash:M,domain:X,did:t.did,gate_content_hashes:{intent:G},execution_context_hash:Z,group_id:s.groupId,ttl:m,commitment_mode:f==="per-action"?"review":"automatic",title:S.trim(),intent_ciphertext:ge,encrypted_keys:de,approvers_frozen:le,intent_disclosure_hash:Pe,disclose_identity:I});try{await A.pushGateContent(Jf(Sn,{boundsHash:ve,contextHash:M,context:i.context,contextLabels:i.contextLabels,gateContent:i.gateContent}))}catch(it){try{await A.revokeAttestation(Ze,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Authorization signed but gate content delivery failed. The attestation was revoked. Please try again. (${it instanceof Error?it.message:"Unknown error"})`)}if(et)try{await A.revokeAttestation(et,`Replaced by ${Ze} (edit)`),A.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/authorizations?highlight=${encodeURIComponent(Ze)}`)}catch(X){O(X instanceof Error?X.message:"Attestation failed")}finally{b(!1)}}};if(!s||!i)return a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const L=Object.entries(i.bounds).filter(([X])=>X!=="profile"&&X!=="path"),U=Object.entries(i.context),q=((Y==null?void 0:Y.caps)!=null?Object.keys(Y.caps):[]).length!==0,me=H.length>0?H.join(", "):((Y==null?void 0:Y.approvers)??[]).join(", "),ze=q?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${me}, 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.",Be=q?`Over-cap actions will be reviewed by you and ${me}. Within-cap actions run per the mode you chose above.`:`Approvers ${me} can read your intent but won't gate any action — no caps configured on this profile.`,z=!!((ot=Y==null?void 0:Y.approvers)!=null&&ot.length),E=m>w,B={flex:1,padding:"0.75rem",border:f==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:f==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},te={flex:1,padding:"0.75rem",border:f==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:f==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},xe=((ue=c==null?void 0:c.contextSchema)==null?void 0:ue.keyOrder)??[],Ee=$.filter(X=>zy(xe,i.context,X.context)),Q=Ee.length>0,re=$e(s.profileId),he=X=>{const ve=Object.values(X).map(M=>String(M).trim()).filter(Boolean);return ve.length>0?ve.join(", "):"all (unscoped)"},se=Ee.map(X=>he(X.context)).join("; "),ce=`This grant's scope overlaps an existing grant on ${re} (scoped to: ${se}). The agent may act under either. Per-action limits take the more permissive value, and daily limits add together — two grants of 10/day allow 20/day. Approval is not weakened: if either grant requires review, review still applies. Confirm this is intended before authorizing.`;return a.jsxs(a.Fragment,{children:[a.jsx(Kf,{currentStep:4,onStepClick:X=>{X<=3&&e(`/agent/gate?step=${X}`)}}),a.jsxs("div",{className:"card",children:[a.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),a.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your authorization details before signing."}),N&&a.jsx("div",{className:"error-message",children:N}),a.jsxs("div",{className:"field-editable",children:[a.jsxs("div",{className:"field-label",children:[a.jsx("span",{className:"pen",children:"✎"})," Title"]}),a.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${$e(s.profileId)}: daily operations`,value:S,onChange:X=>k(X.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),a.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this authorization on your dashboard."})]}),a.jsxs("div",{className:"field-editable",children:[a.jsxs("div",{className:"field-label",children:[a.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),a.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[a.jsxs("button",{onClick:()=>h("per-action"),style:te,children:[a.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),a.jsxs("button",{onClick:()=>h("immediate"),style:B,children:[a.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]})]}),a.jsxs("div",{className:"field-editable",children:[a.jsxs("div",{className:"field-label",children:[a.jsx("span",{className:"pen",children:"✎"})," Duration"]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",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(X=>X.seconds<=w).map(X=>a.jsx("button",{onClick:()=>{x(X.seconds),g("")},style:{padding:"0.5rem 0.85rem",border:m===X.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:m===X.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:X.label},X.seconds)),a.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[a.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:j,onChange:X=>{g(X.target.value);const ve=parseInt(X.target.value,10);if(ve>0){const M=p==="days"?ve*86400:ve*3600;x(Math.min(M,w))}}}),a.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:p,onChange:X=>{v(X.target.value);const ve=parseInt(j,10);if(ve>0){const M=X.target.value==="days"?ve*86400:ve*3600;x(Math.min(M,w))}},children:[a.jsx("option",{value:"hours",children:"hours"}),a.jsx("option",{value:"days",children:"days"})]})]}),E&&a.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",w>=86400?`${Math.floor(w/86400)} days`:`${Math.floor(w/3600)} hours`]})]})]}),a.jsx("div",{className:"field-editable",children:a.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:I,onChange:X=>T(X.target.checked),style:{marginTop:"0.15rem"}}),a.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this authority",a.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.'})]})]})}),a.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),a.jsxs("div",{className:"info-block",children:[a.jsxs("div",{className:"info-head",children:[a.jsx("span",{className:"info-title",children:"Intent"}),a.jsx("button",{className:"info-edit",onClick:()=>e("/agent/gate?step=3"),children:"edit in step 3"})]}),a.jsx("div",{style:{whiteSpace:"pre-wrap"},children:i.gateContent.intent})]}),(!!L.length||!!U.length)&&a.jsxs("div",{className:"info-block",children:[a.jsxs("div",{className:"info-head",children:[a.jsx("span",{className:"info-title",children:"Scope & Limits"}),a.jsx("button",{className:"info-edit",onClick:()=>e("/agent/gate?step=2"),children:"edit in step 2"})]}),a.jsxs("dl",{className:"info-kv",children:[U.map(([X,ve])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:X}),a.jsx("dd",{children:Xf(X,ve,i.contextLabels)})]},X)),L.map(([X,ve])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:X}),a.jsx("dd",{children:String(ve)})]},X))]})]}),a.jsxs("div",{className:"info-block",children:[a.jsx("div",{className:"info-head",children:a.jsx("span",{className:"info-title",children:"Authority"})}),a.jsxs("dl",{className:"info-kv",children:[a.jsx("dt",{children:"Profile"}),a.jsxs("dd",{children:[$e(s.profileId),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:s.profileId})]}),s.groupName&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Team"}),a.jsx("dd",{children:s.groupName})]}),s.groupId&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Approvers"}),a.jsx("dd",{children:J?(((kt=Y==null?void 0:Y.approvers)==null?void 0:kt.length)??0)===0?a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"None — solo authorization"}),a.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."})]}):a.jsxs(a.Fragment,{children:[me,a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:ze})]}):a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),W>0?a.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:[a.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),a.jsxs("div",{children:[W===1?`An active grant on ${re} already has exactly these limits.`:`${W} active grants on ${re} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",a.jsx("strong",{children:"Extend"})," on the Authorizations page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,Q?a.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:[a.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),a.jsx("div",{children:ce})]})]}):null,a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/agent/gate"),children:"Back"}),a.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:D,disabled:P||!S.trim(),children:P?"Signing...":f==="immediate"?"Authorize":"Authorize (Review Mode)"})]}),a.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:z?"block":"none"},children:Be})]})]})}const Ry={card:"💳",mail:"✉️"};function _y(e){const t=e==null?void 0:e.overrides;return!t||typeof t!="object"?!1:Object.values(t).some(n=>{var r;return typeof((r=n==null?void 0:n.read)==null?void 0:r.ageField)=="string"})}const Ay=[0,7,30,90,365,3650];function jo(e){return e===null?"From your authorization":e===0?"Read nothing":e===1?"1 day back":e===365?"1 year back":e%365===0?`${e/365} years back`:`${e} days back`}function $y({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:s}){var Ee;const[o,i]=u.useState({}),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[h,m]=u.useState({}),[x,w]=u.useState(!1),[y,j]=u.useState(null),[g,p]=u.useState(!1),[v,S]=u.useState(!1),[k,I]=u.useState(!1),[T,P]=u.useState(!1),[b,N]=u.useState({}),[O,Y]=u.useState(null),[V,H]=u.useState(!1),[C,J]=u.useState(null);u.useEffect(()=>{let Q=!1;return A.getCredential(e.id).then(re=>{var he;if(!(Q||!re.configured)){if(c(!0),f(!0),re.fields){const se={};for(const ce of e.credentials.fields)re.fields[ce.key]!=null&&(se[ce.key]=re.fields[ce.key]);m(se)}if(e.oauth){const se=((he=re.fieldNames)==null?void 0:he.includes(e.oauth.tokenStorage))??!1;w(se),se&&A.getOAuthHealth(e.id).then(ce=>{Q||j(ce)})}}}).catch(()=>{}),()=>{Q=!0}},[e.id,e.oauth]);const ne=_y(e.toolGating),$=t?t.readAgeDays??null:void 0,_=V&&O?O.value:$,W=async Q=>{Y({value:Q}),H(!0),J(null);try{await A.setReadPolicy(e.id,Q),s(Q===null?`${e.name} read window now follows your authorization`:`${e.name} read window set to ${jo(Q).toLowerCase()}`),r()}catch(re){J(re instanceof Error?re.message:"Could not save")}finally{H(!1),Y(null)}},R=!!e.oauth||e.credentials.fields.some(Q=>!Q.optional),D=e.oauth?x:l,L=!R||D,U=n==="starting"?"starting":L?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!x?"needs-oauth":"unconfigured",ee=async()=>{if(e.credentials.fields.some(re=>{var he;return(he=o[re.key])==null?void 0:he.trim()})){p(!0);try{await A.setCredential(e.id,o),c(!0),i({}),e.oauth?s(`${e.name} credentials saved!`):(s(`${e.name} credentials saved — starting integration...`),await ze())}catch{s(`Failed to save ${e.name} credentials`)}finally{p(!1)}}},q=async()=>{if(e.credentials.fields.some(re=>{var he;return(he=o[re.key])==null?void 0:he.trim()})){p(!0);try{await A.setCredential(e.id,o),i({}),c(!0),e.oauth?s(`${e.name} credentials saved — now click Connect.`):(P(!1),s(`${e.name} credentials updated — restarting...`),await ze())}catch{s(`Failed to update ${e.name} credentials`)}finally{p(!1)}}},me=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const Q=setInterval(async()=>{var re;try{const he=await A.getCredential(e.id);he.configured&&e.oauth&&((re=he.fieldNames)!=null&&re.includes(e.oauth.tokenStorage))&&(w(!0),P(!1),j(null),clearInterval(Q),s(`${e.name} connected — starting integration...`),A.getOAuthHealth(e.id).then(j).catch(()=>{}),await ze())}catch{}},2e3);setTimeout(()=>clearInterval(Q),12e4)},ze=async()=>{I(!0);try{const Q=await A.activateIntegration(e.id);Q.warning?s(Q.warning):s(`${e.name} integration started with ${Q.tools.length} tools`),r()}catch(Q){s(`Failed to start ${e.name}: ${Q instanceof Error?Q.message:"Unknown error"}`)}finally{I(!1)}},Be=async()=>{try{await A.removeMcpIntegration(e.id),s(`${e.name} integration removed`),r()}catch{s(`Failed to remove ${e.name}`)}},z=Ry[e.icon]??"🔧",E=U==="running"?{c:"int-chip-ok",t:"Running"}:U==="starting"?{c:"int-chip-idle",t:"Starting"}:t&&!t.running&&t.error?{c:"int-chip-bad",t:"Crashed"}:{c:"int-chip-idle",t:"Stopped"},B=e.oauth&&x&&(y==null?void 0:y.status)==="failed",te=R?B?{c:"int-chip-bad",t:"Auth failed"}:D?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},xe=Q=>Q.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return a.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[a.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:z}),a.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:e.name}),a.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[U!=="unconfigured"&&U!=="needs-oauth"&&a.jsxs("span",{className:`int-chip ${E.c}`,children:[a.jsx("span",{className:"int-dot"}),E.t]}),a.jsxs("span",{className:`int-chip ${te.c}`,children:[a.jsx("span",{className:"int-dot"}),te.t]})]})]}),e.oauth&&x&&a.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:y!=null&&y.account?a.jsxs(a.Fragment,{children:["Connected as ",a.jsx("b",{children:y.account})]}):a.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),B&&!T&&a.jsxs("div",{style:{marginTop:"0.7rem"},children:[a.jsxs("div",{className:"status-banner status-banner-error",style:{marginBottom:"0.6rem"},children:[a.jsx("span",{className:"status-banner-icon",children:"!"}),a.jsxs("span",{className:"status-banner-text",children:["Authentication failed",y!=null&&y.error?` — ${y.error}`:"",". Reconnect to restore access."]})]}),a.jsxs("button",{className:"btn btn-primary btn-sm",onClick:me,children:["Reconnect ",e.name]})]}),a.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[a.jsx("summary",{children:"Details"}),a.jsxs("div",{className:"int-meta",children:[a.jsx("span",{className:"int-k",children:"What"}),a.jsx("span",{children:e.description}),e.profile&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"int-k",children:"Profile"}),a.jsx("span",{children:e.profile})]}),e.oauth&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"int-k",children:"Scopes"}),a.jsx("span",{children:((Ee=e.oauth.scopes)==null?void 0:Ee.join(", "))||"—"})]}),t&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"int-k",children:"Tools"}),a.jsxs("span",{children:[t.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(U!=="running"||B)&&a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsxs("button",{onClick:()=>S(!v),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[a.jsx("span",{style:{transition:"transform 0.2s",transform:v?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),v&&a.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((Q,re)=>a.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[a.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:re+1}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:Q.title}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[xe(Q.description),Q.link&&a.jsxs(a.Fragment,{children:[" ",a.jsxs("a",{href:Q.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},re))})]}),U==="starting"&&a.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[a.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),T&&a.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[a.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),d&&a.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(Q=>a.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[a.jsx("label",{className:"form-label",children:Q.label}),Q.type==="password"?a.jsxs("div",{className:"cred-field",children:[a.jsx("input",{className:"form-input",type:b[Q.key]?"text":"password",name:`${e.id}-${Q.key}-credential`,autoComplete:"new-password",placeholder:Q.placeholder,value:o[Q.key]||"",onChange:re=>i(he=>({...he,[Q.key]:re.target.value}))}),a.jsx("button",{className:"cred-toggle",onClick:()=>N(re=>({...re,[Q.key]:!re[Q.key]})),children:b[Q.key]?"hide":"show"})]}):a.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${Q.key}-credential`,autoComplete:"off",placeholder:Q.placeholder,value:o[Q.key]||"",onChange:re=>i(he=>({...he,[Q.key]:re.target.value}))})]},Q.key)),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[a.jsx("button",{className:"btn btn-primary btn-sm",onClick:q,disabled:g,children:g?"Saving…":"Save"}),e.oauth&&a.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:me,children:["Connect ",e.name]}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{P(!1),i({})},children:"Cancel"})]})]}),!T&&U==="running"&&t&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[a.jsx(Qe,{to:"/agent/new",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Authorize agent"}),(e.credentials.fields.length>0||e.oauth)&&a.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{i({...h}),P(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Change credentials"}),a.jsx("span",{style:{flex:1}}),a.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:Be,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"})]}),ne&&_!==void 0&&a.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",marginBottom:"0.35rem"},children:[a.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Read policy"}),a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"How far back your agent may read"})]}),a.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no new authorization needed."}),a.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[Ay.map(Q=>{const re=_===Q;return a.jsx("button",{className:`btn btn-sm ${re?"btn-primary":"btn-secondary"}`,"aria-pressed":re,disabled:V,onClick:()=>W(Q),children:jo(Q)},Q)}),a.jsx("button",{className:`btn btn-sm ${_===null?"btn-primary":"btn-ghost"}`,"aria-pressed":_===null,disabled:V,onClick:()=>W(null),title:"Clear the local setting and use the read window from your signed authorization instead.",children:jo(null)})]}),a.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:C?a.jsx("span",{style:{color:"var(--danger)"},children:C}):V?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):_===null?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your authorization. If none is set there, reads are blocked."}):_===0?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):a.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",_," days is blocked, whoever it is from."]})})]}),a.jsx("div",{style:{display:"none"},children:a.jsx(Qe,{to:"/agent/new",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Authorize your agent"})})]}),U==="unconfigured"&&(()=>{const Q=e.credentials.fields.every(se=>se.optional),re=e.credentials.fields.some(se=>!se.optional),he=e.credentials.fields.some(se=>{var ce;return(ce=o[se.key])==null?void 0:ce.trim()});return a.jsxs(a.Fragment,{children:[d&&a.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:[a.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"," ",a.jsx("button",{onClick:()=>{c(!0),e.oauth&&w(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!d&&a.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&&!d&&a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(se=>a.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[a.jsx("label",{className:"form-label",children:se.label}),se.type==="password"?a.jsxs("div",{className:"cred-field",children:[a.jsx("input",{className:"form-input",type:b[se.key]?"text":"password",name:`${e.id}-${se.key}-credential`,autoComplete:"new-password",placeholder:se.placeholder,value:o[se.key]||"",onChange:ce=>i(ot=>({...ot,[se.key]:ce.target.value}))}),a.jsx("button",{className:"cred-toggle",onClick:()=>N(ce=>({...ce,[se.key]:!ce[se.key]})),children:b[se.key]?"hide":"show"})]}):a.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${se.key}-credential`,autoComplete:"off",placeholder:se.placeholder,value:o[se.key]||"",onChange:ce=>i(ot=>({...ot,[se.key]:ce.target.value}))})]},se.key)),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[he&&a.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:g||re&&!e.credentials.fields.filter(se=>!se.optional).every(se=>{var ce;return(ce=o[se.key])==null?void 0:ce.trim()}),children:g?"Saving...":"Save & Encrypt"}),Q&&!he&&a.jsx("button",{className:"btn btn-primary",onClick:ze,disabled:k,children:k?"Starting...":`Activate ${e.name}`})]})]})})(),U==="needs-oauth"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[a.jsxs("button",{className:"btn btn-primary",onClick:me,children:["Connect ",e.name," Account"]}),a.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Change Credentials"})]})]}),U==="ready"&&!t&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[a.jsx("button",{className:"btn btn-primary",onClick:ze,disabled:k,children:k?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&a.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Update Credentials"}),e.oauth&&a.jsx("button",{className:"btn btn-ghost",onClick:()=>{c(!1),w(!1)},children:"Change Credentials"})]})]}),U==="ready"&&t&&!t.running&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[a.jsx("span",{className:"service-status-dot"}),"Not running"]}),t.error&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:t.error}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{className:"btn btn-primary",onClick:ze,disabled:k,children:k?"Starting...":"Start"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:Be,children:"Disable"})]})]})]})}function Ly(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:s}=El(),[o,i]=u.useState(""),l=u.useCallback(c=>{i(c),setTimeout(()=>i(""),5e3)},[]);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",children:[a.jsx("h1",{className:"page-title",children:"Integrations"}),a.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),o&&a.jsx("div",{className:"alert alert-success",children:o}),e?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):t===!1?a.jsxs("div",{className:"status-banner status-banner-error",children:[a.jsx("span",{className:"status-banner-icon",children:"!"}),a.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):a.jsxs(a.Fragment,{children:[r.map(c=>a.jsx($y,{manifest:c.manifest,integration:c.integration,state:c.state,onStatusChange:s,onSuccess:l},c.id)),r.length===0&&(n?a.jsxs("div",{className:"status-banner status-banner-error",children:[a.jsx("span",{className:"status-banner-icon",children:"!"}),a.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"," ",a.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):a.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."}))]})]})}function My(){var O,Y,V;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Oe(),[s,o]=u.useState(null),[i,l]=u.useState(!1),[c,d]=u.useState(""),[f,h]=u.useState(""),[m,x]=u.useState(!1),[w,y]=u.useState(""),[j,g]=u.useState("");u.useEffect(()=>{fetch("/health").then(H=>H.json()).then(H=>{typeof H.spUrl=="string"&&g(H.spUrl)}).catch(()=>{})},[]),u.useEffect(()=>{if(!e){o(null);return}A.getGroupById(e.id).then(H=>{const C=H.group??H,J=H.members??[],ne=H.isAdmin??!1,$=J.map(_=>{const W=_.userId||_.id||"",R=_.role||(ne&&W===C.createdBy?"admin":"member");return{id:W,name:_.name||W.slice(0,8)||"Member",email:_.email||"",domains:_.domains||[],role:R,isAdmin:R==="admin"||ne&&W===C.createdBy}});o({id:C.id,name:C.name,members:$})}).catch(()=>o(null))},[e==null?void 0:e.id]);const p=(s==null?void 0:s.members.filter(H=>H.isAdmin))??[],v=(e==null?void 0:e.isAdmin)===!0&&p.length<=1&&p.some(H=>H.id===(r==null?void 0:r.id)),S=(e==null?void 0:e.name)??"",k=w.trim()===S&&!i,I=()=>{y(""),x(!0)},T=()=>{x(!1),y("")},P=async()=>{if(!(!e||!k)){l(!0),d("");try{await A.leaveTeam(e.id),await n(),h("You have left the team."),o(null),T()}catch(H){d(H instanceof Error?H.message:"Failed to leave team")}finally{l(!1)}}},b=e&&j?`${j}/dashboard/groups/${e.id}`:void 0,N=j?`${j}/dashboard/groups`:void 0;return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"page-header",children:a.jsxs("div",{children:[a.jsx("h1",{className:"page-title",children:"Team"}),a.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Service Provider dashboard."})]})}),c&&a.jsx("div",{className:"error-message",children:c}),f&&a.jsx("div",{className:"alert alert-success",children:f}),e?a.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[a.jsxs("div",{className:"card-header",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"card-title",children:e.name}),a.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((O=s==null?void 0:s.members)==null?void 0:O.length)??0," ",(((Y=s==null?void 0:s.members)==null?void 0:Y.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),a.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(V=s==null?void 0:s.members)==null?void 0:V.map(H=>a.jsxs("div",{className:"member-row",children:[a.jsx("div",{className:"member-avatar",children:H.name.split(" ").map(C=>C[0]).join("").slice(0,2).toUpperCase()}),a.jsxs("div",{className:"member-info",children:[a.jsx("div",{className:"member-name",children:H.name}),a.jsx("div",{className:"member-email",children:H.email})]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:H.role})]},H.id)),a.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[b&&a.jsx("a",{className:"btn btn-secondary btn-sm",href:b,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Service Provider →"}),a.jsx("span",{title:v?"You are the only admin. Transfer admin to another member in your Service Provider dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:a.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:I,disabled:i||v,children:"Leave team"})})]})]}):a.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[a.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),a.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."}),N&&a.jsx("a",{className:"btn btn-primary btn-sm",href:N,target:"_blank",rel:"noopener noreferrer",children:"Open Service Provider dashboard →"})]}),m&&e&&a.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:T,children:a.jsxs("div",{className:"card",onClick:H=>H.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[a.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",S,"?"]}),a.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),a.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[a.jsx("li",{children:"Revoke all authorizations you created in this team's context"}),a.jsx("li",{children:"Reject any pending action proposals you authored"}),a.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),a.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",a.jsx("strong",{children:"personal"})," authorizations are not affected."]}),a.jsxs("div",{className:"form-group",children:[a.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",a.jsx("code",{children:S})," to confirm:"]}),a.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:w,onChange:H=>y(H.target.value),placeholder:S,disabled:i,autoFocus:!0})]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[a.jsx("button",{className:"btn btn-ghost",onClick:T,disabled:i,children:"Cancel"}),a.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:P,disabled:!k,children:i?"Leaving...":"Leave team"})]})]})})]})}function Fy({onDismiss:e}){const t=qt(),{group:n,groupId:r,domain:s}=Oe(),[o,i]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState([]),[h,m]=u.useState(!0),[x,w]=u.useState({}),[y,j]=u.useState(null);u.useEffect(()=>{Promise.all([A.listProfiles().catch(()=>[]),A.getIntegrationManifests().then(b=>b.manifests??[]).catch(()=>[]),A.getMcpHealth().then(b=>b.integrations??[]).catch(()=>[])]).then(async([b,N,O])=>{if(i(b),c(N),f(O),r){const Y=await Promise.all(b.map(H=>A.getTeamProfileConfig(r,H.id).catch(()=>null))),V={};b.forEach((H,C)=>{const J=Y[C];J&&(V[H.id]=J)}),w(V)}}).finally(()=>m(!1))},[r]);const g=new Map;for(const b of l)b.profile&&g.set(b.profile,b);const p=b=>b.replace(/@.*$/,"").split("/").pop()??b,v=b=>b.split("@")[1]??"",S=new Map;for(const b of o){const N=p(b.id);if(!g.has(N))continue;const O=S.get(N);(!O||v(b.id).localeCompare(v(O.id),void 0,{numeric:!0})>0)&&S.set(N,b)}const k=l.map(b=>{const N=b.profile?S.get(b.profile):void 0;return N?{manifest:b,profile:N,integration:d.find(O=>O.id===b.id)}:null}).filter(b=>b!==null),I=b=>b in x,T=(b,N)=>{if(!r){console.error("No active group when creating authorization");return}const O=I(b);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:b,groupId:r,groupName:(n==null?void 0:n.name)??null,domain:s,isTeam:O})),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")},P=(b,N)=>{r&&(N!=null&&N.templates&&N.templates.length>0?j({profileId:b,manifest:N}):T(b))};if(y){const b=y.manifest.templates??[];return a.jsxs(a.Fragment,{children:[a.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginBottom:"1rem"},onClick:()=>j(null),children:"← Back to profiles"}),a.jsxs("h3",{style:{margin:"0 0 0.25rem 0",fontSize:"1rem"},children:["Set up ",y.manifest.name," authorization"]}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.5rem",marginBottom:"0.75rem",fontWeight:600},children:"Quick start"}),a.jsx("div",{style:{display:"grid",gap:"0.75rem",gridTemplateColumns:`repeat(${Math.min(b.length,3)}, 1fr)`},children:b.map(N=>a.jsxs("button",{className:"template-card",onClick:()=>T(y.profileId,N),children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.375rem"},children:[a.jsx("span",{className:`template-mode template-mode-${N.mode==="automatic"?"auto":"review"}`,children:N.mode==="automatic"?"Auto":"Review"}),a.jsx("span",{className:"template-risk","data-risk":N.risk,children:N.risk})]}),a.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.25rem"},children:N.name}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",lineHeight:1.45,marginBottom:"0.5rem"},children:N.description}),a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.3rem"},children:N.tags.map(O=>a.jsx("span",{className:"template-tag",children:O},O))})]},N.name))}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",margin:"1.5rem 0"},children:[a.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}}),a.jsx("span",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"or"}),a.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}})]}),a.jsx("button",{className:"btn btn-primary",style:{width:"100%",textAlign:"center",padding:"0.75rem"},onClick:()=>T(y.profileId),children:"Custom — define your own limits and scope"})]})}return a.jsxs(a.Fragment,{children:[a.jsx("style",{children:`
|
|
70
|
-
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
|
|
71
|
-
.profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
|
|
72
|
-
@media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
|
|
73
|
-
@media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
|
|
74
|
-
`}),h?a.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):k.length===0?a.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[a.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),a.jsx(Qe,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):a.jsx("div",{className:"profile-grid",children:k.map(({manifest:b,profile:N,integration:O})=>{const Y=I(N.id),V=(O==null?void 0:O.running)===!0;return a.jsxs("div",{className:"card",style:V?void 0:{opacity:.7},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[a.jsx("h3",{className:"card-title",style:{margin:0},children:b.name}),Y?a.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"}):a.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"})]}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:b.description||N.description}),V?a.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>P(N.id,b),children:"Authorize"}):a.jsxs(Qe,{to:`/integrations?setup=${(b==null?void 0:b.id)??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",(b==null?void 0:b.name)??"integration"]})]},b.id)})})]})}const Oy={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function By({status:e,label:t}){return a.jsx("span",{className:`status-badge status-${e}`,children:t||Oy[e]})}function Dy({domain:e,attested:t}){const n=t===!0?"domain-attested":t===!1?"domain-missing":"";return a.jsx("span",{className:`domain-badge ${n}`,style:{fontSize:"0.75rem"},children:e})}const Cn=86400,Pr=3600,_s=60,Uy=30*Cn;function Wy(e){if(e<=0)return"Expired";if(e>90*Cn){const t=Math.floor(e/Uy);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*Cn){const t=Math.floor(e/Cn);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*Cn){const t=Math.floor(e/Cn),n=Math.floor(e%Cn/Pr);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*Pr){const t=Math.floor(e/Pr),n=Math.floor(e%Pr/_s);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=_s){const t=Math.floor(e/_s),n=Math.floor(e%_s);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function Hy({expiresAt:e}){const[t,n]=u.useState(()=>e-Date.now()/1e3),r=t<2*Pr;u.useEffect(()=>{const o=setInterval(()=>n(e-Date.now()/1e3),r?1e3:6e4);return()=>clearInterval(o)},[e,r]);const s=t<300;return a.jsx("span",{className:`ttl-badge ${s?"ttl-warn":"ttl-ok"}`,children:Wy(t)})}function qf({icon:e,title:t,text:n,children:r}){return a.jsxs("div",{className:"empty-state",children:[e&&a.jsx("div",{className:"empty-state-icon",children:e}),a.jsx("div",{className:"empty-state-title",children:t}),n&&a.jsx("div",{className:"empty-state-text",children:n}),r]})}function Vy(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 Gy=[{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 Ky({item:e,onClose:t,onSuccess:n}){var g;const{user:r,activeDomain:s,groupId:o}=Oe(),i=e.remaining_seconds??0,l=Gy.filter(p=>p.seconds>i),c=((g=l[0])==null?void 0:g.seconds)??2592e3,[d,f]=u.useState(c),[h,m]=u.useState(!1),[x,w]=u.useState(""),y=Object.entries(e.frame).filter(([p])=>p!=="profile"&&p!=="path"),j=async()=>{var p;if(r){m(!0),w("");try{const v=e.authorization_id,S=await A.getGateContent(v);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 k=await A.getProfile(e.profile_id),I=e.frame,T=S.context??{},P=e.attested_domains[0]||s||"owner",b=await Ys(I,k),N=await Qf(T,k),[O,Y]=await Promise.all([Sa(S.gateContent.intent),Sa(JSON.stringify({profile:e.profile_id,path:e.path,domain:P}))]);if(!o)throw new Error("No active group; cannot extend authorization.");const V=(((p=e.deferred_commitment_domains)==null?void 0:p.length)??0)>0?"review":"automatic",H=await A.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:I,bounds_hash:b,context_hash:N,domain:P,did:r.did,gate_content_hashes:{intent:O},execution_context_hash:Y,group_id:o,commitment_mode:V,ttl:d});await A.pushGateContent(Jf(H,{boundsHash:b,contextHash:N,context:T,path:e.path,gateContent:S.gateContent})),n()}catch(v){w(v instanceof Error?v.message:"Extension failed")}finally{m(!1)}}};return a.jsx("div",{className:"modal-backdrop",onClick:p=>p.target===p.currentTarget&&t(),children:a.jsxs("div",{className:"modal",children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h3",{className:"modal-title",children:"Extend Authorization"}),a.jsx("button",{className:"modal-close",onClick:t,children:"×"})]}),a.jsxs("div",{className:"modal-body",children:[a.jsxs("div",{style:{marginBottom:"1rem"},children:[a.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[$e(e.profile_id)," / ",e.path]}),y.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:y.map(([p,v])=>`${p}=${v}`).join(" · ")})]}),a.jsxs("div",{style:{marginBottom:"1rem"},children:[a.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&&a.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",Vy(i),". Only longer durations are shown."]}),a.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:l.length===0?a.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(p=>a.jsx("button",{className:`btn ${d===p.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>f(p.seconds),style:{minWidth:"3.5rem"},children:p.label},p.seconds))})]}),a.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)."}),x&&a.jsx("div",{className:"error-message",children:x})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx("button",{className:"btn btn-secondary",onClick:t,disabled:h,children:"Cancel"}),a.jsx("button",{className:"btn btn-primary",onClick:j,disabled:h,children:h?"Extending...":"Extend"})]})]})})}function Yy(e,t,n){return[...e].sort((r,s)=>{if(n){if(r.authorization_id===n&&s.authorization_id!==n)return-1;if(s.authorization_id===n&&r.authorization_id!==n)return 1}const o=At(r,{revokedSet:t}),i=At(s,{revokedSet:t}),l={active:0,pending:1,expired:2,revoked:3};return l[o]!==l[i]?l[o]-l[i]:new Date(s.created_at).getTime()-new Date(r.created_at).getTime()})}function Qy({item:e,newerProfile:t,revokedSet:n,expandedHash:r,gateCache:s,gateLoading:o,copiedHash:i,revokingHash:l,copyingHash:c,profileConfigCache:d,mode:f,ownerLabel:h,isAdmin:m,onExpand:x,onCopyHash:w,onCopy:y,onRevoke:j,onExtend:g,highlightHash:p}){var D;const v=At(e,{revokedSet:n}),S=r===e.authorization_id,k=s[e.authorization_id],I=v==="active"||v==="pending"||v==="expired",T=Object.entries(e.frame).filter(([L])=>L!=="profile"&&L!=="path"),P=d.get(e.profile_id)??null,b=(((D=P==null?void 0:P.approvers)==null?void 0:D.length)??0)>0,N=new Map;if(P!=null&&P.caps&&f==="team")for(const[L,U]of T){const ee=P.caps[L];ee!==void 0&&Number(U)>ee&&N.set(L,{authorized:Number(U),cap:ee})}const O=N.size>0,Y=e.approvers_frozen??[],V=(P==null?void 0:P.approvers)??[],H=f==="team"&&Y.length>0&&V.length>0&&(Y.length!==V.length||Y.some(L=>!V.includes(L))||V.some(L=>!Y.includes(L))),C=Array.from(N.entries()).map(([L,U])=>`${L}: ${U.authorized} (cap ${U.cap})`).join(", "),J=Array.from(N.entries()).map(([L,U])=>`${L}: ${U.authorized} → ${U.cap}`).join(", "),ne=O?b?N.size===1?`Above team cap: ${C} — actions require approval`:`Above team cap (${N.size}): ${C} — actions require approval`:N.size===1?`Reduced by hard cap: ${J}`:`Reduced by hard cap (${N.size}): ${J}`:"",$=O?b?"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,_=$e(e.profile_id),W=t?a.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem",padding:"0.4rem 0.6rem",border:"1px solid var(--border)",borderRadius:6},children:[a.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[_,"@",t.version," available"]}),t.whatsNew?a.jsxs(a.Fragment,{children:[" — ",t.whatsNew]}):null,a.jsx("br",{}),a.jsxs("span",{children:["This authority stays on ",e.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,R=p!=null&&e.authorization_id===p;return a.jsxs("div",{className:`card${R?" card-highlight":""}`,style:{marginBottom:0},children:[W,h&&a.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",a.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:h})]}),a.jsxs("div",{className:"auth-card-header",children:[a.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:_}),e.title&&a.jsx("span",{style:{fontWeight:500,fontSize:"0.85rem",color:"var(--text-secondary)"},children:e.title}),a.jsx(By,{status:v}),v==="active"&&e.earliest_expiry&&a.jsx(Hy,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),v==="expired"&&a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:new Date(e.created_at).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[e.required_domains.map(L=>a.jsx(Dy,{domain:L,attested:e.attested_domains.includes(L)},L)),e.deferred_commitment_domains.length>0&&a.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"}),O&&a.jsx("span",{title:$,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:b?"var(--accent-subtle)":"var(--danger-subtle)",color:b?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:ne}),H&&a.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:()=>y(e),disabled:c===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:c===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),T.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:T.map(([L,U],ee)=>{const q=N.get(L);return a.jsxs("span",{children:[ee>0&&" · ",q?b?a.jsxs("span",{title:`Team cap on ${L} is ${q.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${q.authorized}.`,children:[a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[L,"=",String(U)]}),a.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",q.cap]})]}):a.jsxs("span",{title:`Team cap on ${L} is ${q.cap} with no approvers configured (hard cap). Authorized for ${q.authorized}; effective ${q.cap}.`,children:[a.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[L,"=",String(U)]}),a.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",q.cap]})]}):a.jsxs("span",{children:[L,"=",String(U)]})]},L)})}),a.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>x(e),children:S?"▲ Hide Details":"▼ Details"})}),S&&a.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[T.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),a.jsx("dl",{className:"review-grid",children:T.map(([L,U])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:L}),a.jsx("dd",{children:String(U)})]},L))})]}),(k==null?void 0:k.context)&&Object.keys(k.context).length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Context"}),a.jsx("dl",{className:"review-grid",children:Object.entries(k.context).map(([L,U])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:L}),a.jsx("dd",{title:String(U),children:Xf(L,U,k.contextLabels)})]},L))})]}),a.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),o===e.authorization_id?a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):k?a.jsx("div",{className:"gate-content-block",children:a.jsx("div",{className:"gate-content-item",children:a.jsx("div",{className:"gate-content-text",children:k.gateContent.intent})})}):a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),a.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()}`]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:e.authorization_id}),a.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>w(e.authorization_id),children:i===e.authorization_id?"copied":"copy"})]}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!h&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>y(e),disabled:c===e.authorization_id,title:"Start a new authorization pre-filled with these bounds, context, and intent",children:c===e.authorization_id?"Copying…":"⧉ Copy"}),!h&&(v==="active"||v==="pending")&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>y(e,{asEdit:!0}),disabled:c===e.authorization_id,title:"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new authorization revokes this one",children:"✎ Edit"}),!h&&I&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>g(e),children:"↻ Extend"}),h&&m&&v!=="revoked"?a.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>j(e.authorization_id,h,_),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):!h&&(v==="active"||v==="pending")?a.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>j(e.authorization_id),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]},e.authorization_id)}function Jy(){const[e,t]=u.useState([]),[n,r]=u.useState(!0),[s,o]=u.useState([]),[i,l]=u.useState(!1),[c,d]=u.useState(new Map),[f,h]=u.useState("mine"),[m,x]=u.useState("active"),[w,y]=u.useState(null),[j,g]=u.useState(null),[p,v]=$f(),[S,k]=u.useState(()=>p.get("new")==="1"),[I,T]=u.useState(()=>p.get("highlight")),[P,b]=u.useState(null),[N,O]=u.useState({}),[Y,V]=u.useState(null),[H,C]=u.useState(null),[J,ne]=u.useState(null),[$,_]=u.useState(new Set),[W,R]=u.useState(null),[D,L]=u.useState(null),U=qt(),{group:ee,groupId:q,domain:me,mode:ze,activeTeam:Be}=Oe(),z=(Be==null?void 0:Be.isAdmin)===!0,[E,B]=u.useState(()=>new Map),te=u.useCallback(()=>{r(!0),A.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),xe=u.useCallback(()=>{q&&(l(!0),A.listTeamAuthorizations(q).then(o).catch(()=>{}).finally(()=>l(!1)))},[q]);fe("attestation-changed",()=>{te(),z&&q&&xe()}),u.useEffect(()=>{if(!I)return;p.get("highlight")&&(p.delete("highlight"),v(p,{replace:!0}));const M=window.setTimeout(()=>T(null),3e3);return()=>window.clearTimeout(M)},[]),Lt(te,3e5),u.useEffect(()=>{f==="team"&&z&&q&&s.length===0&&!i&&xe()},[f,z,q,s.length,i,xe]),u.useEffect(()=>{let M=!1;return A.listProfiles().then(G=>{if(M)return;const Z=le=>le.replace(/@.*$/,"").split("/").pop()??le,ge=le=>le.split("@")[1]??"",de=new Map;for(const le of G){const Pe=Z(le.id),Ze=de.get(Pe);(!Ze||ge(le.id).localeCompare(ge(Ze.id),void 0,{numeric:!0})>0)&&de.set(Pe,le)}d(de)}).catch(()=>{}),()=>{M=!0}},[]);const Ee=u.useCallback(M=>{const G=Pe=>Pe.replace(/@.*$/,"").split("/").pop()??Pe,Z=Pe=>Pe.split("@")[1]??"",ge=c.get(G(M));if(!ge)return;const de=Z(M),le=Z(ge.id);if(!(!de||!le))return le.localeCompare(de,void 0,{numeric:!0})>0?ge:void 0},[c]);u.useEffect(()=>{if(ze!=="team"||!q)return;const M=f==="mine"?e:s;if(M.length===0)return;const G=[...new Set(M.map(Z=>Z.profile_id))].filter(Z=>!E.has(Z));if(G.length!==0){B(Z=>{const ge=new Map(Z);for(const de of G)ge.set(de,null);return ge});for(const Z of G)A.getTeamProfileConfig(q,Z).then(ge=>{B(de=>new Map(de).set(Z,ge))}).catch(()=>{})}},[e,s,f,q,ze,E]);const Q=async M=>{if(P===M.authorization_id){b(null);return}b(M.authorization_id);const G=M.authorization_id;if(!(G in N)){V(M.authorization_id);try{const Z=await A.getGateContent(G);O(ge=>({...ge,[G]:Z}))}catch{O(Z=>({...Z,[G]:null}))}finally{V(null)}}},re=M=>{navigator.clipboard.writeText(M).then(()=>{ne(M),setTimeout(()=>ne(null),2e3)})},he=async(M,G)=>{var Z;if(!q){alert("No active group; cannot copy authorization.");return}L(M.authorization_id);try{const ge=M.authorization_id;let de=N[ge]??null;ge in N||(de=await A.getGateContent(ge),O(On=>({...On,[ge]:de})));const le=Object.fromEntries(Object.entries(M.frame).filter(([On])=>On!=="profile"&&On!=="path")),Pe=(de==null?void 0:de.context)??{},Ze=((Z=de==null?void 0:de.gateContent)==null?void 0:Z.intent)??"",et=M.deferred_commitment_domains.length>0?"review":"automatic",Sn=M.attested_domains[0]||me||"owner",it=Date.parse(M.created_at),oe=M.earliest_expiry?Date.parse(M.earliest_expiry):NaN,Bt=Number.isFinite(it)&&Number.isFinite(oe)&&oe>it?Math.round((oe-it)/1e3):void 0;sessionStorage.setItem("agentAuth",JSON.stringify({profileId:M.profile_id,groupId:q,groupName:(ee==null?void 0:ee.name)??null,domain:Sn})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:le,context:Pe,gateContent:{intent:Ze},templateMode:et,templateTtl:Bt})),G!=null&&G.asEdit?sessionStorage.setItem("agentEditReplaces",M.authorization_id):sessionStorage.removeItem("agentEditReplaces"),U("/agent/gate")}catch(ge){alert(ge instanceof Error?ge.message:"Failed to copy authorization")}finally{L(null)}},se=async(M,G,Z)=>{const ge=G&&Z?`Revoke ${G}'s ${Z} authorization? This cannot be undone.`:"Revoke this authorization? The agent will no longer be able to execute actions under this attestation.";if(confirm(ge)){R(M);try{await A.revokeAttestation(M),_(de=>new Set(de).add(M)),A.resyncGates().catch(()=>{}),G&&q&&xe()}catch(de){alert(de instanceof Error?de.message:"Failed to revoke authorization")}finally{R(null)}}},ce=f==="mine"?e:s,ot=f==="mine"?n:i,ue={active:ce.filter(M=>At(M,{revokedSet:$})==="active").length,pending:ce.filter(M=>At(M,{revokedSet:$})==="pending").length,expired:ce.filter(M=>At(M,{revokedSet:$})==="expired").length,revoked:ce.filter(M=>At(M,{revokedSet:$})==="revoked").length},kt=(()=>{const M=new Map;for(const G of ce){if(At(G,{revokedSet:$})!==m)continue;const Z=M.get(G.profile_id)??{count:0,review:!1};Z.count+=1,G.deferred_commitment_domains.length>0&&(Z.review=!0),M.set(G.profile_id,Z)}return Array.from(M.entries()).map(([G,Z])=>({profileId:G,...Z})).sort((G,Z)=>$e(G.profileId).localeCompare($e(Z.profileId)))})(),X=Yy(ce.filter(M=>{if(At(M,{revokedSet:$})!==m||w!==null&&M.profile_id!==w)return!1;if(j!==null){const G=M.deferred_commitment_domains.length>0;if(j==="review"&&!G||j==="auto"&&G)return!1}return!0}),$,I),ve={revokedSet:$,expandedHash:P,gateCache:N,gateLoading:Y,copiedHash:J,revokingHash:W,copyingHash:D,profileConfigCache:E,mode:ze,activeDomain:me,group:ee,groupId:q,onExpand:Q,onCopyHash:re,onCopy:he,onRevoke:se,onExtend:C,highlightHash:I};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[a.jsxs("div",{children:[a.jsx("h1",{className:"page-title",children:"Authorizations"}),a.jsx("p",{className:"page-subtitle",children:"Active, pending, and expired agent authorizations."})]}),a.jsx("button",{className:"btn btn-primary",onClick:()=>k(!0),children:"+ New authorization"})]}),S&&a.jsx("div",{className:"modal-backdrop",onClick:()=>{k(!1),p.get("new")&&(p.delete("new"),v(p,{replace:!0}))},children:a.jsxs("div",{className:"modal",onClick:M=>M.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h2",{className:"modal-title",children:"New authorization"}),a.jsx("button",{className:"modal-close",onClick:()=>{k(!1),p.get("new")&&(p.delete("new"),v(p,{replace:!0}))},children:"×"})]}),a.jsxs("div",{className:"modal-body",children:[a.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."}),a.jsx(Fy,{onDismiss:()=>k(!1)})]})]})}),z&&a.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[a.jsx("button",{className:`nav-tab${f==="mine"?" active":""}`,onClick:()=>{h("mine"),x("active"),y(null),g(null),b(null)},children:"Mine"}),a.jsx("button",{className:`nav-tab${f==="team"?" active":""}`,onClick:()=>{h("team"),x("active"),y(null),g(null),b(null)},children:"Team"})]}),a.jsx("div",{className:"nav-tabs",children:["active","pending","expired","revoked"].map(M=>a.jsxs("button",{className:`nav-tab${m===M?" active":""}`,onClick:()=>{x(M),y(null),g(null)},children:[M.charAt(0).toUpperCase()+M.slice(1)," (",ue[M],")"]},M))}),kt.length>0&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[kt.map(M=>{const G=w===M.profileId;return a.jsx("button",{className:`btn btn-sm ${G?"btn-primary":"btn-secondary"}`,onClick:()=>y(G?null:M.profileId),children:$e(M.profileId)},M.profileId)}),a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(M=>{const G=j===M;return a.jsx("button",{className:`btn btn-sm ${G?"btn-primary":"btn-secondary"}`,onClick:()=>g(G?null:M),children:M==="auto"?"Auto":"Review"},M)})]}),ot&&ce.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):X.length===0?a.jsx(qf,{icon:"☰",title:"No authorizations",text:`No ${m} authorizations found.`}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:X.map(M=>{const G=f==="team"?M:null,Z=G!=null&&G.owner?G.owner.name??G.owner.email??G.owner.userId:void 0;return a.jsx(Qy,{item:M,newerProfile:Ee(M.profile_id),ownerLabel:Z,isAdmin:z,...ve},M.authorization_id)})}),H&&a.jsx(Ky,{item:H,onClose:()=>C(null),onSuccess:()=>{C(null),te()}})]})}function Xy(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function qy(e,t){var c,d,f;const{integrationId:n,toolName:r}=Xy(e.action),s=t.find(h=>h.id===n),o=(d=(c=s==null?void 0:s.toolGating)==null?void 0:c.overrides)==null?void 0:d[r];if(o!=null&&o.actionLabel)return o.actionLabel;const i=$e(e.profileId),l=(f=e.executionContext)==null?void 0:f.action_type;return typeof l=="string"&&l?`${i} · ${l}`:`${i} · ${r}`}function qc(e){const t=[];for(const[n,r]of Object.entries(e.executionContext??{})){if(!n.startsWith("allowed_"))continue;const s=String(r??"").trim();s&&t.push(s.split(",").map(o=>o.trim()).filter(Boolean).join(", "))}return t.join(" · ")}function Zy(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function ex(e){const t=$e(e),n=e.split("@")[1];return n?`${t}@${n}`:t}function tx(e){return new Date(e*1e3).toLocaleString()}function nx(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 rx(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||$e(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 Zc(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,s)=>s.timestamp-r.timestamp)}function sx(){const{activeTeam:e,groupId:t}=Oe(),n=(e==null?void 0:e.isAdmin)===!0,[r,s]=u.useState("mine"),[o,i]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState(""),[h,m]=u.useState(!0),[x,w]=u.useState({}),[y,j]=u.useState(new Set),[g,p]=u.useState(""),[v,S]=u.useState(new Set),[k,I]=u.useState(new Set),[T,P]=u.useState("all"),[b,N]=u.useState(!1),[O,Y]=u.useState(null),[V,H]=u.useState(!1),[C,J]=u.useState(!1),ne=u.useRef(""),$=u.useCallback(z=>r==="team"&&n&&t?A.listTeamReceiptsPage(t,{before:z,limit:200}):A.getMyReceiptsPage({before:z,limit:200}),[r,n,t]),_=u.useCallback(()=>{const z=r==="team"?`team:${t}`:"mine",E=ne.current!==z;ne.current=z,m(!0),J(!1),$().then(B=>{i(te=>E?B.receipts:Zc(te,B.receipts)),Y(te=>E?B.nextBefore:te??B.nextBefore)}).catch(()=>{E&&i([]),J(!0)}).finally(()=>m(!1))},[$,r,t]),W=u.useCallback(()=>{!O||V||(H(!0),J(!1),$(O).then(z=>{i(E=>Zc(E,z.receipts)),Y(z.nextBefore)}).catch(()=>J(!0)).finally(()=>H(!1)))},[O,V,$]);Lt(_,12e4),u.useEffect(()=>{A.getIntegrationManifests().then(({manifests:z})=>c(z)).catch(()=>{}),fetch("/health").then(z=>z.json()).then(z=>{typeof z.spUrl=="string"&&f(z.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),u.useEffect(()=>{r!=="team"||Object.keys(x).length>0||A.listUsers().then(z=>{const E={};for(const B of z)E[B.id]={name:B.name,email:B.email};w(E)}).catch(()=>{})},[r,x]);const R=u.useMemo(()=>{const z=new Set;for(const E of o)z.add($e(E.profileId));return[...z].sort()},[o]),D=u.useMemo(()=>{const z=new Set;for(const E of o)z.add(E.action);return[...z].sort()},[o]),L=u.useMemo(()=>{if(r!=="team")return[];const z=new Set;for(const E of o)E.userId&&z.add(E.userId);return[...z].map(E=>{var B;return{id:E,label:(B=x[E])!=null&&B.name?`${x[E].name} (${x[E].email})`:E}}).sort((E,B)=>E.label.localeCompare(B.label))},[r,o,x]),U=u.useMemo(()=>o.filter(z=>!(!rx(z,g)||v.size>0&&!v.has($e(z.profileId))||k.size>0&&!k.has(z.action)||y.size>0&&z.userId&&!y.has(z.userId)||!nx(z,T))),[o,g,v,k,y,T]),ee=v.size>0||k.size>0||y.size>0||T!=="all";function q(z){S(E=>{const B=new Set(E);return B.has(z)?B.delete(z):B.add(z),B})}function me(z){I(E=>{const B=new Set(E);return B.has(z)?B.delete(z):B.add(z),B})}function ze(z){j(E=>{const B=new Set(E);return B.has(z)?B.delete(z):B.add(z),B})}function Be(){S(new Set),I(new Set),j(new Set),P("all"),p("")}return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",children:[a.jsx("h1",{className:"page-title",children:"Receipts"}),a.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),n&&a.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(z=>a.jsx("button",{onClick:()=>s(z),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===z?"2px solid var(--accent)":"2px solid transparent",color:r===z?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===z?600:500},children:z==="mine"?"Mine":"Team"},z))}),a.jsxs("div",{className:"search-filter-bar",children:[a.jsxs("div",{className:"search-input-wrap",children:[a.jsx("span",{className:"search-icon",children:"⌕"}),a.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:g,onChange:z=>p(z.target.value)}),g&&a.jsx("button",{className:"search-clear",onClick:()=>p(""),children:"×"})]}),a.jsxs("button",{className:`btn btn-sm btn-secondary${b?" active":""}`,onClick:()=>N(!b),children:["Filters",ee?` (${v.size+k.size+(T!=="all"?1:0)})`:""]})]}),b&&a.jsxs("div",{className:"filter-panel",children:[R.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Profile"}),a.jsx("div",{className:"filter-chips",children:R.map(z=>a.jsx("button",{className:`filter-chip${v.has(z)?" selected":""}`,onClick:()=>q(z),children:z},z))})]}),D.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Action"}),a.jsx("div",{className:"filter-chips",children:D.map(z=>a.jsx("button",{className:`filter-chip${k.has(z)?" selected":""}`,onClick:()=>me(z),children:z},z))})]}),r==="team"&&L.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Owner"}),a.jsx("div",{className:"filter-chips",children:L.map(z=>a.jsx("button",{className:`filter-chip${y.has(z.id)?" selected":""}`,onClick:()=>ze(z.id),children:z.label},z.id))})]}),a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Time range"}),a.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([z,E])=>a.jsx("button",{className:`filter-chip${T===z?" selected":""}`,onClick:()=>P(z),children:E},z))})]})]}),ee&&a.jsxs("div",{className:"active-filters",children:[[...v].map(z=>a.jsxs("span",{className:"active-chip",onClick:()=>q(z),children:[z," ",a.jsx("span",{className:"chip-remove",children:"×"})]},z)),[...k].map(z=>a.jsxs("span",{className:"active-chip",onClick:()=>me(z),children:[z," ",a.jsx("span",{className:"chip-remove",children:"×"})]},z)),[...y].map(z=>{const E=x[z],B=E?E.name:z;return a.jsxs("span",{className:"active-chip",onClick:()=>ze(z),children:[B," ",a.jsx("span",{className:"chip-remove",children:"×"})]},z)}),T!=="all"&&a.jsxs("span",{className:"active-chip",onClick:()=>P("all"),children:[T==="1d"?"Today":T==="7d"?"7 days":"30 days"," ",a.jsx("span",{className:"chip-remove",children:"×"})]}),a.jsx("button",{className:"clear-filters",onClick:Be,children:"Clear all"})]}),C&&a.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:a.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."})}),h&&o.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):U.length===0?a.jsx(qf,{icon:"⌕",title:o.length===0?"No receipts in the last 30 days":"No matching receipts",text:o.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."}):a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:U.length===o.length?`${o.length} receipt${o.length!==1?"s":""}`:`${U.length} of ${o.length} receipts`}),a.jsx("div",{className:"timeline",children:U.map(z=>{var E,B;return a.jsx("div",{className:"timeline-event",children:a.jsxs("div",{className:"card",style:{marginBottom:0},children:[a.jsxs("div",{className:"receipt-head",children:[a.jsx("span",{className:"receipt-what",children:qy(z,l)}),a.jsx("span",{className:"receipt-tag",children:Zy(z)?"review":"automatic"}),z.contentHash&&a.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(E=z.contentBinding)!=null&&E.fields?`The receipt binds: ${z.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),a.jsx("span",{className:"auth-card-time",children:tx(z.timestamp)})]}),qc(z)&&a.jsx("div",{className:"receipt-scope",children:qc(z)}),r==="team"&&z.userId&&a.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner:"," ",a.jsx("span",{style:{color:"var(--text-secondary)"},children:(B=x[z.userId])!=null&&B.name?`${x[z.userId].name} (${x[z.userId].email})`:z.userId})]}),a.jsxs("div",{className:"receipt-foot",children:[d&&a.jsx("a",{className:"receipt-link",href:`${d}/r/${z.id}`,target:"_blank",rel:"noreferrer",children:"View receipt ↗"}),a.jsx("span",{className:"receipt-id",children:z.id.slice(0,8)}),a.jsx("span",{className:"receipt-tag",children:ex(z.profileId)})]}),a.jsxs("details",{className:"receipt-more",children:[a.jsx("summary",{children:"Technical"}),a.jsxs("div",{className:"receipt-kv",children:[a.jsxs("div",{children:["action · ",z.action]}),a.jsxs("div",{children:["profile · ",z.profileId]}),Object.keys(z.executionContext).length>0&&a.jsxs("div",{children:["context ·"," ",Object.entries(z.executionContext).map(([te,xe])=>`${te}=${xe}`).join(" · ")]}),a.jsxs("div",{children:["usage · daily ",z.cumulativeState.daily.count," calls, $",z.cumulativeState.daily.amount," · monthly"," ",z.cumulativeState.monthly.count," calls, $",z.cumulativeState.monthly.amount]}),z.contentHash&&a.jsxs("div",{children:["content · ",z.contentHash]}),a.jsxs("div",{children:["authorization · ",z.attestationHash]})]})]})]})},z.id)})})]}),O&&a.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:W,disabled:V,children:V?"Loading…":"Load older"})})]})}const ax={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function ox(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[s,o]=u.useState(null),i=u.useCallback(async()=>{try{t(await A.getAutostart())}catch(d){o(d instanceof Error?d.message:"Could not read autostart state")}},[]);u.useEffect(()=>{i()},[i]);const l=u.useCallback(async()=>{if(!(!(e!=null&&e.supported)||n)){r(!0),o(null);try{await A.setAutostart(!e.installed)}catch(d){o(d instanceof Error?d.message:"Failed")}finally{try{t(await A.getAutostart()),o(null)}catch(d){o(d instanceof Error?d.message:"Could not re-read state")}r(!1)}}},[e,n,i]);if(!e)return a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),a.jsx("p",{role:s?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:s?`Could not read autostart state: ${s}`:"Checking…"})]});const c=ax[e.platform]??"a login service";return a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[a.jsxs("div",{children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),a.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:e.supported?a.jsxs(a.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",c," — no admin rights needed."]}):e.reason})]}),e.supported&&a.jsx("button",{type:"button",onClick:()=>void l(),disabled:n,"aria-pressed":e.installed,className:e.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:n?"Working…":e.installed?"Turn off":"Turn on"})]}),e.supported&&a.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",a.jsx("strong",{children:e.installed?"On — starts from your next login":"Off"})]}),e.supported&&a.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Turning this on doesn't interrupt the gateway you're using — it takes effect at your next login. After any restart Suveren comes back ",a.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),s&&a.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger, #c00)"},children:s})]})}function ix(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[s,o]=u.useState(null),i=u.useCallback(async()=>{try{const c=await A.getGatewaySettings();t(c.desktopNotifications),o(null)}catch(c){o(c instanceof Error?c.message:"Could not read notification setting")}},[]);u.useEffect(()=>{i()},[i]);const l=u.useCallback(async()=>{if(!(e===null||n)){r(!0),o(null);try{const c=await A.setGatewaySettings({desktopNotifications:!e});t(c.desktopNotifications)}catch(c){o(c instanceof Error?c.message:"Failed to save"),await i()}finally{r(!1)}}},[e,n,i]);return e===null?a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),a.jsx("p",{role:s?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:s?`Could not read the setting: ${s}`:"Checking…"})]}):a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[a.jsxs("div",{children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),a.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:"Tells you something is waiting for review — never what it is, and never with an approve button. Open Suveren to see and decide. At most one notification a minute; the browser tab always shows the count."})]}),a.jsx("button",{type:"button",onClick:()=>void l(),disabled:n,"aria-pressed":e,className:e?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:n?"Saving…":e?"Turn off":"Turn on"})]}),s&&a.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:s})]})}const lx={npm:"Checking npm for new releases",docker:"Checking the container registry for new images",dev:"Git checkout — comparing against origin/main, not npm releases"};function cx(){const{version:e,latestVersion:t,updateAvailable:n,installMethod:r}=Cl();return e?a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),a.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",a.jsx("strong",{children:e}),n&&t?a.jsxs(a.Fragment,{children:[" — ",a.jsx("strong",{children:t})," is available"]}):null]}),a.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[lx[r]??"Update checking is unavailable",r==="dev"&&a.jsx(a.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}const ux={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 dx(){const[e,t]=u.useState(""),[n,r]=u.useState("openrouter"),[s,o]=u.useState("openai-compatible"),[i,l]=u.useState("https://openrouter.ai/api/v1"),[c,d]=u.useState("google/gemma-4-31b-it"),[f,h]=u.useState(""),[m,x]=u.useState(!1),[w,y]=u.useState(!1),[j,g]=u.useState(!1),[p,v]=u.useState(null),[S,k]=u.useState([]),[I,T]=u.useState(!1),[P,b]=u.useState(null),[N,O]=u.useState(""),Y=u.useCallback(_=>{t(_),setTimeout(()=>t(""),3e3)},[]),V=u.useCallback(async(_,W,R)=>{T(!0),b(null);try{const D=await A.aiModels({provider:_,endpoint:W,...R?{apiKey:R}:{}});D.ok&&D.models.length>0?(k(D.models),b(`${D.models.length} models available`)):(k([]),b(D.message||"No models returned — using defaults"))}catch(D){k([]),b(D instanceof Error?D.message:"Failed to load models")}finally{T(!1)}},[]),H=u.useCallback(async()=>{try{const _=await A.getCredential("ai-config");if(x(_.configured),_.configured&&_.fields){const W=_.fields.provider||"openai-compatible",R=_.fields.endpoint||"";_.fields.provider&&o(W),_.fields.endpoint&&l(R),_.fields.model&&d(_.fields.model),R.includes("openai.com")?r("openai"):R.includes("groq.com")?r("groq"):R.includes("together.xyz")?r("together"):R.includes("openrouter.ai")?r("openrouter"):r("ollama"),R&&V(W,R)}}catch{}},[V]);u.useEffect(()=>{H()},[H]);const C=_=>{r(_),k([]),b(null),O("");const W=ux[_];W&&(o(W.provider),l(W.endpoint),d(""),V(W.provider,W.endpoint,f||void 0))},J=()=>V(s,i,f||void 0),ne=async()=>{y(!0);try{await A.setCredential("ai-config",{provider:s,endpoint:i,model:c,...f?{apiKey:f}:{}}),x(!0),Y("AI configuration saved!")}catch{Y("Failed to save AI config")}finally{y(!1)}},$=async()=>{g(!0),v(null);try{const _=await A.aiTest({provider:s,endpoint:i,model:c,...f?{apiKey:f}:{}});v(_.ok?`OK: ${_.message}`:`Failed: ${_.message}`)}catch(_){v(`Error: ${_ instanceof Error?_.message:"Unknown"}`)}finally{g(!1)}};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",children:[a.jsx("h1",{className:"page-title",children:"AI Assistant"}),a.jsx("p",{className:"page-subtitle",children:"Advisory AI to help you think through intent when authorizing agents."})]}),e&&a.jsx("div",{className:"alert alert-success",children:e}),a.jsxs("div",{className:"card",children:[a.jsx("h3",{className:"card-title",children:"Configuration"}),a.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."}),m&&a.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[a.jsx("span",{className:"status-banner-icon",children:"✓"}),a.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),a.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[a.jsx("label",{className:"form-label",children:"Provider Preset"}),a.jsxs("select",{className:"form-input",value:n,onChange:_=>C(_.target.value),children:[a.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),a.jsx("option",{value:"ollama",children:"Ollama (local)"}),a.jsx("option",{value:"openai",children:"OpenAI"}),a.jsx("option",{value:"groq",children:"Groq"}),a.jsx("option",{value:"together",children:"Together"})]})]}),a.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[a.jsxs("label",{className:"form-label",children:["API Key ",s==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),a.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:f,onChange:_=>h(_.target.value),onBlur:()=>{f.trim()&&V(s,i,f.trim())},placeholder:m?"••••••••••••••••":"sk-... (not needed for Ollama)"}),a.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:"Each provider uses its own key — paste it and the model list loads automatically."})]}),a.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a.jsx("label",{className:"form-label",children:"Model"}),a.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:J,disabled:I,title:"Re-fetch the model list from the provider",children:I?"Loading…":"↻ Refresh"})]}),S.length===0?a.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:I?"Loading models…":s==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const _=S,W=_.includes(c),R=_.length>12,D=N.trim().toLowerCase();let L=D?_.filter(U=>U.toLowerCase().includes(D)):_;return W&&!L.includes(c)&&(L=[c,...L]),a.jsxs(a.Fragment,{children:[R&&a.jsx("input",{className:"form-input",value:N,onChange:U=>O(U.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),a.jsxs("select",{className:"form-input",value:W?c:"__unset__",onChange:U=>d(U.target.value==="__unset__"?"":U.target.value),children:[a.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),L.map(U=>a.jsx("option",{value:U,children:U},U)),D&&L.length===0&&a.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",N,"”"]})]})]})})(),P&&a.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:P})]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsx("button",{className:"btn btn-primary",onClick:ne,disabled:w||!c.trim(),title:c.trim()?void 0:"Select a model first",children:w?"Saving...":"Save & Encrypt"}),m&&a.jsx("button",{className:"btn btn-ghost",onClick:$,disabled:j,children:j?"Testing...":"Test Connection"})]}),p&&a.jsx("div",{className:`alert ${p.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:p})]}),a.jsx(fx,{}),a.jsx(ox,{}),a.jsx(ix,{}),a.jsx(cx,{}),a.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[a.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,marginBottom:"1rem"},children:"Security"}),a.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[a.jsxs("div",{style:{marginBottom:"1rem"},children:[a.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),a.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[a.jsx("li",{children:"Every tool call verified against your authorization bounds"}),a.jsx("li",{children:"Credentials never exposed to agents through MCP"}),a.jsx("li",{children:"Every action produces a signed receipt"})]})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),a.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[a.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),a.jsx("li",{children:"For best security, run agents in sandboxed environments"}),a.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})]})]})}function fx(){const[e,t]=u.useState(null),[n,r]=u.useState({intent:"",context:""}),[s,o]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(null),[f,h]=u.useState(!1),m=u.useCallback(async()=>{if(!f)try{const y=await A.getAIPrompts();t(y),r({intent:y.intent.current,context:y.context.current}),h(!0)}catch(y){l(y instanceof Error?y.message:"Failed to load prompts")}},[f]),x=async y=>{if(e){o(y),l(null);try{const j=n[y],g=j.trim()===e[y].default.trim()?"":j;await A.setAIPrompt(y,g);const p=await A.getAIPrompts();t(p),r({intent:p.intent.current,context:p.context.current}),d(y),setTimeout(()=>d(null),2e3)}catch(j){l(j instanceof Error?j.message:"Save failed")}finally{o(null)}}},w=async y=>{if(confirm(`Revert ${y} prompt to the built-in default?`)){o(y),l(null);try{await A.setAIPrompt(y,"");const j=await A.getAIPrompts();t(j),r({intent:j.intent.current,context:j.context.current})}catch(j){l(j instanceof Error?j.message:"Revert failed")}finally{o(null)}}};return a.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:y=>{y.currentTarget.open&&m()},children:[a.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),a.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&&a.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:i}),!f&&!i&&a.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&a.jsxs(a.Fragment,{children:[a.jsx(eu,{kind:"intent",label:"Intent — per-authorization",description:"Used on the Intent gate when creating a new authorization.",state:e.intent,draft:n.intent,onChange:y=>r(j=>({...j,intent:y})),onSave:()=>x("intent"),onRevert:()=>w("intent"),saving:s==="intent",justSaved:c==="intent"}),a.jsx(eu,{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:y=>r(j=>({...j,context:y})),onSave:()=>x("context"),onRevert:()=>w("context"),saving:s==="context",justSaved:c==="context"})]})]})}function eu({kind:e,label:t,description:n,state:r,draft:s,onChange:o,onSave:i,onRevert:l,saving:c,justSaved:d}){const f=s!==r.current;return a.jsxs("section",{style:{marginBottom:"1.5rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:t}),a.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:n})]}),r.overridden&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),a.jsx("textarea",{className:"form-textarea",value:s,onChange:h=>o(h.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`}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[a.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:i,disabled:c||!f,children:c?"Saving…":"Save"}),r.overridden&&a.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"}),d&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),f&&!c&&!d&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),a.jsxs("details",{style:{marginTop:"0.5rem"},children:[a.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),a.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})]}),a.jsx("span",{style:{display:"none"},children:e})]})}function px(e){return e.proposalId?"review":"automatic"}function tu(e,t,n={}){const r=n.status??"pending",s=n.includeAutonomous??!1,o=[];for(const i of e)r==="pending"&&i.status!=="pending"||n.profile&&i.profileId!==n.profile||o.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=px(i);!s&&l==="automatic"||n.profile&&i.profileId!==n.profile||o.push({kind:"receipt",id:i.id,sortTimestamp:i.timestamp,commitmentMode:l,profileId:i.profileId,receipt:i})}return o.sort((i,l)=>l.sortTimestamp-i.sortTimestamp),typeof n.limit=="number"&&n.limit>0?o.slice(0,n.limit):o}const mx=["https://","http://"];function Zf(e,t){return e!=null&&e.length?e.flatMap(n=>{const r=n.template.replace(/\{(\w+)\}/g,(s,o)=>{const i=t[o];return typeof i=="string"||typeof i=="number"?String(i):"\0"});return r.includes("\0")||/\{|\}/.test(r)?[]:mx.some(s=>r.toLowerCase().startsWith(s))?[{label:n.label,href:r,description:n.description}]:[]}):[]}function hx({profileId:e}){return a.jsx("span",{className:"profile-badge",children:$e(e)})}function ep(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),s=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);let i;return r>0?i=`expires in ${r}d ${s}h`:s>0?i=`expires in ${s}h ${o}m`:i=`expires in ${Math.max(1,o)}m`,{label:i,urgent:n<2*3600,expired:!1}}const gx={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},vx={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function yx(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 xx(e){return e.split("__").pop()??e}function wx(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}const Sx=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]),jx=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function kx(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:jx.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function ji(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=>ji(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function nu({item:e,onApprove:t,onReject:n,resolving:r,proposalLinks:s}){const o=e.kind==="proposal",i=o?e.proposal.status:"executed",l=o?e.proposal.tool:e.receipt.action,c=xx(l),d=wx(l),f=o?e.proposal.toolArgs:null,h=o?e.proposal.executionContext:e.receipt.executionContext,m=o?null:e.receipt.cumulativeState,x=o?Zf(s,e.proposal.toolArgs):[],w=f?Object.entries(f).filter(([j])=>!Sx.has(j)):[],y=Object.entries(h??{});return a.jsxs("div",{className:"card",children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[a.jsx(hx,{profileId:e.profileId}),a.jsx("code",{style:{fontSize:"0.85rem"},children:c}),e.commitmentMode==="automatic"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),a.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[o&&i==="pending"&&(()=>{const j=ep(e.proposal.expiresAt,Date.now());return a.jsx("span",{style:{fontSize:"0.72rem",color:j.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:j.urgent?600:400,whiteSpace:"nowrap"},children:j.label})})(),a.jsx("span",{className:`status-badge ${vx[i]}`,children:gx[i]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:yx(e.sortTimestamp)})]})]}),d&&a.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:[a.jsx("span",{children:"⚠"}),a.jsx("span",{children:"Irreversible action"})]}),o&&typeof(f==null?void 0:f._imagePreview)=="string"&&a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),a.jsx("img",{src:f._imagePreview,alt:typeof(f==null?void 0:f.altText)=="string"?f.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),x.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:x.map(j=>a.jsxs("a",{href:j.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:j.description??j.href,children:[j.label," ↗"]},j.label))}),o&&w.length>0&&a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Arguments"}),a.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:w.map(([j,g])=>a.jsxs(u.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:j}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:kx(j,g)?a.jsx("img",{src:g,alt:typeof(f==null?void 0:f.altText)=="string"?f.altText:j,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"},onError:p=>{const v=p.currentTarget,S=v.parentElement;if(!S)return;v.style.display="none";const k=document.createElement("span");k.textContent=g,k.style.color="var(--text-tertiary)",S.appendChild(k)}}):ji(g)})]},j))})]}),y.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:y.map(([j,g])=>`${j}=${ji(g)}`).join(" · ")}),m&&a.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",m.daily.count," action",m.daily.count===1?"":"s",m.daily.amount>0?`, ${m.daily.amount}`:""," · ","this month: ",m.monthly.count,m.monthly.amount>0?`, ${m.monthly.amount}`:""]}),o&&i==="pending"&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{className:"btn btn-primary",onClick:()=>t==null?void 0:t(e.id),disabled:r,children:r?"Approving…":"Approve"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:()=>n==null?void 0:n(e.id),disabled:r,children:"Reject"})]}),a.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[o?"Proposal":"Receipt",": ",e.id]})]})}const bx=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function ki(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=>ki(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Cx(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 Nx({proposal:e,currentUserId:t,onAction:n,onMessage:r,proposalLinks:s}){const[o,i]=u.useState(!1),[l,c]=u.useState(!1),[d,f]=u.useState(null),[h,m]=u.useState(!1),[x,w]=u.useState(null),[y,j]=u.useState(!1),g=e.tool.split("__").pop()??e.tool,p=Object.entries(e.toolArgs).filter(([C])=>!bx.has(C)),v=Object.entries(e.executionContext),S=Zf(s,e.toolArgs),k=e.pendingApprovers??[],I=e.approvedBy??{},T=Object.keys(I).length,P=k.filter(C=>!(C in I)).length,b=t in I,N=async()=>{if(d===null){m(!0),w(null);try{const C=await A.getAttestationIntent(e.authorizationId);if(!C){w("Intent not available or you are not an authorized approver.");return}const J=await A.decryptIntent({intentCiphertext:C.intentCiphertext,encryptedKey:C.encryptedKey,approverId:t});f(J)}catch(C){w(C instanceof Error?C.message:"Failed to decrypt intent")}finally{m(!1)}}},O=async()=>{y?j(!1):(j(!0),await N())},Y=async()=>{i(!0),r("");try{await A.approveProposal(e.id);try{if(d===null){const C=await A.getAttestationIntent(e.authorizationId);if(C){const J=await A.decryptIntent({intentCiphertext:C.intentCiphertext,encryptedKey:C.encryptedKey,approverId:t});f(J),await A.storeApprovedIntent(e.authorizationId,J)}}else await A.storeApprovedIntent(e.authorizationId,d)}catch{}r(`Approved. ${P-1>0?`${P-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(C){r(C instanceof Error?C.message:"Approval failed")}finally{i(!1)}},V=async()=>{const C=prompt("Rejection reason (optional):");if(C!==null){c(!0),r("");try{await A.rejectProposal(e.id,C||void 0),r("Action rejected."),n()}catch(J){r(J instanceof Error?J.message:"Rejection failed")}finally{c(!1)}}},H=o||l;return a.jsxs("div",{className:"card",children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[a.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:$e(e.profileId)}),a.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"}),a.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const C=ep(e.expiresAt,Date.now());return a.jsx("span",{style:{fontSize:"0.72rem",color:C.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:C.urgent?600:400,whiteSpace:"nowrap"},children:C.label})})(),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Cx(e.createdAt)})]})]}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[T," of ",k.length," approver",k.length===1?"":"s"," signed off",k.map(C=>{const J=C in I;return a.jsxs("span",{style:{marginLeft:"0.5rem",color:J?"var(--success, green)":"var(--text-tertiary)"},children:[J?"✓":"○"," ",C===t?"You":C]},C)})]}),a.jsxs("div",{style:{marginBottom:"0.5rem"},children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Proposed action"}),a.jsx("code",{style:{fontSize:"0.85rem"},children:g})]}),S.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:S.map(C=>a.jsxs("a",{href:C.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:C.description??C.href,children:[C.label," ↗"]},C.label))}),p.length>0&&a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Arguments"}),a.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:p.map(([C,J])=>a.jsxs(u.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:C}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:ki(J)})]},C))})]}),v.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:v.map(([C,J])=>`${C}=${ki(J)}`).join(" · ")}),a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsxs("button",{className:"btn btn-ghost btn-sm",style:{padding:"0.2rem 0",fontSize:"0.75rem"},onClick:O,disabled:h,children:[y?"▲ Hide intent":"▼ Show intent",h&&" (decrypting...)"]}),y&&a.jsx("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-main)",borderRadius:"0.375rem",border:"1px solid var(--border)"},children:x?a.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:x}):d!==null?a.jsx("p",{style:{fontSize:"0.85rem",margin:0,whiteSpace:"pre-wrap",color:"var(--text-primary)"},children:d}):a.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this authority."})})]}),!b&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[a.jsx("button",{className:"btn btn-primary",onClick:Y,disabled:H,children:o?"Approving...":"Approve"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:V,disabled:H,children:l?"Rejecting...":"Reject"})]}),b&&a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),a.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})}function Ex(){const{domain:e,user:t}=Oe(),n=(t==null?void 0:t.id)??"",[r,s]=u.useState("awaiting-me"),[o,i]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState(!0),[h,m]=u.useState(""),x=u.useCallback(async()=>{try{const E=await A.getProposalsForApprover();i(E)}catch{}finally{f(!1)}},[]);fe("proposal-added",x),fe("proposal-approved",x),fe("proposal-rejected",x),fe("proposal-resolved",x),Lt(x,3e4);const[w,y]=u.useState([]),j=u.useCallback(async()=>{try{const E=await A.getProposals(e||"owner");y(E)}catch{}},[e]);fe("proposal-added",j),fe("proposal-approved",j),fe("proposal-rejected",j),fe("proposal-resolved",j),Lt(j,3e4,e);const g=u.useMemo(()=>w.filter(E=>{var B;return E.status==="pending"&&(((B=E.pendingApprovers)==null?void 0:B.length)??0)===0}),[w]),p=u.useMemo(()=>tu(g,[],{status:"pending"}),[g]),[v,S]=u.useState([]),k=u.useCallback(async()=>{if(n)try{const B=(await A.getProposals(e||"owner")).filter(te=>te.status==="pending"&&te.pendingApprovers&&te.pendingApprovers.includes(n)&&te.approvedBy&&n in te.approvedBy);S(B)}catch{}},[n,e]);fe("proposal-approved",k),fe("proposal-rejected",k),Lt(k,3e4,`${n}:${e}`),u.useEffect(()=>{A.getIntegrationManifests().then(E=>c(E.manifests??[])).catch(()=>{})},[]);const I=E=>{var B;return(B=l.find(te=>te.id===E.split("__")[0]))==null?void 0:B.proposalLinks};u.useEffect(()=>{x(),j(),k()},[]);const[T,P]=u.useState([]),[b,N]=u.useState([]),[O,Y]=u.useState(!0),[V,H]=u.useState(null),[C,J]=u.useState(""),[ne,$]=u.useState("pending"),[_,W]=u.useState(null),[R,D]=u.useState(!1),L=u.useCallback(async()=>{try{const{proposals:E,receipts:B}=await A.getThread({domain:e,status:ne,sinceDays:7});P(E),N(B)}catch{}finally{Y(!1)}},[e,ne]);Lt(L,3e4,`${e}:${ne}`);const U=async(E,B)=>{H(E),J("");try{const te=e||"owner",xe=await A.resolveProposal(E,B,te);J(B==="commit"?`Action approved. Status: ${xe.status}`:"Action rejected."),await Promise.all([L(),j()])}catch(te){J(te instanceof Error?te.message:"Failed")}finally{H(null)}},ee=u.useMemo(()=>{const E=new Set;for(const B of T)E.add(B.profileId);for(const B of b)E.add(B.profileId);return Array.from(E).sort()},[T,b]),q=u.useMemo(()=>tu(T,b,{status:ne,profile:_??void 0,includeAutonomous:R}),[T,b,ne,_,R]),me=u.useCallback(()=>{x(),k()},[x,k]),ze=u.useMemo(()=>{const E=new Set,B=[];for(const te of v)E.has(te.id)||(E.add(te.id),B.push(te));return B.sort((te,xe)=>xe.createdAt-te.createdAt)},[v]),Be=o.length+p.length,z=ze.length;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",children:[a.jsx("h1",{className:"page-title",children:"Pending Approvals"}),a.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."})]}),a.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[a.jsxs("button",{className:`nav-tab${r==="awaiting-me"?" active":""}`,onClick:()=>s("awaiting-me"),children:["Awaiting me ",Be>0&&a.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:Be})]}),a.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>s("awaiting-others"),children:["Awaiting others ",z>0&&a.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:z})]}),a.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{s("all"),L()},children:"All"})]}),r==="awaiting-me"&&a.jsx(a.Fragment,{children:d&&Be===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Be===0?a.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[a.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(h||C)&&a.jsx("div",{className:"alert alert-success",children:h||C}),p.map(E=>a.jsx(nu,{proposalLinks:E.kind==="proposal"?I(E.proposal.tool):void 0,item:E,onApprove:B=>U(B,"commit"),onReject:B=>U(B,"reject"),resolving:V===E.id},E.id)),o.map(E=>a.jsx(Nx,{proposal:E,currentUserId:n,onAction:me,onMessage:m,proposalLinks:I(E.tool)},E.id))]})}),r==="awaiting-others"&&a.jsx(a.Fragment,{children:ze.length===0?a.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[a.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:ze.map(E=>a.jsx(zx,{proposal:E,currentUserId:n,onCancel:async()=>{try{await A.rejectProposal(E.id,"cancelled by creator"),k(),j()}catch(B){alert(B instanceof Error?B.message:"Cancel failed")}}},E.id))})}),r==="all"&&a.jsxs(a.Fragment,{children:[C&&a.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:C}),a.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[a.jsx("button",{className:`filter-chip ${ne==="pending"?"selected":""}`,onClick:()=>$("pending"),children:"Pending"}),a.jsx("button",{className:`filter-chip ${ne==="all"?"selected":""}`,onClick:()=>$("all"),children:"All"}),ee.length>0&&a.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),ee.map(E=>a.jsx("button",{className:`filter-chip ${_===E?"selected":""}`,onClick:()=>W(_===E?null:E),children:$e(E)},E)),ne==="all"&&a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),a.jsxs("button",{className:`filter-chip ${R?"selected":""}`,onClick:()=>D(!R),title:"Include actions executed without human review (automatic commitment mode)",children:[R?"✓ ":"","Autonomous actions"]})]})]}),O&&q.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):q.length===0?a.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[a.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:ne==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:ne==="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."})]}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:q.map(E=>a.jsx(nu,{proposalLinks:E.kind==="proposal"?I(E.proposal.tool):void 0,item:E,onApprove:B=>U(B,"commit"),onReject:B=>U(B,"reject"),resolving:V===E.id},E.id))})]})]})}function Tx(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 zx({proposal:e,currentUserId:t,onCancel:n}){var d;const[r,s]=u.useState(!1),o=Object.keys(e.approvedBy??{}),i=(e.pendingApprovers??[]).filter(f=>!(f in(e.approvedBy??{}))),l=(((d=e.pendingApprovers)==null?void 0:d.length)??0)>0,c=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){s(!0);try{await n()}finally{s(!1)}}};return a.jsxs("div",{className:"card",children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[a.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:$e(e.profileId)}),l&&a.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"}),a.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Tx(e.createdAt)})]}),a.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:a.jsx("code",{children:e.tool.split("__").pop()??e.tool})}),l&&a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[o.map(f=>a.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:f===t?"You approved":`${f} approved`},f)),i.map(f=>a.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",f===t?"you":f]},f))]}),a.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:a.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:c,disabled:r,children:r?"Cancelling...":"Cancel"})})]})}const Ix=`# Agent Brief
|
|
75
|
-
|
|
76
|
-
You act on my behalf through Suveren — the gateway that gates every
|
|
77
|
-
privileged tool call you make. Suveren implements the bounded-authority
|
|
78
|
-
model from the open Human Agency Protocol (HAP): each authorization
|
|
79
|
-
describes an area of authority, a set of numeric limits, and a scope.
|
|
80
|
-
Operate inside those bounds or the Gatekeeper will reject your action.
|
|
81
|
-
|
|
82
|
-
## Before you act in a domain
|
|
83
|
-
|
|
84
|
-
1. Call \`list-authorizations(domain: "<domain>")\` to load the full
|
|
85
|
-
intent, scope, and usage for that area. The session brief shows only
|
|
86
|
-
a one-line summary per authority — the Intent paragraph lives behind
|
|
87
|
-
that call, and often contains soft rules you MUST honor (e.g. "never
|
|
88
|
-
publish on weekends", "only reply in English").
|
|
89
|
-
2. If the action would exceed a bound or fall outside the scope, stop
|
|
90
|
-
and explain what would be blocked instead of trying.
|
|
91
|
-
3. If you're not sure whether an action is covered, ask me first.
|
|
92
|
-
|
|
93
|
-
## How to handle reviews
|
|
94
|
-
|
|
95
|
-
Authorizations in review mode require my approval before the action
|
|
96
|
-
executes. When you propose an action:
|
|
97
|
-
- Include everything I need to judge it (title, recipients, amounts,
|
|
98
|
-
dates, attendees) in the tool arguments.
|
|
99
|
-
- Don't batch unrelated proposals — one proposal per decision.
|
|
100
|
-
|
|
101
|
-
## Standing orders
|
|
102
|
-
|
|
103
|
-
(Add your own here. Examples:)
|
|
104
|
-
|
|
105
|
-
- Every morning, summarize today's calendar and flag conflicts.
|
|
106
|
-
- On Fridays, give me a weekly review: what's done, what slipped, what's
|
|
107
|
-
next.
|
|
108
|
-
- Never email anyone outside the company without asking first.
|
|
109
|
-
- When drafting posts, prefer plain language over marketing copy.
|
|
110
|
-
`;function Px(){const[e,t]=u.useState(""),[n,r]=u.useState(""),[s,o]=u.useState(!0),[i,l]=u.useState(!1),[c,d]=u.useState(null),[f,h]=u.useState(!1),m=e!==n,x=new Blob([e]).size,w=16*1024;u.useEffect(()=>{if(!m)return;const p=S=>{S.preventDefault(),S.returnValue=""},v=S=>{var T,P;if(S.defaultPrevented||S.button!==0||S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const k=(P=(T=S.target)==null?void 0:T.closest)==null?void 0:P.call(T,"a");if(!k||!k.href)return;let I;try{I=new URL(k.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",p),document.addEventListener("click",v,!0),()=>{window.removeEventListener("beforeunload",p),document.removeEventListener("click",v,!0)}},[m]),u.useEffect(()=>{let p=!1;return A.getAgentContext().then(v=>{p||(t(v),r(v))}).catch(v=>{p||d({kind:"error",text:v instanceof Error?v.message:"Failed to load context"})}).finally(()=>{p||o(!1)}),()=>{p=!0}},[]);const y=async()=>{l(!0),d(null);try{await A.saveAgentContext(e),r(e),d({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(p){d({kind:"error",text:p instanceof Error?p.message:"Save failed"})}finally{l(!1)}},j=()=>{t(n),d(null)},g=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(Ix)};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"page-header",children:[a.jsx("h1",{className:"page-title",children:"Agent Brief"}),a.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()&&!s&&a.jsx("button",{className:"btn btn-primary btn-sm",onClick:g,disabled:i,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),c&&a.jsx("div",{className:c.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:c.text}),a.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[a.jsx("div",{className:"card intent-pane chat",children:a.jsx(wa,{target:{kind:"context"},currentText:e,onApply:p=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(p)},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…"})}),a.jsxs("div",{className:"card intent-pane document",children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[a.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),a.jsxs("span",{style:{fontSize:"0.75rem",color:x>w?"var(--danger)":"var(--text-muted)"},children:[x.toLocaleString()," / ",w.toLocaleString()," bytes"]})]}),a.jsx("textarea",{className:"form-textarea",value:e,onChange:p=>t(p.target.value),placeholder:s?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:s,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),a.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[a.jsx("button",{className:"btn btn-ghost",onClick:j,disabled:i||!m,children:"Revert"}),a.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:y,disabled:i||!m||x>w||s,children:i?"Saving…":"Save"})]})]}),a.jsx("button",{type:"button",className:"floating-help",onClick:()=>h(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),a.jsx(Yf,{open:f,onClose:()=>h(!1),ariaLabel:"Brief assistant",children:a.jsx(wa,{target:{kind:"context"},currentText:e,onApply:p=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(p),h(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Rx({children:e}){const{user:t,mode:n,domain:r}=Oe();return t?n==="team"&&!r?a.jsx(nn,{to:"/onboarding",replace:!0}):a.jsx(a.Fragment,{children:e}):a.jsx(nn,{to:"/login",replace:!0})}function _x(){const{user:e}=Oe();return a.jsxs(Eg,{children:[a.jsx(Le,{path:"/login",element:e?a.jsx(nn,{to:"/",replace:!0}):a.jsx(Uv,{})}),a.jsx(Le,{path:"/onboarding",element:e?a.jsx(Wv,{}):a.jsx(nn,{to:"/login",replace:!0})}),a.jsxs(Le,{element:a.jsx(Rx,{children:a.jsx(Dv,{})}),children:[a.jsx(Le,{path:"/",element:a.jsx(ty,{})}),a.jsx(Le,{path:"/agent/new",element:a.jsx(nn,{to:"/authorizations?new=1",replace:!0})}),a.jsx(Le,{path:"/agent/gate",element:a.jsx(Ny,{})}),a.jsx(Le,{path:"/agent/review",element:a.jsx(Py,{})}),a.jsx(Le,{path:"/integrations",element:a.jsx(Ly,{})}),a.jsx(Le,{path:"/groups",element:a.jsx(My,{})}),a.jsx(Le,{path:"/authorizations",element:a.jsx(Jy,{})}),a.jsx(Le,{path:"/audit",element:a.jsx(sx,{})}),a.jsx(Le,{path:"/proposals",element:a.jsx(Ex,{})}),a.jsx(Le,{path:"/agent-brief",element:a.jsx(Px,{})}),a.jsx(Le,{path:"/settings",element:a.jsx(dx,{})}),a.jsx(Le,{path:"/settings/services",element:a.jsx(nn,{to:"/settings",replace:!0})}),a.jsx(Le,{path:"/deploy",element:a.jsx(nn,{to:"/integrations",replace:!0})})]}),a.jsx(Le,{path:"*",element:a.jsx(nn,{to:"/",replace:!0})})]})}function Ax(){return a.jsx(qg,{children:a.jsx(lv,{children:a.jsx(cv,{children:a.jsx(_x,{})})})})}vf(document.getElementById("root")).render(a.jsx(u.StrictMode,{children:a.jsx(Ax,{})}));
|