@suveren/gateway 0.8.2 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
var sp=Object.defineProperty;var ap=(e,t,n)=>t in e?sp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var xr=(e,t,n)=>ap(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:{}},Na={},su={exports:{}},se={};/**
|
|
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 cs=Symbol.for("react.element"),op=Symbol.for("react.portal"),ip=Symbol.for("react.fragment"),lp=Symbol.for("react.strict_mode"),cp=Symbol.for("react.profiler"),up=Symbol.for("react.provider"),dp=Symbol.for("react.context"),fp=Symbol.for("react.forward_ref"),pp=Symbol.for("react.suspense"),mp=Symbol.for("react.memo"),hp=Symbol.for("react.lazy"),zl=Symbol.iterator;function gp(e){return e===null||typeof e!="object"?null:(e=zl&&e[zl]||e["@@iterator"],typeof e=="function"?e:null)}var au={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ou=Object.assign,iu={};function pr(e,t,n){this.props=e,this.context=t,this.refs=iu,this.updater=n||au}pr.prototype.isReactComponent={};pr.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")};pr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function lu(){}lu.prototype=pr.prototype;function Ci(e,t,n){this.props=e,this.context=t,this.refs=iu,this.updater=n||au}var Ni=Ci.prototype=new lu;Ni.constructor=Ci;ou(Ni,pr.prototype);Ni.isPureReactComponent=!0;var Il=Array.isArray,cu=Object.prototype.hasOwnProperty,Ei={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:cs,type:e,key:o,ref:i,props:s,_owner:Ei.current}}function vp(e,t){return{$$typeof:cs,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ti(e){return typeof e=="object"&&e!==null&&e.$$typeof===cs}function yp(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Rl=/\/+/g;function Va(e,t){return typeof e=="object"&&e!==null&&e.key!=null?yp(""+e.key):t.toString(36)}function Fs(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 cs:case op:i=!0}}if(i)return i=e,s=s(i),e=r===""?"."+Va(i,0):r,Il(s)?(n="",e!=null&&(n=e.replace(Rl,"$&/")+"/"),Fs(s,t,n,"",function(d){return d})):s!=null&&(Ti(s)&&(s=vp(s,n+(!s.key||i&&i.key===s.key?"":(""+s.key).replace(Rl,"$&/")+"/")+e)),t.push(s)),1;if(i=0,r=r===""?".":r+":",Il(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+Va(o,l);i+=Fs(o,t,n,c,s)}else if(c=gp(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+Va(o,l++),i+=Fs(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 gs(e,t,n){if(e==null)return e;var r=[],s=0;return Fs(e,r,"","",function(o){return t.call(n,o,s++)}),r}function xp(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 qe={current:null},Os={transition:null},wp={ReactCurrentDispatcher:qe,ReactCurrentBatchConfig:Os,ReactCurrentOwner:Ei};function fu(){throw Error("act(...) is not supported in production builds of React.")}se.Children={map:gs,forEach:function(e,t,n){gs(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return gs(e,function(){t++}),t},toArray:function(e){return gs(e,function(t){return t})||[]},only:function(e){if(!Ti(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};se.Component=pr;se.Fragment=ip;se.Profiler=cp;se.PureComponent=Ci;se.StrictMode=lp;se.Suspense=pp;se.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=wp;se.act=fu;se.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=Ei.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:cs,type:e.type,key:s,ref:o,props:r,_owner:i}};se.createContext=function(e){return e={$$typeof:dp,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:up,_context:e},e.Consumer=e};se.createElement=du;se.createFactory=function(e){var t=du.bind(null,e);return t.type=e,t};se.createRef=function(){return{current:null}};se.forwardRef=function(e){return{$$typeof:fp,render:e}};se.isValidElement=Ti;se.lazy=function(e){return{$$typeof:hp,_payload:{_status:-1,_result:e},_init:xp}};se.memo=function(e,t){return{$$typeof:mp,type:e,compare:t===void 0?null:t}};se.startTransition=function(e){var t=Os.transition;Os.transition={};try{e()}finally{Os.transition=t}};se.unstable_act=fu;se.useCallback=function(e,t){return qe.current.useCallback(e,t)};se.useContext=function(e){return qe.current.useContext(e)};se.useDebugValue=function(){};se.useDeferredValue=function(e){return qe.current.useDeferredValue(e)};se.useEffect=function(e,t){return qe.current.useEffect(e,t)};se.useId=function(){return qe.current.useId()};se.useImperativeHandle=function(e,t,n){return qe.current.useImperativeHandle(e,t,n)};se.useInsertionEffect=function(e,t){return qe.current.useInsertionEffect(e,t)};se.useLayoutEffect=function(e,t){return qe.current.useLayoutEffect(e,t)};se.useMemo=function(e,t){return qe.current.useMemo(e,t)};se.useReducer=function(e,t,n){return qe.current.useReducer(e,t,n)};se.useRef=function(e){return qe.current.useRef(e)};se.useState=function(e){return qe.current.useState(e)};se.useSyncExternalStore=function(e,t,n){return qe.current.useSyncExternalStore(e,t,n)};se.useTransition=function(){return qe.current.useTransition()};se.version="18.3.1";su.exports=se;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 Sp=u,jp=Symbol.for("react.element"),kp=Symbol.for("react.fragment"),bp=Object.prototype.hasOwnProperty,Cp=Sp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Np={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)bp.call(t,r)&&!Np.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:jp,type:e,key:o,ref:i,props:s,_owner:Cp.current}}Na.Fragment=kp;Na.jsx=pu;Na.jsxs=pu;ru.exports=Na;var a=ru.exports,mu={exports:{}},ut={},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(M,$){var H=M.length;M.push($);e:for(;0<H;){var _=H-1>>>1,D=M[_];if(0<s(D,$))M[_]=$,M[H]=D,H=_;else break e}}function n(M){return M.length===0?null:M[0]}function r(M){if(M.length===0)return null;var $=M[0],H=M.pop();if(H!==$){M[0]=H;e:for(var _=0,D=M.length,F=D>>>1;_<F;){var G=2*(_+1)-1,q=M[G],ee=G+1,ue=M[ee];if(0>s(q,H))ee<D&&0>s(ue,q)?(M[_]=ue,M[ee]=H,_=ee):(M[_]=q,M[G]=H,_=G);else if(ee<D&&0>s(ue,H))M[_]=ue,M[ee]=H,_=ee;else break e}}return $}function s(M,$){var H=M.sortIndex-$.sortIndex;return H!==0?H:M.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,m=null,p=3,x=!1,w=!1,y=!1,j=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,g=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(M){for(var $=n(d);$!==null;){if($.callback===null)r(d);else if($.startTime<=M)r(d),$.sortIndex=$.expirationTime,t(c,$);else break;$=n(d)}}function S(M){if(y=!1,v(M),!w)if(n(c)!==null)w=!0,X(b);else{var $=n(d);$!==null&&te(S,$.startTime-M)}}function b(M,$){w=!1,y&&(y=!1,h(P),P=-1),x=!0;var H=p;try{for(v($),m=n(c);m!==null&&(!(m.expirationTime>$)||M&&!B());){var _=m.callback;if(typeof _=="function"){m.callback=null,p=m.priorityLevel;var D=_(m.expirationTime<=$);$=e.unstable_now(),typeof D=="function"?m.callback=D:m===n(c)&&r(c),v($)}else r(c);m=n(c)}if(m!==null)var F=!0;else{var G=n(d);G!==null&&te(S,G.startTime-$),F=!1}return F}finally{m=null,p=H,x=!1}}var I=!1,R=null,P=-1,C=5,z=-1;function B(){return!(e.unstable_now()-z<C)}function K(){if(R!==null){var M=e.unstable_now();z=M;var $=!0;try{$=R(!0,M)}finally{$?Y():(I=!1,R=null)}}else I=!1}var Y;if(typeof g=="function")Y=function(){g(K)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,T=W.port2;W.port1.onmessage=K,Y=function(){T.postMessage(null)}}else Y=function(){j(K,0)};function X(M){R=M,I||(I=!0,Y())}function te(M,$){P=j(function(){M(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(M){M.callback=null},e.unstable_continueExecution=function(){w||x||(w=!0,X(b))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):C=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(M){switch(p){case 1:case 2:case 3:var $=3;break;default:$=p}var H=p;p=$;try{return M()}finally{p=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,$){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var H=p;p=M;try{return $()}finally{p=H}},e.unstable_scheduleCallback=function(M,$,H){var _=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?_+H:_):H=_,M){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=H+D,M={id:f++,callback:$,priorityLevel:M,startTime:H,expirationTime:D,sortIndex:-1},H>_?(M.sortIndex=H,t(d,M),n(c)===null&&M===n(d)&&(y?(h(P),P=-1):y=!0,te(S,H-_))):(M.sortIndex=D,t(c,M),w||x||(w=!0,X(b))),M},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(M){var $=p;return function(){var H=p;p=$;try{return M.apply(this,arguments)}finally{p=H}}}})(gu);hu.exports=gu;var Ep=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 Tp=u,ct=Ep;function O(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,Vr={};function On(e,t){or(e,t),or(e+"Capture",t)}function or(e,t){for(Vr[e]=t,e=0;e<t.length;e++)vu.add(t[e])}var Yt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Co=Object.prototype.hasOwnProperty,zp=/^[: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={},_l={};function Ip(e){return Co.call(_l,e)?!0:Co.call(Pl,e)?!1:zp.test(e)?_l[e]=!0:(Pl[e]=!0,!1)}function Rp(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 Pp(e,t,n,r){if(t===null||typeof t>"u"||Rp(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 Ze(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 Be={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Be[e]=new Ze(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Be[t]=new Ze(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Be[e]=new Ze(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Be[e]=new Ze(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){Be[e]=new Ze(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Be[e]=new Ze(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Be[e]=new Ze(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Be[e]=new Ze(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Be[e]=new Ze(e,5,!1,e.toLowerCase(),null,!1,!1)});var zi=/[\-:]([a-z])/g;function Ii(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(zi,Ii);Be[t]=new Ze(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(zi,Ii);Be[t]=new Ze(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(zi,Ii);Be[t]=new Ze(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Be[e]=new Ze(e,1,!1,e.toLowerCase(),null,!1,!1)});Be.xlinkHref=new Ze("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Be[e]=new Ze(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ri(e,t,n,r){var s=Be.hasOwnProperty(t)?Be[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Pp(t,n,s,r)&&(n=null),r||s===null?Ip(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 Zt=Tp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,vs=Symbol.for("react.element"),Un=Symbol.for("react.portal"),Wn=Symbol.for("react.fragment"),Pi=Symbol.for("react.strict_mode"),No=Symbol.for("react.profiler"),yu=Symbol.for("react.provider"),xu=Symbol.for("react.context"),_i=Symbol.for("react.forward_ref"),Eo=Symbol.for("react.suspense"),To=Symbol.for("react.suspense_list"),Ai=Symbol.for("react.memo"),nn=Symbol.for("react.lazy"),wu=Symbol.for("react.offscreen"),Al=Symbol.iterator;function wr(e){return e===null||typeof e!="object"?null:(e=Al&&e[Al]||e["@@iterator"],typeof e=="function"?e:null)}var Se=Object.assign,Ga;function Ir(e){if(Ga===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Ga=t&&t[1]||""}return`
|
|
34
|
+
`+Ga+e}var Ka=!1;function Ya(e,t){if(!e||Ka)return"";Ka=!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{Ka=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Ir(e):""}function _p(e){switch(e.tag){case 5:return Ir(e.type);case 16:return Ir("Lazy");case 13:return Ir("Suspense");case 19:return Ir("SuspenseList");case 0:case 2:case 15:return e=Ya(e.type,!1),e;case 11:return e=Ya(e.type.render,!1),e;case 1:return e=Ya(e.type,!0),e;default:return""}}function zo(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 Wn:return"Fragment";case Un:return"Portal";case No:return"Profiler";case Pi:return"StrictMode";case Eo:return"Suspense";case To: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 _i:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ai:return t=e.displayName||null,t!==null?t:zo(e.type)||"Memo";case nn:t=e._payload,e=e._init;try{return zo(e(t))}catch{}}return null}function Ap(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 zo(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 yn(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 $p(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 ys(e){e._valueTracker||(e._valueTracker=$p(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 Zs(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 Io(e,t){var n=t.checked;return Se({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function $l(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=yn(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&&Ri(e,"checked",t,!1)}function Ro(e,t){ku(e,t);var n=yn(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")?Po(e,t.type,n):t.hasOwnProperty("defaultValue")&&Po(e,t.type,yn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ll(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 Po(e,t,n){(t!=="number"||Zs(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Rr=Array.isArray;function er(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=""+yn(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 _o(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(O(91));return Se({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ml(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(O(92));if(Rr(n)){if(1<n.length)throw Error(O(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:yn(n)}}function bu(e,t){var n=yn(t.value),r=yn(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 Fl(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 Ao(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 xs,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(xs=xs||document.createElement("div"),xs.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=xs.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Gr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var $r={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},Lp=["Webkit","ms","Moz","O"];Object.keys($r).forEach(function(e){Lp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),$r[t]=$r[e]})});function Eu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||$r.hasOwnProperty(e)&&$r[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 Mp=Se({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(Mp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(O(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(O(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(O(61))}if(t.style!=null&&typeof t.style!="object")throw Error(O(62))}}function Lo(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 Mo=null;function $i(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Fo=null,tr=null,nr=null;function Ol(e){if(e=fs(e)){if(typeof Fo!="function")throw Error(O(280));var t=e.stateNode;t&&(t=Ra(t),Fo(e.stateNode,e.type,t))}}function zu(e){tr?nr?nr.push(e):nr=[e]:tr=e}function Iu(){if(tr){var e=tr,t=nr;if(nr=tr=null,Ol(e),t)for(e=0;e<t.length;e++)Ol(t[e])}}function Ru(e,t){return e(t)}function Pu(){}var Qa=!1;function _u(e,t,n){if(Qa)return e(t,n);Qa=!0;try{return Ru(e,t,n)}finally{Qa=!1,(tr!==null||nr!==null)&&(Pu(),Iu())}}function Kr(e,t){var n=e.stateNode;if(n===null)return null;var r=Ra(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(O(231,t,typeof n));return n}var Oo=!1;if(Yt)try{var Sr={};Object.defineProperty(Sr,"passive",{get:function(){Oo=!0}}),window.addEventListener("test",Sr,Sr),window.removeEventListener("test",Sr,Sr)}catch{Oo=!1}function Fp(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 Lr=!1,ea=null,ta=!1,Bo=null,Op={onError:function(e){Lr=!0,ea=e}};function Bp(e,t,n,r,s,o,i,l,c){Lr=!1,ea=null,Fp.apply(Op,arguments)}function Dp(e,t,n,r,s,o,i,l,c){if(Bp.apply(this,arguments),Lr){if(Lr){var d=ea;Lr=!1,ea=null}else throw Error(O(198));ta||(ta=!0,Bo=d)}}function Bn(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 Bl(e){if(Bn(e)!==e)throw Error(O(188))}function Up(e){var t=e.alternate;if(!t){if(t=Bn(e),t===null)throw Error(O(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 Bl(s),e;if(o===r)return Bl(s),t;o=o.sibling}throw Error(O(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(O(189))}}if(n.alternate!==r)throw Error(O(190))}if(n.tag!==3)throw Error(O(188));return n.stateNode.current===n?e:t}function $u(e){return e=Up(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=ct.unstable_scheduleCallback,Dl=ct.unstable_cancelCallback,Wp=ct.unstable_shouldYield,Hp=ct.unstable_requestPaint,be=ct.unstable_now,Vp=ct.unstable_getCurrentPriorityLevel,Li=ct.unstable_ImmediatePriority,Fu=ct.unstable_UserBlockingPriority,na=ct.unstable_NormalPriority,Gp=ct.unstable_LowPriority,Ou=ct.unstable_IdlePriority,Ea=null,Ot=null;function Kp(e){if(Ot&&typeof Ot.onCommitFiberRoot=="function")try{Ot.onCommitFiberRoot(Ea,e,void 0,(e.current.flags&128)===128)}catch{}}var It=Math.clz32?Math.clz32:Jp,Yp=Math.log,Qp=Math.LN2;function Jp(e){return e>>>=0,e===0?32:31-(Yp(e)/Qp|0)|0}var ws=64,Ss=4194304;function Pr(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 ra(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=Pr(l):(o&=i,o!==0&&(r=Pr(o)))}else i=n&~s,i!==0?r=Pr(i):o!==0&&(r=Pr(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-It(t),s=1<<n,r|=e[n],t&=~s;return r}function Xp(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-It(o),l=1<<i,c=s[i];c===-1?(!(l&n)||l&r)&&(s[i]=Xp(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function Do(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Bu(){var e=ws;return ws<<=1,!(ws&4194240)&&(ws=64),e}function Ja(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function us(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-It(t),e[t]=n}function Zp(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-It(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function Mi(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-It(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var de=0;function Du(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Uu,Fi,Wu,Hu,Vu,Uo=!1,js=[],un=null,dn=null,fn=null,Yr=new Map,Qr=new Map,an=[],em="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 Ul(e,t){switch(e){case"focusin":case"focusout":un=null;break;case"dragenter":case"dragleave":dn=null;break;case"mouseover":case"mouseout":fn=null;break;case"pointerover":case"pointerout":Yr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Qr.delete(t.pointerId)}}function jr(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=fs(t),t!==null&&Fi(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function tm(e,t,n,r,s){switch(t){case"focusin":return un=jr(un,e,t,n,r,s),!0;case"dragenter":return dn=jr(dn,e,t,n,r,s),!0;case"mouseover":return fn=jr(fn,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return Yr.set(o,jr(Yr.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,Qr.set(o,jr(Qr.get(o)||null,e,t,n,r,s)),!0}return!1}function Gu(e){var t=Tn(e.target);if(t!==null){var n=Bn(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 Bs(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Wo(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Mo=r,n.target.dispatchEvent(r),Mo=null}else return t=fs(n),t!==null&&Fi(t),e.blockedOn=n,!1;t.shift()}return!0}function Wl(e,t,n){Bs(e)&&n.delete(t)}function nm(){Uo=!1,un!==null&&Bs(un)&&(un=null),dn!==null&&Bs(dn)&&(dn=null),fn!==null&&Bs(fn)&&(fn=null),Yr.forEach(Wl),Qr.forEach(Wl)}function kr(e,t){e.blockedOn===t&&(e.blockedOn=null,Uo||(Uo=!0,ct.unstable_scheduleCallback(ct.unstable_NormalPriority,nm)))}function Jr(e){function t(s){return kr(s,e)}if(0<js.length){kr(js[0],e);for(var n=1;n<js.length;n++){var r=js[n];r.blockedOn===e&&(r.blockedOn=null)}}for(un!==null&&kr(un,e),dn!==null&&kr(dn,e),fn!==null&&kr(fn,e),Yr.forEach(t),Qr.forEach(t),n=0;n<an.length;n++)r=an[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<an.length&&(n=an[0],n.blockedOn===null);)Gu(n),n.blockedOn===null&&an.shift()}var rr=Zt.ReactCurrentBatchConfig,sa=!0;function rm(e,t,n,r){var s=de,o=rr.transition;rr.transition=null;try{de=1,Oi(e,t,n,r)}finally{de=s,rr.transition=o}}function sm(e,t,n,r){var s=de,o=rr.transition;rr.transition=null;try{de=4,Oi(e,t,n,r)}finally{de=s,rr.transition=o}}function Oi(e,t,n,r){if(sa){var s=Wo(e,t,n,r);if(s===null)oo(e,t,r,aa,n),Ul(e,r);else if(tm(s,e,t,n,r))r.stopPropagation();else if(Ul(e,r),t&4&&-1<em.indexOf(e)){for(;s!==null;){var o=fs(s);if(o!==null&&Uu(o),o=Wo(e,t,n,r),o===null&&oo(e,t,r,aa,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else oo(e,t,r,null,n)}}var aa=null;function Wo(e,t,n,r){if(aa=null,e=$i(r),e=Tn(e),e!==null)if(t=Bn(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 aa=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(Vp()){case Li:return 1;case Fu:return 4;case na:case Gp:return 16;case Ou:return 536870912;default:return 16}default:return 16}}var ln=null,Bi=null,Ds=null;function Yu(){if(Ds)return Ds;var e,t=Bi,n=t.length,r,s="value"in ln?ln.value:ln.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 Ds=s.slice(e,1<r?1-r:void 0)}function Us(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 ks(){return!0}function Hl(){return!1}function dt(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)?ks:Hl,this.isPropagationStopped=Hl,this}return Se(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=ks)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=ks)},persist:function(){},isPersistent:ks}),t}var mr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Di=dt(mr),ds=Se({},mr,{view:0,detail:0}),am=dt(ds),Xa,qa,br,Ta=Se({},ds,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ui,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!==br&&(br&&e.type==="mousemove"?(Xa=e.screenX-br.screenX,qa=e.screenY-br.screenY):qa=Xa=0,br=e),Xa)},movementY:function(e){return"movementY"in e?e.movementY:qa}}),Vl=dt(Ta),om=Se({},Ta,{dataTransfer:0}),im=dt(om),lm=Se({},ds,{relatedTarget:0}),Za=dt(lm),cm=Se({},mr,{animationName:0,elapsedTime:0,pseudoElement:0}),um=dt(cm),dm=Se({},mr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),fm=dt(dm),pm=Se({},mr,{data:0}),Gl=dt(pm),mm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hm={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"},gm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vm(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=gm[e])?!!t[e]:!1}function Ui(){return vm}var ym=Se({},ds,{key:function(e){if(e.key){var t=mm[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Us(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?hm[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ui,charCode:function(e){return e.type==="keypress"?Us(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Us(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),xm=dt(ym),wm=Se({},Ta,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Kl=dt(wm),Sm=Se({},ds,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ui}),jm=dt(Sm),km=Se({},mr,{propertyName:0,elapsedTime:0,pseudoElement:0}),bm=dt(km),Cm=Se({},Ta,{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}),Nm=dt(Cm),Em=[9,13,27,32],Wi=Yt&&"CompositionEvent"in window,Mr=null;Yt&&"documentMode"in document&&(Mr=document.documentMode);var Tm=Yt&&"TextEvent"in window&&!Mr,Qu=Yt&&(!Wi||Mr&&8<Mr&&11>=Mr),Yl=" ",Ql=!1;function Ju(e,t){switch(e){case"keyup":return Em.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 Hn=!1;function zm(e,t){switch(e){case"compositionend":return Xu(t);case"keypress":return t.which!==32?null:(Ql=!0,Yl);case"textInput":return e=t.data,e===Yl&&Ql?null:e;default:return null}}function Im(e,t){if(Hn)return e==="compositionend"||!Wi&&Ju(e,t)?(e=Yu(),Ds=Bi=ln=null,Hn=!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 Rm={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 Jl(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Rm[e.type]:t==="textarea"}function qu(e,t,n,r){zu(r),t=oa(t,"onChange"),0<t.length&&(n=new Di("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Fr=null,Xr=null;function Pm(e){cd(e,0)}function za(e){var t=Kn(e);if(ju(t))return e}function _m(e,t){if(e==="change")return t}var Zu=!1;if(Yt){var eo;if(Yt){var to="oninput"in document;if(!to){var Xl=document.createElement("div");Xl.setAttribute("oninput","return;"),to=typeof Xl.oninput=="function"}eo=to}else eo=!1;Zu=eo&&(!document.documentMode||9<document.documentMode)}function ql(){Fr&&(Fr.detachEvent("onpropertychange",ed),Xr=Fr=null)}function ed(e){if(e.propertyName==="value"&&za(Xr)){var t=[];qu(t,Xr,e,$i(e)),_u(Pm,t)}}function Am(e,t,n){e==="focusin"?(ql(),Fr=t,Xr=n,Fr.attachEvent("onpropertychange",ed)):e==="focusout"&&ql()}function $m(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return za(Xr)}function Lm(e,t){if(e==="click")return za(t)}function Mm(e,t){if(e==="input"||e==="change")return za(t)}function Fm(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Pt=typeof Object.is=="function"?Object.is:Fm;function qr(e,t){if(Pt(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(!Co.call(t,s)||!Pt(e[s],t[s]))return!1}return!0}function Zl(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ec(e,t){var n=Zl(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=Zl(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=Zs();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Zs(e.document)}return t}function Hi(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 Om(e){var t=nd(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&td(n.ownerDocument.documentElement,n)){if(r!==null&&Hi(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=ec(n,o);var i=ec(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 Bm=Yt&&"documentMode"in document&&11>=document.documentMode,Vn=null,Ho=null,Or=null,Vo=!1;function tc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Vo||Vn==null||Vn!==Zs(r)||(r=Vn,"selectionStart"in r&&Hi(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}),Or&&qr(Or,r)||(Or=r,r=oa(Ho,"onSelect"),0<r.length&&(t=new Di("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Vn)))}function bs(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Gn={animationend:bs("Animation","AnimationEnd"),animationiteration:bs("Animation","AnimationIteration"),animationstart:bs("Animation","AnimationStart"),transitionend:bs("Transition","TransitionEnd")},no={},rd={};Yt&&(rd=document.createElement("div").style,"AnimationEvent"in window||(delete Gn.animationend.animation,delete Gn.animationiteration.animation,delete Gn.animationstart.animation),"TransitionEvent"in window||delete Gn.transitionend.transition);function Ia(e){if(no[e])return no[e];if(!Gn[e])return e;var t=Gn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in rd)return no[e]=t[n];return e}var sd=Ia("animationend"),ad=Ia("animationiteration"),od=Ia("animationstart"),id=Ia("transitionend"),ld=new Map,nc="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 wn(e,t){ld.set(e,t),On(t,[e])}for(var ro=0;ro<nc.length;ro++){var so=nc[ro],Dm=so.toLowerCase(),Um=so[0].toUpperCase()+so.slice(1);wn(Dm,"on"+Um)}wn(sd,"onAnimationEnd");wn(ad,"onAnimationIteration");wn(od,"onAnimationStart");wn("dblclick","onDoubleClick");wn("focusin","onFocus");wn("focusout","onBlur");wn(id,"onTransitionEnd");or("onMouseEnter",["mouseout","mouseover"]);or("onMouseLeave",["mouseout","mouseover"]);or("onPointerEnter",["pointerout","pointerover"]);or("onPointerLeave",["pointerout","pointerover"]);On("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));On("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));On("onBeforeInput",["compositionend","keypress","textInput","paste"]);On("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));On("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));On("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var _r="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(" "),Wm=new Set("cancel close invalid load scroll toggle".split(" ").concat(_r));function rc(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Dp(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;rc(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;rc(s,l,d),o=c}}}if(ta)throw e=Bo,ta=!1,Bo=null,e}function he(e,t){var n=t[Jo];n===void 0&&(n=t[Jo]=new Set);var r=e+"__bubble";n.has(r)||(ud(t,e,2,!1),n.add(r))}function ao(e,t,n){var r=0;t&&(r|=4),ud(n,e,r,t)}var Cs="_reactListening"+Math.random().toString(36).slice(2);function Zr(e){if(!e[Cs]){e[Cs]=!0,vu.forEach(function(n){n!=="selectionchange"&&(Wm.has(n)||ao(n,!1,e),ao(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Cs]||(t[Cs]=!0,ao("selectionchange",!1,t))}}function ud(e,t,n,r){switch(Ku(t)){case 1:var s=rm;break;case 4:s=sm;break;default:s=Oi}n=s.bind(null,t,n,e),s=void 0,!Oo||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 oo(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=Tn(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=$i(n),m=[];e:{var p=ld.get(e);if(p!==void 0){var x=Di,w=e;switch(e){case"keypress":if(Us(n)===0)break e;case"keydown":case"keyup":x=xm;break;case"focusin":w="focus",x=Za;break;case"focusout":w="blur",x=Za;break;case"beforeblur":case"afterblur":x=Za;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=Vl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=im;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=jm;break;case sd:case ad:case od:x=um;break;case id:x=bm;break;case"scroll":x=am;break;case"wheel":x=Nm;break;case"copy":case"cut":case"paste":x=fm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=Kl}var y=(t&4)!==0,j=!y&&e==="scroll",h=y?p!==null?p+"Capture":null:p;y=[];for(var g=d,v;g!==null;){v=g;var S=v.stateNode;if(v.tag===5&&S!==null&&(v=S,h!==null&&(S=Kr(g,h),S!=null&&y.push(es(g,S,v)))),j)break;g=g.return}0<y.length&&(p=new x(p,w,null,n,f),m.push({event:p,listeners:y}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",p&&n!==Mo&&(w=n.relatedTarget||n.fromElement)&&(Tn(w)||w[Qt]))break e;if((x||p)&&(p=f.window===f?f:(p=f.ownerDocument)?p.defaultView||p.parentWindow:window,x?(w=n.relatedTarget||n.toElement,x=d,w=w?Tn(w):null,w!==null&&(j=Bn(w),w!==j||w.tag!==5&&w.tag!==6)&&(w=null)):(x=null,w=d),x!==w)){if(y=Vl,S="onMouseLeave",h="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(y=Kl,S="onPointerLeave",h="onPointerEnter",g="pointer"),j=x==null?p:Kn(x),v=w==null?p:Kn(w),p=new y(S,g+"leave",x,n,f),p.target=j,p.relatedTarget=v,S=null,Tn(f)===d&&(y=new y(h,g+"enter",w,n,f),y.target=v,y.relatedTarget=j,S=y),j=S,x&&w)t:{for(y=x,h=w,g=0,v=y;v;v=Dn(v))g++;for(v=0,S=h;S;S=Dn(S))v++;for(;0<g-v;)y=Dn(y),g--;for(;0<v-g;)h=Dn(h),v--;for(;g--;){if(y===h||h!==null&&y===h.alternate)break t;y=Dn(y),h=Dn(h)}y=null}else y=null;x!==null&&sc(m,p,x,y,!1),w!==null&&j!==null&&sc(m,j,w,y,!0)}}e:{if(p=d?Kn(d):window,x=p.nodeName&&p.nodeName.toLowerCase(),x==="select"||x==="input"&&p.type==="file")var b=_m;else if(Jl(p))if(Zu)b=Mm;else{b=$m;var I=Am}else(x=p.nodeName)&&x.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(b=Lm);if(b&&(b=b(e,d))){qu(m,b,n,f);break e}I&&I(e,p,d),e==="focusout"&&(I=p._wrapperState)&&I.controlled&&p.type==="number"&&Po(p,"number",p.value)}switch(I=d?Kn(d):window,e){case"focusin":(Jl(I)||I.contentEditable==="true")&&(Vn=I,Ho=d,Or=null);break;case"focusout":Or=Ho=Vn=null;break;case"mousedown":Vo=!0;break;case"contextmenu":case"mouseup":case"dragend":Vo=!1,tc(m,n,f);break;case"selectionchange":if(Bm)break;case"keydown":case"keyup":tc(m,n,f)}var R;if(Wi)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 Hn?Ju(e,n)&&(P="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(P="onCompositionStart");P&&(Qu&&n.locale!=="ko"&&(Hn||P!=="onCompositionStart"?P==="onCompositionEnd"&&Hn&&(R=Yu()):(ln=f,Bi="value"in ln?ln.value:ln.textContent,Hn=!0)),I=oa(d,P),0<I.length&&(P=new Gl(P,e,null,n,f),m.push({event:P,listeners:I}),R?P.data=R:(R=Xu(n),R!==null&&(P.data=R)))),(R=Tm?zm(e,n):Im(e,n))&&(d=oa(d,"onBeforeInput"),0<d.length&&(f=new Gl("onBeforeInput","beforeinput",null,n,f),m.push({event:f,listeners:d}),f.data=R))}cd(m,t)})}function es(e,t,n){return{instance:e,listener:t,currentTarget:n}}function oa(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=Kr(e,n),o!=null&&r.unshift(es(e,o,s)),o=Kr(e,t),o!=null&&r.push(es(e,o,s))),e=e.return}return r}function Dn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function sc(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=Kr(n,o),c!=null&&i.unshift(es(n,c,l))):s||(c=Kr(n,o),c!=null&&i.push(es(n,c,l)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var Hm=/\r\n?/g,Vm=/\u0000|\uFFFD/g;function ac(e){return(typeof e=="string"?e:""+e).replace(Hm,`
|
|
38
|
+
`).replace(Vm,"")}function Ns(e,t,n){if(t=ac(t),ac(e)!==t&&n)throw Error(O(425))}function ia(){}var Go=null,Ko=null;function Yo(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 Qo=typeof setTimeout=="function"?setTimeout:void 0,Gm=typeof clearTimeout=="function"?clearTimeout:void 0,oc=typeof Promise=="function"?Promise:void 0,Km=typeof queueMicrotask=="function"?queueMicrotask:typeof oc<"u"?function(e){return oc.resolve(null).then(e).catch(Ym)}:Qo;function Ym(e){setTimeout(function(){throw e})}function io(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),Jr(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Jr(t)}function pn(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 ic(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 hr=Math.random().toString(36).slice(2),Mt="__reactFiber$"+hr,ts="__reactProps$"+hr,Qt="__reactContainer$"+hr,Jo="__reactEvents$"+hr,Qm="__reactListeners$"+hr,Jm="__reactHandles$"+hr;function Tn(e){var t=e[Mt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Qt]||n[Mt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=ic(e);e!==null;){if(n=e[Mt])return n;e=ic(e)}return t}e=n,n=e.parentNode}return null}function fs(e){return e=e[Mt]||e[Qt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Kn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(O(33))}function Ra(e){return e[ts]||null}var Xo=[],Yn=-1;function Sn(e){return{current:e}}function ge(e){0>Yn||(e.current=Xo[Yn],Xo[Yn]=null,Yn--)}function fe(e,t){Yn++,Xo[Yn]=e.current,e.current=t}var xn={},Ke=Sn(xn),rt=Sn(!1),An=xn;function ir(e,t){var n=e.type.contextTypes;if(!n)return xn;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 la(){ge(rt),ge(Ke)}function lc(e,t,n){if(Ke.current!==xn)throw Error(O(168));fe(Ke,t),fe(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(O(108,Ap(e)||"Unknown",s));return Se({},n,r)}function ca(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xn,An=Ke.current,fe(Ke,e),fe(rt,rt.current),!0}function cc(e,t,n){var r=e.stateNode;if(!r)throw Error(O(169));n?(e=dd(e,t,An),r.__reactInternalMemoizedMergedChildContext=e,ge(rt),ge(Ke),fe(Ke,e)):ge(rt),fe(rt,n)}var Ht=null,Pa=!1,lo=!1;function fd(e){Ht===null?Ht=[e]:Ht.push(e)}function Xm(e){Pa=!0,fd(e)}function jn(){if(!lo&&Ht!==null){lo=!0;var e=0,t=de;try{var n=Ht;for(de=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ht=null,Pa=!1}catch(s){throw Ht!==null&&(Ht=Ht.slice(e+1)),Mu(Li,jn),s}finally{de=t,lo=!1}}return null}var Qn=[],Jn=0,ua=null,da=0,ht=[],gt=0,$n=null,Vt=1,Gt="";function Cn(e,t){Qn[Jn++]=da,Qn[Jn++]=ua,ua=e,da=t}function pd(e,t,n){ht[gt++]=Vt,ht[gt++]=Gt,ht[gt++]=$n,$n=e;var r=Vt;e=Gt;var s=32-It(r)-1;r&=~(1<<s),n+=1;var o=32-It(t)+s;if(30<o){var i=s-s%5;o=(r&(1<<i)-1).toString(32),r>>=i,s-=i,Vt=1<<32-It(t)+s|n<<s|r,Gt=o+e}else Vt=1<<o|n<<s|r,Gt=e}function Vi(e){e.return!==null&&(Cn(e,1),pd(e,1,0))}function Gi(e){for(;e===ua;)ua=Qn[--Jn],Qn[Jn]=null,da=Qn[--Jn],Qn[Jn]=null;for(;e===$n;)$n=ht[--gt],ht[gt]=null,Gt=ht[--gt],ht[gt]=null,Vt=ht[--gt],ht[gt]=null}var lt=null,it=null,ve=!1,zt=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 uc(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,lt=e,it=pn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,lt=e,it=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=$n!==null?{id:Vt,overflow:Gt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=vt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,lt=e,it=null,!0):!1;default:return!1}}function qo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Zo(e){if(ve){var t=it;if(t){var n=t;if(!uc(e,t)){if(qo(e))throw Error(O(418));t=pn(n.nextSibling);var r=lt;t&&uc(e,t)?md(r,n):(e.flags=e.flags&-4097|2,ve=!1,lt=e)}}else{if(qo(e))throw Error(O(418));e.flags=e.flags&-4097|2,ve=!1,lt=e}}}function dc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;lt=e}function Es(e){if(e!==lt)return!1;if(!ve)return dc(e),ve=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Yo(e.type,e.memoizedProps)),t&&(t=it)){if(qo(e))throw hd(),Error(O(418));for(;t;)md(e,t),t=pn(t.nextSibling)}if(dc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){it=pn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}it=null}}else it=lt?pn(e.stateNode.nextSibling):null;return!0}function hd(){for(var e=it;e;)e=pn(e.nextSibling)}function lr(){it=lt=null,ve=!1}function Ki(e){zt===null?zt=[e]:zt.push(e)}var qm=Zt.ReactCurrentBatchConfig;function Cr(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(O(309));var r=n.stateNode}if(!r)throw Error(O(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(O(284));if(!n._owner)throw Error(O(290,e))}return e}function Ts(e,t){throw e=Object.prototype.toString.call(t),Error(O(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function fc(e){var t=e._init;return t(e._payload)}function gd(e){function t(h,g){if(e){var v=h.deletions;v===null?(h.deletions=[g],h.flags|=16):v.push(g)}}function n(h,g){if(!e)return null;for(;g!==null;)t(h,g),g=g.sibling;return null}function r(h,g){for(h=new Map;g!==null;)g.key!==null?h.set(g.key,g):h.set(g.index,g),g=g.sibling;return h}function s(h,g){return h=vn(h,g),h.index=0,h.sibling=null,h}function o(h,g,v){return h.index=v,e?(v=h.alternate,v!==null?(v=v.index,v<g?(h.flags|=2,g):v):(h.flags|=2,g)):(h.flags|=1048576,g)}function i(h){return e&&h.alternate===null&&(h.flags|=2),h}function l(h,g,v,S){return g===null||g.tag!==6?(g=go(v,h.mode,S),g.return=h,g):(g=s(g,v),g.return=h,g)}function c(h,g,v,S){var b=v.type;return b===Wn?f(h,g,v.props.children,S,v.key):g!==null&&(g.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===nn&&fc(b)===g.type)?(S=s(g,v.props),S.ref=Cr(h,g,v),S.return=h,S):(S=Qs(v.type,v.key,v.props,null,h.mode,S),S.ref=Cr(h,g,v),S.return=h,S)}function d(h,g,v,S){return g===null||g.tag!==4||g.stateNode.containerInfo!==v.containerInfo||g.stateNode.implementation!==v.implementation?(g=vo(v,h.mode,S),g.return=h,g):(g=s(g,v.children||[]),g.return=h,g)}function f(h,g,v,S,b){return g===null||g.tag!==7?(g=_n(v,h.mode,S,b),g.return=h,g):(g=s(g,v),g.return=h,g)}function m(h,g,v){if(typeof g=="string"&&g!==""||typeof g=="number")return g=go(""+g,h.mode,v),g.return=h,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case vs:return v=Qs(g.type,g.key,g.props,null,h.mode,v),v.ref=Cr(h,null,g),v.return=h,v;case Un:return g=vo(g,h.mode,v),g.return=h,g;case nn:var S=g._init;return m(h,S(g._payload),v)}if(Rr(g)||wr(g))return g=_n(g,h.mode,v,null),g.return=h,g;Ts(h,g)}return null}function p(h,g,v,S){var b=g!==null?g.key:null;if(typeof v=="string"&&v!==""||typeof v=="number")return b!==null?null:l(h,g,""+v,S);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case vs:return v.key===b?c(h,g,v,S):null;case Un:return v.key===b?d(h,g,v,S):null;case nn:return b=v._init,p(h,g,b(v._payload),S)}if(Rr(v)||wr(v))return b!==null?null:f(h,g,v,S,null);Ts(h,v)}return null}function x(h,g,v,S,b){if(typeof S=="string"&&S!==""||typeof S=="number")return h=h.get(v)||null,l(g,h,""+S,b);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case vs:return h=h.get(S.key===null?v:S.key)||null,c(g,h,S,b);case Un:return h=h.get(S.key===null?v:S.key)||null,d(g,h,S,b);case nn:var I=S._init;return x(h,g,v,I(S._payload),b)}if(Rr(S)||wr(S))return h=h.get(v)||null,f(g,h,S,b,null);Ts(g,S)}return null}function w(h,g,v,S){for(var b=null,I=null,R=g,P=g=0,C=null;R!==null&&P<v.length;P++){R.index>P?(C=R,R=null):C=R.sibling;var z=p(h,R,v[P],S);if(z===null){R===null&&(R=C);break}e&&R&&z.alternate===null&&t(h,R),g=o(z,g,P),I===null?b=z:I.sibling=z,I=z,R=C}if(P===v.length)return n(h,R),ve&&Cn(h,P),b;if(R===null){for(;P<v.length;P++)R=m(h,v[P],S),R!==null&&(g=o(R,g,P),I===null?b=R:I.sibling=R,I=R);return ve&&Cn(h,P),b}for(R=r(h,R);P<v.length;P++)C=x(R,h,P,v[P],S),C!==null&&(e&&C.alternate!==null&&R.delete(C.key===null?P:C.key),g=o(C,g,P),I===null?b=C:I.sibling=C,I=C);return e&&R.forEach(function(B){return t(h,B)}),ve&&Cn(h,P),b}function y(h,g,v,S){var b=wr(v);if(typeof b!="function")throw Error(O(150));if(v=b.call(v),v==null)throw Error(O(151));for(var I=b=null,R=g,P=g=0,C=null,z=v.next();R!==null&&!z.done;P++,z=v.next()){R.index>P?(C=R,R=null):C=R.sibling;var B=p(h,R,z.value,S);if(B===null){R===null&&(R=C);break}e&&R&&B.alternate===null&&t(h,R),g=o(B,g,P),I===null?b=B:I.sibling=B,I=B,R=C}if(z.done)return n(h,R),ve&&Cn(h,P),b;if(R===null){for(;!z.done;P++,z=v.next())z=m(h,z.value,S),z!==null&&(g=o(z,g,P),I===null?b=z:I.sibling=z,I=z);return ve&&Cn(h,P),b}for(R=r(h,R);!z.done;P++,z=v.next())z=x(R,h,P,z.value,S),z!==null&&(e&&z.alternate!==null&&R.delete(z.key===null?P:z.key),g=o(z,g,P),I===null?b=z:I.sibling=z,I=z);return e&&R.forEach(function(K){return t(h,K)}),ve&&Cn(h,P),b}function j(h,g,v,S){if(typeof v=="object"&&v!==null&&v.type===Wn&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case vs:e:{for(var b=v.key,I=g;I!==null;){if(I.key===b){if(b=v.type,b===Wn){if(I.tag===7){n(h,I.sibling),g=s(I,v.props.children),g.return=h,h=g;break e}}else if(I.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===nn&&fc(b)===I.type){n(h,I.sibling),g=s(I,v.props),g.ref=Cr(h,I,v),g.return=h,h=g;break e}n(h,I);break}else t(h,I);I=I.sibling}v.type===Wn?(g=_n(v.props.children,h.mode,S,v.key),g.return=h,h=g):(S=Qs(v.type,v.key,v.props,null,h.mode,S),S.ref=Cr(h,g,v),S.return=h,h=S)}return i(h);case Un:e:{for(I=v.key;g!==null;){if(g.key===I)if(g.tag===4&&g.stateNode.containerInfo===v.containerInfo&&g.stateNode.implementation===v.implementation){n(h,g.sibling),g=s(g,v.children||[]),g.return=h,h=g;break e}else{n(h,g);break}else t(h,g);g=g.sibling}g=vo(v,h.mode,S),g.return=h,h=g}return i(h);case nn:return I=v._init,j(h,g,I(v._payload),S)}if(Rr(v))return w(h,g,v,S);if(wr(v))return y(h,g,v,S);Ts(h,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,g!==null&&g.tag===6?(n(h,g.sibling),g=s(g,v),g.return=h,h=g):(n(h,g),g=go(v,h.mode,S),g.return=h,h=g),i(h)):n(h,g)}return j}var cr=gd(!0),vd=gd(!1),fa=Sn(null),pa=null,Xn=null,Yi=null;function Qi(){Yi=Xn=pa=null}function Ji(e){var t=fa.current;ge(fa),e._currentValue=t}function ei(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 sr(e,t){pa=e,Yi=Xn=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(Yi!==e)if(e={context:e,memoizedValue:t,next:null},Xn===null){if(pa===null)throw Error(O(308));Xn=e,pa.dependencies={lanes:0,firstContext:e}}else Xn=Xn.next=e;return t}var zn=null;function Xi(e){zn===null?zn=[e]:zn.push(e)}function yd(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Xi(t)):(n.next=s.next,s.next=n),t.interleaved=n,Jt(e,r)}function Jt(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 rn=!1;function qi(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 Kt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function mn(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,Jt(e,n)}return s=r.interleaved,s===null?(t.next=t,Xi(r)):(t.next=s.next,s.next=t),r.interleaved=t,Jt(e,n)}function Ws(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,Mi(e,n)}}function pc(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 ma(e,t,n,r){var s=e.updateQueue;rn=!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 m=s.baseState;i=0,f=d=c=null,l=o;do{var p=l.lane,x=l.eventTime;if((r&p)===p){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(p=t,x=n,y.tag){case 1:if(w=y.payload,typeof w=="function"){m=w.call(x,m,p);break e}m=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=y.payload,p=typeof w=="function"?w.call(x,m,p):w,p==null)break e;m=Se({},m,p);break e;case 2:rn=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else x={eventTime:x,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(d=f=x,c=m):f=f.next=x,i|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(f===null&&(c=m),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);Mn|=i,e.lanes=i,e.memoizedState=m}}function mc(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(O(191,s));s.call(r)}}}var ps={},Bt=Sn(ps),ns=Sn(ps),rs=Sn(ps);function In(e){if(e===ps)throw Error(O(174));return e}function Zi(e,t){switch(fe(rs,t),fe(ns,e),fe(Bt,ps),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ao(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Ao(t,e)}ge(Bt),fe(Bt,t)}function ur(){ge(Bt),ge(ns),ge(rs)}function wd(e){In(rs.current);var t=In(Bt.current),n=Ao(t,e.type);t!==n&&(fe(ns,e),fe(Bt,n))}function el(e){ns.current===e&&(ge(Bt),ge(ns))}var xe=Sn(0);function ha(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 co=[];function tl(){for(var e=0;e<co.length;e++)co[e]._workInProgressVersionPrimary=null;co.length=0}var Hs=Zt.ReactCurrentDispatcher,uo=Zt.ReactCurrentBatchConfig,Ln=0,we=null,Ne=null,Ae=null,ga=!1,Br=!1,ss=0,Zm=0;function He(){throw Error(O(321))}function nl(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Pt(e[n],t[n]))return!1;return!0}function rl(e,t,n,r,s,o){if(Ln=o,we=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Hs.current=e===null||e.memoizedState===null?rh:sh,e=n(r,s),Br){o=0;do{if(Br=!1,ss=0,25<=o)throw Error(O(301));o+=1,Ae=Ne=null,t.updateQueue=null,Hs.current=ah,e=n(r,s)}while(Br)}if(Hs.current=va,t=Ne!==null&&Ne.next!==null,Ln=0,Ae=Ne=we=null,ga=!1,t)throw Error(O(300));return e}function sl(){var e=ss!==0;return ss=0,e}function $t(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ae===null?we.memoizedState=Ae=e:Ae=Ae.next=e,Ae}function wt(){if(Ne===null){var e=we.alternate;e=e!==null?e.memoizedState:null}else e=Ne.next;var t=Ae===null?we.memoizedState:Ae.next;if(t!==null)Ae=t,Ne=e;else{if(e===null)throw Error(O(310));Ne=e,e={memoizedState:Ne.memoizedState,baseState:Ne.baseState,baseQueue:Ne.baseQueue,queue:Ne.queue,next:null},Ae===null?we.memoizedState=Ae=e:Ae=Ae.next=e}return Ae}function as(e,t){return typeof t=="function"?t(e):t}function fo(e){var t=wt(),n=t.queue;if(n===null)throw Error(O(311));n.lastRenderedReducer=e;var r=Ne,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((Ln&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 m={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=m,i=r):c=c.next=m,we.lanes|=f,Mn|=f}d=d.next}while(d!==null&&d!==o);c===null?i=r:c.next=l,Pt(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,we.lanes|=o,Mn|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function po(e){var t=wt(),n=t.queue;if(n===null)throw Error(O(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);Pt(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=we,r=wt(),s=t(),o=!Pt(r.memoizedState,s);if(o&&(r.memoizedState=s,nt=!0),r=r.queue,al(Cd.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||Ae!==null&&Ae.memoizedState.tag&1){if(n.flags|=2048,os(9,bd.bind(null,n,r,s,t),void 0,null),$e===null)throw Error(O(349));Ln&30||kd(n,t,s)}return s}function kd(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=we.updateQueue,t===null?(t={lastEffect:null,stores:null},we.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!Pt(e,n)}catch{return!0}}function Ed(e){var t=Jt(e,1);t!==null&&Rt(t,e,1,-1)}function hc(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:as,lastRenderedState:e},t.queue=e,e=e.dispatch=nh.bind(null,we,e),[t.memoizedState,e]}function os(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=we.updateQueue,t===null?(t={lastEffect:null,stores:null},we.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 Vs(e,t,n,r){var s=$t();we.flags|=e,s.memoizedState=os(1|t,n,void 0,r===void 0?null:r)}function _a(e,t,n,r){var s=wt();r=r===void 0?null:r;var o=void 0;if(Ne!==null){var i=Ne.memoizedState;if(o=i.destroy,r!==null&&nl(r,i.deps)){s.memoizedState=os(t,n,o,r);return}}we.flags|=e,s.memoizedState=os(1|t,n,o,r)}function gc(e,t){return Vs(8390656,8,e,t)}function al(e,t){return _a(2048,8,e,t)}function zd(e,t){return _a(4,2,e,t)}function Id(e,t){return _a(4,4,e,t)}function Rd(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 Pd(e,t,n){return n=n!=null?n.concat([e]):null,_a(4,4,Rd.bind(null,t,e),n)}function ol(){}function _d(e,t){var n=wt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&nl(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&&nl(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function $d(e,t,n){return Ln&21?(Pt(n,t)||(n=Bu(),we.lanes|=n,Mn|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,nt=!0),e.memoizedState=n)}function eh(e,t){var n=de;de=n!==0&&4>n?n:4,e(!0);var r=uo.transition;uo.transition={};try{e(!1),t()}finally{de=n,uo.transition=r}}function Ld(){return wt().memoizedState}function th(e,t,n){var r=gn(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=Xe();Rt(n,e,r,s),Od(n,t,r)}}function nh(e,t,n){var r=gn(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,Pt(l,i)){var c=t.interleaved;c===null?(s.next=s,Xi(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=yd(e,t,s,r),n!==null&&(s=Xe(),Rt(n,e,r,s),Od(n,t,r))}}function Md(e){var t=e.alternate;return e===we||t!==null&&t===we}function Fd(e,t){Br=ga=!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,Mi(e,n)}}var va={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},rh={readContext:xt,useCallback:function(e,t){return $t().memoizedState=[e,t===void 0?null:t],e},useContext:xt,useEffect:gc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Vs(4194308,4,Rd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Vs(4194308,4,e,t)},useInsertionEffect:function(e,t){return Vs(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=th.bind(null,we,e),[r.memoizedState,e]},useRef:function(e){var t=$t();return e={current:e},t.memoizedState=e},useState:hc,useDebugValue:ol,useDeferredValue:function(e){return $t().memoizedState=e},useTransition:function(){var e=hc(!1),t=e[0];return e=eh.bind(null,e[1]),$t().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=we,s=$t();if(ve){if(n===void 0)throw Error(O(407));n=n()}else{if(n=t(),$e===null)throw Error(O(349));Ln&30||kd(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,gc(Cd.bind(null,r,o,e),[e]),r.flags|=2048,os(9,bd.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=$t(),t=$e.identifierPrefix;if(ve){var n=Gt,r=Vt;n=(r&~(1<<32-It(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ss++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Zm++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},sh={readContext:xt,useCallback:_d,useContext:xt,useEffect:al,useImperativeHandle:Pd,useInsertionEffect:zd,useLayoutEffect:Id,useMemo:Ad,useReducer:fo,useRef:Td,useState:function(){return fo(as)},useDebugValue:ol,useDeferredValue:function(e){var t=wt();return $d(t,Ne.memoizedState,e)},useTransition:function(){var e=fo(as)[0],t=wt().memoizedState;return[e,t]},useMutableSource:Sd,useSyncExternalStore:jd,useId:Ld,unstable_isNewReconciler:!1},ah={readContext:xt,useCallback:_d,useContext:xt,useEffect:al,useImperativeHandle:Pd,useInsertionEffect:zd,useLayoutEffect:Id,useMemo:Ad,useReducer:po,useRef:Td,useState:function(){return po(as)},useDebugValue:ol,useDeferredValue:function(e){var t=wt();return Ne===null?t.memoizedState=e:$d(t,Ne.memoizedState,e)},useTransition:function(){var e=po(as)[0],t=wt().memoizedState;return[e,t]},useMutableSource:Sd,useSyncExternalStore:jd,useId:Ld,unstable_isNewReconciler:!1};function Et(e,t){if(e&&e.defaultProps){t=Se({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function ti(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Se({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Aa={isMounted:function(e){return(e=e._reactInternals)?Bn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Xe(),s=gn(e),o=Kt(r,s);o.payload=t,n!=null&&(o.callback=n),t=mn(e,o,s),t!==null&&(Rt(t,e,s,r),Ws(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Xe(),s=gn(e),o=Kt(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=mn(e,o,s),t!==null&&(Rt(t,e,s,r),Ws(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Xe(),r=gn(e),s=Kt(n,r);s.tag=2,t!=null&&(s.callback=t),t=mn(e,s,r),t!==null&&(Rt(t,e,r,n),Ws(t,e,r))}};function vc(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=xn,o=t.contextType;return typeof o=="object"&&o!==null?o=xt(o):(s=st(t)?An:Ke.current,r=t.contextTypes,o=(r=r!=null)?ir(e,s):xn),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Aa,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function yc(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&&Aa.enqueueReplaceState(t,t.state,null)}function ni(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},qi(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=xt(o):(o=st(t)?An:Ke.current,s.context=ir(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(ti(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&&Aa.enqueueReplaceState(s,s.state,null),ma(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function dr(e,t){try{var n="",r=t;do n+=_p(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 mo(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ri(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var oh=typeof WeakMap=="function"?WeakMap:Map;function Dd(e,t,n){n=Kt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){xa||(xa=!0,pi=r),ri(e,t)},n}function Ud(e,t,n){n=Kt(-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(){ri(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){ri(e,t),typeof r!="function"&&(hn===null?hn=new Set([this]):hn.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function xc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new oh;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=wh.bind(null,e,t,n),t.then(e,e))}function wc(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 Sc(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=Kt(-1,1),t.tag=2,mn(n,t,1))),n.lanes|=1),e)}var ih=Zt.ReactCurrentOwner,nt=!1;function Qe(e,t,n,r){t.child=e===null?vd(t,null,n,r):cr(t,e.child,n,r)}function jc(e,t,n,r,s){n=n.render;var o=t.ref;return sr(t,s),r=rl(e,t,n,r,o,s),n=sl(),e!==null&&!nt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Xt(e,t,s)):(ve&&n&&Vi(t),t.flags|=1,Qe(e,t,r,s),t.child)}function kc(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!ml(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=Qs(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 Xt(e,t,s)}return t.flags|=1,e=vn(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,Xt(e,t,s)}return si(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},fe(Zn,ot),ot|=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,fe(Zn,ot),ot|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,fe(Zn,ot),ot|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,fe(Zn,ot),ot|=r;return Qe(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 si(e,t,n,r,s){var o=st(n)?An:Ke.current;return o=ir(t,o),sr(t,s),n=rl(e,t,n,r,o,s),r=sl(),e!==null&&!nt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,Xt(e,t,s)):(ve&&r&&Vi(t),t.flags|=1,Qe(e,t,n,s),t.child)}function bc(e,t,n,r,s){if(st(n)){var o=!0;ca(t)}else o=!1;if(sr(t,s),t.stateNode===null)Gs(e,t),Bd(t,n,r),ni(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)?An:Ke.current,d=ir(t,d));var f=n.getDerivedStateFromProps,m=typeof f=="function"||typeof i.getSnapshotBeforeUpdate=="function";m||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==r||c!==d)&&yc(t,i,r,d),rn=!1;var p=t.memoizedState;i.state=p,ma(t,r,i,s),c=t.memoizedState,l!==r||p!==c||rt.current||rn?(typeof f=="function"&&(ti(t,n,f,r),c=t.memoizedState),(l=rn||vc(t,n,l,r,p,c,d))?(m||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:Et(t.type,l),i.props=d,m=t.pendingProps,p=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=xt(c):(c=st(n)?An:Ke.current,c=ir(t,c));var x=n.getDerivedStateFromProps;(f=typeof x=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==m||p!==c)&&yc(t,i,r,c),rn=!1,p=t.memoizedState,i.state=p,ma(t,r,i,s);var w=t.memoizedState;l!==m||p!==w||rt.current||rn?(typeof x=="function"&&(ti(t,n,x,r),w=t.memoizedState),(d=rn||vc(t,n,d,r,p,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&&p===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===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&&p===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return ai(e,t,n,r,o,s)}function ai(e,t,n,r,s,o){Vd(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return s&&cc(t,n,!1),Xt(e,t,o);r=t.stateNode,ih.current=t;var l=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=cr(t,e.child,null,o),t.child=cr(t,null,l,o)):Qe(e,t,l,o),t.memoizedState=r.state,s&&cc(t,n,!0),t.child}function Gd(e){var t=e.stateNode;t.pendingContext?lc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&lc(e,t.context,!1),Zi(e,t.containerInfo)}function Cc(e,t,n,r,s){return lr(),Ki(s),t.flags|=256,Qe(e,t,n,r),t.child}var oi={dehydrated:null,treeContext:null,retryLane:0};function ii(e){return{baseLanes:e,cachePool:null,transitions:null}}function Kd(e,t,n){var r=t.pendingProps,s=xe.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),fe(xe,s&1),e===null)return Zo(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=Ma(i,r,0,null),e=_n(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=ii(n),t.memoizedState=oi,e):il(t,i));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return lh(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=vn(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=vn(l,o):(o=_n(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?ii(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},o.memoizedState=i,o.childLanes=e.childLanes&~n,t.memoizedState=oi,r}return o=e.child,e=o.sibling,r=vn(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 il(e,t){return t=Ma({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function zs(e,t,n,r){return r!==null&&Ki(r),cr(t,e.child,null,n),e=il(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function lh(e,t,n,r,s,o,i){if(n)return t.flags&256?(t.flags&=-257,r=mo(Error(O(422))),zs(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=Ma({mode:"visible",children:r.children},s,0,null),o=_n(o,s,i,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&cr(t,e.child,null,i),t.child.memoizedState=ii(i),t.memoizedState=oi,o);if(!(t.mode&1))return zs(e,t,i,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(O(419)),r=mo(o,r,void 0),zs(e,t,i,r)}if(l=(i&e.childLanes)!==0,nt||l){if(r=$e,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,Jt(e,s),Rt(r,e,s,-1))}return pl(),r=mo(Error(O(421))),zs(e,t,i,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=Sh.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,it=pn(s.nextSibling),lt=t,ve=!0,zt=null,e!==null&&(ht[gt++]=Vt,ht[gt++]=Gt,ht[gt++]=$n,Vt=e.id,Gt=e.overflow,$n=t),t=il(t,r.children),t.flags|=4096,t)}function Nc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ei(e.return,t,n)}function ho(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(Qe(e,t,r.children,n),r=xe.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&&Nc(e,n,t);else if(e.tag===19)Nc(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(fe(xe,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&&ha(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),ho(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&&ha(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}ho(t,!0,n,null,o);break;case"together":ho(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Gs(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Xt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Mn|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(O(153));if(t.child!==null){for(e=t.child,n=vn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=vn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function ch(e,t,n){switch(t.tag){case 3:Gd(t),lr();break;case 5:wd(t);break;case 1:st(t.type)&&ca(t);break;case 4:Zi(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;fe(fa,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(fe(xe,xe.current&1),t.flags|=128,null):n&t.child.childLanes?Kd(e,t,n):(fe(xe,xe.current&1),e=Xt(e,t,n),e!==null?e.sibling:null);fe(xe,xe.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),fe(xe,xe.current),r)break;return null;case 22:case 23:return t.lanes=0,Hd(e,t,n)}return Xt(e,t,n)}var Qd,li,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}};li=function(){};Jd=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,In(Bt.current);var o=null;switch(n){case"input":s=Io(e,s),r=Io(e,r),o=[];break;case"select":s=Se({},s,{value:void 0}),r=Se({},r,{value:void 0}),o=[];break;case"textarea":s=_o(e,s),r=_o(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=ia)}$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"&&(Vr.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"&&(Vr.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&he("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 Nr(e,t){if(!ve)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 uh(e,t,n){var r=t.pendingProps;switch(Gi(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)&&la(),Ve(t),null;case 3:return r=t.stateNode,ur(),ge(rt),ge(Ke),tl(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Es(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,zt!==null&&(gi(zt),zt=null))),li(e,t),Ve(t),null;case 5:el(t);var s=In(rs.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(O(166));return Ve(t),null}if(e=In(Bt.current),Es(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Mt]=t,r[ts]=o,e=(t.mode&1)!==0,n){case"dialog":he("cancel",r),he("close",r);break;case"iframe":case"object":case"embed":he("load",r);break;case"video":case"audio":for(s=0;s<_r.length;s++)he(_r[s],r);break;case"source":he("error",r);break;case"img":case"image":case"link":he("error",r),he("load",r);break;case"details":he("toggle",r);break;case"input":$l(r,o),he("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},he("invalid",r);break;case"textarea":Ml(r,o),he("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&&Ns(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&Ns(r.textContent,l,e),s=["children",""+l]):Vr.hasOwnProperty(i)&&l!=null&&i==="onScroll"&&he("scroll",r)}switch(n){case"input":ys(r),Ll(r,o,!0);break;case"textarea":ys(r),Fl(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=ia)}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[Mt]=t,e[ts]=r,Qd(e,t,!1,!1),t.stateNode=e;e:{switch(i=Lo(n,r),n){case"dialog":he("cancel",e),he("close",e),s=r;break;case"iframe":case"object":case"embed":he("load",e),s=r;break;case"video":case"audio":for(s=0;s<_r.length;s++)he(_r[s],e);s=r;break;case"source":he("error",e),s=r;break;case"img":case"image":case"link":he("error",e),he("load",e),s=r;break;case"details":he("toggle",e),s=r;break;case"input":$l(e,r),s=Io(e,r),he("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Se({},r,{value:void 0}),he("invalid",e);break;case"textarea":Ml(e,r),s=_o(e,r),he("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!=="")&&Gr(e,c):typeof c=="number"&&Gr(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Vr.hasOwnProperty(o)?c!=null&&o==="onScroll"&&he("scroll",e):c!=null&&Ri(e,o,c,i))}switch(n){case"input":ys(e),Ll(e,r,!1);break;case"textarea":ys(e),Fl(e);break;case"option":r.value!=null&&e.setAttribute("value",""+yn(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?er(e,!!r.multiple,o,!1):r.defaultValue!=null&&er(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=ia)}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(O(166));if(n=In(rs.current),In(Bt.current),Es(t)){if(r=t.stateNode,n=t.memoizedProps,r[Mt]=t,(o=r.nodeValue!==n)&&(e=lt,e!==null))switch(e.tag){case 3:Ns(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ns(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Mt]=t,t.stateNode=r}return Ve(t),null;case 13:if(ge(xe),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ve&&it!==null&&t.mode&1&&!(t.flags&128))hd(),lr(),t.flags|=98560,o=!1;else if(o=Es(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(O(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(O(317));o[Mt]=t}else lr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ve(t),o=!1}else zt!==null&&(gi(zt),zt=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||xe.current&1?Ee===0&&(Ee=3):pl())),t.updateQueue!==null&&(t.flags|=4),Ve(t),null);case 4:return ur(),li(e,t),e===null&&Zr(t.stateNode.containerInfo),Ve(t),null;case 10:return Ji(t.type._context),Ve(t),null;case 17:return st(t.type)&&la(),Ve(t),null;case 19:if(ge(xe),o=t.memoizedState,o===null)return Ve(t),null;if(r=(t.flags&128)!==0,i=o.rendering,i===null)if(r)Nr(o,!1);else{if(Ee!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=ha(e),i!==null){for(t.flags|=128,Nr(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 fe(xe,xe.current&1|2),t.child}e=e.sibling}o.tail!==null&&be()>fr&&(t.flags|=128,r=!0,Nr(o,!1),t.lanes=4194304)}else{if(!r)if(e=ha(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Nr(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!ve)return Ve(t),null}else 2*be()-o.renderingStartTime>fr&&n!==1073741824&&(t.flags|=128,r=!0,Nr(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=be(),t.sibling=null,n=xe.current,fe(xe,r?n&1|2:n&1),t):(Ve(t),null);case 22:case 23:return fl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ot&1073741824&&(Ve(t),t.subtreeFlags&6&&(t.flags|=8192)):Ve(t),null;case 24:return null;case 25:return null}throw Error(O(156,t.tag))}function dh(e,t){switch(Gi(t),t.tag){case 1:return st(t.type)&&la(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ur(),ge(rt),ge(Ke),tl(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return el(t),null;case 13:if(ge(xe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(O(340));lr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ge(xe),null;case 4:return ur(),null;case 10:return Ji(t.type._context),null;case 22:case 23:return fl(),null;case 24:return null;default:return null}}var Is=!1,Ge=!1,fh=typeof WeakSet=="function"?WeakSet:Set,Q=null;function qn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ke(e,t,r)}else n.current=null}function ci(e,t,n){try{n()}catch(r){ke(e,t,r)}}var Ec=!1;function ph(e,t){if(Go=sa,e=nd(),Hi(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,m=e,p=null;t:for(;;){for(var x;m!==n||s!==0&&m.nodeType!==3||(l=i+s),m!==o||r!==0&&m.nodeType!==3||(c=i+r),m.nodeType===3&&(i+=m.nodeValue.length),(x=m.firstChild)!==null;)p=m,m=x;for(;;){if(m===e)break t;if(p===n&&++d===s&&(l=i),p===o&&++f===r&&(c=i),(x=m.nextSibling)!==null)break;m=p,p=m.parentNode}m=x}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ko={focusedElem:e,selectionRange:n},sa=!1,Q=t;Q!==null;)if(t=Q,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;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,h=t.stateNode,g=h.getSnapshotBeforeUpdate(t.elementType===t.type?y:Et(t.type,y),j);h.__reactInternalSnapshotBeforeUpdate=g}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(O(163))}}catch(S){ke(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return w=Ec,Ec=!1,w}function Dr(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&&ci(t,n,o)}s=s.next}while(s!==r)}}function $a(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 ui(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[Mt],delete t[ts],delete t[Jo],delete t[Qm],delete t[Jm])),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 Tc(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 di(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=ia));else if(r!==4&&(e=e.child,e!==null))for(di(e,t,n),e=e.sibling;e!==null;)di(e,t,n),e=e.sibling}function fi(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(fi(e,t,n),e=e.sibling;e!==null;)fi(e,t,n),e=e.sibling}var Fe=null,Tt=!1;function tn(e,t,n){for(n=n.child;n!==null;)ef(e,t,n),n=n.sibling}function ef(e,t,n){if(Ot&&typeof Ot.onCommitFiberUnmount=="function")try{Ot.onCommitFiberUnmount(Ea,n)}catch{}switch(n.tag){case 5:Ge||qn(n,t);case 6:var r=Fe,s=Tt;Fe=null,tn(e,t,n),Fe=r,Tt=s,Fe!==null&&(Tt?(e=Fe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Fe.removeChild(n.stateNode));break;case 18:Fe!==null&&(Tt?(e=Fe,n=n.stateNode,e.nodeType===8?io(e.parentNode,n):e.nodeType===1&&io(e,n),Jr(e)):io(Fe,n.stateNode));break;case 4:r=Fe,s=Tt,Fe=n.stateNode.containerInfo,Tt=!0,tn(e,t,n),Fe=r,Tt=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)&&ci(n,t,i),s=s.next}while(s!==r)}tn(e,t,n);break;case 1:if(!Ge&&(qn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){ke(n,t,l)}tn(e,t,n);break;case 21:tn(e,t,n);break;case 22:n.mode&1?(Ge=(r=Ge)||n.memoizedState!==null,tn(e,t,n),Ge=r):tn(e,t,n);break;default:tn(e,t,n)}}function zc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new fh),t.forEach(function(r){var s=jh.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Nt(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:Fe=l.stateNode,Tt=!1;break e;case 3:Fe=l.stateNode.containerInfo,Tt=!0;break e;case 4:Fe=l.stateNode.containerInfo,Tt=!0;break e}l=l.return}if(Fe===null)throw Error(O(160));ef(o,i,s),Fe=null,Tt=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){ke(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(Nt(t,e),At(e),r&4){try{Dr(3,e,e.return),$a(3,e)}catch(y){ke(e,e.return,y)}try{Dr(5,e,e.return)}catch(y){ke(e,e.return,y)}}break;case 1:Nt(t,e),At(e),r&512&&n!==null&&qn(n,n.return);break;case 5:if(Nt(t,e),At(e),r&512&&n!==null&&qn(n,n.return),e.flags&32){var s=e.stateNode;try{Gr(s,"")}catch(y){ke(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),Lo(l,i);var d=Lo(l,o);for(i=0;i<c.length;i+=2){var f=c[i],m=c[i+1];f==="style"?Tu(s,m):f==="dangerouslySetInnerHTML"?Nu(s,m):f==="children"?Gr(s,m):Ri(s,f,m,d)}switch(l){case"input":Ro(s,o);break;case"textarea":bu(s,o);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var x=o.value;x!=null?er(s,!!o.multiple,x,!1):p!==!!o.multiple&&(o.defaultValue!=null?er(s,!!o.multiple,o.defaultValue,!0):er(s,!!o.multiple,o.multiple?[]:"",!1))}s[ts]=o}catch(y){ke(e,e.return,y)}}break;case 6:if(Nt(t,e),At(e),r&4){if(e.stateNode===null)throw Error(O(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(y){ke(e,e.return,y)}}break;case 3:if(Nt(t,e),At(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Jr(t.containerInfo)}catch(y){ke(e,e.return,y)}break;case 4:Nt(t,e),At(e);break;case 13:Nt(t,e),At(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(ul=be())),r&4&&zc(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Ge=(d=Ge)||f,Nt(t,e),Ge=d):Nt(t,e),At(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(Q=e,f=e.child;f!==null;){for(m=Q=f;Q!==null;){switch(p=Q,x=p.child,p.tag){case 0:case 11:case 14:case 15:Dr(4,p,p.return);break;case 1:qn(p,p.return);var w=p.stateNode;if(typeof w.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,w.props=t.memoizedProps,w.state=t.memoizedState,w.componentWillUnmount()}catch(y){ke(r,n,y)}}break;case 5:qn(p,p.return);break;case 22:if(p.memoizedState!==null){Rc(m);continue}}x!==null?(x.return=p,Q=x):Rc(m)}f=f.sibling}e:for(f=null,m=e;;){if(m.tag===5){if(f===null){f=m;try{s=m.stateNode,d?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=m.stateNode,c=m.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=Eu("display",i))}catch(y){ke(e,e.return,y)}}}else if(m.tag===6){if(f===null)try{m.stateNode.nodeValue=d?"":m.memoizedProps}catch(y){ke(e,e.return,y)}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===e)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===e)break e;for(;m.sibling===null;){if(m.return===null||m.return===e)break e;f===m&&(f=null),m=m.return}f===m&&(f=null),m.sibling.return=m.return,m=m.sibling}}break;case 19:Nt(t,e),At(e),r&4&&zc(e);break;case 21:break;default:Nt(t,e),At(e)}}function At(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(O(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Gr(s,""),r.flags&=-33);var o=Tc(e);fi(e,o,s);break;case 3:case 4:var i=r.stateNode.containerInfo,l=Tc(e);di(e,l,i);break;default:throw Error(O(161))}}catch(c){ke(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function mh(e,t,n){Q=e,nf(e)}function nf(e,t,n){for(var r=(e.mode&1)!==0;Q!==null;){var s=Q,o=s.child;if(s.tag===22&&r){var i=s.memoizedState!==null||Is;if(!i){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Ge;l=Is;var d=Ge;if(Is=i,(Ge=c)&&!d)for(Q=s;Q!==null;)i=Q,c=i.child,i.tag===22&&i.memoizedState!==null?Pc(s):c!==null?(c.return=i,Q=c):Pc(s);for(;o!==null;)Q=o,nf(o),o=o.sibling;Q=s,Is=l,Ge=d}Ic(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Q=o):Ic(e)}}function Ic(e){for(;Q!==null;){var t=Q;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ge||$a(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:Et(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&mc(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}mc(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 m=f.dehydrated;m!==null&&Jr(m)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(O(163))}Ge||t.flags&512&&ui(t)}catch(p){ke(t,t.return,p)}}if(t===e){Q=null;break}if(n=t.sibling,n!==null){n.return=t.return,Q=n;break}Q=t.return}}function Rc(e){for(;Q!==null;){var t=Q;if(t===e){Q=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Q=n;break}Q=t.return}}function Pc(e){for(;Q!==null;){var t=Q;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{$a(4,t)}catch(c){ke(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){ke(t,s,c)}}var o=t.return;try{ui(t)}catch(c){ke(t,o,c)}break;case 5:var i=t.return;try{ui(t)}catch(c){ke(t,i,c)}}}catch(c){ke(t,t.return,c)}if(t===e){Q=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Q=l;break}Q=t.return}}var hh=Math.ceil,ya=Zt.ReactCurrentDispatcher,ll=Zt.ReactCurrentOwner,yt=Zt.ReactCurrentBatchConfig,ie=0,$e=null,Ce=null,Oe=0,ot=0,Zn=Sn(0),Ee=0,is=null,Mn=0,La=0,cl=0,Ur=null,tt=null,ul=0,fr=1/0,Wt=null,xa=!1,pi=null,hn=null,Rs=!1,cn=null,wa=0,Wr=0,mi=null,Ks=-1,Ys=0;function Xe(){return ie&6?be():Ks!==-1?Ks:Ks=be()}function gn(e){return e.mode&1?ie&2&&Oe!==0?Oe&-Oe:qm.transition!==null?(Ys===0&&(Ys=Bu()),Ys):(e=de,e!==0||(e=window.event,e=e===void 0?16:Ku(e.type)),e):1}function Rt(e,t,n,r){if(50<Wr)throw Wr=0,mi=null,Error(O(185));us(e,n,r),(!(ie&2)||e!==$e)&&(e===$e&&(!(ie&2)&&(La|=n),Ee===4&&on(e,Oe)),at(e,r),n===1&&ie===0&&!(t.mode&1)&&(fr=be()+500,Pa&&jn()))}function at(e,t){var n=e.callbackNode;qp(e,t);var r=ra(e,e===$e?Oe:0);if(r===0)n!==null&&Dl(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Dl(n),t===1)e.tag===0?Xm(_c.bind(null,e)):fd(_c.bind(null,e)),Km(function(){!(ie&6)&&jn()}),n=null;else{switch(Du(r)){case 1:n=Li;break;case 4:n=Fu;break;case 16:n=na;break;case 536870912:n=Ou;break;default:n=na}n=df(n,rf.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function rf(e,t){if(Ks=-1,Ys=0,ie&6)throw Error(O(327));var n=e.callbackNode;if(ar()&&e.callbackNode!==n)return null;var r=ra(e,e===$e?Oe:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Sa(e,r);else{t=r;var s=ie;ie|=2;var o=af();($e!==e||Oe!==t)&&(Wt=null,fr=be()+500,Pn(e,t));do try{yh();break}catch(l){sf(e,l)}while(!0);Qi(),ya.current=o,ie=s,Ce!==null?t=0:($e=null,Oe=0,t=Ee)}if(t!==0){if(t===2&&(s=Do(e),s!==0&&(r=s,t=hi(e,s))),t===1)throw n=is,Pn(e,0),on(e,r),at(e,be()),n;if(t===6)on(e,r);else{if(s=e.current.alternate,!(r&30)&&!gh(s)&&(t=Sa(e,r),t===2&&(o=Do(e),o!==0&&(r=o,t=hi(e,o))),t===1))throw n=is,Pn(e,0),on(e,r),at(e,be()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(O(345));case 2:Nn(e,tt,Wt);break;case 3:if(on(e,r),(r&130023424)===r&&(t=ul+500-be(),10<t)){if(ra(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Xe(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Qo(Nn.bind(null,e,tt,Wt),t);break}Nn(e,tt,Wt);break;case 4:if(on(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var i=31-It(r);o=1<<i,i=t[i],i>s&&(s=i),r&=~o}if(r=s,r=be()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*hh(r/1960))-r,10<r){e.timeoutHandle=Qo(Nn.bind(null,e,tt,Wt),r);break}Nn(e,tt,Wt);break;case 5:Nn(e,tt,Wt);break;default:throw Error(O(329))}}}return at(e,be()),e.callbackNode===n?rf.bind(null,e):null}function hi(e,t){var n=Ur;return e.current.memoizedState.isDehydrated&&(Pn(e,t).flags|=256),e=Sa(e,t),e!==2&&(t=tt,tt=n,t!==null&&gi(t)),e}function gi(e){tt===null?tt=e:tt.push.apply(tt,e)}function gh(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(!Pt(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 on(e,t){for(t&=~cl,t&=~La,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-It(t),r=1<<n;e[n]=-1,t&=~r}}function _c(e){if(ie&6)throw Error(O(327));ar();var t=ra(e,0);if(!(t&1))return at(e,be()),null;var n=Sa(e,t);if(e.tag!==0&&n===2){var r=Do(e);r!==0&&(t=r,n=hi(e,r))}if(n===1)throw n=is,Pn(e,0),on(e,t),at(e,be()),n;if(n===6)throw Error(O(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Nn(e,tt,Wt),at(e,be()),null}function dl(e,t){var n=ie;ie|=1;try{return e(t)}finally{ie=n,ie===0&&(fr=be()+500,Pa&&jn())}}function Fn(e){cn!==null&&cn.tag===0&&!(ie&6)&&ar();var t=ie;ie|=1;var n=yt.transition,r=de;try{if(yt.transition=null,de=1,e)return e()}finally{de=r,yt.transition=n,ie=t,!(ie&6)&&jn()}}function fl(){ot=Zn.current,ge(Zn)}function Pn(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Gm(n)),Ce!==null)for(n=Ce.return;n!==null;){var r=n;switch(Gi(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&la();break;case 3:ur(),ge(rt),ge(Ke),tl();break;case 5:el(r);break;case 4:ur();break;case 13:ge(xe);break;case 19:ge(xe);break;case 10:Ji(r.type._context);break;case 22:case 23:fl()}n=n.return}if($e=e,Ce=e=vn(e.current,null),Oe=ot=t,Ee=0,is=null,cl=La=Mn=0,tt=Ur=null,zn!==null){for(t=0;t<zn.length;t++)if(n=zn[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}zn=null}return e}function sf(e,t){do{var n=Ce;try{if(Qi(),Hs.current=va,ga){for(var r=we.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}ga=!1}if(Ln=0,Ae=Ne=we=null,Br=!1,ss=0,ll.current=null,n===null||n.return===null){Ee=1,is=t,Ce=null;break}e:{var o=e,i=n.return,l=n,c=t;if(t=Oe,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,f=l,m=f.tag;if(!(f.mode&1)&&(m===0||m===11||m===15)){var p=f.alternate;p?(f.updateQueue=p.updateQueue,f.memoizedState=p.memoizedState,f.lanes=p.lanes):(f.updateQueue=null,f.memoizedState=null)}var x=wc(i);if(x!==null){x.flags&=-257,Sc(x,i,l,o,t),x.mode&1&&xc(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)){xc(o,d,t),pl();break e}c=Error(O(426))}}else if(ve&&l.mode&1){var j=wc(i);if(j!==null){!(j.flags&65536)&&(j.flags|=256),Sc(j,i,l,o,t),Ki(dr(c,l));break e}}o=c=dr(c,l),Ee!==4&&(Ee=2),Ur===null?Ur=[o]:Ur.push(o),o=i;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var h=Dd(o,c,t);pc(o,h);break e;case 1:l=c;var g=o.type,v=o.stateNode;if(!(o.flags&128)&&(typeof g.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(hn===null||!hn.has(v)))){o.flags|=65536,t&=-t,o.lanes|=t;var S=Ud(o,l,t);pc(o,S);break e}}o=o.return}while(o!==null)}lf(n)}catch(b){t=b,Ce===n&&n!==null&&(Ce=n=n.return);continue}break}while(!0)}function af(){var e=ya.current;return ya.current=va,e===null?va:e}function pl(){(Ee===0||Ee===3||Ee===2)&&(Ee=4),$e===null||!(Mn&268435455)&&!(La&268435455)||on($e,Oe)}function Sa(e,t){var n=ie;ie|=2;var r=af();($e!==e||Oe!==t)&&(Wt=null,Pn(e,t));do try{vh();break}catch(s){sf(e,s)}while(!0);if(Qi(),ie=n,ya.current=r,Ce!==null)throw Error(O(261));return $e=null,Oe=0,Ee}function vh(){for(;Ce!==null;)of(Ce)}function yh(){for(;Ce!==null&&!Wp();)of(Ce)}function of(e){var t=uf(e.alternate,e,ot);e.memoizedProps=e.pendingProps,t===null?lf(e):Ce=t,ll.current=null}function lf(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=dh(n,t),n!==null){n.flags&=32767,Ce=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Ee=6,Ce=null;return}}else if(n=uh(n,t,ot),n!==null){Ce=n;return}if(t=t.sibling,t!==null){Ce=t;return}Ce=t=e}while(t!==null);Ee===0&&(Ee=5)}function Nn(e,t,n){var r=de,s=yt.transition;try{yt.transition=null,de=1,xh(e,t,n,r)}finally{yt.transition=s,de=r}return null}function xh(e,t,n,r){do ar();while(cn!==null);if(ie&6)throw Error(O(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(O(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(Zp(e,o),e===$e&&(Ce=$e=null,Oe=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Rs||(Rs=!0,df(na,function(){return ar(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=yt.transition,yt.transition=null;var i=de;de=1;var l=ie;ie|=4,ll.current=null,ph(e,n),tf(n,e),Om(Ko),sa=!!Go,Ko=Go=null,e.current=n,mh(n),Hp(),ie=l,de=i,yt.transition=o}else e.current=n;if(Rs&&(Rs=!1,cn=e,wa=s),o=e.pendingLanes,o===0&&(hn=null),Kp(n.stateNode),at(e,be()),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(xa)throw xa=!1,e=pi,pi=null,e;return wa&1&&e.tag!==0&&ar(),o=e.pendingLanes,o&1?e===mi?Wr++:(Wr=0,mi=e):Wr=0,jn(),null}function ar(){if(cn!==null){var e=Du(wa),t=yt.transition,n=de;try{if(yt.transition=null,de=16>e?16:e,cn===null)var r=!1;else{if(e=cn,cn=null,wa=0,ie&6)throw Error(O(331));var s=ie;for(ie|=4,Q=e.current;Q!==null;){var o=Q,i=o.child;if(Q.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Q=d;Q!==null;){var f=Q;switch(f.tag){case 0:case 11:case 15:Dr(8,f,o)}var m=f.child;if(m!==null)m.return=f,Q=m;else for(;Q!==null;){f=Q;var p=f.sibling,x=f.return;if(qd(f),f===d){Q=null;break}if(p!==null){p.return=x,Q=p;break}Q=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)}}Q=o}}if(o.subtreeFlags&2064&&i!==null)i.return=o,Q=i;else e:for(;Q!==null;){if(o=Q,o.flags&2048)switch(o.tag){case 0:case 11:case 15:Dr(9,o,o.return)}var h=o.sibling;if(h!==null){h.return=o.return,Q=h;break e}Q=o.return}}var g=e.current;for(Q=g;Q!==null;){i=Q;var v=i.child;if(i.subtreeFlags&2064&&v!==null)v.return=i,Q=v;else e:for(i=g;Q!==null;){if(l=Q,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:$a(9,l)}}catch(b){ke(l,l.return,b)}if(l===i){Q=null;break e}var S=l.sibling;if(S!==null){S.return=l.return,Q=S;break e}Q=l.return}}if(ie=s,jn(),Ot&&typeof Ot.onPostCommitFiberRoot=="function")try{Ot.onPostCommitFiberRoot(Ea,e)}catch{}r=!0}return r}finally{de=n,yt.transition=t}}return!1}function Ac(e,t,n){t=dr(n,t),t=Dd(e,t,1),e=mn(e,t,1),t=Xe(),e!==null&&(us(e,1,t),at(e,t))}function ke(e,t,n){if(e.tag===3)Ac(e,e,n);else for(;t!==null;){if(t.tag===3){Ac(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(hn===null||!hn.has(r))){e=dr(n,e),e=Ud(t,e,1),t=mn(t,e,1),e=Xe(),t!==null&&(us(t,1,e),at(t,e));break}}t=t.return}}function wh(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Xe(),e.pingedLanes|=e.suspendedLanes&n,$e===e&&(Oe&n)===n&&(Ee===4||Ee===3&&(Oe&130023424)===Oe&&500>be()-ul?Pn(e,0):cl|=n),at(e,t)}function cf(e,t){t===0&&(e.mode&1?(t=Ss,Ss<<=1,!(Ss&130023424)&&(Ss=4194304)):t=1);var n=Xe();e=Jt(e,t),e!==null&&(us(e,t,n),at(e,n))}function Sh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),cf(e,n)}function jh(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(O(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,ch(e,t,n);nt=!!(e.flags&131072)}else nt=!1,ve&&t.flags&1048576&&pd(t,da,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Gs(e,t),e=t.pendingProps;var s=ir(t,Ke.current);sr(t,n),s=rl(null,t,r,e,s,n);var o=sl();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,ca(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,qi(t),s.updater=Aa,t.stateNode=s,s._reactInternals=t,ni(t,r,e,n),t=ai(null,t,r,!0,o,n)):(t.tag=0,ve&&o&&Vi(t),Qe(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Gs(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=bh(r),e=Et(r,e),s){case 0:t=si(null,t,r,e,n);break e;case 1:t=bc(null,t,r,e,n);break e;case 11:t=jc(null,t,r,e,n);break e;case 14:t=kc(null,t,r,Et(r.type,e),n);break e}throw Error(O(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Et(r,s),si(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Et(r,s),bc(e,t,r,s,n);case 3:e:{if(Gd(t),e===null)throw Error(O(387));r=t.pendingProps,o=t.memoizedState,s=o.element,xd(e,t),ma(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=dr(Error(O(423)),t),t=Cc(e,t,r,n,s);break e}else if(r!==s){s=dr(Error(O(424)),t),t=Cc(e,t,r,n,s);break e}else for(it=pn(t.stateNode.containerInfo.firstChild),lt=t,ve=!0,zt=null,n=vd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(lr(),r===s){t=Xt(e,t,n);break e}Qe(e,t,r,n)}t=t.child}return t;case 5:return wd(t),e===null&&Zo(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,i=s.children,Yo(r,s)?i=null:o!==null&&Yo(r,o)&&(t.flags|=32),Vd(e,t),Qe(e,t,i,n),t.child;case 6:return e===null&&Zo(t),null;case 13:return Kd(e,t,n);case 4:return Zi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=cr(t,null,r,n):Qe(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Et(r,s),jc(e,t,r,s,n);case 7:return Qe(e,t,t.pendingProps,n),t.child;case 8:return Qe(e,t,t.pendingProps.children,n),t.child;case 12:return Qe(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,fe(fa,r._currentValue),r._currentValue=i,o!==null)if(Pt(o.value,i)){if(o.children===s.children&&!rt.current){t=Xt(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=Kt(-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),ei(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(O(341));i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),ei(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}Qe(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,sr(t,n),s=xt(s),r=r(s),t.flags|=1,Qe(e,t,r,n),t.child;case 14:return r=t.type,s=Et(r,t.pendingProps),s=Et(r.type,s),kc(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:Et(r,s),Gs(e,t),t.tag=1,st(r)?(e=!0,ca(t)):e=!1,sr(t,n),Bd(t,r,s),ni(t,r,s,n),ai(null,t,r,!0,e,n);case 19:return Yd(e,t,n);case 22:return Hd(e,t,n)}throw Error(O(156,t.tag))};function df(e,t){return Mu(e,t)}function kh(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 kh(e,t,n,r)}function ml(e){return e=e.prototype,!(!e||!e.isReactComponent)}function bh(e){if(typeof e=="function")return ml(e)?1:0;if(e!=null){if(e=e.$$typeof,e===_i)return 11;if(e===Ai)return 14}return 2}function vn(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 Qs(e,t,n,r,s,o){var i=2;if(r=e,typeof e=="function")ml(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Wn:return _n(n.children,s,o,t);case Pi:i=8,s|=8;break;case No:return e=vt(12,n,t,s|2),e.elementType=No,e.lanes=o,e;case Eo:return e=vt(13,n,t,s),e.elementType=Eo,e.lanes=o,e;case To:return e=vt(19,n,t,s),e.elementType=To,e.lanes=o,e;case wu:return Ma(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 _i:i=11;break e;case Ai:i=14;break e;case nn:i=16,r=null;break e}throw Error(O(130,e==null?e:typeof e,""))}return t=vt(i,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function _n(e,t,n,r){return e=vt(7,e,r,t),e.lanes=n,e}function Ma(e,t,n,r){return e=vt(22,e,r,t),e.elementType=wu,e.lanes=n,e.stateNode={isHidden:!1},e}function go(e,t,n){return e=vt(6,e,null,t),e.lanes=n,e}function vo(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 Ch(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=Ja(0),this.expirationTimes=Ja(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ja(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function hl(e,t,n,r,s,o,i,l,c){return e=new Ch(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},qi(o),e}function Nh(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Un,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function ff(e){if(!e)return xn;e=e._reactInternals;e:{if(Bn(e)!==e||e.tag!==1)throw Error(O(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(O(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=hl(n,r,!0,e,s,o,i,l,c),e.context=ff(null),n=e.current,r=Xe(),s=gn(n),o=Kt(r,s),o.callback=t??null,mn(n,o,s),e.current.lanes=s,us(e,s,r),at(e,r),e}function Fa(e,t,n,r){var s=t.current,o=Xe(),i=gn(s);return n=ff(n),t.context===null?t.context=n:t.pendingContext=n,t=Kt(o,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=mn(s,t,i),e!==null&&(Rt(e,s,i,o),Ws(e,s,i)),i}function ja(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 $c(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function gl(e,t){$c(e,t),(e=e.alternate)&&$c(e,t)}function Eh(){return null}var mf=typeof reportError=="function"?reportError:function(e){console.error(e)};function vl(e){this._internalRoot=e}Oa.prototype.render=vl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(O(409));Fa(e,t,null,null)};Oa.prototype.unmount=vl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Fn(function(){Fa(null,e,null,null)}),t[Qt]=null}};function Oa(e){this._internalRoot=e}Oa.prototype.unstable_scheduleHydration=function(e){if(e){var t=Hu();e={blockedOn:null,target:e,priority:t};for(var n=0;n<an.length&&t!==0&&t<an[n].priority;n++);an.splice(n,0,e),n===0&&Gu(e)}};function yl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Ba(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Lc(){}function Th(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var d=ja(i);o.call(d)}}var i=pf(t,r,e,0,null,!1,!1,"",Lc);return e._reactRootContainer=i,e[Qt]=i.current,Zr(e.nodeType===8?e.parentNode:e),Fn(),i}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=ja(c);l.call(d)}}var c=hl(e,0,!1,null,null,!1,!1,"",Lc);return e._reactRootContainer=c,e[Qt]=c.current,Zr(e.nodeType===8?e.parentNode:e),Fn(function(){Fa(t,c,n,r)}),c}function Da(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=ja(i);l.call(c)}}Fa(t,i,e,s)}else i=Th(n,t,e,s,r);return ja(i)}Uu=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Pr(t.pendingLanes);n!==0&&(Mi(t,n|1),at(t,be()),!(ie&6)&&(fr=be()+500,jn()))}break;case 13:Fn(function(){var r=Jt(e,1);if(r!==null){var s=Xe();Rt(r,e,1,s)}}),gl(e,1)}};Fi=function(e){if(e.tag===13){var t=Jt(e,134217728);if(t!==null){var n=Xe();Rt(t,e,134217728,n)}gl(e,134217728)}};Wu=function(e){if(e.tag===13){var t=gn(e),n=Jt(e,t);if(n!==null){var r=Xe();Rt(n,e,t,r)}gl(e,t)}};Hu=function(){return de};Vu=function(e,t){var n=de;try{return de=e,t()}finally{de=n}};Fo=function(e,t,n){switch(t){case"input":if(Ro(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=Ra(r);if(!s)throw Error(O(90));ju(r),Ro(r,s)}}}break;case"textarea":bu(e,n);break;case"select":t=n.value,t!=null&&er(e,!!n.multiple,t,!1)}};Ru=dl;Pu=Fn;var zh={usingClientEntryPoint:!1,Events:[fs,Kn,Ra,zu,Iu,dl]},Er={findFiberByHostInstance:Tn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Ih={bundleType:Er.bundleType,version:Er.version,rendererPackageName:Er.rendererPackageName,rendererConfig:Er.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Zt.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=$u(e),e===null?null:e.stateNode},findFiberByHostInstance:Er.findFiberByHostInstance||Eh,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 Ps=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ps.isDisabled&&Ps.supportsFiber)try{Ea=Ps.inject(Ih),Ot=Ps}catch{}}ut.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zh;ut.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!yl(t))throw Error(O(200));return Nh(e,t,null,n)};ut.createRoot=function(e,t){if(!yl(e))throw Error(O(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=hl(e,1,!1,null,null,n,!1,r,s),e[Qt]=t.current,Zr(e.nodeType===8?e.parentNode:e),new vl(t)};ut.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(O(188)):(e=Object.keys(e).join(","),Error(O(268,e)));return e=$u(t),e=e===null?null:e.stateNode,e};ut.flushSync=function(e){return Fn(e)};ut.hydrate=function(e,t,n){if(!Ba(t))throw Error(O(200));return Da(null,e,t,!0,n)};ut.hydrateRoot=function(e,t,n){if(!yl(e))throw Error(O(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[Qt]=t.current,Zr(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 Oa(t)};ut.render=function(e,t,n){if(!Ba(t))throw Error(O(200));return Da(null,e,t,!1,n)};ut.unmountComponentAtNode=function(e){if(!Ba(e))throw Error(O(40));return e._reactRootContainer?(Fn(function(){Da(null,null,e,!1,function(){e._reactRootContainer=null,e[Qt]=null})}),!0):!1};ut.unstable_batchedUpdates=dl;ut.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Ba(n))throw Error(O(200));if(e==null||e._reactInternals===void 0)throw Error(O(38));return Da(e,t,n,!1,r)};ut.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=ut;var gf=mu.exports,vf,Mc=gf;vf=Mc.createRoot,Mc.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 Fc="popstate";function Oc(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Rh(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 vi("",{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:ls(s)}return _h(t,n,null,e)}function ye(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 Ph(){return Math.random().toString(36).substring(2,10)}function Bc(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 vi(e,t,n=null,r,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?gr(t):t,state:n,key:t&&t.key||r||Ph(),unstable_mask:s}}function ls({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 gr(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 _h(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 m(){l="POP";let j=f(),h=j==null?null:j-d;d=j,c&&c({action:l,location:y.location,delta:h})}function p(j,h){l="PUSH";let g=Oc(j)?j:vi(y.location,j,h);d=f()+1;let v=Bc(g,d),S=y.createHref(g.unstable_mask||g);try{i.pushState(v,"",S)}catch(b){if(b instanceof DOMException&&b.name==="DataCloneError")throw b;s.location.assign(S)}o&&c&&c({action:l,location:y.location,delta:1})}function x(j,h){l="REPLACE";let g=Oc(j)?j:vi(y.location,j,h);d=f();let v=Bc(g,d),S=y.createHref(g.unstable_mask||g);i.replaceState(v,"",S),o&&c&&c({action:l,location:y.location,delta:0})}function w(j){return Ah(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(Fc,m),c=j,()=>{s.removeEventListener(Fc,m),c=null}},createHref(j){return t(s,j)},createURL:w,encodeLocation(j){let h=w(j);return{pathname:h.pathname,search:h.search,hash:h.hash}},push:p,replace:x,go(j){return i.go(j)}};return y}function Ah(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ye(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:ls(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function yf(e,t,n="/"){return $h(e,t,n,!1)}function $h(e,t,n,r){let s=typeof t=="string"?gr(t):t,o=qt(s.pathname||"/",n);if(o==null)return null;let i=xf(e);Lh(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let d=Kh(o);l=Vh(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;ye(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 m=Dt([r,f.relativePath]),p=n.concat(f);i.children&&i.children.length>0&&(ye(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),xf(i.children,t,p,m,c)),!(i.path==null&&!i.index)&&t.push({path:m,score:Wh(m,i.index),routesMeta:p})};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 Lh(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Hh(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Mh=/^:[\w-]+$/,Fh=3,Oh=2,Bh=1,Dh=10,Uh=-2,Dc=e=>e==="*";function Wh(e,t){let n=e.split("/"),r=n.length;return n.some(Dc)&&(r+=Uh),t&&(r+=Oh),n.filter(s=>!Dc(s)).reduce((s,o)=>s+(Mh.test(o)?Fh:o===""?Bh:Dh),r)}function Hh(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 Vh(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)||"/",m=ka({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),p=c.route;if(!m&&d&&n&&!r[r.length-1].route.index&&(m=ka({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!m)return null;Object.assign(s,m.params),i.push({params:s,pathname:Dt([o,m.pathname]),pathnameBase:Xh(Dt([o,m.pathnameBase])),route:p}),m.pathnameBase!=="/"&&(o=Dt([o,m.pathnameBase]))}return i}function ka(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Gh(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:m},p)=>{if(f==="*"){let w=l[p]||"";i=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const x=l[p];return m&&!x?d[f]=void 0:d[f]=(x||"").replace(/%2F/g,"/"),d},{}),pathname:o,pathnameBase:i,pattern:e}}function Gh(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 m=f.charAt(d+i.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}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 Kh(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 qt(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 Yh=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Qh(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?gr(e):e,o;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?o=Uc(n.substring(1),"/"):o=Uc(n,t)):o=t,{pathname:o,search:qh(r),hash:Zh(s)}}function Uc(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 yo(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 Jh(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function xl(e){let t=Jh(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Ua(e,t,n,r=!1){let s;typeof e=="string"?s=gr(e):(s={...e},ye(!s.pathname||!s.pathname.includes("?"),yo("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),yo("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),yo("#","search","hash",s)));let o=e===""||s.pathname==="",i=o?"/":s.pathname,l;if(i==null)l=n;else{let m=t.length-1;if(!r&&i.startsWith("..")){let p=i.split("/");for(;p[0]==="..";)p.shift(),m-=1;s.pathname=p.join("/")}l=m>=0?t[m]:"/"}let c=Qh(s,l),d=i&&i!=="/"&&i.endsWith("/"),f=(o||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Dt=e=>e.join("/").replace(/\/\/+/g,"/"),Xh=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),qh=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Zh=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,eg=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 tg(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function ng(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"||!Yh.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=qt(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 rg=["GET",...kf];new Set(rg);var vr=u.createContext(null);vr.displayName="DataRouter";var Wa=u.createContext(null);Wa.displayName="DataRouterState";var sg=u.createContext(!1),bf=u.createContext({isTransitioning:!1});bf.displayName="ViewTransition";var ag=u.createContext(new Map);ag.displayName="Fetchers";var og=u.createContext(null);og.displayName="Await";var ft=u.createContext(null);ft.displayName="Navigation";var ms=u.createContext(null);ms.displayName="Location";var _t=u.createContext({outlet:null,matches:[],isDataRoute:!1});_t.displayName="Route";var wl=u.createContext(null);wl.displayName="RouteError";var Cf="REACT_ROUTER_ERROR",ig="REDIRECT",lg="ROUTE_ERROR_RESPONSE";function cg(e){if(e.startsWith(`${Cf}:${ig}:{`))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 ug(e){if(e.startsWith(`${Cf}:${lg}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new eg(t.status,t.statusText,t.data)}catch{}}function dg(e,{relative:t}={}){ye(yr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=u.useContext(ft),{hash:s,pathname:o,search:i}=hs(e,{relative:t}),l=o;return n!=="/"&&(l=o==="/"?n:Dt([n,o])),r.createHref({pathname:l,search:i,hash:s})}function yr(){return u.useContext(ms)!=null}function jt(){return ye(yr(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(ms).location}var Nf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ef(e){u.useContext(ft).static||u.useLayoutEffect(e)}function en(){let{isDataRoute:e}=u.useContext(_t);return e?Ng():fg()}function fg(){ye(yr(),"useNavigate() may be used only in the context of a <Router> component.");let e=u.useContext(vr),{basename:t,navigator:n}=u.useContext(ft),{matches:r}=u.useContext(_t),{pathname:s}=jt(),o=JSON.stringify(xl(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=Ua(c,JSON.parse(o),s,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Dt([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,o,s,e])}var pg=u.createContext(null);function mg(e){let t=u.useContext(_t).outlet;return u.useMemo(()=>t&&u.createElement(pg.Provider,{value:e},t),[t,e])}function hs(e,{relative:t}={}){let{matches:n}=u.useContext(_t),{pathname:r}=jt(),s=JSON.stringify(xl(n));return u.useMemo(()=>Ua(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function hg(e,t){return Tf(e,t)}function Tf(e,t,n){var j;ye(yr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=u.useContext(ft),{matches:s}=u.useContext(_t),o=s[s.length-1],i=o?o.params:{},l=o?o.pathname:"/",c=o?o.pathnameBase:"/",d=o&&o.route;{let h=d&&d.path||"";If(l,!d||h.endsWith("*")||h.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${h}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
50
|
+
|
|
51
|
+
Please change the parent <Route path="${h}"> to <Route path="${h==="/"?"*":`${h}/*`}">.`)}let f=jt(),m;if(t){let h=typeof t=="string"?gr(t):t;ye(c==="/"||((j=h.pathname)==null?void 0:j.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${h.pathname}" was given in the \`location\` prop.`),m=h}else m=f;let p=m.pathname||"/",x=p;if(c!=="/"){let h=c.replace(/^\//,"").split("/");x="/"+p.replace(/^\//,"").split("/").slice(h.length).join("/")}let w=yf(e,{pathname:x});St(d||w!=null,`No routes matched location "${m.pathname}${m.search}${m.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 "${m.pathname}${m.search}${m.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=wg(w&&w.map(h=>Object.assign({},h,{params:Object.assign({},i,h.params),pathname:Dt([c,r.encodeLocation?r.encodeLocation(h.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathname]),pathnameBase:h.pathnameBase==="/"?c:Dt([c,r.encodeLocation?r.encodeLocation(h.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathnameBase])})),s,n);return t&&y?u.createElement(ms.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...m},navigationType:"POP"}},y):y}function gg(){let e=Cg(),t=tg(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 vg=u.createElement(gg,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=ug(e.digest);n&&(e=n)}let t=e!==void 0?u.createElement(_t.Provider,{value:this.props.routeContext},u.createElement(wl.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?u.createElement(yg,{error:e},t):t}};zf.contextType=sg;var xo=new WeakMap;function yg({children:e,error:t}){let{basename:n}=u.useContext(ft);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=cg(t.digest);if(r){let s=xo.get(t);if(s)throw s;let o=jf(r.location,n);if(Sf&&!xo.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 xo.set(t,i),i}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return e}function xg({routeContext:e,match:t,children:n}){let r=u.useContext(vr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),u.createElement(_t.Provider,{value:e},n)}function wg(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(m=>m.route.id&&(o==null?void 0:o[m.route.id])!==void 0);ye(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 m=s[f];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=f),m.route.id){let{loaderData:p,errors:x}=r,w=m.route.loader&&!p.hasOwnProperty(m.route.id)&&(!x||x[m.route.id]===void 0);if(m.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,m)=>{var p,x;c(f,{location:r.location,params:((x=(p=r.matches)==null?void 0:p[0])==null?void 0:x.params)??{},unstable_pattern:ng(r.matches),errorInfo:m})}:void 0;return s.reduceRight((f,m,p)=>{let x,w=!1,y=null,j=null;r&&(x=o&&m.route.id?o[m.route.id]:void 0,y=m.route.errorElement||vg,i&&(l<0&&p===0?(If("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),w=!0,j=null):l===p&&(w=!0,j=m.route.hydrateFallbackElement||null)));let h=t.concat(s.slice(0,p+1)),g=()=>{let v;return x?v=y:w?v=j:m.route.Component?v=u.createElement(m.route.Component,null):m.route.element?v=m.route.element:v=f,u.createElement(xg,{match:m,routeContext:{outlet:f,matches:h,isDataRoute:r!=null},children:v})};return r&&(m.route.ErrorBoundary||m.route.errorElement||p===0)?u.createElement(zf,{location:r.location,revalidation:r.revalidation,component:y,error:x,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:d}):g()},null)}function Sl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Sg(e){let t=u.useContext(vr);return ye(t,Sl(e)),t}function jg(e){let t=u.useContext(Wa);return ye(t,Sl(e)),t}function kg(e){let t=u.useContext(_t);return ye(t,Sl(e)),t}function jl(e){let t=kg(e),n=t.matches[t.matches.length-1];return ye(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function bg(){return jl("useRouteId")}function Cg(){var r;let e=u.useContext(wl),t=jg("useRouteError"),n=jl("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function Ng(){let{router:e}=Sg("useNavigate"),t=jl("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 Wc={};function If(e,t,n){!t&&!Wc[e]&&(Wc[e]=!0,St(!1,n))}u.memo(Eg);function Eg({routes:e,future:t,state:n,isStatic:r,onError:s}){return Tf(e,void 0,{state:n,isStatic:r,onError:s})}function sn({to:e,replace:t,state:n,relative:r}){ye(yr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=u.useContext(ft);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(_t),{pathname:i}=jt(),l=en(),c=Ua(e,xl(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 Tg(e){return mg(e.context)}function _e(e){ye(!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 zg({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:o=!1,unstable_useTransitions:i}){ye(!yr(),"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=gr(n));let{pathname:d="/",search:f="",hash:m="",state:p=null,key:x="default",unstable_mask:w}=n,y=u.useMemo(()=>{let j=qt(d,l);return j==null?null:{location:{pathname:j,search:f,hash:m,state:p,key:x,unstable_mask:w},navigationType:r}},[l,d,f,m,p,x,r,w]);return St(y!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${m}" because it does not start with the basename, so the <Router> won't render anything.`),y==null?null:u.createElement(ft.Provider,{value:c},u.createElement(ms.Provider,{children:t,value:y}))}function Ig({children:e,location:t}){return hg(yi(e),t)}function yi(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,yi(r.props.children,o));return}ye(r.type===_e,`[${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>`),ye(!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=yi(r.props.children,o)),n.push(i)}),n}var Js="get",Xs="application/x-www-form-urlencoded";function Ha(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Rg(e){return Ha(e)&&e.tagName.toLowerCase()==="button"}function Pg(e){return Ha(e)&&e.tagName.toLowerCase()==="form"}function _g(e){return Ha(e)&&e.tagName.toLowerCase()==="input"}function Ag(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function $g(e,t){return e.button===0&&(!t||t==="_self")&&!Ag(e)}function xi(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 Lg(e,t){let n=xi(e);return t&&t.forEach((r,s)=>{n.has(s)||t.getAll(s).forEach(o=>{n.append(s,o)})}),n}var _s=null;function Mg(){if(_s===null)try{new FormData(document.createElement("form"),0),_s=!1}catch{_s=!0}return _s}var Fg=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function wo(e){return e!=null&&!Fg.has(e)?(St(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Xs}"`),null):e}function Og(e,t){let n,r,s,o,i;if(Pg(e)){let l=e.getAttribute("action");r=l?qt(l,t):null,n=e.getAttribute("method")||Js,s=wo(e.getAttribute("enctype"))||Xs,o=new FormData(e)}else if(Rg(e)||_g(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?qt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Js,s=wo(e.getAttribute("formenctype"))||wo(l.getAttribute("enctype"))||Xs,o=new FormData(l,e),!Mg()){let{name:d,type:f,value:m}=e;if(f==="image"){let p=d?`${d}.`:"";o.append(`${p}x`,"0"),o.append(`${p}y`,"0")}else d&&o.append(d,m)}}else{if(Ha(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Js,r=null,s=Xs,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 kl(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Bg(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&&qt(s.pathname,t)==="/"?s.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${r}`,s}async function Dg(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 Ug(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 Wg(e,t,n){let r=await Promise.all(e.map(async s=>{let o=t.routes[s.route.id];if(o){let i=await Dg(o,n);return i.links?i.links():[]}return[]}));return Kg(r.flat(1).filter(Ug).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function Hc(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 m;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 p=c.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:((m=n[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function Hg(e,t,{includeHydrateFallback:n}={}){return Vg(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 Vg(e){return[...new Set(e)]}function Gg(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Kg(e,t){let n=new Set;return new Set(t),e.reduce((r,s)=>{let o=JSON.stringify(Gg(s));return n.has(o)||(n.add(o),r.push({key:o,link:s})),r},[])}function Rf(){let e=u.useContext(vr);return kl(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Yg(){let e=u.useContext(Wa);return kl(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var bl=u.createContext(void 0);bl.displayName="FrameworkContext";function Pf(){let e=u.useContext(bl);return kl(e,"You must render this element inside a <HydratedRouter> element"),e}function Qg(e,t){let n=u.useContext(bl),[r,s]=u.useState(!1),[o,i]=u.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:m}=t,p=u.useRef(null);u.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let y=h=>{h.forEach(g=>{i(g.isIntersecting)})},j=new IntersectionObserver(y,{threshold:.5});return p.current&&j.observe(p.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,p,{}]:[o,p,{onFocus:Tr(l,x),onBlur:Tr(c,w),onMouseEnter:Tr(d,x),onMouseLeave:Tr(f,w),onTouchStart:Tr(m,x)}]:[!1,p,{}]}function Tr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Jg({page:e,...t}){let{router:n}=Rf(),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 Xg(e){let{manifest:t,routeModules:n}=Pf(),[r,s]=u.useState([]);return u.useEffect(()=>{let o=!1;return Wg(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}=Pf(),{basename:l}=Rf(),{loaderData:c,matches:d}=Yg(),f=u.useMemo(()=>Hc(e,t,d,o,r,"data"),[e,t,d,o,r]),m=u.useMemo(()=>Hc(e,t,d,o,r,"assets"),[e,t,d,o,r]),p=u.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let y=new Set,j=!1;if(t.forEach(g=>{var S;let v=o.routes[g.route.id];!v||!v.hasLoader||(!f.some(b=>b.route.id===g.route.id)&&g.route.id in c&&((S=i[g.route.id])!=null&&S.shouldRevalidate)||v.hasClientLoader?j=!0:y.add(g.route.id))}),y.size===0)return[];let h=Bg(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return j&&y.size>0&&h.searchParams.set("_routes",t.filter(g=>y.has(g.route.id)).map(g=>g.route.id).join(",")),[h.pathname+h.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,r,o,f,t,e,i]),x=u.useMemo(()=>Hg(m,o),[m,o]),w=Xg(m);return u.createElement(u.Fragment,null,p.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 Zg(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var ev=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{ev&&(window.__reactRouterVersion="7.13.1")}catch{}function tv({basename:e,children:t,unstable_useTransitions:n,window:r}){let s=u.useRef();s.current==null&&(s.current=Rh({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(zg,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o,unstable_useTransitions:n})}var _f=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Je=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:m,viewTransition:p,unstable_defaultShouldRevalidate:x,...w},y){let{basename:j,navigator:h,unstable_useTransitions:g}=u.useContext(ft),v=typeof f=="string"&&_f.test(f),S=jf(f,j);f=S.to;let b=dg(f,{relative:s}),I=jt(),R=null;if(l){let T=Ua(l,[],I.unstable_mask?I.unstable_mask.pathname:"/",!0);j!=="/"&&(T.pathname=T.pathname==="/"?j:Dt([j,T.pathname])),R=h.createHref(T)}let[P,C,z]=Qg(r,w),B=sv(f,{replace:i,unstable_mask:l,state:c,target:d,preventScrollReset:m,relative:s,viewTransition:p,unstable_defaultShouldRevalidate:x,unstable_useTransitions:g});function K(T){t&&t(T),T.defaultPrevented||B(T)}let Y=!(S.isExternal||o),W=u.createElement("a",{...w,...z,href:(Y?R:void 0)||S.absoluteURL||b,onClick:Y?K:t,ref:Zg(y,C),target:d,"data-discover":!v&&n==="render"?"true":void 0});return P&&!v?u.createElement(u.Fragment,null,W,u.createElement(Jg,{page:b})):W});Je.displayName="Link";var Cl=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 m=hs(i,{relative:d.relative}),p=jt(),x=u.useContext(Wa),{navigator:w,basename:y}=u.useContext(ft),j=x!=null&&cv(m)&&l===!0,h=w.encodeLocation?w.encodeLocation(m).pathname:m.pathname,g=p.pathname,v=x&&x.navigation&&x.navigation.location?x.navigation.location.pathname:null;n||(g=g.toLowerCase(),v=v?v.toLowerCase():null,h=h.toLowerCase()),v&&y&&(v=qt(v,y)||v);const S=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let b=g===h||!s&&g.startsWith(h)&&g.charAt(S)==="/",I=v!=null&&(v===h||!s&&v.startsWith(h)&&v.charAt(h.length)==="/"),R={isActive:b,isPending:I,isTransitioning:j},P=b?t:void 0,C;typeof r=="function"?C=r(R):C=[r,b?"active":null,I?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let z=typeof o=="function"?o(R):o;return u.createElement(Je,{...d,"aria-current":P,className:C,ref:f,style:z,to:i,viewTransition:l},typeof c=="function"?c(R):c)});Cl.displayName="NavLink";var nv=u.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:s,state:o,method:i=Js,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:m,unstable_defaultShouldRevalidate:p,...x},w)=>{let{unstable_useTransitions:y}=u.useContext(ft),j=iv(),h=lv(l,{relative:d}),g=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&_f.test(l),S=b=>{if(c&&c(b),b.defaultPrevented)return;b.preventDefault();let I=b.nativeEvent.submitter,R=(I==null?void 0:I.getAttribute("formmethod"))||i,P=()=>j(I||b.currentTarget,{fetcherKey:t,method:R,navigate:n,replace:s,state:o,relative:d,preventScrollReset:f,viewTransition:m,unstable_defaultShouldRevalidate:p});y&&n!==!1?u.startTransition(()=>P()):P()};return u.createElement("form",{ref:w,method:g,action:h,onSubmit:r?c:S,...x,"data-discover":!v&&e==="render"?"true":void 0})});nv.displayName="Form";function rv(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(vr);return ye(t,rv(e)),t}function sv(e,{target:t,replace:n,unstable_mask:r,state:s,preventScrollReset:o,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c,unstable_useTransitions:d}={}){let f=en(),m=jt(),p=hs(e,{relative:i});return u.useCallback(x=>{if($g(x,t)){x.preventDefault();let w=n!==void 0?n:ls(m)===ls(p),y=()=>f(e,{replace:w,unstable_mask:r,state:s,preventScrollReset:o,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c});d?u.startTransition(()=>y()):y()}},[m,f,p,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(xi(e)),n=u.useRef(!1),r=jt(),s=u.useMemo(()=>Lg(r.search,n.current?null:t.current),[r.search]),o=en(),i=u.useCallback((l,c)=>{const d=xi(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,o("?"+d,c)},[o,s]);return[s,i]}var av=0,ov=()=>`__${String(++av)}__`;function iv(){let{router:e}=Af("useSubmit"),{basename:t}=u.useContext(ft),n=bg(),r=e.fetch,s=e.navigate;return u.useCallback(async(o,i={})=>{let{action:l,method:c,encType:d,formData:f,body:m}=Og(o,t);if(i.navigate===!1){let p=i.fetcherKey||ov();await r(p,n,i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:m,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:m,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 lv(e,{relative:t}={}){let{basename:n}=u.useContext(ft),r=u.useContext(_t);ye(r,"useFormAction must be used inside a RouteContext");let[s]=r.matches.slice(-1),o={...hs(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(m=>m).forEach(m=>l.append("index",m));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:Dt([n,o.pathname])),ls(o)}function cv(e,{relative:t}={}){let n=u.useContext(bf);ye(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=hs(e,{relative:t});if(!n.isTransitioning)return!1;let o=qt(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=qt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return ka(s.pathname,i)!=null||ka(s.pathname,o)!=null}class Lf extends Error{constructor(n){super("different_account");xr(this,"summary");this.name="DifferentAccountError",this.summary=n}}class uv{constructor(){xr(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 fetchEvidenceBundle(){var s;const t=await this.fetch("/api/evidence-export"),n=await t.json();if(!t.ok)throw new Error(n.error??`Export failed (${t.status})`);const r=((s=/filename="([^"]+)"/.exec(t.headers.get("content-disposition")??""))==null?void 0:s[1])??"suveren-evidence.json";return{bundle:n,filename:r}}async getLocalAuthorizations(){const t=await this.fetch("/api/evidence/authorizations");if(!t.ok)throw new Error(`Local evidence unavailable (${t.status})`);const n=await t.json();return{authorizations:n.authorizations??{},signatures:n.signatures??{}}}async getArchivedReceipt(t){const n=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(t)}`);if(n.status===404)return null;if(!n.ok)throw new Error(`Local evidence unavailable (${n.status})`);return await n.json()}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 m=new Date(c);m.setUTCDate(c.getUTCDate()-f),l.push(m.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 uv,Mf=u.createContext(null);function dv({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),[m,p]=u.useState(null),[x,w]=u.useState(!1),[y,j]=u.useState(""),h=u.useRef(!1),g=u.useRef(null),v=u.useCallback(async()=>{if(h.current)try{const P=await A.getMyTeam();if(P){const{group:C,membership:z}=P;f(C),p(z),s("team"),i(C);const B=g.current??z.domains[0]??"owner";c(B)}else f(null),p(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,C={})=>{w(!0),j("");try{A.setApiKey(P),h.current=!0;const z=await A.login(P,C);n(z),g.current=z.id;const B=await A.getGroups(),K=B.find(Y=>Y.isPersonal)??B[0]??null;i(K),c("owner"),await v()}catch(z){throw A.clearApiKey(),h.current=!1,j(z instanceof Error?z.message:"Login failed"),z}finally{w(!1)}},[v]),b=u.useCallback(async()=>{await A.logout(),A.clearApiKey(),h.current=!1,g.current=null,n(null),i(null),c(""),f(null),p(null),s("personal"),j("")},[]),I=u.useCallback(()=>j(""),[]),R=u.useCallback((P,C)=>{i(P),c(C)},[]);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:m,isLoading:x,error:y,login:S,logout:b,clearError:I,activeGroup:o,activeDomain:l,groups:o?[o]:[],setActiveContext:R,refreshGroups:v},children:e})}function Le(){const e=u.useContext(Mf);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Ff=u.createContext(null);function fv({children:e}){const{user:t}=Le(),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,m=>{let p;try{p=JSON.parse(m.data)}catch{p=null}const x=o.current.get(f);if(x)for(const w of x)try{w(p)}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 ce(e,t){const n=u.useContext(Ff);if(!n)return;const{addListener:r}=n;u.useEffect(()=>r(e,t),[e,t,r])}const Hr="suveren-theme",Vc="hap-theme";function As(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(Vc);t!==null&&localStorage.getItem(Hr)===null&&localStorage.setItem(Hr,t),t!==null&&localStorage.removeItem(Vc)})();function Of(){const[e,t]=u.useState(()=>{const o=localStorage.getItem(Hr);return o==="light"||o==="dark"?o:"system"}),[n,r]=u.useState(()=>As(e));u.useEffect(()=>{const o=document.documentElement,i=As(e);o.setAttribute("data-theme",i),e==="system"?localStorage.removeItem(Hr):localStorage.setItem(Hr,e),r(As(e))},[e]),u.useEffect(()=>{if(e!=="system")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>r(As("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 pv=5*60*1e3,mv=2e3;function Nl(){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,m]=u.useState(!1),[p,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 h=setInterval(()=>j(!1),p?mv:pv),g=()=>{document.visibilityState==="visible"&&j(!1)};return document.addEventListener("visibilitychange",g),window.addEventListener("focus",g),()=>{y=!0,clearInterval(h),document.removeEventListener("visibilitychange",g),window.removeEventListener("focus",g)}},[p]),{updateAvailable:e&&!f,installMethod:n,version:s,latestVersion:i,serverRestarted:c,startFastPolling:()=>x(!0),dismiss:()=>m(!0)}}function hv({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 gv(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Gc={system:"◑",light:"☀",dark:"☾"};function El({onMenuToggle:e}){const{user:t,logout:n}=Le(),{theme:r,toggle:s}=Of(),{version:o,updateAvailable:i,latestVersion:l}=Nl(),c=gv(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(hv,{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:Gc[r]}),a.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):a.jsx("button",{className:"theme-toggle",onClick:s,title:`Theme: ${r}`,children:Gc[r]})}),t&&e&&a.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function Lt(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[Lt(r,t)].push(r);return n}function vv(e,t){return t==="expired"?e.earliest_expiry?{iso:e.earliest_expiry,meaning:"expired"}:null:e.created_at?{iso:e.created_at,meaning:"created"}:null}function Ft(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),yv=3e4,xv=5e3,wv=3e5;function Sv(e,t,n){return t===0?"loading":e!=null&&e.running?"running":e!=null&&e.error?"error":e&&n?"starting":"not-running"}function jv({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,m]=await Promise.all([A.getIntegrationManifests().catch(()=>(d=!0,{manifests:[]})),A.getMcpHealth().catch(()=>null)]);n(x=>({...x,manifests:f.manifests,integrations:(m==null?void 0:m.integrations)??x.integrations,activeSessions:(m==null?void 0:m.activeSessions)??x.activeSessions,mcpServerUp:!!m,manifestsError:d,fetchCount:x.fetchCount+1}));const p=f.manifests.filter(x=>x.oauth);if(p.length>0){const x=await Promise.all(p.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(m=>m.id===d.id);return f&&!f.running});ce("integration-changed",s),Ft(s,o?xv:wv);const i=u.useMemo(()=>{const d=new Map(t.integrations.map(p=>[p.id,p])),f=Date.now();o&&r.current===null?r.current=f:o||(r.current=null);const m=r.current!==null&&f-r.current<yv;return t.manifests.map(p=>{const x=d.get(p.id),w=Sv(x,t.fetchCount,m),y=t.authHealth[p.id];return{id:p.id,manifest:p,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 Tl(){const e=u.useContext(Df);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const kv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/authorizations",icon:"☰",label:"Mandates",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/audit",icon:"▣",label:"Tickets"},{to:"/groups",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant",statusKey:"assistant"}];function bv(){const{activeDomain:e}=Le(),[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,m=(l==null?void 0:l.length)??0,p=f+m;p>0&&(d.proposals=p),(!c||!c.trim())&&(d.brief=1),n(d)}catch{}},[e]);return ce("attestation-changed",r),ce("proposal-added",r),ce("proposal-resolved",r),ce("proposal-approved",r),ce("proposal-rejected",r),ce("team-membership-changed",r),Ft(r,3e5,e),t}const Cv={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},Nv={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 Ev(){const{mode:e,group:t,domain:n,activeTeam:r}=Le(),s=bv(),{attentionCount:o}=Tl(),i={...s};o>0&&(i.integrations=o);const l=kv.filter(p=>!p.teamOnly||e==="team"),c=u.useRef(null),[d,f]=u.useState(null),m=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)},[m.pathname]),a.jsxs("div",{className:"sidebar",children:[a.jsx("ul",{className:"sidebar-nav",children:l.map(p=>{const x=p.statusKey?i[p.statusKey]:0;return a.jsx("li",{children:a.jsxs(Cl,{to:p.to,end:p.to==="/",className:({isActive:w})=>`sidebar-item${w?" active":""}`,children:[a.jsx("span",{className:"icon",children:p.icon}),p.label,x?a.jsx("span",{style:Cv,children:x}):null]})},p.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:Nv,role:"status","aria-live":"polite",children:d})]})}const So="suveren:updatedTo";function Tv(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 zv(){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}=Nl(),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[m,p]=u.useState(()=>{try{const v=sessionStorage.getItem(So);if(v)return sessionStorage.removeItem(So),v}catch{}return null}),x=Tv(t),w=u.useRef(null),y=v=>{try{sessionStorage.setItem(So,v||r||"✓")}catch{}window.location.reload()};u.useEffect(()=>{if(!m)return;const v=setTimeout(()=>p(null),6e3);return()=>clearTimeout(v)},[m]),u.useEffect(()=>{if(!l||!s)return;const v=()=>zv()?!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&&!m||!!m&&!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 b=((I=w.current)==null?void 0:I.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${b}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 h=()=>{c(!0),o()},g=async()=>{try{await navigator.clipboard.writeText(x),f(!0),setTimeout(()=>f(!1),1800)}catch{}};return a.jsxs(a.Fragment,{children:[m&&!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",m&&m!=="✓"?` — ${m} is live`:" — now live","."]}),a.jsx("button",{className:"update-banner-x",onClick:()=>p(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!m&&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:h,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:g,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 Iv={system:"◑",light:"☀",dark:"☾"},Rv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals"},{to:"/authorizations",icon:"☰",label:"Mandates"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/audit",icon:"▣",label:"Tickets"},{to:"/groups",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant"}];function Pv({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:s,logout:o}=Le(),{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:Rv.map(d=>a.jsxs(Cl,{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:Iv[i]}),"Theme: ",i]}),a.jsx("button",{className:"mobile-menu-action",onClick:()=>{o(),t()},children:"Logout"})]})]})]}):null}function Wf(e){return e.status==="pending"}function _v(e,t){return e.filter(Wf).length+t.length}const bn=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],Av=500;function $v(){const{user:e,domain:t}=Le(),[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(_v(l,c))}catch{r(0)}},[e,t]),i=u.useCallback(()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o()},Av)},[o]);return u.useEffect(()=>(o(),()=>{s.current&&clearTimeout(s.current)}),[o]),ce(bn[0],i),ce(bn[1],i),ce(bn[2],i),ce(bn[3],i),ce(bn[4],i),ce(bn[5],i),ce(bn[6],i),n}const Kc="Suveren",Lv="/favicon.svg",Mv="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",$s={x1:74.54,y1:22.74,x2:94.46,y2:34.24},Fv=14,Ov="#f59e0b";function Bv(e){const t=Hf(e);return t>0?`(${t}) ${Kc}`:Kc}function Hf(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function Dv(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
52
|
+
<path class="m" d="${Mv}"/>
|
|
53
|
+
<line class="m" x1="${$s.x1}" y1="${$s.y1}" x2="${$s.x2}" y2="${$s.y2}"/>
|
|
54
|
+
<circle cx="103" cy="103" r="25" fill="${Ov}"/>
|
|
55
|
+
<style>.m{stroke:#111111;stroke-width:${Fv};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 Uv(){return document.querySelector('link[rel="icon"]')}function Vf(e){const t=Hf(e);document.title=Bv(t);const n=Uv();if(!n)return;const r=t>0?Dv():Lv;n.getAttribute("href")!==r&&n.setAttribute("href",r)}function Wv(){Vf(0)}function Hv(){const e=$v();return u.useEffect(()=>{Vf(e)},[e]),u.useEffect(()=>Wv,[]),null}function Vv(){const[e,t]=u.useState(!1);return a.jsxs(jv,{children:[a.jsx(Hv,{}),a.jsx(El,{onMenuToggle:()=>t(!e)}),a.jsx(Uf,{}),a.jsx(Ev,{}),a.jsx(Pv,{open:e,onClose:()=>t(!1)}),a.jsx("div",{className:"main-content",children:a.jsx("div",{className:"page-inner",children:a.jsx(Tg,{})})})]})}function Gv(){const[e,t]=u.useState(""),{login:n,isLoading:r,error:s,clearError:o}=Le(),[i,l]=u.useState(null),c=async()=>{if(e.trim()){o();try{await n(e)}catch(m){if(m instanceof Lf){l(m.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(El,{}),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:m=>t(m.target.value),onKeyDown:m=>m.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((m,p)=>a.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:p<2?"0.5rem":0},children:[a.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[p+1,"."]}),m]},p))})]})]})})]}),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:m=>m.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 Kv(){const{setActiveContext:e}=Le(),t=en(),[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 p=await A.joinGroup(n.trim());e(p,p.myDomains[0]||""),t("/")}catch(p){l(p instanceof Error?p.message:"Failed to join group")}finally{d(!1)}}},m=async()=>{if(s.trim()){d(!0),l("");try{const p=await A.createGroup(s.trim());e(p,p.myDomains[0]||""),t("/")}catch(p){l(p instanceof Error?p.message:"Failed to create group")}finally{d(!1)}}};return a.jsxs(a.Fragment,{children:[a.jsx(El,{}),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:p=>r(p.target.value),onKeyDown:p=>p.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:p=>o(p.target.value),onKeyDown:p=>p.key==="Enter"&&m(),style:{flex:1},disabled:c}),a.jsx("button",{className:"btn btn-secondary",onClick:m,disabled:c,children:"Create"})]})]})]})})]})}const wi="suveren-setup-ai-skipped",Si="suveren-setup-agent-done",ji="suveren-setup-dismissed",Yv={"hap-setup-ai-skipped":wi,"hap-setup-agent-done":Si,"hap-setup-dismissed":ji};function Qv(){for(const[e,t]of Object.entries(Yv)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}Qv();const jo={"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 Jv({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:s}){const[o,i]=u.useState(()=>localStorage.getItem(wi)==="true"),[l,c]=u.useState(()=>localStorage.getItem(Si)==="true"),[d,f]=u.useState(()=>localStorage.getItem(ji)==="true"),[m,p]=u.useState(null),[x,w]=u.useState("claude-code"),[y,j]=u.useState(!1),h=[{label:"AI Assistant",detail:"A trusted AI helps you think through authorizations — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":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"}],g=h.filter(C=>C.status==="done"||C.status==="skipped").length,v=g===h.length,S=u.useCallback(()=>{localStorage.setItem(wi,"true"),i(!0)},[]),b=u.useCallback(()=>{localStorage.setItem(Si,"true"),c(!0),p(null)},[]),I=u.useCallback(()=>{localStorage.setItem(ji,"true"),f(!0)},[]),R=u.useCallback(async C=>{try{await navigator.clipboard.writeText(C),j(!0),setTimeout(()=>j(!1),2e3)}catch{}},[]);if(d||v)return null;const P=h.findIndex(C=>C.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:h.map((C,z)=>{const B=z===P,K=C.status==="done"||C.status==="skipped"?"●":"○",Y=C.status==="done"?"var(--success)":C.status==="skipped"?"var(--text-tertiary)":B?"var(--accent)":"var(--text-tertiary)";return a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:B?"0.75rem":"0.25rem 0",borderRadius:B?"0.5rem":void 0,background:B?"var(--accent-subtle)":void 0},children:[a.jsx("span",{style:{color:Y,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:K}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[C.to&&C.status==="pending"?a.jsx(Je,{to:C.to,style:{fontSize:"0.9rem",fontWeight:B?600:500,color:B?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:C.label}):C.status==="pending"&&z===3?a.jsx("button",{onClick:()=>p(m===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:B?600:500,color:B?"var(--accent)":"var(--text-primary)"},children:C.label}):a.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:C.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:C.label}),C.optional&&C.status==="pending"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),C.status==="skipped"&&a.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),C.detail&&C.status==="pending"&&B&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:C.detail})]}),C.optional&&C.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"}),C.to&&C.status==="pending"&&a.jsx(Je,{to:C.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),z===3&&m===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(jo).map(([W,T])=>a.jsx("button",{onClick:()=>w(W),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:x===W?600:400,background:x===W?"var(--accent-subtle)":"transparent",color:x===W?"var(--accent)":"var(--text-secondary)",border:`1px solid ${x===W?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:T.label},W))}),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:jo[x].snippet(s)}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>R(jo[x].snippet(s)),children:y?"Copied":"Copy"}),a.jsx("button",{className:"btn btn-primary btn-sm",onClick:b,children:"Done"})]})]})]},z)})}),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:`${g/h.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:[g," of ",h.length," complete"]})]})]})}function Rn({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 ko(){return a.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[a.jsx(Rn,{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(Rn,{variant:"line",style:{width:"35%"}}),a.jsx(Rn,{variant:"line-sm",style:{width:"65%"}})]})]})}const Xv={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Gf=e=>Xv[e]??e,qv={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 Zv(e){return qv[e]??{chip:"Blocked",sev:"info"}}function ey(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 ty(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 ny=5;function ry(){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:ny}).then(({count:f,records:m})=>{r(f),t(m),l(!1)}).catch(()=>l(!0))},[s]);if(u.useEffect(()=>{c()},[c]),Ft(c,12e4),i||e===null)return null;const d=(f,m)=>{const p=Zv(f.reason);return a.jsxs("div",{className:"rb-row",children:[a.jsx("span",{className:`rb-dot ${p.sev==="act"?"act":p.sev==="info"?"info":""}`,"aria-hidden":"true"}),a.jsxs("div",{className:"rb-body",children:[a.jsx("div",{className:"rb-line",children:ey(f)}),a.jsxs("div",{className:"rb-meta",children:[a.jsx("span",{className:`rb-chip ${p.sev==="act"?"act":p.sev==="warn"?"warn":""}`,children:p.chip}),a.jsx("span",{className:"rb-via",children:Gf(f.integrationId)})]}),p.fixTo&&a.jsx(Je,{className:"rb-fix",to:p.fixTo,children:"Set a read window →"})]}),a.jsx("div",{className:"rb-when",children:ty(f.ts,Date.now())})]},`${f.ts}-${m}`)};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 sy=30*60;function bo(e){return e.replace(/@.*$/,"").split("/").pop()??e}function ay(){var W;const{domain:e}=Le(),[t,n]=u.useState([]),[r,s]=u.useState([]),[o,i]=u.useState([]),[l,c]=u.useState(!0),[d,f]=u.useState(!1),[m,p]=u.useState(!1),[x,w]=u.useState(!1),{entries:y,activeSessions:j,loading:h}=Tl(),g=!h,v=u.useCallback(()=>{A.getMyAttestations().then(T=>{n(T),f(!0)}).catch(()=>f(!0)),A.getProposals(e||"owner").then(T=>{s(T),p(!0)}).catch(()=>p(!0)),A.getProposalsForApprover().then(T=>i(T)).catch(()=>i([])),A.getCredential("ai-config").then(T=>{c(T.configured),w(!0)}).catch(()=>w(!0))},[e]);ce("attestation-changed",v),ce("proposal-added",v),ce("proposal-resolved",v),ce("proposal-approved",v),ce("proposal-rejected",v),Ft(v,3e5,e);const S=d&&m&&x&&g,b=Bf(t),I=b.active,R=b.expired,P=I.filter(T=>T.remaining_seconds!==null&&T.remaining_seconds<=sy),C=r.filter(Wf),z=y.filter(T=>T.state==="running"),B=y.filter(T=>T.state==="starting"),K=y.filter(T=>T.state==="not-running"||T.state==="error"),Y=[];for(const T of o)Y.push({label:"Approval needed",detail:`${T.tool} — above-cap action under ${bo(T.profileId)}`,to:"/proposals",color:"var(--warning)"});for(const T of C)Y.push({label:"Approval pending",detail:`${T.tool} awaiting your approval`,to:"/proposals",color:"var(--warning)"});for(const T of P){const X=Math.ceil((T.remaining_seconds??0)/60);Y.push({label:"Expiring soon",detail:`${T.title??bo(T.profile_id)} — ${X} min remaining`,to:"/authorizations",color:"var(--warning)"})}for(const T of R)Y.push({label:"Expired",detail:T.title??bo(T.profile_id),to:"/authorizations",color:"var(--danger)"});for(const T of K)Y.push({label:T.state==="error"?"Integration error":"Integration stopped",detail:T.state==="error"&&((W=T.integration)!=null&&W.error)?`${T.manifest.name}: ${T.integration.error}`:`${T.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"});for(const T of B)Y.push({label:"Integration starting",detail:`${T.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const T of y)T.authStatus==="failed"&&T.state!=="not-running"&&T.state!=="error"&&Y.push({label:"Reconnect needed",detail:`${T.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return l||Y.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(Jv,{aiConfigured:l,hasRunningIntegration:z.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(Je,{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(Rn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),a.jsx(Je,{to:"/proposals",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[m?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:C.length>0?"var(--warning)":"var(--text-tertiary)"},children:C.length}):a.jsx(Rn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),a.jsx(Je,{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:R.length>0?"var(--danger)":"var(--text-tertiary)"},children:R.length}):a.jsx(Rn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),a.jsx(Je,{to:"/integrations",style:{textDecoration:"none"},children:a.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[g?a.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:z.length>0?"var(--success)":"var(--text-tertiary)"},children:z.length}):a.jsx(Rn,{variant:"title"}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),Y.length>0?a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:Y.map((T,X)=>a.jsx(Je,{to:T.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:T.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:T.label}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.detail})]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]})},X))}):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(ko,{}),a.jsx(ko,{}),a.jsx(ko,{})]}),a.jsx(ry,{})]})}const oy=["Scope & Limits","Intent","Authorize"];function Kf({currentStep:e,onStepClick:t}){const n=en();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:oy.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 iy=40;function Te(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,iy)}function ly({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:"})," ",Te(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 cy({integrationId:e,field:t,value:n,onChange:r,disabled:s,onLabels:o}){const[i,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState(!0);u.useEffect(()=>{let w=!1;return A.discoverScopeField(e,t).then(y=>{var j;w||(l(y.options),m(!1),(j=y.options)!=null&&j.length&&(o==null||o(Object.fromEntries(y.options.map(h=>[h.value,h.label])))))}).catch(y=>{w||(d(y instanceof Error?y.message:String(y)),m(!1))}),()=>{w=!0}},[e,t]);const p=new Set(n.split(",").map(w=>w.trim()).filter(Boolean)),x=w=>{const y=new Set(p);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,h=j==="reader",g=y.primary===!0;return a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:h?"var(--text-tertiary)":"var(--text-primary)",cursor:s||h?"not-allowed":"pointer"},title:h?"Read-only — you can authorize list/read but not writes":void 0,children:[a.jsx("input",{type:"checkbox",checked:p.has(String(w.value)),onChange:()=>x(String(w.value)),disabled:s||h}),a.jsx("span",{children:w.label||w.value}),g&&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 uy(e){return e.replace(/@.*$/,"").split("/").pop()??e}function dy(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function fy(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function py(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function Yc(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 my(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function hy(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function gy(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 vy(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 yy({id:e,value:t,onChange:n,disabled:r,placeholder:s,unit:o}){const i=hy(o),l=gy(o),c=my(o),d=vy(t,o),f=t===""?null:Number(t),m=()=>{const x=t===""?0:Number(t),w=x%i,y=w===0?x+i:x+(i-w);n(String(y))},p=()=>{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:p,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:m,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 Qc({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 xy({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),m=t?t.split(",").map(h=>h.trim()).filter(Boolean):[],p=h=>{const g=h.trim();if(!g)return;if(!Yc(g,s)){d(!0);return}d(!1);const v=m.includes(g)?m:[...m,g];n(v.join(",")),l("")},x=h=>{const g=m.filter((v,S)=>S!==h);n(g.join(","))},w=h=>{h.key==="Enter"||h.key===","||h.key==="Tab"?i.trim()&&(h.preventDefault(),p(i)):h.key==="Backspace"&&!i&&m.length>0&&x(m.length-1)},y=h=>{const g=h.clipboardData.getData("text");if(g.includes(",")){h.preventDefault();const S=g.split(",").map(I=>I.trim()).filter(Boolean).filter(I=>Yc(I,s)),b=[...new Set([...m,...S])];n(b.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 h;return(h=f.current)==null?void 0:h.focus()},children:[m.map((h,g)=>a.jsxs("span",{className:"tag-pill",children:[h,!r&&a.jsx("button",{type:"button",className:"tag-remove",onClick:v=>{v.stopPropagation(),x(g)},"aria-label":`Remove ${h}`,children:"×"})]},h)),!r&&a.jsx("input",{ref:f,id:e,className:"tag-input-field",type:"text",value:i,onChange:h=>{l(h.target.value),d(!1)},onKeyDown:w,onPaste:y,onBlur:()=>{i.trim()&&p(i)},placeholder:m.length===0?o??j:""})]})}function wy({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 Jc({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:s,readOnly:o,twoColumn:i,discoveryIntegrationId:l,onLabels:c}){const d=dy(e,t),f=`${s}-field-${e}`,m=a.jsx(a.Fragment,{children:py(t)?a.jsx(wy,{id:f,options:t.enum,value:n,onChange:p=>r(e,p),disabled:o}):(()=>{const p=t.boundType;return(p==null?void 0:p.kind)==="enum"&&Array.isArray(p.values)})()?a.jsxs("select",{id:f,className:"form-select",value:n,onChange:p=>r(e,p.target.value),disabled:o,children:[a.jsx("option",{value:"",children:"Select..."}),t.boundType.values.map(p=>a.jsx("option",{value:p,children:p},p))]}):"enum"in t&&t.enum?a.jsxs("select",{id:f,className:"form-select",value:n,onChange:p=>r(e,p.target.value),disabled:o,children:[a.jsx("option",{value:"",children:"Select..."}),t.enum.map(p=>a.jsx("option",{value:p,children:p},p))]}):t.type==="number"?a.jsx(yy,{id:f,value:n,onChange:p=>r(e,p),disabled:o,unit:t.unit}):fy(t)?a.jsx(xy,{id:f,value:n,onChange:p=>r(e,p),disabled:o,format:t.format}):l?a.jsx(cy,{integrationId:l,field:e,value:n,onChange:p=>r(e,p),disabled:o,onLabels:p=>c==null?void 0:c(e,p)}):a.jsx("input",{id:f,className:"form-input",type:"text",value:n,onChange:p=>r(e,p.target.value),disabled:o})});return i?a.jsxs("div",{className:"bounds-field-row",children:[a.jsx("div",{className:"bounds-field-label",children:a.jsx(Qc,{htmlFor:f,label:d,description:t.description})}),a.jsx("div",{className:"bounds-field-input",children:m})]},`${s}-${e}`):a.jsxs("div",{className:"form-group",children:[a.jsx(Qc,{htmlFor:f,label:d,description:t.description}),m]},`${s}-${e}`)}function Sy(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 jy(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 ky({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,m=e.contextSchema,p=f?Object.entries(f.fields).filter(([_,D])=>!(_==="profile"||_==="path"||D.enforced===!1||D.enforcedBy==="gatekeeper")):[],x=f?Object.entries(f.fields).filter(([,_])=>_.enforcedBy==="gatekeeper").filter(([,_])=>_.enforced!==!1).map(([_,D])=>D.displayName??_):[],w=m&&m.keyOrder.length>0?Object.entries(m.fields):[],y=s??i??{},j=o??{},h={};for(const[_]of p)h[_]=y[_]!==void 0?String(y[_]):"";const g={};for(const[_]of w)g[_]=j[_]!==void 0?String(j[_]):"";const[v,S]=u.useState(h),[b,I]=u.useState(g),[R,P]=u.useState({}),[C,z]=u.useState(null);u.useEffect(()=>{const _=uy(e.id);A.getIntegrationManifests().then(({manifests:D})=>{const F=D.find(G=>G.profile===_&&G.contextDiscovery&&Object.keys(G.contextDiscovery).length>0);z(F??null)}).catch(()=>z(null))},[e.id]);const B=Sy(v,l),K=jy(v,l==null?void 0:l.caps),Y=(_,D)=>{S(F=>({...F,[_]:D}))},W=(_,D)=>{I(F=>({...F,[_]:D}))},T=()=>{const _={profile:e.id};for(const[F,G]of p)G.type==="number"?_[F]=v[F]===""?0:Number(v[F]):_[F]=v[F];const D={};for(const[F,G]of w)G.type==="number"?D[F]=b[F]===""?0:Number(b[F]):D[F]=b[F];return[_,D]},X=()=>{const[_,D]=T();t(_,D,R)},te=()=>{const _=(l==null?void 0:l.caps)??{},D={...v};for(const q of K)_[q]!==void 0&&(D[q]=String(_[q]));S(D);const F={profile:e.id};for(const[q,ee]of p)if(ee.type==="number"){const ue=D[q]??"";F[q]=ue===""?0:Number(ue)}else F[q]=D[q]??"";const G={};for(const[q,ee]of w)ee.type==="number"?G[q]=b[q]===""?0:Number(b[q]):G[q]=b[q];t(F,G,R)},M=_=>{const D=l==null?void 0:l.caps;if(!D||D[_]===void 0)return null;const F=D[_],G=K.has(_);return B==="hard-ceiling"&&G?a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",F," — exceeds team ceiling"]}):B==="above-approvers"&&G?a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",F," — above cap"]}):a.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",F," ok"]})},$=()=>{var _;if(B==="no-config")return null;if(B==="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(B==="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(B==="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(B==="hard-ceiling"){const D=Array.from(K)[0],F=D?(_=l==null?void 0:l.caps)==null?void 0:_[D]:void 0,G=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 ",F??"the configured limit",". Lower your bound or ask ",G," 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:te,children:"Save below cap"}),n&&a.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},H=B==="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(([_,D])=>{var G;const F=!!((G=C==null?void 0:C.contextDiscovery)!=null&&G[_]);return a.jsx(Jc,{fieldKey:_,fieldDef:D,value:b[_],onChange:W,prefix:"context",readOnly:r,discoveryIntegrationId:F?C.id:void 0,onLabels:(q,ee)=>P(ue=>({...ue,[q]:ee}))},`context-${_}`)})]}),p.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:p.map(([_,D])=>{var F;return a.jsxs("div",{style:{display:"contents"},children:[a.jsx(Jc,{fieldKey:_,fieldDef:D,value:v[_],onChange:Y,prefix:"bounds",readOnly:r,twoColumn:!0}),B!=="no-config"&&((F=l==null?void 0:l.caps)==null?void 0:F[_])!==void 0&&a.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:M(_)})]},`bounds-${_}`)})}),$(),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(Je,{to:"/integrations",children:"Integrations"}),"."]})]}),a.jsx("button",{className:"btn btn-primary",onClick:X,disabled:H,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function by(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 Cy(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Ny="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 ba({target:e,currentText:t,onApply:n,greeting:r,placeholder:s,title:o}){const[i,l]=u.useState([{role:"assistant",content:r??Ny}]),[c,d]=u.useState(""),[f,m]=u.useState(!1),[p,x]=u.useState(null),w=u.useRef(null);u.useEffect(()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},[i,f]);const y=async()=>{const h=c.trim();if(!h||f)return;const g=[...i,{role:"user",content:h}];l(g),d(""),x(null),m(!0);try{const v=await A.aiChat({target:e,currentText:t,messages:g.filter((S,b)=>!(b===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{m(!1)}},j=h=>{h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.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((h,g)=>{const v=h.role==="assistant"?by(h.content):null,S=v?Cy(h.content):h.content;return a.jsx("div",{className:`chat-msg ${h.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"})]})]})},g)}),f&&a.jsx("div",{className:"chat-msg assistant",children:a.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),p&&a.jsx("div",{className:"error-message",children:p}),a.jsxs("div",{className:"chat-composer",children:[a.jsxs("div",{className:"chat-composer-pill",children:[a.jsx("textarea",{className:"chat-input",value:c,onChange:h=>d(h.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 Ey(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ty(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 m,p;return((m=f.scope)==null?void 0:m.toLowerCase())===d||((p=f.scope)==null?void 0:p.split(",").map(x=>x.trim().toLowerCase()).includes(d))})},i=["\\[\\d+\\]",...r.map(Ey)],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 m=f.scope&&f.scope!=="all (unscoped)"?f.scope:"all recipients",p=n?`${n}: ${m}`:m;return{text:c,label:p,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 Xc=`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 zy(e,t,n,r){return Ty(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 Iy(){var le;const e=en(),[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),[m,p]=u.useState(null),[x,w]=u.useState({}),[y,j]=u.useState(Xc),[h,g]=u.useState(!1),[v,S]=u.useState(!0),[b,I]=u.useState(null),[R,P]=u.useState([]),[C,z]=u.useState(void 0),[B,K]=u.useState(!1),[Y,W]=u.useState(null),[T,X]=u.useState(null),[te,M]=u.useState(null),[$,H]=u.useState([]),[_,D]=u.useState(null);u.useEffect(()=>{var pe;const L=sessionStorage.getItem("agentAuth");if(!L){e("/agent/new");return}const J=JSON.parse(L);s(J);const ne=sessionStorage.getItem("agentGate");if(ne){const me=JSON.parse(ne);me.bounds&&f(me.bounds),me.context&&p(me.context),(pe=me.gateContent)!=null&&pe.intent&&j(me.gateContent.intent)}A.getProfile(J.profileId).then(me=>i(me)).catch(()=>e("/agent/new")).finally(()=>S(!1)),J.groupId&&Promise.all([A.getTeamProfileConfig(J.groupId,J.profileId).catch(()=>null),A.getGroupById(J.groupId).catch(()=>null),A.listUsers().catch(()=>[])]).then(([me,ze,kt])=>{if(I(me),me){const Ie=new Map;for(const ae of kt){const Ue=ae.name&&ae.email?`${ae.name} (${ae.email})`:ae.name||ae.email||ae.id;Ie.set(ae.id,Ue)}const pt=(ze==null?void 0:ze.members)??[];for(const ae of pt){const Ue=ae.userId??ae.id;Ue&&(ae.name&&ae.email?Ie.set(Ue,`${ae.name} (${ae.email})`):ae.name&&Ie.set(Ue,ae.name))}const Re=(me.approvers??[]).map(ae=>Ie.get(ae)??ae);P(Re);const et=pt.find(ae=>ae.role==="admin");if(et){const ae=et.userId??et.id;ae&&z(Ie.get(ae)??et.name)}}})},[e]);const F=d?Object.entries(d).filter(([L])=>L!=="profile"&&L!=="path").map(([L,J])=>`${L} = ${J}`).join(", "):"",G=(L,J,ne)=>{f(L),p(J),ne&&w(ne),c(3)},q=y.trim()!==Xc.trim()&&y.trim()!=="",ee=L=>{q&&!confirm("Replace your current intent with the AI draft?")||j(L)},ue=()=>{const L=o==null?void 0:o.ttl,J={intent:y},ne=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...ne,bounds:d,context:m,contextLabels:x,gateContent:J,ttlConfig:L})),e("/agent/review")},Me=async()=>{if(r){K(!0),W(null),X(null),M(null),H([]),D(null);try{const L=await A.aiIntentReview({profileId:r.profileId,newIntent:y,context:m??void 0});H(L.grants??[]),L.success?L.review?W(L.review):X(L.note??"No other authorizations on this profile to compare against."):M(L.error??"Check failed.")}catch(L){M(L instanceof Error?L.message:"Check failed.")}finally{K(!1)}}},De=L=>{j(L),(Y||T||te)&&(W(null),X(null),M(null),H([]),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:L=>{L>=2&&c(L)}}),a.jsx(ly,{profileId:r.profileId,bounds:F||void 0,groupName:r.groupName,domain:r.domain}),l===2&&a.jsx("div",{className:"card",children:a.jsx(ky,{profile:o,onConfirm:G,onCancel:()=>e("/agent/new"),initialBounds:d||void 0,initialContext:m||void 0,profileConfig:b,approverNames:R,adminName:C})}),l===3&&a.jsxs("div",{className:"intent-layout",children:[a.jsx("div",{className:"card intent-pane chat tool",children:a.jsx(ba,{target:{kind:"intent",profileId:r.profileId,bounds:F||void 0},currentText:y,onApply:ee})}),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:L=>De(L.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:Me,disabled:B||!q,children:B?"Checking…":"Check against my other grants"}),te&&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:te})]}),T&&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:T})]}),Y&&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:zy(Y,$,D,Te(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:ue,disabled:!q,children:"Continue to Review"})]}),(((le=b==null?void 0:b.approvers)==null?void 0:le.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 ",R.length>0?R.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",R.length>0?R.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:()=>g(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),a.jsx(Yf,{open:h,onClose:()=>g(!1),ariaLabel:"Intent assistant",children:a.jsx(ba,{target:{kind:"intent",profileId:r.profileId,bounds:F||void 0},currentText:y,onApply:L=>{ee(L),g(!1)}})}),_&&a.jsx("div",{className:"modal-backdrop",onClick:L=>L.target===L.currentTarget&&D(null),children:a.jsxs("div",{className:"modal",children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h3",{className:"modal-title",children:_.length>1?`Existing authorizations (${_.length})`:"Existing authorization"}),a.jsx("button",{className:"modal-close",onClick:()=>D(null),children:"×"})]}),a.jsx("div",{className:"modal-body",children:_.map((L,J)=>{var ne;return a.jsxs("div",{style:{marginBottom:J<_.length-1?"1rem":0,paddingBottom:J<_.length-1?"1rem":0,borderBottom:J<_.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:L.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:((ne=L.intent)==null?void 0:ne.trim())||"(no intent recorded)"}),Object.entries(L.bounds).filter(([pe])=>pe!=="profile"&&pe!=="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(L.bounds).filter(([pe])=>pe!=="profile"&&pe!=="path").map(([pe,me])=>`${pe}: ${me}`).join(" · ")})]})]},J)})})]})})]})]})}function Ry(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
65
|
+
`).split(`
|
|
66
|
+
`).map(s=>s.replace(/[ \t]+$/,"")).join(`
|
|
67
|
+
`).replace(/\n+$/,"")}async function Qf(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("")}class Py extends Error{constructor(n,r,s){super(s);xr(this,"code");xr(this,"field");this.name="CanonicalValueError",this.code=n,this.field=r}}function _y(e){const t=new TextEncoder().encode(e);let n="";for(const r of t)r===61||r===37||r<32||r>126?n+="%"+r.toString(16).toUpperCase().padStart(2,"0"):n+=String.fromCharCode(r);return n}function Jf(e,t,n){const r=[];for(const s of t){const o=e[s];if(o==null)continue;const i=String(o);if(i.includes(`
|
|
68
|
+
`)||i.includes("\r"))throw new Py(n,s,`Value for "${s}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);r.push(`${s}=${_y(i)}`)}return r.join(`
|
|
69
|
+
`)}async function qs(e,t){const n=t.boundsSchema??t.frameSchema;if(!n)throw new Error("Profile has no boundsSchema or frameSchema");const r=Jf(e,n.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await Qf(r)}`}async function Xf(e,t){const n=t.contextSchema?Jf(e,t.contextSchema.keyOrder,"CONTEXT_INVALID_VALUE"):"";return`sha256:${await Qf(n)}`}async function Ca(e){const t=new TextEncoder().encode(Ry(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 qf(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 qc(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function Ay(e,t){for(const n of e)if(t.has(n))return!0;return!1}function $y(e,t,n){for(const r of e){const s=qc(t[r]),o=qc(n[r]);if(!(s.size===0||o.size===0)&&!Ay(s,o))return!1}return!0}function Ly(e){return e.length>24?`${e.slice(0,10)}…`:e}function Zf(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} (${Ly(o)})`:o}).join(", ")}function My(){var ae,Ue,V,N;const e=en(),{user:t,mode:n,domain:r}=Le(),[s,o]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState("per-action"),[p,x]=u.useState(1800),[w,y]=u.useState(86400),[j,h]=u.useState(""),[g,v]=u.useState("hours"),[S,b]=u.useState(""),[I,R]=u.useState(!0),[P,C]=u.useState(!1),[z,B]=u.useState(""),[K,Y]=u.useState(null),[W,T]=u.useState([]),[X,te]=u.useState(!1),[M,$]=u.useState([]),[H,_]=u.useState(0);u.useEffect(()=>{var Ye;const k=sessionStorage.getItem("agentAuth"),E=sessionStorage.getItem("agentGate");if(!k||!E){e("/agent/new");return}const U=JSON.parse(k),Z=JSON.parse(E),re={bounds:Z.bounds??{},context:Z.context??{},contextLabels:Z.contextLabels??void 0,gateContent:Z.gateContent};o(U),l(re),Z.ttlConfig&&(x(Z.ttlConfig.default??1800),y(Z.ttlConfig.max??86400)),Z.templateMode==="automatic"?m("immediate"):Z.templateMode==="review"&&m("per-action");const Pe=((Ye=Z.ttlConfig)==null?void 0:Ye.max)??86400;if(typeof Z.templateTtl=="number"&&Z.templateTtl>0){const je=Math.min(Z.templateTtl,Pe);x(je),[3600,86400,604800,2592e3,31536e3].includes(je)||(je%86400===0?(h(String(je/86400)),v("days")):(h(String(Math.max(1,Math.round(je/3600)))),v("hours")))}A.getProfile(U.profileId).then(je=>{var mt;if(d(je),!S){const bt=je.name??((mt=U.profileId.split("/").pop())==null?void 0:mt.replace(/@.*$/,""))??"",We=[];if(re.context&&je.contextSchema)for(const Ct of je.contextSchema.keyOrder){const oe=re.context[Ct];if(oe!==void 0&&oe!==""){const kn=String(oe).split(",").map(rp=>rp.trim()).filter(Boolean);We.push(kn.join(", "))}}const Ut=We.length>0?`${bt}: ${We.join(" · ")}`:bt;b(Ut)}}).catch(()=>{}),U.groupId?Promise.all([A.getTeamProfileConfig(U.groupId,U.profileId).catch(()=>null),A.getGroupById(U.groupId).catch(()=>null),A.listUsers().catch(()=>[])]).then(([je,mt,bt])=>{if(Y(je),je){const We=new Map;for(const oe of bt){const kn=oe.name&&oe.email?`${oe.name} (${oe.email})`:oe.name||oe.email||oe.id;We.set(oe.id,kn)}const Ut=(mt==null?void 0:mt.members)??[];for(const oe of Ut){const kn=oe.userId??oe.id;kn&&(oe.name&&oe.email?We.set(kn,`${oe.name} (${oe.email})`):oe.name&&We.set(kn,oe.name))}const Ct=(je.approvers??[]).map(oe=>We.get(oe)??oe);T(Ct)}}).finally(()=>{te(!0)}):te(!0)},[e]),u.useEffect(()=>{if(!(s!=null&&s.profileId))return;const k=s.profileId,E=sessionStorage.getItem("agentEditReplaces");A.getEnrichedAuthorizations().then(U=>{const Z=U.filter(re=>re.profileId===k&&re.authorizationId!==E).map(re=>({authorizationId:re.authorizationId,bounds:re.bounds,context:re.context??{},intent:re.intent}));$(Z)}).catch(()=>$([]))},[s==null?void 0:s.profileId]),u.useEffect(()=>{if(!i||!c||M.length===0){_(0);return}let k=!1;return(async()=>{const E=await qs(i.bounds,c),U=await Promise.all(M.map(Z=>qs(Z.bounds,c).catch(()=>null)));k||_(U.filter(Z=>Z===E).length)})().catch(()=>{k||_(0)}),()=>{k=!0}},[i,c,M]);const D=async()=>{if(!(!s||!i||!c||!t)){if(!s.groupId){B("No active group; cannot create authorization.");return}C(!0),B("");try{const k=r||s.domain||"owner",E=await qs(i.bounds,c),U=await Xf(i.context,c),[Z,re]=await Promise.all([Ca(i.gateContent.intent),Ca(JSON.stringify({profile:s.profileId,domain:k,group:s.groupId}))]);let Pe,Ye,je,mt;if(s.isTeam){const Ct=await A.getApproversPubkeys(s.groupId,s.profileId);if(Ct.length>0){const oe=await A.encryptIntent(i.gateContent.intent,Ct);Pe=oe.intentCiphertext,Ye=oe.encryptedKeys,je=oe.approversFrozen,mt=oe.intentDisclosureHash}}const bt=`authz_${crypto.randomUUID()}`,We=sessionStorage.getItem("agentEditReplaces")||void 0,Ut=await A.attest({authorization_id:bt,replaces:We,profile_id:s.profileId,bounds:i.bounds,bounds_hash:E,context_hash:U,domain:k,did:t.did,gate_content_hashes:{intent:Z},execution_context_hash:re,group_id:s.groupId,ttl:p,commitment_mode:f==="per-action"?"review":"automatic",title:S.trim(),intent_ciphertext:Pe,encrypted_keys:Ye,approvers_frozen:je,intent_disclosure_hash:mt,disclose_identity:I});try{await A.pushGateContent(qf(Ut,{boundsHash:E,contextHash:U,context:i.context,contextLabels:i.contextLabels,gateContent:i.gateContent}))}catch(Ct){try{await A.revokeAttestation(bt,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Authorization signed but gate content delivery failed. The attestation was revoked. Please try again. (${Ct instanceof Error?Ct.message:"Unknown error"})`)}if(We)try{await A.revokeAttestation(We,`Replaced by ${bt} (edit)`),A.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/authorizations?highlight=${encodeURIComponent(bt)}`)}catch(k){B(k instanceof Error?k.message:"Attestation failed")}finally{C(!1)}}};if(!s||!i)return a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const F=Object.entries(i.bounds).filter(([k])=>k!=="profile"&&k!=="path"),G=Object.entries(i.context),ee=((K==null?void 0:K.caps)!=null?Object.keys(K.caps):[]).length!==0,ue=W.length>0?W.join(", "):((K==null?void 0:K.approvers)??[]).join(", "),Me=ee?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${ue}, 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.",De=ee?`Over-cap actions will be reviewed by you and ${ue}. Within-cap actions run per the mode you chose above.`:`Approvers ${ue} can read your intent but won't gate any action — no caps configured on this profile.`,le=!!((ae=K==null?void 0:K.approvers)!=null&&ae.length),L=!!s.groupId&&X&&(((Ue=K==null?void 0:K.approvers)==null?void 0:Ue.length)??0)===0,J=p>w,ne={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"},pe={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"},me=((V=c==null?void 0:c.contextSchema)==null?void 0:V.keyOrder)??[],ze=M.filter(k=>$y(me,i.context,k.context)),kt=ze.length>0,Ie=Te(s.profileId),pt=k=>{const E=Object.values(k).map(U=>String(U).trim()).filter(Boolean);return E.length>0?E.join(", "):"all (unscoped)"},Re=ze.map(k=>pt(k.context)).join("; "),et=`This grant's scope overlaps an existing grant on ${Ie} (scoped to: ${Re}). 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:k=>{k<=3&&e(`/agent/gate?step=${k}`)}}),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."}),z&&a.jsx("div",{className:"error-message",children:z}),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. ${Te(s.profileId)}: daily operations`,value:S,onChange:k=>b(k.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:()=>m("per-action"),style:pe,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:()=>m("immediate"),style:ne,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(k=>k.seconds<=w).map(k=>a.jsx("button",{onClick:()=>{x(k.seconds),h("")},style:{padding:"0.5rem 0.85rem",border:p===k.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:p===k.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:k.label},k.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:k=>{h(k.target.value);const E=parseInt(k.target.value,10);if(E>0){const U=g==="days"?E*86400:E*3600;x(Math.min(U,w))}}}),a.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:g,onChange:k=>{v(k.target.value);const E=parseInt(j,10);if(E>0){const U=k.target.value==="days"?E*86400:E*3600;x(Math.min(U,w))}},children:[a.jsx("option",{value:"hours",children:"hours"}),a.jsx("option",{value:"days",children:"days"})]})]}),J&&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:k=>R(k.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})]}),(!!F.length||!!G.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:[G.map(([k,E])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:k}),a.jsx("dd",{children:Zf(k,E,i.contextLabels)})]},k)),F.map(([k,E])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:k}),a.jsx("dd",{children:String(E)})]},k))]})]}),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:[Te(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:X?(((N=K==null?void 0:K.approvers)==null?void 0:N.length)??0)===0?a.jsxs(a.Fragment,{children:[a.jsxs("span",{style:{color:"var(--danger)",fontWeight:600},children:["Not enabled for ",s.groupName??"this team"]}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:"A team admin must name at least one approver for this profile on the Authority Server (team → Profiles) before anyone can grant under it. Personal use is unaffected."})]}):a.jsxs(a.Fragment,{children:[ue,a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:Me})]}):a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),H>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:[H===1?`An active grant on ${Ie} already has exactly these limits.`:`${H} active grants on ${Ie} 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,kt?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:et})]})]}):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()||L,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:le?"block":"none"},children:De})]})]})}const Fy={card:"💳",mail:"✉️"};function Oy(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 By=[0,7,30,90,365,3650];function Ls(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 Dy({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:s}){var Ue;const[o,i]=u.useState({}),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[m,p]=u.useState({}),[x,w]=u.useState({}),[y,j]=u.useState(void 0),[h,g]=u.useState(!1),[v,S]=u.useState(null),[b,I]=u.useState(!1),[R,P]=u.useState(!1),[C,z]=u.useState(!1),[B,K]=u.useState(!1),[Y,W]=u.useState({}),[T,X]=u.useState(null),[te,M]=u.useState(!1),[$,H]=u.useState(null),[_,D]=u.useState(!1);u.useEffect(()=>{let V=!1;return A.getCredential(e.id).then(N=>{var k;if(!(V||!N.configured)){if(c(!0),f(!0),N.fields){const E={};for(const U of e.credentials.fields)N.fields[U.key]!=null&&(E[U.key]=N.fields[U.key]);p(E)}if(w(N.secrets??{}),j(N.updatedAt),e.oauth){const E=((k=N.fieldNames)==null?void 0:k.includes(e.oauth.tokenStorage))??!1;g(E),E&&A.getOAuthHealth(e.id).then(U=>{V||S(U)})}}}).catch(()=>{}),()=>{V=!0}},[e.id,e.oauth]);const F=Oy(e.toolGating),G=t?t.readAgeDays??null:void 0,q=te&&T?T.value:G,ee=async V=>{X({value:V}),M(!0),H(null);try{await A.setReadPolicy(e.id,V),s(V===null?`${e.name} read window now follows your authorization`:`${e.name} read window set to ${Ls(V).toLowerCase()}`),r()}catch(N){H(N instanceof Error?N.message:"Could not save")}finally{M(!1),X(null)}},ue=!!e.oauth||e.credentials.fields.some(V=>!V.optional),Me=e.oauth?h:l,De=!ue||Me,le=n==="starting"?"starting":De?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!h?"needs-oauth":"unconfigured",L=async()=>{if(e.credentials.fields.some(N=>{var k;return(k=o[N.key])==null?void 0:k.trim()})){I(!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{I(!1)}}},J=()=>{const V={};for(const N of e.credentials.fields){const k=o[N.key];N.type==="password"?k!=null&&k.trim()&&(V[N.key]=k):k!=null&&k!==(m[N.key]??"")&&(V[N.key]=k)}return V},ne=Object.keys(J()).length>0,pe=async()=>{const V=J();if(Object.keys(V).length!==0){I(!0);try{await A.setCredential(e.id,V),i({}),c(!0),e.oauth?s(`${e.name} credentials saved — now click Connect.`):(K(!1),s(`${e.name} credentials updated — restarting...`),await ze())}catch{s(`Failed to update ${e.name} credentials`)}finally{I(!1)}}},me=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const V=setInterval(async()=>{var N;try{const k=await A.getCredential(e.id);k.configured&&e.oauth&&((N=k.fieldNames)!=null&&N.includes(e.oauth.tokenStorage))&&(g(!0),K(!1),S(null),clearInterval(V),s(`${e.name} connected — starting integration...`),A.getOAuthHealth(e.id).then(S).catch(()=>{}),await ze())}catch{}},2e3);setTimeout(()=>clearInterval(V),12e4)},ze=async()=>{z(!0);try{const V=await A.activateIntegration(e.id);V.warning?s(V.warning):s(`${e.name} integration started with ${V.tools.length} tools`),r()}catch(V){s(`Failed to start ${e.name}: ${V instanceof Error?V.message:"Unknown error"}`)}finally{z(!1)}},kt=async()=>{try{await A.removeMcpIntegration(e.id),s(`${e.name} integration removed`),r()}catch{s(`Failed to remove ${e.name}`)}},Ie=Fy[e.icon]??"🔧",pt=le==="running"?{c:"int-chip-ok",t:"Running"}:le==="starting"?{c:"int-chip-idle",t:"Starting"}:t&&!t.running&&t.error?{c:"int-chip-bad",t:"Crashed"}:{c:"int-chip-idle",t:"Stopped"},Re=e.oauth&&h&&(v==null?void 0:v.status)==="failed",et=ue?Re?{c:"int-chip-bad",t:"Auth failed"}:Me?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},ae=V=>V.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:Ie}),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:[le!=="unconfigured"&&le!=="needs-oauth"&&a.jsxs("span",{className:`int-chip ${pt.c}`,children:[a.jsx("span",{className:"int-dot"}),pt.t]}),a.jsxs("span",{className:`int-chip ${et.c}`,children:[a.jsx("span",{className:"int-dot"}),et.t]})]})]}),e.oauth&&h&&a.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:v!=null&&v.account?a.jsxs(a.Fragment,{children:["Connected as ",a.jsx("b",{children:v.account})]}):a.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),Re&&!B&&a.jsxs("div",{style:{marginTop:"0.7rem",border:"1px solid var(--danger)",borderRadius:"10px",padding:"0.8rem 0.95rem",background:"color-mix(in srgb, var(--danger) 5%, var(--bg-elevated))"},children:[a.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[e.name," stopped accepting the stored credentials"]}),a.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[(v==null?void 0:v.error)==="invalid_grant"?a.jsxs(a.Fragment,{children:["The refresh token was revoked (",a.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):v!=null&&v.error?a.jsxs(a.Fragment,{children:["The provider reported ",a.jsx("code",{children:v.error}),"."]}):a.jsx(a.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",e.name," actions are ",a.jsx("b",{children:"blocked"}),", not failing silently."]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[a.jsxs("button",{className:"btn btn-primary btn-sm",onClick:me,children:["Reconnect ",e.name]}),a.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{i({...m}),K(!0)},children:"Edit credentials"})]})]}),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:((Ue=e.oauth.scopes)==null?void 0:Ue.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&&(le!=="running"||Re)&&a.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a.jsxs("button",{onClick:()=>P(!R),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:R?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),R&&a.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((V,N)=>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:N+1}),a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:V.title}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[ae(V.description),V.link&&a.jsxs(a.Fragment,{children:[" ",a.jsxs("a",{href:V.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},N))})]}),le==="starting"&&a.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[a.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),B&&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:["Leaving a secret blank keeps the stored one — editing other fields can never silently wipe it.",e.oauth?" Save, then Connect to re-link the account.":""]}),e.credentials.fields.map(V=>{var N;return a.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[a.jsx("label",{className:"form-label",children:V.label}),V.type==="password"?a.jsxs("div",{className:"cred-field",children:[a.jsx("input",{className:"form-input",type:Y[V.key]?"text":"password",name:`${e.id}-${V.key}-credential`,autoComplete:"new-password",placeholder:(N=x[V.key])!=null&&N.preview?`Unchanged — ends in ${x[V.key].preview}`:d?"Unchanged — paste a new value to replace":V.placeholder,value:o[V.key]||"",onChange:k=>i(E=>({...E,[V.key]:k.target.value}))}),a.jsx("button",{className:"cred-toggle",onClick:()=>W(k=>({...k,[V.key]:!k[V.key]})),children:Y[V.key]?"hide":"show"})]}):a.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${V.key}-credential`,autoComplete:"off",placeholder:V.placeholder,value:o[V.key]||"",onChange:k=>i(E=>({...E,[V.key]:k.target.value}))})]},V.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:pe,disabled:b||!ne,children:b?"Saving…":"Save"}),!ne&&!b&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),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:()=>{K(!1),i({})},children:"Cancel"})]})]}),!B&&le==="running"&&t&&a.jsxs(a.Fragment,{children:[(Object.keys(m).length>0||Object.keys(x).length>0)&&a.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:e.credentials.fields.map(V=>{const N=V.type==="password",k=x[V.key];return!N&&m[V.key]==null||N&&k==null?null:a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[a.jsx("span",{style:{color:"var(--text-muted)"},children:V.label}),a.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[N?k.preview??"set":m[V.key],N&&y&&a.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(y).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},V.key)})}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[a.jsx(Je,{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({...m}),K(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),a.jsx("span",{style:{flex:1}}),a.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:kt,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"})]}),F&&q!==void 0&&!_&&a.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[a.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),a.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:q===null?"window from your authorization":Ls(q).toLowerCase()}),te&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),$&&a.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:$})]}),a.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>D(!0),children:"Edit"})]})}),F&&q!==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:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[a.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),a.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>D(!1),children:"Done"})]}),a.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new authorization."}),a.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[By.map(V=>{const N=q===V;return a.jsx("button",{className:`btn btn-sm ${N?"btn-primary":"btn-secondary"}`,"aria-pressed":N,disabled:te,onClick:()=>ee(V),children:Ls(V)},V)}),a.jsx("button",{className:`btn btn-sm ${q===null?"btn-primary":"btn-ghost"}`,"aria-pressed":q===null,disabled:te,onClick:()=>ee(null),title:"Clear the local setting and use the read window from your signed authorization instead.",children:Ls(null)})]}),a.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:$?a.jsx("span",{style:{color:"var(--danger)"},children:$}):te?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):q===null?a.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your authorization. If none is set there, reads are blocked."}):q===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 ",q," days is blocked, whoever it is from."]})})]}),a.jsx("div",{style:{display:"none"},children:a.jsx(Je,{to:"/agent/new",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Authorize your agent"})})]}),le==="unconfigured"&&(()=>{const V=e.credentials.fields.every(E=>E.optional),N=e.credentials.fields.some(E=>!E.optional),k=e.credentials.fields.some(E=>{var U;return(U=o[E.key])==null?void 0:U.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&&g(!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(E=>a.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[a.jsx("label",{className:"form-label",children:E.label}),E.type==="password"?a.jsxs("div",{className:"cred-field",children:[a.jsx("input",{className:"form-input",type:Y[E.key]?"text":"password",name:`${e.id}-${E.key}-credential`,autoComplete:"new-password",placeholder:E.placeholder,value:o[E.key]||"",onChange:U=>i(Z=>({...Z,[E.key]:U.target.value}))}),a.jsx("button",{className:"cred-toggle",onClick:()=>W(U=>({...U,[E.key]:!U[E.key]})),children:Y[E.key]?"hide":"show"})]}):a.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${E.key}-credential`,autoComplete:"off",placeholder:E.placeholder,value:o[E.key]||"",onChange:U=>i(Z=>({...Z,[E.key]:U.target.value}))})]},E.key)),a.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[k&&a.jsx("button",{className:"btn btn-primary",onClick:L,disabled:b||N&&!e.credentials.fields.filter(E=>!E.optional).every(E=>{var U;return(U=o[E.key])==null?void 0:U.trim()}),children:b?"Saving...":"Save & Encrypt"}),V&&!k&&a.jsx("button",{className:"btn btn-primary",onClick:ze,disabled:C,children:C?"Starting...":`Activate ${e.name}`})]})]})})(),le==="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"})]})]}),le==="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:C,children:C?"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),g(!1)},children:"Change Credentials"})]})]}),le==="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:C,children:C?"Starting...":"Start"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:kt,children:"Disable"})]})]})]})}function Uy(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:s}=Tl(),[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(Dy,{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 Wy(){var B,K,Y;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Le(),[s,o]=u.useState(null),[i,l]=u.useState(!1),[c,d]=u.useState(""),[f,m]=u.useState(""),[p,x]=u.useState(!1),[w,y]=u.useState(""),[j,h]=u.useState("");u.useEffect(()=>{fetch("/health").then(W=>W.json()).then(W=>{typeof W.spUrl=="string"&&h(W.spUrl)}).catch(()=>{})},[]),u.useEffect(()=>{if(!e){o(null);return}A.getGroupById(e.id).then(W=>{const T=W.group??W,X=W.members??[],te=W.isAdmin??!1,M=X.map($=>{const H=$.userId||$.id||"",_=$.role||(te&&H===T.createdBy?"admin":"member");return{id:H,name:$.name||H.slice(0,8)||"Member",email:$.email||"",domains:$.domains||[],role:_,isAdmin:_==="admin"||te&&H===T.createdBy}});o({id:T.id,name:T.name,members:M})}).catch(()=>o(null))},[e==null?void 0:e.id]);const g=(s==null?void 0:s.members.filter(W=>W.isAdmin))??[],v=(e==null?void 0:e.isAdmin)===!0&&g.length<=1&&g.some(W=>W.id===(r==null?void 0:r.id)),S=(e==null?void 0:e.name)??"",b=w.trim()===S&&!i,I=()=>{y(""),x(!0)},R=()=>{x(!1),y("")},P=async()=>{if(!(!e||!b)){l(!0),d("");try{await A.leaveTeam(e.id),await n(),m("You have left the team."),o(null),R()}catch(W){d(W instanceof Error?W.message:"Failed to leave team")}finally{l(!1)}}},C=e&&j?`${j}/dashboard/groups/${e.id}`:void 0,z=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:[((B=s==null?void 0:s.members)==null?void 0:B.length)??0," ",(((K=s==null?void 0:s.members)==null?void 0:K.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),a.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(Y=s==null?void 0:s.members)==null?void 0:Y.map(W=>a.jsxs("div",{className:"member-row",children:[a.jsx("div",{className:"member-avatar",children:W.name.split(" ").map(T=>T[0]).join("").slice(0,2).toUpperCase()}),a.jsxs("div",{className:"member-info",children:[a.jsx("div",{className:"member-name",children:W.name}),a.jsx("div",{className:"member-email",children:W.email})]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:W.role})]},W.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:[C&&a.jsx("a",{className:"btn btn-secondary btn-sm",href:C,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."}),z&&a.jsx("a",{className:"btn btn-primary btn-sm",href:z,target:"_blank",rel:"noopener noreferrer",children:"Open Service Provider dashboard →"})]}),p&&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:R,children:a.jsxs("div",{className:"card",onClick:W=>W.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:W=>y(W.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:R,disabled:i,children:"Cancel"}),a.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:P,disabled:!b,children:i?"Leaving...":"Leave team"})]})]})})]})}function Hy({onDismiss:e}){const t=en(),{group:n,groupId:r,domain:s}=Le(),[o,i]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState([]),[m,p]=u.useState(!0),[x,w]=u.useState({}),[y,j]=u.useState(null);u.useEffect(()=>{Promise.all([A.listProfiles().catch(()=>[]),A.getIntegrationManifests().then(C=>C.manifests??[]).catch(()=>[]),A.getMcpHealth().then(C=>C.integrations??[]).catch(()=>[])]).then(async([C,z,B])=>{if(i(C),c(z),f(B),r){const K=await Promise.all(C.map(W=>A.getTeamProfileConfig(r,W.id).catch(()=>null))),Y={};C.forEach((W,T)=>{const X=K[T];X&&(Y[W.id]=X)}),w(Y)}}).finally(()=>p(!1))},[r]);const h=new Map;for(const C of l)C.profile&&h.set(C.profile,C);const g=C=>C.replace(/@.*$/,"").split("/").pop()??C,v=C=>C.split("@")[1]??"",S=new Map;for(const C of o){const z=g(C.id);if(!h.has(z))continue;const B=S.get(z);(!B||v(C.id).localeCompare(v(B.id),void 0,{numeric:!0})>0)&&S.set(z,C)}const b=l.map(C=>{const z=C.profile?S.get(C.profile):void 0;return z?{manifest:C,profile:z,integration:d.find(B=>B.id===C.id)}:null}).filter(C=>C!==null),I=C=>C in x,R=(C,z)=>{if(!r){console.error("No active group when creating authorization");return}const B=I(C);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:C,groupId:r,groupName:(n==null?void 0:n.name)??null,domain:s,isTeam:B})),z?sessionStorage.setItem("agentGate",JSON.stringify({bounds:z.bounds,context:z.context,gateContent:{intent:z.intent},ttlConfig:{max:z.ttl},templateMode:z.mode,templateTtl:z.ttl})):sessionStorage.removeItem("agentGate"),j(null),e==null||e(),t("/agent/gate")},P=(C,z)=>{r&&(z!=null&&z.templates&&z.templates.length>0?j({profileId:C,manifest:z}):R(C))};if(y){const C=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(C.length,3)}, 1fr)`},children:C.map(z=>a.jsxs("button",{className:"template-card",onClick:()=>R(y.profileId,z),children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.375rem"},children:[a.jsx("span",{className:`template-mode template-mode-${z.mode==="automatic"?"auto":"review"}`,children:z.mode==="automatic"?"Auto":"Review"}),a.jsx("span",{className:"template-risk","data-risk":z.risk,children:z.risk})]}),a.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.25rem"},children:z.name}),a.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",lineHeight:1.45,marginBottom:"0.5rem"},children:z.description}),a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.3rem"},children:z.tags.map(B=>a.jsx("span",{className:"template-tag",children:B},B))})]},z.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:()=>R(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
|
+
`}),m?a.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):b.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(Je,{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:b.map(({manifest:C,profile:z,integration:B})=>{const K=I(z.id),Y=(B==null?void 0:B.running)===!0;return a.jsxs("div",{className:"card",style:Y?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:C.name}),K?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:C.description||z.description}),Y?a.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>P(z.id,C),children:"Authorize"}):a.jsxs(Je,{to:`/integrations?setup=${(C==null?void 0:C.id)??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",(C==null?void 0:C.name)??"integration"]})]},C.id)})})]})}const Vy={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function Gy({status:e,label:t}){return a.jsx("span",{className:`status-badge status-${e}`,children:t||Vy[e]})}function Ky({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 En=86400,Ar=3600,Ms=60,Yy=30*En;function Qy(e){if(e<=0)return"Expired";if(e>90*En){const t=Math.floor(e/Yy);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*En){const t=Math.floor(e/En);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*En){const t=Math.floor(e/En),n=Math.floor(e%En/Ar);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*Ar){const t=Math.floor(e/Ar),n=Math.floor(e%Ar/Ms);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=Ms){const t=Math.floor(e/Ms),n=Math.floor(e%Ms);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function Jy({expiresAt:e}){const[t,n]=u.useState(()=>e-Date.now()/1e3),r=t<2*Ar;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:Qy(t)})}function ep({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 Xy(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 qy=[{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 Zy({item:e,onClose:t,onSuccess:n}){var v;const{user:r,activeDomain:s,groupId:o}=Le(),[i,l]=u.useState(null);u.useEffect(()=>{let S=!1;return A.getProfile(e.profile_id).then(b=>{var I;S||l(((I=b==null?void 0:b.ttl)==null?void 0:I.max)??null)}).catch(()=>{}),()=>{S=!0}},[e.profile_id]);const c=e.remaining_seconds??0,d=qy.filter(S=>S.seconds>c&&(i===null||S.seconds<=i)),f=((v=d[0])==null?void 0:v.seconds)??2592e3,[m,p]=u.useState(f);u.useEffect(()=>{var S;if(i!==null&&m>i){const b=(S=d[d.length-1])==null?void 0:S.seconds;b&&p(b)}},[i]);const[x,w]=u.useState(!1),[y,j]=u.useState(""),h=Object.entries(e.frame).filter(([S])=>S!=="profile"&&S!=="path"),g=async()=>{var S;if(r){w(!0),j("");try{const b=e.authorization_id,I=await A.getGateContent(b);if(!I)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const R=await A.getProfile(e.profile_id),P=e.frame,C=I.context??{},z=e.attested_domains[0]||s||"owner",B=await qs(P,R),K=await Xf(C,R),[Y,W]=await Promise.all([Ca(I.gateContent.intent),Ca(JSON.stringify({profile:e.profile_id,path:e.path,domain:z}))]);if(!o)throw new Error("No active group; cannot extend authorization.");const T=(((S=e.deferred_commitment_domains)==null?void 0:S.length)??0)>0?"review":"automatic",X=await A.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:P,bounds_hash:B,context_hash:K,domain:z,did:r.did,gate_content_hashes:{intent:Y},execution_context_hash:W,group_id:o,commitment_mode:T,ttl:m});await A.pushGateContent(qf(X,{boundsHash:B,contextHash:K,context:C,path:e.path,gateContent:I.gateContent})),n()}catch(b){j(b instanceof Error?b.message:"Extension failed")}finally{w(!1)}}};return a.jsx("div",{className:"modal-backdrop",onClick:S=>S.target===S.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:[Te(e.profile_id)," / ",e.path]}),h.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:h.map(([S,b])=>`${S}=${b}`).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"}),c>0&&a.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",Xy(c),". Only longer durations are shown."]}),a.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:d.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."}):d.map(S=>a.jsx("button",{className:`btn ${m===S.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>p(S.seconds),style:{minWidth:"3.5rem"},children:S.label},S.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)."}),y&&a.jsx("div",{className:"error-message",children:y})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx("button",{className:"btn btn-secondary",onClick:t,disabled:x,children:"Cancel"}),a.jsx("button",{className:"btn btn-primary",onClick:g,disabled:x,children:x?"Extending...":"Extend"})]})]})})}function ex(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=Lt(r,{revokedSet:t}),i=Lt(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 tx({item:e,newerProfile:t,revokedSet:n,expandedHash:r,gateCache:s,gateLoading:o,copiedHash:i,revokingHash:l,copyingHash:c,profileConfigCache:d,mode:f,ownerLabel:m,isAdmin:p,onExpand:x,onCopyHash:w,onCopy:y,onRevoke:j,onExtend:h,highlightHash:g}){var D;const v=Lt(e,{revokedSet:n}),S=r===e.authorization_id,b=s[e.authorization_id],I=v==="active"||v==="pending"||v==="expired",R=Object.entries(e.frame).filter(([F])=>F!=="profile"&&F!=="path"),P=d.get(e.profile_id)??null,C=(((D=P==null?void 0:P.approvers)==null?void 0:D.length)??0)>0,z=new Map;if(P!=null&&P.caps&&f==="team")for(const[F,G]of R){const q=P.caps[F];q!==void 0&&Number(G)>q&&z.set(F,{authorized:Number(G),cap:q})}const B=z.size>0,K=e.approvers_frozen??[],Y=(P==null?void 0:P.approvers)??[],W=f==="team"&&K.length>0&&Y.length>0&&(K.length!==Y.length||K.some(F=>!Y.includes(F))||Y.some(F=>!K.includes(F))),T=Array.from(z.entries()).map(([F,G])=>`${F}: ${G.authorized} (cap ${G.cap})`).join(", "),X=Array.from(z.entries()).map(([F,G])=>`${F}: ${G.authorized} → ${G.cap}`).join(", "),te=B?C?z.size===1?`Above team cap: ${T} — actions require approval`:`Above team cap (${z.size}): ${T} — actions require approval`:z.size===1?`Reduced by hard cap: ${X}`:`Reduced by hard cap (${z.size}): ${X}`:"",M=B?C?"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,$=Te(e.profile_id),H=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,_=g!=null&&e.authorization_id===g;return a.jsxs("div",{className:`card${_?" card-highlight":""}`,style:{marginBottom:0},children:[H,m&&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:m})]}),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(Gy,{status:v}),v==="active"&&e.earliest_expiry&&a.jsx(Jy,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),v==="expired"&&(()=>{const F=vv(e,v);return F?a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(F.iso).toLocaleString()}`,children:new Date(F.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}):null})()]}),a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[e.required_domains.map(F=>a.jsx(Ky,{domain:F,attested:e.attested_domains.includes(F)},F)),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"}),B&&a.jsx("span",{title:M,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:C?"var(--accent-subtle)":"var(--danger-subtle)",color:C?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:te}),W&&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"})]}),R.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:R.map(([F,G],q)=>{const ee=z.get(F);return a.jsxs("span",{children:[q>0&&" · ",ee?C?a.jsxs("span",{title:`Team cap on ${F} is ${ee.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${ee.authorized}.`,children:[a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[F,"=",String(G)]}),a.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",ee.cap]})]}):a.jsxs("span",{title:`Team cap on ${F} is ${ee.cap} with no approvers configured (hard cap). Authorized for ${ee.authorized}; effective ${ee.cap}.`,children:[a.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[F,"=",String(G)]}),a.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",ee.cap]})]}):a.jsxs("span",{children:[F,"=",String(G)]})]},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",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:[R.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:R.map(([F,G])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:F}),a.jsx("dd",{children:String(G)})]},F))})]}),(b==null?void 0:b.context)&&Object.keys(b.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(b.context).map(([F,G])=>a.jsxs("span",{style:{display:"contents"},children:[a.jsx("dt",{children:F}),a.jsx("dd",{title:String(G),children:Zf(F,G,b.contextLabels)})]},F))})]}),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..."}):b?a.jsx("div",{className:"gate-content-block",children:a.jsx("div",{className:"gate-content-item",children:a.jsx("div",{className:"gate-content-text",children:b.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:[!m&&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"}),!m&&(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"}),!m&&I&&a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>h(e),children:"↻ Extend"}),m&&p&&v!=="revoked"?a.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>j(e.authorization_id,m,$),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):!m&&(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 nx(){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,m]=u.useState("mine"),[p,x]=u.useState("active"),[w,y]=u.useState(null),[j,h]=u.useState(null),[g,v]=$f(),[S,b]=u.useState(()=>g.get("new")==="1"),[I,R]=u.useState(()=>g.get("highlight")),[P,C]=u.useState(null),[z,B]=u.useState({}),[K,Y]=u.useState(null),[W,T]=u.useState(null),[X,te]=u.useState(null),[M,$]=u.useState(new Set),[H,_]=u.useState(null),[D,F]=u.useState(null),G=en(),{group:q,groupId:ee,domain:ue,mode:Me,activeTeam:De}=Le(),le=(De==null?void 0:De.isAdmin)===!0,[L,J]=u.useState(()=>new Map),ne=u.useCallback(()=>{r(!0),A.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),pe=u.useCallback(()=>{ee&&(l(!0),A.listTeamAuthorizations(ee).then(o).catch(()=>{}).finally(()=>l(!1)))},[ee]);ce("attestation-changed",()=>{ne(),le&&ee&&pe()}),u.useEffect(()=>{if(!I)return;g.get("highlight")&&(g.delete("highlight"),v(g,{replace:!0}));const k=window.setTimeout(()=>R(null),3e3);return()=>window.clearTimeout(k)},[]),Ft(ne,3e5),u.useEffect(()=>{f==="team"&&le&&ee&&s.length===0&&!i&&pe()},[f,le,ee,s.length,i,pe]),u.useEffect(()=>{let k=!1;return A.listProfiles().then(E=>{if(k)return;const U=Pe=>Pe.replace(/@.*$/,"").split("/").pop()??Pe,Z=Pe=>Pe.split("@")[1]??"",re=new Map;for(const Pe of E){const Ye=U(Pe.id),je=re.get(Ye);(!je||Z(Pe.id).localeCompare(Z(je.id),void 0,{numeric:!0})>0)&&re.set(Ye,Pe)}d(re)}).catch(()=>{}),()=>{k=!0}},[]);const me=u.useCallback(k=>{const E=Ye=>Ye.replace(/@.*$/,"").split("/").pop()??Ye,U=Ye=>Ye.split("@")[1]??"",Z=c.get(E(k));if(!Z)return;const re=U(k),Pe=U(Z.id);if(!(!re||!Pe))return Pe.localeCompare(re,void 0,{numeric:!0})>0?Z:void 0},[c]);u.useEffect(()=>{if(Me!=="team"||!ee)return;const k=f==="mine"?e:s;if(k.length===0)return;const E=[...new Set(k.map(U=>U.profile_id))].filter(U=>!L.has(U));if(E.length!==0){J(U=>{const Z=new Map(U);for(const re of E)Z.set(re,null);return Z});for(const U of E)A.getTeamProfileConfig(ee,U).then(Z=>{J(re=>new Map(re).set(U,Z))}).catch(()=>{})}},[e,s,f,ee,Me,L]);const ze=async k=>{if(P===k.authorization_id){C(null);return}C(k.authorization_id);const E=k.authorization_id;if(!(E in z)){Y(k.authorization_id);try{const U=await A.getGateContent(E);B(Z=>({...Z,[E]:U}))}catch{B(U=>({...U,[E]:null}))}finally{Y(null)}}},kt=k=>{navigator.clipboard.writeText(k).then(()=>{te(k),setTimeout(()=>te(null),2e3)})},Ie=async(k,E)=>{var U;if(!ee){alert("No active group; cannot copy authorization.");return}F(k.authorization_id);try{const Z=k.authorization_id;let re=z[Z]??null;Z in z||(re=await A.getGateContent(Z),B(oe=>({...oe,[Z]:re})));const Pe=Object.fromEntries(Object.entries(k.frame).filter(([oe])=>oe!=="profile"&&oe!=="path")),Ye=(re==null?void 0:re.context)??{},je=((U=re==null?void 0:re.gateContent)==null?void 0:U.intent)??"",mt=k.deferred_commitment_domains.length>0?"review":"automatic",bt=k.attested_domains[0]||ue||"owner",We=Date.parse(k.created_at),Ut=k.earliest_expiry?Date.parse(k.earliest_expiry):NaN,Ct=Number.isFinite(We)&&Number.isFinite(Ut)&&Ut>We?Math.round((Ut-We)/1e3):void 0;sessionStorage.setItem("agentAuth",JSON.stringify({profileId:k.profile_id,groupId:ee,groupName:(q==null?void 0:q.name)??null,domain:bt})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:Pe,context:Ye,gateContent:{intent:je},templateMode:mt,templateTtl:Ct})),E!=null&&E.asEdit?sessionStorage.setItem("agentEditReplaces",k.authorization_id):sessionStorage.removeItem("agentEditReplaces"),G("/agent/gate")}catch(Z){alert(Z instanceof Error?Z.message:"Failed to copy authorization")}finally{F(null)}},pt=async(k,E,U)=>{const Z=E&&U?`Revoke ${E}'s ${U} authorization? This cannot be undone.`:"Revoke this authorization? The agent will no longer be able to execute actions under this attestation.";if(confirm(Z)){_(k);try{await A.revokeAttestation(k),$(re=>new Set(re).add(k)),A.resyncGates().catch(()=>{}),E&&ee&&pe()}catch(re){alert(re instanceof Error?re.message:"Failed to revoke authorization")}finally{_(null)}}},Re=f==="mine"?e:s,et=f==="mine"?n:i,ae={active:Re.filter(k=>Lt(k,{revokedSet:M})==="active").length,pending:Re.filter(k=>Lt(k,{revokedSet:M})==="pending").length,expired:Re.filter(k=>Lt(k,{revokedSet:M})==="expired").length,revoked:Re.filter(k=>Lt(k,{revokedSet:M})==="revoked").length},Ue=(()=>{const k=new Map;for(const E of Re){if(Lt(E,{revokedSet:M})!==p)continue;const U=k.get(E.profile_id)??{count:0,review:!1};U.count+=1,E.deferred_commitment_domains.length>0&&(U.review=!0),k.set(E.profile_id,U)}return Array.from(k.entries()).map(([E,U])=>({profileId:E,...U})).sort((E,U)=>Te(E.profileId).localeCompare(Te(U.profileId)))})(),V=ex(Re.filter(k=>{if(Lt(k,{revokedSet:M})!==p||w!==null&&k.profile_id!==w)return!1;if(j!==null){const E=k.deferred_commitment_domains.length>0;if(j==="review"&&!E||j==="auto"&&E)return!1}return!0}),M,I),N={revokedSet:M,expandedHash:P,gateCache:z,gateLoading:K,copiedHash:X,revokingHash:H,copyingHash:D,profileConfigCache:L,mode:Me,activeDomain:ue,group:q,groupId:ee,onExpand:ze,onCopyHash:kt,onCopy:Ie,onRevoke:pt,onExtend:T,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:"Mandates"}),a.jsx("p",{className:"page-subtitle",children:"Active, pending, and expired agent authorizations."})]}),a.jsx("button",{className:"btn btn-primary",onClick:()=>b(!0),children:"+ New authorization"})]}),S&&a.jsx("div",{className:"modal-backdrop",onClick:()=>{b(!1),g.get("new")&&(g.delete("new"),v(g,{replace:!0}))},children:a.jsxs("div",{className:"modal",onClick:k=>k.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:()=>{b(!1),g.get("new")&&(g.delete("new"),v(g,{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(Hy,{onDismiss:()=>b(!1)})]})]})}),le&&a.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[a.jsx("button",{className:`nav-tab${f==="mine"?" active":""}`,onClick:()=>{m("mine"),x("active"),y(null),h(null),C(null)},children:"Mine"}),a.jsx("button",{className:`nav-tab${f==="team"?" active":""}`,onClick:()=>{m("team"),x("active"),y(null),h(null),C(null)},children:"Team"})]}),a.jsx("div",{className:"nav-tabs",children:["active","pending","expired","revoked"].map(k=>a.jsxs("button",{className:`nav-tab${p===k?" active":""}`,onClick:()=>{x(k),y(null),h(null)},children:[k.charAt(0).toUpperCase()+k.slice(1)," (",ae[k],")"]},k))}),Ue.length>0&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[Ue.map(k=>{const E=w===k.profileId;return a.jsx("button",{className:`btn btn-sm ${E?"btn-primary":"btn-secondary"}`,onClick:()=>y(E?null:k.profileId),children:Te(k.profileId)},k.profileId)}),a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(k=>{const E=j===k;return a.jsx("button",{className:`btn btn-sm ${E?"btn-primary":"btn-secondary"}`,onClick:()=>h(E?null:k),children:k==="auto"?"Auto":"Review"},k)})]}),et&&Re.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):V.length===0?a.jsx(ep,{icon:"☰",title:"No authorizations",text:`No ${p} authorizations found.`}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:V.map(k=>{const E=f==="team"?k:null,U=E!=null&&E.owner?E.owner.name??E.owner.email??E.owner.userId:void 0;return a.jsx(tx,{item:k,newerProfile:me(k.profile_id),ownerLabel:U,isAdmin:le,...N},k.authorization_id)})}),W&&a.jsx(Zy,{item:W,onClose:()=>T(null),onSuccess:()=>{T(null),ne()}})]})}function rx(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function sx(e,t){var c,d,f;const{integrationId:n,toolName:r}=rx(e.action),s=t.find(m=>m.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=Te(e.profileId),l=(f=e.executionContext)==null?void 0:f.action_type;return typeof l=="string"&&l?`${i} · ${l}`:`${i} · ${r}`}function ax(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 ox(e){if(!e)return"";const t=[];for(const[n,r]of Object.entries(e)){if(n==="action_type")continue;const s=String(r??"").trim();if(!s)continue;const o=n.replace(/^allowed_/,"").replace(/_/g," ");t.push(`${o} ${s.split(",").map(i=>i.trim()).filter(Boolean).join(", ")}`)}return t.join(" · ")}function ix(e,t){var o,i;const n=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],r=e.actionType??(typeof((o=e.executionContext)==null?void 0:o.action_type)=="string"?e.executionContext.action_type:void 0),s=[];for(const{window:l,label:c}of n){const d=(i=e.cumulativeState)==null?void 0:i[l];if(!d)continue;const f=`_${l}_max`,m=Object.keys(t??{}).filter(j=>j.endsWith(f)),p=(r&&m.find(j=>j.startsWith(`${r}_`)))??(m.length===1?m[0]:void 0),w=(p?/^(amount|spend)_/.test(p):!1)?d.amount:d.count,y=p?Number(t==null?void 0:t[p]):NaN;p&&Number.isFinite(y)?s.push(`${w} of ${y} ${c}`):s.push(`${d.count} ${d.count===1?"call":"calls"} ${c}`)}return s.join(" · ")}function lx(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function cx(e){const t=Te(e),n=e.split("@")[1];return n?`${t}@${n}`:t}function zr({label:e,children:t}){return a.jsxs(a.Fragment,{children:[a.jsx("dt",{className:"receipt-row-label",children:e}),a.jsx("dd",{className:"receipt-row-value",children:t})]})}function ux({receipt:e,manifests:t,localAuth:n,localUnavailable:r,signature:s,grantTitle:o,ownerLabel:i,spUrl:l,formatDate:c,onOpenComplete:d}){var w;const f=ax(e),m=ox(n==null?void 0:n.context),p=ix(e,(n==null?void 0:n.bounds)??e.limits),x=n==null?void 0:n.intent;return a.jsxs("div",{className:"card",style:{marginBottom:0},children:[a.jsxs("div",{className:"receipt-head",children:[a.jsx("span",{className:"receipt-what",children:sx(e,t)}),a.jsx("span",{className:"receipt-tag",children:lx(e)?"review":"automatic"}),e.contentHash&&a.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(w=e.contentBinding)!=null&&w.fields?`The receipt binds: ${e.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),a.jsx("span",{className:"auth-card-time",children:c(e.timestamp)})]}),f&&a.jsx("div",{className:"receipt-scope",children:f}),a.jsxs("dl",{className:"receipt-rows",children:[a.jsx(zr,{label:"authorization",children:a.jsx("strong",{children:o||cx(e.profileId)})}),i&&a.jsx(zr,{label:"owner",children:i}),m&&a.jsx(zr,{label:"allowed",children:m}),p&&a.jsx(zr,{label:"used",children:a.jsx("span",{className:"receipt-num",children:p})}),a.jsx(zr,{label:"intent",children:x?a.jsx("span",{className:"receipt-intent",children:x}):a.jsx("span",{className:"receipt-absent",children:r?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]}),a.jsxs("div",{className:"receipt-foot",children:[s==="valid"&&a.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the receipt was issued — no Authority Server involved.",children:"✓ Verified on this device"}),s==="invalid"&&a.jsx("span",{className:"receipt-tamper",title:"The stored receipt does not match what was signed.",children:"⚠ Signature check FAILED"}),a.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:d,children:"Complete receipt"}),l&&a.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",a.jsx("a",{className:"receipt-link",href:`${l}/r/${e.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),a.jsxs("details",{className:"receipt-more",children:[a.jsx("summary",{children:"Raw"}),a.jsxs("div",{className:"receipt-kv",children:[a.jsxs("div",{children:["receipt · ",e.id]}),a.jsxs("div",{children:["action · ",e.action]}),a.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&a.jsxs("div",{children:["authorization · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&a.jsxs("div",{children:["context ·"," ",Object.entries(e.executionContext).map(([y,j])=>`${y}=${j}`).join(" · ")]}),(n==null?void 0:n.boundsHash)&&a.jsxs("div",{children:["bounds hash · ",n.boundsHash]}),(n==null?void 0:n.contextHash)&&a.jsxs("div",{children:["context hash · ",n.contextHash]}),e.contentHash&&a.jsxs("div",{children:["content · ",e.contentHash]}),e.proposalId&&a.jsxs("div",{children:["proposal · ",e.proposalId]}),a.jsxs("div",{children:["signature · ",e.signature]})]})]})]})}function dx({receipt:e,onClose:t}){const[n,r]=u.useState(null),[s,o]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState(!0),[f,m]=u.useState(!1);u.useEffect(()=>{let j=!1;return d(!0),A.getArchivedReceipt(e.id).then(h=>{j||(r(h),o(h?"local":"authority-server"),l((h==null?void 0:h.signature)??null))}).catch(()=>{j||o("authority-server")}).finally(()=>{j||d(!1)}),()=>{j=!0}},[e.id]);const p=n?n.entry:{receipt:e},x=JSON.stringify(p,null,2);function w(){const j=URL.createObjectURL(new Blob([x],{type:"application/json"})),h=document.createElement("a");h.href=j,h.download=`suveren-receipt-${e.id.slice(0,8)}.json`,h.click(),URL.revokeObjectURL(j)}async function y(){try{await navigator.clipboard.writeText(x),m(!0),setTimeout(()=>m(!1),2e3)}catch{m(!1)}}return a.jsx("div",{className:"modal-backdrop",onClick:j=>j.target===j.currentTarget&&t(),children:a.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h3",{className:"modal-title",children:"Complete receipt"}),a.jsx("button",{className:"modal-close",onClick:t,"aria-label":"Close",children:"×"})]}),a.jsxs("div",{className:"modal-body",children:[i==="valid"&&a.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this receipt was issued."}),i==="invalid"&&a.jsx("p",{className:"receipt-tamper",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"⚠ Signature check FAILED — the stored receipt does not match what was signed."}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:c?"Loading…":s==="local"?"Held on this device — the signed receipt, the attestation it ran under, and the issuer key. Anyone with this file and that key can verify it offline, without Suveren.":"No local copy of this receipt (it predates local archiving, or ran on another device). Shown from the Authority Server — complete and signed, but it needs the server to retrieve."}),a.jsx("pre",{style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.68rem",lineHeight:1.65,margin:0,background:"var(--accent-subtle)",border:"1px solid var(--border)",borderRadius:"6px",padding:"0.75rem 0.85rem",overflowX:"auto",maxHeight:"22rem",overflowY:"auto"},children:x})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx("button",{className:"btn btn-primary btn-sm",onClick:w,children:"Download"}),a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:y,children:f?"Copied":"Copy"})]})]})})}function fx(e){return new Date(e*1e3).toLocaleString()}function px(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 mx(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||Te(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 hx(){const{activeTeam:e,groupId:t}=Le(),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(""),[m,p]=u.useState(!0),[x,w]=u.useState({}),[y,j]=u.useState(new Set),[h,g]=u.useState(""),[v,S]=u.useState(new Set),[b,I]=u.useState(new Set),[R,P]=u.useState("all"),[C,z]=u.useState(!1),[B,K]=u.useState(!1),[Y,W]=u.useState(null),[T,X]=u.useState({}),[te,M]=u.useState(!1),[$,H]=u.useState({}),[_,D]=u.useState({}),[F,G]=u.useState(null),[q,ee]=u.useState(null),[ue,Me]=u.useState(!1),[De,le]=u.useState(!1),L=u.useRef(""),J=u.useCallback(N=>r==="team"&&n&&t?A.listTeamReceiptsPage(t,{before:N,limit:200}):A.getMyReceiptsPage({before:N,limit:200}),[r,n,t]),ne=u.useCallback(()=>{const N=r==="team"?`team:${t}`:"mine",k=L.current!==N;L.current=N,p(!0),le(!1),J().then(E=>{i(U=>k?E.receipts:Zc(U,E.receipts)),ee(U=>k?E.nextBefore:U??E.nextBefore)}).catch(()=>{k&&i([]),le(!0)}).finally(()=>p(!1))},[J,r,t]),pe=u.useCallback(()=>{!q||ue||(Me(!0),le(!1),J(q).then(N=>{i(k=>Zc(k,N.receipts)),ee(N.nextBefore)}).catch(()=>le(!0)).finally(()=>Me(!1)))},[q,ue,J]);Ft(ne,12e4),u.useEffect(()=>{A.getIntegrationManifests().then(({manifests:N})=>c(N)).catch(()=>{}),fetch("/health").then(N=>N.json()).then(N=>{typeof N.spUrl=="string"&&f(N.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),u.useEffect(()=>{A.getLocalAuthorizations().then(({authorizations:N,signatures:k})=>{X(N),H(k),M(!1)}).catch(()=>{X({}),H({}),M(!0)}),A.getMyAttestations().then(N=>{const k={};for(const E of N)E.authorization_id&&E.title&&(k[E.authorization_id]=E.title);D(k)}).catch(()=>{})},[]),u.useEffect(()=>{r!=="team"||Object.keys(x).length>0||A.listUsers().then(N=>{const k={};for(const E of N)k[E.id]={name:E.name,email:E.email};w(k)}).catch(()=>{})},[r,x]);const me=u.useMemo(()=>{const N=new Set;for(const k of o)N.add(Te(k.profileId));return[...N].sort()},[o]),ze=u.useMemo(()=>{const N=new Set;for(const k of o)N.add(k.action);return[...N].sort()},[o]),kt=u.useMemo(()=>{if(r!=="team")return[];const N=new Set;for(const k of o)k.userId&&N.add(k.userId);return[...N].map(k=>{var E;return{id:k,label:(E=x[k])!=null&&E.name?`${x[k].name} (${x[k].email})`:k}}).sort((k,E)=>k.label.localeCompare(E.label))},[r,o,x]),Ie=u.useMemo(()=>o.filter(N=>!(!mx(N,h)||v.size>0&&!v.has(Te(N.profileId))||b.size>0&&!b.has(N.action)||y.size>0&&N.userId&&!y.has(N.userId)||!px(N,R))),[o,h,v,b,y,R]),pt=v.size>0||b.size>0||y.size>0||R!=="all";function Re(N){S(k=>{const E=new Set(k);return E.has(N)?E.delete(N):E.add(N),E})}function et(N){I(k=>{const E=new Set(k);return E.has(N)?E.delete(N):E.add(N),E})}function ae(N){j(k=>{const E=new Set(k);return E.has(N)?E.delete(N):E.add(N),E})}function Ue(){S(new Set),I(new Set),j(new Set),P("all"),g("")}async function V(){K(!0),W(null);try{const{bundle:N,filename:k}=await A.fetchEvidenceBundle(),E=URL.createObjectURL(new Blob([JSON.stringify(N,null,2)],{type:"application/json"})),U=document.createElement("a");U.href=E,U.download=k,U.click(),URL.revokeObjectURL(E);const Z=N.sources??{};Z.authorityServer?Z.local||W(`Downloaded Authority Server history only — ${Z.localError??"local archive unavailable."}`):W(`Downloaded local evidence only — ${Z.asError??"Authority Server export unavailable."}`)}catch(N){W(`Export failed: ${N instanceof Error?N.message:String(N)}`)}finally{K(!1)}}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:"Tickets"}),a.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),a.jsx("button",{className:"btn btn-secondary",onClick:V,disabled:B,children:B?"Preparing…":"Download evidence"})]}),Y&&a.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:Y}),n&&a.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(N=>a.jsx("button",{onClick:()=>s(N),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===N?"2px solid var(--accent)":"2px solid transparent",color:r===N?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===N?600:500},children:N==="mine"?"Mine":"Team"},N))}),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:h,onChange:N=>g(N.target.value)}),h&&a.jsx("button",{className:"search-clear",onClick:()=>g(""),children:"×"})]}),a.jsxs("button",{className:`btn btn-sm btn-secondary${C?" active":""}`,onClick:()=>z(!C),children:["Filters",pt?` (${v.size+b.size+(R!=="all"?1:0)})`:""]})]}),C&&a.jsxs("div",{className:"filter-panel",children:[me.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Profile"}),a.jsx("div",{className:"filter-chips",children:me.map(N=>a.jsx("button",{className:`filter-chip${v.has(N)?" selected":""}`,onClick:()=>Re(N),children:N},N))})]}),ze.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Action"}),a.jsx("div",{className:"filter-chips",children:ze.map(N=>a.jsx("button",{className:`filter-chip${b.has(N)?" selected":""}`,onClick:()=>et(N),children:N},N))})]}),r==="team"&&kt.length>1&&a.jsxs("div",{className:"filter-section",children:[a.jsx("div",{className:"filter-label",children:"Owner"}),a.jsx("div",{className:"filter-chips",children:kt.map(N=>a.jsx("button",{className:`filter-chip${y.has(N.id)?" selected":""}`,onClick:()=>ae(N.id),children:N.label},N.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(([N,k])=>a.jsx("button",{className:`filter-chip${R===N?" selected":""}`,onClick:()=>P(N),children:k},N))})]})]}),pt&&a.jsxs("div",{className:"active-filters",children:[[...v].map(N=>a.jsxs("span",{className:"active-chip",onClick:()=>Re(N),children:[N," ",a.jsx("span",{className:"chip-remove",children:"×"})]},N)),[...b].map(N=>a.jsxs("span",{className:"active-chip",onClick:()=>et(N),children:[N," ",a.jsx("span",{className:"chip-remove",children:"×"})]},N)),[...y].map(N=>{const k=x[N],E=k?k.name:N;return a.jsxs("span",{className:"active-chip",onClick:()=>ae(N),children:[E," ",a.jsx("span",{className:"chip-remove",children:"×"})]},N)}),R!=="all"&&a.jsxs("span",{className:"active-chip",onClick:()=>P("all"),children:[R==="1d"?"Today":R==="7d"?"7 days":"30 days"," ",a.jsx("span",{className:"chip-remove",children:"×"})]}),a.jsx("button",{className:"clear-filters",onClick:Ue,children:"Clear all"})]}),De&&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."})}),m&&o.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Ie.length===0?a.jsx(ep,{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:Ie.length===o.length?`${o.length} receipt${o.length!==1?"s":""}`:`${Ie.length} of ${o.length} receipts`}),a.jsx("div",{className:"timeline",children:Ie.map(N=>{const k=N.userId?x[N.userId]:void 0;return a.jsx("div",{className:"timeline-event",children:a.jsx(ux,{receipt:N,manifests:l,localAuth:N.authorizationId?T[N.authorizationId]:void 0,localUnavailable:te,signature:$[N.id],grantTitle:N.authorizationId?_[N.authorizationId]:null,ownerLabel:r==="team"&&N.userId?k?`${k.name} (${k.email})`:N.userId:null,spUrl:d,formatDate:fx,onOpenComplete:()=>G(N)})},N.id)})})]}),F&&a.jsx(dx,{receipt:F,onClose:()=>G(null)}),q&&a.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:a.jsx("button",{className:"btn btn-secondary btn-sm",onClick:pe,disabled:ue,children:ue?"Loading…":"Load older"})})]})}const gx={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function vx(){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=gx[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 yx(){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 xx={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 wx(){const{version:e,latestVersion:t,updateAvailable:n,installMethod:r}=Nl();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:[xx[r]??"Update checking is unavailable",r==="dev"&&a.jsx(a.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}const Sx={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 jx(){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,m]=u.useState(""),[p,x]=u.useState(!1),[w,y]=u.useState(!1),[j,h]=u.useState(!1),[g,v]=u.useState(null),[S,b]=u.useState([]),[I,R]=u.useState(!1),[P,C]=u.useState(null),[z,B]=u.useState(""),K=u.useCallback($=>{t($),setTimeout(()=>t(""),3e3)},[]),Y=u.useCallback(async($,H,_)=>{R(!0),C(null);try{const D=await A.aiModels({provider:$,endpoint:H,..._?{apiKey:_}:{}});D.ok&&D.models.length>0?(b(D.models),C(`${D.models.length} models available`)):(b([]),C(D.message||"No models returned — using defaults"))}catch(D){b([]),C(D instanceof Error?D.message:"Failed to load models")}finally{R(!1)}},[]),W=u.useCallback(async()=>{try{const $=await A.getCredential("ai-config");if(x($.configured),$.configured&&$.fields){const H=$.fields.provider||"openai-compatible",_=$.fields.endpoint||"";$.fields.provider&&o(H),$.fields.endpoint&&l(_),$.fields.model&&d($.fields.model),_.includes("openai.com")?r("openai"):_.includes("groq.com")?r("groq"):_.includes("together.xyz")?r("together"):_.includes("openrouter.ai")?r("openrouter"):r("ollama"),_&&Y(H,_)}}catch{}},[Y]);u.useEffect(()=>{W()},[W]);const T=$=>{r($),b([]),C(null),B("");const H=Sx[$];H&&(o(H.provider),l(H.endpoint),d(""),Y(H.provider,H.endpoint,f||void 0))},X=()=>Y(s,i,f||void 0),te=async()=>{y(!0);try{await A.setCredential("ai-config",{provider:s,endpoint:i,model:c,...f?{apiKey:f}:{}}),x(!0),K("AI configuration saved!")}catch{K("Failed to save AI config")}finally{y(!1)}},M=async()=>{h(!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{h(!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."}),p&&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:$=>T($.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:$=>m($.target.value),onBlur:()=>{f.trim()&&Y(s,i,f.trim())},placeholder:p?"••••••••••••••••":"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:X,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,H=$.includes(c),_=$.length>12,D=z.trim().toLowerCase();let F=D?$.filter(G=>G.toLowerCase().includes(D)):$;return H&&!F.includes(c)&&(F=[c,...F]),a.jsxs(a.Fragment,{children:[_&&a.jsx("input",{className:"form-input",value:z,onChange:G=>B(G.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),a.jsxs("select",{className:"form-input",value:H?c:"__unset__",onChange:G=>d(G.target.value==="__unset__"?"":G.target.value),children:[a.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),F.map(G=>a.jsx("option",{value:G,children:G},G)),D&&F.length===0&&a.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",z,"”"]})]})]})})(),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:te,disabled:w||!c.trim(),title:c.trim()?void 0:"Select a model first",children:w?"Saving...":"Save & Encrypt"}),p&&a.jsx("button",{className:"btn btn-ghost",onClick:M,disabled:j,children:j?"Testing...":"Test Connection"})]}),g&&a.jsx("div",{className:`alert ${g.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:g})]}),a.jsx(kx,{}),a.jsx(vx,{}),a.jsx(yx,{}),a.jsx(wx,{}),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 kx(){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,m]=u.useState(!1),p=u.useCallback(async()=>{if(!f)try{const y=await A.getAIPrompts();t(y),r({intent:y.intent.current,context:y.context.current}),m(!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],h=j.trim()===e[y].default.trim()?"":j;await A.setAIPrompt(y,h);const g=await A.getAIPrompts();t(g),r({intent:g.intent.current,context:g.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&&p()},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:m=>o(m.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 bx(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=bx(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 Cx=["https://","http://"];function tp(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)?[]:Cx.some(s=>r.toLowerCase().startsWith(s))?[{label:n.label,href:r,description:n.description}]:[]}):[]}function Nx({profileId:e}){return a.jsx("span",{className:"profile-badge",children:Te(e)})}function np(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 Ex={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},Tx={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function zx(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 Ix(e){return e.split("__").pop()??e}function Rx(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}const Px=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]),_x=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function Ax(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:_x.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}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 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=Ix(l),d=Rx(l),f=o?e.proposal.toolArgs:null,m=o?e.proposal.executionContext:e.receipt.executionContext,p=o?null:e.receipt.cumulativeState,x=o?tp(s,e.proposal.toolArgs):[],w=f?Object.entries(f).filter(([j])=>!Px.has(j)):[],y=Object.entries(m??{});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(Nx,{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=np(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 ${Tx[i]}`,children:Ex[i]}),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:zx(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,h])=>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:Ax(j,h)?a.jsx("img",{src:h,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:g=>{const v=g.currentTarget,S=v.parentElement;if(!S)return;v.style.display="none";const b=document.createElement("span");b.textContent=h,b.style.color="var(--text-tertiary)",S.appendChild(b)}}):ki(h)})]},j))})]}),y.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:y.map(([j,h])=>`${j}=${ki(h)}`).join(" · ")}),p&&a.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",p.daily.count," action",p.daily.count===1?"":"s",p.daily.amount>0?`, ${p.daily.amount}`:""," · ","this month: ",p.monthly.count,p.monthly.amount>0?`, ${p.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 $x=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function bi(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=>bi(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Lx(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 Mx({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),[m,p]=u.useState(!1),[x,w]=u.useState(null),[y,j]=u.useState(!1),h=e.tool.split("__").pop()??e.tool,g=Object.entries(e.toolArgs).filter(([T])=>!$x.has(T)),v=Object.entries(e.executionContext),S=tp(s,e.toolArgs),b=e.pendingApprovers??[],I=e.approvedBy??{},R=Object.keys(I).length,P=b.filter(T=>!(T in I)).length,C=t in I,z=async()=>{if(d===null){p(!0),w(null);try{const T=await A.getAttestationIntent(e.authorizationId);if(!T){w("Intent not available or you are not an authorized approver.");return}const X=await A.decryptIntent({intentCiphertext:T.intentCiphertext,encryptedKey:T.encryptedKey,approverId:t});f(X)}catch(T){w(T instanceof Error?T.message:"Failed to decrypt intent")}finally{p(!1)}}},B=async()=>{y?j(!1):(j(!0),await z())},K=async()=>{i(!0),r("");try{await A.approveProposal(e.id);try{if(d===null){const T=await A.getAttestationIntent(e.authorizationId);if(T){const X=await A.decryptIntent({intentCiphertext:T.intentCiphertext,encryptedKey:T.encryptedKey,approverId:t});f(X),await A.storeApprovedIntent(e.authorizationId,X)}}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(T){r(T instanceof Error?T.message:"Approval failed")}finally{i(!1)}},Y=async()=>{const T=prompt("Rejection reason (optional):");if(T!==null){c(!0),r("");try{await A.rejectProposal(e.id,T||void 0),r("Action rejected."),n()}catch(X){r(X instanceof Error?X.message:"Rejection failed")}finally{c(!1)}}},W=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:Te(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 T=np(e.expiresAt,Date.now());return a.jsx("span",{style:{fontSize:"0.72rem",color:T.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:T.urgent?600:400,whiteSpace:"nowrap"},children:T.label})})(),a.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Lx(e.createdAt)})]})]}),a.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[R," of ",b.length," approver",b.length===1?"":"s"," signed off",b.map(T=>{const X=T in I;return a.jsxs("span",{style:{marginLeft:"0.5rem",color:X?"var(--success, green)":"var(--text-tertiary)"},children:[X?"✓":"○"," ",T===t?"You":T]},T)})]}),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:h})]}),S.length>0&&a.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:S.map(T=>a.jsxs("a",{href:T.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:T.description??T.href,children:[T.label," ↗"]},T.label))}),g.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:g.map(([T,X])=>a.jsxs(u.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:T}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:bi(X)})]},T))})]}),v.length>0&&a.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:v.map(([T,X])=>`${T}=${bi(X)}`).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:B,disabled:m,children:[y?"▲ Hide intent":"▼ Show intent",m&&" (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."})})]}),!C&&a.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[a.jsx("button",{className:"btn btn-primary",onClick:K,disabled:W,children:o?"Approving...":"Approve"}),a.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:Y,disabled:W,children:l?"Rejecting...":"Reject"})]}),C&&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 Fx(){const{domain:e,user:t}=Le(),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),[m,p]=u.useState(""),x=u.useCallback(async()=>{try{const L=await A.getProposalsForApprover();i(L)}catch{}finally{f(!1)}},[]);ce("proposal-added",x),ce("proposal-approved",x),ce("proposal-rejected",x),ce("proposal-resolved",x),Ft(x,3e4);const[w,y]=u.useState([]),j=u.useCallback(async()=>{try{const L=await A.getProposals(e||"owner");y(L)}catch{}},[e]);ce("proposal-added",j),ce("proposal-approved",j),ce("proposal-rejected",j),ce("proposal-resolved",j),Ft(j,3e4,e);const h=u.useMemo(()=>w.filter(L=>{var J;return L.status==="pending"&&(((J=L.pendingApprovers)==null?void 0:J.length)??0)===0}),[w]),g=u.useMemo(()=>tu(h,[],{status:"pending"}),[h]),[v,S]=u.useState([]),b=u.useCallback(async()=>{if(n)try{const J=(await A.getProposals(e||"owner")).filter(ne=>ne.status==="pending"&&ne.pendingApprovers&&ne.pendingApprovers.includes(n)&&ne.approvedBy&&n in ne.approvedBy);S(J)}catch{}},[n,e]);ce("proposal-approved",b),ce("proposal-rejected",b),Ft(b,3e4,`${n}:${e}`),u.useEffect(()=>{A.getIntegrationManifests().then(L=>c(L.manifests??[])).catch(()=>{})},[]);const I=L=>{var J;return(J=l.find(ne=>ne.id===L.split("__")[0]))==null?void 0:J.proposalLinks};u.useEffect(()=>{x(),j(),b()},[]);const[R,P]=u.useState([]),[C,z]=u.useState([]),[B,K]=u.useState(!0),[Y,W]=u.useState(null),[T,X]=u.useState(""),[te,M]=u.useState("pending"),[$,H]=u.useState(null),[_,D]=u.useState(!1),F=u.useCallback(async()=>{try{const{proposals:L,receipts:J}=await A.getThread({domain:e,status:te,sinceDays:7});P(L),z(J)}catch{}finally{K(!1)}},[e,te]);Ft(F,3e4,`${e}:${te}`);const G=async(L,J)=>{W(L),X("");try{const ne=e||"owner",pe=await A.resolveProposal(L,J,ne);X(J==="commit"?`Action approved. Status: ${pe.status}`:"Action rejected."),await Promise.all([F(),j()])}catch(ne){X(ne instanceof Error?ne.message:"Failed")}finally{W(null)}},q=u.useMemo(()=>{const L=new Set;for(const J of R)L.add(J.profileId);for(const J of C)L.add(J.profileId);return Array.from(L).sort()},[R,C]),ee=u.useMemo(()=>tu(R,C,{status:te,profile:$??void 0,includeAutonomous:_}),[R,C,te,$,_]),ue=u.useCallback(()=>{x(),b()},[x,b]),Me=u.useMemo(()=>{const L=new Set,J=[];for(const ne of v)L.has(ne.id)||(L.add(ne.id),J.push(ne));return J.sort((ne,pe)=>pe.createdAt-ne.createdAt)},[v]),De=o.length+g.length,le=Me.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 ",De>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:De})]}),a.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>s("awaiting-others"),children:["Awaiting others ",le>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:le})]}),a.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{s("all"),F()},children:"All"})]}),r==="awaiting-me"&&a.jsx(a.Fragment,{children:d&&De===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):De===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:[(m||T)&&a.jsx("div",{className:"alert alert-success",children:m||T}),g.map(L=>a.jsx(nu,{proposalLinks:L.kind==="proposal"?I(L.proposal.tool):void 0,item:L,onApprove:J=>G(J,"commit"),onReject:J=>G(J,"reject"),resolving:Y===L.id},L.id)),o.map(L=>a.jsx(Mx,{proposal:L,currentUserId:n,onAction:ue,onMessage:p,proposalLinks:I(L.tool)},L.id))]})}),r==="awaiting-others"&&a.jsx(a.Fragment,{children:Me.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:Me.map(L=>a.jsx(Bx,{proposal:L,currentUserId:n,onCancel:async()=>{try{await A.rejectProposal(L.id,"cancelled by creator"),b(),j()}catch(J){alert(J instanceof Error?J.message:"Cancel failed")}}},L.id))})}),r==="all"&&a.jsxs(a.Fragment,{children:[T&&a.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:T}),a.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[a.jsx("button",{className:`filter-chip ${te==="pending"?"selected":""}`,onClick:()=>M("pending"),children:"Pending"}),a.jsx("button",{className:`filter-chip ${te==="all"?"selected":""}`,onClick:()=>M("all"),children:"All"}),q.length>0&&a.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),q.map(L=>a.jsx("button",{className:`filter-chip ${$===L?"selected":""}`,onClick:()=>H($===L?null:L),children:Te(L)},L)),te==="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 ${_?"selected":""}`,onClick:()=>D(!_),title:"Include actions executed without human review (automatic commitment mode)",children:[_?"✓ ":"","Autonomous actions"]})]})]}),B&&ee.length===0?a.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ee.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:te==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),a.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:te==="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:ee.map(L=>a.jsx(nu,{proposalLinks:L.kind==="proposal"?I(L.proposal.tool):void 0,item:L,onApprove:J=>G(J,"commit"),onReject:J=>G(J,"reject"),resolving:Y===L.id},L.id))})]})]})}function Ox(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 Bx({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:Te(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:Ox(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 Dx=`# 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 Ux(){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,m]=u.useState(!1),p=e!==n,x=new Blob([e]).size,w=16*1024;u.useEffect(()=>{if(!p)return;const g=S=>{S.preventDefault(),S.returnValue=""},v=S=>{var R,P;if(S.defaultPrevented||S.button!==0||S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const b=(P=(R=S.target)==null?void 0:R.closest)==null?void 0:P.call(R,"a");if(!b||!b.href)return;let I;try{I=new URL(b.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",g),document.addEventListener("click",v,!0),()=>{window.removeEventListener("beforeunload",g),document.removeEventListener("click",v,!0)}},[p]),u.useEffect(()=>{let g=!1;return A.getAgentContext().then(v=>{g||(t(v),r(v))}).catch(v=>{g||d({kind:"error",text:v instanceof Error?v.message:"Failed to load context"})}).finally(()=>{g||o(!1)}),()=>{g=!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(g){d({kind:"error",text:g instanceof Error?g.message:"Save failed"})}finally{l(!1)}},j=()=>{t(n),d(null)},h=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(Dx)};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:h,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(ba,{target:{kind:"context"},currentText:e,onApply:g=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(g)},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:g=>t(g.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||!p,children:"Revert"}),a.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:y,disabled:i||!p||x>w||s,children:i?"Saving…":"Save"})]})]}),a.jsx("button",{type:"button",className:"floating-help",onClick:()=>m(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),a.jsx(Yf,{open:f,onClose:()=>m(!1),ariaLabel:"Brief assistant",children:a.jsx(ba,{target:{kind:"context"},currentText:e,onApply:g=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(g),m(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Wx({children:e}){const{user:t,mode:n,domain:r}=Le();return t?n==="team"&&!r?a.jsx(sn,{to:"/onboarding",replace:!0}):a.jsx(a.Fragment,{children:e}):a.jsx(sn,{to:"/login",replace:!0})}function Hx(){const{user:e}=Le();return a.jsxs(Ig,{children:[a.jsx(_e,{path:"/login",element:e?a.jsx(sn,{to:"/",replace:!0}):a.jsx(Gv,{})}),a.jsx(_e,{path:"/onboarding",element:e?a.jsx(Kv,{}):a.jsx(sn,{to:"/login",replace:!0})}),a.jsxs(_e,{element:a.jsx(Wx,{children:a.jsx(Vv,{})}),children:[a.jsx(_e,{path:"/",element:a.jsx(ay,{})}),a.jsx(_e,{path:"/agent/new",element:a.jsx(sn,{to:"/authorizations?new=1",replace:!0})}),a.jsx(_e,{path:"/agent/gate",element:a.jsx(Iy,{})}),a.jsx(_e,{path:"/agent/review",element:a.jsx(My,{})}),a.jsx(_e,{path:"/integrations",element:a.jsx(Uy,{})}),a.jsx(_e,{path:"/groups",element:a.jsx(Wy,{})}),a.jsx(_e,{path:"/authorizations",element:a.jsx(nx,{})}),a.jsx(_e,{path:"/audit",element:a.jsx(hx,{})}),a.jsx(_e,{path:"/proposals",element:a.jsx(Fx,{})}),a.jsx(_e,{path:"/agent-brief",element:a.jsx(Ux,{})}),a.jsx(_e,{path:"/settings",element:a.jsx(jx,{})}),a.jsx(_e,{path:"/settings/services",element:a.jsx(sn,{to:"/settings",replace:!0})}),a.jsx(_e,{path:"/deploy",element:a.jsx(sn,{to:"/integrations",replace:!0})})]}),a.jsx(_e,{path:"*",element:a.jsx(sn,{to:"/",replace:!0})})]})}function Vx(){return a.jsx(tv,{children:a.jsx(dv,{children:a.jsx(fv,{children:a.jsx(Hx,{})})})})}vf(document.getElementById("root")).render(a.jsx(u.StrictMode,{children:a.jsx(Vx,{})}));
|