@suveren/gateway 0.25.1 → 0.26.0

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,120 @@
1
+ var kp=Object.defineProperty;var bp=(e,t,n)=>t in e?kp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Fr=(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 Vd={exports:{}},ai={},Gd={exports:{}},fe={};/**
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 Ps=Symbol.for("react.element"),Np=Symbol.for("react.portal"),Cp=Symbol.for("react.fragment"),Ep=Symbol.for("react.strict_mode"),Tp=Symbol.for("react.profiler"),Ip=Symbol.for("react.provider"),Rp=Symbol.for("react.context"),Ap=Symbol.for("react.forward_ref"),Pp=Symbol.for("react.suspense"),$p=Symbol.for("react.memo"),_p=Symbol.for("react.lazy"),Uc=Symbol.iterator;function Lp(e){return e===null||typeof e!="object"?null:(e=Uc&&e[Uc]||e["@@iterator"],typeof e=="function"?e:null)}var Kd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Yd=Object.assign,Jd={};function Rr(e,t,n){this.props=e,this.context=t,this.refs=Jd,this.updater=n||Kd}Rr.prototype.isReactComponent={};Rr.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")};Rr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Qd(){}Qd.prototype=Rr.prototype;function yl(e,t,n){this.props=e,this.context=t,this.refs=Jd,this.updater=n||Kd}var vl=yl.prototype=new Qd;vl.constructor=yl;Yd(vl,Rr.prototype);vl.isPureReactComponent=!0;var Wc=Array.isArray,qd=Object.prototype.hasOwnProperty,xl={current:null},Xd={key:!0,ref:!0,__self:!0,__source:!0};function Zd(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)qd.call(t,r)&&!Xd.hasOwnProperty(r)&&(a[r]=t[r]);var c=arguments.length-2;if(c===1)a.children=n;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];a.children=l}if(e&&e.defaultProps)for(r in c=e.defaultProps,c)a[r]===void 0&&(a[r]=c[r]);return{$$typeof:Ps,type:e,key:i,ref:o,props:a,_owner:xl.current}}function zp(e,t){return{$$typeof:Ps,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function wl(e){return typeof e=="object"&&e!==null&&e.$$typeof===Ps}function Fp(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Hc=/\/+/g;function Ti(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Fp(""+e.key):t.toString(36)}function fa(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 Ps:case Np:o=!0}}if(o)return o=e,a=a(o),e=r===""?"."+Ti(o,0):r,Wc(a)?(n="",e!=null&&(n=e.replace(Hc,"$&/")+"/"),fa(a,t,n,"",function(u){return u})):a!=null&&(wl(a)&&(a=zp(a,n+(!a.key||o&&o.key===a.key?"":(""+a.key).replace(Hc,"$&/")+"/")+e)),t.push(a)),1;if(o=0,r=r===""?".":r+":",Wc(e))for(var c=0;c<e.length;c++){i=e[c];var l=r+Ti(i,c);o+=fa(i,t,n,l,a)}else if(l=Lp(e),typeof l=="function")for(e=l.call(e),c=0;!(i=e.next()).done;)i=i.value,l=r+Ti(i,c++),o+=fa(i,t,n,l,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 Ws(e,t,n){if(e==null)return e;var r=[],a=0;return fa(e,r,"","",function(i){return t.call(n,i,a++)}),r}function Op(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},ma={transition:null},Mp={ReactCurrentDispatcher:rt,ReactCurrentBatchConfig:ma,ReactCurrentOwner:xl};function ef(){throw Error("act(...) is not supported in production builds of React.")}fe.Children={map:Ws,forEach:function(e,t,n){Ws(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Ws(e,function(){t++}),t},toArray:function(e){return Ws(e,function(t){return t})||[]},only:function(e){if(!wl(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};fe.Component=Rr;fe.Fragment=Cp;fe.Profiler=Tp;fe.PureComponent=yl;fe.StrictMode=Ep;fe.Suspense=Pp;fe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Mp;fe.act=ef;fe.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=Yd({},e.props),a=e.key,i=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,o=xl.current),t.key!==void 0&&(a=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in t)qd.call(t,l)&&!Xd.hasOwnProperty(l)&&(r[l]=t[l]===void 0&&c!==void 0?c[l]:t[l])}var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];r.children=c}return{$$typeof:Ps,type:e.type,key:a,ref:i,props:r,_owner:o}};fe.createContext=function(e){return e={$$typeof:Rp,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Ip,_context:e},e.Consumer=e};fe.createElement=Zd;fe.createFactory=function(e){var t=Zd.bind(null,e);return t.type=e,t};fe.createRef=function(){return{current:null}};fe.forwardRef=function(e){return{$$typeof:Ap,render:e}};fe.isValidElement=wl;fe.lazy=function(e){return{$$typeof:_p,_payload:{_status:-1,_result:e},_init:Op}};fe.memo=function(e,t){return{$$typeof:$p,type:e,compare:t===void 0?null:t}};fe.startTransition=function(e){var t=ma.transition;ma.transition={};try{e()}finally{ma.transition=t}};fe.unstable_act=ef;fe.useCallback=function(e,t){return rt.current.useCallback(e,t)};fe.useContext=function(e){return rt.current.useContext(e)};fe.useDebugValue=function(){};fe.useDeferredValue=function(e){return rt.current.useDeferredValue(e)};fe.useEffect=function(e,t){return rt.current.useEffect(e,t)};fe.useId=function(){return rt.current.useId()};fe.useImperativeHandle=function(e,t,n){return rt.current.useImperativeHandle(e,t,n)};fe.useInsertionEffect=function(e,t){return rt.current.useInsertionEffect(e,t)};fe.useLayoutEffect=function(e,t){return rt.current.useLayoutEffect(e,t)};fe.useMemo=function(e,t){return rt.current.useMemo(e,t)};fe.useReducer=function(e,t,n){return rt.current.useReducer(e,t,n)};fe.useRef=function(e){return rt.current.useRef(e)};fe.useState=function(e){return rt.current.useState(e)};fe.useSyncExternalStore=function(e,t,n){return rt.current.useSyncExternalStore(e,t,n)};fe.useTransition=function(){return rt.current.useTransition()};fe.version="18.3.1";Gd.exports=fe;var d=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 Bp=d,Dp=Symbol.for("react.element"),Up=Symbol.for("react.fragment"),Wp=Object.prototype.hasOwnProperty,Hp=Bp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Vp={key:!0,ref:!0,__self:!0,__source:!0};function tf(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)Wp.call(t,r)&&!Vp.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:Dp,type:e,key:i,ref:o,props:a,_owner:Hp.current}}ai.Fragment=Up;ai.jsx=tf;ai.jsxs=tf;Vd.exports=ai;var s=Vd.exports,nf={exports:{}},jt={},rf={exports:{}},sf={};/**
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,P){var B=z.length;z.push(P);e:for(;0<B;){var _=B-1>>>1,F=z[_];if(0<a(F,P))z[_]=P,z[B]=F,B=_;else break e}}function n(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var P=z[0],B=z.pop();if(B!==P){z[0]=B;e:for(var _=0,F=z.length,K=F>>>1;_<K;){var X=2*(_+1)-1,ne=z[X],le=X+1,me=z[le];if(0>a(ne,B))le<F&&0>a(me,ne)?(z[_]=me,z[le]=B,_=le):(z[_]=ne,z[X]=B,_=X);else if(le<F&&0>a(me,B))z[_]=me,z[le]=B,_=le;else break e}}return P}function a(z,P){var B=z.sortIndex-P.sortIndex;return B!==0?B:z.id-P.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,c=o.now();e.unstable_now=function(){return o.now()-c}}var l=[],u=[],f=1,h=null,m=3,x=!1,j=!1,v=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,p=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(z){for(var P=n(u);P!==null;){if(P.callback===null)r(u);else if(P.startTime<=z)r(u),P.sortIndex=P.expirationTime,t(l,P);else break;P=n(u)}}function w(z){if(v=!1,y(z),!j)if(n(l)!==null)j=!0,Z(k);else{var P=n(u);P!==null&&se(w,P.startTime-z)}}function k(z,P){j=!1,v&&(v=!1,g(R),R=-1),x=!0;var B=m;try{for(y(P),h=n(l);h!==null&&(!(h.expirationTime>P)||z&&!$());){var _=h.callback;if(typeof _=="function"){h.callback=null,m=h.priorityLevel;var F=_(h.expirationTime<=P);P=e.unstable_now(),typeof F=="function"?h.callback=F:h===n(l)&&r(l),y(P)}else r(l);h=n(l)}if(h!==null)var K=!0;else{var X=n(u);X!==null&&se(w,X.startTime-P),K=!1}return K}finally{h=null,m=B,x=!1}}var C=!1,N=null,R=-1,I=5,L=-1;function $(){return!(e.unstable_now()-L<I)}function T(){if(N!==null){var z=e.unstable_now();L=z;var P=!0;try{P=N(!0,z)}finally{P?O():(C=!1,N=null)}}else C=!1}var O;if(typeof p=="function")O=function(){p(T)};else if(typeof MessageChannel<"u"){var V=new MessageChannel,A=V.port2;V.port1.onmessage=T,O=function(){A.postMessage(null)}}else O=function(){S(T,0)};function Z(z){N=z,C||(C=!0,O())}function se(z,P){R=S(function(){z(e.unstable_now())},P)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_continueExecution=function(){j||x||(j=!0,Z(k))},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"):I=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(l)},e.unstable_next=function(z){switch(m){case 1:case 2:case 3:var P=3;break;default:P=m}var B=m;m=P;try{return z()}finally{m=B}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,P){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var B=m;m=z;try{return P()}finally{m=B}},e.unstable_scheduleCallback=function(z,P,B){var _=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?_+B:_):B=_,z){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=B+F,z={id:f++,callback:P,priorityLevel:z,startTime:B,expirationTime:F,sortIndex:-1},B>_?(z.sortIndex=B,t(u,z),n(l)===null&&z===n(u)&&(v?(g(R),R=-1):v=!0,se(w,B-_))):(z.sortIndex=F,t(l,z),j||x||(j=!0,Z(k))),z},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(z){var P=m;return function(){var B=m;m=P;try{return z.apply(this,arguments)}finally{m=B}}}})(sf);rf.exports=sf;var Gp=rf.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 Kp=d,wt=Gp;function D(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 af=new Set,fs={};function Qn(e,t){jr(e,t),jr(e+"Capture",t)}function jr(e,t){for(fs[e]=t,e=0;e<t.length;e++)af.add(t[e])}var nn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),uo=Object.prototype.hasOwnProperty,Yp=/^[: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]*$/,Vc={},Gc={};function Jp(e){return uo.call(Gc,e)?!0:uo.call(Vc,e)?!1:Yp.test(e)?Gc[e]=!0:(Vc[e]=!0,!1)}function Qp(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 qp(e,t,n,r){if(t===null||typeof t>"u"||Qp(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 Je={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Je[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];Je[t]=new st(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Je[e]=new st(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Je[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){Je[e]=new st(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Je[e]=new st(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Je[e]=new st(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Je[e]=new st(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Je[e]=new st(e,5,!1,e.toLowerCase(),null,!1,!1)});var jl=/[\-:]([a-z])/g;function Sl(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(jl,Sl);Je[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(jl,Sl);Je[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(jl,Sl);Je[t]=new st(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Je[e]=new st(e,1,!1,e.toLowerCase(),null,!1,!1)});Je.xlinkHref=new st("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Je[e]=new st(e,1,!1,e.toLowerCase(),null,!0,!0)});function kl(e,t,n,r){var a=Je.hasOwnProperty(t)?Je[t]:null;(a!==null?a.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(qp(t,n,a,r)&&(n=null),r||a===null?Jp(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 ln=Kp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Hs=Symbol.for("react.element"),rr=Symbol.for("react.portal"),sr=Symbol.for("react.fragment"),bl=Symbol.for("react.strict_mode"),fo=Symbol.for("react.profiler"),of=Symbol.for("react.provider"),lf=Symbol.for("react.context"),Nl=Symbol.for("react.forward_ref"),mo=Symbol.for("react.suspense"),ho=Symbol.for("react.suspense_list"),Cl=Symbol.for("react.memo"),un=Symbol.for("react.lazy"),cf=Symbol.for("react.offscreen"),Kc=Symbol.iterator;function Or(e){return e===null||typeof e!="object"?null:(e=Kc&&e[Kc]||e["@@iterator"],typeof e=="function"?e:null)}var Ae=Object.assign,Ii;function Qr(e){if(Ii===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Ii=t&&t[1]||""}return`
34
+ `+Ii+e}var Ri=!1;function Ai(e,t){if(!e||Ri)return"";Ri=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var a=u.stack.split(`
35
+ `),i=r.stack.split(`
36
+ `),o=a.length-1,c=i.length-1;1<=o&&0<=c&&a[o]!==i[c];)c--;for(;1<=o&&0<=c;o--,c--)if(a[o]!==i[c]){if(o!==1||c!==1)do if(o--,c--,0>c||a[o]!==i[c]){var l=`
37
+ `+a[o].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}while(1<=o&&0<=c);break}}}finally{Ri=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Qr(e):""}function Xp(e){switch(e.tag){case 5:return Qr(e.type);case 16:return Qr("Lazy");case 13:return Qr("Suspense");case 19:return Qr("SuspenseList");case 0:case 2:case 15:return e=Ai(e.type,!1),e;case 11:return e=Ai(e.type.render,!1),e;case 1:return e=Ai(e.type,!0),e;default:return""}}function po(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 sr:return"Fragment";case rr:return"Portal";case fo:return"Profiler";case bl:return"StrictMode";case mo:return"Suspense";case ho:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case lf:return(e.displayName||"Context")+".Consumer";case of:return(e._context.displayName||"Context")+".Provider";case Nl:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Cl:return t=e.displayName||null,t!==null?t:po(e.type)||"Memo";case un:t=e._payload,e=e._init;try{return po(e(t))}catch{}}return null}function Zp(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 po(t);case 8:return t===bl?"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 bn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function uf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function eg(e){var t=uf(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 Vs(e){e._valueTracker||(e._valueTracker=eg(e))}function df(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=uf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ia(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 go(e,t){var n=t.checked;return Ae({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Yc(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=bn(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 ff(e,t){t=t.checked,t!=null&&kl(e,"checked",t,!1)}function yo(e,t){ff(e,t);var n=bn(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")?vo(e,t.type,n):t.hasOwnProperty("defaultValue")&&vo(e,t.type,bn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Jc(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 vo(e,t,n){(t!=="number"||Ia(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var qr=Array.isArray;function pr(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=""+bn(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 xo(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(D(91));return Ae({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Qc(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(D(92));if(qr(n)){if(1<n.length)throw Error(D(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:bn(n)}}function mf(e,t){var n=bn(t.value),r=bn(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 qc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function hf(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 wo(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?hf(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Gs,pf=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(Gs=Gs||document.createElement("div"),Gs.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Gs.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ms(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ns={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},tg=["Webkit","ms","Moz","O"];Object.keys(ns).forEach(function(e){tg.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ns[t]=ns[e]})});function gf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ns.hasOwnProperty(e)&&ns[e]?(""+t).trim():t+"px"}function yf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=gf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var ng=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 jo(e,t){if(t){if(ng[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(D(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(D(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(D(61))}if(t.style!=null&&typeof t.style!="object")throw Error(D(62))}}function So(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 ko=null;function El(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var bo=null,gr=null,yr=null;function Xc(e){if(e=Ls(e)){if(typeof bo!="function")throw Error(D(280));var t=e.stateNode;t&&(t=ui(t),bo(e.stateNode,e.type,t))}}function vf(e){gr?yr?yr.push(e):yr=[e]:gr=e}function xf(){if(gr){var e=gr,t=yr;if(yr=gr=null,Xc(e),t)for(e=0;e<t.length;e++)Xc(t[e])}}function wf(e,t){return e(t)}function jf(){}var Pi=!1;function Sf(e,t,n){if(Pi)return e(t,n);Pi=!0;try{return wf(e,t,n)}finally{Pi=!1,(gr!==null||yr!==null)&&(jf(),xf())}}function hs(e,t){var n=e.stateNode;if(n===null)return null;var r=ui(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(D(231,t,typeof n));return n}var No=!1;if(nn)try{var Mr={};Object.defineProperty(Mr,"passive",{get:function(){No=!0}}),window.addEventListener("test",Mr,Mr),window.removeEventListener("test",Mr,Mr)}catch{No=!1}function rg(e,t,n,r,a,i,o,c,l){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(f){this.onError(f)}}var rs=!1,Ra=null,Aa=!1,Co=null,sg={onError:function(e){rs=!0,Ra=e}};function ag(e,t,n,r,a,i,o,c,l){rs=!1,Ra=null,rg.apply(sg,arguments)}function ig(e,t,n,r,a,i,o,c,l){if(ag.apply(this,arguments),rs){if(rs){var u=Ra;rs=!1,Ra=null}else throw Error(D(198));Aa||(Aa=!0,Co=u)}}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 kf(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 Zc(e){if(qn(e)!==e)throw Error(D(188))}function og(e){var t=e.alternate;if(!t){if(t=qn(e),t===null)throw Error(D(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 Zc(a),e;if(i===r)return Zc(a),t;i=i.sibling}throw Error(D(188))}if(n.return!==r.return)n=a,r=i;else{for(var o=!1,c=a.child;c;){if(c===n){o=!0,n=a,r=i;break}if(c===r){o=!0,r=a,n=i;break}c=c.sibling}if(!o){for(c=i.child;c;){if(c===n){o=!0,n=i,r=a;break}if(c===r){o=!0,r=i,n=a;break}c=c.sibling}if(!o)throw Error(D(189))}}if(n.alternate!==r)throw Error(D(190))}if(n.tag!==3)throw Error(D(188));return n.stateNode.current===n?e:t}function bf(e){return e=og(e),e!==null?Nf(e):null}function Nf(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Nf(e);if(t!==null)return t;e=e.sibling}return null}var Cf=wt.unstable_scheduleCallback,eu=wt.unstable_cancelCallback,lg=wt.unstable_shouldYield,cg=wt.unstable_requestPaint,Le=wt.unstable_now,ug=wt.unstable_getCurrentPriorityLevel,Tl=wt.unstable_ImmediatePriority,Ef=wt.unstable_UserBlockingPriority,Pa=wt.unstable_NormalPriority,dg=wt.unstable_LowPriority,Tf=wt.unstable_IdlePriority,ii=null,Kt=null;function fg(e){if(Kt&&typeof Kt.onCommitFiberRoot=="function")try{Kt.onCommitFiberRoot(ii,e,void 0,(e.current.flags&128)===128)}catch{}}var Ft=Math.clz32?Math.clz32:pg,mg=Math.log,hg=Math.LN2;function pg(e){return e>>>=0,e===0?32:31-(mg(e)/hg|0)|0}var Ks=64,Ys=4194304;function Xr(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 $a(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 c=o&~a;c!==0?r=Xr(c):(i&=o,i!==0&&(r=Xr(i)))}else o=n&~a,o!==0?r=Xr(o):i!==0&&(r=Xr(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-Ft(t),a=1<<n,r|=e[n],t&=~a;return r}function gg(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 yg(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-Ft(i),c=1<<o,l=a[o];l===-1?(!(c&n)||c&r)&&(a[o]=gg(c,t)):l<=t&&(e.expiredLanes|=c),i&=~c}}function Eo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function If(){var e=Ks;return Ks<<=1,!(Ks&4194240)&&(Ks=64),e}function $i(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function $s(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ft(t),e[t]=n}function vg(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-Ft(n),i=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~i}}function Il(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ft(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var je=0;function Rf(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Af,Rl,Pf,$f,_f,To=!1,Js=[],gn=null,yn=null,vn=null,ps=new Map,gs=new Map,fn=[],xg="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 tu(e,t){switch(e){case"focusin":case"focusout":gn=null;break;case"dragenter":case"dragleave":yn=null;break;case"mouseover":case"mouseout":vn=null;break;case"pointerover":case"pointerout":ps.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":gs.delete(t.pointerId)}}function Br(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=Ls(t),t!==null&&Rl(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function wg(e,t,n,r,a){switch(t){case"focusin":return gn=Br(gn,e,t,n,r,a),!0;case"dragenter":return yn=Br(yn,e,t,n,r,a),!0;case"mouseover":return vn=Br(vn,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return ps.set(i,Br(ps.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,gs.set(i,Br(gs.get(i)||null,e,t,n,r,a)),!0}return!1}function Lf(e){var t=Fn(e.target);if(t!==null){var n=qn(t);if(n!==null){if(t=n.tag,t===13){if(t=kf(n),t!==null){e.blockedOn=t,_f(e.priority,function(){Pf(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 ha(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Io(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);ko=r,n.target.dispatchEvent(r),ko=null}else return t=Ls(n),t!==null&&Rl(t),e.blockedOn=n,!1;t.shift()}return!0}function nu(e,t,n){ha(e)&&n.delete(t)}function jg(){To=!1,gn!==null&&ha(gn)&&(gn=null),yn!==null&&ha(yn)&&(yn=null),vn!==null&&ha(vn)&&(vn=null),ps.forEach(nu),gs.forEach(nu)}function Dr(e,t){e.blockedOn===t&&(e.blockedOn=null,To||(To=!0,wt.unstable_scheduleCallback(wt.unstable_NormalPriority,jg)))}function ys(e){function t(a){return Dr(a,e)}if(0<Js.length){Dr(Js[0],e);for(var n=1;n<Js.length;n++){var r=Js[n];r.blockedOn===e&&(r.blockedOn=null)}}for(gn!==null&&Dr(gn,e),yn!==null&&Dr(yn,e),vn!==null&&Dr(vn,e),ps.forEach(t),gs.forEach(t),n=0;n<fn.length;n++)r=fn[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<fn.length&&(n=fn[0],n.blockedOn===null);)Lf(n),n.blockedOn===null&&fn.shift()}var vr=ln.ReactCurrentBatchConfig,_a=!0;function Sg(e,t,n,r){var a=je,i=vr.transition;vr.transition=null;try{je=1,Al(e,t,n,r)}finally{je=a,vr.transition=i}}function kg(e,t,n,r){var a=je,i=vr.transition;vr.transition=null;try{je=4,Al(e,t,n,r)}finally{je=a,vr.transition=i}}function Al(e,t,n,r){if(_a){var a=Io(e,t,n,r);if(a===null)Wi(e,t,r,La,n),tu(e,r);else if(wg(a,e,t,n,r))r.stopPropagation();else if(tu(e,r),t&4&&-1<xg.indexOf(e)){for(;a!==null;){var i=Ls(a);if(i!==null&&Af(i),i=Io(e,t,n,r),i===null&&Wi(e,t,r,La,n),i===a)break;a=i}a!==null&&r.stopPropagation()}else Wi(e,t,r,null,n)}}var La=null;function Io(e,t,n,r){if(La=null,e=El(r),e=Fn(e),e!==null)if(t=qn(e),t===null)e=null;else if(n=t.tag,n===13){if(e=kf(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 La=e,null}function zf(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(ug()){case Tl:return 1;case Ef:return 4;case Pa:case dg:return 16;case Tf:return 536870912;default:return 16}default:return 16}}var hn=null,Pl=null,pa=null;function Ff(){if(pa)return pa;var e,t=Pl,n=t.length,r,a="value"in hn?hn.value:hn.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 pa=a.slice(e,1<r?1-r:void 0)}function ga(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 Qs(){return!0}function ru(){return!1}function St(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 c in e)e.hasOwnProperty(c)&&(n=e[c],this[c]=n?n(i):i[c]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Qs:ru,this.isPropagationStopped=ru,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=Qs)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Qs)},persist:function(){},isPersistent:Qs}),t}var Ar={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},$l=St(Ar),_s=Ae({},Ar,{view:0,detail:0}),bg=St(_s),_i,Li,Ur,oi=Ae({},_s,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_l,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!==Ur&&(Ur&&e.type==="mousemove"?(_i=e.screenX-Ur.screenX,Li=e.screenY-Ur.screenY):Li=_i=0,Ur=e),_i)},movementY:function(e){return"movementY"in e?e.movementY:Li}}),su=St(oi),Ng=Ae({},oi,{dataTransfer:0}),Cg=St(Ng),Eg=Ae({},_s,{relatedTarget:0}),zi=St(Eg),Tg=Ae({},Ar,{animationName:0,elapsedTime:0,pseudoElement:0}),Ig=St(Tg),Rg=Ae({},Ar,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Ag=St(Rg),Pg=Ae({},Ar,{data:0}),au=St(Pg),$g={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},_g={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"},Lg={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function zg(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Lg[e])?!!t[e]:!1}function _l(){return zg}var Fg=Ae({},_s,{key:function(e){if(e.key){var t=$g[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ga(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?_g[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_l,charCode:function(e){return e.type==="keypress"?ga(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ga(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Og=St(Fg),Mg=Ae({},oi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),iu=St(Mg),Bg=Ae({},_s,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_l}),Dg=St(Bg),Ug=Ae({},Ar,{propertyName:0,elapsedTime:0,pseudoElement:0}),Wg=St(Ug),Hg=Ae({},oi,{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}),Vg=St(Hg),Gg=[9,13,27,32],Ll=nn&&"CompositionEvent"in window,ss=null;nn&&"documentMode"in document&&(ss=document.documentMode);var Kg=nn&&"TextEvent"in window&&!ss,Of=nn&&(!Ll||ss&&8<ss&&11>=ss),ou=" ",lu=!1;function Mf(e,t){switch(e){case"keyup":return Gg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ar=!1;function Yg(e,t){switch(e){case"compositionend":return Bf(t);case"keypress":return t.which!==32?null:(lu=!0,ou);case"textInput":return e=t.data,e===ou&&lu?null:e;default:return null}}function Jg(e,t){if(ar)return e==="compositionend"||!Ll&&Mf(e,t)?(e=Ff(),pa=Pl=hn=null,ar=!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 Of&&t.locale!=="ko"?null:t.data;default:return null}}var Qg={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 cu(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Qg[e.type]:t==="textarea"}function Df(e,t,n,r){vf(r),t=za(t,"onChange"),0<t.length&&(n=new $l("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var as=null,vs=null;function qg(e){Xf(e,0)}function li(e){var t=lr(e);if(df(t))return e}function Xg(e,t){if(e==="change")return t}var Uf=!1;if(nn){var Fi;if(nn){var Oi="oninput"in document;if(!Oi){var uu=document.createElement("div");uu.setAttribute("oninput","return;"),Oi=typeof uu.oninput=="function"}Fi=Oi}else Fi=!1;Uf=Fi&&(!document.documentMode||9<document.documentMode)}function du(){as&&(as.detachEvent("onpropertychange",Wf),vs=as=null)}function Wf(e){if(e.propertyName==="value"&&li(vs)){var t=[];Df(t,vs,e,El(e)),Sf(qg,t)}}function Zg(e,t,n){e==="focusin"?(du(),as=t,vs=n,as.attachEvent("onpropertychange",Wf)):e==="focusout"&&du()}function ey(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return li(vs)}function ty(e,t){if(e==="click")return li(t)}function ny(e,t){if(e==="input"||e==="change")return li(t)}function ry(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Bt=typeof Object.is=="function"?Object.is:ry;function xs(e,t){if(Bt(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(!uo.call(t,a)||!Bt(e[a],t[a]))return!1}return!0}function fu(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function mu(e,t){var n=fu(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=fu(n)}}function Hf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Hf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Vf(){for(var e=window,t=Ia();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ia(e.document)}return t}function zl(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 sy(e){var t=Vf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Hf(n.ownerDocument.documentElement,n)){if(r!==null&&zl(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=mu(n,i);var o=mu(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 ay=nn&&"documentMode"in document&&11>=document.documentMode,ir=null,Ro=null,is=null,Ao=!1;function hu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ao||ir==null||ir!==Ia(r)||(r=ir,"selectionStart"in r&&zl(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}),is&&xs(is,r)||(is=r,r=za(Ro,"onSelect"),0<r.length&&(t=new $l("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ir)))}function qs(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var or={animationend:qs("Animation","AnimationEnd"),animationiteration:qs("Animation","AnimationIteration"),animationstart:qs("Animation","AnimationStart"),transitionend:qs("Transition","TransitionEnd")},Mi={},Gf={};nn&&(Gf=document.createElement("div").style,"AnimationEvent"in window||(delete or.animationend.animation,delete or.animationiteration.animation,delete or.animationstart.animation),"TransitionEvent"in window||delete or.transitionend.transition);function ci(e){if(Mi[e])return Mi[e];if(!or[e])return e;var t=or[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Gf)return Mi[e]=t[n];return e}var Kf=ci("animationend"),Yf=ci("animationiteration"),Jf=ci("animationstart"),Qf=ci("transitionend"),qf=new Map,pu="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 Cn(e,t){qf.set(e,t),Qn(t,[e])}for(var Bi=0;Bi<pu.length;Bi++){var Di=pu[Bi],iy=Di.toLowerCase(),oy=Di[0].toUpperCase()+Di.slice(1);Cn(iy,"on"+oy)}Cn(Kf,"onAnimationEnd");Cn(Yf,"onAnimationIteration");Cn(Jf,"onAnimationStart");Cn("dblclick","onDoubleClick");Cn("focusin","onFocus");Cn("focusout","onBlur");Cn(Qf,"onTransitionEnd");jr("onMouseEnter",["mouseout","mouseover"]);jr("onMouseLeave",["mouseout","mouseover"]);jr("onPointerEnter",["pointerout","pointerover"]);jr("onPointerLeave",["pointerout","pointerover"]);Qn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Qn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Qn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Qn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Qn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Qn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Zr="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(" "),ly=new Set("cancel close invalid load scroll toggle".split(" ").concat(Zr));function gu(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,ig(r,t,void 0,e),e.currentTarget=null}function Xf(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 c=r[o],l=c.instance,u=c.currentTarget;if(c=c.listener,l!==i&&a.isPropagationStopped())break e;gu(a,c,u),i=l}else for(o=0;o<r.length;o++){if(c=r[o],l=c.instance,u=c.currentTarget,c=c.listener,l!==i&&a.isPropagationStopped())break e;gu(a,c,u),i=l}}}if(Aa)throw e=Co,Aa=!1,Co=null,e}function be(e,t){var n=t[zo];n===void 0&&(n=t[zo]=new Set);var r=e+"__bubble";n.has(r)||(Zf(t,e,2,!1),n.add(r))}function Ui(e,t,n){var r=0;t&&(r|=4),Zf(n,e,r,t)}var Xs="_reactListening"+Math.random().toString(36).slice(2);function ws(e){if(!e[Xs]){e[Xs]=!0,af.forEach(function(n){n!=="selectionchange"&&(ly.has(n)||Ui(n,!1,e),Ui(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Xs]||(t[Xs]=!0,Ui("selectionchange",!1,t))}}function Zf(e,t,n,r){switch(zf(t)){case 1:var a=Sg;break;case 4:a=kg;break;default:a=Al}n=a.bind(null,t,n,e),a=void 0,!No||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 Wi(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 c=r.stateNode.containerInfo;if(c===a||c.nodeType===8&&c.parentNode===a)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&(l=o.stateNode.containerInfo,l===a||l.nodeType===8&&l.parentNode===a))return;o=o.return}for(;c!==null;){if(o=Fn(c),o===null)return;if(l=o.tag,l===5||l===6){r=i=o;continue e}c=c.parentNode}}r=r.return}Sf(function(){var u=i,f=El(n),h=[];e:{var m=qf.get(e);if(m!==void 0){var x=$l,j=e;switch(e){case"keypress":if(ga(n)===0)break e;case"keydown":case"keyup":x=Og;break;case"focusin":j="focus",x=zi;break;case"focusout":j="blur",x=zi;break;case"beforeblur":case"afterblur":x=zi;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=su;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=Cg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=Dg;break;case Kf:case Yf:case Jf:x=Ig;break;case Qf:x=Wg;break;case"scroll":x=bg;break;case"wheel":x=Vg;break;case"copy":case"cut":case"paste":x=Ag;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=iu}var v=(t&4)!==0,S=!v&&e==="scroll",g=v?m!==null?m+"Capture":null:m;v=[];for(var p=u,y;p!==null;){y=p;var w=y.stateNode;if(y.tag===5&&w!==null&&(y=w,g!==null&&(w=hs(p,g),w!=null&&v.push(js(p,w,y)))),S)break;p=p.return}0<v.length&&(m=new x(m,j,null,n,f),h.push({event:m,listeners:v}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",m&&n!==ko&&(j=n.relatedTarget||n.fromElement)&&(Fn(j)||j[rn]))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=u,j=j?Fn(j):null,j!==null&&(S=qn(j),j!==S||j.tag!==5&&j.tag!==6)&&(j=null)):(x=null,j=u),x!==j)){if(v=su,w="onMouseLeave",g="onMouseEnter",p="mouse",(e==="pointerout"||e==="pointerover")&&(v=iu,w="onPointerLeave",g="onPointerEnter",p="pointer"),S=x==null?m:lr(x),y=j==null?m:lr(j),m=new v(w,p+"leave",x,n,f),m.target=S,m.relatedTarget=y,w=null,Fn(f)===u&&(v=new v(g,p+"enter",j,n,f),v.target=y,v.relatedTarget=S,w=v),S=w,x&&j)t:{for(v=x,g=j,p=0,y=v;y;y=Zn(y))p++;for(y=0,w=g;w;w=Zn(w))y++;for(;0<p-y;)v=Zn(v),p--;for(;0<y-p;)g=Zn(g),y--;for(;p--;){if(v===g||g!==null&&v===g.alternate)break t;v=Zn(v),g=Zn(g)}v=null}else v=null;x!==null&&yu(h,m,x,v,!1),j!==null&&S!==null&&yu(h,S,j,v,!0)}}e:{if(m=u?lr(u):window,x=m.nodeName&&m.nodeName.toLowerCase(),x==="select"||x==="input"&&m.type==="file")var k=Xg;else if(cu(m))if(Uf)k=ny;else{k=ey;var C=Zg}else(x=m.nodeName)&&x.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(k=ty);if(k&&(k=k(e,u))){Df(h,k,n,f);break e}C&&C(e,m,u),e==="focusout"&&(C=m._wrapperState)&&C.controlled&&m.type==="number"&&vo(m,"number",m.value)}switch(C=u?lr(u):window,e){case"focusin":(cu(C)||C.contentEditable==="true")&&(ir=C,Ro=u,is=null);break;case"focusout":is=Ro=ir=null;break;case"mousedown":Ao=!0;break;case"contextmenu":case"mouseup":case"dragend":Ao=!1,hu(h,n,f);break;case"selectionchange":if(ay)break;case"keydown":case"keyup":hu(h,n,f)}var N;if(Ll)e:{switch(e){case"compositionstart":var R="onCompositionStart";break e;case"compositionend":R="onCompositionEnd";break e;case"compositionupdate":R="onCompositionUpdate";break e}R=void 0}else ar?Mf(e,n)&&(R="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(R="onCompositionStart");R&&(Of&&n.locale!=="ko"&&(ar||R!=="onCompositionStart"?R==="onCompositionEnd"&&ar&&(N=Ff()):(hn=f,Pl="value"in hn?hn.value:hn.textContent,ar=!0)),C=za(u,R),0<C.length&&(R=new au(R,e,null,n,f),h.push({event:R,listeners:C}),N?R.data=N:(N=Bf(n),N!==null&&(R.data=N)))),(N=Kg?Yg(e,n):Jg(e,n))&&(u=za(u,"onBeforeInput"),0<u.length&&(f=new au("onBeforeInput","beforeinput",null,n,f),h.push({event:f,listeners:u}),f.data=N))}Xf(h,t)})}function js(e,t,n){return{instance:e,listener:t,currentTarget:n}}function za(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,i=a.stateNode;a.tag===5&&i!==null&&(a=i,i=hs(e,n),i!=null&&r.unshift(js(e,i,a)),i=hs(e,t),i!=null&&r.push(js(e,i,a))),e=e.return}return r}function Zn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function yu(e,t,n,r,a){for(var i=t._reactName,o=[];n!==null&&n!==r;){var c=n,l=c.alternate,u=c.stateNode;if(l!==null&&l===r)break;c.tag===5&&u!==null&&(c=u,a?(l=hs(n,i),l!=null&&o.unshift(js(n,l,c))):a||(l=hs(n,i),l!=null&&o.push(js(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var cy=/\r\n?/g,uy=/\u0000|\uFFFD/g;function vu(e){return(typeof e=="string"?e:""+e).replace(cy,`
38
+ `).replace(uy,"")}function Zs(e,t,n){if(t=vu(t),vu(e)!==t&&n)throw Error(D(425))}function Fa(){}var Po=null,$o=null;function _o(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 Lo=typeof setTimeout=="function"?setTimeout:void 0,dy=typeof clearTimeout=="function"?clearTimeout:void 0,xu=typeof Promise=="function"?Promise:void 0,fy=typeof queueMicrotask=="function"?queueMicrotask:typeof xu<"u"?function(e){return xu.resolve(null).then(e).catch(my)}:Lo;function my(e){setTimeout(function(){throw e})}function Hi(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),ys(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);ys(t)}function xn(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 wu(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 Pr=Math.random().toString(36).slice(2),Gt="__reactFiber$"+Pr,Ss="__reactProps$"+Pr,rn="__reactContainer$"+Pr,zo="__reactEvents$"+Pr,hy="__reactListeners$"+Pr,py="__reactHandles$"+Pr;function Fn(e){var t=e[Gt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[rn]||n[Gt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=wu(e);e!==null;){if(n=e[Gt])return n;e=wu(e)}return t}e=n,n=e.parentNode}return null}function Ls(e){return e=e[Gt]||e[rn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function lr(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(D(33))}function ui(e){return e[Ss]||null}var Fo=[],cr=-1;function En(e){return{current:e}}function Ne(e){0>cr||(e.current=Fo[cr],Fo[cr]=null,cr--)}function ke(e,t){cr++,Fo[cr]=e.current,e.current=t}var Nn={},Ze=En(Nn),dt=En(!1),Hn=Nn;function Sr(e,t){var n=e.type.contextTypes;if(!n)return Nn;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 ft(e){return e=e.childContextTypes,e!=null}function Oa(){Ne(dt),Ne(Ze)}function ju(e,t,n){if(Ze.current!==Nn)throw Error(D(168));ke(Ze,t),ke(dt,n)}function em(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(D(108,Zp(e)||"Unknown",a));return Ae({},n,r)}function Ma(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Nn,Hn=Ze.current,ke(Ze,e),ke(dt,dt.current),!0}function Su(e,t,n){var r=e.stateNode;if(!r)throw Error(D(169));n?(e=em(e,t,Hn),r.__reactInternalMemoizedMergedChildContext=e,Ne(dt),Ne(Ze),ke(Ze,e)):Ne(dt),ke(dt,n)}var qt=null,di=!1,Vi=!1;function tm(e){qt===null?qt=[e]:qt.push(e)}function gy(e){di=!0,tm(e)}function Tn(){if(!Vi&&qt!==null){Vi=!0;var e=0,t=je;try{var n=qt;for(je=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}qt=null,di=!1}catch(a){throw qt!==null&&(qt=qt.slice(e+1)),Cf(Tl,Tn),a}finally{je=t,Vi=!1}}return null}var ur=[],dr=0,Ba=null,Da=0,Nt=[],Ct=0,Vn=null,Zt=1,en="";function $n(e,t){ur[dr++]=Da,ur[dr++]=Ba,Ba=e,Da=t}function nm(e,t,n){Nt[Ct++]=Zt,Nt[Ct++]=en,Nt[Ct++]=Vn,Vn=e;var r=Zt;e=en;var a=32-Ft(r)-1;r&=~(1<<a),n+=1;var i=32-Ft(t)+a;if(30<i){var o=a-a%5;i=(r&(1<<o)-1).toString(32),r>>=o,a-=o,Zt=1<<32-Ft(t)+a|n<<a|r,en=i+e}else Zt=1<<i|n<<a|r,en=e}function Fl(e){e.return!==null&&($n(e,1),nm(e,1,0))}function Ol(e){for(;e===Ba;)Ba=ur[--dr],ur[dr]=null,Da=ur[--dr],ur[dr]=null;for(;e===Vn;)Vn=Nt[--Ct],Nt[Ct]=null,en=Nt[--Ct],Nt[Ct]=null,Zt=Nt[--Ct],Nt[Ct]=null}var xt=null,vt=null,Ee=!1,zt=null;function rm(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 ku(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,xt=e,vt=xn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,xt=e,vt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Vn!==null?{id:Zt,overflow:en}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Et(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,xt=e,vt=null,!0):!1;default:return!1}}function Oo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Mo(e){if(Ee){var t=vt;if(t){var n=t;if(!ku(e,t)){if(Oo(e))throw Error(D(418));t=xn(n.nextSibling);var r=xt;t&&ku(e,t)?rm(r,n):(e.flags=e.flags&-4097|2,Ee=!1,xt=e)}}else{if(Oo(e))throw Error(D(418));e.flags=e.flags&-4097|2,Ee=!1,xt=e}}}function bu(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;xt=e}function ea(e){if(e!==xt)return!1;if(!Ee)return bu(e),Ee=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!_o(e.type,e.memoizedProps)),t&&(t=vt)){if(Oo(e))throw sm(),Error(D(418));for(;t;)rm(e,t),t=xn(t.nextSibling)}if(bu(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(D(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){vt=xn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}vt=null}}else vt=xt?xn(e.stateNode.nextSibling):null;return!0}function sm(){for(var e=vt;e;)e=xn(e.nextSibling)}function kr(){vt=xt=null,Ee=!1}function Ml(e){zt===null?zt=[e]:zt.push(e)}var yy=ln.ReactCurrentBatchConfig;function Wr(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(D(309));var r=n.stateNode}if(!r)throw Error(D(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 c=a.refs;o===null?delete c[i]:c[i]=o},t._stringRef=i,t)}if(typeof e!="string")throw Error(D(284));if(!n._owner)throw Error(D(290,e))}return e}function ta(e,t){throw e=Object.prototype.toString.call(t),Error(D(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Nu(e){var t=e._init;return t(e._payload)}function am(e){function t(g,p){if(e){var y=g.deletions;y===null?(g.deletions=[p],g.flags|=16):y.push(p)}}function n(g,p){if(!e)return null;for(;p!==null;)t(g,p),p=p.sibling;return null}function r(g,p){for(g=new Map;p!==null;)p.key!==null?g.set(p.key,p):g.set(p.index,p),p=p.sibling;return g}function a(g,p){return g=kn(g,p),g.index=0,g.sibling=null,g}function i(g,p,y){return g.index=y,e?(y=g.alternate,y!==null?(y=y.index,y<p?(g.flags|=2,p):y):(g.flags|=2,p)):(g.flags|=1048576,p)}function o(g){return e&&g.alternate===null&&(g.flags|=2),g}function c(g,p,y,w){return p===null||p.tag!==6?(p=Xi(y,g.mode,w),p.return=g,p):(p=a(p,y),p.return=g,p)}function l(g,p,y,w){var k=y.type;return k===sr?f(g,p,y.props.children,w,y.key):p!==null&&(p.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===un&&Nu(k)===p.type)?(w=a(p,y.props),w.ref=Wr(g,p,y),w.return=g,w):(w=ka(y.type,y.key,y.props,null,g.mode,w),w.ref=Wr(g,p,y),w.return=g,w)}function u(g,p,y,w){return p===null||p.tag!==4||p.stateNode.containerInfo!==y.containerInfo||p.stateNode.implementation!==y.implementation?(p=Zi(y,g.mode,w),p.return=g,p):(p=a(p,y.children||[]),p.return=g,p)}function f(g,p,y,w,k){return p===null||p.tag!==7?(p=Wn(y,g.mode,w,k),p.return=g,p):(p=a(p,y),p.return=g,p)}function h(g,p,y){if(typeof p=="string"&&p!==""||typeof p=="number")return p=Xi(""+p,g.mode,y),p.return=g,p;if(typeof p=="object"&&p!==null){switch(p.$$typeof){case Hs:return y=ka(p.type,p.key,p.props,null,g.mode,y),y.ref=Wr(g,null,p),y.return=g,y;case rr:return p=Zi(p,g.mode,y),p.return=g,p;case un:var w=p._init;return h(g,w(p._payload),y)}if(qr(p)||Or(p))return p=Wn(p,g.mode,y,null),p.return=g,p;ta(g,p)}return null}function m(g,p,y,w){var k=p!==null?p.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return k!==null?null:c(g,p,""+y,w);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Hs:return y.key===k?l(g,p,y,w):null;case rr:return y.key===k?u(g,p,y,w):null;case un:return k=y._init,m(g,p,k(y._payload),w)}if(qr(y)||Or(y))return k!==null?null:f(g,p,y,w,null);ta(g,y)}return null}function x(g,p,y,w,k){if(typeof w=="string"&&w!==""||typeof w=="number")return g=g.get(y)||null,c(p,g,""+w,k);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Hs:return g=g.get(w.key===null?y:w.key)||null,l(p,g,w,k);case rr:return g=g.get(w.key===null?y:w.key)||null,u(p,g,w,k);case un:var C=w._init;return x(g,p,y,C(w._payload),k)}if(qr(w)||Or(w))return g=g.get(y)||null,f(p,g,w,k,null);ta(p,w)}return null}function j(g,p,y,w){for(var k=null,C=null,N=p,R=p=0,I=null;N!==null&&R<y.length;R++){N.index>R?(I=N,N=null):I=N.sibling;var L=m(g,N,y[R],w);if(L===null){N===null&&(N=I);break}e&&N&&L.alternate===null&&t(g,N),p=i(L,p,R),C===null?k=L:C.sibling=L,C=L,N=I}if(R===y.length)return n(g,N),Ee&&$n(g,R),k;if(N===null){for(;R<y.length;R++)N=h(g,y[R],w),N!==null&&(p=i(N,p,R),C===null?k=N:C.sibling=N,C=N);return Ee&&$n(g,R),k}for(N=r(g,N);R<y.length;R++)I=x(N,g,R,y[R],w),I!==null&&(e&&I.alternate!==null&&N.delete(I.key===null?R:I.key),p=i(I,p,R),C===null?k=I:C.sibling=I,C=I);return e&&N.forEach(function($){return t(g,$)}),Ee&&$n(g,R),k}function v(g,p,y,w){var k=Or(y);if(typeof k!="function")throw Error(D(150));if(y=k.call(y),y==null)throw Error(D(151));for(var C=k=null,N=p,R=p=0,I=null,L=y.next();N!==null&&!L.done;R++,L=y.next()){N.index>R?(I=N,N=null):I=N.sibling;var $=m(g,N,L.value,w);if($===null){N===null&&(N=I);break}e&&N&&$.alternate===null&&t(g,N),p=i($,p,R),C===null?k=$:C.sibling=$,C=$,N=I}if(L.done)return n(g,N),Ee&&$n(g,R),k;if(N===null){for(;!L.done;R++,L=y.next())L=h(g,L.value,w),L!==null&&(p=i(L,p,R),C===null?k=L:C.sibling=L,C=L);return Ee&&$n(g,R),k}for(N=r(g,N);!L.done;R++,L=y.next())L=x(N,g,R,L.value,w),L!==null&&(e&&L.alternate!==null&&N.delete(L.key===null?R:L.key),p=i(L,p,R),C===null?k=L:C.sibling=L,C=L);return e&&N.forEach(function(T){return t(g,T)}),Ee&&$n(g,R),k}function S(g,p,y,w){if(typeof y=="object"&&y!==null&&y.type===sr&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Hs:e:{for(var k=y.key,C=p;C!==null;){if(C.key===k){if(k=y.type,k===sr){if(C.tag===7){n(g,C.sibling),p=a(C,y.props.children),p.return=g,g=p;break e}}else if(C.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===un&&Nu(k)===C.type){n(g,C.sibling),p=a(C,y.props),p.ref=Wr(g,C,y),p.return=g,g=p;break e}n(g,C);break}else t(g,C);C=C.sibling}y.type===sr?(p=Wn(y.props.children,g.mode,w,y.key),p.return=g,g=p):(w=ka(y.type,y.key,y.props,null,g.mode,w),w.ref=Wr(g,p,y),w.return=g,g=w)}return o(g);case rr:e:{for(C=y.key;p!==null;){if(p.key===C)if(p.tag===4&&p.stateNode.containerInfo===y.containerInfo&&p.stateNode.implementation===y.implementation){n(g,p.sibling),p=a(p,y.children||[]),p.return=g,g=p;break e}else{n(g,p);break}else t(g,p);p=p.sibling}p=Zi(y,g.mode,w),p.return=g,g=p}return o(g);case un:return C=y._init,S(g,p,C(y._payload),w)}if(qr(y))return j(g,p,y,w);if(Or(y))return v(g,p,y,w);ta(g,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,p!==null&&p.tag===6?(n(g,p.sibling),p=a(p,y),p.return=g,g=p):(n(g,p),p=Xi(y,g.mode,w),p.return=g,g=p),o(g)):n(g,p)}return S}var br=am(!0),im=am(!1),Ua=En(null),Wa=null,fr=null,Bl=null;function Dl(){Bl=fr=Wa=null}function Ul(e){var t=Ua.current;Ne(Ua),e._currentValue=t}function Bo(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 xr(e,t){Wa=e,Bl=fr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ut=!0),e.firstContext=null)}function Rt(e){var t=e._currentValue;if(Bl!==e)if(e={context:e,memoizedValue:t,next:null},fr===null){if(Wa===null)throw Error(D(308));fr=e,Wa.dependencies={lanes:0,firstContext:e}}else fr=fr.next=e;return t}var On=null;function Wl(e){On===null?On=[e]:On.push(e)}function om(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,Wl(t)):(n.next=a.next,a.next=n),t.interleaved=n,sn(e,r)}function sn(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 dn=!1;function Hl(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function lm(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 tn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(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,sn(e,n)}return a=r.interleaved,a===null?(t.next=t,Wl(r)):(t.next=a.next,a.next=t),r.interleaved=t,sn(e,n)}function ya(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Il(e,n)}}function Cu(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 Ha(e,t,n,r){var a=e.updateQueue;dn=!1;var i=a.firstBaseUpdate,o=a.lastBaseUpdate,c=a.shared.pending;if(c!==null){a.shared.pending=null;var l=c,u=l.next;l.next=null,o===null?i=u:o.next=u,o=l;var f=e.alternate;f!==null&&(f=f.updateQueue,c=f.lastBaseUpdate,c!==o&&(c===null?f.firstBaseUpdate=u:c.next=u,f.lastBaseUpdate=l))}if(i!==null){var h=a.baseState;o=0,f=u=l=null,c=i;do{var m=c.lane,x=c.eventTime;if((r&m)===m){f!==null&&(f=f.next={eventTime:x,lane:0,tag:c.tag,payload:c.payload,callback:c.callback,next:null});e:{var j=e,v=c;switch(m=t,x=n,v.tag){case 1:if(j=v.payload,typeof j=="function"){h=j.call(x,h,m);break e}h=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=v.payload,m=typeof j=="function"?j.call(x,h,m):j,m==null)break e;h=Ae({},h,m);break e;case 2:dn=!0}}c.callback!==null&&c.lane!==0&&(e.flags|=64,m=a.effects,m===null?a.effects=[c]:m.push(c))}else x={eventTime:x,lane:m,tag:c.tag,payload:c.payload,callback:c.callback,next:null},f===null?(u=f=x,l=h):f=f.next=x,o|=m;if(c=c.next,c===null){if(c=a.shared.pending,c===null)break;m=c,c=m.next,m.next=null,a.lastBaseUpdate=m,a.shared.pending=null}}while(!0);if(f===null&&(l=h),a.baseState=l,a.firstBaseUpdate=u,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);Kn|=o,e.lanes=o,e.memoizedState=h}}function Eu(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(D(191,a));a.call(r)}}}var zs={},Yt=En(zs),ks=En(zs),bs=En(zs);function Mn(e){if(e===zs)throw Error(D(174));return e}function Vl(e,t){switch(ke(bs,t),ke(ks,e),ke(Yt,zs),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:wo(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=wo(t,e)}Ne(Yt),ke(Yt,t)}function Nr(){Ne(Yt),Ne(ks),Ne(bs)}function cm(e){Mn(bs.current);var t=Mn(Yt.current),n=wo(t,e.type);t!==n&&(ke(ks,e),ke(Yt,n))}function Gl(e){ks.current===e&&(Ne(Yt),Ne(ks))}var Ie=En(0);function Va(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 Gi=[];function Kl(){for(var e=0;e<Gi.length;e++)Gi[e]._workInProgressVersionPrimary=null;Gi.length=0}var va=ln.ReactCurrentDispatcher,Ki=ln.ReactCurrentBatchConfig,Gn=0,Re=null,Me=null,He=null,Ga=!1,os=!1,Ns=0,vy=0;function Qe(){throw Error(D(321))}function Yl(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Bt(e[n],t[n]))return!1;return!0}function Jl(e,t,n,r,a,i){if(Gn=i,Re=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,va.current=e===null||e.memoizedState===null?Sy:ky,e=n(r,a),os){i=0;do{if(os=!1,Ns=0,25<=i)throw Error(D(301));i+=1,He=Me=null,t.updateQueue=null,va.current=by,e=n(r,a)}while(os)}if(va.current=Ka,t=Me!==null&&Me.next!==null,Gn=0,He=Me=Re=null,Ga=!1,t)throw Error(D(300));return e}function Ql(){var e=Ns!==0;return Ns=0,e}function Vt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return He===null?Re.memoizedState=He=e:He=He.next=e,He}function At(){if(Me===null){var e=Re.alternate;e=e!==null?e.memoizedState:null}else e=Me.next;var t=He===null?Re.memoizedState:He.next;if(t!==null)He=t,Me=e;else{if(e===null)throw Error(D(310));Me=e,e={memoizedState:Me.memoizedState,baseState:Me.baseState,baseQueue:Me.baseQueue,queue:Me.queue,next:null},He===null?Re.memoizedState=He=e:He=He.next=e}return He}function Cs(e,t){return typeof t=="function"?t(e):t}function Yi(e){var t=At(),n=t.queue;if(n===null)throw Error(D(311));n.lastRenderedReducer=e;var r=Me,a=r.baseQueue,i=n.pending;if(i!==null){if(a!==null){var o=a.next;a.next=i.next,i.next=o}r.baseQueue=a=i,n.pending=null}if(a!==null){i=a.next,r=r.baseState;var c=o=null,l=null,u=i;do{var f=u.lane;if((Gn&f)===f)l!==null&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var h={lane:f,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};l===null?(c=l=h,o=r):l=l.next=h,Re.lanes|=f,Kn|=f}u=u.next}while(u!==null&&u!==i);l===null?o=r:l.next=c,Bt(r,t.memoizedState)||(ut=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=l,n.lastRenderedState=r}if(e=n.interleaved,e!==null){a=e;do i=a.lane,Re.lanes|=i,Kn|=i,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Ji(e){var t=At(),n=t.queue;if(n===null)throw Error(D(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);Bt(i,t.memoizedState)||(ut=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function um(){}function dm(e,t){var n=Re,r=At(),a=t(),i=!Bt(r.memoizedState,a);if(i&&(r.memoizedState=a,ut=!0),r=r.queue,ql(hm.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||He!==null&&He.memoizedState.tag&1){if(n.flags|=2048,Es(9,mm.bind(null,n,r,a,t),void 0,null),Ve===null)throw Error(D(349));Gn&30||fm(n,t,a)}return a}function fm(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 mm(e,t,n,r){t.value=n,t.getSnapshot=r,pm(t)&&gm(e)}function hm(e,t,n){return n(function(){pm(t)&&gm(e)})}function pm(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Bt(e,n)}catch{return!0}}function gm(e){var t=sn(e,1);t!==null&&Ot(t,e,1,-1)}function Tu(e){var t=Vt();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Cs,lastRenderedState:e},t.queue=e,e=e.dispatch=jy.bind(null,Re,e),[t.memoizedState,e]}function Es(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 ym(){return At().memoizedState}function xa(e,t,n,r){var a=Vt();Re.flags|=e,a.memoizedState=Es(1|t,n,void 0,r===void 0?null:r)}function fi(e,t,n,r){var a=At();r=r===void 0?null:r;var i=void 0;if(Me!==null){var o=Me.memoizedState;if(i=o.destroy,r!==null&&Yl(r,o.deps)){a.memoizedState=Es(t,n,i,r);return}}Re.flags|=e,a.memoizedState=Es(1|t,n,i,r)}function Iu(e,t){return xa(8390656,8,e,t)}function ql(e,t){return fi(2048,8,e,t)}function vm(e,t){return fi(4,2,e,t)}function xm(e,t){return fi(4,4,e,t)}function wm(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 jm(e,t,n){return n=n!=null?n.concat([e]):null,fi(4,4,wm.bind(null,t,e),n)}function Xl(){}function Sm(e,t){var n=At();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Yl(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function km(e,t){var n=At();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Yl(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function bm(e,t,n){return Gn&21?(Bt(n,t)||(n=If(),Re.lanes|=n,Kn|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ut=!0),e.memoizedState=n)}function xy(e,t){var n=je;je=n!==0&&4>n?n:4,e(!0);var r=Ki.transition;Ki.transition={};try{e(!1),t()}finally{je=n,Ki.transition=r}}function Nm(){return At().memoizedState}function wy(e,t,n){var r=Sn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Cm(e))Em(t,n);else if(n=om(e,t,n,r),n!==null){var a=nt();Ot(n,e,r,a),Tm(n,t,r)}}function jy(e,t,n){var r=Sn(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Cm(e))Em(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,c=i(o,n);if(a.hasEagerState=!0,a.eagerState=c,Bt(c,o)){var l=t.interleaved;l===null?(a.next=a,Wl(t)):(a.next=l.next,l.next=a),t.interleaved=a;return}}catch{}finally{}n=om(e,t,a,r),n!==null&&(a=nt(),Ot(n,e,r,a),Tm(n,t,r))}}function Cm(e){var t=e.alternate;return e===Re||t!==null&&t===Re}function Em(e,t){os=Ga=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Tm(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Il(e,n)}}var Ka={readContext:Rt,useCallback:Qe,useContext:Qe,useEffect:Qe,useImperativeHandle:Qe,useInsertionEffect:Qe,useLayoutEffect:Qe,useMemo:Qe,useReducer:Qe,useRef:Qe,useState:Qe,useDebugValue:Qe,useDeferredValue:Qe,useTransition:Qe,useMutableSource:Qe,useSyncExternalStore:Qe,useId:Qe,unstable_isNewReconciler:!1},Sy={readContext:Rt,useCallback:function(e,t){return Vt().memoizedState=[e,t===void 0?null:t],e},useContext:Rt,useEffect:Iu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,xa(4194308,4,wm.bind(null,t,e),n)},useLayoutEffect:function(e,t){return xa(4194308,4,e,t)},useInsertionEffect:function(e,t){return xa(4,2,e,t)},useMemo:function(e,t){var n=Vt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Vt();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=wy.bind(null,Re,e),[r.memoizedState,e]},useRef:function(e){var t=Vt();return e={current:e},t.memoizedState=e},useState:Tu,useDebugValue:Xl,useDeferredValue:function(e){return Vt().memoizedState=e},useTransition:function(){var e=Tu(!1),t=e[0];return e=xy.bind(null,e[1]),Vt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Re,a=Vt();if(Ee){if(n===void 0)throw Error(D(407));n=n()}else{if(n=t(),Ve===null)throw Error(D(349));Gn&30||fm(r,t,n)}a.memoizedState=n;var i={value:n,getSnapshot:t};return a.queue=i,Iu(hm.bind(null,r,i,e),[e]),r.flags|=2048,Es(9,mm.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Vt(),t=Ve.identifierPrefix;if(Ee){var n=en,r=Zt;n=(r&~(1<<32-Ft(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Ns++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=vy++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},ky={readContext:Rt,useCallback:Sm,useContext:Rt,useEffect:ql,useImperativeHandle:jm,useInsertionEffect:vm,useLayoutEffect:xm,useMemo:km,useReducer:Yi,useRef:ym,useState:function(){return Yi(Cs)},useDebugValue:Xl,useDeferredValue:function(e){var t=At();return bm(t,Me.memoizedState,e)},useTransition:function(){var e=Yi(Cs)[0],t=At().memoizedState;return[e,t]},useMutableSource:um,useSyncExternalStore:dm,useId:Nm,unstable_isNewReconciler:!1},by={readContext:Rt,useCallback:Sm,useContext:Rt,useEffect:ql,useImperativeHandle:jm,useInsertionEffect:vm,useLayoutEffect:xm,useMemo:km,useReducer:Ji,useRef:ym,useState:function(){return Ji(Cs)},useDebugValue:Xl,useDeferredValue:function(e){var t=At();return Me===null?t.memoizedState=e:bm(t,Me.memoizedState,e)},useTransition:function(){var e=Ji(Cs)[0],t=At().memoizedState;return[e,t]},useMutableSource:um,useSyncExternalStore:dm,useId:Nm,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 Do(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 mi={isMounted:function(e){return(e=e._reactInternals)?qn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=nt(),a=Sn(e),i=tn(r,a);i.payload=t,n!=null&&(i.callback=n),t=wn(e,i,a),t!==null&&(Ot(t,e,a,r),ya(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=nt(),a=Sn(e),i=tn(r,a);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=wn(e,i,a),t!==null&&(Ot(t,e,a,r),ya(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=nt(),r=Sn(e),a=tn(n,r);a.tag=2,t!=null&&(a.callback=t),t=wn(e,a,r),t!==null&&(Ot(t,e,r,n),ya(t,e,r))}};function Ru(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?!xs(n,r)||!xs(a,i):!0}function Im(e,t,n){var r=!1,a=Nn,i=t.contextType;return typeof i=="object"&&i!==null?i=Rt(i):(a=ft(t)?Hn:Ze.current,r=t.contextTypes,i=(r=r!=null)?Sr(e,a):Nn),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=mi,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=i),t}function Au(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&&mi.enqueueReplaceState(t,t.state,null)}function Uo(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},Hl(e);var i=t.contextType;typeof i=="object"&&i!==null?a.context=Rt(i):(i=ft(t)?Hn:Ze.current,a.context=Sr(e,i)),a.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Do(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&&mi.enqueueReplaceState(a,a.state,null),Ha(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function Cr(e,t){try{var n="",r=t;do n+=Xp(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 Qi(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Wo(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Ny=typeof WeakMap=="function"?WeakMap:Map;function Rm(e,t,n){n=tn(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Ja||(Ja=!0,Zo=r),Wo(e,t)},n}function Am(e,t,n){n=tn(-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(){Wo(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Wo(e,t),typeof r!="function"&&(jn===null?jn=new Set([this]):jn.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function Pu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ny;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=My.bind(null,e,t,n),t.then(e,e))}function $u(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 _u(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=tn(-1,1),t.tag=2,wn(n,t,1))),n.lanes|=1),e)}var Cy=ln.ReactCurrentOwner,ut=!1;function tt(e,t,n,r){t.child=e===null?im(t,null,n,r):br(t,e.child,n,r)}function Lu(e,t,n,r,a){n=n.render;var i=t.ref;return xr(t,a),r=Jl(e,t,n,r,i,a),n=Ql(),e!==null&&!ut?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,an(e,t,a)):(Ee&&n&&Fl(t),t.flags|=1,tt(e,t,r,a),t.child)}function zu(e,t,n,r,a){if(e===null){var i=n.type;return typeof i=="function"&&!ic(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,Pm(e,t,i,r,a)):(e=ka(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:xs,n(o,r)&&e.ref===t.ref)return an(e,t,a)}return t.flags|=1,e=kn(i,r),e.ref=t.ref,e.return=t,t.child=e}function Pm(e,t,n,r,a){if(e!==null){var i=e.memoizedProps;if(xs(i,r)&&e.ref===t.ref)if(ut=!1,t.pendingProps=r=i,(e.lanes&a)!==0)e.flags&131072&&(ut=!0);else return t.lanes=e.lanes,an(e,t,a)}return Ho(e,t,n,r,a)}function $m(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},ke(hr,yt),yt|=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,ke(hr,yt),yt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,ke(hr,yt),yt|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,ke(hr,yt),yt|=r;return tt(e,t,a,n),t.child}function _m(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ho(e,t,n,r,a){var i=ft(n)?Hn:Ze.current;return i=Sr(t,i),xr(t,a),n=Jl(e,t,n,r,i,a),r=Ql(),e!==null&&!ut?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,an(e,t,a)):(Ee&&r&&Fl(t),t.flags|=1,tt(e,t,n,a),t.child)}function Fu(e,t,n,r,a){if(ft(n)){var i=!0;Ma(t)}else i=!1;if(xr(t,a),t.stateNode===null)wa(e,t),Im(t,n,r),Uo(t,n,r,a),r=!0;else if(e===null){var o=t.stateNode,c=t.memoizedProps;o.props=c;var l=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=Rt(u):(u=ft(n)?Hn:Ze.current,u=Sr(t,u));var f=n.getDerivedStateFromProps,h=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(c!==r||l!==u)&&Au(t,o,r,u),dn=!1;var m=t.memoizedState;o.state=m,Ha(t,r,o,a),l=t.memoizedState,c!==r||m!==l||dt.current||dn?(typeof f=="function"&&(Do(t,n,f,r),l=t.memoizedState),(c=dn||Ru(t,n,c,r,m,l,u))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),o.props=r,o.state=l,o.context=u,r=c):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,lm(e,t),c=t.memoizedProps,u=t.type===t.elementType?c:_t(t.type,c),o.props=u,h=t.pendingProps,m=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=Rt(l):(l=ft(n)?Hn:Ze.current,l=Sr(t,l));var x=n.getDerivedStateFromProps;(f=typeof x=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(c!==h||m!==l)&&Au(t,o,r,l),dn=!1,m=t.memoizedState,o.state=m,Ha(t,r,o,a);var j=t.memoizedState;c!==h||m!==j||dt.current||dn?(typeof x=="function"&&(Do(t,n,x,r),j=t.memoizedState),(u=dn||Ru(t,n,u,r,m,j,l)||!1)?(f||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,j,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,j,l)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||c===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=j),o.props=r,o.state=j,o.context=l,r=u):(typeof o.componentDidUpdate!="function"||c===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return Vo(e,t,n,r,i,a)}function Vo(e,t,n,r,a,i){_m(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return a&&Su(t,n,!1),an(e,t,i);r=t.stateNode,Cy.current=t;var c=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=br(t,e.child,null,i),t.child=br(t,null,c,i)):tt(e,t,c,i),t.memoizedState=r.state,a&&Su(t,n,!0),t.child}function Lm(e){var t=e.stateNode;t.pendingContext?ju(e,t.pendingContext,t.pendingContext!==t.context):t.context&&ju(e,t.context,!1),Vl(e,t.containerInfo)}function Ou(e,t,n,r,a){return kr(),Ml(a),t.flags|=256,tt(e,t,n,r),t.child}var Go={dehydrated:null,treeContext:null,retryLane:0};function Ko(e){return{baseLanes:e,cachePool:null,transitions:null}}function zm(e,t,n){var r=t.pendingProps,a=Ie.current,i=!1,o=(t.flags&128)!==0,c;if((c=o)||(c=e!==null&&e.memoizedState===null?!1:(a&2)!==0),c?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),ke(Ie,a&1),e===null)return Mo(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=gi(o,r,0,null),e=Wn(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Ko(n),t.memoizedState=Go,e):Zl(t,o));if(a=e.memoizedState,a!==null&&(c=a.dehydrated,c!==null))return Ey(e,t,o,r,c,a,n);if(i){i=r.fallback,o=t.mode,a=e.child,c=a.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&t.child!==a?(r=t.child,r.childLanes=0,r.pendingProps=l,t.deletions=null):(r=kn(a,l),r.subtreeFlags=a.subtreeFlags&14680064),c!==null?i=kn(c,i):(i=Wn(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?Ko(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=Go,r}return i=e.child,e=i.sibling,r=kn(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 Zl(e,t){return t=gi({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function na(e,t,n,r){return r!==null&&Ml(r),br(t,e.child,null,n),e=Zl(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Ey(e,t,n,r,a,i,o){if(n)return t.flags&256?(t.flags&=-257,r=Qi(Error(D(422))),na(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,a=t.mode,r=gi({mode:"visible",children:r.children},a,0,null),i=Wn(i,a,o,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&br(t,e.child,null,o),t.child.memoizedState=Ko(o),t.memoizedState=Go,i);if(!(t.mode&1))return na(e,t,o,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var c=r.dgst;return r=c,i=Error(D(419)),r=Qi(i,r,void 0),na(e,t,o,r)}if(c=(o&e.childLanes)!==0,ut||c){if(r=Ve,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,sn(e,a),Ot(r,e,a,-1))}return ac(),r=Qi(Error(D(421))),na(e,t,o,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=By.bind(null,e),a._reactRetry=t,null):(e=i.treeContext,vt=xn(a.nextSibling),xt=t,Ee=!0,zt=null,e!==null&&(Nt[Ct++]=Zt,Nt[Ct++]=en,Nt[Ct++]=Vn,Zt=e.id,en=e.overflow,Vn=t),t=Zl(t,r.children),t.flags|=4096,t)}function Mu(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Bo(e.return,t,n)}function qi(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 Fm(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&&Mu(e,n,t);else if(e.tag===19)Mu(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(ke(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&&Va(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),qi(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&&Va(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}qi(t,!0,n,null,i);break;case"together":qi(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function wa(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function an(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Kn|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(D(153));if(t.child!==null){for(e=t.child,n=kn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=kn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Ty(e,t,n){switch(t.tag){case 3:Lm(t),kr();break;case 5:cm(t);break;case 1:ft(t.type)&&Ma(t);break;case 4:Vl(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;ke(Ua,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(ke(Ie,Ie.current&1),t.flags|=128,null):n&t.child.childLanes?zm(e,t,n):(ke(Ie,Ie.current&1),e=an(e,t,n),e!==null?e.sibling:null);ke(Ie,Ie.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Fm(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),ke(Ie,Ie.current),r)break;return null;case 22:case 23:return t.lanes=0,$m(e,t,n)}return an(e,t,n)}var Om,Yo,Mm,Bm;Om=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}};Yo=function(){};Mm=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,Mn(Yt.current);var i=null;switch(n){case"input":a=go(e,a),r=go(e,r),i=[];break;case"select":a=Ae({},a,{value:void 0}),r=Ae({},r,{value:void 0}),i=[];break;case"textarea":a=xo(e,a),r=xo(e,r),i=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Fa)}jo(n,r);var o;n=null;for(u in a)if(!r.hasOwnProperty(u)&&a.hasOwnProperty(u)&&a[u]!=null)if(u==="style"){var c=a[u];for(o in c)c.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(fs.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in r){var l=r[u];if(c=a!=null?a[u]:void 0,r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null))if(u==="style")if(c){for(o in c)!c.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in l)l.hasOwnProperty(o)&&c[o]!==l[o]&&(n||(n={}),n[o]=l[o])}else n||(i||(i=[]),i.push(u,n)),n=l;else u==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(i=i||[]).push(u,l)):u==="children"?typeof l!="string"&&typeof l!="number"||(i=i||[]).push(u,""+l):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(fs.hasOwnProperty(u)?(l!=null&&u==="onScroll"&&be("scroll",e),i||c===l||(i=[])):(i=i||[]).push(u,l))}n&&(i=i||[]).push("style",n);var u=i;(t.updateQueue=u)&&(t.flags|=4)}};Bm=function(e,t,n,r){n!==r&&(t.flags|=4)};function Hr(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 Iy(e,t,n){var r=t.pendingProps;switch(Ol(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 ft(t.type)&&Oa(),qe(t),null;case 3:return r=t.stateNode,Nr(),Ne(dt),Ne(Ze),Kl(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(ea(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,zt!==null&&(nl(zt),zt=null))),Yo(e,t),qe(t),null;case 5:Gl(t);var a=Mn(bs.current);if(n=t.type,e!==null&&t.stateNode!=null)Mm(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(D(166));return qe(t),null}if(e=Mn(Yt.current),ea(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Gt]=t,r[Ss]=i,e=(t.mode&1)!==0,n){case"dialog":be("cancel",r),be("close",r);break;case"iframe":case"object":case"embed":be("load",r);break;case"video":case"audio":for(a=0;a<Zr.length;a++)be(Zr[a],r);break;case"source":be("error",r);break;case"img":case"image":case"link":be("error",r),be("load",r);break;case"details":be("toggle",r);break;case"input":Yc(r,i),be("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},be("invalid",r);break;case"textarea":Qc(r,i),be("invalid",r)}jo(n,i),a=null;for(var o in i)if(i.hasOwnProperty(o)){var c=i[o];o==="children"?typeof c=="string"?r.textContent!==c&&(i.suppressHydrationWarning!==!0&&Zs(r.textContent,c,e),a=["children",c]):typeof c=="number"&&r.textContent!==""+c&&(i.suppressHydrationWarning!==!0&&Zs(r.textContent,c,e),a=["children",""+c]):fs.hasOwnProperty(o)&&c!=null&&o==="onScroll"&&be("scroll",r)}switch(n){case"input":Vs(r),Jc(r,i,!0);break;case"textarea":Vs(r),qc(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Fa)}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=hf(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[Gt]=t,e[Ss]=r,Om(e,t,!1,!1),t.stateNode=e;e:{switch(o=So(n,r),n){case"dialog":be("cancel",e),be("close",e),a=r;break;case"iframe":case"object":case"embed":be("load",e),a=r;break;case"video":case"audio":for(a=0;a<Zr.length;a++)be(Zr[a],e);a=r;break;case"source":be("error",e),a=r;break;case"img":case"image":case"link":be("error",e),be("load",e),a=r;break;case"details":be("toggle",e),a=r;break;case"input":Yc(e,r),a=go(e,r),be("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=Ae({},r,{value:void 0}),be("invalid",e);break;case"textarea":Qc(e,r),a=xo(e,r),be("invalid",e);break;default:a=r}jo(n,a),c=a;for(i in c)if(c.hasOwnProperty(i)){var l=c[i];i==="style"?yf(e,l):i==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&pf(e,l)):i==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&ms(e,l):typeof l=="number"&&ms(e,""+l):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(fs.hasOwnProperty(i)?l!=null&&i==="onScroll"&&be("scroll",e):l!=null&&kl(e,i,l,o))}switch(n){case"input":Vs(e),Jc(e,r,!1);break;case"textarea":Vs(e),qc(e);break;case"option":r.value!=null&&e.setAttribute("value",""+bn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?pr(e,!!r.multiple,i,!1):r.defaultValue!=null&&pr(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=Fa)}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)Bm(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(D(166));if(n=Mn(bs.current),Mn(Yt.current),ea(t)){if(r=t.stateNode,n=t.memoizedProps,r[Gt]=t,(i=r.nodeValue!==n)&&(e=xt,e!==null))switch(e.tag){case 3:Zs(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Zs(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Gt]=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&&vt!==null&&t.mode&1&&!(t.flags&128))sm(),kr(),t.flags|=98560,i=!1;else if(i=ea(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(D(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(D(317));i[Gt]=t}else kr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;qe(t),i=!1}else zt!==null&&(nl(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?De===0&&(De=3):ac())),t.updateQueue!==null&&(t.flags|=4),qe(t),null);case 4:return Nr(),Yo(e,t),e===null&&ws(t.stateNode.containerInfo),qe(t),null;case 10:return Ul(t.type._context),qe(t),null;case 17:return ft(t.type)&&Oa(),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)Hr(i,!1);else{if(De!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Va(e),o!==null){for(t.flags|=128,Hr(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 ke(Ie,Ie.current&1|2),t.child}e=e.sibling}i.tail!==null&&Le()>Er&&(t.flags|=128,r=!0,Hr(i,!1),t.lanes=4194304)}else{if(!r)if(e=Va(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Hr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!Ee)return qe(t),null}else 2*Le()-i.renderingStartTime>Er&&n!==1073741824&&(t.flags|=128,r=!0,Hr(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,ke(Ie,r?n&1|2:n&1),t):(qe(t),null);case 22:case 23:return sc(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?yt&1073741824&&(qe(t),t.subtreeFlags&6&&(t.flags|=8192)):qe(t),null;case 24:return null;case 25:return null}throw Error(D(156,t.tag))}function Ry(e,t){switch(Ol(t),t.tag){case 1:return ft(t.type)&&Oa(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Nr(),Ne(dt),Ne(Ze),Kl(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Gl(t),null;case 13:if(Ne(Ie),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(D(340));kr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ne(Ie),null;case 4:return Nr(),null;case 10:return Ul(t.type._context),null;case 22:case 23:return sc(),null;case 24:return null;default:return null}}var ra=!1,Xe=!1,Ay=typeof WeakSet=="function"?WeakSet:Set,Q=null;function mr(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 Jo(e,t,n){try{n()}catch(r){$e(e,t,r)}}var Bu=!1;function Py(e,t){if(Po=_a,e=Vf(),zl(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,c=-1,l=-1,u=0,f=0,h=e,m=null;t:for(;;){for(var x;h!==n||a!==0&&h.nodeType!==3||(c=o+a),h!==i||r!==0&&h.nodeType!==3||(l=o+r),h.nodeType===3&&(o+=h.nodeValue.length),(x=h.firstChild)!==null;)m=h,h=x;for(;;){if(h===e)break t;if(m===n&&++u===a&&(c=o),m===i&&++f===r&&(l=o),(x=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=x}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for($o={focusedElem:e,selectionRange:n},_a=!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,p=g.getSnapshotBeforeUpdate(t.elementType===t.type?v:_t(t.type,v),S);g.__reactInternalSnapshotBeforeUpdate=p}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(D(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=Bu,Bu=!1,j}function ls(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&&Jo(t,n,i)}a=a.next}while(a!==r)}}function hi(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 Qo(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[Gt],delete t[Ss],delete t[zo],delete t[hy],delete t[py])),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 Um(e){return e.tag===5||e.tag===3||e.tag===4}function Du(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Um(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 qo(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=Fa));else if(r!==4&&(e=e.child,e!==null))for(qo(e,t,n),e=e.sibling;e!==null;)qo(e,t,n),e=e.sibling}function Xo(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(Xo(e,t,n),e=e.sibling;e!==null;)Xo(e,t,n),e=e.sibling}var Ke=null,Lt=!1;function cn(e,t,n){for(n=n.child;n!==null;)Wm(e,t,n),n=n.sibling}function Wm(e,t,n){if(Kt&&typeof Kt.onCommitFiberUnmount=="function")try{Kt.onCommitFiberUnmount(ii,n)}catch{}switch(n.tag){case 5:Xe||mr(n,t);case 6:var r=Ke,a=Lt;Ke=null,cn(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?Hi(e.parentNode,n):e.nodeType===1&&Hi(e,n),ys(e)):Hi(Ke,n.stateNode));break;case 4:r=Ke,a=Lt,Ke=n.stateNode.containerInfo,Lt=!0,cn(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)&&Jo(n,t,o),a=a.next}while(a!==r)}cn(e,t,n);break;case 1:if(!Xe&&(mr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(c){$e(n,t,c)}cn(e,t,n);break;case 21:cn(e,t,n);break;case 22:n.mode&1?(Xe=(r=Xe)||n.memoizedState!==null,cn(e,t,n),Xe=r):cn(e,t,n);break;default:cn(e,t,n)}}function Uu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Ay),t.forEach(function(r){var a=Dy.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function $t(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,c=o;e:for(;c!==null;){switch(c.tag){case 5:Ke=c.stateNode,Lt=!1;break e;case 3:Ke=c.stateNode.containerInfo,Lt=!0;break e;case 4:Ke=c.stateNode.containerInfo,Lt=!0;break e}c=c.return}if(Ke===null)throw Error(D(160));Wm(i,o,a),Ke=null,Lt=!1;var l=a.alternate;l!==null&&(l.return=null),a.return=null}catch(u){$e(a,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Hm(t,e),t=t.sibling}function Hm(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if($t(t,e),Ht(e),r&4){try{ls(3,e,e.return),hi(3,e)}catch(v){$e(e,e.return,v)}try{ls(5,e,e.return)}catch(v){$e(e,e.return,v)}}break;case 1:$t(t,e),Ht(e),r&512&&n!==null&&mr(n,n.return);break;case 5:if($t(t,e),Ht(e),r&512&&n!==null&&mr(n,n.return),e.flags&32){var a=e.stateNode;try{ms(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,c=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{c==="input"&&i.type==="radio"&&i.name!=null&&ff(a,i),So(c,o);var u=So(c,i);for(o=0;o<l.length;o+=2){var f=l[o],h=l[o+1];f==="style"?yf(a,h):f==="dangerouslySetInnerHTML"?pf(a,h):f==="children"?ms(a,h):kl(a,f,h,u)}switch(c){case"input":yo(a,i);break;case"textarea":mf(a,i);break;case"select":var m=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!i.multiple;var x=i.value;x!=null?pr(a,!!i.multiple,x,!1):m!==!!i.multiple&&(i.defaultValue!=null?pr(a,!!i.multiple,i.defaultValue,!0):pr(a,!!i.multiple,i.multiple?[]:"",!1))}a[Ss]=i}catch(v){$e(e,e.return,v)}}break;case 6:if($t(t,e),Ht(e),r&4){if(e.stateNode===null)throw Error(D(162));a=e.stateNode,i=e.memoizedProps;try{a.nodeValue=i}catch(v){$e(e,e.return,v)}}break;case 3:if($t(t,e),Ht(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{ys(t.containerInfo)}catch(v){$e(e,e.return,v)}break;case 4:$t(t,e),Ht(e);break;case 13:$t(t,e),Ht(e),a=e.child,a.flags&8192&&(i=a.memoizedState!==null,a.stateNode.isHidden=i,!i||a.alternate!==null&&a.alternate.memoizedState!==null||(nc=Le())),r&4&&Uu(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Xe=(u=Xe)||f,$t(t,e),Xe=u):$t(t,e),Ht(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!f&&e.mode&1)for(Q=e,f=e.child;f!==null;){for(h=Q=f;Q!==null;){switch(m=Q,x=m.child,m.tag){case 0:case 11:case 14:case 15:ls(4,m,m.return);break;case 1:mr(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:mr(m,m.return);break;case 22:if(m.memoizedState!==null){Hu(h);continue}}x!==null?(x.return=m,Q=x):Hu(h)}f=f.sibling}e:for(f=null,h=e;;){if(h.tag===5){if(f===null){f=h;try{a=h.stateNode,u?(i=a.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(c=h.stateNode,l=h.memoizedProps.style,o=l!=null&&l.hasOwnProperty("display")?l.display:null,c.style.display=gf("display",o))}catch(v){$e(e,e.return,v)}}}else if(h.tag===6){if(f===null)try{h.stateNode.nodeValue=u?"":h.memoizedProps}catch(v){$e(e,e.return,v)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===e)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;h.sibling===null;){if(h.return===null||h.return===e)break e;f===h&&(f=null),h=h.return}f===h&&(f=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:$t(t,e),Ht(e),r&4&&Uu(e);break;case 21:break;default:$t(t,e),Ht(e)}}function Ht(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Um(n)){var r=n;break e}n=n.return}throw Error(D(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(ms(a,""),r.flags&=-33);var i=Du(e);Xo(e,i,a);break;case 3:case 4:var o=r.stateNode.containerInfo,c=Du(e);qo(e,c,o);break;default:throw Error(D(161))}}catch(l){$e(e,e.return,l)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function $y(e,t,n){Q=e,Vm(e)}function Vm(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||ra;if(!o){var c=a.alternate,l=c!==null&&c.memoizedState!==null||Xe;c=ra;var u=Xe;if(ra=o,(Xe=l)&&!u)for(Q=a;Q!==null;)o=Q,l=o.child,o.tag===22&&o.memoizedState!==null?Vu(a):l!==null?(l.return=o,Q=l):Vu(a);for(;i!==null;)Q=i,Vm(i),i=i.sibling;Q=a,ra=c,Xe=u}Wu(e)}else a.subtreeFlags&8772&&i!==null?(i.return=a,Q=i):Wu(e)}}function Wu(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||hi(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&&Eu(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}Eu(t,o,n)}break;case 5:var c=t.stateNode;if(n===null&&t.flags&4){n=c;var l=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var f=u.memoizedState;if(f!==null){var h=f.dehydrated;h!==null&&ys(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(D(163))}Xe||t.flags&512&&Qo(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 Hu(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 Vu(e){for(;Q!==null;){var t=Q;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{hi(4,t)}catch(l){$e(t,n,l)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(l){$e(t,a,l)}}var i=t.return;try{Qo(t)}catch(l){$e(t,i,l)}break;case 5:var o=t.return;try{Qo(t)}catch(l){$e(t,o,l)}}}catch(l){$e(t,t.return,l)}if(t===e){Q=null;break}var c=t.sibling;if(c!==null){c.return=t.return,Q=c;break}Q=t.return}}var _y=Math.ceil,Ya=ln.ReactCurrentDispatcher,ec=ln.ReactCurrentOwner,It=ln.ReactCurrentBatchConfig,ge=0,Ve=null,Oe=null,Ye=0,yt=0,hr=En(0),De=0,Ts=null,Kn=0,pi=0,tc=0,cs=null,ct=null,nc=0,Er=1/0,Qt=null,Ja=!1,Zo=null,jn=null,sa=!1,pn=null,Qa=0,us=0,el=null,ja=-1,Sa=0;function nt(){return ge&6?Le():ja!==-1?ja:ja=Le()}function Sn(e){return e.mode&1?ge&2&&Ye!==0?Ye&-Ye:yy.transition!==null?(Sa===0&&(Sa=If()),Sa):(e=je,e!==0||(e=window.event,e=e===void 0?16:zf(e.type)),e):1}function Ot(e,t,n,r){if(50<us)throw us=0,el=null,Error(D(185));$s(e,n,r),(!(ge&2)||e!==Ve)&&(e===Ve&&(!(ge&2)&&(pi|=n),De===4&&mn(e,Ye)),mt(e,r),n===1&&ge===0&&!(t.mode&1)&&(Er=Le()+500,di&&Tn()))}function mt(e,t){var n=e.callbackNode;yg(e,t);var r=$a(e,e===Ve?Ye:0);if(r===0)n!==null&&eu(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&eu(n),t===1)e.tag===0?gy(Gu.bind(null,e)):tm(Gu.bind(null,e)),fy(function(){!(ge&6)&&Tn()}),n=null;else{switch(Rf(r)){case 1:n=Tl;break;case 4:n=Ef;break;case 16:n=Pa;break;case 536870912:n=Tf;break;default:n=Pa}n=Zm(n,Gm.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Gm(e,t){if(ja=-1,Sa=0,ge&6)throw Error(D(327));var n=e.callbackNode;if(wr()&&e.callbackNode!==n)return null;var r=$a(e,e===Ve?Ye:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=qa(e,r);else{t=r;var a=ge;ge|=2;var i=Ym();(Ve!==e||Ye!==t)&&(Qt=null,Er=Le()+500,Un(e,t));do try{Fy();break}catch(c){Km(e,c)}while(!0);Dl(),Ya.current=i,ge=a,Oe!==null?t=0:(Ve=null,Ye=0,t=De)}if(t!==0){if(t===2&&(a=Eo(e),a!==0&&(r=a,t=tl(e,a))),t===1)throw n=Ts,Un(e,0),mn(e,r),mt(e,Le()),n;if(t===6)mn(e,r);else{if(a=e.current.alternate,!(r&30)&&!Ly(a)&&(t=qa(e,r),t===2&&(i=Eo(e),i!==0&&(r=i,t=tl(e,i))),t===1))throw n=Ts,Un(e,0),mn(e,r),mt(e,Le()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(D(345));case 2:_n(e,ct,Qt);break;case 3:if(mn(e,r),(r&130023424)===r&&(t=nc+500-Le(),10<t)){if($a(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){nt(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Lo(_n.bind(null,e,ct,Qt),t);break}_n(e,ct,Qt);break;case 4:if(mn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var o=31-Ft(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*_y(r/1960))-r,10<r){e.timeoutHandle=Lo(_n.bind(null,e,ct,Qt),r);break}_n(e,ct,Qt);break;case 5:_n(e,ct,Qt);break;default:throw Error(D(329))}}}return mt(e,Le()),e.callbackNode===n?Gm.bind(null,e):null}function tl(e,t){var n=cs;return e.current.memoizedState.isDehydrated&&(Un(e,t).flags|=256),e=qa(e,t),e!==2&&(t=ct,ct=n,t!==null&&nl(t)),e}function nl(e){ct===null?ct=e:ct.push.apply(ct,e)}function Ly(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(!Bt(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 mn(e,t){for(t&=~tc,t&=~pi,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Ft(t),r=1<<n;e[n]=-1,t&=~r}}function Gu(e){if(ge&6)throw Error(D(327));wr();var t=$a(e,0);if(!(t&1))return mt(e,Le()),null;var n=qa(e,t);if(e.tag!==0&&n===2){var r=Eo(e);r!==0&&(t=r,n=tl(e,r))}if(n===1)throw n=Ts,Un(e,0),mn(e,t),mt(e,Le()),n;if(n===6)throw Error(D(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,_n(e,ct,Qt),mt(e,Le()),null}function rc(e,t){var n=ge;ge|=1;try{return e(t)}finally{ge=n,ge===0&&(Er=Le()+500,di&&Tn())}}function Yn(e){pn!==null&&pn.tag===0&&!(ge&6)&&wr();var t=ge;ge|=1;var n=It.transition,r=je;try{if(It.transition=null,je=1,e)return e()}finally{je=r,It.transition=n,ge=t,!(ge&6)&&Tn()}}function sc(){yt=hr.current,Ne(hr)}function Un(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,dy(n)),Oe!==null)for(n=Oe.return;n!==null;){var r=n;switch(Ol(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Oa();break;case 3:Nr(),Ne(dt),Ne(Ze),Kl();break;case 5:Gl(r);break;case 4:Nr();break;case 13:Ne(Ie);break;case 19:Ne(Ie);break;case 10:Ul(r.type._context);break;case 22:case 23:sc()}n=n.return}if(Ve=e,Oe=e=kn(e.current,null),Ye=yt=t,De=0,Ts=null,tc=pi=Kn=0,ct=cs=null,On!==null){for(t=0;t<On.length;t++)if(n=On[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}On=null}return e}function Km(e,t){do{var n=Oe;try{if(Dl(),va.current=Ka,Ga){for(var r=Re.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}Ga=!1}if(Gn=0,He=Me=Re=null,os=!1,Ns=0,ec.current=null,n===null||n.return===null){De=1,Ts=t,Oe=null;break}e:{var i=e,o=n.return,c=n,l=t;if(t=Ye,c.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var u=l,f=c,h=f.tag;if(!(f.mode&1)&&(h===0||h===11||h===15)){var m=f.alternate;m?(f.updateQueue=m.updateQueue,f.memoizedState=m.memoizedState,f.lanes=m.lanes):(f.updateQueue=null,f.memoizedState=null)}var x=$u(o);if(x!==null){x.flags&=-257,_u(x,o,c,i,t),x.mode&1&&Pu(i,u,t),t=x,l=u;var j=t.updateQueue;if(j===null){var v=new Set;v.add(l),t.updateQueue=v}else j.add(l);break e}else{if(!(t&1)){Pu(i,u,t),ac();break e}l=Error(D(426))}}else if(Ee&&c.mode&1){var S=$u(o);if(S!==null){!(S.flags&65536)&&(S.flags|=256),_u(S,o,c,i,t),Ml(Cr(l,c));break e}}i=l=Cr(l,c),De!==4&&(De=2),cs===null?cs=[i]:cs.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var g=Rm(i,l,t);Cu(i,g);break e;case 1:c=l;var p=i.type,y=i.stateNode;if(!(i.flags&128)&&(typeof p.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(jn===null||!jn.has(y)))){i.flags|=65536,t&=-t,i.lanes|=t;var w=Am(i,c,t);Cu(i,w);break e}}i=i.return}while(i!==null)}Qm(n)}catch(k){t=k,Oe===n&&n!==null&&(Oe=n=n.return);continue}break}while(!0)}function Ym(){var e=Ya.current;return Ya.current=Ka,e===null?Ka:e}function ac(){(De===0||De===3||De===2)&&(De=4),Ve===null||!(Kn&268435455)&&!(pi&268435455)||mn(Ve,Ye)}function qa(e,t){var n=ge;ge|=2;var r=Ym();(Ve!==e||Ye!==t)&&(Qt=null,Un(e,t));do try{zy();break}catch(a){Km(e,a)}while(!0);if(Dl(),ge=n,Ya.current=r,Oe!==null)throw Error(D(261));return Ve=null,Ye=0,De}function zy(){for(;Oe!==null;)Jm(Oe)}function Fy(){for(;Oe!==null&&!lg();)Jm(Oe)}function Jm(e){var t=Xm(e.alternate,e,yt);e.memoizedProps=e.pendingProps,t===null?Qm(e):Oe=t,ec.current=null}function Qm(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=Ry(n,t),n!==null){n.flags&=32767,Oe=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{De=6,Oe=null;return}}else if(n=Iy(n,t,yt),n!==null){Oe=n;return}if(t=t.sibling,t!==null){Oe=t;return}Oe=t=e}while(t!==null);De===0&&(De=5)}function _n(e,t,n){var r=je,a=It.transition;try{It.transition=null,je=1,Oy(e,t,n,r)}finally{It.transition=a,je=r}return null}function Oy(e,t,n,r){do wr();while(pn!==null);if(ge&6)throw Error(D(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(D(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(vg(e,i),e===Ve&&(Oe=Ve=null,Ye=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||sa||(sa=!0,Zm(Pa,function(){return wr(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=It.transition,It.transition=null;var o=je;je=1;var c=ge;ge|=4,ec.current=null,Py(e,n),Hm(n,e),sy($o),_a=!!Po,$o=Po=null,e.current=n,$y(n),cg(),ge=c,je=o,It.transition=i}else e.current=n;if(sa&&(sa=!1,pn=e,Qa=a),i=e.pendingLanes,i===0&&(jn=null),fg(n.stateNode),mt(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(Ja)throw Ja=!1,e=Zo,Zo=null,e;return Qa&1&&e.tag!==0&&wr(),i=e.pendingLanes,i&1?e===el?us++:(us=0,el=e):us=0,Tn(),null}function wr(){if(pn!==null){var e=Rf(Qa),t=It.transition,n=je;try{if(It.transition=null,je=16>e?16:e,pn===null)var r=!1;else{if(e=pn,pn=null,Qa=0,ge&6)throw Error(D(331));var a=ge;for(ge|=4,Q=e.current;Q!==null;){var i=Q,o=i.child;if(Q.flags&16){var c=i.deletions;if(c!==null){for(var l=0;l<c.length;l++){var u=c[l];for(Q=u;Q!==null;){var f=Q;switch(f.tag){case 0:case 11:case 15:ls(8,f,i)}var h=f.child;if(h!==null)h.return=f,Q=h;else for(;Q!==null;){f=Q;var m=f.sibling,x=f.return;if(Dm(f),f===u){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:ls(9,i,i.return)}var g=i.sibling;if(g!==null){g.return=i.return,Q=g;break e}Q=i.return}}var p=e.current;for(Q=p;Q!==null;){o=Q;var y=o.child;if(o.subtreeFlags&2064&&y!==null)y.return=o,Q=y;else e:for(o=p;Q!==null;){if(c=Q,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:hi(9,c)}}catch(k){$e(c,c.return,k)}if(c===o){Q=null;break e}var w=c.sibling;if(w!==null){w.return=c.return,Q=w;break e}Q=c.return}}if(ge=a,Tn(),Kt&&typeof Kt.onPostCommitFiberRoot=="function")try{Kt.onPostCommitFiberRoot(ii,e)}catch{}r=!0}return r}finally{je=n,It.transition=t}}return!1}function Ku(e,t,n){t=Cr(n,t),t=Rm(e,t,1),e=wn(e,t,1),t=nt(),e!==null&&($s(e,1,t),mt(e,t))}function $e(e,t,n){if(e.tag===3)Ku(e,e,n);else for(;t!==null;){if(t.tag===3){Ku(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(jn===null||!jn.has(r))){e=Cr(n,e),e=Am(t,e,1),t=wn(t,e,1),e=nt(),t!==null&&($s(t,1,e),mt(t,e));break}}t=t.return}}function My(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=nt(),e.pingedLanes|=e.suspendedLanes&n,Ve===e&&(Ye&n)===n&&(De===4||De===3&&(Ye&130023424)===Ye&&500>Le()-nc?Un(e,0):tc|=n),mt(e,t)}function qm(e,t){t===0&&(e.mode&1?(t=Ys,Ys<<=1,!(Ys&130023424)&&(Ys=4194304)):t=1);var n=nt();e=sn(e,t),e!==null&&($s(e,t,n),mt(e,n))}function By(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),qm(e,n)}function Dy(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(D(314))}r!==null&&r.delete(t),qm(e,n)}var Xm;Xm=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||dt.current)ut=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ut=!1,Ty(e,t,n);ut=!!(e.flags&131072)}else ut=!1,Ee&&t.flags&1048576&&nm(t,Da,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;wa(e,t),e=t.pendingProps;var a=Sr(t,Ze.current);xr(t,n),a=Jl(null,t,r,e,a,n);var i=Ql();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,ft(r)?(i=!0,Ma(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Hl(t),a.updater=mi,t.stateNode=a,a._reactInternals=t,Uo(t,r,e,n),t=Vo(null,t,r,!0,i,n)):(t.tag=0,Ee&&i&&Fl(t),tt(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(wa(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=Wy(r),e=_t(r,e),a){case 0:t=Ho(null,t,r,e,n);break e;case 1:t=Fu(null,t,r,e,n);break e;case 11:t=Lu(null,t,r,e,n);break e;case 14:t=zu(null,t,r,_t(r.type,e),n);break e}throw Error(D(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:_t(r,a),Ho(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:_t(r,a),Fu(e,t,r,a,n);case 3:e:{if(Lm(t),e===null)throw Error(D(387));r=t.pendingProps,i=t.memoizedState,a=i.element,lm(e,t),Ha(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=Cr(Error(D(423)),t),t=Ou(e,t,r,n,a);break e}else if(r!==a){a=Cr(Error(D(424)),t),t=Ou(e,t,r,n,a);break e}else for(vt=xn(t.stateNode.containerInfo.firstChild),xt=t,Ee=!0,zt=null,n=im(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(kr(),r===a){t=an(e,t,n);break e}tt(e,t,r,n)}t=t.child}return t;case 5:return cm(t),e===null&&Mo(t),r=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,o=a.children,_o(r,a)?o=null:i!==null&&_o(r,i)&&(t.flags|=32),_m(e,t),tt(e,t,o,n),t.child;case 6:return e===null&&Mo(t),null;case 13:return zm(e,t,n);case 4:return Vl(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=br(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),Lu(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,ke(Ua,r._currentValue),r._currentValue=o,i!==null)if(Bt(i.value,o)){if(i.children===a.children&&!dt.current){t=an(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var c=i.dependencies;if(c!==null){o=i.child;for(var l=c.firstContext;l!==null;){if(l.context===r){if(i.tag===1){l=tn(-1,n&-n),l.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var f=u.pending;f===null?l.next=l:(l.next=f.next,f.next=l),u.pending=l}}i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),Bo(i.return,n,t),c.lanes|=n;break}l=l.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(D(341));o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Bo(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,xr(t,n),a=Rt(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),zu(e,t,r,a,n);case 15:return Pm(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:_t(r,a),wa(e,t),t.tag=1,ft(r)?(e=!0,Ma(t)):e=!1,xr(t,n),Im(t,r,a),Uo(t,r,a,n),Vo(null,t,r,!0,e,n);case 19:return Fm(e,t,n);case 22:return $m(e,t,n)}throw Error(D(156,t.tag))};function Zm(e,t){return Cf(e,t)}function Uy(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 Uy(e,t,n,r)}function ic(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Wy(e){if(typeof e=="function")return ic(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Nl)return 11;if(e===Cl)return 14}return 2}function kn(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 ka(e,t,n,r,a,i){var o=2;if(r=e,typeof e=="function")ic(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case sr:return Wn(n.children,a,i,t);case bl:o=8,a|=8;break;case fo:return e=Et(12,n,t,a|2),e.elementType=fo,e.lanes=i,e;case mo:return e=Et(13,n,t,a),e.elementType=mo,e.lanes=i,e;case ho:return e=Et(19,n,t,a),e.elementType=ho,e.lanes=i,e;case cf:return gi(n,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case of:o=10;break e;case lf:o=9;break e;case Nl:o=11;break e;case Cl:o=14;break e;case un:o=16,r=null;break e}throw Error(D(130,e==null?e:typeof e,""))}return t=Et(o,n,t,a),t.elementType=e,t.type=r,t.lanes=i,t}function Wn(e,t,n,r){return e=Et(7,e,r,t),e.lanes=n,e}function gi(e,t,n,r){return e=Et(22,e,r,t),e.elementType=cf,e.lanes=n,e.stateNode={isHidden:!1},e}function Xi(e,t,n){return e=Et(6,e,null,t),e.lanes=n,e}function Zi(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 Hy(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=$i(0),this.expirationTimes=$i(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$i(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function oc(e,t,n,r,a,i,o,c,l){return e=new Hy(e,t,n,c,l),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},Hl(i),e}function Vy(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:rr,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function eh(e){if(!e)return Nn;e=e._reactInternals;e:{if(qn(e)!==e||e.tag!==1)throw Error(D(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ft(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(D(171))}if(e.tag===1){var n=e.type;if(ft(n))return em(e,n,t)}return t}function th(e,t,n,r,a,i,o,c,l){return e=oc(n,r,!0,e,a,i,o,c,l),e.context=eh(null),n=e.current,r=nt(),a=Sn(n),i=tn(r,a),i.callback=t??null,wn(n,i,a),e.current.lanes=a,$s(e,a,r),mt(e,r),e}function yi(e,t,n,r){var a=t.current,i=nt(),o=Sn(a);return n=eh(n),t.context===null?t.context=n:t.pendingContext=n,t=tn(i,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=wn(a,t,o),e!==null&&(Ot(e,a,o,i),ya(e,a,o)),o}function Xa(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 Yu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function lc(e,t){Yu(e,t),(e=e.alternate)&&Yu(e,t)}function Gy(){return null}var nh=typeof reportError=="function"?reportError:function(e){console.error(e)};function cc(e){this._internalRoot=e}vi.prototype.render=cc.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(D(409));yi(e,t,null,null)};vi.prototype.unmount=cc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Yn(function(){yi(null,e,null,null)}),t[rn]=null}};function vi(e){this._internalRoot=e}vi.prototype.unstable_scheduleHydration=function(e){if(e){var t=$f();e={blockedOn:null,target:e,priority:t};for(var n=0;n<fn.length&&t!==0&&t<fn[n].priority;n++);fn.splice(n,0,e),n===0&&Lf(e)}};function uc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function xi(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Ju(){}function Ky(e,t,n,r,a){if(a){if(typeof r=="function"){var i=r;r=function(){var u=Xa(o);i.call(u)}}var o=th(t,r,e,0,null,!1,!1,"",Ju);return e._reactRootContainer=o,e[rn]=o.current,ws(e.nodeType===8?e.parentNode:e),Yn(),o}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var c=r;r=function(){var u=Xa(l);c.call(u)}}var l=oc(e,0,!1,null,null,!1,!1,"",Ju);return e._reactRootContainer=l,e[rn]=l.current,ws(e.nodeType===8?e.parentNode:e),Yn(function(){yi(t,l,n,r)}),l}function wi(e,t,n,r,a){var i=n._reactRootContainer;if(i){var o=i;if(typeof a=="function"){var c=a;a=function(){var l=Xa(o);c.call(l)}}yi(t,o,e,a)}else o=Ky(n,t,e,a,r);return Xa(o)}Af=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Xr(t.pendingLanes);n!==0&&(Il(t,n|1),mt(t,Le()),!(ge&6)&&(Er=Le()+500,Tn()))}break;case 13:Yn(function(){var r=sn(e,1);if(r!==null){var a=nt();Ot(r,e,1,a)}}),lc(e,1)}};Rl=function(e){if(e.tag===13){var t=sn(e,134217728);if(t!==null){var n=nt();Ot(t,e,134217728,n)}lc(e,134217728)}};Pf=function(e){if(e.tag===13){var t=Sn(e),n=sn(e,t);if(n!==null){var r=nt();Ot(n,e,t,r)}lc(e,t)}};$f=function(){return je};_f=function(e,t){var n=je;try{return je=e,t()}finally{je=n}};bo=function(e,t,n){switch(t){case"input":if(yo(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=ui(r);if(!a)throw Error(D(90));df(r),yo(r,a)}}}break;case"textarea":mf(e,n);break;case"select":t=n.value,t!=null&&pr(e,!!n.multiple,t,!1)}};wf=rc;jf=Yn;var Yy={usingClientEntryPoint:!1,Events:[Ls,lr,ui,vf,xf,rc]},Vr={findFiberByHostInstance:Fn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Jy={bundleType:Vr.bundleType,version:Vr.version,rendererPackageName:Vr.rendererPackageName,rendererConfig:Vr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ln.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=bf(e),e===null?null:e.stateNode},findFiberByHostInstance:Vr.findFiberByHostInstance||Gy,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 aa=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!aa.isDisabled&&aa.supportsFiber)try{ii=aa.inject(Jy),Kt=aa}catch{}}jt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Yy;jt.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!uc(t))throw Error(D(200));return Vy(e,t,null,n)};jt.createRoot=function(e,t){if(!uc(e))throw Error(D(299));var n=!1,r="",a=nh;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=oc(e,1,!1,null,null,n,!1,r,a),e[rn]=t.current,ws(e.nodeType===8?e.parentNode:e),new cc(t)};jt.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(D(188)):(e=Object.keys(e).join(","),Error(D(268,e)));return e=bf(t),e=e===null?null:e.stateNode,e};jt.flushSync=function(e){return Yn(e)};jt.hydrate=function(e,t,n){if(!xi(t))throw Error(D(200));return wi(null,e,t,!0,n)};jt.hydrateRoot=function(e,t,n){if(!uc(e))throw Error(D(405));var r=n!=null&&n.hydratedSources||null,a=!1,i="",o=nh;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=th(t,null,e,1,n??null,a,!1,i,o),e[rn]=t.current,ws(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 vi(t)};jt.render=function(e,t,n){if(!xi(t))throw Error(D(200));return wi(null,e,t,!1,n)};jt.unmountComponentAtNode=function(e){if(!xi(e))throw Error(D(40));return e._reactRootContainer?(Yn(function(){wi(null,null,e,!1,function(){e._reactRootContainer=null,e[rn]=null})}),!0):!1};jt.unstable_batchedUpdates=rc;jt.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!xi(n))throw Error(D(200));if(e==null||e._reactInternals===void 0)throw Error(D(38));return wi(e,t,n,!1,r)};jt.version="18.3.1-next-f1338f8080-20240426";function rh(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(rh)}catch(e){console.error(e)}}rh(),nf.exports=jt;var sh=nf.exports,ah,Qu=sh;ah=Qu.createRoot,Qu.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 dc=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,ih=/^[\\/]{2}/;function Qy(e,t){return t+e.replace(/\\/g,"/")}var qu="popstate";function Xu(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function qy(e={}){function t(r,a){var u;let i=(u=a.state)==null?void 0:u.masked,{pathname:o,search:c,hash:l}=i||r.location;return rl("",{pathname:o,search:c,hash:l},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:Jn(a)}return Zy(t,n,null,e)}function Te(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Pt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Xy(){return Math.random().toString(36).substring(2,10)}function Zu(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 rl(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?$r(t):t,state:n,key:t&&t.key||r||Xy(),mask:a}}function Jn({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 $r(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 Zy(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,c="POP",l=null,u=f();u==null&&(u=0,o.replaceState({...o.state,idx:u},""));function f(){return(o.state||{idx:null}).idx}function h(){c="POP";let S=f(),g=S==null?null:S-u;u=S,l&&l({action:c,location:v.location,delta:g})}function m(S,g){c="PUSH";let p=Xu(S)?S:rl(v.location,S,g);u=f()+1;let y=Zu(p,u),w=v.createHref(p.mask||p);try{o.pushState(y,"",w)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;a.location.assign(w)}i&&l&&l({action:c,location:v.location,delta:1})}function x(S,g){c="REPLACE";let p=Xu(S)?S:rl(v.location,S,g);u=f();let y=Zu(p,u),w=v.createHref(p.mask||p);o.replaceState(y,"",w),i&&l&&l({action:c,location:v.location,delta:0})}function j(S){return ev(a,S)}let v={get action(){return c},get location(){return e(a,o)},listen(S){if(l)throw new Error("A history only accepts one active listener");return a.addEventListener(qu,h),l=S,()=>{a.removeEventListener(qu,h),l=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 ev(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:Jn(t);return a=a.replace(/ $/,"%20"),!n&&ih.test(a)&&(a=r+a),new URL(a,r)}function oh(e,t,n="/"){return tv(e,t,n,!1)}function tv(e,t,n,r,a){let i=typeof t=="string"?$r(t):t,o=on(i.pathname||"/",n);if(o==null)return null;let c=nv(e),l=null,u=mv(o);for(let f=0;l==null&&f<c.length;++f)l=fv(c[f],u,r);return l}function nv(e){let t=lh(e);return rv(t),t}function lh(e,t=[],n=[],r="",a=!1){let i=(o,c,l=a,u)=>{let f={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:c,route:o};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&l)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 h=Mt([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 "${h}".`),lh(o.children,t,m,h,l)),!(o.path==null&&!o.index)&&t.push({path:h,score:uv(h,o.index),routesMeta:m.map((x,j)=>{let[v,S]=dh(x.relativePath,x.caseSensitive,j===m.length-1);return{...x,matcher:v,compiledParams:S}})})};return e.forEach((o,c)=>{var l;if(o.path===""||!((l=o.path)!=null&&l.includes("?")))i(o,c);else for(let u of ch(o.path))i(o,c,!0,u)}),t}function ch(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=ch(r.join("/")),c=[];return c.push(...o.map(l=>l===""?i:[i,l].join("/"))),a&&c.push(...o),c.map(l=>e.startsWith("/")&&l===""?"/":l)}function rv(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:dv(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var sv=/^:[\w-]+$/,av=3,iv=2,ov=1,lv=10,cv=-2,ed=e=>e==="*";function uv(e,t){let n=e.split("/"),r=n.length;return n.some(ed)&&(r+=cv),t&&(r+=iv),n.filter(a=>!ed(a)).reduce((a,i)=>a+(sv.test(i)?av:i===""?ov:lv),r)}function dv(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 fv(e,t,n=!1){let{routesMeta:r}=e,a={},i="/",o=[];for(let c=0;c<r.length;++c){let l=r[c],u=c===r.length-1,f=i==="/"?t:t.slice(i.length)||"/",h={path:l.relativePath,caseSensitive:l.caseSensitive,end:u},m=l.matcher&&l.compiledParams?uh(h,f,l.matcher,l.compiledParams):Za(h,f),x=l.route;if(!m&&u&&n&&!r[r.length-1].route.index&&(m=Za({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},f)),!m)return null;Object.assign(a,m.params),o.push({params:a,pathname:Mt([i,m.pathname]),pathnameBase:gv(Mt([i,m.pathnameBase])),route:x}),m.pathnameBase!=="/"&&(i=Mt([i,m.pathnameBase]))}return o}function Za(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=dh(e.path,e.caseSensitive,e.end);return uh(e,t,n,r)}function uh(e,t,n,r){let a=t.match(n);if(!a)return null;let i=a[0],o=Tr(i,1),c=a.slice(1);return{params:r.reduce((u,{paramName:f,isOptional:h},m)=>{if(f==="*"){let j=c[m]||"";o=Tr(i.slice(0,i.length-j.length),1)}const x=c[m];return h&&!x?u[f]=void 0:u[f]=(x||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:o,pattern:e}}function dh(e,t=!1,n=!0){Pt(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,c,l,u,f)=>{if(r.push({paramName:c,isOptional:l!=null}),l){let h=f.charAt(u+o.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function mv(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Pt(!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 on(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 hv(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?$r(e):e,i;return n?(n=fh(n),n.startsWith("/")||n.startsWith("\\")?i=td(n.substring(1),"/"):i=td(n,t)):i=t,{pathname:i,search:yv(r),hash:vv(a)}}function td(e,t){let n=Tr(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function eo(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 pv(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function fc(e){let t=pv(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function ji(e,t,n,r=!1){let a;typeof e=="string"?a=$r(e):(a={...e},Te(!a.pathname||!a.pathname.includes("?"),eo("?","pathname","search",a)),Te(!a.pathname||!a.pathname.includes("#"),eo("#","pathname","hash",a)),Te(!a.search||!a.search.includes("#"),eo("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,c;if(o==null)c=n;else{let h=t.length-1;if(!r&&o.startsWith("..")){let m=o.split("/");for(;m[0]==="..";)m.shift(),h-=1;a.pathname=m.join("/")}c=h>=0?t[h]:"/"}let l=hv(a,c),u=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(u||f)&&(l.pathname+="/"),l}var fh=e=>e.replace(/[\\/]{2,}/g,"/"),Mt=e=>fh(e.join("/"));function Tr(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 gv=e=>Tr(e).replace(/^\/*/,"/"),yv=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,vv=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,xv=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 wv(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function jv(e){let t=e.map(n=>n.route.path).filter(Boolean);return Mt(t)||"/"}var mh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function hh(e,t){let n=e;if(typeof n!="string"||!dc.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(mh)try{let i=new URL(window.location.href),o=ih.test(n)?new URL(Qy(n,i.protocol)):new URL(n),c=on(o.pathname,t);o.origin===i.origin&&c!=null?n=c+o.search+o.hash:a=!0}catch{Pt(!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 nd=new URL("http://localhost");function mc(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),nd)}catch{return nd}}function to(e,t){return e.origin===t.origin&&(e.origin!=="null"||e.protocol===t.protocol&&e.host===t.host)}function Sv(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 hc(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&&!to(a,n),c=!to(i,n);if(r==="reject"){if(o||c)throw new Error("External navigation is not allowed")}else if(c&&(a==null||!Sv(e,a)||!to(a,i)))throw new Error("External navigation is not allowed")}var ph=["POST","PUT","PATCH","DELETE"];new Set(ph);var kv=["GET",...ph];new Set(kv);var bv=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Nv(e){try{return bv.includes(new URL(e).protocol)}catch{return!1}}var _r=d.createContext(null);_r.displayName="DataRouter";var Si=d.createContext(null);Si.displayName="DataRouterState";var gh=d.createContext(!1);function Cv(){return d.useContext(gh)}var yh=d.createContext({isTransitioning:!1});yh.displayName="ViewTransition";var Ev=d.createContext(new Map);Ev.displayName="Fetchers";var Tv=d.createContext(null);Tv.displayName="Await";var kt=d.createContext(null);kt.displayName="Navigation";var Fs=d.createContext(null);Fs.displayName="Location";var Dt=d.createContext({outlet:null,matches:[],isDataRoute:!1});Dt.displayName="Route";var pc=d.createContext(null);pc.displayName="RouteError";var vh="REACT_ROUTER_ERROR",Iv="REDIRECT",Rv="ROUTE_ERROR_RESPONSE";function Av(e){if(e.startsWith(`${vh}:${Iv}:{`))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 Pv(e){if(e.startsWith(`${vh}:${Rv}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new xv(t.status,t.statusText,t.data)}catch{}}function $v(e,{relative:t}={}){Te(Lr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=d.useContext(kt),{hash:a,pathname:i,search:o}=Os(e,{relative:t}),c=i;return n!=="/"&&(c=i==="/"?n:Mt([n,i])),r.createHref({pathname:c,search:o,hash:a})}function Lr(){return d.useContext(Fs)!=null}function ht(){return Te(Lr(),"useLocation() may be used only in the context of a <Router> component."),d.useContext(Fs).location}var xh="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function wh(e){d.useContext(kt).static||d.useLayoutEffect(e)}function Ut(){let{isDataRoute:e}=d.useContext(Dt);return e?Yv():_v()}function _v(){Te(Lr(),"useNavigate() may be used only in the context of a <Router> component.");let e=d.useContext(_r),{basename:t,navigator:n}=d.useContext(kt),{matches:r}=d.useContext(Dt),{pathname:a}=ht(),i=JSON.stringify(fc(r)),o=d.useRef(!1);return wh(()=>{o.current=!0}),d.useCallback((l,u={})=>{if(Pt(o.current,xh),!o.current)return;if(typeof l=="number"){n.go(l);return}let f=ji(l,JSON.parse(i),a,u.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Mt([t,f.pathname])),hc(typeof l=="string"?l:Jn(l),n.createHref(f),mc(n),"reject"),(u.replace?n.replace:n.push)(f,u.state,u)},[t,n,i,a,e])}var Lv=d.createContext(null);function zv(e){let t=d.useContext(Dt).outlet;return d.useMemo(()=>t&&d.createElement(Lv.Provider,{value:e},t),[t,e])}function Os(e,{relative:t}={}){let{matches:n}=d.useContext(Dt),{pathname:r}=ht(),a=JSON.stringify(fc(n));return d.useMemo(()=>ji(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Fv(e,t){return jh(e,t)}function jh(e,t,n){var S;Te(Lr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=d.useContext(kt),{matches:a}=d.useContext(Dt),i=a[a.length-1],o=i?i.params:{},c=i?i.pathname:"/",l=i?i.pathnameBase:"/",u=i&&i.route;{let g=u&&u.path||"";kh(c,!u||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (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=ht(),h;if(t){let g=typeof t=="string"?$r(t):t;Te(l==="/"||((S=g.pathname)==null?void 0:S.startsWith(l)),`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 "${l}" but pathname "${g.pathname}" was given in the \`location\` prop.`),h=g}else h=f;let m=h.pathname||"/",x=m;if(l!=="/"){let g=l.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})):oh(e,{pathname:x});Pt(u||j!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),Pt(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 "${h.pathname}${h.search}${h.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let v=Uv(j&&j.map(g=>Object.assign({},g,{params:Object.assign({},o,g.params),pathname:Mt([l,r.encodeLocation?r.encodeLocation(g.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?l:Mt([l,r.encodeLocation?r.encodeLocation(g.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),a,n);return t&&v?d.createElement(Fs.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...h},navigationType:"POP"}},v):v}function Ov(){let e=Kv(),t=wv(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=d.createElement(d.Fragment,null,d.createElement("p",null,"💿 Hey developer 👋"),d.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",d.createElement("code",{style:i},"ErrorBoundary")," or"," ",d.createElement("code",{style:i},"errorElement")," prop on your route.")),d.createElement(d.Fragment,null,d.createElement("h2",null,"Unexpected Application Error!"),d.createElement("h3",{style:{fontStyle:"italic"}},t),n?d.createElement("pre",{style:a},n):null,o)}var Mv=d.createElement(Ov,null),Sh=class extends d.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=Pv(e.digest);n&&(e=n)}let t=e!==void 0?d.createElement(Dt.Provider,{value:this.props.routeContext},d.createElement(pc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?d.createElement(Bv,{error:e},t):t}};Sh.contextType=gh;var no=new WeakMap;function Bv({children:e,error:t}){let{basename:n,navigator:r}=d.useContext(kt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let a=Av(t.digest);if(a){let i=no.get(t);if(i)throw i;let o=hh(a.location,n),c=o.absoluteURL||o.to;if(hc(a.location,c,mc(r),"allow-explicit"),Nv(c))throw new Error("Invalid redirect location");if(mh&&!no.get(t))if(o.isExternal||a.reloadDocument)window.location.href=c;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:a.replace}));throw no.set(t,l),l}return d.createElement("meta",{httpEquiv:"refresh",content:`0;url=${c}`})}}return e}function Dv({routeContext:e,match:t,children:n}){let r=d.useContext(_r);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),d.createElement(Dt.Provider,{value:e},n)}function Uv(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,i=r==null?void 0:r.errors;if(i!=null){let f=a.findIndex(h=>h.route.id&&(i==null?void 0:i[h.route.id])!==void 0);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,c=-1;if(n&&r){o=r.renderFallback;for(let f=0;f<a.length;f++){let h=a[f];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(c=f),h.route.id){let{loaderData:m,errors:x}=r,j=h.route.loader&&!m.hasOwnProperty(h.route.id)&&(!x||x[h.route.id]===void 0);if(h.route.lazy||j){n.isStatic&&(o=!0),c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}}let l=n==null?void 0:n.onError,u=r&&l?(f,h)=>{var m,x;l(f,{location:r.location,params:((x=(m=r.matches)==null?void 0:m[0])==null?void 0:x.params)??{},pattern:jv(r.matches),errorInfo:h})}:void 0;return a.reduceRight((f,h,m)=>{let x,j=!1,v=null,S=null;r&&(x=i&&h.route.id?i[h.route.id]:void 0,v=h.route.errorElement||Mv,o&&(c<0&&m===0?(kh("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),j=!0,S=null):c===m&&(j=!0,S=h.route.hydrateFallbackElement||null)));let g=t.concat(a.slice(0,m+1)),p=()=>{let y;return x?y=v:j?y=S:h.route.Component?y=d.createElement(h.route.Component,null):h.route.element?y=h.route.element:y=f,d.createElement(Dv,{match:h,routeContext:{outlet:f,matches:g,isDataRoute:r!=null},children:y})};return r&&(h.route.ErrorBoundary||h.route.errorElement||m===0)?d.createElement(Sh,{location:r.location,revalidation:r.revalidation,component:v,error:x,children:p(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:u}):p()},null)}function gc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wv(e){let t=d.useContext(_r);return Te(t,gc(e)),t}function Hv(e){let t=d.useContext(Si);return Te(t,gc(e)),t}function Vv(e){let t=d.useContext(Dt);return Te(t,gc(e)),t}function yc(e){let t=Vv(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 Gv(){return yc("useRouteId")}function Kv(){var r;let e=d.useContext(pc),t=Hv("useRouteError"),n=yc("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function Yv(){let{router:e}=Wv("useNavigate"),t=yc("useNavigate"),n=d.useRef(!1);return wh(()=>{n.current=!0}),d.useCallback(async(a,i={})=>{Pt(n.current,xh),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var rd={};function kh(e,t,n){!t&&!rd[e]&&(rd[e]=!0,Pt(!1,n))}d.memo(Jv);function Jv({routes:e,manifest:t,future:n,state:r,isStatic:a,onError:i}){return jh(e,void 0,{manifest:t,state:r,isStatic:a,onError:i})}function Xt({to:e,replace:t,state:n,relative:r}){Te(Lr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a,navigator:i}=d.useContext(kt);Pt(!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}=d.useContext(Dt),{pathname:c}=ht(),l=Ut(),u=ji(e,fc(o),c,r==="path");hc(typeof e=="string"?e:Jn(e),i.createHref(u),mc(i),"reject");let f=JSON.stringify(u);return d.useEffect(()=>{l(JSON.parse(f),{replace:t,state:n,relative:r})},[l,f,r,t,n]),null}function Qv(e){return zv(e.context)}function Se(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 qv({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:i=!1,useTransitions:o}){Te(!Lr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),l=d.useMemo(()=>({basename:c,navigator:a,static:i,useTransitions:o,future:{}}),[c,a,i,o]);typeof n=="string"&&(n=$r(n));let{pathname:u="/",search:f="",hash:h="",state:m=null,key:x="default",mask:j}=n,v=d.useMemo(()=>{let S=on(u,c);return S==null?null:{location:{pathname:S,search:f,hash:h,state:m,key:x,mask:j},navigationType:r}},[c,u,f,h,m,x,r,j]);return Pt(v!=null,`<Router basename="${c}"> is not able to match the URL "${u}${f}${h}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:d.createElement(kt.Provider,{value:l},d.createElement(Fs.Provider,{children:t,value:v}))}function Xv({children:e,location:t}){return Fv(sl(e),t)}function sl(e,t=[]){let n=[];return d.Children.forEach(e,(r,a)=>{if(!d.isValidElement(r))return;let i=[...t,a];if(r.type===d.Fragment){n.push.apply(n,sl(r.props.children,i));return}Te(r.type===Se,`[${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=sl(r.props.children,i)),n.push(o)}),n}var ba="get",Na="application/x-www-form-urlencoded";function ki(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Zv(e){return ki(e)&&e.tagName.toLowerCase()==="button"}function ex(e){return ki(e)&&e.tagName.toLowerCase()==="form"}function tx(e){return ki(e)&&e.tagName.toLowerCase()==="input"}function nx(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function rx(e,t){return e.button===0&&(!t||t==="_self")&&!nx(e)}function al(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 sx(e,t){let n=al(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}var ia=null;function ax(){if(ia===null)try{new FormData(document.createElement("form"),0),ia=!1}catch{ia=!0}return ia}var ix=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ro(e){return e!=null&&!ix.has(e)?(Pt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Na}"`),null):e}function ox(e,t){let n,r,a,i,o;if(ex(e)){let c=e.getAttribute("action");r=c?on(c,t):null,n=e.getAttribute("method")||ba,a=ro(e.getAttribute("enctype"))||Na,i=new FormData(e)}else if(Zv(e)||tx(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||c.getAttribute("action");if(r=l?on(l,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||ba,a=ro(e.getAttribute("formenctype"))||ro(c.getAttribute("enctype"))||Na,i=new FormData(c,e),!ax()){let{name:u,type:f,value:h}=e;if(f==="image"){let m=u?`${u}.`:"";i.append(`${m}x`,"0"),i.append(`${m}y`,"0")}else u&&i.append(u,h)}}else{if(ki(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=ba,r=null,a=Na,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 vc(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function bh(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&&on(a.pathname,t)==="/"?a.pathname=`${Tr(t)}/_root.${r}`:a.pathname=`${Tr(a.pathname)}.${r}`,a}async function lx(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 cx(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 ux(e,t,n){let r=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await lx(i,n);return o.links?o.links():[]}return[]}));return hx(r.flat(1).filter(cx).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function sd(e,t,n,r,a,i){let o=(l,u)=>n[u]?l.route.id!==n[u].route.id:!0,c=(l,u)=>{var f;return n[u].pathname!==l.pathname||((f=n[u].route.path)==null?void 0:f.endsWith("*"))&&n[u].params["*"]!==l.params["*"]};return i==="assets"?t.filter((l,u)=>o(l,u)||c(l,u)):i==="data"?t.filter((l,u)=>{var h;let f=r.routes[l.route.id];if(!f||!f.hasLoader)return!1;if(o(l,u)||c(l,u))return!0;if(l.route.shouldRevalidate){let m=l.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((h=n[0])==null?void 0:h.params)||{},nextUrl:new URL(e,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function dx(e,t,{includeHydrateFallback:n}={}){return fx(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 fx(e){return[...new Set(e)]}function mx(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function hx(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let i=JSON.stringify(mx(a));return n.has(i)||(n.add(i),r.push({key:i,link:a})),r},[])}function xc(){let e=d.useContext(_r);return vc(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function px(){let e=d.useContext(Si);return vc(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var wc=d.createContext(void 0);wc.displayName="FrameworkContext";function bi(){let e=d.useContext(wc);return vc(e,"You must render this element inside a <HydratedRouter> element"),e}function gx(e,t){let n=d.useContext(wc),[r,a]=d.useState(!1),[i,o]=d.useState(!1),{onFocus:c,onBlur:l,onMouseEnter:u,onMouseLeave:f,onTouchStart:h}=t,m=d.useRef(null);d.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let v=g=>{g.forEach(p=>{o(p.isIntersecting)})},S=new IntersectionObserver(v,{threshold:.5});return m.current&&S.observe(m.current),()=>{S.disconnect()}}},[e]),d.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:Gr(c,x),onBlur:Gr(l,j),onMouseEnter:Gr(u,x),onMouseLeave:Gr(f,j),onTouchStart:Gr(h,x)}]:[!1,m,{}]}function Gr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function yx({page:e,...t}){let n=Cv(),{nonce:r}=bi(),{router:a}=xc(),i=d.useMemo(()=>oh(a.routes,e,a.basename),[a.routes,e,a.basename]);return i?(t.nonce==null&&r&&(t={...t,nonce:r}),n?d.createElement(xx,{page:e,matches:i,...t}):d.createElement(wx,{page:e,matches:i,...t})):null}function vx(e){let{manifest:t,routeModules:n}=bi(),[r,a]=d.useState([]);return d.useEffect(()=>{let i=!1;return ux(e,t,n).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,n]),r}function xx({page:e,matches:t,...n}){let r=ht(),{future:a}=bi(),{basename:i}=xc(),o=d.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let c=bh(e,i,a.v8_trailingSlashAwareDataRequests,"rsc"),l=!1,u=[];for(let f of t)typeof f.route.shouldRevalidate=="function"?l=!0:u.push(f.route.id);return l&&u.length>0&&c.searchParams.set("_routes",u.join(",")),[c.pathname+c.search]},[i,a.v8_trailingSlashAwareDataRequests,e,r,t]);return d.createElement(d.Fragment,null,o.map(c=>d.createElement("link",{key:c,rel:"prefetch",as:"fetch",href:c,...n})))}function wx({page:e,matches:t,...n}){let r=ht(),{future:a,manifest:i,routeModules:o}=bi(),{basename:c}=xc(),{loaderData:l,matches:u}=px(),f=d.useMemo(()=>sd(e,t,u,i,r,"data"),[e,t,u,i,r]),h=d.useMemo(()=>sd(e,t,u,i,r,"assets"),[e,t,u,i,r]),m=d.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let v=new Set,S=!1;if(t.forEach(p=>{var w;let y=i.routes[p.route.id];!y||!y.hasLoader||(!f.some(k=>k.route.id===p.route.id)&&p.route.id in l&&((w=o[p.route.id])!=null&&w.shouldRevalidate)||y.hasClientLoader?S=!0:v.add(p.route.id))}),v.size===0)return[];let g=bh(e,c,a.v8_trailingSlashAwareDataRequests,"data");return S&&v.size>0&&g.searchParams.set("_routes",t.filter(p=>v.has(p.route.id)).map(p=>p.route.id).join(",")),[g.pathname+g.search]},[c,a.v8_trailingSlashAwareDataRequests,l,r,i,f,t,e,o]),x=d.useMemo(()=>dx(h,i),[h,i]),j=vx(h);return d.createElement(d.Fragment,null,m.map(v=>d.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),x.map(v=>d.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),j.map(({key:v,link:S})=>d.createElement("link",{key:v,nonce:n.nonce,...S,crossOrigin:S.crossOrigin??n.crossOrigin})))}function jx(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Sx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Sx&&(window.__reactRouterVersion="7.18.4")}catch{}function kx({basename:e,children:t,useTransitions:n,window:r}){let a=d.useRef();a.current==null&&(a.current=qy({window:r,v5Compat:!0}));let i=a.current,[o,c]=d.useState({action:i.action,location:i.location}),l=d.useCallback(u=>{n===!1?c(u):d.startTransition(()=>c(u))},[n]);return d.useLayoutEffect(()=>i.listen(l),[i,l]),d.createElement(qv,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:i,useTransitions:n})}var Be=d.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:i,replace:o,mask:c,state:l,target:u,to:f,preventScrollReset:h,viewTransition:m,defaultShouldRevalidate:x,...j},v){let{basename:S,navigator:g,useTransitions:p}=d.useContext(kt),y=typeof f=="string"&&dc.test(f),w=hh(f,S);f=w.to;let k=$v(f,{relative:a}),C=ht(),N=null;if(c){let A=ji(c,[],C.mask?C.mask.pathname:"/",!0);S!=="/"&&(A.pathname=A.pathname==="/"?S:Mt([S,A.pathname])),N=g.createHref(A)}let[R,I,L]=gx(r,j),$=Cx(f,{replace:o,mask:c,state:l,target:u,preventScrollReset:h,relative:a,viewTransition:m,defaultShouldRevalidate:x,useTransitions:p});function T(A){t&&t(A),A.defaultPrevented||$(A)}let O=!(w.isExternal||i),V=d.createElement("a",{...j,...L,href:(O?N:void 0)||w.absoluteURL||k,onClick:O?T:t,ref:jx(v,I),target:u,"data-discover":!y&&n==="render"?"true":void 0});return R&&!y?d.createElement(d.Fragment,null,V,d.createElement(yx,{page:k})):V});Be.displayName="Link";var jc=d.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:i,to:o,viewTransition:c,children:l,...u},f){let h=Os(o,{relative:u.relative}),m=ht(),x=d.useContext(Si),{navigator:j,basename:v}=d.useContext(kt),S=x!=null&&Ax(h)&&c===!0,g=j.encodeLocation?j.encodeLocation(h).pathname:h.pathname,p=m.pathname,y=x&&x.navigation&&x.navigation.location?x.navigation.location.pathname:null;n||(p=p.toLowerCase(),y=y?y.toLowerCase():null,g=g.toLowerCase()),y&&v&&(y=on(y,v)||y);const w=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let k=p===g||!a&&p.startsWith(g)&&p.charAt(w)==="/",C=y!=null&&(y===g||!a&&y.startsWith(g)&&y.charAt(g.length)==="/"),N={isActive:k,isPending:C,isTransitioning:S},R=k?t:void 0,I;typeof r=="function"?I=r(N):I=[r,k?"active":null,C?"pending":null,S?"transitioning":null].filter(Boolean).join(" ");let L=typeof i=="function"?i(N):i;return d.createElement(Be,{...u,"aria-current":R,className:I,ref:f,style:L,to:o,viewTransition:c},typeof l=="function"?l(N):l)});jc.displayName="NavLink";var bx=d.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:i,method:o=ba,action:c,onSubmit:l,relative:u,preventScrollReset:f,viewTransition:h,defaultShouldRevalidate:m,...x},j)=>{let{useTransitions:v}=d.useContext(kt),S=Ix(),g=Rx(c,{relative:u}),p=o.toLowerCase()==="get"?"get":"post",y=typeof c=="string"&&dc.test(c),w=k=>{if(l&&l(k),k.defaultPrevented)return;k.preventDefault();let C=k.nativeEvent.submitter,N=(C==null?void 0:C.getAttribute("formmethod"))||o,R=()=>S(C||k.currentTarget,{fetcherKey:t,method:N,navigate:n,replace:a,state:i,relative:u,preventScrollReset:f,viewTransition:h,defaultShouldRevalidate:m});v&&n!==!1?d.startTransition(()=>R()):R()};return d.createElement("form",{ref:j,method:p,action:g,onSubmit:r?l:w,...x,"data-discover":!y&&e==="render"?"true":void 0})});bx.displayName="Form";function Nx(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Nh(e){let t=d.useContext(_r);return Te(t,Nx(e)),t}function Cx(e,{target:t,replace:n,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:c,defaultShouldRevalidate:l,useTransitions:u}={}){let f=Ut(),h=ht(),m=Os(e,{relative:o});return d.useCallback(x=>{if(rx(x,t)){x.preventDefault();let j=n!==void 0?n:Jn(h)===Jn(m),v=()=>f(e,{replace:j,mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:c,defaultShouldRevalidate:l});u?d.startTransition(()=>v()):v()}},[h,f,m,n,r,a,t,e,i,o,c,l,u])}function Sc(e){Pt(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=d.useRef(al(e)),n=d.useRef(!1),r=ht(),a=d.useMemo(()=>sx(r.search,n.current?null:t.current),[r.search]),i=Ut(),o=d.useCallback((c,l)=>{const u=al(typeof c=="function"?c(new URLSearchParams(a)):c);n.current=!0,i("?"+u,l)},[i,a]);return[a,o]}var Ex=0,Tx=()=>`__${String(++Ex)}__`;function Ix(){let{router:e}=Nh("useSubmit"),{basename:t}=d.useContext(kt),n=Gv(),r=e.fetch,a=e.navigate;return d.useCallback(async(i,o={})=>{let{action:c,method:l,encType:u,formData:f,body:h}=ox(i,t);if(o.navigate===!1){let m=o.fetcherKey||Tx();await r(m,n,o.action||c,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:f,body:h,formMethod:o.method||l,formEncType:o.encType||u,flushSync:o.flushSync})}else await a(o.action||c,{defaultShouldRevalidate:o.defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:f,body:h,formMethod:o.method||l,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,a,t,n])}function Rx(e,{relative:t}={}){let{basename:n}=d.useContext(kt),r=d.useContext(Dt);Te(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),i={...Os(e||".",{relative:t})},o=ht();if(e==null){i.search=o.search;let c=new URLSearchParams(i.search),l=c.getAll("index");if(l.some(f=>f==="")){c.delete("index"),l.filter(h=>h).forEach(h=>c.append("index",h));let f=c.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:Mt([n,i.pathname])),Jn(i)}function Ax(e,{relative:t}={}){let n=d.useContext(yh);Te(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Nh("useViewTransitionState"),a=Os(e,{relative:t});if(!n.isTransitioning)return!1;let i=on(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=on(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Za(a.pathname,o)!=null||Za(a.pathname,i)!=null}const Bn="owner";function Px(e){const t=e||Bn;return t===Bn?[Bn]:[t,Bn]}function $x(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 _x(e,t){const n=t||Bn,r=(e==null?void 0:e.pendingDomains)??[];return r.includes(n)?n:r.includes(Bn)?Bn:n}class Ch extends Error{constructor(n){super("different_account");Fr(this,"summary");this.name="DifferentAccountError",this.summary=n}}function pe(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 Lx(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 zx{constructor(){Fr(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 Ch(i.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!r.ok){const i=await r.json().catch(()=>({error:"Invalid API key"}));throw new Error(pe(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(pe(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,c;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(l=>!(i.attestedDomains??[]).includes(l)),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(l=>l.expiresAt))*1e3).toISOString():null,remaining_seconds:(c=i.attestations)!=null&&c.length?Math.max(0,Math.min(...i.attestations.map(l=>l.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(pe(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(pe(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(pe(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(pe(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(pe(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(pe(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(pe(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,ended:r.ended??{mandates:0,proposals:0}}}async getCreatePreview(){const t=await this.fetch("/api/groups/create/preview");if(!t.ok){const n=await t.json().catch(()=>({error:"Unknown error"}));throw new Error(pe(n,`Failed to preview team creation: ${t.status}`))}return t.json()}async getJoinPreview(t){const n=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(t)}`);if(!n.ok){const r=await n.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(pe(r,`Invalid invite code: ${n.status}`))}return n.json()}async requestToJoinGroup(t){const n=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:t})});if(n.status!==202){const a=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(pe(a,`Request to join failed: ${n.status}`))}return(await n.json()).request}async withdrawJoinRequest(){const t=await this.fetch("/api/groups/join",{method:"DELETE"});if(t.status===404)return!1;if(!t.ok){const r=await t.json().catch(()=>({error:"Unknown error"}));throw new Error(pe(r,`Withdraw failed: ${t.status}`))}return(await t.json()).withdrawn===!0}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(pe(r,`Invite failed: ${n.status}`))}return n.json()}async getMyTeam(){const t=await this.fetch("/api/groups/me");if(!t.ok)return{group:null,membership:null,pendingRequest:null};const n=await t.json();return{group:n.group??null,membership:n.membership??null,pendingRequest:n.pendingRequest??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(pe(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(pe(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:pe(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:pe(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(pe(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(pe(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(pe(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(pe(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(pe(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?Lx(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(pe(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,n="pending"){const r=n==="all"?"&status=all":"",a=await this.fetch(`/api/proposals?domain=${encodeURIComponent(t)}${r}`);if(!a.ok)throw new Error(`Failed to fetch proposals: ${a.status}`);return(await a.json()).proposals??[]}async getMyProposals(t,n="pending"){const r=await Promise.all(Px(t).map(a=>this.getProposals(a,n)));return $x(r)}async resolveProposal(t,n,r,a){const i=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/resolve`,{method:"POST",body:JSON.stringify({action:n,domain:r,...a})});if(!i.ok){const o=await i.json().catch(()=>({error:"Failed"}));throw new Error(pe(o,`Failed: ${i.status}`))}return i.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(pe(r,`approveProposal failed: ${n.status}`))}return n.json()}async rejectProposal(t,n){const r=typeof n=="string"?{reason:n}:n??{},a=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/reject`,{method:"POST",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed"}));throw new Error(pe(i,`rejectProposal failed: ${a.status}`))}return a.json()}async getProposalPreview(t){const n=await this.fetch(`/proposal-status/${encodeURIComponent(t)}/preview`);if(!n.ok)throw new Error(`Failed to fetch preview: ${n.status}`);return n.json()}async getProposalOutcome(t){const n=await this.fetch(`/proposal-status/${encodeURIComponent(t)}/outcome`);if(!n.ok)throw new Error(`Failed to fetch outcome: ${n.status}`);return n.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(pe(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(pe(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 c,l;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(u=>!(a.attestedDomains??a.attested_domains??[]).includes(u)),deferred_commitment_domains:a.deferredCommitmentDomains??a.deferred_commitment_domains??[],approvers_frozen:a.approversFrozen??a.approvers_frozen??[],above_cap:a.aboveCap??a.above_cap??!1,created_at:a.createdAt?new Date(a.createdAt*1e3).toISOString():a.created_at??"",earliest_expiry:(c=a.mandates)!=null&&c.length?new Date(Math.min(...a.mandates.map(u=>u.expiresAt))*1e3).toISOString():null,remaining_seconds:(l=a.mandates)!=null&&l.length?Math.max(0,Math.min(...a.mandates.map(u=>u.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,r);let i=[];if(r==="all"){const o=[],c=new Date;for(let u=0;u<n;u++){const f=new Date(c);f.setUTCDate(c.getUTCDate()-u),o.push(f.toISOString().slice(0,10))}i=(await Promise.all(o.map(u=>this.getMyReceipts({date:u,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(pe(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(pe(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:pe(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(pe(a,`Save failed: ${r.status}`))}}}const E=new zx,Eh=d.createContext(null);function Fx({children:e}){const[t,n]=d.useState(null),[r,a]=d.useState("personal"),[i,o]=d.useState(null),[c,l]=d.useState(""),[u,f]=d.useState(null),[h,m]=d.useState(null),[x,j]=d.useState(null),[v,S]=d.useState(!1),[g,p]=d.useState(""),y=d.useRef(!1),w=d.useRef(null),k=d.useCallback(async()=>{if(y.current)try{const $=await E.getMyTeam();if(j($.pendingRequest),$.group&&$.membership){const{group:T,membership:O}=$;f(T),m(O),a("team"),o(T);const V=w.current??O.domains[0]??"owner";l(V)}else f(null),m(null),a("personal")}catch{}},[]);d.useEffect(()=>{const $=()=>{document.visibilityState==="visible"&&k()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)},[k]),d.useEffect(()=>{fetch("/health").then($=>$.json()).then($=>{var T;((T=$.session)==null?void 0:T.lockedReason)==="as-url-changed"&&p(`Authority Server changed to ${$.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const C=d.useCallback(async($,T={})=>{S(!0),p("");try{E.setApiKey($),y.current=!0;const O=await E.login($,T);n(O),w.current=O.id;const V=await E.getGroups(),A=V.find(Z=>Z.isPersonal)??V[0]??null;o(A),l("owner"),await k()}catch(O){throw E.clearApiKey(),y.current=!1,p(O instanceof Error?O.message:"Login failed"),O}finally{S(!1)}},[k]),N=d.useCallback(async()=>{await E.logout(),E.clearApiKey(),y.current=!1,w.current=null,n(null),o(null),l(""),f(null),m(null),j(null),a("personal"),p("")},[]),R=d.useCallback($=>{E.clearApiKey(),y.current=!1,w.current=null,n(null),o(null),l(""),f(null),m(null),j(null),a("personal"),p($??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),I=d.useCallback(()=>p(""),[]),L=d.useCallback(($,T)=>{o($),l(T)},[]);return s.jsx(Eh.Provider,{value:{user:t,mode:r,group:i,domain:c,groupId:(i==null?void 0:i.id)??null,activeTeam:u,activeMembership:h,pendingRequest:x,isLoading:v,error:g,login:C,logout:N,clearError:I,handleSessionLocked:R,activeGroup:i,activeDomain:c,groups:i?[i]:[],setActiveContext:L,refreshGroups:k},children:e})}function Ue(){const e=d.useContext(Eh);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Th=d.createContext(null);function Ox({children:e}){const{user:t}=Ue(),n=d.useRef(null),[r,a]=d.useState(!1),i=d.useRef(new Map),o=d.useCallback((c,l)=>{const u=i.current;return u.has(c)||u.set(c,new Set),u.get(c).add(l),()=>{var f;(f=u.get(c))==null||f.delete(l)}},[]);return d.useEffect(()=>{if(!t){n.current&&(n.current.close(),n.current=null,a(!1));return}if(n.current)return;const c=E.getApiKey();if(!c)return;const l=new EventSource(`/events?key=${encodeURIComponent(c)}`);n.current=l,l.onopen=()=>a(!0),l.onerror=()=>a(!1);const u=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected","session-locked"];for(const f of u)l.addEventListener(f,h=>{let m;try{m=JSON.parse(h.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()=>{l.close(),n.current=null,a(!1)}},[t]),s.jsx(Th.Provider,{value:{connected:r,addListener:o},children:e})}function ve(e,t){const n=d.useContext(Th);if(!n)return;const{addListener:r}=n;d.useEffect(()=>r(e,t),[e,t,r])}const ds="suveren-theme",ad="hap-theme";function oa(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(ad);t!==null&&localStorage.getItem(ds)===null&&localStorage.setItem(ds,t),t!==null&&localStorage.removeItem(ad)})();function Ih(){const[e,t]=d.useState(()=>{const i=localStorage.getItem(ds);return i==="light"||i==="dark"?i:"system"}),[n,r]=d.useState(()=>oa(e));d.useEffect(()=>{const i=document.documentElement,o=oa(e);i.setAttribute("data-theme",o),e==="system"?localStorage.removeItem(ds):localStorage.setItem(ds,e),r(oa(e))},[e]),d.useEffect(()=>{if(e!=="system")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>r(oa("system"));return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[e]);const a=d.useCallback(()=>{t(i=>i==="system"?"light":i==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:n,toggle:a}}const Mx=5*60*1e3,Bx=2e3;function kc(){const[e,t]=d.useState(!1),[n,r]=d.useState("docker"),[a,i]=d.useState(""),[o,c]=d.useState(null),[l,u]=d.useState(!1),[f,h]=d.useState(!1),[m,x]=d.useState(!1),j=d.useRef(null);return d.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"&&c(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"&&u(!0)))}).catch(()=>{})};S(!0);const g=setInterval(()=>S(!1),m?Bx:Mx),p=()=>{document.visibilityState==="visible"&&S(!1)};return document.addEventListener("visibilitychange",p),window.addEventListener("focus",p),()=>{v=!0,clearInterval(g),document.removeEventListener("visibilitychange",p),window.removeEventListener("focus",p)}},[m]),{updateAvailable:e&&!f,installMethod:n,version:a,latestVersion:o,serverRestarted:l,startFastPolling:()=>x(!0),dismiss:()=>h(!0)}}function Dx(e){return!e||typeof e!="object"?{managed:!1}:{managed:Array.isArray(e.policyLocked)&&e.policyLocked.includes("team")}}function Ux(){const[e,t]=d.useState({managed:!1});return d.useEffect(()=>{let n=!1;return fetch("/health").then(r=>r.json()).then(r=>{n||t(Dx(r))}).catch(()=>{}),()=>{n=!0}},[]),e}function Wx({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 Hx(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const id={system:"◑",light:"☀",dark:"☾"};function bc({onMenuToggle:e}){const{user:t,logout:n,mode:r,activeTeam:a}=Ue(),{theme:i,toggle:o}=Ih(),{version:c,updateAvailable:l,latestVersion:u}=kc(),{managed:f}=Ux(),h=Hx(c),m=r==="team"&&a?`Team ${a.name}`:"Personal";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(Wx,{size:20}),s.jsx("span",{className:"logo",children:"Suveren"}),s.jsx("span",{className:"version-badge",children:"Local Gateway"}),h&&s.jsxs("span",{className:"gw-version",title:l&&u?`Running v${h} — v${u} is available`:"Running gateway version","data-stale":l?"true":void 0,children:["v",h,l&&u?` → ${u}`:""]})]}),s.jsx("div",{className:"nav-spacer"}),s.jsx("div",{className:"nav-actions nav-actions-desktop",children:t?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"workspace-pill","data-managed":f?"true":void 0,title:f?`${m} — set by your IT`:m,children:[m,f&&s.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),s.jsx("span",{className:"user-chip",children:s.jsx("strong",{children:t.name})}),s.jsx("button",{className:"theme-toggle",onClick:o,title:`Theme: ${i}`,children:id[i]}),s.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):s.jsx("button",{className:"theme-toggle",onClick:o,title:`Theme: ${i}`,children:id[i]})}),t&&e&&s.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function Nc(e,t){var n;if((n=t==null?void 0:t.revokedSet)!=null&&n.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function Rh(e){return e==="expired"||e==="revoked"}function Ah(e,t){var n;return!!((n=t==null?void 0:t.archivedSet)!=null&&n.has(e.authorization_id))&&Rh(Nc(e,t))}function ei(e,t){return Ah(e,t)?"archived":Nc(e,t)}function Ph(e,t){const n={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const r of e)n[ei(r,t)].push(r);return n}function Vx(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 Tt(e,t,n){const r=d.useRef(e);r.current=e,d.useEffect(()=>{let a=null;const i=()=>typeof document>"u"?!0:document.visibilityState==="visible",o=()=>{i()&&r.current()},c=()=>{a===null&&(a=setInterval(o,t))},l=()=>{a!==null&&(clearInterval(a),a=null)},u=()=>{i()?(r.current(),c()):l()};return i()&&(r.current(),c()),document.addEventListener("visibilitychange",u),()=>{l(),document.removeEventListener("visibilitychange",u)}},[t,n])}function Cc(){const[e,t]=d.useState(!1);return d.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 Gx(e,t){const n=e.simulation;return n?(((t==null?void 0:t[n.field])??"").trim().toLowerCase()||n.default.trim().toLowerCase())==="simulation":!1}function Is(e){return!!(e!=null&&e.simulation)}const $h=d.createContext(null),Kx=3e4,Yx=5e3,Jx=3e5;function Qx(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 qx({children:e}){const[t,n]=d.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),r=d.useRef(null),a=d.useCallback(async()=>{let f=!1;const[h,m]=await Promise.all([E.getIntegrationManifests().catch(()=>(f=!0,{manifests:[]})),E.getMcpHealth().catch(()=>null)]);n(j=>({...j,manifests:h.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=h.manifests.filter(j=>j.oauth);if(x.length>0){const j=await Promise.all(x.map(async v=>[v.id,await E.getOAuthHealth(v.id)]));n(v=>({...v,authHealth:Object.fromEntries(j)}))}},[]),i=t.fetchCount>0&&t.manifests.some(f=>{const h=t.integrations.find(m=>m.id===f.id);return h&&!h.running&&!h.paused});ve("integration-changed",a),Tt(a,i?Yx:Jx);const o=d.useMemo(()=>{const f=new Map(t.integrations.map(x=>[x.id,x])),h=Date.now();i&&r.current===null?r.current=h:i||(r.current=null);const m=r.current!==null&&h-r.current<Kx;return t.manifests.map(x=>{const j=f.get(x.id),v=Qx(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]),c=Cc(),l=d.useMemo(()=>o.filter(f=>!(c&&!Is(f.manifest))&&(f.state==="not-running"||f.state==="error"||f.authStatus==="failed")).length,[o,c]),u={loading:t.fetchCount===0,mcpServerUp:t.mcpServerUp,manifestsError:t.manifestsError,entries:o,attentionCount:l,activeSessions:t.activeSessions,refresh:a};return s.jsx($h.Provider,{value:u,children:e})}function Ec(){const e=d.useContext($h);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const Xx={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Tc=e=>Xx[e]??e,Zx={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 e0(e){return(e&&Zx[e])??{chip:"Blocked",sev:"info"}}function t0(e){const t=Tc(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 _h(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 od=5,n0=24*60*60*1e3,Ca=7;function r0(e,t){const n=t-Ca*n0;return{recent:e.filter(r=>r.ts>=n),all:e}}function s0(){const[e,t]=d.useState(null),[n,r]=d.useState(!1),[a,i]=d.useState(!1),o=d.useCallback(()=>{E.getDenials({limit:200}).then(({records:m})=>{t(m),i(!1)}).catch(()=>i(!0))},[]);if(d.useEffect(()=>{o()},[o]),Tt(o,12e4),a||e===null)return null;const{recent:c,all:l}=r0(e,Date.now()),u=n?l:c.slice(0,od),f=l.length-c.length,h=(m,x)=>{const j=e0(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:t0(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:Tc(m.integrationId)})]}),j.fixTo&&s.jsx(Be,{className:"rb-fix",to:j.fixTo,children:"Set a read window →"})]}),s.jsx("div",{className:"rb-when",children:_h(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?l.length:c.length)>0&&s.jsx("span",{className:"rb-count",children:n?l.length:c.length})]}),u.length===0?s.jsxs("div",{className:"rb-empty",children:[s.jsx("span",{className:"rb-mark","aria-hidden":"true",children:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6 9 17l-5-5"})})}),s.jsxs("h3",{children:["Nothing blocked in the last ",Ca," days"]}),s.jsx("p",{children:"Your agent has stayed within every limit you set."}),f>0&&s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!0),children:["Show the last 30 days (",f,")"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"rb-sub",children:[n?"Last 30 days. ":`Last ${Ca} days. `,"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."]}),s.jsx("div",{className:"rb-rows",children:u.map(h)}),!n&&l.length>u.length&&s.jsx("div",{className:"rb-foot",children:s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!0),children:["View all ",l.length," blocks from the last 30 days"]})}),n&&l.length>Math.min(c.length,od)&&s.jsx("div",{className:"rb-foot",children:s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!1),children:["Show only the last ",Ca," days"]})})]})]})}function Rs(e){return e.kind??"read"}function a0(e,t){var i,o,c,l;if(!t)return"";if(!e)return t;const n=(o=(i=e.scopeSchema)==null?void 0:i.fields)==null?void 0:o[t];if(n!=null&&n.displayName)return n.displayName;const r=((c=e.boundsSchema)==null?void 0:c.fields)??{};if((l=r[t])!=null&&l.displayName)return r[t].displayName;const a=Object.values(r).find(u=>u.boundType&&"of"in u.boundType&&u.boundType.of===t);return a!=null&&a.displayName?a.displayName:t}const i0={bound:"Blocked — above your limit",scope:"Blocked — outside your mandate's scope",cumulative:"Blocked — limit reached",simulation:"Blocked — simulation mode",not_authorized:"Blocked — not authorized",read:"Read blocked"},o0={bound:"Nothing ran. To allow this, raise the limit on the mandate (needs your signature) — or ask the AI to stay within it.",scope:"Nothing ran. To allow this, widen the mandate's scope (needs your signature) — or ask the AI to stay within it.",cumulative:"Nothing ran. Possible again once the window resets — or raise the limit in the mandate.",simulation:"Nothing ran. Turn off simulation mode in Settings to use real systems.",not_authorized:"Nothing ran. Grant a mandate for this, or ask the decision owner.",read:"Nothing was read."};function ld(e){return e===void 0?"":typeof e=="number"?e.toLocaleString():e}function l0(e,t){const n=Rs(e),r=ld(e.value),a=ld(e.limit);switch(n){case"bound":return r&&a?`${t||"Value"} ${r} is above the limit ${a}.`:e.detail;case"scope":return r?`${t||"Value"} "${r}" is not within your mandate's allowed ${t||"scope"}.`:e.detail;case"cumulative":return r&&a?`${r} of ${a} used — the limit is reached.`:e.detail;case"simulation":return"Real systems are switched off while the gateway runs in simulation mode.";case"not_authorized":return"No mandate currently covers this action.";case"read":default:return e.detail}}function c0(e){const t=Rs(e),n=Tc(e.integrationId),r=e.mandateTitle?` · mandate "${e.mandateTitle}"`:e.mandateId?` · mandate ${e.mandateId.slice(0,14)}…`:"",a=e.who==="authority-server"?"refused by the Authority Server":t==="read"?"refused by this gateway":"refused by this gateway, before anything ran",i=e.code?` (${e.code})`:"";return`${n} · ${e.tool}${r} · ${a}${i}`}function u0(e,t){const n=Rs(e),r=a0(t,e.field);return{title:i0[n],sentence:l0(e,r),sourceLine:c0(e),whatYouCanDo:o0[n]}}function Lh(e,t){const n=new Date(t);return n.setHours(0,0,0,0),e.filter(r=>r.ts>=n.getTime()).length}const d0=[{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:"/blocked",icon:"⛔",label:"Blocked",statusKey:"blocked"},{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 f0(){const{activeDomain:e}=Ue(),[t,n]=d.useState({}),r=d.useCallback(async()=>{try{const[a,i,o,c,l,u,f]=await Promise.all([E.getCredential("ai-config").catch(()=>null),E.getMyAttestations().catch(()=>null),E.getMyProposals(e).catch(()=>null),E.getProposalsForApprover().catch(()=>null),E.getAgentContext().catch(()=>""),E.getArchivedMandates().catch(()=>[]),E.getDenials({limit:200}).catch(()=>null)]),h={};if(a&&!a.configured&&(h.assistant=1),i){const v=Ph(i,{archivedSet:new Set(u)}).expired.length;v>0&&(h.authorizations=v)}const m=(o==null?void 0:o.length)??0,x=(c==null?void 0:c.length)??0,j=m+x;if(j>0&&(h.proposals=j),(!l||!l.trim())&&(h.brief=1),f){const v=Lh(f.records,Date.now());v>0&&(h.blocked=v)}n(h)}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),d.useEffect(()=>(window.addEventListener("suveren:archived-changed",r),()=>window.removeEventListener("suveren:archived-changed",r)),[r]),Tt(r,3e5,e),t}const m0={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},h0={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 p0(){const{mode:e,group:t,domain:n,activeTeam:r}=Ue(),a=f0(),{attentionCount:i}=Ec(),o={...a};i>0&&(o.integrations=i);const c=d0.filter(m=>!m.teamOnly||e==="team"),l=d.useRef(null),[u,f]=d.useState(null),h=ht();return d.useEffect(()=>{if(l.current===null){l.current=e;return}l.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"),l.current=e)},[e,r]),d.useEffect(()=>{f(null)},[h.pathname]),s.jsxs("div",{className:"sidebar",children:[s.jsx("ul",{className:"sidebar-nav",children:c.map(m=>{const x=m.statusKey?o[m.statusKey]:0;return s.jsx("li",{children:s.jsxs(jc,{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:m0,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})]}),u&&s.jsx("div",{style:h0,role:"status","aria-live":"polite",children:u})]})}const so="suveren:updatedTo";function g0(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 y0="Updates for this gateway come from your company's IT — no action needed here.";function v0(e){return e==="managed"?"update-banner is-managed":"update-banner"}const x0="Download the new installer and run it. Your settings and mandates stay.";function w0(e){const t="https://github.com/suverenai/suveren-gateway/releases";return e?`${t}/tag/v${e}`:`${t}/latest`}function j0(){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 zh(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:a,startFastPolling:i,dismiss:o}=kc(),[c,l]=d.useState(!1),[u,f]=d.useState(!1),[h,m]=d.useState(()=>{try{const y=sessionStorage.getItem(so);if(y)return sessionStorage.removeItem(so),y}catch{}return null}),x=g0(t),j=d.useRef(null),v=y=>{try{sessionStorage.setItem(so,y||r||"✓")}catch{}window.location.reload()};d.useEffect(()=>{if(!h)return;const y=setTimeout(()=>m(null),6e3);return()=>clearTimeout(y)},[h]),d.useEffect(()=>{if(!c||!a)return;const y=()=>j0()?!1:(v(n),!0);if(y())return;const w=setInterval(y,1500);return()=>clearInterval(w)},[c,a,n]),d.useEffect(()=>(document.body.classList.toggle("is-updating",c),()=>document.body.classList.remove("is-updating")),[c]);const S=e&&!c&&!h||!!h&&!c;d.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 k=((C=j.current)==null?void 0:C.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${k}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=()=>{l(!0),i()},p=async()=>{if(x)try{await navigator.clipboard.writeText(x),f(!0),setTimeout(()=>f(!1),1800)}catch{}};return s.jsxs(s.Fragment,{children:[h&&!c&&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",h&&h!=="✓"?` — ${h} is live`:" — now live","."]}),s.jsx("button",{className:"update-banner-x",onClick:()=>m(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!c&&!h&&s.jsxs("div",{ref:j,className:v0(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:w0(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:y0}),t==="msi"&&s.jsx("p",{className:"update-banner-hint",children:x0})]}),c&&s.jsx("div",{className:"update-overlay",children:s.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[s.jsx("div",{className:"update-spinner"}),s.jsxs("h2",{children:["Finishing the update","…"]}),s.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",s.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),s.jsxs("div",{className:"update-cmd-row",children:[s.jsx("code",{className:"update-cmd",children:x}),s.jsx("button",{className:"btn btn-sm btn-primary",onClick:p,children:u?"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:()=>l(!1),children:"Cancel"})]})]})})]})}function Fh(){const e=Cc(),t=d.useRef(null);return d.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 S0={system:"◑",light:"☀",dark:"☾"},k0=[{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 b0({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:a,logout:i}=Ue(),{theme:o,toggle:c}=Ih(),l=ht();return d.useEffect(()=>{t()},[l.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:k0.map(u=>s.jsxs(jc,{to:u.to,end:u.to==="/",className:({isActive:f})=>`mobile-menu-item${f?" active":""}`,onClick:t,children:[s.jsx("span",{className:"icon",children:u.icon}),u.label]},u.to))}),s.jsxs("div",{className:"mobile-menu-footer",children:[s.jsxs("button",{className:"mobile-menu-action",onClick:()=>{c()},children:[s.jsx("span",{className:"icon",children:S0[o]}),"Theme: ",o]}),s.jsx("button",{className:"mobile-menu-action",onClick:()=>{i(),t()},children:"Logout"})]})]})]}):null}function Oh(e){return e.status==="pending"}function N0(e,t){return e.filter(Oh).length+t.length}const Pn=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],C0=500;function Mh(){const{user:e,domain:t}=Ue(),[n,r]=d.useState(0),a=d.useRef(null),i=d.useCallback(async()=>{if(!e){r(0);return}try{const[c,l]=await Promise.all([E.getMyProposals(t).catch(()=>[]),E.getProposalsForApprover().catch(()=>[])]);r(N0(c,l))}catch{r(0)}},[e,t]),o=d.useCallback(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i()},C0)},[i]);return d.useEffect(()=>(i(),()=>{a.current&&clearTimeout(a.current)}),[i]),ve(Pn[0],o),ve(Pn[1],o),ve(Pn[2],o),ve(Pn[3],o),ve(Pn[4],o),ve(Pn[5],o),ve(Pn[6],o),n}const cd="Suveren",E0="/favicon.svg",T0="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",la={x1:74.54,y1:22.74,x2:94.46,y2:34.24},I0=14,R0="#f59e0b";function A0(e){const t=Ic(e);return t>0?`(${t}) ${cd}`:cd}function Ic(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function P0(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
52
+ <path class="m" d="${T0}"/>
53
+ <line class="m" x1="${la.x1}" y1="${la.y1}" x2="${la.x2}" y2="${la.y2}"/>
54
+ <circle cx="103" cy="103" r="25" fill="${R0}"/>
55
+ <style>.m{stroke:#111111;stroke-width:${I0};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 $0(){return document.querySelector('link[rel="icon"]')}function Bh(e){const t=Ic(e);document.title=A0(t),Dh(t);const n=$0();if(!n)return;const r=t>0?P0():E0;n.getAttribute("href")!==r&&n.setAttribute("href",r)}function _0(){Bh(0)}function Dh(e,t=globalThis.navigator){var a;if(!t||typeof t.setAppBadge!="function")return;const n=Ic(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 L0(){const e=Mh();return d.useEffect(()=>{Bh(e)},[e]),d.useEffect(()=>_0,[]),null}const Uh="suveren:dockBadgePrompt";function z0(){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(Uh))return!1}catch{}return!0}function F0(){const[e,t]=d.useState(!1),n=Mh();if(d.useEffect(()=>{t(z0())},[]),!e)return null;const r=()=>{try{localStorage.setItem(Uh,"1")}catch{}t(!1)},a=async()=>{try{await Notification.requestPermission()==="granted"&&Dh(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 O0(){const[e,t]=d.useState(!1);return s.jsxs(qx,{children:[s.jsx(L0,{}),s.jsx(bc,{onMenuToggle:()=>t(!e)}),s.jsx(zh,{}),s.jsx(Fh,{}),s.jsx(p0,{}),s.jsx(b0,{open:e,onClose:()=>t(!1)}),s.jsx("div",{className:"main-content",children:s.jsxs("div",{className:"page-inner",children:[s.jsx(F0,{}),s.jsx(Qv,{})]})})]})}function Wh({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 Rc(){return typeof navigator<"u"&&navigator.webdriver===!0}const Ac="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function M0(){const[e,t]=d.useState(""),{login:n,isLoading:r,error:a,clearError:i}=Ue(),[o,c]=d.useState(null),l=Rc(),u=async()=>{if(!(!e.trim()||l)){i();try{await n(e)}catch(m){if(m instanceof Ch){c(m.summary);return}}}},f=async()=>{c(null),i();try{await n(e,{confirmWipe:!0})}catch{}},h=()=>{c(null)};return s.jsxs(s.Fragment,{children:[s.jsx(bc,{}),s.jsx(zh,{}),s.jsx(Fh,{}),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(Wh,{what:"sign-in"}),l&&s.jsx("div",{className:"error-message",children:Ac}),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"&&u(),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:u,disabled:r||l,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:h,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:h,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 B0(e,t){return!t&&e!=null}function D0(e,t){return e==="join-waiting"&&t==="team"}function U0(e,t,n,r){return n!=null||e!=="join-waiting"||t==="team"?null:r}function W0(e){return`${e} personal mandate${e===1?"":"s"}`}function H0({mandates:e,pendingProposals:t}){return e.length===0&&t===0?s.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)"},children:"You have no personal mandates to end."}):s.jsxs("div",{style:{background:"var(--bg-elevated)",borderRadius:"0.5rem",padding:"0.75rem 1rem",margin:"0.75rem 0"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Your personal mandates end"}),s.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,fontSize:"0.825rem"},children:e.map(n=>s.jsxs("li",{style:{display:"flex",justifyContent:"space-between",gap:"0.5rem",padding:"0.25rem 0",borderBottom:"1px solid var(--border)"},children:[s.jsx("span",{children:n.title||n.profileId}),s.jsx("span",{style:{color:"var(--text-tertiary)"},children:n.commitmentMode??""})]},n.id))}),s.jsxs("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem",marginBottom:0},children:["They stay in your history; their tickets stay verifiable.",t>0&&` ${t} personal proposal${t===1?"":"s"} waiting for approval end${t===1?"s":""} too.`]})]})}function V0(){const{mode:e,pendingRequest:t,refreshGroups:n}=Ue(),r=Ut(),[a,i]=d.useState("choose"),[o,c]=d.useState(""),[l,u]=d.useState(""),[f,h]=d.useState(null),[m,x]=d.useState(null),[j,v]=d.useState(""),[S,g]=d.useState(""),[p,y]=d.useState(!1),w=d.useRef(!1);d.useEffect(()=>{B0(t,w.current)&&(w.current=!0,i("join-waiting"))},[t]),d.useEffect(()=>{D0(a,e)&&r("/")},[a,e,r]);const k=d.useRef(null);d.useEffect(()=>{if(t){k.current=t.groupName;return}const T=U0(a,e,t,k.current);T&&(v(T),i("join-declined"),k.current=null)},[t,a,e]),d.useEffect(()=>{if(a!=="join-waiting")return;const T=setInterval(()=>{n()},5e3);return()=>clearInterval(T)},[a,n]);const C=d.useCallback(()=>{i("choose"),g(""),h(null),x(null),c(""),u("")},[]),N=async()=>{if(o.trim()){y(!0),g("");try{const T=await E.getJoinPreview(o.trim());h(T),i("join-preview")}catch(T){g(T instanceof Error?T.message:"Invalid or expired invite code")}finally{y(!1)}}},R=async()=>{y(!0),g("");try{await E.requestToJoinGroup(o.trim()),await n(),i("join-waiting")}catch(T){g(T instanceof Error?T.message:"Failed to join group")}finally{y(!1)}},I=async()=>{y(!0),g("");try{await E.withdrawJoinRequest(),await n(),C()}catch(T){g(T instanceof Error?T.message:"Failed to withdraw request")}finally{y(!1)}},L=async()=>{i("create"),g(""),y(!0);try{const T=await E.getCreatePreview();x(T)}catch(T){g(T instanceof Error?T.message:"Failed to load preview")}finally{y(!1)}},$=async()=>{if(l.trim()){y(!0),g("");try{await E.createGroup(l.trim()),await n(),r("/")}catch(T){g(T instanceof Error?T.message:"Failed to create group")}finally{y(!1)}}};return s.jsxs(s.Fragment,{children:[s.jsx(bc,{}),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&&s.jsx("div",{className:"error-message",children:S}),a==="choose"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[s.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join or create a team"}),s.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6},children:"An account is Personal or in one team — never both. Joining or creating a team moves your account: your personal mandates end (kept in your history)."})]}),s.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[s.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing team"}),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:o,onChange:T=>c(T.target.value),onKeyDown:T=>T.key==="Enter"&&N(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:p}),s.jsx("button",{className:"btn btn-primary",onClick:N,disabled:p||!o.trim(),children:p?"Checking…":"Continue"})]})]}),s.jsxs("div",{className:"card",children:[s.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new team"}),s.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members."}),s.jsx("button",{className:"btn btn-secondary",onClick:L,disabled:p,children:"Create a team"})]})]}),a==="join-preview"&&f&&s.jsxs("div",{className:"card",children:[s.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Join team ",f.groupName,"?"]}),s.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Your account ",s.jsx("strong",{children:"moves to the team"}),". From then on you work under the team's rules — its approvers and limits."]}),s.jsx(H0,{mandates:f.personalMandates,pendingProposals:f.pendingPersonalProposals}),s.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:["The team admin (",f.admin.name,") confirms your request. Nothing changes until then."]}),s.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:R,disabled:p,children:p?"Asking…":"Ask to join"}),s.jsx("button",{className:"btn btn-ghost",onClick:C,disabled:p,children:"Cancel"})]})]}),a==="join-waiting"&&s.jsxs("div",{className:"card",children:[s.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request sent to team ",(t==null?void 0:t.groupName)??""]}),s.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Waiting for the team admin to confirm. Until then your account stays Personal and your mandates keep working."}),s.jsx("button",{className:"btn btn-secondary",onClick:I,disabled:p,children:p?"Withdrawing…":"Withdraw request"})]}),a==="join-declined"&&s.jsxs("div",{className:"card",children:[s.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request to ",j," ended"]}),s.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"The team admin declined your request, or it was withdrawn. Your account stays Personal."}),s.jsx("button",{className:"btn btn-primary",onClick:C,disabled:p,children:"Back"})]}),a==="create"&&s.jsxs("div",{className:"card",children:[s.jsx("h3",{style:{marginBottom:"0.75rem"},children:"Create a team"}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsx("label",{style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:"Team name"}),s.jsx("input",{className:"form-input",placeholder:"e.g., Acme Corp",value:l,onChange:T=>u(T.target.value),onKeyDown:T=>T.key==="Enter"&&$(),disabled:p,autoFocus:!0})]}),m&&s.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",W0(m.personalMandates.length)," end (kept in your history)."]}),s.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginTop:"1rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:$,disabled:p||!l.trim(),children:p?"Creating…":"Create team and move my account"}),s.jsx("button",{className:"btn btn-ghost",onClick:C,disabled:p,children:"Cancel"})]})]})]})})]})}const ud={"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`}},dd=["claude-code","claude-desktop","chatgpt-codex","other"];function il({mcpEndpoint:e}){const[t,n]=d.useState(dd[0]),[r,a]=d.useState(!1),i=d.useCallback(async c=>{try{await navigator.clipboard.writeText(c),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[]),o=ud[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:dd.map(c=>s.jsx("button",{className:`mcp-tab${t===c?" active":""}`,onClick:()=>n(c),children:ud[c].label},c))}),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 ol="suveren-setup-ai-skipped",ll="suveren-setup-agent-done",cl="suveren-setup-dismissed",G0={"hap-setup-ai-skipped":ol,"hap-setup-agent-done":ll,"hap-setup-dismissed":cl};function K0(){for(const[e,t]of Object.entries(G0)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}K0();function Y0({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:a}){const[i,o]=d.useState(()=>localStorage.getItem(ol)==="true"),[c,l]=d.useState(()=>localStorage.getItem(ll)==="true"),[u,f]=d.useState(()=>localStorage.getItem(cl)==="true"),[h,m]=d.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||c?"done":"pending"}],j=x.filter(w=>w.status==="done"||w.status==="skipped").length,v=j===x.length,S=d.useCallback(()=>{localStorage.setItem(ol,"true"),o(!0)},[]),g=d.useCallback(()=>{localStorage.setItem(ll,"true"),l(!0),m(null)},[]),p=d.useCallback(()=>{localStorage.setItem(cl,"true"),f(!0)},[]);if(u||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:p,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,k)=>{const C=k===y,N=w.status==="done"||w.status==="skipped"?"●":"○",R=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:R,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(Be,{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"&&k===3?s.jsx("button",{onClick:()=>m(h===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(Be,{to:w.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),k===3&&h===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(il,{mcpEndpoint:a}),s.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:g,children:"Done"})]})]},k)})}),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 Hh(e,t=null){const n=[e.hasContact,e.hasDelegationMandate,e.delegationProposalCount>0],r=n.every(Boolean),a=e.otherMandateCount===0&&!r,i=n.findIndex(u=>!u),o=t!==null&&n[t]===!1?t:i,c=e.managed?"managed":"self",l=u=>n[u]?{status:"done"}:u!==o?{status:"todo"}:u===1?{status:"open",variant:c,simulationOn:e.simulationOn}:u===0?{status:"open",variant:c}:{status:"open"};return{visible:a,step1:l(0),step2:l(1),step3:l(2)}}const J0="/mandates?new=1&profile=delegation";function fd({text:e}){const[t,n]=d.useState(!1),r=d.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 ao({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 Q0({contact:e,hasDelegationMandate:t,otherMandateCount:n,delegationProposalCount:r,managed:a,simulationOn:i,mcpEndpoint:o}){const c={hasContact:e!==null,hasDelegationMandate:t,otherMandateCount:n,delegationProposalCount:r,managed:a,simulationOn:i},[l,u]=d.useState(null),f=Hh(c,l);if(!f.visible)return null;const h=`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 ",_h(Date.parse(e.lastSeenAt),Date.now()).toLowerCase()]}):s.jsx(ao,{todo:f.step1.status==="todo",onOpen:()=>u(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(il,{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:h}),s.jsx(fd,{text:h})]})}),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(il,{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(Be,{to:"/mandates",children:"review or revoke under Mandates"})]}):s.jsx(ao,{todo:f.step2.status==="todo",onOpen:()=>u(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(Be,{to:J0,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(ao,{todo:f.step3.status==="todo",onOpen:()=>u(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(fd,{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(Be,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function q0(){const[e,t]=d.useState(null);return d.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 X0(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 Vh(){const[e,t]=d.useState({simulation:null,locked:!1});return d.useEffect(()=>{let n=!1;return fetch("/health").then(r=>r.json()).then(r=>{n||t(X0(r))}).catch(()=>{}),()=>{n=!0}},[]),e}function Z0(e){return!e||typeof e!="object"?!1:Array.isArray(e.policyLocked)&&e.policyLocked.length>0}function ew(){const[e,t]=d.useState(!1);return d.useEffect(()=>{let n=!1;const r=()=>{fetch("/health").then(o=>o.json()).then(o=>{n||t(Z0(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 Dn({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 io(){return s.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[s.jsx(Dn,{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(Dn,{variant:"line",style:{width:"35%"}}),s.jsx(Dn,{variant:"line-sm",style:{width:"65%"}})]})]})}function tw(){const[e,t]=d.useState([]);return Tt(async()=>{try{const{skipped:r}=await E.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 nw(e,t){return t&&!Is(e.manifest)}function rw(e,t=!1){var r;const n=[];for(const a of e)nw(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"&&(Is(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 sw(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 aw=30*60;function er(e){return e.replace(/@.*$/,"").split("/").pop()??e}function iw(){const{domain:e}=Ue(),[t,n]=d.useState([]),[r,a]=d.useState([]),[i,o]=d.useState([]),[c,l]=d.useState(!0),[u,f]=d.useState(!1),[h,m]=d.useState([]),[x,j]=d.useState(!1),[v,S]=d.useState(!1),[g,p]=d.useState(null),[y,w]=d.useState(!1),{entries:k,activeSessions:C,loading:N}=Ec(),R=q0(),I=!N,{simulation:L}=Vh(),$=L===!0,T=ew(),O=d.useCallback(()=>{E.getMyAttestations().then(J=>{n(J),f(!0)}).catch(()=>f(!0)),E.getArchivedMandates().then(m).catch(()=>m([])),E.getMyProposals(e).then(J=>{a(J),j(!0)}).catch(()=>j(!0)),E.getProposalsForApprover().then(J=>o(J)).catch(()=>o([])),E.getCredential("ai-config").then(J=>{l(J.configured),S(!0)}).catch(()=>S(!0)),E.getAgentContact().then(J=>{p(J.contact),w(!0)}).catch(()=>w(!0))},[e]);ve("attestation-changed",O),ve("proposal-added",O),ve("proposal-resolved",O),ve("proposal-approved",O),ve("proposal-rejected",O),Tt(O,3e5,e);const V=u&&x&&v&&I&&y&&L!==null,A=Ph(t,{archivedSet:new Set(h)}),Z=A.active,se=A.expired,z=Z.some(J=>er(J.profile_id)==="delegation"),P=Z.filter(J=>er(J.profile_id)!=="delegation").length,B=r.filter(J=>er(J.profileId)==="delegation").length,_=Hh({hasContact:g!==null,hasDelegationMandate:z,otherMandateCount:P,delegationProposalCount:B,managed:T,simulationOn:$}),F=$&&_.visible,K=Z.filter(J=>J.remaining_seconds!==null&&J.remaining_seconds<=aw),X=r.filter(Oh),ne=k.filter(J=>J.state==="running"),le=k.filter(J=>J.state==="starting"),me=sw(k),ye=[];for(const J of i)ye.push({label:"Approval needed",detail:`${J.tool} — above-cap action under ${er(J.profileId)}`,to:"/approvals",color:"var(--warning)"});for(const J of X)ye.push({label:"Approval pending",detail:`${J.tool} awaiting your approval`,to:"/approvals",color:"var(--warning)"});for(const J of K){const xe=Math.ceil((J.remaining_seconds??0)/60);ye.push({label:"Expiring soon",detail:`${J.title??er(J.profile_id)} — ${xe} min remaining`,to:"/mandates",color:"var(--warning)"})}for(const J of se)ye.push({label:"Expired",detail:J.title??er(J.profile_id),to:"/mandates",color:"var(--danger)"});ye.push(...rw(k,$));for(const J of le)ye.push({label:"Integration starting",detail:`${J.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const J of k)J.authStatus==="failed"&&J.state!=="not-running"&&J.state!=="error"&&J.state!=="paused"&&ye.push({label:"Reconnect needed",detail:`${J.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return c||ye.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"})}),V&&R&&(F?s.jsx(Q0,{contact:g,hasDelegationMandate:z,otherMandateCount:P,delegationProposalCount:B,managed:T,simulationOn:$,mcpEndpoint:R}):!$&&s.jsx(Y0,{aiConfigured:c,hasRunningIntegration:ne.length>0,hasActiveAuth:Z.length>0,hasAgentConnected:C>0,mcpEndpoint:R})),!F&&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(Be,{to:"/mandates",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[u?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:Z.length>0?"var(--success)":"var(--text-tertiary)"},children:Z.length}):s.jsx(Dn,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),s.jsx(Be,{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(Dn,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),s.jsx(Be,{to:"/mandates",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[u?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:se.length>0?"var(--danger)":"var(--text-tertiary)"},children:se.length}):s.jsx(Dn,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),s.jsx(Be,{to:"/integrations",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[I?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:ne.length>0?"var(--success)":"var(--text-tertiary)"},children:ne.length}):s.jsx(Dn,{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"}),ye.length>0&&s.jsx("span",{className:"rb-count",children:ye.length})]}),ye.length>0?s.jsx("div",{className:"attention-rows",children:ye.map((J,xe)=>s.jsxs(Be,{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:"›"})]},xe))}):V?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(io,{}),s.jsx(io,{}),s.jsx(io,{})]})]})]}),me&&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:[me.count," real system",me.count===1?"":"s"," ",me.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",me.namesText,"."]})]}),s.jsx(tw,{}),s.jsx(s0,{})]})}const ow=["Scope & Limits","Intent","Sign"];function Gh({currentStep:e,onStepClick:t}){const n=Ut();return s.jsxs("div",{className:"wizard-progress",children:[s.jsx("ol",{className:"wizard-steps",children:ow.map((r,a)=>{const i=a+2,o=i<e,c=i===e,l=i-1<e,u=o&&!!t;return s.jsxs("li",{className:`wizard-step${l?" reached":""}`,"aria-current":c?"step":void 0,children:[s.jsx("button",{type:"button",className:`step-circle${o?" completed":""}${c?" current":""}`,onClick:u?()=>t(i):void 0,disabled:!u,"aria-label":`${r}${o?" (done)":c?" (current)":""}`,children:o?"✓":a+1}),s.jsx("span",{className:`step-label-text${c?" 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 md=40,lw={delegation:"Delegation"};function ze(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=lw[i.toLowerCase()];return o||(t?t.slice(0,md):(i.charAt(0).toUpperCase()+i.slice(1)).slice(0,md))}function cw({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:"})," ",ze(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 uw({integrationId:e,field:t,value:n,onChange:r,disabled:a,onLabels:i}){const[o,c]=d.useState(null),[l,u]=d.useState(null),[f,h]=d.useState(!0);d.useEffect(()=>{let j=!1;return E.discoverScopeField(e,t).then(v=>{var S;j||(c(v.options),h(!1),(S=v.options)!=null&&S.length&&(i==null||i(Object.fromEntries(v.options.map(g=>[g.value,g.label])))))}).catch(v=>{j||(u(v instanceof Error?v.message:String(v)),h(!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,"…"]}):l||!o?s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",l??"no response","). Enter values manually, separated by commas."]}),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",p=v.primary===!0;return s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:g?"var(--text-tertiary)":"var(--text-primary)",cursor:a||g?"not-allowed":"pointer"},title:g?"Read-only — you can authorize list/read but not writes":void 0,children:[s.jsx("input",{type:"checkbox",checked:m.has(String(j.value)),onChange:()=>x(String(j.value)),disabled:a||g}),s.jsx("span",{children:j.label||j.value}),p&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),S&&s.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",S]})]},j.value)})})}function Pc(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 dw(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):Pc(e)===1?"1":""}function Kh(e){const t=e.maximum;return typeof t=="number"&&Number.isFinite(t)?t:void 0}function hd(e,t){const n=Pc(e),r=Kh(e),a=t===""?n:Math.max(n,Number(t));return r!==void 0?Math.min(r,a):a}function $c(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function fw(e){return e.replace(/@.*$/,"").split("/").pop()??e}function mw(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function hw(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function pw(e){var n;const t=e;return!!(t.enum&&((n=t.constraint)!=null&&n.enforceable.includes("subset")))}function pd(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 gw(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function yw(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 vw(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 xw({id:e,value:t,onChange:n,disabled:r,placeholder:a,unit:i,min:o=0,max:c}){const l=gw(i),u=yw(i).filter(v=>c===void 0||v.value<=c),f=$c(i),h=vw(t,i),m=t===""?null:Number(t),x=()=>{const v=t===""?0:Number(t),S=v%l,g=S===0?v+l:v+(l-S);n(String(c!==void 0?Math.min(c,g):g))},j=()=>{const v=t===""?0:Number(t);if(v<=o)return;const S=v%l,g=S===0?v-l: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:c,step:l,value:t,placeholder:a??String(o),onChange:v=>{const S=v.target.value;n(c!==void 0&&S!==""&&Number(S)>c?String(c):S)},onFocus:v=>v.target.select(),disabled:r}),s.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:x,disabled:r||c!==void 0&&t!==""&&Number(t)>=c,"aria-label":"Increase",children:"+"}),f&&s.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:f})]}),u.length>0&&!r&&s.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:u.map(v=>s.jsx("button",{type:"button",className:`preset-chip${m===v.value?" preset-chip-selected":""}`,onClick:()=>n(String(v.value)),children:v.label},v.value))}),h&&s.jsxs("div",{className:"bounded-input-echo",children:["≈ ",h]})]})}function gd({htmlFor:e,label:t,description:n}){const[r,a]=d.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 ww({id:e,value:t,onChange:n,disabled:r,format:a,placeholder:i}){const[o,c]=d.useState(""),[l,u]=d.useState(!1),f=d.useRef(null),h=t?t.split(",").map(g=>g.trim()).filter(Boolean):[],m=g=>{const p=g.trim();if(!p)return;if(!pd(p,a)){u(!0);return}u(!1);const y=h.includes(p)?h:[...h,p];n(y.join(",")),c("")},x=g=>{const p=h.filter((y,w)=>w!==g);n(p.join(","))},j=g=>{g.key==="Enter"||g.key===","||g.key==="Tab"?o.trim()&&(g.preventDefault(),m(o)):g.key==="Backspace"&&!o&&h.length>0&&x(h.length-1)},v=g=>{const p=g.clipboardData.getData("text");if(p.includes(",")){g.preventDefault();const w=p.split(",").map(C=>C.trim()).filter(Boolean).filter(C=>pd(C,a)),k=[...new Set([...h,...w])];n(k.join(",")),c(""),u(!1)}},S=a==="email"?"Type email and press Enter...":"Type domain and press Enter...";return s.jsxs("div",{className:`tag-input${l?" tag-input-invalid":""}`,onClick:()=>{var g;return(g=f.current)==null?void 0:g.focus()},children:[h.map((g,p)=>s.jsxs("span",{className:"tag-pill",children:[g,!r&&s.jsx("button",{type:"button",className:"tag-remove",onClick:y=>{y.stopPropagation(),x(p)},"aria-label":`Remove ${g}`,children:"×"})]},g)),!r&&s.jsx("input",{ref:f,id:e,className:"tag-input-field",type:"text",value:o,onChange:g=>{c(g.target.value),u(!1)},onKeyDown:j,onPaste:v,onBlur:()=>{o.trim()&&m(o)},placeholder:h.length===0?i??S:""})]})}function jw({id:e,options:t,value:n,onChange:r,disabled:a}){const i=n?n.split(",").map(c=>c.trim()).filter(Boolean):[],o=c=>{const l=i.includes(c)?i.filter(u=>u!==c):[...i,c];r(l.join(","))};return s.jsx("div",{className:"checkbox-group",id:e,children:t.map(c=>s.jsxs("label",{className:`checkbox-pill${i.includes(c)?" checkbox-pill-selected":""}`,children:[s.jsx("input",{type:"checkbox",checked:i.includes(c),onChange:()=>o(c),disabled:a}),s.jsx("span",{children:c})]},c))})}function yd({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:a,readOnly:i,twoColumn:o,discoveryIntegrationId:c,onLabels:l}){const u=mw(e,t),f=`${a}-field-${e}`,h=s.jsx(s.Fragment,{children:pw(t)?s.jsx(jw,{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(xw,{id:f,value:n,onChange:m=>r(e,m),disabled:i,unit:t.unit,min:Pc(t),max:Kh(t)}):hw(t)?s.jsx(ww,{id:f,value:n,onChange:m=>r(e,m),disabled:i,format:t.format}):c?s.jsx(uw,{integrationId:c,field:e,value:n,onChange:m=>r(e,m),disabled:i,onLabels:m=>l==null?void 0:l(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(gd,{htmlFor:f,label:u,description:t.description})}),s.jsx("div",{className:"bounds-field-input",children:h})]},`${a}-${e}`):s.jsxs("div",{className:"form-group",children:[s.jsx(gd,{htmlFor:f,label:u,description:t.description}),h]},`${a}-${e}`)}function Sw(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,c]of Object.entries(n)){const l=e[o];if(l===""||l===void 0)continue;const u=Number(l);if(!isNaN(u)&&u>c){i=!0;break}}return i?r?"above-approvers":"hard-ceiling":"within-cap"}function kw(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 bw({profile:e,onConfirm:t,onCancel:n,readOnly:r,initialBounds:a,initialContext:i,initialFrame:o,profileConfig:c,approverNames:l,adminName:u}){const f=e.boundsSchema,h=e.scopeSchema,m=f?Object.entries(f.fields).filter(([_,F])=>!(_==="profile"||_==="path"||F.enforced===!1||F.enforcedBy==="gatekeeper")):[],x=f?Object.entries(f.fields).filter(([,_])=>_.enforcedBy==="gatekeeper").filter(([,_])=>_.enforced!==!1).map(([_,F])=>F.displayName??_):[],j=h&&h.keyOrder.length>0?Object.entries(h.fields):[],v=a??o??{},S=i??{},g={};for(const[_,F]of m)g[_]=dw(F,v[_]);const p={};for(const[_]of j)p[_]=S[_]!==void 0?String(S[_]):"";const[y,w]=d.useState(g),[k,C]=d.useState(p),[N,R]=d.useState({}),[I,L]=d.useState(null);d.useEffect(()=>{const _=fw(e.id);E.getIntegrationManifests().then(({manifests:F})=>{const K=F.find(X=>X.profile===_&&X.contextDiscovery&&Object.keys(X.contextDiscovery).length>0);L(K??null)}).catch(()=>L(null))},[e.id]);const $=Sw(y,c),T=kw(y,c==null?void 0:c.caps),O=(_,F)=>{w(K=>({...K,[_]:F}))},V=(_,F)=>{C(K=>({...K,[_]:F}))},A=()=>{const _={profile:e.id};for(const[K,X]of m)X.type==="number"?_[K]=hd(X,y[K]):_[K]=y[K];const F={};for(const[K,X]of j)X.type==="number"?F[K]=k[K]===""?0:Number(k[K]):F[K]=k[K];return[_,F]},Z=()=>{const[_,F]=A();t(_,F,N)},se=()=>{const _=(c==null?void 0:c.caps)??{},F={...y};for(const ne of T)_[ne]!==void 0&&(F[ne]=String(_[ne]));w(F);const K={profile:e.id};for(const[ne,le]of m)le.type==="number"?K[ne]=hd(le,F[ne]??""):K[ne]=F[ne]??"";const X={};for(const[ne,le]of j)le.type==="number"?X[ne]=k[ne]===""?0:Number(k[ne]):X[ne]=k[ne];t(K,X,N)},z=_=>{const F=c==null?void 0:c.caps;if(!F||F[_]===void 0)return null;const K=F[_],X=T.has(_);return $==="hard-ceiling"&&X?s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",K," — exceeds team ceiling"]}):$==="above-approvers"&&X?s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",K," — above cap"]}):s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",K," ok"]})},P=()=>{var _;if($==="no-config")return null;if($==="approvers-dormant"){const F=l&&l.length>0?l.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: ",F]}),s.jsxs("div",{children:["No caps are set on this profile, so ",F," 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($==="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($==="above-approvers"){const F=l&&l.length>0?l.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 ",F,". Within-cap actions run per the mode you choose."]})]})}if($==="hard-ceiling"){const F=Array.from(T)[0],K=F?(_=c==null?void 0:c.caps)==null?void 0:_[F]:void 0,X=u??"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 ",K??"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:se,children:"Save below cap"}),n&&s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},B=$==="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(([_,F])=>{var X;const K=!!((X=I==null?void 0:I.contextDiscovery)!=null&&X[_]);return s.jsx(yd,{fieldKey:_,fieldDef:F,value:k[_],onChange:V,prefix:"context",readOnly:r,discoveryIntegrationId:K?I.id:void 0,onLabels:(ne,le)=>R(me=>({...me,[ne]:le}))},`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(([_,F])=>{var K;return s.jsxs("div",{style:{display:"contents"},children:[s.jsx(yd,{fieldKey:_,fieldDef:F,value:y[_],onChange:O,prefix:"bounds",readOnly:r,twoColumn:!0}),$!=="no-config"&&((K=c==null?void 0:c.caps)==null?void 0:K[_])!==void 0&&s.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:z(_)})]},`bounds-${_}`)})}),P(),x.length>0&&s.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[x.join(", ")," ",x.length===1?"is":"are"," set on the integration, not here — reads are checked on this device, so the limit applies immediately and can be changed any time under"," ",s.jsx(Be,{to:"/integrations",children:"Integrations"}),"."]})]}),s.jsx("button",{className:"btn btn-primary",onClick:Z,disabled:B,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function Nw(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 Cw(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Ew="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 ti({target:e,currentText:t,onApply:n,greeting:r,placeholder:a,title:i}){const[o,c]=d.useState([{role:"assistant",content:r??Ew}]),[l,u]=d.useState(""),[f,h]=d.useState(!1),[m,x]=d.useState(null),j=d.useRef(null),v=d.useRef(null);d.useEffect(()=>{const p=j.current;if(!p)return;const y=o[o.length-1],w=v.current;!f&&(y==null?void 0:y.role)==="assistant"&&o.length>1&&w?p.scrollTop=w.offsetTop:p.scrollTop=p.scrollHeight},[o,f]);const S=async()=>{const p=l.trim();if(!p||f)return;const y=[...o,{role:"user",content:p}];c(y),u(""),x(null),h(!0);try{const w=await E.aiChat({target:e,currentText:t,messages:y.filter((k,C)=>!(C===0&&k.role==="assistant"))});w.success&&w.reply?c(k=>[...k,{role:"assistant",content:w.reply}]):x(w.error??"AI returned no reply")}catch(w){x(w instanceof Error?w.message:"Chat failed")}finally{h(!1)}},g=p=>{p.key==="Enter"&&!p.shiftKey&&!p.nativeEvent.isComposing&&(p.preventDefault(),S())};return s.jsxs("div",{className:"intent-chat",children:[s.jsx("h3",{className:"card-title",children:i??"AI Assistant"}),s.jsxs("div",{ref:j,className:"chat-messages",children:[o.map((p,y)=>{const w=p.role==="assistant"?Nw(p.content):null,k=w?Cw(p.content):p.content;return s.jsx("div",{className:`chat-msg ${p.role}`,ref:y===o.length-1?v:void 0,children:s.jsxs("div",{className:"chat-msg-body",children:[k&&s.jsx("div",{className:"chat-msg-prose",children:k}),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:l,onChange:p=>u(p.target.value),onKeyDown:g,placeholder:a??"Ask for help articulating the intent…",rows:1,disabled:f}),s.jsx("button",{type:"button",className:"chat-send-btn",onClick:S,disabled:f||!l.trim(),"aria-label":"Send",children:"↑"})]}),s.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Yh({open:e,onClose:t,children:n,ariaLabel:r}){const a=d.useRef(null),i=d.useRef(null);return d.useEffect(()=>{var c;if(!e)return;i.current=document.activeElement,document.body.style.overflow="hidden";const o=l=>{l.key==="Escape"&&t()};return document.addEventListener("keydown",o),(c=a.current)==null||c.focus(),()=>{document.removeEventListener("keydown",o),document.body.style.overflow="",i.current instanceof HTMLElement&&i.current.focus()}},[e,t]),sh.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 Tw(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Iw(e,t,n){if(t.length===0)return[{text:e,label:e,matched:null}];const r=[],a=new Set;for(const l of t)if(!(!l.scope||l.scope==="all (unscoped)"))for(const u of[l.scope,...l.scope.split(",").map(f=>f.trim())]){const f=u.toLowerCase();u&&!a.has(f)&&(a.add(f),r.push(u))}r.sort((l,u)=>u.length-l.length);const i=l=>{const u=l.toLowerCase();return t.filter(f=>{var h,m;return((h=f.scope)==null?void 0:h.toLowerCase())===u||((m=f.scope)==null?void 0:m.split(",").map(x=>x.trim().toLowerCase()).includes(u))})},o=["\\[\\d+\\]",...r.map(Tw)],c=new RegExp(`(${o.join("|")})`,"gi");return e.split(c).filter(l=>l!=="").map(l=>{const u=/^\[(\d+)\]$/.exec(l);if(u){const f=t[Number(u[1])-1];if(f){const h=f.scope&&f.scope!=="all (unscoped)"?f.scope:"all recipients",m=n?`${n}: ${h}`:h;return{text:l,label:m,matched:[f]}}}else if(r.some(f=>f.toLowerCase()===l.toLowerCase())){const f=i(l);if(f.length>0)return{text:l,label:l,matched:f}}return{text:l,label:l,matched:null}})}const vd=`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 Rw(e,t,n,r){return Iw(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 Aw(){var oe;const e=Ut(),[t]=Sc(),n=Number(t.get("step"))||2,[r,a]=d.useState(null),[i,o]=d.useState(null),[c,l]=d.useState(n),[u,f]=d.useState(null),[h,m]=d.useState(null),[x,j]=d.useState({}),[v,S]=d.useState(vd),[g,p]=d.useState(!1),[y,w]=d.useState(null),[k,C]=d.useState(!0),[N,R]=d.useState(null),[I,L]=d.useState([]),[$,T]=d.useState(void 0),[O,V]=d.useState(!1),[A,Z]=d.useState(null),[se,z]=d.useState(null),[P,B]=d.useState(null),[_,F]=d.useState([]),[K,X]=d.useState(null);d.useEffect(()=>{var ie;const G=sessionStorage.getItem("agentAuth");if(!G){e("/mandates?new=1");return}const M=JSON.parse(G);a(M),M.intentHint&&S(M.intentHint),E.getCredential("ai-config").then(ce=>w(ce.configured)).catch(()=>w(!1));const ee=sessionStorage.getItem("agentGate");if(ee){const ce=JSON.parse(ee);ce.bounds&&f(ce.bounds),ce.context&&m(ce.context),(ie=ce.gateContent)!=null&&ie.intent&&S(ce.gateContent.intent)}E.getProfile(M.profileId).then(ce=>o(ce)).catch(()=>e("/mandates?new=1")).finally(()=>C(!1)),M.groupId&&Promise.all([E.getTeamProfileConfig(M.groupId,M.profileId).catch(()=>null),E.getGroupById(M.groupId).catch(()=>null),E.listUsers().catch(()=>[])]).then(([ce,We,at])=>{if(R(ce),ce){const _e=new Map;for(const ue of at){const b=ue.name&&ue.email?`${ue.name} (${ue.email})`:ue.name||ue.email||ue.id;_e.set(ue.id,b)}const et=(We==null?void 0:We.members)??[];for(const ue of et){const b=ue.userId??ue.id;b&&(ue.name&&ue.email?_e.set(b,`${ue.name} (${ue.email})`):ue.name&&_e.set(b,ue.name))}const pt=(ce.approvers??[]).map(ue=>_e.get(ue)??ue);L(pt);const it=et.find(ue=>ue.role==="admin");if(it){const ue=it.userId??it.id;ue&&T(_e.get(ue)??it.name)}}})},[e]);const ne=u?Object.entries(u).filter(([G])=>G!=="profile"&&G!=="path").map(([G,M])=>`${G} = ${M}`).join(", "):"",le=(G,M,ee)=>{f(G),m(M),ee&&j(ee),l(3)},me=v.trim()!==vd.trim()&&v.trim()!=="",ye=G=>{me&&!confirm("Replace your current intent with the AI draft?")||S(G)},J=()=>{const G=i==null?void 0:i.ttl,M={intent:v},ee=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...ee,bounds:u,context:h,contextLabels:x,gateContent:M,ttlConfig:G})),e("/mandates/new/sign")},xe=async()=>{if(r){V(!0),Z(null),z(null),B(null),F([]),X(null);try{const G=await E.aiIntentReview({profileId:r.profileId,newIntent:v,context:h??void 0});F(G.grants??[]),G.success?G.review?Z(G.review):z(G.note??"No other mandates on this profile to compare against."):B(G.error??"Check failed.")}catch(G){B(G instanceof Error?G.message:"Check failed.")}finally{V(!1)}}},re=G=>{S(G),(A||se||P)&&(Z(null),z(null),B(null),F([]),X(null))};return k||!r||!i?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):s.jsxs(s.Fragment,{children:[s.jsx(Gh,{currentStep:c,onStepClick:G=>{G>=2&&l(G)}}),s.jsx(cw,{profileId:r.profileId,bounds:ne||void 0,groupName:r.groupName,domain:r.domain}),c===2&&s.jsx("div",{className:"card",children:s.jsx(bw,{profile:i,onConfirm:le,onCancel:()=>e("/mandates?new=1"),initialBounds:u||void 0,initialContext:h||void 0,profileConfig:N,approverNames:I,adminName:$})}),c===3&&s.jsxs("div",{className:`intent-layout${y?"":" no-chat"}`,children:[y&&s.jsx("div",{className:"card intent-pane chat tool",children:s.jsx(ti,{target:{kind:"intent",profileId:r.profileId,bounds:ne||void 0},currentText:v,onApply:ye})}),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:G=>re(G.target.value)}),s.jsxs("div",{className:"char-counter",children:[v.length," / 2000"]})]}),y===!1&&s.jsxs("p",{className:"intent-ai-hint",children:[s.jsx(Be,{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:xe,disabled:O||!me,children:O?"Checking…":"Check against my other grants"}),P&&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:P})]}),se&&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:se})]}),A&&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:Rw(A,_,X,ze(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:()=>l(2),children:"Back"}),s.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:J,disabled:!me,children:"Continue to Review"})]}),(((oe=N==null?void 0:N.approvers)==null?void 0:oe.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 ",I.length>0?I.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",I.length>0?I.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:()=>p(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),s.jsx(Yh,{open:g,onClose:()=>p(!1),ariaLabel:"Intent assistant",children:s.jsx(ti,{target:{kind:"intent",profileId:r.profileId,bounds:ne||void 0},currentText:v,onApply:G=>{ye(G),p(!1)}})})]}),K&&s.jsx("div",{className:"modal-backdrop",onClick:G=>G.target===G.currentTarget&&X(null),children:s.jsxs("div",{className:"modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:K.length>1?`Existing mandates (${K.length})`:"Existing mandate"}),s.jsx("button",{className:"modal-close",onClick:()=>X(null),children:"×"})]}),s.jsx("div",{className:"modal-body",children:K.map((G,M)=>{var ee;return s.jsxs("div",{style:{marginBottom:M<K.length-1?"1rem":0,paddingBottom:M<K.length-1?"1rem":0,borderBottom:M<K.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:G.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:((ee=G.intent)==null?void 0:ee.trim())||"(no intent recorded)"}),Object.entries(G.bounds).filter(([ie])=>ie!=="profile"&&ie!=="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(G.bounds).filter(([ie])=>ie!=="profile"&&ie!=="path").map(([ie,ce])=>`${ie}: ${ce}`).join(" · ")})]})]},M)})})]})})]})]})}function Pw(e){return e.normalize("NFC").replace(/\r\n?/g,`
70
+ `).split(`
71
+ `).map(a=>a.replace(/[ \t]+$/,"")).join(`
72
+ `).replace(/\n+$/,"")}async function _c(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 $w extends Error{constructor(n,r,a){super(a);Fr(this,"code");Fr(this,"field");this.name="CanonicalValueError",this.code=n,this.field=r}}function _w(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 Jh(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 $w(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}=${_w(o)}`)}return r.join(`
74
+ `)}async function Ea(e,t){const n=t.boundsSchema;if(!n)throw new Error("Profile has no boundsSchema");const r=Jh(e,n.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await _c(r)}`}async function Qh(e,t){const n=t.scopeSchema?Jh(e,t.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await _c(n)}`}function ul(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":ul(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)+":"+ul(a))}return"{"+n.join(",")+"}"}async function qh(e){return`sha256:${await _c(ul(e))}`}async function ni(e){const t=new TextEncoder().encode(Pw(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 Xh(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 Lw(e){const t=e.commitment_modes;return t===void 0?["review","automatic"]:Array.isArray(t)?["review","automatic"].filter(n=>t.includes(n)):[]}function zw(e){return e==="per-action"?"review":"automatic"}function xd(e){return e?Lw(e).map(t=>t==="review"?"per-action":"immediate"):["per-action","immediate"]}function Fw(e,t){return t.includes(e)?e:t[0]??null}function wd(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function Ow(e,t){for(const n of e)if(t.has(n))return!0;return!1}function Mw(e,t,n){for(const r of e){const a=wd(t[r]),i=wd(n[r]);if(!(a.size===0||i.size===0)&&!Ow(a,i))return!1}return!0}function Bw(e){return e.length>24?`${e.slice(0,10)}…`:e}function Zh(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} (${Bw(i)})`:i}).join(", ")}function ep(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:`Ask an admin of ${t} to enable ${e.profileName} and name who may give its 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}}const ri=500,Dw=["Lower the discount","Other recipient","Shorter","Different wording"];function Lc(e){const t=e.trim();return t.length===0?{valid:!1,error:"Describe what should change."}:t.length>ri?{valid:!1,error:`At most ${ri} characters (currently ${t.length}).`}:{valid:!0,trimmed:t}}function Uw(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tp(e,t){return e.toLowerCase().includes(t.toLowerCase())}function Ww(e,t){const n=e.trim();if(n.length===0)return t;if(!tp(n,t))return`${n}. ${t}`;const r=new RegExp(`\\.?\\s*${Uw(t)}\\.?`,"i");return n.replace(r,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function dl(){return{outcome:"rejected"}}function np(e){const t=Lc(e);if(!t.valid)throw new Error(t.error);return{outcome:"change_needed",note:t.trimmed}}function Hw(){return{outcome:"replaced"}}const Vw={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function Gw(e,t){const n=e.rejectedBy??e.approverRejectedBy;if(!n)return null;const r=n.outcome??"rejected",a=n.note??("reason"in n?n.reason:void 0);return{kind:Vw[r],who:n.userId===t?"You":n.userId,at:n.at,note:a}}function Kw(){var Y,ae;const e=Ut(),{user:t,mode:n,domain:r}=Ue(),[a,i]=d.useState(null),[o,c]=d.useState(null),[l,u]=d.useState(null),[f,h]=d.useState("per-action"),[m,x]=d.useState(1800),[j,v]=d.useState(86400),[S,g]=d.useState(""),[p,y]=d.useState("hours"),[w,k]=d.useState(""),[C,N]=d.useState(!0),[R,I]=d.useState(!1);d.useEffect(()=>{E.getIdentityDisclosure().then(H=>I(H.always)).catch(()=>{})},[]);const[L,$]=d.useState(!1),[T,O]=d.useState(""),[V,A]=d.useState(null),[Z,se]=d.useState([]),[z,P]=d.useState(!1),[B,_]=d.useState([]),[F,K]=d.useState(0);d.useEffect(()=>{var Rn;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),c(Ge),Ce.ttlConfig&&(x(Ce.ttlConfig.default??1800),v(Ce.ttlConfig.max??86400)),Ce.templateMode==="automatic"?h("immediate"):Ce.templateMode==="review"&&h("per-action");const In=((Rn=Ce.ttlConfig)==null?void 0:Rn.max)??86400;if(typeof Ce.templateTtl=="number"&&Ce.templateTtl>0){const Fe=Math.min(Ce.templateTtl,In);x(Fe),[3600,86400,604800,2592e3,31536e3].includes(Fe)||(Fe%86400===0?(g(String(Fe/86400)),y("days")):(g(String(Math.max(1,Math.round(Fe/3600)))),y("hours")))}E.getProfile(Pe.profileId).then(Fe=>{var gt;if(u(Fe),!w){const bt=Fe.name??((gt=Pe.profileId.split("/").pop())==null?void 0:gt.replace(/@.*$/,""))??"",ot=[];if(Ge.context&&Fe.scopeSchema)for(const te of Fe.scopeSchema.keyOrder){const q=Ge.context[te];if(q!==void 0&&q!==""){const de=String(q).split(",").map(we=>we.trim()).filter(Boolean);ot.push(de.join(", "))}}const W=ot.length>0?`${bt}: ${ot.join(" · ")}`:bt;k(W)}}).catch(()=>{}),Pe.isPersonal?P(!0):Promise.all([E.getTeamProfileConfig(Pe.groupId,Pe.profileId).catch(()=>null),E.getGroupById(Pe.groupId).catch(()=>null),E.listUsers().catch(()=>[])]).then(([Fe,gt,bt])=>{if(A(Fe),Fe){const ot=new Map;for(const q of bt){const de=q.name&&q.email?`${q.name} (${q.email})`:q.name||q.email||q.id;ot.set(q.id,de)}const W=(gt==null?void 0:gt.members)??[];for(const q of W){const de=q.userId??q.id;de&&(q.name&&q.email?ot.set(de,`${q.name} (${q.email})`):q.name&&ot.set(de,q.name))}const te=(Fe.approvers??[]).map(q=>ot.get(q)??q);se(te)}}).finally(()=>{P(!0)})},[e]),d.useEffect(()=>{if(!(a!=null&&a.profileId))return;const H=a.profileId,he=sessionStorage.getItem("agentEditReplaces");E.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]),d.useEffect(()=>{if(!l)return;const H=Fw(f,xd(l));H&&H!==f&&h(H)},[l,f]),d.useEffect(()=>{if(!o||!l||B.length===0){K(0);return}let H=!1;return(async()=>{const he=await Ea(o.bounds,l),Pe=await Promise.all(B.map(Ce=>Ea(Ce.bounds,l).catch(()=>null)));H||K(Pe.filter(Ce=>Ce===he).length)})().catch(()=>{H||K(0)}),()=>{H=!0}},[o,l,B]);const X=async()=>{if(!(!a||!o||!l||!t)){if(!a.groupId){O("No active group; cannot create mandate.");return}$(!0),O("");try{const H=r||a.domain||"owner",he=await Ea(o.bounds,l),Pe=await Qh(o.context,l),[Ce,Ge]=await Promise.all([ni(o.gateContent.intent),ni(JSON.stringify({profile:a.profileId,domain:H,group:a.groupId}))]);let In,Rn,Fe,gt;if(a.isTeam){const de=await E.getApproversPubkeys(a.groupId,a.profileId);if(de.length>0){const we=await E.encryptIntent(o.gateContent.intent,de);In=we.intentCiphertext,Rn=we.encryptedKeys,Fe=we.approversFrozen,gt=we.intentDisclosureHash}}const bt=`authz_${crypto.randomUUID()}`,ot=sessionStorage.getItem("agentEditReplaces")||void 0,W=sessionStorage.getItem("agentReplacesProposal")||void 0,te=await qh(l),q=await E.attest({authorization_id:bt,replaces:ot,profile_id:a.profileId,profile_hash:te,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:zw(f),title:w.trim(),intent_ciphertext:In,encrypted_keys:Rn,approvers_frozen:Fe,intent_disclosure_hash:gt,disclose_identity:C});try{await E.pushGateContent(Xh(q,{boundsHash:he,contextHash:Pe,context:o.context,contextLabels:o.contextLabels,gateContent:o.gateContent}))}catch(de){try{await E.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. (${de instanceof Error?de.message:"Unknown error"})`)}if(ot)try{await E.revokeAttestation(ot,`Replaced by ${bt} (edit)`),E.resyncGates().catch(()=>{})}catch{}if(W)try{await E.rejectProposal(W,Hw())}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),e(`/mandates?highlight=${encodeURIComponent(bt)}`)}catch(H){O(H instanceof Error?H.message:"Signing the mandate failed")}finally{$(!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"),le=Object.entries(o.context),ye=((V==null?void 0:V.caps)!=null?Object.keys(V.caps):[]).length!==0,J=Z.length>0?Z.join(", "):((V==null?void 0:V.approvers)??[]).join(", "),xe=ye?`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=ye?`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.`,oe=!!((Y=V==null?void 0:V.approvers)!=null&&Y.length),G=ep({isPersonal:a.isPersonal,configLoaded:z,approvers:V==null?void 0:V.approvers,userId:t==null?void 0:t.id,profileName:ze(a.profileId),teamName:a.groupName}),M=!G.can,ee=xd(l),ie=ee.length===0,ce=m>j,We={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"},at={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"},_e=((ae=l==null?void 0:l.scopeSchema)==null?void 0:ae.keyOrder)??[],et=B.filter(H=>Mw(_e,o.context,H.context)),pt=et.length>0,it=ze(a.profileId),ue=H=>{const he=Object.values(H).map(Pe=>String(Pe).trim()).filter(Boolean);return he.length>0?he.join(", "):"all (unscoped)"},b=et.map(H=>ue(H.context)).join("; "),U=`This grant's scope overlaps an existing grant on ${it} (scoped to: ${b}). 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(Gh,{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&&l&&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 ",ze(a.profileId)," ",l.version," — the current version of this profile."]})]}),T&&s.jsx("div",{className:"error-message",children:T}),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. ${ze(a.profileId)}: daily operations`,value:w,onChange:H=>k(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:[ee.includes("per-action")&&s.jsxs("button",{onClick:()=>h("per-action"),style:at,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."})]}),ee.includes("immediate")&&s.jsxs("button",{onClick:()=>h("immediate"),style:We,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."})]})]}),ee.length===1&&s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:ee[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),ie&&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=p==="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:p,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"})]})]}),ce&&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:R||C,disabled:R,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.',R&&" 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||!!le.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:[le.map(([H,he])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:H}),s.jsx("dd",{children:Zh(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:[ze(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?G.can?s.jsxs(s.Fragment,{children:[J,s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:xe})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{color:"var(--danger)",fontWeight:600},children:G.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${a.groupName??"this team"}`:"You cannot give this mandate"}),G.code==="OWNER_NOT_APPROVER"&&s.jsx("div",{children:J}),s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[G.reason," ",G.fix]})]}):s.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),F>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:[F===1?`An active grant on ${it} already has exactly these limits.`:`${F} active grants on ${it} 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:U})]})]}):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:L||!w.trim()||M||ie,children:L?"Signing...":f==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),s.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:oe?"block":"none"},children:re})]})]})}const Yw={card:"💳",mail:"✉️"};function rp(e){return Yw[e]??"🔧"}function Jw(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 Qw=[0,7,30,90,365,3650];function ca(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 qw(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 oo({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:a}){var ue;const[i,o]=d.useState({}),[c,l]=d.useState(!1),[u,f]=d.useState(!1),[h,m]=d.useState({}),[x,j]=d.useState({}),[v,S]=d.useState(void 0),[g,p]=d.useState(!1),[y,w]=d.useState(null),[k,C]=d.useState(!1),[N,R]=d.useState(!1),[I,L]=d.useState(!1),[$,T]=d.useState(!1),[O,V]=d.useState({}),[A,Z]=d.useState(null),[se,z]=d.useState(!1),[P,B]=d.useState(null),[_,F]=d.useState(!1);d.useEffect(()=>{let b=!1;return E.getCredential(e.id).then(U=>{var Y;if(!(b||!U.configured)){if(l(!0),f(!0),U.fields){const ae={};for(const H of e.credentials.fields)U.fields[H.key]!=null&&(ae[H.key]=U.fields[H.key]);m(ae)}if(j(U.secrets??{}),S(U.updatedAt),e.oauth){const ae=((Y=U.fieldNames)==null?void 0:Y.includes(e.oauth.tokenStorage))??!1;p(ae),ae&&E.getOAuthHealth(e.id).then(H=>{b||w(H)})}}}).catch(()=>{}),()=>{b=!0}},[e.id,e.oauth]);const K=Jw(e.toolGating),X=t?t.readAgeDays??null:void 0,ne=se&&A?A.value:X,le=async b=>{Z({value:b}),z(!0),B(null);try{await E.setReadPolicy(e.id,b),a(b===null?`${e.name} read window now follows your mandate`:`${e.name} read window set to ${ca(b).toLowerCase()}`),r()}catch(U){B(U instanceof Error?U.message:"Could not save")}finally{z(!1),Z(null)}},me=!!e.oauth||e.credentials.fields.some(b=>!b.optional),ye=e.oauth?g:c,J=!me||ye,xe=n==="starting"?"starting":J?t!=null&&t.running?"running":!c&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&c&&!g?"needs-oauth":"unconfigured",re=async()=>{if(e.credentials.fields.some(U=>{var Y;return(Y=i[U.key])==null?void 0:Y.trim()})){C(!0);try{await E.setCredential(e.id,i),l(!0),o({}),e.oauth?a(`${e.name} credentials saved!`):(a(`${e.name} credentials saved — starting integration...`),await ie())}catch{a(`Failed to save ${e.name} credentials`)}finally{C(!1)}}},oe=()=>{const b={};for(const U of e.credentials.fields){const Y=i[U.key];U.type==="password"?Y!=null&&Y.trim()&&(b[U.key]=Y):Y!=null&&Y!==(h[U.key]??"")&&(b[U.key]=Y)}return b},G=Object.keys(oe()).length>0,M=async()=>{const b=oe();if(Object.keys(b).length!==0){C(!0);try{await E.setCredential(e.id,b),o({}),l(!0),e.oauth?a(`${e.name} credentials saved — now click Connect.`):(T(!1),a(`${e.name} credentials updated — restarting...`),await ie())}catch{a(`Failed to update ${e.name} credentials`)}finally{C(!1)}}},ee=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const b=setInterval(async()=>{var U;try{const Y=await E.getCredential(e.id);Y.configured&&e.oauth&&((U=Y.fieldNames)!=null&&U.includes(e.oauth.tokenStorage))&&(p(!0),T(!1),w(null),clearInterval(b),a(`${e.name} connected — starting integration...`),E.getOAuthHealth(e.id).then(w).catch(()=>{}),await ie())}catch{}},2e3);setTimeout(()=>clearInterval(b),12e4)},ie=async()=>{L(!0);try{const b=await E.activateIntegration(e.id);b.warning?a(b.warning):a(`${e.name} integration started with ${b.tools.length} tools`),r()}catch(b){a(`Failed to start ${e.name}: ${b instanceof Error?b.message:"Unknown error"}`)}finally{L(!1)}},ce=async()=>{try{await E.removeMcpIntegration(e.id),a(`${e.name} integration removed`),r()}catch{a(`Failed to remove ${e.name}`)}},We=rp(e.icon),at=qw(t),_e=xe==="running"?{c:"int-chip-ok",t:"Running"}:xe==="starting"?{c:"int-chip-idle",t:"Starting"}:at.chip,et=e.oauth&&g&&(y==null?void 0:y.status)==="failed",pt=me?et?{c:"int-chip-bad",t:"Auth failed"}:ye?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},it=b=>b.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:We}),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:[xe!=="unconfigured"&&xe!=="needs-oauth"&&s.jsxs("span",{className:`int-chip ${_e.c}`,children:[s.jsx("span",{className:"int-dot"}),_e.t]}),s.jsxs("span",{className:`int-chip ${pt.c}`,children:[s.jsx("span",{className:"int-dot"}),pt.t]}),Gx(e,h)&&s.jsxs("span",{className:"int-chip int-chip-sim",title:"This connector answers from a simulated system with test data. Nothing reaches your real systems.",children:[s.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),e.oauth&&g&&s.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:y!=null&&y.account?s.jsxs(s.Fragment,{children:["Connected as ",s.jsx("b",{children:y.account})]}):s.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),et&&!$&&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:ee,children:["Reconnect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{o({...h}),T(!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:((ue=e.oauth.scopes)==null?void 0:ue.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&&(xe!=="running"||et)&&s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsxs("button",{onClick:()=>R(!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((b,U)=>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:U+1}),s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:b.title}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[it(b.description),b.link&&s.jsxs(s.Fragment,{children:[" ",s.jsxs("a",{href:b.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},U))})]}),xe==="starting"&&s.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[s.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),$&&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"}),u&&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(b=>{var U;return s.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[s.jsx("label",{className:"form-label",children:b.label}),b.type==="password"?s.jsxs("div",{className:"cred-field",children:[s.jsx("input",{className:"form-input",type:O[b.key]?"text":"password",name:`${e.id}-${b.key}-credential`,autoComplete:"new-password",placeholder:(U=x[b.key])!=null&&U.preview?`Unchanged — ends in ${x[b.key].preview}`:u?"Unchanged — paste a new value to replace":b.placeholder,value:i[b.key]||"",onChange:Y=>o(ae=>({...ae,[b.key]:Y.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>V(Y=>({...Y,[b.key]:!Y[b.key]})),children:O[b.key]?"hide":"show"})]}):s.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${b.key}-credential`,autoComplete:"off",placeholder:b.placeholder,value:i[b.key]||"",onChange:Y=>o(ae=>({...ae,[b.key]:Y.target.value}))})]},b.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:M,disabled:k||!G,children:k?"Saving…":"Save"}),!G&&!k&&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:ee,children:["Connect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{T(!1),o({})},children:"Cancel"})]})]}),!$&&xe==="running"&&t&&s.jsxs(s.Fragment,{children:[(Object.keys(h).length>0||Object.keys(x).length>0)&&s.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:e.credentials.fields.map(b=>{const U=b.type==="password",Y=x[b.key];return!U&&h[b.key]==null||U&&Y==null?null:s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[s.jsx("span",{style:{color:"var(--text-muted)"},children:b.label}),s.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[U?Y.preview??"set":h[b.key],U&&v&&s.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(v).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},b.key)})}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx(Be,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(e.credentials.fields.length>0||e.oauth)&&s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{o({...h}),T(!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:ce,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"})]}),K&&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":ca(ne).toLowerCase()}),se&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),P&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:P})]}),s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>F(!0),children:"Edit"})]})}),K&&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:()=>F(!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:[Qw.map(b=>{const U=ne===b;return s.jsx("button",{className:`btn btn-sm ${U?"btn-primary":"btn-secondary"}`,"aria-pressed":U,disabled:se,onClick:()=>le(b),children:ca(b)},b)}),s.jsx("button",{className:`btn btn-sm ${ne===null?"btn-primary":"btn-ghost"}`,"aria-pressed":ne===null,disabled:se,onClick:()=>le(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:ca(null)})]}),s.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:P?s.jsx("span",{style:{color:"var(--danger)"},children:P}):se?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(Be,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),xe==="unconfigured"&&(()=>{const b=e.credentials.fields.every(ae=>ae.optional),U=e.credentials.fields.some(ae=>!ae.optional),Y=e.credentials.fields.some(ae=>{var H;return(H=i[ae.key])==null?void 0:H.trim()});return s.jsxs(s.Fragment,{children:[u&&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:()=>{l(!0),e.oauth&&p(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!u&&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&&!u&&s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(ae=>s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsx("label",{className:"form-label",children:ae.label}),ae.type==="password"?s.jsxs("div",{className:"cred-field",children:[s.jsx("input",{className:"form-input",type:O[ae.key]?"text":"password",name:`${e.id}-${ae.key}-credential`,autoComplete:"new-password",placeholder:ae.placeholder,value:i[ae.key]||"",onChange:H=>o(he=>({...he,[ae.key]:H.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>V(H=>({...H,[ae.key]:!H[ae.key]})),children:O[ae.key]?"hide":"show"})]}):s.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${ae.key}-credential`,autoComplete:"off",placeholder:ae.placeholder,value:i[ae.key]||"",onChange:H=>o(he=>({...he,[ae.key]:H.target.value}))})]},ae.key)),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[Y&&s.jsx("button",{className:"btn btn-primary",onClick:re,disabled:k||U&&!e.credentials.fields.filter(ae=>!ae.optional).every(ae=>{var H;return(H=i[ae.key])==null?void 0:H.trim()}),children:k?"Saving...":"Save & Encrypt"}),b&&!Y&&s.jsx("button",{className:"btn btn-primary",onClick:ie,disabled:I,children:I?"Starting...":`Activate ${e.name}`})]})]})})(),xe==="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:ee,children:["Connect ",e.name," Account"]}),s.jsx("button",{className:"btn btn-ghost",onClick:()=>l(!1),children:"Change Credentials"})]})]}),xe==="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:ie,disabled:I,children:I?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&s.jsx("button",{className:"btn btn-ghost",onClick:()=>l(!1),children:"Update Credentials"}),e.oauth&&s.jsx("button",{className:"btn btn-ghost",onClick:()=>{l(!1),p(!1)},children:"Change Credentials"})]})]}),xe==="ready"&&t&&!t.running&&(at.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:ie,disabled:I,children:I?"Starting...":"Start"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:ce,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:ce,children:"Disable"})})]}))]})}function Xw(e,t){if(!t)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const n=e.filter(o=>Is(o.manifest)),r=e.filter(o=>!Is(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 Zw({entry:e}){return s.jsxs("div",{className:"int-paused-row",children:[s.jsx("span",{"aria-hidden":"true",children:rp(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 ej(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:a}=Ec(),i=Cc(),[o,c]=d.useState(""),l=d.useCallback(f=>{c(f),setTimeout(()=>c(""),5e3)},[]),u=Xw(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."})]}):u.grouped?s.jsxs(s.Fragment,{children:[u.testSystems.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"int-group-label",children:"Test systems"}),u.testSystems.map(f=>s.jsx(oo,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:l},f.id))]}),(u.realErrors.length>0||u.pausedReal.length>0)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"int-group-label",children:"Real systems"}),u.realErrors.map(f=>s.jsx(oo,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:l},f.id)),u.pausedReal.length>0&&s.jsxs("details",{className:"int-paused-group",open:!0,children:[s.jsxs("summary",{children:["Paused while simulation mode is on (",u.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"}),")."]}),u.pausedReal.map(f=>s.jsx(Zw,{entry:f},f.id))]})]}),r.length===0&&s.jsx(jd,{manifestsError:n})]}):s.jsxs(s.Fragment,{children:[r.map(f=>s.jsx(oo,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:l},f.id)),r.length===0&&s.jsx(jd,{manifestsError:n})]})]})}function jd({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 tj(){var T,O,V;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Ue(),a=Ut(),[i,o]=d.useState(null),[c,l]=d.useState(!1),[u,f]=d.useState(""),[h,m]=d.useState(""),[x,j]=d.useState(!1),[v,S]=d.useState(""),[g,p]=d.useState("");d.useEffect(()=>{fetch("/health").then(A=>A.json()).then(A=>{typeof A.spUrl=="string"&&p(A.spUrl)}).catch(()=>{})},[]),d.useEffect(()=>{if(!e){o(null);return}E.getGroupById(e.id).then(A=>{const Z=A.group??A,se=A.members??[],z=A.isAdmin??!1,P=se.map(B=>{const _=B.userId||B.id||"",F=B.role||(z&&_===Z.createdBy?"admin":"member");return{id:_,name:B.name||_.slice(0,8)||"Member",email:B.email||"",domains:B.domains||[],role:F,isAdmin:F==="admin"||z&&_===Z.createdBy}});o({id:Z.id,name:Z.name,members:P})}).catch(()=>o(null))},[e==null?void 0:e.id]);const y=(i==null?void 0:i.members.filter(A=>A.isAdmin))??[],w=(e==null?void 0:e.isAdmin)===!0&&y.length<=1&&y.some(A=>A.id===(r==null?void 0:r.id)),k=(e==null?void 0:e.name)??"",C=v.trim()===k&&!c,N=()=>{S(""),j(!0)},R=()=>{j(!1),S("")},I=async()=>{if(!(!e||!C)){l(!0),f("");try{await E.leaveTeam(e.id),await n(),m("You have left the team."),o(null),R()}catch(A){f(A instanceof Error?A.message:"Failed to leave team")}finally{l(!1)}}},L=e&&g?`${g}/dashboard/groups/${e.id}`:void 0,$=g?`${g}/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."})]})}),u&&s.jsx("div",{className:"error-message",children:u}),h&&s.jsx("div",{className:"alert alert-success",children:h}),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:[((T=i==null?void 0:i.members)==null?void 0:T.length)??0," ",(((O=i==null?void 0:i.members)==null?void 0:O.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),s.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(V=i==null?void 0:i.members)==null?void 0:V.map(A=>s.jsxs("div",{className:"member-row",children:[s.jsx("div",{className:"member-avatar",children:A.name.split(" ").map(Z=>Z[0]).join("").slice(0,2).toUpperCase()}),s.jsxs("div",{className:"member-info",children:[s.jsx("div",{className:"member-name",children:A.name}),s.jsx("div",{className:"member-email",children:A.email})]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:A.role})]},A.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:[L&&s.jsx("a",{className:"btn btn-secondary btn-sm",href:L,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),s.jsx("span",{title:w?"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:N,disabled:c||w,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. An account is Personal or in one team — joining or creating a team moves it."}),s.jsxs("div",{style:{display:"flex",gap:"0.75rem",justifyContent:"center",flexWrap:"wrap"},children:[s.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>a("/onboarding"),children:"Join or create a team"}),$&&s.jsx("a",{className:"btn btn-ghost btn-sm",href:$,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),x&&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:R,children:s.jsxs("div",{className:"card",onClick:A=>A.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 ",k,"?"]}),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:k})," to confirm:"]}),s.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:v,onChange:A=>S(A.target.value),placeholder:k,disabled:c,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:R,disabled:c,children:"Cancel"}),s.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:I,disabled:!C,children:c?"Leaving...":"Leave team"})]})]})})]})}const nj=new Set(["mail","users","receipt","credit-card","calendar","megaphone","archive","rocket","flask","shopping-cart","bar-chart","help-circle"]),rj={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 sj(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 Xn(e,t){const n=sj(e),r=t!=null&&t.icon&&nj.has(t.icon)?t.icon:rj[n]??"help-circle",a=ze(e,t==null?void 0:t.name);return{icon:r,name:a,testSetup:n==="delegation"}}function Ni(e){return e.startsWith("setup__")}const aj={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 sp({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:aj[e]})}function Ms({profileId:e,declared:t}){const{icon:n,name:r}=Xn(e,t);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"id-rail",children:[s.jsx(sp,{icon:n,className:"id-rail-icon"}),s.jsx("span",{className:"id-rail-name",children:r})]}),s.jsx("div",{className:"id-sep"})]})}const As=e=>e.replace(/@.*$/,"").split("/").pop()??e,Sd=e=>e.split("@")[1]??"";function ij(e,t){const n=new Map;for(const r of e){const a=As(r.id);if(!t.has(a))continue;const i=n.get(a);(!i||Sd(r.id).localeCompare(Sd(i.id),void 0,{numeric:!0})>0)&&n.set(a,r)}return n}function oj(e,t,n,r){var c;const a=new Set([...t.filter(l=>l.profile).map(l=>l.profile),...r.map(l=>As(l.profile))]),i=ij(e,a),o=[];for(const l of t){const u=l.profile?i.get(l.profile):void 0;u&&o.push({key:`connector:${l.id}`,name:l.name,description:l.description||u.description,profile:u,kind:"connector",ready:((c=n.find(f=>f.id===l.id))==null?void 0:c.running)===!0,setupId:l.id,...l.intentHint?{intentHint:l.intentHint}:{}})}for(const l of r){const u=i.get(As(l.profile));u&&o.push({key:`builtin:${l.id}`,name:l.name,description:l.description||u.description,profile:u,kind:"builtin",ready:l.available,unavailableReason:l.available?void 0:"Available only while simulation mode is on.",...l.intentHint?{intentHint:l.intentHint}:{}})}return o}function lj(e,t,n){if(t)return e.find(r=>As(r.profile.id)===As(t)&&r.ready&&n(r))}function cj({onDismiss:e,preselectProfileId:t}){const n=Ut(),{group:r,groupId:a,domain:i,user:o}=Ue(),[c,l]=d.useState([]),[u,f]=d.useState([]),[h,m]=d.useState([]),[x,j]=d.useState([]),[v,S]=d.useState(!0),[g,p]=d.useState({});d.useEffect(()=>{Promise.all([E.listProfiles().catch(()=>[]),E.getIntegrationManifests().then(I=>I.manifests??[]).catch(()=>[]),E.getMcpHealth().catch(()=>null)]).then(async([I,L,$])=>{if(l(I),f(L),m(($==null?void 0:$.integrations)??[]),j(($==null?void 0:$.builtins)??[]),a){const T=await Promise.all(I.map(V=>E.getTeamProfileConfig(a,V.id).catch(()=>null))),O={};I.forEach((V,A)=>{const Z=T[A];Z&&(O[V.id]=Z)}),p(O)}}).finally(()=>S(!1))},[a]);const y=oj(c,u,h,x),w=I=>{var L;return ep({isPersonal:!!(r!=null&&r.isPersonal),configLoaded:!v,approvers:(L=g[I.id])==null?void 0:L.approvers,userId:o==null?void 0:o.id,profileName:ze(I.id),teamName:r==null?void 0:r.name})},k=I=>I in g,C=(I,L)=>{if(!a){console.error("No active group when creating authorization");return}const $=k(I);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:I,groupId:a,groupName:(r==null?void 0:r.name)??null,domain:i,isTeam:$,isPersonal:!!(r!=null&&r.isPersonal),...L?{intentHint:L}:{}})),sessionStorage.removeItem("agentGate"),e==null||e(),n("/mandates/new/intent")},N=(I,L)=>{a&&C(I,L)},R=d.useRef(!1);return d.useEffect(()=>{if(v||!t||R.current)return;const I=lj(y,t,L=>w(L.profile).can);I&&(R.current=!0,N(I.profile.id,I.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(Be,{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(I=>{const L=I.profile,$=k(L.id),T=w(L),O=!I.ready||!T.can,{icon:V}=Xn(L.id,{name:L.name,icon:L.icon});return s.jsxs("div",{className:"card",style:O?{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(sp,{icon:V,className:"profile-chip-icon"}),I.name]}),$?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:I.description}),T.can?I.ready?s.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>N(L.id,I.intentHint),children:"Give a mandate"}):I.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:I.unavailableReason})]}):s.jsxs(Be,{to:`/integrations?setup=${I.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",I.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:[T.reason," ",s.jsx("span",{style:{color:"var(--text-tertiary)"},children:T.fix})]})]})]},I.key)})})]})}const uj={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function dj({status:e,label:t}){return s.jsx("span",{className:`status-badge status-${e}`,children:t||uj[e]})}function fj({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,es=3600,ua=60,mj=30*Ln;function hj(e){if(e<=0)return"Expired";if(e>90*Ln){const t=Math.floor(e/mj);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/es);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*es){const t=Math.floor(e/es),n=Math.floor(e%es/ua);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=ua){const t=Math.floor(e/ua),n=Math.floor(e%ua);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function pj({expiresAt:e}){const[t,n]=d.useState(()=>e-Date.now()/1e3),r=t<2*es;d.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:hj(t)})}function Ir({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 gj(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 yj=[{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 vj({item:e,onClose:t,onSuccess:n}){var y;const{user:r,activeDomain:a,groupId:i}=Ue(),[o,c]=d.useState(null);d.useEffect(()=>{let w=!1;return E.getProfile(e.profile_id).then(k=>{var C;w||c(((C=k==null?void 0:k.ttl)==null?void 0:C.max)??null)}).catch(()=>{}),()=>{w=!0}},[e.profile_id]);const l=e.remaining_seconds??0,u=yj.filter(w=>w.seconds>l&&(o===null||w.seconds<=o)),f=((y=u[0])==null?void 0:y.seconds)??2592e3,[h,m]=d.useState(f);d.useEffect(()=>{var w;if(o!==null&&h>o){const k=(w=u[u.length-1])==null?void 0:w.seconds;k&&m(k)}},[o]);const[x,j]=d.useState(!1),[v,S]=d.useState(""),g=Object.entries(e.frame).filter(([w])=>w!=="profile"&&w!=="path"),p=async()=>{var w;if(r){j(!0),S("");try{const k=e.authorization_id,C=await E.getGateContent(k);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 E.getProfile(e.profile_id),R=e.frame,I=C.context??{},L=e.attested_domains[0]||a||"owner",$=await Ea(R,N),T=await Qh(I,N),[O,V]=await Promise.all([ni(C.gateContent.intent),ni(JSON.stringify({profile:e.profile_id,path:e.path,domain:L}))]);if(!i)throw new Error("No active group; cannot extend mandate.");const A=(((w=e.deferred_commitment_domains)==null?void 0:w.length)??0)>0?"review":"automatic",Z=await qh(N),se=await E.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,profile_hash:Z,supported_versions:["0.7"],bounds:R,bounds_hash:$,scope_hash:T,domain:L,did:r.did,mandate_owners:[{did:r.did}],gate_content_hashes:{intent:O},execution_context_hash:V,group_id:i,commitment_mode:A,ttl:h});await E.pushGateContent(Xh(se,{boundsHash:$,contextHash:T,context:I,path:e.path,gateContent:C.gateContent})),n()}catch(k){S(k instanceof Error?k.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:[ze(e.profile_id)," / ",e.path]}),g.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:g.map(([w,k])=>`${w}=${k}`).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"}),l>0&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",gj(l),". Only longer durations are shown."]}),s.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:u.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."}):u.map(w=>s.jsx("button",{className:`btn ${h===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:p,disabled:x,children:x?"Extending...":"Extend"})]})]})})}function kd(e){return e.replace(/@.*$/,"").split("/").pop()??e}function bd(e){return e.split("@")[1]??""}function xj(e,t){return bd(e).localeCompare(bd(t),void 0,{numeric:!0})>0}function ap(e,t){const n=kd(e);let r;for(const a of t)kd(a.id)===n&&(!r||xj(a.id,r.id))&&(r=a);return r}function ip(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 op(e,t){return ip(e,t.boundsSchema)}function lp(e,t){return ip(e,t.scopeSchema)}function wj(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=ei(r,t),o=ei(a,t),c={active:0,pending:1,expired:2,revoked:3,archived:4};return c[i]!==c[o]?c[i]-c[o]:new Date(a.created_at).getTime()-new Date(r.created_at).getTime()})}function jj({item:e,newerProfile:t,revokedSet:n,expandedHash:r,gateCache:a,gateLoading:i,copiedHash:o,revokingHash:c,copyingHash:l,profileConfigCache:u,mode:f,ownerLabel:h,isAdmin:m,onExpand:x,onCopyHash:j,onCopy:v,onRevoke:S,onExtend:g,archivedSet:p,archivingHash:y,onArchive:w,highlightHash:k,needsReapprovalSet:C}){var xe;const N=Nc(e,{revokedSet:n}),R=N==="active"&&((C==null?void 0:C.has(e.authorization_id))??!1),I=Ah(e,{revokedSet:n,archivedSet:p}),L=!h&&!!w&&Rh(N),$=r===e.authorization_id,T=a[e.authorization_id],O=N==="active"||N==="pending"||N==="expired",V=Object.entries(e.frame).filter(([re])=>re!=="profile"&&re!=="path"),A=u.get(e.profile_id)??null,Z=(((xe=A==null?void 0:A.approvers)==null?void 0:xe.length)??0)>0,se=new Map;if(A!=null&&A.caps&&f==="team")for(const[re,oe]of V){const G=A.caps[re];G!==void 0&&Number(oe)>G&&se.set(re,{authorized:Number(oe),cap:G})}const z=se.size>0,P=e.approvers_frozen??[],B=(A==null?void 0:A.approvers)??[],_=f==="team"&&P.length>0&&B.length>0&&(P.length!==B.length||P.some(re=>!B.includes(re))||B.some(re=>!P.includes(re))),F=Array.from(se.entries()).map(([re,oe])=>`${re}: ${oe.authorized} (cap ${oe.cap})`).join(", "),K=Array.from(se.entries()).map(([re,oe])=>`${re}: ${oe.authorized} → ${oe.cap}`).join(", "),X=z?Z?se.size===1?`Above team cap: ${F} — actions require approval`:`Above team cap (${se.size}): ${F} — actions require approval`:se.size===1?`Reduced by hard cap: ${K}`:`Reduced by hard cap (${se.size}): ${K}`:"",ne=z?Z?"Above-cap actions under this mandate require per-action approval from the profile's approvers. Bounds remain authorized at their original values.":"No approvers are configured for this profile, so the team cap is a hard ceiling. Bounds above the cap are effectively reduced to the cap. Ask the admin to raise the cap or add approvers, or copy this mandate to reissue within the cap.":void 0,le=Xn(e.profile_id),me=le.name,ye=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:[me,"@",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=k!=null&&e.authorization_id===k;return s.jsxs("div",{className:`card id-card${J?" card-highlight":""}`,style:{marginBottom:0},children:[s.jsx(Ms,{profileId:e.profile_id}),s.jsxs("div",{className:"id-body",children:[ye,h&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",s.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:h})]}),s.jsxs("div",{className:"auth-card-header",children:[s.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:e.title||me}),s.jsx(dj,{status:N}),R&&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"}),le.testSetup&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),N==="active"&&e.earliest_expiry&&s.jsx(pj,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),N==="expired"&&(()=>{const re=Vx(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(fj,{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:Z?"var(--accent-subtle)":"var(--danger-subtle)",color:Z?"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:l===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:l===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),V.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:V.map(([re,oe],G)=>{const M=se.get(re);return s.jsxs("span",{children:[G>0&&" · ",M?Z?s.jsxs("span",{title:`Team cap on ${re} is ${M.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${M.authorized}.`,children:[s.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[re,"=",String(oe)]}),s.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",M.cap]})]}):s.jsxs("span",{title:`Team cap on ${re} is ${M.cap} with no approvers configured (hard cap). Authorized for ${M.authorized}; effective ${M.cap}.`,children:[s.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[re,"=",String(oe)]}),s.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",M.cap]})]}):s.jsxs("span",{children:[re,"=",String(oe)]})]},re)})}),s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[L&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>w(e.authorization_id,!I),disabled:y===e.authorization_id,title:I?"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?I?"Unarchiving…":"Archiving…":I?"↩ Unarchive":"⊟ Archive"}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>x(e),children:$?"▲ Hide Details":"▼ Details"})]}),$&&s.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[V.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:V.map(([re,oe])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:re}),s.jsx("dd",{children:String(oe)})]},re))})]}),(T==null?void 0:T.context)&&Object.keys(T.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(T.context).map(([re,oe])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:re}),s.jsx("dd",{title:String(oe),children:Zh(re,oe,T.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..."}):T?s.jsx("div",{className:"gate-content-block",children:s.jsx("div",{className:"gate-content-item",children:s.jsx("div",{className:"gate-content-text",children:T.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:[!h&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>v(e),disabled:l===e.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:l===e.authorization_id?"Copying…":"⧉ Copy"}),!h&&(N==="active"||N==="pending")&&s.jsx("button",{className:R?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>v(e,{asEdit:!0}),disabled:l===e.authorization_id,title:R?"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:R?"⚠ Re-approve":"✎ Edit"}),!h&&O&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>g(e),children:"↻ Extend"}),h&&m&&N!=="revoked"?s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>S(e.authorization_id,h,me),disabled:c===e.authorization_id,children:c===e.authorization_id?"Revoking…":"Revoke"}):!h&&(N==="active"||N==="pending")?s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>S(e.authorization_id),disabled:c===e.authorization_id,children:c===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]})]},e.authorization_id)}function Sj(){const[e,t]=d.useState([]),[n,r]=d.useState(!0),[a,i]=d.useState([]),[o,c]=d.useState(!1),[l,u]=d.useState(new Map),[f,h]=d.useState("mine"),[m,x]=d.useState("active"),[j,v]=d.useState(null),[S,g]=d.useState(null),[p,y]=Sc(),[w,k]=d.useState(()=>p.get("new")==="1"),[C]=d.useState(()=>p.get("profile")),[N,R]=d.useState(()=>p.get("highlight")),[I,L]=d.useState(null),[$,T]=d.useState({}),[O,V]=d.useState(null),[A,Z]=d.useState(null),[se,z]=d.useState(null),[P,B]=d.useState(new Set),[_,F]=d.useState(null),[K,X]=d.useState(new Set),[ne,le]=d.useState(null),[me,ye]=d.useState(null),[J,xe]=d.useState(new Set),re=Ut(),{group:oe,groupId:G,domain:M,mode:ee,activeTeam:ie}=Ue(),ce=(ie==null?void 0:ie.isAdmin)===!0,[We,at]=d.useState(()=>new Map),_e=d.useCallback(()=>{r(!0),E.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),et=d.useCallback(()=>{E.getArchivedMandates().then(W=>X(new Set(W))).catch(()=>{})},[]);d.useEffect(()=>{et()},[et]);const pt=d.useCallback(()=>{E.getEnrichedAuthorizations().then(W=>xe(new Set(W.filter(te=>te.needsReapproval).map(te=>te.authorizationId)))).catch(()=>{})},[]);d.useEffect(()=>{pt()},[pt]);const it=async(W,te)=>{le(W);try{const q=await E.setMandateArchived(W,te);X(new Set(q)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(q){alert(q instanceof Error?q.message:"Failed to update archive")}finally{le(null)}},ue=d.useCallback(()=>{G&&(c(!0),E.listTeamAuthorizations(G).then(i).catch(()=>{}).finally(()=>c(!1)))},[G]);ve("attestation-changed",()=>{_e(),ce&&G&&ue(),pt()}),d.useEffect(()=>{if(!N)return;p.get("highlight")&&(p.delete("highlight"),y(p,{replace:!0}));const W=window.setTimeout(()=>R(null),3e3);return()=>window.clearTimeout(W)},[]),Tt(_e,3e5),d.useEffect(()=>{f==="team"&&ce&&G&&a.length===0&&!o&&ue()},[f,ce,G,a.length,o,ue]),d.useEffect(()=>{let W=!1;return E.listProfiles().then(te=>{if(W)return;const q=lt=>lt.replace(/@.*$/,"").split("/").pop()??lt,de=lt=>lt.split("@")[1]??"",we=new Map;for(const lt of te){const Wt=q(lt.id),Ds=we.get(Wt);(!Ds||de(lt.id).localeCompare(de(Ds.id),void 0,{numeric:!0})>0)&&we.set(Wt,lt)}u(we)}).catch(()=>{}),()=>{W=!0}},[]);const b=d.useCallback(W=>{const te=Wt=>Wt.replace(/@.*$/,"").split("/").pop()??Wt,q=Wt=>Wt.split("@")[1]??"",de=l.get(te(W));if(!de)return;const we=q(W),lt=q(de.id);if(!(!we||!lt))return lt.localeCompare(we,void 0,{numeric:!0})>0?de:void 0},[l]);d.useEffect(()=>{if(ee!=="team"||!G)return;const W=f==="mine"?e:a;if(W.length===0)return;const te=[...new Set(W.map(q=>q.profile_id))].filter(q=>!We.has(q));if(te.length!==0){at(q=>{const de=new Map(q);for(const we of te)de.set(we,null);return de});for(const q of te)E.getTeamProfileConfig(G,q).then(de=>{at(we=>new Map(we).set(q,de))}).catch(()=>{})}},[e,a,f,G,ee,We]);const U=async W=>{if(I===W.authorization_id){L(null);return}L(W.authorization_id);const te=W.authorization_id;if(!(te in $)){V(W.authorization_id);try{const q=await E.getGateContent(te);T(de=>({...de,[te]:q}))}catch{T(q=>({...q,[te]:null}))}finally{V(null)}}},Y=W=>{navigator.clipboard.writeText(W).then(()=>{z(W),setTimeout(()=>z(null),2e3)})},ae=async(W,te)=>{var q;if(!G){alert("No active group; cannot copy mandate.");return}ye(W.authorization_id);try{const de=W.authorization_id;let we=$[de]??null;de in $||(we=await E.getGateContent(de),T(An=>({...An,[de]:we})));const lt=Object.fromEntries(Object.entries(W.frame).filter(([An])=>An!=="profile"&&An!=="path")),Wt=(we==null?void 0:we.context)??{},Ds=((q=we==null?void 0:we.gateContent)==null?void 0:q.intent)??"",xp=W.deferred_commitment_domains.length>0?"review":"automatic",wp=W.attested_domains[0]||M||"owner",Ci=Date.parse(W.created_at),Ei=W.earliest_expiry?Date.parse(W.earliest_expiry):NaN,jp=Number.isFinite(Ci)&&Number.isFinite(Ei)&&Ei>Ci?Math.round((Ei-Ci)/1e3):void 0;let Oc=W.profile_id,Mc=lt,Bc=Wt,Dc;const Sp=await E.listProfiles(),Us=ap(W.profile_id,Sp);if(Us&&Us.id!==W.profile_id){const An=await E.getProfile(Us.id);Oc=Us.id,Mc=op(lt,An),Bc=lp(Wt,An),Dc=W.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Oc,groupId:G,groupName:(oe==null?void 0:oe.name)??null,domain:wp,isPersonal:!!(oe!=null&&oe.isPersonal),upgradedFromProfileId:Dc})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:Mc,context:Bc,gateContent:{intent:Ds},templateMode:xp,templateTtl:jp})),te!=null&&te.asEdit?sessionStorage.setItem("agentEditReplaces",W.authorization_id):sessionStorage.removeItem("agentEditReplaces"),re("/mandates/new/intent")}catch(de){alert(de instanceof Error?de.message:"Failed to copy mandate")}finally{ye(null)}},H=async(W,te,q)=>{const de=te&&q?`Revoke ${te}'s ${q} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(de)){F(W);try{await E.revokeAttestation(W),B(we=>new Set(we).add(W)),E.resyncGates().catch(()=>{}),te&&G&&ue()}catch(we){alert(we instanceof Error?we.message:"Failed to revoke mandate")}finally{F(null)}}},he=f==="mine"?e:a,Pe=f==="mine"?n:o,Ce=f==="mine"?{revokedSet:P,archivedSet:K}:{revokedSet:P},Ge=W=>ei(W,Ce),In={active:0,pending:0,expired:0,revoked:0,archived:0};for(const W of he)In[Ge(W)]+=1;const Rn=f==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],Fe=(()=>{const W=new Map;for(const te of he){if(Ge(te)!==m)continue;const q=W.get(te.profile_id)??{count:0,review:!1};q.count+=1,te.deferred_commitment_domains.length>0&&(q.review=!0),W.set(te.profile_id,q)}return Array.from(W.entries()).map(([te,q])=>({profileId:te,...q})).sort((te,q)=>ze(te.profileId).localeCompare(ze(q.profileId)))})(),gt=wj(he.filter(W=>{if(Ge(W)!==m||j!==null&&W.profile_id!==j)return!1;if(S!==null){const te=W.deferred_commitment_domains.length>0;if(S==="review"&&!te||S==="auto"&&te)return!1}return!0}),Ce,N),bt={revokedSet:P,expandedHash:I,gateCache:$,gateLoading:O,copiedHash:se,revokingHash:_,copyingHash:me,profileConfigCache:We,mode:ee,activeDomain:M,group:oe,groupId:G,onExpand:U,onCopyHash:Y,onCopy:ae,onRevoke:H,onExtend:Z,highlightHash:N},ot={...bt,archivedSet:K,archivingHash:ne,onArchive:it,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:()=>k(!0),children:"+ New mandate"})]}),w&&s.jsx("div",{className:"modal-backdrop",onClick:()=>{k(!1),(p.get("new")||p.get("profile"))&&(p.delete("new"),p.delete("profile"),y(p,{replace:!0}))},children:s.jsxs("div",{className:"modal",onClick:W=>W.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:()=>{k(!1),(p.get("new")||p.get("profile"))&&(p.delete("new"),p.delete("profile"),y(p,{replace:!0}))},children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem",marginTop:0,marginBottom:"1rem"},children:"What should your agent be able to do? Pick a profile, set limits, then authorize."}),s.jsx(cj,{onDismiss:()=>k(!1),preselectProfileId:C})]})]})}),ce&&s.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[s.jsx("button",{className:`nav-tab${f==="mine"?" active":""}`,onClick:()=>{h("mine"),x("active"),v(null),g(null),L(null)},children:"Mine"}),s.jsx("button",{className:`nav-tab${f==="team"?" active":""}`,onClick:()=>{h("team"),x("active"),v(null),g(null),L(null)},children:"Team"})]}),s.jsx("div",{className:"nav-tabs",children:Rn.map(W=>s.jsxs("button",{className:`nav-tab${m===W?" active":""}`,onClick:()=>{x(W),v(null),g(null)},children:[W.charAt(0).toUpperCase()+W.slice(1)," (",In[W],")"]},W))}),Fe.length>0&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[Fe.map(W=>{const te=j===W.profileId;return s.jsx("button",{className:`btn btn-sm ${te?"btn-primary":"btn-secondary"}`,onClick:()=>v(te?null:W.profileId),children:ze(W.profileId)},W.profileId)}),s.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(W=>{const te=S===W;return s.jsx("button",{className:`btn btn-sm ${te?"btn-primary":"btn-secondary"}`,onClick:()=>g(te?null:W),children:W==="auto"?"Auto":"Review"},W)})]}),Pe&&he.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):gt.length===0?s.jsx(Ir,{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:gt.map(W=>{const te=f==="team"?W:null,q=te!=null&&te.owner?te.owner.name??te.owner.email??te.owner.userId:void 0;return s.jsx(jj,{item:W,newerProfile:b(W.profile_id),ownerLabel:q,isAdmin:ce,...f==="mine"?ot:bt},W.authorization_id)})}),A&&s.jsx(vj,{item:A,onClose:()=>Z(null),onSuccess:()=>{Z(null),_e()}})]})}const kj=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function zr(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 zc(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function bj(e){const{integrationId:t,toolName:n}=zc(e);return t?`${t} · ${n}`:n}function cp(e,t){const n=t==null?void 0:t.find(r=>r.id===e);return n!=null&&n.name?n.name:e?e.toUpperCase():"the system"}function Nj(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
80
+ `)||e.length>120)?"markdown":"text"}function Cj(e,t){var o,c;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 l of a){if(!(l in e)||kj.has(l))continue;const u=e[l],f=n[l]??{},h=f.kind??Nj(u),m={key:l,label:f.label??zr(l),kind:h,value:u,hint:(c=r[l])==null?void 0:c.description};h==="money"&&f.currencyArg&&typeof e[f.currencyArg]=="string"&&(m.currency=e[f.currencyArg]),h==="profile"&&typeof u=="string"&&(m.profileRef=u),(h==="profile-limits"||h==="profile-scope")&&f.profileArg&&typeof e[f.profileArg]=="string"&&(m.profileRef=e[f.profileArg]),i.push(m)}return i}function up(e,t){var r,a;const n=(a=(r=t==null?void 0:t.scopeSchema)==null?void 0:r.fields)==null?void 0:a[e];return n?{label:n.displayName??e,hint:n.description}:{label:e}}function Ej(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 c of i){if(c==="profile"||!(c in e))continue;const l=e[c],u=a[c],f=$c(u==null?void 0:u.unit),h=Array.isArray(l)?l.join(", "):String(l);o.push({key:c,label:(u==null?void 0:u.displayName)??zr(c),value:f?`${h} ${f}`:h,hint:u==null?void 0:u.description,unknown:t?!u:void 0})}return o}function Tj(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function Ij(e,t){var l,u,f;const{integrationId:n,toolName:r}=Tj(e.action),a=t.find(h=>h.id===n),i=(u=(l=a==null?void 0:a.toolGating)==null?void 0:l.overrides)==null?void 0:u[r];if(i!=null&&i.actionLabel)return i.actionLabel;const o=ze(e.profileId),c=(f=e.executionContext)==null?void 0:f.action_type;return typeof c=="string"&&c?`${o} · ${c}`:`${o} · ${r}`}function Rj(e,t){var a;const n=(a=t==null?void 0:t.scopeSchema)==null?void 0:a.fields;if(!n)return"";const r=[];for(const[i,o]of Object.entries(e.executionContext??{})){if(!(i in n))continue;const c=String(o??"").trim();c&&r.push(c.split(",").map(l=>l.trim()).filter(Boolean).join(", "))}return r.join(" · ")}function Aj(e,t){var a,i;if(!e)return"";const n=((a=t==null?void 0:t.scopeSchema)==null?void 0:a.fields)??{},r=[];for(const[o,c]of Object.entries(e)){if(o==="action_type")continue;const l=String(c??"").trim();if(!l)continue;const u=((i=n[o])==null?void 0:i.displayName)??o;r.push(`${u} ${l.split(",").map(f=>f.trim()).filter(Boolean).join(", ")}`)}return r.join(" · ")}function Nd(e){return e.appliesTo}function Pj(e,t,n){var c,l,u,f;const r=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],a=e.actionType??(typeof((c=e.executionContext)==null?void 0:c.action_type)=="string"?e.executionContext.action_type:void 0),i=(l=n==null?void 0:n.boundsSchema)==null?void 0:l.fields,o=[];for(const{window:h,label:m}of r){const x=(u=e.cumulativeState)==null?void 0:u[h];if(!x)continue;let j;if(i&&t){const g=Object.entries(i).filter(([w,k])=>{if(!(w in t))return!1;const C=k.boundType;if(!C||C.kind!=="cumulative_sum"&&C.kind!=="cumulative_count"||C.window!==h)return!1;const N=Nd(k);return!N||!a||N.includes(a)}),y=(a?g.find(([,w])=>{var k;return(k=Nd(w))==null?void 0:k.includes(a)}):void 0)??(g.length===1?g[0]:void 0);y&&(j={key:y[0],isAmount:((f=y[1].boundType)==null?void 0:f.kind)==="cumulative_sum"})}const v=j?j.isAmount?x.amount:x.count:void 0,S=j?Number(t==null?void 0:t[j.key]):NaN;j&&Number.isFinite(S)?o.push(`${v} of ${S} ${m}`):o.push(`${x.count} ${x.count===1?"call":"calls"} ${m}`)}return o.join(" · ")}function $j(e,t,n){var i;const r=(i=n==null?void 0:n.boundsSchema)==null?void 0:i.fields;if(!e||!t||!r)return[];const a=[];for(const[o,c]of Object.entries(r)){const l=c.boundType;if(!l||l.kind!=="per_transaction")continue;const u=l.of;if(!(u in e)||!(o in t))continue;const f=Number(e[u]),h=Number(t[o]);if(!Number.isFinite(f)||!Number.isFinite(h))continue;const m=$c(c.unit),x=c.displayName??zr(u),j=v=>m?`${v.toLocaleString()} ${m}`:v.toLocaleString();a.push({key:o,label:x,ok:f<=h,valueText:j(f),limitText:j(h)})}return a}function _j(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function Lj(e){const t=ze(e),n=e.split("@")[1];return n?`${t}@${n}`:t}const Cd=new Map;function zj(e){let t=Cd.get(e);return t||(t=(async()=>{try{let n=e;if(!e.includes("@")){const r=await E.listProfiles(),a=o=>o.replace(/@.*$/,"").split("/").pop(),i=r.filter(o=>a(o.id)===e).sort((o,c)=>(c.id.split("@")[1]??"").localeCompare(o.id.split("@")[1]??"",void 0,{numeric:!0}));if(!i[0])return null;n=i[0].id}return await E.getProfile(n)}catch{return null}})(),Cd.set(e,t)),t}function Bs(e){const[t,n]=d.useState(null);return d.useEffect(()=>{let r=!0;return e&&zj(e).then(a=>{r&&n(a)}),()=>{r=!1}},[e]),t}async function Ed(e){const t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(r=>r.toString(16).padStart(2,"0")).join("")}function Fj(e){return e.normalize("NFC").replace(/\r\n?/g,`
81
+ `).split(`
82
+ `).map(a=>a.replace(/[ \t]+$/,"")).join(`
83
+ `).replace(/\n+$/,"")}function fl(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":fl(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)+":"+fl(a))}return"{"+n.join(",")+"}"}async function Oj(e,t){if(e==="jcs"){if(typeof t=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await Ed(fl(t))}`}if(typeof t!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await Ed(Fj(t))}`}function zn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Jt(e,t=!1){return e==null?"—":typeof e=="string"?e:typeof e=="boolean"?String(e):typeof e=="number"?t||Number.isInteger(e)?String(e):String(Math.round(e*100)/100):"—"}function Mj(e){return e==null?!1:typeof e=="string"||Array.isArray(e)?e.length>0:!0}function ts(e,t,n){const r=t?Object.keys(t).filter(a=>a in e):Object.keys(e);return r.length===0?"—":r.map(a=>{var l,u;const i=e[a],o=((l=t==null?void 0:t[a])==null?void 0:l.title)??zr(a),c=zn(i)?ts(i,(u=t==null?void 0:t[a])==null?void 0:u.properties,n):Jt(i,n);return`${o}: ${c}`}).join(" · ")}function Bj(e){return e.split(`
84
+ `).map(t=>t.startsWith("+")&&!t.startsWith("+++")?{text:t,kind:"add"}:t.startsWith("-")&&!t.startsWith("---")?{text:t,kind:"remove"}:{text:t,kind:"context"})}function Dj(e,t){var a;if(Array.isArray(e)){if(e.length===0)return{value:"—"};if(e.every(u=>!zn(u)&&!Array.isArray(u))){if(e.every(h=>typeof h=="string"))return{lines:e};const u=e.map(h=>Jt(h)).join(", "),f=e.map(h=>Jt(h,!0)).join(", ");return f===u?{value:u}:{value:u,valueTitle:f}}const i=(a=t==null?void 0:t.items)==null?void 0:a.properties,o=e.map(u=>zn(u)?ts(u,i,!1):Jt(u)),c=e.map(u=>zn(u)?ts(u,i,!0):Jt(u,!0)),l=o.map((u,f)=>u===c[f]?void 0:c[f]);return l.some(u=>u!==void 0)?{lines:o,lineTitles:l}:{lines:o}}if(zn(e)){const i=t==null?void 0:t.properties,o=i?Object.keys(i).filter(u=>u in e):Object.keys(e);if(o.length>0&&o.every(u=>!zn(e[u])&&!Array.isArray(e[u])))return{sublist:o.map(f=>{var v;const h=e[f],m=((v=i==null?void 0:i[f])==null?void 0:v.title)??zr(f),x=Jt(h),j=Jt(h,!0);return j===x?{key:f,label:m,value:x}:{key:f,label:m,value:x,valueTitle:j}})};const c=ts(e,i,!1),l=ts(e,i,!0);return l===c?{value:c}:{value:c,valueTitle:l}}if(typeof e=="string"&&(t==null?void 0:t.contentMediaType)==="text/x-diff")return{diffLines:Bj(e)};const n=Jt(e),r=Jt(e,!0);return r===n?{value:n}:{value:n,valueTitle:r}}function Uj(e){let t;try{t=JSON.parse(e)}catch{return null}return zn(t)?t:null}function si(e){const t=e!=null&&e.structured&&Object.keys(e.structured).length>0?e.structured:void 0;if(t)return{obj:t,schema:e==null?void 0:e.outputSchema};const n=e!=null&&e.text?Uj(e.text):null;return n?{obj:n}:null}function ml(e){const t=si(e);if(!t)return[];const{obj:n,schema:r}=t,a=(r==null?void 0:r.properties)??{},i=[...new Set([...Object.keys(a),...Object.keys(n)])],o=[];for(const c of i){if(!(c in n))continue;const l=a[c],u=(l==null?void 0:l.title)??zr(c),f={key:c,label:u,...Dj(n[c],l)};l!=null&&l.description&&(f.description=l.description),o.push(f)}return o}function hl(e,t){const n=si(e);if(n){const a=ml(e),i=t==null?void 0:t.fields;let o;if(i&&i.length>0){const u=new Map(a.map(f=>[f.key,f]));o=i.map(f=>u.get(f)).filter(f=>f!==void 0)}else o=a.filter(u=>Mj(n.obj[u.key]));const c=new Set(o.map(u=>u.key)),l=a.filter(u=>!c.has(u.key));return{kind:"structured",fields:o,moreFields:l,totalFields:a.length}}const r=e==null?void 0:e.text;return r&&r.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:r}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function Td(e){return e?e.lines?`lines:${JSON.stringify(e.lines)}`:e.sublist?`sublist:${JSON.stringify(e.sublist.map(t=>[t.key,t.value]))}`:e.diffLines?`diffLines:${JSON.stringify(e.diffLines)}`:`value:${e.value??""}`:""}function da(e){return{kind:e.length>0?"structured":"empty",fields:e,moreFields:[],totalFields:e.length}}function Wj(e,t,n){const r=si(e),a=si(t);if(!r&&!a){const m=(e==null?void 0:e.text)??"",x=(t==null?void 0:t.text)??"";return m===x?{approved:da([]),current:da([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:m},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:x},unchanged:!1}}const i=new Map(ml(e).map(m=>[m.key,m])),o=new Map(ml(t).map(m=>[m.key,m])),l=[...new Set([...i.keys(),...o.keys()])].filter(m=>m===(n==null?void 0:n.excludeKey)?!1:Td(i.get(m))!==Td(o.get(m))),u=n!=null&&n.fields&&n.fields.length>0?[...n.fields.filter(m=>l.includes(m)),...l.filter(m=>!n.fields.includes(m))]:l,f=u.map(m=>i.get(m)).filter(m=>m!==void 0),h=u.map(m=>o.get(m)).filter(m=>m!==void 0);return{approved:da(f),current:da(h),unchanged:l.length===0}}function Hj(e){return e.offDevice?"off-device":e.boundContent===void 0?"none":e.hasHashToCheck?e.hashVerified===!0?"verified":"mismatch":"unchecked"}function Vj(e,t){return e===void 0?{kind:"empty",fields:[],moreFields:[],totalFields:0}:typeof e=="string"?hl({text:e}):hl({structured:e},{fields:t})}function Gj(e,t){return e?Object.entries(e).filter(([,n])=>n!=null&&n!=="").map(([n,r])=>({key:n,label:up(n,t).label,value:String(r)})):[]}function Kj({row:e}){return s.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[e.label,e.description&&s.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:e.description})]})}function Yj({row:e}){return e.sublist?s.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:e.sublist.map(t=>s.jsxs(d.Fragment,{children:[s.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:t.label}),s.jsx("dd",{style:{margin:0,wordBreak:"break-word"},title:t.valueTitle,children:t.value})]},t.key))}):e.diffLines?s.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:e.diffLines.map((t,n)=>s.jsx("div",{style:t.kind==="remove"?{color:"var(--danger)",textDecoration:"line-through"}:t.kind==="add"?{color:"var(--success)"}:void 0,children:t.text||" "},n))}):e.lines?s.jsx("div",{children:e.lines.map((t,n)=>{var r;return s.jsx("div",{title:(r=e.lineTitles)==null?void 0:r[n],children:t},n)})}):s.jsx("span",{title:e.valueTitle,children:e.value})}function Id({rows:e}){return s.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.map(t=>s.jsxs(d.Fragment,{children:[s.jsx(Kj,{row:t}),s.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:s.jsx(Yj,{row:t})})]},t.key))})}function Ta({rendered:e}){return e.kind==="empty"?s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):e.kind==="text"?s.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.text}):s.jsxs(s.Fragment,{children:[s.jsx(Id,{rows:e.fields}),e.moreFields.length>0&&s.jsxs("details",{style:{fontSize:"0.8rem"},children:[s.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",e.totalFields,")"]}),s.jsx(Id,{rows:e.moreFields})]})]})}function dp({receipt:e,profile:t}){var m;const[n,r]=d.useState(void 0),[a,i]=d.useState(null),o=!!(e.contentHash&&e.contentBinding);if(d.useEffect(()=>{let x=!0;return r(void 0),i(null),(async()=>{let j;try{j=await E.getArchivedReceipt(e.id)}catch{x&&r(null);return}let v=null;const S=j==null?void 0:j.entry.boundContent;if(S!==void 0&&o)try{v=await Oj(e.contentBinding.kind,S)===e.contentHash}catch{v=!1}x&&(i(v),r(j))})(),()=>{x=!1}},[e.id,e.contentHash,e.contentBinding,o]),n===void 0)return s.jsx("div",{className:"ticket-done-box ticket-done-loading","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const c=n===null,l=n==null?void 0:n.entry.boundContent,u=Hj({offDevice:c,boundContent:l,hasHashToCheck:o,hashVerified:a});if(u==="off-device")return s.jsx("div",{className:"ticket-done-box ticket-done-off-device","data-testid":"ticket-what-was-done","data-bound":"off-device",children:s.jsx("p",{className:"ticket-done-note",children:"Content not on this device — only the signed values are shown."})});if(u==="none"){const x=Gj(e.executionContext,t);return s.jsxs("div",{className:"ticket-done-box","data-testid":"ticket-what-was-done","data-bound":"none",children:[s.jsx("h4",{children:"What was done"}),x.length>0?s.jsx("dl",{className:"ticket-done-fields",children:x.map(j=>s.jsxs("div",{className:"ticket-done-field-row",children:[s.jsx("dt",{children:j.label}),s.jsx("dd",{children:j.value})]},j.key))}):s.jsx("p",{className:"ticket-done-note",children:"No checked values recorded for this action."})]})}const f=Vj(l,(m=e.contentBinding)==null?void 0:m.fields),h=u==="verified"?"ticket-done-verified":u==="mismatch"?"ticket-done-mismatch":"ticket-done-unchecked";return s.jsxs("div",{className:`ticket-done-box ${h}`,"data-testid":"ticket-what-was-done","data-bound":u,children:[s.jsxs("h4",{children:["What was done",u!=="unchecked"&&s.jsxs(s.Fragment,{children:[" ",s.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]})]}),s.jsx(Ta,{rendered:f}),u==="verified"&&s.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ This exact content is bound by hash — any change after the fact would break the ticket."}),u==="mismatch"&&s.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This content does NOT match the ticket's signed hash — it may have been altered since archiving."}),u==="unchecked"&&s.jsx("p",{className:"ticket-done-note ticket-done-note-neutral",children:"This content is kept on this device, but the ticket carries no content hash — it cannot be checked against the ticket."})]})}function Kr({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 Jj({receipt:e,manifests:t,localAuth:n,localUnavailable:r,signature:a,grantTitle:i,ownerLabel:o,spUrl:c,formatDate:l,onOpenComplete:u}){var p;const f=Bs(e.profileId),h=Rj(e,f),m=Aj(n==null?void 0:n.context,f),x=Pj(e,(n==null?void 0:n.bounds)??e.limits,f),j=n==null?void 0:n.intent,v=Xn(e.profileId).testSetup||Ni(e.action),[S,g]=d.useState(!1);return s.jsxs("div",{className:"card id-card",style:{marginBottom:0},children:[s.jsx(Ms,{profileId:e.profileId}),s.jsxs("div",{className:"id-body",children:[s.jsxs("div",{className:"receipt-head",children:[s.jsx("span",{className:"receipt-what",children:Ij(e,t)}),s.jsx("span",{className:"receipt-tag",children:_j(e)?"review":"automatic"}),e.contentHash&&s.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(p=e.contentBinding)!=null&&p.fields?`The ticket binds: ${e.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),v&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),s.jsx("span",{className:"auth-card-time",children:l(e.timestamp)})]}),h&&s.jsx("div",{className:"receipt-scope",children:h}),s.jsx(dp,{receipt:e,profile:f}),s.jsxs("dl",{className:"receipt-rows",children:[s.jsxs(Kr,{label:"mandate",children:[s.jsx("strong",{children:i||Lj(e.profileId)})," ",s.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),o&&s.jsx(Kr,{label:"owner",children:o}),m&&s.jsxs(Kr,{label:"allowed",children:[m," ",s.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),x&&s.jsxs(Kr,{label:"used",children:[s.jsx("span",{className:"receipt-num",children:x})," ",s.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),s.jsx(Kr,{label:"intent",children:j?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`intent-text${S?"":" intent-clamped"}`,children:j}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>g(!S),children:S?"Show less":"Show full intent"})," ",s.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}):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==="valid-legacy"&&s.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued. This ticket was issued before protocol 0.7 and is checked with that version's format.",children:"✓ Verified on this device · issued before protocol 0.7"}),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:u,children:"Complete ticket"}),c&&s.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",s.jsx("a",{className:"receipt-link",href:`${c}/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(([y,w])=>`${y}=${w}`).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 Qj({receipt:e,onClose:t}){const[n,r]=d.useState(null),[a,i]=d.useState(null),[o,c]=d.useState(null),[l,u]=d.useState(!0),[f,h]=d.useState(!1);d.useEffect(()=>{let S=!1;return u(!0),E.getArchivedReceipt(e.id).then(g=>{S||(r(g),i(g?"local":"authority-server"),c((g==null?void 0:g.signature)??null))}).catch(()=>{S||i("authority-server")}).finally(()=>{S||u(!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),h(!0),setTimeout(()=>h(!1),2e3)}catch{h(!1)}}return s.jsx("div",{className:"modal-backdrop",onClick:S=>S.target===S.currentTarget&&t(),children:s.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:"Complete ticket"}),s.jsx("button",{className:"modal-close",onClick:t,"aria-label":"Close",children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[o==="valid"&&s.jsx("p",{className:"receipt-verified",style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:"✓ Ed25519 signature verified on this device, against the issuer key archived when this ticket was issued."}),o==="valid-legacy"&&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. Issued before protocol 0.7 — checked with that version's format."}),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:l?"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 qj(e){return new Date(e*1e3).toLocaleString()}function Xj(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 Zj(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||ze(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 Rd(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 eS(){const{activeTeam:e,groupId:t}=Ue(),n=(e==null?void 0:e.isAdmin)===!0,[r,a]=d.useState("mine"),[i,o]=d.useState([]),[c,l]=d.useState([]),[u,f]=d.useState(""),[h,m]=d.useState(!0),[x,j]=d.useState({}),[v,S]=d.useState(new Set),[g,p]=d.useState(""),[y,w]=d.useState(new Set),[k,C]=d.useState(new Set),[N,R]=d.useState("all"),[I,L]=d.useState(!1),[$,T]=d.useState(!1),[O,V]=d.useState(null),[A,Z]=d.useState({}),[se,z]=d.useState(!1),[P,B]=d.useState({}),[_,F]=d.useState({}),[K,X]=d.useState(null),[ne,le]=d.useState(null),[me,ye]=d.useState(!1),[J,xe]=d.useState(!1),re=d.useRef(""),oe=d.useCallback(b=>r==="team"&&n&&t?E.listTeamReceiptsPage(t,{before:b,limit:200}):E.getMyReceiptsPage({before:b,limit:200}),[r,n,t]),G=d.useCallback(()=>{const b=r==="team"?`team:${t}`:"mine",U=re.current!==b;re.current=b,m(!0),xe(!1),oe().then(Y=>{o(ae=>U?Y.receipts:Rd(ae,Y.receipts)),le(ae=>U?Y.nextBefore:ae??Y.nextBefore)}).catch(()=>{U&&o([]),xe(!0)}).finally(()=>m(!1))},[oe,r,t]),M=d.useCallback(()=>{!ne||me||(ye(!0),xe(!1),oe(ne).then(b=>{o(U=>Rd(U,b.receipts)),le(b.nextBefore)}).catch(()=>xe(!0)).finally(()=>ye(!1)))},[ne,me,oe]);Tt(G,12e4),d.useEffect(()=>{E.getIntegrationManifests().then(({manifests:b})=>l(b)).catch(()=>{}),fetch("/health").then(b=>b.json()).then(b=>{typeof b.spUrl=="string"&&f(b.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),d.useEffect(()=>{E.getLocalAuthorizations().then(({authorizations:b,signatures:U})=>{Z(b),B(U),z(!1)}).catch(()=>{Z({}),B({}),z(!0)}),E.getMyAttestations().then(b=>{const U={};for(const Y of b)Y.authorization_id&&Y.title&&(U[Y.authorization_id]=Y.title);F(U)}).catch(()=>{})},[]),d.useEffect(()=>{r!=="team"||Object.keys(x).length>0||E.listUsers().then(b=>{const U={};for(const Y of b)U[Y.id]={name:Y.name,email:Y.email};j(U)}).catch(()=>{})},[r,x]);const ee=d.useMemo(()=>{const b=new Set;for(const U of i)b.add(ze(U.profileId));return[...b].sort()},[i]),ie=d.useMemo(()=>{const b=new Set;for(const U of i)b.add(U.action);return[...b].sort()},[i]),ce=d.useMemo(()=>{if(r!=="team")return[];const b=new Set;for(const U of i)U.userId&&b.add(U.userId);return[...b].map(U=>{var Y;return{id:U,label:(Y=x[U])!=null&&Y.name?`${x[U].name} (${x[U].email})`:U}}).sort((U,Y)=>U.label.localeCompare(Y.label))},[r,i,x]),We=d.useMemo(()=>i.filter(b=>!(!Zj(b,g)||y.size>0&&!y.has(ze(b.profileId))||k.size>0&&!k.has(b.action)||v.size>0&&b.userId&&!v.has(b.userId)||!Xj(b,N))),[i,g,y,k,v,N]),at=y.size>0||k.size>0||v.size>0||N!=="all";function _e(b){w(U=>{const Y=new Set(U);return Y.has(b)?Y.delete(b):Y.add(b),Y})}function et(b){C(U=>{const Y=new Set(U);return Y.has(b)?Y.delete(b):Y.add(b),Y})}function pt(b){S(U=>{const Y=new Set(U);return Y.has(b)?Y.delete(b):Y.add(b),Y})}function it(){w(new Set),C(new Set),S(new Set),R("all"),p("")}async function ue(){T(!0),V(null);try{const{bundle:b,filename:U}=await E.fetchEvidenceBundle(),Y=URL.createObjectURL(new Blob([JSON.stringify(b,null,2)],{type:"application/json"})),ae=document.createElement("a");ae.href=Y,ae.download=U,ae.click(),URL.revokeObjectURL(Y);const H=b.sources??{};H.authorityServer?H.local||V(`Downloaded Authority Server history only — ${H.localError??"local archive unavailable."}`):V(`Downloaded local evidence only — ${H.asError??"Authority Server export unavailable."}`)}catch(b){V(`Export failed: ${b instanceof Error?b.message:String(b)}`)}finally{T(!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:ue,disabled:$,children:$?"Preparing…":"Download evidence"})]}),O&&s.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:O}),n&&s.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(b=>s.jsx("button",{onClick:()=>a(b),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===b?"2px solid var(--accent)":"2px solid transparent",color:r===b?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===b?600:500},children:b==="mine"?"Mine":"Team"},b))}),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:b=>p(b.target.value)}),g&&s.jsx("button",{className:"search-clear",onClick:()=>p(""),children:"×"})]}),s.jsxs("button",{className:`btn btn-sm btn-secondary${I?" active":""}`,onClick:()=>L(!I),children:["Filters",at?` (${y.size+k.size+(N!=="all"?1:0)})`:""]})]}),I&&s.jsxs("div",{className:"filter-panel",children:[ee.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Profile"}),s.jsx("div",{className:"filter-chips",children:ee.map(b=>s.jsx("button",{className:`filter-chip${y.has(b)?" selected":""}`,onClick:()=>_e(b),children:b},b))})]}),ie.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Action"}),s.jsx("div",{className:"filter-chips",children:ie.map(b=>s.jsx("button",{className:`filter-chip${k.has(b)?" selected":""}`,onClick:()=>et(b),children:b},b))})]}),r==="team"&&ce.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Owner"}),s.jsx("div",{className:"filter-chips",children:ce.map(b=>s.jsx("button",{className:`filter-chip${v.has(b.id)?" selected":""}`,onClick:()=>pt(b.id),children:b.label},b.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(([b,U])=>s.jsx("button",{className:`filter-chip${N===b?" selected":""}`,onClick:()=>R(b),children:U},b))})]})]}),at&&s.jsxs("div",{className:"active-filters",children:[[...y].map(b=>s.jsxs("span",{className:"active-chip",onClick:()=>_e(b),children:[b," ",s.jsx("span",{className:"chip-remove",children:"×"})]},b)),[...k].map(b=>s.jsxs("span",{className:"active-chip",onClick:()=>et(b),children:[b," ",s.jsx("span",{className:"chip-remove",children:"×"})]},b)),[...v].map(b=>{const U=x[b],Y=U?U.name:b;return s.jsxs("span",{className:"active-chip",onClick:()=>pt(b),children:[Y," ",s.jsx("span",{className:"chip-remove",children:"×"})]},b)}),N!=="all"&&s.jsxs("span",{className:"active-chip",onClick:()=>R("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:it,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."})}),h&&i.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):We.length===0?s.jsx(Ir,{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:We.length===i.length?`${i.length} ticket${i.length!==1?"s":""}`:`${We.length} of ${i.length} tickets`}),s.jsx("div",{className:"timeline",children:We.map(b=>{const U=b.userId?x[b.userId]:void 0;return s.jsx("div",{className:"timeline-event",children:s.jsx(Jj,{receipt:b,manifests:c,localAuth:b.authorizationId?A[b.authorizationId]:void 0,localUnavailable:se,signature:P[b.id],grantTitle:b.authorizationId?_[b.authorizationId]:null,ownerLabel:r==="team"&&b.userId?U?`${U.name} (${U.email})`:b.userId:null,spUrl:u,formatDate:qj,onOpenComplete:()=>X(b)})},b.id)})})]}),K&&s.jsx(Qj,{receipt:K,onClose:()=>X(null)}),ne&&s.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:M,disabled:me,children:me?"Loading…":"Load older"})})]})}function tS(){const[e,t]=d.useState(null),[n,r]=d.useState({}),[a,i]=d.useState(!1),o=d.useCallback(()=>{E.getDenials({limit:200}).then(({records:l})=>{t(l),i(!1)}).catch(()=>i(!0))},[]);if(d.useEffect(()=>{o()},[o]),Tt(o,6e4),d.useEffect(()=>{if(!e)return;const l=[...new Set(e.map(u=>u.profile).filter(u=>!!u))].filter(u=>!(u in n));l.length!==0&&Promise.all(l.map(u=>E.getProfile(u).catch(()=>null))).then(u=>{r(f=>{const h={...f};return l.forEach((m,x)=>{u[x]&&(h[m]=u[x])}),h})})},[e,n]),a)return s.jsx(Ir,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(e===null)return null;const c=Lh(e,Date.now());return s.jsxs("div",{className:"blocked-page",children:[s.jsxs("div",{className:"page-header blocked-header",children:[s.jsx("h1",{className:"page-title",children:"Blocked actions"}),s.jsxs("span",{className:"blocked-today",children:[c," today · nothing ran"]})]}),e.length===0?s.jsx(Ir,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):s.jsx("div",{className:"blocked-list",children:e.map((l,u)=>{const f=u0(l,l.profile?n[l.profile]:void 0);return s.jsxs("div",{className:"blocked-row","data-kind":Rs(l),children:[s.jsx("span",{className:`blocked-dot blocked-dot-${Rs(l)}`,"aria-hidden":"true"}),s.jsxs("div",{className:"blocked-row-main",children:[s.jsx("div",{className:"blocked-title",children:f.title}),s.jsx("div",{className:"blocked-sentence",children:f.sentence}),s.jsx("div",{className:"blocked-source",children:f.sourceLine}),s.jsxs("details",{children:[s.jsx("summary",{children:"What you can do"}),s.jsx("div",{className:"blocked-advice",children:f.whatYouCanDo})]})]}),s.jsx("div",{className:"blocked-when",children:new Date(l.ts).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},`${l.ts}-${u}`)})})]})}const nS={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function rS(){const[e,t]=d.useState(null),[n,r]=d.useState(!1),[a,i]=d.useState(null),o=d.useCallback(async()=>{try{t(await E.getAutostart())}catch(u){i(u instanceof Error?u.message:"Could not read autostart state")}},[]);d.useEffect(()=>{o()},[o]);const c=d.useCallback(async()=>{if(!(!(e!=null&&e.supported)||n)){r(!0),i(null);try{await E.setAutostart(!e.installed)}catch(u){i(u instanceof Error?u.message:"Failed")}finally{try{t(await E.getAutostart()),i(null)}catch(u){i(u instanceof Error?u.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 l=nS[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 ",l," — no admin rights needed."]}):e.reason})]}),e.supported&&s.jsx("button",{type:"button",onClick:()=>void c(),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 sS(){const[e,t]=d.useState(null),[n,r]=d.useState(!1),[a,i]=d.useState(null),o=d.useCallback(async()=>{try{const l=await E.getGatewaySettings();t(l.desktopNotifications),i(null)}catch(l){i(l instanceof Error?l.message:"Could not read notification setting")}},[]);d.useEffect(()=>{o()},[o]);const c=d.useCallback(async()=>{if(!(e===null||n)){r(!0),i(null);try{const l=await E.setGatewaySettings({desktopNotifications:!e});t(l.desktopNotifications)}catch(l){i(l instanceof Error?l.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 c(),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 aS(){const[e,t]=d.useState(null),[n,r]=d.useState(!1),[a,i]=d.useState(null),o=d.useCallback(async()=>{try{t(await E.getIdentityDisclosure()),i(null)}catch(f){i(f instanceof Error?f.message:"Could not read the setting")}},[]);d.useEffect(()=>{o()},[o]);const c=d.useCallback(async()=>{if(!(!e||n)){r(!0),i(null);try{t(await E.setIdentityDisclosure(!e.always))}catch(f){i(f instanceof Error?f.message:"Failed to save"),await o()}finally{r(!1)}}},[e,n,o]),l=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:[l,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 u=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:[l,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:u?`Your identity: ${u}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),s.jsx("button",{type:"button",onClick:()=>void c(),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 iS={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 oS(){const{version:e,latestVersion:t,updateAvailable:n,installMethod:r}=kc();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:[iS[r]??"Update checking is unavailable",r==="dev"&&s.jsx(s.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function pl({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 Pd(e){return e===!0}function lS(){const[e,t]=d.useState(null),[n,r]=d.useState(null);d.useEffect(()=>{let o=!1;return E.getAsPairing().then(c=>{o||t(c)}).catch(c=>{o||r(c instanceof Error?c.message:"Could not read Authority Server info")}),()=>{o=!0}},[]);const a=Pd(e==null?void 0:e.asUrlLockedByPolicy),i=Pd(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(pl,{})]}),!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(pl,{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 cS(){const{simulation:e,locked:t}=Vh();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(pl,{})]}),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 uS={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"]}},Yr=["AI Assistant","Authority Server","This computer","Security","Version"],Jr={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function dS(){const[e,t]=d.useState(""),[n,r]=d.useState("openrouter"),[a,i]=d.useState("openai-compatible"),[o,c]=d.useState("https://openrouter.ai/api/v1"),[l,u]=d.useState("google/gemma-4-31b-it"),[f,h]=d.useState(""),[m,x]=d.useState(!1),[j,v]=d.useState(!1),[S,g]=d.useState(!1),[p,y]=d.useState(null),[w,k]=d.useState([]),[C,N]=d.useState(!1),[R,I]=d.useState(null),[L,$]=d.useState(""),T=d.useCallback(P=>{t(P),setTimeout(()=>t(""),3e3)},[]),O=d.useCallback(async(P,B,_)=>{N(!0),I(null);try{const F=await E.aiModels({provider:P,endpoint:B,..._?{apiKey:_}:{}});F.ok&&F.models.length>0?(k(F.models),I(`${F.models.length} models available`)):(k([]),I(F.message||"No models returned — using defaults"))}catch(F){k([]),I(F instanceof Error?F.message:"Failed to load models")}finally{N(!1)}},[]),V=d.useCallback(async()=>{try{const P=await E.getCredential("ai-config");if(x(P.configured),P.configured&&P.fields){const B=P.fields.provider||"openai-compatible",_=P.fields.endpoint||"";P.fields.provider&&i(B),P.fields.endpoint&&c(_),P.fields.model&&u(P.fields.model),_.includes("openai.com")?r("openai"):_.includes("groq.com")?r("groq"):_.includes("together.xyz")?r("together"):_.includes("openrouter.ai")?r("openrouter"):r("ollama"),_&&O(B,_)}}catch{}},[O]);d.useEffect(()=>{V()},[V]);const A=P=>{r(P),k([]),I(null),$("");const B=uS[P];B&&(i(B.provider),c(B.endpoint),u(""),O(B.provider,B.endpoint,f||void 0))},Z=()=>O(a,o,f||void 0),se=async()=>{v(!0);try{await E.setCredential("ai-config",{provider:a,endpoint:o,model:l,...f?{apiKey:f}:{}}),x(!0),T("AI configuration saved!")}catch{T("Failed to save AI config")}finally{v(!1)}},z=async()=>{g(!0),y(null);try{const P=await E.aiTest({provider:a,endpoint:o,model:l,...f?{apiKey:f}:{}});y(P.ok?`OK: ${P.message}`:`Failed: ${P.message}`)}catch(P){y(`Error: ${P instanceof Error?P.message:"Unknown"}`)}finally{g(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Settings"}),s.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),e&&s.jsx("div",{className:"alert alert-success",children:e}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Jr,children:Yr[0]}),s.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),s.jsxs("div",{className:"card",children:[s.jsx("h3",{className:"card-title",children:"Configuration"}),s.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Connect a trusted AI model that has access to your intent — problem, objective, and tradeoffs — to help you think through mandates. Keys are encrypted in your vault."}),m&&s.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[s.jsx("span",{className:"status-banner-icon",children:"✓"}),s.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsx("label",{className:"form-label",children:"Provider Preset"}),s.jsxs("select",{className:"form-input",value:n,onChange:P=>A(P.target.value),children:[s.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),s.jsx("option",{value:"ollama",children:"Ollama (local)"}),s.jsx("option",{value:"openai",children:"OpenAI"}),s.jsx("option",{value:"groq",children:"Groq"}),s.jsx("option",{value:"together",children:"Together"})]})]}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsxs("label",{className:"form-label",children:["API Key ",a==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),s.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:f,onChange:P=>h(P.target.value),onBlur:()=>{f.trim()&&O(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:Z,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 P=w,B=P.includes(l),_=P.length>12,F=L.trim().toLowerCase();let K=F?P.filter(X=>X.toLowerCase().includes(F)):P;return B&&!K.includes(l)&&(K=[l,...K]),s.jsxs(s.Fragment,{children:[_&&s.jsx("input",{className:"form-input",value:L,onChange:X=>$(X.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),s.jsxs("select",{className:"form-input",value:B?l:"__unset__",onChange:X=>u(X.target.value==="__unset__"?"":X.target.value),children:[s.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),K.map(X=>s.jsx("option",{value:X,children:X},X)),F&&K.length===0&&s.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",L,"”"]})]})]})})(),R&&s.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:R})]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[s.jsx("button",{className:"btn btn-primary",onClick:se,disabled:j||!l.trim(),title:l.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"})]}),p&&s.jsx("div",{className:`alert ${p.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:p})]}),s.jsx(fS,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Jr,children:Yr[1]}),s.jsx(lS,{}),s.jsx(aS,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Jr,children:Yr[2]}),s.jsx(rS,{}),s.jsx(sS,{}),s.jsx(cS,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Jr,children:Yr[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:Jr,children:Yr[4]}),s.jsx(oS,{})]})]})}function fS(){const[e,t]=d.useState(null),[n,r]=d.useState({intent:"",context:""}),[a,i]=d.useState(null),[o,c]=d.useState(null),[l,u]=d.useState(null),[f,h]=d.useState(!1),m=d.useCallback(async()=>{if(!f)try{const v=await E.getAIPrompts();t(v),r({intent:v.intent.current,context:v.context.current}),h(!0)}catch(v){c(v instanceof Error?v.message:"Failed to load prompts")}},[f]),x=async v=>{if(e){i(v),c(null);try{const S=n[v],g=S.trim()===e[v].default.trim()?"":S;await E.setAIPrompt(v,g);const p=await E.getAIPrompts();t(p),r({intent:p.intent.current,context:p.context.current}),u(v),setTimeout(()=>u(null),2e3)}catch(S){c(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),c(null);try{await E.setAIPrompt(v,"");const S=await E.getAIPrompts();t(S),r({intent:S.intent.current,context:S.context.current})}catch(S){c(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($d,{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:l==="intent"}),s.jsx($d,{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:l==="context"})]})]})}function $d({kind:e,label:t,description:n,state:r,draft:a,onChange:i,onSave:o,onRevert:c,saving:l,justSaved:u}){const f=a!==r.current;return s.jsxs("section",{style:{marginBottom:"1.5rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:t}),s.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:n})]}),r.overridden&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),s.jsx("textarea",{className:"form-textarea",value:a,onChange:h=>i(h.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${t} system prompt`}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[s.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:o,disabled:l||!f,children:l?"Saving…":"Save"}),r.overridden&&s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:c,disabled:l,title:"Discard the override and use the built-in default",children:"Revert to default"}),u&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),f&&!l&&!u&&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 mS(e){return e.proposalId?"review":"automatic"}function _d(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 c=mS(o);!a&&c==="automatic"||n.profile&&o.profileId!==n.profile||i.push({kind:"receipt",id:o.id,sortTimestamp:o.timestamp,commitmentMode:c,profileId:o.profileId,receipt:o})}return i.sort((o,c)=>c.sortTimestamp-o.sortTimestamp),typeof n.limit=="number"&&n.limit>0?i.slice(0,n.limit):i}const hS=["https://","http://"];function fp(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)?[]:hS.some(a=>r.toLowerCase().startsWith(a))?[{label:n.label,href:r,description:n.description}]:[]}):[]}function mp(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 pS=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function gS(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:pS.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function tr(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 Ld({row:e,which:t}){const n=Bs(e.profileRef),r=Ej(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(d.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 yS({row:e}){const t=Bs(e.profileRef),n=(t==null?void 0:t.id)??e.profileRef??"";return s.jsxs(s.Fragment,{children:[(t==null?void 0:t.name)??ze(n),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:n})]})}function vS({row:e,altText:t}){switch(e.kind){case"profile":return s.jsx(yS,{row:e});case"profile-limits":return s.jsx(Ld,{row:e,which:"limits"});case"profile-scope":return s.jsx(Ld,{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:tr(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:tr(n)},r))}):s.jsx(s.Fragment,{children:tr(e.value)});case"money":return s.jsxs(s.Fragment,{children:[tr(e.value),e.currency?` ${e.currency}`:""]});case"object":return s.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:tr(e.value)});default:return gS(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:tr(e.value)})}}function hp({args:e,display:t,heading:n="Details"}){const r=Cj(e,t);if(r.length===0)return null;const a=typeof e.altText=="string"?e.altText:void 0;return s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n&&s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:n}),s.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:r.map(i=>s.jsxs(d.Fragment,{children:[s.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:i.hint,children:i.label}),s.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:s.jsx(vS,{row:i,altText:a})})]},i.key))})]})}const zd=500;function gl(e){return e.length>zd?`${e.slice(0,zd)}…`:e}function Fd(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function Od(e,t){switch(e.status){case"none":return e.reason==="no_target"?{heading:"Nothing to read beforehand",note:`This action does not refer to an existing record — nothing to read beforehand. Showing exactly what will be sent to ${t}.`}:{heading:"No preview declared",note:`No preview declared for this tool — showing exactly what will be sent to ${t}.`};case"unavailable":return e.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:e.message?`Preview not available — ${gl(e.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:e.message?`Not found in your system — ${gl(e.message)}`:"Not found in your system."};case"ok":{const n=hl(e.body,{fields:e.fields}),r={heading:`From ${t}, before it runs`,note:`Read by the gateway with ${e.tool} when you opened this card — the AI is not involved.`,rendered:n},a=e.version;if(a&&(r.versionNote=`You approve ${a.field} ${a.approved}; if it changes, ${t} refuses it.`,a.stale)){const i=Wj(e.body,a.currentBody,{fields:e.fields,excludeKey:a.field});r.stale={heading:`A newer ${a.field} exists (${a.current})`,approvedLabel:`${Fd(a.field)} ${a.approved}`,currentLabel:`${Fd(a.field)} ${a.current}`,...i.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:i.approved,currentRendered:i.current}}}return r}}}function xS(e,t){if(e.state!=="failed")return null;const n=e.detail?gl(e.detail):void 0;return e.outcome==="changed"?{heading:"Changed since your approval",note:`The record changed in ${t} since you approved it — nothing was done. Ask the AI to request it again.`}:{heading:`Refused by ${t}`,note:`${t} refused it${n?`: ${n}`:""} — nothing was done. Ask the AI to request it again.`}}function wS(e){return e!==null&&e!=="loading"&&e!=="ok"&&e!=="stale"}function jS({proposalId:e,systemName:t}){const[n,r]=d.useState(null);if(d.useEffect(()=>{let i=!0;return r(null),E.getProposalOutcome(e).then(o=>{i&&r(o)}).catch(()=>{}),()=>{i=!1}},[e]),!n)return null;const a=xS(n,t);return a?s.jsxs("div",{className:"outcome-box",children:[s.jsx("h4",{children:a.heading}),s.jsx("p",{className:"outcome-note",children:a.note})]}):null}function SS({proposalId:e,systemName:t,onTone:n}){const[r,a]=d.useState(null),[i,o]=d.useState(!1);if(d.useEffect(()=>{let u=!0;return a(null),o(!1),E.getProposalPreview(e).then(f=>{u&&a(f)}).catch(()=>{u&&o(!0)}),()=>{u=!1}},[e]),d.useEffect(()=>{if(i){n==null||n("unavailable");return}if(!r)return;const u=Od(r,t);n==null||n(r.status==="ok"?u.stale?"stale":"ok":r.status)},[r,i,t,n]),i)return s.jsxs("div",{className:"preview-box preview-box-unavailable","data-testid":"approval-preview","data-preview-status":"unavailable",children:[s.jsx("h4",{children:"Preview not available"}),s.jsx("p",{className:"preview-note",children:"Preview not available on this gateway."})]});if(!r)return s.jsxs("div",{className:"preview-box preview-box-loading","data-testid":"approval-preview","data-preview-status":"loading","aria-busy":"true",children:["Reading from ",t,"…"]});const c=Od(r,t),l=r.status==="ok"?c.stale?"stale":"ok":r.status;return l==="none"?s.jsx("p",{className:"preview-note","data-testid":"approval-preview","data-preview-status":"none",children:c.note}):s.jsxs("div",{className:`preview-box preview-box-${l}`,"data-testid":"approval-preview","data-preview-status":l,children:[s.jsx("h4",{children:c.heading}),c.rendered&&s.jsx(Ta,{rendered:c.rendered}),s.jsx("p",{className:"preview-note",children:c.note}),c.versionNote&&!c.stale&&s.jsx("p",{className:"preview-note",children:c.versionNote}),c.stale&&s.jsxs("div",{className:"preview-stale",children:[s.jsx("h5",{children:c.stale.heading}),c.stale.unchangedNote?s.jsx("p",{className:"preview-note",children:c.stale.unchangedNote}):s.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.5rem 0 0"},children:[s.jsx("dt",{children:c.stale.approvedLabel}),s.jsx("dd",{children:s.jsx(Ta,{rendered:c.stale.approvedRendered})}),s.jsx("dt",{children:c.stale.currentLabel}),s.jsx("dd",{children:s.jsx(Ta,{rendered:c.stale.currentRendered})})]})]})]})}let lo=null;function kS(){return lo||(lo=E.getEnrichedAuthorizations().then(e=>new Map(e.map(t=>[t.authorizationId,t.bounds]))).catch(()=>new Map)),lo}function bS(e){const[t,n]=d.useState(void 0);return d.useEffect(()=>{let r=!0;if(e)return kS().then(a=>{r&&n(a.get(e))}),()=>{r=!1}},[e]),t}function NS(e,t){const[n,r]=d.useState(null),[a,i]=d.useState(!1),[o,c]=d.useState(null);return d.useEffect(()=>{let l=!0;return r(null),c(null),i(!0),(async()=>{try{const u=await E.getAttestationIntent(e);if(!u){l&&c("Intent not available or you are not an authorized approver.");return}const f=await E.decryptIntent({intentCiphertext:u.intentCiphertext,encryptedKey:u.encryptedKey,approverId:t});l&&r(f)}catch(u){l&&c(u instanceof Error?u.message:"Failed to decrypt intent")}finally{l&&i(!1)}})(),()=>{l=!1}},[e,t]),{intent:n,loading:a,error:o}}function Md(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,r]of Object.entries(e))(typeof r=="string"||typeof r=="number")&&(t[n]=r);return t}function CS(e){const t=Md(e.limits),n=Md(e.scope),r=typeof e.intent=="string"?e.intent:"",a={bounds:t,context:n,gateContent:{intent:r}};return(e.mode==="automatic"||e.mode==="review")&&(a.templateMode=e.mode),typeof e.duration_hours=="number"&&e.duration_hours>0&&(a.templateTtl=Math.round(e.duration_hours*3600)),a}function pp(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=>pp(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}const ES="setup__create_mandate";function gp({proposal:e,currentUserId:t,proposalLinks:n,toolDisplay:r,manifests:a}){const[i,o]=d.useState(!1),[c,l]=d.useState(!1),[u,f]=d.useState(null),h=Ut(),{group:m,groupId:x,domain:j}=Ue(),v=Object.entries(e.executionContext),S=Bs(e.profileId),g=bS(e.authorizationId),p=$j(e.executionContext,g,S),y=fp(n,e.toolArgs),w=bj(e.tool),{integrationId:k}=zc(e.tool),C=cp(k,a),{intent:N,loading:R,error:I}=NS(e.authorizationId,t),L=async()=>{if(!x){f("No active workspace; cannot open the mandate screen.");return}l(!0),f(null);try{const A=e.toolArgs,Z=typeof A.profile=="string"?A.profile:"",se=await E.listProfiles(),z=ap(Z,se);if(!z){f(`Unknown profile "${Z}".`);return}const P=await E.getProfile(z.id),B=CS(A),_=op(B.bounds,P),F=lp(B.context,P);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:z.id,groupId:x,groupName:(m==null?void 0:m.name)??null,domain:j,isPersonal:!!(m!=null&&m.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...B,bounds:_,context:F})),sessionStorage.setItem("agentReplacesProposal",e.id),h("/mandates/new/intent")}catch(A){f(A instanceof Error?A.message:"Could not open the mandate screen.")}finally{l(!1)}},[$,T]=d.useState(null),O=wS($),V=s.jsxs(s.Fragment,{children:[s.jsx(hp,{args:e.toolArgs,display:r,heading:""}),v.length>0&&s.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:v.map(([A,Z],se)=>{const{label:z,hint:P}=up(A,S);return s.jsxs("span",{children:[se>0&&" · ",s.jsxs("span",{title:P,children:[z,"=",pp(Z)]})]},A)})})]});return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"approval-headline",children:w}),O&&s.jsxs("div",{className:"preview-box preview-box-ok","data-testid":"bound-values-open",style:{marginBottom:"0.5rem"},children:[s.jsxs("h4",{children:["What will be sent ",s.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),V]}),s.jsx(SS,{proposalId:e.id,systemName:C,onTone:T}),p.length>0&&s.jsxs("div",{className:"limit-checks",children:[s.jsx("h4",{children:"Within your limits"}),s.jsx("ul",{className:"limit-check-list",children:p.map(A=>s.jsxs("li",{className:A.ok?"ok":"bad",children:[s.jsx("span",{className:"limit-check-icon",children:A.ok?"✓":"✗"}),s.jsxs("span",{children:[A.label," ",A.valueText," — your limit ",A.limitText]})]},A.key))})]}),s.jsxs("div",{className:"mandate-intent",children:[s.jsxs("dl",{children:[s.jsx("dt",{children:"Mandate"}),s.jsxs("dd",{children:[s.jsx("strong",{children:(S==null?void 0:S.name)??ze(e.profileId)}),s.jsx("span",{className:"src-tag src-tag-local",children:"local"})]})]}),s.jsxs("dl",{children:[s.jsx("dt",{children:"Intent"}),s.jsx("dd",{children:I?s.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:I}):N!==null?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:`intent-text${i?"":" intent-clamped"}`,children:N}),s.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>o(!i),children:i?"Show less":"Show full intent"})]}):R?s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"Loading intent…"}):s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]})]}),y.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:y.map(A=>s.jsxs("a",{href:A.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:A.description??A.href,children:[A.label," ↗"]},A.label))}),!O&&s.jsxs("details",{className:"proposal-args-fold",style:{marginBottom:"0.75rem"},children:[s.jsx("summary",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",cursor:"pointer"},children:"Details (exactly what is bound)"}),s.jsx("div",{style:{marginTop:"0.5rem"},children:V})]}),e.tool===ES&&s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",margin:"0 0 0.4rem"},children:["The intent above is written by the AI, but it becomes ",s.jsx("strong",{children:"your words"})," once you approve. Edit it first — nothing is created until you sign on the mandate screen."]}),s.jsx("button",{type:"button",className:"btn btn-secondary btn-sm","data-testid":"edit-before-signing",onClick:L,disabled:c,children:c?"Opening…":"Edit before signing"}),u&&s.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:"0.4rem 0 0"},children:u})]})]})}function yp({note:e,onNoteChange:t,onSend:n,onCancel:r,sending:a,error:i}){return s.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"var(--bg-main)",padding:"0.75rem 0.875rem",marginTop:"0.5rem"},children:[s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:[s.jsx("strong",{style:{color:"var(--text-primary)"},children:"What should change?"})," (the AI will read this)"]}),s.jsx("div",{style:{display:"flex",gap:"0.375rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:Dw.map(o=>s.jsx("button",{type:"button",className:`filter-chip${tp(e,o)?" selected":""}`,onClick:()=>t(Ww(e,o)),disabled:a,children:o},o))}),s.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:e,maxLength:ri,onChange:o=>t(o.target.value),rows:3,placeholder:"What should the AI do differently?",disabled:a,style:{width:"100%",resize:"vertical",fontFamily:"inherit"}}),s.jsxs("div",{style:{textAlign:"right",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[e.length," / ",ri]}),i&&s.jsx("div",{className:"error-message",style:{marginTop:"0.4rem"},children:i}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.5rem"},children:[s.jsx("button",{"data-testid":"btn-send-back",className:"btn btn-primary",style:{background:"var(--warning)",borderColor:"var(--warning)"},onClick:n,disabled:a,children:a?"Sending…":"Send back for change"}),s.jsx("button",{className:"btn btn-ghost",onClick:r,disabled:a,children:"Cancel"})]}),s.jsx("p",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",marginTop:"0.5rem",marginBottom:0},children:"The AI is told: adjust and propose again — a new proposal you approve again. Nothing runs from this one."})]})}const TS={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},IS={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"},RS={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced"};function Bd(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 AS(e){return e.split("__").pop()??e}function PS(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}function vp(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=>vp(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Dd({item:e,onApprove:t,onReject:n,onChangeNeeded:r,resolving:a,proposalLinks:i,toolDisplay:o,manifests:c,currentUserId:l}){const u=e.kind==="proposal",f=u?e.proposal.status:"executed",h=u?e.proposal.tool:e.receipt.action,m=AS(h),x=PS(h),{integrationId:j}=zc(h),v=cp(j,c),[S,g]=d.useState(!1),[p,y]=d.useState(""),[w,k]=d.useState(""),C=()=>{const A=Lc(p);if(!A.valid){k(A.error);return}k(""),r==null||r(e.id,A.trimmed)},N=u&&f==="rejected"?Gw(e.proposal,l??""):null,R=Bs(e.profileId),I=u?e.proposal.toolArgs:null,L=u?e.proposal.executionContext:e.receipt.executionContext,$=u?null:e.receipt.cumulativeState,T=u?fp(i,e.proposal.toolArgs):[],O=Object.entries(L??{}),V=Xn(e.profileId).testSetup||Ni(h);return s.jsxs("div",{className:"card id-card",children:[s.jsx(Ms,{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:m}),V&&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:[u&&f==="pending"&&(()=>{const A=mp(e.proposal.expiresAt,Date.now());return s.jsx("span",{style:{fontSize:"0.72rem",color:A.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:A.urgent?600:400,whiteSpace:"nowrap"},children:A.label})})(),s.jsx("span",{"data-testid":N?"outcome-kind":void 0,className:`status-badge ${N?RS[N.kind]:IS[f]}`,children:N?N.kind:TS[f]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Bd(e.sortTimestamp)})]})]}),u&&e.proposal.status==="executed"&&s.jsx(jS,{proposalId:e.proposal.id,systemName:v}),N&&s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[s.jsxs("div",{children:["By ",N.who,", ",Bd(N.at)]}),N.note&&s.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[N.kind==="CHANGE NEEDED"?"Change: ":"Note: ",N.note]})]}),x&&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"})]}),u&&typeof(I==null?void 0:I._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:I._imagePreview,alt:typeof(I==null?void 0:I.altText)=="string"?I.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),u&&f==="pending"?s.jsx(gp,{proposal:e.proposal,currentUserId:l??"",proposalLinks:i,toolDisplay:o,manifests:c}):s.jsxs(s.Fragment,{children:[T.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:T.map(A=>s.jsxs("a",{href:A.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:A.description??A.href,children:[A.label," ↗"]},A.label))}),u?s.jsxs(s.Fragment,{children:[I&&s.jsx(hp,{args:I,display:o}),O.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:O.map(([A,Z])=>`${A}=${vp(Z)}`).join(" · ")})]}):s.jsx(dp,{receipt:e.receipt,profile:R})]}),$&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",$.daily.count," action",$.daily.count===1?"":"s",$.daily.amount>0?`, ${$.daily.amount}`:""," · ","this month: ",$.monthly.count,$.monthly.amount>0?`, ${$.monthly.amount}`:""]}),u&&f==="pending"&&(S?s.jsx(yp,{note:p,onNoteChange:y,onSend:C,onCancel:()=>{g(!1),y(""),k("")},sending:!!a,error:w}):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:a,children:a?"Approving…":"Approve"}),s.jsx("button",{"data-testid":"btn-change-needed",className:"btn",style:{background:"#fff",color:"var(--warning)",border:"1px solid var(--warning)"},onClick:()=>g(!0),disabled:a,children:"Change needed"}),s.jsx("button",{"data-testid":"btn-reject",className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:()=>n==null?void 0:n(e.id),disabled:a,children:"Reject"})]})),s.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[u?"Proposal":"Ticket",": ",e.id]})]})]})}function $S(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 _S({proposal:e,currentUserId:t,onAction:n,onMessage:r,proposalLinks:a,toolDisplay:i,manifests:o}){const[c,l]=d.useState(!1),[u,f]=d.useState(!1),[h,m]=d.useState(!1),[x,j]=d.useState(""),[v,S]=d.useState(""),[g,p]=d.useState(!1),y=Xn(e.profileId).testSetup||Ni(e.tool),w=e.pendingApprovers??[],k=e.approvedBy??{},C=Object.keys(k).length,N=w.filter(O=>!(O in k)).length,R=t in k,I=async()=>{if(Rc()){r(Ac);return}l(!0),r("");try{await E.approveProposal(e.id);try{const O=await E.getAttestationIntent(e.authorizationId);if(O){const V=await E.decryptIntent({intentCiphertext:O.intentCiphertext,encryptedKey:O.encryptedKey,approverId:t});await E.storeApprovedIntent(e.authorizationId,V)}}catch{}r(`Approved. ${N-1>0?`${N-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(O){r(O instanceof Error?O.message:"Approval failed")}finally{l(!1)}},L=async()=>{f(!0),r("");try{await E.rejectProposal(e.id,dl()),r("Action rejected."),n()}catch(O){r(O instanceof Error?O.message:"Rejection failed")}finally{f(!1)}},$=async()=>{const O=Lc(x);if(!O.valid){S(O.error);return}S(""),p(!0),r("");try{await E.rejectProposal(e.id,np(O.trimmed)),r("Sent back for a change."),n()}catch(V){r(V instanceof Error?V.message:"Failed to send back")}finally{p(!1)}},T=c||u||g;return s.jsxs("div",{className:"card id-card",children:[s.jsx(Ms,{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"}),y&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),s.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const O=mp(e.expiresAt,Date.now());return s.jsx("span",{style:{fontSize:"0.72rem",color:O.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:O.urgent?600:400,whiteSpace:"nowrap"},children:O.label})})(),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:$S(e.createdAt)})]})]}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[C," of ",w.length," approver",w.length===1?"":"s"," signed off",w.map(O=>{const V=O in k;return s.jsxs("span",{style:{marginLeft:"0.5rem",color:V?"var(--success, green)":"var(--text-tertiary)"},children:[V?"✓":"○"," ",O===t?"You":O]},O)})]}),s.jsx(gp,{proposal:e,currentUserId:t,proposalLinks:a,toolDisplay:i,manifests:o}),!R&&(h?s.jsx(yp,{note:x,onNoteChange:j,onSend:$,onCancel:()=>{m(!1),j(""),S("")},sending:g,error:v}):s.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:I,disabled:T,children:c?"Approving...":"Approve"}),s.jsx("button",{"data-testid":"btn-change-needed",className:"btn",style:{background:"#fff",color:"var(--warning)",border:"1px solid var(--warning)"},onClick:()=>m(!0),disabled:T,children:"Change needed"}),s.jsx("button",{"data-testid":"btn-reject",className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:L,disabled:T,children:u?"Rejecting...":"Reject"})]})),R&&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 LS(){const{domain:e,user:t}=Ue(),n=(t==null?void 0:t.id)??"",[r,a]=d.useState("awaiting-me"),[i,o]=d.useState([]),[c,l]=d.useState([]),[u,f]=d.useState({}),[h,m]=d.useState(!0),[x,j]=d.useState(""),v=d.useCallback(async()=>{try{const M=await E.getProposalsForApprover();o(M)}catch{}finally{m(!1)}},[]);ve("proposal-added",v),ve("proposal-approved",v),ve("proposal-rejected",v),ve("proposal-resolved",v),Tt(v,3e4);const[S,g]=d.useState([]),p=d.useCallback(async()=>{try{const M=await E.getMyProposals(e);g(M)}catch{}},[e]);ve("proposal-added",p),ve("proposal-approved",p),ve("proposal-rejected",p),ve("proposal-resolved",p),Tt(p,3e4,e);const y=d.useMemo(()=>S.filter(M=>{var ee;return M.status==="pending"&&(((ee=M.pendingApprovers)==null?void 0:ee.length)??0)===0}),[S]),w=d.useMemo(()=>_d(y,[],{status:"pending"}),[y]),[k,C]=d.useState([]),N=d.useCallback(async()=>{if(n)try{const ee=(await E.getMyProposals(e)).filter(ie=>ie.status==="pending"&&ie.pendingApprovers&&ie.pendingApprovers.includes(n)&&ie.approvedBy&&n in ie.approvedBy);C(ee)}catch{}},[n,e]);ve("proposal-approved",N),ve("proposal-rejected",N),Tt(N,3e4,`${n}:${e}`),d.useEffect(()=>{E.getIntegrationManifests().then(M=>l(M.manifests??[])).catch(()=>{}),E.getToolDisplay().then(f).catch(()=>{})},[]);const R=M=>{var ee;return(ee=c.find(ie=>ie.id===M.split("__")[0]))==null?void 0:ee.proposalLinks};d.useEffect(()=>{v(),p(),N()},[]);const[I,L]=d.useState([]),[$,T]=d.useState([]),[O,V]=d.useState(!0),[A,Z]=d.useState(null),[se,z]=d.useState(""),[P,B]=d.useState("pending"),[_,F]=d.useState(null),[K,X]=d.useState(!1),ne=d.useCallback(async()=>{try{const{proposals:M,receipts:ee}=await E.getThread({domain:e,status:P,sinceDays:7});L(M),T(ee)}catch{}finally{V(!1)}},[e,P]);Tt(ne,3e4,`${e}:${P}`);const le=async(M,ee,ie)=>{if(ee==="commit"&&Rc()){z(Ac);return}Z(M),z("");try{const ce=I.find(_e=>_e.id===M)??S.find(_e=>_e.id===M),We=_x(ce,e),at=await E.resolveProposal(M,ee,We,ie);z(ee==="commit"?`Action approved. Status: ${at.status}`:(ie==null?void 0:ie.outcome)==="change_needed"?"Sent back for a change.":"Action rejected."),await Promise.all([ne(),p()])}catch(ce){z(ce instanceof Error?ce.message:"Failed")}finally{Z(null)}},me=(M,ee)=>le(M,"reject",np(ee)),ye=d.useMemo(()=>{const M=new Set;for(const ee of I)M.add(ee.profileId);for(const ee of $)M.add(ee.profileId);return Array.from(M).sort()},[I,$]),J=d.useMemo(()=>_d(I,$,{status:P,profile:_??void 0,includeAutonomous:K}),[I,$,P,_,K]),xe=d.useCallback(()=>{v(),N()},[v,N]),re=d.useMemo(()=>{const M=new Set,ee=[];for(const ie of k)M.has(ie.id)||(M.add(ie.id),ee.push(ie));return ee.sort((ie,ce)=>ce.createdAt-ie.createdAt)},[k]),oe=i.length+w.length,G=re.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(Wh,{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 ",oe>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:oe})]}),s.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>a("awaiting-others"),children:["Awaiting others ",G>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:G})]}),s.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{a("all"),ne()},children:"All"})]}),r==="awaiting-me"&&s.jsx(s.Fragment,{children:h&&oe===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):oe===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||se)&&s.jsx("div",{className:"alert alert-success",children:x||se}),w.map(M=>s.jsx(Dd,{proposalLinks:M.kind==="proposal"?R(M.proposal.tool):void 0,toolDisplay:M.kind==="proposal"?u[M.proposal.tool]:void 0,manifests:c,currentUserId:n,item:M,onApprove:ee=>le(ee,"commit"),onReject:ee=>le(ee,"reject",dl()),onChangeNeeded:me,resolving:A===M.id},M.id)),i.map(M=>s.jsx(_S,{proposal:M,currentUserId:n,onAction:xe,onMessage:j,proposalLinks:R(M.tool),toolDisplay:u[M.tool],manifests:c},M.id))]})}),r==="awaiting-others"&&s.jsx(s.Fragment,{children:re.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:re.map(M=>s.jsx(FS,{proposal:M,currentUserId:n,onCancel:async()=>{try{await E.rejectProposal(M.id,{reason:"cancelled by creator"}),N(),p()}catch(ee){alert(ee instanceof Error?ee.message:"Cancel failed")}}},M.id))})}),r==="all"&&s.jsxs(s.Fragment,{children:[se&&s.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:se}),s.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[s.jsx("button",{className:`filter-chip ${P==="pending"?"selected":""}`,onClick:()=>B("pending"),children:"Pending"}),s.jsx("button",{className:`filter-chip ${P==="all"?"selected":""}`,onClick:()=>B("all"),children:"All"}),ye.length>0&&s.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),ye.map(M=>s.jsx("button",{className:`filter-chip ${_===M?"selected":""}`,onClick:()=>F(_===M?null:M),children:ze(M)},M)),P==="all"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),s.jsxs("button",{className:`filter-chip ${K?"selected":""}`,onClick:()=>X(!K),title:"Include actions executed without human review (automatic commitment mode)",children:[K?"✓ ":"","Autonomous actions"]})]})]}),O&&J.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):J.length===0?s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[s.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:P==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:P==="pending"?"Your agents are operating within their mandates. Switch to All to see recent activity.":"When an agent calls a gated tool, activity will appear here."})]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:J.map(M=>s.jsx(Dd,{proposalLinks:M.kind==="proposal"?R(M.proposal.tool):void 0,toolDisplay:M.kind==="proposal"?u[M.proposal.tool]:void 0,manifests:c,currentUserId:n,item:M,onApprove:ee=>le(ee,"commit"),onReject:ee=>le(ee,"reject",dl()),onChangeNeeded:me,resolving:A===M.id},M.id))})]})]})}function zS(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 FS({proposal:e,currentUserId:t,onCancel:n}){var f;const[r,a]=d.useState(!1),i=Object.keys(e.approvedBy??{}),o=(e.pendingApprovers??[]).filter(h=>!(h in(e.approvedBy??{}))),c=(((f=e.pendingApprovers)==null?void 0:f.length)??0)>0,l=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){a(!0);try{await n()}finally{a(!1)}}},u=Xn(e.profileId).testSetup||Ni(e.tool);return s.jsxs("div",{className:"card id-card",children:[s.jsx(Ms,{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}),u&&s.jsx("span",{className:"sim-mark",children:"Test setup"}),c&&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:zS(e.createdAt)})]}),c&&s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[i.map(h=>s.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:h===t?"You approved":`${h} approved`},h)),o.map(h=>s.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",h===t?"you":h]},h))]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:s.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:l,disabled:r,children:r?"Cancelling...":"Cancel"})})]})]})}const OS=`# Agent Brief
85
+
86
+ You act on my behalf through Suveren — the gateway that gates every
87
+ privileged tool call you make. Suveren implements the bounded-authority
88
+ model from the open Human Agency Protocol (HAP): each mandate
89
+ describes an area of authority, a set of numeric limits, and a scope.
90
+ Operate inside those bounds or the Gatekeeper will reject your action.
91
+
92
+ ## Before you act in a domain
93
+
94
+ 1. Call \`list-authorizations(domain: "<domain>")\` to load the full
95
+ intent, scope, and usage for that area. The session brief shows only
96
+ a one-line summary per mandate — the Intent paragraph lives behind
97
+ that call, and often contains soft rules you MUST honor (e.g. "never
98
+ publish on weekends", "only reply in English").
99
+ 2. If the action would exceed a bound or fall outside the scope, stop
100
+ and explain what would be blocked instead of trying.
101
+ 3. If you're not sure whether an action is covered, ask me first.
102
+
103
+ ## How to handle reviews
104
+
105
+ Mandates in review mode require my approval before the action
106
+ executes. When you propose an action:
107
+ - Include everything I need to judge it (title, recipients, amounts,
108
+ dates, attendees) in the tool arguments.
109
+ - Don't batch unrelated proposals — one proposal per decision.
110
+
111
+ ## Standing orders
112
+
113
+ (Add your own here. Examples:)
114
+
115
+ - Every morning, summarize today's calendar and flag conflicts.
116
+ - On Fridays, give me a weekly review: what's done, what slipped, what's
117
+ next.
118
+ - Never email anyone outside the company without asking first.
119
+ - When drafting posts, prefer plain language over marketing copy.
120
+ `;function MS(){const[e,t]=d.useState(""),[n,r]=d.useState(""),[a,i]=d.useState(!0),[o,c]=d.useState(!1),[l,u]=d.useState(null),[f,h]=d.useState(!1),m=e!==n,x=new Blob([e]).size,j=16*1024;d.useEffect(()=>{if(!m)return;const p=w=>{w.preventDefault(),w.returnValue=""},y=w=>{var N,R;if(w.defaultPrevented||w.button!==0||w.metaKey||w.ctrlKey||w.shiftKey||w.altKey)return;const k=(R=(N=w.target)==null?void 0:N.closest)==null?void 0:R.call(N,"a");if(!k||!k.href)return;let C;try{C=new URL(k.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",p),document.addEventListener("click",y,!0),()=>{window.removeEventListener("beforeunload",p),document.removeEventListener("click",y,!0)}},[m]),d.useEffect(()=>{let p=!1;return E.getAgentContext().then(y=>{p||(t(y),r(y))}).catch(y=>{p||u({kind:"error",text:y instanceof Error?y.message:"Failed to load context"})}).finally(()=>{p||i(!1)}),()=>{p=!0}},[]);const v=async()=>{c(!0),u(null);try{await E.saveAgentContext(e),r(e),u({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(p){u({kind:"error",text:p instanceof Error?p.message:"Save failed"})}finally{c(!1)}},S=()=>{t(n),u(null)},g=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(OS)};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"})]}),l&&s.jsx("div",{className:l.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:l.text}),s.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[s.jsx("div",{className:"card intent-pane chat",children:s.jsx(ti,{target:{kind:"context"},currentText:e,onApply:p=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(p)},greeting:"Tell me what your agent should know — I'll help shape your standing orders. Or ask me to draft a full brief and we'll iterate.",placeholder:"Ask for help with your brief…"})}),s.jsxs("div",{className:"card intent-pane document",children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[s.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),s.jsxs("span",{style:{fontSize:"0.75rem",color:x>j?"var(--danger)":"var(--text-muted)"},children:[x.toLocaleString()," / ",j.toLocaleString()," bytes"]})]}),s.jsx("textarea",{className:"form-textarea",value:e,onChange:p=>t(p.target.value),placeholder:a?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:a,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),s.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:S,disabled:o||!m,children:"Revert"}),s.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:v,disabled:o||!m||x>j||a,children:o?"Saving…":"Save"})]})]}),s.jsx("button",{type:"button",className:"floating-help",onClick:()=>h(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),s.jsx(Yh,{open:f,onClose:()=>h(!1),ariaLabel:"Brief assistant",children:s.jsx(ti,{target:{kind:"context"},currentText:e,onApply:p=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(p),h(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function BS(e){const t=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return t&&t[1].replace(/<[^>]+>/g,"").trim()||"Report"}function DS(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 US(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function WS(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 HS(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 VS(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 Ud(e,t="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:t}}function GS(e){return/Labels?$/.test(e)||e==="limits"||e==="fields"}function KS(e,t){const n=t[e];return n==null||n===""||GS(e)?null:typeof n=="object"?JSON.stringify(n):String(n)}function YS(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 JS(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 QS="allow-popups allow-popups-to-escape-sandbox",qS="AI analysis — not verified",XS="Green = verified by the gateway — raw signed fields only",ZS="Grey dashed = the AI's own analysis, not verified",ek="= translation by the AI, not verified",tk="Übersetzung anzeigen / show translation";function Wd(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 nk(e,t){return t&&e.renderedHtmlGloss?e.renderedHtmlGloss:e.renderedHtml}function rk(e,t,n){const r=new URLSearchParams(e);return r.set("element",t),n?r.set("ticket",n):r.delete("ticket"),r}const sk={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function ak(e){return e.filter(t=>t.status==="unverifiable").map(t=>({elementId:t.id,text:`${sk[t.kind]??"Element"}: ${t.reason??"could not be checked"}`}))}function ik(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 ok(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 Fc={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},lk={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function ck(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 uk(e,t){const n=lk[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:{...Fc,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 co(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:Fc,children:ck(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))}),uk(e,t.data??{})]})]}):null}function dk({report:e,elementId:t,ticketParam:n,onClose:r,onSelectTicket:a}){var h;const i=e.elements.find(m=>m.id===t),o=JS(i,n),c=o?e.ticketDetails[o]:void 0,l=ik(i),u=(h=e.proof.verifiedValues.find(m=>m.elementId===t))==null?void 0:h.summary,f=d.useRef(null);return d.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"})]}),u&&s.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:u}),l.length>0&&s.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:l.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:Fc,children:Object.keys(i.data??{}).map(m=>{const x=KS(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)})})),c&&s.jsxs(s.Fragment,{children:[co("Ticket",c.ticket),co("Mandate",c.mandate),co("Approval",c.approval)]}),o&&!c&&s.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",o,"."]})]})}async function fk(e){const{html:t,filename:n}=await e.exportReport();e.download(t,n),await e.refresh()}function Hd({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 mk({report:e,open:t,selectedId:n,onOpenElement:r,detail:a}){const{proof:i,coverage:o}=e,c=ak(e.elements),l=YS(o),u=HS(o),f=VS(o),h=Ud(i.signaturesValid),m=Ud(i.recordsChecked);return s.jsxs("div",{className:`reports-side${t?" reports-side-open":""}`,children:[a,s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"card-title",children:"Proof"}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Tickets referenced"}),s.jsx("b",{children:i.ticketsReferenced.length})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Signatures valid"}),s.jsx("b",{style:h.kind==="ok"?{color:"var(--success)"}:void 0,children:h.text})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Records checked"}),s.jsx("b",{style:m.kind==="ok"?{color:"var(--success)"}:void 0,children:m.text})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Not verifiable"}),s.jsx("b",{children:i.unverifiableCount})]}),c.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"}),u.kind==="error"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"reports-error",role:"alert",children:u.text}),s.jsx(Hd,{detail:u.detail})]}):s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Cases"}),s.jsx("b",{children:u.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(Hd,{detail:f.detail})]}),l&&s.jsx("p",{className:"reports-missing",children:l})]}),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 hk(){const[e,t]=d.useState(null),[n,r]=d.useState(!0),[a,i]=d.useState(null),[o,c]=d.useState(!1),[l,u]=d.useState(!1),[f,h]=d.useState(null),[m,x]=d.useState(!1),[j,v]=d.useState(!1),[S,g]=Sc(),p=d.useCallback(()=>E.getReport().then(({report:T})=>t(T)).catch(T=>i(T instanceof Error?T.message:String(T))),[]),y=d.useCallback(()=>{r(!0),i(null),p().finally(()=>r(!1))},[p]);d.useEffect(()=>{y()},[y]);const w=d.useCallback(()=>{c(!0),E.recheckReport().then(({report:T})=>t(T)).catch(T=>i(T instanceof Error?T.message:String(T))).finally(()=>c(!1))},[]),k=d.useCallback(async()=>{u(!0),h(null);try{await fk({exportReport:()=>E.exportReportWithProof(),download:(T,O)=>{const V=URL.createObjectURL(new Blob([T],{type:"text/html"})),A=document.createElement("a");A.href=V,A.download=O,A.click(),URL.revokeObjectURL(V)},refresh:p})}catch(T){h(T instanceof Error?T.message:String(T))}finally{u(!1)}},[p]),C=S.get("element"),N=S.get("ticket"),R=d.useCallback((T,O)=>{g(rk(S,T,O))},[S,g]),I=d.useCallback(()=>{const T=new URLSearchParams(S);T.delete("element"),T.delete("ticket"),g(T,{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(Ir,{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(Ir,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const L=BS(e.renderedHtml),$=DS(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:L}),s.jsxs("p",{className:"page-subtitle",children:[$?`written by the AI under mandate ${$} · `:"","checked ",US(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:k,disabled:l,children:l?"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:WS(e.proof,e.coverage)}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>x(T=>!T),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"}),XS]}),s.jsxs("span",{className:"reports-legend-chip",children:[s.jsx("span",{className:"reports-sw reports-sw-a"}),ZS," (“",qS,"”)"]}),e.renderedHtmlGloss&&s.jsxs("span",{className:"reports-legend-chip",children:[s.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",ek]})]}),Wd(e)&&s.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:Wd(e)}),e.renderedHtmlGloss&&s.jsxs("label",{className:"reports-gloss-switch",children:[s.jsx("input",{type:"checkbox",role:"switch",checked:j,onChange:T=>v(T.target.checked)}),s.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:s.jsx("span",{className:"reports-gloss-thumb"})}),s.jsx("span",{children:tk})]}),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:QS,srcDoc:ok(nk(e,j)),className:"reports-iframe"})]}),s.jsx(mk,{report:e,open:m||!!C,selectedId:C,onOpenElement:T=>R(T),detail:C?s.jsx(dk,{report:e,elementId:C,ticketParam:N,onClose:I,onSelectTicket:T=>R(C,T)}):void 0})]})]})})}function nr({to:e}){const{search:t,hash:n}=ht();return s.jsx(Xt,{to:`${e}${t}${n}`,replace:!0})}function pk({children:e}){const{user:t,mode:n,domain:r}=Ue();return t?n==="team"&&!r?s.jsx(Xt,{to:"/onboarding",replace:!0}):s.jsx(s.Fragment,{children:e}):s.jsx(Xt,{to:"/login",replace:!0})}function gk(){const{user:e,handleSessionLocked:t,refreshGroups:n}=Ue();return ve("session-locked",r=>{const a=r==null?void 0:r.message;t(a)}),ve("team-membership-changed",()=>{n()}),s.jsxs(Xv,{children:[s.jsx(Se,{path:"/login",element:e?s.jsx(Xt,{to:"/",replace:!0}):s.jsx(M0,{})}),s.jsx(Se,{path:"/onboarding",element:e?s.jsx(V0,{}):s.jsx(Xt,{to:"/login",replace:!0})}),s.jsxs(Se,{element:s.jsx(pk,{children:s.jsx(O0,{})}),children:[s.jsx(Se,{path:"/",element:s.jsx(iw,{})}),s.jsx(Se,{path:"/mandates",element:s.jsx(Sj,{})}),s.jsx(Se,{path:"/mandates/new/intent",element:s.jsx(Aw,{})}),s.jsx(Se,{path:"/mandates/new/sign",element:s.jsx(Kw,{})}),s.jsx(Se,{path:"/integrations",element:s.jsx(ej,{})}),s.jsx(Se,{path:"/team",element:s.jsx(tj,{})}),s.jsx(Se,{path:"/tickets",element:s.jsx(eS,{})}),s.jsx(Se,{path:"/blocked",element:s.jsx(tS,{})}),s.jsx(Se,{path:"/approvals",element:s.jsx(LS,{})}),s.jsx(Se,{path:"/reports",element:s.jsx(hk,{})}),s.jsx(Se,{path:"/agent/new",element:s.jsx(Xt,{to:"/mandates?new=1",replace:!0})}),s.jsx(Se,{path:"/agent/gate",element:s.jsx(nr,{to:"/mandates/new/intent"})}),s.jsx(Se,{path:"/agent/review",element:s.jsx(nr,{to:"/mandates/new/sign"})}),s.jsx(Se,{path:"/authorizations",element:s.jsx(nr,{to:"/mandates"})}),s.jsx(Se,{path:"/groups",element:s.jsx(nr,{to:"/team"})}),s.jsx(Se,{path:"/audit",element:s.jsx(nr,{to:"/tickets"})}),s.jsx(Se,{path:"/proposals",element:s.jsx(nr,{to:"/approvals"})}),s.jsx(Se,{path:"/agent-brief",element:s.jsx(MS,{})}),s.jsx(Se,{path:"/settings",element:s.jsx(dS,{})}),s.jsx(Se,{path:"/settings/services",element:s.jsx(Xt,{to:"/settings",replace:!0})}),s.jsx(Se,{path:"/deploy",element:s.jsx(Xt,{to:"/integrations",replace:!0})})]}),s.jsx(Se,{path:"*",element:s.jsx(Xt,{to:"/",replace:!0})})]})}function yk(){return s.jsx(kx,{children:s.jsx(Fx,{children:s.jsx(Ox,{children:s.jsx(gk,{})})})})}ah(document.getElementById("root")).render(s.jsx(d.StrictMode,{children:s.jsx(yk,{})}));