@suveren/gateway 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var Dp=Object.defineProperty;var Bp=(e,t,n)=>t in e?Dp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _r=(e,t,n)=>Bp(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 hd={exports:{}},Qa={},gd={exports:{}},ce={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Cs=Symbol.for("react.element"),Up=Symbol.for("react.portal"),Wp=Symbol.for("react.fragment"),Hp=Symbol.for("react.strict_mode"),Vp=Symbol.for("react.profiler"),Gp=Symbol.for("react.provider"),Kp=Symbol.for("react.context"),Yp=Symbol.for("react.forward_ref"),Qp=Symbol.for("react.suspense"),Jp=Symbol.for("react.memo"),qp=Symbol.for("react.lazy"),Sc=Symbol.iterator;function Xp(e){return e===null||typeof e!="object"?null:(e=Sc&&e[Sc]||e["@@iterator"],typeof e=="function"?e:null)}var yd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},vd=Object.assign,xd={};function Er(e,t,n){this.props=e,this.context=t,this.refs=xd,this.updater=n||yd}Er.prototype.isReactComponent={};Er.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")};Er.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function wd(){}wd.prototype=Er.prototype;function tl(e,t,n){this.props=e,this.context=t,this.refs=xd,this.updater=n||yd}var nl=tl.prototype=new wd;nl.constructor=tl;vd(nl,Er.prototype);nl.isPureReactComponent=!0;var kc=Array.isArray,jd=Object.prototype.hasOwnProperty,rl={current:null},Sd={key:!0,ref:!0,__self:!0,__source:!0};function kd(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)jd.call(t,r)&&!Sd.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:Cs,type:e,key:i,ref:o,props:a,_owner:rl.current}}function Zp(e,t){return{$$typeof:Cs,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function sl(e){return typeof e=="object"&&e!==null&&e.$$typeof===Cs}function eh(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var bc=/\/+/g;function vi(e,t){return typeof e=="object"&&e!==null&&e.key!=null?eh(""+e.key):t.toString(36)}function sa(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 Cs:case Up:o=!0}}if(o)return o=e,a=a(o),e=r===""?"."+vi(o,0):r,kc(a)?(n="",e!=null&&(n=e.replace(bc,"$&/")+"/"),sa(a,t,n,"",function(d){return d})):a!=null&&(sl(a)&&(a=Zp(a,n+(!a.key||o&&o.key===a.key?"":(""+a.key).replace(bc,"$&/")+"/")+e)),t.push(a)),1;if(o=0,r=r===""?".":r+":",kc(e))for(var l=0;l<e.length;l++){i=e[l];var c=r+vi(i,l);o+=sa(i,t,n,c,a)}else if(c=Xp(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=r+vi(i,l++),o+=sa(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 $s(e,t,n){if(e==null)return e;var r=[],a=0;return sa(e,r,"","",function(i){return t.call(n,i,a++)}),r}function th(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},aa={transition:null},nh={ReactCurrentDispatcher:rt,ReactCurrentBatchConfig:aa,ReactCurrentOwner:rl};function bd(){throw Error("act(...) is not supported in production builds of React.")}ce.Children={map:$s,forEach:function(e,t,n){$s(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return $s(e,function(){t++}),t},toArray:function(e){return $s(e,function(t){return t})||[]},only:function(e){if(!sl(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ce.Component=Er;ce.Fragment=Wp;ce.Profiler=Vp;ce.PureComponent=tl;ce.StrictMode=Hp;ce.Suspense=Qp;ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=nh;ce.act=bd;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=vd({},e.props),a=e.key,i=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,o=rl.current),t.key!==void 0&&(a=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)jd.call(t,c)&&!Sd.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var d=0;d<c;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:Cs,type:e.type,key:a,ref:i,props:r,_owner:o}};ce.createContext=function(e){return e={$$typeof:Kp,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Gp,_context:e},e.Consumer=e};ce.createElement=kd;ce.createFactory=function(e){var t=kd.bind(null,e);return t.type=e,t};ce.createRef=function(){return{current:null}};ce.forwardRef=function(e){return{$$typeof:Yp,render:e}};ce.isValidElement=sl;ce.lazy=function(e){return{$$typeof:qp,_payload:{_status:-1,_result:e},_init:th}};ce.memo=function(e,t){return{$$typeof:Jp,type:e,compare:t===void 0?null:t}};ce.startTransition=function(e){var t=aa.transition;aa.transition={};try{e()}finally{aa.transition=t}};ce.unstable_act=bd;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";gd.exports=ce;var u=gd.exports;/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.production.min.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var rh=u,sh=Symbol.for("react.element"),ah=Symbol.for("react.fragment"),ih=Object.prototype.hasOwnProperty,oh=rh.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,lh={key:!0,ref:!0,__self:!0,__source:!0};function Nd(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)ih.call(t,r)&&!lh.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:sh,type:e,key:i,ref:o,props:a,_owner:oh.current}}Qa.Fragment=ah;Qa.jsx=Nd;Qa.jsxs=Nd;hd.exports=Qa;var s=hd.exports,Cd={exports:{}},wt={},Ed={exports:{}},Td={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/(function(e){function t(z,R){var D=z.length;z.push(R);e:for(;0<D;){var _=D-1>>>1,$=z[_];if(0<a($,R))z[_]=R,z[D]=$,D=_;else break e}}function n(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var R=z[0],D=z.pop();if(D!==R){z[0]=D;e:for(var _=0,$=z.length,V=$>>>1;_<V;){var X=2*(_+1)-1,ne=z[X],oe=X+1,de=z[oe];if(0>a(ne,D))oe<$&&0>a(de,ne)?(z[_]=de,z[oe]=D,_=oe):(z[_]=ne,z[X]=D,_=X);else if(oe<$&&0>a(de,D))z[_]=de,z[oe]=D,_=oe;else break e}}return R}function a(z,R){var D=z.sortIndex-R.sortIndex;return D!==0?D:z.id-R.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,p=null,m=3,x=!1,j=!1,v=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,h=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(z){for(var R=n(d);R!==null;){if(R.callback===null)r(d);else if(R.startTime<=z)r(d),R.sortIndex=R.expirationTime,t(c,R);else break;R=n(d)}}function w(z){if(v=!1,y(z),!j)if(n(c)!==null)j=!0,W(b);else{var R=n(d);R!==null&&ee(w,R.startTime-z)}}function b(z,R){j=!1,v&&(v=!1,g(A),A=-1),x=!0;var D=m;try{for(y(R),p=n(c);p!==null&&(!(p.expirationTime>R)||z&&!O());){var _=p.callback;if(typeof _=="function"){p.callback=null,m=p.priorityLevel;var $=_(p.expirationTime<=R);R=e.unstable_now(),typeof $=="function"?p.callback=$:p===n(c)&&r(c),y(R)}else r(c);p=n(c)}if(p!==null)var V=!0;else{var X=n(d);X!==null&&ee(w,X.startTime-R),V=!1}return V}finally{p=null,m=D,x=!1}}var C=!1,N=null,A=-1,E=5,P=-1;function O(){return!(e.unstable_now()-P<E)}function L(){if(N!==null){var z=e.unstable_now();P=z;var R=!0;try{R=N(!0,z)}finally{R?Z():(C=!1,N=null)}}else C=!1}var Z;if(typeof h=="function")Z=function(){h(L)};else if(typeof MessageChannel<"u"){var F=new MessageChannel,q=F.port2;F.port1.onmessage=L,Z=function(){q.postMessage(null)}}else Z=function(){S(L,0)};function W(z){N=z,C||(C=!0,Z())}function ee(z,R){A=S(function(){z(e.unstable_now())},R)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_continueExecution=function(){j||x||(j=!0,W(b))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(z){switch(m){case 1:case 2:case 3:var R=3;break;default:R=m}var D=m;m=R;try{return z()}finally{m=D}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,R){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var D=m;m=z;try{return R()}finally{m=D}},e.unstable_scheduleCallback=function(z,R,D){var _=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?_+D:_):D=_,z){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=D+$,z={id:f++,callback:R,priorityLevel:z,startTime:D,expirationTime:$,sortIndex:-1},D>_?(z.sortIndex=D,t(d,z),n(c)===null&&z===n(d)&&(v?(g(A),A=-1):v=!0,ee(w,D-_))):(z.sortIndex=$,t(c,z),j||x||(j=!0,W(b))),z},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(z){var R=m;return function(){var D=m;m=R;try{return z.apply(this,arguments)}finally{m=D}}}})(Td);Ed.exports=Td;var ch=Ed.exports;/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.min.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var uh=u,xt=ch;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 Id=new Set,os={};function Yn(e,t){xr(e,t),xr(e+"Capture",t)}function xr(e,t){for(os[e]=t,e=0;e<t.length;e++)Id.add(t[e])}var en=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Zi=Object.prototype.hasOwnProperty,dh=/^[: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]*$/,Nc={},Cc={};function fh(e){return Zi.call(Cc,e)?!0:Zi.call(Nc,e)?!1:dh.test(e)?Cc[e]=!0:(Nc[e]=!0,!1)}function mh(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 ph(e,t,n,r){if(t===null||typeof t>"u"||mh(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 Qe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Qe[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];Qe[t]=new st(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Qe[e]=new st(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Qe[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){Qe[e]=new st(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Qe[e]=new st(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Qe[e]=new st(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Qe[e]=new st(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Qe[e]=new st(e,5,!1,e.toLowerCase(),null,!1,!1)});var al=/[\-:]([a-z])/g;function il(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(al,il);Qe[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(al,il);Qe[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(al,il);Qe[t]=new st(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Qe[e]=new st(e,1,!1,e.toLowerCase(),null,!1,!1)});Qe.xlinkHref=new st("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Qe[e]=new st(e,1,!1,e.toLowerCase(),null,!0,!0)});function ol(e,t,n,r){var a=Qe.hasOwnProperty(t)?Qe[t]:null;(a!==null?a.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(ph(t,n,a,r)&&(n=null),r||a===null?fh(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 an=uh.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Ms=Symbol.for("react.element"),tr=Symbol.for("react.portal"),nr=Symbol.for("react.fragment"),ll=Symbol.for("react.strict_mode"),eo=Symbol.for("react.profiler"),Rd=Symbol.for("react.provider"),Ad=Symbol.for("react.context"),cl=Symbol.for("react.forward_ref"),to=Symbol.for("react.suspense"),no=Symbol.for("react.suspense_list"),ul=Symbol.for("react.memo"),cn=Symbol.for("react.lazy"),Pd=Symbol.for("react.offscreen"),Ec=Symbol.iterator;function Lr(e){return e===null||typeof e!="object"?null:(e=Ec&&e[Ec]||e["@@iterator"],typeof e=="function"?e:null)}var Ae=Object.assign,xi;function Gr(e){if(xi===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);xi=t&&t[1]||""}return`
|
|
34
|
+
`+xi+e}var wi=!1;function ji(e,t){if(!e||wi)return"";wi=!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
|
+
`),i=r.stack.split(`
|
|
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{wi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Gr(e):""}function hh(e){switch(e.tag){case 5:return Gr(e.type);case 16:return Gr("Lazy");case 13:return Gr("Suspense");case 19:return Gr("SuspenseList");case 0:case 2:case 15:return e=ji(e.type,!1),e;case 11:return e=ji(e.type.render,!1),e;case 1:return e=ji(e.type,!0),e;default:return""}}function ro(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 nr:return"Fragment";case tr:return"Portal";case eo:return"Profiler";case ll:return"StrictMode";case to:return"Suspense";case no:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ad:return(e.displayName||"Context")+".Consumer";case Rd:return(e._context.displayName||"Context")+".Provider";case cl:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ul:return t=e.displayName||null,t!==null?t:ro(e.type)||"Memo";case cn:t=e._payload,e=e._init;try{return ro(e(t))}catch{}}return null}function gh(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 ro(t);case 8:return t===ll?"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 kn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function _d(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function yh(e){var t=_d(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 Fs(e){e._valueTracker||(e._valueTracker=yh(e))}function Ld(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=_d(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function wa(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 so(e,t){var n=t.checked;return Ae({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Tc(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=kn(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 zd(e,t){t=t.checked,t!=null&&ol(e,"checked",t,!1)}function ao(e,t){zd(e,t);var n=kn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?io(e,t.type,n):t.hasOwnProperty("defaultValue")&&io(e,t.type,kn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ic(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function io(e,t,n){(t!=="number"||wa(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Kr=Array.isArray;function mr(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=""+kn(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 oo(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(M(91));return Ae({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Rc(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(Kr(n)){if(1<n.length)throw Error(M(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:kn(n)}}function $d(e,t){var n=kn(t.value),r=kn(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 Ac(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Md(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 lo(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Md(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Os,Fd=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(Os=Os||document.createElement("div"),Os.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Os.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ls(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var qr={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},vh=["Webkit","ms","Moz","O"];Object.keys(qr).forEach(function(e){vh.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),qr[t]=qr[e]})});function Od(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||qr.hasOwnProperty(e)&&qr[e]?(""+t).trim():t+"px"}function Dd(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=Od(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var xh=Ae({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 co(e,t){if(t){if(xh[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 uo(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 fo=null;function dl(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var mo=null,pr=null,hr=null;function Pc(e){if(e=Is(e)){if(typeof mo!="function")throw Error(M(280));var t=e.stateNode;t&&(t=ei(t),mo(e.stateNode,e.type,t))}}function Bd(e){pr?hr?hr.push(e):hr=[e]:pr=e}function Ud(){if(pr){var e=pr,t=hr;if(hr=pr=null,Pc(e),t)for(e=0;e<t.length;e++)Pc(t[e])}}function Wd(e,t){return e(t)}function Hd(){}var Si=!1;function Vd(e,t,n){if(Si)return e(t,n);Si=!0;try{return Wd(e,t,n)}finally{Si=!1,(pr!==null||hr!==null)&&(Hd(),Ud())}}function cs(e,t){var n=e.stateNode;if(n===null)return null;var r=ei(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 po=!1;if(en)try{var zr={};Object.defineProperty(zr,"passive",{get:function(){po=!0}}),window.addEventListener("test",zr,zr),window.removeEventListener("test",zr,zr)}catch{po=!1}function wh(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 Xr=!1,ja=null,Sa=!1,ho=null,jh={onError:function(e){Xr=!0,ja=e}};function Sh(e,t,n,r,a,i,o,l,c){Xr=!1,ja=null,wh.apply(jh,arguments)}function kh(e,t,n,r,a,i,o,l,c){if(Sh.apply(this,arguments),Xr){if(Xr){var d=ja;Xr=!1,ja=null}else throw Error(M(198));Sa||(Sa=!0,ho=d)}}function Qn(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 Gd(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 _c(e){if(Qn(e)!==e)throw Error(M(188))}function bh(e){var t=e.alternate;if(!t){if(t=Qn(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 _c(a),e;if(i===r)return _c(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 Kd(e){return e=bh(e),e!==null?Yd(e):null}function Yd(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Yd(e);if(t!==null)return t;e=e.sibling}return null}var Qd=xt.unstable_scheduleCallback,Lc=xt.unstable_cancelCallback,Nh=xt.unstable_shouldYield,Ch=xt.unstable_requestPaint,Le=xt.unstable_now,Eh=xt.unstable_getCurrentPriorityLevel,fl=xt.unstable_ImmediatePriority,Jd=xt.unstable_UserBlockingPriority,ka=xt.unstable_NormalPriority,Th=xt.unstable_LowPriority,qd=xt.unstable_IdlePriority,Ja=null,Gt=null;function Ih(e){if(Gt&&typeof Gt.onCommitFiberRoot=="function")try{Gt.onCommitFiberRoot(Ja,e,void 0,(e.current.flags&128)===128)}catch{}}var Mt=Math.clz32?Math.clz32:Ph,Rh=Math.log,Ah=Math.LN2;function Ph(e){return e>>>=0,e===0?32:31-(Rh(e)/Ah|0)|0}var Ds=64,Bs=4194304;function Yr(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 ba(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=Yr(l):(i&=o,i!==0&&(r=Yr(i)))}else o=n&~a,o!==0?r=Yr(o):i!==0&&(r=Yr(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-Mt(t),a=1<<n,r|=e[n],t&=~a;return r}function _h(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 Lh(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-Mt(i),l=1<<o,c=a[o];c===-1?(!(l&n)||l&r)&&(a[o]=_h(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function go(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Xd(){var e=Ds;return Ds<<=1,!(Ds&4194240)&&(Ds=64),e}function ki(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Es(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Mt(t),e[t]=n}function zh(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-Mt(n),i=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~i}}function ml(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Mt(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var we=0;function Zd(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var ef,pl,tf,nf,rf,yo=!1,Us=[],hn=null,gn=null,yn=null,us=new Map,ds=new Map,dn=[],$h="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 zc(e,t){switch(e){case"focusin":case"focusout":hn=null;break;case"dragenter":case"dragleave":gn=null;break;case"mouseover":case"mouseout":yn=null;break;case"pointerover":case"pointerout":us.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ds.delete(t.pointerId)}}function $r(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=Is(t),t!==null&&pl(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function Mh(e,t,n,r,a){switch(t){case"focusin":return hn=$r(hn,e,t,n,r,a),!0;case"dragenter":return gn=$r(gn,e,t,n,r,a),!0;case"mouseover":return yn=$r(yn,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return us.set(i,$r(us.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,ds.set(i,$r(ds.get(i)||null,e,t,n,r,a)),!0}return!1}function sf(e){var t=zn(e.target);if(t!==null){var n=Qn(t);if(n!==null){if(t=n.tag,t===13){if(t=Gd(n),t!==null){e.blockedOn=t,rf(e.priority,function(){tf(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 ia(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=vo(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);fo=r,n.target.dispatchEvent(r),fo=null}else return t=Is(n),t!==null&&pl(t),e.blockedOn=n,!1;t.shift()}return!0}function $c(e,t,n){ia(e)&&n.delete(t)}function Fh(){yo=!1,hn!==null&&ia(hn)&&(hn=null),gn!==null&&ia(gn)&&(gn=null),yn!==null&&ia(yn)&&(yn=null),us.forEach($c),ds.forEach($c)}function Mr(e,t){e.blockedOn===t&&(e.blockedOn=null,yo||(yo=!0,xt.unstable_scheduleCallback(xt.unstable_NormalPriority,Fh)))}function fs(e){function t(a){return Mr(a,e)}if(0<Us.length){Mr(Us[0],e);for(var n=1;n<Us.length;n++){var r=Us[n];r.blockedOn===e&&(r.blockedOn=null)}}for(hn!==null&&Mr(hn,e),gn!==null&&Mr(gn,e),yn!==null&&Mr(yn,e),us.forEach(t),ds.forEach(t),n=0;n<dn.length;n++)r=dn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<dn.length&&(n=dn[0],n.blockedOn===null);)sf(n),n.blockedOn===null&&dn.shift()}var gr=an.ReactCurrentBatchConfig,Na=!0;function Oh(e,t,n,r){var a=we,i=gr.transition;gr.transition=null;try{we=1,hl(e,t,n,r)}finally{we=a,gr.transition=i}}function Dh(e,t,n,r){var a=we,i=gr.transition;gr.transition=null;try{we=4,hl(e,t,n,r)}finally{we=a,gr.transition=i}}function hl(e,t,n,r){if(Na){var a=vo(e,t,n,r);if(a===null)_i(e,t,r,Ca,n),zc(e,r);else if(Mh(a,e,t,n,r))r.stopPropagation();else if(zc(e,r),t&4&&-1<$h.indexOf(e)){for(;a!==null;){var i=Is(a);if(i!==null&&ef(i),i=vo(e,t,n,r),i===null&&_i(e,t,r,Ca,n),i===a)break;a=i}a!==null&&r.stopPropagation()}else _i(e,t,r,null,n)}}var Ca=null;function vo(e,t,n,r){if(Ca=null,e=dl(r),e=zn(e),e!==null)if(t=Qn(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Gd(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 Ca=e,null}function af(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(Eh()){case fl:return 1;case Jd:return 4;case ka:case Th:return 16;case qd:return 536870912;default:return 16}default:return 16}}var mn=null,gl=null,oa=null;function of(){if(oa)return oa;var e,t=gl,n=t.length,r,a="value"in mn?mn.value:mn.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 oa=a.slice(e,1<r?1-r:void 0)}function la(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Ws(){return!0}function Mc(){return!1}function jt(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)?Ws:Mc,this.isPropagationStopped=Mc,this}return Ae(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Ws)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Ws)},persist:function(){},isPersistent:Ws}),t}var Tr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},yl=jt(Tr),Ts=Ae({},Tr,{view:0,detail:0}),Bh=jt(Ts),bi,Ni,Fr,qa=Ae({},Ts,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:vl,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!==Fr&&(Fr&&e.type==="mousemove"?(bi=e.screenX-Fr.screenX,Ni=e.screenY-Fr.screenY):Ni=bi=0,Fr=e),bi)},movementY:function(e){return"movementY"in e?e.movementY:Ni}}),Fc=jt(qa),Uh=Ae({},qa,{dataTransfer:0}),Wh=jt(Uh),Hh=Ae({},Ts,{relatedTarget:0}),Ci=jt(Hh),Vh=Ae({},Tr,{animationName:0,elapsedTime:0,pseudoElement:0}),Gh=jt(Vh),Kh=Ae({},Tr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Yh=jt(Kh),Qh=Ae({},Tr,{data:0}),Oc=jt(Qh),Jh={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},qh={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"},Xh={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Zh(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Xh[e])?!!t[e]:!1}function vl(){return Zh}var eg=Ae({},Ts,{key:function(e){if(e.key){var t=Jh[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=la(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?qh[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:vl,charCode:function(e){return e.type==="keypress"?la(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?la(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),tg=jt(eg),ng=Ae({},qa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Dc=jt(ng),rg=Ae({},Ts,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:vl}),sg=jt(rg),ag=Ae({},Tr,{propertyName:0,elapsedTime:0,pseudoElement:0}),ig=jt(ag),og=Ae({},qa,{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}),lg=jt(og),cg=[9,13,27,32],xl=en&&"CompositionEvent"in window,Zr=null;en&&"documentMode"in document&&(Zr=document.documentMode);var ug=en&&"TextEvent"in window&&!Zr,lf=en&&(!xl||Zr&&8<Zr&&11>=Zr),Bc=" ",Uc=!1;function cf(e,t){switch(e){case"keyup":return cg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function uf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var rr=!1;function dg(e,t){switch(e){case"compositionend":return uf(t);case"keypress":return t.which!==32?null:(Uc=!0,Bc);case"textInput":return e=t.data,e===Bc&&Uc?null:e;default:return null}}function fg(e,t){if(rr)return e==="compositionend"||!xl&&cf(e,t)?(e=of(),oa=gl=mn=null,rr=!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 lf&&t.locale!=="ko"?null:t.data;default:return null}}var mg={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 Wc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!mg[e.type]:t==="textarea"}function df(e,t,n,r){Bd(r),t=Ea(t,"onChange"),0<t.length&&(n=new yl("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var es=null,ms=null;function pg(e){Sf(e,0)}function Xa(e){var t=ir(e);if(Ld(t))return e}function hg(e,t){if(e==="change")return t}var ff=!1;if(en){var Ei;if(en){var Ti="oninput"in document;if(!Ti){var Hc=document.createElement("div");Hc.setAttribute("oninput","return;"),Ti=typeof Hc.oninput=="function"}Ei=Ti}else Ei=!1;ff=Ei&&(!document.documentMode||9<document.documentMode)}function Vc(){es&&(es.detachEvent("onpropertychange",mf),ms=es=null)}function mf(e){if(e.propertyName==="value"&&Xa(ms)){var t=[];df(t,ms,e,dl(e)),Vd(pg,t)}}function gg(e,t,n){e==="focusin"?(Vc(),es=t,ms=n,es.attachEvent("onpropertychange",mf)):e==="focusout"&&Vc()}function yg(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Xa(ms)}function vg(e,t){if(e==="click")return Xa(t)}function xg(e,t){if(e==="input"||e==="change")return Xa(t)}function wg(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Dt=typeof Object.is=="function"?Object.is:wg;function ps(e,t){if(Dt(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(!Zi.call(t,a)||!Dt(e[a],t[a]))return!1}return!0}function Gc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Kc(e,t){var n=Gc(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=Gc(n)}}function pf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?pf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function hf(){for(var e=window,t=wa();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=wa(e.document)}return t}function wl(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 jg(e){var t=hf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&pf(n.ownerDocument.documentElement,n)){if(r!==null&&wl(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=Kc(n,i);var o=Kc(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 Sg=en&&"documentMode"in document&&11>=document.documentMode,sr=null,xo=null,ts=null,wo=!1;function Yc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;wo||sr==null||sr!==wa(r)||(r=sr,"selectionStart"in r&&wl(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}),ts&&ps(ts,r)||(ts=r,r=Ea(xo,"onSelect"),0<r.length&&(t=new yl("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=sr)))}function Hs(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ar={animationend:Hs("Animation","AnimationEnd"),animationiteration:Hs("Animation","AnimationIteration"),animationstart:Hs("Animation","AnimationStart"),transitionend:Hs("Transition","TransitionEnd")},Ii={},gf={};en&&(gf=document.createElement("div").style,"AnimationEvent"in window||(delete ar.animationend.animation,delete ar.animationiteration.animation,delete ar.animationstart.animation),"TransitionEvent"in window||delete ar.transitionend.transition);function Za(e){if(Ii[e])return Ii[e];if(!ar[e])return e;var t=ar[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in gf)return Ii[e]=t[n];return e}var yf=Za("animationend"),vf=Za("animationiteration"),xf=Za("animationstart"),wf=Za("transitionend"),jf=new Map,Qc="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 Nn(e,t){jf.set(e,t),Yn(t,[e])}for(var Ri=0;Ri<Qc.length;Ri++){var Ai=Qc[Ri],kg=Ai.toLowerCase(),bg=Ai[0].toUpperCase()+Ai.slice(1);Nn(kg,"on"+bg)}Nn(yf,"onAnimationEnd");Nn(vf,"onAnimationIteration");Nn(xf,"onAnimationStart");Nn("dblclick","onDoubleClick");Nn("focusin","onFocus");Nn("focusout","onBlur");Nn(wf,"onTransitionEnd");xr("onMouseEnter",["mouseout","mouseover"]);xr("onMouseLeave",["mouseout","mouseover"]);xr("onPointerEnter",["pointerout","pointerover"]);xr("onPointerLeave",["pointerout","pointerover"]);Yn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Yn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Yn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Yn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Yn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Yn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Qr="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(" "),Ng=new Set("cancel close invalid load scroll toggle".split(" ").concat(Qr));function Jc(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,kh(r,t,void 0,e),e.currentTarget=null}function Sf(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;Jc(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;Jc(a,l,d),i=c}}}if(Sa)throw e=ho,Sa=!1,ho=null,e}function ke(e,t){var n=t[No];n===void 0&&(n=t[No]=new Set);var r=e+"__bubble";n.has(r)||(kf(t,e,2,!1),n.add(r))}function Pi(e,t,n){var r=0;t&&(r|=4),kf(n,e,r,t)}var Vs="_reactListening"+Math.random().toString(36).slice(2);function hs(e){if(!e[Vs]){e[Vs]=!0,Id.forEach(function(n){n!=="selectionchange"&&(Ng.has(n)||Pi(n,!1,e),Pi(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Vs]||(t[Vs]=!0,Pi("selectionchange",!1,t))}}function kf(e,t,n,r){switch(af(t)){case 1:var a=Oh;break;case 4:a=Dh;break;default:a=hl}n=a.bind(null,t,n,e),a=void 0,!po||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 _i(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=zn(l),o===null)return;if(c=o.tag,c===5||c===6){r=i=o;continue e}l=l.parentNode}}r=r.return}Vd(function(){var d=i,f=dl(n),p=[];e:{var m=jf.get(e);if(m!==void 0){var x=yl,j=e;switch(e){case"keypress":if(la(n)===0)break e;case"keydown":case"keyup":x=tg;break;case"focusin":j="focus",x=Ci;break;case"focusout":j="blur",x=Ci;break;case"beforeblur":case"afterblur":x=Ci;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=Fc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=Wh;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=sg;break;case yf:case vf:case xf:x=Gh;break;case wf:x=ig;break;case"scroll":x=Bh;break;case"wheel":x=lg;break;case"copy":case"cut":case"paste":x=Yh;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=Dc}var v=(t&4)!==0,S=!v&&e==="scroll",g=v?m!==null?m+"Capture":null:m;v=[];for(var h=d,y;h!==null;){y=h;var w=y.stateNode;if(y.tag===5&&w!==null&&(y=w,g!==null&&(w=cs(h,g),w!=null&&v.push(gs(h,w,y)))),S)break;h=h.return}0<v.length&&(m=new x(m,j,null,n,f),p.push({event:m,listeners:v}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",m&&n!==fo&&(j=n.relatedTarget||n.fromElement)&&(zn(j)||j[tn]))break e;if((x||m)&&(m=f.window===f?f:(m=f.ownerDocument)?m.defaultView||m.parentWindow:window,x?(j=n.relatedTarget||n.toElement,x=d,j=j?zn(j):null,j!==null&&(S=Qn(j),j!==S||j.tag!==5&&j.tag!==6)&&(j=null)):(x=null,j=d),x!==j)){if(v=Fc,w="onMouseLeave",g="onMouseEnter",h="mouse",(e==="pointerout"||e==="pointerover")&&(v=Dc,w="onPointerLeave",g="onPointerEnter",h="pointer"),S=x==null?m:ir(x),y=j==null?m:ir(j),m=new v(w,h+"leave",x,n,f),m.target=S,m.relatedTarget=y,w=null,zn(f)===d&&(v=new v(g,h+"enter",j,n,f),v.target=y,v.relatedTarget=S,w=v),S=w,x&&j)t:{for(v=x,g=j,h=0,y=v;y;y=qn(y))h++;for(y=0,w=g;w;w=qn(w))y++;for(;0<h-y;)v=qn(v),h--;for(;0<y-h;)g=qn(g),y--;for(;h--;){if(v===g||g!==null&&v===g.alternate)break t;v=qn(v),g=qn(g)}v=null}else v=null;x!==null&&qc(p,m,x,v,!1),j!==null&&S!==null&&qc(p,S,j,v,!0)}}e:{if(m=d?ir(d):window,x=m.nodeName&&m.nodeName.toLowerCase(),x==="select"||x==="input"&&m.type==="file")var b=hg;else if(Wc(m))if(ff)b=xg;else{b=yg;var C=gg}else(x=m.nodeName)&&x.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(b=vg);if(b&&(b=b(e,d))){df(p,b,n,f);break e}C&&C(e,m,d),e==="focusout"&&(C=m._wrapperState)&&C.controlled&&m.type==="number"&&io(m,"number",m.value)}switch(C=d?ir(d):window,e){case"focusin":(Wc(C)||C.contentEditable==="true")&&(sr=C,xo=d,ts=null);break;case"focusout":ts=xo=sr=null;break;case"mousedown":wo=!0;break;case"contextmenu":case"mouseup":case"dragend":wo=!1,Yc(p,n,f);break;case"selectionchange":if(Sg)break;case"keydown":case"keyup":Yc(p,n,f)}var N;if(xl)e:{switch(e){case"compositionstart":var A="onCompositionStart";break e;case"compositionend":A="onCompositionEnd";break e;case"compositionupdate":A="onCompositionUpdate";break e}A=void 0}else rr?cf(e,n)&&(A="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(A="onCompositionStart");A&&(lf&&n.locale!=="ko"&&(rr||A!=="onCompositionStart"?A==="onCompositionEnd"&&rr&&(N=of()):(mn=f,gl="value"in mn?mn.value:mn.textContent,rr=!0)),C=Ea(d,A),0<C.length&&(A=new Oc(A,e,null,n,f),p.push({event:A,listeners:C}),N?A.data=N:(N=uf(n),N!==null&&(A.data=N)))),(N=ug?dg(e,n):fg(e,n))&&(d=Ea(d,"onBeforeInput"),0<d.length&&(f=new Oc("onBeforeInput","beforeinput",null,n,f),p.push({event:f,listeners:d}),f.data=N))}Sf(p,t)})}function gs(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ea(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,i=a.stateNode;a.tag===5&&i!==null&&(a=i,i=cs(e,n),i!=null&&r.unshift(gs(e,i,a)),i=cs(e,t),i!=null&&r.push(gs(e,i,a))),e=e.return}return r}function qn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function qc(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=cs(n,i),c!=null&&o.unshift(gs(n,c,l))):a||(c=cs(n,i),c!=null&&o.push(gs(n,c,l)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Cg=/\r\n?/g,Eg=/\u0000|\uFFFD/g;function Xc(e){return(typeof e=="string"?e:""+e).replace(Cg,`
|
|
38
|
+
`).replace(Eg,"")}function Gs(e,t,n){if(t=Xc(t),Xc(e)!==t&&n)throw Error(M(425))}function Ta(){}var jo=null,So=null;function ko(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 bo=typeof setTimeout=="function"?setTimeout:void 0,Tg=typeof clearTimeout=="function"?clearTimeout:void 0,Zc=typeof Promise=="function"?Promise:void 0,Ig=typeof queueMicrotask=="function"?queueMicrotask:typeof Zc<"u"?function(e){return Zc.resolve(null).then(e).catch(Rg)}:bo;function Rg(e){setTimeout(function(){throw e})}function Li(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),fs(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);fs(t)}function vn(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 eu(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 Ir=Math.random().toString(36).slice(2),Vt="__reactFiber$"+Ir,ys="__reactProps$"+Ir,tn="__reactContainer$"+Ir,No="__reactEvents$"+Ir,Ag="__reactListeners$"+Ir,Pg="__reactHandles$"+Ir;function zn(e){var t=e[Vt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[tn]||n[Vt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=eu(e);e!==null;){if(n=e[Vt])return n;e=eu(e)}return t}e=n,n=e.parentNode}return null}function Is(e){return e=e[Vt]||e[tn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ir(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(M(33))}function ei(e){return e[ys]||null}var Co=[],or=-1;function Cn(e){return{current:e}}function Ne(e){0>or||(e.current=Co[or],Co[or]=null,or--)}function Se(e,t){or++,Co[or]=e.current,e.current=t}var bn={},Ze=Cn(bn),ut=Cn(!1),Un=bn;function wr(e,t){var n=e.type.contextTypes;if(!n)return bn;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 dt(e){return e=e.childContextTypes,e!=null}function Ia(){Ne(ut),Ne(Ze)}function tu(e,t,n){if(Ze.current!==bn)throw Error(M(168));Se(Ze,t),Se(ut,n)}function bf(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,gh(e)||"Unknown",a));return Ae({},n,r)}function Ra(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||bn,Un=Ze.current,Se(Ze,e),Se(ut,ut.current),!0}function nu(e,t,n){var r=e.stateNode;if(!r)throw Error(M(169));n?(e=bf(e,t,Un),r.__reactInternalMemoizedMergedChildContext=e,Ne(ut),Ne(Ze),Se(Ze,e)):Ne(ut),Se(ut,n)}var Qt=null,ti=!1,zi=!1;function Nf(e){Qt===null?Qt=[e]:Qt.push(e)}function _g(e){ti=!0,Nf(e)}function En(){if(!zi&&Qt!==null){zi=!0;var e=0,t=we;try{var n=Qt;for(we=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Qt=null,ti=!1}catch(a){throw Qt!==null&&(Qt=Qt.slice(e+1)),Qd(fl,En),a}finally{we=t,zi=!1}}return null}var lr=[],cr=0,Aa=null,Pa=0,Nt=[],Ct=0,Wn=null,qt=1,Xt="";function Pn(e,t){lr[cr++]=Pa,lr[cr++]=Aa,Aa=e,Pa=t}function Cf(e,t,n){Nt[Ct++]=qt,Nt[Ct++]=Xt,Nt[Ct++]=Wn,Wn=e;var r=qt;e=Xt;var a=32-Mt(r)-1;r&=~(1<<a),n+=1;var i=32-Mt(t)+a;if(30<i){var o=a-a%5;i=(r&(1<<o)-1).toString(32),r>>=o,a-=o,qt=1<<32-Mt(t)+a|n<<a|r,Xt=i+e}else qt=1<<i|n<<a|r,Xt=e}function jl(e){e.return!==null&&(Pn(e,1),Cf(e,1,0))}function Sl(e){for(;e===Aa;)Aa=lr[--cr],lr[cr]=null,Pa=lr[--cr],lr[cr]=null;for(;e===Wn;)Wn=Nt[--Ct],Nt[Ct]=null,Xt=Nt[--Ct],Nt[Ct]=null,qt=Nt[--Ct],Nt[Ct]=null}var vt=null,yt=null,Ee=!1,zt=null;function Ef(e,t){var n=Et(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 ru(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,vt=e,yt=vn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,vt=e,yt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Wn!==null?{id:qt,overflow:Xt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Et(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,vt=e,yt=null,!0):!1;default:return!1}}function Eo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function To(e){if(Ee){var t=yt;if(t){var n=t;if(!ru(e,t)){if(Eo(e))throw Error(M(418));t=vn(n.nextSibling);var r=vt;t&&ru(e,t)?Ef(r,n):(e.flags=e.flags&-4097|2,Ee=!1,vt=e)}}else{if(Eo(e))throw Error(M(418));e.flags=e.flags&-4097|2,Ee=!1,vt=e}}}function su(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;vt=e}function Ks(e){if(e!==vt)return!1;if(!Ee)return su(e),Ee=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!ko(e.type,e.memoizedProps)),t&&(t=yt)){if(Eo(e))throw Tf(),Error(M(418));for(;t;)Ef(e,t),t=vn(t.nextSibling)}if(su(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){yt=vn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}yt=null}}else yt=vt?vn(e.stateNode.nextSibling):null;return!0}function Tf(){for(var e=yt;e;)e=vn(e.nextSibling)}function jr(){yt=vt=null,Ee=!1}function kl(e){zt===null?zt=[e]:zt.push(e)}var Lg=an.ReactCurrentBatchConfig;function Or(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 Ys(e,t){throw e=Object.prototype.toString.call(t),Error(M(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function au(e){var t=e._init;return t(e._payload)}function If(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=Sn(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,w){return h===null||h.tag!==6?(h=Ui(y,g.mode,w),h.return=g,h):(h=a(h,y),h.return=g,h)}function c(g,h,y,w){var b=y.type;return b===nr?f(g,h,y.props.children,w,y.key):h!==null&&(h.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===cn&&au(b)===h.type)?(w=a(h,y.props),w.ref=Or(g,h,y),w.return=g,w):(w=ha(y.type,y.key,y.props,null,g.mode,w),w.ref=Or(g,h,y),w.return=g,w)}function d(g,h,y,w){return h===null||h.tag!==4||h.stateNode.containerInfo!==y.containerInfo||h.stateNode.implementation!==y.implementation?(h=Wi(y,g.mode,w),h.return=g,h):(h=a(h,y.children||[]),h.return=g,h)}function f(g,h,y,w,b){return h===null||h.tag!==7?(h=Bn(y,g.mode,w,b),h.return=g,h):(h=a(h,y),h.return=g,h)}function p(g,h,y){if(typeof h=="string"&&h!==""||typeof h=="number")return h=Ui(""+h,g.mode,y),h.return=g,h;if(typeof h=="object"&&h!==null){switch(h.$$typeof){case Ms:return y=ha(h.type,h.key,h.props,null,g.mode,y),y.ref=Or(g,null,h),y.return=g,y;case tr:return h=Wi(h,g.mode,y),h.return=g,h;case cn:var w=h._init;return p(g,w(h._payload),y)}if(Kr(h)||Lr(h))return h=Bn(h,g.mode,y,null),h.return=g,h;Ys(g,h)}return null}function m(g,h,y,w){var b=h!==null?h.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return b!==null?null:l(g,h,""+y,w);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Ms:return y.key===b?c(g,h,y,w):null;case tr:return y.key===b?d(g,h,y,w):null;case cn:return b=y._init,m(g,h,b(y._payload),w)}if(Kr(y)||Lr(y))return b!==null?null:f(g,h,y,w,null);Ys(g,y)}return null}function x(g,h,y,w,b){if(typeof w=="string"&&w!==""||typeof w=="number")return g=g.get(y)||null,l(h,g,""+w,b);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Ms:return g=g.get(w.key===null?y:w.key)||null,c(h,g,w,b);case tr:return g=g.get(w.key===null?y:w.key)||null,d(h,g,w,b);case cn:var C=w._init;return x(g,h,y,C(w._payload),b)}if(Kr(w)||Lr(w))return g=g.get(y)||null,f(h,g,w,b,null);Ys(h,w)}return null}function j(g,h,y,w){for(var b=null,C=null,N=h,A=h=0,E=null;N!==null&&A<y.length;A++){N.index>A?(E=N,N=null):E=N.sibling;var P=m(g,N,y[A],w);if(P===null){N===null&&(N=E);break}e&&N&&P.alternate===null&&t(g,N),h=i(P,h,A),C===null?b=P:C.sibling=P,C=P,N=E}if(A===y.length)return n(g,N),Ee&&Pn(g,A),b;if(N===null){for(;A<y.length;A++)N=p(g,y[A],w),N!==null&&(h=i(N,h,A),C===null?b=N:C.sibling=N,C=N);return Ee&&Pn(g,A),b}for(N=r(g,N);A<y.length;A++)E=x(N,g,A,y[A],w),E!==null&&(e&&E.alternate!==null&&N.delete(E.key===null?A:E.key),h=i(E,h,A),C===null?b=E:C.sibling=E,C=E);return e&&N.forEach(function(O){return t(g,O)}),Ee&&Pn(g,A),b}function v(g,h,y,w){var b=Lr(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,A=h=0,E=null,P=y.next();N!==null&&!P.done;A++,P=y.next()){N.index>A?(E=N,N=null):E=N.sibling;var O=m(g,N,P.value,w);if(O===null){N===null&&(N=E);break}e&&N&&O.alternate===null&&t(g,N),h=i(O,h,A),C===null?b=O:C.sibling=O,C=O,N=E}if(P.done)return n(g,N),Ee&&Pn(g,A),b;if(N===null){for(;!P.done;A++,P=y.next())P=p(g,P.value,w),P!==null&&(h=i(P,h,A),C===null?b=P:C.sibling=P,C=P);return Ee&&Pn(g,A),b}for(N=r(g,N);!P.done;A++,P=y.next())P=x(N,g,A,P.value,w),P!==null&&(e&&P.alternate!==null&&N.delete(P.key===null?A:P.key),h=i(P,h,A),C===null?b=P:C.sibling=P,C=P);return e&&N.forEach(function(L){return t(g,L)}),Ee&&Pn(g,A),b}function S(g,h,y,w){if(typeof y=="object"&&y!==null&&y.type===nr&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Ms:e:{for(var b=y.key,C=h;C!==null;){if(C.key===b){if(b=y.type,b===nr){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===cn&&au(b)===C.type){n(g,C.sibling),h=a(C,y.props),h.ref=Or(g,C,y),h.return=g,g=h;break e}n(g,C);break}else t(g,C);C=C.sibling}y.type===nr?(h=Bn(y.props.children,g.mode,w,y.key),h.return=g,g=h):(w=ha(y.type,y.key,y.props,null,g.mode,w),w.ref=Or(g,h,y),w.return=g,g=w)}return o(g);case tr: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=Wi(y,g.mode,w),h.return=g,g=h}return o(g);case cn:return C=y._init,S(g,h,C(y._payload),w)}if(Kr(y))return j(g,h,y,w);if(Lr(y))return v(g,h,y,w);Ys(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=Ui(y,g.mode,w),h.return=g,g=h),o(g)):n(g,h)}return S}var Sr=If(!0),Rf=If(!1),_a=Cn(null),La=null,ur=null,bl=null;function Nl(){bl=ur=La=null}function Cl(e){var t=_a.current;Ne(_a),e._currentValue=t}function Io(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 yr(e,t){La=e,bl=ur=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ct=!0),e.firstContext=null)}function It(e){var t=e._currentValue;if(bl!==e)if(e={context:e,memoizedValue:t,next:null},ur===null){if(La===null)throw Error(M(308));ur=e,La.dependencies={lanes:0,firstContext:e}}else ur=ur.next=e;return t}var $n=null;function El(e){$n===null?$n=[e]:$n.push(e)}function Af(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,El(t)):(n.next=a.next,a.next=n),t.interleaved=n,nn(e,r)}function nn(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 un=!1;function Tl(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Pf(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 Zt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function xn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ge&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,nn(e,n)}return a=r.interleaved,a===null?(t.next=t,El(r)):(t.next=a.next,a.next=t),r.interleaved=t,nn(e,n)}function ca(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,ml(e,n)}}function iu(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 za(e,t,n,r){var a=e.updateQueue;un=!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 p=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 j=e,v=l;switch(m=t,x=n,v.tag){case 1:if(j=v.payload,typeof j=="function"){p=j.call(x,p,m);break e}p=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=v.payload,m=typeof j=="function"?j.call(x,p,m):j,m==null)break e;p=Ae({},p,m);break e;case 2:un=!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=p):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=p),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);Vn|=o,e.lanes=o,e.memoizedState=p}}function ou(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 Rs={},Kt=Cn(Rs),vs=Cn(Rs),xs=Cn(Rs);function Mn(e){if(e===Rs)throw Error(M(174));return e}function Il(e,t){switch(Se(xs,t),Se(vs,e),Se(Kt,Rs),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:lo(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=lo(t,e)}Ne(Kt),Se(Kt,t)}function kr(){Ne(Kt),Ne(vs),Ne(xs)}function _f(e){Mn(xs.current);var t=Mn(Kt.current),n=lo(t,e.type);t!==n&&(Se(vs,e),Se(Kt,n))}function Rl(e){vs.current===e&&(Ne(Kt),Ne(vs))}var Ie=Cn(0);function $a(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 $i=[];function Al(){for(var e=0;e<$i.length;e++)$i[e]._workInProgressVersionPrimary=null;$i.length=0}var ua=an.ReactCurrentDispatcher,Mi=an.ReactCurrentBatchConfig,Hn=0,Re=null,Oe=null,Ue=null,Ma=!1,ns=!1,ws=0,zg=0;function Je(){throw Error(M(321))}function Pl(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Dt(e[n],t[n]))return!1;return!0}function _l(e,t,n,r,a,i){if(Hn=i,Re=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ua.current=e===null||e.memoizedState===null?Og:Dg,e=n(r,a),ns){i=0;do{if(ns=!1,ws=0,25<=i)throw Error(M(301));i+=1,Ue=Oe=null,t.updateQueue=null,ua.current=Bg,e=n(r,a)}while(ns)}if(ua.current=Fa,t=Oe!==null&&Oe.next!==null,Hn=0,Ue=Oe=Re=null,Ma=!1,t)throw Error(M(300));return e}function Ll(){var e=ws!==0;return ws=0,e}function Ht(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ue===null?Re.memoizedState=Ue=e:Ue=Ue.next=e,Ue}function Rt(){if(Oe===null){var e=Re.alternate;e=e!==null?e.memoizedState:null}else e=Oe.next;var t=Ue===null?Re.memoizedState:Ue.next;if(t!==null)Ue=t,Oe=e;else{if(e===null)throw Error(M(310));Oe=e,e={memoizedState:Oe.memoizedState,baseState:Oe.baseState,baseQueue:Oe.baseQueue,queue:Oe.queue,next:null},Ue===null?Re.memoizedState=Ue=e:Ue=Ue.next=e}return Ue}function js(e,t){return typeof t=="function"?t(e):t}function Fi(e){var t=Rt(),n=t.queue;if(n===null)throw Error(M(311));n.lastRenderedReducer=e;var r=Oe,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((Hn&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 p={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=p,o=r):c=c.next=p,Re.lanes|=f,Vn|=f}d=d.next}while(d!==null&&d!==i);c===null?o=r:c.next=l,Dt(r,t.memoizedState)||(ct=!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,Re.lanes|=i,Vn|=i,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Oi(e){var t=Rt(),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);Dt(i,t.memoizedState)||(ct=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function Lf(){}function zf(e,t){var n=Re,r=Rt(),a=t(),i=!Dt(r.memoizedState,a);if(i&&(r.memoizedState=a,ct=!0),r=r.queue,zl(Ff.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Ue!==null&&Ue.memoizedState.tag&1){if(n.flags|=2048,Ss(9,Mf.bind(null,n,r,a,t),void 0,null),We===null)throw Error(M(349));Hn&30||$f(n,t,a)}return a}function $f(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Re.updateQueue,t===null?(t={lastEffect:null,stores:null},Re.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Mf(e,t,n,r){t.value=n,t.getSnapshot=r,Of(t)&&Df(e)}function Ff(e,t,n){return n(function(){Of(t)&&Df(e)})}function Of(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Dt(e,n)}catch{return!0}}function Df(e){var t=nn(e,1);t!==null&&Ft(t,e,1,-1)}function lu(e){var t=Ht();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:js,lastRenderedState:e},t.queue=e,e=e.dispatch=Fg.bind(null,Re,e),[t.memoizedState,e]}function Ss(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Re.updateQueue,t===null?(t={lastEffect:null,stores:null},Re.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 Bf(){return Rt().memoizedState}function da(e,t,n,r){var a=Ht();Re.flags|=e,a.memoizedState=Ss(1|t,n,void 0,r===void 0?null:r)}function ni(e,t,n,r){var a=Rt();r=r===void 0?null:r;var i=void 0;if(Oe!==null){var o=Oe.memoizedState;if(i=o.destroy,r!==null&&Pl(r,o.deps)){a.memoizedState=Ss(t,n,i,r);return}}Re.flags|=e,a.memoizedState=Ss(1|t,n,i,r)}function cu(e,t){return da(8390656,8,e,t)}function zl(e,t){return ni(2048,8,e,t)}function Uf(e,t){return ni(4,2,e,t)}function Wf(e,t){return ni(4,4,e,t)}function Hf(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 Vf(e,t,n){return n=n!=null?n.concat([e]):null,ni(4,4,Hf.bind(null,t,e),n)}function $l(){}function Gf(e,t){var n=Rt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Pl(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Kf(e,t){var n=Rt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Pl(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Yf(e,t,n){return Hn&21?(Dt(n,t)||(n=Xd(),Re.lanes|=n,Vn|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ct=!0),e.memoizedState=n)}function $g(e,t){var n=we;we=n!==0&&4>n?n:4,e(!0);var r=Mi.transition;Mi.transition={};try{e(!1),t()}finally{we=n,Mi.transition=r}}function Qf(){return Rt().memoizedState}function Mg(e,t,n){var r=jn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Jf(e))qf(t,n);else if(n=Af(e,t,n,r),n!==null){var a=nt();Ft(n,e,r,a),Xf(n,t,r)}}function Fg(e,t,n){var r=jn(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Jf(e))qf(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,Dt(l,o)){var c=t.interleaved;c===null?(a.next=a,El(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=Af(e,t,a,r),n!==null&&(a=nt(),Ft(n,e,r,a),Xf(n,t,r))}}function Jf(e){var t=e.alternate;return e===Re||t!==null&&t===Re}function qf(e,t){ns=Ma=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Xf(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ml(e,n)}}var Fa={readContext:It,useCallback:Je,useContext:Je,useEffect:Je,useImperativeHandle:Je,useInsertionEffect:Je,useLayoutEffect:Je,useMemo:Je,useReducer:Je,useRef:Je,useState:Je,useDebugValue:Je,useDeferredValue:Je,useTransition:Je,useMutableSource:Je,useSyncExternalStore:Je,useId:Je,unstable_isNewReconciler:!1},Og={readContext:It,useCallback:function(e,t){return Ht().memoizedState=[e,t===void 0?null:t],e},useContext:It,useEffect:cu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,da(4194308,4,Hf.bind(null,t,e),n)},useLayoutEffect:function(e,t){return da(4194308,4,e,t)},useInsertionEffect:function(e,t){return da(4,2,e,t)},useMemo:function(e,t){var n=Ht();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ht();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=Mg.bind(null,Re,e),[r.memoizedState,e]},useRef:function(e){var t=Ht();return e={current:e},t.memoizedState=e},useState:lu,useDebugValue:$l,useDeferredValue:function(e){return Ht().memoizedState=e},useTransition:function(){var e=lu(!1),t=e[0];return e=$g.bind(null,e[1]),Ht().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Re,a=Ht();if(Ee){if(n===void 0)throw Error(M(407));n=n()}else{if(n=t(),We===null)throw Error(M(349));Hn&30||$f(r,t,n)}a.memoizedState=n;var i={value:n,getSnapshot:t};return a.queue=i,cu(Ff.bind(null,r,i,e),[e]),r.flags|=2048,Ss(9,Mf.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Ht(),t=We.identifierPrefix;if(Ee){var n=Xt,r=qt;n=(r&~(1<<32-Mt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ws++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=zg++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Dg={readContext:It,useCallback:Gf,useContext:It,useEffect:zl,useImperativeHandle:Vf,useInsertionEffect:Uf,useLayoutEffect:Wf,useMemo:Kf,useReducer:Fi,useRef:Bf,useState:function(){return Fi(js)},useDebugValue:$l,useDeferredValue:function(e){var t=Rt();return Yf(t,Oe.memoizedState,e)},useTransition:function(){var e=Fi(js)[0],t=Rt().memoizedState;return[e,t]},useMutableSource:Lf,useSyncExternalStore:zf,useId:Qf,unstable_isNewReconciler:!1},Bg={readContext:It,useCallback:Gf,useContext:It,useEffect:zl,useImperativeHandle:Vf,useInsertionEffect:Uf,useLayoutEffect:Wf,useMemo:Kf,useReducer:Oi,useRef:Bf,useState:function(){return Oi(js)},useDebugValue:$l,useDeferredValue:function(e){var t=Rt();return Oe===null?t.memoizedState=e:Yf(t,Oe.memoizedState,e)},useTransition:function(){var e=Oi(js)[0],t=Rt().memoizedState;return[e,t]},useMutableSource:Lf,useSyncExternalStore:zf,useId:Qf,unstable_isNewReconciler:!1};function _t(e,t){if(e&&e.defaultProps){t=Ae({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Ro(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ae({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var ri={isMounted:function(e){return(e=e._reactInternals)?Qn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=nt(),a=jn(e),i=Zt(r,a);i.payload=t,n!=null&&(i.callback=n),t=xn(e,i,a),t!==null&&(Ft(t,e,a,r),ca(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=nt(),a=jn(e),i=Zt(r,a);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=xn(e,i,a),t!==null&&(Ft(t,e,a,r),ca(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=nt(),r=jn(e),a=Zt(n,r);a.tag=2,t!=null&&(a.callback=t),t=xn(e,a,r),t!==null&&(Ft(t,e,r,n),ca(t,e,r))}};function uu(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?!ps(n,r)||!ps(a,i):!0}function Zf(e,t,n){var r=!1,a=bn,i=t.contextType;return typeof i=="object"&&i!==null?i=It(i):(a=dt(t)?Un:Ze.current,r=t.contextTypes,i=(r=r!=null)?wr(e,a):bn),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=ri,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=i),t}function du(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&&ri.enqueueReplaceState(t,t.state,null)}function Ao(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},Tl(e);var i=t.contextType;typeof i=="object"&&i!==null?a.context=It(i):(i=dt(t)?Un:Ze.current,a.context=wr(e,i)),a.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Ro(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&&ri.enqueueReplaceState(a,a.state,null),za(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function br(e,t){try{var n="",r=t;do n+=hh(r),r=r.return;while(r);var a=n}catch(i){a=`
|
|
39
|
+
Error generating stack: `+i.message+`
|
|
40
|
+
`+i.stack}return{value:e,source:t,stack:a,digest:null}}function Di(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Po(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Ug=typeof WeakMap=="function"?WeakMap:Map;function em(e,t,n){n=Zt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Da||(Da=!0,Uo=r),Po(e,t)},n}function tm(e,t,n){n=Zt(-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(){Po(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Po(e,t),typeof r!="function"&&(wn===null?wn=new Set([this]):wn.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function fu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ug;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=ny.bind(null,e,t,n),t.then(e,e))}function mu(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 pu(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=Zt(-1,1),t.tag=2,xn(n,t,1))),n.lanes|=1),e)}var Wg=an.ReactCurrentOwner,ct=!1;function tt(e,t,n,r){t.child=e===null?Rf(t,null,n,r):Sr(t,e.child,n,r)}function hu(e,t,n,r,a){n=n.render;var i=t.ref;return yr(t,a),r=_l(e,t,n,r,i,a),n=Ll(),e!==null&&!ct?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,rn(e,t,a)):(Ee&&n&&jl(t),t.flags|=1,tt(e,t,r,a),t.child)}function gu(e,t,n,r,a){if(e===null){var i=n.type;return typeof i=="function"&&!Hl(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,nm(e,t,i,r,a)):(e=ha(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:ps,n(o,r)&&e.ref===t.ref)return rn(e,t,a)}return t.flags|=1,e=Sn(i,r),e.ref=t.ref,e.return=t,t.child=e}function nm(e,t,n,r,a){if(e!==null){var i=e.memoizedProps;if(ps(i,r)&&e.ref===t.ref)if(ct=!1,t.pendingProps=r=i,(e.lanes&a)!==0)e.flags&131072&&(ct=!0);else return t.lanes=e.lanes,rn(e,t,a)}return _o(e,t,n,r,a)}function rm(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},Se(fr,gt),gt|=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,Se(fr,gt),gt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,Se(fr,gt),gt|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,Se(fr,gt),gt|=r;return tt(e,t,a,n),t.child}function sm(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function _o(e,t,n,r,a){var i=dt(n)?Un:Ze.current;return i=wr(t,i),yr(t,a),n=_l(e,t,n,r,i,a),r=Ll(),e!==null&&!ct?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,rn(e,t,a)):(Ee&&r&&jl(t),t.flags|=1,tt(e,t,n,a),t.child)}function yu(e,t,n,r,a){if(dt(n)){var i=!0;Ra(t)}else i=!1;if(yr(t,a),t.stateNode===null)fa(e,t),Zf(t,n,r),Ao(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=It(d):(d=dt(n)?Un:Ze.current,d=wr(t,d));var f=n.getDerivedStateFromProps,p=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function";p||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==r||c!==d)&&du(t,o,r,d),un=!1;var m=t.memoizedState;o.state=m,za(t,r,o,a),c=t.memoizedState,l!==r||m!==c||ut.current||un?(typeof f=="function"&&(Ro(t,n,f,r),c=t.memoizedState),(l=un||uu(t,n,l,r,m,c,d))?(p||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,Pf(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:_t(t.type,l),o.props=d,p=t.pendingProps,m=o.context,c=n.contextType,typeof c=="object"&&c!==null?c=It(c):(c=dt(n)?Un:Ze.current,c=wr(t,c));var x=n.getDerivedStateFromProps;(f=typeof x=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==p||m!==c)&&du(t,o,r,c),un=!1,m=t.memoizedState,o.state=m,za(t,r,o,a);var j=t.memoizedState;l!==p||m!==j||ut.current||un?(typeof x=="function"&&(Ro(t,n,x,r),j=t.memoizedState),(d=un||uu(t,n,d,r,m,j,c)||!1)?(f||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,j,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,j,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=j),o.props=r,o.state=j,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 Lo(e,t,n,r,i,a)}function Lo(e,t,n,r,a,i){sm(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return a&&nu(t,n,!1),rn(e,t,i);r=t.stateNode,Wg.current=t;var l=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Sr(t,e.child,null,i),t.child=Sr(t,null,l,i)):tt(e,t,l,i),t.memoizedState=r.state,a&&nu(t,n,!0),t.child}function am(e){var t=e.stateNode;t.pendingContext?tu(e,t.pendingContext,t.pendingContext!==t.context):t.context&&tu(e,t.context,!1),Il(e,t.containerInfo)}function vu(e,t,n,r,a){return jr(),kl(a),t.flags|=256,tt(e,t,n,r),t.child}var zo={dehydrated:null,treeContext:null,retryLane:0};function $o(e){return{baseLanes:e,cachePool:null,transitions:null}}function im(e,t,n){var r=t.pendingProps,a=Ie.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),Se(Ie,a&1),e===null)return To(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=ii(o,r,0,null),e=Bn(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=$o(n),t.memoizedState=zo,e):Ml(t,o));if(a=e.memoizedState,a!==null&&(l=a.dehydrated,l!==null))return Hg(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=Sn(a,c),r.subtreeFlags=a.subtreeFlags&14680064),l!==null?i=Sn(l,i):(i=Bn(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?$o(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=zo,r}return i=e.child,e=i.sibling,r=Sn(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 Ml(e,t){return t=ii({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Qs(e,t,n,r){return r!==null&&kl(r),Sr(t,e.child,null,n),e=Ml(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Hg(e,t,n,r,a,i,o){if(n)return t.flags&256?(t.flags&=-257,r=Di(Error(M(422))),Qs(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,a=t.mode,r=ii({mode:"visible",children:r.children},a,0,null),i=Bn(i,a,o,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&Sr(t,e.child,null,o),t.child.memoizedState=$o(o),t.memoizedState=zo,i);if(!(t.mode&1))return Qs(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=Di(i,r,void 0),Qs(e,t,o,r)}if(l=(o&e.childLanes)!==0,ct||l){if(r=We,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,nn(e,a),Ft(r,e,a,-1))}return Wl(),r=Di(Error(M(421))),Qs(e,t,o,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=ry.bind(null,e),a._reactRetry=t,null):(e=i.treeContext,yt=vn(a.nextSibling),vt=t,Ee=!0,zt=null,e!==null&&(Nt[Ct++]=qt,Nt[Ct++]=Xt,Nt[Ct++]=Wn,qt=e.id,Xt=e.overflow,Wn=t),t=Ml(t,r.children),t.flags|=4096,t)}function xu(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Io(e.return,t,n)}function Bi(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 om(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;if(tt(e,t,r.children,n),r=Ie.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&&xu(e,n,t);else if(e.tag===19)xu(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(Se(Ie,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&&$a(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Bi(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&&$a(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Bi(t,!0,n,null,i);break;case"together":Bi(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function fa(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function rn(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Vn|=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=Sn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Sn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Vg(e,t,n){switch(t.tag){case 3:am(t),jr();break;case 5:_f(t);break;case 1:dt(t.type)&&Ra(t);break;case 4:Il(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;Se(_a,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Se(Ie,Ie.current&1),t.flags|=128,null):n&t.child.childLanes?im(e,t,n):(Se(Ie,Ie.current&1),e=rn(e,t,n),e!==null?e.sibling:null);Se(Ie,Ie.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return om(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),Se(Ie,Ie.current),r)break;return null;case 22:case 23:return t.lanes=0,rm(e,t,n)}return rn(e,t,n)}var lm,Mo,cm,um;lm=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}};Mo=function(){};cm=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,Mn(Kt.current);var i=null;switch(n){case"input":a=so(e,a),r=so(e,r),i=[];break;case"select":a=Ae({},a,{value:void 0}),r=Ae({},r,{value:void 0}),i=[];break;case"textarea":a=oo(e,a),r=oo(e,r),i=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Ta)}co(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"&&(os.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"&&(os.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&ke("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)}};um=function(e,t,n,r){n!==r&&(t.flags|=4)};function Dr(e,t){if(!Ee)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 qe(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 Gg(e,t,n){var r=t.pendingProps;switch(Sl(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qe(t),null;case 1:return dt(t.type)&&Ia(),qe(t),null;case 3:return r=t.stateNode,kr(),Ne(ut),Ne(Ze),Al(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Ks(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,zt!==null&&(Vo(zt),zt=null))),Mo(e,t),qe(t),null;case 5:Rl(t);var a=Mn(xs.current);if(n=t.type,e!==null&&t.stateNode!=null)cm(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 qe(t),null}if(e=Mn(Kt.current),Ks(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Vt]=t,r[ys]=i,e=(t.mode&1)!==0,n){case"dialog":ke("cancel",r),ke("close",r);break;case"iframe":case"object":case"embed":ke("load",r);break;case"video":case"audio":for(a=0;a<Qr.length;a++)ke(Qr[a],r);break;case"source":ke("error",r);break;case"img":case"image":case"link":ke("error",r),ke("load",r);break;case"details":ke("toggle",r);break;case"input":Tc(r,i),ke("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},ke("invalid",r);break;case"textarea":Rc(r,i),ke("invalid",r)}co(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&&Gs(r.textContent,l,e),a=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&Gs(r.textContent,l,e),a=["children",""+l]):os.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&ke("scroll",r)}switch(n){case"input":Fs(r),Ic(r,i,!0);break;case"textarea":Fs(r),Ac(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Ta)}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=Md(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[Vt]=t,e[ys]=r,lm(e,t,!1,!1),t.stateNode=e;e:{switch(o=uo(n,r),n){case"dialog":ke("cancel",e),ke("close",e),a=r;break;case"iframe":case"object":case"embed":ke("load",e),a=r;break;case"video":case"audio":for(a=0;a<Qr.length;a++)ke(Qr[a],e);a=r;break;case"source":ke("error",e),a=r;break;case"img":case"image":case"link":ke("error",e),ke("load",e),a=r;break;case"details":ke("toggle",e),a=r;break;case"input":Tc(e,r),a=so(e,r),ke("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=Ae({},r,{value:void 0}),ke("invalid",e);break;case"textarea":Rc(e,r),a=oo(e,r),ke("invalid",e);break;default:a=r}co(n,a),l=a;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?Dd(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Fd(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&ls(e,c):typeof c=="number"&&ls(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(os.hasOwnProperty(i)?c!=null&&i==="onScroll"&&ke("scroll",e):c!=null&&ol(e,i,c,o))}switch(n){case"input":Fs(e),Ic(e,r,!1);break;case"textarea":Fs(e),Ac(e);break;case"option":r.value!=null&&e.setAttribute("value",""+kn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?mr(e,!!r.multiple,i,!1):r.defaultValue!=null&&mr(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=Ta)}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 qe(t),null;case 6:if(e&&t.stateNode!=null)um(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(M(166));if(n=Mn(xs.current),Mn(Kt.current),Ks(t)){if(r=t.stateNode,n=t.memoizedProps,r[Vt]=t,(i=r.nodeValue!==n)&&(e=vt,e!==null))switch(e.tag){case 3:Gs(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Gs(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Vt]=t,t.stateNode=r}return qe(t),null;case 13:if(Ne(Ie),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ee&&yt!==null&&t.mode&1&&!(t.flags&128))Tf(),jr(),t.flags|=98560,i=!1;else if(i=Ks(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[Vt]=t}else jr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;qe(t),i=!1}else zt!==null&&(Vo(zt),zt=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||Ie.current&1?Be===0&&(Be=3):Wl())),t.updateQueue!==null&&(t.flags|=4),qe(t),null);case 4:return kr(),Mo(e,t),e===null&&hs(t.stateNode.containerInfo),qe(t),null;case 10:return Cl(t.type._context),qe(t),null;case 17:return dt(t.type)&&Ia(),qe(t),null;case 19:if(Ne(Ie),i=t.memoizedState,i===null)return qe(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)Dr(i,!1);else{if(Be!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=$a(e),o!==null){for(t.flags|=128,Dr(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 Se(Ie,Ie.current&1|2),t.child}e=e.sibling}i.tail!==null&&Le()>Nr&&(t.flags|=128,r=!0,Dr(i,!1),t.lanes=4194304)}else{if(!r)if(e=$a(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Dr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!Ee)return qe(t),null}else 2*Le()-i.renderingStartTime>Nr&&n!==1073741824&&(t.flags|=128,r=!0,Dr(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=Ie.current,Se(Ie,r?n&1|2:n&1),t):(qe(t),null);case 22:case 23:return Ul(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?gt&1073741824&&(qe(t),t.subtreeFlags&6&&(t.flags|=8192)):qe(t),null;case 24:return null;case 25:return null}throw Error(M(156,t.tag))}function Kg(e,t){switch(Sl(t),t.tag){case 1:return dt(t.type)&&Ia(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return kr(),Ne(ut),Ne(Ze),Al(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Rl(t),null;case 13:if(Ne(Ie),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(M(340));jr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ne(Ie),null;case 4:return kr(),null;case 10:return Cl(t.type._context),null;case 22:case 23:return Ul(),null;case 24:return null;default:return null}}var Js=!1,Xe=!1,Yg=typeof WeakSet=="function"?WeakSet:Set,Q=null;function dr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){_e(e,t,r)}else n.current=null}function Fo(e,t,n){try{n()}catch(r){_e(e,t,r)}}var wu=!1;function Qg(e,t){if(jo=Na,e=hf(),wl(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,p=e,m=null;t:for(;;){for(var x;p!==n||a!==0&&p.nodeType!==3||(l=o+a),p!==i||r!==0&&p.nodeType!==3||(c=o+r),p.nodeType===3&&(o+=p.nodeValue.length),(x=p.firstChild)!==null;)m=p,p=x;for(;;){if(p===e)break t;if(m===n&&++d===a&&(l=o),m===i&&++f===r&&(c=o),(x=p.nextSibling)!==null)break;p=m,m=p.parentNode}p=x}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(So={focusedElem:e,selectionRange:n},Na=!1,Q=t;Q!==null;)if(t=Q,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var j=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var v=j.memoizedProps,S=j.memoizedState,g=t.stateNode,h=g.getSnapshotBeforeUpdate(t.elementType===t.type?v:_t(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(w){_e(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return j=wu,wu=!1,j}function rs(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&&Fo(t,n,i)}a=a.next}while(a!==r)}}function si(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 Oo(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 dm(e){var t=e.alternate;t!==null&&(e.alternate=null,dm(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Vt],delete t[ys],delete t[No],delete t[Ag],delete t[Pg])),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 fm(e){return e.tag===5||e.tag===3||e.tag===4}function ju(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||fm(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 Do(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=Ta));else if(r!==4&&(e=e.child,e!==null))for(Do(e,t,n),e=e.sibling;e!==null;)Do(e,t,n),e=e.sibling}function Bo(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(Bo(e,t,n),e=e.sibling;e!==null;)Bo(e,t,n),e=e.sibling}var Ke=null,Lt=!1;function ln(e,t,n){for(n=n.child;n!==null;)mm(e,t,n),n=n.sibling}function mm(e,t,n){if(Gt&&typeof Gt.onCommitFiberUnmount=="function")try{Gt.onCommitFiberUnmount(Ja,n)}catch{}switch(n.tag){case 5:Xe||dr(n,t);case 6:var r=Ke,a=Lt;Ke=null,ln(e,t,n),Ke=r,Lt=a,Ke!==null&&(Lt?(e=Ke,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ke.removeChild(n.stateNode));break;case 18:Ke!==null&&(Lt?(e=Ke,n=n.stateNode,e.nodeType===8?Li(e.parentNode,n):e.nodeType===1&&Li(e,n),fs(e)):Li(Ke,n.stateNode));break;case 4:r=Ke,a=Lt,Ke=n.stateNode.containerInfo,Lt=!0,ln(e,t,n),Ke=r,Lt=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)&&Fo(n,t,o),a=a.next}while(a!==r)}ln(e,t,n);break;case 1:if(!Xe&&(dr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){_e(n,t,l)}ln(e,t,n);break;case 21:ln(e,t,n);break;case 22:n.mode&1?(Xe=(r=Xe)||n.memoizedState!==null,ln(e,t,n),Xe=r):ln(e,t,n);break;default:ln(e,t,n)}}function Su(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Yg),t.forEach(function(r){var a=sy.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function Pt(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:Ke=l.stateNode,Lt=!1;break e;case 3:Ke=l.stateNode.containerInfo,Lt=!0;break e;case 4:Ke=l.stateNode.containerInfo,Lt=!0;break e}l=l.return}if(Ke===null)throw Error(M(160));mm(i,o,a),Ke=null,Lt=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(d){_e(a,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)pm(t,e),t=t.sibling}function pm(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Pt(t,e),Wt(e),r&4){try{rs(3,e,e.return),si(3,e)}catch(v){_e(e,e.return,v)}try{rs(5,e,e.return)}catch(v){_e(e,e.return,v)}}break;case 1:Pt(t,e),Wt(e),r&512&&n!==null&&dr(n,n.return);break;case 5:if(Pt(t,e),Wt(e),r&512&&n!==null&&dr(n,n.return),e.flags&32){var a=e.stateNode;try{ls(a,"")}catch(v){_e(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&&zd(a,i),uo(l,o);var d=uo(l,i);for(o=0;o<c.length;o+=2){var f=c[o],p=c[o+1];f==="style"?Dd(a,p):f==="dangerouslySetInnerHTML"?Fd(a,p):f==="children"?ls(a,p):ol(a,f,p,d)}switch(l){case"input":ao(a,i);break;case"textarea":$d(a,i);break;case"select":var m=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!i.multiple;var x=i.value;x!=null?mr(a,!!i.multiple,x,!1):m!==!!i.multiple&&(i.defaultValue!=null?mr(a,!!i.multiple,i.defaultValue,!0):mr(a,!!i.multiple,i.multiple?[]:"",!1))}a[ys]=i}catch(v){_e(e,e.return,v)}}break;case 6:if(Pt(t,e),Wt(e),r&4){if(e.stateNode===null)throw Error(M(162));a=e.stateNode,i=e.memoizedProps;try{a.nodeValue=i}catch(v){_e(e,e.return,v)}}break;case 3:if(Pt(t,e),Wt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{fs(t.containerInfo)}catch(v){_e(e,e.return,v)}break;case 4:Pt(t,e),Wt(e);break;case 13:Pt(t,e),Wt(e),a=e.child,a.flags&8192&&(i=a.memoizedState!==null,a.stateNode.isHidden=i,!i||a.alternate!==null&&a.alternate.memoizedState!==null||(Dl=Le())),r&4&&Su(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Xe=(d=Xe)||f,Pt(t,e),Xe=d):Pt(t,e),Wt(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(Q=e,f=e.child;f!==null;){for(p=Q=f;Q!==null;){switch(m=Q,x=m.child,m.tag){case 0:case 11:case 14:case 15:rs(4,m,m.return);break;case 1:dr(m,m.return);var j=m.stateNode;if(typeof j.componentWillUnmount=="function"){r=m,n=m.return;try{t=r,j.props=t.memoizedProps,j.state=t.memoizedState,j.componentWillUnmount()}catch(v){_e(r,n,v)}}break;case 5:dr(m,m.return);break;case 22:if(m.memoizedState!==null){bu(p);continue}}x!==null?(x.return=m,Q=x):bu(p)}f=f.sibling}e:for(f=null,p=e;;){if(p.tag===5){if(f===null){f=p;try{a=p.stateNode,d?(i=a.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=p.stateNode,c=p.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=Od("display",o))}catch(v){_e(e,e.return,v)}}}else if(p.tag===6){if(f===null)try{p.stateNode.nodeValue=d?"":p.memoizedProps}catch(v){_e(e,e.return,v)}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===e)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===e)break e;for(;p.sibling===null;){if(p.return===null||p.return===e)break e;f===p&&(f=null),p=p.return}f===p&&(f=null),p.sibling.return=p.return,p=p.sibling}}break;case 19:Pt(t,e),Wt(e),r&4&&Su(e);break;case 21:break;default:Pt(t,e),Wt(e)}}function Wt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(fm(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&&(ls(a,""),r.flags&=-33);var i=ju(e);Bo(e,i,a);break;case 3:case 4:var o=r.stateNode.containerInfo,l=ju(e);Do(e,l,o);break;default:throw Error(M(161))}}catch(c){_e(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Jg(e,t,n){Q=e,hm(e)}function hm(e,t,n){for(var r=(e.mode&1)!==0;Q!==null;){var a=Q,i=a.child;if(a.tag===22&&r){var o=a.memoizedState!==null||Js;if(!o){var l=a.alternate,c=l!==null&&l.memoizedState!==null||Xe;l=Js;var d=Xe;if(Js=o,(Xe=c)&&!d)for(Q=a;Q!==null;)o=Q,c=o.child,o.tag===22&&o.memoizedState!==null?Nu(a):c!==null?(c.return=o,Q=c):Nu(a);for(;i!==null;)Q=i,hm(i),i=i.sibling;Q=a,Js=l,Xe=d}ku(e)}else a.subtreeFlags&8772&&i!==null?(i.return=a,Q=i):ku(e)}}function ku(e){for(;Q!==null;){var t=Q;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Xe||si(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:_t(t.type,n.memoizedProps);r.componentDidUpdate(a,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&ou(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}ou(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 p=f.dehydrated;p!==null&&fs(p)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(M(163))}Xe||t.flags&512&&Oo(t)}catch(m){_e(t,t.return,m)}}if(t===e){Q=null;break}if(n=t.sibling,n!==null){n.return=t.return,Q=n;break}Q=t.return}}function bu(e){for(;Q!==null;){var t=Q;if(t===e){Q=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Q=n;break}Q=t.return}}function Nu(e){for(;Q!==null;){var t=Q;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{si(4,t)}catch(c){_e(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(c){_e(t,a,c)}}var i=t.return;try{Oo(t)}catch(c){_e(t,i,c)}break;case 5:var o=t.return;try{Oo(t)}catch(c){_e(t,o,c)}}}catch(c){_e(t,t.return,c)}if(t===e){Q=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Q=l;break}Q=t.return}}var qg=Math.ceil,Oa=an.ReactCurrentDispatcher,Fl=an.ReactCurrentOwner,Tt=an.ReactCurrentBatchConfig,ge=0,We=null,Me=null,Ye=0,gt=0,fr=Cn(0),Be=0,ks=null,Vn=0,ai=0,Ol=0,ss=null,lt=null,Dl=0,Nr=1/0,Yt=null,Da=!1,Uo=null,wn=null,qs=!1,pn=null,Ba=0,as=0,Wo=null,ma=-1,pa=0;function nt(){return ge&6?Le():ma!==-1?ma:ma=Le()}function jn(e){return e.mode&1?ge&2&&Ye!==0?Ye&-Ye:Lg.transition!==null?(pa===0&&(pa=Xd()),pa):(e=we,e!==0||(e=window.event,e=e===void 0?16:af(e.type)),e):1}function Ft(e,t,n,r){if(50<as)throw as=0,Wo=null,Error(M(185));Es(e,n,r),(!(ge&2)||e!==We)&&(e===We&&(!(ge&2)&&(ai|=n),Be===4&&fn(e,Ye)),ft(e,r),n===1&&ge===0&&!(t.mode&1)&&(Nr=Le()+500,ti&&En()))}function ft(e,t){var n=e.callbackNode;Lh(e,t);var r=ba(e,e===We?Ye:0);if(r===0)n!==null&&Lc(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Lc(n),t===1)e.tag===0?_g(Cu.bind(null,e)):Nf(Cu.bind(null,e)),Ig(function(){!(ge&6)&&En()}),n=null;else{switch(Zd(r)){case 1:n=fl;break;case 4:n=Jd;break;case 16:n=ka;break;case 536870912:n=qd;break;default:n=ka}n=km(n,gm.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function gm(e,t){if(ma=-1,pa=0,ge&6)throw Error(M(327));var n=e.callbackNode;if(vr()&&e.callbackNode!==n)return null;var r=ba(e,e===We?Ye:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Ua(e,r);else{t=r;var a=ge;ge|=2;var i=vm();(We!==e||Ye!==t)&&(Yt=null,Nr=Le()+500,Dn(e,t));do try{ey();break}catch(l){ym(e,l)}while(!0);Nl(),Oa.current=i,ge=a,Me!==null?t=0:(We=null,Ye=0,t=Be)}if(t!==0){if(t===2&&(a=go(e),a!==0&&(r=a,t=Ho(e,a))),t===1)throw n=ks,Dn(e,0),fn(e,r),ft(e,Le()),n;if(t===6)fn(e,r);else{if(a=e.current.alternate,!(r&30)&&!Xg(a)&&(t=Ua(e,r),t===2&&(i=go(e),i!==0&&(r=i,t=Ho(e,i))),t===1))throw n=ks,Dn(e,0),fn(e,r),ft(e,Le()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(M(345));case 2:_n(e,lt,Yt);break;case 3:if(fn(e,r),(r&130023424)===r&&(t=Dl+500-Le(),10<t)){if(ba(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){nt(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=bo(_n.bind(null,e,lt,Yt),t);break}_n(e,lt,Yt);break;case 4:if(fn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var o=31-Mt(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*qg(r/1960))-r,10<r){e.timeoutHandle=bo(_n.bind(null,e,lt,Yt),r);break}_n(e,lt,Yt);break;case 5:_n(e,lt,Yt);break;default:throw Error(M(329))}}}return ft(e,Le()),e.callbackNode===n?gm.bind(null,e):null}function Ho(e,t){var n=ss;return e.current.memoizedState.isDehydrated&&(Dn(e,t).flags|=256),e=Ua(e,t),e!==2&&(t=lt,lt=n,t!==null&&Vo(t)),e}function Vo(e){lt===null?lt=e:lt.push.apply(lt,e)}function Xg(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(!Dt(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 fn(e,t){for(t&=~Ol,t&=~ai,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Mt(t),r=1<<n;e[n]=-1,t&=~r}}function Cu(e){if(ge&6)throw Error(M(327));vr();var t=ba(e,0);if(!(t&1))return ft(e,Le()),null;var n=Ua(e,t);if(e.tag!==0&&n===2){var r=go(e);r!==0&&(t=r,n=Ho(e,r))}if(n===1)throw n=ks,Dn(e,0),fn(e,t),ft(e,Le()),n;if(n===6)throw Error(M(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,_n(e,lt,Yt),ft(e,Le()),null}function Bl(e,t){var n=ge;ge|=1;try{return e(t)}finally{ge=n,ge===0&&(Nr=Le()+500,ti&&En())}}function Gn(e){pn!==null&&pn.tag===0&&!(ge&6)&&vr();var t=ge;ge|=1;var n=Tt.transition,r=we;try{if(Tt.transition=null,we=1,e)return e()}finally{we=r,Tt.transition=n,ge=t,!(ge&6)&&En()}}function Ul(){gt=fr.current,Ne(fr)}function Dn(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Tg(n)),Me!==null)for(n=Me.return;n!==null;){var r=n;switch(Sl(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Ia();break;case 3:kr(),Ne(ut),Ne(Ze),Al();break;case 5:Rl(r);break;case 4:kr();break;case 13:Ne(Ie);break;case 19:Ne(Ie);break;case 10:Cl(r.type._context);break;case 22:case 23:Ul()}n=n.return}if(We=e,Me=e=Sn(e.current,null),Ye=gt=t,Be=0,ks=null,Ol=ai=Vn=0,lt=ss=null,$n!==null){for(t=0;t<$n.length;t++)if(n=$n[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}$n=null}return e}function ym(e,t){do{var n=Me;try{if(Nl(),ua.current=Fa,Ma){for(var r=Re.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}Ma=!1}if(Hn=0,Ue=Oe=Re=null,ns=!1,ws=0,Fl.current=null,n===null||n.return===null){Be=1,ks=t,Me=null;break}e:{var i=e,o=n.return,l=n,c=t;if(t=Ye,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,f=l,p=f.tag;if(!(f.mode&1)&&(p===0||p===11||p===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=mu(o);if(x!==null){x.flags&=-257,pu(x,o,l,i,t),x.mode&1&&fu(i,d,t),t=x,c=d;var j=t.updateQueue;if(j===null){var v=new Set;v.add(c),t.updateQueue=v}else j.add(c);break e}else{if(!(t&1)){fu(i,d,t),Wl();break e}c=Error(M(426))}}else if(Ee&&l.mode&1){var S=mu(o);if(S!==null){!(S.flags&65536)&&(S.flags|=256),pu(S,o,l,i,t),kl(br(c,l));break e}}i=c=br(c,l),Be!==4&&(Be=2),ss===null?ss=[i]:ss.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var g=em(i,c,t);iu(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"&&(wn===null||!wn.has(y)))){i.flags|=65536,t&=-t,i.lanes|=t;var w=tm(i,l,t);iu(i,w);break e}}i=i.return}while(i!==null)}wm(n)}catch(b){t=b,Me===n&&n!==null&&(Me=n=n.return);continue}break}while(!0)}function vm(){var e=Oa.current;return Oa.current=Fa,e===null?Fa:e}function Wl(){(Be===0||Be===3||Be===2)&&(Be=4),We===null||!(Vn&268435455)&&!(ai&268435455)||fn(We,Ye)}function Ua(e,t){var n=ge;ge|=2;var r=vm();(We!==e||Ye!==t)&&(Yt=null,Dn(e,t));do try{Zg();break}catch(a){ym(e,a)}while(!0);if(Nl(),ge=n,Oa.current=r,Me!==null)throw Error(M(261));return We=null,Ye=0,Be}function Zg(){for(;Me!==null;)xm(Me)}function ey(){for(;Me!==null&&!Nh();)xm(Me)}function xm(e){var t=Sm(e.alternate,e,gt);e.memoizedProps=e.pendingProps,t===null?wm(e):Me=t,Fl.current=null}function wm(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=Kg(n,t),n!==null){n.flags&=32767,Me=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Be=6,Me=null;return}}else if(n=Gg(n,t,gt),n!==null){Me=n;return}if(t=t.sibling,t!==null){Me=t;return}Me=t=e}while(t!==null);Be===0&&(Be=5)}function _n(e,t,n){var r=we,a=Tt.transition;try{Tt.transition=null,we=1,ty(e,t,n,r)}finally{Tt.transition=a,we=r}return null}function ty(e,t,n,r){do vr();while(pn!==null);if(ge&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(zh(e,i),e===We&&(Me=We=null,Ye=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||qs||(qs=!0,km(ka,function(){return vr(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=Tt.transition,Tt.transition=null;var o=we;we=1;var l=ge;ge|=4,Fl.current=null,Qg(e,n),pm(n,e),jg(So),Na=!!jo,So=jo=null,e.current=n,Jg(n),Ch(),ge=l,we=o,Tt.transition=i}else e.current=n;if(qs&&(qs=!1,pn=e,Ba=a),i=e.pendingLanes,i===0&&(wn=null),Ih(n.stateNode),ft(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(Da)throw Da=!1,e=Uo,Uo=null,e;return Ba&1&&e.tag!==0&&vr(),i=e.pendingLanes,i&1?e===Wo?as++:(as=0,Wo=e):as=0,En(),null}function vr(){if(pn!==null){var e=Zd(Ba),t=Tt.transition,n=we;try{if(Tt.transition=null,we=16>e?16:e,pn===null)var r=!1;else{if(e=pn,pn=null,Ba=0,ge&6)throw Error(M(331));var a=ge;for(ge|=4,Q=e.current;Q!==null;){var i=Q,o=i.child;if(Q.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Q=d;Q!==null;){var f=Q;switch(f.tag){case 0:case 11:case 15:rs(8,f,i)}var p=f.child;if(p!==null)p.return=f,Q=p;else for(;Q!==null;){f=Q;var m=f.sibling,x=f.return;if(dm(f),f===d){Q=null;break}if(m!==null){m.return=x,Q=m;break}Q=x}}}var j=i.alternate;if(j!==null){var v=j.child;if(v!==null){j.child=null;do{var S=v.sibling;v.sibling=null,v=S}while(v!==null)}}Q=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,Q=o;else e:for(;Q!==null;){if(i=Q,i.flags&2048)switch(i.tag){case 0:case 11:case 15:rs(9,i,i.return)}var g=i.sibling;if(g!==null){g.return=i.return,Q=g;break e}Q=i.return}}var h=e.current;for(Q=h;Q!==null;){o=Q;var y=o.child;if(o.subtreeFlags&2064&&y!==null)y.return=o,Q=y;else e:for(o=h;Q!==null;){if(l=Q,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:si(9,l)}}catch(b){_e(l,l.return,b)}if(l===o){Q=null;break e}var w=l.sibling;if(w!==null){w.return=l.return,Q=w;break e}Q=l.return}}if(ge=a,En(),Gt&&typeof Gt.onPostCommitFiberRoot=="function")try{Gt.onPostCommitFiberRoot(Ja,e)}catch{}r=!0}return r}finally{we=n,Tt.transition=t}}return!1}function Eu(e,t,n){t=br(n,t),t=em(e,t,1),e=xn(e,t,1),t=nt(),e!==null&&(Es(e,1,t),ft(e,t))}function _e(e,t,n){if(e.tag===3)Eu(e,e,n);else for(;t!==null;){if(t.tag===3){Eu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(wn===null||!wn.has(r))){e=br(n,e),e=tm(t,e,1),t=xn(t,e,1),e=nt(),t!==null&&(Es(t,1,e),ft(t,e));break}}t=t.return}}function ny(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=nt(),e.pingedLanes|=e.suspendedLanes&n,We===e&&(Ye&n)===n&&(Be===4||Be===3&&(Ye&130023424)===Ye&&500>Le()-Dl?Dn(e,0):Ol|=n),ft(e,t)}function jm(e,t){t===0&&(e.mode&1?(t=Bs,Bs<<=1,!(Bs&130023424)&&(Bs=4194304)):t=1);var n=nt();e=nn(e,t),e!==null&&(Es(e,t,n),ft(e,n))}function ry(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),jm(e,n)}function sy(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),jm(e,n)}var Sm;Sm=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ut.current)ct=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ct=!1,Vg(e,t,n);ct=!!(e.flags&131072)}else ct=!1,Ee&&t.flags&1048576&&Cf(t,Pa,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;fa(e,t),e=t.pendingProps;var a=wr(t,Ze.current);yr(t,n),a=_l(null,t,r,e,a,n);var i=Ll();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,dt(r)?(i=!0,Ra(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Tl(t),a.updater=ri,t.stateNode=a,a._reactInternals=t,Ao(t,r,e,n),t=Lo(null,t,r,!0,i,n)):(t.tag=0,Ee&&i&&jl(t),tt(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(fa(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=iy(r),e=_t(r,e),a){case 0:t=_o(null,t,r,e,n);break e;case 1:t=yu(null,t,r,e,n);break e;case 11:t=hu(null,t,r,e,n);break e;case 14:t=gu(null,t,r,_t(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:_t(r,a),_o(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:_t(r,a),yu(e,t,r,a,n);case 3:e:{if(am(t),e===null)throw Error(M(387));r=t.pendingProps,i=t.memoizedState,a=i.element,Pf(e,t),za(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=br(Error(M(423)),t),t=vu(e,t,r,n,a);break e}else if(r!==a){a=br(Error(M(424)),t),t=vu(e,t,r,n,a);break e}else for(yt=vn(t.stateNode.containerInfo.firstChild),vt=t,Ee=!0,zt=null,n=Rf(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(jr(),r===a){t=rn(e,t,n);break e}tt(e,t,r,n)}t=t.child}return t;case 5:return _f(t),e===null&&To(t),r=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,o=a.children,ko(r,a)?o=null:i!==null&&ko(r,i)&&(t.flags|=32),sm(e,t),tt(e,t,o,n),t.child;case 6:return e===null&&To(t),null;case 13:return im(e,t,n);case 4:return Il(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Sr(t,null,r,n):tt(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:_t(r,a),hu(e,t,r,a,n);case 7:return tt(e,t,t.pendingProps,n),t.child;case 8:return tt(e,t,t.pendingProps.children,n),t.child;case 12:return tt(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,Se(_a,r._currentValue),r._currentValue=o,i!==null)if(Dt(i.value,o)){if(i.children===a.children&&!ut.current){t=rn(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=Zt(-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),Io(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),Io(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}tt(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,yr(t,n),a=It(a),r=r(a),t.flags|=1,tt(e,t,r,n),t.child;case 14:return r=t.type,a=_t(r,t.pendingProps),a=_t(r.type,a),gu(e,t,r,a,n);case 15:return nm(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:_t(r,a),fa(e,t),t.tag=1,dt(r)?(e=!0,Ra(t)):e=!1,yr(t,n),Zf(t,r,a),Ao(t,r,a,n),Lo(null,t,r,!0,e,n);case 19:return om(e,t,n);case 22:return rm(e,t,n)}throw Error(M(156,t.tag))};function km(e,t){return Qd(e,t)}function ay(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 Et(e,t,n,r){return new ay(e,t,n,r)}function Hl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function iy(e){if(typeof e=="function")return Hl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===cl)return 11;if(e===ul)return 14}return 2}function Sn(e,t){var n=e.alternate;return n===null?(n=Et(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 ha(e,t,n,r,a,i){var o=2;if(r=e,typeof e=="function")Hl(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case nr:return Bn(n.children,a,i,t);case ll:o=8,a|=8;break;case eo:return e=Et(12,n,t,a|2),e.elementType=eo,e.lanes=i,e;case to:return e=Et(13,n,t,a),e.elementType=to,e.lanes=i,e;case no:return e=Et(19,n,t,a),e.elementType=no,e.lanes=i,e;case Pd:return ii(n,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Rd:o=10;break e;case Ad:o=9;break e;case cl:o=11;break e;case ul:o=14;break e;case cn:o=16,r=null;break e}throw Error(M(130,e==null?e:typeof e,""))}return t=Et(o,n,t,a),t.elementType=e,t.type=r,t.lanes=i,t}function Bn(e,t,n,r){return e=Et(7,e,r,t),e.lanes=n,e}function ii(e,t,n,r){return e=Et(22,e,r,t),e.elementType=Pd,e.lanes=n,e.stateNode={isHidden:!1},e}function Ui(e,t,n){return e=Et(6,e,null,t),e.lanes=n,e}function Wi(e,t,n){return t=Et(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function oy(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=ki(0),this.expirationTimes=ki(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ki(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Vl(e,t,n,r,a,i,o,l,c){return e=new oy(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Et(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Tl(i),e}function ly(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:tr,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function bm(e){if(!e)return bn;e=e._reactInternals;e:{if(Qn(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(dt(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(dt(n))return bf(e,n,t)}return t}function Nm(e,t,n,r,a,i,o,l,c){return e=Vl(n,r,!0,e,a,i,o,l,c),e.context=bm(null),n=e.current,r=nt(),a=jn(n),i=Zt(r,a),i.callback=t??null,xn(n,i,a),e.current.lanes=a,Es(e,a,r),ft(e,r),e}function oi(e,t,n,r){var a=t.current,i=nt(),o=jn(a);return n=bm(n),t.context===null?t.context=n:t.pendingContext=n,t=Zt(i,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=xn(a,t,o),e!==null&&(Ft(e,a,o,i),ca(e,a,o)),o}function Wa(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 Tu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Gl(e,t){Tu(e,t),(e=e.alternate)&&Tu(e,t)}function cy(){return null}var Cm=typeof reportError=="function"?reportError:function(e){console.error(e)};function Kl(e){this._internalRoot=e}li.prototype.render=Kl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(M(409));oi(e,t,null,null)};li.prototype.unmount=Kl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Gn(function(){oi(null,e,null,null)}),t[tn]=null}};function li(e){this._internalRoot=e}li.prototype.unstable_scheduleHydration=function(e){if(e){var t=nf();e={blockedOn:null,target:e,priority:t};for(var n=0;n<dn.length&&t!==0&&t<dn[n].priority;n++);dn.splice(n,0,e),n===0&&sf(e)}};function Yl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ci(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Iu(){}function uy(e,t,n,r,a){if(a){if(typeof r=="function"){var i=r;r=function(){var d=Wa(o);i.call(d)}}var o=Nm(t,r,e,0,null,!1,!1,"",Iu);return e._reactRootContainer=o,e[tn]=o.current,hs(e.nodeType===8?e.parentNode:e),Gn(),o}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var l=r;r=function(){var d=Wa(c);l.call(d)}}var c=Vl(e,0,!1,null,null,!1,!1,"",Iu);return e._reactRootContainer=c,e[tn]=c.current,hs(e.nodeType===8?e.parentNode:e),Gn(function(){oi(t,c,n,r)}),c}function ui(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=Wa(o);l.call(c)}}oi(t,o,e,a)}else o=uy(n,t,e,a,r);return Wa(o)}ef=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Yr(t.pendingLanes);n!==0&&(ml(t,n|1),ft(t,Le()),!(ge&6)&&(Nr=Le()+500,En()))}break;case 13:Gn(function(){var r=nn(e,1);if(r!==null){var a=nt();Ft(r,e,1,a)}}),Gl(e,1)}};pl=function(e){if(e.tag===13){var t=nn(e,134217728);if(t!==null){var n=nt();Ft(t,e,134217728,n)}Gl(e,134217728)}};tf=function(e){if(e.tag===13){var t=jn(e),n=nn(e,t);if(n!==null){var r=nt();Ft(n,e,t,r)}Gl(e,t)}};nf=function(){return we};rf=function(e,t){var n=we;try{return we=e,t()}finally{we=n}};mo=function(e,t,n){switch(t){case"input":if(ao(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=ei(r);if(!a)throw Error(M(90));Ld(r),ao(r,a)}}}break;case"textarea":$d(e,n);break;case"select":t=n.value,t!=null&&mr(e,!!n.multiple,t,!1)}};Wd=Bl;Hd=Gn;var dy={usingClientEntryPoint:!1,Events:[Is,ir,ei,Bd,Ud,Bl]},Br={findFiberByHostInstance:zn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},fy={bundleType:Br.bundleType,version:Br.version,rendererPackageName:Br.rendererPackageName,rendererConfig:Br.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:an.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Kd(e),e===null?null:e.stateNode},findFiberByHostInstance:Br.findFiberByHostInstance||cy,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 Xs=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xs.isDisabled&&Xs.supportsFiber)try{Ja=Xs.inject(fy),Gt=Xs}catch{}}wt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=dy;wt.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Yl(t))throw Error(M(200));return ly(e,t,null,n)};wt.createRoot=function(e,t){if(!Yl(e))throw Error(M(299));var n=!1,r="",a=Cm;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=Vl(e,1,!1,null,null,n,!1,r,a),e[tn]=t.current,hs(e.nodeType===8?e.parentNode:e),new Kl(t)};wt.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=Kd(t),e=e===null?null:e.stateNode,e};wt.flushSync=function(e){return Gn(e)};wt.hydrate=function(e,t,n){if(!ci(t))throw Error(M(200));return ui(null,e,t,!0,n)};wt.hydrateRoot=function(e,t,n){if(!Yl(e))throw Error(M(405));var r=n!=null&&n.hydratedSources||null,a=!1,i="",o=Cm;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=Nm(t,null,e,1,n??null,a,!1,i,o),e[tn]=t.current,hs(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 li(t)};wt.render=function(e,t,n){if(!ci(t))throw Error(M(200));return ui(null,e,t,!1,n)};wt.unmountComponentAtNode=function(e){if(!ci(e))throw Error(M(40));return e._reactRootContainer?(Gn(function(){ui(null,null,e,!1,function(){e._reactRootContainer=null,e[tn]=null})}),!0):!1};wt.unstable_batchedUpdates=Bl;wt.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!ci(n))throw Error(M(200));if(e==null||e._reactInternals===void 0)throw Error(M(38));return ui(e,t,n,!1,r)};wt.version="18.3.1-next-f1338f8080-20240426";function Em(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Em)}catch(e){console.error(e)}}Em(),Cd.exports=wt;var Tm=Cd.exports,Im,Ru=Tm;Im=Ru.createRoot,Ru.hydrateRoot;/**
|
|
41
|
+
* react-router v7.18.4
|
|
42
|
+
*
|
|
43
|
+
* Copyright (c) Remix Software Inc.
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the MIT license found in the
|
|
46
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
47
|
+
*
|
|
48
|
+
* @license MIT
|
|
49
|
+
*/var Ql=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Rm=/^[\\/]{2}/;function my(e,t){return t+e.replace(/\\/g,"/")}var Au="popstate";function Pu(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function py(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 Go("",{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:Kn(a)}return gy(t,n,null,e)}function Te(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function At(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function hy(){return Math.random().toString(36).substring(2,10)}function _u(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 Go(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Rr(t):t,state:n,key:t&&t.key||r||hy(),mask:a}}function Kn({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 Rr(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 gy(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 p(){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 h=Pu(S)?S:Go(v.location,S,g);d=f()+1;let y=_u(h,d),w=v.createHref(h.mask||h);try{o.pushState(y,"",w)}catch(b){if(b instanceof DOMException&&b.name==="DataCloneError")throw b;a.location.assign(w)}i&&c&&c({action:l,location:v.location,delta:1})}function x(S,g){l="REPLACE";let h=Pu(S)?S:Go(v.location,S,g);d=f();let y=_u(h,d),w=v.createHref(h.mask||h);o.replaceState(y,"",w),i&&c&&c({action:l,location:v.location,delta:0})}function j(S){return yy(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(Au,p),c=S,()=>{a.removeEventListener(Au,p),c=null}},createHref(S){return t(a,S)},createURL:j,encodeLocation(S){let g=j(S);return{pathname:g.pathname,search:g.search,hash:g.hash}},push:m,replace:x,go(S){return o.go(S)}};return v}function yy(e,t,n=!1){let r="http://localhost";e&&(r=e.location.origin!=="null"?e.location.origin:e.location.href),Te(r,"No window.location.(origin|href) available to create URL");let a=typeof t=="string"?t:Kn(t);return a=a.replace(/ $/,"%20"),!n&&Rm.test(a)&&(a=r+a),new URL(a,r)}function Am(e,t,n="/"){return vy(e,t,n,!1)}function vy(e,t,n,r,a){let i=typeof t=="string"?Rr(t):t,o=sn(i.pathname||"/",n);if(o==null)return null;let l=xy(e),c=null,d=Ry(o);for(let f=0;c==null&&f<l.length;++f)c=Iy(l[f],d,r);return c}function xy(e){let t=Pm(e);return wy(t),t}function Pm(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;Te(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 p=Ot([r,f.relativePath]),m=n.concat(f);o.children&&o.children.length>0&&(Te(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),Pm(o.children,t,m,p,c)),!(o.path==null&&!o.index)&&t.push({path:p,score:Ey(p,o.index),routesMeta:m.map((x,j)=>{let[v,S]=zm(x.relativePath,x.caseSensitive,j===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 _m(o.path))i(o,l,!0,d)}),t}function _m(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=_m(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 wy(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ty(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var jy=/^:[\w-]+$/,Sy=3,ky=2,by=1,Ny=10,Cy=-2,Lu=e=>e==="*";function Ey(e,t){let n=e.split("/"),r=n.length;return n.some(Lu)&&(r+=Cy),t&&(r+=ky),n.filter(a=>!Lu(a)).reduce((a,i)=>a+(jy.test(i)?Sy:i===""?by:Ny),r)}function Ty(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 Iy(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)||"/",p={path:c.relativePath,caseSensitive:c.caseSensitive,end:d},m=c.matcher&&c.compiledParams?Lm(p,f,c.matcher,c.compiledParams):Ha(p,f),x=c.route;if(!m&&d&&n&&!r[r.length-1].route.index&&(m=Ha({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!m)return null;Object.assign(a,m.params),o.push({params:a,pathname:Ot([i,m.pathname]),pathnameBase:_y(Ot([i,m.pathnameBase])),route:x}),m.pathnameBase!=="/"&&(i=Ot([i,m.pathnameBase]))}return o}function Ha(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=zm(e.path,e.caseSensitive,e.end);return Lm(e,t,n,r)}function Lm(e,t,n,r){let a=t.match(n);if(!a)return null;let i=a[0],o=Cr(i,1),l=a.slice(1);return{params:r.reduce((d,{paramName:f,isOptional:p},m)=>{if(f==="*"){let j=l[m]||"";o=Cr(i.slice(0,i.length-j.length),1)}const x=l[m];return p&&!x?d[f]=void 0:d[f]=(x||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:o,pattern:e}}function zm(e,t=!1,n=!0){At(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 p=f.charAt(d+o.length);return p&&p!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}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 Ry(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return At(!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 sn(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"?Rr(e):e,i;return n?(n=$m(n),n.startsWith("/")||n.startsWith("\\")?i=zu(n.substring(1),"/"):i=zu(n,t)):i=t,{pathname:i,search:Ly(r),hash:zy(a)}}function zu(e,t){let n=Cr(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function Hi(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 Py(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Jl(e){let t=Py(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function di(e,t,n,r=!1){let a;typeof e=="string"?a=Rr(e):(a={...e},Te(!a.pathname||!a.pathname.includes("?"),Hi("?","pathname","search",a)),Te(!a.pathname||!a.pathname.includes("#"),Hi("#","pathname","hash",a)),Te(!a.search||!a.search.includes("#"),Hi("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=n;else{let p=t.length-1;if(!r&&o.startsWith("..")){let m=o.split("/");for(;m[0]==="..";)m.shift(),p-=1;a.pathname=m.join("/")}l=p>=0?t[p]:"/"}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 $m=e=>e.replace(/[\\/]{2,}/g,"/"),Ot=e=>$m(e.join("/"));function Cr(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 _y=e=>Cr(e).replace(/^\/*/,"/"),Ly=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,zy=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,$y=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 My(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 Ot(t)||"/"}var Mm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Fm(e,t){let n=e;if(typeof n!="string"||!Ql.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(Mm)try{let i=new URL(window.location.href),o=Rm.test(n)?new URL(my(n,i.protocol)):new URL(n),l=sn(o.pathname,t);o.origin===i.origin&&l!=null?n=l+o.search+o.hash:a=!0}catch{At(!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 $u=new URL("http://localhost");function ql(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),$u)}catch{return $u}}function Vi(e,t){return e.origin===t.origin&&(e.origin!=="null"||e.protocol===t.protocol&&e.host===t.host)}function Oy(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 Xl(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&&!Vi(a,n),l=!Vi(i,n);if(r==="reject"){if(o||l)throw new Error("External navigation is not allowed")}else if(l&&(a==null||!Oy(e,a)||!Vi(a,i)))throw new Error("External navigation is not allowed")}var Om=["POST","PUT","PATCH","DELETE"];new Set(Om);var Dy=["GET",...Om];new Set(Dy);var By=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Uy(e){try{return By.includes(new URL(e).protocol)}catch{return!1}}var Ar=u.createContext(null);Ar.displayName="DataRouter";var fi=u.createContext(null);fi.displayName="DataRouterState";var Dm=u.createContext(!1);function Wy(){return u.useContext(Dm)}var Bm=u.createContext({isTransitioning:!1});Bm.displayName="ViewTransition";var Hy=u.createContext(new Map);Hy.displayName="Fetchers";var Vy=u.createContext(null);Vy.displayName="Await";var St=u.createContext(null);St.displayName="Navigation";var As=u.createContext(null);As.displayName="Location";var Bt=u.createContext({outlet:null,matches:[],isDataRoute:!1});Bt.displayName="Route";var Zl=u.createContext(null);Zl.displayName="RouteError";var Um="REACT_ROUTER_ERROR",Gy="REDIRECT",Ky="ROUTE_ERROR_RESPONSE";function Yy(e){if(e.startsWith(`${Um}:${Gy}:{`))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 Qy(e){if(e.startsWith(`${Um}:${Ky}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new $y(t.status,t.statusText,t.data)}catch{}}function Jy(e,{relative:t}={}){Te(Pr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=u.useContext(St),{hash:a,pathname:i,search:o}=Ps(e,{relative:t}),l=i;return n!=="/"&&(l=i==="/"?n:Ot([n,i])),r.createHref({pathname:l,search:o,hash:a})}function Pr(){return u.useContext(As)!=null}function mt(){return Te(Pr(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(As).location}var Wm="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Hm(e){u.useContext(St).static||u.useLayoutEffect(e)}function on(){let{isDataRoute:e}=u.useContext(Bt);return e?dv():qy()}function qy(){Te(Pr(),"useNavigate() may be used only in the context of a <Router> component.");let e=u.useContext(Ar),{basename:t,navigator:n}=u.useContext(St),{matches:r}=u.useContext(Bt),{pathname:a}=mt(),i=JSON.stringify(Jl(r)),o=u.useRef(!1);return Hm(()=>{o.current=!0}),u.useCallback((c,d={})=>{if(At(o.current,Wm),!o.current)return;if(typeof c=="number"){n.go(c);return}let f=di(c,JSON.parse(i),a,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Ot([t,f.pathname])),Xl(typeof c=="string"?c:Kn(c),n.createHref(f),ql(n),"reject"),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,i,a,e])}var Xy=u.createContext(null);function Zy(e){let t=u.useContext(Bt).outlet;return u.useMemo(()=>t&&u.createElement(Xy.Provider,{value:e},t),[t,e])}function Ps(e,{relative:t}={}){let{matches:n}=u.useContext(Bt),{pathname:r}=mt(),a=JSON.stringify(Jl(n));return u.useMemo(()=>di(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function ev(e,t){return Vm(e,t)}function Vm(e,t,n){var S;Te(Pr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=u.useContext(St),{matches:a}=u.useContext(Bt),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||"";Km(l,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${g}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
50
|
+
|
|
51
|
+
Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let f=mt(),p;if(t){let g=typeof t=="string"?Rr(t):t;Te(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.`),p=g}else p=f;let m=p.pathname||"/",x=m;if(c!=="/"){let g=c.replace(/^\//,"").split("/");x="/"+m.replace(/^\//,"").split("/").slice(g.length).join("/")}let j=n&&n.state.matches.length?n.state.matches.map(g=>Object.assign(g,{route:n.manifest[g.route.id]||g.route})):Am(e,{pathname:x});At(d||j!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),At(j==null||j[j.length-1].route.element!==void 0||j[j.length-1].route.Component!==void 0||j[j.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.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=av(j&&j.map(g=>Object.assign({},g,{params:Object.assign({},o,g.params),pathname:Ot([c,r.encodeLocation?r.encodeLocation(g.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:Ot([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(As.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...p},navigationType:"POP"}},v):v}function tv(){let e=uv(),t=My(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 nv=u.createElement(tv,null),Gm=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=Qy(e.digest);n&&(e=n)}let t=e!==void 0?u.createElement(Bt.Provider,{value:this.props.routeContext},u.createElement(Zl.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?u.createElement(rv,{error:e},t):t}};Gm.contextType=Dm;var Gi=new WeakMap;function rv({children:e,error:t}){let{basename:n,navigator:r}=u.useContext(St);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let a=Yy(t.digest);if(a){let i=Gi.get(t);if(i)throw i;let o=Fm(a.location,n),l=o.absoluteURL||o.to;if(Xl(a.location,l,ql(r),"allow-explicit"),Uy(l))throw new Error("Invalid redirect location");if(Mm&&!Gi.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 Gi.set(t,c),c}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${l}`})}}return e}function sv({routeContext:e,match:t,children:n}){let r=u.useContext(Ar);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),u.createElement(Bt.Provider,{value:e},n)}function av(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(p=>p.route.id&&(i==null?void 0:i[p.route.id])!==void 0);Te(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 p=a[f];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(l=f),p.route.id){let{loaderData:m,errors:x}=r,j=p.route.loader&&!m.hasOwnProperty(p.route.id)&&(!x||x[p.route.id]===void 0);if(p.route.lazy||j){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,p)=>{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:p})}:void 0;return a.reduceRight((f,p,m)=>{let x,j=!1,v=null,S=null;r&&(x=i&&p.route.id?i[p.route.id]:void 0,v=p.route.errorElement||nv,o&&(l<0&&m===0?(Km("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),j=!0,S=null):l===m&&(j=!0,S=p.route.hydrateFallbackElement||null)));let g=t.concat(a.slice(0,m+1)),h=()=>{let y;return x?y=v:j?y=S:p.route.Component?y=u.createElement(p.route.Component,null):p.route.element?y=p.route.element:y=f,u.createElement(sv,{match:p,routeContext:{outlet:f,matches:g,isDataRoute:r!=null},children:y})};return r&&(p.route.ErrorBoundary||p.route.errorElement||m===0)?u.createElement(Gm,{location:r.location,revalidation:r.revalidation,component:v,error:x,children:h(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:d}):h()},null)}function ec(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function iv(e){let t=u.useContext(Ar);return Te(t,ec(e)),t}function ov(e){let t=u.useContext(fi);return Te(t,ec(e)),t}function lv(e){let t=u.useContext(Bt);return Te(t,ec(e)),t}function tc(e){let t=lv(e),n=t.matches[t.matches.length-1];return Te(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function cv(){return tc("useRouteId")}function uv(){var r;let e=u.useContext(Zl),t=ov("useRouteError"),n=tc("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function dv(){let{router:e}=iv("useNavigate"),t=tc("useNavigate"),n=u.useRef(!1);return Hm(()=>{n.current=!0}),u.useCallback(async(a,i={})=>{At(n.current,Wm),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var Mu={};function Km(e,t,n){!t&&!Mu[e]&&(Mu[e]=!0,At(!1,n))}u.memo(fv);function fv({routes:e,manifest:t,future:n,state:r,isStatic:a,onError:i}){return Vm(e,void 0,{manifest:t,state:r,isStatic:a,onError:i})}function Jt({to:e,replace:t,state:n,relative:r}){Te(Pr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a,navigator:i}=u.useContext(St);At(!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(Bt),{pathname:l}=mt(),c=on(),d=di(e,Jl(o),l,r==="path");Xl(typeof e=="string"?e:Kn(e),i.createHref(d),ql(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 mv(e){return Zy(e.context)}function be(e){Te(!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 pv({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:i=!1,useTransitions:o}){Te(!Pr(),"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=Rr(n));let{pathname:d="/",search:f="",hash:p="",state:m=null,key:x="default",mask:j}=n,v=u.useMemo(()=>{let S=sn(d,l);return S==null?null:{location:{pathname:S,search:f,hash:p,state:m,key:x,mask:j},navigationType:r}},[l,d,f,p,m,x,r,j]);return At(v!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${p}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:u.createElement(St.Provider,{value:c},u.createElement(As.Provider,{children:t,value:v}))}function hv({children:e,location:t}){return ev(Ko(e),t)}function Ko(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,Ko(r.props.children,i));return}Te(r.type===be,`[${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>`),Te(!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=Ko(r.props.children,i)),n.push(o)}),n}var ga="get",ya="application/x-www-form-urlencoded";function mi(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function gv(e){return mi(e)&&e.tagName.toLowerCase()==="button"}function yv(e){return mi(e)&&e.tagName.toLowerCase()==="form"}function vv(e){return mi(e)&&e.tagName.toLowerCase()==="input"}function xv(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function wv(e,t){return e.button===0&&(!t||t==="_self")&&!xv(e)}function Yo(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 jv(e,t){let n=Yo(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}var Zs=null;function Sv(){if(Zs===null)try{new FormData(document.createElement("form"),0),Zs=!1}catch{Zs=!0}return Zs}var kv=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ki(e){return e!=null&&!kv.has(e)?(At(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ya}"`),null):e}function bv(e,t){let n,r,a,i,o;if(yv(e)){let l=e.getAttribute("action");r=l?sn(l,t):null,n=e.getAttribute("method")||ga,a=Ki(e.getAttribute("enctype"))||ya,i=new FormData(e)}else if(gv(e)||vv(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?sn(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||ga,a=Ki(e.getAttribute("formenctype"))||Ki(l.getAttribute("enctype"))||ya,i=new FormData(l,e),!Sv()){let{name:d,type:f,value:p}=e;if(f==="image"){let m=d?`${d}.`:"";i.append(`${m}x`,"0"),i.append(`${m}y`,"0")}else d&&i.append(d,p)}}else{if(mi(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=ga,r=null,a=ya,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 nc(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ym(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&&sn(a.pathname,t)==="/"?a.pathname=`${Cr(t)}/_root.${r}`:a.pathname=`${Cr(a.pathname)}.${r}`,a}async function Nv(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 Cv(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 Ev(e,t,n){let r=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await Nv(i,n);return o.links?o.links():[]}return[]}));return Av(r.flat(1).filter(Cv).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function Fu(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 p;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:((p=n[0])==null?void 0:p.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function Tv(e,t,{includeHydrateFallback:n}={}){return Iv(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 Iv(e){return[...new Set(e)]}function Rv(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(Rv(a));return n.has(i)||(n.add(i),r.push({key:i,link:a})),r},[])}function rc(){let e=u.useContext(Ar);return nc(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Pv(){let e=u.useContext(fi);return nc(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var sc=u.createContext(void 0);sc.displayName="FrameworkContext";function pi(){let e=u.useContext(sc);return nc(e,"You must render this element inside a <HydratedRouter> element"),e}function _v(e,t){let n=u.useContext(sc),[r,a]=u.useState(!1),[i,o]=u.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:p}=t,m=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 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)},j=()=>{a(!1),o(!1)};return n?e!=="intent"?[i,m,{}]:[i,m,{onFocus:Ur(l,x),onBlur:Ur(c,j),onMouseEnter:Ur(d,x),onMouseLeave:Ur(f,j),onTouchStart:Ur(p,x)}]:[!1,m,{}]}function Ur(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Lv({page:e,...t}){let n=Wy(),{nonce:r}=pi(),{router:a}=rc(),i=u.useMemo(()=>Am(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&r&&(t={...t,nonce:r}),n?u.createElement($v,{page:e,matches:i,...t}):u.createElement(Mv,{page:e,matches:i,...t})):null}function zv(e){let{manifest:t,routeModules:n}=pi(),[r,a]=u.useState([]);return u.useEffect(()=>{let i=!1;return Ev(e,t,n).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,n]),r}function $v({page:e,matches:t,...n}){let r=mt(),{future:a}=pi(),{basename:i}=rc(),o=u.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let l=Ym(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 Mv({page:e,matches:t,...n}){let r=mt(),{future:a,manifest:i,routeModules:o}=pi(),{basename:l}=rc(),{loaderData:c,matches:d}=Pv(),f=u.useMemo(()=>Fu(e,t,d,i,r,"data"),[e,t,d,i,r]),p=u.useMemo(()=>Fu(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(h=>{var w;let y=i.routes[h.route.id];!y||!y.hasLoader||(!f.some(b=>b.route.id===h.route.id)&&h.route.id in c&&((w=o[h.route.id])!=null&&w.shouldRevalidate)||y.hasClientLoader?S=!0:v.add(h.route.id))}),v.size===0)return[];let g=Ym(e,l,a.v8_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.v8_trailingSlashAwareDataRequests,c,r,i,f,t,e,o]),x=u.useMemo(()=>Tv(p,i),[p,i]),j=zv(p);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})),j.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 Ov=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Ov&&(window.__reactRouterVersion="7.18.4")}catch{}function Dv({basename:e,children:t,useTransitions:n,window:r}){let a=u.useRef();a.current==null&&(a.current=py({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(pv,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:i,useTransitions:n})}var De=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:p,viewTransition:m,defaultShouldRevalidate:x,...j},v){let{basename:S,navigator:g,useTransitions:h}=u.useContext(St),y=typeof f=="string"&&Ql.test(f),w=Fm(f,S);f=w.to;let b=Jy(f,{relative:a}),C=mt(),N=null;if(l){let q=di(l,[],C.mask?C.mask.pathname:"/",!0);S!=="/"&&(q.pathname=q.pathname==="/"?S:Ot([S,q.pathname])),N=g.createHref(q)}let[A,E,P]=_v(r,j),O=Wv(f,{replace:o,mask:l,state:c,target:d,preventScrollReset:p,relative:a,viewTransition:m,defaultShouldRevalidate:x,useTransitions:h});function L(q){t&&t(q),q.defaultPrevented||O(q)}let Z=!(w.isExternal||i),F=u.createElement("a",{...j,...P,href:(Z?N:void 0)||w.absoluteURL||b,onClick:Z?L:t,ref:Fv(v,E),target:d,"data-discover":!y&&n==="render"?"true":void 0});return A&&!y?u.createElement(u.Fragment,null,F,u.createElement(Lv,{page:b})):F});De.displayName="Link";var ac=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 p=Ps(o,{relative:d.relative}),m=mt(),x=u.useContext(fi),{navigator:j,basename:v}=u.useContext(St),S=x!=null&&Yv(p)&&l===!0,g=j.encodeLocation?j.encodeLocation(p).pathname:p.pathname,h=m.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=sn(y,v)||y);const w=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let b=h===g||!a&&h.startsWith(g)&&h.charAt(w)==="/",C=y!=null&&(y===g||!a&&y.startsWith(g)&&y.charAt(g.length)==="/"),N={isActive:b,isPending:C,isTransitioning:S},A=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 P=typeof i=="function"?i(N):i;return u.createElement(De,{...d,"aria-current":A,className:E,ref:f,style:P,to:o,viewTransition:l},typeof c=="function"?c(N):c)});ac.displayName="NavLink";var Bv=u.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:i,method:o=ga,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...x},j)=>{let{useTransitions:v}=u.useContext(St),S=Gv(),g=Kv(l,{relative:d}),h=o.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&Ql.test(l),w=b=>{if(c&&c(b),b.defaultPrevented)return;b.preventDefault();let C=b.nativeEvent.submitter,N=(C==null?void 0:C.getAttribute("formmethod"))||o,A=()=>S(C||b.currentTarget,{fetcherKey:t,method:N,navigate:n,replace:a,state:i,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m});v&&n!==!1?u.startTransition(()=>A()):A()};return u.createElement("form",{ref:j,method:h,action:g,onSubmit:r?c:w,...x,"data-discover":!y&&e==="render"?"true":void 0})});Bv.displayName="Form";function Uv(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Qm(e){let t=u.useContext(Ar);return Te(t,Uv(e)),t}function Wv(e,{target:t,replace:n,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let f=on(),p=mt(),m=Ps(e,{relative:o});return u.useCallback(x=>{if(wv(x,t)){x.preventDefault();let j=n!==void 0?n:Kn(p)===Kn(m),v=()=>f(e,{replace:j,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});d?u.startTransition(()=>v()):v()}},[p,f,m,n,r,a,t,e,i,o,l,c,d])}function ic(e){At(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(Yo(e)),n=u.useRef(!1),r=mt(),a=u.useMemo(()=>jv(r.search,n.current?null:t.current),[r.search]),i=on(),o=u.useCallback((l,c)=>{const d=Yo(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,i("?"+d,c)},[i,a]);return[a,o]}var Hv=0,Vv=()=>`__${String(++Hv)}__`;function Gv(){let{router:e}=Qm("useSubmit"),{basename:t}=u.useContext(St),n=cv(),r=e.fetch,a=e.navigate;return u.useCallback(async(i,o={})=>{let{action:l,method:c,encType:d,formData:f,body:p}=bv(i,t);if(o.navigate===!1){let m=o.fetcherKey||Vv();await r(m,n,o.action||l,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:f,body:p,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:p,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 Kv(e,{relative:t}={}){let{basename:n}=u.useContext(St),r=u.useContext(Bt);Te(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),i={...Ps(e||".",{relative:t})},o=mt();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(p=>p).forEach(p=>l.append("index",p));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:Ot([n,i.pathname])),Kn(i)}function Yv(e,{relative:t}={}){let n=u.useContext(Bm);Te(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Qm("useViewTransitionState"),a=Ps(e,{relative:t});if(!n.isTransitioning)return!1;let i=sn(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=sn(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ha(a.pathname,o)!=null||Ha(a.pathname,i)!=null}const Fn="owner";function Qv(e){const t=e||Fn;return t===Fn?[Fn]:[t,Fn]}function Jv(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 qv(e,t){const n=t||Fn,r=(e==null?void 0:e.pendingDomains)??[];return r.includes(n)?n:r.includes(Fn)?Fn:n}class Jm extends Error{constructor(n){super("different_account");_r(this,"summary");this.name="DifferentAccountError",this.summary=n}}function xe(e,t){const n=e??{},r=Array.isArray(n.errors)?n.errors[0]:void 0;return r!=null&&r.message?r.code?`${r.message} (${r.code})`:r.message:r!=null&&r.code?r.code:n.error||n.detail||t}function Xv(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 Zv{constructor(){_r(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 Jm(i.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!r.ok){const i=await r.json().catch(()=>({error:"Invalid API key"}));throw new Error(xe(i,`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/mandate",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(xe(r,`Signing failed: ${n.status}`))}return n.json()}async getPending(t){const n=await this.fetch(`/api/mandates/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/mandates/mine${n}`);if(!r.ok)throw new Error(`Failed to fetch attestations: ${r.status}`);return((await r.json()).mandates??[]).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/tickets/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);return(await a.json()).tickets??[]}async fetchEvidenceBundle(){var a;const t=await this.fetch("/api/evidence-export"),n=await t.json();if(!t.ok)throw new Error(xe(n,`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(xe(n,`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(xe(r,`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(xe(n,`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(xe(i,`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(xe(a,`Revoke failed: ${r.status}`))}}async getAttestations(t){const n=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch attestations: ${n.status}`);const r=await n.json();return{...r,attestations:r.mandates??r.attestations??[]}}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(xe(i,`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(xe(i,`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(xe(r,`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(xe(r,`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(xe(r,`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)});if(!n.ok){const r=await n.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:xe(r,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return n.json()}async aiIntentReview(t){const n=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:xe(r,"AI request failed")}}return n.json()}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 getAgentContact(){const t=await this.fetch("/mcp/agent-contact");if(!t.ok)throw new Error(`Failed to fetch agent contact: ${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(xe(a,`Discovery failed: ${r.status}`))}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(xe(r,`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(xe(a,`HTTP ${r.status}`))}}async getTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`);if(r.status===404||!r.ok)return null;const a=await r.json();return(a==null?void 0:a.config)??null}async setTeamProfileConfig(t,n,r){const a=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(xe(i,`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(xe(a,`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?Xv(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(xe(a,`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(Qv(t).map(r=>this.getProposals(r)));return Jv(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(xe(i,`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(xe(r,`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(xe(a,`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(xe(a,`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(xe(a,`storeApprovedIntent failed: ${r.status}`))}}async listTeamAuthorizations(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/mandates`);if(!n.ok)throw new Error(`Failed to fetch team authorizations: ${n.status}`);return((await n.json()).mandates??[]).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.mandates)!=null&&l.length?new Date(Math.min(...a.mandates.map(d=>d.expiresAt))*1e3).toISOString():null,remaining_seconds:(c=a.mandates)!=null&&c.length?Math.max(0,Math.min(...a.mandates.map(d=>d.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:i}})}async listTeamReceipts(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/tickets`);if(!n.ok)throw new Error(`Failed to fetch team receipts: ${n.status}`);return(await n.json()).tickets??[]}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/tickets/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);const i=await a.json();return{receipts:i.tickets??[],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)}/tickets${a?"?"+a:""}`);if(!i.ok)throw new Error(`Failed to fetch team receipts: ${i.status}`);const o=await i.json();return{receipts:o.tickets??[],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(xe(r,`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(xe(r,`Save failed: ${n.status}`))}}async aiChat(t){const n=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:xe(r,`Chat failed: ${n.status}`)}}return n.json()}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(xe(a,`Save failed: ${r.status}`))}}}const T=new Zv,qm=u.createContext(null);function ex({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),[p,m]=u.useState(null),[x,j]=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:P,membership:O}=E;f(P),m(O),a("team"),o(P);const L=h.current??O.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 P;((P=E.session)==null?void 0:P.lockedReason)==="as-url-changed"&&S(`Authority Server changed to ${E.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const w=u.useCallback(async(E,P={})=>{j(!0),S("");try{T.setApiKey(E),g.current=!0;const O=await T.login(E,P);n(O),h.current=O.id;const L=await T.getGroups(),Z=L.find(F=>F.isPersonal)??L[0]??null;o(Z),c("owner"),await y()}catch(O){throw T.clearApiKey(),g.current=!1,S(O instanceof Error?O.message:"Login failed"),O}finally{j(!1)}},[y]),b=u.useCallback(async()=>{await T.logout(),T.clearApiKey(),g.current=!1,h.current=null,n(null),o(null),c(""),f(null),m(null),a("personal"),S("")},[]),C=u.useCallback(E=>{T.clearApiKey(),g.current=!1,h.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(""),[]),A=u.useCallback((E,P)=>{o(E),c(P)},[]);return s.jsx(qm.Provider,{value:{user:t,mode:r,group:i,domain:l,groupId:(i==null?void 0:i.id)??null,activeTeam:d,activeMembership:p,isLoading:x,error:v,login:w,logout:b,clearError:N,handleSessionLocked:C,activeGroup:i,activeDomain:l,groups:i?[i]:[],setActiveContext:A,refreshGroups:y},children:e})}function He(){const e=u.useContext(qm);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Xm=u.createContext(null);function tx({children:e}){const{user:t}=He(),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,p=>{let m;try{m=JSON.parse(p.data)}catch{m=null}const x=i.current.get(f);if(x)for(const j of x)try{j(m)}catch(v){console.error(`[EventSource] handler for "${f}" threw:`,v)}});return()=>{c.close(),n.current=null,a(!1)}},[t]),s.jsx(Xm.Provider,{value:{connected:r,addListener:o},children:e})}function ve(e,t){const n=u.useContext(Xm);if(!n)return;const{addListener:r}=n;u.useEffect(()=>r(e,t),[e,t,r])}const is="suveren-theme",Ou="hap-theme";function ea(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(Ou);t!==null&&localStorage.getItem(is)===null&&localStorage.setItem(is,t),t!==null&&localStorage.removeItem(Ou)})();function Zm(){const[e,t]=u.useState(()=>{const i=localStorage.getItem(is);return i==="light"||i==="dark"?i:"system"}),[n,r]=u.useState(()=>ea(e));u.useEffect(()=>{const i=document.documentElement,o=ea(e);i.setAttribute("data-theme",o),e==="system"?localStorage.removeItem(is):localStorage.setItem(is,e),r(ea(e))},[e]),u.useEffect(()=>{if(e!=="system")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>r(ea("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 nx=5*60*1e3,rx=2e3;function oc(){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,p]=u.useState(!1),[m,x]=u.useState(!1),j=u.useRef(null);return u.useEffect(()=>{let v=!1;const S=(y=!1)=>{fetch(y?"/health?refresh=1":"/health").then(w=>w.json()).then(w=>{v||(w.installMethod&&r(w.installMethod),typeof w.latestVersion<"u"&&l(w.latestVersion),w.updateAvailable&&t(!0),w.version&&(i(w.version),j.current===null?j.current=w.version:w.version!==j.current&&w.version!=="dev"&&d(!0)))}).catch(()=>{})};S(!0);const g=setInterval(()=>S(!1),m?rx:nx),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)}},[m]),{updateAvailable:e&&!f,installMethod:n,version:a,latestVersion:o,serverRestarted:c,startFastPolling:()=>x(!0),dismiss:()=>p(!0)}}function sx({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 ax(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Du={system:"◑",light:"☀",dark:"☾"};function lc({onMenuToggle:e}){const{user:t,logout:n}=He(),{theme:r,toggle:a}=Zm(),{version:i,updateAvailable:o,latestVersion:l}=oc(),c=ax(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(sx,{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:Du[r]}),s.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):s.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:Du[r]})}),t&&e&&s.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function cc(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 ep(e){return e==="expired"||e==="revoked"}function tp(e,t){var n;return!!((n=t==null?void 0:t.archivedSet)!=null&&n.has(e.authorization_id))&&ep(cc(e,t))}function Va(e,t){return tp(e,t)?"archived":cc(e,t)}function np(e,t){const n={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const r of e)n[Va(r,t)].push(r);return n}function ix(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 $t(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])}function uc(){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 ox(e,t){const n=e.simulation;return n?(((t==null?void 0:t[n.field])??"").trim().toLowerCase()||n.default.trim().toLowerCase())==="simulation":!1}function bs(e){return!!(e!=null&&e.simulation)}const rp=u.createContext(null),lx=3e4,cx=5e3,ux=3e5;function dx(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 fx({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 f=!1;const[p,m]=await Promise.all([T.getIntegrationManifests().catch(()=>(f=!0,{manifests:[]})),T.getMcpHealth().catch(()=>null)]);n(j=>({...j,manifests:p.manifests,integrations:(m==null?void 0:m.integrations)??j.integrations,activeSessions:(m==null?void 0:m.activeSessions)??j.activeSessions,mcpServerUp:!!m,manifestsError:f,fetchCount:j.fetchCount+1}));const x=p.manifests.filter(j=>j.oauth);if(x.length>0){const j=await Promise.all(x.map(async v=>[v.id,await T.getOAuthHealth(v.id)]));n(v=>({...v,authHealth:Object.fromEntries(j)}))}},[]),i=t.fetchCount>0&&t.manifests.some(f=>{const p=t.integrations.find(m=>m.id===f.id);return p&&!p.running&&!p.paused});ve("integration-changed",a),$t(a,i?cx:ux);const o=u.useMemo(()=>{const f=new Map(t.integrations.map(x=>[x.id,x])),p=Date.now();i&&r.current===null?r.current=p:i||(r.current=null);const m=r.current!==null&&p-r.current<lx;return t.manifests.map(x=>{const j=f.get(x.id),v=dx(j,t.fetchCount,m),S=t.authHealth[x.id];return{id:x.id,manifest:x,integration:j,state:v,authStatus:S==null?void 0:S.status,authAccount:S==null?void 0:S.account,authError:S==null?void 0:S.error}})},[t,i]),l=uc(),c=u.useMemo(()=>o.filter(f=>!(l&&!bs(f.manifest))&&(f.state==="not-running"||f.state==="error"||f.authStatus==="failed")).length,[o,l]),d={loading:t.fetchCount===0,mcpServerUp:t.mcpServerUp,manifestsError:t.manifestsError,entries:o,attentionCount:c,activeSessions:t.activeSessions,refresh:a};return s.jsx(rp.Provider,{value:d,children:e})}function dc(){const e=u.useContext(rp);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const mx=[{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 px(){const{activeDomain:e}=He(),[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 j=np(i,{archivedSet:new Set(d)}).expired.length;j>0&&(f.authorizations=j)}const p=(o==null?void 0:o.length)??0,m=(l==null?void 0:l.length)??0,x=p+m;x>0&&(f.proposals=x),(!c||!c.trim())&&(f.brief=1),n(f)}catch{}},[e]);return ve("attestation-changed",r),ve("proposal-added",r),ve("proposal-resolved",r),ve("proposal-approved",r),ve("proposal-rejected",r),ve("team-membership-changed",r),u.useEffect(()=>(window.addEventListener("suveren:archived-changed",r),()=>window.removeEventListener("suveren:archived-changed",r)),[r]),$t(r,3e5,e),t}const hx={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},gx={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 yx(){const{mode:e,group:t,domain:n,activeTeam:r}=He(),a=px(),{attentionCount:i}=dc(),o={...a};i>0&&(o.integrations=i);const l=mx.filter(m=>!m.teamOnly||e==="team"),c=u.useRef(null),[d,f]=u.useState(null),p=mt();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)},[p.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(ac,{to:m.to,end:m.to==="/",className:({isActive:j})=>`sidebar-item${j?" active":""}`,children:[s.jsx("span",{className:"icon",children:m.icon}),m.label,x?s.jsx("span",{style:hx,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:gx,role:"status","aria-live":"polite",children:d})]})}const Yi="suveren:updatedTo";function vx(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 xx="Updates for this gateway come from your company's IT — no action needed here.";function wx(e){return e==="managed"?"update-banner is-managed":"update-banner"}const jx="Download the new installer and run it. Your settings and mandates stay.";function Sx(e){const t="https://github.com/suverenai/suveren-gateway/releases";return e?`${t}/tag/v${e}`:`${t}/latest`}function kx(){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 sp(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:a,startFastPolling:i,dismiss:o}=oc(),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[p,m]=u.useState(()=>{try{const y=sessionStorage.getItem(Yi);if(y)return sessionStorage.removeItem(Yi),y}catch{}return null}),x=vx(t),j=u.useRef(null),v=y=>{try{sessionStorage.setItem(Yi,y||r||"✓")}catch{}window.location.reload()};u.useEffect(()=>{if(!p)return;const y=setTimeout(()=>m(null),6e3);return()=>clearTimeout(y)},[p]),u.useEffect(()=>{if(!l||!a)return;const y=()=>kx()?!1:(v(n),!0);if(y())return;const w=setInterval(y,1500);return()=>clearInterval(w)},[l,a,n]),u.useEffect(()=>(document.body.classList.toggle("is-updating",l),()=>document.body.classList.remove("is-updating")),[l]);const S=e&&!l&&!p||!!p&&!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=j.current)==null?void 0:C.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${b}px`)};y();const w=new ResizeObserver(y);return j.current&&w.observe(j.current),()=>{w.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:[p&&!l&&s.jsx("div",{ref:j,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",p&&p!=="✓"?` — ${p} is live`:" — now live","."]}),s.jsx("button",{className:"update-banner-x",onClick:()=>m(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!p&&s.jsxs("div",{ref:j,className:wx(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:Sx(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:xx}),t==="msi"&&s.jsx("p",{className:"update-banner-hint",children:jx})]}),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 ap(){const e=uc(),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 bx={system:"◑",light:"☀",dark:"☾"},Nx=[{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 Cx({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:a,logout:i}=He(),{theme:o,toggle:l}=Zm(),c=mt();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:Nx.map(d=>s.jsxs(ac,{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:bx[o]}),"Theme: ",o]}),s.jsx("button",{className:"mobile-menu-action",onClick:()=>{i(),t()},children:"Logout"})]})]})]}):null}function ip(e){return e.status==="pending"}function Ex(e,t){return e.filter(ip).length+t.length}const An=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],Tx=500;function op(){const{user:e,domain:t}=He(),[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]),ve(An[0],o),ve(An[1],o),ve(An[2],o),ve(An[3],o),ve(An[4],o),ve(An[5],o),ve(An[6],o),n}const Bu="Suveren",Ix="/favicon.svg",Rx="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",ta={x1:74.54,y1:22.74,x2:94.46,y2:34.24},Ax=14,Px="#f59e0b";function _x(e){const t=fc(e);return t>0?`(${t}) ${Bu}`:Bu}function fc(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function Lx(){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="${ta.x1}" y1="${ta.y1}" x2="${ta.x2}" y2="${ta.y2}"/>
|
|
54
|
+
<circle cx="103" cy="103" r="25" fill="${Px}"/>
|
|
55
|
+
<style>.m{stroke:#111111;stroke-width:${Ax};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 zx(){return document.querySelector('link[rel="icon"]')}function lp(e){const t=fc(e);document.title=_x(t),cp(t);const n=zx();if(!n)return;const r=t>0?Lx():Ix;n.getAttribute("href")!==r&&n.setAttribute("href",r)}function $x(){lp(0)}function cp(e,t=globalThis.navigator){var a;if(!t||typeof t.setAppBadge!="function")return;const n=fc(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 Mx(){const e=op();return u.useEffect(()=>{lp(e)},[e]),u.useEffect(()=>$x,[]),null}const up="suveren:dockBadgePrompt";function Fx(){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(up))return!1}catch{}return!0}function Ox(){const[e,t]=u.useState(!1),n=op();if(u.useEffect(()=>{t(Fx())},[]),!e)return null;const r=()=>{try{localStorage.setItem(up,"1")}catch{}t(!1)},a=async()=>{try{await Notification.requestPermission()==="granted"&&cp(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 Dx(){const[e,t]=u.useState(!1);return s.jsxs(fx,{children:[s.jsx(Mx,{}),s.jsx(lc,{onMenuToggle:()=>t(!e)}),s.jsx(sp,{}),s.jsx(ap,{}),s.jsx(yx,{}),s.jsx(Cx,{open:e,onClose:()=>t(!1)}),s.jsx("div",{className:"main-content",children:s.jsxs("div",{className:"page-inner",children:[s.jsx(Ox,{}),s.jsx(mv,{})]})})]})}function dp({what:e}){return s.jsxs("div",{className:"human-only-note",role:"note",children:[s.jsx("strong",{children:"Only you."})," ",e==="sign-in"?"Never let an AI or a browser it controls sign in here or see this key.":"Approve only yourself. Never let an AI or a browser it controls open this page or approve for you."]})}function mc(){return typeof navigator<"u"&&navigator.webdriver===!0}const pc="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function Bx(){const[e,t]=u.useState(""),{login:n,isLoading:r,error:a,clearError:i}=He(),[o,l]=u.useState(null),c=mc(),d=async()=>{if(!(!e.trim()||c)){i();try{await n(e)}catch(m){if(m instanceof Jm){l(m.summary);return}}}},f=async()=>{l(null),i();try{await n(e,{confirmWipe:!0})}catch{}},p=()=>{l(null)};return s.jsxs(s.Fragment,{children:[s.jsx(lc,{}),s.jsx(sp,{}),s.jsx(ap,{}),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."})]}),s.jsx(dp,{what:"sign-in"}),c&&s.jsx("div",{className:"error-message",children:pc}),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"&&d(),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:d,disabled:r||c,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,x)=>s.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:x<2?"0.5rem":0},children:[s.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[x+1,"."]}),m]},x))})]})]})})]}),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:p,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:p,disabled:r,children:"Cancel"}),s.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:f,disabled:r,children:r?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function Ux(){const{setActiveContext:e}=He(),t=on(),[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)}}},p=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(lc,{}),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"&&p(),style:{flex:1},disabled:c}),s.jsx("button",{className:"btn btn-secondary",onClick:p,disabled:c,children:"Create"})]})]})]})})]})}const Uu={"claude-code":{label:"Claude Code",snippet:e=>`claude mcp add --transport http suveren ${e}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:e=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json, then restart Claude Desktop:
|
|
57
|
+
|
|
58
|
+
${JSON.stringify({mcpServers:{suveren:{command:"npx",args:["mcp-remote@latest",`${e}/mcp`,"--allow-http"]}}},null,2)}`},"chatgpt-codex":{label:"ChatGPT / Codex",snippet:e=>`Add to ~/.codex/config.toml:
|
|
59
|
+
|
|
60
|
+
[mcp_servers.suveren]
|
|
61
|
+
url = "${e}/mcp"
|
|
62
|
+
|
|
63
|
+
Or: codex mcp add suveren --url ${e}/mcp`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
|
|
64
|
+
SSE transport: GET ${e}/sse
|
|
65
|
+
Health check: GET ${e}/health`}},Wu=["claude-code","claude-desktop","chatgpt-codex","other"];function Qo({mcpEndpoint:e}){const[t,n]=u.useState(Wu[0]),[r,a]=u.useState(!1),i=u.useCallback(async l=>{try{await navigator.clipboard.writeText(l),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[]),o=Uu[t].snippet(e);return s.jsxs("div",{children:[s.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),s.jsx("div",{className:"mcp-endpoint",children:e}),s.jsx("div",{className:"mcp-tabs",children:Wu.map(l=>s.jsx("button",{className:`mcp-tab${t===l?" active":""}`,onClick:()=>n(l),children:Uu[l].label},l))}),s.jsx("pre",{className:"mcp-snippet",children:o}),s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>i(o),children:r?"Copied":"Copy"})]})}const Jo="suveren-setup-ai-skipped",qo="suveren-setup-agent-done",Xo="suveren-setup-dismissed",Wx={"hap-setup-ai-skipped":Jo,"hap-setup-agent-done":qo,"hap-setup-dismissed":Xo};function Hx(){for(const[e,t]of Object.entries(Wx)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}Hx();function Vx({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:a}){const[i,o]=u.useState(()=>localStorage.getItem(Jo)==="true"),[l,c]=u.useState(()=>localStorage.getItem(qo)==="true"),[d,f]=u.useState(()=>localStorage.getItem(Xo)==="true"),[p,m]=u.useState(null),x=[{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"}],j=x.filter(w=>w.status==="done"||w.status==="skipped").length,v=j===x.length,S=u.useCallback(()=>{localStorage.setItem(Jo,"true"),o(!0)},[]),g=u.useCallback(()=>{localStorage.setItem(qo,"true"),c(!0),m(null)},[]),h=u.useCallback(()=>{localStorage.setItem(Xo,"true"),f(!0)},[]);if(d||v)return null;const y=x.findIndex(w=>w.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:h,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:x.map((w,b)=>{const C=b===y,N=w.status==="done"||w.status==="skipped"?"●":"○",A=w.status==="done"?"var(--success)":w.status==="skipped"?"var(--text-tertiary)":C?"var(--accent)":"var(--text-tertiary)";return s.jsxs("div",{children:[s.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:C?"0.75rem":"0.25rem 0",borderRadius:C?"0.5rem":void 0,background:C?"var(--accent-subtle)":void 0},children:[s.jsx("span",{style:{color:A,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:N}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[w.to&&w.status==="pending"?s.jsx(De,{to:w.to,style:{fontSize:"0.9rem",fontWeight:C?600:500,color:C?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:w.label}):w.status==="pending"&&b===3?s.jsx("button",{onClick:()=>m(p===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:C?600:500,color:C?"var(--accent)":"var(--text-primary)"},children:w.label}):s.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:w.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:w.label}),w.optional&&w.status==="pending"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),w.status==="skipped"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),w.detail&&w.status==="pending"&&C&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:w.detail})]}),w.optional&&w.status==="pending"&&s.jsx("button",{onClick:S,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),w.to&&w.status==="pending"&&s.jsx(De,{to:w.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),b===3&&p===3&&s.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[s.jsx(Qo,{mcpEndpoint:a}),s.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:g,children:"Done"})]})]},b)})}),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:`${j/x.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:[j," of ",x.length," complete"]})]})]})}function fp(e,t=null){const n=[e.hasContact,e.hasDelegationMandate,e.delegationProposalCount>0],r=n.every(Boolean),a=e.otherMandateCount===0&&!r,i=n.findIndex(d=>!d),o=t!==null&&n[t]===!1?t:i,l=e.managed?"managed":"self",c=d=>n[d]?{status:"done"}:d!==o?{status:"todo"}:d===1?{status:"open",variant:l,simulationOn:e.simulationOn}:d===0?{status:"open",variant:l}:{status:"open"};return{visible:a,step1:c(0),step2:c(1),step3:c(2)}}const Gx={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},mp=e=>Gx[e]??e,Kx={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 Yx(e){return Kx[e]??{chip:"Blocked",sev:"info"}}function Qx(e){const t=mp(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 pp(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 Hu=5,Jx=24*60*60*1e3,va=7;function qx(e,t){const n=t-va*Jx;return{recent:e.filter(r=>r.ts>=n),all:e}}function Xx(){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]),$t(o,12e4),a||e===null)return null;const{recent:l,all:c}=qx(e,Date.now()),d=n?c:l.slice(0,Hu),f=c.length-l.length,p=(m,x)=>{const j=Yx(m.reason);return s.jsxs("div",{className:"rb-row",children:[s.jsx("span",{className:`rb-dot ${j.sev==="act"?"act":j.sev==="info"?"info":""}`,"aria-hidden":"true"}),s.jsxs("div",{className:"rb-body",children:[s.jsx("div",{className:"rb-line",children:Qx(m)}),s.jsxs("div",{className:"rb-meta",children:[s.jsx("span",{className:`rb-chip ${j.sev==="act"?"act":j.sev==="warn"?"warn":""}`,children:j.chip}),s.jsx("span",{className:"rb-via",children:mp(m.integrationId)})]}),j.fixTo&&s.jsx(De,{className:"rb-fix",to:j.fixTo,children:"Set a read window →"})]}),s.jsx("div",{className:"rb-when",children:pp(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 ",va," 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 ${va} 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(p)}),!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,Hu)&&s.jsx("div",{className:"rb-foot",children:s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!1),children:["Show only the last ",va," days"]})})]})]})}const Zx="/mandates?new=1&profile=delegation";function Vu({text:e}){const[t,n]=u.useState(!1),r=u.useCallback(async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}catch{}},[e]);return s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:r,children:t?"Copied":"Copy"})}function Qi({todo:e,onOpen:t,children:n}){return e?s.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:t,children:n}):s.jsx("span",{className:"flow-step-title",children:n})}function e0({contact:e,hasDelegationMandate:t,otherMandateCount:n,delegationProposalCount:r,managed:a,simulationOn:i,mcpEndpoint:o}){const l={hasContact:e!==null,hasDelegationMandate:t,otherMandateCount:n,delegationProposalCount:r,managed:a,simulationOn:i},[c,d]=u.useState(null),f=fp(l,c);if(!f.visible)return null;const p=`Please connect to the Suveren gateway: MCP server at ${o}/mcp`;return s.jsxs("div",{className:"card setup-card",children:[s.jsx("h2",{className:"card-title",children:"Get started"}),s.jsx("p",{className:"setup-intro",children:"You decide what your AI can do — it acts only within that. Every action that changes something gets a signed ticket."}),s.jsxs("div",{className:"flow-step",children:[s.jsxs("div",{className:"flow-step-head",children:[s.jsx("span",{className:`flow-step-marker flow-${f.step1.status==="open"?"open":f.step1.status==="done"?"done":"todo"}`,children:f.step1.status==="done"?"✓":"1"}),f.step1.status==="done"&&e?s.jsxs("span",{className:"flow-step-title flow-done-title",children:[e.clientName," connected · last contact ",pp(Date.parse(e.lastSeenAt),Date.now()).toLowerCase()]}):s.jsx(Qi,{todo:f.step1.status==="todo",onOpen:()=>d(0),children:"Connect your AI"})]}),f.step1.status==="open"&&s.jsx("div",{className:"flow-step-body",children:f.step1.variant==="managed"?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),s.jsxs("details",{className:"int-details",children:[s.jsx("summary",{children:"For your IT"}),s.jsx("div",{style:{marginTop:"0.75rem"},children:s.jsx(Qo,{mcpEndpoint:o})})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),s.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:s.jsxs("div",{className:"quote-box",children:[s.jsx("span",{className:"quote-text",children:p}),s.jsx(Vu,{text:p})]})}),s.jsx("p",{className:"cta-helper",style:{marginTop:0,marginBottom:"0.75rem"},children:"If your AI can't add it itself, it will tell you how. In ChatGPT, use a local session."}),s.jsxs("details",{className:"int-details",children:[s.jsx("summary",{children:"Set it up by hand"}),s.jsx("div",{style:{marginTop:"0.75rem"},children:s.jsx(Qo,{mcpEndpoint:o})})]})]})})]}),s.jsxs("div",{className:"flow-step",children:[s.jsxs("div",{className:"flow-step-head",children:[s.jsx("span",{className:`flow-step-marker flow-${f.step2.status==="open"?"open":f.step2.status==="done"?"done":"todo"}`,children:f.step2.status==="done"?"✓":"2"}),f.step2.status==="done"?s.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",s.jsx(De,{to:"/mandates",children:"review or revoke under Mandates"})]}):s.jsx(Qi,{todo:f.step2.status==="todo",onOpen:()=>d(1),children:"Give the Delegation mandate"})]}),f.step2.status==="open"&&s.jsxs("div",{className:"flow-step-body",children:[s.jsx("p",{children:"Delegation lets your AI propose the rest of its own setup — new mandates and its working instructions. It can only propose; nothing changes until you approve it."}),s.jsxs("ul",{className:"bound-list",children:[s.jsx("li",{children:"Read the setup guides"}),s.jsx("li",{children:"Propose new mandates — each waits for your approval"}),s.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),f.step2.simulationOn?s.jsxs(s.Fragment,{children:[s.jsx(De,{to:Zx,className:"btn btn-primary",children:"Give the Delegation mandate →"}),s.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),f.step2.variant==="managed"&&s.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):s.jsx("p",{className:"managed-note",style:{marginTop:0},children:f.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":s.jsxs(s.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",s.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),s.jsxs("div",{className:"flow-step",children:[s.jsxs("div",{className:"flow-step-head",children:[s.jsx("span",{className:`flow-step-marker flow-${f.step3.status==="open"?"open":"todo"}`,children:"3"}),s.jsx(Qi,{todo:f.step3.status==="todo",onOpen:()=>d(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),f.step3.status==="open"&&s.jsxs("div",{className:"flow-step-body",children:[s.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:s.jsxs("div",{className:"quote-box",children:[s.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),s.jsx(Vu,{text:"How do I start with Suveren?"})]})}),s.jsxs("p",{children:["It will interview you, suggest test data, and propose mandates and a brief. Approve its proposals under ",s.jsx(De,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function t0(){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 n0(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 hp(){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(n0(r))}).catch(()=>{}),()=>{n=!0}},[]),e}function r0(e){return!e||typeof e!="object"?!1:Array.isArray(e.policyLocked)&&e.policyLocked.length>0}function s0(){const[e,t]=u.useState(!1);return u.useEffect(()=>{let n=!1;const r=()=>{fetch("/health").then(o=>o.json()).then(o=>{n||t(r0(o))}).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 On({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 Ji(){return s.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[s.jsx(On,{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(On,{variant:"line",style:{width:"35%"}}),s.jsx(On,{variant:"line-sm",style:{width:"65%"}})]})]})}function a0(){const[e,t]=u.useState([]);return $t(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 i0(e,t){return t&&!bs(e.manifest)}function o0(e,t=!1){var r;const n=[];for(const a of e)i0(a,t)||(a.state==="error"?n.push({label:"Integration error",detail:(r=a.integration)!=null&&r.error?`${a.manifest.name}: ${a.integration.error}`:`${a.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"}):a.state==="not-running"&&(bs(a.manifest)?n.push({label:`${a.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--danger)"}):n.push({label:"Integration stopped",detail:`${a.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"})));return n}function l0(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 c0=30*60;function Xn(e){return e.replace(/@.*$/,"").split("/").pop()??e}function u0(){const{domain:e}=He(),[t,n]=u.useState([]),[r,a]=u.useState([]),[i,o]=u.useState([]),[l,c]=u.useState(!0),[d,f]=u.useState(!1),[p,m]=u.useState([]),[x,j]=u.useState(!1),[v,S]=u.useState(!1),[g,h]=u.useState(null),[y,w]=u.useState(!1),{entries:b,activeSessions:C,loading:N}=dc(),A=t0(),E=!N,{simulation:P}=hp(),O=P===!0,L=s0(),Z=u.useCallback(()=>{T.getMyAttestations().then(J=>{n(J),f(!0)}).catch(()=>f(!0)),T.getArchivedMandates().then(m).catch(()=>m([])),T.getMyProposals(e).then(J=>{a(J),j(!0)}).catch(()=>j(!0)),T.getProposalsForApprover().then(J=>o(J)).catch(()=>o([])),T.getCredential("ai-config").then(J=>{c(J.configured),S(!0)}).catch(()=>S(!0)),T.getAgentContact().then(J=>{h(J.contact),w(!0)}).catch(()=>w(!0))},[e]);ve("attestation-changed",Z),ve("proposal-added",Z),ve("proposal-resolved",Z),ve("proposal-approved",Z),ve("proposal-rejected",Z),$t(Z,3e5,e);const F=d&&x&&v&&E&&y&&P!==null,q=np(t,{archivedSet:new Set(p)}),W=q.active,ee=q.expired,z=W.some(J=>Xn(J.profile_id)==="delegation"),R=W.filter(J=>Xn(J.profile_id)!=="delegation").length,D=r.filter(J=>Xn(J.profileId)==="delegation").length,_=fp({hasContact:g!==null,hasDelegationMandate:z,otherMandateCount:R,delegationProposalCount:D,managed:L,simulationOn:O}),$=O&&_.visible,V=W.filter(J=>J.remaining_seconds!==null&&J.remaining_seconds<=c0),X=r.filter(ip),ne=b.filter(J=>J.state==="running"),oe=b.filter(J=>J.state==="starting"),de=l0(b),fe=[];for(const J of i)fe.push({label:"Approval needed",detail:`${J.tool} — above-cap action under ${Xn(J.profileId)}`,to:"/approvals",color:"var(--warning)"});for(const J of X)fe.push({label:"Approval pending",detail:`${J.tool} awaiting your approval`,to:"/approvals",color:"var(--warning)"});for(const J of V){const me=Math.ceil((J.remaining_seconds??0)/60);fe.push({label:"Expiring soon",detail:`${J.title??Xn(J.profile_id)} — ${me} min remaining`,to:"/mandates",color:"var(--warning)"})}for(const J of ee)fe.push({label:"Expired",detail:J.title??Xn(J.profile_id),to:"/mandates",color:"var(--danger)"});fe.push(...o0(b,O));for(const J of oe)fe.push({label:"Integration starting",detail:`${J.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const J of b)J.authStatus==="failed"&&J.state!=="not-running"&&J.state!=="error"&&J.state!=="paused"&&fe.push({label:"Reconnect needed",detail:`${J.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return l||fe.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"})}),F&&A&&($?s.jsx(e0,{contact:g,hasDelegationMandate:z,otherMandateCount:R,delegationProposalCount:D,managed:L,simulationOn:O,mcpEndpoint:A}):!O&&s.jsx(Vx,{aiConfigured:l,hasRunningIntegration:ne.length>0,hasActiveAuth:W.length>0,hasAgentConnected:C>0,mcpEndpoint:A})),!$&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[s.jsx(De,{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:W.length>0?"var(--success)":"var(--text-tertiary)"},children:W.length}):s.jsx(On,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),s.jsx(De,{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:X.length>0?"var(--warning)":"var(--text-tertiary)"},children:X.length}):s.jsx(On,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),s.jsx(De,{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:ee.length>0?"var(--danger)":"var(--text-tertiary)"},children:ee.length}):s.jsx(On,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),s.jsx(De,{to:"/integrations",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[E?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:ne.length>0?"var(--success)":"var(--text-tertiary)"},children:ne.length}):s.jsx(On,{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"}),fe.length>0&&s.jsx("span",{className:"rb-count",children:fe.length})]}),fe.length>0?s.jsx("div",{className:"attention-rows",children:fe.map((J,me)=>s.jsxs(De,{to:J.to,className:"attention-row",children:[s.jsx("span",{className:"attention-dot",style:{background:J.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:J.label}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:J.detail})]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},me))}):F?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(Ji,{}),s.jsx(Ji,{}),s.jsx(Ji,{})]})]})]}),de&&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:[de.count," real system",de.count===1?"":"s"," ",de.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",de.namesText,"."]})]}),s.jsx(a0,{}),s.jsx(Xx,{})]})}const d0=["Scope & Limits","Intent","Sign"];function gp({currentStep:e,onStepClick:t}){const n=on();return s.jsxs("div",{className:"wizard-progress",children:[s.jsx("ol",{className:"wizard-steps",children:d0.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 Gu=40,f0={delegation:"Delegation"};function Fe(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=f0[i.toLowerCase()];return o||(t?t.slice(0,Gu):(i.charAt(0).toUpperCase()+i.slice(1)).slice(0,Gu))}function m0({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:"})," ",Fe(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 p0({integrationId:e,field:t,value:n,onChange:r,disabled:a,onLabels:i}){const[o,l]=u.useState(null),[c,d]=u.useState(null),[f,p]=u.useState(!0);u.useEffect(()=>{let j=!1;return T.discoverScopeField(e,t).then(v=>{var S;j||(l(v.options),p(!1),(S=v.options)!=null&&S.length&&(i==null||i(Object.fromEntries(v.options.map(g=>[g.value,g.label])))))}).catch(v=>{j||(d(v instanceof Error?v.message:String(v)),p(!1))}),()=>{j=!0}},[e,t]);const m=new Set(n.split(",").map(j=>j.trim()).filter(Boolean)),x=j=>{const v=new Set(m);v.has(j)?v.delete(j):v.add(j),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:j=>r(j.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(j=>{const v=j.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:m.has(String(j.value)),onChange:()=>x(String(j.value)),disabled:a||g}),s.jsx("span",{children:j.label||j.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]})]},j.value)})})}function hc(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 h0(e,t){if(t!==void 0)return String(t);const n=e.default;return typeof n=="string"||typeof n=="number"&&Number.isFinite(n)?String(n):hc(e)===1?"1":""}function yp(e){const t=e.maximum;return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Ku(e,t){const n=hc(e),r=yp(e),a=t===""?n:Math.max(n,Number(t));return r!==void 0?Math.min(r,a):a}function vp(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function g0(e){return e.replace(/@.*$/,"").split("/").pop()??e}function y0(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function v0(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function x0(e){var n;const t=e;return!!(t.enum&&((n=t.constraint)!=null&&n.enforceable.includes("subset")))}function Yu(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 w0(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function j0(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 S0(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 k0({id:e,value:t,onChange:n,disabled:r,placeholder:a,unit:i,min:o=0,max:l}){const c=w0(i),d=j0(i).filter(v=>l===void 0||v.value<=l),f=vp(i),p=S0(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))},j=()=>{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:j,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))}),p&&s.jsxs("div",{className:"bounded-input-echo",children:["≈ ",p]})]})}function Qu({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 b0({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),p=t?t.split(",").map(g=>g.trim()).filter(Boolean):[],m=g=>{const h=g.trim();if(!h)return;if(!Yu(h,a)){d(!0);return}d(!1);const y=p.includes(h)?p:[...p,h];n(y.join(",")),l("")},x=g=>{const h=p.filter((y,w)=>w!==g);n(h.join(","))},j=g=>{g.key==="Enter"||g.key===","||g.key==="Tab"?o.trim()&&(g.preventDefault(),m(o)):g.key==="Backspace"&&!o&&p.length>0&&x(p.length-1)},v=g=>{const h=g.clipboardData.getData("text");if(h.includes(",")){g.preventDefault();const w=h.split(",").map(C=>C.trim()).filter(Boolean).filter(C=>Yu(C,a)),b=[...new Set([...p,...w])];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:[p.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:j,onPaste:v,onBlur:()=>{o.trim()&&m(o)},placeholder:p.length===0?i??S:""})]})}function N0({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 Ju({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:a,readOnly:i,twoColumn:o,discoveryIntegrationId:l,onLabels:c}){const d=y0(e,t),f=`${a}-field-${e}`,p=s.jsx(s.Fragment,{children:x0(t)?s.jsx(N0,{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))]}):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(k0,{id:f,value:n,onChange:m=>r(e,m),disabled:i,unit:t.unit,min:hc(t),max:yp(t)}):v0(t)?s.jsx(b0,{id:f,value:n,onChange:m=>r(e,m),disabled:i,format:t.format}):l?s.jsx(p0,{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(Qu,{htmlFor:f,label:d,description:t.description})}),s.jsx("div",{className:"bounds-field-input",children:p})]},`${a}-${e}`):s.jsxs("div",{className:"form-group",children:[s.jsx(Qu,{htmlFor:f,label:d,description:t.description}),p]},`${a}-${e}`)}function C0(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 E0(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 T0({profile:e,onConfirm:t,onCancel:n,readOnly:r,initialBounds:a,initialContext:i,initialFrame:o,profileConfig:l,approverNames:c,adminName:d}){const f=e.boundsSchema,p=e.scopeSchema,m=f?Object.entries(f.fields).filter(([_,$])=>!(_==="profile"||_==="path"||$.enforced===!1||$.enforcedBy==="gatekeeper")):[],x=f?Object.entries(f.fields).filter(([,_])=>_.enforcedBy==="gatekeeper").filter(([,_])=>_.enforced!==!1).map(([_,$])=>$.displayName??_):[],j=p&&p.keyOrder.length>0?Object.entries(p.fields):[],v=a??o??{},S=i??{},g={};for(const[_,$]of m)g[_]=h0($,v[_]);const h={};for(const[_]of j)h[_]=S[_]!==void 0?String(S[_]):"";const[y,w]=u.useState(g),[b,C]=u.useState(h),[N,A]=u.useState({}),[E,P]=u.useState(null);u.useEffect(()=>{const _=g0(e.id);T.getIntegrationManifests().then(({manifests:$})=>{const V=$.find(X=>X.profile===_&&X.contextDiscovery&&Object.keys(X.contextDiscovery).length>0);P(V??null)}).catch(()=>P(null))},[e.id]);const O=C0(y,l),L=E0(y,l==null?void 0:l.caps),Z=(_,$)=>{w(V=>({...V,[_]:$}))},F=(_,$)=>{C(V=>({...V,[_]:$}))},q=()=>{const _={profile:e.id};for(const[V,X]of m)X.type==="number"?_[V]=Ku(X,y[V]):_[V]=y[V];const $={};for(const[V,X]of j)X.type==="number"?$[V]=b[V]===""?0:Number(b[V]):$[V]=b[V];return[_,$]},W=()=>{const[_,$]=q();t(_,$,N)},ee=()=>{const _=(l==null?void 0:l.caps)??{},$={...y};for(const ne of L)_[ne]!==void 0&&($[ne]=String(_[ne]));w($);const V={profile:e.id};for(const[ne,oe]of m)oe.type==="number"?V[ne]=Ku(oe,$[ne]??""):V[ne]=$[ne]??"";const X={};for(const[ne,oe]of j)oe.type==="number"?X[ne]=b[ne]===""?0:Number(b[ne]):X[ne]=b[ne];t(V,X,N)},z=_=>{const $=l==null?void 0:l.caps;if(!$||$[_]===void 0)return null;const V=$[_],X=L.has(_);return O==="hard-ceiling"&&X?s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",V," — exceeds team ceiling"]}):O==="above-approvers"&&X?s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",V," — above cap"]}):s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",V," ok"]})},R=()=>{var _;if(O==="no-config")return null;if(O==="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(O==="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(O==="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(O==="hard-ceiling"){const $=Array.from(L)[0],V=$?(_=l==null?void 0:l.caps)==null?void 0:_[$]:void 0,X=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 ",V??"the configured limit",". Lower your bound or ask ",X," 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:ee,children:"Save below cap"}),n&&s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},D=O==="hard-ceiling";return s.jsxs("div",{children:[j.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"})]})]}),j.map(([_,$])=>{var X;const V=!!((X=E==null?void 0:E.contextDiscovery)!=null&&X[_]);return s.jsx(Ju,{fieldKey:_,fieldDef:$,value:b[_],onChange:F,prefix:"context",readOnly:r,discoveryIntegrationId:V?E.id:void 0,onLabels:(ne,oe)=>A(de=>({...de,[ne]:oe}))},`context-${_}`)})]}),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(([_,$])=>{var V;return s.jsxs("div",{style:{display:"contents"},children:[s.jsx(Ju,{fieldKey:_,fieldDef:$,value:y[_],onChange:Z,prefix:"bounds",readOnly:r,twoColumn:!0}),O!=="no-config"&&((V=l==null?void 0:l.caps)==null?void 0:V[_])!==void 0&&s.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:z(_)})]},`bounds-${_}`)})}),R(),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(De,{to:"/integrations",children:"Integrations"}),"."]})]}),s.jsx("button",{className:"btn btn-primary",onClick:W,disabled:D,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function I0(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 R0(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const A0="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 Ga({target:e,currentText:t,onApply:n,greeting:r,placeholder:a,title:i}){const[o,l]=u.useState([{role:"assistant",content:r??A0}]),[c,d]=u.useState(""),[f,p]=u.useState(!1),[m,x]=u.useState(null),j=u.useRef(null),v=u.useRef(null);u.useEffect(()=>{const h=j.current;if(!h)return;const y=o[o.length-1],w=v.current;!f&&(y==null?void 0:y.role)==="assistant"&&o.length>1&&w?h.scrollTop=w.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),p(!0);try{const w=await T.aiChat({target:e,currentText:t,messages:y.filter((b,C)=>!(C===0&&b.role==="assistant"))});w.success&&w.reply?l(b=>[...b,{role:"assistant",content:w.reply}]):x(w.error??"AI returned no reply")}catch(w){x(w instanceof Error?w.message:"Chat failed")}finally{p(!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:j,className:"chat-messages",children:[o.map((h,y)=>{const w=h.role==="assistant"?I0(h.content):null,b=w?R0(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}),w!==null&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"chat-fenced-block",children:w}),s.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(w),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: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 xp({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]),Tm.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 P0(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _0(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 p,m;return((p=f.scope)==null?void 0:p.toLowerCase())===d||((m=f.scope)==null?void 0:m.split(",").map(x=>x.trim().toLowerCase()).includes(d))})},o=["\\[\\d+\\]",...r.map(P0)],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 p=f.scope&&f.scope!=="all (unscoped)"?f.scope:"all recipients",m=n?`${n}: ${p}`:p;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 qu=`Why — What's the situation? Why does this need to happen?
|
|
66
|
+
|
|
67
|
+
Goal — What should the agent try to achieve?
|
|
68
|
+
|
|
69
|
+
Watch out — What should the agent avoid or be careful about?`;function L0(e,t,n,r){return _0(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 z0(){var ie;const e=on(),[t]=ic(),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),[p,m]=u.useState(null),[x,j]=u.useState({}),[v,S]=u.useState(qu),[g,h]=u.useState(!1),[y,w]=u.useState(null),[b,C]=u.useState(!0),[N,A]=u.useState(null),[E,P]=u.useState([]),[O,L]=u.useState(void 0),[Z,F]=u.useState(!1),[q,W]=u.useState(null),[ee,z]=u.useState(null),[R,D]=u.useState(null),[_,$]=u.useState([]),[V,X]=u.useState(null);u.useEffect(()=>{var ye;const I=sessionStorage.getItem("agentAuth");if(!I){e("/mandates?new=1");return}const K=JSON.parse(I);a(K),K.intentHint&&S(K.intentHint),T.getCredential("ai-config").then(pe=>w(pe.configured)).catch(()=>w(!1));const ae=sessionStorage.getItem("agentGate");if(ae){const pe=JSON.parse(ae);pe.bounds&&f(pe.bounds),pe.context&&m(pe.context),(ye=pe.gateContent)!=null&&ye.intent&&S(pe.gateContent.intent)}T.getProfile(K.profileId).then(pe=>o(pe)).catch(()=>e("/mandates?new=1")).finally(()=>C(!1)),K.groupId&&Promise.all([T.getTeamProfileConfig(K.groupId,K.profileId).catch(()=>null),T.getGroupById(K.groupId).catch(()=>null),T.listUsers().catch(()=>[])]).then(([pe,ze,kt])=>{if(A(pe),pe){const Ve=new Map;for(const le of kt){const k=le.name&&le.email?`${le.name} (${le.email})`:le.name||le.email||le.id;Ve.set(le.id,k)}const et=(ze==null?void 0:ze.members)??[];for(const le of et){const k=le.userId??le.id;k&&(le.name&&le.email?Ve.set(k,`${le.name} (${le.email})`):le.name&&Ve.set(k,le.name))}const pt=(pe.approvers??[]).map(le=>Ve.get(le)??le);P(pt);const at=et.find(le=>le.role==="admin");if(at){const le=at.userId??at.id;le&&L(Ve.get(le)??at.name)}}})},[e]);const ne=d?Object.entries(d).filter(([I])=>I!=="profile"&&I!=="path").map(([I,K])=>`${I} = ${K}`).join(", "):"",oe=(I,K,ae)=>{f(I),m(K),ae&&j(ae),c(3)},de=v.trim()!==qu.trim()&&v.trim()!=="",fe=I=>{de&&!confirm("Replace your current intent with the AI draft?")||S(I)},J=()=>{const I=i==null?void 0:i.ttl,K={intent:v},ae=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...ae,bounds:d,context:p,contextLabels:x,gateContent:K,ttlConfig:I})),e("/mandates/new/sign")},me=async()=>{if(r){F(!0),W(null),z(null),D(null),$([]),X(null);try{const I=await T.aiIntentReview({profileId:r.profileId,newIntent:v,context:p??void 0});$(I.grants??[]),I.success?I.review?W(I.review):z(I.note??"No other mandates on this profile to compare against."):D(I.error??"Check failed.")}catch(I){D(I instanceof Error?I.message:"Check failed.")}finally{F(!1)}}},re=I=>{S(I),(q||ee||R)&&(W(null),z(null),D(null),$([]),X(null))};return b||!r||!i?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):s.jsxs(s.Fragment,{children:[s.jsx(gp,{currentStep:l,onStepClick:I=>{I>=2&&c(I)}}),s.jsx(m0,{profileId:r.profileId,bounds:ne||void 0,groupName:r.groupName,domain:r.domain}),l===2&&s.jsx("div",{className:"card",children:s.jsx(T0,{profile:i,onConfirm:oe,onCancel:()=>e("/mandates?new=1"),initialBounds:d||void 0,initialContext:p||void 0,profileConfig:N,approverNames:E,adminName:O})}),l===3&&s.jsxs("div",{className:`intent-layout${y?"":" no-chat"}`,children:[y&&s.jsx("div",{className:"card intent-pane chat tool",children:s.jsx(Ga,{target:{kind:"intent",profileId:r.profileId,bounds:ne||void 0},currentText:v,onApply:fe})}),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:I=>re(I.target.value)}),s.jsxs("div",{className:"char-counter",children:[v.length," / 2000"]})]}),y===!1&&s.jsxs("p",{className:"intent-ai-hint",children:[s.jsx(De,{to:"/settings",children:"Set up an AI assistant in Settings"})," to get help writing this."]}),y&&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:me,disabled:Z||!de,children:Z?"Checking…":"Check against my other grants"}),R&&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:R})]}),ee&&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:ee})]}),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.jsxs("div",{className:"hint-body",children:[s.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),s.jsx("div",{style:{whiteSpace:"pre-wrap"},children:L0(q,_,X,Fe(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:J,disabled:!de,children:"Continue to Review"})]}),(((ie=N==null?void 0:N.approvers)==null?void 0:ie.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 ",E.length>0?E.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",E.length>0?E.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),y&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"floating-help",onClick:()=>h(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),s.jsx(xp,{open:g,onClose:()=>h(!1),ariaLabel:"Intent assistant",children:s.jsx(Ga,{target:{kind:"intent",profileId:r.profileId,bounds:ne||void 0},currentText:v,onApply:I=>{fe(I),h(!1)}})})]}),V&&s.jsx("div",{className:"modal-backdrop",onClick:I=>I.target===I.currentTarget&&X(null),children:s.jsxs("div",{className:"modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:V.length>1?`Existing mandates (${V.length})`:"Existing mandate"}),s.jsx("button",{className:"modal-close",onClick:()=>X(null),children:"×"})]}),s.jsx("div",{className:"modal-body",children:V.map((I,K)=>{var ae;return s.jsxs("div",{style:{marginBottom:K<V.length-1?"1rem":0,paddingBottom:K<V.length-1?"1rem":0,borderBottom:K<V.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:I.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:((ae=I.intent)==null?void 0:ae.trim())||"(no intent recorded)"}),Object.entries(I.bounds).filter(([ye])=>ye!=="profile"&&ye!=="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(I.bounds).filter(([ye])=>ye!=="profile"&&ye!=="path").map(([ye,pe])=>`${ye}: ${pe}`).join(" · ")})]})]},K)})})]})})]})]})}function $0(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
70
|
+
`).split(`
|
|
71
|
+
`).map(a=>a.replace(/[ \t]+$/,"")).join(`
|
|
72
|
+
`).replace(/\n+$/,"")}async function gc(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 M0 extends Error{constructor(n,r,a){super(a);_r(this,"code");_r(this,"field");this.name="CanonicalValueError",this.code=n,this.field=r}}function F0(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 wp(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(`
|
|
73
|
+
`)||o.includes("\r"))throw new M0(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}=${F0(o)}`)}return r.join(`
|
|
74
|
+
`)}async function xa(e,t){const n=t.boundsSchema;if(!n)throw new Error("Profile has no boundsSchema");const r=wp(e,n.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await gc(r)}`}async function jp(e,t){const n=t.scopeSchema?wp(e,t.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await gc(n)}`}function Zo(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(a=>a===void 0?"null":Zo(a)).join(",")+"]";const t=e,n=[];for(const r of Object.keys(t).sort()){const a=t[r];a!==void 0&&n.push(JSON.stringify(r)+":"+Zo(a))}return"{"+n.join(",")+"}"}async function Sp(e){return`sha256:${await gc(Zo(e))}`}async function Ka(e){const t=new TextEncoder().encode($0(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 kp(e,t){if(!e.authorization_id)throw new Error("Signing 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 O0(e){const t=e.commitment_modes;return t===void 0?["review","automatic"]:Array.isArray(t)?["review","automatic"].filter(n=>t.includes(n)):[]}function D0(e){return e==="per-action"?"review":"automatic"}function Xu(e){return e?O0(e).map(t=>t==="review"?"per-action":"immediate"):["per-action","immediate"]}function B0(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 U0(e,t){for(const n of e)if(t.has(n))return!0;return!1}function W0(e,t,n){for(const r of e){const a=Zu(t[r]),i=Zu(n[r]);if(!(a.size===0||i.size===0)&&!U0(a,i))return!1}return!0}function H0(e){return e.length>24?`${e.slice(0,10)}…`:e}function bp(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} (${H0(i)})`:i}).join(", ")}function Np(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 V0(){var G,se;const e=on(),{user:t,mode:n,domain:r}=He(),[a,i]=u.useState(null),[o,l]=u.useState(null),[c,d]=u.useState(null),[f,p]=u.useState("per-action"),[m,x]=u.useState(1800),[j,v]=u.useState(86400),[S,g]=u.useState(""),[h,y]=u.useState("hours"),[w,b]=u.useState(""),[C,N]=u.useState(!0),[A,E]=u.useState(!1);u.useEffect(()=>{T.getIdentityDisclosure().then(H=>E(H.always)).catch(()=>{})},[]);const[P,O]=u.useState(!1),[L,Z]=u.useState(""),[F,q]=u.useState(null),[W,ee]=u.useState([]),[z,R]=u.useState(!1),[D,_]=u.useState([]),[$,V]=u.useState(0);u.useEffect(()=>{var In;const H=sessionStorage.getItem("agentAuth"),he=sessionStorage.getItem("agentGate");if(!H||!he){e("/mandates?new=1");return}const Pe=JSON.parse(H),Ce=JSON.parse(he),Ge={bounds:Ce.bounds??{},context:Ce.context??{},contextLabels:Ce.contextLabels??void 0,gateContent:Ce.gateContent};i(Pe),l(Ge),Ce.ttlConfig&&(x(Ce.ttlConfig.default??1800),v(Ce.ttlConfig.max??86400)),Ce.templateMode==="automatic"?p("immediate"):Ce.templateMode==="review"&&p("per-action");const Tn=((In=Ce.ttlConfig)==null?void 0:In.max)??86400;if(typeof Ce.templateTtl=="number"&&Ce.templateTtl>0){const $e=Math.min(Ce.templateTtl,Tn);x($e),[3600,86400,604800,2592e3,31536e3].includes($e)||($e%86400===0?(g(String($e/86400)),y("days")):(g(String(Math.max(1,Math.round($e/3600)))),y("hours")))}T.getProfile(Pe.profileId).then($e=>{var ht;if(d($e),!w){const bt=$e.name??((ht=Pe.profileId.split("/").pop())==null?void 0:ht.replace(/@.*$/,""))??"",it=[];if(Ge.context&&$e.scopeSchema)for(const te of $e.scopeSchema.keyOrder){const Y=Ge.context[te];if(Y!==void 0&&Y!==""){const ue=String(Y).split(",").map(je=>je.trim()).filter(Boolean);it.push(ue.join(", "))}}const U=it.length>0?`${bt}: ${it.join(" · ")}`:bt;b(U)}}).catch(()=>{}),Pe.isPersonal?R(!0):Promise.all([T.getTeamProfileConfig(Pe.groupId,Pe.profileId).catch(()=>null),T.getGroupById(Pe.groupId).catch(()=>null),T.listUsers().catch(()=>[])]).then(([$e,ht,bt])=>{if(q($e),$e){const it=new Map;for(const Y of bt){const ue=Y.name&&Y.email?`${Y.name} (${Y.email})`:Y.name||Y.email||Y.id;it.set(Y.id,ue)}const U=(ht==null?void 0:ht.members)??[];for(const Y of U){const ue=Y.userId??Y.id;ue&&(Y.name&&Y.email?it.set(ue,`${Y.name} (${Y.email})`):Y.name&&it.set(ue,Y.name))}const te=($e.approvers??[]).map(Y=>it.get(Y)??Y);ee(te)}}).finally(()=>{R(!0)})},[e]),u.useEffect(()=>{if(!(a!=null&&a.profileId))return;const H=a.profileId,he=sessionStorage.getItem("agentEditReplaces");T.getEnrichedAuthorizations().then(Pe=>{const Ce=Pe.filter(Ge=>Ge.profileId===H&&Ge.authorizationId!==he).map(Ge=>({authorizationId:Ge.authorizationId,bounds:Ge.bounds,context:Ge.context??{},intent:Ge.intent}));_(Ce)}).catch(()=>_([]))},[a==null?void 0:a.profileId]),u.useEffect(()=>{if(!c)return;const H=B0(f,Xu(c));H&&H!==f&&p(H)},[c,f]),u.useEffect(()=>{if(!o||!c||D.length===0){V(0);return}let H=!1;return(async()=>{const he=await xa(o.bounds,c),Pe=await Promise.all(D.map(Ce=>xa(Ce.bounds,c).catch(()=>null)));H||V(Pe.filter(Ce=>Ce===he).length)})().catch(()=>{H||V(0)}),()=>{H=!0}},[o,c,D]);const X=async()=>{if(!(!a||!o||!c||!t)){if(!a.groupId){Z("No active group; cannot create mandate.");return}O(!0),Z("");try{const H=r||a.domain||"owner",he=await xa(o.bounds,c),Pe=await jp(o.context,c),[Ce,Ge]=await Promise.all([Ka(o.gateContent.intent),Ka(JSON.stringify({profile:a.profileId,domain:H,group:a.groupId}))]);let Tn,In,$e,ht;if(a.isTeam){const Y=await T.getApproversPubkeys(a.groupId,a.profileId);if(Y.length>0){const ue=await T.encryptIntent(o.gateContent.intent,Y);Tn=ue.intentCiphertext,In=ue.encryptedKeys,$e=ue.approversFrozen,ht=ue.intentDisclosureHash}}const bt=`authz_${crypto.randomUUID()}`,it=sessionStorage.getItem("agentEditReplaces")||void 0,U=await Sp(c),te=await T.attest({authorization_id:bt,replaces:it,profile_id:a.profileId,profile_hash:U,supported_versions:["0.7"],bounds:o.bounds,bounds_hash:he,scope_hash:Pe,domain:H,did:t.did,mandate_owners:[{did:t.did}],gate_content_hashes:{intent:Ce},execution_context_hash:Ge,group_id:a.groupId,ttl:m,commitment_mode:D0(f),title:w.trim(),intent_ciphertext:Tn,encrypted_keys:In,approvers_frozen:$e,intent_disclosure_hash:ht,disclose_identity:C});try{await T.pushGateContent(kp(te,{boundsHash:he,contextHash:Pe,context:o.context,contextLabels:o.contextLabels,gateContent:o.gateContent}))}catch(Y){try{await T.revokeAttestation(bt,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${Y instanceof Error?Y.message:"Unknown error"})`)}if(it)try{await T.revokeAttestation(it,`Replaced by ${bt} (edit)`),T.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/mandates?highlight=${encodeURIComponent(bt)}`)}catch(H){Z(H instanceof Error?H.message:"Signing the mandate failed")}finally{O(!1)}}};if(!a||!o)return s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const ne=Object.entries(o.bounds).filter(([H])=>H!=="profile"&&H!=="path"),oe=Object.entries(o.context),fe=((F==null?void 0:F.caps)!=null?Object.keys(F.caps):[]).length!==0,J=W.length>0?W.join(", "):((F==null?void 0:F.approvers)??[]).join(", "),me=fe?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${J}, 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.",re=fe?`Over-cap actions will be reviewed by you and ${J}. Within-cap actions run per the mode you chose above.`:`Approvers ${J} can read your intent but won't gate any action — no caps configured on this profile.`,ie=!!((G=F==null?void 0:F.approvers)!=null&&G.length),I=Np({isPersonal:a.isPersonal,configLoaded:z,approvers:F==null?void 0:F.approvers,userId:t==null?void 0:t.id,profileName:Fe(a.profileId),teamName:a.groupName}),K=!I.can,ae=Xu(c),ye=ae.length===0,pe=m>j,ze={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"},kt={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"},Ve=((se=c==null?void 0:c.scopeSchema)==null?void 0:se.keyOrder)??[],et=D.filter(H=>W0(Ve,o.context,H.context)),pt=et.length>0,at=Fe(a.profileId),le=H=>{const he=Object.values(H).map(Pe=>String(Pe).trim()).filter(Boolean);return he.length>0?he.join(", "):"all (unscoped)"},k=et.map(H=>le(H.context)).join("; "),B=`This grant's scope overlaps an existing grant on ${at} (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(gp,{currentStep:4,onStepClick:H=>{H<=3&&e(`/mandates/new/intent?step=${H}`)}}),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."}),a.upgradedFromProfileId&&c&&s.jsxs("div",{className:"hint-box",role:"note",style:{marginBottom:"1rem"},children:[s.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),s.jsxs("div",{className:"hint-body",children:["Updated to ",Fe(a.profileId)," ",c.version," — the current version of this profile."]})]}),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. ${Fe(a.profileId)}: daily operations`,value:w,onChange:H=>b(H.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:[ae.includes("per-action")&&s.jsxs("button",{onClick:()=>p("per-action"),style:kt,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."})]}),ae.includes("immediate")&&s.jsxs("button",{onClick:()=>p("immediate"),style:ze,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."})]})]}),ae.length===1&&s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:ae[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),ye&&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(H=>H.seconds<=j).map(H=>s.jsx("button",{onClick:()=>{x(H.seconds),g("")},style:{padding:"0.5rem 0.85rem",border:m===H.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:m===H.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:H.label},H.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:H=>{g(H.target.value);const he=parseInt(H.target.value,10);if(he>0){const Pe=h==="days"?he*86400:he*3600;x(Math.min(Pe,j))}}}),s.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:h,onChange:H=>{y(H.target.value);const he=parseInt(S,10);if(he>0){const Pe=H.target.value==="days"?he*86400:he*3600;x(Math.min(Pe,j))}},children:[s.jsx("option",{value:"hours",children:"hours"}),s.jsx("option",{value:"days",children:"days"})]})]}),pe&&s.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",j>=86400?`${Math.floor(j/86400)} days`:`${Math.floor(j/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:A||C,disabled:A,onChange:H=>N(H.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.',A&&" 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||!!oe.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:[oe.map(([H,he])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:H}),s.jsx("dd",{children:bp(H,he,o.contextLabels)})]},H)),ne.map(([H,he])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:H}),s.jsx("dd",{children:String(he)})]},H))]})]}),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:[Fe(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:z?I.can?s.jsxs(s.Fragment,{children:[J,s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:me})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{color:"var(--danger)",fontWeight:600},children:I.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${a.groupName??"this team"}`:"You cannot give this mandate"}),I.code==="OWNER_NOT_APPROVER"&&s.jsx("div",{children:J}),s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[I.reason," ",I.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 ${at} already has exactly these limits.`:`${$} active grants on ${at} 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,pt?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:X,disabled:P||!w.trim()||K||ye,children:P?"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:ie?"block":"none"},children:re})]})]})}const G0={card:"💳",mail:"✉️"};function Cp(e){return G0[e]??"🔧"}function K0(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 na(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 Q0(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 qi({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:a}){var le;const[i,o]=u.useState({}),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[p,m]=u.useState({}),[x,j]=u.useState({}),[v,S]=u.useState(void 0),[g,h]=u.useState(!1),[y,w]=u.useState(null),[b,C]=u.useState(!1),[N,A]=u.useState(!1),[E,P]=u.useState(!1),[O,L]=u.useState(!1),[Z,F]=u.useState({}),[q,W]=u.useState(null),[ee,z]=u.useState(!1),[R,D]=u.useState(null),[_,$]=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 se={};for(const H of e.credentials.fields)B.fields[H.key]!=null&&(se[H.key]=B.fields[H.key]);m(se)}if(j(B.secrets??{}),S(B.updatedAt),e.oauth){const se=((G=B.fieldNames)==null?void 0:G.includes(e.oauth.tokenStorage))??!1;h(se),se&&T.getOAuthHealth(e.id).then(H=>{k||w(H)})}}}).catch(()=>{}),()=>{k=!0}},[e.id,e.oauth]);const V=K0(e.toolGating),X=t?t.readAgeDays??null:void 0,ne=ee&&q?q.value:X,oe=async k=>{W({value:k}),z(!0),D(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 ${na(k).toLowerCase()}`),r()}catch(B){D(B instanceof Error?B.message:"Could not save")}finally{z(!1),W(null)}},de=!!e.oauth||e.credentials.fields.some(k=>!k.optional),fe=e.oauth?g:l,J=!de||fe,me=n==="starting"?"starting":J?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!g?"needs-oauth":"unconfigured",re=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 ye())}catch{a(`Failed to save ${e.name} credentials`)}finally{C(!1)}}},ie=()=>{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!==(p[B.key]??"")&&(k[B.key]=G)}return k},I=Object.keys(ie()).length>0,K=async()=>{const k=ie();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 ye())}catch{a(`Failed to update ${e.name} credentials`)}finally{C(!1)}}},ae=()=>{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),L(!1),w(null),clearInterval(k),a(`${e.name} connected — starting integration...`),T.getOAuthHealth(e.id).then(w).catch(()=>{}),await ye())}catch{}},2e3);setTimeout(()=>clearInterval(k),12e4)},ye=async()=>{P(!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{P(!1)}},pe=async()=>{try{await T.removeMcpIntegration(e.id),a(`${e.name} integration removed`),r()}catch{a(`Failed to remove ${e.name}`)}},ze=Cp(e.icon),kt=Q0(t),Ve=me==="running"?{c:"int-chip-ok",t:"Running"}:me==="starting"?{c:"int-chip-idle",t:"Starting"}:kt.chip,et=e.oauth&&g&&(y==null?void 0:y.status)==="failed",pt=de?et?{c:"int-chip-bad",t:"Auth failed"}:fe?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},at=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:ze}),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:[me!=="unconfigured"&&me!=="needs-oauth"&&s.jsxs("span",{className:`int-chip ${Ve.c}`,children:[s.jsx("span",{className:"int-dot"}),Ve.t]}),s.jsxs("span",{className:`int-chip ${pt.c}`,children:[s.jsx("span",{className:"int-dot"}),pt.t]}),ox(e,p)&&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"})}),et&&!O&&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:ae,children:["Reconnect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{o({...p}),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:((le=e.oauth.scopes)==null?void 0:le.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&&(me!=="running"||et)&&s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsxs("button",{onClick:()=>A(!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:[at(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))})]}),me==="starting"&&s.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[s.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),O&&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:Z[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(se=>({...se,[k.key]:G.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>F(G=>({...G,[k.key]:!G[k.key]})),children:Z[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(se=>({...se,[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:K,disabled:b||!I,children:b?"Saving…":"Save"}),!I&&!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:ae,children:["Connect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{L(!1),o({})},children:"Cancel"})]})]}),!O&&me==="running"&&t&&s.jsxs(s.Fragment,{children:[(Object.keys(p).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&&p[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":p[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(De,{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({...p}),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:pe,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"})]}),V&&ne!==void 0&&!_&&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":na(ne).toLowerCase()}),ee&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),R&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:R})]}),s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>$(!0),children:"Edit"})]})}),V&&ne!==void 0&&_&&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:ee,onClick:()=>oe(k),children:na(k)},k)}),s.jsx("button",{className:`btn btn-sm ${ne===null?"btn-primary":"btn-ghost"}`,"aria-pressed":ne===null,disabled:ee,onClick:()=>oe(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:na(null)})]}),s.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:R?s.jsx("span",{style:{color:"var(--danger)"},children:R}):ee?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(De,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),me==="unconfigured"&&(()=>{const k=e.credentials.fields.every(se=>se.optional),B=e.credentials.fields.some(se=>!se.optional),G=e.credentials.fields.some(se=>{var H;return(H=i[se.key])==null?void 0:H.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(se=>s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsx("label",{className:"form-label",children:se.label}),se.type==="password"?s.jsxs("div",{className:"cred-field",children:[s.jsx("input",{className:"form-input",type:Z[se.key]?"text":"password",name:`${e.id}-${se.key}-credential`,autoComplete:"new-password",placeholder:se.placeholder,value:i[se.key]||"",onChange:H=>o(he=>({...he,[se.key]:H.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>F(H=>({...H,[se.key]:!H[se.key]})),children:Z[se.key]?"hide":"show"})]}):s.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${se.key}-credential`,autoComplete:"off",placeholder:se.placeholder,value:i[se.key]||"",onChange:H=>o(he=>({...he,[se.key]:H.target.value}))})]},se.key)),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[G&&s.jsx("button",{className:"btn btn-primary",onClick:re,disabled:b||B&&!e.credentials.fields.filter(se=>!se.optional).every(se=>{var H;return(H=i[se.key])==null?void 0:H.trim()}),children:b?"Saving...":"Save & Encrypt"}),k&&!G&&s.jsx("button",{className:"btn btn-primary",onClick:ye,disabled:E,children:E?"Starting...":`Activate ${e.name}`})]})]})})(),me==="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:ae,children:["Connect ",e.name," Account"]}),s.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Change Credentials"})]})]}),me==="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:ye,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"})]})]}),me==="ready"&&t&&!t.running&&(kt.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:ye,disabled:E,children:E?"Starting...":"Start"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:pe,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:pe,children:"Disable"})})]}))]})}function J0(e,t){if(!t)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const n=e.filter(o=>bs(o.manifest)),r=e.filter(o=>!bs(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 q0({entry:e}){return s.jsxs("div",{className:"int-paused-row",children:[s.jsx("span",{"aria-hidden":"true",children:Cp(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 X0(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:a}=dc(),i=uc(),[o,l]=u.useState(""),c=u.useCallback(f=>{l(f),setTimeout(()=>l(""),5e3)},[]),d=J0(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(qi,{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(qi,{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(q0,{entry:f},f.id))]})]}),r.length===0&&s.jsx(ed,{manifestsError:n})]}):s.jsxs(s.Fragment,{children:[r.map(f=>s.jsx(qi,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:c},f.id)),r.length===0&&s.jsx(ed,{manifestsError:n})]})]})}function ed({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 Z0(){var O,L,Z;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=He(),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(""),[f,p]=u.useState(""),[m,x]=u.useState(!1),[j,v]=u.useState(""),[S,g]=u.useState("");u.useEffect(()=>{fetch("/health").then(F=>F.json()).then(F=>{typeof F.spUrl=="string"&&g(F.spUrl)}).catch(()=>{})},[]),u.useEffect(()=>{if(!e){i(null);return}T.getGroupById(e.id).then(F=>{const q=F.group??F,W=F.members??[],ee=F.isAdmin??!1,z=W.map(R=>{const D=R.userId||R.id||"",_=R.role||(ee&&D===q.createdBy?"admin":"member");return{id:D,name:R.name||D.slice(0,8)||"Member",email:R.email||"",domains:R.domains||[],role:_,isAdmin:_==="admin"||ee&&D===q.createdBy}});i({id:q.id,name:q.name,members:z})}).catch(()=>i(null))},[e==null?void 0:e.id]);const h=(a==null?void 0:a.members.filter(F=>F.isAdmin))??[],y=(e==null?void 0:e.isAdmin)===!0&&h.length<=1&&h.some(F=>F.id===(r==null?void 0:r.id)),w=(e==null?void 0:e.name)??"",b=j.trim()===w&&!o,C=()=>{v(""),x(!0)},N=()=>{x(!1),v("")},A=async()=>{if(!(!e||!b)){l(!0),d("");try{await T.leaveTeam(e.id),await n(),p("You have left the team."),i(null),N()}catch(F){d(F instanceof Error?F.message:"Failed to leave team")}finally{l(!1)}}},E=e&&S?`${S}/dashboard/groups/${e.id}`:void 0,P=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:[((O=a==null?void 0:a.members)==null?void 0:O.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"})]}),(Z=a==null?void 0:a.members)==null?void 0:Z.map(F=>s.jsxs("div",{className:"member-row",children:[s.jsx("div",{className:"member-avatar",children:F.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:F.name}),s.jsx("div",{className:"member-email",children:F.email})]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:F.role})]},F.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."}),P&&s.jsx("a",{className:"btn btn-primary btn-sm",href:P,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:F=>F.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 ",w,"?"]}),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:w})," to confirm:"]}),s.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:j,onChange:F=>v(F.target.value),placeholder:w,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:A,disabled:!b,children:o?"Leaving...":"Leave team"})]})]})})]})}const ew=new Set(["mail","users","receipt","credit-card","calendar","megaphone","archive","rocket","flask","shopping-cart","bar-chart","help-circle"]),tw={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 nw(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 Jn(e,t){const n=nw(e),r=t!=null&&t.icon&&ew.has(t.icon)?t.icon:tw[n]??"help-circle",a=Fe(e,t==null?void 0:t.name);return{icon:r,name:a,testSetup:n==="delegation"}}function hi(e){return e.startsWith("setup__")}const rw={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 Ep({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:rw[e]})}function _s({profileId:e,declared:t}){const{icon:n,name:r}=Jn(e,t);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"id-rail",children:[s.jsx(Ep,{icon:n,className:"id-rail-icon"}),s.jsx("span",{className:"id-rail-name",children:r})]}),s.jsx("div",{className:"id-sep"})]})}const Ns=e=>e.replace(/@.*$/,"").split("/").pop()??e,td=e=>e.split("@")[1]??"";function sw(e,t){const n=new Map;for(const r of e){const a=Ns(r.id);if(!t.has(a))continue;const i=n.get(a);(!i||td(r.id).localeCompare(td(i.id),void 0,{numeric:!0})>0)&&n.set(a,r)}return n}function aw(e,t,n,r){var l;const a=new Set([...t.filter(c=>c.profile).map(c=>c.profile),...r.map(c=>Ns(c.profile))]),i=sw(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,...c.intentHint?{intentHint:c.intentHint}:{}})}for(const c of r){const d=i.get(Ns(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.",...c.intentHint?{intentHint:c.intentHint}:{}})}return o}function iw(e,t,n){if(t)return e.find(r=>Ns(r.profile.id)===Ns(t)&&r.ready&&n(r))}function ow({onDismiss:e,preselectProfileId:t}){const n=on(),{group:r,groupId:a,domain:i,user:o}=He(),[l,c]=u.useState([]),[d,f]=u.useState([]),[p,m]=u.useState([]),[x,j]=u.useState([]),[v,S]=u.useState(!0),[g,h]=u.useState({});u.useEffect(()=>{Promise.all([T.listProfiles().catch(()=>[]),T.getIntegrationManifests().then(E=>E.manifests??[]).catch(()=>[]),T.getMcpHealth().catch(()=>null)]).then(async([E,P,O])=>{if(c(E),f(P),m((O==null?void 0:O.integrations)??[]),j((O==null?void 0:O.builtins)??[]),a){const L=await Promise.all(E.map(F=>T.getTeamProfileConfig(a,F.id).catch(()=>null))),Z={};E.forEach((F,q)=>{const W=L[q];W&&(Z[F.id]=W)}),h(Z)}}).finally(()=>S(!1))},[a]);const y=aw(l,d,p,x),w=E=>{var P;return Np({isPersonal:!!(r!=null&&r.isPersonal),configLoaded:!v,approvers:(P=g[E.id])==null?void 0:P.approvers,userId:o==null?void 0:o.id,profileName:Fe(E.id),teamName:r==null?void 0:r.name})},b=E=>E in g,C=(E,P)=>{if(!a){console.error("No active group when creating authorization");return}const O=b(E);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:E,groupId:a,groupName:(r==null?void 0:r.name)??null,domain:i,isTeam:O,isPersonal:!!(r!=null&&r.isPersonal),...P?{intentHint:P}:{}})),sessionStorage.removeItem("agentGate"),e==null||e(),n("/mandates/new/intent")},N=(E,P)=>{a&&C(E,P)},A=u.useRef(!1);return u.useEffect(()=>{if(v||!t||A.current)return;const E=iw(y,t,P=>w(P.profile).can);E&&(A.current=!0,N(E.profile.id,E.intentHint))},[v,t]),s.jsxs(s.Fragment,{children:[s.jsx("style",{children:`
|
|
75
|
+
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
|
|
76
|
+
.profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
|
|
77
|
+
@media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
|
|
78
|
+
@media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
|
|
79
|
+
`}),v?s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):y.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(De,{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:y.map(E=>{const P=E.profile,O=b(P.id),L=w(P),Z=!E.ready||!L.can,{icon:F}=Jn(P.id,{name:P.name,icon:P.icon});return s.jsxs("div",{className:"card",style:Z?{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(Ep,{icon:F,className:"profile-chip-icon"}),E.name]}),O?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"}):r!=null&&r.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:E.description}),L.can?E.ready?s.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>N(P.id,E.intentHint),children:"Give a mandate"}):E.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:E.unavailableReason})]}):s.jsxs(De,{to:`/integrations?setup=${E.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",E.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:[L.reason," ",s.jsx("span",{style:{color:"var(--text-tertiary)"},children:L.fix})]})]})]},E.key)})})]})}const lw={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function cw({status:e,label:t}){return s.jsx("span",{className:`status-badge status-${e}`,children:t||lw[e]})}function uw({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 Ln=86400,Jr=3600,ra=60,dw=30*Ln;function fw(e){if(e<=0)return"Expired";if(e>90*Ln){const t=Math.floor(e/dw);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*Ln){const t=Math.floor(e/Ln);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*Ln){const t=Math.floor(e/Ln),n=Math.floor(e%Ln/Jr);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*Jr){const t=Math.floor(e/Jr),n=Math.floor(e%Jr/ra);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=ra){const t=Math.floor(e/ra),n=Math.floor(e%ra);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function mw({expiresAt:e}){const[t,n]=u.useState(()=>e-Date.now()/1e3),r=t<2*Jr;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:fw(t)})}function Ya({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 pw(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 hw=[{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 gw({item:e,onClose:t,onSuccess:n}){var y;const{user:r,activeDomain:a,groupId:i}=He(),[o,l]=u.useState(null);u.useEffect(()=>{let w=!1;return T.getProfile(e.profile_id).then(b=>{var C;w||l(((C=b==null?void 0:b.ttl)==null?void 0:C.max)??null)}).catch(()=>{}),()=>{w=!0}},[e.profile_id]);const c=e.remaining_seconds??0,d=hw.filter(w=>w.seconds>c&&(o===null||w.seconds<=o)),f=((y=d[0])==null?void 0:y.seconds)??2592e3,[p,m]=u.useState(f);u.useEffect(()=>{var w;if(o!==null&&p>o){const b=(w=d[d.length-1])==null?void 0:w.seconds;b&&m(b)}},[o]);const[x,j]=u.useState(!1),[v,S]=u.useState(""),g=Object.entries(e.frame).filter(([w])=>w!=="profile"&&w!=="path"),h=async()=>{var w;if(r){j(!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),A=e.frame,E=C.context??{},P=e.attested_domains[0]||a||"owner",O=await xa(A,N),L=await jp(E,N),[Z,F]=await Promise.all([Ka(C.gateContent.intent),Ka(JSON.stringify({profile:e.profile_id,path:e.path,domain:P}))]);if(!i)throw new Error("No active group; cannot extend mandate.");const q=(((w=e.deferred_commitment_domains)==null?void 0:w.length)??0)>0?"review":"automatic",W=await Sp(N),ee=await T.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,profile_hash:W,supported_versions:["0.7"],bounds:A,bounds_hash:O,scope_hash:L,domain:P,did:r.did,mandate_owners:[{did:r.did}],gate_content_hashes:{intent:Z},execution_context_hash:F,group_id:i,commitment_mode:q,ttl:p});await T.pushGateContent(kp(ee,{boundsHash:O,contextHash:L,context:E,path:e.path,gateContent:C.gateContent})),n()}catch(b){S(b instanceof Error?b.message:"Extension failed")}finally{j(!1)}}};return s.jsx("div",{className:"modal-backdrop",onClick:w=>w.target===w.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:[Fe(e.profile_id)," / ",e.path]}),g.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:g.map(([w,b])=>`${w}=${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 ",pw(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(w=>s.jsx("button",{className:`btn ${p===w.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>m(w.seconds),style:{minWidth:"3.5rem"},children:w.label},w.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 nd(e){return e.replace(/@.*$/,"").split("/").pop()??e}function rd(e){return e.split("@")[1]??""}function yw(e,t){return rd(e).localeCompare(rd(t),void 0,{numeric:!0})>0}function vw(e,t){const n=nd(e);let r;for(const a of t)nd(a.id)===n&&(!r||yw(a.id,r.id))&&(r=a);return r}function Tp(e,t){var r;if(!t)return{};const n={};for(const a of t.keyOrder){if(a==="profile"||a==="path")continue;if(e[a]!==void 0){n[a]=e[a];continue}const i=(r=t.fields[a])==null?void 0:r.default;(typeof i=="string"||typeof i=="number"&&Number.isFinite(i))&&(n[a]=i)}return n}function xw(e,t){return Tp(e,t.boundsSchema)}function ww(e,t){return Tp(e,t.scopeSchema)}function jw(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=Va(r,t),o=Va(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 Sw({item:e,newerProfile:t,revokedSet:n,expandedHash:r,gateCache:a,gateLoading:i,copiedHash:o,revokingHash:l,copyingHash:c,profileConfigCache:d,mode:f,ownerLabel:p,isAdmin:m,onExpand:x,onCopyHash:j,onCopy:v,onRevoke:S,onExtend:g,archivedSet:h,archivingHash:y,onArchive:w,highlightHash:b,needsReapprovalSet:C}){var me;const N=cc(e,{revokedSet:n}),A=N==="active"&&((C==null?void 0:C.has(e.authorization_id))??!1),E=tp(e,{revokedSet:n,archivedSet:h}),P=!p&&!!w&&ep(N),O=r===e.authorization_id,L=a[e.authorization_id],Z=N==="active"||N==="pending"||N==="expired",F=Object.entries(e.frame).filter(([re])=>re!=="profile"&&re!=="path"),q=d.get(e.profile_id)??null,W=(((me=q==null?void 0:q.approvers)==null?void 0:me.length)??0)>0,ee=new Map;if(q!=null&&q.caps&&f==="team")for(const[re,ie]of F){const I=q.caps[re];I!==void 0&&Number(ie)>I&&ee.set(re,{authorized:Number(ie),cap:I})}const z=ee.size>0,R=e.approvers_frozen??[],D=(q==null?void 0:q.approvers)??[],_=f==="team"&&R.length>0&&D.length>0&&(R.length!==D.length||R.some(re=>!D.includes(re))||D.some(re=>!R.includes(re))),$=Array.from(ee.entries()).map(([re,ie])=>`${re}: ${ie.authorized} (cap ${ie.cap})`).join(", "),V=Array.from(ee.entries()).map(([re,ie])=>`${re}: ${ie.authorized} → ${ie.cap}`).join(", "),X=z?W?ee.size===1?`Above team cap: ${$} — actions require approval`:`Above team cap (${ee.size}): ${$} — actions require approval`:ee.size===1?`Reduced by hard cap: ${V}`:`Reduced by hard cap (${ee.size}): ${V}`:"",ne=z?W?"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,oe=Jn(e.profile_id),de=oe.name,fe=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:[de,"@",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,J=b!=null&&e.authorization_id===b;return s.jsxs("div",{className:`card id-card${J?" card-highlight":""}`,style:{marginBottom:0},children:[s.jsx(_s,{profileId:e.profile_id}),s.jsxs("div",{className:"id-body",children:[fe,p&&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:p})]}),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||de}),s.jsx(cw,{status:N}),A&&s.jsx("span",{title:"The Authority Server no longer verifies this mandate's protocol version. Re-approve it to keep using this authority.",style:{fontSize:"0.75rem",fontWeight:700,color:"var(--text-on-warning, #7a4a00)",background:"var(--warning-bg, #fff3cd)",borderRadius:"4px",padding:"2px 6px"},children:"Needs re-approval"}),oe.testSetup&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),N==="active"&&e.earliest_expiry&&s.jsx(mw,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),N==="expired"&&(()=>{const re=ix(e,N);return re?s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(re.iso).toLocaleString()}`,children:new Date(re.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(re=>s.jsx(uw,{domain:re,attested:e.attested_domains.includes(re)},re)),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"}),z&&s.jsx("span",{title:ne,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:W?"var(--accent-subtle)":"var(--danger-subtle)",color:W?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:X}),_&&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"})]}),F.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:F.map(([re,ie],I)=>{const K=ee.get(re);return s.jsxs("span",{children:[I>0&&" · ",K?W?s.jsxs("span",{title:`Team cap on ${re} is ${K.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${K.authorized}.`,children:[s.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[re,"=",String(ie)]}),s.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",K.cap]})]}):s.jsxs("span",{title:`Team cap on ${re} is ${K.cap} with no approvers configured (hard cap). Authorized for ${K.authorized}; effective ${K.cap}.`,children:[s.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[re,"=",String(ie)]}),s.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",K.cap]})]}):s.jsxs("span",{children:[re,"=",String(ie)]})]},re)})}),s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[P&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>w(e.authorization_id,!E),disabled:y===e.authorization_id,title:E?"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?E?"Unarchiving…":"Archiving…":E?"↩ Unarchive":"⊟ Archive"}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>x(e),children:O?"▲ Hide Details":"▼ Details"})]}),O&&s.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[F.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:F.map(([re,ie])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:re}),s.jsx("dd",{children:String(ie)})]},re))})]}),(L==null?void 0:L.context)&&Object.keys(L.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(L.context).map(([re,ie])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:re}),s.jsx("dd",{title:String(ie),children:bp(re,ie,L.contextLabels)})]},re))})]}),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..."}):L?s.jsx("div",{className:"gate-content-block",children:s.jsx("div",{className:"gate-content-item",children:s.jsx("div",{className:"gate-content-text",children:L.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:()=>j(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:[!p&&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"}),!p&&(N==="active"||N==="pending")&&s.jsx("button",{className:A?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>v(e,{asEdit:!0}),disabled:c===e.authorization_id,title:A?"The Authority Server no longer verifies this mandate's protocol version. Re-approving opens the ceremony pre-filled with the same bounds, scope, and intent; signing it revokes this one.":"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:A?"⚠ Re-approve":"✎ Edit"}),!p&&Z&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>g(e),children:"↻ Extend"}),p&&m&&N!=="revoked"?s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>S(e.authorization_id,p,de),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):!p&&(N==="active"||N==="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 kw(){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,p]=u.useState("mine"),[m,x]=u.useState("active"),[j,v]=u.useState(null),[S,g]=u.useState(null),[h,y]=ic(),[w,b]=u.useState(()=>h.get("new")==="1"),[C]=u.useState(()=>h.get("profile")),[N,A]=u.useState(()=>h.get("highlight")),[E,P]=u.useState(null),[O,L]=u.useState({}),[Z,F]=u.useState(null),[q,W]=u.useState(null),[ee,z]=u.useState(null),[R,D]=u.useState(new Set),[_,$]=u.useState(null),[V,X]=u.useState(new Set),[ne,oe]=u.useState(null),[de,fe]=u.useState(null),[J,me]=u.useState(new Set),re=on(),{group:ie,groupId:I,domain:K,mode:ae,activeTeam:ye}=He(),pe=(ye==null?void 0:ye.isAdmin)===!0,[ze,kt]=u.useState(()=>new Map),Ve=u.useCallback(()=>{r(!0),T.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),et=u.useCallback(()=>{T.getArchivedMandates().then(U=>X(new Set(U))).catch(()=>{})},[]);u.useEffect(()=>{et()},[et]);const pt=u.useCallback(()=>{T.getEnrichedAuthorizations().then(U=>me(new Set(U.filter(te=>te.needsReapproval).map(te=>te.authorizationId)))).catch(()=>{})},[]);u.useEffect(()=>{pt()},[pt]);const at=async(U,te)=>{oe(U);try{const Y=await T.setMandateArchived(U,te);X(new Set(Y)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(Y){alert(Y instanceof Error?Y.message:"Failed to update archive")}finally{oe(null)}},le=u.useCallback(()=>{I&&(l(!0),T.listTeamAuthorizations(I).then(i).catch(()=>{}).finally(()=>l(!1)))},[I]);ve("attestation-changed",()=>{Ve(),pe&&I&&le(),pt()}),u.useEffect(()=>{if(!N)return;h.get("highlight")&&(h.delete("highlight"),y(h,{replace:!0}));const U=window.setTimeout(()=>A(null),3e3);return()=>window.clearTimeout(U)},[]),$t(Ve,3e5),u.useEffect(()=>{f==="team"&&pe&&I&&a.length===0&&!o&&le()},[f,pe,I,a.length,o,le]),u.useEffect(()=>{let U=!1;return T.listProfiles().then(te=>{if(U)return;const Y=ot=>ot.replace(/@.*$/,"").split("/").pop()??ot,ue=ot=>ot.split("@")[1]??"",je=new Map;for(const ot of te){const Ut=Y(ot.id),Ls=je.get(Ut);(!Ls||ue(ot.id).localeCompare(ue(Ls.id),void 0,{numeric:!0})>0)&&je.set(Ut,ot)}d(je)}).catch(()=>{}),()=>{U=!0}},[]);const k=u.useCallback(U=>{const te=Ut=>Ut.replace(/@.*$/,"").split("/").pop()??Ut,Y=Ut=>Ut.split("@")[1]??"",ue=c.get(te(U));if(!ue)return;const je=Y(U),ot=Y(ue.id);if(!(!je||!ot))return ot.localeCompare(je,void 0,{numeric:!0})>0?ue:void 0},[c]);u.useEffect(()=>{if(ae!=="team"||!I)return;const U=f==="mine"?e:a;if(U.length===0)return;const te=[...new Set(U.map(Y=>Y.profile_id))].filter(Y=>!ze.has(Y));if(te.length!==0){kt(Y=>{const ue=new Map(Y);for(const je of te)ue.set(je,null);return ue});for(const Y of te)T.getTeamProfileConfig(I,Y).then(ue=>{kt(je=>new Map(je).set(Y,ue))}).catch(()=>{})}},[e,a,f,I,ae,ze]);const B=async U=>{if(E===U.authorization_id){P(null);return}P(U.authorization_id);const te=U.authorization_id;if(!(te in O)){F(U.authorization_id);try{const Y=await T.getGateContent(te);L(ue=>({...ue,[te]:Y}))}catch{L(Y=>({...Y,[te]:null}))}finally{F(null)}}},G=U=>{navigator.clipboard.writeText(U).then(()=>{z(U),setTimeout(()=>z(null),2e3)})},se=async(U,te)=>{var Y;if(!I){alert("No active group; cannot copy mandate.");return}fe(U.authorization_id);try{const ue=U.authorization_id;let je=O[ue]??null;ue in O||(je=await T.getGateContent(ue),L(Rn=>({...Rn,[ue]:je})));const ot=Object.fromEntries(Object.entries(U.frame).filter(([Rn])=>Rn!=="profile"&&Rn!=="path")),Ut=(je==null?void 0:je.context)??{},Ls=((Y=je==null?void 0:je.gateContent)==null?void 0:Y.intent)??"",$p=U.deferred_commitment_domains.length>0?"review":"automatic",Mp=U.attested_domains[0]||K||"owner",gi=Date.parse(U.created_at),yi=U.earliest_expiry?Date.parse(U.earliest_expiry):NaN,Fp=Number.isFinite(gi)&&Number.isFinite(yi)&&yi>gi?Math.round((yi-gi)/1e3):void 0;let vc=U.profile_id,xc=ot,wc=Ut,jc;const Op=await T.listProfiles(),zs=vw(U.profile_id,Op);if(zs&&zs.id!==U.profile_id){const Rn=await T.getProfile(zs.id);vc=zs.id,xc=xw(ot,Rn),wc=ww(Ut,Rn),jc=U.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:vc,groupId:I,groupName:(ie==null?void 0:ie.name)??null,domain:Mp,isPersonal:!!(ie!=null&&ie.isPersonal),upgradedFromProfileId:jc})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:xc,context:wc,gateContent:{intent:Ls},templateMode:$p,templateTtl:Fp})),te!=null&&te.asEdit?sessionStorage.setItem("agentEditReplaces",U.authorization_id):sessionStorage.removeItem("agentEditReplaces"),re("/mandates/new/intent")}catch(ue){alert(ue instanceof Error?ue.message:"Failed to copy mandate")}finally{fe(null)}},H=async(U,te,Y)=>{const ue=te&&Y?`Revoke ${te}'s ${Y} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(ue)){$(U);try{await T.revokeAttestation(U),D(je=>new Set(je).add(U)),T.resyncGates().catch(()=>{}),te&&I&&le()}catch(je){alert(je instanceof Error?je.message:"Failed to revoke mandate")}finally{$(null)}}},he=f==="mine"?e:a,Pe=f==="mine"?n:o,Ce=f==="mine"?{revokedSet:R,archivedSet:V}:{revokedSet:R},Ge=U=>Va(U,Ce),Tn={active:0,pending:0,expired:0,revoked:0,archived:0};for(const U of he)Tn[Ge(U)]+=1;const In=f==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],$e=(()=>{const U=new Map;for(const te of he){if(Ge(te)!==m)continue;const Y=U.get(te.profile_id)??{count:0,review:!1};Y.count+=1,te.deferred_commitment_domains.length>0&&(Y.review=!0),U.set(te.profile_id,Y)}return Array.from(U.entries()).map(([te,Y])=>({profileId:te,...Y})).sort((te,Y)=>Fe(te.profileId).localeCompare(Fe(Y.profileId)))})(),ht=jw(he.filter(U=>{if(Ge(U)!==m||j!==null&&U.profile_id!==j)return!1;if(S!==null){const te=U.deferred_commitment_domains.length>0;if(S==="review"&&!te||S==="auto"&&te)return!1}return!0}),Ce,N),bt={revokedSet:R,expandedHash:E,gateCache:O,gateLoading:Z,copiedHash:ee,revokingHash:_,copyingHash:de,profileConfigCache:ze,mode:ae,activeDomain:K,group:ie,groupId:I,onExpand:B,onCopyHash:G,onCopy:se,onRevoke:H,onExtend:W,highlightHash:N},it={...bt,archivedSet:V,archivingHash:ne,onArchive:at,needsReapprovalSet:J};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"})]}),w&&s.jsx("div",{className:"modal-backdrop",onClick:()=>{b(!1),(h.get("new")||h.get("profile"))&&(h.delete("new"),h.delete("profile"),y(h,{replace:!0}))},children:s.jsxs("div",{className:"modal",onClick:U=>U.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.get("profile"))&&(h.delete("new"),h.delete("profile"),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(ow,{onDismiss:()=>b(!1),preselectProfileId:C})]})]})}),pe&&s.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[s.jsx("button",{className:`nav-tab${f==="mine"?" active":""}`,onClick:()=>{p("mine"),x("active"),v(null),g(null),P(null)},children:"Mine"}),s.jsx("button",{className:`nav-tab${f==="team"?" active":""}`,onClick:()=>{p("team"),x("active"),v(null),g(null),P(null)},children:"Team"})]}),s.jsx("div",{className:"nav-tabs",children:In.map(U=>s.jsxs("button",{className:`nav-tab${m===U?" active":""}`,onClick:()=>{x(U),v(null),g(null)},children:[U.charAt(0).toUpperCase()+U.slice(1)," (",Tn[U],")"]},U))}),$e.length>0&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[$e.map(U=>{const te=j===U.profileId;return s.jsx("button",{className:`btn btn-sm ${te?"btn-primary":"btn-secondary"}`,onClick:()=>v(te?null:U.profileId),children:Fe(U.profileId)},U.profileId)}),s.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(U=>{const te=S===U;return s.jsx("button",{className:`btn btn-sm ${te?"btn-primary":"btn-secondary"}`,onClick:()=>g(te?null:U),children:U==="auto"?"Auto":"Review"},U)})]}),Pe&&he.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ht.length===0?s.jsx(Ya,{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:ht.map(U=>{const te=f==="team"?U:null,Y=te!=null&&te.owner?te.owner.name??te.owner.email??te.owner.userId:void 0;return s.jsx(Sw,{item:U,newerProfile:k(U.profile_id),ownerLabel:Y,isAdmin:pe,...f==="mine"?it:bt},U.authorization_id)})}),q&&s.jsx(gw,{item:q,onClose:()=>W(null),onSuccess:()=>{W(null),Ve()}})]})}function bw(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function Nw(e,t){var c,d,f;const{integrationId:n,toolName:r}=bw(e.action),a=t.find(p=>p.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=Fe(e.profileId),l=(f=e.executionContext)==null?void 0:f.action_type;return typeof l=="string"&&l?`${o} · ${l}`:`${o} · ${r}`}function Cw(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 Ew(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 Tw(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`,p=Object.keys(t??{}).filter(S=>S.endsWith(f)),m=(r&&p.find(S=>S.startsWith(`${r}_`)))??(p.length===1?p[0]:void 0),j=(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(`${j} of ${v} ${c}`):a.push(`${d.count} ${d.count===1?"call":"calls"} ${c}`)}return a.join(" · ")}function Iw(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function Rw(e){const t=Fe(e),n=e.split("@")[1];return n?`${t}@${n}`:t}function Wr({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 Aw({receipt:e,manifests:t,localAuth:n,localUnavailable:r,signature:a,grantTitle:i,ownerLabel:o,spUrl:l,formatDate:c,onOpenComplete:d}){var v;const f=Cw(e),p=Ew(n==null?void 0:n.context),m=Tw(e,(n==null?void 0:n.bounds)??e.limits),x=n==null?void 0:n.intent,j=Jn(e.profileId).testSetup||hi(e.action);return s.jsxs("div",{className:"card id-card",style:{marginBottom:0},children:[s.jsx(_s,{profileId:e.profileId}),s.jsxs("div",{className:"id-body",children:[s.jsxs("div",{className:"receipt-head",children:[s.jsx("span",{className:"receipt-what",children:Nw(e,t)}),s.jsx("span",{className:"receipt-tag",children:Iw(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"}),j&&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(Wr,{label:"mandate",children:s.jsx("strong",{children:i||Rw(e.profileId)})}),o&&s.jsx(Wr,{label:"owner",children:o}),p&&s.jsx(Wr,{label:"allowed",children:p}),m&&s.jsx(Wr,{label:"used",children:s.jsx("span",{className:"receipt-num",children:m})}),s.jsx(Wr,{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 Pw({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,p]=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 j(){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),p(!0),setTimeout(()=>p(!1),2e3)}catch{p(!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:j,children:"Download"}),s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:v,children:f?"Copied":"Copy"})]})]})})}function _w(e){return new Date(e*1e3).toLocaleString()}function Lw(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 zw(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||Fe(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 sd(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 $w(){const{activeTeam:e,groupId:t}=He(),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(""),[p,m]=u.useState(!0),[x,j]=u.useState({}),[v,S]=u.useState(new Set),[g,h]=u.useState(""),[y,w]=u.useState(new Set),[b,C]=u.useState(new Set),[N,A]=u.useState("all"),[E,P]=u.useState(!1),[O,L]=u.useState(!1),[Z,F]=u.useState(null),[q,W]=u.useState({}),[ee,z]=u.useState(!1),[R,D]=u.useState({}),[_,$]=u.useState({}),[V,X]=u.useState(null),[ne,oe]=u.useState(null),[de,fe]=u.useState(!1),[J,me]=u.useState(!1),re=u.useRef(""),ie=u.useCallback(k=>r==="team"&&n&&t?T.listTeamReceiptsPage(t,{before:k,limit:200}):T.getMyReceiptsPage({before:k,limit:200}),[r,n,t]),I=u.useCallback(()=>{const k=r==="team"?`team:${t}`:"mine",B=re.current!==k;re.current=k,m(!0),me(!1),ie().then(G=>{o(se=>B?G.receipts:sd(se,G.receipts)),oe(se=>B?G.nextBefore:se??G.nextBefore)}).catch(()=>{B&&o([]),me(!0)}).finally(()=>m(!1))},[ie,r,t]),K=u.useCallback(()=>{!ne||de||(fe(!0),me(!1),ie(ne).then(k=>{o(B=>sd(B,k.receipts)),oe(k.nextBefore)}).catch(()=>me(!0)).finally(()=>fe(!1)))},[ne,de,ie]);$t(I,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})=>{W(k),D(B),z(!1)}).catch(()=>{W({}),D({}),z(!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};j(B)}).catch(()=>{})},[r,x]);const ae=u.useMemo(()=>{const k=new Set;for(const B of i)k.add(Fe(B.profileId));return[...k].sort()},[i]),ye=u.useMemo(()=>{const k=new Set;for(const B of i)k.add(B.action);return[...k].sort()},[i]),pe=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]),ze=u.useMemo(()=>i.filter(k=>!(!zw(k,g)||y.size>0&&!y.has(Fe(k.profileId))||b.size>0&&!b.has(k.action)||v.size>0&&k.userId&&!v.has(k.userId)||!Lw(k,N))),[i,g,y,b,v,N]),kt=y.size>0||b.size>0||v.size>0||N!=="all";function Ve(k){w(B=>{const G=new Set(B);return G.has(k)?G.delete(k):G.add(k),G})}function et(k){C(B=>{const G=new Set(B);return G.has(k)?G.delete(k):G.add(k),G})}function pt(k){S(B=>{const G=new Set(B);return G.has(k)?G.delete(k):G.add(k),G})}function at(){w(new Set),C(new Set),S(new Set),A("all"),h("")}async function le(){L(!0),F(null);try{const{bundle:k,filename:B}=await T.fetchEvidenceBundle(),G=URL.createObjectURL(new Blob([JSON.stringify(k,null,2)],{type:"application/json"})),se=document.createElement("a");se.href=G,se.download=B,se.click(),URL.revokeObjectURL(G);const H=k.sources??{};H.authorityServer?H.local||F(`Downloaded Authority Server history only — ${H.localError??"local archive unavailable."}`):F(`Downloaded local evidence only — ${H.asError??"Authority Server export unavailable."}`)}catch(k){F(`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:le,disabled:O,children:O?"Preparing…":"Download evidence"})]}),Z&&s.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:Z}),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:()=>P(!E),children:["Filters",kt?` (${y.size+b.size+(N!=="all"?1:0)})`:""]})]}),E&&s.jsxs("div",{className:"filter-panel",children:[ae.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Profile"}),s.jsx("div",{className:"filter-chips",children:ae.map(k=>s.jsx("button",{className:`filter-chip${y.has(k)?" selected":""}`,onClick:()=>Ve(k),children:k},k))})]}),ye.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Action"}),s.jsx("div",{className:"filter-chips",children:ye.map(k=>s.jsx("button",{className:`filter-chip${b.has(k)?" selected":""}`,onClick:()=>et(k),children:k},k))})]}),r==="team"&&pe.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Owner"}),s.jsx("div",{className:"filter-chips",children:pe.map(k=>s.jsx("button",{className:`filter-chip${v.has(k.id)?" selected":""}`,onClick:()=>pt(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:()=>A(k),children:B},k))})]})]}),kt&&s.jsxs("div",{className:"active-filters",children:[[...y].map(k=>s.jsxs("span",{className:"active-chip",onClick:()=>Ve(k),children:[k," ",s.jsx("span",{className:"chip-remove",children:"×"})]},k)),[...b].map(k=>s.jsxs("span",{className:"active-chip",onClick:()=>et(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:()=>pt(k),children:[G," ",s.jsx("span",{className:"chip-remove",children:"×"})]},k)}),N!=="all"&&s.jsxs("span",{className:"active-chip",onClick:()=>A("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:at,children:"Clear all"})]}),J&&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."})}),p&&i.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ze.length===0?s.jsx(Ya,{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:ze.length===i.length?`${i.length} ticket${i.length!==1?"s":""}`:`${ze.length} of ${i.length} tickets`}),s.jsx("div",{className:"timeline",children:ze.map(k=>{const B=k.userId?x[k.userId]:void 0;return s.jsx("div",{className:"timeline-event",children:s.jsx(Aw,{receipt:k,manifests:l,localAuth:k.authorizationId?q[k.authorizationId]:void 0,localUnavailable:ee,signature:R[k.id],grantTitle:k.authorizationId?_[k.authorizationId]:null,ownerLabel:r==="team"&&k.userId?B?`${B.name} (${B.email})`:k.userId:null,spUrl:d,formatDate:_w,onOpenComplete:()=>X(k)})},k.id)})})]}),V&&s.jsx(Pw,{receipt:V,onClose:()=>X(null)}),ne&&s.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:K,disabled:de,children:de?"Loading…":"Load older"})})]})}const Mw={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function Fw(){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=Mw[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 Ow(){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 ad={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function Dw(){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"?`${ad.as_vouched} ${e.verifier}`:ad[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 Bw={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 Uw(){const{version:e,latestVersion:t,updateAvailable:n,installMethod:r}=oc();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:[Bw[r]??"Update checking is unavailable",r==="dev"&&s.jsx(s.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function el({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 id(e){return e===!0}function Ww(){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=id(e==null?void 0:e.asUrlLockedByPolicy),i=id(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(el,{})]}),!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(el,{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 Hw(){const{simulation:e,locked:t}=hp();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(el,{})]}),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 Vw={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"]}},Hr=["AI Assistant","Authority Server","This computer","Security","Version"],Vr={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function Gw(){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,p]=u.useState(""),[m,x]=u.useState(!1),[j,v]=u.useState(!1),[S,g]=u.useState(!1),[h,y]=u.useState(null),[w,b]=u.useState([]),[C,N]=u.useState(!1),[A,E]=u.useState(null),[P,O]=u.useState(""),L=u.useCallback(R=>{t(R),setTimeout(()=>t(""),3e3)},[]),Z=u.useCallback(async(R,D,_)=>{N(!0),E(null);try{const $=await T.aiModels({provider:R,endpoint:D,..._?{apiKey:_}:{}});$.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)}},[]),F=u.useCallback(async()=>{try{const R=await T.getCredential("ai-config");if(x(R.configured),R.configured&&R.fields){const D=R.fields.provider||"openai-compatible",_=R.fields.endpoint||"";R.fields.provider&&i(D),R.fields.endpoint&&l(_),R.fields.model&&d(R.fields.model),_.includes("openai.com")?r("openai"):_.includes("groq.com")?r("groq"):_.includes("together.xyz")?r("together"):_.includes("openrouter.ai")?r("openrouter"):r("ollama"),_&&Z(D,_)}}catch{}},[Z]);u.useEffect(()=>{F()},[F]);const q=R=>{r(R),b([]),E(null),O("");const D=Vw[R];D&&(i(D.provider),l(D.endpoint),d(""),Z(D.provider,D.endpoint,f||void 0))},W=()=>Z(a,o,f||void 0),ee=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)}},z=async()=>{g(!0),y(null);try{const R=await T.aiTest({provider:a,endpoint:o,model:c,...f?{apiKey:f}:{}});y(R.ok?`OK: ${R.message}`:`Failed: ${R.message}`)}catch(R){y(`Error: ${R instanceof Error?R.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:Vr,children:Hr[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:R=>q(R.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:R=>p(R.target.value),onBlur:()=>{f.trim()&&Z(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:W,disabled:C,title:"Re-fetch the model list from the provider",children:C?"Loading…":"↻ Refresh"})]}),w.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 R=w,D=R.includes(c),_=R.length>12,$=P.trim().toLowerCase();let V=$?R.filter(X=>X.toLowerCase().includes($)):R;return D&&!V.includes(c)&&(V=[c,...V]),s.jsxs(s.Fragment,{children:[_&&s.jsx("input",{className:"form-input",value:P,onChange:X=>O(X.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),s.jsxs("select",{className:"form-input",value:D?c:"__unset__",onChange:X=>d(X.target.value==="__unset__"?"":X.target.value),children:[s.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),V.map(X=>s.jsx("option",{value:X,children:X},X)),$&&V.length===0&&s.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",P,"”"]})]})]})})(),A&&s.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:A})]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[s.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:j||!c.trim(),title:c.trim()?void 0:"Select a model first",children:j?"Saving...":"Save & Encrypt"}),m&&s.jsx("button",{className:"btn btn-ghost",onClick:z,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(Kw,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Vr,children:Hr[1]}),s.jsx(Ww,{}),s.jsx(Dw,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Vr,children:Hr[2]}),s.jsx(Fw,{}),s.jsx(Ow,{}),s.jsx(Hw,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Vr,children:Hr[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:Vr,children:Hr[4]}),s.jsx(Uw,{})]})]})}function Kw(){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,p]=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}),p(!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)}}},j=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(od,{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:()=>j("intent"),saving:a==="intent",justSaved:c==="intent"}),s.jsx(od,{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:()=>j("context"),saving:a==="context",justSaved:c==="context"})]})]})}function od({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:p=>i(p.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 Yw(e){return e.proposalId?"review":"automatic"}function ld(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=Yw(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 Qw=["https://","http://"];function Ip(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)?[]:Qw.some(a=>r.toLowerCase().startsWith(a))?[{label:n.label,href:r,description:n.description}]:[]}):[]}function Rp(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 Jw=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function Ap(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 qw(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
|
|
80
|
+
`)||e.length>120)?"markdown":"text"}function Xw(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)||Jw.has(c))continue;const d=e[c],f=n[c]??{},p=f.kind??qw(d),m={key:c,label:f.label??Ap(c),kind:p,value:d,hint:(l=r[c])==null?void 0:l.description};p==="money"&&f.currencyArg&&typeof e[f.currencyArg]=="string"&&(m.currency=e[f.currencyArg]),p==="profile"&&typeof d=="string"&&(m.profileRef=d),(p==="profile-limits"||p==="profile-scope")&&f.profileArg&&typeof e[f.profileArg]=="string"&&(m.profileRef=e[f.profileArg]),i.push(m)}return i}function Zw(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.scopeSchema,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=vp(d==null?void 0:d.unit),p=Array.isArray(c)?c.join(", "):String(c);o.push({key:l,label:(d==null?void 0:d.displayName)??Ap(l),value:f?`${p} ${f}`:p,hint:d==null?void 0:d.description,unknown:t?!d:void 0})}return o}const cd=new Map;function ej(e){let t=cd.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}})(),cd.set(e,t)),t}function Pp(e){const[t,n]=u.useState(null);return u.useEffect(()=>{let r=!0;return e&&ej(e).then(a=>{r&&n(a)}),()=>{r=!1}},[e]),t}const tj=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function nj(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:tj.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function Zn(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 ud({row:e,which:t}){const n=Pp(e.profileRef),r=Zw(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 rj({row:e}){const t=Pp(e.profileRef),n=(t==null?void 0:t.id)??e.profileRef??"";return s.jsxs(s.Fragment,{children:[(t==null?void 0:t.name)??Fe(n),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:n})]})}function sj({row:e,altText:t}){switch(e.kind){case"profile":return s.jsx(rj,{row:e});case"profile-limits":return s.jsx(ud,{row:e,which:"limits"});case"profile-scope":return s.jsx(ud,{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:Zn(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:Zn(n)},r))}):s.jsx(s.Fragment,{children:Zn(e.value)});case"money":return s.jsxs(s.Fragment,{children:[Zn(e.value),e.currency?` ${e.currency}`:""]});case"object":return s.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Zn(e.value)});default:return nj(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:Zn(e.value)})}}function _p({args:e,display:t}){const n=Xw(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(sj,{row:a,altText:r})})]},a.key))})]})}const aj={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},ij={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function oj(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 lj(e){return e.split("__").pop()??e}function cj(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}function Lp(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=>Lp(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function dd({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=lj(c),f=cj(c),p=o?e.proposal.toolArgs:null,m=o?e.proposal.executionContext:e.receipt.executionContext,x=o?null:e.receipt.cumulativeState,j=o?Ip(a,e.proposal.toolArgs):[],v=Object.entries(m??{}),S=Jn(e.profileId).testSetup||hi(c);return s.jsxs("div",{className:"card id-card",children:[s.jsx(_s,{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=Rp(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 ${ij[l]}`,children:aj[l]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:oj(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(p==null?void 0:p._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:p._imagePreview,alt:typeof(p==null?void 0:p.altText)=="string"?p.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),j.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:j.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&&p&&s.jsx(_p,{args:p,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}=${Lp(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 zp(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=>zp(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function uj(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 dj({proposal:e,currentUserId:t,onAction:n,onMessage:r,proposalLinks:a,toolDisplay:i}){const[o,l]=u.useState(!1),[c,d]=u.useState(!1),[f,p]=u.useState(null),[m,x]=u.useState(!1),[j,v]=u.useState(null),[S,g]=u.useState(!1),h=e.tool.split("__").pop()??e.tool,y=Object.entries(e.executionContext),w=Ip(a,e.toolArgs),b=Jn(e.profileId).testSetup||hi(e.tool),C=e.pendingApprovers??[],N=e.approvedBy??{},A=Object.keys(N).length,E=C.filter(W=>!(W in N)).length,P=t in N,O=async()=>{if(f===null){x(!0),v(null);try{const W=await T.getAttestationIntent(e.authorizationId);if(!W){v("Intent not available or you are not an authorized approver.");return}const ee=await T.decryptIntent({intentCiphertext:W.intentCiphertext,encryptedKey:W.encryptedKey,approverId:t});p(ee)}catch(W){v(W instanceof Error?W.message:"Failed to decrypt intent")}finally{x(!1)}}},L=async()=>{S?g(!1):(g(!0),await O())},Z=async()=>{if(mc()){r(pc);return}l(!0),r("");try{await T.approveProposal(e.id);try{if(f===null){const W=await T.getAttestationIntent(e.authorizationId);if(W){const ee=await T.decryptIntent({intentCiphertext:W.intentCiphertext,encryptedKey:W.encryptedKey,approverId:t});p(ee),await T.storeApprovedIntent(e.authorizationId,ee)}}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(W){r(W instanceof Error?W.message:"Approval failed")}finally{l(!1)}},F=async()=>{const W=prompt("Rejection reason (optional):");if(W!==null){d(!0),r("");try{await T.rejectProposal(e.id,W||void 0),r("Action rejected."),n()}catch(ee){r(ee instanceof Error?ee.message:"Rejection failed")}finally{d(!1)}}},q=o||c;return s.jsxs("div",{className:"card id-card",children:[s.jsx(_s,{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 W=Rp(e.expiresAt,Date.now());return s.jsx("span",{style:{fontSize:"0.72rem",color:W.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:W.urgent?600:400,whiteSpace:"nowrap"},children:W.label})})(),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:uj(e.createdAt)})]})]}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[A," of ",C.length," approver",C.length===1?"":"s"," signed off",C.map(W=>{const ee=W in N;return s.jsxs("span",{style:{marginLeft:"0.5rem",color:ee?"var(--success, green)":"var(--text-tertiary)"},children:[ee?"✓":"○"," ",W===t?"You":W]},W)})]}),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})]}),w.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:w.map(W=>s.jsxs("a",{href:W.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:W.description??W.href,children:[W.label," ↗"]},W.label))}),s.jsx(_p,{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(([W,ee])=>`${W}=${zp(ee)}`).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:j?s.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:j}):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."})})]}),!P&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:Z,disabled:q,children:o?"Approving...":"Approve"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:F,disabled:q,children:c?"Rejecting...":"Reject"})]}),P&&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 fj(){const{domain:e,user:t}=He(),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({}),[p,m]=u.useState(!0),[x,j]=u.useState(""),v=u.useCallback(async()=>{try{const I=await T.getProposalsForApprover();o(I)}catch{}finally{m(!1)}},[]);ve("proposal-added",v),ve("proposal-approved",v),ve("proposal-rejected",v),ve("proposal-resolved",v),$t(v,3e4);const[S,g]=u.useState([]),h=u.useCallback(async()=>{try{const I=await T.getMyProposals(e);g(I)}catch{}},[e]);ve("proposal-added",h),ve("proposal-approved",h),ve("proposal-rejected",h),ve("proposal-resolved",h),$t(h,3e4,e);const y=u.useMemo(()=>S.filter(I=>{var K;return I.status==="pending"&&(((K=I.pendingApprovers)==null?void 0:K.length)??0)===0}),[S]),w=u.useMemo(()=>ld(y,[],{status:"pending"}),[y]),[b,C]=u.useState([]),N=u.useCallback(async()=>{if(n)try{const K=(await T.getMyProposals(e)).filter(ae=>ae.status==="pending"&&ae.pendingApprovers&&ae.pendingApprovers.includes(n)&&ae.approvedBy&&n in ae.approvedBy);C(K)}catch{}},[n,e]);ve("proposal-approved",N),ve("proposal-rejected",N),$t(N,3e4,`${n}:${e}`),u.useEffect(()=>{T.getIntegrationManifests().then(I=>c(I.manifests??[])).catch(()=>{}),T.getToolDisplay().then(f).catch(()=>{})},[]);const A=I=>{var K;return(K=l.find(ae=>ae.id===I.split("__")[0]))==null?void 0:K.proposalLinks};u.useEffect(()=>{v(),h(),N()},[]);const[E,P]=u.useState([]),[O,L]=u.useState([]),[Z,F]=u.useState(!0),[q,W]=u.useState(null),[ee,z]=u.useState(""),[R,D]=u.useState("pending"),[_,$]=u.useState(null),[V,X]=u.useState(!1),ne=u.useCallback(async()=>{try{const{proposals:I,receipts:K}=await T.getThread({domain:e,status:R,sinceDays:7});P(I),L(K)}catch{}finally{F(!1)}},[e,R]);$t(ne,3e4,`${e}:${R}`);const oe=async(I,K)=>{if(K==="commit"&&mc()){z(pc);return}W(I),z("");try{const ae=E.find(ze=>ze.id===I)??S.find(ze=>ze.id===I),ye=qv(ae,e),pe=await T.resolveProposal(I,K,ye);z(K==="commit"?`Action approved. Status: ${pe.status}`:"Action rejected."),await Promise.all([ne(),h()])}catch(ae){z(ae instanceof Error?ae.message:"Failed")}finally{W(null)}},de=u.useMemo(()=>{const I=new Set;for(const K of E)I.add(K.profileId);for(const K of O)I.add(K.profileId);return Array.from(I).sort()},[E,O]),fe=u.useMemo(()=>ld(E,O,{status:R,profile:_??void 0,includeAutonomous:V}),[E,O,R,_,V]),J=u.useCallback(()=>{v(),N()},[v,N]),me=u.useMemo(()=>{const I=new Set,K=[];for(const ae of b)I.has(ae.id)||(I.add(ae.id),K.push(ae));return K.sort((ae,ye)=>ye.createdAt-ae.createdAt)},[b]),re=i.length+w.length,ie=me.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.jsx(dp,{what:"approve"})]}),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 ",re>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:re})]}),s.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>a("awaiting-others"),children:["Awaiting others ",ie>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:ie})]}),s.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{a("all"),ne()},children:"All"})]}),r==="awaiting-me"&&s.jsx(s.Fragment,{children:p&&re===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):re===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||ee)&&s.jsx("div",{className:"alert alert-success",children:x||ee}),w.map(I=>s.jsx(dd,{proposalLinks:I.kind==="proposal"?A(I.proposal.tool):void 0,toolDisplay:I.kind==="proposal"?d[I.proposal.tool]:void 0,item:I,onApprove:K=>oe(K,"commit"),onReject:K=>oe(K,"reject"),resolving:q===I.id},I.id)),i.map(I=>s.jsx(dj,{proposal:I,currentUserId:n,onAction:J,onMessage:j,proposalLinks:A(I.tool),toolDisplay:d[I.tool]},I.id))]})}),r==="awaiting-others"&&s.jsx(s.Fragment,{children:me.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:me.map(I=>s.jsx(pj,{proposal:I,currentUserId:n,onCancel:async()=>{try{await T.rejectProposal(I.id,"cancelled by creator"),N(),h()}catch(K){alert(K instanceof Error?K.message:"Cancel failed")}}},I.id))})}),r==="all"&&s.jsxs(s.Fragment,{children:[ee&&s.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:ee}),s.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[s.jsx("button",{className:`filter-chip ${R==="pending"?"selected":""}`,onClick:()=>D("pending"),children:"Pending"}),s.jsx("button",{className:`filter-chip ${R==="all"?"selected":""}`,onClick:()=>D("all"),children:"All"}),de.length>0&&s.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),de.map(I=>s.jsx("button",{className:`filter-chip ${_===I?"selected":""}`,onClick:()=>$(_===I?null:I),children:Fe(I)},I)),R==="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 ${V?"selected":""}`,onClick:()=>X(!V),title:"Include actions executed without human review (automatic commitment mode)",children:[V?"✓ ":"","Autonomous actions"]})]})]}),Z&&fe.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):fe.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:R==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:R==="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:fe.map(I=>s.jsx(dd,{proposalLinks:I.kind==="proposal"?A(I.proposal.tool):void 0,toolDisplay:I.kind==="proposal"?d[I.proposal.tool]:void 0,item:I,onApprove:K=>oe(K,"commit"),onReject:K=>oe(K,"reject"),resolving:q===I.id},I.id))})]})]})}function mj(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 pj({proposal:e,currentUserId:t,onCancel:n}){var f;const[r,a]=u.useState(!1),i=Object.keys(e.approvedBy??{}),o=(e.pendingApprovers??[]).filter(p=>!(p 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=Jn(e.profileId).testSetup||hi(e.tool);return s.jsxs("div",{className:"card id-card",children:[s.jsx(_s,{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:mj(e.createdAt)})]}),l&&s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[i.map(p=>s.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:p===t?"You approved":`${p} approved`},p)),o.map(p=>s.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",p===t?"you":p]},p))]}),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 hj=`# Agent Brief
|
|
81
|
+
|
|
82
|
+
You act on my behalf through Suveren — the gateway that gates every
|
|
83
|
+
privileged tool call you make. Suveren implements the bounded-authority
|
|
84
|
+
model from the open Human Agency Protocol (HAP): each mandate
|
|
85
|
+
describes an area of authority, a set of numeric limits, and a scope.
|
|
86
|
+
Operate inside those bounds or the Gatekeeper will reject your action.
|
|
87
|
+
|
|
88
|
+
## Before you act in a domain
|
|
89
|
+
|
|
90
|
+
1. Call \`list-authorizations(domain: "<domain>")\` to load the full
|
|
91
|
+
intent, scope, and usage for that area. The session brief shows only
|
|
92
|
+
a one-line summary per mandate — the Intent paragraph lives behind
|
|
93
|
+
that call, and often contains soft rules you MUST honor (e.g. "never
|
|
94
|
+
publish on weekends", "only reply in English").
|
|
95
|
+
2. If the action would exceed a bound or fall outside the scope, stop
|
|
96
|
+
and explain what would be blocked instead of trying.
|
|
97
|
+
3. If you're not sure whether an action is covered, ask me first.
|
|
98
|
+
|
|
99
|
+
## How to handle reviews
|
|
100
|
+
|
|
101
|
+
Mandates in review mode require my approval before the action
|
|
102
|
+
executes. When you propose an action:
|
|
103
|
+
- Include everything I need to judge it (title, recipients, amounts,
|
|
104
|
+
dates, attendees) in the tool arguments.
|
|
105
|
+
- Don't batch unrelated proposals — one proposal per decision.
|
|
106
|
+
|
|
107
|
+
## Standing orders
|
|
108
|
+
|
|
109
|
+
(Add your own here. Examples:)
|
|
110
|
+
|
|
111
|
+
- Every morning, summarize today's calendar and flag conflicts.
|
|
112
|
+
- On Fridays, give me a weekly review: what's done, what slipped, what's
|
|
113
|
+
next.
|
|
114
|
+
- Never email anyone outside the company without asking first.
|
|
115
|
+
- When drafting posts, prefer plain language over marketing copy.
|
|
116
|
+
`;function gj(){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,p]=u.useState(!1),m=e!==n,x=new Blob([e]).size,j=16*1024;u.useEffect(()=>{if(!m)return;const h=w=>{w.preventDefault(),w.returnValue=""},y=w=>{var N,A;if(w.defaultPrevented||w.button!==0||w.metaKey||w.ctrlKey||w.shiftKey||w.altKey)return;const b=(A=(N=w.target)==null?void 0:N.closest)==null?void 0:A.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?")||(w.preventDefault(),w.stopPropagation()))};return window.addEventListener("beforeunload",h),document.addEventListener("click",y,!0),()=>{window.removeEventListener("beforeunload",h),document.removeEventListener("click",y,!0)}},[m]),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(hj)};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(Ga,{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>j?"var(--danger)":"var(--text-muted)"},children:[x.toLocaleString()," / ",j.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||!m,children:"Revert"}),s.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:v,disabled:o||!m||x>j||a,children:o?"Saving…":"Save"})]})]}),s.jsx("button",{type:"button",className:"floating-help",onClick:()=>p(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),s.jsx(xp,{open:f,onClose:()=>p(!1),ariaLabel:"Brief assistant",children:s.jsx(Ga,{target:{kind:"context"},currentText:e,onApply:h=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(h),p(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function yj(e){const t=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return t&&t[1].replace(/<[^>]+>/g,"").trim()||"Report"}function vj(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 xj(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function wj(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 jj(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 Sj(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 fd(e,t="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:t}}function kj(e){return/Labels?$/.test(e)||e==="limits"||e==="fields"}function bj(e,t){const n=t[e];return n==null||n===""||kj(e)?null:typeof n=="object"?JSON.stringify(n):String(n)}function Nj(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 Cj(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 Ej="allow-popups allow-popups-to-escape-sandbox",Tj="AI analysis — not verified",Ij="Green = verified by the gateway — raw signed fields only",Rj="Grey dashed = the AI's own analysis, not verified",Aj="= translation by the AI, not verified",Pj="Übersetzung anzeigen / show translation";function md(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 _j(e,t){return t&&e.renderedHtmlGloss?e.renderedHtmlGloss:e.renderedHtml}function Lj(e,t,n){const r=new URLSearchParams(e);return r.set("element",t),n?r.set("ticket",n):r.delete("ticket"),r}const zj={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function $j(e){return e.filter(t=>t.status==="unverifiable").map(t=>({elementId:t.id,text:`${zj[t.kind]??"Element"}: ${t.reason??"could not be checked"}`}))}function Mj(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 Fj(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 yc={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},Oj={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function Dj(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 Bj(e,t){const n=Oj[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:{...yc,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 Xi(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:yc,children:Dj(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))}),Bj(e,t.data??{})]})]}):null}function Uj({report:e,elementId:t,ticketParam:n,onClose:r,onSelectTicket:a}){var p;const i=e.elements.find(m=>m.id===t),o=Cj(i,n),l=o?e.ticketDetails[o]:void 0,c=Mj(i),d=(p=e.proof.verifiedValues.find(m=>m.elementId===t))==null?void 0:p.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:yc,children:Object.keys(i.data??{}).map(m=>{const x=bj(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:[Xi("Ticket",l.ticket),Xi("Mandate",l.mandate),Xi("Approval",l.approval)]}),o&&!l&&s.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",o,"."]})]})}async function Wj(e){const{html:t,filename:n}=await e.exportReport();e.download(t,n),await e.refresh()}function pd({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 Hj({report:e,open:t,selectedId:n,onOpenElement:r,detail:a}){const{proof:i,coverage:o}=e,l=$j(e.elements),c=Nj(o),d=jj(o),f=Sj(o),p=fd(i.signaturesValid),m=fd(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:p.kind==="ok"?{color:"var(--success)"}:void 0,children:p.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(pd,{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(pd,{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 Vj(){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,p]=u.useState(null),[m,x]=u.useState(!1),[j,v]=u.useState(!1),[S,g]=ic(),h=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),h().finally(()=>r(!1))},[h]);u.useEffect(()=>{y()},[y]);const w=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),p(null);try{await Wj({exportReport:()=>T.exportReportWithProof(),download:(L,Z)=>{const F=URL.createObjectURL(new Blob([L],{type:"text/html"})),q=document.createElement("a");q.href=F,q.download=Z,q.click(),URL.revokeObjectURL(F)},refresh:h})}catch(L){p(L instanceof Error?L.message:String(L))}finally{d(!1)}},[h]),C=S.get("element"),N=S.get("ticket"),A=u.useCallback((L,Z)=>{g(Lj(S,L,Z))},[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(Ya,{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(Ya,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const P=yj(e.renderedHtml),O=vj(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:P}),s.jsxs("p",{className:"page-subtitle",children:[O?`written by the AI under mandate ${O} · `:"","checked ",xj(e.checkedAt)]})]}),s.jsxs("div",{className:"reports-bar-actions",children:[s.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:w,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:wj(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"}),Ij]}),s.jsxs("span",{className:"reports-legend-chip",children:[s.jsx("span",{className:"reports-sw reports-sw-a"}),Rj," (“",Tj,"”)"]}),e.renderedHtmlGloss&&s.jsxs("span",{className:"reports-legend-chip",children:[s.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",Aj]})]}),md(e)&&s.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:md(e)}),e.renderedHtmlGloss&&s.jsxs("label",{className:"reports-gloss-switch",children:[s.jsx("input",{type:"checkbox",role:"switch",checked:j,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:Pj})]}),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:Ej,srcDoc:Fj(_j(e,j)),className:"reports-iframe"})]}),s.jsx(Hj,{report:e,open:m||!!C,selectedId:C,onOpenElement:L=>A(L),detail:C?s.jsx(Uj,{report:e,elementId:C,ticketParam:N,onClose:E,onSelectTicket:L=>A(C,L)}):void 0})]})]})})}function er({to:e}){const{search:t,hash:n}=mt();return s.jsx(Jt,{to:`${e}${t}${n}`,replace:!0})}function Gj({children:e}){const{user:t,mode:n,domain:r}=He();return t?n==="team"&&!r?s.jsx(Jt,{to:"/onboarding",replace:!0}):s.jsx(s.Fragment,{children:e}):s.jsx(Jt,{to:"/login",replace:!0})}function Kj(){const{user:e,handleSessionLocked:t}=He();return ve("session-locked",n=>{const r=n==null?void 0:n.message;t(r)}),s.jsxs(hv,{children:[s.jsx(be,{path:"/login",element:e?s.jsx(Jt,{to:"/",replace:!0}):s.jsx(Bx,{})}),s.jsx(be,{path:"/onboarding",element:e?s.jsx(Ux,{}):s.jsx(Jt,{to:"/login",replace:!0})}),s.jsxs(be,{element:s.jsx(Gj,{children:s.jsx(Dx,{})}),children:[s.jsx(be,{path:"/",element:s.jsx(u0,{})}),s.jsx(be,{path:"/mandates",element:s.jsx(kw,{})}),s.jsx(be,{path:"/mandates/new/intent",element:s.jsx(z0,{})}),s.jsx(be,{path:"/mandates/new/sign",element:s.jsx(V0,{})}),s.jsx(be,{path:"/integrations",element:s.jsx(X0,{})}),s.jsx(be,{path:"/team",element:s.jsx(Z0,{})}),s.jsx(be,{path:"/tickets",element:s.jsx($w,{})}),s.jsx(be,{path:"/approvals",element:s.jsx(fj,{})}),s.jsx(be,{path:"/reports",element:s.jsx(Vj,{})}),s.jsx(be,{path:"/agent/new",element:s.jsx(Jt,{to:"/mandates?new=1",replace:!0})}),s.jsx(be,{path:"/agent/gate",element:s.jsx(er,{to:"/mandates/new/intent"})}),s.jsx(be,{path:"/agent/review",element:s.jsx(er,{to:"/mandates/new/sign"})}),s.jsx(be,{path:"/authorizations",element:s.jsx(er,{to:"/mandates"})}),s.jsx(be,{path:"/groups",element:s.jsx(er,{to:"/team"})}),s.jsx(be,{path:"/audit",element:s.jsx(er,{to:"/tickets"})}),s.jsx(be,{path:"/proposals",element:s.jsx(er,{to:"/approvals"})}),s.jsx(be,{path:"/agent-brief",element:s.jsx(gj,{})}),s.jsx(be,{path:"/settings",element:s.jsx(Gw,{})}),s.jsx(be,{path:"/settings/services",element:s.jsx(Jt,{to:"/settings",replace:!0})}),s.jsx(be,{path:"/deploy",element:s.jsx(Jt,{to:"/integrations",replace:!0})})]}),s.jsx(be,{path:"*",element:s.jsx(Jt,{to:"/",replace:!0})})]})}function Yj(){return s.jsx(Dv,{children:s.jsx(ex,{children:s.jsx(tx,{children:s.jsx(Kj,{})})})})}Im(document.getElementById("root")).render(s.jsx(u.StrictMode,{children:s.jsx(Yj,{})}));
|