@suveren/gateway 0.26.0 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,120 @@
1
+ var sg=Object.defineProperty;var ag=(n,s,i)=>s in n?sg(n,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[s]=i;var zs=(n,s,i)=>ag(n,typeof s!="symbol"?s+"":s,i);(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 m of d.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&o(m)}).observe(document,{childList:!0,subtree:!0});function i(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=i(c);fetch(c.href,d)}})();var ul={exports:{}},Fs={},dl={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 Hd;function ig(){if(Hd)return Be;Hd=1;var n=Symbol.for("react.element"),s=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),m=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),j=Symbol.iterator;function w(S){return S===null||typeof S!="object"?null:(S=j&&S[j]||S["@@iterator"],typeof S=="function"?S:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,k={};function C(S,_,J){this.props=S,this.context=_,this.refs=k,this.updater=J||N}C.prototype.isReactComponent={},C.prototype.setState=function(S,_){if(typeof S!="object"&&typeof S!="function"&&S!=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,S,_,"setState")},C.prototype.forceUpdate=function(S){this.updater.enqueueForceUpdate(this,S,"forceUpdate")};function T(){}T.prototype=C.prototype;function I(S,_,J){this.props=S,this.context=_,this.refs=k,this.updater=J||N}var $=I.prototype=new T;$.constructor=I,E($,C.prototype),$.isPureReactComponent=!0;var A=Array.isArray,B=Object.prototype.hasOwnProperty,K={current:null},V={key:!0,ref:!0,__self:!0,__source:!0};function de(S,_,J){var te,ce={},ve=null,Ce=null;if(_!=null)for(te in _.ref!==void 0&&(Ce=_.ref),_.key!==void 0&&(ve=""+_.key),_)B.call(_,te)&&!V.hasOwnProperty(te)&&(ce[te]=_[te]);var ke=arguments.length-2;if(ke===1)ce.children=J;else if(1<ke){for(var se=Array(ke),$e=0;$e<ke;$e++)se[$e]=arguments[$e+2];ce.children=se}if(S&&S.defaultProps)for(te in ke=S.defaultProps,ke)ce[te]===void 0&&(ce[te]=ke[te]);return{$$typeof:n,type:S,key:ve,ref:Ce,props:ce,_owner:K.current}}function Y(S,_){return{$$typeof:n,type:S.type,key:_,ref:S.ref,props:S.props,_owner:S._owner}}function re(S){return typeof S=="object"&&S!==null&&S.$$typeof===n}function G(S){var _={"=":"=0",":":"=2"};return"$"+S.replace(/[=:]/g,function(J){return _[J]})}var D=/\/+/g;function ie(S,_){return typeof S=="object"&&S!==null&&S.key!=null?G(""+S.key):_.toString(36)}function fe(S,_,J,te,ce){var ve=typeof S;(ve==="undefined"||ve==="boolean")&&(S=null);var Ce=!1;if(S===null)Ce=!0;else switch(ve){case"string":case"number":Ce=!0;break;case"object":switch(S.$$typeof){case n:case s:Ce=!0}}if(Ce)return Ce=S,ce=ce(Ce),S=te===""?"."+ie(Ce,0):te,A(ce)?(J="",S!=null&&(J=S.replace(D,"$&/")+"/"),fe(ce,_,J,"",function($e){return $e})):ce!=null&&(re(ce)&&(ce=Y(ce,J+(!ce.key||Ce&&Ce.key===ce.key?"":(""+ce.key).replace(D,"$&/")+"/")+S)),_.push(ce)),1;if(Ce=0,te=te===""?".":te+":",A(S))for(var ke=0;ke<S.length;ke++){ve=S[ke];var se=te+ie(ve,ke);Ce+=fe(ve,_,J,se,ce)}else if(se=w(S),typeof se=="function")for(S=se.call(S),ke=0;!(ve=S.next()).done;)ve=ve.value,se=te+ie(ve,ke++),Ce+=fe(ve,_,J,se,ce);else if(ve==="object")throw _=String(S),Error("Objects are not valid as a React child (found: "+(_==="[object Object]"?"object with keys {"+Object.keys(S).join(", ")+"}":_)+"). If you meant to render a collection of children, use an array instead.");return Ce}function Z(S,_,J){if(S==null)return S;var te=[],ce=0;return fe(S,te,"","",function(ve){return _.call(J,ve,ce++)}),te}function pe(S){if(S._status===-1){var _=S._result;_=_(),_.then(function(J){(S._status===0||S._status===-1)&&(S._status=1,S._result=J)},function(J){(S._status===0||S._status===-1)&&(S._status=2,S._result=J)}),S._status===-1&&(S._status=0,S._result=_)}if(S._status===1)return S._result.default;throw S._result}var ee={current:null},W={transition:null},O={ReactCurrentDispatcher:ee,ReactCurrentBatchConfig:W,ReactCurrentOwner:K};function H(){throw Error("act(...) is not supported in production builds of React.")}return Be.Children={map:Z,forEach:function(S,_,J){Z(S,function(){_.apply(this,arguments)},J)},count:function(S){var _=0;return Z(S,function(){_++}),_},toArray:function(S){return Z(S,function(_){return _})||[]},only:function(S){if(!re(S))throw Error("React.Children.only expected to receive a single React element child.");return S}},Be.Component=C,Be.Fragment=i,Be.Profiler=c,Be.PureComponent=I,Be.StrictMode=o,Be.Suspense=p,Be.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=O,Be.act=H,Be.cloneElement=function(S,_,J){if(S==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+S+".");var te=E({},S.props),ce=S.key,ve=S.ref,Ce=S._owner;if(_!=null){if(_.ref!==void 0&&(ve=_.ref,Ce=K.current),_.key!==void 0&&(ce=""+_.key),S.type&&S.type.defaultProps)var ke=S.type.defaultProps;for(se in _)B.call(_,se)&&!V.hasOwnProperty(se)&&(te[se]=_[se]===void 0&&ke!==void 0?ke[se]:_[se])}var se=arguments.length-2;if(se===1)te.children=J;else if(1<se){ke=Array(se);for(var $e=0;$e<se;$e++)ke[$e]=arguments[$e+2];te.children=ke}return{$$typeof:n,type:S.type,key:ce,ref:ve,props:te,_owner:Ce}},Be.createContext=function(S){return S={$$typeof:m,_currentValue:S,_currentValue2:S,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},S.Provider={$$typeof:d,_context:S},S.Consumer=S},Be.createElement=de,Be.createFactory=function(S){var _=de.bind(null,S);return _.type=S,_},Be.createRef=function(){return{current:null}},Be.forwardRef=function(S){return{$$typeof:g,render:S}},Be.isValidElement=re,Be.lazy=function(S){return{$$typeof:v,_payload:{_status:-1,_result:S},_init:pe}},Be.memo=function(S,_){return{$$typeof:y,type:S,compare:_===void 0?null:_}},Be.startTransition=function(S){var _=W.transition;W.transition={};try{S()}finally{W.transition=_}},Be.unstable_act=H,Be.useCallback=function(S,_){return ee.current.useCallback(S,_)},Be.useContext=function(S){return ee.current.useContext(S)},Be.useDebugValue=function(){},Be.useDeferredValue=function(S){return ee.current.useDeferredValue(S)},Be.useEffect=function(S,_){return ee.current.useEffect(S,_)},Be.useId=function(){return ee.current.useId()},Be.useImperativeHandle=function(S,_,J){return ee.current.useImperativeHandle(S,_,J)},Be.useInsertionEffect=function(S,_){return ee.current.useInsertionEffect(S,_)},Be.useLayoutEffect=function(S,_){return ee.current.useLayoutEffect(S,_)},Be.useMemo=function(S,_){return ee.current.useMemo(S,_)},Be.useReducer=function(S,_,J){return ee.current.useReducer(S,_,J)},Be.useRef=function(S){return ee.current.useRef(S)},Be.useState=function(S){return ee.current.useState(S)},Be.useSyncExternalStore=function(S,_,J){return ee.current.useSyncExternalStore(S,_,J)},Be.useTransition=function(){return ee.current.useTransition()},Be.version="18.3.1",Be}var Vd;function Ml(){return Vd||(Vd=1,dl.exports=ig()),dl.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 Gd;function og(){if(Gd)return Fs;Gd=1;var n=Ml(),s=Symbol.for("react.element"),i=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,c=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function m(g,p,y){var v,j={},w=null,N=null;y!==void 0&&(w=""+y),p.key!==void 0&&(w=""+p.key),p.ref!==void 0&&(N=p.ref);for(v in p)o.call(p,v)&&!d.hasOwnProperty(v)&&(j[v]=p[v]);if(g&&g.defaultProps)for(v in p=g.defaultProps,p)j[v]===void 0&&(j[v]=p[v]);return{$$typeof:s,type:g,key:w,ref:N,props:j,_owner:c.current}}return Fs.Fragment=i,Fs.jsx=m,Fs.jsxs=m,Fs}var Kd;function lg(){return Kd||(Kd=1,ul.exports=og()),ul.exports}var r=lg(),f=Ml(),ai={},fl={exports:{}},Mt={},hl={exports:{}},ml={};/**
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 Yd;function cg(){return Yd||(Yd=1,(function(n){function s(W,O){var H=W.length;W.push(O);e:for(;0<H;){var S=H-1>>>1,_=W[S];if(0<c(_,O))W[S]=O,W[H]=_,H=S;else break e}}function i(W){return W.length===0?null:W[0]}function o(W){if(W.length===0)return null;var O=W[0],H=W.pop();if(H!==O){W[0]=H;e:for(var S=0,_=W.length,J=_>>>1;S<J;){var te=2*(S+1)-1,ce=W[te],ve=te+1,Ce=W[ve];if(0>c(ce,H))ve<_&&0>c(Ce,ce)?(W[S]=Ce,W[ve]=H,S=ve):(W[S]=ce,W[te]=H,S=te);else if(ve<_&&0>c(Ce,H))W[S]=Ce,W[ve]=H,S=ve;else break e}}return O}function c(W,O){var H=W.sortIndex-O.sortIndex;return H!==0?H:W.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var m=Date,g=m.now();n.unstable_now=function(){return m.now()-g}}var p=[],y=[],v=1,j=null,w=3,N=!1,E=!1,k=!1,C=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function $(W){for(var O=i(y);O!==null;){if(O.callback===null)o(y);else if(O.startTime<=W)o(y),O.sortIndex=O.expirationTime,s(p,O);else break;O=i(y)}}function A(W){if(k=!1,$(W),!E)if(i(p)!==null)E=!0,pe(B);else{var O=i(y);O!==null&&ee(A,O.startTime-W)}}function B(W,O){E=!1,k&&(k=!1,T(de),de=-1),N=!0;var H=w;try{for($(O),j=i(p);j!==null&&(!(j.expirationTime>O)||W&&!G());){var S=j.callback;if(typeof S=="function"){j.callback=null,w=j.priorityLevel;var _=S(j.expirationTime<=O);O=n.unstable_now(),typeof _=="function"?j.callback=_:j===i(p)&&o(p),$(O)}else o(p);j=i(p)}if(j!==null)var J=!0;else{var te=i(y);te!==null&&ee(A,te.startTime-O),J=!1}return J}finally{j=null,w=H,N=!1}}var K=!1,V=null,de=-1,Y=5,re=-1;function G(){return!(n.unstable_now()-re<Y)}function D(){if(V!==null){var W=n.unstable_now();re=W;var O=!0;try{O=V(!0,W)}finally{O?ie():(K=!1,V=null)}}else K=!1}var ie;if(typeof I=="function")ie=function(){I(D)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,Z=fe.port2;fe.port1.onmessage=D,ie=function(){Z.postMessage(null)}}else ie=function(){C(D,0)};function pe(W){V=W,K||(K=!0,ie())}function ee(W,O){de=C(function(){W(n.unstable_now())},O)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(W){W.callback=null},n.unstable_continueExecution=function(){E||N||(E=!0,pe(B))},n.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},n.unstable_getCurrentPriorityLevel=function(){return w},n.unstable_getFirstCallbackNode=function(){return i(p)},n.unstable_next=function(W){switch(w){case 1:case 2:case 3:var O=3;break;default:O=w}var H=w;w=O;try{return W()}finally{w=H}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(W,O){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var H=w;w=W;try{return O()}finally{w=H}},n.unstable_scheduleCallback=function(W,O,H){var S=n.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?S+H:S):H=S,W){case 1:var _=-1;break;case 2:_=250;break;case 5:_=1073741823;break;case 4:_=1e4;break;default:_=5e3}return _=H+_,W={id:v++,callback:O,priorityLevel:W,startTime:H,expirationTime:_,sortIndex:-1},H>S?(W.sortIndex=H,s(y,W),i(p)===null&&W===i(y)&&(k?(T(de),de=-1):k=!0,ee(A,H-S))):(W.sortIndex=_,s(p,W),E||N||(E=!0,pe(B))),W},n.unstable_shouldYield=G,n.unstable_wrapCallback=function(W){var O=w;return function(){var H=w;w=O;try{return W.apply(this,arguments)}finally{w=H}}}})(ml)),ml}var Jd;function ug(){return Jd||(Jd=1,hl.exports=cg()),hl.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 qd;function dg(){if(qd)return Mt;qd=1;var n=Ml(),s=ug();function i(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,a=1;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,c={};function d(e,t){m(e,t),m(e+"Capture",t)}function m(e,t){for(c[e]=t,e=0;e<t.length;e++)o.add(t[e])}var g=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[: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={},j={};function w(e){return p.call(j,e)?!0:p.call(v,e)?!1:y.test(e)?j[e]=!0:(v[e]=!0,!1)}function N(e,t,a,l){if(a!==null&&a.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return l?!1:a!==null?!a.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function E(e,t,a,l){if(t===null||typeof t>"u"||N(e,t,a,l))return!0;if(l)return!1;if(a!==null)switch(a.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function k(e,t,a,l,u,h,x){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=l,this.attributeNamespace=u,this.mustUseProperty=a,this.propertyName=e,this.type=t,this.sanitizeURL=h,this.removeEmptyString=x}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){C[e]=new k(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];C[t]=new k(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){C[e]=new k(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){C[e]=new k(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 k(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){C[e]=new k(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){C[e]=new k(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){C[e]=new k(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){C[e]=new k(e,5,!1,e.toLowerCase(),null,!1,!1)});var T=/[\-:]([a-z])/g;function I(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(T,I);C[t]=new k(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(T,I);C[t]=new k(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(T,I);C[t]=new k(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){C[e]=new k(e,1,!1,e.toLowerCase(),null,!1,!1)}),C.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){C[e]=new k(e,1,!1,e.toLowerCase(),null,!0,!0)});function $(e,t,a,l){var u=C.hasOwnProperty(t)?C[t]:null;(u!==null?u.type!==0:l||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(E(t,a,u,l)&&(a=null),l||u===null?w(t)&&(a===null?e.removeAttribute(t):e.setAttribute(t,""+a)):u.mustUseProperty?e[u.propertyName]=a===null?u.type===3?!1:"":a:(t=u.attributeName,l=u.attributeNamespace,a===null?e.removeAttribute(t):(u=u.type,a=u===3||u===4&&a===!0?"":""+a,l?e.setAttributeNS(l,t,a):e.setAttribute(t,a))))}var A=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,B=Symbol.for("react.element"),K=Symbol.for("react.portal"),V=Symbol.for("react.fragment"),de=Symbol.for("react.strict_mode"),Y=Symbol.for("react.profiler"),re=Symbol.for("react.provider"),G=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),ie=Symbol.for("react.suspense"),fe=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),pe=Symbol.for("react.lazy"),ee=Symbol.for("react.offscreen"),W=Symbol.iterator;function O(e){return e===null||typeof e!="object"?null:(e=W&&e[W]||e["@@iterator"],typeof e=="function"?e:null)}var H=Object.assign,S;function _(e){if(S===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);S=t&&t[1]||""}return`
34
+ `+S+e}var J=!1;function te(e,t){if(!e||J)return"";J=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(U){var l=U}Reflect.construct(e,[],t)}else{try{t.call()}catch(U){l=U}e.call(t.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
+ `),h=l.stack.split(`
36
+ `),x=u.length-1,b=h.length-1;1<=x&&0<=b&&u[x]!==h[b];)b--;for(;1<=x&&0<=b;x--,b--)if(u[x]!==h[b]){if(x!==1||b!==1)do if(x--,b--,0>b||u[x]!==h[b]){var R=`
37
+ `+u[x].replace(" at new "," at ");return e.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",e.displayName)),R}while(1<=x&&0<=b);break}}}finally{J=!1,Error.prepareStackTrace=a}return(e=e?e.displayName||e.name:"")?_(e):""}function ce(e){switch(e.tag){case 5:return _(e.type);case 16:return _("Lazy");case 13:return _("Suspense");case 19:return _("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 V:return"Fragment";case K:return"Portal";case Y:return"Profiler";case de:return"StrictMode";case ie:return"Suspense";case fe:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case G:return(e.displayName||"Context")+".Consumer";case re:return(e._context.displayName||"Context")+".Provider";case D:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Z:return t=e.displayName||null,t!==null?t:ve(e.type)||"Memo";case pe:t=e._payload,e=e._init;try{return ve(e(t))}catch{}}return null}function Ce(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ve(t);case 8:return t===de?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function 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 t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function $e(e){var t=se(e)?"checked":"value",a=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),l=""+e[t];if(!e.hasOwnProperty(t)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var u=a.get,h=a.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return u.call(this)},set:function(x){l=""+x,h.call(this,x)}}),Object.defineProperty(e,t,{enumerable:a.enumerable}),{getValue:function(){return l},setValue:function(x){l=""+x},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ee(e){e._valueTracker||(e._valueTracker=$e(e))}function _e(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==a?(t.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,t){var a=t.checked;return H({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??e._wrapperState.initialChecked})}function we(e,t){var a=t.defaultValue==null?"":t.defaultValue,l=t.checked!=null?t.checked:t.defaultChecked;a=ke(t.value!=null?t.value:a),e._wrapperState={initialChecked:l,initialValue:a,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Te(e,t){t=t.checked,t!=null&&$(e,"checked",t,!1)}function Le(e,t){Te(e,t);var a=ke(t.value),l=t.type;if(a!=null)l==="number"?(a===0&&e.value===""||e.value!=a)&&(e.value=""+a):e.value!==""+a&&(e.value=""+a);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?xt(e,t.type,a):t.hasOwnProperty("defaultValue")&&xt(e,t.type,ke(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function lt(e,t,a){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var l=t.type;if(!(l!=="submit"&&l!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,a||t===e.value||(e.value=t),e.defaultValue=t}a=e.name,a!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,a!==""&&(e.name=a)}function xt(e,t,a){(t!=="number"||he(e.ownerDocument)!==e)&&(a==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+a&&(e.defaultValue=""+a))}var Ke=Array.isArray;function et(e,t,a,l){if(e=e.options,t){t={};for(var u=0;u<a.length;u++)t["$"+a[u]]=!0;for(a=0;a<e.length;a++)u=t.hasOwnProperty("$"+e[a].value),e[a].selected!==u&&(e[a].selected=u),u&&l&&(e[a].defaultSelected=!0)}else{for(a=""+ke(a),t=null,u=0;u<e.length;u++){if(e[u].value===a){e[u].selected=!0,l&&(e[u].defaultSelected=!0);return}t!==null||e[u].disabled||(t=e[u])}t!==null&&(t.selected=!0)}}function st(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(i(91));return H({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function mt(e,t){var a=t.value;if(a==null){if(a=t.children,t=t.defaultValue,a!=null){if(t!=null)throw Error(i(92));if(Ke(a)){if(1<a.length)throw Error(i(93));a=a[0]}t=a}t==null&&(t=""),a=t}e._wrapperState={initialValue:ke(a)}}function Fe(e,t){var a=ke(t.value),l=ke(t.defaultValue);a!=null&&(a=""+a,a!==e.value&&(e.value=a),t.defaultValue==null&&e.defaultValue!==a&&(e.defaultValue=a)),l!=null&&(e.defaultValue=""+l)}function L(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function oe(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,t){return e==null||e==="http://www.w3.org/1999/xhtml"?oe(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Re,ue=(function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,a,l,u){MSApp.execUnsafeLocalFunction(function(){return e(t,a,l,u)})}:e})(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Re=Re||document.createElement("div"),Re.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Re.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Oe(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}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(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ge[t]=Ge[e]})});function ft(e,t,a){return t==null||typeof t=="boolean"||t===""?"":a||typeof t!="number"||t===0||Ge.hasOwnProperty(e)&&Ge[e]?(""+t).trim():t+"px"}function fn(e,t){e=e.style;for(var a in t)if(t.hasOwnProperty(a)){var l=a.indexOf("--")===0,u=ft(a,t[a],l);a==="float"&&(a="cssFloat"),l?e.setProperty(a,u):e[a]=u}}var vn=H({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,t){if(t){if(vn[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(i(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(i(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(i(61))}if(t.style!=null&&typeof t.style!="object")throw Error(i(62))}}function bt(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var 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=js(e)){if(typeof ae!="function")throw Error(i(280));var t=e.stateNode;t&&(t=wa(t),ae(e.stateNode,e.type,t))}}function ze(e){je?ge?ge.push(e):ge=[e]:je=e}function Je(){if(je){var e=je,t=ge;if(ge=je=null,Me(e),t)for(e=0;e<t.length;e++)Me(t[e])}}function Dt(e,t){return e(t)}function Xn(){}var ts=!1;function Xs(e,t,a){if(ts)return e(t,a);ts=!0;try{return Dt(e,t,a)}finally{ts=!1,(je!==null||ge!==null)&&(Xn(),Je())}}function xn(e,t){var a=e.stateNode;if(a===null)return null;var l=wa(a);if(l===null)return null;a=l[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(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(a&&typeof a!="function")throw Error(i(231,t,typeof a));return a}var Zn=!1;if(g)try{var er={};Object.defineProperty(er,"passive",{get:function(){Zn=!0}}),window.addEventListener("test",er,er),window.removeEventListener("test",er,er)}catch{Zn=!1}function Zs(e,t,a,l,u,h,x,b,R){var U=Array.prototype.slice.call(arguments,3);try{t.apply(a,U)}catch(Q){this.onError(Q)}}var Pn=!1,tr=null,nr=!1,ns=null,kr={onError:function(e){Pn=!0,tr=e}};function wn(e,t,a,l,u,h,x,b,R){Pn=!1,tr=null,Zs.apply(kr,arguments)}function hm(e,t,a,l,u,h,x,b,R){if(wn.apply(this,arguments),Pn){if(Pn){var U=tr;Pn=!1,tr=null}else throw Error(i(198));nr||(nr=!0,ns=U)}}function rr(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function hc(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function mc(e){if(rr(e)!==e)throw Error(i(188))}function mm(e){var t=e.alternate;if(!t){if(t=rr(e),t===null)throw Error(i(188));return t!==e?null:e}for(var a=e,l=t;;){var u=a.return;if(u===null)break;var h=u.alternate;if(h===null){if(l=u.return,l!==null){a=l;continue}break}if(u.child===h.child){for(h=u.child;h;){if(h===a)return mc(u),e;if(h===l)return mc(u),t;h=h.sibling}throw Error(i(188))}if(a.return!==l.return)a=u,l=h;else{for(var x=!1,b=u.child;b;){if(b===a){x=!0,a=u,l=h;break}if(b===l){x=!0,l=u,a=h;break}b=b.sibling}if(!x){for(b=h.child;b;){if(b===a){x=!0,a=h,l=u;break}if(b===l){x=!0,l=h,a=u;break}b=b.sibling}if(!x)throw Error(i(189))}}if(a.alternate!==l)throw Error(i(190))}if(a.tag!==3)throw Error(i(188));return a.stateNode.current===a?e:t}function pc(e){return e=mm(e),e!==null?gc(e):null}function gc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=gc(e);if(t!==null)return t;e=e.sibling}return null}var yc=s.unstable_scheduleCallback,vc=s.unstable_cancelCallback,pm=s.unstable_shouldYield,gm=s.unstable_requestPaint,ct=s.unstable_now,ym=s.unstable_getCurrentPriorityLevel,Ri=s.unstable_ImmediatePriority,xc=s.unstable_UserBlockingPriority,ea=s.unstable_NormalPriority,vm=s.unstable_LowPriority,wc=s.unstable_IdlePriority,ta=null,hn=null;function xm(e){if(hn&&typeof hn.onCommitFiberRoot=="function")try{hn.onCommitFiberRoot(ta,e,void 0,(e.current.flags&128)===128)}catch{}}var tn=Math.clz32?Math.clz32:Sm,wm=Math.log,jm=Math.LN2;function Sm(e){return e>>>=0,e===0?32:31-(wm(e)/jm|0)|0}var na=64,ra=4194304;function rs(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 sa(e,t){var a=e.pendingLanes;if(a===0)return 0;var l=0,u=e.suspendedLanes,h=e.pingedLanes,x=a&268435455;if(x!==0){var b=x&~u;b!==0?l=rs(b):(h&=x,h!==0&&(l=rs(h)))}else x=a&~u,x!==0?l=rs(x):h!==0&&(l=rs(h));if(l===0)return 0;if(t!==0&&t!==l&&(t&u)===0&&(u=l&-l,h=t&-t,u>=h||u===16&&(h&4194240)!==0))return t;if((l&4)!==0&&(l|=a&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=l;0<t;)a=31-tn(t),u=1<<a,l|=e[a],t&=~u;return l}function km(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function bm(e,t){for(var a=e.suspendedLanes,l=e.pingedLanes,u=e.expirationTimes,h=e.pendingLanes;0<h;){var x=31-tn(h),b=1<<x,R=u[x];R===-1?((b&a)===0||(b&l)!==0)&&(u[x]=km(b,t)):R<=t&&(e.expiredLanes|=b),h&=~b}}function Ii(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function jc(){var e=na;return na<<=1,(na&4194240)===0&&(na=64),e}function Ai(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function ss(e,t,a){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-tn(t),e[t]=a}function Nm(e,t){var a=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0<a;){var u=31-tn(a),h=1<<u;t[u]=0,l[u]=-1,e[u]=-1,a&=~h}}function Pi(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var l=31-tn(a),u=1<<l;u&t|e[l]&t&&(e[l]|=t),a&=~u}}var Ve=0;function Sc(e){return e&=-e,1<e?4<e?(e&268435455)!==0?16:536870912:4:1}var kc,_i,bc,Nc,Cc,Li=!1,aa=[],_n=null,Ln=null,$n=null,as=new Map,is=new Map,zn=[],Cm="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 Ec(e,t){switch(e){case"focusin":case"focusout":_n=null;break;case"dragenter":case"dragleave":Ln=null;break;case"mouseover":case"mouseout":$n=null;break;case"pointerover":case"pointerout":as.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":is.delete(t.pointerId)}}function os(e,t,a,l,u,h){return e===null||e.nativeEvent!==h?(e={blockedOn:t,domEventName:a,eventSystemFlags:l,nativeEvent:h,targetContainers:[u]},t!==null&&(t=js(t),t!==null&&_i(t)),e):(e.eventSystemFlags|=l,t=e.targetContainers,u!==null&&t.indexOf(u)===-1&&t.push(u),e)}function Em(e,t,a,l,u){switch(t){case"focusin":return _n=os(_n,e,t,a,l,u),!0;case"dragenter":return Ln=os(Ln,e,t,a,l,u),!0;case"mouseover":return $n=os($n,e,t,a,l,u),!0;case"pointerover":var h=u.pointerId;return as.set(h,os(as.get(h)||null,e,t,a,l,u)),!0;case"gotpointercapture":return h=u.pointerId,is.set(h,os(is.get(h)||null,e,t,a,l,u)),!0}return!1}function Tc(e){var t=sr(e.target);if(t!==null){var a=rr(t);if(a!==null){if(t=a.tag,t===13){if(t=hc(a),t!==null){e.blockedOn=t,Cc(e.priority,function(){bc(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ia(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=zi(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(a===null){a=e.nativeEvent;var l=new a.constructor(a.type,a);Et=l,a.target.dispatchEvent(l),Et=null}else return t=js(a),t!==null&&_i(t),e.blockedOn=a,!1;t.shift()}return!0}function Rc(e,t,a){ia(e)&&a.delete(t)}function Tm(){Li=!1,_n!==null&&ia(_n)&&(_n=null),Ln!==null&&ia(Ln)&&(Ln=null),$n!==null&&ia($n)&&($n=null),as.forEach(Rc),is.forEach(Rc)}function ls(e,t){e.blockedOn===t&&(e.blockedOn=null,Li||(Li=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Tm)))}function cs(e){function t(u){return ls(u,e)}if(0<aa.length){ls(aa[0],e);for(var a=1;a<aa.length;a++){var l=aa[a];l.blockedOn===e&&(l.blockedOn=null)}}for(_n!==null&&ls(_n,e),Ln!==null&&ls(Ln,e),$n!==null&&ls($n,e),as.forEach(t),is.forEach(t),a=0;a<zn.length;a++)l=zn[a],l.blockedOn===e&&(l.blockedOn=null);for(;0<zn.length&&(a=zn[0],a.blockedOn===null);)Tc(a),a.blockedOn===null&&zn.shift()}var br=A.ReactCurrentBatchConfig,oa=!0;function Rm(e,t,a,l){var u=Ve,h=br.transition;br.transition=null;try{Ve=1,$i(e,t,a,l)}finally{Ve=u,br.transition=h}}function Im(e,t,a,l){var u=Ve,h=br.transition;br.transition=null;try{Ve=4,$i(e,t,a,l)}finally{Ve=u,br.transition=h}}function $i(e,t,a,l){if(oa){var u=zi(e,t,a,l);if(u===null)Zi(e,t,l,la,a),Ec(e,l);else if(Em(u,e,t,a,l))l.stopPropagation();else if(Ec(e,l),t&4&&-1<Cm.indexOf(e)){for(;u!==null;){var h=js(u);if(h!==null&&kc(h),h=zi(e,t,a,l),h===null&&Zi(e,t,l,la,a),h===u)break;u=h}u!==null&&l.stopPropagation()}else Zi(e,t,l,null,a)}}var la=null;function zi(e,t,a,l){if(la=null,e=wt(l),e=sr(e),e!==null)if(t=rr(e),t===null)e=null;else if(a=t.tag,a===13){if(e=hc(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return la=e,null}function Ic(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(ym()){case Ri:return 1;case xc:return 4;case ea:case vm:return 16;case wc:return 536870912;default:return 16}default:return 16}}var Fn=null,Fi=null,ca=null;function Ac(){if(ca)return ca;var e,t=Fi,a=t.length,l,u="value"in Fn?Fn.value:Fn.textContent,h=u.length;for(e=0;e<a&&t[e]===u[e];e++);var x=a-e;for(l=1;l<=x&&t[a-l]===u[h-l];l++);return ca=u.slice(e,1<l?1-l:void 0)}function ua(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function da(){return!0}function Pc(){return!1}function Ut(e){function t(a,l,u,h,x){this._reactName=a,this._targetInst=u,this.type=l,this.nativeEvent=h,this.target=x,this.currentTarget=null;for(var b in e)e.hasOwnProperty(b)&&(a=e[b],this[b]=a?a(h):h[b]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?da:Pc,this.isPropagationStopped=Pc,this}return H(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=da)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=da)},persist:function(){},isPersistent:da}),t}var Nr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Oi=Ut(Nr),us=H({},Nr,{view:0,detail:0}),Am=Ut(us),Mi,Bi,ds,fa=H({},us,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ui,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ds&&(ds&&e.type==="mousemove"?(Mi=e.screenX-ds.screenX,Bi=e.screenY-ds.screenY):Bi=Mi=0,ds=e),Mi)},movementY:function(e){return"movementY"in e?e.movementY:Bi}}),_c=Ut(fa),Pm=H({},fa,{dataTransfer:0}),_m=Ut(Pm),Lm=H({},us,{relatedTarget:0}),Di=Ut(Lm),$m=H({},Nr,{animationName:0,elapsedTime:0,pseudoElement:0}),zm=Ut($m),Fm=H({},Nr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Om=Ut(Fm),Mm=H({},Nr,{data:0}),Lc=Ut(Mm),Bm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Dm={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"},Um={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Wm(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Um[e])?!!t[e]:!1}function Ui(){return Wm}var Hm=H({},us,{key:function(e){if(e.key){var t=Bm[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ua(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Dm[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ui,charCode:function(e){return e.type==="keypress"?ua(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ua(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Vm=Ut(Hm),Gm=H({},fa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$c=Ut(Gm),Km=H({},us,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ui}),Ym=Ut(Km),Jm=H({},Nr,{propertyName:0,elapsedTime:0,pseudoElement:0}),qm=Ut(Jm),Qm=H({},fa,{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}),Xm=Ut(Qm),Zm=[9,13,27,32],Wi=g&&"CompositionEvent"in window,fs=null;g&&"documentMode"in document&&(fs=document.documentMode);var ep=g&&"TextEvent"in window&&!fs,zc=g&&(!Wi||fs&&8<fs&&11>=fs),Fc=" ",Oc=!1;function Mc(e,t){switch(e){case"keyup":return Zm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Cr=!1;function tp(e,t){switch(e){case"compositionend":return Bc(t);case"keypress":return t.which!==32?null:(Oc=!0,Fc);case"textInput":return e=t.data,e===Fc&&Oc?null:e;default:return null}}function np(e,t){if(Cr)return e==="compositionend"||!Wi&&Mc(e,t)?(e=Ac(),ca=Fi=Fn=null,Cr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return zc&&t.locale!=="ko"?null:t.data;default:return null}}var rp={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 Dc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!rp[e.type]:t==="textarea"}function Uc(e,t,a,l){ze(l),t=ya(t,"onChange"),0<t.length&&(a=new Oi("onChange","change",null,a,l),e.push({event:a,listeners:t}))}var hs=null,ms=null;function sp(e){iu(e,0)}function ha(e){var t=Ar(e);if(_e(t))return e}function ap(e,t){if(e==="change")return t}var Wc=!1;if(g){var Hi;if(g){var Vi="oninput"in document;if(!Vi){var Hc=document.createElement("div");Hc.setAttribute("oninput","return;"),Vi=typeof Hc.oninput=="function"}Hi=Vi}else Hi=!1;Wc=Hi&&(!document.documentMode||9<document.documentMode)}function Vc(){hs&&(hs.detachEvent("onpropertychange",Gc),ms=hs=null)}function Gc(e){if(e.propertyName==="value"&&ha(ms)){var t=[];Uc(t,ms,e,wt(e)),Xs(sp,t)}}function ip(e,t,a){e==="focusin"?(Vc(),hs=t,ms=a,hs.attachEvent("onpropertychange",Gc)):e==="focusout"&&Vc()}function op(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ha(ms)}function lp(e,t){if(e==="click")return ha(t)}function cp(e,t){if(e==="input"||e==="change")return ha(t)}function up(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var nn=typeof Object.is=="function"?Object.is:up;function ps(e,t){if(nn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),l=Object.keys(t);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var u=a[l];if(!p.call(t,u)||!nn(e[u],t[u]))return!1}return!0}function Kc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Yc(e,t){var a=Kc(e);e=0;for(var l;a;){if(a.nodeType===3){if(l=e+a.textContent.length,e<=t&&l>=t)return{node:a,offset:t-e};e=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Kc(a)}}function Jc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Jc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qc(){for(var e=window,t=he();t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=he(e.document)}return t}function Gi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function dp(e){var t=qc(),a=e.focusedElem,l=e.selectionRange;if(t!==a&&a&&a.ownerDocument&&Jc(a.ownerDocument.documentElement,a)){if(l!==null&&Gi(a)){if(t=l.start,e=l.end,e===void 0&&(e=t),"selectionStart"in a)a.selectionStart=t,a.selectionEnd=Math.min(e,a.value.length);else if(e=(t=a.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var u=a.textContent.length,h=Math.min(l.start,u);l=l.end===void 0?h:Math.min(l.end,u),!e.extend&&h>l&&(u=l,l=h,h=u),u=Yc(a,h);var x=Yc(a,l);u&&x&&(e.rangeCount!==1||e.anchorNode!==u.node||e.anchorOffset!==u.offset||e.focusNode!==x.node||e.focusOffset!==x.offset)&&(t=t.createRange(),t.setStart(u.node,u.offset),e.removeAllRanges(),h>l?(e.addRange(t),e.extend(x.node,x.offset)):(t.setEnd(x.node,x.offset),e.addRange(t)))}}for(t=[],e=a;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<t.length;a++)e=t[a],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var fp=g&&"documentMode"in document&&11>=document.documentMode,Er=null,Ki=null,gs=null,Yi=!1;function Qc(e,t,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Yi||Er==null||Er!==he(l)||(l=Er,"selectionStart"in l&&Gi(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}),gs&&ps(gs,l)||(gs=l,l=ya(Ki,"onSelect"),0<l.length&&(t=new Oi("onSelect","select",null,t,a),e.push({event:t,listeners:l}),t.target=Er)))}function ma(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var Tr={animationend:ma("Animation","AnimationEnd"),animationiteration:ma("Animation","AnimationIteration"),animationstart:ma("Animation","AnimationStart"),transitionend:ma("Transition","TransitionEnd")},Ji={},Xc={};g&&(Xc=document.createElement("div").style,"AnimationEvent"in window||(delete Tr.animationend.animation,delete Tr.animationiteration.animation,delete Tr.animationstart.animation),"TransitionEvent"in window||delete Tr.transitionend.transition);function pa(e){if(Ji[e])return Ji[e];if(!Tr[e])return e;var t=Tr[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in Xc)return Ji[e]=t[a];return e}var Zc=pa("animationend"),eu=pa("animationiteration"),tu=pa("animationstart"),nu=pa("transitionend"),ru=new Map,su="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 On(e,t){ru.set(e,t),d(t,[e])}for(var qi=0;qi<su.length;qi++){var Qi=su[qi],hp=Qi.toLowerCase(),mp=Qi[0].toUpperCase()+Qi.slice(1);On(hp,"on"+mp)}On(Zc,"onAnimationEnd"),On(eu,"onAnimationIteration"),On(tu,"onAnimationStart"),On("dblclick","onDoubleClick"),On("focusin","onFocus"),On("focusout","onBlur"),On(nu,"onTransitionEnd"),m("onMouseEnter",["mouseout","mouseover"]),m("onMouseLeave",["mouseout","mouseover"]),m("onPointerEnter",["pointerout","pointerover"]),m("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 ys="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(" "),pp=new Set("cancel close invalid load scroll toggle".split(" ").concat(ys));function au(e,t,a){var l=e.type||"unknown-event";e.currentTarget=a,hm(l,t,void 0,e),e.currentTarget=null}function iu(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var l=e[a],u=l.event;l=l.listeners;e:{var h=void 0;if(t)for(var x=l.length-1;0<=x;x--){var b=l[x],R=b.instance,U=b.currentTarget;if(b=b.listener,R!==h&&u.isPropagationStopped())break e;au(u,b,U),h=R}else for(x=0;x<l.length;x++){if(b=l[x],R=b.instance,U=b.currentTarget,b=b.listener,R!==h&&u.isPropagationStopped())break e;au(u,b,U),h=R}}}if(nr)throw e=ns,nr=!1,ns=null,e}function Xe(e,t){var a=t[ao];a===void 0&&(a=t[ao]=new Set);var l=e+"__bubble";a.has(l)||(ou(t,e,2,!1),a.add(l))}function Xi(e,t,a){var l=0;t&&(l|=4),ou(a,e,l,t)}var ga="_reactListening"+Math.random().toString(36).slice(2);function vs(e){if(!e[ga]){e[ga]=!0,o.forEach(function(a){a!=="selectionchange"&&(pp.has(a)||Xi(a,!1,e),Xi(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[ga]||(t[ga]=!0,Xi("selectionchange",!1,t))}}function ou(e,t,a,l){switch(Ic(t)){case 1:var u=Rm;break;case 4:u=Im;break;default:u=$i}a=u.bind(null,t,a,e),u=void 0,!Zn||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(u=!0),l?u!==void 0?e.addEventListener(t,a,{capture:!0,passive:u}):e.addEventListener(t,a,!0):u!==void 0?e.addEventListener(t,a,{passive:u}):e.addEventListener(t,a,!1)}function Zi(e,t,a,l,u){var h=l;if((t&1)===0&&(t&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 R=x.tag;if((R===3||R===4)&&(R=x.stateNode.containerInfo,R===u||R.nodeType===8&&R.parentNode===u))return;x=x.return}for(;b!==null;){if(x=sr(b),x===null)return;if(R=x.tag,R===5||R===6){l=h=x;continue e}b=b.parentNode}}l=l.return}Xs(function(){var U=h,Q=wt(a),ne=[];e:{var q=ru.get(e);if(q!==void 0){var ye=Oi,Se=e;switch(e){case"keypress":if(ua(a)===0)break e;case"keydown":case"keyup":ye=Vm;break;case"focusin":Se="focus",ye=Di;break;case"focusout":Se="blur",ye=Di;break;case"beforeblur":case"afterblur":ye=Di;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ye=_c;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ye=_m;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ye=Ym;break;case Zc:case eu:case tu:ye=zm;break;case nu:ye=qm;break;case"scroll":ye=Am;break;case"wheel":ye=Xm;break;case"copy":case"cut":case"paste":ye=Om;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ye=$c}var be=(t&4)!==0,ut=!be&&e==="scroll",z=be?q!==null?q+"Capture":null:q;be=[];for(var P=U,F;P!==null;){F=P;var le=F.stateNode;if(F.tag===5&&le!==null&&(F=le,z!==null&&(le=xn(P,z),le!=null&&be.push(xs(P,le,F)))),ut)break;P=P.return}0<be.length&&(q=new ye(q,Se,null,a,Q),ne.push({event:q,listeners:be}))}}if((t&7)===0){e:{if(q=e==="mouseover"||e==="pointerover",ye=e==="mouseout"||e==="pointerout",q&&a!==Et&&(Se=a.relatedTarget||a.fromElement)&&(sr(Se)||Se[jn]))break e;if((ye||q)&&(q=Q.window===Q?Q:(q=Q.ownerDocument)?q.defaultView||q.parentWindow:window,ye?(Se=a.relatedTarget||a.toElement,ye=U,Se=Se?sr(Se):null,Se!==null&&(ut=rr(Se),Se!==ut||Se.tag!==5&&Se.tag!==6)&&(Se=null)):(ye=null,Se=U),ye!==Se)){if(be=_c,le="onMouseLeave",z="onMouseEnter",P="mouse",(e==="pointerout"||e==="pointerover")&&(be=$c,le="onPointerLeave",z="onPointerEnter",P="pointer"),ut=ye==null?q:Ar(ye),F=Se==null?q:Ar(Se),q=new be(le,P+"leave",ye,a,Q),q.target=ut,q.relatedTarget=F,le=null,sr(Q)===U&&(be=new be(z,P+"enter",Se,a,Q),be.target=F,be.relatedTarget=ut,le=be),ut=le,ye&&Se)t:{for(be=ye,z=Se,P=0,F=be;F;F=Rr(F))P++;for(F=0,le=z;le;le=Rr(le))F++;for(;0<P-F;)be=Rr(be),P--;for(;0<F-P;)z=Rr(z),F--;for(;P--;){if(be===z||z!==null&&be===z.alternate)break t;be=Rr(be),z=Rr(z)}be=null}else be=null;ye!==null&&lu(ne,q,ye,be,!1),Se!==null&&ut!==null&&lu(ne,ut,Se,be,!0)}}e:{if(q=U?Ar(U):window,ye=q.nodeName&&q.nodeName.toLowerCase(),ye==="select"||ye==="input"&&q.type==="file")var Ne=ap;else if(Dc(q))if(Wc)Ne=cp;else{Ne=op;var Ie=ip}else(ye=q.nodeName)&&ye.toLowerCase()==="input"&&(q.type==="checkbox"||q.type==="radio")&&(Ne=lp);if(Ne&&(Ne=Ne(e,U))){Uc(ne,Ne,a,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?Ar(U):window,e){case"focusin":(Dc(Ie)||Ie.contentEditable==="true")&&(Er=Ie,Ki=U,gs=null);break;case"focusout":gs=Ki=Er=null;break;case"mousedown":Yi=!0;break;case"contextmenu":case"mouseup":case"dragend":Yi=!1,Qc(ne,a,Q);break;case"selectionchange":if(fp)break;case"keydown":case"keyup":Qc(ne,a,Q)}var Ae;if(Wi)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 Cr?Mc(e,a)&&(Pe="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Pe="onCompositionStart");Pe&&(zc&&a.locale!=="ko"&&(Cr||Pe!=="onCompositionStart"?Pe==="onCompositionEnd"&&Cr&&(Ae=Ac()):(Fn=Q,Fi="value"in Fn?Fn.value:Fn.textContent,Cr=!0)),Ie=ya(U,Pe),0<Ie.length&&(Pe=new Lc(Pe,e,null,a,Q),ne.push({event:Pe,listeners:Ie}),Ae?Pe.data=Ae:(Ae=Bc(a),Ae!==null&&(Pe.data=Ae)))),(Ae=ep?tp(e,a):np(e,a))&&(U=ya(U,"onBeforeInput"),0<U.length&&(Q=new Lc("onBeforeInput","beforeinput",null,a,Q),ne.push({event:Q,listeners:U}),Q.data=Ae))}iu(ne,t)})}function xs(e,t,a){return{instance:e,listener:t,currentTarget:a}}function ya(e,t){for(var a=t+"Capture",l=[];e!==null;){var u=e,h=u.stateNode;u.tag===5&&h!==null&&(u=h,h=xn(e,a),h!=null&&l.unshift(xs(e,h,u)),h=xn(e,t),h!=null&&l.push(xs(e,h,u))),e=e.return}return l}function Rr(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function lu(e,t,a,l,u){for(var h=t._reactName,x=[];a!==null&&a!==l;){var b=a,R=b.alternate,U=b.stateNode;if(R!==null&&R===l)break;b.tag===5&&U!==null&&(b=U,u?(R=xn(a,h),R!=null&&x.unshift(xs(a,R,b))):u||(R=xn(a,h),R!=null&&x.push(xs(a,R,b)))),a=a.return}x.length!==0&&e.push({event:t,listeners:x})}var gp=/\r\n?/g,yp=/\u0000|\uFFFD/g;function cu(e){return(typeof e=="string"?e:""+e).replace(gp,`
38
+ `).replace(yp,"")}function va(e,t,a){if(t=cu(t),cu(e)!==t&&a)throw Error(i(425))}function xa(){}var eo=null,to=null;function no(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var ro=typeof setTimeout=="function"?setTimeout:void 0,vp=typeof clearTimeout=="function"?clearTimeout:void 0,uu=typeof Promise=="function"?Promise:void 0,xp=typeof queueMicrotask=="function"?queueMicrotask:typeof uu<"u"?function(e){return uu.resolve(null).then(e).catch(wp)}:ro;function wp(e){setTimeout(function(){throw e})}function so(e,t){var a=t,l=0;do{var u=a.nextSibling;if(e.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"){if(l===0){e.removeChild(u),cs(t);return}l--}else a!=="$"&&a!=="$?"&&a!=="$!"||l++;a=u}while(a);cs(t)}function Mn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function du(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"){if(t===0)return e;t--}else a==="/$"&&t++}e=e.previousSibling}return null}var Ir=Math.random().toString(36).slice(2),mn="__reactFiber$"+Ir,ws="__reactProps$"+Ir,jn="__reactContainer$"+Ir,ao="__reactEvents$"+Ir,jp="__reactListeners$"+Ir,Sp="__reactHandles$"+Ir;function sr(e){var t=e[mn];if(t)return t;for(var a=e.parentNode;a;){if(t=a[jn]||a[mn]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=du(e);e!==null;){if(a=e[mn])return a;e=du(e)}return t}e=a,a=e.parentNode}return null}function js(e){return e=e[mn]||e[jn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Ar(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(i(33))}function wa(e){return e[ws]||null}var io=[],Pr=-1;function Bn(e){return{current:e}}function Ze(e){0>Pr||(e.current=io[Pr],io[Pr]=null,Pr--)}function qe(e,t){Pr++,io[Pr]=e.current,e.current=t}var Dn={},Tt=Bn(Dn),Lt=Bn(!1),ar=Dn;function _r(e,t){var a=e.type.contextTypes;if(!a)return Dn;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===t)return l.__reactInternalMemoizedMaskedChildContext;var u={},h;for(h in a)u[h]=t[h];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=u),u}function $t(e){return e=e.childContextTypes,e!=null}function ja(){Ze(Lt),Ze(Tt)}function fu(e,t,a){if(Tt.current!==Dn)throw Error(i(168));qe(Tt,t),qe(Lt,a)}function hu(e,t,a){var l=e.stateNode;if(t=t.childContextTypes,typeof l.getChildContext!="function")return a;l=l.getChildContext();for(var u in l)if(!(u in t))throw Error(i(108,Ce(e)||"Unknown",u));return H({},a,l)}function Sa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Dn,ar=Tt.current,qe(Tt,e),qe(Lt,Lt.current),!0}function mu(e,t,a){var l=e.stateNode;if(!l)throw Error(i(169));a?(e=hu(e,t,ar),l.__reactInternalMemoizedMergedChildContext=e,Ze(Lt),Ze(Tt),qe(Tt,e)):Ze(Lt),qe(Lt,a)}var Sn=null,ka=!1,oo=!1;function pu(e){Sn===null?Sn=[e]:Sn.push(e)}function kp(e){ka=!0,pu(e)}function Un(){if(!oo&&Sn!==null){oo=!0;var e=0,t=Ve;try{var a=Sn;for(Ve=1;e<a.length;e++){var l=a[e];do l=l(!0);while(l!==null)}Sn=null,ka=!1}catch(u){throw Sn!==null&&(Sn=Sn.slice(e+1)),yc(Ri,Un),u}finally{Ve=t,oo=!1}}return null}var Lr=[],$r=0,ba=null,Na=0,Kt=[],Yt=0,ir=null,kn=1,bn="";function or(e,t){Lr[$r++]=Na,Lr[$r++]=ba,ba=e,Na=t}function gu(e,t,a){Kt[Yt++]=kn,Kt[Yt++]=bn,Kt[Yt++]=ir,ir=e;var l=kn;e=bn;var u=32-tn(l)-1;l&=~(1<<u),a+=1;var h=32-tn(t)+u;if(30<h){var x=u-u%5;h=(l&(1<<x)-1).toString(32),l>>=x,u-=x,kn=1<<32-tn(t)+u|a<<u|l,bn=h+e}else kn=1<<h|a<<u|l,bn=e}function lo(e){e.return!==null&&(or(e,1),gu(e,1,0))}function co(e){for(;e===ba;)ba=Lr[--$r],Lr[$r]=null,Na=Lr[--$r],Lr[$r]=null;for(;e===ir;)ir=Kt[--Yt],Kt[Yt]=null,bn=Kt[--Yt],Kt[Yt]=null,kn=Kt[--Yt],Kt[Yt]=null}var Wt=null,Ht=null,nt=!1,rn=null;function yu(e,t){var a=Xt(5,null,null,0);a.elementType="DELETED",a.stateNode=t,a.return=e,t=e.deletions,t===null?(e.deletions=[a],e.flags|=16):t.push(a)}function vu(e,t){switch(e.tag){case 5:var a=e.type;return t=t.nodeType!==1||a.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Wt=e,Ht=Mn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Wt=e,Ht=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(a=ir!==null?{id:kn,overflow:bn}:null,e.memoizedState={dehydrated:t,treeContext:a,retryLane:1073741824},a=Xt(18,null,null,0),a.stateNode=t,a.return=e,e.child=a,Wt=e,Ht=null,!0):!1;default:return!1}}function uo(e){return(e.mode&1)!==0&&(e.flags&128)===0}function fo(e){if(nt){var t=Ht;if(t){var a=t;if(!vu(e,t)){if(uo(e))throw Error(i(418));t=Mn(a.nextSibling);var l=Wt;t&&vu(e,t)?yu(l,a):(e.flags=e.flags&-4097|2,nt=!1,Wt=e)}}else{if(uo(e))throw Error(i(418));e.flags=e.flags&-4097|2,nt=!1,Wt=e}}}function xu(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Wt=e}function Ca(e){if(e!==Wt)return!1;if(!nt)return xu(e),nt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!no(e.type,e.memoizedProps)),t&&(t=Ht)){if(uo(e))throw wu(),Error(i(418));for(;t;)yu(e,t),t=Mn(t.nextSibling)}if(xu(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"){if(t===0){Ht=Mn(e.nextSibling);break e}t--}else a!=="$"&&a!=="$!"&&a!=="$?"||t++}e=e.nextSibling}Ht=null}}else Ht=Wt?Mn(e.stateNode.nextSibling):null;return!0}function wu(){for(var e=Ht;e;)e=Mn(e.nextSibling)}function zr(){Ht=Wt=null,nt=!1}function ho(e){rn===null?rn=[e]:rn.push(e)}var bp=A.ReactCurrentBatchConfig;function Ss(e,t,a){if(e=a.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(i(309));var l=a.stateNode}if(!l)throw Error(i(147,e));var u=l,h=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===h?t.ref:(t=function(x){var b=u.refs;x===null?delete b[h]:b[h]=x},t._stringRef=h,t)}if(typeof e!="string")throw Error(i(284));if(!a._owner)throw Error(i(290,e))}return e}function Ea(e,t){throw e=Object.prototype.toString.call(t),Error(i(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function ju(e){var t=e._init;return t(e._payload)}function Su(e){function t(z,P){if(e){var F=z.deletions;F===null?(z.deletions=[P],z.flags|=16):F.push(P)}}function a(z,P){if(!e)return null;for(;P!==null;)t(z,P),P=P.sibling;return null}function l(z,P){for(z=new Map;P!==null;)P.key!==null?z.set(P.key,P):z.set(P.index,P),P=P.sibling;return z}function u(z,P){return z=qn(z,P),z.index=0,z.sibling=null,z}function h(z,P,F){return z.index=F,e?(F=z.alternate,F!==null?(F=F.index,F<P?(z.flags|=2,P):F):(z.flags|=2,P)):(z.flags|=1048576,P)}function x(z){return e&&z.alternate===null&&(z.flags|=2),z}function b(z,P,F,le){return P===null||P.tag!==6?(P=sl(F,z.mode,le),P.return=z,P):(P=u(P,F),P.return=z,P)}function R(z,P,F,le){var Ne=F.type;return Ne===V?Q(z,P,F.props.children,le,F.key):P!==null&&(P.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===pe&&ju(Ne)===P.type)?(le=u(P,F.props),le.ref=Ss(z,P,F),le.return=z,le):(le=Qa(F.type,F.key,F.props,null,z.mode,le),le.ref=Ss(z,P,F),le.return=z,le)}function U(z,P,F,le){return P===null||P.tag!==4||P.stateNode.containerInfo!==F.containerInfo||P.stateNode.implementation!==F.implementation?(P=al(F,z.mode,le),P.return=z,P):(P=u(P,F.children||[]),P.return=z,P)}function Q(z,P,F,le,Ne){return P===null||P.tag!==7?(P=pr(F,z.mode,le,Ne),P.return=z,P):(P=u(P,F),P.return=z,P)}function ne(z,P,F){if(typeof P=="string"&&P!==""||typeof P=="number")return P=sl(""+P,z.mode,F),P.return=z,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case B:return F=Qa(P.type,P.key,P.props,null,z.mode,F),F.ref=Ss(z,null,P),F.return=z,F;case K:return P=al(P,z.mode,F),P.return=z,P;case pe:var le=P._init;return ne(z,le(P._payload),F)}if(Ke(P)||O(P))return P=pr(P,z.mode,F,null),P.return=z,P;Ea(z,P)}return null}function q(z,P,F,le){var Ne=P!==null?P.key:null;if(typeof F=="string"&&F!==""||typeof F=="number")return Ne!==null?null:b(z,P,""+F,le);if(typeof F=="object"&&F!==null){switch(F.$$typeof){case B:return F.key===Ne?R(z,P,F,le):null;case K:return F.key===Ne?U(z,P,F,le):null;case pe:return Ne=F._init,q(z,P,Ne(F._payload),le)}if(Ke(F)||O(F))return Ne!==null?null:Q(z,P,F,le,null);Ea(z,F)}return null}function ye(z,P,F,le,Ne){if(typeof le=="string"&&le!==""||typeof le=="number")return z=z.get(F)||null,b(P,z,""+le,Ne);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case B:return z=z.get(le.key===null?F:le.key)||null,R(P,z,le,Ne);case K:return z=z.get(le.key===null?F:le.key)||null,U(P,z,le,Ne);case pe:var Ie=le._init;return ye(z,P,F,Ie(le._payload),Ne)}if(Ke(le)||O(le))return z=z.get(F)||null,Q(P,z,le,Ne,null);Ea(P,le)}return null}function Se(z,P,F,le){for(var Ne=null,Ie=null,Ae=P,Pe=P=0,kt=null;Ae!==null&&Pe<F.length;Pe++){Ae.index>Pe?(kt=Ae,Ae=null):kt=Ae.sibling;var We=q(z,Ae,F[Pe],le);if(We===null){Ae===null&&(Ae=kt);break}e&&Ae&&We.alternate===null&&t(z,Ae),P=h(We,P,Pe),Ie===null?Ne=We:Ie.sibling=We,Ie=We,Ae=kt}if(Pe===F.length)return a(z,Ae),nt&&or(z,Pe),Ne;if(Ae===null){for(;Pe<F.length;Pe++)Ae=ne(z,F[Pe],le),Ae!==null&&(P=h(Ae,P,Pe),Ie===null?Ne=Ae:Ie.sibling=Ae,Ie=Ae);return nt&&or(z,Pe),Ne}for(Ae=l(z,Ae);Pe<F.length;Pe++)kt=ye(Ae,z,Pe,F[Pe],le),kt!==null&&(e&&kt.alternate!==null&&Ae.delete(kt.key===null?Pe:kt.key),P=h(kt,P,Pe),Ie===null?Ne=kt:Ie.sibling=kt,Ie=kt);return e&&Ae.forEach(function(Qn){return t(z,Qn)}),nt&&or(z,Pe),Ne}function be(z,P,F,le){var Ne=O(F);if(typeof Ne!="function")throw Error(i(150));if(F=Ne.call(F),F==null)throw Error(i(151));for(var Ie=Ne=null,Ae=P,Pe=P=0,kt=null,We=F.next();Ae!==null&&!We.done;Pe++,We=F.next()){Ae.index>Pe?(kt=Ae,Ae=null):kt=Ae.sibling;var Qn=q(z,Ae,We.value,le);if(Qn===null){Ae===null&&(Ae=kt);break}e&&Ae&&Qn.alternate===null&&t(z,Ae),P=h(Qn,P,Pe),Ie===null?Ne=Qn:Ie.sibling=Qn,Ie=Qn,Ae=kt}if(We.done)return a(z,Ae),nt&&or(z,Pe),Ne;if(Ae===null){for(;!We.done;Pe++,We=F.next())We=ne(z,We.value,le),We!==null&&(P=h(We,P,Pe),Ie===null?Ne=We:Ie.sibling=We,Ie=We);return nt&&or(z,Pe),Ne}for(Ae=l(z,Ae);!We.done;Pe++,We=F.next())We=ye(Ae,z,Pe,We.value,le),We!==null&&(e&&We.alternate!==null&&Ae.delete(We.key===null?Pe:We.key),P=h(We,P,Pe),Ie===null?Ne=We:Ie.sibling=We,Ie=We);return e&&Ae.forEach(function(rg){return t(z,rg)}),nt&&or(z,Pe),Ne}function ut(z,P,F,le){if(typeof F=="object"&&F!==null&&F.type===V&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case B:e:{for(var Ne=F.key,Ie=P;Ie!==null;){if(Ie.key===Ne){if(Ne=F.type,Ne===V){if(Ie.tag===7){a(z,Ie.sibling),P=u(Ie,F.props.children),P.return=z,z=P;break e}}else if(Ie.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===pe&&ju(Ne)===Ie.type){a(z,Ie.sibling),P=u(Ie,F.props),P.ref=Ss(z,Ie,F),P.return=z,z=P;break e}a(z,Ie);break}else t(z,Ie);Ie=Ie.sibling}F.type===V?(P=pr(F.props.children,z.mode,le,F.key),P.return=z,z=P):(le=Qa(F.type,F.key,F.props,null,z.mode,le),le.ref=Ss(z,P,F),le.return=z,z=le)}return x(z);case K:e:{for(Ie=F.key;P!==null;){if(P.key===Ie)if(P.tag===4&&P.stateNode.containerInfo===F.containerInfo&&P.stateNode.implementation===F.implementation){a(z,P.sibling),P=u(P,F.children||[]),P.return=z,z=P;break e}else{a(z,P);break}else t(z,P);P=P.sibling}P=al(F,z.mode,le),P.return=z,z=P}return x(z);case pe:return Ie=F._init,ut(z,P,Ie(F._payload),le)}if(Ke(F))return Se(z,P,F,le);if(O(F))return be(z,P,F,le);Ea(z,F)}return typeof F=="string"&&F!==""||typeof F=="number"?(F=""+F,P!==null&&P.tag===6?(a(z,P.sibling),P=u(P,F),P.return=z,z=P):(a(z,P),P=sl(F,z.mode,le),P.return=z,z=P),x(z)):a(z,P)}return ut}var Fr=Su(!0),ku=Su(!1),Ta=Bn(null),Ra=null,Or=null,mo=null;function po(){mo=Or=Ra=null}function go(e){var t=Ta.current;Ze(Ta),e._currentValue=t}function yo(e,t,a){for(;e!==null;){var l=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,l!==null&&(l.childLanes|=t)):l!==null&&(l.childLanes&t)!==t&&(l.childLanes|=t),e===a)break;e=e.return}}function Mr(e,t){Ra=e,mo=Or=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(zt=!0),e.firstContext=null)}function Jt(e){var t=e._currentValue;if(mo!==e)if(e={context:e,memoizedValue:t,next:null},Or===null){if(Ra===null)throw Error(i(308));Or=e,Ra.dependencies={lanes:0,firstContext:e}}else Or=Or.next=e;return t}var lr=null;function vo(e){lr===null?lr=[e]:lr.push(e)}function bu(e,t,a,l){var u=t.interleaved;return u===null?(a.next=a,vo(t)):(a.next=u.next,u.next=a),t.interleaved=a,Nn(e,l)}function Nn(e,t){e.lanes|=t;var a=e.alternate;for(a!==null&&(a.lanes|=t),a=e,e=e.return;e!==null;)e.childLanes|=t,a=e.alternate,a!==null&&(a.childLanes|=t),a=e,e=e.return;return a.tag===3?a.stateNode:null}var Wn=!1;function xo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Nu(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Cn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Hn(e,t,a){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Ue&2)!==0){var u=l.pending;return u===null?t.next=t:(t.next=u.next,u.next=t),l.pending=t,Nn(e,a)}return u=l.interleaved,u===null?(t.next=t,vo(l)):(t.next=u.next,u.next=t),l.interleaved=t,Nn(e,a)}function Ia(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194240)!==0)){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,Pi(e,a)}}function Cu(e,t){var a=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var u=null,h=null;if(a=a.firstBaseUpdate,a!==null){do{var x={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};h===null?u=h=x:h=h.next=x,a=a.next}while(a!==null);h===null?u=h=t:h=h.next=t}else u=h=t;a={baseState:l.baseState,firstBaseUpdate:u,lastBaseUpdate:h,shared:l.shared,effects:l.effects},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}function Aa(e,t,a,l){var u=e.updateQueue;Wn=!1;var h=u.firstBaseUpdate,x=u.lastBaseUpdate,b=u.shared.pending;if(b!==null){u.shared.pending=null;var R=b,U=R.next;R.next=null,x===null?h=U:x.next=U,x=R;var Q=e.alternate;Q!==null&&(Q=Q.updateQueue,b=Q.lastBaseUpdate,b!==x&&(b===null?Q.firstBaseUpdate=U:b.next=U,Q.lastBaseUpdate=R))}if(h!==null){var ne=u.baseState;x=0,Q=U=R=null,b=h;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=t,ye=a,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=H({},ne,q);break e;case 2:Wn=!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,R=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&&(R=ne),u.baseState=R,u.firstBaseUpdate=U,u.lastBaseUpdate=Q,t=u.shared.interleaved,t!==null){u=t;do x|=u.lane,u=u.next;while(u!==t)}else h===null&&(u.shared.lanes=0);dr|=x,e.lanes=x,e.memoizedState=ne}}function Eu(e,t,a){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var l=e[t],u=l.callback;if(u!==null){if(l.callback=null,l=a,typeof u!="function")throw Error(i(191,u));u.call(l)}}}var ks={},pn=Bn(ks),bs=Bn(ks),Ns=Bn(ks);function cr(e){if(e===ks)throw Error(i(174));return e}function wo(e,t){switch(qe(Ns,t),qe(bs,e),qe(pn,ks),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:me(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=me(t,e)}Ze(pn),qe(pn,t)}function Br(){Ze(pn),Ze(bs),Ze(Ns)}function Tu(e){cr(Ns.current);var t=cr(pn.current),a=me(t,e.type);t!==a&&(qe(bs,e),qe(pn,a))}function jo(e){bs.current===e&&(Ze(pn),Ze(bs))}var at=Bn(0);function Pa(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var So=[];function ko(){for(var e=0;e<So.length;e++)So[e]._workInProgressVersionPrimary=null;So.length=0}var _a=A.ReactCurrentDispatcher,bo=A.ReactCurrentBatchConfig,ur=0,it=null,pt=null,jt=null,La=!1,Cs=!1,Es=0,Np=0;function Rt(){throw Error(i(321))}function No(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!nn(e[a],t[a]))return!1;return!0}function Co(e,t,a,l,u,h){if(ur=h,it=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,_a.current=e===null||e.memoizedState===null?Rp:Ip,e=a(l,u),Cs){h=0;do{if(Cs=!1,Es=0,25<=h)throw Error(i(301));h+=1,jt=pt=null,t.updateQueue=null,_a.current=Ap,e=a(l,u)}while(Cs)}if(_a.current=Fa,t=pt!==null&&pt.next!==null,ur=0,jt=pt=it=null,La=!1,t)throw Error(i(300));return e}function Eo(){var e=Es!==0;return Es=0,e}function gn(){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 qt(){if(pt===null){var e=it.alternate;e=e!==null?e.memoizedState:null}else e=pt.next;var t=jt===null?it.memoizedState:jt.next;if(t!==null)jt=t,pt=e;else{if(e===null)throw Error(i(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 Ts(e,t){return typeof t=="function"?t(e):t}function To(e){var t=qt(),a=t.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=e;var l=pt,u=l.baseQueue,h=a.pending;if(h!==null){if(u!==null){var x=u.next;u.next=h.next,h.next=x}l.baseQueue=u=h,a.pending=null}if(u!==null){h=u.next,l=l.baseState;var b=x=null,R=null,U=h;do{var Q=U.lane;if((ur&Q)===Q)R!==null&&(R=R.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};R===null?(b=R=ne,x=l):R=R.next=ne,it.lanes|=Q,dr|=Q}U=U.next}while(U!==null&&U!==h);R===null?x=l:R.next=b,nn(l,t.memoizedState)||(zt=!0),t.memoizedState=l,t.baseState=x,t.baseQueue=R,a.lastRenderedState=l}if(e=a.interleaved,e!==null){u=e;do h=u.lane,it.lanes|=h,dr|=h,u=u.next;while(u!==e)}else u===null&&(a.lanes=0);return[t.memoizedState,a.dispatch]}function Ro(e){var t=qt(),a=t.queue;if(a===null)throw Error(i(311));a.lastRenderedReducer=e;var l=a.dispatch,u=a.pending,h=t.memoizedState;if(u!==null){a.pending=null;var x=u=u.next;do h=e(h,x.action),x=x.next;while(x!==u);nn(h,t.memoizedState)||(zt=!0),t.memoizedState=h,t.baseQueue===null&&(t.baseState=h),a.lastRenderedState=h}return[h,l]}function Ru(){}function Iu(e,t){var a=it,l=qt(),u=t(),h=!nn(l.memoizedState,u);if(h&&(l.memoizedState=u,zt=!0),l=l.queue,Io(_u.bind(null,a,l,e),[e]),l.getSnapshot!==t||h||jt!==null&&jt.memoizedState.tag&1){if(a.flags|=2048,Rs(9,Pu.bind(null,a,l,u,t),void 0,null),St===null)throw Error(i(349));(ur&30)!==0||Au(a,t,u)}return u}function Au(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=it.updateQueue,t===null?(t={lastEffect:null,stores:null},it.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function Pu(e,t,a,l){t.value=a,t.getSnapshot=l,Lu(t)&&$u(e)}function _u(e,t,a){return a(function(){Lu(t)&&$u(e)})}function Lu(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!nn(e,a)}catch{return!0}}function $u(e){var t=Nn(e,1);t!==null&&ln(t,e,1,-1)}function zu(e){var t=gn();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ts,lastRenderedState:e},t.queue=e,e=e.dispatch=Tp.bind(null,it,e),[t.memoizedState,e]}function Rs(e,t,a,l){return e={tag:e,create:t,destroy:a,deps:l,next:null},t=it.updateQueue,t===null?(t={lastEffect:null,stores:null},it.updateQueue=t,t.lastEffect=e.next=e):(a=t.lastEffect,a===null?t.lastEffect=e.next=e:(l=a.next,a.next=e,e.next=l,t.lastEffect=e)),e}function Fu(){return qt().memoizedState}function $a(e,t,a,l){var u=gn();it.flags|=e,u.memoizedState=Rs(1|t,a,void 0,l===void 0?null:l)}function za(e,t,a,l){var u=qt();l=l===void 0?null:l;var h=void 0;if(pt!==null){var x=pt.memoizedState;if(h=x.destroy,l!==null&&No(l,x.deps)){u.memoizedState=Rs(t,a,h,l);return}}it.flags|=e,u.memoizedState=Rs(1|t,a,h,l)}function Ou(e,t){return $a(8390656,8,e,t)}function Io(e,t){return za(2048,8,e,t)}function Mu(e,t){return za(4,2,e,t)}function Bu(e,t){return za(4,4,e,t)}function Du(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Uu(e,t,a){return a=a!=null?a.concat([e]):null,za(4,4,Du.bind(null,t,e),a)}function Ao(){}function Wu(e,t){var a=qt();t=t===void 0?null:t;var l=a.memoizedState;return l!==null&&t!==null&&No(t,l[1])?l[0]:(a.memoizedState=[e,t],e)}function Hu(e,t){var a=qt();t=t===void 0?null:t;var l=a.memoizedState;return l!==null&&t!==null&&No(t,l[1])?l[0]:(e=e(),a.memoizedState=[e,t],e)}function Vu(e,t,a){return(ur&21)===0?(e.baseState&&(e.baseState=!1,zt=!0),e.memoizedState=a):(nn(a,t)||(a=jc(),it.lanes|=a,dr|=a,e.baseState=!0),t)}function Cp(e,t){var a=Ve;Ve=a!==0&&4>a?a:4,e(!0);var l=bo.transition;bo.transition={};try{e(!1),t()}finally{Ve=a,bo.transition=l}}function Gu(){return qt().memoizedState}function Ep(e,t,a){var l=Yn(e);if(a={lane:l,action:a,hasEagerState:!1,eagerState:null,next:null},Ku(e))Yu(t,a);else if(a=bu(e,t,a,l),a!==null){var u=_t();ln(a,e,l,u),Ju(a,t,l)}}function Tp(e,t,a){var l=Yn(e),u={lane:l,action:a,hasEagerState:!1,eagerState:null,next:null};if(Ku(e))Yu(t,u);else{var h=e.alternate;if(e.lanes===0&&(h===null||h.lanes===0)&&(h=t.lastRenderedReducer,h!==null))try{var x=t.lastRenderedState,b=h(x,a);if(u.hasEagerState=!0,u.eagerState=b,nn(b,x)){var R=t.interleaved;R===null?(u.next=u,vo(t)):(u.next=R.next,R.next=u),t.interleaved=u;return}}catch{}finally{}a=bu(e,t,u,l),a!==null&&(u=_t(),ln(a,e,l,u),Ju(a,t,l))}}function Ku(e){var t=e.alternate;return e===it||t!==null&&t===it}function Yu(e,t){Cs=La=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function Ju(e,t,a){if((a&4194240)!==0){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,Pi(e,a)}}var Fa={readContext:Jt,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},Rp={readContext:Jt,useCallback:function(e,t){return gn().memoizedState=[e,t===void 0?null:t],e},useContext:Jt,useEffect:Ou,useImperativeHandle:function(e,t,a){return a=a!=null?a.concat([e]):null,$a(4194308,4,Du.bind(null,t,e),a)},useLayoutEffect:function(e,t){return $a(4194308,4,e,t)},useInsertionEffect:function(e,t){return $a(4,2,e,t)},useMemo:function(e,t){var a=gn();return t=t===void 0?null:t,e=e(),a.memoizedState=[e,t],e},useReducer:function(e,t,a){var l=gn();return t=a!==void 0?a(t):t,l.memoizedState=l.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},l.queue=e,e=e.dispatch=Ep.bind(null,it,e),[l.memoizedState,e]},useRef:function(e){var t=gn();return e={current:e},t.memoizedState=e},useState:zu,useDebugValue:Ao,useDeferredValue:function(e){return gn().memoizedState=e},useTransition:function(){var e=zu(!1),t=e[0];return e=Cp.bind(null,e[1]),gn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,a){var l=it,u=gn();if(nt){if(a===void 0)throw Error(i(407));a=a()}else{if(a=t(),St===null)throw Error(i(349));(ur&30)!==0||Au(l,t,a)}u.memoizedState=a;var h={value:a,getSnapshot:t};return u.queue=h,Ou(_u.bind(null,l,h,e),[e]),l.flags|=2048,Rs(9,Pu.bind(null,l,h,a,t),void 0,null),a},useId:function(){var e=gn(),t=St.identifierPrefix;if(nt){var a=bn,l=kn;a=(l&~(1<<32-tn(l)-1)).toString(32)+a,t=":"+t+"R"+a,a=Es++,0<a&&(t+="H"+a.toString(32)),t+=":"}else a=Np++,t=":"+t+"r"+a.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Ip={readContext:Jt,useCallback:Wu,useContext:Jt,useEffect:Io,useImperativeHandle:Uu,useInsertionEffect:Mu,useLayoutEffect:Bu,useMemo:Hu,useReducer:To,useRef:Fu,useState:function(){return To(Ts)},useDebugValue:Ao,useDeferredValue:function(e){var t=qt();return Vu(t,pt.memoizedState,e)},useTransition:function(){var e=To(Ts)[0],t=qt().memoizedState;return[e,t]},useMutableSource:Ru,useSyncExternalStore:Iu,useId:Gu,unstable_isNewReconciler:!1},Ap={readContext:Jt,useCallback:Wu,useContext:Jt,useEffect:Io,useImperativeHandle:Uu,useInsertionEffect:Mu,useLayoutEffect:Bu,useMemo:Hu,useReducer:Ro,useRef:Fu,useState:function(){return Ro(Ts)},useDebugValue:Ao,useDeferredValue:function(e){var t=qt();return pt===null?t.memoizedState=e:Vu(t,pt.memoizedState,e)},useTransition:function(){var e=Ro(Ts)[0],t=qt().memoizedState;return[e,t]},useMutableSource:Ru,useSyncExternalStore:Iu,useId:Gu,unstable_isNewReconciler:!1};function sn(e,t){if(e&&e.defaultProps){t=H({},t),e=e.defaultProps;for(var a in e)t[a]===void 0&&(t[a]=e[a]);return t}return t}function Po(e,t,a,l){t=e.memoizedState,a=a(l,t),a=a==null?t:H({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Oa={isMounted:function(e){return(e=e._reactInternals)?rr(e)===e:!1},enqueueSetState:function(e,t,a){e=e._reactInternals;var l=_t(),u=Yn(e),h=Cn(l,u);h.payload=t,a!=null&&(h.callback=a),t=Hn(e,h,u),t!==null&&(ln(t,e,u,l),Ia(t,e,u))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var l=_t(),u=Yn(e),h=Cn(l,u);h.tag=1,h.payload=t,a!=null&&(h.callback=a),t=Hn(e,h,u),t!==null&&(ln(t,e,u,l),Ia(t,e,u))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=_t(),l=Yn(e),u=Cn(a,l);u.tag=2,t!=null&&(u.callback=t),t=Hn(e,u,l),t!==null&&(ln(t,e,l,a),Ia(t,e,l))}};function qu(e,t,a,l,u,h,x){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,h,x):t.prototype&&t.prototype.isPureReactComponent?!ps(a,l)||!ps(u,h):!0}function Qu(e,t,a){var l=!1,u=Dn,h=t.contextType;return typeof h=="object"&&h!==null?h=Jt(h):(u=$t(t)?ar:Tt.current,l=t.contextTypes,h=(l=l!=null)?_r(e,u):Dn),t=new t(a,h),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Oa,e.stateNode=t,t._reactInternals=e,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=u,e.__reactInternalMemoizedMaskedChildContext=h),t}function Xu(e,t,a,l){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,l),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,l),t.state!==e&&Oa.enqueueReplaceState(t,t.state,null)}function _o(e,t,a,l){var u=e.stateNode;u.props=a,u.state=e.memoizedState,u.refs={},xo(e);var h=t.contextType;typeof h=="object"&&h!==null?u.context=Jt(h):(h=$t(t)?ar:Tt.current,u.context=_r(e,h)),u.state=e.memoizedState,h=t.getDerivedStateFromProps,typeof h=="function"&&(Po(e,t,h,a),u.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(t=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),t!==u.state&&Oa.enqueueReplaceState(u,u.state,null),Aa(e,a,u,l),u.state=e.memoizedState),typeof u.componentDidMount=="function"&&(e.flags|=4194308)}function Dr(e,t){try{var a="",l=t;do a+=ce(l),l=l.return;while(l);var u=a}catch(h){u=`
39
+ Error generating stack: `+h.message+`
40
+ `+h.stack}return{value:e,source:t,stack:u,digest:null}}function Lo(e,t,a){return{value:e,source:null,stack:a??null,digest:t??null}}function $o(e,t){try{console.error(t.value)}catch(a){setTimeout(function(){throw a})}}var Pp=typeof WeakMap=="function"?WeakMap:Map;function Zu(e,t,a){a=Cn(-1,a),a.tag=3,a.payload={element:null};var l=t.value;return a.callback=function(){Va||(Va=!0,qo=l),$o(e,t)},a}function ed(e,t,a){a=Cn(-1,a),a.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var u=t.value;a.payload=function(){return l(u)},a.callback=function(){$o(e,t)}}var h=e.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(a.callback=function(){$o(e,t),typeof l!="function"&&(Gn===null?Gn=new Set([this]):Gn.add(this));var x=t.stack;this.componentDidCatch(t.value,{componentStack:x!==null?x:""})}),a}function td(e,t,a){var l=e.pingCache;if(l===null){l=e.pingCache=new Pp;var u=new Set;l.set(t,u)}else u=l.get(t),u===void 0&&(u=new Set,l.set(t,u));u.has(a)||(u.add(a),e=Gp.bind(null,e,t,a),t.then(e,e))}function nd(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function rd(e,t,a,l,u){return(e.mode&1)===0?(e===t?e.flags|=65536:(e.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(t=Cn(-1,1),t.tag=2,Hn(a,t,1))),a.lanes|=1),e):(e.flags|=65536,e.lanes=u,e)}var _p=A.ReactCurrentOwner,zt=!1;function Pt(e,t,a,l){t.child=e===null?ku(t,null,a,l):Fr(t,e.child,a,l)}function sd(e,t,a,l,u){a=a.render;var h=t.ref;return Mr(t,u),l=Co(e,t,a,l,h,u),a=Eo(),e!==null&&!zt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~u,En(e,t,u)):(nt&&a&&lo(t),t.flags|=1,Pt(e,t,l,u),t.child)}function ad(e,t,a,l,u){if(e===null){var h=a.type;return typeof h=="function"&&!rl(h)&&h.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(t.tag=15,t.type=h,id(e,t,h,l,u)):(e=Qa(a.type,null,l,t,t.mode,u),e.ref=t.ref,e.return=t,t.child=e)}if(h=e.child,(e.lanes&u)===0){var x=h.memoizedProps;if(a=a.compare,a=a!==null?a:ps,a(x,l)&&e.ref===t.ref)return En(e,t,u)}return t.flags|=1,e=qn(h,l),e.ref=t.ref,e.return=t,t.child=e}function id(e,t,a,l,u){if(e!==null){var h=e.memoizedProps;if(ps(h,l)&&e.ref===t.ref)if(zt=!1,t.pendingProps=l=h,(e.lanes&u)!==0)(e.flags&131072)!==0&&(zt=!0);else return t.lanes=e.lanes,En(e,t,u)}return zo(e,t,a,l,u)}function od(e,t,a){var l=t.pendingProps,u=l.children,h=e!==null?e.memoizedState:null;if(l.mode==="hidden")if((t.mode&1)===0)t.memoizedState={baseLanes:0,cachePool:null,transitions:null},qe(Wr,Vt),Vt|=a;else{if((a&1073741824)===0)return e=h!==null?h.baseLanes|a:a,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,qe(Wr,Vt),Vt|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=h!==null?h.baseLanes:a,qe(Wr,Vt),Vt|=l}else h!==null?(l=h.baseLanes|a,t.memoizedState=null):l=a,qe(Wr,Vt),Vt|=l;return Pt(e,t,u,a),t.child}function ld(e,t){var a=t.ref;(e===null&&a!==null||e!==null&&e.ref!==a)&&(t.flags|=512,t.flags|=2097152)}function zo(e,t,a,l,u){var h=$t(a)?ar:Tt.current;return h=_r(t,h),Mr(t,u),a=Co(e,t,a,l,h,u),l=Eo(),e!==null&&!zt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~u,En(e,t,u)):(nt&&l&&lo(t),t.flags|=1,Pt(e,t,a,u),t.child)}function cd(e,t,a,l,u){if($t(a)){var h=!0;Sa(t)}else h=!1;if(Mr(t,u),t.stateNode===null)Ba(e,t),Qu(t,a,l),_o(t,a,l,u),l=!0;else if(e===null){var x=t.stateNode,b=t.memoizedProps;x.props=b;var R=x.context,U=a.contextType;typeof U=="object"&&U!==null?U=Jt(U):(U=$t(a)?ar:Tt.current,U=_r(t,U));var Q=a.getDerivedStateFromProps,ne=typeof Q=="function"||typeof x.getSnapshotBeforeUpdate=="function";ne||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==l||R!==U)&&Xu(t,x,l,U),Wn=!1;var q=t.memoizedState;x.state=q,Aa(t,l,x,u),R=t.memoizedState,b!==l||q!==R||Lt.current||Wn?(typeof Q=="function"&&(Po(t,a,Q,l),R=t.memoizedState),(b=Wn||qu(t,a,b,l,q,R,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"&&(t.flags|=4194308)):(typeof x.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=R),x.props=l,x.state=R,x.context=U,l=b):(typeof x.componentDidMount=="function"&&(t.flags|=4194308),l=!1)}else{x=t.stateNode,Nu(e,t),b=t.memoizedProps,U=t.type===t.elementType?b:sn(t.type,b),x.props=U,ne=t.pendingProps,q=x.context,R=a.contextType,typeof R=="object"&&R!==null?R=Jt(R):(R=$t(a)?ar:Tt.current,R=_r(t,R));var ye=a.getDerivedStateFromProps;(Q=typeof ye=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(b!==ne||q!==R)&&Xu(t,x,l,R),Wn=!1,q=t.memoizedState,x.state=q,Aa(t,l,x,u);var Se=t.memoizedState;b!==ne||q!==Se||Lt.current||Wn?(typeof ye=="function"&&(Po(t,a,ye,l),Se=t.memoizedState),(U=Wn||qu(t,a,U,l,q,Se,R)||!1)?(Q||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(l,Se,R),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(l,Se,R)),typeof x.componentDidUpdate=="function"&&(t.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof x.componentDidUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(t.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=Se),x.props=l,x.state=Se,x.context=R,l=U):(typeof x.componentDidUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(t.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&q===e.memoizedState||(t.flags|=1024),l=!1)}return Fo(e,t,a,l,h,u)}function Fo(e,t,a,l,u,h){ld(e,t);var x=(t.flags&128)!==0;if(!l&&!x)return u&&mu(t,a,!1),En(e,t,h);l=t.stateNode,_p.current=t;var b=x&&typeof a.getDerivedStateFromError!="function"?null:l.render();return t.flags|=1,e!==null&&x?(t.child=Fr(t,e.child,null,h),t.child=Fr(t,null,b,h)):Pt(e,t,b,h),t.memoizedState=l.state,u&&mu(t,a,!0),t.child}function ud(e){var t=e.stateNode;t.pendingContext?fu(e,t.pendingContext,t.pendingContext!==t.context):t.context&&fu(e,t.context,!1),wo(e,t.containerInfo)}function dd(e,t,a,l,u){return zr(),ho(u),t.flags|=256,Pt(e,t,a,l),t.child}var Oo={dehydrated:null,treeContext:null,retryLane:0};function Mo(e){return{baseLanes:e,cachePool:null,transitions:null}}function fd(e,t,a){var l=t.pendingProps,u=at.current,h=!1,x=(t.flags&128)!==0,b;if((b=x)||(b=e!==null&&e.memoizedState===null?!1:(u&2)!==0),b?(h=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(u|=1),qe(at,u&1),e===null)return fo(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((t.mode&1)===0?t.lanes=1:e.data==="$!"?t.lanes=8:t.lanes=1073741824,null):(x=l.children,e=l.fallback,h?(l=t.mode,h=t.child,x={mode:"hidden",children:x},(l&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=x):h=Xa(x,l,0,null),e=pr(e,l,a,null),h.return=t,e.return=t,h.sibling=e,t.child=h,t.child.memoizedState=Mo(a),t.memoizedState=Oo,e):Bo(t,x));if(u=e.memoizedState,u!==null&&(b=u.dehydrated,b!==null))return Lp(e,t,x,l,b,u,a);if(h){h=l.fallback,x=t.mode,u=e.child,b=u.sibling;var R={mode:"hidden",children:l.children};return(x&1)===0&&t.child!==u?(l=t.child,l.childLanes=0,l.pendingProps=R,t.deletions=null):(l=qn(u,R),l.subtreeFlags=u.subtreeFlags&14680064),b!==null?h=qn(b,h):(h=pr(h,x,a,null),h.flags|=2),h.return=t,l.return=t,l.sibling=h,t.child=l,l=h,h=t.child,x=e.child.memoizedState,x=x===null?Mo(a):{baseLanes:x.baseLanes|a,cachePool:null,transitions:x.transitions},h.memoizedState=x,h.childLanes=e.childLanes&~a,t.memoizedState=Oo,l}return h=e.child,e=h.sibling,l=qn(h,{mode:"visible",children:l.children}),(t.mode&1)===0&&(l.lanes=a),l.return=t,l.sibling=null,e!==null&&(a=t.deletions,a===null?(t.deletions=[e],t.flags|=16):a.push(e)),t.child=l,t.memoizedState=null,l}function Bo(e,t){return t=Xa({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ma(e,t,a,l){return l!==null&&ho(l),Fr(t,e.child,null,a),e=Bo(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Lp(e,t,a,l,u,h,x){if(a)return t.flags&256?(t.flags&=-257,l=Lo(Error(i(422))),Ma(e,t,x,l)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(h=l.fallback,u=t.mode,l=Xa({mode:"visible",children:l.children},u,0,null),h=pr(h,u,x,null),h.flags|=2,l.return=t,h.return=t,l.sibling=h,t.child=l,(t.mode&1)!==0&&Fr(t,e.child,null,x),t.child.memoizedState=Mo(x),t.memoizedState=Oo,h);if((t.mode&1)===0)return Ma(e,t,x,null);if(u.data==="$!"){if(l=u.nextSibling&&u.nextSibling.dataset,l)var b=l.dgst;return l=b,h=Error(i(419)),l=Lo(h,l,void 0),Ma(e,t,x,l)}if(b=(x&e.childLanes)!==0,zt||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!==h.retryLane&&(h.retryLane=u,Nn(e,u),ln(l,e,u,-1))}return nl(),l=Lo(Error(i(421))),Ma(e,t,x,l)}return u.data==="$?"?(t.flags|=128,t.child=e.child,t=Kp.bind(null,e),u._reactRetry=t,null):(e=h.treeContext,Ht=Mn(u.nextSibling),Wt=t,nt=!0,rn=null,e!==null&&(Kt[Yt++]=kn,Kt[Yt++]=bn,Kt[Yt++]=ir,kn=e.id,bn=e.overflow,ir=t),t=Bo(t,l.children),t.flags|=4096,t)}function hd(e,t,a){e.lanes|=t;var l=e.alternate;l!==null&&(l.lanes|=t),yo(e.return,t,a)}function Do(e,t,a,l,u){var h=e.memoizedState;h===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:u}:(h.isBackwards=t,h.rendering=null,h.renderingStartTime=0,h.last=l,h.tail=a,h.tailMode=u)}function md(e,t,a){var l=t.pendingProps,u=l.revealOrder,h=l.tail;if(Pt(e,t,l.children,a),l=at.current,(l&2)!==0)l=l&1|2,t.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&hd(e,a,t);else if(e.tag===19)hd(e,a,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(qe(at,l),(t.mode&1)===0)t.memoizedState=null;else switch(u){case"forwards":for(a=t.child,u=null;a!==null;)e=a.alternate,e!==null&&Pa(e)===null&&(u=a),a=a.sibling;a=u,a===null?(u=t.child,t.child=null):(u=a.sibling,a.sibling=null),Do(t,!1,u,a,h);break;case"backwards":for(a=null,u=t.child,t.child=null;u!==null;){if(e=u.alternate,e!==null&&Pa(e)===null){t.child=u;break}e=u.sibling,u.sibling=a,a=u,u=e}Do(t,!0,a,null,h);break;case"together":Do(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Ba(e,t){(t.mode&1)===0&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function En(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),dr|=t.lanes,(a&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,a=qn(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=qn(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function $p(e,t,a){switch(t.tag){case 3:ud(t),zr();break;case 5:Tu(t);break;case 1:$t(t.type)&&Sa(t);break;case 4:wo(t,t.stateNode.containerInfo);break;case 10:var l=t.type._context,u=t.memoizedProps.value;qe(Ta,l._currentValue),l._currentValue=u;break;case 13:if(l=t.memoizedState,l!==null)return l.dehydrated!==null?(qe(at,at.current&1),t.flags|=128,null):(a&t.child.childLanes)!==0?fd(e,t,a):(qe(at,at.current&1),e=En(e,t,a),e!==null?e.sibling:null);qe(at,at.current&1);break;case 19:if(l=(a&t.childLanes)!==0,(e.flags&128)!==0){if(l)return md(e,t,a);t.flags|=128}if(u=t.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 t.lanes=0,od(e,t,a)}return En(e,t,a)}var pd,Uo,gd,yd;pd=function(e,t){for(var a=t.child;a!==null;){if(a.tag===5||a.tag===6)e.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},Uo=function(){},gd=function(e,t,a,l){var u=e.memoizedProps;if(u!==l){e=t.stateNode,cr(pn.current);var h=null;switch(a){case"input":u=X(e,u),l=X(e,l),h=[];break;case"select":u=H({},u,{value:void 0}),l=H({},l,{value:void 0}),h=[];break;case"textarea":u=st(e,u),l=st(e,l),h=[];break;default:typeof u.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=xa)}tt(a,l);var x;a=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)&&(a||(a={}),a[x]="")}else U!=="dangerouslySetInnerHTML"&&U!=="children"&&U!=="suppressContentEditableWarning"&&U!=="suppressHydrationWarning"&&U!=="autoFocus"&&(c.hasOwnProperty(U)?h||(h=[]):(h=h||[]).push(U,null));for(U in l){var R=l[U];if(b=u!=null?u[U]:void 0,l.hasOwnProperty(U)&&R!==b&&(R!=null||b!=null))if(U==="style")if(b){for(x in b)!b.hasOwnProperty(x)||R&&R.hasOwnProperty(x)||(a||(a={}),a[x]="");for(x in R)R.hasOwnProperty(x)&&b[x]!==R[x]&&(a||(a={}),a[x]=R[x])}else a||(h||(h=[]),h.push(U,a)),a=R;else U==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,b=b?b.__html:void 0,R!=null&&b!==R&&(h=h||[]).push(U,R)):U==="children"?typeof R!="string"&&typeof R!="number"||(h=h||[]).push(U,""+R):U!=="suppressContentEditableWarning"&&U!=="suppressHydrationWarning"&&(c.hasOwnProperty(U)?(R!=null&&U==="onScroll"&&Xe("scroll",e),h||b===R||(h=[])):(h=h||[]).push(U,R))}a&&(h=h||[]).push("style",a);var U=h;(t.updateQueue=U)&&(t.flags|=4)}},yd=function(e,t,a,l){a!==l&&(t.flags|=4)};function Is(e,t){if(!nt)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function It(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,l=0;if(t)for(var u=e.child;u!==null;)a|=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;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags,l|=u.flags,u.return=e,u=u.sibling;return e.subtreeFlags|=l,e.childLanes=a,t}function zp(e,t,a){var l=t.pendingProps;switch(co(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(t),null;case 1:return $t(t.type)&&ja(),It(t),null;case 3:return l=t.stateNode,Br(),Ze(Lt),Ze(Tt),ko(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(Ca(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,rn!==null&&(Zo(rn),rn=null))),Uo(e,t),It(t),null;case 5:jo(t);var u=cr(Ns.current);if(a=t.type,e!==null&&t.stateNode!=null)gd(e,t,a,l,u),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!l){if(t.stateNode===null)throw Error(i(166));return It(t),null}if(e=cr(pn.current),Ca(t)){l=t.stateNode,a=t.type;var h=t.memoizedProps;switch(l[mn]=t,l[ws]=h,e=(t.mode&1)!==0,a){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<ys.length;u++)Xe(ys[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,h),Xe("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!h.multiple},Xe("invalid",l);break;case"textarea":mt(l,h),Xe("invalid",l)}tt(a,h),u=null;for(var x in h)if(h.hasOwnProperty(x)){var b=h[x];x==="children"?typeof b=="string"?l.textContent!==b&&(h.suppressHydrationWarning!==!0&&va(l.textContent,b,e),u=["children",b]):typeof b=="number"&&l.textContent!==""+b&&(h.suppressHydrationWarning!==!0&&va(l.textContent,b,e),u=["children",""+b]):c.hasOwnProperty(x)&&b!=null&&x==="onScroll"&&Xe("scroll",l)}switch(a){case"input":Ee(l),lt(l,h,!0);break;case"textarea":Ee(l),L(l);break;case"select":case"option":break;default:typeof h.onClick=="function"&&(l.onclick=xa)}l=u,t.updateQueue=l,l!==null&&(t.flags|=4)}else{x=u.nodeType===9?u:u.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=oe(a)),e==="http://www.w3.org/1999/xhtml"?a==="script"?(e=x.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=x.createElement(a,{is:l.is}):(e=x.createElement(a),a==="select"&&(x=e,l.multiple?x.multiple=!0:l.size&&(x.size=l.size))):e=x.createElementNS(e,a),e[mn]=t,e[ws]=l,pd(e,t,!1,!1),t.stateNode=e;e:{switch(x=bt(a,l),a){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<ys.length;u++)Xe(ys[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=H({},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(a,u),b=u;for(h in b)if(b.hasOwnProperty(h)){var R=b[h];h==="style"?fn(e,R):h==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&ue(e,R)):h==="children"?typeof R=="string"?(a!=="textarea"||R!=="")&&Oe(e,R):typeof R=="number"&&Oe(e,""+R):h!=="suppressContentEditableWarning"&&h!=="suppressHydrationWarning"&&h!=="autoFocus"&&(c.hasOwnProperty(h)?R!=null&&h==="onScroll"&&Xe("scroll",e):R!=null&&$(e,h,R,x))}switch(a){case"input":Ee(e),lt(e,l,!1);break;case"textarea":Ee(e),L(e);break;case"option":l.value!=null&&e.setAttribute("value",""+ke(l.value));break;case"select":e.multiple=!!l.multiple,h=l.value,h!=null?et(e,!!l.multiple,h,!1):l.defaultValue!=null&&et(e,!!l.multiple,l.defaultValue,!0);break;default:typeof u.onClick=="function"&&(e.onclick=xa)}switch(a){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}}l&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return It(t),null;case 6:if(e&&t.stateNode!=null)yd(e,t,e.memoizedProps,l);else{if(typeof l!="string"&&t.stateNode===null)throw Error(i(166));if(a=cr(Ns.current),cr(pn.current),Ca(t)){if(l=t.stateNode,a=t.memoizedProps,l[mn]=t,(h=l.nodeValue!==a)&&(e=Wt,e!==null))switch(e.tag){case 3:va(l.nodeValue,a,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&va(l.nodeValue,a,(e.mode&1)!==0)}h&&(t.flags|=4)}else l=(a.nodeType===9?a:a.ownerDocument).createTextNode(l),l[mn]=t,t.stateNode=l}return It(t),null;case 13:if(Ze(at),l=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(nt&&Ht!==null&&(t.mode&1)!==0&&(t.flags&128)===0)wu(),zr(),t.flags|=98560,h=!1;else if(h=Ca(t),l!==null&&l.dehydrated!==null){if(e===null){if(!h)throw Error(i(318));if(h=t.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(i(317));h[mn]=t}else zr(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;It(t),h=!1}else rn!==null&&(Zo(rn),rn=null),h=!0;if(!h)return t.flags&65536?t:null}return(t.flags&128)!==0?(t.lanes=a,t):(l=l!==null,l!==(e!==null&&e.memoizedState!==null)&&l&&(t.child.flags|=8192,(t.mode&1)!==0&&(e===null||(at.current&1)!==0?gt===0&&(gt=3):nl())),t.updateQueue!==null&&(t.flags|=4),It(t),null);case 4:return Br(),Uo(e,t),e===null&&vs(t.stateNode.containerInfo),It(t),null;case 10:return go(t.type._context),It(t),null;case 17:return $t(t.type)&&ja(),It(t),null;case 19:if(Ze(at),h=t.memoizedState,h===null)return It(t),null;if(l=(t.flags&128)!==0,x=h.rendering,x===null)if(l)Is(h,!1);else{if(gt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(x=Pa(e),x!==null){for(t.flags|=128,Is(h,!1),l=x.updateQueue,l!==null&&(t.updateQueue=l,t.flags|=4),t.subtreeFlags=0,l=a,a=t.child;a!==null;)h=a,e=l,h.flags&=14680066,x=h.alternate,x===null?(h.childLanes=0,h.lanes=e,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=x.childLanes,h.lanes=x.lanes,h.child=x.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=x.memoizedProps,h.memoizedState=x.memoizedState,h.updateQueue=x.updateQueue,h.type=x.type,e=x.dependencies,h.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),a=a.sibling;return qe(at,at.current&1|2),t.child}e=e.sibling}h.tail!==null&&ct()>Hr&&(t.flags|=128,l=!0,Is(h,!1),t.lanes=4194304)}else{if(!l)if(e=Pa(x),e!==null){if(t.flags|=128,l=!0,a=e.updateQueue,a!==null&&(t.updateQueue=a,t.flags|=4),Is(h,!0),h.tail===null&&h.tailMode==="hidden"&&!x.alternate&&!nt)return It(t),null}else 2*ct()-h.renderingStartTime>Hr&&a!==1073741824&&(t.flags|=128,l=!0,Is(h,!1),t.lanes=4194304);h.isBackwards?(x.sibling=t.child,t.child=x):(a=h.last,a!==null?a.sibling=x:t.child=x,h.last=x)}return h.tail!==null?(t=h.tail,h.rendering=t,h.tail=t.sibling,h.renderingStartTime=ct(),t.sibling=null,a=at.current,qe(at,l?a&1|2:a&1),t):(It(t),null);case 22:case 23:return tl(),l=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(t.flags|=8192),l&&(t.mode&1)!==0?(Vt&1073741824)!==0&&(It(t),t.subtreeFlags&6&&(t.flags|=8192)):It(t),null;case 24:return null;case 25:return null}throw Error(i(156,t.tag))}function Fp(e,t){switch(co(t),t.tag){case 1:return $t(t.type)&&ja(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Br(),Ze(Lt),Ze(Tt),ko(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return jo(t),null;case 13:if(Ze(at),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));zr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ze(at),null;case 4:return Br(),null;case 10:return go(t.type._context),null;case 22:case 23:return tl(),null;case 24:return null;default:return null}}var Da=!1,At=!1,Op=typeof WeakSet=="function"?WeakSet:Set,xe=null;function Ur(e,t){var a=e.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(l){ot(e,t,l)}else a.current=null}function Wo(e,t,a){try{a()}catch(l){ot(e,t,l)}}var vd=!1;function Mp(e,t){if(eo=oa,e=qc(),Gi(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var u=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{a.nodeType,h.nodeType}catch{a=null;break e}var x=0,b=-1,R=-1,U=0,Q=0,ne=e,q=null;t:for(;;){for(var ye;ne!==a||u!==0&&ne.nodeType!==3||(b=x+u),ne!==h||l!==0&&ne.nodeType!==3||(R=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===a&&++U===u&&(b=x),q===h&&++Q===l&&(R=x),(ye=ne.nextSibling)!==null)break;ne=q,q=ne.parentNode}ne=ye}a=b===-1||R===-1?null:{start:b,end:R}}else a=null}a=a||{start:0,end:0}}else a=null;for(to={focusedElem:e,selectionRange:a},oa=!1,xe=t;xe!==null;)if(t=xe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,xe=e;else for(;xe!==null;){t=xe;try{var Se=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(Se!==null){var be=Se.memoizedProps,ut=Se.memoizedState,z=t.stateNode,P=z.getSnapshotBeforeUpdate(t.elementType===t.type?be:sn(t.type,be),ut);z.__reactInternalSnapshotBeforeUpdate=P}break;case 3:var F=t.stateNode.containerInfo;F.nodeType===1?F.textContent="":F.nodeType===9&&F.documentElement&&F.removeChild(F.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(le){ot(t,t.return,le)}if(e=t.sibling,e!==null){e.return=t.return,xe=e;break}xe=t.return}return Se=vd,vd=!1,Se}function As(e,t,a){var l=t.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var u=l=l.next;do{if((u.tag&e)===e){var h=u.destroy;u.destroy=void 0,h!==void 0&&Wo(t,a,h)}u=u.next}while(u!==l)}}function Ua(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var a=t=t.next;do{if((a.tag&e)===e){var l=a.create;a.destroy=l()}a=a.next}while(a!==t)}}function Ho(e){var t=e.ref;if(t!==null){var a=e.stateNode;switch(e.tag){case 5:e=a;break;default:e=a}typeof t=="function"?t(e):t.current=e}}function xd(e){var t=e.alternate;t!==null&&(e.alternate=null,xd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[mn],delete t[ws],delete t[ao],delete t[jp],delete t[Sp])),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 wd(e){return e.tag===5||e.tag===3||e.tag===4}function jd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||wd(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 Vo(e,t,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?a.nodeType===8?a.parentNode.insertBefore(e,t):a.insertBefore(e,t):(a.nodeType===8?(t=a.parentNode,t.insertBefore(e,a)):(t=a,t.appendChild(e)),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=xa));else if(l!==4&&(e=e.child,e!==null))for(Vo(e,t,a),e=e.sibling;e!==null;)Vo(e,t,a),e=e.sibling}function Go(e,t,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(Go(e,t,a),e=e.sibling;e!==null;)Go(e,t,a),e=e.sibling}var Nt=null,an=!1;function Vn(e,t,a){for(a=a.child;a!==null;)Sd(e,t,a),a=a.sibling}function Sd(e,t,a){if(hn&&typeof hn.onCommitFiberUnmount=="function")try{hn.onCommitFiberUnmount(ta,a)}catch{}switch(a.tag){case 5:At||Ur(a,t);case 6:var l=Nt,u=an;Nt=null,Vn(e,t,a),Nt=l,an=u,Nt!==null&&(an?(e=Nt,a=a.stateNode,e.nodeType===8?e.parentNode.removeChild(a):e.removeChild(a)):Nt.removeChild(a.stateNode));break;case 18:Nt!==null&&(an?(e=Nt,a=a.stateNode,e.nodeType===8?so(e.parentNode,a):e.nodeType===1&&so(e,a),cs(e)):so(Nt,a.stateNode));break;case 4:l=Nt,u=an,Nt=a.stateNode.containerInfo,an=!0,Vn(e,t,a),Nt=l,an=u;break;case 0:case 11:case 14:case 15:if(!At&&(l=a.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){u=l=l.next;do{var h=u,x=h.destroy;h=h.tag,x!==void 0&&((h&2)!==0||(h&4)!==0)&&Wo(a,t,x),u=u.next}while(u!==l)}Vn(e,t,a);break;case 1:if(!At&&(Ur(a,t),l=a.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=a.memoizedProps,l.state=a.memoizedState,l.componentWillUnmount()}catch(b){ot(a,t,b)}Vn(e,t,a);break;case 21:Vn(e,t,a);break;case 22:a.mode&1?(At=(l=At)||a.memoizedState!==null,Vn(e,t,a),At=l):Vn(e,t,a);break;default:Vn(e,t,a)}}function kd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var a=e.stateNode;a===null&&(a=e.stateNode=new Op),t.forEach(function(l){var u=Yp.bind(null,e,l);a.has(l)||(a.add(l),l.then(u,u))})}}function on(e,t){var a=t.deletions;if(a!==null)for(var l=0;l<a.length;l++){var u=a[l];try{var h=e,x=t,b=x;e:for(;b!==null;){switch(b.tag){case 5:Nt=b.stateNode,an=!1;break e;case 3:Nt=b.stateNode.containerInfo,an=!0;break e;case 4:Nt=b.stateNode.containerInfo,an=!0;break e}b=b.return}if(Nt===null)throw Error(i(160));Sd(h,x,u),Nt=null,an=!1;var R=u.alternate;R!==null&&(R.return=null),u.return=null}catch(U){ot(u,t,U)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)bd(t,e),t=t.sibling}function bd(e,t){var a=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(on(t,e),yn(e),l&4){try{As(3,e,e.return),Ua(3,e)}catch(be){ot(e,e.return,be)}try{As(5,e,e.return)}catch(be){ot(e,e.return,be)}}break;case 1:on(t,e),yn(e),l&512&&a!==null&&Ur(a,a.return);break;case 5:if(on(t,e),yn(e),l&512&&a!==null&&Ur(a,a.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 h=e.memoizedProps,x=a!==null?a.memoizedProps:h,b=e.type,R=e.updateQueue;if(e.updateQueue=null,R!==null)try{b==="input"&&h.type==="radio"&&h.name!=null&&Te(u,h),bt(b,x);var U=bt(b,h);for(x=0;x<R.length;x+=2){var Q=R[x],ne=R[x+1];Q==="style"?fn(u,ne):Q==="dangerouslySetInnerHTML"?ue(u,ne):Q==="children"?Oe(u,ne):$(u,Q,ne,U)}switch(b){case"input":Le(u,h);break;case"textarea":Fe(u,h);break;case"select":var q=u._wrapperState.wasMultiple;u._wrapperState.wasMultiple=!!h.multiple;var ye=h.value;ye!=null?et(u,!!h.multiple,ye,!1):q!==!!h.multiple&&(h.defaultValue!=null?et(u,!!h.multiple,h.defaultValue,!0):et(u,!!h.multiple,h.multiple?[]:"",!1))}u[ws]=h}catch(be){ot(e,e.return,be)}}break;case 6:if(on(t,e),yn(e),l&4){if(e.stateNode===null)throw Error(i(162));u=e.stateNode,h=e.memoizedProps;try{u.nodeValue=h}catch(be){ot(e,e.return,be)}}break;case 3:if(on(t,e),yn(e),l&4&&a!==null&&a.memoizedState.isDehydrated)try{cs(t.containerInfo)}catch(be){ot(e,e.return,be)}break;case 4:on(t,e),yn(e);break;case 13:on(t,e),yn(e),u=e.child,u.flags&8192&&(h=u.memoizedState!==null,u.stateNode.isHidden=h,!h||u.alternate!==null&&u.alternate.memoizedState!==null||(Jo=ct())),l&4&&kd(e);break;case 22:if(Q=a!==null&&a.memoizedState!==null,e.mode&1?(At=(U=At)||Q,on(t,e),At=U):on(t,e),yn(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:As(4,q,q.return);break;case 1:Ur(q,q.return);var Se=q.stateNode;if(typeof Se.componentWillUnmount=="function"){l=q,a=q.return;try{t=l,Se.props=t.memoizedProps,Se.state=t.memoizedState,Se.componentWillUnmount()}catch(be){ot(l,a,be)}}break;case 5:Ur(q,q.return);break;case 22:if(q.memoizedState!==null){Ed(ne);continue}}ye!==null?(ye.return=q,xe=ye):Ed(ne)}Q=Q.sibling}e:for(Q=null,ne=e;;){if(ne.tag===5){if(Q===null){Q=ne;try{u=ne.stateNode,U?(h=u.style,typeof h.setProperty=="function"?h.setProperty("display","none","important"):h.display="none"):(b=ne.stateNode,R=ne.memoizedProps.style,x=R!=null&&R.hasOwnProperty("display")?R.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:on(t,e),yn(e),l&4&&kd(e);break;case 21:break;default:on(t,e),yn(e)}}function yn(e){var t=e.flags;if(t&2){try{e:{for(var a=e.return;a!==null;){if(wd(a)){var l=a;break e}a=a.return}throw Error(i(160))}switch(l.tag){case 5:var u=l.stateNode;l.flags&32&&(Oe(u,""),l.flags&=-33);var h=jd(e);Go(e,h,u);break;case 3:case 4:var x=l.stateNode.containerInfo,b=jd(e);Vo(e,b,x);break;default:throw Error(i(161))}}catch(R){ot(e,e.return,R)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Bp(e,t,a){xe=e,Nd(e)}function Nd(e,t,a){for(var l=(e.mode&1)!==0;xe!==null;){var u=xe,h=u.child;if(u.tag===22&&l){var x=u.memoizedState!==null||Da;if(!x){var b=u.alternate,R=b!==null&&b.memoizedState!==null||At;b=Da;var U=At;if(Da=x,(At=R)&&!U)for(xe=u;xe!==null;)x=xe,R=x.child,x.tag===22&&x.memoizedState!==null?Td(u):R!==null?(R.return=x,xe=R):Td(u);for(;h!==null;)xe=h,Nd(h),h=h.sibling;xe=u,Da=b,At=U}Cd(e)}else(u.subtreeFlags&8772)!==0&&h!==null?(h.return=u,xe=h):Cd(e)}}function Cd(e){for(;xe!==null;){var t=xe;if((t.flags&8772)!==0){var a=t.alternate;try{if((t.flags&8772)!==0)switch(t.tag){case 0:case 11:case 15:At||Ua(5,t);break;case 1:var l=t.stateNode;if(t.flags&4&&!At)if(a===null)l.componentDidMount();else{var u=t.elementType===t.type?a.memoizedProps:sn(t.type,a.memoizedProps);l.componentDidUpdate(u,a.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var h=t.updateQueue;h!==null&&Eu(t,h,l);break;case 3:var x=t.updateQueue;if(x!==null){if(a=null,t.child!==null)switch(t.child.tag){case 5:a=t.child.stateNode;break;case 1:a=t.child.stateNode}Eu(t,x,a)}break;case 5:var b=t.stateNode;if(a===null&&t.flags&4){a=b;var R=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":R.autoFocus&&a.focus();break;case"img":R.src&&(a.src=R.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var U=t.alternate;if(U!==null){var Q=U.memoizedState;if(Q!==null){var ne=Q.dehydrated;ne!==null&&cs(ne)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(i(163))}At||t.flags&512&&Ho(t)}catch(q){ot(t,t.return,q)}}if(t===e){xe=null;break}if(a=t.sibling,a!==null){a.return=t.return,xe=a;break}xe=t.return}}function Ed(e){for(;xe!==null;){var t=xe;if(t===e){xe=null;break}var a=t.sibling;if(a!==null){a.return=t.return,xe=a;break}xe=t.return}}function Td(e){for(;xe!==null;){var t=xe;try{switch(t.tag){case 0:case 11:case 15:var a=t.return;try{Ua(4,t)}catch(R){ot(t,a,R)}break;case 1:var l=t.stateNode;if(typeof l.componentDidMount=="function"){var u=t.return;try{l.componentDidMount()}catch(R){ot(t,u,R)}}var h=t.return;try{Ho(t)}catch(R){ot(t,h,R)}break;case 5:var x=t.return;try{Ho(t)}catch(R){ot(t,x,R)}}}catch(R){ot(t,t.return,R)}if(t===e){xe=null;break}var b=t.sibling;if(b!==null){b.return=t.return,xe=b;break}xe=t.return}}var Dp=Math.ceil,Wa=A.ReactCurrentDispatcher,Ko=A.ReactCurrentOwner,Qt=A.ReactCurrentBatchConfig,Ue=0,St=null,ht=null,Ct=0,Vt=0,Wr=Bn(0),gt=0,Ps=null,dr=0,Ha=0,Yo=0,_s=null,Ft=null,Jo=0,Hr=1/0,Tn=null,Va=!1,qo=null,Gn=null,Ga=!1,Kn=null,Ka=0,Ls=0,Qo=null,Ya=-1,Ja=0;function _t(){return(Ue&6)!==0?ct():Ya!==-1?Ya:Ya=ct()}function Yn(e){return(e.mode&1)===0?1:(Ue&2)!==0&&Ct!==0?Ct&-Ct:bp.transition!==null?(Ja===0&&(Ja=jc()),Ja):(e=Ve,e!==0||(e=window.event,e=e===void 0?16:Ic(e.type)),e)}function ln(e,t,a,l){if(50<Ls)throw Ls=0,Qo=null,Error(i(185));ss(e,a,l),((Ue&2)===0||e!==St)&&(e===St&&((Ue&2)===0&&(Ha|=a),gt===4&&Jn(e,Ct)),Ot(e,l),a===1&&Ue===0&&(t.mode&1)===0&&(Hr=ct()+500,ka&&Un()))}function Ot(e,t){var a=e.callbackNode;bm(e,t);var l=sa(e,e===St?Ct:0);if(l===0)a!==null&&vc(a),e.callbackNode=null,e.callbackPriority=0;else if(t=l&-l,e.callbackPriority!==t){if(a!=null&&vc(a),t===1)e.tag===0?kp(Id.bind(null,e)):pu(Id.bind(null,e)),xp(function(){(Ue&6)===0&&Un()}),a=null;else{switch(Sc(l)){case 1:a=Ri;break;case 4:a=xc;break;case 16:a=ea;break;case 536870912:a=wc;break;default:a=ea}a=Od(a,Rd.bind(null,e))}e.callbackPriority=t,e.callbackNode=a}}function Rd(e,t){if(Ya=-1,Ja=0,(Ue&6)!==0)throw Error(i(327));var a=e.callbackNode;if(Vr()&&e.callbackNode!==a)return null;var l=sa(e,e===St?Ct:0);if(l===0)return null;if((l&30)!==0||(l&e.expiredLanes)!==0||t)t=qa(e,l);else{t=l;var u=Ue;Ue|=2;var h=Pd();(St!==e||Ct!==t)&&(Tn=null,Hr=ct()+500,hr(e,t));do try{Hp();break}catch(b){Ad(e,b)}while(!0);po(),Wa.current=h,Ue=u,ht!==null?t=0:(St=null,Ct=0,t=gt)}if(t!==0){if(t===2&&(u=Ii(e),u!==0&&(l=u,t=Xo(e,u))),t===1)throw a=Ps,hr(e,0),Jn(e,l),Ot(e,ct()),a;if(t===6)Jn(e,l);else{if(u=e.current.alternate,(l&30)===0&&!Up(u)&&(t=qa(e,l),t===2&&(h=Ii(e),h!==0&&(l=h,t=Xo(e,h))),t===1))throw a=Ps,hr(e,0),Jn(e,l),Ot(e,ct()),a;switch(e.finishedWork=u,e.finishedLanes=l,t){case 0:case 1:throw Error(i(345));case 2:mr(e,Ft,Tn);break;case 3:if(Jn(e,l),(l&130023424)===l&&(t=Jo+500-ct(),10<t)){if(sa(e,0)!==0)break;if(u=e.suspendedLanes,(u&l)!==l){_t(),e.pingedLanes|=e.suspendedLanes&u;break}e.timeoutHandle=ro(mr.bind(null,e,Ft,Tn),t);break}mr(e,Ft,Tn);break;case 4:if(Jn(e,l),(l&4194240)===l)break;for(t=e.eventTimes,u=-1;0<l;){var x=31-tn(l);h=1<<x,x=t[x],x>u&&(u=x),l&=~h}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*Dp(l/1960))-l,10<l){e.timeoutHandle=ro(mr.bind(null,e,Ft,Tn),l);break}mr(e,Ft,Tn);break;case 5:mr(e,Ft,Tn);break;default:throw Error(i(329))}}}return Ot(e,ct()),e.callbackNode===a?Rd.bind(null,e):null}function Xo(e,t){var a=_s;return e.current.memoizedState.isDehydrated&&(hr(e,t).flags|=256),e=qa(e,t),e!==2&&(t=Ft,Ft=a,t!==null&&Zo(t)),e}function Zo(e){Ft===null?Ft=e:Ft.push.apply(Ft,e)}function Up(e){for(var t=e;;){if(t.flags&16384){var a=t.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var l=0;l<a.length;l++){var u=a[l],h=u.getSnapshot;u=u.value;try{if(!nn(h(),u))return!1}catch{return!1}}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Jn(e,t){for(t&=~Yo,t&=~Ha,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var a=31-tn(t),l=1<<a;e[a]=-1,t&=~l}}function Id(e){if((Ue&6)!==0)throw Error(i(327));Vr();var t=sa(e,0);if((t&1)===0)return Ot(e,ct()),null;var a=qa(e,t);if(e.tag!==0&&a===2){var l=Ii(e);l!==0&&(t=l,a=Xo(e,l))}if(a===1)throw a=Ps,hr(e,0),Jn(e,t),Ot(e,ct()),a;if(a===6)throw Error(i(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,mr(e,Ft,Tn),Ot(e,ct()),null}function el(e,t){var a=Ue;Ue|=1;try{return e(t)}finally{Ue=a,Ue===0&&(Hr=ct()+500,ka&&Un())}}function fr(e){Kn!==null&&Kn.tag===0&&(Ue&6)===0&&Vr();var t=Ue;Ue|=1;var a=Qt.transition,l=Ve;try{if(Qt.transition=null,Ve=1,e)return e()}finally{Ve=l,Qt.transition=a,Ue=t,(Ue&6)===0&&Un()}}function tl(){Vt=Wr.current,Ze(Wr)}function hr(e,t){e.finishedWork=null,e.finishedLanes=0;var a=e.timeoutHandle;if(a!==-1&&(e.timeoutHandle=-1,vp(a)),ht!==null)for(a=ht.return;a!==null;){var l=a;switch(co(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&ja();break;case 3:Br(),Ze(Lt),Ze(Tt),ko();break;case 5:jo(l);break;case 4:Br();break;case 13:Ze(at);break;case 19:Ze(at);break;case 10:go(l.type._context);break;case 22:case 23:tl()}a=a.return}if(St=e,ht=e=qn(e.current,null),Ct=Vt=t,gt=0,Ps=null,Yo=Ha=dr=0,Ft=_s=null,lr!==null){for(t=0;t<lr.length;t++)if(a=lr[t],l=a.interleaved,l!==null){a.interleaved=null;var u=l.next,h=a.pending;if(h!==null){var x=h.next;h.next=u,l.next=x}a.pending=l}lr=null}return e}function Ad(e,t){do{var a=ht;try{if(po(),_a.current=Fa,La){for(var l=it.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}La=!1}if(ur=0,jt=pt=it=null,Cs=!1,Es=0,Ko.current=null,a===null||a.return===null){gt=1,Ps=t,ht=null;break}e:{var h=e,x=a.return,b=a,R=t;if(t=Ct,b.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var U=R,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=nd(x);if(ye!==null){ye.flags&=-257,rd(ye,x,b,h,t),ye.mode&1&&td(h,U,t),t=ye,R=U;var Se=t.updateQueue;if(Se===null){var be=new Set;be.add(R),t.updateQueue=be}else Se.add(R);break e}else{if((t&1)===0){td(h,U,t),nl();break e}R=Error(i(426))}}else if(nt&&b.mode&1){var ut=nd(x);if(ut!==null){(ut.flags&65536)===0&&(ut.flags|=256),rd(ut,x,b,h,t),ho(Dr(R,b));break e}}h=R=Dr(R,b),gt!==4&&(gt=2),_s===null?_s=[h]:_s.push(h),h=x;do{switch(h.tag){case 3:h.flags|=65536,t&=-t,h.lanes|=t;var z=Zu(h,R,t);Cu(h,z);break e;case 1:b=R;var P=h.type,F=h.stateNode;if((h.flags&128)===0&&(typeof P.getDerivedStateFromError=="function"||F!==null&&typeof F.componentDidCatch=="function"&&(Gn===null||!Gn.has(F)))){h.flags|=65536,t&=-t,h.lanes|=t;var le=ed(h,b,t);Cu(h,le);break e}}h=h.return}while(h!==null)}Ld(a)}catch(Ne){t=Ne,ht===a&&a!==null&&(ht=a=a.return);continue}break}while(!0)}function Pd(){var e=Wa.current;return Wa.current=Fa,e===null?Fa:e}function nl(){(gt===0||gt===3||gt===2)&&(gt=4),St===null||(dr&268435455)===0&&(Ha&268435455)===0||Jn(St,Ct)}function qa(e,t){var a=Ue;Ue|=2;var l=Pd();(St!==e||Ct!==t)&&(Tn=null,hr(e,t));do try{Wp();break}catch(u){Ad(e,u)}while(!0);if(po(),Ue=a,Wa.current=l,ht!==null)throw Error(i(261));return St=null,Ct=0,gt}function Wp(){for(;ht!==null;)_d(ht)}function Hp(){for(;ht!==null&&!pm();)_d(ht)}function _d(e){var t=Fd(e.alternate,e,Vt);e.memoizedProps=e.pendingProps,t===null?Ld(e):ht=t,Ko.current=null}function Ld(e){var t=e;do{var a=t.alternate;if(e=t.return,(t.flags&32768)===0){if(a=zp(a,t,Vt),a!==null){ht=a;return}}else{if(a=Fp(a,t),a!==null){a.flags&=32767,ht=a;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{gt=6,ht=null;return}}if(t=t.sibling,t!==null){ht=t;return}ht=t=e}while(t!==null);gt===0&&(gt=5)}function mr(e,t,a){var l=Ve,u=Qt.transition;try{Qt.transition=null,Ve=1,Vp(e,t,a,l)}finally{Qt.transition=u,Ve=l}return null}function Vp(e,t,a,l){do Vr();while(Kn!==null);if((Ue&6)!==0)throw Error(i(327));a=e.finishedWork;var u=e.finishedLanes;if(a===null)return null;if(e.finishedWork=null,e.finishedLanes=0,a===e.current)throw Error(i(177));e.callbackNode=null,e.callbackPriority=0;var h=a.lanes|a.childLanes;if(Nm(e,h),e===St&&(ht=St=null,Ct=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||Ga||(Ga=!0,Od(ea,function(){return Vr(),null})),h=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||h){h=Qt.transition,Qt.transition=null;var x=Ve;Ve=1;var b=Ue;Ue|=4,Ko.current=null,Mp(e,a),bd(a,e),dp(to),oa=!!eo,to=eo=null,e.current=a,Bp(a),gm(),Ue=b,Ve=x,Qt.transition=h}else e.current=a;if(Ga&&(Ga=!1,Kn=e,Ka=u),h=e.pendingLanes,h===0&&(Gn=null),xm(a.stateNode),Ot(e,ct()),t!==null)for(l=e.onRecoverableError,a=0;a<t.length;a++)u=t[a],l(u.value,{componentStack:u.stack,digest:u.digest});if(Va)throw Va=!1,e=qo,qo=null,e;return(Ka&1)!==0&&e.tag!==0&&Vr(),h=e.pendingLanes,(h&1)!==0?e===Qo?Ls++:(Ls=0,Qo=e):Ls=0,Un(),null}function Vr(){if(Kn!==null){var e=Sc(Ka),t=Qt.transition,a=Ve;try{if(Qt.transition=null,Ve=16>e?16:e,Kn===null)var l=!1;else{if(e=Kn,Kn=null,Ka=0,(Ue&6)!==0)throw Error(i(331));var u=Ue;for(Ue|=4,xe=e.current;xe!==null;){var h=xe,x=h.child;if((xe.flags&16)!==0){var b=h.deletions;if(b!==null){for(var R=0;R<b.length;R++){var U=b[R];for(xe=U;xe!==null;){var Q=xe;switch(Q.tag){case 0:case 11:case 15:As(8,Q,h)}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(xd(Q),Q===U){xe=null;break}if(q!==null){q.return=ye,xe=q;break}xe=ye}}}var Se=h.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=h}}if((h.subtreeFlags&2064)!==0&&x!==null)x.return=h,xe=x;else e:for(;xe!==null;){if(h=xe,(h.flags&2048)!==0)switch(h.tag){case 0:case 11:case 15:As(9,h,h.return)}var z=h.sibling;if(z!==null){z.return=h.return,xe=z;break e}xe=h.return}}var P=e.current;for(xe=P;xe!==null;){x=xe;var F=x.child;if((x.subtreeFlags&2064)!==0&&F!==null)F.return=x,xe=F;else e:for(x=P;xe!==null;){if(b=xe,(b.flags&2048)!==0)try{switch(b.tag){case 0:case 11:case 15:Ua(9,b)}}catch(Ne){ot(b,b.return,Ne)}if(b===x){xe=null;break e}var le=b.sibling;if(le!==null){le.return=b.return,xe=le;break e}xe=b.return}}if(Ue=u,Un(),hn&&typeof hn.onPostCommitFiberRoot=="function")try{hn.onPostCommitFiberRoot(ta,e)}catch{}l=!0}return l}finally{Ve=a,Qt.transition=t}}return!1}function $d(e,t,a){t=Dr(a,t),t=Zu(e,t,1),e=Hn(e,t,1),t=_t(),e!==null&&(ss(e,1,t),Ot(e,t))}function ot(e,t,a){if(e.tag===3)$d(e,e,a);else for(;t!==null;){if(t.tag===3){$d(t,e,a);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Gn===null||!Gn.has(l))){e=Dr(a,e),e=ed(t,e,1),t=Hn(t,e,1),e=_t(),t!==null&&(ss(t,1,e),Ot(t,e));break}}t=t.return}}function Gp(e,t,a){var l=e.pingCache;l!==null&&l.delete(t),t=_t(),e.pingedLanes|=e.suspendedLanes&a,St===e&&(Ct&a)===a&&(gt===4||gt===3&&(Ct&130023424)===Ct&&500>ct()-Jo?hr(e,0):Yo|=a),Ot(e,t)}function zd(e,t){t===0&&((e.mode&1)===0?t=1:(t=ra,ra<<=1,(ra&130023424)===0&&(ra=4194304)));var a=_t();e=Nn(e,t),e!==null&&(ss(e,t,a),Ot(e,a))}function Kp(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),zd(e,a)}function Yp(e,t){var a=0;switch(e.tag){case 13:var l=e.stateNode,u=e.memoizedState;u!==null&&(a=u.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(i(314))}l!==null&&l.delete(t),zd(e,a)}var Fd;Fd=function(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps||Lt.current)zt=!0;else{if((e.lanes&a)===0&&(t.flags&128)===0)return zt=!1,$p(e,t,a);zt=(e.flags&131072)!==0}else zt=!1,nt&&(t.flags&1048576)!==0&&gu(t,Na,t.index);switch(t.lanes=0,t.tag){case 2:var l=t.type;Ba(e,t),e=t.pendingProps;var u=_r(t,Tt.current);Mr(t,a),u=Co(null,t,l,e,u,a);var h=Eo();return t.flags|=1,typeof u=="object"&&u!==null&&typeof u.render=="function"&&u.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,$t(l)?(h=!0,Sa(t)):h=!1,t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,xo(t),u.updater=Oa,t.stateNode=u,u._reactInternals=t,_o(t,l,e,a),t=Fo(null,t,l,!0,h,a)):(t.tag=0,nt&&h&&lo(t),Pt(null,t,u,a),t=t.child),t;case 16:l=t.elementType;e:{switch(Ba(e,t),e=t.pendingProps,u=l._init,l=u(l._payload),t.type=l,u=t.tag=qp(l),e=sn(l,e),u){case 0:t=zo(null,t,l,e,a);break e;case 1:t=cd(null,t,l,e,a);break e;case 11:t=sd(null,t,l,e,a);break e;case 14:t=ad(null,t,l,sn(l.type,e),a);break e}throw Error(i(306,l,""))}return t;case 0:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:sn(l,u),zo(e,t,l,u,a);case 1:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:sn(l,u),cd(e,t,l,u,a);case 3:e:{if(ud(t),e===null)throw Error(i(387));l=t.pendingProps,h=t.memoizedState,u=h.element,Nu(e,t),Aa(t,l,null,a);var x=t.memoizedState;if(l=x.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},t.updateQueue.baseState=h,t.memoizedState=h,t.flags&256){u=Dr(Error(i(423)),t),t=dd(e,t,l,a,u);break e}else if(l!==u){u=Dr(Error(i(424)),t),t=dd(e,t,l,a,u);break e}else for(Ht=Mn(t.stateNode.containerInfo.firstChild),Wt=t,nt=!0,rn=null,a=ku(t,null,l,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(zr(),l===u){t=En(e,t,a);break e}Pt(e,t,l,a)}t=t.child}return t;case 5:return Tu(t),e===null&&fo(t),l=t.type,u=t.pendingProps,h=e!==null?e.memoizedProps:null,x=u.children,no(l,u)?x=null:h!==null&&no(l,h)&&(t.flags|=32),ld(e,t),Pt(e,t,x,a),t.child;case 6:return e===null&&fo(t),null;case 13:return fd(e,t,a);case 4:return wo(t,t.stateNode.containerInfo),l=t.pendingProps,e===null?t.child=Fr(t,null,l,a):Pt(e,t,l,a),t.child;case 11:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:sn(l,u),sd(e,t,l,u,a);case 7:return Pt(e,t,t.pendingProps,a),t.child;case 8:return Pt(e,t,t.pendingProps.children,a),t.child;case 12:return Pt(e,t,t.pendingProps.children,a),t.child;case 10:e:{if(l=t.type._context,u=t.pendingProps,h=t.memoizedProps,x=u.value,qe(Ta,l._currentValue),l._currentValue=x,h!==null)if(nn(h.value,x)){if(h.children===u.children&&!Lt.current){t=En(e,t,a);break e}}else for(h=t.child,h!==null&&(h.return=t);h!==null;){var b=h.dependencies;if(b!==null){x=h.child;for(var R=b.firstContext;R!==null;){if(R.context===l){if(h.tag===1){R=Cn(-1,a&-a),R.tag=2;var U=h.updateQueue;if(U!==null){U=U.shared;var Q=U.pending;Q===null?R.next=R:(R.next=Q.next,Q.next=R),U.pending=R}}h.lanes|=a,R=h.alternate,R!==null&&(R.lanes|=a),yo(h.return,a,t),b.lanes|=a;break}R=R.next}}else if(h.tag===10)x=h.type===t.type?null:h.child;else if(h.tag===18){if(x=h.return,x===null)throw Error(i(341));x.lanes|=a,b=x.alternate,b!==null&&(b.lanes|=a),yo(x,a,t),x=h.sibling}else x=h.child;if(x!==null)x.return=h;else for(x=h;x!==null;){if(x===t){x=null;break}if(h=x.sibling,h!==null){h.return=x.return,x=h;break}x=x.return}h=x}Pt(e,t,u.children,a),t=t.child}return t;case 9:return u=t.type,l=t.pendingProps.children,Mr(t,a),u=Jt(u),l=l(u),t.flags|=1,Pt(e,t,l,a),t.child;case 14:return l=t.type,u=sn(l,t.pendingProps),u=sn(l.type,u),ad(e,t,l,u,a);case 15:return id(e,t,t.type,t.pendingProps,a);case 17:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:sn(l,u),Ba(e,t),t.tag=1,$t(l)?(e=!0,Sa(t)):e=!1,Mr(t,a),Qu(t,l,u),_o(t,l,u,a),Fo(null,t,l,!0,e,a);case 19:return md(e,t,a);case 22:return od(e,t,a)}throw Error(i(156,t.tag))};function Od(e,t){return yc(e,t)}function Jp(e,t,a,l){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xt(e,t,a,l){return new Jp(e,t,a,l)}function rl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qp(e){if(typeof e=="function")return rl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===D)return 11;if(e===Z)return 14}return 2}function qn(e,t){var a=e.alternate;return a===null?(a=Xt(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&14680064,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a}function Qa(e,t,a,l,u,h){var x=2;if(l=e,typeof e=="function")rl(e)&&(x=1);else if(typeof e=="string")x=5;else e:switch(e){case V:return pr(a.children,u,h,t);case de:x=8,u|=8;break;case Y:return e=Xt(12,a,t,u|2),e.elementType=Y,e.lanes=h,e;case ie:return e=Xt(13,a,t,u),e.elementType=ie,e.lanes=h,e;case fe:return e=Xt(19,a,t,u),e.elementType=fe,e.lanes=h,e;case ee:return Xa(a,u,h,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case re:x=10;break e;case G:x=9;break e;case D:x=11;break e;case Z:x=14;break e;case pe:x=16,l=null;break e}throw Error(i(130,e==null?e:typeof e,""))}return t=Xt(x,a,t,u),t.elementType=e,t.type=l,t.lanes=h,t}function pr(e,t,a,l){return e=Xt(7,e,l,t),e.lanes=a,e}function Xa(e,t,a,l){return e=Xt(22,e,l,t),e.elementType=ee,e.lanes=a,e.stateNode={isHidden:!1},e}function sl(e,t,a){return e=Xt(6,e,null,t),e.lanes=a,e}function al(e,t,a){return t=Xt(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Qp(e,t,a,l,u){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ai(0),this.expirationTimes=Ai(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ai(0),this.identifierPrefix=l,this.onRecoverableError=u,this.mutableSourceEagerHydrationData=null}function il(e,t,a,l,u,h,x,b,R){return e=new Qp(e,t,a,b,R),t===1?(t=1,h===!0&&(t|=8)):t=0,h=Xt(3,null,null,t),e.current=h,h.stateNode=e,h.memoizedState={element:l,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},xo(h),e}function Xp(e,t,a){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:K,key:l==null?null:""+l,children:e,containerInfo:t,implementation:a}}function Md(e){if(!e)return Dn;e=e._reactInternals;e:{if(rr(e)!==e||e.tag!==1)throw Error(i(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if($t(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(i(171))}if(e.tag===1){var a=e.type;if($t(a))return hu(e,a,t)}return t}function Bd(e,t,a,l,u,h,x,b,R){return e=il(a,l,!0,e,u,h,x,b,R),e.context=Md(null),a=e.current,l=_t(),u=Yn(a),h=Cn(l,u),h.callback=t??null,Hn(a,h,u),e.current.lanes=u,ss(e,u,l),Ot(e,l),e}function Za(e,t,a,l){var u=t.current,h=_t(),x=Yn(u);return a=Md(a),t.context===null?t.context=a:t.pendingContext=a,t=Cn(h,x),t.payload={element:e},l=l===void 0?null:l,l!==null&&(t.callback=l),e=Hn(u,t,x),e!==null&&(ln(e,u,x,h),Ia(e,u,x)),x}function ei(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 Dd(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function ol(e,t){Dd(e,t),(e=e.alternate)&&Dd(e,t)}function Zp(){return null}var Ud=typeof reportError=="function"?reportError:function(e){console.error(e)};function ll(e){this._internalRoot=e}ti.prototype.render=ll.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));Za(e,t,null,null)},ti.prototype.unmount=ll.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;fr(function(){Za(null,e,null,null)}),t[jn]=null}};function ti(e){this._internalRoot=e}ti.prototype.unstable_scheduleHydration=function(e){if(e){var t=Nc();e={blockedOn:null,target:e,priority:t};for(var a=0;a<zn.length&&t!==0&&t<zn[a].priority;a++);zn.splice(a,0,e),a===0&&Tc(e)}};function cl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ni(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Wd(){}function eg(e,t,a,l,u){if(u){if(typeof l=="function"){var h=l;l=function(){var U=ei(x);h.call(U)}}var x=Bd(t,l,e,0,null,!1,!1,"",Wd);return e._reactRootContainer=x,e[jn]=x.current,vs(e.nodeType===8?e.parentNode:e),fr(),x}for(;u=e.lastChild;)e.removeChild(u);if(typeof l=="function"){var b=l;l=function(){var U=ei(R);b.call(U)}}var R=il(e,0,!1,null,null,!1,!1,"",Wd);return e._reactRootContainer=R,e[jn]=R.current,vs(e.nodeType===8?e.parentNode:e),fr(function(){Za(t,R,a,l)}),R}function ri(e,t,a,l,u){var h=a._reactRootContainer;if(h){var x=h;if(typeof u=="function"){var b=u;u=function(){var R=ei(x);b.call(R)}}Za(t,x,e,u)}else x=eg(a,t,e,u,l);return ei(x)}kc=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var a=rs(t.pendingLanes);a!==0&&(Pi(t,a|1),Ot(t,ct()),(Ue&6)===0&&(Hr=ct()+500,Un()))}break;case 13:fr(function(){var l=Nn(e,1);if(l!==null){var u=_t();ln(l,e,1,u)}}),ol(e,1)}},_i=function(e){if(e.tag===13){var t=Nn(e,134217728);if(t!==null){var a=_t();ln(t,e,134217728,a)}ol(e,134217728)}},bc=function(e){if(e.tag===13){var t=Yn(e),a=Nn(e,t);if(a!==null){var l=_t();ln(a,e,t,l)}ol(e,t)}},Nc=function(){return Ve},Cc=function(e,t){var a=Ve;try{return Ve=e,t()}finally{Ve=a}},ae=function(e,t,a){switch(t){case"input":if(Le(e,a),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<a.length;t++){var l=a[t];if(l!==e&&l.form===e.form){var u=wa(l);if(!u)throw Error(i(90));_e(l),Le(l,u)}}}break;case"textarea":Fe(e,a);break;case"select":t=a.value,t!=null&&et(e,!!a.multiple,t,!1)}},Dt=el,Xn=fr;var tg={usingClientEntryPoint:!1,Events:[js,Ar,wa,ze,Je,el]},$s={findFiberByHostInstance:sr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ng={bundleType:$s.bundleType,version:$s.version,rendererPackageName:$s.rendererPackageName,rendererConfig:$s.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:A.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=pc(e),e===null?null:e.stateNode},findFiberByHostInstance:$s.findFiberByHostInstance||Zp,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 si=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!si.isDisabled&&si.supportsFiber)try{ta=si.inject(ng),hn=si}catch{}}return Mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=tg,Mt.createPortal=function(e,t){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!cl(t))throw Error(i(200));return Xp(e,t,null,a)},Mt.createRoot=function(e,t){if(!cl(e))throw Error(i(299));var a=!1,l="",u=Ud;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(l=t.identifierPrefix),t.onRecoverableError!==void 0&&(u=t.onRecoverableError)),t=il(e,1,!1,null,null,a,!1,l,u),e[jn]=t.current,vs(e.nodeType===8?e.parentNode:e),new ll(t)},Mt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(i(188)):(e=Object.keys(e).join(","),Error(i(268,e)));return e=pc(t),e=e===null?null:e.stateNode,e},Mt.flushSync=function(e){return fr(e)},Mt.hydrate=function(e,t,a){if(!ni(t))throw Error(i(200));return ri(null,e,t,!0,a)},Mt.hydrateRoot=function(e,t,a){if(!cl(e))throw Error(i(405));var l=a!=null&&a.hydratedSources||null,u=!1,h="",x=Ud;if(a!=null&&(a.unstable_strictMode===!0&&(u=!0),a.identifierPrefix!==void 0&&(h=a.identifierPrefix),a.onRecoverableError!==void 0&&(x=a.onRecoverableError)),t=Bd(t,null,e,1,a??null,u,!1,h,x),e[jn]=t.current,vs(e),l)for(e=0;e<l.length;e++)a=l[e],u=a._getVersion,u=u(a._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[a,u]:t.mutableSourceEagerHydrationData.push(a,u);return new ti(t)},Mt.render=function(e,t,a){if(!ni(t))throw Error(i(200));return ri(null,e,t,!1,a)},Mt.unmountComponentAtNode=function(e){if(!ni(e))throw Error(i(40));return e._reactRootContainer?(fr(function(){ri(null,null,e,!1,function(){e._reactRootContainer=null,e[jn]=null})}),!0):!1},Mt.unstable_batchedUpdates=el,Mt.unstable_renderSubtreeIntoContainer=function(e,t,a,l){if(!ni(a))throw Error(i(200));if(e==null||e._reactInternals===void 0)throw Error(i(38));return ri(e,t,a,!1,l)},Mt.version="18.3.1-next-f1338f8080-20240426",Mt}var Qd;function Jf(){if(Qd)return fl.exports;Qd=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(s){console.error(s)}}return n(),fl.exports=dg(),fl.exports}var Xd;function fg(){if(Xd)return ai;Xd=1;var n=Jf();return ai.createRoot=n.createRoot,ai.hydrateRoot=n.hydrateRoot,ai}var hg=fg();/**
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 Bl=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,qf=/^[\\/]{2}/;function mg(n,s){return s+n.replace(/\\/g,"/")}var Zd="popstate";function ef(n){return typeof n=="object"&&n!=null&&"pathname"in n&&"search"in n&&"hash"in n&&"state"in n&&"key"in n}function pg(n={}){function s(o,c){var y;let d=(y=c.state)==null?void 0:y.masked,{pathname:m,search:g,hash:p}=d||o.location;return Nl("",{pathname:m,search:g,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 i(o,c){return typeof c=="string"?c:jr(c)}return yg(s,i,null,n)}function rt(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function en(n,s){if(!n){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function gg(){return Math.random().toString(36).substring(2,10)}function tf(n,s){return{usr:n.state,key:n.key,idx:s,masked:n.mask?{pathname:n.pathname,search:n.search,hash:n.hash}:void 0}}function Nl(n,s,i=null,o,c){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof s=="string"?Qr(s):s,state:i,key:s&&s.key||o||gg(),mask:c}}function jr({pathname:n="/",search:s="",hash:i=""}){return s&&s!=="?"&&(n+=s.charAt(0)==="?"?s:"?"+s),i&&i!=="#"&&(n+=i.charAt(0)==="#"?i:"#"+i),n}function Qr(n){let s={};if(n){let i=n.indexOf("#");i>=0&&(s.hash=n.substring(i),n=n.substring(0,i));let o=n.indexOf("?");o>=0&&(s.search=n.substring(o),n=n.substring(0,o)),n&&(s.pathname=n)}return s}function yg(n,s,i,o={}){let{window:c=document.defaultView,v5Compat:d=!1}=o,m=c.history,g="POP",p=null,y=v();y==null&&(y=0,m.replaceState({...m.state,idx:y},""));function v(){return(m.state||{idx:null}).idx}function j(){g="POP";let C=v(),T=C==null?null:C-y;y=C,p&&p({action:g,location:k.location,delta:T})}function w(C,T){g="PUSH";let I=ef(C)?C:Nl(k.location,C,T);y=v()+1;let $=tf(I,y),A=k.createHref(I.mask||I);try{m.pushState($,"",A)}catch(B){if(B instanceof DOMException&&B.name==="DataCloneError")throw B;c.location.assign(A)}d&&p&&p({action:g,location:k.location,delta:1})}function N(C,T){g="REPLACE";let I=ef(C)?C:Nl(k.location,C,T);y=v();let $=tf(I,y),A=k.createHref(I.mask||I);m.replaceState($,"",A),d&&p&&p({action:g,location:k.location,delta:0})}function E(C){return vg(c,C)}let k={get action(){return g},get location(){return n(c,m)},listen(C){if(p)throw new Error("A history only accepts one active listener");return c.addEventListener(Zd,j),p=C,()=>{c.removeEventListener(Zd,j),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:w,replace:N,go(C){return m.go(C)}};return k}function vg(n,s,i=!1){let o="http://localhost";n&&(o=n.location.origin!=="null"?n.location.origin:n.location.href),rt(o,"No window.location.(origin|href) available to create URL");let c=typeof s=="string"?s:jr(s);return c=c.replace(/ $/,"%20"),!i&&qf.test(c)&&(c=o+c),new URL(c,o)}function Qf(n,s,i="/"){return xg(n,s,i,!1)}function xg(n,s,i,o,c){let d=typeof s=="string"?Qr(s):s,m=An(d.pathname||"/",i);if(m==null)return null;let g=wg(n),p=null,y=Ag(m);for(let v=0;p==null&&v<g.length;++v)p=Ig(g[v],y,o);return p}function wg(n){let s=Xf(n);return jg(s),s}function Xf(n,s=[],i=[],o="",c=!1){let d=(m,g,p=c,y)=>{let v={relativePath:y===void 0?m.path||"":y,caseSensitive:m.caseSensitive===!0,childrenIndex:g,route:m};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 j=cn([o,v.relativePath]),w=i.concat(v);m.children&&m.children.length>0&&(rt(m.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${j}".`),Xf(m.children,s,w,j,p)),!(m.path==null&&!m.index)&&s.push({path:j,score:Tg(j,m.index),routesMeta:w.map((N,E)=>{let[k,C]=th(N.relativePath,N.caseSensitive,E===w.length-1);return{...N,matcher:k,compiledParams:C}})})};return n.forEach((m,g)=>{var p;if(m.path===""||!((p=m.path)!=null&&p.includes("?")))d(m,g);else for(let y of Zf(m.path))d(m,g,!0,y)}),s}function Zf(n){let s=n.split("/");if(s.length===0)return[];let[i,...o]=s,c=i.endsWith("?"),d=i.replace(/\?$/,"");if(o.length===0)return c?[d,""]:[d];let m=Zf(o.join("/")),g=[];return g.push(...m.map(p=>p===""?d:[d,p].join("/"))),c&&g.push(...m),g.map(p=>n.startsWith("/")&&p===""?"/":p)}function jg(n){n.sort((s,i)=>s.score!==i.score?i.score-s.score:Rg(s.routesMeta.map(o=>o.childrenIndex),i.routesMeta.map(o=>o.childrenIndex)))}var Sg=/^:[\w-]+$/,kg=3,bg=2,Ng=1,Cg=10,Eg=-2,nf=n=>n==="*";function Tg(n,s){let i=n.split("/"),o=i.length;return i.some(nf)&&(o+=Eg),s&&(o+=bg),i.filter(c=>!nf(c)).reduce((c,d)=>c+(Sg.test(d)?kg:d===""?Ng:Cg),o)}function Rg(n,s){return n.length===s.length&&n.slice(0,-1).every((o,c)=>o===s[c])?n[n.length-1]-s[s.length-1]:0}function Ig(n,s,i=!1){let{routesMeta:o}=n,c={},d="/",m=[];for(let g=0;g<o.length;++g){let p=o[g],y=g===o.length-1,v=d==="/"?s:s.slice(d.length)||"/",j={path:p.relativePath,caseSensitive:p.caseSensitive,end:y},w=p.matcher&&p.compiledParams?eh(j,v,p.matcher,p.compiledParams):vi(j,v),N=p.route;if(!w&&y&&i&&!o[o.length-1].route.index&&(w=vi({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},v)),!w)return null;Object.assign(c,w.params),m.push({params:c,pathname:cn([d,w.pathname]),pathnameBase:Lg(cn([d,w.pathnameBase])),route:N}),w.pathnameBase!=="/"&&(d=cn([d,w.pathnameBase]))}return m}function vi(n,s){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[i,o]=th(n.path,n.caseSensitive,n.end);return eh(n,s,i,o)}function eh(n,s,i,o){let c=s.match(i);if(!c)return null;let d=c[0],m=Jr(d,1),g=c.slice(1);return{params:o.reduce((y,{paramName:v,isOptional:j},w)=>{if(v==="*"){let E=g[w]||"";m=Jr(d.slice(0,d.length-E.length),1)}const N=g[w];return j&&!N?y[v]=void 0:y[v]=(N||"").replace(/%2F/g,"/"),y},{}),pathname:d,pathnameBase:m,pattern:n}}function th(n,s=!1,i=!0){en(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let o=[],c="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(m,g,p,y,v)=>{if(o.push({paramName:g,isOptional:p!=null}),p){let j=v.charAt(y+m.length);return j&&j!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(o.push({paramName:"*"}),c+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?c+="\\/*$":n!==""&&n!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,s?void 0:"i"),o]}function Ag(n){try{return n.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return en(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),n}}function An(n,s){if(s==="/")return n;if(!n.toLowerCase().startsWith(s.toLowerCase()))return null;let i=s.endsWith("/")?s.length-1:s.length,o=n.charAt(i);return o&&o!=="/"?null:n.slice(i)||"/"}function Pg(n,s="/"){let{pathname:i,search:o="",hash:c=""}=typeof n=="string"?Qr(n):n,d;return i?(i=nh(i),i.startsWith("/")||i.startsWith("\\")?d=rf(i.substring(1),"/"):d=rf(i,s)):d=s,{pathname:d,search:$g(o),hash:zg(c)}}function rf(n,s){let i=Jr(s).split("/");return n.split("/").forEach(c=>{c===".."?i.length>1&&i.pop():c!=="."&&i.push(c)}),i.length>1?i.join("/"):"/"}function pl(n,s,i,o){return`Cannot include a '${n}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function _g(n){return n.filter((s,i)=>i===0||s.route.path&&s.route.path.length>0)}function Dl(n){let s=_g(n);return s.map((i,o)=>o===s.length-1?i.pathname:i.pathnameBase)}function bi(n,s,i,o=!1){let c;typeof n=="string"?c=Qr(n):(c={...n},rt(!c.pathname||!c.pathname.includes("?"),pl("?","pathname","search",c)),rt(!c.pathname||!c.pathname.includes("#"),pl("#","pathname","hash",c)),rt(!c.search||!c.search.includes("#"),pl("#","search","hash",c)));let d=n===""||c.pathname==="",m=d?"/":c.pathname,g;if(m==null)g=i;else{let j=s.length-1;if(!o&&m.startsWith("..")){let w=m.split("/");for(;w[0]==="..";)w.shift(),j-=1;c.pathname=w.join("/")}g=j>=0?s[j]:"/"}let p=Pg(c,g),y=m&&m!=="/"&&m.endsWith("/"),v=(d||m===".")&&i.endsWith("/");return!p.pathname.endsWith("/")&&(y||v)&&(p.pathname+="/"),p}var nh=n=>n.replace(/[\\/]{2,}/g,"/"),cn=n=>nh(n.join("/"));function Jr(n,s=0){let i=n.length;for(;i>s&&n.charCodeAt(i-1)===47;)i--;return i===n.length?n:n.slice(0,i)}var Lg=n=>Jr(n).replace(/^\/*/,"/"),$g=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,zg=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n,Fg=class{constructor(n,s,i,o=!1){this.status=n,this.statusText=s||"",this.internal=o,i instanceof Error?(this.data=i.toString(),this.error=i):this.data=i}};function Og(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}function Mg(n){let s=n.map(i=>i.route.path).filter(Boolean);return cn(s)||"/"}var rh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function sh(n,s){let i=n;if(typeof i!="string"||!Bl.test(i))return{absoluteURL:void 0,isExternal:!1,to:i};let o=i,c=!1;if(rh)try{let d=new URL(window.location.href),m=qf.test(i)?new URL(mg(i,d.protocol)):new URL(i),g=An(m.pathname,s);m.origin===d.origin&&g!=null?i=g+m.search+m.hash:c=!0}catch{en(!1,`<Link to="${i}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var sf=new URL("http://localhost");function Ul(n){if(n.createURL)return n.createURL("/");try{return new URL(n.createHref("/"),sf)}catch{return sf}}function gl(n,s){return n.origin===s.origin&&(n.origin!=="null"||n.protocol===s.protocol&&n.host===s.host)}function Bg(n,s){if(n.startsWith("//"))return!0;let i=s.protocol.toLowerCase();return n.toLowerCase().startsWith(i)?s.host===""||n.slice(i.length).startsWith("//"):!1}function Wl(n,s,i,o){let c=null;try{c=n==null?null:new URL(n,i)}catch{}let d=new URL(s,i),m=c!=null&&!gl(c,i),g=!gl(d,i);if(o==="reject"){if(m||g)throw new Error("External navigation is not allowed")}else if(g&&(c==null||!Bg(n,c)||!gl(c,d)))throw new Error("External navigation is not allowed")}var ah=["POST","PUT","PATCH","DELETE"];new Set(ah);var Dg=["GET",...ah];new Set(Dg);var Ug=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Wg(n){try{return Ug.includes(new URL(n).protocol)}catch{return!1}}var Xr=f.createContext(null);Xr.displayName="DataRouter";var Ni=f.createContext(null);Ni.displayName="DataRouterState";var ih=f.createContext(!1);function Hg(){return f.useContext(ih)}var oh=f.createContext({isTransitioning:!1});oh.displayName="ViewTransition";var Vg=f.createContext(new Map);Vg.displayName="Fetchers";var Gg=f.createContext(null);Gg.displayName="Await";var Gt=f.createContext(null);Gt.displayName="Navigation";var Ys=f.createContext(null);Ys.displayName="Location";var un=f.createContext({outlet:null,matches:[],isDataRoute:!1});un.displayName="Route";var Hl=f.createContext(null);Hl.displayName="RouteError";var lh="REACT_ROUTER_ERROR",Kg="REDIRECT",Yg="ROUTE_ERROR_RESPONSE";function Jg(n){if(n.startsWith(`${lh}:${Kg}:{`))try{let s=JSON.parse(n.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 qg(n){if(n.startsWith(`${lh}:${Yg}:{`))try{let s=JSON.parse(n.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new Fg(s.status,s.statusText,s.data)}catch{}}function Qg(n,{relative:s}={}){rt(Zr(),"useHref() may be used only in the context of a <Router> component.");let{basename:i,navigator:o}=f.useContext(Gt),{hash:c,pathname:d,search:m}=Js(n,{relative:s}),g=d;return i!=="/"&&(g=d==="/"?i:cn([i,d])),o.createHref({pathname:g,search:m,hash:c})}function Zr(){return f.useContext(Ys)!=null}function Bt(){return rt(Zr(),"useLocation() may be used only in the context of a <Router> component."),f.useContext(Ys).location}var ch="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function uh(n){f.useContext(Gt).static||f.useLayoutEffect(n)}function dn(){let{isDataRoute:n}=f.useContext(un);return n?fy():Xg()}function Xg(){rt(Zr(),"useNavigate() may be used only in the context of a <Router> component.");let n=f.useContext(Xr),{basename:s,navigator:i}=f.useContext(Gt),{matches:o}=f.useContext(un),{pathname:c}=Bt(),d=JSON.stringify(Dl(o)),m=f.useRef(!1);return uh(()=>{m.current=!0}),f.useCallback((p,y={})=>{if(en(m.current,ch),!m.current)return;if(typeof p=="number"){i.go(p);return}let v=bi(p,JSON.parse(d),c,y.relative==="path");n==null&&s!=="/"&&(v.pathname=v.pathname==="/"?s:cn([s,v.pathname])),Wl(typeof p=="string"?p:jr(p),i.createHref(v),Ul(i),"reject"),(y.replace?i.replace:i.push)(v,y.state,y)},[s,i,d,c,n])}var Zg=f.createContext(null);function ey(n){let s=f.useContext(un).outlet;return f.useMemo(()=>s&&f.createElement(Zg.Provider,{value:n},s),[s,n])}function Js(n,{relative:s}={}){let{matches:i}=f.useContext(un),{pathname:o}=Bt(),c=JSON.stringify(Dl(i));return f.useMemo(()=>bi(n,JSON.parse(c),o,s==="path"),[n,c,o,s])}function ty(n,s){return dh(n,s)}function dh(n,s,i){var C;rt(Zr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=f.useContext(Gt),{matches:c}=f.useContext(un),d=c[c.length-1],m=d?d.params:{},g=d?d.pathname:"/",p=d?d.pathnameBase:"/",y=d&&d.route;{let T=y&&y.path||"";hh(g,!y||T.endsWith("*")||T.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (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=Bt(),j;if(s){let T=typeof s=="string"?Qr(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.`),j=T}else j=v;let w=j.pathname||"/",N=w;if(p!=="/"){let T=p.replace(/^\//,"").split("/");N="/"+w.replace(/^\//,"").split("/").slice(T.length).join("/")}let E=i&&i.state.matches.length?i.state.matches.map(T=>Object.assign(T,{route:i.manifest[T.route.id]||T.route})):Qf(n,{pathname:N});en(y||E!=null,`No routes matched location "${j.pathname}${j.search}${j.hash}" `),en(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 "${j.pathname}${j.search}${j.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 k=iy(E&&E.map(T=>Object.assign({},T,{params:Object.assign({},m,T.params),pathname:cn([p,o.encodeLocation?o.encodeLocation(T.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathname]),pathnameBase:T.pathnameBase==="/"?p:cn([p,o.encodeLocation?o.encodeLocation(T.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathnameBase])})),c,i);return s&&k?f.createElement(Ys.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...j},navigationType:"POP"}},k):k}function ny(){let n=dy(),s=Og(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),i=n instanceof Error?n.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},d={padding:"2px 4px",backgroundColor:o},m=null;return console.error("Error handled by React Router default ErrorBoundary:",n),m=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),i?f.createElement("pre",{style:c},i):null,m)}var ry=f.createElement(ny,null),fh=class extends f.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,s){return s.location!==n.location||s.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:s.error,location:s.location,revalidation:n.revalidation||s.revalidation}}componentDidCatch(n,s){this.props.onError?this.props.onError(n,s):console.error("React Router caught the following error during render",n)}render(){let n=this.state.error;if(this.context&&typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){const i=qg(n.digest);i&&(n=i)}let s=n!==void 0?f.createElement(un.Provider,{value:this.props.routeContext},f.createElement(Hl.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?f.createElement(sy,{error:n},s):s}};fh.contextType=ih;var yl=new WeakMap;function sy({children:n,error:s}){let{basename:i,navigator:o}=f.useContext(Gt);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let c=Jg(s.digest);if(c){let d=yl.get(s);if(d)throw d;let m=sh(c.location,i),g=m.absoluteURL||m.to;if(Wl(c.location,g,Ul(o),"allow-explicit"),Wg(g))throw new Error("Invalid redirect location");if(rh&&!yl.get(s))if(m.isExternal||c.reloadDocument)window.location.href=g;else{const p=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(m.to,{replace:c.replace}));throw yl.set(s,p),p}return f.createElement("meta",{httpEquiv:"refresh",content:`0;url=${g}`})}}return n}function ay({routeContext:n,match:s,children:i}){let o=f.useContext(Xr);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),f.createElement(un.Provider,{value:n},i)}function iy(n,s=[],i){let o=i==null?void 0:i.state;if(n==null){if(!o)return null;if(o.errors)n=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)n=o.matches;else return null}let c=n,d=o==null?void 0:o.errors;if(d!=null){let v=c.findIndex(j=>j.route.id&&(d==null?void 0:d[j.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 m=!1,g=-1;if(i&&o){m=o.renderFallback;for(let v=0;v<c.length;v++){let j=c[v];if((j.route.HydrateFallback||j.route.hydrateFallbackElement)&&(g=v),j.route.id){let{loaderData:w,errors:N}=o,E=j.route.loader&&!w.hasOwnProperty(j.route.id)&&(!N||N[j.route.id]===void 0);if(j.route.lazy||E){i.isStatic&&(m=!0),g>=0?c=c.slice(0,g+1):c=[c[0]];break}}}}let p=i==null?void 0:i.onError,y=o&&p?(v,j)=>{var w,N;p(v,{location:o.location,params:((N=(w=o.matches)==null?void 0:w[0])==null?void 0:N.params)??{},pattern:Mg(o.matches),errorInfo:j})}:void 0;return c.reduceRight((v,j,w)=>{let N,E=!1,k=null,C=null;o&&(N=d&&j.route.id?d[j.route.id]:void 0,k=j.route.errorElement||ry,m&&(g<0&&w===0?(hh("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,C=null):g===w&&(E=!0,C=j.route.hydrateFallbackElement||null)));let T=s.concat(c.slice(0,w+1)),I=()=>{let $;return N?$=k:E?$=C:j.route.Component?$=f.createElement(j.route.Component,null):j.route.element?$=j.route.element:$=v,f.createElement(ay,{match:j,routeContext:{outlet:v,matches:T,isDataRoute:o!=null},children:$})};return o&&(j.route.ErrorBoundary||j.route.errorElement||w===0)?f.createElement(fh,{location:o.location,revalidation:o.revalidation,component:k,error:N,children:I(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:y}):I()},null)}function Vl(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function oy(n){let s=f.useContext(Xr);return rt(s,Vl(n)),s}function ly(n){let s=f.useContext(Ni);return rt(s,Vl(n)),s}function cy(n){let s=f.useContext(un);return rt(s,Vl(n)),s}function Gl(n){let s=cy(n),i=s.matches[s.matches.length-1];return rt(i.route.id,`${n} can only be used on routes that contain a unique "id"`),i.route.id}function uy(){return Gl("useRouteId")}function dy(){var o;let n=f.useContext(Hl),s=ly("useRouteError"),i=Gl("useRouteError");return n!==void 0?n:(o=s.errors)==null?void 0:o[i]}function fy(){let{router:n}=oy("useNavigate"),s=Gl("useNavigate"),i=f.useRef(!1);return uh(()=>{i.current=!0}),f.useCallback(async(c,d={})=>{en(i.current,ch),i.current&&(typeof c=="number"?await n.navigate(c):await n.navigate(c,{fromRouteId:s,...d}))},[n,s])}var af={};function hh(n,s,i){!s&&!af[n]&&(af[n]=!0,en(!1,i))}f.memo(hy);function hy({routes:n,manifest:s,future:i,state:o,isStatic:c,onError:d}){return dh(n,void 0,{manifest:s,state:o,isStatic:c,onError:d})}function In({to:n,replace:s,state:i,relative:o}){rt(Zr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:c,navigator:d}=f.useContext(Gt);en(!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:m}=f.useContext(un),{pathname:g}=Bt(),p=dn(),y=bi(n,Dl(m),g,o==="path");Wl(typeof n=="string"?n:jr(n),d.createHref(y),Ul(d),"reject");let v=JSON.stringify(y);return f.useEffect(()=>{p(JSON.parse(v),{replace:s,state:i,relative:o})},[p,v,o,s,i]),null}function my(n){return ey(n.context)}function Qe(n){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 py({basename:n="/",children:s=null,location:i,navigationType:o="POP",navigator:c,static:d=!1,useTransitions:m}){rt(!Zr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let g=n.replace(/^\/*/,"/"),p=f.useMemo(()=>({basename:g,navigator:c,static:d,useTransitions:m,future:{}}),[g,c,d,m]);typeof i=="string"&&(i=Qr(i));let{pathname:y="/",search:v="",hash:j="",state:w=null,key:N="default",mask:E}=i,k=f.useMemo(()=>{let C=An(y,g);return C==null?null:{location:{pathname:C,search:v,hash:j,state:w,key:N,mask:E},navigationType:o}},[g,y,v,j,w,N,o,E]);return en(k!=null,`<Router basename="${g}"> is not able to match the URL "${y}${v}${j}" because it does not start with the basename, so the <Router> won't render anything.`),k==null?null:f.createElement(Gt.Provider,{value:p},f.createElement(Ys.Provider,{children:s,value:k}))}function gy({children:n,location:s}){return ty(Cl(n),s)}function Cl(n,s=[]){let i=[];return f.Children.forEach(n,(o,c)=>{if(!f.isValidElement(o))return;let d=[...s,c];if(o.type===f.Fragment){i.push.apply(i,Cl(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 m={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&&(m.children=Cl(o.props.children,d)),i.push(m)}),i}var fi="get",hi="application/x-www-form-urlencoded";function Ci(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function yy(n){return Ci(n)&&n.tagName.toLowerCase()==="button"}function vy(n){return Ci(n)&&n.tagName.toLowerCase()==="form"}function xy(n){return Ci(n)&&n.tagName.toLowerCase()==="input"}function wy(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function jy(n,s){return n.button===0&&(!s||s==="_self")&&!wy(n)}function El(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((s,i)=>{let o=n[i];return s.concat(Array.isArray(o)?o.map(c=>[i,c]):[[i,o]])},[]))}function Sy(n,s){let i=El(n);return s&&s.forEach((o,c)=>{i.has(c)||s.getAll(c).forEach(d=>{i.append(c,d)})}),i}var ii=null;function ky(){if(ii===null)try{new FormData(document.createElement("form"),0),ii=!1}catch{ii=!0}return ii}var by=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function vl(n){return n!=null&&!by.has(n)?(en(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${hi}"`),null):n}function Ny(n,s){let i,o,c,d,m;if(vy(n)){let g=n.getAttribute("action");o=g?An(g,s):null,i=n.getAttribute("method")||fi,c=vl(n.getAttribute("enctype"))||hi,d=new FormData(n)}else if(yy(n)||xy(n)&&(n.type==="submit"||n.type==="image")){let g=n.form;if(g==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=n.getAttribute("formaction")||g.getAttribute("action");if(o=p?An(p,s):null,i=n.getAttribute("formmethod")||g.getAttribute("method")||fi,c=vl(n.getAttribute("formenctype"))||vl(g.getAttribute("enctype"))||hi,d=new FormData(g,n),!ky()){let{name:y,type:v,value:j}=n;if(v==="image"){let w=y?`${y}.`:"";d.append(`${w}x`,"0"),d.append(`${w}y`,"0")}else y&&d.append(y,j)}}else{if(Ci(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');i=fi,o=null,c=hi,m=n}return d&&c==="text/plain"&&(m=d,d=void 0),{action:o,method:i.toLowerCase(),encType:c,formData:d,body:m}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Kl(n,s){if(n===!1||n===null||typeof n>"u")throw new Error(s)}function mh(n,s,i,o){let c=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return i?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:s&&An(c.pathname,s)==="/"?c.pathname=`${Jr(s)}/_root.${o}`:c.pathname=`${Jr(c.pathname)}.${o}`,c}async function Cy(n,s){if(n.id in s)return s[n.id];try{let i=await import(n.module);return s[n.id]=i,i}catch(i){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(i),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Ey(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function Ty(n,s,i){let o=await Promise.all(n.map(async c=>{let d=s.routes[c.route.id];if(d){let m=await Cy(d,i);return m.links?m.links():[]}return[]}));return Py(o.flat(1).filter(Ey).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function of(n,s,i,o,c,d){let m=(p,y)=>i[y]?p.route.id!==i[y].route.id:!0,g=(p,y)=>{var v;return i[y].pathname!==p.pathname||((v=i[y].route.path)==null?void 0:v.endsWith("*"))&&i[y].params["*"]!==p.params["*"]};return d==="assets"?s.filter((p,y)=>m(p,y)||g(p,y)):d==="data"?s.filter((p,y)=>{var j;let v=o.routes[p.route.id];if(!v||!v.hasLoader)return!1;if(m(p,y)||g(p,y))return!0;if(p.route.shouldRevalidate){let w=p.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((j=i[0])==null?void 0:j.params)||{},nextUrl:new URL(n,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof w=="boolean")return w}return!0}):[]}function Ry(n,s,{includeHydrateFallback:i}={}){return Iy(n.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)),i&&c.hydrateFallbackModule&&(d=d.concat(c.hydrateFallbackModule)),c.imports&&(d=d.concat(c.imports)),d}).flat(1))}function Iy(n){return[...new Set(n)]}function Ay(n){let s={},i=Object.keys(n).sort();for(let o of i)s[o]=n[o];return s}function Py(n,s){let i=new Set;return new Set(s),n.reduce((o,c)=>{let d=JSON.stringify(Ay(c));return i.has(d)||(i.add(d),o.push({key:d,link:c})),o},[])}function Yl(){let n=f.useContext(Xr);return Kl(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function _y(){let n=f.useContext(Ni);return Kl(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var Jl=f.createContext(void 0);Jl.displayName="FrameworkContext";function Ei(){let n=f.useContext(Jl);return Kl(n,"You must render this element inside a <HydratedRouter> element"),n}function Ly(n,s){let i=f.useContext(Jl),[o,c]=f.useState(!1),[d,m]=f.useState(!1),{onFocus:g,onBlur:p,onMouseEnter:y,onMouseLeave:v,onTouchStart:j}=s,w=f.useRef(null);f.useEffect(()=>{if(n==="render"&&m(!0),n==="viewport"){let k=T=>{T.forEach(I=>{m(I.isIntersecting)})},C=new IntersectionObserver(k,{threshold:.5});return w.current&&C.observe(w.current),()=>{C.disconnect()}}},[n]),f.useEffect(()=>{if(o){let k=setTimeout(()=>{m(!0)},100);return()=>{clearTimeout(k)}}},[o]);let N=()=>{c(!0)},E=()=>{c(!1),m(!1)};return i?n!=="intent"?[d,w,{}]:[d,w,{onFocus:Os(g,N),onBlur:Os(p,E),onMouseEnter:Os(y,N),onMouseLeave:Os(v,E),onTouchStart:Os(j,N)}]:[!1,w,{}]}function Os(n,s){return i=>{n&&n(i),i.defaultPrevented||s(i)}}function $y({page:n,...s}){let i=Hg(),{nonce:o}=Ei(),{router:c}=Yl(),d=f.useMemo(()=>Qf(c.routes,n,c.basename),[c.routes,n,c.basename]);return d?(s.nonce==null&&o&&(s={...s,nonce:o}),i?f.createElement(Fy,{page:n,matches:d,...s}):f.createElement(Oy,{page:n,matches:d,...s})):null}function zy(n){let{manifest:s,routeModules:i}=Ei(),[o,c]=f.useState([]);return f.useEffect(()=>{let d=!1;return Ty(n,s,i).then(m=>{d||c(m)}),()=>{d=!0}},[n,s,i]),o}function Fy({page:n,matches:s,...i}){let o=Bt(),{future:c}=Ei(),{basename:d}=Yl(),m=f.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let g=mh(n,d,c.v8_trailingSlashAwareDataRequests,"rsc"),p=!1,y=[];for(let v of s)typeof v.route.shouldRevalidate=="function"?p=!0:y.push(v.route.id);return p&&y.length>0&&g.searchParams.set("_routes",y.join(",")),[g.pathname+g.search]},[d,c.v8_trailingSlashAwareDataRequests,n,o,s]);return f.createElement(f.Fragment,null,m.map(g=>f.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...i})))}function Oy({page:n,matches:s,...i}){let o=Bt(),{future:c,manifest:d,routeModules:m}=Ei(),{basename:g}=Yl(),{loaderData:p,matches:y}=_y(),v=f.useMemo(()=>of(n,s,y,d,o,"data"),[n,s,y,d,o]),j=f.useMemo(()=>of(n,s,y,d,o,"assets"),[n,s,y,d,o]),w=f.useMemo(()=>{if(n===o.pathname+o.search+o.hash)return[];let k=new Set,C=!1;if(s.forEach(I=>{var A;let $=d.routes[I.route.id];!$||!$.hasLoader||(!v.some(B=>B.route.id===I.route.id)&&I.route.id in p&&((A=m[I.route.id])!=null&&A.shouldRevalidate)||$.hasClientLoader?C=!0:k.add(I.route.id))}),k.size===0)return[];let T=mh(n,g,c.v8_trailingSlashAwareDataRequests,"data");return C&&k.size>0&&T.searchParams.set("_routes",s.filter(I=>k.has(I.route.id)).map(I=>I.route.id).join(",")),[T.pathname+T.search]},[g,c.v8_trailingSlashAwareDataRequests,p,o,d,v,s,n,m]),N=f.useMemo(()=>Ry(j,d),[j,d]),E=zy(j);return f.createElement(f.Fragment,null,w.map(k=>f.createElement("link",{key:k,rel:"prefetch",as:"fetch",href:k,...i})),N.map(k=>f.createElement("link",{key:k,rel:"modulepreload",href:k,...i})),E.map(({key:k,link:C})=>f.createElement("link",{key:k,nonce:i.nonce,...C,crossOrigin:C.crossOrigin??i.crossOrigin})))}function My(...n){return s=>{n.forEach(i=>{typeof i=="function"?i(s):i!=null&&(i.current=s)})}}var By=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{By&&(window.__reactRouterVersion="7.18.4")}catch{}function Dy({basename:n,children:s,useTransitions:i,window:o}){let c=f.useRef();c.current==null&&(c.current=pg({window:o,v5Compat:!0}));let d=c.current,[m,g]=f.useState({action:d.action,location:d.location}),p=f.useCallback(y=>{i===!1?g(y):f.startTransition(()=>g(y))},[i]);return f.useLayoutEffect(()=>d.listen(p),[d,p]),f.createElement(py,{basename:n,children:s,location:m.location,navigationType:m.action,navigator:d,useTransitions:i})}var yt=f.forwardRef(function({onClick:s,discover:i="render",prefetch:o="none",relative:c,reloadDocument:d,replace:m,mask:g,state:p,target:y,to:v,preventScrollReset:j,viewTransition:w,defaultShouldRevalidate:N,...E},k){let{basename:C,navigator:T,useTransitions:I}=f.useContext(Gt),$=typeof v=="string"&&Bl.test(v),A=sh(v,C);v=A.to;let B=Qg(v,{relative:c}),K=Bt(),V=null;if(g){let Z=bi(g,[],K.mask?K.mask.pathname:"/",!0);C!=="/"&&(Z.pathname=Z.pathname==="/"?C:cn([C,Z.pathname])),V=T.createHref(Z)}let[de,Y,re]=Ly(o,E),G=Hy(v,{replace:m,mask:g,state:p,target:y,preventScrollReset:j,relative:c,viewTransition:w,defaultShouldRevalidate:N,useTransitions:I});function D(Z){s&&s(Z),Z.defaultPrevented||G(Z)}let ie=!(A.isExternal||d),fe=f.createElement("a",{...E,...re,href:(ie?V:void 0)||A.absoluteURL||B,onClick:ie?D:s,ref:My(k,Y),target:y,"data-discover":!$&&i==="render"?"true":void 0});return de&&!$?f.createElement(f.Fragment,null,fe,f.createElement($y,{page:B})):fe});yt.displayName="Link";var ql=f.forwardRef(function({"aria-current":s="page",caseSensitive:i=!1,className:o="",end:c=!1,style:d,to:m,viewTransition:g,children:p,...y},v){let j=Js(m,{relative:y.relative}),w=Bt(),N=f.useContext(Ni),{navigator:E,basename:k}=f.useContext(Gt),C=N!=null&&Jy(j)&&g===!0,T=E.encodeLocation?E.encodeLocation(j).pathname:j.pathname,I=w.pathname,$=N&&N.navigation&&N.navigation.location?N.navigation.location.pathname:null;i||(I=I.toLowerCase(),$=$?$.toLowerCase():null,T=T.toLowerCase()),$&&k&&($=An($,k)||$);const A=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let B=I===T||!c&&I.startsWith(T)&&I.charAt(A)==="/",K=$!=null&&($===T||!c&&$.startsWith(T)&&$.charAt(T.length)==="/"),V={isActive:B,isPending:K,isTransitioning:C},de=B?s:void 0,Y;typeof o=="function"?Y=o(V):Y=[o,B?"active":null,K?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let re=typeof d=="function"?d(V):d;return f.createElement(yt,{...y,"aria-current":de,className:Y,ref:v,style:re,to:m,viewTransition:g},typeof p=="function"?p(V):p)});ql.displayName="NavLink";var Uy=f.forwardRef(({discover:n="render",fetcherKey:s,navigate:i,reloadDocument:o,replace:c,state:d,method:m=fi,action:g,onSubmit:p,relative:y,preventScrollReset:v,viewTransition:j,defaultShouldRevalidate:w,...N},E)=>{let{useTransitions:k}=f.useContext(Gt),C=Ky(),T=Yy(g,{relative:y}),I=m.toLowerCase()==="get"?"get":"post",$=typeof g=="string"&&Bl.test(g),A=B=>{if(p&&p(B),B.defaultPrevented)return;B.preventDefault();let K=B.nativeEvent.submitter,V=(K==null?void 0:K.getAttribute("formmethod"))||m,de=()=>C(K||B.currentTarget,{fetcherKey:s,method:V,navigate:i,replace:c,state:d,relative:y,preventScrollReset:v,viewTransition:j,defaultShouldRevalidate:w});k&&i!==!1?f.startTransition(()=>de()):de()};return f.createElement("form",{ref:E,method:I,action:T,onSubmit:o?p:A,...N,"data-discover":!$&&n==="render"?"true":void 0})});Uy.displayName="Form";function Wy(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ph(n){let s=f.useContext(Xr);return rt(s,Wy(n)),s}function Hy(n,{target:s,replace:i,mask:o,state:c,preventScrollReset:d,relative:m,viewTransition:g,defaultShouldRevalidate:p,useTransitions:y}={}){let v=dn(),j=Bt(),w=Js(n,{relative:m});return f.useCallback(N=>{if(jy(N,s)){N.preventDefault();let E=i!==void 0?i:jr(j)===jr(w),k=()=>v(n,{replace:E,mask:o,state:c,preventScrollReset:d,relative:m,viewTransition:g,defaultShouldRevalidate:p});y?f.startTransition(()=>k()):k()}},[j,v,w,i,o,c,s,n,d,m,g,p,y])}function Ql(n){en(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(El(n)),i=f.useRef(!1),o=Bt(),c=f.useMemo(()=>Sy(o.search,i.current?null:s.current),[o.search]),d=dn(),m=f.useCallback((g,p)=>{const y=El(typeof g=="function"?g(new URLSearchParams(c)):g);i.current=!0,d("?"+y,p)},[d,c]);return[c,m]}var Vy=0,Gy=()=>`__${String(++Vy)}__`;function Ky(){let{router:n}=ph("useSubmit"),{basename:s}=f.useContext(Gt),i=uy(),o=n.fetch,c=n.navigate;return f.useCallback(async(d,m={})=>{let{action:g,method:p,encType:y,formData:v,body:j}=Ny(d,s);if(m.navigate===!1){let w=m.fetcherKey||Gy();await o(w,i,m.action||g,{defaultShouldRevalidate:m.defaultShouldRevalidate,preventScrollReset:m.preventScrollReset,formData:v,body:j,formMethod:m.method||p,formEncType:m.encType||y,flushSync:m.flushSync})}else await c(m.action||g,{defaultShouldRevalidate:m.defaultShouldRevalidate,preventScrollReset:m.preventScrollReset,formData:v,body:j,formMethod:m.method||p,formEncType:m.encType||y,replace:m.replace,state:m.state,fromRouteId:i,flushSync:m.flushSync,viewTransition:m.viewTransition})},[o,c,s,i])}function Yy(n,{relative:s}={}){let{basename:i}=f.useContext(Gt),o=f.useContext(un);rt(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),d={...Js(n||".",{relative:s})},m=Bt();if(n==null){d.search=m.search;let g=new URLSearchParams(d.search),p=g.getAll("index");if(p.some(v=>v==="")){g.delete("index"),p.filter(j=>j).forEach(j=>g.append("index",j));let v=g.toString();d.search=v?`?${v}`:""}}return(!n||n===".")&&c.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),i!=="/"&&(d.pathname=d.pathname==="/"?i:cn([i,d.pathname])),jr(d)}function Jy(n,{relative:s}={}){let i=f.useContext(oh);rt(i!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=ph("useViewTransitionState"),c=Js(n,{relative:s});if(!i.isTransitioning)return!1;let d=An(i.currentLocation.pathname,o)||i.currentLocation.pathname,m=An(i.nextLocation.pathname,o)||i.nextLocation.pathname;return vi(c.pathname,m)!=null||vi(c.pathname,d)!=null}var qy=Jf();const xr="owner";function Qy(n){const s=n||xr;return s===xr?[xr]:[s,xr]}function Xy(n){const s=new Map;for(const i of n)for(const o of i)s.has(o.id)||s.set(o.id,o);return[...s.values()].sort((i,o)=>o.createdAt-i.createdAt)}function Zy(n,s){const i=s||xr,o=(n==null?void 0:n.pendingDomains)??[];return o.includes(i)?i:o.includes(xr)?xr:i}class gh extends Error{constructor(i){super("different_account");zs(this,"summary");this.name="DifferentAccountError",this.summary=i}}function De(n,s){const i=n??{},o=Array.isArray(i.errors)?i.errors[0]:void 0;return o!=null&&o.message?o.code?`${o.message} (${o.code})`:o.message:o!=null&&o.code?o.code:i.error||i.detail||s}function ev(n){const s=n==null?void 0:n.pubkeys;return!s||typeof s!="object"||Array.isArray(s)?[]:Object.entries(s).filter(i=>typeof i[1]=="string"&&i[1].length>0).map(([i,o])=>({userId:i,publicKey:o}))}class tv{constructor(){zs(this,"apiKey",null)}setApiKey(s){this.apiKey=s}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(s,i){return globalThis.fetch(s,{...i,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...i==null?void 0:i.headers}})}async login(s,i={}){const o=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":s,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:i.confirmWipe===!0})});if(o.status===409){const d=await o.json().catch(()=>({}));if(d!=null&&d.wouldWipe)throw new gh(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 i=await s.json();return i.groups??i}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 i=await this.fetch(`/api/profiles/${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to fetch profile: ${i.status}`);return i.json()}async attest(s){const i=await this.fetch("/api/as/mandate",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Signing failed: ${i.status}`))}return i.json()}async getPending(s){const i=await this.fetch(`/api/mandates/pending?domain=${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to fetch pending: ${i.status}`);const o=await i.json();return o.pending??o}async getMyAttestations(s){const i=s?`?status=${encodeURIComponent(s)}`:"",o=await this.fetch(`/api/mandates/mine${i}`);if(!o.ok)throw new Error(`Failed to fetch attestations: ${o.status}`);return((await o.json()).mandates??[]).map(d=>{var m,g;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:(m=d.attestations)!=null&&m.length?new Date(Math.min(...d.attestations.map(p=>p.expiresAt))*1e3).toISOString():null,remaining_seconds:(g=d.attestations)!=null&&g.length?Math.max(0,Math.min(...d.attestations.map(p=>p.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(s){const i=new URLSearchParams;s!=null&&s.since&&i.set("since",String(s.since)),s!=null&&s.limit&&i.set("limit",String(s.limit));const o=i.toString()?`?${i.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 i=new URLSearchParams;s!=null&&s.date&&i.set("date",s.date),s!=null&&s.profile&&i.set("profile",s.profile),s!=null&&s.limit&&i.set("limit",String(s.limit));const o=i.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"),i=await s.json();if(!s.ok)throw new Error(De(i,`Export failed (${s.status})`));const o=((c=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:c[1])??"suveren-evidence.json";return{bundle:i,filename:o}}async getLocalAuthorizations(){const s=await this.fetch("/api/evidence/authorizations");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const i=await s.json();return{authorizations:i.authorizations??{},signatures:i.signatures??{}}}async getArchivedReceipt(s){const i=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}`);if(i.status===404)return null;if(!i.ok)throw new Error(`Local evidence unavailable (${i.status})`);return await i.json()}async getReport(){const s=await this.fetch("/api/report");if(!s.ok){const i=await s.json().catch(()=>({error:`Report unavailable (${s.status})`}));throw new Error(De(i,`Report unavailable (${s.status})`))}return s.json()}async saveReport(s){const i=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:s})});if(!i.ok){const o=await i.json().catch(()=>({error:`Save failed (${i.status})`}));throw new Error(De(o,`Save failed (${i.status})`))}return i.json()}async recheckReport(){const s=await this.fetch("/api/report/recheck",{method:"POST"});if(!s.ok){const i=await s.json().catch(()=>({error:`Recheck failed (${s.status})`}));throw new Error(De(i,`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 i=await s.text(),o=((c=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:c[1])??"suveren-report.html";return{html:i,filename:o}}async revokeAttestation(s,i){const o=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/revoke`,{method:"POST",body:JSON.stringify({reason:i??"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 i=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to fetch attestations: ${i.status}`);const o=await i.json();return{...o,attestations:o.mandates??o.attestations??[]}}async getGroupById(s){const i=await this.fetch(`/api/groups/${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to fetch group: ${i.status}`);return i.json()}async createGroup(s){const i=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:s})});if(!i.ok){const d=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(De(d,`Create group failed: ${i.status}`))}const o=await i.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 i=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(De(i,`Failed to preview team creation: ${s.status}`))}return s.json()}async getJoinPreview(s){const i=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(s)}`);if(!i.ok){const o=await i.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(De(o,`Invalid invite code: ${i.status}`))}return i.json()}async requestToJoinGroup(s){const i=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:s})});if(i.status!==202){const c=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(De(c,`Request to join failed: ${i.status}`))}return(await i.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 i=await this.fetch(`/api/groups/${encodeURIComponent(s)}/invite`,{method:"POST"});if(!i.ok){const o=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(De(o,`Invite failed: ${i.status}`))}return i.json()}async getMyTeam(){const s=await this.fetch("/api/groups/me");if(!s.ok)return{group:null,membership:null,pendingRequest:null};const i=await s.json();return{group:i.group??null,membership:i.membership??null,pendingRequest:i.pendingRequest??null}}async listUsers(){const s=await this.fetch("/api/users");return s.ok?(await s.json()).users??[]:[]}async setPubkey(s){const i=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:s})});if(!i.ok){const o=await i.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(De(o,`setPubkey failed: ${i.status}`))}}async getPubkey(s){const i=await this.fetch(`/api/users/${encodeURIComponent(s)}/pubkey`);return i.status===404||!i.ok?null:(await i.json()).pubkey??null}async leaveTeam(s){const i=await this.fetch(`/api/groups/${encodeURIComponent(s)}/leave`,{method:"POST"});if(!i.ok){const o=await i.json().catch(()=>({error:"Failed to leave team"}));throw new Error(De(o,`Leave failed: ${i.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 i=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok)throw new Error(`Failed to save settings: ${i.status}`);return i.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,i){const o=await this.fetch(`/api/archived-mandates/${encodeURIComponent(s)}`,{method:i?"PUT":"DELETE"});if(!o.ok)throw new Error(`Failed to ${i?"archive":"unarchive"} mandate: ${o.status}`);return(await o.json()).archived}async getCredential(s){const i=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to check credential: ${i.status}`);return i.json()}async setCredential(s,i){const o=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`,{method:"PUT",body:JSON.stringify(i)});if(!o.ok)throw new Error(`Failed to save credential: ${o.status}`)}async testCredential(s){const i=await this.fetch(`/vault/test/${encodeURIComponent(s)}`,{method:"POST"});if(!i.ok)throw new Error(`Test failed: ${i.status}`);return i.json()}async aiAssist(s){const i=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:De(o,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return i.json()}async aiIntentReview(s){const i=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:De(o,"AI request failed")}}return i.json()}async aiTest(s){const i=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(s??{})});if(!i.ok)throw new Error(`AI test failed: ${i.status}`);return i.json()}async aiModels(s){const i=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(s??{})});if(!i.ok)throw new Error(`Model list failed: ${i.status}`);return i.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 i=await this.fetch(`/auth/oauth/${encodeURIComponent(s)}/health`);return i.ok?await i.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,i){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/discover/${encodeURIComponent(i)}`);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 i=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}/activate`,{method:"POST"});if(!i.ok){const o=await i.json().catch(()=>({error:"Failed"}));throw new Error(De(o,`Failed: ${i.status}`))}return i.json()}async removeMcpIntegration(s){const i=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}`,{method:"DELETE"});if(!i.ok)throw new Error(`Failed to remove integration: ${i.status}`)}async setReadPolicy(s,i){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:i})});if(!o.ok){const c=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(De(c,`HTTP ${o.status}`))}}async getTeamProfileConfig(s,i){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(i)}`);if(o.status===404||!o.ok)return null;const c=await o.json();return(c==null?void 0:c.config)??null}async setTeamProfileConfig(s,i,o){const c=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(i)}`,{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,i){const o=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:s,recipients:i})});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 i=await s.json();return(i==null?void 0:i.tools)??{}}async getApproversPubkeys(s,i){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(i)}/approvers/pubkeys`);return o.ok?ev(await o.json()):[]}async deleteTeamProfileConfig(s,i){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(i)}`,{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 i=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:s})});if(!i.ok)throw new Error(`Failed to save identity setting: ${i.status}`);return i.json()}async getProposals(s,i="pending"){const o=i==="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,i="pending"){const o=await Promise.all(Qy(s).map(c=>this.getProposals(c,i)));return Xy(o)}async resolveProposal(s,i,o,c){const{noteEncrypted:d,contentHash:m,note:g,...p}=c??{},y=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/resolve`,{method:"POST",body:JSON.stringify({action:i,domain:o,...p,...d?{note_encrypted:d}:g?{note:g}:{},...m?{content_hash:m}:{}})});if(!y.ok){const v=await y.json().catch(()=>({error:"Failed"}));throw new Error(De(v,`Failed: ${y.status}`))}return y.json()}async getProposal(s){const i=await this.fetch(`/api/proposals/${encodeURIComponent(s)}`);if(!i.ok){const c=await i.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`getProposal failed: ${i.status}`))}const o=await i.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,i){const o=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/approve`,{method:"POST",body:i?JSON.stringify({content_hash:i}):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,i,o){let c;if(typeof i=="string")c={reason:i};else{const{noteEncrypted:m,note:g,...p}=i??{};c={...p,...m?{note_encrypted:m}:g?{note:g}:{}}}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 m=await d.json().catch(()=>({error:"Failed"}));throw new Error(De(m,`rejectProposal failed: ${d.status}`))}return d.json()}async getProposalPreview(s){const i=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/preview`);if(!i.ok)throw new Error(`Failed to fetch preview: ${i.status}`);return i.json()}async getProposalOutcome(s){const i=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/outcome`);if(!i.ok)throw new Error(`Failed to fetch outcome: ${i.status}`);return i.json()}async getAttestationIntent(s){const i=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/intent`);return i.status===404||i.status===403||!i.ok?null:i.json()}async decryptIntent(s){const i=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const c=await i.json().catch(()=>({error:"Decryption failed"}));throw new Error(De(c,`decryptIntent failed: ${i.status}`))}return(await i.json()).intent}async decryptProposalContent(s){const i=await this.fetch("/api/decrypt-proposal-content",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"Decryption failed"}));throw new Error(De(o,`decryptProposalContent failed: ${i.status}`))}return i.json()}async encryptProposalNote(s,i){const o=await this.fetch("/api/encrypt-proposal-note",{method:"POST",body:JSON.stringify({note:s,recipientUserIds:i})});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,i){const o=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:s,intent:i})});if(!o.ok){const c=await o.json().catch(()=>({error:"Failed"}));throw new Error(De(c,`storeApprovedIntent failed: ${o.status}`))}}async listTeamAuthorizations(s){const i=await this.fetch(`/api/groups/${encodeURIComponent(s)}/mandates`);if(!i.ok)throw new Error(`Failed to fetch team authorizations: ${i.status}`);return((await i.json()).mandates??[]).map(c=>{var g,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(y=>!(c.attestedDomains??c.attested_domains??[]).includes(y)),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:(g=c.mandates)!=null&&g.length?new Date(Math.min(...c.mandates.map(y=>y.expiresAt))*1e3).toISOString():null,remaining_seconds:(p=c.mandates)!=null&&p.length?Math.max(0,Math.min(...c.mandates.map(y=>y.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:d}})}async listTeamReceipts(s){const i=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets`);if(!i.ok)throw new Error(`Failed to fetch team receipts: ${i.status}`);return(await i.json()).tickets??[]}async getMyReceiptsPage(s){const i=new URLSearchParams;s!=null&&s.before&&i.set("before",s.before),s!=null&&s.profile&&i.set("profile",s.profile),s!=null&&s.limit&&i.set("limit",String(s.limit));const o=i.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,i){const o=new URLSearchParams;i!=null&&i.before&&o.set("before",i.before),i!=null&&i.profile&&o.set("profile",i.profile),i!=null&&i.limit&&o.set("limit",String(i.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 m=await d.json();return{receipts:m.tickets??[],nextBefore:m.nextBefore??null}}async getThread(s){const i=s.sinceDays??7,o=s.status??"pending",c=await this.getMyProposals(s.domain,o);let d=[];if(o==="all"){const m=[],g=new Date;for(let y=0;y<i;y++){const v=new Date(g);v.setUTCDate(g.getUTCDate()-y),m.push(v.toISOString().slice(0,10))}d=(await Promise.all(m.map(y=>this.getMyReceipts({date:y,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 i=await this.fetch("/autostart",{method:s?"POST":"DELETE"});if(!i.ok){const o=await i.json().catch(()=>({}));throw new Error(o.message||`HTTP ${i.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 i=await this.fetch(`/gate-content?path=${encodeURIComponent(s)}`);if(!i.ok)throw new Error(`Failed to fetch gate content: ${i.status}`);return(await i.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 i=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(De(o,`Push gate content failed: ${i.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 i=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:s})});if(!i.ok){const o=await i.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(De(o,`Save failed: ${i.status}`))}}async aiChat(s){const i=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(s)});if(!i.ok){const o=await i.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:De(o,`Chat failed: ${i.status}`)}}return i.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,i){const o=await this.fetch(`/ai-prompts/${s}`,{method:"PUT",body:JSON.stringify({value:i})});if(!o.ok){const c=await o.json().catch(()=>({error:"Save failed"}));throw new Error(De(c,`Save failed: ${o.status}`))}}}const M=new tv,yh=f.createContext(null);function nv({children:n}){const[s,i]=f.useState(null),[o,c]=f.useState("personal"),[d,m]=f.useState(null),[g,p]=f.useState(""),[y,v]=f.useState(null),[j,w]=f.useState(null),[N,E]=f.useState(null),[k,C]=f.useState(!1),[T,I]=f.useState(""),$=f.useRef(!1),A=f.useRef(null),B=f.useCallback(async()=>{if($.current)try{const G=await M.getMyTeam();if(E(G.pendingRequest),G.group&&G.membership){const{group:D,membership:ie}=G;v(D),w(ie),c("team"),m(D);const fe=A.current??ie.domains[0]??"owner";p(fe)}else v(null),w(null),c("personal")}catch{}},[]);f.useEffect(()=>{const G=()=>{document.visibilityState==="visible"&&B()};return document.addEventListener("visibilitychange",G),()=>document.removeEventListener("visibilitychange",G)},[B]),f.useEffect(()=>{fetch("/health").then(G=>G.json()).then(G=>{var D;((D=G.session)==null?void 0:D.lockedReason)==="as-url-changed"&&I(`Authority Server changed to ${G.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const K=f.useCallback(async(G,D={})=>{C(!0),I("");try{M.setApiKey(G),$.current=!0;const ie=await M.login(G,D);i(ie),A.current=ie.id;const fe=await M.getGroups(),Z=fe.find(pe=>pe.isPersonal)??fe[0]??null;m(Z),p("owner"),await B()}catch(ie){throw M.clearApiKey(),$.current=!1,I(ie instanceof Error?ie.message:"Login failed"),ie}finally{C(!1)}},[B]),V=f.useCallback(async()=>{await M.logout(),M.clearApiKey(),$.current=!1,A.current=null,i(null),m(null),p(""),v(null),w(null),E(null),c("personal"),I("")},[]),de=f.useCallback(G=>{M.clearApiKey(),$.current=!1,A.current=null,i(null),m(null),p(""),v(null),w(null),E(null),c("personal"),I(G??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),Y=f.useCallback(()=>I(""),[]),re=f.useCallback((G,D)=>{m(G),p(D)},[]);return r.jsx(yh.Provider,{value:{user:s,mode:o,group:d,domain:g,groupId:(d==null?void 0:d.id)??null,activeTeam:y,activeMembership:j,pendingRequest:N,isLoading:k,error:T,login:K,logout:V,clearError:Y,handleSessionLocked:de,activeGroup:d,activeDomain:g,groups:d?[d]:[],setActiveContext:re,refreshGroups:B},children:n})}function vt(){const n=f.useContext(yh);if(!n)throw new Error("useAuth must be used within AuthProvider");return n}const vh=f.createContext(null);function rv({children:n}){const{user:s}=vt(),i=f.useRef(null),[o,c]=f.useState(!1),d=f.useRef(new Map),m=f.useCallback((g,p)=>{const y=d.current;return y.has(g)||y.set(g,new Set),y.get(g).add(p),()=>{var v;(v=y.get(g))==null||v.delete(p)}},[]);return f.useEffect(()=>{if(!s){i.current&&(i.current.close(),i.current=null,c(!1));return}if(i.current)return;const g=M.getApiKey();if(!g)return;const p=new EventSource(`/events?key=${encodeURIComponent(g)}`);i.current=p,p.onopen=()=>c(!0),p.onerror=()=>c(!1);const y=["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 y)p.addEventListener(v,j=>{let w;try{w=JSON.parse(j.data)}catch{w=null}const N=d.current.get(v);if(N)for(const E of N)try{E(w)}catch(k){console.error(`[EventSource] handler for "${v}" threw:`,k)}});return()=>{p.close(),i.current=null,c(!1)}},[s]),r.jsx(vh.Provider,{value:{connected:o,addListener:m},children:n})}function He(n,s){const i=f.useContext(vh);if(!i)return;const{addListener:o}=i;f.useEffect(()=>o(n,s),[n,s,o])}const Hs="suveren-theme",lf="hap-theme";function oi(n){return n!=="system"?n:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(lf);s!==null&&localStorage.getItem(Hs)===null&&localStorage.setItem(Hs,s),s!==null&&localStorage.removeItem(lf)})();function xh(){const[n,s]=f.useState(()=>{const d=localStorage.getItem(Hs);return d==="light"||d==="dark"?d:"system"}),[i,o]=f.useState(()=>oi(n));f.useEffect(()=>{const d=document.documentElement,m=oi(n);d.setAttribute("data-theme",m),n==="system"?localStorage.removeItem(Hs):localStorage.setItem(Hs,n),o(oi(n))},[n]),f.useEffect(()=>{if(n!=="system")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),m=()=>o(oi("system"));return d.addEventListener("change",m),()=>d.removeEventListener("change",m)},[n]);const c=f.useCallback(()=>{s(d=>d==="system"?"light":d==="light"?"dark":"system")},[]);return{theme:n,effectiveTheme:i,toggle:c}}const sv=300*1e3,av=2e3;function Xl(){const[n,s]=f.useState(!1),[i,o]=f.useState("docker"),[c,d]=f.useState(""),[m,g]=f.useState(null),[p,y]=f.useState(!1),[v,j]=f.useState(!1),[w,N]=f.useState(!1),E=f.useRef(null);return f.useEffect(()=>{let k=!1;const C=($=!1)=>{fetch($?"/health?refresh=1":"/health").then(A=>A.json()).then(A=>{k||(A.installMethod&&o(A.installMethod),typeof A.latestVersion<"u"&&g(A.latestVersion),A.updateAvailable&&s(!0),A.version&&(d(A.version),E.current===null?E.current=A.version:A.version!==E.current&&A.version!=="dev"&&y(!0)))}).catch(()=>{})};C(!0);const T=setInterval(()=>C(!1),w?av:sv),I=()=>{document.visibilityState==="visible"&&C(!1)};return document.addEventListener("visibilitychange",I),window.addEventListener("focus",I),()=>{k=!0,clearInterval(T),document.removeEventListener("visibilitychange",I),window.removeEventListener("focus",I)}},[w]),{updateAvailable:n&&!v,installMethod:i,version:c,latestVersion:m,serverRestarted:p,startFastPolling:()=>N(!0),dismiss:()=>j(!0)}}function iv(n){return!n||typeof n!="object"?{managed:!1}:{managed:Array.isArray(n.policyLocked)&&n.policyLocked.includes("team")}}function ov(){const[n,s]=f.useState({managed:!1});return f.useEffect(()=>{let i=!1;return fetch("/health").then(o=>o.json()).then(o=>{i||s(iv(o))}).catch(()=>{}),()=>{i=!0}},[]),n}function lv({size:n=20}){return r.jsxs("svg",{width:n,height:n,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 cv(n){return n?n==="dev"?"dev":/^[0-9a-f]{40}$/i.test(n)?n.slice(0,7):n:""}const cf={system:"◑",light:"☀",dark:"☾"};function Zl({onMenuToggle:n}){const{user:s,logout:i,mode:o,activeTeam:c}=vt(),{theme:d,toggle:m}=xh(),{version:g,updateAvailable:p,latestVersion:y}=Xl(),{managed:v}=ov(),j=cv(g),w=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(lv,{size:20}),r.jsx("span",{className:"logo",children:"Suveren"}),r.jsx("span",{className:"version-badge",children:"Local Gateway"}),j&&r.jsxs("span",{className:"gw-version",title:p&&y?`Running v${j} — v${y} is available`:"Running gateway version","data-stale":p?"true":void 0,children:["v",j,p&&y?` → ${y}`:""]})]}),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?`${w} — set by your IT`:w,children:[w,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:m,title:`Theme: ${d}`,children:cf[d]}),r.jsx("button",{className:"nav-logout",onClick:i,children:"Logout"})]}):r.jsx("button",{className:"theme-toggle",onClick:m,title:`Theme: ${d}`,children:cf[d]})}),s&&n&&r.jsx("button",{className:"mobile-menu-btn",onClick:n,"aria-label":"Menu",children:"☰"})]})})}function ec(n,s){var i;if((i=s==null?void 0:s.revokedSet)!=null&&i.has(n.authorization_id))return"revoked";switch(n.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return n.remaining_seconds===null||n.remaining_seconds<=0?"expired":n.missing_domains.length>0?"pending":"active"}function wh(n){return n==="expired"||n==="revoked"}function jh(n,s){var i;return!!((i=s==null?void 0:s.archivedSet)!=null&&i.has(n.authorization_id))&&wh(ec(n,s))}function xi(n,s){return jh(n,s)?"archived":ec(n,s)}function Sh(n,s){const i={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of n)i[xi(o,s)].push(o);return i}function uv(n,s){return s==="expired"?n.earliest_expiry?{iso:n.earliest_expiry,meaning:"expired"}:null:n.created_at?{iso:n.created_at,meaning:"created"}:null}function Zt(n,s,i){const o=f.useRef(n);o.current=n,f.useEffect(()=>{let c=null;const d=()=>typeof document>"u"?!0:document.visibilityState==="visible",m=()=>{d()&&o.current()},g=()=>{c===null&&(c=setInterval(m,s))},p=()=>{c!==null&&(clearInterval(c),c=null)},y=()=>{d()?(o.current(),g()):p()};return d()&&(o.current(),g()),document.addEventListener("visibilitychange",y),()=>{p(),document.removeEventListener("visibilitychange",y)}},[s,i])}function tc(){const[n,s]=f.useState(!1);return f.useEffect(()=>{let i=!1;const o=()=>{fetch("/health").then(m=>m.json()).then(m=>{i||s(m.simulation===!0)}).catch(()=>{})};o();const c=setInterval(o,3e4),d=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",d),()=>{i=!0,clearInterval(c),document.removeEventListener("visibilitychange",d)}},[]),n}function dv(n,s){const i=n.simulation;return i?(((s==null?void 0:s[i.field])??"").trim().toLowerCase()||i.default.trim().toLowerCase())==="simulation":!1}function Vs(n){return!!(n!=null&&n.simulation)}const kh=f.createContext(null),fv=3e4,hv=5e3,mv=3e5;function pv(n,s,i){return s===0?"loading":n!=null&&n.running?"running":n!=null&&n.paused?"paused":n!=null&&n.error?"error":n&&i?"starting":"not-running"}function gv({children:n}){const[s,i]=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[j,w]=await Promise.all([M.getIntegrationManifests().catch(()=>(v=!0,{manifests:[]})),M.getMcpHealth().catch(()=>null)]);i(E=>({...E,manifests:j.manifests,integrations:(w==null?void 0:w.integrations)??E.integrations,activeSessions:(w==null?void 0:w.activeSessions)??E.activeSessions,mcpServerUp:!!w,manifestsError:v,fetchCount:E.fetchCount+1}));const N=j.manifests.filter(E=>E.oauth);if(N.length>0){const E=await Promise.all(N.map(async k=>[k.id,await M.getOAuthHealth(k.id)]));i(k=>({...k,authHealth:Object.fromEntries(E)}))}},[]),d=s.fetchCount>0&&s.manifests.some(v=>{const j=s.integrations.find(w=>w.id===v.id);return j&&!j.running&&!j.paused});He("integration-changed",c),Zt(c,d?hv:mv);const m=f.useMemo(()=>{const v=new Map(s.integrations.map(N=>[N.id,N])),j=Date.now();d&&o.current===null?o.current=j:d||(o.current=null);const w=o.current!==null&&j-o.current<fv;return s.manifests.map(N=>{const E=v.get(N.id),k=pv(E,s.fetchCount,w),C=s.authHealth[N.id];return{id:N.id,manifest:N,integration:E,state:k,authStatus:C==null?void 0:C.status,authAccount:C==null?void 0:C.account,authError:C==null?void 0:C.error}})},[s,d]),g=tc(),p=f.useMemo(()=>m.filter(v=>!(g&&!Vs(v.manifest))&&(v.state==="not-running"||v.state==="error"||v.authStatus==="failed")).length,[m,g]),y={loading:s.fetchCount===0,mcpServerUp:s.mcpServerUp,manifestsError:s.manifestsError,entries:m,attentionCount:p,activeSessions:s.activeSessions,refresh:c};return r.jsx(kh.Provider,{value:y,children:n})}function nc(){const n=f.useContext(kh);if(!n)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return n}const yv={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},rc=n=>yv[n]??n,vv={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 xv(n){return(n&&vv[n])??{chip:"Blocked",sev:"info"}}function wv(n){const s=rc(n.integrationId);switch(n.reason){case"resource":return n.integrationId==="calendar"?r.jsxs(r.Fragment,{children:["Tried to read your ",r.jsx("b",{children:n.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:n.detail})}}function bh(n,s){const i=Math.max(0,(s-n)/1e3);if(i<60)return"Just now";if(i<3600)return`${Math.floor(i/60)} min ago`;if(i<86400)return`${Math.floor(i/3600)} hr ago`;const o=Math.floor(i/86400);return o===1?"Yesterday":`${o} days ago`}const uf=5,jv=1440*60*1e3,mi=7;function Sv(n,s){const i=s-mi*jv;return{recent:n.filter(o=>o.ts>=i),all:n}}function kv(){const[n,s]=f.useState(null),[i,o]=f.useState(!1),[c,d]=f.useState(!1),m=f.useCallback(()=>{M.getDenials({limit:200}).then(({records:w})=>{s(w),d(!1)}).catch(()=>d(!0))},[]);if(f.useEffect(()=>{m()},[m]),Zt(m,12e4),c||n===null)return null;const{recent:g,all:p}=Sv(n,Date.now()),y=i?p:g.slice(0,uf),v=p.length-g.length,j=(w,N)=>{const E=xv(w.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:wv(w)}),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:rc(w.integrationId)})]}),E.fixTo&&r.jsx(yt,{className:"rb-fix",to:E.fixTo,children:"Set a read window →"})]}),r.jsx("div",{className:"rb-when",children:bh(w.ts,Date.now())})]},`${w.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"}),(i?p.length:g.length)>0&&r.jsx("span",{className:"rb-count",children:i?p.length:g.length})]}),y.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 ",mi," 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:[i?"Last 30 days. ":`Last ${mi} 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:y.map(j)}),!i&&p.length>y.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"]})}),i&&p.length>Math.min(g.length,uf)&&r.jsx("div",{className:"rb-foot",children:r.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>o(!1),children:["Show only the last ",mi," days"]})})]})]})}function Gs(n){return n.kind??"read"}function bv(n,s){var d,m,g,p;if(!s)return"";if(!n)return s;const i=(m=(d=n.scopeSchema)==null?void 0:d.fields)==null?void 0:m[s];if(i!=null&&i.displayName)return i.displayName;const o=((g=n.boundsSchema)==null?void 0:g.fields)??{};if((p=o[s])!=null&&p.displayName)return o[s].displayName;const c=Object.values(o).find(y=>y.boundType&&"of"in y.boundType&&y.boundType.of===s);return c!=null&&c.displayName?c.displayName:s}const Nv={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"},Cv={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 df(n){return n===void 0?"":typeof n=="number"?n.toLocaleString():n}function Ev(n,s){const i=Gs(n),o=df(n.value),c=df(n.limit);switch(i){case"bound":return o&&c?`${s||"Value"} ${o} is above the limit ${c}.`:n.detail;case"scope":return o?`${s||"Value"} "${o}" is not within your mandate's allowed ${s||"scope"}.`:n.detail;case"cumulative":return o&&c?`${o} of ${c} used — the limit is reached.`:n.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 n.detail}}function Tv(n){const s=Gs(n),i=rc(n.integrationId),o=n.mandateTitle?` · mandate "${n.mandateTitle}"`:n.mandateId?` · mandate ${n.mandateId.slice(0,14)}…`:"",c=n.who==="authority-server"?"refused by the Authority Server":s==="read"?"refused by this gateway":"refused by this gateway, before anything ran",d=n.code?` (${n.code})`:"";return`${i} · ${n.tool}${o} · ${c}${d}`}function Rv(n,s){const i=Gs(n),o=bv(s,n.field);return{title:Nv[i],sentence:Ev(n,o),sourceLine:Tv(n),whatYouCanDo:Cv[i]}}function Nh(n,s){const i=new Date(s);return i.setHours(0,0,0,0),n.filter(o=>o.ts>=i.getTime()).length}const Iv=[{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 Av(){const{activeDomain:n}=vt(),[s,i]=f.useState({}),o=f.useCallback(async()=>{try{const[c,d,m,g,p,y,v]=await Promise.all([M.getCredential("ai-config").catch(()=>null),M.getMyAttestations().catch(()=>null),M.getMyProposals(n).catch(()=>null),M.getProposalsForApprover().catch(()=>null),M.getAgentContext().catch(()=>""),M.getArchivedMandates().catch(()=>[]),M.getDenials({limit:200}).catch(()=>null)]),j={};if(c&&!c.configured&&(j.assistant=1),d){const k=Sh(d,{archivedSet:new Set(y)}).expired.length;k>0&&(j.authorizations=k)}const w=(m==null?void 0:m.length)??0,N=(g==null?void 0:g.length)??0,E=w+N;if(E>0&&(j.proposals=E),(!p||!p.trim())&&(j.brief=1),v){const k=Nh(v.records,Date.now());k>0&&(j.blocked=k)}i(j)}catch{}},[n]);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]),Zt(o,3e5,n),s}const Pv={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},_v={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 Lv(){const{mode:n,group:s,domain:i,activeTeam:o}=vt(),c=Av(),{attentionCount:d}=nc(),m={...c};d>0&&(m.integrations=d);const g=Iv.filter(w=>!w.teamOnly||n==="team"),p=f.useRef(null),[y,v]=f.useState(null),j=Bt();return f.useEffect(()=>{if(p.current===null){p.current=n;return}p.current!==n&&(n==="team"&&o?v(`You are now acting in team context — ${o.name}`):n==="personal"&&v("You have left the team — back to personal context"),p.current=n)},[n,o]),f.useEffect(()=>{v(null)},[j.pathname]),r.jsxs("div",{className:"sidebar",children:[r.jsx("ul",{className:"sidebar-nav",children:g.map(w=>{const N=w.statusKey?m[w.statusKey]:0;return r.jsx("li",{children:r.jsxs(ql,{to:w.to,end:w.to==="/",className:({isActive:E})=>`sidebar-item${E?" active":""}`,children:[r.jsx("span",{className:"icon",children:w.icon}),w.label,N?r.jsx("span",{style:Pv,children:N}):null]})},w.to)})}),r.jsxs("div",{className:"sidebar-context",children:[r.jsx("div",{className:"ctx-label",children:"Active context"}),r.jsx("div",{className:"ctx-value",children:n==="personal"?"personal":s?`${s.name} / ${i}`:i})]}),y&&r.jsx("div",{style:_v,role:"status","aria-live":"polite",children:y})]})}const xl="suveren:updatedTo";function $v(n){return n==="managed"||n==="msi"?null:n==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":n==="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 zv="Updates for this gateway come from your company's IT — no action needed here.";function Fv(n){return n==="managed"?"update-banner is-managed":"update-banner"}const Ov="Download the new installer and run it. Your settings and mandates stay.";function Mv(n){const s="https://github.com/suverenai/suveren-gateway/releases";return n?`${s}/tag/v${n}`:`${s}/latest`}function Bv(){const n=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const i of n)if(!i.closest(".update-overlay"))return!0;const s=document.activeElement;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)){const i=s.value;if(i&&i.trim())return!0}return!1}function Ch(){const{updateAvailable:n,installMethod:s,version:i,latestVersion:o,serverRestarted:c,startFastPolling:d,dismiss:m}=Xl(),[g,p]=f.useState(!1),[y,v]=f.useState(!1),[j,w]=f.useState(()=>{try{const $=sessionStorage.getItem(xl);if($)return sessionStorage.removeItem(xl),$}catch{}return null}),N=$v(s),E=f.useRef(null),k=$=>{try{sessionStorage.setItem(xl,$||o||"✓")}catch{}window.location.reload()};f.useEffect(()=>{if(!j)return;const $=setTimeout(()=>w(null),6e3);return()=>clearTimeout($)},[j]),f.useEffect(()=>{if(!g||!c)return;const $=()=>Bv()?!1:(k(i),!0);if($())return;const A=setInterval($,1500);return()=>clearInterval(A)},[g,c,i]),f.useEffect(()=>(document.body.classList.toggle("is-updating",g),()=>document.body.classList.remove("is-updating")),[g]);const C=n&&!g&&!j||!!j&&!g;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 $=()=>{var K;const B=((K=E.current)==null?void 0:K.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${B}px`)};$();const A=new ResizeObserver($);return E.current&&A.observe(E.current),()=>{A.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[C]);const T=()=>{p(!0),d()},I=async()=>{if(N)try{await navigator.clipboard.writeText(N),v(!0),setTimeout(()=>v(!1),1800)}catch{}};return r.jsxs(r.Fragment,{children:[j&&!g&&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",j&&j!=="✓"?` — ${j} is live`:" — now live","."]}),r.jsx("button",{className:"update-banner-x",onClick:()=>w(null),"aria-label":"Dismiss",children:"×"})]})}),n&&!g&&!j&&r.jsxs("div",{ref:E,className:Fv(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:Mv(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:m,"aria-label":"Dismiss",children:"×"})]})]}),s==="managed"&&r.jsx("p",{className:"update-banner-hint",children:zv}),s==="msi"&&r.jsx("p",{className:"update-banner-hint",children:Ov})]}),g&&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:I,children:y?"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:()=>k(i),children:"Reload now"}),r.jsx("button",{className:"btn btn-secondary",onClick:()=>p(!1),children:"Cancel"})]})]})})]})}function Eh(){const n=tc(),s=f.useRef(null);return f.useEffect(()=>{if(!n){document.documentElement.style.removeProperty("--sim-banner-h");return}const i=()=>{var d;const c=((d=s.current)==null?void 0:d.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${c}px`)};i();const o=new ResizeObserver(i);return s.current&&o.observe(s.current),()=>{o.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[n]),n?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 Dv={system:"◑",light:"☀",dark:"☾"},Uv=[{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 Wv({open:n,onClose:s}){const{user:i,activeGroup:o,activeDomain:c,logout:d}=vt(),{theme:m,toggle:g}=xh(),p=Bt();return f.useEffect(()=>{s()},[p.pathname]),n?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"mobile-menu-backdrop",onClick:s}),r.jsxs("div",{className:"mobile-menu-panel",children:[i&&r.jsxs("div",{className:"mobile-menu-header",children:[r.jsx("strong",{children:i.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:Uv.map(y=>r.jsxs(ql,{to:y.to,end:y.to==="/",className:({isActive:v})=>`mobile-menu-item${v?" active":""}`,onClick:s,children:[r.jsx("span",{className:"icon",children:y.icon}),y.label]},y.to))}),r.jsxs("div",{className:"mobile-menu-footer",children:[r.jsxs("button",{className:"mobile-menu-action",onClick:()=>{g()},children:[r.jsx("span",{className:"icon",children:Dv[m]}),"Theme: ",m]}),r.jsx("button",{className:"mobile-menu-action",onClick:()=>{d(),s()},children:"Logout"})]})]})]}):null}function Th(n){return n.status==="pending"}function Hv(n,s){return n.filter(Th).length+s.length}const gr=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],Vv=500;function Rh(){const{user:n,domain:s}=vt(),[i,o]=f.useState(0),c=f.useRef(null),d=f.useCallback(async()=>{if(!n){o(0);return}try{const[g,p]=await Promise.all([M.getMyProposals(s).catch(()=>[]),M.getProposalsForApprover().catch(()=>[])]);o(Hv(g,p))}catch{o(0)}},[n,s]),m=f.useCallback(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d()},Vv)},[d]);return f.useEffect(()=>(d(),()=>{c.current&&clearTimeout(c.current)}),[d]),He(gr[0],m),He(gr[1],m),He(gr[2],m),He(gr[3],m),He(gr[4],m),He(gr[5],m),He(gr[6],m),i}const ff="Suveren",Gv="/favicon.svg",Kv="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",li={x1:74.54,y1:22.74,x2:94.46,y2:34.24},Yv=14,Jv="#f59e0b";function qv(n){const s=sc(n);return s>0?`(${s}) ${ff}`:ff}function sc(n){return Number.isFinite(n)&&n>0?Math.floor(n):0}function Qv(){const n=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
52
+ <path class="m" d="${Kv}"/>
53
+ <line class="m" x1="${li.x1}" y1="${li.y1}" x2="${li.x2}" y2="${li.y2}"/>
54
+ <circle cx="103" cy="103" r="25" fill="${Jv}"/>
55
+ <style>.m{stroke:#111111;stroke-width:${Yv};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(n)}`}function Xv(){return document.querySelector('link[rel="icon"]')}function Ih(n){const s=sc(n);document.title=qv(s),Ah(s);const i=Xv();if(!i)return;const o=s>0?Qv():Gv;i.getAttribute("href")!==o&&i.setAttribute("href",o)}function Zv(){Ih(0)}function Ah(n,s=globalThis.navigator){var c;if(!s||typeof s.setAppBadge!="function")return;const i=sc(n),o=i>0?s.setAppBadge(i):s.clearAppBadge?s.clearAppBadge():s.setAppBadge(0);(c=o==null?void 0:o.catch)==null||c.call(o,()=>{})}function ex(){const n=Rh();return f.useEffect(()=>{Ih(n)},[n]),f.useEffect(()=>Zv,[]),null}const Ph="suveren:dockBadgePrompt";function tx(){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(Ph))return!1}catch{}return!0}function nx(){const[n,s]=f.useState(!1),i=Rh();if(f.useEffect(()=>{s(tx())},[]),!n)return null;const o=()=>{try{localStorage.setItem(Ph,"1")}catch{}s(!1)},c=async()=>{try{await Notification.requestPermission()==="granted"&&Ah(i)}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 rx(){const[n,s]=f.useState(!1);return r.jsxs(gv,{children:[r.jsx(ex,{}),r.jsx(Zl,{onMenuToggle:()=>s(!n)}),r.jsx(Ch,{}),r.jsx(Eh,{}),r.jsx(Lv,{}),r.jsx(Wv,{open:n,onClose:()=>s(!1)}),r.jsx("div",{className:"main-content",children:r.jsxs("div",{className:"page-inner",children:[r.jsx(nx,{}),r.jsx(my,{})]})})]})}function _h({what:n}){return r.jsxs("div",{className:"human-only-note",role:"note",children:[r.jsx("strong",{children:"Only you."})," ",n==="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 ac(){return typeof navigator<"u"&&navigator.webdriver===!0}const ic="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function sx(){const[n,s]=f.useState(""),{login:i,isLoading:o,error:c,clearError:d}=vt(),[m,g]=f.useState(null),p=ac(),y=async()=>{if(!(!n.trim()||p)){d();try{await i(n)}catch(w){if(w instanceof gh){g(w.summary);return}}}},v=async()=>{g(null),d();try{await i(n,{confirmWipe:!0})}catch{}},j=()=>{g(null)};return r.jsxs(r.Fragment,{children:[r.jsx(Zl,{}),r.jsx(Ch,{}),r.jsx(Eh,{}),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(_h,{what:"sign-in"}),p&&r.jsx("div",{className:"error-message",children:ic}),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:n,onChange:w=>s(w.target.value),onKeyDown:w=>w.key==="Enter"&&y(),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:y,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((w,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,"."]}),w]},N))})]})]})})]}),m&&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:j,children:r.jsxs("div",{className:"card",onClick:w=>w.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:[m.credentialCount," stored service credential",m.credentialCount===1?"":"s",m.credentialIds.length>0&&r.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",m.credentialIds.slice(0,5).join(", "),m.credentialIds.length>5?`, +${m.credentialIds.length-5} more`:"",")"]})]}),r.jsxs("li",{children:[m.serviceCount," configured integration",m.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:j,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 ax(n,s){return!s&&n!=null}function ix(n,s){return n==="join-waiting"&&s==="team"}function ox(n,s,i,o){return i!=null||n!=="join-waiting"||s==="team"?null:o}function lx(n){return`${n} personal mandate${n===1?"":"s"}`}function cx({mandates:n,pendingProposals:s}){return n.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:n.map(i=>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:i.title||i.profileId}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:i.commitmentMode??""})]},i.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 ux(){const{mode:n,pendingRequest:s,refreshGroups:i}=vt(),o=dn(),[c,d]=f.useState("choose"),[m,g]=f.useState(""),[p,y]=f.useState(""),[v,j]=f.useState(null),[w,N]=f.useState(null),[E,k]=f.useState(""),[C,T]=f.useState(""),[I,$]=f.useState(!1),A=f.useRef(!1);f.useEffect(()=>{ax(s,A.current)&&(A.current=!0,d("join-waiting"))},[s]),f.useEffect(()=>{ix(c,n)&&o("/")},[c,n,o]);const B=f.useRef(null);f.useEffect(()=>{if(s){B.current=s.groupName;return}const D=ox(c,n,s,B.current);D&&(k(D),d("join-declined"),B.current=null)},[s,c,n]),f.useEffect(()=>{if(c!=="join-waiting")return;const D=setInterval(()=>{i()},5e3);return()=>clearInterval(D)},[c,i]);const K=f.useCallback(()=>{d("choose"),T(""),j(null),N(null),g(""),y("")},[]),V=async()=>{if(m.trim()){$(!0),T("");try{const D=await M.getJoinPreview(m.trim());j(D),d("join-preview")}catch(D){T(D instanceof Error?D.message:"Invalid or expired invite code")}finally{$(!1)}}},de=async()=>{$(!0),T("");try{await M.requestToJoinGroup(m.trim()),await i(),d("join-waiting")}catch(D){T(D instanceof Error?D.message:"Failed to join group")}finally{$(!1)}},Y=async()=>{$(!0),T("");try{await M.withdrawJoinRequest(),await i(),K()}catch(D){T(D instanceof Error?D.message:"Failed to withdraw request")}finally{$(!1)}},re=async()=>{d("create"),T(""),$(!0);try{const D=await M.getCreatePreview();N(D)}catch(D){T(D instanceof Error?D.message:"Failed to load preview")}finally{$(!1)}},G=async()=>{if(p.trim()){$(!0),T("");try{await M.createGroup(p.trim()),await i(),o("/")}catch(D){T(D instanceof Error?D.message:"Failed to create group")}finally{$(!1)}}};return r.jsxs(r.Fragment,{children:[r.jsx(Zl,{}),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:m,onChange:D=>g(D.target.value),onKeyDown:D=>D.key==="Enter"&&V(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:I}),r.jsx("button",{className:"btn btn-primary",onClick:V,disabled:I||!m.trim(),children:I?"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:I,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(cx,{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:de,disabled:I,children:I?"Asking…":"Ask to join"}),r.jsx("button",{className:"btn btn-ghost",onClick:K,disabled:I,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:I,children:I?"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:K,disabled:I,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:D=>y(D.target.value),onKeyDown:D=>D.key==="Enter"&&G(),disabled:I,autoFocus:!0})]}),w&&r.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",lx(w.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:G,disabled:I||!p.trim(),children:I?"Creating…":"Create team and move my account"}),r.jsx("button",{className:"btn btn-ghost",onClick:K,disabled:I,children:"Cancel"})]})]})]})})]})}const hf={"claude-code":{label:"Claude Code",snippet:n=>`claude mcp add --transport http suveren ${n}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:n=>`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",`${n}/mcp`,"--allow-http"]}}},null,2)}`},"chatgpt-codex":{label:"ChatGPT / Codex",snippet:n=>`Add to ~/.codex/config.toml:
59
+
60
+ [mcp_servers.suveren]
61
+ url = "${n}/mcp"
62
+
63
+ Or: codex mcp add suveren --url ${n}/mcp`},other:{label:"Other",snippet:n=>`Streamable HTTP: POST ${n}/mcp
64
+ SSE transport: GET ${n}/sse
65
+ Health check: GET ${n}/health`}},mf=["claude-code","claude-desktop","chatgpt-codex","other"];function Tl({mcpEndpoint:n}){const[s,i]=f.useState(mf[0]),[o,c]=f.useState(!1),d=f.useCallback(async g=>{try{await navigator.clipboard.writeText(g),c(!0),setTimeout(()=>c(!1),2e3)}catch{}},[]),m=hf[s].snippet(n);return r.jsxs("div",{children:[r.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),r.jsx("div",{className:"mcp-endpoint",children:n}),r.jsx("div",{className:"mcp-tabs",children:mf.map(g=>r.jsx("button",{className:`mcp-tab${s===g?" active":""}`,onClick:()=>i(g),children:hf[g].label},g))}),r.jsx("pre",{className:"mcp-snippet",children:m}),r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>d(m),children:o?"Copied":"Copy"})]})}const Rl="suveren-setup-ai-skipped",Il="suveren-setup-agent-done",Al="suveren-setup-dismissed",dx={"hap-setup-ai-skipped":Rl,"hap-setup-agent-done":Il,"hap-setup-dismissed":Al};function fx(){for(const[n,s]of Object.entries(dx)){const i=localStorage.getItem(n);i!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,i),i!==null&&localStorage.removeItem(n)}}fx();function hx({aiConfigured:n,hasRunningIntegration:s,hasActiveAuth:i,hasAgentConnected:o,mcpEndpoint:c}){const[d,m]=f.useState(()=>localStorage.getItem(Rl)==="true"),[g,p]=f.useState(()=>localStorage.getItem(Il)==="true"),[y,v]=f.useState(()=>localStorage.getItem(Al)==="true"),[j,w]=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:n?"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:i?"done":"pending"},{label:"Connect your agent",status:o||g?"done":"pending"}],E=N.filter(A=>A.status==="done"||A.status==="skipped").length,k=E===N.length,C=f.useCallback(()=>{localStorage.setItem(Rl,"true"),m(!0)},[]),T=f.useCallback(()=>{localStorage.setItem(Il,"true"),p(!0),w(null)},[]),I=f.useCallback(()=>{localStorage.setItem(Al,"true"),v(!0)},[]);if(y||k)return null;const $=N.findIndex(A=>A.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:I,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:N.map((A,B)=>{const K=B===$,V=A.status==="done"||A.status==="skipped"?"●":"○",de=A.status==="done"?"var(--success)":A.status==="skipped"?"var(--text-tertiary)":K?"var(--accent)":"var(--text-tertiary)";return r.jsxs("div",{children:[r.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:K?"0.75rem":"0.25rem 0",borderRadius:K?"0.5rem":void 0,background:K?"var(--accent-subtle)":void 0},children:[r.jsx("span",{style:{color:de,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:V}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[A.to&&A.status==="pending"?r.jsx(yt,{to:A.to,style:{fontSize:"0.9rem",fontWeight:K?600:500,color:K?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:A.label}):A.status==="pending"&&B===3?r.jsx("button",{onClick:()=>w(j===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:K?600:500,color:K?"var(--accent)":"var(--text-primary)"},children:A.label}):r.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:A.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:A.label}),A.optional&&A.status==="pending"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),A.status==="skipped"&&r.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),A.detail&&A.status==="pending"&&K&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:A.detail})]}),A.optional&&A.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"}),A.to&&A.status==="pending"&&r.jsx(yt,{to:A.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),B===3&&j===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(Tl,{mcpEndpoint:c}),r.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:T,children:"Done"})]})]},B)})}),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 Lh(n,s=null){const i=[n.hasContact,n.hasDelegationMandate,n.delegationProposalCount>0],o=i.every(Boolean),c=n.otherMandateCount===0&&!o,d=i.findIndex(y=>!y),m=s!==null&&i[s]===!1?s:d,g=n.managed?"managed":"self",p=y=>i[y]?{status:"done"}:y!==m?{status:"todo"}:y===1?{status:"open",variant:g,simulationOn:n.simulationOn}:y===0?{status:"open",variant:g}:{status:"open"};return{visible:c,step1:p(0),step2:p(1),step3:p(2)}}const mx="/mandates?new=1&profile=delegation";function pf({text:n}){const[s,i]=f.useState(!1),o=f.useCallback(async()=>{try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),2e3)}catch{}},[n]);return r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:o,children:s?"Copied":"Copy"})}function wl({todo:n,onOpen:s,children:i}){return n?r.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:s,children:i}):r.jsx("span",{className:"flow-step-title",children:i})}function px({contact:n,hasDelegationMandate:s,otherMandateCount:i,delegationProposalCount:o,managed:c,simulationOn:d,mcpEndpoint:m}){const g={hasContact:n!==null,hasDelegationMandate:s,otherMandateCount:i,delegationProposalCount:o,managed:c,simulationOn:d},[p,y]=f.useState(null),v=Lh(g,p);if(!v.visible)return null;const j=`Please connect to the Suveren gateway: MCP server at ${m}/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"&&n?r.jsxs("span",{className:"flow-step-title flow-done-title",children:[n.clientName," connected · last contact ",bh(Date.parse(n.lastSeenAt),Date.now()).toLowerCase()]}):r.jsx(wl,{todo:v.step1.status==="todo",onOpen:()=>y(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(Tl,{mcpEndpoint:m})})]})]}):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:j}),r.jsx(pf,{text:j})]})}),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(Tl,{mcpEndpoint:m})})]})]})})]}),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(wl,{todo:v.step2.status==="todo",onOpen:()=>y(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:mx,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(wl,{todo:v.step3.status==="todo",onOpen:()=>y(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(pf,{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 gx(){const[n,s]=f.useState(null);return f.useEffect(()=>{let i=!1;return fetch("/health").then(o=>o.json()).then(o=>{!i&&typeof o.mcpPort=="number"&&s(`http://localhost:${o.mcpPort}`)}).catch(()=>{}),()=>{i=!0}},[]),n}function yx(n){if(!n||typeof n!="object")return{simulation:null,locked:!1};const s=Array.isArray(n.policyLocked)&&n.policyLocked.includes("simulation");return{simulation:typeof n.simulation=="boolean"?n.simulation:null,locked:s}}function $h(){const[n,s]=f.useState({simulation:null,locked:!1});return f.useEffect(()=>{let i=!1;return fetch("/health").then(o=>o.json()).then(o=>{i||s(yx(o))}).catch(()=>{}),()=>{i=!0}},[]),n}function vx(n){return!n||typeof n!="object"?!1:Array.isArray(n.policyLocked)&&n.policyLocked.length>0}function xx(){const[n,s]=f.useState(!1);return f.useEffect(()=>{let i=!1;const o=()=>{fetch("/health").then(m=>m.json()).then(m=>{i||s(vx(m))}).catch(()=>{})};o();const c=setInterval(o,3e4),d=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",d),()=>{i=!0,clearInterval(c),document.removeEventListener("visibilitychange",d)}},[]),n}function wr({variant:n="base",style:s,className:i,...o}){const c=n==="title"?"skeleton skeleton-title":n==="line"?"skeleton skeleton-line":n==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return r.jsx("span",{className:`${c}${i?` ${i}`:""}`,style:s,role:"status","aria-busy":"true","aria-label":o["aria-label"]??"Loading"})}function jl(){return r.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[r.jsx(wr,{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(wr,{variant:"line",style:{width:"35%"}}),r.jsx(wr,{variant:"line-sm",style:{width:"65%"}})]})]})}function wx(){const[n,s]=f.useState([]);return Zt(async()=>{try{const{skipped:o}=await M.getSkippedCommitments();s(o)}catch{}},3e4),n.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 (",n.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:n.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 jx(n,s){return s&&!Vs(n.manifest)}function Sx(n,s=!1){var o;const i=[];for(const c of n)jx(c,s)||(c.state==="error"?i.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"&&(Vs(c.manifest)?i.push({label:`${c.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--danger)"}):i.push({label:"Integration stopped",detail:`${c.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"})));return i}function kx(n){const s=n.filter(i=>i.state==="paused");return s.length===0?null:{count:s.length,namesText:s.map(i=>i.manifest.name).join(", ")}}const bx=1800;function Gr(n){return n.replace(/@.*$/,"").split("/").pop()??n}function Nx(){const{domain:n}=vt(),[s,i]=f.useState([]),[o,c]=f.useState([]),[d,m]=f.useState([]),[g,p]=f.useState(!0),[y,v]=f.useState(!1),[j,w]=f.useState([]),[N,E]=f.useState(!1),[k,C]=f.useState(!1),[T,I]=f.useState(null),[$,A]=f.useState(!1),{entries:B,activeSessions:K,loading:V}=nc(),de=gx(),Y=!V,{simulation:re}=$h(),G=re===!0,D=xx(),ie=f.useCallback(()=>{M.getMyAttestations().then(se=>{i(se),v(!0)}).catch(()=>v(!0)),M.getArchivedMandates().then(w).catch(()=>w([])),M.getMyProposals(n).then(se=>{c(se),E(!0)}).catch(()=>E(!0)),M.getProposalsForApprover().then(se=>m(se)).catch(()=>m([])),M.getCredential("ai-config").then(se=>{p(se.configured),C(!0)}).catch(()=>C(!0)),M.getAgentContact().then(se=>{I(se.contact),A(!0)}).catch(()=>A(!0))},[n]);He("attestation-changed",ie),He("proposal-added",ie),He("proposal-resolved",ie),He("proposal-approved",ie),He("proposal-rejected",ie),Zt(ie,3e5,n);const fe=y&&N&&k&&Y&&$&&re!==null,Z=Sh(s,{archivedSet:new Set(j)}),pe=Z.active,ee=Z.expired,W=pe.some(se=>Gr(se.profile_id)==="delegation"),O=pe.filter(se=>Gr(se.profile_id)!=="delegation").length,H=o.filter(se=>Gr(se.profileId)==="delegation").length,S=Lh({hasContact:T!==null,hasDelegationMandate:W,otherMandateCount:O,delegationProposalCount:H,managed:D,simulationOn:G}),_=G&&S.visible,J=pe.filter(se=>se.remaining_seconds!==null&&se.remaining_seconds<=bx),te=o.filter(Th),ce=B.filter(se=>se.state==="running"),ve=B.filter(se=>se.state==="starting"),Ce=kx(B),ke=[];for(const se of d)ke.push({label:"Approval needed",detail:`${se.tool} — above-cap action under ${Gr(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 J){const $e=Math.ceil((se.remaining_seconds??0)/60);ke.push({label:"Expiring soon",detail:`${se.title??Gr(se.profile_id)} — ${$e} min remaining`,to:"/mandates",color:"var(--warning)"})}for(const se of ee)ke.push({label:"Expired",detail:se.title??Gr(se.profile_id),to:"/mandates",color:"var(--danger)"});ke.push(...Sx(B,G));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 B)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 g||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"})}),fe&&de&&(_?r.jsx(px,{contact:T,hasDelegationMandate:W,otherMandateCount:O,delegationProposalCount:H,managed:D,simulationOn:G,mcpEndpoint:de}):!G&&r.jsx(hx,{aiConfigured:g,hasRunningIntegration:ce.length>0,hasActiveAuth:pe.length>0,hasAgentConnected:K>0,mcpEndpoint:de})),!_&&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:[y?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:pe.length>0?"var(--success)":"var(--text-tertiary)"},children:pe.length}):r.jsx(wr,{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(wr,{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:[y?r.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:ee.length>0?"var(--danger)":"var(--text-tertiary)"},children:ee.length}):r.jsx(wr,{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:ce.length>0?"var(--success)":"var(--text-tertiary)"},children:ce.length}):r.jsx(wr,{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,$e)=>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:"›"})]},$e))}):fe?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(jl,{}),r.jsx(jl,{}),r.jsx(jl,{})]})]})]}),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(wx,{}),r.jsx(kv,{})]})}const Cx=["Scope & Limits","Intent","Sign"];function zh({currentStep:n,onStepClick:s}){const i=dn();return r.jsxs("div",{className:"wizard-progress",children:[r.jsx("ol",{className:"wizard-steps",children:Cx.map((o,c)=>{const d=c+2,m=d<n,g=d===n,p=d-1<n,y=m&&!!s;return r.jsxs("li",{className:`wizard-step${p?" reached":""}`,"aria-current":g?"step":void 0,children:[r.jsx("button",{type:"button",className:`step-circle${m?" completed":""}${g?" current":""}`,onClick:y?()=>s(d):void 0,disabled:!y,"aria-label":`${o}${m?" (done)":g?" (current)":""}`,children:m?"✓":c+1}),r.jsx("span",{className:`step-label-text${g?" current":m?" completed":""}`,children:o})]},d)})}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>i("/mandates?new=1"),children:"Cancel"})]})}const gf=40,Ex={delegation:"Delegation"};function dt(n,s){const i=n.lastIndexOf("/"),o=i>=0?n.slice(i+1):n,c=o.indexOf("@"),d=c>=0?o.slice(0,c):o,m=Ex[d.toLowerCase()];return m||(s?s.slice(0,gf):(d.charAt(0).toUpperCase()+d.slice(1)).slice(0,gf))}function Tx({profileId:n,bounds:s,groupName:i,domain:o,onSwitch:c}){return r.jsxs("div",{className:"context-strip",children:[i&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"context-strip-label",children:"Team:"}),r.jsxs("span",{children:[r.jsx("strong",{children:i}),o?` / ${o}`:""]})]}),n&&r.jsxs("span",{children:[r.jsx("strong",{children:"Profile:"})," ",dt(n)]}),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 Rx({integrationId:n,field:s,value:i,onChange:o,disabled:c,onLabels:d}){const[m,g]=f.useState(null),[p,y]=f.useState(null),[v,j]=f.useState(!0);f.useEffect(()=>{let E=!1;return M.discoverScopeField(n,s).then(k=>{var C;E||(g(k.options),j(!1),(C=k.options)!=null&&C.length&&(d==null||d(Object.fromEntries(k.options.map(T=>[T.value,T.label])))))}).catch(k=>{E||(y(k instanceof Error?k.message:String(k)),j(!1))}),()=>{E=!0}},[n,s]);const w=new Set(i.split(",").map(E=>E.trim()).filter(Boolean)),N=E=>{const k=new Set(w);k.has(E)?k.delete(E):k.add(E),o(Array.from(k).join(","))};return v?r.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",n,"…"]}):p||!m?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:i,onChange:E=>o(E.target.value),disabled:c})]}):m.length===0?r.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",n," for this field."]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:m.map(E=>{const k=E.extras??{},C=typeof k.access=="string"?k.access:void 0,T=C==="reader",I=k.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:w.has(String(E.value)),onChange:()=>N(String(E.value)),disabled:c||T}),r.jsx("span",{children:E.label||E.value}),I&&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 oc(n){if(n.type!=="number")return 0;const s=n.boundType,i=n.unit;return(s==null?void 0:s.kind)==="per_transaction"&&i==="count"?1:0}function Ix(n,s){if(s!==void 0)return String(s);const i=n.default;return typeof i=="string"||typeof i=="number"&&Number.isFinite(i)?String(i):oc(n)===1?"1":""}function Fh(n){const s=n.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function yf(n,s){const i=oc(n),o=Fh(n),c=s===""?i:Math.max(i,Number(s));return o!==void 0?Math.min(o,c):c}function lc(n){return!n||n==="count"?"":n==="minutes"?"min":n==="hours"?"hr":n==="days"?"days":n==="percent"?"%":n.startsWith("currency:")?n.slice(9):n}function Ax(n){return n.replace(/@.*$/,"").split("/").pop()??n}function Px(n,s){return s.displayName?s.displayName:n.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function _x(n){return n.type==="string"&&(n.format==="email"||n.format==="domain")}function Lx(n){var i;const s=n;return!!(s.enum&&((i=s.constraint)!=null&&i.enforceable.includes("subset")))}function vf(n,s){const i=n.trim();return i?s==="email"?i.includes("@")&&i.indexOf(".",i.indexOf("@"))>-1:s==="domain"?i.includes(".")&&!i.includes("@"):!0:!1}function $x(n){return n?n==="minutes"?15:n==="percent"?5:n.startsWith("currency:")?10:1:1}function zx(n){return n?n==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:n==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:n==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:n==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:n.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function Fx(n,s){if(!n||!s)return"";const i=Number(n);if(!Number.isFinite(i)||i<=0)return"";if(s==="minutes"&&i>=60){const o=Math.floor(i/60),c=i%60;return c===0?`${o} hour${o!==1?"s":""}`:`${o}h ${c}m`}if(s==="hours"&&i>=24&&i%24===0){const o=i/24;return`${o} day${o!==1?"s":""}`}if(s==="days"){if(i>=30&&i%30===0)return`${i/30} month${i/30!==1?"s":""}`;if(i>=7&&i%7===0)return`${i/7} week${i/7!==1?"s":""}`}return""}function Ox({id:n,value:s,onChange:i,disabled:o,placeholder:c,unit:d,min:m=0,max:g}){const p=$x(d),y=zx(d).filter(k=>g===void 0||k.value<=g),v=lc(d),j=Fx(s,d),w=s===""?null:Number(s),N=()=>{const k=s===""?0:Number(s),C=k%p,T=C===0?k+p:k+(p-C);i(String(g!==void 0?Math.min(g,T):T))},E=()=>{const k=s===""?0:Number(s);if(k<=m)return;const C=k%p,T=C===0?k-p:k-C;i(String(Math.max(m,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)<=m,"aria-label":"Decrease",children:"−"}),r.jsx("input",{id:n,className:"stepper-input",type:"number",min:m,max:g,step:p,value:s,placeholder:c??String(m),onChange:k=>{const C=k.target.value;i(g!==void 0&&C!==""&&Number(C)>g?String(g):C)},onFocus:k=>k.target.select(),disabled:o}),r.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:N,disabled:o||g!==void 0&&s!==""&&Number(s)>=g,"aria-label":"Increase",children:"+"}),v&&r.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:v})]}),y.length>0&&!o&&r.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:y.map(k=>r.jsx("button",{type:"button",className:`preset-chip${w===k.value?" preset-chip-selected":""}`,onClick:()=>i(String(k.value)),children:k.label},k.value))}),j&&r.jsxs("div",{className:"bounded-input-echo",children:["≈ ",j]})]})}function xf({htmlFor:n,label:s,description:i}){const[o,c]=f.useState(!1);return r.jsxs("div",{className:"field-label-with-tip",children:[r.jsx("label",{className:"form-label",htmlFor:n,children:s}),i&&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:i})]})]})}function Mx({id:n,value:s,onChange:i,disabled:o,format:c,placeholder:d}){const[m,g]=f.useState(""),[p,y]=f.useState(!1),v=f.useRef(null),j=s?s.split(",").map(T=>T.trim()).filter(Boolean):[],w=T=>{const I=T.trim();if(!I)return;if(!vf(I,c)){y(!0);return}y(!1);const $=j.includes(I)?j:[...j,I];i($.join(",")),g("")},N=T=>{const I=j.filter(($,A)=>A!==T);i(I.join(","))},E=T=>{T.key==="Enter"||T.key===","||T.key==="Tab"?m.trim()&&(T.preventDefault(),w(m)):T.key==="Backspace"&&!m&&j.length>0&&N(j.length-1)},k=T=>{const I=T.clipboardData.getData("text");if(I.includes(",")){T.preventDefault();const A=I.split(",").map(K=>K.trim()).filter(Boolean).filter(K=>vf(K,c)),B=[...new Set([...j,...A])];i(B.join(",")),g(""),y(!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:[j.map((T,I)=>r.jsxs("span",{className:"tag-pill",children:[T,!o&&r.jsx("button",{type:"button",className:"tag-remove",onClick:$=>{$.stopPropagation(),N(I)},"aria-label":`Remove ${T}`,children:"×"})]},T)),!o&&r.jsx("input",{ref:v,id:n,className:"tag-input-field",type:"text",value:m,onChange:T=>{g(T.target.value),y(!1)},onKeyDown:E,onPaste:k,onBlur:()=>{m.trim()&&w(m)},placeholder:j.length===0?d??C:""})]})}function Bx({id:n,options:s,value:i,onChange:o,disabled:c}){const d=i?i.split(",").map(g=>g.trim()).filter(Boolean):[],m=g=>{const p=d.includes(g)?d.filter(y=>y!==g):[...d,g];o(p.join(","))};return r.jsx("div",{className:"checkbox-group",id:n,children:s.map(g=>r.jsxs("label",{className:`checkbox-pill${d.includes(g)?" checkbox-pill-selected":""}`,children:[r.jsx("input",{type:"checkbox",checked:d.includes(g),onChange:()=>m(g),disabled:c}),r.jsx("span",{children:g})]},g))})}function wf({fieldKey:n,fieldDef:s,value:i,onChange:o,prefix:c,readOnly:d,twoColumn:m,discoveryIntegrationId:g,onLabels:p}){const y=Px(n,s),v=`${c}-field-${n}`,j=r.jsx(r.Fragment,{children:Lx(s)?r.jsx(Bx,{id:v,options:s.enum,value:i,onChange:w=>o(n,w),disabled:d}):(()=>{const w=s.boundType;return(w==null?void 0:w.kind)==="enum"&&Array.isArray(w.values)})()?r.jsxs("select",{id:v,className:"form-select",value:i,onChange:w=>o(n,w.target.value),disabled:d,children:[r.jsx("option",{value:"",children:"Select..."}),s.boundType.values.map(w=>r.jsx("option",{value:w,children:w},w))]}):s.enum?r.jsxs("select",{id:v,className:"form-select",value:i,onChange:w=>o(n,w.target.value),disabled:d,children:[r.jsx("option",{value:"",children:"Select..."}),s.enum.map(w=>r.jsx("option",{value:w,children:w},w))]}):s.type==="number"?r.jsx(Ox,{id:v,value:i,onChange:w=>o(n,w),disabled:d,unit:s.unit,min:oc(s),max:Fh(s)}):_x(s)?r.jsx(Mx,{id:v,value:i,onChange:w=>o(n,w),disabled:d,format:s.format}):g?r.jsx(Rx,{integrationId:g,field:n,value:i,onChange:w=>o(n,w),disabled:d,onLabels:w=>p==null?void 0:p(n,w)}):r.jsx("input",{id:v,className:"form-input",type:"text",value:i,onChange:w=>o(n,w.target.value),disabled:d})});return m?r.jsxs("div",{className:"bounds-field-row",children:[r.jsx("div",{className:"bounds-field-label",children:r.jsx(xf,{htmlFor:v,label:y,description:s.description})}),r.jsx("div",{className:"bounds-field-input",children:j})]},`${c}-${n}`):r.jsxs("div",{className:"form-group",children:[r.jsx(xf,{htmlFor:v,label:y,description:s.description}),j]},`${c}-${n}`)}function Dx(n,s){if(!s)return"no-config";const i=s.caps,o=Array.isArray(s.approvers)&&s.approvers.length>0;if(!(i&&Object.keys(i).length>0))return o?"approvers-dormant":"no-config";let d=!1;for(const[m,g]of Object.entries(i)){const p=n[m];if(p===""||p===void 0)continue;const y=Number(p);if(!isNaN(y)&&y>g){d=!0;break}}return d?o?"above-approvers":"hard-ceiling":"within-cap"}function Ux(n,s){const i=new Set;if(!s)return i;for(const[o,c]of Object.entries(s)){const d=n[o];if(d===""||d===void 0)continue;const m=Number(d);!isNaN(m)&&m>c&&i.add(o)}return i}function Wx({profile:n,onConfirm:s,onCancel:i,readOnly:o,initialBounds:c,initialContext:d,initialFrame:m,profileConfig:g,approverNames:p,adminName:y}){const v=n.boundsSchema,j=n.scopeSchema,w=v?Object.entries(v.fields).filter(([S,_])=>!(S==="profile"||S==="path"||_.enforced===!1||_.enforcedBy==="gatekeeper")):[],N=v?Object.entries(v.fields).filter(([,S])=>S.enforcedBy==="gatekeeper").filter(([,S])=>S.enforced!==!1).map(([S,_])=>_.displayName??S):[],E=j&&j.keyOrder.length>0?Object.entries(j.fields):[],k=c??m??{},C=d??{},T={};for(const[S,_]of w)T[S]=Ix(_,k[S]);const I={};for(const[S]of E)I[S]=C[S]!==void 0?String(C[S]):"";const[$,A]=f.useState(T),[B,K]=f.useState(I),[V,de]=f.useState({}),[Y,re]=f.useState(null);f.useEffect(()=>{const S=Ax(n.id);M.getIntegrationManifests().then(({manifests:_})=>{const J=_.find(te=>te.profile===S&&te.contextDiscovery&&Object.keys(te.contextDiscovery).length>0);re(J??null)}).catch(()=>re(null))},[n.id]);const G=Dx($,g),D=Ux($,g==null?void 0:g.caps),ie=(S,_)=>{A(J=>({...J,[S]:_}))},fe=(S,_)=>{K(J=>({...J,[S]:_}))},Z=()=>{const S={profile:n.id};for(const[J,te]of w)te.type==="number"?S[J]=yf(te,$[J]):S[J]=$[J];const _={};for(const[J,te]of E)te.type==="number"?_[J]=B[J]===""?0:Number(B[J]):_[J]=B[J];return[S,_]},pe=()=>{const[S,_]=Z();s(S,_,V)},ee=()=>{const S=(g==null?void 0:g.caps)??{},_={...$};for(const ce of D)S[ce]!==void 0&&(_[ce]=String(S[ce]));A(_);const J={profile:n.id};for(const[ce,ve]of w)ve.type==="number"?J[ce]=yf(ve,_[ce]??""):J[ce]=_[ce]??"";const te={};for(const[ce,ve]of E)ve.type==="number"?te[ce]=B[ce]===""?0:Number(B[ce]):te[ce]=B[ce];s(J,te,V)},W=S=>{const _=g==null?void 0:g.caps;if(!_||_[S]===void 0)return null;const J=_[S],te=D.has(S);return G==="hard-ceiling"&&te?r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",J," — exceeds team ceiling"]}):G==="above-approvers"&&te?r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",J," — above cap"]}):r.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",J," ok"]})},O=()=>{var S;if(G==="no-config")return null;if(G==="approvers-dormant"){const _=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: ",_]}),r.jsxs("div",{children:["No caps are set on this profile, so ",_," won't gate any action under this mandate. Your intent will still be encrypted and shared with them as an accountability record — they can read what you authorised, even though they aren't reviewing individual actions."]})]})}if(G==="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(G==="above-approvers"){const _=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 ",_,". Within-cap actions run per the mode you choose."]})]})}if(G==="hard-ceiling"){const _=Array.from(D)[0],J=_?(S=g==null?void 0:g.caps)==null?void 0:S[_]:void 0,te=y??"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 ",J??"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"}),i&&r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:i,children:"Cancel"})]})]})}return null},H=G==="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(([S,_])=>{var te;const J=!!((te=Y==null?void 0:Y.contextDiscovery)!=null&&te[S]);return r.jsx(wf,{fieldKey:S,fieldDef:_,value:B[S],onChange:fe,prefix:"context",readOnly:o,discoveryIntegrationId:J?Y.id:void 0,onLabels:(ce,ve)=>de(Ce=>({...Ce,[ce]:ve}))},`context-${S}`)})]}),w.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:w.map(([S,_])=>{var J;return r.jsxs("div",{style:{display:"contents"},children:[r.jsx(wf,{fieldKey:S,fieldDef:_,value:$[S],onChange:ie,prefix:"bounds",readOnly:o,twoColumn:!0}),G!=="no-config"&&((J=g==null?void 0:g.caps)==null?void 0:J[S])!==void 0&&r.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:W(S)})]},`bounds-${S}`)})}),O(),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:H,style:{marginTop:"0.5rem"},children:o?"Next: Gates":"Next: Problem Statement"})]})}function Hx(n){var i;const s=n.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((i=s==null?void 0:s[1])==null?void 0:i.trim())??null}function Vx(n){return n.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Gx="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 wi({target:n,currentText:s,onApply:i,greeting:o,placeholder:c,title:d}){const[m,g]=f.useState([{role:"assistant",content:o??Gx}]),[p,y]=f.useState(""),[v,j]=f.useState(!1),[w,N]=f.useState(null),E=f.useRef(null),k=f.useRef(null);f.useEffect(()=>{const I=E.current;if(!I)return;const $=m[m.length-1],A=k.current;!v&&($==null?void 0:$.role)==="assistant"&&m.length>1&&A?I.scrollTop=A.offsetTop:I.scrollTop=I.scrollHeight},[m,v]);const C=async()=>{const I=p.trim();if(!I||v)return;const $=[...m,{role:"user",content:I}];g($),y(""),N(null),j(!0);try{const A=await M.aiChat({target:n,currentText:s,messages:$.filter((B,K)=>!(K===0&&B.role==="assistant"))});A.success&&A.reply?g(B=>[...B,{role:"assistant",content:A.reply}]):N(A.error??"AI returned no reply")}catch(A){N(A instanceof Error?A.message:"Chat failed")}finally{j(!1)}},T=I=>{I.key==="Enter"&&!I.shiftKey&&!I.nativeEvent.isComposing&&(I.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:[m.map((I,$)=>{const A=I.role==="assistant"?Hx(I.content):null,B=A?Vx(I.content):I.content;return r.jsx("div",{className:`chat-msg ${I.role}`,ref:$===m.length-1?k:void 0,children:r.jsxs("div",{className:"chat-msg-body",children:[B&&r.jsx("div",{className:"chat-msg-prose",children:B}),A!==null&&r.jsxs(r.Fragment,{children:[r.jsx("pre",{className:"chat-fenced-block",children:A}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>i(A),children:"Apply this draft"})]})]})},$)}),v&&r.jsx("div",{className:"chat-msg assistant",children:r.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),w&&r.jsx("div",{className:"error-message",children:w}),r.jsxs("div",{className:"chat-composer",children:[r.jsxs("div",{className:"chat-composer-pill",children:[r.jsx("textarea",{className:"chat-input",value:p,onChange:I=>y(I.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 Oh({open:n,onClose:s,children:i,ariaLabel:o}){const c=f.useRef(null),d=f.useRef(null);return f.useEffect(()=>{var g;if(!n)return;d.current=document.activeElement,document.body.style.overflow="hidden";const m=p=>{p.key==="Escape"&&s()};return document.addEventListener("keydown",m),(g=c.current)==null||g.focus(),()=>{document.removeEventListener("keydown",m),document.body.style.overflow="",d.current instanceof HTMLElement&&d.current.focus()}},[n,s]),qy.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`bottom-sheet-backdrop${n?" is-open":""}`,onClick:s,"aria-hidden":"true"}),r.jsxs("aside",{ref:c,className:`bottom-sheet${n?" 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:"×"}),i]})]}),document.body)}function Kx(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yx(n,s,i){if(s.length===0)return[{text:n,label:n,matched:null}];const o=[],c=new Set;for(const p of s)if(!(!p.scope||p.scope==="all (unscoped)"))for(const y of[p.scope,...p.scope.split(",").map(v=>v.trim())]){const v=y.toLowerCase();y&&!c.has(v)&&(c.add(v),o.push(y))}o.sort((p,y)=>y.length-p.length);const d=p=>{const y=p.toLowerCase();return s.filter(v=>{var j,w;return((j=v.scope)==null?void 0:j.toLowerCase())===y||((w=v.scope)==null?void 0:w.split(",").map(N=>N.trim().toLowerCase()).includes(y))})},m=["\\[\\d+\\]",...o.map(Kx)],g=new RegExp(`(${m.join("|")})`,"gi");return n.split(g).filter(p=>p!=="").map(p=>{const y=/^\[(\d+)\]$/.exec(p);if(y){const v=s[Number(y[1])-1];if(v){const j=v.scope&&v.scope!=="all (unscoped)"?v.scope:"all recipients",w=i?`${i}: ${j}`:j;return{text:p,label:w,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 jf=`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 Jx(n,s,i,o){return Yx(n,s,o).map((c,d)=>{if(!c.matched)return r.jsx("span",{children:c.text},d);const m=c.matched;return r.jsx("button",{type:"button",onClick:()=>i(m),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:c.label},d)})}function qx(){var _e;const n=dn(),[s]=Ql(),i=Number(s.get("step"))||2,[o,c]=f.useState(null),[d,m]=f.useState(null),[g,p]=f.useState(i),[y,v]=f.useState(null),[j,w]=f.useState(null),[N,E]=f.useState({}),[k,C]=f.useState(jf),[T,I]=f.useState(!1),[$,A]=f.useState(null),[B,K]=f.useState(!0),[V,de]=f.useState(null),[Y,re]=f.useState([]),[G,D]=f.useState(void 0),[ie,fe]=f.useState(!1),[Z,pe]=f.useState(null),[ee,W]=f.useState(null),[O,H]=f.useState(null),[S,_]=f.useState([]),[J,te]=f.useState(null);f.useEffect(()=>{var Te;const he=sessionStorage.getItem("agentAuth");if(!he){n("/mandates?new=1");return}const X=JSON.parse(he);c(X),X.intentHint&&C(X.intentHint),M.getCredential("ai-config").then(Le=>A(Le.configured)).catch(()=>A(!1));const we=sessionStorage.getItem("agentGate");if(we){const Le=JSON.parse(we);Le.bounds&&v(Le.bounds),Le.context&&w(Le.context),(Te=Le.gateContent)!=null&&Te.intent&&C(Le.gateContent.intent)}M.getProfile(X.profileId).then(Le=>m(Le)).catch(()=>n("/mandates?new=1")).finally(()=>K(!1)),X.groupId&&Promise.all([M.getTeamProfileConfig(X.groupId,X.profileId).catch(()=>null),M.getGroupById(X.groupId).catch(()=>null),M.listUsers().catch(()=>[])]).then(([Le,lt,xt])=>{if(de(Le),Le){const Ke=new Map;for(const Fe of xt){const L=Fe.name&&Fe.email?`${Fe.name} (${Fe.email})`:Fe.name||Fe.email||Fe.id;Ke.set(Fe.id,L)}const et=(lt==null?void 0:lt.members)??[];for(const Fe of et){const L=Fe.userId??Fe.id;L&&(Fe.name&&Fe.email?Ke.set(L,`${Fe.name} (${Fe.email})`):Fe.name&&Ke.set(L,Fe.name))}const st=(Le.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&&D(Ke.get(Fe)??mt.name)}}})},[n]);const ce=y?Object.entries(y).filter(([he])=>he!=="profile"&&he!=="path").map(([he,X])=>`${he} = ${X}`).join(", "):"",ve=(he,X,we)=>{v(he),w(X),we&&E(we),p(3)},Ce=k.trim()!==jf.trim()&&k.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:k},we=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...we,bounds:y,context:j,contextLabels:N,gateContent:X,ttlConfig:he})),n("/mandates/new/sign")},$e=async()=>{if(o){fe(!0),pe(null),W(null),H(null),_([]),te(null);try{const he=await M.aiIntentReview({profileId:o.profileId,newIntent:k,context:j??void 0});_(he.grants??[]),he.success?he.review?pe(he.review):W(he.note??"No other mandates on this profile to compare against."):H(he.error??"Check failed.")}catch(he){H(he instanceof Error?he.message:"Check failed.")}finally{fe(!1)}}},Ee=he=>{C(he),(Z||ee||O)&&(pe(null),W(null),H(null),_([]),te(null))};return B||!o||!d?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):r.jsxs(r.Fragment,{children:[r.jsx(zh,{currentStep:g,onStepClick:he=>{he>=2&&p(he)}}),r.jsx(Tx,{profileId:o.profileId,bounds:ce||void 0,groupName:o.groupName,domain:o.domain}),g===2&&r.jsx("div",{className:"card",children:r.jsx(Wx,{profile:d,onConfirm:ve,onCancel:()=>n("/mandates?new=1"),initialBounds:y||void 0,initialContext:j||void 0,profileConfig:V,approverNames:Y,adminName:G})}),g===3&&r.jsxs("div",{className:`intent-layout${$?"":" no-chat"}`,children:[$&&r.jsx("div",{className:"card intent-pane chat tool",children:r.jsx(wi,{target:{kind:"intent",profileId:o.profileId,bounds:ce||void 0},currentText:k,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:k,onChange:he=>Ee(he.target.value)}),r.jsxs("div",{className:"char-counter",children:[k.length," / 2000"]})]}),$===!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."]}),$&&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:$e,disabled:ie||!Ce,children:ie?"Checking…":"Check against my other grants"}),O&&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:O})]}),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:Jx(Z,S,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=V==null?void 0:V.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."]})]})]}),$&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"floating-help",onClick:()=>I(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),r.jsx(Oh,{open:T,onClose:()=>I(!1),ariaLabel:"Intent assistant",children:r.jsx(wi,{target:{kind:"intent",profileId:o.profileId,bounds:ce||void 0},currentText:k,onApply:he=>{ke(he),I(!1)}})})]}),J&&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:J.length>1?`Existing mandates (${J.length})`:"Existing mandate"}),r.jsx("button",{className:"modal-close",onClick:()=>te(null),children:"×"})]}),r.jsx("div",{className:"modal-body",children:J.map((he,X)=>{var we;return r.jsxs("div",{style:{marginBottom:X<J.length-1?"1rem":0,paddingBottom:X<J.length-1?"1rem":0,borderBottom:X<J.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,Le])=>`${Te}: ${Le}`).join(" · ")})]})]},X)})})]})})]})]})}function Qx(n){return n.normalize("NFC").replace(/\r\n?/g,`
70
+ `).split(`
71
+ `).map(c=>c.replace(/[ \t]+$/,"")).join(`
72
+ `).replace(/\n+$/,"")}async function cc(n){const i=new TextEncoder().encode(n),o=await crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(o)).map(d=>d.toString(16).padStart(2,"0")).join("")}class Xx extends Error{constructor(i,o,c){super(c);zs(this,"code");zs(this,"field");this.name="CanonicalValueError",this.code=i,this.field=o}}function Zx(n){const s=new TextEncoder().encode(n);let i="";for(const o of s)o===61||o===37||o<32||o>126?i+="%"+o.toString(16).toUpperCase().padStart(2,"0"):i+=String.fromCharCode(o);return i}function Mh(n,s,i){const o=[];for(const c of s){const d=n[c];if(d==null)continue;const m=String(d);if(m.includes(`
73
+ `)||m.includes("\r"))throw new Xx(i,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}=${Zx(m)}`)}return o.join(`
74
+ `)}async function pi(n,s){const i=s.boundsSchema;if(!i)throw new Error("Profile has no boundsSchema");const o=Mh(n,i.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await cc(o)}`}async function Bh(n,s){const i=s.scopeSchema?Mh(n,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await cc(i)}`}function Pl(n){if(n===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof n=="number"&&!Number.isFinite(n))throw new Error(`canonicalize: ${n} is not a valid JSON number`);if(n===null||typeof n!="object")return JSON.stringify(n);if(Array.isArray(n))return"["+n.map(c=>c===void 0?"null":Pl(c)).join(",")+"]";const s=n,i=[];for(const o of Object.keys(s).sort()){const c=s[o];c!==void 0&&i.push(JSON.stringify(o)+":"+Pl(c))}return"{"+i.join(",")+"}"}async function Dh(n){return`sha256:${await cc(Pl(n))}`}async function ji(n){const s=new TextEncoder().encode(Qx(n)),i=await crypto.subtle.digest("SHA-256",s);return`sha256:${Array.from(new Uint8Array(i)).map(d=>d.toString(16).padStart(2,"0")).join("")}`}function Uh(n,s){if(!n.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:n.authorization_id,boundsHash:n.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 e0(n){const s=n.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(i=>s.includes(i)):[]}function t0(n){return n==="per-action"?"review":"automatic"}function Sf(n){return n?e0(n).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function n0(n,s){return s.includes(n)?n:s[0]??null}function kf(n){return n==null?new Set:new Set(String(n).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function r0(n,s){for(const i of n)if(s.has(i))return!0;return!1}function s0(n,s,i){for(const o of n){const c=kf(s[o]),d=kf(i[o]);if(!(c.size===0||d.size===0)&&!r0(c,d))return!1}return!0}function a0(n){return n.length>24?`${n.slice(0,10)}…`:n}function Wh(n,s,i){const o=i==null?void 0:i[n];return String(s).split(",").map(d=>d.trim()).filter(Boolean).map(d=>{const m=o==null?void 0:o[d];return m?`${m} (${a0(d)})`:d}).join(", ")}function Hh(n){var i;if(n.isPersonal)return{can:!0};if(!n.configLoaded)return{can:!0};const s=n.teamName?`"${n.teamName}"`:"this team";return(((i=n.approvers)==null?void 0:i.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${s}.`,fix:`Ask an admin of ${s} to enable ${n.profileName} and name who may give its mandates.`}:!n.userId||!n.approvers.includes(n.userId)?{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${n.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 Si=500,i0=["Lower the discount","Other recipient","Shorter","Different wording"];function uc(n){const s=n.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>Si?{valid:!1,error:`At most ${Si} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function o0(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Vh(n,s){return n.toLowerCase().includes(s.toLowerCase())}function l0(n,s){const i=n.trim();if(i.length===0)return s;if(!Vh(i,s))return`${i}. ${s}`;const o=new RegExp(`\\.?\\s*${o0(s)}\\.?`,"i");return i.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function _l(){return{outcome:"rejected"}}function c0(n){const s=uc(n);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function bf(){return{outcome:"replaced"}}function u0(n,s){if((n.pendingApprovers??[]).includes(s))return{route:"approver"};const i=n.pendingDomains??[];return i.includes(s)?{route:"resolve",domain:s}:i.includes("owner")?{route:"resolve",domain:"owner"}:null}const d0={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function f0(n,s){const i=n.rejectedBy??n.approverRejectedBy;if(!i)return null;const o=i.outcome??"rejected",c=i.note??("reason"in i?i.reason:void 0);return{kind:d0[o],who:i.userId===s?"You":i.userId,at:i.at,note:c}}function h0(){var me,Re;const n=dn(),{user:s,mode:i,domain:o}=vt(),[c,d]=f.useState(null),[m,g]=f.useState(null),[p,y]=f.useState(null),[v,j]=f.useState("per-action"),[w,N]=f.useState(1800),[E,k]=f.useState(86400),[C,T]=f.useState(""),[I,$]=f.useState("hours"),[A,B]=f.useState(""),[K,V]=f.useState(!0),[de,Y]=f.useState(!1);f.useEffect(()=>{M.getIdentityDisclosure().then(ue=>Y(ue.always)).catch(()=>{})},[]);const[re,G]=f.useState(!1),[D,ie]=f.useState(""),[fe,Z]=f.useState(null),[pe,ee]=f.useState([]),[W,O]=f.useState(!1),[H,S]=f.useState([]),[_,J]=f.useState(0);f.useEffect(()=>{var vn;const ue=sessionStorage.getItem("agentAuth"),Oe=sessionStorage.getItem("agentGate");if(!ue||!Oe){n("/mandates?new=1");return}const Ge=JSON.parse(ue),Ye=JSON.parse(Oe),ft={bounds:Ye.bounds??{},context:Ye.context??{},contextLabels:Ye.contextLabels??void 0,gateContent:Ye.gateContent};d(Ge),g(ft),Ye.ttlConfig&&(N(Ye.ttlConfig.default??1800),k(Ye.ttlConfig.max??86400)),Ye.templateMode==="automatic"?j("immediate"):Ye.templateMode==="review"&&j("per-action");const fn=((vn=Ye.ttlConfig)==null?void 0:vn.max)??86400;if(typeof Ye.templateTtl=="number"&&Ye.templateTtl>0){const tt=Math.min(Ye.templateTtl,fn);N(tt),[3600,86400,604800,2592e3,31536e3].includes(tt)||(tt%86400===0?(T(String(tt/86400)),$("days")):(T(String(Math.max(1,Math.round(tt/3600)))),$("hours")))}M.getProfile(Ge.profileId).then(tt=>{var bt;if(y(tt),!A){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;B(ae)}}).catch(()=>{}),Ge.isPersonal?O(!0):Promise.all([M.getTeamProfileConfig(Ge.groupId,Ge.profileId).catch(()=>null),M.getGroupById(Ge.groupId).catch(()=>null),M.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(()=>{O(!0)})},[n]),f.useEffect(()=>{if(!(c!=null&&c.profileId))return;const ue=c.profileId,Oe=sessionStorage.getItem("agentEditReplaces");M.getEnrichedAuthorizations().then(Ge=>{const Ye=Ge.filter(ft=>ft.profileId===ue&&ft.authorizationId!==Oe).map(ft=>({authorizationId:ft.authorizationId,bounds:ft.bounds,context:ft.context??{},intent:ft.intent}));S(Ye)}).catch(()=>S([]))},[c==null?void 0:c.profileId]),f.useEffect(()=>{if(!p)return;const ue=n0(v,Sf(p));ue&&ue!==v&&j(ue)},[p,v]),f.useEffect(()=>{if(!m||!p||H.length===0){J(0);return}let ue=!1;return(async()=>{const Oe=await pi(m.bounds,p),Ge=await Promise.all(H.map(Ye=>pi(Ye.bounds,p).catch(()=>null)));ue||J(Ge.filter(Ye=>Ye===Oe).length)})().catch(()=>{ue||J(0)}),()=>{ue=!0}},[m,p,H]);const te=async()=>{if(!(!c||!m||!p||!s)){if(!c.groupId){ie("No active group; cannot create mandate.");return}G(!0),ie("");try{const ue=o||c.domain||"owner",Oe=await pi(m.bounds,p),Ge=await Bh(m.context,p),[Ye,ft]=await Promise.all([ji(m.gateContent.intent),ji(JSON.stringify({profile:c.profileId,domain:ue,group:c.groupId}))]);let fn,vn,tt,bt;if(c.isTeam){const ze=await M.getApproversPubkeys(c.groupId,c.profileId);if(ze.length>0){const Je=await M.encryptIntent(m.gateContent.intent,ze);fn=Je.intentCiphertext,vn=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 Dh(p),ge=await M.attest({authorization_id:Et,replaces:wt,profile_id:c.profileId,profile_hash:je,supported_versions:["0.7"],bounds:m.bounds,bounds_hash:Oe,scope_hash:Ge,domain:ue,did:s.did,mandate_owners:[{did:s.did}],gate_content_hashes:{intent:Ye},execution_context_hash:ft,group_id:c.groupId,ttl:w,commitment_mode:t0(v),title:A.trim(),intent_ciphertext:fn,encrypted_keys:vn,approvers_frozen:tt,intent_disclosure_hash:bt,disclose_identity:K});try{await M.pushGateContent(Uh(ge,{boundsHash:Oe,contextHash:Ge,context:m.context,contextLabels:m.contextLabels,gateContent:m.gateContent}))}catch(ze){try{await M.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 M.revokeAttestation(wt,`Replaced by ${Et} (edit)`),M.resyncGates().catch(()=>{})}catch{}let Me="";if(ae)try{const ze=await M.getProposal(ae);if(ze.status==="pending"){const Je=u0(ze,(s==null?void 0:s.id)??"");Je?Je.route==="approver"?await M.rejectProposal(ae,bf()):await M.resolveProposal(ae,"reject",Je.domain,bf()):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){ie(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${Me}) — reject it under Approvals.`);return}n(`/mandates?highlight=${encodeURIComponent(Et)}`)}catch(ue){ie(ue instanceof Error?ue.message:"Signing the mandate failed")}finally{G(!1)}}};if(!c||!m)return r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const ce=Object.entries(m.bounds).filter(([ue])=>ue!=="profile"&&ue!=="path"),ve=Object.entries(m.context),ke=((fe==null?void 0:fe.caps)!=null?Object.keys(fe.caps):[]).length!==0,se=pe.length>0?pe.join(", "):((fe==null?void 0:fe.approvers)??[]).join(", "),$e=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=fe==null?void 0:fe.approvers)!=null&&me.length),he=Hh({isPersonal:c.isPersonal,configLoaded:W,approvers:fe==null?void 0:fe.approvers,userId:s==null?void 0:s.id,profileName:dt(c.profileId),teamName:c.groupName}),X=!he.can,we=Sf(p),Te=we.length===0,Le=w>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=H.filter(ue=>s0(Ke,m.context,ue.context)),st=et.length>0,mt=dt(c.profileId),Fe=ue=>{const Oe=Object.values(ue).map(Ge=>String(Ge).trim()).filter(Boolean);return Oe.length>0?Oe.join(", "):"all (unscoped)"},L=et.map(ue=>Fe(ue.context)).join("; "),oe=`This grant's scope overlaps an existing grant on ${mt} (scoped to: ${L}). 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(zh,{currentStep:4,onStepClick:ue=>{ue<=3&&n(`/mandates/new/intent?step=${ue}`)}}),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."]})]}),D&&r.jsx("div",{className:"error-message",children:D}),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:A,onChange:ue=>B(ue.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:()=>j("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:()=>j("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(ue=>ue.seconds<=E).map(ue=>r.jsx("button",{onClick:()=>{N(ue.seconds),T("")},style:{padding:"0.5rem 0.85rem",border:w===ue.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:w===ue.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:ue.label},ue.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:ue=>{T(ue.target.value);const Oe=parseInt(ue.target.value,10);if(Oe>0){const Ge=I==="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:I,onChange:ue=>{$(ue.target.value);const Oe=parseInt(C,10);if(Oe>0){const Ge=ue.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"})]})]}),Le&&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:de||K,disabled:de,onChange:ue=>V(ue.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.',de&&" 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:()=>n("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),r.jsx("div",{style:{whiteSpace:"pre-wrap"},children:m.gateContent.intent})]}),(!!ce.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:()=>n("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),r.jsxs("dl",{className:"info-kv",children:[ve.map(([ue,Oe])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:ue}),r.jsx("dd",{children:Wh(ue,Oe,m.contextLabels)})]},ue)),ce.map(([ue,Oe])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:ue}),r.jsx("dd",{children:String(Oe)})]},ue))]})]}),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:$e})]}):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…"})})]})]})]}),_>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:[_===1?`An active grant on ${mt} already has exactly these limits.`:`${_} 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:oe})]})]}):null,r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-ghost",onClick:()=>n("/mandates/new/intent"),children:"Back"}),r.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:te,disabled:re||!A.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 m0={card:"💳",mail:"✉️"};function Gh(n){return m0[n]??"🔧"}function p0(n){const s=n==null?void 0:n.overrides;return!s||typeof s!="object"?!1:Object.values(s).some(i=>{var o;return typeof((o=i==null?void 0:i.read)==null?void 0:o.ageField)=="string"})}const g0=[0,7,30,90,365,3650];function ci(n){return n===null?"From your mandate":n===0?"Read nothing":n===1?"1 day back":n===365?"1 year back":n%365===0?`${n/365} years back`:`${n} days back`}function y0(n){return(n==null?void 0:n.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:n&&!n.running&&n.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function Sl({manifest:n,integration:s,state:i,onStatusChange:o,onSuccess:c}){var Fe;const[d,m]=f.useState({}),[g,p]=f.useState(!1),[y,v]=f.useState(!1),[j,w]=f.useState({}),[N,E]=f.useState({}),[k,C]=f.useState(void 0),[T,I]=f.useState(!1),[$,A]=f.useState(null),[B,K]=f.useState(!1),[V,de]=f.useState(!1),[Y,re]=f.useState(!1),[G,D]=f.useState(!1),[ie,fe]=f.useState({}),[Z,pe]=f.useState(null),[ee,W]=f.useState(!1),[O,H]=f.useState(null),[S,_]=f.useState(!1);f.useEffect(()=>{let L=!1;return M.getCredential(n.id).then(oe=>{var me;if(!(L||!oe.configured)){if(p(!0),v(!0),oe.fields){const Re={};for(const ue of n.credentials.fields)oe.fields[ue.key]!=null&&(Re[ue.key]=oe.fields[ue.key]);w(Re)}if(E(oe.secrets??{}),C(oe.updatedAt),n.oauth){const Re=((me=oe.fieldNames)==null?void 0:me.includes(n.oauth.tokenStorage))??!1;I(Re),Re&&M.getOAuthHealth(n.id).then(ue=>{L||A(ue)})}}}).catch(()=>{}),()=>{L=!0}},[n.id,n.oauth]);const J=p0(n.toolGating),te=s?s.readAgeDays??null:void 0,ce=ee&&Z?Z.value:te,ve=async L=>{pe({value:L}),W(!0),H(null);try{await M.setReadPolicy(n.id,L),c(L===null?`${n.name} read window now follows your mandate`:`${n.name} read window set to ${ci(L).toLowerCase()}`),o()}catch(oe){H(oe instanceof Error?oe.message:"Could not save")}finally{W(!1),pe(null)}},Ce=!!n.oauth||n.credentials.fields.some(L=>!L.optional),ke=n.oauth?T:g,se=!Ce||ke,$e=i==="starting"?"starting":se?s!=null&&s.running?"running":!g&&n.credentials.fields.length>0?"unconfigured":"ready":n.oauth&&g&&!T?"needs-oauth":"unconfigured",Ee=async()=>{if(n.credentials.fields.some(oe=>{var me;return(me=d[oe.key])==null?void 0:me.trim()})){K(!0);try{await M.setCredential(n.id,d),p(!0),m({}),n.oauth?c(`${n.name} credentials saved!`):(c(`${n.name} credentials saved — starting integration...`),await Te())}catch{c(`Failed to save ${n.name} credentials`)}finally{K(!1)}}},_e=()=>{const L={};for(const oe of n.credentials.fields){const me=d[oe.key];oe.type==="password"?me!=null&&me.trim()&&(L[oe.key]=me):me!=null&&me!==(j[oe.key]??"")&&(L[oe.key]=me)}return L},he=Object.keys(_e()).length>0,X=async()=>{const L=_e();if(Object.keys(L).length!==0){K(!0);try{await M.setCredential(n.id,L),m({}),p(!0),n.oauth?c(`${n.name} credentials saved — now click Connect.`):(D(!1),c(`${n.name} credentials updated — restarting...`),await Te())}catch{c(`Failed to update ${n.name} credentials`)}finally{K(!1)}}},we=()=>{window.open(`/auth/oauth/${n.id}/start`,"_blank","width=600,height=700");const L=setInterval(async()=>{var oe;try{const me=await M.getCredential(n.id);me.configured&&n.oauth&&((oe=me.fieldNames)!=null&&oe.includes(n.oauth.tokenStorage))&&(I(!0),D(!1),A(null),clearInterval(L),c(`${n.name} connected — starting integration...`),M.getOAuthHealth(n.id).then(A).catch(()=>{}),await Te())}catch{}},2e3);setTimeout(()=>clearInterval(L),12e4)},Te=async()=>{re(!0);try{const L=await M.activateIntegration(n.id);L.warning?c(L.warning):c(`${n.name} integration started with ${L.tools.length} tools`),o()}catch(L){c(`Failed to start ${n.name}: ${L instanceof Error?L.message:"Unknown error"}`)}finally{re(!1)}},Le=async()=>{try{await M.removeMcpIntegration(n.id),c(`${n.name} integration removed`),o()}catch{c(`Failed to remove ${n.name}`)}},lt=Gh(n.icon),xt=y0(s),Ke=$e==="running"?{c:"int-chip-ok",t:"Running"}:$e==="starting"?{c:"int-chip-idle",t:"Starting"}:xt.chip,et=n.oauth&&T&&($==null?void 0:$.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=L=>L.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${n.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:n.name}),r.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[$e!=="unconfigured"&&$e!=="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]}),dv(n,j)&&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"]})]})]}),n.oauth&&T&&r.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:$!=null&&$.account?r.jsxs(r.Fragment,{children:["Connected as ",r.jsx("b",{children:$.account})]}):r.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),et&&!G&&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:[n.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:[($==null?void 0:$.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."]}):$!=null&&$.error?r.jsxs(r.Fragment,{children:["The provider reported ",r.jsx("code",{children:$.error}),"."]}):r.jsx(r.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",n.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 ",n.name]}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{m({...j}),D(!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:n.description}),n.profile&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Profile"}),r.jsx("span",{children:n.profile})]}),n.oauth&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"int-k",children:"Scopes"}),r.jsx("span",{children:((Fe=n.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"]})]})]})]}),n.setupGuide&&n.setupGuide.length>0&&($e!=="running"||et)&&r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[r.jsxs("button",{onClick:()=>de(!V),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:V?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",n.name]}),V&&r.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:n.setupGuide.map((L,oe)=>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:oe+1}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:L.title}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[mt(L.description),L.link&&r.jsxs(r.Fragment,{children:[" ",r.jsxs("a",{href:L.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},oe))})]}),$e==="starting"&&r.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[r.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),G&&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"}),y&&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.",n.oauth?" Save, then Connect to re-link the account.":""]}),n.credentials.fields.map(L=>{var oe;return r.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[r.jsx("label",{className:"form-label",children:L.label}),L.type==="password"?r.jsxs("div",{className:"cred-field",children:[r.jsx("input",{className:"form-input",type:ie[L.key]?"text":"password",name:`${n.id}-${L.key}-credential`,autoComplete:"new-password",placeholder:(oe=N[L.key])!=null&&oe.preview?`Unchanged — ends in ${N[L.key].preview}`:y?"Unchanged — paste a new value to replace":L.placeholder,value:d[L.key]||"",onChange:me=>m(Re=>({...Re,[L.key]:me.target.value}))}),r.jsx("button",{className:"cred-toggle",onClick:()=>fe(me=>({...me,[L.key]:!me[L.key]})),children:ie[L.key]?"hide":"show"})]}):r.jsx("input",{className:"form-input",type:"text",name:`${n.id}-${L.key}-credential`,autoComplete:"off",placeholder:L.placeholder,value:d[L.key]||"",onChange:me=>m(Re=>({...Re,[L.key]:me.target.value}))})]},L.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:B||!he,children:B?"Saving…":"Save"}),!he&&!B&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),n.oauth&&r.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:we,children:["Connect ",n.name]}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{D(!1),m({})},children:"Cancel"})]})]}),!G&&$e==="running"&&s&&r.jsxs(r.Fragment,{children:[(Object.keys(j).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:n.credentials.fields.map(L=>{const oe=L.type==="password",me=N[L.key];return!oe&&j[L.key]==null||oe&&me==null?null:r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[r.jsx("span",{style:{color:"var(--text-muted)"},children:L.label}),r.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[oe?me.preview??"set":j[L.key],oe&&k&&r.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(k).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},L.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"}),(n.credentials.fields.length>0||n.oauth)&&r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{m({...j}),D(!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:Le,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"})]}),J&&ce!==void 0&&!S&&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:ce===null?"window from your mandate":ci(ce).toLowerCase()}),ee&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),O&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:O})]}),r.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>_(!0),children:"Edit"})]})}),J&&ce!==void 0&&S&&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:()=>_(!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:[g0.map(L=>{const oe=ce===L;return r.jsx("button",{className:`btn btn-sm ${oe?"btn-primary":"btn-secondary"}`,"aria-pressed":oe,disabled:ee,onClick:()=>ve(L),children:ci(L)},L)}),r.jsx("button",{className:`btn btn-sm ${ce===null?"btn-primary":"btn-ghost"}`,"aria-pressed":ce===null,disabled:ee,onClick:()=>ve(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:ci(null)})]}),r.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:O?r.jsx("span",{style:{color:"var(--danger)"},children:O}):ee?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):ce===null?r.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):ce===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 ",ce," 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"})})]}),$e==="unconfigured"&&(()=>{const L=n.credentials.fields.every(Re=>Re.optional),oe=n.credentials.fields.some(Re=>!Re.optional),me=n.credentials.fields.some(Re=>{var ue;return(ue=d[Re.key])==null?void 0:ue.trim()});return r.jsxs(r.Fragment,{children:[y&&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),n.oauth&&I(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),n.oauth&&!y&&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."}),n.setupHint&&!y&&r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:n.setupHint}),n.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:ie[Re.key]?"text":"password",name:`${n.id}-${Re.key}-credential`,autoComplete:"new-password",placeholder:Re.placeholder,value:d[Re.key]||"",onChange:ue=>m(Oe=>({...Oe,[Re.key]:ue.target.value}))}),r.jsx("button",{className:"cred-toggle",onClick:()=>fe(ue=>({...ue,[Re.key]:!ue[Re.key]})),children:ie[Re.key]?"hide":"show"})]}):r.jsx("input",{className:"form-input",type:"text",name:`${n.id}-${Re.key}-credential`,autoComplete:"off",placeholder:Re.placeholder,value:d[Re.key]||"",onChange:ue=>m(Oe=>({...Oe,[Re.key]:ue.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:B||oe&&!n.credentials.fields.filter(Re=>!Re.optional).every(Re=>{var ue;return(ue=d[Re.key])==null?void 0:ue.trim()}),children:B?"Saving...":"Save & Encrypt"}),L&&!me&&r.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:Y,children:Y?"Starting...":`Activate ${n.name}`})]})]})})(),$e==="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 ",n.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 ",n.name," Account"]}),r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Change Credentials"})]})]}),$e==="ready"&&!s&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",n.oauth?`${n.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 ${n.name} Integration`}),!n.oauth&&r.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Update Credentials"}),n.oauth&&r.jsx("button",{className:"btn btn-ghost",onClick:()=>{p(!1),I(!1)},children:"Change Credentials"})]})]}),$e==="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:Le,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:Le,children:"Disable"})})]}))]})}function v0(n,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:n};const i=n.filter(m=>Vs(m.manifest)),o=n.filter(m=>!Vs(m.manifest)),c=o.filter(m=>m.state==="error"),d=o.filter(m=>m.state!=="error");return{grouped:!0,testSystems:i,realErrors:c,pausedReal:d,ungrouped:[]}}function x0({entry:n}){return r.jsxs("div",{className:"int-paused-row",children:[r.jsx("span",{"aria-hidden":"true",children:Gh(n.manifest.icon)}),r.jsx("span",{className:"int-paused-name",children:n.manifest.name}),r.jsxs("span",{className:"int-chip int-chip-paused",children:[r.jsx("span",{className:"int-dot"}),"Paused"]})]})}function w0(){const{loading:n,mcpServerUp:s,manifestsError:i,entries:o,refresh:c}=nc(),d=tc(),[m,g]=f.useState(""),p=f.useCallback(v=>{g(v),setTimeout(()=>g(""),5e3)},[]),y=v0(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."})]}),m&&r.jsx("div",{className:"alert alert-success",children:m}),n?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."})]}):y.grouped?r.jsxs(r.Fragment,{children:[y.testSystems.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"int-group-label",children:"Test systems"}),y.testSystems.map(v=>r.jsx(Sl,{manifest:v.manifest,integration:v.integration,state:v.state,onStatusChange:c,onSuccess:p},v.id))]}),(y.realErrors.length>0||y.pausedReal.length>0)&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"int-group-label",children:"Real systems"}),y.realErrors.map(v=>r.jsx(Sl,{manifest:v.manifest,integration:v.integration,state:v.state,onStatusChange:c,onSuccess:p},v.id)),y.pausedReal.length>0&&r.jsxs("details",{className:"int-paused-group",open:!0,children:[r.jsxs("summary",{children:["Paused while simulation mode is on (",y.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"}),")."]}),y.pausedReal.map(v=>r.jsx(x0,{entry:v},v.id))]})]}),o.length===0&&r.jsx(Nf,{manifestsError:i})]}):r.jsxs(r.Fragment,{children:[o.map(v=>r.jsx(Sl,{manifest:v.manifest,integration:v.integration,state:v.state,onStatusChange:c,onSuccess:p},v.id)),o.length===0&&r.jsx(Nf,{manifestsError:i})]})]})}function Nf({manifestsError:n}){return n?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 j0(){var D,ie,fe;const{activeTeam:n,activeMembership:s,refreshGroups:i,user:o}=vt(),c=dn(),[d,m]=f.useState(null),[g,p]=f.useState(!1),[y,v]=f.useState(""),[j,w]=f.useState(""),[N,E]=f.useState(!1),[k,C]=f.useState(""),[T,I]=f.useState("");f.useEffect(()=>{fetch("/health").then(Z=>Z.json()).then(Z=>{typeof Z.spUrl=="string"&&I(Z.spUrl)}).catch(()=>{})},[]),f.useEffect(()=>{if(!n){m(null);return}M.getGroupById(n.id).then(Z=>{const pe=Z.group??Z,ee=Z.members??[],W=Z.isAdmin??!1,O=ee.map(H=>{const S=H.userId||H.id||"",_=H.role||(W&&S===pe.createdBy?"admin":"member");return{id:S,name:H.name||S.slice(0,8)||"Member",email:H.email||"",domains:H.domains||[],role:_,isAdmin:_==="admin"||W&&S===pe.createdBy}});m({id:pe.id,name:pe.name,members:O})}).catch(()=>m(null))},[n==null?void 0:n.id]);const $=(d==null?void 0:d.members.filter(Z=>Z.isAdmin))??[],A=(n==null?void 0:n.isAdmin)===!0&&$.length<=1&&$.some(Z=>Z.id===(o==null?void 0:o.id)),B=(n==null?void 0:n.name)??"",K=k.trim()===B&&!g,V=()=>{C(""),E(!0)},de=()=>{E(!1),C("")},Y=async()=>{if(!(!n||!K)){p(!0),v("");try{await M.leaveTeam(n.id),await i(),w("You have left the team."),m(null),de()}catch(Z){v(Z instanceof Error?Z.message:"Failed to leave team")}finally{p(!1)}}},re=n&&T?`${T}/dashboard/groups/${n.id}`:void 0,G=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."})]})}),y&&r.jsx("div",{className:"error-message",children:y}),j&&r.jsx("div",{className:"alert alert-success",children:j}),n?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:n.name}),r.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((D=d==null?void 0:d.members)==null?void 0:D.length)??0," ",(((ie=d==null?void 0:d.members)==null?void 0:ie.length)??0)===1?"member":"members",n.isAdmin&&" · You are admin"]})]}),r.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(fe=d==null?void 0:d.members)==null?void 0:fe.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:A?"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:V,disabled:g||A,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"}),G&&r.jsx("a",{className:"btn btn-ghost btn-sm",href:G,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),N&&n&&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:de,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 ",B,"?"]}),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:B})," to confirm:"]}),r.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:k,onChange:Z=>C(Z.target.value),placeholder:B,disabled:g,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:de,disabled:g,children:"Cancel"}),r.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:Y,disabled:!K,children:g?"Leaving...":"Leave team"})]})]})})]})}const S0=new Set(["mail","users","receipt","credit-card","calendar","megaphone","archive","rocket","flask","shopping-cart","bar-chart","help-circle"]),k0={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 b0(n){const s=n.lastIndexOf("/"),i=s>=0?n.slice(s+1):n,o=i.indexOf("@");return(o>=0?i.slice(0,o):i).toLowerCase()}function Sr(n,s){const i=b0(n),o=s!=null&&s.icon&&S0.has(s.icon)?s.icon:k0[i]??"help-circle",c=dt(n,s==null?void 0:s.name);return{icon:o,name:c,testSetup:i==="delegation"}}function Ti(n){return n.startsWith("setup__")}const N0={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 Kh({icon:n,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:N0[n]})}function qs({profileId:n,declared:s}){const{icon:i,name:o}=Sr(n,s);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"id-rail",children:[r.jsx(Kh,{icon:i,className:"id-rail-icon"}),r.jsx("span",{className:"id-rail-name",children:o})]}),r.jsx("div",{className:"id-sep"})]})}const Ks=n=>n.replace(/@.*$/,"").split("/").pop()??n,Cf=n=>n.split("@")[1]??"";function C0(n,s){const i=new Map;for(const o of n){const c=Ks(o.id);if(!s.has(c))continue;const d=i.get(c);(!d||Cf(o.id).localeCompare(Cf(d.id),void 0,{numeric:!0})>0)&&i.set(c,o)}return i}function E0(n,s,i,o){var g;const c=new Set([...s.filter(p=>p.profile).map(p=>p.profile),...o.map(p=>Ks(p.profile))]),d=C0(n,c),m=[];for(const p of s){const y=p.profile?d.get(p.profile):void 0;y&&m.push({key:`connector:${p.id}`,name:p.name,description:p.description||y.description,profile:y,kind:"connector",ready:((g=i.find(v=>v.id===p.id))==null?void 0:g.running)===!0,setupId:p.id,...p.intentHint?{intentHint:p.intentHint}:{}})}for(const p of o){const y=d.get(Ks(p.profile));y&&m.push({key:`builtin:${p.id}`,name:p.name,description:p.description||y.description,profile:y,kind:"builtin",ready:p.available,unavailableReason:p.available?void 0:"Available only while simulation mode is on.",...p.intentHint?{intentHint:p.intentHint}:{}})}return m}function T0(n,s,i){if(s)return n.find(o=>Ks(o.profile.id)===Ks(s)&&o.ready&&i(o))}function R0({onDismiss:n,preselectProfileId:s}){const i=dn(),{group:o,groupId:c,domain:d,user:m}=vt(),[g,p]=f.useState([]),[y,v]=f.useState([]),[j,w]=f.useState([]),[N,E]=f.useState([]),[k,C]=f.useState(!0),[T,I]=f.useState({});f.useEffect(()=>{Promise.all([M.listProfiles().catch(()=>[]),M.getIntegrationManifests().then(Y=>Y.manifests??[]).catch(()=>[]),M.getMcpHealth().catch(()=>null)]).then(async([Y,re,G])=>{if(p(Y),v(re),w((G==null?void 0:G.integrations)??[]),E((G==null?void 0:G.builtins)??[]),c){const D=await Promise.all(Y.map(fe=>M.getTeamProfileConfig(c,fe.id).catch(()=>null))),ie={};Y.forEach((fe,Z)=>{const pe=D[Z];pe&&(ie[fe.id]=pe)}),I(ie)}}).finally(()=>C(!1))},[c]);const $=E0(g,y,j,N),A=Y=>{var re;return Hh({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!k,approvers:(re=T[Y.id])==null?void 0:re.approvers,userId:m==null?void 0:m.id,profileName:dt(Y.id),teamName:o==null?void 0:o.name})},B=Y=>Y in T,K=(Y,re)=>{if(!c){console.error("No active group when creating authorization");return}const G=B(Y);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Y,groupId:c,groupName:(o==null?void 0:o.name)??null,domain:d,isTeam:G,isPersonal:!!(o!=null&&o.isPersonal),...re?{intentHint:re}:{}})),sessionStorage.removeItem("agentGate"),n==null||n(),i("/mandates/new/intent")},V=(Y,re)=>{c&&K(Y,re)},de=f.useRef(!1);return f.useEffect(()=>{if(k||!s||de.current)return;const Y=T0($,s,re=>A(re.profile).can);Y&&(de.current=!0,V(Y.profile.id,Y.intentHint))},[k,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
+ `}),k?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):$.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:()=>n==null?void 0:n(),children:"Go to Integrations"})]}):r.jsx("div",{className:"profile-grid",children:$.map(Y=>{const re=Y.profile,G=B(re.id),D=A(re),ie=!Y.ready||!D.can,{icon:fe}=Sr(re.id,{name:re.name,icon:re.icon});return r.jsxs("div",{className:"card",style:ie?{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(Kh,{icon:fe,className:"profile-chip-icon"}),Y.name]}),G?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}),D.can?Y.ready?r.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>V(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:()=>n==null?void 0:n(),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:[D.reason," ",r.jsx("span",{style:{color:"var(--text-tertiary)"},children:D.fix})]})]})]},Y.key)})})]})}const I0={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function A0({status:n,label:s}){return r.jsx("span",{className:`status-badge status-${n}`,children:s||I0[n]})}function P0({domain:n,attested:s}){const i=s===!0?"domain-attested":s===!1?"domain-missing":"";return r.jsx("span",{className:`domain-badge ${i}`,style:{fontSize:"0.75rem"},children:n})}const yr=86400,Us=3600,ui=60,_0=30*yr;function L0(n){if(n<=0)return"Expired";if(n>90*yr){const s=Math.floor(n/_0);return`${s} ${s===1?"month":"months"} remaining`}if(n>7*yr){const s=Math.floor(n/yr);return`${s} ${s===1?"day":"days"} remaining`}if(n>=2*yr){const s=Math.floor(n/yr),i=Math.floor(n%yr/Us);return`${s} ${s===1?"day":"days"} ${i}h remaining`}if(n>=2*Us){const s=Math.floor(n/Us),i=Math.floor(n%Us/ui);return`${s}h ${String(i).padStart(2,"0")}m remaining`}if(n>=ui){const s=Math.floor(n/ui),i=Math.floor(n%ui);return`${s}m ${String(i).padStart(2,"0")}s remaining`}return`${Math.floor(n)}s remaining`}function $0({expiresAt:n}){const[s,i]=f.useState(()=>n-Date.now()/1e3),o=s<2*Us;f.useEffect(()=>{const d=setInterval(()=>i(n-Date.now()/1e3),o?1e3:6e4);return()=>clearInterval(d)},[n,o]);const c=s<300;return r.jsx("span",{className:`ttl-badge ${c?"ttl-warn":"ttl-ok"}`,children:L0(s)})}function qr({icon:n,title:s,text:i,children:o}){return r.jsxs("div",{className:"empty-state",children:[n&&r.jsx("div",{className:"empty-state-icon",children:n}),r.jsx("div",{className:"empty-state-title",children:s}),i&&r.jsx("div",{className:"empty-state-text",children:i}),o]})}function z0(n){const s=Math.floor(n/86400);if(s>=1)return`${s} day${s===1?"":"s"}`;const i=Math.floor(n/3600);if(i>=1)return`${i} hour${i===1?"":"s"}`;const o=Math.ceil(n/60);return`${o} minute${o===1?"":"s"}`}const F0=[{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 O0({item:n,onClose:s,onSuccess:i}){var $;const{user:o,activeDomain:c,groupId:d}=vt(),[m,g]=f.useState(null);f.useEffect(()=>{let A=!1;return M.getProfile(n.profile_id).then(B=>{var K;A||g(((K=B==null?void 0:B.ttl)==null?void 0:K.max)??null)}).catch(()=>{}),()=>{A=!0}},[n.profile_id]);const p=n.remaining_seconds??0,y=F0.filter(A=>A.seconds>p&&(m===null||A.seconds<=m)),v=(($=y[0])==null?void 0:$.seconds)??2592e3,[j,w]=f.useState(v);f.useEffect(()=>{var A;if(m!==null&&j>m){const B=(A=y[y.length-1])==null?void 0:A.seconds;B&&w(B)}},[m]);const[N,E]=f.useState(!1),[k,C]=f.useState(""),T=Object.entries(n.frame).filter(([A])=>A!=="profile"&&A!=="path"),I=async()=>{var A;if(o){E(!0),C("");try{const B=n.authorization_id,K=await M.getGateContent(B);if(!K)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const V=await M.getProfile(n.profile_id),de=n.frame,Y=K.context??{},re=n.attested_domains[0]||c||"owner",G=await pi(de,V),D=await Bh(Y,V),[ie,fe]=await Promise.all([ji(K.gateContent.intent),ji(JSON.stringify({profile:n.profile_id,path:n.path,domain:re}))]);if(!d)throw new Error("No active group; cannot extend mandate.");const Z=(((A=n.deferred_commitment_domains)==null?void 0:A.length)??0)>0?"review":"automatic",pe=await Dh(V),ee=await M.attest({authorization_id:n.authorization_id,renew:!0,profile_id:n.profile_id,profile_hash:pe,supported_versions:["0.7"],bounds:de,bounds_hash:G,scope_hash:D,domain:re,did:o.did,mandate_owners:[{did:o.did}],gate_content_hashes:{intent:ie},execution_context_hash:fe,group_id:d,commitment_mode:Z,ttl:j});await M.pushGateContent(Uh(ee,{boundsHash:G,contextHash:D,context:Y,path:n.path,gateContent:K.gateContent})),i()}catch(B){C(B instanceof Error?B.message:"Extension failed")}finally{E(!1)}}};return r.jsx("div",{className:"modal-backdrop",onClick:A=>A.target===A.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(n.profile_id)," / ",n.path]}),T.length>0&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:T.map(([A,B])=>`${A}=${B}`).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 ",z0(p),". Only longer durations are shown."]}),r.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:y.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."}):y.map(A=>r.jsx("button",{className:`btn ${j===A.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>w(A.seconds),style:{minWidth:"3.5rem"},children:A.label},A.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)."}),k&&r.jsx("div",{className:"error-message",children:k})]}),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:I,disabled:N,children:N?"Extending...":"Extend"})]})]})})}function Ef(n){return n.replace(/@.*$/,"").split("/").pop()??n}function Tf(n){return n.split("@")[1]??""}function M0(n,s){return Tf(n).localeCompare(Tf(s),void 0,{numeric:!0})>0}function Yh(n,s){const i=Ef(n);let o;for(const c of s)Ef(c.id)===i&&(!o||M0(c.id,o.id))&&(o=c);return o}function Jh(n,s){var o;if(!s)return{};const i={};for(const c of s.keyOrder){if(c==="profile"||c==="path")continue;if(n[c]!==void 0){i[c]=n[c];continue}const d=(o=s.fields[c])==null?void 0:o.default;(typeof d=="string"||typeof d=="number"&&Number.isFinite(d))&&(i[c]=d)}return i}function qh(n,s){return Jh(n,s.boundsSchema)}function Qh(n,s){return Jh(n,s.scopeSchema)}function B0(n,s,i){return[...n].sort((o,c)=>{if(i){if(o.authorization_id===i&&c.authorization_id!==i)return-1;if(c.authorization_id===i&&o.authorization_id!==i)return 1}const d=xi(o,s),m=xi(c,s),g={active:0,pending:1,expired:2,revoked:3,archived:4};return g[d]!==g[m]?g[d]-g[m]:new Date(c.created_at).getTime()-new Date(o.created_at).getTime()})}function D0({item:n,newerProfile:s,revokedSet:i,expandedHash:o,gateCache:c,gateLoading:d,copiedHash:m,revokingHash:g,copyingHash:p,profileConfigCache:y,mode:v,ownerLabel:j,isAdmin:w,onExpand:N,onCopyHash:E,onCopy:k,onRevoke:C,onExtend:T,archivedSet:I,archivingHash:$,onArchive:A,highlightHash:B,needsReapprovalSet:K}){var $e;const V=ec(n,{revokedSet:i}),de=V==="active"&&((K==null?void 0:K.has(n.authorization_id))??!1),Y=jh(n,{revokedSet:i,archivedSet:I}),re=!j&&!!A&&wh(V),G=o===n.authorization_id,D=c[n.authorization_id],ie=V==="active"||V==="pending"||V==="expired",fe=Object.entries(n.frame).filter(([Ee])=>Ee!=="profile"&&Ee!=="path"),Z=y.get(n.profile_id)??null,pe=((($e=Z==null?void 0:Z.approvers)==null?void 0:$e.length)??0)>0,ee=new Map;if(Z!=null&&Z.caps&&v==="team")for(const[Ee,_e]of fe){const he=Z.caps[Ee];he!==void 0&&Number(_e)>he&&ee.set(Ee,{authorized:Number(_e),cap:he})}const W=ee.size>0,O=n.approvers_frozen??[],H=(Z==null?void 0:Z.approvers)??[],S=v==="team"&&O.length>0&&H.length>0&&(O.length!==H.length||O.some(Ee=>!H.includes(Ee))||H.some(Ee=>!O.includes(Ee))),_=Array.from(ee.entries()).map(([Ee,_e])=>`${Ee}: ${_e.authorized} (cap ${_e.cap})`).join(", "),J=Array.from(ee.entries()).map(([Ee,_e])=>`${Ee}: ${_e.authorized} → ${_e.cap}`).join(", "),te=W?pe?ee.size===1?`Above team cap: ${_} — actions require approval`:`Above team cap (${ee.size}): ${_} — actions require approval`:ee.size===1?`Reduced by hard cap: ${J}`:`Reduced by hard cap (${ee.size}): ${J}`:"",ce=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=Sr(n.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 ",n.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,se=B!=null&&n.authorization_id===B;return r.jsxs("div",{className:`card id-card${se?" card-highlight":""}`,style:{marginBottom:0},children:[r.jsx(qs,{profileId:n.profile_id}),r.jsxs("div",{className:"id-body",children:[ke,j&&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:j})]}),r.jsxs("div",{className:"auth-card-header",children:[r.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:n.title||Ce}),r.jsx(A0,{status:V}),de&&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"}),V==="active"&&n.earliest_expiry&&r.jsx($0,{expiresAt:new Date(n.earliest_expiry).getTime()/1e3}),V==="expired"&&(()=>{const Ee=uv(n,V);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:[n.required_domains.map(Ee=>r.jsx(P0,{domain:Ee,attested:n.attested_domains.includes(Ee)},Ee)),n.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:ce,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}),S&&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:()=>k(n),disabled:p===n.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===n.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),fe.length>0&&r.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:fe.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:()=>A(n.authorization_id,!Y),disabled:$===n.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:$===n.authorization_id?Y?"Unarchiving…":"Archiving…":Y?"↩ Unarchive":"⊟ Archive"}),r.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>N(n),children:G?"▲ Hide Details":"▼ Details"})]}),G&&r.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[fe.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:fe.map(([Ee,_e])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:Ee}),r.jsx("dd",{children:String(_e)})]},Ee))})]}),(D==null?void 0:D.context)&&Object.keys(D.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(D.context).map(([Ee,_e])=>r.jsxs("span",{style:{display:"contents"},children:[r.jsx("dt",{children:Ee}),r.jsx("dd",{title:String(_e),children:Wh(Ee,_e,D.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===n.authorization_id?r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):D?r.jsx("div",{className:"gate-content-block",children:r.jsx("div",{className:"gate-content-item",children:r.jsx("div",{className:"gate-content-text",children:D.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(n.created_at).toLocaleString(),n.earliest_expiry&&` · Expires: ${new Date(n.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:n.authorization_id}),r.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>E(n.authorization_id),children:m===n.authorization_id?"copied":"copy"})]}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!j&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>k(n),disabled:p===n.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:p===n.authorization_id?"Copying…":"⧉ Copy"}),!j&&(V==="active"||V==="pending")&&r.jsx("button",{className:de?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>k(n,{asEdit:!0}),disabled:p===n.authorization_id,title:de?"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:de?"⚠ Re-approve":"✎ Edit"}),!j&&ie&&r.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>T(n),children:"↻ Extend"}),j&&w&&V!=="revoked"?r.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>C(n.authorization_id,j,Ce),disabled:g===n.authorization_id,children:g===n.authorization_id?"Revoking…":"Revoke"}):!j&&(V==="active"||V==="pending")?r.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>C(n.authorization_id),disabled:g===n.authorization_id,children:g===n.authorization_id?"Revoking…":"Revoke"}):null]})]})]})]},n.authorization_id)}function U0(){const[n,s]=f.useState([]),[i,o]=f.useState(!0),[c,d]=f.useState([]),[m,g]=f.useState(!1),[p,y]=f.useState(new Map),[v,j]=f.useState("mine"),[w,N]=f.useState("active"),[E,k]=f.useState(null),[C,T]=f.useState(null),[I,$]=Ql(),[A,B]=f.useState(()=>I.get("new")==="1"),[K]=f.useState(()=>I.get("profile")),[V,de]=f.useState(()=>I.get("highlight")),[Y,re]=f.useState(null),[G,D]=f.useState({}),[ie,fe]=f.useState(null),[Z,pe]=f.useState(null),[ee,W]=f.useState(null),[O,H]=f.useState(new Set),[S,_]=f.useState(null),[J,te]=f.useState(new Set),[ce,ve]=f.useState(null),[Ce,ke]=f.useState(null),[se,$e]=f.useState(new Set),Ee=dn(),{group:_e,groupId:he,domain:X,mode:we,activeTeam:Te}=vt(),Le=(Te==null?void 0:Te.isAdmin)===!0,[lt,xt]=f.useState(()=>new Map),Ke=f.useCallback(()=>{o(!0),M.getMyAttestations().then(s).catch(()=>{}).finally(()=>o(!1))},[]),et=f.useCallback(()=>{M.getArchivedMandates().then(ae=>te(new Set(ae))).catch(()=>{})},[]);f.useEffect(()=>{et()},[et]);const st=f.useCallback(()=>{M.getEnrichedAuthorizations().then(ae=>$e(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 M.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&&(g(!0),M.listTeamAuthorizations(he).then(d).catch(()=>{}).finally(()=>g(!1)))},[he]);He("attestation-changed",()=>{Ke(),Le&&he&&Fe(),st()}),f.useEffect(()=>{if(!V)return;I.get("highlight")&&(I.delete("highlight"),$(I,{replace:!0}));const ae=window.setTimeout(()=>de(null),3e3);return()=>window.clearTimeout(ae)},[]),Zt(Ke,3e5),f.useEffect(()=>{v==="team"&&Le&&he&&c.length===0&&!m&&Fe()},[v,Le,he,c.length,m,Fe]),f.useEffect(()=>{let ae=!1;return M.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 Dt=ge(Je.id),Xn=ze.get(Dt);(!Xn||Me(Je.id).localeCompare(Me(Xn.id),void 0,{numeric:!0})>0)&&ze.set(Dt,Je)}y(ze)}).catch(()=>{}),()=>{ae=!0}},[]);const L=f.useCallback(ae=>{const je=Dt=>Dt.replace(/@.*$/,"").split("/").pop()??Dt,ge=Dt=>Dt.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"?n: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)M.getTeamProfileConfig(he,ge).then(Me=>{xt(ze=>new Map(ze).set(ge,Me))}).catch(()=>{})}},[n,c,v,he,we,lt]);const oe=async ae=>{if(Y===ae.authorization_id){re(null);return}re(ae.authorization_id);const je=ae.authorization_id;if(!(je in G)){fe(ae.authorization_id);try{const ge=await M.getGateContent(je);D(Me=>({...Me,[je]:ge}))}catch{D(ge=>({...ge,[je]:null}))}finally{fe(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=G[Me]??null;Me in G||(ze=await M.getGateContent(Me),D(wn=>({...wn,[Me]:ze})));const Je=Object.fromEntries(Object.entries(ae.frame).filter(([wn])=>wn!=="profile"&&wn!=="path")),Dt=(ze==null?void 0:ze.context)??{},Xn=((ge=ze==null?void 0:ze.gateContent)==null?void 0:ge.intent)??"",ts=ae.deferred_commitment_domains.length>0?"review":"automatic",Xs=ae.attested_domains[0]||X||"owner",xn=Date.parse(ae.created_at),Zn=ae.earliest_expiry?Date.parse(ae.earliest_expiry):NaN,er=Number.isFinite(xn)&&Number.isFinite(Zn)&&Zn>xn?Math.round((Zn-xn)/1e3):void 0;let Zs=ae.profile_id,Pn=Je,tr=Dt,nr;const ns=await M.listProfiles(),kr=Yh(ae.profile_id,ns);if(kr&&kr.id!==ae.profile_id){const wn=await M.getProfile(kr.id);Zs=kr.id,Pn=qh(Je,wn),tr=Qh(Dt,wn),nr=ae.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Zs,groupId:he,groupName:(_e==null?void 0:_e.name)??null,domain:Xs,isPersonal:!!(_e!=null&&_e.isPersonal),upgradedFromProfileId:nr})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:Pn,context:tr,gateContent:{intent:Xn},templateMode:ts,templateTtl:er})),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)}},ue=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)){_(ae);try{await M.revokeAttestation(ae),H(ze=>new Set(ze).add(ae)),M.resyncGates().catch(()=>{}),je&&he&&Fe()}catch(ze){alert(ze instanceof Error?ze.message:"Failed to revoke mandate")}finally{_(null)}}},Oe=v==="mine"?n:c,Ge=v==="mine"?i:m,Ye=v==="mine"?{revokedSet:O,archivedSet:J}:{revokedSet:O},ft=ae=>xi(ae,Ye),fn={active:0,pending:0,expired:0,revoked:0,archived:0};for(const ae of Oe)fn[ft(ae)]+=1;const vn=v==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],tt=(()=>{const ae=new Map;for(const je of Oe){if(ft(je)!==w)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=B0(Oe.filter(ae=>{if(ft(ae)!==w||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,V),Et={revokedSet:O,expandedHash:Y,gateCache:G,gateLoading:ie,copiedHash:ee,revokingHash:S,copyingHash:Ce,profileConfigCache:lt,mode:we,activeDomain:X,group:_e,groupId:he,onExpand:oe,onCopyHash:me,onCopy:Re,onRevoke:ue,onExtend:pe,highlightHash:V},wt={...Et,archivedSet:J,archivingHash:ce,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:()=>B(!0),children:"+ New mandate"})]}),A&&r.jsx("div",{className:"modal-backdrop",onClick:()=>{B(!1),(I.get("new")||I.get("profile"))&&(I.delete("new"),I.delete("profile"),$(I,{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:()=>{B(!1),(I.get("new")||I.get("profile"))&&(I.delete("new"),I.delete("profile"),$(I,{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(R0,{onDismiss:()=>B(!1),preselectProfileId:K})]})]})}),Le&&r.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[r.jsx("button",{className:`nav-tab${v==="mine"?" active":""}`,onClick:()=>{j("mine"),N("active"),k(null),T(null),re(null)},children:"Mine"}),r.jsx("button",{className:`nav-tab${v==="team"?" active":""}`,onClick:()=>{j("team"),N("active"),k(null),T(null),re(null)},children:"Team"})]}),r.jsx("div",{className:"nav-tabs",children:vn.map(ae=>r.jsxs("button",{className:`nav-tab${w===ae?" active":""}`,onClick:()=>{N(ae),k(null),T(null)},children:[ae.charAt(0).toUpperCase()+ae.slice(1)," (",fn[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:()=>k(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(qr,{icon:"☰",title:"No mandates",text:w==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${w} 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(D0,{item:ae,newerProfile:L(ae.profile_id),ownerLabel:ge,isAdmin:Le,...v==="mine"?wt:Et},ae.authorization_id)})}),Z&&r.jsx(O0,{item:Z,onClose:()=>pe(null),onSuccess:()=>{pe(null),Ke()}})]})}const W0=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function es(n){const s=n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)}function dc(n){const s=n.indexOf("__");return s<0?{integrationId:"",toolName:n}:{integrationId:n.slice(0,s),toolName:n.slice(s+2)}}function H0(n){const{integrationId:s,toolName:i}=dc(n);return s?`${s} · ${i}`:i}function Xh(n,s){const i=s==null?void 0:s.find(o=>o.id===n);return i!=null&&i.name?i.name:n?n.toUpperCase():"the system"}function V0(n){return Array.isArray(n)?"list":n&&typeof n=="object"?"object":typeof n=="string"&&(n.includes(`
80
+ `)||n.length>120)?"markdown":"text"}function G0(n,s){var m,g;const i=(s==null?void 0:s.approvalView)??{},o=((m=s==null?void 0:s.inputSchema)==null?void 0:m.properties)??{},c=[...new Set([...Object.keys(i),...Object.keys(o),...Object.keys(n)])],d=[];for(const p of c){if(!(p in n)||W0.has(p))continue;const y=n[p],v=i[p]??{},j=v.kind??V0(y),w={key:p,label:v.label??es(p),kind:j,value:y,hint:(g=o[p])==null?void 0:g.description};j==="money"&&v.currencyArg&&typeof n[v.currencyArg]=="string"&&(w.currency=n[v.currencyArg]),j==="profile"&&typeof y=="string"&&(w.profileRef=y),(j==="profile-limits"||j==="profile-scope")&&v.profileArg&&typeof n[v.profileArg]=="string"&&(w.profileRef=n[v.profileArg]),d.push(w)}return d}function Zh(n,s){var o,c;const i=(c=(o=s==null?void 0:s.scopeSchema)==null?void 0:o.fields)==null?void 0:c[n];return i?{label:i.displayName??n,hint:i.description}:{label:n}}function K0(n,s,i){if(!n||typeof n!="object"||Array.isArray(n))return[];const o=i==="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(n)])],m=[];for(const g of d){if(g==="profile"||!(g in n))continue;const p=n[g],y=c[g],v=lc(y==null?void 0:y.unit),j=Array.isArray(p)?p.join(", "):String(p);m.push({key:g,label:(y==null?void 0:y.displayName)??es(g),value:v?`${j} ${v}`:j,hint:y==null?void 0:y.description,unknown:s?!y:void 0})}return m}function Y0(n){const s=n.indexOf("__");return s<0?{integrationId:"",toolName:n}:{integrationId:n.slice(0,s),toolName:n.slice(s+2)}}function J0(n,s){var p,y,v;const{integrationId:i,toolName:o}=Y0(n.action),c=s.find(j=>j.id===i),d=(y=(p=c==null?void 0:c.toolGating)==null?void 0:p.overrides)==null?void 0:y[o];if(d!=null&&d.actionLabel)return d.actionLabel;const m=dt(n.profileId),g=(v=n.executionContext)==null?void 0:v.action_type;return typeof g=="string"&&g?`${m} · ${g}`:`${m} · ${o}`}function q0(n,s){var c;const i=(c=s==null?void 0:s.scopeSchema)==null?void 0:c.fields;if(!i)return"";const o=[];for(const[d,m]of Object.entries(n.executionContext??{})){if(!(d in i))continue;const g=String(m??"").trim();g&&o.push(g.split(",").map(p=>p.trim()).filter(Boolean).join(", "))}return o.join(" · ")}function Q0(n,s){var c,d;if(!n)return"";const i=((c=s==null?void 0:s.scopeSchema)==null?void 0:c.fields)??{},o=[];for(const[m,g]of Object.entries(n)){if(m==="action_type")continue;const p=String(g??"").trim();if(!p)continue;const y=((d=i[m])==null?void 0:d.displayName)??m;o.push(`${y} ${p.split(",").map(v=>v.trim()).filter(Boolean).join(", ")}`)}return o.join(" · ")}function Rf(n){return n.appliesTo}function X0(n,s,i){var g,p,y,v;const o=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],c=n.actionType??(typeof((g=n.executionContext)==null?void 0:g.action_type)=="string"?n.executionContext.action_type:void 0),d=(p=i==null?void 0:i.boundsSchema)==null?void 0:p.fields,m=[];for(const{window:j,label:w}of o){const N=(y=n.cumulativeState)==null?void 0:y[j];if(!N)continue;let E;if(d&&s){const T=Object.entries(d).filter(([A,B])=>{if(!(A in s))return!1;const K=B.boundType;if(!K||K.kind!=="cumulative_sum"&&K.kind!=="cumulative_count"||K.window!==j)return!1;const V=Rf(B);return!V||!c||V.includes(c)}),$=(c?T.find(([,A])=>{var B;return(B=Rf(A))==null?void 0:B.includes(c)}):void 0)??(T.length===1?T[0]:void 0);$&&(E={key:$[0],isAmount:((v=$[1].boundType)==null?void 0:v.kind)==="cumulative_sum"})}const k=E?E.isAmount?N.amount:N.count:void 0,C=E?Number(s==null?void 0:s[E.key]):NaN;E&&Number.isFinite(C)?m.push(`${k} of ${C} ${w}`):m.push(`${N.count} ${N.count===1?"call":"calls"} ${w}`)}return m.join(" · ")}function Z0(n,s,i){var d;const o=(d=i==null?void 0:i.boundsSchema)==null?void 0:d.fields;if(!n||!s||!o)return[];const c=[];for(const[m,g]of Object.entries(o)){const p=g.boundType;if(!p||p.kind!=="per_transaction")continue;const y=p.of;if(!(y in n)||!(m in s))continue;const v=Number(n[y]),j=Number(s[m]);if(!Number.isFinite(v)||!Number.isFinite(j))continue;const w=lc(g.unit),N=g.displayName??es(y),E=k=>w?`${k.toLocaleString()} ${w}`:k.toLocaleString();c.push({key:m,label:N,ok:v<=j,valueText:E(v),limitText:E(j)})}return c}function ew(n){return typeof n.proposalId=="string"&&n.proposalId.length>0}function tw(n){const s=dt(n),i=n.split("@")[1];return i?`${s}@${i}`:s}const If=new Map;function nw(n){let s=If.get(n);return s||(s=(async()=>{try{let i=n;if(!n.includes("@")){const o=await M.listProfiles(),c=m=>m.replace(/@.*$/,"").split("/").pop(),d=o.filter(m=>c(m.id)===n).sort((m,g)=>(g.id.split("@")[1]??"").localeCompare(m.id.split("@")[1]??"",void 0,{numeric:!0}));if(!d[0])return null;i=d[0].id}return await M.getProfile(i)}catch{return null}})(),If.set(n,s)),s}function Qs(n){const[s,i]=f.useState(null);return f.useEffect(()=>{let o=!0;return n&&nw(n).then(c=>{o&&i(c)}),()=>{o=!1}},[n]),s}async function Af(n){const s=new TextEncoder().encode(n),i=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(i)).map(o=>o.toString(16).padStart(2,"0")).join("")}function rw(n){return n.normalize("NFC").replace(/\r\n?/g,`
81
+ `).split(`
82
+ `).map(c=>c.replace(/[ \t]+$/,"")).join(`
83
+ `).replace(/\n+$/,"")}function Ll(n){if(n===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof n=="number"&&!Number.isFinite(n))throw new Error(`canonicalize: ${n} is not a valid JSON number`);if(n===null||typeof n!="object")return JSON.stringify(n);if(Array.isArray(n))return"["+n.map(c=>c===void 0?"null":Ll(c)).join(",")+"]";const s=n,i=[];for(const o of Object.keys(s).sort()){const c=s[o];c!==void 0&&i.push(JSON.stringify(o)+":"+Ll(c))}return"{"+i.join(",")+"}"}async function em(n,s){if(n==="jcs"){if(typeof s=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await Af(Ll(s))}`}if(typeof s!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await Af(rw(s))}`}function vr(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Rn(n,s=!1){return n==null?"—":typeof n=="string"?n:typeof n=="boolean"?String(n):typeof n=="number"?s||Number.isInteger(n)?String(n):String(Math.round(n*100)/100):"—"}function sw(n){return n==null?!1:typeof n=="string"||Array.isArray(n)?n.length>0:!0}function Ws(n,s,i){const o=s?Object.keys(s).filter(c=>c in n):Object.keys(n);return o.length===0?"—":o.map(c=>{var p,y;const d=n[c],m=((p=s==null?void 0:s[c])==null?void 0:p.title)??es(c),g=vr(d)?Ws(d,(y=s==null?void 0:s[c])==null?void 0:y.properties,i):Rn(d,i);return`${m}: ${g}`}).join(" · ")}function aw(n){return n.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 iw(n,s){var c;if(Array.isArray(n)){if(n.length===0)return{value:"—"};if(n.every(y=>!vr(y)&&!Array.isArray(y))){if(n.every(j=>typeof j=="string"))return{lines:n};const y=n.map(j=>Rn(j)).join(", "),v=n.map(j=>Rn(j,!0)).join(", ");return v===y?{value:y}:{value:y,valueTitle:v}}const d=(c=s==null?void 0:s.items)==null?void 0:c.properties,m=n.map(y=>vr(y)?Ws(y,d,!1):Rn(y)),g=n.map(y=>vr(y)?Ws(y,d,!0):Rn(y,!0)),p=m.map((y,v)=>y===g[v]?void 0:g[v]);return p.some(y=>y!==void 0)?{lines:m,lineTitles:p}:{lines:m}}if(vr(n)){const d=s==null?void 0:s.properties,m=d?Object.keys(d).filter(y=>y in n):Object.keys(n);if(m.length>0&&m.every(y=>!vr(n[y])&&!Array.isArray(n[y])))return{sublist:m.map(v=>{var k;const j=n[v],w=((k=d==null?void 0:d[v])==null?void 0:k.title)??es(v),N=Rn(j),E=Rn(j,!0);return E===N?{key:v,label:w,value:N}:{key:v,label:w,value:N,valueTitle:E}})};const g=Ws(n,d,!1),p=Ws(n,d,!0);return p===g?{value:g}:{value:g,valueTitle:p}}if(typeof n=="string"&&(s==null?void 0:s.contentMediaType)==="text/x-diff")return{diffLines:aw(n)};const i=Rn(n),o=Rn(n,!0);return o===i?{value:i}:{value:i,valueTitle:o}}function ow(n){let s;try{s=JSON.parse(n)}catch{return null}return vr(s)?s:null}function ki(n){const s=n!=null&&n.structured&&Object.keys(n.structured).length>0?n.structured:void 0;if(s)return{obj:s,schema:n==null?void 0:n.outputSchema};const i=n!=null&&n.text?ow(n.text):null;return i?{obj:i}:null}function $l(n){const s=ki(n);if(!s)return[];const{obj:i,schema:o}=s,c=(o==null?void 0:o.properties)??{},d=[...new Set([...Object.keys(c),...Object.keys(i)])],m=[];for(const g of d){if(!(g in i))continue;const p=c[g],y=(p==null?void 0:p.title)??es(g),v={key:g,label:y,...iw(i[g],p)};p!=null&&p.description&&(v.description=p.description),m.push(v)}return m}function zl(n,s){const i=ki(n);if(i){const c=$l(n),d=s==null?void 0:s.fields;let m;if(d&&d.length>0){const y=new Map(c.map(v=>[v.key,v]));m=d.map(v=>y.get(v)).filter(v=>v!==void 0)}else m=c.filter(y=>sw(i.obj[y.key]));const g=new Set(m.map(y=>y.key)),p=c.filter(y=>!g.has(y.key));return{kind:"structured",fields:m,moreFields:p,totalFields:c.length}}const o=n==null?void 0:n.text;return o&&o.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:o}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function Pf(n){return n?n.lines?`lines:${JSON.stringify(n.lines)}`:n.sublist?`sublist:${JSON.stringify(n.sublist.map(s=>[s.key,s.value]))}`:n.diffLines?`diffLines:${JSON.stringify(n.diffLines)}`:`value:${n.value??""}`:""}function di(n){return{kind:n.length>0?"structured":"empty",fields:n,moreFields:[],totalFields:n.length}}function lw(n,s,i){const o=ki(n),c=ki(s);if(!o&&!c){const w=(n==null?void 0:n.text)??"",N=(s==null?void 0:s.text)??"";return w===N?{approved:di([]),current:di([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:w},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:N},unchanged:!1}}const d=new Map($l(n).map(w=>[w.key,w])),m=new Map($l(s).map(w=>[w.key,w])),p=[...new Set([...d.keys(),...m.keys()])].filter(w=>w===(i==null?void 0:i.excludeKey)?!1:Pf(d.get(w))!==Pf(m.get(w))),y=i!=null&&i.fields&&i.fields.length>0?[...i.fields.filter(w=>p.includes(w)),...p.filter(w=>!i.fields.includes(w))]:p,v=y.map(w=>d.get(w)).filter(w=>w!==void 0),j=y.map(w=>m.get(w)).filter(w=>w!==void 0);return{approved:di(v),current:di(j),unchanged:p.length===0}}function cw(n){return n.offDevice?"off-device":n.boundContent===void 0?"none":n.hasHashToCheck?n.hashVerified===!0?"verified":"mismatch":"unchecked"}function uw(n,s){return n===void 0?{kind:"empty",fields:[],moreFields:[],totalFields:0}:typeof n=="string"?zl({text:n}):zl({structured:n},{fields:s})}function dw(n,s){return n?Object.entries(n).filter(([,i])=>i!=null&&i!=="").map(([i,o])=>({key:i,label:Zh(i,s).label,value:String(o)})):[]}function fw({row:n}){return r.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[n.label,n.description&&r.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:n.description})]})}function hw({row:n}){return n.sublist?r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:n.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))}):n.diffLines?r.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:n.diffLines.map((s,i)=>r.jsx("div",{style:s.kind==="remove"?{color:"var(--danger)",textDecoration:"line-through"}:s.kind==="add"?{color:"var(--success)"}:void 0,children:s.text||" "},i))}):n.lines?r.jsx("div",{children:n.lines.map((s,i)=>{var o;return r.jsx("div",{title:(o=n.lineTitles)==null?void 0:o[i],children:s},i)})}):r.jsx("span",{title:n.valueTitle,children:n.value})}function _f({rows:n}){return r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:n.map(s=>r.jsxs(f.Fragment,{children:[r.jsx(fw,{row:s}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:r.jsx(hw,{row:s})})]},s.key))})}function gi({rendered:n}){return n.kind==="empty"?r.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):n.kind==="text"?r.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:n.text}):r.jsxs(r.Fragment,{children:[r.jsx(_f,{rows:n.fields}),n.moreFields.length>0&&r.jsxs("details",{style:{fontSize:"0.8rem"},children:[r.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",n.totalFields,")"]}),r.jsx(_f,{rows:n.moreFields})]})]})}function tm({receipt:n,profile:s}){var w;const[i,o]=f.useState(void 0),[c,d]=f.useState(null),m=!!(n.contentHash&&n.contentBinding);if(f.useEffect(()=>{let N=!0;return o(void 0),d(null),(async()=>{let E;try{E=await M.getArchivedReceipt(n.id)}catch{N&&o(null);return}let k=null;const C=E==null?void 0:E.entry.boundContent;if(C!==void 0&&m)try{k=await em(n.contentBinding.kind,C)===n.contentHash}catch{k=!1}N&&(d(k),o(E))})(),()=>{N=!1}},[n.id,n.contentHash,n.contentBinding,m]),i===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 g=i===null,p=i==null?void 0:i.entry.boundContent,y=cw({offDevice:g,boundContent:p,hasHashToCheck:m,hashVerified:c});if(y==="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(y==="none"){const N=dw(n.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=uw(p,(w=n.contentBinding)==null?void 0:w.fields),j=y==="verified"?"ticket-done-verified":y==="mismatch"?"ticket-done-mismatch":"ticket-done-unchecked";return r.jsxs("div",{className:`ticket-done-box ${j}`,"data-testid":"ticket-what-was-done","data-bound":y,children:[r.jsxs("h4",{children:["What was done",y!=="unchecked"&&r.jsxs(r.Fragment,{children:[" ",r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]})]}),r.jsx(gi,{rendered:v}),y==="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."}),y==="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."}),y==="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 Ms({label:n,children:s}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{className:"receipt-row-label",children:n}),r.jsx("dd",{className:"receipt-row-value",children:s})]})}function mw({receipt:n,manifests:s,localAuth:i,localUnavailable:o,signature:c,grantTitle:d,ownerLabel:m,spUrl:g,formatDate:p,onOpenComplete:y}){var I;const v=Qs(n.profileId),j=q0(n,v),w=Q0(i==null?void 0:i.context,v),N=X0(n,(i==null?void 0:i.bounds)??n.limits,v),E=i==null?void 0:i.intent,k=Sr(n.profileId).testSetup||Ti(n.action),[C,T]=f.useState(!1);return r.jsxs("div",{className:"card id-card",style:{marginBottom:0},children:[r.jsx(qs,{profileId:n.profileId}),r.jsxs("div",{className:"id-body",children:[r.jsxs("div",{className:"receipt-head",children:[r.jsx("span",{className:"receipt-what",children:J0(n,s)}),r.jsx("span",{className:"receipt-tag",children:ew(n)?"review":"automatic"}),n.contentHash&&r.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(I=n.contentBinding)!=null&&I.fields?`The ticket binds: ${n.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),k&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),r.jsx("span",{className:"auth-card-time",children:p(n.timestamp)})]}),j&&r.jsx("div",{className:"receipt-scope",children:j}),r.jsx(tm,{receipt:n,profile:v}),r.jsxs("dl",{className:"receipt-rows",children:[r.jsxs(Ms,{label:"mandate",children:[r.jsx("strong",{children:d||tw(n.profileId)})," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),m&&r.jsx(Ms,{label:"owner",children:m}),w&&r.jsxs(Ms,{label:"allowed",children:[w," ",r.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),N&&r.jsxs(Ms,{label:"used",children:[r.jsx("span",{className:"receipt-num",children:N})," ",r.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),r.jsx(Ms,{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:y,children:"Complete ticket"}),g&&r.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",r.jsx("a",{className:"receipt-link",href:`${g}/r/${n.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 · ",n.id]}),r.jsxs("div",{children:["action · ",n.action]}),r.jsxs("div",{children:["profile · ",n.profileId]}),n.authorizationId&&r.jsxs("div",{children:["mandate · ",n.authorizationId]}),Object.keys(n.executionContext??{}).length>0&&r.jsxs("div",{children:["scope ·"," ",Object.entries(n.executionContext).map(([$,A])=>`${$}=${A}`).join(" · ")]}),(i==null?void 0:i.boundsHash)&&r.jsxs("div",{children:["bounds hash · ",i.boundsHash]}),(i==null?void 0:i.contextHash)&&r.jsxs("div",{children:["scope hash · ",i.contextHash]}),n.contentHash&&r.jsxs("div",{children:["content · ",n.contentHash]}),n.proposalId&&r.jsxs("div",{children:["proposal · ",n.proposalId]}),r.jsxs("div",{children:["signature · ",n.signature]})]})]})]})]})}function pw({receipt:n,onClose:s}){const[i,o]=f.useState(null),[c,d]=f.useState(null),[m,g]=f.useState(null),[p,y]=f.useState(!0),[v,j]=f.useState(!1);f.useEffect(()=>{let C=!1;return y(!0),M.getArchivedReceipt(n.id).then(T=>{C||(o(T),d(T?"local":"authority-server"),g((T==null?void 0:T.signature)??null))}).catch(()=>{C||d("authority-server")}).finally(()=>{C||y(!1)}),()=>{C=!0}},[n.id]);const w=i?i.entry:{receipt:n},N=JSON.stringify(w,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-${n.id.slice(0,8)}.json`,T.click(),URL.revokeObjectURL(C)}async function k(){try{await navigator.clipboard.writeText(N),j(!0),setTimeout(()=>j(!1),2e3)}catch{j(!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:[m==="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."}),m==="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."}),m==="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:k,children:v?"Copied":"Copy"})]})]})})}function gw(n){return new Date(n*1e3).toLocaleString()}function yw(n,s){if(s==="all")return!0;const i=s==="1d"?1:s==="7d"?7:30,o=Math.floor(Date.now()/1e3)-i*86400;return n.timestamp>=o}function vw(n,s){if(!s)return!0;const i=s.toLowerCase();return n.profileId.toLowerCase().includes(i)||dt(n.profileId).toLowerCase().includes(i)||n.path.toLowerCase().includes(i)||n.action.toLowerCase().includes(i)||n.attestationHash.toLowerCase().includes(i)||n.id.toLowerCase().includes(i)||JSON.stringify(n.executionContext).toLowerCase().includes(i)}function Lf(n,s){const i=new Map(n.map(o=>[o.id,o]));for(const o of s)i.set(o.id,o);return[...i.values()].sort((o,c)=>c.timestamp-o.timestamp)}function xw(){const{activeTeam:n,groupId:s}=vt(),i=(n==null?void 0:n.isAdmin)===!0,[o,c]=f.useState("mine"),[d,m]=f.useState([]),[g,p]=f.useState([]),[y,v]=f.useState(""),[j,w]=f.useState(!0),[N,E]=f.useState({}),[k,C]=f.useState(new Set),[T,I]=f.useState(""),[$,A]=f.useState(new Set),[B,K]=f.useState(new Set),[V,de]=f.useState("all"),[Y,re]=f.useState(!1),[G,D]=f.useState(!1),[ie,fe]=f.useState(null),[Z,pe]=f.useState({}),[ee,W]=f.useState(!1),[O,H]=f.useState({}),[S,_]=f.useState({}),[J,te]=f.useState(null),[ce,ve]=f.useState(null),[Ce,ke]=f.useState(!1),[se,$e]=f.useState(!1),Ee=f.useRef(""),_e=f.useCallback(L=>o==="team"&&i&&s?M.listTeamReceiptsPage(s,{before:L,limit:200}):M.getMyReceiptsPage({before:L,limit:200}),[o,i,s]),he=f.useCallback(()=>{const L=o==="team"?`team:${s}`:"mine",oe=Ee.current!==L;Ee.current=L,w(!0),$e(!1),_e().then(me=>{m(Re=>oe?me.receipts:Lf(Re,me.receipts)),ve(Re=>oe?me.nextBefore:Re??me.nextBefore)}).catch(()=>{oe&&m([]),$e(!0)}).finally(()=>w(!1))},[_e,o,s]),X=f.useCallback(()=>{!ce||Ce||(ke(!0),$e(!1),_e(ce).then(L=>{m(oe=>Lf(oe,L.receipts)),ve(L.nextBefore)}).catch(()=>$e(!0)).finally(()=>ke(!1)))},[ce,Ce,_e]);Zt(he,12e4),f.useEffect(()=>{M.getIntegrationManifests().then(({manifests:L})=>p(L)).catch(()=>{}),fetch("/health").then(L=>L.json()).then(L=>{typeof L.spUrl=="string"&&v(L.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),f.useEffect(()=>{M.getLocalAuthorizations().then(({authorizations:L,signatures:oe})=>{pe(L),H(oe),W(!1)}).catch(()=>{pe({}),H({}),W(!0)}),M.getMyAttestations().then(L=>{const oe={};for(const me of L)me.authorization_id&&me.title&&(oe[me.authorization_id]=me.title);_(oe)}).catch(()=>{})},[]),f.useEffect(()=>{o!=="team"||Object.keys(N).length>0||M.listUsers().then(L=>{const oe={};for(const me of L)oe[me.id]={name:me.name,email:me.email};E(oe)}).catch(()=>{})},[o,N]);const we=f.useMemo(()=>{const L=new Set;for(const oe of d)L.add(dt(oe.profileId));return[...L].sort()},[d]),Te=f.useMemo(()=>{const L=new Set;for(const oe of d)L.add(oe.action);return[...L].sort()},[d]),Le=f.useMemo(()=>{if(o!=="team")return[];const L=new Set;for(const oe of d)oe.userId&&L.add(oe.userId);return[...L].map(oe=>{var me;return{id:oe,label:(me=N[oe])!=null&&me.name?`${N[oe].name} (${N[oe].email})`:oe}}).sort((oe,me)=>oe.label.localeCompare(me.label))},[o,d,N]),lt=f.useMemo(()=>d.filter(L=>!(!vw(L,T)||$.size>0&&!$.has(dt(L.profileId))||B.size>0&&!B.has(L.action)||k.size>0&&L.userId&&!k.has(L.userId)||!yw(L,V))),[d,T,$,B,k,V]),xt=$.size>0||B.size>0||k.size>0||V!=="all";function Ke(L){A(oe=>{const me=new Set(oe);return me.has(L)?me.delete(L):me.add(L),me})}function et(L){K(oe=>{const me=new Set(oe);return me.has(L)?me.delete(L):me.add(L),me})}function st(L){C(oe=>{const me=new Set(oe);return me.has(L)?me.delete(L):me.add(L),me})}function mt(){A(new Set),K(new Set),C(new Set),de("all"),I("")}async function Fe(){D(!0),fe(null);try{const{bundle:L,filename:oe}=await M.fetchEvidenceBundle(),me=URL.createObjectURL(new Blob([JSON.stringify(L,null,2)],{type:"application/json"})),Re=document.createElement("a");Re.href=me,Re.download=oe,Re.click(),URL.revokeObjectURL(me);const ue=L.sources??{};ue.authorityServer?ue.local||fe(`Downloaded Authority Server history only — ${ue.localError??"local archive unavailable."}`):fe(`Downloaded local evidence only — ${ue.asError??"Authority Server export unavailable."}`)}catch(L){fe(`Export failed: ${L instanceof Error?L.message:String(L)}`)}finally{D(!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:G,children:G?"Preparing…":"Download evidence"})]}),ie&&r.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:ie}),i&&r.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(L=>r.jsx("button",{onClick:()=>c(L),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:o===L?"2px solid var(--accent)":"2px solid transparent",color:o===L?"var(--text-primary)":"var(--text-tertiary)",fontWeight:o===L?600:500},children:L==="mine"?"Mine":"Team"},L))}),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:L=>I(L.target.value)}),T&&r.jsx("button",{className:"search-clear",onClick:()=>I(""),children:"×"})]}),r.jsxs("button",{className:`btn btn-sm btn-secondary${Y?" active":""}`,onClick:()=>re(!Y),children:["Filters",xt?` (${$.size+B.size+(V!=="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(L=>r.jsx("button",{className:`filter-chip${$.has(L)?" selected":""}`,onClick:()=>Ke(L),children:L},L))})]}),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(L=>r.jsx("button",{className:`filter-chip${B.has(L)?" selected":""}`,onClick:()=>et(L),children:L},L))})]}),o==="team"&&Le.length>1&&r.jsxs("div",{className:"filter-section",children:[r.jsx("div",{className:"filter-label",children:"Owner"}),r.jsx("div",{className:"filter-chips",children:Le.map(L=>r.jsx("button",{className:`filter-chip${k.has(L.id)?" selected":""}`,onClick:()=>st(L.id),children:L.label},L.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(([L,oe])=>r.jsx("button",{className:`filter-chip${V===L?" selected":""}`,onClick:()=>de(L),children:oe},L))})]})]}),xt&&r.jsxs("div",{className:"active-filters",children:[[...$].map(L=>r.jsxs("span",{className:"active-chip",onClick:()=>Ke(L),children:[L," ",r.jsx("span",{className:"chip-remove",children:"×"})]},L)),[...B].map(L=>r.jsxs("span",{className:"active-chip",onClick:()=>et(L),children:[L," ",r.jsx("span",{className:"chip-remove",children:"×"})]},L)),[...k].map(L=>{const oe=N[L],me=oe?oe.name:L;return r.jsxs("span",{className:"active-chip",onClick:()=>st(L),children:[me," ",r.jsx("span",{className:"chip-remove",children:"×"})]},L)}),V!=="all"&&r.jsxs("span",{className:"active-chip",onClick:()=>de("all"),children:[V==="1d"?"Today":V==="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."})}),j&&d.length===0?r.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):lt.length===0?r.jsx(qr,{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(L=>{const oe=L.userId?N[L.userId]:void 0;return r.jsx("div",{className:"timeline-event",children:r.jsx(mw,{receipt:L,manifests:g,localAuth:L.authorizationId?Z[L.authorizationId]:void 0,localUnavailable:ee,signature:O[L.id],grantTitle:L.authorizationId?S[L.authorizationId]:null,ownerLabel:o==="team"&&L.userId?oe?`${oe.name} (${oe.email})`:L.userId:null,spUrl:y,formatDate:gw,onOpenComplete:()=>te(L)})},L.id)})})]}),J&&r.jsx(pw,{receipt:J,onClose:()=>te(null)}),ce&&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 ww(){const[n,s]=f.useState(null),[i,o]=f.useState({}),[c,d]=f.useState(!1),m=f.useCallback(()=>{M.getDenials({limit:200}).then(({records:p})=>{s(p),d(!1)}).catch(()=>d(!0))},[]);if(f.useEffect(()=>{m()},[m]),Zt(m,6e4),f.useEffect(()=>{if(!n)return;const p=[...new Set(n.map(y=>y.profile).filter(y=>!!y))].filter(y=>!(y in i));p.length!==0&&Promise.all(p.map(y=>M.getProfile(y).catch(()=>null))).then(y=>{o(v=>{const j={...v};return p.forEach((w,N)=>{y[N]&&(j[w]=y[N])}),j})})},[n,i]),c)return r.jsx(qr,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(n===null)return null;const g=Nh(n,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:[g," today · nothing ran"]})]}),n.length===0?r.jsx(qr,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):r.jsx("div",{className:"blocked-list",children:n.map((p,y)=>{const v=Rv(p,p.profile?i[p.profile]:void 0);return r.jsxs("div",{className:"blocked-row","data-kind":Gs(p),children:[r.jsx("span",{className:`blocked-dot blocked-dot-${Gs(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}-${y}`)})})]})}const jw={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function Sw(){const[n,s]=f.useState(null),[i,o]=f.useState(!1),[c,d]=f.useState(null),m=f.useCallback(async()=>{try{s(await M.getAutostart())}catch(y){d(y instanceof Error?y.message:"Could not read autostart state")}},[]);f.useEffect(()=>{m()},[m]);const g=f.useCallback(async()=>{if(!(!(n!=null&&n.supported)||i)){o(!0),d(null);try{await M.setAutostart(!n.installed)}catch(y){d(y instanceof Error?y.message:"Failed")}finally{try{s(await M.getAutostart()),d(null)}catch(y){d(y instanceof Error?y.message:"Could not re-read state")}o(!1)}}},[n,i,m]);if(!n)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=jw[n.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:n.supported?r.jsxs(r.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",p," — no admin rights needed."]}):n.reason})]}),n.supported&&r.jsx("button",{type:"button",onClick:()=>void g(),disabled:i,"aria-pressed":n.installed,className:n.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:i?"Working…":n.installed?"Turn off":"Turn on"})]}),n.supported&&r.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",r.jsx("strong",{children:n.installed?"On — starts from your next login":"Off"})]}),n.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 kw(){const[n,s]=f.useState(null),[i,o]=f.useState(!1),[c,d]=f.useState(null),m=f.useCallback(async()=>{try{const p=await M.getGatewaySettings();s(p.desktopNotifications),d(null)}catch(p){d(p instanceof Error?p.message:"Could not read notification setting")}},[]);f.useEffect(()=>{m()},[m]);const g=f.useCallback(async()=>{if(!(n===null||i)){o(!0),d(null);try{const p=await M.setGatewaySettings({desktopNotifications:!n});s(p.desktopNotifications)}catch(p){d(p instanceof Error?p.message:"Failed to save"),await m()}finally{o(!1)}}},[n,i,m]);return n===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 g(),disabled:i,"aria-pressed":n,className:n?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:i?"Saving…":n?"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 $f={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function bw(){const[n,s]=f.useState(null),[i,o]=f.useState(!1),[c,d]=f.useState(null),m=f.useCallback(async()=>{try{s(await M.getIdentityDisclosure()),d(null)}catch(v){d(v instanceof Error?v.message:"Could not read the setting")}},[]);f.useEffect(()=>{m()},[m]);const g=f.useCallback(async()=>{if(!(!n||i)){o(!0),d(null);try{s(await M.setIdentityDisclosure(!n.always))}catch(v){d(v instanceof Error?v.message:"Failed to save"),await m()}finally{o(!1)}}},[n,i,m]),p=r.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!n)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 y=n.verified&&n.name?`${n.name} — ${n.method==="as_vouched"?`${$f.as_vouched} ${n.verifier}`:$f[n.method??""]??n.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:[n.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:y?`Your identity: ${y}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),r.jsx("button",{type:"button",onClick:()=>void g(),disabled:i,"aria-pressed":n.always,className:n.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:i?"Saving…":n.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 Nw={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 Cw(){const{version:n,latestVersion:s,updateAvailable:i,installMethod:o}=Xl();return n?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:n}),i&&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:[Nw[o]??"Update checking is unavailable",o==="dev"&&r.jsx(r.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Fl({title:n}){return r.jsxs("span",{className:"it-locked-badge",title:n,children:[r.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function zf(n){return n===!0}function Ew(){const[n,s]=f.useState(null),[i,o]=f.useState(null);f.useEffect(()=>{let m=!1;return M.getAsPairing().then(g=>{m||s(g)}).catch(g=>{m||o(g instanceof Error?g.message:"Could not read Authority Server info")}),()=>{m=!0}},[]);const c=zf(n==null?void 0:n.asUrlLockedByPolicy),d=zf(n==null?void 0:n.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(Fl,{})]}),!n&&!i&&r.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),i&&r.jsx("p",{role:"alert",style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--danger, #c00)"},children:i}),n&&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:n.asUrl})]}),n.paired&&n.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:n.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."}),(n.tlsPinFingerprint||n.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(Fl,{title:"TLS pinning is set by your IT policy"})," ",n.tlsPinFingerprint?r.jsx("code",{children:n.tlsPinFingerprint}):r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",n.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),r.jsx("br",{}),r.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[n.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 Tw(){const{simulation:n,locked:s}=$h();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.',n!==null&&r.jsxs(r.Fragment,{children:[" ","Currently ",r.jsx("strong",{children:n?"ON":"OFF"}),n?" — real systems are not reachable from this gateway.":"."]})]})]}),r.jsx(Fl,{})]}),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",n!==null?` (currently ${n?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const Rw={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"]}},Bs=["AI Assistant","Authority Server","This computer","Security","Version"],Ds={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function Iw(){const[n,s]=f.useState(""),[i,o]=f.useState("openrouter"),[c,d]=f.useState("openai-compatible"),[m,g]=f.useState("https://openrouter.ai/api/v1"),[p,y]=f.useState("google/gemma-4-31b-it"),[v,j]=f.useState(""),[w,N]=f.useState(!1),[E,k]=f.useState(!1),[C,T]=f.useState(!1),[I,$]=f.useState(null),[A,B]=f.useState([]),[K,V]=f.useState(!1),[de,Y]=f.useState(null),[re,G]=f.useState(""),D=f.useCallback(O=>{s(O),setTimeout(()=>s(""),3e3)},[]),ie=f.useCallback(async(O,H,S)=>{V(!0),Y(null);try{const _=await M.aiModels({provider:O,endpoint:H,...S?{apiKey:S}:{}});_.ok&&_.models.length>0?(B(_.models),Y(`${_.models.length} models available`)):(B([]),Y(_.message||"No models returned — using defaults"))}catch(_){B([]),Y(_ instanceof Error?_.message:"Failed to load models")}finally{V(!1)}},[]),fe=f.useCallback(async()=>{try{const O=await M.getCredential("ai-config");if(N(O.configured),O.configured&&O.fields){const H=O.fields.provider||"openai-compatible",S=O.fields.endpoint||"";O.fields.provider&&d(H),O.fields.endpoint&&g(S),O.fields.model&&y(O.fields.model),S.includes("openai.com")?o("openai"):S.includes("groq.com")?o("groq"):S.includes("together.xyz")?o("together"):S.includes("openrouter.ai")?o("openrouter"):o("ollama"),S&&ie(H,S)}}catch{}},[ie]);f.useEffect(()=>{fe()},[fe]);const Z=O=>{o(O),B([]),Y(null),G("");const H=Rw[O];H&&(d(H.provider),g(H.endpoint),y(""),ie(H.provider,H.endpoint,v||void 0))},pe=()=>ie(c,m,v||void 0),ee=async()=>{k(!0);try{await M.setCredential("ai-config",{provider:c,endpoint:m,model:p,...v?{apiKey:v}:{}}),N(!0),D("AI configuration saved!")}catch{D("Failed to save AI config")}finally{k(!1)}},W=async()=>{T(!0),$(null);try{const O=await M.aiTest({provider:c,endpoint:m,model:p,...v?{apiKey:v}:{}});$(O.ok?`OK: ${O.message}`:`Failed: ${O.message}`)}catch(O){$(`Error: ${O instanceof Error?O.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."})]}),n&&r.jsx("div",{className:"alert alert-success",children:n}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ds,children:Bs[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."}),w&&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:i,onChange:O=>Z(O.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:O=>j(O.target.value),onBlur:()=>{v.trim()&&ie(c,m,v.trim())},placeholder:w?"••••••••••••••••":"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:K,title:"Re-fetch the model list from the provider",children:K?"Loading…":"↻ Refresh"})]}),A.length===0?r.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:K?"Loading models…":c==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const O=A,H=O.includes(p),S=O.length>12,_=re.trim().toLowerCase();let J=_?O.filter(te=>te.toLowerCase().includes(_)):O;return H&&!J.includes(p)&&(J=[p,...J]),r.jsxs(r.Fragment,{children:[S&&r.jsx("input",{className:"form-input",value:re,onChange:te=>G(te.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),r.jsxs("select",{className:"form-input",value:H?p:"__unset__",onChange:te=>y(te.target.value==="__unset__"?"":te.target.value),children:[r.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),J.map(te=>r.jsx("option",{value:te,children:te},te)),_&&J.length===0&&r.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",re,"”"]})]})]})})(),de&&r.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:de})]}),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"}),w&&r.jsx("button",{className:"btn btn-ghost",onClick:W,disabled:C,children:C?"Testing...":"Test Connection"})]}),I&&r.jsx("div",{className:`alert ${I.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:I})]}),r.jsx(Aw,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ds,children:Bs[1]}),r.jsx(Ew,{}),r.jsx(bw,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ds,children:Bs[2]}),r.jsx(Sw,{}),r.jsx(kw,{}),r.jsx(Tw,{})]}),r.jsxs("section",{style:{marginBottom:"2rem"},children:[r.jsx("h2",{style:Ds,children:Bs[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:Ds,children:Bs[4]}),r.jsx(Cw,{})]})]})}function Aw(){const[n,s]=f.useState(null),[i,o]=f.useState({intent:"",context:""}),[c,d]=f.useState(null),[m,g]=f.useState(null),[p,y]=f.useState(null),[v,j]=f.useState(!1),w=f.useCallback(async()=>{if(!v)try{const k=await M.getAIPrompts();s(k),o({intent:k.intent.current,context:k.context.current}),j(!0)}catch(k){g(k instanceof Error?k.message:"Failed to load prompts")}},[v]),N=async k=>{if(n){d(k),g(null);try{const C=i[k],T=C.trim()===n[k].default.trim()?"":C;await M.setAIPrompt(k,T);const I=await M.getAIPrompts();s(I),o({intent:I.intent.current,context:I.context.current}),y(k),setTimeout(()=>y(null),2e3)}catch(C){g(C instanceof Error?C.message:"Save failed")}finally{d(null)}}},E=async k=>{if(confirm(`Revert ${k} prompt to the built-in default?`)){d(k),g(null);try{await M.setAIPrompt(k,"");const C=await M.getAIPrompts();s(C),o({intent:C.intent.current,context:C.context.current})}catch(C){g(C instanceof Error?C.message:"Revert failed")}finally{d(null)}}};return r.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:k=>{k.currentTarget.open&&w()},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."}),m&&r.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:m}),!v&&!m&&r.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),n&&r.jsxs(r.Fragment,{children:[r.jsx(Ff,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:n.intent,draft:i.intent,onChange:k=>o(C=>({...C,intent:k})),onSave:()=>N("intent"),onRevert:()=>E("intent"),saving:c==="intent",justSaved:p==="intent"}),r.jsx(Ff,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:n.context,draft:i.context,onChange:k=>o(C=>({...C,context:k})),onSave:()=>N("context"),onRevert:()=>E("context"),saving:c==="context",justSaved:p==="context"})]})]})}function Ff({kind:n,label:s,description:i,state:o,draft:c,onChange:d,onSave:m,onRevert:g,saving:p,justSaved:y}){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:i})]}),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:j=>d(j.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:m,disabled:p||!v,children:p?"Saving…":"Save"}),o.overridden&&r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:g,disabled:p,title:"Discard the override and use the built-in default",children:"Revert to default"}),y&&r.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),v&&!p&&!y&&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:n})]})}function Pw(n){return n.proposalId?"review":"automatic"}function Of(n,s,i={}){const o=i.status??"pending",c=i.includeAutonomous??!1,d=[];for(const m of n)o==="pending"&&m.status!=="pending"||i.profile&&m.profileId!==i.profile||d.push({kind:"proposal",id:m.id,sortTimestamp:m.createdAt,commitmentMode:"review",profileId:m.profileId,proposal:m});if(o==="all")for(const m of s){const g=Pw(m);!c&&g==="automatic"||i.profile&&m.profileId!==i.profile||d.push({kind:"receipt",id:m.id,sortTimestamp:m.timestamp,commitmentMode:g,profileId:m.profileId,receipt:m})}return d.sort((m,g)=>g.sortTimestamp-m.sortTimestamp),typeof i.limit=="number"&&i.limit>0?d.slice(0,i.limit):d}const _w=["https://","http://"];function nm(n,s){return n!=null&&n.length?n.flatMap(i=>{const o=i.template.replace(/\{(\w+)\}/g,(c,d)=>{const m=s[d];return typeof m=="string"||typeof m=="number"?String(m):"\0"});return o.includes("\0")||/\{|\}/.test(o)?[]:_w.some(c=>o.toLowerCase().startsWith(c))?[{label:i.label,href:o,description:i.description}]:[]}):[]}function rm(n,s){const i=n-Math.floor(s/1e3);if(i<=0)return{label:"expired",urgent:!1,expired:!0};const o=Math.floor(i/86400),c=Math.floor(i%86400/3600),d=Math.floor(i%3600/60);let m;return o>0?m=`expires in ${o}d ${c}h`:c>0?m=`expires in ${c}h ${d}m`:m=`expires in ${Math.max(1,d)}m`,{label:m,urgent:i<2*3600,expired:!1}}const Lw=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function $w(n,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:Lw.test(n)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function Kr(n){if(n==null)return"—";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);try{return JSON.stringify(n,null,2)}catch{return String(n)}}function Mf({row:n,which:s}){const i=Qs(n.profileRef),o=K0(n.value,i,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 zw({row:n}){const s=Qs(n.profileRef),i=(s==null?void 0:s.id)??n.profileRef??"";return r.jsxs(r.Fragment,{children:[(s==null?void 0:s.name)??dt(i),r.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:i})]})}function Fw({row:n,altText:s}){switch(n.kind){case"profile":return r.jsx(zw,{row:n});case"profile-limits":return r.jsx(Mf,{row:n,which:"limits"});case"profile-scope":return r.jsx(Mf,{row:n,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:Kr(n.value)});case"list":return Array.isArray(n.value)?r.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:n.value.map((i,o)=>r.jsx("li",{children:Kr(i)},o))}):r.jsx(r.Fragment,{children:Kr(n.value)});case"money":return r.jsxs(r.Fragment,{children:[Kr(n.value),n.currency?` ${n.currency}`:""]});case"object":return r.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Kr(n.value)});default:return $w(n.key,n.value)?r.jsx("img",{src:n.value,alt:s??n.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):r.jsx(r.Fragment,{children:Kr(n.value)})}}function sm({args:n,display:s,heading:i="Details"}){const o=G0(n,s);if(o.length===0)return null;const c=typeof n.altText=="string"?n.altText:void 0;return r.jsxs("div",{style:{marginBottom:"0.75rem"},children:[i&&r.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:i}),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(Fw,{row:d,altText:c})})]},d.key))})]})}const Bf=500;function Ol(n){return n.length>Bf?`${n.slice(0,Bf)}…`:n}function Df(n){return n.length?n[0].toUpperCase()+n.slice(1):n}function Uf(n,s){switch(n.status){case"none":return n.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 n.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:n.message?`Preview not available — ${Ol(n.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:n.message?`Not found in your system — ${Ol(n.message)}`:"Not found in your system."};case"ok":{const i=zl(n.body,{fields:n.fields}),o={heading:`From ${s}, before it runs`,note:`Read by the gateway with ${n.tool} when you opened this card — the AI is not involved.`,rendered:i},c=n.version;if(c&&(o.versionNote=`You approve ${c.field} ${c.approved}; if it changes, ${s} refuses it.`,c.stale)){const d=lw(n.body,c.currentBody,{fields:n.fields,excludeKey:c.field});o.stale={heading:`A newer ${c.field} exists (${c.current})`,approvedLabel:`${Df(c.field)} ${c.approved}`,currentLabel:`${Df(c.field)} ${c.current}`,...d.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:d.approved,currentRendered:d.current}}}return o}}}function Ow(n,s){if(n.state!=="failed")return null;const i=n.detail?Ol(n.detail):void 0;return n.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${i?`: ${i}`:""} — nothing was done. Ask the AI to request it again.`}}function Mw(n){return n!==null&&n!=="loading"&&n!=="ok"&&n!=="stale"}function Bw({proposalId:n,systemName:s}){const[i,o]=f.useState(null);if(f.useEffect(()=>{let d=!0;return o(null),M.getProposalOutcome(n).then(m=>{d&&o(m)}).catch(()=>{}),()=>{d=!1}},[n]),!i)return null;const c=Ow(i,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 Dw({proposalId:n,systemName:s,onTone:i}){const[o,c]=f.useState(null),[d,m]=f.useState(!1);if(f.useEffect(()=>{let y=!0;return c(null),m(!1),M.getProposalPreview(n).then(v=>{y&&c(v)}).catch(()=>{y&&m(!0)}),()=>{y=!1}},[n]),f.useEffect(()=>{if(d){i==null||i("unavailable");return}if(!o)return;const y=Uf(o,s);i==null||i(o.status==="ok"?y.stale?"stale":"ok":o.status)},[o,d,s,i]),d)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(!o)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=Uf(o,s),p=o.status==="ok"?g.stale?"stale":"ok":o.status;return p==="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-${p}`,"data-testid":"approval-preview","data-preview-status":p,children:[r.jsx("h4",{children:g.heading}),g.rendered&&r.jsx(gi,{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(gi,{rendered:g.stale.approvedRendered})}),r.jsx("dt",{children:g.stale.currentLabel}),r.jsx("dd",{children:r.jsx(gi,{rendered:g.stale.currentRendered})})]})]})]})}let kl=null;function Uw(){return kl||(kl=M.getEnrichedAuthorizations().then(n=>new Map(n.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),kl}function Ww(n){const[s,i]=f.useState(void 0);return f.useEffect(()=>{let o=!0;if(n)return Uw().then(c=>{o&&i(c.get(n))}),()=>{o=!1}},[n]),s}function Hw(n,s){const[i,o]=f.useState(null),[c,d]=f.useState(!1),[m,g]=f.useState(null);return f.useEffect(()=>{let p=!0;return o(null),g(null),d(!0),(async()=>{var y;try{try{const w=await M.getGateContent(n);if((y=w==null?void 0:w.gateContent)!=null&&y.intent){p&&o(w.gateContent.intent);return}}catch{}const v=await M.getAttestationIntent(n);if(!v){p&&g("Intent not available or you are not an authorized approver.");return}const j=await M.decryptIntent({intentCiphertext:v.intentCiphertext,encryptedKey:v.encryptedKey,approverId:s});p&&o(j)}catch(v){p&&g(v instanceof Error?v.message:"Failed to decrypt intent")}finally{p&&d(!1)}})(),()=>{p=!1}},[n,s]),{intent:i,loading:c,error:m}}async function am(n){if(n.toolArgs)return n.toolArgs;if(!n.content)return null;try{const{plaintext:s}=await M.decryptProposalContent(n.content),i=JSON.parse(s);return typeof i!="object"||i===null||Array.isArray(i)?null:i}catch{return null}}function Vw(n){if(!n.content)return[];const s=new Set([...n.createdBy?[n.createdBy]:[],...n.pendingApprovers??[]]),i=new Set(Object.keys(n.content.keys));return Array.from(s).filter(o=>!i.has(o))}function im(n){return!n.loading&&n.readable}function om(n,s){const i=new Set;if(n.content)for(const o of Object.keys(n.content.keys))i.add(o);else{n.createdBy&&i.add(n.createdBy);for(const o of n.pendingApprovers??[])i.add(o)}return s&&i.add(s),Array.from(i)}async function yi(n){const s=await am(n);if(s)return em("jcs",s)}function Gw(n){var o;const[s,i]=f.useState((n==null?void 0:n.note)??null);return f.useEffect(()=>{let c=!0;if(n!=null&&n.note){i(n.note);return}if(!(n!=null&&n.noteEncrypted)){i(null);return}return i(null),M.decryptProposalContent(n.noteEncrypted).then(({plaintext:d})=>{c&&i(d)}).catch(()=>{c&&i(null)}),()=>{c=!1}},[n==null?void 0:n.note,(o=n==null?void 0:n.noteEncrypted)==null?void 0:o.ciphertext]),s}const Kw={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function lm(n){var o;const[s,i]=f.useState(Kw);return f.useEffect(()=>{let c=!0;if(n.toolArgs){i({toolArgs:n.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!n.content){i({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return i({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const d=await am(n);c&&i({toolArgs:d,loading:!1,sealed:!0,undecryptable:d===null})})(),()=>{c=!1}},[(o=n.content)==null?void 0:o.ciphertext,n.toolArgs]),s}function Wf(n){if(!n||typeof n!="object"||Array.isArray(n))return{};const s={};for(const[i,o]of Object.entries(n))(typeof o=="string"||typeof o=="number")&&(s[i]=o);return s}function Yw(n){const s=Wf(n.limits),i=Wf(n.scope),o=typeof n.intent=="string"?n.intent:"",c={bounds:s,context:i,gateContent:{intent:o}};return(n.mode==="automatic"||n.mode==="review")&&(c.templateMode=n.mode),typeof n.duration_hours=="number"&&n.duration_hours>0&&(c.templateTtl=Math.round(n.duration_hours*3600)),c}function cm(n){if(n==null)return"—";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(Array.isArray(n))return n.map(s=>cm(s)).join(", ");try{return JSON.stringify(n,null,2)}catch{return String(n)}}const Jw="setup__create_mandate";function um({proposal:n,currentUserId:s,proposalLinks:i,toolDisplay:o,manifests:c,onContentState:d}){const[m,g]=f.useState(!1),[p,y]=f.useState(!1),[v,j]=f.useState(null),w=dn(),{group:N,groupId:E,domain:k}=vt(),C=Object.entries(n.executionContext),T=Qs(n.profileId),I=Ww(n.authorizationId),$=Z0(n.executionContext,I,T),A=H0(n.tool),{integrationId:B}=dc(n.tool),K=Xh(B,c),{intent:V,loading:de,error:Y}=Hw(n.authorizationId,s),re=lm(n),G=re.toolArgs!==null;f.useEffect(()=>{d==null||d({loading:re.loading,readable:G})},[re.loading,G]);const D=Vw(n),ie=re.toolArgs?nm(i,re.toolArgs):[],fe=async()=>{if(!E){j("No active workspace; cannot open the mandate screen.");return}y(!0),j(null);try{if(!re.toolArgs){j("This content is not readable on this device yet.");return}const O=re.toolArgs,H=typeof O.profile=="string"?O.profile:"",S=await M.listProfiles(),_=Yh(H,S);if(!_){j(`Unknown profile "${H}".`);return}const J=await M.getProfile(_.id),te=Yw(O),ce=qh(te.bounds,J),ve=Qh(te.context,J);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:_.id,groupId:E,groupName:(N==null?void 0:N.name)??null,domain:k,isPersonal:!!(N!=null&&N.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...te,bounds:ce,context:ve})),sessionStorage.setItem("agentReplacesProposal",n.id),w("/mandates/new/intent")}catch(O){j(O instanceof Error?O.message:"Could not open the mandate screen.")}finally{y(!1)}},[Z,pe]=f.useState(null),ee=Mw(Z),W=re.toolArgs?r.jsxs(r.Fragment,{children:[r.jsx(sm,{args:re.toolArgs,display:o,heading:""}),C.length>0&&r.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:C.map(([O,H],S)=>{const{label:_,hint:J}=Zh(O,T);return r.jsxs("span",{children:[S>0&&" · ",r.jsxs("span",{title:J,children:[_,"=",cm(H)]})]},O)})})]}):null;return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"approval-headline",children:A}),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&&G&&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."})]}),D.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: ",D.join(", ")," — shared automatically once they sign in on a device."]}),G&&r.jsx(Dw,{proposalId:n.id,systemName:K,onTone:pe}),$.length>0&&r.jsxs("div",{className:"limit-checks",children:[r.jsx("h4",{children:"Within your limits"}),r.jsx("ul",{className:"limit-check-list",children:$.map(O=>r.jsxs("li",{className:O.ok?"ok":"bad",children:[r.jsx("span",{className:"limit-check-icon",children:O.ok?"✓":"✗"}),r.jsxs("span",{children:[O.label," ",O.valueText," — your limit ",O.limitText]})]},O.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(n.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}):V!==null?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:`intent-text${m?"":" intent-clamped"}`,children:V}),r.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>g(!m),children:m?"Show less":"Show full intent"})]}):de?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."})})]})]}),G&&ie.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:ie.map(O=>r.jsxs("a",{href:O.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:O.description??O.href,children:[O.label," ↗"]},O.label))}),!ee&&G&&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})]}),G&&n.tool===Jw&&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:fe,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 dm({note:n,onNoteChange:s,onSend:i,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:i0.map(m=>r.jsx("button",{type:"button",className:`filter-chip${Vh(n,m)?" selected":""}`,onClick:()=>s(l0(n,m)),disabled:c,children:m},m))}),r.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:n,maxLength:Si,onChange:m=>s(m.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:[n.length," / ",Si]}),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:i,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 qw={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},Qw={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"},Xw={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced"};function Hf(n){const s=Date.now()-n*1e3,i=s/36e5;return i<48?i<1?`${Math.max(1,Math.round(s/6e4))}m ago`:`${Math.round(i)}h ago`:new Date(n*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Zw(n){return n.split("__").pop()??n}function ej(n){const s=n.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function fm(n){if(n==null)return"—";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(Array.isArray(n))return n.map(s=>fm(s)).join(", ");try{return JSON.stringify(n,null,2)}catch{return String(n)}}function Vf({item:n,onApprove:s,onReject:i,onChangeNeeded:o,resolving:c,proposalLinks:d,toolDisplay:m,manifests:g,currentUserId:p}){const y=n.kind==="proposal",v=y?n.proposal.status:"executed",j=y?n.proposal.tool:n.receipt.action,w=Zw(j),N=ej(j),{integrationId:E}=dc(j),k=Xh(E,g),[C,T]=f.useState(!1),[I,$]=f.useState(""),[A,B]=f.useState(""),K=()=>{const S=uc(I);if(!S.valid){B(S.error);return}B(""),o==null||o(n.id,S.trimmed)},V=y&&v==="rejected"?f0(n.proposal,p??""):null,de=Gw(y?n.proposal.rejectedBy??n.proposal.approverRejectedBy??null:null),Y=Qs(n.profileId),re=lm(y?n.proposal:{toolArgs:void 0,content:void 0}),G=y?re.toolArgs:null,D=y?n.proposal.executionContext:n.receipt.executionContext,ie=y?null:n.receipt.cumulativeState,[fe,Z]=f.useState(!0),[pe,ee]=f.useState(!1),W=y&&re.toolArgs?nm(d,re.toolArgs):[],O=Object.entries(D??{}),H=Sr(n.profileId).testSetup||Ti(j);return r.jsxs("div",{className:"card id-card",children:[r.jsx(qs,{profileId:n.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:w}),H&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),n.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:[y&&v==="pending"&&(()=>{const S=rm(n.proposal.expiresAt,Date.now());return r.jsx("span",{style:{fontSize:"0.72rem",color:S.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:S.urgent?600:400,whiteSpace:"nowrap"},children:S.label})})(),r.jsx("span",{"data-testid":V?"outcome-kind":void 0,className:`status-badge ${V?Xw[V.kind]:Qw[v]}`,children:V?V.kind:qw[v]}),r.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Hf(n.sortTimestamp)})]})]}),y&&n.proposal.status==="executed"&&r.jsx(Bw,{proposalId:n.proposal.id,systemName:k}),V&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[r.jsxs("div",{children:["By ",V.who,", ",Hf(V.at)]}),(de??V.note)&&r.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[V.kind==="CHANGE NEEDED"?"Change: ":"Note: ",de??V.note]})]}),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"})]}),y&&typeof(G==null?void 0:G._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:G._imagePreview,alt:typeof(G==null?void 0:G.altText)=="string"?G.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),y&&v==="pending"?r.jsx(um,{proposal:n.proposal,currentUserId:p??"",proposalLinks:d,toolDisplay:m,manifests:g,onContentState:({loading:S,readable:_})=>{ee(S),Z(_)}}):r.jsxs(r.Fragment,{children:[W.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:W.map(S=>r.jsxs("a",{href:S.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:S.description??S.href,children:[S.label," ↗"]},S.label))}),y?r.jsxs(r.Fragment,{children:[G&&r.jsx(sm,{args:G,display:m}),O.length>0&&r.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:O.map(([S,_])=>`${S}=${fm(_)}`).join(" · ")})]}):r.jsx(tm,{receipt:n.receipt,profile:Y})]}),ie&&r.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",ie.daily.count," action",ie.daily.count===1?"":"s",ie.daily.amount>0?`, ${ie.daily.amount}`:""," · ","this month: ",ie.monthly.count,ie.monthly.amount>0?`, ${ie.monthly.amount}`:""]}),y&&v==="pending"&&im({loading:pe,readable:fe})&&(C?r.jsx(dm,{note:I,onNoteChange:$,onSend:K,onCancel:()=>{T(!1),$(""),B("")},sending:!!c,error:A}):r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:()=>s==null?void 0:s(n.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:()=>i==null?void 0:i(n.id),disabled:c,children:"Reject"})]})),r.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[y?"Proposal":"Ticket",": ",n.id]})]})]})}function tj(n){const s=Date.now()-n*1e3,i=Math.floor(s/6e4);if(i<60)return`${Math.max(1,i)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function nj({proposal:n,currentUserId:s,onAction:i,onMessage:o,proposalLinks:c,toolDisplay:d,manifests:m}){const[g,p]=f.useState(!1),[y,v]=f.useState(!1),[j,w]=f.useState(!1),[N,E]=f.useState(""),[k,C]=f.useState(""),[T,I]=f.useState(!1),[$,A]=f.useState(!1),[B,K]=f.useState(!0),V=Sr(n.profileId).testSetup||Ti(n.tool),de=n.pendingApprovers??[],Y=n.approvedBy??{},re=Object.keys(Y).length,G=de.filter(ee=>!(ee in Y)).length,D=s in Y,ie=async()=>{if(ac()){o(ic);return}p(!0),o("");try{const ee=await yi(n);await M.approveProposal(n.id,ee);try{const W=await M.getAttestationIntent(n.authorizationId);if(W){const O=await M.decryptIntent({intentCiphertext:W.intentCiphertext,encryptedKey:W.encryptedKey,approverId:s});await M.storeApprovedIntent(n.authorizationId,O)}}catch{}o(`Approved. ${G-1>0?`${G-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),i()}catch(ee){o(ee instanceof Error?ee.message:"Approval failed")}finally{p(!1)}},fe=async()=>{v(!0),o("");try{const ee=await yi(n);await M.rejectProposal(n.id,_l(),ee),o("Action rejected."),i()}catch(ee){o(ee instanceof Error?ee.message:"Rejection failed")}finally{v(!1)}},Z=async()=>{const ee=uc(N);if(!ee.valid){C(ee.error);return}C(""),I(!0),o("");try{const{noteEncrypted:W}=await M.encryptProposalNote(ee.trimmed,om(n,s)),O=await yi(n);await M.rejectProposal(n.id,{outcome:"change_needed",noteEncrypted:W},O),o("Sent back for a change."),i()}catch(W){o(W instanceof Error?W.message:"Failed to send back")}finally{I(!1)}},pe=g||y||T;return r.jsxs("div",{className:"card id-card",children:[r.jsx(qs,{profileId:n.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"}),V&&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=rm(n.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:tj(n.createdAt)})]})]}),r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[re," of ",de.length," approver",de.length===1?"":"s"," signed off",de.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(um,{proposal:n,currentUserId:s,proposalLinks:c,toolDisplay:d,manifests:m,onContentState:({loading:ee,readable:W})=>{A(ee),K(W)}}),!D&&im({loading:$,readable:B})&&(j?r.jsx(dm,{note:N,onNoteChange:E,onSend:Z,onCancel:()=>{w(!1),E(""),C("")},sending:T,error:k}):r.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[r.jsx("button",{className:"btn btn-primary",onClick:ie,disabled:pe,children:g?"Approving...":"Approve"}),r.jsx("button",{"data-testid":"btn-change-needed",className:"btn",style:{background:"#fff",color:"var(--warning)",border:"1px solid var(--warning)"},onClick:()=>w(!0),disabled:pe,children:"Change needed"}),r.jsx("button",{"data-testid":"btn-reject",className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:fe,disabled:pe,children:y?"Rejecting...":"Reject"})]})),D&&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: ",n.id]})]})]})}function rj(){const{domain:n,user:s}=vt(),i=(s==null?void 0:s.id)??"",[o,c]=f.useState("awaiting-me"),[d,m]=f.useState([]),[g,p]=f.useState([]),[y,v]=f.useState({}),[j,w]=f.useState(!0),[N,E]=f.useState(""),k=f.useCallback(async()=>{try{const X=await M.getProposalsForApprover();m(X)}catch{}finally{w(!1)}},[]);He("proposal-added",k),He("proposal-approved",k),He("proposal-rejected",k),He("proposal-resolved",k),Zt(k,3e4);const[C,T]=f.useState([]),I=f.useCallback(async()=>{try{const X=await M.getMyProposals(n);T(X)}catch{}},[n]);He("proposal-added",I),He("proposal-approved",I),He("proposal-rejected",I),He("proposal-resolved",I),Zt(I,3e4,n);const $=f.useMemo(()=>C.filter(X=>{var we;return X.status==="pending"&&(((we=X.pendingApprovers)==null?void 0:we.length)??0)===0}),[C]),A=f.useMemo(()=>Of($,[],{status:"pending"}),[$]),[B,K]=f.useState([]),V=f.useCallback(async()=>{if(i)try{const we=(await M.getMyProposals(n)).filter(Te=>Te.status==="pending"&&Te.pendingApprovers&&Te.pendingApprovers.includes(i)&&Te.approvedBy&&i in Te.approvedBy);K(we)}catch{}},[i,n]);He("proposal-approved",V),He("proposal-rejected",V),Zt(V,3e4,`${i}:${n}`),f.useEffect(()=>{M.getIntegrationManifests().then(X=>p(X.manifests??[])).catch(()=>{}),M.getToolDisplay().then(v).catch(()=>{})},[]);const de=X=>{var we;return(we=g.find(Te=>Te.id===X.split("__")[0]))==null?void 0:we.proposalLinks};f.useEffect(()=>{k(),I(),V()},[]);const[Y,re]=f.useState([]),[G,D]=f.useState([]),[ie,fe]=f.useState(!0),[Z,pe]=f.useState(null),[ee,W]=f.useState(""),[O,H]=f.useState("pending"),[S,_]=f.useState(null),[J,te]=f.useState(!1),ce=f.useCallback(async()=>{try{const{proposals:X,receipts:we}=await M.getThread({domain:n,status:O,sinceDays:7});re(X),D(we)}catch{}finally{fe(!1)}},[n,O]);Zt(ce,3e4,`${n}:${O}`);const ve=async(X,we,Te)=>{if(we==="commit"&&ac()){W(ic);return}pe(X),W("");try{const Le=Y.find(st=>st.id===X)??C.find(st=>st.id===X),lt=Zy(Le,n),xt=Le?await yi(Le):void 0;let Ke=Te??{};if((Te==null?void 0:Te.outcome)==="change_needed"&&Te.note){const st=Le?om(Le,i):[i],{noteEncrypted:mt}=await M.encryptProposalNote(Te.note,st);Ke={outcome:"change_needed",noteEncrypted:mt}}const et=await M.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([ce(),I()])}catch(Le){W(Le instanceof Error?Le.message:"Failed")}finally{pe(null)}},Ce=(X,we)=>ve(X,"reject",c0(we)),ke=f.useMemo(()=>{const X=new Set;for(const we of Y)X.add(we.profileId);for(const we of G)X.add(we.profileId);return Array.from(X).sort()},[Y,G]),se=f.useMemo(()=>Of(Y,G,{status:O,profile:S??void 0,includeAutonomous:J}),[Y,G,O,S,J]),$e=f.useCallback(()=>{k(),V()},[k,V]),Ee=f.useMemo(()=>{const X=new Set,we=[];for(const Te of B)X.has(Te.id)||(X.add(Te.id),we.push(Te));return we.sort((Te,Le)=>Le.createdAt-Te.createdAt)},[B]),_e=d.length+A.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(_h,{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"),ce()},children:"All"})]}),o==="awaiting-me"&&r.jsx(r.Fragment,{children:j&&_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}),A.map(X=>r.jsx(Vf,{proposalLinks:X.kind==="proposal"?de(X.proposal.tool):void 0,toolDisplay:X.kind==="proposal"?y[X.proposal.tool]:void 0,manifests:g,currentUserId:i,item:X,onApprove:we=>ve(we,"commit"),onReject:we=>ve(we,"reject",_l()),onChangeNeeded:Ce,resolving:Z===X.id},X.id)),d.map(X=>r.jsx(nj,{proposal:X,currentUserId:i,onAction:$e,onMessage:E,proposalLinks:de(X.tool),toolDisplay:y[X.tool],manifests:g},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(aj,{proposal:X,currentUserId:i,onCancel:async()=>{try{await M.rejectProposal(X.id,{reason:"cancelled by creator"}),V(),I()}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 ${O==="pending"?"selected":""}`,onClick:()=>H("pending"),children:"Pending"}),r.jsx("button",{className:`filter-chip ${O==="all"?"selected":""}`,onClick:()=>H("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 ${S===X?"selected":""}`,onClick:()=>_(S===X?null:X),children:dt(X)},X)),O==="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 ${J?"selected":""}`,onClick:()=>te(!J),title:"Include actions executed without human review (automatic commitment mode)",children:[J?"✓ ":"","Autonomous actions"]})]})]}),ie&&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:O==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),r.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:O==="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(Vf,{proposalLinks:X.kind==="proposal"?de(X.proposal.tool):void 0,toolDisplay:X.kind==="proposal"?y[X.proposal.tool]:void 0,manifests:g,currentUserId:i,item:X,onApprove:we=>ve(we,"commit"),onReject:we=>ve(we,"reject",_l()),onChangeNeeded:Ce,resolving:Z===X.id},X.id))})]})]})}function sj(n){const s=Date.now()-n*1e3,i=Math.floor(s/6e4);if(i<60)return`${Math.max(1,i)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function aj({proposal:n,currentUserId:s,onCancel:i}){var v;const[o,c]=f.useState(!1),d=Object.keys(n.approvedBy??{}),m=(n.pendingApprovers??[]).filter(j=>!(j in(n.approvedBy??{}))),g=(((v=n.pendingApprovers)==null?void 0:v.length)??0)>0,p=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){c(!0);try{await i()}finally{c(!1)}}},y=Sr(n.profileId).testSetup||Ti(n.tool);return r.jsxs("div",{className:"card id-card",children:[r.jsx(qs,{profileId:n.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:n.tool.split("__").pop()??n.tool}),y&&r.jsx("span",{className:"sim-mark",children:"Test setup"}),g&&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:sj(n.createdAt)})]}),g&&r.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[d.map(j=>r.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:j===s?"You approved":`${j} approved`},j)),m.map(j=>r.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",j===s?"you":j]},j))]}),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 ij=`# 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 oj(){const[n,s]=f.useState(""),[i,o]=f.useState(""),[c,d]=f.useState(!0),[m,g]=f.useState(!1),[p,y]=f.useState(null),[v,j]=f.useState(!1),w=n!==i,N=new Blob([n]).size,E=16*1024;f.useEffect(()=>{if(!w)return;const I=A=>{A.preventDefault(),A.returnValue=""},$=A=>{var V,de;if(A.defaultPrevented||A.button!==0||A.metaKey||A.ctrlKey||A.shiftKey||A.altKey)return;const B=(de=(V=A.target)==null?void 0:V.closest)==null?void 0:de.call(V,"a");if(!B||!B.href)return;let K;try{K=new URL(B.href)}catch{return}K.origin===window.location.origin&&K.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(A.preventDefault(),A.stopPropagation()))};return window.addEventListener("beforeunload",I),document.addEventListener("click",$,!0),()=>{window.removeEventListener("beforeunload",I),document.removeEventListener("click",$,!0)}},[w]),f.useEffect(()=>{let I=!1;return M.getAgentContext().then($=>{I||(s($),o($))}).catch($=>{I||y({kind:"error",text:$ instanceof Error?$.message:"Failed to load context"})}).finally(()=>{I||d(!1)}),()=>{I=!0}},[]);const k=async()=>{g(!0),y(null);try{await M.saveAgentContext(n),o(n),y({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(I){y({kind:"error",text:I instanceof Error?I.message:"Save failed"})}finally{g(!1)}},C=()=>{s(i),y(null)},T=()=>{n.trim()&&!confirm("Replace current context with the starter template?")||s(ij)};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."}),!n.trim()&&!c&&r.jsx("button",{className:"btn btn-primary btn-sm",onClick:T,disabled:m,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(wi,{target:{kind:"context"},currentText:n,onApply:I=>{n.trim()&&!confirm("Replace the current context with the applied draft?")||s(I)},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:n,onChange:I=>s(I.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:m||!w,children:"Revert"}),r.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:k,disabled:m||!w||N>E||c,children:m?"Saving…":"Save"})]})]}),r.jsx("button",{type:"button",className:"floating-help",onClick:()=>j(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),r.jsx(Oh,{open:v,onClose:()=>j(!1),ariaLabel:"Brief assistant",children:r.jsx(wi,{target:{kind:"context"},currentText:n,onApply:I=>{n.trim()&&!confirm("Replace the current context with the applied draft?")||(s(I),j(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function lj(n){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(n);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function cj(n){const s=n.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 i=s.data;if(typeof i.profileLabel=="string"&&i.profileLabel)return i.profileLabel;const o=i.profile.split("@")[0].split("/").pop();return o?o.charAt(0).toUpperCase()+o.slice(1):null}function uj(n){return new Date(n*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function dj(n,s){const i=s.emailExportError?"cases unknown":`${s.coveredCases.length}/${s.loadedCases.length} cases`;return`${n.signaturesValid>0?`${n.signaturesValid} ✓ tickets`:`${n.signaturesValid} tickets`} · ${i} · ${s.ticketsReferenced.length}/${s.ticketsInPeriod.length} tickets covered`}function fj(n){return n.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:n.emailExportError}:{kind:"ok",text:`${n.coveredCases.length} of ${n.loadedCases.length}`}}function hj(n){return n.periodStart!==null?null:n.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:n.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function Gf(n,s="none in this report"){return n>0?{kind:"ok",text:`${n} ✓`}:{kind:"neutral",text:s}}function mj(n){return/Labels?$/.test(n)||n==="limits"||n==="fields"}function pj(n,s){const i=s[n];return i==null||i===""||mj(n)?null:typeof i=="object"?JSON.stringify(i):String(i)}function gj(n){const s=[];return n.missingCases.length>0&&s.push(`cases ${n.missingCases.join(", ")}`),n.ticketsNotReferenced.length>0&&s.push(`${n.ticketsNotReferenced.length} ticket${n.ticketsNotReferenced.length===1?"":"s"}`),s.length>0?`Not in the report: ${s.join(" · ")}`:null}function yj(n,s){var i;if(s)return s;if(!n)return null;if(n.kind==="sv-ticket")return n.attrs.ref||null;if(n.kind==="sv-approval"||n.kind==="sv-mandate")return n.attrs.ticket||null;if(n.kind==="sv-case"){const o=(i=n.data)==null?void 0:i.goal;return(o==null?void 0:o.ticketId)??null}return null}const vj="allow-popups allow-popups-to-escape-sandbox",xj="AI analysis — not verified",wj="Green = verified by the gateway — raw signed fields only",jj="Grey dashed = the AI's own analysis, not verified",Sj="= translation by the AI, not verified",kj="Übersetzung anzeigen / show translation";function Kf(n){var i;const s=((i=n.formatNotice)==null?void 0:i.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 bj(n,s){return s&&n.renderedHtmlGloss?n.renderedHtmlGloss:n.renderedHtml}function Nj(n,s,i){const o=new URLSearchParams(n);return o.set("element",s),i?o.set("ticket",i):o.delete("ticket"),o}const Cj={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function Ej(n){return n.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${Cj[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function Tj(n){if(!n||n.kind!=="sv-case"||!n.data)return[];const s=Array.isArray(n.data.steps)?n.data.steps:[],i=n.data.goal,o=[...s.map(c=>({n:c,isGoal:!1})),...i?[{n:i,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 Rj(n){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>${n}</body></html>`}const fc={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},Ij={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function Aj(n,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"]}[n].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 Pj(n,s){const i=Ij[n].filter(o=>s[o]!==void 0);return i.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:{...fc,marginTop:"0.5rem"},children:i.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 bl(n,s){return s?r.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[r.jsx("div",{className:"card-title",children:n}),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:fc,children:Aj(n,s.data??{}).map(({label:i,value:o})=>r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:i}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:o})]},i))}),Pj(n,s.data??{})]})]}):null}function _j({report:n,elementId:s,ticketParam:i,onClose:o,onSelectTicket:c}){var j;const d=n.elements.find(w=>w.id===s),m=yj(d,i),g=m?n.ticketDetails[m]:void 0,p=Tj(d),y=(j=n.proof.verifiedValues.find(w=>w.elementId===s))==null?void 0:j.summary,v=f.useRef(null);return f.useEffect(()=>{const w=v.current;if(!w||typeof w.getBoundingClientRect!="function")return;const N=w.getBoundingClientRect().top;(N<0||N>window.innerHeight-80)&&w.scrollIntoView({block:"start",behavior:"smooth"})},[s,i]),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"})]}),y&&r.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:y}),p.length>0&&r.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:p.map(w=>r.jsxs("button",{type:"button",className:`btn btn-sm ${w.ticketId===m?"btn-secondary":"btn-ghost"}`,"aria-pressed":w.ticketId===m,onClick:()=>c(w.ticketId),children:[w.isGoal?"Goal: ":"",w.label]},w.ticketId))}),!d&&r.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),d&&!m&&(d.status==="unverifiable"?r.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",d.reason??"no further detail."]}):r.jsx("dl",{style:fc,children:Object.keys(d.data??{}).map(w=>{const N=pj(w,d.data??{});return N===null?null:r.jsxs("div",{style:{display:"contents"},children:[r.jsx("dt",{style:{color:"var(--text-muted)"},children:w}),r.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:N})]},w)})})),g&&r.jsxs(r.Fragment,{children:[bl("Ticket",g.ticket),bl("Mandate",g.mandate),bl("Approval",g.approval)]}),m&&!g&&r.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",m,"."]})]})}async function Lj(n){const{html:s,filename:i}=await n.exportReport();n.download(s,i),await n.refresh()}function Yf({detail:n}){return n?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:n})]}):null}function $j({report:n,open:s,selectedId:i,onOpenElement:o,detail:c}){const{proof:d,coverage:m}=n,g=Ej(n.elements),p=gj(m),y=fj(m),v=hj(m),j=Gf(d.signaturesValid),w=Gf(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:j.kind==="ok"?{color:"var(--success)"}:void 0,children:j.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Records checked"}),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:"Not verifiable"}),r.jsx("b",{children:d.unverifiableCount})]}),g.map(N=>r.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${i===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"}),y.kind==="error"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"reports-error",role:"alert",children:y.text}),r.jsx(Yf,{detail:y.detail})]}):r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Cases"}),r.jsx("b",{children:y.text})]}),r.jsxs("div",{className:"reports-row",children:[r.jsx("span",{children:"Tickets in test period"}),r.jsxs("b",{children:[m.ticketsReferenced.length," of ",m.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(Yf,{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${i===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 zj(){const[n,s]=f.useState(null),[i,o]=f.useState(!0),[c,d]=f.useState(null),[m,g]=f.useState(!1),[p,y]=f.useState(!1),[v,j]=f.useState(null),[w,N]=f.useState(!1),[E,k]=f.useState(!1),[C,T]=Ql(),I=f.useCallback(()=>M.getReport().then(({report:D})=>s(D)).catch(D=>d(D instanceof Error?D.message:String(D))),[]),$=f.useCallback(()=>{o(!0),d(null),I().finally(()=>o(!1))},[I]);f.useEffect(()=>{$()},[$]);const A=f.useCallback(()=>{g(!0),M.recheckReport().then(({report:D})=>s(D)).catch(D=>d(D instanceof Error?D.message:String(D))).finally(()=>g(!1))},[]),B=f.useCallback(async()=>{y(!0),j(null);try{await Lj({exportReport:()=>M.exportReportWithProof(),download:(D,ie)=>{const fe=URL.createObjectURL(new Blob([D],{type:"text/html"})),Z=document.createElement("a");Z.href=fe,Z.download=ie,Z.click(),URL.revokeObjectURL(fe)},refresh:I})}catch(D){j(D instanceof Error?D.message:String(D))}finally{y(!1)}},[I]),K=C.get("element"),V=C.get("ticket"),de=f.useCallback((D,ie)=>{T(Nj(C,D,ie))},[C,T]),Y=f.useCallback(()=>{const D=new URLSearchParams(C);D.delete("element"),D.delete("ticket"),T(D,{replace:!0})},[C,T]);if(i)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(qr,{icon:"⚠",title:"Report unavailable",text:c})]});if(!n)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(qr,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const re=lj(n.renderedHtml),G=cj(n.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:[G?`written by the AI under mandate ${G} · `:"","checked ",uj(n.checkedAt)]})]}),r.jsxs("div",{className:"reports-bar-actions",children:[r.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:A,disabled:m,children:m?"Checking…":"Check again"}),r.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:B,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:dj(n.proof,n.coverage)}),r.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>N(D=>!D),children:w?"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"}),jj," (“",xj,"”)"]}),n.renderedHtmlGloss&&r.jsxs("span",{className:"reports-legend-chip",children:[r.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",Sj]})]}),Kf(n)&&r.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:Kf(n)}),n.renderedHtmlGloss&&r.jsxs("label",{className:"reports-gloss-switch",children:[r.jsx("input",{type:"checkbox",role:"switch",checked:E,onChange:D=>k(D.target.checked)}),r.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:r.jsx("span",{className:"reports-gloss-thumb"})}),r.jsx("span",{children:kj})]}),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:vj,srcDoc:Rj(bj(n,E)),className:"reports-iframe"})]}),r.jsx($j,{report:n,open:w||!!K,selectedId:K,onOpenElement:D=>de(D),detail:K?r.jsx(_j,{report:n,elementId:K,ticketParam:V,onClose:Y,onSelectTicket:D=>de(K,D)}):void 0})]})]})})}function Yr({to:n}){const{search:s,hash:i}=Bt();return r.jsx(In,{to:`${n}${s}${i}`,replace:!0})}function Fj({children:n}){const{user:s,mode:i,domain:o}=vt();return s?i==="team"&&!o?r.jsx(In,{to:"/onboarding",replace:!0}):r.jsx(r.Fragment,{children:n}):r.jsx(In,{to:"/login",replace:!0})}function Oj(){const{user:n,handleSessionLocked:s,refreshGroups:i}=vt();return He("session-locked",o=>{const c=o==null?void 0:o.message;s(c)}),He("team-membership-changed",()=>{i()}),r.jsxs(gy,{children:[r.jsx(Qe,{path:"/login",element:n?r.jsx(In,{to:"/",replace:!0}):r.jsx(sx,{})}),r.jsx(Qe,{path:"/onboarding",element:n?r.jsx(ux,{}):r.jsx(In,{to:"/login",replace:!0})}),r.jsxs(Qe,{element:r.jsx(Fj,{children:r.jsx(rx,{})}),children:[r.jsx(Qe,{path:"/",element:r.jsx(Nx,{})}),r.jsx(Qe,{path:"/mandates",element:r.jsx(U0,{})}),r.jsx(Qe,{path:"/mandates/new/intent",element:r.jsx(qx,{})}),r.jsx(Qe,{path:"/mandates/new/sign",element:r.jsx(h0,{})}),r.jsx(Qe,{path:"/integrations",element:r.jsx(w0,{})}),r.jsx(Qe,{path:"/team",element:r.jsx(j0,{})}),r.jsx(Qe,{path:"/tickets",element:r.jsx(xw,{})}),r.jsx(Qe,{path:"/blocked",element:r.jsx(ww,{})}),r.jsx(Qe,{path:"/approvals",element:r.jsx(rj,{})}),r.jsx(Qe,{path:"/reports",element:r.jsx(zj,{})}),r.jsx(Qe,{path:"/agent/new",element:r.jsx(In,{to:"/mandates?new=1",replace:!0})}),r.jsx(Qe,{path:"/agent/gate",element:r.jsx(Yr,{to:"/mandates/new/intent"})}),r.jsx(Qe,{path:"/agent/review",element:r.jsx(Yr,{to:"/mandates/new/sign"})}),r.jsx(Qe,{path:"/authorizations",element:r.jsx(Yr,{to:"/mandates"})}),r.jsx(Qe,{path:"/groups",element:r.jsx(Yr,{to:"/team"})}),r.jsx(Qe,{path:"/audit",element:r.jsx(Yr,{to:"/tickets"})}),r.jsx(Qe,{path:"/proposals",element:r.jsx(Yr,{to:"/approvals"})}),r.jsx(Qe,{path:"/agent-brief",element:r.jsx(oj,{})}),r.jsx(Qe,{path:"/settings",element:r.jsx(Iw,{})}),r.jsx(Qe,{path:"/settings/services",element:r.jsx(In,{to:"/settings",replace:!0})}),r.jsx(Qe,{path:"/deploy",element:r.jsx(In,{to:"/integrations",replace:!0})})]}),r.jsx(Qe,{path:"*",element:r.jsx(In,{to:"/",replace:!0})})]})}function Mj(){return r.jsx(Dy,{children:r.jsx(nv,{children:r.jsx(rv,{children:r.jsx(Oj,{})})})})}hg.createRoot(document.getElementById("root")).render(r.jsx(f.StrictMode,{children:r.jsx(Mj,{})}));