@suveren/gateway 0.19.1 → 0.19.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var hh=Object.defineProperty;var ph=(e,t,n)=>t in e?hh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Er=(e,t,n)=>ph(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();var Qu={exports:{}},Ba={},Ju={exports:{}},ce={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@ var rp=Object.defineProperty;var sp=(e,t,n)=>t in e?rp(e,t,{enumerable:!0,config
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var vs=Symbol.for("react.element"),gh=Symbol.for("react.portal"),yh=Symbol.for("react.fragment"),vh=Symbol.for("react.strict_mode"),xh=Symbol.for("react.profiler"),wh=Symbol.for("react.provider"),jh=Symbol.for("react.context"),Sh=Symbol.for("react.forward_ref"),kh=Symbol.for("react.suspense"),bh=Symbol.for("react.memo"),Nh=Symbol.for("react.lazy"),oc=Symbol.iterator;function Ch(e){return e===null||typeof e!="object"?null:(e=oc&&e[oc]||e["@@iterator"],typeof e=="function"?e:null)}var Xu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},qu=Object.assign,Zu={};function jr(e,t,n){this.props=e,this.context=t,this.refs=Zu,this.updater=n||Xu}jr.prototype.isReactComponent={};jr.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")};jr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ed(){}ed.prototype=jr.prototype;function Yo(e,t,n){this.props=e,this.context=t,this.refs=Zu,this.updater=n||Xu}var Qo=Yo.prototype=new ed;Qo.constructor=Yo;qu(Qo,jr.prototype);Qo.isPureReactComponent=!0;var lc=Array.isArray,td=Object.prototype.hasOwnProperty,Jo={current:null},nd={key:!0,ref:!0,__self:!0,__source:!0};function rd(e,t,n){var r,a={},i=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)td.call(t,r)&&!nd.hasOwnProperty(r)&&(a[r]=t[r]);var l=arguments.length-2;if(l===1)a.children=n;else if(1<l){for(var c=Array(l),d=0;d<l;d++)c[d]=arguments[d+2];a.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)a[r]===void 0&&(a[r]=l[r]);return{$$typeof:vs,type:e,key:i,ref:o,props:a,_owner:Jo.current}}function Eh(e,t){return{$$typeof:vs,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Xo(e){return typeof e=="object"&&e!==null&&e.$$typeof===vs}function Th(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var cc=/\/+/g;function ui(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Th(""+e.key):t.toString(36)}function Qs(e,t,n,r,a){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case vs:case gh:o=!0}}if(o)return o=e,a=a(o),e=r===""?"."+ui(o,0):r,lc(a)?(n="",e!=null&&(n=e.replace(cc,"$&/")+"/"),Qs(a,t,n,"",function(d){return d})):a!=null&&(Xo(a)&&(a=Eh(a,n+(!a.key||o&&o.key===a.key?"":(""+a.key).replace(cc,"$&/")+"/")+e)),t.push(a)),1;if(o=0,r=r===""?".":r+":",lc(e))for(var l=0;l<e.length;l++){i=e[l];var c=r+ui(i,l);o+=Qs(i,t,n,c,a)}else if(c=Ch(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=r+ui(i,l++),o+=Qs(i,t,n,c,a);else if(i==="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 o}function Es(e,t,n){if(e==null)return e;var r=[],a=0;return Qs(e,r,"","",function(i){return t.call(n,i,a++)}),r}function Ih(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 rt={current:null},Js={transition:null},Rh={ReactCurrentDispatcher:rt,ReactCurrentBatchConfig:Js,ReactCurrentOwner:Jo};function sd(){throw Error("act(...) is not supported in production builds of React.")}ce.Children={map:Es,forEach:function(e,t,n){Es(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Es(e,function(){t++}),t},toArray:function(e){return Es(e,function(t){return t})||[]},only:function(e){if(!Xo(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ce.Component=jr;ce.Fragment=yh;ce.Profiler=xh;ce.PureComponent=Yo;ce.StrictMode=vh;ce.Suspense=kh;ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Rh;ce.act=sd;ce.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=qu({},e.props),a=e.key,i=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,o=Jo.current),t.key!==void 0&&(a=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)td.call(t,c)&&!nd.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:vs,type:e.type,key:a,ref:i,props:r,_owner:o}};ce.createContext=function(e){return e={$$typeof:jh,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:wh,_context:e},e.Consumer=e};ce.createElement=rd;ce.createFactory=function(e){var t=rd.bind(null,e);return t.type=e,t};ce.createRef=function(){return{current:null}};ce.forwardRef=function(e){return{$$typeof:Sh,render:e}};ce.isValidElement=Xo;ce.lazy=function(e){return{$$typeof:Nh,_payload:{_status:-1,_result:e},_init:Ih}};ce.memo=function(e,t){return{$$typeof:bh,type:e,compare:t===void 0?null:t}};ce.startTransition=function(e){var t=Js.transition;Js.transition={};try{e()}finally{Js.transition=t}};ce.unstable_act=sd;ce.useCallback=function(e,t){return rt.current.useCallback(e,t)};ce.useContext=function(e){return rt.current.useContext(e)};ce.useDebugValue=function(){};ce.useDeferredValue=function(e){return rt.current.useDeferredValue(e)};ce.useEffect=function(e,t){return rt.current.useEffect(e,t)};ce.useId=function(){return rt.current.useId()};ce.useImperativeHandle=function(e,t,n){return rt.current.useImperativeHandle(e,t,n)};ce.useInsertionEffect=function(e,t){return rt.current.useInsertionEffect(e,t)};ce.useLayoutEffect=function(e,t){return rt.current.useLayoutEffect(e,t)};ce.useMemo=function(e,t){return rt.current.useMemo(e,t)};ce.useReducer=function(e,t,n){return rt.current.useReducer(e,t,n)};ce.useRef=function(e){return rt.current.useRef(e)};ce.useState=function(e){return rt.current.useState(e)};ce.useSyncExternalStore=function(e,t,n){return rt.current.useSyncExternalStore(e,t,n)};ce.useTransition=function(){return rt.current.useTransition()};ce.version="18.3.1";Ju.exports=ce;var u=Ju.exports;/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.production.min.js
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@ var rp=Object.defineProperty;var sp=(e,t,n)=>t in e?rp(e,t,{enumerable:!0,config
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var Ph=u,Ah=Symbol.for("react.element"),_h=Symbol.for("react.fragment"),Lh=Object.prototype.hasOwnProperty,zh=Ph.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,$h={key:!0,ref:!0,__self:!0,__source:!0};function ad(e,t,n){var r,a={},i=null,o=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)Lh.call(t,r)&&!$h.hasOwnProperty(r)&&(a[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)a[r]===void 0&&(a[r]=t[r]);return{$$typeof:Ah,type:e,key:i,ref:o,props:a,_owner:zh.current}}Ba.Fragment=_h;Ba.jsx=ad;Ba.jsxs=ad;Qu.exports=Ba;var s=Qu.exports,id={exports:{}},gt={},od={exports:{}},ld={};/**
|
|
18
18
|
* @license React
|
|
19
19
|
* scheduler.production.min.js
|
|
20
20
|
*
|
|
@@ -22,7 +22,7 @@ var rp=Object.defineProperty;var sp=(e,t,n)=>t in e?rp(e,t,{enumerable:!0,config
|
|
|
22
22
|
*
|
|
23
23
|
* This source code is licensed under the MIT license found in the
|
|
24
24
|
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/(function(e){function t(_,P){var V=_.length;_.push(P);e:for(;0<V;){var R=V-1>>>1
|
|
25
|
+
*/(function(e){function t(_,P){var V=_.length;_.push(P);e:for(;0<V;){var R=V-1>>>1,$=_[R];if(0<a($,P))_[R]=P,_[V]=$,V=R;else break e}}function n(_){return _.length===0?null:_[0]}function r(_){if(_.length===0)return null;var P=_[0],V=_.pop();if(V!==P){_[0]=V;e:for(var R=0,$=_.length,Y=$>>>1;R<Y;){var te=2*(R+1)-1,ne=_[te],de=te+1,xe=_[de];if(0>a(ne,V))de<$&&0>a(xe,ne)?(_[R]=xe,_[de]=V,R=de):(_[R]=ne,_[te]=V,R=te);else if(de<$&&0>a(xe,V))_[R]=xe,_[de]=V,R=de;else break e}}return P}function a(_,P){var V=_.sortIndex-P.sortIndex;return V!==0?V:_.id-P.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],d=[],f=1,h=null,m=3,x=!1,w=!1,v=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,p=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(_){for(var P=n(d);P!==null;){if(P.callback===null)r(d);else if(P.startTime<=_)r(d),P.sortIndex=P.expirationTime,t(c,P);else break;P=n(d)}}function j(_){if(v=!1,y(_),!w)if(n(c)!==null)w=!0,H(b);else{var P=n(d);P!==null&&O(j,P.startTime-_)}}function b(_,P){w=!1,v&&(v=!1,g(I),I=-1),x=!0;var V=m;try{for(y(P),h=n(c);h!==null&&(!(h.expirationTime>P)||_&&!D());){var R=h.callback;if(typeof R=="function"){h.callback=null,m=h.priorityLevel;var $=R(h.expirationTime<=P);P=e.unstable_now(),typeof $=="function"?h.callback=$:h===n(c)&&r(c),y(P)}else r(c);h=n(c)}if(h!==null)var Y=!0;else{var te=n(d);te!==null&&O(j,te.startTime-P),Y=!1}return Y}finally{h=null,m=V,x=!1}}var C=!1,N=null,I=-1,E=5,A=-1;function D(){return!(e.unstable_now()-A<E)}function L(){if(N!==null){var _=e.unstable_now();A=_;var P=!0;try{P=N(!0,_)}finally{P?K():(C=!1,N=null)}}else C=!1}var K;if(typeof p=="function")K=function(){p(L)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,Q=z.port2;z.port1.onmessage=L,K=function(){Q.postMessage(null)}}else K=function(){S(L,0)};function H(_){N=_,C||(C=!0,K())}function O(_,P){I=S(function(){_(e.unstable_now())},P)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(_){_.callback=null},e.unstable_continueExecution=function(){w||x||(w=!0,H(b))},e.unstable_forceFrameRate=function(_){0>_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<_?Math.floor(1e3/_):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(_){switch(m){case 1:case 2:case 3:var P=3;break;default:P=m}var V=m;m=P;try{return _()}finally{m=V}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(_,P){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var V=m;m=_;try{return P()}finally{m=V}},e.unstable_scheduleCallback=function(_,P,V){var R=e.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?R+V:R):V=R,_){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=V+$,_={id:f++,callback:P,priorityLevel:_,startTime:V,expirationTime:$,sortIndex:-1},V>R?(_.sortIndex=V,t(d,_),n(c)===null&&_===n(d)&&(v?(g(I),I=-1):v=!0,O(j,V-R))):(_.sortIndex=$,t(c,_),w||x||(w=!0,H(b))),_},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(_){var P=m;return function(){var V=m;m=P;try{return _.apply(this,arguments)}finally{m=V}}}})(ld);od.exports=ld;var Mh=od.exports;/**
|
|
26
26
|
* @license React
|
|
27
27
|
* react-dom.production.min.js
|
|
28
28
|
*
|
|
@@ -30,15 +30,15 @@ var rp=Object.defineProperty;var sp=(e,t,n)=>t in e?rp(e,t,{enumerable:!0,config
|
|
|
30
30
|
*
|
|
31
31
|
* This source code is licensed under the MIT license found in the
|
|
32
32
|
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var
|
|
34
|
-
`+
|
|
33
|
+
*/var Fh=u,pt=Mh;function M(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 cd=new Set,ts={};function Wn(e,t){mr(e,t),mr(e+"Capture",t)}function mr(e,t){for(ts[e]=t,e=0;e<t.length;e++)cd.add(t[e])}var Qt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Gi=Object.prototype.hasOwnProperty,Oh=/^[: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]*$/,uc={},dc={};function Bh(e){return Gi.call(dc,e)?!0:Gi.call(uc,e)?!1:Oh.test(e)?dc[e]=!0:(uc[e]=!0,!1)}function Dh(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 Uh(e,t,n,r){if(t===null||typeof t>"u"||Dh(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 st(e,t,n,r,a,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var Ve={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ve[e]=new st(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ve[t]=new st(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ve[e]=new st(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ve[e]=new st(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){Ve[e]=new st(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ve[e]=new st(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ve[e]=new st(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ve[e]=new st(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ve[e]=new st(e,5,!1,e.toLowerCase(),null,!1,!1)});var qo=/[\-:]([a-z])/g;function Zo(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(qo,Zo);Ve[t]=new st(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(qo,Zo);Ve[t]=new st(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(qo,Zo);Ve[t]=new st(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ve[e]=new st(e,1,!1,e.toLowerCase(),null,!1,!1)});Ve.xlinkHref=new st("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ve[e]=new st(e,1,!1,e.toLowerCase(),null,!0,!0)});function el(e,t,n,r){var a=Ve.hasOwnProperty(t)?Ve[t]:null;(a!==null?a.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Uh(t,n,a,r)&&(n=null),r||a===null?Bh(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):a.mustUseProperty?e[a.propertyName]=n===null?a.type===3?!1:"":n:(t=a.attributeName,r=a.attributeNamespace,n===null?e.removeAttribute(t):(a=a.type,n=a===3||a===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var en=Fh.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Ts=Symbol.for("react.element"),Qn=Symbol.for("react.portal"),Jn=Symbol.for("react.fragment"),tl=Symbol.for("react.strict_mode"),Ki=Symbol.for("react.profiler"),ud=Symbol.for("react.provider"),dd=Symbol.for("react.context"),nl=Symbol.for("react.forward_ref"),Yi=Symbol.for("react.suspense"),Qi=Symbol.for("react.suspense_list"),rl=Symbol.for("react.memo"),sn=Symbol.for("react.lazy"),fd=Symbol.for("react.offscreen"),fc=Symbol.iterator;function Tr(e){return e===null||typeof e!="object"?null:(e=fc&&e[fc]||e["@@iterator"],typeof e=="function"?e:null)}var Re=Object.assign,di;function Br(e){if(di===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);di=t&&t[1]||""}return`
|
|
34
|
+
`+di+e}var fi=!1;function mi(e,t){if(!e||fi)return"";fi=!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 a=d.stack.split(`
|
|
35
35
|
`),i=r.stack.split(`
|
|
36
36
|
`),o=a.length-1,l=i.length-1;1<=o&&0<=l&&a[o]!==i[l];)l--;for(;1<=o&&0<=l;o--,l--)if(a[o]!==i[l]){if(o!==1||l!==1)do if(o--,l--,0>l||a[o]!==i[l]){var c=`
|
|
37
|
-
`+a[o].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=o&&0<=l);break}}}finally{ui=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Fr(e):""}function Ap(e){switch(e.tag){case 5:return Fr(e.type);case 16:return Fr("Lazy");case 13:return Fr("Suspense");case 19:return Fr("SuspenseList");case 0:case 2:case 15:return e=di(e.type,!1),e;case 11:return e=di(e.type.render,!1),e;case 1:return e=di(e.type,!0),e;default:return""}}function Ki(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 Qn:return"Fragment";case Yn:return"Portal";case Hi:return"Profiler";case qo:return"StrictMode";case Vi:return"Suspense";case Gi:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case rd:return(e.displayName||"Context")+".Consumer";case nd:return(e._context.displayName||"Context")+".Provider";case Zo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case el:return t=e.displayName||null,t!==null?t:Ki(e.type)||"Memo";case sn:t=e._payload,e=e._init;try{return Ki(e(t))}catch{}}return null}function _p(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 Ki(t);case 8:return t===qo?"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 xn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ad(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function zp(e){var t=ad(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var a=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ts(e){e._valueTracker||(e._valueTracker=zp(e))}function id(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=ad(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function ua(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 Yi(e,t){var n=t.checked;return Re({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ic(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=xn(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 od(e,t){t=t.checked,t!=null&&Xo(e,"checked",t,!1)}function Qi(e,t){od(e,t);var n=xn(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")?Ji(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ji(e,t.type,xn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function oc(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 Ji(e,t,n){(t!=="number"||ua(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Or=Array.isArray;function ir(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+xn(n),t=null,a=0;a<e.length;a++){if(e[a].value===n){e[a].selected=!0,r&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function Xi(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(M(91));return Re({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function lc(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(M(92));if(Or(n)){if(1<n.length)throw Error(M(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:xn(n)}}function ld(e,t){var n=xn(t.value),r=xn(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 cc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function cd(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 qi(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?cd(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Is,ud=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,a){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,a)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Is=Is||document.createElement("div"),Is.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Is.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function es(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Wr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},$p=["Webkit","ms","Moz","O"];Object.keys(Wr).forEach(function(e){$p.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Wr[t]=Wr[e]})});function dd(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Wr.hasOwnProperty(e)&&Wr[e]?(""+t).trim():t+"px"}function fd(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=dd(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var Lp=Re({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 Zi(e,t){if(t){if(Lp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(M(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(M(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(M(61))}if(t.style!=null&&typeof t.style!="object")throw Error(M(62))}}function eo(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 to=null;function tl(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var no=null,or=null,lr=null;function uc(e){if(e=ws(e)){if(typeof no!="function")throw Error(M(280));var t=e.stateNode;t&&(t=Ha(t),no(e.stateNode,e.type,t))}}function md(e){or?lr?lr.push(e):lr=[e]:or=e}function pd(){if(or){var e=or,t=lr;if(lr=or=null,uc(e),t)for(e=0;e<t.length;e++)uc(t[e])}}function hd(e,t){return e(t)}function gd(){}var fi=!1;function yd(e,t,n){if(fi)return e(t,n);fi=!0;try{return hd(e,t,n)}finally{fi=!1,(or!==null||lr!==null)&&(gd(),pd())}}function ts(e,t){var n=e.stateNode;if(n===null)return null;var r=Ha(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(M(231,t,typeof n));return n}var ro=!1;if(Qt)try{var Er={};Object.defineProperty(Er,"passive",{get:function(){ro=!0}}),window.addEventListener("test",Er,Er),window.removeEventListener("test",Er,Er)}catch{ro=!1}function Mp(e,t,n,r,a,i,o,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(f){this.onError(f)}}var Hr=!1,da=null,fa=!1,so=null,Fp={onError:function(e){Hr=!0,da=e}};function Op(e,t,n,r,a,i,o,l,c){Hr=!1,da=null,Mp.apply(Fp,arguments)}function Bp(e,t,n,r,a,i,o,l,c){if(Op.apply(this,arguments),Hr){if(Hr){var d=da;Hr=!1,da=null}else throw Error(M(198));fa||(fa=!0,so=d)}}function Wn(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 vd(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 dc(e){if(Wn(e)!==e)throw Error(M(188))}function Dp(e){var t=e.alternate;if(!t){if(t=Wn(e),t===null)throw Error(M(188));return t!==e?null:e}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var i=a.alternate;if(i===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===i.child){for(i=a.child;i;){if(i===n)return dc(a),e;if(i===r)return dc(a),t;i=i.sibling}throw Error(M(188))}if(n.return!==r.return)n=a,r=i;else{for(var o=!1,l=a.child;l;){if(l===n){o=!0,n=a,r=i;break}if(l===r){o=!0,r=a,n=i;break}l=l.sibling}if(!o){for(l=i.child;l;){if(l===n){o=!0,n=i,r=a;break}if(l===r){o=!0,r=i,n=a;break}l=l.sibling}if(!o)throw Error(M(189))}}if(n.alternate!==r)throw Error(M(190))}if(n.tag!==3)throw Error(M(188));return n.stateNode.current===n?e:t}function xd(e){return e=Dp(e),e!==null?wd(e):null}function wd(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=wd(e);if(t!==null)return t;e=e.sibling}return null}var jd=pt.unstable_scheduleCallback,fc=pt.unstable_cancelCallback,Up=pt.unstable_shouldYield,Wp=pt.unstable_requestPaint,ze=pt.unstable_now,Hp=pt.unstable_getCurrentPriorityLevel,nl=pt.unstable_ImmediatePriority,Sd=pt.unstable_UserBlockingPriority,ma=pt.unstable_NormalPriority,Vp=pt.unstable_LowPriority,kd=pt.unstable_IdlePriority,Ba=null,Bt=null;function Gp(e){if(Bt&&typeof Bt.onCommitFiberRoot=="function")try{Bt.onCommitFiberRoot(Ba,e,void 0,(e.current.flags&128)===128)}catch{}}var _t=Math.clz32?Math.clz32:Qp,Kp=Math.log,Yp=Math.LN2;function Qp(e){return e>>>=0,e===0?32:31-(Kp(e)/Yp|0)|0}var Rs=64,Ps=4194304;function Br(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function pa(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,a=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var l=o&~a;l!==0?r=Br(l):(i&=o,i!==0&&(r=Br(i)))}else o=n&~a,o!==0?r=Br(o):i!==0&&(r=Br(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&a)&&(a=r&-r,i=t&-t,a>=i||a===16&&(i&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-_t(t),a=1<<n,r|=e[n],t&=~a;return r}function Jp(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 Xp(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-_t(i),l=1<<o,c=a[o];c===-1?(!(l&n)||l&r)&&(a[o]=Jp(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function ao(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function bd(){var e=Rs;return Rs<<=1,!(Rs&4194240)&&(Rs=64),e}function mi(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function vs(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-_t(t),e[t]=n}function qp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var a=31-_t(n),i=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~i}}function rl(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-_t(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var ye=0;function Nd(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Cd,sl,Ed,Td,Id,io=!1,As=[],dn=null,fn=null,mn=null,ns=new Map,rs=new Map,on=[],Zp="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 mc(e,t){switch(e){case"focusin":case"focusout":dn=null;break;case"dragenter":case"dragleave":fn=null;break;case"mouseover":case"mouseout":mn=null;break;case"pointerover":case"pointerout":ns.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":rs.delete(t.pointerId)}}function Tr(e,t,n,r,a,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[a]},t!==null&&(t=ws(t),t!==null&&sl(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function eh(e,t,n,r,a){switch(t){case"focusin":return dn=Tr(dn,e,t,n,r,a),!0;case"dragenter":return fn=Tr(fn,e,t,n,r,a),!0;case"mouseover":return mn=Tr(mn,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return ns.set(i,Tr(ns.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,rs.set(i,Tr(rs.get(i)||null,e,t,n,r,a)),!0}return!1}function Rd(e){var t=Rn(e.target);if(t!==null){var n=Wn(t);if(n!==null){if(t=n.tag,t===13){if(t=vd(n),t!==null){e.blockedOn=t,Id(e.priority,function(){Ed(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 Js(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=oo(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);to=r,n.target.dispatchEvent(r),to=null}else return t=ws(n),t!==null&&sl(t),e.blockedOn=n,!1;t.shift()}return!0}function pc(e,t,n){Js(e)&&n.delete(t)}function th(){io=!1,dn!==null&&Js(dn)&&(dn=null),fn!==null&&Js(fn)&&(fn=null),mn!==null&&Js(mn)&&(mn=null),ns.forEach(pc),rs.forEach(pc)}function Ir(e,t){e.blockedOn===t&&(e.blockedOn=null,io||(io=!0,pt.unstable_scheduleCallback(pt.unstable_NormalPriority,th)))}function ss(e){function t(a){return Ir(a,e)}if(0<As.length){Ir(As[0],e);for(var n=1;n<As.length;n++){var r=As[n];r.blockedOn===e&&(r.blockedOn=null)}}for(dn!==null&&Ir(dn,e),fn!==null&&Ir(fn,e),mn!==null&&Ir(mn,e),ns.forEach(t),rs.forEach(t),n=0;n<on.length;n++)r=on[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<on.length&&(n=on[0],n.blockedOn===null);)Rd(n),n.blockedOn===null&&on.shift()}var cr=en.ReactCurrentBatchConfig,ha=!0;function nh(e,t,n,r){var a=ye,i=cr.transition;cr.transition=null;try{ye=1,al(e,t,n,r)}finally{ye=a,cr.transition=i}}function rh(e,t,n,r){var a=ye,i=cr.transition;cr.transition=null;try{ye=4,al(e,t,n,r)}finally{ye=a,cr.transition=i}}function al(e,t,n,r){if(ha){var a=oo(e,t,n,r);if(a===null)ki(e,t,r,ga,n),mc(e,r);else if(eh(a,e,t,n,r))r.stopPropagation();else if(mc(e,r),t&4&&-1<Zp.indexOf(e)){for(;a!==null;){var i=ws(a);if(i!==null&&Cd(i),i=oo(e,t,n,r),i===null&&ki(e,t,r,ga,n),i===a)break;a=i}a!==null&&r.stopPropagation()}else ki(e,t,r,null,n)}}var ga=null;function oo(e,t,n,r){if(ga=null,e=tl(r),e=Rn(e),e!==null)if(t=Wn(e),t===null)e=null;else if(n=t.tag,n===13){if(e=vd(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 ga=e,null}function Pd(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(Hp()){case nl:return 1;case Sd:return 4;case ma:case Vp:return 16;case kd:return 536870912;default:return 16}default:return 16}}var cn=null,il=null,Xs=null;function Ad(){if(Xs)return Xs;var e,t=il,n=t.length,r,a="value"in cn?cn.value:cn.textContent,i=a.length;for(e=0;e<n&&t[e]===a[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===a[i-r];r++);return Xs=a.slice(e,1<r?1-r:void 0)}function qs(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 _s(){return!0}function hc(){return!1}function gt(e){function t(n,r,a,i,o){this._reactName=n,this._targetInst=a,this.type=r,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?_s:hc,this.isPropagationStopped=hc,this}return Re(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=_s)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=_s)},persist:function(){},isPersistent:_s}),t}var wr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ol=gt(wr),xs=Re({},wr,{view:0,detail:0}),sh=gt(xs),pi,hi,Rr,Da=Re({},xs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ll,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!==Rr&&(Rr&&e.type==="mousemove"?(pi=e.screenX-Rr.screenX,hi=e.screenY-Rr.screenY):hi=pi=0,Rr=e),pi)},movementY:function(e){return"movementY"in e?e.movementY:hi}}),gc=gt(Da),ah=Re({},Da,{dataTransfer:0}),ih=gt(ah),oh=Re({},xs,{relatedTarget:0}),gi=gt(oh),lh=Re({},wr,{animationName:0,elapsedTime:0,pseudoElement:0}),ch=gt(lh),uh=Re({},wr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),dh=gt(uh),fh=Re({},wr,{data:0}),yc=gt(fh),mh={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ph={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"},hh={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function gh(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=hh[e])?!!t[e]:!1}function ll(){return gh}var yh=Re({},xs,{key:function(e){if(e.key){var t=mh[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=qs(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?ph[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ll,charCode:function(e){return e.type==="keypress"?qs(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?qs(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),vh=gt(yh),xh=Re({},Da,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),vc=gt(xh),wh=Re({},xs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ll}),jh=gt(wh),Sh=Re({},wr,{propertyName:0,elapsedTime:0,pseudoElement:0}),kh=gt(Sh),bh=Re({},Da,{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}),Nh=gt(bh),Ch=[9,13,27,32],cl=Qt&&"CompositionEvent"in window,Vr=null;Qt&&"documentMode"in document&&(Vr=document.documentMode);var Eh=Qt&&"TextEvent"in window&&!Vr,_d=Qt&&(!cl||Vr&&8<Vr&&11>=Vr),xc=" ",wc=!1;function zd(e,t){switch(e){case"keyup":return Ch.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $d(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Jn=!1;function Th(e,t){switch(e){case"compositionend":return $d(t);case"keypress":return t.which!==32?null:(wc=!0,xc);case"textInput":return e=t.data,e===xc&&wc?null:e;default:return null}}function Ih(e,t){if(Jn)return e==="compositionend"||!cl&&zd(e,t)?(e=Ad(),Xs=il=cn=null,Jn=!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 _d&&t.locale!=="ko"?null:t.data;default:return null}}var Rh={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 jc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Rh[e.type]:t==="textarea"}function Ld(e,t,n,r){md(r),t=ya(t,"onChange"),0<t.length&&(n=new ol("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Gr=null,as=null;function Ph(e){Kd(e,0)}function Ua(e){var t=Zn(e);if(id(t))return e}function Ah(e,t){if(e==="change")return t}var Md=!1;if(Qt){var yi;if(Qt){var vi="oninput"in document;if(!vi){var Sc=document.createElement("div");Sc.setAttribute("oninput","return;"),vi=typeof Sc.oninput=="function"}yi=vi}else yi=!1;Md=yi&&(!document.documentMode||9<document.documentMode)}function kc(){Gr&&(Gr.detachEvent("onpropertychange",Fd),as=Gr=null)}function Fd(e){if(e.propertyName==="value"&&Ua(as)){var t=[];Ld(t,as,e,tl(e)),yd(Ph,t)}}function _h(e,t,n){e==="focusin"?(kc(),Gr=t,as=n,Gr.attachEvent("onpropertychange",Fd)):e==="focusout"&&kc()}function zh(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ua(as)}function $h(e,t){if(e==="click")return Ua(t)}function Lh(e,t){if(e==="input"||e==="change")return Ua(t)}function Mh(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var $t=typeof Object.is=="function"?Object.is:Mh;function is(e,t){if($t(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!Wi.call(t,a)||!$t(e[a],t[a]))return!1}return!0}function bc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Nc(e,t){var n=bc(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=bc(n)}}function Od(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Od(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Bd(){for(var e=window,t=ua();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=ua(e.document)}return t}function ul(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 Fh(e){var t=Bd(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Od(n.ownerDocument.documentElement,n)){if(r!==null&&ul(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=n.textContent.length,i=Math.min(r.start,a);r=r.end===void 0?i:Math.min(r.end,a),!e.extend&&i>r&&(a=r,r=i,i=a),a=Nc(n,i);var o=Nc(n,r);a&&o&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.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 Oh=Qt&&"documentMode"in document&&11>=document.documentMode,Xn=null,lo=null,Kr=null,co=!1;function Cc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;co||Xn==null||Xn!==ua(r)||(r=Xn,"selectionStart"in r&&ul(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}),Kr&&is(Kr,r)||(Kr=r,r=ya(lo,"onSelect"),0<r.length&&(t=new ol("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Xn)))}function zs(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var qn={animationend:zs("Animation","AnimationEnd"),animationiteration:zs("Animation","AnimationIteration"),animationstart:zs("Animation","AnimationStart"),transitionend:zs("Transition","TransitionEnd")},xi={},Dd={};Qt&&(Dd=document.createElement("div").style,"AnimationEvent"in window||(delete qn.animationend.animation,delete qn.animationiteration.animation,delete qn.animationstart.animation),"TransitionEvent"in window||delete qn.transitionend.transition);function Wa(e){if(xi[e])return xi[e];if(!qn[e])return e;var t=qn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Dd)return xi[e]=t[n];return e}var Ud=Wa("animationend"),Wd=Wa("animationiteration"),Hd=Wa("animationstart"),Vd=Wa("transitionend"),Gd=new Map,Ec="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 jn(e,t){Gd.set(e,t),Un(t,[e])}for(var wi=0;wi<Ec.length;wi++){var ji=Ec[wi],Bh=ji.toLowerCase(),Dh=ji[0].toUpperCase()+ji.slice(1);jn(Bh,"on"+Dh)}jn(Ud,"onAnimationEnd");jn(Wd,"onAnimationIteration");jn(Hd,"onAnimationStart");jn("dblclick","onDoubleClick");jn("focusin","onFocus");jn("focusout","onBlur");jn(Vd,"onTransitionEnd");fr("onMouseEnter",["mouseout","mouseover"]);fr("onMouseLeave",["mouseout","mouseover"]);fr("onPointerEnter",["pointerout","pointerover"]);fr("onPointerLeave",["pointerout","pointerover"]);Un("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Un("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Un("onBeforeInput",["compositionend","keypress","textInput","paste"]);Un("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Un("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Un("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Dr="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(" "),Uh=new Set("cancel close invalid load scroll toggle".split(" ").concat(Dr));function Tc(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Bp(r,t,void 0,e),e.currentTarget=null}function Kd(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var o=r.length-1;0<=o;o--){var l=r[o],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==i&&a.isPropagationStopped())break e;Tc(a,l,d),i=c}else for(o=0;o<r.length;o++){if(l=r[o],c=l.instance,d=l.currentTarget,l=l.listener,c!==i&&a.isPropagationStopped())break e;Tc(a,l,d),i=c}}}if(fa)throw e=so,fa=!1,so=null,e}function we(e,t){var n=t[ho];n===void 0&&(n=t[ho]=new Set);var r=e+"__bubble";n.has(r)||(Yd(t,e,2,!1),n.add(r))}function Si(e,t,n){var r=0;t&&(r|=4),Yd(n,e,r,t)}var $s="_reactListening"+Math.random().toString(36).slice(2);function os(e){if(!e[$s]){e[$s]=!0,td.forEach(function(n){n!=="selectionchange"&&(Uh.has(n)||Si(n,!1,e),Si(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[$s]||(t[$s]=!0,Si("selectionchange",!1,t))}}function Yd(e,t,n,r){switch(Pd(t)){case 1:var a=nh;break;case 4:a=rh;break;default:a=al}n=a.bind(null,t,n,e),a=void 0,!ro||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),r?a!==void 0?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):a!==void 0?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function ki(e,t,n,r,a){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var l=r.stateNode.containerInfo;if(l===a||l.nodeType===8&&l.parentNode===a)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===a||c.nodeType===8&&c.parentNode===a))return;o=o.return}for(;l!==null;){if(o=Rn(l),o===null)return;if(c=o.tag,c===5||c===6){r=i=o;continue e}l=l.parentNode}}r=r.return}yd(function(){var d=i,f=tl(n),m=[];e:{var p=Gd.get(e);if(p!==void 0){var x=ol,w=e;switch(e){case"keypress":if(qs(n)===0)break e;case"keydown":case"keyup":x=vh;break;case"focusin":w="focus",x=gi;break;case"focusout":w="blur",x=gi;break;case"beforeblur":case"afterblur":x=gi;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=gc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=ih;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=jh;break;case Ud:case Wd:case Hd:x=ch;break;case Vd:x=kh;break;case"scroll":x=sh;break;case"wheel":x=Nh;break;case"copy":case"cut":case"paste":x=dh;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=vc}var v=(t&4)!==0,S=!v&&e==="scroll",g=v?p!==null?p+"Capture":null:p;v=[];for(var h=d,y;h!==null;){y=h;var j=y.stateNode;if(y.tag===5&&j!==null&&(y=j,g!==null&&(j=ts(h,g),j!=null&&v.push(ls(h,j,y)))),S)break;h=h.return}0<v.length&&(p=new x(p,w,null,n,f),m.push({event:p,listeners:v}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",p&&n!==to&&(w=n.relatedTarget||n.fromElement)&&(Rn(w)||w[Jt]))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?Rn(w):null,w!==null&&(S=Wn(w),w!==S||w.tag!==5&&w.tag!==6)&&(w=null)):(x=null,w=d),x!==w)){if(v=gc,j="onMouseLeave",g="onMouseEnter",h="mouse",(e==="pointerout"||e==="pointerover")&&(v=vc,j="onPointerLeave",g="onPointerEnter",h="pointer"),S=x==null?p:Zn(x),y=w==null?p:Zn(w),p=new v(j,h+"leave",x,n,f),p.target=S,p.relatedTarget=y,j=null,Rn(f)===d&&(v=new v(g,h+"enter",w,n,f),v.target=y,v.relatedTarget=S,j=v),S=j,x&&w)t:{for(v=x,g=w,h=0,y=v;y;y=Vn(y))h++;for(y=0,j=g;j;j=Vn(j))y++;for(;0<h-y;)v=Vn(v),h--;for(;0<y-h;)g=Vn(g),y--;for(;h--;){if(v===g||g!==null&&v===g.alternate)break t;v=Vn(v),g=Vn(g)}v=null}else v=null;x!==null&&Ic(m,p,x,v,!1),w!==null&&S!==null&&Ic(m,S,w,v,!0)}}e:{if(p=d?Zn(d):window,x=p.nodeName&&p.nodeName.toLowerCase(),x==="select"||x==="input"&&p.type==="file")var b=Ah;else if(jc(p))if(Md)b=Lh;else{b=zh;var C=_h}else(x=p.nodeName)&&x.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(b=$h);if(b&&(b=b(e,d))){Ld(m,b,n,f);break e}C&&C(e,p,d),e==="focusout"&&(C=p._wrapperState)&&C.controlled&&p.type==="number"&&Ji(p,"number",p.value)}switch(C=d?Zn(d):window,e){case"focusin":(jc(C)||C.contentEditable==="true")&&(Xn=C,lo=d,Kr=null);break;case"focusout":Kr=lo=Xn=null;break;case"mousedown":co=!0;break;case"contextmenu":case"mouseup":case"dragend":co=!1,Cc(m,n,f);break;case"selectionchange":if(Oh)break;case"keydown":case"keyup":Cc(m,n,f)}var N;if(cl)e:{switch(e){case"compositionstart":var I="onCompositionStart";break e;case"compositionend":I="onCompositionEnd";break e;case"compositionupdate":I="onCompositionUpdate";break e}I=void 0}else Jn?zd(e,n)&&(I="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(I="onCompositionStart");I&&(_d&&n.locale!=="ko"&&(Jn||I!=="onCompositionStart"?I==="onCompositionEnd"&&Jn&&(N=Ad()):(cn=f,il="value"in cn?cn.value:cn.textContent,Jn=!0)),C=ya(d,I),0<C.length&&(I=new yc(I,e,null,n,f),m.push({event:I,listeners:C}),N?I.data=N:(N=$d(n),N!==null&&(I.data=N)))),(N=Eh?Th(e,n):Ih(e,n))&&(d=ya(d,"onBeforeInput"),0<d.length&&(f=new yc("onBeforeInput","beforeinput",null,n,f),m.push({event:f,listeners:d}),f.data=N))}Kd(m,t)})}function ls(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ya(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,i=a.stateNode;a.tag===5&&i!==null&&(a=i,i=ts(e,n),i!=null&&r.unshift(ls(e,i,a)),i=ts(e,t),i!=null&&r.push(ls(e,i,a))),e=e.return}return r}function Vn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Ic(e,t,n,r,a){for(var i=t._reactName,o=[];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,a?(c=ts(n,i),c!=null&&o.unshift(ls(n,c,l))):a||(c=ts(n,i),c!=null&&o.push(ls(n,c,l)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Wh=/\r\n?/g,Hh=/\u0000|\uFFFD/g;function Rc(e){return(typeof e=="string"?e:""+e).replace(Wh,`
|
|
38
|
-
`).replace(Hh,"")}function Ls(e,t,n){if(t=Rc(t),Rc(e)!==t&&n)throw Error(M(425))}function va(){}var uo=null,fo=null;function mo(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 po=typeof setTimeout=="function"?setTimeout:void 0,Vh=typeof clearTimeout=="function"?clearTimeout:void 0,Pc=typeof Promise=="function"?Promise:void 0,Gh=typeof queueMicrotask=="function"?queueMicrotask:typeof Pc<"u"?function(e){return Pc.resolve(null).then(e).catch(Kh)}:po;function Kh(e){setTimeout(function(){throw e})}function bi(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&a.nodeType===8)if(n=a.data,n==="/$"){if(r===0){e.removeChild(a),ss(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);ss(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 Ac(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 jr=Math.random().toString(36).slice(2),Ot="__reactFiber$"+jr,cs="__reactProps$"+jr,Jt="__reactContainer$"+jr,ho="__reactEvents$"+jr,Yh="__reactListeners$"+jr,Qh="__reactHandles$"+jr;function Rn(e){var t=e[Ot];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Jt]||n[Ot]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Ac(e);e!==null;){if(n=e[Ot])return n;e=Ac(e)}return t}e=n,n=e.parentNode}return null}function ws(e){return e=e[Ot]||e[Jt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Zn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(M(33))}function Ha(e){return e[cs]||null}var go=[],er=-1;function Sn(e){return{current:e}}function Se(e){0>er||(e.current=go[er],go[er]=null,er--)}function ve(e,t){er++,go[er]=e.current,e.current=t}var wn={},qe=Sn(wn),lt=Sn(!1),Mn=wn;function mr(e,t){var n=e.type.contextTypes;if(!n)return wn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a={},i;for(i in n)a[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function ct(e){return e=e.childContextTypes,e!=null}function xa(){Se(lt),Se(qe)}function _c(e,t,n){if(qe.current!==wn)throw Error(M(168));ve(qe,t),ve(lt,n)}function Qd(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var a in r)if(!(a in t))throw Error(M(108,_p(e)||"Unknown",a));return Re({},n,r)}function wa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||wn,Mn=qe.current,ve(qe,e),ve(lt,lt.current),!0}function zc(e,t,n){var r=e.stateNode;if(!r)throw Error(M(169));n?(e=Qd(e,t,Mn),r.__reactInternalMemoizedMergedChildContext=e,Se(lt),Se(qe),ve(qe,e)):Se(lt),ve(lt,n)}var Ht=null,Va=!1,Ni=!1;function Jd(e){Ht===null?Ht=[e]:Ht.push(e)}function Jh(e){Va=!0,Jd(e)}function kn(){if(!Ni&&Ht!==null){Ni=!0;var e=0,t=ye;try{var n=Ht;for(ye=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ht=null,Va=!1}catch(a){throw Ht!==null&&(Ht=Ht.slice(e+1)),jd(nl,kn),a}finally{ye=t,Ni=!1}}return null}var tr=[],nr=0,ja=null,Sa=0,jt=[],St=0,Fn=null,Gt=1,Kt="";function En(e,t){tr[nr++]=Sa,tr[nr++]=ja,ja=e,Sa=t}function Xd(e,t,n){jt[St++]=Gt,jt[St++]=Kt,jt[St++]=Fn,Fn=e;var r=Gt;e=Kt;var a=32-_t(r)-1;r&=~(1<<a),n+=1;var i=32-_t(t)+a;if(30<i){var o=a-a%5;i=(r&(1<<o)-1).toString(32),r>>=o,a-=o,Gt=1<<32-_t(t)+a|n<<a|r,Kt=i+e}else Gt=1<<i|n<<a|r,Kt=e}function dl(e){e.return!==null&&(En(e,1),Xd(e,1,0))}function fl(e){for(;e===ja;)ja=tr[--nr],tr[nr]=null,Sa=tr[--nr],tr[nr]=null;for(;e===Fn;)Fn=jt[--St],jt[St]=null,Kt=jt[--St],jt[St]=null,Gt=jt[--St],jt[St]=null}var mt=null,ft=null,be=!1,Pt=null;function qd(e,t){var n=kt(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 $c(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,mt=e,ft=pn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,mt=e,ft=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Fn!==null?{id:Gt,overflow:Kt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=kt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,mt=e,ft=null,!0):!1;default:return!1}}function yo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function vo(e){if(be){var t=ft;if(t){var n=t;if(!$c(e,t)){if(yo(e))throw Error(M(418));t=pn(n.nextSibling);var r=mt;t&&$c(e,t)?qd(r,n):(e.flags=e.flags&-4097|2,be=!1,mt=e)}}else{if(yo(e))throw Error(M(418));e.flags=e.flags&-4097|2,be=!1,mt=e}}}function Lc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;mt=e}function Ms(e){if(e!==mt)return!1;if(!be)return Lc(e),be=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!mo(e.type,e.memoizedProps)),t&&(t=ft)){if(yo(e))throw Zd(),Error(M(418));for(;t;)qd(e,t),t=pn(t.nextSibling)}if(Lc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(M(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ft=pn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ft=null}}else ft=mt?pn(e.stateNode.nextSibling):null;return!0}function Zd(){for(var e=ft;e;)e=pn(e.nextSibling)}function pr(){ft=mt=null,be=!1}function ml(e){Pt===null?Pt=[e]:Pt.push(e)}var Xh=en.ReactCurrentBatchConfig;function Pr(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(M(309));var r=n.stateNode}if(!r)throw Error(M(147,e));var a=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(o){var l=a.refs;o===null?delete l[i]:l[i]=o},t._stringRef=i,t)}if(typeof e!="string")throw Error(M(284));if(!n._owner)throw Error(M(290,e))}return e}function Fs(e,t){throw e=Object.prototype.toString.call(t),Error(M(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Mc(e){var t=e._init;return t(e._payload)}function ef(e){function t(g,h){if(e){var y=g.deletions;y===null?(g.deletions=[h],g.flags|=16):y.push(h)}}function n(g,h){if(!e)return null;for(;h!==null;)t(g,h),h=h.sibling;return null}function r(g,h){for(g=new Map;h!==null;)h.key!==null?g.set(h.key,h):g.set(h.index,h),h=h.sibling;return g}function a(g,h){return g=vn(g,h),g.index=0,g.sibling=null,g}function i(g,h,y){return g.index=y,e?(y=g.alternate,y!==null?(y=y.index,y<h?(g.flags|=2,h):y):(g.flags|=2,h)):(g.flags|=1048576,h)}function o(g){return e&&g.alternate===null&&(g.flags|=2),g}function l(g,h,y,j){return h===null||h.tag!==6?(h=Ai(y,g.mode,j),h.return=g,h):(h=a(h,y),h.return=g,h)}function c(g,h,y,j){var b=y.type;return b===Qn?f(g,h,y.props.children,j,y.key):h!==null&&(h.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===sn&&Mc(b)===h.type)?(j=a(h,y.props),j.ref=Pr(g,h,y),j.return=g,j):(j=aa(y.type,y.key,y.props,null,g.mode,j),j.ref=Pr(g,h,y),j.return=g,j)}function d(g,h,y,j){return h===null||h.tag!==4||h.stateNode.containerInfo!==y.containerInfo||h.stateNode.implementation!==y.implementation?(h=_i(y,g.mode,j),h.return=g,h):(h=a(h,y.children||[]),h.return=g,h)}function f(g,h,y,j,b){return h===null||h.tag!==7?(h=Ln(y,g.mode,j,b),h.return=g,h):(h=a(h,y),h.return=g,h)}function m(g,h,y){if(typeof h=="string"&&h!==""||typeof h=="number")return h=Ai(""+h,g.mode,y),h.return=g,h;if(typeof h=="object"&&h!==null){switch(h.$$typeof){case Es:return y=aa(h.type,h.key,h.props,null,g.mode,y),y.ref=Pr(g,null,h),y.return=g,y;case Yn:return h=_i(h,g.mode,y),h.return=g,h;case sn:var j=h._init;return m(g,j(h._payload),y)}if(Or(h)||Cr(h))return h=Ln(h,g.mode,y,null),h.return=g,h;Fs(g,h)}return null}function p(g,h,y,j){var b=h!==null?h.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return b!==null?null:l(g,h,""+y,j);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Es:return y.key===b?c(g,h,y,j):null;case Yn:return y.key===b?d(g,h,y,j):null;case sn:return b=y._init,p(g,h,b(y._payload),j)}if(Or(y)||Cr(y))return b!==null?null:f(g,h,y,j,null);Fs(g,y)}return null}function x(g,h,y,j,b){if(typeof j=="string"&&j!==""||typeof j=="number")return g=g.get(y)||null,l(h,g,""+j,b);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Es:return g=g.get(j.key===null?y:j.key)||null,c(h,g,j,b);case Yn:return g=g.get(j.key===null?y:j.key)||null,d(h,g,j,b);case sn:var C=j._init;return x(g,h,y,C(j._payload),b)}if(Or(j)||Cr(j))return g=g.get(y)||null,f(h,g,j,b,null);Fs(h,j)}return null}function w(g,h,y,j){for(var b=null,C=null,N=h,I=h=0,E=null;N!==null&&I<y.length;I++){N.index>I?(E=N,N=null):E=N.sibling;var A=p(g,N,y[I],j);if(A===null){N===null&&(N=E);break}e&&N&&A.alternate===null&&t(g,N),h=i(A,h,I),C===null?b=A:C.sibling=A,C=A,N=E}if(I===y.length)return n(g,N),be&&En(g,I),b;if(N===null){for(;I<y.length;I++)N=m(g,y[I],j),N!==null&&(h=i(N,h,I),C===null?b=N:C.sibling=N,C=N);return be&&En(g,I),b}for(N=r(g,N);I<y.length;I++)E=x(N,g,I,y[I],j),E!==null&&(e&&E.alternate!==null&&N.delete(E.key===null?I:E.key),h=i(E,h,I),C===null?b=E:C.sibling=E,C=E);return e&&N.forEach(function(D){return t(g,D)}),be&&En(g,I),b}function v(g,h,y,j){var b=Cr(y);if(typeof b!="function")throw Error(M(150));if(y=b.call(y),y==null)throw Error(M(151));for(var C=b=null,N=h,I=h=0,E=null,A=y.next();N!==null&&!A.done;I++,A=y.next()){N.index>I?(E=N,N=null):E=N.sibling;var D=p(g,N,A.value,j);if(D===null){N===null&&(N=E);break}e&&N&&D.alternate===null&&t(g,N),h=i(D,h,I),C===null?b=D:C.sibling=D,C=D,N=E}if(A.done)return n(g,N),be&&En(g,I),b;if(N===null){for(;!A.done;I++,A=y.next())A=m(g,A.value,j),A!==null&&(h=i(A,h,I),C===null?b=A:C.sibling=A,C=A);return be&&En(g,I),b}for(N=r(g,N);!A.done;I++,A=y.next())A=x(N,g,I,A.value,j),A!==null&&(e&&A.alternate!==null&&N.delete(A.key===null?I:A.key),h=i(A,h,I),C===null?b=A:C.sibling=A,C=A);return e&&N.forEach(function(z){return t(g,z)}),be&&En(g,I),b}function S(g,h,y,j){if(typeof y=="object"&&y!==null&&y.type===Qn&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Es:e:{for(var b=y.key,C=h;C!==null;){if(C.key===b){if(b=y.type,b===Qn){if(C.tag===7){n(g,C.sibling),h=a(C,y.props.children),h.return=g,g=h;break e}}else if(C.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===sn&&Mc(b)===C.type){n(g,C.sibling),h=a(C,y.props),h.ref=Pr(g,C,y),h.return=g,g=h;break e}n(g,C);break}else t(g,C);C=C.sibling}y.type===Qn?(h=Ln(y.props.children,g.mode,j,y.key),h.return=g,g=h):(j=aa(y.type,y.key,y.props,null,g.mode,j),j.ref=Pr(g,h,y),j.return=g,g=j)}return o(g);case Yn:e:{for(C=y.key;h!==null;){if(h.key===C)if(h.tag===4&&h.stateNode.containerInfo===y.containerInfo&&h.stateNode.implementation===y.implementation){n(g,h.sibling),h=a(h,y.children||[]),h.return=g,g=h;break e}else{n(g,h);break}else t(g,h);h=h.sibling}h=_i(y,g.mode,j),h.return=g,g=h}return o(g);case sn:return C=y._init,S(g,h,C(y._payload),j)}if(Or(y))return w(g,h,y,j);if(Cr(y))return v(g,h,y,j);Fs(g,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,h!==null&&h.tag===6?(n(g,h.sibling),h=a(h,y),h.return=g,g=h):(n(g,h),h=Ai(y,g.mode,j),h.return=g,g=h),o(g)):n(g,h)}return S}var hr=ef(!0),tf=ef(!1),ka=Sn(null),ba=null,rr=null,pl=null;function hl(){pl=rr=ba=null}function gl(e){var t=ka.current;Se(ka),e._currentValue=t}function xo(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 ur(e,t){ba=e,pl=rr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ot=!0),e.firstContext=null)}function Nt(e){var t=e._currentValue;if(pl!==e)if(e={context:e,memoizedValue:t,next:null},rr===null){if(ba===null)throw Error(M(308));rr=e,ba.dependencies={lanes:0,firstContext:e}}else rr=rr.next=e;return t}var Pn=null;function yl(e){Pn===null?Pn=[e]:Pn.push(e)}function nf(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,yl(t)):(n.next=a.next,a.next=n),t.interleaved=n,Xt(e,r)}function Xt(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 an=!1;function vl(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function rf(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 Yt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function hn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,me&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,Xt(e,n)}return a=r.interleaved,a===null?(t.next=t,yl(r)):(t.next=a.next,a.next=t),r.interleaved=t,Xt(e,n)}function Zs(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,rl(e,n)}}function Fc(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var a=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?a=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?a=i=t:i=i.next=t}else a=i=t;n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:i,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 Na(e,t,n,r){var a=e.updateQueue;an=!1;var i=a.firstBaseUpdate,o=a.lastBaseUpdate,l=a.shared.pending;if(l!==null){a.shared.pending=null;var c=l,d=c.next;c.next=null,o===null?i=d:o.next=d,o=c;var f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==o&&(l===null?f.firstBaseUpdate=d:l.next=d,f.lastBaseUpdate=c))}if(i!==null){var m=a.baseState;o=0,f=d=c=null,l=i;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,v=l;switch(p=t,x=n,v.tag){case 1:if(w=v.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=v.payload,p=typeof w=="function"?w.call(x,m,p):w,p==null)break e;m=Re({},m,p);break e;case 2:an=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=a.effects,p===null?a.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,o|=p;if(l=l.next,l===null){if(l=a.shared.pending,l===null)break;p=l,l=p.next,p.next=null,a.lastBaseUpdate=p,a.shared.pending=null}}while(!0);if(f===null&&(c=m),a.baseState=c,a.firstBaseUpdate=d,a.lastBaseUpdate=f,t=a.shared.interleaved,t!==null){a=t;do o|=a.lane,a=a.next;while(a!==t)}else i===null&&(a.shared.lanes=0);Bn|=o,e.lanes=o,e.memoizedState=m}}function Oc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],a=r.callback;if(a!==null){if(r.callback=null,r=n,typeof a!="function")throw Error(M(191,a));a.call(r)}}}var js={},Dt=Sn(js),us=Sn(js),ds=Sn(js);function An(e){if(e===js)throw Error(M(174));return e}function xl(e,t){switch(ve(ds,t),ve(us,e),ve(Dt,js),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:qi(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=qi(t,e)}Se(Dt),ve(Dt,t)}function gr(){Se(Dt),Se(us),Se(ds)}function sf(e){An(ds.current);var t=An(Dt.current),n=qi(t,e.type);t!==n&&(ve(us,e),ve(Dt,n))}function wl(e){us.current===e&&(Se(Dt),Se(us))}var Te=Sn(0);function Ca(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 Ci=[];function jl(){for(var e=0;e<Ci.length;e++)Ci[e]._workInProgressVersionPrimary=null;Ci.length=0}var ea=en.ReactCurrentDispatcher,Ei=en.ReactCurrentBatchConfig,On=0,Ie=null,Me=null,Be=null,Ea=!1,Yr=!1,fs=0,qh=0;function Qe(){throw Error(M(321))}function Sl(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!$t(e[n],t[n]))return!1;return!0}function kl(e,t,n,r,a,i){if(On=i,Ie=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ea.current=e===null||e.memoizedState===null?ng:rg,e=n(r,a),Yr){i=0;do{if(Yr=!1,fs=0,25<=i)throw Error(M(301));i+=1,Be=Me=null,t.updateQueue=null,ea.current=sg,e=n(r,a)}while(Yr)}if(ea.current=Ta,t=Me!==null&&Me.next!==null,On=0,Be=Me=Ie=null,Ea=!1,t)throw Error(M(300));return e}function bl(){var e=fs!==0;return fs=0,e}function Ft(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Be===null?Ie.memoizedState=Be=e:Be=Be.next=e,Be}function Ct(){if(Me===null){var e=Ie.alternate;e=e!==null?e.memoizedState:null}else e=Me.next;var t=Be===null?Ie.memoizedState:Be.next;if(t!==null)Be=t,Me=e;else{if(e===null)throw Error(M(310));Me=e,e={memoizedState:Me.memoizedState,baseState:Me.baseState,baseQueue:Me.baseQueue,queue:Me.queue,next:null},Be===null?Ie.memoizedState=Be=e:Be=Be.next=e}return Be}function ms(e,t){return typeof t=="function"?t(e):t}function Ti(e){var t=Ct(),n=t.queue;if(n===null)throw Error(M(311));n.lastRenderedReducer=e;var r=Me,a=r.baseQueue,i=n.pending;if(i!==null){if(a!==null){var o=a.next;a.next=i.next,i.next=o}r.baseQueue=a=i,n.pending=null}if(a!==null){i=a.next,r=r.baseState;var l=o=null,c=null,d=i;do{var f=d.lane;if((On&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,o=r):c=c.next=m,Ie.lanes|=f,Bn|=f}d=d.next}while(d!==null&&d!==i);c===null?o=r:c.next=l,$t(r,t.memoizedState)||(ot=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){a=e;do i=a.lane,Ie.lanes|=i,Bn|=i,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Ii(e){var t=Ct(),n=t.queue;if(n===null)throw Error(M(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,i=t.memoizedState;if(a!==null){n.pending=null;var o=a=a.next;do i=e(i,o.action),o=o.next;while(o!==a);$t(i,t.memoizedState)||(ot=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function af(){}function of(e,t){var n=Ie,r=Ct(),a=t(),i=!$t(r.memoizedState,a);if(i&&(r.memoizedState=a,ot=!0),r=r.queue,Nl(uf.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Be!==null&&Be.memoizedState.tag&1){if(n.flags|=2048,ps(9,cf.bind(null,n,r,a,t),void 0,null),De===null)throw Error(M(349));On&30||lf(n,t,a)}return a}function lf(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ie.updateQueue,t===null?(t={lastEffect:null,stores:null},Ie.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function cf(e,t,n,r){t.value=n,t.getSnapshot=r,df(t)&&ff(e)}function uf(e,t,n){return n(function(){df(t)&&ff(e)})}function df(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!$t(e,n)}catch{return!0}}function ff(e){var t=Xt(e,1);t!==null&&zt(t,e,1,-1)}function Bc(e){var t=Ft();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:e},t.queue=e,e=e.dispatch=tg.bind(null,Ie,e),[t.memoizedState,e]}function ps(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Ie.updateQueue,t===null?(t={lastEffect:null,stores:null},Ie.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 mf(){return Ct().memoizedState}function ta(e,t,n,r){var a=Ft();Ie.flags|=e,a.memoizedState=ps(1|t,n,void 0,r===void 0?null:r)}function Ga(e,t,n,r){var a=Ct();r=r===void 0?null:r;var i=void 0;if(Me!==null){var o=Me.memoizedState;if(i=o.destroy,r!==null&&Sl(r,o.deps)){a.memoizedState=ps(t,n,i,r);return}}Ie.flags|=e,a.memoizedState=ps(1|t,n,i,r)}function Dc(e,t){return ta(8390656,8,e,t)}function Nl(e,t){return Ga(2048,8,e,t)}function pf(e,t){return Ga(4,2,e,t)}function hf(e,t){return Ga(4,4,e,t)}function gf(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 yf(e,t,n){return n=n!=null?n.concat([e]):null,Ga(4,4,gf.bind(null,t,e),n)}function Cl(){}function vf(e,t){var n=Ct();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Sl(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function xf(e,t){var n=Ct();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Sl(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function wf(e,t,n){return On&21?($t(n,t)||(n=bd(),Ie.lanes|=n,Bn|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ot=!0),e.memoizedState=n)}function Zh(e,t){var n=ye;ye=n!==0&&4>n?n:4,e(!0);var r=Ei.transition;Ei.transition={};try{e(!1),t()}finally{ye=n,Ei.transition=r}}function jf(){return Ct().memoizedState}function eg(e,t,n){var r=yn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Sf(e))kf(t,n);else if(n=nf(e,t,n,r),n!==null){var a=nt();zt(n,e,r,a),bf(n,t,r)}}function tg(e,t,n){var r=yn(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Sf(e))kf(t,a);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,l=i(o,n);if(a.hasEagerState=!0,a.eagerState=l,$t(l,o)){var c=t.interleaved;c===null?(a.next=a,yl(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=nf(e,t,a,r),n!==null&&(a=nt(),zt(n,e,r,a),bf(n,t,r))}}function Sf(e){var t=e.alternate;return e===Ie||t!==null&&t===Ie}function kf(e,t){Yr=Ea=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function bf(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rl(e,n)}}var Ta={readContext:Nt,useCallback:Qe,useContext:Qe,useEffect:Qe,useImperativeHandle:Qe,useInsertionEffect:Qe,useLayoutEffect:Qe,useMemo:Qe,useReducer:Qe,useRef:Qe,useState:Qe,useDebugValue:Qe,useDeferredValue:Qe,useTransition:Qe,useMutableSource:Qe,useSyncExternalStore:Qe,useId:Qe,unstable_isNewReconciler:!1},ng={readContext:Nt,useCallback:function(e,t){return Ft().memoizedState=[e,t===void 0?null:t],e},useContext:Nt,useEffect:Dc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ta(4194308,4,gf.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ta(4194308,4,e,t)},useInsertionEffect:function(e,t){return ta(4,2,e,t)},useMemo:function(e,t){var n=Ft();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ft();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=eg.bind(null,Ie,e),[r.memoizedState,e]},useRef:function(e){var t=Ft();return e={current:e},t.memoizedState=e},useState:Bc,useDebugValue:Cl,useDeferredValue:function(e){return Ft().memoizedState=e},useTransition:function(){var e=Bc(!1),t=e[0];return e=Zh.bind(null,e[1]),Ft().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ie,a=Ft();if(be){if(n===void 0)throw Error(M(407));n=n()}else{if(n=t(),De===null)throw Error(M(349));On&30||lf(r,t,n)}a.memoizedState=n;var i={value:n,getSnapshot:t};return a.queue=i,Dc(uf.bind(null,r,i,e),[e]),r.flags|=2048,ps(9,cf.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Ft(),t=De.identifierPrefix;if(be){var n=Kt,r=Gt;n=(r&~(1<<32-_t(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=fs++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=qh++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},rg={readContext:Nt,useCallback:vf,useContext:Nt,useEffect:Nl,useImperativeHandle:yf,useInsertionEffect:pf,useLayoutEffect:hf,useMemo:xf,useReducer:Ti,useRef:mf,useState:function(){return Ti(ms)},useDebugValue:Cl,useDeferredValue:function(e){var t=Ct();return wf(t,Me.memoizedState,e)},useTransition:function(){var e=Ti(ms)[0],t=Ct().memoizedState;return[e,t]},useMutableSource:af,useSyncExternalStore:of,useId:jf,unstable_isNewReconciler:!1},sg={readContext:Nt,useCallback:vf,useContext:Nt,useEffect:Nl,useImperativeHandle:yf,useInsertionEffect:pf,useLayoutEffect:hf,useMemo:xf,useReducer:Ii,useRef:mf,useState:function(){return Ii(ms)},useDebugValue:Cl,useDeferredValue:function(e){var t=Ct();return Me===null?t.memoizedState=e:wf(t,Me.memoizedState,e)},useTransition:function(){var e=Ii(ms)[0],t=Ct().memoizedState;return[e,t]},useMutableSource:af,useSyncExternalStore:of,useId:jf,unstable_isNewReconciler:!1};function It(e,t){if(e&&e.defaultProps){t=Re({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function wo(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Re({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ka={isMounted:function(e){return(e=e._reactInternals)?Wn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=nt(),a=yn(e),i=Yt(r,a);i.payload=t,n!=null&&(i.callback=n),t=hn(e,i,a),t!==null&&(zt(t,e,a,r),Zs(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=nt(),a=yn(e),i=Yt(r,a);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=hn(e,i,a),t!==null&&(zt(t,e,a,r),Zs(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=nt(),r=yn(e),a=Yt(n,r);a.tag=2,t!=null&&(a.callback=t),t=hn(e,a,r),t!==null&&(zt(t,e,r,n),Zs(t,e,r))}};function Uc(e,t,n,r,a,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,o):t.prototype&&t.prototype.isPureReactComponent?!is(n,r)||!is(a,i):!0}function Nf(e,t,n){var r=!1,a=wn,i=t.contextType;return typeof i=="object"&&i!==null?i=Nt(i):(a=ct(t)?Mn:qe.current,r=t.contextTypes,i=(r=r!=null)?mr(e,a):wn),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ka,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=i),t}function Wc(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&&Ka.enqueueReplaceState(t,t.state,null)}function jo(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},vl(e);var i=t.contextType;typeof i=="object"&&i!==null?a.context=Nt(i):(i=ct(t)?Mn:qe.current,a.context=mr(e,i)),a.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(wo(e,t,i,n),a.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(t=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),t!==a.state&&Ka.enqueueReplaceState(a,a.state,null),Na(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function yr(e,t){try{var n="",r=t;do n+=Ap(r),r=r.return;while(r);var a=n}catch(i){a=`
|
|
37
|
+
`+a[o].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=o&&0<=l);break}}}finally{fi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Br(e):""}function Wh(e){switch(e.tag){case 5:return Br(e.type);case 16:return Br("Lazy");case 13:return Br("Suspense");case 19:return Br("SuspenseList");case 0:case 2:case 15:return e=mi(e.type,!1),e;case 11:return e=mi(e.type.render,!1),e;case 1:return e=mi(e.type,!0),e;default:return""}}function Ji(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 Jn:return"Fragment";case Qn:return"Portal";case Ki:return"Profiler";case tl:return"StrictMode";case Yi:return"Suspense";case Qi:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case dd:return(e.displayName||"Context")+".Consumer";case ud:return(e._context.displayName||"Context")+".Provider";case nl:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case rl:return t=e.displayName||null,t!==null?t:Ji(e.type)||"Memo";case sn:t=e._payload,e=e._init;try{return Ji(e(t))}catch{}}return null}function Hh(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 Ji(t);case 8:return t===tl?"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 xn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function md(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Vh(e){var t=md(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var a=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Is(e){e._valueTracker||(e._valueTracker=Vh(e))}function hd(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=md(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function da(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 Xi(e,t){var n=t.checked;return Re({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function mc(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=xn(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 pd(e,t){t=t.checked,t!=null&&el(e,"checked",t,!1)}function qi(e,t){pd(e,t);var n=xn(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")?Zi(e,t.type,n):t.hasOwnProperty("defaultValue")&&Zi(e,t.type,xn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function hc(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 Zi(e,t,n){(t!=="number"||da(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Dr=Array.isArray;function or(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+xn(n),t=null,a=0;a<e.length;a++){if(e[a].value===n){e[a].selected=!0,r&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function eo(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(M(91));return Re({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function pc(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(M(92));if(Dr(n)){if(1<n.length)throw Error(M(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:xn(n)}}function gd(e,t){var n=xn(t.value),r=xn(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 gc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function yd(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 to(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?yd(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Rs,vd=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,a){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,a)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Rs=Rs||document.createElement("div"),Rs.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Rs.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ns(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Vr={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},Gh=["Webkit","ms","Moz","O"];Object.keys(Vr).forEach(function(e){Gh.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Vr[t]=Vr[e]})});function xd(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Vr.hasOwnProperty(e)&&Vr[e]?(""+t).trim():t+"px"}function wd(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=xd(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var Kh=Re({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 no(e,t){if(t){if(Kh[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(M(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(M(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(M(61))}if(t.style!=null&&typeof t.style!="object")throw Error(M(62))}}function ro(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 so=null;function sl(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ao=null,lr=null,cr=null;function yc(e){if(e=js(e)){if(typeof ao!="function")throw Error(M(280));var t=e.stateNode;t&&(t=Va(t),ao(e.stateNode,e.type,t))}}function jd(e){lr?cr?cr.push(e):cr=[e]:lr=e}function Sd(){if(lr){var e=lr,t=cr;if(cr=lr=null,yc(e),t)for(e=0;e<t.length;e++)yc(t[e])}}function kd(e,t){return e(t)}function bd(){}var hi=!1;function Nd(e,t,n){if(hi)return e(t,n);hi=!0;try{return kd(e,t,n)}finally{hi=!1,(lr!==null||cr!==null)&&(bd(),Sd())}}function rs(e,t){var n=e.stateNode;if(n===null)return null;var r=Va(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(M(231,t,typeof n));return n}var io=!1;if(Qt)try{var Ir={};Object.defineProperty(Ir,"passive",{get:function(){io=!0}}),window.addEventListener("test",Ir,Ir),window.removeEventListener("test",Ir,Ir)}catch{io=!1}function Yh(e,t,n,r,a,i,o,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(f){this.onError(f)}}var Gr=!1,fa=null,ma=!1,oo=null,Qh={onError:function(e){Gr=!0,fa=e}};function Jh(e,t,n,r,a,i,o,l,c){Gr=!1,fa=null,Yh.apply(Qh,arguments)}function Xh(e,t,n,r,a,i,o,l,c){if(Jh.apply(this,arguments),Gr){if(Gr){var d=fa;Gr=!1,fa=null}else throw Error(M(198));ma||(ma=!0,oo=d)}}function Hn(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 Cd(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 vc(e){if(Hn(e)!==e)throw Error(M(188))}function qh(e){var t=e.alternate;if(!t){if(t=Hn(e),t===null)throw Error(M(188));return t!==e?null:e}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var i=a.alternate;if(i===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===i.child){for(i=a.child;i;){if(i===n)return vc(a),e;if(i===r)return vc(a),t;i=i.sibling}throw Error(M(188))}if(n.return!==r.return)n=a,r=i;else{for(var o=!1,l=a.child;l;){if(l===n){o=!0,n=a,r=i;break}if(l===r){o=!0,r=a,n=i;break}l=l.sibling}if(!o){for(l=i.child;l;){if(l===n){o=!0,n=i,r=a;break}if(l===r){o=!0,r=i,n=a;break}l=l.sibling}if(!o)throw Error(M(189))}}if(n.alternate!==r)throw Error(M(190))}if(n.tag!==3)throw Error(M(188));return n.stateNode.current===n?e:t}function Ed(e){return e=qh(e),e!==null?Td(e):null}function Td(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Td(e);if(t!==null)return t;e=e.sibling}return null}var Id=pt.unstable_scheduleCallback,xc=pt.unstable_cancelCallback,Zh=pt.unstable_shouldYield,ep=pt.unstable_requestPaint,Le=pt.unstable_now,tp=pt.unstable_getCurrentPriorityLevel,al=pt.unstable_ImmediatePriority,Rd=pt.unstable_UserBlockingPriority,ha=pt.unstable_NormalPriority,np=pt.unstable_LowPriority,Pd=pt.unstable_IdlePriority,Da=null,Dt=null;function rp(e){if(Dt&&typeof Dt.onCommitFiberRoot=="function")try{Dt.onCommitFiberRoot(Da,e,void 0,(e.current.flags&128)===128)}catch{}}var _t=Math.clz32?Math.clz32:ip,sp=Math.log,ap=Math.LN2;function ip(e){return e>>>=0,e===0?32:31-(sp(e)/ap|0)|0}var Ps=64,As=4194304;function Ur(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 pa(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,a=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var l=o&~a;l!==0?r=Ur(l):(i&=o,i!==0&&(r=Ur(i)))}else o=n&~a,o!==0?r=Ur(o):i!==0&&(r=Ur(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&a)&&(a=r&-r,i=t&-t,a>=i||a===16&&(i&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-_t(t),a=1<<n,r|=e[n],t&=~a;return r}function op(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 lp(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-_t(i),l=1<<o,c=a[o];c===-1?(!(l&n)||l&r)&&(a[o]=op(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function lo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Ad(){var e=Ps;return Ps<<=1,!(Ps&4194240)&&(Ps=64),e}function pi(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function xs(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-_t(t),e[t]=n}function cp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var a=31-_t(n),i=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~i}}function il(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-_t(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var ye=0;function _d(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Ld,ol,zd,$d,Md,co=!1,_s=[],dn=null,fn=null,mn=null,ss=new Map,as=new Map,on=[],up="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 wc(e,t){switch(e){case"focusin":case"focusout":dn=null;break;case"dragenter":case"dragleave":fn=null;break;case"mouseover":case"mouseout":mn=null;break;case"pointerover":case"pointerout":ss.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":as.delete(t.pointerId)}}function Rr(e,t,n,r,a,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[a]},t!==null&&(t=js(t),t!==null&&ol(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function dp(e,t,n,r,a){switch(t){case"focusin":return dn=Rr(dn,e,t,n,r,a),!0;case"dragenter":return fn=Rr(fn,e,t,n,r,a),!0;case"mouseover":return mn=Rr(mn,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return ss.set(i,Rr(ss.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,as.set(i,Rr(as.get(i)||null,e,t,n,r,a)),!0}return!1}function Fd(e){var t=Rn(e.target);if(t!==null){var n=Hn(t);if(n!==null){if(t=n.tag,t===13){if(t=Cd(n),t!==null){e.blockedOn=t,Md(e.priority,function(){zd(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 Xs(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=uo(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);so=r,n.target.dispatchEvent(r),so=null}else return t=js(n),t!==null&&ol(t),e.blockedOn=n,!1;t.shift()}return!0}function jc(e,t,n){Xs(e)&&n.delete(t)}function fp(){co=!1,dn!==null&&Xs(dn)&&(dn=null),fn!==null&&Xs(fn)&&(fn=null),mn!==null&&Xs(mn)&&(mn=null),ss.forEach(jc),as.forEach(jc)}function Pr(e,t){e.blockedOn===t&&(e.blockedOn=null,co||(co=!0,pt.unstable_scheduleCallback(pt.unstable_NormalPriority,fp)))}function is(e){function t(a){return Pr(a,e)}if(0<_s.length){Pr(_s[0],e);for(var n=1;n<_s.length;n++){var r=_s[n];r.blockedOn===e&&(r.blockedOn=null)}}for(dn!==null&&Pr(dn,e),fn!==null&&Pr(fn,e),mn!==null&&Pr(mn,e),ss.forEach(t),as.forEach(t),n=0;n<on.length;n++)r=on[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<on.length&&(n=on[0],n.blockedOn===null);)Fd(n),n.blockedOn===null&&on.shift()}var ur=en.ReactCurrentBatchConfig,ga=!0;function mp(e,t,n,r){var a=ye,i=ur.transition;ur.transition=null;try{ye=1,ll(e,t,n,r)}finally{ye=a,ur.transition=i}}function hp(e,t,n,r){var a=ye,i=ur.transition;ur.transition=null;try{ye=4,ll(e,t,n,r)}finally{ye=a,ur.transition=i}}function ll(e,t,n,r){if(ga){var a=uo(e,t,n,r);if(a===null)Ni(e,t,r,ya,n),wc(e,r);else if(dp(a,e,t,n,r))r.stopPropagation();else if(wc(e,r),t&4&&-1<up.indexOf(e)){for(;a!==null;){var i=js(a);if(i!==null&&Ld(i),i=uo(e,t,n,r),i===null&&Ni(e,t,r,ya,n),i===a)break;a=i}a!==null&&r.stopPropagation()}else Ni(e,t,r,null,n)}}var ya=null;function uo(e,t,n,r){if(ya=null,e=sl(r),e=Rn(e),e!==null)if(t=Hn(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Cd(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 ya=e,null}function Od(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(tp()){case al:return 1;case Rd:return 4;case ha:case np:return 16;case Pd:return 536870912;default:return 16}default:return 16}}var cn=null,cl=null,qs=null;function Bd(){if(qs)return qs;var e,t=cl,n=t.length,r,a="value"in cn?cn.value:cn.textContent,i=a.length;for(e=0;e<n&&t[e]===a[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===a[i-r];r++);return qs=a.slice(e,1<r?1-r:void 0)}function Zs(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 Ls(){return!0}function Sc(){return!1}function yt(e){function t(n,r,a,i,o){this._reactName=n,this._targetInst=a,this.type=r,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Ls:Sc,this.isPropagationStopped=Sc,this}return Re(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=Ls)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Ls)},persist:function(){},isPersistent:Ls}),t}var Sr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ul=yt(Sr),ws=Re({},Sr,{view:0,detail:0}),pp=yt(ws),gi,yi,Ar,Ua=Re({},ws,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:dl,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!==Ar&&(Ar&&e.type==="mousemove"?(gi=e.screenX-Ar.screenX,yi=e.screenY-Ar.screenY):yi=gi=0,Ar=e),gi)},movementY:function(e){return"movementY"in e?e.movementY:yi}}),kc=yt(Ua),gp=Re({},Ua,{dataTransfer:0}),yp=yt(gp),vp=Re({},ws,{relatedTarget:0}),vi=yt(vp),xp=Re({},Sr,{animationName:0,elapsedTime:0,pseudoElement:0}),wp=yt(xp),jp=Re({},Sr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Sp=yt(jp),kp=Re({},Sr,{data:0}),bc=yt(kp),bp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Np={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"},Cp={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ep(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Cp[e])?!!t[e]:!1}function dl(){return Ep}var Tp=Re({},ws,{key:function(e){if(e.key){var t=bp[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Zs(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Np[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:dl,charCode:function(e){return e.type==="keypress"?Zs(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Zs(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ip=yt(Tp),Rp=Re({},Ua,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Nc=yt(Rp),Pp=Re({},ws,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:dl}),Ap=yt(Pp),_p=Re({},Sr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Lp=yt(_p),zp=Re({},Ua,{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}),$p=yt(zp),Mp=[9,13,27,32],fl=Qt&&"CompositionEvent"in window,Kr=null;Qt&&"documentMode"in document&&(Kr=document.documentMode);var Fp=Qt&&"TextEvent"in window&&!Kr,Dd=Qt&&(!fl||Kr&&8<Kr&&11>=Kr),Cc=" ",Ec=!1;function Ud(e,t){switch(e){case"keyup":return Mp.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xn=!1;function Op(e,t){switch(e){case"compositionend":return Wd(t);case"keypress":return t.which!==32?null:(Ec=!0,Cc);case"textInput":return e=t.data,e===Cc&&Ec?null:e;default:return null}}function Bp(e,t){if(Xn)return e==="compositionend"||!fl&&Ud(e,t)?(e=Bd(),qs=cl=cn=null,Xn=!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 Dd&&t.locale!=="ko"?null:t.data;default:return null}}var Dp={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 Tc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Dp[e.type]:t==="textarea"}function Hd(e,t,n,r){jd(r),t=va(t,"onChange"),0<t.length&&(n=new ul("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Yr=null,os=null;function Up(e){tf(e,0)}function Wa(e){var t=er(e);if(hd(t))return e}function Wp(e,t){if(e==="change")return t}var Vd=!1;if(Qt){var xi;if(Qt){var wi="oninput"in document;if(!wi){var Ic=document.createElement("div");Ic.setAttribute("oninput","return;"),wi=typeof Ic.oninput=="function"}xi=wi}else xi=!1;Vd=xi&&(!document.documentMode||9<document.documentMode)}function Rc(){Yr&&(Yr.detachEvent("onpropertychange",Gd),os=Yr=null)}function Gd(e){if(e.propertyName==="value"&&Wa(os)){var t=[];Hd(t,os,e,sl(e)),Nd(Up,t)}}function Hp(e,t,n){e==="focusin"?(Rc(),Yr=t,os=n,Yr.attachEvent("onpropertychange",Gd)):e==="focusout"&&Rc()}function Vp(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Wa(os)}function Gp(e,t){if(e==="click")return Wa(t)}function Kp(e,t){if(e==="input"||e==="change")return Wa(t)}function Yp(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var $t=typeof Object.is=="function"?Object.is:Yp;function ls(e,t){if($t(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!Gi.call(t,a)||!$t(e[a],t[a]))return!1}return!0}function Pc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ac(e,t){var n=Pc(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=Pc(n)}}function Kd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Kd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Yd(){for(var e=window,t=da();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=da(e.document)}return t}function ml(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 Qp(e){var t=Yd(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Kd(n.ownerDocument.documentElement,n)){if(r!==null&&ml(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=n.textContent.length,i=Math.min(r.start,a);r=r.end===void 0?i:Math.min(r.end,a),!e.extend&&i>r&&(a=r,r=i,i=a),a=Ac(n,i);var o=Ac(n,r);a&&o&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.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 Jp=Qt&&"documentMode"in document&&11>=document.documentMode,qn=null,fo=null,Qr=null,mo=!1;function _c(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;mo||qn==null||qn!==da(r)||(r=qn,"selectionStart"in r&&ml(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}),Qr&&ls(Qr,r)||(Qr=r,r=va(fo,"onSelect"),0<r.length&&(t=new ul("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=qn)))}function zs(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Zn={animationend:zs("Animation","AnimationEnd"),animationiteration:zs("Animation","AnimationIteration"),animationstart:zs("Animation","AnimationStart"),transitionend:zs("Transition","TransitionEnd")},ji={},Qd={};Qt&&(Qd=document.createElement("div").style,"AnimationEvent"in window||(delete Zn.animationend.animation,delete Zn.animationiteration.animation,delete Zn.animationstart.animation),"TransitionEvent"in window||delete Zn.transitionend.transition);function Ha(e){if(ji[e])return ji[e];if(!Zn[e])return e;var t=Zn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Qd)return ji[e]=t[n];return e}var Jd=Ha("animationend"),Xd=Ha("animationiteration"),qd=Ha("animationstart"),Zd=Ha("transitionend"),ef=new Map,Lc="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 jn(e,t){ef.set(e,t),Wn(t,[e])}for(var Si=0;Si<Lc.length;Si++){var ki=Lc[Si],Xp=ki.toLowerCase(),qp=ki[0].toUpperCase()+ki.slice(1);jn(Xp,"on"+qp)}jn(Jd,"onAnimationEnd");jn(Xd,"onAnimationIteration");jn(qd,"onAnimationStart");jn("dblclick","onDoubleClick");jn("focusin","onFocus");jn("focusout","onBlur");jn(Zd,"onTransitionEnd");mr("onMouseEnter",["mouseout","mouseover"]);mr("onMouseLeave",["mouseout","mouseover"]);mr("onPointerEnter",["pointerout","pointerover"]);mr("onPointerLeave",["pointerout","pointerover"]);Wn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Wn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Wn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Wn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Wn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Wn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Wr="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(" "),Zp=new Set("cancel close invalid load scroll toggle".split(" ").concat(Wr));function zc(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Xh(r,t,void 0,e),e.currentTarget=null}function tf(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var o=r.length-1;0<=o;o--){var l=r[o],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==i&&a.isPropagationStopped())break e;zc(a,l,d),i=c}else for(o=0;o<r.length;o++){if(l=r[o],c=l.instance,d=l.currentTarget,l=l.listener,c!==i&&a.isPropagationStopped())break e;zc(a,l,d),i=c}}}if(ma)throw e=oo,ma=!1,oo=null,e}function we(e,t){var n=t[vo];n===void 0&&(n=t[vo]=new Set);var r=e+"__bubble";n.has(r)||(nf(t,e,2,!1),n.add(r))}function bi(e,t,n){var r=0;t&&(r|=4),nf(n,e,r,t)}var $s="_reactListening"+Math.random().toString(36).slice(2);function cs(e){if(!e[$s]){e[$s]=!0,cd.forEach(function(n){n!=="selectionchange"&&(Zp.has(n)||bi(n,!1,e),bi(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[$s]||(t[$s]=!0,bi("selectionchange",!1,t))}}function nf(e,t,n,r){switch(Od(t)){case 1:var a=mp;break;case 4:a=hp;break;default:a=ll}n=a.bind(null,t,n,e),a=void 0,!io||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),r?a!==void 0?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):a!==void 0?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function Ni(e,t,n,r,a){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var l=r.stateNode.containerInfo;if(l===a||l.nodeType===8&&l.parentNode===a)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===a||c.nodeType===8&&c.parentNode===a))return;o=o.return}for(;l!==null;){if(o=Rn(l),o===null)return;if(c=o.tag,c===5||c===6){r=i=o;continue e}l=l.parentNode}}r=r.return}Nd(function(){var d=i,f=sl(n),h=[];e:{var m=ef.get(e);if(m!==void 0){var x=ul,w=e;switch(e){case"keypress":if(Zs(n)===0)break e;case"keydown":case"keyup":x=Ip;break;case"focusin":w="focus",x=vi;break;case"focusout":w="blur",x=vi;break;case"beforeblur":case"afterblur":x=vi;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=kc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=yp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=Ap;break;case Jd:case Xd:case qd:x=wp;break;case Zd:x=Lp;break;case"scroll":x=pp;break;case"wheel":x=$p;break;case"copy":case"cut":case"paste":x=Sp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=Nc}var v=(t&4)!==0,S=!v&&e==="scroll",g=v?m!==null?m+"Capture":null:m;v=[];for(var p=d,y;p!==null;){y=p;var j=y.stateNode;if(y.tag===5&&j!==null&&(y=j,g!==null&&(j=rs(p,g),j!=null&&v.push(us(p,j,y)))),S)break;p=p.return}0<v.length&&(m=new x(m,w,null,n,f),h.push({event:m,listeners:v}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",m&&n!==so&&(w=n.relatedTarget||n.fromElement)&&(Rn(w)||w[Jt]))break e;if((x||m)&&(m=f.window===f?f:(m=f.ownerDocument)?m.defaultView||m.parentWindow:window,x?(w=n.relatedTarget||n.toElement,x=d,w=w?Rn(w):null,w!==null&&(S=Hn(w),w!==S||w.tag!==5&&w.tag!==6)&&(w=null)):(x=null,w=d),x!==w)){if(v=kc,j="onMouseLeave",g="onMouseEnter",p="mouse",(e==="pointerout"||e==="pointerover")&&(v=Nc,j="onPointerLeave",g="onPointerEnter",p="pointer"),S=x==null?m:er(x),y=w==null?m:er(w),m=new v(j,p+"leave",x,n,f),m.target=S,m.relatedTarget=y,j=null,Rn(f)===d&&(v=new v(g,p+"enter",w,n,f),v.target=y,v.relatedTarget=S,j=v),S=j,x&&w)t:{for(v=x,g=w,p=0,y=v;y;y=Gn(y))p++;for(y=0,j=g;j;j=Gn(j))y++;for(;0<p-y;)v=Gn(v),p--;for(;0<y-p;)g=Gn(g),y--;for(;p--;){if(v===g||g!==null&&v===g.alternate)break t;v=Gn(v),g=Gn(g)}v=null}else v=null;x!==null&&$c(h,m,x,v,!1),w!==null&&S!==null&&$c(h,S,w,v,!0)}}e:{if(m=d?er(d):window,x=m.nodeName&&m.nodeName.toLowerCase(),x==="select"||x==="input"&&m.type==="file")var b=Wp;else if(Tc(m))if(Vd)b=Kp;else{b=Vp;var C=Hp}else(x=m.nodeName)&&x.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(b=Gp);if(b&&(b=b(e,d))){Hd(h,b,n,f);break e}C&&C(e,m,d),e==="focusout"&&(C=m._wrapperState)&&C.controlled&&m.type==="number"&&Zi(m,"number",m.value)}switch(C=d?er(d):window,e){case"focusin":(Tc(C)||C.contentEditable==="true")&&(qn=C,fo=d,Qr=null);break;case"focusout":Qr=fo=qn=null;break;case"mousedown":mo=!0;break;case"contextmenu":case"mouseup":case"dragend":mo=!1,_c(h,n,f);break;case"selectionchange":if(Jp)break;case"keydown":case"keyup":_c(h,n,f)}var N;if(fl)e:{switch(e){case"compositionstart":var I="onCompositionStart";break e;case"compositionend":I="onCompositionEnd";break e;case"compositionupdate":I="onCompositionUpdate";break e}I=void 0}else Xn?Ud(e,n)&&(I="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(I="onCompositionStart");I&&(Dd&&n.locale!=="ko"&&(Xn||I!=="onCompositionStart"?I==="onCompositionEnd"&&Xn&&(N=Bd()):(cn=f,cl="value"in cn?cn.value:cn.textContent,Xn=!0)),C=va(d,I),0<C.length&&(I=new bc(I,e,null,n,f),h.push({event:I,listeners:C}),N?I.data=N:(N=Wd(n),N!==null&&(I.data=N)))),(N=Fp?Op(e,n):Bp(e,n))&&(d=va(d,"onBeforeInput"),0<d.length&&(f=new bc("onBeforeInput","beforeinput",null,n,f),h.push({event:f,listeners:d}),f.data=N))}tf(h,t)})}function us(e,t,n){return{instance:e,listener:t,currentTarget:n}}function va(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,i=a.stateNode;a.tag===5&&i!==null&&(a=i,i=rs(e,n),i!=null&&r.unshift(us(e,i,a)),i=rs(e,t),i!=null&&r.push(us(e,i,a))),e=e.return}return r}function Gn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function $c(e,t,n,r,a){for(var i=t._reactName,o=[];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,a?(c=rs(n,i),c!=null&&o.unshift(us(n,c,l))):a||(c=rs(n,i),c!=null&&o.push(us(n,c,l)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var eg=/\r\n?/g,tg=/\u0000|\uFFFD/g;function Mc(e){return(typeof e=="string"?e:""+e).replace(eg,`
|
|
38
|
+
`).replace(tg,"")}function Ms(e,t,n){if(t=Mc(t),Mc(e)!==t&&n)throw Error(M(425))}function xa(){}var ho=null,po=null;function go(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var yo=typeof setTimeout=="function"?setTimeout:void 0,ng=typeof clearTimeout=="function"?clearTimeout:void 0,Fc=typeof Promise=="function"?Promise:void 0,rg=typeof queueMicrotask=="function"?queueMicrotask:typeof Fc<"u"?function(e){return Fc.resolve(null).then(e).catch(sg)}:yo;function sg(e){setTimeout(function(){throw e})}function Ci(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&a.nodeType===8)if(n=a.data,n==="/$"){if(r===0){e.removeChild(a),is(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);is(t)}function hn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Oc(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var kr=Math.random().toString(36).slice(2),Bt="__reactFiber$"+kr,ds="__reactProps$"+kr,Jt="__reactContainer$"+kr,vo="__reactEvents$"+kr,ag="__reactListeners$"+kr,ig="__reactHandles$"+kr;function Rn(e){var t=e[Bt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Jt]||n[Bt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Oc(e);e!==null;){if(n=e[Bt])return n;e=Oc(e)}return t}e=n,n=e.parentNode}return null}function js(e){return e=e[Bt]||e[Jt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function er(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(M(33))}function Va(e){return e[ds]||null}var xo=[],tr=-1;function Sn(e){return{current:e}}function Se(e){0>tr||(e.current=xo[tr],xo[tr]=null,tr--)}function ve(e,t){tr++,xo[tr]=e.current,e.current=t}var wn={},qe=Sn(wn),lt=Sn(!1),Mn=wn;function hr(e,t){var n=e.type.contextTypes;if(!n)return wn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a={},i;for(i in n)a[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function ct(e){return e=e.childContextTypes,e!=null}function wa(){Se(lt),Se(qe)}function Bc(e,t,n){if(qe.current!==wn)throw Error(M(168));ve(qe,t),ve(lt,n)}function rf(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var a in r)if(!(a in t))throw Error(M(108,Hh(e)||"Unknown",a));return Re({},n,r)}function ja(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||wn,Mn=qe.current,ve(qe,e),ve(lt,lt.current),!0}function Dc(e,t,n){var r=e.stateNode;if(!r)throw Error(M(169));n?(e=rf(e,t,Mn),r.__reactInternalMemoizedMergedChildContext=e,Se(lt),Se(qe),ve(qe,e)):Se(lt),ve(lt,n)}var Ht=null,Ga=!1,Ei=!1;function sf(e){Ht===null?Ht=[e]:Ht.push(e)}function og(e){Ga=!0,sf(e)}function kn(){if(!Ei&&Ht!==null){Ei=!0;var e=0,t=ye;try{var n=Ht;for(ye=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ht=null,Ga=!1}catch(a){throw Ht!==null&&(Ht=Ht.slice(e+1)),Id(al,kn),a}finally{ye=t,Ei=!1}}return null}var nr=[],rr=0,Sa=null,ka=0,jt=[],St=0,Fn=null,Gt=1,Kt="";function En(e,t){nr[rr++]=ka,nr[rr++]=Sa,Sa=e,ka=t}function af(e,t,n){jt[St++]=Gt,jt[St++]=Kt,jt[St++]=Fn,Fn=e;var r=Gt;e=Kt;var a=32-_t(r)-1;r&=~(1<<a),n+=1;var i=32-_t(t)+a;if(30<i){var o=a-a%5;i=(r&(1<<o)-1).toString(32),r>>=o,a-=o,Gt=1<<32-_t(t)+a|n<<a|r,Kt=i+e}else Gt=1<<i|n<<a|r,Kt=e}function hl(e){e.return!==null&&(En(e,1),af(e,1,0))}function pl(e){for(;e===Sa;)Sa=nr[--rr],nr[rr]=null,ka=nr[--rr],nr[rr]=null;for(;e===Fn;)Fn=jt[--St],jt[St]=null,Kt=jt[--St],jt[St]=null,Gt=jt[--St],jt[St]=null}var ht=null,mt=null,be=!1,Pt=null;function of(e,t){var n=kt(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,ht=e,mt=hn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ht=e,mt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Fn!==null?{id:Gt,overflow:Kt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=kt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ht=e,mt=null,!0):!1;default:return!1}}function wo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function jo(e){if(be){var t=mt;if(t){var n=t;if(!Uc(e,t)){if(wo(e))throw Error(M(418));t=hn(n.nextSibling);var r=ht;t&&Uc(e,t)?of(r,n):(e.flags=e.flags&-4097|2,be=!1,ht=e)}}else{if(wo(e))throw Error(M(418));e.flags=e.flags&-4097|2,be=!1,ht=e}}}function Wc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ht=e}function Fs(e){if(e!==ht)return!1;if(!be)return Wc(e),be=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!go(e.type,e.memoizedProps)),t&&(t=mt)){if(wo(e))throw lf(),Error(M(418));for(;t;)of(e,t),t=hn(t.nextSibling)}if(Wc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(M(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){mt=hn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}mt=null}}else mt=ht?hn(e.stateNode.nextSibling):null;return!0}function lf(){for(var e=mt;e;)e=hn(e.nextSibling)}function pr(){mt=ht=null,be=!1}function gl(e){Pt===null?Pt=[e]:Pt.push(e)}var lg=en.ReactCurrentBatchConfig;function _r(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(M(309));var r=n.stateNode}if(!r)throw Error(M(147,e));var a=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(o){var l=a.refs;o===null?delete l[i]:l[i]=o},t._stringRef=i,t)}if(typeof e!="string")throw Error(M(284));if(!n._owner)throw Error(M(290,e))}return e}function Os(e,t){throw e=Object.prototype.toString.call(t),Error(M(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Hc(e){var t=e._init;return t(e._payload)}function cf(e){function t(g,p){if(e){var y=g.deletions;y===null?(g.deletions=[p],g.flags|=16):y.push(p)}}function n(g,p){if(!e)return null;for(;p!==null;)t(g,p),p=p.sibling;return null}function r(g,p){for(g=new Map;p!==null;)p.key!==null?g.set(p.key,p):g.set(p.index,p),p=p.sibling;return g}function a(g,p){return g=vn(g,p),g.index=0,g.sibling=null,g}function i(g,p,y){return g.index=y,e?(y=g.alternate,y!==null?(y=y.index,y<p?(g.flags|=2,p):y):(g.flags|=2,p)):(g.flags|=1048576,p)}function o(g){return e&&g.alternate===null&&(g.flags|=2),g}function l(g,p,y,j){return p===null||p.tag!==6?(p=Li(y,g.mode,j),p.return=g,p):(p=a(p,y),p.return=g,p)}function c(g,p,y,j){var b=y.type;return b===Jn?f(g,p,y.props.children,j,y.key):p!==null&&(p.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===sn&&Hc(b)===p.type)?(j=a(p,y.props),j.ref=_r(g,p,y),j.return=g,j):(j=ia(y.type,y.key,y.props,null,g.mode,j),j.ref=_r(g,p,y),j.return=g,j)}function d(g,p,y,j){return p===null||p.tag!==4||p.stateNode.containerInfo!==y.containerInfo||p.stateNode.implementation!==y.implementation?(p=zi(y,g.mode,j),p.return=g,p):(p=a(p,y.children||[]),p.return=g,p)}function f(g,p,y,j,b){return p===null||p.tag!==7?(p=$n(y,g.mode,j,b),p.return=g,p):(p=a(p,y),p.return=g,p)}function h(g,p,y){if(typeof p=="string"&&p!==""||typeof p=="number")return p=Li(""+p,g.mode,y),p.return=g,p;if(typeof p=="object"&&p!==null){switch(p.$$typeof){case Ts:return y=ia(p.type,p.key,p.props,null,g.mode,y),y.ref=_r(g,null,p),y.return=g,y;case Qn:return p=zi(p,g.mode,y),p.return=g,p;case sn:var j=p._init;return h(g,j(p._payload),y)}if(Dr(p)||Tr(p))return p=$n(p,g.mode,y,null),p.return=g,p;Os(g,p)}return null}function m(g,p,y,j){var b=p!==null?p.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return b!==null?null:l(g,p,""+y,j);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Ts:return y.key===b?c(g,p,y,j):null;case Qn:return y.key===b?d(g,p,y,j):null;case sn:return b=y._init,m(g,p,b(y._payload),j)}if(Dr(y)||Tr(y))return b!==null?null:f(g,p,y,j,null);Os(g,y)}return null}function x(g,p,y,j,b){if(typeof j=="string"&&j!==""||typeof j=="number")return g=g.get(y)||null,l(p,g,""+j,b);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Ts:return g=g.get(j.key===null?y:j.key)||null,c(p,g,j,b);case Qn:return g=g.get(j.key===null?y:j.key)||null,d(p,g,j,b);case sn:var C=j._init;return x(g,p,y,C(j._payload),b)}if(Dr(j)||Tr(j))return g=g.get(y)||null,f(p,g,j,b,null);Os(p,j)}return null}function w(g,p,y,j){for(var b=null,C=null,N=p,I=p=0,E=null;N!==null&&I<y.length;I++){N.index>I?(E=N,N=null):E=N.sibling;var A=m(g,N,y[I],j);if(A===null){N===null&&(N=E);break}e&&N&&A.alternate===null&&t(g,N),p=i(A,p,I),C===null?b=A:C.sibling=A,C=A,N=E}if(I===y.length)return n(g,N),be&&En(g,I),b;if(N===null){for(;I<y.length;I++)N=h(g,y[I],j),N!==null&&(p=i(N,p,I),C===null?b=N:C.sibling=N,C=N);return be&&En(g,I),b}for(N=r(g,N);I<y.length;I++)E=x(N,g,I,y[I],j),E!==null&&(e&&E.alternate!==null&&N.delete(E.key===null?I:E.key),p=i(E,p,I),C===null?b=E:C.sibling=E,C=E);return e&&N.forEach(function(D){return t(g,D)}),be&&En(g,I),b}function v(g,p,y,j){var b=Tr(y);if(typeof b!="function")throw Error(M(150));if(y=b.call(y),y==null)throw Error(M(151));for(var C=b=null,N=p,I=p=0,E=null,A=y.next();N!==null&&!A.done;I++,A=y.next()){N.index>I?(E=N,N=null):E=N.sibling;var D=m(g,N,A.value,j);if(D===null){N===null&&(N=E);break}e&&N&&D.alternate===null&&t(g,N),p=i(D,p,I),C===null?b=D:C.sibling=D,C=D,N=E}if(A.done)return n(g,N),be&&En(g,I),b;if(N===null){for(;!A.done;I++,A=y.next())A=h(g,A.value,j),A!==null&&(p=i(A,p,I),C===null?b=A:C.sibling=A,C=A);return be&&En(g,I),b}for(N=r(g,N);!A.done;I++,A=y.next())A=x(N,g,I,A.value,j),A!==null&&(e&&A.alternate!==null&&N.delete(A.key===null?I:A.key),p=i(A,p,I),C===null?b=A:C.sibling=A,C=A);return e&&N.forEach(function(L){return t(g,L)}),be&&En(g,I),b}function S(g,p,y,j){if(typeof y=="object"&&y!==null&&y.type===Jn&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Ts:e:{for(var b=y.key,C=p;C!==null;){if(C.key===b){if(b=y.type,b===Jn){if(C.tag===7){n(g,C.sibling),p=a(C,y.props.children),p.return=g,g=p;break e}}else if(C.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===sn&&Hc(b)===C.type){n(g,C.sibling),p=a(C,y.props),p.ref=_r(g,C,y),p.return=g,g=p;break e}n(g,C);break}else t(g,C);C=C.sibling}y.type===Jn?(p=$n(y.props.children,g.mode,j,y.key),p.return=g,g=p):(j=ia(y.type,y.key,y.props,null,g.mode,j),j.ref=_r(g,p,y),j.return=g,g=j)}return o(g);case Qn:e:{for(C=y.key;p!==null;){if(p.key===C)if(p.tag===4&&p.stateNode.containerInfo===y.containerInfo&&p.stateNode.implementation===y.implementation){n(g,p.sibling),p=a(p,y.children||[]),p.return=g,g=p;break e}else{n(g,p);break}else t(g,p);p=p.sibling}p=zi(y,g.mode,j),p.return=g,g=p}return o(g);case sn:return C=y._init,S(g,p,C(y._payload),j)}if(Dr(y))return w(g,p,y,j);if(Tr(y))return v(g,p,y,j);Os(g,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,p!==null&&p.tag===6?(n(g,p.sibling),p=a(p,y),p.return=g,g=p):(n(g,p),p=Li(y,g.mode,j),p.return=g,g=p),o(g)):n(g,p)}return S}var gr=cf(!0),uf=cf(!1),ba=Sn(null),Na=null,sr=null,yl=null;function vl(){yl=sr=Na=null}function xl(e){var t=ba.current;Se(ba),e._currentValue=t}function So(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 dr(e,t){Na=e,yl=sr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ot=!0),e.firstContext=null)}function Nt(e){var t=e._currentValue;if(yl!==e)if(e={context:e,memoizedValue:t,next:null},sr===null){if(Na===null)throw Error(M(308));sr=e,Na.dependencies={lanes:0,firstContext:e}}else sr=sr.next=e;return t}var Pn=null;function wl(e){Pn===null?Pn=[e]:Pn.push(e)}function df(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,wl(t)):(n.next=a.next,a.next=n),t.interleaved=n,Xt(e,r)}function Xt(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 an=!1;function jl(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ff(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 Yt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function pn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,me&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,Xt(e,n)}return a=r.interleaved,a===null?(t.next=t,wl(r)):(t.next=a.next,a.next=t),r.interleaved=t,Xt(e,n)}function ea(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,il(e,n)}}function Vc(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var a=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?a=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?a=i=t:i=i.next=t}else a=i=t;n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:i,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 Ca(e,t,n,r){var a=e.updateQueue;an=!1;var i=a.firstBaseUpdate,o=a.lastBaseUpdate,l=a.shared.pending;if(l!==null){a.shared.pending=null;var c=l,d=c.next;c.next=null,o===null?i=d:o.next=d,o=c;var f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==o&&(l===null?f.firstBaseUpdate=d:l.next=d,f.lastBaseUpdate=c))}if(i!==null){var h=a.baseState;o=0,f=d=c=null,l=i;do{var m=l.lane,x=l.eventTime;if((r&m)===m){f!==null&&(f=f.next={eventTime:x,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var w=e,v=l;switch(m=t,x=n,v.tag){case 1:if(w=v.payload,typeof w=="function"){h=w.call(x,h,m);break e}h=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=v.payload,m=typeof w=="function"?w.call(x,h,m):w,m==null)break e;h=Re({},h,m);break e;case 2:an=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,m=a.effects,m===null?a.effects=[l]:m.push(l))}else x={eventTime:x,lane:m,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(d=f=x,c=h):f=f.next=x,o|=m;if(l=l.next,l===null){if(l=a.shared.pending,l===null)break;m=l,l=m.next,m.next=null,a.lastBaseUpdate=m,a.shared.pending=null}}while(!0);if(f===null&&(c=h),a.baseState=c,a.firstBaseUpdate=d,a.lastBaseUpdate=f,t=a.shared.interleaved,t!==null){a=t;do o|=a.lane,a=a.next;while(a!==t)}else i===null&&(a.shared.lanes=0);Bn|=o,e.lanes=o,e.memoizedState=h}}function Gc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],a=r.callback;if(a!==null){if(r.callback=null,r=n,typeof a!="function")throw Error(M(191,a));a.call(r)}}}var Ss={},Ut=Sn(Ss),fs=Sn(Ss),ms=Sn(Ss);function An(e){if(e===Ss)throw Error(M(174));return e}function Sl(e,t){switch(ve(ms,t),ve(fs,e),ve(Ut,Ss),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:to(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=to(t,e)}Se(Ut),ve(Ut,t)}function yr(){Se(Ut),Se(fs),Se(ms)}function mf(e){An(ms.current);var t=An(Ut.current),n=to(t,e.type);t!==n&&(ve(fs,e),ve(Ut,n))}function kl(e){fs.current===e&&(Se(Ut),Se(fs))}var Te=Sn(0);function Ea(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 Ti=[];function bl(){for(var e=0;e<Ti.length;e++)Ti[e]._workInProgressVersionPrimary=null;Ti.length=0}var ta=en.ReactCurrentDispatcher,Ii=en.ReactCurrentBatchConfig,On=0,Ie=null,Me=null,Be=null,Ta=!1,Jr=!1,hs=0,cg=0;function Qe(){throw Error(M(321))}function Nl(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!$t(e[n],t[n]))return!1;return!0}function Cl(e,t,n,r,a,i){if(On=i,Ie=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ta.current=e===null||e.memoizedState===null?mg:hg,e=n(r,a),Jr){i=0;do{if(Jr=!1,hs=0,25<=i)throw Error(M(301));i+=1,Be=Me=null,t.updateQueue=null,ta.current=pg,e=n(r,a)}while(Jr)}if(ta.current=Ia,t=Me!==null&&Me.next!==null,On=0,Be=Me=Ie=null,Ta=!1,t)throw Error(M(300));return e}function El(){var e=hs!==0;return hs=0,e}function Ot(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Be===null?Ie.memoizedState=Be=e:Be=Be.next=e,Be}function Ct(){if(Me===null){var e=Ie.alternate;e=e!==null?e.memoizedState:null}else e=Me.next;var t=Be===null?Ie.memoizedState:Be.next;if(t!==null)Be=t,Me=e;else{if(e===null)throw Error(M(310));Me=e,e={memoizedState:Me.memoizedState,baseState:Me.baseState,baseQueue:Me.baseQueue,queue:Me.queue,next:null},Be===null?Ie.memoizedState=Be=e:Be=Be.next=e}return Be}function ps(e,t){return typeof t=="function"?t(e):t}function Ri(e){var t=Ct(),n=t.queue;if(n===null)throw Error(M(311));n.lastRenderedReducer=e;var r=Me,a=r.baseQueue,i=n.pending;if(i!==null){if(a!==null){var o=a.next;a.next=i.next,i.next=o}r.baseQueue=a=i,n.pending=null}if(a!==null){i=a.next,r=r.baseState;var l=o=null,c=null,d=i;do{var f=d.lane;if((On&f)===f)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var h={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=h,o=r):c=c.next=h,Ie.lanes|=f,Bn|=f}d=d.next}while(d!==null&&d!==i);c===null?o=r:c.next=l,$t(r,t.memoizedState)||(ot=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){a=e;do i=a.lane,Ie.lanes|=i,Bn|=i,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Pi(e){var t=Ct(),n=t.queue;if(n===null)throw Error(M(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,i=t.memoizedState;if(a!==null){n.pending=null;var o=a=a.next;do i=e(i,o.action),o=o.next;while(o!==a);$t(i,t.memoizedState)||(ot=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function hf(){}function pf(e,t){var n=Ie,r=Ct(),a=t(),i=!$t(r.memoizedState,a);if(i&&(r.memoizedState=a,ot=!0),r=r.queue,Tl(vf.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Be!==null&&Be.memoizedState.tag&1){if(n.flags|=2048,gs(9,yf.bind(null,n,r,a,t),void 0,null),De===null)throw Error(M(349));On&30||gf(n,t,a)}return a}function gf(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ie.updateQueue,t===null?(t={lastEffect:null,stores:null},Ie.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function yf(e,t,n,r){t.value=n,t.getSnapshot=r,xf(t)&&wf(e)}function vf(e,t,n){return n(function(){xf(t)&&wf(e)})}function xf(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!$t(e,n)}catch{return!0}}function wf(e){var t=Xt(e,1);t!==null&&Lt(t,e,1,-1)}function Kc(e){var t=Ot();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:e},t.queue=e,e=e.dispatch=fg.bind(null,Ie,e),[t.memoizedState,e]}function gs(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Ie.updateQueue,t===null?(t={lastEffect:null,stores:null},Ie.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 jf(){return Ct().memoizedState}function na(e,t,n,r){var a=Ot();Ie.flags|=e,a.memoizedState=gs(1|t,n,void 0,r===void 0?null:r)}function Ka(e,t,n,r){var a=Ct();r=r===void 0?null:r;var i=void 0;if(Me!==null){var o=Me.memoizedState;if(i=o.destroy,r!==null&&Nl(r,o.deps)){a.memoizedState=gs(t,n,i,r);return}}Ie.flags|=e,a.memoizedState=gs(1|t,n,i,r)}function Yc(e,t){return na(8390656,8,e,t)}function Tl(e,t){return Ka(2048,8,e,t)}function Sf(e,t){return Ka(4,2,e,t)}function kf(e,t){return Ka(4,4,e,t)}function bf(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 Nf(e,t,n){return n=n!=null?n.concat([e]):null,Ka(4,4,bf.bind(null,t,e),n)}function Il(){}function Cf(e,t){var n=Ct();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 Ef(e,t){var n=Ct();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 Tf(e,t,n){return On&21?($t(n,t)||(n=Ad(),Ie.lanes|=n,Bn|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ot=!0),e.memoizedState=n)}function ug(e,t){var n=ye;ye=n!==0&&4>n?n:4,e(!0);var r=Ii.transition;Ii.transition={};try{e(!1),t()}finally{ye=n,Ii.transition=r}}function If(){return Ct().memoizedState}function dg(e,t,n){var r=yn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Rf(e))Pf(t,n);else if(n=df(e,t,n,r),n!==null){var a=nt();Lt(n,e,r,a),Af(n,t,r)}}function fg(e,t,n){var r=yn(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rf(e))Pf(t,a);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,l=i(o,n);if(a.hasEagerState=!0,a.eagerState=l,$t(l,o)){var c=t.interleaved;c===null?(a.next=a,wl(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=df(e,t,a,r),n!==null&&(a=nt(),Lt(n,e,r,a),Af(n,t,r))}}function Rf(e){var t=e.alternate;return e===Ie||t!==null&&t===Ie}function Pf(e,t){Jr=Ta=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Af(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,il(e,n)}}var Ia={readContext:Nt,useCallback:Qe,useContext:Qe,useEffect:Qe,useImperativeHandle:Qe,useInsertionEffect:Qe,useLayoutEffect:Qe,useMemo:Qe,useReducer:Qe,useRef:Qe,useState:Qe,useDebugValue:Qe,useDeferredValue:Qe,useTransition:Qe,useMutableSource:Qe,useSyncExternalStore:Qe,useId:Qe,unstable_isNewReconciler:!1},mg={readContext:Nt,useCallback:function(e,t){return Ot().memoizedState=[e,t===void 0?null:t],e},useContext:Nt,useEffect:Yc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,na(4194308,4,bf.bind(null,t,e),n)},useLayoutEffect:function(e,t){return na(4194308,4,e,t)},useInsertionEffect:function(e,t){return na(4,2,e,t)},useMemo:function(e,t){var n=Ot();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ot();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=dg.bind(null,Ie,e),[r.memoizedState,e]},useRef:function(e){var t=Ot();return e={current:e},t.memoizedState=e},useState:Kc,useDebugValue:Il,useDeferredValue:function(e){return Ot().memoizedState=e},useTransition:function(){var e=Kc(!1),t=e[0];return e=ug.bind(null,e[1]),Ot().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ie,a=Ot();if(be){if(n===void 0)throw Error(M(407));n=n()}else{if(n=t(),De===null)throw Error(M(349));On&30||gf(r,t,n)}a.memoizedState=n;var i={value:n,getSnapshot:t};return a.queue=i,Yc(vf.bind(null,r,i,e),[e]),r.flags|=2048,gs(9,yf.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Ot(),t=De.identifierPrefix;if(be){var n=Kt,r=Gt;n=(r&~(1<<32-_t(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=hs++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=cg++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},hg={readContext:Nt,useCallback:Cf,useContext:Nt,useEffect:Tl,useImperativeHandle:Nf,useInsertionEffect:Sf,useLayoutEffect:kf,useMemo:Ef,useReducer:Ri,useRef:jf,useState:function(){return Ri(ps)},useDebugValue:Il,useDeferredValue:function(e){var t=Ct();return Tf(t,Me.memoizedState,e)},useTransition:function(){var e=Ri(ps)[0],t=Ct().memoizedState;return[e,t]},useMutableSource:hf,useSyncExternalStore:pf,useId:If,unstable_isNewReconciler:!1},pg={readContext:Nt,useCallback:Cf,useContext:Nt,useEffect:Tl,useImperativeHandle:Nf,useInsertionEffect:Sf,useLayoutEffect:kf,useMemo:Ef,useReducer:Pi,useRef:jf,useState:function(){return Pi(ps)},useDebugValue:Il,useDeferredValue:function(e){var t=Ct();return Me===null?t.memoizedState=e:Tf(t,Me.memoizedState,e)},useTransition:function(){var e=Pi(ps)[0],t=Ct().memoizedState;return[e,t]},useMutableSource:hf,useSyncExternalStore:pf,useId:If,unstable_isNewReconciler:!1};function It(e,t){if(e&&e.defaultProps){t=Re({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function ko(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Re({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ya={isMounted:function(e){return(e=e._reactInternals)?Hn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=nt(),a=yn(e),i=Yt(r,a);i.payload=t,n!=null&&(i.callback=n),t=pn(e,i,a),t!==null&&(Lt(t,e,a,r),ea(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=nt(),a=yn(e),i=Yt(r,a);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=pn(e,i,a),t!==null&&(Lt(t,e,a,r),ea(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=nt(),r=yn(e),a=Yt(n,r);a.tag=2,t!=null&&(a.callback=t),t=pn(e,a,r),t!==null&&(Lt(t,e,r,n),ea(t,e,r))}};function Qc(e,t,n,r,a,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,o):t.prototype&&t.prototype.isPureReactComponent?!ls(n,r)||!ls(a,i):!0}function _f(e,t,n){var r=!1,a=wn,i=t.contextType;return typeof i=="object"&&i!==null?i=Nt(i):(a=ct(t)?Mn:qe.current,r=t.contextTypes,i=(r=r!=null)?hr(e,a):wn),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ya,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=i),t}function Jc(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&&Ya.enqueueReplaceState(t,t.state,null)}function bo(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},jl(e);var i=t.contextType;typeof i=="object"&&i!==null?a.context=Nt(i):(i=ct(t)?Mn:qe.current,a.context=hr(e,i)),a.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(ko(e,t,i,n),a.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(t=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),t!==a.state&&Ya.enqueueReplaceState(a,a.state,null),Ca(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function vr(e,t){try{var n="",r=t;do n+=Wh(r),r=r.return;while(r);var a=n}catch(i){a=`
|
|
39
39
|
Error generating stack: `+i.message+`
|
|
40
|
-
`+i.stack}return{value:e,source:t,stack:a,digest:null}}function Ri(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function So(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var ag=typeof WeakMap=="function"?WeakMap:Map;function Cf(e,t,n){n=Yt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Ra||(Ra=!0,Ao=r),So(e,t)},n}function Ef(e,t,n){n=Yt(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var a=t.value;n.payload=function(){return r(a)},n.callback=function(){So(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){So(e,t),typeof r!="function"&&(gn===null?gn=new Set([this]):gn.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function Hc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new ag;var a=new Set;r.set(t,a)}else a=r.get(t),a===void 0&&(a=new Set,r.set(t,a));a.has(n)||(a.add(n),e=xg.bind(null,e,t,n),t.then(e,e))}function Vc(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 Gc(e,t,n,r,a){return e.mode&1?(e.flags|=65536,e.lanes=a,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Yt(-1,1),t.tag=2,hn(n,t,1))),n.lanes|=1),e)}var ig=en.ReactCurrentOwner,ot=!1;function et(e,t,n,r){t.child=e===null?tf(t,null,n,r):hr(t,e.child,n,r)}function Kc(e,t,n,r,a){n=n.render;var i=t.ref;return ur(t,a),r=kl(e,t,n,r,i,a),n=bl(),e!==null&&!ot?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,qt(e,t,a)):(be&&n&&dl(t),t.flags|=1,et(e,t,r,a),t.child)}function Yc(e,t,n,r,a){if(e===null){var i=n.type;return typeof i=="function"&&!zl(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,Tf(e,t,i,r,a)):(e=aa(n.type,null,r,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&a)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:is,n(o,r)&&e.ref===t.ref)return qt(e,t,a)}return t.flags|=1,e=vn(i,r),e.ref=t.ref,e.return=t,t.child=e}function Tf(e,t,n,r,a){if(e!==null){var i=e.memoizedProps;if(is(i,r)&&e.ref===t.ref)if(ot=!1,t.pendingProps=r=i,(e.lanes&a)!==0)e.flags&131072&&(ot=!0);else return t.lanes=e.lanes,qt(e,t,a)}return ko(e,t,n,r,a)}function If(e,t,n){var r=t.pendingProps,a=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ve(ar,dt),dt|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,ve(ar,dt),dt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,ve(ar,dt),dt|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,ve(ar,dt),dt|=r;return et(e,t,a,n),t.child}function Rf(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function ko(e,t,n,r,a){var i=ct(n)?Mn:qe.current;return i=mr(t,i),ur(t,a),n=kl(e,t,n,r,i,a),r=bl(),e!==null&&!ot?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,qt(e,t,a)):(be&&r&&dl(t),t.flags|=1,et(e,t,n,a),t.child)}function Qc(e,t,n,r,a){if(ct(n)){var i=!0;wa(t)}else i=!1;if(ur(t,a),t.stateNode===null)na(e,t),Nf(t,n,r),jo(t,n,r,a),r=!0;else if(e===null){var o=t.stateNode,l=t.memoizedProps;o.props=l;var c=o.context,d=n.contextType;typeof d=="object"&&d!==null?d=Nt(d):(d=ct(n)?Mn:qe.current,d=mr(t,d));var f=n.getDerivedStateFromProps,m=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function";m||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==r||c!==d)&&Wc(t,o,r,d),an=!1;var p=t.memoizedState;o.state=p,Na(t,r,o,a),c=t.memoizedState,l!==r||p!==c||lt.current||an?(typeof f=="function"&&(wo(t,n,f,r),c=t.memoizedState),(l=an||Uc(t,n,l,r,p,c,d))?(m||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=d,r=l):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,rf(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:It(t.type,l),o.props=d,m=t.pendingProps,p=o.context,c=n.contextType,typeof c=="object"&&c!==null?c=Nt(c):(c=ct(n)?Mn:qe.current,c=mr(t,c));var x=n.getDerivedStateFromProps;(f=typeof x=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==m||p!==c)&&Wc(t,o,r,c),an=!1,p=t.memoizedState,o.state=p,Na(t,r,o,a);var w=t.memoizedState;l!==m||p!==w||lt.current||an?(typeof x=="function"&&(wo(t,n,x,r),w=t.memoizedState),(d=an||Uc(t,n,d,r,p,w,c)||!1)?(f||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,w,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,w,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=w),o.props=r,o.state=w,o.context=c,r=d):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return bo(e,t,n,r,i,a)}function bo(e,t,n,r,a,i){Rf(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return a&&zc(t,n,!1),qt(e,t,i);r=t.stateNode,ig.current=t;var l=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=hr(t,e.child,null,i),t.child=hr(t,null,l,i)):et(e,t,l,i),t.memoizedState=r.state,a&&zc(t,n,!0),t.child}function Pf(e){var t=e.stateNode;t.pendingContext?_c(e,t.pendingContext,t.pendingContext!==t.context):t.context&&_c(e,t.context,!1),xl(e,t.containerInfo)}function Jc(e,t,n,r,a){return pr(),ml(a),t.flags|=256,et(e,t,n,r),t.child}var No={dehydrated:null,treeContext:null,retryLane:0};function Co(e){return{baseLanes:e,cachePool:null,transitions:null}}function Af(e,t,n){var r=t.pendingProps,a=Te.current,i=!1,o=(t.flags&128)!==0,l;if((l=o)||(l=e!==null&&e.memoizedState===null?!1:(a&2)!==0),l?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),ve(Te,a&1),e===null)return vo(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):(o=r.children,e=r.fallback,i?(r=t.mode,i=t.child,o={mode:"hidden",children:o},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Ja(o,r,0,null),e=Ln(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Co(n),t.memoizedState=No,e):El(t,o));if(a=e.memoizedState,a!==null&&(l=a.dehydrated,l!==null))return og(e,t,o,r,l,a,n);if(i){i=r.fallback,o=t.mode,a=e.child,l=a.sibling;var c={mode:"hidden",children:r.children};return!(o&1)&&t.child!==a?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=vn(a,c),r.subtreeFlags=a.subtreeFlags&14680064),l!==null?i=vn(l,i):(i=Ln(i,o,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,o=e.child.memoizedState,o=o===null?Co(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=No,r}return i=e.child,e=i.sibling,r=vn(i,{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 El(e,t){return t=Ja({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Os(e,t,n,r){return r!==null&&ml(r),hr(t,e.child,null,n),e=El(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function og(e,t,n,r,a,i,o){if(n)return t.flags&256?(t.flags&=-257,r=Ri(Error(M(422))),Os(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,a=t.mode,r=Ja({mode:"visible",children:r.children},a,0,null),i=Ln(i,a,o,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&hr(t,e.child,null,o),t.child.memoizedState=Co(o),t.memoizedState=No,i);if(!(t.mode&1))return Os(e,t,o,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(M(419)),r=Ri(i,r,void 0),Os(e,t,o,r)}if(l=(o&e.childLanes)!==0,ot||l){if(r=De,r!==null){switch(o&-o){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=a&(r.suspendedLanes|o)?0:a,a!==0&&a!==i.retryLane&&(i.retryLane=a,Xt(e,a),zt(r,e,a,-1))}return _l(),r=Ri(Error(M(421))),Os(e,t,o,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=wg.bind(null,e),a._reactRetry=t,null):(e=i.treeContext,ft=pn(a.nextSibling),mt=t,be=!0,Pt=null,e!==null&&(jt[St++]=Gt,jt[St++]=Kt,jt[St++]=Fn,Gt=e.id,Kt=e.overflow,Fn=t),t=El(t,r.children),t.flags|=4096,t)}function Xc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),xo(e.return,t,n)}function Pi(e,t,n,r,a){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=a)}function _f(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;if(et(e,t,r.children,n),r=Te.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Xc(e,n,t);else if(e.tag===19)Xc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(ve(Te,r),!(t.mode&1))t.memoizedState=null;else switch(a){case"forwards":for(n=t.child,a=null;n!==null;)e=n.alternate,e!==null&&Ca(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Pi(t,!1,a,n,i);break;case"backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&Ca(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Pi(t,!0,n,null,i);break;case"together":Pi(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function na(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function qt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Bn|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(M(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 lg(e,t,n){switch(t.tag){case 3:Pf(t),pr();break;case 5:sf(t);break;case 1:ct(t.type)&&wa(t);break;case 4:xl(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;ve(ka,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(ve(Te,Te.current&1),t.flags|=128,null):n&t.child.childLanes?Af(e,t,n):(ve(Te,Te.current&1),e=qt(e,t,n),e!==null?e.sibling:null);ve(Te,Te.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return _f(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),ve(Te,Te.current),r)break;return null;case 22:case 23:return t.lanes=0,If(e,t,n)}return qt(e,t,n)}var zf,Eo,$f,Lf;zf=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}};Eo=function(){};$f=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,An(Dt.current);var i=null;switch(n){case"input":a=Yi(e,a),r=Yi(e,r),i=[];break;case"select":a=Re({},a,{value:void 0}),r=Re({},r,{value:void 0}),i=[];break;case"textarea":a=Xi(e,a),r=Xi(e,r),i=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=va)}Zi(n,r);var o;n=null;for(d in a)if(!r.hasOwnProperty(d)&&a.hasOwnProperty(d)&&a[d]!=null)if(d==="style"){var l=a[d];for(o in l)l.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Zr.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in r){var c=r[d];if(l=a!=null?a[d]:void 0,r.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="style")if(l){for(o in l)!l.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in c)c.hasOwnProperty(o)&&l[o]!==c[o]&&(n||(n={}),n[o]=c[o])}else n||(i||(i=[]),i.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Zr.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&we("scroll",e),i||l===c||(i=[])):(i=i||[]).push(d,c))}n&&(i=i||[]).push("style",n);var d=i;(t.updateQueue=d)&&(t.flags|=4)}};Lf=function(e,t,n,r){n!==r&&(t.flags|=4)};function Ar(e,t){if(!be)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 Je(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags&14680064,r|=a.flags&14680064,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function cg(e,t,n){var r=t.pendingProps;switch(fl(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Je(t),null;case 1:return ct(t.type)&&xa(),Je(t),null;case 3:return r=t.stateNode,gr(),Se(lt),Se(qe),jl(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Ms(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Pt!==null&&($o(Pt),Pt=null))),Eo(e,t),Je(t),null;case 5:wl(t);var a=An(ds.current);if(n=t.type,e!==null&&t.stateNode!=null)$f(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(M(166));return Je(t),null}if(e=An(Dt.current),Ms(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Ot]=t,r[cs]=i,e=(t.mode&1)!==0,n){case"dialog":we("cancel",r),we("close",r);break;case"iframe":case"object":case"embed":we("load",r);break;case"video":case"audio":for(a=0;a<Dr.length;a++)we(Dr[a],r);break;case"source":we("error",r);break;case"img":case"image":case"link":we("error",r),we("load",r);break;case"details":we("toggle",r);break;case"input":ic(r,i),we("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},we("invalid",r);break;case"textarea":lc(r,i),we("invalid",r)}Zi(n,i),a=null;for(var o in i)if(i.hasOwnProperty(o)){var l=i[o];o==="children"?typeof l=="string"?r.textContent!==l&&(i.suppressHydrationWarning!==!0&&Ls(r.textContent,l,e),a=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&Ls(r.textContent,l,e),a=["children",""+l]):Zr.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&we("scroll",r)}switch(n){case"input":Ts(r),oc(r,i,!0);break;case"textarea":Ts(r),cc(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=va)}r=a,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=cd(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Ot]=t,e[cs]=r,zf(e,t,!1,!1),t.stateNode=e;e:{switch(o=eo(n,r),n){case"dialog":we("cancel",e),we("close",e),a=r;break;case"iframe":case"object":case"embed":we("load",e),a=r;break;case"video":case"audio":for(a=0;a<Dr.length;a++)we(Dr[a],e);a=r;break;case"source":we("error",e),a=r;break;case"img":case"image":case"link":we("error",e),we("load",e),a=r;break;case"details":we("toggle",e),a=r;break;case"input":ic(e,r),a=Yi(e,r),we("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=Re({},r,{value:void 0}),we("invalid",e);break;case"textarea":lc(e,r),a=Xi(e,r),we("invalid",e);break;default:a=r}Zi(n,a),l=a;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?fd(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&ud(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&es(e,c):typeof c=="number"&&es(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Zr.hasOwnProperty(i)?c!=null&&i==="onScroll"&&we("scroll",e):c!=null&&Xo(e,i,c,o))}switch(n){case"input":Ts(e),oc(e,r,!1);break;case"textarea":Ts(e),cc(e);break;case"option":r.value!=null&&e.setAttribute("value",""+xn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?ir(e,!!r.multiple,i,!1):r.defaultValue!=null&&ir(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=va)}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 Je(t),null;case 6:if(e&&t.stateNode!=null)Lf(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(M(166));if(n=An(ds.current),An(Dt.current),Ms(t)){if(r=t.stateNode,n=t.memoizedProps,r[Ot]=t,(i=r.nodeValue!==n)&&(e=mt,e!==null))switch(e.tag){case 3:Ls(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ls(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Ot]=t,t.stateNode=r}return Je(t),null;case 13:if(Se(Te),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(be&&ft!==null&&t.mode&1&&!(t.flags&128))Zd(),pr(),t.flags|=98560,i=!1;else if(i=Ms(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(M(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(M(317));i[Ot]=t}else pr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Je(t),i=!1}else Pt!==null&&($o(Pt),Pt=null),i=!0;if(!i)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||Te.current&1?Fe===0&&(Fe=3):_l())),t.updateQueue!==null&&(t.flags|=4),Je(t),null);case 4:return gr(),Eo(e,t),e===null&&os(t.stateNode.containerInfo),Je(t),null;case 10:return gl(t.type._context),Je(t),null;case 17:return ct(t.type)&&xa(),Je(t),null;case 19:if(Se(Te),i=t.memoizedState,i===null)return Je(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)Ar(i,!1);else{if(Fe!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Ca(e),o!==null){for(t.flags|=128,Ar(i,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return ve(Te,Te.current&1|2),t.child}e=e.sibling}i.tail!==null&&ze()>vr&&(t.flags|=128,r=!0,Ar(i,!1),t.lanes=4194304)}else{if(!r)if(e=Ca(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Ar(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!be)return Je(t),null}else 2*ze()-i.renderingStartTime>vr&&n!==1073741824&&(t.flags|=128,r=!0,Ar(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=ze(),t.sibling=null,n=Te.current,ve(Te,r?n&1|2:n&1),t):(Je(t),null);case 22:case 23:return Al(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?dt&1073741824&&(Je(t),t.subtreeFlags&6&&(t.flags|=8192)):Je(t),null;case 24:return null;case 25:return null}throw Error(M(156,t.tag))}function ug(e,t){switch(fl(t),t.tag){case 1:return ct(t.type)&&xa(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return gr(),Se(lt),Se(qe),jl(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return wl(t),null;case 13:if(Se(Te),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(M(340));pr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Se(Te),null;case 4:return gr(),null;case 10:return gl(t.type._context),null;case 22:case 23:return Al(),null;case 24:return null;default:return null}}var Bs=!1,Xe=!1,dg=typeof WeakSet=="function"?WeakSet:Set,J=null;function sr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ae(e,t,r)}else n.current=null}function To(e,t,n){try{n()}catch(r){Ae(e,t,r)}}var qc=!1;function fg(e,t){if(uo=ha,e=Bd(),ul(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,l=-1,c=-1,d=0,f=0,m=e,p=null;t:for(;;){for(var x;m!==n||a!==0&&m.nodeType!==3||(l=o+a),m!==i||r!==0&&m.nodeType!==3||(c=o+r),m.nodeType===3&&(o+=m.nodeValue.length),(x=m.firstChild)!==null;)p=m,m=x;for(;;){if(m===e)break t;if(p===n&&++d===a&&(l=o),p===i&&++f===r&&(c=o),(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(fo={focusedElem:e,selectionRange:n},ha=!1,J=t;J!==null;)if(t=J,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,J=e;else for(;J!==null;){t=J;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 v=w.memoizedProps,S=w.memoizedState,g=t.stateNode,h=g.getSnapshotBeforeUpdate(t.elementType===t.type?v:It(t.type,v),S);g.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(M(163))}}catch(j){Ae(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,J=e;break}J=t.return}return w=qc,qc=!1,w}function Qr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&e)===e){var i=a.destroy;a.destroy=void 0,i!==void 0&&To(t,n,i)}a=a.next}while(a!==r)}}function Ya(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 Io(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 Mf(e){var t=e.alternate;t!==null&&(e.alternate=null,Mf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ot],delete t[cs],delete t[ho],delete t[Yh],delete t[Qh])),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 Ff(e){return e.tag===5||e.tag===3||e.tag===4}function Zc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ff(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 Ro(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=va));else if(r!==4&&(e=e.child,e!==null))for(Ro(e,t,n),e=e.sibling;e!==null;)Ro(e,t,n),e=e.sibling}function Po(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(Po(e,t,n),e=e.sibling;e!==null;)Po(e,t,n),e=e.sibling}var We=null,Rt=!1;function rn(e,t,n){for(n=n.child;n!==null;)Of(e,t,n),n=n.sibling}function Of(e,t,n){if(Bt&&typeof Bt.onCommitFiberUnmount=="function")try{Bt.onCommitFiberUnmount(Ba,n)}catch{}switch(n.tag){case 5:Xe||sr(n,t);case 6:var r=We,a=Rt;We=null,rn(e,t,n),We=r,Rt=a,We!==null&&(Rt?(e=We,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):We.removeChild(n.stateNode));break;case 18:We!==null&&(Rt?(e=We,n=n.stateNode,e.nodeType===8?bi(e.parentNode,n):e.nodeType===1&&bi(e,n),ss(e)):bi(We,n.stateNode));break;case 4:r=We,a=Rt,We=n.stateNode.containerInfo,Rt=!0,rn(e,t,n),We=r,Rt=a;break;case 0:case 11:case 14:case 15:if(!Xe&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){a=r=r.next;do{var i=a,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&To(n,t,o),a=a.next}while(a!==r)}rn(e,t,n);break;case 1:if(!Xe&&(sr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Ae(n,t,l)}rn(e,t,n);break;case 21:rn(e,t,n);break;case 22:n.mode&1?(Xe=(r=Xe)||n.memoizedState!==null,rn(e,t,n),Xe=r):rn(e,t,n);break;default:rn(e,t,n)}}function eu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new dg),t.forEach(function(r){var a=jg.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function Tt(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r];try{var i=e,o=t,l=o;e:for(;l!==null;){switch(l.tag){case 5:We=l.stateNode,Rt=!1;break e;case 3:We=l.stateNode.containerInfo,Rt=!0;break e;case 4:We=l.stateNode.containerInfo,Rt=!0;break e}l=l.return}if(We===null)throw Error(M(160));Of(i,o,a),We=null,Rt=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(d){Ae(a,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Bf(t,e),t=t.sibling}function Bf(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Tt(t,e),Mt(e),r&4){try{Qr(3,e,e.return),Ya(3,e)}catch(v){Ae(e,e.return,v)}try{Qr(5,e,e.return)}catch(v){Ae(e,e.return,v)}}break;case 1:Tt(t,e),Mt(e),r&512&&n!==null&&sr(n,n.return);break;case 5:if(Tt(t,e),Mt(e),r&512&&n!==null&&sr(n,n.return),e.flags&32){var a=e.stateNode;try{es(a,"")}catch(v){Ae(e,e.return,v)}}if(r&4&&(a=e.stateNode,a!=null)){var i=e.memoizedProps,o=n!==null?n.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&od(a,i),eo(l,o);var d=eo(l,i);for(o=0;o<c.length;o+=2){var f=c[o],m=c[o+1];f==="style"?fd(a,m):f==="dangerouslySetInnerHTML"?ud(a,m):f==="children"?es(a,m):Xo(a,f,m,d)}switch(l){case"input":Qi(a,i);break;case"textarea":ld(a,i);break;case"select":var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!i.multiple;var x=i.value;x!=null?ir(a,!!i.multiple,x,!1):p!==!!i.multiple&&(i.defaultValue!=null?ir(a,!!i.multiple,i.defaultValue,!0):ir(a,!!i.multiple,i.multiple?[]:"",!1))}a[cs]=i}catch(v){Ae(e,e.return,v)}}break;case 6:if(Tt(t,e),Mt(e),r&4){if(e.stateNode===null)throw Error(M(162));a=e.stateNode,i=e.memoizedProps;try{a.nodeValue=i}catch(v){Ae(e,e.return,v)}}break;case 3:if(Tt(t,e),Mt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{ss(t.containerInfo)}catch(v){Ae(e,e.return,v)}break;case 4:Tt(t,e),Mt(e);break;case 13:Tt(t,e),Mt(e),a=e.child,a.flags&8192&&(i=a.memoizedState!==null,a.stateNode.isHidden=i,!i||a.alternate!==null&&a.alternate.memoizedState!==null||(Rl=ze())),r&4&&eu(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Xe=(d=Xe)||f,Tt(t,e),Xe=d):Tt(t,e),Mt(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(J=e,f=e.child;f!==null;){for(m=J=f;J!==null;){switch(p=J,x=p.child,p.tag){case 0:case 11:case 14:case 15:Qr(4,p,p.return);break;case 1:sr(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(v){Ae(r,n,v)}}break;case 5:sr(p,p.return);break;case 22:if(p.memoizedState!==null){nu(m);continue}}x!==null?(x.return=p,J=x):nu(m)}f=f.sibling}e:for(f=null,m=e;;){if(m.tag===5){if(f===null){f=m;try{a=m.stateNode,d?(i=a.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=m.stateNode,c=m.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=dd("display",o))}catch(v){Ae(e,e.return,v)}}}else if(m.tag===6){if(f===null)try{m.stateNode.nodeValue=d?"":m.memoizedProps}catch(v){Ae(e,e.return,v)}}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:Tt(t,e),Mt(e),r&4&&eu(e);break;case 21:break;default:Tt(t,e),Mt(e)}}function Mt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Ff(n)){var r=n;break e}n=n.return}throw Error(M(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(es(a,""),r.flags&=-33);var i=Zc(e);Po(e,i,a);break;case 3:case 4:var o=r.stateNode.containerInfo,l=Zc(e);Ro(e,l,o);break;default:throw Error(M(161))}}catch(c){Ae(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function mg(e,t,n){J=e,Df(e)}function Df(e,t,n){for(var r=(e.mode&1)!==0;J!==null;){var a=J,i=a.child;if(a.tag===22&&r){var o=a.memoizedState!==null||Bs;if(!o){var l=a.alternate,c=l!==null&&l.memoizedState!==null||Xe;l=Bs;var d=Xe;if(Bs=o,(Xe=c)&&!d)for(J=a;J!==null;)o=J,c=o.child,o.tag===22&&o.memoizedState!==null?ru(a):c!==null?(c.return=o,J=c):ru(a);for(;i!==null;)J=i,Df(i),i=i.sibling;J=a,Bs=l,Xe=d}tu(e)}else a.subtreeFlags&8772&&i!==null?(i.return=a,J=i):tu(e)}}function tu(e){for(;J!==null;){var t=J;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Xe||Ya(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Xe)if(n===null)r.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:It(t.type,n.memoizedProps);r.componentDidUpdate(a,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Oc(t,i,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Oc(t,o,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&&ss(m)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(M(163))}Xe||t.flags&512&&Io(t)}catch(p){Ae(t,t.return,p)}}if(t===e){J=null;break}if(n=t.sibling,n!==null){n.return=t.return,J=n;break}J=t.return}}function nu(e){for(;J!==null;){var t=J;if(t===e){J=null;break}var n=t.sibling;if(n!==null){n.return=t.return,J=n;break}J=t.return}}function ru(e){for(;J!==null;){var t=J;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Ya(4,t)}catch(c){Ae(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(c){Ae(t,a,c)}}var i=t.return;try{Io(t)}catch(c){Ae(t,i,c)}break;case 5:var o=t.return;try{Io(t)}catch(c){Ae(t,o,c)}}}catch(c){Ae(t,t.return,c)}if(t===e){J=null;break}var l=t.sibling;if(l!==null){l.return=t.return,J=l;break}J=t.return}}var pg=Math.ceil,Ia=en.ReactCurrentDispatcher,Tl=en.ReactCurrentOwner,bt=en.ReactCurrentBatchConfig,me=0,De=null,$e=null,He=0,dt=0,ar=Sn(0),Fe=0,hs=null,Bn=0,Qa=0,Il=0,Jr=null,it=null,Rl=0,vr=1/0,Wt=null,Ra=!1,Ao=null,gn=null,Ds=!1,un=null,Pa=0,Xr=0,_o=null,ra=-1,sa=0;function nt(){return me&6?ze():ra!==-1?ra:ra=ze()}function yn(e){return e.mode&1?me&2&&He!==0?He&-He:Xh.transition!==null?(sa===0&&(sa=bd()),sa):(e=ye,e!==0||(e=window.event,e=e===void 0?16:Pd(e.type)),e):1}function zt(e,t,n,r){if(50<Xr)throw Xr=0,_o=null,Error(M(185));vs(e,n,r),(!(me&2)||e!==De)&&(e===De&&(!(me&2)&&(Qa|=n),Fe===4&&ln(e,He)),ut(e,r),n===1&&me===0&&!(t.mode&1)&&(vr=ze()+500,Va&&kn()))}function ut(e,t){var n=e.callbackNode;Xp(e,t);var r=pa(e,e===De?He:0);if(r===0)n!==null&&fc(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&fc(n),t===1)e.tag===0?Jh(su.bind(null,e)):Jd(su.bind(null,e)),Gh(function(){!(me&6)&&kn()}),n=null;else{switch(Nd(r)){case 1:n=nl;break;case 4:n=Sd;break;case 16:n=ma;break;case 536870912:n=kd;break;default:n=ma}n=Qf(n,Uf.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Uf(e,t){if(ra=-1,sa=0,me&6)throw Error(M(327));var n=e.callbackNode;if(dr()&&e.callbackNode!==n)return null;var r=pa(e,e===De?He:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Aa(e,r);else{t=r;var a=me;me|=2;var i=Hf();(De!==e||He!==t)&&(Wt=null,vr=ze()+500,$n(e,t));do try{yg();break}catch(l){Wf(e,l)}while(!0);hl(),Ia.current=i,me=a,$e!==null?t=0:(De=null,He=0,t=Fe)}if(t!==0){if(t===2&&(a=ao(e),a!==0&&(r=a,t=zo(e,a))),t===1)throw n=hs,$n(e,0),ln(e,r),ut(e,ze()),n;if(t===6)ln(e,r);else{if(a=e.current.alternate,!(r&30)&&!hg(a)&&(t=Aa(e,r),t===2&&(i=ao(e),i!==0&&(r=i,t=zo(e,i))),t===1))throw n=hs,$n(e,0),ln(e,r),ut(e,ze()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(M(345));case 2:Tn(e,it,Wt);break;case 3:if(ln(e,r),(r&130023424)===r&&(t=Rl+500-ze(),10<t)){if(pa(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){nt(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=po(Tn.bind(null,e,it,Wt),t);break}Tn(e,it,Wt);break;case 4:if(ln(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var o=31-_t(r);i=1<<o,o=t[o],o>a&&(a=o),r&=~i}if(r=a,r=ze()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*pg(r/1960))-r,10<r){e.timeoutHandle=po(Tn.bind(null,e,it,Wt),r);break}Tn(e,it,Wt);break;case 5:Tn(e,it,Wt);break;default:throw Error(M(329))}}}return ut(e,ze()),e.callbackNode===n?Uf.bind(null,e):null}function zo(e,t){var n=Jr;return e.current.memoizedState.isDehydrated&&($n(e,t).flags|=256),e=Aa(e,t),e!==2&&(t=it,it=n,t!==null&&$o(t)),e}function $o(e){it===null?it=e:it.push.apply(it,e)}function hg(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var a=n[r],i=a.getSnapshot;a=a.value;try{if(!$t(i(),a))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ln(e,t){for(t&=~Il,t&=~Qa,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-_t(t),r=1<<n;e[n]=-1,t&=~r}}function su(e){if(me&6)throw Error(M(327));dr();var t=pa(e,0);if(!(t&1))return ut(e,ze()),null;var n=Aa(e,t);if(e.tag!==0&&n===2){var r=ao(e);r!==0&&(t=r,n=zo(e,r))}if(n===1)throw n=hs,$n(e,0),ln(e,t),ut(e,ze()),n;if(n===6)throw Error(M(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Tn(e,it,Wt),ut(e,ze()),null}function Pl(e,t){var n=me;me|=1;try{return e(t)}finally{me=n,me===0&&(vr=ze()+500,Va&&kn())}}function Dn(e){un!==null&&un.tag===0&&!(me&6)&&dr();var t=me;me|=1;var n=bt.transition,r=ye;try{if(bt.transition=null,ye=1,e)return e()}finally{ye=r,bt.transition=n,me=t,!(me&6)&&kn()}}function Al(){dt=ar.current,Se(ar)}function $n(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Vh(n)),$e!==null)for(n=$e.return;n!==null;){var r=n;switch(fl(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&xa();break;case 3:gr(),Se(lt),Se(qe),jl();break;case 5:wl(r);break;case 4:gr();break;case 13:Se(Te);break;case 19:Se(Te);break;case 10:gl(r.type._context);break;case 22:case 23:Al()}n=n.return}if(De=e,$e=e=vn(e.current,null),He=dt=t,Fe=0,hs=null,Il=Qa=Bn=0,it=Jr=null,Pn!==null){for(t=0;t<Pn.length;t++)if(n=Pn[t],r=n.interleaved,r!==null){n.interleaved=null;var a=r.next,i=n.pending;if(i!==null){var o=i.next;i.next=a,r.next=o}n.pending=r}Pn=null}return e}function Wf(e,t){do{var n=$e;try{if(hl(),ea.current=Ta,Ea){for(var r=Ie.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}Ea=!1}if(On=0,Be=Me=Ie=null,Yr=!1,fs=0,Tl.current=null,n===null||n.return===null){Fe=1,hs=t,$e=null;break}e:{var i=e,o=n.return,l=n,c=t;if(t=He,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=Vc(o);if(x!==null){x.flags&=-257,Gc(x,o,l,i,t),x.mode&1&&Hc(i,d,t),t=x,c=d;var w=t.updateQueue;if(w===null){var v=new Set;v.add(c),t.updateQueue=v}else w.add(c);break e}else{if(!(t&1)){Hc(i,d,t),_l();break e}c=Error(M(426))}}else if(be&&l.mode&1){var S=Vc(o);if(S!==null){!(S.flags&65536)&&(S.flags|=256),Gc(S,o,l,i,t),ml(yr(c,l));break e}}i=c=yr(c,l),Fe!==4&&(Fe=2),Jr===null?Jr=[i]:Jr.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var g=Cf(i,c,t);Fc(i,g);break e;case 1:l=c;var h=i.type,y=i.stateNode;if(!(i.flags&128)&&(typeof h.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(gn===null||!gn.has(y)))){i.flags|=65536,t&=-t,i.lanes|=t;var j=Ef(i,l,t);Fc(i,j);break e}}i=i.return}while(i!==null)}Gf(n)}catch(b){t=b,$e===n&&n!==null&&($e=n=n.return);continue}break}while(!0)}function Hf(){var e=Ia.current;return Ia.current=Ta,e===null?Ta:e}function _l(){(Fe===0||Fe===3||Fe===2)&&(Fe=4),De===null||!(Bn&268435455)&&!(Qa&268435455)||ln(De,He)}function Aa(e,t){var n=me;me|=2;var r=Hf();(De!==e||He!==t)&&(Wt=null,$n(e,t));do try{gg();break}catch(a){Wf(e,a)}while(!0);if(hl(),me=n,Ia.current=r,$e!==null)throw Error(M(261));return De=null,He=0,Fe}function gg(){for(;$e!==null;)Vf($e)}function yg(){for(;$e!==null&&!Up();)Vf($e)}function Vf(e){var t=Yf(e.alternate,e,dt);e.memoizedProps=e.pendingProps,t===null?Gf(e):$e=t,Tl.current=null}function Gf(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=ug(n,t),n!==null){n.flags&=32767,$e=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Fe=6,$e=null;return}}else if(n=cg(n,t,dt),n!==null){$e=n;return}if(t=t.sibling,t!==null){$e=t;return}$e=t=e}while(t!==null);Fe===0&&(Fe=5)}function Tn(e,t,n){var r=ye,a=bt.transition;try{bt.transition=null,ye=1,vg(e,t,n,r)}finally{bt.transition=a,ye=r}return null}function vg(e,t,n,r){do dr();while(un!==null);if(me&6)throw Error(M(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(M(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(qp(e,i),e===De&&($e=De=null,He=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Ds||(Ds=!0,Qf(ma,function(){return dr(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=bt.transition,bt.transition=null;var o=ye;ye=1;var l=me;me|=4,Tl.current=null,fg(e,n),Bf(n,e),Fh(fo),ha=!!uo,fo=uo=null,e.current=n,mg(n),Wp(),me=l,ye=o,bt.transition=i}else e.current=n;if(Ds&&(Ds=!1,un=e,Pa=a),i=e.pendingLanes,i===0&&(gn=null),Gp(n.stateNode),ut(e,ze()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],r(a.value,{componentStack:a.stack,digest:a.digest});if(Ra)throw Ra=!1,e=Ao,Ao=null,e;return Pa&1&&e.tag!==0&&dr(),i=e.pendingLanes,i&1?e===_o?Xr++:(Xr=0,_o=e):Xr=0,kn(),null}function dr(){if(un!==null){var e=Nd(Pa),t=bt.transition,n=ye;try{if(bt.transition=null,ye=16>e?16:e,un===null)var r=!1;else{if(e=un,un=null,Pa=0,me&6)throw Error(M(331));var a=me;for(me|=4,J=e.current;J!==null;){var i=J,o=i.child;if(J.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(J=d;J!==null;){var f=J;switch(f.tag){case 0:case 11:case 15:Qr(8,f,i)}var m=f.child;if(m!==null)m.return=f,J=m;else for(;J!==null;){f=J;var p=f.sibling,x=f.return;if(Mf(f),f===d){J=null;break}if(p!==null){p.return=x,J=p;break}J=x}}}var w=i.alternate;if(w!==null){var v=w.child;if(v!==null){w.child=null;do{var S=v.sibling;v.sibling=null,v=S}while(v!==null)}}J=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,J=o;else e:for(;J!==null;){if(i=J,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Qr(9,i,i.return)}var g=i.sibling;if(g!==null){g.return=i.return,J=g;break e}J=i.return}}var h=e.current;for(J=h;J!==null;){o=J;var y=o.child;if(o.subtreeFlags&2064&&y!==null)y.return=o,J=y;else e:for(o=h;J!==null;){if(l=J,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Ya(9,l)}}catch(b){Ae(l,l.return,b)}if(l===o){J=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,J=j;break e}J=l.return}}if(me=a,kn(),Bt&&typeof Bt.onPostCommitFiberRoot=="function")try{Bt.onPostCommitFiberRoot(Ba,e)}catch{}r=!0}return r}finally{ye=n,bt.transition=t}}return!1}function au(e,t,n){t=yr(n,t),t=Cf(e,t,1),e=hn(e,t,1),t=nt(),e!==null&&(vs(e,1,t),ut(e,t))}function Ae(e,t,n){if(e.tag===3)au(e,e,n);else for(;t!==null;){if(t.tag===3){au(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(gn===null||!gn.has(r))){e=yr(n,e),e=Ef(t,e,1),t=hn(t,e,1),e=nt(),t!==null&&(vs(t,1,e),ut(t,e));break}}t=t.return}}function xg(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=nt(),e.pingedLanes|=e.suspendedLanes&n,De===e&&(He&n)===n&&(Fe===4||Fe===3&&(He&130023424)===He&&500>ze()-Rl?$n(e,0):Il|=n),ut(e,t)}function Kf(e,t){t===0&&(e.mode&1?(t=Ps,Ps<<=1,!(Ps&130023424)&&(Ps=4194304)):t=1);var n=nt();e=Xt(e,t),e!==null&&(vs(e,t,n),ut(e,n))}function wg(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Kf(e,n)}function jg(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(M(314))}r!==null&&r.delete(t),Kf(e,n)}var Yf;Yf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||lt.current)ot=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ot=!1,lg(e,t,n);ot=!!(e.flags&131072)}else ot=!1,be&&t.flags&1048576&&Xd(t,Sa,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;na(e,t),e=t.pendingProps;var a=mr(t,qe.current);ur(t,n),a=kl(null,t,r,e,a,n);var i=bl();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ct(r)?(i=!0,wa(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,vl(t),a.updater=Ka,t.stateNode=a,a._reactInternals=t,jo(t,r,e,n),t=bo(null,t,r,!0,i,n)):(t.tag=0,be&&i&&dl(t),et(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(na(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=kg(r),e=It(r,e),a){case 0:t=ko(null,t,r,e,n);break e;case 1:t=Qc(null,t,r,e,n);break e;case 11:t=Kc(null,t,r,e,n);break e;case 14:t=Yc(null,t,r,It(r.type,e),n);break e}throw Error(M(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:It(r,a),ko(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:It(r,a),Qc(e,t,r,a,n);case 3:e:{if(Pf(t),e===null)throw Error(M(387));r=t.pendingProps,i=t.memoizedState,a=i.element,rf(e,t),Na(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){a=yr(Error(M(423)),t),t=Jc(e,t,r,n,a);break e}else if(r!==a){a=yr(Error(M(424)),t),t=Jc(e,t,r,n,a);break e}else for(ft=pn(t.stateNode.containerInfo.firstChild),mt=t,be=!0,Pt=null,n=tf(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(pr(),r===a){t=qt(e,t,n);break e}et(e,t,r,n)}t=t.child}return t;case 5:return sf(t),e===null&&vo(t),r=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,o=a.children,mo(r,a)?o=null:i!==null&&mo(r,i)&&(t.flags|=32),Rf(e,t),et(e,t,o,n),t.child;case 6:return e===null&&vo(t),null;case 13:return Af(e,t,n);case 4:return xl(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=hr(t,null,r,n):et(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:It(r,a),Kc(e,t,r,a,n);case 7:return et(e,t,t.pendingProps,n),t.child;case 8:return et(e,t,t.pendingProps.children,n),t.child;case 12:return et(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,i=t.memoizedProps,o=a.value,ve(ka,r._currentValue),r._currentValue=o,i!==null)if($t(i.value,o)){if(i.children===a.children&&!lt.current){t=qt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){o=i.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Yt(-1,n&-n),c.tag=2;var d=i.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}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),xo(i.return,n,t),l.lanes|=n;break}c=c.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(M(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),xo(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}et(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,ur(t,n),a=Nt(a),r=r(a),t.flags|=1,et(e,t,r,n),t.child;case 14:return r=t.type,a=It(r,t.pendingProps),a=It(r.type,a),Yc(e,t,r,a,n);case 15:return Tf(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:It(r,a),na(e,t),t.tag=1,ct(r)?(e=!0,wa(t)):e=!1,ur(t,n),Nf(t,r,a),jo(t,r,a,n),bo(null,t,r,!0,e,n);case 19:return _f(e,t,n);case 22:return If(e,t,n)}throw Error(M(156,t.tag))};function Qf(e,t){return jd(e,t)}function Sg(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 kt(e,t,n,r){return new Sg(e,t,n,r)}function zl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function kg(e){if(typeof e=="function")return zl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Zo)return 11;if(e===el)return 14}return 2}function vn(e,t){var n=e.alternate;return n===null?(n=kt(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 aa(e,t,n,r,a,i){var o=2;if(r=e,typeof e=="function")zl(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Qn:return Ln(n.children,a,i,t);case qo:o=8,a|=8;break;case Hi:return e=kt(12,n,t,a|2),e.elementType=Hi,e.lanes=i,e;case Vi:return e=kt(13,n,t,a),e.elementType=Vi,e.lanes=i,e;case Gi:return e=kt(19,n,t,a),e.elementType=Gi,e.lanes=i,e;case sd:return Ja(n,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case nd:o=10;break e;case rd:o=9;break e;case Zo:o=11;break e;case el:o=14;break e;case sn:o=16,r=null;break e}throw Error(M(130,e==null?e:typeof e,""))}return t=kt(o,n,t,a),t.elementType=e,t.type=r,t.lanes=i,t}function Ln(e,t,n,r){return e=kt(7,e,r,t),e.lanes=n,e}function Ja(e,t,n,r){return e=kt(22,e,r,t),e.elementType=sd,e.lanes=n,e.stateNode={isHidden:!1},e}function Ai(e,t,n){return e=kt(6,e,null,t),e.lanes=n,e}function _i(e,t,n){return t=kt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function bg(e,t,n,r,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=mi(0),this.expirationTimes=mi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=mi(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function $l(e,t,n,r,a,i,o,l,c){return e=new bg(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=kt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},vl(i),e}function Ng(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Yn,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function Jf(e){if(!e)return wn;e=e._reactInternals;e:{if(Wn(e)!==e||e.tag!==1)throw Error(M(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ct(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(M(171))}if(e.tag===1){var n=e.type;if(ct(n))return Qd(e,n,t)}return t}function Xf(e,t,n,r,a,i,o,l,c){return e=$l(n,r,!0,e,a,i,o,l,c),e.context=Jf(null),n=e.current,r=nt(),a=yn(n),i=Yt(r,a),i.callback=t??null,hn(n,i,a),e.current.lanes=a,vs(e,a,r),ut(e,r),e}function Xa(e,t,n,r){var a=t.current,i=nt(),o=yn(a);return n=Jf(n),t.context===null?t.context=n:t.pendingContext=n,t=Yt(i,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=hn(a,t,o),e!==null&&(zt(e,a,o,i),Zs(e,a,o)),o}function _a(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 iu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Ll(e,t){iu(e,t),(e=e.alternate)&&iu(e,t)}function Cg(){return null}var qf=typeof reportError=="function"?reportError:function(e){console.error(e)};function Ml(e){this._internalRoot=e}qa.prototype.render=Ml.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(M(409));Xa(e,t,null,null)};qa.prototype.unmount=Ml.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Dn(function(){Xa(null,e,null,null)}),t[Jt]=null}};function qa(e){this._internalRoot=e}qa.prototype.unstable_scheduleHydration=function(e){if(e){var t=Td();e={blockedOn:null,target:e,priority:t};for(var n=0;n<on.length&&t!==0&&t<on[n].priority;n++);on.splice(n,0,e),n===0&&Rd(e)}};function Fl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Za(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function ou(){}function Eg(e,t,n,r,a){if(a){if(typeof r=="function"){var i=r;r=function(){var d=_a(o);i.call(d)}}var o=Xf(t,r,e,0,null,!1,!1,"",ou);return e._reactRootContainer=o,e[Jt]=o.current,os(e.nodeType===8?e.parentNode:e),Dn(),o}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var l=r;r=function(){var d=_a(c);l.call(d)}}var c=$l(e,0,!1,null,null,!1,!1,"",ou);return e._reactRootContainer=c,e[Jt]=c.current,os(e.nodeType===8?e.parentNode:e),Dn(function(){Xa(t,c,n,r)}),c}function ei(e,t,n,r,a){var i=n._reactRootContainer;if(i){var o=i;if(typeof a=="function"){var l=a;a=function(){var c=_a(o);l.call(c)}}Xa(t,o,e,a)}else o=Eg(n,t,e,a,r);return _a(o)}Cd=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Br(t.pendingLanes);n!==0&&(rl(t,n|1),ut(t,ze()),!(me&6)&&(vr=ze()+500,kn()))}break;case 13:Dn(function(){var r=Xt(e,1);if(r!==null){var a=nt();zt(r,e,1,a)}}),Ll(e,1)}};sl=function(e){if(e.tag===13){var t=Xt(e,134217728);if(t!==null){var n=nt();zt(t,e,134217728,n)}Ll(e,134217728)}};Ed=function(e){if(e.tag===13){var t=yn(e),n=Xt(e,t);if(n!==null){var r=nt();zt(n,e,t,r)}Ll(e,t)}};Td=function(){return ye};Id=function(e,t){var n=ye;try{return ye=e,t()}finally{ye=n}};no=function(e,t,n){switch(t){case"input":if(Qi(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=Ha(r);if(!a)throw Error(M(90));id(r),Qi(r,a)}}}break;case"textarea":ld(e,n);break;case"select":t=n.value,t!=null&&ir(e,!!n.multiple,t,!1)}};hd=Pl;gd=Dn;var Tg={usingClientEntryPoint:!1,Events:[ws,Zn,Ha,md,pd,Pl]},_r={findFiberByHostInstance:Rn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Ig={bundleType:_r.bundleType,version:_r.version,rendererPackageName:_r.rendererPackageName,rendererConfig:_r.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:en.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=xd(e),e===null?null:e.stateNode},findFiberByHostInstance:_r.findFiberByHostInstance||Cg,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 Us=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Us.isDisabled&&Us.supportsFiber)try{Ba=Us.inject(Ig),Bt=Us}catch{}}ht.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Tg;ht.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Fl(t))throw Error(M(200));return Ng(e,t,null,n)};ht.createRoot=function(e,t){if(!Fl(e))throw Error(M(299));var n=!1,r="",a=qf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=$l(e,1,!1,null,null,n,!1,r,a),e[Jt]=t.current,os(e.nodeType===8?e.parentNode:e),new Ml(t)};ht.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(M(188)):(e=Object.keys(e).join(","),Error(M(268,e)));return e=xd(t),e=e===null?null:e.stateNode,e};ht.flushSync=function(e){return Dn(e)};ht.hydrate=function(e,t,n){if(!Za(t))throw Error(M(200));return ei(null,e,t,!0,n)};ht.hydrateRoot=function(e,t,n){if(!Fl(e))throw Error(M(405));var r=n!=null&&n.hydratedSources||null,a=!1,i="",o=qf;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=Xf(t,null,e,1,n??null,a,!1,i,o),e[Jt]=t.current,os(e),r)for(e=0;e<r.length;e++)n=r[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new qa(t)};ht.render=function(e,t,n){if(!Za(t))throw Error(M(200));return ei(null,e,t,!1,n)};ht.unmountComponentAtNode=function(e){if(!Za(e))throw Error(M(40));return e._reactRootContainer?(Dn(function(){ei(null,null,e,!1,function(){e._reactRootContainer=null,e[Jt]=null})}),!0):!1};ht.unstable_batchedUpdates=Pl;ht.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Za(n))throw Error(M(200));if(e==null||e._reactInternals===void 0)throw Error(M(38));return ei(e,t,n,!1,r)};ht.version="18.3.1-next-f1338f8080-20240426";function Zf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Zf)}catch(e){console.error(e)}}Zf(),qu.exports=ht;var em=qu.exports,tm,lu=em;tm=lu.createRoot,lu.hydrateRoot;/**
|
|
41
|
-
* react-router v7.
|
|
40
|
+
`+i.stack}return{value:e,source:t,stack:a,digest:null}}function Ai(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function No(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var gg=typeof WeakMap=="function"?WeakMap:Map;function Lf(e,t,n){n=Yt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Pa||(Pa=!0,zo=r),No(e,t)},n}function zf(e,t,n){n=Yt(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var a=t.value;n.payload=function(){return r(a)},n.callback=function(){No(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){No(e,t),typeof r!="function"&&(gn===null?gn=new Set([this]):gn.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function Xc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new gg;var a=new Set;r.set(t,a)}else a=r.get(t),a===void 0&&(a=new Set,r.set(t,a));a.has(n)||(a.add(n),e=Rg.bind(null,e,t,n),t.then(e,e))}function qc(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 Zc(e,t,n,r,a){return e.mode&1?(e.flags|=65536,e.lanes=a,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Yt(-1,1),t.tag=2,pn(n,t,1))),n.lanes|=1),e)}var yg=en.ReactCurrentOwner,ot=!1;function et(e,t,n,r){t.child=e===null?uf(t,null,n,r):gr(t,e.child,n,r)}function eu(e,t,n,r,a){n=n.render;var i=t.ref;return dr(t,a),r=Cl(e,t,n,r,i,a),n=El(),e!==null&&!ot?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,qt(e,t,a)):(be&&n&&hl(t),t.flags|=1,et(e,t,r,a),t.child)}function tu(e,t,n,r,a){if(e===null){var i=n.type;return typeof i=="function"&&!Ml(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,$f(e,t,i,r,a)):(e=ia(n.type,null,r,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&a)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:ls,n(o,r)&&e.ref===t.ref)return qt(e,t,a)}return t.flags|=1,e=vn(i,r),e.ref=t.ref,e.return=t,t.child=e}function $f(e,t,n,r,a){if(e!==null){var i=e.memoizedProps;if(ls(i,r)&&e.ref===t.ref)if(ot=!1,t.pendingProps=r=i,(e.lanes&a)!==0)e.flags&131072&&(ot=!0);else return t.lanes=e.lanes,qt(e,t,a)}return Co(e,t,n,r,a)}function Mf(e,t,n){var r=t.pendingProps,a=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ve(ir,ft),ft|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,ve(ir,ft),ft|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,ve(ir,ft),ft|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,ve(ir,ft),ft|=r;return et(e,t,a,n),t.child}function Ff(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Co(e,t,n,r,a){var i=ct(n)?Mn:qe.current;return i=hr(t,i),dr(t,a),n=Cl(e,t,n,r,i,a),r=El(),e!==null&&!ot?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,qt(e,t,a)):(be&&r&&hl(t),t.flags|=1,et(e,t,n,a),t.child)}function nu(e,t,n,r,a){if(ct(n)){var i=!0;ja(t)}else i=!1;if(dr(t,a),t.stateNode===null)ra(e,t),_f(t,n,r),bo(t,n,r,a),r=!0;else if(e===null){var o=t.stateNode,l=t.memoizedProps;o.props=l;var c=o.context,d=n.contextType;typeof d=="object"&&d!==null?d=Nt(d):(d=ct(n)?Mn:qe.current,d=hr(t,d));var f=n.getDerivedStateFromProps,h=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==r||c!==d)&&Jc(t,o,r,d),an=!1;var m=t.memoizedState;o.state=m,Ca(t,r,o,a),c=t.memoizedState,l!==r||m!==c||lt.current||an?(typeof f=="function"&&(ko(t,n,f,r),c=t.memoizedState),(l=an||Qc(t,n,l,r,m,c,d))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=d,r=l):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,ff(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:It(t.type,l),o.props=d,h=t.pendingProps,m=o.context,c=n.contextType,typeof c=="object"&&c!==null?c=Nt(c):(c=ct(n)?Mn:qe.current,c=hr(t,c));var x=n.getDerivedStateFromProps;(f=typeof x=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==h||m!==c)&&Jc(t,o,r,c),an=!1,m=t.memoizedState,o.state=m,Ca(t,r,o,a);var w=t.memoizedState;l!==h||m!==w||lt.current||an?(typeof x=="function"&&(ko(t,n,x,r),w=t.memoizedState),(d=an||Qc(t,n,d,r,m,w,c)||!1)?(f||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,w,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,w,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=w),o.props=r,o.state=w,o.context=c,r=d):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return Eo(e,t,n,r,i,a)}function Eo(e,t,n,r,a,i){Ff(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return a&&Dc(t,n,!1),qt(e,t,i);r=t.stateNode,yg.current=t;var l=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=gr(t,e.child,null,i),t.child=gr(t,null,l,i)):et(e,t,l,i),t.memoizedState=r.state,a&&Dc(t,n,!0),t.child}function Of(e){var t=e.stateNode;t.pendingContext?Bc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Bc(e,t.context,!1),Sl(e,t.containerInfo)}function ru(e,t,n,r,a){return pr(),gl(a),t.flags|=256,et(e,t,n,r),t.child}var To={dehydrated:null,treeContext:null,retryLane:0};function Io(e){return{baseLanes:e,cachePool:null,transitions:null}}function Bf(e,t,n){var r=t.pendingProps,a=Te.current,i=!1,o=(t.flags&128)!==0,l;if((l=o)||(l=e!==null&&e.memoizedState===null?!1:(a&2)!==0),l?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),ve(Te,a&1),e===null)return jo(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):(o=r.children,e=r.fallback,i?(r=t.mode,i=t.child,o={mode:"hidden",children:o},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Xa(o,r,0,null),e=$n(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Io(n),t.memoizedState=To,e):Rl(t,o));if(a=e.memoizedState,a!==null&&(l=a.dehydrated,l!==null))return vg(e,t,o,r,l,a,n);if(i){i=r.fallback,o=t.mode,a=e.child,l=a.sibling;var c={mode:"hidden",children:r.children};return!(o&1)&&t.child!==a?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=vn(a,c),r.subtreeFlags=a.subtreeFlags&14680064),l!==null?i=vn(l,i):(i=$n(i,o,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,o=e.child.memoizedState,o=o===null?Io(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=To,r}return i=e.child,e=i.sibling,r=vn(i,{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 Rl(e,t){return t=Xa({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Bs(e,t,n,r){return r!==null&&gl(r),gr(t,e.child,null,n),e=Rl(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function vg(e,t,n,r,a,i,o){if(n)return t.flags&256?(t.flags&=-257,r=Ai(Error(M(422))),Bs(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,a=t.mode,r=Xa({mode:"visible",children:r.children},a,0,null),i=$n(i,a,o,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&gr(t,e.child,null,o),t.child.memoizedState=Io(o),t.memoizedState=To,i);if(!(t.mode&1))return Bs(e,t,o,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(M(419)),r=Ai(i,r,void 0),Bs(e,t,o,r)}if(l=(o&e.childLanes)!==0,ot||l){if(r=De,r!==null){switch(o&-o){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=a&(r.suspendedLanes|o)?0:a,a!==0&&a!==i.retryLane&&(i.retryLane=a,Xt(e,a),Lt(r,e,a,-1))}return $l(),r=Ai(Error(M(421))),Bs(e,t,o,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=Pg.bind(null,e),a._reactRetry=t,null):(e=i.treeContext,mt=hn(a.nextSibling),ht=t,be=!0,Pt=null,e!==null&&(jt[St++]=Gt,jt[St++]=Kt,jt[St++]=Fn,Gt=e.id,Kt=e.overflow,Fn=t),t=Rl(t,r.children),t.flags|=4096,t)}function su(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),So(e.return,t,n)}function _i(e,t,n,r,a){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=a)}function Df(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;if(et(e,t,r.children,n),r=Te.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&&su(e,n,t);else if(e.tag===19)su(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(ve(Te,r),!(t.mode&1))t.memoizedState=null;else switch(a){case"forwards":for(n=t.child,a=null;n!==null;)e=n.alternate,e!==null&&Ea(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),_i(t,!1,a,n,i);break;case"backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&Ea(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}_i(t,!0,n,null,i);break;case"together":_i(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function ra(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function qt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Bn|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(M(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 xg(e,t,n){switch(t.tag){case 3:Of(t),pr();break;case 5:mf(t);break;case 1:ct(t.type)&&ja(t);break;case 4:Sl(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;ve(ba,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(ve(Te,Te.current&1),t.flags|=128,null):n&t.child.childLanes?Bf(e,t,n):(ve(Te,Te.current&1),e=qt(e,t,n),e!==null?e.sibling:null);ve(Te,Te.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Df(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),ve(Te,Te.current),r)break;return null;case 22:case 23:return t.lanes=0,Mf(e,t,n)}return qt(e,t,n)}var Uf,Ro,Wf,Hf;Uf=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}};Ro=function(){};Wf=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,An(Ut.current);var i=null;switch(n){case"input":a=Xi(e,a),r=Xi(e,r),i=[];break;case"select":a=Re({},a,{value:void 0}),r=Re({},r,{value:void 0}),i=[];break;case"textarea":a=eo(e,a),r=eo(e,r),i=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=xa)}no(n,r);var o;n=null;for(d in a)if(!r.hasOwnProperty(d)&&a.hasOwnProperty(d)&&a[d]!=null)if(d==="style"){var l=a[d];for(o in l)l.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(ts.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in r){var c=r[d];if(l=a!=null?a[d]:void 0,r.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="style")if(l){for(o in l)!l.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in c)c.hasOwnProperty(o)&&l[o]!==c[o]&&(n||(n={}),n[o]=c[o])}else n||(i||(i=[]),i.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(ts.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&we("scroll",e),i||l===c||(i=[])):(i=i||[]).push(d,c))}n&&(i=i||[]).push("style",n);var d=i;(t.updateQueue=d)&&(t.flags|=4)}};Hf=function(e,t,n,r){n!==r&&(t.flags|=4)};function Lr(e,t){if(!be)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 Je(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags&14680064,r|=a.flags&14680064,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function wg(e,t,n){var r=t.pendingProps;switch(pl(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Je(t),null;case 1:return ct(t.type)&&wa(),Je(t),null;case 3:return r=t.stateNode,yr(),Se(lt),Se(qe),bl(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Fs(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Pt!==null&&(Fo(Pt),Pt=null))),Ro(e,t),Je(t),null;case 5:kl(t);var a=An(ms.current);if(n=t.type,e!==null&&t.stateNode!=null)Wf(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(M(166));return Je(t),null}if(e=An(Ut.current),Fs(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Bt]=t,r[ds]=i,e=(t.mode&1)!==0,n){case"dialog":we("cancel",r),we("close",r);break;case"iframe":case"object":case"embed":we("load",r);break;case"video":case"audio":for(a=0;a<Wr.length;a++)we(Wr[a],r);break;case"source":we("error",r);break;case"img":case"image":case"link":we("error",r),we("load",r);break;case"details":we("toggle",r);break;case"input":mc(r,i),we("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},we("invalid",r);break;case"textarea":pc(r,i),we("invalid",r)}no(n,i),a=null;for(var o in i)if(i.hasOwnProperty(o)){var l=i[o];o==="children"?typeof l=="string"?r.textContent!==l&&(i.suppressHydrationWarning!==!0&&Ms(r.textContent,l,e),a=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&Ms(r.textContent,l,e),a=["children",""+l]):ts.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&we("scroll",r)}switch(n){case"input":Is(r),hc(r,i,!0);break;case"textarea":Is(r),gc(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=xa)}r=a,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=yd(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Bt]=t,e[ds]=r,Uf(e,t,!1,!1),t.stateNode=e;e:{switch(o=ro(n,r),n){case"dialog":we("cancel",e),we("close",e),a=r;break;case"iframe":case"object":case"embed":we("load",e),a=r;break;case"video":case"audio":for(a=0;a<Wr.length;a++)we(Wr[a],e);a=r;break;case"source":we("error",e),a=r;break;case"img":case"image":case"link":we("error",e),we("load",e),a=r;break;case"details":we("toggle",e),a=r;break;case"input":mc(e,r),a=Xi(e,r),we("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=Re({},r,{value:void 0}),we("invalid",e);break;case"textarea":pc(e,r),a=eo(e,r),we("invalid",e);break;default:a=r}no(n,a),l=a;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?wd(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&vd(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&ns(e,c):typeof c=="number"&&ns(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(ts.hasOwnProperty(i)?c!=null&&i==="onScroll"&&we("scroll",e):c!=null&&el(e,i,c,o))}switch(n){case"input":Is(e),hc(e,r,!1);break;case"textarea":Is(e),gc(e);break;case"option":r.value!=null&&e.setAttribute("value",""+xn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?or(e,!!r.multiple,i,!1):r.defaultValue!=null&&or(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=xa)}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 Je(t),null;case 6:if(e&&t.stateNode!=null)Hf(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(M(166));if(n=An(ms.current),An(Ut.current),Fs(t)){if(r=t.stateNode,n=t.memoizedProps,r[Bt]=t,(i=r.nodeValue!==n)&&(e=ht,e!==null))switch(e.tag){case 3:Ms(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ms(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Bt]=t,t.stateNode=r}return Je(t),null;case 13:if(Se(Te),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(be&&mt!==null&&t.mode&1&&!(t.flags&128))lf(),pr(),t.flags|=98560,i=!1;else if(i=Fs(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(M(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(M(317));i[Bt]=t}else pr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Je(t),i=!1}else Pt!==null&&(Fo(Pt),Pt=null),i=!0;if(!i)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||Te.current&1?Fe===0&&(Fe=3):$l())),t.updateQueue!==null&&(t.flags|=4),Je(t),null);case 4:return yr(),Ro(e,t),e===null&&cs(t.stateNode.containerInfo),Je(t),null;case 10:return xl(t.type._context),Je(t),null;case 17:return ct(t.type)&&wa(),Je(t),null;case 19:if(Se(Te),i=t.memoizedState,i===null)return Je(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)Lr(i,!1);else{if(Fe!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Ea(e),o!==null){for(t.flags|=128,Lr(i,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return ve(Te,Te.current&1|2),t.child}e=e.sibling}i.tail!==null&&Le()>xr&&(t.flags|=128,r=!0,Lr(i,!1),t.lanes=4194304)}else{if(!r)if(e=Ea(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Lr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!be)return Je(t),null}else 2*Le()-i.renderingStartTime>xr&&n!==1073741824&&(t.flags|=128,r=!0,Lr(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Le(),t.sibling=null,n=Te.current,ve(Te,r?n&1|2:n&1),t):(Je(t),null);case 22:case 23:return zl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ft&1073741824&&(Je(t),t.subtreeFlags&6&&(t.flags|=8192)):Je(t),null;case 24:return null;case 25:return null}throw Error(M(156,t.tag))}function jg(e,t){switch(pl(t),t.tag){case 1:return ct(t.type)&&wa(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return yr(),Se(lt),Se(qe),bl(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return kl(t),null;case 13:if(Se(Te),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(M(340));pr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Se(Te),null;case 4:return yr(),null;case 10:return xl(t.type._context),null;case 22:case 23:return zl(),null;case 24:return null;default:return null}}var Ds=!1,Xe=!1,Sg=typeof WeakSet=="function"?WeakSet:Set,J=null;function ar(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ae(e,t,r)}else n.current=null}function Po(e,t,n){try{n()}catch(r){Ae(e,t,r)}}var au=!1;function kg(e,t){if(ho=ga,e=Yd(),ml(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,l=-1,c=-1,d=0,f=0,h=e,m=null;t:for(;;){for(var x;h!==n||a!==0&&h.nodeType!==3||(l=o+a),h!==i||r!==0&&h.nodeType!==3||(c=o+r),h.nodeType===3&&(o+=h.nodeValue.length),(x=h.firstChild)!==null;)m=h,h=x;for(;;){if(h===e)break t;if(m===n&&++d===a&&(l=o),m===i&&++f===r&&(c=o),(x=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=x}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(po={focusedElem:e,selectionRange:n},ga=!1,J=t;J!==null;)if(t=J,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,J=e;else for(;J!==null;){t=J;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 v=w.memoizedProps,S=w.memoizedState,g=t.stateNode,p=g.getSnapshotBeforeUpdate(t.elementType===t.type?v:It(t.type,v),S);g.__reactInternalSnapshotBeforeUpdate=p}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(M(163))}}catch(j){Ae(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,J=e;break}J=t.return}return w=au,au=!1,w}function Xr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&e)===e){var i=a.destroy;a.destroy=void 0,i!==void 0&&Po(t,n,i)}a=a.next}while(a!==r)}}function Qa(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 Ao(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 Vf(e){var t=e.alternate;t!==null&&(e.alternate=null,Vf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Bt],delete t[ds],delete t[vo],delete t[ag],delete t[ig])),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 Gf(e){return e.tag===5||e.tag===3||e.tag===4}function iu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Gf(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 _o(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=xa));else if(r!==4&&(e=e.child,e!==null))for(_o(e,t,n),e=e.sibling;e!==null;)_o(e,t,n),e=e.sibling}function Lo(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(Lo(e,t,n),e=e.sibling;e!==null;)Lo(e,t,n),e=e.sibling}var We=null,Rt=!1;function rn(e,t,n){for(n=n.child;n!==null;)Kf(e,t,n),n=n.sibling}function Kf(e,t,n){if(Dt&&typeof Dt.onCommitFiberUnmount=="function")try{Dt.onCommitFiberUnmount(Da,n)}catch{}switch(n.tag){case 5:Xe||ar(n,t);case 6:var r=We,a=Rt;We=null,rn(e,t,n),We=r,Rt=a,We!==null&&(Rt?(e=We,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):We.removeChild(n.stateNode));break;case 18:We!==null&&(Rt?(e=We,n=n.stateNode,e.nodeType===8?Ci(e.parentNode,n):e.nodeType===1&&Ci(e,n),is(e)):Ci(We,n.stateNode));break;case 4:r=We,a=Rt,We=n.stateNode.containerInfo,Rt=!0,rn(e,t,n),We=r,Rt=a;break;case 0:case 11:case 14:case 15:if(!Xe&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){a=r=r.next;do{var i=a,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Po(n,t,o),a=a.next}while(a!==r)}rn(e,t,n);break;case 1:if(!Xe&&(ar(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Ae(n,t,l)}rn(e,t,n);break;case 21:rn(e,t,n);break;case 22:n.mode&1?(Xe=(r=Xe)||n.memoizedState!==null,rn(e,t,n),Xe=r):rn(e,t,n);break;default:rn(e,t,n)}}function ou(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Sg),t.forEach(function(r){var a=Ag.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function Tt(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r];try{var i=e,o=t,l=o;e:for(;l!==null;){switch(l.tag){case 5:We=l.stateNode,Rt=!1;break e;case 3:We=l.stateNode.containerInfo,Rt=!0;break e;case 4:We=l.stateNode.containerInfo,Rt=!0;break e}l=l.return}if(We===null)throw Error(M(160));Kf(i,o,a),We=null,Rt=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(d){Ae(a,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Yf(t,e),t=t.sibling}function Yf(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Tt(t,e),Ft(e),r&4){try{Xr(3,e,e.return),Qa(3,e)}catch(v){Ae(e,e.return,v)}try{Xr(5,e,e.return)}catch(v){Ae(e,e.return,v)}}break;case 1:Tt(t,e),Ft(e),r&512&&n!==null&&ar(n,n.return);break;case 5:if(Tt(t,e),Ft(e),r&512&&n!==null&&ar(n,n.return),e.flags&32){var a=e.stateNode;try{ns(a,"")}catch(v){Ae(e,e.return,v)}}if(r&4&&(a=e.stateNode,a!=null)){var i=e.memoizedProps,o=n!==null?n.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&pd(a,i),ro(l,o);var d=ro(l,i);for(o=0;o<c.length;o+=2){var f=c[o],h=c[o+1];f==="style"?wd(a,h):f==="dangerouslySetInnerHTML"?vd(a,h):f==="children"?ns(a,h):el(a,f,h,d)}switch(l){case"input":qi(a,i);break;case"textarea":gd(a,i);break;case"select":var m=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!i.multiple;var x=i.value;x!=null?or(a,!!i.multiple,x,!1):m!==!!i.multiple&&(i.defaultValue!=null?or(a,!!i.multiple,i.defaultValue,!0):or(a,!!i.multiple,i.multiple?[]:"",!1))}a[ds]=i}catch(v){Ae(e,e.return,v)}}break;case 6:if(Tt(t,e),Ft(e),r&4){if(e.stateNode===null)throw Error(M(162));a=e.stateNode,i=e.memoizedProps;try{a.nodeValue=i}catch(v){Ae(e,e.return,v)}}break;case 3:if(Tt(t,e),Ft(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{is(t.containerInfo)}catch(v){Ae(e,e.return,v)}break;case 4:Tt(t,e),Ft(e);break;case 13:Tt(t,e),Ft(e),a=e.child,a.flags&8192&&(i=a.memoizedState!==null,a.stateNode.isHidden=i,!i||a.alternate!==null&&a.alternate.memoizedState!==null||(_l=Le())),r&4&&ou(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Xe=(d=Xe)||f,Tt(t,e),Xe=d):Tt(t,e),Ft(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(J=e,f=e.child;f!==null;){for(h=J=f;J!==null;){switch(m=J,x=m.child,m.tag){case 0:case 11:case 14:case 15:Xr(4,m,m.return);break;case 1:ar(m,m.return);var w=m.stateNode;if(typeof w.componentWillUnmount=="function"){r=m,n=m.return;try{t=r,w.props=t.memoizedProps,w.state=t.memoizedState,w.componentWillUnmount()}catch(v){Ae(r,n,v)}}break;case 5:ar(m,m.return);break;case 22:if(m.memoizedState!==null){cu(h);continue}}x!==null?(x.return=m,J=x):cu(h)}f=f.sibling}e:for(f=null,h=e;;){if(h.tag===5){if(f===null){f=h;try{a=h.stateNode,d?(i=a.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=h.stateNode,c=h.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=xd("display",o))}catch(v){Ae(e,e.return,v)}}}else if(h.tag===6){if(f===null)try{h.stateNode.nodeValue=d?"":h.memoizedProps}catch(v){Ae(e,e.return,v)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===e)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;h.sibling===null;){if(h.return===null||h.return===e)break e;f===h&&(f=null),h=h.return}f===h&&(f=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:Tt(t,e),Ft(e),r&4&&ou(e);break;case 21:break;default:Tt(t,e),Ft(e)}}function Ft(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Gf(n)){var r=n;break e}n=n.return}throw Error(M(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(ns(a,""),r.flags&=-33);var i=iu(e);Lo(e,i,a);break;case 3:case 4:var o=r.stateNode.containerInfo,l=iu(e);_o(e,l,o);break;default:throw Error(M(161))}}catch(c){Ae(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function bg(e,t,n){J=e,Qf(e)}function Qf(e,t,n){for(var r=(e.mode&1)!==0;J!==null;){var a=J,i=a.child;if(a.tag===22&&r){var o=a.memoizedState!==null||Ds;if(!o){var l=a.alternate,c=l!==null&&l.memoizedState!==null||Xe;l=Ds;var d=Xe;if(Ds=o,(Xe=c)&&!d)for(J=a;J!==null;)o=J,c=o.child,o.tag===22&&o.memoizedState!==null?uu(a):c!==null?(c.return=o,J=c):uu(a);for(;i!==null;)J=i,Qf(i),i=i.sibling;J=a,Ds=l,Xe=d}lu(e)}else a.subtreeFlags&8772&&i!==null?(i.return=a,J=i):lu(e)}}function lu(e){for(;J!==null;){var t=J;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Xe||Qa(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Xe)if(n===null)r.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:It(t.type,n.memoizedProps);r.componentDidUpdate(a,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Gc(t,i,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Gc(t,o,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var f=d.memoizedState;if(f!==null){var h=f.dehydrated;h!==null&&is(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(M(163))}Xe||t.flags&512&&Ao(t)}catch(m){Ae(t,t.return,m)}}if(t===e){J=null;break}if(n=t.sibling,n!==null){n.return=t.return,J=n;break}J=t.return}}function cu(e){for(;J!==null;){var t=J;if(t===e){J=null;break}var n=t.sibling;if(n!==null){n.return=t.return,J=n;break}J=t.return}}function uu(e){for(;J!==null;){var t=J;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Qa(4,t)}catch(c){Ae(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(c){Ae(t,a,c)}}var i=t.return;try{Ao(t)}catch(c){Ae(t,i,c)}break;case 5:var o=t.return;try{Ao(t)}catch(c){Ae(t,o,c)}}}catch(c){Ae(t,t.return,c)}if(t===e){J=null;break}var l=t.sibling;if(l!==null){l.return=t.return,J=l;break}J=t.return}}var Ng=Math.ceil,Ra=en.ReactCurrentDispatcher,Pl=en.ReactCurrentOwner,bt=en.ReactCurrentBatchConfig,me=0,De=null,ze=null,He=0,ft=0,ir=Sn(0),Fe=0,ys=null,Bn=0,Ja=0,Al=0,qr=null,it=null,_l=0,xr=1/0,Wt=null,Pa=!1,zo=null,gn=null,Us=!1,un=null,Aa=0,Zr=0,$o=null,sa=-1,aa=0;function nt(){return me&6?Le():sa!==-1?sa:sa=Le()}function yn(e){return e.mode&1?me&2&&He!==0?He&-He:lg.transition!==null?(aa===0&&(aa=Ad()),aa):(e=ye,e!==0||(e=window.event,e=e===void 0?16:Od(e.type)),e):1}function Lt(e,t,n,r){if(50<Zr)throw Zr=0,$o=null,Error(M(185));xs(e,n,r),(!(me&2)||e!==De)&&(e===De&&(!(me&2)&&(Ja|=n),Fe===4&&ln(e,He)),ut(e,r),n===1&&me===0&&!(t.mode&1)&&(xr=Le()+500,Ga&&kn()))}function ut(e,t){var n=e.callbackNode;lp(e,t);var r=pa(e,e===De?He:0);if(r===0)n!==null&&xc(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&xc(n),t===1)e.tag===0?og(du.bind(null,e)):sf(du.bind(null,e)),rg(function(){!(me&6)&&kn()}),n=null;else{switch(_d(r)){case 1:n=al;break;case 4:n=Rd;break;case 16:n=ha;break;case 536870912:n=Pd;break;default:n=ha}n=rm(n,Jf.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Jf(e,t){if(sa=-1,aa=0,me&6)throw Error(M(327));var n=e.callbackNode;if(fr()&&e.callbackNode!==n)return null;var r=pa(e,e===De?He:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=_a(e,r);else{t=r;var a=me;me|=2;var i=qf();(De!==e||He!==t)&&(Wt=null,xr=Le()+500,zn(e,t));do try{Tg();break}catch(l){Xf(e,l)}while(!0);vl(),Ra.current=i,me=a,ze!==null?t=0:(De=null,He=0,t=Fe)}if(t!==0){if(t===2&&(a=lo(e),a!==0&&(r=a,t=Mo(e,a))),t===1)throw n=ys,zn(e,0),ln(e,r),ut(e,Le()),n;if(t===6)ln(e,r);else{if(a=e.current.alternate,!(r&30)&&!Cg(a)&&(t=_a(e,r),t===2&&(i=lo(e),i!==0&&(r=i,t=Mo(e,i))),t===1))throw n=ys,zn(e,0),ln(e,r),ut(e,Le()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(M(345));case 2:Tn(e,it,Wt);break;case 3:if(ln(e,r),(r&130023424)===r&&(t=_l+500-Le(),10<t)){if(pa(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){nt(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=yo(Tn.bind(null,e,it,Wt),t);break}Tn(e,it,Wt);break;case 4:if(ln(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var o=31-_t(r);i=1<<o,o=t[o],o>a&&(a=o),r&=~i}if(r=a,r=Le()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Ng(r/1960))-r,10<r){e.timeoutHandle=yo(Tn.bind(null,e,it,Wt),r);break}Tn(e,it,Wt);break;case 5:Tn(e,it,Wt);break;default:throw Error(M(329))}}}return ut(e,Le()),e.callbackNode===n?Jf.bind(null,e):null}function Mo(e,t){var n=qr;return e.current.memoizedState.isDehydrated&&(zn(e,t).flags|=256),e=_a(e,t),e!==2&&(t=it,it=n,t!==null&&Fo(t)),e}function Fo(e){it===null?it=e:it.push.apply(it,e)}function Cg(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var a=n[r],i=a.getSnapshot;a=a.value;try{if(!$t(i(),a))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ln(e,t){for(t&=~Al,t&=~Ja,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-_t(t),r=1<<n;e[n]=-1,t&=~r}}function du(e){if(me&6)throw Error(M(327));fr();var t=pa(e,0);if(!(t&1))return ut(e,Le()),null;var n=_a(e,t);if(e.tag!==0&&n===2){var r=lo(e);r!==0&&(t=r,n=Mo(e,r))}if(n===1)throw n=ys,zn(e,0),ln(e,t),ut(e,Le()),n;if(n===6)throw Error(M(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Tn(e,it,Wt),ut(e,Le()),null}function Ll(e,t){var n=me;me|=1;try{return e(t)}finally{me=n,me===0&&(xr=Le()+500,Ga&&kn())}}function Dn(e){un!==null&&un.tag===0&&!(me&6)&&fr();var t=me;me|=1;var n=bt.transition,r=ye;try{if(bt.transition=null,ye=1,e)return e()}finally{ye=r,bt.transition=n,me=t,!(me&6)&&kn()}}function zl(){ft=ir.current,Se(ir)}function zn(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,ng(n)),ze!==null)for(n=ze.return;n!==null;){var r=n;switch(pl(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&wa();break;case 3:yr(),Se(lt),Se(qe),bl();break;case 5:kl(r);break;case 4:yr();break;case 13:Se(Te);break;case 19:Se(Te);break;case 10:xl(r.type._context);break;case 22:case 23:zl()}n=n.return}if(De=e,ze=e=vn(e.current,null),He=ft=t,Fe=0,ys=null,Al=Ja=Bn=0,it=qr=null,Pn!==null){for(t=0;t<Pn.length;t++)if(n=Pn[t],r=n.interleaved,r!==null){n.interleaved=null;var a=r.next,i=n.pending;if(i!==null){var o=i.next;i.next=a,r.next=o}n.pending=r}Pn=null}return e}function Xf(e,t){do{var n=ze;try{if(vl(),ta.current=Ia,Ta){for(var r=Ie.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}Ta=!1}if(On=0,Be=Me=Ie=null,Jr=!1,hs=0,Pl.current=null,n===null||n.return===null){Fe=1,ys=t,ze=null;break}e:{var i=e,o=n.return,l=n,c=t;if(t=He,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,f=l,h=f.tag;if(!(f.mode&1)&&(h===0||h===11||h===15)){var m=f.alternate;m?(f.updateQueue=m.updateQueue,f.memoizedState=m.memoizedState,f.lanes=m.lanes):(f.updateQueue=null,f.memoizedState=null)}var x=qc(o);if(x!==null){x.flags&=-257,Zc(x,o,l,i,t),x.mode&1&&Xc(i,d,t),t=x,c=d;var w=t.updateQueue;if(w===null){var v=new Set;v.add(c),t.updateQueue=v}else w.add(c);break e}else{if(!(t&1)){Xc(i,d,t),$l();break e}c=Error(M(426))}}else if(be&&l.mode&1){var S=qc(o);if(S!==null){!(S.flags&65536)&&(S.flags|=256),Zc(S,o,l,i,t),gl(vr(c,l));break e}}i=c=vr(c,l),Fe!==4&&(Fe=2),qr===null?qr=[i]:qr.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var g=Lf(i,c,t);Vc(i,g);break e;case 1:l=c;var p=i.type,y=i.stateNode;if(!(i.flags&128)&&(typeof p.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(gn===null||!gn.has(y)))){i.flags|=65536,t&=-t,i.lanes|=t;var j=zf(i,l,t);Vc(i,j);break e}}i=i.return}while(i!==null)}em(n)}catch(b){t=b,ze===n&&n!==null&&(ze=n=n.return);continue}break}while(!0)}function qf(){var e=Ra.current;return Ra.current=Ia,e===null?Ia:e}function $l(){(Fe===0||Fe===3||Fe===2)&&(Fe=4),De===null||!(Bn&268435455)&&!(Ja&268435455)||ln(De,He)}function _a(e,t){var n=me;me|=2;var r=qf();(De!==e||He!==t)&&(Wt=null,zn(e,t));do try{Eg();break}catch(a){Xf(e,a)}while(!0);if(vl(),me=n,Ra.current=r,ze!==null)throw Error(M(261));return De=null,He=0,Fe}function Eg(){for(;ze!==null;)Zf(ze)}function Tg(){for(;ze!==null&&!Zh();)Zf(ze)}function Zf(e){var t=nm(e.alternate,e,ft);e.memoizedProps=e.pendingProps,t===null?em(e):ze=t,Pl.current=null}function em(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=jg(n,t),n!==null){n.flags&=32767,ze=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Fe=6,ze=null;return}}else if(n=wg(n,t,ft),n!==null){ze=n;return}if(t=t.sibling,t!==null){ze=t;return}ze=t=e}while(t!==null);Fe===0&&(Fe=5)}function Tn(e,t,n){var r=ye,a=bt.transition;try{bt.transition=null,ye=1,Ig(e,t,n,r)}finally{bt.transition=a,ye=r}return null}function Ig(e,t,n,r){do fr();while(un!==null);if(me&6)throw Error(M(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(M(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(cp(e,i),e===De&&(ze=De=null,He=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Us||(Us=!0,rm(ha,function(){return fr(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=bt.transition,bt.transition=null;var o=ye;ye=1;var l=me;me|=4,Pl.current=null,kg(e,n),Yf(n,e),Qp(po),ga=!!ho,po=ho=null,e.current=n,bg(n),ep(),me=l,ye=o,bt.transition=i}else e.current=n;if(Us&&(Us=!1,un=e,Aa=a),i=e.pendingLanes,i===0&&(gn=null),rp(n.stateNode),ut(e,Le()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],r(a.value,{componentStack:a.stack,digest:a.digest});if(Pa)throw Pa=!1,e=zo,zo=null,e;return Aa&1&&e.tag!==0&&fr(),i=e.pendingLanes,i&1?e===$o?Zr++:(Zr=0,$o=e):Zr=0,kn(),null}function fr(){if(un!==null){var e=_d(Aa),t=bt.transition,n=ye;try{if(bt.transition=null,ye=16>e?16:e,un===null)var r=!1;else{if(e=un,un=null,Aa=0,me&6)throw Error(M(331));var a=me;for(me|=4,J=e.current;J!==null;){var i=J,o=i.child;if(J.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(J=d;J!==null;){var f=J;switch(f.tag){case 0:case 11:case 15:Xr(8,f,i)}var h=f.child;if(h!==null)h.return=f,J=h;else for(;J!==null;){f=J;var m=f.sibling,x=f.return;if(Vf(f),f===d){J=null;break}if(m!==null){m.return=x,J=m;break}J=x}}}var w=i.alternate;if(w!==null){var v=w.child;if(v!==null){w.child=null;do{var S=v.sibling;v.sibling=null,v=S}while(v!==null)}}J=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,J=o;else e:for(;J!==null;){if(i=J,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Xr(9,i,i.return)}var g=i.sibling;if(g!==null){g.return=i.return,J=g;break e}J=i.return}}var p=e.current;for(J=p;J!==null;){o=J;var y=o.child;if(o.subtreeFlags&2064&&y!==null)y.return=o,J=y;else e:for(o=p;J!==null;){if(l=J,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Qa(9,l)}}catch(b){Ae(l,l.return,b)}if(l===o){J=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,J=j;break e}J=l.return}}if(me=a,kn(),Dt&&typeof Dt.onPostCommitFiberRoot=="function")try{Dt.onPostCommitFiberRoot(Da,e)}catch{}r=!0}return r}finally{ye=n,bt.transition=t}}return!1}function fu(e,t,n){t=vr(n,t),t=Lf(e,t,1),e=pn(e,t,1),t=nt(),e!==null&&(xs(e,1,t),ut(e,t))}function Ae(e,t,n){if(e.tag===3)fu(e,e,n);else for(;t!==null;){if(t.tag===3){fu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(gn===null||!gn.has(r))){e=vr(n,e),e=zf(t,e,1),t=pn(t,e,1),e=nt(),t!==null&&(xs(t,1,e),ut(t,e));break}}t=t.return}}function Rg(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=nt(),e.pingedLanes|=e.suspendedLanes&n,De===e&&(He&n)===n&&(Fe===4||Fe===3&&(He&130023424)===He&&500>Le()-_l?zn(e,0):Al|=n),ut(e,t)}function tm(e,t){t===0&&(e.mode&1?(t=As,As<<=1,!(As&130023424)&&(As=4194304)):t=1);var n=nt();e=Xt(e,t),e!==null&&(xs(e,t,n),ut(e,n))}function Pg(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),tm(e,n)}function Ag(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(M(314))}r!==null&&r.delete(t),tm(e,n)}var nm;nm=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||lt.current)ot=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ot=!1,xg(e,t,n);ot=!!(e.flags&131072)}else ot=!1,be&&t.flags&1048576&&af(t,ka,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;ra(e,t),e=t.pendingProps;var a=hr(t,qe.current);dr(t,n),a=Cl(null,t,r,e,a,n);var i=El();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ct(r)?(i=!0,ja(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,jl(t),a.updater=Ya,t.stateNode=a,a._reactInternals=t,bo(t,r,e,n),t=Eo(null,t,r,!0,i,n)):(t.tag=0,be&&i&&hl(t),et(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(ra(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=Lg(r),e=It(r,e),a){case 0:t=Co(null,t,r,e,n);break e;case 1:t=nu(null,t,r,e,n);break e;case 11:t=eu(null,t,r,e,n);break e;case 14:t=tu(null,t,r,It(r.type,e),n);break e}throw Error(M(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:It(r,a),Co(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:It(r,a),nu(e,t,r,a,n);case 3:e:{if(Of(t),e===null)throw Error(M(387));r=t.pendingProps,i=t.memoizedState,a=i.element,ff(e,t),Ca(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){a=vr(Error(M(423)),t),t=ru(e,t,r,n,a);break e}else if(r!==a){a=vr(Error(M(424)),t),t=ru(e,t,r,n,a);break e}else for(mt=hn(t.stateNode.containerInfo.firstChild),ht=t,be=!0,Pt=null,n=uf(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(pr(),r===a){t=qt(e,t,n);break e}et(e,t,r,n)}t=t.child}return t;case 5:return mf(t),e===null&&jo(t),r=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,o=a.children,go(r,a)?o=null:i!==null&&go(r,i)&&(t.flags|=32),Ff(e,t),et(e,t,o,n),t.child;case 6:return e===null&&jo(t),null;case 13:return Bf(e,t,n);case 4:return Sl(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=gr(t,null,r,n):et(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:It(r,a),eu(e,t,r,a,n);case 7:return et(e,t,t.pendingProps,n),t.child;case 8:return et(e,t,t.pendingProps.children,n),t.child;case 12:return et(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,i=t.memoizedProps,o=a.value,ve(ba,r._currentValue),r._currentValue=o,i!==null)if($t(i.value,o)){if(i.children===a.children&&!lt.current){t=qt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){o=i.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Yt(-1,n&-n),c.tag=2;var d=i.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}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),So(i.return,n,t),l.lanes|=n;break}c=c.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(M(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),So(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}et(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,dr(t,n),a=Nt(a),r=r(a),t.flags|=1,et(e,t,r,n),t.child;case 14:return r=t.type,a=It(r,t.pendingProps),a=It(r.type,a),tu(e,t,r,a,n);case 15:return $f(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:It(r,a),ra(e,t),t.tag=1,ct(r)?(e=!0,ja(t)):e=!1,dr(t,n),_f(t,r,a),bo(t,r,a,n),Eo(null,t,r,!0,e,n);case 19:return Df(e,t,n);case 22:return Mf(e,t,n)}throw Error(M(156,t.tag))};function rm(e,t){return Id(e,t)}function _g(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 kt(e,t,n,r){return new _g(e,t,n,r)}function Ml(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Lg(e){if(typeof e=="function")return Ml(e)?1:0;if(e!=null){if(e=e.$$typeof,e===nl)return 11;if(e===rl)return 14}return 2}function vn(e,t){var n=e.alternate;return n===null?(n=kt(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 ia(e,t,n,r,a,i){var o=2;if(r=e,typeof e=="function")Ml(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Jn:return $n(n.children,a,i,t);case tl:o=8,a|=8;break;case Ki:return e=kt(12,n,t,a|2),e.elementType=Ki,e.lanes=i,e;case Yi:return e=kt(13,n,t,a),e.elementType=Yi,e.lanes=i,e;case Qi:return e=kt(19,n,t,a),e.elementType=Qi,e.lanes=i,e;case fd:return Xa(n,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ud:o=10;break e;case dd:o=9;break e;case nl:o=11;break e;case rl:o=14;break e;case sn:o=16,r=null;break e}throw Error(M(130,e==null?e:typeof e,""))}return t=kt(o,n,t,a),t.elementType=e,t.type=r,t.lanes=i,t}function $n(e,t,n,r){return e=kt(7,e,r,t),e.lanes=n,e}function Xa(e,t,n,r){return e=kt(22,e,r,t),e.elementType=fd,e.lanes=n,e.stateNode={isHidden:!1},e}function Li(e,t,n){return e=kt(6,e,null,t),e.lanes=n,e}function zi(e,t,n){return t=kt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function zg(e,t,n,r,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=pi(0),this.expirationTimes=pi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pi(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Fl(e,t,n,r,a,i,o,l,c){return e=new zg(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=kt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},jl(i),e}function $g(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Qn,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function sm(e){if(!e)return wn;e=e._reactInternals;e:{if(Hn(e)!==e||e.tag!==1)throw Error(M(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ct(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(M(171))}if(e.tag===1){var n=e.type;if(ct(n))return rf(e,n,t)}return t}function am(e,t,n,r,a,i,o,l,c){return e=Fl(n,r,!0,e,a,i,o,l,c),e.context=sm(null),n=e.current,r=nt(),a=yn(n),i=Yt(r,a),i.callback=t??null,pn(n,i,a),e.current.lanes=a,xs(e,a,r),ut(e,r),e}function qa(e,t,n,r){var a=t.current,i=nt(),o=yn(a);return n=sm(n),t.context===null?t.context=n:t.pendingContext=n,t=Yt(i,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=pn(a,t,o),e!==null&&(Lt(e,a,o,i),ea(e,a,o)),o}function La(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 mu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Ol(e,t){mu(e,t),(e=e.alternate)&&mu(e,t)}function Mg(){return null}var im=typeof reportError=="function"?reportError:function(e){console.error(e)};function Bl(e){this._internalRoot=e}Za.prototype.render=Bl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(M(409));qa(e,t,null,null)};Za.prototype.unmount=Bl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Dn(function(){qa(null,e,null,null)}),t[Jt]=null}};function Za(e){this._internalRoot=e}Za.prototype.unstable_scheduleHydration=function(e){if(e){var t=$d();e={blockedOn:null,target:e,priority:t};for(var n=0;n<on.length&&t!==0&&t<on[n].priority;n++);on.splice(n,0,e),n===0&&Fd(e)}};function Dl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ei(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function hu(){}function Fg(e,t,n,r,a){if(a){if(typeof r=="function"){var i=r;r=function(){var d=La(o);i.call(d)}}var o=am(t,r,e,0,null,!1,!1,"",hu);return e._reactRootContainer=o,e[Jt]=o.current,cs(e.nodeType===8?e.parentNode:e),Dn(),o}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var l=r;r=function(){var d=La(c);l.call(d)}}var c=Fl(e,0,!1,null,null,!1,!1,"",hu);return e._reactRootContainer=c,e[Jt]=c.current,cs(e.nodeType===8?e.parentNode:e),Dn(function(){qa(t,c,n,r)}),c}function ti(e,t,n,r,a){var i=n._reactRootContainer;if(i){var o=i;if(typeof a=="function"){var l=a;a=function(){var c=La(o);l.call(c)}}qa(t,o,e,a)}else o=Fg(n,t,e,a,r);return La(o)}Ld=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Ur(t.pendingLanes);n!==0&&(il(t,n|1),ut(t,Le()),!(me&6)&&(xr=Le()+500,kn()))}break;case 13:Dn(function(){var r=Xt(e,1);if(r!==null){var a=nt();Lt(r,e,1,a)}}),Ol(e,1)}};ol=function(e){if(e.tag===13){var t=Xt(e,134217728);if(t!==null){var n=nt();Lt(t,e,134217728,n)}Ol(e,134217728)}};zd=function(e){if(e.tag===13){var t=yn(e),n=Xt(e,t);if(n!==null){var r=nt();Lt(n,e,t,r)}Ol(e,t)}};$d=function(){return ye};Md=function(e,t){var n=ye;try{return ye=e,t()}finally{ye=n}};ao=function(e,t,n){switch(t){case"input":if(qi(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=Va(r);if(!a)throw Error(M(90));hd(r),qi(r,a)}}}break;case"textarea":gd(e,n);break;case"select":t=n.value,t!=null&&or(e,!!n.multiple,t,!1)}};kd=Ll;bd=Dn;var Og={usingClientEntryPoint:!1,Events:[js,er,Va,jd,Sd,Ll]},zr={findFiberByHostInstance:Rn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Bg={bundleType:zr.bundleType,version:zr.version,rendererPackageName:zr.rendererPackageName,rendererConfig:zr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:en.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Ed(e),e===null?null:e.stateNode},findFiberByHostInstance:zr.findFiberByHostInstance||Mg,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 Ws=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ws.isDisabled&&Ws.supportsFiber)try{Da=Ws.inject(Bg),Dt=Ws}catch{}}gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Og;gt.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Dl(t))throw Error(M(200));return $g(e,t,null,n)};gt.createRoot=function(e,t){if(!Dl(e))throw Error(M(299));var n=!1,r="",a=im;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=Fl(e,1,!1,null,null,n,!1,r,a),e[Jt]=t.current,cs(e.nodeType===8?e.parentNode:e),new Bl(t)};gt.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(M(188)):(e=Object.keys(e).join(","),Error(M(268,e)));return e=Ed(t),e=e===null?null:e.stateNode,e};gt.flushSync=function(e){return Dn(e)};gt.hydrate=function(e,t,n){if(!ei(t))throw Error(M(200));return ti(null,e,t,!0,n)};gt.hydrateRoot=function(e,t,n){if(!Dl(e))throw Error(M(405));var r=n!=null&&n.hydratedSources||null,a=!1,i="",o=im;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=am(t,null,e,1,n??null,a,!1,i,o),e[Jt]=t.current,cs(e),r)for(e=0;e<r.length;e++)n=r[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new Za(t)};gt.render=function(e,t,n){if(!ei(t))throw Error(M(200));return ti(null,e,t,!1,n)};gt.unmountComponentAtNode=function(e){if(!ei(e))throw Error(M(40));return e._reactRootContainer?(Dn(function(){ti(null,null,e,!1,function(){e._reactRootContainer=null,e[Jt]=null})}),!0):!1};gt.unstable_batchedUpdates=Ll;gt.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!ei(n))throw Error(M(200));if(e==null||e._reactInternals===void 0)throw Error(M(38));return ti(e,t,n,!1,r)};gt.version="18.3.1-next-f1338f8080-20240426";function om(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(om)}catch(e){console.error(e)}}om(),id.exports=gt;var lm=id.exports,cm,pu=lm;cm=pu.createRoot,pu.hydrateRoot;/**
|
|
41
|
+
* react-router v7.18.4
|
|
42
42
|
*
|
|
43
43
|
* Copyright (c) Remix Software Inc.
|
|
44
44
|
*
|
|
@@ -46,33 +46,33 @@ Error generating stack: `+i.message+`
|
|
|
46
46
|
* LICENSE.md file in the root directory of this source tree.
|
|
47
47
|
*
|
|
48
48
|
* @license MIT
|
|
49
|
-
*/var cu="popstate";function uu(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Rg(e={}){function t(r,a){var d;let i=(d=a.state)==null?void 0:d.masked,{pathname:o,search:l,hash:c}=i||r.location;return Lo("",{pathname:o,search:l,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default",i?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,a){return typeof a=="string"?a:gs(a)}return Ag(t,n,null,e)}function Ne(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Et(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Pg(){return Math.random().toString(36).substring(2,10)}function du(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 Lo(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Sr(t):t,state:n,key:t&&t.key||r||Pg(),unstable_mask:a}}function gs({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 Sr(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 Ag(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,l="POP",c=null,d=f();d==null&&(d=0,o.replaceState({...o.state,idx:d},""));function f(){return(o.state||{idx:null}).idx}function m(){l="POP";let S=f(),g=S==null?null:S-d;d=S,c&&c({action:l,location:v.location,delta:g})}function p(S,g){l="PUSH";let h=uu(S)?S:Lo(v.location,S,g);d=f()+1;let y=du(h,d),j=v.createHref(h.unstable_mask||h);try{o.pushState(y,"",j)}catch(b){if(b instanceof DOMException&&b.name==="DataCloneError")throw b;a.location.assign(j)}i&&c&&c({action:l,location:v.location,delta:1})}function x(S,g){l="REPLACE";let h=uu(S)?S:Lo(v.location,S,g);d=f();let y=du(h,d),j=v.createHref(h.unstable_mask||h);o.replaceState(y,"",j),i&&c&&c({action:l,location:v.location,delta:0})}function w(S){return _g(S)}let v={get action(){return l},get location(){return e(a,o)},listen(S){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(cu,m),c=S,()=>{a.removeEventListener(cu,m),c=null}},createHref(S){return t(a,S)},createURL:w,encodeLocation(S){let g=w(S);return{pathname:g.pathname,search:g.search,hash:g.hash}},push:p,replace:x,go(S){return o.go(S)}};return v}function _g(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Ne(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:gs(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function nm(e,t,n="/"){return zg(e,t,n,!1)}function zg(e,t,n,r){let a=typeof t=="string"?Sr(t):t,i=Zt(a.pathname||"/",n);if(i==null)return null;let o=rm(e);$g(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let d=Gg(i);l=Hg(o[c],d,r)}return l}function rm(e,t=[],n=[],r="",a=!1){let i=(o,l,c=a,d)=>{let f={relativePath:d===void 0?o.path||"":d,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&c)return;Ne(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=Ut([r,f.relativePath]),p=n.concat(f);o.children&&o.children.length>0&&(Ne(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),rm(o.children,t,p,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:Ug(m,o.index),routesMeta:p})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let d of sm(o.path))i(o,l,!0,d)}),t}function sm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=sm(r.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),a&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function $g(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Wg(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Lg=/^:[\w-]+$/,Mg=3,Fg=2,Og=1,Bg=10,Dg=-2,fu=e=>e==="*";function Ug(e,t){let n=e.split("/"),r=n.length;return n.some(fu)&&(r+=Dg),t&&(r+=Fg),n.filter(a=>!fu(a)).reduce((a,i)=>a+(Lg.test(i)?Mg:i===""?Og:Bg),r)}function Wg(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function Hg(e,t,n=!1){let{routesMeta:r}=e,a={},i="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,f=i==="/"?t:t.slice(i.length)||"/",m=za({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),p=c.route;if(!m&&d&&n&&!r[r.length-1].route.index&&(m=za({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!m)return null;Object.assign(a,m.params),o.push({params:a,pathname:Ut([i,m.pathname]),pathnameBase:Jg(Ut([i,m.pathnameBase])),route:p}),m.pathnameBase!=="/"&&(i=Ut([i,m.pathnameBase]))}return o}function za(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Vg(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((d,{paramName:f,isOptional:m},p)=>{if(f==="*"){let w=l[p]||"";o=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const x=l[p];return m&&!x?d[f]=void 0:d[f]=(x||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:o,pattern:e}}function Vg(e,t=!1,n=!0){Et(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,d,f)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let m=f.charAt(d+o.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function Gg(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Et(!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 Zt(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 Kg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Yg(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?Sr(e):e,i;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?i=mu(n.substring(1),"/"):i=mu(n,t)):i=t,{pathname:i,search:Xg(r),hash:qg(a)}}function mu(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function zi(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 Qg(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Ol(e){let t=Qg(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function ti(e,t,n,r=!1){let a;typeof e=="string"?a=Sr(e):(a={...e},Ne(!a.pathname||!a.pathname.includes("?"),zi("?","pathname","search",a)),Ne(!a.pathname||!a.pathname.includes("#"),zi("#","pathname","hash",a)),Ne(!a.search||!a.search.includes("#"),zi("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=n;else{let m=t.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),m-=1;a.pathname=p.join("/")}l=m>=0?t[m]:"/"}let c=Yg(a,l),d=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Ut=e=>e.join("/").replace(/\/\/+/g,"/"),Jg=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Xg=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,qg=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Zg=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 ey(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function ty(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var am=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function im(e,t){let n=e;if(typeof n!="string"||!Kg.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(am)try{let i=new URL(window.location.href),o=n.startsWith("//")?new URL(i.protocol+n):new URL(n),l=Zt(o.pathname,t);o.origin===i.origin&&l!=null?n=l+o.search+o.hash:a=!0}catch{Et(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var om=["POST","PUT","PATCH","DELETE"];new Set(om);var ny=["GET",...om];new Set(ny);var kr=u.createContext(null);kr.displayName="DataRouter";var ni=u.createContext(null);ni.displayName="DataRouterState";var ry=u.createContext(!1),lm=u.createContext({isTransitioning:!1});lm.displayName="ViewTransition";var sy=u.createContext(new Map);sy.displayName="Fetchers";var ay=u.createContext(null);ay.displayName="Await";var yt=u.createContext(null);yt.displayName="Navigation";var Ss=u.createContext(null);Ss.displayName="Location";var Lt=u.createContext({outlet:null,matches:[],isDataRoute:!1});Lt.displayName="Route";var Bl=u.createContext(null);Bl.displayName="RouteError";var cm="REACT_ROUTER_ERROR",iy="REDIRECT",oy="ROUTE_ERROR_RESPONSE";function ly(e){if(e.startsWith(`${cm}:${iy}:{`))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 cy(e){if(e.startsWith(`${cm}:${oy}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Zg(t.status,t.statusText,t.data)}catch{}}function uy(e,{relative:t}={}){Ne(br(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=u.useContext(yt),{hash:a,pathname:i,search:o}=ks(e,{relative:t}),l=i;return n!=="/"&&(l=i==="/"?n:Ut([n,i])),r.createHref({pathname:l,search:o,hash:a})}function br(){return u.useContext(Ss)!=null}function vt(){return Ne(br(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(Ss).location}var um="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function dm(e){u.useContext(yt).static||u.useLayoutEffect(e)}function tn(){let{isDataRoute:e}=u.useContext(Lt);return e?Ny():dy()}function dy(){Ne(br(),"useNavigate() may be used only in the context of a <Router> component.");let e=u.useContext(kr),{basename:t,navigator:n}=u.useContext(yt),{matches:r}=u.useContext(Lt),{pathname:a}=vt(),i=JSON.stringify(Ol(r)),o=u.useRef(!1);return dm(()=>{o.current=!0}),u.useCallback((c,d={})=>{if(Et(o.current,um),!o.current)return;if(typeof c=="number"){n.go(c);return}let f=ti(c,JSON.parse(i),a,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Ut([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,i,a,e])}var fy=u.createContext(null);function my(e){let t=u.useContext(Lt).outlet;return u.useMemo(()=>t&&u.createElement(fy.Provider,{value:e},t),[t,e])}function ks(e,{relative:t}={}){let{matches:n}=u.useContext(Lt),{pathname:r}=vt(),a=JSON.stringify(Ol(n));return u.useMemo(()=>ti(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function py(e,t){return fm(e,t)}function fm(e,t,n){var S;Ne(br(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=u.useContext(yt),{matches:a}=u.useContext(Lt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",d=i&&i.route;{let g=d&&d.path||"";pm(l,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${g}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
49
|
+
*/var Ul=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,um=/^[\\/]{2}/;function Dg(e,t){return t+e.replace(/\\/g,"/")}var gu="popstate";function yu(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Ug(e={}){function t(r,a){var d;let i=(d=a.state)==null?void 0:d.masked,{pathname:o,search:l,hash:c}=i||r.location;return Oo("",{pathname:o,search:l,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default",i?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,a){return typeof a=="string"?a:Un(a)}return Hg(t,n,null,e)}function Ne(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Et(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Wg(){return Math.random().toString(36).substring(2,10)}function vu(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Oo(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?br(t):t,state:n,key:t&&t.key||r||Wg(),mask:a}}function Un({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 br(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 Hg(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,l="POP",c=null,d=f();d==null&&(d=0,o.replaceState({...o.state,idx:d},""));function f(){return(o.state||{idx:null}).idx}function h(){l="POP";let S=f(),g=S==null?null:S-d;d=S,c&&c({action:l,location:v.location,delta:g})}function m(S,g){l="PUSH";let p=yu(S)?S:Oo(v.location,S,g);d=f()+1;let y=vu(p,d),j=v.createHref(p.mask||p);try{o.pushState(y,"",j)}catch(b){if(b instanceof DOMException&&b.name==="DataCloneError")throw b;a.location.assign(j)}i&&c&&c({action:l,location:v.location,delta:1})}function x(S,g){l="REPLACE";let p=yu(S)?S:Oo(v.location,S,g);d=f();let y=vu(p,d),j=v.createHref(p.mask||p);o.replaceState(y,"",j),i&&c&&c({action:l,location:v.location,delta:0})}function w(S){return Vg(a,S)}let v={get action(){return l},get location(){return e(a,o)},listen(S){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(gu,h),c=S,()=>{a.removeEventListener(gu,h),c=null}},createHref(S){return t(a,S)},createURL:w,encodeLocation(S){let g=w(S);return{pathname:g.pathname,search:g.search,hash:g.hash}},push:m,replace:x,go(S){return o.go(S)}};return v}function Vg(e,t,n=!1){let r="http://localhost";e&&(r=e.location.origin!=="null"?e.location.origin:e.location.href),Ne(r,"No window.location.(origin|href) available to create URL");let a=typeof t=="string"?t:Un(t);return a=a.replace(/ $/,"%20"),!n&&um.test(a)&&(a=r+a),new URL(a,r)}function dm(e,t,n="/"){return Gg(e,t,n,!1)}function Gg(e,t,n,r,a){let i=typeof t=="string"?br(t):t,o=Zt(i.pathname||"/",n);if(o==null)return null;let l=Kg(e),c=null,d=sy(o);for(let f=0;c==null&&f<l.length;++f)c=ry(l[f],d,r);return c}function Kg(e){let t=fm(e);return Yg(t),t}function fm(e,t=[],n=[],r="",a=!1){let i=(o,l,c=a,d)=>{let f={relativePath:d===void 0?o.path||"":d,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&c)return;Ne(f.relativePath.startsWith(r),`Absolute route path "${f.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(r.length)}let h=zt([r,f.relativePath]),m=n.concat(f);o.children&&o.children.length>0&&(Ne(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),fm(o.children,t,m,h,c)),!(o.path==null&&!o.index)&&t.push({path:h,score:ty(h,o.index),routesMeta:m.map((x,w)=>{let[v,S]=pm(x.relativePath,x.caseSensitive,w===m.length-1);return{...x,matcher:v,compiledParams:S}})})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let d of mm(o.path))i(o,l,!0,d)}),t}function mm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=mm(r.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),a&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function Yg(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:ny(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Qg=/^:[\w-]+$/,Jg=3,Xg=2,qg=1,Zg=10,ey=-2,xu=e=>e==="*";function ty(e,t){let n=e.split("/"),r=n.length;return n.some(xu)&&(r+=ey),t&&(r+=Xg),n.filter(a=>!xu(a)).reduce((a,i)=>a+(Qg.test(i)?Jg:i===""?qg:Zg),r)}function ny(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function ry(e,t,n=!1){let{routesMeta:r}=e,a={},i="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,f=i==="/"?t:t.slice(i.length)||"/",h={path:c.relativePath,caseSensitive:c.caseSensitive,end:d},m=c.matcher&&c.compiledParams?hm(h,f,c.matcher,c.compiledParams):za(h,f),x=c.route;if(!m&&d&&n&&!r[r.length-1].route.index&&(m=za({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!m)return null;Object.assign(a,m.params),o.push({params:a,pathname:zt([i,m.pathname]),pathnameBase:oy(zt([i,m.pathnameBase])),route:x}),m.pathnameBase!=="/"&&(i=zt([i,m.pathnameBase]))}return o}function za(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=pm(e.path,e.caseSensitive,e.end);return hm(e,t,n,r)}function hm(e,t,n,r){let a=t.match(n);if(!a)return null;let i=a[0],o=wr(i,1),l=a.slice(1);return{params:r.reduce((d,{paramName:f,isOptional:h},m)=>{if(f==="*"){let w=l[m]||"";o=wr(i.slice(0,i.length-w.length),1)}const x=l[m];return h&&!x?d[f]=void 0:d[f]=(x||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:o,pattern:e}}function pm(e,t=!1,n=!0){Et(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,d,f)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let h=f.charAt(d+o.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function sy(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Et(!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 Zt(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)||"/"}function ay(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?br(e):e,i;return n?(n=gm(n),n.startsWith("/")||n.startsWith("\\")?i=wu(n.substring(1),"/"):i=wu(n,t)):i=t,{pathname:i,search:ly(r),hash:cy(a)}}function wu(e,t){let n=wr(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function $i(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 iy(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Wl(e){let t=iy(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function ni(e,t,n,r=!1){let a;typeof e=="string"?a=br(e):(a={...e},Ne(!a.pathname||!a.pathname.includes("?"),$i("?","pathname","search",a)),Ne(!a.pathname||!a.pathname.includes("#"),$i("#","pathname","hash",a)),Ne(!a.search||!a.search.includes("#"),$i("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=n;else{let h=t.length-1;if(!r&&o.startsWith("..")){let m=o.split("/");for(;m[0]==="..";)m.shift(),h-=1;a.pathname=m.join("/")}l=h>=0?t[h]:"/"}let c=ay(a,l),d=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var gm=e=>e.replace(/[\\/]{2,}/g,"/"),zt=e=>gm(e.join("/"));function wr(e,t=0){let n=e.length;for(;n>t&&e.charCodeAt(n-1)===47;)n--;return n===e.length?e:e.slice(0,n)}var oy=e=>wr(e).replace(/^\/*/,"/"),ly=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,cy=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,uy=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 dy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function fy(e){let t=e.map(n=>n.route.path).filter(Boolean);return zt(t)||"/"}var ym=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function vm(e,t){let n=e;if(typeof n!="string"||!Ul.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(ym)try{let i=new URL(window.location.href),o=um.test(n)?new URL(Dg(n,i.protocol)):new URL(n),l=Zt(o.pathname,t);o.origin===i.origin&&l!=null?n=l+o.search+o.hash:a=!0}catch{Et(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var ju=new URL("http://localhost");function Hl(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),ju)}catch{return ju}}function Mi(e,t){return e.origin===t.origin&&(e.origin!=="null"||e.protocol===t.protocol&&e.host===t.host)}function my(e,t){if(e.startsWith("//"))return!0;let n=t.protocol.toLowerCase();return e.toLowerCase().startsWith(n)?t.host===""||e.slice(n.length).startsWith("//"):!1}function Vl(e,t,n,r){let a=null;try{a=e==null?null:new URL(e,n)}catch{}let i=new URL(t,n),o=a!=null&&!Mi(a,n),l=!Mi(i,n);if(r==="reject"){if(o||l)throw new Error("External navigation is not allowed")}else if(l&&(a==null||!my(e,a)||!Mi(a,i)))throw new Error("External navigation is not allowed")}var xm=["POST","PUT","PATCH","DELETE"];new Set(xm);var hy=["GET",...xm];new Set(hy);var py=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function gy(e){try{return py.includes(new URL(e).protocol)}catch{return!1}}var Nr=u.createContext(null);Nr.displayName="DataRouter";var ri=u.createContext(null);ri.displayName="DataRouterState";var wm=u.createContext(!1);function yy(){return u.useContext(wm)}var jm=u.createContext({isTransitioning:!1});jm.displayName="ViewTransition";var vy=u.createContext(new Map);vy.displayName="Fetchers";var xy=u.createContext(null);xy.displayName="Await";var vt=u.createContext(null);vt.displayName="Navigation";var ks=u.createContext(null);ks.displayName="Location";var Mt=u.createContext({outlet:null,matches:[],isDataRoute:!1});Mt.displayName="Route";var Gl=u.createContext(null);Gl.displayName="RouteError";var Sm="REACT_ROUTER_ERROR",wy="REDIRECT",jy="ROUTE_ERROR_RESPONSE";function Sy(e){if(e.startsWith(`${Sm}:${wy}:{`))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 ky(e){if(e.startsWith(`${Sm}:${jy}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new uy(t.status,t.statusText,t.data)}catch{}}function by(e,{relative:t}={}){Ne(Cr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=u.useContext(vt),{hash:a,pathname:i,search:o}=bs(e,{relative:t}),l=i;return n!=="/"&&(l=i==="/"?n:zt([n,i])),r.createHref({pathname:l,search:o,hash:a})}function Cr(){return u.useContext(ks)!=null}function dt(){return Ne(Cr(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(ks).location}var km="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function bm(e){u.useContext(vt).static||u.useLayoutEffect(e)}function tn(){let{isDataRoute:e}=u.useContext(Mt);return e?Oy():Ny()}function Ny(){Ne(Cr(),"useNavigate() may be used only in the context of a <Router> component.");let e=u.useContext(Nr),{basename:t,navigator:n}=u.useContext(vt),{matches:r}=u.useContext(Mt),{pathname:a}=dt(),i=JSON.stringify(Wl(r)),o=u.useRef(!1);return bm(()=>{o.current=!0}),u.useCallback((c,d={})=>{if(Et(o.current,km),!o.current)return;if(typeof c=="number"){n.go(c);return}let f=ni(c,JSON.parse(i),a,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:zt([t,f.pathname])),Vl(typeof c=="string"?c:Un(c),n.createHref(f),Hl(n),"reject"),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,i,a,e])}var Cy=u.createContext(null);function Ey(e){let t=u.useContext(Mt).outlet;return u.useMemo(()=>t&&u.createElement(Cy.Provider,{value:e},t),[t,e])}function bs(e,{relative:t}={}){let{matches:n}=u.useContext(Mt),{pathname:r}=dt(),a=JSON.stringify(Wl(n));return u.useMemo(()=>ni(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Ty(e,t){return Nm(e,t)}function Nm(e,t,n){var S;Ne(Cr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=u.useContext(vt),{matches:a}=u.useContext(Mt),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",d=i&&i.route;{let g=d&&d.path||"";Em(l,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${g}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
50
50
|
|
|
51
|
-
Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let f=vt(),m;if(t){let g=typeof t=="string"?Sr(t):t;Ne(c==="/"||((S=g.pathname)==null?void 0:S.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${g.pathname}" was given in the \`location\` prop.`),m=g}else m=f;let p=m.pathname||"/",x=p;if(c!=="/"){let g=c.replace(/^\//,"").split("/");x="/"+p.replace(/^\//,"").split("/").slice(g.length).join("/")}let w=nm(e,{pathname:x});Et(d||w!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Et(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 v=xy(w&&w.map(g=>Object.assign({},g,{params:Object.assign({},o,g.params),pathname:Ut([c,r.encodeLocation?r.encodeLocation(g.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:Ut([c,r.encodeLocation?r.encodeLocation(g.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),a,n);return t&&v?u.createElement(Ss.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...m},navigationType:"POP"}},v):v}function hy(){let e=by(),t=ey(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=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:i},"ErrorBoundary")," or"," ",u.createElement("code",{style:i},"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:a},n):null,o)}var gy=u.createElement(hy,null),mm=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=cy(e.digest);n&&(e=n)}let t=e!==void 0?u.createElement(Lt.Provider,{value:this.props.routeContext},u.createElement(Bl.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?u.createElement(yy,{error:e},t):t}};mm.contextType=ry;var $i=new WeakMap;function yy({children:e,error:t}){let{basename:n}=u.useContext(yt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=ly(t.digest);if(r){let a=$i.get(t);if(a)throw a;let i=im(r.location,n);if(am&&!$i.get(t))if(i.isExternal||r.reloadDocument)window.location.href=i.absoluteURL||i.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:r.replace}));throw $i.set(t,o),o}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${i.absoluteURL||i.to}`})}}return e}function vy({routeContext:e,match:t,children:n}){let r=u.useContext(kr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),u.createElement(Lt.Provider,{value:e},n)}function xy(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,i=r==null?void 0:r.errors;if(i!=null){let f=a.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);Ne(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,f+1))}let o=!1,l=-1;if(n&&r){o=r.renderFallback;for(let f=0;f<a.length;f++){let m=a[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&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[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:ty(r.matches),errorInfo:m})}:void 0;return a.reduceRight((f,m,p)=>{let x,w=!1,v=null,S=null;r&&(x=i&&m.route.id?i[m.route.id]:void 0,v=m.route.errorElement||gy,o&&(l<0&&p===0?(pm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),w=!0,S=null):l===p&&(w=!0,S=m.route.hydrateFallbackElement||null)));let g=t.concat(a.slice(0,p+1)),h=()=>{let y;return x?y=v:w?y=S:m.route.Component?y=u.createElement(m.route.Component,null):m.route.element?y=m.route.element:y=f,u.createElement(vy,{match:m,routeContext:{outlet:f,matches:g,isDataRoute:r!=null},children:y})};return r&&(m.route.ErrorBoundary||m.route.errorElement||p===0)?u.createElement(mm,{location:r.location,revalidation:r.revalidation,component:v,error:x,children:h(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:d}):h()},null)}function Dl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function wy(e){let t=u.useContext(kr);return Ne(t,Dl(e)),t}function jy(e){let t=u.useContext(ni);return Ne(t,Dl(e)),t}function Sy(e){let t=u.useContext(Lt);return Ne(t,Dl(e)),t}function Ul(e){let t=Sy(e),n=t.matches[t.matches.length-1];return Ne(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function ky(){return Ul("useRouteId")}function by(){var r;let e=u.useContext(Bl),t=jy("useRouteError"),n=Ul("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function Ny(){let{router:e}=wy("useNavigate"),t=Ul("useNavigate"),n=u.useRef(!1);return dm(()=>{n.current=!0}),u.useCallback(async(a,i={})=>{Et(n.current,um),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var pu={};function pm(e,t,n){!t&&!pu[e]&&(pu[e]=!0,Et(!1,n))}u.memo(Cy);function Cy({routes:e,future:t,state:n,isStatic:r,onError:a}){return fm(e,void 0,{state:n,isStatic:r,onError:a})}function Vt({to:e,replace:t,state:n,relative:r}){Ne(br(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=u.useContext(yt);Et(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:i}=u.useContext(Lt),{pathname:o}=vt(),l=tn(),c=ti(e,Ol(i),o,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 Ey(e){return my(e.context)}function je(e){Ne(!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 Ty({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:i=!1,unstable_useTransitions:o}){Ne(!br(),"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:a,static:i,unstable_useTransitions:o,future:{}}),[l,a,i,o]);typeof n=="string"&&(n=Sr(n));let{pathname:d="/",search:f="",hash:m="",state:p=null,key:x="default",unstable_mask:w}=n,v=u.useMemo(()=>{let S=Zt(d,l);return S==null?null:{location:{pathname:S,search:f,hash:m,state:p,key:x,unstable_mask:w},navigationType:r}},[l,d,f,m,p,x,r,w]);return Et(v!=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.`),v==null?null:u.createElement(yt.Provider,{value:c},u.createElement(Ss.Provider,{children:t,value:v}))}function Iy({children:e,location:t}){return py(Mo(e),t)}function Mo(e,t=[]){let n=[];return u.Children.forEach(e,(r,a)=>{if(!u.isValidElement(r))return;let i=[...t,a];if(r.type===u.Fragment){n.push.apply(n,Mo(r.props.children,i));return}Ne(r.type===je,`[${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>`),Ne(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||i.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&&(o.children=Mo(r.props.children,i)),n.push(o)}),n}var ia="get",oa="application/x-www-form-urlencoded";function ri(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Ry(e){return ri(e)&&e.tagName.toLowerCase()==="button"}function Py(e){return ri(e)&&e.tagName.toLowerCase()==="form"}function Ay(e){return ri(e)&&e.tagName.toLowerCase()==="input"}function _y(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function zy(e,t){return e.button===0&&(!t||t==="_self")&&!_y(e)}function Fo(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function $y(e,t){let n=Fo(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}var Ws=null;function Ly(){if(Ws===null)try{new FormData(document.createElement("form"),0),Ws=!1}catch{Ws=!0}return Ws}var My=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Li(e){return e!=null&&!My.has(e)?(Et(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${oa}"`),null):e}function Fy(e,t){let n,r,a,i,o;if(Py(e)){let l=e.getAttribute("action");r=l?Zt(l,t):null,n=e.getAttribute("method")||ia,a=Li(e.getAttribute("enctype"))||oa,i=new FormData(e)}else if(Ry(e)||Ay(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?Zt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||ia,a=Li(e.getAttribute("formenctype"))||Li(l.getAttribute("enctype"))||oa,i=new FormData(l,e),!Ly()){let{name:d,type:f,value:m}=e;if(f==="image"){let p=d?`${d}.`:"";i.append(`${p}x`,"0"),i.append(`${p}y`,"0")}else d&&i.append(d,m)}}else{if(ri(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=ia,r=null,a=oa,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Wl(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Oy(e,t,n,r){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${r}`:a.pathname=`${a.pathname}.${r}`:a.pathname==="/"?a.pathname=`_root.${r}`:t&&Zt(a.pathname,t)==="/"?a.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${r}`,a}async function By(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 Dy(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 Uy(e,t,n){let r=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await By(i,n);return o.links?o.links():[]}return[]}));return Gy(r.flat(1).filter(Dy).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function hu(e,t,n,r,a,i){let o=(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 i==="assets"?t.filter((c,d)=>o(c,d)||l(c,d)):i==="data"?t.filter((c,d)=>{var m;let f=r.routes[c.route.id];if(!f||!f.hasLoader)return!1;if(o(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let p=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.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 Wy(e,t,{includeHydrateFallback:n}={}){return Hy(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function Hy(e){return[...new Set(e)]}function Vy(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Gy(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let i=JSON.stringify(Vy(a));return n.has(i)||(n.add(i),r.push({key:i,link:a})),r},[])}function hm(){let e=u.useContext(kr);return Wl(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Ky(){let e=u.useContext(ni);return Wl(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Hl=u.createContext(void 0);Hl.displayName="FrameworkContext";function gm(){let e=u.useContext(Hl);return Wl(e,"You must render this element inside a <HydratedRouter> element"),e}function Yy(e,t){let n=u.useContext(Hl),[r,a]=u.useState(!1),[i,o]=u.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:m}=t,p=u.useRef(null);u.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let v=g=>{g.forEach(h=>{o(h.isIntersecting)})},S=new IntersectionObserver(v,{threshold:.5});return p.current&&S.observe(p.current),()=>{S.disconnect()}}},[e]),u.useEffect(()=>{if(r){let v=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(v)}}},[r]);let x=()=>{a(!0)},w=()=>{a(!1),o(!1)};return n?e!=="intent"?[i,p,{}]:[i,p,{onFocus:zr(l,x),onBlur:zr(c,w),onMouseEnter:zr(d,x),onMouseLeave:zr(f,w),onTouchStart:zr(m,x)}]:[!1,p,{}]}function zr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Qy({page:e,...t}){let{router:n}=hm(),r=u.useMemo(()=>nm(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?u.createElement(Xy,{page:e,matches:r,...t}):null}function Jy(e){let{manifest:t,routeModules:n}=gm(),[r,a]=u.useState([]);return u.useEffect(()=>{let i=!1;return Uy(e,t,n).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,n]),r}function Xy({page:e,matches:t,...n}){let r=vt(),{future:a,manifest:i,routeModules:o}=gm(),{basename:l}=hm(),{loaderData:c,matches:d}=Ky(),f=u.useMemo(()=>hu(e,t,d,i,r,"data"),[e,t,d,i,r]),m=u.useMemo(()=>hu(e,t,d,i,r,"assets"),[e,t,d,i,r]),p=u.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let v=new Set,S=!1;if(t.forEach(h=>{var j;let y=i.routes[h.route.id];!y||!y.hasLoader||(!f.some(b=>b.route.id===h.route.id)&&h.route.id in c&&((j=o[h.route.id])!=null&&j.shouldRevalidate)||y.hasClientLoader?S=!0:v.add(h.route.id))}),v.size===0)return[];let g=Oy(e,l,a.unstable_trailingSlashAwareDataRequests,"data");return S&&v.size>0&&g.searchParams.set("_routes",t.filter(h=>v.has(h.route.id)).map(h=>h.route.id).join(",")),[g.pathname+g.search]},[l,a.unstable_trailingSlashAwareDataRequests,c,r,i,f,t,e,o]),x=u.useMemo(()=>Wy(m,i),[m,i]),w=Jy(m);return u.createElement(u.Fragment,null,p.map(v=>u.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),x.map(v=>u.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),w.map(({key:v,link:S})=>u.createElement("link",{key:v,nonce:n.nonce,...S,crossOrigin:S.crossOrigin??n.crossOrigin})))}function qy(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Zy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Zy&&(window.__reactRouterVersion="7.13.1")}catch{}function ev({basename:e,children:t,unstable_useTransitions:n,window:r}){let a=u.useRef();a.current==null&&(a.current=Rg({window:r,v5Compat:!0}));let i=a.current,[o,l]=u.useState({action:i.action,location:i.location}),c=u.useCallback(d=>{n===!1?l(d):u.startTransition(()=>l(d))},[n]);return u.useLayoutEffect(()=>i.listen(c),[i,c]),u.createElement(Ty,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:i,unstable_useTransitions:n})}var ym=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,tt=u.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:i,replace:o,unstable_mask:l,state:c,target:d,to:f,preventScrollReset:m,viewTransition:p,unstable_defaultShouldRevalidate:x,...w},v){let{basename:S,navigator:g,unstable_useTransitions:h}=u.useContext(yt),y=typeof f=="string"&&ym.test(f),j=im(f,S);f=j.to;let b=uy(f,{relative:a}),C=vt(),N=null;if(l){let Q=ti(l,[],C.unstable_mask?C.unstable_mask.pathname:"/",!0);S!=="/"&&(Q.pathname=Q.pathname==="/"?S:Ut([S,Q.pathname])),N=g.createHref(Q)}let[I,E,A]=Yy(r,w),D=rv(f,{replace:o,unstable_mask:l,state:c,target:d,preventScrollReset:m,relative:a,viewTransition:p,unstable_defaultShouldRevalidate:x,unstable_useTransitions:h});function z(Q){t&&t(Q),Q.defaultPrevented||D(Q)}let K=!(j.isExternal||i),$=u.createElement("a",{...w,...A,href:(K?N:void 0)||j.absoluteURL||b,onClick:K?z:t,ref:qy(v,E),target:d,"data-discover":!y&&n==="render"?"true":void 0});return I&&!y?u.createElement(u.Fragment,null,$,u.createElement(Qy,{page:b})):$});tt.displayName="Link";var Vl=u.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...d},f){let m=ks(o,{relative:d.relative}),p=vt(),x=u.useContext(ni),{navigator:w,basename:v}=u.useContext(yt),S=x!=null&&lv(m)&&l===!0,g=w.encodeLocation?w.encodeLocation(m).pathname:m.pathname,h=p.pathname,y=x&&x.navigation&&x.navigation.location?x.navigation.location.pathname:null;n||(h=h.toLowerCase(),y=y?y.toLowerCase():null,g=g.toLowerCase()),y&&v&&(y=Zt(y,v)||y);const j=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let b=h===g||!a&&h.startsWith(g)&&h.charAt(j)==="/",C=y!=null&&(y===g||!a&&y.startsWith(g)&&y.charAt(g.length)==="/"),N={isActive:b,isPending:C,isTransitioning:S},I=b?t:void 0,E;typeof r=="function"?E=r(N):E=[r,b?"active":null,C?"pending":null,S?"transitioning":null].filter(Boolean).join(" ");let A=typeof i=="function"?i(N):i;return u.createElement(tt,{...d,"aria-current":I,className:E,ref:f,style:A,to:o,viewTransition:l},typeof c=="function"?c(N):c)});Vl.displayName="NavLink";var tv=u.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:i,method:o=ia,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:m,unstable_defaultShouldRevalidate:p,...x},w)=>{let{unstable_useTransitions:v}=u.useContext(yt),S=iv(),g=ov(l,{relative:d}),h=o.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&ym.test(l),j=b=>{if(c&&c(b),b.defaultPrevented)return;b.preventDefault();let C=b.nativeEvent.submitter,N=(C==null?void 0:C.getAttribute("formmethod"))||o,I=()=>S(C||b.currentTarget,{fetcherKey:t,method:N,navigate:n,replace:a,state:i,relative:d,preventScrollReset:f,viewTransition:m,unstable_defaultShouldRevalidate:p});v&&n!==!1?u.startTransition(()=>I()):I()};return u.createElement("form",{ref:w,method:h,action:g,onSubmit:r?c:j,...x,"data-discover":!y&&e==="render"?"true":void 0})});tv.displayName="Form";function nv(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function vm(e){let t=u.useContext(kr);return Ne(t,nv(e)),t}function rv(e,{target:t,replace:n,unstable_mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,unstable_defaultShouldRevalidate:c,unstable_useTransitions:d}={}){let f=tn(),m=vt(),p=ks(e,{relative:o});return u.useCallback(x=>{if(zy(x,t)){x.preventDefault();let w=n!==void 0?n:gs(m)===gs(p),v=()=>f(e,{replace:w,unstable_mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,unstable_defaultShouldRevalidate:c});d?u.startTransition(()=>v()):v()}},[m,f,p,n,r,a,t,e,i,o,l,c,d])}function Gl(e){Et(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(Fo(e)),n=u.useRef(!1),r=vt(),a=u.useMemo(()=>$y(r.search,n.current?null:t.current),[r.search]),i=tn(),o=u.useCallback((l,c)=>{const d=Fo(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,i("?"+d,c)},[i,a]);return[a,o]}var sv=0,av=()=>`__${String(++sv)}__`;function iv(){let{router:e}=vm("useSubmit"),{basename:t}=u.useContext(yt),n=ky(),r=e.fetch,a=e.navigate;return u.useCallback(async(i,o={})=>{let{action:l,method:c,encType:d,formData:f,body:m}=Fy(i,t);if(o.navigate===!1){let p=o.fetcherKey||av();await r(p,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:f,body:m,formMethod:o.method||c,formEncType:o.encType||d,flushSync:o.flushSync})}else await a(o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:f,body:m,formMethod:o.method||c,formEncType:o.encType||d,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,a,t,n])}function ov(e,{relative:t}={}){let{basename:n}=u.useContext(yt),r=u.useContext(Lt);Ne(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),i={...ks(e||".",{relative:t})},o=vt();if(e==null){i.search=o.search;let l=new URLSearchParams(i.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();i.search=f?`?${f}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(i.pathname=i.pathname==="/"?n:Ut([n,i.pathname])),gs(i)}function lv(e,{relative:t}={}){let n=u.useContext(lm);Ne(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=vm("useViewTransitionState"),a=ks(e,{relative:t});if(!n.isTransitioning)return!1;let i=Zt(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Zt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return za(a.pathname,o)!=null||za(a.pathname,i)!=null}const _n="owner";function cv(e){const t=e||_n;return t===_n?[_n]:[t,_n]}function uv(e){const t=new Map;for(const n of e)for(const r of n)t.has(r.id)||t.set(r.id,r);return[...t.values()].sort((n,r)=>r.createdAt-n.createdAt)}function dv(e,t){const n=t||_n,r=(e==null?void 0:e.pendingDomains)??[];return r.includes(n)?n:r.includes(_n)?_n:n}class xm extends Error{constructor(n){super("different_account");Nr(this,"summary");this.name="DifferentAccountError",this.summary=n}}function fv(e){const t=e==null?void 0:e.pubkeys;return!t||typeof t!="object"||Array.isArray(t)?[]:Object.entries(t).filter(n=>typeof n[1]=="string"&&n[1].length>0).map(([n,r])=>({userId:n,publicKey:r}))}class mv{constructor(){Nr(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 i=await r.json().catch(()=>({}));if(i!=null&&i.wouldWipe)throw new xm(i.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!r.ok){const i=await r.json().catch(()=>({error:"Invalid API key"}));throw new Error(i.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(i=>{var o,l;return{authorization_id:i.authorization_id,profile_id:i.profileId,path:i.path,title:i.title??null,sp_status:i.status??null,frame:i.bounds??i.frame??{},required_domains:i.requiredDomains??[],attested_domains:i.attestedDomains??[],missing_domains:(i.requiredDomains??[]).filter(c=>!(i.attestedDomains??[]).includes(c)),deferred_commitment_domains:i.deferredCommitmentDomains??[],approvers_frozen:i.approversFrozen??[],above_cap:i.aboveCap??!1,created_at:i.createdAt?new Date(i.createdAt*1e3).toISOString():"",earliest_expiry:(o=i.attestations)!=null&&o.length?new Date(Math.min(...i.attestations.map(c=>c.expiresAt))*1e3).toISOString():null,remaining_seconds:(l=i.attestations)!=null&&l.length?Math.max(0,Math.min(...i.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()}`:"",a=await this.fetch(`/denials${r}`);if(!a.ok)throw new Error(`Failed to fetch denials: ${a.status}`);return a.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(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);return(await a.json()).receipts??[]}async fetchEvidenceBundle(){var a;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=((a=/filename="([^"]+)"/.exec(t.headers.get("content-disposition")??""))==null?void 0:a[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 getReport(){const t=await this.fetch("/api/report");if(!t.ok){const n=await t.json().catch(()=>({error:`Report unavailable (${t.status})`}));throw new Error(n.error??`Report unavailable (${t.status})`)}return t.json()}async saveReport(t){const n=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:t})});if(!n.ok){const r=await n.json().catch(()=>({error:`Save failed (${n.status})`}));throw new Error(r.error??`Save failed (${n.status})`)}return n.json()}async recheckReport(){const t=await this.fetch("/api/report/recheck",{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({error:`Recheck failed (${t.status})`}));throw new Error(n.error??`Recheck failed (${t.status})`)}return t.json()}async exportReportWithProof(){var a;const t=await this.fetch("/api/report/export");if(!t.ok){const i=await t.json().catch(()=>({error:`Export failed (${t.status})`}));throw new Error(i.error??`Export failed (${t.status})`)}const n=await t.text(),r=((a=/filename="([^"]+)"/.exec(t.headers.get("content-disposition")??""))==null?void 0:a[1])??"suveren-report.html";return{html:n,filename:r}}async revokeAttestation(t,n){const r=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/revoke`,{method:"POST",body:JSON.stringify({reason:n??"Revoked by user"})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to revoke"}));throw new Error(a.error||`Revoke failed: ${r.status}`)}}async getAttestations(t){const n=await this.fetch(`/api/attestations?authorization_id=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch attestations: ${n.status}`);return n.json()}async getGroupById(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch group: ${n.status}`);return n.json()}async createGroup(t){const n=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:t})});if(!n.ok){const i=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||`Create group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:!0}}async joinGroup(t){const n=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:t})});if(!n.ok){const i=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||`Join group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:a.isAdmin||!1}}async inviteToGroup(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/invite`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Invite failed: ${n.status}`)}return n.json()}async getMyTeam(){const t=await this.fetch("/api/groups/me");if(!t.ok)return null;const n=await t.json();return n.group?{group:n.group,membership:n.membership}:null}async listUsers(){const t=await this.fetch("/api/users");return t.ok?(await t.json()).users??[]:[]}async setPubkey(t){const n=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(r.error||`setPubkey failed: ${n.status}`)}}async getPubkey(t){const n=await this.fetch(`/api/users/${encodeURIComponent(t)}/pubkey`);return n.status===404||!n.ok?null:(await n.json()).pubkey??null}async leaveTeam(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/leave`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to leave team"}));throw new Error(r.error||`Leave failed: ${n.status}`)}}async getVaultStatus(){const t=await this.fetch("/vault/status");if(!t.ok)throw new Error(`Failed to fetch vault status: ${t.status}`);return t.json()}async 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 getArchivedMandates(){const t=await this.fetch("/api/archived-mandates");if(!t.ok)throw new Error(`Failed to load archived mandates: ${t.status}`);return(await t.json()).archived}async setMandateArchived(t,n){const r=await this.fetch(`/api/archived-mandates/${encodeURIComponent(t)}`,{method:n?"PUT":"DELETE"});if(!r.ok)throw new Error(`Failed to ${n?"archive":"unarchive"} mandate: ${r.status}`);return(await r.json()).archived}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 a=await r.json().catch(()=>({error:`Discovery failed: ${r.status}`}));throw new Error(a.error)}return r.json()}async activateIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}/activate`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`Failed: ${n.status}`)}return n.json()}async removeMcpIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`Failed to remove integration: ${n.status}`)}async 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 a=await r.json().catch(()=>({error:`HTTP ${r.status}`}));throw new Error(a.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 a=await r.json();return(a==null?void 0:a.config)??null}async setTeamProfileConfig(t,n,r){const a=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(i.error||`setTeamProfileConfig failed: ${a.status}`)}}async encryptIntent(t,n){const r=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:t,recipients:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Encryption failed"}));throw new Error(a.error||`encryptIntent failed: ${r.status}`)}return r.json()}async getToolDisplay(){const t=await this.fetch("/tool-display");if(!t.ok)return{};const n=await t.json();return(n==null?void 0:n.tools)??{}}async getApproversPubkeys(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}/approvers/pubkeys`);return r.ok?fv(await r.json()):[]}async deleteTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"DELETE"});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(a.error||`deleteTeamProfileConfig failed: ${r.status}`)}}async getIdentityDisclosure(){const t=await this.fetch("/api/users/me/identity-disclosure");if(!t.ok)throw new Error(`Failed to read identity setting: ${t.status}`);return t.json()}async setIdentityDisclosure(t){const n=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:t})});if(!n.ok)throw new Error(`Failed to save identity setting: ${n.status}`);return n.json()}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 getMyProposals(t){const n=await Promise.all(cv(t).map(r=>this.getProposals(r)));return uv(n)}async resolveProposal(t,n,r){const a=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/resolve`,{method:"POST",body:JSON.stringify({action:n,domain:r})});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed"}));throw new Error(i.error||`Failed: ${a.status}`)}return a.json()}async getProposalsForApprover(){const t=await this.fetch("/api/proposals?approver=me");if(!t.ok)throw new Error(`Failed to fetch approver proposals: ${t.status}`);return(await t.json()).proposals??[]}async approveProposal(t){const n=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/approve`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`approveProposal failed: ${n.status}`)}return n.json()}async rejectProposal(t,n){const r=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/reject`,{method:"POST",body:JSON.stringify({reason:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`rejectProposal failed: ${r.status}`)}return r.json()}async getAttestationIntent(t){const n=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/intent`);return n.status===404||n.status===403||!n.ok?null:n.json()}async decryptIntent(t){const n=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const a=await n.json().catch(()=>({error:"Decryption failed"}));throw new Error(a.error||`decryptIntent failed: ${n.status}`)}return(await n.json()).intent}async storeApprovedIntent(t,n){const r=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:t,intent:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`storeApprovedIntent failed: ${r.status}`)}}async listTeamAuthorizations(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/attestations`);if(!n.ok)throw new Error(`Failed to fetch team authorizations: ${n.status}`);return((await n.json()).items??[]).map(a=>{var l,c;const i=a.owner??{userId:""};return{authorization_id:a.authorization_id??a.authorizationId,profile_id:a.profileId??a.profile_id,path:a.path??"",title:a.title??null,sp_status:a.status??a.sp_status??null,frame:a.bounds??a.frame??{},required_domains:a.requiredDomains??a.required_domains??[],attested_domains:a.attestedDomains??a.attested_domains??[],missing_domains:(a.requiredDomains??a.required_domains??[]).filter(d=>!(a.attestedDomains??a.attested_domains??[]).includes(d)),deferred_commitment_domains:a.deferredCommitmentDomains??a.deferred_commitment_domains??[],approvers_frozen:a.approversFrozen??a.approvers_frozen??[],above_cap:a.aboveCap??a.above_cap??!1,created_at:a.createdAt?new Date(a.createdAt*1e3).toISOString():a.created_at??"",earliest_expiry:(l=a.attestations)!=null&&l.length?new Date(Math.min(...a.attestations.map(d=>d.expiresAt))*1e3).toISOString():null,remaining_seconds:(c=a.attestations)!=null&&c.length?Math.max(0,Math.min(...a.attestations.map(d=>d.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:i}})}async listTeamReceipts(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts`);if(!n.ok)throw new Error(`Failed to fetch team receipts: ${n.status}`);return(await n.json()).receipts??[]}async getMyReceiptsPage(t){const n=new URLSearchParams;t!=null&&t.before&&n.set("before",t.before),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);const i=await a.json();return{receipts:i.receipts??[],nextBefore:i.nextBefore??null}}async listTeamReceiptsPage(t,n){const r=new URLSearchParams;n!=null&&n.before&&r.set("before",n.before),n!=null&&n.profile&&r.set("profile",n.profile),n!=null&&n.limit&&r.set("limit",String(n.limit));const a=r.toString(),i=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts${a?"?"+a:""}`);if(!i.ok)throw new Error(`Failed to fetch team receipts: ${i.status}`);const o=await i.json();return{receipts:o.receipts??[],nextBefore:o.nextBefore??null}}async getThread(t){const n=t.sinceDays??7,r=t.status??"pending",a=await this.getMyProposals(t.domain);let i=[];if(r==="all"){const o=[],l=new Date;for(let d=0;d<n;d++){const f=new Date(l);f.setUTCDate(l.getUTCDate()-d),o.push(f.toISOString().slice(0,10))}i=(await Promise.all(o.map(d=>this.getMyReceipts({date:d,profile:t.profile})))).flat()}return{proposals:a,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 getAsPairing(){const t=await this.fetch("/as-pairing");if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}async getSkippedCommitments(){const t=await this.fetch("/skipped-commitments");if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}async getGateContent(t){const n=await this.fetch(`/gate-content?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch gate content: ${n.status}`);return(await n.json()).entry??null}async resyncGates(){const t=await this.fetch("/resync-gates",{method:"POST"});if(!t.ok)throw new Error(`Failed to resync gates: ${t.status}`)}async getEnrichedAuthorizations(){const t=await this.fetch("/active-authorizations");if(!t.ok)throw new Error(`Failed to fetch authorizations: ${t.status}`);return(await t.json()).authorizations??[]}async pushGateContent(t){const n=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(r.error||`Push gate content failed: ${n.status}`)}}async getAgentContext(){const t=await this.fetch("/agent-brief/context");if(!t.ok)throw new Error(`Failed to fetch agent context: ${t.status}`);return(await t.json()).content}async saveAgentContext(t){const n=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(r.error||`Save failed: ${n.status}`)}}async aiChat(t){const n=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI chat failed"}))).error||`Chat failed: ${n.status}`}}async getAIPrompts(){const t=await this.fetch("/ai-prompts");if(!t.ok)throw new Error(`Failed to load AI prompts: ${t.status}`);return t.json()}async setAIPrompt(t,n){const r=await this.fetch(`/ai-prompts/${t}`,{method:"PUT",body:JSON.stringify({value:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Save failed"}));throw new Error(a.error||`Save failed: ${r.status}`)}}}const T=new mv,wm=u.createContext(null);function pv({children:e}){const[t,n]=u.useState(null),[r,a]=u.useState("personal"),[i,o]=u.useState(null),[l,c]=u.useState(""),[d,f]=u.useState(null),[m,p]=u.useState(null),[x,w]=u.useState(!1),[v,S]=u.useState(""),g=u.useRef(!1),h=u.useRef(null),y=u.useCallback(async()=>{if(g.current)try{const E=await T.getMyTeam();if(E){const{group:A,membership:D}=E;f(A),p(D),a("team"),o(A);const z=h.current??D.domains[0]??"owner";c(z)}else f(null),p(null),a("personal")}catch{}},[]);u.useEffect(()=>{const E=()=>{document.visibilityState==="visible"&&y()};return document.addEventListener("visibilitychange",E),()=>document.removeEventListener("visibilitychange",E)},[y]),u.useEffect(()=>{fetch("/health").then(E=>E.json()).then(E=>{var A;((A=E.session)==null?void 0:A.lockedReason)==="as-url-changed"&&S(`Authority Server changed to ${E.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const j=u.useCallback(async(E,A={})=>{w(!0),S("");try{T.setApiKey(E),g.current=!0;const D=await T.login(E,A);n(D),h.current=D.id;const z=await T.getGroups(),K=z.find($=>$.isPersonal)??z[0]??null;o(K),c("owner"),await y()}catch(D){throw T.clearApiKey(),g.current=!1,S(D instanceof Error?D.message:"Login failed"),D}finally{w(!1)}},[y]),b=u.useCallback(async()=>{await T.logout(),T.clearApiKey(),g.current=!1,h.current=null,n(null),o(null),c(""),f(null),p(null),a("personal"),S("")},[]),C=u.useCallback(E=>{T.clearApiKey(),g.current=!1,h.current=null,n(null),o(null),c(""),f(null),p(null),a("personal"),S(E??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),N=u.useCallback(()=>S(""),[]),I=u.useCallback((E,A)=>{o(E),c(A)},[]);return s.jsx(wm.Provider,{value:{user:t,mode:r,group:i,domain:l,groupId:(i==null?void 0:i.id)??null,activeTeam:d,activeMembership:m,isLoading:x,error:v,login:j,logout:b,clearError:N,handleSessionLocked:C,activeGroup:i,activeDomain:l,groups:i?[i]:[],setActiveContext:I,refreshGroups:y},children:e})}function Ue(){const e=u.useContext(wm);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const jm=u.createContext(null);function hv({children:e}){const{user:t}=Ue(),n=u.useRef(null),[r,a]=u.useState(!1),i=u.useRef(new Map),o=u.useCallback((l,c)=>{const d=i.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,a(!1));return}if(n.current)return;const l=T.getApiKey();if(!l)return;const c=new EventSource(`/events?key=${encodeURIComponent(l)}`);n.current=c,c.onopen=()=>a(!0),c.onerror=()=>a(!1);const d=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected","session-locked"];for(const f of d)c.addEventListener(f,m=>{let p;try{p=JSON.parse(m.data)}catch{p=null}const x=i.current.get(f);if(x)for(const w of x)try{w(p)}catch(v){console.error(`[EventSource] handler for "${f}" threw:`,v)}});return()=>{c.close(),n.current=null,a(!1)}},[t]),s.jsx(jm.Provider,{value:{connected:r,addListener:o},children:e})}function he(e,t){const n=u.useContext(jm);if(!n)return;const{addListener:r}=n;u.useEffect(()=>r(e,t),[e,t,r])}const qr="suveren-theme",gu="hap-theme";function Hs(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(gu);t!==null&&localStorage.getItem(qr)===null&&localStorage.setItem(qr,t),t!==null&&localStorage.removeItem(gu)})();function Sm(){const[e,t]=u.useState(()=>{const i=localStorage.getItem(qr);return i==="light"||i==="dark"?i:"system"}),[n,r]=u.useState(()=>Hs(e));u.useEffect(()=>{const i=document.documentElement,o=Hs(e);i.setAttribute("data-theme",o),e==="system"?localStorage.removeItem(qr):localStorage.setItem(qr,e),r(Hs(e))},[e]),u.useEffect(()=>{if(e!=="system")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>r(Hs("system"));return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[e]);const a=u.useCallback(()=>{t(i=>i==="system"?"light":i==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:n,toggle:a}}const gv=5*60*1e3,yv=2e3;function Kl(){const[e,t]=u.useState(!1),[n,r]=u.useState("docker"),[a,i]=u.useState(""),[o,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 v=!1;const S=(y=!1)=>{fetch(y?"/health?refresh=1":"/health").then(j=>j.json()).then(j=>{v||(j.installMethod&&r(j.installMethod),typeof j.latestVersion<"u"&&l(j.latestVersion),j.updateAvailable&&t(!0),j.version&&(i(j.version),w.current===null?w.current=j.version:j.version!==w.current&&j.version!=="dev"&&d(!0)))}).catch(()=>{})};S(!0);const g=setInterval(()=>S(!1),p?yv:gv),h=()=>{document.visibilityState==="visible"&&S(!1)};return document.addEventListener("visibilitychange",h),window.addEventListener("focus",h),()=>{v=!0,clearInterval(g),document.removeEventListener("visibilitychange",h),window.removeEventListener("focus",h)}},[p]),{updateAvailable:e&&!f,installMethod:n,version:a,latestVersion:o,serverRestarted:c,startFastPolling:()=>x(!0),dismiss:()=>m(!0)}}function vv({size:e=20}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[s.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),s.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function xv(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const yu={system:"◑",light:"☀",dark:"☾"};function Yl({onMenuToggle:e}){const{user:t,logout:n}=Ue(),{theme:r,toggle:a}=Sm(),{version:i,updateAvailable:o,latestVersion:l}=Kl(),c=xv(i);return s.jsx("nav",{className:"top-nav",children:s.jsxs("div",{className:"top-nav-inner",children:[s.jsxs("div",{className:"logo-group",children:[s.jsx(vv,{size:20}),s.jsx("span",{className:"logo",children:"Suveren"}),s.jsx("span",{className:"version-badge",children:"Local Gateway"}),c&&s.jsxs("span",{className:"gw-version",title:o&&l?`Running v${c} — v${l} is available`:"Running gateway version","data-stale":o?"true":void 0,children:["v",c,o&&l?` → ${l}`:""]})]}),s.jsx("div",{className:"nav-spacer"}),s.jsx("div",{className:"nav-actions nav-actions-desktop",children:t?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"user-chip",children:s.jsx("strong",{children:t.name})}),s.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:yu[r]}),s.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):s.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:yu[r]})}),t&&e&&s.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function Ql(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 km(e){return e==="expired"||e==="revoked"}function bm(e,t){var n;return!!((n=t==null?void 0:t.archivedSet)!=null&&n.has(e.authorization_id))&&km(Ql(e,t))}function $a(e,t){return bm(e,t)?"archived":Ql(e,t)}function Nm(e,t){const n={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const r of e)n[$a(r,t)].push(r);return n}function wv(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 At(e,t,n){const r=u.useRef(e);r.current=e,u.useEffect(()=>{let a=null;const i=()=>typeof document>"u"?!0:document.visibilityState==="visible",o=()=>{i()&&r.current()},l=()=>{a===null&&(a=setInterval(o,t))},c=()=>{a!==null&&(clearInterval(a),a=null)},d=()=>{i()?(r.current(),l()):c()};return i()&&(r.current(),l()),document.addEventListener("visibilitychange",d),()=>{c(),document.removeEventListener("visibilitychange",d)}},[t,n])}const Cm=u.createContext(null),jv=3e4,Sv=5e3,kv=3e5;function bv(e,t,n){return t===0?"loading":e!=null&&e.running?"running":e!=null&&e.paused?"paused":e!=null&&e.error?"error":e&&n?"starting":"not-running"}function Nv({children:e}){const[t,n]=u.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),r=u.useRef(null),a=u.useCallback(async()=>{let d=!1;const[f,m]=await Promise.all([T.getIntegrationManifests().catch(()=>(d=!0,{manifests:[]})),T.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 T.getOAuthHealth(w.id)]));n(w=>({...w,authHealth:Object.fromEntries(x)}))}},[]),i=t.fetchCount>0&&t.manifests.some(d=>{const f=t.integrations.find(m=>m.id===d.id);return f&&!f.running&&!f.paused});he("integration-changed",a),At(a,i?Sv:kv);const o=u.useMemo(()=>{const d=new Map(t.integrations.map(p=>[p.id,p])),f=Date.now();i&&r.current===null?r.current=f:i||(r.current=null);const m=r.current!==null&&f-r.current<jv;return t.manifests.map(p=>{const x=d.get(p.id),w=bv(x,t.fetchCount,m),v=t.authHealth[p.id];return{id:p.id,manifest:p,integration:x,state:w,authStatus:v==null?void 0:v.status,authAccount:v==null?void 0:v.account,authError:v==null?void 0:v.error}})},[t,i]),l=u.useMemo(()=>o.filter(d=>d.state==="not-running"||d.state==="error"||d.authStatus==="failed").length,[o]),c={loading:t.fetchCount===0,mcpServerUp:t.mcpServerUp,manifestsError:t.manifestsError,entries:o,attentionCount:l,activeSessions:t.activeSessions,refresh:a};return s.jsx(Cm.Provider,{value:c,children:e})}function Jl(){const e=u.useContext(Cm);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const Cv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/mandates",icon:"☰",label:"Mandates",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant"}];function Ev(){const{activeDomain:e}=Ue(),[t,n]=u.useState({}),r=u.useCallback(async()=>{try{const[a,i,o,l,c,d]=await Promise.all([T.getCredential("ai-config").catch(()=>null),T.getMyAttestations().catch(()=>null),T.getMyProposals(e).catch(()=>null),T.getProposalsForApprover().catch(()=>null),T.getAgentContext().catch(()=>""),T.getArchivedMandates().catch(()=>[])]),f={};if(a&&!a.configured&&(f.assistant=1),i){const w=Nm(i,{archivedSet:new Set(d)}).expired.length;w>0&&(f.authorizations=w)}const m=(o==null?void 0:o.length)??0,p=(l==null?void 0:l.length)??0,x=m+p;x>0&&(f.proposals=x),(!c||!c.trim())&&(f.brief=1),n(f)}catch{}},[e]);return he("attestation-changed",r),he("proposal-added",r),he("proposal-resolved",r),he("proposal-approved",r),he("proposal-rejected",r),he("team-membership-changed",r),u.useEffect(()=>(window.addEventListener("suveren:archived-changed",r),()=>window.removeEventListener("suveren:archived-changed",r)),[r]),At(r,3e5,e),t}const Tv={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},Iv={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 Rv(){const{mode:e,group:t,domain:n,activeTeam:r}=Ue(),a=Ev(),{attentionCount:i}=Jl(),o={...a};i>0&&(o.integrations=i);const l=Cv.filter(p=>!p.teamOnly||e==="team"),c=u.useRef(null),[d,f]=u.useState(null),m=vt();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]),s.jsxs("div",{className:"sidebar",children:[s.jsx("ul",{className:"sidebar-nav",children:l.map(p=>{const x=p.statusKey?o[p.statusKey]:0;return s.jsx("li",{children:s.jsxs(Vl,{to:p.to,end:p.to==="/",className:({isActive:w})=>`sidebar-item${w?" active":""}`,children:[s.jsx("span",{className:"icon",children:p.icon}),p.label,x?s.jsx("span",{style:Tv,children:x}):null]})},p.to)})}),s.jsxs("div",{className:"sidebar-context",children:[s.jsx("div",{className:"ctx-label",children:"Active context"}),s.jsx("div",{className:"ctx-value",children:e==="personal"?"personal":t?`${t.name} / ${n}`:n})]}),d&&s.jsx("div",{style:Iv,role:"status","aria-live":"polite",children:d})]})}const Mi="suveren:updatedTo";function Pv(e){return e==="managed"||e==="msi"?null: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"}const Av="Updates for this gateway come from your company's IT — no action needed here.";function _v(e){return e==="managed"?"update-banner is-managed":"update-banner"}const zv="Download the new installer and run it. Your settings and mandates stay.";function $v(e){const t="https://github.com/suverenai/suveren-gateway/releases";return e?`${t}/tag/v${e}`:`${t}/latest`}function Lv(){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 Em(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:a,startFastPolling:i,dismiss:o}=Kl(),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[m,p]=u.useState(()=>{try{const y=sessionStorage.getItem(Mi);if(y)return sessionStorage.removeItem(Mi),y}catch{}return null}),x=Pv(t),w=u.useRef(null),v=y=>{try{sessionStorage.setItem(Mi,y||r||"✓")}catch{}window.location.reload()};u.useEffect(()=>{if(!m)return;const y=setTimeout(()=>p(null),6e3);return()=>clearTimeout(y)},[m]),u.useEffect(()=>{if(!l||!a)return;const y=()=>Lv()?!1:(v(n),!0);if(y())return;const j=setInterval(y,1500);return()=>clearInterval(j)},[l,a,n]),u.useEffect(()=>(document.body.classList.toggle("is-updating",l),()=>document.body.classList.remove("is-updating")),[l]);const S=e&&!l&&!m||!!m&&!l;u.useEffect(()=>{if(!S){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const y=()=>{var C;const b=((C=w.current)==null?void 0:C.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${b}px`)};y();const j=new ResizeObserver(y);return w.current&&j.observe(w.current),()=>{j.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[S]);const g=()=>{c(!0),i()},h=async()=>{if(x)try{await navigator.clipboard.writeText(x),f(!0),setTimeout(()=>f(!1),1800)}catch{}};return s.jsxs(s.Fragment,{children:[m&&!l&&s.jsx("div",{ref:w,className:"update-banner is-live",role:"status","aria-live":"polite",children:s.jsxs("div",{className:"update-banner-row",children:[s.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",m&&m!=="✓"?` — ${m} is live`:" — now live","."]}),s.jsx("button",{className:"update-banner-x",onClick:()=>p(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!m&&s.jsxs("div",{ref:w,className:_v(t),role:"status","aria-live":"polite",children:[s.jsxs("div",{className:"update-banner-row",children:[s.jsx("span",{className:"update-banner-text",children:t==="msi"&&r?`Update available — version ${r}.`:"Update available."}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[t==="msi"&&s.jsx("a",{className:"btn btn-sm btn-secondary",href:$v(r),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),t!=="managed"&&t!=="msi"&&s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:g,children:"Update"}),s.jsx("button",{className:"update-banner-x",onClick:o,"aria-label":"Dismiss",children:"×"})]})]}),t==="managed"&&s.jsx("p",{className:"update-banner-hint",children:Av}),t==="msi"&&s.jsx("p",{className:"update-banner-hint",children:zv})]}),l&&s.jsx("div",{className:"update-overlay",children:s.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[s.jsx("div",{className:"update-spinner"}),s.jsxs("h2",{children:["Finishing the update","…"]}),s.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",s.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),s.jsxs("div",{className:"update-cmd-row",children:[s.jsx("code",{className:"update-cmd",children:x}),s.jsx("button",{className:"btn btn-sm btn-primary",onClick:h,children:d?"Copied":"Copy"})]}),s.jsxs("div",{className:"update-status",children:[s.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),s.jsxs("div",{className:"update-overlay-actions",children:[s.jsx("button",{className:"btn btn-primary",onClick:()=>v(n),children:"Reload now"}),s.jsx("button",{className:"btn btn-secondary",onClick:()=>c(!1),children:"Cancel"})]})]})})]})}function Tm(){const[e,t]=u.useState(!1);return u.useEffect(()=>{let n=!1;const r=()=>{fetch("/health").then(o=>o.json()).then(o=>{n||t(o.simulation===!0)}).catch(()=>{})};r();const a=setInterval(r,3e4),i=()=>{document.visibilityState==="visible"&&r()};return document.addEventListener("visibilitychange",i),()=>{n=!0,clearInterval(a),document.removeEventListener("visibilitychange",i)}},[]),e}function Im(){const e=Tm(),t=u.useRef(null);return u.useEffect(()=>{if(!e){document.documentElement.style.removeProperty("--sim-banner-h");return}const n=()=>{var i;const a=((i=t.current)==null?void 0:i.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${a}px`)};n();const r=new ResizeObserver(n);return t.current&&r.observe(t.current),()=>{r.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[e]),e?s.jsx("div",{ref:t,className:"simulation-banner",role:"status","aria-live":"polite",children:s.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const Mv={system:"◑",light:"☀",dark:"☾"},Fv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function Ov({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:a,logout:i}=Ue(),{theme:o,toggle:l}=Sm(),c=vt();return u.useEffect(()=>{t()},[c.pathname]),e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mobile-menu-backdrop",onClick:t}),s.jsxs("div",{className:"mobile-menu-panel",children:[n&&s.jsxs("div",{className:"mobile-menu-header",children:[s.jsx("strong",{children:n.name}),s.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:r?`${r.name} / ${a}`:a||"personal"})]}),s.jsx("nav",{className:"mobile-menu-nav",children:Fv.map(d=>s.jsxs(Vl,{to:d.to,end:d.to==="/",className:({isActive:f})=>`mobile-menu-item${f?" active":""}`,onClick:t,children:[s.jsx("span",{className:"icon",children:d.icon}),d.label]},d.to))}),s.jsxs("div",{className:"mobile-menu-footer",children:[s.jsxs("button",{className:"mobile-menu-action",onClick:()=>{l()},children:[s.jsx("span",{className:"icon",children:Mv[o]}),"Theme: ",o]}),s.jsx("button",{className:"mobile-menu-action",onClick:()=>{i(),t()},children:"Logout"})]})]})]}):null}function Rm(e){return e.status==="pending"}function Bv(e,t){return e.filter(Rm).length+t.length}const Cn=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],Dv=500;function Pm(){const{user:e,domain:t}=Ue(),[n,r]=u.useState(0),a=u.useRef(null),i=u.useCallback(async()=>{if(!e){r(0);return}try{const[l,c]=await Promise.all([T.getMyProposals(t).catch(()=>[]),T.getProposalsForApprover().catch(()=>[])]);r(Bv(l,c))}catch{r(0)}},[e,t]),o=u.useCallback(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i()},Dv)},[i]);return u.useEffect(()=>(i(),()=>{a.current&&clearTimeout(a.current)}),[i]),he(Cn[0],o),he(Cn[1],o),he(Cn[2],o),he(Cn[3],o),he(Cn[4],o),he(Cn[5],o),he(Cn[6],o),n}const vu="Suveren",Uv="/favicon.svg",Wv="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Vs={x1:74.54,y1:22.74,x2:94.46,y2:34.24},Hv=14,Vv="#f59e0b";function Gv(e){const t=Xl(e);return t>0?`(${t}) ${vu}`:vu}function Xl(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function Kv(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
52
|
-
<path class="m" d="${
|
|
53
|
-
<line class="m" x1="${
|
|
54
|
-
<circle cx="103" cy="103" r="25" fill="${
|
|
55
|
-
<style>.m{stroke:#111111;stroke-width:${
|
|
56
|
-
</svg>`;return`data:image/svg+xml,${encodeURIComponent(e)}`}function Yv(){return document.querySelector('link[rel="icon"]')}function Am(e){const t=Xl(e);document.title=Gv(t),_m(t);const n=Yv();if(!n)return;const r=t>0?Kv():Uv;n.getAttribute("href")!==r&&n.setAttribute("href",r)}function Qv(){Am(0)}function _m(e,t=globalThis.navigator){var a;if(!t||typeof t.setAppBadge!="function")return;const n=Xl(e),r=n>0?t.setAppBadge(n):t.clearAppBadge?t.clearAppBadge():t.setAppBadge(0);(a=r==null?void 0:r.catch)==null||a.call(r,()=>{})}function Jv(){const e=Pm();return u.useEffect(()=>{Am(e)},[e]),u.useEffect(()=>Qv,[]),null}const zm="suveren:dockBadgePrompt";function Xv(){var r;if(typeof window>"u"||!("Notification"in window)||!("setAppBadge"in navigator)||!(((r=window.matchMedia)==null?void 0:r.call(window,"(display-mode: standalone)").matches)||navigator.standalone===!0))return!1;const t=navigator.userAgent;if(!(/Safari\//.test(t)&&!/Chrome\/|Chromium\/|Edg\//.test(t))||Notification.permission!=="default")return!1;try{if(localStorage.getItem(zm))return!1}catch{}return!0}function qv(){const[e,t]=u.useState(!1),n=Pm();if(u.useEffect(()=>{t(Xv())},[]),!e)return null;const r=()=>{try{localStorage.setItem(zm,"1")}catch{}t(!1)},a=async()=>{try{await Notification.requestPermission()==="granted"&&_m(n)}catch{}r()};return s.jsxs("div",{className:"hint-box",style:{marginBottom:"1rem",alignItems:"center"},children:[s.jsxs("div",{className:"hint-body",children:[s.jsx("div",{className:"hint-head",children:"Show waiting approvals on the Dock icon"}),"Safari needs your permission once. The icon then shows how many approvals are waiting, and nothing else."]}),s.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:a,children:"Allow"}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:r,"aria-label":"Not now",children:"Not now"})]})}function Zv(){const[e,t]=u.useState(!1);return s.jsxs(Nv,{children:[s.jsx(Jv,{}),s.jsx(Yl,{onMenuToggle:()=>t(!e)}),s.jsx(Em,{}),s.jsx(Im,{}),s.jsx(Rv,{}),s.jsx(Ov,{open:e,onClose:()=>t(!1)}),s.jsx("div",{className:"main-content",children:s.jsxs("div",{className:"page-inner",children:[s.jsx(qv,{}),s.jsx(Ey,{})]})})]})}function ex(){const[e,t]=u.useState(""),{login:n,isLoading:r,error:a,clearError:i}=Ue(),[o,l]=u.useState(null),c=async()=>{if(e.trim()){i();try{await n(e)}catch(m){if(m instanceof xm){l(m.summary);return}}}},d=async()=>{l(null),i();try{await n(e,{confirmWipe:!0})}catch{}},f=()=>{l(null)};return s.jsxs(s.Fragment,{children:[s.jsx(Yl,{}),s.jsx(Em,{}),s.jsx(Im,{}),s.jsxs("div",{className:"login-split",children:[s.jsx("div",{className:"login-split-left",children:s.jsxs("div",{style:{maxWidth:"28rem"},children:[s.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."}),s.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 tickets."})]})}),s.jsx("div",{className:"login-split-right",children:s.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[s.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[s.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),s.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage mandates."})]}),a&&s.jsx("div",{className:"error-message",children:a}),s.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[s.jsx("label",{className:"form-label",children:"API Key"}),s.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"}}),s.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),s.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:c,disabled:r,style:{marginBottom:"2rem"},children:r?"Signing in...":"Sign In"}),s.jsx("div",{className:"login-divider",children:"New here?"}),s.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[s.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",s.jsx("br",{}),"then come back to sign in."]}),s.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"})]}),s.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),s.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[s.jsxs(s.Fragment,{children:["Create an account at ",s.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 giving mandates"].map((m,p)=>s.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:p<2?"0.5rem":0},children:[s.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[p+1,"."]}),m]},p))})]})]})})]}),o&&s.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:s.jsxs("div",{className:"card",onClick:m=>m.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[s.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),s.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 ",s.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),s.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[s.jsxs("li",{children:[o.credentialCount," stored service credential",o.credentialCount===1?"":"s",o.credentialIds.length>0&&s.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",o.credentialIds.slice(0,5).join(", "),o.credentialIds.length>5?`, +${o.credentialIds.length-5} more`:"",")"]})]}),s.jsxs("li",{children:[o.serviceCount," configured integration",o.serviceCount===1?"":"s"]}),s.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),s.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),s.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Mandates and tickets on the Authority Server are NOT affected — only this gateway's local state is wiped."}),s.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."}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:f,disabled:r,children:"Cancel"}),s.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 tx(){const{setActiveContext:e}=Ue(),t=tn(),[n,r]=u.useState(""),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(!1),f=async()=>{if(n.trim()){d(!0),l("");try{const p=await T.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(a.trim()){d(!0),l("");try{const p=await T.createGroup(a.trim());e(p,p.myDomains[0]||""),t("/")}catch(p){l(p instanceof Error?p.message:"Failed to create group")}finally{d(!1)}}};return s.jsxs(s.Fragment,{children:[s.jsx(Yl,{}),s.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:s.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[s.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[s.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join Your Team"}),s.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."})]}),o&&s.jsx("div",{className:"error-message",children:o}),s.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[s.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing group"}),s.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),s.jsxs("div",{className:"invite-input-row",children:[s.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}),s.jsx("button",{className:"btn btn-primary",onClick:f,disabled:c,children:"Join"})]})]}),s.jsxs("div",{className:"card",children:[s.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new group"}),s.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members. Assign domains after creation."}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("input",{className:"form-input",placeholder:"Group name (e.g., Acme Corp)",value:a,onChange:p=>i(p.target.value),onKeyDown:p=>p.key==="Enter"&&m(),style:{flex:1},disabled:c}),s.jsx("button",{className:"btn btn-secondary",onClick:m,disabled:c,children:"Create"})]})]})]})})]})}const Oo="suveren-setup-ai-skipped",Bo="suveren-setup-agent-done",Do="suveren-setup-dismissed",nx={"hap-setup-ai-skipped":Oo,"hap-setup-agent-done":Bo,"hap-setup-dismissed":Do};function rx(){for(const[e,t]of Object.entries(nx)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}rx();const Fi={"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:
|
|
51
|
+
Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let f=dt(),h;if(t){let g=typeof t=="string"?br(t):t;Ne(c==="/"||((S=g.pathname)==null?void 0:S.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${g.pathname}" was given in the \`location\` prop.`),h=g}else h=f;let m=h.pathname||"/",x=m;if(c!=="/"){let g=c.replace(/^\//,"").split("/");x="/"+m.replace(/^\//,"").split("/").slice(g.length).join("/")}let w=n&&n.state.matches.length?n.state.matches.map(g=>Object.assign(g,{route:n.manifest[g.route.id]||g.route})):dm(e,{pathname:x});Et(d||w!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),Et(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let v=_y(w&&w.map(g=>Object.assign({},g,{params:Object.assign({},o,g.params),pathname:zt([c,r.encodeLocation?r.encodeLocation(g.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:zt([c,r.encodeLocation?r.encodeLocation(g.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),a,n);return t&&v?u.createElement(ks.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...h},navigationType:"POP"}},v):v}function Iy(){let e=Fy(),t=dy(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=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:i},"ErrorBoundary")," or"," ",u.createElement("code",{style:i},"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:a},n):null,o)}var Ry=u.createElement(Iy,null),Cm=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=ky(e.digest);n&&(e=n)}let t=e!==void 0?u.createElement(Mt.Provider,{value:this.props.routeContext},u.createElement(Gl.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?u.createElement(Py,{error:e},t):t}};Cm.contextType=wm;var Fi=new WeakMap;function Py({children:e,error:t}){let{basename:n,navigator:r}=u.useContext(vt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let a=Sy(t.digest);if(a){let i=Fi.get(t);if(i)throw i;let o=vm(a.location,n),l=o.absoluteURL||o.to;if(Vl(a.location,l,Hl(r),"allow-explicit"),gy(l))throw new Error("Invalid redirect location");if(ym&&!Fi.get(t))if(o.isExternal||a.reloadDocument)window.location.href=l;else{const c=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:a.replace}));throw Fi.set(t,c),c}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${l}`})}}return e}function Ay({routeContext:e,match:t,children:n}){let r=u.useContext(Nr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),u.createElement(Mt.Provider,{value:e},n)}function _y(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,i=r==null?void 0:r.errors;if(i!=null){let f=a.findIndex(h=>h.route.id&&(i==null?void 0:i[h.route.id])!==void 0);Ne(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,f+1))}let o=!1,l=-1;if(n&&r){o=r.renderFallback;for(let f=0;f<a.length;f++){let h=a[f];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(l=f),h.route.id){let{loaderData:m,errors:x}=r,w=h.route.loader&&!m.hasOwnProperty(h.route.id)&&(!x||x[h.route.id]===void 0);if(h.route.lazy||w){n.isStatic&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=n==null?void 0:n.onError,d=r&&c?(f,h)=>{var m,x;c(f,{location:r.location,params:((x=(m=r.matches)==null?void 0:m[0])==null?void 0:x.params)??{},pattern:fy(r.matches),errorInfo:h})}:void 0;return a.reduceRight((f,h,m)=>{let x,w=!1,v=null,S=null;r&&(x=i&&h.route.id?i[h.route.id]:void 0,v=h.route.errorElement||Ry,o&&(l<0&&m===0?(Em("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),w=!0,S=null):l===m&&(w=!0,S=h.route.hydrateFallbackElement||null)));let g=t.concat(a.slice(0,m+1)),p=()=>{let y;return x?y=v:w?y=S:h.route.Component?y=u.createElement(h.route.Component,null):h.route.element?y=h.route.element:y=f,u.createElement(Ay,{match:h,routeContext:{outlet:f,matches:g,isDataRoute:r!=null},children:y})};return r&&(h.route.ErrorBoundary||h.route.errorElement||m===0)?u.createElement(Cm,{location:r.location,revalidation:r.revalidation,component:v,error:x,children:p(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:d}):p()},null)}function Kl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ly(e){let t=u.useContext(Nr);return Ne(t,Kl(e)),t}function zy(e){let t=u.useContext(ri);return Ne(t,Kl(e)),t}function $y(e){let t=u.useContext(Mt);return Ne(t,Kl(e)),t}function Yl(e){let t=$y(e),n=t.matches[t.matches.length-1];return Ne(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function My(){return Yl("useRouteId")}function Fy(){var r;let e=u.useContext(Gl),t=zy("useRouteError"),n=Yl("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function Oy(){let{router:e}=Ly("useNavigate"),t=Yl("useNavigate"),n=u.useRef(!1);return bm(()=>{n.current=!0}),u.useCallback(async(a,i={})=>{Et(n.current,km),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var Su={};function Em(e,t,n){!t&&!Su[e]&&(Su[e]=!0,Et(!1,n))}u.memo(By);function By({routes:e,manifest:t,future:n,state:r,isStatic:a,onError:i}){return Nm(e,void 0,{manifest:t,state:r,isStatic:a,onError:i})}function Vt({to:e,replace:t,state:n,relative:r}){Ne(Cr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a,navigator:i}=u.useContext(vt);Et(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:o}=u.useContext(Mt),{pathname:l}=dt(),c=tn(),d=ni(e,Wl(o),l,r==="path");Vl(typeof e=="string"?e:Un(e),i.createHref(d),Hl(i),"reject");let f=JSON.stringify(d);return u.useEffect(()=>{c(JSON.parse(f),{replace:t,state:n,relative:r})},[c,f,r,t,n]),null}function Dy(e){return Ey(e.context)}function je(e){Ne(!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 Uy({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:i=!1,useTransitions:o}){Ne(!Cr(),"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:a,static:i,useTransitions:o,future:{}}),[l,a,i,o]);typeof n=="string"&&(n=br(n));let{pathname:d="/",search:f="",hash:h="",state:m=null,key:x="default",mask:w}=n,v=u.useMemo(()=>{let S=Zt(d,l);return S==null?null:{location:{pathname:S,search:f,hash:h,state:m,key:x,mask:w},navigationType:r}},[l,d,f,h,m,x,r,w]);return Et(v!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${h}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:u.createElement(vt.Provider,{value:c},u.createElement(ks.Provider,{children:t,value:v}))}function Wy({children:e,location:t}){return Ty(Bo(e),t)}function Bo(e,t=[]){let n=[];return u.Children.forEach(e,(r,a)=>{if(!u.isValidElement(r))return;let i=[...t,a];if(r.type===u.Fragment){n.push.apply(n,Bo(r.props.children,i));return}Ne(r.type===je,`[${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>`),Ne(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||i.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&&(o.children=Bo(r.props.children,i)),n.push(o)}),n}var oa="get",la="application/x-www-form-urlencoded";function si(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Hy(e){return si(e)&&e.tagName.toLowerCase()==="button"}function Vy(e){return si(e)&&e.tagName.toLowerCase()==="form"}function Gy(e){return si(e)&&e.tagName.toLowerCase()==="input"}function Ky(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Yy(e,t){return e.button===0&&(!t||t==="_self")&&!Ky(e)}function Do(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function Qy(e,t){let n=Do(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}var Hs=null;function Jy(){if(Hs===null)try{new FormData(document.createElement("form"),0),Hs=!1}catch{Hs=!0}return Hs}var Xy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Oi(e){return e!=null&&!Xy.has(e)?(Et(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${la}"`),null):e}function qy(e,t){let n,r,a,i,o;if(Vy(e)){let l=e.getAttribute("action");r=l?Zt(l,t):null,n=e.getAttribute("method")||oa,a=Oi(e.getAttribute("enctype"))||la,i=new FormData(e)}else if(Hy(e)||Gy(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?Zt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||oa,a=Oi(e.getAttribute("formenctype"))||Oi(l.getAttribute("enctype"))||la,i=new FormData(l,e),!Jy()){let{name:d,type:f,value:h}=e;if(f==="image"){let m=d?`${d}.`:"";i.append(`${m}x`,"0"),i.append(`${m}y`,"0")}else d&&i.append(d,h)}}else{if(si(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=oa,r=null,a=la,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Ql(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Tm(e,t,n,r){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${r}`:a.pathname=`${a.pathname}.${r}`:a.pathname==="/"?a.pathname=`_root.${r}`:t&&Zt(a.pathname,t)==="/"?a.pathname=`${wr(t)}/_root.${r}`:a.pathname=`${wr(a.pathname)}.${r}`,a}async function Zy(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 ev(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 tv(e,t,n){let r=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await Zy(i,n);return o.links?o.links():[]}return[]}));return av(r.flat(1).filter(ev).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function ku(e,t,n,r,a,i){let o=(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 i==="assets"?t.filter((c,d)=>o(c,d)||l(c,d)):i==="data"?t.filter((c,d)=>{var h;let f=r.routes[c.route.id];if(!f||!f.hasLoader)return!1;if(o(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let m=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((h=n[0])==null?void 0:h.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function nv(e,t,{includeHydrateFallback:n}={}){return rv(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function rv(e){return[...new Set(e)]}function sv(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function av(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let i=JSON.stringify(sv(a));return n.has(i)||(n.add(i),r.push({key:i,link:a})),r},[])}function Jl(){let e=u.useContext(Nr);return Ql(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function iv(){let e=u.useContext(ri);return Ql(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Xl=u.createContext(void 0);Xl.displayName="FrameworkContext";function ai(){let e=u.useContext(Xl);return Ql(e,"You must render this element inside a <HydratedRouter> element"),e}function ov(e,t){let n=u.useContext(Xl),[r,a]=u.useState(!1),[i,o]=u.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:h}=t,m=u.useRef(null);u.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let v=g=>{g.forEach(p=>{o(p.isIntersecting)})},S=new IntersectionObserver(v,{threshold:.5});return m.current&&S.observe(m.current),()=>{S.disconnect()}}},[e]),u.useEffect(()=>{if(r){let v=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(v)}}},[r]);let x=()=>{a(!0)},w=()=>{a(!1),o(!1)};return n?e!=="intent"?[i,m,{}]:[i,m,{onFocus:$r(l,x),onBlur:$r(c,w),onMouseEnter:$r(d,x),onMouseLeave:$r(f,w),onTouchStart:$r(h,x)}]:[!1,m,{}]}function $r(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function lv({page:e,...t}){let n=yy(),{nonce:r}=ai(),{router:a}=Jl(),i=u.useMemo(()=>dm(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&r&&(t={...t,nonce:r}),n?u.createElement(uv,{page:e,matches:i,...t}):u.createElement(dv,{page:e,matches:i,...t})):null}function cv(e){let{manifest:t,routeModules:n}=ai(),[r,a]=u.useState([]);return u.useEffect(()=>{let i=!1;return tv(e,t,n).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,n]),r}function uv({page:e,matches:t,...n}){let r=dt(),{future:a}=ai(),{basename:i}=Jl(),o=u.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let l=Tm(e,i,a.v8_trailingSlashAwareDataRequests,"rsc"),c=!1,d=[];for(let f of t)typeof f.route.shouldRevalidate=="function"?c=!0:d.push(f.route.id);return c&&d.length>0&&l.searchParams.set("_routes",d.join(",")),[l.pathname+l.search]},[i,a.v8_trailingSlashAwareDataRequests,e,r,t]);return u.createElement(u.Fragment,null,o.map(l=>u.createElement("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function dv({page:e,matches:t,...n}){let r=dt(),{future:a,manifest:i,routeModules:o}=ai(),{basename:l}=Jl(),{loaderData:c,matches:d}=iv(),f=u.useMemo(()=>ku(e,t,d,i,r,"data"),[e,t,d,i,r]),h=u.useMemo(()=>ku(e,t,d,i,r,"assets"),[e,t,d,i,r]),m=u.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let v=new Set,S=!1;if(t.forEach(p=>{var j;let y=i.routes[p.route.id];!y||!y.hasLoader||(!f.some(b=>b.route.id===p.route.id)&&p.route.id in c&&((j=o[p.route.id])!=null&&j.shouldRevalidate)||y.hasClientLoader?S=!0:v.add(p.route.id))}),v.size===0)return[];let g=Tm(e,l,a.v8_trailingSlashAwareDataRequests,"data");return S&&v.size>0&&g.searchParams.set("_routes",t.filter(p=>v.has(p.route.id)).map(p=>p.route.id).join(",")),[g.pathname+g.search]},[l,a.v8_trailingSlashAwareDataRequests,c,r,i,f,t,e,o]),x=u.useMemo(()=>nv(h,i),[h,i]),w=cv(h);return u.createElement(u.Fragment,null,m.map(v=>u.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),x.map(v=>u.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),w.map(({key:v,link:S})=>u.createElement("link",{key:v,nonce:n.nonce,...S,crossOrigin:S.crossOrigin??n.crossOrigin})))}function fv(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var mv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{mv&&(window.__reactRouterVersion="7.18.4")}catch{}function hv({basename:e,children:t,useTransitions:n,window:r}){let a=u.useRef();a.current==null&&(a.current=Ug({window:r,v5Compat:!0}));let i=a.current,[o,l]=u.useState({action:i.action,location:i.location}),c=u.useCallback(d=>{n===!1?l(d):u.startTransition(()=>l(d))},[n]);return u.useLayoutEffect(()=>i.listen(c),[i,c]),u.createElement(Uy,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:i,useTransitions:n})}var tt=u.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:i,replace:o,mask:l,state:c,target:d,to:f,preventScrollReset:h,viewTransition:m,defaultShouldRevalidate:x,...w},v){let{basename:S,navigator:g,useTransitions:p}=u.useContext(vt),y=typeof f=="string"&&Ul.test(f),j=vm(f,S);f=j.to;let b=by(f,{relative:a}),C=dt(),N=null;if(l){let Q=ni(l,[],C.mask?C.mask.pathname:"/",!0);S!=="/"&&(Q.pathname=Q.pathname==="/"?S:zt([S,Q.pathname])),N=g.createHref(Q)}let[I,E,A]=ov(r,w),D=yv(f,{replace:o,mask:l,state:c,target:d,preventScrollReset:h,relative:a,viewTransition:m,defaultShouldRevalidate:x,useTransitions:p});function L(Q){t&&t(Q),Q.defaultPrevented||D(Q)}let K=!(j.isExternal||i),z=u.createElement("a",{...w,...A,href:(K?N:void 0)||j.absoluteURL||b,onClick:K?L:t,ref:fv(v,E),target:d,"data-discover":!y&&n==="render"?"true":void 0});return I&&!y?u.createElement(u.Fragment,null,z,u.createElement(lv,{page:b})):z});tt.displayName="Link";var ql=u.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...d},f){let h=bs(o,{relative:d.relative}),m=dt(),x=u.useContext(ri),{navigator:w,basename:v}=u.useContext(vt),S=x!=null&&Sv(h)&&l===!0,g=w.encodeLocation?w.encodeLocation(h).pathname:h.pathname,p=m.pathname,y=x&&x.navigation&&x.navigation.location?x.navigation.location.pathname:null;n||(p=p.toLowerCase(),y=y?y.toLowerCase():null,g=g.toLowerCase()),y&&v&&(y=Zt(y,v)||y);const j=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let b=p===g||!a&&p.startsWith(g)&&p.charAt(j)==="/",C=y!=null&&(y===g||!a&&y.startsWith(g)&&y.charAt(g.length)==="/"),N={isActive:b,isPending:C,isTransitioning:S},I=b?t:void 0,E;typeof r=="function"?E=r(N):E=[r,b?"active":null,C?"pending":null,S?"transitioning":null].filter(Boolean).join(" ");let A=typeof i=="function"?i(N):i;return u.createElement(tt,{...d,"aria-current":I,className:E,ref:f,style:A,to:o,viewTransition:l},typeof c=="function"?c(N):c)});ql.displayName="NavLink";var pv=u.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:i,method:o=oa,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:h,defaultShouldRevalidate:m,...x},w)=>{let{useTransitions:v}=u.useContext(vt),S=wv(),g=jv(l,{relative:d}),p=o.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&Ul.test(l),j=b=>{if(c&&c(b),b.defaultPrevented)return;b.preventDefault();let C=b.nativeEvent.submitter,N=(C==null?void 0:C.getAttribute("formmethod"))||o,I=()=>S(C||b.currentTarget,{fetcherKey:t,method:N,navigate:n,replace:a,state:i,relative:d,preventScrollReset:f,viewTransition:h,defaultShouldRevalidate:m});v&&n!==!1?u.startTransition(()=>I()):I()};return u.createElement("form",{ref:w,method:p,action:g,onSubmit:r?c:j,...x,"data-discover":!y&&e==="render"?"true":void 0})});pv.displayName="Form";function gv(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Im(e){let t=u.useContext(Nr);return Ne(t,gv(e)),t}function yv(e,{target:t,replace:n,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let f=tn(),h=dt(),m=bs(e,{relative:o});return u.useCallback(x=>{if(Yy(x,t)){x.preventDefault();let w=n!==void 0?n:Un(h)===Un(m),v=()=>f(e,{replace:w,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});d?u.startTransition(()=>v()):v()}},[h,f,m,n,r,a,t,e,i,o,l,c,d])}function Zl(e){Et(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(Do(e)),n=u.useRef(!1),r=dt(),a=u.useMemo(()=>Qy(r.search,n.current?null:t.current),[r.search]),i=tn(),o=u.useCallback((l,c)=>{const d=Do(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,i("?"+d,c)},[i,a]);return[a,o]}var vv=0,xv=()=>`__${String(++vv)}__`;function wv(){let{router:e}=Im("useSubmit"),{basename:t}=u.useContext(vt),n=My(),r=e.fetch,a=e.navigate;return u.useCallback(async(i,o={})=>{let{action:l,method:c,encType:d,formData:f,body:h}=qy(i,t);if(o.navigate===!1){let m=o.fetcherKey||xv();await r(m,n,o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:f,body:h,formMethod:o.method||c,formEncType:o.encType||d,flushSync:o.flushSync})}else await a(o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:f,body:h,formMethod:o.method||c,formEncType:o.encType||d,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,a,t,n])}function jv(e,{relative:t}={}){let{basename:n}=u.useContext(vt),r=u.useContext(Mt);Ne(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),i={...bs(e||".",{relative:t})},o=dt();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(f=>f==="")){l.delete("index"),c.filter(h=>h).forEach(h=>l.append("index",h));let f=l.toString();i.search=f?`?${f}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(i.pathname=i.pathname==="/"?n:zt([n,i.pathname])),Un(i)}function Sv(e,{relative:t}={}){let n=u.useContext(jm);Ne(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Im("useViewTransitionState"),a=bs(e,{relative:t});if(!n.isTransitioning)return!1;let i=Zt(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Zt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return za(a.pathname,o)!=null||za(a.pathname,i)!=null}const _n="owner";function kv(e){const t=e||_n;return t===_n?[_n]:[t,_n]}function bv(e){const t=new Map;for(const n of e)for(const r of n)t.has(r.id)||t.set(r.id,r);return[...t.values()].sort((n,r)=>r.createdAt-n.createdAt)}function Nv(e,t){const n=t||_n,r=(e==null?void 0:e.pendingDomains)??[];return r.includes(n)?n:r.includes(_n)?_n:n}class Rm extends Error{constructor(n){super("different_account");Er(this,"summary");this.name="DifferentAccountError",this.summary=n}}function Cv(e){const t=e==null?void 0:e.pubkeys;return!t||typeof t!="object"||Array.isArray(t)?[]:Object.entries(t).filter(n=>typeof n[1]=="string"&&n[1].length>0).map(([n,r])=>({userId:n,publicKey:r}))}class Ev{constructor(){Er(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 i=await r.json().catch(()=>({}));if(i!=null&&i.wouldWipe)throw new Rm(i.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!r.ok){const i=await r.json().catch(()=>({error:"Invalid API key"}));throw new Error(i.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(i=>{var o,l;return{authorization_id:i.authorization_id,profile_id:i.profileId,path:i.path,title:i.title??null,sp_status:i.status??null,frame:i.bounds??i.frame??{},required_domains:i.requiredDomains??[],attested_domains:i.attestedDomains??[],missing_domains:(i.requiredDomains??[]).filter(c=>!(i.attestedDomains??[]).includes(c)),deferred_commitment_domains:i.deferredCommitmentDomains??[],approvers_frozen:i.approversFrozen??[],above_cap:i.aboveCap??!1,created_at:i.createdAt?new Date(i.createdAt*1e3).toISOString():"",earliest_expiry:(o=i.attestations)!=null&&o.length?new Date(Math.min(...i.attestations.map(c=>c.expiresAt))*1e3).toISOString():null,remaining_seconds:(l=i.attestations)!=null&&l.length?Math.max(0,Math.min(...i.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()}`:"",a=await this.fetch(`/denials${r}`);if(!a.ok)throw new Error(`Failed to fetch denials: ${a.status}`);return a.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(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);return(await a.json()).receipts??[]}async fetchEvidenceBundle(){var a;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=((a=/filename="([^"]+)"/.exec(t.headers.get("content-disposition")??""))==null?void 0:a[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 getReport(){const t=await this.fetch("/api/report");if(!t.ok){const n=await t.json().catch(()=>({error:`Report unavailable (${t.status})`}));throw new Error(n.error??`Report unavailable (${t.status})`)}return t.json()}async saveReport(t){const n=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:t})});if(!n.ok){const r=await n.json().catch(()=>({error:`Save failed (${n.status})`}));throw new Error(r.error??`Save failed (${n.status})`)}return n.json()}async recheckReport(){const t=await this.fetch("/api/report/recheck",{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({error:`Recheck failed (${t.status})`}));throw new Error(n.error??`Recheck failed (${t.status})`)}return t.json()}async exportReportWithProof(){var a;const t=await this.fetch("/api/report/export");if(!t.ok){const i=await t.json().catch(()=>({error:`Export failed (${t.status})`}));throw new Error(i.error??`Export failed (${t.status})`)}const n=await t.text(),r=((a=/filename="([^"]+)"/.exec(t.headers.get("content-disposition")??""))==null?void 0:a[1])??"suveren-report.html";return{html:n,filename:r}}async revokeAttestation(t,n){const r=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/revoke`,{method:"POST",body:JSON.stringify({reason:n??"Revoked by user"})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to revoke"}));throw new Error(a.error||`Revoke failed: ${r.status}`)}}async getAttestations(t){const n=await this.fetch(`/api/attestations?authorization_id=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch attestations: ${n.status}`);return n.json()}async getGroupById(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch group: ${n.status}`);return n.json()}async createGroup(t){const n=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:t})});if(!n.ok){const i=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||`Create group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:!0}}async joinGroup(t){const n=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:t})});if(!n.ok){const i=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||`Join group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:a.isAdmin||!1}}async inviteToGroup(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/invite`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Invite failed: ${n.status}`)}return n.json()}async getMyTeam(){const t=await this.fetch("/api/groups/me");if(!t.ok)return null;const n=await t.json();return n.group?{group:n.group,membership:n.membership}:null}async listUsers(){const t=await this.fetch("/api/users");return t.ok?(await t.json()).users??[]:[]}async setPubkey(t){const n=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(r.error||`setPubkey failed: ${n.status}`)}}async getPubkey(t){const n=await this.fetch(`/api/users/${encodeURIComponent(t)}/pubkey`);return n.status===404||!n.ok?null:(await n.json()).pubkey??null}async leaveTeam(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/leave`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to leave team"}));throw new Error(r.error||`Leave failed: ${n.status}`)}}async getVaultStatus(){const t=await this.fetch("/vault/status");if(!t.ok)throw new Error(`Failed to fetch vault status: ${t.status}`);return t.json()}async 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 getArchivedMandates(){const t=await this.fetch("/api/archived-mandates");if(!t.ok)throw new Error(`Failed to load archived mandates: ${t.status}`);return(await t.json()).archived}async setMandateArchived(t,n){const r=await this.fetch(`/api/archived-mandates/${encodeURIComponent(t)}`,{method:n?"PUT":"DELETE"});if(!r.ok)throw new Error(`Failed to ${n?"archive":"unarchive"} mandate: ${r.status}`);return(await r.json()).archived}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 a=await r.json().catch(()=>({error:`Discovery failed: ${r.status}`}));throw new Error(a.error)}return r.json()}async activateIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}/activate`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`Failed: ${n.status}`)}return n.json()}async removeMcpIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`Failed to remove integration: ${n.status}`)}async 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 a=await r.json().catch(()=>({error:`HTTP ${r.status}`}));throw new Error(a.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 a=await r.json();return(a==null?void 0:a.config)??null}async setTeamProfileConfig(t,n,r){const a=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(i.error||`setTeamProfileConfig failed: ${a.status}`)}}async encryptIntent(t,n){const r=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:t,recipients:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Encryption failed"}));throw new Error(a.error||`encryptIntent failed: ${r.status}`)}return r.json()}async getToolDisplay(){const t=await this.fetch("/tool-display");if(!t.ok)return{};const n=await t.json();return(n==null?void 0:n.tools)??{}}async getApproversPubkeys(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}/approvers/pubkeys`);return r.ok?Cv(await r.json()):[]}async deleteTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"DELETE"});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(a.error||`deleteTeamProfileConfig failed: ${r.status}`)}}async getIdentityDisclosure(){const t=await this.fetch("/api/users/me/identity-disclosure");if(!t.ok)throw new Error(`Failed to read identity setting: ${t.status}`);return t.json()}async setIdentityDisclosure(t){const n=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:t})});if(!n.ok)throw new Error(`Failed to save identity setting: ${n.status}`);return n.json()}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 getMyProposals(t){const n=await Promise.all(kv(t).map(r=>this.getProposals(r)));return bv(n)}async resolveProposal(t,n,r){const a=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/resolve`,{method:"POST",body:JSON.stringify({action:n,domain:r})});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed"}));throw new Error(i.error||`Failed: ${a.status}`)}return a.json()}async getProposalsForApprover(){const t=await this.fetch("/api/proposals?approver=me");if(!t.ok)throw new Error(`Failed to fetch approver proposals: ${t.status}`);return(await t.json()).proposals??[]}async approveProposal(t){const n=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/approve`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`approveProposal failed: ${n.status}`)}return n.json()}async rejectProposal(t,n){const r=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/reject`,{method:"POST",body:JSON.stringify({reason:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`rejectProposal failed: ${r.status}`)}return r.json()}async getAttestationIntent(t){const n=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/intent`);return n.status===404||n.status===403||!n.ok?null:n.json()}async decryptIntent(t){const n=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const a=await n.json().catch(()=>({error:"Decryption failed"}));throw new Error(a.error||`decryptIntent failed: ${n.status}`)}return(await n.json()).intent}async storeApprovedIntent(t,n){const r=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:t,intent:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`storeApprovedIntent failed: ${r.status}`)}}async listTeamAuthorizations(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/attestations`);if(!n.ok)throw new Error(`Failed to fetch team authorizations: ${n.status}`);return((await n.json()).items??[]).map(a=>{var l,c;const i=a.owner??{userId:""};return{authorization_id:a.authorization_id??a.authorizationId,profile_id:a.profileId??a.profile_id,path:a.path??"",title:a.title??null,sp_status:a.status??a.sp_status??null,frame:a.bounds??a.frame??{},required_domains:a.requiredDomains??a.required_domains??[],attested_domains:a.attestedDomains??a.attested_domains??[],missing_domains:(a.requiredDomains??a.required_domains??[]).filter(d=>!(a.attestedDomains??a.attested_domains??[]).includes(d)),deferred_commitment_domains:a.deferredCommitmentDomains??a.deferred_commitment_domains??[],approvers_frozen:a.approversFrozen??a.approvers_frozen??[],above_cap:a.aboveCap??a.above_cap??!1,created_at:a.createdAt?new Date(a.createdAt*1e3).toISOString():a.created_at??"",earliest_expiry:(l=a.attestations)!=null&&l.length?new Date(Math.min(...a.attestations.map(d=>d.expiresAt))*1e3).toISOString():null,remaining_seconds:(c=a.attestations)!=null&&c.length?Math.max(0,Math.min(...a.attestations.map(d=>d.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:i}})}async listTeamReceipts(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts`);if(!n.ok)throw new Error(`Failed to fetch team receipts: ${n.status}`);return(await n.json()).receipts??[]}async getMyReceiptsPage(t){const n=new URLSearchParams;t!=null&&t.before&&n.set("before",t.before),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);const i=await a.json();return{receipts:i.receipts??[],nextBefore:i.nextBefore??null}}async listTeamReceiptsPage(t,n){const r=new URLSearchParams;n!=null&&n.before&&r.set("before",n.before),n!=null&&n.profile&&r.set("profile",n.profile),n!=null&&n.limit&&r.set("limit",String(n.limit));const a=r.toString(),i=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts${a?"?"+a:""}`);if(!i.ok)throw new Error(`Failed to fetch team receipts: ${i.status}`);const o=await i.json();return{receipts:o.receipts??[],nextBefore:o.nextBefore??null}}async getThread(t){const n=t.sinceDays??7,r=t.status??"pending",a=await this.getMyProposals(t.domain);let i=[];if(r==="all"){const o=[],l=new Date;for(let d=0;d<n;d++){const f=new Date(l);f.setUTCDate(l.getUTCDate()-d),o.push(f.toISOString().slice(0,10))}i=(await Promise.all(o.map(d=>this.getMyReceipts({date:d,profile:t.profile})))).flat()}return{proposals:a,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 getAsPairing(){const t=await this.fetch("/as-pairing");if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}async getSkippedCommitments(){const t=await this.fetch("/skipped-commitments");if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}async getGateContent(t){const n=await this.fetch(`/gate-content?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch gate content: ${n.status}`);return(await n.json()).entry??null}async resyncGates(){const t=await this.fetch("/resync-gates",{method:"POST"});if(!t.ok)throw new Error(`Failed to resync gates: ${t.status}`)}async getEnrichedAuthorizations(){const t=await this.fetch("/active-authorizations");if(!t.ok)throw new Error(`Failed to fetch authorizations: ${t.status}`);return(await t.json()).authorizations??[]}async pushGateContent(t){const n=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(r.error||`Push gate content failed: ${n.status}`)}}async getAgentContext(){const t=await this.fetch("/agent-brief/context");if(!t.ok)throw new Error(`Failed to fetch agent context: ${t.status}`);return(await t.json()).content}async saveAgentContext(t){const n=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(r.error||`Save failed: ${n.status}`)}}async aiChat(t){const n=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI chat failed"}))).error||`Chat failed: ${n.status}`}}async getAIPrompts(){const t=await this.fetch("/ai-prompts");if(!t.ok)throw new Error(`Failed to load AI prompts: ${t.status}`);return t.json()}async setAIPrompt(t,n){const r=await this.fetch(`/ai-prompts/${t}`,{method:"PUT",body:JSON.stringify({value:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Save failed"}));throw new Error(a.error||`Save failed: ${r.status}`)}}}const T=new Ev,Pm=u.createContext(null);function Tv({children:e}){const[t,n]=u.useState(null),[r,a]=u.useState("personal"),[i,o]=u.useState(null),[l,c]=u.useState(""),[d,f]=u.useState(null),[h,m]=u.useState(null),[x,w]=u.useState(!1),[v,S]=u.useState(""),g=u.useRef(!1),p=u.useRef(null),y=u.useCallback(async()=>{if(g.current)try{const E=await T.getMyTeam();if(E){const{group:A,membership:D}=E;f(A),m(D),a("team"),o(A);const L=p.current??D.domains[0]??"owner";c(L)}else f(null),m(null),a("personal")}catch{}},[]);u.useEffect(()=>{const E=()=>{document.visibilityState==="visible"&&y()};return document.addEventListener("visibilitychange",E),()=>document.removeEventListener("visibilitychange",E)},[y]),u.useEffect(()=>{fetch("/health").then(E=>E.json()).then(E=>{var A;((A=E.session)==null?void 0:A.lockedReason)==="as-url-changed"&&S(`Authority Server changed to ${E.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const j=u.useCallback(async(E,A={})=>{w(!0),S("");try{T.setApiKey(E),g.current=!0;const D=await T.login(E,A);n(D),p.current=D.id;const L=await T.getGroups(),K=L.find(z=>z.isPersonal)??L[0]??null;o(K),c("owner"),await y()}catch(D){throw T.clearApiKey(),g.current=!1,S(D instanceof Error?D.message:"Login failed"),D}finally{w(!1)}},[y]),b=u.useCallback(async()=>{await T.logout(),T.clearApiKey(),g.current=!1,p.current=null,n(null),o(null),c(""),f(null),m(null),a("personal"),S("")},[]),C=u.useCallback(E=>{T.clearApiKey(),g.current=!1,p.current=null,n(null),o(null),c(""),f(null),m(null),a("personal"),S(E??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),N=u.useCallback(()=>S(""),[]),I=u.useCallback((E,A)=>{o(E),c(A)},[]);return s.jsx(Pm.Provider,{value:{user:t,mode:r,group:i,domain:l,groupId:(i==null?void 0:i.id)??null,activeTeam:d,activeMembership:h,isLoading:x,error:v,login:j,logout:b,clearError:N,handleSessionLocked:C,activeGroup:i,activeDomain:l,groups:i?[i]:[],setActiveContext:I,refreshGroups:y},children:e})}function Ue(){const e=u.useContext(Pm);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Am=u.createContext(null);function Iv({children:e}){const{user:t}=Ue(),n=u.useRef(null),[r,a]=u.useState(!1),i=u.useRef(new Map),o=u.useCallback((l,c)=>{const d=i.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,a(!1));return}if(n.current)return;const l=T.getApiKey();if(!l)return;const c=new EventSource(`/events?key=${encodeURIComponent(l)}`);n.current=c,c.onopen=()=>a(!0),c.onerror=()=>a(!1);const d=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected","session-locked"];for(const f of d)c.addEventListener(f,h=>{let m;try{m=JSON.parse(h.data)}catch{m=null}const x=i.current.get(f);if(x)for(const w of x)try{w(m)}catch(v){console.error(`[EventSource] handler for "${f}" threw:`,v)}});return()=>{c.close(),n.current=null,a(!1)}},[t]),s.jsx(Am.Provider,{value:{connected:r,addListener:o},children:e})}function pe(e,t){const n=u.useContext(Am);if(!n)return;const{addListener:r}=n;u.useEffect(()=>r(e,t),[e,t,r])}const es="suveren-theme",bu="hap-theme";function Vs(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(bu);t!==null&&localStorage.getItem(es)===null&&localStorage.setItem(es,t),t!==null&&localStorage.removeItem(bu)})();function _m(){const[e,t]=u.useState(()=>{const i=localStorage.getItem(es);return i==="light"||i==="dark"?i:"system"}),[n,r]=u.useState(()=>Vs(e));u.useEffect(()=>{const i=document.documentElement,o=Vs(e);i.setAttribute("data-theme",o),e==="system"?localStorage.removeItem(es):localStorage.setItem(es,e),r(Vs(e))},[e]),u.useEffect(()=>{if(e!=="system")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>r(Vs("system"));return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[e]);const a=u.useCallback(()=>{t(i=>i==="system"?"light":i==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:n,toggle:a}}const Rv=5*60*1e3,Pv=2e3;function ec(){const[e,t]=u.useState(!1),[n,r]=u.useState("docker"),[a,i]=u.useState(""),[o,l]=u.useState(null),[c,d]=u.useState(!1),[f,h]=u.useState(!1),[m,x]=u.useState(!1),w=u.useRef(null);return u.useEffect(()=>{let v=!1;const S=(y=!1)=>{fetch(y?"/health?refresh=1":"/health").then(j=>j.json()).then(j=>{v||(j.installMethod&&r(j.installMethod),typeof j.latestVersion<"u"&&l(j.latestVersion),j.updateAvailable&&t(!0),j.version&&(i(j.version),w.current===null?w.current=j.version:j.version!==w.current&&j.version!=="dev"&&d(!0)))}).catch(()=>{})};S(!0);const g=setInterval(()=>S(!1),m?Pv:Rv),p=()=>{document.visibilityState==="visible"&&S(!1)};return document.addEventListener("visibilitychange",p),window.addEventListener("focus",p),()=>{v=!0,clearInterval(g),document.removeEventListener("visibilitychange",p),window.removeEventListener("focus",p)}},[m]),{updateAvailable:e&&!f,installMethod:n,version:a,latestVersion:o,serverRestarted:c,startFastPolling:()=>x(!0),dismiss:()=>h(!0)}}function Av({size:e=20}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[s.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),s.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function _v(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Nu={system:"◑",light:"☀",dark:"☾"};function tc({onMenuToggle:e}){const{user:t,logout:n}=Ue(),{theme:r,toggle:a}=_m(),{version:i,updateAvailable:o,latestVersion:l}=ec(),c=_v(i);return s.jsx("nav",{className:"top-nav",children:s.jsxs("div",{className:"top-nav-inner",children:[s.jsxs("div",{className:"logo-group",children:[s.jsx(Av,{size:20}),s.jsx("span",{className:"logo",children:"Suveren"}),s.jsx("span",{className:"version-badge",children:"Local Gateway"}),c&&s.jsxs("span",{className:"gw-version",title:o&&l?`Running v${c} — v${l} is available`:"Running gateway version","data-stale":o?"true":void 0,children:["v",c,o&&l?` → ${l}`:""]})]}),s.jsx("div",{className:"nav-spacer"}),s.jsx("div",{className:"nav-actions nav-actions-desktop",children:t?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"user-chip",children:s.jsx("strong",{children:t.name})}),s.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:Nu[r]}),s.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):s.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:Nu[r]})}),t&&e&&s.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function nc(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 Lm(e){return e==="expired"||e==="revoked"}function zm(e,t){var n;return!!((n=t==null?void 0:t.archivedSet)!=null&&n.has(e.authorization_id))&&Lm(nc(e,t))}function $a(e,t){return zm(e,t)?"archived":nc(e,t)}function $m(e,t){const n={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const r of e)n[$a(r,t)].push(r);return n}function Lv(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 At(e,t,n){const r=u.useRef(e);r.current=e,u.useEffect(()=>{let a=null;const i=()=>typeof document>"u"?!0:document.visibilityState==="visible",o=()=>{i()&&r.current()},l=()=>{a===null&&(a=setInterval(o,t))},c=()=>{a!==null&&(clearInterval(a),a=null)},d=()=>{i()?(r.current(),l()):c()};return i()&&(r.current(),l()),document.addEventListener("visibilitychange",d),()=>{c(),document.removeEventListener("visibilitychange",d)}},[t,n])}const Mm=u.createContext(null),zv=3e4,$v=5e3,Mv=3e5;function Fv(e,t,n){return t===0?"loading":e!=null&&e.running?"running":e!=null&&e.paused?"paused":e!=null&&e.error?"error":e&&n?"starting":"not-running"}function Ov({children:e}){const[t,n]=u.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),r=u.useRef(null),a=u.useCallback(async()=>{let d=!1;const[f,h]=await Promise.all([T.getIntegrationManifests().catch(()=>(d=!0,{manifests:[]})),T.getMcpHealth().catch(()=>null)]);n(x=>({...x,manifests:f.manifests,integrations:(h==null?void 0:h.integrations)??x.integrations,activeSessions:(h==null?void 0:h.activeSessions)??x.activeSessions,mcpServerUp:!!h,manifestsError:d,fetchCount:x.fetchCount+1}));const m=f.manifests.filter(x=>x.oauth);if(m.length>0){const x=await Promise.all(m.map(async w=>[w.id,await T.getOAuthHealth(w.id)]));n(w=>({...w,authHealth:Object.fromEntries(x)}))}},[]),i=t.fetchCount>0&&t.manifests.some(d=>{const f=t.integrations.find(h=>h.id===d.id);return f&&!f.running&&!f.paused});pe("integration-changed",a),At(a,i?$v:Mv);const o=u.useMemo(()=>{const d=new Map(t.integrations.map(m=>[m.id,m])),f=Date.now();i&&r.current===null?r.current=f:i||(r.current=null);const h=r.current!==null&&f-r.current<zv;return t.manifests.map(m=>{const x=d.get(m.id),w=Fv(x,t.fetchCount,h),v=t.authHealth[m.id];return{id:m.id,manifest:m,integration:x,state:w,authStatus:v==null?void 0:v.status,authAccount:v==null?void 0:v.account,authError:v==null?void 0:v.error}})},[t,i]),l=u.useMemo(()=>o.filter(d=>d.state==="not-running"||d.state==="error"||d.authStatus==="failed").length,[o]),c={loading:t.fetchCount===0,mcpServerUp:t.mcpServerUp,manifestsError:t.manifestsError,entries:o,attentionCount:l,activeSessions:t.activeSessions,refresh:a};return s.jsx(Mm.Provider,{value:c,children:e})}function rc(){const e=u.useContext(Mm);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const Bv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/mandates",icon:"☰",label:"Mandates",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant"}];function Dv(){const{activeDomain:e}=Ue(),[t,n]=u.useState({}),r=u.useCallback(async()=>{try{const[a,i,o,l,c,d]=await Promise.all([T.getCredential("ai-config").catch(()=>null),T.getMyAttestations().catch(()=>null),T.getMyProposals(e).catch(()=>null),T.getProposalsForApprover().catch(()=>null),T.getAgentContext().catch(()=>""),T.getArchivedMandates().catch(()=>[])]),f={};if(a&&!a.configured&&(f.assistant=1),i){const w=$m(i,{archivedSet:new Set(d)}).expired.length;w>0&&(f.authorizations=w)}const h=(o==null?void 0:o.length)??0,m=(l==null?void 0:l.length)??0,x=h+m;x>0&&(f.proposals=x),(!c||!c.trim())&&(f.brief=1),n(f)}catch{}},[e]);return pe("attestation-changed",r),pe("proposal-added",r),pe("proposal-resolved",r),pe("proposal-approved",r),pe("proposal-rejected",r),pe("team-membership-changed",r),u.useEffect(()=>(window.addEventListener("suveren:archived-changed",r),()=>window.removeEventListener("suveren:archived-changed",r)),[r]),At(r,3e5,e),t}const Uv={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},Wv={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 Hv(){const{mode:e,group:t,domain:n,activeTeam:r}=Ue(),a=Dv(),{attentionCount:i}=rc(),o={...a};i>0&&(o.integrations=i);const l=Bv.filter(m=>!m.teamOnly||e==="team"),c=u.useRef(null),[d,f]=u.useState(null),h=dt();return u.useEffect(()=>{if(c.current===null){c.current=e;return}c.current!==e&&(e==="team"&&r?f(`You are now acting in team context — ${r.name}`):e==="personal"&&f("You have left the team — back to personal context"),c.current=e)},[e,r]),u.useEffect(()=>{f(null)},[h.pathname]),s.jsxs("div",{className:"sidebar",children:[s.jsx("ul",{className:"sidebar-nav",children:l.map(m=>{const x=m.statusKey?o[m.statusKey]:0;return s.jsx("li",{children:s.jsxs(ql,{to:m.to,end:m.to==="/",className:({isActive:w})=>`sidebar-item${w?" active":""}`,children:[s.jsx("span",{className:"icon",children:m.icon}),m.label,x?s.jsx("span",{style:Uv,children:x}):null]})},m.to)})}),s.jsxs("div",{className:"sidebar-context",children:[s.jsx("div",{className:"ctx-label",children:"Active context"}),s.jsx("div",{className:"ctx-value",children:e==="personal"?"personal":t?`${t.name} / ${n}`:n})]}),d&&s.jsx("div",{style:Wv,role:"status","aria-live":"polite",children:d})]})}const Bi="suveren:updatedTo";function Vv(e){return e==="managed"||e==="msi"?null: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"}const Gv="Updates for this gateway come from your company's IT — no action needed here.";function Kv(e){return e==="managed"?"update-banner is-managed":"update-banner"}const Yv="Download the new installer and run it. Your settings and mandates stay.";function Qv(e){const t="https://github.com/suverenai/suveren-gateway/releases";return e?`${t}/tag/v${e}`:`${t}/latest`}function Jv(){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 Fm(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:a,startFastPolling:i,dismiss:o}=ec(),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[h,m]=u.useState(()=>{try{const y=sessionStorage.getItem(Bi);if(y)return sessionStorage.removeItem(Bi),y}catch{}return null}),x=Vv(t),w=u.useRef(null),v=y=>{try{sessionStorage.setItem(Bi,y||r||"✓")}catch{}window.location.reload()};u.useEffect(()=>{if(!h)return;const y=setTimeout(()=>m(null),6e3);return()=>clearTimeout(y)},[h]),u.useEffect(()=>{if(!l||!a)return;const y=()=>Jv()?!1:(v(n),!0);if(y())return;const j=setInterval(y,1500);return()=>clearInterval(j)},[l,a,n]),u.useEffect(()=>(document.body.classList.toggle("is-updating",l),()=>document.body.classList.remove("is-updating")),[l]);const S=e&&!l&&!h||!!h&&!l;u.useEffect(()=>{if(!S){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const y=()=>{var C;const b=((C=w.current)==null?void 0:C.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${b}px`)};y();const j=new ResizeObserver(y);return w.current&&j.observe(w.current),()=>{j.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[S]);const g=()=>{c(!0),i()},p=async()=>{if(x)try{await navigator.clipboard.writeText(x),f(!0),setTimeout(()=>f(!1),1800)}catch{}};return s.jsxs(s.Fragment,{children:[h&&!l&&s.jsx("div",{ref:w,className:"update-banner is-live",role:"status","aria-live":"polite",children:s.jsxs("div",{className:"update-banner-row",children:[s.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",h&&h!=="✓"?` — ${h} is live`:" — now live","."]}),s.jsx("button",{className:"update-banner-x",onClick:()=>m(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!h&&s.jsxs("div",{ref:w,className:Kv(t),role:"status","aria-live":"polite",children:[s.jsxs("div",{className:"update-banner-row",children:[s.jsx("span",{className:"update-banner-text",children:t==="msi"&&r?`Update available — version ${r}.`:"Update available."}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[t==="msi"&&s.jsx("a",{className:"btn btn-sm btn-secondary",href:Qv(r),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),t!=="managed"&&t!=="msi"&&s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:g,children:"Update"}),s.jsx("button",{className:"update-banner-x",onClick:o,"aria-label":"Dismiss",children:"×"})]})]}),t==="managed"&&s.jsx("p",{className:"update-banner-hint",children:Gv}),t==="msi"&&s.jsx("p",{className:"update-banner-hint",children:Yv})]}),l&&s.jsx("div",{className:"update-overlay",children:s.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[s.jsx("div",{className:"update-spinner"}),s.jsxs("h2",{children:["Finishing the update","…"]}),s.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",s.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),s.jsxs("div",{className:"update-cmd-row",children:[s.jsx("code",{className:"update-cmd",children:x}),s.jsx("button",{className:"btn btn-sm btn-primary",onClick:p,children:d?"Copied":"Copy"})]}),s.jsxs("div",{className:"update-status",children:[s.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),s.jsxs("div",{className:"update-overlay-actions",children:[s.jsx("button",{className:"btn btn-primary",onClick:()=>v(n),children:"Reload now"}),s.jsx("button",{className:"btn btn-secondary",onClick:()=>c(!1),children:"Cancel"})]})]})})]})}function Om(){const[e,t]=u.useState(!1);return u.useEffect(()=>{let n=!1;const r=()=>{fetch("/health").then(o=>o.json()).then(o=>{n||t(o.simulation===!0)}).catch(()=>{})};r();const a=setInterval(r,3e4),i=()=>{document.visibilityState==="visible"&&r()};return document.addEventListener("visibilitychange",i),()=>{n=!0,clearInterval(a),document.removeEventListener("visibilitychange",i)}},[]),e}function Bm(){const e=Om(),t=u.useRef(null);return u.useEffect(()=>{if(!e){document.documentElement.style.removeProperty("--sim-banner-h");return}const n=()=>{var i;const a=((i=t.current)==null?void 0:i.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${a}px`)};n();const r=new ResizeObserver(n);return t.current&&r.observe(t.current),()=>{r.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[e]),e?s.jsx("div",{ref:t,className:"simulation-banner",role:"status","aria-live":"polite",children:s.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const Xv={system:"◑",light:"☀",dark:"☾"},qv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function Zv({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:a,logout:i}=Ue(),{theme:o,toggle:l}=_m(),c=dt();return u.useEffect(()=>{t()},[c.pathname]),e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mobile-menu-backdrop",onClick:t}),s.jsxs("div",{className:"mobile-menu-panel",children:[n&&s.jsxs("div",{className:"mobile-menu-header",children:[s.jsx("strong",{children:n.name}),s.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:r?`${r.name} / ${a}`:a||"personal"})]}),s.jsx("nav",{className:"mobile-menu-nav",children:qv.map(d=>s.jsxs(ql,{to:d.to,end:d.to==="/",className:({isActive:f})=>`mobile-menu-item${f?" active":""}`,onClick:t,children:[s.jsx("span",{className:"icon",children:d.icon}),d.label]},d.to))}),s.jsxs("div",{className:"mobile-menu-footer",children:[s.jsxs("button",{className:"mobile-menu-action",onClick:()=>{l()},children:[s.jsx("span",{className:"icon",children:Xv[o]}),"Theme: ",o]}),s.jsx("button",{className:"mobile-menu-action",onClick:()=>{i(),t()},children:"Logout"})]})]})]}):null}function Dm(e){return e.status==="pending"}function ex(e,t){return e.filter(Dm).length+t.length}const Cn=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],tx=500;function Um(){const{user:e,domain:t}=Ue(),[n,r]=u.useState(0),a=u.useRef(null),i=u.useCallback(async()=>{if(!e){r(0);return}try{const[l,c]=await Promise.all([T.getMyProposals(t).catch(()=>[]),T.getProposalsForApprover().catch(()=>[])]);r(ex(l,c))}catch{r(0)}},[e,t]),o=u.useCallback(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i()},tx)},[i]);return u.useEffect(()=>(i(),()=>{a.current&&clearTimeout(a.current)}),[i]),pe(Cn[0],o),pe(Cn[1],o),pe(Cn[2],o),pe(Cn[3],o),pe(Cn[4],o),pe(Cn[5],o),pe(Cn[6],o),n}const Cu="Suveren",nx="/favicon.svg",rx="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Gs={x1:74.54,y1:22.74,x2:94.46,y2:34.24},sx=14,ax="#f59e0b";function ix(e){const t=sc(e);return t>0?`(${t}) ${Cu}`:Cu}function sc(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function ox(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
52
|
+
<path class="m" d="${rx}"/>
|
|
53
|
+
<line class="m" x1="${Gs.x1}" y1="${Gs.y1}" x2="${Gs.x2}" y2="${Gs.y2}"/>
|
|
54
|
+
<circle cx="103" cy="103" r="25" fill="${ax}"/>
|
|
55
|
+
<style>.m{stroke:#111111;stroke-width:${sx};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 lx(){return document.querySelector('link[rel="icon"]')}function Wm(e){const t=sc(e);document.title=ix(t),Hm(t);const n=lx();if(!n)return;const r=t>0?ox():nx;n.getAttribute("href")!==r&&n.setAttribute("href",r)}function cx(){Wm(0)}function Hm(e,t=globalThis.navigator){var a;if(!t||typeof t.setAppBadge!="function")return;const n=sc(e),r=n>0?t.setAppBadge(n):t.clearAppBadge?t.clearAppBadge():t.setAppBadge(0);(a=r==null?void 0:r.catch)==null||a.call(r,()=>{})}function ux(){const e=Um();return u.useEffect(()=>{Wm(e)},[e]),u.useEffect(()=>cx,[]),null}const Vm="suveren:dockBadgePrompt";function dx(){var r;if(typeof window>"u"||!("Notification"in window)||!("setAppBadge"in navigator)||!(((r=window.matchMedia)==null?void 0:r.call(window,"(display-mode: standalone)").matches)||navigator.standalone===!0))return!1;const t=navigator.userAgent;if(!(/Safari\//.test(t)&&!/Chrome\/|Chromium\/|Edg\//.test(t))||Notification.permission!=="default")return!1;try{if(localStorage.getItem(Vm))return!1}catch{}return!0}function fx(){const[e,t]=u.useState(!1),n=Um();if(u.useEffect(()=>{t(dx())},[]),!e)return null;const r=()=>{try{localStorage.setItem(Vm,"1")}catch{}t(!1)},a=async()=>{try{await Notification.requestPermission()==="granted"&&Hm(n)}catch{}r()};return s.jsxs("div",{className:"hint-box",style:{marginBottom:"1rem",alignItems:"center"},children:[s.jsxs("div",{className:"hint-body",children:[s.jsx("div",{className:"hint-head",children:"Show waiting approvals on the Dock icon"}),"Safari needs your permission once. The icon then shows how many approvals are waiting, and nothing else."]}),s.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:a,children:"Allow"}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:r,"aria-label":"Not now",children:"Not now"})]})}function mx(){const[e,t]=u.useState(!1);return s.jsxs(Ov,{children:[s.jsx(ux,{}),s.jsx(tc,{onMenuToggle:()=>t(!e)}),s.jsx(Fm,{}),s.jsx(Bm,{}),s.jsx(Hv,{}),s.jsx(Zv,{open:e,onClose:()=>t(!1)}),s.jsx("div",{className:"main-content",children:s.jsxs("div",{className:"page-inner",children:[s.jsx(fx,{}),s.jsx(Dy,{})]})})]})}function hx(){const[e,t]=u.useState(""),{login:n,isLoading:r,error:a,clearError:i}=Ue(),[o,l]=u.useState(null),c=async()=>{if(e.trim()){i();try{await n(e)}catch(h){if(h instanceof Rm){l(h.summary);return}}}},d=async()=>{l(null),i();try{await n(e,{confirmWipe:!0})}catch{}},f=()=>{l(null)};return s.jsxs(s.Fragment,{children:[s.jsx(tc,{}),s.jsx(Fm,{}),s.jsx(Bm,{}),s.jsxs("div",{className:"login-split",children:[s.jsx("div",{className:"login-split-left",children:s.jsxs("div",{style:{maxWidth:"28rem"},children:[s.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."}),s.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 tickets."})]})}),s.jsx("div",{className:"login-split-right",children:s.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[s.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[s.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),s.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage mandates."})]}),a&&s.jsx("div",{className:"error-message",children:a}),s.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[s.jsx("label",{className:"form-label",children:"API Key"}),s.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:h=>t(h.target.value),onKeyDown:h=>h.key==="Enter"&&c(),disabled:r,style:{padding:"0.75rem"}}),s.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),s.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:c,disabled:r,style:{marginBottom:"2rem"},children:r?"Signing in...":"Sign In"}),s.jsx("div",{className:"login-divider",children:"New here?"}),s.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[s.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",s.jsx("br",{}),"then come back to sign in."]}),s.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"})]}),s.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),s.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[s.jsxs(s.Fragment,{children:["Create an account at ",s.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 giving mandates"].map((h,m)=>s.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:m<2?"0.5rem":0},children:[s.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[m+1,"."]}),h]},m))})]})]})})]}),o&&s.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:s.jsxs("div",{className:"card",onClick:h=>h.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[s.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),s.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 ",s.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),s.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[s.jsxs("li",{children:[o.credentialCount," stored service credential",o.credentialCount===1?"":"s",o.credentialIds.length>0&&s.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",o.credentialIds.slice(0,5).join(", "),o.credentialIds.length>5?`, +${o.credentialIds.length-5} more`:"",")"]})]}),s.jsxs("li",{children:[o.serviceCount," configured integration",o.serviceCount===1?"":"s"]}),s.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),s.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),s.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Mandates and tickets on the Authority Server are NOT affected — only this gateway's local state is wiped."}),s.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."}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:f,disabled:r,children:"Cancel"}),s.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 px(){const{setActiveContext:e}=Ue(),t=tn(),[n,r]=u.useState(""),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(!1),f=async()=>{if(n.trim()){d(!0),l("");try{const m=await T.joinGroup(n.trim());e(m,m.myDomains[0]||""),t("/")}catch(m){l(m instanceof Error?m.message:"Failed to join group")}finally{d(!1)}}},h=async()=>{if(a.trim()){d(!0),l("");try{const m=await T.createGroup(a.trim());e(m,m.myDomains[0]||""),t("/")}catch(m){l(m instanceof Error?m.message:"Failed to create group")}finally{d(!1)}}};return s.jsxs(s.Fragment,{children:[s.jsx(tc,{}),s.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:s.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[s.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[s.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join Your Team"}),s.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."})]}),o&&s.jsx("div",{className:"error-message",children:o}),s.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[s.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing group"}),s.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),s.jsxs("div",{className:"invite-input-row",children:[s.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:n,onChange:m=>r(m.target.value),onKeyDown:m=>m.key==="Enter"&&f(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:c}),s.jsx("button",{className:"btn btn-primary",onClick:f,disabled:c,children:"Join"})]})]}),s.jsxs("div",{className:"card",children:[s.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new group"}),s.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members. Assign domains after creation."}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("input",{className:"form-input",placeholder:"Group name (e.g., Acme Corp)",value:a,onChange:m=>i(m.target.value),onKeyDown:m=>m.key==="Enter"&&h(),style:{flex:1},disabled:c}),s.jsx("button",{className:"btn btn-secondary",onClick:h,disabled:c,children:"Create"})]})]})]})})]})}const Uo="suveren-setup-ai-skipped",Wo="suveren-setup-agent-done",Ho="suveren-setup-dismissed",gx={"hap-setup-ai-skipped":Uo,"hap-setup-agent-done":Wo,"hap-setup-dismissed":Ho};function yx(){for(const[e,t]of Object.entries(gx)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}yx();const Di={"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
57
|
|
|
58
58
|
${JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)}`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
|
|
59
59
|
SSE transport: GET ${e}/sse
|
|
60
|
-
Health check: GET ${e}/health`}};function sx({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:a}){const[i,o]=u.useState(()=>localStorage.getItem(Oo)==="true"),[l,c]=u.useState(()=>localStorage.getItem(Bo)==="true"),[d,f]=u.useState(()=>localStorage.getItem(Do)==="true"),[m,p]=u.useState(null),[x,w]=u.useState("claude-code"),[v,S]=u.useState(!1),g=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":i?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:t?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:n?"done":"pending"},{label:"Connect your agent",status:r||l?"done":"pending"}],h=g.filter(E=>E.status==="done"||E.status==="skipped").length,y=h===g.length,j=u.useCallback(()=>{localStorage.setItem(Oo,"true"),o(!0)},[]),b=u.useCallback(()=>{localStorage.setItem(Bo,"true"),c(!0),p(null)},[]),C=u.useCallback(()=>{localStorage.setItem(Do,"true"),f(!0)},[]),N=u.useCallback(async E=>{try{await navigator.clipboard.writeText(E),S(!0),setTimeout(()=>S(!1),2e3)}catch{}},[]);if(d||y)return null;const I=g.findIndex(E=>E.status==="pending");return s.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[s.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),s.jsx("button",{onClick:C,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:"×"})]}),s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:g.map((E,A)=>{const D=A===I,z=E.status==="done"||E.status==="skipped"?"●":"○",K=E.status==="done"?"var(--success)":E.status==="skipped"?"var(--text-tertiary)":D?"var(--accent)":"var(--text-tertiary)";return s.jsxs("div",{children:[s.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:D?"0.75rem":"0.25rem 0",borderRadius:D?"0.5rem":void 0,background:D?"var(--accent-subtle)":void 0},children:[s.jsx("span",{style:{color:K,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:z}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[E.to&&E.status==="pending"?s.jsx(tt,{to:E.to,style:{fontSize:"0.9rem",fontWeight:D?600:500,color:D?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:E.label}):E.status==="pending"&&A===3?s.jsx("button",{onClick:()=>p(m===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:D?600:500,color:D?"var(--accent)":"var(--text-primary)"},children:E.label}):s.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:E.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:E.label}),E.optional&&E.status==="pending"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),E.status==="skipped"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),E.detail&&E.status==="pending"&&D&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:E.detail})]}),E.optional&&E.status==="pending"&&s.jsx("button",{onClick:j,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),E.to&&E.status==="pending"&&s.jsx(tt,{to:E.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),A===3&&m===3&&s.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[s.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem",color:"var(--text-primary)"},children:"MCP Endpoint"}),s.jsx("div",{style:{fontFamily:"monospace",fontSize:"0.85rem",padding:"0.5rem 0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",marginBottom:"1rem",wordBreak:"break-all"},children:a}),s.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"0.75rem"},children:Object.entries(Fi).map(([$,Q])=>s.jsx("button",{onClick:()=>w($),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:x===$?600:400,background:x===$?"var(--accent-subtle)":"transparent",color:x===$?"var(--accent)":"var(--text-secondary)",border:`1px solid ${x===$?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:Q.label},$))}),s.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:Fi[x].snippet(a)}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>N(Fi[x].snippet(a)),children:v?"Copied":"Copy"}),s.jsx("button",{className:"btn btn-primary btn-sm",onClick:b,children:"Done"})]})]})]},A)})}),s.jsxs("div",{style:{marginTop:"1.25rem"},children:[s.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:s.jsx("div",{style:{height:"100%",width:`${h/g.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),s.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[h," of ",g.length," complete"]})]})]})}function ax(){const[e,t]=u.useState(null);return u.useEffect(()=>{let n=!1;return fetch("/health").then(r=>r.json()).then(r=>{!n&&typeof r.mcpPort=="number"&&t(`http://localhost:${r.mcpPort}`)}).catch(()=>{}),()=>{n=!0}},[]),e}function zn({variant:e="base",style:t,className:n,...r}){const a=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return s.jsx("span",{className:`${a}${n?` ${n}`:""}`,style:t,role:"status","aria-busy":"true","aria-label":r["aria-label"]??"Loading"})}function Oi(){return s.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[s.jsx(zn,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),s.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[s.jsx(zn,{variant:"line",style:{width:"35%"}}),s.jsx(zn,{variant:"line-sm",style:{width:"65%"}})]})]})}const ix={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},$m=e=>ix[e]??e,ox={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:"/mandates"},ungoverned:{chip:"Unconfigured",sev:"act"},query_unsafe:{chip:"Unsafe search",sev:"info"}};function lx(e){return ox[e]??{chip:"Blocked",sev:"info"}}function cx(e){const t=$m(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?s.jsxs(s.Fragment,{children:["Tried to read your ",s.jsx("b",{children:e.target??"restricted"})," calendar"]}):s.jsxs(s.Fragment,{children:["Tried to read a restricted location in ",t]});case"spam":return s.jsxs(s.Fragment,{children:["Tried to open a message in ",s.jsx("b",{children:"spam or trash"})]});case"age":return s.jsxs(s.Fragment,{children:["Tried to read ",t," older than your read window"]});case"unset_age":return s.jsxs(s.Fragment,{children:["Your ",t," has ",s.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return s.jsxs(s.Fragment,{children:["Read access isn't granted on your ",t," mandate"]});case"ungoverned":return s.jsxs(s.Fragment,{children:["A ",t," tool isn't configured for safe reading"]});case"query_unsafe":return s.jsx(s.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return s.jsx(s.Fragment,{children:e.detail})}}function ux(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 xu=5,dx=24*60*60*1e3,la=7;function fx(e,t){const n=t-la*dx;return{recent:e.filter(r=>r.ts>=n),all:e}}function mx(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(!1),o=u.useCallback(()=>{T.getDenials({limit:200}).then(({records:p})=>{t(p),i(!1)}).catch(()=>i(!0))},[]);if(u.useEffect(()=>{o()},[o]),At(o,12e4),a||e===null)return null;const{recent:l,all:c}=fx(e,Date.now()),d=n?c:l.slice(0,xu),f=c.length-l.length,m=(p,x)=>{const w=lx(p.reason);return s.jsxs("div",{className:"rb-row",children:[s.jsx("span",{className:`rb-dot ${w.sev==="act"?"act":w.sev==="info"?"info":""}`,"aria-hidden":"true"}),s.jsxs("div",{className:"rb-body",children:[s.jsx("div",{className:"rb-line",children:cx(p)}),s.jsxs("div",{className:"rb-meta",children:[s.jsx("span",{className:`rb-chip ${w.sev==="act"?"act":w.sev==="warn"?"warn":""}`,children:w.chip}),s.jsx("span",{className:"rb-via",children:$m(p.integrationId)})]}),w.fixTo&&s.jsx(tt,{className:"rb-fix",to:w.fixTo,children:"Set a read window →"})]}),s.jsx("div",{className:"rb-when",children:ux(p.ts,Date.now())})]},`${p.ts}-${x}`)};return s.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[s.jsxs("div",{className:"card-header",children:[s.jsx("h2",{className:"card-title",children:"Recent blocks"}),(n?c.length:l.length)>0&&s.jsx("span",{className:"rb-count",children:n?c.length:l.length})]}),d.length===0?s.jsxs("div",{className:"rb-empty",children:[s.jsx("span",{className:"rb-mark","aria-hidden":"true",children:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6 9 17l-5-5"})})}),s.jsxs("h3",{children:["Nothing blocked in the last ",la," days"]}),s.jsx("p",{children:"Your agent has stayed within every limit you set."}),f>0&&s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!0),children:["Show the last 30 days (",f,")"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"rb-sub",children:[n?"Last 30 days. ":`Last ${la} days. `,"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."]}),s.jsx("div",{className:"rb-rows",children:d.map(m)}),!n&&c.length>d.length&&s.jsx("div",{className:"rb-foot",children:s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!0),children:["View all ",c.length," blocks from the last 30 days"]})}),n&&c.length>Math.min(l.length,xu)&&s.jsx("div",{className:"rb-foot",children:s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!1),children:["Show only the last ",la," days"]})})]})]})}function px(){const[e,t]=u.useState([]);return At(async()=>{try{const{skipped:r}=await T.getSkippedCommitments();t(r)}catch{}},3e4),e.length===0?null:s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px solid var(--warn, #b58900)"},children:[s.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",e.length,")"]}),s.jsx("p",{style:{margin:"0.5rem 0 1rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"These were approved, but this gateway has no local record of asking for them — usually because a different device/installation of yours submitted them, or its local record is gone. Re-run the same request on this gateway to execute it here."}),s.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:e.map(r=>s.jsxs("li",{style:{marginBottom:"0.35rem"},children:[s.jsx("code",{children:r.tool})," ",s.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",r.id,")"]})]},r.id))})]})}function hx(e,t){const n=e.simulation;return n?(((t==null?void 0:t[n.field])??"").trim().toLowerCase()||n.default.trim().toLowerCase())==="simulation":!1}function Uo(e){return!!(e!=null&&e.simulation)}function gx(e){var n;const t=[];for(const r of e)r.state==="error"?t.push({label:"Integration error",detail:(n=r.integration)!=null&&n.error?`${r.manifest.name}: ${r.integration.error}`:`${r.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"}):r.state==="not-running"&&(Uo(r.manifest)?t.push({label:`${r.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--danger)"}):t.push({label:"Integration stopped",detail:`${r.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"}));return t}function yx(e){const t=e.filter(n=>n.state==="paused");return t.length===0?null:{count:t.length,namesText:t.map(n=>n.manifest.name).join(", ")}}const vx=30*60;function Bi(e){return e.replace(/@.*$/,"").split("/").pop()??e}function xx(){const{domain:e}=Ue(),[t,n]=u.useState([]),[r,a]=u.useState([]),[i,o]=u.useState([]),[l,c]=u.useState(!0),[d,f]=u.useState(!1),[m,p]=u.useState([]),[x,w]=u.useState(!1),[v,S]=u.useState(!1),{entries:g,activeSessions:h,loading:y}=Jl(),j=ax(),b=!y,C=u.useCallback(()=>{T.getMyAttestations().then(O=>{n(O),f(!0)}).catch(()=>f(!0)),T.getArchivedMandates().then(p).catch(()=>p([])),T.getMyProposals(e).then(O=>{a(O),w(!0)}).catch(()=>w(!0)),T.getProposalsForApprover().then(O=>o(O)).catch(()=>o([])),T.getCredential("ai-config").then(O=>{c(O.configured),S(!0)}).catch(()=>S(!0))},[e]);he("attestation-changed",C),he("proposal-added",C),he("proposal-resolved",C),he("proposal-approved",C),he("proposal-rejected",C),At(C,3e5,e);const N=d&&x&&v&&b,I=Nm(t,{archivedSet:new Set(m)}),E=I.active,A=I.expired,D=E.filter(O=>O.remaining_seconds!==null&&O.remaining_seconds<=vx),z=r.filter(Rm),K=g.filter(O=>O.state==="running"),$=g.filter(O=>O.state==="starting"),Q=yx(g),H=[];for(const O of i)H.push({label:"Approval needed",detail:`${O.tool} — above-cap action under ${Bi(O.profileId)}`,to:"/approvals",color:"var(--warning)"});for(const O of z)H.push({label:"Approval pending",detail:`${O.tool} awaiting your approval`,to:"/approvals",color:"var(--warning)"});for(const O of D){const _=Math.ceil((O.remaining_seconds??0)/60);H.push({label:"Expiring soon",detail:`${O.title??Bi(O.profile_id)} — ${_} min remaining`,to:"/mandates",color:"var(--warning)"})}for(const O of A)H.push({label:"Expired",detail:O.title??Bi(O.profile_id),to:"/mandates",color:"var(--danger)"});H.push(...gx(g));for(const O of $)H.push({label:"Integration starting",detail:`${O.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const O of g)O.authStatus==="failed"&&O.state!=="not-running"&&O.state!=="error"&&O.state!=="paused"&&H.push({label:"Reconnect needed",detail:`${O.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return l||H.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Dashboard"})}),N&&j&&s.jsx(sx,{aiConfigured:l,hasRunningIntegration:K.length>0,hasActiveAuth:E.length>0,hasAgentConnected:h>0,mcpEndpoint:j}),s.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[s.jsx(tt,{to:"/mandates",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[d?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:E.length>0?"var(--success)":"var(--text-tertiary)"},children:E.length}):s.jsx(zn,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),s.jsx(tt,{to:"/approvals",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[x?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:z.length>0?"var(--warning)":"var(--text-tertiary)"},children:z.length}):s.jsx(zn,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),s.jsx(tt,{to:"/mandates",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[d?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:A.length>0?"var(--danger)":"var(--text-tertiary)"},children:A.length}):s.jsx(zn,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),s.jsx(tt,{to:"/integrations",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[b?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:K.length>0?"var(--success)":"var(--text-tertiary)"},children:K.length}):s.jsx(zn,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),s.jsxs("section",{className:"card attention","aria-label":"Needs your attention",children:[s.jsxs("div",{className:"card-header",children:[s.jsx("h2",{className:"card-title",children:"Needs your attention"}),H.length>0&&s.jsx("span",{className:"rb-count",children:H.length})]}),H.length>0?s.jsx("div",{className:"attention-rows",children:H.map((O,_)=>s.jsxs(tt,{to:O.to,className:"attention-row",children:[s.jsx("span",{className:"attention-dot",style:{background:O.color},"aria-hidden":"true"}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:O.label}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O.detail})]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},_))}):N?s.jsxs("div",{className:"all-clear",children:[s.jsx("span",{className:"rb-mark","aria-hidden":"true",children:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6 9 17l-5-5"})})}),s.jsx("h3",{children:"All clear"}),s.jsx("p",{children:"Nothing needs your attention."})]}):s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[s.jsx(Oi,{}),s.jsx(Oi,{}),s.jsx(Oi,{})]})]}),Q&&s.jsxs("div",{className:"sim-paused-summary",role:"status",children:[s.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),s.jsxs("span",{children:[s.jsxs("b",{children:[Q.count," real system",Q.count===1?"":"s"," ",Q.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",Q.namesText,"."]})]}),s.jsx(px,{}),s.jsx(mx,{})]})}const wx=["Scope & Limits","Intent","Sign"];function Lm({currentStep:e,onStepClick:t}){const n=tn();return s.jsxs("div",{className:"wizard-progress",children:[s.jsx("ol",{className:"wizard-steps",children:wx.map((r,a)=>{const i=a+2,o=i<e,l=i===e,c=i-1<e,d=o&&!!t;return s.jsxs("li",{className:`wizard-step${c?" reached":""}`,"aria-current":l?"step":void 0,children:[s.jsx("button",{type:"button",className:`step-circle${o?" completed":""}${l?" current":""}`,onClick:d?()=>t(i):void 0,disabled:!d,"aria-label":`${r}${o?" (done)":l?" (current)":""}`,children:o?"✓":a+1}),s.jsx("span",{className:`step-label-text${l?" current":o?" completed":""}`,children:r})]},i)})}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>n("/mandates?new=1"),children:"Cancel"})]})}const wu=40,jx={delegation:"Test Setup"};function Oe(e,t){const n=e.lastIndexOf("/"),r=n>=0?e.slice(n+1):e,a=r.indexOf("@"),i=a>=0?r.slice(0,a):r,o=jx[i.toLowerCase()];return o||(t?t.slice(0,wu):(i.charAt(0).toUpperCase()+i.slice(1)).slice(0,wu))}function Sx({profileId:e,bounds:t,groupName:n,domain:r,onSwitch:a}){return s.jsxs("div",{className:"context-strip",children:[n&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"context-strip-label",children:"Team:"}),s.jsxs("span",{children:[s.jsx("strong",{children:n}),r?` / ${r}`:""]})]}),e&&s.jsxs("span",{children:[s.jsx("strong",{children:"Profile:"})," ",Oe(e)]}),t&&s.jsxs("span",{children:[s.jsx("strong",{children:"Bounds:"})," ",t]}),a&&s.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:a,children:"Switch"})]})}function kx({integrationId:e,field:t,value:n,onChange:r,disabled:a,onLabels:i}){const[o,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState(!0);u.useEffect(()=>{let w=!1;return T.discoverScopeField(e,t).then(v=>{var S;w||(l(v.options),m(!1),(S=v.options)!=null&&S.length&&(i==null||i(Object.fromEntries(v.options.map(g=>[g.value,g.label])))))}).catch(v=>{w||(d(v instanceof Error?v.message:String(v)),m(!1))}),()=>{w=!0}},[e,t]);const p=new Set(n.split(",").map(w=>w.trim()).filter(Boolean)),x=w=>{const v=new Set(p);v.has(w)?v.delete(w):v.add(w),r(Array.from(v).join(","))};return f?s.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):c||!o?s.jsxs(s.Fragment,{children:[s.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."]}),s.jsx("input",{className:"form-input",type:"text",value:n,onChange:w=>r(w.target.value),disabled:a})]}):o.length===0?s.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:o.map(w=>{const v=w.extras??{},S=typeof v.access=="string"?v.access:void 0,g=S==="reader",h=v.primary===!0;return s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:g?"var(--text-tertiary)":"var(--text-primary)",cursor:a||g?"not-allowed":"pointer"},title:g?"Read-only — you can authorize list/read but not writes":void 0,children:[s.jsx("input",{type:"checkbox",checked:p.has(String(w.value)),onChange:()=>x(String(w.value)),disabled:a||g}),s.jsx("span",{children:w.label||w.value}),h&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),S&&s.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",S]})]},w.value)})})}function ql(e){if(e.type!=="number")return 0;const t=e.boundType,n=e.unit;return(t==null?void 0:t.kind)==="per_transaction"&&n==="count"?1:0}function bx(e,t){return t!==void 0?String(t):ql(e)===1?"1":""}function Mm(e){const t=e.maximum;return typeof t=="number"&&Number.isFinite(t)?t:void 0}function ju(e,t){const n=ql(e),r=Mm(e),a=t===""?n:Math.max(n,Number(t));return r!==void 0?Math.min(r,a):a}function Fm(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function Nx(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Cx(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Ex(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function Tx(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function Su(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 Ix(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function Rx(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 Px(e,t){if(!e||!t)return"";const n=Number(e);if(!Number.isFinite(n)||n<=0)return"";if(t==="minutes"&&n>=60){const r=Math.floor(n/60),a=n%60;return a===0?`${r} hour${r!==1?"s":""}`:`${r}h ${a}m`}if(t==="hours"&&n>=24&&n%24===0){const r=n/24;return`${r} day${r!==1?"s":""}`}if(t==="days"){if(n>=30&&n%30===0)return`${n/30} month${n/30!==1?"s":""}`;if(n>=7&&n%7===0)return`${n/7} week${n/7!==1?"s":""}`}return""}function Ax({id:e,value:t,onChange:n,disabled:r,placeholder:a,unit:i,min:o=0,max:l}){const c=Ix(i),d=Rx(i).filter(v=>l===void 0||v.value<=l),f=Fm(i),m=Px(t,i),p=t===""?null:Number(t),x=()=>{const v=t===""?0:Number(t),S=v%c,g=S===0?v+c:v+(c-S);n(String(l!==void 0?Math.min(l,g):g))},w=()=>{const v=t===""?0:Number(t);if(v<=o)return;const S=v%c,g=S===0?v-c:v-S;n(String(Math.max(o,g)))};return s.jsxs("div",{className:"bounded-input",children:[s.jsxs("div",{className:"bounded-input-field",children:[s.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:w,disabled:r||t===""||Number(t)<=o,"aria-label":"Decrease",children:"−"}),s.jsx("input",{id:e,className:"stepper-input",type:"number",min:o,max:l,step:c,value:t,placeholder:a??String(o),onChange:v=>{const S=v.target.value;n(l!==void 0&&S!==""&&Number(S)>l?String(l):S)},onFocus:v=>v.target.select(),disabled:r}),s.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:x,disabled:r||l!==void 0&&t!==""&&Number(t)>=l,"aria-label":"Increase",children:"+"}),f&&s.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:f})]}),d.length>0&&!r&&s.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:d.map(v=>s.jsx("button",{type:"button",className:`preset-chip${p===v.value?" preset-chip-selected":""}`,onClick:()=>n(String(v.value)),children:v.label},v.value))}),m&&s.jsxs("div",{className:"bounded-input-echo",children:["≈ ",m]})]})}function ku({htmlFor:e,label:t,description:n}){const[r,a]=u.useState(!1);return s.jsxs("div",{className:"field-label-with-tip",children:[s.jsx("label",{className:"form-label",htmlFor:e,children:t}),n&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${t}" mean?`,"aria-expanded":r,onClick:()=>a(i=>!i),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onBlur:()=>a(!1),children:"i"}),r&&s.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:n})]})]})}function _x({id:e,value:t,onChange:n,disabled:r,format:a,placeholder:i}){const[o,l]=u.useState(""),[c,d]=u.useState(!1),f=u.useRef(null),m=t?t.split(",").map(g=>g.trim()).filter(Boolean):[],p=g=>{const h=g.trim();if(!h)return;if(!Su(h,a)){d(!0);return}d(!1);const y=m.includes(h)?m:[...m,h];n(y.join(",")),l("")},x=g=>{const h=m.filter((y,j)=>j!==g);n(h.join(","))},w=g=>{g.key==="Enter"||g.key===","||g.key==="Tab"?o.trim()&&(g.preventDefault(),p(o)):g.key==="Backspace"&&!o&&m.length>0&&x(m.length-1)},v=g=>{const h=g.clipboardData.getData("text");if(h.includes(",")){g.preventDefault();const j=h.split(",").map(C=>C.trim()).filter(Boolean).filter(C=>Su(C,a)),b=[...new Set([...m,...j])];n(b.join(",")),l(""),d(!1)}},S=a==="email"?"Type email and press Enter...":"Type domain and press Enter...";return s.jsxs("div",{className:`tag-input${c?" tag-input-invalid":""}`,onClick:()=>{var g;return(g=f.current)==null?void 0:g.focus()},children:[m.map((g,h)=>s.jsxs("span",{className:"tag-pill",children:[g,!r&&s.jsx("button",{type:"button",className:"tag-remove",onClick:y=>{y.stopPropagation(),x(h)},"aria-label":`Remove ${g}`,children:"×"})]},g)),!r&&s.jsx("input",{ref:f,id:e,className:"tag-input-field",type:"text",value:o,onChange:g=>{l(g.target.value),d(!1)},onKeyDown:w,onPaste:v,onBlur:()=>{o.trim()&&p(o)},placeholder:m.length===0?i??S:""})]})}function zx({id:e,options:t,value:n,onChange:r,disabled:a}){const i=n?n.split(",").map(l=>l.trim()).filter(Boolean):[],o=l=>{const c=i.includes(l)?i.filter(d=>d!==l):[...i,l];r(c.join(","))};return s.jsx("div",{className:"checkbox-group",id:e,children:t.map(l=>s.jsxs("label",{className:`checkbox-pill${i.includes(l)?" checkbox-pill-selected":""}`,children:[s.jsx("input",{type:"checkbox",checked:i.includes(l),onChange:()=>o(l),disabled:a}),s.jsx("span",{children:l})]},l))})}function bu({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:a,readOnly:i,twoColumn:o,discoveryIntegrationId:l,onLabels:c}){const d=Cx(e,t),f=`${a}-field-${e}`,m=s.jsx(s.Fragment,{children:Tx(t)?s.jsx(zx,{id:f,options:t.enum,value:n,onChange:p=>r(e,p),disabled:i}):(()=>{const p=t.boundType;return(p==null?void 0:p.kind)==="enum"&&Array.isArray(p.values)})()?s.jsxs("select",{id:f,className:"form-select",value:n,onChange:p=>r(e,p.target.value),disabled:i,children:[s.jsx("option",{value:"",children:"Select..."}),t.boundType.values.map(p=>s.jsx("option",{value:p,children:p},p))]}):"enum"in t&&t.enum?s.jsxs("select",{id:f,className:"form-select",value:n,onChange:p=>r(e,p.target.value),disabled:i,children:[s.jsx("option",{value:"",children:"Select..."}),t.enum.map(p=>s.jsx("option",{value:p,children:p},p))]}):t.type==="number"?s.jsx(Ax,{id:f,value:n,onChange:p=>r(e,p),disabled:i,unit:t.unit,min:ql(t),max:Mm(t)}):Ex(t)?s.jsx(_x,{id:f,value:n,onChange:p=>r(e,p),disabled:i,format:t.format}):l?s.jsx(kx,{integrationId:l,field:e,value:n,onChange:p=>r(e,p),disabled:i,onLabels:p=>c==null?void 0:c(e,p)}):s.jsx("input",{id:f,className:"form-input",type:"text",value:n,onChange:p=>r(e,p.target.value),disabled:i})});return o?s.jsxs("div",{className:"bounds-field-row",children:[s.jsx("div",{className:"bounds-field-label",children:s.jsx(ku,{htmlFor:f,label:d,description:t.description})}),s.jsx("div",{className:"bounds-field-input",children:m})]},`${a}-${e}`):s.jsxs("div",{className:"form-group",children:[s.jsx(ku,{htmlFor:f,label:d,description:t.description}),m]},`${a}-${e}`)}function $x(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 i=!1;for(const[o,l]of Object.entries(n)){const c=e[o];if(c===""||c===void 0)continue;const d=Number(c);if(!isNaN(d)&&d>l){i=!0;break}}return i?r?"above-approvers":"hard-ceiling":"within-cap"}function Lx(e,t){const n=new Set;if(!t)return n;for(const[r,a]of Object.entries(t)){const i=e[r];if(i===""||i===void 0)continue;const o=Number(i);!isNaN(o)&&o>a&&n.add(r)}return n}function Mx({profile:e,onConfirm:t,onCancel:n,readOnly:r,initialBounds:a,initialContext:i,initialFrame:o,profileConfig:l,approverNames:c,adminName:d}){const f=e.boundsSchema??e.frameSchema,m=e.contextSchema,p=f?Object.entries(f.fields).filter(([R,L])=>!(R==="profile"||R==="path"||L.enforced===!1||L.enforcedBy==="gatekeeper")):[],x=f?Object.entries(f.fields).filter(([,R])=>R.enforcedBy==="gatekeeper").filter(([,R])=>R.enforced!==!1).map(([R,L])=>L.displayName??R):[],w=m&&m.keyOrder.length>0?Object.entries(m.fields):[],v=a??o??{},S=i??{},g={};for(const[R,L]of p)g[R]=bx(L,v[R]);const h={};for(const[R]of w)h[R]=S[R]!==void 0?String(S[R]):"";const[y,j]=u.useState(g),[b,C]=u.useState(h),[N,I]=u.useState({}),[E,A]=u.useState(null);u.useEffect(()=>{const R=Nx(e.id);T.getIntegrationManifests().then(({manifests:L})=>{const Y=L.find(te=>te.profile===R&&te.contextDiscovery&&Object.keys(te.contextDiscovery).length>0);A(Y??null)}).catch(()=>A(null))},[e.id]);const D=$x(y,l),z=Lx(y,l==null?void 0:l.caps),K=(R,L)=>{j(Y=>({...Y,[R]:L}))},$=(R,L)=>{C(Y=>({...Y,[R]:L}))},Q=()=>{const R={profile:e.id};for(const[Y,te]of p)te.type==="number"?R[Y]=ju(te,y[Y]):R[Y]=y[Y];const L={};for(const[Y,te]of w)te.type==="number"?L[Y]=b[Y]===""?0:Number(b[Y]):L[Y]=b[Y];return[R,L]},H=()=>{const[R,L]=Q();t(R,L,N)},O=()=>{const R=(l==null?void 0:l.caps)??{},L={...y};for(const ne of z)R[ne]!==void 0&&(L[ne]=String(R[ne]));j(L);const Y={profile:e.id};for(const[ne,de]of p)de.type==="number"?Y[ne]=ju(de,L[ne]??""):Y[ne]=L[ne]??"";const te={};for(const[ne,de]of w)de.type==="number"?te[ne]=b[ne]===""?0:Number(b[ne]):te[ne]=b[ne];t(Y,te,N)},_=R=>{const L=l==null?void 0:l.caps;if(!L||L[R]===void 0)return null;const Y=L[R],te=z.has(R);return D==="hard-ceiling"&&te?s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Y," — exceeds team ceiling"]}):D==="above-approvers"&&te?s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Y," — above cap"]}):s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Y," ok"]})},P=()=>{var R;if(D==="no-config")return null;if(D==="approvers-dormant"){const L=c&&c.length>0?c.join(", "):"the configured approvers";return s.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:[s.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",L]}),s.jsxs("div",{children:["No caps are set on this profile, so ",L," won't gate any action under this mandate. 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(D==="within-cap")return s.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:s.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(D==="above-approvers"){const L=c&&c.length>0?c.join(", "):"the required approvers";return s.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:[s.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),s.jsxs("div",{children:[s.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",L,". Within-cap actions run per the mode you choose."]})]})}if(D==="hard-ceiling"){const L=Array.from(z)[0],Y=L?(R=l==null?void 0:l.caps)==null?void 0:R[L]:void 0,te=d??"the team admin";return s.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:[s.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),s.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",Y??"the configured limit",". Lower your bound or ask ",te," to add an approver path above the cap."]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:O,children:"Save below cap"}),n&&s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},V=D==="hard-ceiling";return s.jsxs("div",{children:[w.length>0&&s.jsxs("div",{className:"context-section",children:[s.jsxs("div",{className:"bounds-section-header",children:[s.jsx("span",{className:"bounds-section-icon",children:"🛡"}),s.jsxs("div",{children:[s.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),s.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),w.map(([R,L])=>{var te;const Y=!!((te=E==null?void 0:E.contextDiscovery)!=null&&te[R]);return s.jsx(bu,{fieldKey:R,fieldDef:L,value:b[R],onChange:$,prefix:"context",readOnly:r,discoveryIntegrationId:Y?E.id:void 0,onLabels:(ne,de)=>I(xe=>({...xe,[ne]:de}))},`context-${R}`)})]}),p.length>0&&s.jsxs("div",{className:"bounds-section",children:[s.jsxs("div",{className:"bounds-section-header",children:[s.jsx("span",{className:"bounds-section-icon",children:"🔒"}),s.jsxs("div",{children:[s.jsx("div",{className:"bounds-section-title",children:"Limits"}),s.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),s.jsx("div",{className:"bounds-fields-grid",children:p.map(([R,L])=>{var Y;return s.jsxs("div",{style:{display:"contents"},children:[s.jsx(bu,{fieldKey:R,fieldDef:L,value:y[R],onChange:K,prefix:"bounds",readOnly:r,twoColumn:!0}),D!=="no-config"&&((Y=l==null?void 0:l.caps)==null?void 0:Y[R])!==void 0&&s.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:_(R)})]},`bounds-${R}`)})}),P(),x.length>0&&s.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"," ",s.jsx(tt,{to:"/integrations",children:"Integrations"}),"."]})]}),s.jsx("button",{className:"btn btn-primary",onClick:H,disabled:V,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function Fx(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 Ox(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Bx="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 La({target:e,currentText:t,onApply:n,greeting:r,placeholder:a,title:i}){const[o,l]=u.useState([{role:"assistant",content:r??Bx}]),[c,d]=u.useState(""),[f,m]=u.useState(!1),[p,x]=u.useState(null),w=u.useRef(null),v=u.useRef(null);u.useEffect(()=>{const h=w.current;if(!h)return;const y=o[o.length-1],j=v.current;!f&&(y==null?void 0:y.role)==="assistant"&&o.length>1&&j?h.scrollTop=j.offsetTop:h.scrollTop=h.scrollHeight},[o,f]);const S=async()=>{const h=c.trim();if(!h||f)return;const y=[...o,{role:"user",content:h}];l(y),d(""),x(null),m(!0);try{const j=await T.aiChat({target:e,currentText:t,messages:y.filter((b,C)=>!(C===0&&b.role==="assistant"))});j.success&&j.reply?l(b=>[...b,{role:"assistant",content:j.reply}]):x(j.error??"AI returned no reply")}catch(j){x(j instanceof Error?j.message:"Chat failed")}finally{m(!1)}},g=h=>{h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),S())};return s.jsxs("div",{className:"intent-chat",children:[s.jsx("h3",{className:"card-title",children:i??"AI Assistant"}),s.jsxs("div",{ref:w,className:"chat-messages",children:[o.map((h,y)=>{const j=h.role==="assistant"?Fx(h.content):null,b=j?Ox(h.content):h.content;return s.jsx("div",{className:`chat-msg ${h.role}`,ref:y===o.length-1?v:void 0,children:s.jsxs("div",{className:"chat-msg-body",children:[b&&s.jsx("div",{className:"chat-msg-prose",children:b}),j!==null&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"chat-fenced-block",children:j}),s.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(j),children:"Apply this draft"})]})]})},y)}),f&&s.jsx("div",{className:"chat-msg assistant",children:s.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),p&&s.jsx("div",{className:"error-message",children:p}),s.jsxs("div",{className:"chat-composer",children:[s.jsxs("div",{className:"chat-composer-pill",children:[s.jsx("textarea",{className:"chat-input",value:c,onChange:h=>d(h.target.value),onKeyDown:g,placeholder:a??"Ask for help articulating the intent…",rows:1,disabled:f}),s.jsx("button",{type:"button",className:"chat-send-btn",onClick:S,disabled:f||!c.trim(),"aria-label":"Send",children:"↑"})]}),s.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Om({open:e,onClose:t,children:n,ariaLabel:r}){const a=u.useRef(null),i=u.useRef(null);return u.useEffect(()=>{var l;if(!e)return;i.current=document.activeElement,document.body.style.overflow="hidden";const o=c=>{c.key==="Escape"&&t()};return document.addEventListener("keydown",o),(l=a.current)==null||l.focus(),()=>{document.removeEventListener("keydown",o),document.body.style.overflow="",i.current instanceof HTMLElement&&i.current.focus()}},[e,t]),em.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:t,"aria-hidden":"true"}),s.jsxs("aside",{ref:a,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":r,tabIndex:-1,children:[s.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),s.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:t,"aria-label":"Close",children:"×"}),n]})]}),document.body)}function Dx(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ux(e,t,n){if(t.length===0)return[{text:e,label:e,matched:null}];const r=[],a=new Set;for(const c of t)if(!(!c.scope||c.scope==="all (unscoped)"))for(const d of[c.scope,...c.scope.split(",").map(f=>f.trim())]){const f=d.toLowerCase();d&&!a.has(f)&&(a.add(f),r.push(d))}r.sort((c,d)=>d.length-c.length);const i=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))})},o=["\\[\\d+\\]",...r.map(Dx)],l=new RegExp(`(${o.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=i(c);if(f.length>0)return{text:c,label:c,matched:f}}return{text:c,label:c,matched:null}})}const Nu=`Why — What's the situation? Why does this need to happen?
|
|
60
|
+
Health check: GET ${e}/health`}};function vx({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:a}){const[i,o]=u.useState(()=>localStorage.getItem(Uo)==="true"),[l,c]=u.useState(()=>localStorage.getItem(Wo)==="true"),[d,f]=u.useState(()=>localStorage.getItem(Ho)==="true"),[h,m]=u.useState(null),[x,w]=u.useState("claude-code"),[v,S]=u.useState(!1),g=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":i?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:t?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:n?"done":"pending"},{label:"Connect your agent",status:r||l?"done":"pending"}],p=g.filter(E=>E.status==="done"||E.status==="skipped").length,y=p===g.length,j=u.useCallback(()=>{localStorage.setItem(Uo,"true"),o(!0)},[]),b=u.useCallback(()=>{localStorage.setItem(Wo,"true"),c(!0),m(null)},[]),C=u.useCallback(()=>{localStorage.setItem(Ho,"true"),f(!0)},[]),N=u.useCallback(async E=>{try{await navigator.clipboard.writeText(E),S(!0),setTimeout(()=>S(!1),2e3)}catch{}},[]);if(d||y)return null;const I=g.findIndex(E=>E.status==="pending");return s.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[s.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),s.jsx("button",{onClick:C,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:"×"})]}),s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:g.map((E,A)=>{const D=A===I,L=E.status==="done"||E.status==="skipped"?"●":"○",K=E.status==="done"?"var(--success)":E.status==="skipped"?"var(--text-tertiary)":D?"var(--accent)":"var(--text-tertiary)";return s.jsxs("div",{children:[s.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:D?"0.75rem":"0.25rem 0",borderRadius:D?"0.5rem":void 0,background:D?"var(--accent-subtle)":void 0},children:[s.jsx("span",{style:{color:K,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:L}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[E.to&&E.status==="pending"?s.jsx(tt,{to:E.to,style:{fontSize:"0.9rem",fontWeight:D?600:500,color:D?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:E.label}):E.status==="pending"&&A===3?s.jsx("button",{onClick:()=>m(h===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:D?600:500,color:D?"var(--accent)":"var(--text-primary)"},children:E.label}):s.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:E.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:E.label}),E.optional&&E.status==="pending"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),E.status==="skipped"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),E.detail&&E.status==="pending"&&D&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:E.detail})]}),E.optional&&E.status==="pending"&&s.jsx("button",{onClick:j,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),E.to&&E.status==="pending"&&s.jsx(tt,{to:E.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),A===3&&h===3&&s.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[s.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem",color:"var(--text-primary)"},children:"MCP Endpoint"}),s.jsx("div",{style:{fontFamily:"monospace",fontSize:"0.85rem",padding:"0.5rem 0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",marginBottom:"1rem",wordBreak:"break-all"},children:a}),s.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"0.75rem"},children:Object.entries(Di).map(([z,Q])=>s.jsx("button",{onClick:()=>w(z),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:x===z?600:400,background:x===z?"var(--accent-subtle)":"transparent",color:x===z?"var(--accent)":"var(--text-secondary)",border:`1px solid ${x===z?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:Q.label},z))}),s.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:Di[x].snippet(a)}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>N(Di[x].snippet(a)),children:v?"Copied":"Copy"}),s.jsx("button",{className:"btn btn-primary btn-sm",onClick:b,children:"Done"})]})]})]},A)})}),s.jsxs("div",{style:{marginTop:"1.25rem"},children:[s.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:s.jsx("div",{style:{height:"100%",width:`${p/g.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),s.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[p," of ",g.length," complete"]})]})]})}function xx(){const[e,t]=u.useState(null);return u.useEffect(()=>{let n=!1;return fetch("/health").then(r=>r.json()).then(r=>{!n&&typeof r.mcpPort=="number"&&t(`http://localhost:${r.mcpPort}`)}).catch(()=>{}),()=>{n=!0}},[]),e}function Ln({variant:e="base",style:t,className:n,...r}){const a=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return s.jsx("span",{className:`${a}${n?` ${n}`:""}`,style:t,role:"status","aria-busy":"true","aria-label":r["aria-label"]??"Loading"})}function Ui(){return s.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[s.jsx(Ln,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),s.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[s.jsx(Ln,{variant:"line",style:{width:"35%"}}),s.jsx(Ln,{variant:"line-sm",style:{width:"65%"}})]})]})}const wx={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Gm=e=>wx[e]??e,jx={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:"/mandates"},ungoverned:{chip:"Unconfigured",sev:"act"},query_unsafe:{chip:"Unsafe search",sev:"info"}};function Sx(e){return jx[e]??{chip:"Blocked",sev:"info"}}function kx(e){const t=Gm(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?s.jsxs(s.Fragment,{children:["Tried to read your ",s.jsx("b",{children:e.target??"restricted"})," calendar"]}):s.jsxs(s.Fragment,{children:["Tried to read a restricted location in ",t]});case"spam":return s.jsxs(s.Fragment,{children:["Tried to open a message in ",s.jsx("b",{children:"spam or trash"})]});case"age":return s.jsxs(s.Fragment,{children:["Tried to read ",t," older than your read window"]});case"unset_age":return s.jsxs(s.Fragment,{children:["Your ",t," has ",s.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return s.jsxs(s.Fragment,{children:["Read access isn't granted on your ",t," mandate"]});case"ungoverned":return s.jsxs(s.Fragment,{children:["A ",t," tool isn't configured for safe reading"]});case"query_unsafe":return s.jsx(s.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return s.jsx(s.Fragment,{children:e.detail})}}function bx(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 Eu=5,Nx=24*60*60*1e3,ca=7;function Cx(e,t){const n=t-ca*Nx;return{recent:e.filter(r=>r.ts>=n),all:e}}function Ex(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(!1),o=u.useCallback(()=>{T.getDenials({limit:200}).then(({records:m})=>{t(m),i(!1)}).catch(()=>i(!0))},[]);if(u.useEffect(()=>{o()},[o]),At(o,12e4),a||e===null)return null;const{recent:l,all:c}=Cx(e,Date.now()),d=n?c:l.slice(0,Eu),f=c.length-l.length,h=(m,x)=>{const w=Sx(m.reason);return s.jsxs("div",{className:"rb-row",children:[s.jsx("span",{className:`rb-dot ${w.sev==="act"?"act":w.sev==="info"?"info":""}`,"aria-hidden":"true"}),s.jsxs("div",{className:"rb-body",children:[s.jsx("div",{className:"rb-line",children:kx(m)}),s.jsxs("div",{className:"rb-meta",children:[s.jsx("span",{className:`rb-chip ${w.sev==="act"?"act":w.sev==="warn"?"warn":""}`,children:w.chip}),s.jsx("span",{className:"rb-via",children:Gm(m.integrationId)})]}),w.fixTo&&s.jsx(tt,{className:"rb-fix",to:w.fixTo,children:"Set a read window →"})]}),s.jsx("div",{className:"rb-when",children:bx(m.ts,Date.now())})]},`${m.ts}-${x}`)};return s.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[s.jsxs("div",{className:"card-header",children:[s.jsx("h2",{className:"card-title",children:"Recent blocks"}),(n?c.length:l.length)>0&&s.jsx("span",{className:"rb-count",children:n?c.length:l.length})]}),d.length===0?s.jsxs("div",{className:"rb-empty",children:[s.jsx("span",{className:"rb-mark","aria-hidden":"true",children:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6 9 17l-5-5"})})}),s.jsxs("h3",{children:["Nothing blocked in the last ",ca," days"]}),s.jsx("p",{children:"Your agent has stayed within every limit you set."}),f>0&&s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!0),children:["Show the last 30 days (",f,")"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"rb-sub",children:[n?"Last 30 days. ":`Last ${ca} days. `,"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."]}),s.jsx("div",{className:"rb-rows",children:d.map(h)}),!n&&c.length>d.length&&s.jsx("div",{className:"rb-foot",children:s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!0),children:["View all ",c.length," blocks from the last 30 days"]})}),n&&c.length>Math.min(l.length,Eu)&&s.jsx("div",{className:"rb-foot",children:s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!1),children:["Show only the last ",ca," days"]})})]})]})}function Tx(){const[e,t]=u.useState([]);return At(async()=>{try{const{skipped:r}=await T.getSkippedCommitments();t(r)}catch{}},3e4),e.length===0?null:s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px solid var(--warn, #b58900)"},children:[s.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",e.length,")"]}),s.jsx("p",{style:{margin:"0.5rem 0 1rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"These were approved, but this gateway has no local record of asking for them — usually because a different device/installation of yours submitted them, or its local record is gone. Re-run the same request on this gateway to execute it here."}),s.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:e.map(r=>s.jsxs("li",{style:{marginBottom:"0.35rem"},children:[s.jsx("code",{children:r.tool})," ",s.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",r.id,")"]})]},r.id))})]})}function Ix(e,t){const n=e.simulation;return n?(((t==null?void 0:t[n.field])??"").trim().toLowerCase()||n.default.trim().toLowerCase())==="simulation":!1}function Vo(e){return!!(e!=null&&e.simulation)}function Rx(e){var n;const t=[];for(const r of e)r.state==="error"?t.push({label:"Integration error",detail:(n=r.integration)!=null&&n.error?`${r.manifest.name}: ${r.integration.error}`:`${r.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"}):r.state==="not-running"&&(Vo(r.manifest)?t.push({label:`${r.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--danger)"}):t.push({label:"Integration stopped",detail:`${r.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"}));return t}function Px(e){const t=e.filter(n=>n.state==="paused");return t.length===0?null:{count:t.length,namesText:t.map(n=>n.manifest.name).join(", ")}}const Ax=30*60;function Wi(e){return e.replace(/@.*$/,"").split("/").pop()??e}function _x(){const{domain:e}=Ue(),[t,n]=u.useState([]),[r,a]=u.useState([]),[i,o]=u.useState([]),[l,c]=u.useState(!0),[d,f]=u.useState(!1),[h,m]=u.useState([]),[x,w]=u.useState(!1),[v,S]=u.useState(!1),{entries:g,activeSessions:p,loading:y}=rc(),j=xx(),b=!y,C=u.useCallback(()=>{T.getMyAttestations().then(O=>{n(O),f(!0)}).catch(()=>f(!0)),T.getArchivedMandates().then(m).catch(()=>m([])),T.getMyProposals(e).then(O=>{a(O),w(!0)}).catch(()=>w(!0)),T.getProposalsForApprover().then(O=>o(O)).catch(()=>o([])),T.getCredential("ai-config").then(O=>{c(O.configured),S(!0)}).catch(()=>S(!0))},[e]);pe("attestation-changed",C),pe("proposal-added",C),pe("proposal-resolved",C),pe("proposal-approved",C),pe("proposal-rejected",C),At(C,3e5,e);const N=d&&x&&v&&b,I=$m(t,{archivedSet:new Set(h)}),E=I.active,A=I.expired,D=E.filter(O=>O.remaining_seconds!==null&&O.remaining_seconds<=Ax),L=r.filter(Dm),K=g.filter(O=>O.state==="running"),z=g.filter(O=>O.state==="starting"),Q=Px(g),H=[];for(const O of i)H.push({label:"Approval needed",detail:`${O.tool} — above-cap action under ${Wi(O.profileId)}`,to:"/approvals",color:"var(--warning)"});for(const O of L)H.push({label:"Approval pending",detail:`${O.tool} awaiting your approval`,to:"/approvals",color:"var(--warning)"});for(const O of D){const _=Math.ceil((O.remaining_seconds??0)/60);H.push({label:"Expiring soon",detail:`${O.title??Wi(O.profile_id)} — ${_} min remaining`,to:"/mandates",color:"var(--warning)"})}for(const O of A)H.push({label:"Expired",detail:O.title??Wi(O.profile_id),to:"/mandates",color:"var(--danger)"});H.push(...Rx(g));for(const O of z)H.push({label:"Integration starting",detail:`${O.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const O of g)O.authStatus==="failed"&&O.state!=="not-running"&&O.state!=="error"&&O.state!=="paused"&&H.push({label:"Reconnect needed",detail:`${O.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return l||H.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Dashboard"})}),N&&j&&s.jsx(vx,{aiConfigured:l,hasRunningIntegration:K.length>0,hasActiveAuth:E.length>0,hasAgentConnected:p>0,mcpEndpoint:j}),s.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[s.jsx(tt,{to:"/mandates",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[d?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:E.length>0?"var(--success)":"var(--text-tertiary)"},children:E.length}):s.jsx(Ln,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),s.jsx(tt,{to:"/approvals",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[x?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:L.length>0?"var(--warning)":"var(--text-tertiary)"},children:L.length}):s.jsx(Ln,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),s.jsx(tt,{to:"/mandates",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[d?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:A.length>0?"var(--danger)":"var(--text-tertiary)"},children:A.length}):s.jsx(Ln,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),s.jsx(tt,{to:"/integrations",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[b?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:K.length>0?"var(--success)":"var(--text-tertiary)"},children:K.length}):s.jsx(Ln,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),s.jsxs("section",{className:"card attention","aria-label":"Needs your attention",children:[s.jsxs("div",{className:"card-header",children:[s.jsx("h2",{className:"card-title",children:"Needs your attention"}),H.length>0&&s.jsx("span",{className:"rb-count",children:H.length})]}),H.length>0?s.jsx("div",{className:"attention-rows",children:H.map((O,_)=>s.jsxs(tt,{to:O.to,className:"attention-row",children:[s.jsx("span",{className:"attention-dot",style:{background:O.color},"aria-hidden":"true"}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:O.label}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O.detail})]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},_))}):N?s.jsxs("div",{className:"all-clear",children:[s.jsx("span",{className:"rb-mark","aria-hidden":"true",children:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6 9 17l-5-5"})})}),s.jsx("h3",{children:"All clear"}),s.jsx("p",{children:"Nothing needs your attention."})]}):s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[s.jsx(Ui,{}),s.jsx(Ui,{}),s.jsx(Ui,{})]})]}),Q&&s.jsxs("div",{className:"sim-paused-summary",role:"status",children:[s.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),s.jsxs("span",{children:[s.jsxs("b",{children:[Q.count," real system",Q.count===1?"":"s"," ",Q.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",Q.namesText,"."]})]}),s.jsx(Tx,{}),s.jsx(Ex,{})]})}const Lx=["Scope & Limits","Intent","Sign"];function Km({currentStep:e,onStepClick:t}){const n=tn();return s.jsxs("div",{className:"wizard-progress",children:[s.jsx("ol",{className:"wizard-steps",children:Lx.map((r,a)=>{const i=a+2,o=i<e,l=i===e,c=i-1<e,d=o&&!!t;return s.jsxs("li",{className:`wizard-step${c?" reached":""}`,"aria-current":l?"step":void 0,children:[s.jsx("button",{type:"button",className:`step-circle${o?" completed":""}${l?" current":""}`,onClick:d?()=>t(i):void 0,disabled:!d,"aria-label":`${r}${o?" (done)":l?" (current)":""}`,children:o?"✓":a+1}),s.jsx("span",{className:`step-label-text${l?" current":o?" completed":""}`,children:r})]},i)})}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>n("/mandates?new=1"),children:"Cancel"})]})}const Tu=40,zx={delegation:"Test Setup"};function Oe(e,t){const n=e.lastIndexOf("/"),r=n>=0?e.slice(n+1):e,a=r.indexOf("@"),i=a>=0?r.slice(0,a):r,o=zx[i.toLowerCase()];return o||(t?t.slice(0,Tu):(i.charAt(0).toUpperCase()+i.slice(1)).slice(0,Tu))}function $x({profileId:e,bounds:t,groupName:n,domain:r,onSwitch:a}){return s.jsxs("div",{className:"context-strip",children:[n&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"context-strip-label",children:"Team:"}),s.jsxs("span",{children:[s.jsx("strong",{children:n}),r?` / ${r}`:""]})]}),e&&s.jsxs("span",{children:[s.jsx("strong",{children:"Profile:"})," ",Oe(e)]}),t&&s.jsxs("span",{children:[s.jsx("strong",{children:"Bounds:"})," ",t]}),a&&s.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:a,children:"Switch"})]})}function Mx({integrationId:e,field:t,value:n,onChange:r,disabled:a,onLabels:i}){const[o,l]=u.useState(null),[c,d]=u.useState(null),[f,h]=u.useState(!0);u.useEffect(()=>{let w=!1;return T.discoverScopeField(e,t).then(v=>{var S;w||(l(v.options),h(!1),(S=v.options)!=null&&S.length&&(i==null||i(Object.fromEntries(v.options.map(g=>[g.value,g.label])))))}).catch(v=>{w||(d(v instanceof Error?v.message:String(v)),h(!1))}),()=>{w=!0}},[e,t]);const m=new Set(n.split(",").map(w=>w.trim()).filter(Boolean)),x=w=>{const v=new Set(m);v.has(w)?v.delete(w):v.add(w),r(Array.from(v).join(","))};return f?s.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):c||!o?s.jsxs(s.Fragment,{children:[s.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."]}),s.jsx("input",{className:"form-input",type:"text",value:n,onChange:w=>r(w.target.value),disabled:a})]}):o.length===0?s.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:o.map(w=>{const v=w.extras??{},S=typeof v.access=="string"?v.access:void 0,g=S==="reader",p=v.primary===!0;return s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:g?"var(--text-tertiary)":"var(--text-primary)",cursor:a||g?"not-allowed":"pointer"},title:g?"Read-only — you can authorize list/read but not writes":void 0,children:[s.jsx("input",{type:"checkbox",checked:m.has(String(w.value)),onChange:()=>x(String(w.value)),disabled:a||g}),s.jsx("span",{children:w.label||w.value}),p&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),S&&s.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",S]})]},w.value)})})}function ac(e){if(e.type!=="number")return 0;const t=e.boundType,n=e.unit;return(t==null?void 0:t.kind)==="per_transaction"&&n==="count"?1:0}function Fx(e,t){return t!==void 0?String(t):ac(e)===1?"1":""}function Ym(e){const t=e.maximum;return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Iu(e,t){const n=ac(e),r=Ym(e),a=t===""?n:Math.max(n,Number(t));return r!==void 0?Math.min(r,a):a}function Qm(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function Ox(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Bx(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Dx(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function Ux(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function Ru(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 Wx(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function Hx(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 Vx(e,t){if(!e||!t)return"";const n=Number(e);if(!Number.isFinite(n)||n<=0)return"";if(t==="minutes"&&n>=60){const r=Math.floor(n/60),a=n%60;return a===0?`${r} hour${r!==1?"s":""}`:`${r}h ${a}m`}if(t==="hours"&&n>=24&&n%24===0){const r=n/24;return`${r} day${r!==1?"s":""}`}if(t==="days"){if(n>=30&&n%30===0)return`${n/30} month${n/30!==1?"s":""}`;if(n>=7&&n%7===0)return`${n/7} week${n/7!==1?"s":""}`}return""}function Gx({id:e,value:t,onChange:n,disabled:r,placeholder:a,unit:i,min:o=0,max:l}){const c=Wx(i),d=Hx(i).filter(v=>l===void 0||v.value<=l),f=Qm(i),h=Vx(t,i),m=t===""?null:Number(t),x=()=>{const v=t===""?0:Number(t),S=v%c,g=S===0?v+c:v+(c-S);n(String(l!==void 0?Math.min(l,g):g))},w=()=>{const v=t===""?0:Number(t);if(v<=o)return;const S=v%c,g=S===0?v-c:v-S;n(String(Math.max(o,g)))};return s.jsxs("div",{className:"bounded-input",children:[s.jsxs("div",{className:"bounded-input-field",children:[s.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:w,disabled:r||t===""||Number(t)<=o,"aria-label":"Decrease",children:"−"}),s.jsx("input",{id:e,className:"stepper-input",type:"number",min:o,max:l,step:c,value:t,placeholder:a??String(o),onChange:v=>{const S=v.target.value;n(l!==void 0&&S!==""&&Number(S)>l?String(l):S)},onFocus:v=>v.target.select(),disabled:r}),s.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:x,disabled:r||l!==void 0&&t!==""&&Number(t)>=l,"aria-label":"Increase",children:"+"}),f&&s.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:f})]}),d.length>0&&!r&&s.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:d.map(v=>s.jsx("button",{type:"button",className:`preset-chip${m===v.value?" preset-chip-selected":""}`,onClick:()=>n(String(v.value)),children:v.label},v.value))}),h&&s.jsxs("div",{className:"bounded-input-echo",children:["≈ ",h]})]})}function Pu({htmlFor:e,label:t,description:n}){const[r,a]=u.useState(!1);return s.jsxs("div",{className:"field-label-with-tip",children:[s.jsx("label",{className:"form-label",htmlFor:e,children:t}),n&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${t}" mean?`,"aria-expanded":r,onClick:()=>a(i=>!i),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onBlur:()=>a(!1),children:"i"}),r&&s.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:n})]})]})}function Kx({id:e,value:t,onChange:n,disabled:r,format:a,placeholder:i}){const[o,l]=u.useState(""),[c,d]=u.useState(!1),f=u.useRef(null),h=t?t.split(",").map(g=>g.trim()).filter(Boolean):[],m=g=>{const p=g.trim();if(!p)return;if(!Ru(p,a)){d(!0);return}d(!1);const y=h.includes(p)?h:[...h,p];n(y.join(",")),l("")},x=g=>{const p=h.filter((y,j)=>j!==g);n(p.join(","))},w=g=>{g.key==="Enter"||g.key===","||g.key==="Tab"?o.trim()&&(g.preventDefault(),m(o)):g.key==="Backspace"&&!o&&h.length>0&&x(h.length-1)},v=g=>{const p=g.clipboardData.getData("text");if(p.includes(",")){g.preventDefault();const j=p.split(",").map(C=>C.trim()).filter(Boolean).filter(C=>Ru(C,a)),b=[...new Set([...h,...j])];n(b.join(",")),l(""),d(!1)}},S=a==="email"?"Type email and press Enter...":"Type domain and press Enter...";return s.jsxs("div",{className:`tag-input${c?" tag-input-invalid":""}`,onClick:()=>{var g;return(g=f.current)==null?void 0:g.focus()},children:[h.map((g,p)=>s.jsxs("span",{className:"tag-pill",children:[g,!r&&s.jsx("button",{type:"button",className:"tag-remove",onClick:y=>{y.stopPropagation(),x(p)},"aria-label":`Remove ${g}`,children:"×"})]},g)),!r&&s.jsx("input",{ref:f,id:e,className:"tag-input-field",type:"text",value:o,onChange:g=>{l(g.target.value),d(!1)},onKeyDown:w,onPaste:v,onBlur:()=>{o.trim()&&m(o)},placeholder:h.length===0?i??S:""})]})}function Yx({id:e,options:t,value:n,onChange:r,disabled:a}){const i=n?n.split(",").map(l=>l.trim()).filter(Boolean):[],o=l=>{const c=i.includes(l)?i.filter(d=>d!==l):[...i,l];r(c.join(","))};return s.jsx("div",{className:"checkbox-group",id:e,children:t.map(l=>s.jsxs("label",{className:`checkbox-pill${i.includes(l)?" checkbox-pill-selected":""}`,children:[s.jsx("input",{type:"checkbox",checked:i.includes(l),onChange:()=>o(l),disabled:a}),s.jsx("span",{children:l})]},l))})}function Au({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:a,readOnly:i,twoColumn:o,discoveryIntegrationId:l,onLabels:c}){const d=Bx(e,t),f=`${a}-field-${e}`,h=s.jsx(s.Fragment,{children:Ux(t)?s.jsx(Yx,{id:f,options:t.enum,value:n,onChange:m=>r(e,m),disabled:i}):(()=>{const m=t.boundType;return(m==null?void 0:m.kind)==="enum"&&Array.isArray(m.values)})()?s.jsxs("select",{id:f,className:"form-select",value:n,onChange:m=>r(e,m.target.value),disabled:i,children:[s.jsx("option",{value:"",children:"Select..."}),t.boundType.values.map(m=>s.jsx("option",{value:m,children:m},m))]}):"enum"in t&&t.enum?s.jsxs("select",{id:f,className:"form-select",value:n,onChange:m=>r(e,m.target.value),disabled:i,children:[s.jsx("option",{value:"",children:"Select..."}),t.enum.map(m=>s.jsx("option",{value:m,children:m},m))]}):t.type==="number"?s.jsx(Gx,{id:f,value:n,onChange:m=>r(e,m),disabled:i,unit:t.unit,min:ac(t),max:Ym(t)}):Dx(t)?s.jsx(Kx,{id:f,value:n,onChange:m=>r(e,m),disabled:i,format:t.format}):l?s.jsx(Mx,{integrationId:l,field:e,value:n,onChange:m=>r(e,m),disabled:i,onLabels:m=>c==null?void 0:c(e,m)}):s.jsx("input",{id:f,className:"form-input",type:"text",value:n,onChange:m=>r(e,m.target.value),disabled:i})});return o?s.jsxs("div",{className:"bounds-field-row",children:[s.jsx("div",{className:"bounds-field-label",children:s.jsx(Pu,{htmlFor:f,label:d,description:t.description})}),s.jsx("div",{className:"bounds-field-input",children:h})]},`${a}-${e}`):s.jsxs("div",{className:"form-group",children:[s.jsx(Pu,{htmlFor:f,label:d,description:t.description}),h]},`${a}-${e}`)}function Qx(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 i=!1;for(const[o,l]of Object.entries(n)){const c=e[o];if(c===""||c===void 0)continue;const d=Number(c);if(!isNaN(d)&&d>l){i=!0;break}}return i?r?"above-approvers":"hard-ceiling":"within-cap"}function Jx(e,t){const n=new Set;if(!t)return n;for(const[r,a]of Object.entries(t)){const i=e[r];if(i===""||i===void 0)continue;const o=Number(i);!isNaN(o)&&o>a&&n.add(r)}return n}function Xx({profile:e,onConfirm:t,onCancel:n,readOnly:r,initialBounds:a,initialContext:i,initialFrame:o,profileConfig:l,approverNames:c,adminName:d}){const f=e.boundsSchema??e.frameSchema,h=e.contextSchema,m=f?Object.entries(f.fields).filter(([R,$])=>!(R==="profile"||R==="path"||$.enforced===!1||$.enforcedBy==="gatekeeper")):[],x=f?Object.entries(f.fields).filter(([,R])=>R.enforcedBy==="gatekeeper").filter(([,R])=>R.enforced!==!1).map(([R,$])=>$.displayName??R):[],w=h&&h.keyOrder.length>0?Object.entries(h.fields):[],v=a??o??{},S=i??{},g={};for(const[R,$]of m)g[R]=Fx($,v[R]);const p={};for(const[R]of w)p[R]=S[R]!==void 0?String(S[R]):"";const[y,j]=u.useState(g),[b,C]=u.useState(p),[N,I]=u.useState({}),[E,A]=u.useState(null);u.useEffect(()=>{const R=Ox(e.id);T.getIntegrationManifests().then(({manifests:$})=>{const Y=$.find(te=>te.profile===R&&te.contextDiscovery&&Object.keys(te.contextDiscovery).length>0);A(Y??null)}).catch(()=>A(null))},[e.id]);const D=Qx(y,l),L=Jx(y,l==null?void 0:l.caps),K=(R,$)=>{j(Y=>({...Y,[R]:$}))},z=(R,$)=>{C(Y=>({...Y,[R]:$}))},Q=()=>{const R={profile:e.id};for(const[Y,te]of m)te.type==="number"?R[Y]=Iu(te,y[Y]):R[Y]=y[Y];const $={};for(const[Y,te]of w)te.type==="number"?$[Y]=b[Y]===""?0:Number(b[Y]):$[Y]=b[Y];return[R,$]},H=()=>{const[R,$]=Q();t(R,$,N)},O=()=>{const R=(l==null?void 0:l.caps)??{},$={...y};for(const ne of L)R[ne]!==void 0&&($[ne]=String(R[ne]));j($);const Y={profile:e.id};for(const[ne,de]of m)de.type==="number"?Y[ne]=Iu(de,$[ne]??""):Y[ne]=$[ne]??"";const te={};for(const[ne,de]of w)de.type==="number"?te[ne]=b[ne]===""?0:Number(b[ne]):te[ne]=b[ne];t(Y,te,N)},_=R=>{const $=l==null?void 0:l.caps;if(!$||$[R]===void 0)return null;const Y=$[R],te=L.has(R);return D==="hard-ceiling"&&te?s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Y," — exceeds team ceiling"]}):D==="above-approvers"&&te?s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Y," — above cap"]}):s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Y," ok"]})},P=()=>{var R;if(D==="no-config")return null;if(D==="approvers-dormant"){const $=c&&c.length>0?c.join(", "):"the configured approvers";return s.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:[s.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",$]}),s.jsxs("div",{children:["No caps are set on this profile, so ",$," won't gate any action under this mandate. 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(D==="within-cap")return s.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:s.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(D==="above-approvers"){const $=c&&c.length>0?c.join(", "):"the required approvers";return s.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:[s.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),s.jsxs("div",{children:[s.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",$,". Within-cap actions run per the mode you choose."]})]})}if(D==="hard-ceiling"){const $=Array.from(L)[0],Y=$?(R=l==null?void 0:l.caps)==null?void 0:R[$]:void 0,te=d??"the team admin";return s.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:[s.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),s.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",Y??"the configured limit",". Lower your bound or ask ",te," to add an approver path above the cap."]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:O,children:"Save below cap"}),n&&s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},V=D==="hard-ceiling";return s.jsxs("div",{children:[w.length>0&&s.jsxs("div",{className:"context-section",children:[s.jsxs("div",{className:"bounds-section-header",children:[s.jsx("span",{className:"bounds-section-icon",children:"🛡"}),s.jsxs("div",{children:[s.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),s.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),w.map(([R,$])=>{var te;const Y=!!((te=E==null?void 0:E.contextDiscovery)!=null&&te[R]);return s.jsx(Au,{fieldKey:R,fieldDef:$,value:b[R],onChange:z,prefix:"context",readOnly:r,discoveryIntegrationId:Y?E.id:void 0,onLabels:(ne,de)=>I(xe=>({...xe,[ne]:de}))},`context-${R}`)})]}),m.length>0&&s.jsxs("div",{className:"bounds-section",children:[s.jsxs("div",{className:"bounds-section-header",children:[s.jsx("span",{className:"bounds-section-icon",children:"🔒"}),s.jsxs("div",{children:[s.jsx("div",{className:"bounds-section-title",children:"Limits"}),s.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),s.jsx("div",{className:"bounds-fields-grid",children:m.map(([R,$])=>{var Y;return s.jsxs("div",{style:{display:"contents"},children:[s.jsx(Au,{fieldKey:R,fieldDef:$,value:y[R],onChange:K,prefix:"bounds",readOnly:r,twoColumn:!0}),D!=="no-config"&&((Y=l==null?void 0:l.caps)==null?void 0:Y[R])!==void 0&&s.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:_(R)})]},`bounds-${R}`)})}),P(),x.length>0&&s.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"," ",s.jsx(tt,{to:"/integrations",children:"Integrations"}),"."]})]}),s.jsx("button",{className:"btn btn-primary",onClick:H,disabled:V,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function qx(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 Zx(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const e0="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 Ma({target:e,currentText:t,onApply:n,greeting:r,placeholder:a,title:i}){const[o,l]=u.useState([{role:"assistant",content:r??e0}]),[c,d]=u.useState(""),[f,h]=u.useState(!1),[m,x]=u.useState(null),w=u.useRef(null),v=u.useRef(null);u.useEffect(()=>{const p=w.current;if(!p)return;const y=o[o.length-1],j=v.current;!f&&(y==null?void 0:y.role)==="assistant"&&o.length>1&&j?p.scrollTop=j.offsetTop:p.scrollTop=p.scrollHeight},[o,f]);const S=async()=>{const p=c.trim();if(!p||f)return;const y=[...o,{role:"user",content:p}];l(y),d(""),x(null),h(!0);try{const j=await T.aiChat({target:e,currentText:t,messages:y.filter((b,C)=>!(C===0&&b.role==="assistant"))});j.success&&j.reply?l(b=>[...b,{role:"assistant",content:j.reply}]):x(j.error??"AI returned no reply")}catch(j){x(j instanceof Error?j.message:"Chat failed")}finally{h(!1)}},g=p=>{p.key==="Enter"&&!p.shiftKey&&!p.nativeEvent.isComposing&&(p.preventDefault(),S())};return s.jsxs("div",{className:"intent-chat",children:[s.jsx("h3",{className:"card-title",children:i??"AI Assistant"}),s.jsxs("div",{ref:w,className:"chat-messages",children:[o.map((p,y)=>{const j=p.role==="assistant"?qx(p.content):null,b=j?Zx(p.content):p.content;return s.jsx("div",{className:`chat-msg ${p.role}`,ref:y===o.length-1?v:void 0,children:s.jsxs("div",{className:"chat-msg-body",children:[b&&s.jsx("div",{className:"chat-msg-prose",children:b}),j!==null&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"chat-fenced-block",children:j}),s.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(j),children:"Apply this draft"})]})]})},y)}),f&&s.jsx("div",{className:"chat-msg assistant",children:s.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),m&&s.jsx("div",{className:"error-message",children:m}),s.jsxs("div",{className:"chat-composer",children:[s.jsxs("div",{className:"chat-composer-pill",children:[s.jsx("textarea",{className:"chat-input",value:c,onChange:p=>d(p.target.value),onKeyDown:g,placeholder:a??"Ask for help articulating the intent…",rows:1,disabled:f}),s.jsx("button",{type:"button",className:"chat-send-btn",onClick:S,disabled:f||!c.trim(),"aria-label":"Send",children:"↑"})]}),s.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Jm({open:e,onClose:t,children:n,ariaLabel:r}){const a=u.useRef(null),i=u.useRef(null);return u.useEffect(()=>{var l;if(!e)return;i.current=document.activeElement,document.body.style.overflow="hidden";const o=c=>{c.key==="Escape"&&t()};return document.addEventListener("keydown",o),(l=a.current)==null||l.focus(),()=>{document.removeEventListener("keydown",o),document.body.style.overflow="",i.current instanceof HTMLElement&&i.current.focus()}},[e,t]),lm.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:t,"aria-hidden":"true"}),s.jsxs("aside",{ref:a,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":r,tabIndex:-1,children:[s.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),s.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:t,"aria-label":"Close",children:"×"}),n]})]}),document.body)}function t0(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function n0(e,t,n){if(t.length===0)return[{text:e,label:e,matched:null}];const r=[],a=new Set;for(const c of t)if(!(!c.scope||c.scope==="all (unscoped)"))for(const d of[c.scope,...c.scope.split(",").map(f=>f.trim())]){const f=d.toLowerCase();d&&!a.has(f)&&(a.add(f),r.push(d))}r.sort((c,d)=>d.length-c.length);const i=c=>{const d=c.toLowerCase();return t.filter(f=>{var h,m;return((h=f.scope)==null?void 0:h.toLowerCase())===d||((m=f.scope)==null?void 0:m.split(",").map(x=>x.trim().toLowerCase()).includes(d))})},o=["\\[\\d+\\]",...r.map(t0)],l=new RegExp(`(${o.join("|")})`,"gi");return e.split(l).filter(c=>c!=="").map(c=>{const d=/^\[(\d+)\]$/.exec(c);if(d){const f=t[Number(d[1])-1];if(f){const h=f.scope&&f.scope!=="all (unscoped)"?f.scope:"all recipients",m=n?`${n}: ${h}`:h;return{text:c,label:m,matched:[f]}}}else if(r.some(f=>f.toLowerCase()===c.toLowerCase())){const f=i(c);if(f.length>0)return{text:c,label:c,matched:f}}return{text:c,label:c,matched:null}})}const _u=`Why — What's the situation? Why does this need to happen?
|
|
61
61
|
|
|
62
62
|
Goal — What should the agent try to achieve?
|
|
63
63
|
|
|
64
|
-
Watch out — What should the agent avoid or be careful about?`;function
|
|
64
|
+
Watch out — What should the agent avoid or be careful about?`;function r0(e,t,n,r){return n0(e,t,r).map((a,i)=>{if(!a.matched)return s.jsx("span",{children:a.text},i);const o=a.matched;return s.jsx("button",{type:"button",onClick:()=>n(o),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:a.label},i)})}function s0(){var ee;const e=tn(),[t]=Zl(),n=Number(t.get("step"))||2,[r,a]=u.useState(null),[i,o]=u.useState(null),[l,c]=u.useState(n),[d,f]=u.useState(null),[h,m]=u.useState(null),[x,w]=u.useState({}),[v,S]=u.useState(_u),[g,p]=u.useState(!1),[y,j]=u.useState(!0),[b,C]=u.useState(null),[N,I]=u.useState([]),[E,A]=u.useState(void 0),[D,L]=u.useState(!1),[K,z]=u.useState(null),[Q,H]=u.useState(null),[O,_]=u.useState(null),[P,V]=u.useState([]),[R,$]=u.useState(null);u.useEffect(()=>{var re;const X=sessionStorage.getItem("agentAuth");if(!X){e("/mandates?new=1");return}const oe=JSON.parse(X);a(oe);const W=sessionStorage.getItem("agentGate");if(W){const se=JSON.parse(W);se.bounds&&f(se.bounds),se.context&&m(se.context),(re=se.gateContent)!=null&&re.intent&&S(se.gateContent.intent)}T.getProfile(oe.profileId).then(se=>o(se)).catch(()=>e("/mandates?new=1")).finally(()=>j(!1)),oe.groupId&&Promise.all([T.getTeamProfileConfig(oe.groupId,oe.profileId).catch(()=>null),T.getGroupById(oe.groupId).catch(()=>null),T.listUsers().catch(()=>[])]).then(([se,Ce,Ge])=>{if(C(se),se){const _e=new Map;for(const fe of Ge){const Ze=fe.name&&fe.email?`${fe.name} (${fe.email})`:fe.name||fe.email||fe.id;_e.set(fe.id,Ze)}const xt=(Ce==null?void 0:Ce.members)??[];for(const fe of xt){const Ze=fe.userId??fe.id;Ze&&(fe.name&&fe.email?_e.set(Ze,`${fe.name} (${fe.email})`):fe.name&&_e.set(Ze,fe.name))}const at=(se.approvers??[]).map(fe=>_e.get(fe)??fe);I(at);const Ke=xt.find(fe=>fe.role==="admin");if(Ke){const fe=Ke.userId??Ke.id;fe&&A(_e.get(fe)??Ke.name)}}})},[e]);const Y=d?Object.entries(d).filter(([X])=>X!=="profile"&&X!=="path").map(([X,oe])=>`${X} = ${oe}`).join(", "):"",te=(X,oe,W)=>{f(X),m(oe),W&&w(W),c(3)},ne=v.trim()!==_u.trim()&&v.trim()!=="",de=X=>{ne&&!confirm("Replace your current intent with the AI draft?")||S(X)},xe=()=>{const X=i==null?void 0:i.ttl,oe={intent:v},W=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...W,bounds:d,context:h,contextLabels:x,gateContent:oe,ttlConfig:X})),e("/mandates/new/sign")},$e=async()=>{if(r){L(!0),z(null),H(null),_(null),V([]),$(null);try{const X=await T.aiIntentReview({profileId:r.profileId,newIntent:v,context:h??void 0});V(X.grants??[]),X.success?X.review?z(X.review):H(X.note??"No other mandates on this profile to compare against."):_(X.error??"Check failed.")}catch(X){_(X instanceof Error?X.message:"Check failed.")}finally{L(!1)}}},q=X=>{S(X),(K||Q||O)&&(z(null),H(null),_(null),V([]),$(null))};return y||!r||!i?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):s.jsxs(s.Fragment,{children:[s.jsx(Km,{currentStep:l,onStepClick:X=>{X>=2&&c(X)}}),s.jsx($x,{profileId:r.profileId,bounds:Y||void 0,groupName:r.groupName,domain:r.domain}),l===2&&s.jsx("div",{className:"card",children:s.jsx(Xx,{profile:i,onConfirm:te,onCancel:()=>e("/mandates?new=1"),initialBounds:d||void 0,initialContext:h||void 0,profileConfig:b,approverNames:N,adminName:E})}),l===3&&s.jsxs("div",{className:"intent-layout",children:[s.jsx("div",{className:"card intent-pane chat tool",children:s.jsx(Ma,{target:{kind:"intent",profileId:r.profileId,bounds:Y||void 0},currentText:v,onApply:de})}),s.jsxs("div",{className:"card intent-pane document",children:[s.jsx("h3",{className:"card-title",children:"What should your agent know?"}),s.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[s.jsxs("div",{className:"field-label",children:[s.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),s.jsx("textarea",{className:"intent-textarea",value:v,onChange:X=>q(X.target.value)}),s.jsxs("div",{className:"char-counter",children:[v.length," / 2000"]})]}),s.jsxs("div",{style:{marginTop:"0.5rem"},children:[s.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:$e,disabled:D||!ne,children:D?"Checking…":"Check against my other grants"}),O&&s.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeftColor:"var(--danger)"},children:[s.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),s.jsx("div",{className:"hint-body",children:O})]}),Q&&s.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[s.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),s.jsx("div",{className:"hint-body",children:Q})]}),K&&s.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[s.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),s.jsxs("div",{className:"hint-body",children:[s.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),s.jsx("div",{style:{whiteSpace:"pre-wrap"},children:r0(K,P,$,Oe(r.profileId))}),s.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),s.jsxs("div",{className:"intent-footer",children:[s.jsx("button",{className:"btn btn-ghost",onClick:()=>c(2),children:"Back"}),s.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:xe,disabled:!ne,children:"Continue to Review"})]}),(((ee=b==null?void 0:b.approvers)==null?void 0:ee.length)??0)>0&&s.jsxs("div",{className:"hint-box",role:"note",children:[s.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),s.jsxs("div",{className:"hint-body",children:[s.jsxs("div",{className:"hint-head",children:["Visible to ",N.length>0?N.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",N.length>0?N.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),s.jsx("button",{type:"button",className:"floating-help",onClick:()=>p(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),s.jsx(Jm,{open:g,onClose:()=>p(!1),ariaLabel:"Intent assistant",children:s.jsx(Ma,{target:{kind:"intent",profileId:r.profileId,bounds:Y||void 0},currentText:v,onApply:X=>{de(X),p(!1)}})}),R&&s.jsx("div",{className:"modal-backdrop",onClick:X=>X.target===X.currentTarget&&$(null),children:s.jsxs("div",{className:"modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:R.length>1?`Existing mandates (${R.length})`:"Existing mandate"}),s.jsx("button",{className:"modal-close",onClick:()=>$(null),children:"×"})]}),s.jsx("div",{className:"modal-body",children:R.map((X,oe)=>{var W;return s.jsxs("div",{style:{marginBottom:oe<R.length-1?"1rem":0,paddingBottom:oe<R.length-1?"1rem":0,borderBottom:oe<R.length-1?"1px solid var(--border)":"none"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),s.jsx("div",{style:{marginBottom:"0.75rem"},children:X.scope}),s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),s.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((W=X.intent)==null?void 0:W.trim())||"(no intent recorded)"}),Object.entries(X.bounds).filter(([re])=>re!=="profile"&&re!=="path").length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),s.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(X.bounds).filter(([re])=>re!=="profile"&&re!=="path").map(([re,se])=>`${re}: ${se}`).join(" · ")})]})]},oe)})})]})})]})]})}function a0(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
65
65
|
`).split(`
|
|
66
66
|
`).map(a=>a.replace(/[ \t]+$/,"")).join(`
|
|
67
|
-
`).replace(/\n+$/,"")}async function
|
|
68
|
-
`)||o.includes("\r"))throw new
|
|
69
|
-
`)}async function ca(e,t){const n=t.boundsSchema??t.frameSchema;if(!n)throw new Error("Profile has no boundsSchema or frameSchema");const r=Dm(e,n.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await Bm(r)}`}async function Um(e,t){const n=t.contextSchema?Dm(e,t.contextSchema.keyOrder,"CONTEXT_INVALID_VALUE"):"";return`sha256:${await Bm(n)}`}async function Ma(e){const t=new TextEncoder().encode(Vx(e)),n=await crypto.subtle.digest("SHA-256",t);return`sha256:${Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}`}function Wm(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 Yx(e){const t=e.commitment_modes;return t===void 0?["review","automatic"]:Array.isArray(t)?["review","automatic"].filter(n=>t.includes(n)):[]}function Qx(e){return e==="per-action"?"review":"automatic"}function Cu(e){return e?Yx(e).map(t=>t==="review"?"per-action":"immediate"):["per-action","immediate"]}function Jx(e,t){return t.includes(e)?e:t[0]??null}function Eu(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function Xx(e,t){for(const n of e)if(t.has(n))return!0;return!1}function qx(e,t,n){for(const r of e){const a=Eu(t[r]),i=Eu(n[r]);if(!(a.size===0||i.size===0)&&!Xx(a,i))return!1}return!0}function Zx(e){return e.length>24?`${e.slice(0,10)}…`:e}function Hm(e,t,n){const r=n==null?void 0:n[e];return String(t).split(",").map(i=>i.trim()).filter(Boolean).map(i=>{const o=r==null?void 0:r[i];return o?`${o} (${Zx(i)})`:i}).join(", ")}function Vm(e){var n;if(e.isPersonal)return{can:!0};if(!e.configLoaded)return{can:!0};const t=e.teamName?`"${e.teamName}"`:"this team";return(((n=e.approvers)==null?void 0:n.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${t}.`,fix:`A team admin names who may give ${e.profileName} mandates.`}:!e.userId||!e.approvers.includes(e.userId)?{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${e.profileName}'s approvers in ${t} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}:{can:!0}}function e0(){var G,ae;const e=tn(),{user:t,mode:n,domain:r}=Ue(),[a,i]=u.useState(null),[o,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState("per-action"),[p,x]=u.useState(1800),[w,v]=u.useState(86400),[S,g]=u.useState(""),[h,y]=u.useState("hours"),[j,b]=u.useState(""),[C,N]=u.useState(!0),[I,E]=u.useState(!1);u.useEffect(()=>{T.getIdentityDisclosure().then(U=>E(U.always)).catch(()=>{})},[]);const[A,D]=u.useState(!1),[z,K]=u.useState(""),[$,Q]=u.useState(null),[H,O]=u.useState([]),[_,P]=u.useState(!1),[V,R]=u.useState([]),[L,Y]=u.useState(0);u.useEffect(()=>{var Nn;const U=sessionStorage.getItem("agentAuth"),pe=sessionStorage.getItem("agentGate");if(!U||!pe){e("/mandates?new=1");return}const Pe=JSON.parse(U),ke=JSON.parse(pe),Ye={bounds:ke.bounds??{},context:ke.context??{},contextLabels:ke.contextLabels??void 0,gateContent:ke.gateContent};i(Pe),l(Ye),ke.ttlConfig&&(x(ke.ttlConfig.default??1800),v(ke.ttlConfig.max??86400)),ke.templateMode==="automatic"?m("immediate"):ke.templateMode==="review"&&m("per-action");const bn=((Nn=ke.ttlConfig)==null?void 0:Nn.max)??86400;if(typeof ke.templateTtl=="number"&&ke.templateTtl>0){const F=Math.min(ke.templateTtl,bn);x(F),[3600,86400,604800,2592e3,31536e3].includes(F)||(F%86400===0?(g(String(F/86400)),y("days")):(g(String(Math.max(1,Math.round(F/3600)))),y("hours")))}T.getProfile(Pe.profileId).then(F=>{var Z;if(d(F),!j){const ie=F.name??((Z=Pe.profileId.split("/").pop())==null?void 0:Z.replace(/@.*$/,""))??"",ue=[];if(Ye.context&&F.contextSchema)for(const Ee of F.contextSchema.keyOrder){const le=Ye.context[Ee];if(le!==void 0&&le!==""){const wt=String(le).split(",").map(ai=>ai.trim()).filter(Boolean);ue.push(wt.join(", "))}}const ge=ue.length>0?`${ie}: ${ue.join(" · ")}`:ie;b(ge)}}).catch(()=>{}),Pe.isPersonal?P(!0):Promise.all([T.getTeamProfileConfig(Pe.groupId,Pe.profileId).catch(()=>null),T.getGroupById(Pe.groupId).catch(()=>null),T.listUsers().catch(()=>[])]).then(([F,Z,ie])=>{if(Q(F),F){const ue=new Map;for(const le of ie){const wt=le.name&&le.email?`${le.name} (${le.email})`:le.name||le.email||le.id;ue.set(le.id,wt)}const ge=(Z==null?void 0:Z.members)??[];for(const le of ge){const wt=le.userId??le.id;wt&&(le.name&&le.email?ue.set(wt,`${le.name} (${le.email})`):le.name&&ue.set(wt,le.name))}const Ee=(F.approvers??[]).map(le=>ue.get(le)??le);O(Ee)}}).finally(()=>{P(!0)})},[e]),u.useEffect(()=>{if(!(a!=null&&a.profileId))return;const U=a.profileId,pe=sessionStorage.getItem("agentEditReplaces");T.getEnrichedAuthorizations().then(Pe=>{const ke=Pe.filter(Ye=>Ye.profileId===U&&Ye.authorizationId!==pe).map(Ye=>({authorizationId:Ye.authorizationId,bounds:Ye.bounds,context:Ye.context??{},intent:Ye.intent}));R(ke)}).catch(()=>R([]))},[a==null?void 0:a.profileId]),u.useEffect(()=>{if(!c)return;const U=Jx(f,Cu(c));U&&U!==f&&m(U)},[c,f]),u.useEffect(()=>{if(!o||!c||V.length===0){Y(0);return}let U=!1;return(async()=>{const pe=await ca(o.bounds,c),Pe=await Promise.all(V.map(ke=>ca(ke.bounds,c).catch(()=>null)));U||Y(Pe.filter(ke=>ke===pe).length)})().catch(()=>{U||Y(0)}),()=>{U=!0}},[o,c,V]);const te=async()=>{if(!(!a||!o||!c||!t)){if(!a.groupId){K("No active group; cannot create mandate.");return}D(!0),K("");try{const U=r||a.domain||"owner",pe=await ca(o.bounds,c),Pe=await Um(o.context,c),[ke,Ye]=await Promise.all([Ma(o.gateContent.intent),Ma(JSON.stringify({profile:a.profileId,domain:U,group:a.groupId}))]);let bn,Nn,F,Z;if(a.isTeam){const Ee=await T.getApproversPubkeys(a.groupId,a.profileId);if(Ee.length>0){const le=await T.encryptIntent(o.gateContent.intent,Ee);bn=le.intentCiphertext,Nn=le.encryptedKeys,F=le.approversFrozen,Z=le.intentDisclosureHash}}const ie=`authz_${crypto.randomUUID()}`,ue=sessionStorage.getItem("agentEditReplaces")||void 0,ge=await T.attest({authorization_id:ie,replaces:ue,profile_id:a.profileId,bounds:o.bounds,bounds_hash:pe,context_hash:Pe,domain:U,did:t.did,gate_content_hashes:{intent:ke},execution_context_hash:Ye,group_id:a.groupId,ttl:p,commitment_mode:Qx(f),title:j.trim(),intent_ciphertext:bn,encrypted_keys:Nn,approvers_frozen:F,intent_disclosure_hash:Z,disclose_identity:C});try{await T.pushGateContent(Wm(ge,{boundsHash:pe,contextHash:Pe,context:o.context,contextLabels:o.contextLabels,gateContent:o.gateContent}))}catch(Ee){try{await T.revokeAttestation(ie,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${Ee instanceof Error?Ee.message:"Unknown error"})`)}if(ue)try{await T.revokeAttestation(ue,`Replaced by ${ie} (edit)`),T.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/mandates?highlight=${encodeURIComponent(ie)}`)}catch(U){K(U instanceof Error?U.message:"Signing the mandate failed")}finally{D(!1)}}};if(!a||!o)return s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const ne=Object.entries(o.bounds).filter(([U])=>U!=="profile"&&U!=="path"),de=Object.entries(o.context),Le=(($==null?void 0:$.caps)!=null?Object.keys($.caps):[]).length!==0,q=H.length>0?H.join(", "):(($==null?void 0:$.approvers)??[]).join(", "),ee=Le?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${q}, 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.",X=Le?`Over-cap actions will be reviewed by you and ${q}. Within-cap actions run per the mode you chose above.`:`Approvers ${q} can read your intent but won't gate any action — no caps configured on this profile.`,oe=!!((G=$==null?void 0:$.approvers)!=null&&G.length),W=Vm({isPersonal:a.isPersonal,configLoaded:_,approvers:$==null?void 0:$.approvers,userId:t==null?void 0:t.id,profileName:Oe(a.profileId),teamName:a.groupName}),re=!W.can,se=Cu(c),Ce=se.length===0,Ge=p>w,_e={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"},xt={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"},at=((ae=c==null?void 0:c.contextSchema)==null?void 0:ae.keyOrder)??[],Ke=V.filter(U=>qx(at,o.context,U.context)),fe=Ke.length>0,Ze=Oe(a.profileId),nn=U=>{const pe=Object.values(U).map(Pe=>String(Pe).trim()).filter(Boolean);return pe.length>0?pe.join(", "):"all (unscoped)"},k=Ke.map(U=>nn(U.context)).join("; "),B=`This grant's scope overlaps an existing grant on ${Ze} (scoped to: ${k}). 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 s.jsxs(s.Fragment,{children:[s.jsx(Lm,{currentStep:4,onStepClick:U=>{U<=3&&e(`/mandates/new/intent?step=${U}`)}}),s.jsxs("div",{className:"card",children:[s.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),s.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),z&&s.jsx("div",{className:"error-message",children:z}),s.jsxs("div",{className:"field-editable",children:[s.jsxs("div",{className:"field-label",children:[s.jsx("span",{className:"pen",children:"✎"})," Title"]}),s.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Oe(a.profileId)}: daily operations`,value:j,onChange:U=>b(U.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),s.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),s.jsxs("div",{className:"field-editable",children:[s.jsxs("div",{className:"field-label",children:[s.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),s.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[se.includes("per-action")&&s.jsxs("button",{onClick:()=>m("per-action"),style:xt,children:[s.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),se.includes("immediate")&&s.jsxs("button",{onClick:()=>m("immediate"),style:_e,children:[s.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]}),se.length===1&&s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:se[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Ce&&s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--danger)",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),s.jsxs("div",{className:"field-editable",children:[s.jsxs("div",{className:"field-label",children:[s.jsx("span",{className:"pen",children:"✎"})," Duration"]}),s.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(U=>U.seconds<=w).map(U=>s.jsx("button",{onClick:()=>{x(U.seconds),g("")},style:{padding:"0.5rem 0.85rem",border:p===U.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:p===U.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:U.label},U.seconds)),s.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[s.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:S,onChange:U=>{g(U.target.value);const pe=parseInt(U.target.value,10);if(pe>0){const Pe=h==="days"?pe*86400:pe*3600;x(Math.min(Pe,w))}}}),s.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:h,onChange:U=>{y(U.target.value);const pe=parseInt(S,10);if(pe>0){const Pe=U.target.value==="days"?pe*86400:pe*3600;x(Math.min(Pe,w))}},children:[s.jsx("option",{value:"hours",children:"hours"}),s.jsx("option",{value:"days",children:"days"})]})]}),Ge&&s.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",w>=86400?`${Math.floor(w/86400)} days`:`${Math.floor(w/3600)} hours`]})]})]}),s.jsx("div",{className:"field-editable",children:s.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[s.jsx("input",{type:"checkbox",checked:I||C,disabled:I,onChange:U=>N(U.target.checked),style:{marginTop:"0.15rem"}}),s.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",s.jsxs("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.',I&&" Always on — you chose this in Settings."]})]})]})}),s.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),s.jsxs("div",{className:"info-block",children:[s.jsxs("div",{className:"info-head",children:[s.jsx("span",{className:"info-title",children:"Intent"}),s.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),s.jsx("div",{style:{whiteSpace:"pre-wrap"},children:o.gateContent.intent})]}),(!!ne.length||!!de.length)&&s.jsxs("div",{className:"info-block",children:[s.jsxs("div",{className:"info-head",children:[s.jsx("span",{className:"info-title",children:"Scope & Limits"}),s.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),s.jsxs("dl",{className:"info-kv",children:[de.map(([U,pe])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:U}),s.jsx("dd",{children:Hm(U,pe,o.contextLabels)})]},U)),ne.map(([U,pe])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:U}),s.jsx("dd",{children:String(pe)})]},U))]})]}),s.jsxs("div",{className:"info-block",children:[s.jsx("div",{className:"info-head",children:s.jsx("span",{className:"info-title",children:"Authority"})}),s.jsxs("dl",{className:"info-kv",children:[s.jsx("dt",{children:"Profile"}),s.jsxs("dd",{children:[Oe(a.profileId),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:a.profileId})]}),!a.isPersonal&&a.groupName&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Team"}),s.jsx("dd",{children:a.groupName})]}),!a.isPersonal&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Approvers"}),s.jsx("dd",{children:_?W.can?s.jsxs(s.Fragment,{children:[q,s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:ee})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{color:"var(--danger)",fontWeight:600},children:W.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${a.groupName??"this team"}`:"You cannot give this mandate"}),W.code==="OWNER_NOT_APPROVER"&&s.jsx("div",{children:q}),s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[W.reason," ",W.fix]})]}):s.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),L>0?s.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:[s.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),s.jsxs("div",{children:[L===1?`An active grant on ${Ze} already has exactly these limits.`:`${L} active grants on ${Ze} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",s.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,fe?s.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:[s.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),s.jsx("div",{children:B})]})]}):null,s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/mandates/new/intent"),children:"Back"}),s.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:te,disabled:A||!j.trim()||re||Ce,children:A?"Signing...":f==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),s.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:oe?"block":"none"},children:X})]})]})}const t0={card:"💳",mail:"✉️"};function Gm(e){return t0[e]??"🔧"}function n0(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 r0=[0,7,30,90,365,3650];function Gs(e){return e===null?"From your mandate":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 s0(e){return(e==null?void 0:e.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:e&&!e.running&&e.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function Di({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:a}){var nn;const[i,o]=u.useState({}),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[m,p]=u.useState({}),[x,w]=u.useState({}),[v,S]=u.useState(void 0),[g,h]=u.useState(!1),[y,j]=u.useState(null),[b,C]=u.useState(!1),[N,I]=u.useState(!1),[E,A]=u.useState(!1),[D,z]=u.useState(!1),[K,$]=u.useState({}),[Q,H]=u.useState(null),[O,_]=u.useState(!1),[P,V]=u.useState(null),[R,L]=u.useState(!1);u.useEffect(()=>{let k=!1;return T.getCredential(e.id).then(B=>{var G;if(!(k||!B.configured)){if(c(!0),f(!0),B.fields){const ae={};for(const U of e.credentials.fields)B.fields[U.key]!=null&&(ae[U.key]=B.fields[U.key]);p(ae)}if(w(B.secrets??{}),S(B.updatedAt),e.oauth){const ae=((G=B.fieldNames)==null?void 0:G.includes(e.oauth.tokenStorage))??!1;h(ae),ae&&T.getOAuthHealth(e.id).then(U=>{k||j(U)})}}}).catch(()=>{}),()=>{k=!0}},[e.id,e.oauth]);const Y=n0(e.toolGating),te=t?t.readAgeDays??null:void 0,ne=O&&Q?Q.value:te,de=async k=>{H({value:k}),_(!0),V(null);try{await T.setReadPolicy(e.id,k),a(k===null?`${e.name} read window now follows your mandate`:`${e.name} read window set to ${Gs(k).toLowerCase()}`),r()}catch(B){V(B instanceof Error?B.message:"Could not save")}finally{_(!1),H(null)}},xe=!!e.oauth||e.credentials.fields.some(k=>!k.optional),Le=e.oauth?g:l,q=!xe||Le,ee=n==="starting"?"starting":q?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!g?"needs-oauth":"unconfigured",X=async()=>{if(e.credentials.fields.some(B=>{var G;return(G=i[B.key])==null?void 0:G.trim()})){C(!0);try{await T.setCredential(e.id,i),c(!0),o({}),e.oauth?a(`${e.name} credentials saved!`):(a(`${e.name} credentials saved — starting integration...`),await Ce())}catch{a(`Failed to save ${e.name} credentials`)}finally{C(!1)}}},oe=()=>{const k={};for(const B of e.credentials.fields){const G=i[B.key];B.type==="password"?G!=null&&G.trim()&&(k[B.key]=G):G!=null&&G!==(m[B.key]??"")&&(k[B.key]=G)}return k},W=Object.keys(oe()).length>0,re=async()=>{const k=oe();if(Object.keys(k).length!==0){C(!0);try{await T.setCredential(e.id,k),o({}),c(!0),e.oauth?a(`${e.name} credentials saved — now click Connect.`):(z(!1),a(`${e.name} credentials updated — restarting...`),await Ce())}catch{a(`Failed to update ${e.name} credentials`)}finally{C(!1)}}},se=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const k=setInterval(async()=>{var B;try{const G=await T.getCredential(e.id);G.configured&&e.oauth&&((B=G.fieldNames)!=null&&B.includes(e.oauth.tokenStorage))&&(h(!0),z(!1),j(null),clearInterval(k),a(`${e.name} connected — starting integration...`),T.getOAuthHealth(e.id).then(j).catch(()=>{}),await Ce())}catch{}},2e3);setTimeout(()=>clearInterval(k),12e4)},Ce=async()=>{A(!0);try{const k=await T.activateIntegration(e.id);k.warning?a(k.warning):a(`${e.name} integration started with ${k.tools.length} tools`),r()}catch(k){a(`Failed to start ${e.name}: ${k instanceof Error?k.message:"Unknown error"}`)}finally{A(!1)}},Ge=async()=>{try{await T.removeMcpIntegration(e.id),a(`${e.name} integration removed`),r()}catch{a(`Failed to remove ${e.name}`)}},_e=Gm(e.icon),xt=s0(t),at=ee==="running"?{c:"int-chip-ok",t:"Running"}:ee==="starting"?{c:"int-chip-idle",t:"Starting"}:xt.chip,Ke=e.oauth&&g&&(y==null?void 0:y.status)==="failed",fe=xe?Ke?{c:"int-chip-bad",t:"Auth failed"}:Le?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},Ze=k=>k.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return s.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[s.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:_e}),s.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:e.name}),s.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[ee!=="unconfigured"&&ee!=="needs-oauth"&&s.jsxs("span",{className:`int-chip ${at.c}`,children:[s.jsx("span",{className:"int-dot"}),at.t]}),s.jsxs("span",{className:`int-chip ${fe.c}`,children:[s.jsx("span",{className:"int-dot"}),fe.t]}),hx(e,m)&&s.jsxs("span",{className:"int-chip int-chip-sim",title:"This connector answers from a simulated system with test data. Nothing reaches your real systems.",children:[s.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),e.oauth&&g&&s.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:y!=null&&y.account?s.jsxs(s.Fragment,{children:["Connected as ",s.jsx("b",{children:y.account})]}):s.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),Ke&&!D&&s.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:[s.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[e.name," stopped accepting the stored credentials"]}),s.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[(y==null?void 0:y.error)==="invalid_grant"?s.jsxs(s.Fragment,{children:["The refresh token was revoked (",s.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):y!=null&&y.error?s.jsxs(s.Fragment,{children:["The provider reported ",s.jsx("code",{children:y.error}),"."]}):s.jsx(s.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",e.name," actions are ",s.jsx("b",{children:"blocked"}),", not failing silently."]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[s.jsxs("button",{className:"btn btn-primary btn-sm",onClick:se,children:["Reconnect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{o({...m}),z(!0)},children:"Edit credentials"})]})]}),s.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[s.jsx("summary",{children:"Details"}),s.jsxs("div",{className:"int-meta",children:[s.jsx("span",{className:"int-k",children:"What"}),s.jsx("span",{children:e.description}),e.profile&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"int-k",children:"Profile"}),s.jsx("span",{children:e.profile})]}),e.oauth&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"int-k",children:"Scopes"}),s.jsx("span",{children:((nn=e.oauth.scopes)==null?void 0:nn.join(", "))||"—"})]}),t&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"int-k",children:"Tools"}),s.jsxs("span",{children:[t.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(ee!=="running"||Ke)&&s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsxs("button",{onClick:()=>I(!N),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[s.jsx("span",{style:{transition:"transform 0.2s",transform:N?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),N&&s.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((k,B)=>s.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[s.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:B+1}),s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:k.title}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[Ze(k.description),k.link&&s.jsxs(s.Fragment,{children:[" ",s.jsxs("a",{href:k.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},B))})]}),ee==="starting"&&s.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[s.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),D&&s.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[s.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),d&&s.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(k=>{var B;return s.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[s.jsx("label",{className:"form-label",children:k.label}),k.type==="password"?s.jsxs("div",{className:"cred-field",children:[s.jsx("input",{className:"form-input",type:K[k.key]?"text":"password",name:`${e.id}-${k.key}-credential`,autoComplete:"new-password",placeholder:(B=x[k.key])!=null&&B.preview?`Unchanged — ends in ${x[k.key].preview}`:d?"Unchanged — paste a new value to replace":k.placeholder,value:i[k.key]||"",onChange:G=>o(ae=>({...ae,[k.key]:G.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>$(G=>({...G,[k.key]:!G[k.key]})),children:K[k.key]?"hide":"show"})]}):s.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${k.key}-credential`,autoComplete:"off",placeholder:k.placeholder,value:i[k.key]||"",onChange:G=>o(ae=>({...ae,[k.key]:G.target.value}))})]},k.key)}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[s.jsx("button",{className:"btn btn-primary btn-sm",onClick:re,disabled:b||!W,children:b?"Saving…":"Save"}),!W&&!b&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),e.oauth&&s.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:se,children:["Connect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{z(!1),o({})},children:"Cancel"})]})]}),!D&&ee==="running"&&t&&s.jsxs(s.Fragment,{children:[(Object.keys(m).length>0||Object.keys(x).length>0)&&s.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:e.credentials.fields.map(k=>{const B=k.type==="password",G=x[k.key];return!B&&m[k.key]==null||B&&G==null?null:s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[s.jsx("span",{style:{color:"var(--text-muted)"},children:k.label}),s.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[B?G.preview??"set":m[k.key],B&&v&&s.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(v).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},k.key)})}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx(tt,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(e.credentials.fields.length>0||e.oauth)&&s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{o({...m}),z(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),s.jsx("span",{style:{flex:1}}),s.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:Ge,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"})]}),Y&&ne!==void 0&&!R&&s.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[s.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),s.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:ne===null?"window from your mandate":Gs(ne).toLowerCase()}),O&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),P&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:P})]}),s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>L(!0),children:"Edit"})]})}),Y&&ne!==void 0&&R&&s.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[s.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),s.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>L(!1),children:"Done"})]}),s.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new mandate."}),s.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[r0.map(k=>{const B=ne===k;return s.jsx("button",{className:`btn btn-sm ${B?"btn-primary":"btn-secondary"}`,"aria-pressed":B,disabled:O,onClick:()=>de(k),children:Gs(k)},k)}),s.jsx("button",{className:`btn btn-sm ${ne===null?"btn-primary":"btn-ghost"}`,"aria-pressed":ne===null,disabled:O,onClick:()=>de(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:Gs(null)})]}),s.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:P?s.jsx("span",{style:{color:"var(--danger)"},children:P}):O?s.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):ne===null?s.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):ne===0?s.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):s.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",ne," days is blocked, whoever it is from."]})})]}),s.jsx("div",{style:{display:"none"},children:s.jsx(tt,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),ee==="unconfigured"&&(()=>{const k=e.credentials.fields.every(ae=>ae.optional),B=e.credentials.fields.some(ae=>!ae.optional),G=e.credentials.fields.some(ae=>{var U;return(U=i[ae.key])==null?void 0:U.trim()});return s.jsxs(s.Fragment,{children:[d&&s.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:[s.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"," ",s.jsx("button",{onClick:()=>{c(!0),e.oauth&&h(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!d&&s.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&&s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(ae=>s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsx("label",{className:"form-label",children:ae.label}),ae.type==="password"?s.jsxs("div",{className:"cred-field",children:[s.jsx("input",{className:"form-input",type:K[ae.key]?"text":"password",name:`${e.id}-${ae.key}-credential`,autoComplete:"new-password",placeholder:ae.placeholder,value:i[ae.key]||"",onChange:U=>o(pe=>({...pe,[ae.key]:U.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>$(U=>({...U,[ae.key]:!U[ae.key]})),children:K[ae.key]?"hide":"show"})]}):s.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${ae.key}-credential`,autoComplete:"off",placeholder:ae.placeholder,value:i[ae.key]||"",onChange:U=>o(pe=>({...pe,[ae.key]:U.target.value}))})]},ae.key)),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[G&&s.jsx("button",{className:"btn btn-primary",onClick:X,disabled:b||B&&!e.credentials.fields.filter(ae=>!ae.optional).every(ae=>{var U;return(U=i[ae.key])==null?void 0:U.trim()}),children:b?"Saving...":"Save & Encrypt"}),k&&!G&&s.jsx("button",{className:"btn btn-primary",onClick:Ce,disabled:E,children:E?"Starting...":`Activate ${e.name}`})]})]})})(),ee==="needs-oauth"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[s.jsxs("button",{className:"btn btn-primary",onClick:se,children:["Connect ",e.name," Account"]}),s.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Change Credentials"})]})]}),ee==="ready"&&!t&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[s.jsx("button",{className:"btn btn-primary",onClick:Ce,disabled:E,children:E?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&s.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Update Credentials"}),e.oauth&&s.jsx("button",{className:"btn btn-ghost",onClick:()=>{c(!1),h(!1)},children:"Change Credentials"})]})]}),ee==="ready"&&t&&!t.running&&(xt.showStart?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[s.jsx("span",{className:"service-status-dot"}),"Not running"]}),t.error&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:t.error}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:Ce,disabled:E,children:E?"Starting...":"Start"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:Ge,children:"Disable"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"service-status",style:{marginBottom:"0.5rem",color:"var(--text-muted)"},children:[s.jsx("span",{className:"service-status-dot",style:{background:"var(--text-muted)"}}),"Paused"]}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.75rem"},children:"Real systems are off while simulation mode is on."}),s.jsx("div",{style:{display:"flex",gap:"0.5rem"},children:s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:Ge,children:"Disable"})})]}))]})}function a0(e,t){if(!t)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const n=e.filter(o=>Uo(o.manifest)),r=e.filter(o=>!Uo(o.manifest)),a=r.filter(o=>o.state==="error"),i=r.filter(o=>o.state!=="error");return{grouped:!0,testSystems:n,realErrors:a,pausedReal:i,ungrouped:[]}}function i0({entry:e}){return s.jsxs("div",{className:"int-paused-row",children:[s.jsx("span",{"aria-hidden":"true",children:Gm(e.manifest.icon)}),s.jsx("span",{className:"int-paused-name",children:e.manifest.name}),s.jsxs("span",{className:"int-chip int-chip-paused",children:[s.jsx("span",{className:"int-dot"}),"Paused"]})]})}function o0(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:a}=Jl(),i=Tm(),[o,l]=u.useState(""),c=u.useCallback(f=>{l(f),setTimeout(()=>l(""),5e3)},[]),d=a0(r,i);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Integrations"}),s.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),o&&s.jsx("div",{className:"alert alert-success",children:o}),e?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):t===!1?s.jsxs("div",{className:"status-banner status-banner-error",children:[s.jsx("span",{className:"status-banner-icon",children:"!"}),s.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):d.grouped?s.jsxs(s.Fragment,{children:[d.testSystems.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"int-group-label",children:"Test systems"}),d.testSystems.map(f=>s.jsx(Di,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:c},f.id))]}),(d.realErrors.length>0||d.pausedReal.length>0)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"int-group-label",children:"Real systems"}),d.realErrors.map(f=>s.jsx(Di,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:c},f.id)),d.pausedReal.length>0&&s.jsxs("details",{className:"int-paused-group",open:!0,children:[s.jsxs("summary",{children:["Paused while simulation mode is on (",d.pausedReal.length,")"]}),s.jsxs("p",{className:"int-paused-group-note",children:["Nothing is lost — mandates, credentials and data stay. They start again when simulation mode is switched off (",s.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),d.pausedReal.map(f=>s.jsx(i0,{entry:f},f.id))]})]}),r.length===0&&s.jsx(Tu,{manifestsError:n})]}):s.jsxs(s.Fragment,{children:[r.map(f=>s.jsx(Di,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:c},f.id)),r.length===0&&s.jsx(Tu,{manifestsError:n})]})]})}function Tu({manifestsError:e}){return e?s.jsxs("div",{className:"status-banner status-banner-error",children:[s.jsx("span",{className:"status-banner-icon",children:"!"}),s.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"," ",s.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):s.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function l0(){var D,z,K;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Ue(),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(""),[f,m]=u.useState(""),[p,x]=u.useState(!1),[w,v]=u.useState(""),[S,g]=u.useState("");u.useEffect(()=>{fetch("/health").then($=>$.json()).then($=>{typeof $.spUrl=="string"&&g($.spUrl)}).catch(()=>{})},[]),u.useEffect(()=>{if(!e){i(null);return}T.getGroupById(e.id).then($=>{const Q=$.group??$,H=$.members??[],O=$.isAdmin??!1,_=H.map(P=>{const V=P.userId||P.id||"",R=P.role||(O&&V===Q.createdBy?"admin":"member");return{id:V,name:P.name||V.slice(0,8)||"Member",email:P.email||"",domains:P.domains||[],role:R,isAdmin:R==="admin"||O&&V===Q.createdBy}});i({id:Q.id,name:Q.name,members:_})}).catch(()=>i(null))},[e==null?void 0:e.id]);const h=(a==null?void 0:a.members.filter($=>$.isAdmin))??[],y=(e==null?void 0:e.isAdmin)===!0&&h.length<=1&&h.some($=>$.id===(r==null?void 0:r.id)),j=(e==null?void 0:e.name)??"",b=w.trim()===j&&!o,C=()=>{v(""),x(!0)},N=()=>{x(!1),v("")},I=async()=>{if(!(!e||!b)){l(!0),d("");try{await T.leaveTeam(e.id),await n(),m("You have left the team."),i(null),N()}catch($){d($ instanceof Error?$.message:"Failed to leave team")}finally{l(!1)}}},E=e&&S?`${S}/dashboard/groups/${e.id}`:void 0,A=S?`${S}/dashboard/groups`:void 0;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"page-header",children:s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:"Team"}),s.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),c&&s.jsx("div",{className:"error-message",children:c}),f&&s.jsx("div",{className:"alert alert-success",children:f}),e?s.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[s.jsxs("div",{className:"card-header",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"card-title",children:e.name}),s.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((D=a==null?void 0:a.members)==null?void 0:D.length)??0," ",(((z=a==null?void 0:a.members)==null?void 0:z.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),s.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(K=a==null?void 0:a.members)==null?void 0:K.map($=>s.jsxs("div",{className:"member-row",children:[s.jsx("div",{className:"member-avatar",children:$.name.split(" ").map(Q=>Q[0]).join("").slice(0,2).toUpperCase()}),s.jsxs("div",{className:"member-info",children:[s.jsx("div",{className:"member-name",children:$.name}),s.jsx("div",{className:"member-email",children:$.email})]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:$.role})]},$.id)),s.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[E&&s.jsx("a",{className:"btn btn-secondary btn-sm",href:E,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),s.jsx("span",{title:y?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:s.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:C,disabled:o||y,children:"Leave team"})})]})]}):s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[s.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),s.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",maxWidth:480,marginLeft:"auto",marginRight:"auto"},children:"Every mandate you create here is in your personal context. You can join an existing team or create a new one in your Authority Server dashboard."}),A&&s.jsx("a",{className:"btn btn-primary btn-sm",href:A,target:"_blank",rel:"noopener noreferrer",children:"Open Authority Server dashboard →"})]}),p&&e&&s.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:N,children:s.jsxs("div",{className:"card",onClick:$=>$.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[s.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",j,"?"]}),s.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),s.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[s.jsx("li",{children:"Revoke all mandates you created in this team's context"}),s.jsx("li",{children:"Reject any pending action proposals you authored"}),s.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),s.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",s.jsx("strong",{children:"personal"})," mandates are not affected."]}),s.jsxs("div",{className:"form-group",children:[s.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",s.jsx("code",{children:j})," to confirm:"]}),s.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:w,onChange:$=>v($.target.value),placeholder:j,disabled:o,autoFocus:!0})]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:N,disabled:o,children:"Cancel"}),s.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:I,disabled:!b,children:o?"Leaving...":"Leave team"})]})]})})]})}const c0=new Set(["mail","users","receipt","credit-card","calendar","megaphone","archive","rocket","flask","shopping-cart","bar-chart","help-circle"]),u0={email:"mail",customers:"users",sales:"receipt",charge:"credit-card",calendar:"calendar",publish:"megaphone",records:"archive",deploy:"rocket",delegation:"flask",purchase:"shopping-cart",reporting:"bar-chart"};function d0(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(t+1):e,r=n.indexOf("@");return(r>=0?n.slice(0,r):n).toLowerCase()}function Hn(e,t){const n=d0(e),r=t!=null&&t.icon&&c0.has(t.icon)?t.icon:u0[n]??"help-circle",a=Oe(e,t==null?void 0:t.name);return{icon:r,name:a,testSetup:n==="delegation"}}function si(e){return e.startsWith("setup__")}const f0={mail:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("path",{d:"m3 7 9 6 9-6"})]}),users:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),s.jsx("path",{d:"M3.5 20c0-3.6 2.5-6.3 5.5-6.3s5.5 2.7 5.5 6.3"}),s.jsx("circle",{cx:"17.2",cy:"9.2",r:"2.3"}),s.jsx("path",{d:"M16.8 13.9c2.4.5 4.2 2.6 4.2 5.4"})]}),receipt:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6 3h12v18l-2.2-1.4L14 21l-2-1.4L10 21l-2-1.4L6 21V3Z"}),s.jsx("line",{x1:"9",y1:"7.5",x2:"15",y2:"7.5"}),s.jsx("line",{x1:"9",y1:"11.5",x2:"15",y2:"11.5"}),s.jsx("line",{x1:"9",y1:"15.5",x2:"13",y2:"15.5"})]}),"credit-card":s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2.2"}),s.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"}),s.jsx("line",{x1:"5.5",y1:"15",x2:"9.5",y2:"15"})]}),calendar:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4.5",width:"18",height:"16.5",rx:"2"}),s.jsx("line",{x1:"3",y1:"9.5",x2:"21",y2:"9.5"}),s.jsx("line",{x1:"8",y1:"2.5",x2:"8",y2:"6.5"}),s.jsx("line",{x1:"16",y1:"2.5",x2:"16",y2:"6.5"})]}),megaphone:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 10.2v3.6c0 .7.6 1.2 1.2 1.2h2.6l6.4 4V5l-6.4 4H4.2C3.6 9 3 9.5 3 10.2Z"}),s.jsx("path",{d:"M14.5 8.3a4.3 4.3 0 0 1 0 7.4"}),s.jsx("path",{d:"M17.6 6a7.6 7.6 0 0 1 0 12"})]}),archive:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"3.5",width:"18",height:"5",rx:"1.2"}),s.jsx("path",{d:"M5 8.5V18a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5"}),s.jsx("line",{x1:"10",y1:"13",x2:"14",y2:"13"})]}),rocket:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 2.2c2.4 2 3.8 5.3 3.8 8.6 0 1.9-.9 3.9-.9 3.9H9.1s-.9-2-.9-3.9c0-3.3 1.4-6.6 3.8-8.6Z"}),s.jsx("path",{d:"M9 14.7 6.3 19.4l3.8-1.7"}),s.jsx("path",{d:"M15 14.7l2.7 4.7-3.8-1.7"}),s.jsx("circle",{cx:"12",cy:"9.3",r:"1.3"})]}),flask:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M9 3h6"}),s.jsx("path",{d:"M10 3v6.3l-5 9.1A2 2 0 0 0 6.7 21.5h10.6a2 2 0 0 0 1.7-3.1l-5-9.1V3"}),s.jsx("line",{x1:"8.3",y1:"14.5",x2:"15.7",y2:"14.5"})]}),"shopping-cart":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9",cy:"20",r:"1.4"}),s.jsx("circle",{cx:"18",cy:"20",r:"1.4"}),s.jsx("path",{d:"M2.5 3h2.4l2.1 11.2a2 2 0 0 0 2 1.6h8.6a2 2 0 0 0 2-1.6l1.4-7.6H6"})]}),"bar-chart":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"4",y1:"20.5",x2:"20",y2:"20.5"}),s.jsx("rect",{x:"6",y:"13",width:"3.2",height:"7.5"}),s.jsx("rect",{x:"11.4",y:"8.5",width:"3.2",height:"12"}),s.jsx("rect",{x:"16.8",y:"4",width:"3.2",height:"16.5"})]}),"help-circle":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),s.jsx("path",{d:"M9.6 9.6a2.5 2.5 0 1 1 3.6 2.3c-.9.5-1.4 1.1-1.4 2.2"}),s.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function Km({icon:e,className:t}){return s.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:f0[e]})}function bs({profileId:e,declared:t}){const{icon:n,name:r}=Hn(e,t);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"id-rail",children:[s.jsx(Km,{icon:n,className:"id-rail-icon"}),s.jsx("span",{className:"id-rail-name",children:r})]}),s.jsx("div",{className:"id-sep"})]})}const Wo=e=>e.replace(/@.*$/,"").split("/").pop()??e,Iu=e=>e.split("@")[1]??"";function m0(e,t){const n=new Map;for(const r of e){const a=Wo(r.id);if(!t.has(a))continue;const i=n.get(a);(!i||Iu(r.id).localeCompare(Iu(i.id),void 0,{numeric:!0})>0)&&n.set(a,r)}return n}function p0(e,t,n,r){var l;const a=new Set([...t.filter(c=>c.profile).map(c=>c.profile),...r.map(c=>Wo(c.profile))]),i=m0(e,a),o=[];for(const c of t){const d=c.profile?i.get(c.profile):void 0;d&&o.push({key:`connector:${c.id}`,name:c.name,description:c.description||d.description,profile:d,kind:"connector",ready:((l=n.find(f=>f.id===c.id))==null?void 0:l.running)===!0,setupId:c.id})}for(const c of r){const d=i.get(Wo(c.profile));d&&o.push({key:`builtin:${c.id}`,name:c.name,description:c.description||d.description,profile:d,kind:"builtin",ready:c.available,unavailableReason:c.available?void 0:"Available only while simulation mode is on."})}return o}function h0({onDismiss:e}){const t=tn(),{group:n,groupId:r,domain:a,user:i}=Ue(),[o,l]=u.useState([]),[c,d]=u.useState([]),[f,m]=u.useState([]),[p,x]=u.useState([]),[w,v]=u.useState(!0),[S,g]=u.useState({});u.useEffect(()=>{Promise.all([T.listProfiles().catch(()=>[]),T.getIntegrationManifests().then(N=>N.manifests??[]).catch(()=>[]),T.getMcpHealth().catch(()=>null)]).then(async([N,I,E])=>{if(l(N),d(I),m((E==null?void 0:E.integrations)??[]),x((E==null?void 0:E.builtins)??[]),r){const A=await Promise.all(N.map(z=>T.getTeamProfileConfig(r,z.id).catch(()=>null))),D={};N.forEach((z,K)=>{const $=A[K];$&&(D[z.id]=$)}),g(D)}}).finally(()=>v(!1))},[r]);const h=p0(o,c,f,p),y=N=>{var I;return Vm({isPersonal:!!(n!=null&&n.isPersonal),configLoaded:!w,approvers:(I=S[N.id])==null?void 0:I.approvers,userId:i==null?void 0:i.id,profileName:Oe(N.id),teamName:n==null?void 0:n.name})},j=N=>N in S,b=N=>{if(!r){console.error("No active group when creating authorization");return}const I=j(N);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:N,groupId:r,groupName:(n==null?void 0:n.name)??null,domain:a,isTeam:I,isPersonal:!!(n!=null&&n.isPersonal)})),sessionStorage.removeItem("agentGate"),e==null||e(),t("/mandates/new/intent")},C=N=>{r&&b(N)};return s.jsxs(s.Fragment,{children:[s.jsx("style",{children:`
|
|
67
|
+
`).replace(/\n+$/,"")}async function Xm(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(i=>i.toString(16).padStart(2,"0")).join("")}class i0 extends Error{constructor(n,r,a){super(a);Er(this,"code");Er(this,"field");this.name="CanonicalValueError",this.code=n,this.field=r}}function o0(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 qm(e,t,n){const r=[];for(const a of t){const i=e[a];if(i==null)continue;const o=String(i);if(o.includes(`
|
|
68
|
+
`)||o.includes("\r"))throw new i0(n,a,`Value for "${a}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);r.push(`${a}=${o0(o)}`)}return r.join(`
|
|
69
|
+
`)}async function ua(e,t){const n=t.boundsSchema??t.frameSchema;if(!n)throw new Error("Profile has no boundsSchema or frameSchema");const r=qm(e,n.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await Xm(r)}`}async function Zm(e,t){const n=t.contextSchema?qm(e,t.contextSchema.keyOrder,"CONTEXT_INVALID_VALUE"):"";return`sha256:${await Xm(n)}`}async function Fa(e){const t=new TextEncoder().encode(a0(e)),n=await crypto.subtle.digest("SHA-256",t);return`sha256:${Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}`}function eh(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 l0(e){const t=e.commitment_modes;return t===void 0?["review","automatic"]:Array.isArray(t)?["review","automatic"].filter(n=>t.includes(n)):[]}function c0(e){return e==="per-action"?"review":"automatic"}function Lu(e){return e?l0(e).map(t=>t==="review"?"per-action":"immediate"):["per-action","immediate"]}function u0(e,t){return t.includes(e)?e:t[0]??null}function zu(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function d0(e,t){for(const n of e)if(t.has(n))return!0;return!1}function f0(e,t,n){for(const r of e){const a=zu(t[r]),i=zu(n[r]);if(!(a.size===0||i.size===0)&&!d0(a,i))return!1}return!0}function m0(e){return e.length>24?`${e.slice(0,10)}…`:e}function th(e,t,n){const r=n==null?void 0:n[e];return String(t).split(",").map(i=>i.trim()).filter(Boolean).map(i=>{const o=r==null?void 0:r[i];return o?`${o} (${m0(i)})`:i}).join(", ")}function nh(e){var n;if(e.isPersonal)return{can:!0};if(!e.configLoaded)return{can:!0};const t=e.teamName?`"${e.teamName}"`:"this team";return(((n=e.approvers)==null?void 0:n.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${t}.`,fix:`A team admin names who may give ${e.profileName} mandates.`}:!e.userId||!e.approvers.includes(e.userId)?{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${e.profileName}'s approvers in ${t} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}:{can:!0}}function h0(){var G,ae;const e=tn(),{user:t,mode:n,domain:r}=Ue(),[a,i]=u.useState(null),[o,l]=u.useState(null),[c,d]=u.useState(null),[f,h]=u.useState("per-action"),[m,x]=u.useState(1800),[w,v]=u.useState(86400),[S,g]=u.useState(""),[p,y]=u.useState("hours"),[j,b]=u.useState(""),[C,N]=u.useState(!0),[I,E]=u.useState(!1);u.useEffect(()=>{T.getIdentityDisclosure().then(U=>E(U.always)).catch(()=>{})},[]);const[A,D]=u.useState(!1),[L,K]=u.useState(""),[z,Q]=u.useState(null),[H,O]=u.useState([]),[_,P]=u.useState(!1),[V,R]=u.useState([]),[$,Y]=u.useState(0);u.useEffect(()=>{var Nn;const U=sessionStorage.getItem("agentAuth"),he=sessionStorage.getItem("agentGate");if(!U||!he){e("/mandates?new=1");return}const Pe=JSON.parse(U),ke=JSON.parse(he),Ye={bounds:ke.bounds??{},context:ke.context??{},contextLabels:ke.contextLabels??void 0,gateContent:ke.gateContent};i(Pe),l(Ye),ke.ttlConfig&&(x(ke.ttlConfig.default??1800),v(ke.ttlConfig.max??86400)),ke.templateMode==="automatic"?h("immediate"):ke.templateMode==="review"&&h("per-action");const bn=((Nn=ke.ttlConfig)==null?void 0:Nn.max)??86400;if(typeof ke.templateTtl=="number"&&ke.templateTtl>0){const F=Math.min(ke.templateTtl,bn);x(F),[3600,86400,604800,2592e3,31536e3].includes(F)||(F%86400===0?(g(String(F/86400)),y("days")):(g(String(Math.max(1,Math.round(F/3600)))),y("hours")))}T.getProfile(Pe.profileId).then(F=>{var Z;if(d(F),!j){const ie=F.name??((Z=Pe.profileId.split("/").pop())==null?void 0:Z.replace(/@.*$/,""))??"",ue=[];if(Ye.context&&F.contextSchema)for(const Ee of F.contextSchema.keyOrder){const le=Ye.context[Ee];if(le!==void 0&&le!==""){const wt=String(le).split(",").map(oi=>oi.trim()).filter(Boolean);ue.push(wt.join(", "))}}const ge=ue.length>0?`${ie}: ${ue.join(" · ")}`:ie;b(ge)}}).catch(()=>{}),Pe.isPersonal?P(!0):Promise.all([T.getTeamProfileConfig(Pe.groupId,Pe.profileId).catch(()=>null),T.getGroupById(Pe.groupId).catch(()=>null),T.listUsers().catch(()=>[])]).then(([F,Z,ie])=>{if(Q(F),F){const ue=new Map;for(const le of ie){const wt=le.name&&le.email?`${le.name} (${le.email})`:le.name||le.email||le.id;ue.set(le.id,wt)}const ge=(Z==null?void 0:Z.members)??[];for(const le of ge){const wt=le.userId??le.id;wt&&(le.name&&le.email?ue.set(wt,`${le.name} (${le.email})`):le.name&&ue.set(wt,le.name))}const Ee=(F.approvers??[]).map(le=>ue.get(le)??le);O(Ee)}}).finally(()=>{P(!0)})},[e]),u.useEffect(()=>{if(!(a!=null&&a.profileId))return;const U=a.profileId,he=sessionStorage.getItem("agentEditReplaces");T.getEnrichedAuthorizations().then(Pe=>{const ke=Pe.filter(Ye=>Ye.profileId===U&&Ye.authorizationId!==he).map(Ye=>({authorizationId:Ye.authorizationId,bounds:Ye.bounds,context:Ye.context??{},intent:Ye.intent}));R(ke)}).catch(()=>R([]))},[a==null?void 0:a.profileId]),u.useEffect(()=>{if(!c)return;const U=u0(f,Lu(c));U&&U!==f&&h(U)},[c,f]),u.useEffect(()=>{if(!o||!c||V.length===0){Y(0);return}let U=!1;return(async()=>{const he=await ua(o.bounds,c),Pe=await Promise.all(V.map(ke=>ua(ke.bounds,c).catch(()=>null)));U||Y(Pe.filter(ke=>ke===he).length)})().catch(()=>{U||Y(0)}),()=>{U=!0}},[o,c,V]);const te=async()=>{if(!(!a||!o||!c||!t)){if(!a.groupId){K("No active group; cannot create mandate.");return}D(!0),K("");try{const U=r||a.domain||"owner",he=await ua(o.bounds,c),Pe=await Zm(o.context,c),[ke,Ye]=await Promise.all([Fa(o.gateContent.intent),Fa(JSON.stringify({profile:a.profileId,domain:U,group:a.groupId}))]);let bn,Nn,F,Z;if(a.isTeam){const Ee=await T.getApproversPubkeys(a.groupId,a.profileId);if(Ee.length>0){const le=await T.encryptIntent(o.gateContent.intent,Ee);bn=le.intentCiphertext,Nn=le.encryptedKeys,F=le.approversFrozen,Z=le.intentDisclosureHash}}const ie=`authz_${crypto.randomUUID()}`,ue=sessionStorage.getItem("agentEditReplaces")||void 0,ge=await T.attest({authorization_id:ie,replaces:ue,profile_id:a.profileId,bounds:o.bounds,bounds_hash:he,context_hash:Pe,domain:U,did:t.did,gate_content_hashes:{intent:ke},execution_context_hash:Ye,group_id:a.groupId,ttl:m,commitment_mode:c0(f),title:j.trim(),intent_ciphertext:bn,encrypted_keys:Nn,approvers_frozen:F,intent_disclosure_hash:Z,disclose_identity:C});try{await T.pushGateContent(eh(ge,{boundsHash:he,contextHash:Pe,context:o.context,contextLabels:o.contextLabels,gateContent:o.gateContent}))}catch(Ee){try{await T.revokeAttestation(ie,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${Ee instanceof Error?Ee.message:"Unknown error"})`)}if(ue)try{await T.revokeAttestation(ue,`Replaced by ${ie} (edit)`),T.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/mandates?highlight=${encodeURIComponent(ie)}`)}catch(U){K(U instanceof Error?U.message:"Signing the mandate failed")}finally{D(!1)}}};if(!a||!o)return s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const ne=Object.entries(o.bounds).filter(([U])=>U!=="profile"&&U!=="path"),de=Object.entries(o.context),$e=((z==null?void 0:z.caps)!=null?Object.keys(z.caps):[]).length!==0,q=H.length>0?H.join(", "):((z==null?void 0:z.approvers)??[]).join(", "),ee=$e?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${q}, 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.",X=$e?`Over-cap actions will be reviewed by you and ${q}. Within-cap actions run per the mode you chose above.`:`Approvers ${q} can read your intent but won't gate any action — no caps configured on this profile.`,oe=!!((G=z==null?void 0:z.approvers)!=null&&G.length),W=nh({isPersonal:a.isPersonal,configLoaded:_,approvers:z==null?void 0:z.approvers,userId:t==null?void 0:t.id,profileName:Oe(a.profileId),teamName:a.groupName}),re=!W.can,se=Lu(c),Ce=se.length===0,Ge=m>w,_e={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"},xt={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"},at=((ae=c==null?void 0:c.contextSchema)==null?void 0:ae.keyOrder)??[],Ke=V.filter(U=>f0(at,o.context,U.context)),fe=Ke.length>0,Ze=Oe(a.profileId),nn=U=>{const he=Object.values(U).map(Pe=>String(Pe).trim()).filter(Boolean);return he.length>0?he.join(", "):"all (unscoped)"},k=Ke.map(U=>nn(U.context)).join("; "),B=`This grant's scope overlaps an existing grant on ${Ze} (scoped to: ${k}). 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 s.jsxs(s.Fragment,{children:[s.jsx(Km,{currentStep:4,onStepClick:U=>{U<=3&&e(`/mandates/new/intent?step=${U}`)}}),s.jsxs("div",{className:"card",children:[s.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),s.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),L&&s.jsx("div",{className:"error-message",children:L}),s.jsxs("div",{className:"field-editable",children:[s.jsxs("div",{className:"field-label",children:[s.jsx("span",{className:"pen",children:"✎"})," Title"]}),s.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Oe(a.profileId)}: daily operations`,value:j,onChange:U=>b(U.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),s.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),s.jsxs("div",{className:"field-editable",children:[s.jsxs("div",{className:"field-label",children:[s.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),s.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[se.includes("per-action")&&s.jsxs("button",{onClick:()=>h("per-action"),style:xt,children:[s.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),se.includes("immediate")&&s.jsxs("button",{onClick:()=>h("immediate"),style:_e,children:[s.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]}),se.length===1&&s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:se[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Ce&&s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--danger)",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),s.jsxs("div",{className:"field-editable",children:[s.jsxs("div",{className:"field-label",children:[s.jsx("span",{className:"pen",children:"✎"})," Duration"]}),s.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(U=>U.seconds<=w).map(U=>s.jsx("button",{onClick:()=>{x(U.seconds),g("")},style:{padding:"0.5rem 0.85rem",border:m===U.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:m===U.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:U.label},U.seconds)),s.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[s.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:S,onChange:U=>{g(U.target.value);const he=parseInt(U.target.value,10);if(he>0){const Pe=p==="days"?he*86400:he*3600;x(Math.min(Pe,w))}}}),s.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:p,onChange:U=>{y(U.target.value);const he=parseInt(S,10);if(he>0){const Pe=U.target.value==="days"?he*86400:he*3600;x(Math.min(Pe,w))}},children:[s.jsx("option",{value:"hours",children:"hours"}),s.jsx("option",{value:"days",children:"days"})]})]}),Ge&&s.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",w>=86400?`${Math.floor(w/86400)} days`:`${Math.floor(w/3600)} hours`]})]})]}),s.jsx("div",{className:"field-editable",children:s.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[s.jsx("input",{type:"checkbox",checked:I||C,disabled:I,onChange:U=>N(U.target.checked),style:{marginTop:"0.15rem"}}),s.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",s.jsxs("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.',I&&" Always on — you chose this in Settings."]})]})]})}),s.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),s.jsxs("div",{className:"info-block",children:[s.jsxs("div",{className:"info-head",children:[s.jsx("span",{className:"info-title",children:"Intent"}),s.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),s.jsx("div",{style:{whiteSpace:"pre-wrap"},children:o.gateContent.intent})]}),(!!ne.length||!!de.length)&&s.jsxs("div",{className:"info-block",children:[s.jsxs("div",{className:"info-head",children:[s.jsx("span",{className:"info-title",children:"Scope & Limits"}),s.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),s.jsxs("dl",{className:"info-kv",children:[de.map(([U,he])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:U}),s.jsx("dd",{children:th(U,he,o.contextLabels)})]},U)),ne.map(([U,he])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:U}),s.jsx("dd",{children:String(he)})]},U))]})]}),s.jsxs("div",{className:"info-block",children:[s.jsx("div",{className:"info-head",children:s.jsx("span",{className:"info-title",children:"Authority"})}),s.jsxs("dl",{className:"info-kv",children:[s.jsx("dt",{children:"Profile"}),s.jsxs("dd",{children:[Oe(a.profileId),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:a.profileId})]}),!a.isPersonal&&a.groupName&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Team"}),s.jsx("dd",{children:a.groupName})]}),!a.isPersonal&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Approvers"}),s.jsx("dd",{children:_?W.can?s.jsxs(s.Fragment,{children:[q,s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:ee})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{color:"var(--danger)",fontWeight:600},children:W.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${a.groupName??"this team"}`:"You cannot give this mandate"}),W.code==="OWNER_NOT_APPROVER"&&s.jsx("div",{children:q}),s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[W.reason," ",W.fix]})]}):s.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),$>0?s.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:[s.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),s.jsxs("div",{children:[$===1?`An active grant on ${Ze} already has exactly these limits.`:`${$} active grants on ${Ze} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",s.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,fe?s.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:[s.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),s.jsx("div",{children:B})]})]}):null,s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/mandates/new/intent"),children:"Back"}),s.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:te,disabled:A||!j.trim()||re||Ce,children:A?"Signing...":f==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),s.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:oe?"block":"none"},children:X})]})]})}const p0={card:"💳",mail:"✉️"};function rh(e){return p0[e]??"🔧"}function g0(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 y0=[0,7,30,90,365,3650];function Ks(e){return e===null?"From your mandate":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 v0(e){return(e==null?void 0:e.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:e&&!e.running&&e.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function Hi({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:a}){var nn;const[i,o]=u.useState({}),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[h,m]=u.useState({}),[x,w]=u.useState({}),[v,S]=u.useState(void 0),[g,p]=u.useState(!1),[y,j]=u.useState(null),[b,C]=u.useState(!1),[N,I]=u.useState(!1),[E,A]=u.useState(!1),[D,L]=u.useState(!1),[K,z]=u.useState({}),[Q,H]=u.useState(null),[O,_]=u.useState(!1),[P,V]=u.useState(null),[R,$]=u.useState(!1);u.useEffect(()=>{let k=!1;return T.getCredential(e.id).then(B=>{var G;if(!(k||!B.configured)){if(c(!0),f(!0),B.fields){const ae={};for(const U of e.credentials.fields)B.fields[U.key]!=null&&(ae[U.key]=B.fields[U.key]);m(ae)}if(w(B.secrets??{}),S(B.updatedAt),e.oauth){const ae=((G=B.fieldNames)==null?void 0:G.includes(e.oauth.tokenStorage))??!1;p(ae),ae&&T.getOAuthHealth(e.id).then(U=>{k||j(U)})}}}).catch(()=>{}),()=>{k=!0}},[e.id,e.oauth]);const Y=g0(e.toolGating),te=t?t.readAgeDays??null:void 0,ne=O&&Q?Q.value:te,de=async k=>{H({value:k}),_(!0),V(null);try{await T.setReadPolicy(e.id,k),a(k===null?`${e.name} read window now follows your mandate`:`${e.name} read window set to ${Ks(k).toLowerCase()}`),r()}catch(B){V(B instanceof Error?B.message:"Could not save")}finally{_(!1),H(null)}},xe=!!e.oauth||e.credentials.fields.some(k=>!k.optional),$e=e.oauth?g:l,q=!xe||$e,ee=n==="starting"?"starting":q?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!g?"needs-oauth":"unconfigured",X=async()=>{if(e.credentials.fields.some(B=>{var G;return(G=i[B.key])==null?void 0:G.trim()})){C(!0);try{await T.setCredential(e.id,i),c(!0),o({}),e.oauth?a(`${e.name} credentials saved!`):(a(`${e.name} credentials saved — starting integration...`),await Ce())}catch{a(`Failed to save ${e.name} credentials`)}finally{C(!1)}}},oe=()=>{const k={};for(const B of e.credentials.fields){const G=i[B.key];B.type==="password"?G!=null&&G.trim()&&(k[B.key]=G):G!=null&&G!==(h[B.key]??"")&&(k[B.key]=G)}return k},W=Object.keys(oe()).length>0,re=async()=>{const k=oe();if(Object.keys(k).length!==0){C(!0);try{await T.setCredential(e.id,k),o({}),c(!0),e.oauth?a(`${e.name} credentials saved — now click Connect.`):(L(!1),a(`${e.name} credentials updated — restarting...`),await Ce())}catch{a(`Failed to update ${e.name} credentials`)}finally{C(!1)}}},se=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const k=setInterval(async()=>{var B;try{const G=await T.getCredential(e.id);G.configured&&e.oauth&&((B=G.fieldNames)!=null&&B.includes(e.oauth.tokenStorage))&&(p(!0),L(!1),j(null),clearInterval(k),a(`${e.name} connected — starting integration...`),T.getOAuthHealth(e.id).then(j).catch(()=>{}),await Ce())}catch{}},2e3);setTimeout(()=>clearInterval(k),12e4)},Ce=async()=>{A(!0);try{const k=await T.activateIntegration(e.id);k.warning?a(k.warning):a(`${e.name} integration started with ${k.tools.length} tools`),r()}catch(k){a(`Failed to start ${e.name}: ${k instanceof Error?k.message:"Unknown error"}`)}finally{A(!1)}},Ge=async()=>{try{await T.removeMcpIntegration(e.id),a(`${e.name} integration removed`),r()}catch{a(`Failed to remove ${e.name}`)}},_e=rh(e.icon),xt=v0(t),at=ee==="running"?{c:"int-chip-ok",t:"Running"}:ee==="starting"?{c:"int-chip-idle",t:"Starting"}:xt.chip,Ke=e.oauth&&g&&(y==null?void 0:y.status)==="failed",fe=xe?Ke?{c:"int-chip-bad",t:"Auth failed"}:$e?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},Ze=k=>k.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return s.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[s.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:_e}),s.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:e.name}),s.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[ee!=="unconfigured"&&ee!=="needs-oauth"&&s.jsxs("span",{className:`int-chip ${at.c}`,children:[s.jsx("span",{className:"int-dot"}),at.t]}),s.jsxs("span",{className:`int-chip ${fe.c}`,children:[s.jsx("span",{className:"int-dot"}),fe.t]}),Ix(e,h)&&s.jsxs("span",{className:"int-chip int-chip-sim",title:"This connector answers from a simulated system with test data. Nothing reaches your real systems.",children:[s.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),e.oauth&&g&&s.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:y!=null&&y.account?s.jsxs(s.Fragment,{children:["Connected as ",s.jsx("b",{children:y.account})]}):s.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),Ke&&!D&&s.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:[s.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[e.name," stopped accepting the stored credentials"]}),s.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[(y==null?void 0:y.error)==="invalid_grant"?s.jsxs(s.Fragment,{children:["The refresh token was revoked (",s.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):y!=null&&y.error?s.jsxs(s.Fragment,{children:["The provider reported ",s.jsx("code",{children:y.error}),"."]}):s.jsx(s.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",e.name," actions are ",s.jsx("b",{children:"blocked"}),", not failing silently."]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[s.jsxs("button",{className:"btn btn-primary btn-sm",onClick:se,children:["Reconnect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{o({...h}),L(!0)},children:"Edit credentials"})]})]}),s.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[s.jsx("summary",{children:"Details"}),s.jsxs("div",{className:"int-meta",children:[s.jsx("span",{className:"int-k",children:"What"}),s.jsx("span",{children:e.description}),e.profile&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"int-k",children:"Profile"}),s.jsx("span",{children:e.profile})]}),e.oauth&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"int-k",children:"Scopes"}),s.jsx("span",{children:((nn=e.oauth.scopes)==null?void 0:nn.join(", "))||"—"})]}),t&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"int-k",children:"Tools"}),s.jsxs("span",{children:[t.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(ee!=="running"||Ke)&&s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsxs("button",{onClick:()=>I(!N),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[s.jsx("span",{style:{transition:"transform 0.2s",transform:N?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),N&&s.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((k,B)=>s.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[s.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:B+1}),s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:k.title}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[Ze(k.description),k.link&&s.jsxs(s.Fragment,{children:[" ",s.jsxs("a",{href:k.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},B))})]}),ee==="starting"&&s.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[s.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),D&&s.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[s.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),d&&s.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(k=>{var B;return s.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[s.jsx("label",{className:"form-label",children:k.label}),k.type==="password"?s.jsxs("div",{className:"cred-field",children:[s.jsx("input",{className:"form-input",type:K[k.key]?"text":"password",name:`${e.id}-${k.key}-credential`,autoComplete:"new-password",placeholder:(B=x[k.key])!=null&&B.preview?`Unchanged — ends in ${x[k.key].preview}`:d?"Unchanged — paste a new value to replace":k.placeholder,value:i[k.key]||"",onChange:G=>o(ae=>({...ae,[k.key]:G.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>z(G=>({...G,[k.key]:!G[k.key]})),children:K[k.key]?"hide":"show"})]}):s.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${k.key}-credential`,autoComplete:"off",placeholder:k.placeholder,value:i[k.key]||"",onChange:G=>o(ae=>({...ae,[k.key]:G.target.value}))})]},k.key)}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[s.jsx("button",{className:"btn btn-primary btn-sm",onClick:re,disabled:b||!W,children:b?"Saving…":"Save"}),!W&&!b&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),e.oauth&&s.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:se,children:["Connect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{L(!1),o({})},children:"Cancel"})]})]}),!D&&ee==="running"&&t&&s.jsxs(s.Fragment,{children:[(Object.keys(h).length>0||Object.keys(x).length>0)&&s.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:e.credentials.fields.map(k=>{const B=k.type==="password",G=x[k.key];return!B&&h[k.key]==null||B&&G==null?null:s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[s.jsx("span",{style:{color:"var(--text-muted)"},children:k.label}),s.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[B?G.preview??"set":h[k.key],B&&v&&s.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(v).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},k.key)})}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx(tt,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(e.credentials.fields.length>0||e.oauth)&&s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{o({...h}),L(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),s.jsx("span",{style:{flex:1}}),s.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:Ge,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"})]}),Y&&ne!==void 0&&!R&&s.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[s.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),s.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:ne===null?"window from your mandate":Ks(ne).toLowerCase()}),O&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),P&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:P})]}),s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>$(!0),children:"Edit"})]})}),Y&&ne!==void 0&&R&&s.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[s.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),s.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>$(!1),children:"Done"})]}),s.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new mandate."}),s.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[y0.map(k=>{const B=ne===k;return s.jsx("button",{className:`btn btn-sm ${B?"btn-primary":"btn-secondary"}`,"aria-pressed":B,disabled:O,onClick:()=>de(k),children:Ks(k)},k)}),s.jsx("button",{className:`btn btn-sm ${ne===null?"btn-primary":"btn-ghost"}`,"aria-pressed":ne===null,disabled:O,onClick:()=>de(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:Ks(null)})]}),s.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:P?s.jsx("span",{style:{color:"var(--danger)"},children:P}):O?s.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):ne===null?s.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):ne===0?s.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):s.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",ne," days is blocked, whoever it is from."]})})]}),s.jsx("div",{style:{display:"none"},children:s.jsx(tt,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),ee==="unconfigured"&&(()=>{const k=e.credentials.fields.every(ae=>ae.optional),B=e.credentials.fields.some(ae=>!ae.optional),G=e.credentials.fields.some(ae=>{var U;return(U=i[ae.key])==null?void 0:U.trim()});return s.jsxs(s.Fragment,{children:[d&&s.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:[s.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"," ",s.jsx("button",{onClick:()=>{c(!0),e.oauth&&p(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!d&&s.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&&s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(ae=>s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsx("label",{className:"form-label",children:ae.label}),ae.type==="password"?s.jsxs("div",{className:"cred-field",children:[s.jsx("input",{className:"form-input",type:K[ae.key]?"text":"password",name:`${e.id}-${ae.key}-credential`,autoComplete:"new-password",placeholder:ae.placeholder,value:i[ae.key]||"",onChange:U=>o(he=>({...he,[ae.key]:U.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>z(U=>({...U,[ae.key]:!U[ae.key]})),children:K[ae.key]?"hide":"show"})]}):s.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${ae.key}-credential`,autoComplete:"off",placeholder:ae.placeholder,value:i[ae.key]||"",onChange:U=>o(he=>({...he,[ae.key]:U.target.value}))})]},ae.key)),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[G&&s.jsx("button",{className:"btn btn-primary",onClick:X,disabled:b||B&&!e.credentials.fields.filter(ae=>!ae.optional).every(ae=>{var U;return(U=i[ae.key])==null?void 0:U.trim()}),children:b?"Saving...":"Save & Encrypt"}),k&&!G&&s.jsx("button",{className:"btn btn-primary",onClick:Ce,disabled:E,children:E?"Starting...":`Activate ${e.name}`})]})]})})(),ee==="needs-oauth"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[s.jsxs("button",{className:"btn btn-primary",onClick:se,children:["Connect ",e.name," Account"]}),s.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Change Credentials"})]})]}),ee==="ready"&&!t&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[s.jsx("button",{className:"btn btn-primary",onClick:Ce,disabled:E,children:E?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&s.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Update Credentials"}),e.oauth&&s.jsx("button",{className:"btn btn-ghost",onClick:()=>{c(!1),p(!1)},children:"Change Credentials"})]})]}),ee==="ready"&&t&&!t.running&&(xt.showStart?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[s.jsx("span",{className:"service-status-dot"}),"Not running"]}),t.error&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:t.error}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:Ce,disabled:E,children:E?"Starting...":"Start"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:Ge,children:"Disable"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"service-status",style:{marginBottom:"0.5rem",color:"var(--text-muted)"},children:[s.jsx("span",{className:"service-status-dot",style:{background:"var(--text-muted)"}}),"Paused"]}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.75rem"},children:"Real systems are off while simulation mode is on."}),s.jsx("div",{style:{display:"flex",gap:"0.5rem"},children:s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:Ge,children:"Disable"})})]}))]})}function x0(e,t){if(!t)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const n=e.filter(o=>Vo(o.manifest)),r=e.filter(o=>!Vo(o.manifest)),a=r.filter(o=>o.state==="error"),i=r.filter(o=>o.state!=="error");return{grouped:!0,testSystems:n,realErrors:a,pausedReal:i,ungrouped:[]}}function w0({entry:e}){return s.jsxs("div",{className:"int-paused-row",children:[s.jsx("span",{"aria-hidden":"true",children:rh(e.manifest.icon)}),s.jsx("span",{className:"int-paused-name",children:e.manifest.name}),s.jsxs("span",{className:"int-chip int-chip-paused",children:[s.jsx("span",{className:"int-dot"}),"Paused"]})]})}function j0(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:a}=rc(),i=Om(),[o,l]=u.useState(""),c=u.useCallback(f=>{l(f),setTimeout(()=>l(""),5e3)},[]),d=x0(r,i);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Integrations"}),s.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),o&&s.jsx("div",{className:"alert alert-success",children:o}),e?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):t===!1?s.jsxs("div",{className:"status-banner status-banner-error",children:[s.jsx("span",{className:"status-banner-icon",children:"!"}),s.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):d.grouped?s.jsxs(s.Fragment,{children:[d.testSystems.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"int-group-label",children:"Test systems"}),d.testSystems.map(f=>s.jsx(Hi,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:c},f.id))]}),(d.realErrors.length>0||d.pausedReal.length>0)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"int-group-label",children:"Real systems"}),d.realErrors.map(f=>s.jsx(Hi,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:c},f.id)),d.pausedReal.length>0&&s.jsxs("details",{className:"int-paused-group",open:!0,children:[s.jsxs("summary",{children:["Paused while simulation mode is on (",d.pausedReal.length,")"]}),s.jsxs("p",{className:"int-paused-group-note",children:["Nothing is lost — mandates, credentials and data stay. They start again when simulation mode is switched off (",s.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),d.pausedReal.map(f=>s.jsx(w0,{entry:f},f.id))]})]}),r.length===0&&s.jsx($u,{manifestsError:n})]}):s.jsxs(s.Fragment,{children:[r.map(f=>s.jsx(Hi,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:c},f.id)),r.length===0&&s.jsx($u,{manifestsError:n})]})]})}function $u({manifestsError:e}){return e?s.jsxs("div",{className:"status-banner status-banner-error",children:[s.jsx("span",{className:"status-banner-icon",children:"!"}),s.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"," ",s.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):s.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function S0(){var D,L,K;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Ue(),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(""),[f,h]=u.useState(""),[m,x]=u.useState(!1),[w,v]=u.useState(""),[S,g]=u.useState("");u.useEffect(()=>{fetch("/health").then(z=>z.json()).then(z=>{typeof z.spUrl=="string"&&g(z.spUrl)}).catch(()=>{})},[]),u.useEffect(()=>{if(!e){i(null);return}T.getGroupById(e.id).then(z=>{const Q=z.group??z,H=z.members??[],O=z.isAdmin??!1,_=H.map(P=>{const V=P.userId||P.id||"",R=P.role||(O&&V===Q.createdBy?"admin":"member");return{id:V,name:P.name||V.slice(0,8)||"Member",email:P.email||"",domains:P.domains||[],role:R,isAdmin:R==="admin"||O&&V===Q.createdBy}});i({id:Q.id,name:Q.name,members:_})}).catch(()=>i(null))},[e==null?void 0:e.id]);const p=(a==null?void 0:a.members.filter(z=>z.isAdmin))??[],y=(e==null?void 0:e.isAdmin)===!0&&p.length<=1&&p.some(z=>z.id===(r==null?void 0:r.id)),j=(e==null?void 0:e.name)??"",b=w.trim()===j&&!o,C=()=>{v(""),x(!0)},N=()=>{x(!1),v("")},I=async()=>{if(!(!e||!b)){l(!0),d("");try{await T.leaveTeam(e.id),await n(),h("You have left the team."),i(null),N()}catch(z){d(z instanceof Error?z.message:"Failed to leave team")}finally{l(!1)}}},E=e&&S?`${S}/dashboard/groups/${e.id}`:void 0,A=S?`${S}/dashboard/groups`:void 0;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"page-header",children:s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:"Team"}),s.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),c&&s.jsx("div",{className:"error-message",children:c}),f&&s.jsx("div",{className:"alert alert-success",children:f}),e?s.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[s.jsxs("div",{className:"card-header",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"card-title",children:e.name}),s.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((D=a==null?void 0:a.members)==null?void 0:D.length)??0," ",(((L=a==null?void 0:a.members)==null?void 0:L.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),s.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(K=a==null?void 0:a.members)==null?void 0:K.map(z=>s.jsxs("div",{className:"member-row",children:[s.jsx("div",{className:"member-avatar",children:z.name.split(" ").map(Q=>Q[0]).join("").slice(0,2).toUpperCase()}),s.jsxs("div",{className:"member-info",children:[s.jsx("div",{className:"member-name",children:z.name}),s.jsx("div",{className:"member-email",children:z.email})]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:z.role})]},z.id)),s.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[E&&s.jsx("a",{className:"btn btn-secondary btn-sm",href:E,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),s.jsx("span",{title:y?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:s.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:C,disabled:o||y,children:"Leave team"})})]})]}):s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[s.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),s.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",maxWidth:480,marginLeft:"auto",marginRight:"auto"},children:"Every mandate you create here is in your personal context. You can join an existing team or create a new one in your Authority Server dashboard."}),A&&s.jsx("a",{className:"btn btn-primary btn-sm",href:A,target:"_blank",rel:"noopener noreferrer",children:"Open Authority Server dashboard →"})]}),m&&e&&s.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:N,children:s.jsxs("div",{className:"card",onClick:z=>z.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[s.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",j,"?"]}),s.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),s.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[s.jsx("li",{children:"Revoke all mandates you created in this team's context"}),s.jsx("li",{children:"Reject any pending action proposals you authored"}),s.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),s.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",s.jsx("strong",{children:"personal"})," mandates are not affected."]}),s.jsxs("div",{className:"form-group",children:[s.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",s.jsx("code",{children:j})," to confirm:"]}),s.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:w,onChange:z=>v(z.target.value),placeholder:j,disabled:o,autoFocus:!0})]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:N,disabled:o,children:"Cancel"}),s.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:I,disabled:!b,children:o?"Leaving...":"Leave team"})]})]})})]})}const k0=new Set(["mail","users","receipt","credit-card","calendar","megaphone","archive","rocket","flask","shopping-cart","bar-chart","help-circle"]),b0={email:"mail",customers:"users",sales:"receipt",charge:"credit-card",calendar:"calendar",publish:"megaphone",records:"archive",deploy:"rocket",delegation:"flask",purchase:"shopping-cart",reporting:"bar-chart"};function N0(e){const t=e.lastIndexOf("/"),n=t>=0?e.slice(t+1):e,r=n.indexOf("@");return(r>=0?n.slice(0,r):n).toLowerCase()}function Vn(e,t){const n=N0(e),r=t!=null&&t.icon&&k0.has(t.icon)?t.icon:b0[n]??"help-circle",a=Oe(e,t==null?void 0:t.name);return{icon:r,name:a,testSetup:n==="delegation"}}function ii(e){return e.startsWith("setup__")}const C0={mail:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("path",{d:"m3 7 9 6 9-6"})]}),users:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),s.jsx("path",{d:"M3.5 20c0-3.6 2.5-6.3 5.5-6.3s5.5 2.7 5.5 6.3"}),s.jsx("circle",{cx:"17.2",cy:"9.2",r:"2.3"}),s.jsx("path",{d:"M16.8 13.9c2.4.5 4.2 2.6 4.2 5.4"})]}),receipt:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6 3h12v18l-2.2-1.4L14 21l-2-1.4L10 21l-2-1.4L6 21V3Z"}),s.jsx("line",{x1:"9",y1:"7.5",x2:"15",y2:"7.5"}),s.jsx("line",{x1:"9",y1:"11.5",x2:"15",y2:"11.5"}),s.jsx("line",{x1:"9",y1:"15.5",x2:"13",y2:"15.5"})]}),"credit-card":s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2.2"}),s.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"}),s.jsx("line",{x1:"5.5",y1:"15",x2:"9.5",y2:"15"})]}),calendar:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4.5",width:"18",height:"16.5",rx:"2"}),s.jsx("line",{x1:"3",y1:"9.5",x2:"21",y2:"9.5"}),s.jsx("line",{x1:"8",y1:"2.5",x2:"8",y2:"6.5"}),s.jsx("line",{x1:"16",y1:"2.5",x2:"16",y2:"6.5"})]}),megaphone:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 10.2v3.6c0 .7.6 1.2 1.2 1.2h2.6l6.4 4V5l-6.4 4H4.2C3.6 9 3 9.5 3 10.2Z"}),s.jsx("path",{d:"M14.5 8.3a4.3 4.3 0 0 1 0 7.4"}),s.jsx("path",{d:"M17.6 6a7.6 7.6 0 0 1 0 12"})]}),archive:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"3.5",width:"18",height:"5",rx:"1.2"}),s.jsx("path",{d:"M5 8.5V18a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5"}),s.jsx("line",{x1:"10",y1:"13",x2:"14",y2:"13"})]}),rocket:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 2.2c2.4 2 3.8 5.3 3.8 8.6 0 1.9-.9 3.9-.9 3.9H9.1s-.9-2-.9-3.9c0-3.3 1.4-6.6 3.8-8.6Z"}),s.jsx("path",{d:"M9 14.7 6.3 19.4l3.8-1.7"}),s.jsx("path",{d:"M15 14.7l2.7 4.7-3.8-1.7"}),s.jsx("circle",{cx:"12",cy:"9.3",r:"1.3"})]}),flask:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M9 3h6"}),s.jsx("path",{d:"M10 3v6.3l-5 9.1A2 2 0 0 0 6.7 21.5h10.6a2 2 0 0 0 1.7-3.1l-5-9.1V3"}),s.jsx("line",{x1:"8.3",y1:"14.5",x2:"15.7",y2:"14.5"})]}),"shopping-cart":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9",cy:"20",r:"1.4"}),s.jsx("circle",{cx:"18",cy:"20",r:"1.4"}),s.jsx("path",{d:"M2.5 3h2.4l2.1 11.2a2 2 0 0 0 2 1.6h8.6a2 2 0 0 0 2-1.6l1.4-7.6H6"})]}),"bar-chart":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"4",y1:"20.5",x2:"20",y2:"20.5"}),s.jsx("rect",{x:"6",y:"13",width:"3.2",height:"7.5"}),s.jsx("rect",{x:"11.4",y:"8.5",width:"3.2",height:"12"}),s.jsx("rect",{x:"16.8",y:"4",width:"3.2",height:"16.5"})]}),"help-circle":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),s.jsx("path",{d:"M9.6 9.6a2.5 2.5 0 1 1 3.6 2.3c-.9.5-1.4 1.1-1.4 2.2"}),s.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function sh({icon:e,className:t}){return s.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:C0[e]})}function Ns({profileId:e,declared:t}){const{icon:n,name:r}=Vn(e,t);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"id-rail",children:[s.jsx(sh,{icon:n,className:"id-rail-icon"}),s.jsx("span",{className:"id-rail-name",children:r})]}),s.jsx("div",{className:"id-sep"})]})}const Go=e=>e.replace(/@.*$/,"").split("/").pop()??e,Mu=e=>e.split("@")[1]??"";function E0(e,t){const n=new Map;for(const r of e){const a=Go(r.id);if(!t.has(a))continue;const i=n.get(a);(!i||Mu(r.id).localeCompare(Mu(i.id),void 0,{numeric:!0})>0)&&n.set(a,r)}return n}function T0(e,t,n,r){var l;const a=new Set([...t.filter(c=>c.profile).map(c=>c.profile),...r.map(c=>Go(c.profile))]),i=E0(e,a),o=[];for(const c of t){const d=c.profile?i.get(c.profile):void 0;d&&o.push({key:`connector:${c.id}`,name:c.name,description:c.description||d.description,profile:d,kind:"connector",ready:((l=n.find(f=>f.id===c.id))==null?void 0:l.running)===!0,setupId:c.id})}for(const c of r){const d=i.get(Go(c.profile));d&&o.push({key:`builtin:${c.id}`,name:c.name,description:c.description||d.description,profile:d,kind:"builtin",ready:c.available,unavailableReason:c.available?void 0:"Available only while simulation mode is on."})}return o}function I0({onDismiss:e}){const t=tn(),{group:n,groupId:r,domain:a,user:i}=Ue(),[o,l]=u.useState([]),[c,d]=u.useState([]),[f,h]=u.useState([]),[m,x]=u.useState([]),[w,v]=u.useState(!0),[S,g]=u.useState({});u.useEffect(()=>{Promise.all([T.listProfiles().catch(()=>[]),T.getIntegrationManifests().then(N=>N.manifests??[]).catch(()=>[]),T.getMcpHealth().catch(()=>null)]).then(async([N,I,E])=>{if(l(N),d(I),h((E==null?void 0:E.integrations)??[]),x((E==null?void 0:E.builtins)??[]),r){const A=await Promise.all(N.map(L=>T.getTeamProfileConfig(r,L.id).catch(()=>null))),D={};N.forEach((L,K)=>{const z=A[K];z&&(D[L.id]=z)}),g(D)}}).finally(()=>v(!1))},[r]);const p=T0(o,c,f,m),y=N=>{var I;return nh({isPersonal:!!(n!=null&&n.isPersonal),configLoaded:!w,approvers:(I=S[N.id])==null?void 0:I.approvers,userId:i==null?void 0:i.id,profileName:Oe(N.id),teamName:n==null?void 0:n.name})},j=N=>N in S,b=N=>{if(!r){console.error("No active group when creating authorization");return}const I=j(N);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:N,groupId:r,groupName:(n==null?void 0:n.name)??null,domain:a,isTeam:I,isPersonal:!!(n!=null&&n.isPersonal)})),sessionStorage.removeItem("agentGate"),e==null||e(),t("/mandates/new/intent")},C=N=>{r&&b(N)};return s.jsxs(s.Fragment,{children:[s.jsx("style",{children:`
|
|
70
70
|
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
|
|
71
71
|
.profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
|
|
72
72
|
@media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
|
|
73
73
|
@media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
|
|
74
|
-
`}),w?s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):h.length===0?s.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[s.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),s.jsx(tt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):s.jsx("div",{className:"profile-grid",children:h.map(N=>{const I=N.profile,E=j(I.id),A=y(I),D=!N.ready||!A.can,{icon:z}=Hn(I.id,{name:I.name,icon:I.icon});return s.jsxs("div",{className:"card",style:D?{opacity:.7}:void 0,children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[s.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[s.jsx(Km,{icon:z,className:"profile-chip-icon"}),N.name]}),E?s.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"}):n!=null&&n.isPersonal?s.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"}):null]}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:N.description}),A.can?N.ready?s.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>C(I.id),children:"Give a mandate"}):N.kind==="builtin"?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:N.unavailableReason})]}):s.jsxs(tt,{to:`/integrations?setup=${N.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",N.name]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[A.reason," ",s.jsx("span",{style:{color:"var(--text-tertiary)"},children:A.fix})]})]})]},N.key)})})]})}const g0={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function y0({status:e,label:t}){return s.jsx("span",{className:`status-badge status-${e}`,children:t||g0[e]})}function v0({domain:e,attested:t}){const n=t===!0?"domain-attested":t===!1?"domain-missing":"";return s.jsx("span",{className:`domain-badge ${n}`,style:{fontSize:"0.75rem"},children:e})}const In=86400,Ur=3600,Ks=60,x0=30*In;function w0(e){if(e<=0)return"Expired";if(e>90*In){const t=Math.floor(e/x0);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*In){const t=Math.floor(e/In);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*In){const t=Math.floor(e/In),n=Math.floor(e%In/Ur);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*Ur){const t=Math.floor(e/Ur),n=Math.floor(e%Ur/Ks);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=Ks){const t=Math.floor(e/Ks),n=Math.floor(e%Ks);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function j0({expiresAt:e}){const[t,n]=u.useState(()=>e-Date.now()/1e3),r=t<2*Ur;u.useEffect(()=>{const i=setInterval(()=>n(e-Date.now()/1e3),r?1e3:6e4);return()=>clearInterval(i)},[e,r]);const a=t<300;return s.jsx("span",{className:`ttl-badge ${a?"ttl-warn":"ttl-ok"}`,children:w0(t)})}function Fa({icon:e,title:t,text:n,children:r}){return s.jsxs("div",{className:"empty-state",children:[e&&s.jsx("div",{className:"empty-state-icon",children:e}),s.jsx("div",{className:"empty-state-title",children:t}),n&&s.jsx("div",{className:"empty-state-text",children:n}),r]})}function S0(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 k0=[{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 b0({item:e,onClose:t,onSuccess:n}){var y;const{user:r,activeDomain:a,groupId:i}=Ue(),[o,l]=u.useState(null);u.useEffect(()=>{let j=!1;return T.getProfile(e.profile_id).then(b=>{var C;j||l(((C=b==null?void 0:b.ttl)==null?void 0:C.max)??null)}).catch(()=>{}),()=>{j=!0}},[e.profile_id]);const c=e.remaining_seconds??0,d=k0.filter(j=>j.seconds>c&&(o===null||j.seconds<=o)),f=((y=d[0])==null?void 0:y.seconds)??2592e3,[m,p]=u.useState(f);u.useEffect(()=>{var j;if(o!==null&&m>o){const b=(j=d[d.length-1])==null?void 0:j.seconds;b&&p(b)}},[o]);const[x,w]=u.useState(!1),[v,S]=u.useState(""),g=Object.entries(e.frame).filter(([j])=>j!=="profile"&&j!=="path"),h=async()=>{var j;if(r){w(!0),S("");try{const b=e.authorization_id,C=await T.getGateContent(b);if(!C)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const N=await T.getProfile(e.profile_id),I=e.frame,E=C.context??{},A=e.attested_domains[0]||a||"owner",D=await ca(I,N),z=await Um(E,N),[K,$]=await Promise.all([Ma(C.gateContent.intent),Ma(JSON.stringify({profile:e.profile_id,path:e.path,domain:A}))]);if(!i)throw new Error("No active group; cannot extend mandate.");const Q=(((j=e.deferred_commitment_domains)==null?void 0:j.length)??0)>0?"review":"automatic",H=await T.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:I,bounds_hash:D,context_hash:z,domain:A,did:r.did,gate_content_hashes:{intent:K},execution_context_hash:$,group_id:i,commitment_mode:Q,ttl:m});await T.pushGateContent(Wm(H,{boundsHash:D,contextHash:z,context:E,path:e.path,gateContent:C.gateContent})),n()}catch(b){S(b instanceof Error?b.message:"Extension failed")}finally{w(!1)}}};return s.jsx("div",{className:"modal-backdrop",onClick:j=>j.target===j.currentTarget&&t(),children:s.jsxs("div",{className:"modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:"Extend mandate"}),s.jsx("button",{className:"modal-close",onClick:t,children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[s.jsxs("div",{style:{marginBottom:"1rem"},children:[s.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Oe(e.profile_id)," / ",e.path]}),g.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:g.map(([j,b])=>`${j}=${b}`).join(" · ")})]}),s.jsxs("div",{style:{marginBottom:"1rem"},children:[s.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&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",S0(c),". Only longer durations are shown."]}),s.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:d.length===0?s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):d.map(j=>s.jsx("button",{className:`btn ${m===j.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>p(j.seconds),style:{minWidth:"3.5rem"},children:j.label},j.seconds))})]}),s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),v&&s.jsx("div",{className:"error-message",children:v})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:t,disabled:x,children:"Cancel"}),s.jsx("button",{className:"btn btn-primary",onClick:h,disabled:x,children:x?"Extending...":"Extend"})]})]})})}function N0(e,t,n){return[...e].sort((r,a)=>{if(n){if(r.authorization_id===n&&a.authorization_id!==n)return-1;if(a.authorization_id===n&&r.authorization_id!==n)return 1}const i=$a(r,t),o=$a(a,t),l={active:0,pending:1,expired:2,revoked:3,archived:4};return l[i]!==l[o]?l[i]-l[o]:new Date(a.created_at).getTime()-new Date(r.created_at).getTime()})}function C0({item:e,newerProfile:t,revokedSet:n,expandedHash:r,gateCache:a,gateLoading:i,copiedHash:o,revokingHash:l,copyingHash:c,profileConfigCache:d,mode:f,ownerLabel:m,isAdmin:p,onExpand:x,onCopyHash:w,onCopy:v,onRevoke:S,onExtend:g,archivedSet:h,archivingHash:y,onArchive:j,highlightHash:b}){var Le;const C=Ql(e,{revokedSet:n}),N=bm(e,{revokedSet:n,archivedSet:h}),I=!m&&!!j&&km(C),E=r===e.authorization_id,A=a[e.authorization_id],D=C==="active"||C==="pending"||C==="expired",z=Object.entries(e.frame).filter(([q])=>q!=="profile"&&q!=="path"),K=d.get(e.profile_id)??null,$=(((Le=K==null?void 0:K.approvers)==null?void 0:Le.length)??0)>0,Q=new Map;if(K!=null&&K.caps&&f==="team")for(const[q,ee]of z){const X=K.caps[q];X!==void 0&&Number(ee)>X&&Q.set(q,{authorized:Number(ee),cap:X})}const H=Q.size>0,O=e.approvers_frozen??[],_=(K==null?void 0:K.approvers)??[],P=f==="team"&&O.length>0&&_.length>0&&(O.length!==_.length||O.some(q=>!_.includes(q))||_.some(q=>!O.includes(q))),V=Array.from(Q.entries()).map(([q,ee])=>`${q}: ${ee.authorized} (cap ${ee.cap})`).join(", "),R=Array.from(Q.entries()).map(([q,ee])=>`${q}: ${ee.authorized} → ${ee.cap}`).join(", "),L=H?$?Q.size===1?`Above team cap: ${V} — actions require approval`:`Above team cap (${Q.size}): ${V} — actions require approval`:Q.size===1?`Reduced by hard cap: ${R}`:`Reduced by hard cap (${Q.size}): ${R}`:"",Y=H?$?"Above-cap actions under this mandate 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 mandate to reissue within the cap.":void 0,te=Hn(e.profile_id),ne=te.name,de=t?s.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:[s.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[ne,"@",t.version," available"]}),t.whatsNew?s.jsxs(s.Fragment,{children:[" — ",t.whatsNew]}):null,s.jsx("br",{}),s.jsxs("span",{children:["This mandate stays on ",e.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,xe=b!=null&&e.authorization_id===b;return s.jsxs("div",{className:`card id-card${xe?" card-highlight":""}`,style:{marginBottom:0},children:[s.jsx(bs,{profileId:e.profile_id}),s.jsxs("div",{className:"id-body",children:[de,m&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",s.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:m})]}),s.jsxs("div",{className:"auth-card-header",children:[s.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:e.title||ne}),s.jsx(y0,{status:C}),te.testSetup&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),C==="active"&&e.earliest_expiry&&s.jsx(j0,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),C==="expired"&&(()=>{const q=wv(e,C);return q?s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(q.iso).toLocaleString()}`,children:new Date(q.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}):null})()]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[e.required_domains.map(q=>s.jsx(v0,{domain:q,attested:e.attested_domains.includes(q)},q)),e.deferred_commitment_domains.length>0&&s.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"}),H&&s.jsx("span",{title:Y,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:$?"var(--accent-subtle)":"var(--danger-subtle)",color:$?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:L}),P&&s.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:()=>v(e),disabled:c===e.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:c===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),z.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:z.map(([q,ee],X)=>{const oe=Q.get(q);return s.jsxs("span",{children:[X>0&&" · ",oe?$?s.jsxs("span",{title:`Team cap on ${q} is ${oe.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${oe.authorized}.`,children:[s.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[q,"=",String(ee)]}),s.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",oe.cap]})]}):s.jsxs("span",{title:`Team cap on ${q} is ${oe.cap} with no approvers configured (hard cap). Authorized for ${oe.authorized}; effective ${oe.cap}.`,children:[s.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[q,"=",String(ee)]}),s.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",oe.cap]})]}):s.jsxs("span",{children:[q,"=",String(ee)]})]},q)})}),s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[I&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>j(e.authorization_id,!N),disabled:y===e.authorization_id,title:N?"Move back to the Expired or Revoked list":"Hide from the list and the nav badge. Nothing is deleted: the mandate and its tickets stay stored and verifiable.",children:y===e.authorization_id?N?"Unarchiving…":"Archiving…":N?"↩ Unarchive":"⊟ Archive"}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>x(e),children:E?"▲ Hide Details":"▼ Details"})]}),E&&s.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[z.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),s.jsx("dl",{className:"review-grid",children:z.map(([q,ee])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:q}),s.jsx("dd",{children:String(ee)})]},q))})]}),(A==null?void 0:A.context)&&Object.keys(A.context).length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Scope"}),s.jsx("dl",{className:"review-grid",children:Object.entries(A.context).map(([q,ee])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:q}),s.jsx("dd",{title:String(ee),children:Hm(q,ee,A.contextLabels)})]},q))})]}),s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),i===e.authorization_id?s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):A?s.jsx("div",{className:"gate-content-block",children:s.jsx("div",{className:"gate-content-item",children:s.jsx("div",{className:"gate-content-text",children:A.gateContent.intent})})}):s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),s.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()}`]}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:e.authorization_id}),s.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>w(e.authorization_id),children:o===e.authorization_id?"copied":"copy"})]}),s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!m&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>v(e),disabled:c===e.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:c===e.authorization_id?"Copying…":"⧉ Copy"}),!m&&(C==="active"||C==="pending")&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>v(e,{asEdit:!0}),disabled:c===e.authorization_id,title:"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:"✎ Edit"}),!m&&D&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>g(e),children:"↻ Extend"}),m&&p&&C!=="revoked"?s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>S(e.authorization_id,m,ne),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):!m&&(C==="active"||C==="pending")?s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>S(e.authorization_id),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]})]},e.authorization_id)}function E0(){const[e,t]=u.useState([]),[n,r]=u.useState(!0),[a,i]=u.useState([]),[o,l]=u.useState(!1),[c,d]=u.useState(new Map),[f,m]=u.useState("mine"),[p,x]=u.useState("active"),[w,v]=u.useState(null),[S,g]=u.useState(null),[h,y]=Gl(),[j,b]=u.useState(()=>h.get("new")==="1"),[C,N]=u.useState(()=>h.get("highlight")),[I,E]=u.useState(null),[A,D]=u.useState({}),[z,K]=u.useState(null),[$,Q]=u.useState(null),[H,O]=u.useState(null),[_,P]=u.useState(new Set),[V,R]=u.useState(null),[L,Y]=u.useState(new Set),[te,ne]=u.useState(null),[de,xe]=u.useState(null),Le=tn(),{group:q,groupId:ee,domain:X,mode:oe,activeTeam:W}=Ue(),re=(W==null?void 0:W.isAdmin)===!0,[se,Ce]=u.useState(()=>new Map),Ge=u.useCallback(()=>{r(!0),T.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),_e=u.useCallback(()=>{T.getArchivedMandates().then(F=>Y(new Set(F))).catch(()=>{})},[]);u.useEffect(()=>{_e()},[_e]);const xt=async(F,Z)=>{ne(F);try{const ie=await T.setMandateArchived(F,Z);Y(new Set(ie)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(ie){alert(ie instanceof Error?ie.message:"Failed to update archive")}finally{ne(null)}},at=u.useCallback(()=>{ee&&(l(!0),T.listTeamAuthorizations(ee).then(i).catch(()=>{}).finally(()=>l(!1)))},[ee]);he("attestation-changed",()=>{Ge(),re&&ee&&at()}),u.useEffect(()=>{if(!C)return;h.get("highlight")&&(h.delete("highlight"),y(h,{replace:!0}));const F=window.setTimeout(()=>N(null),3e3);return()=>window.clearTimeout(F)},[]),At(Ge,3e5),u.useEffect(()=>{f==="team"&&re&&ee&&a.length===0&&!o&&at()},[f,re,ee,a.length,o,at]),u.useEffect(()=>{let F=!1;return T.listProfiles().then(Z=>{if(F)return;const ie=Ee=>Ee.replace(/@.*$/,"").split("/").pop()??Ee,ue=Ee=>Ee.split("@")[1]??"",ge=new Map;for(const Ee of Z){const le=ie(Ee.id),wt=ge.get(le);(!wt||ue(Ee.id).localeCompare(ue(wt.id),void 0,{numeric:!0})>0)&&ge.set(le,Ee)}d(ge)}).catch(()=>{}),()=>{F=!0}},[]);const Ke=u.useCallback(F=>{const Z=le=>le.replace(/@.*$/,"").split("/").pop()??le,ie=le=>le.split("@")[1]??"",ue=c.get(Z(F));if(!ue)return;const ge=ie(F),Ee=ie(ue.id);if(!(!ge||!Ee))return Ee.localeCompare(ge,void 0,{numeric:!0})>0?ue:void 0},[c]);u.useEffect(()=>{if(oe!=="team"||!ee)return;const F=f==="mine"?e:a;if(F.length===0)return;const Z=[...new Set(F.map(ie=>ie.profile_id))].filter(ie=>!se.has(ie));if(Z.length!==0){Ce(ie=>{const ue=new Map(ie);for(const ge of Z)ue.set(ge,null);return ue});for(const ie of Z)T.getTeamProfileConfig(ee,ie).then(ue=>{Ce(ge=>new Map(ge).set(ie,ue))}).catch(()=>{})}},[e,a,f,ee,oe,se]);const fe=async F=>{if(I===F.authorization_id){E(null);return}E(F.authorization_id);const Z=F.authorization_id;if(!(Z in A)){K(F.authorization_id);try{const ie=await T.getGateContent(Z);D(ue=>({...ue,[Z]:ie}))}catch{D(ie=>({...ie,[Z]:null}))}finally{K(null)}}},Ze=F=>{navigator.clipboard.writeText(F).then(()=>{O(F),setTimeout(()=>O(null),2e3)})},nn=async(F,Z)=>{var ie;if(!ee){alert("No active group; cannot copy mandate.");return}xe(F.authorization_id);try{const ue=F.authorization_id;let ge=A[ue]??null;ue in A||(ge=await T.getGateContent(ue),D(Ns=>({...Ns,[ue]:ge})));const Ee=Object.fromEntries(Object.entries(F.frame).filter(([Ns])=>Ns!=="profile"&&Ns!=="path")),le=(ge==null?void 0:ge.context)??{},wt=((ie=ge==null?void 0:ge.gateContent)==null?void 0:ie.intent)??"",ai=F.deferred_commitment_domains.length>0?"review":"automatic",tp=F.attested_domains[0]||X||"owner",ii=Date.parse(F.created_at),oi=F.earliest_expiry?Date.parse(F.earliest_expiry):NaN,np=Number.isFinite(ii)&&Number.isFinite(oi)&&oi>ii?Math.round((oi-ii)/1e3):void 0;sessionStorage.setItem("agentAuth",JSON.stringify({profileId:F.profile_id,groupId:ee,groupName:(q==null?void 0:q.name)??null,domain:tp,isPersonal:!!(q!=null&&q.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:Ee,context:le,gateContent:{intent:wt},templateMode:ai,templateTtl:np})),Z!=null&&Z.asEdit?sessionStorage.setItem("agentEditReplaces",F.authorization_id):sessionStorage.removeItem("agentEditReplaces"),Le("/mandates/new/intent")}catch(ue){alert(ue instanceof Error?ue.message:"Failed to copy mandate")}finally{xe(null)}},k=async(F,Z,ie)=>{const ue=Z&&ie?`Revoke ${Z}'s ${ie} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(ue)){R(F);try{await T.revokeAttestation(F),P(ge=>new Set(ge).add(F)),T.resyncGates().catch(()=>{}),Z&&ee&&at()}catch(ge){alert(ge instanceof Error?ge.message:"Failed to revoke mandate")}finally{R(null)}}},B=f==="mine"?e:a,G=f==="mine"?n:o,ae=f==="mine"?{revokedSet:_,archivedSet:L}:{revokedSet:_},U=F=>$a(F,ae),pe={active:0,pending:0,expired:0,revoked:0,archived:0};for(const F of B)pe[U(F)]+=1;const Pe=f==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],ke=(()=>{const F=new Map;for(const Z of B){if(U(Z)!==p)continue;const ie=F.get(Z.profile_id)??{count:0,review:!1};ie.count+=1,Z.deferred_commitment_domains.length>0&&(ie.review=!0),F.set(Z.profile_id,ie)}return Array.from(F.entries()).map(([Z,ie])=>({profileId:Z,...ie})).sort((Z,ie)=>Oe(Z.profileId).localeCompare(Oe(ie.profileId)))})(),Ye=N0(B.filter(F=>{if(U(F)!==p||w!==null&&F.profile_id!==w)return!1;if(S!==null){const Z=F.deferred_commitment_domains.length>0;if(S==="review"&&!Z||S==="auto"&&Z)return!1}return!0}),ae,C),bn={revokedSet:_,expandedHash:I,gateCache:A,gateLoading:z,copiedHash:H,revokingHash:V,copyingHash:de,profileConfigCache:se,mode:oe,activeDomain:X,group:q,groupId:ee,onExpand:fe,onCopyHash:Ze,onCopy:nn,onRevoke:k,onExtend:Q,highlightHash:C},Nn={...bn,archivedSet:L,archivingHash:te,onArchive:xt};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:"Mandates"}),s.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),s.jsx("button",{className:"btn btn-primary",onClick:()=>b(!0),children:"+ New mandate"})]}),j&&s.jsx("div",{className:"modal-backdrop",onClick:()=>{b(!1),h.get("new")&&(h.delete("new"),y(h,{replace:!0}))},children:s.jsxs("div",{className:"modal",onClick:F=>F.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h2",{className:"modal-title",children:"New mandate"}),s.jsx("button",{className:"modal-close",onClick:()=>{b(!1),h.get("new")&&(h.delete("new"),y(h,{replace:!0}))},children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[s.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."}),s.jsx(h0,{onDismiss:()=>b(!1)})]})]})}),re&&s.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[s.jsx("button",{className:`nav-tab${f==="mine"?" active":""}`,onClick:()=>{m("mine"),x("active"),v(null),g(null),E(null)},children:"Mine"}),s.jsx("button",{className:`nav-tab${f==="team"?" active":""}`,onClick:()=>{m("team"),x("active"),v(null),g(null),E(null)},children:"Team"})]}),s.jsx("div",{className:"nav-tabs",children:Pe.map(F=>s.jsxs("button",{className:`nav-tab${p===F?" active":""}`,onClick:()=>{x(F),v(null),g(null)},children:[F.charAt(0).toUpperCase()+F.slice(1)," (",pe[F],")"]},F))}),ke.length>0&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[ke.map(F=>{const Z=w===F.profileId;return s.jsx("button",{className:`btn btn-sm ${Z?"btn-primary":"btn-secondary"}`,onClick:()=>v(Z?null:F.profileId),children:Oe(F.profileId)},F.profileId)}),s.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(F=>{const Z=S===F;return s.jsx("button",{className:`btn btn-sm ${Z?"btn-primary":"btn-secondary"}`,onClick:()=>g(Z?null:F),children:F==="auto"?"Auto":"Review"},F)})]}),G&&B.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Ye.length===0?s.jsx(Fa,{icon:"☰",title:"No mandates",text:p==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${p} mandates found.`}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:Ye.map(F=>{const Z=f==="team"?F:null,ie=Z!=null&&Z.owner?Z.owner.name??Z.owner.email??Z.owner.userId:void 0;return s.jsx(C0,{item:F,newerProfile:Ke(F.profile_id),ownerLabel:ie,isAdmin:re,...f==="mine"?Nn:bn},F.authorization_id)})}),$&&s.jsx(b0,{item:$,onClose:()=>Q(null),onSuccess:()=>{Q(null),Ge()}})]})}function T0(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function I0(e,t){var c,d,f;const{integrationId:n,toolName:r}=T0(e.action),a=t.find(m=>m.id===n),i=(d=(c=a==null?void 0:a.toolGating)==null?void 0:c.overrides)==null?void 0:d[r];if(i!=null&&i.actionLabel)return i.actionLabel;const o=Oe(e.profileId),l=(f=e.executionContext)==null?void 0:f.action_type;return typeof l=="string"&&l?`${o} · ${l}`:`${o} · ${r}`}function R0(e){const t=[];for(const[n,r]of Object.entries(e.executionContext??{})){if(!n.startsWith("allowed_"))continue;const a=String(r??"").trim();a&&t.push(a.split(",").map(i=>i.trim()).filter(Boolean).join(", "))}return t.join(" · ")}function P0(e){if(!e)return"";const t=[];for(const[n,r]of Object.entries(e)){if(n==="action_type")continue;const a=String(r??"").trim();if(!a)continue;const i=n.replace(/^allowed_/,"").replace(/_/g," ");t.push(`${i} ${a.split(",").map(o=>o.trim()).filter(Boolean).join(", ")}`)}return t.join(" · ")}function A0(e,t){var i,o;const n=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],r=e.actionType??(typeof((i=e.executionContext)==null?void 0:i.action_type)=="string"?e.executionContext.action_type:void 0),a=[];for(const{window:l,label:c}of n){const d=(o=e.cumulativeState)==null?void 0:o[l];if(!d)continue;const f=`_${l}_max`,m=Object.keys(t??{}).filter(S=>S.endsWith(f)),p=(r&&m.find(S=>S.startsWith(`${r}_`)))??(m.length===1?m[0]:void 0),w=(p?/^(amount|spend)_/.test(p):!1)?d.amount:d.count,v=p?Number(t==null?void 0:t[p]):NaN;p&&Number.isFinite(v)?a.push(`${w} of ${v} ${c}`):a.push(`${d.count} ${d.count===1?"call":"calls"} ${c}`)}return a.join(" · ")}function _0(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function z0(e){const t=Oe(e),n=e.split("@")[1];return n?`${t}@${n}`:t}function $r({label:e,children:t}){return s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"receipt-row-label",children:e}),s.jsx("dd",{className:"receipt-row-value",children:t})]})}function $0({receipt:e,manifests:t,localAuth:n,localUnavailable:r,signature:a,grantTitle:i,ownerLabel:o,spUrl:l,formatDate:c,onOpenComplete:d}){var v;const f=R0(e),m=P0(n==null?void 0:n.context),p=A0(e,(n==null?void 0:n.bounds)??e.limits),x=n==null?void 0:n.intent,w=Hn(e.profileId).testSetup||si(e.action);return s.jsxs("div",{className:"card id-card",style:{marginBottom:0},children:[s.jsx(bs,{profileId:e.profileId}),s.jsxs("div",{className:"id-body",children:[s.jsxs("div",{className:"receipt-head",children:[s.jsx("span",{className:"receipt-what",children:I0(e,t)}),s.jsx("span",{className:"receipt-tag",children:_0(e)?"review":"automatic"}),e.contentHash&&s.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(v=e.contentBinding)!=null&&v.fields?`The ticket binds: ${e.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),w&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),s.jsx("span",{className:"auth-card-time",children:c(e.timestamp)})]}),f&&s.jsx("div",{className:"receipt-scope",children:f}),s.jsxs("dl",{className:"receipt-rows",children:[s.jsx($r,{label:"mandate",children:s.jsx("strong",{children:i||z0(e.profileId)})}),o&&s.jsx($r,{label:"owner",children:o}),m&&s.jsx($r,{label:"allowed",children:m}),p&&s.jsx($r,{label:"used",children:s.jsx("span",{className:"receipt-num",children:p})}),s.jsx($r,{label:"intent",children:x?s.jsx("span",{className:"receipt-intent",children:x}):s.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"})})]}),s.jsxs("div",{className:"receipt-foot",children:[a==="valid"&&s.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued — no Authority Server involved.",children:"✓ Verified on this device"}),a==="invalid"&&s.jsx("span",{className:"receipt-tamper",title:"The stored ticket does not match what was signed.",children:"⚠ Signature check FAILED"}),s.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:d,children:"Complete ticket"}),l&&s.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",s.jsx("a",{className:"receipt-link",href:`${l}/r/${e.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),s.jsxs("details",{className:"receipt-more",children:[s.jsx("summary",{children:"Raw"}),s.jsxs("div",{className:"receipt-kv",children:[s.jsxs("div",{children:["ticket · ",e.id]}),s.jsxs("div",{children:["action · ",e.action]}),s.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&s.jsxs("div",{children:["mandate · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&s.jsxs("div",{children:["scope ·"," ",Object.entries(e.executionContext).map(([S,g])=>`${S}=${g}`).join(" · ")]}),(n==null?void 0:n.boundsHash)&&s.jsxs("div",{children:["bounds hash · ",n.boundsHash]}),(n==null?void 0:n.contextHash)&&s.jsxs("div",{children:["scope hash · ",n.contextHash]}),e.contentHash&&s.jsxs("div",{children:["content · ",e.contentHash]}),e.proposalId&&s.jsxs("div",{children:["proposal · ",e.proposalId]}),s.jsxs("div",{children:["signature · ",e.signature]})]})]})]})]})}function L0({receipt:e,onClose:t}){const[n,r]=u.useState(null),[a,i]=u.useState(null),[o,l]=u.useState(null),[c,d]=u.useState(!0),[f,m]=u.useState(!1);u.useEffect(()=>{let S=!1;return d(!0),T.getArchivedReceipt(e.id).then(g=>{S||(r(g),i(g?"local":"authority-server"),l((g==null?void 0:g.signature)??null))}).catch(()=>{S||i("authority-server")}).finally(()=>{S||d(!1)}),()=>{S=!0}},[e.id]);const p=n?n.entry:{receipt:e},x=JSON.stringify(p,null,2);function w(){const S=URL.createObjectURL(new Blob([x],{type:"application/json"})),g=document.createElement("a");g.href=S,g.download=`suveren-ticket-${e.id.slice(0,8)}.json`,g.click(),URL.revokeObjectURL(S)}async function v(){try{await navigator.clipboard.writeText(x),m(!0),setTimeout(()=>m(!1),2e3)}catch{m(!1)}}return s.jsx("div",{className:"modal-backdrop",onClick:S=>S.target===S.currentTarget&&t(),children:s.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:"Complete ticket"}),s.jsx("button",{className:"modal-close",onClick:t,"aria-label":"Close",children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[o==="valid"&&s.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 ticket was issued."}),o==="invalid"&&s.jsx("p",{className:"receipt-tamper",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"⚠ Signature check FAILED — the stored ticket does not match what was signed."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:c?"Loading…":a==="local"?"Held on this device — the signed ticket, the mandate 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 ticket (it predates local archiving, or ran on another device). Shown from the Authority Server — complete and signed, but it needs the server to retrieve."}),s.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})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-primary btn-sm",onClick:w,children:"Download"}),s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:v,children:f?"Copied":"Copy"})]})]})})}function M0(e){return new Date(e*1e3).toLocaleString()}function F0(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 O0(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||Oe(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 Ru(e,t){const n=new Map(e.map(r=>[r.id,r]));for(const r of t)n.set(r.id,r);return[...n.values()].sort((r,a)=>a.timestamp-r.timestamp)}function B0(){const{activeTeam:e,groupId:t}=Ue(),n=(e==null?void 0:e.isAdmin)===!0,[r,a]=u.useState("mine"),[i,o]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState(""),[m,p]=u.useState(!0),[x,w]=u.useState({}),[v,S]=u.useState(new Set),[g,h]=u.useState(""),[y,j]=u.useState(new Set),[b,C]=u.useState(new Set),[N,I]=u.useState("all"),[E,A]=u.useState(!1),[D,z]=u.useState(!1),[K,$]=u.useState(null),[Q,H]=u.useState({}),[O,_]=u.useState(!1),[P,V]=u.useState({}),[R,L]=u.useState({}),[Y,te]=u.useState(null),[ne,de]=u.useState(null),[xe,Le]=u.useState(!1),[q,ee]=u.useState(!1),X=u.useRef(""),oe=u.useCallback(k=>r==="team"&&n&&t?T.listTeamReceiptsPage(t,{before:k,limit:200}):T.getMyReceiptsPage({before:k,limit:200}),[r,n,t]),W=u.useCallback(()=>{const k=r==="team"?`team:${t}`:"mine",B=X.current!==k;X.current=k,p(!0),ee(!1),oe().then(G=>{o(ae=>B?G.receipts:Ru(ae,G.receipts)),de(ae=>B?G.nextBefore:ae??G.nextBefore)}).catch(()=>{B&&o([]),ee(!0)}).finally(()=>p(!1))},[oe,r,t]),re=u.useCallback(()=>{!ne||xe||(Le(!0),ee(!1),oe(ne).then(k=>{o(B=>Ru(B,k.receipts)),de(k.nextBefore)}).catch(()=>ee(!0)).finally(()=>Le(!1)))},[ne,xe,oe]);At(W,12e4),u.useEffect(()=>{T.getIntegrationManifests().then(({manifests:k})=>c(k)).catch(()=>{}),fetch("/health").then(k=>k.json()).then(k=>{typeof k.spUrl=="string"&&f(k.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),u.useEffect(()=>{T.getLocalAuthorizations().then(({authorizations:k,signatures:B})=>{H(k),V(B),_(!1)}).catch(()=>{H({}),V({}),_(!0)}),T.getMyAttestations().then(k=>{const B={};for(const G of k)G.authorization_id&&G.title&&(B[G.authorization_id]=G.title);L(B)}).catch(()=>{})},[]),u.useEffect(()=>{r!=="team"||Object.keys(x).length>0||T.listUsers().then(k=>{const B={};for(const G of k)B[G.id]={name:G.name,email:G.email};w(B)}).catch(()=>{})},[r,x]);const se=u.useMemo(()=>{const k=new Set;for(const B of i)k.add(Oe(B.profileId));return[...k].sort()},[i]),Ce=u.useMemo(()=>{const k=new Set;for(const B of i)k.add(B.action);return[...k].sort()},[i]),Ge=u.useMemo(()=>{if(r!=="team")return[];const k=new Set;for(const B of i)B.userId&&k.add(B.userId);return[...k].map(B=>{var G;return{id:B,label:(G=x[B])!=null&&G.name?`${x[B].name} (${x[B].email})`:B}}).sort((B,G)=>B.label.localeCompare(G.label))},[r,i,x]),_e=u.useMemo(()=>i.filter(k=>!(!O0(k,g)||y.size>0&&!y.has(Oe(k.profileId))||b.size>0&&!b.has(k.action)||v.size>0&&k.userId&&!v.has(k.userId)||!F0(k,N))),[i,g,y,b,v,N]),xt=y.size>0||b.size>0||v.size>0||N!=="all";function at(k){j(B=>{const G=new Set(B);return G.has(k)?G.delete(k):G.add(k),G})}function Ke(k){C(B=>{const G=new Set(B);return G.has(k)?G.delete(k):G.add(k),G})}function fe(k){S(B=>{const G=new Set(B);return G.has(k)?G.delete(k):G.add(k),G})}function Ze(){j(new Set),C(new Set),S(new Set),I("all"),h("")}async function nn(){z(!0),$(null);try{const{bundle:k,filename:B}=await T.fetchEvidenceBundle(),G=URL.createObjectURL(new Blob([JSON.stringify(k,null,2)],{type:"application/json"})),ae=document.createElement("a");ae.href=G,ae.download=B,ae.click(),URL.revokeObjectURL(G);const U=k.sources??{};U.authorityServer?U.local||$(`Downloaded Authority Server history only — ${U.localError??"local archive unavailable."}`):$(`Downloaded local evidence only — ${U.asError??"Authority Server export unavailable."}`)}catch(k){$(`Export failed: ${k instanceof Error?k.message:String(k)}`)}finally{z(!1)}}return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:"Tickets"}),s.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),s.jsx("button",{className:"btn btn-secondary",onClick:nn,disabled:D,children:D?"Preparing…":"Download evidence"})]}),K&&s.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:K}),n&&s.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(k=>s.jsx("button",{onClick:()=>a(k),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===k?"2px solid var(--accent)":"2px solid transparent",color:r===k?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===k?600:500},children:k==="mine"?"Mine":"Team"},k))}),s.jsxs("div",{className:"search-filter-bar",children:[s.jsxs("div",{className:"search-input-wrap",children:[s.jsx("span",{className:"search-icon",children:"⌕"}),s.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:g,onChange:k=>h(k.target.value)}),g&&s.jsx("button",{className:"search-clear",onClick:()=>h(""),children:"×"})]}),s.jsxs("button",{className:`btn btn-sm btn-secondary${E?" active":""}`,onClick:()=>A(!E),children:["Filters",xt?` (${y.size+b.size+(N!=="all"?1:0)})`:""]})]}),E&&s.jsxs("div",{className:"filter-panel",children:[se.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Profile"}),s.jsx("div",{className:"filter-chips",children:se.map(k=>s.jsx("button",{className:`filter-chip${y.has(k)?" selected":""}`,onClick:()=>at(k),children:k},k))})]}),Ce.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Action"}),s.jsx("div",{className:"filter-chips",children:Ce.map(k=>s.jsx("button",{className:`filter-chip${b.has(k)?" selected":""}`,onClick:()=>Ke(k),children:k},k))})]}),r==="team"&&Ge.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Owner"}),s.jsx("div",{className:"filter-chips",children:Ge.map(k=>s.jsx("button",{className:`filter-chip${v.has(k.id)?" selected":""}`,onClick:()=>fe(k.id),children:k.label},k.id))})]}),s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Time range"}),s.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([k,B])=>s.jsx("button",{className:`filter-chip${N===k?" selected":""}`,onClick:()=>I(k),children:B},k))})]})]}),xt&&s.jsxs("div",{className:"active-filters",children:[[...y].map(k=>s.jsxs("span",{className:"active-chip",onClick:()=>at(k),children:[k," ",s.jsx("span",{className:"chip-remove",children:"×"})]},k)),[...b].map(k=>s.jsxs("span",{className:"active-chip",onClick:()=>Ke(k),children:[k," ",s.jsx("span",{className:"chip-remove",children:"×"})]},k)),[...v].map(k=>{const B=x[k],G=B?B.name:k;return s.jsxs("span",{className:"active-chip",onClick:()=>fe(k),children:[G," ",s.jsx("span",{className:"chip-remove",children:"×"})]},k)}),N!=="all"&&s.jsxs("span",{className:"active-chip",onClick:()=>I("all"),children:[N==="1d"?"Today":N==="7d"?"7 days":"30 days"," ",s.jsx("span",{className:"chip-remove",children:"×"})]}),s.jsx("button",{className:"clear-filters",onClick:Ze,children:"Clear all"})]}),q&&s.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:s.jsx("span",{style:{color:"var(--danger, #c0392b)",fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),m&&i.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):_e.length===0?s.jsx(Fa,{icon:"⌕",title:i.length===0?"No tickets in the last 30 days":"No matching tickets",text:i.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:_e.length===i.length?`${i.length} ticket${i.length!==1?"s":""}`:`${_e.length} of ${i.length} tickets`}),s.jsx("div",{className:"timeline",children:_e.map(k=>{const B=k.userId?x[k.userId]:void 0;return s.jsx("div",{className:"timeline-event",children:s.jsx($0,{receipt:k,manifests:l,localAuth:k.authorizationId?Q[k.authorizationId]:void 0,localUnavailable:O,signature:P[k.id],grantTitle:k.authorizationId?R[k.authorizationId]:null,ownerLabel:r==="team"&&k.userId?B?`${B.name} (${B.email})`:k.userId:null,spUrl:d,formatDate:M0,onOpenComplete:()=>te(k)})},k.id)})})]}),Y&&s.jsx(L0,{receipt:Y,onClose:()=>te(null)}),ne&&s.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:re,disabled:xe,children:xe?"Loading…":"Load older"})})]})}const D0={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function U0(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(null),o=u.useCallback(async()=>{try{t(await T.getAutostart())}catch(d){i(d instanceof Error?d.message:"Could not read autostart state")}},[]);u.useEffect(()=>{o()},[o]);const l=u.useCallback(async()=>{if(!(!(e!=null&&e.supported)||n)){r(!0),i(null);try{await T.setAutostart(!e.installed)}catch(d){i(d instanceof Error?d.message:"Failed")}finally{try{t(await T.getAutostart()),i(null)}catch(d){i(d instanceof Error?d.message:"Could not re-read state")}r(!1)}}},[e,n,o]);if(!e)return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),s.jsx("p",{role:a?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:a?`Could not read autostart state: ${a}`:"Checking…"})]});const c=D0[e.platform]??"a login service";return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsxs("div",{children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),s.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:e.supported?s.jsxs(s.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",c," — no admin rights needed."]}):e.reason})]}),e.supported&&s.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&&s.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",s.jsx("strong",{children:e.installed?"On — starts from your next login":"Off"})]}),e.supported&&s.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 ",s.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),a&&s.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger, #c00)"},children:a})]})}function W0(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(null),o=u.useCallback(async()=>{try{const c=await T.getGatewaySettings();t(c.desktopNotifications),i(null)}catch(c){i(c instanceof Error?c.message:"Could not read notification setting")}},[]);u.useEffect(()=>{o()},[o]);const l=u.useCallback(async()=>{if(!(e===null||n)){r(!0),i(null);try{const c=await T.setGatewaySettings({desktopNotifications:!e});t(c.desktopNotifications)}catch(c){i(c instanceof Error?c.message:"Failed to save"),await o()}finally{r(!1)}}},[e,n,o]);return e===null?s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),s.jsx("p",{role:a?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:a?`Could not read the setting: ${a}`:"Checking…"})]}):s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsxs("div",{children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),s.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."})]}),s.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"})]}),a&&s.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:a})]})}const Pu={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function H0(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(null),o=u.useCallback(async()=>{try{t(await T.getIdentityDisclosure()),i(null)}catch(f){i(f instanceof Error?f.message:"Could not read the setting")}},[]);u.useEffect(()=>{o()},[o]);const l=u.useCallback(async()=>{if(!(!e||n)){r(!0),i(null);try{t(await T.setIdentityDisclosure(!e.always))}catch(f){i(f instanceof Error?f.message:"Failed to save"),await o()}finally{r(!1)}}},[e,n,o]),c=s.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!e)return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[c,s.jsx("p",{role:a?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:a?`Could not read the setting: ${a}`:"Checking…"})]});const d=e.verified&&e.name?`${e.name} — ${e.method==="as_vouched"?`${Pu.as_vouched} ${e.verifier}`:Pu[e.method??""]??e.method}`:null;return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsxs("div",{children:[c,s.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[e.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),s.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:d?`Your identity: ${d}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),s.jsx("button",{type:"button",onClick:()=>void l(),disabled:n,"aria-pressed":e.always,className:e.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:n?"Saving…":e.always?"Turn off":"Always show my name"})]}),a&&s.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:a})]})}const V0={npm:"Checking npm for new releases",docker:"Checking the container registry for new images",dev:"Git checkout — comparing against origin/main, not npm releases",managed:"Checking npm for new releases — managed by your IT",msi:"Checking for new releases — update with the Windows installer"};function G0(){const{version:e,latestVersion:t,updateAvailable:n,installMethod:r}=Kl();return e?s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",s.jsx("strong",{children:e}),n&&t?s.jsxs(s.Fragment,{children:[" — ",s.jsx("strong",{children:t})," is available"]}):null]}),s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[V0[r]??"Update checking is unavailable",r==="dev"&&s.jsx(s.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Ho({title:e}){return s.jsxs("span",{className:"it-locked-badge",title:e,children:[s.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function Au(e){return e===!0}function K0(){const[e,t]=u.useState(null),[n,r]=u.useState(null);u.useEffect(()=>{let o=!1;return T.getAsPairing().then(l=>{o||t(l)}).catch(l=>{o||r(l instanceof Error?l.message:"Could not read Authority Server info")}),()=>{o=!0}},[]);const a=Au(e==null?void 0:e.asUrlLockedByPolicy),i=Au(e==null?void 0:e.pinTlsLockedByPolicy);return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),a&&s.jsx(Ho,{})]}),!e&&!n&&s.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),n&&s.jsx("p",{role:"alert",style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--danger, #c00)"},children:n}),e&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[s.jsx("strong",{children:"URL:"})," ",s.jsx("code",{children:e.asUrl})]}),e.paired&&e.fingerprint?s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[s.jsx("strong",{children:"Key fingerprint:"})," ",s.jsx("code",{children:e.fingerprint}),s.jsx("br",{}),s.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Compare this with the fingerprint on the Authority Server's own admin page over a second channel (phone, video call) to confirm this gateway is talking to the right server."})]}):s.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:"Not yet paired — sign in once to pin this server's key."}),(e.tlsPinFingerprint||e.pinTlsEnabled)&&s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[s.jsx("strong",{children:"TLS certificate pin:"})," ",i&&s.jsx(Ho,{title:"TLS pinning is set by your IT policy"})," ",e.tlsPinFingerprint?s.jsx("code",{children:e.tlsPinFingerprint}):s.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",e.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),s.jsx("br",{}),s.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[e.pinTlsEnabled?s.jsxs(s.Fragment,{children:["TLS pinning is ON",i?s.jsx(s.Fragment,{children:", set by your organization's IT policy"}):s.jsxs(s.Fragment,{children:[" (",s.jsx("code",{children:"config set pin-tls on"}),")"]}),". Every connection to the Authority Server must present this certificate's public key, or the gateway refuses it and locks."]}):s.jsxs(s.Fragment,{children:["Captured at sign-in; not currently enforced",i?s.jsx(s.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):s.jsxs(s.Fragment,{children:[" (",s.jsx("code",{children:"config set pin-tls on"})," to require it on every connection)"]}),"."]})," ","A certificate renewal with the SAME key keeps this pin; a NEW key needs re-pairing."]})]}),a?s.jsx("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This Authority Server URL is set by your organization's IT policy and cannot be changed from this computer. Contact your IT administrator if it needs to change."}):s.jsxs("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:["To point this gateway at a different Authority Server:"," ",s.jsx("code",{children:"suveren-gateway config set as-url <url>"}),", then restart. Changing it ends the current sign-in and clears cached mandates — you sign in again against the new server."]})]})]})}function Y0(e){if(!e||typeof e!="object")return{simulation:null,locked:!1};const t=Array.isArray(e.policyLocked)&&e.policyLocked.includes("simulation");return{simulation:typeof e.simulation=="boolean"?e.simulation:null,locked:t}}function Q0(){const[e,t]=u.useState({simulation:null,locked:!1});return u.useEffect(()=>{let n=!1;return fetch("/health").then(r=>r.json()).then(r=>{n||t(Y0(r))}).catch(()=>{}),()=>{n=!0}},[]),e}function J0(){const{simulation:e,locked:t}=Q0();return t?s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsxs("div",{children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),s.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:['Blocks every real connector without a manifest "simulation" marker.',e!==null&&s.jsxs(s.Fragment,{children:[" ","Currently ",s.jsx("strong",{children:e?"ON":"OFF"}),e?" — real systems are not reachable from this gateway.":"."]})]})]}),s.jsx(Ho,{})]}),s.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Simulation mode is set by your organization's IT policy",e!==null?` (currently ${e?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const X0={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"]}},Lr=["AI Assistant","Authority Server","This computer","Security","Version"],Mr={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function q0(){const[e,t]=u.useState(""),[n,r]=u.useState("openrouter"),[a,i]=u.useState("openai-compatible"),[o,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,v]=u.useState(!1),[S,g]=u.useState(!1),[h,y]=u.useState(null),[j,b]=u.useState([]),[C,N]=u.useState(!1),[I,E]=u.useState(null),[A,D]=u.useState(""),z=u.useCallback(P=>{t(P),setTimeout(()=>t(""),3e3)},[]),K=u.useCallback(async(P,V,R)=>{N(!0),E(null);try{const L=await T.aiModels({provider:P,endpoint:V,...R?{apiKey:R}:{}});L.ok&&L.models.length>0?(b(L.models),E(`${L.models.length} models available`)):(b([]),E(L.message||"No models returned — using defaults"))}catch(L){b([]),E(L instanceof Error?L.message:"Failed to load models")}finally{N(!1)}},[]),$=u.useCallback(async()=>{try{const P=await T.getCredential("ai-config");if(x(P.configured),P.configured&&P.fields){const V=P.fields.provider||"openai-compatible",R=P.fields.endpoint||"";P.fields.provider&&i(V),P.fields.endpoint&&l(R),P.fields.model&&d(P.fields.model),R.includes("openai.com")?r("openai"):R.includes("groq.com")?r("groq"):R.includes("together.xyz")?r("together"):R.includes("openrouter.ai")?r("openrouter"):r("ollama"),R&&K(V,R)}}catch{}},[K]);u.useEffect(()=>{$()},[$]);const Q=P=>{r(P),b([]),E(null),D("");const V=X0[P];V&&(i(V.provider),l(V.endpoint),d(""),K(V.provider,V.endpoint,f||void 0))},H=()=>K(a,o,f||void 0),O=async()=>{v(!0);try{await T.setCredential("ai-config",{provider:a,endpoint:o,model:c,...f?{apiKey:f}:{}}),x(!0),z("AI configuration saved!")}catch{z("Failed to save AI config")}finally{v(!1)}},_=async()=>{g(!0),y(null);try{const P=await T.aiTest({provider:a,endpoint:o,model:c,...f?{apiKey:f}:{}});y(P.ok?`OK: ${P.message}`:`Failed: ${P.message}`)}catch(P){y(`Error: ${P instanceof Error?P.message:"Unknown"}`)}finally{g(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Settings"}),s.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),e&&s.jsx("div",{className:"alert alert-success",children:e}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Mr,children:Lr[0]}),s.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),s.jsxs("div",{className:"card",children:[s.jsx("h3",{className:"card-title",children:"Configuration"}),s.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 mandates. Keys are encrypted in your vault."}),p&&s.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[s.jsx("span",{className:"status-banner-icon",children:"✓"}),s.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsx("label",{className:"form-label",children:"Provider Preset"}),s.jsxs("select",{className:"form-input",value:n,onChange:P=>Q(P.target.value),children:[s.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),s.jsx("option",{value:"ollama",children:"Ollama (local)"}),s.jsx("option",{value:"openai",children:"OpenAI"}),s.jsx("option",{value:"groq",children:"Groq"}),s.jsx("option",{value:"together",children:"Together"})]})]}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsxs("label",{className:"form-label",children:["API Key ",a==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),s.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:f,onChange:P=>m(P.target.value),onBlur:()=>{f.trim()&&K(a,o,f.trim())},placeholder:p?"••••••••••••••••":"sk-... (not needed for Ollama)"}),s.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."})]}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s.jsx("label",{className:"form-label",children:"Model"}),s.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:H,disabled:C,title:"Re-fetch the model list from the provider",children:C?"Loading…":"↻ Refresh"})]}),j.length===0?s.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:C?"Loading models…":a==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const P=j,V=P.includes(c),R=P.length>12,L=A.trim().toLowerCase();let Y=L?P.filter(te=>te.toLowerCase().includes(L)):P;return V&&!Y.includes(c)&&(Y=[c,...Y]),s.jsxs(s.Fragment,{children:[R&&s.jsx("input",{className:"form-input",value:A,onChange:te=>D(te.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),s.jsxs("select",{className:"form-input",value:V?c:"__unset__",onChange:te=>d(te.target.value==="__unset__"?"":te.target.value),children:[s.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),Y.map(te=>s.jsx("option",{value:te,children:te},te)),L&&Y.length===0&&s.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",A,"”"]})]})]})})(),I&&s.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:I})]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[s.jsx("button",{className:"btn btn-primary",onClick:O,disabled:w||!c.trim(),title:c.trim()?void 0:"Select a model first",children:w?"Saving...":"Save & Encrypt"}),p&&s.jsx("button",{className:"btn btn-ghost",onClick:_,disabled:S,children:S?"Testing...":"Test Connection"})]}),h&&s.jsx("div",{className:`alert ${h.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:h})]}),s.jsx(Z0,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Mr,children:Lr[1]}),s.jsx(K0,{}),s.jsx(H0,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Mr,children:Lr[2]}),s.jsx(U0,{}),s.jsx(W0,{}),s.jsx(J0,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Mr,children:Lr[3]}),s.jsx("div",{className:"card",style:{padding:"1.5rem"},children:s.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[s.jsxs("div",{style:{marginBottom:"1rem"},children:[s.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),s.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[s.jsx("li",{children:"Every tool call verified against your mandate bounds"}),s.jsx("li",{children:"Credentials never exposed to agents through MCP"}),s.jsx("li",{children:"Every action produces a signed ticket"})]})]}),s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),s.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[s.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),s.jsx("li",{children:"For best security, run agents in sandboxed environments"}),s.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})})]}),s.jsxs("section",{children:[s.jsx("h2",{style:Mr,children:Lr[4]}),s.jsx(G0,{})]})]})}function Z0(){const[e,t]=u.useState(null),[n,r]=u.useState({intent:"",context:""}),[a,i]=u.useState(null),[o,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState(!1),p=u.useCallback(async()=>{if(!f)try{const v=await T.getAIPrompts();t(v),r({intent:v.intent.current,context:v.context.current}),m(!0)}catch(v){l(v instanceof Error?v.message:"Failed to load prompts")}},[f]),x=async v=>{if(e){i(v),l(null);try{const S=n[v],g=S.trim()===e[v].default.trim()?"":S;await T.setAIPrompt(v,g);const h=await T.getAIPrompts();t(h),r({intent:h.intent.current,context:h.context.current}),d(v),setTimeout(()=>d(null),2e3)}catch(S){l(S instanceof Error?S.message:"Save failed")}finally{i(null)}}},w=async v=>{if(confirm(`Revert ${v} prompt to the built-in default?`)){i(v),l(null);try{await T.setAIPrompt(v,"");const S=await T.getAIPrompts();t(S),r({intent:S.intent.current,context:S.context.current})}catch(S){l(S instanceof Error?S.message:"Revert failed")}finally{i(null)}}};return s.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:v=>{v.currentTarget.open&&p()},children:[s.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),s.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-mandate) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),o&&s.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:o}),!f&&!o&&s.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&s.jsxs(s.Fragment,{children:[s.jsx(_u,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:e.intent,draft:n.intent,onChange:v=>r(S=>({...S,intent:v})),onSave:()=>x("intent"),onRevert:()=>w("intent"),saving:a==="intent",justSaved:c==="intent"}),s.jsx(_u,{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:v=>r(S=>({...S,context:v})),onSave:()=>x("context"),onRevert:()=>w("context"),saving:a==="context",justSaved:c==="context"})]})]})}function _u({kind:e,label:t,description:n,state:r,draft:a,onChange:i,onSave:o,onRevert:l,saving:c,justSaved:d}){const f=a!==r.current;return s.jsxs("section",{style:{marginBottom:"1.5rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:t}),s.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:n})]}),r.overridden&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),s.jsx("textarea",{className:"form-textarea",value:a,onChange:m=>i(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`}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[s.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:o,disabled:c||!f,children:c?"Saving…":"Save"}),r.overridden&&s.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&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),f&&!c&&!d&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),s.jsxs("details",{style:{marginTop:"0.5rem"},children:[s.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),s.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})]}),s.jsx("span",{style:{display:"none"},children:e})]})}function ew(e){return e.proposalId?"review":"automatic"}function zu(e,t,n={}){const r=n.status??"pending",a=n.includeAutonomous??!1,i=[];for(const o of e)r==="pending"&&o.status!=="pending"||n.profile&&o.profileId!==n.profile||i.push({kind:"proposal",id:o.id,sortTimestamp:o.createdAt,commitmentMode:"review",profileId:o.profileId,proposal:o});if(r==="all")for(const o of t){const l=ew(o);!a&&l==="automatic"||n.profile&&o.profileId!==n.profile||i.push({kind:"receipt",id:o.id,sortTimestamp:o.timestamp,commitmentMode:l,profileId:o.profileId,receipt:o})}return i.sort((o,l)=>l.sortTimestamp-o.sortTimestamp),typeof n.limit=="number"&&n.limit>0?i.slice(0,n.limit):i}const tw=["https://","http://"];function Ym(e,t){return e!=null&&e.length?e.flatMap(n=>{const r=n.template.replace(/\{(\w+)\}/g,(a,i)=>{const o=t[i];return typeof o=="string"||typeof o=="number"?String(o):"\0"});return r.includes("\0")||/\{|\}/.test(r)?[]:tw.some(a=>r.toLowerCase().startsWith(a))?[{label:n.label,href:r,description:n.description}]:[]}):[]}function Qm(e,t){const n=e-Math.floor(t/1e3);if(n<=0)return{label:"expired",urgent:!1,expired:!0};const r=Math.floor(n/86400),a=Math.floor(n%86400/3600),i=Math.floor(n%3600/60);let o;return r>0?o=`expires in ${r}d ${a}h`:a>0?o=`expires in ${a}h ${i}m`:o=`expires in ${Math.max(1,i)}m`,{label:o,urgent:n<2*3600,expired:!1}}const nw=new Set(["receipt_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function Jm(e){const t=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function rw(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
|
|
75
|
-
`)||e.length>120)?"markdown":"text"}function sw(e,t){var o,l;const n=(t==null?void 0:t.approvalView)??{},r=((o=t==null?void 0:t.inputSchema)==null?void 0:o.properties)??{},a=[...new Set([...Object.keys(n),...Object.keys(r),...Object.keys(e)])],i=[];for(const c of a){if(!(c in e)||nw.has(c))continue;const d=e[c],f=n[c]??{},m=f.kind??rw(d),p={key:c,label:f.label??Jm(c),kind:m,value:d,hint:(l=r[c])==null?void 0:l.description};m==="money"&&f.currencyArg&&typeof e[f.currencyArg]=="string"&&(p.currency=e[f.currencyArg]),m==="profile"&&typeof d=="string"&&(p.profileRef=d),(m==="profile-limits"||m==="profile-scope")&&f.profileArg&&typeof e[f.profileArg]=="string"&&(p.profileRef=e[f.profileArg]),i.push(p)}return i}function aw(e,t,n){if(!e||typeof e!="object"||Array.isArray(e))return[];const r=n==="limits"?t==null?void 0:t.boundsSchema:t==null?void 0:t.contextSchema,a=(r==null?void 0:r.fields)??{},i=[...new Set([...(r==null?void 0:r.keyOrder)??[],...Object.keys(e)])],o=[];for(const l of i){if(l==="profile"||!(l in e))continue;const c=e[l],d=a[l],f=Fm(d==null?void 0:d.unit),m=Array.isArray(c)?c.join(", "):String(c);o.push({key:l,label:(d==null?void 0:d.displayName)??Jm(l),value:f?`${m} ${f}`:m,hint:d==null?void 0:d.description,unknown:t?!d:void 0})}return o}const $u=new Map;function iw(e){let t=$u.get(e);return t||(t=(async()=>{try{let n=e;if(!e.includes("@")){const r=await T.listProfiles(),a=o=>o.replace(/@.*$/,"").split("/").pop(),i=r.filter(o=>a(o.id)===e).sort((o,l)=>(l.id.split("@")[1]??"").localeCompare(o.id.split("@")[1]??"",void 0,{numeric:!0}));if(!i[0])return null;n=i[0].id}return await T.getProfile(n)}catch{return null}})(),$u.set(e,t)),t}function Xm(e){const[t,n]=u.useState(null);return u.useEffect(()=>{let r=!0;return e&&iw(e).then(a=>{r&&n(a)}),()=>{r=!1}},[e]),t}const ow=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function lw(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:ow.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function Gn(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Lu({row:e,which:t}){const n=Xm(e.profileRef),r=aw(e.value,n,t);return r.length===0?s.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):s.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:r.map(a=>s.jsxs(u.Fragment,{children:[s.jsx("dt",{style:{color:"var(--text-secondary)"},title:a.hint,children:a.label}),s.jsxs("dd",{style:{margin:0,fontWeight:600},children:[a.value,a.unknown&&s.jsx("span",{style:{color:"var(--danger)",fontWeight:400,marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},a.key))})}function cw({row:e}){const t=Xm(e.profileRef),n=(t==null?void 0:t.id)??e.profileRef??"";return s.jsxs(s.Fragment,{children:[(t==null?void 0:t.name)??Oe(n),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:n})]})}function uw({row:e,altText:t}){switch(e.kind){case"profile":return s.jsx(cw,{row:e});case"profile-limits":return s.jsx(Lu,{row:e,which:"limits"});case"profile-scope":return s.jsx(Lu,{row:e,which:"scope"});case"markdown":return s.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Gn(e.value)});case"list":return Array.isArray(e.value)?s.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:e.value.map((n,r)=>s.jsx("li",{children:Gn(n)},r))}):s.jsx(s.Fragment,{children:Gn(e.value)});case"money":return s.jsxs(s.Fragment,{children:[Gn(e.value),e.currency?` ${e.currency}`:""]});case"object":return s.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Gn(e.value)});default:return lw(e.key,e.value)?s.jsx("img",{src:e.value,alt:t??e.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):s.jsx(s.Fragment,{children:Gn(e.value)})}}function qm({args:e,display:t}){const n=sw(e,t);if(n.length===0)return null;const r=typeof e.altText=="string"?e.altText:void 0;return s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Details"}),s.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:n.map(a=>s.jsxs(u.Fragment,{children:[s.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:a.hint,children:a.label}),s.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:s.jsx(uw,{row:a,altText:r})})]},a.key))})]})}const dw={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},fw={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function mw(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 pw(e){return e.split("__").pop()??e}function hw(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}function Zm(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=>Zm(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Mu({item:e,onApprove:t,onReject:n,resolving:r,proposalLinks:a,toolDisplay:i}){const o=e.kind==="proposal",l=o?e.proposal.status:"executed",c=o?e.proposal.tool:e.receipt.action,d=pw(c),f=hw(c),m=o?e.proposal.toolArgs:null,p=o?e.proposal.executionContext:e.receipt.executionContext,x=o?null:e.receipt.cumulativeState,w=o?Ym(a,e.proposal.toolArgs):[],v=Object.entries(p??{}),S=Hn(e.profileId).testSetup||si(c);return s.jsxs("div",{className:"card id-card",children:[s.jsx(bs,{profileId:e.profileId}),s.jsxs("div",{className:"id-body",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[s.jsx("code",{style:{fontSize:"0.85rem"},children:d}),S&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),e.commitmentMode==="automatic"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),s.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[o&&l==="pending"&&(()=>{const g=Qm(e.proposal.expiresAt,Date.now());return s.jsx("span",{style:{fontSize:"0.72rem",color:g.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:g.urgent?600:400,whiteSpace:"nowrap"},children:g.label})})(),s.jsx("span",{className:`status-badge ${fw[l]}`,children:dw[l]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:mw(e.sortTimestamp)})]})]}),f&&s.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:[s.jsx("span",{children:"⚠"}),s.jsx("span",{children:"Irreversible action"})]}),o&&typeof(m==null?void 0:m._imagePreview)=="string"&&s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),s.jsx("img",{src:m._imagePreview,alt:typeof(m==null?void 0:m.altText)=="string"?m.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),w.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:w.map(g=>s.jsxs("a",{href:g.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:g.description??g.href,children:[g.label," ↗"]},g.label))}),o&&m&&s.jsx(qm,{args:m,display:i}),v.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:v.map(([g,h])=>`${g}=${Zm(h)}`).join(" · ")}),x&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",x.daily.count," action",x.daily.count===1?"":"s",x.daily.amount>0?`, ${x.daily.amount}`:""," · ","this month: ",x.monthly.count,x.monthly.amount>0?`, ${x.monthly.amount}`:""]}),o&&l==="pending"&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:()=>t==null?void 0:t(e.id),disabled:r,children:r?"Approving…":"Approve"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:()=>n==null?void 0:n(e.id),disabled:r,children:"Reject"})]}),s.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[o?"Proposal":"Ticket",": ",e.id]})]})]})}function ep(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=>ep(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function gw(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 yw({proposal:e,currentUserId:t,onAction:n,onMessage:r,proposalLinks:a,toolDisplay:i}){const[o,l]=u.useState(!1),[c,d]=u.useState(!1),[f,m]=u.useState(null),[p,x]=u.useState(!1),[w,v]=u.useState(null),[S,g]=u.useState(!1),h=e.tool.split("__").pop()??e.tool,y=Object.entries(e.executionContext),j=Ym(a,e.toolArgs),b=Hn(e.profileId).testSetup||si(e.tool),C=e.pendingApprovers??[],N=e.approvedBy??{},I=Object.keys(N).length,E=C.filter(H=>!(H in N)).length,A=t in N,D=async()=>{if(f===null){x(!0),v(null);try{const H=await T.getAttestationIntent(e.authorizationId);if(!H){v("Intent not available or you are not an authorized approver.");return}const O=await T.decryptIntent({intentCiphertext:H.intentCiphertext,encryptedKey:H.encryptedKey,approverId:t});m(O)}catch(H){v(H instanceof Error?H.message:"Failed to decrypt intent")}finally{x(!1)}}},z=async()=>{S?g(!1):(g(!0),await D())},K=async()=>{l(!0),r("");try{await T.approveProposal(e.id);try{if(f===null){const H=await T.getAttestationIntent(e.authorizationId);if(H){const O=await T.decryptIntent({intentCiphertext:H.intentCiphertext,encryptedKey:H.encryptedKey,approverId:t});m(O),await T.storeApprovedIntent(e.authorizationId,O)}}else await T.storeApprovedIntent(e.authorizationId,f)}catch{}r(`Approved. ${E-1>0?`${E-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(H){r(H instanceof Error?H.message:"Approval failed")}finally{l(!1)}},$=async()=>{const H=prompt("Rejection reason (optional):");if(H!==null){d(!0),r("");try{await T.rejectProposal(e.id,H||void 0),r("Action rejected."),n()}catch(O){r(O instanceof Error?O.message:"Rejection failed")}finally{d(!1)}}},Q=o||c;return s.jsxs("div",{className:"card id-card",children:[s.jsx(bs,{profileId:e.profileId}),s.jsxs("div",{className:"id-body",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[s.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"}),b&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),s.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const H=Qm(e.expiresAt,Date.now());return s.jsx("span",{style:{fontSize:"0.72rem",color:H.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:H.urgent?600:400,whiteSpace:"nowrap"},children:H.label})})(),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:gw(e.createdAt)})]})]}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[I," of ",C.length," approver",C.length===1?"":"s"," signed off",C.map(H=>{const O=H in N;return s.jsxs("span",{style:{marginLeft:"0.5rem",color:O?"var(--success, green)":"var(--text-tertiary)"},children:[O?"✓":"○"," ",H===t?"You":H]},H)})]}),s.jsxs("div",{style:{marginBottom:"0.5rem"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Proposed action"}),s.jsx("code",{style:{fontSize:"0.85rem"},children:h})]}),j.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:j.map(H=>s.jsxs("a",{href:H.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:H.description??H.href,children:[H.label," ↗"]},H.label))}),s.jsx(qm,{args:e.toolArgs,display:i}),y.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:y.map(([H,O])=>`${H}=${ep(O)}`).join(" · ")}),s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsxs("button",{className:"btn btn-ghost btn-sm",style:{padding:"0.2rem 0",fontSize:"0.75rem"},onClick:z,disabled:p,children:[S?"▲ Hide intent":"▼ Show intent",p&&" (decrypting...)"]}),S&&s.jsx("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-main)",borderRadius:"0.375rem",border:"1px solid var(--border)"},children:w?s.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:w}):f!==null?s.jsx("p",{style:{fontSize:"0.85rem",margin:0,whiteSpace:"pre-wrap",color:"var(--text-primary)"},children:f}):s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]}),!A&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:K,disabled:Q,children:o?"Approving...":"Approve"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:$,disabled:Q,children:c?"Rejecting...":"Reject"})]}),A&&s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),s.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})]})}function vw(){const{domain:e,user:t}=Ue(),n=(t==null?void 0:t.id)??"",[r,a]=u.useState("awaiting-me"),[i,o]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState({}),[m,p]=u.useState(!0),[x,w]=u.useState(""),v=u.useCallback(async()=>{try{const W=await T.getProposalsForApprover();o(W)}catch{}finally{p(!1)}},[]);he("proposal-added",v),he("proposal-approved",v),he("proposal-rejected",v),he("proposal-resolved",v),At(v,3e4);const[S,g]=u.useState([]),h=u.useCallback(async()=>{try{const W=await T.getMyProposals(e);g(W)}catch{}},[e]);he("proposal-added",h),he("proposal-approved",h),he("proposal-rejected",h),he("proposal-resolved",h),At(h,3e4,e);const y=u.useMemo(()=>S.filter(W=>{var re;return W.status==="pending"&&(((re=W.pendingApprovers)==null?void 0:re.length)??0)===0}),[S]),j=u.useMemo(()=>zu(y,[],{status:"pending"}),[y]),[b,C]=u.useState([]),N=u.useCallback(async()=>{if(n)try{const re=(await T.getMyProposals(e)).filter(se=>se.status==="pending"&&se.pendingApprovers&&se.pendingApprovers.includes(n)&&se.approvedBy&&n in se.approvedBy);C(re)}catch{}},[n,e]);he("proposal-approved",N),he("proposal-rejected",N),At(N,3e4,`${n}:${e}`),u.useEffect(()=>{T.getIntegrationManifests().then(W=>c(W.manifests??[])).catch(()=>{}),T.getToolDisplay().then(f).catch(()=>{})},[]);const I=W=>{var re;return(re=l.find(se=>se.id===W.split("__")[0]))==null?void 0:re.proposalLinks};u.useEffect(()=>{v(),h(),N()},[]);const[E,A]=u.useState([]),[D,z]=u.useState([]),[K,$]=u.useState(!0),[Q,H]=u.useState(null),[O,_]=u.useState(""),[P,V]=u.useState("pending"),[R,L]=u.useState(null),[Y,te]=u.useState(!1),ne=u.useCallback(async()=>{try{const{proposals:W,receipts:re}=await T.getThread({domain:e,status:P,sinceDays:7});A(W),z(re)}catch{}finally{$(!1)}},[e,P]);At(ne,3e4,`${e}:${P}`);const de=async(W,re)=>{H(W),_("");try{const se=E.find(_e=>_e.id===W)??S.find(_e=>_e.id===W),Ce=dv(se,e),Ge=await T.resolveProposal(W,re,Ce);_(re==="commit"?`Action approved. Status: ${Ge.status}`:"Action rejected."),await Promise.all([ne(),h()])}catch(se){_(se instanceof Error?se.message:"Failed")}finally{H(null)}},xe=u.useMemo(()=>{const W=new Set;for(const re of E)W.add(re.profileId);for(const re of D)W.add(re.profileId);return Array.from(W).sort()},[E,D]),Le=u.useMemo(()=>zu(E,D,{status:P,profile:R??void 0,includeAutonomous:Y}),[E,D,P,R,Y]),q=u.useCallback(()=>{v(),N()},[v,N]),ee=u.useMemo(()=>{const W=new Set,re=[];for(const se of b)W.has(se.id)||(W.add(se.id),re.push(se));return re.sort((se,Ce)=>Ce.createdAt-se.createdAt)},[b]),X=i.length+j.length,oe=ee.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Pending Approvals"}),s.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."})]}),s.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[s.jsxs("button",{className:`nav-tab${r==="awaiting-me"?" active":""}`,onClick:()=>a("awaiting-me"),children:["Awaiting me ",X>0&&s.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:X})]}),s.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>a("awaiting-others"),children:["Awaiting others ",oe>0&&s.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:oe})]}),s.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{a("all"),ne()},children:"All"})]}),r==="awaiting-me"&&s.jsx(s.Fragment,{children:m&&X===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):X===0?s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[s.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(x||O)&&s.jsx("div",{className:"alert alert-success",children:x||O}),j.map(W=>s.jsx(Mu,{proposalLinks:W.kind==="proposal"?I(W.proposal.tool):void 0,toolDisplay:W.kind==="proposal"?d[W.proposal.tool]:void 0,item:W,onApprove:re=>de(re,"commit"),onReject:re=>de(re,"reject"),resolving:Q===W.id},W.id)),i.map(W=>s.jsx(yw,{proposal:W,currentUserId:n,onAction:q,onMessage:w,proposalLinks:I(W.tool),toolDisplay:d[W.tool]},W.id))]})}),r==="awaiting-others"&&s.jsx(s.Fragment,{children:ee.length===0?s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[s.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:ee.map(W=>s.jsx(ww,{proposal:W,currentUserId:n,onCancel:async()=>{try{await T.rejectProposal(W.id,"cancelled by creator"),N(),h()}catch(re){alert(re instanceof Error?re.message:"Cancel failed")}}},W.id))})}),r==="all"&&s.jsxs(s.Fragment,{children:[O&&s.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:O}),s.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[s.jsx("button",{className:`filter-chip ${P==="pending"?"selected":""}`,onClick:()=>V("pending"),children:"Pending"}),s.jsx("button",{className:`filter-chip ${P==="all"?"selected":""}`,onClick:()=>V("all"),children:"All"}),xe.length>0&&s.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),xe.map(W=>s.jsx("button",{className:`filter-chip ${R===W?"selected":""}`,onClick:()=>L(R===W?null:W),children:Oe(W)},W)),P==="all"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),s.jsxs("button",{className:`filter-chip ${Y?"selected":""}`,onClick:()=>te(!Y),title:"Include actions executed without human review (automatic commitment mode)",children:[Y?"✓ ":"","Autonomous actions"]})]})]}),K&&Le.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Le.length===0?s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[s.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:P==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:P==="pending"?"Your agents are operating within their mandates. Switch to All to see recent activity.":"When an agent calls a gated tool, activity will appear here."})]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:Le.map(W=>s.jsx(Mu,{proposalLinks:W.kind==="proposal"?I(W.proposal.tool):void 0,toolDisplay:W.kind==="proposal"?d[W.proposal.tool]:void 0,item:W,onApprove:re=>de(re,"commit"),onReject:re=>de(re,"reject"),resolving:Q===W.id},W.id))})]})]})}function xw(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 ww({proposal:e,currentUserId:t,onCancel:n}){var f;const[r,a]=u.useState(!1),i=Object.keys(e.approvedBy??{}),o=(e.pendingApprovers??[]).filter(m=>!(m in(e.approvedBy??{}))),l=(((f=e.pendingApprovers)==null?void 0:f.length)??0)>0,c=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){a(!0);try{await n()}finally{a(!1)}}},d=Hn(e.profileId).testSetup||si(e.tool);return s.jsxs("div",{className:"card id-card",children:[s.jsx(bs,{profileId:e.profileId}),s.jsxs("div",{className:"id-body",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[s.jsx("code",{style:{fontSize:"0.85rem"},children:e.tool.split("__").pop()??e.tool}),d&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),l&&s.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"}),s.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:xw(e.createdAt)})]}),l&&s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[i.map(m=>s.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:m===t?"You approved":`${m} approved`},m)),o.map(m=>s.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",m===t?"you":m]},m))]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:s.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:c,disabled:r,children:r?"Cancelling...":"Cancel"})})]})]})}const jw=`# Agent Brief
|
|
74
|
+
`}),w?s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):p.length===0?s.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[s.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),s.jsx(tt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):s.jsx("div",{className:"profile-grid",children:p.map(N=>{const I=N.profile,E=j(I.id),A=y(I),D=!N.ready||!A.can,{icon:L}=Vn(I.id,{name:I.name,icon:I.icon});return s.jsxs("div",{className:"card",style:D?{opacity:.7}:void 0,children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[s.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[s.jsx(sh,{icon:L,className:"profile-chip-icon"}),N.name]}),E?s.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"}):n!=null&&n.isPersonal?s.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"}):null]}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:N.description}),A.can?N.ready?s.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>C(I.id),children:"Give a mandate"}):N.kind==="builtin"?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:N.unavailableReason})]}):s.jsxs(tt,{to:`/integrations?setup=${N.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",N.name]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[A.reason," ",s.jsx("span",{style:{color:"var(--text-tertiary)"},children:A.fix})]})]})]},N.key)})})]})}const R0={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function P0({status:e,label:t}){return s.jsx("span",{className:`status-badge status-${e}`,children:t||R0[e]})}function A0({domain:e,attested:t}){const n=t===!0?"domain-attested":t===!1?"domain-missing":"";return s.jsx("span",{className:`domain-badge ${n}`,style:{fontSize:"0.75rem"},children:e})}const In=86400,Hr=3600,Ys=60,_0=30*In;function L0(e){if(e<=0)return"Expired";if(e>90*In){const t=Math.floor(e/_0);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*In){const t=Math.floor(e/In);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*In){const t=Math.floor(e/In),n=Math.floor(e%In/Hr);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*Hr){const t=Math.floor(e/Hr),n=Math.floor(e%Hr/Ys);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=Ys){const t=Math.floor(e/Ys),n=Math.floor(e%Ys);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function z0({expiresAt:e}){const[t,n]=u.useState(()=>e-Date.now()/1e3),r=t<2*Hr;u.useEffect(()=>{const i=setInterval(()=>n(e-Date.now()/1e3),r?1e3:6e4);return()=>clearInterval(i)},[e,r]);const a=t<300;return s.jsx("span",{className:`ttl-badge ${a?"ttl-warn":"ttl-ok"}`,children:L0(t)})}function Oa({icon:e,title:t,text:n,children:r}){return s.jsxs("div",{className:"empty-state",children:[e&&s.jsx("div",{className:"empty-state-icon",children:e}),s.jsx("div",{className:"empty-state-title",children:t}),n&&s.jsx("div",{className:"empty-state-text",children:n}),r]})}function $0(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 M0=[{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 F0({item:e,onClose:t,onSuccess:n}){var y;const{user:r,activeDomain:a,groupId:i}=Ue(),[o,l]=u.useState(null);u.useEffect(()=>{let j=!1;return T.getProfile(e.profile_id).then(b=>{var C;j||l(((C=b==null?void 0:b.ttl)==null?void 0:C.max)??null)}).catch(()=>{}),()=>{j=!0}},[e.profile_id]);const c=e.remaining_seconds??0,d=M0.filter(j=>j.seconds>c&&(o===null||j.seconds<=o)),f=((y=d[0])==null?void 0:y.seconds)??2592e3,[h,m]=u.useState(f);u.useEffect(()=>{var j;if(o!==null&&h>o){const b=(j=d[d.length-1])==null?void 0:j.seconds;b&&m(b)}},[o]);const[x,w]=u.useState(!1),[v,S]=u.useState(""),g=Object.entries(e.frame).filter(([j])=>j!=="profile"&&j!=="path"),p=async()=>{var j;if(r){w(!0),S("");try{const b=e.authorization_id,C=await T.getGateContent(b);if(!C)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const N=await T.getProfile(e.profile_id),I=e.frame,E=C.context??{},A=e.attested_domains[0]||a||"owner",D=await ua(I,N),L=await Zm(E,N),[K,z]=await Promise.all([Fa(C.gateContent.intent),Fa(JSON.stringify({profile:e.profile_id,path:e.path,domain:A}))]);if(!i)throw new Error("No active group; cannot extend mandate.");const Q=(((j=e.deferred_commitment_domains)==null?void 0:j.length)??0)>0?"review":"automatic",H=await T.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:I,bounds_hash:D,context_hash:L,domain:A,did:r.did,gate_content_hashes:{intent:K},execution_context_hash:z,group_id:i,commitment_mode:Q,ttl:h});await T.pushGateContent(eh(H,{boundsHash:D,contextHash:L,context:E,path:e.path,gateContent:C.gateContent})),n()}catch(b){S(b instanceof Error?b.message:"Extension failed")}finally{w(!1)}}};return s.jsx("div",{className:"modal-backdrop",onClick:j=>j.target===j.currentTarget&&t(),children:s.jsxs("div",{className:"modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:"Extend mandate"}),s.jsx("button",{className:"modal-close",onClick:t,children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[s.jsxs("div",{style:{marginBottom:"1rem"},children:[s.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Oe(e.profile_id)," / ",e.path]}),g.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:g.map(([j,b])=>`${j}=${b}`).join(" · ")})]}),s.jsxs("div",{style:{marginBottom:"1rem"},children:[s.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&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",$0(c),". Only longer durations are shown."]}),s.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:d.length===0?s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):d.map(j=>s.jsx("button",{className:`btn ${h===j.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>m(j.seconds),style:{minWidth:"3.5rem"},children:j.label},j.seconds))})]}),s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),v&&s.jsx("div",{className:"error-message",children:v})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:t,disabled:x,children:"Cancel"}),s.jsx("button",{className:"btn btn-primary",onClick:p,disabled:x,children:x?"Extending...":"Extend"})]})]})})}function O0(e,t,n){return[...e].sort((r,a)=>{if(n){if(r.authorization_id===n&&a.authorization_id!==n)return-1;if(a.authorization_id===n&&r.authorization_id!==n)return 1}const i=$a(r,t),o=$a(a,t),l={active:0,pending:1,expired:2,revoked:3,archived:4};return l[i]!==l[o]?l[i]-l[o]:new Date(a.created_at).getTime()-new Date(r.created_at).getTime()})}function B0({item:e,newerProfile:t,revokedSet:n,expandedHash:r,gateCache:a,gateLoading:i,copiedHash:o,revokingHash:l,copyingHash:c,profileConfigCache:d,mode:f,ownerLabel:h,isAdmin:m,onExpand:x,onCopyHash:w,onCopy:v,onRevoke:S,onExtend:g,archivedSet:p,archivingHash:y,onArchive:j,highlightHash:b}){var $e;const C=nc(e,{revokedSet:n}),N=zm(e,{revokedSet:n,archivedSet:p}),I=!h&&!!j&&Lm(C),E=r===e.authorization_id,A=a[e.authorization_id],D=C==="active"||C==="pending"||C==="expired",L=Object.entries(e.frame).filter(([q])=>q!=="profile"&&q!=="path"),K=d.get(e.profile_id)??null,z=((($e=K==null?void 0:K.approvers)==null?void 0:$e.length)??0)>0,Q=new Map;if(K!=null&&K.caps&&f==="team")for(const[q,ee]of L){const X=K.caps[q];X!==void 0&&Number(ee)>X&&Q.set(q,{authorized:Number(ee),cap:X})}const H=Q.size>0,O=e.approvers_frozen??[],_=(K==null?void 0:K.approvers)??[],P=f==="team"&&O.length>0&&_.length>0&&(O.length!==_.length||O.some(q=>!_.includes(q))||_.some(q=>!O.includes(q))),V=Array.from(Q.entries()).map(([q,ee])=>`${q}: ${ee.authorized} (cap ${ee.cap})`).join(", "),R=Array.from(Q.entries()).map(([q,ee])=>`${q}: ${ee.authorized} → ${ee.cap}`).join(", "),$=H?z?Q.size===1?`Above team cap: ${V} — actions require approval`:`Above team cap (${Q.size}): ${V} — actions require approval`:Q.size===1?`Reduced by hard cap: ${R}`:`Reduced by hard cap (${Q.size}): ${R}`:"",Y=H?z?"Above-cap actions under this mandate 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 mandate to reissue within the cap.":void 0,te=Vn(e.profile_id),ne=te.name,de=t?s.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:[s.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[ne,"@",t.version," available"]}),t.whatsNew?s.jsxs(s.Fragment,{children:[" — ",t.whatsNew]}):null,s.jsx("br",{}),s.jsxs("span",{children:["This mandate stays on ",e.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,xe=b!=null&&e.authorization_id===b;return s.jsxs("div",{className:`card id-card${xe?" card-highlight":""}`,style:{marginBottom:0},children:[s.jsx(Ns,{profileId:e.profile_id}),s.jsxs("div",{className:"id-body",children:[de,h&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",s.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:h})]}),s.jsxs("div",{className:"auth-card-header",children:[s.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:e.title||ne}),s.jsx(P0,{status:C}),te.testSetup&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),C==="active"&&e.earliest_expiry&&s.jsx(z0,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),C==="expired"&&(()=>{const q=Lv(e,C);return q?s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(q.iso).toLocaleString()}`,children:new Date(q.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}):null})()]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[e.required_domains.map(q=>s.jsx(A0,{domain:q,attested:e.attested_domains.includes(q)},q)),e.deferred_commitment_domains.length>0&&s.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"}),H&&s.jsx("span",{title:Y,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:z?"var(--accent-subtle)":"var(--danger-subtle)",color:z?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:$}),P&&s.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:()=>v(e),disabled:c===e.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:c===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),L.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:L.map(([q,ee],X)=>{const oe=Q.get(q);return s.jsxs("span",{children:[X>0&&" · ",oe?z?s.jsxs("span",{title:`Team cap on ${q} is ${oe.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${oe.authorized}.`,children:[s.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[q,"=",String(ee)]}),s.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",oe.cap]})]}):s.jsxs("span",{title:`Team cap on ${q} is ${oe.cap} with no approvers configured (hard cap). Authorized for ${oe.authorized}; effective ${oe.cap}.`,children:[s.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[q,"=",String(ee)]}),s.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",oe.cap]})]}):s.jsxs("span",{children:[q,"=",String(ee)]})]},q)})}),s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[I&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>j(e.authorization_id,!N),disabled:y===e.authorization_id,title:N?"Move back to the Expired or Revoked list":"Hide from the list and the nav badge. Nothing is deleted: the mandate and its tickets stay stored and verifiable.",children:y===e.authorization_id?N?"Unarchiving…":"Archiving…":N?"↩ Unarchive":"⊟ Archive"}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>x(e),children:E?"▲ Hide Details":"▼ Details"})]}),E&&s.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[L.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),s.jsx("dl",{className:"review-grid",children:L.map(([q,ee])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:q}),s.jsx("dd",{children:String(ee)})]},q))})]}),(A==null?void 0:A.context)&&Object.keys(A.context).length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Scope"}),s.jsx("dl",{className:"review-grid",children:Object.entries(A.context).map(([q,ee])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:q}),s.jsx("dd",{title:String(ee),children:th(q,ee,A.contextLabels)})]},q))})]}),s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),i===e.authorization_id?s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):A?s.jsx("div",{className:"gate-content-block",children:s.jsx("div",{className:"gate-content-item",children:s.jsx("div",{className:"gate-content-text",children:A.gateContent.intent})})}):s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),s.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()}`]}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:e.authorization_id}),s.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>w(e.authorization_id),children:o===e.authorization_id?"copied":"copy"})]}),s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!h&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>v(e),disabled:c===e.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:c===e.authorization_id?"Copying…":"⧉ Copy"}),!h&&(C==="active"||C==="pending")&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>v(e,{asEdit:!0}),disabled:c===e.authorization_id,title:"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:"✎ Edit"}),!h&&D&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>g(e),children:"↻ Extend"}),h&&m&&C!=="revoked"?s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>S(e.authorization_id,h,ne),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):!h&&(C==="active"||C==="pending")?s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>S(e.authorization_id),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]})]},e.authorization_id)}function D0(){const[e,t]=u.useState([]),[n,r]=u.useState(!0),[a,i]=u.useState([]),[o,l]=u.useState(!1),[c,d]=u.useState(new Map),[f,h]=u.useState("mine"),[m,x]=u.useState("active"),[w,v]=u.useState(null),[S,g]=u.useState(null),[p,y]=Zl(),[j,b]=u.useState(()=>p.get("new")==="1"),[C,N]=u.useState(()=>p.get("highlight")),[I,E]=u.useState(null),[A,D]=u.useState({}),[L,K]=u.useState(null),[z,Q]=u.useState(null),[H,O]=u.useState(null),[_,P]=u.useState(new Set),[V,R]=u.useState(null),[$,Y]=u.useState(new Set),[te,ne]=u.useState(null),[de,xe]=u.useState(null),$e=tn(),{group:q,groupId:ee,domain:X,mode:oe,activeTeam:W}=Ue(),re=(W==null?void 0:W.isAdmin)===!0,[se,Ce]=u.useState(()=>new Map),Ge=u.useCallback(()=>{r(!0),T.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),_e=u.useCallback(()=>{T.getArchivedMandates().then(F=>Y(new Set(F))).catch(()=>{})},[]);u.useEffect(()=>{_e()},[_e]);const xt=async(F,Z)=>{ne(F);try{const ie=await T.setMandateArchived(F,Z);Y(new Set(ie)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(ie){alert(ie instanceof Error?ie.message:"Failed to update archive")}finally{ne(null)}},at=u.useCallback(()=>{ee&&(l(!0),T.listTeamAuthorizations(ee).then(i).catch(()=>{}).finally(()=>l(!1)))},[ee]);pe("attestation-changed",()=>{Ge(),re&&ee&&at()}),u.useEffect(()=>{if(!C)return;p.get("highlight")&&(p.delete("highlight"),y(p,{replace:!0}));const F=window.setTimeout(()=>N(null),3e3);return()=>window.clearTimeout(F)},[]),At(Ge,3e5),u.useEffect(()=>{f==="team"&&re&&ee&&a.length===0&&!o&&at()},[f,re,ee,a.length,o,at]),u.useEffect(()=>{let F=!1;return T.listProfiles().then(Z=>{if(F)return;const ie=Ee=>Ee.replace(/@.*$/,"").split("/").pop()??Ee,ue=Ee=>Ee.split("@")[1]??"",ge=new Map;for(const Ee of Z){const le=ie(Ee.id),wt=ge.get(le);(!wt||ue(Ee.id).localeCompare(ue(wt.id),void 0,{numeric:!0})>0)&&ge.set(le,Ee)}d(ge)}).catch(()=>{}),()=>{F=!0}},[]);const Ke=u.useCallback(F=>{const Z=le=>le.replace(/@.*$/,"").split("/").pop()??le,ie=le=>le.split("@")[1]??"",ue=c.get(Z(F));if(!ue)return;const ge=ie(F),Ee=ie(ue.id);if(!(!ge||!Ee))return Ee.localeCompare(ge,void 0,{numeric:!0})>0?ue:void 0},[c]);u.useEffect(()=>{if(oe!=="team"||!ee)return;const F=f==="mine"?e:a;if(F.length===0)return;const Z=[...new Set(F.map(ie=>ie.profile_id))].filter(ie=>!se.has(ie));if(Z.length!==0){Ce(ie=>{const ue=new Map(ie);for(const ge of Z)ue.set(ge,null);return ue});for(const ie of Z)T.getTeamProfileConfig(ee,ie).then(ue=>{Ce(ge=>new Map(ge).set(ie,ue))}).catch(()=>{})}},[e,a,f,ee,oe,se]);const fe=async F=>{if(I===F.authorization_id){E(null);return}E(F.authorization_id);const Z=F.authorization_id;if(!(Z in A)){K(F.authorization_id);try{const ie=await T.getGateContent(Z);D(ue=>({...ue,[Z]:ie}))}catch{D(ie=>({...ie,[Z]:null}))}finally{K(null)}}},Ze=F=>{navigator.clipboard.writeText(F).then(()=>{O(F),setTimeout(()=>O(null),2e3)})},nn=async(F,Z)=>{var ie;if(!ee){alert("No active group; cannot copy mandate.");return}xe(F.authorization_id);try{const ue=F.authorization_id;let ge=A[ue]??null;ue in A||(ge=await T.getGateContent(ue),D(Cs=>({...Cs,[ue]:ge})));const Ee=Object.fromEntries(Object.entries(F.frame).filter(([Cs])=>Cs!=="profile"&&Cs!=="path")),le=(ge==null?void 0:ge.context)??{},wt=((ie=ge==null?void 0:ge.gateContent)==null?void 0:ie.intent)??"",oi=F.deferred_commitment_domains.length>0?"review":"automatic",fh=F.attested_domains[0]||X||"owner",li=Date.parse(F.created_at),ci=F.earliest_expiry?Date.parse(F.earliest_expiry):NaN,mh=Number.isFinite(li)&&Number.isFinite(ci)&&ci>li?Math.round((ci-li)/1e3):void 0;sessionStorage.setItem("agentAuth",JSON.stringify({profileId:F.profile_id,groupId:ee,groupName:(q==null?void 0:q.name)??null,domain:fh,isPersonal:!!(q!=null&&q.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:Ee,context:le,gateContent:{intent:wt},templateMode:oi,templateTtl:mh})),Z!=null&&Z.asEdit?sessionStorage.setItem("agentEditReplaces",F.authorization_id):sessionStorage.removeItem("agentEditReplaces"),$e("/mandates/new/intent")}catch(ue){alert(ue instanceof Error?ue.message:"Failed to copy mandate")}finally{xe(null)}},k=async(F,Z,ie)=>{const ue=Z&&ie?`Revoke ${Z}'s ${ie} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(ue)){R(F);try{await T.revokeAttestation(F),P(ge=>new Set(ge).add(F)),T.resyncGates().catch(()=>{}),Z&&ee&&at()}catch(ge){alert(ge instanceof Error?ge.message:"Failed to revoke mandate")}finally{R(null)}}},B=f==="mine"?e:a,G=f==="mine"?n:o,ae=f==="mine"?{revokedSet:_,archivedSet:$}:{revokedSet:_},U=F=>$a(F,ae),he={active:0,pending:0,expired:0,revoked:0,archived:0};for(const F of B)he[U(F)]+=1;const Pe=f==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],ke=(()=>{const F=new Map;for(const Z of B){if(U(Z)!==m)continue;const ie=F.get(Z.profile_id)??{count:0,review:!1};ie.count+=1,Z.deferred_commitment_domains.length>0&&(ie.review=!0),F.set(Z.profile_id,ie)}return Array.from(F.entries()).map(([Z,ie])=>({profileId:Z,...ie})).sort((Z,ie)=>Oe(Z.profileId).localeCompare(Oe(ie.profileId)))})(),Ye=O0(B.filter(F=>{if(U(F)!==m||w!==null&&F.profile_id!==w)return!1;if(S!==null){const Z=F.deferred_commitment_domains.length>0;if(S==="review"&&!Z||S==="auto"&&Z)return!1}return!0}),ae,C),bn={revokedSet:_,expandedHash:I,gateCache:A,gateLoading:L,copiedHash:H,revokingHash:V,copyingHash:de,profileConfigCache:se,mode:oe,activeDomain:X,group:q,groupId:ee,onExpand:fe,onCopyHash:Ze,onCopy:nn,onRevoke:k,onExtend:Q,highlightHash:C},Nn={...bn,archivedSet:$,archivingHash:te,onArchive:xt};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:"Mandates"}),s.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),s.jsx("button",{className:"btn btn-primary",onClick:()=>b(!0),children:"+ New mandate"})]}),j&&s.jsx("div",{className:"modal-backdrop",onClick:()=>{b(!1),p.get("new")&&(p.delete("new"),y(p,{replace:!0}))},children:s.jsxs("div",{className:"modal",onClick:F=>F.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h2",{className:"modal-title",children:"New mandate"}),s.jsx("button",{className:"modal-close",onClick:()=>{b(!1),p.get("new")&&(p.delete("new"),y(p,{replace:!0}))},children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[s.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."}),s.jsx(I0,{onDismiss:()=>b(!1)})]})]})}),re&&s.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[s.jsx("button",{className:`nav-tab${f==="mine"?" active":""}`,onClick:()=>{h("mine"),x("active"),v(null),g(null),E(null)},children:"Mine"}),s.jsx("button",{className:`nav-tab${f==="team"?" active":""}`,onClick:()=>{h("team"),x("active"),v(null),g(null),E(null)},children:"Team"})]}),s.jsx("div",{className:"nav-tabs",children:Pe.map(F=>s.jsxs("button",{className:`nav-tab${m===F?" active":""}`,onClick:()=>{x(F),v(null),g(null)},children:[F.charAt(0).toUpperCase()+F.slice(1)," (",he[F],")"]},F))}),ke.length>0&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[ke.map(F=>{const Z=w===F.profileId;return s.jsx("button",{className:`btn btn-sm ${Z?"btn-primary":"btn-secondary"}`,onClick:()=>v(Z?null:F.profileId),children:Oe(F.profileId)},F.profileId)}),s.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(F=>{const Z=S===F;return s.jsx("button",{className:`btn btn-sm ${Z?"btn-primary":"btn-secondary"}`,onClick:()=>g(Z?null:F),children:F==="auto"?"Auto":"Review"},F)})]}),G&&B.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Ye.length===0?s.jsx(Oa,{icon:"☰",title:"No mandates",text:m==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${m} mandates found.`}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:Ye.map(F=>{const Z=f==="team"?F:null,ie=Z!=null&&Z.owner?Z.owner.name??Z.owner.email??Z.owner.userId:void 0;return s.jsx(B0,{item:F,newerProfile:Ke(F.profile_id),ownerLabel:ie,isAdmin:re,...f==="mine"?Nn:bn},F.authorization_id)})}),z&&s.jsx(F0,{item:z,onClose:()=>Q(null),onSuccess:()=>{Q(null),Ge()}})]})}function U0(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function W0(e,t){var c,d,f;const{integrationId:n,toolName:r}=U0(e.action),a=t.find(h=>h.id===n),i=(d=(c=a==null?void 0:a.toolGating)==null?void 0:c.overrides)==null?void 0:d[r];if(i!=null&&i.actionLabel)return i.actionLabel;const o=Oe(e.profileId),l=(f=e.executionContext)==null?void 0:f.action_type;return typeof l=="string"&&l?`${o} · ${l}`:`${o} · ${r}`}function H0(e){const t=[];for(const[n,r]of Object.entries(e.executionContext??{})){if(!n.startsWith("allowed_"))continue;const a=String(r??"").trim();a&&t.push(a.split(",").map(i=>i.trim()).filter(Boolean).join(", "))}return t.join(" · ")}function V0(e){if(!e)return"";const t=[];for(const[n,r]of Object.entries(e)){if(n==="action_type")continue;const a=String(r??"").trim();if(!a)continue;const i=n.replace(/^allowed_/,"").replace(/_/g," ");t.push(`${i} ${a.split(",").map(o=>o.trim()).filter(Boolean).join(", ")}`)}return t.join(" · ")}function G0(e,t){var i,o;const n=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],r=e.actionType??(typeof((i=e.executionContext)==null?void 0:i.action_type)=="string"?e.executionContext.action_type:void 0),a=[];for(const{window:l,label:c}of n){const d=(o=e.cumulativeState)==null?void 0:o[l];if(!d)continue;const f=`_${l}_max`,h=Object.keys(t??{}).filter(S=>S.endsWith(f)),m=(r&&h.find(S=>S.startsWith(`${r}_`)))??(h.length===1?h[0]:void 0),w=(m?/^(amount|spend)_/.test(m):!1)?d.amount:d.count,v=m?Number(t==null?void 0:t[m]):NaN;m&&Number.isFinite(v)?a.push(`${w} of ${v} ${c}`):a.push(`${d.count} ${d.count===1?"call":"calls"} ${c}`)}return a.join(" · ")}function K0(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function Y0(e){const t=Oe(e),n=e.split("@")[1];return n?`${t}@${n}`:t}function Mr({label:e,children:t}){return s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"receipt-row-label",children:e}),s.jsx("dd",{className:"receipt-row-value",children:t})]})}function Q0({receipt:e,manifests:t,localAuth:n,localUnavailable:r,signature:a,grantTitle:i,ownerLabel:o,spUrl:l,formatDate:c,onOpenComplete:d}){var v;const f=H0(e),h=V0(n==null?void 0:n.context),m=G0(e,(n==null?void 0:n.bounds)??e.limits),x=n==null?void 0:n.intent,w=Vn(e.profileId).testSetup||ii(e.action);return s.jsxs("div",{className:"card id-card",style:{marginBottom:0},children:[s.jsx(Ns,{profileId:e.profileId}),s.jsxs("div",{className:"id-body",children:[s.jsxs("div",{className:"receipt-head",children:[s.jsx("span",{className:"receipt-what",children:W0(e,t)}),s.jsx("span",{className:"receipt-tag",children:K0(e)?"review":"automatic"}),e.contentHash&&s.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(v=e.contentBinding)!=null&&v.fields?`The ticket binds: ${e.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),w&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),s.jsx("span",{className:"auth-card-time",children:c(e.timestamp)})]}),f&&s.jsx("div",{className:"receipt-scope",children:f}),s.jsxs("dl",{className:"receipt-rows",children:[s.jsx(Mr,{label:"mandate",children:s.jsx("strong",{children:i||Y0(e.profileId)})}),o&&s.jsx(Mr,{label:"owner",children:o}),h&&s.jsx(Mr,{label:"allowed",children:h}),m&&s.jsx(Mr,{label:"used",children:s.jsx("span",{className:"receipt-num",children:m})}),s.jsx(Mr,{label:"intent",children:x?s.jsx("span",{className:"receipt-intent",children:x}):s.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"})})]}),s.jsxs("div",{className:"receipt-foot",children:[a==="valid"&&s.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued — no Authority Server involved.",children:"✓ Verified on this device"}),a==="invalid"&&s.jsx("span",{className:"receipt-tamper",title:"The stored ticket does not match what was signed.",children:"⚠ Signature check FAILED"}),s.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:d,children:"Complete ticket"}),l&&s.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",s.jsx("a",{className:"receipt-link",href:`${l}/r/${e.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),s.jsxs("details",{className:"receipt-more",children:[s.jsx("summary",{children:"Raw"}),s.jsxs("div",{className:"receipt-kv",children:[s.jsxs("div",{children:["ticket · ",e.id]}),s.jsxs("div",{children:["action · ",e.action]}),s.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&s.jsxs("div",{children:["mandate · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&s.jsxs("div",{children:["scope ·"," ",Object.entries(e.executionContext).map(([S,g])=>`${S}=${g}`).join(" · ")]}),(n==null?void 0:n.boundsHash)&&s.jsxs("div",{children:["bounds hash · ",n.boundsHash]}),(n==null?void 0:n.contextHash)&&s.jsxs("div",{children:["scope hash · ",n.contextHash]}),e.contentHash&&s.jsxs("div",{children:["content · ",e.contentHash]}),e.proposalId&&s.jsxs("div",{children:["proposal · ",e.proposalId]}),s.jsxs("div",{children:["signature · ",e.signature]})]})]})]})]})}function J0({receipt:e,onClose:t}){const[n,r]=u.useState(null),[a,i]=u.useState(null),[o,l]=u.useState(null),[c,d]=u.useState(!0),[f,h]=u.useState(!1);u.useEffect(()=>{let S=!1;return d(!0),T.getArchivedReceipt(e.id).then(g=>{S||(r(g),i(g?"local":"authority-server"),l((g==null?void 0:g.signature)??null))}).catch(()=>{S||i("authority-server")}).finally(()=>{S||d(!1)}),()=>{S=!0}},[e.id]);const m=n?n.entry:{receipt:e},x=JSON.stringify(m,null,2);function w(){const S=URL.createObjectURL(new Blob([x],{type:"application/json"})),g=document.createElement("a");g.href=S,g.download=`suveren-ticket-${e.id.slice(0,8)}.json`,g.click(),URL.revokeObjectURL(S)}async function v(){try{await navigator.clipboard.writeText(x),h(!0),setTimeout(()=>h(!1),2e3)}catch{h(!1)}}return s.jsx("div",{className:"modal-backdrop",onClick:S=>S.target===S.currentTarget&&t(),children:s.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:"Complete ticket"}),s.jsx("button",{className:"modal-close",onClick:t,"aria-label":"Close",children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[o==="valid"&&s.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 ticket was issued."}),o==="invalid"&&s.jsx("p",{className:"receipt-tamper",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"⚠ Signature check FAILED — the stored ticket does not match what was signed."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:c?"Loading…":a==="local"?"Held on this device — the signed ticket, the mandate 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 ticket (it predates local archiving, or ran on another device). Shown from the Authority Server — complete and signed, but it needs the server to retrieve."}),s.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})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-primary btn-sm",onClick:w,children:"Download"}),s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:v,children:f?"Copied":"Copy"})]})]})})}function X0(e){return new Date(e*1e3).toLocaleString()}function q0(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 Z0(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||Oe(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 Fu(e,t){const n=new Map(e.map(r=>[r.id,r]));for(const r of t)n.set(r.id,r);return[...n.values()].sort((r,a)=>a.timestamp-r.timestamp)}function ew(){const{activeTeam:e,groupId:t}=Ue(),n=(e==null?void 0:e.isAdmin)===!0,[r,a]=u.useState("mine"),[i,o]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState(""),[h,m]=u.useState(!0),[x,w]=u.useState({}),[v,S]=u.useState(new Set),[g,p]=u.useState(""),[y,j]=u.useState(new Set),[b,C]=u.useState(new Set),[N,I]=u.useState("all"),[E,A]=u.useState(!1),[D,L]=u.useState(!1),[K,z]=u.useState(null),[Q,H]=u.useState({}),[O,_]=u.useState(!1),[P,V]=u.useState({}),[R,$]=u.useState({}),[Y,te]=u.useState(null),[ne,de]=u.useState(null),[xe,$e]=u.useState(!1),[q,ee]=u.useState(!1),X=u.useRef(""),oe=u.useCallback(k=>r==="team"&&n&&t?T.listTeamReceiptsPage(t,{before:k,limit:200}):T.getMyReceiptsPage({before:k,limit:200}),[r,n,t]),W=u.useCallback(()=>{const k=r==="team"?`team:${t}`:"mine",B=X.current!==k;X.current=k,m(!0),ee(!1),oe().then(G=>{o(ae=>B?G.receipts:Fu(ae,G.receipts)),de(ae=>B?G.nextBefore:ae??G.nextBefore)}).catch(()=>{B&&o([]),ee(!0)}).finally(()=>m(!1))},[oe,r,t]),re=u.useCallback(()=>{!ne||xe||($e(!0),ee(!1),oe(ne).then(k=>{o(B=>Fu(B,k.receipts)),de(k.nextBefore)}).catch(()=>ee(!0)).finally(()=>$e(!1)))},[ne,xe,oe]);At(W,12e4),u.useEffect(()=>{T.getIntegrationManifests().then(({manifests:k})=>c(k)).catch(()=>{}),fetch("/health").then(k=>k.json()).then(k=>{typeof k.spUrl=="string"&&f(k.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),u.useEffect(()=>{T.getLocalAuthorizations().then(({authorizations:k,signatures:B})=>{H(k),V(B),_(!1)}).catch(()=>{H({}),V({}),_(!0)}),T.getMyAttestations().then(k=>{const B={};for(const G of k)G.authorization_id&&G.title&&(B[G.authorization_id]=G.title);$(B)}).catch(()=>{})},[]),u.useEffect(()=>{r!=="team"||Object.keys(x).length>0||T.listUsers().then(k=>{const B={};for(const G of k)B[G.id]={name:G.name,email:G.email};w(B)}).catch(()=>{})},[r,x]);const se=u.useMemo(()=>{const k=new Set;for(const B of i)k.add(Oe(B.profileId));return[...k].sort()},[i]),Ce=u.useMemo(()=>{const k=new Set;for(const B of i)k.add(B.action);return[...k].sort()},[i]),Ge=u.useMemo(()=>{if(r!=="team")return[];const k=new Set;for(const B of i)B.userId&&k.add(B.userId);return[...k].map(B=>{var G;return{id:B,label:(G=x[B])!=null&&G.name?`${x[B].name} (${x[B].email})`:B}}).sort((B,G)=>B.label.localeCompare(G.label))},[r,i,x]),_e=u.useMemo(()=>i.filter(k=>!(!Z0(k,g)||y.size>0&&!y.has(Oe(k.profileId))||b.size>0&&!b.has(k.action)||v.size>0&&k.userId&&!v.has(k.userId)||!q0(k,N))),[i,g,y,b,v,N]),xt=y.size>0||b.size>0||v.size>0||N!=="all";function at(k){j(B=>{const G=new Set(B);return G.has(k)?G.delete(k):G.add(k),G})}function Ke(k){C(B=>{const G=new Set(B);return G.has(k)?G.delete(k):G.add(k),G})}function fe(k){S(B=>{const G=new Set(B);return G.has(k)?G.delete(k):G.add(k),G})}function Ze(){j(new Set),C(new Set),S(new Set),I("all"),p("")}async function nn(){L(!0),z(null);try{const{bundle:k,filename:B}=await T.fetchEvidenceBundle(),G=URL.createObjectURL(new Blob([JSON.stringify(k,null,2)],{type:"application/json"})),ae=document.createElement("a");ae.href=G,ae.download=B,ae.click(),URL.revokeObjectURL(G);const U=k.sources??{};U.authorityServer?U.local||z(`Downloaded Authority Server history only — ${U.localError??"local archive unavailable."}`):z(`Downloaded local evidence only — ${U.asError??"Authority Server export unavailable."}`)}catch(k){z(`Export failed: ${k instanceof Error?k.message:String(k)}`)}finally{L(!1)}}return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:"Tickets"}),s.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),s.jsx("button",{className:"btn btn-secondary",onClick:nn,disabled:D,children:D?"Preparing…":"Download evidence"})]}),K&&s.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:K}),n&&s.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(k=>s.jsx("button",{onClick:()=>a(k),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===k?"2px solid var(--accent)":"2px solid transparent",color:r===k?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===k?600:500},children:k==="mine"?"Mine":"Team"},k))}),s.jsxs("div",{className:"search-filter-bar",children:[s.jsxs("div",{className:"search-input-wrap",children:[s.jsx("span",{className:"search-icon",children:"⌕"}),s.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:g,onChange:k=>p(k.target.value)}),g&&s.jsx("button",{className:"search-clear",onClick:()=>p(""),children:"×"})]}),s.jsxs("button",{className:`btn btn-sm btn-secondary${E?" active":""}`,onClick:()=>A(!E),children:["Filters",xt?` (${y.size+b.size+(N!=="all"?1:0)})`:""]})]}),E&&s.jsxs("div",{className:"filter-panel",children:[se.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Profile"}),s.jsx("div",{className:"filter-chips",children:se.map(k=>s.jsx("button",{className:`filter-chip${y.has(k)?" selected":""}`,onClick:()=>at(k),children:k},k))})]}),Ce.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Action"}),s.jsx("div",{className:"filter-chips",children:Ce.map(k=>s.jsx("button",{className:`filter-chip${b.has(k)?" selected":""}`,onClick:()=>Ke(k),children:k},k))})]}),r==="team"&&Ge.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Owner"}),s.jsx("div",{className:"filter-chips",children:Ge.map(k=>s.jsx("button",{className:`filter-chip${v.has(k.id)?" selected":""}`,onClick:()=>fe(k.id),children:k.label},k.id))})]}),s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Time range"}),s.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([k,B])=>s.jsx("button",{className:`filter-chip${N===k?" selected":""}`,onClick:()=>I(k),children:B},k))})]})]}),xt&&s.jsxs("div",{className:"active-filters",children:[[...y].map(k=>s.jsxs("span",{className:"active-chip",onClick:()=>at(k),children:[k," ",s.jsx("span",{className:"chip-remove",children:"×"})]},k)),[...b].map(k=>s.jsxs("span",{className:"active-chip",onClick:()=>Ke(k),children:[k," ",s.jsx("span",{className:"chip-remove",children:"×"})]},k)),[...v].map(k=>{const B=x[k],G=B?B.name:k;return s.jsxs("span",{className:"active-chip",onClick:()=>fe(k),children:[G," ",s.jsx("span",{className:"chip-remove",children:"×"})]},k)}),N!=="all"&&s.jsxs("span",{className:"active-chip",onClick:()=>I("all"),children:[N==="1d"?"Today":N==="7d"?"7 days":"30 days"," ",s.jsx("span",{className:"chip-remove",children:"×"})]}),s.jsx("button",{className:"clear-filters",onClick:Ze,children:"Clear all"})]}),q&&s.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:s.jsx("span",{style:{color:"var(--danger, #c0392b)",fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),h&&i.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):_e.length===0?s.jsx(Oa,{icon:"⌕",title:i.length===0?"No tickets in the last 30 days":"No matching tickets",text:i.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:_e.length===i.length?`${i.length} ticket${i.length!==1?"s":""}`:`${_e.length} of ${i.length} tickets`}),s.jsx("div",{className:"timeline",children:_e.map(k=>{const B=k.userId?x[k.userId]:void 0;return s.jsx("div",{className:"timeline-event",children:s.jsx(Q0,{receipt:k,manifests:l,localAuth:k.authorizationId?Q[k.authorizationId]:void 0,localUnavailable:O,signature:P[k.id],grantTitle:k.authorizationId?R[k.authorizationId]:null,ownerLabel:r==="team"&&k.userId?B?`${B.name} (${B.email})`:k.userId:null,spUrl:d,formatDate:X0,onOpenComplete:()=>te(k)})},k.id)})})]}),Y&&s.jsx(J0,{receipt:Y,onClose:()=>te(null)}),ne&&s.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:re,disabled:xe,children:xe?"Loading…":"Load older"})})]})}const tw={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function nw(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(null),o=u.useCallback(async()=>{try{t(await T.getAutostart())}catch(d){i(d instanceof Error?d.message:"Could not read autostart state")}},[]);u.useEffect(()=>{o()},[o]);const l=u.useCallback(async()=>{if(!(!(e!=null&&e.supported)||n)){r(!0),i(null);try{await T.setAutostart(!e.installed)}catch(d){i(d instanceof Error?d.message:"Failed")}finally{try{t(await T.getAutostart()),i(null)}catch(d){i(d instanceof Error?d.message:"Could not re-read state")}r(!1)}}},[e,n,o]);if(!e)return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),s.jsx("p",{role:a?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:a?`Could not read autostart state: ${a}`:"Checking…"})]});const c=tw[e.platform]??"a login service";return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsxs("div",{children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),s.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:e.supported?s.jsxs(s.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",c," — no admin rights needed."]}):e.reason})]}),e.supported&&s.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&&s.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",s.jsx("strong",{children:e.installed?"On — starts from your next login":"Off"})]}),e.supported&&s.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 ",s.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),a&&s.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger, #c00)"},children:a})]})}function rw(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(null),o=u.useCallback(async()=>{try{const c=await T.getGatewaySettings();t(c.desktopNotifications),i(null)}catch(c){i(c instanceof Error?c.message:"Could not read notification setting")}},[]);u.useEffect(()=>{o()},[o]);const l=u.useCallback(async()=>{if(!(e===null||n)){r(!0),i(null);try{const c=await T.setGatewaySettings({desktopNotifications:!e});t(c.desktopNotifications)}catch(c){i(c instanceof Error?c.message:"Failed to save"),await o()}finally{r(!1)}}},[e,n,o]);return e===null?s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),s.jsx("p",{role:a?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:a?`Could not read the setting: ${a}`:"Checking…"})]}):s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsxs("div",{children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),s.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."})]}),s.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"})]}),a&&s.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:a})]})}const Ou={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function sw(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(null),o=u.useCallback(async()=>{try{t(await T.getIdentityDisclosure()),i(null)}catch(f){i(f instanceof Error?f.message:"Could not read the setting")}},[]);u.useEffect(()=>{o()},[o]);const l=u.useCallback(async()=>{if(!(!e||n)){r(!0),i(null);try{t(await T.setIdentityDisclosure(!e.always))}catch(f){i(f instanceof Error?f.message:"Failed to save"),await o()}finally{r(!1)}}},[e,n,o]),c=s.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!e)return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[c,s.jsx("p",{role:a?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:a?`Could not read the setting: ${a}`:"Checking…"})]});const d=e.verified&&e.name?`${e.name} — ${e.method==="as_vouched"?`${Ou.as_vouched} ${e.verifier}`:Ou[e.method??""]??e.method}`:null;return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsxs("div",{children:[c,s.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[e.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),s.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:d?`Your identity: ${d}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),s.jsx("button",{type:"button",onClick:()=>void l(),disabled:n,"aria-pressed":e.always,className:e.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:n?"Saving…":e.always?"Turn off":"Always show my name"})]}),a&&s.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:a})]})}const aw={npm:"Checking npm for new releases",docker:"Checking the container registry for new images",dev:"Git checkout — comparing against origin/main, not npm releases",managed:"Checking npm for new releases — managed by your IT",msi:"Checking for new releases — update with the Windows installer"};function iw(){const{version:e,latestVersion:t,updateAvailable:n,installMethod:r}=ec();return e?s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",s.jsx("strong",{children:e}),n&&t?s.jsxs(s.Fragment,{children:[" — ",s.jsx("strong",{children:t})," is available"]}):null]}),s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[aw[r]??"Update checking is unavailable",r==="dev"&&s.jsx(s.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Ko({title:e}){return s.jsxs("span",{className:"it-locked-badge",title:e,children:[s.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function Bu(e){return e===!0}function ow(){const[e,t]=u.useState(null),[n,r]=u.useState(null);u.useEffect(()=>{let o=!1;return T.getAsPairing().then(l=>{o||t(l)}).catch(l=>{o||r(l instanceof Error?l.message:"Could not read Authority Server info")}),()=>{o=!0}},[]);const a=Bu(e==null?void 0:e.asUrlLockedByPolicy),i=Bu(e==null?void 0:e.pinTlsLockedByPolicy);return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),a&&s.jsx(Ko,{})]}),!e&&!n&&s.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),n&&s.jsx("p",{role:"alert",style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--danger, #c00)"},children:n}),e&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[s.jsx("strong",{children:"URL:"})," ",s.jsx("code",{children:e.asUrl})]}),e.paired&&e.fingerprint?s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[s.jsx("strong",{children:"Key fingerprint:"})," ",s.jsx("code",{children:e.fingerprint}),s.jsx("br",{}),s.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Compare this with the fingerprint on the Authority Server's own admin page over a second channel (phone, video call) to confirm this gateway is talking to the right server."})]}):s.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:"Not yet paired — sign in once to pin this server's key."}),(e.tlsPinFingerprint||e.pinTlsEnabled)&&s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[s.jsx("strong",{children:"TLS certificate pin:"})," ",i&&s.jsx(Ko,{title:"TLS pinning is set by your IT policy"})," ",e.tlsPinFingerprint?s.jsx("code",{children:e.tlsPinFingerprint}):s.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",e.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),s.jsx("br",{}),s.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[e.pinTlsEnabled?s.jsxs(s.Fragment,{children:["TLS pinning is ON",i?s.jsx(s.Fragment,{children:", set by your organization's IT policy"}):s.jsxs(s.Fragment,{children:[" (",s.jsx("code",{children:"config set pin-tls on"}),")"]}),". Every connection to the Authority Server must present this certificate's public key, or the gateway refuses it and locks."]}):s.jsxs(s.Fragment,{children:["Captured at sign-in; not currently enforced",i?s.jsx(s.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):s.jsxs(s.Fragment,{children:[" (",s.jsx("code",{children:"config set pin-tls on"})," to require it on every connection)"]}),"."]})," ","A certificate renewal with the SAME key keeps this pin; a NEW key needs re-pairing."]})]}),a?s.jsx("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This Authority Server URL is set by your organization's IT policy and cannot be changed from this computer. Contact your IT administrator if it needs to change."}):s.jsxs("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:["To point this gateway at a different Authority Server:"," ",s.jsx("code",{children:"suveren-gateway config set as-url <url>"}),", then restart. Changing it ends the current sign-in and clears cached mandates — you sign in again against the new server."]})]})]})}function lw(e){if(!e||typeof e!="object")return{simulation:null,locked:!1};const t=Array.isArray(e.policyLocked)&&e.policyLocked.includes("simulation");return{simulation:typeof e.simulation=="boolean"?e.simulation:null,locked:t}}function cw(){const[e,t]=u.useState({simulation:null,locked:!1});return u.useEffect(()=>{let n=!1;return fetch("/health").then(r=>r.json()).then(r=>{n||t(lw(r))}).catch(()=>{}),()=>{n=!0}},[]),e}function uw(){const{simulation:e,locked:t}=cw();return t?s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsxs("div",{children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),s.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:['Blocks every real connector without a manifest "simulation" marker.',e!==null&&s.jsxs(s.Fragment,{children:[" ","Currently ",s.jsx("strong",{children:e?"ON":"OFF"}),e?" — real systems are not reachable from this gateway.":"."]})]})]}),s.jsx(Ko,{})]}),s.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Simulation mode is set by your organization's IT policy",e!==null?` (currently ${e?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const dw={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"]}},Fr=["AI Assistant","Authority Server","This computer","Security","Version"],Or={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function fw(){const[e,t]=u.useState(""),[n,r]=u.useState("openrouter"),[a,i]=u.useState("openai-compatible"),[o,l]=u.useState("https://openrouter.ai/api/v1"),[c,d]=u.useState("google/gemma-4-31b-it"),[f,h]=u.useState(""),[m,x]=u.useState(!1),[w,v]=u.useState(!1),[S,g]=u.useState(!1),[p,y]=u.useState(null),[j,b]=u.useState([]),[C,N]=u.useState(!1),[I,E]=u.useState(null),[A,D]=u.useState(""),L=u.useCallback(P=>{t(P),setTimeout(()=>t(""),3e3)},[]),K=u.useCallback(async(P,V,R)=>{N(!0),E(null);try{const $=await T.aiModels({provider:P,endpoint:V,...R?{apiKey:R}:{}});$.ok&&$.models.length>0?(b($.models),E(`${$.models.length} models available`)):(b([]),E($.message||"No models returned — using defaults"))}catch($){b([]),E($ instanceof Error?$.message:"Failed to load models")}finally{N(!1)}},[]),z=u.useCallback(async()=>{try{const P=await T.getCredential("ai-config");if(x(P.configured),P.configured&&P.fields){const V=P.fields.provider||"openai-compatible",R=P.fields.endpoint||"";P.fields.provider&&i(V),P.fields.endpoint&&l(R),P.fields.model&&d(P.fields.model),R.includes("openai.com")?r("openai"):R.includes("groq.com")?r("groq"):R.includes("together.xyz")?r("together"):R.includes("openrouter.ai")?r("openrouter"):r("ollama"),R&&K(V,R)}}catch{}},[K]);u.useEffect(()=>{z()},[z]);const Q=P=>{r(P),b([]),E(null),D("");const V=dw[P];V&&(i(V.provider),l(V.endpoint),d(""),K(V.provider,V.endpoint,f||void 0))},H=()=>K(a,o,f||void 0),O=async()=>{v(!0);try{await T.setCredential("ai-config",{provider:a,endpoint:o,model:c,...f?{apiKey:f}:{}}),x(!0),L("AI configuration saved!")}catch{L("Failed to save AI config")}finally{v(!1)}},_=async()=>{g(!0),y(null);try{const P=await T.aiTest({provider:a,endpoint:o,model:c,...f?{apiKey:f}:{}});y(P.ok?`OK: ${P.message}`:`Failed: ${P.message}`)}catch(P){y(`Error: ${P instanceof Error?P.message:"Unknown"}`)}finally{g(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Settings"}),s.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),e&&s.jsx("div",{className:"alert alert-success",children:e}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Or,children:Fr[0]}),s.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),s.jsxs("div",{className:"card",children:[s.jsx("h3",{className:"card-title",children:"Configuration"}),s.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 mandates. Keys are encrypted in your vault."}),m&&s.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[s.jsx("span",{className:"status-banner-icon",children:"✓"}),s.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsx("label",{className:"form-label",children:"Provider Preset"}),s.jsxs("select",{className:"form-input",value:n,onChange:P=>Q(P.target.value),children:[s.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),s.jsx("option",{value:"ollama",children:"Ollama (local)"}),s.jsx("option",{value:"openai",children:"OpenAI"}),s.jsx("option",{value:"groq",children:"Groq"}),s.jsx("option",{value:"together",children:"Together"})]})]}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsxs("label",{className:"form-label",children:["API Key ",a==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),s.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:f,onChange:P=>h(P.target.value),onBlur:()=>{f.trim()&&K(a,o,f.trim())},placeholder:m?"••••••••••••••••":"sk-... (not needed for Ollama)"}),s.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."})]}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s.jsx("label",{className:"form-label",children:"Model"}),s.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:H,disabled:C,title:"Re-fetch the model list from the provider",children:C?"Loading…":"↻ Refresh"})]}),j.length===0?s.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:C?"Loading models…":a==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const P=j,V=P.includes(c),R=P.length>12,$=A.trim().toLowerCase();let Y=$?P.filter(te=>te.toLowerCase().includes($)):P;return V&&!Y.includes(c)&&(Y=[c,...Y]),s.jsxs(s.Fragment,{children:[R&&s.jsx("input",{className:"form-input",value:A,onChange:te=>D(te.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),s.jsxs("select",{className:"form-input",value:V?c:"__unset__",onChange:te=>d(te.target.value==="__unset__"?"":te.target.value),children:[s.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),Y.map(te=>s.jsx("option",{value:te,children:te},te)),$&&Y.length===0&&s.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",A,"”"]})]})]})})(),I&&s.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:I})]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[s.jsx("button",{className:"btn btn-primary",onClick:O,disabled:w||!c.trim(),title:c.trim()?void 0:"Select a model first",children:w?"Saving...":"Save & Encrypt"}),m&&s.jsx("button",{className:"btn btn-ghost",onClick:_,disabled:S,children:S?"Testing...":"Test Connection"})]}),p&&s.jsx("div",{className:`alert ${p.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:p})]}),s.jsx(mw,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Or,children:Fr[1]}),s.jsx(ow,{}),s.jsx(sw,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Or,children:Fr[2]}),s.jsx(nw,{}),s.jsx(rw,{}),s.jsx(uw,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Or,children:Fr[3]}),s.jsx("div",{className:"card",style:{padding:"1.5rem"},children:s.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[s.jsxs("div",{style:{marginBottom:"1rem"},children:[s.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),s.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[s.jsx("li",{children:"Every tool call verified against your mandate bounds"}),s.jsx("li",{children:"Credentials never exposed to agents through MCP"}),s.jsx("li",{children:"Every action produces a signed ticket"})]})]}),s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),s.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[s.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),s.jsx("li",{children:"For best security, run agents in sandboxed environments"}),s.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})})]}),s.jsxs("section",{children:[s.jsx("h2",{style:Or,children:Fr[4]}),s.jsx(iw,{})]})]})}function mw(){const[e,t]=u.useState(null),[n,r]=u.useState({intent:"",context:""}),[a,i]=u.useState(null),[o,l]=u.useState(null),[c,d]=u.useState(null),[f,h]=u.useState(!1),m=u.useCallback(async()=>{if(!f)try{const v=await T.getAIPrompts();t(v),r({intent:v.intent.current,context:v.context.current}),h(!0)}catch(v){l(v instanceof Error?v.message:"Failed to load prompts")}},[f]),x=async v=>{if(e){i(v),l(null);try{const S=n[v],g=S.trim()===e[v].default.trim()?"":S;await T.setAIPrompt(v,g);const p=await T.getAIPrompts();t(p),r({intent:p.intent.current,context:p.context.current}),d(v),setTimeout(()=>d(null),2e3)}catch(S){l(S instanceof Error?S.message:"Save failed")}finally{i(null)}}},w=async v=>{if(confirm(`Revert ${v} prompt to the built-in default?`)){i(v),l(null);try{await T.setAIPrompt(v,"");const S=await T.getAIPrompts();t(S),r({intent:S.intent.current,context:S.context.current})}catch(S){l(S instanceof Error?S.message:"Revert failed")}finally{i(null)}}};return s.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:v=>{v.currentTarget.open&&m()},children:[s.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),s.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-mandate) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),o&&s.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:o}),!f&&!o&&s.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&s.jsxs(s.Fragment,{children:[s.jsx(Du,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:e.intent,draft:n.intent,onChange:v=>r(S=>({...S,intent:v})),onSave:()=>x("intent"),onRevert:()=>w("intent"),saving:a==="intent",justSaved:c==="intent"}),s.jsx(Du,{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:v=>r(S=>({...S,context:v})),onSave:()=>x("context"),onRevert:()=>w("context"),saving:a==="context",justSaved:c==="context"})]})]})}function Du({kind:e,label:t,description:n,state:r,draft:a,onChange:i,onSave:o,onRevert:l,saving:c,justSaved:d}){const f=a!==r.current;return s.jsxs("section",{style:{marginBottom:"1.5rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:t}),s.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:n})]}),r.overridden&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),s.jsx("textarea",{className:"form-textarea",value:a,onChange:h=>i(h.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${t} system prompt`}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[s.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:o,disabled:c||!f,children:c?"Saving…":"Save"}),r.overridden&&s.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&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),f&&!c&&!d&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),s.jsxs("details",{style:{marginTop:"0.5rem"},children:[s.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),s.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})]}),s.jsx("span",{style:{display:"none"},children:e})]})}function hw(e){return e.proposalId?"review":"automatic"}function Uu(e,t,n={}){const r=n.status??"pending",a=n.includeAutonomous??!1,i=[];for(const o of e)r==="pending"&&o.status!=="pending"||n.profile&&o.profileId!==n.profile||i.push({kind:"proposal",id:o.id,sortTimestamp:o.createdAt,commitmentMode:"review",profileId:o.profileId,proposal:o});if(r==="all")for(const o of t){const l=hw(o);!a&&l==="automatic"||n.profile&&o.profileId!==n.profile||i.push({kind:"receipt",id:o.id,sortTimestamp:o.timestamp,commitmentMode:l,profileId:o.profileId,receipt:o})}return i.sort((o,l)=>l.sortTimestamp-o.sortTimestamp),typeof n.limit=="number"&&n.limit>0?i.slice(0,n.limit):i}const pw=["https://","http://"];function ah(e,t){return e!=null&&e.length?e.flatMap(n=>{const r=n.template.replace(/\{(\w+)\}/g,(a,i)=>{const o=t[i];return typeof o=="string"||typeof o=="number"?String(o):"\0"});return r.includes("\0")||/\{|\}/.test(r)?[]:pw.some(a=>r.toLowerCase().startsWith(a))?[{label:n.label,href:r,description:n.description}]:[]}):[]}function ih(e,t){const n=e-Math.floor(t/1e3);if(n<=0)return{label:"expired",urgent:!1,expired:!0};const r=Math.floor(n/86400),a=Math.floor(n%86400/3600),i=Math.floor(n%3600/60);let o;return r>0?o=`expires in ${r}d ${a}h`:a>0?o=`expires in ${a}h ${i}m`:o=`expires in ${Math.max(1,i)}m`,{label:o,urgent:n<2*3600,expired:!1}}const gw=new Set(["receipt_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function oh(e){const t=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function yw(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
|
|
75
|
+
`)||e.length>120)?"markdown":"text"}function vw(e,t){var o,l;const n=(t==null?void 0:t.approvalView)??{},r=((o=t==null?void 0:t.inputSchema)==null?void 0:o.properties)??{},a=[...new Set([...Object.keys(n),...Object.keys(r),...Object.keys(e)])],i=[];for(const c of a){if(!(c in e)||gw.has(c))continue;const d=e[c],f=n[c]??{},h=f.kind??yw(d),m={key:c,label:f.label??oh(c),kind:h,value:d,hint:(l=r[c])==null?void 0:l.description};h==="money"&&f.currencyArg&&typeof e[f.currencyArg]=="string"&&(m.currency=e[f.currencyArg]),h==="profile"&&typeof d=="string"&&(m.profileRef=d),(h==="profile-limits"||h==="profile-scope")&&f.profileArg&&typeof e[f.profileArg]=="string"&&(m.profileRef=e[f.profileArg]),i.push(m)}return i}function xw(e,t,n){if(!e||typeof e!="object"||Array.isArray(e))return[];const r=n==="limits"?t==null?void 0:t.boundsSchema:t==null?void 0:t.contextSchema,a=(r==null?void 0:r.fields)??{},i=[...new Set([...(r==null?void 0:r.keyOrder)??[],...Object.keys(e)])],o=[];for(const l of i){if(l==="profile"||!(l in e))continue;const c=e[l],d=a[l],f=Qm(d==null?void 0:d.unit),h=Array.isArray(c)?c.join(", "):String(c);o.push({key:l,label:(d==null?void 0:d.displayName)??oh(l),value:f?`${h} ${f}`:h,hint:d==null?void 0:d.description,unknown:t?!d:void 0})}return o}const Wu=new Map;function ww(e){let t=Wu.get(e);return t||(t=(async()=>{try{let n=e;if(!e.includes("@")){const r=await T.listProfiles(),a=o=>o.replace(/@.*$/,"").split("/").pop(),i=r.filter(o=>a(o.id)===e).sort((o,l)=>(l.id.split("@")[1]??"").localeCompare(o.id.split("@")[1]??"",void 0,{numeric:!0}));if(!i[0])return null;n=i[0].id}return await T.getProfile(n)}catch{return null}})(),Wu.set(e,t)),t}function lh(e){const[t,n]=u.useState(null);return u.useEffect(()=>{let r=!0;return e&&ww(e).then(a=>{r&&n(a)}),()=>{r=!1}},[e]),t}const jw=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function Sw(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:jw.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function Kn(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Hu({row:e,which:t}){const n=lh(e.profileRef),r=xw(e.value,n,t);return r.length===0?s.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):s.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:r.map(a=>s.jsxs(u.Fragment,{children:[s.jsx("dt",{style:{color:"var(--text-secondary)"},title:a.hint,children:a.label}),s.jsxs("dd",{style:{margin:0,fontWeight:600},children:[a.value,a.unknown&&s.jsx("span",{style:{color:"var(--danger)",fontWeight:400,marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},a.key))})}function kw({row:e}){const t=lh(e.profileRef),n=(t==null?void 0:t.id)??e.profileRef??"";return s.jsxs(s.Fragment,{children:[(t==null?void 0:t.name)??Oe(n),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:n})]})}function bw({row:e,altText:t}){switch(e.kind){case"profile":return s.jsx(kw,{row:e});case"profile-limits":return s.jsx(Hu,{row:e,which:"limits"});case"profile-scope":return s.jsx(Hu,{row:e,which:"scope"});case"markdown":return s.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Kn(e.value)});case"list":return Array.isArray(e.value)?s.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:e.value.map((n,r)=>s.jsx("li",{children:Kn(n)},r))}):s.jsx(s.Fragment,{children:Kn(e.value)});case"money":return s.jsxs(s.Fragment,{children:[Kn(e.value),e.currency?` ${e.currency}`:""]});case"object":return s.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Kn(e.value)});default:return Sw(e.key,e.value)?s.jsx("img",{src:e.value,alt:t??e.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):s.jsx(s.Fragment,{children:Kn(e.value)})}}function ch({args:e,display:t}){const n=vw(e,t);if(n.length===0)return null;const r=typeof e.altText=="string"?e.altText:void 0;return s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Details"}),s.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:n.map(a=>s.jsxs(u.Fragment,{children:[s.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:a.hint,children:a.label}),s.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:s.jsx(bw,{row:a,altText:r})})]},a.key))})]})}const Nw={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},Cw={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function Ew(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 Tw(e){return e.split("__").pop()??e}function Iw(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}function uh(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=>uh(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Vu({item:e,onApprove:t,onReject:n,resolving:r,proposalLinks:a,toolDisplay:i}){const o=e.kind==="proposal",l=o?e.proposal.status:"executed",c=o?e.proposal.tool:e.receipt.action,d=Tw(c),f=Iw(c),h=o?e.proposal.toolArgs:null,m=o?e.proposal.executionContext:e.receipt.executionContext,x=o?null:e.receipt.cumulativeState,w=o?ah(a,e.proposal.toolArgs):[],v=Object.entries(m??{}),S=Vn(e.profileId).testSetup||ii(c);return s.jsxs("div",{className:"card id-card",children:[s.jsx(Ns,{profileId:e.profileId}),s.jsxs("div",{className:"id-body",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[s.jsx("code",{style:{fontSize:"0.85rem"},children:d}),S&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),e.commitmentMode==="automatic"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),s.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[o&&l==="pending"&&(()=>{const g=ih(e.proposal.expiresAt,Date.now());return s.jsx("span",{style:{fontSize:"0.72rem",color:g.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:g.urgent?600:400,whiteSpace:"nowrap"},children:g.label})})(),s.jsx("span",{className:`status-badge ${Cw[l]}`,children:Nw[l]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Ew(e.sortTimestamp)})]})]}),f&&s.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:[s.jsx("span",{children:"⚠"}),s.jsx("span",{children:"Irreversible action"})]}),o&&typeof(h==null?void 0:h._imagePreview)=="string"&&s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),s.jsx("img",{src:h._imagePreview,alt:typeof(h==null?void 0:h.altText)=="string"?h.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),w.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:w.map(g=>s.jsxs("a",{href:g.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:g.description??g.href,children:[g.label," ↗"]},g.label))}),o&&h&&s.jsx(ch,{args:h,display:i}),v.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:v.map(([g,p])=>`${g}=${uh(p)}`).join(" · ")}),x&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",x.daily.count," action",x.daily.count===1?"":"s",x.daily.amount>0?`, ${x.daily.amount}`:""," · ","this month: ",x.monthly.count,x.monthly.amount>0?`, ${x.monthly.amount}`:""]}),o&&l==="pending"&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:()=>t==null?void 0:t(e.id),disabled:r,children:r?"Approving…":"Approve"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:()=>n==null?void 0:n(e.id),disabled:r,children:"Reject"})]}),s.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[o?"Proposal":"Ticket",": ",e.id]})]})]})}function dh(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=>dh(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Rw(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 Pw({proposal:e,currentUserId:t,onAction:n,onMessage:r,proposalLinks:a,toolDisplay:i}){const[o,l]=u.useState(!1),[c,d]=u.useState(!1),[f,h]=u.useState(null),[m,x]=u.useState(!1),[w,v]=u.useState(null),[S,g]=u.useState(!1),p=e.tool.split("__").pop()??e.tool,y=Object.entries(e.executionContext),j=ah(a,e.toolArgs),b=Vn(e.profileId).testSetup||ii(e.tool),C=e.pendingApprovers??[],N=e.approvedBy??{},I=Object.keys(N).length,E=C.filter(H=>!(H in N)).length,A=t in N,D=async()=>{if(f===null){x(!0),v(null);try{const H=await T.getAttestationIntent(e.authorizationId);if(!H){v("Intent not available or you are not an authorized approver.");return}const O=await T.decryptIntent({intentCiphertext:H.intentCiphertext,encryptedKey:H.encryptedKey,approverId:t});h(O)}catch(H){v(H instanceof Error?H.message:"Failed to decrypt intent")}finally{x(!1)}}},L=async()=>{S?g(!1):(g(!0),await D())},K=async()=>{l(!0),r("");try{await T.approveProposal(e.id);try{if(f===null){const H=await T.getAttestationIntent(e.authorizationId);if(H){const O=await T.decryptIntent({intentCiphertext:H.intentCiphertext,encryptedKey:H.encryptedKey,approverId:t});h(O),await T.storeApprovedIntent(e.authorizationId,O)}}else await T.storeApprovedIntent(e.authorizationId,f)}catch{}r(`Approved. ${E-1>0?`${E-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(H){r(H instanceof Error?H.message:"Approval failed")}finally{l(!1)}},z=async()=>{const H=prompt("Rejection reason (optional):");if(H!==null){d(!0),r("");try{await T.rejectProposal(e.id,H||void 0),r("Action rejected."),n()}catch(O){r(O instanceof Error?O.message:"Rejection failed")}finally{d(!1)}}},Q=o||c;return s.jsxs("div",{className:"card id-card",children:[s.jsx(Ns,{profileId:e.profileId}),s.jsxs("div",{className:"id-body",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[s.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"}),b&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),s.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const H=ih(e.expiresAt,Date.now());return s.jsx("span",{style:{fontSize:"0.72rem",color:H.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:H.urgent?600:400,whiteSpace:"nowrap"},children:H.label})})(),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Rw(e.createdAt)})]})]}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[I," of ",C.length," approver",C.length===1?"":"s"," signed off",C.map(H=>{const O=H in N;return s.jsxs("span",{style:{marginLeft:"0.5rem",color:O?"var(--success, green)":"var(--text-tertiary)"},children:[O?"✓":"○"," ",H===t?"You":H]},H)})]}),s.jsxs("div",{style:{marginBottom:"0.5rem"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Proposed action"}),s.jsx("code",{style:{fontSize:"0.85rem"},children:p})]}),j.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:j.map(H=>s.jsxs("a",{href:H.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:H.description??H.href,children:[H.label," ↗"]},H.label))}),s.jsx(ch,{args:e.toolArgs,display:i}),y.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:y.map(([H,O])=>`${H}=${dh(O)}`).join(" · ")}),s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsxs("button",{className:"btn btn-ghost btn-sm",style:{padding:"0.2rem 0",fontSize:"0.75rem"},onClick:L,disabled:m,children:[S?"▲ Hide intent":"▼ Show intent",m&&" (decrypting...)"]}),S&&s.jsx("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-main)",borderRadius:"0.375rem",border:"1px solid var(--border)"},children:w?s.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:w}):f!==null?s.jsx("p",{style:{fontSize:"0.85rem",margin:0,whiteSpace:"pre-wrap",color:"var(--text-primary)"},children:f}):s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]}),!A&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:K,disabled:Q,children:o?"Approving...":"Approve"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:z,disabled:Q,children:c?"Rejecting...":"Reject"})]}),A&&s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),s.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})]})}function Aw(){const{domain:e,user:t}=Ue(),n=(t==null?void 0:t.id)??"",[r,a]=u.useState("awaiting-me"),[i,o]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState({}),[h,m]=u.useState(!0),[x,w]=u.useState(""),v=u.useCallback(async()=>{try{const W=await T.getProposalsForApprover();o(W)}catch{}finally{m(!1)}},[]);pe("proposal-added",v),pe("proposal-approved",v),pe("proposal-rejected",v),pe("proposal-resolved",v),At(v,3e4);const[S,g]=u.useState([]),p=u.useCallback(async()=>{try{const W=await T.getMyProposals(e);g(W)}catch{}},[e]);pe("proposal-added",p),pe("proposal-approved",p),pe("proposal-rejected",p),pe("proposal-resolved",p),At(p,3e4,e);const y=u.useMemo(()=>S.filter(W=>{var re;return W.status==="pending"&&(((re=W.pendingApprovers)==null?void 0:re.length)??0)===0}),[S]),j=u.useMemo(()=>Uu(y,[],{status:"pending"}),[y]),[b,C]=u.useState([]),N=u.useCallback(async()=>{if(n)try{const re=(await T.getMyProposals(e)).filter(se=>se.status==="pending"&&se.pendingApprovers&&se.pendingApprovers.includes(n)&&se.approvedBy&&n in se.approvedBy);C(re)}catch{}},[n,e]);pe("proposal-approved",N),pe("proposal-rejected",N),At(N,3e4,`${n}:${e}`),u.useEffect(()=>{T.getIntegrationManifests().then(W=>c(W.manifests??[])).catch(()=>{}),T.getToolDisplay().then(f).catch(()=>{})},[]);const I=W=>{var re;return(re=l.find(se=>se.id===W.split("__")[0]))==null?void 0:re.proposalLinks};u.useEffect(()=>{v(),p(),N()},[]);const[E,A]=u.useState([]),[D,L]=u.useState([]),[K,z]=u.useState(!0),[Q,H]=u.useState(null),[O,_]=u.useState(""),[P,V]=u.useState("pending"),[R,$]=u.useState(null),[Y,te]=u.useState(!1),ne=u.useCallback(async()=>{try{const{proposals:W,receipts:re}=await T.getThread({domain:e,status:P,sinceDays:7});A(W),L(re)}catch{}finally{z(!1)}},[e,P]);At(ne,3e4,`${e}:${P}`);const de=async(W,re)=>{H(W),_("");try{const se=E.find(_e=>_e.id===W)??S.find(_e=>_e.id===W),Ce=Nv(se,e),Ge=await T.resolveProposal(W,re,Ce);_(re==="commit"?`Action approved. Status: ${Ge.status}`:"Action rejected."),await Promise.all([ne(),p()])}catch(se){_(se instanceof Error?se.message:"Failed")}finally{H(null)}},xe=u.useMemo(()=>{const W=new Set;for(const re of E)W.add(re.profileId);for(const re of D)W.add(re.profileId);return Array.from(W).sort()},[E,D]),$e=u.useMemo(()=>Uu(E,D,{status:P,profile:R??void 0,includeAutonomous:Y}),[E,D,P,R,Y]),q=u.useCallback(()=>{v(),N()},[v,N]),ee=u.useMemo(()=>{const W=new Set,re=[];for(const se of b)W.has(se.id)||(W.add(se.id),re.push(se));return re.sort((se,Ce)=>Ce.createdAt-se.createdAt)},[b]),X=i.length+j.length,oe=ee.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Pending Approvals"}),s.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."})]}),s.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[s.jsxs("button",{className:`nav-tab${r==="awaiting-me"?" active":""}`,onClick:()=>a("awaiting-me"),children:["Awaiting me ",X>0&&s.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:X})]}),s.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>a("awaiting-others"),children:["Awaiting others ",oe>0&&s.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:oe})]}),s.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{a("all"),ne()},children:"All"})]}),r==="awaiting-me"&&s.jsx(s.Fragment,{children:h&&X===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):X===0?s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[s.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(x||O)&&s.jsx("div",{className:"alert alert-success",children:x||O}),j.map(W=>s.jsx(Vu,{proposalLinks:W.kind==="proposal"?I(W.proposal.tool):void 0,toolDisplay:W.kind==="proposal"?d[W.proposal.tool]:void 0,item:W,onApprove:re=>de(re,"commit"),onReject:re=>de(re,"reject"),resolving:Q===W.id},W.id)),i.map(W=>s.jsx(Pw,{proposal:W,currentUserId:n,onAction:q,onMessage:w,proposalLinks:I(W.tool),toolDisplay:d[W.tool]},W.id))]})}),r==="awaiting-others"&&s.jsx(s.Fragment,{children:ee.length===0?s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[s.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:ee.map(W=>s.jsx(Lw,{proposal:W,currentUserId:n,onCancel:async()=>{try{await T.rejectProposal(W.id,"cancelled by creator"),N(),p()}catch(re){alert(re instanceof Error?re.message:"Cancel failed")}}},W.id))})}),r==="all"&&s.jsxs(s.Fragment,{children:[O&&s.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:O}),s.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[s.jsx("button",{className:`filter-chip ${P==="pending"?"selected":""}`,onClick:()=>V("pending"),children:"Pending"}),s.jsx("button",{className:`filter-chip ${P==="all"?"selected":""}`,onClick:()=>V("all"),children:"All"}),xe.length>0&&s.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),xe.map(W=>s.jsx("button",{className:`filter-chip ${R===W?"selected":""}`,onClick:()=>$(R===W?null:W),children:Oe(W)},W)),P==="all"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),s.jsxs("button",{className:`filter-chip ${Y?"selected":""}`,onClick:()=>te(!Y),title:"Include actions executed without human review (automatic commitment mode)",children:[Y?"✓ ":"","Autonomous actions"]})]})]}),K&&$e.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):$e.length===0?s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[s.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:P==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:P==="pending"?"Your agents are operating within their mandates. Switch to All to see recent activity.":"When an agent calls a gated tool, activity will appear here."})]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:$e.map(W=>s.jsx(Vu,{proposalLinks:W.kind==="proposal"?I(W.proposal.tool):void 0,toolDisplay:W.kind==="proposal"?d[W.proposal.tool]:void 0,item:W,onApprove:re=>de(re,"commit"),onReject:re=>de(re,"reject"),resolving:Q===W.id},W.id))})]})]})}function _w(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 Lw({proposal:e,currentUserId:t,onCancel:n}){var f;const[r,a]=u.useState(!1),i=Object.keys(e.approvedBy??{}),o=(e.pendingApprovers??[]).filter(h=>!(h in(e.approvedBy??{}))),l=(((f=e.pendingApprovers)==null?void 0:f.length)??0)>0,c=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){a(!0);try{await n()}finally{a(!1)}}},d=Vn(e.profileId).testSetup||ii(e.tool);return s.jsxs("div",{className:"card id-card",children:[s.jsx(Ns,{profileId:e.profileId}),s.jsxs("div",{className:"id-body",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[s.jsx("code",{style:{fontSize:"0.85rem"},children:e.tool.split("__").pop()??e.tool}),d&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),l&&s.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"}),s.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:_w(e.createdAt)})]}),l&&s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[i.map(h=>s.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:h===t?"You approved":`${h} approved`},h)),o.map(h=>s.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",h===t?"you":h]},h))]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:s.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:c,disabled:r,children:r?"Cancelling...":"Cancel"})})]})]})}const zw=`# Agent Brief
|
|
76
76
|
|
|
77
77
|
You act on my behalf through Suveren — the gateway that gates every
|
|
78
78
|
privileged tool call you make. Suveren implements the bounded-authority
|
|
@@ -108,4 +108,4 @@ executes. When you propose an action:
|
|
|
108
108
|
next.
|
|
109
109
|
- Never email anyone outside the company without asking first.
|
|
110
110
|
- When drafting posts, prefer plain language over marketing copy.
|
|
111
|
-
`;function Sw(){const[e,t]=u.useState(""),[n,r]=u.useState(""),[a,i]=u.useState(!0),[o,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 h=j=>{j.preventDefault(),j.returnValue=""},y=j=>{var N,I;if(j.defaultPrevented||j.button!==0||j.metaKey||j.ctrlKey||j.shiftKey||j.altKey)return;const b=(I=(N=j.target)==null?void 0:N.closest)==null?void 0:I.call(N,"a");if(!b||!b.href)return;let C;try{C=new URL(b.href)}catch{return}C.origin===window.location.origin&&C.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(j.preventDefault(),j.stopPropagation()))};return window.addEventListener("beforeunload",h),document.addEventListener("click",y,!0),()=>{window.removeEventListener("beforeunload",h),document.removeEventListener("click",y,!0)}},[p]),u.useEffect(()=>{let h=!1;return T.getAgentContext().then(y=>{h||(t(y),r(y))}).catch(y=>{h||d({kind:"error",text:y instanceof Error?y.message:"Failed to load context"})}).finally(()=>{h||i(!1)}),()=>{h=!0}},[]);const v=async()=>{l(!0),d(null);try{await T.saveAgentContext(e),r(e),d({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(h){d({kind:"error",text:h instanceof Error?h.message:"Save failed"})}finally{l(!1)}},S=()=>{t(n),d(null)},g=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(jw)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Agent Brief"}),s.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!e.trim()&&!a&&s.jsx("button",{className:"btn btn-primary btn-sm",onClick:g,disabled:o,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),c&&s.jsx("div",{className:c.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:c.text}),s.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[s.jsx("div",{className:"card intent-pane chat",children:s.jsx(La,{target:{kind:"context"},currentText:e,onApply:h=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(h)},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…"})}),s.jsxs("div",{className:"card intent-pane document",children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[s.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),s.jsxs("span",{style:{fontSize:"0.75rem",color:x>w?"var(--danger)":"var(--text-muted)"},children:[x.toLocaleString()," / ",w.toLocaleString()," bytes"]})]}),s.jsx("textarea",{className:"form-textarea",value:e,onChange:h=>t(h.target.value),placeholder:a?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:a,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),s.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:S,disabled:o||!p,children:"Revert"}),s.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:v,disabled:o||!p||x>w||a,children:o?"Saving…":"Save"})]})]}),s.jsx("button",{type:"button",className:"floating-help",onClick:()=>m(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),s.jsx(Om,{open:f,onClose:()=>m(!1),ariaLabel:"Brief assistant",children:s.jsx(La,{target:{kind:"context"},currentText:e,onApply:h=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(h),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 kw(e){const t=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return t&&t[1].replace(/<[^>]+>/g,"").trim()||"Report"}function bw(e){const t=e.find(a=>{var i;return a.kind==="sv-mandate"&&a.status!=="unverifiable"&&typeof((i=a.data)==null?void 0:i.profile)=="string"});if(!t)return null;const n=t.data;if(typeof n.profileLabel=="string"&&n.profileLabel)return n.profileLabel;const r=n.profile.split("@")[0].split("/").pop();return r?r.charAt(0).toUpperCase()+r.slice(1):null}function Nw(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Cw(e,t){const n=t.emailExportError?"cases unknown":`${t.coveredCases.length}/${t.loadedCases.length} cases`;return`${e.signaturesValid>0?`${e.signaturesValid} ✓ tickets`:`${e.signaturesValid} tickets`} · ${n} · ${t.ticketsReferenced.length}/${t.ticketsInPeriod.length} tickets covered`}function Ew(e){return e.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:e.emailExportError}:{kind:"ok",text:`${e.coveredCases.length} of ${e.loadedCases.length}`}}function Tw(e){return e.periodStart!==null?null:e.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:e.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function Fu(e,t="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:t}}function Iw(e){return/Labels?$/.test(e)||e==="limits"||e==="fields"}function Rw(e,t){const n=t[e];return n==null||n===""||Iw(e)?null:typeof n=="object"?JSON.stringify(n):String(n)}function Pw(e){const t=[];return e.missingCases.length>0&&t.push(`cases ${e.missingCases.join(", ")}`),e.ticketsNotReferenced.length>0&&t.push(`${e.ticketsNotReferenced.length} ticket${e.ticketsNotReferenced.length===1?"":"s"}`),t.length>0?`Not in the report: ${t.join(" · ")}`:null}function Aw(e,t){var n;if(t)return t;if(!e)return null;if(e.kind==="sv-ticket")return e.attrs.ref||null;if(e.kind==="sv-approval"||e.kind==="sv-mandate")return e.attrs.ticket||null;if(e.kind==="sv-case"){const r=(n=e.data)==null?void 0:n.goal;return(r==null?void 0:r.ticketId)??null}return null}const _w="allow-popups allow-popups-to-escape-sandbox",zw="AI analysis — not verified",$w="Green = verified by the gateway — raw signed fields only",Lw="Grey dashed = the AI's own analysis, not verified",Mw="= translation by the AI, not verified",Fw="Übersetzung anzeigen / show translation";function Ou(e){var n;const t=((n=e.formatNotice)==null?void 0:n.blocksNotShown)??0;return t<=0?null:`This report was written in an older format — ${t} ${t===1?"block was":"blocks were"} not shown. Ask the AI to write it again.`}function Ow(e,t){return t&&e.renderedHtmlGloss?e.renderedHtmlGloss:e.renderedHtml}function Bw(e,t,n){const r=new URLSearchParams(e);return r.set("element",t),n?r.set("ticket",n):r.delete("ticket"),r}const Dw={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function Uw(e){return e.filter(t=>t.status==="unverifiable").map(t=>({elementId:t.id,text:`${Dw[t.kind]??"Element"}: ${t.reason??"could not be checked"}`}))}function Ww(e){if(!e||e.kind!=="sv-case"||!e.data)return[];const t=Array.isArray(e.data.steps)?e.data.steps:[],n=e.data.goal,r=[...t.map(a=>({n:a,isGoal:!1})),...n?[{n,isGoal:!0}]:[]].filter(a=>typeof a.n.ticketId=="string"&&a.n.ticketId);return r.sort((a,i)=>(a.n.time??0)-(i.n.time??0)),r.map(({n:a,isGoal:i})=>({ticketId:a.ticketId,label:String(a.action??a.ticketId),isGoal:i}))}function Hw(e){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>body{margin:12px;background:#fff}</style></head><body>${e}</body></html>`}const Zl={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},Vw={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function Gw(e,t){return Array.isArray(t.fields)?t.fields.map(r=>({label:r.key,value:r.value})):{Ticket:["action","profile","time"],Mandate:["profile","mode","owners","intent"],Approval:["createdAt","decidedAt","whoLabel","status","waitSeconds"]}[e].filter(r=>t[r]!==void 0&&t[r]!==null).map(r=>({label:r,value:typeof t[r]=="object"?JSON.stringify(t[r]):String(t[r])}))}function Kw(e,t){const n=Vw[e].filter(r=>t[r]!==void 0);return n.length===0?null:s.jsxs("details",{style:{marginTop:"0.5rem"},children:[s.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),s.jsx("dl",{style:{...Zl,marginTop:"0.5rem"},children:n.map(r=>s.jsxs("div",{style:{display:"contents"},children:[s.jsx("dt",{style:{color:"var(--text-muted)"},children:r}),s.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof t[r]=="object"?JSON.stringify(t[r]):String(t[r])})]},r))})]})}function Ui(e,t){return t?s.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[s.jsx("div",{className:"card-title",children:e}),t.status==="unverifiable"?s.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",t.reason??"no further detail."]}):s.jsxs(s.Fragment,{children:[s.jsx("dl",{style:Zl,children:Gw(e,t.data??{}).map(({label:n,value:r})=>s.jsxs("div",{style:{display:"contents"},children:[s.jsx("dt",{style:{color:"var(--text-muted)"},children:n}),s.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:r})]},n))}),Kw(e,t.data??{})]})]}):null}function Yw({report:e,elementId:t,ticketParam:n,onClose:r,onSelectTicket:a}){var m;const i=e.elements.find(p=>p.id===t),o=Aw(i,n),l=o?e.ticketDetails[o]:void 0,c=Ww(i),d=(m=e.proof.verifiedValues.find(p=>p.elementId===t))==null?void 0:m.summary,f=u.useRef(null);return u.useEffect(()=>{const p=f.current;if(!p||typeof p.getBoundingClientRect!="function")return;const x=p.getBoundingClientRect().top;(x<0||x>window.innerHeight-80)&&p.scrollIntoView({block:"start",behavior:"smooth"})},[t,n]),s.jsxs("div",{className:"card reports-detail",ref:f,children:[s.jsxs("div",{className:"card-header",children:[s.jsx("div",{className:"card-title",children:"Details"}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:r,children:"Close"})]}),d&&s.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:d}),c.length>0&&s.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:c.map(p=>s.jsxs("button",{type:"button",className:`btn btn-sm ${p.ticketId===o?"btn-secondary":"btn-ghost"}`,"aria-pressed":p.ticketId===o,onClick:()=>a(p.ticketId),children:[p.isGoal?"Goal: ":"",p.label]},p.ticketId))}),!i&&s.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),i&&!o&&(i.status==="unverifiable"?s.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",i.reason??"no further detail."]}):s.jsx("dl",{style:Zl,children:Object.keys(i.data??{}).map(p=>{const x=Rw(p,i.data??{});return x===null?null:s.jsxs("div",{style:{display:"contents"},children:[s.jsx("dt",{style:{color:"var(--text-muted)"},children:p}),s.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:x})]},p)})})),l&&s.jsxs(s.Fragment,{children:[Ui("Ticket",l.ticket),Ui("Mandate",l.mandate),Ui("Approval",l.approval)]}),o&&!l&&s.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",o,"."]})]})}async function Qw(e){const{html:t,filename:n}=await e.exportReport();e.download(t,n),await e.refresh()}function Bu({detail:e}){return e?s.jsxs("details",{style:{marginTop:"0.25rem"},children:[s.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),s.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:e})]}):null}function Jw({report:e,open:t,selectedId:n,onOpenElement:r,detail:a}){const{proof:i,coverage:o}=e,l=Uw(e.elements),c=Pw(o),d=Ew(o),f=Tw(o),m=Fu(i.signaturesValid),p=Fu(i.recordsChecked);return s.jsxs("div",{className:`reports-side${t?" reports-side-open":""}`,children:[a,s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"card-title",children:"Proof"}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Tickets referenced"}),s.jsx("b",{children:i.ticketsReferenced.length})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Signatures valid"}),s.jsx("b",{style:m.kind==="ok"?{color:"var(--success)"}:void 0,children:m.text})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Records checked"}),s.jsx("b",{style:p.kind==="ok"?{color:"var(--success)"}:void 0,children:p.text})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Not verifiable"}),s.jsx("b",{children:i.unverifiableCount})]}),l.map(x=>s.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${n===x.elementId?" reports-row-selected":""}`,onClick:()=>r(x.elementId),children:[s.jsx("span",{children:x.text}),s.jsx("span",{"aria-hidden":"true",children:"›"})]},x.elementId))]}),s.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[s.jsx("div",{className:"card-title",children:"Coverage"}),d.kind==="error"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"reports-error",role:"alert",children:d.text}),s.jsx(Bu,{detail:d.detail})]}):s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Cases"}),s.jsx("b",{children:d.text})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Tickets in test period"}),s.jsxs("b",{children:[o.ticketsReferenced.length," of ",o.ticketsInPeriod.length]})]}),f&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:f.detail?"reports-error":"reports-note",role:f.detail?"alert":void 0,children:f.text}),s.jsx(Bu,{detail:f.detail})]}),c&&s.jsx("p",{className:"reports-missing",children:c})]}),i.verifiedValues.length>0&&s.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[s.jsx("div",{className:"card-title",children:"Checked values"}),i.verifiedValues.map(x=>s.jsxs("button",{type:"button",className:`reports-row reports-row-button${n===x.elementId?" reports-row-selected":""}`,onClick:()=>r(x.elementId),title:"Show details",children:[s.jsx("span",{children:x.summary}),s.jsx("span",{"aria-hidden":"true",children:"›"})]},x.elementId))]})]})}function Xw(){const[e,t]=u.useState(null),[n,r]=u.useState(!0),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(!1),[f,m]=u.useState(null),[p,x]=u.useState(!1),[w,v]=u.useState(!1),[S,g]=Gl(),h=u.useCallback(()=>T.getReport().then(({report:z})=>t(z)).catch(z=>i(z instanceof Error?z.message:String(z))),[]),y=u.useCallback(()=>{r(!0),i(null),h().finally(()=>r(!1))},[h]);u.useEffect(()=>{y()},[y]);const j=u.useCallback(()=>{l(!0),T.recheckReport().then(({report:z})=>t(z)).catch(z=>i(z instanceof Error?z.message:String(z))).finally(()=>l(!1))},[]),b=u.useCallback(async()=>{d(!0),m(null);try{await Qw({exportReport:()=>T.exportReportWithProof(),download:(z,K)=>{const $=URL.createObjectURL(new Blob([z],{type:"text/html"})),Q=document.createElement("a");Q.href=$,Q.download=K,Q.click(),URL.revokeObjectURL($)},refresh:h})}catch(z){m(z instanceof Error?z.message:String(z))}finally{d(!1)}},[h]),C=S.get("element"),N=S.get("ticket"),I=u.useCallback((z,K)=>{g(Bw(S,z,K))},[S,g]),E=u.useCallback(()=>{const z=new URLSearchParams(S);z.delete("element"),z.delete("ticket"),g(z,{replace:!0})},[S,g]);if(n)return s.jsxs("div",{className:"page-inner",children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Reports"})}),s.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(a)return s.jsxs("div",{className:"page-inner",children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Reports"})}),s.jsx(Fa,{icon:"⚠",title:"Report unavailable",text:a})]});if(!e)return s.jsxs("div",{className:"page-inner",children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Reports"})}),s.jsx(Fa,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const A=kw(e.renderedHtml),D=bw(e.elements);return s.jsx("div",{className:"page-inner reports-page",children:s.jsxs("div",{className:"reports-layout",children:[s.jsxs("div",{className:"reports-bar",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:A}),s.jsxs("p",{className:"page-subtitle",children:[D?`written by the AI under mandate ${D} · `:"","checked ",Nw(e.checkedAt)]})]}),s.jsxs("div",{className:"reports-bar-actions",children:[s.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:j,disabled:o,children:o?"Checking…":"Check again"}),s.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:b,disabled:c,children:c?"Exporting…":"Export with proof"})]})]}),f&&s.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",f]}),s.jsxs("div",{className:"reports-summary-chip",children:[s.jsx("span",{children:Cw(e.proof,e.coverage)}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>x(z=>!z),children:p?"hide":"details"})]}),s.jsxs("div",{className:"reports-grid",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"reports-legend",role:"note",children:[s.jsxs("span",{className:"reports-legend-chip",children:[s.jsx("span",{className:"reports-sw reports-sw-v"}),$w]}),s.jsxs("span",{className:"reports-legend-chip",children:[s.jsx("span",{className:"reports-sw reports-sw-a"}),Lw," (“",zw,"”)"]}),e.renderedHtmlGloss&&s.jsxs("span",{className:"reports-legend-chip",children:[s.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",Mw]})]}),Ou(e)&&s.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:Ou(e)}),e.renderedHtmlGloss&&s.jsxs("label",{className:"reports-gloss-switch",children:[s.jsx("input",{type:"checkbox",role:"switch",checked:w,onChange:z=>v(z.target.checked)}),s.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:s.jsx("span",{className:"reports-gloss-thumb"})}),s.jsx("span",{children:Fw})]}),s.jsx("p",{className:"form-hint",style:{marginBottom:"0.5rem"},children:"Written by the AI, rendered without scripts or network access. Scroll inside the report — the gateway does not auto-resize the frame. Click a checked value to see its details."}),s.jsx("iframe",{title:"Report",sandbox:_w,srcDoc:Hw(Ow(e,w)),className:"reports-iframe"})]}),s.jsx(Jw,{report:e,open:p||!!C,selectedId:C,onOpenElement:z=>I(z),detail:C?s.jsx(Yw,{report:e,elementId:C,ticketParam:N,onClose:E,onSelectTicket:z=>I(C,z)}):void 0})]})]})})}function Kn({to:e}){const{search:t,hash:n}=vt();return s.jsx(Vt,{to:`${e}${t}${n}`,replace:!0})}function qw({children:e}){const{user:t,mode:n,domain:r}=Ue();return t?n==="team"&&!r?s.jsx(Vt,{to:"/onboarding",replace:!0}):s.jsx(s.Fragment,{children:e}):s.jsx(Vt,{to:"/login",replace:!0})}function Zw(){const{user:e,handleSessionLocked:t}=Ue();return he("session-locked",n=>{const r=n==null?void 0:n.message;t(r)}),s.jsxs(Iy,{children:[s.jsx(je,{path:"/login",element:e?s.jsx(Vt,{to:"/",replace:!0}):s.jsx(ex,{})}),s.jsx(je,{path:"/onboarding",element:e?s.jsx(tx,{}):s.jsx(Vt,{to:"/login",replace:!0})}),s.jsxs(je,{element:s.jsx(qw,{children:s.jsx(Zv,{})}),children:[s.jsx(je,{path:"/",element:s.jsx(xx,{})}),s.jsx(je,{path:"/mandates",element:s.jsx(E0,{})}),s.jsx(je,{path:"/mandates/new/intent",element:s.jsx(Hx,{})}),s.jsx(je,{path:"/mandates/new/sign",element:s.jsx(e0,{})}),s.jsx(je,{path:"/integrations",element:s.jsx(o0,{})}),s.jsx(je,{path:"/team",element:s.jsx(l0,{})}),s.jsx(je,{path:"/tickets",element:s.jsx(B0,{})}),s.jsx(je,{path:"/approvals",element:s.jsx(vw,{})}),s.jsx(je,{path:"/reports",element:s.jsx(Xw,{})}),s.jsx(je,{path:"/agent/new",element:s.jsx(Vt,{to:"/mandates?new=1",replace:!0})}),s.jsx(je,{path:"/agent/gate",element:s.jsx(Kn,{to:"/mandates/new/intent"})}),s.jsx(je,{path:"/agent/review",element:s.jsx(Kn,{to:"/mandates/new/sign"})}),s.jsx(je,{path:"/authorizations",element:s.jsx(Kn,{to:"/mandates"})}),s.jsx(je,{path:"/groups",element:s.jsx(Kn,{to:"/team"})}),s.jsx(je,{path:"/audit",element:s.jsx(Kn,{to:"/tickets"})}),s.jsx(je,{path:"/proposals",element:s.jsx(Kn,{to:"/approvals"})}),s.jsx(je,{path:"/agent-brief",element:s.jsx(Sw,{})}),s.jsx(je,{path:"/settings",element:s.jsx(q0,{})}),s.jsx(je,{path:"/settings/services",element:s.jsx(Vt,{to:"/settings",replace:!0})}),s.jsx(je,{path:"/deploy",element:s.jsx(Vt,{to:"/integrations",replace:!0})})]}),s.jsx(je,{path:"*",element:s.jsx(Vt,{to:"/",replace:!0})})]})}function ej(){return s.jsx(ev,{children:s.jsx(pv,{children:s.jsx(hv,{children:s.jsx(Zw,{})})})})}tm(document.getElementById("root")).render(s.jsx(u.StrictMode,{children:s.jsx(ej,{})}));
|
|
111
|
+
`;function $w(){const[e,t]=u.useState(""),[n,r]=u.useState(""),[a,i]=u.useState(!0),[o,l]=u.useState(!1),[c,d]=u.useState(null),[f,h]=u.useState(!1),m=e!==n,x=new Blob([e]).size,w=16*1024;u.useEffect(()=>{if(!m)return;const p=j=>{j.preventDefault(),j.returnValue=""},y=j=>{var N,I;if(j.defaultPrevented||j.button!==0||j.metaKey||j.ctrlKey||j.shiftKey||j.altKey)return;const b=(I=(N=j.target)==null?void 0:N.closest)==null?void 0:I.call(N,"a");if(!b||!b.href)return;let C;try{C=new URL(b.href)}catch{return}C.origin===window.location.origin&&C.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(j.preventDefault(),j.stopPropagation()))};return window.addEventListener("beforeunload",p),document.addEventListener("click",y,!0),()=>{window.removeEventListener("beforeunload",p),document.removeEventListener("click",y,!0)}},[m]),u.useEffect(()=>{let p=!1;return T.getAgentContext().then(y=>{p||(t(y),r(y))}).catch(y=>{p||d({kind:"error",text:y instanceof Error?y.message:"Failed to load context"})}).finally(()=>{p||i(!1)}),()=>{p=!0}},[]);const v=async()=>{l(!0),d(null);try{await T.saveAgentContext(e),r(e),d({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(p){d({kind:"error",text:p instanceof Error?p.message:"Save failed"})}finally{l(!1)}},S=()=>{t(n),d(null)},g=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(zw)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Agent Brief"}),s.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!e.trim()&&!a&&s.jsx("button",{className:"btn btn-primary btn-sm",onClick:g,disabled:o,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),c&&s.jsx("div",{className:c.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:c.text}),s.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[s.jsx("div",{className:"card intent-pane chat",children:s.jsx(Ma,{target:{kind:"context"},currentText:e,onApply:p=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(p)},greeting:"Tell me what your agent should know — I'll help shape your standing orders. Or ask me to draft a full brief and we'll iterate.",placeholder:"Ask for help with your brief…"})}),s.jsxs("div",{className:"card intent-pane document",children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[s.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),s.jsxs("span",{style:{fontSize:"0.75rem",color:x>w?"var(--danger)":"var(--text-muted)"},children:[x.toLocaleString()," / ",w.toLocaleString()," bytes"]})]}),s.jsx("textarea",{className:"form-textarea",value:e,onChange:p=>t(p.target.value),placeholder:a?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:a,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),s.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:S,disabled:o||!m,children:"Revert"}),s.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:v,disabled:o||!m||x>w||a,children:o?"Saving…":"Save"})]})]}),s.jsx("button",{type:"button",className:"floating-help",onClick:()=>h(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),s.jsx(Jm,{open:f,onClose:()=>h(!1),ariaLabel:"Brief assistant",children:s.jsx(Ma,{target:{kind:"context"},currentText:e,onApply:p=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(p),h(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Mw(e){const t=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return t&&t[1].replace(/<[^>]+>/g,"").trim()||"Report"}function Fw(e){const t=e.find(a=>{var i;return a.kind==="sv-mandate"&&a.status!=="unverifiable"&&typeof((i=a.data)==null?void 0:i.profile)=="string"});if(!t)return null;const n=t.data;if(typeof n.profileLabel=="string"&&n.profileLabel)return n.profileLabel;const r=n.profile.split("@")[0].split("/").pop();return r?r.charAt(0).toUpperCase()+r.slice(1):null}function Ow(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Bw(e,t){const n=t.emailExportError?"cases unknown":`${t.coveredCases.length}/${t.loadedCases.length} cases`;return`${e.signaturesValid>0?`${e.signaturesValid} ✓ tickets`:`${e.signaturesValid} tickets`} · ${n} · ${t.ticketsReferenced.length}/${t.ticketsInPeriod.length} tickets covered`}function Dw(e){return e.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:e.emailExportError}:{kind:"ok",text:`${e.coveredCases.length} of ${e.loadedCases.length}`}}function Uw(e){return e.periodStart!==null?null:e.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:e.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function Gu(e,t="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:t}}function Ww(e){return/Labels?$/.test(e)||e==="limits"||e==="fields"}function Hw(e,t){const n=t[e];return n==null||n===""||Ww(e)?null:typeof n=="object"?JSON.stringify(n):String(n)}function Vw(e){const t=[];return e.missingCases.length>0&&t.push(`cases ${e.missingCases.join(", ")}`),e.ticketsNotReferenced.length>0&&t.push(`${e.ticketsNotReferenced.length} ticket${e.ticketsNotReferenced.length===1?"":"s"}`),t.length>0?`Not in the report: ${t.join(" · ")}`:null}function Gw(e,t){var n;if(t)return t;if(!e)return null;if(e.kind==="sv-ticket")return e.attrs.ref||null;if(e.kind==="sv-approval"||e.kind==="sv-mandate")return e.attrs.ticket||null;if(e.kind==="sv-case"){const r=(n=e.data)==null?void 0:n.goal;return(r==null?void 0:r.ticketId)??null}return null}const Kw="allow-popups allow-popups-to-escape-sandbox",Yw="AI analysis — not verified",Qw="Green = verified by the gateway — raw signed fields only",Jw="Grey dashed = the AI's own analysis, not verified",Xw="= translation by the AI, not verified",qw="Übersetzung anzeigen / show translation";function Ku(e){var n;const t=((n=e.formatNotice)==null?void 0:n.blocksNotShown)??0;return t<=0?null:`This report was written in an older format — ${t} ${t===1?"block was":"blocks were"} not shown. Ask the AI to write it again.`}function Zw(e,t){return t&&e.renderedHtmlGloss?e.renderedHtmlGloss:e.renderedHtml}function ej(e,t,n){const r=new URLSearchParams(e);return r.set("element",t),n?r.set("ticket",n):r.delete("ticket"),r}const tj={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function nj(e){return e.filter(t=>t.status==="unverifiable").map(t=>({elementId:t.id,text:`${tj[t.kind]??"Element"}: ${t.reason??"could not be checked"}`}))}function rj(e){if(!e||e.kind!=="sv-case"||!e.data)return[];const t=Array.isArray(e.data.steps)?e.data.steps:[],n=e.data.goal,r=[...t.map(a=>({n:a,isGoal:!1})),...n?[{n,isGoal:!0}]:[]].filter(a=>typeof a.n.ticketId=="string"&&a.n.ticketId);return r.sort((a,i)=>(a.n.time??0)-(i.n.time??0)),r.map(({n:a,isGoal:i})=>({ticketId:a.ticketId,label:String(a.action??a.ticketId),isGoal:i}))}function sj(e){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>body{margin:12px;background:#fff}</style></head><body>${e}</body></html>`}const ic={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},aj={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function ij(e,t){return Array.isArray(t.fields)?t.fields.map(r=>({label:r.key,value:r.value})):{Ticket:["action","profile","time"],Mandate:["profile","mode","owners","intent"],Approval:["createdAt","decidedAt","whoLabel","status","waitSeconds"]}[e].filter(r=>t[r]!==void 0&&t[r]!==null).map(r=>({label:r,value:typeof t[r]=="object"?JSON.stringify(t[r]):String(t[r])}))}function oj(e,t){const n=aj[e].filter(r=>t[r]!==void 0);return n.length===0?null:s.jsxs("details",{style:{marginTop:"0.5rem"},children:[s.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),s.jsx("dl",{style:{...ic,marginTop:"0.5rem"},children:n.map(r=>s.jsxs("div",{style:{display:"contents"},children:[s.jsx("dt",{style:{color:"var(--text-muted)"},children:r}),s.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof t[r]=="object"?JSON.stringify(t[r]):String(t[r])})]},r))})]})}function Vi(e,t){return t?s.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[s.jsx("div",{className:"card-title",children:e}),t.status==="unverifiable"?s.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",t.reason??"no further detail."]}):s.jsxs(s.Fragment,{children:[s.jsx("dl",{style:ic,children:ij(e,t.data??{}).map(({label:n,value:r})=>s.jsxs("div",{style:{display:"contents"},children:[s.jsx("dt",{style:{color:"var(--text-muted)"},children:n}),s.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:r})]},n))}),oj(e,t.data??{})]})]}):null}function lj({report:e,elementId:t,ticketParam:n,onClose:r,onSelectTicket:a}){var h;const i=e.elements.find(m=>m.id===t),o=Gw(i,n),l=o?e.ticketDetails[o]:void 0,c=rj(i),d=(h=e.proof.verifiedValues.find(m=>m.elementId===t))==null?void 0:h.summary,f=u.useRef(null);return u.useEffect(()=>{const m=f.current;if(!m||typeof m.getBoundingClientRect!="function")return;const x=m.getBoundingClientRect().top;(x<0||x>window.innerHeight-80)&&m.scrollIntoView({block:"start",behavior:"smooth"})},[t,n]),s.jsxs("div",{className:"card reports-detail",ref:f,children:[s.jsxs("div",{className:"card-header",children:[s.jsx("div",{className:"card-title",children:"Details"}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:r,children:"Close"})]}),d&&s.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:d}),c.length>0&&s.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:c.map(m=>s.jsxs("button",{type:"button",className:`btn btn-sm ${m.ticketId===o?"btn-secondary":"btn-ghost"}`,"aria-pressed":m.ticketId===o,onClick:()=>a(m.ticketId),children:[m.isGoal?"Goal: ":"",m.label]},m.ticketId))}),!i&&s.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),i&&!o&&(i.status==="unverifiable"?s.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",i.reason??"no further detail."]}):s.jsx("dl",{style:ic,children:Object.keys(i.data??{}).map(m=>{const x=Hw(m,i.data??{});return x===null?null:s.jsxs("div",{style:{display:"contents"},children:[s.jsx("dt",{style:{color:"var(--text-muted)"},children:m}),s.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:x})]},m)})})),l&&s.jsxs(s.Fragment,{children:[Vi("Ticket",l.ticket),Vi("Mandate",l.mandate),Vi("Approval",l.approval)]}),o&&!l&&s.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",o,"."]})]})}async function cj(e){const{html:t,filename:n}=await e.exportReport();e.download(t,n),await e.refresh()}function Yu({detail:e}){return e?s.jsxs("details",{style:{marginTop:"0.25rem"},children:[s.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),s.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:e})]}):null}function uj({report:e,open:t,selectedId:n,onOpenElement:r,detail:a}){const{proof:i,coverage:o}=e,l=nj(e.elements),c=Vw(o),d=Dw(o),f=Uw(o),h=Gu(i.signaturesValid),m=Gu(i.recordsChecked);return s.jsxs("div",{className:`reports-side${t?" reports-side-open":""}`,children:[a,s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"card-title",children:"Proof"}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Tickets referenced"}),s.jsx("b",{children:i.ticketsReferenced.length})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Signatures valid"}),s.jsx("b",{style:h.kind==="ok"?{color:"var(--success)"}:void 0,children:h.text})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Records checked"}),s.jsx("b",{style:m.kind==="ok"?{color:"var(--success)"}:void 0,children:m.text})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Not verifiable"}),s.jsx("b",{children:i.unverifiableCount})]}),l.map(x=>s.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${n===x.elementId?" reports-row-selected":""}`,onClick:()=>r(x.elementId),children:[s.jsx("span",{children:x.text}),s.jsx("span",{"aria-hidden":"true",children:"›"})]},x.elementId))]}),s.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[s.jsx("div",{className:"card-title",children:"Coverage"}),d.kind==="error"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"reports-error",role:"alert",children:d.text}),s.jsx(Yu,{detail:d.detail})]}):s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Cases"}),s.jsx("b",{children:d.text})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Tickets in test period"}),s.jsxs("b",{children:[o.ticketsReferenced.length," of ",o.ticketsInPeriod.length]})]}),f&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:f.detail?"reports-error":"reports-note",role:f.detail?"alert":void 0,children:f.text}),s.jsx(Yu,{detail:f.detail})]}),c&&s.jsx("p",{className:"reports-missing",children:c})]}),i.verifiedValues.length>0&&s.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[s.jsx("div",{className:"card-title",children:"Checked values"}),i.verifiedValues.map(x=>s.jsxs("button",{type:"button",className:`reports-row reports-row-button${n===x.elementId?" reports-row-selected":""}`,onClick:()=>r(x.elementId),title:"Show details",children:[s.jsx("span",{children:x.summary}),s.jsx("span",{"aria-hidden":"true",children:"›"})]},x.elementId))]})]})}function dj(){const[e,t]=u.useState(null),[n,r]=u.useState(!0),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(!1),[f,h]=u.useState(null),[m,x]=u.useState(!1),[w,v]=u.useState(!1),[S,g]=Zl(),p=u.useCallback(()=>T.getReport().then(({report:L})=>t(L)).catch(L=>i(L instanceof Error?L.message:String(L))),[]),y=u.useCallback(()=>{r(!0),i(null),p().finally(()=>r(!1))},[p]);u.useEffect(()=>{y()},[y]);const j=u.useCallback(()=>{l(!0),T.recheckReport().then(({report:L})=>t(L)).catch(L=>i(L instanceof Error?L.message:String(L))).finally(()=>l(!1))},[]),b=u.useCallback(async()=>{d(!0),h(null);try{await cj({exportReport:()=>T.exportReportWithProof(),download:(L,K)=>{const z=URL.createObjectURL(new Blob([L],{type:"text/html"})),Q=document.createElement("a");Q.href=z,Q.download=K,Q.click(),URL.revokeObjectURL(z)},refresh:p})}catch(L){h(L instanceof Error?L.message:String(L))}finally{d(!1)}},[p]),C=S.get("element"),N=S.get("ticket"),I=u.useCallback((L,K)=>{g(ej(S,L,K))},[S,g]),E=u.useCallback(()=>{const L=new URLSearchParams(S);L.delete("element"),L.delete("ticket"),g(L,{replace:!0})},[S,g]);if(n)return s.jsxs("div",{className:"page-inner",children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Reports"})}),s.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(a)return s.jsxs("div",{className:"page-inner",children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Reports"})}),s.jsx(Oa,{icon:"⚠",title:"Report unavailable",text:a})]});if(!e)return s.jsxs("div",{className:"page-inner",children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Reports"})}),s.jsx(Oa,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const A=Mw(e.renderedHtml),D=Fw(e.elements);return s.jsx("div",{className:"page-inner reports-page",children:s.jsxs("div",{className:"reports-layout",children:[s.jsxs("div",{className:"reports-bar",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:A}),s.jsxs("p",{className:"page-subtitle",children:[D?`written by the AI under mandate ${D} · `:"","checked ",Ow(e.checkedAt)]})]}),s.jsxs("div",{className:"reports-bar-actions",children:[s.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:j,disabled:o,children:o?"Checking…":"Check again"}),s.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:b,disabled:c,children:c?"Exporting…":"Export with proof"})]})]}),f&&s.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",f]}),s.jsxs("div",{className:"reports-summary-chip",children:[s.jsx("span",{children:Bw(e.proof,e.coverage)}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>x(L=>!L),children:m?"hide":"details"})]}),s.jsxs("div",{className:"reports-grid",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"reports-legend",role:"note",children:[s.jsxs("span",{className:"reports-legend-chip",children:[s.jsx("span",{className:"reports-sw reports-sw-v"}),Qw]}),s.jsxs("span",{className:"reports-legend-chip",children:[s.jsx("span",{className:"reports-sw reports-sw-a"}),Jw," (“",Yw,"”)"]}),e.renderedHtmlGloss&&s.jsxs("span",{className:"reports-legend-chip",children:[s.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",Xw]})]}),Ku(e)&&s.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:Ku(e)}),e.renderedHtmlGloss&&s.jsxs("label",{className:"reports-gloss-switch",children:[s.jsx("input",{type:"checkbox",role:"switch",checked:w,onChange:L=>v(L.target.checked)}),s.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:s.jsx("span",{className:"reports-gloss-thumb"})}),s.jsx("span",{children:qw})]}),s.jsx("p",{className:"form-hint",style:{marginBottom:"0.5rem"},children:"Written by the AI, rendered without scripts or network access. Scroll inside the report — the gateway does not auto-resize the frame. Click a checked value to see its details."}),s.jsx("iframe",{title:"Report",sandbox:Kw,srcDoc:sj(Zw(e,w)),className:"reports-iframe"})]}),s.jsx(uj,{report:e,open:m||!!C,selectedId:C,onOpenElement:L=>I(L),detail:C?s.jsx(lj,{report:e,elementId:C,ticketParam:N,onClose:E,onSelectTicket:L=>I(C,L)}):void 0})]})]})})}function Yn({to:e}){const{search:t,hash:n}=dt();return s.jsx(Vt,{to:`${e}${t}${n}`,replace:!0})}function fj({children:e}){const{user:t,mode:n,domain:r}=Ue();return t?n==="team"&&!r?s.jsx(Vt,{to:"/onboarding",replace:!0}):s.jsx(s.Fragment,{children:e}):s.jsx(Vt,{to:"/login",replace:!0})}function mj(){const{user:e,handleSessionLocked:t}=Ue();return pe("session-locked",n=>{const r=n==null?void 0:n.message;t(r)}),s.jsxs(Wy,{children:[s.jsx(je,{path:"/login",element:e?s.jsx(Vt,{to:"/",replace:!0}):s.jsx(hx,{})}),s.jsx(je,{path:"/onboarding",element:e?s.jsx(px,{}):s.jsx(Vt,{to:"/login",replace:!0})}),s.jsxs(je,{element:s.jsx(fj,{children:s.jsx(mx,{})}),children:[s.jsx(je,{path:"/",element:s.jsx(_x,{})}),s.jsx(je,{path:"/mandates",element:s.jsx(D0,{})}),s.jsx(je,{path:"/mandates/new/intent",element:s.jsx(s0,{})}),s.jsx(je,{path:"/mandates/new/sign",element:s.jsx(h0,{})}),s.jsx(je,{path:"/integrations",element:s.jsx(j0,{})}),s.jsx(je,{path:"/team",element:s.jsx(S0,{})}),s.jsx(je,{path:"/tickets",element:s.jsx(ew,{})}),s.jsx(je,{path:"/approvals",element:s.jsx(Aw,{})}),s.jsx(je,{path:"/reports",element:s.jsx(dj,{})}),s.jsx(je,{path:"/agent/new",element:s.jsx(Vt,{to:"/mandates?new=1",replace:!0})}),s.jsx(je,{path:"/agent/gate",element:s.jsx(Yn,{to:"/mandates/new/intent"})}),s.jsx(je,{path:"/agent/review",element:s.jsx(Yn,{to:"/mandates/new/sign"})}),s.jsx(je,{path:"/authorizations",element:s.jsx(Yn,{to:"/mandates"})}),s.jsx(je,{path:"/groups",element:s.jsx(Yn,{to:"/team"})}),s.jsx(je,{path:"/audit",element:s.jsx(Yn,{to:"/tickets"})}),s.jsx(je,{path:"/proposals",element:s.jsx(Yn,{to:"/approvals"})}),s.jsx(je,{path:"/agent-brief",element:s.jsx($w,{})}),s.jsx(je,{path:"/settings",element:s.jsx(fw,{})}),s.jsx(je,{path:"/settings/services",element:s.jsx(Vt,{to:"/settings",replace:!0})}),s.jsx(je,{path:"/deploy",element:s.jsx(Vt,{to:"/integrations",replace:!0})})]}),s.jsx(je,{path:"*",element:s.jsx(Vt,{to:"/",replace:!0})})]})}function hj(){return s.jsx(hv,{children:s.jsx(Tv,{children:s.jsx(Iv,{children:s.jsx(mj,{})})})})}cm(document.getElementById("root")).render(s.jsx(u.StrictMode,{children:s.jsx(hj,{})}));
|