@suveren/gateway 0.27.1 → 0.28.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 pg=Object.defineProperty;var gg=(t,s,a)=>s in t?pg(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Os=(t,s,a)=>gg(t,typeof s!="symbol"?s+"":s,a);(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&o(h)}).observe(document,{childList:!0,subtree:!0});function a(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function o(c){if(c.ep)return;c.ep=!0;const d=a(c);fetch(c.href,d)}})();var yl={exports:{}},Ms={},vl={exports:{}},Be={};/**
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 Qd;function yg(){if(Qd)return Be;Qd=1;var t=Symbol.for("react.element"),s=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),h=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),w=Symbol.iterator;function j(k){return k===null||typeof k!="object"?null:(k=w&&k[w]||k["@@iterator"],typeof k=="function"?k:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,S={};function C(k,A,K){this.props=k,this.context=A,this.refs=S,this.updater=K||N}C.prototype.isReactComponent={},C.prototype.setState=function(k,A){if(typeof k!="object"&&typeof k!="function"&&k!=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,k,A,"setState")},C.prototype.forceUpdate=function(k){this.updater.enqueueForceUpdate(this,k,"forceUpdate")};function T(){}T.prototype=C.prototype;function R(k,A,K){this.props=k,this.context=A,this.refs=S,this.updater=K||N}var L=R.prototype=new T;L.constructor=R,E(L,C.prototype),L.isPureReactComponent=!0;var P=Array.isArray,F=Object.prototype.hasOwnProperty,G={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function ie(k,A,K){var te,ue={},ve=null,Ce=null;if(A!=null)for(te in A.ref!==void 0&&(Ce=A.ref),A.key!==void 0&&(ve=""+A.key),A)F.call(A,te)&&!H.hasOwnProperty(te)&&(ue[te]=A[te]);var ke=arguments.length-2;if(ke===1)ue.children=K;else if(1<ke){for(var se=Array(ke),Le=0;Le<ke;Le++)se[Le]=arguments[Le+2];ue.children=se}if(k&&k.defaultProps)for(te in ke=k.defaultProps,ke)ue[te]===void 0&&(ue[te]=ke[te]);return{$$typeof:t,type:k,key:ve,ref:Ce,props:ue,_owner:G.current}}function Y(k,A){return{$$typeof:t,type:k.type,key:A,ref:k.ref,props:k.props,_owner:k._owner}}function re(k){return typeof k=="object"&&k!==null&&k.$$typeof===t}function J(k){var A={"=":"=0",":":"=2"};return"$"+k.replace(/[=:]/g,function(K){return A[K]})}var M=/\/+/g;function fe(k,A){return typeof k=="object"&&k!==null&&k.key!=null?J(""+k.key):A.toString(36)}function oe(k,A,K,te,ue){var ve=typeof k;(ve==="undefined"||ve==="boolean")&&(k=null);var Ce=!1;if(k===null)Ce=!0;else switch(ve){case"string":case"number":Ce=!0;break;case"object":switch(k.$$typeof){case t:case s:Ce=!0}}if(Ce)return Ce=k,ue=ue(Ce),k=te===""?"."+fe(Ce,0):te,P(ue)?(K="",k!=null&&(K=k.replace(M,"$&/")+"/"),oe(ue,A,K,"",function(Le){return Le})):ue!=null&&(re(ue)&&(ue=Y(ue,K+(!ue.key||Ce&&Ce.key===ue.key?"":(""+ue.key).replace(M,"$&/")+"/")+k)),A.push(ue)),1;if(Ce=0,te=te===""?".":te+":",P(k))for(var ke=0;ke<k.length;ke++){ve=k[ke];var se=te+fe(ve,ke);Ce+=oe(ve,A,K,se,ue)}else if(se=j(k),typeof se=="function")for(k=se.call(k),ke=0;!(ve=k.next()).done;)ve=ve.value,se=te+fe(ve,ke++),Ce+=oe(ve,A,K,se,ue);else if(ve==="object")throw A=String(k),Error("Objects are not valid as a React child (found: "+(A==="[object Object]"?"object with keys {"+Object.keys(k).join(", ")+"}":A)+"). If you meant to render a collection of children, use an array instead.");return Ce}function Z(k,A,K){if(k==null)return k;var te=[],ue=0;return oe(k,te,"","",function(ve){return A.call(K,ve,ue++)}),te}function pe(k){if(k._status===-1){var A=k._result;A=A(),A.then(function(K){(k._status===0||k._status===-1)&&(k._status=1,k._result=K)},function(K){(k._status===0||k._status===-1)&&(k._status=2,k._result=K)}),k._status===-1&&(k._status=0,k._result=A)}if(k._status===1)return k._result.default;throw k._result}var ee={current:null},W={transition:null},B={ReactCurrentDispatcher:ee,ReactCurrentBatchConfig:W,ReactCurrentOwner:G};function V(){throw Error("act(...) is not supported in production builds of React.")}return Be.Children={map:Z,forEach:function(k,A,K){Z(k,function(){A.apply(this,arguments)},K)},count:function(k){var A=0;return Z(k,function(){A++}),A},toArray:function(k){return Z(k,function(A){return A})||[]},only:function(k){if(!re(k))throw Error("React.Children.only expected to receive a single React element child.");return k}},Be.Component=C,Be.Fragment=a,Be.Profiler=c,Be.PureComponent=R,Be.StrictMode=o,Be.Suspense=p,Be.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=B,Be.act=V,Be.cloneElement=function(k,A,K){if(k==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+k+".");var te=E({},k.props),ue=k.key,ve=k.ref,Ce=k._owner;if(A!=null){if(A.ref!==void 0&&(ve=A.ref,Ce=G.current),A.key!==void 0&&(ue=""+A.key),k.type&&k.type.defaultProps)var ke=k.type.defaultProps;for(se in A)F.call(A,se)&&!H.hasOwnProperty(se)&&(te[se]=A[se]===void 0&&ke!==void 0?ke[se]:A[se])}var se=arguments.length-2;if(se===1)te.children=K;else if(1<se){ke=Array(se);for(var Le=0;Le<se;Le++)ke[Le]=arguments[Le+2];te.children=ke}return{$$typeof:t,type:k.type,key:ue,ref:ve,props:te,_owner:Ce}},Be.createContext=function(k){return k={$$typeof:h,_currentValue:k,_currentValue2:k,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},k.Provider={$$typeof:d,_context:k},k.Consumer=k},Be.createElement=ie,Be.createFactory=function(k){var A=ie.bind(null,k);return A.type=k,A},Be.createRef=function(){return{current:null}},Be.forwardRef=function(k){return{$$typeof:y,render:k}},Be.isValidElement=re,Be.lazy=function(k){return{$$typeof:v,_payload:{_status:-1,_result:k},_init:pe}},Be.memo=function(k,A){return{$$typeof:g,type:k,compare:A===void 0?null:A}},Be.startTransition=function(k){var A=W.transition;W.transition={};try{k()}finally{W.transition=A}},Be.unstable_act=V,Be.useCallback=function(k,A){return ee.current.useCallback(k,A)},Be.useContext=function(k){return ee.current.useContext(k)},Be.useDebugValue=function(){},Be.useDeferredValue=function(k){return ee.current.useDeferredValue(k)},Be.useEffect=function(k,A){return ee.current.useEffect(k,A)},Be.useId=function(){return ee.current.useId()},Be.useImperativeHandle=function(k,A,K){return ee.current.useImperativeHandle(k,A,K)},Be.useInsertionEffect=function(k,A){return ee.current.useInsertionEffect(k,A)},Be.useLayoutEffect=function(k,A){return ee.current.useLayoutEffect(k,A)},Be.useMemo=function(k,A){return ee.current.useMemo(k,A)},Be.useReducer=function(k,A,K){return ee.current.useReducer(k,A,K)},Be.useRef=function(k){return ee.current.useRef(k)},Be.useState=function(k){return ee.current.useState(k)},Be.useSyncExternalStore=function(k,A,K){return ee.current.useSyncExternalStore(k,A,K)},Be.useTransition=function(){return ee.current.useTransition()},Be.version="18.3.1",Be}var Xd;function Gl(){return Xd||(Xd=1,vl.exports=yg()),vl.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 Zd;function vg(){if(Zd)return Ms;Zd=1;var t=Gl(),s=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function h(y,p,g){var v,w={},j=null,N=null;g!==void 0&&(j=""+g),p.key!==void 0&&(j=""+p.key),p.ref!==void 0&&(N=p.ref);for(v in p)o.call(p,v)&&!d.hasOwnProperty(v)&&(w[v]=p[v]);if(y&&y.defaultProps)for(v in p=y.defaultProps,p)w[v]===void 0&&(w[v]=p[v]);return{$$typeof:s,type:y,key:j,ref:N,props:w,_owner:c.current}}return Ms.Fragment=a,Ms.jsx=h,Ms.jsxs=h,Ms}var ef;function xg(){return ef||(ef=1,yl.exports=vg()),yl.exports}var r=xg(),f=Gl(),li={},xl={exports:{}},Bt={},wl={exports:{}},jl={};/**
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
+ */var tf;function wg(){return tf||(tf=1,(function(t){function s(W,B){var V=W.length;W.push(B);e:for(;0<V;){var k=V-1>>>1,A=W[k];if(0<c(A,B))W[k]=B,W[V]=A,V=k;else break e}}function a(W){return W.length===0?null:W[0]}function o(W){if(W.length===0)return null;var B=W[0],V=W.pop();if(V!==B){W[0]=V;e:for(var k=0,A=W.length,K=A>>>1;k<K;){var te=2*(k+1)-1,ue=W[te],ve=te+1,Ce=W[ve];if(0>c(ue,V))ve<A&&0>c(Ce,ue)?(W[k]=Ce,W[ve]=V,k=ve):(W[k]=ue,W[te]=V,k=te);else if(ve<A&&0>c(Ce,V))W[k]=Ce,W[ve]=V,k=ve;else break e}}return B}function c(W,B){var V=W.sortIndex-B.sortIndex;return V!==0?V:W.id-B.id}if(typeof performance=="object"&&typeof performance.now=="function"){var d=performance;t.unstable_now=function(){return d.now()}}else{var h=Date,y=h.now();t.unstable_now=function(){return h.now()-y}}var p=[],g=[],v=1,w=null,j=3,N=!1,E=!1,S=!1,C=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function L(W){for(var B=a(g);B!==null;){if(B.callback===null)o(g);else if(B.startTime<=W)o(g),B.sortIndex=B.expirationTime,s(p,B);else break;B=a(g)}}function P(W){if(S=!1,L(W),!E)if(a(p)!==null)E=!0,pe(F);else{var B=a(g);B!==null&&ee(P,B.startTime-W)}}function F(W,B){E=!1,S&&(S=!1,T(ie),ie=-1),N=!0;var V=j;try{for(L(B),w=a(p);w!==null&&(!(w.expirationTime>B)||W&&!J());){var k=w.callback;if(typeof k=="function"){w.callback=null,j=w.priorityLevel;var A=k(w.expirationTime<=B);B=t.unstable_now(),typeof A=="function"?w.callback=A:w===a(p)&&o(p),L(B)}else o(p);w=a(p)}if(w!==null)var K=!0;else{var te=a(g);te!==null&&ee(P,te.startTime-B),K=!1}return K}finally{w=null,j=V,N=!1}}var G=!1,H=null,ie=-1,Y=5,re=-1;function J(){return!(t.unstable_now()-re<Y)}function M(){if(H!==null){var W=t.unstable_now();re=W;var B=!0;try{B=H(!0,W)}finally{B?fe():(G=!1,H=null)}}else G=!1}var fe;if(typeof R=="function")fe=function(){R(M)};else if(typeof MessageChannel<"u"){var oe=new MessageChannel,Z=oe.port2;oe.port1.onmessage=M,fe=function(){Z.postMessage(null)}}else fe=function(){C(M,0)};function pe(W){H=W,G||(G=!0,fe())}function ee(W,B){ie=C(function(){W(t.unstable_now())},B)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(W){W.callback=null},t.unstable_continueExecution=function(){E||N||(E=!0,pe(F))},t.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Y=0<W?Math.floor(1e3/W):5},t.unstable_getCurrentPriorityLevel=function(){return j},t.unstable_getFirstCallbackNode=function(){return a(p)},t.unstable_next=function(W){switch(j){case 1:case 2:case 3:var B=3;break;default:B=j}var V=j;j=B;try{return W()}finally{j=V}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(W,B){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var V=j;j=W;try{return B()}finally{j=V}},t.unstable_scheduleCallback=function(W,B,V){var k=t.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?k+V:k):V=k,W){case 1:var A=-1;break;case 2:A=250;break;case 5:A=1073741823;break;case 4:A=1e4;break;default:A=5e3}return A=V+A,W={id:v++,callback:B,priorityLevel:W,startTime:V,expirationTime:A,sortIndex:-1},V>k?(W.sortIndex=V,s(g,W),a(p)===null&&W===a(g)&&(S?(T(ie),ie=-1):S=!0,ee(P,V-k))):(W.sortIndex=A,s(p,W),E||N||(E=!0,pe(F))),W},t.unstable_shouldYield=J,t.unstable_wrapCallback=function(W){var B=j;return function(){var V=j;j=B;try{return W.apply(this,arguments)}finally{j=V}}}})(jl)),jl}var nf;function jg(){return nf||(nf=1,wl.exports=wg()),wl.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 rf;function Sg(){if(rf)return Bt;rf=1;var t=Gl(),s=jg();function a(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i<arguments.length;i++)n+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,c={};function d(e,n){h(e,n),h(e+"Capture",n)}function h(e,n){for(c[e]=n,e=0;e<n.length;e++)o.add(n[e])}var y=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,g=/^[: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]*$/,v={},w={};function j(e){return p.call(w,e)?!0:p.call(v,e)?!1:g.test(e)?w[e]=!0:(v[e]=!0,!1)}function N(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function E(e,n,i,l){if(n===null||typeof n>"u"||N(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function S(e,n,i,l,u,m,x){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=u,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=m,this.removeEmptyString=x}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){C[e]=new S(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];C[n]=new S(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){C[e]=new S(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){C[e]=new S(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){C[e]=new S(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){C[e]=new S(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){C[e]=new S(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){C[e]=new S(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){C[e]=new S(e,5,!1,e.toLowerCase(),null,!1,!1)});var T=/[\-:]([a-z])/g;function R(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 n=e.replace(T,R);C[n]=new S(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(T,R);C[n]=new S(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(T,R);C[n]=new S(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){C[e]=new S(e,1,!1,e.toLowerCase(),null,!1,!1)}),C.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){C[e]=new S(e,1,!1,e.toLowerCase(),null,!0,!0)});function L(e,n,i,l){var u=C.hasOwnProperty(n)?C[n]:null;(u!==null?u.type!==0:l||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(E(n,i,u,l)&&(i=null),l||u===null?j(n)&&(i===null?e.removeAttribute(n):e.setAttribute(n,""+i)):u.mustUseProperty?e[u.propertyName]=i===null?u.type===3?!1:"":i:(n=u.attributeName,l=u.attributeNamespace,i===null?e.removeAttribute(n):(u=u.type,i=u===3||u===4&&i===!0?"":""+i,l?e.setAttributeNS(l,n,i):e.setAttribute(n,i))))}var P=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,F=Symbol.for("react.element"),G=Symbol.for("react.portal"),H=Symbol.for("react.fragment"),ie=Symbol.for("react.strict_mode"),Y=Symbol.for("react.profiler"),re=Symbol.for("react.provider"),J=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),fe=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),pe=Symbol.for("react.lazy"),ee=Symbol.for("react.offscreen"),W=Symbol.iterator;function B(e){return e===null||typeof e!="object"?null:(e=W&&e[W]||e["@@iterator"],typeof e=="function"?e:null)}var V=Object.assign,k;function A(e){if(k===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);k=n&&n[1]||""}return`
34
+ `+k+e}var K=!1;function te(e,n){if(!e||K)return"";K=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(U){var l=U}Reflect.construct(e,[],n)}else{try{n.call()}catch(U){l=U}e.call(n.prototype)}else{try{throw Error()}catch(U){l=U}e()}}catch(U){if(U&&l&&typeof U.stack=="string"){for(var u=U.stack.split(`
35
+ `),m=l.stack.split(`
36
+ `),x=u.length-1,b=m.length-1;1<=x&&0<=b&&u[x]!==m[b];)b--;for(;1<=x&&0<=b;x--,b--)if(u[x]!==m[b]){if(x!==1||b!==1)do if(x--,b--,0>b||u[x]!==m[b]){var I=`
37
+ `+u[x].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),I}while(1<=x&&0<=b);break}}}finally{K=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?A(e):""}function ue(e){switch(e.tag){case 5:return A(e.type);case 16:return A("Lazy");case 13:return A("Suspense");case 19:return A("SuspenseList");case 0:case 2:case 15:return e=te(e.type,!1),e;case 11:return e=te(e.type.render,!1),e;case 1:return e=te(e.type,!0),e;default:return""}}function ve(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 H:return"Fragment";case G:return"Portal";case Y:return"Profiler";case ie:return"StrictMode";case fe:return"Suspense";case oe:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case J:return(e.displayName||"Context")+".Consumer";case re:return(e._context.displayName||"Context")+".Provider";case M:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Z:return n=e.displayName||null,n!==null?n:ve(e.type)||"Memo";case pe:n=e._payload,e=e._init;try{return ve(e(n))}catch{}}return null}function Ce(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ve(n);case 8:return n===ie?"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 n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function ke(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Le(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var u=i.get,m=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return u.call(this)},set:function(x){l=""+x,m.call(this,x)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(x){l=""+x},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Ee(e){e._valueTracker||(e._valueTracker=Le(e))}function _e(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function he(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 X(e,n){var i=n.checked;return V({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function we(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=ke(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&L(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=ke(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?xt(e,n.type,i):n.hasOwnProperty("defaultValue")&&xt(e,n.type,ke(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function lt(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function xt(e,n,i){(n!=="number"||he(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Ke=Array.isArray;function et(e,n,i,l){if(e=e.options,n){n={};for(var u=0;u<i.length;u++)n["$"+i[u]]=!0;for(i=0;i<e.length;i++)u=n.hasOwnProperty("$"+e[i].value),e[i].selected!==u&&(e[i].selected=u),u&&l&&(e[i].defaultSelected=!0)}else{for(i=""+ke(i),n=null,u=0;u<e.length;u++){if(e[u].value===i){e[u].selected=!0,l&&(e[u].defaultSelected=!0);return}n!==null||e[u].disabled||(n=e[u])}n!==null&&(n.selected=!0)}}function st(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(a(91));return V({},n,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function mt(e,n){var i=n.value;if(i==null){if(i=n.children,n=n.defaultValue,i!=null){if(n!=null)throw Error(a(92));if(Ke(i)){if(1<i.length)throw Error(a(93));i=i[0]}n=i}n==null&&(n=""),i=n}e._wrapperState={initialValue:ke(i)}}function Fe(e,n){var i=ke(n.value),l=ke(n.defaultValue);i!=null&&(i=""+i,i!==e.value&&(e.value=i),n.defaultValue==null&&e.defaultValue!==i&&(e.defaultValue=i)),l!=null&&(e.defaultValue=""+l)}function $(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!==""&&n!==null&&(e.value=n)}function le(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 me(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?le(n):e==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Re,de=(function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,i,l,u){MSApp.execUnsafeLocalFunction(function(){return e(n,i,l,u)})}:e})(function(e,n){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=n;else{for(Re=Re||document.createElement("div"),Re.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=Re.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Oe(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var Ge={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},Ye=["Webkit","ms","Moz","O"];Object.keys(Ge).forEach(function(e){Ye.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),Ge[n]=Ge[e]})});function ft(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||Ge.hasOwnProperty(e)&&Ge[e]?(""+n).trim():n+"px"}function pn(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,u=ft(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,u):e[i]=u}}var jn=V({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 tt(e,n){if(n){if(jn[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(a(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(a(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(a(61))}if(n.style!=null&&typeof n.style!="object")throw Error(a(62))}}function bt(e,n){if(e.indexOf("-")===-1)return typeof n.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 Et=null;function wt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ae=null,je=null,ge=null;function Me(e){if(e=ks(e)){if(typeof ae!="function")throw Error(a(280));var n=e.stateNode;n&&(n=ka(n),ae(e.stateNode,e.type,n))}}function ze(e){je?ge?ge.push(e):ge=[e]:je=e}function Je(){if(je){var e=je,n=ge;if(ge=je=null,Me(e),n)for(e=0;e<n.length;e++)Me(n[e])}}function Ut(e,n){return e(n)}function er(){}var rs=!1;function ta(e,n,i){if(rs)return e(n,i);rs=!0;try{return Ut(e,n,i)}finally{rs=!1,(je!==null||ge!==null)&&(er(),Je())}}function Sn(e,n){var i=e.stateNode;if(i===null)return null;var l=ka(i);if(l===null)return null;i=l[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(i&&typeof i!="function")throw Error(a(231,n,typeof i));return i}var tr=!1;if(y)try{var nr={};Object.defineProperty(nr,"passive",{get:function(){tr=!0}}),window.addEventListener("test",nr,nr),window.removeEventListener("test",nr,nr)}catch{tr=!1}function na(e,n,i,l,u,m,x,b,I){var U=Array.prototype.slice.call(arguments,3);try{n.apply(i,U)}catch(Q){this.onError(Q)}}var $n=!1,rr=null,sr=!1,ss=null,Cr={onError:function(e){$n=!0,rr=e}};function kn(e,n,i,l,u,m,x,b,I){$n=!1,rr=null,na.apply(Cr,arguments)}function bm(e,n,i,l,u,m,x,b,I){if(kn.apply(this,arguments),$n){if($n){var U=rr;$n=!1,rr=null}else throw Error(a(198));sr||(sr=!0,ss=U)}}function ar(e){var n=e,i=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(i=n.return),e=n.return;while(e)}return n.tag===3?i:null}function wc(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function jc(e){if(ar(e)!==e)throw Error(a(188))}function Nm(e){var n=e.alternate;if(!n){if(n=ar(e),n===null)throw Error(a(188));return n!==e?null:e}for(var i=e,l=n;;){var u=i.return;if(u===null)break;var m=u.alternate;if(m===null){if(l=u.return,l!==null){i=l;continue}break}if(u.child===m.child){for(m=u.child;m;){if(m===i)return jc(u),e;if(m===l)return jc(u),n;m=m.sibling}throw Error(a(188))}if(i.return!==l.return)i=u,l=m;else{for(var x=!1,b=u.child;b;){if(b===i){x=!0,i=u,l=m;break}if(b===l){x=!0,l=u,i=m;break}b=b.sibling}if(!x){for(b=m.child;b;){if(b===i){x=!0,i=m,l=u;break}if(b===l){x=!0,l=m,i=u;break}b=b.sibling}if(!x)throw Error(a(189))}}if(i.alternate!==l)throw Error(a(190))}if(i.tag!==3)throw Error(a(188));return i.stateNode.current===i?e:n}function Sc(e){return e=Nm(e),e!==null?kc(e):null}function kc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var n=kc(e);if(n!==null)return n;e=e.sibling}return null}var bc=s.unstable_scheduleCallback,Nc=s.unstable_cancelCallback,Cm=s.unstable_shouldYield,Em=s.unstable_requestPaint,ct=s.unstable_now,Tm=s.unstable_getCurrentPriorityLevel,zi=s.unstable_ImmediatePriority,Cc=s.unstable_UserBlockingPriority,ra=s.unstable_NormalPriority,Rm=s.unstable_LowPriority,Ec=s.unstable_IdlePriority,sa=null,gn=null;function Im(e){if(gn&&typeof gn.onCommitFiberRoot=="function")try{gn.onCommitFiberRoot(sa,e,void 0,(e.current.flags&128)===128)}catch{}}var sn=Math.clz32?Math.clz32:_m,Am=Math.log,Pm=Math.LN2;function _m(e){return e>>>=0,e===0?32:31-(Am(e)/Pm|0)|0}var aa=64,ia=4194304;function as(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 oa(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,u=e.suspendedLanes,m=e.pingedLanes,x=i&268435455;if(x!==0){var b=x&~u;b!==0?l=as(b):(m&=x,m!==0&&(l=as(m)))}else x=i&~u,x!==0?l=as(x):m!==0&&(l=as(m));if(l===0)return 0;if(n!==0&&n!==l&&(n&u)===0&&(u=l&-l,m=n&-n,u>=m||u===16&&(m&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0<n;)i=31-sn(n),u=1<<i,l|=e[i],n&=~u;return l}function $m(e,n){switch(e){case 1:case 2:case 4:return n+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 n+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 Lm(e,n){for(var i=e.suspendedLanes,l=e.pingedLanes,u=e.expirationTimes,m=e.pendingLanes;0<m;){var x=31-sn(m),b=1<<x,I=u[x];I===-1?((b&i)===0||(b&l)!==0)&&(u[x]=$m(b,n)):I<=n&&(e.expiredLanes|=b),m&=~b}}function Fi(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Tc(){var e=aa;return aa<<=1,(aa&4194240)===0&&(aa=64),e}function Oi(e){for(var n=[],i=0;31>i;i++)n.push(e);return n}function is(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-sn(n),e[n]=i}function zm(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0<i;){var u=31-sn(i),m=1<<u;n[u]=0,l[u]=-1,e[u]=-1,i&=~m}}function Mi(e,n){var i=e.entangledLanes|=n;for(e=e.entanglements;i;){var l=31-sn(i),u=1<<l;u&n|e[l]&n&&(e[l]|=n),i&=~u}}var Ve=0;function Rc(e){return e&=-e,1<e?4<e?(e&268435455)!==0?16:536870912:4:1}var Ic,Bi,Ac,Pc,_c,Di=!1,la=[],Ln=null,zn=null,Fn=null,os=new Map,ls=new Map,On=[],Fm="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 $c(e,n){switch(e){case"focusin":case"focusout":Ln=null;break;case"dragenter":case"dragleave":zn=null;break;case"mouseover":case"mouseout":Fn=null;break;case"pointerover":case"pointerout":os.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":ls.delete(n.pointerId)}}function cs(e,n,i,l,u,m){return e===null||e.nativeEvent!==m?(e={blockedOn:n,domEventName:i,eventSystemFlags:l,nativeEvent:m,targetContainers:[u]},n!==null&&(n=ks(n),n!==null&&Bi(n)),e):(e.eventSystemFlags|=l,n=e.targetContainers,u!==null&&n.indexOf(u)===-1&&n.push(u),e)}function Om(e,n,i,l,u){switch(n){case"focusin":return Ln=cs(Ln,e,n,i,l,u),!0;case"dragenter":return zn=cs(zn,e,n,i,l,u),!0;case"mouseover":return Fn=cs(Fn,e,n,i,l,u),!0;case"pointerover":var m=u.pointerId;return os.set(m,cs(os.get(m)||null,e,n,i,l,u)),!0;case"gotpointercapture":return m=u.pointerId,ls.set(m,cs(ls.get(m)||null,e,n,i,l,u)),!0}return!1}function Lc(e){var n=ir(e.target);if(n!==null){var i=ar(n);if(i!==null){if(n=i.tag,n===13){if(n=wc(i),n!==null){e.blockedOn=n,_c(e.priority,function(){Ac(i)});return}}else if(n===3&&i.stateNode.current.memoizedState.isDehydrated){e.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ca(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var i=Wi(e.domEventName,e.eventSystemFlags,n[0],e.nativeEvent);if(i===null){i=e.nativeEvent;var l=new i.constructor(i.type,i);Et=l,i.target.dispatchEvent(l),Et=null}else return n=ks(i),n!==null&&Bi(n),e.blockedOn=i,!1;n.shift()}return!0}function zc(e,n,i){ca(e)&&i.delete(n)}function Mm(){Di=!1,Ln!==null&&ca(Ln)&&(Ln=null),zn!==null&&ca(zn)&&(zn=null),Fn!==null&&ca(Fn)&&(Fn=null),os.forEach(zc),ls.forEach(zc)}function us(e,n){e.blockedOn===n&&(e.blockedOn=null,Di||(Di=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Mm)))}function ds(e){function n(u){return us(u,e)}if(0<la.length){us(la[0],e);for(var i=1;i<la.length;i++){var l=la[i];l.blockedOn===e&&(l.blockedOn=null)}}for(Ln!==null&&us(Ln,e),zn!==null&&us(zn,e),Fn!==null&&us(Fn,e),os.forEach(n),ls.forEach(n),i=0;i<On.length;i++)l=On[i],l.blockedOn===e&&(l.blockedOn=null);for(;0<On.length&&(i=On[0],i.blockedOn===null);)Lc(i),i.blockedOn===null&&On.shift()}var Er=P.ReactCurrentBatchConfig,ua=!0;function Bm(e,n,i,l){var u=Ve,m=Er.transition;Er.transition=null;try{Ve=1,Ui(e,n,i,l)}finally{Ve=u,Er.transition=m}}function Dm(e,n,i,l){var u=Ve,m=Er.transition;Er.transition=null;try{Ve=4,Ui(e,n,i,l)}finally{Ve=u,Er.transition=m}}function Ui(e,n,i,l){if(ua){var u=Wi(e,n,i,l);if(u===null)io(e,n,l,da,i),$c(e,l);else if(Om(u,e,n,i,l))l.stopPropagation();else if($c(e,l),n&4&&-1<Fm.indexOf(e)){for(;u!==null;){var m=ks(u);if(m!==null&&Ic(m),m=Wi(e,n,i,l),m===null&&io(e,n,l,da,i),m===u)break;u=m}u!==null&&l.stopPropagation()}else io(e,n,l,null,i)}}var da=null;function Wi(e,n,i,l){if(da=null,e=wt(l),e=ir(e),e!==null)if(n=ar(e),n===null)e=null;else if(i=n.tag,i===13){if(e=wc(n),e!==null)return e;e=null}else if(i===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null);return da=e,null}function Fc(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(Tm()){case zi:return 1;case Cc:return 4;case ra:case Rm:return 16;case Ec:return 536870912;default:return 16}default:return 16}}var Mn=null,Hi=null,fa=null;function Oc(){if(fa)return fa;var e,n=Hi,i=n.length,l,u="value"in Mn?Mn.value:Mn.textContent,m=u.length;for(e=0;e<i&&n[e]===u[e];e++);var x=i-e;for(l=1;l<=x&&n[i-l]===u[m-l];l++);return fa=u.slice(e,1<l?1-l:void 0)}function ha(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function ma(){return!0}function Mc(){return!1}function Wt(e){function n(i,l,u,m,x){this._reactName=i,this._targetInst=u,this.type=l,this.nativeEvent=m,this.target=x,this.currentTarget=null;for(var b in e)e.hasOwnProperty(b)&&(i=e[b],this[b]=i?i(m):m[b]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?ma:Mc,this.isPropagationStopped=Mc,this}return V(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=ma)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=ma)},persist:function(){},isPersistent:ma}),n}var Tr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vi=Wt(Tr),fs=V({},Tr,{view:0,detail:0}),Um=Wt(fs),Gi,Ki,hs,pa=V({},fs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ji,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!==hs&&(hs&&e.type==="mousemove"?(Gi=e.screenX-hs.screenX,Ki=e.screenY-hs.screenY):Ki=Gi=0,hs=e),Gi)},movementY:function(e){return"movementY"in e?e.movementY:Ki}}),Bc=Wt(pa),Wm=V({},pa,{dataTransfer:0}),Hm=Wt(Wm),Vm=V({},fs,{relatedTarget:0}),Yi=Wt(Vm),Gm=V({},Tr,{animationName:0,elapsedTime:0,pseudoElement:0}),Km=Wt(Gm),Ym=V({},Tr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Jm=Wt(Ym),qm=V({},Tr,{data:0}),Dc=Wt(qm),Qm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Xm={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"},Zm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ep(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Zm[e])?!!n[e]:!1}function Ji(){return ep}var tp=V({},fs,{key:function(e){if(e.key){var n=Qm[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ha(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Xm[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ji,charCode:function(e){return e.type==="keypress"?ha(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ha(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),np=Wt(tp),rp=V({},pa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Uc=Wt(rp),sp=V({},fs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ji}),ap=Wt(sp),ip=V({},Tr,{propertyName:0,elapsedTime:0,pseudoElement:0}),op=Wt(ip),lp=V({},pa,{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}),cp=Wt(lp),up=[9,13,27,32],qi=y&&"CompositionEvent"in window,ms=null;y&&"documentMode"in document&&(ms=document.documentMode);var dp=y&&"TextEvent"in window&&!ms,Wc=y&&(!qi||ms&&8<ms&&11>=ms),Hc=" ",Vc=!1;function Gc(e,n){switch(e){case"keyup":return up.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Rr=!1;function fp(e,n){switch(e){case"compositionend":return Kc(n);case"keypress":return n.which!==32?null:(Vc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Vc?null:e;default:return null}}function hp(e,n){if(Rr)return e==="compositionend"||!qi&&Gc(e,n)?(e=Oc(),fa=Hi=Mn=null,Rr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Wc&&n.locale!=="ko"?null:n.data;default:return null}}var mp={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 Yc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!mp[e.type]:n==="textarea"}function Jc(e,n,i,l){ze(l),n=wa(n,"onChange"),0<n.length&&(i=new Vi("onChange","change",null,i,l),e.push({event:i,listeners:n}))}var ps=null,gs=null;function pp(e){hu(e,0)}function ga(e){var n=$r(e);if(_e(n))return e}function gp(e,n){if(e==="change")return n}var qc=!1;if(y){var Qi;if(y){var Xi="oninput"in document;if(!Xi){var Qc=document.createElement("div");Qc.setAttribute("oninput","return;"),Xi=typeof Qc.oninput=="function"}Qi=Xi}else Qi=!1;qc=Qi&&(!document.documentMode||9<document.documentMode)}function Xc(){ps&&(ps.detachEvent("onpropertychange",Zc),gs=ps=null)}function Zc(e){if(e.propertyName==="value"&&ga(gs)){var n=[];Jc(n,gs,e,wt(e)),ta(pp,n)}}function yp(e,n,i){e==="focusin"?(Xc(),ps=n,gs=i,ps.attachEvent("onpropertychange",Zc)):e==="focusout"&&Xc()}function vp(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ga(gs)}function xp(e,n){if(e==="click")return ga(n)}function wp(e,n){if(e==="input"||e==="change")return ga(n)}function jp(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var an=typeof Object.is=="function"?Object.is:jp;function ys(e,n){if(an(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var i=Object.keys(e),l=Object.keys(n);if(i.length!==l.length)return!1;for(l=0;l<i.length;l++){var u=i[l];if(!p.call(n,u)||!an(e[u],n[u]))return!1}return!0}function eu(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function tu(e,n){var i=eu(e);e=0;for(var l;i;){if(i.nodeType===3){if(l=e+i.textContent.length,e<=n&&l>=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=eu(i)}}function nu(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?nu(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ru(){for(var e=window,n=he();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=he(e.document)}return n}function Zi(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function Sp(e){var n=ru(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&nu(i.ownerDocument.documentElement,i)){if(l!==null&&Zi(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var u=i.textContent.length,m=Math.min(l.start,u);l=l.end===void 0?m:Math.min(l.end,u),!e.extend&&m>l&&(u=l,l=m,m=u),u=tu(i,m);var x=tu(i,l);u&&x&&(e.rangeCount!==1||e.anchorNode!==u.node||e.anchorOffset!==u.offset||e.focusNode!==x.node||e.focusOffset!==x.offset)&&(n=n.createRange(),n.setStart(u.node,u.offset),e.removeAllRanges(),m>l?(e.addRange(n),e.extend(x.node,x.offset)):(n.setEnd(x.node,x.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<n.length;i++)e=n[i],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var kp=y&&"documentMode"in document&&11>=document.documentMode,Ir=null,eo=null,vs=null,to=!1;function su(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;to||Ir==null||Ir!==he(l)||(l=Ir,"selectionStart"in l&&Zi(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),vs&&ys(vs,l)||(vs=l,l=wa(eo,"onSelect"),0<l.length&&(n=new Vi("onSelect","select",null,n,i),e.push({event:n,listeners:l}),n.target=Ir)))}function ya(e,n){var i={};return i[e.toLowerCase()]=n.toLowerCase(),i["Webkit"+e]="webkit"+n,i["Moz"+e]="moz"+n,i}var Ar={animationend:ya("Animation","AnimationEnd"),animationiteration:ya("Animation","AnimationIteration"),animationstart:ya("Animation","AnimationStart"),transitionend:ya("Transition","TransitionEnd")},no={},au={};y&&(au=document.createElement("div").style,"AnimationEvent"in window||(delete Ar.animationend.animation,delete Ar.animationiteration.animation,delete Ar.animationstart.animation),"TransitionEvent"in window||delete Ar.transitionend.transition);function va(e){if(no[e])return no[e];if(!Ar[e])return e;var n=Ar[e],i;for(i in n)if(n.hasOwnProperty(i)&&i in au)return no[e]=n[i];return e}var iu=va("animationend"),ou=va("animationiteration"),lu=va("animationstart"),cu=va("transitionend"),uu=new Map,du="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 Bn(e,n){uu.set(e,n),d(n,[e])}for(var ro=0;ro<du.length;ro++){var so=du[ro],bp=so.toLowerCase(),Np=so[0].toUpperCase()+so.slice(1);Bn(bp,"on"+Np)}Bn(iu,"onAnimationEnd"),Bn(ou,"onAnimationIteration"),Bn(lu,"onAnimationStart"),Bn("dblclick","onDoubleClick"),Bn("focusin","onFocus"),Bn("focusout","onBlur"),Bn(cu,"onTransitionEnd"),h("onMouseEnter",["mouseout","mouseover"]),h("onMouseLeave",["mouseout","mouseover"]),h("onPointerEnter",["pointerout","pointerover"]),h("onPointerLeave",["pointerout","pointerover"]),d("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),d("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),d("onBeforeInput",["compositionend","keypress","textInput","paste"]),d("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var xs="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(" "),Cp=new Set("cancel close invalid load scroll toggle".split(" ").concat(xs));function fu(e,n,i){var l=e.type||"unknown-event";e.currentTarget=i,bm(l,n,void 0,e),e.currentTarget=null}function hu(e,n){n=(n&4)!==0;for(var i=0;i<e.length;i++){var l=e[i],u=l.event;l=l.listeners;e:{var m=void 0;if(n)for(var x=l.length-1;0<=x;x--){var b=l[x],I=b.instance,U=b.currentTarget;if(b=b.listener,I!==m&&u.isPropagationStopped())break e;fu(u,b,U),m=I}else for(x=0;x<l.length;x++){if(b=l[x],I=b.instance,U=b.currentTarget,b=b.listener,I!==m&&u.isPropagationStopped())break e;fu(u,b,U),m=I}}}if(sr)throw e=ss,sr=!1,ss=null,e}function Xe(e,n){var i=n[ho];i===void 0&&(i=n[ho]=new Set);var l=e+"__bubble";i.has(l)||(mu(n,e,2,!1),i.add(l))}function ao(e,n,i){var l=0;n&&(l|=4),mu(i,e,l,n)}var xa="_reactListening"+Math.random().toString(36).slice(2);function ws(e){if(!e[xa]){e[xa]=!0,o.forEach(function(i){i!=="selectionchange"&&(Cp.has(i)||ao(i,!1,e),ao(i,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[xa]||(n[xa]=!0,ao("selectionchange",!1,n))}}function mu(e,n,i,l){switch(Fc(n)){case 1:var u=Bm;break;case 4:u=Dm;break;default:u=Ui}i=u.bind(null,n,i,e),u=void 0,!tr||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(u=!0),l?u!==void 0?e.addEventListener(n,i,{capture:!0,passive:u}):e.addEventListener(n,i,!0):u!==void 0?e.addEventListener(n,i,{passive:u}):e.addEventListener(n,i,!1)}function io(e,n,i,l,u){var m=l;if((n&1)===0&&(n&2)===0&&l!==null)e:for(;;){if(l===null)return;var x=l.tag;if(x===3||x===4){var b=l.stateNode.containerInfo;if(b===u||b.nodeType===8&&b.parentNode===u)break;if(x===4)for(x=l.return;x!==null;){var I=x.tag;if((I===3||I===4)&&(I=x.stateNode.containerInfo,I===u||I.nodeType===8&&I.parentNode===u))return;x=x.return}for(;b!==null;){if(x=ir(b),x===null)return;if(I=x.tag,I===5||I===6){l=m=x;continue e}b=b.parentNode}}l=l.return}ta(function(){var U=m,Q=wt(i),ne=[];e:{var q=uu.get(e);if(q!==void 0){var ye=Vi,Se=e;switch(e){case"keypress":if(ha(i)===0)break e;case"keydown":case"keyup":ye=np;break;case"focusin":Se="focus",ye=Yi;break;case"focusout":Se="blur",ye=Yi;break;case"beforeblur":case"afterblur":ye=Yi;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ye=Bc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ye=Hm;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ye=ap;break;case iu:case ou:case lu:ye=Km;break;case cu:ye=op;break;case"scroll":ye=Um;break;case"wheel":ye=cp;break;case"copy":case"cut":case"paste":ye=Jm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ye=Uc}var be=(n&4)!==0,ut=!be&&e==="scroll",z=be?q!==null?q+"Capture":null:q;be=[];for(var _=U,O;_!==null;){O=_;var ce=O.stateNode;if(O.tag===5&&ce!==null&&(O=ce,z!==null&&(ce=Sn(_,z),ce!=null&&be.push(js(_,ce,O)))),ut)break;_=_.return}0<be.length&&(q=new ye(q,Se,null,i,Q),ne.push({event:q,listeners:be}))}}if((n&7)===0){e:{if(q=e==="mouseover"||e==="pointerover",ye=e==="mouseout"||e==="pointerout",q&&i!==Et&&(Se=i.relatedTarget||i.fromElement)&&(ir(Se)||Se[bn]))break e;if((ye||q)&&(q=Q.window===Q?Q:(q=Q.ownerDocument)?q.defaultView||q.parentWindow:window,ye?(Se=i.relatedTarget||i.toElement,ye=U,Se=Se?ir(Se):null,Se!==null&&(ut=ar(Se),Se!==ut||Se.tag!==5&&Se.tag!==6)&&(Se=null)):(ye=null,Se=U),ye!==Se)){if(be=Bc,ce="onMouseLeave",z="onMouseEnter",_="mouse",(e==="pointerout"||e==="pointerover")&&(be=Uc,ce="onPointerLeave",z="onPointerEnter",_="pointer"),ut=ye==null?q:$r(ye),O=Se==null?q:$r(Se),q=new be(ce,_+"leave",ye,i,Q),q.target=ut,q.relatedTarget=O,ce=null,ir(Q)===U&&(be=new be(z,_+"enter",Se,i,Q),be.target=O,be.relatedTarget=ut,ce=be),ut=ce,ye&&Se)t:{for(be=ye,z=Se,_=0,O=be;O;O=Pr(O))_++;for(O=0,ce=z;ce;ce=Pr(ce))O++;for(;0<_-O;)be=Pr(be),_--;for(;0<O-_;)z=Pr(z),O--;for(;_--;){if(be===z||z!==null&&be===z.alternate)break t;be=Pr(be),z=Pr(z)}be=null}else be=null;ye!==null&&pu(ne,q,ye,be,!1),Se!==null&&ut!==null&&pu(ne,ut,Se,be,!0)}}e:{if(q=U?$r(U):window,ye=q.nodeName&&q.nodeName.toLowerCase(),ye==="select"||ye==="input"&&q.type==="file")var Ne=gp;else if(Yc(q))if(qc)Ne=wp;else{Ne=vp;var Ie=yp}else(ye=q.nodeName)&&ye.toLowerCase()==="input"&&(q.type==="checkbox"||q.type==="radio")&&(Ne=xp);if(Ne&&(Ne=Ne(e,U))){Jc(ne,Ne,i,Q);break e}Ie&&Ie(e,q,U),e==="focusout"&&(Ie=q._wrapperState)&&Ie.controlled&&q.type==="number"&&xt(q,"number",q.value)}switch(Ie=U?$r(U):window,e){case"focusin":(Yc(Ie)||Ie.contentEditable==="true")&&(Ir=Ie,eo=U,vs=null);break;case"focusout":vs=eo=Ir=null;break;case"mousedown":to=!0;break;case"contextmenu":case"mouseup":case"dragend":to=!1,su(ne,i,Q);break;case"selectionchange":if(kp)break;case"keydown":case"keyup":su(ne,i,Q)}var Ae;if(qi)e:{switch(e){case"compositionstart":var Pe="onCompositionStart";break e;case"compositionend":Pe="onCompositionEnd";break e;case"compositionupdate":Pe="onCompositionUpdate";break e}Pe=void 0}else Rr?Gc(e,i)&&(Pe="onCompositionEnd"):e==="keydown"&&i.keyCode===229&&(Pe="onCompositionStart");Pe&&(Wc&&i.locale!=="ko"&&(Rr||Pe!=="onCompositionStart"?Pe==="onCompositionEnd"&&Rr&&(Ae=Oc()):(Mn=Q,Hi="value"in Mn?Mn.value:Mn.textContent,Rr=!0)),Ie=wa(U,Pe),0<Ie.length&&(Pe=new Dc(Pe,e,null,i,Q),ne.push({event:Pe,listeners:Ie}),Ae?Pe.data=Ae:(Ae=Kc(i),Ae!==null&&(Pe.data=Ae)))),(Ae=dp?fp(e,i):hp(e,i))&&(U=wa(U,"onBeforeInput"),0<U.length&&(Q=new Dc("onBeforeInput","beforeinput",null,i,Q),ne.push({event:Q,listeners:U}),Q.data=Ae))}hu(ne,n)})}function js(e,n,i){return{instance:e,listener:n,currentTarget:i}}function wa(e,n){for(var i=n+"Capture",l=[];e!==null;){var u=e,m=u.stateNode;u.tag===5&&m!==null&&(u=m,m=Sn(e,i),m!=null&&l.unshift(js(e,m,u)),m=Sn(e,n),m!=null&&l.push(js(e,m,u))),e=e.return}return l}function Pr(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function pu(e,n,i,l,u){for(var m=n._reactName,x=[];i!==null&&i!==l;){var b=i,I=b.alternate,U=b.stateNode;if(I!==null&&I===l)break;b.tag===5&&U!==null&&(b=U,u?(I=Sn(i,m),I!=null&&x.unshift(js(i,I,b))):u||(I=Sn(i,m),I!=null&&x.push(js(i,I,b)))),i=i.return}x.length!==0&&e.push({event:n,listeners:x})}var Ep=/\r\n?/g,Tp=/\u0000|\uFFFD/g;function gu(e){return(typeof e=="string"?e:""+e).replace(Ep,`
38
+ `).replace(Tp,"")}function ja(e,n,i){if(n=gu(n),gu(e)!==n&&i)throw Error(a(425))}function Sa(){}var oo=null,lo=null;function co(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var uo=typeof setTimeout=="function"?setTimeout:void 0,Rp=typeof clearTimeout=="function"?clearTimeout:void 0,yu=typeof Promise=="function"?Promise:void 0,Ip=typeof queueMicrotask=="function"?queueMicrotask:typeof yu<"u"?function(e){return yu.resolve(null).then(e).catch(Ap)}:uo;function Ap(e){setTimeout(function(){throw e})}function fo(e,n){var i=n,l=0;do{var u=i.nextSibling;if(e.removeChild(i),u&&u.nodeType===8)if(i=u.data,i==="/$"){if(l===0){e.removeChild(u),ds(n);return}l--}else i!=="$"&&i!=="$?"&&i!=="$!"||l++;i=u}while(i);ds(n)}function Dn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?")break;if(n==="/$")return null}}return e}function vu(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var i=e.data;if(i==="$"||i==="$!"||i==="$?"){if(n===0)return e;n--}else i==="/$"&&n++}e=e.previousSibling}return null}var _r=Math.random().toString(36).slice(2),yn="__reactFiber$"+_r,Ss="__reactProps$"+_r,bn="__reactContainer$"+_r,ho="__reactEvents$"+_r,Pp="__reactListeners$"+_r,_p="__reactHandles$"+_r;function ir(e){var n=e[yn];if(n)return n;for(var i=e.parentNode;i;){if(n=i[bn]||i[yn]){if(i=n.alternate,n.child!==null||i!==null&&i.child!==null)for(e=vu(e);e!==null;){if(i=e[yn])return i;e=vu(e)}return n}e=i,i=e.parentNode}return null}function ks(e){return e=e[yn]||e[bn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function $r(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(a(33))}function ka(e){return e[Ss]||null}var mo=[],Lr=-1;function Un(e){return{current:e}}function Ze(e){0>Lr||(e.current=mo[Lr],mo[Lr]=null,Lr--)}function qe(e,n){Lr++,mo[Lr]=e.current,e.current=n}var Wn={},Tt=Un(Wn),Lt=Un(!1),or=Wn;function zr(e,n){var i=e.type.contextTypes;if(!i)return Wn;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var u={},m;for(m in i)u[m]=n[m];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=u),u}function zt(e){return e=e.childContextTypes,e!=null}function ba(){Ze(Lt),Ze(Tt)}function xu(e,n,i){if(Tt.current!==Wn)throw Error(a(168));qe(Tt,n),qe(Lt,i)}function wu(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var u in l)if(!(u in n))throw Error(a(108,Ce(e)||"Unknown",u));return V({},i,l)}function Na(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Wn,or=Tt.current,qe(Tt,e),qe(Lt,Lt.current),!0}function ju(e,n,i){var l=e.stateNode;if(!l)throw Error(a(169));i?(e=wu(e,n,or),l.__reactInternalMemoizedMergedChildContext=e,Ze(Lt),Ze(Tt),qe(Tt,e)):Ze(Lt),qe(Lt,i)}var Nn=null,Ca=!1,po=!1;function Su(e){Nn===null?Nn=[e]:Nn.push(e)}function $p(e){Ca=!0,Su(e)}function Hn(){if(!po&&Nn!==null){po=!0;var e=0,n=Ve;try{var i=Nn;for(Ve=1;e<i.length;e++){var l=i[e];do l=l(!0);while(l!==null)}Nn=null,Ca=!1}catch(u){throw Nn!==null&&(Nn=Nn.slice(e+1)),bc(zi,Hn),u}finally{Ve=n,po=!1}}return null}var Fr=[],Or=0,Ea=null,Ta=0,Jt=[],qt=0,lr=null,Cn=1,En="";function cr(e,n){Fr[Or++]=Ta,Fr[Or++]=Ea,Ea=e,Ta=n}function ku(e,n,i){Jt[qt++]=Cn,Jt[qt++]=En,Jt[qt++]=lr,lr=e;var l=Cn;e=En;var u=32-sn(l)-1;l&=~(1<<u),i+=1;var m=32-sn(n)+u;if(30<m){var x=u-u%5;m=(l&(1<<x)-1).toString(32),l>>=x,u-=x,Cn=1<<32-sn(n)+u|i<<u|l,En=m+e}else Cn=1<<m|i<<u|l,En=e}function go(e){e.return!==null&&(cr(e,1),ku(e,1,0))}function yo(e){for(;e===Ea;)Ea=Fr[--Or],Fr[Or]=null,Ta=Fr[--Or],Fr[Or]=null;for(;e===lr;)lr=Jt[--qt],Jt[qt]=null,En=Jt[--qt],Jt[qt]=null,Cn=Jt[--qt],Jt[qt]=null}var Ht=null,Vt=null,nt=!1,on=null;function bu(e,n){var i=en(5,null,null,0);i.elementType="DELETED",i.stateNode=n,i.return=e,n=e.deletions,n===null?(e.deletions=[i],e.flags|=16):n.push(i)}function Nu(e,n){switch(e.tag){case 5:var i=e.type;return n=n.nodeType!==1||i.toLowerCase()!==n.nodeName.toLowerCase()?null:n,n!==null?(e.stateNode=n,Ht=e,Vt=Dn(n.firstChild),!0):!1;case 6:return n=e.pendingProps===""||n.nodeType!==3?null:n,n!==null?(e.stateNode=n,Ht=e,Vt=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(i=lr!==null?{id:Cn,overflow:En}:null,e.memoizedState={dehydrated:n,treeContext:i,retryLane:1073741824},i=en(18,null,null,0),i.stateNode=n,i.return=e,e.child=i,Ht=e,Vt=null,!0):!1;default:return!1}}function vo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function xo(e){if(nt){var n=Vt;if(n){var i=n;if(!Nu(e,n)){if(vo(e))throw Error(a(418));n=Dn(i.nextSibling);var l=Ht;n&&Nu(e,n)?bu(l,i):(e.flags=e.flags&-4097|2,nt=!1,Ht=e)}}else{if(vo(e))throw Error(a(418));e.flags=e.flags&-4097|2,nt=!1,Ht=e}}}function Cu(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Ht=e}function Ra(e){if(e!==Ht)return!1;if(!nt)return Cu(e),nt=!0,!1;var n;if((n=e.tag!==3)&&!(n=e.tag!==5)&&(n=e.type,n=n!=="head"&&n!=="body"&&!co(e.type,e.memoizedProps)),n&&(n=Vt)){if(vo(e))throw Eu(),Error(a(418));for(;n;)bu(e,n),n=Dn(n.nextSibling)}if(Cu(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8){var i=e.data;if(i==="/$"){if(n===0){Vt=Dn(e.nextSibling);break e}n--}else i!=="$"&&i!=="$!"&&i!=="$?"||n++}e=e.nextSibling}Vt=null}}else Vt=Ht?Dn(e.stateNode.nextSibling):null;return!0}function Eu(){for(var e=Vt;e;)e=Dn(e.nextSibling)}function Mr(){Vt=Ht=null,nt=!1}function wo(e){on===null?on=[e]:on.push(e)}var Lp=P.ReactCurrentBatchConfig;function bs(e,n,i){if(e=i.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(a(309));var l=i.stateNode}if(!l)throw Error(a(147,e));var u=l,m=""+e;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===m?n.ref:(n=function(x){var b=u.refs;x===null?delete b[m]:b[m]=x},n._stringRef=m,n)}if(typeof e!="string")throw Error(a(284));if(!i._owner)throw Error(a(290,e))}return e}function Ia(e,n){throw e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e))}function Tu(e){var n=e._init;return n(e._payload)}function Ru(e){function n(z,_){if(e){var O=z.deletions;O===null?(z.deletions=[_],z.flags|=16):O.push(_)}}function i(z,_){if(!e)return null;for(;_!==null;)n(z,_),_=_.sibling;return null}function l(z,_){for(z=new Map;_!==null;)_.key!==null?z.set(_.key,_):z.set(_.index,_),_=_.sibling;return z}function u(z,_){return z=Xn(z,_),z.index=0,z.sibling=null,z}function m(z,_,O){return z.index=O,e?(O=z.alternate,O!==null?(O=O.index,O<_?(z.flags|=2,_):O):(z.flags|=2,_)):(z.flags|=1048576,_)}function x(z){return e&&z.alternate===null&&(z.flags|=2),z}function b(z,_,O,ce){return _===null||_.tag!==6?(_=dl(O,z.mode,ce),_.return=z,_):(_=u(_,O),_.return=z,_)}function I(z,_,O,ce){var Ne=O.type;return Ne===H?Q(z,_,O.props.children,ce,O.key):_!==null&&(_.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===pe&&Tu(Ne)===_.type)?(ce=u(_,O.props),ce.ref=bs(z,_,O),ce.return=z,ce):(ce=ei(O.type,O.key,O.props,null,z.mode,ce),ce.ref=bs(z,_,O),ce.return=z,ce)}function U(z,_,O,ce){return _===null||_.tag!==4||_.stateNode.containerInfo!==O.containerInfo||_.stateNode.implementation!==O.implementation?(_=fl(O,z.mode,ce),_.return=z,_):(_=u(_,O.children||[]),_.return=z,_)}function Q(z,_,O,ce,Ne){return _===null||_.tag!==7?(_=yr(O,z.mode,ce,Ne),_.return=z,_):(_=u(_,O),_.return=z,_)}function ne(z,_,O){if(typeof _=="string"&&_!==""||typeof _=="number")return _=dl(""+_,z.mode,O),_.return=z,_;if(typeof _=="object"&&_!==null){switch(_.$$typeof){case F:return O=ei(_.type,_.key,_.props,null,z.mode,O),O.ref=bs(z,null,_),O.return=z,O;case G:return _=fl(_,z.mode,O),_.return=z,_;case pe:var ce=_._init;return ne(z,ce(_._payload),O)}if(Ke(_)||B(_))return _=yr(_,z.mode,O,null),_.return=z,_;Ia(z,_)}return null}function q(z,_,O,ce){var Ne=_!==null?_.key:null;if(typeof O=="string"&&O!==""||typeof O=="number")return Ne!==null?null:b(z,_,""+O,ce);if(typeof O=="object"&&O!==null){switch(O.$$typeof){case F:return O.key===Ne?I(z,_,O,ce):null;case G:return O.key===Ne?U(z,_,O,ce):null;case pe:return Ne=O._init,q(z,_,Ne(O._payload),ce)}if(Ke(O)||B(O))return Ne!==null?null:Q(z,_,O,ce,null);Ia(z,O)}return null}function ye(z,_,O,ce,Ne){if(typeof ce=="string"&&ce!==""||typeof ce=="number")return z=z.get(O)||null,b(_,z,""+ce,Ne);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case F:return z=z.get(ce.key===null?O:ce.key)||null,I(_,z,ce,Ne);case G:return z=z.get(ce.key===null?O:ce.key)||null,U(_,z,ce,Ne);case pe:var Ie=ce._init;return ye(z,_,O,Ie(ce._payload),Ne)}if(Ke(ce)||B(ce))return z=z.get(O)||null,Q(_,z,ce,Ne,null);Ia(_,ce)}return null}function Se(z,_,O,ce){for(var Ne=null,Ie=null,Ae=_,Pe=_=0,kt=null;Ae!==null&&Pe<O.length;Pe++){Ae.index>Pe?(kt=Ae,Ae=null):kt=Ae.sibling;var We=q(z,Ae,O[Pe],ce);if(We===null){Ae===null&&(Ae=kt);break}e&&Ae&&We.alternate===null&&n(z,Ae),_=m(We,_,Pe),Ie===null?Ne=We:Ie.sibling=We,Ie=We,Ae=kt}if(Pe===O.length)return i(z,Ae),nt&&cr(z,Pe),Ne;if(Ae===null){for(;Pe<O.length;Pe++)Ae=ne(z,O[Pe],ce),Ae!==null&&(_=m(Ae,_,Pe),Ie===null?Ne=Ae:Ie.sibling=Ae,Ie=Ae);return nt&&cr(z,Pe),Ne}for(Ae=l(z,Ae);Pe<O.length;Pe++)kt=ye(Ae,z,Pe,O[Pe],ce),kt!==null&&(e&&kt.alternate!==null&&Ae.delete(kt.key===null?Pe:kt.key),_=m(kt,_,Pe),Ie===null?Ne=kt:Ie.sibling=kt,Ie=kt);return e&&Ae.forEach(function(Zn){return n(z,Zn)}),nt&&cr(z,Pe),Ne}function be(z,_,O,ce){var Ne=B(O);if(typeof Ne!="function")throw Error(a(150));if(O=Ne.call(O),O==null)throw Error(a(151));for(var Ie=Ne=null,Ae=_,Pe=_=0,kt=null,We=O.next();Ae!==null&&!We.done;Pe++,We=O.next()){Ae.index>Pe?(kt=Ae,Ae=null):kt=Ae.sibling;var Zn=q(z,Ae,We.value,ce);if(Zn===null){Ae===null&&(Ae=kt);break}e&&Ae&&Zn.alternate===null&&n(z,Ae),_=m(Zn,_,Pe),Ie===null?Ne=Zn:Ie.sibling=Zn,Ie=Zn,Ae=kt}if(We.done)return i(z,Ae),nt&&cr(z,Pe),Ne;if(Ae===null){for(;!We.done;Pe++,We=O.next())We=ne(z,We.value,ce),We!==null&&(_=m(We,_,Pe),Ie===null?Ne=We:Ie.sibling=We,Ie=We);return nt&&cr(z,Pe),Ne}for(Ae=l(z,Ae);!We.done;Pe++,We=O.next())We=ye(Ae,z,Pe,We.value,ce),We!==null&&(e&&We.alternate!==null&&Ae.delete(We.key===null?Pe:We.key),_=m(We,_,Pe),Ie===null?Ne=We:Ie.sibling=We,Ie=We);return e&&Ae.forEach(function(mg){return n(z,mg)}),nt&&cr(z,Pe),Ne}function ut(z,_,O,ce){if(typeof O=="object"&&O!==null&&O.type===H&&O.key===null&&(O=O.props.children),typeof O=="object"&&O!==null){switch(O.$$typeof){case F:e:{for(var Ne=O.key,Ie=_;Ie!==null;){if(Ie.key===Ne){if(Ne=O.type,Ne===H){if(Ie.tag===7){i(z,Ie.sibling),_=u(Ie,O.props.children),_.return=z,z=_;break e}}else if(Ie.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===pe&&Tu(Ne)===Ie.type){i(z,Ie.sibling),_=u(Ie,O.props),_.ref=bs(z,Ie,O),_.return=z,z=_;break e}i(z,Ie);break}else n(z,Ie);Ie=Ie.sibling}O.type===H?(_=yr(O.props.children,z.mode,ce,O.key),_.return=z,z=_):(ce=ei(O.type,O.key,O.props,null,z.mode,ce),ce.ref=bs(z,_,O),ce.return=z,z=ce)}return x(z);case G:e:{for(Ie=O.key;_!==null;){if(_.key===Ie)if(_.tag===4&&_.stateNode.containerInfo===O.containerInfo&&_.stateNode.implementation===O.implementation){i(z,_.sibling),_=u(_,O.children||[]),_.return=z,z=_;break e}else{i(z,_);break}else n(z,_);_=_.sibling}_=fl(O,z.mode,ce),_.return=z,z=_}return x(z);case pe:return Ie=O._init,ut(z,_,Ie(O._payload),ce)}if(Ke(O))return Se(z,_,O,ce);if(B(O))return be(z,_,O,ce);Ia(z,O)}return typeof O=="string"&&O!==""||typeof O=="number"?(O=""+O,_!==null&&_.tag===6?(i(z,_.sibling),_=u(_,O),_.return=z,z=_):(i(z,_),_=dl(O,z.mode,ce),_.return=z,z=_),x(z)):i(z,_)}return ut}var Br=Ru(!0),Iu=Ru(!1),Aa=Un(null),Pa=null,Dr=null,jo=null;function So(){jo=Dr=Pa=null}function ko(e){var n=Aa.current;Ze(Aa),e._currentValue=n}function bo(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Ur(e,n){Pa=e,jo=Dr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Ft=!0),e.firstContext=null)}function Qt(e){var n=e._currentValue;if(jo!==e)if(e={context:e,memoizedValue:n,next:null},Dr===null){if(Pa===null)throw Error(a(308));Dr=e,Pa.dependencies={lanes:0,firstContext:e}}else Dr=Dr.next=e;return n}var ur=null;function No(e){ur===null?ur=[e]:ur.push(e)}function Au(e,n,i,l){var u=n.interleaved;return u===null?(i.next=i,No(n)):(i.next=u.next,u.next=i),n.interleaved=i,Tn(e,l)}function Tn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var Vn=!1;function Co(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Pu(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Rn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Gn(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Ue&2)!==0){var u=l.pending;return u===null?n.next=n:(n.next=u.next,u.next=n),l.pending=n,Tn(e,i)}return u=l.interleaved,u===null?(n.next=n,No(l)):(n.next=u.next,u.next=n),l.interleaved=n,Tn(e,i)}function _a(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Mi(e,i)}}function _u(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var u=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var x={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};m===null?u=m=x:m=m.next=x,i=i.next}while(i!==null);m===null?u=m=n:m=m.next=n}else u=m=n;i={baseState:l.baseState,firstBaseUpdate:u,lastBaseUpdate:m,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function $a(e,n,i,l){var u=e.updateQueue;Vn=!1;var m=u.firstBaseUpdate,x=u.lastBaseUpdate,b=u.shared.pending;if(b!==null){u.shared.pending=null;var I=b,U=I.next;I.next=null,x===null?m=U:x.next=U,x=I;var Q=e.alternate;Q!==null&&(Q=Q.updateQueue,b=Q.lastBaseUpdate,b!==x&&(b===null?Q.firstBaseUpdate=U:b.next=U,Q.lastBaseUpdate=I))}if(m!==null){var ne=u.baseState;x=0,Q=U=I=null,b=m;do{var q=b.lane,ye=b.eventTime;if((l&q)===q){Q!==null&&(Q=Q.next={eventTime:ye,lane:0,tag:b.tag,payload:b.payload,callback:b.callback,next:null});e:{var Se=e,be=b;switch(q=n,ye=i,be.tag){case 1:if(Se=be.payload,typeof Se=="function"){ne=Se.call(ye,ne,q);break e}ne=Se;break e;case 3:Se.flags=Se.flags&-65537|128;case 0:if(Se=be.payload,q=typeof Se=="function"?Se.call(ye,ne,q):Se,q==null)break e;ne=V({},ne,q);break e;case 2:Vn=!0}}b.callback!==null&&b.lane!==0&&(e.flags|=64,q=u.effects,q===null?u.effects=[b]:q.push(b))}else ye={eventTime:ye,lane:q,tag:b.tag,payload:b.payload,callback:b.callback,next:null},Q===null?(U=Q=ye,I=ne):Q=Q.next=ye,x|=q;if(b=b.next,b===null){if(b=u.shared.pending,b===null)break;q=b,b=q.next,q.next=null,u.lastBaseUpdate=q,u.shared.pending=null}}while(!0);if(Q===null&&(I=ne),u.baseState=I,u.firstBaseUpdate=U,u.lastBaseUpdate=Q,n=u.shared.interleaved,n!==null){u=n;do x|=u.lane,u=u.next;while(u!==n)}else m===null&&(u.shared.lanes=0);hr|=x,e.lanes=x,e.memoizedState=ne}}function $u(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.length;n++){var l=e[n],u=l.callback;if(u!==null){if(l.callback=null,l=i,typeof u!="function")throw Error(a(191,u));u.call(l)}}}var Ns={},vn=Un(Ns),Cs=Un(Ns),Es=Un(Ns);function dr(e){if(e===Ns)throw Error(a(174));return e}function Eo(e,n){switch(qe(Es,n),qe(Cs,e),qe(vn,Ns),e=n.nodeType,e){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:me(null,"");break;default:e=e===8?n.parentNode:n,n=e.namespaceURI||null,e=e.tagName,n=me(n,e)}Ze(vn),qe(vn,n)}function Wr(){Ze(vn),Ze(Cs),Ze(Es)}function Lu(e){dr(Es.current);var n=dr(vn.current),i=me(n,e.type);n!==i&&(qe(Cs,e),qe(vn,i))}function To(e){Cs.current===e&&(Ze(vn),Ze(Cs))}var at=Un(0);function La(e){for(var n=e;n!==null;){if(n.tag===13){var i=n.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Ro=[];function Io(){for(var e=0;e<Ro.length;e++)Ro[e]._workInProgressVersionPrimary=null;Ro.length=0}var za=P.ReactCurrentDispatcher,Ao=P.ReactCurrentBatchConfig,fr=0,it=null,pt=null,jt=null,Fa=!1,Ts=!1,Rs=0,zp=0;function Rt(){throw Error(a(321))}function Po(e,n){if(n===null)return!1;for(var i=0;i<n.length&&i<e.length;i++)if(!an(e[i],n[i]))return!1;return!0}function _o(e,n,i,l,u,m){if(fr=m,it=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,za.current=e===null||e.memoizedState===null?Bp:Dp,e=i(l,u),Ts){m=0;do{if(Ts=!1,Rs=0,25<=m)throw Error(a(301));m+=1,jt=pt=null,n.updateQueue=null,za.current=Up,e=i(l,u)}while(Ts)}if(za.current=Ba,n=pt!==null&&pt.next!==null,fr=0,jt=pt=it=null,Fa=!1,n)throw Error(a(300));return e}function $o(){var e=Rs!==0;return Rs=0,e}function xn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jt===null?it.memoizedState=jt=e:jt=jt.next=e,jt}function Xt(){if(pt===null){var e=it.alternate;e=e!==null?e.memoizedState:null}else e=pt.next;var n=jt===null?it.memoizedState:jt.next;if(n!==null)jt=n,pt=e;else{if(e===null)throw Error(a(310));pt=e,e={memoizedState:pt.memoizedState,baseState:pt.baseState,baseQueue:pt.baseQueue,queue:pt.queue,next:null},jt===null?it.memoizedState=jt=e:jt=jt.next=e}return jt}function Is(e,n){return typeof n=="function"?n(e):n}function Lo(e){var n=Xt(),i=n.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var l=pt,u=l.baseQueue,m=i.pending;if(m!==null){if(u!==null){var x=u.next;u.next=m.next,m.next=x}l.baseQueue=u=m,i.pending=null}if(u!==null){m=u.next,l=l.baseState;var b=x=null,I=null,U=m;do{var Q=U.lane;if((fr&Q)===Q)I!==null&&(I=I.next={lane:0,action:U.action,hasEagerState:U.hasEagerState,eagerState:U.eagerState,next:null}),l=U.hasEagerState?U.eagerState:e(l,U.action);else{var ne={lane:Q,action:U.action,hasEagerState:U.hasEagerState,eagerState:U.eagerState,next:null};I===null?(b=I=ne,x=l):I=I.next=ne,it.lanes|=Q,hr|=Q}U=U.next}while(U!==null&&U!==m);I===null?x=l:I.next=b,an(l,n.memoizedState)||(Ft=!0),n.memoizedState=l,n.baseState=x,n.baseQueue=I,i.lastRenderedState=l}if(e=i.interleaved,e!==null){u=e;do m=u.lane,it.lanes|=m,hr|=m,u=u.next;while(u!==e)}else u===null&&(i.lanes=0);return[n.memoizedState,i.dispatch]}function zo(e){var n=Xt(),i=n.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var l=i.dispatch,u=i.pending,m=n.memoizedState;if(u!==null){i.pending=null;var x=u=u.next;do m=e(m,x.action),x=x.next;while(x!==u);an(m,n.memoizedState)||(Ft=!0),n.memoizedState=m,n.baseQueue===null&&(n.baseState=m),i.lastRenderedState=m}return[m,l]}function zu(){}function Fu(e,n){var i=it,l=Xt(),u=n(),m=!an(l.memoizedState,u);if(m&&(l.memoizedState=u,Ft=!0),l=l.queue,Fo(Bu.bind(null,i,l,e),[e]),l.getSnapshot!==n||m||jt!==null&&jt.memoizedState.tag&1){if(i.flags|=2048,As(9,Mu.bind(null,i,l,u,n),void 0,null),St===null)throw Error(a(349));(fr&30)!==0||Ou(i,n,u)}return u}function Ou(e,n,i){e.flags|=16384,e={getSnapshot:n,value:i},n=it.updateQueue,n===null?(n={lastEffect:null,stores:null},it.updateQueue=n,n.stores=[e]):(i=n.stores,i===null?n.stores=[e]:i.push(e))}function Mu(e,n,i,l){n.value=i,n.getSnapshot=l,Du(n)&&Uu(e)}function Bu(e,n,i){return i(function(){Du(n)&&Uu(e)})}function Du(e){var n=e.getSnapshot;e=e.value;try{var i=n();return!an(e,i)}catch{return!0}}function Uu(e){var n=Tn(e,1);n!==null&&dn(n,e,1,-1)}function Wu(e){var n=xn();return typeof e=="function"&&(e=e()),n.memoizedState=n.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Is,lastRenderedState:e},n.queue=e,e=e.dispatch=Mp.bind(null,it,e),[n.memoizedState,e]}function As(e,n,i,l){return e={tag:e,create:n,destroy:i,deps:l,next:null},n=it.updateQueue,n===null?(n={lastEffect:null,stores:null},it.updateQueue=n,n.lastEffect=e.next=e):(i=n.lastEffect,i===null?n.lastEffect=e.next=e:(l=i.next,i.next=e,e.next=l,n.lastEffect=e)),e}function Hu(){return Xt().memoizedState}function Oa(e,n,i,l){var u=xn();it.flags|=e,u.memoizedState=As(1|n,i,void 0,l===void 0?null:l)}function Ma(e,n,i,l){var u=Xt();l=l===void 0?null:l;var m=void 0;if(pt!==null){var x=pt.memoizedState;if(m=x.destroy,l!==null&&Po(l,x.deps)){u.memoizedState=As(n,i,m,l);return}}it.flags|=e,u.memoizedState=As(1|n,i,m,l)}function Vu(e,n){return Oa(8390656,8,e,n)}function Fo(e,n){return Ma(2048,8,e,n)}function Gu(e,n){return Ma(4,2,e,n)}function Ku(e,n){return Ma(4,4,e,n)}function Yu(e,n){if(typeof n=="function")return e=e(),n(e),function(){n(null)};if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function Ju(e,n,i){return i=i!=null?i.concat([e]):null,Ma(4,4,Yu.bind(null,n,e),i)}function Oo(){}function qu(e,n){var i=Xt();n=n===void 0?null:n;var l=i.memoizedState;return l!==null&&n!==null&&Po(n,l[1])?l[0]:(i.memoizedState=[e,n],e)}function Qu(e,n){var i=Xt();n=n===void 0?null:n;var l=i.memoizedState;return l!==null&&n!==null&&Po(n,l[1])?l[0]:(e=e(),i.memoizedState=[e,n],e)}function Xu(e,n,i){return(fr&21)===0?(e.baseState&&(e.baseState=!1,Ft=!0),e.memoizedState=i):(an(i,n)||(i=Tc(),it.lanes|=i,hr|=i,e.baseState=!0),n)}function Fp(e,n){var i=Ve;Ve=i!==0&&4>i?i:4,e(!0);var l=Ao.transition;Ao.transition={};try{e(!1),n()}finally{Ve=i,Ao.transition=l}}function Zu(){return Xt().memoizedState}function Op(e,n,i){var l=qn(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},ed(e))td(n,i);else if(i=Au(e,n,i,l),i!==null){var u=_t();dn(i,e,l,u),nd(i,n,l)}}function Mp(e,n,i){var l=qn(e),u={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(ed(e))td(n,u);else{var m=e.alternate;if(e.lanes===0&&(m===null||m.lanes===0)&&(m=n.lastRenderedReducer,m!==null))try{var x=n.lastRenderedState,b=m(x,i);if(u.hasEagerState=!0,u.eagerState=b,an(b,x)){var I=n.interleaved;I===null?(u.next=u,No(n)):(u.next=I.next,I.next=u),n.interleaved=u;return}}catch{}finally{}i=Au(e,n,u,l),i!==null&&(u=_t(),dn(i,e,l,u),nd(i,n,l))}}function ed(e){var n=e.alternate;return e===it||n!==null&&n===it}function td(e,n){Ts=Fa=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function nd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Mi(e,i)}}var Ba={readContext:Qt,useCallback:Rt,useContext:Rt,useEffect:Rt,useImperativeHandle:Rt,useInsertionEffect:Rt,useLayoutEffect:Rt,useMemo:Rt,useReducer:Rt,useRef:Rt,useState:Rt,useDebugValue:Rt,useDeferredValue:Rt,useTransition:Rt,useMutableSource:Rt,useSyncExternalStore:Rt,useId:Rt,unstable_isNewReconciler:!1},Bp={readContext:Qt,useCallback:function(e,n){return xn().memoizedState=[e,n===void 0?null:n],e},useContext:Qt,useEffect:Vu,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Oa(4194308,4,Yu.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Oa(4194308,4,e,n)},useInsertionEffect:function(e,n){return Oa(4,2,e,n)},useMemo:function(e,n){var i=xn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=xn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=Op.bind(null,it,e),[l.memoizedState,e]},useRef:function(e){var n=xn();return e={current:e},n.memoizedState=e},useState:Wu,useDebugValue:Oo,useDeferredValue:function(e){return xn().memoizedState=e},useTransition:function(){var e=Wu(!1),n=e[0];return e=Fp.bind(null,e[1]),xn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=it,u=xn();if(nt){if(i===void 0)throw Error(a(407));i=i()}else{if(i=n(),St===null)throw Error(a(349));(fr&30)!==0||Ou(l,n,i)}u.memoizedState=i;var m={value:i,getSnapshot:n};return u.queue=m,Vu(Bu.bind(null,l,m,e),[e]),l.flags|=2048,As(9,Mu.bind(null,l,m,i,n),void 0,null),i},useId:function(){var e=xn(),n=St.identifierPrefix;if(nt){var i=En,l=Cn;i=(l&~(1<<32-sn(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Rs++,0<i&&(n+="H"+i.toString(32)),n+=":"}else i=zp++,n=":"+n+"r"+i.toString(32)+":";return e.memoizedState=n},unstable_isNewReconciler:!1},Dp={readContext:Qt,useCallback:qu,useContext:Qt,useEffect:Fo,useImperativeHandle:Ju,useInsertionEffect:Gu,useLayoutEffect:Ku,useMemo:Qu,useReducer:Lo,useRef:Hu,useState:function(){return Lo(Is)},useDebugValue:Oo,useDeferredValue:function(e){var n=Xt();return Xu(n,pt.memoizedState,e)},useTransition:function(){var e=Lo(Is)[0],n=Xt().memoizedState;return[e,n]},useMutableSource:zu,useSyncExternalStore:Fu,useId:Zu,unstable_isNewReconciler:!1},Up={readContext:Qt,useCallback:qu,useContext:Qt,useEffect:Fo,useImperativeHandle:Ju,useInsertionEffect:Gu,useLayoutEffect:Ku,useMemo:Qu,useReducer:zo,useRef:Hu,useState:function(){return zo(Is)},useDebugValue:Oo,useDeferredValue:function(e){var n=Xt();return pt===null?n.memoizedState=e:Xu(n,pt.memoizedState,e)},useTransition:function(){var e=zo(Is)[0],n=Xt().memoizedState;return[e,n]},useMutableSource:zu,useSyncExternalStore:Fu,useId:Zu,unstable_isNewReconciler:!1};function ln(e,n){if(e&&e.defaultProps){n=V({},n),e=e.defaultProps;for(var i in e)n[i]===void 0&&(n[i]=e[i]);return n}return n}function Mo(e,n,i,l){n=e.memoizedState,i=i(l,n),i=i==null?n:V({},n,i),e.memoizedState=i,e.lanes===0&&(e.updateQueue.baseState=i)}var Da={isMounted:function(e){return(e=e._reactInternals)?ar(e)===e:!1},enqueueSetState:function(e,n,i){e=e._reactInternals;var l=_t(),u=qn(e),m=Rn(l,u);m.payload=n,i!=null&&(m.callback=i),n=Gn(e,m,u),n!==null&&(dn(n,e,u,l),_a(n,e,u))},enqueueReplaceState:function(e,n,i){e=e._reactInternals;var l=_t(),u=qn(e),m=Rn(l,u);m.tag=1,m.payload=n,i!=null&&(m.callback=i),n=Gn(e,m,u),n!==null&&(dn(n,e,u,l),_a(n,e,u))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var i=_t(),l=qn(e),u=Rn(i,l);u.tag=2,n!=null&&(u.callback=n),n=Gn(e,u,l),n!==null&&(dn(n,e,l,i),_a(n,e,l))}};function rd(e,n,i,l,u,m,x){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,m,x):n.prototype&&n.prototype.isPureReactComponent?!ys(i,l)||!ys(u,m):!0}function sd(e,n,i){var l=!1,u=Wn,m=n.contextType;return typeof m=="object"&&m!==null?m=Qt(m):(u=zt(n)?or:Tt.current,l=n.contextTypes,m=(l=l!=null)?zr(e,u):Wn),n=new n(i,m),e.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=Da,e.stateNode=n,n._reactInternals=e,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=u,e.__reactInternalMemoizedMaskedChildContext=m),n}function ad(e,n,i,l){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(i,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(i,l),n.state!==e&&Da.enqueueReplaceState(n,n.state,null)}function Bo(e,n,i,l){var u=e.stateNode;u.props=i,u.state=e.memoizedState,u.refs={},Co(e);var m=n.contextType;typeof m=="object"&&m!==null?u.context=Qt(m):(m=zt(n)?or:Tt.current,u.context=zr(e,m)),u.state=e.memoizedState,m=n.getDerivedStateFromProps,typeof m=="function"&&(Mo(e,n,m,i),u.state=e.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(n=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),n!==u.state&&Da.enqueueReplaceState(u,u.state,null),$a(e,i,u,l),u.state=e.memoizedState),typeof u.componentDidMount=="function"&&(e.flags|=4194308)}function Hr(e,n){try{var i="",l=n;do i+=ue(l),l=l.return;while(l);var u=i}catch(m){u=`
39
+ Error generating stack: `+m.message+`
40
+ `+m.stack}return{value:e,source:n,stack:u,digest:null}}function Do(e,n,i){return{value:e,source:null,stack:i??null,digest:n??null}}function Uo(e,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var Wp=typeof WeakMap=="function"?WeakMap:Map;function id(e,n,i){i=Rn(-1,i),i.tag=3,i.payload={element:null};var l=n.value;return i.callback=function(){Ya||(Ya=!0,rl=l),Uo(e,n)},i}function od(e,n,i){i=Rn(-1,i),i.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var u=n.value;i.payload=function(){return l(u)},i.callback=function(){Uo(e,n)}}var m=e.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(i.callback=function(){Uo(e,n),typeof l!="function"&&(Yn===null?Yn=new Set([this]):Yn.add(this));var x=n.stack;this.componentDidCatch(n.value,{componentStack:x!==null?x:""})}),i}function ld(e,n,i){var l=e.pingCache;if(l===null){l=e.pingCache=new Wp;var u=new Set;l.set(n,u)}else u=l.get(n),u===void 0&&(u=new Set,l.set(n,u));u.has(i)||(u.add(i),e=rg.bind(null,e,n,i),n.then(e,e))}function cd(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function ud(e,n,i,l,u){return(e.mode&1)===0?(e===n?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(n=Rn(-1,1),n.tag=2,Gn(i,n,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=u,e)}var Hp=P.ReactCurrentOwner,Ft=!1;function Pt(e,n,i,l){n.child=e===null?Iu(n,null,i,l):Br(n,e.child,i,l)}function dd(e,n,i,l,u){i=i.render;var m=n.ref;return Ur(n,u),l=_o(e,n,i,l,m,u),i=$o(),e!==null&&!Ft?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~u,In(e,n,u)):(nt&&i&&go(n),n.flags|=1,Pt(e,n,l,u),n.child)}function fd(e,n,i,l,u){if(e===null){var m=i.type;return typeof m=="function"&&!ul(m)&&m.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=m,hd(e,n,m,l,u)):(e=ei(i.type,null,l,n,n.mode,u),e.ref=n.ref,e.return=n,n.child=e)}if(m=e.child,(e.lanes&u)===0){var x=m.memoizedProps;if(i=i.compare,i=i!==null?i:ys,i(x,l)&&e.ref===n.ref)return In(e,n,u)}return n.flags|=1,e=Xn(m,l),e.ref=n.ref,e.return=n,n.child=e}function hd(e,n,i,l,u){if(e!==null){var m=e.memoizedProps;if(ys(m,l)&&e.ref===n.ref)if(Ft=!1,n.pendingProps=l=m,(e.lanes&u)!==0)(e.flags&131072)!==0&&(Ft=!0);else return n.lanes=e.lanes,In(e,n,u)}return Wo(e,n,i,l,u)}function md(e,n,i){var l=n.pendingProps,u=l.children,m=e!==null?e.memoizedState:null;if(l.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},qe(Gr,Gt),Gt|=i;else{if((i&1073741824)===0)return e=m!==null?m.baseLanes|i:i,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,qe(Gr,Gt),Gt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=m!==null?m.baseLanes:i,qe(Gr,Gt),Gt|=l}else m!==null?(l=m.baseLanes|i,n.memoizedState=null):l=i,qe(Gr,Gt),Gt|=l;return Pt(e,n,u,i),n.child}function pd(e,n){var i=n.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function Wo(e,n,i,l,u){var m=zt(i)?or:Tt.current;return m=zr(n,m),Ur(n,u),i=_o(e,n,i,l,m,u),l=$o(),e!==null&&!Ft?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~u,In(e,n,u)):(nt&&l&&go(n),n.flags|=1,Pt(e,n,i,u),n.child)}function gd(e,n,i,l,u){if(zt(i)){var m=!0;Na(n)}else m=!1;if(Ur(n,u),n.stateNode===null)Wa(e,n),sd(n,i,l),Bo(n,i,l,u),l=!0;else if(e===null){var x=n.stateNode,b=n.memoizedProps;x.props=b;var I=x.context,U=i.contextType;typeof U=="object"&&U!==null?U=Qt(U):(U=zt(i)?or:Tt.current,U=zr(n,U));var Q=i.getDerivedStateFromProps,ne=typeof Q=="function"||typeof x.getSnapshotBeforeUpdate=="function";ne||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==l||I!==U)&&ad(n,x,l,U),Vn=!1;var q=n.memoizedState;x.state=q,$a(n,l,x,u),I=n.memoizedState,b!==l||q!==I||Lt.current||Vn?(typeof Q=="function"&&(Mo(n,i,Q,l),I=n.memoizedState),(b=Vn||rd(n,i,b,l,q,I,U))?(ne||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(n.flags|=4194308)):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=I),x.props=l,x.state=I,x.context=U,l=b):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{x=n.stateNode,Pu(e,n),b=n.memoizedProps,U=n.type===n.elementType?b:ln(n.type,b),x.props=U,ne=n.pendingProps,q=x.context,I=i.contextType,typeof I=="object"&&I!==null?I=Qt(I):(I=zt(i)?or:Tt.current,I=zr(n,I));var ye=i.getDerivedStateFromProps;(Q=typeof ye=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==ne||q!==I)&&ad(n,x,l,I),Vn=!1,q=n.memoizedState,x.state=q,$a(n,l,x,u);var Se=n.memoizedState;b!==ne||q!==Se||Lt.current||Vn?(typeof ye=="function"&&(Mo(n,i,ye,l),Se=n.memoizedState),(U=Vn||rd(n,i,U,l,q,Se,I)||!1)?(Q||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(l,Se,I),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(l,Se,I)),typeof x.componentDidUpdate=="function"&&(n.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof x.componentDidUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=Se),x.props=l,x.state=Se,x.context=I,l=U):(typeof x.componentDidUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(n.flags|=1024),l=!1)}return Ho(e,n,i,l,m,u)}function Ho(e,n,i,l,u,m){pd(e,n);var x=(n.flags&128)!==0;if(!l&&!x)return u&&ju(n,i,!1),In(e,n,m);l=n.stateNode,Hp.current=n;var b=x&&typeof i.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&x?(n.child=Br(n,e.child,null,m),n.child=Br(n,null,b,m)):Pt(e,n,b,m),n.memoizedState=l.state,u&&ju(n,i,!0),n.child}function yd(e){var n=e.stateNode;n.pendingContext?xu(e,n.pendingContext,n.pendingContext!==n.context):n.context&&xu(e,n.context,!1),Eo(e,n.containerInfo)}function vd(e,n,i,l,u){return Mr(),wo(u),n.flags|=256,Pt(e,n,i,l),n.child}var Vo={dehydrated:null,treeContext:null,retryLane:0};function Go(e){return{baseLanes:e,cachePool:null,transitions:null}}function xd(e,n,i){var l=n.pendingProps,u=at.current,m=!1,x=(n.flags&128)!==0,b;if((b=x)||(b=e!==null&&e.memoizedState===null?!1:(u&2)!==0),b?(m=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(u|=1),qe(at,u&1),e===null)return xo(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((n.mode&1)===0?n.lanes=1:e.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(x=l.children,e=l.fallback,m?(l=n.mode,m=n.child,x={mode:"hidden",children:x},(l&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=x):m=ti(x,l,0,null),e=yr(e,l,i,null),m.return=n,e.return=n,m.sibling=e,n.child=m,n.child.memoizedState=Go(i),n.memoizedState=Vo,e):Ko(n,x));if(u=e.memoizedState,u!==null&&(b=u.dehydrated,b!==null))return Vp(e,n,x,l,b,u,i);if(m){m=l.fallback,x=n.mode,u=e.child,b=u.sibling;var I={mode:"hidden",children:l.children};return(x&1)===0&&n.child!==u?(l=n.child,l.childLanes=0,l.pendingProps=I,n.deletions=null):(l=Xn(u,I),l.subtreeFlags=u.subtreeFlags&14680064),b!==null?m=Xn(b,m):(m=yr(m,x,i,null),m.flags|=2),m.return=n,l.return=n,l.sibling=m,n.child=l,l=m,m=n.child,x=e.child.memoizedState,x=x===null?Go(i):{baseLanes:x.baseLanes|i,cachePool:null,transitions:x.transitions},m.memoizedState=x,m.childLanes=e.childLanes&~i,n.memoizedState=Vo,l}return m=e.child,e=m.sibling,l=Xn(m,{mode:"visible",children:l.children}),(n.mode&1)===0&&(l.lanes=i),l.return=n,l.sibling=null,e!==null&&(i=n.deletions,i===null?(n.deletions=[e],n.flags|=16):i.push(e)),n.child=l,n.memoizedState=null,l}function Ko(e,n){return n=ti({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Ua(e,n,i,l){return l!==null&&wo(l),Br(n,e.child,null,i),e=Ko(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Vp(e,n,i,l,u,m,x){if(i)return n.flags&256?(n.flags&=-257,l=Do(Error(a(422))),Ua(e,n,x,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(m=l.fallback,u=n.mode,l=ti({mode:"visible",children:l.children},u,0,null),m=yr(m,u,x,null),m.flags|=2,l.return=n,m.return=n,l.sibling=m,n.child=l,(n.mode&1)!==0&&Br(n,e.child,null,x),n.child.memoizedState=Go(x),n.memoizedState=Vo,m);if((n.mode&1)===0)return Ua(e,n,x,null);if(u.data==="$!"){if(l=u.nextSibling&&u.nextSibling.dataset,l)var b=l.dgst;return l=b,m=Error(a(419)),l=Do(m,l,void 0),Ua(e,n,x,l)}if(b=(x&e.childLanes)!==0,Ft||b){if(l=St,l!==null){switch(x&-x){case 4:u=2;break;case 16:u=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:u=32;break;case 536870912:u=268435456;break;default:u=0}u=(u&(l.suspendedLanes|x))!==0?0:u,u!==0&&u!==m.retryLane&&(m.retryLane=u,Tn(e,u),dn(l,e,u,-1))}return cl(),l=Do(Error(a(421))),Ua(e,n,x,l)}return u.data==="$?"?(n.flags|=128,n.child=e.child,n=sg.bind(null,e),u._reactRetry=n,null):(e=m.treeContext,Vt=Dn(u.nextSibling),Ht=n,nt=!0,on=null,e!==null&&(Jt[qt++]=Cn,Jt[qt++]=En,Jt[qt++]=lr,Cn=e.id,En=e.overflow,lr=n),n=Ko(n,l.children),n.flags|=4096,n)}function wd(e,n,i){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),bo(e.return,n,i)}function Yo(e,n,i,l,u){var m=e.memoizedState;m===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:i,tailMode:u}:(m.isBackwards=n,m.rendering=null,m.renderingStartTime=0,m.last=l,m.tail=i,m.tailMode=u)}function jd(e,n,i){var l=n.pendingProps,u=l.revealOrder,m=l.tail;if(Pt(e,n,l.children,i),l=at.current,(l&2)!==0)l=l&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&wd(e,i,n);else if(e.tag===19)wd(e,i,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(qe(at,l),(n.mode&1)===0)n.memoizedState=null;else switch(u){case"forwards":for(i=n.child,u=null;i!==null;)e=i.alternate,e!==null&&La(e)===null&&(u=i),i=i.sibling;i=u,i===null?(u=n.child,n.child=null):(u=i.sibling,i.sibling=null),Yo(n,!1,u,i,m);break;case"backwards":for(i=null,u=n.child,n.child=null;u!==null;){if(e=u.alternate,e!==null&&La(e)===null){n.child=u;break}e=u.sibling,u.sibling=i,i=u,u=e}Yo(n,!0,i,null,m);break;case"together":Yo(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function Wa(e,n){(n.mode&1)===0&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function In(e,n,i){if(e!==null&&(n.dependencies=e.dependencies),hr|=n.lanes,(i&n.childLanes)===0)return null;if(e!==null&&n.child!==e.child)throw Error(a(153));if(n.child!==null){for(e=n.child,i=Xn(e,e.pendingProps),n.child=i,i.return=n;e.sibling!==null;)e=e.sibling,i=i.sibling=Xn(e,e.pendingProps),i.return=n;i.sibling=null}return n.child}function Gp(e,n,i){switch(n.tag){case 3:yd(n),Mr();break;case 5:Lu(n);break;case 1:zt(n.type)&&Na(n);break;case 4:Eo(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,u=n.memoizedProps.value;qe(Aa,l._currentValue),l._currentValue=u;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(qe(at,at.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?xd(e,n,i):(qe(at,at.current&1),e=In(e,n,i),e!==null?e.sibling:null);qe(at,at.current&1);break;case 19:if(l=(i&n.childLanes)!==0,(e.flags&128)!==0){if(l)return jd(e,n,i);n.flags|=128}if(u=n.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),qe(at,at.current),l)break;return null;case 22:case 23:return n.lanes=0,md(e,n,i)}return In(e,n,i)}var Sd,Jo,kd,bd;Sd=function(e,n){for(var i=n.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},Jo=function(){},kd=function(e,n,i,l){var u=e.memoizedProps;if(u!==l){e=n.stateNode,dr(vn.current);var m=null;switch(i){case"input":u=X(e,u),l=X(e,l),m=[];break;case"select":u=V({},u,{value:void 0}),l=V({},l,{value:void 0}),m=[];break;case"textarea":u=st(e,u),l=st(e,l),m=[];break;default:typeof u.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=Sa)}tt(i,l);var x;i=null;for(U in u)if(!l.hasOwnProperty(U)&&u.hasOwnProperty(U)&&u[U]!=null)if(U==="style"){var b=u[U];for(x in b)b.hasOwnProperty(x)&&(i||(i={}),i[x]="")}else U!=="dangerouslySetInnerHTML"&&U!=="children"&&U!=="suppressContentEditableWarning"&&U!=="suppressHydrationWarning"&&U!=="autoFocus"&&(c.hasOwnProperty(U)?m||(m=[]):(m=m||[]).push(U,null));for(U in l){var I=l[U];if(b=u!=null?u[U]:void 0,l.hasOwnProperty(U)&&I!==b&&(I!=null||b!=null))if(U==="style")if(b){for(x in b)!b.hasOwnProperty(x)||I&&I.hasOwnProperty(x)||(i||(i={}),i[x]="");for(x in I)I.hasOwnProperty(x)&&b[x]!==I[x]&&(i||(i={}),i[x]=I[x])}else i||(m||(m=[]),m.push(U,i)),i=I;else U==="dangerouslySetInnerHTML"?(I=I?I.__html:void 0,b=b?b.__html:void 0,I!=null&&b!==I&&(m=m||[]).push(U,I)):U==="children"?typeof I!="string"&&typeof I!="number"||(m=m||[]).push(U,""+I):U!=="suppressContentEditableWarning"&&U!=="suppressHydrationWarning"&&(c.hasOwnProperty(U)?(I!=null&&U==="onScroll"&&Xe("scroll",e),m||b===I||(m=[])):(m=m||[]).push(U,I))}i&&(m=m||[]).push("style",i);var U=m;(n.updateQueue=U)&&(n.flags|=4)}},bd=function(e,n,i,l){i!==l&&(n.flags|=4)};function Ps(e,n){if(!nt)switch(e.tailMode){case"hidden":n=e.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var l=null;i!==null;)i.alternate!==null&&(l=i),i=i.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function It(e){var n=e.alternate!==null&&e.alternate.child===e.child,i=0,l=0;if(n)for(var u=e.child;u!==null;)i|=u.lanes|u.childLanes,l|=u.subtreeFlags&14680064,l|=u.flags&14680064,u.return=e,u=u.sibling;else for(u=e.child;u!==null;)i|=u.lanes|u.childLanes,l|=u.subtreeFlags,l|=u.flags,u.return=e,u=u.sibling;return e.subtreeFlags|=l,e.childLanes=i,n}function Kp(e,n,i){var l=n.pendingProps;switch(yo(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(n),null;case 1:return zt(n.type)&&ba(),It(n),null;case 3:return l=n.stateNode,Wr(),Ze(Lt),Ze(Tt),Io(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(Ra(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,on!==null&&(il(on),on=null))),Jo(e,n),It(n),null;case 5:To(n);var u=dr(Es.current);if(i=n.type,e!==null&&n.stateNode!=null)kd(e,n,i,l,u),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(a(166));return It(n),null}if(e=dr(vn.current),Ra(n)){l=n.stateNode,i=n.type;var m=n.memoizedProps;switch(l[yn]=n,l[Ss]=m,e=(n.mode&1)!==0,i){case"dialog":Xe("cancel",l),Xe("close",l);break;case"iframe":case"object":case"embed":Xe("load",l);break;case"video":case"audio":for(u=0;u<xs.length;u++)Xe(xs[u],l);break;case"source":Xe("error",l);break;case"img":case"image":case"link":Xe("error",l),Xe("load",l);break;case"details":Xe("toggle",l);break;case"input":we(l,m),Xe("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!m.multiple},Xe("invalid",l);break;case"textarea":mt(l,m),Xe("invalid",l)}tt(i,m),u=null;for(var x in m)if(m.hasOwnProperty(x)){var b=m[x];x==="children"?typeof b=="string"?l.textContent!==b&&(m.suppressHydrationWarning!==!0&&ja(l.textContent,b,e),u=["children",b]):typeof b=="number"&&l.textContent!==""+b&&(m.suppressHydrationWarning!==!0&&ja(l.textContent,b,e),u=["children",""+b]):c.hasOwnProperty(x)&&b!=null&&x==="onScroll"&&Xe("scroll",l)}switch(i){case"input":Ee(l),lt(l,m,!0);break;case"textarea":Ee(l),$(l);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(l.onclick=Sa)}l=u,n.updateQueue=l,l!==null&&(n.flags|=4)}else{x=u.nodeType===9?u:u.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=le(i)),e==="http://www.w3.org/1999/xhtml"?i==="script"?(e=x.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=x.createElement(i,{is:l.is}):(e=x.createElement(i),i==="select"&&(x=e,l.multiple?x.multiple=!0:l.size&&(x.size=l.size))):e=x.createElementNS(e,i),e[yn]=n,e[Ss]=l,Sd(e,n,!1,!1),n.stateNode=e;e:{switch(x=bt(i,l),i){case"dialog":Xe("cancel",e),Xe("close",e),u=l;break;case"iframe":case"object":case"embed":Xe("load",e),u=l;break;case"video":case"audio":for(u=0;u<xs.length;u++)Xe(xs[u],e);u=l;break;case"source":Xe("error",e),u=l;break;case"img":case"image":case"link":Xe("error",e),Xe("load",e),u=l;break;case"details":Xe("toggle",e),u=l;break;case"input":we(e,l),u=X(e,l),Xe("invalid",e);break;case"option":u=l;break;case"select":e._wrapperState={wasMultiple:!!l.multiple},u=V({},l,{value:void 0}),Xe("invalid",e);break;case"textarea":mt(e,l),u=st(e,l),Xe("invalid",e);break;default:u=l}tt(i,u),b=u;for(m in b)if(b.hasOwnProperty(m)){var I=b[m];m==="style"?pn(e,I):m==="dangerouslySetInnerHTML"?(I=I?I.__html:void 0,I!=null&&de(e,I)):m==="children"?typeof I=="string"?(i!=="textarea"||I!=="")&&Oe(e,I):typeof I=="number"&&Oe(e,""+I):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(c.hasOwnProperty(m)?I!=null&&m==="onScroll"&&Xe("scroll",e):I!=null&&L(e,m,I,x))}switch(i){case"input":Ee(e),lt(e,l,!1);break;case"textarea":Ee(e),$(e);break;case"option":l.value!=null&&e.setAttribute("value",""+ke(l.value));break;case"select":e.multiple=!!l.multiple,m=l.value,m!=null?et(e,!!l.multiple,m,!1):l.defaultValue!=null&&et(e,!!l.multiple,l.defaultValue,!0);break;default:typeof u.onClick=="function"&&(e.onclick=Sa)}switch(i){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}}l&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return It(n),null;case 6:if(e&&n.stateNode!=null)bd(e,n,e.memoizedProps,l);else{if(typeof l!="string"&&n.stateNode===null)throw Error(a(166));if(i=dr(Es.current),dr(vn.current),Ra(n)){if(l=n.stateNode,i=n.memoizedProps,l[yn]=n,(m=l.nodeValue!==i)&&(e=Ht,e!==null))switch(e.tag){case 3:ja(l.nodeValue,i,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&ja(l.nodeValue,i,(e.mode&1)!==0)}m&&(n.flags|=4)}else l=(i.nodeType===9?i:i.ownerDocument).createTextNode(l),l[yn]=n,n.stateNode=l}return It(n),null;case 13:if(Ze(at),l=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(nt&&Vt!==null&&(n.mode&1)!==0&&(n.flags&128)===0)Eu(),Mr(),n.flags|=98560,m=!1;else if(m=Ra(n),l!==null&&l.dehydrated!==null){if(e===null){if(!m)throw Error(a(318));if(m=n.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(a(317));m[yn]=n}else Mr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;It(n),m=!1}else on!==null&&(il(on),on=null),m=!0;if(!m)return n.flags&65536?n:null}return(n.flags&128)!==0?(n.lanes=i,n):(l=l!==null,l!==(e!==null&&e.memoizedState!==null)&&l&&(n.child.flags|=8192,(n.mode&1)!==0&&(e===null||(at.current&1)!==0?gt===0&&(gt=3):cl())),n.updateQueue!==null&&(n.flags|=4),It(n),null);case 4:return Wr(),Jo(e,n),e===null&&ws(n.stateNode.containerInfo),It(n),null;case 10:return ko(n.type._context),It(n),null;case 17:return zt(n.type)&&ba(),It(n),null;case 19:if(Ze(at),m=n.memoizedState,m===null)return It(n),null;if(l=(n.flags&128)!==0,x=m.rendering,x===null)if(l)Ps(m,!1);else{if(gt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(x=La(e),x!==null){for(n.flags|=128,Ps(m,!1),l=x.updateQueue,l!==null&&(n.updateQueue=l,n.flags|=4),n.subtreeFlags=0,l=i,i=n.child;i!==null;)m=i,e=l,m.flags&=14680066,x=m.alternate,x===null?(m.childLanes=0,m.lanes=e,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=x.childLanes,m.lanes=x.lanes,m.child=x.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=x.memoizedProps,m.memoizedState=x.memoizedState,m.updateQueue=x.updateQueue,m.type=x.type,e=x.dependencies,m.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),i=i.sibling;return qe(at,at.current&1|2),n.child}e=e.sibling}m.tail!==null&&ct()>Kr&&(n.flags|=128,l=!0,Ps(m,!1),n.lanes=4194304)}else{if(!l)if(e=La(x),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Ps(m,!0),m.tail===null&&m.tailMode==="hidden"&&!x.alternate&&!nt)return It(n),null}else 2*ct()-m.renderingStartTime>Kr&&i!==1073741824&&(n.flags|=128,l=!0,Ps(m,!1),n.lanes=4194304);m.isBackwards?(x.sibling=n.child,n.child=x):(i=m.last,i!==null?i.sibling=x:n.child=x,m.last=x)}return m.tail!==null?(n=m.tail,m.rendering=n,m.tail=n.sibling,m.renderingStartTime=ct(),n.sibling=null,i=at.current,qe(at,l?i&1|2:i&1),n):(It(n),null);case 22:case 23:return ll(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Gt&1073741824)!==0&&(It(n),n.subtreeFlags&6&&(n.flags|=8192)):It(n),null;case 24:return null;case 25:return null}throw Error(a(156,n.tag))}function Yp(e,n){switch(yo(n),n.tag){case 1:return zt(n.type)&&ba(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Wr(),Ze(Lt),Ze(Tt),Io(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return To(n),null;case 13:if(Ze(at),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));Mr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ze(at),null;case 4:return Wr(),null;case 10:return ko(n.type._context),null;case 22:case 23:return ll(),null;case 24:return null;default:return null}}var Ha=!1,At=!1,Jp=typeof WeakSet=="function"?WeakSet:Set,xe=null;function Vr(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){ot(e,n,l)}else i.current=null}function qo(e,n,i){try{i()}catch(l){ot(e,n,l)}}var Nd=!1;function qp(e,n){if(oo=ua,e=ru(),Zi(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var u=l.anchorOffset,m=l.focusNode;l=l.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var x=0,b=-1,I=-1,U=0,Q=0,ne=e,q=null;t:for(;;){for(var ye;ne!==i||u!==0&&ne.nodeType!==3||(b=x+u),ne!==m||l!==0&&ne.nodeType!==3||(I=x+l),ne.nodeType===3&&(x+=ne.nodeValue.length),(ye=ne.firstChild)!==null;)q=ne,ne=ye;for(;;){if(ne===e)break t;if(q===i&&++U===u&&(b=x),q===m&&++Q===l&&(I=x),(ye=ne.nextSibling)!==null)break;ne=q,q=ne.parentNode}ne=ye}i=b===-1||I===-1?null:{start:b,end:I}}else i=null}i=i||{start:0,end:0}}else i=null;for(lo={focusedElem:e,selectionRange:i},ua=!1,xe=n;xe!==null;)if(n=xe,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,xe=e;else for(;xe!==null;){n=xe;try{var Se=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(Se!==null){var be=Se.memoizedProps,ut=Se.memoizedState,z=n.stateNode,_=z.getSnapshotBeforeUpdate(n.elementType===n.type?be:ln(n.type,be),ut);z.__reactInternalSnapshotBeforeUpdate=_}break;case 3:var O=n.stateNode.containerInfo;O.nodeType===1?O.textContent="":O.nodeType===9&&O.documentElement&&O.removeChild(O.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(ce){ot(n,n.return,ce)}if(e=n.sibling,e!==null){e.return=n.return,xe=e;break}xe=n.return}return Se=Nd,Nd=!1,Se}function _s(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var u=l=l.next;do{if((u.tag&e)===e){var m=u.destroy;u.destroy=void 0,m!==void 0&&qo(n,i,m)}u=u.next}while(u!==l)}}function Va(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function Qo(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Cd(e){var n=e.alternate;n!==null&&(e.alternate=null,Cd(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[yn],delete n[Ss],delete n[ho],delete n[Pp],delete n[_p])),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 Ed(e){return e.tag===5||e.tag===3||e.tag===4}function Td(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ed(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 Xo(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Sa));else if(l!==4&&(e=e.child,e!==null))for(Xo(e,n,i),e=e.sibling;e!==null;)Xo(e,n,i),e=e.sibling}function Zo(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(Zo(e,n,i),e=e.sibling;e!==null;)Zo(e,n,i),e=e.sibling}var Nt=null,cn=!1;function Kn(e,n,i){for(i=i.child;i!==null;)Rd(e,n,i),i=i.sibling}function Rd(e,n,i){if(gn&&typeof gn.onCommitFiberUnmount=="function")try{gn.onCommitFiberUnmount(sa,i)}catch{}switch(i.tag){case 5:At||Vr(i,n);case 6:var l=Nt,u=cn;Nt=null,Kn(e,n,i),Nt=l,cn=u,Nt!==null&&(cn?(e=Nt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):Nt.removeChild(i.stateNode));break;case 18:Nt!==null&&(cn?(e=Nt,i=i.stateNode,e.nodeType===8?fo(e.parentNode,i):e.nodeType===1&&fo(e,i),ds(e)):fo(Nt,i.stateNode));break;case 4:l=Nt,u=cn,Nt=i.stateNode.containerInfo,cn=!0,Kn(e,n,i),Nt=l,cn=u;break;case 0:case 11:case 14:case 15:if(!At&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){u=l=l.next;do{var m=u,x=m.destroy;m=m.tag,x!==void 0&&((m&2)!==0||(m&4)!==0)&&qo(i,n,x),u=u.next}while(u!==l)}Kn(e,n,i);break;case 1:if(!At&&(Vr(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(b){ot(i,n,b)}Kn(e,n,i);break;case 21:Kn(e,n,i);break;case 22:i.mode&1?(At=(l=At)||i.memoizedState!==null,Kn(e,n,i),At=l):Kn(e,n,i);break;default:Kn(e,n,i)}}function Id(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Jp),n.forEach(function(l){var u=ag.bind(null,e,l);i.has(l)||(i.add(l),l.then(u,u))})}}function un(e,n){var i=n.deletions;if(i!==null)for(var l=0;l<i.length;l++){var u=i[l];try{var m=e,x=n,b=x;e:for(;b!==null;){switch(b.tag){case 5:Nt=b.stateNode,cn=!1;break e;case 3:Nt=b.stateNode.containerInfo,cn=!0;break e;case 4:Nt=b.stateNode.containerInfo,cn=!0;break e}b=b.return}if(Nt===null)throw Error(a(160));Rd(m,x,u),Nt=null,cn=!1;var I=u.alternate;I!==null&&(I.return=null),u.return=null}catch(U){ot(u,n,U)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Ad(n,e),n=n.sibling}function Ad(e,n){var i=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(un(n,e),wn(e),l&4){try{_s(3,e,e.return),Va(3,e)}catch(be){ot(e,e.return,be)}try{_s(5,e,e.return)}catch(be){ot(e,e.return,be)}}break;case 1:un(n,e),wn(e),l&512&&i!==null&&Vr(i,i.return);break;case 5:if(un(n,e),wn(e),l&512&&i!==null&&Vr(i,i.return),e.flags&32){var u=e.stateNode;try{Oe(u,"")}catch(be){ot(e,e.return,be)}}if(l&4&&(u=e.stateNode,u!=null)){var m=e.memoizedProps,x=i!==null?i.memoizedProps:m,b=e.type,I=e.updateQueue;if(e.updateQueue=null,I!==null)try{b==="input"&&m.type==="radio"&&m.name!=null&&Te(u,m),bt(b,x);var U=bt(b,m);for(x=0;x<I.length;x+=2){var Q=I[x],ne=I[x+1];Q==="style"?pn(u,ne):Q==="dangerouslySetInnerHTML"?de(u,ne):Q==="children"?Oe(u,ne):L(u,Q,ne,U)}switch(b){case"input":$e(u,m);break;case"textarea":Fe(u,m);break;case"select":var q=u._wrapperState.wasMultiple;u._wrapperState.wasMultiple=!!m.multiple;var ye=m.value;ye!=null?et(u,!!m.multiple,ye,!1):q!==!!m.multiple&&(m.defaultValue!=null?et(u,!!m.multiple,m.defaultValue,!0):et(u,!!m.multiple,m.multiple?[]:"",!1))}u[Ss]=m}catch(be){ot(e,e.return,be)}}break;case 6:if(un(n,e),wn(e),l&4){if(e.stateNode===null)throw Error(a(162));u=e.stateNode,m=e.memoizedProps;try{u.nodeValue=m}catch(be){ot(e,e.return,be)}}break;case 3:if(un(n,e),wn(e),l&4&&i!==null&&i.memoizedState.isDehydrated)try{ds(n.containerInfo)}catch(be){ot(e,e.return,be)}break;case 4:un(n,e),wn(e);break;case 13:un(n,e),wn(e),u=e.child,u.flags&8192&&(m=u.memoizedState!==null,u.stateNode.isHidden=m,!m||u.alternate!==null&&u.alternate.memoizedState!==null||(nl=ct())),l&4&&Id(e);break;case 22:if(Q=i!==null&&i.memoizedState!==null,e.mode&1?(At=(U=At)||Q,un(n,e),At=U):un(n,e),wn(e),l&8192){if(U=e.memoizedState!==null,(e.stateNode.isHidden=U)&&!Q&&(e.mode&1)!==0)for(xe=e,Q=e.child;Q!==null;){for(ne=xe=Q;xe!==null;){switch(q=xe,ye=q.child,q.tag){case 0:case 11:case 14:case 15:_s(4,q,q.return);break;case 1:Vr(q,q.return);var Se=q.stateNode;if(typeof Se.componentWillUnmount=="function"){l=q,i=q.return;try{n=l,Se.props=n.memoizedProps,Se.state=n.memoizedState,Se.componentWillUnmount()}catch(be){ot(l,i,be)}}break;case 5:Vr(q,q.return);break;case 22:if(q.memoizedState!==null){$d(ne);continue}}ye!==null?(ye.return=q,xe=ye):$d(ne)}Q=Q.sibling}e:for(Q=null,ne=e;;){if(ne.tag===5){if(Q===null){Q=ne;try{u=ne.stateNode,U?(m=u.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none"):(b=ne.stateNode,I=ne.memoizedProps.style,x=I!=null&&I.hasOwnProperty("display")?I.display:null,b.style.display=ft("display",x))}catch(be){ot(e,e.return,be)}}}else if(ne.tag===6){if(Q===null)try{ne.stateNode.nodeValue=U?"":ne.memoizedProps}catch(be){ot(e,e.return,be)}}else if((ne.tag!==22&&ne.tag!==23||ne.memoizedState===null||ne===e)&&ne.child!==null){ne.child.return=ne,ne=ne.child;continue}if(ne===e)break e;for(;ne.sibling===null;){if(ne.return===null||ne.return===e)break e;Q===ne&&(Q=null),ne=ne.return}Q===ne&&(Q=null),ne.sibling.return=ne.return,ne=ne.sibling}}break;case 19:un(n,e),wn(e),l&4&&Id(e);break;case 21:break;default:un(n,e),wn(e)}}function wn(e){var n=e.flags;if(n&2){try{e:{for(var i=e.return;i!==null;){if(Ed(i)){var l=i;break e}i=i.return}throw Error(a(160))}switch(l.tag){case 5:var u=l.stateNode;l.flags&32&&(Oe(u,""),l.flags&=-33);var m=Td(e);Zo(e,m,u);break;case 3:case 4:var x=l.stateNode.containerInfo,b=Td(e);Xo(e,b,x);break;default:throw Error(a(161))}}catch(I){ot(e,e.return,I)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function Qp(e,n,i){xe=e,Pd(e)}function Pd(e,n,i){for(var l=(e.mode&1)!==0;xe!==null;){var u=xe,m=u.child;if(u.tag===22&&l){var x=u.memoizedState!==null||Ha;if(!x){var b=u.alternate,I=b!==null&&b.memoizedState!==null||At;b=Ha;var U=At;if(Ha=x,(At=I)&&!U)for(xe=u;xe!==null;)x=xe,I=x.child,x.tag===22&&x.memoizedState!==null?Ld(u):I!==null?(I.return=x,xe=I):Ld(u);for(;m!==null;)xe=m,Pd(m),m=m.sibling;xe=u,Ha=b,At=U}_d(e)}else(u.subtreeFlags&8772)!==0&&m!==null?(m.return=u,xe=m):_d(e)}}function _d(e){for(;xe!==null;){var n=xe;if((n.flags&8772)!==0){var i=n.alternate;try{if((n.flags&8772)!==0)switch(n.tag){case 0:case 11:case 15:At||Va(5,n);break;case 1:var l=n.stateNode;if(n.flags&4&&!At)if(i===null)l.componentDidMount();else{var u=n.elementType===n.type?i.memoizedProps:ln(n.type,i.memoizedProps);l.componentDidUpdate(u,i.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var m=n.updateQueue;m!==null&&$u(n,m,l);break;case 3:var x=n.updateQueue;if(x!==null){if(i=null,n.child!==null)switch(n.child.tag){case 5:i=n.child.stateNode;break;case 1:i=n.child.stateNode}$u(n,x,i)}break;case 5:var b=n.stateNode;if(i===null&&n.flags&4){i=b;var I=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":I.autoFocus&&i.focus();break;case"img":I.src&&(i.src=I.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var U=n.alternate;if(U!==null){var Q=U.memoizedState;if(Q!==null){var ne=Q.dehydrated;ne!==null&&ds(ne)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}At||n.flags&512&&Qo(n)}catch(q){ot(n,n.return,q)}}if(n===e){xe=null;break}if(i=n.sibling,i!==null){i.return=n.return,xe=i;break}xe=n.return}}function $d(e){for(;xe!==null;){var n=xe;if(n===e){xe=null;break}var i=n.sibling;if(i!==null){i.return=n.return,xe=i;break}xe=n.return}}function Ld(e){for(;xe!==null;){var n=xe;try{switch(n.tag){case 0:case 11:case 15:var i=n.return;try{Va(4,n)}catch(I){ot(n,i,I)}break;case 1:var l=n.stateNode;if(typeof l.componentDidMount=="function"){var u=n.return;try{l.componentDidMount()}catch(I){ot(n,u,I)}}var m=n.return;try{Qo(n)}catch(I){ot(n,m,I)}break;case 5:var x=n.return;try{Qo(n)}catch(I){ot(n,x,I)}}}catch(I){ot(n,n.return,I)}if(n===e){xe=null;break}var b=n.sibling;if(b!==null){b.return=n.return,xe=b;break}xe=n.return}}var Xp=Math.ceil,Ga=P.ReactCurrentDispatcher,el=P.ReactCurrentOwner,Zt=P.ReactCurrentBatchConfig,Ue=0,St=null,ht=null,Ct=0,Gt=0,Gr=Un(0),gt=0,$s=null,hr=0,Ka=0,tl=0,Ls=null,Ot=null,nl=0,Kr=1/0,An=null,Ya=!1,rl=null,Yn=null,Ja=!1,Jn=null,qa=0,zs=0,sl=null,Qa=-1,Xa=0;function _t(){return(Ue&6)!==0?ct():Qa!==-1?Qa:Qa=ct()}function qn(e){return(e.mode&1)===0?1:(Ue&2)!==0&&Ct!==0?Ct&-Ct:Lp.transition!==null?(Xa===0&&(Xa=Tc()),Xa):(e=Ve,e!==0||(e=window.event,e=e===void 0?16:Fc(e.type)),e)}function dn(e,n,i,l){if(50<zs)throw zs=0,sl=null,Error(a(185));is(e,i,l),((Ue&2)===0||e!==St)&&(e===St&&((Ue&2)===0&&(Ka|=i),gt===4&&Qn(e,Ct)),Mt(e,l),i===1&&Ue===0&&(n.mode&1)===0&&(Kr=ct()+500,Ca&&Hn()))}function Mt(e,n){var i=e.callbackNode;Lm(e,n);var l=oa(e,e===St?Ct:0);if(l===0)i!==null&&Nc(i),e.callbackNode=null,e.callbackPriority=0;else if(n=l&-l,e.callbackPriority!==n){if(i!=null&&Nc(i),n===1)e.tag===0?$p(Fd.bind(null,e)):Su(Fd.bind(null,e)),Ip(function(){(Ue&6)===0&&Hn()}),i=null;else{switch(Rc(l)){case 1:i=zi;break;case 4:i=Cc;break;case 16:i=ra;break;case 536870912:i=Ec;break;default:i=ra}i=Vd(i,zd.bind(null,e))}e.callbackPriority=n,e.callbackNode=i}}function zd(e,n){if(Qa=-1,Xa=0,(Ue&6)!==0)throw Error(a(327));var i=e.callbackNode;if(Yr()&&e.callbackNode!==i)return null;var l=oa(e,e===St?Ct:0);if(l===0)return null;if((l&30)!==0||(l&e.expiredLanes)!==0||n)n=Za(e,l);else{n=l;var u=Ue;Ue|=2;var m=Md();(St!==e||Ct!==n)&&(An=null,Kr=ct()+500,pr(e,n));do try{tg();break}catch(b){Od(e,b)}while(!0);So(),Ga.current=m,Ue=u,ht!==null?n=0:(St=null,Ct=0,n=gt)}if(n!==0){if(n===2&&(u=Fi(e),u!==0&&(l=u,n=al(e,u))),n===1)throw i=$s,pr(e,0),Qn(e,l),Mt(e,ct()),i;if(n===6)Qn(e,l);else{if(u=e.current.alternate,(l&30)===0&&!Zp(u)&&(n=Za(e,l),n===2&&(m=Fi(e),m!==0&&(l=m,n=al(e,m))),n===1))throw i=$s,pr(e,0),Qn(e,l),Mt(e,ct()),i;switch(e.finishedWork=u,e.finishedLanes=l,n){case 0:case 1:throw Error(a(345));case 2:gr(e,Ot,An);break;case 3:if(Qn(e,l),(l&130023424)===l&&(n=nl+500-ct(),10<n)){if(oa(e,0)!==0)break;if(u=e.suspendedLanes,(u&l)!==l){_t(),e.pingedLanes|=e.suspendedLanes&u;break}e.timeoutHandle=uo(gr.bind(null,e,Ot,An),n);break}gr(e,Ot,An);break;case 4:if(Qn(e,l),(l&4194240)===l)break;for(n=e.eventTimes,u=-1;0<l;){var x=31-sn(l);m=1<<x,x=n[x],x>u&&(u=x),l&=~m}if(l=u,l=ct()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Xp(l/1960))-l,10<l){e.timeoutHandle=uo(gr.bind(null,e,Ot,An),l);break}gr(e,Ot,An);break;case 5:gr(e,Ot,An);break;default:throw Error(a(329))}}}return Mt(e,ct()),e.callbackNode===i?zd.bind(null,e):null}function al(e,n){var i=Ls;return e.current.memoizedState.isDehydrated&&(pr(e,n).flags|=256),e=Za(e,n),e!==2&&(n=Ot,Ot=i,n!==null&&il(n)),e}function il(e){Ot===null?Ot=e:Ot.push.apply(Ot,e)}function Zp(e){for(var n=e;;){if(n.flags&16384){var i=n.updateQueue;if(i!==null&&(i=i.stores,i!==null))for(var l=0;l<i.length;l++){var u=i[l],m=u.getSnapshot;u=u.value;try{if(!an(m(),u))return!1}catch{return!1}}}if(i=n.child,n.subtreeFlags&16384&&i!==null)i.return=n,n=i;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Qn(e,n){for(n&=~tl,n&=~Ka,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var i=31-sn(n),l=1<<i;e[i]=-1,n&=~l}}function Fd(e){if((Ue&6)!==0)throw Error(a(327));Yr();var n=oa(e,0);if((n&1)===0)return Mt(e,ct()),null;var i=Za(e,n);if(e.tag!==0&&i===2){var l=Fi(e);l!==0&&(n=l,i=al(e,l))}if(i===1)throw i=$s,pr(e,0),Qn(e,n),Mt(e,ct()),i;if(i===6)throw Error(a(345));return e.finishedWork=e.current.alternate,e.finishedLanes=n,gr(e,Ot,An),Mt(e,ct()),null}function ol(e,n){var i=Ue;Ue|=1;try{return e(n)}finally{Ue=i,Ue===0&&(Kr=ct()+500,Ca&&Hn())}}function mr(e){Jn!==null&&Jn.tag===0&&(Ue&6)===0&&Yr();var n=Ue;Ue|=1;var i=Zt.transition,l=Ve;try{if(Zt.transition=null,Ve=1,e)return e()}finally{Ve=l,Zt.transition=i,Ue=n,(Ue&6)===0&&Hn()}}function ll(){Gt=Gr.current,Ze(Gr)}function pr(e,n){e.finishedWork=null,e.finishedLanes=0;var i=e.timeoutHandle;if(i!==-1&&(e.timeoutHandle=-1,Rp(i)),ht!==null)for(i=ht.return;i!==null;){var l=i;switch(yo(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&ba();break;case 3:Wr(),Ze(Lt),Ze(Tt),Io();break;case 5:To(l);break;case 4:Wr();break;case 13:Ze(at);break;case 19:Ze(at);break;case 10:ko(l.type._context);break;case 22:case 23:ll()}i=i.return}if(St=e,ht=e=Xn(e.current,null),Ct=Gt=n,gt=0,$s=null,tl=Ka=hr=0,Ot=Ls=null,ur!==null){for(n=0;n<ur.length;n++)if(i=ur[n],l=i.interleaved,l!==null){i.interleaved=null;var u=l.next,m=i.pending;if(m!==null){var x=m.next;m.next=u,l.next=x}i.pending=l}ur=null}return e}function Od(e,n){do{var i=ht;try{if(So(),za.current=Ba,Fa){for(var l=it.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}Fa=!1}if(fr=0,jt=pt=it=null,Ts=!1,Rs=0,el.current=null,i===null||i.return===null){gt=1,$s=n,ht=null;break}e:{var m=e,x=i.return,b=i,I=n;if(n=Ct,b.flags|=32768,I!==null&&typeof I=="object"&&typeof I.then=="function"){var U=I,Q=b,ne=Q.tag;if((Q.mode&1)===0&&(ne===0||ne===11||ne===15)){var q=Q.alternate;q?(Q.updateQueue=q.updateQueue,Q.memoizedState=q.memoizedState,Q.lanes=q.lanes):(Q.updateQueue=null,Q.memoizedState=null)}var ye=cd(x);if(ye!==null){ye.flags&=-257,ud(ye,x,b,m,n),ye.mode&1&&ld(m,U,n),n=ye,I=U;var Se=n.updateQueue;if(Se===null){var be=new Set;be.add(I),n.updateQueue=be}else Se.add(I);break e}else{if((n&1)===0){ld(m,U,n),cl();break e}I=Error(a(426))}}else if(nt&&b.mode&1){var ut=cd(x);if(ut!==null){(ut.flags&65536)===0&&(ut.flags|=256),ud(ut,x,b,m,n),wo(Hr(I,b));break e}}m=I=Hr(I,b),gt!==4&&(gt=2),Ls===null?Ls=[m]:Ls.push(m),m=x;do{switch(m.tag){case 3:m.flags|=65536,n&=-n,m.lanes|=n;var z=id(m,I,n);_u(m,z);break e;case 1:b=I;var _=m.type,O=m.stateNode;if((m.flags&128)===0&&(typeof _.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(Yn===null||!Yn.has(O)))){m.flags|=65536,n&=-n,m.lanes|=n;var ce=od(m,b,n);_u(m,ce);break e}}m=m.return}while(m!==null)}Dd(i)}catch(Ne){n=Ne,ht===i&&i!==null&&(ht=i=i.return);continue}break}while(!0)}function Md(){var e=Ga.current;return Ga.current=Ba,e===null?Ba:e}function cl(){(gt===0||gt===3||gt===2)&&(gt=4),St===null||(hr&268435455)===0&&(Ka&268435455)===0||Qn(St,Ct)}function Za(e,n){var i=Ue;Ue|=2;var l=Md();(St!==e||Ct!==n)&&(An=null,pr(e,n));do try{eg();break}catch(u){Od(e,u)}while(!0);if(So(),Ue=i,Ga.current=l,ht!==null)throw Error(a(261));return St=null,Ct=0,gt}function eg(){for(;ht!==null;)Bd(ht)}function tg(){for(;ht!==null&&!Cm();)Bd(ht)}function Bd(e){var n=Hd(e.alternate,e,Gt);e.memoizedProps=e.pendingProps,n===null?Dd(e):ht=n,el.current=null}function Dd(e){var n=e;do{var i=n.alternate;if(e=n.return,(n.flags&32768)===0){if(i=Kp(i,n,Gt),i!==null){ht=i;return}}else{if(i=Yp(i,n),i!==null){i.flags&=32767,ht=i;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{gt=6,ht=null;return}}if(n=n.sibling,n!==null){ht=n;return}ht=n=e}while(n!==null);gt===0&&(gt=5)}function gr(e,n,i){var l=Ve,u=Zt.transition;try{Zt.transition=null,Ve=1,ng(e,n,i,l)}finally{Zt.transition=u,Ve=l}return null}function ng(e,n,i,l){do Yr();while(Jn!==null);if((Ue&6)!==0)throw Error(a(327));i=e.finishedWork;var u=e.finishedLanes;if(i===null)return null;if(e.finishedWork=null,e.finishedLanes=0,i===e.current)throw Error(a(177));e.callbackNode=null,e.callbackPriority=0;var m=i.lanes|i.childLanes;if(zm(e,m),e===St&&(ht=St=null,Ct=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||Ja||(Ja=!0,Vd(ra,function(){return Yr(),null})),m=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||m){m=Zt.transition,Zt.transition=null;var x=Ve;Ve=1;var b=Ue;Ue|=4,el.current=null,qp(e,i),Ad(i,e),Sp(lo),ua=!!oo,lo=oo=null,e.current=i,Qp(i),Em(),Ue=b,Ve=x,Zt.transition=m}else e.current=i;if(Ja&&(Ja=!1,Jn=e,qa=u),m=e.pendingLanes,m===0&&(Yn=null),Im(i.stateNode),Mt(e,ct()),n!==null)for(l=e.onRecoverableError,i=0;i<n.length;i++)u=n[i],l(u.value,{componentStack:u.stack,digest:u.digest});if(Ya)throw Ya=!1,e=rl,rl=null,e;return(qa&1)!==0&&e.tag!==0&&Yr(),m=e.pendingLanes,(m&1)!==0?e===sl?zs++:(zs=0,sl=e):zs=0,Hn(),null}function Yr(){if(Jn!==null){var e=Rc(qa),n=Zt.transition,i=Ve;try{if(Zt.transition=null,Ve=16>e?16:e,Jn===null)var l=!1;else{if(e=Jn,Jn=null,qa=0,(Ue&6)!==0)throw Error(a(331));var u=Ue;for(Ue|=4,xe=e.current;xe!==null;){var m=xe,x=m.child;if((xe.flags&16)!==0){var b=m.deletions;if(b!==null){for(var I=0;I<b.length;I++){var U=b[I];for(xe=U;xe!==null;){var Q=xe;switch(Q.tag){case 0:case 11:case 15:_s(8,Q,m)}var ne=Q.child;if(ne!==null)ne.return=Q,xe=ne;else for(;xe!==null;){Q=xe;var q=Q.sibling,ye=Q.return;if(Cd(Q),Q===U){xe=null;break}if(q!==null){q.return=ye,xe=q;break}xe=ye}}}var Se=m.alternate;if(Se!==null){var be=Se.child;if(be!==null){Se.child=null;do{var ut=be.sibling;be.sibling=null,be=ut}while(be!==null)}}xe=m}}if((m.subtreeFlags&2064)!==0&&x!==null)x.return=m,xe=x;else e:for(;xe!==null;){if(m=xe,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:_s(9,m,m.return)}var z=m.sibling;if(z!==null){z.return=m.return,xe=z;break e}xe=m.return}}var _=e.current;for(xe=_;xe!==null;){x=xe;var O=x.child;if((x.subtreeFlags&2064)!==0&&O!==null)O.return=x,xe=O;else e:for(x=_;xe!==null;){if(b=xe,(b.flags&2048)!==0)try{switch(b.tag){case 0:case 11:case 15:Va(9,b)}}catch(Ne){ot(b,b.return,Ne)}if(b===x){xe=null;break e}var ce=b.sibling;if(ce!==null){ce.return=b.return,xe=ce;break e}xe=b.return}}if(Ue=u,Hn(),gn&&typeof gn.onPostCommitFiberRoot=="function")try{gn.onPostCommitFiberRoot(sa,e)}catch{}l=!0}return l}finally{Ve=i,Zt.transition=n}}return!1}function Ud(e,n,i){n=Hr(i,n),n=id(e,n,1),e=Gn(e,n,1),n=_t(),e!==null&&(is(e,1,n),Mt(e,n))}function ot(e,n,i){if(e.tag===3)Ud(e,e,i);else for(;n!==null;){if(n.tag===3){Ud(n,e,i);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Yn===null||!Yn.has(l))){e=Hr(i,e),e=od(n,e,1),n=Gn(n,e,1),e=_t(),n!==null&&(is(n,1,e),Mt(n,e));break}}n=n.return}}function rg(e,n,i){var l=e.pingCache;l!==null&&l.delete(n),n=_t(),e.pingedLanes|=e.suspendedLanes&i,St===e&&(Ct&i)===i&&(gt===4||gt===3&&(Ct&130023424)===Ct&&500>ct()-nl?pr(e,0):tl|=i),Mt(e,n)}function Wd(e,n){n===0&&((e.mode&1)===0?n=1:(n=ia,ia<<=1,(ia&130023424)===0&&(ia=4194304)));var i=_t();e=Tn(e,n),e!==null&&(is(e,n,i),Mt(e,i))}function sg(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Wd(e,i)}function ag(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,u=e.memoizedState;u!==null&&(i=u.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(a(314))}l!==null&&l.delete(n),Wd(e,i)}var Hd;Hd=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Lt.current)Ft=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Ft=!1,Gp(e,n,i);Ft=(e.flags&131072)!==0}else Ft=!1,nt&&(n.flags&1048576)!==0&&ku(n,Ta,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Wa(e,n),e=n.pendingProps;var u=zr(n,Tt.current);Ur(n,i),u=_o(null,n,l,e,u,i);var m=$o();return n.flags|=1,typeof u=="object"&&u!==null&&typeof u.render=="function"&&u.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,zt(l)?(m=!0,Na(n)):m=!1,n.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,Co(n),u.updater=Da,n.stateNode=u,u._reactInternals=n,Bo(n,l,e,i),n=Ho(null,n,l,!0,m,i)):(n.tag=0,nt&&m&&go(n),Pt(null,n,u,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Wa(e,n),e=n.pendingProps,u=l._init,l=u(l._payload),n.type=l,u=n.tag=og(l),e=ln(l,e),u){case 0:n=Wo(null,n,l,e,i);break e;case 1:n=gd(null,n,l,e,i);break e;case 11:n=dd(null,n,l,e,i);break e;case 14:n=fd(null,n,l,ln(l.type,e),i);break e}throw Error(a(306,l,""))}return n;case 0:return l=n.type,u=n.pendingProps,u=n.elementType===l?u:ln(l,u),Wo(e,n,l,u,i);case 1:return l=n.type,u=n.pendingProps,u=n.elementType===l?u:ln(l,u),gd(e,n,l,u,i);case 3:e:{if(yd(n),e===null)throw Error(a(387));l=n.pendingProps,m=n.memoizedState,u=m.element,Pu(e,n),$a(n,l,null,i);var x=n.memoizedState;if(l=x.element,m.isDehydrated)if(m={element:l,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},n.updateQueue.baseState=m,n.memoizedState=m,n.flags&256){u=Hr(Error(a(423)),n),n=vd(e,n,l,i,u);break e}else if(l!==u){u=Hr(Error(a(424)),n),n=vd(e,n,l,i,u);break e}else for(Vt=Dn(n.stateNode.containerInfo.firstChild),Ht=n,nt=!0,on=null,i=Iu(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Mr(),l===u){n=In(e,n,i);break e}Pt(e,n,l,i)}n=n.child}return n;case 5:return Lu(n),e===null&&xo(n),l=n.type,u=n.pendingProps,m=e!==null?e.memoizedProps:null,x=u.children,co(l,u)?x=null:m!==null&&co(l,m)&&(n.flags|=32),pd(e,n),Pt(e,n,x,i),n.child;case 6:return e===null&&xo(n),null;case 13:return xd(e,n,i);case 4:return Eo(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=Br(n,null,l,i):Pt(e,n,l,i),n.child;case 11:return l=n.type,u=n.pendingProps,u=n.elementType===l?u:ln(l,u),dd(e,n,l,u,i);case 7:return Pt(e,n,n.pendingProps,i),n.child;case 8:return Pt(e,n,n.pendingProps.children,i),n.child;case 12:return Pt(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,u=n.pendingProps,m=n.memoizedProps,x=u.value,qe(Aa,l._currentValue),l._currentValue=x,m!==null)if(an(m.value,x)){if(m.children===u.children&&!Lt.current){n=In(e,n,i);break e}}else for(m=n.child,m!==null&&(m.return=n);m!==null;){var b=m.dependencies;if(b!==null){x=m.child;for(var I=b.firstContext;I!==null;){if(I.context===l){if(m.tag===1){I=Rn(-1,i&-i),I.tag=2;var U=m.updateQueue;if(U!==null){U=U.shared;var Q=U.pending;Q===null?I.next=I:(I.next=Q.next,Q.next=I),U.pending=I}}m.lanes|=i,I=m.alternate,I!==null&&(I.lanes|=i),bo(m.return,i,n),b.lanes|=i;break}I=I.next}}else if(m.tag===10)x=m.type===n.type?null:m.child;else if(m.tag===18){if(x=m.return,x===null)throw Error(a(341));x.lanes|=i,b=x.alternate,b!==null&&(b.lanes|=i),bo(x,i,n),x=m.sibling}else x=m.child;if(x!==null)x.return=m;else for(x=m;x!==null;){if(x===n){x=null;break}if(m=x.sibling,m!==null){m.return=x.return,x=m;break}x=x.return}m=x}Pt(e,n,u.children,i),n=n.child}return n;case 9:return u=n.type,l=n.pendingProps.children,Ur(n,i),u=Qt(u),l=l(u),n.flags|=1,Pt(e,n,l,i),n.child;case 14:return l=n.type,u=ln(l,n.pendingProps),u=ln(l.type,u),fd(e,n,l,u,i);case 15:return hd(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,u=n.pendingProps,u=n.elementType===l?u:ln(l,u),Wa(e,n),n.tag=1,zt(l)?(e=!0,Na(n)):e=!1,Ur(n,i),sd(n,l,u),Bo(n,l,u,i),Ho(null,n,l,!0,e,i);case 19:return jd(e,n,i);case 22:return md(e,n,i)}throw Error(a(156,n.tag))};function Vd(e,n){return bc(e,n)}function ig(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function en(e,n,i,l){return new ig(e,n,i,l)}function ul(e){return e=e.prototype,!(!e||!e.isReactComponent)}function og(e){if(typeof e=="function")return ul(e)?1:0;if(e!=null){if(e=e.$$typeof,e===M)return 11;if(e===Z)return 14}return 2}function Xn(e,n){var i=e.alternate;return i===null?(i=en(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function ei(e,n,i,l,u,m){var x=2;if(l=e,typeof e=="function")ul(e)&&(x=1);else if(typeof e=="string")x=5;else e:switch(e){case H:return yr(i.children,u,m,n);case ie:x=8,u|=8;break;case Y:return e=en(12,i,n,u|2),e.elementType=Y,e.lanes=m,e;case fe:return e=en(13,i,n,u),e.elementType=fe,e.lanes=m,e;case oe:return e=en(19,i,n,u),e.elementType=oe,e.lanes=m,e;case ee:return ti(i,u,m,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case re:x=10;break e;case J:x=9;break e;case M:x=11;break e;case Z:x=14;break e;case pe:x=16,l=null;break e}throw Error(a(130,e==null?e:typeof e,""))}return n=en(x,i,n,u),n.elementType=e,n.type=l,n.lanes=m,n}function yr(e,n,i,l){return e=en(7,e,l,n),e.lanes=i,e}function ti(e,n,i,l){return e=en(22,e,l,n),e.elementType=ee,e.lanes=i,e.stateNode={isHidden:!1},e}function dl(e,n,i){return e=en(6,e,null,n),e.lanes=i,e}function fl(e,n,i){return n=en(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function lg(e,n,i,l,u){this.tag=n,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=Oi(0),this.expirationTimes=Oi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Oi(0),this.identifierPrefix=l,this.onRecoverableError=u,this.mutableSourceEagerHydrationData=null}function hl(e,n,i,l,u,m,x,b,I){return e=new lg(e,n,i,b,I),n===1?(n=1,m===!0&&(n|=8)):n=0,m=en(3,null,null,n),e.current=m,m.stateNode=e,m.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Co(m),e}function cg(e,n,i){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:G,key:l==null?null:""+l,children:e,containerInfo:n,implementation:i}}function Gd(e){if(!e)return Wn;e=e._reactInternals;e:{if(ar(e)!==e||e.tag!==1)throw Error(a(170));var n=e;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(zt(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(a(171))}if(e.tag===1){var i=e.type;if(zt(i))return wu(e,i,n)}return n}function Kd(e,n,i,l,u,m,x,b,I){return e=hl(i,l,!0,e,u,m,x,b,I),e.context=Gd(null),i=e.current,l=_t(),u=qn(i),m=Rn(l,u),m.callback=n??null,Gn(i,m,u),e.current.lanes=u,is(e,u,l),Mt(e,l),e}function ni(e,n,i,l){var u=n.current,m=_t(),x=qn(u);return i=Gd(i),n.context===null?n.context=i:n.pendingContext=i,n=Rn(m,x),n.payload={element:e},l=l===void 0?null:l,l!==null&&(n.callback=l),e=Gn(u,n,x),e!==null&&(dn(e,u,x,m),_a(e,u,x)),x}function ri(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 Yd(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var i=e.retryLane;e.retryLane=i!==0&&i<n?i:n}}function ml(e,n){Yd(e,n),(e=e.alternate)&&Yd(e,n)}function ug(){return null}var Jd=typeof reportError=="function"?reportError:function(e){console.error(e)};function pl(e){this._internalRoot=e}si.prototype.render=pl.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));ni(e,n,null,null)},si.prototype.unmount=pl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;mr(function(){ni(null,e,null,null)}),n[bn]=null}};function si(e){this._internalRoot=e}si.prototype.unstable_scheduleHydration=function(e){if(e){var n=Pc();e={blockedOn:null,target:e,priority:n};for(var i=0;i<On.length&&n!==0&&n<On[i].priority;i++);On.splice(i,0,e),i===0&&Lc(e)}};function gl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ai(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function qd(){}function dg(e,n,i,l,u){if(u){if(typeof l=="function"){var m=l;l=function(){var U=ri(x);m.call(U)}}var x=Kd(n,l,e,0,null,!1,!1,"",qd);return e._reactRootContainer=x,e[bn]=x.current,ws(e.nodeType===8?e.parentNode:e),mr(),x}for(;u=e.lastChild;)e.removeChild(u);if(typeof l=="function"){var b=l;l=function(){var U=ri(I);b.call(U)}}var I=hl(e,0,!1,null,null,!1,!1,"",qd);return e._reactRootContainer=I,e[bn]=I.current,ws(e.nodeType===8?e.parentNode:e),mr(function(){ni(n,I,i,l)}),I}function ii(e,n,i,l,u){var m=i._reactRootContainer;if(m){var x=m;if(typeof u=="function"){var b=u;u=function(){var I=ri(x);b.call(I)}}ni(n,x,e,u)}else x=dg(i,n,e,u,l);return ri(x)}Ic=function(e){switch(e.tag){case 3:var n=e.stateNode;if(n.current.memoizedState.isDehydrated){var i=as(n.pendingLanes);i!==0&&(Mi(n,i|1),Mt(n,ct()),(Ue&6)===0&&(Kr=ct()+500,Hn()))}break;case 13:mr(function(){var l=Tn(e,1);if(l!==null){var u=_t();dn(l,e,1,u)}}),ml(e,1)}},Bi=function(e){if(e.tag===13){var n=Tn(e,134217728);if(n!==null){var i=_t();dn(n,e,134217728,i)}ml(e,134217728)}},Ac=function(e){if(e.tag===13){var n=qn(e),i=Tn(e,n);if(i!==null){var l=_t();dn(i,e,n,l)}ml(e,n)}},Pc=function(){return Ve},_c=function(e,n){var i=Ve;try{return Ve=e,n()}finally{Ve=i}},ae=function(e,n,i){switch(n){case"input":if($e(e,i),n=i.name,i.type==="radio"&&n!=null){for(i=e;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),n=0;n<i.length;n++){var l=i[n];if(l!==e&&l.form===e.form){var u=ka(l);if(!u)throw Error(a(90));_e(l),$e(l,u)}}}break;case"textarea":Fe(e,i);break;case"select":n=i.value,n!=null&&et(e,!!i.multiple,n,!1)}},Ut=ol,er=mr;var fg={usingClientEntryPoint:!1,Events:[ks,$r,ka,ze,Je,ol]},Fs={findFiberByHostInstance:ir,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},hg={bundleType:Fs.bundleType,version:Fs.version,rendererPackageName:Fs.rendererPackageName,rendererConfig:Fs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:P.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Sc(e),e===null?null:e.stateNode},findFiberByHostInstance:Fs.findFiberByHostInstance||ug,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 oi=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!oi.isDisabled&&oi.supportsFiber)try{sa=oi.inject(hg),gn=oi}catch{}}return Bt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=fg,Bt.createPortal=function(e,n){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!gl(n))throw Error(a(200));return cg(e,n,null,i)},Bt.createRoot=function(e,n){if(!gl(e))throw Error(a(299));var i=!1,l="",u=Jd;return n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(u=n.onRecoverableError)),n=hl(e,1,!1,null,null,i,!1,l,u),e[bn]=n.current,ws(e.nodeType===8?e.parentNode:e),new pl(n)},Bt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=Sc(n),e=e===null?null:e.stateNode,e},Bt.flushSync=function(e){return mr(e)},Bt.hydrate=function(e,n,i){if(!ai(n))throw Error(a(200));return ii(null,e,n,!0,i)},Bt.hydrateRoot=function(e,n,i){if(!gl(e))throw Error(a(405));var l=i!=null&&i.hydratedSources||null,u=!1,m="",x=Jd;if(i!=null&&(i.unstable_strictMode===!0&&(u=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(x=i.onRecoverableError)),n=Kd(n,null,e,1,i??null,u,!1,m,x),e[bn]=n.current,ws(e),l)for(e=0;e<l.length;e++)i=l[e],u=i._getVersion,u=u(i._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[i,u]:n.mutableSourceEagerHydrationData.push(i,u);return new si(n)},Bt.render=function(e,n,i){if(!ai(n))throw Error(a(200));return ii(null,e,n,!1,i)},Bt.unmountComponentAtNode=function(e){if(!ai(e))throw Error(a(40));return e._reactRootContainer?(mr(function(){ii(null,null,e,!1,function(){e._reactRootContainer=null,e[bn]=null})}),!0):!1},Bt.unstable_batchedUpdates=ol,Bt.unstable_renderSubtreeIntoContainer=function(e,n,i,l){if(!ai(i))throw Error(a(200));if(e==null||e._reactInternals===void 0)throw Error(a(38));return ii(e,n,i,!1,l)},Bt.version="18.3.1-next-f1338f8080-20240426",Bt}var sf;function nh(){if(sf)return xl.exports;sf=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(s){console.error(s)}}return t(),xl.exports=Sg(),xl.exports}var af;function kg(){if(af)return li;af=1;var t=nh();return li.createRoot=t.createRoot,li.hydrateRoot=t.hydrateRoot,li}var bg=kg();/**
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 Kl=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,rh=/^[\\/]{2}/;function Ng(t,s){return s+t.replace(/\\/g,"/")}var of="popstate";function lf(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function Cg(t={}){function s(o,c){var g;let d=(g=c.state)==null?void 0:g.masked,{pathname:h,search:y,hash:p}=d||o.location;return _l("",{pathname:h,search:y,hash:p},c.state&&c.state.usr||null,c.state&&c.state.key||"default",d?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function a(o,c){return typeof c=="string"?c:kr(c)}return Tg(s,a,null,t)}function rt(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function rn(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Eg(){return Math.random().toString(36).substring(2,10)}function cf(t,s){return{usr:t.state,key:t.key,idx:s,masked:t.mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function _l(t,s,a=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof s=="string"?es(s):s,state:a,key:s&&s.key||o||Eg(),mask:c}}function kr({pathname:t="/",search:s="",hash:a=""}){return s&&s!=="?"&&(t+=s.charAt(0)==="?"?s:"?"+s),a&&a!=="#"&&(t+=a.charAt(0)==="#"?a:"#"+a),t}function es(t){let s={};if(t){let a=t.indexOf("#");a>=0&&(s.hash=t.substring(a),t=t.substring(0,a));let o=t.indexOf("?");o>=0&&(s.search=t.substring(o),t=t.substring(0,o)),t&&(s.pathname=t)}return s}function Tg(t,s,a,o={}){let{window:c=document.defaultView,v5Compat:d=!1}=o,h=c.history,y="POP",p=null,g=v();g==null&&(g=0,h.replaceState({...h.state,idx:g},""));function v(){return(h.state||{idx:null}).idx}function w(){y="POP";let C=v(),T=C==null?null:C-g;g=C,p&&p({action:y,location:S.location,delta:T})}function j(C,T){y="PUSH";let R=lf(C)?C:_l(S.location,C,T);g=v()+1;let L=cf(R,g),P=S.createHref(R.mask||R);try{h.pushState(L,"",P)}catch(F){if(F instanceof DOMException&&F.name==="DataCloneError")throw F;c.location.assign(P)}d&&p&&p({action:y,location:S.location,delta:1})}function N(C,T){y="REPLACE";let R=lf(C)?C:_l(S.location,C,T);g=v();let L=cf(R,g),P=S.createHref(R.mask||R);h.replaceState(L,"",P),d&&p&&p({action:y,location:S.location,delta:0})}function E(C){return Rg(c,C)}let S={get action(){return y},get location(){return t(c,h)},listen(C){if(p)throw new Error("A history only accepts one active listener");return c.addEventListener(of,w),p=C,()=>{c.removeEventListener(of,w),p=null}},createHref(C){return s(c,C)},createURL:E,encodeLocation(C){let T=E(C);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:j,replace:N,go(C){return h.go(C)}};return S}function Rg(t,s,a=!1){let o="http://localhost";t&&(o=t.location.origin!=="null"?t.location.origin:t.location.href),rt(o,"No window.location.(origin|href) available to create URL");let c=typeof s=="string"?s:kr(s);return c=c.replace(/ $/,"%20"),!a&&rh.test(c)&&(c=o+c),new URL(c,o)}function sh(t,s,a="/"){return Ig(t,s,a,!1)}function Ig(t,s,a,o,c){let d=typeof s=="string"?es(s):s,h=_n(d.pathname||"/",a);if(h==null)return null;let y=Ag(t),p=null,g=Ug(h);for(let v=0;p==null&&v<y.length;++v)p=Dg(y[v],g,o);return p}function Ag(t){let s=ah(t);return Pg(s),s}function ah(t,s=[],a=[],o="",c=!1){let d=(h,y,p=c,g)=>{let v={relativePath:g===void 0?h.path||"":g,caseSensitive:h.caseSensitive===!0,childrenIndex:y,route:h};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(o)&&p)return;rt(v.relativePath.startsWith(o),`Absolute route path "${v.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(o.length)}let w=fn([o,v.relativePath]),j=a.concat(v);h.children&&h.children.length>0&&(rt(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${w}".`),ah(h.children,s,j,w,p)),!(h.path==null&&!h.index)&&s.push({path:w,score:Mg(w,h.index),routesMeta:j.map((N,E)=>{let[S,C]=lh(N.relativePath,N.caseSensitive,E===j.length-1);return{...N,matcher:S,compiledParams:C}})})};return t.forEach((h,y)=>{var p;if(h.path===""||!((p=h.path)!=null&&p.includes("?")))d(h,y);else for(let g of ih(h.path))d(h,y,!0,g)}),s}function ih(t){let s=t.split("/");if(s.length===0)return[];let[a,...o]=s,c=a.endsWith("?"),d=a.replace(/\?$/,"");if(o.length===0)return c?[d,""]:[d];let h=ih(o.join("/")),y=[];return y.push(...h.map(p=>p===""?d:[d,p].join("/"))),c&&y.push(...h),y.map(p=>t.startsWith("/")&&p===""?"/":p)}function Pg(t){t.sort((s,a)=>s.score!==a.score?a.score-s.score:Bg(s.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var _g=/^:[\w-]+$/,$g=3,Lg=2,zg=1,Fg=10,Og=-2,uf=t=>t==="*";function Mg(t,s){let a=t.split("/"),o=a.length;return a.some(uf)&&(o+=Og),s&&(o+=Lg),a.filter(c=>!uf(c)).reduce((c,d)=>c+(_g.test(d)?$g:d===""?zg:Fg),o)}function Bg(t,s){return t.length===s.length&&t.slice(0,-1).every((o,c)=>o===s[c])?t[t.length-1]-s[s.length-1]:0}function Dg(t,s,a=!1){let{routesMeta:o}=t,c={},d="/",h=[];for(let y=0;y<o.length;++y){let p=o[y],g=y===o.length-1,v=d==="/"?s:s.slice(d.length)||"/",w={path:p.relativePath,caseSensitive:p.caseSensitive,end:g},j=p.matcher&&p.compiledParams?oh(w,v,p.matcher,p.compiledParams):ji(w,v),N=p.route;if(!j&&g&&a&&!o[o.length-1].route.index&&(j=ji({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},v)),!j)return null;Object.assign(c,j.params),h.push({params:c,pathname:fn([d,j.pathname]),pathnameBase:Vg(fn([d,j.pathnameBase])),route:N}),j.pathnameBase!=="/"&&(d=fn([d,j.pathnameBase]))}return h}function ji(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[a,o]=lh(t.path,t.caseSensitive,t.end);return oh(t,s,a,o)}function oh(t,s,a,o){let c=s.match(a);if(!c)return null;let d=c[0],h=Xr(d,1),y=c.slice(1);return{params:o.reduce((g,{paramName:v,isOptional:w},j)=>{if(v==="*"){let E=y[j]||"";h=Xr(d.slice(0,d.length-E.length),1)}const N=y[j];return w&&!N?g[v]=void 0:g[v]=(N||"").replace(/%2F/g,"/"),g},{}),pathname:d,pathnameBase:h,pattern:t}}function lh(t,s=!1,a=!0){rn(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,y,p,g,v)=>{if(o.push({paramName:y,isOptional:p!=null}),p){let w=v.charAt(g+h.length);return w&&w!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,s?void 0:"i"),o]}function Ug(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return rn(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),t}}function _n(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let a=s.endsWith("/")?s.length-1:s.length,o=t.charAt(a);return o&&o!=="/"?null:t.slice(a)||"/"}function Wg(t,s="/"){let{pathname:a,search:o="",hash:c=""}=typeof t=="string"?es(t):t,d;return a?(a=ch(a),a.startsWith("/")||a.startsWith("\\")?d=df(a.substring(1),"/"):d=df(a,s)):d=s,{pathname:d,search:Gg(o),hash:Kg(c)}}function df(t,s){let a=Xr(s).split("/");return t.split("/").forEach(c=>{c===".."?a.length>1&&a.pop():c!=="."&&a.push(c)}),a.length>1?a.join("/"):"/"}function Sl(t,s,a,o){return`Cannot include a '${t}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Hg(t){return t.filter((s,a)=>a===0||s.route.path&&s.route.path.length>0)}function Yl(t){let s=Hg(t);return s.map((a,o)=>o===s.length-1?a.pathname:a.pathnameBase)}function Ii(t,s,a,o=!1){let c;typeof t=="string"?c=es(t):(c={...t},rt(!c.pathname||!c.pathname.includes("?"),Sl("?","pathname","search",c)),rt(!c.pathname||!c.pathname.includes("#"),Sl("#","pathname","hash",c)),rt(!c.search||!c.search.includes("#"),Sl("#","search","hash",c)));let d=t===""||c.pathname==="",h=d?"/":c.pathname,y;if(h==null)y=a;else{let w=s.length-1;if(!o&&h.startsWith("..")){let j=h.split("/");for(;j[0]==="..";)j.shift(),w-=1;c.pathname=j.join("/")}y=w>=0?s[w]:"/"}let p=Wg(c,y),g=h&&h!=="/"&&h.endsWith("/"),v=(d||h===".")&&a.endsWith("/");return!p.pathname.endsWith("/")&&(g||v)&&(p.pathname+="/"),p}var ch=t=>t.replace(/[\\/]{2,}/g,"/"),fn=t=>ch(t.join("/"));function Xr(t,s=0){let a=t.length;for(;a>s&&t.charCodeAt(a-1)===47;)a--;return a===t.length?t:t.slice(0,a)}var Vg=t=>Xr(t).replace(/^\/*/,"/"),Gg=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Kg=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,Yg=class{constructor(t,s,a,o=!1){this.status=t,this.statusText=s||"",this.internal=o,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function Jg(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function qg(t){let s=t.map(a=>a.route.path).filter(Boolean);return fn(s)||"/"}var uh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function dh(t,s){let a=t;if(typeof a!="string"||!Kl.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,c=!1;if(uh)try{let d=new URL(window.location.href),h=rh.test(a)?new URL(Ng(a,d.protocol)):new URL(a),y=_n(h.pathname,s);h.origin===d.origin&&y!=null?a=y+h.search+h.hash:c=!0}catch{rn(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var ff=new URL("http://localhost");function Jl(t){if(t.createURL)return t.createURL("/");try{return new URL(t.createHref("/"),ff)}catch{return ff}}function kl(t,s){return t.origin===s.origin&&(t.origin!=="null"||t.protocol===s.protocol&&t.host===s.host)}function Qg(t,s){if(t.startsWith("//"))return!0;let a=s.protocol.toLowerCase();return t.toLowerCase().startsWith(a)?s.host===""||t.slice(a.length).startsWith("//"):!1}function ql(t,s,a,o){let c=null;try{c=t==null?null:new URL(t,a)}catch{}let d=new URL(s,a),h=c!=null&&!kl(c,a),y=!kl(d,a);if(o==="reject"){if(h||y)throw new Error("External navigation is not allowed")}else if(y&&(c==null||!Qg(t,c)||!kl(c,d)))throw new Error("External navigation is not allowed")}var fh=["POST","PUT","PATCH","DELETE"];new Set(fh);var Xg=["GET",...fh];new Set(Xg);var Zg=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function ey(t){try{return Zg.includes(new URL(t).protocol)}catch{return!1}}var ts=f.createContext(null);ts.displayName="DataRouter";var Ai=f.createContext(null);Ai.displayName="DataRouterState";var hh=f.createContext(!1);function ty(){return f.useContext(hh)}var mh=f.createContext({isTransitioning:!1});mh.displayName="ViewTransition";var ny=f.createContext(new Map);ny.displayName="Fetchers";var ry=f.createContext(null);ry.displayName="Await";var Yt=f.createContext(null);Yt.displayName="Navigation";var Qs=f.createContext(null);Qs.displayName="Location";var hn=f.createContext({outlet:null,matches:[],isDataRoute:!1});hn.displayName="Route";var Ql=f.createContext(null);Ql.displayName="RouteError";var ph="REACT_ROUTER_ERROR",sy="REDIRECT",ay="ROUTE_ERROR_RESPONSE";function iy(t){if(t.startsWith(`${ph}:${sy}:{`))try{let s=JSON.parse(t.slice(28));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string"&&typeof s.location=="string"&&typeof s.reloadDocument=="boolean"&&typeof s.replace=="boolean")return s}catch{}}function oy(t){if(t.startsWith(`${ph}:${ay}:{`))try{let s=JSON.parse(t.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new Yg(s.status,s.statusText,s.data)}catch{}}function ly(t,{relative:s}={}){rt(ns(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:o}=f.useContext(Yt),{hash:c,pathname:d,search:h}=Xs(t,{relative:s}),y=d;return a!=="/"&&(y=d==="/"?a:fn([a,d])),o.createHref({pathname:y,search:h,hash:c})}function ns(){return f.useContext(Qs)!=null}function Dt(){return rt(ns(),"useLocation() may be used only in the context of a <Router> component."),f.useContext(Qs).location}var gh="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function yh(t){f.useContext(Yt).static||f.useLayoutEffect(t)}function mn(){let{isDataRoute:t}=f.useContext(hn);return t?ky():cy()}function cy(){rt(ns(),"useNavigate() may be used only in the context of a <Router> component.");let t=f.useContext(ts),{basename:s,navigator:a}=f.useContext(Yt),{matches:o}=f.useContext(hn),{pathname:c}=Dt(),d=JSON.stringify(Yl(o)),h=f.useRef(!1);return yh(()=>{h.current=!0}),f.useCallback((p,g={})=>{if(rn(h.current,gh),!h.current)return;if(typeof p=="number"){a.go(p);return}let v=Ii(p,JSON.parse(d),c,g.relative==="path");t==null&&s!=="/"&&(v.pathname=v.pathname==="/"?s:fn([s,v.pathname])),ql(typeof p=="string"?p:kr(p),a.createHref(v),Jl(a),"reject"),(g.replace?a.replace:a.push)(v,g.state,g)},[s,a,d,c,t])}var uy=f.createContext(null);function dy(t){let s=f.useContext(hn).outlet;return f.useMemo(()=>s&&f.createElement(uy.Provider,{value:t},s),[s,t])}function Xs(t,{relative:s}={}){let{matches:a}=f.useContext(hn),{pathname:o}=Dt(),c=JSON.stringify(Yl(a));return f.useMemo(()=>Ii(t,JSON.parse(c),o,s==="path"),[t,c,o,s])}function fy(t,s){return vh(t,s)}function vh(t,s,a){var C;rt(ns(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=f.useContext(Yt),{matches:c}=f.useContext(hn),d=c[c.length-1],h=d?d.params:{},y=d?d.pathname:"/",p=d?d.pathnameBase:"/",g=d&&d.route;{let T=g&&g.path||"";wh(y,!g||T.endsWith("*")||T.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${y}" (under <Route path="${T}">) 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="${T}"> to <Route path="${T==="/"?"*":`${T}/*`}">.`)}let v=Dt(),w;if(s){let T=typeof s=="string"?es(s):s;rt(p==="/"||((C=T.pathname)==null?void 0:C.startsWith(p)),`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 "${p}" but pathname "${T.pathname}" was given in the \`location\` prop.`),w=T}else w=v;let j=w.pathname||"/",N=j;if(p!=="/"){let T=p.replace(/^\//,"").split("/");N="/"+j.replace(/^\//,"").split("/").slice(T.length).join("/")}let E=a&&a.state.matches.length?a.state.matches.map(T=>Object.assign(T,{route:a.manifest[T.route.id]||T.route})):sh(t,{pathname:N});rn(g||E!=null,`No routes matched location "${w.pathname}${w.search}${w.hash}" `),rn(E==null||E[E.length-1].route.element!==void 0||E[E.length-1].route.Component!==void 0||E[E.length-1].route.lazy!==void 0,`Matched leaf route at location "${w.pathname}${w.search}${w.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 S=yy(E&&E.map(T=>Object.assign({},T,{params:Object.assign({},h,T.params),pathname:fn([p,o.encodeLocation?o.encodeLocation(T.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathname]),pathnameBase:T.pathnameBase==="/"?p:fn([p,o.encodeLocation?o.encodeLocation(T.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathnameBase])})),c,a);return s&&S?f.createElement(Qs.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...w},navigationType:"POP"}},S):S}function hy(){let t=Sy(),s=Jg(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),a=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},d={padding:"2px 4px",backgroundColor:o},h=null;return console.error("Error handled by React Router default ErrorBoundary:",t),h=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:d},"ErrorBoundary")," or"," ",f.createElement("code",{style:d},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},s),a?f.createElement("pre",{style:c},a):null,h)}var my=f.createElement(hy,null),xh=class extends f.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,s){return s.location!==t.location||s.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:s.error,location:s.location,revalidation:t.revalidation||s.revalidation}}componentDidCatch(t,s){this.props.onError?this.props.onError(t,s):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const a=oy(t.digest);a&&(t=a)}let s=t!==void 0?f.createElement(hn.Provider,{value:this.props.routeContext},f.createElement(Ql.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?f.createElement(py,{error:t},s):s}};xh.contextType=hh;var bl=new WeakMap;function py({children:t,error:s}){let{basename:a,navigator:o}=f.useContext(Yt);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let c=iy(s.digest);if(c){let d=bl.get(s);if(d)throw d;let h=dh(c.location,a),y=h.absoluteURL||h.to;if(ql(c.location,y,Jl(o),"allow-explicit"),ey(y))throw new Error("Invalid redirect location");if(uh&&!bl.get(s))if(h.isExternal||c.reloadDocument)window.location.href=y;else{const p=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(h.to,{replace:c.replace}));throw bl.set(s,p),p}return f.createElement("meta",{httpEquiv:"refresh",content:`0;url=${y}`})}}return t}function gy({routeContext:t,match:s,children:a}){let o=f.useContext(ts);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),f.createElement(hn.Provider,{value:t},a)}function yy(t,s=[],a){let o=a==null?void 0:a.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let c=t,d=o==null?void 0:o.errors;if(d!=null){let v=c.findIndex(w=>w.route.id&&(d==null?void 0:d[w.route.id])!==void 0);rt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(d).join(",")}`),c=c.slice(0,Math.min(c.length,v+1))}let h=!1,y=-1;if(a&&o){h=o.renderFallback;for(let v=0;v<c.length;v++){let w=c[v];if((w.route.HydrateFallback||w.route.hydrateFallbackElement)&&(y=v),w.route.id){let{loaderData:j,errors:N}=o,E=w.route.loader&&!j.hasOwnProperty(w.route.id)&&(!N||N[w.route.id]===void 0);if(w.route.lazy||E){a.isStatic&&(h=!0),y>=0?c=c.slice(0,y+1):c=[c[0]];break}}}}let p=a==null?void 0:a.onError,g=o&&p?(v,w)=>{var j,N;p(v,{location:o.location,params:((N=(j=o.matches)==null?void 0:j[0])==null?void 0:N.params)??{},pattern:qg(o.matches),errorInfo:w})}:void 0;return c.reduceRight((v,w,j)=>{let N,E=!1,S=null,C=null;o&&(N=d&&w.route.id?d[w.route.id]:void 0,S=w.route.errorElement||my,h&&(y<0&&j===0?(wh("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,C=null):y===j&&(E=!0,C=w.route.hydrateFallbackElement||null)));let T=s.concat(c.slice(0,j+1)),R=()=>{let L;return N?L=S:E?L=C:w.route.Component?L=f.createElement(w.route.Component,null):w.route.element?L=w.route.element:L=v,f.createElement(gy,{match:w,routeContext:{outlet:v,matches:T,isDataRoute:o!=null},children:L})};return o&&(w.route.ErrorBoundary||w.route.errorElement||j===0)?f.createElement(xh,{location:o.location,revalidation:o.revalidation,component:S,error:N,children:R(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:g}):R()},null)}function Xl(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function vy(t){let s=f.useContext(ts);return rt(s,Xl(t)),s}function xy(t){let s=f.useContext(Ai);return rt(s,Xl(t)),s}function wy(t){let s=f.useContext(hn);return rt(s,Xl(t)),s}function Zl(t){let s=wy(t),a=s.matches[s.matches.length-1];return rt(a.route.id,`${t} can only be used on routes that contain a unique "id"`),a.route.id}function jy(){return Zl("useRouteId")}function Sy(){var o;let t=f.useContext(Ql),s=xy("useRouteError"),a=Zl("useRouteError");return t!==void 0?t:(o=s.errors)==null?void 0:o[a]}function ky(){let{router:t}=vy("useNavigate"),s=Zl("useNavigate"),a=f.useRef(!1);return yh(()=>{a.current=!0}),f.useCallback(async(c,d={})=>{rn(a.current,gh),a.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:s,...d}))},[t,s])}var hf={};function wh(t,s,a){!s&&!hf[t]&&(hf[t]=!0,rn(!1,a))}f.memo(by);function by({routes:t,manifest:s,future:a,state:o,isStatic:c,onError:d}){return vh(t,void 0,{manifest:s,state:o,isStatic:c,onError:d})}function Pn({to:t,replace:s,state:a,relative:o}){rt(ns(),"<Navigate> may be used only in the context of a <Router> component.");let{static:c,navigator:d}=f.useContext(Yt);rn(!c,"<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:h}=f.useContext(hn),{pathname:y}=Dt(),p=mn(),g=Ii(t,Yl(h),y,o==="path");ql(typeof t=="string"?t:kr(t),d.createHref(g),Jl(d),"reject");let v=JSON.stringify(g);return f.useEffect(()=>{p(JSON.parse(v),{replace:s,state:a,relative:o})},[p,v,o,s,a]),null}function Ny(t){return dy(t.context)}function Qe(t){rt(!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 Cy({basename:t="/",children:s=null,location:a,navigationType:o="POP",navigator:c,static:d=!1,useTransitions:h}){rt(!ns(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let y=t.replace(/^\/*/,"/"),p=f.useMemo(()=>({basename:y,navigator:c,static:d,useTransitions:h,future:{}}),[y,c,d,h]);typeof a=="string"&&(a=es(a));let{pathname:g="/",search:v="",hash:w="",state:j=null,key:N="default",mask:E}=a,S=f.useMemo(()=>{let C=_n(g,y);return C==null?null:{location:{pathname:C,search:v,hash:w,state:j,key:N,mask:E},navigationType:o}},[y,g,v,w,j,N,o,E]);return rn(S!=null,`<Router basename="${y}"> is not able to match the URL "${g}${v}${w}" because it does not start with the basename, so the <Router> won't render anything.`),S==null?null:f.createElement(Yt.Provider,{value:p},f.createElement(Qs.Provider,{children:s,value:S}))}function Ey({children:t,location:s}){return fy($l(t),s)}function $l(t,s=[]){let a=[];return f.Children.forEach(t,(o,c)=>{if(!f.isValidElement(o))return;let d=[...s,c];if(o.type===f.Fragment){a.push.apply(a,$l(o.props.children,d));return}rt(o.type===Qe,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),rt(!o.props.index||!o.props.children,"An index route cannot have child routes.");let h={id:o.props.id||d.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(h.children=$l(o.props.children,d)),a.push(h)}),a}var pi="get",gi="application/x-www-form-urlencoded";function Pi(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Ty(t){return Pi(t)&&t.tagName.toLowerCase()==="button"}function Ry(t){return Pi(t)&&t.tagName.toLowerCase()==="form"}function Iy(t){return Pi(t)&&t.tagName.toLowerCase()==="input"}function Ay(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Py(t,s){return t.button===0&&(!s||s==="_self")&&!Ay(t)}function Ll(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,a)=>{let o=t[a];return s.concat(Array.isArray(o)?o.map(c=>[a,c]):[[a,o]])},[]))}function _y(t,s){let a=Ll(t);return s&&s.forEach((o,c)=>{a.has(c)||s.getAll(c).forEach(d=>{a.append(c,d)})}),a}var ci=null;function $y(){if(ci===null)try{new FormData(document.createElement("form"),0),ci=!1}catch{ci=!0}return ci}var Ly=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Nl(t){return t!=null&&!Ly.has(t)?(rn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${gi}"`),null):t}function zy(t,s){let a,o,c,d,h;if(Ry(t)){let y=t.getAttribute("action");o=y?_n(y,s):null,a=t.getAttribute("method")||pi,c=Nl(t.getAttribute("enctype"))||gi,d=new FormData(t)}else if(Ty(t)||Iy(t)&&(t.type==="submit"||t.type==="image")){let y=t.form;if(y==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=t.getAttribute("formaction")||y.getAttribute("action");if(o=p?_n(p,s):null,a=t.getAttribute("formmethod")||y.getAttribute("method")||pi,c=Nl(t.getAttribute("formenctype"))||Nl(y.getAttribute("enctype"))||gi,d=new FormData(y,t),!$y()){let{name:g,type:v,value:w}=t;if(v==="image"){let j=g?`${g}.`:"";d.append(`${j}x`,"0"),d.append(`${j}y`,"0")}else g&&d.append(g,w)}}else{if(Pi(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=pi,o=null,c=gi,h=t}return d&&c==="text/plain"&&(h=d,d=void 0),{action:o,method:a.toLowerCase(),encType:c,formData:d,body:h}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ec(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function jh(t,s,a,o){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return a?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:s&&_n(c.pathname,s)==="/"?c.pathname=`${Xr(s)}/_root.${o}`:c.pathname=`${Xr(c.pathname)}.${o}`,c}async function Fy(t,s){if(t.id in s)return s[t.id];try{let a=await import(t.module);return s[t.id]=a,a}catch(a){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Oy(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function My(t,s,a){let o=await Promise.all(t.map(async c=>{let d=s.routes[c.route.id];if(d){let h=await Fy(d,a);return h.links?h.links():[]}return[]}));return Wy(o.flat(1).filter(Oy).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function mf(t,s,a,o,c,d){let h=(p,g)=>a[g]?p.route.id!==a[g].route.id:!0,y=(p,g)=>{var v;return a[g].pathname!==p.pathname||((v=a[g].route.path)==null?void 0:v.endsWith("*"))&&a[g].params["*"]!==p.params["*"]};return d==="assets"?s.filter((p,g)=>h(p,g)||y(p,g)):d==="data"?s.filter((p,g)=>{var w;let v=o.routes[p.route.id];if(!v||!v.hasLoader)return!1;if(h(p,g)||y(p,g))return!0;if(p.route.shouldRevalidate){let j=p.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((w=a[0])==null?void 0:w.params)||{},nextUrl:new URL(t,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof j=="boolean")return j}return!0}):[]}function By(t,s,{includeHydrateFallback:a}={}){return Dy(t.map(o=>{let c=s.routes[o.route.id];if(!c)return[];let d=[c.module];return c.clientActionModule&&(d=d.concat(c.clientActionModule)),c.clientLoaderModule&&(d=d.concat(c.clientLoaderModule)),a&&c.hydrateFallbackModule&&(d=d.concat(c.hydrateFallbackModule)),c.imports&&(d=d.concat(c.imports)),d}).flat(1))}function Dy(t){return[...new Set(t)]}function Uy(t){let s={},a=Object.keys(t).sort();for(let o of a)s[o]=t[o];return s}function Wy(t,s){let a=new Set;return new Set(s),t.reduce((o,c)=>{let d=JSON.stringify(Uy(c));return a.has(d)||(a.add(d),o.push({key:d,link:c})),o},[])}function tc(){let t=f.useContext(ts);return ec(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Hy(){let t=f.useContext(Ai);return ec(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var nc=f.createContext(void 0);nc.displayName="FrameworkContext";function _i(){let t=f.useContext(nc);return ec(t,"You must render this element inside a <HydratedRouter> element"),t}function Vy(t,s){let a=f.useContext(nc),[o,c]=f.useState(!1),[d,h]=f.useState(!1),{onFocus:y,onBlur:p,onMouseEnter:g,onMouseLeave:v,onTouchStart:w}=s,j=f.useRef(null);f.useEffect(()=>{if(t==="render"&&h(!0),t==="viewport"){let S=T=>{T.forEach(R=>{h(R.isIntersecting)})},C=new IntersectionObserver(S,{threshold:.5});return j.current&&C.observe(j.current),()=>{C.disconnect()}}},[t]),f.useEffect(()=>{if(o){let S=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(S)}}},[o]);let N=()=>{c(!0)},E=()=>{c(!1),h(!1)};return a?t!=="intent"?[d,j,{}]:[d,j,{onFocus:Bs(y,N),onBlur:Bs(p,E),onMouseEnter:Bs(g,N),onMouseLeave:Bs(v,E),onTouchStart:Bs(w,N)}]:[!1,j,{}]}function Bs(t,s){return a=>{t&&t(a),a.defaultPrevented||s(a)}}function Gy({page:t,...s}){let a=ty(),{nonce:o}=_i(),{router:c}=tc(),d=f.useMemo(()=>sh(c.routes,t,c.basename),[c.routes,t,c.basename]);return d?(s.nonce==null&&o&&(s={...s,nonce:o}),a?f.createElement(Yy,{page:t,matches:d,...s}):f.createElement(Jy,{page:t,matches:d,...s})):null}function Ky(t){let{manifest:s,routeModules:a}=_i(),[o,c]=f.useState([]);return f.useEffect(()=>{let d=!1;return My(t,s,a).then(h=>{d||c(h)}),()=>{d=!0}},[t,s,a]),o}function Yy({page:t,matches:s,...a}){let o=Dt(),{future:c}=_i(),{basename:d}=tc(),h=f.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let y=jh(t,d,c.v8_trailingSlashAwareDataRequests,"rsc"),p=!1,g=[];for(let v of s)typeof v.route.shouldRevalidate=="function"?p=!0:g.push(v.route.id);return p&&g.length>0&&y.searchParams.set("_routes",g.join(",")),[y.pathname+y.search]},[d,c.v8_trailingSlashAwareDataRequests,t,o,s]);return f.createElement(f.Fragment,null,h.map(y=>f.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...a})))}function Jy({page:t,matches:s,...a}){let o=Dt(),{future:c,manifest:d,routeModules:h}=_i(),{basename:y}=tc(),{loaderData:p,matches:g}=Hy(),v=f.useMemo(()=>mf(t,s,g,d,o,"data"),[t,s,g,d,o]),w=f.useMemo(()=>mf(t,s,g,d,o,"assets"),[t,s,g,d,o]),j=f.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let S=new Set,C=!1;if(s.forEach(R=>{var P;let L=d.routes[R.route.id];!L||!L.hasLoader||(!v.some(F=>F.route.id===R.route.id)&&R.route.id in p&&((P=h[R.route.id])!=null&&P.shouldRevalidate)||L.hasClientLoader?C=!0:S.add(R.route.id))}),S.size===0)return[];let T=jh(t,y,c.v8_trailingSlashAwareDataRequests,"data");return C&&S.size>0&&T.searchParams.set("_routes",s.filter(R=>S.has(R.route.id)).map(R=>R.route.id).join(",")),[T.pathname+T.search]},[y,c.v8_trailingSlashAwareDataRequests,p,o,d,v,s,t,h]),N=f.useMemo(()=>By(w,d),[w,d]),E=Ky(w);return f.createElement(f.Fragment,null,j.map(S=>f.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...a})),N.map(S=>f.createElement("link",{key:S,rel:"modulepreload",href:S,...a})),E.map(({key:S,link:C})=>f.createElement("link",{key:S,nonce:a.nonce,...C,crossOrigin:C.crossOrigin??a.crossOrigin})))}function qy(...t){return s=>{t.forEach(a=>{typeof a=="function"?a(s):a!=null&&(a.current=s)})}}var Qy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Qy&&(window.__reactRouterVersion="7.18.4")}catch{}function Xy({basename:t,children:s,useTransitions:a,window:o}){let c=f.useRef();c.current==null&&(c.current=Cg({window:o,v5Compat:!0}));let d=c.current,[h,y]=f.useState({action:d.action,location:d.location}),p=f.useCallback(g=>{a===!1?y(g):f.startTransition(()=>y(g))},[a]);return f.useLayoutEffect(()=>d.listen(p),[d,p]),f.createElement(Cy,{basename:t,children:s,location:h.location,navigationType:h.action,navigator:d,useTransitions:a})}var yt=f.forwardRef(function({onClick:s,discover:a="render",prefetch:o="none",relative:c,reloadDocument:d,replace:h,mask:y,state:p,target:g,to:v,preventScrollReset:w,viewTransition:j,defaultShouldRevalidate:N,...E},S){let{basename:C,navigator:T,useTransitions:R}=f.useContext(Yt),L=typeof v=="string"&&Kl.test(v),P=dh(v,C);v=P.to;let F=ly(v,{relative:c}),G=Dt(),H=null;if(y){let Z=Ii(y,[],G.mask?G.mask.pathname:"/",!0);C!=="/"&&(Z.pathname=Z.pathname==="/"?C:fn([C,Z.pathname])),H=T.createHref(Z)}let[ie,Y,re]=Vy(o,E),J=tv(v,{replace:h,mask:y,state:p,target:g,preventScrollReset:w,relative:c,viewTransition:j,defaultShouldRevalidate:N,useTransitions:R});function M(Z){s&&s(Z),Z.defaultPrevented||J(Z)}let fe=!(P.isExternal||d),oe=f.createElement("a",{...E,...re,href:(fe?H:void 0)||P.absoluteURL||F,onClick:fe?M:s,ref:qy(S,Y),target:g,"data-discover":!L&&a==="render"?"true":void 0});return ie&&!L?f.createElement(f.Fragment,null,oe,f.createElement(Gy,{page:F})):oe});yt.displayName="Link";var rc=f.forwardRef(function({"aria-current":s="page",caseSensitive:a=!1,className:o="",end:c=!1,style:d,to:h,viewTransition:y,children:p,...g},v){let w=Xs(h,{relative:g.relative}),j=Dt(),N=f.useContext(Ai),{navigator:E,basename:S}=f.useContext(Yt),C=N!=null&&iv(w)&&y===!0,T=E.encodeLocation?E.encodeLocation(w).pathname:w.pathname,R=j.pathname,L=N&&N.navigation&&N.navigation.location?N.navigation.location.pathname:null;a||(R=R.toLowerCase(),L=L?L.toLowerCase():null,T=T.toLowerCase()),L&&S&&(L=_n(L,S)||L);const P=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let F=R===T||!c&&R.startsWith(T)&&R.charAt(P)==="/",G=L!=null&&(L===T||!c&&L.startsWith(T)&&L.charAt(T.length)==="/"),H={isActive:F,isPending:G,isTransitioning:C},ie=F?s:void 0,Y;typeof o=="function"?Y=o(H):Y=[o,F?"active":null,G?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let re=typeof d=="function"?d(H):d;return f.createElement(yt,{...g,"aria-current":ie,className:Y,ref:v,style:re,to:h,viewTransition:y},typeof p=="function"?p(H):p)});rc.displayName="NavLink";var Zy=f.forwardRef(({discover:t="render",fetcherKey:s,navigate:a,reloadDocument:o,replace:c,state:d,method:h=pi,action:y,onSubmit:p,relative:g,preventScrollReset:v,viewTransition:w,defaultShouldRevalidate:j,...N},E)=>{let{useTransitions:S}=f.useContext(Yt),C=sv(),T=av(y,{relative:g}),R=h.toLowerCase()==="get"?"get":"post",L=typeof y=="string"&&Kl.test(y),P=F=>{if(p&&p(F),F.defaultPrevented)return;F.preventDefault();let G=F.nativeEvent.submitter,H=(G==null?void 0:G.getAttribute("formmethod"))||h,ie=()=>C(G||F.currentTarget,{fetcherKey:s,method:H,navigate:a,replace:c,state:d,relative:g,preventScrollReset:v,viewTransition:w,defaultShouldRevalidate:j});S&&a!==!1?f.startTransition(()=>ie()):ie()};return f.createElement("form",{ref:E,method:R,action:T,onSubmit:o?p:P,...N,"data-discover":!L&&t==="render"?"true":void 0})});Zy.displayName="Form";function ev(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Sh(t){let s=f.useContext(ts);return rt(s,ev(t)),s}function tv(t,{target:s,replace:a,mask:o,state:c,preventScrollReset:d,relative:h,viewTransition:y,defaultShouldRevalidate:p,useTransitions:g}={}){let v=mn(),w=Dt(),j=Xs(t,{relative:h});return f.useCallback(N=>{if(Py(N,s)){N.preventDefault();let E=a!==void 0?a:kr(w)===kr(j),S=()=>v(t,{replace:E,mask:o,state:c,preventScrollReset:d,relative:h,viewTransition:y,defaultShouldRevalidate:p});g?f.startTransition(()=>S()):S()}},[w,v,j,a,o,c,s,t,d,h,y,p,g])}function sc(t){rn(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 s=f.useRef(Ll(t)),a=f.useRef(!1),o=Dt(),c=f.useMemo(()=>_y(o.search,a.current?null:s.current),[o.search]),d=mn(),h=f.useCallback((y,p)=>{const g=Ll(typeof y=="function"?y(new URLSearchParams(c)):y);a.current=!0,d("?"+g,p)},[d,c]);return[c,h]}var nv=0,rv=()=>`__${String(++nv)}__`;function sv(){let{router:t}=Sh("useSubmit"),{basename:s}=f.useContext(Yt),a=jy(),o=t.fetch,c=t.navigate;return f.useCallback(async(d,h={})=>{let{action:y,method:p,encType:g,formData:v,body:w}=zy(d,s);if(h.navigate===!1){let j=h.fetcherKey||rv();await o(j,a,h.action||y,{defaultShouldRevalidate:h.defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:v,body:w,formMethod:h.method||p,formEncType:h.encType||g,flushSync:h.flushSync})}else await c(h.action||y,{defaultShouldRevalidate:h.defaultShouldRevalidate,preventScrollReset:h.preventScrollReset,formData:v,body:w,formMethod:h.method||p,formEncType:h.encType||g,replace:h.replace,state:h.state,fromRouteId:a,flushSync:h.flushSync,viewTransition:h.viewTransition})},[o,c,s,a])}function av(t,{relative:s}={}){let{basename:a}=f.useContext(Yt),o=f.useContext(hn);rt(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),d={...Xs(t||".",{relative:s})},h=Dt();if(t==null){d.search=h.search;let y=new URLSearchParams(d.search),p=y.getAll("index");if(p.some(v=>v==="")){y.delete("index"),p.filter(w=>w).forEach(w=>y.append("index",w));let v=y.toString();d.search=v?`?${v}`:""}}return(!t||t===".")&&c.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(d.pathname=d.pathname==="/"?a:fn([a,d.pathname])),kr(d)}function iv(t,{relative:s}={}){let a=f.useContext(mh);rt(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Sh("useViewTransitionState"),c=Xs(t,{relative:s});if(!a.isTransitioning)return!1;let d=_n(a.currentLocation.pathname,o)||a.currentLocation.pathname,h=_n(a.nextLocation.pathname,o)||a.nextLocation.pathname;return ji(c.pathname,h)!=null||ji(c.pathname,d)!=null}var ov=nh();const wr="owner";function lv(t){const s=t||wr;return s===wr?[wr]:[s,wr]}function cv(t){const s=new Map;for(const a of t)for(const o of a)s.has(o.id)||s.set(o.id,o);return[...s.values()].sort((a,o)=>o.createdAt-a.createdAt)}function uv(t,s){const a=s||wr,o=(t==null?void 0:t.pendingDomains)??[];return o.includes(a)?a:o.includes(wr)?wr:a}class kh extends Error{constructor(a){super("different_account");Os(this,"summary");this.name="DifferentAccountError",this.summary=a}}function De(t,s){const a=t??{},o=Array.isArray(a.errors)?a.errors[0]:void 0;return o!=null&&o.message?o.code?`${o.message} (${o.code})`:o.message:o!=null&&o.code?o.code:a.error||a.detail||s}function dv(t){const s=t==null?void 0:t.pubkeys;return!s||typeof s!="object"||Array.isArray(s)?[]:Object.entries(s).filter(a=>typeof a[1]=="string"&&a[1].length>0).map(([a,o])=>({userId:a,publicKey:o}))}class fv{constructor(){Os(this,"apiKey",null)}setApiKey(s){this.apiKey=s}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(s,a){return globalThis.fetch(s,{...a,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...a==null?void 0:a.headers}})}async login(s,a={}){const o=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":s,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:a.confirmWipe===!0})});if(o.status===409){const d=await o.json().catch(()=>({}));if(d!=null&&d.wouldWipe)throw new kh(d.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!o.ok){const d=await o.json().catch(()=>({error:"Invalid API key"}));throw new Error(De(d,`Login failed: ${o.status}`))}return(await o.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const s=await this.fetch("/api/groups");if(!s.ok)throw new Error(`Failed to fetch groups: ${s.status}`);const a=await s.json();return a.groups??a}async listProfiles(){const s=await this.fetch("/api/profiles");if(!s.ok)throw new Error(`Failed to fetch profiles: ${s.status}`);return(await s.json()).profiles}async getProfile(s){const a=await this.fetch(`/api/profiles/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch profile: ${a.status}`);return a.json()}async attest(s){const a=await this.fetch("/api/as/mandate",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Signing failed: ${a.status}`))}return a.json()}async getPending(s){const a=await this.fetch(`/api/mandates/pending?domain=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch pending: ${a.status}`);const o=await a.json();return o.pending??o}async getMyAttestations(s){const a=s?`?status=${encodeURIComponent(s)}`:"",o=await this.fetch(`/api/mandates/mine${a}`);if(!o.ok)throw new Error(`Failed to fetch attestations: ${o.status}`);return((await o.json()).mandates??[]).map(d=>{var h,y;return{authorization_id:d.authorization_id,profile_id:d.profileId,path:d.path,title:d.title??null,sp_status:d.status??null,frame:d.bounds??d.frame??{},required_domains:d.requiredDomains??[],attested_domains:d.attestedDomains??[],missing_domains:(d.requiredDomains??[]).filter(p=>!(d.attestedDomains??[]).includes(p)),deferred_commitment_domains:d.deferredCommitmentDomains??[],approvers_frozen:d.approversFrozen??[],above_cap:d.aboveCap??!1,created_at:d.createdAt?new Date(d.createdAt*1e3).toISOString():"",earliest_expiry:(h=d.attestations)!=null&&h.length?new Date(Math.min(...d.attestations.map(p=>p.expiresAt))*1e3).toISOString():null,remaining_seconds:(y=d.attestations)!=null&&y.length?Math.max(0,Math.min(...d.attestations.map(p=>p.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(s){const a=new URLSearchParams;s!=null&&s.since&&a.set("since",String(s.since)),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString()?`?${a.toString()}`:"",c=await this.fetch(`/denials${o}`);if(!c.ok)throw new Error(`Failed to fetch denials: ${c.status}`);return c.json()}async getMyReceipts(s){const a=new URLSearchParams;s!=null&&s.date&&a.set("date",s.date),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),c=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!c.ok)throw new Error(`Failed to fetch receipts: ${c.status}`);return(await c.json()).tickets??[]}async fetchEvidenceBundle(){var c;const s=await this.fetch("/api/evidence-export"),a=await s.json();if(!s.ok)throw new Error(De(a,`Export failed (${s.status})`));const o=((c=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:c[1])??"suveren-evidence.json";return{bundle:a,filename:o}}async getLocalAuthorizations(){const s=await this.fetch("/api/evidence/authorizations");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const a=await s.json();return{authorizations:a.authorizations??{},signatures:a.signatures??{}}}async getArchivedReceipt(s){const a=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}`);if(a.status===404)return null;if(!a.ok)throw new Error(`Local evidence unavailable (${a.status})`);return await a.json()}async getReport(){const s=await this.fetch("/api/report");if(!s.ok){const a=await s.json().catch(()=>({error:`Report unavailable (${s.status})`}));throw new Error(De(a,`Report unavailable (${s.status})`))}return s.json()}async saveReport(s){const a=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:s})});if(!a.ok){const o=await a.json().catch(()=>({error:`Save failed (${a.status})`}));throw new Error(De(o,`Save failed (${a.status})`))}return a.json()}async recheckReport(){const s=await this.fetch("/api/report/recheck",{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:`Recheck failed (${s.status})`}));throw new Error(De(a,`Recheck failed (${s.status})`))}return s.json()}async exportReportWithProof(){var c;const s=await this.fetch("/api/report/export");if(!s.ok){const d=await s.json().catch(()=>({error:`Export failed (${s.status})`}));throw new Error(De(d,`Export failed (${s.status})`))}const a=await s.text(),o=((c=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:c[1])??"suveren-report.html";return{html:a,filename:o}}async revokeAttestation(s,a){const o=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/revoke`,{method:"POST",body:JSON.stringify({reason:a??"Revoked by user"})});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed to revoke"}));throw new Error(De(c,`Revoke failed: ${o.status}`))}}async getAttestations(s){const a=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch attestations: ${a.status}`);const o=await a.json();return{...o,attestations:o.mandates??o.attestations??[]}}async getGroupById(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch group: ${a.status}`);return a.json()}async createGroup(s){const a=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:s})});if(!a.ok){const d=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(d,`Create group failed: ${a.status}`))}const o=await a.json(),c=o.group||o;return{id:c.id,name:c.name,myDomains:c.myDomains||[],isAdmin:!0,ended:o.ended??{mandates:0,proposals:0}}}async getCreatePreview(){const s=await this.fetch("/api/groups/create/preview");if(!s.ok){const a=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(De(a,`Failed to preview team creation: ${s.status}`))}return s.json()}async getJoinPreview(s){const a=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(s)}`);if(!a.ok){const o=await a.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(De(o,`Invalid invite code: ${a.status}`))}return a.json()}async requestToJoinGroup(s){const a=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:s})});if(a.status!==202){const c=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(c,`Request to join failed: ${a.status}`))}return(await a.json()).request}async withdrawJoinRequest(){const s=await this.fetch("/api/groups/join",{method:"DELETE"});if(s.status===404)return!1;if(!s.ok){const o=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Withdraw failed: ${s.status}`))}return(await s.json()).withdrawn===!0}async inviteToGroup(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/invite`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Invite failed: ${a.status}`))}return a.json()}async getMyTeam(){const s=await this.fetch("/api/groups/me");if(!s.ok)return{group:null,membership:null,pendingRequest:null};const a=await s.json();return{group:a.group??null,membership:a.membership??null,pendingRequest:a.pendingRequest??null}}async listUsers(){const s=await this.fetch("/api/users");return s.ok?(await s.json()).users??[]:[]}async setPubkey(s){const a=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(De(o,`setPubkey failed: ${a.status}`))}}async getPubkey(s){const a=await this.fetch(`/api/users/${encodeURIComponent(s)}/pubkey`);return a.status===404||!a.ok?null:(await a.json()).pubkey??null}async leaveTeam(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/leave`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to leave team"}));throw new Error(De(o,`Leave failed: ${a.status}`))}}async getVaultStatus(){const s=await this.fetch("/vault/status");if(!s.ok)throw new Error(`Failed to fetch vault status: ${s.status}`);return s.json()}async getGatewaySettings(){const s=await this.fetch("/api/gateway-settings");if(!s.ok)throw new Error(`Failed to load settings: ${s.status}`);return s.json()}async setGatewaySettings(s){const a=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error(`Failed to save settings: ${a.status}`);return a.json()}async getArchivedMandates(){const s=await this.fetch("/api/archived-mandates");if(!s.ok)throw new Error(`Failed to load archived mandates: ${s.status}`);return(await s.json()).archived}async setMandateArchived(s,a){const o=await this.fetch(`/api/archived-mandates/${encodeURIComponent(s)}`,{method:a?"PUT":"DELETE"});if(!o.ok)throw new Error(`Failed to ${a?"archive":"unarchive"} mandate: ${o.status}`);return(await o.json()).archived}async getCredential(s){const a=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to check credential: ${a.status}`);return a.json()}async setCredential(s,a){const o=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`,{method:"PUT",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to save credential: ${o.status}`)}async testCredential(s){const a=await this.fetch(`/vault/test/${encodeURIComponent(s)}`,{method:"POST"});if(!a.ok)throw new Error(`Test failed: ${a.status}`);return a.json()}async aiAssist(s){const a=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:De(o,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return a.json()}async aiIntentReview(s){const a=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:De(o,"AI request failed")}}return a.json()}async aiTest(s){const a=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`AI test failed: ${a.status}`);return a.json()}async aiModels(s){const a=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`Model list failed: ${a.status}`);return a.json()}async getMcpHealth(){const s=await this.fetch("/mcp/health");if(!s.ok)throw new Error(`MCP server unreachable: ${s.status}`);return s.json()}async getAgentContact(){const s=await this.fetch("/mcp/agent-contact");if(!s.ok)throw new Error(`Failed to fetch agent contact: ${s.status}`);return s.json()}async getMcpIntegrations(){const s=await this.fetch("/mcp/integrations");if(!s.ok)throw new Error(`Failed to fetch integrations: ${s.status}`);return s.json()}async getOAuthHealth(s){try{const a=await this.fetch(`/auth/oauth/${encodeURIComponent(s)}/health`);return a.ok?await a.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const s=await this.fetch("/mcp/integrations/manifests");if(!s.ok)throw new Error(`Failed to fetch manifests: ${s.status}`);return s.json()}async discoverScopeField(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/discover/${encodeURIComponent(a)}`);if(!o.ok){const c=await o.json().catch(()=>({error:`Discovery failed: ${o.status}`}));throw new Error(De(c,`Discovery failed: ${o.status}`))}return o.json()}async activateIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}/activate`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed"}));throw new Error(De(o,`Failed: ${a.status}`))}return a.json()}async removeMcpIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}`,{method:"DELETE"});if(!a.ok)throw new Error(`Failed to remove integration: ${a.status}`)}async setReadPolicy(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:a})});if(!o.ok){const c=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(De(c,`HTTP ${o.status}`))}}async getTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`);if(o.status===404||!o.ok)return null;const c=await o.json();return(c==null?void 0:c.config)??null}async setTeamProfileConfig(s,a,o){const c=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(o)});if(!c.ok){const d=await c.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(De(d,`setTeamProfileConfig failed: ${c.status}`))}}async encryptIntent(s,a){const o=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:s,recipients:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(De(c,`encryptIntent failed: ${o.status}`))}return o.json()}async getToolDisplay(){const s=await this.fetch("/tool-display");if(!s.ok)return{};const a=await s.json();return(a==null?void 0:a.tools)??{}}async getApproversPubkeys(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}/approvers/pubkeys`);return o.ok?dv(await o.json()):[]}async deleteTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"DELETE"});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(De(c,`deleteTeamProfileConfig failed: ${o.status}`))}}async getIdentityDisclosure(){const s=await this.fetch("/api/users/me/identity-disclosure");if(!s.ok)throw new Error(`Failed to read identity setting: ${s.status}`);return s.json()}async setIdentityDisclosure(s){const a=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:s})});if(!a.ok)throw new Error(`Failed to save identity setting: ${a.status}`);return a.json()}async getProposals(s,a="pending"){const o=a==="all"?"&status=all":"",c=await this.fetch(`/api/proposals?domain=${encodeURIComponent(s)}${o}`);if(!c.ok)throw new Error(`Failed to fetch proposals: ${c.status}`);return(await c.json()).proposals??[]}async getMyProposals(s,a="pending"){const o=await Promise.all(lv(s).map(c=>this.getProposals(c,a)));return cv(o)}async resolveProposal(s,a,o,c){const{noteEncrypted:d,contentHash:h,note:y,...p}=c??{},g=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/resolve`,{method:"POST",body:JSON.stringify({action:a,domain:o,...p,...d?{note_encrypted:d}:y?{note:y}:{},...h?{content_hash:h}:{}})});if(!g.ok){const v=await g.json().catch(()=>({error:"Failed"}));throw new Error(De(v,`Failed: ${g.status}`))}return g.json()}async getProposal(s){const a=await this.fetch(`/api/proposals/${encodeURIComponent(s)}`);if(!a.ok){const c=await a.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`getProposal failed: ${a.status}`))}const o=await a.json();return o.proposal??o}async getProposalsForApprover(){const s=await this.fetch("/api/proposals?approver=me");if(!s.ok)throw new Error(`Failed to fetch approver proposals: ${s.status}`);return(await s.json()).proposals??[]}async approveProposal(s,a){const o=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/approve`,{method:"POST",body:a?JSON.stringify({content_hash:a}):void 0});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`approveProposal failed: ${o.status}`))}return o.json()}async rejectProposal(s,a,o){let c;if(typeof a=="string")c={reason:a};else{const{noteEncrypted:h,note:y,...p}=a??{};c={...p,...h?{note_encrypted:h}:y?{note:y}:{}}}o&&(c.content_hash=o);const d=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/reject`,{method:"POST",body:JSON.stringify(c)});if(!d.ok){const h=await d.json().catch(()=>({error:"Failed"}));throw new Error(De(h,`rejectProposal failed: ${d.status}`))}return d.json()}async getProposalPreview(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/preview`);if(!a.ok)throw new Error(`Failed to fetch preview: ${a.status}`);return a.json()}async getProposalOutcome(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/outcome`);if(!a.ok)throw new Error(`Failed to fetch outcome: ${a.status}`);return a.json()}async getAttestationIntent(s){const a=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/intent`);return a.status===404||a.status===403||!a.ok?null:a.json()}async decryptIntent(s){const a=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const c=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(De(c,`decryptIntent failed: ${a.status}`))}return(await a.json()).intent}async decryptProposalContent(s){const a=await this.fetch("/api/decrypt-proposal-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(De(o,`decryptProposalContent failed: ${a.status}`))}return a.json()}async encryptProposalNote(s,a){const o=await this.fetch("/api/encrypt-proposal-note",{method:"POST",body:JSON.stringify({note:s,recipientUserIds:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(De(c,`encryptProposalNote failed: ${o.status}`))}return o.json()}async storeApprovedIntent(s,a){const o=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:s,intent:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`storeApprovedIntent failed: ${o.status}`))}}async listTeamAuthorizations(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/mandates`);if(!a.ok)throw new Error(`Failed to fetch team authorizations: ${a.status}`);return((await a.json()).mandates??[]).map(c=>{var y,p;const d=c.owner??{userId:""};return{authorization_id:c.authorization_id??c.authorizationId,profile_id:c.profileId??c.profile_id,path:c.path??"",title:c.title??null,sp_status:c.status??c.sp_status??null,frame:c.bounds??c.frame??{},required_domains:c.requiredDomains??c.required_domains??[],attested_domains:c.attestedDomains??c.attested_domains??[],missing_domains:(c.requiredDomains??c.required_domains??[]).filter(g=>!(c.attestedDomains??c.attested_domains??[]).includes(g)),deferred_commitment_domains:c.deferredCommitmentDomains??c.deferred_commitment_domains??[],approvers_frozen:c.approversFrozen??c.approvers_frozen??[],above_cap:c.aboveCap??c.above_cap??!1,created_at:c.createdAt?new Date(c.createdAt*1e3).toISOString():c.created_at??"",earliest_expiry:(y=c.mandates)!=null&&y.length?new Date(Math.min(...c.mandates.map(g=>g.expiresAt))*1e3).toISOString():null,remaining_seconds:(p=c.mandates)!=null&&p.length?Math.max(0,Math.min(...c.mandates.map(g=>g.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:d}})}async listTeamReceipts(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets`);if(!a.ok)throw new Error(`Failed to fetch team receipts: ${a.status}`);return(await a.json()).tickets??[]}async getMyReceiptsPage(s){const a=new URLSearchParams;s!=null&&s.before&&a.set("before",s.before),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),c=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!c.ok)throw new Error(`Failed to fetch receipts: ${c.status}`);const d=await c.json();return{receipts:d.tickets??[],nextBefore:d.nextBefore??null}}async listTeamReceiptsPage(s,a){const o=new URLSearchParams;a!=null&&a.before&&o.set("before",a.before),a!=null&&a.profile&&o.set("profile",a.profile),a!=null&&a.limit&&o.set("limit",String(a.limit));const c=o.toString(),d=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets${c?"?"+c:""}`);if(!d.ok)throw new Error(`Failed to fetch team receipts: ${d.status}`);const h=await d.json();return{receipts:h.tickets??[],nextBefore:h.nextBefore??null}}async getThread(s){const a=s.sinceDays??7,o=s.status??"pending",c=await this.getMyProposals(s.domain,o);let d=[];if(o==="all"){const h=[],y=new Date;for(let g=0;g<a;g++){const v=new Date(y);v.setUTCDate(y.getUTCDate()-g),h.push(v.toISOString().slice(0,10))}d=(await Promise.all(h.map(g=>this.getMyReceipts({date:g,profile:s.profile})))).flat()}return{proposals:c,receipts:d}}async getAutostart(){const s=await this.fetch("/autostart");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async setAutostart(s){const a=await this.fetch("/autostart",{method:s?"POST":"DELETE"});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.message||`HTTP ${a.status}`)}}async getAsPairing(){const s=await this.fetch("/as-pairing");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getSkippedCommitments(){const s=await this.fetch("/skipped-commitments");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getGateContent(s){const a=await this.fetch(`/gate-content?path=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch gate content: ${a.status}`);return(await a.json()).entry??null}async resyncGates(){const s=await this.fetch("/resync-gates",{method:"POST"});if(!s.ok)throw new Error(`Failed to resync gates: ${s.status}`)}async getEnrichedAuthorizations(){const s=await this.fetch("/active-authorizations");if(!s.ok)throw new Error(`Failed to fetch authorizations: ${s.status}`);return(await s.json()).authorizations??[]}async pushGateContent(s){const a=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(De(o,`Push gate content failed: ${a.status}`))}}async getAgentContext(){const s=await this.fetch("/agent-brief/context");if(!s.ok)throw new Error(`Failed to fetch agent context: ${s.status}`);return(await s.json()).content}async saveAgentContext(s){const a=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(De(o,`Save failed: ${a.status}`))}}async aiChat(s){const a=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:De(o,`Chat failed: ${a.status}`)}}return a.json()}async getAIPrompts(){const s=await this.fetch("/ai-prompts");if(!s.ok)throw new Error(`Failed to load AI prompts: ${s.status}`);return s.json()}async setAIPrompt(s,a){const o=await this.fetch(`/ai-prompts/${s}`,{method:"PUT",body:JSON.stringify({value:a})});if(!o.ok){const c=await o.json().catch(()=>({error:"Save failed"}));throw new Error(De(c,`Save failed: ${o.status}`))}}}const D=new fv,bh=f.createContext(null);function hv({children:t}){const[s,a]=f.useState(null),[o,c]=f.useState("personal"),[d,h]=f.useState(null),[y,p]=f.useState(""),[g,v]=f.useState(null),[w,j]=f.useState(null),[N,E]=f.useState(null),[S,C]=f.useState(!1),[T,R]=f.useState(""),L=f.useRef(!1),P=f.useRef(null),F=f.useCallback(async()=>{if(L.current)try{const J=await D.getMyTeam();if(E(J.pendingRequest),J.group&&J.membership){const{group:M,membership:fe}=J;v(M),j(fe),c("team"),h(M);const oe=P.current??fe.domains[0]??"owner";p(oe)}else v(null),j(null),c("personal")}catch{}},[]);f.useEffect(()=>{const J=()=>{document.visibilityState==="visible"&&F()};return document.addEventListener("visibilitychange",J),()=>document.removeEventListener("visibilitychange",J)},[F]),f.useEffect(()=>{fetch("/health").then(J=>J.json()).then(J=>{var M;((M=J.session)==null?void 0:M.lockedReason)==="as-url-changed"&&R(`Authority Server changed to ${J.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const G=f.useCallback(async(J,M={})=>{C(!0),R("");try{D.setApiKey(J),L.current=!0;const fe=await D.login(J,M);a(fe),P.current=fe.id;const oe=await D.getGroups(),Z=oe.find(pe=>pe.isPersonal)??oe[0]??null;h(Z),p("owner"),await F()}catch(fe){throw D.clearApiKey(),L.current=!1,R(fe instanceof Error?fe.message:"Login failed"),fe}finally{C(!1)}},[F]),H=f.useCallback(async()=>{await D.logout(),D.clearApiKey(),L.current=!1,P.current=null,a(null),h(null),p(""),v(null),j(null),E(null),c("personal"),R("")},[]),ie=f.useCallback(J=>{D.clearApiKey(),L.current=!1,P.current=null,a(null),h(null),p(""),v(null),j(null),E(null),c("personal"),R(J??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),Y=f.useCallback(()=>R(""),[]),re=f.useCallback((J,M)=>{h(J),p(M)},[]);return r.jsx(bh.Provider,{value:{user:s,mode:o,group:d,domain:y,groupId:(d==null?void 0:d.id)??null,activeTeam:g,activeMembership:w,pendingRequest:N,isLoading:S,error:T,login:G,logout:H,clearError:Y,handleSessionLocked:ie,activeGroup:d,activeDomain:y,groups:d?[d]:[],setActiveContext:re,refreshGroups:F},children:t})}function vt(){const t=f.useContext(bh);if(!t)throw new Error("useAuth must be used within AuthProvider");return t}const Nh=f.createContext(null);function mv({children:t}){const{user:s}=vt(),a=f.useRef(null),[o,c]=f.useState(!1),d=f.useRef(new Map),h=f.useCallback((y,p)=>{const g=d.current;return g.has(y)||g.set(y,new Set),g.get(y).add(p),()=>{var v;(v=g.get(y))==null||v.delete(p)}},[]);return f.useEffect(()=>{if(!s){a.current&&(a.current.close(),a.current=null,c(!1));return}if(a.current)return;const y=D.getApiKey();if(!y)return;const p=new EventSource(`/events?key=${encodeURIComponent(y)}`);a.current=p,p.onopen=()=>c(!0),p.onerror=()=>c(!1);const g=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected","session-locked"];for(const v of g)p.addEventListener(v,w=>{let j;try{j=JSON.parse(w.data)}catch{j=null}const N=d.current.get(v);if(N)for(const E of N)try{E(j)}catch(S){console.error(`[EventSource] handler for "${v}" threw:`,S)}});return()=>{p.close(),a.current=null,c(!1)}},[s]),r.jsx(Nh.Provider,{value:{connected:o,addListener:h},children:t})}function He(t,s){const a=f.useContext(Nh);if(!a)return;const{addListener:o}=a;f.useEffect(()=>o(t,s),[t,s,o])}const Vs="suveren-theme",pf="hap-theme";function ui(t){return t!=="system"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(pf);s!==null&&localStorage.getItem(Vs)===null&&localStorage.setItem(Vs,s),s!==null&&localStorage.removeItem(pf)})();function Ch(){const[t,s]=f.useState(()=>{const d=localStorage.getItem(Vs);return d==="light"||d==="dark"?d:"system"}),[a,o]=f.useState(()=>ui(t));f.useEffect(()=>{const d=document.documentElement,h=ui(t);d.setAttribute("data-theme",h),t==="system"?localStorage.removeItem(Vs):localStorage.setItem(Vs,t),o(ui(t))},[t]),f.useEffect(()=>{if(t!=="system")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),h=()=>o(ui("system"));return d.addEventListener("change",h),()=>d.removeEventListener("change",h)},[t]);const c=f.useCallback(()=>{s(d=>d==="system"?"light":d==="light"?"dark":"system")},[]);return{theme:t,effectiveTheme:a,toggle:c}}const pv=300*1e3,gv=2e3;function ac(){const[t,s]=f.useState(!1),[a,o]=f.useState("docker"),[c,d]=f.useState(""),[h,y]=f.useState(null),[p,g]=f.useState(!1),[v,w]=f.useState(!1),[j,N]=f.useState(!1),E=f.useRef(null);return f.useEffect(()=>{let S=!1;const C=(L=!1)=>{fetch(L?"/health?refresh=1":"/health").then(P=>P.json()).then(P=>{S||(P.installMethod&&o(P.installMethod),typeof P.latestVersion<"u"&&y(P.latestVersion),P.updateAvailable&&s(!0),P.version&&(d(P.version),E.current===null?E.current=P.version:P.version!==E.current&&P.version!=="dev"&&g(!0)))}).catch(()=>{})};C(!0);const T=setInterval(()=>C(!1),j?gv:pv),R=()=>{document.visibilityState==="visible"&&C(!1)};return document.addEventListener("visibilitychange",R),window.addEventListener("focus",R),()=>{S=!0,clearInterval(T),document.removeEventListener("visibilitychange",R),window.removeEventListener("focus",R)}},[j]),{updateAvailable:t&&!v,installMethod:a,version:c,latestVersion:h,serverRestarted:p,startFastPolling:()=>N(!0),dismiss:()=>w(!0)}}function yv(t){return!t||typeof t!="object"?{managed:!1}:{managed:Array.isArray(t.policyLocked)&&t.policyLocked.includes("team")}}function vv(){const[t,s]=f.useState({managed:!1});return f.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(yv(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function xv({size:t=20}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[r.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),r.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function wv(t){return t?t==="dev"?"dev":/^[0-9a-f]{40}$/i.test(t)?t.slice(0,7):t:""}const gf={system:"◑",light:"☀",dark:"☾"};function ic({onMenuToggle:t}){const{user:s,logout:a,mode:o,activeTeam:c}=vt(),{theme:d,toggle:h}=Ch(),{version:y,updateAvailable:p,latestVersion:g}=ac(),{managed:v}=vv(),w=wv(y),j=o==="team"&&c?`Team ${c.name}`:"Personal";return r.jsx("nav",{className:"top-nav",children:r.jsxs("div",{className:"top-nav-inner",children:[r.jsxs("div",{className:"logo-group",children:[r.jsx(xv,{size:20}),r.jsx("span",{className:"logo",children:"Suveren"}),r.jsx("span",{className:"version-badge",children:"Local Gateway"}),w&&r.jsxs("span",{className:"gw-version",title:p&&g?`Running v${w} — v${g} is available`:"Running gateway version","data-stale":p?"true":void 0,children:["v",w,p&&g?` → ${g}`:""]})]}),r.jsx("div",{className:"nav-spacer"}),r.jsx("div",{className:"nav-actions nav-actions-desktop",children:s?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"workspace-pill","data-managed":v?"true":void 0,title:v?`${j} — set by your IT`:j,children:[j,v&&r.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),r.jsx("span",{className:"user-chip",children:r.jsx("strong",{children:s.name})}),r.jsx("button",{className:"theme-toggle",onClick:h,title:`Theme: ${d}`,children:gf[d]}),r.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):r.jsx("button",{className:"theme-toggle",onClick:h,title:`Theme: ${d}`,children:gf[d]})}),s&&t&&r.jsx("button",{className:"mobile-menu-btn",onClick:t,"aria-label":"Menu",children:"☰"})]})})}function oc(t,s){var a;if((a=s==null?void 0:s.revokedSet)!=null&&a.has(t.authorization_id))return"revoked";switch(t.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return t.remaining_seconds===null||t.remaining_seconds<=0?"expired":t.missing_domains.length>0?"pending":"active"}function Eh(t){return t==="expired"||t==="revoked"}function Th(t,s){var a;return!!((a=s==null?void 0:s.archivedSet)!=null&&a.has(t.authorization_id))&&Eh(oc(t,s))}function Si(t,s){return Th(t,s)?"archived":oc(t,s)}function Rh(t,s){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of t)a[Si(o,s)].push(o);return a}function jv(t,s){return s==="expired"?t.earliest_expiry?{iso:t.earliest_expiry,meaning:"expired"}:null:t.created_at?{iso:t.created_at,meaning:"created"}:null}function nn(t,s,a){const o=f.useRef(t);o.current=t,f.useEffect(()=>{let c=null;const d=()=>typeof document>"u"?!0:document.visibilityState==="visible",h=()=>{d()&&o.current()},y=()=>{c===null&&(c=setInterval(h,s))},p=()=>{c!==null&&(clearInterval(c),c=null)},g=()=>{d()?(o.current(),y()):p()};return d()&&(o.current(),y()),document.addEventListener("visibilitychange",g),()=>{p(),document.removeEventListener("visibilitychange",g)}},[s,a])}function lc(){const[t,s]=f.useState(!1);return f.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(h=>h.json()).then(h=>{a||s(h.simulation===!0)}).catch(()=>{})};o();const c=setInterval(o,3e4),d=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",d),()=>{a=!0,clearInterval(c),document.removeEventListener("visibilitychange",d)}},[]),t}function Sv(t,s){const a=t.simulation;return a?(((s==null?void 0:s[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function Ks(t){return!!(t!=null&&t.simulation)}const Ih=f.createContext(null),kv=3e4,bv=5e3,Nv=3e5;function Cv(t,s,a){return s===0?"loading":t!=null&&t.running?"running":t!=null&&t.paused?"paused":t!=null&&t.error?"error":t&&a?"starting":"not-running"}function Ev({children:t}){const[s,a]=f.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),o=f.useRef(null),c=f.useCallback(async()=>{let v=!1;const[w,j]=await Promise.all([D.getIntegrationManifests().catch(()=>(v=!0,{manifests:[]})),D.getMcpHealth().catch(()=>null)]);a(E=>({...E,manifests:w.manifests,integrations:(j==null?void 0:j.integrations)??E.integrations,activeSessions:(j==null?void 0:j.activeSessions)??E.activeSessions,mcpServerUp:!!j,manifestsError:v,fetchCount:E.fetchCount+1}));const N=w.manifests.filter(E=>E.oauth);if(N.length>0){const E=await Promise.all(N.map(async S=>[S.id,await D.getOAuthHealth(S.id)]));a(S=>({...S,authHealth:Object.fromEntries(E)}))}},[]),d=s.fetchCount>0&&s.manifests.some(v=>{const w=s.integrations.find(j=>j.id===v.id);return w&&!w.running&&!w.paused});He("integration-changed",c),nn(c,d?bv:Nv);const h=f.useMemo(()=>{const v=new Map(s.integrations.map(N=>[N.id,N])),w=Date.now();d&&o.current===null?o.current=w:d||(o.current=null);const j=o.current!==null&&w-o.current<kv;return s.manifests.map(N=>{const E=v.get(N.id),S=Cv(E,s.fetchCount,j),C=s.authHealth[N.id];return{id:N.id,manifest:N,integration:E,state:S,authStatus:C==null?void 0:C.status,authAccount:C==null?void 0:C.account,authError:C==null?void 0:C.error}})},[s,d]),y=lc(),p=f.useMemo(()=>h.filter(v=>!(y&&!Ks(v.manifest))&&(v.state==="not-running"||v.state==="error"||v.authStatus==="failed")).length,[h,y]),g={loading:s.fetchCount===0,mcpServerUp:s.mcpServerUp,manifestsError:s.manifestsError,entries:h,attentionCount:p,activeSessions:s.activeSessions,refresh:c};return r.jsx(Ih.Provider,{value:g,children:t})}function cc(){const t=f.useContext(Ih);if(!t)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return t}const Tv={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},uc=t=>Tv[t]??t,Rv={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 Iv(t){return(t&&Rv[t])??{chip:"Blocked",sev:"info"}}function Av(t){const s=uc(t.integrationId);switch(t.reason){case"resource":return t.integrationId==="calendar"?r.jsxs(r.Fragment,{children:["Tried to read your ",r.jsx("b",{children:t.target??"restricted"})," calendar"]}):r.jsxs(r.Fragment,{children:["Tried to read a restricted location in ",s]});case"spam":return r.jsxs(r.Fragment,{children:["Tried to open a message in ",r.jsx("b",{children:"spam or trash"})]});case"age":return r.jsxs(r.Fragment,{children:["Tried to read ",s," older than your read window"]});case"unset_age":return r.jsxs(r.Fragment,{children:["Your ",s," has ",r.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return r.jsxs(r.Fragment,{children:["Read access isn't granted on your ",s," mandate"]});case"ungoverned":return r.jsxs(r.Fragment,{children:["A ",s," tool isn't configured for safe reading"]});case"query_unsafe":return r.jsx(r.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return r.jsx(r.Fragment,{children:t.detail})}}function Ah(t,s){const a=Math.max(0,(s-t)/1e3);if(a<60)return"Just now";if(a<3600)return`${Math.floor(a/60)} min ago`;if(a<86400)return`${Math.floor(a/3600)} hr ago`;const o=Math.floor(a/86400);return o===1?"Yesterday":`${o} days ago`}const yf=5,Pv=1440*60*1e3,yi=7;function _v(t,s){const a=s-yi*Pv;return{recent:t.filter(o=>o.ts>=a),all:t}}function $v(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,d]=f.useState(!1),h=f.useCallback(()=>{D.getDenials({limit:200}).then(({records:j})=>{s(j),d(!1)}).catch(()=>d(!0))},[]);if(f.useEffect(()=>{h()},[h]),nn(h,12e4),c||t===null)return null;const{recent:y,all:p}=_v(t,Date.now()),g=a?p:y.slice(0,yf),v=p.length-y.length,w=(j,N)=>{const E=Iv(j.reason);return r.jsxs("div",{className:"rb-row",children:[r.jsx("span",{className:`rb-dot ${E.sev==="act"?"act":E.sev==="info"?"info":""}`,"aria-hidden":"true"}),r.jsxs("div",{className:"rb-body",children:[r.jsx("div",{className:"rb-line",children:Av(j)}),r.jsxs("div",{className:"rb-meta",children:[r.jsx("span",{className:`rb-chip ${E.sev==="act"?"act":E.sev==="warn"?"warn":""}`,children:E.chip}),r.jsx("span",{className:"rb-via",children:uc(j.integrationId)})]}),E.fixTo&&r.jsx(yt,{className:"rb-fix",to:E.fixTo,children:"Set a read window →"})]}),r.jsx("div",{className:"rb-when",children:Ah(j.ts,Date.now())})]},`${j.ts}-${N}`)};return r.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[r.jsxs("div",{className:"card-header",children:[r.jsx("h2",{className:"card-title",children:"Recent blocks"}),(a?p.length:y.length)>0&&r.jsx("span",{className:"rb-count",children:a?p.length:y.length})]}),g.length===0?r.jsxs("div",{className:"rb-empty",children:[r.jsx("span",{className:"rb-mark","aria-hidden":"true",children:r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 6 9 17l-5-5"})})}),r.jsxs("h3",{children:["Nothing blocked in the last ",yi," days"]}),r.jsx("p",{children:"Your agent has stayed within every limit you set."}),v>0&&r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!0),children:["Show the last 30 days (",v,")"]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"rb-sub",children:[a?"Last 30 days. ":`Last ${yi} days. `,"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."]}),r.jsx("div",{className:"rb-rows",children:g.map(w)}),!a&&p.length>g.length&&r.jsx("div",{className:"rb-foot",children:r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!0),children:["View all ",p.length," blocks from the last 30 days"]})}),a&&p.length>Math.min(y.length,yf)&&r.jsx("div",{className:"rb-foot",children:r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!1),children:["Show only the last ",yi," days"]})})]})]})}function Ys(t){return t.kind??"read"}function Lv(t,s){var d,h,y,p;if(!s)return"";if(!t)return s;const a=(h=(d=t.scopeSchema)==null?void 0:d.fields)==null?void 0:h[s];if(a!=null&&a.displayName)return a.displayName;const o=((y=t.boundsSchema)==null?void 0:y.fields)??{};if((p=o[s])!=null&&p.displayName)return o[s].displayName;const c=Object.values(o).find(g=>g.boundType&&"of"in g.boundType&&g.boundType.of===s);return c!=null&&c.displayName?c.displayName:s}const zv={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"},Fv={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 vf(t){return t===void 0?"":typeof t=="number"?t.toLocaleString():t}function Ov(t,s){const a=Ys(t),o=vf(t.value),c=vf(t.limit);switch(a){case"bound":return o&&c?`${s||"Value"} ${o} is above the limit ${c}.`:t.detail;case"scope":return o?`${s||"Value"} "${o}" is not within your mandate's allowed ${s||"scope"}.`:t.detail;case"cumulative":return o&&c?`${o} of ${c} used — the limit is reached.`:t.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 t.detail}}function Mv(t){const s=Ys(t),a=uc(t.integrationId),o=t.mandateTitle?` · mandate "${t.mandateTitle}"`:t.mandateId?` · mandate ${t.mandateId.slice(0,14)}…`:"",c=t.who==="authority-server"?"refused by the Authority Server":s==="read"?"refused by this gateway":"refused by this gateway, before anything ran",d=t.code?` (${t.code})`:"";return`${a} · ${t.tool}${o} · ${c}${d}`}function Bv(t,s){const a=Ys(t),o=Lv(s,t.field);return{title:zv[a],sentence:Ov(t,o),sourceLine:Mv(t),whatYouCanDo:Fv[a]}}function Ph(t,s){const a=new Date(s);return a.setHours(0,0,0,0),t.filter(o=>o.ts>=a.getTime()).length}const Dv=[{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 Uv(){const{activeDomain:t}=vt(),[s,a]=f.useState({}),o=f.useCallback(async()=>{try{const[c,d,h,y,p,g,v]=await Promise.all([D.getCredential("ai-config").catch(()=>null),D.getMyAttestations().catch(()=>null),D.getMyProposals(t).catch(()=>null),D.getProposalsForApprover().catch(()=>null),D.getAgentContext().catch(()=>""),D.getArchivedMandates().catch(()=>[]),D.getDenials({limit:200}).catch(()=>null)]),w={};if(c&&!c.configured&&(w.assistant=1),d){const S=Rh(d,{archivedSet:new Set(g)}).expired.length;S>0&&(w.authorizations=S)}const j=(h==null?void 0:h.length)??0,N=(y==null?void 0:y.length)??0,E=j+N;if(E>0&&(w.proposals=E),(!p||!p.trim())&&(w.brief=1),v){const S=Ph(v.records,Date.now());S>0&&(w.blocked=S)}a(w)}catch{}},[t]);return He("attestation-changed",o),He("proposal-added",o),He("proposal-resolved",o),He("proposal-approved",o),He("proposal-rejected",o),He("team-membership-changed",o),f.useEffect(()=>(window.addEventListener("suveren:archived-changed",o),()=>window.removeEventListener("suveren:archived-changed",o)),[o]),nn(o,3e5,t),s}const Wv={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},Hv={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 Vv(){const{mode:t,group:s,domain:a,activeTeam:o}=vt(),c=Uv(),{attentionCount:d}=cc(),h={...c};d>0&&(h.integrations=d);const y=Dv.filter(j=>!j.teamOnly||t==="team"),p=f.useRef(null),[g,v]=f.useState(null),w=Dt();return f.useEffect(()=>{if(p.current===null){p.current=t;return}p.current!==t&&(t==="team"&&o?v(`You are now acting in team context — ${o.name}`):t==="personal"&&v("You have left the team — back to personal context"),p.current=t)},[t,o]),f.useEffect(()=>{v(null)},[w.pathname]),r.jsxs("div",{className:"sidebar",children:[r.jsx("ul",{className:"sidebar-nav",children:y.map(j=>{const N=j.statusKey?h[j.statusKey]:0;return r.jsx("li",{children:r.jsxs(rc,{to:j.to,end:j.to==="/",className:({isActive:E})=>`sidebar-item${E?" active":""}`,children:[r.jsx("span",{className:"icon",children:j.icon}),j.label,N?r.jsx("span",{style:Wv,children:N}):null]})},j.to)})}),r.jsxs("div",{className:"sidebar-context",children:[r.jsx("div",{className:"ctx-label",children:"Active context"}),r.jsx("div",{className:"ctx-value",children:t==="personal"?"personal":s?`${s.name} / ${a}`:a})]}),g&&r.jsx("div",{style:Hv,role:"status","aria-live":"polite",children:g})]})}const Cl="suveren:updatedTo";function Gv(t){return t==="managed"||t==="msi"?null:t==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":t==="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 Kv="Updates for this gateway come from your company's IT — no action needed here.";function Yv(t){return t==="managed"?"update-banner is-managed":"update-banner"}const Jv="Download the new installer and run it. Your settings and mandates stay.";function qv(t){const s="https://github.com/suverenai/suveren-gateway/releases";return t?`${s}/tag/v${t}`:`${s}/latest`}function Qv(){const t=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const a of t)if(!a.closest(".update-overlay"))return!0;const s=document.activeElement;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)){const a=s.value;if(a&&a.trim())return!0}return!1}function _h(){const{updateAvailable:t,installMethod:s,version:a,latestVersion:o,serverRestarted:c,startFastPolling:d,dismiss:h}=ac(),[y,p]=f.useState(!1),[g,v]=f.useState(!1),[w,j]=f.useState(()=>{try{const L=sessionStorage.getItem(Cl);if(L)return sessionStorage.removeItem(Cl),L}catch{}return null}),N=Gv(s),E=f.useRef(null),S=L=>{try{sessionStorage.setItem(Cl,L||o||"✓")}catch{}window.location.reload()};f.useEffect(()=>{if(!w)return;const L=setTimeout(()=>j(null),6e3);return()=>clearTimeout(L)},[w]),f.useEffect(()=>{if(!y||!c)return;const L=()=>Qv()?!1:(S(a),!0);if(L())return;const P=setInterval(L,1500);return()=>clearInterval(P)},[y,c,a]),f.useEffect(()=>(document.body.classList.toggle("is-updating",y),()=>document.body.classList.remove("is-updating")),[y]);const C=t&&!y&&!w||!!w&&!y;f.useEffect(()=>{if(!C){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const L=()=>{var G;const F=((G=E.current)==null?void 0:G.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${F}px`)};L();const P=new ResizeObserver(L);return E.current&&P.observe(E.current),()=>{P.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[C]);const T=()=>{p(!0),d()},R=async()=>{if(N)try{await navigator.clipboard.writeText(N),v(!0),setTimeout(()=>v(!1),1800)}catch{}};return r.jsxs(r.Fragment,{children:[w&&!y&&r.jsx("div",{ref:E,className:"update-banner is-live",role:"status","aria-live":"polite",children:r.jsxs("div",{className:"update-banner-row",children:[r.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",w&&w!=="✓"?` — ${w} is live`:" — now live","."]}),r.jsx("button",{className:"update-banner-x",onClick:()=>j(null),"aria-label":"Dismiss",children:"×"})]})}),t&&!y&&!w&&r.jsxs("div",{ref:E,className:Yv(s),role:"status","aria-live":"polite",children:[r.jsxs("div",{className:"update-banner-row",children:[r.jsx("span",{className:"update-banner-text",children:s==="msi"&&o?`Update available — version ${o}.`:"Update available."}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[s==="msi"&&r.jsx("a",{className:"btn btn-sm btn-secondary",href:qv(o),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),s!=="managed"&&s!=="msi"&&r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:T,children:"Update"}),r.jsx("button",{className:"update-banner-x",onClick:h,"aria-label":"Dismiss",children:"×"})]})]}),s==="managed"&&r.jsx("p",{className:"update-banner-hint",children:Kv}),s==="msi"&&r.jsx("p",{className:"update-banner-hint",children:Jv})]}),y&&r.jsx("div",{className:"update-overlay",children:r.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[r.jsx("div",{className:"update-spinner"}),r.jsxs("h2",{children:["Finishing the update","…"]}),r.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",r.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),r.jsxs("div",{className:"update-cmd-row",children:[r.jsx("code",{className:"update-cmd",children:N}),r.jsx("button",{className:"btn btn-sm btn-primary",onClick:R,children:g?"Copied":"Copy"})]}),r.jsxs("div",{className:"update-status",children:[r.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),r.jsxs("div",{className:"update-overlay-actions",children:[r.jsx("button",{className:"btn btn-primary",onClick:()=>S(a),children:"Reload now"}),r.jsx("button",{className:"btn btn-secondary",onClick:()=>p(!1),children:"Cancel"})]})]})})]})}function $h(){const t=lc(),s=f.useRef(null);return f.useEffect(()=>{if(!t){document.documentElement.style.removeProperty("--sim-banner-h");return}const a=()=>{var d;const c=((d=s.current)==null?void 0:d.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${c}px`)};a();const o=new ResizeObserver(a);return s.current&&o.observe(s.current),()=>{o.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[t]),t?r.jsx("div",{ref:s,className:"simulation-banner",role:"status","aria-live":"polite",children:r.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const Xv={system:"◑",light:"☀",dark:"☾"},Zv=[{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 ex({open:t,onClose:s}){const{user:a,activeGroup:o,activeDomain:c,logout:d}=vt(),{theme:h,toggle:y}=Ch(),p=Dt();return f.useEffect(()=>{s()},[p.pathname]),t?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"mobile-menu-backdrop",onClick:s}),r.jsxs("div",{className:"mobile-menu-panel",children:[a&&r.jsxs("div",{className:"mobile-menu-header",children:[r.jsx("strong",{children:a.name}),r.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:o?`${o.name} / ${c}`:c||"personal"})]}),r.jsx("nav",{className:"mobile-menu-nav",children:Zv.map(g=>r.jsxs(rc,{to:g.to,end:g.to==="/",className:({isActive:v})=>`mobile-menu-item${v?" active":""}`,onClick:s,children:[r.jsx("span",{className:"icon",children:g.icon}),g.label]},g.to))}),r.jsxs("div",{className:"mobile-menu-footer",children:[r.jsxs("button",{className:"mobile-menu-action",onClick:()=>{y()},children:[r.jsx("span",{className:"icon",children:Xv[h]}),"Theme: ",h]}),r.jsx("button",{className:"mobile-menu-action",onClick:()=>{d(),s()},children:"Logout"})]})]})]}):null}function Lh(t){return t.status==="pending"}function tx(t,s){return t.filter(Lh).length+s.length}const vr=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],nx=500;function zh(){const{user:t,domain:s}=vt(),[a,o]=f.useState(0),c=f.useRef(null),d=f.useCallback(async()=>{if(!t){o(0);return}try{const[y,p]=await Promise.all([D.getMyProposals(s).catch(()=>[]),D.getProposalsForApprover().catch(()=>[])]);o(tx(y,p))}catch{o(0)}},[t,s]),h=f.useCallback(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d()},nx)},[d]);return f.useEffect(()=>(d(),()=>{c.current&&clearTimeout(c.current)}),[d]),He(vr[0],h),He(vr[1],h),He(vr[2],h),He(vr[3],h),He(vr[4],h),He(vr[5],h),He(vr[6],h),a}const xf="Suveren",rx="/favicon.svg",sx="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",di={x1:74.54,y1:22.74,x2:94.46,y2:34.24},ax=14,ix="#f59e0b";function ox(t){const s=dc(t);return s>0?`(${s}) ${xf}`:xf}function dc(t){return Number.isFinite(t)&&t>0?Math.floor(t):0}function lx(){const t=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
52
+ <path class="m" d="${sx}"/>
53
+ <line class="m" x1="${di.x1}" y1="${di.y1}" x2="${di.x2}" y2="${di.y2}"/>
54
+ <circle cx="103" cy="103" r="25" fill="${ix}"/>
55
+ <style>.m{stroke:#111111;stroke-width:${ax};fill:none;stroke-linecap:round}@media (prefers-color-scheme:dark){.m{stroke:#ffffff;stroke-width:13.3}}</style>
56
+ </svg>`;return`data:image/svg+xml,${encodeURIComponent(t)}`}function cx(){return document.querySelector('link[rel="icon"]')}function Fh(t){const s=dc(t);document.title=ox(s),Oh(s);const a=cx();if(!a)return;const o=s>0?lx():rx;a.getAttribute("href")!==o&&a.setAttribute("href",o)}function ux(){Fh(0)}function Oh(t,s=globalThis.navigator){var c;if(!s||typeof s.setAppBadge!="function")return;const a=dc(t),o=a>0?s.setAppBadge(a):s.clearAppBadge?s.clearAppBadge():s.setAppBadge(0);(c=o==null?void 0:o.catch)==null||c.call(o,()=>{})}function dx(){const t=zh();return f.useEffect(()=>{Fh(t)},[t]),f.useEffect(()=>ux,[]),null}const Mh="suveren:dockBadgePrompt";function fx(){var o;if(typeof window>"u"||!("Notification"in window)||!("setAppBadge"in navigator)||!(((o=window.matchMedia)==null?void 0:o.call(window,"(display-mode: standalone)").matches)||navigator.standalone===!0))return!1;const s=navigator.userAgent;if(!(/Safari\//.test(s)&&!/Chrome\/|Chromium\/|Edg\//.test(s))||Notification.permission!=="default")return!1;try{if(localStorage.getItem(Mh))return!1}catch{}return!0}function hx(){const[t,s]=f.useState(!1),a=zh();if(f.useEffect(()=>{s(fx())},[]),!t)return null;const o=()=>{try{localStorage.setItem(Mh,"1")}catch{}s(!1)},c=async()=>{try{await Notification.requestPermission()==="granted"&&Oh(a)}catch{}o()};return r.jsxs("div",{className:"hint-box",style:{marginBottom:"1rem",alignItems:"center"},children:[r.jsxs("div",{className:"hint-body",children:[r.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."]}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:c,children:"Allow"}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,"aria-label":"Not now",children:"Not now"})]})}function mx(){const[t,s]=f.useState(!1);return r.jsxs(Ev,{children:[r.jsx(dx,{}),r.jsx(ic,{onMenuToggle:()=>s(!t)}),r.jsx(_h,{}),r.jsx($h,{}),r.jsx(Vv,{}),r.jsx(ex,{open:t,onClose:()=>s(!1)}),r.jsx("div",{className:"main-content",children:r.jsxs("div",{className:"page-inner",children:[r.jsx(hx,{}),r.jsx(Ny,{})]})})]})}function Bh({what:t}){return r.jsxs("div",{className:"human-only-note",role:"note",children:[r.jsx("strong",{children:"Only you."})," ",t==="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 fc(){return typeof navigator<"u"&&navigator.webdriver===!0}const hc="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function px(){const[t,s]=f.useState(""),{login:a,isLoading:o,error:c,clearError:d}=vt(),[h,y]=f.useState(null),p=fc(),g=async()=>{if(!(!t.trim()||p)){d();try{await a(t)}catch(j){if(j instanceof kh){y(j.summary);return}}}},v=async()=>{y(null),d();try{await a(t,{confirmWipe:!0})}catch{}},w=()=>{y(null)};return r.jsxs(r.Fragment,{children:[r.jsx(ic,{}),r.jsx(_h,{}),r.jsx($h,{}),r.jsxs("div",{className:"login-split",children:[r.jsx("div",{className:"login-split-left",children:r.jsxs("div",{style:{maxWidth:"28rem"},children:[r.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."}),r.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."})]})}),r.jsx("div",{className:"login-split-right",children:r.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[r.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[r.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),r.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage mandates."})]}),r.jsx(Bh,{what:"sign-in"}),p&&r.jsx("div",{className:"error-message",children:hc}),c&&r.jsx("div",{className:"error-message",children:c}),r.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[r.jsx("label",{className:"form-label",children:"API Key"}),r.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:t,onChange:j=>s(j.target.value),onKeyDown:j=>j.key==="Enter"&&g(),disabled:o,style:{padding:"0.75rem"}}),r.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),r.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:g,disabled:o||p,style:{marginBottom:"2rem"},children:o?"Signing in...":"Sign In"}),r.jsx("div",{className:"login-divider",children:"New here?"}),r.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[r.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",r.jsx("br",{}),"then come back to sign in."]}),r.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"})]}),r.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),r.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[r.jsxs(r.Fragment,{children:["Create an account at ",r.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((j,N)=>r.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:N<2?"0.5rem":0},children:[r.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[N+1,"."]}),j]},N))})]})]})})]}),h&&r.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:w,children:r.jsxs("div",{className:"card",onClick:j=>j.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[r.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),r.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 ",r.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),r.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[r.jsxs("li",{children:[h.credentialCount," stored service credential",h.credentialCount===1?"":"s",h.credentialIds.length>0&&r.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",h.credentialIds.slice(0,5).join(", "),h.credentialIds.length>5?`, +${h.credentialIds.length-5} more`:"",")"]})]}),r.jsxs("li",{children:[h.serviceCount," configured integration",h.serviceCount===1?"":"s"]}),r.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),r.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),r.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."}),r.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."}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:w,disabled:o,children:"Cancel"}),r.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:v,disabled:o,children:o?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function gx(t,s){return!s&&t!=null}function yx(t,s){return t==="join-waiting"&&s==="team"}function vx(t,s,a,o){return a!=null||t!=="join-waiting"||s==="team"?null:o}function xx(t){return`${t} personal mandate${t===1?"":"s"}`}function wx({mandates:t,pendingProposals:s}){return t.length===0&&s===0?r.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)"},children:"You have no personal mandates to end."}):r.jsxs("div",{style:{background:"var(--bg-elevated)",borderRadius:"0.5rem",padding:"0.75rem 1rem",margin:"0.75rem 0"},children:[r.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"}),r.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,fontSize:"0.825rem"},children:t.map(a=>r.jsxs("li",{style:{display:"flex",justifyContent:"space-between",gap:"0.5rem",padding:"0.25rem 0",borderBottom:"1px solid var(--border)"},children:[r.jsx("span",{children:a.title||a.profileId}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:a.commitmentMode??""})]},a.id))}),r.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.",s>0&&` ${s} personal proposal${s===1?"":"s"} waiting for approval end${s===1?"s":""} too.`]})]})}function jx(){const{mode:t,pendingRequest:s,refreshGroups:a}=vt(),o=mn(),[c,d]=f.useState("choose"),[h,y]=f.useState(""),[p,g]=f.useState(""),[v,w]=f.useState(null),[j,N]=f.useState(null),[E,S]=f.useState(""),[C,T]=f.useState(""),[R,L]=f.useState(!1),P=f.useRef(!1);f.useEffect(()=>{gx(s,P.current)&&(P.current=!0,d("join-waiting"))},[s]),f.useEffect(()=>{yx(c,t)&&o("/")},[c,t,o]);const F=f.useRef(null);f.useEffect(()=>{if(s){F.current=s.groupName;return}const M=vx(c,t,s,F.current);M&&(S(M),d("join-declined"),F.current=null)},[s,c,t]),f.useEffect(()=>{if(c!=="join-waiting")return;const M=setInterval(()=>{a()},5e3);return()=>clearInterval(M)},[c,a]);const G=f.useCallback(()=>{d("choose"),T(""),w(null),N(null),y(""),g("")},[]),H=async()=>{if(h.trim()){L(!0),T("");try{const M=await D.getJoinPreview(h.trim());w(M),d("join-preview")}catch(M){T(M instanceof Error?M.message:"Invalid or expired invite code")}finally{L(!1)}}},ie=async()=>{L(!0),T("");try{await D.requestToJoinGroup(h.trim()),await a(),d("join-waiting")}catch(M){T(M instanceof Error?M.message:"Failed to join group")}finally{L(!1)}},Y=async()=>{L(!0),T("");try{await D.withdrawJoinRequest(),await a(),G()}catch(M){T(M instanceof Error?M.message:"Failed to withdraw request")}finally{L(!1)}},re=async()=>{d("create"),T(""),L(!0);try{const M=await D.getCreatePreview();N(M)}catch(M){T(M instanceof Error?M.message:"Failed to load preview")}finally{L(!1)}},J=async()=>{if(p.trim()){L(!0),T("");try{await D.createGroup(p.trim()),await a(),o("/")}catch(M){T(M instanceof Error?M.message:"Failed to create group")}finally{L(!1)}}};return r.jsxs(r.Fragment,{children:[r.jsx(ic,{}),r.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:r.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[C&&r.jsx("div",{className:"error-message",children:C}),c==="choose"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[r.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join or create a team"}),r.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)."})]}),r.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[r.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing team"}),r.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),r.jsxs("div",{className:"invite-input-row",children:[r.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:h,onChange:M=>y(M.target.value),onKeyDown:M=>M.key==="Enter"&&H(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:R}),r.jsx("button",{className:"btn btn-primary",onClick:H,disabled:R||!h.trim(),children:R?"Checking…":"Continue"})]})]}),r.jsxs("div",{className:"card",children:[r.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new team"}),r.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members."}),r.jsx("button",{className:"btn btn-secondary",onClick:re,disabled:R,children:"Create a team"})]})]}),c==="join-preview"&&v&&r.jsxs("div",{className:"card",children:[r.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Join team ",v.groupName,"?"]}),r.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Your account ",r.jsx("strong",{children:"moves to the team"}),". From then on you work under the team's rules — its approvers and limits."]}),r.jsx(wx,{mandates:v.personalMandates,pendingProposals:v.pendingPersonalProposals}),r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:["The team admin (",v.admin.name,") confirms your request. Nothing changes until then."]}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:ie,disabled:R,children:R?"Asking…":"Ask to join"}),r.jsx("button",{className:"btn btn-ghost",onClick:G,disabled:R,children:"Cancel"})]})]}),c==="join-waiting"&&r.jsxs("div",{className:"card",children:[r.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request sent to team ",(s==null?void 0:s.groupName)??""]}),r.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."}),r.jsx("button",{className:"btn btn-secondary",onClick:Y,disabled:R,children:R?"Withdrawing…":"Withdraw request"})]}),c==="join-declined"&&r.jsxs("div",{className:"card",children:[r.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request to ",E," ended"]}),r.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."}),r.jsx("button",{className:"btn btn-primary",onClick:G,disabled:R,children:"Back"})]}),c==="create"&&r.jsxs("div",{className:"card",children:[r.jsx("h3",{style:{marginBottom:"0.75rem"},children:"Create a team"}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsx("label",{style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:"Team name"}),r.jsx("input",{className:"form-input",placeholder:"e.g., Acme Corp",value:p,onChange:M=>g(M.target.value),onKeyDown:M=>M.key==="Enter"&&J(),disabled:R,autoFocus:!0})]}),j&&r.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",xx(j.personalMandates.length)," end (kept in your history)."]}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginTop:"1rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:J,disabled:R||!p.trim(),children:R?"Creating…":"Create team and move my account"}),r.jsx("button",{className:"btn btn-ghost",onClick:G,disabled:R,children:"Cancel"})]})]})]})})]})}const wf={"claude-code":{label:"Claude Code",snippet:t=>`claude mcp add --transport http suveren ${t}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:t=>`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",`${t}/mcp`,"--allow-http"]}}},null,2)}`},"chatgpt-codex":{label:"ChatGPT / Codex",snippet:t=>`Add to ~/.codex/config.toml:
59
+
60
+ [mcp_servers.suveren]
61
+ url = "${t}/mcp"
62
+
63
+ Or: codex mcp add suveren --url ${t}/mcp`},other:{label:"Other",snippet:t=>`Streamable HTTP: POST ${t}/mcp
64
+ SSE transport: GET ${t}/sse
65
+ Health check: GET ${t}/health`}},jf=["claude-code","claude-desktop","chatgpt-codex","other"];function zl({mcpEndpoint:t}){const[s,a]=f.useState(jf[0]),[o,c]=f.useState(!1),d=f.useCallback(async y=>{try{await navigator.clipboard.writeText(y),c(!0),setTimeout(()=>c(!1),2e3)}catch{}},[]),h=wf[s].snippet(t);return r.jsxs("div",{children:[r.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),r.jsx("div",{className:"mcp-endpoint",children:t}),r.jsx("div",{className:"mcp-tabs",children:jf.map(y=>r.jsx("button",{className:`mcp-tab${s===y?" active":""}`,onClick:()=>a(y),children:wf[y].label},y))}),r.jsx("pre",{className:"mcp-snippet",children:h}),r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>d(h),children:o?"Copied":"Copy"})]})}const Fl="suveren-setup-ai-skipped",Ol="suveren-setup-agent-done",Ml="suveren-setup-dismissed",Sx={"hap-setup-ai-skipped":Fl,"hap-setup-agent-done":Ol,"hap-setup-dismissed":Ml};function kx(){for(const[t,s]of Object.entries(Sx)){const a=localStorage.getItem(t);a!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,a),a!==null&&localStorage.removeItem(t)}}kx();function bx({aiConfigured:t,hasRunningIntegration:s,hasActiveAuth:a,hasAgentConnected:o,mcpEndpoint:c}){const[d,h]=f.useState(()=>localStorage.getItem(Fl)==="true"),[y,p]=f.useState(()=>localStorage.getItem(Ol)==="true"),[g,v]=f.useState(()=>localStorage.getItem(Ml)==="true"),[w,j]=f.useState(null),N=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:t?"done":d?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:s?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:a?"done":"pending"},{label:"Connect your agent",status:o||y?"done":"pending"}],E=N.filter(P=>P.status==="done"||P.status==="skipped").length,S=E===N.length,C=f.useCallback(()=>{localStorage.setItem(Fl,"true"),h(!0)},[]),T=f.useCallback(()=>{localStorage.setItem(Ol,"true"),p(!0),j(null)},[]),R=f.useCallback(()=>{localStorage.setItem(Ml,"true"),v(!0)},[]);if(g||S)return null;const L=N.findIndex(P=>P.status==="pending");return r.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[r.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),r.jsx("button",{onClick:R,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:"×"})]}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:N.map((P,F)=>{const G=F===L,H=P.status==="done"||P.status==="skipped"?"●":"○",ie=P.status==="done"?"var(--success)":P.status==="skipped"?"var(--text-tertiary)":G?"var(--accent)":"var(--text-tertiary)";return r.jsxs("div",{children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:G?"0.75rem":"0.25rem 0",borderRadius:G?"0.5rem":void 0,background:G?"var(--accent-subtle)":void 0},children:[r.jsx("span",{style:{color:ie,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:H}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[P.to&&P.status==="pending"?r.jsx(yt,{to:P.to,style:{fontSize:"0.9rem",fontWeight:G?600:500,color:G?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:P.label}):P.status==="pending"&&F===3?r.jsx("button",{onClick:()=>j(w===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:G?600:500,color:G?"var(--accent)":"var(--text-primary)"},children:P.label}):r.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:P.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:P.label}),P.optional&&P.status==="pending"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),P.status==="skipped"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),P.detail&&P.status==="pending"&&G&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:P.detail})]}),P.optional&&P.status==="pending"&&r.jsx("button",{onClick:C,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),P.to&&P.status==="pending"&&r.jsx(yt,{to:P.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),F===3&&w===3&&r.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[r.jsx(zl,{mcpEndpoint:c}),r.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:T,children:"Done"})]})]},F)})}),r.jsxs("div",{style:{marginTop:"1.25rem"},children:[r.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:r.jsx("div",{style:{height:"100%",width:`${E/N.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),r.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[E," of ",N.length," complete"]})]})]})}function Dh(t,s=null){const a=[t.hasContact,t.hasDelegationMandate,t.delegationProposalCount>0],o=a.every(Boolean),c=t.otherMandateCount===0&&!o,d=a.findIndex(g=>!g),h=s!==null&&a[s]===!1?s:d,y=t.managed?"managed":"self",p=g=>a[g]?{status:"done"}:g!==h?{status:"todo"}:g===1?{status:"open",variant:y,simulationOn:t.simulationOn}:g===0?{status:"open",variant:y}:{status:"open"};return{visible:c,step1:p(0),step2:p(1),step3:p(2)}}const Nx="/mandates?new=1&profile=delegation";function Sf({text:t}){const[s,a]=f.useState(!1),o=f.useCallback(async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t]);return r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:o,children:s?"Copied":"Copy"})}function El({todo:t,onOpen:s,children:a}){return t?r.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:s,children:a}):r.jsx("span",{className:"flow-step-title",children:a})}function Cx({contact:t,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:c,simulationOn:d,mcpEndpoint:h}){const y={hasContact:t!==null,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:c,simulationOn:d},[p,g]=f.useState(null),v=Dh(y,p);if(!v.visible)return null;const w=`Please connect to the Suveren gateway: MCP server at ${h}/mcp`;return r.jsxs("div",{className:"card setup-card",children:[r.jsx("h2",{className:"card-title",children:"Get started"}),r.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."}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${v.step1.status==="open"?"open":v.step1.status==="done"?"done":"todo"}`,children:v.step1.status==="done"?"✓":"1"}),v.step1.status==="done"&&t?r.jsxs("span",{className:"flow-step-title flow-done-title",children:[t.clientName," connected · last contact ",Ah(Date.parse(t.lastSeenAt),Date.now()).toLowerCase()]}):r.jsx(El,{todo:v.step1.status==="todo",onOpen:()=>g(0),children:"Connect your AI"})]}),v.step1.status==="open"&&r.jsx("div",{className:"flow-step-body",children:v.step1.variant==="managed"?r.jsxs(r.Fragment,{children:[r.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),r.jsxs("details",{className:"int-details",children:[r.jsx("summary",{children:"For your IT"}),r.jsx("div",{style:{marginTop:"0.75rem"},children:r.jsx(zl,{mcpEndpoint:h})})]})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),r.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:r.jsxs("div",{className:"quote-box",children:[r.jsx("span",{className:"quote-text",children:w}),r.jsx(Sf,{text:w})]})}),r.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."}),r.jsxs("details",{className:"int-details",children:[r.jsx("summary",{children:"Set it up by hand"}),r.jsx("div",{style:{marginTop:"0.75rem"},children:r.jsx(zl,{mcpEndpoint:h})})]})]})})]}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${v.step2.status==="open"?"open":v.step2.status==="done"?"done":"todo"}`,children:v.step2.status==="done"?"✓":"2"}),v.step2.status==="done"?r.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",r.jsx(yt,{to:"/mandates",children:"review or revoke under Mandates"})]}):r.jsx(El,{todo:v.step2.status==="todo",onOpen:()=>g(1),children:"Give the Delegation mandate"})]}),v.step2.status==="open"&&r.jsxs("div",{className:"flow-step-body",children:[r.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."}),r.jsxs("ul",{className:"bound-list",children:[r.jsx("li",{children:"Read the setup guides"}),r.jsx("li",{children:"Propose new mandates — each waits for your approval"}),r.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),v.step2.simulationOn?r.jsxs(r.Fragment,{children:[r.jsx(yt,{to:Nx,className:"btn btn-primary",children:"Give the Delegation mandate →"}),r.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),v.step2.variant==="managed"&&r.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):r.jsx("p",{className:"managed-note",style:{marginTop:0},children:v.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":r.jsxs(r.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",r.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),r.jsxs("div",{className:"flow-step",children:[r.jsxs("div",{className:"flow-step-head",children:[r.jsx("span",{className:`flow-step-marker flow-${v.step3.status==="open"?"open":"todo"}`,children:"3"}),r.jsx(El,{todo:v.step3.status==="todo",onOpen:()=>g(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),v.step3.status==="open"&&r.jsxs("div",{className:"flow-step-body",children:[r.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:r.jsxs("div",{className:"quote-box",children:[r.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),r.jsx(Sf,{text:"How do I start with Suveren?"})]})}),r.jsxs("p",{children:["It will interview you, suggest test data, and propose mandates and a brief. Approve its proposals under ",r.jsx(yt,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function Ex(){const[t,s]=f.useState(null);return f.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{!a&&typeof o.mcpPort=="number"&&s(`http://localhost:${o.mcpPort}`)}).catch(()=>{}),()=>{a=!0}},[]),t}function Tx(t){if(!t||typeof t!="object")return{simulation:null,locked:!1};const s=Array.isArray(t.policyLocked)&&t.policyLocked.includes("simulation");return{simulation:typeof t.simulation=="boolean"?t.simulation:null,locked:s}}function Uh(){const[t,s]=f.useState({simulation:null,locked:!1});return f.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(Tx(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function Rx(t){return!t||typeof t!="object"?!1:Array.isArray(t.policyLocked)&&t.policyLocked.length>0}function Ix(){const[t,s]=f.useState(!1);return f.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(h=>h.json()).then(h=>{a||s(Rx(h))}).catch(()=>{})};o();const c=setInterval(o,3e4),d=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",d),()=>{a=!0,clearInterval(c),document.removeEventListener("visibilitychange",d)}},[]),t}function jr({variant:t="base",style:s,className:a,...o}){const c=t==="title"?"skeleton skeleton-title":t==="line"?"skeleton skeleton-line":t==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return r.jsx("span",{className:`${c}${a?` ${a}`:""}`,style:s,role:"status","aria-busy":"true","aria-label":o["aria-label"]??"Loading"})}function Tl(){return r.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[r.jsx(jr,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[r.jsx(jr,{variant:"line",style:{width:"35%"}}),r.jsx(jr,{variant:"line-sm",style:{width:"65%"}})]})]})}function Ax(){const[t,s]=f.useState([]);return nn(async()=>{try{const{skipped:o}=await D.getSkippedCommitments();s(o)}catch{}},3e4),t.length===0?null:r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px solid var(--warn, #b58900)"},children:[r.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",t.length,")"]}),r.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."}),r.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:t.map(o=>r.jsxs("li",{style:{marginBottom:"0.35rem"},children:[r.jsx("code",{children:o.tool})," ",r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",o.id,")"]})]},o.id))})]})}function Px(t,s){return s&&!Ks(t.manifest)}function _x(t,s=!1){var o;const a=[];for(const c of t)Px(c,s)||(c.state==="error"?a.push({label:"Integration error",detail:(o=c.integration)!=null&&o.error?`${c.manifest.name}: ${c.integration.error}`:`${c.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"}):c.state==="not-running"&&(Ks(c.manifest)?a.push({label:`${c.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--danger)"}):a.push({label:"Integration stopped",detail:`${c.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"})));return a}function $x(t){const s=t.filter(a=>a.state==="paused");return s.length===0?null:{count:s.length,namesText:s.map(a=>a.manifest.name).join(", ")}}const Lx=1800;function Jr(t){return t.replace(/@.*$/,"").split("/").pop()??t}function zx(){const{domain:t}=vt(),[s,a]=f.useState([]),[o,c]=f.useState([]),[d,h]=f.useState([]),[y,p]=f.useState(!0),[g,v]=f.useState(!1),[w,j]=f.useState([]),[N,E]=f.useState(!1),[S,C]=f.useState(!1),[T,R]=f.useState(null),[L,P]=f.useState(!1),{entries:F,activeSessions:G,loading:H}=cc(),ie=Ex(),Y=!H,{simulation:re}=Uh(),J=re===!0,M=Ix(),fe=f.useCallback(()=>{D.getMyAttestations().then(se=>{a(se),v(!0)}).catch(()=>v(!0)),D.getArchivedMandates().then(j).catch(()=>j([])),D.getMyProposals(t).then(se=>{c(se),E(!0)}).catch(()=>E(!0)),D.getProposalsForApprover().then(se=>h(se)).catch(()=>h([])),D.getCredential("ai-config").then(se=>{p(se.configured),C(!0)}).catch(()=>C(!0)),D.getAgentContact().then(se=>{R(se.contact),P(!0)}).catch(()=>P(!0))},[t]);He("attestation-changed",fe),He("proposal-added",fe),He("proposal-resolved",fe),He("proposal-approved",fe),He("proposal-rejected",fe),nn(fe,3e5,t);const oe=g&&N&&S&&Y&&L&&re!==null,Z=Rh(s,{archivedSet:new Set(w)}),pe=Z.active,ee=Z.expired,W=pe.some(se=>Jr(se.profile_id)==="delegation"),B=pe.filter(se=>Jr(se.profile_id)!=="delegation").length,V=o.filter(se=>Jr(se.profileId)==="delegation").length,k=Dh({hasContact:T!==null,hasDelegationMandate:W,otherMandateCount:B,delegationProposalCount:V,managed:M,simulationOn:J}),A=J&&k.visible,K=pe.filter(se=>se.remaining_seconds!==null&&se.remaining_seconds<=Lx),te=o.filter(Lh),ue=F.filter(se=>se.state==="running"),ve=F.filter(se=>se.state==="starting"),Ce=$x(F),ke=[];for(const se of d)ke.push({label:"Approval needed",detail:`${se.tool} — above-cap action under ${Jr(se.profileId)}`,to:"/approvals",color:"var(--warning)"});for(const se of te)ke.push({label:"Approval pending",detail:`${se.tool} awaiting your approval`,to:"/approvals",color:"var(--warning)"});for(const se of K){const Le=Math.ceil((se.remaining_seconds??0)/60);ke.push({label:"Expiring soon",detail:`${se.title??Jr(se.profile_id)} — ${Le} min remaining`,to:"/mandates",color:"var(--warning)"})}for(const se of ee)ke.push({label:"Expired",detail:se.title??Jr(se.profile_id),to:"/mandates",color:"var(--danger)"});ke.push(..._x(F,J));for(const se of ve)ke.push({label:"Integration starting",detail:`${se.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const se of F)se.authStatus==="failed"&&se.state!=="not-running"&&se.state!=="error"&&se.state!=="paused"&&ke.push({label:"Reconnect needed",detail:`${se.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return y||ke.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Dashboard"})}),oe&&ie&&(A?r.jsx(Cx,{contact:T,hasDelegationMandate:W,otherMandateCount:B,delegationProposalCount:V,managed:M,simulationOn:J,mcpEndpoint:ie}):!J&&r.jsx(bx,{aiConfigured:y,hasRunningIntegration:ue.length>0,hasActiveAuth:pe.length>0,hasAgentConnected:G>0,mcpEndpoint:ie})),!A&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[r.jsx(yt,{to:"/mandates",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[g?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:pe.length>0?"var(--success)":"var(--text-tertiary)"},children:pe.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),r.jsx(yt,{to:"/approvals",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[N?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:te.length>0?"var(--warning)":"var(--text-tertiary)"},children:te.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),r.jsx(yt,{to:"/mandates",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[g?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:ee.length>0?"var(--danger)":"var(--text-tertiary)"},children:ee.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),r.jsx(yt,{to:"/integrations",style:{textDecoration:"none"},children:r.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[Y?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:ue.length>0?"var(--success)":"var(--text-tertiary)"},children:ue.length}):r.jsx(jr,{variant:"title"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),r.jsxs("section",{className:"card attention","aria-label":"Needs your attention",children:[r.jsxs("div",{className:"card-header",children:[r.jsx("h2",{className:"card-title",children:"Needs your attention"}),ke.length>0&&r.jsx("span",{className:"rb-count",children:ke.length})]}),ke.length>0?r.jsx("div",{className:"attention-rows",children:ke.map((se,Le)=>r.jsxs(yt,{to:se.to,className:"attention-row",children:[r.jsx("span",{className:"attention-dot",style:{background:se.color},"aria-hidden":"true"}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:se.label}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:se.detail})]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},Le))}):oe?r.jsxs("div",{className:"all-clear",children:[r.jsx("span",{className:"rb-mark","aria-hidden":"true",children:r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 6 9 17l-5-5"})})}),r.jsx("h3",{children:"All clear"}),r.jsx("p",{children:"Nothing needs your attention."})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[r.jsx(Tl,{}),r.jsx(Tl,{}),r.jsx(Tl,{})]})]})]}),Ce&&r.jsxs("div",{className:"sim-paused-summary",role:"status",children:[r.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),r.jsxs("span",{children:[r.jsxs("b",{children:[Ce.count," real system",Ce.count===1?"":"s"," ",Ce.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",Ce.namesText,"."]})]}),r.jsx(Ax,{}),r.jsx($v,{})]})}const Fx=["Scope & Limits","Intent","Sign"];function Wh({currentStep:t,onStepClick:s}){const a=mn();return r.jsxs("div",{className:"wizard-progress",children:[r.jsx("ol",{className:"wizard-steps",children:Fx.map((o,c)=>{const d=c+2,h=d<t,y=d===t,p=d-1<t,g=h&&!!s;return r.jsxs("li",{className:`wizard-step${p?" reached":""}`,"aria-current":y?"step":void 0,children:[r.jsx("button",{type:"button",className:`step-circle${h?" completed":""}${y?" current":""}`,onClick:g?()=>s(d):void 0,disabled:!g,"aria-label":`${o}${h?" (done)":y?" (current)":""}`,children:h?"✓":c+1}),r.jsx("span",{className:`step-label-text${y?" current":h?" completed":""}`,children:o})]},d)})}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>a("/mandates?new=1"),children:"Cancel"})]})}const kf=40,Ox={delegation:"Delegation"};function dt(t,s){const a=t.lastIndexOf("/"),o=a>=0?t.slice(a+1):t,c=o.indexOf("@"),d=c>=0?o.slice(0,c):o,h=Ox[d.toLowerCase()];return h||(s?s.slice(0,kf):(d.charAt(0).toUpperCase()+d.slice(1)).slice(0,kf))}function Mx({profileId:t,bounds:s,groupName:a,domain:o,onSwitch:c}){return r.jsxs("div",{className:"context-strip",children:[a&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"context-strip-label",children:"Team:"}),r.jsxs("span",{children:[r.jsx("strong",{children:a}),o?` / ${o}`:""]})]}),t&&r.jsxs("span",{children:[r.jsx("strong",{children:"Profile:"})," ",dt(t)]}),s&&r.jsxs("span",{children:[r.jsx("strong",{children:"Bounds:"})," ",s]}),c&&r.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:c,children:"Switch"})]})}function Bx({integrationId:t,field:s,value:a,onChange:o,disabled:c,onLabels:d}){const[h,y]=f.useState(null),[p,g]=f.useState(null),[v,w]=f.useState(!0);f.useEffect(()=>{let E=!1;return D.discoverScopeField(t,s).then(S=>{var C;E||(y(S.options),w(!1),(C=S.options)!=null&&C.length&&(d==null||d(Object.fromEntries(S.options.map(T=>[T.value,T.label])))))}).catch(S=>{E||(g(S instanceof Error?S.message:String(S)),w(!1))}),()=>{E=!0}},[t,s]);const j=new Set(a.split(",").map(E=>E.trim()).filter(Boolean)),N=E=>{const S=new Set(j);S.has(E)?S.delete(E):S.add(E),o(Array.from(S).join(","))};return v?r.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",t,"…"]}):p||!h?r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",p??"no response","). Enter values manually, separated by commas."]}),r.jsx("input",{className:"form-input",type:"text",value:a,onChange:E=>o(E.target.value),disabled:c})]}):h.length===0?r.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",t," for this field."]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:h.map(E=>{const S=E.extras??{},C=typeof S.access=="string"?S.access:void 0,T=C==="reader",R=S.primary===!0;return r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:T?"var(--text-tertiary)":"var(--text-primary)",cursor:c||T?"not-allowed":"pointer"},title:T?"Read-only — you can authorize list/read but not writes":void 0,children:[r.jsx("input",{type:"checkbox",checked:j.has(String(E.value)),onChange:()=>N(String(E.value)),disabled:c||T}),r.jsx("span",{children:E.label||E.value}),R&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),C&&r.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",C]})]},E.value)})})}function mc(t){if(t.type!=="number")return 0;const s=t.boundType,a=t.unit;return(s==null?void 0:s.kind)==="per_transaction"&&a==="count"?1:0}function Dx(t,s){if(s!==void 0)return String(s);const a=t.default;return typeof a=="string"||typeof a=="number"&&Number.isFinite(a)?String(a):mc(t)===1?"1":""}function Hh(t){const s=t.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function bf(t,s){const a=mc(t),o=Hh(t),c=s===""?a:Math.max(a,Number(s));return o!==void 0?Math.min(o,c):c}function pc(t){return!t||t==="count"?"":t==="minutes"?"min":t==="hours"?"hr":t==="days"?"days":t==="percent"?"%":t.startsWith("currency:")?t.slice(9):t}function Ux(t){return t.replace(/@.*$/,"").split("/").pop()??t}function Wx(t,s){return s.displayName?s.displayName:t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Hx(t){return t.type==="string"&&(t.format==="email"||t.format==="domain")}function Vx(t){var a;const s=t;return!!(s.enum&&((a=s.constraint)!=null&&a.enforceable.includes("subset")))}function Nf(t,s){const a=t.trim();return a?s==="email"?a.includes("@")&&a.indexOf(".",a.indexOf("@"))>-1:s==="domain"?a.includes(".")&&!a.includes("@"):!0:!1}function Gx(t){return t?t==="minutes"?15:t==="percent"?5:t.startsWith("currency:")?10:1:1}function Kx(t){return t?t==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:t==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:t==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:t==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:t.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function Yx(t,s){if(!t||!s)return"";const a=Number(t);if(!Number.isFinite(a)||a<=0)return"";if(s==="minutes"&&a>=60){const o=Math.floor(a/60),c=a%60;return c===0?`${o} hour${o!==1?"s":""}`:`${o}h ${c}m`}if(s==="hours"&&a>=24&&a%24===0){const o=a/24;return`${o} day${o!==1?"s":""}`}if(s==="days"){if(a>=30&&a%30===0)return`${a/30} month${a/30!==1?"s":""}`;if(a>=7&&a%7===0)return`${a/7} week${a/7!==1?"s":""}`}return""}function Jx({id:t,value:s,onChange:a,disabled:o,placeholder:c,unit:d,min:h=0,max:y}){const p=Gx(d),g=Kx(d).filter(S=>y===void 0||S.value<=y),v=pc(d),w=Yx(s,d),j=s===""?null:Number(s),N=()=>{const S=s===""?0:Number(s),C=S%p,T=C===0?S+p:S+(p-C);a(String(y!==void 0?Math.min(y,T):T))},E=()=>{const S=s===""?0:Number(s);if(S<=h)return;const C=S%p,T=C===0?S-p:S-C;a(String(Math.max(h,T)))};return r.jsxs("div",{className:"bounded-input",children:[r.jsxs("div",{className:"bounded-input-field",children:[r.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:E,disabled:o||s===""||Number(s)<=h,"aria-label":"Decrease",children:"−"}),r.jsx("input",{id:t,className:"stepper-input",type:"number",min:h,max:y,step:p,value:s,placeholder:c??String(h),onChange:S=>{const C=S.target.value;a(y!==void 0&&C!==""&&Number(C)>y?String(y):C)},onFocus:S=>S.target.select(),disabled:o}),r.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:N,disabled:o||y!==void 0&&s!==""&&Number(s)>=y,"aria-label":"Increase",children:"+"}),v&&r.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:v})]}),g.length>0&&!o&&r.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:g.map(S=>r.jsx("button",{type:"button",className:`preset-chip${j===S.value?" preset-chip-selected":""}`,onClick:()=>a(String(S.value)),children:S.label},S.value))}),w&&r.jsxs("div",{className:"bounded-input-echo",children:["≈ ",w]})]})}function Cf({htmlFor:t,label:s,description:a}){const[o,c]=f.useState(!1);return r.jsxs("div",{className:"field-label-with-tip",children:[r.jsx("label",{className:"form-label",htmlFor:t,children:s}),a&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${s}" mean?`,"aria-expanded":o,onClick:()=>c(d=>!d),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onBlur:()=>c(!1),children:"i"}),o&&r.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:a})]})]})}function qx({id:t,value:s,onChange:a,disabled:o,format:c,placeholder:d}){const[h,y]=f.useState(""),[p,g]=f.useState(!1),v=f.useRef(null),w=s?s.split(",").map(T=>T.trim()).filter(Boolean):[],j=T=>{const R=T.trim();if(!R)return;if(!Nf(R,c)){g(!0);return}g(!1);const L=w.includes(R)?w:[...w,R];a(L.join(",")),y("")},N=T=>{const R=w.filter((L,P)=>P!==T);a(R.join(","))},E=T=>{T.key==="Enter"||T.key===","||T.key==="Tab"?h.trim()&&(T.preventDefault(),j(h)):T.key==="Backspace"&&!h&&w.length>0&&N(w.length-1)},S=T=>{const R=T.clipboardData.getData("text");if(R.includes(",")){T.preventDefault();const P=R.split(",").map(G=>G.trim()).filter(Boolean).filter(G=>Nf(G,c)),F=[...new Set([...w,...P])];a(F.join(",")),y(""),g(!1)}},C=c==="email"?"Type email and press Enter...":"Type domain and press Enter...";return r.jsxs("div",{className:`tag-input${p?" tag-input-invalid":""}`,onClick:()=>{var T;return(T=v.current)==null?void 0:T.focus()},children:[w.map((T,R)=>r.jsxs("span",{className:"tag-pill",children:[T,!o&&r.jsx("button",{type:"button",className:"tag-remove",onClick:L=>{L.stopPropagation(),N(R)},"aria-label":`Remove ${T}`,children:"×"})]},T)),!o&&r.jsx("input",{ref:v,id:t,className:"tag-input-field",type:"text",value:h,onChange:T=>{y(T.target.value),g(!1)},onKeyDown:E,onPaste:S,onBlur:()=>{h.trim()&&j(h)},placeholder:w.length===0?d??C:""})]})}function Qx({id:t,options:s,value:a,onChange:o,disabled:c}){const d=a?a.split(",").map(y=>y.trim()).filter(Boolean):[],h=y=>{const p=d.includes(y)?d.filter(g=>g!==y):[...d,y];o(p.join(","))};return r.jsx("div",{className:"checkbox-group",id:t,children:s.map(y=>r.jsxs("label",{className:`checkbox-pill${d.includes(y)?" checkbox-pill-selected":""}`,children:[r.jsx("input",{type:"checkbox",checked:d.includes(y),onChange:()=>h(y),disabled:c}),r.jsx("span",{children:y})]},y))})}function Ef({fieldKey:t,fieldDef:s,value:a,onChange:o,prefix:c,readOnly:d,twoColumn:h,discoveryIntegrationId:y,onLabels:p}){const g=Wx(t,s),v=`${c}-field-${t}`,w=r.jsx(r.Fragment,{children:Vx(s)?r.jsx(Qx,{id:v,options:s.enum,value:a,onChange:j=>o(t,j),disabled:d}):(()=>{const j=s.boundType;return(j==null?void 0:j.kind)==="enum"&&Array.isArray(j.values)})()?r.jsxs("select",{id:v,className:"form-select",value:a,onChange:j=>o(t,j.target.value),disabled:d,children:[r.jsx("option",{value:"",children:"Select..."}),s.boundType.values.map(j=>r.jsx("option",{value:j,children:j},j))]}):s.enum?r.jsxs("select",{id:v,className:"form-select",value:a,onChange:j=>o(t,j.target.value),disabled:d,children:[r.jsx("option",{value:"",children:"Select..."}),s.enum.map(j=>r.jsx("option",{value:j,children:j},j))]}):s.type==="number"?r.jsx(Jx,{id:v,value:a,onChange:j=>o(t,j),disabled:d,unit:s.unit,min:mc(s),max:Hh(s)}):Hx(s)?r.jsx(qx,{id:v,value:a,onChange:j=>o(t,j),disabled:d,format:s.format}):y?r.jsx(Bx,{integrationId:y,field:t,value:a,onChange:j=>o(t,j),disabled:d,onLabels:j=>p==null?void 0:p(t,j)}):r.jsx("input",{id:v,className:"form-input",type:"text",value:a,onChange:j=>o(t,j.target.value),disabled:d})});return h?r.jsxs("div",{className:"bounds-field-row",children:[r.jsx("div",{className:"bounds-field-label",children:r.jsx(Cf,{htmlFor:v,label:g,description:s.description})}),r.jsx("div",{className:"bounds-field-input",children:w})]},`${c}-${t}`):r.jsxs("div",{className:"form-group",children:[r.jsx(Cf,{htmlFor:v,label:g,description:s.description}),w]},`${c}-${t}`)}function Xx(t,s){if(!s)return"no-config";const a=s.caps,o=Array.isArray(s.approvers)&&s.approvers.length>0;if(!(a&&Object.keys(a).length>0))return o?"approvers-dormant":"no-config";let d=!1;for(const[h,y]of Object.entries(a)){const p=t[h];if(p===""||p===void 0)continue;const g=Number(p);if(!isNaN(g)&&g>y){d=!0;break}}return d?o?"above-approvers":"hard-ceiling":"within-cap"}function Zx(t,s){const a=new Set;if(!s)return a;for(const[o,c]of Object.entries(s)){const d=t[o];if(d===""||d===void 0)continue;const h=Number(d);!isNaN(h)&&h>c&&a.add(o)}return a}function e0({profile:t,onConfirm:s,onCancel:a,readOnly:o,initialBounds:c,initialContext:d,initialFrame:h,profileConfig:y,approverNames:p,adminName:g}){const v=t.boundsSchema,w=t.scopeSchema,j=v?Object.entries(v.fields).filter(([k,A])=>!(k==="profile"||k==="path"||A.enforced===!1||A.enforcedBy==="gatekeeper")):[],N=v?Object.entries(v.fields).filter(([,k])=>k.enforcedBy==="gatekeeper").filter(([,k])=>k.enforced!==!1).map(([k,A])=>A.displayName??k):[],E=w&&w.keyOrder.length>0?Object.entries(w.fields):[],S=c??h??{},C=d??{},T={};for(const[k,A]of j)T[k]=Dx(A,S[k]);const R={};for(const[k]of E)R[k]=C[k]!==void 0?String(C[k]):"";const[L,P]=f.useState(T),[F,G]=f.useState(R),[H,ie]=f.useState({}),[Y,re]=f.useState(null);f.useEffect(()=>{const k=Ux(t.id);D.getIntegrationManifests().then(({manifests:A})=>{const K=A.find(te=>te.profile===k&&te.contextDiscovery&&Object.keys(te.contextDiscovery).length>0);re(K??null)}).catch(()=>re(null))},[t.id]);const J=Xx(L,y),M=Zx(L,y==null?void 0:y.caps),fe=(k,A)=>{P(K=>({...K,[k]:A}))},oe=(k,A)=>{G(K=>({...K,[k]:A}))},Z=()=>{const k={profile:t.id};for(const[K,te]of j)te.type==="number"?k[K]=bf(te,L[K]):k[K]=L[K];const A={};for(const[K,te]of E)te.type==="number"?A[K]=F[K]===""?0:Number(F[K]):A[K]=F[K];return[k,A]},pe=()=>{const[k,A]=Z();s(k,A,H)},ee=()=>{const k=(y==null?void 0:y.caps)??{},A={...L};for(const ue of M)k[ue]!==void 0&&(A[ue]=String(k[ue]));P(A);const K={profile:t.id};for(const[ue,ve]of j)ve.type==="number"?K[ue]=bf(ve,A[ue]??""):K[ue]=A[ue]??"";const te={};for(const[ue,ve]of E)ve.type==="number"?te[ue]=F[ue]===""?0:Number(F[ue]):te[ue]=F[ue];s(K,te,H)},W=k=>{const A=y==null?void 0:y.caps;if(!A||A[k]===void 0)return null;const K=A[k],te=M.has(k);return J==="hard-ceiling"&&te?r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",K," — exceeds team ceiling"]}):J==="above-approvers"&&te?r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",K," — above cap"]}):r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",K," ok"]})},B=()=>{var k;if(J==="no-config")return null;if(J==="approvers-dormant"){const A=p&&p.length>0?p.join(", "):"the configured approvers";return r.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:[r.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",A]}),r.jsxs("div",{children:["No caps are set on this profile, so ",A," 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(J==="within-cap")return r.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:r.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(J==="above-approvers"){const A=p&&p.length>0?p.join(", "):"the required approvers";return r.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:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),r.jsxs("div",{children:[r.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",A,". Within-cap actions run per the mode you choose."]})]})}if(J==="hard-ceiling"){const A=Array.from(M)[0],K=A?(k=y==null?void 0:y.caps)==null?void 0:k[A]:void 0,te=g??"the team admin";return r.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:[r.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),r.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",K??"the configured limit",". Lower your bound or ask ",te," to add an approver path above the cap."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ee,children:"Save below cap"}),a&&r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})}return null},V=J==="hard-ceiling";return r.jsxs("div",{children:[E.length>0&&r.jsxs("div",{className:"context-section",children:[r.jsxs("div",{className:"bounds-section-header",children:[r.jsx("span",{className:"bounds-section-icon",children:"🛡"}),r.jsxs("div",{children:[r.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),r.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),E.map(([k,A])=>{var te;const K=!!((te=Y==null?void 0:Y.contextDiscovery)!=null&&te[k]);return r.jsx(Ef,{fieldKey:k,fieldDef:A,value:F[k],onChange:oe,prefix:"context",readOnly:o,discoveryIntegrationId:K?Y.id:void 0,onLabels:(ue,ve)=>ie(Ce=>({...Ce,[ue]:ve}))},`context-${k}`)})]}),j.length>0&&r.jsxs("div",{className:"bounds-section",children:[r.jsxs("div",{className:"bounds-section-header",children:[r.jsx("span",{className:"bounds-section-icon",children:"🔒"}),r.jsxs("div",{children:[r.jsx("div",{className:"bounds-section-title",children:"Limits"}),r.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),r.jsx("div",{className:"bounds-fields-grid",children:j.map(([k,A])=>{var K;return r.jsxs("div",{style:{display:"contents"},children:[r.jsx(Ef,{fieldKey:k,fieldDef:A,value:L[k],onChange:fe,prefix:"bounds",readOnly:o,twoColumn:!0}),J!=="no-config"&&((K=y==null?void 0:y.caps)==null?void 0:K[k])!==void 0&&r.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:W(k)})]},`bounds-${k}`)})}),B(),N.length>0&&r.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[N.join(", ")," ",N.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"," ",r.jsx(yt,{to:"/integrations",children:"Integrations"}),"."]})]}),r.jsx("button",{className:"btn btn-primary",onClick:pe,disabled:V,style:{marginTop:"0.5rem"},children:o?"Next: Gates":"Next: Problem Statement"})]})}function t0(t){var a;const s=t.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((a=s==null?void 0:s[1])==null?void 0:a.trim())??null}function n0(t){return t.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const r0="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 ki({target:t,currentText:s,onApply:a,greeting:o,placeholder:c,title:d}){const[h,y]=f.useState([{role:"assistant",content:o??r0}]),[p,g]=f.useState(""),[v,w]=f.useState(!1),[j,N]=f.useState(null),E=f.useRef(null),S=f.useRef(null);f.useEffect(()=>{const R=E.current;if(!R)return;const L=h[h.length-1],P=S.current;!v&&(L==null?void 0:L.role)==="assistant"&&h.length>1&&P?R.scrollTop=P.offsetTop:R.scrollTop=R.scrollHeight},[h,v]);const C=async()=>{const R=p.trim();if(!R||v)return;const L=[...h,{role:"user",content:R}];y(L),g(""),N(null),w(!0);try{const P=await D.aiChat({target:t,currentText:s,messages:L.filter((F,G)=>!(G===0&&F.role==="assistant"))});P.success&&P.reply?y(F=>[...F,{role:"assistant",content:P.reply}]):N(P.error??"AI returned no reply")}catch(P){N(P instanceof Error?P.message:"Chat failed")}finally{w(!1)}},T=R=>{R.key==="Enter"&&!R.shiftKey&&!R.nativeEvent.isComposing&&(R.preventDefault(),C())};return r.jsxs("div",{className:"intent-chat",children:[r.jsx("h3",{className:"card-title",children:d??"AI Assistant"}),r.jsxs("div",{ref:E,className:"chat-messages",children:[h.map((R,L)=>{const P=R.role==="assistant"?t0(R.content):null,F=P?n0(R.content):R.content;return r.jsx("div",{className:`chat-msg ${R.role}`,ref:L===h.length-1?S:void 0,children:r.jsxs("div",{className:"chat-msg-body",children:[F&&r.jsx("div",{className:"chat-msg-prose",children:F}),P!==null&&r.jsxs(r.Fragment,{children:[r.jsx("pre",{className:"chat-fenced-block",children:P}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>a(P),children:"Apply this draft"})]})]})},L)}),v&&r.jsx("div",{className:"chat-msg assistant",children:r.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),j&&r.jsx("div",{className:"error-message",children:j}),r.jsxs("div",{className:"chat-composer",children:[r.jsxs("div",{className:"chat-composer-pill",children:[r.jsx("textarea",{className:"chat-input",value:p,onChange:R=>g(R.target.value),onKeyDown:T,placeholder:c??"Ask for help articulating the intent…",rows:1,disabled:v}),r.jsx("button",{type:"button",className:"chat-send-btn",onClick:C,disabled:v||!p.trim(),"aria-label":"Send",children:"↑"})]}),r.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Vh({open:t,onClose:s,children:a,ariaLabel:o}){const c=f.useRef(null),d=f.useRef(null);return f.useEffect(()=>{var y;if(!t)return;d.current=document.activeElement,document.body.style.overflow="hidden";const h=p=>{p.key==="Escape"&&s()};return document.addEventListener("keydown",h),(y=c.current)==null||y.focus(),()=>{document.removeEventListener("keydown",h),document.body.style.overflow="",d.current instanceof HTMLElement&&d.current.focus()}},[t,s]),ov.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`bottom-sheet-backdrop${t?" is-open":""}`,onClick:s,"aria-hidden":"true"}),r.jsxs("aside",{ref:c,className:`bottom-sheet${t?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":o,tabIndex:-1,children:[r.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),r.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:s,"aria-label":"Close",children:"×"}),a]})]}),document.body)}function s0(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function a0(t,s,a){if(s.length===0)return[{text:t,label:t,matched:null}];const o=[],c=new Set;for(const p of s)if(!(!p.scope||p.scope==="all (unscoped)"))for(const g of[p.scope,...p.scope.split(",").map(v=>v.trim())]){const v=g.toLowerCase();g&&!c.has(v)&&(c.add(v),o.push(g))}o.sort((p,g)=>g.length-p.length);const d=p=>{const g=p.toLowerCase();return s.filter(v=>{var w,j;return((w=v.scope)==null?void 0:w.toLowerCase())===g||((j=v.scope)==null?void 0:j.split(",").map(N=>N.trim().toLowerCase()).includes(g))})},h=["\\[\\d+\\]",...o.map(s0)],y=new RegExp(`(${h.join("|")})`,"gi");return t.split(y).filter(p=>p!=="").map(p=>{const g=/^\[(\d+)\]$/.exec(p);if(g){const v=s[Number(g[1])-1];if(v){const w=v.scope&&v.scope!=="all (unscoped)"?v.scope:"all recipients",j=a?`${a}: ${w}`:w;return{text:p,label:j,matched:[v]}}}else if(o.some(v=>v.toLowerCase()===p.toLowerCase())){const v=d(p);if(v.length>0)return{text:p,label:p,matched:v}}return{text:p,label:p,matched:null}})}const Tf=`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 i0(t,s,a,o){return a0(t,s,o).map((c,d)=>{if(!c.matched)return r.jsx("span",{children:c.text},d);const h=c.matched;return r.jsx("button",{type:"button",onClick:()=>a(h),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:c.label},d)})}function o0(){var _e;const t=mn(),[s]=sc(),a=Number(s.get("step"))||2,[o,c]=f.useState(null),[d,h]=f.useState(null),[y,p]=f.useState(a),[g,v]=f.useState(null),[w,j]=f.useState(null),[N,E]=f.useState({}),[S,C]=f.useState(Tf),[T,R]=f.useState(!1),[L,P]=f.useState(null),[F,G]=f.useState(!0),[H,ie]=f.useState(null),[Y,re]=f.useState([]),[J,M]=f.useState(void 0),[fe,oe]=f.useState(!1),[Z,pe]=f.useState(null),[ee,W]=f.useState(null),[B,V]=f.useState(null),[k,A]=f.useState([]),[K,te]=f.useState(null);f.useEffect(()=>{var Te;const he=sessionStorage.getItem("agentAuth");if(!he){t("/mandates?new=1");return}const X=JSON.parse(he);c(X),X.intentHint&&C(X.intentHint),D.getCredential("ai-config").then($e=>P($e.configured)).catch(()=>P(!1));const we=sessionStorage.getItem("agentGate");if(we){const $e=JSON.parse(we);$e.bounds&&v($e.bounds),$e.context&&j($e.context),(Te=$e.gateContent)!=null&&Te.intent&&C($e.gateContent.intent)}D.getProfile(X.profileId).then($e=>h($e)).catch(()=>t("/mandates?new=1")).finally(()=>G(!1)),X.groupId&&Promise.all([D.getTeamProfileConfig(X.groupId,X.profileId).catch(()=>null),D.getGroupById(X.groupId).catch(()=>null),D.listUsers().catch(()=>[])]).then(([$e,lt,xt])=>{if(ie($e),$e){const Ke=new Map;for(const Fe of xt){const $=Fe.name&&Fe.email?`${Fe.name} (${Fe.email})`:Fe.name||Fe.email||Fe.id;Ke.set(Fe.id,$)}const et=(lt==null?void 0:lt.members)??[];for(const Fe of et){const $=Fe.userId??Fe.id;$&&(Fe.name&&Fe.email?Ke.set($,`${Fe.name} (${Fe.email})`):Fe.name&&Ke.set($,Fe.name))}const st=($e.approvers??[]).map(Fe=>Ke.get(Fe)??Fe);re(st);const mt=et.find(Fe=>Fe.role==="admin");if(mt){const Fe=mt.userId??mt.id;Fe&&M(Ke.get(Fe)??mt.name)}}})},[t]);const ue=g?Object.entries(g).filter(([he])=>he!=="profile"&&he!=="path").map(([he,X])=>`${he} = ${X}`).join(", "):"",ve=(he,X,we)=>{v(he),j(X),we&&E(we),p(3)},Ce=S.trim()!==Tf.trim()&&S.trim()!=="",ke=he=>{Ce&&!confirm("Replace your current intent with the AI draft?")||C(he)},se=()=>{const he=d==null?void 0:d.ttl,X={intent:S},we=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...we,bounds:g,context:w,contextLabels:N,gateContent:X,ttlConfig:he})),t("/mandates/new/sign")},Le=async()=>{if(o){oe(!0),pe(null),W(null),V(null),A([]),te(null);try{const he=await D.aiIntentReview({profileId:o.profileId,newIntent:S,context:w??void 0});A(he.grants??[]),he.success?he.review?pe(he.review):W(he.note??"No other mandates on this profile to compare against."):V(he.error??"Check failed.")}catch(he){V(he instanceof Error?he.message:"Check failed.")}finally{oe(!1)}}},Ee=he=>{C(he),(Z||ee||B)&&(pe(null),W(null),V(null),A([]),te(null))};return F||!o||!d?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):r.jsxs(r.Fragment,{children:[r.jsx(Wh,{currentStep:y,onStepClick:he=>{he>=2&&p(he)}}),r.jsx(Mx,{profileId:o.profileId,bounds:ue||void 0,groupName:o.groupName,domain:o.domain}),y===2&&r.jsx("div",{className:"card",children:r.jsx(e0,{profile:d,onConfirm:ve,onCancel:()=>t("/mandates?new=1"),initialBounds:g||void 0,initialContext:w||void 0,profileConfig:H,approverNames:Y,adminName:J})}),y===3&&r.jsxs("div",{className:`intent-layout${L?"":" no-chat"}`,children:[L&&r.jsx("div",{className:"card intent-pane chat tool",children:r.jsx(ki,{target:{kind:"intent",profileId:o.profileId,bounds:ue||void 0},currentText:S,onApply:ke})}),r.jsxs("div",{className:"card intent-pane document",children:[r.jsx("h3",{className:"card-title",children:"What should your agent know?"}),r.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),r.jsx("textarea",{className:"intent-textarea",value:S,onChange:he=>Ee(he.target.value)}),r.jsxs("div",{className:"char-counter",children:[S.length," / 2000"]})]}),L===!1&&r.jsxs("p",{className:"intent-ai-hint",children:[r.jsx(yt,{to:"/settings",children:"Set up an AI assistant in Settings"})," to get help writing this."]}),L&&r.jsxs("div",{style:{marginTop:"0.5rem"},children:[r.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:Le,disabled:fe||!Ce,children:fe?"Checking…":"Check against my other grants"}),B&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeftColor:"var(--danger)"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),r.jsx("div",{className:"hint-body",children:B})]}),ee&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsx("div",{className:"hint-body",children:ee})]}),Z&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsxs("div",{className:"hint-body",children:[r.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),r.jsx("div",{style:{whiteSpace:"pre-wrap"},children:i0(Z,k,te,dt(o.profileId))}),r.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),r.jsxs("div",{className:"intent-footer",children:[r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(2),children:"Back"}),r.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:se,disabled:!Ce,children:"Continue to Review"})]}),(((_e=H==null?void 0:H.approvers)==null?void 0:_e.length)??0)>0&&r.jsxs("div",{className:"hint-box",role:"note",children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsxs("div",{className:"hint-body",children:[r.jsxs("div",{className:"hint-head",children:["Visible to ",Y.length>0?Y.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",Y.length>0?Y.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),L&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"floating-help",onClick:()=>R(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),r.jsx(Vh,{open:T,onClose:()=>R(!1),ariaLabel:"Intent assistant",children:r.jsx(ki,{target:{kind:"intent",profileId:o.profileId,bounds:ue||void 0},currentText:S,onApply:he=>{ke(he),R(!1)}})})]}),K&&r.jsx("div",{className:"modal-backdrop",onClick:he=>he.target===he.currentTarget&&te(null),children:r.jsxs("div",{className:"modal",children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h3",{className:"modal-title",children:K.length>1?`Existing mandates (${K.length})`:"Existing mandate"}),r.jsx("button",{className:"modal-close",onClick:()=>te(null),children:"×"})]}),r.jsx("div",{className:"modal-body",children:K.map((he,X)=>{var we;return r.jsxs("div",{style:{marginBottom:X<K.length-1?"1rem":0,paddingBottom:X<K.length-1?"1rem":0,borderBottom:X<K.length-1?"1px solid var(--border)":"none"},children:[r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),r.jsx("div",{style:{marginBottom:"0.75rem"},children:he.scope}),r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),r.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((we=he.intent)==null?void 0:we.trim())||"(no intent recorded)"}),Object.entries(he.bounds).filter(([Te])=>Te!=="profile"&&Te!=="path").length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),r.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(he.bounds).filter(([Te])=>Te!=="profile"&&Te!=="path").map(([Te,$e])=>`${Te}: ${$e}`).join(" · ")})]})]},X)})})]})})]})]})}function l0(t){return t.normalize("NFC").replace(/\r\n?/g,`
70
+ `).split(`
71
+ `).map(c=>c.replace(/[ \t]+$/,"")).join(`
72
+ `).replace(/\n+$/,"")}async function gc(t){const a=new TextEncoder().encode(t),o=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(o)).map(d=>d.toString(16).padStart(2,"0")).join("")}class c0 extends Error{constructor(a,o,c){super(c);Os(this,"code");Os(this,"field");this.name="CanonicalValueError",this.code=a,this.field=o}}function u0(t){const s=new TextEncoder().encode(t);let a="";for(const o of s)o===61||o===37||o<32||o>126?a+="%"+o.toString(16).toUpperCase().padStart(2,"0"):a+=String.fromCharCode(o);return a}function Gh(t,s,a){const o=[];for(const c of s){const d=t[c];if(d==null)continue;const h=String(d);if(h.includes(`
73
+ `)||h.includes("\r"))throw new c0(a,c,`Value for "${c}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);o.push(`${c}=${u0(h)}`)}return o.join(`
74
+ `)}async function vi(t,s){const a=s.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const o=Gh(t,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await gc(o)}`}async function Kh(t,s){const a=s.scopeSchema?Gh(t,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await gc(a)}`}function Bl(t){if(t===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof t=="number"&&!Number.isFinite(t))throw new Error(`canonicalize: ${t} is not a valid JSON number`);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return"["+t.map(c=>c===void 0?"null":Bl(c)).join(",")+"]";const s=t,a=[];for(const o of Object.keys(s).sort()){const c=s[o];c!==void 0&&a.push(JSON.stringify(o)+":"+Bl(c))}return"{"+a.join(",")+"}"}async function Yh(t){return`sha256:${await gc(Bl(t))}`}async function bi(t){const s=new TextEncoder().encode(l0(t)),a=await crypto.subtle.digest("SHA-256",s);return`sha256:${Array.from(new Uint8Array(a)).map(d=>d.toString(16).padStart(2,"0")).join("")}`}function Jh(t,s){if(!t.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:t.authorization_id,boundsHash:t.bounds_hash??s.boundsHash,contextHash:s.contextHash,context:s.context,...s.contextLabels&&Object.keys(s.contextLabels).length>0?{contextLabels:s.contextLabels}:{},gateContent:s.gateContent,...s.path?{path:s.path}:{}}}function d0(t){const s=t.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(a=>s.includes(a)):[]}function f0(t){return t==="per-action"?"review":"automatic"}function Rf(t){return t?d0(t).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function h0(t,s){return s.includes(t)?t:s[0]??null}function If(t){return t==null?new Set:new Set(String(t).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function m0(t,s){for(const a of t)if(s.has(a))return!0;return!1}function p0(t,s,a){for(const o of t){const c=If(s[o]),d=If(a[o]);if(!(c.size===0||d.size===0)&&!m0(c,d))return!1}return!0}function g0(t){return t.length>24?`${t.slice(0,10)}…`:t}function qh(t,s,a){const o=a==null?void 0:a[t];return String(s).split(",").map(d=>d.trim()).filter(Boolean).map(d=>{const h=o==null?void 0:o[d];return h?`${h} (${g0(d)})`:d}).join(", ")}function Qh(t){var a;if(t.isPersonal)return{can:!0};if(!t.configLoaded)return{can:!0};const s=t.teamName?`"${t.teamName}"`:"this team";return(((a=t.approvers)==null?void 0:a.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${s}.`,fix:`Ask an admin of ${s} to enable ${t.profileName} and name who may give its mandates.`}:!t.userId||!t.approvers.includes(t.userId)?{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${t.profileName}'s approvers in ${s} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}:{can:!0}}const Ni=500,y0=["Lower the discount","Other recipient","Shorter","Different wording"];function yc(t){const s=t.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>Ni?{valid:!1,error:`At most ${Ni} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function v0(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xh(t,s){return t.toLowerCase().includes(s.toLowerCase())}function x0(t,s){const a=t.trim();if(a.length===0)return s;if(!Xh(a,s))return`${a}. ${s}`;const o=new RegExp(`\\.?\\s*${v0(s)}\\.?`,"i");return a.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function Dl(){return{outcome:"rejected"}}function w0(t){const s=yc(t);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function Af(){return{outcome:"replaced"}}function j0(t,s){if((t.pendingApprovers??[]).includes(s))return{route:"approver"};const a=t.pendingDomains??[];return a.includes(s)?{route:"resolve",domain:s}:a.includes("owner")?{route:"resolve",domain:"owner"}:null}const S0={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function k0(t,s){const a=t.rejectedBy??t.approverRejectedBy;if(!a)return null;const o=a.outcome??"rejected",c=a.note??("reason"in a?a.reason:void 0);return{kind:S0[o],who:a.userId===s?"You":a.userId,at:a.at,note:c}}function b0(t){return t.refusal?{kind:"REFUSED",at:t.refusal.at,message:t.refusal.message}:null}function N0(){var me,Re;const t=mn(),{user:s,mode:a,domain:o}=vt(),[c,d]=f.useState(null),[h,y]=f.useState(null),[p,g]=f.useState(null),[v,w]=f.useState("per-action"),[j,N]=f.useState(1800),[E,S]=f.useState(86400),[C,T]=f.useState(""),[R,L]=f.useState("hours"),[P,F]=f.useState(""),[G,H]=f.useState(!0),[ie,Y]=f.useState(!1);f.useEffect(()=>{D.getIdentityDisclosure().then(de=>Y(de.always)).catch(()=>{})},[]);const[re,J]=f.useState(!1),[M,fe]=f.useState(""),[oe,Z]=f.useState(null),[pe,ee]=f.useState([]),[W,B]=f.useState(!1),[V,k]=f.useState([]),[A,K]=f.useState(0);f.useEffect(()=>{var jn;const de=sessionStorage.getItem("agentAuth"),Oe=sessionStorage.getItem("agentGate");if(!de||!Oe){t("/mandates?new=1");return}const Ge=JSON.parse(de),Ye=JSON.parse(Oe),ft={bounds:Ye.bounds??{},context:Ye.context??{},contextLabels:Ye.contextLabels??void 0,gateContent:Ye.gateContent};d(Ge),y(ft),Ye.ttlConfig&&(N(Ye.ttlConfig.default??1800),S(Ye.ttlConfig.max??86400)),Ye.templateMode==="automatic"?w("immediate"):Ye.templateMode==="review"&&w("per-action");const pn=((jn=Ye.ttlConfig)==null?void 0:jn.max)??86400;if(typeof Ye.templateTtl=="number"&&Ye.templateTtl>0){const tt=Math.min(Ye.templateTtl,pn);N(tt),[3600,86400,604800,2592e3,31536e3].includes(tt)||(tt%86400===0?(T(String(tt/86400)),L("days")):(T(String(Math.max(1,Math.round(tt/3600)))),L("hours")))}D.getProfile(Ge.profileId).then(tt=>{var bt;if(g(tt),!P){const Et=tt.name??((bt=Ge.profileId.split("/").pop())==null?void 0:bt.replace(/@.*$/,""))??"",wt=[];if(ft.context&&tt.scopeSchema)for(const je of tt.scopeSchema.keyOrder){const ge=ft.context[je];if(ge!==void 0&&ge!==""){const Me=String(ge).split(",").map(ze=>ze.trim()).filter(Boolean);wt.push(Me.join(", "))}}const ae=wt.length>0?`${Et}: ${wt.join(" · ")}`:Et;F(ae)}}).catch(()=>{}),Ge.isPersonal?B(!0):Promise.all([D.getTeamProfileConfig(Ge.groupId,Ge.profileId).catch(()=>null),D.getGroupById(Ge.groupId).catch(()=>null),D.listUsers().catch(()=>[])]).then(([tt,bt,Et])=>{if(Z(tt),tt){const wt=new Map;for(const ge of Et){const Me=ge.name&&ge.email?`${ge.name} (${ge.email})`:ge.name||ge.email||ge.id;wt.set(ge.id,Me)}const ae=(bt==null?void 0:bt.members)??[];for(const ge of ae){const Me=ge.userId??ge.id;Me&&(ge.name&&ge.email?wt.set(Me,`${ge.name} (${ge.email})`):ge.name&&wt.set(Me,ge.name))}const je=(tt.approvers??[]).map(ge=>wt.get(ge)??ge);ee(je)}}).finally(()=>{B(!0)})},[t]),f.useEffect(()=>{if(!(c!=null&&c.profileId))return;const de=c.profileId,Oe=sessionStorage.getItem("agentEditReplaces");D.getEnrichedAuthorizations().then(Ge=>{const Ye=Ge.filter(ft=>ft.profileId===de&&ft.authorizationId!==Oe).map(ft=>({authorizationId:ft.authorizationId,bounds:ft.bounds,context:ft.context??{},intent:ft.intent}));k(Ye)}).catch(()=>k([]))},[c==null?void 0:c.profileId]),f.useEffect(()=>{if(!p)return;const de=h0(v,Rf(p));de&&de!==v&&w(de)},[p,v]),f.useEffect(()=>{if(!h||!p||V.length===0){K(0);return}let de=!1;return(async()=>{const Oe=await vi(h.bounds,p),Ge=await Promise.all(V.map(Ye=>vi(Ye.bounds,p).catch(()=>null)));de||K(Ge.filter(Ye=>Ye===Oe).length)})().catch(()=>{de||K(0)}),()=>{de=!0}},[h,p,V]);const te=async()=>{if(!(!c||!h||!p||!s)){if(!c.groupId){fe("No active group; cannot create mandate.");return}J(!0),fe("");try{const de=o||c.domain||"owner",Oe=await vi(h.bounds,p),Ge=await Kh(h.context,p),[Ye,ft]=await Promise.all([bi(h.gateContent.intent),bi(JSON.stringify({profile:c.profileId,domain:de,group:c.groupId}))]);let pn,jn,tt,bt;if(c.isTeam){const ze=await D.getApproversPubkeys(c.groupId,c.profileId);if(ze.length>0){const Je=await D.encryptIntent(h.gateContent.intent,ze);pn=Je.intentCiphertext,jn=Je.encryptedKeys,tt=Je.approversFrozen,bt=Je.intentDisclosureHash}}const Et=`authz_${crypto.randomUUID()}`,wt=sessionStorage.getItem("agentEditReplaces")||void 0,ae=sessionStorage.getItem("agentReplacesProposal")||void 0,je=await Yh(p),ge=await D.attest({authorization_id:Et,replaces:wt,profile_id:c.profileId,profile_hash:je,supported_versions:["0.7"],bounds:h.bounds,bounds_hash:Oe,scope_hash:Ge,domain:de,did:s.did,mandate_owners:[{did:s.did}],gate_content_hashes:{intent:Ye},execution_context_hash:ft,group_id:c.groupId,ttl:j,commitment_mode:f0(v),title:P.trim(),intent_ciphertext:pn,encrypted_keys:jn,approvers_frozen:tt,intent_disclosure_hash:bt,disclose_identity:G});try{await D.pushGateContent(Jh(ge,{boundsHash:Oe,contextHash:Ge,context:h.context,contextLabels:h.contextLabels,gateContent:h.gateContent}))}catch(ze){try{await D.revokeAttestation(Et,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${ze instanceof Error?ze.message:"Unknown error"})`)}if(wt)try{await D.revokeAttestation(wt,`Replaced by ${Et} (edit)`),D.resyncGates().catch(()=>{})}catch{}let Me="";if(ae)try{const ze=await D.getProposal(ae);if(ze.status==="pending"){const Je=j0(ze,(s==null?void 0:s.id)??"");Je?Je.route==="approver"?await D.rejectProposal(ae,Af()):await D.resolveProposal(ae,"reject",Je.domain,Af()):Me="you are not one of the people who may decide it"}}catch(ze){Me=ze instanceof Error?ze.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),Me){fe(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${Me}) — reject it under Approvals.`);return}t(`/mandates?highlight=${encodeURIComponent(Et)}`)}catch(de){fe(de instanceof Error?de.message:"Signing the mandate failed")}finally{J(!1)}}};if(!c||!h)return r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const ue=Object.entries(h.bounds).filter(([de])=>de!=="profile"&&de!=="path"),ve=Object.entries(h.context),ke=((oe==null?void 0:oe.caps)!=null?Object.keys(oe.caps):[]).length!==0,se=pe.length>0?pe.join(", "):((oe==null?void 0:oe.approvers)??[]).join(", "),Le=ke?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${se}, 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.",Ee=ke?`Over-cap actions will be reviewed by you and ${se}. Within-cap actions run per the mode you chose above.`:`Approvers ${se} can read your intent but won't gate any action — no caps configured on this profile.`,_e=!!((me=oe==null?void 0:oe.approvers)!=null&&me.length),he=Qh({isPersonal:c.isPersonal,configLoaded:W,approvers:oe==null?void 0:oe.approvers,userId:s==null?void 0:s.id,profileName:dt(c.profileId),teamName:c.groupName}),X=!he.can,we=Rf(p),Te=we.length===0,$e=j>E,lt={flex:1,padding:"0.75rem",border:v==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:v==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},xt={flex:1,padding:"0.75rem",border:v==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:v==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Ke=((Re=p==null?void 0:p.scopeSchema)==null?void 0:Re.keyOrder)??[],et=V.filter(de=>p0(Ke,h.context,de.context)),st=et.length>0,mt=dt(c.profileId),Fe=de=>{const Oe=Object.values(de).map(Ge=>String(Ge).trim()).filter(Boolean);return Oe.length>0?Oe.join(", "):"all (unscoped)"},$=et.map(de=>Fe(de.context)).join("; "),le=`This grant's scope overlaps an existing grant on ${mt} (scoped to: ${$}). 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 r.jsxs(r.Fragment,{children:[r.jsx(Wh,{currentStep:4,onStepClick:de=>{de<=3&&t(`/mandates/new/intent?step=${de}`)}}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),c.upgradedFromProfileId&&p&&r.jsxs("div",{className:"hint-box",role:"note",style:{marginBottom:"1rem"},children:[r.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),r.jsxs("div",{className:"hint-body",children:["Updated to ",dt(c.profileId)," ",p.version," — the current version of this profile."]})]}),M&&r.jsx("div",{className:"error-message",children:M}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Title"]}),r.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${dt(c.profileId)}: daily operations`,value:P,onChange:de=>F(de.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),r.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[we.includes("per-action")&&r.jsxs("button",{onClick:()=>w("per-action"),style:xt,children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),we.includes("immediate")&&r.jsxs("button",{onClick:()=>w("immediate"),style:lt,children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]}),we.length===1&&r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:we[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Te&&r.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."})]}),r.jsxs("div",{className:"field-editable",children:[r.jsxs("div",{className:"field-label",children:[r.jsx("span",{className:"pen",children:"✎"})," Duration"]}),r.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(de=>de.seconds<=E).map(de=>r.jsx("button",{onClick:()=>{N(de.seconds),T("")},style:{padding:"0.5rem 0.85rem",border:j===de.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:j===de.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:de.label},de.seconds)),r.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[r.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:C,onChange:de=>{T(de.target.value);const Oe=parseInt(de.target.value,10);if(Oe>0){const Ge=R==="days"?Oe*86400:Oe*3600;N(Math.min(Ge,E))}}}),r.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:R,onChange:de=>{L(de.target.value);const Oe=parseInt(C,10);if(Oe>0){const Ge=de.target.value==="days"?Oe*86400:Oe*3600;N(Math.min(Ge,E))}},children:[r.jsx("option",{value:"hours",children:"hours"}),r.jsx("option",{value:"days",children:"days"})]})]}),$e&&r.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",E>=86400?`${Math.floor(E/86400)} days`:`${Math.floor(E/3600)} hours`]})]})]}),r.jsx("div",{className:"field-editable",children:r.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[r.jsx("input",{type:"checkbox",checked:ie||G,disabled:ie,onChange:de=>H(de.target.checked),style:{marginTop:"0.15rem"}}),r.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",r.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.',ie&&" Always on — you chose this in Settings."]})]})]})}),r.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),r.jsxs("div",{className:"info-block",children:[r.jsxs("div",{className:"info-head",children:[r.jsx("span",{className:"info-title",children:"Intent"}),r.jsx("button",{className:"info-edit",onClick:()=>t("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),r.jsx("div",{style:{whiteSpace:"pre-wrap"},children:h.gateContent.intent})]}),(!!ue.length||!!ve.length)&&r.jsxs("div",{className:"info-block",children:[r.jsxs("div",{className:"info-head",children:[r.jsx("span",{className:"info-title",children:"Scope & Limits"}),r.jsx("button",{className:"info-edit",onClick:()=>t("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),r.jsxs("dl",{className:"info-kv",children:[ve.map(([de,Oe])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:de}),r.jsx("dd",{children:qh(de,Oe,h.contextLabels)})]},de)),ue.map(([de,Oe])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:de}),r.jsx("dd",{children:String(Oe)})]},de))]})]}),r.jsxs("div",{className:"info-block",children:[r.jsx("div",{className:"info-head",children:r.jsx("span",{className:"info-title",children:"Authority"})}),r.jsxs("dl",{className:"info-kv",children:[r.jsx("dt",{children:"Profile"}),r.jsxs("dd",{children:[dt(c.profileId),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:c.profileId})]}),!c.isPersonal&&c.groupName&&r.jsxs(r.Fragment,{children:[r.jsx("dt",{children:"Team"}),r.jsx("dd",{children:c.groupName})]}),!c.isPersonal&&r.jsxs(r.Fragment,{children:[r.jsx("dt",{children:"Approvers"}),r.jsx("dd",{children:W?he.can?r.jsxs(r.Fragment,{children:[se,r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:Le})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{color:"var(--danger)",fontWeight:600},children:he.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${c.groupName??"this team"}`:"You cannot give this mandate"}),he.code==="OWNER_NOT_APPROVER"&&r.jsx("div",{children:se}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[he.reason," ",he.fix]})]}):r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),A>0?r.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:[r.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),r.jsxs("div",{children:[A===1?`An active grant on ${mt} already has exactly these limits.`:`${A} active grants on ${mt} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",r.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,st?r.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:[r.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),r.jsx("div",{children:le})]})]}):null,r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:()=>t("/mandates/new/intent"),children:"Back"}),r.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:te,disabled:re||!P.trim()||X||Te,children:re?"Signing...":v==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),r.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:_e?"block":"none"},children:Ee})]})]})}const C0={card:"💳",mail:"✉️"};function Zh(t){return C0[t]??"🔧"}function E0(t){const s=t==null?void 0:t.overrides;return!s||typeof s!="object"?!1:Object.values(s).some(a=>{var o;return typeof((o=a==null?void 0:a.read)==null?void 0:o.ageField)=="string"})}const T0=[0,7,30,90,365,3650];function fi(t){return t===null?"From your mandate":t===0?"Read nothing":t===1?"1 day back":t===365?"1 year back":t%365===0?`${t/365} years back`:`${t} days back`}function R0(t){return(t==null?void 0:t.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:t&&!t.running&&t.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function Rl({manifest:t,integration:s,state:a,onStatusChange:o,onSuccess:c}){var Fe;const[d,h]=f.useState({}),[y,p]=f.useState(!1),[g,v]=f.useState(!1),[w,j]=f.useState({}),[N,E]=f.useState({}),[S,C]=f.useState(void 0),[T,R]=f.useState(!1),[L,P]=f.useState(null),[F,G]=f.useState(!1),[H,ie]=f.useState(!1),[Y,re]=f.useState(!1),[J,M]=f.useState(!1),[fe,oe]=f.useState({}),[Z,pe]=f.useState(null),[ee,W]=f.useState(!1),[B,V]=f.useState(null),[k,A]=f.useState(!1);f.useEffect(()=>{let $=!1;return D.getCredential(t.id).then(le=>{var me;if(!($||!le.configured)){if(p(!0),v(!0),le.fields){const Re={};for(const de of t.credentials.fields)le.fields[de.key]!=null&&(Re[de.key]=le.fields[de.key]);j(Re)}if(E(le.secrets??{}),C(le.updatedAt),t.oauth){const Re=((me=le.fieldNames)==null?void 0:me.includes(t.oauth.tokenStorage))??!1;R(Re),Re&&D.getOAuthHealth(t.id).then(de=>{$||P(de)})}}}).catch(()=>{}),()=>{$=!0}},[t.id,t.oauth]);const K=E0(t.toolGating),te=s?s.readAgeDays??null:void 0,ue=ee&&Z?Z.value:te,ve=async $=>{pe({value:$}),W(!0),V(null);try{await D.setReadPolicy(t.id,$),c($===null?`${t.name} read window now follows your mandate`:`${t.name} read window set to ${fi($).toLowerCase()}`),o()}catch(le){V(le instanceof Error?le.message:"Could not save")}finally{W(!1),pe(null)}},Ce=!!t.oauth||t.credentials.fields.some($=>!$.optional),ke=t.oauth?T:y,se=!Ce||ke,Le=a==="starting"?"starting":se?s!=null&&s.running?"running":!y&&t.credentials.fields.length>0?"unconfigured":"ready":t.oauth&&y&&!T?"needs-oauth":"unconfigured",Ee=async()=>{if(t.credentials.fields.some(le=>{var me;return(me=d[le.key])==null?void 0:me.trim()})){G(!0);try{await D.setCredential(t.id,d),p(!0),h({}),t.oauth?c(`${t.name} credentials saved!`):(c(`${t.name} credentials saved — starting integration...`),await Te())}catch{c(`Failed to save ${t.name} credentials`)}finally{G(!1)}}},_e=()=>{const $={};for(const le of t.credentials.fields){const me=d[le.key];le.type==="password"?me!=null&&me.trim()&&($[le.key]=me):me!=null&&me!==(w[le.key]??"")&&($[le.key]=me)}return $},he=Object.keys(_e()).length>0,X=async()=>{const $=_e();if(Object.keys($).length!==0){G(!0);try{await D.setCredential(t.id,$),h({}),p(!0),t.oauth?c(`${t.name} credentials saved — now click Connect.`):(M(!1),c(`${t.name} credentials updated — restarting...`),await Te())}catch{c(`Failed to update ${t.name} credentials`)}finally{G(!1)}}},we=()=>{window.open(`/auth/oauth/${t.id}/start`,"_blank","width=600,height=700");const $=setInterval(async()=>{var le;try{const me=await D.getCredential(t.id);me.configured&&t.oauth&&((le=me.fieldNames)!=null&&le.includes(t.oauth.tokenStorage))&&(R(!0),M(!1),P(null),clearInterval($),c(`${t.name} connected — starting integration...`),D.getOAuthHealth(t.id).then(P).catch(()=>{}),await Te())}catch{}},2e3);setTimeout(()=>clearInterval($),12e4)},Te=async()=>{re(!0);try{const $=await D.activateIntegration(t.id);$.warning?c($.warning):c(`${t.name} integration started with ${$.tools.length} tools`),o()}catch($){c(`Failed to start ${t.name}: ${$ instanceof Error?$.message:"Unknown error"}`)}finally{re(!1)}},$e=async()=>{try{await D.removeMcpIntegration(t.id),c(`${t.name} integration removed`),o()}catch{c(`Failed to remove ${t.name}`)}},lt=Zh(t.icon),xt=R0(s),Ke=Le==="running"?{c:"int-chip-ok",t:"Running"}:Le==="starting"?{c:"int-chip-idle",t:"Starting"}:xt.chip,et=t.oauth&&T&&(L==null?void 0:L.status)==="failed",st=Ce?et?{c:"int-chip-bad",t:"Auth failed"}:ke?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},mt=$=>$.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${t.id}/callback`);return r.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[r.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:lt}),r.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:t.name}),r.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[Le!=="unconfigured"&&Le!=="needs-oauth"&&r.jsxs("span",{className:`int-chip ${Ke.c}`,children:[r.jsx("span",{className:"int-dot"}),Ke.t]}),r.jsxs("span",{className:`int-chip ${st.c}`,children:[r.jsx("span",{className:"int-dot"}),st.t]}),Sv(t,w)&&r.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:[r.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),t.oauth&&T&&r.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:L!=null&&L.account?r.jsxs(r.Fragment,{children:["Connected as ",r.jsx("b",{children:L.account})]}):r.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),et&&!J&&r.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:[r.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[t.name," stopped accepting the stored credentials"]}),r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[(L==null?void 0:L.error)==="invalid_grant"?r.jsxs(r.Fragment,{children:["The refresh token was revoked (",r.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):L!=null&&L.error?r.jsxs(r.Fragment,{children:["The provider reported ",r.jsx("code",{children:L.error}),"."]}):r.jsx(r.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",t.name," actions are ",r.jsx("b",{children:"blocked"}),", not failing silently."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[r.jsxs("button",{className:"btn btn-primary btn-sm",onClick:we,children:["Reconnect ",t.name]}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{h({...w}),M(!0)},children:"Edit credentials"})]})]}),r.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[r.jsx("summary",{children:"Details"}),r.jsxs("div",{className:"int-meta",children:[r.jsx("span",{className:"int-k",children:"What"}),r.jsx("span",{children:t.description}),t.profile&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Profile"}),r.jsx("span",{children:t.profile})]}),t.oauth&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Scopes"}),r.jsx("span",{children:((Fe=t.oauth.scopes)==null?void 0:Fe.join(", "))||"—"})]}),s&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Tools"}),r.jsxs("span",{children:[s.toolCount," gated"]})]})]})]}),t.setupGuide&&t.setupGuide.length>0&&(Le!=="running"||et)&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsxs("button",{onClick:()=>ie(!H),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[r.jsx("span",{style:{transition:"transform 0.2s",transform:H?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",t.name]}),H&&r.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:t.setupGuide.map(($,le)=>r.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[r.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:le+1}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:$.title}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[mt($.description),$.link&&r.jsxs(r.Fragment,{children:[" ",r.jsxs("a",{href:$.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},le))})]}),Le==="starting"&&r.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[r.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),J&&r.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[r.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),g&&r.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.",t.oauth?" Save, then Connect to re-link the account.":""]}),t.credentials.fields.map($=>{var le;return r.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[r.jsx("label",{className:"form-label",children:$.label}),$.type==="password"?r.jsxs("div",{className:"cred-field",children:[r.jsx("input",{className:"form-input",type:fe[$.key]?"text":"password",name:`${t.id}-${$.key}-credential`,autoComplete:"new-password",placeholder:(le=N[$.key])!=null&&le.preview?`Unchanged — ends in ${N[$.key].preview}`:g?"Unchanged — paste a new value to replace":$.placeholder,value:d[$.key]||"",onChange:me=>h(Re=>({...Re,[$.key]:me.target.value}))}),r.jsx("button",{className:"cred-toggle",onClick:()=>oe(me=>({...me,[$.key]:!me[$.key]})),children:fe[$.key]?"hide":"show"})]}):r.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${$.key}-credential`,autoComplete:"off",placeholder:$.placeholder,value:d[$.key]||"",onChange:me=>h(Re=>({...Re,[$.key]:me.target.value}))})]},$.key)}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:X,disabled:F||!he,children:F?"Saving…":"Save"}),!he&&!F&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),t.oauth&&r.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:we,children:["Connect ",t.name]}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{M(!1),h({})},children:"Cancel"})]})]}),!J&&Le==="running"&&s&&r.jsxs(r.Fragment,{children:[(Object.keys(w).length>0||Object.keys(N).length>0)&&r.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:t.credentials.fields.map($=>{const le=$.type==="password",me=N[$.key];return!le&&w[$.key]==null||le&&me==null?null:r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[r.jsx("span",{style:{color:"var(--text-muted)"},children:$.label}),r.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[le?me.preview??"set":w[$.key],le&&S&&r.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(S).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},$.key)})}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx(yt,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(t.credentials.fields.length>0||t.oauth)&&r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{h({...w}),M(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),r.jsx("span",{style:{flex:1}}),r.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:$e,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&&ue!==void 0&&!k&&r.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[r.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),r.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:ue===null?"window from your mandate":fi(ue).toLowerCase()}),ee&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),B&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:B})]}),r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>A(!0),children:"Edit"})]})}),K&&ue!==void 0&&k&&r.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[r.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),r.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>A(!1),children:"Done"})]}),r.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new mandate."}),r.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[T0.map($=>{const le=ue===$;return r.jsx("button",{className:`btn btn-sm ${le?"btn-primary":"btn-secondary"}`,"aria-pressed":le,disabled:ee,onClick:()=>ve($),children:fi($)},$)}),r.jsx("button",{className:`btn btn-sm ${ue===null?"btn-primary":"btn-ghost"}`,"aria-pressed":ue===null,disabled:ee,onClick:()=>ve(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:fi(null)})]}),r.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:B?r.jsx("span",{style:{color:"var(--danger)"},children:B}):ee?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):ue===null?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):ue===0?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):r.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",ue," days is blocked, whoever it is from."]})})]}),r.jsx("div",{style:{display:"none"},children:r.jsx(yt,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),Le==="unconfigured"&&(()=>{const $=t.credentials.fields.every(Re=>Re.optional),le=t.credentials.fields.some(Re=>!Re.optional),me=t.credentials.fields.some(Re=>{var de;return(de=d[Re.key])==null?void 0:de.trim()});return r.jsxs(r.Fragment,{children:[g&&r.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:[r.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"," ",r.jsx("button",{onClick:()=>{p(!0),t.oauth&&R(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),t.oauth&&!g&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),t.setupHint&&!g&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:t.setupHint}),t.credentials.fields.map(Re=>r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsx("label",{className:"form-label",children:Re.label}),Re.type==="password"?r.jsxs("div",{className:"cred-field",children:[r.jsx("input",{className:"form-input",type:fe[Re.key]?"text":"password",name:`${t.id}-${Re.key}-credential`,autoComplete:"new-password",placeholder:Re.placeholder,value:d[Re.key]||"",onChange:de=>h(Oe=>({...Oe,[Re.key]:de.target.value}))}),r.jsx("button",{className:"cred-toggle",onClick:()=>oe(de=>({...de,[Re.key]:!de[Re.key]})),children:fe[Re.key]?"hide":"show"})]}):r.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${Re.key}-credential`,autoComplete:"off",placeholder:Re.placeholder,value:d[Re.key]||"",onChange:de=>h(Oe=>({...Oe,[Re.key]:de.target.value}))})]},Re.key)),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[me&&r.jsx("button",{className:"btn btn-primary",onClick:Ee,disabled:F||le&&!t.credentials.fields.filter(Re=>!Re.optional).every(Re=>{var de;return(de=d[Re.key])==null?void 0:de.trim()}),children:F?"Saving...":"Save & Encrypt"}),$&&!me&&r.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:Y,children:Y?"Starting...":`Activate ${t.name}`})]})]})})(),Le==="needs-oauth"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",t.name," account to authorize access."]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[r.jsxs("button",{className:"btn btn-primary",onClick:we,children:["Connect ",t.name," Account"]}),r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Change Credentials"})]})]}),Le==="ready"&&!s&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",t.oauth?`${t.name} account connected`:"Credentials configured"]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[r.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:Y,children:Y?"Starting...":`Start ${t.name} Integration`}),!t.oauth&&r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Update Credentials"}),t.oauth&&r.jsx("button",{className:"btn btn-ghost",onClick:()=>{p(!1),R(!1)},children:"Change Credentials"})]})]}),Le==="ready"&&s&&!s.running&&(xt.showStart?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[r.jsx("span",{className:"service-status-dot"}),"Not running"]}),s.error&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:s.error}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:Y,children:Y?"Starting...":"Start"}),r.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:$e,children:"Disable"})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"service-status",style:{marginBottom:"0.5rem",color:"var(--text-muted)"},children:[r.jsx("span",{className:"service-status-dot",style:{background:"var(--text-muted)"}}),"Paused"]}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.75rem"},children:"Real systems are off while simulation mode is on."}),r.jsx("div",{style:{display:"flex",gap:"0.5rem"},children:r.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:$e,children:"Disable"})})]}))]})}function I0(t,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:t};const a=t.filter(h=>Ks(h.manifest)),o=t.filter(h=>!Ks(h.manifest)),c=o.filter(h=>h.state==="error"),d=o.filter(h=>h.state!=="error");return{grouped:!0,testSystems:a,realErrors:c,pausedReal:d,ungrouped:[]}}function A0({entry:t}){return r.jsxs("div",{className:"int-paused-row",children:[r.jsx("span",{"aria-hidden":"true",children:Zh(t.manifest.icon)}),r.jsx("span",{className:"int-paused-name",children:t.manifest.name}),r.jsxs("span",{className:"int-chip int-chip-paused",children:[r.jsx("span",{className:"int-dot"}),"Paused"]})]})}function P0(){const{loading:t,mcpServerUp:s,manifestsError:a,entries:o,refresh:c}=cc(),d=lc(),[h,y]=f.useState(""),p=f.useCallback(v=>{y(v),setTimeout(()=>y(""),5e3)},[]),g=I0(o,d);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Integrations"}),r.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),h&&r.jsx("div",{className:"alert alert-success",children:h}),t?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):s===!1?r.jsxs("div",{className:"status-banner status-banner-error",children:[r.jsx("span",{className:"status-banner-icon",children:"!"}),r.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):g.grouped?r.jsxs(r.Fragment,{children:[g.testSystems.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"int-group-label",children:"Test systems"}),g.testSystems.map(v=>r.jsx(Rl,{manifest:v.manifest,integration:v.integration,state:v.state,onStatusChange:c,onSuccess:p},v.id))]}),(g.realErrors.length>0||g.pausedReal.length>0)&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"int-group-label",children:"Real systems"}),g.realErrors.map(v=>r.jsx(Rl,{manifest:v.manifest,integration:v.integration,state:v.state,onStatusChange:c,onSuccess:p},v.id)),g.pausedReal.length>0&&r.jsxs("details",{className:"int-paused-group",open:!0,children:[r.jsxs("summary",{children:["Paused while simulation mode is on (",g.pausedReal.length,")"]}),r.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 (",r.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),g.pausedReal.map(v=>r.jsx(A0,{entry:v},v.id))]})]}),o.length===0&&r.jsx(Pf,{manifestsError:a})]}):r.jsxs(r.Fragment,{children:[o.map(v=>r.jsx(Rl,{manifest:v.manifest,integration:v.integration,state:v.state,onStatusChange:c,onSuccess:p},v.id)),o.length===0&&r.jsx(Pf,{manifestsError:a})]})]})}function Pf({manifestsError:t}){return t?r.jsxs("div",{className:"status-banner status-banner-error",children:[r.jsx("span",{className:"status-banner-icon",children:"!"}),r.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"," ",r.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):r.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function _0(){var M,fe,oe;const{activeTeam:t,activeMembership:s,refreshGroups:a,user:o}=vt(),c=mn(),[d,h]=f.useState(null),[y,p]=f.useState(!1),[g,v]=f.useState(""),[w,j]=f.useState(""),[N,E]=f.useState(!1),[S,C]=f.useState(""),[T,R]=f.useState("");f.useEffect(()=>{fetch("/health").then(Z=>Z.json()).then(Z=>{typeof Z.spUrl=="string"&&R(Z.spUrl)}).catch(()=>{})},[]),f.useEffect(()=>{if(!t){h(null);return}D.getGroupById(t.id).then(Z=>{const pe=Z.group??Z,ee=Z.members??[],W=Z.isAdmin??!1,B=ee.map(V=>{const k=V.userId||V.id||"",A=V.role||(W&&k===pe.createdBy?"admin":"member");return{id:k,name:V.name||k.slice(0,8)||"Member",email:V.email||"",domains:V.domains||[],role:A,isAdmin:A==="admin"||W&&k===pe.createdBy}});h({id:pe.id,name:pe.name,members:B})}).catch(()=>h(null))},[t==null?void 0:t.id]);const L=(d==null?void 0:d.members.filter(Z=>Z.isAdmin))??[],P=(t==null?void 0:t.isAdmin)===!0&&L.length<=1&&L.some(Z=>Z.id===(o==null?void 0:o.id)),F=(t==null?void 0:t.name)??"",G=S.trim()===F&&!y,H=()=>{C(""),E(!0)},ie=()=>{E(!1),C("")},Y=async()=>{if(!(!t||!G)){p(!0),v("");try{await D.leaveTeam(t.id),await a(),j("You have left the team."),h(null),ie()}catch(Z){v(Z instanceof Error?Z.message:"Failed to leave team")}finally{p(!1)}}},re=t&&T?`${T}/dashboard/groups/${t.id}`:void 0,J=T?`${T}/dashboard/groups`:void 0;return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"page-header",children:r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Team"}),r.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),g&&r.jsx("div",{className:"error-message",children:g}),w&&r.jsx("div",{className:"alert alert-success",children:w}),t?r.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[r.jsxs("div",{className:"card-header",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"card-title",children:t.name}),r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((M=d==null?void 0:d.members)==null?void 0:M.length)??0," ",(((fe=d==null?void 0:d.members)==null?void 0:fe.length)??0)===1?"member":"members",t.isAdmin&&" · You are admin"]})]}),r.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(oe=d==null?void 0:d.members)==null?void 0:oe.map(Z=>r.jsxs("div",{className:"member-row",children:[r.jsx("div",{className:"member-avatar",children:Z.name.split(" ").map(pe=>pe[0]).join("").slice(0,2).toUpperCase()}),r.jsxs("div",{className:"member-info",children:[r.jsx("div",{className:"member-name",children:Z.name}),r.jsx("div",{className:"member-email",children:Z.email})]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Z.role})]},Z.id)),r.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[re&&r.jsx("a",{className:"btn btn-secondary btn-sm",href:re,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),r.jsx("span",{title:P?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:r.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:H,disabled:y||P,children:"Leave team"})})]})]}):r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[r.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),r.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."}),r.jsxs("div",{style:{display:"flex",gap:"0.75rem",justifyContent:"center",flexWrap:"wrap"},children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>c("/onboarding"),children:"Join or create a team"}),J&&r.jsx("a",{className:"btn btn-ghost btn-sm",href:J,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),N&&t&&r.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:ie,children:r.jsxs("div",{className:"card",onClick:Z=>Z.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[r.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",F,"?"]}),r.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),r.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[r.jsx("li",{children:"Revoke all mandates you created in this team's context"}),r.jsx("li",{children:"Reject any pending action proposals you authored"}),r.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),r.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",r.jsx("strong",{children:"personal"})," mandates are not affected."]}),r.jsxs("div",{className:"form-group",children:[r.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",r.jsx("code",{children:F})," to confirm:"]}),r.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:S,onChange:Z=>C(Z.target.value),placeholder:F,disabled:y,autoFocus:!0})]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:ie,disabled:y,children:"Cancel"}),r.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:Y,disabled:!G,children:y?"Leaving...":"Leave team"})]})]})})]})}const $0=new Set(["mail","users","receipt","credit-card","calendar","megaphone","archive","rocket","flask","shopping-cart","bar-chart","help-circle"]),L0={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 z0(t){const s=t.lastIndexOf("/"),a=s>=0?t.slice(s+1):t,o=a.indexOf("@");return(o>=0?a.slice(0,o):a).toLowerCase()}function Nr(t,s){const a=z0(t),o=s!=null&&s.icon&&$0.has(s.icon)?s.icon:L0[a]??"help-circle",c=dt(t,s==null?void 0:s.name);return{icon:o,name:c,testSetup:a==="delegation"}}function $i(t){return t.startsWith("setup__")}const F0={mail:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),r.jsx("path",{d:"m3 7 9 6 9-6"})]}),users:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),r.jsx("path",{d:"M3.5 20c0-3.6 2.5-6.3 5.5-6.3s5.5 2.7 5.5 6.3"}),r.jsx("circle",{cx:"17.2",cy:"9.2",r:"2.3"}),r.jsx("path",{d:"M16.8 13.9c2.4.5 4.2 2.6 4.2 5.4"})]}),receipt:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M6 3h12v18l-2.2-1.4L14 21l-2-1.4L10 21l-2-1.4L6 21V3Z"}),r.jsx("line",{x1:"9",y1:"7.5",x2:"15",y2:"7.5"}),r.jsx("line",{x1:"9",y1:"11.5",x2:"15",y2:"11.5"}),r.jsx("line",{x1:"9",y1:"15.5",x2:"13",y2:"15.5"})]}),"credit-card":r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2.2"}),r.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"}),r.jsx("line",{x1:"5.5",y1:"15",x2:"9.5",y2:"15"})]}),calendar:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"4.5",width:"18",height:"16.5",rx:"2"}),r.jsx("line",{x1:"3",y1:"9.5",x2:"21",y2:"9.5"}),r.jsx("line",{x1:"8",y1:"2.5",x2:"8",y2:"6.5"}),r.jsx("line",{x1:"16",y1:"2.5",x2:"16",y2:"6.5"})]}),megaphone:r.jsxs(r.Fragment,{children:[r.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"}),r.jsx("path",{d:"M14.5 8.3a4.3 4.3 0 0 1 0 7.4"}),r.jsx("path",{d:"M17.6 6a7.6 7.6 0 0 1 0 12"})]}),archive:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"3.5",width:"18",height:"5",rx:"1.2"}),r.jsx("path",{d:"M5 8.5V18a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5"}),r.jsx("line",{x1:"10",y1:"13",x2:"14",y2:"13"})]}),rocket:r.jsxs(r.Fragment,{children:[r.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"}),r.jsx("path",{d:"M9 14.7 6.3 19.4l3.8-1.7"}),r.jsx("path",{d:"M15 14.7l2.7 4.7-3.8-1.7"}),r.jsx("circle",{cx:"12",cy:"9.3",r:"1.3"})]}),flask:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M9 3h6"}),r.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"}),r.jsx("line",{x1:"8.3",y1:"14.5",x2:"15.7",y2:"14.5"})]}),"shopping-cart":r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9",cy:"20",r:"1.4"}),r.jsx("circle",{cx:"18",cy:"20",r:"1.4"}),r.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":r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"4",y1:"20.5",x2:"20",y2:"20.5"}),r.jsx("rect",{x:"6",y:"13",width:"3.2",height:"7.5"}),r.jsx("rect",{x:"11.4",y:"8.5",width:"3.2",height:"12"}),r.jsx("rect",{x:"16.8",y:"4",width:"3.2",height:"16.5"})]}),"help-circle":r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),r.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"}),r.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function em({icon:t,className:s}){return r.jsx("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:F0[t]})}function Zs({profileId:t,declared:s}){const{icon:a,name:o}=Nr(t,s);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"id-rail",children:[r.jsx(em,{icon:a,className:"id-rail-icon"}),r.jsx("span",{className:"id-rail-name",children:o})]}),r.jsx("div",{className:"id-sep"})]})}const Js=t=>t.replace(/@.*$/,"").split("/").pop()??t,_f=t=>t.split("@")[1]??"";function O0(t,s){const a=new Map;for(const o of t){const c=Js(o.id);if(!s.has(c))continue;const d=a.get(c);(!d||_f(o.id).localeCompare(_f(d.id),void 0,{numeric:!0})>0)&&a.set(c,o)}return a}function M0(t,s,a,o){var y;const c=new Set([...s.filter(p=>p.profile).map(p=>p.profile),...o.map(p=>Js(p.profile))]),d=O0(t,c),h=[];for(const p of s){const g=p.profile?d.get(p.profile):void 0;g&&h.push({key:`connector:${p.id}`,name:p.name,description:p.description||g.description,profile:g,kind:"connector",ready:((y=a.find(v=>v.id===p.id))==null?void 0:y.running)===!0,setupId:p.id,...p.intentHint?{intentHint:p.intentHint}:{}})}for(const p of o){const g=d.get(Js(p.profile));g&&h.push({key:`builtin:${p.id}`,name:p.name,description:p.description||g.description,profile:g,kind:"builtin",ready:p.available,unavailableReason:p.available?void 0:"Available only while simulation mode is on.",...p.intentHint?{intentHint:p.intentHint}:{}})}return h}function B0(t,s,a){if(s)return t.find(o=>Js(o.profile.id)===Js(s)&&o.ready&&a(o))}function D0({onDismiss:t,preselectProfileId:s}){const a=mn(),{group:o,groupId:c,domain:d,user:h}=vt(),[y,p]=f.useState([]),[g,v]=f.useState([]),[w,j]=f.useState([]),[N,E]=f.useState([]),[S,C]=f.useState(!0),[T,R]=f.useState({});f.useEffect(()=>{Promise.all([D.listProfiles().catch(()=>[]),D.getIntegrationManifests().then(Y=>Y.manifests??[]).catch(()=>[]),D.getMcpHealth().catch(()=>null)]).then(async([Y,re,J])=>{if(p(Y),v(re),j((J==null?void 0:J.integrations)??[]),E((J==null?void 0:J.builtins)??[]),c){const M=await Promise.all(Y.map(oe=>D.getTeamProfileConfig(c,oe.id).catch(()=>null))),fe={};Y.forEach((oe,Z)=>{const pe=M[Z];pe&&(fe[oe.id]=pe)}),R(fe)}}).finally(()=>C(!1))},[c]);const L=M0(y,g,w,N),P=Y=>{var re;return Qh({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!S,approvers:(re=T[Y.id])==null?void 0:re.approvers,userId:h==null?void 0:h.id,profileName:dt(Y.id),teamName:o==null?void 0:o.name})},F=Y=>Y in T,G=(Y,re)=>{if(!c){console.error("No active group when creating authorization");return}const J=F(Y);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Y,groupId:c,groupName:(o==null?void 0:o.name)??null,domain:d,isTeam:J,isPersonal:!!(o!=null&&o.isPersonal),...re?{intentHint:re}:{}})),sessionStorage.removeItem("agentGate"),t==null||t(),a("/mandates/new/intent")},H=(Y,re)=>{c&&G(Y,re)},ie=f.useRef(!1);return f.useEffect(()=>{if(S||!s||ie.current)return;const Y=B0(L,s,re=>P(re.profile).can);Y&&(ie.current=!0,H(Y.profile.id,Y.intentHint))},[S,s]),r.jsxs(r.Fragment,{children:[r.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
+ `}),S?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):L.length===0?r.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[r.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),r.jsx(yt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>t==null?void 0:t(),children:"Go to Integrations"})]}):r.jsx("div",{className:"profile-grid",children:L.map(Y=>{const re=Y.profile,J=F(re.id),M=P(re),fe=!Y.ready||!M.can,{icon:oe}=Nr(re.id,{name:re.name,icon:re.icon});return r.jsxs("div",{className:"card",style:fe?{opacity:.7}:void 0,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[r.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[r.jsx(em,{icon:oe,className:"profile-chip-icon"}),Y.name]}),J?r.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"}):o!=null&&o.isPersonal?r.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]}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:Y.description}),M.can?Y.ready?r.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>H(re.id,Y.intentHint),children:"Give a mandate"}):Y.kind==="builtin"?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:Y.unavailableReason})]}):r.jsxs(yt,{to:`/integrations?setup=${Y.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>t==null?void 0:t(),children:["Set up ",Y.name]}):r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[M.reason," ",r.jsx("span",{style:{color:"var(--text-tertiary)"},children:M.fix})]})]})]},Y.key)})})]})}const U0={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function W0({status:t,label:s}){return r.jsx("span",{className:`status-badge status-${t}`,children:s||U0[t]})}function H0({domain:t,attested:s}){const a=s===!0?"domain-attested":s===!1?"domain-missing":"";return r.jsx("span",{className:`domain-badge ${a}`,style:{fontSize:"0.75rem"},children:t})}const xr=86400,Hs=3600,hi=60,V0=30*xr;function G0(t){if(t<=0)return"Expired";if(t>90*xr){const s=Math.floor(t/V0);return`${s} ${s===1?"month":"months"} remaining`}if(t>7*xr){const s=Math.floor(t/xr);return`${s} ${s===1?"day":"days"} remaining`}if(t>=2*xr){const s=Math.floor(t/xr),a=Math.floor(t%xr/Hs);return`${s} ${s===1?"day":"days"} ${a}h remaining`}if(t>=2*Hs){const s=Math.floor(t/Hs),a=Math.floor(t%Hs/hi);return`${s}h ${String(a).padStart(2,"0")}m remaining`}if(t>=hi){const s=Math.floor(t/hi),a=Math.floor(t%hi);return`${s}m ${String(a).padStart(2,"0")}s remaining`}return`${Math.floor(t)}s remaining`}function K0({expiresAt:t}){const[s,a]=f.useState(()=>t-Date.now()/1e3),o=s<2*Hs;f.useEffect(()=>{const d=setInterval(()=>a(t-Date.now()/1e3),o?1e3:6e4);return()=>clearInterval(d)},[t,o]);const c=s<300;return r.jsx("span",{className:`ttl-badge ${c?"ttl-warn":"ttl-ok"}`,children:G0(s)})}function Zr({icon:t,title:s,text:a,children:o}){return r.jsxs("div",{className:"empty-state",children:[t&&r.jsx("div",{className:"empty-state-icon",children:t}),r.jsx("div",{className:"empty-state-title",children:s}),a&&r.jsx("div",{className:"empty-state-text",children:a}),o]})}function Y0(t){const s=Math.floor(t/86400);if(s>=1)return`${s} day${s===1?"":"s"}`;const a=Math.floor(t/3600);if(a>=1)return`${a} hour${a===1?"":"s"}`;const o=Math.ceil(t/60);return`${o} minute${o===1?"":"s"}`}const J0=[{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 q0({item:t,onClose:s,onSuccess:a}){var L;const{user:o,activeDomain:c,groupId:d}=vt(),[h,y]=f.useState(null);f.useEffect(()=>{let P=!1;return D.getProfile(t.profile_id).then(F=>{var G;P||y(((G=F==null?void 0:F.ttl)==null?void 0:G.max)??null)}).catch(()=>{}),()=>{P=!0}},[t.profile_id]);const p=t.remaining_seconds??0,g=J0.filter(P=>P.seconds>p&&(h===null||P.seconds<=h)),v=((L=g[0])==null?void 0:L.seconds)??2592e3,[w,j]=f.useState(v);f.useEffect(()=>{var P;if(h!==null&&w>h){const F=(P=g[g.length-1])==null?void 0:P.seconds;F&&j(F)}},[h]);const[N,E]=f.useState(!1),[S,C]=f.useState(""),T=Object.entries(t.frame).filter(([P])=>P!=="profile"&&P!=="path"),R=async()=>{var P;if(o){E(!0),C("");try{const F=t.authorization_id,G=await D.getGateContent(F);if(!G)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const H=await D.getProfile(t.profile_id),ie=t.frame,Y=G.context??{},re=t.attested_domains[0]||c||"owner",J=await vi(ie,H),M=await Kh(Y,H),[fe,oe]=await Promise.all([bi(G.gateContent.intent),bi(JSON.stringify({profile:t.profile_id,path:t.path,domain:re}))]);if(!d)throw new Error("No active group; cannot extend mandate.");const Z=(((P=t.deferred_commitment_domains)==null?void 0:P.length)??0)>0?"review":"automatic",pe=await Yh(H),ee=await D.attest({authorization_id:t.authorization_id,renew:!0,profile_id:t.profile_id,profile_hash:pe,supported_versions:["0.7"],bounds:ie,bounds_hash:J,scope_hash:M,domain:re,did:o.did,mandate_owners:[{did:o.did}],gate_content_hashes:{intent:fe},execution_context_hash:oe,group_id:d,commitment_mode:Z,ttl:w});await D.pushGateContent(Jh(ee,{boundsHash:J,contextHash:M,context:Y,path:t.path,gateContent:G.gateContent})),a()}catch(F){C(F instanceof Error?F.message:"Extension failed")}finally{E(!1)}}};return r.jsx("div",{className:"modal-backdrop",onClick:P=>P.target===P.currentTarget&&s(),children:r.jsxs("div",{className:"modal",children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h3",{className:"modal-title",children:"Extend mandate"}),r.jsx("button",{className:"modal-close",onClick:s,children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[dt(t.profile_id)," / ",t.path]}),T.length>0&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:T.map(([P,F])=>`${P}=${F}`).join(" · ")})]}),r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),p>0&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",Y0(p),". Only longer durations are shown."]}),r.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:g.length===0?r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):g.map(P=>r.jsx("button",{className:`btn ${w===P.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>j(P.seconds),style:{minWidth:"3.5rem"},children:P.label},P.seconds))})]}),r.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)."}),S&&r.jsx("div",{className:"error-message",children:S})]}),r.jsxs("div",{className:"modal-footer",children:[r.jsx("button",{className:"btn btn-secondary",onClick:s,disabled:N,children:"Cancel"}),r.jsx("button",{className:"btn btn-primary",onClick:R,disabled:N,children:N?"Extending...":"Extend"})]})]})})}function $f(t){return t.replace(/@.*$/,"").split("/").pop()??t}function Lf(t){return t.split("@")[1]??""}function Q0(t,s){return Lf(t).localeCompare(Lf(s),void 0,{numeric:!0})>0}function tm(t,s){const a=$f(t);let o;for(const c of s)$f(c.id)===a&&(!o||Q0(c.id,o.id))&&(o=c);return o}function nm(t,s){var o;if(!s)return{};const a={};for(const c of s.keyOrder){if(c==="profile"||c==="path")continue;if(t[c]!==void 0){a[c]=t[c];continue}const d=(o=s.fields[c])==null?void 0:o.default;(typeof d=="string"||typeof d=="number"&&Number.isFinite(d))&&(a[c]=d)}return a}function rm(t,s){return nm(t,s.boundsSchema)}function sm(t,s){return nm(t,s.scopeSchema)}function X0(t,s,a){return[...t].sort((o,c)=>{if(a){if(o.authorization_id===a&&c.authorization_id!==a)return-1;if(c.authorization_id===a&&o.authorization_id!==a)return 1}const d=Si(o,s),h=Si(c,s),y={active:0,pending:1,expired:2,revoked:3,archived:4};return y[d]!==y[h]?y[d]-y[h]:new Date(c.created_at).getTime()-new Date(o.created_at).getTime()})}function Z0({item:t,newerProfile:s,revokedSet:a,expandedHash:o,gateCache:c,gateLoading:d,copiedHash:h,revokingHash:y,copyingHash:p,profileConfigCache:g,mode:v,ownerLabel:w,isAdmin:j,onExpand:N,onCopyHash:E,onCopy:S,onRevoke:C,onExtend:T,archivedSet:R,archivingHash:L,onArchive:P,highlightHash:F,needsReapprovalSet:G}){var Le;const H=oc(t,{revokedSet:a}),ie=H==="active"&&((G==null?void 0:G.has(t.authorization_id))??!1),Y=Th(t,{revokedSet:a,archivedSet:R}),re=!w&&!!P&&Eh(H),J=o===t.authorization_id,M=c[t.authorization_id],fe=H==="active"||H==="pending"||H==="expired",oe=Object.entries(t.frame).filter(([Ee])=>Ee!=="profile"&&Ee!=="path"),Z=g.get(t.profile_id)??null,pe=(((Le=Z==null?void 0:Z.approvers)==null?void 0:Le.length)??0)>0,ee=new Map;if(Z!=null&&Z.caps&&v==="team")for(const[Ee,_e]of oe){const he=Z.caps[Ee];he!==void 0&&Number(_e)>he&&ee.set(Ee,{authorized:Number(_e),cap:he})}const W=ee.size>0,B=t.approvers_frozen??[],V=(Z==null?void 0:Z.approvers)??[],k=v==="team"&&B.length>0&&V.length>0&&(B.length!==V.length||B.some(Ee=>!V.includes(Ee))||V.some(Ee=>!B.includes(Ee))),A=Array.from(ee.entries()).map(([Ee,_e])=>`${Ee}: ${_e.authorized} (cap ${_e.cap})`).join(", "),K=Array.from(ee.entries()).map(([Ee,_e])=>`${Ee}: ${_e.authorized} → ${_e.cap}`).join(", "),te=W?pe?ee.size===1?`Above team cap: ${A} — actions require approval`:`Above team cap (${ee.size}): ${A} — actions require approval`:ee.size===1?`Reduced by hard cap: ${K}`:`Reduced by hard cap (${ee.size}): ${K}`:"",ue=W?pe?"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,ve=Nr(t.profile_id),Ce=ve.name,ke=s?r.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:[r.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[Ce,"@",s.version," available"]}),s.whatsNew?r.jsxs(r.Fragment,{children:[" — ",s.whatsNew]}):null,r.jsx("br",{}),r.jsxs("span",{children:["This mandate stays on ",t.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,se=F!=null&&t.authorization_id===F;return r.jsxs("div",{className:`card id-card${se?" card-highlight":""}`,style:{marginBottom:0},children:[r.jsx(Zs,{profileId:t.profile_id}),r.jsxs("div",{className:"id-body",children:[ke,w&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",r.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:w})]}),r.jsxs("div",{className:"auth-card-header",children:[r.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:t.title||Ce}),r.jsx(W0,{status:H}),ie&&r.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"}),ve.testSetup&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),H==="active"&&t.earliest_expiry&&r.jsx(K0,{expiresAt:new Date(t.earliest_expiry).getTime()/1e3}),H==="expired"&&(()=>{const Ee=jv(t,H);return Ee?r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(Ee.iso).toLocaleString()}`,children:new Date(Ee.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}):null})()]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[t.required_domains.map(Ee=>r.jsx(H0,{domain:Ee,attested:t.attested_domains.includes(Ee)},Ee)),t.deferred_commitment_domains.length>0&&r.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"}),W&&r.jsx("span",{title:ue,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:pe?"var(--accent-subtle)":"var(--danger-subtle)",color:pe?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:te}),k&&r.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:()=>S(t),disabled:p===t.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:p===t.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),oe.length>0&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:oe.map(([Ee,_e],he)=>{const X=ee.get(Ee);return r.jsxs("span",{children:[he>0&&" · ",X?pe?r.jsxs("span",{title:`Team cap on ${Ee} is ${X.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${X.authorized}.`,children:[r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[Ee,"=",String(_e)]}),r.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",X.cap]})]}):r.jsxs("span",{title:`Team cap on ${Ee} is ${X.cap} with no approvers configured (hard cap). Authorized for ${X.authorized}; effective ${X.cap}.`,children:[r.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[Ee,"=",String(_e)]}),r.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",X.cap]})]}):r.jsxs("span",{children:[Ee,"=",String(_e)]})]},Ee)})}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[re&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>P(t.authorization_id,!Y),disabled:L===t.authorization_id,title:Y?"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:L===t.authorization_id?Y?"Unarchiving…":"Archiving…":Y?"↩ Unarchive":"⊟ Archive"}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>N(t),children:J?"▲ Hide Details":"▼ Details"})]}),J&&r.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[oe.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),r.jsx("dl",{className:"review-grid",children:oe.map(([Ee,_e])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:Ee}),r.jsx("dd",{children:String(_e)})]},Ee))})]}),(M==null?void 0:M.context)&&Object.keys(M.context).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Scope"}),r.jsx("dl",{className:"review-grid",children:Object.entries(M.context).map(([Ee,_e])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:Ee}),r.jsx("dd",{title:String(_e),children:qh(Ee,_e,M.contextLabels)})]},Ee))})]}),r.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),d===t.authorization_id?r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):M?r.jsx("div",{className:"gate-content-block",children:r.jsx("div",{className:"gate-content-item",children:r.jsx("div",{className:"gate-content-text",children:M.gateContent.intent})})}):r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(t.created_at).toLocaleString(),t.earliest_expiry&&` · Expires: ${new Date(t.earliest_expiry).toLocaleString()}`]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:t.authorization_id}),r.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>E(t.authorization_id),children:h===t.authorization_id?"copied":"copy"})]}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!w&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>S(t),disabled:p===t.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:p===t.authorization_id?"Copying…":"⧉ Copy"}),!w&&(H==="active"||H==="pending")&&r.jsx("button",{className:ie?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>S(t,{asEdit:!0}),disabled:p===t.authorization_id,title:ie?"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:ie?"⚠ Re-approve":"✎ Edit"}),!w&&fe&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>T(t),children:"↻ Extend"}),w&&j&&H!=="revoked"?r.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>C(t.authorization_id,w,Ce),disabled:y===t.authorization_id,children:y===t.authorization_id?"Revoking…":"Revoke"}):!w&&(H==="active"||H==="pending")?r.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>C(t.authorization_id),disabled:y===t.authorization_id,children:y===t.authorization_id?"Revoking…":"Revoke"}):null]})]})]})]},t.authorization_id)}function ew(){const[t,s]=f.useState([]),[a,o]=f.useState(!0),[c,d]=f.useState([]),[h,y]=f.useState(!1),[p,g]=f.useState(new Map),[v,w]=f.useState("mine"),[j,N]=f.useState("active"),[E,S]=f.useState(null),[C,T]=f.useState(null),[R,L]=sc(),[P,F]=f.useState(()=>R.get("new")==="1"),[G]=f.useState(()=>R.get("profile")),[H,ie]=f.useState(()=>R.get("highlight")),[Y,re]=f.useState(null),[J,M]=f.useState({}),[fe,oe]=f.useState(null),[Z,pe]=f.useState(null),[ee,W]=f.useState(null),[B,V]=f.useState(new Set),[k,A]=f.useState(null),[K,te]=f.useState(new Set),[ue,ve]=f.useState(null),[Ce,ke]=f.useState(null),[se,Le]=f.useState(new Set),Ee=mn(),{group:_e,groupId:he,domain:X,mode:we,activeTeam:Te}=vt(),$e=(Te==null?void 0:Te.isAdmin)===!0,[lt,xt]=f.useState(()=>new Map),Ke=f.useCallback(()=>{o(!0),D.getMyAttestations().then(s).catch(()=>{}).finally(()=>o(!1))},[]),et=f.useCallback(()=>{D.getArchivedMandates().then(ae=>te(new Set(ae))).catch(()=>{})},[]);f.useEffect(()=>{et()},[et]);const st=f.useCallback(()=>{D.getEnrichedAuthorizations().then(ae=>Le(new Set(ae.filter(je=>je.needsReapproval).map(je=>je.authorizationId)))).catch(()=>{})},[]);f.useEffect(()=>{st()},[st]);const mt=async(ae,je)=>{ve(ae);try{const ge=await D.setMandateArchived(ae,je);te(new Set(ge)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(ge){alert(ge instanceof Error?ge.message:"Failed to update archive")}finally{ve(null)}},Fe=f.useCallback(()=>{he&&(y(!0),D.listTeamAuthorizations(he).then(d).catch(()=>{}).finally(()=>y(!1)))},[he]);He("attestation-changed",()=>{Ke(),$e&&he&&Fe(),st()}),f.useEffect(()=>{if(!H)return;R.get("highlight")&&(R.delete("highlight"),L(R,{replace:!0}));const ae=window.setTimeout(()=>ie(null),3e3);return()=>window.clearTimeout(ae)},[]),nn(Ke,3e5),f.useEffect(()=>{v==="team"&&$e&&he&&c.length===0&&!h&&Fe()},[v,$e,he,c.length,h,Fe]),f.useEffect(()=>{let ae=!1;return D.listProfiles().then(je=>{if(ae)return;const ge=Je=>Je.replace(/@.*$/,"").split("/").pop()??Je,Me=Je=>Je.split("@")[1]??"",ze=new Map;for(const Je of je){const Ut=ge(Je.id),er=ze.get(Ut);(!er||Me(Je.id).localeCompare(Me(er.id),void 0,{numeric:!0})>0)&&ze.set(Ut,Je)}g(ze)}).catch(()=>{}),()=>{ae=!0}},[]);const $=f.useCallback(ae=>{const je=Ut=>Ut.replace(/@.*$/,"").split("/").pop()??Ut,ge=Ut=>Ut.split("@")[1]??"",Me=p.get(je(ae));if(!Me)return;const ze=ge(ae),Je=ge(Me.id);if(!(!ze||!Je))return Je.localeCompare(ze,void 0,{numeric:!0})>0?Me:void 0},[p]);f.useEffect(()=>{if(we!=="team"||!he)return;const ae=v==="mine"?t:c;if(ae.length===0)return;const je=[...new Set(ae.map(ge=>ge.profile_id))].filter(ge=>!lt.has(ge));if(je.length!==0){xt(ge=>{const Me=new Map(ge);for(const ze of je)Me.set(ze,null);return Me});for(const ge of je)D.getTeamProfileConfig(he,ge).then(Me=>{xt(ze=>new Map(ze).set(ge,Me))}).catch(()=>{})}},[t,c,v,he,we,lt]);const le=async ae=>{if(Y===ae.authorization_id){re(null);return}re(ae.authorization_id);const je=ae.authorization_id;if(!(je in J)){oe(ae.authorization_id);try{const ge=await D.getGateContent(je);M(Me=>({...Me,[je]:ge}))}catch{M(ge=>({...ge,[je]:null}))}finally{oe(null)}}},me=ae=>{navigator.clipboard.writeText(ae).then(()=>{W(ae),setTimeout(()=>W(null),2e3)})},Re=async(ae,je)=>{var ge;if(!he){alert("No active group; cannot copy mandate.");return}ke(ae.authorization_id);try{const Me=ae.authorization_id;let ze=J[Me]??null;Me in J||(ze=await D.getGateContent(Me),M(kn=>({...kn,[Me]:ze})));const Je=Object.fromEntries(Object.entries(ae.frame).filter(([kn])=>kn!=="profile"&&kn!=="path")),Ut=(ze==null?void 0:ze.context)??{},er=((ge=ze==null?void 0:ze.gateContent)==null?void 0:ge.intent)??"",rs=ae.deferred_commitment_domains.length>0?"review":"automatic",ta=ae.attested_domains[0]||X||"owner",Sn=Date.parse(ae.created_at),tr=ae.earliest_expiry?Date.parse(ae.earliest_expiry):NaN,nr=Number.isFinite(Sn)&&Number.isFinite(tr)&&tr>Sn?Math.round((tr-Sn)/1e3):void 0;let na=ae.profile_id,$n=Je,rr=Ut,sr;const ss=await D.listProfiles(),Cr=tm(ae.profile_id,ss);if(Cr&&Cr.id!==ae.profile_id){const kn=await D.getProfile(Cr.id);na=Cr.id,$n=rm(Je,kn),rr=sm(Ut,kn),sr=ae.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:na,groupId:he,groupName:(_e==null?void 0:_e.name)??null,domain:ta,isPersonal:!!(_e!=null&&_e.isPersonal),upgradedFromProfileId:sr})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:$n,context:rr,gateContent:{intent:er},templateMode:rs,templateTtl:nr})),je!=null&&je.asEdit?sessionStorage.setItem("agentEditReplaces",ae.authorization_id):sessionStorage.removeItem("agentEditReplaces"),Ee("/mandates/new/intent")}catch(Me){alert(Me instanceof Error?Me.message:"Failed to copy mandate")}finally{ke(null)}},de=async(ae,je,ge)=>{const Me=je&&ge?`Revoke ${je}'s ${ge} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(Me)){A(ae);try{await D.revokeAttestation(ae),V(ze=>new Set(ze).add(ae)),D.resyncGates().catch(()=>{}),je&&he&&Fe()}catch(ze){alert(ze instanceof Error?ze.message:"Failed to revoke mandate")}finally{A(null)}}},Oe=v==="mine"?t:c,Ge=v==="mine"?a:h,Ye=v==="mine"?{revokedSet:B,archivedSet:K}:{revokedSet:B},ft=ae=>Si(ae,Ye),pn={active:0,pending:0,expired:0,revoked:0,archived:0};for(const ae of Oe)pn[ft(ae)]+=1;const jn=v==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],tt=(()=>{const ae=new Map;for(const je of Oe){if(ft(je)!==j)continue;const ge=ae.get(je.profile_id)??{count:0,review:!1};ge.count+=1,je.deferred_commitment_domains.length>0&&(ge.review=!0),ae.set(je.profile_id,ge)}return Array.from(ae.entries()).map(([je,ge])=>({profileId:je,...ge})).sort((je,ge)=>dt(je.profileId).localeCompare(dt(ge.profileId)))})(),bt=X0(Oe.filter(ae=>{if(ft(ae)!==j||E!==null&&ae.profile_id!==E)return!1;if(C!==null){const je=ae.deferred_commitment_domains.length>0;if(C==="review"&&!je||C==="auto"&&je)return!1}return!0}),Ye,H),Et={revokedSet:B,expandedHash:Y,gateCache:J,gateLoading:fe,copiedHash:ee,revokingHash:k,copyingHash:Ce,profileConfigCache:lt,mode:we,activeDomain:X,group:_e,groupId:he,onExpand:le,onCopyHash:me,onCopy:Re,onRevoke:de,onExtend:pe,highlightHash:H},wt={...Et,archivedSet:K,archivingHash:ue,onArchive:mt,needsReapprovalSet:se};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Mandates"}),r.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),r.jsx("button",{className:"btn btn-primary",onClick:()=>F(!0),children:"+ New mandate"})]}),P&&r.jsx("div",{className:"modal-backdrop",onClick:()=>{F(!1),(R.get("new")||R.get("profile"))&&(R.delete("new"),R.delete("profile"),L(R,{replace:!0}))},children:r.jsxs("div",{className:"modal",onClick:ae=>ae.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h2",{className:"modal-title",children:"New mandate"}),r.jsx("button",{className:"modal-close",onClick:()=>{F(!1),(R.get("new")||R.get("profile"))&&(R.delete("new"),R.delete("profile"),L(R,{replace:!0}))},children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[r.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."}),r.jsx(D0,{onDismiss:()=>F(!1),preselectProfileId:G})]})]})}),$e&&r.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[r.jsx("button",{className:`nav-tab${v==="mine"?" active":""}`,onClick:()=>{w("mine"),N("active"),S(null),T(null),re(null)},children:"Mine"}),r.jsx("button",{className:`nav-tab${v==="team"?" active":""}`,onClick:()=>{w("team"),N("active"),S(null),T(null),re(null)},children:"Team"})]}),r.jsx("div",{className:"nav-tabs",children:jn.map(ae=>r.jsxs("button",{className:`nav-tab${j===ae?" active":""}`,onClick:()=>{N(ae),S(null),T(null)},children:[ae.charAt(0).toUpperCase()+ae.slice(1)," (",pn[ae],")"]},ae))}),tt.length>0&&r.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[tt.map(ae=>{const je=E===ae.profileId;return r.jsx("button",{className:`btn btn-sm ${je?"btn-primary":"btn-secondary"}`,onClick:()=>S(je?null:ae.profileId),children:dt(ae.profileId)},ae.profileId)}),r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(ae=>{const je=C===ae;return r.jsx("button",{className:`btn btn-sm ${je?"btn-primary":"btn-secondary"}`,onClick:()=>T(je?null:ae),children:ae==="auto"?"Auto":"Review"},ae)})]}),Ge&&Oe.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):bt.length===0?r.jsx(Zr,{icon:"☰",title:"No mandates",text:j==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${j} mandates found.`}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:bt.map(ae=>{const je=v==="team"?ae:null,ge=je!=null&&je.owner?je.owner.name??je.owner.email??je.owner.userId:void 0;return r.jsx(Z0,{item:ae,newerProfile:$(ae.profile_id),ownerLabel:ge,isAdmin:$e,...v==="mine"?wt:Et},ae.authorization_id)})}),Z&&r.jsx(q0,{item:Z,onClose:()=>pe(null),onSuccess:()=>{pe(null),Ke()}})]})}const tw=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function Kt(t){const s=t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)}function vc(t){const s=t.indexOf("__");return s<0?{integrationId:"",toolName:t}:{integrationId:t.slice(0,s),toolName:t.slice(s+2)}}function nw(t){const{integrationId:s,toolName:a}=vc(t);return s?`${s} · ${a}`:a}function am(t,s){const a=s==null?void 0:s.find(o=>o.id===t);return a!=null&&a.name?a.name:t?t.toUpperCase():"the system"}function rw(t){return Array.isArray(t)?"list":t&&typeof t=="object"?"object":typeof t=="string"&&(t.includes(`
80
+ `)||t.length>120)?"markdown":"text"}function sw(t,s){var h,y;const a=(s==null?void 0:s.approvalView)??{},o=((h=s==null?void 0:s.inputSchema)==null?void 0:h.properties)??{},c=[...new Set([...Object.keys(a),...Object.keys(o),...Object.keys(t)])],d=[];for(const p of c){if(!(p in t)||tw.has(p))continue;const g=t[p],v=a[p]??{},w=v.kind??rw(g),j={key:p,label:v.label??Kt(p),kind:w,value:g,hint:(y=o[p])==null?void 0:y.description};w==="money"&&v.currencyArg&&typeof t[v.currencyArg]=="string"&&(j.currency=t[v.currencyArg]),w==="profile"&&typeof g=="string"&&(j.profileRef=g),(w==="profile-limits"||w==="profile-scope")&&v.profileArg&&typeof t[v.profileArg]=="string"&&(j.profileRef=t[v.profileArg]),d.push(j)}return d}function im(t,s){var o,c;const a=(c=(o=s==null?void 0:s.scopeSchema)==null?void 0:o.fields)==null?void 0:c[t];return a?{label:a.displayName??t,hint:a.description}:{label:t}}function aw(t,s,a){if(!t||typeof t!="object"||Array.isArray(t))return[];const o=a==="limits"?s==null?void 0:s.boundsSchema:s==null?void 0:s.scopeSchema,c=(o==null?void 0:o.fields)??{},d=[...new Set([...(o==null?void 0:o.keyOrder)??[],...Object.keys(t)])],h=[];for(const y of d){if(y==="profile"||!(y in t))continue;const p=t[y],g=c[y],v=pc(g==null?void 0:g.unit),w=Array.isArray(p)?p.join(", "):String(p);h.push({key:y,label:(g==null?void 0:g.displayName)??Kt(y),value:v?`${w} ${v}`:w,hint:g==null?void 0:g.description,unknown:s?!g:void 0})}return h}function iw(t){const s=t.indexOf("__");return s<0?{integrationId:"",toolName:t}:{integrationId:t.slice(0,s),toolName:t.slice(s+2)}}function ow(t,s){var p,g,v;const{integrationId:a,toolName:o}=iw(t.action),c=s.find(w=>w.id===a),d=(g=(p=c==null?void 0:c.toolGating)==null?void 0:p.overrides)==null?void 0:g[o];if(d!=null&&d.actionLabel)return d.actionLabel;const h=dt(t.profileId),y=(v=t.executionContext)==null?void 0:v.action_type;return typeof y=="string"&&y?`${h} · ${y}`:`${h} · ${o}`}function lw(t,s){var c;const a=(c=s==null?void 0:s.scopeSchema)==null?void 0:c.fields;if(!a)return"";const o=[];for(const[d,h]of Object.entries(t.executionContext??{})){if(!(d in a))continue;const y=String(h??"").trim();y&&o.push(y.split(",").map(p=>p.trim()).filter(Boolean).join(", "))}return o.join(" · ")}function cw(t,s){var c,d;if(!t)return"";const a=((c=s==null?void 0:s.scopeSchema)==null?void 0:c.fields)??{},o=[];for(const[h,y]of Object.entries(t)){if(h==="action_type")continue;const p=String(y??"").trim();if(!p)continue;const g=((d=a[h])==null?void 0:d.displayName)??h;o.push(`${g} ${p.split(",").map(v=>v.trim()).filter(Boolean).join(", ")}`)}return o.join(" · ")}function zf(t){return t.appliesTo}function uw(t,s,a){var y,p,g,v;const o=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],c=t.actionType??(typeof((y=t.executionContext)==null?void 0:y.action_type)=="string"?t.executionContext.action_type:void 0),d=(p=a==null?void 0:a.boundsSchema)==null?void 0:p.fields,h=[];for(const{window:w,label:j}of o){const N=(g=t.cumulativeState)==null?void 0:g[w];if(!N)continue;let E;if(d&&s){const T=Object.entries(d).filter(([P,F])=>{if(!(P in s))return!1;const G=F.boundType;if(!G||G.kind!=="cumulative_sum"&&G.kind!=="cumulative_count"||G.window!==w)return!1;const H=zf(F);return!H||!c||H.includes(c)}),L=(c?T.find(([,P])=>{var F;return(F=zf(P))==null?void 0:F.includes(c)}):void 0)??(T.length===1?T[0]:void 0);L&&(E={key:L[0],isAmount:((v=L[1].boundType)==null?void 0:v.kind)==="cumulative_sum"})}const S=E?E.isAmount?N.amount:N.count:void 0,C=E?Number(s==null?void 0:s[E.key]):NaN;E&&Number.isFinite(C)?h.push(`${S} of ${C} ${j}`):h.push(`${N.count} ${N.count===1?"call":"calls"} ${j}`)}return h.join(" · ")}function dw(t,s,a){var d;const o=(d=a==null?void 0:a.boundsSchema)==null?void 0:d.fields;if(!t||!s||!o)return[];const c=[];for(const[h,y]of Object.entries(o)){const p=y.boundType;if(!p||p.kind!=="per_transaction")continue;const g=p.of;if(!(g in t)||!(h in s))continue;const v=Number(t[g]),w=Number(s[h]);if(!Number.isFinite(v)||!Number.isFinite(w))continue;const j=pc(y.unit),N=y.displayName??Kt(g),E=S=>j?`${S.toLocaleString()} ${j}`:S.toLocaleString();c.push({key:h,label:N,ok:v<=w,valueText:E(v),limitText:E(w)})}return c}function fw(t){return typeof t.proposalId=="string"&&t.proposalId.length>0}function hw(t){const s=dt(t),a=t.split("@")[1];return a?`${s}@${a}`:s}const Ff=new Map;function mw(t){let s=Ff.get(t);return s||(s=(async()=>{try{let a=t;if(!t.includes("@")){const o=await D.listProfiles(),c=h=>h.replace(/@.*$/,"").split("/").pop(),d=o.filter(h=>c(h.id)===t).sort((h,y)=>(y.id.split("@")[1]??"").localeCompare(h.id.split("@")[1]??"",void 0,{numeric:!0}));if(!d[0])return null;a=d[0].id}return await D.getProfile(a)}catch{return null}})(),Ff.set(t,s)),s}function ea(t){const[s,a]=f.useState(null);return f.useEffect(()=>{let o=!0;return t&&mw(t).then(c=>{o&&a(c)}),()=>{o=!1}},[t]),s}async function Of(t){const s=new TextEncoder().encode(t),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}function pw(t){return t.normalize("NFC").replace(/\r\n?/g,`
81
+ `).split(`
82
+ `).map(c=>c.replace(/[ \t]+$/,"")).join(`
83
+ `).replace(/\n+$/,"")}function Ul(t){if(t===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof t=="number"&&!Number.isFinite(t))throw new Error(`canonicalize: ${t} is not a valid JSON number`);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return"["+t.map(c=>c===void 0?"null":Ul(c)).join(",")+"]";const s=t,a=[];for(const o of Object.keys(s).sort()){const c=s[o];c!==void 0&&a.push(JSON.stringify(o)+":"+Ul(c))}return"{"+a.join(",")+"}"}async function om(t,s){if(t==="jcs"){if(typeof s=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await Of(Ul(s))}`}if(typeof s!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await Of(pw(s))}`}function tn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function $t(t,s=!1){return t==null?"—":typeof t=="string"?t:typeof t=="boolean"?String(t):typeof t=="number"?s||Number.isInteger(t)?String(t):String(Math.round(t*100)/100):"—"}function gw(t){return t==null?!1:typeof t=="string"||Array.isArray(t)?t.length>0:!0}function Sr(t,s,a){const o=s?Object.keys(s).filter(c=>c in t):Object.keys(t);return o.length===0?"—":o.map(c=>{var p,g;const d=t[c],h=((p=s==null?void 0:s[c])==null?void 0:p.title)??Kt(c),y=tn(d)?Sr(d,(g=s==null?void 0:s[c])==null?void 0:g.properties,a):$t(d,a);return`${h}: ${y}`}).join(" · ")}function yw(t,s){const a=s?Object.keys(s).filter(d=>t.some(h=>d in h)):[...new Set(t.flatMap(d=>Object.keys(d)))],o=a.map(d=>{var h;return{key:d,label:((h=s==null?void 0:s[d])==null?void 0:h.title)??Kt(d)}}),c=t.map(d=>({cells:a.map(h=>{var v,w;const y=d[h],p=tn(y)?Sr(y,(v=s==null?void 0:s[h])==null?void 0:v.properties,!1):$t(y),g=tn(y)?Sr(y,(w=s==null?void 0:s[h])==null?void 0:w.properties,!0):$t(y,!0);return g===p?{value:p,sealed:!1}:{value:p,valueTitle:g,sealed:!1}})}));return{columns:o,rows:c}}function vw(t){return t.split(`
84
+ `).map(s=>s.startsWith("+")&&!s.startsWith("+++")?{text:s,kind:"add"}:s.startsWith("-")&&!s.startsWith("---")?{text:s,kind:"remove"}:{text:s,kind:"context"})}function xw(t,s){var c;if(Array.isArray(t)){if(t.length===0)return{value:"—"};if(t.every(v=>!tn(v)&&!Array.isArray(v))){if(t.every(j=>typeof j=="string"))return{lines:t};const v=t.map(j=>$t(j)).join(", "),w=t.map(j=>$t(j,!0)).join(", ");return w===v?{value:v}:{value:v,valueTitle:w}}const d=(c=s==null?void 0:s.items)==null?void 0:c.properties,h=t.map(v=>tn(v)?Sr(v,d,!1):$t(v)),y=t.map(v=>tn(v)?Sr(v,d,!0):$t(v,!0)),p=h.map((v,w)=>v===y[w]?void 0:y[w]),g=t.every(tn)?yw(t,d):void 0;return{lines:h,...p.some(v=>v!==void 0)?{lineTitles:p}:{},...g?{table:g}:{}}}if(tn(t)){const d=s==null?void 0:s.properties,h=d?Object.keys(d).filter(g=>g in t):Object.keys(t);if(h.length>0&&h.every(g=>!tn(t[g])&&!Array.isArray(t[g])))return{sublist:h.map(v=>{var S;const w=t[v],j=((S=d==null?void 0:d[v])==null?void 0:S.title)??Kt(v),N=$t(w),E=$t(w,!0);return E===N?{key:v,label:j,value:N}:{key:v,label:j,value:N,valueTitle:E}})};const y=Sr(t,d,!1),p=Sr(t,d,!0);return p===y?{value:y}:{value:y,valueTitle:p}}if(typeof t=="string"&&(s==null?void 0:s.contentMediaType)==="text/x-diff")return{diffLines:vw(t)};const a=$t(t),o=$t(t,!0);return o===a?{value:a}:{value:a,valueTitle:o}}function ww(t){let s;try{s=JSON.parse(t)}catch{return null}return tn(s)?s:null}function br(t){const s=t!=null&&t.structured&&Object.keys(t.structured).length>0?t.structured:void 0;if(s)return{obj:s,schema:t==null?void 0:t.outputSchema};const a=t!=null&&t.text?ww(t.text):null;return a?{obj:a}:null}function Ci(t){const s=br(t);if(!s)return[];const{obj:a,schema:o}=s,c=(o==null?void 0:o.properties)??{},d=[...new Set([...Object.keys(c),...Object.keys(a)])],h=[];for(const y of d){if(!(y in a))continue;const p=c[y],g=(p==null?void 0:p.title)??Kt(y),v={key:y,label:g,...xw(a[y],p)};p!=null&&p.description&&(v.description=p.description),h.push(v)}return h}function Ei(t,s){const a=br(t);if(a){const c=Ci(t),d=s==null?void 0:s.fields;let h;if(d&&d.length>0){const g=new Map(c.map(v=>[v.key,v]));h=d.map(v=>g.get(v)).filter(v=>v!==void 0)}else h=c.filter(g=>gw(a.obj[g.key]));const y=new Set(h.map(g=>g.key)),p=c.filter(g=>!y.has(g.key));return{kind:"structured",fields:h,moreFields:p,totalFields:c.length}}const o=t==null?void 0:t.text;return o&&o.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:o}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function Mf(t){return t?t.lines?`lines:${JSON.stringify(t.lines)}`:t.sublist?`sublist:${JSON.stringify(t.sublist.map(s=>[s.key,s.value]))}`:t.diffLines?`diffLines:${JSON.stringify(t.diffLines)}`:`value:${t.value??""}`:""}function mi(t){return{kind:t.length>0?"structured":"empty",fields:t,moreFields:[],totalFields:t.length}}function jw(t,s,a){const o=br(t),c=br(s);if(!o&&!c){const j=(t==null?void 0:t.text)??"",N=(s==null?void 0:s.text)??"";return j===N?{approved:mi([]),current:mi([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:j},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:N},unchanged:!1}}const d=new Map(Ci(t).map(j=>[j.key,j])),h=new Map(Ci(s).map(j=>[j.key,j])),p=[...new Set([...d.keys(),...h.keys()])].filter(j=>j===(a==null?void 0:a.excludeKey)?!1:Mf(d.get(j))!==Mf(h.get(j))),g=a!=null&&a.fields&&a.fields.length>0?[...a.fields.filter(j=>p.includes(j)),...p.filter(j=>!a.fields.includes(j))]:p,v=g.map(j=>d.get(j)).filter(j=>j!==void 0),w=g.map(j=>h.get(j)).filter(j=>j!==void 0);return{approved:mi(v),current:mi(w),unchanged:p.length===0}}function Sw(t){const s=t==null?void 0:t.structured;if(Array.isArray(s)&&s.every(tn))return s;if(t!=null&&t.text){let a;try{a=JSON.parse(t.text)}catch{return null}if(Array.isArray(a)&&a.every(tn))return a}return null}function Li(t){const s=$t(t),a=$t(t,!0);return a===s?{value:s}:{value:s,valueTitle:a}}function lm(t){return!t||t.status!=="ok"?[]:Ci(t.body)}function cm(t){if(!t)return"Not read.";switch(t.status){case"not_found":return"Not found in the system.";case"none":return"Nothing to read.";default:return"Not available right now."}}function um(t,s,a){var p;const o=lm(t);if(o.length===0)return{rawId:$t(s),context:[],unresolved:cm(t)};const c=t&&t.status==="ok"?(p=br(t.body))==null?void 0:p.obj:void 0,d=o.find(g=>["name","title","label"].includes(g.key))??o.find(g=>typeof(c==null?void 0:c[g.key])=="string"&&!g.lines&&!g.sublist&&!g.diffLines),h=a==null?void 0:a.pathPrefix,y=o.filter(g=>g.key!==(d==null?void 0:d.key)&&g.key!=="id").map(g=>{var E,S;if(!h)return g;const v=`${h}.${g.key}`,w=Gs(a==null?void 0:a.displayHints,v,g.label);if(!qs((E=a==null?void 0:a.displayHints)==null?void 0:E.money,v)&&!qs((S=a==null?void 0:a.displayHints)==null?void 0:S.percent,v))return w===g.label?g:{...g,label:w};const{value:j,valueTitle:N}=Ti(c==null?void 0:c[g.key],a==null?void 0:a.displayHints,v,a==null?void 0:a.currency);return{...g,label:w,value:j,valueTitle:N}});return{name:d==null?void 0:d.value,rawId:$t(s),context:y}}const kw=new Set(["id","name","title","label"]);function qs(t,s){return!!(t!=null&&t.includes(s))}function Gs(t,s,a){var o;return((o=t==null?void 0:t.labels)==null?void 0:o[s])??a}function bw(t,s){const a=typeof t=="number"?t:Number(t);return Number.isFinite(a)?{value:`${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${s?` ${s}`:""}`}:Li(t)}function Nw(t){return typeof t!="number"&&typeof t!="string"?Li(t):{value:`${t} %`}}function Ti(t,s,a,o){return qs(s==null?void 0:s.money,a)?bw(t,o):qs(s==null?void 0:s.percent,a)?Nw(t):Li(t)}function dm(t,s){return qs(t==null?void 0:t.hidden,s)}function Cw(t,s,a){var h;const o=t==null?void 0:t.currencyField;if(!o)return;const c=o.indexOf(".");if(c<0){const y=s[o];return typeof y=="string"?y:void 0}const d=(h=a(o.slice(0,c)))==null?void 0:h[o.slice(c+1)];return typeof d=="string"?d:void 0}function Ew(t,s,a,o){const c=t.forEach??"",d=t.attach,h=t.elements??[],y=Math.min(s.length,h.length),p=s.slice(0,y),g=h.slice(0,y),v=[...new Set(p.flatMap(S=>Object.keys(S)))].filter(S=>S!==t.sourceArg).filter(S=>!dm(a,`${c}[].${S}`)),w=new Map;if(d)for(const S of g)for(const C of lm(S))w.has(C.key)||w.set(C.key,C.label);const j=d?[...w.keys()].filter(S=>!kw.has(S)):[],N=[];d&&N.push({key:`__attach:${d}`,label:Gs(a,`${c}[].${d}`,Kt(t.sourceArg??d))});for(const S of v)N.push({key:`bound:${S}`,label:Gs(a,`${c}[].${S}`,Kt(S))});for(const S of j)N.push({key:`attached:${S}`,label:Gs(a,`${c}[].${d}.${S}`,w.get(S)??Kt(S))});const E=p.map((S,C)=>{var P;const T=g[C],R=[];if(d){const F=um(T,t.sourceArg?S[t.sourceArg]:void 0),G=F.name?`${F.name} (${F.rawId})`:F.unresolved?`${F.rawId} — ${F.unresolved}`:F.rawId;R.push({value:G,sealed:!1})}for(const F of v){const{value:G,valueTitle:H}=Ti(S[F],a,`${c}[].${F}`,o);R.push({value:G,valueTitle:H,sealed:!0})}const L=T&&T.status==="ok"?(P=br(T.body))==null?void 0:P.obj:void 0;for(const F of j){const G=L==null?void 0:L[F],{value:H,valueTitle:ie}=G!==void 0?Ti(G,a,`${c}[].${d}.${F}`,o):{value:"—",valueTitle:void 0};R.push({value:H,valueTitle:ie,sealed:!1})}return{cells:R}});return{columns:N,rows:E,...t.overflow?{overflowNote:`${t.overflow.total-t.overflow.shown} more not shown`}:{}}}function Tw(t){return`${Kt(t)} — from the system`}function Rw(t){const s=Tw(t.tool),a=t.result;if(!a||a.status!=="ok")return{heading:s,note:cm(a)};const o=Sw(a.body);if(o){if(o.length===0)return{heading:s,note:"Nothing found."};const c=[...new Set(o.flatMap(y=>Object.keys(y)))],d=c.map(y=>({key:y,label:Kt(y)})),h=o.map(y=>({cells:c.map(p=>({...Li(y[p]),sealed:!1}))}));return{heading:s,table:{columns:d,rows:h}}}return{heading:s,body:Ei(a.body,{fields:t.fields})}}function Iw(t,s,a){const o=new Map(s.filter(w=>w.attach&&!w.forEach).map(w=>[w.attach,w])),c=new Map(s.filter(w=>w.forEach).map(w=>[w.forEach,w])),d=s.filter(w=>!w.attach&&!w.forEach),y=Cw(a,t,w=>{var N,E;const j=(N=o.get(w))==null?void 0:N.result;return j&&j.status==="ok"?(E=br(j.body))==null?void 0:E.obj:void 0}),p=(a==null?void 0:a.order)??[],g=[...new Set([...p,...Object.keys(t)])],v=[];for(const w of g){if(!(w in t)||dm(a,w))continue;const j=Gs(a,w,Kt(w)),N=c.get(w);if(N){const T=Array.isArray(t[w])?t[w]:[];v.push({kind:"table",key:w,label:j,table:Ew(N,T,a,y)});continue}const E=o.get(w);if(E){const T=um(E.result,t[w],{pathPrefix:w,displayHints:a,currency:y});v.push({kind:"identity",key:w,label:j,identity:T});continue}const{value:S,valueTitle:C}=Ti(t[w],a,w,y);v.push({kind:"scalar",key:w,label:j,value:S,valueTitle:C})}return{rows:v,sections:d.map(Rw)}}function Aw(t){return t.offDevice?"off-device":t.boundContent===void 0?"none":t.hasHashToCheck?t.hashVerified===!0?"verified":"mismatch":"unchecked"}function Pw(t,s){return t===void 0?{kind:"empty",fields:[],moreFields:[],totalFields:0}:typeof t=="string"?Ei({text:t}):Ei({structured:t},{fields:s})}function _w(t,s){return t?Object.entries(t).filter(([,a])=>a!=null&&a!=="").map(([a,o])=>({key:a,label:im(a,s).label,value:String(o)})):[]}function Ri({table:t}){return t.columns.length===0?r.jsx("p",{className:"preview-note",children:"Nothing to show."}):r.jsxs(r.Fragment,{children:[r.jsxs("table",{className:"preview-table",children:[r.jsx("thead",{children:r.jsx("tr",{children:t.columns.map(s=>r.jsx("th",{children:s.label},s.key))})}),r.jsx("tbody",{children:t.rows.map((s,a)=>r.jsx("tr",{children:s.cells.map((o,c)=>r.jsx("td",{className:o.sealed?"src-tag-value src-tag-sealed-cell":"src-tag-value src-tag-system-cell",title:o.valueTitle,children:o.value},c))},a))})]}),t.overflowNote&&r.jsx("p",{className:"preview-note",children:t.overflowNote})]})}function Bf({row:t}){return r.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[t.label,t.description&&r.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:t.description})]})}function $w({row:t}){return t.sublist?r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:t.sublist.map(s=>r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:s.label}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},title:s.valueTitle,children:s.value})]},s.key))}):t.diffLines?r.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:t.diffLines.map((s,a)=>r.jsx("div",{style:s.kind==="remove"?{color:"var(--danger)",textDecoration:"line-through"}:s.kind==="add"?{color:"var(--success)"}:void 0,children:s.text||" "},a))}):t.table?r.jsx(Ri,{table:t.table}):t.lines?r.jsx("div",{children:t.lines.map((s,a)=>{var o;return r.jsx("div",{title:(o=t.lineTitles)==null?void 0:o[a],children:s},a)})}):r.jsx("span",{title:t.valueTitle,children:t.value})}function Wl({rows:t}){return r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:t.map(s=>s.table?r.jsxs("div",{style:{gridColumn:"1 / -1"},children:[r.jsx(Bf,{row:s}),r.jsx(Ri,{table:s.table})]},s.key):r.jsxs(f.Fragment,{children:[r.jsx(Bf,{row:s}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:r.jsx($w,{row:s})})]},s.key))})}function xi({rendered:t}){return t.kind==="empty"?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):t.kind==="text"?r.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:t.text}):r.jsxs(r.Fragment,{children:[r.jsx(Wl,{rows:t.fields}),t.moreFields.length>0&&r.jsxs("details",{style:{fontSize:"0.8rem"},children:[r.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",t.totalFields,")"]}),r.jsx(Wl,{rows:t.moreFields})]})]})}function fm({receipt:t,profile:s}){var j;const[a,o]=f.useState(void 0),[c,d]=f.useState(null),h=!!(t.contentHash&&t.contentBinding);if(f.useEffect(()=>{let N=!0;return o(void 0),d(null),(async()=>{let E;try{E=await D.getArchivedReceipt(t.id)}catch{N&&o(null);return}let S=null;const C=E==null?void 0:E.entry.boundContent;if(C!==void 0&&h)try{S=await om(t.contentBinding.kind,C)===t.contentHash}catch{S=!1}N&&(d(S),o(E))})(),()=>{N=!1}},[t.id,t.contentHash,t.contentBinding,h]),a===void 0)return r.jsx("div",{className:"ticket-done-box ticket-done-loading","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const y=a===null,p=a==null?void 0:a.entry.boundContent,g=Aw({offDevice:y,boundContent:p,hasHashToCheck:h,hashVerified:c});if(g==="off-device")return r.jsx("div",{className:"ticket-done-box ticket-done-off-device","data-testid":"ticket-what-was-done","data-bound":"off-device",children:r.jsx("p",{className:"ticket-done-note",children:"Content not on this device — only the signed values are shown."})});if(g==="none"){const N=_w(t.executionContext,s);return r.jsxs("div",{className:"ticket-done-box","data-testid":"ticket-what-was-done","data-bound":"none",children:[r.jsx("h4",{children:"What was done"}),N.length>0?r.jsx("dl",{className:"ticket-done-fields",children:N.map(E=>r.jsxs("div",{className:"ticket-done-field-row",children:[r.jsx("dt",{children:E.label}),r.jsx("dd",{children:E.value})]},E.key))}):r.jsx("p",{className:"ticket-done-note",children:"No checked values recorded for this action."})]})}const v=Pw(p,(j=t.contentBinding)==null?void 0:j.fields),w=g==="verified"?"ticket-done-verified":g==="mismatch"?"ticket-done-mismatch":"ticket-done-unchecked";return r.jsxs("div",{className:`ticket-done-box ${w}`,"data-testid":"ticket-what-was-done","data-bound":g,children:[r.jsxs("h4",{children:["What was done",g!=="unchecked"&&r.jsxs(r.Fragment,{children:[" ",r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]})]}),r.jsx(xi,{rendered:v}),g==="verified"&&r.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."}),g==="mismatch"&&r.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."}),g==="unchecked"&&r.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 Ds({label:t,children:s}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{className:"receipt-row-label",children:t}),r.jsx("dd",{className:"receipt-row-value",children:s})]})}function Lw({receipt:t,manifests:s,localAuth:a,localUnavailable:o,signature:c,grantTitle:d,ownerLabel:h,spUrl:y,formatDate:p,onOpenComplete:g}){var R;const v=ea(t.profileId),w=lw(t,v),j=cw(a==null?void 0:a.context,v),N=uw(t,(a==null?void 0:a.bounds)??t.limits,v),E=a==null?void 0:a.intent,S=Nr(t.profileId).testSetup||$i(t.action),[C,T]=f.useState(!1);return r.jsxs("div",{className:"card id-card",style:{marginBottom:0},children:[r.jsx(Zs,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{className:"receipt-head",children:[r.jsx("span",{className:"receipt-what",children:ow(t,s)}),r.jsx("span",{className:"receipt-tag",children:fw(t)?"review":"automatic"}),t.contentHash&&r.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(R=t.contentBinding)!=null&&R.fields?`The ticket binds: ${t.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),S&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),r.jsx("span",{className:"auth-card-time",children:p(t.timestamp)})]}),w&&r.jsx("div",{className:"receipt-scope",children:w}),r.jsx(fm,{receipt:t,profile:v}),r.jsxs("dl",{className:"receipt-rows",children:[r.jsxs(Ds,{label:"mandate",children:[r.jsx("strong",{children:d||hw(t.profileId)})," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),h&&r.jsx(Ds,{label:"owner",children:h}),j&&r.jsxs(Ds,{label:"allowed",children:[j," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),N&&r.jsxs(Ds,{label:"used",children:[r.jsx("span",{className:"receipt-num",children:N})," ",r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),r.jsx(Ds,{label:"intent",children:E?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`intent-text${C?"":" intent-clamped"}`,children:E}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>T(!C),children:C?"Show less":"Show full intent"})," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}):r.jsx("span",{className:"receipt-absent",children:o?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]}),r.jsxs("div",{className:"receipt-foot",children:[c==="valid"&&r.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"}),c==="valid-legacy"&&r.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"}),c==="invalid"&&r.jsx("span",{className:"receipt-tamper",title:"The stored ticket does not match what was signed.",children:"⚠ Signature check FAILED"}),r.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:g,children:"Complete ticket"}),y&&r.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",r.jsx("a",{className:"receipt-link",href:`${y}/r/${t.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),r.jsxs("details",{className:"receipt-more",children:[r.jsx("summary",{children:"Raw"}),r.jsxs("div",{className:"receipt-kv",children:[r.jsxs("div",{children:["ticket · ",t.id]}),r.jsxs("div",{children:["action · ",t.action]}),r.jsxs("div",{children:["profile · ",t.profileId]}),t.authorizationId&&r.jsxs("div",{children:["mandate · ",t.authorizationId]}),Object.keys(t.executionContext??{}).length>0&&r.jsxs("div",{children:["scope ·"," ",Object.entries(t.executionContext).map(([L,P])=>`${L}=${P}`).join(" · ")]}),(a==null?void 0:a.boundsHash)&&r.jsxs("div",{children:["bounds hash · ",a.boundsHash]}),(a==null?void 0:a.contextHash)&&r.jsxs("div",{children:["scope hash · ",a.contextHash]}),t.contentHash&&r.jsxs("div",{children:["content · ",t.contentHash]}),t.proposalId&&r.jsxs("div",{children:["proposal · ",t.proposalId]}),r.jsxs("div",{children:["signature · ",t.signature]})]})]})]})]})}function zw({receipt:t,onClose:s}){const[a,o]=f.useState(null),[c,d]=f.useState(null),[h,y]=f.useState(null),[p,g]=f.useState(!0),[v,w]=f.useState(!1);f.useEffect(()=>{let C=!1;return g(!0),D.getArchivedReceipt(t.id).then(T=>{C||(o(T),d(T?"local":"authority-server"),y((T==null?void 0:T.signature)??null))}).catch(()=>{C||d("authority-server")}).finally(()=>{C||g(!1)}),()=>{C=!0}},[t.id]);const j=a?a.entry:{receipt:t},N=JSON.stringify(j,null,2);function E(){const C=URL.createObjectURL(new Blob([N],{type:"application/json"})),T=document.createElement("a");T.href=C,T.download=`suveren-ticket-${t.id.slice(0,8)}.json`,T.click(),URL.revokeObjectURL(C)}async function S(){try{await navigator.clipboard.writeText(N),w(!0),setTimeout(()=>w(!1),2e3)}catch{w(!1)}}return r.jsx("div",{className:"modal-backdrop",onClick:C=>C.target===C.currentTarget&&s(),children:r.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[r.jsxs("div",{className:"modal-header",children:[r.jsx("h3",{className:"modal-title",children:"Complete ticket"}),r.jsx("button",{className:"modal-close",onClick:s,"aria-label":"Close",children:"×"})]}),r.jsxs("div",{className:"modal-body",children:[h==="valid"&&r.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."}),h==="valid-legacy"&&r.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."}),h==="invalid"&&r.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."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:p?"Loading…":c==="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."}),r.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:N})]}),r.jsxs("div",{className:"modal-footer",children:[r.jsx("button",{className:"btn btn-primary btn-sm",onClick:E,children:"Download"}),r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:S,children:v?"Copied":"Copy"})]})]})})}function Fw(t){return new Date(t*1e3).toLocaleString()}function Ow(t,s){if(s==="all")return!0;const a=s==="1d"?1:s==="7d"?7:30,o=Math.floor(Date.now()/1e3)-a*86400;return t.timestamp>=o}function Mw(t,s){if(!s)return!0;const a=s.toLowerCase();return t.profileId.toLowerCase().includes(a)||dt(t.profileId).toLowerCase().includes(a)||t.path.toLowerCase().includes(a)||t.action.toLowerCase().includes(a)||t.attestationHash.toLowerCase().includes(a)||t.id.toLowerCase().includes(a)||JSON.stringify(t.executionContext).toLowerCase().includes(a)}function Df(t,s){const a=new Map(t.map(o=>[o.id,o]));for(const o of s)a.set(o.id,o);return[...a.values()].sort((o,c)=>c.timestamp-o.timestamp)}function Bw(){const{activeTeam:t,groupId:s}=vt(),a=(t==null?void 0:t.isAdmin)===!0,[o,c]=f.useState("mine"),[d,h]=f.useState([]),[y,p]=f.useState([]),[g,v]=f.useState(""),[w,j]=f.useState(!0),[N,E]=f.useState({}),[S,C]=f.useState(new Set),[T,R]=f.useState(""),[L,P]=f.useState(new Set),[F,G]=f.useState(new Set),[H,ie]=f.useState("all"),[Y,re]=f.useState(!1),[J,M]=f.useState(!1),[fe,oe]=f.useState(null),[Z,pe]=f.useState({}),[ee,W]=f.useState(!1),[B,V]=f.useState({}),[k,A]=f.useState({}),[K,te]=f.useState(null),[ue,ve]=f.useState(null),[Ce,ke]=f.useState(!1),[se,Le]=f.useState(!1),Ee=f.useRef(""),_e=f.useCallback($=>o==="team"&&a&&s?D.listTeamReceiptsPage(s,{before:$,limit:200}):D.getMyReceiptsPage({before:$,limit:200}),[o,a,s]),he=f.useCallback(()=>{const $=o==="team"?`team:${s}`:"mine",le=Ee.current!==$;Ee.current=$,j(!0),Le(!1),_e().then(me=>{h(Re=>le?me.receipts:Df(Re,me.receipts)),ve(Re=>le?me.nextBefore:Re??me.nextBefore)}).catch(()=>{le&&h([]),Le(!0)}).finally(()=>j(!1))},[_e,o,s]),X=f.useCallback(()=>{!ue||Ce||(ke(!0),Le(!1),_e(ue).then($=>{h(le=>Df(le,$.receipts)),ve($.nextBefore)}).catch(()=>Le(!0)).finally(()=>ke(!1)))},[ue,Ce,_e]);nn(he,12e4),f.useEffect(()=>{D.getIntegrationManifests().then(({manifests:$})=>p($)).catch(()=>{}),fetch("/health").then($=>$.json()).then($=>{typeof $.spUrl=="string"&&v($.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),f.useEffect(()=>{D.getLocalAuthorizations().then(({authorizations:$,signatures:le})=>{pe($),V(le),W(!1)}).catch(()=>{pe({}),V({}),W(!0)}),D.getMyAttestations().then($=>{const le={};for(const me of $)me.authorization_id&&me.title&&(le[me.authorization_id]=me.title);A(le)}).catch(()=>{})},[]),f.useEffect(()=>{o!=="team"||Object.keys(N).length>0||D.listUsers().then($=>{const le={};for(const me of $)le[me.id]={name:me.name,email:me.email};E(le)}).catch(()=>{})},[o,N]);const we=f.useMemo(()=>{const $=new Set;for(const le of d)$.add(dt(le.profileId));return[...$].sort()},[d]),Te=f.useMemo(()=>{const $=new Set;for(const le of d)$.add(le.action);return[...$].sort()},[d]),$e=f.useMemo(()=>{if(o!=="team")return[];const $=new Set;for(const le of d)le.userId&&$.add(le.userId);return[...$].map(le=>{var me;return{id:le,label:(me=N[le])!=null&&me.name?`${N[le].name} (${N[le].email})`:le}}).sort((le,me)=>le.label.localeCompare(me.label))},[o,d,N]),lt=f.useMemo(()=>d.filter($=>!(!Mw($,T)||L.size>0&&!L.has(dt($.profileId))||F.size>0&&!F.has($.action)||S.size>0&&$.userId&&!S.has($.userId)||!Ow($,H))),[d,T,L,F,S,H]),xt=L.size>0||F.size>0||S.size>0||H!=="all";function Ke($){P(le=>{const me=new Set(le);return me.has($)?me.delete($):me.add($),me})}function et($){G(le=>{const me=new Set(le);return me.has($)?me.delete($):me.add($),me})}function st($){C(le=>{const me=new Set(le);return me.has($)?me.delete($):me.add($),me})}function mt(){P(new Set),G(new Set),C(new Set),ie("all"),R("")}async function Fe(){M(!0),oe(null);try{const{bundle:$,filename:le}=await D.fetchEvidenceBundle(),me=URL.createObjectURL(new Blob([JSON.stringify($,null,2)],{type:"application/json"})),Re=document.createElement("a");Re.href=me,Re.download=le,Re.click(),URL.revokeObjectURL(me);const de=$.sources??{};de.authorityServer?de.local||oe(`Downloaded Authority Server history only — ${de.localError??"local archive unavailable."}`):oe(`Downloaded local evidence only — ${de.asError??"Authority Server export unavailable."}`)}catch($){oe(`Export failed: ${$ instanceof Error?$.message:String($)}`)}finally{M(!1)}}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:"Tickets"}),r.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),r.jsx("button",{className:"btn btn-secondary",onClick:Fe,disabled:J,children:J?"Preparing…":"Download evidence"})]}),fe&&r.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:fe}),a&&r.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map($=>r.jsx("button",{onClick:()=>c($),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:o===$?"2px solid var(--accent)":"2px solid transparent",color:o===$?"var(--text-primary)":"var(--text-tertiary)",fontWeight:o===$?600:500},children:$==="mine"?"Mine":"Team"},$))}),r.jsxs("div",{className:"search-filter-bar",children:[r.jsxs("div",{className:"search-input-wrap",children:[r.jsx("span",{className:"search-icon",children:"⌕"}),r.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:T,onChange:$=>R($.target.value)}),T&&r.jsx("button",{className:"search-clear",onClick:()=>R(""),children:"×"})]}),r.jsxs("button",{className:`btn btn-sm btn-secondary${Y?" active":""}`,onClick:()=>re(!Y),children:["Filters",xt?` (${L.size+F.size+(H!=="all"?1:0)})`:""]})]}),Y&&r.jsxs("div",{className:"filter-panel",children:[we.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Profile"}),r.jsx("div",{className:"filter-chips",children:we.map($=>r.jsx("button",{className:`filter-chip${L.has($)?" selected":""}`,onClick:()=>Ke($),children:$},$))})]}),Te.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Action"}),r.jsx("div",{className:"filter-chips",children:Te.map($=>r.jsx("button",{className:`filter-chip${F.has($)?" selected":""}`,onClick:()=>et($),children:$},$))})]}),o==="team"&&$e.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Owner"}),r.jsx("div",{className:"filter-chips",children:$e.map($=>r.jsx("button",{className:`filter-chip${S.has($.id)?" selected":""}`,onClick:()=>st($.id),children:$.label},$.id))})]}),r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Time range"}),r.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([$,le])=>r.jsx("button",{className:`filter-chip${H===$?" selected":""}`,onClick:()=>ie($),children:le},$))})]})]}),xt&&r.jsxs("div",{className:"active-filters",children:[[...L].map($=>r.jsxs("span",{className:"active-chip",onClick:()=>Ke($),children:[$," ",r.jsx("span",{className:"chip-remove",children:"×"})]},$)),[...F].map($=>r.jsxs("span",{className:"active-chip",onClick:()=>et($),children:[$," ",r.jsx("span",{className:"chip-remove",children:"×"})]},$)),[...S].map($=>{const le=N[$],me=le?le.name:$;return r.jsxs("span",{className:"active-chip",onClick:()=>st($),children:[me," ",r.jsx("span",{className:"chip-remove",children:"×"})]},$)}),H!=="all"&&r.jsxs("span",{className:"active-chip",onClick:()=>ie("all"),children:[H==="1d"?"Today":H==="7d"?"7 days":"30 days"," ",r.jsx("span",{className:"chip-remove",children:"×"})]}),r.jsx("button",{className:"clear-filters",onClick:mt,children:"Clear all"})]}),se&&r.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:r.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."})}),w&&d.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):lt.length===0?r.jsx(Zr,{icon:"⌕",title:d.length===0?"No tickets in the last 30 days":"No matching tickets",text:d.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:lt.length===d.length?`${d.length} ticket${d.length!==1?"s":""}`:`${lt.length} of ${d.length} tickets`}),r.jsx("div",{className:"timeline",children:lt.map($=>{const le=$.userId?N[$.userId]:void 0;return r.jsx("div",{className:"timeline-event",children:r.jsx(Lw,{receipt:$,manifests:y,localAuth:$.authorizationId?Z[$.authorizationId]:void 0,localUnavailable:ee,signature:B[$.id],grantTitle:$.authorizationId?k[$.authorizationId]:null,ownerLabel:o==="team"&&$.userId?le?`${le.name} (${le.email})`:$.userId:null,spUrl:g,formatDate:Fw,onOpenComplete:()=>te($)})},$.id)})})]}),K&&r.jsx(zw,{receipt:K,onClose:()=>te(null)}),ue&&r.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:X,disabled:Ce,children:Ce?"Loading…":"Load older"})})]})}function Dw(){const[t,s]=f.useState(null),[a,o]=f.useState({}),[c,d]=f.useState(!1),h=f.useCallback(()=>{D.getDenials({limit:200}).then(({records:p})=>{s(p),d(!1)}).catch(()=>d(!0))},[]);if(f.useEffect(()=>{h()},[h]),nn(h,6e4),f.useEffect(()=>{if(!t)return;const p=[...new Set(t.map(g=>g.profile).filter(g=>!!g))].filter(g=>!(g in a));p.length!==0&&Promise.all(p.map(g=>D.getProfile(g).catch(()=>null))).then(g=>{o(v=>{const w={...v};return p.forEach((j,N)=>{g[N]&&(w[j]=g[N])}),w})})},[t,a]),c)return r.jsx(Zr,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(t===null)return null;const y=Ph(t,Date.now());return r.jsxs("div",{className:"blocked-page",children:[r.jsxs("div",{className:"page-header blocked-header",children:[r.jsx("h1",{className:"page-title",children:"Blocked actions"}),r.jsxs("span",{className:"blocked-today",children:[y," today · nothing ran"]})]}),t.length===0?r.jsx(Zr,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):r.jsx("div",{className:"blocked-list",children:t.map((p,g)=>{const v=Bv(p,p.profile?a[p.profile]:void 0);return r.jsxs("div",{className:"blocked-row","data-kind":Ys(p),children:[r.jsx("span",{className:`blocked-dot blocked-dot-${Ys(p)}`,"aria-hidden":"true"}),r.jsxs("div",{className:"blocked-row-main",children:[r.jsx("div",{className:"blocked-title",children:v.title}),r.jsx("div",{className:"blocked-sentence",children:v.sentence}),r.jsx("div",{className:"blocked-source",children:v.sourceLine}),r.jsxs("details",{children:[r.jsx("summary",{children:"What you can do"}),r.jsx("div",{className:"blocked-advice",children:v.whatYouCanDo})]})]}),r.jsx("div",{className:"blocked-when",children:new Date(p.ts).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},`${p.ts}-${g}`)})})]})}const Uw={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function Ww(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,d]=f.useState(null),h=f.useCallback(async()=>{try{s(await D.getAutostart())}catch(g){d(g instanceof Error?g.message:"Could not read autostart state")}},[]);f.useEffect(()=>{h()},[h]);const y=f.useCallback(async()=>{if(!(!(t!=null&&t.supported)||a)){o(!0),d(null);try{await D.setAutostart(!t.installed)}catch(g){d(g instanceof Error?g.message:"Failed")}finally{try{s(await D.getAutostart()),d(null)}catch(g){d(g instanceof Error?g.message:"Could not re-read state")}o(!1)}}},[t,a,h]);if(!t)return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read autostart state: ${c}`:"Checking…"})]});const p=Uw[t.platform]??"a login service";return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),r.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:t.supported?r.jsxs(r.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",p," — no admin rights needed."]}):t.reason})]}),t.supported&&r.jsx("button",{type:"button",onClick:()=>void y(),disabled:a,"aria-pressed":t.installed,className:t.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Working…":t.installed?"Turn off":"Turn on"})]}),t.supported&&r.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",r.jsx("strong",{children:t.installed?"On — starts from your next login":"Off"})]}),t.supported&&r.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 ",r.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger, #c00)"},children:c})]})}function Hw(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,d]=f.useState(null),h=f.useCallback(async()=>{try{const p=await D.getGatewaySettings();s(p.desktopNotifications),d(null)}catch(p){d(p instanceof Error?p.message:"Could not read notification setting")}},[]);f.useEffect(()=>{h()},[h]);const y=f.useCallback(async()=>{if(!(t===null||a)){o(!0),d(null);try{const p=await D.setGatewaySettings({desktopNotifications:!t});s(p.desktopNotifications)}catch(p){d(p instanceof Error?p.message:"Failed to save"),await h()}finally{o(!1)}}},[t,a,h]);return t===null?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read the setting: ${c}`:"Checking…"})]}):r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),r.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."})]}),r.jsx("button",{type:"button",onClick:()=>void y(),disabled:a,"aria-pressed":t,className:t?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":t?"Turn off":"Turn on"})]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:c})]})}const Uf={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function Vw(){const[t,s]=f.useState(null),[a,o]=f.useState(!1),[c,d]=f.useState(null),h=f.useCallback(async()=>{try{s(await D.getIdentityDisclosure()),d(null)}catch(v){d(v instanceof Error?v.message:"Could not read the setting")}},[]);f.useEffect(()=>{h()},[h]);const y=f.useCallback(async()=>{if(!(!t||a)){o(!0),d(null);try{s(await D.setIdentityDisclosure(!t.always))}catch(v){d(v instanceof Error?v.message:"Failed to save"),await h()}finally{o(!1)}}},[t,a,h]),p=r.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!t)return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[p,r.jsx("p",{role:c?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:c?`Could not read the setting: ${c}`:"Checking…"})]});const g=t.verified&&t.name?`${t.name} — ${t.method==="as_vouched"?`${Uf.as_vouched} ${t.verifier}`:Uf[t.method??""]??t.method}`:null;return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[p,r.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[t.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."]}),r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:g?`Your identity: ${g}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),r.jsx("button",{type:"button",onClick:()=>void y(),disabled:a,"aria-pressed":t.always,className:t.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":t.always?"Turn off":"Always show my name"})]}),c&&r.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:c})]})}const Gw={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 Kw(){const{version:t,latestVersion:s,updateAvailable:a,installMethod:o}=ac();return t?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",r.jsx("strong",{children:t}),a&&s?r.jsxs(r.Fragment,{children:[" — ",r.jsx("strong",{children:s})," is available"]}):null]}),r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[Gw[o]??"Update checking is unavailable",o==="dev"&&r.jsx(r.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Hl({title:t}){return r.jsxs("span",{className:"it-locked-badge",title:t,children:[r.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function Wf(t){return t===!0}function Yw(){const[t,s]=f.useState(null),[a,o]=f.useState(null);f.useEffect(()=>{let h=!1;return D.getAsPairing().then(y=>{h||s(y)}).catch(y=>{h||o(y instanceof Error?y.message:"Could not read Authority Server info")}),()=>{h=!0}},[]);const c=Wf(t==null?void 0:t.asUrlLockedByPolicy),d=Wf(t==null?void 0:t.pinTlsLockedByPolicy);return r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),c&&r.jsx(Hl,{})]}),!t&&!a&&r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),a&&r.jsx("p",{role:"alert",style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--danger, #c00)"},children:a}),t&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"URL:"})," ",r.jsx("code",{children:t.asUrl})]}),t.paired&&t.fingerprint?r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"Key fingerprint:"})," ",r.jsx("code",{children:t.fingerprint}),r.jsx("br",{}),r.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."})]}):r.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."}),(t.tlsPinFingerprint||t.pinTlsEnabled)&&r.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[r.jsx("strong",{children:"TLS certificate pin:"})," ",d&&r.jsx(Hl,{title:"TLS pinning is set by your IT policy"})," ",t.tlsPinFingerprint?r.jsx("code",{children:t.tlsPinFingerprint}):r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",t.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),r.jsx("br",{}),r.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[t.pinTlsEnabled?r.jsxs(r.Fragment,{children:["TLS pinning is ON",d?r.jsx(r.Fragment,{children:", set by your organization's IT policy"}):r.jsxs(r.Fragment,{children:[" (",r.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."]}):r.jsxs(r.Fragment,{children:["Captured at sign-in; not currently enforced",d?r.jsx(r.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):r.jsxs(r.Fragment,{children:[" (",r.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."]})]}),c?r.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."}):r.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:"," ",r.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 Jw(){const{simulation:t,locked:s}=Uh();return s?r.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[r.jsxs("div",{children:[r.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),r.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.',t!==null&&r.jsxs(r.Fragment,{children:[" ","Currently ",r.jsx("strong",{children:t?"ON":"OFF"}),t?" — real systems are not reachable from this gateway.":"."]})]})]}),r.jsx(Hl,{})]}),r.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",t!==null?` (currently ${t?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const qw={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"]}},Us=["AI Assistant","Authority Server","This computer","Security","Version"],Ws={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function Qw(){const[t,s]=f.useState(""),[a,o]=f.useState("openrouter"),[c,d]=f.useState("openai-compatible"),[h,y]=f.useState("https://openrouter.ai/api/v1"),[p,g]=f.useState("google/gemma-4-31b-it"),[v,w]=f.useState(""),[j,N]=f.useState(!1),[E,S]=f.useState(!1),[C,T]=f.useState(!1),[R,L]=f.useState(null),[P,F]=f.useState([]),[G,H]=f.useState(!1),[ie,Y]=f.useState(null),[re,J]=f.useState(""),M=f.useCallback(B=>{s(B),setTimeout(()=>s(""),3e3)},[]),fe=f.useCallback(async(B,V,k)=>{H(!0),Y(null);try{const A=await D.aiModels({provider:B,endpoint:V,...k?{apiKey:k}:{}});A.ok&&A.models.length>0?(F(A.models),Y(`${A.models.length} models available`)):(F([]),Y(A.message||"No models returned — using defaults"))}catch(A){F([]),Y(A instanceof Error?A.message:"Failed to load models")}finally{H(!1)}},[]),oe=f.useCallback(async()=>{try{const B=await D.getCredential("ai-config");if(N(B.configured),B.configured&&B.fields){const V=B.fields.provider||"openai-compatible",k=B.fields.endpoint||"";B.fields.provider&&d(V),B.fields.endpoint&&y(k),B.fields.model&&g(B.fields.model),k.includes("openai.com")?o("openai"):k.includes("groq.com")?o("groq"):k.includes("together.xyz")?o("together"):k.includes("openrouter.ai")?o("openrouter"):o("ollama"),k&&fe(V,k)}}catch{}},[fe]);f.useEffect(()=>{oe()},[oe]);const Z=B=>{o(B),F([]),Y(null),J("");const V=qw[B];V&&(d(V.provider),y(V.endpoint),g(""),fe(V.provider,V.endpoint,v||void 0))},pe=()=>fe(c,h,v||void 0),ee=async()=>{S(!0);try{await D.setCredential("ai-config",{provider:c,endpoint:h,model:p,...v?{apiKey:v}:{}}),N(!0),M("AI configuration saved!")}catch{M("Failed to save AI config")}finally{S(!1)}},W=async()=>{T(!0),L(null);try{const B=await D.aiTest({provider:c,endpoint:h,model:p,...v?{apiKey:v}:{}});L(B.ok?`OK: ${B.message}`:`Failed: ${B.message}`)}catch(B){L(`Error: ${B instanceof Error?B.message:"Unknown"}`)}finally{T(!1)}};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Settings"}),r.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),t&&r.jsx("div",{className:"alert alert-success",children:t}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ws,children:Us[0]}),r.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),r.jsxs("div",{className:"card",children:[r.jsx("h3",{className:"card-title",children:"Configuration"}),r.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."}),j&&r.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[r.jsx("span",{className:"status-banner-icon",children:"✓"}),r.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsx("label",{className:"form-label",children:"Provider Preset"}),r.jsxs("select",{className:"form-input",value:a,onChange:B=>Z(B.target.value),children:[r.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),r.jsx("option",{value:"ollama",children:"Ollama (local)"}),r.jsx("option",{value:"openai",children:"OpenAI"}),r.jsx("option",{value:"groq",children:"Groq"}),r.jsx("option",{value:"together",children:"Together"})]})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsxs("label",{className:"form-label",children:["API Key ",c==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),r.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:v,onChange:B=>w(B.target.value),onBlur:()=>{v.trim()&&fe(c,h,v.trim())},placeholder:j?"••••••••••••••••":"sk-... (not needed for Ollama)"}),r.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."})]}),r.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r.jsx("label",{className:"form-label",children:"Model"}),r.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:pe,disabled:G,title:"Re-fetch the model list from the provider",children:G?"Loading…":"↻ Refresh"})]}),P.length===0?r.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:G?"Loading models…":c==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const B=P,V=B.includes(p),k=B.length>12,A=re.trim().toLowerCase();let K=A?B.filter(te=>te.toLowerCase().includes(A)):B;return V&&!K.includes(p)&&(K=[p,...K]),r.jsxs(r.Fragment,{children:[k&&r.jsx("input",{className:"form-input",value:re,onChange:te=>J(te.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),r.jsxs("select",{className:"form-input",value:V?p:"__unset__",onChange:te=>g(te.target.value==="__unset__"?"":te.target.value),children:[r.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),K.map(te=>r.jsx("option",{value:te,children:te},te)),A&&K.length===0&&r.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",re,"”"]})]})]})})(),ie&&r.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:ie})]}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[r.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:E||!p.trim(),title:p.trim()?void 0:"Select a model first",children:E?"Saving...":"Save & Encrypt"}),j&&r.jsx("button",{className:"btn btn-ghost",onClick:W,disabled:C,children:C?"Testing...":"Test Connection"})]}),R&&r.jsx("div",{className:`alert ${R.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:R})]}),r.jsx(Xw,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ws,children:Us[1]}),r.jsx(Yw,{}),r.jsx(Vw,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ws,children:Us[2]}),r.jsx(Ww,{}),r.jsx(Hw,{}),r.jsx(Jw,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ws,children:Us[3]}),r.jsx("div",{className:"card",style:{padding:"1.5rem"},children:r.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[r.jsxs("div",{style:{marginBottom:"1rem"},children:[r.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),r.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[r.jsx("li",{children:"Every tool call verified against your mandate bounds"}),r.jsx("li",{children:"Credentials never exposed to agents through MCP"}),r.jsx("li",{children:"Every action produces a signed ticket"})]})]}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),r.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[r.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),r.jsx("li",{children:"For best security, run agents in sandboxed environments"}),r.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})})]}),r.jsxs("section",{children:[r.jsx("h2",{style:Ws,children:Us[4]}),r.jsx(Kw,{})]})]})}function Xw(){const[t,s]=f.useState(null),[a,o]=f.useState({intent:"",context:""}),[c,d]=f.useState(null),[h,y]=f.useState(null),[p,g]=f.useState(null),[v,w]=f.useState(!1),j=f.useCallback(async()=>{if(!v)try{const S=await D.getAIPrompts();s(S),o({intent:S.intent.current,context:S.context.current}),w(!0)}catch(S){y(S instanceof Error?S.message:"Failed to load prompts")}},[v]),N=async S=>{if(t){d(S),y(null);try{const C=a[S],T=C.trim()===t[S].default.trim()?"":C;await D.setAIPrompt(S,T);const R=await D.getAIPrompts();s(R),o({intent:R.intent.current,context:R.context.current}),g(S),setTimeout(()=>g(null),2e3)}catch(C){y(C instanceof Error?C.message:"Save failed")}finally{d(null)}}},E=async S=>{if(confirm(`Revert ${S} prompt to the built-in default?`)){d(S),y(null);try{await D.setAIPrompt(S,"");const C=await D.getAIPrompts();s(C),o({intent:C.intent.current,context:C.context.current})}catch(C){y(C instanceof Error?C.message:"Revert failed")}finally{d(null)}}};return r.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:S=>{S.currentTarget.open&&j()},children:[r.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),r.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."}),h&&r.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:h}),!v&&!h&&r.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),t&&r.jsxs(r.Fragment,{children:[r.jsx(Hf,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:t.intent,draft:a.intent,onChange:S=>o(C=>({...C,intent:S})),onSave:()=>N("intent"),onRevert:()=>E("intent"),saving:c==="intent",justSaved:p==="intent"}),r.jsx(Hf,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:t.context,draft:a.context,onChange:S=>o(C=>({...C,context:S})),onSave:()=>N("context"),onRevert:()=>E("context"),saving:c==="context",justSaved:p==="context"})]})]})}function Hf({kind:t,label:s,description:a,state:o,draft:c,onChange:d,onSave:h,onRevert:y,saving:p,justSaved:g}){const v=c!==o.current;return r.jsxs("section",{style:{marginBottom:"1.5rem"},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:s}),r.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:a})]}),o.overridden&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),r.jsx("textarea",{className:"form-textarea",value:c,onChange:w=>d(w.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":`${s} system prompt`}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[r.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:h,disabled:p||!v,children:p?"Saving…":"Save"}),o.overridden&&r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:y,disabled:p,title:"Discard the override and use the built-in default",children:"Revert to default"}),g&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),v&&!p&&!g&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),r.jsxs("details",{style:{marginTop:"0.5rem"},children:[r.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),r.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:o.default})]}),r.jsx("span",{style:{display:"none"},children:t})]})}function Zw(t){return t.proposalId?"review":"automatic"}function Vf(t,s,a={}){const o=a.status??"pending",c=a.includeAutonomous??!1,d=[];for(const h of t)o==="pending"&&h.status!=="pending"||a.profile&&h.profileId!==a.profile||d.push({kind:"proposal",id:h.id,sortTimestamp:h.createdAt,commitmentMode:"review",profileId:h.profileId,proposal:h});if(o==="all")for(const h of s){const y=Zw(h);!c&&y==="automatic"||a.profile&&h.profileId!==a.profile||d.push({kind:"receipt",id:h.id,sortTimestamp:h.timestamp,commitmentMode:y,profileId:h.profileId,receipt:h})}return d.sort((h,y)=>y.sortTimestamp-h.sortTimestamp),typeof a.limit=="number"&&a.limit>0?d.slice(0,a.limit):d}const ej=["https://","http://"];function hm(t,s){return t!=null&&t.length?t.flatMap(a=>{const o=a.template.replace(/\{(\w+)\}/g,(c,d)=>{const h=s[d];return typeof h=="string"||typeof h=="number"?String(h):"\0"});return o.includes("\0")||/\{|\}/.test(o)?[]:ej.some(c=>o.toLowerCase().startsWith(c))?[{label:a.label,href:o,description:a.description}]:[]}):[]}function mm(t,s){const a=t-Math.floor(s/1e3);if(a<=0)return{label:"expired",urgent:!1,expired:!0};const o=Math.floor(a/86400),c=Math.floor(a%86400/3600),d=Math.floor(a%3600/60);let h;return o>0?h=`expires in ${o}d ${c}h`:c>0?h=`expires in ${c}h ${d}m`:h=`expires in ${Math.max(1,d)}m`,{label:h,urgent:a<2*3600,expired:!1}}const tj=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function nj(t,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:tj.test(t)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function qr(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Gf({row:t,which:s}){const a=ea(t.profileRef),o=aw(t.value,a,s);return o.length===0?r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:o.map(c=>r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-secondary)"},title:c.hint,children:c.label}),r.jsxs("dd",{style:{margin:0,fontWeight:600},children:[c.value,c.unknown&&r.jsx("span",{style:{color:"var(--danger)",fontWeight:400,marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},c.key))})}function rj({row:t}){const s=ea(t.profileRef),a=(s==null?void 0:s.id)??t.profileRef??"";return r.jsxs(r.Fragment,{children:[(s==null?void 0:s.name)??dt(a),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function sj({row:t,altText:s}){switch(t.kind){case"profile":return r.jsx(rj,{row:t});case"profile-limits":return r.jsx(Gf,{row:t,which:"limits"});case"profile-scope":return r.jsx(Gf,{row:t,which:"scope"});case"markdown":return r.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:qr(t.value)});case"list":return Array.isArray(t.value)?r.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:t.value.map((a,o)=>r.jsx("li",{children:qr(a)},o))}):r.jsx(r.Fragment,{children:qr(t.value)});case"money":return r.jsxs(r.Fragment,{children:[qr(t.value),t.currency?` ${t.currency}`:""]});case"object":return r.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:qr(t.value)});default:return nj(t.key,t.value)?r.jsx("img",{src:t.value,alt:s??t.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):r.jsx(r.Fragment,{children:qr(t.value)})}}function pm({args:t,display:s,heading:a="Details"}){const o=sw(t,s);if(o.length===0)return null;const c=typeof t.altText=="string"?t.altText:void 0;return r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a&&r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:a}),r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:o.map(d=>r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:d.hint,children:d.label}),r.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:r.jsx(sj,{row:d,altText:c})})]},d.key))})]})}const Kf=500;function Vl(t){return t.length>Kf?`${t.slice(0,Kf)}…`:t}function Yf(t){return t.length?t[0].toUpperCase()+t.slice(1):t}function aj(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Jf(t,s,a){switch(t.status){case"none":return t.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 ${s}.`}:{heading:"No preview declared",note:`No preview declared for this tool — showing exactly what will be sent to ${s}.`};case"unavailable":return t.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:t.message?`Preview not available — ${Vl(t.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:t.message?`Not found in your system — ${Vl(t.message)}`:"Not found in your system."};case"ok":{if("reads"in t)return{heading:`What will be created in ${s}`,note:`Read by the gateway, not by the AI — read at ${aj(t.readAt)}.`,creation:Iw(a??{},t.reads,t.display)};const o=Ei(t.body,{fields:t.fields}),c={heading:`From ${s}, before it runs`,note:`Read by the gateway with ${t.tool} when you opened this card — the AI is not involved.`,rendered:o},d=t.version;if(d&&(c.versionNote=`You approve ${d.field} ${d.approved}; if it changes, ${s} refuses it.`,d.stale)){const h=jw(t.body,d.currentBody,{fields:t.fields,excludeKey:d.field});c.stale={heading:`A newer ${d.field} exists (${d.current})`,approvedLabel:`${Yf(d.field)} ${d.approved}`,currentLabel:`${Yf(d.field)} ${d.current}`,...h.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:h.approved,currentRendered:h.current}}}return c}}}function ij(t,s){if(t.state!=="failed")return null;const a=t.detail?Vl(t.detail):void 0;return t.outcome==="changed"?{heading:"Changed since your approval",note:`The record changed in ${s} since you approved it — nothing was done. Ask the AI to request it again.`}:{heading:`Refused by ${s}`,note:`${s} refused it${a?`: ${a}`:""} — nothing was done. Ask the AI to request it again.`}}function oj(t){return t!==null&&t!=="loading"&&t!=="ok"&&t!=="stale"}function lj({proposalId:t,systemName:s}){const[a,o]=f.useState(null);if(f.useEffect(()=>{let d=!0;return o(null),D.getProposalOutcome(t).then(h=>{d&&o(h)}).catch(()=>{}),()=>{d=!1}},[t]),!a)return null;const c=ij(a,s);return c?r.jsxs("div",{className:"outcome-box",children:[r.jsx("h4",{children:c.heading}),r.jsx("p",{className:"outcome-note",children:c.note})]}):null}function cj({identity:t}){return t.unresolved?r.jsxs("span",{children:[r.jsx("span",{className:"id-raw",children:t.rawId})," ",r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["— ",t.unresolved]})]}):r.jsxs("span",{children:[t.name&&r.jsx("span",{className:"src-tag-value src-tag-system-cell",children:t.name})," ",r.jsx("span",{className:"id-raw",children:t.rawId}),t.context.length>0&&r.jsx("span",{className:"creation-context",children:t.context.map(s=>r.jsxs("span",{children:[" · ",s.label," ",s.value]},s.key))})]})}function uj({view:t}){return r.jsxs(r.Fragment,{children:[r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:t.rows.map(s=>s.kind==="table"?null:r.jsxs(f.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:s.label}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:s.kind==="identity"?r.jsx(cj,{identity:s.identity}):r.jsx("span",{className:"src-tag-value src-tag-sealed-cell",title:s.valueTitle,children:s.value})})]},s.key))}),t.rows.filter(s=>s.kind==="table").map(s=>r.jsxs("div",{style:{margin:"0.5rem 0"},children:[r.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:s.label}),r.jsx(Ri,{table:s.table})]},s.key)),t.sections.map((s,a)=>r.jsxs("div",{className:"creation-own-section",children:[r.jsxs("h5",{children:[s.heading," ",r.jsx("span",{className:"src-tag src-tag-system",children:"from the system"})]}),s.table&&r.jsx(Ri,{table:s.table}),s.body&&r.jsx(Wl,{rows:s.body.fields}),s.note&&r.jsx("p",{className:"preview-note",children:s.note})]},a)),r.jsxs("p",{className:"creation-legend",children:[r.jsxs("span",{children:[r.jsx("i",{className:"creation-legend-dot creation-legend-dot-sealed"}),"bold black = sealed: approved and executed exactly so"]}),r.jsxs("span",{children:[r.jsx("i",{className:"creation-legend-dot creation-legend-dot-system"}),"blue = from the system: read by the gateway, not by the AI"]})]})]})}function dj({proposalId:t,systemName:s,toolArgs:a,sealed:o,onTone:c}){const[d,h]=f.useState(null),[y,p]=f.useState(!1);if(f.useEffect(()=>{let w=!0;return h(null),p(!1),D.getProposalPreview(t).then(j=>{w&&h(j)}).catch(()=>{w&&p(!0)}),()=>{w=!1}},[t]),f.useEffect(()=>{if(y){c==null||c("unavailable");return}if(!d)return;const w=Jf(d,s,a??void 0);c==null||c(d.status==="ok"?w.stale?"stale":"ok":d.status)},[d,y,s,c]),y)return r.jsxs("div",{className:"preview-box preview-box-unavailable","data-testid":"approval-preview","data-preview-status":"unavailable",children:[r.jsx("h4",{children:"Preview not available"}),r.jsx("p",{className:"preview-note",children:"Preview not available on this gateway."})]});if(!d)return r.jsxs("div",{className:"preview-box preview-box-loading","data-testid":"approval-preview","data-preview-status":"loading","aria-busy":"true",children:["Reading from ",s,"…"]});const g=Jf(d,s,a??void 0),v=d.status==="ok"?g.stale?"stale":"ok":d.status;return v==="none"?r.jsx("p",{className:"preview-note","data-testid":"approval-preview","data-preview-status":"none",children:g.note}):r.jsxs("div",{className:`preview-box preview-box-${v}`,"data-testid":"approval-preview","data-preview-status":v,children:[r.jsxs("h4",{children:[g.heading,g.creation&&(o?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})," ",r.jsx("span",{className:"lock-tag",children:"end-to-end encrypted"})]}):r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"}))]}),g.creation&&r.jsx(uj,{view:g.creation}),g.rendered&&r.jsx(xi,{rendered:g.rendered}),r.jsx("p",{className:"preview-note",children:g.note}),g.versionNote&&!g.stale&&r.jsx("p",{className:"preview-note",children:g.versionNote}),g.stale&&r.jsxs("div",{className:"preview-stale",children:[r.jsx("h5",{children:g.stale.heading}),g.stale.unchangedNote?r.jsx("p",{className:"preview-note",children:g.stale.unchangedNote}):r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.5rem 0 0"},children:[r.jsx("dt",{children:g.stale.approvedLabel}),r.jsx("dd",{children:r.jsx(xi,{rendered:g.stale.approvedRendered})}),r.jsx("dt",{children:g.stale.currentLabel}),r.jsx("dd",{children:r.jsx(xi,{rendered:g.stale.currentRendered})})]})]})]})}let Il=null;function fj(){return Il||(Il=D.getEnrichedAuthorizations().then(t=>new Map(t.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),Il}function hj(t){const[s,a]=f.useState(void 0);return f.useEffect(()=>{let o=!0;if(t)return fj().then(c=>{o&&a(c.get(t))}),()=>{o=!1}},[t]),s}function mj(t,s){const[a,o]=f.useState(null),[c,d]=f.useState(!1),[h,y]=f.useState(null);return f.useEffect(()=>{let p=!0;return o(null),y(null),d(!0),(async()=>{var g;try{try{const j=await D.getGateContent(t);if((g=j==null?void 0:j.gateContent)!=null&&g.intent){p&&o(j.gateContent.intent);return}}catch{}const v=await D.getAttestationIntent(t);if(!v){p&&y("Intent not available or you are not an authorized approver.");return}const w=await D.decryptIntent({intentCiphertext:v.intentCiphertext,encryptedKey:v.encryptedKey,approverId:s});p&&o(w)}catch(v){p&&y(v instanceof Error?v.message:"Failed to decrypt intent")}finally{p&&d(!1)}})(),()=>{p=!1}},[t,s]),{intent:a,loading:c,error:h}}async function gm(t){if(t.toolArgs)return t.toolArgs;if(!t.content)return null;try{const{plaintext:s}=await D.decryptProposalContent(t.content),a=JSON.parse(s);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function pj(t){if(!t.content)return[];const s=new Set([...t.createdBy?[t.createdBy]:[],...t.pendingApprovers??[]]),a=new Set(Object.keys(t.content.keys));return Array.from(s).filter(o=>!a.has(o))}function ym(t){return!t.loading&&t.readable}function vm(t,s){const a=new Set;if(t.content)for(const o of Object.keys(t.content.keys))a.add(o);else{t.createdBy&&a.add(t.createdBy);for(const o of t.pendingApprovers??[])a.add(o)}return s&&a.add(s),Array.from(a)}async function wi(t){const s=await gm(t);if(s)return om("jcs",s)}function gj(t){var o;const[s,a]=f.useState((t==null?void 0:t.note)??null);return f.useEffect(()=>{let c=!0;if(t!=null&&t.note){a(t.note);return}if(!(t!=null&&t.noteEncrypted)){a(null);return}return a(null),D.decryptProposalContent(t.noteEncrypted).then(({plaintext:d})=>{c&&a(d)}).catch(()=>{c&&a(null)}),()=>{c=!1}},[t==null?void 0:t.note,(o=t==null?void 0:t.noteEncrypted)==null?void 0:o.ciphertext]),s}const yj={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function xm(t){var o;const[s,a]=f.useState(yj);return f.useEffect(()=>{let c=!0;if(t.toolArgs){a({toolArgs:t.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!t.content){a({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return a({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const d=await gm(t);c&&a({toolArgs:d,loading:!1,sealed:!0,undecryptable:d===null})})(),()=>{c=!1}},[(o=t.content)==null?void 0:o.ciphertext,t.toolArgs]),s}function qf(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const s={};for(const[a,o]of Object.entries(t))(typeof o=="string"||typeof o=="number")&&(s[a]=o);return s}function vj(t){const s=qf(t.limits),a=qf(t.scope),o=typeof t.intent=="string"?t.intent:"",c={bounds:s,context:a,gateContent:{intent:o}};return(t.mode==="automatic"||t.mode==="review")&&(c.templateMode=t.mode),typeof t.duration_hours=="number"&&t.duration_hours>0&&(c.templateTtl=Math.round(t.duration_hours*3600)),c}function wm(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.map(s=>wm(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}const xj="setup__create_mandate";function jm({proposal:t,currentUserId:s,proposalLinks:a,toolDisplay:o,manifests:c,onContentState:d}){const[h,y]=f.useState(!1),[p,g]=f.useState(!1),[v,w]=f.useState(null),j=mn(),{group:N,groupId:E,domain:S}=vt(),C=Object.entries(t.executionContext),T=ea(t.profileId),R=hj(t.authorizationId),L=dw(t.executionContext,R,T),P=nw(t.tool),{integrationId:F}=vc(t.tool),G=am(F,c),{intent:H,loading:ie,error:Y}=mj(t.authorizationId,s),re=xm(t),J=re.toolArgs!==null;f.useEffect(()=>{d==null||d({loading:re.loading,readable:J})},[re.loading,J]);const M=pj(t),fe=re.toolArgs?hm(a,re.toolArgs):[],oe=async()=>{if(!E){w("No active workspace; cannot open the mandate screen.");return}g(!0),w(null);try{if(!re.toolArgs){w("This content is not readable on this device yet.");return}const B=re.toolArgs,V=typeof B.profile=="string"?B.profile:"",k=await D.listProfiles(),A=tm(V,k);if(!A){w(`Unknown profile "${V}".`);return}const K=await D.getProfile(A.id),te=vj(B),ue=rm(te.bounds,K),ve=sm(te.context,K);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:A.id,groupId:E,groupName:(N==null?void 0:N.name)??null,domain:S,isPersonal:!!(N!=null&&N.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...te,bounds:ue,context:ve})),sessionStorage.setItem("agentReplacesProposal",t.id),j("/mandates/new/intent")}catch(B){w(B instanceof Error?B.message:"Could not open the mandate screen.")}finally{g(!1)}},[Z,pe]=f.useState(null),ee=oj(Z),W=re.toolArgs?r.jsxs(r.Fragment,{children:[r.jsx(pm,{args:re.toolArgs,display:o,heading:""}),C.length>0&&r.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:C.map(([B,V],k)=>{const{label:A,hint:K}=im(B,T);return r.jsxs("span",{children:[k>0&&" · ",r.jsxs("span",{title:K,children:[A,"=",wm(V)]})]},B)})})]}):null;return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"approval-headline",children:P}),re.sealed&&re.undecryptable&&r.jsxs("div",{className:"preview-box","data-testid":"proposal-undecryptable",style:{marginBottom:"0.5rem"},children:[r.jsx("strong",{children:"Encrypted for another device."}),r.jsx("p",{style:{margin:"0.35rem 0 0",fontSize:"0.85rem",color:"var(--text-secondary)"},children:"This device was added after the proposal was made, and no device of yours has shared it yet. It is shared automatically once a device that can read it comes online — or open it there."})]}),re.sealed&&re.loading&&r.jsx("div",{className:"preview-box","data-testid":"proposal-decrypting",style:{marginBottom:"0.5rem"},children:"Decrypting…"}),ee&&J&&r.jsxs("div",{className:"preview-box preview-box-ok","data-testid":"bound-values-open",style:{marginBottom:"0.5rem"},children:[r.jsxs("h4",{children:["What will be sent",re.sealed?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})," ",r.jsx("span",{className:"lock-tag",children:"end-to-end encrypted"})]}):r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),W,re.sealed&&r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Decrypted on this device. suveren.ai stores only an unreadable copy and its fingerprint."})]}),M.length>0&&r.jsxs("p",{"data-testid":"proposal-cannot-read",style:{margin:"0 0 0.5rem",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Cannot read this proposal yet: ",M.join(", ")," — shared automatically once they sign in on a device."]}),J&&r.jsx(dj,{proposalId:t.id,systemName:G,toolArgs:re.toolArgs,sealed:re.sealed,onTone:pe}),L.length>0&&r.jsxs("div",{className:"limit-checks",children:[r.jsx("h4",{children:"Within your limits"}),r.jsx("ul",{className:"limit-check-list",children:L.map(B=>r.jsxs("li",{className:B.ok?"ok":"bad",children:[r.jsx("span",{className:"limit-check-icon",children:B.ok?"✓":"✗"}),r.jsxs("span",{children:[B.label," ",B.valueText," — your limit ",B.limitText]})]},B.key))})]}),r.jsxs("div",{className:"mandate-intent",children:[r.jsxs("dl",{children:[r.jsx("dt",{children:"Mandate"}),r.jsxs("dd",{children:[r.jsx("strong",{children:(T==null?void 0:T.name)??dt(t.profileId)}),r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]})]}),r.jsxs("dl",{children:[r.jsx("dt",{children:"Intent"}),r.jsx("dd",{children:Y?r.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:Y}):H!==null?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:`intent-text${h?"":" intent-clamped"}`,children:H}),r.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>y(!h),children:h?"Show less":"Show full intent"})]}):ie?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"Loading intent…"}):r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]})]}),J&&fe.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:fe.map(B=>r.jsxs("a",{href:B.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:B.description??B.href,children:[B.label," ↗"]},B.label))}),!ee&&J&&r.jsxs("details",{className:"proposal-args-fold",style:{marginBottom:"0.75rem"},children:[r.jsx("summary",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",cursor:"pointer"},children:"Details (exactly what is bound)"}),r.jsx("div",{style:{marginTop:"0.5rem"},children:W})]}),J&&t.tool===xj&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.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 ",r.jsx("strong",{children:"your words"})," once you approve. Edit it first — nothing is created until you sign on the mandate screen."]}),r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm","data-testid":"edit-before-signing",onClick:oe,disabled:p,children:p?"Opening…":"Edit before signing"}),v&&r.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:"0.4rem 0 0"},children:v})]})]})}function Sm({note:t,onNoteChange:s,onSend:a,onCancel:o,sending:c,error:d}){return r.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"var(--bg-main)",padding:"0.75rem 0.875rem",marginTop:"0.5rem"},children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:[r.jsx("strong",{style:{color:"var(--text-primary)"},children:"What should change?"})," (the AI will read this)"]}),r.jsx("div",{style:{display:"flex",gap:"0.375rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:y0.map(h=>r.jsx("button",{type:"button",className:`filter-chip${Xh(t,h)?" selected":""}`,onClick:()=>s(x0(t,h)),disabled:c,children:h},h))}),r.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:t,maxLength:Ni,onChange:h=>s(h.target.value),rows:3,placeholder:"What should the AI do differently?",disabled:c,style:{width:"100%",resize:"vertical",fontFamily:"inherit"}}),r.jsxs("div",{style:{textAlign:"right",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[t.length," / ",Ni]}),d&&r.jsx("div",{className:"error-message",style:{marginTop:"0.4rem"},children:d}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.5rem"},children:[r.jsx("button",{"data-testid":"btn-send-back",className:"btn btn-primary",style:{background:"var(--warning)",borderColor:"var(--warning)"},onClick:a,disabled:c,children:c?"Sending…":"Send back for change"}),r.jsx("button",{className:"btn btn-ghost",onClick:o,disabled:c,children:"Cancel"})]}),r.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 wj={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},jj={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},Qf={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function Al(t){const s=Date.now()-t*1e3,a=s/36e5;return a<48?a<1?`${Math.max(1,Math.round(s/6e4))}m ago`:`${Math.round(a)}h ago`:new Date(t*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Sj(t){return t.split("__").pop()??t}function kj(t){const s=t.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function km(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.map(s=>km(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Xf({item:t,onApprove:s,onReject:a,onChangeNeeded:o,resolving:c,proposalLinks:d,toolDisplay:h,manifests:y,currentUserId:p}){const g=t.kind==="proposal",v=g?t.proposal.status:"executed",w=g?t.proposal.tool:t.receipt.action,j=Sj(w),N=kj(w),{integrationId:E}=vc(w),S=am(E,y),[C,T]=f.useState(!1),[R,L]=f.useState(""),[P,F]=f.useState(""),G=()=>{const A=yc(R);if(!A.valid){F(A.error);return}F(""),o==null||o(t.id,A.trimmed)},H=g&&v==="rejected"?k0(t.proposal,p??""):null,ie=g&&v==="refused"?b0(t.proposal):null,Y=gj(g?t.proposal.rejectedBy??t.proposal.approverRejectedBy??null:null),re=ea(t.profileId),J=xm(g?t.proposal:{toolArgs:void 0,content:void 0}),M=g?J.toolArgs:null,fe=g?t.proposal.executionContext:t.receipt.executionContext,oe=g?null:t.receipt.cumulativeState,[Z,pe]=f.useState(!0),[ee,W]=f.useState(!1),B=g&&J.toolArgs?hm(d,J.toolArgs):[],V=Object.entries(fe??{}),k=Nr(t.profileId).testSetup||$i(w);return r.jsxs("div",{className:"card id-card",children:[r.jsx(Zs,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[r.jsx("code",{style:{fontSize:"0.85rem"},children:j}),k&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),t.commitmentMode==="automatic"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),r.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[g&&v==="pending"&&(()=>{const A=mm(t.proposal.expiresAt,Date.now());return r.jsx("span",{style:{fontSize:"0.72rem",color:A.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:A.urgent?600:400,whiteSpace:"nowrap"},children:A.label})})(),r.jsx("span",{"data-testid":H||ie?"outcome-kind":void 0,className:`status-badge ${H?Qf[H.kind]:ie?Qf.REFUSED:jj[v]}`,children:H?H.kind:ie?ie.kind:wj[v]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Al(t.sortTimestamp)})]})]}),g&&t.proposal.status==="executed"&&r.jsx(lj,{proposalId:t.proposal.id,systemName:S}),H&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[r.jsxs("div",{children:["By ",H.who,", ",Al(H.at)]}),(Y??H.note)&&r.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[H.kind==="CHANGE NEEDED"?"Change: ":"Note: ",Y??H.note]})]}),ie&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[r.jsxs("div",{children:["By the Authority Server, ",Al(ie.at)]}),r.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",ie.message]})]}),N&&r.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:[r.jsx("span",{children:"⚠"}),r.jsx("span",{children:"Irreversible action"})]}),g&&typeof(M==null?void 0:M._imagePreview)=="string"&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),r.jsx("img",{src:M._imagePreview,alt:typeof(M==null?void 0:M.altText)=="string"?M.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),g&&v==="pending"?r.jsx(jm,{proposal:t.proposal,currentUserId:p??"",proposalLinks:d,toolDisplay:h,manifests:y,onContentState:({loading:A,readable:K})=>{W(A),pe(K)}}):r.jsxs(r.Fragment,{children:[B.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:B.map(A=>r.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))}),g?r.jsxs(r.Fragment,{children:[M&&r.jsx(pm,{args:M,display:h}),V.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:V.map(([A,K])=>`${A}=${km(K)}`).join(" · ")})]}):r.jsx(fm,{receipt:t.receipt,profile:re})]}),oe&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",oe.daily.count," action",oe.daily.count===1?"":"s",oe.daily.amount>0?`, ${oe.daily.amount}`:""," · ","this month: ",oe.monthly.count,oe.monthly.amount>0?`, ${oe.monthly.amount}`:""]}),g&&v==="pending"&&ym({loading:ee,readable:Z})&&(C?r.jsx(Sm,{note:R,onNoteChange:L,onSend:G,onCancel:()=>{T(!1),L(""),F("")},sending:!!c,error:P}):r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:()=>s==null?void 0:s(t.id),disabled:c,children:c?"Approving…":"Approve"}),r.jsx("button",{"data-testid":"btn-change-needed",className:"btn",style:{background:"#fff",color:"var(--warning)",border:"1px solid var(--warning)"},onClick:()=>T(!0),disabled:c,children:"Change needed"}),r.jsx("button",{"data-testid":"btn-reject",className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:()=>a==null?void 0:a(t.id),disabled:c,children:"Reject"})]})),r.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[g?"Proposal":"Ticket",": ",t.id]})]})]})}function bj(t){const s=Date.now()-t*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Nj({proposal:t,currentUserId:s,onAction:a,onMessage:o,proposalLinks:c,toolDisplay:d,manifests:h}){const[y,p]=f.useState(!1),[g,v]=f.useState(!1),[w,j]=f.useState(!1),[N,E]=f.useState(""),[S,C]=f.useState(""),[T,R]=f.useState(!1),[L,P]=f.useState(!1),[F,G]=f.useState(!0),H=Nr(t.profileId).testSetup||$i(t.tool),ie=t.pendingApprovers??[],Y=t.approvedBy??{},re=Object.keys(Y).length,J=ie.filter(ee=>!(ee in Y)).length,M=s in Y,fe=async()=>{if(fc()){o(hc);return}p(!0),o("");try{const ee=await wi(t);await D.approveProposal(t.id,ee);try{const W=await D.getAttestationIntent(t.authorizationId);if(W){const B=await D.decryptIntent({intentCiphertext:W.intentCiphertext,encryptedKey:W.encryptedKey,approverId:s});await D.storeApprovedIntent(t.authorizationId,B)}}catch{}o(`Approved. ${J-1>0?`${J-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),a()}catch(ee){o(ee instanceof Error?ee.message:"Approval failed")}finally{p(!1)}},oe=async()=>{v(!0),o("");try{const ee=await wi(t);await D.rejectProposal(t.id,Dl(),ee),o("Action rejected."),a()}catch(ee){o(ee instanceof Error?ee.message:"Rejection failed")}finally{v(!1)}},Z=async()=>{const ee=yc(N);if(!ee.valid){C(ee.error);return}C(""),R(!0),o("");try{const{noteEncrypted:W}=await D.encryptProposalNote(ee.trimmed,vm(t,s)),B=await wi(t);await D.rejectProposal(t.id,{outcome:"change_needed",noteEncrypted:W},B),o("Sent back for a change."),a()}catch(W){o(W instanceof Error?W.message:"Failed to send back")}finally{R(!1)}},pe=y||g||T;return r.jsxs("div",{className:"card id-card",children:[r.jsx(Zs,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[r.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"}),H&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),r.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const ee=mm(t.expiresAt,Date.now());return r.jsx("span",{style:{fontSize:"0.72rem",color:ee.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:ee.urgent?600:400,whiteSpace:"nowrap"},children:ee.label})})(),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:bj(t.createdAt)})]})]}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[re," of ",ie.length," approver",ie.length===1?"":"s"," signed off",ie.map(ee=>{const W=ee in Y;return r.jsxs("span",{style:{marginLeft:"0.5rem",color:W?"var(--success, green)":"var(--text-tertiary)"},children:[W?"✓":"○"," ",ee===s?"You":ee]},ee)})]}),r.jsx(jm,{proposal:t,currentUserId:s,proposalLinks:c,toolDisplay:d,manifests:h,onContentState:({loading:ee,readable:W})=>{P(ee),G(W)}}),!M&&ym({loading:L,readable:F})&&(w?r.jsx(Sm,{note:N,onNoteChange:E,onSend:Z,onCancel:()=>{j(!1),E(""),C("")},sending:T,error:S}):r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:fe,disabled:pe,children:y?"Approving...":"Approve"}),r.jsx("button",{"data-testid":"btn-change-needed",className:"btn",style:{background:"#fff",color:"var(--warning)",border:"1px solid var(--warning)"},onClick:()=>j(!0),disabled:pe,children:"Change needed"}),r.jsx("button",{"data-testid":"btn-reject",className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:oe,disabled:pe,children:g?"Rejecting...":"Reject"})]})),M&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),r.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",t.id]})]})]})}function Cj(){const{domain:t,user:s}=vt(),a=(s==null?void 0:s.id)??"",[o,c]=f.useState("awaiting-me"),[d,h]=f.useState([]),[y,p]=f.useState([]),[g,v]=f.useState({}),[w,j]=f.useState(!0),[N,E]=f.useState(""),S=f.useCallback(async()=>{try{const X=await D.getProposalsForApprover();h(X)}catch{}finally{j(!1)}},[]);He("proposal-added",S),He("proposal-approved",S),He("proposal-rejected",S),He("proposal-resolved",S),nn(S,3e4);const[C,T]=f.useState([]),R=f.useCallback(async()=>{try{const X=await D.getMyProposals(t);T(X)}catch{}},[t]);He("proposal-added",R),He("proposal-approved",R),He("proposal-rejected",R),He("proposal-resolved",R),nn(R,3e4,t);const L=f.useMemo(()=>C.filter(X=>{var we;return X.status==="pending"&&(((we=X.pendingApprovers)==null?void 0:we.length)??0)===0}),[C]),P=f.useMemo(()=>Vf(L,[],{status:"pending"}),[L]),[F,G]=f.useState([]),H=f.useCallback(async()=>{if(a)try{const we=(await D.getMyProposals(t)).filter(Te=>Te.status==="pending"&&Te.pendingApprovers&&Te.pendingApprovers.includes(a)&&Te.approvedBy&&a in Te.approvedBy);G(we)}catch{}},[a,t]);He("proposal-approved",H),He("proposal-rejected",H),nn(H,3e4,`${a}:${t}`),f.useEffect(()=>{D.getIntegrationManifests().then(X=>p(X.manifests??[])).catch(()=>{}),D.getToolDisplay().then(v).catch(()=>{})},[]);const ie=X=>{var we;return(we=y.find(Te=>Te.id===X.split("__")[0]))==null?void 0:we.proposalLinks};f.useEffect(()=>{S(),R(),H()},[]);const[Y,re]=f.useState([]),[J,M]=f.useState([]),[fe,oe]=f.useState(!0),[Z,pe]=f.useState(null),[ee,W]=f.useState(""),[B,V]=f.useState("pending"),[k,A]=f.useState(null),[K,te]=f.useState(!1),ue=f.useCallback(async()=>{try{const{proposals:X,receipts:we}=await D.getThread({domain:t,status:B,sinceDays:7});re(X),M(we)}catch{}finally{oe(!1)}},[t,B]);nn(ue,3e4,`${t}:${B}`);const ve=async(X,we,Te)=>{if(we==="commit"&&fc()){W(hc);return}pe(X),W("");try{const $e=Y.find(st=>st.id===X)??C.find(st=>st.id===X),lt=uv($e,t),xt=$e?await wi($e):void 0;let Ke=Te??{};if((Te==null?void 0:Te.outcome)==="change_needed"&&Te.note){const st=$e?vm($e,a):[a],{noteEncrypted:mt}=await D.encryptProposalNote(Te.note,st);Ke={outcome:"change_needed",noteEncrypted:mt}}const et=await D.resolveProposal(X,we,lt,{...Ke,contentHash:xt});W(we==="commit"?`Action approved. Status: ${et.status}`:(Te==null?void 0:Te.outcome)==="change_needed"?"Sent back for a change.":"Action rejected."),await Promise.all([ue(),R()])}catch($e){W($e instanceof Error?$e.message:"Failed")}finally{pe(null)}},Ce=(X,we)=>ve(X,"reject",w0(we)),ke=f.useMemo(()=>{const X=new Set;for(const we of Y)X.add(we.profileId);for(const we of J)X.add(we.profileId);return Array.from(X).sort()},[Y,J]),se=f.useMemo(()=>Vf(Y,J,{status:B,profile:k??void 0,includeAutonomous:K}),[Y,J,B,k,K]),Le=f.useCallback(()=>{S(),H()},[S,H]),Ee=f.useMemo(()=>{const X=new Set,we=[];for(const Te of F)X.has(Te.id)||(X.add(Te.id),we.push(Te));return we.sort((Te,$e)=>$e.createdAt-Te.createdAt)},[F]),_e=d.length+P.length,he=Ee.length;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Pending Approvals"}),r.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."}),r.jsx(Bh,{what:"approve"})]}),r.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[r.jsxs("button",{className:`nav-tab${o==="awaiting-me"?" active":""}`,onClick:()=>c("awaiting-me"),children:["Awaiting me ",_e>0&&r.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:_e})]}),r.jsxs("button",{className:`nav-tab${o==="awaiting-others"?" active":""}`,onClick:()=>c("awaiting-others"),children:["Awaiting others ",he>0&&r.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:he})]}),r.jsx("button",{className:`nav-tab${o==="all"?" active":""}`,onClick:()=>{c("all"),ue()},children:"All"})]}),o==="awaiting-me"&&r.jsx(r.Fragment,{children:w&&_e===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):_e===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(N||ee)&&r.jsx("div",{className:"alert alert-success",children:N||ee}),P.map(X=>r.jsx(Xf,{proposalLinks:X.kind==="proposal"?ie(X.proposal.tool):void 0,toolDisplay:X.kind==="proposal"?g[X.proposal.tool]:void 0,manifests:y,currentUserId:a,item:X,onApprove:we=>ve(we,"commit"),onReject:we=>ve(we,"reject",Dl()),onChangeNeeded:Ce,resolving:Z===X.id},X.id)),d.map(X=>r.jsx(Nj,{proposal:X,currentUserId:a,onAction:Le,onMessage:E,proposalLinks:ie(X.tool),toolDisplay:g[X.tool],manifests:y},X.id))]})}),o==="awaiting-others"&&r.jsx(r.Fragment,{children:Ee.length===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:Ee.map(X=>r.jsx(Tj,{proposal:X,currentUserId:a,onCancel:async()=>{try{await D.rejectProposal(X.id,{reason:"cancelled by creator"}),H(),R()}catch(we){alert(we instanceof Error?we.message:"Cancel failed")}}},X.id))})}),o==="all"&&r.jsxs(r.Fragment,{children:[ee&&r.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:ee}),r.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[r.jsx("button",{className:`filter-chip ${B==="pending"?"selected":""}`,onClick:()=>V("pending"),children:"Pending"}),r.jsx("button",{className:`filter-chip ${B==="all"?"selected":""}`,onClick:()=>V("all"),children:"All"}),ke.length>0&&r.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),ke.map(X=>r.jsx("button",{className:`filter-chip ${k===X?"selected":""}`,onClick:()=>A(k===X?null:X),children:dt(X)},X)),B==="all"&&r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),r.jsxs("button",{className:`filter-chip ${K?"selected":""}`,onClick:()=>te(!K),title:"Include actions executed without human review (automatic commitment mode)",children:[K?"✓ ":"","Autonomous actions"]})]})]}),fe&&se.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):se.length===0?r.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[r.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:B==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:B==="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."})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:se.map(X=>r.jsx(Xf,{proposalLinks:X.kind==="proposal"?ie(X.proposal.tool):void 0,toolDisplay:X.kind==="proposal"?g[X.proposal.tool]:void 0,manifests:y,currentUserId:a,item:X,onApprove:we=>ve(we,"commit"),onReject:we=>ve(we,"reject",Dl()),onChangeNeeded:Ce,resolving:Z===X.id},X.id))})]})]})}function Ej(t){const s=Date.now()-t*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Tj({proposal:t,currentUserId:s,onCancel:a}){var v;const[o,c]=f.useState(!1),d=Object.keys(t.approvedBy??{}),h=(t.pendingApprovers??[]).filter(w=>!(w in(t.approvedBy??{}))),y=(((v=t.pendingApprovers)==null?void 0:v.length)??0)>0,p=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){c(!0);try{await a()}finally{c(!1)}}},g=Nr(t.profileId).testSetup||$i(t.tool);return r.jsxs("div",{className:"card id-card",children:[r.jsx(Zs,{profileId:t.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[r.jsx("code",{style:{fontSize:"0.85rem"},children:t.tool.split("__").pop()??t.tool}),g&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),y&&r.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"}),r.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Ej(t.createdAt)})]}),y&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[d.map(w=>r.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:w===s?"You approved":`${w} approved`},w)),h.map(w=>r.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",w===s?"you":w]},w))]}),r.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:r.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:p,disabled:o,children:o?"Cancelling...":"Cancel"})})]})]})}const Rj=`# 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 Ij(){const[t,s]=f.useState(""),[a,o]=f.useState(""),[c,d]=f.useState(!0),[h,y]=f.useState(!1),[p,g]=f.useState(null),[v,w]=f.useState(!1),j=t!==a,N=new Blob([t]).size,E=16*1024;f.useEffect(()=>{if(!j)return;const R=P=>{P.preventDefault(),P.returnValue=""},L=P=>{var H,ie;if(P.defaultPrevented||P.button!==0||P.metaKey||P.ctrlKey||P.shiftKey||P.altKey)return;const F=(ie=(H=P.target)==null?void 0:H.closest)==null?void 0:ie.call(H,"a");if(!F||!F.href)return;let G;try{G=new URL(F.href)}catch{return}G.origin===window.location.origin&&G.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(P.preventDefault(),P.stopPropagation()))};return window.addEventListener("beforeunload",R),document.addEventListener("click",L,!0),()=>{window.removeEventListener("beforeunload",R),document.removeEventListener("click",L,!0)}},[j]),f.useEffect(()=>{let R=!1;return D.getAgentContext().then(L=>{R||(s(L),o(L))}).catch(L=>{R||g({kind:"error",text:L instanceof Error?L.message:"Failed to load context"})}).finally(()=>{R||d(!1)}),()=>{R=!0}},[]);const S=async()=>{y(!0),g(null);try{await D.saveAgentContext(t),o(t),g({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(R){g({kind:"error",text:R instanceof Error?R.message:"Save failed"})}finally{y(!1)}},C=()=>{s(a),g(null)},T=()=>{t.trim()&&!confirm("Replace current context with the starter template?")||s(Rj)};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"page-header",children:[r.jsx("h1",{className:"page-title",children:"Agent Brief"}),r.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!t.trim()&&!c&&r.jsx("button",{className:"btn btn-primary btn-sm",onClick:T,disabled:h,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),p&&r.jsx("div",{className:p.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:p.text}),r.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[r.jsx("div",{className:"card intent-pane chat",children:r.jsx(ki,{target:{kind:"context"},currentText:t,onApply:R=>{t.trim()&&!confirm("Replace the current context with the applied draft?")||s(R)},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…"})}),r.jsxs("div",{className:"card intent-pane document",children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[r.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),r.jsxs("span",{style:{fontSize:"0.75rem",color:N>E?"var(--danger)":"var(--text-muted)"},children:[N.toLocaleString()," / ",E.toLocaleString()," bytes"]})]}),r.jsx("textarea",{className:"form-textarea",value:t,onChange:R=>s(R.target.value),placeholder:c?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:c,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),r.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:C,disabled:h||!j,children:"Revert"}),r.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:S,disabled:h||!j||N>E||c,children:h?"Saving…":"Save"})]})]}),r.jsx("button",{type:"button",className:"floating-help",onClick:()=>w(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),r.jsx(Vh,{open:v,onClose:()=>w(!1),ariaLabel:"Brief assistant",children:r.jsx(ki,{target:{kind:"context"},currentText:t,onApply:R=>{t.trim()&&!confirm("Replace the current context with the applied draft?")||(s(R),w(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Aj(t){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(t);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function Pj(t){const s=t.find(c=>{var d;return c.kind==="sv-mandate"&&c.status!=="unverifiable"&&typeof((d=c.data)==null?void 0:d.profile)=="string"});if(!s)return null;const a=s.data;if(typeof a.profileLabel=="string"&&a.profileLabel)return a.profileLabel;const o=a.profile.split("@")[0].split("/").pop();return o?o.charAt(0).toUpperCase()+o.slice(1):null}function _j(t){return new Date(t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function $j(t,s){const a=s.emailExportError?"cases unknown":`${s.coveredCases.length}/${s.loadedCases.length} cases`;return`${t.signaturesValid>0?`${t.signaturesValid} ✓ tickets`:`${t.signaturesValid} tickets`} · ${a} · ${s.ticketsReferenced.length}/${s.ticketsInPeriod.length} tickets covered`}function Lj(t){return t.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:t.emailExportError}:{kind:"ok",text:`${t.coveredCases.length} of ${t.loadedCases.length}`}}function zj(t){return t.periodStart!==null?null:t.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:t.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function Zf(t,s="none in this report"){return t>0?{kind:"ok",text:`${t} ✓`}:{kind:"neutral",text:s}}function Fj(t){return/Labels?$/.test(t)||t==="limits"||t==="fields"}function Oj(t,s){const a=s[t];return a==null||a===""||Fj(t)?null:typeof a=="object"?JSON.stringify(a):String(a)}function Mj(t){const s=[];return t.missingCases.length>0&&s.push(`cases ${t.missingCases.join(", ")}`),t.ticketsNotReferenced.length>0&&s.push(`${t.ticketsNotReferenced.length} ticket${t.ticketsNotReferenced.length===1?"":"s"}`),s.length>0?`Not in the report: ${s.join(" · ")}`:null}function Bj(t,s){var a;if(s)return s;if(!t)return null;if(t.kind==="sv-ticket")return t.attrs.ref||null;if(t.kind==="sv-approval"||t.kind==="sv-mandate")return t.attrs.ticket||null;if(t.kind==="sv-case"){const o=(a=t.data)==null?void 0:a.goal;return(o==null?void 0:o.ticketId)??null}return null}const Dj="allow-popups allow-popups-to-escape-sandbox",Uj="AI analysis — not verified",Wj="Green = verified by the gateway — raw signed fields only",Hj="Grey dashed = the AI's own analysis, not verified",Vj="= translation by the AI, not verified",Gj="Übersetzung anzeigen / show translation";function eh(t){var a;const s=((a=t.formatNotice)==null?void 0:a.blocksNotShown)??0;return s<=0?null:`This report was written in an older format — ${s} ${s===1?"block was":"blocks were"} not shown. Ask the AI to write it again.`}function Kj(t,s){return s&&t.renderedHtmlGloss?t.renderedHtmlGloss:t.renderedHtml}function Yj(t,s,a){const o=new URLSearchParams(t);return o.set("element",s),a?o.set("ticket",a):o.delete("ticket"),o}const Jj={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function qj(t){return t.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${Jj[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function Qj(t){if(!t||t.kind!=="sv-case"||!t.data)return[];const s=Array.isArray(t.data.steps)?t.data.steps:[],a=t.data.goal,o=[...s.map(c=>({n:c,isGoal:!1})),...a?[{n:a,isGoal:!0}]:[]].filter(c=>typeof c.n.ticketId=="string"&&c.n.ticketId);return o.sort((c,d)=>(c.n.time??0)-(d.n.time??0)),o.map(({n:c,isGoal:d})=>({ticketId:c.ticketId,label:String(c.action??c.ticketId),isGoal:d}))}function Xj(t){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>${t}</body></html>`}const xc={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},Zj={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function eS(t,s){return Array.isArray(s.fields)?s.fields.map(o=>({label:o.key,value:o.value})):{Ticket:["action","profile","time"],Mandate:["profile","mode","owners","intent"],Approval:["createdAt","decidedAt","whoLabel","status","waitSeconds"]}[t].filter(o=>s[o]!==void 0&&s[o]!==null).map(o=>({label:o,value:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])}))}function tS(t,s){const a=Zj[t].filter(o=>s[o]!==void 0);return a.length===0?null:r.jsxs("details",{style:{marginTop:"0.5rem"},children:[r.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),r.jsx("dl",{style:{...xc,marginTop:"0.5rem"},children:a.map(o=>r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:o}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])})]},o))})]})}function Pl(t,s){return s?r.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:t}),s.status==="unverifiable"?r.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",s.reason??"no further detail."]}):r.jsxs(r.Fragment,{children:[r.jsx("dl",{style:xc,children:eS(t,s.data??{}).map(({label:a,value:o})=>r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:a}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:o})]},a))}),tS(t,s.data??{})]})]}):null}function nS({report:t,elementId:s,ticketParam:a,onClose:o,onSelectTicket:c}){var w;const d=t.elements.find(j=>j.id===s),h=Bj(d,a),y=h?t.ticketDetails[h]:void 0,p=Qj(d),g=(w=t.proof.verifiedValues.find(j=>j.elementId===s))==null?void 0:w.summary,v=f.useRef(null);return f.useEffect(()=>{const j=v.current;if(!j||typeof j.getBoundingClientRect!="function")return;const N=j.getBoundingClientRect().top;(N<0||N>window.innerHeight-80)&&j.scrollIntoView({block:"start",behavior:"smooth"})},[s,a]),r.jsxs("div",{className:"card reports-detail",ref:v,children:[r.jsxs("div",{className:"card-header",children:[r.jsx("div",{className:"card-title",children:"Details"}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,children:"Close"})]}),g&&r.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:g}),p.length>0&&r.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:p.map(j=>r.jsxs("button",{type:"button",className:`btn btn-sm ${j.ticketId===h?"btn-secondary":"btn-ghost"}`,"aria-pressed":j.ticketId===h,onClick:()=>c(j.ticketId),children:[j.isGoal?"Goal: ":"",j.label]},j.ticketId))}),!d&&r.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),d&&!h&&(d.status==="unverifiable"?r.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",d.reason??"no further detail."]}):r.jsx("dl",{style:xc,children:Object.keys(d.data??{}).map(j=>{const N=Oj(j,d.data??{});return N===null?null:r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:j}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:N})]},j)})})),y&&r.jsxs(r.Fragment,{children:[Pl("Ticket",y.ticket),Pl("Mandate",y.mandate),Pl("Approval",y.approval)]}),h&&!y&&r.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",h,"."]})]})}async function rS(t){const{html:s,filename:a}=await t.exportReport();t.download(s,a),await t.refresh()}function th({detail:t}){return t?r.jsxs("details",{style:{marginTop:"0.25rem"},children:[r.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),r.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:t})]}):null}function sS({report:t,open:s,selectedId:a,onOpenElement:o,detail:c}){const{proof:d,coverage:h}=t,y=qj(t.elements),p=Mj(h),g=Lj(h),v=zj(h),w=Zf(d.signaturesValid),j=Zf(d.recordsChecked);return r.jsxs("div",{className:`reports-side${s?" reports-side-open":""}`,children:[c,r.jsxs("div",{className:"card",children:[r.jsx("div",{className:"card-title",children:"Proof"}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Tickets referenced"}),r.jsx("b",{children:d.ticketsReferenced.length})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Signatures valid"}),r.jsx("b",{style:w.kind==="ok"?{color:"var(--success)"}:void 0,children:w.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Records checked"}),r.jsx("b",{style:j.kind==="ok"?{color:"var(--success)"}:void 0,children:j.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Not verifiable"}),r.jsx("b",{children:d.unverifiableCount})]}),y.map(N=>r.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),children:[r.jsx("span",{children:N.text}),r.jsx("span",{"aria-hidden":"true",children:"›"})]},N.elementId))]}),r.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:"Coverage"}),g.kind==="error"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"reports-error",role:"alert",children:g.text}),r.jsx(th,{detail:g.detail})]}):r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Cases"}),r.jsx("b",{children:g.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Tickets in test period"}),r.jsxs("b",{children:[h.ticketsReferenced.length," of ",h.ticketsInPeriod.length]})]}),v&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:v.detail?"reports-error":"reports-note",role:v.detail?"alert":void 0,children:v.text}),r.jsx(th,{detail:v.detail})]}),p&&r.jsx("p",{className:"reports-missing",children:p})]}),d.verifiedValues.length>0&&r.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:"Checked values"}),d.verifiedValues.map(N=>r.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),title:"Show details",children:[r.jsx("span",{children:N.summary}),r.jsx("span",{"aria-hidden":"true",children:"›"})]},N.elementId))]})]})}function aS(){const[t,s]=f.useState(null),[a,o]=f.useState(!0),[c,d]=f.useState(null),[h,y]=f.useState(!1),[p,g]=f.useState(!1),[v,w]=f.useState(null),[j,N]=f.useState(!1),[E,S]=f.useState(!1),[C,T]=sc(),R=f.useCallback(()=>D.getReport().then(({report:M})=>s(M)).catch(M=>d(M instanceof Error?M.message:String(M))),[]),L=f.useCallback(()=>{o(!0),d(null),R().finally(()=>o(!1))},[R]);f.useEffect(()=>{L()},[L]);const P=f.useCallback(()=>{y(!0),D.recheckReport().then(({report:M})=>s(M)).catch(M=>d(M instanceof Error?M.message:String(M))).finally(()=>y(!1))},[]),F=f.useCallback(async()=>{g(!0),w(null);try{await rS({exportReport:()=>D.exportReportWithProof(),download:(M,fe)=>{const oe=URL.createObjectURL(new Blob([M],{type:"text/html"})),Z=document.createElement("a");Z.href=oe,Z.download=fe,Z.click(),URL.revokeObjectURL(oe)},refresh:R})}catch(M){w(M instanceof Error?M.message:String(M))}finally{g(!1)}},[R]),G=C.get("element"),H=C.get("ticket"),ie=f.useCallback((M,fe)=>{T(Yj(C,M,fe))},[C,T]),Y=f.useCallback(()=>{const M=new URLSearchParams(C);M.delete("element"),M.delete("ticket"),T(M,{replace:!0})},[C,T]);if(a)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(c)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx(Zr,{icon:"⚠",title:"Report unavailable",text:c})]});if(!t)return r.jsxs("div",{className:"page-inner",children:[r.jsx("div",{className:"page-header",children:r.jsx("h1",{className:"page-title",children:"Reports"})}),r.jsx(Zr,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const re=Aj(t.renderedHtml),J=Pj(t.elements);return r.jsx("div",{className:"page-inner reports-page",children:r.jsxs("div",{className:"reports-layout",children:[r.jsxs("div",{className:"reports-bar",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"page-title",children:re}),r.jsxs("p",{className:"page-subtitle",children:[J?`written by the AI under mandate ${J} · `:"","checked ",_j(t.checkedAt)]})]}),r.jsxs("div",{className:"reports-bar-actions",children:[r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:P,disabled:h,children:h?"Checking…":"Check again"}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:F,disabled:p,children:p?"Exporting…":"Export with proof"})]})]}),v&&r.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",v]}),r.jsxs("div",{className:"reports-summary-chip",children:[r.jsx("span",{children:$j(t.proof,t.coverage)}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>N(M=>!M),children:j?"hide":"details"})]}),r.jsxs("div",{className:"reports-grid",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"reports-legend",role:"note",children:[r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("span",{className:"reports-sw reports-sw-v"}),Wj]}),r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("span",{className:"reports-sw reports-sw-a"}),Hj," (“",Uj,"”)"]}),t.renderedHtmlGloss&&r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",Vj]})]}),eh(t)&&r.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:eh(t)}),t.renderedHtmlGloss&&r.jsxs("label",{className:"reports-gloss-switch",children:[r.jsx("input",{type:"checkbox",role:"switch",checked:E,onChange:M=>S(M.target.checked)}),r.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:r.jsx("span",{className:"reports-gloss-thumb"})}),r.jsx("span",{children:Gj})]}),r.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."}),r.jsx("iframe",{title:"Report",sandbox:Dj,srcDoc:Xj(Kj(t,E)),className:"reports-iframe"})]}),r.jsx(sS,{report:t,open:j||!!G,selectedId:G,onOpenElement:M=>ie(M),detail:G?r.jsx(nS,{report:t,elementId:G,ticketParam:H,onClose:Y,onSelectTicket:M=>ie(G,M)}):void 0})]})]})})}function Qr({to:t}){const{search:s,hash:a}=Dt();return r.jsx(Pn,{to:`${t}${s}${a}`,replace:!0})}function iS({children:t}){const{user:s,mode:a,domain:o}=vt();return s?a==="team"&&!o?r.jsx(Pn,{to:"/onboarding",replace:!0}):r.jsx(r.Fragment,{children:t}):r.jsx(Pn,{to:"/login",replace:!0})}function oS(){const{user:t,handleSessionLocked:s,refreshGroups:a}=vt();return He("session-locked",o=>{const c=o==null?void 0:o.message;s(c)}),He("team-membership-changed",()=>{a()}),r.jsxs(Ey,{children:[r.jsx(Qe,{path:"/login",element:t?r.jsx(Pn,{to:"/",replace:!0}):r.jsx(px,{})}),r.jsx(Qe,{path:"/onboarding",element:t?r.jsx(jx,{}):r.jsx(Pn,{to:"/login",replace:!0})}),r.jsxs(Qe,{element:r.jsx(iS,{children:r.jsx(mx,{})}),children:[r.jsx(Qe,{path:"/",element:r.jsx(zx,{})}),r.jsx(Qe,{path:"/mandates",element:r.jsx(ew,{})}),r.jsx(Qe,{path:"/mandates/new/intent",element:r.jsx(o0,{})}),r.jsx(Qe,{path:"/mandates/new/sign",element:r.jsx(N0,{})}),r.jsx(Qe,{path:"/integrations",element:r.jsx(P0,{})}),r.jsx(Qe,{path:"/team",element:r.jsx(_0,{})}),r.jsx(Qe,{path:"/tickets",element:r.jsx(Bw,{})}),r.jsx(Qe,{path:"/blocked",element:r.jsx(Dw,{})}),r.jsx(Qe,{path:"/approvals",element:r.jsx(Cj,{})}),r.jsx(Qe,{path:"/reports",element:r.jsx(aS,{})}),r.jsx(Qe,{path:"/agent/new",element:r.jsx(Pn,{to:"/mandates?new=1",replace:!0})}),r.jsx(Qe,{path:"/agent/gate",element:r.jsx(Qr,{to:"/mandates/new/intent"})}),r.jsx(Qe,{path:"/agent/review",element:r.jsx(Qr,{to:"/mandates/new/sign"})}),r.jsx(Qe,{path:"/authorizations",element:r.jsx(Qr,{to:"/mandates"})}),r.jsx(Qe,{path:"/groups",element:r.jsx(Qr,{to:"/team"})}),r.jsx(Qe,{path:"/audit",element:r.jsx(Qr,{to:"/tickets"})}),r.jsx(Qe,{path:"/proposals",element:r.jsx(Qr,{to:"/approvals"})}),r.jsx(Qe,{path:"/agent-brief",element:r.jsx(Ij,{})}),r.jsx(Qe,{path:"/settings",element:r.jsx(Qw,{})}),r.jsx(Qe,{path:"/settings/services",element:r.jsx(Pn,{to:"/settings",replace:!0})}),r.jsx(Qe,{path:"/deploy",element:r.jsx(Pn,{to:"/integrations",replace:!0})})]}),r.jsx(Qe,{path:"*",element:r.jsx(Pn,{to:"/",replace:!0})})]})}function lS(){return r.jsx(Xy,{children:r.jsx(hv,{children:r.jsx(mv,{children:r.jsx(oS,{})})})})}bg.createRoot(document.getElementById("root")).render(r.jsx(f.StrictMode,{children:r.jsx(lS,{})}));