@suveren/gateway 0.37.0 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/integrations/erp.json +360 -19
- package/dist/mcp-server/http.mjs +576 -29
- package/dist/ui/assets/index-DNNXeRpZ.js +123 -0
- package/dist/ui/assets/index-Osk4E49r.css +1 -0
- package/dist/ui/index.html +2 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/README.md +17 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/lib/read.js +74 -57
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/lib/types/json.js +11 -11
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/lib/types/urlencoded.js +5 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/lib/utils.js +0 -15
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/package.json +7 -12
- package/node_modules/body-parser/HISTORY.md +7 -2
- package/node_modules/body-parser/README.md +3 -3
- package/node_modules/body-parser/lib/read.js +26 -8
- package/node_modules/body-parser/package.json +1 -1
- package/node_modules/on-finished/index.js +14 -2
- package/node_modules/on-finished/package.json +11 -7
- package/package.json +1 -1
- package/profiles/index.json +2 -1
- package/profiles/master-data/0.1.profile.json +311 -0
- package/dist/ui/assets/index-BC2bXeCQ.js +0 -123
- package/dist/ui/assets/index-XiOgY6b5.css +0 -1
- package/node_modules/on-finished/HISTORY.md +0 -98
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
var tv=Object.defineProperty;var nv=(e,s,a)=>s in e?tv(e,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[s]=a;var Zs=(e,s,a)=>nv(e,typeof s!="symbol"?s+"":s,a);(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))o(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const f of u.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&o(f)}).observe(document,{childList:!0,subtree:!0});function a(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(l){if(l.ep)return;l.ep=!0;const u=a(l);fetch(l.href,u)}})();var Hl={exports:{}},ea={},Vl={exports:{}},We={};/**
|
|
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 $f;function rv(){if($f)return We;$f=1;var e=Symbol.for("react.element"),s=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),f=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),w=Symbol.iterator;function x(A){return A===null||typeof A!="object"?null:(A=w&&A[w]||A["@@iterator"],typeof A=="function"?A:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,S={};function k(A,$,ae){this.props=A,this.context=$,this.refs=S,this.updater=ae||b}k.prototype.isReactComponent={},k.prototype.setState=function(A,$){if(typeof A!="object"&&typeof A!="function"&&A!=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,A,$,"setState")},k.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function E(){}E.prototype=k.prototype;function T(A,$,ae){this.props=A,this.context=$,this.refs=S,this.updater=ae||b}var P=T.prototype=new E;P.constructor=T,N(P,k.prototype),P.isPureReactComponent=!0;var I=Array.isArray,B=Object.prototype.hasOwnProperty,O={current:null},K={key:!0,ref:!0,__self:!0,__source:!0};function _(A,$,ae){var ne,ve={},Se=null,Y=null;if($!=null)for(ne in $.ref!==void 0&&(Y=$.ref),$.key!==void 0&&(Se=""+$.key),$)B.call($,ne)&&!K.hasOwnProperty(ne)&&(ve[ne]=$[ne]);var ce=arguments.length-2;if(ce===1)ve.children=ae;else if(1<ce){for(var ie=Array(ce),te=0;te<ce;te++)ie[te]=arguments[te+2];ve.children=ie}if(A&&A.defaultProps)for(ne in ce=A.defaultProps,ce)ve[ne]===void 0&&(ve[ne]=ce[ne]);return{$$typeof:e,type:A,key:Se,ref:Y,props:ve,_owner:O.current}}function U(A,$){return{$$typeof:e,type:A.type,key:$,ref:A.ref,props:A.props,_owner:A._owner}}function Z(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function V(A){var $={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(ae){return $[ae]})}var M=/\/+/g;function re(A,$){return typeof A=="object"&&A!==null&&A.key!=null?V(""+A.key):$.toString(36)}function de(A,$,ae,ne,ve){var Se=typeof A;(Se==="undefined"||Se==="boolean")&&(A=null);var Y=!1;if(A===null)Y=!0;else switch(Se){case"string":case"number":Y=!0;break;case"object":switch(A.$$typeof){case e:case s:Y=!0}}if(Y)return Y=A,ve=ve(Y),A=ne===""?"."+re(Y,0):ne,I(ve)?(ae="",A!=null&&(ae=A.replace(M,"$&/")+"/"),de(ve,$,ae,"",function(te){return te})):ve!=null&&(Z(ve)&&(ve=U(ve,ae+(!ve.key||Y&&Y.key===ve.key?"":(""+ve.key).replace(M,"$&/")+"/")+A)),$.push(ve)),1;if(Y=0,ne=ne===""?".":ne+":",I(A))for(var ce=0;ce<A.length;ce++){Se=A[ce];var ie=ne+re(Se,ce);Y+=de(Se,$,ae,ie,ve)}else if(ie=x(A),typeof ie=="function")for(A=ie.call(A),ce=0;!(Se=A.next()).done;)Se=Se.value,ie=ne+re(Se,ce++),Y+=de(Se,$,ae,ie,ve);else if(Se==="object")throw $=String(A),Error("Objects are not valid as a React child (found: "+($==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":$)+"). If you meant to render a collection of children, use an array instead.");return Y}function X(A,$,ae){if(A==null)return A;var ne=[],ve=0;return de(A,ne,"","",function(Se){return $.call(ae,Se,ve++)}),ne}function xe(A){if(A._status===-1){var $=A._result;$=$(),$.then(function(ae){(A._status===0||A._status===-1)&&(A._status=1,A._result=ae)},function(ae){(A._status===0||A._status===-1)&&(A._status=2,A._result=ae)}),A._status===-1&&(A._status=0,A._result=$)}if(A._status===1)return A._result.default;throw A._result}var Ne={current:null},ee={transition:null},Q={ReactCurrentDispatcher:Ne,ReactCurrentBatchConfig:ee,ReactCurrentOwner:O};function q(){throw Error("act(...) is not supported in production builds of React.")}return We.Children={map:X,forEach:function(A,$,ae){X(A,function(){$.apply(this,arguments)},ae)},count:function(A){var $=0;return X(A,function(){$++}),$},toArray:function(A){return X(A,function($){return $})||[]},only:function(A){if(!Z(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},We.Component=k,We.Fragment=a,We.Profiler=l,We.PureComponent=T,We.StrictMode=o,We.Suspense=g,We.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Q,We.act=q,We.cloneElement=function(A,$,ae){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var ne=N({},A.props),ve=A.key,Se=A.ref,Y=A._owner;if($!=null){if($.ref!==void 0&&(Se=$.ref,Y=O.current),$.key!==void 0&&(ve=""+$.key),A.type&&A.type.defaultProps)var ce=A.type.defaultProps;for(ie in $)B.call($,ie)&&!K.hasOwnProperty(ie)&&(ne[ie]=$[ie]===void 0&&ce!==void 0?ce[ie]:$[ie])}var ie=arguments.length-2;if(ie===1)ne.children=ae;else if(1<ie){ce=Array(ie);for(var te=0;te<ie;te++)ce[te]=arguments[te+2];ne.children=ce}return{$$typeof:e,type:A.type,key:ve,ref:Se,props:ne,_owner:Y}},We.createContext=function(A){return A={$$typeof:f,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:u,_context:A},A.Consumer=A},We.createElement=_,We.createFactory=function(A){var $=_.bind(null,A);return $.type=A,$},We.createRef=function(){return{current:null}},We.forwardRef=function(A){return{$$typeof:p,render:A}},We.isValidElement=Z,We.lazy=function(A){return{$$typeof:y,_payload:{_status:-1,_result:A},_init:xe}},We.memo=function(A,$){return{$$typeof:v,type:A,compare:$===void 0?null:$}},We.startTransition=function(A){var $=ee.transition;ee.transition={};try{A()}finally{ee.transition=$}},We.unstable_act=q,We.useCallback=function(A,$){return Ne.current.useCallback(A,$)},We.useContext=function(A){return Ne.current.useContext(A)},We.useDebugValue=function(){},We.useDeferredValue=function(A){return Ne.current.useDeferredValue(A)},We.useEffect=function(A,$){return Ne.current.useEffect(A,$)},We.useId=function(){return Ne.current.useId()},We.useImperativeHandle=function(A,$,ae){return Ne.current.useImperativeHandle(A,$,ae)},We.useInsertionEffect=function(A,$){return Ne.current.useInsertionEffect(A,$)},We.useLayoutEffect=function(A,$){return Ne.current.useLayoutEffect(A,$)},We.useMemo=function(A,$){return Ne.current.useMemo(A,$)},We.useReducer=function(A,$,ae){return Ne.current.useReducer(A,$,ae)},We.useRef=function(A){return Ne.current.useRef(A)},We.useState=function(A){return Ne.current.useState(A)},We.useSyncExternalStore=function(A,$,ae){return Ne.current.useSyncExternalStore(A,$,ae)},We.useTransition=function(){return Ne.current.useTransition()},We.version="18.3.1",We}var _f;function Cc(){return _f||(_f=1,Vl.exports=rv()),Vl.exports}/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.production.min.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Lf;function sv(){if(Lf)return ea;Lf=1;var e=Cc(),s=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function f(p,g,v){var y,w={},x=null,b=null;v!==void 0&&(x=""+v),g.key!==void 0&&(x=""+g.key),g.ref!==void 0&&(b=g.ref);for(y in g)o.call(g,y)&&!u.hasOwnProperty(y)&&(w[y]=g[y]);if(p&&p.defaultProps)for(y in g=p.defaultProps,g)w[y]===void 0&&(w[y]=g[y]);return{$$typeof:s,type:p,key:x,ref:b,props:w,_owner:l.current}}return ea.Fragment=a,ea.jsx=f,ea.jsxs=f,ea}var zf;function av(){return zf||(zf=1,Hl.exports=sv()),Hl.exports}var n=av(),h=Cc(),Ni={},Gl={exports:{}},Qt={},Kl={exports:{}},ql={};/**
|
|
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 Ff;function iv(){return Ff||(Ff=1,(function(e){function s(ee,Q){var q=ee.length;ee.push(Q);e:for(;0<q;){var A=q-1>>>1,$=ee[A];if(0<l($,Q))ee[A]=Q,ee[q]=$,q=A;else break e}}function a(ee){return ee.length===0?null:ee[0]}function o(ee){if(ee.length===0)return null;var Q=ee[0],q=ee.pop();if(q!==Q){ee[0]=q;e:for(var A=0,$=ee.length,ae=$>>>1;A<ae;){var ne=2*(A+1)-1,ve=ee[ne],Se=ne+1,Y=ee[Se];if(0>l(ve,q))Se<$&&0>l(Y,ve)?(ee[A]=Y,ee[Se]=q,A=Se):(ee[A]=ve,ee[ne]=q,A=ne);else if(Se<$&&0>l(Y,q))ee[A]=Y,ee[Se]=q,A=Se;else break e}}return Q}function l(ee,Q){var q=ee.sortIndex-Q.sortIndex;return q!==0?q:ee.id-Q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var f=Date,p=f.now();e.unstable_now=function(){return f.now()-p}}var g=[],v=[],y=1,w=null,x=3,b=!1,N=!1,S=!1,k=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function P(ee){for(var Q=a(v);Q!==null;){if(Q.callback===null)o(v);else if(Q.startTime<=ee)o(v),Q.sortIndex=Q.expirationTime,s(g,Q);else break;Q=a(v)}}function I(ee){if(S=!1,P(ee),!N)if(a(g)!==null)N=!0,xe(B);else{var Q=a(v);Q!==null&&Ne(I,Q.startTime-ee)}}function B(ee,Q){N=!1,S&&(S=!1,E(_),_=-1),b=!0;var q=x;try{for(P(Q),w=a(g);w!==null&&(!(w.expirationTime>Q)||ee&&!V());){var A=w.callback;if(typeof A=="function"){w.callback=null,x=w.priorityLevel;var $=A(w.expirationTime<=Q);Q=e.unstable_now(),typeof $=="function"?w.callback=$:w===a(g)&&o(g),P(Q)}else o(g);w=a(g)}if(w!==null)var ae=!0;else{var ne=a(v);ne!==null&&Ne(I,ne.startTime-Q),ae=!1}return ae}finally{w=null,x=q,b=!1}}var O=!1,K=null,_=-1,U=5,Z=-1;function V(){return!(e.unstable_now()-Z<U)}function M(){if(K!==null){var ee=e.unstable_now();Z=ee;var Q=!0;try{Q=K(!0,ee)}finally{Q?re():(O=!1,K=null)}}else O=!1}var re;if(typeof T=="function")re=function(){T(M)};else if(typeof MessageChannel<"u"){var de=new MessageChannel,X=de.port2;de.port1.onmessage=M,re=function(){X.postMessage(null)}}else re=function(){k(M,0)};function xe(ee){K=ee,O||(O=!0,re())}function Ne(ee,Q){_=k(function(){ee(e.unstable_now())},Q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(ee){ee.callback=null},e.unstable_continueExecution=function(){N||b||(N=!0,xe(B))},e.unstable_forceFrameRate=function(ee){0>ee||125<ee?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<ee?Math.floor(1e3/ee):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return a(g)},e.unstable_next=function(ee){switch(x){case 1:case 2:case 3:var Q=3;break;default:Q=x}var q=x;x=Q;try{return ee()}finally{x=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(ee,Q){switch(ee){case 1:case 2:case 3:case 4:case 5:break;default:ee=3}var q=x;x=ee;try{return Q()}finally{x=q}},e.unstable_scheduleCallback=function(ee,Q,q){var A=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?A+q:A):q=A,ee){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=q+$,ee={id:y++,callback:Q,priorityLevel:ee,startTime:q,expirationTime:$,sortIndex:-1},q>A?(ee.sortIndex=q,s(v,ee),a(g)===null&&ee===a(v)&&(S?(E(_),_=-1):S=!0,Ne(I,q-A))):(ee.sortIndex=$,s(g,ee),N||b||(N=!0,xe(B))),ee},e.unstable_shouldYield=V,e.unstable_wrapCallback=function(ee){var Q=x;return function(){var q=x;x=Q;try{return ee.apply(this,arguments)}finally{x=q}}}})(ql)),ql}var Mf;function ov(){return Mf||(Mf=1,Kl.exports=iv()),Kl.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 Of;function lv(){if(Of)return Qt;Of=1;var e=Cc(),s=ov();function a(t){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;i<arguments.length;i++)r+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,l={};function u(t,r){f(t,r),f(t+"Capture",r)}function f(t,r){for(l[t]=r,t=0;t<r.length;t++)o.add(r[t])}var p=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,v=/^[: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]*$/,y={},w={};function x(t){return g.call(w,t)?!0:g.call(y,t)?!1:v.test(t)?w[t]=!0:(y[t]=!0,!1)}function b(t,r,i,c){if(i!==null&&i.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return c?!1:i!==null?!i.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function N(t,r,i,c){if(r===null||typeof r>"u"||b(t,r,i,c))return!0;if(c)return!1;if(i!==null)switch(i.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function S(t,r,i,c,d,m,j){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=c,this.attributeNamespace=d,this.mustUseProperty=i,this.propertyName=t,this.type=r,this.sanitizeURL=m,this.removeEmptyString=j}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){k[t]=new S(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var r=t[0];k[r]=new S(r,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){k[t]=new S(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){k[t]=new S(t,2,!1,t,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(t){k[t]=new S(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){k[t]=new S(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){k[t]=new S(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){k[t]=new S(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){k[t]=new S(t,5,!1,t.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function T(t){return t[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(t){var r=t.replace(E,T);k[r]=new S(r,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var r=t.replace(E,T);k[r]=new S(r,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var r=t.replace(E,T);k[r]=new S(r,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){k[t]=new S(t,1,!1,t.toLowerCase(),null,!1,!1)}),k.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){k[t]=new S(t,1,!1,t.toLowerCase(),null,!0,!0)});function P(t,r,i,c){var d=k.hasOwnProperty(r)?k[r]:null;(d!==null?d.type!==0:c||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(N(r,i,d,c)&&(i=null),c||d===null?x(r)&&(i===null?t.removeAttribute(r):t.setAttribute(r,""+i)):d.mustUseProperty?t[d.propertyName]=i===null?d.type===3?!1:"":i:(r=d.attributeName,c=d.attributeNamespace,i===null?t.removeAttribute(r):(d=d.type,i=d===3||d===4&&i===!0?"":""+i,c?t.setAttributeNS(c,r,i):t.setAttribute(r,i))))}var I=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,B=Symbol.for("react.element"),O=Symbol.for("react.portal"),K=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),U=Symbol.for("react.profiler"),Z=Symbol.for("react.provider"),V=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),de=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),xe=Symbol.for("react.lazy"),Ne=Symbol.for("react.offscreen"),ee=Symbol.iterator;function Q(t){return t===null||typeof t!="object"?null:(t=ee&&t[ee]||t["@@iterator"],typeof t=="function"?t:null)}var q=Object.assign,A;function $(t){if(A===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);A=r&&r[1]||""}return`
|
|
34
|
-
`+A+t}var ae=!1;function ne(t,r){if(!t||ae)return"";ae=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(H){var c=H}Reflect.construct(t,[],r)}else{try{r.call()}catch(H){c=H}t.call(r.prototype)}else{try{throw Error()}catch(H){c=H}t()}}catch(H){if(H&&c&&typeof H.stack=="string"){for(var d=H.stack.split(`
|
|
35
|
-
`),m=c.stack.split(`
|
|
36
|
-
`),j=d.length-1,C=m.length-1;1<=j&&0<=C&&d[j]!==m[C];)C--;for(;1<=j&&0<=C;j--,C--)if(d[j]!==m[C]){if(j!==1||C!==1)do if(j--,C--,0>C||d[j]!==m[C]){var R=`
|
|
37
|
-
`+d[j].replace(" at new "," at ");return t.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",t.displayName)),R}while(1<=j&&0<=C);break}}}finally{ae=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?$(t):""}function ve(t){switch(t.tag){case 5:return $(t.type);case 16:return $("Lazy");case 13:return $("Suspense");case 19:return $("SuspenseList");case 0:case 2:case 15:return t=ne(t.type,!1),t;case 11:return t=ne(t.type.render,!1),t;case 1:return t=ne(t.type,!0),t;default:return""}}function Se(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case K:return"Fragment";case O:return"Portal";case U:return"Profiler";case _:return"StrictMode";case re:return"Suspense";case de:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case V:return(t.displayName||"Context")+".Consumer";case Z:return(t._context.displayName||"Context")+".Provider";case M:var r=t.render;return t=t.displayName,t||(t=r.displayName||r.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case X:return r=t.displayName||null,r!==null?r:Se(t.type)||"Memo";case xe:r=t._payload,t=t._init;try{return Se(t(r))}catch{}}return null}function Y(t){var r=t.type;switch(t.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=r.render,t=t.displayName||t.name||"",r.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Se(r);case 8:return r===_?"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 r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function ce(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function ie(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function te(t){var r=ie(t)?"checked":"value",i=Object.getOwnPropertyDescriptor(t.constructor.prototype,r),c=""+t[r];if(!t.hasOwnProperty(r)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var d=i.get,m=i.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return d.call(this)},set:function(j){c=""+j,m.call(this,j)}}),Object.defineProperty(t,r,{enumerable:i.enumerable}),{getValue:function(){return c},setValue:function(j){c=""+j},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function ze(t){t._valueTracker||(t._valueTracker=te(t))}function Ue(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var i=r.getValue(),c="";return t&&(c=ie(t)?t.checked?"true":"false":t.value),t=c,t!==i?(r.setValue(t),!0):!1}function fe(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function me(t,r){var i=r.checked;return q({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??t._wrapperState.initialChecked})}function Te(t,r){var i=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;i=ce(r.value!=null?r.value:i),t._wrapperState={initialChecked:c,initialValue:i,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Le(t,r){r=r.checked,r!=null&&P(t,"checked",r,!1)}function ge(t,r){Le(t,r);var i=ce(r.value),c=r.type;if(i!=null)c==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+i):t.value!==""+i&&(t.value=""+i);else if(c==="submit"||c==="reset"){t.removeAttribute("value");return}r.hasOwnProperty("value")?Ze(t,r.type,i):r.hasOwnProperty("defaultValue")&&Ze(t,r.type,ce(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(t.defaultChecked=!!r.defaultChecked)}function nt(t,r,i){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var c=r.type;if(!(c!=="submit"&&c!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+t._wrapperState.initialValue,i||r===t.value||(t.value=r),t.defaultValue=r}i=t.name,i!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,i!==""&&(t.name=i)}function Ze(t,r,i){(r!=="number"||fe(t.ownerDocument)!==t)&&(i==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+i&&(t.defaultValue=""+i))}var Ye=Array.isArray;function He(t,r,i,c){if(t=t.options,r){r={};for(var d=0;d<i.length;d++)r["$"+i[d]]=!0;for(i=0;i<t.length;i++)d=r.hasOwnProperty("$"+t[i].value),t[i].selected!==d&&(t[i].selected=d),d&&c&&(t[i].defaultSelected=!0)}else{for(i=""+ce(i),r=null,d=0;d<t.length;d++){if(t[d].value===i){t[d].selected=!0,c&&(t[d].defaultSelected=!0);return}r!==null||t[d].disabled||(r=t[d])}r!==null&&(r.selected=!0)}}function dt(t,r){if(r.dangerouslySetInnerHTML!=null)throw Error(a(91));return q({},r,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function ft(t,r){var i=r.value;if(i==null){if(i=r.children,r=r.defaultValue,i!=null){if(r!=null)throw Error(a(92));if(Ye(i)){if(1<i.length)throw Error(a(93));i=i[0]}r=i}r==null&&(r=""),i=r}t._wrapperState={initialValue:ce(i)}}function Me(t,r){var i=ce(r.value),c=ce(r.defaultValue);i!=null&&(i=""+i,i!==t.value&&(t.value=i),r.defaultValue==null&&t.defaultValue!==i&&(t.defaultValue=i)),c!=null&&(t.defaultValue=""+c)}function pe(t){var r=t.textContent;r===t._wrapperState.initialValue&&r!==""&&r!==null&&(t.value=r)}function Pe(t){switch(t){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 Be(t,r){return t==null||t==="http://www.w3.org/1999/xhtml"?Pe(r):t==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var G,J=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,i,c,d){MSApp.execUnsafeLocalFunction(function(){return t(r,i,c,d)})}:t})(function(t,r){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=r;else{for(G=G||document.createElement("div"),G.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=G.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;r.firstChild;)t.appendChild(r.firstChild)}});function ye(t,r){if(r){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=r;return}}t.textContent=r}var Ve={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},Ge=["Webkit","ms","Moz","O"];Object.keys(Ve).forEach(function(t){Ge.forEach(function(r){r=r+t.charAt(0).toUpperCase()+t.substring(1),Ve[r]=Ve[t]})});function rt(t,r,i){return r==null||typeof r=="boolean"||r===""?"":i||typeof r!="number"||r===0||Ve.hasOwnProperty(t)&&Ve[t]?(""+r).trim():r+"px"}function Vt(t,r){t=t.style;for(var i in r)if(r.hasOwnProperty(i)){var c=i.indexOf("--")===0,d=rt(i,r[i],c);i==="float"&&(i="cssFloat"),c?t.setProperty(i,d):t[i]=d}}var Dt=q({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 et(t,r){if(r){if(Dt[t]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(a(137,t));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(a(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(a(61))}if(r.style!=null&&typeof r.style!="object")throw Error(a(62))}}function W(t,r){if(t.indexOf("-")===-1)return typeof r.is=="string";switch(t){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 we=null;function Ie(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var st=null,yt=null,qe=null;function Et(t){if(t=Ms(t)){if(typeof st!="function")throw Error(a(280));var r=t.stateNode;r&&(r=Ba(r),st(t.stateNode,t.type,r))}}function kt(t){yt?qe?qe.push(t):qe=[t]:yt=t}function Zt(){if(yt){var t=yt,r=qe;if(qe=yt=null,Et(t),r)for(t=0;t<r.length;t++)Et(r[t])}}function ue(t,r){return t(r)}function Ce(){}var Re=!1;function De(t,r,i){if(Re)return t(r,i);Re=!0;try{return ue(t,r,i)}finally{Re=!1,(yt!==null||qe!==null)&&(Ce(),Zt())}}function Xe(t,r){var i=t.stateNode;if(i===null)return null;var c=Ba(i);if(c===null)return null;i=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(i&&typeof i!="function")throw Error(a(231,r,typeof i));return i}var jt=!1;if(p)try{var St={};Object.defineProperty(St,"passive",{get:function(){jt=!0}}),window.addEventListener("test",St,St),window.removeEventListener("test",St,St)}catch{jt=!1}function zr(t,r,i,c,d,m,j,C,R){var H=Array.prototype.slice.call(arguments,3);try{r.apply(i,H)}catch(oe){this.onError(oe)}}var hr=!1,Fr=null,Vn=!1,mr=null,lo={onError:function(t){hr=!0,Fr=t}};function ya(t,r,i,c,d,m,j,C,R){hr=!1,Fr=null,zr.apply(lo,arguments)}function va(t,r,i,c,d,m,j,C,R){if(ya.apply(this,arguments),hr){if(hr){var H=Fr;hr=!1,Fr=null}else throw Error(a(198));Vn||(Vn=!0,mr=H)}}function bn(t){var r=t,i=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(i=r.return),t=r.return;while(t)}return r.tag===3?i:null}function xs(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function xa(t){if(bn(t)!==t)throw Error(a(188))}function Mr(t){var r=t.alternate;if(!r){if(r=bn(t),r===null)throw Error(a(188));return r!==t?null:t}for(var i=t,c=r;;){var d=i.return;if(d===null)break;var m=d.alternate;if(m===null){if(c=d.return,c!==null){i=c;continue}break}if(d.child===m.child){for(m=d.child;m;){if(m===i)return xa(d),t;if(m===c)return xa(d),r;m=m.sibling}throw Error(a(188))}if(i.return!==c.return)i=d,c=m;else{for(var j=!1,C=d.child;C;){if(C===i){j=!0,i=d,c=m;break}if(C===c){j=!0,c=d,i=m;break}C=C.sibling}if(!j){for(C=m.child;C;){if(C===i){j=!0,i=m,c=d;break}if(C===c){j=!0,c=m,i=d;break}C=C.sibling}if(!j)throw Error(a(189))}}if(i.alternate!==c)throw Error(a(190))}if(i.tag!==3)throw Error(a(188));return i.stateNode.current===i?t:r}function kn(t){return t=Mr(t),t!==null?su(t):null}function su(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var r=su(t);if(r!==null)return r;t=t.sibling}return null}var au=s.unstable_scheduleCallback,iu=s.unstable_cancelCallback,fg=s.unstable_shouldYield,hg=s.unstable_requestPaint,vt=s.unstable_now,mg=s.unstable_getCurrentPriorityLevel,co=s.unstable_ImmediatePriority,ou=s.unstable_UserBlockingPriority,wa=s.unstable_NormalPriority,pg=s.unstable_LowPriority,lu=s.unstable_IdlePriority,ja=null,Nn=null;function gg(t){if(Nn&&typeof Nn.onCommitFiberRoot=="function")try{Nn.onCommitFiberRoot(ja,t,void 0,(t.current.flags&128)===128)}catch{}}var hn=Math.clz32?Math.clz32:xg,yg=Math.log,vg=Math.LN2;function xg(t){return t>>>=0,t===0?32:31-(yg(t)/vg|0)|0}var Sa=64,ba=4194304;function ws(t){switch(t&-t){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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function ka(t,r){var i=t.pendingLanes;if(i===0)return 0;var c=0,d=t.suspendedLanes,m=t.pingedLanes,j=i&268435455;if(j!==0){var C=j&~d;C!==0?c=ws(C):(m&=j,m!==0&&(c=ws(m)))}else j=i&~d,j!==0?c=ws(j):m!==0&&(c=ws(m));if(c===0)return 0;if(r!==0&&r!==c&&(r&d)===0&&(d=c&-c,m=r&-r,d>=m||d===16&&(m&4194240)!==0))return r;if((c&4)!==0&&(c|=i&16),r=t.entangledLanes,r!==0)for(t=t.entanglements,r&=c;0<r;)i=31-hn(r),d=1<<i,c|=t[i],r&=~d;return c}function wg(t,r){switch(t){case 1:case 2:case 4:return r+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 r+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 jg(t,r){for(var i=t.suspendedLanes,c=t.pingedLanes,d=t.expirationTimes,m=t.pendingLanes;0<m;){var j=31-hn(m),C=1<<j,R=d[j];R===-1?((C&i)===0||(C&c)!==0)&&(d[j]=wg(C,r)):R<=r&&(t.expiredLanes|=C),m&=~C}}function uo(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function cu(){var t=Sa;return Sa<<=1,(Sa&4194240)===0&&(Sa=64),t}function fo(t){for(var r=[],i=0;31>i;i++)r.push(t);return r}function js(t,r,i){t.pendingLanes|=r,r!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,r=31-hn(r),t[r]=i}function Sg(t,r){var i=t.pendingLanes&~r;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=r,t.mutableReadLanes&=r,t.entangledLanes&=r,r=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<i;){var d=31-hn(i),m=1<<d;r[d]=0,c[d]=-1,t[d]=-1,i&=~m}}function ho(t,r){var i=t.entangledLanes|=r;for(t=t.entanglements;i;){var c=31-hn(i),d=1<<c;d&r|t[c]&r&&(t[c]|=r),i&=~d}}var tt=0;function uu(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var du,mo,fu,hu,mu,po=!1,Na=[],Gn=null,Kn=null,qn=null,Ss=new Map,bs=new Map,Yn=[],bg="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 pu(t,r){switch(t){case"focusin":case"focusout":Gn=null;break;case"dragenter":case"dragleave":Kn=null;break;case"mouseover":case"mouseout":qn=null;break;case"pointerover":case"pointerout":Ss.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":bs.delete(r.pointerId)}}function ks(t,r,i,c,d,m){return t===null||t.nativeEvent!==m?(t={blockedOn:r,domEventName:i,eventSystemFlags:c,nativeEvent:m,targetContainers:[d]},r!==null&&(r=Ms(r),r!==null&&mo(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,d!==null&&r.indexOf(d)===-1&&r.push(d),t)}function kg(t,r,i,c,d){switch(r){case"focusin":return Gn=ks(Gn,t,r,i,c,d),!0;case"dragenter":return Kn=ks(Kn,t,r,i,c,d),!0;case"mouseover":return qn=ks(qn,t,r,i,c,d),!0;case"pointerover":var m=d.pointerId;return Ss.set(m,ks(Ss.get(m)||null,t,r,i,c,d)),!0;case"gotpointercapture":return m=d.pointerId,bs.set(m,ks(bs.get(m)||null,t,r,i,c,d)),!0}return!1}function gu(t){var r=pr(t.target);if(r!==null){var i=bn(r);if(i!==null){if(r=i.tag,r===13){if(r=xs(i),r!==null){t.blockedOn=r,mu(t.priority,function(){fu(i)});return}}else if(r===3&&i.stateNode.current.memoizedState.isDehydrated){t.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Ca(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var i=yo(t.domEventName,t.eventSystemFlags,r[0],t.nativeEvent);if(i===null){i=t.nativeEvent;var c=new i.constructor(i.type,i);we=c,i.target.dispatchEvent(c),we=null}else return r=Ms(i),r!==null&&mo(r),t.blockedOn=i,!1;r.shift()}return!0}function yu(t,r,i){Ca(t)&&i.delete(r)}function Ng(){po=!1,Gn!==null&&Ca(Gn)&&(Gn=null),Kn!==null&&Ca(Kn)&&(Kn=null),qn!==null&&Ca(qn)&&(qn=null),Ss.forEach(yu),bs.forEach(yu)}function Ns(t,r){t.blockedOn===r&&(t.blockedOn=null,po||(po=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Ng)))}function Cs(t){function r(d){return Ns(d,t)}if(0<Na.length){Ns(Na[0],t);for(var i=1;i<Na.length;i++){var c=Na[i];c.blockedOn===t&&(c.blockedOn=null)}}for(Gn!==null&&Ns(Gn,t),Kn!==null&&Ns(Kn,t),qn!==null&&Ns(qn,t),Ss.forEach(r),bs.forEach(r),i=0;i<Yn.length;i++)c=Yn[i],c.blockedOn===t&&(c.blockedOn=null);for(;0<Yn.length&&(i=Yn[0],i.blockedOn===null);)gu(i),i.blockedOn===null&&Yn.shift()}var Or=I.ReactCurrentBatchConfig,Ea=!0;function Cg(t,r,i,c){var d=tt,m=Or.transition;Or.transition=null;try{tt=1,go(t,r,i,c)}finally{tt=d,Or.transition=m}}function Eg(t,r,i,c){var d=tt,m=Or.transition;Or.transition=null;try{tt=4,go(t,r,i,c)}finally{tt=d,Or.transition=m}}function go(t,r,i,c){if(Ea){var d=yo(t,r,i,c);if(d===null)_o(t,r,c,Ta,i),pu(t,c);else if(kg(d,t,r,i,c))c.stopPropagation();else if(pu(t,c),r&4&&-1<bg.indexOf(t)){for(;d!==null;){var m=Ms(d);if(m!==null&&du(m),m=yo(t,r,i,c),m===null&&_o(t,r,c,Ta,i),m===d)break;d=m}d!==null&&c.stopPropagation()}else _o(t,r,c,null,i)}}var Ta=null;function yo(t,r,i,c){if(Ta=null,t=Ie(c),t=pr(t),t!==null)if(r=bn(t),r===null)t=null;else if(i=r.tag,i===13){if(t=xs(r),t!==null)return t;t=null}else if(i===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null);return Ta=t,null}function vu(t){switch(t){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(mg()){case co:return 1;case ou:return 4;case wa:case pg:return 16;case lu:return 536870912;default:return 16}default:return 16}}var Jn=null,vo=null,Aa=null;function xu(){if(Aa)return Aa;var t,r=vo,i=r.length,c,d="value"in Jn?Jn.value:Jn.textContent,m=d.length;for(t=0;t<i&&r[t]===d[t];t++);var j=i-t;for(c=1;c<=j&&r[i-c]===d[m-c];c++);return Aa=d.slice(t,1<c?1-c:void 0)}function Ia(t){var r=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&r===13&&(t=13)):t=r,t===10&&(t=13),32<=t||t===13?t:0}function Ra(){return!0}function wu(){return!1}function en(t){function r(i,c,d,m,j){this._reactName=i,this._targetInst=d,this.type=c,this.nativeEvent=m,this.target=j,this.currentTarget=null;for(var C in t)t.hasOwnProperty(C)&&(i=t[C],this[C]=i?i(m):m[C]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?Ra:wu,this.isPropagationStopped=wu,this}return q(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=Ra)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=Ra)},persist:function(){},isPersistent:Ra}),r}var Br={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xo=en(Br),Es=q({},Br,{view:0,detail:0}),Tg=en(Es),wo,jo,Ts,Pa=q({},Es,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:bo,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Ts&&(Ts&&t.type==="mousemove"?(wo=t.screenX-Ts.screenX,jo=t.screenY-Ts.screenY):jo=wo=0,Ts=t),wo)},movementY:function(t){return"movementY"in t?t.movementY:jo}}),ju=en(Pa),Ag=q({},Pa,{dataTransfer:0}),Ig=en(Ag),Rg=q({},Es,{relatedTarget:0}),So=en(Rg),Pg=q({},Br,{animationName:0,elapsedTime:0,pseudoElement:0}),$g=en(Pg),_g=q({},Br,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Lg=en(_g),zg=q({},Br,{data:0}),Su=en(zg),Fg={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Mg={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"},Og={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Bg(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=Og[t])?!!r[t]:!1}function bo(){return Bg}var Dg=q({},Es,{key:function(t){if(t.key){var r=Fg[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Ia(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Mg[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:bo,charCode:function(t){return t.type==="keypress"?Ia(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Ia(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),Ug=en(Dg),Wg=q({},Pa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),bu=en(Wg),Hg=q({},Es,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:bo}),Vg=en(Hg),Gg=q({},Br,{propertyName:0,elapsedTime:0,pseudoElement:0}),Kg=en(Gg),qg=q({},Pa,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Yg=en(qg),Jg=[9,13,27,32],ko=p&&"CompositionEvent"in window,As=null;p&&"documentMode"in document&&(As=document.documentMode);var Qg=p&&"TextEvent"in window&&!As,ku=p&&(!ko||As&&8<As&&11>=As),Nu=" ",Cu=!1;function Eu(t,r){switch(t){case"keyup":return Jg.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Tu(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Dr=!1;function Xg(t,r){switch(t){case"compositionend":return Tu(r);case"keypress":return r.which!==32?null:(Cu=!0,Nu);case"textInput":return t=r.data,t===Nu&&Cu?null:t;default:return null}}function Zg(t,r){if(Dr)return t==="compositionend"||!ko&&Eu(t,r)?(t=xu(),Aa=vo=Jn=null,Dr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return ku&&r.locale!=="ko"?null:r.data;default:return null}}var ey={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 Au(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!ey[t.type]:r==="textarea"}function Iu(t,r,i,c){kt(c),r=Fa(r,"onChange"),0<r.length&&(i=new xo("onChange","change",null,i,c),t.push({event:i,listeners:r}))}var Is=null,Rs=null;function ty(t){qu(t,0)}function $a(t){var r=Gr(t);if(Ue(r))return t}function ny(t,r){if(t==="change")return r}var Ru=!1;if(p){var No;if(p){var Co="oninput"in document;if(!Co){var Pu=document.createElement("div");Pu.setAttribute("oninput","return;"),Co=typeof Pu.oninput=="function"}No=Co}else No=!1;Ru=No&&(!document.documentMode||9<document.documentMode)}function $u(){Is&&(Is.detachEvent("onpropertychange",_u),Rs=Is=null)}function _u(t){if(t.propertyName==="value"&&$a(Rs)){var r=[];Iu(r,Rs,t,Ie(t)),De(ty,r)}}function ry(t,r,i){t==="focusin"?($u(),Is=r,Rs=i,Is.attachEvent("onpropertychange",_u)):t==="focusout"&&$u()}function sy(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return $a(Rs)}function ay(t,r){if(t==="click")return $a(r)}function iy(t,r){if(t==="input"||t==="change")return $a(r)}function oy(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var mn=typeof Object.is=="function"?Object.is:oy;function Ps(t,r){if(mn(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var i=Object.keys(t),c=Object.keys(r);if(i.length!==c.length)return!1;for(c=0;c<i.length;c++){var d=i[c];if(!g.call(r,d)||!mn(t[d],r[d]))return!1}return!0}function Lu(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function zu(t,r){var i=Lu(t);t=0;for(var c;i;){if(i.nodeType===3){if(c=t+i.textContent.length,t<=r&&c>=r)return{node:i,offset:r-t};t=c}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Lu(i)}}function Fu(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?Fu(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function Mu(){for(var t=window,r=fe();r instanceof t.HTMLIFrameElement;){try{var i=typeof r.contentWindow.location.href=="string"}catch{i=!1}if(i)t=r.contentWindow;else break;r=fe(t.document)}return r}function Eo(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}function ly(t){var r=Mu(),i=t.focusedElem,c=t.selectionRange;if(r!==i&&i&&i.ownerDocument&&Fu(i.ownerDocument.documentElement,i)){if(c!==null&&Eo(i)){if(r=c.start,t=c.end,t===void 0&&(t=r),"selectionStart"in i)i.selectionStart=r,i.selectionEnd=Math.min(t,i.value.length);else if(t=(r=i.ownerDocument||document)&&r.defaultView||window,t.getSelection){t=t.getSelection();var d=i.textContent.length,m=Math.min(c.start,d);c=c.end===void 0?m:Math.min(c.end,d),!t.extend&&m>c&&(d=c,c=m,m=d),d=zu(i,m);var j=zu(i,c);d&&j&&(t.rangeCount!==1||t.anchorNode!==d.node||t.anchorOffset!==d.offset||t.focusNode!==j.node||t.focusOffset!==j.offset)&&(r=r.createRange(),r.setStart(d.node,d.offset),t.removeAllRanges(),m>c?(t.addRange(r),t.extend(j.node,j.offset)):(r.setEnd(j.node,j.offset),t.addRange(r)))}}for(r=[],t=i;t=t.parentNode;)t.nodeType===1&&r.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<r.length;i++)t=r[i],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var cy=p&&"documentMode"in document&&11>=document.documentMode,Ur=null,To=null,$s=null,Ao=!1;function Ou(t,r,i){var c=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Ao||Ur==null||Ur!==fe(c)||(c=Ur,"selectionStart"in c&&Eo(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),$s&&Ps($s,c)||($s=c,c=Fa(To,"onSelect"),0<c.length&&(r=new xo("onSelect","select",null,r,i),t.push({event:r,listeners:c}),r.target=Ur)))}function _a(t,r){var i={};return i[t.toLowerCase()]=r.toLowerCase(),i["Webkit"+t]="webkit"+r,i["Moz"+t]="moz"+r,i}var Wr={animationend:_a("Animation","AnimationEnd"),animationiteration:_a("Animation","AnimationIteration"),animationstart:_a("Animation","AnimationStart"),transitionend:_a("Transition","TransitionEnd")},Io={},Bu={};p&&(Bu=document.createElement("div").style,"AnimationEvent"in window||(delete Wr.animationend.animation,delete Wr.animationiteration.animation,delete Wr.animationstart.animation),"TransitionEvent"in window||delete Wr.transitionend.transition);function La(t){if(Io[t])return Io[t];if(!Wr[t])return t;var r=Wr[t],i;for(i in r)if(r.hasOwnProperty(i)&&i in Bu)return Io[t]=r[i];return t}var Du=La("animationend"),Uu=La("animationiteration"),Wu=La("animationstart"),Hu=La("transitionend"),Vu=new Map,Gu="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 Qn(t,r){Vu.set(t,r),u(r,[t])}for(var Ro=0;Ro<Gu.length;Ro++){var Po=Gu[Ro],uy=Po.toLowerCase(),dy=Po[0].toUpperCase()+Po.slice(1);Qn(uy,"on"+dy)}Qn(Du,"onAnimationEnd"),Qn(Uu,"onAnimationIteration"),Qn(Wu,"onAnimationStart"),Qn("dblclick","onDoubleClick"),Qn("focusin","onFocus"),Qn("focusout","onBlur"),Qn(Hu,"onTransitionEnd"),f("onMouseEnter",["mouseout","mouseover"]),f("onMouseLeave",["mouseout","mouseover"]),f("onPointerEnter",["pointerout","pointerover"]),f("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var _s="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(" "),fy=new Set("cancel close invalid load scroll toggle".split(" ").concat(_s));function Ku(t,r,i){var c=t.type||"unknown-event";t.currentTarget=i,va(c,r,void 0,t),t.currentTarget=null}function qu(t,r){r=(r&4)!==0;for(var i=0;i<t.length;i++){var c=t[i],d=c.event;c=c.listeners;e:{var m=void 0;if(r)for(var j=c.length-1;0<=j;j--){var C=c[j],R=C.instance,H=C.currentTarget;if(C=C.listener,R!==m&&d.isPropagationStopped())break e;Ku(d,C,H),m=R}else for(j=0;j<c.length;j++){if(C=c[j],R=C.instance,H=C.currentTarget,C=C.listener,R!==m&&d.isPropagationStopped())break e;Ku(d,C,H),m=R}}}if(Vn)throw t=mr,Vn=!1,mr=null,t}function ot(t,r){var i=r[Bo];i===void 0&&(i=r[Bo]=new Set);var c=t+"__bubble";i.has(c)||(Yu(r,t,2,!1),i.add(c))}function $o(t,r,i){var c=0;r&&(c|=4),Yu(i,t,c,r)}var za="_reactListening"+Math.random().toString(36).slice(2);function Ls(t){if(!t[za]){t[za]=!0,o.forEach(function(i){i!=="selectionchange"&&(fy.has(i)||$o(i,!1,t),$o(i,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[za]||(r[za]=!0,$o("selectionchange",!1,r))}}function Yu(t,r,i,c){switch(vu(r)){case 1:var d=Cg;break;case 4:d=Eg;break;default:d=go}i=d.bind(null,r,i,t),d=void 0,!jt||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(d=!0),c?d!==void 0?t.addEventListener(r,i,{capture:!0,passive:d}):t.addEventListener(r,i,!0):d!==void 0?t.addEventListener(r,i,{passive:d}):t.addEventListener(r,i,!1)}function _o(t,r,i,c,d){var m=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var j=c.tag;if(j===3||j===4){var C=c.stateNode.containerInfo;if(C===d||C.nodeType===8&&C.parentNode===d)break;if(j===4)for(j=c.return;j!==null;){var R=j.tag;if((R===3||R===4)&&(R=j.stateNode.containerInfo,R===d||R.nodeType===8&&R.parentNode===d))return;j=j.return}for(;C!==null;){if(j=pr(C),j===null)return;if(R=j.tag,R===5||R===6){c=m=j;continue e}C=C.parentNode}}c=c.return}De(function(){var H=m,oe=Ie(i),le=[];e:{var se=Vu.get(t);if(se!==void 0){var je=xo,ke=t;switch(t){case"keypress":if(Ia(i)===0)break e;case"keydown":case"keyup":je=Ug;break;case"focusin":ke="focus",je=So;break;case"focusout":ke="blur",je=So;break;case"beforeblur":case"afterblur":je=So;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=ju;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=Ig;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=Vg;break;case Du:case Uu:case Wu:je=$g;break;case Hu:je=Kg;break;case"scroll":je=Tg;break;case"wheel":je=Yg;break;case"copy":case"cut":case"paste":je=Lg;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=bu}var Ee=(r&4)!==0,xt=!Ee&&t==="scroll",F=Ee?se!==null?se+"Capture":null:se;Ee=[];for(var L=H,D;L!==null;){D=L;var he=D.stateNode;if(D.tag===5&&he!==null&&(D=he,F!==null&&(he=Xe(L,F),he!=null&&Ee.push(zs(L,he,D)))),xt)break;L=L.return}0<Ee.length&&(se=new je(se,ke,null,i,oe),le.push({event:se,listeners:Ee}))}}if((r&7)===0){e:{if(se=t==="mouseover"||t==="pointerover",je=t==="mouseout"||t==="pointerout",se&&i!==we&&(ke=i.relatedTarget||i.fromElement)&&(pr(ke)||ke[Pn]))break e;if((je||se)&&(se=oe.window===oe?oe:(se=oe.ownerDocument)?se.defaultView||se.parentWindow:window,je?(ke=i.relatedTarget||i.toElement,je=H,ke=ke?pr(ke):null,ke!==null&&(xt=bn(ke),ke!==xt||ke.tag!==5&&ke.tag!==6)&&(ke=null)):(je=null,ke=H),je!==ke)){if(Ee=ju,he="onMouseLeave",F="onMouseEnter",L="mouse",(t==="pointerout"||t==="pointerover")&&(Ee=bu,he="onPointerLeave",F="onPointerEnter",L="pointer"),xt=je==null?se:Gr(je),D=ke==null?se:Gr(ke),se=new Ee(he,L+"leave",je,i,oe),se.target=xt,se.relatedTarget=D,he=null,pr(oe)===H&&(Ee=new Ee(F,L+"enter",ke,i,oe),Ee.target=D,Ee.relatedTarget=xt,he=Ee),xt=he,je&&ke)t:{for(Ee=je,F=ke,L=0,D=Ee;D;D=Hr(D))L++;for(D=0,he=F;he;he=Hr(he))D++;for(;0<L-D;)Ee=Hr(Ee),L--;for(;0<D-L;)F=Hr(F),D--;for(;L--;){if(Ee===F||F!==null&&Ee===F.alternate)break t;Ee=Hr(Ee),F=Hr(F)}Ee=null}else Ee=null;je!==null&&Ju(le,se,je,Ee,!1),ke!==null&&xt!==null&&Ju(le,xt,ke,Ee,!0)}}e:{if(se=H?Gr(H):window,je=se.nodeName&&se.nodeName.toLowerCase(),je==="select"||je==="input"&&se.type==="file")var Ae=ny;else if(Au(se))if(Ru)Ae=iy;else{Ae=sy;var $e=ry}else(je=se.nodeName)&&je.toLowerCase()==="input"&&(se.type==="checkbox"||se.type==="radio")&&(Ae=ay);if(Ae&&(Ae=Ae(t,H))){Iu(le,Ae,i,oe);break e}$e&&$e(t,se,H),t==="focusout"&&($e=se._wrapperState)&&$e.controlled&&se.type==="number"&&Ze(se,"number",se.value)}switch($e=H?Gr(H):window,t){case"focusin":(Au($e)||$e.contentEditable==="true")&&(Ur=$e,To=H,$s=null);break;case"focusout":$s=To=Ur=null;break;case"mousedown":Ao=!0;break;case"contextmenu":case"mouseup":case"dragend":Ao=!1,Ou(le,i,oe);break;case"selectionchange":if(cy)break;case"keydown":case"keyup":Ou(le,i,oe)}var _e;if(ko)e:{switch(t){case"compositionstart":var Fe="onCompositionStart";break e;case"compositionend":Fe="onCompositionEnd";break e;case"compositionupdate":Fe="onCompositionUpdate";break e}Fe=void 0}else Dr?Eu(t,i)&&(Fe="onCompositionEnd"):t==="keydown"&&i.keyCode===229&&(Fe="onCompositionStart");Fe&&(ku&&i.locale!=="ko"&&(Dr||Fe!=="onCompositionStart"?Fe==="onCompositionEnd"&&Dr&&(_e=xu()):(Jn=oe,vo="value"in Jn?Jn.value:Jn.textContent,Dr=!0)),$e=Fa(H,Fe),0<$e.length&&(Fe=new Su(Fe,t,null,i,oe),le.push({event:Fe,listeners:$e}),_e?Fe.data=_e:(_e=Tu(i),_e!==null&&(Fe.data=_e)))),(_e=Qg?Xg(t,i):Zg(t,i))&&(H=Fa(H,"onBeforeInput"),0<H.length&&(oe=new Su("onBeforeInput","beforeinput",null,i,oe),le.push({event:oe,listeners:H}),oe.data=_e))}qu(le,r)})}function zs(t,r,i){return{instance:t,listener:r,currentTarget:i}}function Fa(t,r){for(var i=r+"Capture",c=[];t!==null;){var d=t,m=d.stateNode;d.tag===5&&m!==null&&(d=m,m=Xe(t,i),m!=null&&c.unshift(zs(t,m,d)),m=Xe(t,r),m!=null&&c.push(zs(t,m,d))),t=t.return}return c}function Hr(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function Ju(t,r,i,c,d){for(var m=r._reactName,j=[];i!==null&&i!==c;){var C=i,R=C.alternate,H=C.stateNode;if(R!==null&&R===c)break;C.tag===5&&H!==null&&(C=H,d?(R=Xe(i,m),R!=null&&j.unshift(zs(i,R,C))):d||(R=Xe(i,m),R!=null&&j.push(zs(i,R,C)))),i=i.return}j.length!==0&&t.push({event:r,listeners:j})}var hy=/\r\n?/g,my=/\u0000|\uFFFD/g;function Qu(t){return(typeof t=="string"?t:""+t).replace(hy,`
|
|
38
|
-
`).replace(my,"")}function Ma(t,r,i){if(r=Qu(r),Qu(t)!==r&&i)throw Error(a(425))}function Oa(){}var Lo=null,zo=null;function Fo(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Mo=typeof setTimeout=="function"?setTimeout:void 0,py=typeof clearTimeout=="function"?clearTimeout:void 0,Xu=typeof Promise=="function"?Promise:void 0,gy=typeof queueMicrotask=="function"?queueMicrotask:typeof Xu<"u"?function(t){return Xu.resolve(null).then(t).catch(yy)}:Mo;function yy(t){setTimeout(function(){throw t})}function Oo(t,r){var i=r,c=0;do{var d=i.nextSibling;if(t.removeChild(i),d&&d.nodeType===8)if(i=d.data,i==="/$"){if(c===0){t.removeChild(d),Cs(r);return}c--}else i!=="$"&&i!=="$?"&&i!=="$!"||c++;i=d}while(i);Cs(r)}function Xn(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return t}function Zu(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var i=t.data;if(i==="$"||i==="$!"||i==="$?"){if(r===0)return t;r--}else i==="/$"&&r++}t=t.previousSibling}return null}var Vr=Math.random().toString(36).slice(2),Cn="__reactFiber$"+Vr,Fs="__reactProps$"+Vr,Pn="__reactContainer$"+Vr,Bo="__reactEvents$"+Vr,vy="__reactListeners$"+Vr,xy="__reactHandles$"+Vr;function pr(t){var r=t[Cn];if(r)return r;for(var i=t.parentNode;i;){if(r=i[Pn]||i[Cn]){if(i=r.alternate,r.child!==null||i!==null&&i.child!==null)for(t=Zu(t);t!==null;){if(i=t[Cn])return i;t=Zu(t)}return r}t=i,i=t.parentNode}return null}function Ms(t){return t=t[Cn]||t[Pn],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Gr(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(a(33))}function Ba(t){return t[Fs]||null}var Do=[],Kr=-1;function Zn(t){return{current:t}}function lt(t){0>Kr||(t.current=Do[Kr],Do[Kr]=null,Kr--)}function at(t,r){Kr++,Do[Kr]=t.current,t.current=r}var er={},Lt=Zn(er),Gt=Zn(!1),gr=er;function qr(t,r){var i=t.type.contextTypes;if(!i)return er;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var d={},m;for(m in i)d[m]=r[m];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=r,t.__reactInternalMemoizedMaskedChildContext=d),d}function Kt(t){return t=t.childContextTypes,t!=null}function Da(){lt(Gt),lt(Lt)}function ed(t,r,i){if(Lt.current!==er)throw Error(a(168));at(Lt,r),at(Gt,i)}function td(t,r,i){var c=t.stateNode;if(r=r.childContextTypes,typeof c.getChildContext!="function")return i;c=c.getChildContext();for(var d in c)if(!(d in r))throw Error(a(108,Y(t)||"Unknown",d));return q({},i,c)}function Ua(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||er,gr=Lt.current,at(Lt,t),at(Gt,Gt.current),!0}function nd(t,r,i){var c=t.stateNode;if(!c)throw Error(a(169));i?(t=td(t,r,gr),c.__reactInternalMemoizedMergedChildContext=t,lt(Gt),lt(Lt),at(Lt,t)):lt(Gt),at(Gt,i)}var $n=null,Wa=!1,Uo=!1;function rd(t){$n===null?$n=[t]:$n.push(t)}function wy(t){Wa=!0,rd(t)}function tr(){if(!Uo&&$n!==null){Uo=!0;var t=0,r=tt;try{var i=$n;for(tt=1;t<i.length;t++){var c=i[t];do c=c(!0);while(c!==null)}$n=null,Wa=!1}catch(d){throw $n!==null&&($n=$n.slice(t+1)),au(co,tr),d}finally{tt=r,Uo=!1}}return null}var Yr=[],Jr=0,Ha=null,Va=0,an=[],on=0,yr=null,_n=1,Ln="";function vr(t,r){Yr[Jr++]=Va,Yr[Jr++]=Ha,Ha=t,Va=r}function sd(t,r,i){an[on++]=_n,an[on++]=Ln,an[on++]=yr,yr=t;var c=_n;t=Ln;var d=32-hn(c)-1;c&=~(1<<d),i+=1;var m=32-hn(r)+d;if(30<m){var j=d-d%5;m=(c&(1<<j)-1).toString(32),c>>=j,d-=j,_n=1<<32-hn(r)+d|i<<d|c,Ln=m+t}else _n=1<<m|i<<d|c,Ln=t}function Wo(t){t.return!==null&&(vr(t,1),sd(t,1,0))}function Ho(t){for(;t===Ha;)Ha=Yr[--Jr],Yr[Jr]=null,Va=Yr[--Jr],Yr[Jr]=null;for(;t===yr;)yr=an[--on],an[on]=null,Ln=an[--on],an[on]=null,_n=an[--on],an[on]=null}var tn=null,nn=null,ct=!1,pn=null;function ad(t,r){var i=dn(5,null,null,0);i.elementType="DELETED",i.stateNode=r,i.return=t,r=t.deletions,r===null?(t.deletions=[i],t.flags|=16):r.push(i)}function id(t,r){switch(t.tag){case 5:var i=t.type;return r=r.nodeType!==1||i.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(t.stateNode=r,tn=t,nn=Xn(r.firstChild),!0):!1;case 6:return r=t.pendingProps===""||r.nodeType!==3?null:r,r!==null?(t.stateNode=r,tn=t,nn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(i=yr!==null?{id:_n,overflow:Ln}:null,t.memoizedState={dehydrated:r,treeContext:i,retryLane:1073741824},i=dn(18,null,null,0),i.stateNode=r,i.return=t,t.child=i,tn=t,nn=null,!0):!1;default:return!1}}function Vo(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Go(t){if(ct){var r=nn;if(r){var i=r;if(!id(t,r)){if(Vo(t))throw Error(a(418));r=Xn(i.nextSibling);var c=tn;r&&id(t,r)?ad(c,i):(t.flags=t.flags&-4097|2,ct=!1,tn=t)}}else{if(Vo(t))throw Error(a(418));t.flags=t.flags&-4097|2,ct=!1,tn=t}}}function od(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;tn=t}function Ga(t){if(t!==tn)return!1;if(!ct)return od(t),ct=!0,!1;var r;if((r=t.tag!==3)&&!(r=t.tag!==5)&&(r=t.type,r=r!=="head"&&r!=="body"&&!Fo(t.type,t.memoizedProps)),r&&(r=nn)){if(Vo(t))throw ld(),Error(a(418));for(;r;)ad(t,r),r=Xn(r.nextSibling)}if(od(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(a(317));e:{for(t=t.nextSibling,r=0;t;){if(t.nodeType===8){var i=t.data;if(i==="/$"){if(r===0){nn=Xn(t.nextSibling);break e}r--}else i!=="$"&&i!=="$!"&&i!=="$?"||r++}t=t.nextSibling}nn=null}}else nn=tn?Xn(t.stateNode.nextSibling):null;return!0}function ld(){for(var t=nn;t;)t=Xn(t.nextSibling)}function Qr(){nn=tn=null,ct=!1}function Ko(t){pn===null?pn=[t]:pn.push(t)}var jy=I.ReactCurrentBatchConfig;function Os(t,r,i){if(t=i.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(a(309));var c=i.stateNode}if(!c)throw Error(a(147,t));var d=c,m=""+t;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===m?r.ref:(r=function(j){var C=d.refs;j===null?delete C[m]:C[m]=j},r._stringRef=m,r)}if(typeof t!="string")throw Error(a(284));if(!i._owner)throw Error(a(290,t))}return t}function Ka(t,r){throw t=Object.prototype.toString.call(r),Error(a(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t))}function cd(t){var r=t._init;return r(t._payload)}function ud(t){function r(F,L){if(t){var D=F.deletions;D===null?(F.deletions=[L],F.flags|=16):D.push(L)}}function i(F,L){if(!t)return null;for(;L!==null;)r(F,L),L=L.sibling;return null}function c(F,L){for(F=new Map;L!==null;)L.key!==null?F.set(L.key,L):F.set(L.index,L),L=L.sibling;return F}function d(F,L){return F=cr(F,L),F.index=0,F.sibling=null,F}function m(F,L,D){return F.index=D,t?(D=F.alternate,D!==null?(D=D.index,D<L?(F.flags|=2,L):D):(F.flags|=2,L)):(F.flags|=1048576,L)}function j(F){return t&&F.alternate===null&&(F.flags|=2),F}function C(F,L,D,he){return L===null||L.tag!==6?(L=Ml(D,F.mode,he),L.return=F,L):(L=d(L,D),L.return=F,L)}function R(F,L,D,he){var Ae=D.type;return Ae===K?oe(F,L,D.props.children,he,D.key):L!==null&&(L.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===xe&&cd(Ae)===L.type)?(he=d(L,D.props),he.ref=Os(F,L,D),he.return=F,he):(he=yi(D.type,D.key,D.props,null,F.mode,he),he.ref=Os(F,L,D),he.return=F,he)}function H(F,L,D,he){return L===null||L.tag!==4||L.stateNode.containerInfo!==D.containerInfo||L.stateNode.implementation!==D.implementation?(L=Ol(D,F.mode,he),L.return=F,L):(L=d(L,D.children||[]),L.return=F,L)}function oe(F,L,D,he,Ae){return L===null||L.tag!==7?(L=Cr(D,F.mode,he,Ae),L.return=F,L):(L=d(L,D),L.return=F,L)}function le(F,L,D){if(typeof L=="string"&&L!==""||typeof L=="number")return L=Ml(""+L,F.mode,D),L.return=F,L;if(typeof L=="object"&&L!==null){switch(L.$$typeof){case B:return D=yi(L.type,L.key,L.props,null,F.mode,D),D.ref=Os(F,null,L),D.return=F,D;case O:return L=Ol(L,F.mode,D),L.return=F,L;case xe:var he=L._init;return le(F,he(L._payload),D)}if(Ye(L)||Q(L))return L=Cr(L,F.mode,D,null),L.return=F,L;Ka(F,L)}return null}function se(F,L,D,he){var Ae=L!==null?L.key:null;if(typeof D=="string"&&D!==""||typeof D=="number")return Ae!==null?null:C(F,L,""+D,he);if(typeof D=="object"&&D!==null){switch(D.$$typeof){case B:return D.key===Ae?R(F,L,D,he):null;case O:return D.key===Ae?H(F,L,D,he):null;case xe:return Ae=D._init,se(F,L,Ae(D._payload),he)}if(Ye(D)||Q(D))return Ae!==null?null:oe(F,L,D,he,null);Ka(F,D)}return null}function je(F,L,D,he,Ae){if(typeof he=="string"&&he!==""||typeof he=="number")return F=F.get(D)||null,C(L,F,""+he,Ae);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case B:return F=F.get(he.key===null?D:he.key)||null,R(L,F,he,Ae);case O:return F=F.get(he.key===null?D:he.key)||null,H(L,F,he,Ae);case xe:var $e=he._init;return je(F,L,D,$e(he._payload),Ae)}if(Ye(he)||Q(he))return F=F.get(D)||null,oe(L,F,he,Ae,null);Ka(L,he)}return null}function ke(F,L,D,he){for(var Ae=null,$e=null,_e=L,Fe=L=0,It=null;_e!==null&&Fe<D.length;Fe++){_e.index>Fe?(It=_e,_e=null):It=_e.sibling;var Qe=se(F,_e,D[Fe],he);if(Qe===null){_e===null&&(_e=It);break}t&&_e&&Qe.alternate===null&&r(F,_e),L=m(Qe,L,Fe),$e===null?Ae=Qe:$e.sibling=Qe,$e=Qe,_e=It}if(Fe===D.length)return i(F,_e),ct&&vr(F,Fe),Ae;if(_e===null){for(;Fe<D.length;Fe++)_e=le(F,D[Fe],he),_e!==null&&(L=m(_e,L,Fe),$e===null?Ae=_e:$e.sibling=_e,$e=_e);return ct&&vr(F,Fe),Ae}for(_e=c(F,_e);Fe<D.length;Fe++)It=je(_e,F,Fe,D[Fe],he),It!==null&&(t&&It.alternate!==null&&_e.delete(It.key===null?Fe:It.key),L=m(It,L,Fe),$e===null?Ae=It:$e.sibling=It,$e=It);return t&&_e.forEach(function(ur){return r(F,ur)}),ct&&vr(F,Fe),Ae}function Ee(F,L,D,he){var Ae=Q(D);if(typeof Ae!="function")throw Error(a(150));if(D=Ae.call(D),D==null)throw Error(a(151));for(var $e=Ae=null,_e=L,Fe=L=0,It=null,Qe=D.next();_e!==null&&!Qe.done;Fe++,Qe=D.next()){_e.index>Fe?(It=_e,_e=null):It=_e.sibling;var ur=se(F,_e,Qe.value,he);if(ur===null){_e===null&&(_e=It);break}t&&_e&&ur.alternate===null&&r(F,_e),L=m(ur,L,Fe),$e===null?Ae=ur:$e.sibling=ur,$e=ur,_e=It}if(Qe.done)return i(F,_e),ct&&vr(F,Fe),Ae;if(_e===null){for(;!Qe.done;Fe++,Qe=D.next())Qe=le(F,Qe.value,he),Qe!==null&&(L=m(Qe,L,Fe),$e===null?Ae=Qe:$e.sibling=Qe,$e=Qe);return ct&&vr(F,Fe),Ae}for(_e=c(F,_e);!Qe.done;Fe++,Qe=D.next())Qe=je(_e,F,Fe,Qe.value,he),Qe!==null&&(t&&Qe.alternate!==null&&_e.delete(Qe.key===null?Fe:Qe.key),L=m(Qe,L,Fe),$e===null?Ae=Qe:$e.sibling=Qe,$e=Qe);return t&&_e.forEach(function(ev){return r(F,ev)}),ct&&vr(F,Fe),Ae}function xt(F,L,D,he){if(typeof D=="object"&&D!==null&&D.type===K&&D.key===null&&(D=D.props.children),typeof D=="object"&&D!==null){switch(D.$$typeof){case B:e:{for(var Ae=D.key,$e=L;$e!==null;){if($e.key===Ae){if(Ae=D.type,Ae===K){if($e.tag===7){i(F,$e.sibling),L=d($e,D.props.children),L.return=F,F=L;break e}}else if($e.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===xe&&cd(Ae)===$e.type){i(F,$e.sibling),L=d($e,D.props),L.ref=Os(F,$e,D),L.return=F,F=L;break e}i(F,$e);break}else r(F,$e);$e=$e.sibling}D.type===K?(L=Cr(D.props.children,F.mode,he,D.key),L.return=F,F=L):(he=yi(D.type,D.key,D.props,null,F.mode,he),he.ref=Os(F,L,D),he.return=F,F=he)}return j(F);case O:e:{for($e=D.key;L!==null;){if(L.key===$e)if(L.tag===4&&L.stateNode.containerInfo===D.containerInfo&&L.stateNode.implementation===D.implementation){i(F,L.sibling),L=d(L,D.children||[]),L.return=F,F=L;break e}else{i(F,L);break}else r(F,L);L=L.sibling}L=Ol(D,F.mode,he),L.return=F,F=L}return j(F);case xe:return $e=D._init,xt(F,L,$e(D._payload),he)}if(Ye(D))return ke(F,L,D,he);if(Q(D))return Ee(F,L,D,he);Ka(F,D)}return typeof D=="string"&&D!==""||typeof D=="number"?(D=""+D,L!==null&&L.tag===6?(i(F,L.sibling),L=d(L,D),L.return=F,F=L):(i(F,L),L=Ml(D,F.mode,he),L.return=F,F=L),j(F)):i(F,L)}return xt}var Xr=ud(!0),dd=ud(!1),qa=Zn(null),Ya=null,Zr=null,qo=null;function Yo(){qo=Zr=Ya=null}function Jo(t){var r=qa.current;lt(qa),t._currentValue=r}function Qo(t,r,i){for(;t!==null;){var c=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),t===i)break;t=t.return}}function es(t,r){Ya=t,qo=Zr=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&r)!==0&&(qt=!0),t.firstContext=null)}function ln(t){var r=t._currentValue;if(qo!==t)if(t={context:t,memoizedValue:r,next:null},Zr===null){if(Ya===null)throw Error(a(308));Zr=t,Ya.dependencies={lanes:0,firstContext:t}}else Zr=Zr.next=t;return r}var xr=null;function Xo(t){xr===null?xr=[t]:xr.push(t)}function fd(t,r,i,c){var d=r.interleaved;return d===null?(i.next=i,Xo(r)):(i.next=d.next,d.next=i),r.interleaved=i,zn(t,c)}function zn(t,r){t.lanes|=r;var i=t.alternate;for(i!==null&&(i.lanes|=r),i=t,t=t.return;t!==null;)t.childLanes|=r,i=t.alternate,i!==null&&(i.childLanes|=r),i=t,t=t.return;return i.tag===3?i.stateNode:null}var nr=!1;function Zo(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function hd(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Fn(t,r){return{eventTime:t,lane:r,tag:0,payload:null,callback:null,next:null}}function rr(t,r,i){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(Je&2)!==0){var d=c.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),c.pending=r,zn(t,i)}return d=c.interleaved,d===null?(r.next=r,Xo(c)):(r.next=d.next,d.next=r),c.interleaved=r,zn(t,i)}function Ja(t,r,i){if(r=r.updateQueue,r!==null&&(r=r.shared,(i&4194240)!==0)){var c=r.lanes;c&=t.pendingLanes,i|=c,r.lanes=i,ho(t,i)}}function md(t,r){var i=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,i===c)){var d=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var j={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};m===null?d=m=j:m=m.next=j,i=i.next}while(i!==null);m===null?d=m=r:m=m.next=r}else d=m=r;i={baseState:c.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:c.shared,effects:c.effects},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=r:t.next=r,i.lastBaseUpdate=r}function Qa(t,r,i,c){var d=t.updateQueue;nr=!1;var m=d.firstBaseUpdate,j=d.lastBaseUpdate,C=d.shared.pending;if(C!==null){d.shared.pending=null;var R=C,H=R.next;R.next=null,j===null?m=H:j.next=H,j=R;var oe=t.alternate;oe!==null&&(oe=oe.updateQueue,C=oe.lastBaseUpdate,C!==j&&(C===null?oe.firstBaseUpdate=H:C.next=H,oe.lastBaseUpdate=R))}if(m!==null){var le=d.baseState;j=0,oe=H=R=null,C=m;do{var se=C.lane,je=C.eventTime;if((c&se)===se){oe!==null&&(oe=oe.next={eventTime:je,lane:0,tag:C.tag,payload:C.payload,callback:C.callback,next:null});e:{var ke=t,Ee=C;switch(se=r,je=i,Ee.tag){case 1:if(ke=Ee.payload,typeof ke=="function"){le=ke.call(je,le,se);break e}le=ke;break e;case 3:ke.flags=ke.flags&-65537|128;case 0:if(ke=Ee.payload,se=typeof ke=="function"?ke.call(je,le,se):ke,se==null)break e;le=q({},le,se);break e;case 2:nr=!0}}C.callback!==null&&C.lane!==0&&(t.flags|=64,se=d.effects,se===null?d.effects=[C]:se.push(C))}else je={eventTime:je,lane:se,tag:C.tag,payload:C.payload,callback:C.callback,next:null},oe===null?(H=oe=je,R=le):oe=oe.next=je,j|=se;if(C=C.next,C===null){if(C=d.shared.pending,C===null)break;se=C,C=se.next,se.next=null,d.lastBaseUpdate=se,d.shared.pending=null}}while(!0);if(oe===null&&(R=le),d.baseState=R,d.firstBaseUpdate=H,d.lastBaseUpdate=oe,r=d.shared.interleaved,r!==null){d=r;do j|=d.lane,d=d.next;while(d!==r)}else m===null&&(d.shared.lanes=0);Sr|=j,t.lanes=j,t.memoizedState=le}}function pd(t,r,i){if(t=r.effects,r.effects=null,t!==null)for(r=0;r<t.length;r++){var c=t[r],d=c.callback;if(d!==null){if(c.callback=null,c=i,typeof d!="function")throw Error(a(191,d));d.call(c)}}}var Bs={},En=Zn(Bs),Ds=Zn(Bs),Us=Zn(Bs);function wr(t){if(t===Bs)throw Error(a(174));return t}function el(t,r){switch(at(Us,r),at(Ds,t),at(En,Bs),t=r.nodeType,t){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Be(null,"");break;default:t=t===8?r.parentNode:r,r=t.namespaceURI||null,t=t.tagName,r=Be(r,t)}lt(En),at(En,r)}function ts(){lt(En),lt(Ds),lt(Us)}function gd(t){wr(Us.current);var r=wr(En.current),i=Be(r,t.type);r!==i&&(at(Ds,t),at(En,i))}function tl(t){Ds.current===t&&(lt(En),lt(Ds))}var ht=Zn(0);function Xa(t){for(var r=t;r!==null;){if(r.tag===13){var i=r.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var nl=[];function rl(){for(var t=0;t<nl.length;t++)nl[t]._workInProgressVersionPrimary=null;nl.length=0}var Za=I.ReactCurrentDispatcher,sl=I.ReactCurrentBatchConfig,jr=0,mt=null,Nt=null,Tt=null,ei=!1,Ws=!1,Hs=0,Sy=0;function zt(){throw Error(a(321))}function al(t,r){if(r===null)return!1;for(var i=0;i<r.length&&i<t.length;i++)if(!mn(t[i],r[i]))return!1;return!0}function il(t,r,i,c,d,m){if(jr=m,mt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Za.current=t===null||t.memoizedState===null?Cy:Ey,t=i(c,d),Ws){m=0;do{if(Ws=!1,Hs=0,25<=m)throw Error(a(301));m+=1,Tt=Nt=null,r.updateQueue=null,Za.current=Ty,t=i(c,d)}while(Ws)}if(Za.current=ri,r=Nt!==null&&Nt.next!==null,jr=0,Tt=Nt=mt=null,ei=!1,r)throw Error(a(300));return t}function ol(){var t=Hs!==0;return Hs=0,t}function Tn(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Tt===null?mt.memoizedState=Tt=t:Tt=Tt.next=t,Tt}function cn(){if(Nt===null){var t=mt.alternate;t=t!==null?t.memoizedState:null}else t=Nt.next;var r=Tt===null?mt.memoizedState:Tt.next;if(r!==null)Tt=r,Nt=t;else{if(t===null)throw Error(a(310));Nt=t,t={memoizedState:Nt.memoizedState,baseState:Nt.baseState,baseQueue:Nt.baseQueue,queue:Nt.queue,next:null},Tt===null?mt.memoizedState=Tt=t:Tt=Tt.next=t}return Tt}function Vs(t,r){return typeof r=="function"?r(t):r}function ll(t){var r=cn(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=t;var c=Nt,d=c.baseQueue,m=i.pending;if(m!==null){if(d!==null){var j=d.next;d.next=m.next,m.next=j}c.baseQueue=d=m,i.pending=null}if(d!==null){m=d.next,c=c.baseState;var C=j=null,R=null,H=m;do{var oe=H.lane;if((jr&oe)===oe)R!==null&&(R=R.next={lane:0,action:H.action,hasEagerState:H.hasEagerState,eagerState:H.eagerState,next:null}),c=H.hasEagerState?H.eagerState:t(c,H.action);else{var le={lane:oe,action:H.action,hasEagerState:H.hasEagerState,eagerState:H.eagerState,next:null};R===null?(C=R=le,j=c):R=R.next=le,mt.lanes|=oe,Sr|=oe}H=H.next}while(H!==null&&H!==m);R===null?j=c:R.next=C,mn(c,r.memoizedState)||(qt=!0),r.memoizedState=c,r.baseState=j,r.baseQueue=R,i.lastRenderedState=c}if(t=i.interleaved,t!==null){d=t;do m=d.lane,mt.lanes|=m,Sr|=m,d=d.next;while(d!==t)}else d===null&&(i.lanes=0);return[r.memoizedState,i.dispatch]}function cl(t){var r=cn(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=t;var c=i.dispatch,d=i.pending,m=r.memoizedState;if(d!==null){i.pending=null;var j=d=d.next;do m=t(m,j.action),j=j.next;while(j!==d);mn(m,r.memoizedState)||(qt=!0),r.memoizedState=m,r.baseQueue===null&&(r.baseState=m),i.lastRenderedState=m}return[m,c]}function yd(){}function vd(t,r){var i=mt,c=cn(),d=r(),m=!mn(c.memoizedState,d);if(m&&(c.memoizedState=d,qt=!0),c=c.queue,ul(jd.bind(null,i,c,t),[t]),c.getSnapshot!==r||m||Tt!==null&&Tt.memoizedState.tag&1){if(i.flags|=2048,Gs(9,wd.bind(null,i,c,d,r),void 0,null),At===null)throw Error(a(349));(jr&30)!==0||xd(i,r,d)}return d}function xd(t,r,i){t.flags|=16384,t={getSnapshot:r,value:i},r=mt.updateQueue,r===null?(r={lastEffect:null,stores:null},mt.updateQueue=r,r.stores=[t]):(i=r.stores,i===null?r.stores=[t]:i.push(t))}function wd(t,r,i,c){r.value=i,r.getSnapshot=c,Sd(r)&&bd(t)}function jd(t,r,i){return i(function(){Sd(r)&&bd(t)})}function Sd(t){var r=t.getSnapshot;t=t.value;try{var i=r();return!mn(t,i)}catch{return!0}}function bd(t){var r=zn(t,1);r!==null&&xn(r,t,1,-1)}function kd(t){var r=Tn();return typeof t=="function"&&(t=t()),r.memoizedState=r.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Vs,lastRenderedState:t},r.queue=t,t=t.dispatch=Ny.bind(null,mt,t),[r.memoizedState,t]}function Gs(t,r,i,c){return t={tag:t,create:r,destroy:i,deps:c,next:null},r=mt.updateQueue,r===null?(r={lastEffect:null,stores:null},mt.updateQueue=r,r.lastEffect=t.next=t):(i=r.lastEffect,i===null?r.lastEffect=t.next=t:(c=i.next,i.next=t,t.next=c,r.lastEffect=t)),t}function Nd(){return cn().memoizedState}function ti(t,r,i,c){var d=Tn();mt.flags|=t,d.memoizedState=Gs(1|r,i,void 0,c===void 0?null:c)}function ni(t,r,i,c){var d=cn();c=c===void 0?null:c;var m=void 0;if(Nt!==null){var j=Nt.memoizedState;if(m=j.destroy,c!==null&&al(c,j.deps)){d.memoizedState=Gs(r,i,m,c);return}}mt.flags|=t,d.memoizedState=Gs(1|r,i,m,c)}function Cd(t,r){return ti(8390656,8,t,r)}function ul(t,r){return ni(2048,8,t,r)}function Ed(t,r){return ni(4,2,t,r)}function Td(t,r){return ni(4,4,t,r)}function Ad(t,r){if(typeof r=="function")return t=t(),r(t),function(){r(null)};if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function Id(t,r,i){return i=i!=null?i.concat([t]):null,ni(4,4,Ad.bind(null,r,t),i)}function dl(){}function Rd(t,r){var i=cn();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&al(r,c[1])?c[0]:(i.memoizedState=[t,r],t)}function Pd(t,r){var i=cn();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&al(r,c[1])?c[0]:(t=t(),i.memoizedState=[t,r],t)}function $d(t,r,i){return(jr&21)===0?(t.baseState&&(t.baseState=!1,qt=!0),t.memoizedState=i):(mn(i,r)||(i=cu(),mt.lanes|=i,Sr|=i,t.baseState=!0),r)}function by(t,r){var i=tt;tt=i!==0&&4>i?i:4,t(!0);var c=sl.transition;sl.transition={};try{t(!1),r()}finally{tt=i,sl.transition=c}}function _d(){return cn().memoizedState}function ky(t,r,i){var c=or(t);if(i={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null},Ld(t))zd(r,i);else if(i=fd(t,r,i,c),i!==null){var d=Wt();xn(i,t,c,d),Fd(i,r,c)}}function Ny(t,r,i){var c=or(t),d={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null};if(Ld(t))zd(r,d);else{var m=t.alternate;if(t.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var j=r.lastRenderedState,C=m(j,i);if(d.hasEagerState=!0,d.eagerState=C,mn(C,j)){var R=r.interleaved;R===null?(d.next=d,Xo(r)):(d.next=R.next,R.next=d),r.interleaved=d;return}}catch{}finally{}i=fd(t,r,d,c),i!==null&&(d=Wt(),xn(i,t,c,d),Fd(i,r,c))}}function Ld(t){var r=t.alternate;return t===mt||r!==null&&r===mt}function zd(t,r){Ws=ei=!0;var i=t.pending;i===null?r.next=r:(r.next=i.next,i.next=r),t.pending=r}function Fd(t,r,i){if((i&4194240)!==0){var c=r.lanes;c&=t.pendingLanes,i|=c,r.lanes=i,ho(t,i)}}var ri={readContext:ln,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useInsertionEffect:zt,useLayoutEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useMutableSource:zt,useSyncExternalStore:zt,useId:zt,unstable_isNewReconciler:!1},Cy={readContext:ln,useCallback:function(t,r){return Tn().memoizedState=[t,r===void 0?null:r],t},useContext:ln,useEffect:Cd,useImperativeHandle:function(t,r,i){return i=i!=null?i.concat([t]):null,ti(4194308,4,Ad.bind(null,r,t),i)},useLayoutEffect:function(t,r){return ti(4194308,4,t,r)},useInsertionEffect:function(t,r){return ti(4,2,t,r)},useMemo:function(t,r){var i=Tn();return r=r===void 0?null:r,t=t(),i.memoizedState=[t,r],t},useReducer:function(t,r,i){var c=Tn();return r=i!==void 0?i(r):r,c.memoizedState=c.baseState=r,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:r},c.queue=t,t=t.dispatch=ky.bind(null,mt,t),[c.memoizedState,t]},useRef:function(t){var r=Tn();return t={current:t},r.memoizedState=t},useState:kd,useDebugValue:dl,useDeferredValue:function(t){return Tn().memoizedState=t},useTransition:function(){var t=kd(!1),r=t[0];return t=by.bind(null,t[1]),Tn().memoizedState=t,[r,t]},useMutableSource:function(){},useSyncExternalStore:function(t,r,i){var c=mt,d=Tn();if(ct){if(i===void 0)throw Error(a(407));i=i()}else{if(i=r(),At===null)throw Error(a(349));(jr&30)!==0||xd(c,r,i)}d.memoizedState=i;var m={value:i,getSnapshot:r};return d.queue=m,Cd(jd.bind(null,c,m,t),[t]),c.flags|=2048,Gs(9,wd.bind(null,c,m,i,r),void 0,null),i},useId:function(){var t=Tn(),r=At.identifierPrefix;if(ct){var i=Ln,c=_n;i=(c&~(1<<32-hn(c)-1)).toString(32)+i,r=":"+r+"R"+i,i=Hs++,0<i&&(r+="H"+i.toString(32)),r+=":"}else i=Sy++,r=":"+r+"r"+i.toString(32)+":";return t.memoizedState=r},unstable_isNewReconciler:!1},Ey={readContext:ln,useCallback:Rd,useContext:ln,useEffect:ul,useImperativeHandle:Id,useInsertionEffect:Ed,useLayoutEffect:Td,useMemo:Pd,useReducer:ll,useRef:Nd,useState:function(){return ll(Vs)},useDebugValue:dl,useDeferredValue:function(t){var r=cn();return $d(r,Nt.memoizedState,t)},useTransition:function(){var t=ll(Vs)[0],r=cn().memoizedState;return[t,r]},useMutableSource:yd,useSyncExternalStore:vd,useId:_d,unstable_isNewReconciler:!1},Ty={readContext:ln,useCallback:Rd,useContext:ln,useEffect:ul,useImperativeHandle:Id,useInsertionEffect:Ed,useLayoutEffect:Td,useMemo:Pd,useReducer:cl,useRef:Nd,useState:function(){return cl(Vs)},useDebugValue:dl,useDeferredValue:function(t){var r=cn();return Nt===null?r.memoizedState=t:$d(r,Nt.memoizedState,t)},useTransition:function(){var t=cl(Vs)[0],r=cn().memoizedState;return[t,r]},useMutableSource:yd,useSyncExternalStore:vd,useId:_d,unstable_isNewReconciler:!1};function gn(t,r){if(t&&t.defaultProps){r=q({},r),t=t.defaultProps;for(var i in t)r[i]===void 0&&(r[i]=t[i]);return r}return r}function fl(t,r,i,c){r=t.memoizedState,i=i(c,r),i=i==null?r:q({},r,i),t.memoizedState=i,t.lanes===0&&(t.updateQueue.baseState=i)}var si={isMounted:function(t){return(t=t._reactInternals)?bn(t)===t:!1},enqueueSetState:function(t,r,i){t=t._reactInternals;var c=Wt(),d=or(t),m=Fn(c,d);m.payload=r,i!=null&&(m.callback=i),r=rr(t,m,d),r!==null&&(xn(r,t,d,c),Ja(r,t,d))},enqueueReplaceState:function(t,r,i){t=t._reactInternals;var c=Wt(),d=or(t),m=Fn(c,d);m.tag=1,m.payload=r,i!=null&&(m.callback=i),r=rr(t,m,d),r!==null&&(xn(r,t,d,c),Ja(r,t,d))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var i=Wt(),c=or(t),d=Fn(i,c);d.tag=2,r!=null&&(d.callback=r),r=rr(t,d,c),r!==null&&(xn(r,t,c,i),Ja(r,t,c))}};function Md(t,r,i,c,d,m,j){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,m,j):r.prototype&&r.prototype.isPureReactComponent?!Ps(i,c)||!Ps(d,m):!0}function Od(t,r,i){var c=!1,d=er,m=r.contextType;return typeof m=="object"&&m!==null?m=ln(m):(d=Kt(r)?gr:Lt.current,c=r.contextTypes,m=(c=c!=null)?qr(t,d):er),r=new r(i,m),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=si,t.stateNode=r,r._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=d,t.__reactInternalMemoizedMaskedChildContext=m),r}function Bd(t,r,i,c){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(i,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(i,c),r.state!==t&&si.enqueueReplaceState(r,r.state,null)}function hl(t,r,i,c){var d=t.stateNode;d.props=i,d.state=t.memoizedState,d.refs={},Zo(t);var m=r.contextType;typeof m=="object"&&m!==null?d.context=ln(m):(m=Kt(r)?gr:Lt.current,d.context=qr(t,m)),d.state=t.memoizedState,m=r.getDerivedStateFromProps,typeof m=="function"&&(fl(t,r,m,i),d.state=t.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(r=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),r!==d.state&&si.enqueueReplaceState(d,d.state,null),Qa(t,i,d,c),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308)}function ns(t,r){try{var i="",c=r;do i+=ve(c),c=c.return;while(c);var d=i}catch(m){d=`
|
|
39
|
-
Error generating stack: `+m.message+`
|
|
40
|
-
`+m.stack}return{value:t,source:r,stack:d,digest:null}}function ml(t,r,i){return{value:t,source:null,stack:i??null,digest:r??null}}function pl(t,r){try{console.error(r.value)}catch(i){setTimeout(function(){throw i})}}var Ay=typeof WeakMap=="function"?WeakMap:Map;function Dd(t,r,i){i=Fn(-1,i),i.tag=3,i.payload={element:null};var c=r.value;return i.callback=function(){di||(di=!0,Il=c),pl(t,r)},i}function Ud(t,r,i){i=Fn(-1,i),i.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var d=r.value;i.payload=function(){return c(d)},i.callback=function(){pl(t,r)}}var m=t.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(i.callback=function(){pl(t,r),typeof c!="function"&&(ar===null?ar=new Set([this]):ar.add(this));var j=r.stack;this.componentDidCatch(r.value,{componentStack:j!==null?j:""})}),i}function Wd(t,r,i){var c=t.pingCache;if(c===null){c=t.pingCache=new Ay;var d=new Set;c.set(r,d)}else d=c.get(r),d===void 0&&(d=new Set,c.set(r,d));d.has(i)||(d.add(i),t=Wy.bind(null,t,r,i),r.then(t,t))}function Hd(t){do{var r;if((r=t.tag===13)&&(r=t.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return t;t=t.return}while(t!==null);return null}function Vd(t,r,i,c,d){return(t.mode&1)===0?(t===r?t.flags|=65536:(t.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(r=Fn(-1,1),r.tag=2,rr(i,r,1))),i.lanes|=1),t):(t.flags|=65536,t.lanes=d,t)}var Iy=I.ReactCurrentOwner,qt=!1;function Ut(t,r,i,c){r.child=t===null?dd(r,null,i,c):Xr(r,t.child,i,c)}function Gd(t,r,i,c,d){i=i.render;var m=r.ref;return es(r,d),c=il(t,r,i,c,m,d),i=ol(),t!==null&&!qt?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~d,Mn(t,r,d)):(ct&&i&&Wo(r),r.flags|=1,Ut(t,r,c,d),r.child)}function Kd(t,r,i,c,d){if(t===null){var m=i.type;return typeof m=="function"&&!Fl(m)&&m.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(r.tag=15,r.type=m,qd(t,r,m,c,d)):(t=yi(i.type,null,c,r,r.mode,d),t.ref=r.ref,t.return=r,r.child=t)}if(m=t.child,(t.lanes&d)===0){var j=m.memoizedProps;if(i=i.compare,i=i!==null?i:Ps,i(j,c)&&t.ref===r.ref)return Mn(t,r,d)}return r.flags|=1,t=cr(m,c),t.ref=r.ref,t.return=r,r.child=t}function qd(t,r,i,c,d){if(t!==null){var m=t.memoizedProps;if(Ps(m,c)&&t.ref===r.ref)if(qt=!1,r.pendingProps=c=m,(t.lanes&d)!==0)(t.flags&131072)!==0&&(qt=!0);else return r.lanes=t.lanes,Mn(t,r,d)}return gl(t,r,i,c,d)}function Yd(t,r,i){var c=r.pendingProps,d=c.children,m=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},at(ss,rn),rn|=i;else{if((i&1073741824)===0)return t=m!==null?m.baseLanes|i:i,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:t,cachePool:null,transitions:null},r.updateQueue=null,at(ss,rn),rn|=t,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=m!==null?m.baseLanes:i,at(ss,rn),rn|=c}else m!==null?(c=m.baseLanes|i,r.memoizedState=null):c=i,at(ss,rn),rn|=c;return Ut(t,r,d,i),r.child}function Jd(t,r){var i=r.ref;(t===null&&i!==null||t!==null&&t.ref!==i)&&(r.flags|=512,r.flags|=2097152)}function gl(t,r,i,c,d){var m=Kt(i)?gr:Lt.current;return m=qr(r,m),es(r,d),i=il(t,r,i,c,m,d),c=ol(),t!==null&&!qt?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~d,Mn(t,r,d)):(ct&&c&&Wo(r),r.flags|=1,Ut(t,r,i,d),r.child)}function Qd(t,r,i,c,d){if(Kt(i)){var m=!0;Ua(r)}else m=!1;if(es(r,d),r.stateNode===null)ii(t,r),Od(r,i,c),hl(r,i,c,d),c=!0;else if(t===null){var j=r.stateNode,C=r.memoizedProps;j.props=C;var R=j.context,H=i.contextType;typeof H=="object"&&H!==null?H=ln(H):(H=Kt(i)?gr:Lt.current,H=qr(r,H));var oe=i.getDerivedStateFromProps,le=typeof oe=="function"||typeof j.getSnapshotBeforeUpdate=="function";le||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(C!==c||R!==H)&&Bd(r,j,c,H),nr=!1;var se=r.memoizedState;j.state=se,Qa(r,c,j,d),R=r.memoizedState,C!==c||se!==R||Gt.current||nr?(typeof oe=="function"&&(fl(r,i,oe,c),R=r.memoizedState),(C=nr||Md(r,i,C,c,se,R,H))?(le||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(r.flags|=4194308)):(typeof j.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=R),j.props=c,j.state=R,j.context=H,c=C):(typeof j.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{j=r.stateNode,hd(t,r),C=r.memoizedProps,H=r.type===r.elementType?C:gn(r.type,C),j.props=H,le=r.pendingProps,se=j.context,R=i.contextType,typeof R=="object"&&R!==null?R=ln(R):(R=Kt(i)?gr:Lt.current,R=qr(r,R));var je=i.getDerivedStateFromProps;(oe=typeof je=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(C!==le||se!==R)&&Bd(r,j,c,R),nr=!1,se=r.memoizedState,j.state=se,Qa(r,c,j,d);var ke=r.memoizedState;C!==le||se!==ke||Gt.current||nr?(typeof je=="function"&&(fl(r,i,je,c),ke=r.memoizedState),(H=nr||Md(r,i,H,c,se,ke,R)||!1)?(oe||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(c,ke,R),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(c,ke,R)),typeof j.componentDidUpdate=="function"&&(r.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof j.componentDidUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(r.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=ke),j.props=c,j.state=ke,j.context=R,c=H):(typeof j.componentDidUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(r.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(r.flags|=1024),c=!1)}return yl(t,r,i,c,m,d)}function yl(t,r,i,c,d,m){Jd(t,r);var j=(r.flags&128)!==0;if(!c&&!j)return d&&nd(r,i,!1),Mn(t,r,m);c=r.stateNode,Iy.current=r;var C=j&&typeof i.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,t!==null&&j?(r.child=Xr(r,t.child,null,m),r.child=Xr(r,null,C,m)):Ut(t,r,C,m),r.memoizedState=c.state,d&&nd(r,i,!0),r.child}function Xd(t){var r=t.stateNode;r.pendingContext?ed(t,r.pendingContext,r.pendingContext!==r.context):r.context&&ed(t,r.context,!1),el(t,r.containerInfo)}function Zd(t,r,i,c,d){return Qr(),Ko(d),r.flags|=256,Ut(t,r,i,c),r.child}var vl={dehydrated:null,treeContext:null,retryLane:0};function xl(t){return{baseLanes:t,cachePool:null,transitions:null}}function ef(t,r,i){var c=r.pendingProps,d=ht.current,m=!1,j=(r.flags&128)!==0,C;if((C=j)||(C=t!==null&&t.memoizedState===null?!1:(d&2)!==0),C?(m=!0,r.flags&=-129):(t===null||t.memoizedState!==null)&&(d|=1),at(ht,d&1),t===null)return Go(r),t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((r.mode&1)===0?r.lanes=1:t.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(j=c.children,t=c.fallback,m?(c=r.mode,m=r.child,j={mode:"hidden",children:j},(c&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=j):m=vi(j,c,0,null),t=Cr(t,c,i,null),m.return=r,t.return=r,m.sibling=t,r.child=m,r.child.memoizedState=xl(i),r.memoizedState=vl,t):wl(r,j));if(d=t.memoizedState,d!==null&&(C=d.dehydrated,C!==null))return Ry(t,r,j,c,C,d,i);if(m){m=c.fallback,j=r.mode,d=t.child,C=d.sibling;var R={mode:"hidden",children:c.children};return(j&1)===0&&r.child!==d?(c=r.child,c.childLanes=0,c.pendingProps=R,r.deletions=null):(c=cr(d,R),c.subtreeFlags=d.subtreeFlags&14680064),C!==null?m=cr(C,m):(m=Cr(m,j,i,null),m.flags|=2),m.return=r,c.return=r,c.sibling=m,r.child=c,c=m,m=r.child,j=t.child.memoizedState,j=j===null?xl(i):{baseLanes:j.baseLanes|i,cachePool:null,transitions:j.transitions},m.memoizedState=j,m.childLanes=t.childLanes&~i,r.memoizedState=vl,c}return m=t.child,t=m.sibling,c=cr(m,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=i),c.return=r,c.sibling=null,t!==null&&(i=r.deletions,i===null?(r.deletions=[t],r.flags|=16):i.push(t)),r.child=c,r.memoizedState=null,c}function wl(t,r){return r=vi({mode:"visible",children:r},t.mode,0,null),r.return=t,t.child=r}function ai(t,r,i,c){return c!==null&&Ko(c),Xr(r,t.child,null,i),t=wl(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function Ry(t,r,i,c,d,m,j){if(i)return r.flags&256?(r.flags&=-257,c=ml(Error(a(422))),ai(t,r,j,c)):r.memoizedState!==null?(r.child=t.child,r.flags|=128,null):(m=c.fallback,d=r.mode,c=vi({mode:"visible",children:c.children},d,0,null),m=Cr(m,d,j,null),m.flags|=2,c.return=r,m.return=r,c.sibling=m,r.child=c,(r.mode&1)!==0&&Xr(r,t.child,null,j),r.child.memoizedState=xl(j),r.memoizedState=vl,m);if((r.mode&1)===0)return ai(t,r,j,null);if(d.data==="$!"){if(c=d.nextSibling&&d.nextSibling.dataset,c)var C=c.dgst;return c=C,m=Error(a(419)),c=ml(m,c,void 0),ai(t,r,j,c)}if(C=(j&t.childLanes)!==0,qt||C){if(c=At,c!==null){switch(j&-j){case 4:d=2;break;case 16:d=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:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(c.suspendedLanes|j))!==0?0:d,d!==0&&d!==m.retryLane&&(m.retryLane=d,zn(t,d),xn(c,t,d,-1))}return zl(),c=ml(Error(a(421))),ai(t,r,j,c)}return d.data==="$?"?(r.flags|=128,r.child=t.child,r=Hy.bind(null,t),d._reactRetry=r,null):(t=m.treeContext,nn=Xn(d.nextSibling),tn=r,ct=!0,pn=null,t!==null&&(an[on++]=_n,an[on++]=Ln,an[on++]=yr,_n=t.id,Ln=t.overflow,yr=r),r=wl(r,c.children),r.flags|=4096,r)}function tf(t,r,i){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),Qo(t.return,r,i)}function jl(t,r,i,c,d){var m=t.memoizedState;m===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:i,tailMode:d}:(m.isBackwards=r,m.rendering=null,m.renderingStartTime=0,m.last=c,m.tail=i,m.tailMode=d)}function nf(t,r,i){var c=r.pendingProps,d=c.revealOrder,m=c.tail;if(Ut(t,r,c.children,i),c=ht.current,(c&2)!==0)c=c&1|2,r.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&tf(t,i,r);else if(t.tag===19)tf(t,i,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(at(ht,c),(r.mode&1)===0)r.memoizedState=null;else switch(d){case"forwards":for(i=r.child,d=null;i!==null;)t=i.alternate,t!==null&&Xa(t)===null&&(d=i),i=i.sibling;i=d,i===null?(d=r.child,r.child=null):(d=i.sibling,i.sibling=null),jl(r,!1,d,i,m);break;case"backwards":for(i=null,d=r.child,r.child=null;d!==null;){if(t=d.alternate,t!==null&&Xa(t)===null){r.child=d;break}t=d.sibling,d.sibling=i,i=d,d=t}jl(r,!0,i,null,m);break;case"together":jl(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ii(t,r){(r.mode&1)===0&&t!==null&&(t.alternate=null,r.alternate=null,r.flags|=2)}function Mn(t,r,i){if(t!==null&&(r.dependencies=t.dependencies),Sr|=r.lanes,(i&r.childLanes)===0)return null;if(t!==null&&r.child!==t.child)throw Error(a(153));if(r.child!==null){for(t=r.child,i=cr(t,t.pendingProps),r.child=i,i.return=r;t.sibling!==null;)t=t.sibling,i=i.sibling=cr(t,t.pendingProps),i.return=r;i.sibling=null}return r.child}function Py(t,r,i){switch(r.tag){case 3:Xd(r),Qr();break;case 5:gd(r);break;case 1:Kt(r.type)&&Ua(r);break;case 4:el(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,d=r.memoizedProps.value;at(qa,c._currentValue),c._currentValue=d;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(at(ht,ht.current&1),r.flags|=128,null):(i&r.child.childLanes)!==0?ef(t,r,i):(at(ht,ht.current&1),t=Mn(t,r,i),t!==null?t.sibling:null);at(ht,ht.current&1);break;case 19:if(c=(i&r.childLanes)!==0,(t.flags&128)!==0){if(c)return nf(t,r,i);r.flags|=128}if(d=r.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),at(ht,ht.current),c)break;return null;case 22:case 23:return r.lanes=0,Yd(t,r,i)}return Mn(t,r,i)}var rf,Sl,sf,af;rf=function(t,r){for(var i=r.child;i!==null;){if(i.tag===5||i.tag===6)t.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},Sl=function(){},sf=function(t,r,i,c){var d=t.memoizedProps;if(d!==c){t=r.stateNode,wr(En.current);var m=null;switch(i){case"input":d=me(t,d),c=me(t,c),m=[];break;case"select":d=q({},d,{value:void 0}),c=q({},c,{value:void 0}),m=[];break;case"textarea":d=dt(t,d),c=dt(t,c),m=[];break;default:typeof d.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=Oa)}et(i,c);var j;i=null;for(H in d)if(!c.hasOwnProperty(H)&&d.hasOwnProperty(H)&&d[H]!=null)if(H==="style"){var C=d[H];for(j in C)C.hasOwnProperty(j)&&(i||(i={}),i[j]="")}else H!=="dangerouslySetInnerHTML"&&H!=="children"&&H!=="suppressContentEditableWarning"&&H!=="suppressHydrationWarning"&&H!=="autoFocus"&&(l.hasOwnProperty(H)?m||(m=[]):(m=m||[]).push(H,null));for(H in c){var R=c[H];if(C=d!=null?d[H]:void 0,c.hasOwnProperty(H)&&R!==C&&(R!=null||C!=null))if(H==="style")if(C){for(j in C)!C.hasOwnProperty(j)||R&&R.hasOwnProperty(j)||(i||(i={}),i[j]="");for(j in R)R.hasOwnProperty(j)&&C[j]!==R[j]&&(i||(i={}),i[j]=R[j])}else i||(m||(m=[]),m.push(H,i)),i=R;else H==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,C=C?C.__html:void 0,R!=null&&C!==R&&(m=m||[]).push(H,R)):H==="children"?typeof R!="string"&&typeof R!="number"||(m=m||[]).push(H,""+R):H!=="suppressContentEditableWarning"&&H!=="suppressHydrationWarning"&&(l.hasOwnProperty(H)?(R!=null&&H==="onScroll"&&ot("scroll",t),m||C===R||(m=[])):(m=m||[]).push(H,R))}i&&(m=m||[]).push("style",i);var H=m;(r.updateQueue=H)&&(r.flags|=4)}},af=function(t,r,i,c){i!==c&&(r.flags|=4)};function Ks(t,r){if(!ct)switch(t.tailMode){case"hidden":r=t.tail;for(var i=null;r!==null;)r.alternate!==null&&(i=r),r=r.sibling;i===null?t.tail=null:i.sibling=null;break;case"collapsed":i=t.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function Ft(t){var r=t.alternate!==null&&t.alternate.child===t.child,i=0,c=0;if(r)for(var d=t.child;d!==null;)i|=d.lanes|d.childLanes,c|=d.subtreeFlags&14680064,c|=d.flags&14680064,d.return=t,d=d.sibling;else for(d=t.child;d!==null;)i|=d.lanes|d.childLanes,c|=d.subtreeFlags,c|=d.flags,d.return=t,d=d.sibling;return t.subtreeFlags|=c,t.childLanes=i,r}function $y(t,r,i){var c=r.pendingProps;switch(Ho(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ft(r),null;case 1:return Kt(r.type)&&Da(),Ft(r),null;case 3:return c=r.stateNode,ts(),lt(Gt),lt(Lt),rl(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Ga(r)?r.flags|=4:t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,pn!==null&&($l(pn),pn=null))),Sl(t,r),Ft(r),null;case 5:tl(r);var d=wr(Us.current);if(i=r.type,t!==null&&r.stateNode!=null)sf(t,r,i,c,d),t.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!c){if(r.stateNode===null)throw Error(a(166));return Ft(r),null}if(t=wr(En.current),Ga(r)){c=r.stateNode,i=r.type;var m=r.memoizedProps;switch(c[Cn]=r,c[Fs]=m,t=(r.mode&1)!==0,i){case"dialog":ot("cancel",c),ot("close",c);break;case"iframe":case"object":case"embed":ot("load",c);break;case"video":case"audio":for(d=0;d<_s.length;d++)ot(_s[d],c);break;case"source":ot("error",c);break;case"img":case"image":case"link":ot("error",c),ot("load",c);break;case"details":ot("toggle",c);break;case"input":Te(c,m),ot("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!m.multiple},ot("invalid",c);break;case"textarea":ft(c,m),ot("invalid",c)}et(i,m),d=null;for(var j in m)if(m.hasOwnProperty(j)){var C=m[j];j==="children"?typeof C=="string"?c.textContent!==C&&(m.suppressHydrationWarning!==!0&&Ma(c.textContent,C,t),d=["children",C]):typeof C=="number"&&c.textContent!==""+C&&(m.suppressHydrationWarning!==!0&&Ma(c.textContent,C,t),d=["children",""+C]):l.hasOwnProperty(j)&&C!=null&&j==="onScroll"&&ot("scroll",c)}switch(i){case"input":ze(c),nt(c,m,!0);break;case"textarea":ze(c),pe(c);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(c.onclick=Oa)}c=d,r.updateQueue=c,c!==null&&(r.flags|=4)}else{j=d.nodeType===9?d:d.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=Pe(i)),t==="http://www.w3.org/1999/xhtml"?i==="script"?(t=j.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof c.is=="string"?t=j.createElement(i,{is:c.is}):(t=j.createElement(i),i==="select"&&(j=t,c.multiple?j.multiple=!0:c.size&&(j.size=c.size))):t=j.createElementNS(t,i),t[Cn]=r,t[Fs]=c,rf(t,r,!1,!1),r.stateNode=t;e:{switch(j=W(i,c),i){case"dialog":ot("cancel",t),ot("close",t),d=c;break;case"iframe":case"object":case"embed":ot("load",t),d=c;break;case"video":case"audio":for(d=0;d<_s.length;d++)ot(_s[d],t);d=c;break;case"source":ot("error",t),d=c;break;case"img":case"image":case"link":ot("error",t),ot("load",t),d=c;break;case"details":ot("toggle",t),d=c;break;case"input":Te(t,c),d=me(t,c),ot("invalid",t);break;case"option":d=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},d=q({},c,{value:void 0}),ot("invalid",t);break;case"textarea":ft(t,c),d=dt(t,c),ot("invalid",t);break;default:d=c}et(i,d),C=d;for(m in C)if(C.hasOwnProperty(m)){var R=C[m];m==="style"?Vt(t,R):m==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&J(t,R)):m==="children"?typeof R=="string"?(i!=="textarea"||R!=="")&&ye(t,R):typeof R=="number"&&ye(t,""+R):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(l.hasOwnProperty(m)?R!=null&&m==="onScroll"&&ot("scroll",t):R!=null&&P(t,m,R,j))}switch(i){case"input":ze(t),nt(t,c,!1);break;case"textarea":ze(t),pe(t);break;case"option":c.value!=null&&t.setAttribute("value",""+ce(c.value));break;case"select":t.multiple=!!c.multiple,m=c.value,m!=null?He(t,!!c.multiple,m,!1):c.defaultValue!=null&&He(t,!!c.multiple,c.defaultValue,!0);break;default:typeof d.onClick=="function"&&(t.onclick=Oa)}switch(i){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Ft(r),null;case 6:if(t&&r.stateNode!=null)af(t,r,t.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(a(166));if(i=wr(Us.current),wr(En.current),Ga(r)){if(c=r.stateNode,i=r.memoizedProps,c[Cn]=r,(m=c.nodeValue!==i)&&(t=tn,t!==null))switch(t.tag){case 3:Ma(c.nodeValue,i,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Ma(c.nodeValue,i,(t.mode&1)!==0)}m&&(r.flags|=4)}else c=(i.nodeType===9?i:i.ownerDocument).createTextNode(c),c[Cn]=r,r.stateNode=c}return Ft(r),null;case 13:if(lt(ht),c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(ct&&nn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)ld(),Qr(),r.flags|=98560,m=!1;else if(m=Ga(r),c!==null&&c.dehydrated!==null){if(t===null){if(!m)throw Error(a(318));if(m=r.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(a(317));m[Cn]=r}else Qr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Ft(r),m=!1}else pn!==null&&($l(pn),pn=null),m=!0;if(!m)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=i,r):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(t===null||(ht.current&1)!==0?Ct===0&&(Ct=3):zl())),r.updateQueue!==null&&(r.flags|=4),Ft(r),null);case 4:return ts(),Sl(t,r),t===null&&Ls(r.stateNode.containerInfo),Ft(r),null;case 10:return Jo(r.type._context),Ft(r),null;case 17:return Kt(r.type)&&Da(),Ft(r),null;case 19:if(lt(ht),m=r.memoizedState,m===null)return Ft(r),null;if(c=(r.flags&128)!==0,j=m.rendering,j===null)if(c)Ks(m,!1);else{if(Ct!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(j=Xa(t),j!==null){for(r.flags|=128,Ks(m,!1),c=j.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),r.subtreeFlags=0,c=i,i=r.child;i!==null;)m=i,t=c,m.flags&=14680066,j=m.alternate,j===null?(m.childLanes=0,m.lanes=t,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=j.childLanes,m.lanes=j.lanes,m.child=j.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=j.memoizedProps,m.memoizedState=j.memoizedState,m.updateQueue=j.updateQueue,m.type=j.type,t=j.dependencies,m.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),i=i.sibling;return at(ht,ht.current&1|2),r.child}t=t.sibling}m.tail!==null&&vt()>as&&(r.flags|=128,c=!0,Ks(m,!1),r.lanes=4194304)}else{if(!c)if(t=Xa(j),t!==null){if(r.flags|=128,c=!0,i=t.updateQueue,i!==null&&(r.updateQueue=i,r.flags|=4),Ks(m,!0),m.tail===null&&m.tailMode==="hidden"&&!j.alternate&&!ct)return Ft(r),null}else 2*vt()-m.renderingStartTime>as&&i!==1073741824&&(r.flags|=128,c=!0,Ks(m,!1),r.lanes=4194304);m.isBackwards?(j.sibling=r.child,r.child=j):(i=m.last,i!==null?i.sibling=j:r.child=j,m.last=j)}return m.tail!==null?(r=m.tail,m.rendering=r,m.tail=r.sibling,m.renderingStartTime=vt(),r.sibling=null,i=ht.current,at(ht,c?i&1|2:i&1),r):(Ft(r),null);case 22:case 23:return Ll(),c=r.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(rn&1073741824)!==0&&(Ft(r),r.subtreeFlags&6&&(r.flags|=8192)):Ft(r),null;case 24:return null;case 25:return null}throw Error(a(156,r.tag))}function _y(t,r){switch(Ho(r),r.tag){case 1:return Kt(r.type)&&Da(),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return ts(),lt(Gt),lt(Lt),rl(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 5:return tl(r),null;case 13:if(lt(ht),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(a(340));Qr()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return lt(ht),null;case 4:return ts(),null;case 10:return Jo(r.type._context),null;case 22:case 23:return Ll(),null;case 24:return null;default:return null}}var oi=!1,Mt=!1,Ly=typeof WeakSet=="function"?WeakSet:Set,be=null;function rs(t,r){var i=t.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(c){pt(t,r,c)}else i.current=null}function bl(t,r,i){try{i()}catch(c){pt(t,r,c)}}var of=!1;function zy(t,r){if(Lo=Ea,t=Mu(),Eo(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var c=i.getSelection&&i.getSelection();if(c&&c.rangeCount!==0){i=c.anchorNode;var d=c.anchorOffset,m=c.focusNode;c=c.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var j=0,C=-1,R=-1,H=0,oe=0,le=t,se=null;t:for(;;){for(var je;le!==i||d!==0&&le.nodeType!==3||(C=j+d),le!==m||c!==0&&le.nodeType!==3||(R=j+c),le.nodeType===3&&(j+=le.nodeValue.length),(je=le.firstChild)!==null;)se=le,le=je;for(;;){if(le===t)break t;if(se===i&&++H===d&&(C=j),se===m&&++oe===c&&(R=j),(je=le.nextSibling)!==null)break;le=se,se=le.parentNode}le=je}i=C===-1||R===-1?null:{start:C,end:R}}else i=null}i=i||{start:0,end:0}}else i=null;for(zo={focusedElem:t,selectionRange:i},Ea=!1,be=r;be!==null;)if(r=be,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,be=t;else for(;be!==null;){r=be;try{var ke=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(ke!==null){var Ee=ke.memoizedProps,xt=ke.memoizedState,F=r.stateNode,L=F.getSnapshotBeforeUpdate(r.elementType===r.type?Ee:gn(r.type,Ee),xt);F.__reactInternalSnapshotBeforeUpdate=L}break;case 3:var D=r.stateNode.containerInfo;D.nodeType===1?D.textContent="":D.nodeType===9&&D.documentElement&&D.removeChild(D.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(he){pt(r,r.return,he)}if(t=r.sibling,t!==null){t.return=r.return,be=t;break}be=r.return}return ke=of,of=!1,ke}function qs(t,r,i){var c=r.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var d=c=c.next;do{if((d.tag&t)===t){var m=d.destroy;d.destroy=void 0,m!==void 0&&bl(r,i,m)}d=d.next}while(d!==c)}}function li(t,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var c=i.create;i.destroy=c()}i=i.next}while(i!==r)}}function kl(t){var r=t.ref;if(r!==null){var i=t.stateNode;switch(t.tag){case 5:t=i;break;default:t=i}typeof r=="function"?r(t):r.current=t}}function lf(t){var r=t.alternate;r!==null&&(t.alternate=null,lf(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&(delete r[Cn],delete r[Fs],delete r[Bo],delete r[vy],delete r[xy])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function cf(t){return t.tag===5||t.tag===3||t.tag===4}function uf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||cf(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Nl(t,r,i){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?i.nodeType===8?i.parentNode.insertBefore(t,r):i.insertBefore(t,r):(i.nodeType===8?(r=i.parentNode,r.insertBefore(t,i)):(r=i,r.appendChild(t)),i=i._reactRootContainer,i!=null||r.onclick!==null||(r.onclick=Oa));else if(c!==4&&(t=t.child,t!==null))for(Nl(t,r,i),t=t.sibling;t!==null;)Nl(t,r,i),t=t.sibling}function Cl(t,r,i){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?i.insertBefore(t,r):i.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(Cl(t,r,i),t=t.sibling;t!==null;)Cl(t,r,i),t=t.sibling}var $t=null,yn=!1;function sr(t,r,i){for(i=i.child;i!==null;)df(t,r,i),i=i.sibling}function df(t,r,i){if(Nn&&typeof Nn.onCommitFiberUnmount=="function")try{Nn.onCommitFiberUnmount(ja,i)}catch{}switch(i.tag){case 5:Mt||rs(i,r);case 6:var c=$t,d=yn;$t=null,sr(t,r,i),$t=c,yn=d,$t!==null&&(yn?(t=$t,i=i.stateNode,t.nodeType===8?t.parentNode.removeChild(i):t.removeChild(i)):$t.removeChild(i.stateNode));break;case 18:$t!==null&&(yn?(t=$t,i=i.stateNode,t.nodeType===8?Oo(t.parentNode,i):t.nodeType===1&&Oo(t,i),Cs(t)):Oo($t,i.stateNode));break;case 4:c=$t,d=yn,$t=i.stateNode.containerInfo,yn=!0,sr(t,r,i),$t=c,yn=d;break;case 0:case 11:case 14:case 15:if(!Mt&&(c=i.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){d=c=c.next;do{var m=d,j=m.destroy;m=m.tag,j!==void 0&&((m&2)!==0||(m&4)!==0)&&bl(i,r,j),d=d.next}while(d!==c)}sr(t,r,i);break;case 1:if(!Mt&&(rs(i,r),c=i.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=i.memoizedProps,c.state=i.memoizedState,c.componentWillUnmount()}catch(C){pt(i,r,C)}sr(t,r,i);break;case 21:sr(t,r,i);break;case 22:i.mode&1?(Mt=(c=Mt)||i.memoizedState!==null,sr(t,r,i),Mt=c):sr(t,r,i);break;default:sr(t,r,i)}}function ff(t){var r=t.updateQueue;if(r!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new Ly),r.forEach(function(c){var d=Vy.bind(null,t,c);i.has(c)||(i.add(c),c.then(d,d))})}}function vn(t,r){var i=r.deletions;if(i!==null)for(var c=0;c<i.length;c++){var d=i[c];try{var m=t,j=r,C=j;e:for(;C!==null;){switch(C.tag){case 5:$t=C.stateNode,yn=!1;break e;case 3:$t=C.stateNode.containerInfo,yn=!0;break e;case 4:$t=C.stateNode.containerInfo,yn=!0;break e}C=C.return}if($t===null)throw Error(a(160));df(m,j,d),$t=null,yn=!1;var R=d.alternate;R!==null&&(R.return=null),d.return=null}catch(H){pt(d,r,H)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)hf(r,t),r=r.sibling}function hf(t,r){var i=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(vn(r,t),An(t),c&4){try{qs(3,t,t.return),li(3,t)}catch(Ee){pt(t,t.return,Ee)}try{qs(5,t,t.return)}catch(Ee){pt(t,t.return,Ee)}}break;case 1:vn(r,t),An(t),c&512&&i!==null&&rs(i,i.return);break;case 5:if(vn(r,t),An(t),c&512&&i!==null&&rs(i,i.return),t.flags&32){var d=t.stateNode;try{ye(d,"")}catch(Ee){pt(t,t.return,Ee)}}if(c&4&&(d=t.stateNode,d!=null)){var m=t.memoizedProps,j=i!==null?i.memoizedProps:m,C=t.type,R=t.updateQueue;if(t.updateQueue=null,R!==null)try{C==="input"&&m.type==="radio"&&m.name!=null&&Le(d,m),W(C,j);var H=W(C,m);for(j=0;j<R.length;j+=2){var oe=R[j],le=R[j+1];oe==="style"?Vt(d,le):oe==="dangerouslySetInnerHTML"?J(d,le):oe==="children"?ye(d,le):P(d,oe,le,H)}switch(C){case"input":ge(d,m);break;case"textarea":Me(d,m);break;case"select":var se=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!m.multiple;var je=m.value;je!=null?He(d,!!m.multiple,je,!1):se!==!!m.multiple&&(m.defaultValue!=null?He(d,!!m.multiple,m.defaultValue,!0):He(d,!!m.multiple,m.multiple?[]:"",!1))}d[Fs]=m}catch(Ee){pt(t,t.return,Ee)}}break;case 6:if(vn(r,t),An(t),c&4){if(t.stateNode===null)throw Error(a(162));d=t.stateNode,m=t.memoizedProps;try{d.nodeValue=m}catch(Ee){pt(t,t.return,Ee)}}break;case 3:if(vn(r,t),An(t),c&4&&i!==null&&i.memoizedState.isDehydrated)try{Cs(r.containerInfo)}catch(Ee){pt(t,t.return,Ee)}break;case 4:vn(r,t),An(t);break;case 13:vn(r,t),An(t),d=t.child,d.flags&8192&&(m=d.memoizedState!==null,d.stateNode.isHidden=m,!m||d.alternate!==null&&d.alternate.memoizedState!==null||(Al=vt())),c&4&&ff(t);break;case 22:if(oe=i!==null&&i.memoizedState!==null,t.mode&1?(Mt=(H=Mt)||oe,vn(r,t),Mt=H):vn(r,t),An(t),c&8192){if(H=t.memoizedState!==null,(t.stateNode.isHidden=H)&&!oe&&(t.mode&1)!==0)for(be=t,oe=t.child;oe!==null;){for(le=be=oe;be!==null;){switch(se=be,je=se.child,se.tag){case 0:case 11:case 14:case 15:qs(4,se,se.return);break;case 1:rs(se,se.return);var ke=se.stateNode;if(typeof ke.componentWillUnmount=="function"){c=se,i=se.return;try{r=c,ke.props=r.memoizedProps,ke.state=r.memoizedState,ke.componentWillUnmount()}catch(Ee){pt(c,i,Ee)}}break;case 5:rs(se,se.return);break;case 22:if(se.memoizedState!==null){gf(le);continue}}je!==null?(je.return=se,be=je):gf(le)}oe=oe.sibling}e:for(oe=null,le=t;;){if(le.tag===5){if(oe===null){oe=le;try{d=le.stateNode,H?(m=d.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none"):(C=le.stateNode,R=le.memoizedProps.style,j=R!=null&&R.hasOwnProperty("display")?R.display:null,C.style.display=rt("display",j))}catch(Ee){pt(t,t.return,Ee)}}}else if(le.tag===6){if(oe===null)try{le.stateNode.nodeValue=H?"":le.memoizedProps}catch(Ee){pt(t,t.return,Ee)}}else if((le.tag!==22&&le.tag!==23||le.memoizedState===null||le===t)&&le.child!==null){le.child.return=le,le=le.child;continue}if(le===t)break e;for(;le.sibling===null;){if(le.return===null||le.return===t)break e;oe===le&&(oe=null),le=le.return}oe===le&&(oe=null),le.sibling.return=le.return,le=le.sibling}}break;case 19:vn(r,t),An(t),c&4&&ff(t);break;case 21:break;default:vn(r,t),An(t)}}function An(t){var r=t.flags;if(r&2){try{e:{for(var i=t.return;i!==null;){if(cf(i)){var c=i;break e}i=i.return}throw Error(a(160))}switch(c.tag){case 5:var d=c.stateNode;c.flags&32&&(ye(d,""),c.flags&=-33);var m=uf(t);Cl(t,m,d);break;case 3:case 4:var j=c.stateNode.containerInfo,C=uf(t);Nl(t,C,j);break;default:throw Error(a(161))}}catch(R){pt(t,t.return,R)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function Fy(t,r,i){be=t,mf(t)}function mf(t,r,i){for(var c=(t.mode&1)!==0;be!==null;){var d=be,m=d.child;if(d.tag===22&&c){var j=d.memoizedState!==null||oi;if(!j){var C=d.alternate,R=C!==null&&C.memoizedState!==null||Mt;C=oi;var H=Mt;if(oi=j,(Mt=R)&&!H)for(be=d;be!==null;)j=be,R=j.child,j.tag===22&&j.memoizedState!==null?yf(d):R!==null?(R.return=j,be=R):yf(d);for(;m!==null;)be=m,mf(m),m=m.sibling;be=d,oi=C,Mt=H}pf(t)}else(d.subtreeFlags&8772)!==0&&m!==null?(m.return=d,be=m):pf(t)}}function pf(t){for(;be!==null;){var r=be;if((r.flags&8772)!==0){var i=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Mt||li(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!Mt)if(i===null)c.componentDidMount();else{var d=r.elementType===r.type?i.memoizedProps:gn(r.type,i.memoizedProps);c.componentDidUpdate(d,i.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var m=r.updateQueue;m!==null&&pd(r,m,c);break;case 3:var j=r.updateQueue;if(j!==null){if(i=null,r.child!==null)switch(r.child.tag){case 5:i=r.child.stateNode;break;case 1:i=r.child.stateNode}pd(r,j,i)}break;case 5:var C=r.stateNode;if(i===null&&r.flags&4){i=C;var R=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":R.autoFocus&&i.focus();break;case"img":R.src&&(i.src=R.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var H=r.alternate;if(H!==null){var oe=H.memoizedState;if(oe!==null){var le=oe.dehydrated;le!==null&&Cs(le)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}Mt||r.flags&512&&kl(r)}catch(se){pt(r,r.return,se)}}if(r===t){be=null;break}if(i=r.sibling,i!==null){i.return=r.return,be=i;break}be=r.return}}function gf(t){for(;be!==null;){var r=be;if(r===t){be=null;break}var i=r.sibling;if(i!==null){i.return=r.return,be=i;break}be=r.return}}function yf(t){for(;be!==null;){var r=be;try{switch(r.tag){case 0:case 11:case 15:var i=r.return;try{li(4,r)}catch(R){pt(r,i,R)}break;case 1:var c=r.stateNode;if(typeof c.componentDidMount=="function"){var d=r.return;try{c.componentDidMount()}catch(R){pt(r,d,R)}}var m=r.return;try{kl(r)}catch(R){pt(r,m,R)}break;case 5:var j=r.return;try{kl(r)}catch(R){pt(r,j,R)}}}catch(R){pt(r,r.return,R)}if(r===t){be=null;break}var C=r.sibling;if(C!==null){C.return=r.return,be=C;break}be=r.return}}var My=Math.ceil,ci=I.ReactCurrentDispatcher,El=I.ReactCurrentOwner,un=I.ReactCurrentBatchConfig,Je=0,At=null,bt=null,_t=0,rn=0,ss=Zn(0),Ct=0,Ys=null,Sr=0,ui=0,Tl=0,Js=null,Yt=null,Al=0,as=1/0,On=null,di=!1,Il=null,ar=null,fi=!1,ir=null,hi=0,Qs=0,Rl=null,mi=-1,pi=0;function Wt(){return(Je&6)!==0?vt():mi!==-1?mi:mi=vt()}function or(t){return(t.mode&1)===0?1:(Je&2)!==0&&_t!==0?_t&-_t:jy.transition!==null?(pi===0&&(pi=cu()),pi):(t=tt,t!==0||(t=window.event,t=t===void 0?16:vu(t.type)),t)}function xn(t,r,i,c){if(50<Qs)throw Qs=0,Rl=null,Error(a(185));js(t,i,c),((Je&2)===0||t!==At)&&(t===At&&((Je&2)===0&&(ui|=i),Ct===4&&lr(t,_t)),Jt(t,c),i===1&&Je===0&&(r.mode&1)===0&&(as=vt()+500,Wa&&tr()))}function Jt(t,r){var i=t.callbackNode;jg(t,r);var c=ka(t,t===At?_t:0);if(c===0)i!==null&&iu(i),t.callbackNode=null,t.callbackPriority=0;else if(r=c&-c,t.callbackPriority!==r){if(i!=null&&iu(i),r===1)t.tag===0?wy(xf.bind(null,t)):rd(xf.bind(null,t)),gy(function(){(Je&6)===0&&tr()}),i=null;else{switch(uu(c)){case 1:i=co;break;case 4:i=ou;break;case 16:i=wa;break;case 536870912:i=lu;break;default:i=wa}i=Ef(i,vf.bind(null,t))}t.callbackPriority=r,t.callbackNode=i}}function vf(t,r){if(mi=-1,pi=0,(Je&6)!==0)throw Error(a(327));var i=t.callbackNode;if(is()&&t.callbackNode!==i)return null;var c=ka(t,t===At?_t:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||r)r=gi(t,c);else{r=c;var d=Je;Je|=2;var m=jf();(At!==t||_t!==r)&&(On=null,as=vt()+500,kr(t,r));do try{Dy();break}catch(C){wf(t,C)}while(!0);Yo(),ci.current=m,Je=d,bt!==null?r=0:(At=null,_t=0,r=Ct)}if(r!==0){if(r===2&&(d=uo(t),d!==0&&(c=d,r=Pl(t,d))),r===1)throw i=Ys,kr(t,0),lr(t,c),Jt(t,vt()),i;if(r===6)lr(t,c);else{if(d=t.current.alternate,(c&30)===0&&!Oy(d)&&(r=gi(t,c),r===2&&(m=uo(t),m!==0&&(c=m,r=Pl(t,m))),r===1))throw i=Ys,kr(t,0),lr(t,c),Jt(t,vt()),i;switch(t.finishedWork=d,t.finishedLanes=c,r){case 0:case 1:throw Error(a(345));case 2:Nr(t,Yt,On);break;case 3:if(lr(t,c),(c&130023424)===c&&(r=Al+500-vt(),10<r)){if(ka(t,0)!==0)break;if(d=t.suspendedLanes,(d&c)!==c){Wt(),t.pingedLanes|=t.suspendedLanes&d;break}t.timeoutHandle=Mo(Nr.bind(null,t,Yt,On),r);break}Nr(t,Yt,On);break;case 4:if(lr(t,c),(c&4194240)===c)break;for(r=t.eventTimes,d=-1;0<c;){var j=31-hn(c);m=1<<j,j=r[j],j>d&&(d=j),c&=~m}if(c=d,c=vt()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*My(c/1960))-c,10<c){t.timeoutHandle=Mo(Nr.bind(null,t,Yt,On),c);break}Nr(t,Yt,On);break;case 5:Nr(t,Yt,On);break;default:throw Error(a(329))}}}return Jt(t,vt()),t.callbackNode===i?vf.bind(null,t):null}function Pl(t,r){var i=Js;return t.current.memoizedState.isDehydrated&&(kr(t,r).flags|=256),t=gi(t,r),t!==2&&(r=Yt,Yt=i,r!==null&&$l(r)),t}function $l(t){Yt===null?Yt=t:Yt.push.apply(Yt,t)}function Oy(t){for(var r=t;;){if(r.flags&16384){var i=r.updateQueue;if(i!==null&&(i=i.stores,i!==null))for(var c=0;c<i.length;c++){var d=i[c],m=d.getSnapshot;d=d.value;try{if(!mn(m(),d))return!1}catch{return!1}}}if(i=r.child,r.subtreeFlags&16384&&i!==null)i.return=r,r=i;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function lr(t,r){for(r&=~Tl,r&=~ui,t.suspendedLanes|=r,t.pingedLanes&=~r,t=t.expirationTimes;0<r;){var i=31-hn(r),c=1<<i;t[i]=-1,r&=~c}}function xf(t){if((Je&6)!==0)throw Error(a(327));is();var r=ka(t,0);if((r&1)===0)return Jt(t,vt()),null;var i=gi(t,r);if(t.tag!==0&&i===2){var c=uo(t);c!==0&&(r=c,i=Pl(t,c))}if(i===1)throw i=Ys,kr(t,0),lr(t,r),Jt(t,vt()),i;if(i===6)throw Error(a(345));return t.finishedWork=t.current.alternate,t.finishedLanes=r,Nr(t,Yt,On),Jt(t,vt()),null}function _l(t,r){var i=Je;Je|=1;try{return t(r)}finally{Je=i,Je===0&&(as=vt()+500,Wa&&tr())}}function br(t){ir!==null&&ir.tag===0&&(Je&6)===0&&is();var r=Je;Je|=1;var i=un.transition,c=tt;try{if(un.transition=null,tt=1,t)return t()}finally{tt=c,un.transition=i,Je=r,(Je&6)===0&&tr()}}function Ll(){rn=ss.current,lt(ss)}function kr(t,r){t.finishedWork=null,t.finishedLanes=0;var i=t.timeoutHandle;if(i!==-1&&(t.timeoutHandle=-1,py(i)),bt!==null)for(i=bt.return;i!==null;){var c=i;switch(Ho(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Da();break;case 3:ts(),lt(Gt),lt(Lt),rl();break;case 5:tl(c);break;case 4:ts();break;case 13:lt(ht);break;case 19:lt(ht);break;case 10:Jo(c.type._context);break;case 22:case 23:Ll()}i=i.return}if(At=t,bt=t=cr(t.current,null),_t=rn=r,Ct=0,Ys=null,Tl=ui=Sr=0,Yt=Js=null,xr!==null){for(r=0;r<xr.length;r++)if(i=xr[r],c=i.interleaved,c!==null){i.interleaved=null;var d=c.next,m=i.pending;if(m!==null){var j=m.next;m.next=d,c.next=j}i.pending=c}xr=null}return t}function wf(t,r){do{var i=bt;try{if(Yo(),Za.current=ri,ei){for(var c=mt.memoizedState;c!==null;){var d=c.queue;d!==null&&(d.pending=null),c=c.next}ei=!1}if(jr=0,Tt=Nt=mt=null,Ws=!1,Hs=0,El.current=null,i===null||i.return===null){Ct=1,Ys=r,bt=null;break}e:{var m=t,j=i.return,C=i,R=r;if(r=_t,C.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var H=R,oe=C,le=oe.tag;if((oe.mode&1)===0&&(le===0||le===11||le===15)){var se=oe.alternate;se?(oe.updateQueue=se.updateQueue,oe.memoizedState=se.memoizedState,oe.lanes=se.lanes):(oe.updateQueue=null,oe.memoizedState=null)}var je=Hd(j);if(je!==null){je.flags&=-257,Vd(je,j,C,m,r),je.mode&1&&Wd(m,H,r),r=je,R=H;var ke=r.updateQueue;if(ke===null){var Ee=new Set;Ee.add(R),r.updateQueue=Ee}else ke.add(R);break e}else{if((r&1)===0){Wd(m,H,r),zl();break e}R=Error(a(426))}}else if(ct&&C.mode&1){var xt=Hd(j);if(xt!==null){(xt.flags&65536)===0&&(xt.flags|=256),Vd(xt,j,C,m,r),Ko(ns(R,C));break e}}m=R=ns(R,C),Ct!==4&&(Ct=2),Js===null?Js=[m]:Js.push(m),m=j;do{switch(m.tag){case 3:m.flags|=65536,r&=-r,m.lanes|=r;var F=Dd(m,R,r);md(m,F);break e;case 1:C=R;var L=m.type,D=m.stateNode;if((m.flags&128)===0&&(typeof L.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(ar===null||!ar.has(D)))){m.flags|=65536,r&=-r,m.lanes|=r;var he=Ud(m,C,r);md(m,he);break e}}m=m.return}while(m!==null)}bf(i)}catch(Ae){r=Ae,bt===i&&i!==null&&(bt=i=i.return);continue}break}while(!0)}function jf(){var t=ci.current;return ci.current=ri,t===null?ri:t}function zl(){(Ct===0||Ct===3||Ct===2)&&(Ct=4),At===null||(Sr&268435455)===0&&(ui&268435455)===0||lr(At,_t)}function gi(t,r){var i=Je;Je|=2;var c=jf();(At!==t||_t!==r)&&(On=null,kr(t,r));do try{By();break}catch(d){wf(t,d)}while(!0);if(Yo(),Je=i,ci.current=c,bt!==null)throw Error(a(261));return At=null,_t=0,Ct}function By(){for(;bt!==null;)Sf(bt)}function Dy(){for(;bt!==null&&!fg();)Sf(bt)}function Sf(t){var r=Cf(t.alternate,t,rn);t.memoizedProps=t.pendingProps,r===null?bf(t):bt=r,El.current=null}function bf(t){var r=t;do{var i=r.alternate;if(t=r.return,(r.flags&32768)===0){if(i=$y(i,r,rn),i!==null){bt=i;return}}else{if(i=_y(i,r),i!==null){i.flags&=32767,bt=i;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{Ct=6,bt=null;return}}if(r=r.sibling,r!==null){bt=r;return}bt=r=t}while(r!==null);Ct===0&&(Ct=5)}function Nr(t,r,i){var c=tt,d=un.transition;try{un.transition=null,tt=1,Uy(t,r,i,c)}finally{un.transition=d,tt=c}return null}function Uy(t,r,i,c){do is();while(ir!==null);if((Je&6)!==0)throw Error(a(327));i=t.finishedWork;var d=t.finishedLanes;if(i===null)return null;if(t.finishedWork=null,t.finishedLanes=0,i===t.current)throw Error(a(177));t.callbackNode=null,t.callbackPriority=0;var m=i.lanes|i.childLanes;if(Sg(t,m),t===At&&(bt=At=null,_t=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||fi||(fi=!0,Ef(wa,function(){return is(),null})),m=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||m){m=un.transition,un.transition=null;var j=tt;tt=1;var C=Je;Je|=4,El.current=null,zy(t,i),hf(i,t),ly(zo),Ea=!!Lo,zo=Lo=null,t.current=i,Fy(i),hg(),Je=C,tt=j,un.transition=m}else t.current=i;if(fi&&(fi=!1,ir=t,hi=d),m=t.pendingLanes,m===0&&(ar=null),gg(i.stateNode),Jt(t,vt()),r!==null)for(c=t.onRecoverableError,i=0;i<r.length;i++)d=r[i],c(d.value,{componentStack:d.stack,digest:d.digest});if(di)throw di=!1,t=Il,Il=null,t;return(hi&1)!==0&&t.tag!==0&&is(),m=t.pendingLanes,(m&1)!==0?t===Rl?Qs++:(Qs=0,Rl=t):Qs=0,tr(),null}function is(){if(ir!==null){var t=uu(hi),r=un.transition,i=tt;try{if(un.transition=null,tt=16>t?16:t,ir===null)var c=!1;else{if(t=ir,ir=null,hi=0,(Je&6)!==0)throw Error(a(331));var d=Je;for(Je|=4,be=t.current;be!==null;){var m=be,j=m.child;if((be.flags&16)!==0){var C=m.deletions;if(C!==null){for(var R=0;R<C.length;R++){var H=C[R];for(be=H;be!==null;){var oe=be;switch(oe.tag){case 0:case 11:case 15:qs(8,oe,m)}var le=oe.child;if(le!==null)le.return=oe,be=le;else for(;be!==null;){oe=be;var se=oe.sibling,je=oe.return;if(lf(oe),oe===H){be=null;break}if(se!==null){se.return=je,be=se;break}be=je}}}var ke=m.alternate;if(ke!==null){var Ee=ke.child;if(Ee!==null){ke.child=null;do{var xt=Ee.sibling;Ee.sibling=null,Ee=xt}while(Ee!==null)}}be=m}}if((m.subtreeFlags&2064)!==0&&j!==null)j.return=m,be=j;else e:for(;be!==null;){if(m=be,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:qs(9,m,m.return)}var F=m.sibling;if(F!==null){F.return=m.return,be=F;break e}be=m.return}}var L=t.current;for(be=L;be!==null;){j=be;var D=j.child;if((j.subtreeFlags&2064)!==0&&D!==null)D.return=j,be=D;else e:for(j=L;be!==null;){if(C=be,(C.flags&2048)!==0)try{switch(C.tag){case 0:case 11:case 15:li(9,C)}}catch(Ae){pt(C,C.return,Ae)}if(C===j){be=null;break e}var he=C.sibling;if(he!==null){he.return=C.return,be=he;break e}be=C.return}}if(Je=d,tr(),Nn&&typeof Nn.onPostCommitFiberRoot=="function")try{Nn.onPostCommitFiberRoot(ja,t)}catch{}c=!0}return c}finally{tt=i,un.transition=r}}return!1}function kf(t,r,i){r=ns(i,r),r=Dd(t,r,1),t=rr(t,r,1),r=Wt(),t!==null&&(js(t,1,r),Jt(t,r))}function pt(t,r,i){if(t.tag===3)kf(t,t,i);else for(;r!==null;){if(r.tag===3){kf(r,t,i);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(ar===null||!ar.has(c))){t=ns(i,t),t=Ud(r,t,1),r=rr(r,t,1),t=Wt(),r!==null&&(js(r,1,t),Jt(r,t));break}}r=r.return}}function Wy(t,r,i){var c=t.pingCache;c!==null&&c.delete(r),r=Wt(),t.pingedLanes|=t.suspendedLanes&i,At===t&&(_t&i)===i&&(Ct===4||Ct===3&&(_t&130023424)===_t&&500>vt()-Al?kr(t,0):Tl|=i),Jt(t,r)}function Nf(t,r){r===0&&((t.mode&1)===0?r=1:(r=ba,ba<<=1,(ba&130023424)===0&&(ba=4194304)));var i=Wt();t=zn(t,r),t!==null&&(js(t,r,i),Jt(t,i))}function Hy(t){var r=t.memoizedState,i=0;r!==null&&(i=r.retryLane),Nf(t,i)}function Vy(t,r){var i=0;switch(t.tag){case 13:var c=t.stateNode,d=t.memoizedState;d!==null&&(i=d.retryLane);break;case 19:c=t.stateNode;break;default:throw Error(a(314))}c!==null&&c.delete(r),Nf(t,i)}var Cf;Cf=function(t,r,i){if(t!==null)if(t.memoizedProps!==r.pendingProps||Gt.current)qt=!0;else{if((t.lanes&i)===0&&(r.flags&128)===0)return qt=!1,Py(t,r,i);qt=(t.flags&131072)!==0}else qt=!1,ct&&(r.flags&1048576)!==0&&sd(r,Va,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;ii(t,r),t=r.pendingProps;var d=qr(r,Lt.current);es(r,i),d=il(null,r,c,t,d,i);var m=ol();return r.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Kt(c)?(m=!0,Ua(r)):m=!1,r.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Zo(r),d.updater=si,r.stateNode=d,d._reactInternals=r,hl(r,c,t,i),r=yl(null,r,c,!0,m,i)):(r.tag=0,ct&&m&&Wo(r),Ut(null,r,d,i),r=r.child),r;case 16:c=r.elementType;e:{switch(ii(t,r),t=r.pendingProps,d=c._init,c=d(c._payload),r.type=c,d=r.tag=Ky(c),t=gn(c,t),d){case 0:r=gl(null,r,c,t,i);break e;case 1:r=Qd(null,r,c,t,i);break e;case 11:r=Gd(null,r,c,t,i);break e;case 14:r=Kd(null,r,c,gn(c.type,t),i);break e}throw Error(a(306,c,""))}return r;case 0:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),gl(t,r,c,d,i);case 1:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),Qd(t,r,c,d,i);case 3:e:{if(Xd(r),t===null)throw Error(a(387));c=r.pendingProps,m=r.memoizedState,d=m.element,hd(t,r),Qa(r,c,null,i);var j=r.memoizedState;if(c=j.element,m.isDehydrated)if(m={element:c,isDehydrated:!1,cache:j.cache,pendingSuspenseBoundaries:j.pendingSuspenseBoundaries,transitions:j.transitions},r.updateQueue.baseState=m,r.memoizedState=m,r.flags&256){d=ns(Error(a(423)),r),r=Zd(t,r,c,i,d);break e}else if(c!==d){d=ns(Error(a(424)),r),r=Zd(t,r,c,i,d);break e}else for(nn=Xn(r.stateNode.containerInfo.firstChild),tn=r,ct=!0,pn=null,i=dd(r,null,c,i),r.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Qr(),c===d){r=Mn(t,r,i);break e}Ut(t,r,c,i)}r=r.child}return r;case 5:return gd(r),t===null&&Go(r),c=r.type,d=r.pendingProps,m=t!==null?t.memoizedProps:null,j=d.children,Fo(c,d)?j=null:m!==null&&Fo(c,m)&&(r.flags|=32),Jd(t,r),Ut(t,r,j,i),r.child;case 6:return t===null&&Go(r),null;case 13:return ef(t,r,i);case 4:return el(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=Xr(r,null,c,i):Ut(t,r,c,i),r.child;case 11:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),Gd(t,r,c,d,i);case 7:return Ut(t,r,r.pendingProps,i),r.child;case 8:return Ut(t,r,r.pendingProps.children,i),r.child;case 12:return Ut(t,r,r.pendingProps.children,i),r.child;case 10:e:{if(c=r.type._context,d=r.pendingProps,m=r.memoizedProps,j=d.value,at(qa,c._currentValue),c._currentValue=j,m!==null)if(mn(m.value,j)){if(m.children===d.children&&!Gt.current){r=Mn(t,r,i);break e}}else for(m=r.child,m!==null&&(m.return=r);m!==null;){var C=m.dependencies;if(C!==null){j=m.child;for(var R=C.firstContext;R!==null;){if(R.context===c){if(m.tag===1){R=Fn(-1,i&-i),R.tag=2;var H=m.updateQueue;if(H!==null){H=H.shared;var oe=H.pending;oe===null?R.next=R:(R.next=oe.next,oe.next=R),H.pending=R}}m.lanes|=i,R=m.alternate,R!==null&&(R.lanes|=i),Qo(m.return,i,r),C.lanes|=i;break}R=R.next}}else if(m.tag===10)j=m.type===r.type?null:m.child;else if(m.tag===18){if(j=m.return,j===null)throw Error(a(341));j.lanes|=i,C=j.alternate,C!==null&&(C.lanes|=i),Qo(j,i,r),j=m.sibling}else j=m.child;if(j!==null)j.return=m;else for(j=m;j!==null;){if(j===r){j=null;break}if(m=j.sibling,m!==null){m.return=j.return,j=m;break}j=j.return}m=j}Ut(t,r,d.children,i),r=r.child}return r;case 9:return d=r.type,c=r.pendingProps.children,es(r,i),d=ln(d),c=c(d),r.flags|=1,Ut(t,r,c,i),r.child;case 14:return c=r.type,d=gn(c,r.pendingProps),d=gn(c.type,d),Kd(t,r,c,d,i);case 15:return qd(t,r,r.type,r.pendingProps,i);case 17:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),ii(t,r),r.tag=1,Kt(c)?(t=!0,Ua(r)):t=!1,es(r,i),Od(r,c,d),hl(r,c,d,i),yl(null,r,c,!0,t,i);case 19:return nf(t,r,i);case 22:return Yd(t,r,i)}throw Error(a(156,r.tag))};function Ef(t,r){return au(t,r)}function Gy(t,r,i,c){this.tag=t,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dn(t,r,i,c){return new Gy(t,r,i,c)}function Fl(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ky(t){if(typeof t=="function")return Fl(t)?1:0;if(t!=null){if(t=t.$$typeof,t===M)return 11;if(t===X)return 14}return 2}function cr(t,r){var i=t.alternate;return i===null?(i=dn(t.tag,r,t.key,t.mode),i.elementType=t.elementType,i.type=t.type,i.stateNode=t.stateNode,i.alternate=t,t.alternate=i):(i.pendingProps=r,i.type=t.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=t.flags&14680064,i.childLanes=t.childLanes,i.lanes=t.lanes,i.child=t.child,i.memoizedProps=t.memoizedProps,i.memoizedState=t.memoizedState,i.updateQueue=t.updateQueue,r=t.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},i.sibling=t.sibling,i.index=t.index,i.ref=t.ref,i}function yi(t,r,i,c,d,m){var j=2;if(c=t,typeof t=="function")Fl(t)&&(j=1);else if(typeof t=="string")j=5;else e:switch(t){case K:return Cr(i.children,d,m,r);case _:j=8,d|=8;break;case U:return t=dn(12,i,r,d|2),t.elementType=U,t.lanes=m,t;case re:return t=dn(13,i,r,d),t.elementType=re,t.lanes=m,t;case de:return t=dn(19,i,r,d),t.elementType=de,t.lanes=m,t;case Ne:return vi(i,d,m,r);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Z:j=10;break e;case V:j=9;break e;case M:j=11;break e;case X:j=14;break e;case xe:j=16,c=null;break e}throw Error(a(130,t==null?t:typeof t,""))}return r=dn(j,i,r,d),r.elementType=t,r.type=c,r.lanes=m,r}function Cr(t,r,i,c){return t=dn(7,t,c,r),t.lanes=i,t}function vi(t,r,i,c){return t=dn(22,t,c,r),t.elementType=Ne,t.lanes=i,t.stateNode={isHidden:!1},t}function Ml(t,r,i){return t=dn(6,t,null,r),t.lanes=i,t}function Ol(t,r,i){return r=dn(4,t.children!==null?t.children:[],t.key,r),r.lanes=i,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}function qy(t,r,i,c,d){this.tag=r,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=fo(0),this.expirationTimes=fo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fo(0),this.identifierPrefix=c,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Bl(t,r,i,c,d,m,j,C,R){return t=new qy(t,r,i,C,R),r===1?(r=1,m===!0&&(r|=8)):r=0,m=dn(3,null,null,r),t.current=m,m.stateNode=t,m.memoizedState={element:c,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zo(m),t}function Yy(t,r,i){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:c==null?null:""+c,children:t,containerInfo:r,implementation:i}}function Tf(t){if(!t)return er;t=t._reactInternals;e:{if(bn(t)!==t||t.tag!==1)throw Error(a(170));var r=t;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Kt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(a(171))}if(t.tag===1){var i=t.type;if(Kt(i))return td(t,i,r)}return r}function Af(t,r,i,c,d,m,j,C,R){return t=Bl(i,c,!0,t,d,m,j,C,R),t.context=Tf(null),i=t.current,c=Wt(),d=or(i),m=Fn(c,d),m.callback=r??null,rr(i,m,d),t.current.lanes=d,js(t,d,c),Jt(t,c),t}function xi(t,r,i,c){var d=r.current,m=Wt(),j=or(d);return i=Tf(i),r.context===null?r.context=i:r.pendingContext=i,r=Fn(m,j),r.payload={element:t},c=c===void 0?null:c,c!==null&&(r.callback=c),t=rr(d,r,j),t!==null&&(xn(t,d,j,m),Ja(t,d,j)),j}function wi(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function If(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var i=t.retryLane;t.retryLane=i!==0&&i<r?i:r}}function Dl(t,r){If(t,r),(t=t.alternate)&&If(t,r)}function Jy(){return null}var Rf=typeof reportError=="function"?reportError:function(t){console.error(t)};function Ul(t){this._internalRoot=t}ji.prototype.render=Ul.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(a(409));xi(t,r,null,null)},ji.prototype.unmount=Ul.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;br(function(){xi(null,t,null,null)}),r[Pn]=null}};function ji(t){this._internalRoot=t}ji.prototype.unstable_scheduleHydration=function(t){if(t){var r=hu();t={blockedOn:null,target:t,priority:r};for(var i=0;i<Yn.length&&r!==0&&r<Yn[i].priority;i++);Yn.splice(i,0,t),i===0&&gu(t)}};function Wl(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Si(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Pf(){}function Qy(t,r,i,c,d){if(d){if(typeof c=="function"){var m=c;c=function(){var H=wi(j);m.call(H)}}var j=Af(r,c,t,0,null,!1,!1,"",Pf);return t._reactRootContainer=j,t[Pn]=j.current,Ls(t.nodeType===8?t.parentNode:t),br(),j}for(;d=t.lastChild;)t.removeChild(d);if(typeof c=="function"){var C=c;c=function(){var H=wi(R);C.call(H)}}var R=Bl(t,0,!1,null,null,!1,!1,"",Pf);return t._reactRootContainer=R,t[Pn]=R.current,Ls(t.nodeType===8?t.parentNode:t),br(function(){xi(r,R,i,c)}),R}function bi(t,r,i,c,d){var m=i._reactRootContainer;if(m){var j=m;if(typeof d=="function"){var C=d;d=function(){var R=wi(j);C.call(R)}}xi(r,j,t,d)}else j=Qy(i,r,t,d,c);return wi(j)}du=function(t){switch(t.tag){case 3:var r=t.stateNode;if(r.current.memoizedState.isDehydrated){var i=ws(r.pendingLanes);i!==0&&(ho(r,i|1),Jt(r,vt()),(Je&6)===0&&(as=vt()+500,tr()))}break;case 13:br(function(){var c=zn(t,1);if(c!==null){var d=Wt();xn(c,t,1,d)}}),Dl(t,1)}},mo=function(t){if(t.tag===13){var r=zn(t,134217728);if(r!==null){var i=Wt();xn(r,t,134217728,i)}Dl(t,134217728)}},fu=function(t){if(t.tag===13){var r=or(t),i=zn(t,r);if(i!==null){var c=Wt();xn(i,t,r,c)}Dl(t,r)}},hu=function(){return tt},mu=function(t,r){var i=tt;try{return tt=t,r()}finally{tt=i}},st=function(t,r,i){switch(r){case"input":if(ge(t,i),r=i.name,i.type==="radio"&&r!=null){for(i=t;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<i.length;r++){var c=i[r];if(c!==t&&c.form===t.form){var d=Ba(c);if(!d)throw Error(a(90));Ue(c),ge(c,d)}}}break;case"textarea":Me(t,i);break;case"select":r=i.value,r!=null&&He(t,!!i.multiple,r,!1)}},ue=_l,Ce=br;var Xy={usingClientEntryPoint:!1,Events:[Ms,Gr,Ba,kt,Zt,_l]},Xs={findFiberByHostInstance:pr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Zy={bundleType:Xs.bundleType,version:Xs.version,rendererPackageName:Xs.rendererPackageName,rendererConfig:Xs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:I.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=kn(t),t===null?null:t.stateNode},findFiberByHostInstance:Xs.findFiberByHostInstance||Jy,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 ki=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ki.isDisabled&&ki.supportsFiber)try{ja=ki.inject(Zy),Nn=ki}catch{}}return Qt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Xy,Qt.createPortal=function(t,r){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Wl(r))throw Error(a(200));return Yy(t,r,null,i)},Qt.createRoot=function(t,r){if(!Wl(t))throw Error(a(299));var i=!1,c="",d=Rf;return r!=null&&(r.unstable_strictMode===!0&&(i=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(d=r.onRecoverableError)),r=Bl(t,1,!1,null,null,i,!1,c,d),t[Pn]=r.current,Ls(t.nodeType===8?t.parentNode:t),new Ul(r)},Qt.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(a(188)):(t=Object.keys(t).join(","),Error(a(268,t)));return t=kn(r),t=t===null?null:t.stateNode,t},Qt.flushSync=function(t){return br(t)},Qt.hydrate=function(t,r,i){if(!Si(r))throw Error(a(200));return bi(null,t,r,!0,i)},Qt.hydrateRoot=function(t,r,i){if(!Wl(t))throw Error(a(405));var c=i!=null&&i.hydratedSources||null,d=!1,m="",j=Rf;if(i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(j=i.onRecoverableError)),r=Af(r,null,t,1,i??null,d,!1,m,j),t[Pn]=r.current,Ls(t),c)for(t=0;t<c.length;t++)i=c[t],d=i._getVersion,d=d(i._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[i,d]:r.mutableSourceEagerHydrationData.push(i,d);return new ji(r)},Qt.render=function(t,r,i){if(!Si(r))throw Error(a(200));return bi(null,t,r,!1,i)},Qt.unmountComponentAtNode=function(t){if(!Si(t))throw Error(a(40));return t._reactRootContainer?(br(function(){bi(null,null,t,!1,function(){t._reactRootContainer=null,t[Pn]=null})}),!0):!1},Qt.unstable_batchedUpdates=_l,Qt.unstable_renderSubtreeIntoContainer=function(t,r,i,c){if(!Si(i))throw Error(a(200));if(t==null||t._reactInternals===void 0)throw Error(a(38));return bi(t,r,i,!1,c)},Qt.version="18.3.1-next-f1338f8080-20240426",Qt}var Bf;function am(){if(Bf)return Gl.exports;Bf=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(s){console.error(s)}}return e(),Gl.exports=lv(),Gl.exports}var Df;function cv(){if(Df)return Ni;Df=1;var e=am();return Ni.createRoot=e.createRoot,Ni.hydrateRoot=e.hydrateRoot,Ni}var uv=cv();/**
|
|
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 Ec=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,im=/^[\\/]{2}/;function dv(e,s){return s+e.replace(/\\/g,"/")}var Uf="popstate";function Wf(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function fv(e={}){function s(o,l){var v;let u=(v=l.state)==null?void 0:v.masked,{pathname:f,search:p,hash:g}=u||o.location;return uc("",{pathname:f,search:p,hash:g},l.state&&l.state.usr||null,l.state&&l.state.key||"default",u?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function a(o,l){return typeof l=="string"?l:Rr(l)}return mv(s,a,null,e)}function ut(e,s){if(e===!1||e===null||typeof e>"u")throw new Error(s)}function fn(e,s){if(!e){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function hv(){return Math.random().toString(36).substring(2,10)}function Hf(e,s){return{usr:e.state,key:e.key,idx:s,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function uc(e,s,a=null,o,l){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof s=="string"?ms(s):s,state:a,key:s&&s.key||o||hv(),mask:l}}function Rr({pathname:e="/",search:s="",hash:a=""}){return s&&s!=="?"&&(e+=s.charAt(0)==="?"?s:"?"+s),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function ms(e){let s={};if(e){let a=e.indexOf("#");a>=0&&(s.hash=e.substring(a),e=e.substring(0,a));let o=e.indexOf("?");o>=0&&(s.search=e.substring(o),e=e.substring(0,o)),e&&(s.pathname=e)}return s}function mv(e,s,a,o={}){let{window:l=document.defaultView,v5Compat:u=!1}=o,f=l.history,p="POP",g=null,v=y();v==null&&(v=0,f.replaceState({...f.state,idx:v},""));function y(){return(f.state||{idx:null}).idx}function w(){p="POP";let k=y(),E=k==null?null:k-v;v=k,g&&g({action:p,location:S.location,delta:E})}function x(k,E){p="PUSH";let T=Wf(k)?k:uc(S.location,k,E);v=y()+1;let P=Hf(T,v),I=S.createHref(T.mask||T);try{f.pushState(P,"",I)}catch(B){if(B instanceof DOMException&&B.name==="DataCloneError")throw B;l.location.assign(I)}u&&g&&g({action:p,location:S.location,delta:1})}function b(k,E){p="REPLACE";let T=Wf(k)?k:uc(S.location,k,E);v=y();let P=Hf(T,v),I=S.createHref(T.mask||T);f.replaceState(P,"",I),u&&g&&g({action:p,location:S.location,delta:0})}function N(k){return pv(l,k)}let S={get action(){return p},get location(){return e(l,f)},listen(k){if(g)throw new Error("A history only accepts one active listener");return l.addEventListener(Uf,w),g=k,()=>{l.removeEventListener(Uf,w),g=null}},createHref(k){return s(l,k)},createURL:N,encodeLocation(k){let E=N(k);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:x,replace:b,go(k){return f.go(k)}};return S}function pv(e,s,a=!1){let o="http://localhost";e&&(o=e.location.origin!=="null"?e.location.origin:e.location.href),ut(o,"No window.location.(origin|href) available to create URL");let l=typeof s=="string"?s:Rr(s);return l=l.replace(/ $/,"%20"),!a&&im.test(l)&&(l=o+l),new URL(l,o)}function om(e,s,a="/"){return gv(e,s,a,!1)}function gv(e,s,a,o,l){let u=typeof s=="string"?ms(s):s,f=Un(u.pathname||"/",a);if(f==null)return null;let p=yv(e),g=null,v=Tv(f);for(let y=0;g==null&&y<p.length;++y)g=Ev(p[y],v,o);return g}function yv(e){let s=lm(e);return vv(s),s}function lm(e,s=[],a=[],o="",l=!1){let u=(f,p,g=l,v)=>{let y={relativePath:v===void 0?f.path||"":v,caseSensitive:f.caseSensitive===!0,childrenIndex:p,route:f};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&g)return;ut(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let w=wn([o,y.relativePath]),x=a.concat(y);f.children&&f.children.length>0&&(ut(f.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${w}".`),lm(f.children,s,x,w,g)),!(f.path==null&&!f.index)&&s.push({path:w,score:Nv(w,f.index),routesMeta:x.map((b,N)=>{let[S,k]=dm(b.relativePath,b.caseSensitive,N===x.length-1);return{...b,matcher:S,compiledParams:k}})})};return e.forEach((f,p)=>{var g;if(f.path===""||!((g=f.path)!=null&&g.includes("?")))u(f,p);else for(let v of cm(f.path))u(f,p,!0,v)}),s}function cm(e){let s=e.split("/");if(s.length===0)return[];let[a,...o]=s,l=a.endsWith("?"),u=a.replace(/\?$/,"");if(o.length===0)return l?[u,""]:[u];let f=cm(o.join("/")),p=[];return p.push(...f.map(g=>g===""?u:[u,g].join("/"))),l&&p.push(...f),p.map(g=>e.startsWith("/")&&g===""?"/":g)}function vv(e){e.sort((s,a)=>s.score!==a.score?a.score-s.score:Cv(s.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var xv=/^:[\w-]+$/,wv=3,jv=2,Sv=1,bv=10,kv=-2,Vf=e=>e==="*";function Nv(e,s){let a=e.split("/"),o=a.length;return a.some(Vf)&&(o+=kv),s&&(o+=jv),a.filter(l=>!Vf(l)).reduce((l,u)=>l+(xv.test(u)?wv:u===""?Sv:bv),o)}function Cv(e,s){return e.length===s.length&&e.slice(0,-1).every((o,l)=>o===s[l])?e[e.length-1]-s[s.length-1]:0}function Ev(e,s,a=!1){let{routesMeta:o}=e,l={},u="/",f=[];for(let p=0;p<o.length;++p){let g=o[p],v=p===o.length-1,y=u==="/"?s:s.slice(u.length)||"/",w={path:g.relativePath,caseSensitive:g.caseSensitive,end:v},x=g.matcher&&g.compiledParams?um(w,y,g.matcher,g.compiledParams):Fi(w,y),b=g.route;if(!x&&v&&a&&!o[o.length-1].route.index&&(x=Fi({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},y)),!x)return null;Object.assign(l,x.params),f.push({params:l,pathname:wn([u,x.pathname]),pathnameBase:Rv(wn([u,x.pathnameBase])),route:b}),x.pathnameBase!=="/"&&(u=wn([u,x.pathnameBase]))}return f}function Fi(e,s){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,o]=dm(e.path,e.caseSensitive,e.end);return um(e,s,a,o)}function um(e,s,a,o){let l=s.match(a);if(!l)return null;let u=l[0],f=ds(u,1),p=l.slice(1);return{params:o.reduce((v,{paramName:y,isOptional:w},x)=>{if(y==="*"){let N=p[x]||"";f=ds(u.slice(0,u.length-N.length),1)}const b=p[x];return w&&!b?v[y]=void 0:v[y]=(b||"").replace(/%2F/g,"/"),v},{}),pathname:u,pathnameBase:f,pattern:e}}function dm(e,s=!1,a=!0){fn(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(f,p,g,v,y)=>{if(o.push({paramName:p,isOptional:g!=null}),g){let w=y.charAt(v+f.length);return w&&w!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,s?void 0:"i"),o]}function Tv(e){try{return e.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return fn(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),e}}function Un(e,s){if(s==="/")return e;if(!e.toLowerCase().startsWith(s.toLowerCase()))return null;let a=s.endsWith("/")?s.length-1:s.length,o=e.charAt(a);return o&&o!=="/"?null:e.slice(a)||"/"}function Av(e,s="/"){let{pathname:a,search:o="",hash:l=""}=typeof e=="string"?ms(e):e,u;return a?(a=fm(a),a.startsWith("/")||a.startsWith("\\")?u=Gf(a.substring(1),"/"):u=Gf(a,s)):u=s,{pathname:u,search:Pv(o),hash:$v(l)}}function Gf(e,s){let a=ds(s).split("/");return e.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function Yl(e,s,a,o){return`Cannot include a '${e}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Iv(e){return e.filter((s,a)=>a===0||s.route.path&&s.route.path.length>0)}function Tc(e){let s=Iv(e);return s.map((a,o)=>o===s.length-1?a.pathname:a.pathnameBase)}function Xi(e,s,a,o=!1){let l;typeof e=="string"?l=ms(e):(l={...e},ut(!l.pathname||!l.pathname.includes("?"),Yl("?","pathname","search",l)),ut(!l.pathname||!l.pathname.includes("#"),Yl("#","pathname","hash",l)),ut(!l.search||!l.search.includes("#"),Yl("#","search","hash",l)));let u=e===""||l.pathname==="",f=u?"/":l.pathname,p;if(f==null)p=a;else{let w=s.length-1;if(!o&&f.startsWith("..")){let x=f.split("/");for(;x[0]==="..";)x.shift(),w-=1;l.pathname=x.join("/")}p=w>=0?s[w]:"/"}let g=Av(l,p),v=f&&f!=="/"&&f.endsWith("/"),y=(u||f===".")&&a.endsWith("/");return!g.pathname.endsWith("/")&&(v||y)&&(g.pathname+="/"),g}var fm=e=>e.replace(/[\\/]{2,}/g,"/"),wn=e=>fm(e.join("/"));function ds(e,s=0){let a=e.length;for(;a>s&&e.charCodeAt(a-1)===47;)a--;return a===e.length?e:e.slice(0,a)}var Rv=e=>ds(e).replace(/^\/*/,"/"),Pv=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,$v=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,_v=class{constructor(e,s,a,o=!1){this.status=e,this.statusText=s||"",this.internal=o,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function Lv(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function zv(e){let s=e.map(a=>a.route.path).filter(Boolean);return wn(s)||"/"}var hm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function mm(e,s){let a=e;if(typeof a!="string"||!Ec.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,l=!1;if(hm)try{let u=new URL(window.location.href),f=im.test(a)?new URL(dv(a,u.protocol)):new URL(a),p=Un(f.pathname,s);f.origin===u.origin&&p!=null?a=p+f.search+f.hash:l=!0}catch{fn(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:l,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Kf=new URL("http://localhost");function Ac(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),Kf)}catch{return Kf}}function Jl(e,s){return e.origin===s.origin&&(e.origin!=="null"||e.protocol===s.protocol&&e.host===s.host)}function Fv(e,s){if(e.startsWith("//"))return!0;let a=s.protocol.toLowerCase();return e.toLowerCase().startsWith(a)?s.host===""||e.slice(a.length).startsWith("//"):!1}function Ic(e,s,a,o){let l=null;try{l=e==null?null:new URL(e,a)}catch{}let u=new URL(s,a),f=l!=null&&!Jl(l,a),p=!Jl(u,a);if(o==="reject"){if(f||p)throw new Error("External navigation is not allowed")}else if(p&&(l==null||!Fv(e,l)||!Jl(l,u)))throw new Error("External navigation is not allowed")}var pm=["POST","PUT","PATCH","DELETE"];new Set(pm);var Mv=["GET",...pm];new Set(Mv);var Ov=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Bv(e){try{return Ov.includes(new URL(e).protocol)}catch{return!1}}var ps=h.createContext(null);ps.displayName="DataRouter";var Zi=h.createContext(null);Zi.displayName="DataRouterState";var gm=h.createContext(!1);function Dv(){return h.useContext(gm)}var ym=h.createContext({isTransitioning:!1});ym.displayName="ViewTransition";var Uv=h.createContext(new Map);Uv.displayName="Fetchers";var Wv=h.createContext(null);Wv.displayName="Await";var sn=h.createContext(null);sn.displayName="Navigation";var ha=h.createContext(null);ha.displayName="Location";var jn=h.createContext({outlet:null,matches:[],isDataRoute:!1});jn.displayName="Route";var Rc=h.createContext(null);Rc.displayName="RouteError";var vm="REACT_ROUTER_ERROR",Hv="REDIRECT",Vv="ROUTE_ERROR_RESPONSE";function Gv(e){if(e.startsWith(`${vm}:${Hv}:{`))try{let s=JSON.parse(e.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 Kv(e){if(e.startsWith(`${vm}:${Vv}:{`))try{let s=JSON.parse(e.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new _v(s.status,s.statusText,s.data)}catch{}}function qv(e,{relative:s}={}){ut(gs(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:o}=h.useContext(sn),{hash:l,pathname:u,search:f}=ma(e,{relative:s}),p=u;return a!=="/"&&(p=u==="/"?a:wn([a,u])),o.createHref({pathname:p,search:f,hash:l})}function gs(){return h.useContext(ha)!=null}function Xt(){return ut(gs(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(ha).location}var xm="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function wm(e){h.useContext(sn).static||h.useLayoutEffect(e)}function Sn(){let{isDataRoute:e}=h.useContext(jn);return e?cx():Yv()}function Yv(){ut(gs(),"useNavigate() may be used only in the context of a <Router> component.");let e=h.useContext(ps),{basename:s,navigator:a}=h.useContext(sn),{matches:o}=h.useContext(jn),{pathname:l}=Xt(),u=JSON.stringify(Tc(o)),f=h.useRef(!1);return wm(()=>{f.current=!0}),h.useCallback((g,v={})=>{if(fn(f.current,xm),!f.current)return;if(typeof g=="number"){a.go(g);return}let y=Xi(g,JSON.parse(u),l,v.relative==="path");e==null&&s!=="/"&&(y.pathname=y.pathname==="/"?s:wn([s,y.pathname])),Ic(typeof g=="string"?g:Rr(g),a.createHref(y),Ac(a),"reject"),(v.replace?a.replace:a.push)(y,v.state,v)},[s,a,u,l,e])}var Jv=h.createContext(null);function Qv(e){let s=h.useContext(jn).outlet;return h.useMemo(()=>s&&h.createElement(Jv.Provider,{value:e},s),[s,e])}function ma(e,{relative:s}={}){let{matches:a}=h.useContext(jn),{pathname:o}=Xt(),l=JSON.stringify(Tc(a));return h.useMemo(()=>Xi(e,JSON.parse(l),o,s==="path"),[e,l,o,s])}function Xv(e,s){return jm(e,s)}function jm(e,s,a){var k;ut(gs(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=h.useContext(sn),{matches:l}=h.useContext(jn),u=l[l.length-1],f=u?u.params:{},p=u?u.pathname:"/",g=u?u.pathnameBase:"/",v=u&&u.route;{let E=v&&v.path||"";bm(p,!v||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${p}" (under <Route path="${E}">) 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="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let y=Xt(),w;if(s){let E=typeof s=="string"?ms(s):s;ut(g==="/"||((k=E.pathname)==null?void 0:k.startsWith(g)),`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 "${g}" but pathname "${E.pathname}" was given in the \`location\` prop.`),w=E}else w=y;let x=w.pathname||"/",b=x;if(g!=="/"){let E=g.replace(/^\//,"").split("/");b="/"+x.replace(/^\//,"").split("/").slice(E.length).join("/")}let N=a&&a.state.matches.length?a.state.matches.map(E=>Object.assign(E,{route:a.manifest[E.route.id]||E.route})):om(e,{pathname:b});fn(v||N!=null,`No routes matched location "${w.pathname}${w.search}${w.hash}" `),fn(N==null||N[N.length-1].route.element!==void 0||N[N.length-1].route.Component!==void 0||N[N.length-1].route.lazy!==void 0,`Matched leaf route at location "${w.pathname}${w.search}${w.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=rx(N&&N.map(E=>Object.assign({},E,{params:Object.assign({},f,E.params),pathname:wn([g,o.encodeLocation?o.encodeLocation(E.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?g:wn([g,o.encodeLocation?o.encodeLocation(E.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),l,a);return s&&S?h.createElement(ha.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...w},navigationType:"POP"}},S):S}function Zv(){let e=lx(),s=Lv(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},f=null;return console.error("Error handled by React Router default ErrorBoundary:",e),f=h.createElement(h.Fragment,null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:u},"ErrorBoundary")," or"," ",h.createElement("code",{style:u},"errorElement")," prop on your route.")),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},s),a?h.createElement("pre",{style:l},a):null,f)}var ex=h.createElement(Zv,null),Sm=class extends h.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,s){return s.location!==e.location||s.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:s.error,location:s.location,revalidation:e.revalidation||s.revalidation}}componentDidCatch(e,s){this.props.onError?this.props.onError(e,s):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const a=Kv(e.digest);a&&(e=a)}let s=e!==void 0?h.createElement(jn.Provider,{value:this.props.routeContext},h.createElement(Rc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?h.createElement(tx,{error:e},s):s}};Sm.contextType=gm;var Ql=new WeakMap;function tx({children:e,error:s}){let{basename:a,navigator:o}=h.useContext(sn);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let l=Gv(s.digest);if(l){let u=Ql.get(s);if(u)throw u;let f=mm(l.location,a),p=f.absoluteURL||f.to;if(Ic(l.location,p,Ac(o),"allow-explicit"),Bv(p))throw new Error("Invalid redirect location");if(hm&&!Ql.get(s))if(f.isExternal||l.reloadDocument)window.location.href=p;else{const g=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(f.to,{replace:l.replace}));throw Ql.set(s,g),g}return h.createElement("meta",{httpEquiv:"refresh",content:`0;url=${p}`})}}return e}function nx({routeContext:e,match:s,children:a}){let o=h.useContext(ps);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),h.createElement(jn.Provider,{value:e},a)}function rx(e,s=[],a){let o=a==null?void 0:a.state;if(e==null){if(!o)return null;if(o.errors)e=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)e=o.matches;else return null}let l=e,u=o==null?void 0:o.errors;if(u!=null){let y=l.findIndex(w=>w.route.id&&(u==null?void 0:u[w.route.id])!==void 0);ut(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),l=l.slice(0,Math.min(l.length,y+1))}let f=!1,p=-1;if(a&&o){f=o.renderFallback;for(let y=0;y<l.length;y++){let w=l[y];if((w.route.HydrateFallback||w.route.hydrateFallbackElement)&&(p=y),w.route.id){let{loaderData:x,errors:b}=o,N=w.route.loader&&!x.hasOwnProperty(w.route.id)&&(!b||b[w.route.id]===void 0);if(w.route.lazy||N){a.isStatic&&(f=!0),p>=0?l=l.slice(0,p+1):l=[l[0]];break}}}}let g=a==null?void 0:a.onError,v=o&&g?(y,w)=>{var x,b;g(y,{location:o.location,params:((b=(x=o.matches)==null?void 0:x[0])==null?void 0:b.params)??{},pattern:zv(o.matches),errorInfo:w})}:void 0;return l.reduceRight((y,w,x)=>{let b,N=!1,S=null,k=null;o&&(b=u&&w.route.id?u[w.route.id]:void 0,S=w.route.errorElement||ex,f&&(p<0&&x===0?(bm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),N=!0,k=null):p===x&&(N=!0,k=w.route.hydrateFallbackElement||null)));let E=s.concat(l.slice(0,x+1)),T=()=>{let P;return b?P=S:N?P=k:w.route.Component?P=h.createElement(w.route.Component,null):w.route.element?P=w.route.element:P=y,h.createElement(nx,{match:w,routeContext:{outlet:y,matches:E,isDataRoute:o!=null},children:P})};return o&&(w.route.ErrorBoundary||w.route.errorElement||x===0)?h.createElement(Sm,{location:o.location,revalidation:o.revalidation,component:S,error:b,children:T(),routeContext:{outlet:null,matches:E,isDataRoute:!0},onError:v}):T()},null)}function Pc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function sx(e){let s=h.useContext(ps);return ut(s,Pc(e)),s}function ax(e){let s=h.useContext(Zi);return ut(s,Pc(e)),s}function ix(e){let s=h.useContext(jn);return ut(s,Pc(e)),s}function $c(e){let s=ix(e),a=s.matches[s.matches.length-1];return ut(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function ox(){return $c("useRouteId")}function lx(){var o;let e=h.useContext(Rc),s=ax("useRouteError"),a=$c("useRouteError");return e!==void 0?e:(o=s.errors)==null?void 0:o[a]}function cx(){let{router:e}=sx("useNavigate"),s=$c("useNavigate"),a=h.useRef(!1);return wm(()=>{a.current=!0}),h.useCallback(async(l,u={})=>{fn(a.current,xm),a.current&&(typeof l=="number"?await e.navigate(l):await e.navigate(l,{fromRouteId:s,...u}))},[e,s])}var qf={};function bm(e,s,a){!s&&!qf[e]&&(qf[e]=!0,fn(!1,a))}h.memo(ux);function ux({routes:e,manifest:s,future:a,state:o,isStatic:l,onError:u}){return jm(e,void 0,{manifest:s,state:o,isStatic:l,onError:u})}function Bn({to:e,replace:s,state:a,relative:o}){ut(gs(),"<Navigate> may be used only in the context of a <Router> component.");let{static:l,navigator:u}=h.useContext(sn);fn(!l,"<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:f}=h.useContext(jn),{pathname:p}=Xt(),g=Sn(),v=Xi(e,Tc(f),p,o==="path");Ic(typeof e=="string"?e:Rr(e),u.createHref(v),Ac(u),"reject");let y=JSON.stringify(v);return h.useEffect(()=>{g(JSON.parse(y),{replace:s,state:a,relative:o})},[g,y,o,s,a]),null}function dx(e){return Qv(e.context)}function it(e){ut(!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 fx({basename:e="/",children:s=null,location:a,navigationType:o="POP",navigator:l,static:u=!1,useTransitions:f}){ut(!gs(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=e.replace(/^\/*/,"/"),g=h.useMemo(()=>({basename:p,navigator:l,static:u,useTransitions:f,future:{}}),[p,l,u,f]);typeof a=="string"&&(a=ms(a));let{pathname:v="/",search:y="",hash:w="",state:x=null,key:b="default",mask:N}=a,S=h.useMemo(()=>{let k=Un(v,p);return k==null?null:{location:{pathname:k,search:y,hash:w,state:x,key:b,mask:N},navigationType:o}},[p,v,y,w,x,b,o,N]);return fn(S!=null,`<Router basename="${p}"> is not able to match the URL "${v}${y}${w}" because it does not start with the basename, so the <Router> won't render anything.`),S==null?null:h.createElement(sn.Provider,{value:g},h.createElement(ha.Provider,{children:s,value:S}))}function hx({children:e,location:s}){return Xv(dc(e),s)}function dc(e,s=[]){let a=[];return h.Children.forEach(e,(o,l)=>{if(!h.isValidElement(o))return;let u=[...s,l];if(o.type===h.Fragment){a.push.apply(a,dc(o.props.children,u));return}ut(o.type===it,`[${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>`),ut(!o.props.index||!o.props.children,"An index route cannot have child routes.");let f={id:o.props.id||u.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&&(f.children=dc(o.props.children,u)),a.push(f)}),a}var _i="get",Li="application/x-www-form-urlencoded";function eo(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function mx(e){return eo(e)&&e.tagName.toLowerCase()==="button"}function px(e){return eo(e)&&e.tagName.toLowerCase()==="form"}function gx(e){return eo(e)&&e.tagName.toLowerCase()==="input"}function yx(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function vx(e,s){return e.button===0&&(!s||s==="_self")&&!yx(e)}function fc(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((s,a)=>{let o=e[a];return s.concat(Array.isArray(o)?o.map(l=>[a,l]):[[a,o]])},[]))}function xx(e,s){let a=fc(e);return s&&s.forEach((o,l)=>{a.has(l)||s.getAll(l).forEach(u=>{a.append(l,u)})}),a}var Ci=null;function wx(){if(Ci===null)try{new FormData(document.createElement("form"),0),Ci=!1}catch{Ci=!0}return Ci}var jx=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Xl(e){return e!=null&&!jx.has(e)?(fn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Li}"`),null):e}function Sx(e,s){let a,o,l,u,f;if(px(e)){let p=e.getAttribute("action");o=p?Un(p,s):null,a=e.getAttribute("method")||_i,l=Xl(e.getAttribute("enctype"))||Li,u=new FormData(e)}else if(mx(e)||gx(e)&&(e.type==="submit"||e.type==="image")){let p=e.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=e.getAttribute("formaction")||p.getAttribute("action");if(o=g?Un(g,s):null,a=e.getAttribute("formmethod")||p.getAttribute("method")||_i,l=Xl(e.getAttribute("formenctype"))||Xl(p.getAttribute("enctype"))||Li,u=new FormData(p,e),!wx()){let{name:v,type:y,value:w}=e;if(y==="image"){let x=v?`${v}.`:"";u.append(`${x}x`,"0"),u.append(`${x}y`,"0")}else v&&u.append(v,w)}}else{if(eo(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=_i,o=null,l=Li,f=e}return u&&l==="text/plain"&&(f=u,u=void 0),{action:o,method:a.toLowerCase(),encType:l,formData:u,body:f}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function _c(e,s){if(e===!1||e===null||typeof e>"u")throw new Error(s)}function km(e,s,a,o){let l=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a?l.pathname.endsWith("/")?l.pathname=`${l.pathname}_.${o}`:l.pathname=`${l.pathname}.${o}`:l.pathname==="/"?l.pathname=`_root.${o}`:s&&Un(l.pathname,s)==="/"?l.pathname=`${ds(s)}/_root.${o}`:l.pathname=`${ds(l.pathname)}.${o}`,l}async function bx(e,s){if(e.id in s)return s[e.id];try{let a=await import(e.module);return s[e.id]=a,a}catch(a){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function kx(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Nx(e,s,a){let o=await Promise.all(e.map(async l=>{let u=s.routes[l.route.id];if(u){let f=await bx(u,a);return f.links?f.links():[]}return[]}));return Ax(o.flat(1).filter(kx).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function Yf(e,s,a,o,l,u){let f=(g,v)=>a[v]?g.route.id!==a[v].route.id:!0,p=(g,v)=>{var y;return a[v].pathname!==g.pathname||((y=a[v].route.path)==null?void 0:y.endsWith("*"))&&a[v].params["*"]!==g.params["*"]};return u==="assets"?s.filter((g,v)=>f(g,v)||p(g,v)):u==="data"?s.filter((g,v)=>{var w;let y=o.routes[g.route.id];if(!y||!y.hasLoader)return!1;if(f(g,v)||p(g,v))return!0;if(g.route.shouldRevalidate){let x=g.route.shouldRevalidate({currentUrl:new URL(l.pathname+l.search+l.hash,window.origin),currentParams:((w=a[0])==null?void 0:w.params)||{},nextUrl:new URL(e,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function Cx(e,s,{includeHydrateFallback:a}={}){return Ex(e.map(o=>{let l=s.routes[o.route.id];if(!l)return[];let u=[l.module];return l.clientActionModule&&(u=u.concat(l.clientActionModule)),l.clientLoaderModule&&(u=u.concat(l.clientLoaderModule)),a&&l.hydrateFallbackModule&&(u=u.concat(l.hydrateFallbackModule)),l.imports&&(u=u.concat(l.imports)),u}).flat(1))}function Ex(e){return[...new Set(e)]}function Tx(e){let s={},a=Object.keys(e).sort();for(let o of a)s[o]=e[o];return s}function Ax(e,s){let a=new Set;return new Set(s),e.reduce((o,l)=>{let u=JSON.stringify(Tx(l));return a.has(u)||(a.add(u),o.push({key:u,link:l})),o},[])}function Lc(){let e=h.useContext(ps);return _c(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Ix(){let e=h.useContext(Zi);return _c(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var zc=h.createContext(void 0);zc.displayName="FrameworkContext";function to(){let e=h.useContext(zc);return _c(e,"You must render this element inside a <HydratedRouter> element"),e}function Rx(e,s){let a=h.useContext(zc),[o,l]=h.useState(!1),[u,f]=h.useState(!1),{onFocus:p,onBlur:g,onMouseEnter:v,onMouseLeave:y,onTouchStart:w}=s,x=h.useRef(null);h.useEffect(()=>{if(e==="render"&&f(!0),e==="viewport"){let S=E=>{E.forEach(T=>{f(T.isIntersecting)})},k=new IntersectionObserver(S,{threshold:.5});return x.current&&k.observe(x.current),()=>{k.disconnect()}}},[e]),h.useEffect(()=>{if(o){let S=setTimeout(()=>{f(!0)},100);return()=>{clearTimeout(S)}}},[o]);let b=()=>{l(!0)},N=()=>{l(!1),f(!1)};return a?e!=="intent"?[u,x,{}]:[u,x,{onFocus:ta(p,b),onBlur:ta(g,N),onMouseEnter:ta(v,b),onMouseLeave:ta(y,N),onTouchStart:ta(w,b)}]:[!1,x,{}]}function ta(e,s){return a=>{e&&e(a),a.defaultPrevented||s(a)}}function Px({page:e,...s}){let a=Dv(),{nonce:o}=to(),{router:l}=Lc(),u=h.useMemo(()=>om(l.routes,e,l.basename),[l.routes,e,l.basename]);return u?(s.nonce==null&&o&&(s={...s,nonce:o}),a?h.createElement(_x,{page:e,matches:u,...s}):h.createElement(Lx,{page:e,matches:u,...s})):null}function $x(e){let{manifest:s,routeModules:a}=to(),[o,l]=h.useState([]);return h.useEffect(()=>{let u=!1;return Nx(e,s,a).then(f=>{u||l(f)}),()=>{u=!0}},[e,s,a]),o}function _x({page:e,matches:s,...a}){let o=Xt(),{future:l}=to(),{basename:u}=Lc(),f=h.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let p=km(e,u,l.v8_trailingSlashAwareDataRequests,"rsc"),g=!1,v=[];for(let y of s)typeof y.route.shouldRevalidate=="function"?g=!0:v.push(y.route.id);return g&&v.length>0&&p.searchParams.set("_routes",v.join(",")),[p.pathname+p.search]},[u,l.v8_trailingSlashAwareDataRequests,e,o,s]);return h.createElement(h.Fragment,null,f.map(p=>h.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...a})))}function Lx({page:e,matches:s,...a}){let o=Xt(),{future:l,manifest:u,routeModules:f}=to(),{basename:p}=Lc(),{loaderData:g,matches:v}=Ix(),y=h.useMemo(()=>Yf(e,s,v,u,o,"data"),[e,s,v,u,o]),w=h.useMemo(()=>Yf(e,s,v,u,o,"assets"),[e,s,v,u,o]),x=h.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let S=new Set,k=!1;if(s.forEach(T=>{var I;let P=u.routes[T.route.id];!P||!P.hasLoader||(!y.some(B=>B.route.id===T.route.id)&&T.route.id in g&&((I=f[T.route.id])!=null&&I.shouldRevalidate)||P.hasClientLoader?k=!0:S.add(T.route.id))}),S.size===0)return[];let E=km(e,p,l.v8_trailingSlashAwareDataRequests,"data");return k&&S.size>0&&E.searchParams.set("_routes",s.filter(T=>S.has(T.route.id)).map(T=>T.route.id).join(",")),[E.pathname+E.search]},[p,l.v8_trailingSlashAwareDataRequests,g,o,u,y,s,e,f]),b=h.useMemo(()=>Cx(w,u),[w,u]),N=$x(w);return h.createElement(h.Fragment,null,x.map(S=>h.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...a})),b.map(S=>h.createElement("link",{key:S,rel:"modulepreload",href:S,...a})),N.map(({key:S,link:k})=>h.createElement("link",{key:S,nonce:a.nonce,...k,crossOrigin:k.crossOrigin??a.crossOrigin})))}function zx(...e){return s=>{e.forEach(a=>{typeof a=="function"?a(s):a!=null&&(a.current=s)})}}var Fx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Fx&&(window.__reactRouterVersion="7.18.4")}catch{}function Mx({basename:e,children:s,useTransitions:a,window:o}){let l=h.useRef();l.current==null&&(l.current=fv({window:o,v5Compat:!0}));let u=l.current,[f,p]=h.useState({action:u.action,location:u.location}),g=h.useCallback(v=>{a===!1?p(v):h.startTransition(()=>p(v))},[a]);return h.useLayoutEffect(()=>u.listen(g),[u,g]),h.createElement(fx,{basename:e,children:s,location:f.location,navigationType:f.action,navigator:u,useTransitions:a})}var gt=h.forwardRef(function({onClick:s,discover:a="render",prefetch:o="none",relative:l,reloadDocument:u,replace:f,mask:p,state:g,target:v,to:y,preventScrollReset:w,viewTransition:x,defaultShouldRevalidate:b,...N},S){let{basename:k,navigator:E,useTransitions:T}=h.useContext(sn),P=typeof y=="string"&&Ec.test(y),I=mm(y,k);y=I.to;let B=qv(y,{relative:l}),O=Xt(),K=null;if(p){let X=Xi(p,[],O.mask?O.mask.pathname:"/",!0);k!=="/"&&(X.pathname=X.pathname==="/"?k:wn([k,X.pathname])),K=E.createHref(X)}let[_,U,Z]=Rx(o,N),V=Dx(y,{replace:f,mask:p,state:g,target:v,preventScrollReset:w,relative:l,viewTransition:x,defaultShouldRevalidate:b,useTransitions:T});function M(X){s&&s(X),X.defaultPrevented||V(X)}let re=!(I.isExternal||u),de=h.createElement("a",{...N,...Z,href:(re?K:void 0)||I.absoluteURL||B,onClick:re?M:s,ref:zx(S,U),target:v,"data-discover":!P&&a==="render"?"true":void 0});return _&&!P?h.createElement(h.Fragment,null,de,h.createElement(Px,{page:B})):de});gt.displayName="Link";var Fc=h.forwardRef(function({"aria-current":s="page",caseSensitive:a=!1,className:o="",end:l=!1,style:u,to:f,viewTransition:p,children:g,...v},y){let w=ma(f,{relative:v.relative}),x=Xt(),b=h.useContext(Zi),{navigator:N,basename:S}=h.useContext(sn),k=b!=null&&Gx(w)&&p===!0,E=N.encodeLocation?N.encodeLocation(w).pathname:w.pathname,T=x.pathname,P=b&&b.navigation&&b.navigation.location?b.navigation.location.pathname:null;a||(T=T.toLowerCase(),P=P?P.toLowerCase():null,E=E.toLowerCase()),P&&S&&(P=Un(P,S)||P);const I=E!=="/"&&E.endsWith("/")?E.length-1:E.length;let B=T===E||!l&&T.startsWith(E)&&T.charAt(I)==="/",O=P!=null&&(P===E||!l&&P.startsWith(E)&&P.charAt(E.length)==="/"),K={isActive:B,isPending:O,isTransitioning:k},_=B?s:void 0,U;typeof o=="function"?U=o(K):U=[o,B?"active":null,O?"pending":null,k?"transitioning":null].filter(Boolean).join(" ");let Z=typeof u=="function"?u(K):u;return h.createElement(gt,{...v,"aria-current":_,className:U,ref:y,style:Z,to:f,viewTransition:p},typeof g=="function"?g(K):g)});Fc.displayName="NavLink";var Ox=h.forwardRef(({discover:e="render",fetcherKey:s,navigate:a,reloadDocument:o,replace:l,state:u,method:f=_i,action:p,onSubmit:g,relative:v,preventScrollReset:y,viewTransition:w,defaultShouldRevalidate:x,...b},N)=>{let{useTransitions:S}=h.useContext(sn),k=Hx(),E=Vx(p,{relative:v}),T=f.toLowerCase()==="get"?"get":"post",P=typeof p=="string"&&Ec.test(p),I=B=>{if(g&&g(B),B.defaultPrevented)return;B.preventDefault();let O=B.nativeEvent.submitter,K=(O==null?void 0:O.getAttribute("formmethod"))||f,_=()=>k(O||B.currentTarget,{fetcherKey:s,method:K,navigate:a,replace:l,state:u,relative:v,preventScrollReset:y,viewTransition:w,defaultShouldRevalidate:x});S&&a!==!1?h.startTransition(()=>_()):_()};return h.createElement("form",{ref:N,method:T,action:E,onSubmit:o?g:I,...b,"data-discover":!P&&e==="render"?"true":void 0})});Ox.displayName="Form";function Bx(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Nm(e){let s=h.useContext(ps);return ut(s,Bx(e)),s}function Dx(e,{target:s,replace:a,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:p,defaultShouldRevalidate:g,useTransitions:v}={}){let y=Sn(),w=Xt(),x=ma(e,{relative:f});return h.useCallback(b=>{if(vx(b,s)){b.preventDefault();let N=a!==void 0?a:Rr(w)===Rr(x),S=()=>y(e,{replace:N,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:p,defaultShouldRevalidate:g});v?h.startTransition(()=>S()):S()}},[w,y,x,a,o,l,s,e,u,f,p,g,v])}function ys(e){fn(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=h.useRef(fc(e)),a=h.useRef(!1),o=Xt(),l=h.useMemo(()=>xx(o.search,a.current?null:s.current),[o.search]),u=Sn(),f=h.useCallback((p,g)=>{const v=fc(typeof p=="function"?p(new URLSearchParams(l)):p);a.current=!0,u("?"+v,g)},[u,l]);return[l,f]}var Ux=0,Wx=()=>`__${String(++Ux)}__`;function Hx(){let{router:e}=Nm("useSubmit"),{basename:s}=h.useContext(sn),a=ox(),o=e.fetch,l=e.navigate;return h.useCallback(async(u,f={})=>{let{action:p,method:g,encType:v,formData:y,body:w}=Sx(u,s);if(f.navigate===!1){let x=f.fetcherKey||Wx();await o(x,a,f.action||p,{defaultShouldRevalidate:f.defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:w,formMethod:f.method||g,formEncType:f.encType||v,flushSync:f.flushSync})}else await l(f.action||p,{defaultShouldRevalidate:f.defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:w,formMethod:f.method||g,formEncType:f.encType||v,replace:f.replace,state:f.state,fromRouteId:a,flushSync:f.flushSync,viewTransition:f.viewTransition})},[o,l,s,a])}function Vx(e,{relative:s}={}){let{basename:a}=h.useContext(sn),o=h.useContext(jn);ut(o,"useFormAction must be used inside a RouteContext");let[l]=o.matches.slice(-1),u={...ma(e||".",{relative:s})},f=Xt();if(e==null){u.search=f.search;let p=new URLSearchParams(u.search),g=p.getAll("index");if(g.some(y=>y==="")){p.delete("index"),g.filter(w=>w).forEach(w=>p.append("index",w));let y=p.toString();u.search=y?`?${y}`:""}}return(!e||e===".")&&l.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(u.pathname=u.pathname==="/"?a:wn([a,u.pathname])),Rr(u)}function Gx(e,{relative:s}={}){let a=h.useContext(ym);ut(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Nm("useViewTransitionState"),l=ma(e,{relative:s});if(!a.isTransitioning)return!1;let u=Un(a.currentLocation.pathname,o)||a.currentLocation.pathname,f=Un(a.nextLocation.pathname,o)||a.nextLocation.pathname;return Fi(l.pathname,f)!=null||Fi(l.pathname,u)!=null}var Kx=am();const Ir="owner";function qx(e){const s=e||Ir;return s===Ir?[Ir]:[s,Ir]}function Yx(e){const s=new Map;for(const a of e)for(const o of a)s.has(o.id)||s.set(o.id,o);return[...s.values()].sort((a,o)=>o.createdAt-a.createdAt)}function Jx(e,s){const a=s||Ir,o=(e==null?void 0:e.pendingDomains)??[];return o.includes(a)?a:o.includes(Ir)?Ir:a}class Cm extends Error{constructor(a){super("different_account");Zs(this,"summary");this.name="DifferentAccountError",this.summary=a}}function Em(e){return e.grantors??e.approvers}function Qx(e){return e.approvals??1}function Ke(e,s){const a=e??{},o=Array.isArray(a.errors)?a.errors[0]:void 0;return o!=null&&o.message?o.code?`${o.message} (${o.code})`:o.message:o!=null&&o.code?o.code:a.error||a.detail||s}function Xx(e){const s=e==null?void 0:e.pubkeys;return!s||typeof s!="object"||Array.isArray(s)?[]:Object.entries(s).filter(a=>typeof a[1]=="string"&&a[1].length>0).map(([a,o])=>({userId:a,publicKey:o}))}class Zx{constructor(){Zs(this,"apiKey",null)}setApiKey(s){this.apiKey=s}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(s,a){return globalThis.fetch(s,{...a,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...a==null?void 0:a.headers}})}async login(s,a={}){const o=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":s,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:a.confirmWipe===!0})});if(o.status===409){const u=await o.json().catch(()=>({}));if(u!=null&&u.wouldWipe)throw new Cm(u.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!o.ok){const u=await o.json().catch(()=>({error:"Invalid API key"}));throw new Error(Ke(u,`Login failed: ${o.status}`))}return(await o.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const s=await this.fetch("/api/groups");if(!s.ok)throw new Error(`Failed to fetch groups: ${s.status}`);const a=await s.json();return a.groups??a}async listProfiles(){const s=await this.fetch("/api/profiles");if(!s.ok)throw new Error(`Failed to fetch profiles: ${s.status}`);return(await s.json()).profiles}async getProfile(s){const a=await this.fetch(`/api/profiles/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch profile: ${a.status}`);return a.json()}async attest(s){const a=await this.fetch("/api/as/mandate",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ke(o,`Signing failed: ${a.status}`))}return a.json()}async getPending(s){const a=await this.fetch(`/api/mandates/pending?domain=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch pending: ${a.status}`);const o=await a.json();return o.pending??o}async getMyAttestations(s){const a=s?`?status=${encodeURIComponent(s)}`:"",o=await this.fetch(`/api/mandates/mine${a}`);if(!o.ok)throw new Error(`Failed to fetch attestations: ${o.status}`);return((await o.json()).mandates??[]).map(u=>{var f,p;return{authorization_id:u.authorization_id,profile_id:u.profileId,path:u.path,title:u.title??null,sp_status:u.status??null,frame:u.bounds??u.frame??{},required_domains:u.requiredDomains??[],attested_domains:u.attestedDomains??[],missing_domains:(u.requiredDomains??[]).filter(g=>!(u.attestedDomains??[]).includes(g)),deferred_commitment_domains:u.deferredCommitmentDomains??[],approvers_frozen:u.approversFrozen??[],above_cap:u.aboveCap??!1,created_at:u.createdAt?new Date(u.createdAt*1e3).toISOString():"",earliest_expiry:(f=u.attestations)!=null&&f.length?new Date(Math.min(...u.attestations.map(g=>g.expiresAt))*1e3).toISOString():null,remaining_seconds:(p=u.attestations)!=null&&p.length?Math.max(0,Math.min(...u.attestations.map(g=>g.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(s){const a=new URLSearchParams;s!=null&&s.since&&a.set("since",String(s.since)),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString()?`?${a.toString()}`:"",l=await this.fetch(`/denials${o}`);if(!l.ok)throw new Error(`Failed to fetch denials: ${l.status}`);return l.json()}async getMyReceipts(s){const a=new URLSearchParams;s!=null&&s.date&&a.set("date",s.date),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),l=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);return(await l.json()).tickets??[]}async fetchEvidenceBundle(){var l;const s=await this.fetch("/api/evidence-export"),a=await s.json();if(!s.ok)throw new Error(Ke(a,`Export failed (${s.status})`));const o=((l=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-evidence.json";return{bundle:a,filename:o}}async getLocalAuthorizations(){const s=await this.fetch("/api/evidence/authorizations");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const a=await s.json();return{authorizations:a.authorizations??{},signatures:a.signatures??{}}}async getArchivedReceipt(s){const a=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}`);if(a.status===404)return null;if(!a.ok)throw new Error(`Local evidence unavailable (${a.status})`);return await a.json()}async getTicketHeadlines(){const s=await this.fetch("/api/evidence/headlines");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const a=await s.json();return(a==null?void 0:a.headlines)??{}}async getReport(){const s=await this.fetch("/api/report");if(!s.ok){const a=await s.json().catch(()=>({error:`Report unavailable (${s.status})`}));throw new Error(Ke(a,`Report unavailable (${s.status})`))}return s.json()}async saveReport(s){const a=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:s})});if(!a.ok){const o=await a.json().catch(()=>({error:`Save failed (${a.status})`}));throw new Error(Ke(o,`Save failed (${a.status})`))}return a.json()}async recheckReport(){const s=await this.fetch("/api/report/recheck",{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:`Recheck failed (${s.status})`}));throw new Error(Ke(a,`Recheck failed (${s.status})`))}return s.json()}async exportReportWithProof(){var l;const s=await this.fetch("/api/report/export");if(!s.ok){const u=await s.json().catch(()=>({error:`Export failed (${s.status})`}));throw new Error(Ke(u,`Export failed (${s.status})`))}const a=await s.text(),o=((l=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-report.html";return{html:a,filename:o}}async revokeAttestation(s,a){const o=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/revoke`,{method:"POST",body:JSON.stringify({reason:a??"Revoked by user"})});if(!o.ok){const l=await o.json().catch(()=>({error:"Failed to revoke"}));throw new Error(Ke(l,`Revoke failed: ${o.status}`))}}async getAttestations(s){const a=await this.fetch(`/api/mandates?authorization_id=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch attestations: ${a.status}`);const o=await a.json();return{...o,attestations:o.mandates??o.attestations??[]}}async getGroupById(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch group: ${a.status}`);return a.json()}async createGroup(s){const a=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:s})});if(!a.ok){const u=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ke(u,`Create group failed: ${a.status}`))}const o=await a.json(),l=o.group||o;return{id:l.id,name:l.name,myDomains:l.myDomains||[],isAdmin:!0,ended:o.ended??{mandates:0,proposals:0}}}async getCreatePreview(){const s=await this.fetch("/api/groups/create/preview");if(!s.ok){const a=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(Ke(a,`Failed to preview team creation: ${s.status}`))}return s.json()}async getJoinPreview(s){const a=await this.fetch(`/api/groups/join/preview?inviteCode=${encodeURIComponent(s)}`);if(!a.ok){const o=await a.json().catch(()=>({error:"Invalid or expired invite code"}));throw new Error(Ke(o,`Invalid invite code: ${a.status}`))}return a.json()}async requestToJoinGroup(s){const a=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:s})});if(a.status!==202){const l=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ke(l,`Request to join failed: ${a.status}`))}return(await a.json()).request}async withdrawJoinRequest(){const s=await this.fetch("/api/groups/join",{method:"DELETE"});if(s.status===404)return!1;if(!s.ok){const o=await s.json().catch(()=>({error:"Unknown error"}));throw new Error(Ke(o,`Withdraw failed: ${s.status}`))}return(await s.json()).withdrawn===!0}async inviteToGroup(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/invite`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Unknown error"}));throw new Error(Ke(o,`Invite failed: ${a.status}`))}return a.json()}async getMyTeam(){const s=await this.fetch("/api/groups/me");if(!s.ok)return{group:null,membership:null,pendingRequest:null};const a=await s.json();return{group:a.group??null,membership:a.membership??null,pendingRequest:a.pendingRequest??null}}async listUsers(){const s=await this.fetch("/api/users");return s.ok?(await s.json()).users??[]:[]}async setPubkey(s){const a=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(Ke(o,`setPubkey failed: ${a.status}`))}}async getPubkey(s){const a=await this.fetch(`/api/users/${encodeURIComponent(s)}/pubkey`);return a.status===404||!a.ok?null:(await a.json()).pubkey??null}async leaveTeam(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/leave`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to leave team"}));throw new Error(Ke(o,`Leave failed: ${a.status}`))}}async getVaultStatus(){const s=await this.fetch("/vault/status");if(!s.ok)throw new Error(`Failed to fetch vault status: ${s.status}`);return s.json()}async getGatewaySettings(){const s=await this.fetch("/api/gateway-settings");if(!s.ok)throw new Error(`Failed to load settings: ${s.status}`);return s.json()}async setGatewaySettings(s){const a=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error(`Failed to save settings: ${a.status}`);return a.json()}async getArchivedMandates(){const s=await this.fetch("/api/archived-mandates");if(!s.ok)throw new Error(`Failed to load archived mandates: ${s.status}`);return(await s.json()).archived}async setMandateArchived(s,a){const o=await this.fetch(`/api/archived-mandates/${encodeURIComponent(s)}`,{method:a?"PUT":"DELETE"});if(!o.ok)throw new Error(`Failed to ${a?"archive":"unarchive"} mandate: ${o.status}`);return(await o.json()).archived}async getLastSeenBlockedAt(){const s=await this.fetch("/api/blocked-seen");if(!s.ok)throw new Error(`Failed to load last-seen: ${s.status}`);return(await s.json()).lastSeenBlockedAt}async markBlockedSeen(s=Date.now()){const a=await this.fetch("/api/blocked-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark blocked seen: ${a.status}`);return(await a.json()).lastSeenBlockedAt}async getLastSeenReportAt(){const s=await this.fetch("/api/report-seen");if(!s.ok)throw new Error(`Failed to load last-seen report: ${s.status}`);return(await s.json()).lastSeenReportAt}async markReportSeen(s=Date.now()){const a=await this.fetch("/api/report-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark report seen: ${a.status}`);return(await a.json()).lastSeenReportAt}async getLastSeenTicketsAt(){const s=await this.fetch("/api/tickets-seen");if(!s.ok)throw new Error(`Failed to load last-seen tickets: ${s.status}`);return(await s.json()).lastSeenTicketsAt}async markTicketsSeen(s=Date.now()){const a=await this.fetch("/api/tickets-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark tickets seen: ${a.status}`);return(await a.json()).lastSeenTicketsAt}async getCredential(s){const a=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to check credential: ${a.status}`);return a.json()}async setCredential(s,a){const o=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`,{method:"PUT",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to save credential: ${o.status}`)}async testCredential(s){const a=await this.fetch(`/vault/test/${encodeURIComponent(s)}`,{method:"POST"});if(!a.ok)throw new Error(`Test failed: ${a.status}`);return a.json()}async aiAssist(s){const a=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:Ke(o,"AI request failed"),disclaimer:"AI surfaces reality. You supply intent."}}return a.json()}async aiIntentReview(s){const a=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:Ke(o,"AI request failed")}}return a.json()}async aiTest(s){const a=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`AI test failed: ${a.status}`);return a.json()}async aiModels(s){const a=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`Model list failed: ${a.status}`);return a.json()}async getMcpHealth(){const s=await this.fetch("/mcp/health");if(!s.ok)throw new Error(`MCP server unreachable: ${s.status}`);return s.json()}async getAgentContact(){const s=await this.fetch("/mcp/agent-contact");if(!s.ok)throw new Error(`Failed to fetch agent contact: ${s.status}`);return s.json()}async getMcpIntegrations(){const s=await this.fetch("/mcp/integrations");if(!s.ok)throw new Error(`Failed to fetch integrations: ${s.status}`);return s.json()}async getOAuthHealth(s){try{const a=await this.fetch(`/auth/oauth/${encodeURIComponent(s)}/health`);return a.ok?await a.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const s=await this.fetch("/mcp/integrations/manifests");if(!s.ok)throw new Error(`Failed to fetch manifests: ${s.status}`);return s.json()}async getLabelManifests(){const{manifests:s,builtins:a}=await this.getIntegrationManifests();return[...s??[],...a??[]]}async discoverScopeField(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/discover/${encodeURIComponent(a)}`);if(!o.ok){const l=await o.json().catch(()=>({error:`Discovery failed: ${o.status}`}));throw new Error(Ke(l,`Discovery failed: ${o.status}`))}return o.json()}async activateIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}/activate`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed"}));throw new Error(Ke(o,`Failed: ${a.status}`))}return a.json()}async removeMcpIntegration(s){const a=await this.fetch(`/mcp/integrations/${encodeURIComponent(s)}`,{method:"DELETE"});if(!a.ok)throw new Error(`Failed to remove integration: ${a.status}`)}async setReadPolicy(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:a})});if(!o.ok){const l=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(Ke(l,`HTTP ${o.status}`))}}async getTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`);if(o.status===404||!o.ok)return null;const l=await o.json();return(l==null?void 0:l.config)??null}async setTeamProfileConfig(s,a,o){const l=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(o)});if(!l.ok){const u=await l.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(Ke(u,`setTeamProfileConfig failed: ${l.status}`))}}async encryptIntent(s,a){const o=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:s,recipients:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(Ke(l,`encryptIntent failed: ${o.status}`))}return o.json()}async getToolDisplay(){const s=await this.fetch("/tool-display");if(!s.ok)return{};const a=await s.json();return(a==null?void 0:a.tools)??{}}async getApproversPubkeys(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}/approvers/pubkeys`);return o.ok?Xx(await o.json()):[]}async deleteTeamProfileConfig(s,a){const o=await this.fetch(`/api/groups/${encodeURIComponent(s)}/profile-config/${encodeURIComponent(a)}`,{method:"DELETE"});if(!o.ok){const l=await o.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(Ke(l,`deleteTeamProfileConfig failed: ${o.status}`))}}async getIdentityDisclosure(){const s=await this.fetch("/api/users/me/identity-disclosure");if(!s.ok)throw new Error(`Failed to read identity setting: ${s.status}`);return s.json()}async setIdentityDisclosure(s){const a=await this.fetch("/api/users/me/identity-disclosure",{method:"PUT",body:JSON.stringify({always:s})});if(!a.ok)throw new Error(`Failed to save identity setting: ${a.status}`);return a.json()}async getProposals(s,a="pending"){const o=a==="all"?"&status=all":"",l=await this.fetch(`/api/proposals?domain=${encodeURIComponent(s)}${o}`);if(!l.ok)throw new Error(`Failed to fetch proposals: ${l.status}`);return(await l.json()).proposals??[]}async getMyProposals(s,a="pending"){const o=await Promise.all(qx(s).map(l=>this.getProposals(l,a)));return Yx(o)}async resolveProposal(s,a,o,l){const{noteEncrypted:u,contentHash:f,shownHash:p,note:g,...v}=l??{},y=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/resolve`,{method:"POST",body:JSON.stringify({action:a,domain:o,...v,...u?{note_encrypted:u}:g?{note:g}:{},...f?{content_hash:f}:{},...p?{shown_hash:p}:{}})});if(!y.ok){const w=await y.json().catch(()=>({error:"Failed"}));throw new Error(Ke(w,`Failed: ${y.status}`))}return y.json()}async getProposal(s){const a=await this.fetch(`/api/proposals/${encodeURIComponent(s)}`);if(!a.ok){const l=await a.json().catch(()=>({error:"Failed"}));throw new Error(Ke(l,`getProposal failed: ${a.status}`))}const o=await a.json();return o.proposal??o}async getProposalsForApprover(){const s=await this.fetch("/api/proposals?approver=me");if(!s.ok)throw new Error(`Failed to fetch approver proposals: ${s.status}`);return(await s.json()).proposals??[]}async approveProposal(s,a,o){const l={};a&&(l.content_hash=a),o&&(l.shown_hash=o);const u=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/approve`,{method:"POST",body:Object.keys(l).length>0?JSON.stringify(l):void 0});if(!u.ok){const f=await u.json().catch(()=>({error:"Failed"}));throw new Error(Ke(f,`approveProposal failed: ${u.status}`))}return u.json()}async rejectProposal(s,a,o,l){let u;if(typeof a=="string")u={reason:a};else{const{noteEncrypted:p,note:g,...v}=a??{};u={...v,...p?{note_encrypted:p}:g?{note:g}:{}}}o&&(u.content_hash=o),l&&(u.shown_hash=l);const f=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/reject`,{method:"POST",body:JSON.stringify(u)});if(!f.ok){const p=await f.json().catch(()=>({error:"Failed"}));throw new Error(Ke(p,`rejectProposal failed: ${f.status}`))}return f.json()}async getProposalsCreatedByMe(){const s=await this.fetch("/api/proposals?creator=me");if(s.status===400)return null;if(!s.ok)throw new Error(`Failed to fetch my proposals: ${s.status}`);return(await s.json()).proposals??[]}async withdrawProposal(s,a,o,l){const{noteEncrypted:u,note:f}=a??{},p={...u?{note_encrypted:u}:f?{note:f}:{}};o&&(p.content_hash=o),l&&(p.shown_hash=l);const g=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/withdraw`,{method:"POST",body:JSON.stringify(p)});if(!g.ok){const v=await g.json().catch(()=>({error:"Failed"}));throw new Error(Ke(v,`withdrawProposal failed: ${g.status}`))}return g.json()}async getProposalPreview(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/preview`);if(!a.ok)throw new Error(`Failed to fetch preview: ${a.status}`);return a.json()}async getProposalRequestContext(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/request-context`);if(!a.ok)throw new Error(`Failed to fetch request context: ${a.status}`);return a.json()}async saveShownSnapshot(s,a){const o=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/shown-snapshot`,{method:"POST",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to store the shown snapshot: ${o.status}`);return o.json()}async getShownSnapshot(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/shown-snapshot`);if(!a.ok)throw new Error(`Failed to fetch the shown snapshot: ${a.status}`);return a.json()}async getProposalOutcome(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/outcome`);if(!a.ok)throw new Error(`Failed to fetch outcome: ${a.status}`);return a.json()}async getProposalAttachmentPreview(s,a){const o=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/attachment-preview/${encodeURIComponent(a)}`);if(!o.ok)throw new Error(`Failed to fetch attachment preview: ${o.status}`);return o.json()}async getReceiptAttachmentPreview(s,a){const o=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}/attachment-preview/${encodeURIComponent(a)}`);if(!o.ok)throw new Error(`Failed to fetch attachment preview: ${o.status}`);return o.json()}async getAttestationIntent(s){const a=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/intent`);return a.status===404||a.status===403||!a.ok?null:a.json()}async decryptIntent(s){const a=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const l=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(Ke(l,`decryptIntent failed: ${a.status}`))}return(await a.json()).intent}async decryptProposalContent(s){const a=await this.fetch("/api/decrypt-proposal-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(Ke(o,`decryptProposalContent failed: ${a.status}`))}return a.json()}async encryptProposalNote(s,a){const o=await this.fetch("/api/encrypt-proposal-note",{method:"POST",body:JSON.stringify({note:s,recipientUserIds:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Encryption failed"}));throw new Error(Ke(l,`encryptProposalNote failed: ${o.status}`))}return o.json()}async storeApprovedIntent(s,a){const o=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:s,intent:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Failed"}));throw new Error(Ke(l,`storeApprovedIntent failed: ${o.status}`))}}async listTeamAuthorizations(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/mandates`);if(!a.ok)throw new Error(`Failed to fetch team authorizations: ${a.status}`);return((await a.json()).mandates??[]).map(l=>{var p,g;const u=l.owner??{userId:""};return{authorization_id:l.authorization_id??l.authorizationId,profile_id:l.profileId??l.profile_id,path:l.path??"",title:l.title??null,sp_status:l.status??l.sp_status??null,frame:l.bounds??l.frame??{},required_domains:l.requiredDomains??l.required_domains??[],attested_domains:l.attestedDomains??l.attested_domains??[],missing_domains:(l.requiredDomains??l.required_domains??[]).filter(v=>!(l.attestedDomains??l.attested_domains??[]).includes(v)),deferred_commitment_domains:l.deferredCommitmentDomains??l.deferred_commitment_domains??[],approvers_frozen:l.approversFrozen??l.approvers_frozen??[],above_cap:l.aboveCap??l.above_cap??!1,created_at:l.createdAt?new Date(l.createdAt*1e3).toISOString():l.created_at??"",earliest_expiry:(p=l.mandates)!=null&&p.length?new Date(Math.min(...l.mandates.map(v=>v.expiresAt))*1e3).toISOString():null,remaining_seconds:(g=l.mandates)!=null&&g.length?Math.max(0,Math.min(...l.mandates.map(v=>v.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:u}})}async listTeamReceipts(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets`);if(!a.ok)throw new Error(`Failed to fetch team receipts: ${a.status}`);return(await a.json()).tickets??[]}async getMyReceiptsPage(s){const a=new URLSearchParams;s!=null&&s.before&&a.set("before",s.before),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),l=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);const u=await l.json();return{receipts:u.tickets??[],nextBefore:u.nextBefore??null}}async listTeamReceiptsPage(s,a){const o=new URLSearchParams;a!=null&&a.before&&o.set("before",a.before),a!=null&&a.profile&&o.set("profile",a.profile),a!=null&&a.limit&&o.set("limit",String(a.limit));const l=o.toString(),u=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets${l?"?"+l:""}`);if(!u.ok)throw new Error(`Failed to fetch team receipts: ${u.status}`);const f=await u.json();return{receipts:f.tickets??[],nextBefore:f.nextBefore??null}}async getThread(s){const a=s.sinceDays??7,o=s.status??"pending",l=await this.getMyProposals(s.domain,o);let u=[];if(o==="all"){const f=[],p=new Date;for(let v=0;v<a;v++){const y=new Date(p);y.setUTCDate(p.getUTCDate()-v),f.push(y.toISOString().slice(0,10))}u=(await Promise.all(f.map(v=>this.getMyReceipts({date:v,profile:s.profile})))).flat()}return{proposals:l,receipts:u}}async getAutostart(){const s=await this.fetch("/autostart");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async setAutostart(s){const a=await this.fetch("/autostart",{method:s?"POST":"DELETE"});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.message||`HTTP ${a.status}`)}}async getAsPairing(){const s=await this.fetch("/as-pairing");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getSkippedCommitments(){const s=await this.fetch("/skipped-commitments");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getMyPendingProposals(){const s=await this.fetch("/my-pending-proposals");return s.ok?(await s.json().catch(()=>({proposals:[]}))).proposals??[]:[]}async getGateContent(s){const a=await this.fetch(`/gate-content?path=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch gate content: ${a.status}`);return(await a.json()).entry??null}async resyncGates(){const s=await this.fetch("/resync-gates",{method:"POST"});if(!s.ok)throw new Error(`Failed to resync gates: ${s.status}`)}async getEnrichedAuthorizations(){const s=await this.fetch("/active-authorizations");if(!s.ok)throw new Error(`Failed to fetch authorizations: ${s.status}`);return(await s.json()).authorizations??[]}async pushGateContent(s){const a=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(Ke(o,`Push gate content failed: ${a.status}`))}}async getAgentContext(){const s=await this.fetch("/agent-brief/context");if(!s.ok)throw new Error(`Failed to fetch agent context: ${s.status}`);return(await s.json()).content}async saveAgentContext(s){const a=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:s})});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(Ke(o,`Save failed: ${a.status}`))}}async aiChat(s){const a=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI chat failed"}));return{success:!1,error:Ke(o,`Chat failed: ${a.status}`)}}return a.json()}async getAIPrompts(){const s=await this.fetch("/ai-prompts");if(!s.ok)throw new Error(`Failed to load AI prompts: ${s.status}`);return s.json()}async setAIPrompt(s,a){const o=await this.fetch(`/ai-prompts/${s}`,{method:"PUT",body:JSON.stringify({value:a})});if(!o.ok){const l=await o.json().catch(()=>({error:"Save failed"}));throw new Error(Ke(l,`Save failed: ${o.status}`))}}}const z=new Zx,Tm=h.createContext(null);function e0({children:e}){const[s,a]=h.useState(null),[o,l]=h.useState("personal"),[u,f]=h.useState(null),[p,g]=h.useState(""),[v,y]=h.useState(null),[w,x]=h.useState(null),[b,N]=h.useState(null),[S,k]=h.useState(!1),[E,T]=h.useState(""),P=h.useRef(!1),I=h.useRef(null),B=h.useCallback(async()=>{if(P.current)try{const V=await z.getMyTeam();if(N(V.pendingRequest),V.group&&V.membership){const{group:M,membership:re}=V;y(M),x(re),l("team"),f(M);const de=I.current??re.domains[0]??"owner";g(de)}else y(null),x(null),l("personal")}catch{}},[]);h.useEffect(()=>{const V=()=>{document.visibilityState==="visible"&&B()};return document.addEventListener("visibilitychange",V),()=>document.removeEventListener("visibilitychange",V)},[B]),h.useEffect(()=>{fetch("/health").then(V=>V.json()).then(V=>{var M;((M=V.session)==null?void 0:M.lockedReason)==="as-url-changed"&&T(`Authority Server changed to ${V.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const O=h.useCallback(async(V,M={})=>{k(!0),T("");try{z.setApiKey(V),P.current=!0;const re=await z.login(V,M);a(re),I.current=re.id;const de=await z.getGroups(),X=de.find(xe=>xe.isPersonal)??de[0]??null;f(X),g("owner"),await B()}catch(re){throw z.clearApiKey(),P.current=!1,T(re instanceof Error?re.message:"Login failed"),re}finally{k(!1)}},[B]),K=h.useCallback(async()=>{await z.logout(),z.clearApiKey(),P.current=!1,I.current=null,a(null),f(null),g(""),y(null),x(null),N(null),l("personal"),T("")},[]),_=h.useCallback(V=>{z.clearApiKey(),P.current=!1,I.current=null,a(null),f(null),g(""),y(null),x(null),N(null),l("personal"),T(V??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),U=h.useCallback(()=>T(""),[]),Z=h.useCallback((V,M)=>{f(V),g(M)},[]);return n.jsx(Tm.Provider,{value:{user:s,mode:o,group:u,domain:p,groupId:(u==null?void 0:u.id)??null,activeTeam:v,activeMembership:w,pendingRequest:b,isLoading:S,error:E,login:O,logout:K,clearError:U,handleSessionLocked:_,activeGroup:u,activeDomain:p,groups:u?[u]:[],setActiveContext:Z,refreshGroups:B},children:e})}function wt(){const e=h.useContext(Tm);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const t0={"integration-changed":!0,"attestation-changed":!0,"proposal-added":!0,"proposal-resolved":!0,"team-membership-changed":!0,"action-approval-needed":!0,"action-resolved":!0,"proposal-approved":!0,"proposal-rejected":!0,"session-locked":!0,"execution-failed":!0,"denial-recorded":!0,"ticket-recorded":!0,"report-written":!0},n0=Object.keys(t0),Am=h.createContext(null);function r0({children:e}){const{user:s}=wt(),a=h.useRef(null),[o,l]=h.useState(!1),u=h.useRef(new Map),f=h.useCallback((p,g)=>{const v=u.current;return v.has(p)||v.set(p,new Set),v.get(p).add(g),()=>{var y;(y=v.get(p))==null||y.delete(g)}},[]);return h.useEffect(()=>{if(!s){a.current&&(a.current.close(),a.current=null,l(!1));return}if(a.current)return;const p=z.getApiKey();if(!p)return;const g=new EventSource(`/events?key=${encodeURIComponent(p)}`);a.current=g,g.onopen=()=>l(!0),g.onerror=()=>l(!1);for(const v of n0)g.addEventListener(v,y=>{let w;try{w=JSON.parse(y.data)}catch{w=null}const x=u.current.get(v);if(x)for(const b of x)try{b(w)}catch(N){console.error(`[EventSource] handler for "${v}" threw:`,N)}});return()=>{g.close(),a.current=null,l(!1)}},[s]),n.jsx(Am.Provider,{value:{connected:o,addListener:f},children:e})}function Oe(e,s){const a=h.useContext(Am);if(!a)return;const{addListener:o}=a;h.useEffect(()=>o(e,s),[e,s,o])}const la="suveren-theme",Jf="hap-theme";function Ei(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(Jf);s!==null&&localStorage.getItem(la)===null&&localStorage.setItem(la,s),s!==null&&localStorage.removeItem(Jf)})();function Im(){const[e,s]=h.useState(()=>{const u=localStorage.getItem(la);return u==="light"||u==="dark"?u:"system"}),[a,o]=h.useState(()=>Ei(e));h.useEffect(()=>{const u=document.documentElement,f=Ei(e);u.setAttribute("data-theme",f),e==="system"?localStorage.removeItem(la):localStorage.setItem(la,e),o(Ei(e))},[e]),h.useEffect(()=>{if(e!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),f=()=>o(Ei("system"));return u.addEventListener("change",f),()=>u.removeEventListener("change",f)},[e]);const l=h.useCallback(()=>{s(u=>u==="system"?"light":u==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:a,toggle:l}}const s0=300*1e3,a0=2e3;function Mc(){const[e,s]=h.useState(!1),[a,o]=h.useState("docker"),[l,u]=h.useState(""),[f,p]=h.useState(null),[g,v]=h.useState(!1),[y,w]=h.useState(!1),[x,b]=h.useState(!1),N=h.useRef(null);return h.useEffect(()=>{let S=!1;const k=(P=!1)=>{fetch(P?"/health?refresh=1":"/health").then(I=>I.json()).then(I=>{S||(I.installMethod&&o(I.installMethod),typeof I.latestVersion<"u"&&p(I.latestVersion),I.updateAvailable&&s(!0),I.version&&(u(I.version),N.current===null?N.current=I.version:I.version!==N.current&&I.version!=="dev"&&v(!0)))}).catch(()=>{})};k(!0);const E=setInterval(()=>k(!1),x?a0:s0),T=()=>{document.visibilityState==="visible"&&k(!1)};return document.addEventListener("visibilitychange",T),window.addEventListener("focus",T),()=>{S=!0,clearInterval(E),document.removeEventListener("visibilitychange",T),window.removeEventListener("focus",T)}},[x]),{updateAvailable:e&&!y,installMethod:a,version:l,latestVersion:f,serverRestarted:g,startFastPolling:()=>b(!0),dismiss:()=>w(!0)}}function i0(e){return!e||typeof e!="object"?{managed:!1}:{managed:Array.isArray(e.policyLocked)&&e.policyLocked.includes("team")}}function o0(){const[e,s]=h.useState({managed:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(i0(o))}).catch(()=>{}),()=>{a=!0}},[]),e}function l0({size:e=20}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),n.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function c0(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Qf={system:"◑",light:"☀",dark:"☾"};function Oc({onMenuToggle:e}){const{user:s,logout:a,mode:o,activeTeam:l}=wt(),{theme:u,toggle:f}=Im(),{version:p,updateAvailable:g,latestVersion:v}=Mc(),{managed:y}=o0(),w=c0(p),x=o==="team"&&l?`Team ${l.name}`:"Personal";return n.jsx("nav",{className:"top-nav",children:n.jsxs("div",{className:"top-nav-inner",children:[n.jsxs("div",{className:"logo-group",children:[n.jsx(l0,{size:20}),n.jsx("span",{className:"logo",children:"Suveren"}),n.jsx("span",{className:"version-badge",children:"Local Gateway"}),w&&n.jsxs("span",{className:"gw-version",title:g&&v?`Running v${w} — v${v} is available`:"Running gateway version","data-stale":g?"true":void 0,children:["v",w,g&&v?` → ${v}`:""]})]}),n.jsx("div",{className:"nav-spacer"}),n.jsx("div",{className:"nav-actions nav-actions-desktop",children:s?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"workspace-pill","data-managed":y?"true":void 0,title:y?`${x} — set by your IT`:x,children:[x,y&&n.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),n.jsx("span",{className:"user-chip",children:n.jsx("strong",{children:s.name})}),n.jsx("button",{className:"theme-toggle",onClick:f,title:`Theme: ${u}`,children:Qf[u]}),n.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):n.jsx("button",{className:"theme-toggle",onClick:f,title:`Theme: ${u}`,children:Qf[u]})}),s&&e&&n.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function Bc(e,s){var a;if((a=s==null?void 0:s.revokedSet)!=null&&a.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function Rm(e){return e==="expired"||e==="revoked"}function Pm(e,s){var a;return!!((a=s==null?void 0:s.archivedSet)!=null&&a.has(e.authorization_id))&&Rm(Bc(e,s))}function Mi(e,s){return Pm(e,s)?"archived":Bc(e,s)}function $m(e,s){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of e)a[Mi(o,s)].push(o);return a}function u0(e,s){return s==="expired"?e.earliest_expiry?{iso:e.earliest_expiry,meaning:"expired"}:null:e.created_at?{iso:e.created_at,meaning:"created"}:null}function Ot(e,s,a){const o=h.useRef(e);o.current=e,h.useEffect(()=>{let l=null;const u=()=>typeof document>"u"?!0:document.visibilityState==="visible",f=()=>{u()&&o.current()},p=()=>{l===null&&(l=setInterval(f,s))},g=()=>{l!==null&&(clearInterval(l),l=null)},v=()=>{u()?(o.current(),p()):g()};return u()&&(o.current(),p()),document.addEventListener("visibilitychange",v),()=>{g(),document.removeEventListener("visibilitychange",v)}},[s,a])}function Dc(){const[e,s]=h.useState(!1);return h.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(f=>f.json()).then(f=>{a||s(f.simulation===!0)}).catch(()=>{})};o();const l=setInterval(o,3e4),u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}function d0(e,s){const a=e.simulation;return a?(((s==null?void 0:s[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function Oi(e){return!!(e!=null&&e.simulation)}function Xf(e,s){return _m(e,e.modeLabels,s)}function Zf(e,s){return _m(e,e.modeNotes,s)}function _m(e,s,a){const o=e.simulation;if(!s||!o)return;const l=((a==null?void 0:a[o.field])??"").trim().toLowerCase()||o.default.trim().toLowerCase(),u=s[l];if(u===void 0)return;if(typeof u=="string")return u;const f=e.adapterField,p=f?((a==null?void 0:a[f])??"").trim().toLowerCase():"";return p?u[p]:void 0}function Bi(e,s){var a;return s&&(!Oi(e.manifest)||((a=e.integration)==null?void 0:a.paused)==="simulation")}function f0(e,s=!1){var o;const a=[];for(const l of e)Bi(l,s)||(l.state==="error"?a.push({label:"Integration error",detail:(o=l.integration)!=null&&o.error?`${l.manifest.name}: ${l.integration.error}`:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"}):l.state==="not-running"&&(Oi(l.manifest)?a.push({label:`${l.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--text-primary)"}):a.push({label:"Integration stopped",detail:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"})));return a}function h0(e){const s=e.filter(a=>a.state==="paused");return s.length===0?null:{count:s.length,namesText:s.map(a=>a.manifest.name).join(", ")}}const Lm=h.createContext(null),m0=3e4,p0=5e3,g0=3e5;function y0(e,s,a){return s===0?"loading":e!=null&&e.running?"running":e!=null&&e.paused?"paused":e!=null&&e.error?"error":e&&a?"starting":"not-running"}function v0({children:e}){const[s,a]=h.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),o=h.useRef(null),l=h.useCallback(async()=>{let y=!1;const[w,x]=await Promise.all([z.getIntegrationManifests().catch(()=>(y=!0,{manifests:[]})),z.getMcpHealth().catch(()=>null)]);a(N=>({...N,manifests:w.manifests,integrations:(x==null?void 0:x.integrations)??N.integrations,activeSessions:(x==null?void 0:x.activeSessions)??N.activeSessions,mcpServerUp:!!x,manifestsError:y,fetchCount:N.fetchCount+1}));const b=w.manifests.filter(N=>N.oauth);if(b.length>0){const N=await Promise.all(b.map(async S=>[S.id,await z.getOAuthHealth(S.id)]));a(S=>({...S,authHealth:Object.fromEntries(N)}))}},[]),u=s.fetchCount>0&&s.manifests.some(y=>{const w=s.integrations.find(x=>x.id===y.id);return w&&!w.running&&!w.paused});Oe("integration-changed",l),Ot(l,u?p0:g0);const f=h.useMemo(()=>{const y=new Map(s.integrations.map(b=>[b.id,b])),w=Date.now();u&&o.current===null?o.current=w:u||(o.current=null);const x=o.current!==null&&w-o.current<m0;return s.manifests.map(b=>{const N=y.get(b.id),S=y0(N,s.fetchCount,x),k=s.authHealth[b.id];return{id:b.id,manifest:b,integration:N,state:S,authStatus:k==null?void 0:k.status,authAccount:k==null?void 0:k.account,authError:k==null?void 0:k.error}})},[s,u]),p=Dc(),g=h.useMemo(()=>f.filter(y=>!Bi(y,p)&&(y.state==="not-running"||y.state==="error"||y.authStatus==="failed")).length,[f,p]),v={loading:s.fetchCount===0,mcpServerUp:s.mcpServerUp,manifestsError:s.manifestsError,entries:f,attentionCount:g,activeSessions:s.activeSessions,refresh:l};return n.jsx(Lm.Provider,{value:v,children:e})}function Uc(){const e=h.useContext(Lm);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const x0={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Wc=e=>x0[e]??e,w0={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 j0(e){return(e&&w0[e])??{chip:"Blocked",sev:"info"}}function S0(e){const s=Wc(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?n.jsxs(n.Fragment,{children:["Tried to read your ",n.jsx("b",{children:e.target??"restricted"})," calendar"]}):n.jsxs(n.Fragment,{children:["Tried to read a restricted location in ",s]});case"spam":return n.jsxs(n.Fragment,{children:["Tried to open a message in ",n.jsx("b",{children:"spam or trash"})]});case"age":return n.jsxs(n.Fragment,{children:["Tried to read ",s," older than your read window"]});case"unset_age":return n.jsxs(n.Fragment,{children:["Your ",s," has ",n.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return n.jsxs(n.Fragment,{children:["Read access isn't granted on your ",s," mandate"]});case"ungoverned":return n.jsxs(n.Fragment,{children:["A ",s," tool isn't configured for safe reading"]});case"query_unsafe":return n.jsx(n.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return n.jsx(n.Fragment,{children:e.detail})}}function zm(e,s){const a=Math.max(0,(s-e)/1e3);if(a<60)return"Just now";if(a<3600)return`${Math.floor(a/60)} min ago`;if(a<86400)return`${Math.floor(a/3600)} hr ago`;const o=Math.floor(a/86400);return o===1?"Yesterday":`${o} days ago`}const b0=5,k0=1440*60*1e3,N0=7;function C0(e,s){const a=s-N0*k0;return{recent:e.filter(o=>o.ts>=a),all:e}}function E0(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(()=>{z.getDenials({limit:200}).then(({records:w})=>{s(w),o(!1)}).catch(()=>o(!0)),z.getLastSeenBlockedAt().then(u).catch(()=>u(0))},[]);if(h.useEffect(()=>{f()},[f]),Ot(f,12e4),Oe("denial-recorded",f),h.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",f),()=>window.removeEventListener("suveren:blocked-seen-changed",f)),[f]),a||e===null||l===null)return null;const{all:p}=C0(e,Date.now()),g=p.filter(w=>w.ts>l);if(g.length===0)return null;const v=g.slice(0,b0),y=(w,x)=>{const b=j0(w.reason);return n.jsxs("div",{className:"rb-row",children:[n.jsx("span",{className:`rb-dot ${b.sev==="act"?"act":b.sev==="info"?"info":""}`,"aria-hidden":"true"}),n.jsxs("div",{className:"rb-body",children:[n.jsx("div",{className:"rb-line",children:S0(w)}),n.jsxs("div",{className:"rb-meta",children:[n.jsx("span",{className:`rb-chip ${b.sev==="act"?"act":b.sev==="warn"?"warn":""}`,children:b.chip}),n.jsx("span",{className:"rb-via",children:Wc(w.integrationId)})]}),b.fixTo&&n.jsx(gt,{className:"rb-fix",to:b.fixTo,children:"Set a read window →"})]}),n.jsx("div",{className:"rb-when",children:zm(w.ts,Date.now())})]},`${w.ts}-${x}`)};return n.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[n.jsxs("div",{className:"card-header",children:[n.jsx("h2",{className:"card-title",children:"Recent blocks"}),n.jsx("span",{className:"rb-count",children:g.length})]}),n.jsx("p",{className:"rb-sub",children:"New since you last looked. Limits you set that stopped your agent — the gateway doing its job."}),n.jsx("div",{className:"rb-rows",children:v.map(y)}),n.jsxs(gt,{className:"col-btn",to:"/blocked",children:["View all ",p.length," blocks from the last 30 days ›"]})]})}function no(e){return e.kind??"read"}function T0(e,s){var u,f,p,g;if(!s)return"";if(!e)return s;const a=(f=(u=e.scopeSchema)==null?void 0:u.fields)==null?void 0:f[s];if(a!=null&&a.displayName)return a.displayName;const o=((p=e.boundsSchema)==null?void 0:p.fields)??{};if((g=o[s])!=null&&g.displayName)return o[s].displayName;const l=Object.values(o).find(v=>v.boundType&&"of"in v.boundType&&v.boundType.of===s);return l!=null&&l.displayName?l.displayName:s}const A0={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"},I0={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 eh(e){return e===void 0?"":typeof e=="number"?e.toLocaleString():e}function R0(e,s){const a=no(e),o=eh(e.value),l=eh(e.limit);switch(a){case"bound":return o&&l?`${s||"Value"} ${o} is above the limit ${l}.`:e.detail;case"scope":return o?`${s||"Value"} "${o}" is not within your mandate's allowed ${s||"scope"}.`:e.detail;case"cumulative":return o&&l?`${o} of ${l} used — the limit is reached.`:e.detail;case"simulation":return"Real systems are switched off while the gateway runs in simulation mode.";case"not_authorized":return"No mandate currently covers this action.";case"read":default:return e.detail}}function Fm(e,s){if(e.mandateId){const a=s==null?void 0:s[e.mandateId];if(a)return a}return e.mandateTitle}function P0(e,s){const a=Fm(e,s);if(a){const o=[{text:` · mandate "${a}"`}];return e.mandateId&&o.push({text:` (${e.mandateId.slice(0,14)}…)`,dim:!0}),o}return e.mandateId?[{text:` · mandate ${e.mandateId.slice(0,14)}…`}]:[]}function $0(e,s){const a=no(e),o=Wc(e.integrationId),l=e.who==="authority-server"?"refused by the Authority Server":a==="read"?"refused by this gateway":"refused by this gateway, before anything ran",u=e.code?` (${e.code})`:"";return[{text:`${o} · ${e.tool}`},...P0(e,s),{text:` · ${l}${u}`}]}function _0(e,s,a){const o=no(e),l=T0(s,e.field);return{title:A0[o],sentence:R0(e,l),sourceLine:$0(e,a),whatYouCanDo:I0[o]}}function L0(e,s){const a=new Date(s);return a.setHours(0,0,0,0),e.filter(o=>o.ts>=a.getTime()).length}function z0(e,s){return e.filter(a=>a.ts>s).length}const F0=1440*60*1e3;function M0(e,s){const a=new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),o=new Date(s);o.setHours(0,0,0,0);const l=o.getTime();return e>=l?`Today · ${a}`:e>=l-F0?`Yesterday · ${a}`:`${new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})} · ${a}`}function Mm(e,s){return!!e&&e.savedAt*1e3>s}function O0(e){const s=/<h[1-3][^>]*>([\s\S]*?)<\/h[1-3]>/i.exec(e),a=s?s[1].replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/\s+/g," ").trim():"";return a?a.length>80?`${a.slice(0,79)}…`:a:"Report"}function B0(e){var s,a;return{verified:((a=(s=e.proof)==null?void 0:s.verifiedValues)==null?void 0:a.length)??0,unchecked:(e.elements??[]).filter(o=>o.status==="unverifiable").length}}const th=(e,s)=>new Date(e*1e3).toLocaleString(s,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),nh=(e,s)=>new Date(e*1e3).toLocaleString(s,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});function Di(e,s){const a=e==null?void 0:e.window;return a?{text:`Covers ${th(a.start,s)} → ${th(a.end,s)} (${a.days} day${a.days===1?"":"s"})`,title:`From ${nh(a.start,s)} to ${nh(a.end,s)}. Tickets up to 2 minutes after the end count, for small clock differences.`}:{text:"Period not recorded"}}function Om(e,s,a){const o=new Date(e*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"}),u=Math.floor((s-e*1e3)/864e5);if(new Date(s).toDateString()===o.toDateString())return`today ${l}`;const p=`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`;return u>=2?`${p} (${u} days ago)`:p}const D0=[{to:"/",icon:"□",label:"Dashboard",group:"top"},{to:"/approvals",icon:"▷",iconClass:"nav-ic-approval",label:"Approvals",statusKey:"proposals",group:"core"},{to:"/mandates",icon:"☰",iconClass:"nav-ic-mandate",label:"Mandates",statusKey:"authorizations",group:"core",quietCount:!0},{to:"/tickets",icon:"▣",iconClass:"nav-ic-ticket",label:"Tickets",group:"core"},{to:"/reports",icon:"▥",label:"Reports",statusKey:"report",newLabel:!0,group:"core"},{to:"/blocked",icon:"⊘",iconClass:"nav-ic-blocked",label:"Blocked",statusKey:"blocked",group:"core"},{to:"/team",icon:"◉",label:"Team",teamOnly:!0,group:"setup"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief",group:"setup"},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations",group:"setup"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant",group:"setup"}];function U0(){const{activeDomain:e}=wt(),[s,a]=h.useState({}),o=h.useCallback(async()=>{try{const[l,u,f,p,g,v,y,w,x,b]=await Promise.all([z.getCredential("ai-config").catch(()=>null),z.getMyAttestations().catch(()=>null),z.getMyProposals(e).catch(()=>null),z.getProposalsForApprover().catch(()=>null),z.getAgentContext().catch(()=>""),z.getArchivedMandates().catch(()=>[]),z.getDenials({limit:200}).catch(()=>null),z.getLastSeenBlockedAt().catch(()=>0),z.getReport().catch(()=>null),z.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]),N={};if(l&&!l.configured&&(N.assistant=1),u){const T=$m(u,{archivedSet:new Set(v)}).expired.length;T>0&&(N.authorizations=T)}const S=(f==null?void 0:f.length)??0,k=(p==null?void 0:p.length)??0,E=S+k;if(E>0&&(N.proposals=E),(!g||!g.trim())&&(N.brief=1),y){const T=z0(y.records,w);T>0&&(N.blocked=T)}Mm(x==null?void 0:x.report,b)&&(N.report=1),a(N)}catch{}},[e]);return Oe("attestation-changed",o),Oe("proposal-added",o),Oe("proposal-resolved",o),Oe("proposal-approved",o),Oe("proposal-rejected",o),Oe("team-membership-changed",o),Oe("denial-recorded",o),Oe("report-written",o),h.useEffect(()=>(window.addEventListener("suveren:archived-changed",o),()=>window.removeEventListener("suveren:archived-changed",o)),[o]),h.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",o),window.addEventListener("suveren:report-seen-changed",o),()=>{window.removeEventListener("suveren:blocked-seen-changed",o),window.removeEventListener("suveren:report-seen-changed",o)}),[o]),Ot(o,3e5,e),s}const W0={marginLeft:"auto",minWidth:"1.25rem",height:"1.25rem",padding:"0 0.375rem",borderRadius:"0.625rem",background:"var(--neutral)",color:"var(--bg-elevated)",fontSize:"0.7rem",fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},H0={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated)",color:"var(--text-primary)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"var(--elevation-2)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function V0(){const{mode:e,activeTeam:s}=wt(),a=U0(),{attentionCount:o}=Uc(),l={...a};o>0&&(l.integrations=o);const u=D0.filter(y=>!y.teamOnly||e==="team"),f=h.useRef(null),[p,g]=h.useState(null),v=Xt();return h.useEffect(()=>{if(f.current===null){f.current=e;return}f.current!==e&&(e==="team"&&s?g(`You are now acting in team context — ${s.name}`):e==="personal"&&g("You have left the team — back to personal context"),f.current=e)},[e,s]),h.useEffect(()=>{g(null)},[v.pathname]),n.jsxs("div",{className:"sidebar",children:[["top","core","setup"].map(y=>{const w=u.filter(x=>(x.group??"setup")===y);return w.length===0?null:n.jsxs("div",{className:`sidebar-${y}`,children:[y==="setup"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-divider"}),n.jsx("div",{className:"sidebar-group-label",children:"Setup"})]}),n.jsx("ul",{className:"sidebar-nav",children:w.map(x=>{const b=x.statusKey?l[x.statusKey]:0;return n.jsx("li",{children:n.jsxs(Fc,{to:x.to,end:x.to==="/",className:({isActive:N})=>`sidebar-item${N?" active":""}`,children:[n.jsx("span",{className:"icon",children:x.iconClass?n.jsx("span",{className:`nav-ic ${x.iconClass}`,"aria-hidden":"true"}):x.icon}),x.label,b?x.newLabel?n.jsx("span",{className:"nav-new","data-testid":`nav-new-${x.statusKey}`,children:"New"}):n.jsx("span",{style:W0,className:x.quietCount?"nav-count-quiet":void 0,title:x.quietCount?"Expired mandates":void 0,children:b}):null]})},x.to)})})]},y)}),p&&n.jsx("div",{style:H0,role:"status","aria-live":"polite",children:p})]})}const Zl="suveren:updatedTo";function G0(e){return e==="managed"||e==="msi"?null:e==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":e==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}const K0="Updates for this gateway come from your company's IT — no action needed here.";function q0(e){return e==="managed"?"update-banner is-managed":"update-banner"}const Y0="Download the new installer and run it. Your settings and mandates stay.";function J0(e){const s="https://github.com/suverenai/suveren-gateway/releases";return e?`${s}/tag/v${e}`:`${s}/latest`}function Q0(){const e=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const a of e)if(!a.closest(".update-overlay"))return!0;const s=document.activeElement;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)){const a=s.value;if(a&&a.trim())return!0}return!1}function Bm(){const{updateAvailable:e,installMethod:s,version:a,latestVersion:o,serverRestarted:l,startFastPolling:u,dismiss:f}=Mc(),[p,g]=h.useState(!1),[v,y]=h.useState(!1),[w,x]=h.useState(()=>{try{const P=sessionStorage.getItem(Zl);if(P)return sessionStorage.removeItem(Zl),P}catch{}return null}),b=G0(s),N=h.useRef(null),S=P=>{try{sessionStorage.setItem(Zl,P||o||"✓")}catch{}window.location.reload()};h.useEffect(()=>{if(!w)return;const P=setTimeout(()=>x(null),6e3);return()=>clearTimeout(P)},[w]),h.useEffect(()=>{if(!p||!l)return;const P=()=>Q0()?!1:(S(a),!0);if(P())return;const I=setInterval(P,1500);return()=>clearInterval(I)},[p,l,a]),h.useEffect(()=>(document.body.classList.toggle("is-updating",p),()=>document.body.classList.remove("is-updating")),[p]);const k=e&&!p&&!w||!!w&&!p;h.useEffect(()=>{if(!k){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const P=()=>{var O;const B=((O=N.current)==null?void 0:O.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${B}px`)};P();const I=new ResizeObserver(P);return N.current&&I.observe(N.current),()=>{I.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[k]);const E=()=>{g(!0),u()},T=async()=>{if(b)try{await navigator.clipboard.writeText(b),y(!0),setTimeout(()=>y(!1),1800)}catch{}};return n.jsxs(n.Fragment,{children:[w&&!p&&n.jsx("div",{ref:N,className:"update-banner is-live",role:"status","aria-live":"polite",children:n.jsxs("div",{className:"update-banner-row",children:[n.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",w&&w!=="✓"?` — ${w} is live`:" — now live","."]}),n.jsx("button",{className:"update-banner-x",onClick:()=>x(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!p&&!w&&n.jsxs("div",{ref:N,className:q0(s),role:"status","aria-live":"polite",children:[n.jsxs("div",{className:"update-banner-row",children:[n.jsx("span",{className:"update-banner-text",children:s==="msi"&&o?`Update available — version ${o}.`:"Update available."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[s==="msi"&&n.jsx("a",{className:"btn btn-sm btn-secondary",href:J0(o),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),s!=="managed"&&s!=="msi"&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:E,children:"Update"}),n.jsx("button",{className:"update-banner-x",onClick:f,"aria-label":"Dismiss",children:"×"})]})]}),s==="managed"&&n.jsx("p",{className:"update-banner-hint",children:K0}),s==="msi"&&n.jsx("p",{className:"update-banner-hint",children:Y0})]}),p&&n.jsx("div",{className:"update-overlay",children:n.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[n.jsx("div",{className:"update-spinner"}),n.jsxs("h2",{children:["Finishing the update","…"]}),n.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",n.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),n.jsxs("div",{className:"update-cmd-row",children:[n.jsx("code",{className:"update-cmd",children:b}),n.jsx("button",{className:"btn btn-sm btn-primary",onClick:T,children:v?"Copied":"Copy"})]}),n.jsxs("div",{className:"update-status",children:[n.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),n.jsxs("div",{className:"update-overlay-actions",children:[n.jsx("button",{className:"btn btn-primary",onClick:()=>S(a),children:"Reload now"}),n.jsx("button",{className:"btn btn-secondary",onClick:()=>g(!1),children:"Cancel"})]})]})})]})}function Dm(){const e=Dc(),s=h.useRef(null);return h.useEffect(()=>{if(!e){document.documentElement.style.removeProperty("--sim-banner-h");return}const a=()=>{var u;const l=((u=s.current)==null?void 0:u.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${l}px`)};a();const o=new ResizeObserver(a);return s.current&&o.observe(s.current),()=>{o.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[e]),e?n.jsx("div",{ref:s,className:"simulation-banner",role:"status","aria-live":"polite",children:n.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const X0={system:"◑",light:"☀",dark:"☾"},Z0=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/blocked",icon:"⊘",label:"Blocked"},{to:"/team",icon:"◉",label:"Team"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function ew({open:e,onClose:s}){const{user:a,activeGroup:o,activeDomain:l,logout:u}=wt(),{theme:f,toggle:p}=Im(),g=Xt();return h.useEffect(()=>{s()},[g.pathname]),e?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mobile-menu-backdrop",onClick:s}),n.jsxs("div",{className:"mobile-menu-panel",children:[a&&n.jsxs("div",{className:"mobile-menu-header",children:[n.jsx("strong",{children:a.name}),n.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:o?`${o.name} / ${l}`:l||"personal"})]}),n.jsx("nav",{className:"mobile-menu-nav",children:Z0.map(v=>n.jsxs(Fc,{to:v.to,end:v.to==="/",className:({isActive:y})=>`mobile-menu-item${y?" active":""}`,onClick:s,children:[n.jsx("span",{className:"icon",children:v.icon}),v.label]},v.to))}),n.jsxs("div",{className:"mobile-menu-footer",children:[n.jsxs("button",{className:"mobile-menu-action",onClick:()=>{p()},children:[n.jsx("span",{className:"icon",children:X0[f]}),"Theme: ",f]}),n.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),s()},children:"Logout"})]})]})]}):null}function Um(e){return e.status==="pending"}function tw(e,s){return e.filter(Um).length+s.length}const Er=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],nw=500;function Wm(){const{user:e,domain:s}=wt(),[a,o]=h.useState(0),l=h.useRef(null),u=h.useCallback(async()=>{if(!e){o(0);return}try{const[p,g]=await Promise.all([z.getMyProposals(s).catch(()=>[]),z.getProposalsForApprover().catch(()=>[])]);o(tw(p,g))}catch{o(0)}},[e,s]),f=h.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{u()},nw)},[u]);return h.useEffect(()=>(u(),()=>{l.current&&clearTimeout(l.current)}),[u]),Oe(Er[0],f),Oe(Er[1],f),Oe(Er[2],f),Oe(Er[3],f),Oe(Er[4],f),Oe(Er[5],f),Oe(Er[6],f),a}const rh="Suveren",rw="/favicon.svg",sw="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Ti={x1:74.54,y1:22.74,x2:94.46,y2:34.24},aw=14,iw="#f59e0b";function ow(e){const s=Hc(e);return s>0?`(${s}) ${rh}`:rh}function Hc(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function lw(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
52
|
-
<path class="m" d="${sw}"/>
|
|
53
|
-
<line class="m" x1="${Ti.x1}" y1="${Ti.y1}" x2="${Ti.x2}" y2="${Ti.y2}"/>
|
|
54
|
-
<circle cx="103" cy="103" r="25" fill="${iw}"/>
|
|
55
|
-
<style>.m{stroke:#111111;stroke-width:${aw};fill:none;stroke-linecap:round}@media (prefers-color-scheme:dark){.m{stroke:#ffffff;stroke-width:13.3}}</style>
|
|
56
|
-
</svg>`;return`data:image/svg+xml,${encodeURIComponent(e)}`}function cw(){return document.querySelector('link[rel="icon"]')}function Hm(e){const s=Hc(e);document.title=ow(s),Vm(s);const a=cw();if(!a)return;const o=s>0?lw():rw;a.getAttribute("href")!==o&&a.setAttribute("href",o)}function uw(){Hm(0)}function Vm(e,s=globalThis.navigator){var l;if(!s||typeof s.setAppBadge!="function")return;const a=Hc(e),o=a>0?s.setAppBadge(a):s.clearAppBadge?s.clearAppBadge():s.setAppBadge(0);(l=o==null?void 0:o.catch)==null||l.call(o,()=>{})}function dw(){const e=Wm();return h.useEffect(()=>{Hm(e)},[e]),h.useEffect(()=>uw,[]),null}const Gm="suveren:dockBadgePrompt";function fw(){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(Gm))return!1}catch{}return!0}function hw(){const[e,s]=h.useState(!1),a=Wm();if(h.useEffect(()=>{s(fw())},[]),!e)return null;const o=()=>{try{localStorage.setItem(Gm,"1")}catch{}s(!1)},l=async()=>{try{await Notification.requestPermission()==="granted"&&Vm(a)}catch{}o()};return n.jsxs("div",{className:"hint-box",style:{marginBottom:"1rem",alignItems:"center"},children:[n.jsxs("div",{className:"hint-body",children:[n.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."]}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:l,children:"Allow"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,"aria-label":"Not now",children:"Not now"})]})}function mw(){const[e,s]=h.useState(!1);return n.jsxs(v0,{children:[n.jsx(dw,{}),n.jsx(Oc,{onMenuToggle:()=>s(!e)}),n.jsx(Bm,{}),n.jsx(Dm,{}),n.jsx(V0,{}),n.jsx(ew,{open:e,onClose:()=>s(!1)}),n.jsx("div",{className:"main-content",children:n.jsxs("div",{className:"page-inner",children:[n.jsx(hw,{}),n.jsx(dx,{})]})})]})}function Km({what:e}){return n.jsxs("div",{className:"human-only-note",role:"note",children:[n.jsx("strong",{children:"Only you."})," ",e==="sign-in"?"Never let an AI or a browser it controls sign in here or see this key.":"Approve only yourself. Never let an AI or a browser it controls open this page or approve for you."]})}function Vc(){return typeof navigator<"u"&&navigator.webdriver===!0}const Gc="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function pw(){const[e,s]=h.useState(""),{login:a,isLoading:o,error:l,clearError:u}=wt(),[f,p]=h.useState(null),g=Vc(),v=async()=>{if(!(!e.trim()||g)){u();try{await a(e)}catch(x){if(x instanceof Cm){p(x.summary);return}}}},y=async()=>{p(null),u();try{await a(e,{confirmWipe:!0})}catch{}},w=()=>{p(null)};return n.jsxs(n.Fragment,{children:[n.jsx(Oc,{}),n.jsx(Bm,{}),n.jsx(Dm,{}),n.jsxs("div",{className:"login-split",children:[n.jsx("div",{className:"login-split-left",children:n.jsxs("div",{style:{maxWidth:"28rem"},children:[n.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."}),n.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."})]})}),n.jsx("div",{className:"login-split-right",children:n.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),n.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage mandates."})]}),n.jsx(Km,{what:"sign-in"}),g&&n.jsx("div",{className:"error-message",children:Gc}),l&&n.jsx("div",{className:"error-message",children:l}),n.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[n.jsx("label",{className:"form-label",children:"API Key"}),n.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:x=>s(x.target.value),onKeyDown:x=>x.key==="Enter"&&v(),disabled:o,style:{padding:"0.75rem"}}),n.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),n.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:v,disabled:o||g,style:{marginBottom:"2rem"},children:o?"Signing in...":"Sign In"}),n.jsx("div",{className:"login-divider",children:"New here?"}),n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",n.jsx("br",{}),"then come back to sign in."]}),n.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"})]}),n.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[n.jsxs(n.Fragment,{children:["Create an account at ",n.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((x,b)=>n.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:b<2?"0.5rem":0},children:[n.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[b+1,"."]}),x]},b))})]})]})})]}),f&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:w,children:n.jsxs("div",{className:"card",onClick:x=>x.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[n.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),n.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 ",n.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsxs("li",{children:[f.credentialCount," stored service credential",f.credentialCount===1?"":"s",f.credentialIds.length>0&&n.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",f.credentialIds.slice(0,5).join(", "),f.credentialIds.length>5?`, +${f.credentialIds.length-5} more`:"",")"]})]}),n.jsxs("li",{children:[f.serviceCount," configured integration",f.serviceCount===1?"":"s"]}),n.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),n.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),n.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."}),n.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."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:w,disabled:o,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:y,disabled:o,children:o?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function gw(e,s){return!s&&e!=null}function yw(e,s){return e==="join-waiting"&&s==="team"}function vw(e,s,a,o){return a!=null||e!=="join-waiting"||s==="team"?null:o}function xw(e){return`${e} personal mandate${e===1?"":"s"}`}function ww({mandates:e,pendingProposals:s}){return e.length===0&&s===0?n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)"},children:"You have no personal mandates to end."}):n.jsxs("div",{style:{background:"var(--bg-elevated)",borderRadius:"0.5rem",padding:"0.75rem 1rem",margin:"0.75rem 0"},children:[n.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"}),n.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,fontSize:"0.825rem"},children:e.map(a=>n.jsxs("li",{style:{display:"flex",justifyContent:"space-between",gap:"0.5rem",padding:"0.25rem 0",borderBottom:"1px solid var(--border)"},children:[n.jsx("span",{children:a.title||a.profileId}),n.jsx("span",{style:{color:"var(--text-tertiary)"},children:a.commitmentMode??""})]},a.id))}),n.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 jw(){const{mode:e,pendingRequest:s,refreshGroups:a}=wt(),o=Sn(),[l,u]=h.useState("choose"),[f,p]=h.useState(""),[g,v]=h.useState(""),[y,w]=h.useState(null),[x,b]=h.useState(null),[N,S]=h.useState(""),[k,E]=h.useState(""),[T,P]=h.useState(!1),I=h.useRef(!1);h.useEffect(()=>{gw(s,I.current)&&(I.current=!0,u("join-waiting"))},[s]),h.useEffect(()=>{yw(l,e)&&o("/")},[l,e,o]);const B=h.useRef(null);h.useEffect(()=>{if(s){B.current=s.groupName;return}const M=vw(l,e,s,B.current);M&&(S(M),u("join-declined"),B.current=null)},[s,l,e]),h.useEffect(()=>{if(l!=="join-waiting")return;const M=setInterval(()=>{a()},5e3);return()=>clearInterval(M)},[l,a]);const O=h.useCallback(()=>{u("choose"),E(""),w(null),b(null),p(""),v("")},[]),K=async()=>{if(f.trim()){P(!0),E("");try{const M=await z.getJoinPreview(f.trim());w(M),u("join-preview")}catch(M){E(M instanceof Error?M.message:"Invalid or expired invite code")}finally{P(!1)}}},_=async()=>{P(!0),E("");try{await z.requestToJoinGroup(f.trim()),await a(),u("join-waiting")}catch(M){E(M instanceof Error?M.message:"Failed to join group")}finally{P(!1)}},U=async()=>{P(!0),E("");try{await z.withdrawJoinRequest(),await a(),O()}catch(M){E(M instanceof Error?M.message:"Failed to withdraw request")}finally{P(!1)}},Z=async()=>{u("create"),E(""),P(!0);try{const M=await z.getCreatePreview();b(M)}catch(M){E(M instanceof Error?M.message:"Failed to load preview")}finally{P(!1)}},V=async()=>{if(g.trim()){P(!0),E("");try{await z.createGroup(g.trim()),await a(),o("/")}catch(M){E(M instanceof Error?M.message:"Failed to create group")}finally{P(!1)}}};return n.jsxs(n.Fragment,{children:[n.jsx(Oc,{}),n.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:n.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[k&&n.jsx("div",{className:"error-message",children:k}),l==="choose"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join or create a team"}),n.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)."})]}),n.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),n.jsxs("div",{className:"invite-input-row",children:[n.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:f,onChange:M=>p(M.target.value),onKeyDown:M=>M.key==="Enter"&&K(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:T}),n.jsx("button",{className:"btn btn-primary",onClick:K,disabled:T||!f.trim(),children:T?"Checking…":"Continue"})]})]}),n.jsxs("div",{className:"card",children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members."}),n.jsx("button",{className:"btn btn-secondary",onClick:Z,disabled:T,children:"Create a team"})]})]}),l==="join-preview"&&y&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Join team ",y.groupName,"?"]}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Your account ",n.jsx("strong",{children:"moves to the team"}),". From then on you work under the team's rules — its approvers and limits."]}),n.jsx(ww,{mandates:y.personalMandates,pendingProposals:y.pendingPersonalProposals}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:["The team admin (",y.admin.name,") confirms your request. Nothing changes until then."]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:_,disabled:T,children:T?"Asking…":"Ask to join"}),n.jsx("button",{className:"btn btn-ghost",onClick:O,disabled:T,children:"Cancel"})]})]}),l==="join-waiting"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request sent to team ",(s==null?void 0:s.groupName)??""]}),n.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."}),n.jsx("button",{className:"btn btn-secondary",onClick:U,disabled:T,children:T?"Withdrawing…":"Withdraw request"})]}),l==="join-declined"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request to ",N," ended"]}),n.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."}),n.jsx("button",{className:"btn btn-primary",onClick:O,disabled:T,children:"Back"})]}),l==="create"&&n.jsxs("div",{className:"card",children:[n.jsx("h3",{style:{marginBottom:"0.75rem"},children:"Create a team"}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:"Team name"}),n.jsx("input",{className:"form-input",placeholder:"e.g., Acme Corp",value:g,onChange:M=>v(M.target.value),onKeyDown:M=>M.key==="Enter"&&V(),disabled:T,autoFocus:!0})]}),x&&n.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",xw(x.personalMandates.length)," end (kept in your history)."]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginTop:"1rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:V,disabled:T||!g.trim(),children:T?"Creating…":"Create team and move my account"}),n.jsx("button",{className:"btn btn-ghost",onClick:O,disabled:T,children:"Cancel"})]})]})]})})]})}const sh={"claude-code":{label:"Claude Code",snippet:e=>`claude mcp add --transport http suveren ${e}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:e=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json, then restart Claude Desktop:
|
|
57
|
-
|
|
58
|
-
${JSON.stringify({mcpServers:{suveren:{command:"npx",args:["mcp-remote@latest",`${e}/mcp`,"--allow-http"]}}},null,2)}`},"chatgpt-codex":{label:"ChatGPT / Codex",snippet:e=>`Add to ~/.codex/config.toml:
|
|
59
|
-
|
|
60
|
-
[mcp_servers.suveren]
|
|
61
|
-
url = "${e}/mcp"
|
|
62
|
-
|
|
63
|
-
Or: codex mcp add suveren --url ${e}/mcp`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
|
|
64
|
-
SSE transport: GET ${e}/sse
|
|
65
|
-
Health check: GET ${e}/health`}},ah=["claude-code","claude-desktop","chatgpt-codex","other"];function hc({mcpEndpoint:e}){const[s,a]=h.useState(ah[0]),[o,l]=h.useState(!1),u=h.useCallback(async p=>{try{await navigator.clipboard.writeText(p),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},[]),f=sh[s].snippet(e);return n.jsxs("div",{children:[n.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),n.jsx("div",{className:"mcp-endpoint",children:e}),n.jsx("div",{className:"mcp-tabs",children:ah.map(p=>n.jsx("button",{className:`mcp-tab${s===p?" active":""}`,onClick:()=>a(p),children:sh[p].label},p))}),n.jsx("pre",{className:"mcp-snippet",children:f}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>u(f),children:o?"Copied":"Copy"})]})}const mc="suveren-setup-ai-skipped",pc="suveren-setup-agent-done",gc="suveren-setup-dismissed",Sw={"hap-setup-ai-skipped":mc,"hap-setup-agent-done":pc,"hap-setup-dismissed":gc};function bw(){for(const[e,s]of Object.entries(Sw)){const a=localStorage.getItem(e);a!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,a),a!==null&&localStorage.removeItem(e)}}bw();function kw({aiConfigured:e,hasRunningIntegration:s,hasActiveAuth:a,hasAgentConnected:o,mcpEndpoint:l}){const[u,f]=h.useState(()=>localStorage.getItem(mc)==="true"),[p,g]=h.useState(()=>localStorage.getItem(pc)==="true"),[v,y]=h.useState(()=>localStorage.getItem(gc)==="true"),[w,x]=h.useState(null),b=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":u?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:s?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:a?"done":"pending"},{label:"Connect your agent",status:o||p?"done":"pending"}],N=b.filter(I=>I.status==="done"||I.status==="skipped").length,S=N===b.length,k=h.useCallback(()=>{localStorage.setItem(mc,"true"),f(!0)},[]),E=h.useCallback(()=>{localStorage.setItem(pc,"true"),g(!0),x(null)},[]),T=h.useCallback(()=>{localStorage.setItem(gc,"true"),y(!0)},[]);if(v||S)return null;const P=b.findIndex(I=>I.status==="pending");return n.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[n.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),n.jsx("button",{onClick:T,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:"×"})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:b.map((I,B)=>{const O=B===P,K=I.status==="done"||I.status==="skipped"?"●":"○",_=I.status==="done"?"var(--text-primary)":I.status==="skipped"?"var(--text-tertiary)":O?"var(--accent)":"var(--text-tertiary)";return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:O?"0.75rem":"0.25rem 0",borderRadius:O?"0.5rem":void 0,background:O?"var(--accent-subtle)":void 0},children:[n.jsx("span",{style:{color:_,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:K}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[I.to&&I.status==="pending"?n.jsx(gt,{to:I.to,style:{fontSize:"0.9rem",fontWeight:O?600:500,color:O?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:I.label}):I.status==="pending"&&B===3?n.jsx("button",{onClick:()=>x(w===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:O?600:500,color:O?"var(--accent)":"var(--text-primary)"},children:I.label}):n.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:I.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:I.label}),I.optional&&I.status==="pending"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),I.status==="skipped"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),I.detail&&I.status==="pending"&&O&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:I.detail})]}),I.optional&&I.status==="pending"&&n.jsx("button",{onClick:k,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),I.to&&I.status==="pending"&&n.jsx(gt,{to:I.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),B===3&&w===3&&n.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[n.jsx(hc,{mcpEndpoint:l}),n.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:E,children:"Done"})]})]},B)})}),n.jsxs("div",{style:{marginTop:"1.25rem"},children:[n.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:n.jsx("div",{style:{height:"100%",width:`${N/b.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),n.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[N," of ",b.length," complete"]})]})]})}function qm(e,s=null){const a=[e.hasContact,e.hasDelegationMandate,e.delegationProposalCount>0],o=a.every(Boolean),l=e.otherMandateCount===0&&!o,u=a.findIndex(v=>!v),f=s!==null&&a[s]===!1?s:u,p=e.managed?"managed":"self",g=v=>a[v]?{status:"done"}:v!==f?{status:"todo"}:v===1?{status:"open",variant:p,simulationOn:e.simulationOn}:v===0?{status:"open",variant:p}:{status:"open"};return{visible:l,step1:g(0),step2:g(1),step3:g(2)}}const Nw="/mandates?new=1&profile=delegation";function ih({text:e}){const[s,a]=h.useState(!1),o=h.useCallback(async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[e]);return n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:o,children:s?"Copied":"Copy"})}function ec({todo:e,onOpen:s,children:a}){return e?n.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:s,children:a}):n.jsx("span",{className:"flow-step-title",children:a})}function Cw({contact:e,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u,mcpEndpoint:f}){const p={hasContact:e!==null,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u},[g,v]=h.useState(null),y=qm(p,g);if(!y.visible)return null;const w=`Please connect to the Suveren gateway: MCP server at ${f}/mcp`;return n.jsxs("div",{className:"card setup-card",children:[n.jsx("h2",{className:"card-title",children:"Get started"}),n.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."}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step1.status==="open"?"open":y.step1.status==="done"?"done":"todo"}`,children:y.step1.status==="done"?"✓":"1"}),y.step1.status==="done"&&e?n.jsxs("span",{className:"flow-step-title flow-done-title",children:[e.clientName," connected · last contact ",zm(Date.parse(e.lastSeenAt),Date.now()).toLowerCase()]}):n.jsx(ec,{todo:y.step1.status==="todo",onOpen:()=>v(0),children:"Connect your AI"})]}),y.step1.status==="open"&&n.jsx("div",{className:"flow-step-body",children:y.step1.variant==="managed"?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"For your IT"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(hc,{mcpEndpoint:f})})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:w}),n.jsx(ih,{text:w})]})}),n.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."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"Set it up by hand"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(hc,{mcpEndpoint:f})})]})]})})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step2.status==="open"?"open":y.step2.status==="done"?"done":"todo"}`,children:y.step2.status==="done"?"✓":"2"}),y.step2.status==="done"?n.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",n.jsx(gt,{to:"/mandates",children:"review or revoke under Mandates"})]}):n.jsx(ec,{todo:y.step2.status==="todo",onOpen:()=>v(1),children:"Give the Delegation mandate"})]}),y.step2.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.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."}),n.jsxs("ul",{className:"bound-list",children:[n.jsx("li",{children:"Read the setup guides"}),n.jsx("li",{children:"Propose new mandates — each waits for your approval"}),n.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),y.step2.simulationOn?n.jsxs(n.Fragment,{children:[n.jsx(gt,{to:Nw,className:"btn btn-primary",children:"Give the Delegation mandate →"}),n.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),y.step2.variant==="managed"&&n.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):n.jsx("p",{className:"managed-note",style:{marginTop:0},children:y.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":n.jsxs(n.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",n.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step3.status==="open"?"open":"todo"}`,children:"3"}),n.jsx(ec,{todo:y.step3.status==="todo",onOpen:()=>v(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),y.step3.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),n.jsx(ih,{text:"How do I start with Suveren?"})]})}),n.jsxs("p",{children:["It will interview you, suggest test data, and propose mandates and a brief. Approve its proposals under ",n.jsx(gt,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function Ew(){const[e,s]=h.useState(null);return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{!a&&typeof o.mcpPort=="number"&&s(`http://localhost:${o.mcpPort}`)}).catch(()=>{}),()=>{a=!0}},[]),e}function Tw(e){if(!e||typeof e!="object")return{simulation:null,locked:!1};const s=Array.isArray(e.policyLocked)&&e.policyLocked.includes("simulation");return{simulation:typeof e.simulation=="boolean"?e.simulation:null,locked:s}}function Ym(){const[e,s]=h.useState({simulation:null,locked:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(Tw(o))}).catch(()=>{}),()=>{a=!0}},[]),e}function Aw(e){return!e||typeof e!="object"?!1:Array.isArray(e.policyLocked)&&e.policyLocked.length>0}function Iw(){const[e,s]=h.useState(!1);return h.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(f=>f.json()).then(f=>{a||s(Aw(f))}).catch(()=>{})};o();const l=setInterval(o,3e4),u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}const oh=new Map;function Kc(e){let s=oh.get(e);return s||(s=(async()=>{try{let a=e;if(!e.includes("@")){const o=await z.listProfiles(),l=f=>f.replace(/@.*$/,"").split("/").pop(),u=o.filter(f=>l(f.id)===e).sort((f,p)=>(p.id.split("@")[1]??"").localeCompare(f.id.split("@")[1]??"",void 0,{numeric:!0}));if(!u[0])return null;a=u[0].id}return await z.getProfile(a)}catch{return null}})(),oh.set(e,s)),s}function vs(e){const[s,a]=h.useState(null);return h.useEffect(()=>{let o=!0;return e&&Kc(e).then(l=>{o&&a(l)}),()=>{o=!1}},[e]),s}const lh=40;function Bt(e,s){const a=e.lastIndexOf("/"),o=a>=0?e.slice(a+1):e,l=o.indexOf("@"),u=l>=0?o.slice(0,l):o;return s?s.slice(0,lh):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,lh)}function Rn(e){const s=e.lastIndexOf("/"),a=s>=0?e.slice(s+1):e,o=a.indexOf("@");return(o>=0?a.slice(0,o):a).toLowerCase()}function _r(e,s){const a=Rn(e),o=Pr(e),l=Bt(e,s==null?void 0:s.name);return{icon:o,name:l,testSetup:a==="delegation"}}function ro(e){return e.startsWith("setup__")}const Rw={customers:"customers",email:"email",charge:"payments",sales:"sales",calendar:"calendar",records:"records",publish:"publishing",deploy:"deployments",purchase:"purchasing",reporting:"reports",delegation:"setup",invoicing:"invoicing"};function Pr(e){return Rw[Rn(e)]??"unknown"}function ch(e){const s=e.indexOf("@");return s>=0?e.slice(s+1):""}function Dn(e,s){const a=Rn(e),o=s.filter(l=>Rn(l.id)===a).sort((l,u)=>ch(u.id).localeCompare(ch(l.id),void 0,{numeric:!0}))[0];return Bt(e,o==null?void 0:o.name)}function Pw(e,s){const a=e==null?void 0:e.trim();return a?a.toLowerCase()!==s.trim().toLowerCase():!1}function Jm(e){return e&&e.trim()?e.trim():null}function Qm(e,s){return s===null||Rn(e)===s}let tc=null;function Xm(){return tc||(tc=z.listProfiles().catch(()=>[])),tc}function Lr(){const[e,s]=h.useState([]);return h.useEffect(()=>{let a=!0;return Xm().then(o=>{a&&s(o)}),()=>{a=!1}},[]),e}function $w(e){const s=Lr();return Dn(e,s)}function so(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}const Zm=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview","_source","_attachmentsSealed"]);function Ht(e){const s=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)}function Wn(e){const s=e.indexOf("__");return s<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,s),toolName:e.slice(s+2)}}function _w(e){const{integrationId:s,toolName:a}=Wn(e);return s?`${s} · ${a}`:a}function Hn(e,s){const a=s==null?void 0:s.find(o=>o.id===e);return a!=null&&a.name?a.name:e?e.toUpperCase():"the system"}function Lw(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
|
|
66
|
-
`)||e.length>120)?"markdown":"text"}function ep(e,s){var f,p;const a=(s==null?void 0:s.approvalView)??{},o=((f=s==null?void 0:s.inputSchema)==null?void 0:f.properties)??{},l=[...new Set([...Object.keys(a),...Object.keys(o),...Object.keys(e)])],u=[];for(const g of l){if(!(g in e)||Zm.has(g)||g===(s==null?void 0:s.aiTextArg))continue;const v=e[g],y=a[g]??{},w=y.kind??Lw(v),x={key:g,label:y.label??Ht(g),kind:w,value:v,hint:(p=o[g])==null?void 0:p.description};w==="money"&&y.currencyArg&&typeof e[y.currencyArg]=="string"&&(x.currency=e[y.currencyArg]),w==="profile"&&typeof v=="string"&&(x.profileRef=v),(w==="profile-limits"||w==="profile-scope")&&y.profileArg&&typeof e[y.profileArg]=="string"&&(x.profileRef=e[y.profileArg]),u.push(x)}return u}function uh(e,s){const a=s==null?void 0:s.aiTextArg;if(!a)return;const o=e[a];return typeof o=="string"&&o.length>0?o:void 0}function zw(e,s){var o,l;const a=(l=(o=s==null?void 0:s.scopeSchema)==null?void 0:o.fields)==null?void 0:l[e];return a?{label:a.displayName??e,hint:a.description}:{label:e}}function tp(e,s,a){if(!e||typeof e!="object"||Array.isArray(e))return[];const o=a==="limits"?s==null?void 0:s.boundsSchema:s==null?void 0:s.scopeSchema,l=(o==null?void 0:o.fields)??{},u=[...new Set([...(o==null?void 0:o.keyOrder)??[],...Object.keys(e)])],f=[];for(const p of u){if(p==="profile"||!(p in e))continue;const g=e[p],v=l[p],y=so(v==null?void 0:v.unit),w=Array.isArray(g)?g.join(", "):String(g);f.push({key:p,label:(v==null?void 0:v.displayName)??Ht(p),value:y?`${w} ${y}`:w,hint:v==null?void 0:v.description,unknown:s?!v:void 0})}return f}function np(e){const s=e.indexOf("__");return s<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,s),toolName:e.slice(s+2)}}function ao(e,s){var g,v,y;const{integrationId:a,toolName:o}=np(e.action),l=s.find(w=>w.id===a),u=(v=(g=l==null?void 0:l.toolGating)==null?void 0:g.overrides)==null?void 0:v[o];if(u!=null&&u.actionLabel)return u.actionLabel;const f=Bt(e.profileId),p=(y=e.executionContext)==null?void 0:y.action_type;return typeof p=="string"&&p?`${f} · ${p}`:`${f} · ${o}`}function Fw(e,s){var l;const a=(l=s==null?void 0:s.scopeSchema)==null?void 0:l.fields;if(!a)return"";const o=[];for(const[u,f]of Object.entries(e.executionContext??{})){if(!(u in a))continue;const p=String(f??"").trim();p&&o.push(p.split(",").map(g=>g.trim()).filter(Boolean).join(", "))}return o.join(" · ")}function Mw(e,s){var l,u;if(!e)return"";const a=((l=s==null?void 0:s.scopeSchema)==null?void 0:l.fields)??{},o=[];for(const[f,p]of Object.entries(e)){if(f==="action_type")continue;const g=String(p??"").trim();if(!g)continue;const v=((u=a[f])==null?void 0:u.displayName)??f;o.push(`${v} ${g.split(",").map(y=>y.trim()).filter(Boolean).join(", ")}`)}return o.join(" · ")}function dh(e){return e.appliesTo}function Ow(e,s,a,o){var v,y,w;const l=(v=a==null?void 0:a.boundsSchema)==null?void 0:v.fields;if(!l||!s)return;const u=e.actionType??(typeof((y=e.executionContext)==null?void 0:y.action_type)=="string"?e.executionContext.action_type:void 0),f=Object.entries(l).filter(([x,b])=>{if(!(x in s))return!1;const N=b.boundType;if(!N||N.kind!=="cumulative_sum"&&N.kind!=="cumulative_count"||N.window!==o)return!1;const S=dh(b);return!S||!u||S.includes(u)}),g=(u?f.find(([,x])=>{var b;return(b=dh(x))==null?void 0:b.includes(u)}):void 0)??(f.length===1?f[0]:void 0);return g?{key:g[0],isAmount:((w=g[1].boundType)==null?void 0:w.kind)==="cumulative_sum"}:void 0}function rp(e,s,a,o){var p;const l=(p=e.cumulativeState)==null?void 0:p[o];if(!l)return null;const u=Ow(e,s,a,o),f=u?Number(s==null?void 0:s[u.key]):NaN;return u&&Number.isFinite(f)?{used:u.isAmount?l.amount:l.count,limit:f}:{count:l.count}}function Bw(e,s,a){const o=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],l=[];for(const{window:u,label:f}of o){const p=rp(e,s,a,u);p&&l.push("limit"in p?`${p.used} of ${p.limit} ${f}`:`${p.count} ${p.count===1?"call":"calls"} ${f}`)}return l.join(" · ")}function Dw(e,s,a){var u;const o=(u=a==null?void 0:a.boundsSchema)==null?void 0:u.fields;if(!e||!s||!o)return[];const l=[];for(const[f,p]of Object.entries(o)){const g=p.boundType;if(!g||g.kind!=="per_transaction")continue;const v=g.of;if(!(v in e)||!(f in s))continue;const y=Number(e[v]),w=Number(s[f]);if(!Number.isFinite(y)||!Number.isFinite(w))continue;const x=so(p.unit),b=p.displayName??Ht(v),N=S=>x?`${S.toLocaleString()} ${x}`:S.toLocaleString();l.push({key:f,label:b,ok:y<=w,valueText:N(y),limitText:N(w)})}return l}function Ui(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function Uw(e){const s=Bt(e),a=e.split("@")[1];return a?`${s}@${a}`:s}const Ww=["automatic","approved","all"];function Hw(e){return e==="automatic"||e==="approved"?e:"all"}function yc(e,s){return s==="all"?!0:s==="approved"?Ui(e):!Ui(e)}function $r(e,s){return Dn(e,s)}function pa(e,s){return Hn(np(e).integrationId,s)}function Vw(e,s){const a=Math.max(0,Math.floor((s-e)/1e3));if(a<60)return"just now";const o=Math.floor(a/60);if(o<60)return`${o} min`;const l=Math.floor(o/60);if(l<24)return`${l} h`;const u=Math.floor(l/24);return`${u} ${u===1?"day":"days"}`}function sp(e,s){const a=Vw(e*1e3,s);return a==="just now"?"waiting just now":`waiting ${a}`}const Gw=24*3600;function ap(e,s,a){const o=e-Math.floor(s/1e3);return o<=0||o>Gw?null:`Decide by ${new Date(e*1e3).toLocaleString(a,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})} — otherwise it won't run`}function ip(e){return e.replace(/-/g,"").slice(0,8)}function Kw(e,s){const a=new Date(e),o=new Date(s);return a.getFullYear()===o.getFullYear()&&a.getMonth()===o.getMonth()&&a.getDate()===o.getDate()}function qc(e,s){return Kw(e*1e3,s)}function Wi(e,s){return e.timestamp*1e3>s}function qw(e,s){var l;const a=new Map;for(const u of e){if(Ui(u))continue;const f=ao(u,s.manifests),g=`${u.authorizationId??u.profileId}|${u.action}`;let v=a.get(g);v||(v={key:g,area:$r(u.profileId,s.catalog),system:pa(u.action,s.manifests),profileId:u.profileId,mandateTitle:u.authorizationId?(l=s.titles)==null?void 0:l[u.authorizationId]:void 0,label:f,count:0,newCount:0,latestSec:0,tickets:[]},a.set(g,v)),v.count+=1,Wi(u,s.lastSeenMs)&&(v.newCount+=1),v.latestSec=Math.max(v.latestSec,u.timestamp),v.tickets.push(u)}const o=[...a.values()];for(const u of o)u.tickets.sort((f,p)=>p.timestamp-f.timestamp);return o.sort((u,f)=>+(f.newCount>0)-+(u.newCount>0)||f.latestSec-u.latestSec)}function Yw(e,s){var l,u,f,p,g;const a=new Map;for(const v of e){if(!v.authorizationId||!qc(v.timestamp,s.nowMs))continue;const y=a.get(v.authorizationId);(!y||v.timestamp>y.timestamp||v.timestamp===y.timestamp&&(((u=(l=v.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((p=(f=y.cumulativeState)==null?void 0:f.daily)==null?void 0:p.count)??0))&&a.set(v.authorizationId,v)}const o=[];for(const[v,y]of a){const w=rp(y,s.boundsOf(v)??y.limits,s.profileOf(y.profileId),"daily"),x={authorizationId:v,area:$r(y.profileId,s.catalog),system:pa(y.action,s.manifests),profileId:y.profileId,mandateTitle:(g=s.titles)==null?void 0:g[v]};w&&"limit"in w?o.push({...x,used:w.used,limit:w.limit,ratio:w.limit>0?w.used/w.limit:0}):o.push({...x,used:w?w.count:1,ratio:0})}return o.sort((v,y)=>y.ratio-v.ratio||v.area.localeCompare(y.area))}function fh(e){return e.ratio>=.8}function Hi(e,s,a){const o=new Date(e*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"});return qc(e,s)?`today ${l}`:`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`}const Jw={customers:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),n.jsx("path",{d:"M3 19c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5"}),n.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),n.jsx("path",{d:"M15.5 13.8c3 .1 5.5 2 5.5 5"})]}),email:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),n.jsx("path",{d:"m3.5 6 8.5 7 8.5-7"})]}),payments:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"1.5"}),n.jsx("path",{d:"M3 10h18M7 15h4"})]}),sales:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h9l4 4v14H6z"}),n.jsx("path",{d:"M15 3v4h4M9 12h7M9 16h5"})]}),calendar:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"5",width:"17",height:"15",rx:"1.5"}),n.jsx("path",{d:"M3.5 10h17M8 3v4M16 3v4"})]}),records:n.jsx("path",{d:"M3 7h7l2 2h9v10H3z"}),publishing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 10v4l11 4V6z"}),n.jsx("path",{d:"M15 9.5c2 .3 3 1.3 3 2.5s-1 2.2-3 2.5M7 14.5 8.5 19h2.5l-1.3-4"})]}),deployments:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 3v12M7 8l5-5 5 5"}),n.jsx("path",{d:"M4 15v5h16v-5"})]}),invoicing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h12v18l-2-1.3-2 1.3-2-1.3-2 1.3-2-1.3L6 21z"}),n.jsx("path",{d:"M9 8h6M9 12h6M9 16h3"})]}),purchasing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 4h2.5l2.2 11h10.6L20.5 7H6.4"}),n.jsx("circle",{cx:"9",cy:"19",r:"1.4"}),n.jsx("circle",{cx:"17",cy:"19",r:"1.4"})]}),reports:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 20V4M4 20h16"}),n.jsx("path",{d:"M8 16v-4M12 16V8M16 16v-6"})]}),setup:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 7h10M18 7h2M4 17h4M12 17h8"}),n.jsx("circle",{cx:"16",cy:"7",r:"2"}),n.jsx("circle",{cx:"10",cy:"17",r:"2"})]}),unknown:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),n.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"}),n.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function ga({icon:e,className:s}){return n.jsx("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Jw[e]})}function us({profileId:e,area:s,system:a,time:o,trailing:l,leading:u}){return n.jsxs("div",{className:"obj-line",children:[u,n.jsx(ga,{icon:Pr(e)}),n.jsx("b",{children:s}),a&&n.jsxs("span",{children:["· via ",a]}),o&&n.jsxs("span",{children:["· ",o]}),l&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"obj-line-sp"}),l]})]})}function da({title:e,area:s}){return Pw(e,s)?n.jsxs("div",{className:"obj-mandate-line","data-testid":"mandate-line",children:["Mandate: ",e]}):null}async function hh(e){const s=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}function Qw(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
67
|
-
`).split(`
|
|
68
|
-
`).map(l=>l.replace(/[ \t]+$/,"")).join(`
|
|
69
|
-
`).replace(/\n+$/,"")}function vc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":vc(l)).join(",")+"]";const s=e,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+vc(l))}return"{"+a.join(",")+"}"}async function op(e,s){if(e==="jcs"){if(typeof s=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await hh(vc(s))}`}if(typeof s!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await hh(Qw(s))}`}async function lp(e){if(e.toolArgs)return e.toolArgs;if(!e.content)return null;try{const{plaintext:s}=await z.decryptProposalContent(e.content),a=JSON.parse(s);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function Xw(e){if(!e.content)return[];const s=new Set([...e.createdBy?[e.createdBy]:[],...e.pendingApprovers??[]]),a=new Set(Object.keys(e.content.keys));return Array.from(s).filter(o=>!a.has(o))}function cp(e){return!e.loading&&e.readable}function up(e,s){const a=new Set;if(e.content)for(const o of Object.keys(e.content.keys))a.add(o);else{e.createdBy&&a.add(e.createdBy);for(const o of e.pendingApprovers??[])a.add(o)}return s&&a.add(s),Array.from(a)}async function ca(e){const s=await lp(e);if(s)return op("jcs",s)}function Zw(e){var o;const[s,a]=h.useState((e==null?void 0:e.note)??null);return h.useEffect(()=>{let l=!0;if(e!=null&&e.note){a(e.note);return}if(!(e!=null&&e.noteEncrypted)){a(null);return}return a(null),z.decryptProposalContent(e.noteEncrypted).then(({plaintext:u})=>{l&&a(u)}).catch(()=>{l&&a(null)}),()=>{l=!1}},[e==null?void 0:e.note,(o=e==null?void 0:e.noteEncrypted)==null?void 0:o.ciphertext]),s}const ej={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function io(e){var o;const[s,a]=h.useState(ej);return h.useEffect(()=>{let l=!0;if(e.toolArgs){a({toolArgs:e.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!e.content){a({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return a({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const u=await lp(e);l&&a({toolArgs:u,loading:!1,sealed:!0,undecryptable:u===null})})(),()=>{l=!1}},[(o=e.content)==null?void 0:o.ciphertext,e.toolArgs]),s}const mh=140,ph=60,tj=/\{([^{}]+)\}/g;function dp(e,s){var u,f;const{integrationId:a,toolName:o}=Wn(e),l=s==null?void 0:s.find(p=>p.id===a);return((f=(u=l==null?void 0:l.toolGating)==null?void 0:u.overrides)==null?void 0:f[o])??void 0}function fp(e,s){let a=e;for(const o of s.split(".")){if(a===null||typeof a!="object")return;a=a[o]}return a}function gh(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0}function nj(e,s,a,o){if(s==="money"){const u=typeof e=="number"?e:Number(e);if(!Number.isFinite(u))return String(e);if(a&&/^[A-Za-z]{3}$/.test(a))try{return new Intl.NumberFormat(o,{style:"currency",currency:a.toUpperCase()}).format(u)}catch{}return new Intl.NumberFormat(o,{maximumFractionDigits:2}).format(u)}if(s==="percent")return`${e}%`;if(s==="date"){const u=new Date(String(e));return Number.isNaN(u.getTime())?String(e):u.toLocaleDateString(o,{day:"numeric",month:"short"})}if(Array.isArray(e)){const u=e.map(f=>typeof f=="object"&&f!==null?JSON.stringify(f):String(f));return u.length>2?`${u.slice(0,2).join(", ")} +${u.length-2}`:u.join(", ")}const l=typeof e=="object"?JSON.stringify(e):String(e);return s==="short"&&l.length>ph?`${l.slice(0,ph-1).trimEnd()}…`:l}function yh(e,s,a,o){let l=!1;const u=e.replace(tj,(f,p)=>{const[g,v]=p.split("|").map(w=>w.trim()),y=g.split(",").map(w=>fp(s,w.trim())).find(gh);return gh(y)?nj(y,v,a,o):(l=!0,"")});return l?null:u}function hp(e,s,a={}){const o=fp(s,a.currencyField??"currency"),l=typeof o=="string"?o:void 0,u=e.replace(/\[([^[\]]*)\]/g,(g,v)=>yh(v,s,l,a.locale)??""),f=yh(u,s,l,a.locale);if(f===null)return null;const p=f.replace(/\s+/g," ").trim();return p.length>mh?`${p.slice(0,mh-1).trimEnd()}…`:p}function mp(e,s,a,o){var f;const l=Ht(Wn(e).toolName),u=dp(e,a);return!(u!=null&&u.summary)||!s?l:hp(u.summary,s,{currencyField:(f=u.display)==null?void 0:f.currencyField,locale:o})??l}function rj(e,s,a,o){var u;const l=dp(e,a);return!(l!=null&&l.summary)||!s?null:hp(l.summary,s,{currencyField:(u=l.display)==null?void 0:u.currencyField,locale:o})}function pp({proposal:e,manifests:s}){const a=io(e);return n.jsx(n.Fragment,{children:mp(e.tool,a.toolArgs,s)})}function nc({variant:e="base",style:s,className:a,...o}){const l=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return n.jsx("span",{className:`${l}${a?` ${a}`:""}`,style:s,role:"status","aria-busy":"true","aria-label":o["aria-label"]??"Loading"})}const os=5;function sj({auths:e,activeCount:s,waiting:a,waitingReady:o}){const[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState([]),[y,w]=h.useState({}),[x,b]=h.useState({}),N=h.useCallback(()=>{z.getMyReceiptsPage({limit:200}).then(_=>u(_.receipts)).catch(()=>u(_=>_??[])),z.getLastSeenTicketsAt().then(p).catch(()=>p(Number.POSITIVE_INFINITY))},[]);Ot(N,3e5),Oe("ticket-recorded",N),h.useEffect(()=>{z.getLabelManifests().then(v).catch(()=>{}),z.getLocalAuthorizations().then(({authorizations:_})=>w(_)).catch(()=>{})},[]);const S=Lr(),k=h.useMemo(()=>{const _={};for(const U of e)U.authorization_id&&U.title&&(_[U.authorization_id]=U.title);return _},[e]),E=Date.now(),T=h.useMemo(()=>{const _=Date.now();return(l??[]).filter(U=>qc(U.timestamp,_))},[l]);h.useEffect(()=>{const _=[...new Set(T.map(U=>U.profileId))].filter(U=>!(U in x));_.length!==0&&Promise.all(_.map(U=>Kc(U).then(Z=>[U,Z]).catch(()=>[U,null]))).then(U=>b(Z=>({...Z,...Object.fromEntries(U)})))},[T,x]);const P=h.useMemo(()=>qw(T,{catalog:S,manifests:g,titles:k,lastSeenMs:f??Number.POSITIVE_INFINITY}),[T,S,g,k,f]),I=T.filter(_=>yc(_,"approved")).length,B=h.useMemo(()=>Yw(T,{nowMs:Date.now(),catalog:S,manifests:g,titles:k,boundsOf:_=>{var U;return(U=y[_])==null?void 0:U.bounds},profileOf:_=>x[_]}),[T,S,g,k,y,x]),O=P.filter(_=>_.newCount>0).length,K=[...a].sort((_,U)=>_.createdAt-U.createdAt);return n.jsxs("div",{className:"core-cols","data-testid":"core-cols",children:[n.jsxs("section",{"aria-label":"Waiting for you","data-testid":"col-waiting",children:[n.jsxs("div",{className:"core-col-h is-main",children:[n.jsx("h2",{children:"Waiting for you"}),a.length>0&&n.jsx("span",{className:"pill-count",children:a.length})]}),o?K.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing waits for your decision."}):K.slice(0,os).map(_=>{const U=ap(_.expiresAt,E);return n.jsxs(gt,{to:`/approvals?open=${encodeURIComponent(_.id)}`,className:"appr-item appr-item-link","data-testid":"dash-approval",children:[n.jsxs("div",{className:"appr-item-main",children:[n.jsx(us,{profileId:_.profileId,area:$r(_.profileId,S),system:pa(_.tool,g),time:sp(_.createdAt,E)}),n.jsx("div",{className:"appr-item-sum",children:n.jsx(pp,{proposal:_,manifests:g})}),n.jsx(da,{title:_.authorizationId?k[_.authorizationId]:void 0,area:$r(_.profileId,S)}),U&&n.jsx("div",{className:"obj-due",children:U})]}),n.jsx("span",{className:"appr-item-chev","aria-hidden":"true",children:"›"})]},_.id)}):n.jsx(nc,{variant:"line"}),K.length>0&&n.jsx(gt,{to:"/approvals",className:"col-btn",children:"All approvals ›"})]}),n.jsxs("section",{"aria-label":"Done automatically","data-testid":"col-automatic",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Done automatically"}),O>0&&n.jsxs("span",{className:"meta",children:[P.reduce((_,U)=>_+U.newCount,0)," new"]})]}),l===null?n.jsx(nc,{variant:"line"}):P.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing was done automatically today."}):P.slice(0,os).map(_=>n.jsxs("details",{className:`auto-grp${_.newCount>0?"":" is-seen"}`,"data-testid":"auto-group",children:[n.jsxs("summary",{children:[n.jsx("span",{className:`seen-dot${_.newCount>0?" is-new":""}`,"aria-label":_.newCount>0?"new since your last visit":"seen"}),n.jsxs("span",{className:"auto-grp-txt",children:[n.jsx(us,{profileId:_.profileId,area:_.area,system:_.system}),n.jsxs("b",{children:[_.count," × ",_.label]}),n.jsx(da,{title:_.mandateTitle,area:_.area}),n.jsxs("span",{className:"meta",children:[_.newCount>0?`${_.newCount} new`:"seen"," · latest ",Hi(_.latestSec,E)]})]})]}),n.jsxs("div",{className:"auto-grp-list",children:[_.tickets.slice(0,os).map(U=>n.jsxs("div",{className:"auto-grp-row",children:[n.jsx("span",{className:`seen-dot${Wi(U,f??Number.POSITIVE_INFINITY)?" is-new":""}`}),ao(U,g),n.jsxs("span",{className:"t",children:[Hi(U.timestamp,E)," · ",ip(U.id)]})]},U.id)),_.tickets.length>os&&n.jsxs("div",{className:"auto-grp-row meta",children:["+ ",_.tickets.length-os," more in Tickets"]})]})]},_.key)),P.length>0&&n.jsx(gt,{to:"/tickets?filter=automatic",className:"col-btn","data-testid":"btn-automatic-tickets",children:"Automatic tickets ›"}),I>0&&n.jsxs("div",{className:"core-quiet-line",children:[I," approved today — ",n.jsx(gt,{to:"/tickets?filter=approved",children:"see approved tickets"})]})]}),n.jsxs("section",{"aria-label":"Mandates at work today","data-testid":"col-mandates",children:[n.jsx("div",{className:"core-col-h",children:n.jsx("h2",{children:"Mandates at work today"})}),l===null?n.jsx(nc,{variant:"line"}):B.length===0?n.jsx("p",{className:"core-col-empty",children:"No mandate has acted today."}):B.slice(0,os).map(_=>n.jsxs("div",{className:"mandate-obj","data-testid":"mandate-at-work",children:[n.jsx(us,{profileId:_.profileId,area:_.area,system:_.system}),_.mandateTitle&&_.mandateTitle.trim().toLowerCase()!==_.area.trim().toLowerCase()&&n.jsx("div",{className:"mandate-obj-title",children:_.mandateTitle}),n.jsx("div",{className:`usage${fh(_)?" is-near":""}`,children:_.limit!==void 0?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"usage-bar",children:n.jsx("i",{style:{width:`${Math.min(100,Math.round(_.ratio*100))}%`}})}),n.jsxs("span",{children:[fh(_)?n.jsxs("b",{children:[_.used," of ",_.limit]}):`${_.used} of ${_.limit}`," today"]})]}):n.jsxs("span",{children:[_.used," ",_.used===1?"action":"actions"," today"]})})]},_.authorizationId)),l!==null&&s>B.length&&n.jsxs("div",{className:"meta",style:{marginTop:"var(--space-2)",fontSize:"var(--text-caption)"},children:[s-B.length," more mandate",s-B.length===1?"":"s"," in force — no actions today"]}),B.length>0&&n.jsx(gt,{to:"/mandates",className:"col-btn",children:"All mandates ›"})]})]})}function aj(){const[e,s]=h.useState(null),[a,o]=h.useState(Number.POSITIVE_INFINITY),l=h.useCallback(()=>{Promise.all([z.getReport().then(p=>p.report).catch(()=>null),z.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]).then(([p,g])=>{s(p),o(g)})},[]);if(Ot(l,3e5),Oe("report-written",l),!e||!Mm(e,a))return null;const{verified:u,unchecked:f}=B0(e);return n.jsxs("div",{className:"report-line","data-testid":"report-line",children:[n.jsx("span",{className:"nav-new",style:{marginLeft:0},children:"New"}),n.jsxs("span",{className:"report-line-text",children:[n.jsx("b",{children:O0(e.renderedHtml)})," — ",n.jsx("span",{title:Di(e.coverage).title,children:Di(e.coverage).text})," · written ",Om(e.savedAt,Date.now()),f===0?n.jsxs(n.Fragment,{children:[" · all ",u," value",u===1?"":"s"," verified"]}):n.jsxs(n.Fragment,{children:[" · ",u," value",u===1?"":"s"," verified · ",n.jsxs("b",{children:["✕ ",f," could not be checked"]})]})]}),n.jsx(gt,{to:"/reports",className:"col-btn",children:"Open report ›"})]})}function ij(){const[e,s]=h.useState([]);return Ot(async()=>{try{const{skipped:o}=await z.getSkippedCommitments();s(o)}catch{}},3e4),e.length===0?null:n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px dashed var(--text-primary)"},children:[n.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",e.length,")"]}),n.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."}),n.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:e.map(o=>n.jsxs("li",{style:{marginBottom:"0.35rem"},children:[n.jsx("code",{children:o.tool})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",o.id,")"]})]},o.id))})]})}const oj=1800;function na(e){return e.replace(/@.*$/,"").split("/").pop()??e}function lj(){const{domain:e}=wt(),[s,a]=h.useState([]),[o,l]=h.useState([]),[u,f]=h.useState([]),[p,g]=h.useState(!0),[v,y]=h.useState(!1),[w,x]=h.useState([]),[b,N]=h.useState(!1),[S,k]=h.useState(!1),[E,T]=h.useState(null),[P,I]=h.useState(!1),{entries:B,activeSessions:O,loading:K}=Uc(),_=Ew(),U=!K,{simulation:Z}=Ym(),V=Z===!0,M=Iw(),re=h.useCallback(()=>{z.getMyAttestations().then(te=>{a(te),y(!0)}).catch(()=>y(!0)),z.getArchivedMandates().then(x).catch(()=>x([])),z.getMyProposals(e).then(te=>{l(te),N(!0)}).catch(()=>N(!0)),z.getProposalsForApprover().then(te=>f(te)).catch(()=>f([])),z.getCredential("ai-config").then(te=>{g(te.configured),k(!0)}).catch(()=>k(!0)),z.getAgentContact().then(te=>{T(te.contact),I(!0)}).catch(()=>I(!0))},[e]);Oe("attestation-changed",re),Oe("proposal-added",re),Oe("proposal-resolved",re),Oe("proposal-approved",re),Oe("proposal-rejected",re),Oe("execution-failed",re),Ot(re,3e5,e);const de=v&&b&&S&&U&&P&&Z!==null,X=$m(s,{archivedSet:new Set(w)}),xe=X.active,Ne=X.expired,ee=xe.some(te=>na(te.profile_id)==="delegation"),Q=xe.filter(te=>na(te.profile_id)!=="delegation").length,q=o.filter(te=>na(te.profileId)==="delegation").length,A=qm({hasContact:E!==null,hasDelegationMandate:ee,otherMandateCount:Q,delegationProposalCount:q,managed:M,simulationOn:V}),$=V&&A.visible,ae=xe.filter(te=>te.remaining_seconds!==null&&te.remaining_seconds<=oj),ne=o.filter(Um),ve=B.filter(te=>te.state==="running"),Se=B.filter(te=>te.state==="starting"),Y=h0(B),ce=[...ne,...u.filter(te=>!ne.some(ze=>ze.id===te.id))],ie=[];for(const te of ae){const ze=Math.ceil((te.remaining_seconds??0)/60);ie.push({label:"Expiring soon",detail:`${te.title??na(te.profile_id)} — ${ze} min remaining`,to:"/mandates",color:"var(--text-primary)"})}for(const te of Ne)ie.push({label:"Expired",detail:te.title??na(te.profile_id),to:"/mandates",color:"var(--text-primary)"});ie.push(...f0(B,V));for(const te of Se)ie.push({label:"Integration starting",detail:`${te.manifest.name} is coming up…`,to:"/integrations",color:"var(--text-primary)"});for(const te of B)te.authStatus==="failed"&&te.state!=="not-running"&&te.state!=="error"&&te.state!=="paused"&&ie.push({label:"Reconnect needed",detail:`${te.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--text-primary)"});return p||ie.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Dashboard"})}),de&&_&&($?n.jsx(Cw,{contact:E,hasDelegationMandate:ee,otherMandateCount:Q,delegationProposalCount:q,managed:M,simulationOn:V,mcpEndpoint:_}):!V&&n.jsx(kw,{aiConfigured:p,hasRunningIntegration:ve.length>0,hasActiveAuth:xe.length>0,hasAgentConnected:O>0,mcpEndpoint:_})),!$&&n.jsxs(n.Fragment,{children:[n.jsx(sj,{auths:s,activeCount:xe.length,waiting:ce,waitingReady:b}),n.jsx(aj,{}),ie.length>0&&n.jsxs("section",{className:"card attention attention-quiet","aria-label":"Setup — needs attention",children:[n.jsxs("div",{className:"card-header",children:[n.jsx("h2",{className:"card-title",children:"Setup — needs attention"}),n.jsx("span",{className:"rb-count",children:ie.length})]}),n.jsx("div",{className:"attention-rows",children:ie.map((te,ze)=>n.jsxs(gt,{to:te.to,className:"attention-row",children:[n.jsx("span",{className:"attention-dot",style:{background:te.color},"aria-hidden":"true"}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:te.label}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:te.detail})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},ze))})]})]}),Y&&n.jsxs("div",{className:"sim-paused-summary",role:"status",children:[n.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),n.jsxs("span",{children:[n.jsxs("b",{children:[Y.count," real system",Y.count===1?"":"s"," ",Y.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",Y.namesText,"."]})]}),n.jsx(ij,{}),n.jsx(E0,{})]})}const cj=["Scope & Limits","Intent","Sign"];function gp({currentStep:e,onStepClick:s}){const a=Sn();return n.jsxs("div",{className:"wizard-progress",children:[n.jsx("ol",{className:"wizard-steps",children:cj.map((o,l)=>{const u=l+2,f=u<e,p=u===e,g=u-1<e,v=f&&!!s;return n.jsxs("li",{className:`wizard-step${g?" reached":""}`,"aria-current":p?"step":void 0,children:[n.jsx("button",{type:"button",className:`step-circle${f?" completed":""}${p?" current":""}`,onClick:v?()=>s(u):void 0,disabled:!v,"aria-label":`${o}${f?" (done)":p?" (current)":""}`,children:f?"✓":l+1}),n.jsx("span",{className:`step-label-text${p?" current":f?" completed":""}`,children:o})]},u)})}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>a("/mandates?new=1"),children:"Cancel"})]})}function uj({profileId:e,bounds:s,groupName:a,domain:o,onSwitch:l}){return n.jsxs("div",{className:"context-strip",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"context-strip-label",children:"Team:"}),n.jsxs("span",{children:[n.jsx("strong",{children:a}),o?` / ${o}`:""]})]}),e&&n.jsxs("span",{children:[n.jsx("strong",{children:"Profile:"})," ",Bt(e)]}),s&&n.jsxs("span",{children:[n.jsx("strong",{children:"Bounds:"})," ",s]}),l&&n.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:l,children:"Switch"})]})}function dj({integrationId:e,field:s,value:a,onChange:o,disabled:l,onLabels:u}){const[f,p]=h.useState(null),[g,v]=h.useState(null),[y,w]=h.useState(!0);h.useEffect(()=>{let N=!1;return z.discoverScopeField(e,s).then(S=>{var k;N||(p(S.options),w(!1),(k=S.options)!=null&&k.length&&(u==null||u(Object.fromEntries(S.options.map(E=>[E.value,E.label])))))}).catch(S=>{N||(v(S instanceof Error?S.message:String(S)),w(!1))}),()=>{N=!0}},[e,s]);const x=new Set(a.split(",").map(N=>N.trim()).filter(Boolean)),b=N=>{const S=new Set(x);S.has(N)?S.delete(N):S.add(N),o(Array.from(S).join(","))};return y?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):g||!f?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"msg-attention",style:{fontSize:"0.8rem",marginBottom:"0.5rem"},children:["Couldn't fetch options (",g??"no response","). Enter values manually, separated by commas."]}),n.jsx("input",{className:"form-input",type:"text",value:a,onChange:N=>o(N.target.value),disabled:l})]}):f.length===0?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:f.map(N=>{const S=N.extras??{},k=typeof S.access=="string"?S.access:void 0,E=k==="reader",T=S.primary===!0;return n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:E?"var(--text-tertiary)":"var(--text-primary)",cursor:l||E?"not-allowed":"pointer"},title:E?"Read-only — you can authorize list/read but not writes":void 0,children:[n.jsx("input",{type:"checkbox",checked:x.has(String(N.value)),onChange:()=>b(String(N.value)),disabled:l||E}),n.jsx("span",{children:N.label||N.value}),T&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),k&&n.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",k]})]},N.value)})})}function Yc(e){if(e.type!=="number")return 0;const s=e.boundType,a=e.unit;return(s==null?void 0:s.kind)==="per_transaction"&&a==="count"?1:0}function vh(e,s){if(s!==void 0)return String(s);const a=e.default;return typeof a=="string"||typeof a=="number"&&Number.isFinite(a)?String(a):Yc(e)===1?"1":""}function xc(e){const s=e.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function xh(e,s){const a=Yc(e),o=xc(e),l=s===""?a:Math.max(a,Number(s));return o!==void 0?Math.min(o,l):l}function fj(e,s){var o;const a=(o=e.capKinds)==null?void 0:o[s];return a||(e.approvers.length>0?"approval":"hard")}function Jc(e,s,a){var o;return e.approvers.length===0||(s==null?void 0:s.enforcedBy)==="gatekeeper"||((o=s==null?void 0:s.boundType)==null?void 0:o.kind)==="enum"?"hard":fj(e,a)}function yp(e,s,a){const o=e.indexOf(s),l=e.indexOf(a);return o===-1||l===-1?!1:l<o}function Vi(e,s){var a;return((a=e.caps)==null?void 0:a[s])!==void 0}function hj(e,s,a){const o=Object.entries(s.caps??{}).filter(([u])=>Jc(s,a[u],u)==="approval");if(o.length===0)return null;const l=u=>{var f;return((f=a[u])==null?void 0:f.displayName)??u};for(const[u,f]of o){const p=a[u],g=p==null?void 0:p.boundType,v=(g==null?void 0:g.kind)==="per_transaction"||(g==null?void 0:g.kind)==="cumulative_sum"?g.of:void 0,y=v?e[v]:void 0;if(typeof f=="number"&&typeof y=="number"&&y>f)return{field:u,fieldLabel:l(u),cap:f,value:y}}if(o.length===1){const[u,f]=o[0];return{field:u,fieldLabel:l(u),cap:f}}return null}function mj(e){return(e==null?void 0:e.valuesFrom)==="profiles"}const vp=e=>(e.replace(/@.*$/,"").split("/").pop()??e).toLowerCase(),wh=e=>e.split("@")[1]??"";function pj(e){const s=new Map;for(const{id:a}of e){const o=vp(a),l=s.get(o);(!l||wh(a).localeCompare(wh(l),void 0,{numeric:!0})>0)&&s.set(o,a)}return[...s.values()]}function gj(e,s,a){var l;const o=((l=e.constraint)==null?void 0:l.requiredFor)??[];return s.filter(u=>a(u.id)).filter(u=>{var f;return!(((f=u.boundsSchema)==null?void 0:f.actionTypes)??[]).some(p=>o.includes(p))}).map(u=>vp(u.id)).sort((u,f)=>u.localeCompare(f))}function yj(e,s){var g;const[a,o]=h.useState({}),l=Object.entries(((g=e.scopeSchema)==null?void 0:g.fields)??{}).filter(([,v])=>mj(v)),u=l.length>0,f=s==null?void 0:s.groupId,p=!!(s!=null&&s.isPersonal);return h.useEffect(()=>{if(!u)return;let v=!0;return(async()=>{const y=pj(await Xm()),w=(await Promise.all(y.map(N=>Kc(N)))).filter(N=>!!N);let x;if(p)x=()=>!0;else if(f){const N=await Promise.all(w.map(k=>z.getTeamProfileConfig(f,k.id).catch(()=>null))),S=new Set(w.filter((k,E)=>N[E]).map(k=>k.id));x=k=>S.has(k)}else x=()=>!1;const b={};for(const[N,S]of l)b[N]=gj(S,w,x);v&&o(b)})(),()=>{v=!1}},[e.id,u,f,p]),a}function vj(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Qc(e,s){return s.displayName?s.displayName:e.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function xj(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function wj(e){var a;const s=e;return!!(s.enum&&((a=s.constraint)!=null&&a.enforceable.includes("subset")))}function jj(e,s){if(!e)return;const a=(s??"").split(",").map(o=>o.trim()).filter(Boolean);return[...e,...a.filter(o=>!e.includes(o))]}function jh(e,s){const a=e.trim();return a?s==="email"?a.includes("@")&&a.indexOf(".",a.indexOf("@"))>-1:s==="domain"?a.includes(".")&&!a.includes("@"):!0:!1}function Sj(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function bj(e){return e?e==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:e==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:e==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:e==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:e.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function kj(e,s){if(!e||!s)return"";const a=Number(e);if(!Number.isFinite(a)||a<=0)return"";if(s==="minutes"&&a>=60){const o=Math.floor(a/60),l=a%60;return l===0?`${o} hour${o!==1?"s":""}`:`${o}h ${l}m`}if(s==="hours"&&a>=24&&a%24===0){const o=a/24;return`${o} day${o!==1?"s":""}`}if(s==="days"){if(a>=30&&a%30===0)return`${a/30} month${a/30!==1?"s":""}`;if(a>=7&&a%7===0)return`${a/7} week${a/7!==1?"s":""}`}return""}function Nj({id:e,value:s,onChange:a,disabled:o,placeholder:l,unit:u,min:f=0,max:p}){const g=Sj(u),v=bj(u).filter(S=>p===void 0||S.value<=p),y=so(u),w=kj(s,u),x=s===""?null:Number(s),b=()=>{const S=s===""?0:Number(s),k=S%g,E=k===0?S+g:S+(g-k);a(String(p!==void 0?Math.min(p,E):E))},N=()=>{const S=s===""?0:Number(s);if(S<=f)return;const k=S%g,E=k===0?S-g:S-k;a(String(Math.max(f,E)))};return n.jsxs("div",{className:"bounded-input",children:[n.jsxs("div",{className:"bounded-input-field",children:[n.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:N,disabled:o||s===""||Number(s)<=f,"aria-label":"Decrease",children:"−"}),n.jsx("input",{id:e,className:"stepper-input",type:"number",min:f,max:p,step:g,value:s,placeholder:l??String(f),onChange:S=>{const k=S.target.value;a(p!==void 0&&k!==""&&Number(k)>p?String(p):k)},onFocus:S=>S.target.select(),disabled:o}),n.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:b,disabled:o||p!==void 0&&s!==""&&Number(s)>=p,"aria-label":"Increase",children:"+"}),y&&n.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:y})]}),v.length>0&&!o&&n.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:v.map(S=>n.jsx("button",{type:"button",className:`preset-chip${x===S.value?" preset-chip-selected":""}`,onClick:()=>a(String(S.value)),children:S.label},S.value))}),w&&n.jsxs("div",{className:"bounded-input-echo",children:["≈ ",w]})]})}function Sh({htmlFor:e,label:s,description:a}){const[o,l]=h.useState(!1);return n.jsxs("div",{className:"field-label-with-tip",children:[n.jsx("label",{className:"form-label",htmlFor:e,children:s}),a&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${s}" mean?`,"aria-expanded":o,onClick:()=>l(u=>!u),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onBlur:()=>l(!1),children:"i"}),o&&n.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:a})]})]})}function Cj({id:e,value:s,onChange:a,disabled:o,format:l,placeholder:u}){const[f,p]=h.useState(""),[g,v]=h.useState(!1),y=h.useRef(null),w=s?s.split(",").map(E=>E.trim()).filter(Boolean):[],x=E=>{const T=E.trim();if(!T)return;if(!jh(T,l)){v(!0);return}v(!1);const P=w.includes(T)?w:[...w,T];a(P.join(",")),p("")},b=E=>{const T=w.filter((P,I)=>I!==E);a(T.join(","))},N=E=>{E.key==="Enter"||E.key===","||E.key==="Tab"?f.trim()&&(E.preventDefault(),x(f)):E.key==="Backspace"&&!f&&w.length>0&&b(w.length-1)},S=E=>{const T=E.clipboardData.getData("text");if(T.includes(",")){E.preventDefault();const I=T.split(",").map(O=>O.trim()).filter(Boolean).filter(O=>jh(O,l)),B=[...new Set([...w,...I])];a(B.join(",")),p(""),v(!1)}},k=l==="email"?"Type email and press Enter...":"Type domain and press Enter...";return n.jsxs("div",{className:`tag-input${g?" tag-input-invalid":""}`,onClick:()=>{var E;return(E=y.current)==null?void 0:E.focus()},children:[w.map((E,T)=>n.jsxs("span",{className:"tag-pill",children:[E,!o&&n.jsx("button",{type:"button",className:"tag-remove",onClick:P=>{P.stopPropagation(),b(T)},"aria-label":`Remove ${E}`,children:"×"})]},E)),!o&&n.jsx("input",{ref:y,id:e,className:"tag-input-field",type:"text",value:f,onChange:E=>{p(E.target.value),v(!1)},onKeyDown:N,onPaste:S,onBlur:()=>{f.trim()&&x(f)},placeholder:w.length===0?u??k:""})]})}function Ej({id:e,options:s,value:a,onChange:o,disabled:l}){const u=a?a.split(",").map(p=>p.trim()).filter(Boolean):[],f=p=>{const g=u.includes(p)?u.filter(v=>v!==p):[...u,p];o(g.join(","))};return n.jsx("div",{className:"checkbox-group",id:e,children:s.map(p=>n.jsxs("label",{className:`checkbox-pill${u.includes(p)?" checkbox-pill-selected":""}`,children:[n.jsx("input",{type:"checkbox",checked:u.includes(p),onChange:()=>f(p),disabled:l}),n.jsx("span",{children:p})]},p))})}function bh({fieldKey:e,fieldDef:s,value:a,onChange:o,prefix:l,readOnly:u,twoColumn:f,discoveryIntegrationId:p,onLabels:g,capMax:v,enumAllowedFrom:y,options:w}){const x=Qc(e,s),b=`${l}-field-${e}`,N=n.jsx(n.Fragment,{children:wj(s)||w?n.jsx(Ej,{id:b,options:w??s.enum,value:a,onChange:S=>o(e,S),disabled:u}):(()=>{const S=s.boundType;return(S==null?void 0:S.kind)==="enum"&&Array.isArray(S.values)})()?n.jsxs("select",{id:b,className:"form-select",value:a,onChange:S=>o(e,S.target.value),disabled:u||y!==void 0&&s.boundType.values.length-y<=1,children:[n.jsx("option",{value:"",children:"Select..."}),s.boundType.values.map((S,k)=>n.jsx("option",{value:S,disabled:y!==void 0&&k<y,children:S},S))]}):s.enum?n.jsxs("select",{id:b,className:"form-select",value:a,onChange:S=>o(e,S.target.value),disabled:u,children:[n.jsx("option",{value:"",children:"Select..."}),s.enum.map(S=>n.jsx("option",{value:S,children:S},S))]}):s.type==="number"?n.jsx(Nj,{id:b,value:a,onChange:S=>o(e,S),disabled:u,unit:s.unit,min:Yc(s),max:v!==void 0?Math.min(v,xc(s)??v):xc(s)}):xj(s)?n.jsx(Cj,{id:b,value:a,onChange:S=>o(e,S),disabled:u,format:s.format}):p?n.jsx(dj,{integrationId:p,field:e,value:a,onChange:S=>o(e,S),disabled:u,onLabels:S=>g==null?void 0:g(e,S)}):n.jsx("input",{id:b,className:"form-input",type:"text",value:a,onChange:S=>o(e,S.target.value),disabled:u})});return f?n.jsxs("div",{className:"bounds-field-row",children:[n.jsx("div",{className:"bounds-field-label",children:n.jsx(Sh,{htmlFor:b,label:x,description:s.description})}),n.jsx("div",{className:"bounds-field-input",children:N})]},`${l}-${e}`):n.jsxs("div",{className:"form-group",children:[n.jsx(Sh,{htmlFor:b,label:x,description:s.description}),N]},`${l}-${e}`)}function Tj(e,s,a,o){if(!o||!Vi(o,e))return null;const l=o.caps[e],u=Jc(o,s,e);let f=!1;if(typeof l=="number"){const p=a===""?NaN:Number(a);f=!Number.isNaN(p)&&p>l}else if(typeof l=="string"&&a!==""){const p=s.boundType;f=(p==null?void 0:p.kind)==="enum"?yp(p.values??[],l,a):!1}return{kind:u,cap:l,violating:f}}function kh(e,s,a,o){if(!o||!Vi(o,e))return a;const l=Jc(o,s,e),u=o.caps[e];if(l!=="hard")return a;if(typeof u=="number"){const f=a===""?NaN:Number(a);return String(Number.isNaN(f)?u:Math.min(f,u))}if(typeof u=="string"){const f=s.boundType,p=(f==null?void 0:f.kind)==="enum"?f.values??[]:[];return a!==""&&yp(p,u,a)?u:a}return a}function Aj(e,s){if(typeof s!="string")return;const a=e.boundType;if((a==null?void 0:a.kind)!=="enum")return;const o=(a.values??[]).indexOf(s);return o===-1?void 0:o}function Ij(e,s){return so(s.unit)||Qc(e,s).toLowerCase()}function xp(e,s){if(s&&s.length>0)return s.join(" or ");const a=(e==null?void 0:e.approvers)??[];return a.length>0?a.join(" or "):"your team's approvers"}function Rj(e,s,a,o,l){var v;const u=s.enforcedBy==="gatekeeper",f=((v=s.boundType)==null?void 0:v.kind)==="enum";if(a.kind==="hard")return f?n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Disabled by your team's policy — ",Qc(e,s).toLowerCase()," is capped at"," ",String(a.cap)," for this profile."]}):n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Team limit ",String(a.cap),u?" — read limits are always hard, no approval path exists for this cap.":""]});const p=Ij(e,s),g=xp(o,l);return n.jsxs("span",{className:"cap-note soft","data-testid":`cap-note-${e}`,children:["Every ",p," above ",String(a.cap)," goes to ",g," for approval."]})}function Pj({profile:e,onConfirm:s,onCancel:a,readOnly:o,initialBounds:l,initialContext:u,initialFrame:f,profileConfig:p,approverNames:g,adminName:v,workspace:y}){var Se;const w=e.boundsSchema,x=yj(e,y),b=e.scopeSchema,N=Y=>!!p&&Vi(p,Y),S=w?Object.entries(w.fields).filter(([Y,ce])=>!(Y==="profile"||Y==="path"||ce.enforced===!1||ce.enforcedBy==="gatekeeper"&&!N(Y))):[],k=w?Object.entries(w.fields).filter(([Y,ce])=>ce.enforcedBy==="gatekeeper"&&!N(Y)).filter(([,Y])=>Y.enforced!==!1).map(([Y,ce])=>ce.displayName??Y):[],E=b&&b.keyOrder.length>0?Object.entries(b.fields):[],T=l??f??{},P=u??{},I={};for(const[Y,ce]of S)I[Y]=kh(Y,ce,vh(ce,T[Y]),p);const B={};for(const[Y]of E)B[Y]=P[Y]!==void 0?String(P[Y]):"";const[O,K]=h.useState(I),[_,U]=h.useState(B),[Z,V]=h.useState({}),M=h.useRef(new Set);h.useEffect(()=>{K(Y=>{let ce=!1;const ie={...Y};for(const[te,ze]of S){if(M.current.has(te))continue;const Ue=Y[te]!==void 0?Y[te]:vh(ze,T[te]),fe=kh(te,ze,Ue,p);ie[te]!==fe&&(ie[te]=fe,ce=!0)}return ce?ie:Y})},[p]);const[re,de]=h.useState(null);h.useEffect(()=>{const Y=vj(e.id);z.getIntegrationManifests().then(({manifests:ce})=>{const ie=ce.find(te=>te.profile===Y&&te.contextDiscovery&&Object.keys(te.contextDiscovery).length>0);de(ie??null)}).catch(()=>de(null))},[e.id]);const X={};for(const[Y,ce]of S)X[Y]=Tj(Y,ce,O[Y]??"",p);const xe=Object.entries(X).filter(([,Y])=>(Y==null?void 0:Y.kind)==="hard"&&Y.violating).map(([Y])=>Y),Ne=!!p&&(((Se=p.approvers)==null?void 0:Se.length)??0)>0&&S.every(([Y])=>!Vi(p,Y)),ee=(Y,ce)=>{M.current.add(Y),K(ie=>({...ie,[Y]:ce}))},Q=(Y,ce)=>{U(ie=>({...ie,[Y]:ce}))},q=()=>{const Y={profile:e.id};for(const[ie,te]of S)te.type==="number"?Y[ie]=xh(te,O[ie]):Y[ie]=O[ie];const ce={};for(const[ie,te]of E)te.type==="number"?ce[ie]=_[ie]===""?0:Number(_[ie]):ce[ie]=_[ie];return[Y,ce]},A=()=>{const[Y,ce]=q();s(Y,ce,Z)},$=()=>{var te;const Y={...O};for(const ze of xe){const Ue=(te=X[ze])==null?void 0:te.cap;Ue!==void 0&&(Y[ze]=String(Ue))}K(Y);const ce={profile:e.id};for(const[ze,Ue]of S)Ue.type==="number"?ce[ze]=xh(Ue,Y[ze]??""):ce[ze]=Y[ze]??"";const ie={};for(const[ze,Ue]of E)Ue.type==="number"?ie[ze]=_[ze]===""?0:Number(_[ze]):ie[ze]=_[ze];s(ce,ie,Z)},ae=()=>{if(!Ne)return null;const Y=xp(p,g);return n.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:[n.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",Y]}),n.jsxs("div",{children:["No caps are set on this profile, so ",Y," 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."]})]})},ne=()=>{if(xe.length===0)return null;const Y=v??"the team admin";return n.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"2px solid var(--border-strong)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[n.jsx("div",{className:"msg-error",style:{marginBottom:"0.25rem"},children:"Hard team ceiling."}),n.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Lower the bound(s) above, or ask ",Y," to add an approver path above the cap."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:$,children:"Save below cap"}),a&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})},ve=xe.length>0;return n.jsxs("div",{children:[E.length>0&&n.jsxs("div",{className:"context-section",children:[n.jsxs("div",{className:"bounds-section-header",children:[n.jsx("span",{className:"bounds-section-icon",children:"🛡"}),n.jsxs("div",{children:[n.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),n.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),E.map(([Y,ce])=>{var te;const ie=!!((te=re==null?void 0:re.contextDiscovery)!=null&&te[Y]);return n.jsx(bh,{fieldKey:Y,fieldDef:ce,value:_[Y],onChange:Q,prefix:"context",readOnly:o,discoveryIntegrationId:ie?re.id:void 0,onLabels:(ze,Ue)=>V(fe=>({...fe,[ze]:Ue})),options:jj(x[Y],_[Y])},`context-${Y}`)})]}),S.length>0&&n.jsxs("div",{className:"bounds-section",children:[n.jsxs("div",{className:"bounds-section-header",children:[n.jsx("span",{className:"bounds-section-icon",children:"🔒"}),n.jsxs("div",{children:[n.jsx("div",{className:"bounds-section-title",children:"Limits"}),n.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),n.jsx("div",{className:"bounds-fields-grid",children:S.map(([Y,ce])=>{const ie=X[Y];return n.jsxs("div",{style:{display:"contents"},children:[n.jsx(bh,{fieldKey:Y,fieldDef:ce,value:O[Y],onChange:ee,prefix:"bounds",readOnly:o,twoColumn:!0,capMax:(ie==null?void 0:ie.kind)==="hard"&&typeof ie.cap=="number"?ie.cap:void 0,enumAllowedFrom:(ie==null?void 0:ie.kind)==="hard"?Aj(ce,ie.cap):void 0}),ie&&n.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:Rj(Y,ce,ie,p,g)})]},`bounds-${Y}`)})}),ae(),ne(),k.length>0&&n.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[k.join(", ")," ",k.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"," ",n.jsx(gt,{to:"/integrations",children:"Integrations"}),"."]})]}),n.jsx("button",{className:"btn btn-primary",onClick:A,disabled:ve,style:{marginTop:"0.5rem"},children:o?"Next: Gates":"Next: Problem Statement"})]})}function $j(e){var a;const s=e.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((a=s==null?void 0:s[1])==null?void 0:a.trim())??null}function _j(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Lj="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 Gi({target:e,currentText:s,onApply:a,greeting:o,placeholder:l,title:u}){const[f,p]=h.useState([{role:"assistant",content:o??Lj}]),[g,v]=h.useState(""),[y,w]=h.useState(!1),[x,b]=h.useState(null),N=h.useRef(null),S=h.useRef(null);h.useEffect(()=>{const T=N.current;if(!T)return;const P=f[f.length-1],I=S.current;!y&&(P==null?void 0:P.role)==="assistant"&&f.length>1&&I?T.scrollTop=I.offsetTop:T.scrollTop=T.scrollHeight},[f,y]);const k=async()=>{const T=g.trim();if(!T||y)return;const P=[...f,{role:"user",content:T}];p(P),v(""),b(null),w(!0);try{const I=await z.aiChat({target:e,currentText:s,messages:P.filter((B,O)=>!(O===0&&B.role==="assistant"))});I.success&&I.reply?p(B=>[...B,{role:"assistant",content:I.reply}]):b(I.error??"AI returned no reply")}catch(I){b(I instanceof Error?I.message:"Chat failed")}finally{w(!1)}},E=T=>{T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),k())};return n.jsxs("div",{className:"intent-chat",children:[n.jsx("h3",{className:"card-title",children:u??"AI Assistant"}),n.jsxs("div",{ref:N,className:"chat-messages",children:[f.map((T,P)=>{const I=T.role==="assistant"?$j(T.content):null,B=I?_j(T.content):T.content;return n.jsx("div",{className:`chat-msg ${T.role}`,ref:P===f.length-1?S:void 0,children:n.jsxs("div",{className:"chat-msg-body",children:[B&&n.jsx("div",{className:"chat-msg-prose",children:B}),I!==null&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{className:"chat-fenced-block",children:I}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>a(I),children:"Apply this draft"})]})]})},P)}),y&&n.jsx("div",{className:"chat-msg assistant",children:n.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),x&&n.jsx("div",{className:"error-message",children:x}),n.jsxs("div",{className:"chat-composer",children:[n.jsxs("div",{className:"chat-composer-pill",children:[n.jsx("textarea",{className:"chat-input",value:g,onChange:T=>v(T.target.value),onKeyDown:E,placeholder:l??"Ask for help articulating the intent…",rows:1,disabled:y}),n.jsx("button",{type:"button",className:"chat-send-btn",onClick:k,disabled:y||!g.trim(),"aria-label":"Send",children:"↑"})]}),n.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function wp({open:e,onClose:s,children:a,ariaLabel:o}){const l=h.useRef(null),u=h.useRef(null);return h.useEffect(()=>{var p;if(!e)return;u.current=document.activeElement,document.body.style.overflow="hidden";const f=g=>{g.key==="Escape"&&s()};return document.addEventListener("keydown",f),(p=l.current)==null||p.focus(),()=>{document.removeEventListener("keydown",f),document.body.style.overflow="",u.current instanceof HTMLElement&&u.current.focus()}},[e,s]),Kx.createPortal(n.jsxs(n.Fragment,{children:[n.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:s,"aria-hidden":"true"}),n.jsxs("aside",{ref:l,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":o,tabIndex:-1,children:[n.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),n.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:s,"aria-label":"Close",children:"×"}),a]})]}),document.body)}function zj(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fj(e,s,a){if(s.length===0)return[{text:e,label:e,matched:null}];const o=[],l=new Set;for(const g of s)if(!(!g.scope||g.scope==="all (unscoped)"))for(const v of[g.scope,...g.scope.split(",").map(y=>y.trim())]){const y=v.toLowerCase();v&&!l.has(y)&&(l.add(y),o.push(v))}o.sort((g,v)=>v.length-g.length);const u=g=>{const v=g.toLowerCase();return s.filter(y=>{var w,x;return((w=y.scope)==null?void 0:w.toLowerCase())===v||((x=y.scope)==null?void 0:x.split(",").map(b=>b.trim().toLowerCase()).includes(v))})},f=["\\[\\d+\\]",...o.map(zj)],p=new RegExp(`(${f.join("|")})`,"gi");return e.split(p).filter(g=>g!=="").map(g=>{const v=/^\[(\d+)\]$/.exec(g);if(v){const y=s[Number(v[1])-1];if(y){const w=y.scope&&y.scope!=="all (unscoped)"?y.scope:"all recipients",x=a?`${a}: ${w}`:w;return{text:g,label:x,matched:[y]}}}else if(o.some(y=>y.toLowerCase()===g.toLowerCase())){const y=u(g);if(y.length>0)return{text:g,label:g,matched:y}}return{text:g,label:g,matched:null}})}const Nh=`Why — What's the situation? Why does this need to happen?
|
|
70
|
-
|
|
71
|
-
Goal — What should the agent try to achieve?
|
|
72
|
-
|
|
73
|
-
Watch out — What should the agent avoid or be careful about?`;function Mj(e,s,a,o){return Fj(e,s,o).map((l,u)=>{if(!l.matched)return n.jsx("span",{children:l.text},u);const f=l.matched;return n.jsx("button",{type:"button",onClick:()=>a(f),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:l.label},u)})}function Oj(){var Ue;const e=Sn(),[s]=ys(),a=Number(s.get("step"))||2,[o,l]=h.useState(null),[u,f]=h.useState(null),[p,g]=h.useState(a),[v,y]=h.useState(null),[w,x]=h.useState(null),[b,N]=h.useState({}),[S,k]=h.useState(Nh),[E,T]=h.useState(!1),[P,I]=h.useState(null),[B,O]=h.useState(!0),[K,_]=h.useState(null),[U,Z]=h.useState([]),[V,M]=h.useState(void 0),[re,de]=h.useState(!1),[X,xe]=h.useState(null),[Ne,ee]=h.useState(null),[Q,q]=h.useState(null),[A,$]=h.useState([]),[ae,ne]=h.useState(null);h.useEffect(()=>{var Le;const fe=sessionStorage.getItem("agentAuth");if(!fe){e("/mandates?new=1");return}const me=JSON.parse(fe);l(me),me.intentHint&&k(me.intentHint),z.getCredential("ai-config").then(ge=>I(ge.configured)).catch(()=>I(!1));const Te=sessionStorage.getItem("agentGate");if(Te){const ge=JSON.parse(Te);ge.bounds&&y(ge.bounds),ge.context&&x(ge.context),(Le=ge.gateContent)!=null&&Le.intent&&k(ge.gateContent.intent)}z.getProfile(me.profileId).then(ge=>f(ge)).catch(()=>e("/mandates?new=1")).finally(()=>O(!1)),me.groupId&&Promise.all([z.getTeamProfileConfig(me.groupId,me.profileId).catch(()=>null),z.getGroupById(me.groupId).catch(()=>null),z.listUsers().catch(()=>[])]).then(([ge,nt,Ze])=>{if(_(ge),ge){const Ye=new Map;for(const Me of Ze){const pe=Me.name&&Me.email?`${Me.name} (${Me.email})`:Me.name||Me.email||Me.id;Ye.set(Me.id,pe)}const He=(nt==null?void 0:nt.members)??[];for(const Me of He){const pe=Me.userId??Me.id;pe&&(Me.name&&Me.email?Ye.set(pe,`${Me.name} (${Me.email})`):Me.name&&Ye.set(pe,Me.name))}const dt=(ge.approvers??[]).map(Me=>Ye.get(Me)??Me);Z(dt);const ft=He.find(Me=>Me.role==="admin");if(ft){const Me=ft.userId??ft.id;Me&&M(Ye.get(Me)??ft.name)}}})},[e]);const ve=v?Object.entries(v).filter(([fe])=>fe!=="profile"&&fe!=="path").map(([fe,me])=>`${fe} = ${me}`).join(", "):"",Se=(fe,me,Te)=>{y(fe),x(me),Te&&N(Te),g(3)},Y=S.trim()!==Nh.trim()&&S.trim()!=="",ce=fe=>{Y&&!confirm("Replace your current intent with the AI draft?")||k(fe)},ie=()=>{const fe=u==null?void 0:u.ttl,me={intent:S},Te=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...Te,bounds:v,context:w,contextLabels:b,gateContent:me,ttlConfig:fe})),e("/mandates/new/sign")},te=async()=>{if(o){de(!0),xe(null),ee(null),q(null),$([]),ne(null);try{const fe=await z.aiIntentReview({profileId:o.profileId,newIntent:S,context:w??void 0});$(fe.grants??[]),fe.success?fe.review?xe(fe.review):ee(fe.note??"No other mandates on this profile to compare against."):q(fe.error??"Check failed.")}catch(fe){q(fe instanceof Error?fe.message:"Check failed.")}finally{de(!1)}}},ze=fe=>{k(fe),(X||Ne||Q)&&(xe(null),ee(null),q(null),$([]),ne(null))};return B||!o||!u?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):n.jsxs(n.Fragment,{children:[n.jsx(gp,{currentStep:p,onStepClick:fe=>{fe>=2&&g(fe)}}),n.jsx(uj,{profileId:o.profileId,bounds:ve||void 0,groupName:o.groupName,domain:o.domain}),p===2&&n.jsx("div",{className:"card",children:n.jsx(Pj,{profile:u,onConfirm:Se,onCancel:()=>e("/mandates?new=1"),initialBounds:v||void 0,initialContext:w||void 0,profileConfig:K,approverNames:U,adminName:V,workspace:{groupId:o.groupId,isPersonal:o.isPersonal}})}),p===3&&n.jsxs("div",{className:`intent-layout${P?"":" no-chat"}`,children:[P&&n.jsx("div",{className:"card intent-pane chat tool",children:n.jsx(Gi,{target:{kind:"intent",profileId:o.profileId,bounds:ve||void 0},currentText:S,onApply:ce})}),n.jsxs("div",{className:"card intent-pane document",children:[n.jsx("h3",{className:"card-title",children:"What should your agent know?"}),n.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),n.jsx("textarea",{className:"intent-textarea",value:S,onChange:fe=>ze(fe.target.value)}),n.jsxs("div",{className:"char-counter",children:[S.length," / 2000"]})]}),P===!1&&n.jsxs("p",{className:"intent-ai-hint",children:[n.jsx(gt,{to:"/settings",children:"Set up an AI assistant in Settings"})," to get help writing this."]}),P&&n.jsxs("div",{style:{marginTop:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:te,disabled:re||!Y,children:re?"Checking…":"Check against my other grants"}),Q&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeft:"3px solid var(--text-primary)"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),n.jsx("div",{className:"hint-body",children:Q})]}),Ne&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsx("div",{className:"hint-body",children:Ne})]}),X&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:[n.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:Mj(X,A,ne,Bt(o.profileId))}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),n.jsxs("div",{className:"intent-footer",children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>g(2),children:"Back"}),n.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:ie,disabled:!Y,children:"Continue to Review"})]}),(((Ue=K==null?void 0:K.approvers)==null?void 0:Ue.length)??0)>0&&n.jsxs("div",{className:"hint-box",role:"note",children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:[n.jsxs("div",{className:"hint-head",children:["Visible to ",U.length>0?U.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",U.length>0?U.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),P&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"floating-help",onClick:()=>T(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),n.jsx(wp,{open:E,onClose:()=>T(!1),ariaLabel:"Intent assistant",children:n.jsx(Gi,{target:{kind:"intent",profileId:o.profileId,bounds:ve||void 0},currentText:S,onApply:fe=>{ce(fe),T(!1)}})})]}),ae&&n.jsx("div",{className:"modal-backdrop",onClick:fe=>fe.target===fe.currentTarget&&ne(null),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:ae.length>1?`Existing mandates (${ae.length})`:"Existing mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>ne(null),children:"×"})]}),n.jsx("div",{className:"modal-body",children:ae.map((fe,me)=>{var Te;return n.jsxs("div",{style:{marginBottom:me<ae.length-1?"1rem":0,paddingBottom:me<ae.length-1?"1rem":0,borderBottom:me<ae.length-1?"1px solid var(--border)":"none"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),n.jsx("div",{style:{marginBottom:"0.75rem"},children:fe.scope}),n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),n.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((Te=fe.intent)==null?void 0:Te.trim())||"(no intent recorded)"}),Object.entries(fe.bounds).filter(([Le])=>Le!=="profile"&&Le!=="path").length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(fe.bounds).filter(([Le])=>Le!=="profile"&&Le!=="path").map(([Le,ge])=>`${Le}: ${ge}`).join(" · ")})]})]},me)})})]})})]})]})}function Bj(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
74
|
-
`).split(`
|
|
75
|
-
`).map(l=>l.replace(/[ \t]+$/,"")).join(`
|
|
76
|
-
`).replace(/\n+$/,"")}async function Xc(e){const a=new TextEncoder().encode(e),o=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(o)).map(u=>u.toString(16).padStart(2,"0")).join("")}class Dj extends Error{constructor(a,o,l){super(l);Zs(this,"code");Zs(this,"field");this.name="CanonicalValueError",this.code=a,this.field=o}}function Uj(e){const s=new TextEncoder().encode(e);let a="";for(const o of s)o===61||o===37||o<32||o>126?a+="%"+o.toString(16).toUpperCase().padStart(2,"0"):a+=String.fromCharCode(o);return a}function jp(e,s,a){const o=[];for(const l of s){const u=e[l];if(u==null)continue;const f=String(u);if(f.includes(`
|
|
77
|
-
`)||f.includes("\r"))throw new Dj(a,l,`Value for "${l}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);o.push(`${l}=${Uj(f)}`)}return o.join(`
|
|
78
|
-
`)}async function zi(e,s){const a=s.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const o=jp(e,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await Xc(o)}`}async function Sp(e,s){const a=s.scopeSchema?jp(e,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await Xc(a)}`}function wc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":wc(l)).join(",")+"]";const s=e,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+wc(l))}return"{"+a.join(",")+"}"}async function bp(e){return`sha256:${await Xc(wc(e))}`}async function Ki(e){const s=new TextEncoder().encode(Bj(e)),a=await crypto.subtle.digest("SHA-256",s);return`sha256:${Array.from(new Uint8Array(a)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}function kp(e,s){if(!e.authorization_id)throw new Error("Signing result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:e.authorization_id,boundsHash:e.bounds_hash??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 Wj(e){const s=e.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(a=>s.includes(a)):[]}function Hj(e){return e==="per-action"?"review":"automatic"}function Ch(e){return e?Wj(e).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function Vj(e,s){return s.includes(e)?e:s[0]??null}function Eh(e){return e==null?new Set:new Set(String(e).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function Gj(e,s){for(const a of e)if(s.has(a))return!0;return!1}function Kj(e,s,a){for(const o of e){const l=Eh(s[o]),u=Eh(a[o]);if(!(l.size===0||u.size===0)&&!Gj(l,u))return!1}return!0}function qj(e){return e.length>24?`${e.slice(0,10)}…`:e}function Np(e,s,a){const o=a==null?void 0:a[e];return String(s).split(",").map(u=>u.trim()).filter(Boolean).map(u=>{const f=o==null?void 0:o[u];return f?`${f} (${qj(u)})`:u}).join(", ")}function Cp(e){var l;if(e.isPersonal)return{can:!0};if(!e.configLoaded)return{can:!0};const s=e.teamName?`"${e.teamName}"`:"this team";return e.grantors!=="all"&&(((l=e.grantors)==null?void 0:l.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${s}.`,fix:`Ask an admin of ${s} to enable ${e.profileName} and name who may give its mandates.`}:e.grantors==="all"||!!e.userId&&e.grantors.includes(e.userId)?{can:!0}:{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${e.profileName}'s grantors in ${s} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}}const qi=500,Yj=["Lower the discount","Other recipient","Shorter","Different wording"];function Zc(e){const s=e.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>qi?{valid:!1,error:`At most ${qi} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function Jj(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ep(e,s){return e.toLowerCase().includes(s.toLowerCase())}function Qj(e,s){const a=e.trim();if(a.length===0)return s;if(!Ep(a,s))return`${a}. ${s}`;const o=new RegExp(`\\.?\\s*${Jj(s)}\\.?`,"i");return a.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function Tp(){return{outcome:"rejected"}}function Xj(e){const s=Zc(e);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function Th(){return{outcome:"replaced"}}function Zj(e,s){if((e.pendingApprovers??[]).includes(s))return{route:"approver"};const a=e.pendingDomains??[];return a.includes(s)?{route:"resolve",domain:s}:a.includes("owner")?{route:"resolve",domain:"owner"}:null}const eS={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function tS(e,s){const a=e.rejectedBy??e.approverRejectedBy;if(!a)return null;const o=a.outcome??"rejected",l=a.note??("reason"in a?a.reason:void 0);return{kind:eS[o],who:a.userId===s?"You":a.userId,at:a.at,note:l}}function nS(e){return e.refusal?{kind:"REFUSED",at:e.refusal.at,message:e.refusal.message}:null}function rS(){var Be,G;const e=Sn(),{user:s,mode:a,domain:o}=wt(),[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState(null),[y,w]=h.useState("per-action"),[x,b]=h.useState(1800),[N,S]=h.useState(86400),[k,E]=h.useState(""),[T,P]=h.useState("hours"),[I,B]=h.useState(""),[O,K]=h.useState(!0),[_,U]=h.useState(!1);h.useEffect(()=>{z.getIdentityDisclosure().then(J=>U(J.always)).catch(()=>{})},[]);const[Z,V]=h.useState(!1),[M,re]=h.useState(""),[de,X]=h.useState(null),[xe,Ne]=h.useState([]),[ee,Q]=h.useState(!1),[q,A]=h.useState([]),[$,ae]=h.useState(0);h.useEffect(()=>{var Dt;const J=sessionStorage.getItem("agentAuth"),ye=sessionStorage.getItem("agentGate");if(!J||!ye){e("/mandates?new=1");return}const Ve=JSON.parse(J),Ge=JSON.parse(ye),rt={bounds:Ge.bounds??{},context:Ge.context??{},contextLabels:Ge.contextLabels??void 0,gateContent:Ge.gateContent};u(Ve),p(rt),Ge.ttlConfig&&(b(Ge.ttlConfig.default??1800),S(Ge.ttlConfig.max??86400)),Ge.templateMode==="automatic"?w("immediate"):Ge.templateMode==="review"&&w("per-action");const Vt=((Dt=Ge.ttlConfig)==null?void 0:Dt.max)??86400;if(typeof Ge.templateTtl=="number"&&Ge.templateTtl>0){const et=Math.min(Ge.templateTtl,Vt);b(et),[3600,86400,604800,2592e3,31536e3].includes(et)||(et%86400===0?(E(String(et/86400)),P("days")):(E(String(Math.max(1,Math.round(et/3600)))),P("hours")))}z.getProfile(Ve.profileId).then(et=>{var W;if(v(et),!I){const we=et.name??((W=Ve.profileId.split("/").pop())==null?void 0:W.replace(/@.*$/,""))??"",Ie=[];if(rt.context&&et.scopeSchema)for(const yt of et.scopeSchema.keyOrder){const qe=rt.context[yt];if(qe!==void 0&&qe!==""){const Et=String(qe).split(",").map(kt=>kt.trim()).filter(Boolean);Ie.push(Et.join(", "))}}const st=Ie.length>0?`${we}: ${Ie.join(" · ")}`:we;B(st)}}).catch(()=>{}),Ve.isPersonal?Q(!0):Promise.all([z.getTeamProfileConfig(Ve.groupId,Ve.profileId).catch(()=>null),z.getGroupById(Ve.groupId).catch(()=>null),z.listUsers().catch(()=>[])]).then(([et,W,we])=>{if(X(et),et){const Ie=new Map;for(const qe of we){const Et=qe.name&&qe.email?`${qe.name} (${qe.email})`:qe.name||qe.email||qe.id;Ie.set(qe.id,Et)}const st=(W==null?void 0:W.members)??[];for(const qe of st){const Et=qe.userId??qe.id;Et&&(qe.name&&qe.email?Ie.set(Et,`${qe.name} (${qe.email})`):qe.name&&Ie.set(Et,qe.name))}const yt=(et.approvers??[]).map(qe=>Ie.get(qe)??qe);Ne(yt)}}).finally(()=>{Q(!0)})},[e]),h.useEffect(()=>{if(!(l!=null&&l.profileId))return;const J=l.profileId,ye=sessionStorage.getItem("agentEditReplaces");z.getEnrichedAuthorizations().then(Ve=>{const Ge=Ve.filter(rt=>rt.profileId===J&&rt.authorizationId!==ye).map(rt=>({authorizationId:rt.authorizationId,bounds:rt.bounds,context:rt.context??{},intent:rt.intent}));A(Ge)}).catch(()=>A([]))},[l==null?void 0:l.profileId]),h.useEffect(()=>{if(!g)return;const J=Vj(y,Ch(g));J&&J!==y&&w(J)},[g,y]),h.useEffect(()=>{if(!f||!g||q.length===0){ae(0);return}let J=!1;return(async()=>{const ye=await zi(f.bounds,g),Ve=await Promise.all(q.map(Ge=>zi(Ge.bounds,g).catch(()=>null)));J||ae(Ve.filter(Ge=>Ge===ye).length)})().catch(()=>{J||ae(0)}),()=>{J=!0}},[f,g,q]);const ne=async()=>{if(!(!l||!f||!g||!s)){if(!l.groupId){re("No active group; cannot create mandate.");return}V(!0),re("");try{const J=o||l.domain||"owner",ye=await zi(f.bounds,g),Ve=await Sp(f.context,g),[Ge,rt]=await Promise.all([Ki(f.gateContent.intent),Ki(JSON.stringify({profile:l.profileId,domain:J,group:l.groupId}))]);let Vt,Dt,et,W;if(l.isTeam){const kt=await z.getApproversPubkeys(l.groupId,l.profileId);if(kt.length>0){const Zt=await z.encryptIntent(f.gateContent.intent,kt);Vt=Zt.intentCiphertext,Dt=Zt.encryptedKeys,et=Zt.approversFrozen,W=Zt.intentDisclosureHash}}const we=`authz_${crypto.randomUUID()}`,Ie=sessionStorage.getItem("agentEditReplaces")||void 0,st=sessionStorage.getItem("agentReplacesProposal")||void 0,yt=await bp(g),qe=await z.attest({authorization_id:we,replaces:Ie,profile_id:l.profileId,profile_hash:yt,supported_versions:["0.7"],bounds:f.bounds,bounds_hash:ye,scope_hash:Ve,domain:J,did:s.did,mandate_owners:[{did:s.did}],gate_content_hashes:{intent:Ge},execution_context_hash:rt,group_id:l.groupId,ttl:x,commitment_mode:Hj(y),title:I.trim(),intent_ciphertext:Vt,encrypted_keys:Dt,approvers_frozen:et,intent_disclosure_hash:W,disclose_identity:O});try{await z.pushGateContent(kp(qe,{boundsHash:ye,contextHash:Ve,context:f.context,contextLabels:f.contextLabels,gateContent:f.gateContent}))}catch(kt){try{await z.revokeAttestation(we,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${kt instanceof Error?kt.message:"Unknown error"})`)}if(Ie)try{await z.revokeAttestation(Ie,`Replaced by ${we} (edit)`),z.resyncGates().catch(()=>{})}catch{}let Et="";if(st)try{const kt=await z.getProposal(st);if(kt.status==="pending"){const Zt=Zj(kt,(s==null?void 0:s.id)??"");Zt?Zt.route==="approver"?await z.rejectProposal(st,Th()):await z.resolveProposal(st,"reject",Zt.domain,Th()):Et="you are not one of the people who may decide it"}}catch(kt){Et=kt instanceof Error?kt.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),Et){re(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${Et}) — reject it under Approvals.`);return}e(`/mandates?highlight=${encodeURIComponent(we)}`)}catch(J){re(J instanceof Error?J.message:"Signing the mandate failed")}finally{V(!1)}}};if(!l||!f)return n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const ve=Object.entries(f.bounds).filter(([J])=>J!=="profile"&&J!=="path"),Se=Object.entries(f.context),ce=((de==null?void 0:de.caps)!=null?Object.keys(de.caps):[]).length!==0,ie=xe.length>0?xe.join(", "):((de==null?void 0:de.approvers)??[]).join(", "),te=ce?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${ie}, 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.",ze=ce?`Over-cap actions will be reviewed by you and ${ie}. Within-cap actions run per the mode you chose above.`:`Approvers ${ie} can read your intent but won't gate any action — no caps configured on this profile.`,Ue=!!((Be=de==null?void 0:de.approvers)!=null&&Be.length),fe=Cp({isPersonal:l.isPersonal,configLoaded:ee,grantors:de?Em(de):void 0,userId:s==null?void 0:s.id,profileName:Bt(l.profileId),teamName:l.groupName}),me=!fe.can,Te=Ch(g),Le=Te.length===0,ge=x>N,nt={flex:1,padding:"0.75rem",border:y==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:y==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Ze={flex:1,padding:"0.75rem",border:y==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:y==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Ye=((G=g==null?void 0:g.scopeSchema)==null?void 0:G.keyOrder)??[],He=q.filter(J=>Kj(Ye,f.context,J.context)),dt=He.length>0,ft=Bt(l.profileId),Me=J=>{const ye=Object.values(J).map(Ve=>String(Ve).trim()).filter(Boolean);return ye.length>0?ye.join(", "):"all (unscoped)"},pe=He.map(J=>Me(J.context)).join("; "),Pe=`This grant's scope overlaps an existing grant on ${ft} (scoped to: ${pe}). 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 n.jsxs(n.Fragment,{children:[n.jsx(gp,{currentStep:4,onStepClick:J=>{J<=3&&e(`/mandates/new/intent?step=${J}`)}}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),l.upgradedFromProfileId&&g&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginBottom:"1rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:["Updated to ",Bt(l.profileId)," ",g.version," — the current version of this profile."]})]}),M&&n.jsx("div",{className:"error-message",children:M}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Title"]}),n.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Bt(l.profileId)}: daily operations`,value:I,onChange:J=>B(J.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[Te.includes("per-action")&&n.jsxs("button",{onClick:()=>w("per-action"),style:Ze,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),Te.includes("immediate")&&n.jsxs("button",{onClick:()=>w("immediate"),style:nt,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]}),Te.length===1&&n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:Te[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Le&&n.jsx("div",{className:"msg-error",style:{fontSize:"0.75rem",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Duration"]}),n.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(J=>J.seconds<=N).map(J=>n.jsx("button",{onClick:()=>{b(J.seconds),E("")},style:{padding:"0.5rem 0.85rem",border:x===J.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:x===J.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:J.label},J.seconds)),n.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[n.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:k,onChange:J=>{E(J.target.value);const ye=parseInt(J.target.value,10);if(ye>0){const Ve=T==="days"?ye*86400:ye*3600;b(Math.min(Ve,N))}}}),n.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:T,onChange:J=>{P(J.target.value);const ye=parseInt(k,10);if(ye>0){const Ve=J.target.value==="days"?ye*86400:ye*3600;b(Math.min(Ve,N))}},children:[n.jsx("option",{value:"hours",children:"hours"}),n.jsx("option",{value:"days",children:"days"})]})]}),ge&&n.jsxs("span",{className:"msg-error",style:{fontSize:"0.75rem"},children:["Maximum: ",N>=86400?`${Math.floor(N/86400)} days`:`${Math.floor(N/3600)} hours`]})]})]}),n.jsx("div",{className:"field-editable",children:n.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[n.jsx("input",{type:"checkbox",checked:_||O,disabled:_,onChange:J=>K(J.target.checked),style:{marginTop:"0.15rem"}}),n.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",n.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.',_&&" Always on — you chose this in Settings."]})]})]})}),n.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Intent"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:f.gateContent.intent})]}),(!!ve.length||!!Se.length)&&n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Scope & Limits"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),n.jsxs("dl",{className:"info-kv",children:[Se.map(([J,ye])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:J}),n.jsx("dd",{children:Np(J,ye,f.contextLabels)})]},J)),ve.map(([J,ye])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:J}),n.jsx("dd",{children:String(ye)})]},J))]})]}),n.jsxs("div",{className:"info-block",children:[n.jsx("div",{className:"info-head",children:n.jsx("span",{className:"info-title",children:"Authority"})}),n.jsxs("dl",{className:"info-kv",children:[n.jsx("dt",{children:"Profile"}),n.jsxs("dd",{children:[Bt(l.profileId),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:l.profileId})]}),!l.isPersonal&&l.groupName&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Team"}),n.jsx("dd",{children:l.groupName})]}),!l.isPersonal&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Approvers"}),n.jsx("dd",{children:ee?fe.can?n.jsxs(n.Fragment,{children:[ie,n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:te})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"msg-error",children:fe.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${l.groupName??"this team"}`:"You cannot give this mandate"}),fe.code==="OWNER_NOT_APPROVER"&&n.jsx("div",{children:ie}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[fe.reason," ",fe.fix]})]}):n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),$>0?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),n.jsxs("div",{children:[$===1?`An active grant on ${ft} already has exactly these limits.`:`${$} active grants on ${ft} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",n.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,dt?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Overlapping scope"}),n.jsx("div",{children:Pe})]})]}):null,n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/mandates/new/intent"),children:"Back"}),n.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:ne,disabled:Z||!I.trim()||me||Le,children:Z?"Signing...":y==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),n.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:Ue?"block":"none"},children:ze})]})]})}const sS={card:"💳",mail:"✉️"};function Ap(e){return sS[e]??"🔧"}function Ip(e){var a;const s=[e.profile];for(const o of Object.values(((a=e.toolGating)==null?void 0:a.overrides)??{})){const l=o==null?void 0:o.profile;l&&!s.includes(l)&&s.push(l)}return s}function Ah(e,s){const a=new Map;for(const o of e)for(const l of Ip(o.manifest)){let u=a.get(l);u||(u={shortId:l,icon:Pr(l),name:Dn(l,s),entries:[]},a.set(l,u)),u.entries.push(o)}return[...a.values()].sort((o,l)=>o.name.localeCompare(l.name))}function aS(e,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const a=e.filter(f=>Oi(f.manifest)&&!Bi(f,s)),o=e.filter(f=>!Oi(f.manifest)||Bi(f,s)),l=o.filter(f=>f.state==="error"),u=o.filter(f=>f.state!=="error");return{grouped:!0,testSystems:a,realErrors:l,pausedReal:u,ungrouped:[]}}function iS(e){const s=e==null?void 0:e.overrides;return!s||typeof s!="object"?!1:Object.values(s).some(a=>{var o;return typeof((o=a==null?void 0:a.read)==null?void 0:o.ageField)=="string"})}const oS=[0,7,30,90,365,3650];function Ai(e){return e===null?"From your mandate":e===0?"Read nothing":e===1?"1 day back":e===365?"1 year back":e%365===0?`${e/365} years back`:`${e} days back`}function lS(e){return(e==null?void 0:e.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:e&&!e.running&&e.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function rc({manifest:e,integration:s,state:a,onStatusChange:o,onSuccess:l}){var Me;const[u,f]=h.useState({}),[p,g]=h.useState(!1),[v,y]=h.useState(!1),[w,x]=h.useState({}),[b,N]=h.useState({}),[S,k]=h.useState(void 0),[E,T]=h.useState(!1),[P,I]=h.useState(null),[B,O]=h.useState(!1),[K,_]=h.useState(!1),[U,Z]=h.useState(!1),[V,M]=h.useState(!1),[re,de]=h.useState({}),[X,xe]=h.useState(null),[Ne,ee]=h.useState(!1),[Q,q]=h.useState(null),[A,$]=h.useState(!1);h.useEffect(()=>{let pe=!1;return z.getCredential(e.id).then(Pe=>{var Be;if(!(pe||!Pe.configured)){if(g(!0),y(!0),Pe.fields){const G={};for(const J of e.credentials.fields)Pe.fields[J.key]!=null&&(G[J.key]=Pe.fields[J.key]);x(G)}if(N(Pe.secrets??{}),k(Pe.updatedAt),e.oauth){const G=((Be=Pe.fieldNames)==null?void 0:Be.includes(e.oauth.tokenStorage))??!1;T(G),G&&z.getOAuthHealth(e.id).then(J=>{pe||I(J)})}}}).catch(()=>{}),()=>{pe=!0}},[e.id,e.oauth]);const ae=iS(e.toolGating),ne=s?s.readAgeDays??null:void 0,ve=Ne&&X?X.value:ne,Se=async pe=>{xe({value:pe}),ee(!0),q(null);try{await z.setReadPolicy(e.id,pe),l(pe===null?`${e.name} read window now follows your mandate`:`${e.name} read window set to ${Ai(pe).toLowerCase()}`),o()}catch(Pe){q(Pe instanceof Error?Pe.message:"Could not save")}finally{ee(!1),xe(null)}},Y=!!e.oauth||e.credentials.fields.some(pe=>!pe.optional),ce=e.oauth?E:p,ie=!Y||ce,te=a==="starting"?"starting":ie?s!=null&&s.running?"running":!p&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&p&&!E?"needs-oauth":"unconfigured",ze=async()=>{if(e.credentials.fields.some(Pe=>{var Be;return(Be=u[Pe.key])==null?void 0:Be.trim()})){O(!0);try{await z.setCredential(e.id,u),g(!0),f({}),e.oauth?l(`${e.name} credentials saved!`):(l(`${e.name} credentials saved — starting integration...`),await Le())}catch{l(`Failed to save ${e.name} credentials`)}finally{O(!1)}}},Ue=()=>{const pe={};for(const Pe of e.credentials.fields){const Be=u[Pe.key];Pe.type==="password"?Be!=null&&Be.trim()&&(pe[Pe.key]=Be):Be!=null&&Be!==(w[Pe.key]??"")&&(pe[Pe.key]=Be)}return pe},fe=Object.keys(Ue()).length>0,me=async()=>{const pe=Ue();if(Object.keys(pe).length!==0){O(!0);try{await z.setCredential(e.id,pe),f({}),g(!0),e.oauth?l(`${e.name} credentials saved — now click Connect.`):(M(!1),l(`${e.name} credentials updated — restarting...`),await Le())}catch{l(`Failed to update ${e.name} credentials`)}finally{O(!1)}}},Te=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const pe=setInterval(async()=>{var Pe;try{const Be=await z.getCredential(e.id);Be.configured&&e.oauth&&((Pe=Be.fieldNames)!=null&&Pe.includes(e.oauth.tokenStorage))&&(T(!0),M(!1),I(null),clearInterval(pe),l(`${e.name} connected — starting integration...`),z.getOAuthHealth(e.id).then(I).catch(()=>{}),await Le())}catch{}},2e3);setTimeout(()=>clearInterval(pe),12e4)},Le=async()=>{Z(!0);try{const pe=await z.activateIntegration(e.id);pe.warning?l(pe.warning):l(`${e.name} integration started with ${pe.tools.length} tools`),o()}catch(pe){l(`Failed to start ${e.name}: ${pe instanceof Error?pe.message:"Unknown error"}`)}finally{Z(!1)}},ge=async()=>{try{await z.removeMcpIntegration(e.id),l(`${e.name} integration removed`),o()}catch{l(`Failed to remove ${e.name}`)}},nt=Ap(e.icon),Ze=lS(s),Ye=te==="running"?{c:"int-chip-ok",t:"Running"}:te==="starting"?{c:"int-chip-idle",t:"Starting"}:Ze.chip,He=e.oauth&&E&&(P==null?void 0:P.status)==="failed",dt=Y?He?{c:"int-chip-bad",t:"Auth failed"}:ce?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},ft=pe=>pe.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return n.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[n.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:nt}),n.jsxs("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:[e.name,Xf(e,w)&&n.jsxs("span",{style:{fontWeight:400,color:"var(--text-muted)"},children:[" · ",Xf(e,w)]}),Zf(e,w)&&n.jsx("span",{className:"card-mode-note","data-testid":"integration-mode-note",children:Zf(e,w)})]}),n.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[te!=="unconfigured"&&te!=="needs-oauth"&&n.jsxs("span",{className:`int-chip ${Ye.c}`,children:[n.jsx("span",{className:"int-dot"}),Ye.t]}),n.jsxs("span",{className:`int-chip ${dt.c}`,children:[n.jsx("span",{className:"int-dot"}),dt.t]}),d0(e,w)&&n.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:[n.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),e.oauth&&E&&n.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:P!=null&&P.account?n.jsxs(n.Fragment,{children:["Connected as ",n.jsx("b",{children:P.account})]}):n.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),He&&!V&&n.jsxs("div",{style:{marginTop:"0.7rem",border:"2px solid var(--border-strong)",borderRadius:"10px",padding:"0.8rem 0.95rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[e.name," stopped accepting the stored credentials"]}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[(P==null?void 0:P.error)==="invalid_grant"?n.jsxs(n.Fragment,{children:["The refresh token was revoked (",n.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):P!=null&&P.error?n.jsxs(n.Fragment,{children:["The provider reported ",n.jsx("code",{children:P.error}),"."]}):n.jsx(n.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",e.name," actions are ",n.jsx("b",{children:"blocked"}),", not failing silently."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[n.jsxs("button",{className:"btn btn-primary btn-sm",onClick:Te,children:["Reconnect ",e.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{f({...w}),M(!0)},children:"Edit credentials"})]})]}),n.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[n.jsx("summary",{children:"Details"}),n.jsxs("div",{className:"int-meta",children:[n.jsx("span",{className:"int-k",children:"What"}),n.jsx("span",{children:e.description}),e.profile&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Profile"}),n.jsx("span",{children:Ip(e).join(", ")})]}),e.oauth&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Scopes"}),n.jsx("span",{children:((Me=e.oauth.scopes)==null?void 0:Me.join(", "))||"—"})]}),s&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Tools"}),n.jsxs("span",{children:[s.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(te!=="running"||He)&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsxs("button",{onClick:()=>_(!K),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[n.jsx("span",{style:{transition:"transform 0.2s",transform:K?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),K&&n.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((pe,Pe)=>n.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[n.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:Pe+1}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:pe.title}),n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[ft(pe.description),pe.link&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("a",{href:pe.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},Pe))})]}),te==="starting"&&n.jsxs("div",{className:"service-status",style:{color:"var(--text-primary)"},children:[n.jsx("span",{className:"service-status-dot",style:{background:"transparent",border:"1px dashed var(--text-primary)"}}),"Starting…"]}),V&&n.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[n.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),v&&n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.6rem"},children:["Leaving a secret blank keeps the stored one — editing other fields can never silently wipe it.",e.oauth?" Save, then Connect to re-link the account.":""]}),e.credentials.fields.map(pe=>{var Pe;return n.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[n.jsx("label",{className:"form-label",children:pe.label}),pe.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:re[pe.key]?"text":"password",name:`${e.id}-${pe.key}-credential`,autoComplete:"new-password",placeholder:(Pe=b[pe.key])!=null&&Pe.preview?`Unchanged — ends in ${b[pe.key].preview}`:v?"Unchanged — paste a new value to replace":pe.placeholder,value:u[pe.key]||"",onChange:Be=>f(G=>({...G,[pe.key]:Be.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>de(Be=>({...Be,[pe.key]:!Be[pe.key]})),children:re[pe.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${pe.key}-credential`,autoComplete:"off",placeholder:pe.placeholder,value:u[pe.key]||"",onChange:Be=>f(G=>({...G,[pe.key]:Be.target.value}))})]},pe.key)}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:me,disabled:B||!fe,children:B?"Saving…":"Save"}),!fe&&!B&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),e.oauth&&n.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:Te,children:["Connect ",e.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{M(!1),f({})},children:"Cancel"})]})]}),!V&&te==="running"&&s&&n.jsxs(n.Fragment,{children:[(Object.keys(w).length>0||Object.keys(b).length>0)&&n.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:e.credentials.fields.map(pe=>{const Pe=pe.type==="password",Be=b[pe.key];return!Pe&&w[pe.key]==null||Pe&&Be==null?null:n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[n.jsx("span",{style:{color:"var(--text-muted)"},children:pe.label}),n.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[Pe?Be.preview??"set":w[pe.key],Pe&&S&&n.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(S).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},pe.key)})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[n.jsx(gt,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(e.credentials.fields.length>0||e.oauth)&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{f({...w}),M(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),n.jsx("span",{style:{flex:1}}),n.jsx("button",{className:"btn btn-sm btn-outline-strong",onClick:ge,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),ae&&ve!==void 0&&!A&&n.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[n.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),n.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:ve===null?"window from your mandate":Ai(ve).toLowerCase()}),Ne&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),Q&&n.jsx("span",{className:"msg-error",style:{fontSize:"0.78rem"},children:Q})]}),n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>$(!0),children:"Edit"})]})}),ae&&ve!==void 0&&A&&n.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[n.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),n.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>$(!1),children:"Done"})]}),n.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new mandate."}),n.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[oS.map(pe=>{const Pe=ve===pe;return n.jsx("button",{className:`btn btn-sm ${Pe?"btn-primary":"btn-secondary"}`,"aria-pressed":Pe,disabled:Ne,onClick:()=>Se(pe),children:Ai(pe)},pe)}),n.jsx("button",{className:`btn btn-sm ${ve===null?"btn-primary":"btn-ghost"}`,"aria-pressed":ve===null,disabled:Ne,onClick:()=>Se(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:Ai(null)})]}),n.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:Q?n.jsx("span",{className:"msg-error",children:Q}):Ne?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):ve===null?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):ve===0?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):n.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",ve," days is blocked, whoever it is from."]})})]}),n.jsx("div",{style:{display:"none"},children:n.jsx(gt,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),te==="unconfigured"&&(()=>{const pe=e.credentials.fields.every(G=>G.optional),Pe=e.credentials.fields.some(G=>!G.optional),Be=e.credentials.fields.some(G=>{var J;return(J=u[G.key])==null?void 0:J.trim()});return n.jsxs(n.Fragment,{children:[v&&n.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:[n.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"," ",n.jsx("button",{onClick:()=>{g(!0),e.oauth&&T(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),e.setupHint&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(G=>n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:G.label}),G.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:re[G.key]?"text":"password",name:`${e.id}-${G.key}-credential`,autoComplete:"new-password",placeholder:G.placeholder,value:u[G.key]||"",onChange:J=>f(ye=>({...ye,[G.key]:J.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>de(J=>({...J,[G.key]:!J[G.key]})),children:re[G.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${G.key}-credential`,autoComplete:"off",placeholder:G.placeholder,value:u[G.key]||"",onChange:J=>f(ye=>({...ye,[G.key]:J.target.value}))})]},G.key)),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[Be&&n.jsx("button",{className:"btn btn-primary",onClick:ze,disabled:B||Pe&&!e.credentials.fields.filter(G=>!G.optional).every(G=>{var J;return(J=u[G.key])==null?void 0:J.trim()}),children:B?"Saving...":"Save & Encrypt"}),pe&&!Be&&n.jsx("button",{className:"btn btn-primary",onClick:Le,disabled:U,children:U?"Starting...":`Activate ${e.name}`})]})]})})(),te==="needs-oauth"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[n.jsxs("button",{className:"btn btn-primary",onClick:Te,children:["Connect ",e.name," Account"]}),n.jsx("button",{className:"btn btn-ghost",onClick:()=>g(!1),children:"Change Credentials"})]})]}),te==="ready"&&!s&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[n.jsx("button",{className:"btn btn-primary",onClick:Le,disabled:U,children:U?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>g(!1),children:"Update Credentials"}),e.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>{g(!1),T(!1)},children:"Change Credentials"})]})]}),te==="ready"&&s&&!s.running&&(Ze.showStart?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[n.jsx("span",{className:"service-status-dot"}),"Not running"]}),s.error&&n.jsx("div",{className:"msg-error",style:{fontSize:"0.8rem",marginBottom:"0.75rem"},children:s.error}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:Le,disabled:U,children:U?"Starting...":"Start"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:ge,children:"Disable"})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"service-status",style:{marginBottom:"0.5rem",color:"var(--text-muted)"},children:[n.jsx("span",{className:"service-status-dot",style:{background:"var(--text-muted)"}}),"Paused"]}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.75rem"},children:"Real systems are off while simulation mode is on."}),n.jsx("div",{style:{display:"flex",gap:"0.5rem"},children:n.jsx("button",{className:"btn btn-outline-strong",onClick:ge,children:"Disable"})})]}))]})}function Ih({group:e,children:s}){return n.jsxs("div",{className:"area-group","data-testid":"integration-area","data-area":e.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(ga,{icon:e.icon}),n.jsx("b",{children:e.name})]}),s]})}function cS({entry:e}){return n.jsxs("div",{className:"int-paused-row",children:[n.jsx("span",{"aria-hidden":"true",children:Ap(e.manifest.icon)}),n.jsx("span",{className:"int-paused-name",children:e.manifest.name}),n.jsxs("span",{className:"int-chip int-chip-paused",children:[n.jsx("span",{className:"int-dot"}),"Paused"]})]})}function uS(){const{loading:e,mcpServerUp:s,manifestsError:a,entries:o,refresh:l}=Uc(),u=Dc(),[f,p]=h.useState(""),g=Lr(),v=h.useCallback(w=>{p(w),setTimeout(()=>p(""),5e3)},[]),y=aS(o,u);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Integrations"}),n.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),f&&n.jsx("div",{className:"alert alert-success",children:f}),e?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):s===!1?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):y.grouped?n.jsxs(n.Fragment,{children:[y.testSystems.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Test systems"}),Ah(y.testSystems,g).map(w=>n.jsx(Ih,{group:w,children:w.entries.map(x=>n.jsx(rc,{manifest:x.manifest,integration:x.integration,state:x.state,onStatusChange:l,onSuccess:v},x.id))},w.shortId))]}),(y.realErrors.length>0||y.pausedReal.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Real systems"}),y.realErrors.map(w=>n.jsx(rc,{manifest:w.manifest,integration:w.integration,state:w.state,onStatusChange:l,onSuccess:v},w.id)),y.pausedReal.length>0&&n.jsxs("details",{className:"int-paused-group",open:!0,children:[n.jsxs("summary",{children:["Paused while simulation mode is on (",y.pausedReal.length,")"]}),n.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 (",n.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),y.pausedReal.map(w=>n.jsx(cS,{entry:w},w.id))]})]}),o.length===0&&n.jsx(Rh,{manifestsError:a})]}):n.jsxs(n.Fragment,{children:[Ah(o,g).map(w=>n.jsx(Ih,{group:w,children:w.entries.map(x=>n.jsx(rc,{manifest:x.manifest,integration:x.integration,state:x.state,onStatusChange:l,onSuccess:v},x.id))},w.shortId)),o.length===0&&n.jsx(Rh,{manifestsError:a})]})]})}function Rh({manifestsError:e}){return e?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.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"," ",n.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):n.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function dS(){var M,re,de;const{activeTeam:e,activeMembership:s,refreshGroups:a,user:o}=wt(),l=Sn(),[u,f]=h.useState(null),[p,g]=h.useState(!1),[v,y]=h.useState(""),[w,x]=h.useState(""),[b,N]=h.useState(!1),[S,k]=h.useState(""),[E,T]=h.useState("");h.useEffect(()=>{fetch("/health").then(X=>X.json()).then(X=>{typeof X.spUrl=="string"&&T(X.spUrl)}).catch(()=>{})},[]),h.useEffect(()=>{if(!e){f(null);return}z.getGroupById(e.id).then(X=>{const xe=X.group??X,Ne=X.members??[],ee=X.isAdmin??!1,Q=Ne.map(q=>{const A=q.userId||q.id||"",$=q.role||(ee&&A===xe.createdBy?"admin":"member");return{id:A,name:q.name||A.slice(0,8)||"Member",email:q.email||"",domains:q.domains||[],role:$,isAdmin:$==="admin"||ee&&A===xe.createdBy}});f({id:xe.id,name:xe.name,members:Q})}).catch(()=>f(null))},[e==null?void 0:e.id]);const P=(u==null?void 0:u.members.filter(X=>X.isAdmin))??[],I=(e==null?void 0:e.isAdmin)===!0&&P.length<=1&&P.some(X=>X.id===(o==null?void 0:o.id)),B=(e==null?void 0:e.name)??"",O=S.trim()===B&&!p,K=()=>{k(""),N(!0)},_=()=>{N(!1),k("")},U=async()=>{if(!(!e||!O)){g(!0),y("");try{await z.leaveTeam(e.id),await a(),x("You have left the team."),f(null),_()}catch(X){y(X instanceof Error?X.message:"Failed to leave team")}finally{g(!1)}}},Z=e&&E?`${E}/dashboard/groups/${e.id}`:void 0,V=E?`${E}/dashboard/groups`:void 0;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"page-header",children:n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Team"}),n.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),v&&n.jsx("div",{className:"error-message",children:v}),w&&n.jsx("div",{className:"alert alert-success",children:w}),e?n.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[n.jsxs("div",{className:"card-header",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"card-title",children:e.name}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((M=u==null?void 0:u.members)==null?void 0:M.length)??0," ",(((re=u==null?void 0:u.members)==null?void 0:re.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),n.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(de=u==null?void 0:u.members)==null?void 0:de.map(X=>n.jsxs("div",{className:"member-row",children:[n.jsx("div",{className:"member-avatar",children:X.name.split(" ").map(xe=>xe[0]).join("").slice(0,2).toUpperCase()}),n.jsxs("div",{className:"member-info",children:[n.jsx("div",{className:"member-name",children:X.name}),n.jsx("div",{className:"member-email",children:X.email})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:X.role})]},X.id)),n.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[Z&&n.jsx("a",{className:"btn btn-secondary btn-sm",href:Z,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),n.jsx("span",{title:I?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:n.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:K,disabled:p||I,children:"Leave team"})})]})]}):n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[n.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),n.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."}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",justifyContent:"center",flexWrap:"wrap"},children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>l("/onboarding"),children:"Join or create a team"}),V&&n.jsx("a",{className:"btn btn-ghost btn-sm",href:V,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),b&&e&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:_,children:n.jsxs("div",{className:"card",onClick:X=>X.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[n.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",B,"?"]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsx("li",{children:"Revoke all mandates you created in this team's context"}),n.jsx("li",{children:"Reject any pending action proposals you authored"}),n.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",n.jsx("strong",{children:"personal"})," mandates are not affected."]}),n.jsxs("div",{className:"form-group",children:[n.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",n.jsx("code",{children:B})," to confirm:"]}),n.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:S,onChange:X=>k(X.target.value),placeholder:B,disabled:p,autoFocus:!0})]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:_,disabled:p,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:U,disabled:!O,children:p?"Leaving...":"Leave team"})]})]})})]})}function eu({areas:e,selected:s,onSelect:a,totalCount:o}){return e.length<2?null:n.jsxs("div",{className:"ftabs",role:"tablist","aria-label":"Which area","data-testid":"area-filter",children:[n.jsxs("button",{type:"button",role:"tab",className:"ftab","aria-selected":s===null,onClick:()=>a(null),children:["All ",n.jsx("span",{className:"n",children:o})]}),e.map(l=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`area-filter-${l.shortId}`,"aria-selected":s===l.shortId,onClick:()=>a(s===l.shortId?null:l.shortId),children:[n.jsx(ga,{icon:l.icon})," ",l.name," ",n.jsx("span",{className:"n",children:l.count})]},l.shortId))]})}const dr=e=>e.replace(/@.*$/,"").split("/").pop()??e,Ph=e=>e.split("@")[1]??"";function $h(e){var a;const s=e.profile?[dr(e.profile)]:[];for(const o of Object.values(((a=e.toolGating)==null?void 0:a.overrides)??{})){const l=o==null?void 0:o.profile;l&&!s.includes(dr(l))&&s.push(dr(l))}return s}function fS(e,s){const a=new Map;for(const o of e){const l=dr(o.id);if(!s.has(l))continue;const u=a.get(l);(!u||Ph(o.id).localeCompare(Ph(u.id),void 0,{numeric:!0})>0)&&a.set(l,o)}return a}function hS(e,s,a,o){var p;const l=new Set([...s.flatMap(g=>$h(g)),...o.map(g=>dr(g.profile))]),u=fS(e,l),f=[];for(const g of s){const v=$h(g);for(const[y,w]of v.entries()){const x=u.get(w);x&&f.push({key:y===0?`connector:${g.id}`:`connector:${g.id}:${w}`,name:v.length>1?`${g.name} — ${x.name??w}`:g.name,description:g.description||x.description,profile:x,kind:"connector",ready:((p=a.find(b=>b.id===g.id))==null?void 0:p.running)===!0,setupId:g.id,...g.intentHint&&y===0?{intentHint:g.intentHint}:{}})}}for(const g of o){const v=u.get(dr(g.profile));v&&f.push({key:`builtin:${g.id}`,name:g.name,description:g.description||v.description,profile:v,kind:"builtin",ready:g.available,unavailableReason:g.available?void 0:"Available only while simulation mode is on.",...g.intentHint?{intentHint:g.intentHint}:{}})}return f}function mS(e,s,a){if(s)return e.find(o=>dr(o.profile.id)===dr(s)&&o.ready&&a(o))}function Rp({icon:e,className:s}){return n.jsx(ga,{icon:e,className:s})}function pS({onDismiss:e,preselectProfileId:s}){const a=Sn(),{group:o,groupId:l,domain:u,user:f}=wt(),[p,g]=h.useState([]),[v,y]=h.useState([]),[w,x]=h.useState([]),[b,N]=h.useState([]),[S,k]=h.useState(!0),[E,T]=h.useState({});h.useEffect(()=>{Promise.all([z.listProfiles().catch(()=>[]),z.getIntegrationManifests().then(U=>U.manifests??[]).catch(()=>[]),z.getMcpHealth().catch(()=>null)]).then(async([U,Z,V])=>{if(g(U),y(Z),x((V==null?void 0:V.integrations)??[]),N((V==null?void 0:V.builtins)??[]),l){const M=await Promise.all(U.map(de=>z.getTeamProfileConfig(l,de.id).catch(()=>null))),re={};U.forEach((de,X)=>{const xe=M[X];xe&&(re[de.id]=xe)}),T(re)}}).finally(()=>k(!1))},[l]);const P=hS(p,v,w,b),I=U=>{const Z=E[U.id];return Cp({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!S,grantors:Z?Em(Z):void 0,userId:f==null?void 0:f.id,profileName:Bt(U.id),teamName:o==null?void 0:o.name})},B=U=>U in E,O=(U,Z)=>{if(!l){console.error("No active group when creating authorization");return}const V=B(U);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:U,groupId:l,groupName:(o==null?void 0:o.name)??null,domain:u,isTeam:V,isPersonal:!!(o!=null&&o.isPersonal),...Z?{intentHint:Z}:{}})),sessionStorage.removeItem("agentGate"),e==null||e(),a("/mandates/new/intent")},K=(U,Z)=>{l&&O(U,Z)},_=h.useRef(!1);return h.useEffect(()=>{if(S||!s||_.current)return;const U=mS(P,s,Z=>I(Z.profile).can);U&&(_.current=!0,K(U.profile.id,U.intentHint))},[S,s]),n.jsxs(n.Fragment,{children:[n.jsx("style",{children:`
|
|
79
|
-
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
|
|
80
|
-
.profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
|
|
81
|
-
@media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
|
|
82
|
-
@media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
|
|
83
|
-
`}),S?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):P.length===0?n.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[n.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),n.jsx(gt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):n.jsx("div",{className:"profile-grid",children:P.map(U=>{const Z=U.profile,V=B(Z.id),M=I(Z),re=!U.ready||!M.can,{icon:de}=_r(Z.id,{name:Z.name});return n.jsxs("div",{className:"card",style:re?{opacity:.7}:void 0,children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[n.jsxs("h3",{className:"card-title profile-chip",style:{margin:0},children:[n.jsx(Rp,{icon:de,className:"profile-chip-icon"}),U.name]}),V?n.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?n.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]}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:U.description}),M.can?U.ready?n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>K(Z.id,U.intentHint),children:"Give a mandate"}):U.kind==="builtin"?n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:U.unavailableReason})]}):n.jsxs(gt,{to:`/integrations?setup=${U.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",U.name]}):n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[M.reason," ",n.jsx("span",{style:{color:"var(--text-tertiary)"},children:M.fix})]})]})]},U.key)})})]})}const gS={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function yS({status:e,label:s}){return n.jsx("span",{className:`status-badge status-${e}`,children:s||gS[e]})}function vS({domain:e,attested:s}){const a=s===!0?"domain-attested":s===!1?"domain-missing":"";return n.jsx("span",{className:`domain-badge ${a}`,style:{fontSize:"0.75rem"},children:e})}const Tr=86400,oa=3600,Ii=60,xS=30*Tr;function wS(e){if(e<=0)return"Expired";if(e>90*Tr){const s=Math.floor(e/xS);return`${s} ${s===1?"month":"months"} remaining`}if(e>7*Tr){const s=Math.floor(e/Tr);return`${s} ${s===1?"day":"days"} remaining`}if(e>=2*Tr){const s=Math.floor(e/Tr),a=Math.floor(e%Tr/oa);return`${s} ${s===1?"day":"days"} ${a}h remaining`}if(e>=2*oa){const s=Math.floor(e/oa),a=Math.floor(e%oa/Ii);return`${s}h ${String(a).padStart(2,"0")}m remaining`}if(e>=Ii){const s=Math.floor(e/Ii),a=Math.floor(e%Ii);return`${s}m ${String(a).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function jS({expiresAt:e}){const[s,a]=h.useState(()=>e-Date.now()/1e3),o=s<2*oa;h.useEffect(()=>{const u=setInterval(()=>a(e-Date.now()/1e3),o?1e3:6e4);return()=>clearInterval(u)},[e,o]);const l=s<300;return n.jsx("span",{className:`ttl-badge ${l?"ttl-warn":"ttl-ok"}`,children:wS(s)})}function fs({icon:e,title:s,text:a,children:o}){return n.jsxs("div",{className:"empty-state",children:[e&&n.jsx("div",{className:"empty-state-icon",children:e}),n.jsx("div",{className:"empty-state-title",children:s}),a&&n.jsx("div",{className:"empty-state-text",children:a}),o]})}function SS(e){const s=Math.floor(e/86400);if(s>=1)return`${s} day${s===1?"":"s"}`;const a=Math.floor(e/3600);if(a>=1)return`${a} hour${a===1?"":"s"}`;const o=Math.ceil(e/60);return`${o} minute${o===1?"":"s"}`}const bS=[{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 kS({item:e,onClose:s,onSuccess:a}){var P;const{user:o,activeDomain:l,groupId:u}=wt(),[f,p]=h.useState(null);h.useEffect(()=>{let I=!1;return z.getProfile(e.profile_id).then(B=>{var O;I||p(((O=B==null?void 0:B.ttl)==null?void 0:O.max)??null)}).catch(()=>{}),()=>{I=!0}},[e.profile_id]);const g=e.remaining_seconds??0,v=bS.filter(I=>I.seconds>g&&(f===null||I.seconds<=f)),y=((P=v[0])==null?void 0:P.seconds)??2592e3,[w,x]=h.useState(y);h.useEffect(()=>{var I;if(f!==null&&w>f){const B=(I=v[v.length-1])==null?void 0:I.seconds;B&&x(B)}},[f]);const[b,N]=h.useState(!1),[S,k]=h.useState(""),E=Object.entries(e.frame).filter(([I])=>I!=="profile"&&I!=="path"),T=async()=>{var I;if(o){N(!0),k("");try{const B=e.authorization_id,O=await z.getGateContent(B);if(!O)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const K=await z.getProfile(e.profile_id),_=e.frame,U=O.context??{},Z=e.attested_domains[0]||l||"owner",V=await zi(_,K),M=await Sp(U,K),[re,de]=await Promise.all([Ki(O.gateContent.intent),Ki(JSON.stringify({profile:e.profile_id,path:e.path,domain:Z}))]);if(!u)throw new Error("No active group; cannot extend mandate.");const X=(((I=e.deferred_commitment_domains)==null?void 0:I.length)??0)>0?"review":"automatic",xe=await bp(K),Ne=await z.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,profile_hash:xe,supported_versions:["0.7"],bounds:_,bounds_hash:V,scope_hash:M,domain:Z,did:o.did,mandate_owners:[{did:o.did}],gate_content_hashes:{intent:re},execution_context_hash:de,group_id:u,commitment_mode:X,ttl:w});await z.pushGateContent(kp(Ne,{boundsHash:V,contextHash:M,context:U,path:e.path,gateContent:O.gateContent})),a()}catch(B){k(B instanceof Error?B.message:"Extension failed")}finally{N(!1)}}};return n.jsx("div",{className:"modal-backdrop",onClick:I=>I.target===I.currentTarget&&s(),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Extend mandate"}),n.jsx("button",{className:"modal-close",onClick:s,children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Bt(e.profile_id)," / ",e.path]}),E.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:E.map(([I,B])=>`${I}=${B}`).join(" · ")})]}),n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),g>0&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",SS(g),". Only longer durations are shown."]}),n.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:v.length===0?n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):v.map(I=>n.jsx("button",{className:`btn ${w===I.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>x(I.seconds),style:{minWidth:"3.5rem"},children:I.label},I.seconds))})]}),n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),S&&n.jsx("div",{className:"error-message",children:S})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-secondary",onClick:s,disabled:b,children:"Cancel"}),n.jsx("button",{className:"btn btn-primary",onClick:T,disabled:b,children:b?"Extending...":"Extend"})]})]})})}function _h(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Lh(e){return e.split("@")[1]??""}function NS(e,s){return Lh(e).localeCompare(Lh(s),void 0,{numeric:!0})>0}function Pp(e,s){const a=_h(e);let o;for(const l of s)_h(l.id)===a&&(!o||NS(l.id,o.id))&&(o=l);return o}function $p(e,s){var o;if(!s)return{};const a={};for(const l of s.keyOrder){if(l==="profile"||l==="path")continue;if(e[l]!==void 0){a[l]=e[l];continue}const u=(o=s.fields[l])==null?void 0:o.default;(typeof u=="string"||typeof u=="number"&&Number.isFinite(u))&&(a[l]=u)}return a}function _p(e,s){return $p(e,s.boundsSchema)}function Lp(e,s){return $p(e,s.scopeSchema)}function CS(e,s,a){return[...e].sort((o,l)=>{if(a){if(o.authorization_id===a&&l.authorization_id!==a)return-1;if(l.authorization_id===a&&o.authorization_id!==a)return 1}const u=Mi(o,s),f=Mi(l,s),p={active:0,pending:1,expired:2,revoked:3,archived:4};return p[u]!==p[f]?p[u]-p[f]:new Date(l.created_at).getTime()-new Date(o.created_at).getTime()})}function ES(e,s){const a=(s==null?void 0:s.keyedApprovers)??(s==null?void 0:s.approvers)??[];return e.length===0||a.length===0?!1:e.length!==a.length||e.some(o=>!a.includes(o))||a.some(o=>!e.includes(o))}function TS({item:e,newerProfile:s,area:a,revokedSet:o,expandedHash:l,gateCache:u,gateLoading:f,copiedHash:p,revokingHash:g,copyingHash:v,profileConfigCache:y,mode:w,ownerLabel:x,isAdmin:b,onExpand:N,onCopyHash:S,onCopy:k,onRevoke:E,onExtend:T,archivedSet:P,archivingHash:I,onArchive:B,highlightHash:O,needsReapprovalSet:K}){var fe;const _=Bc(e,{revokedSet:o}),U=_==="active"&&((K==null?void 0:K.has(e.authorization_id))??!1),Z=Pm(e,{revokedSet:o,archivedSet:P}),V=!x&&!!B&&Rm(_),M=l===e.authorization_id,re=u[e.authorization_id],de=_==="active"||_==="pending"||_==="expired",X=Object.entries(e.frame).filter(([me])=>me!=="profile"&&me!=="path"),xe=vs(e.profile_id),Ne=new Map(tp(e.frame,xe,"limits").map(me=>[me.key,me])),ee=me=>{var Te;return((Te=Ne.get(me))==null?void 0:Te.label)??me},Q=(me,Te)=>{var Le;return((Le=Ne.get(me))==null?void 0:Le.value)??String(Te)},q=y.get(e.profile_id)??null,A=(((fe=q==null?void 0:q.approvers)==null?void 0:fe.length)??0)>0,$=new Map;if(q!=null&&q.caps&&w==="team")for(const[me,Te]of X){const Le=q.caps[me];typeof Le=="number"&&Number(Te)>Le&&$.set(me,{authorized:Number(Te),cap:Le})}const ae=$.size>0,ne=w==="team"&&ES(e.approvers_frozen??[],q),ve=Array.from($.entries()).map(([me,Te])=>`${me}: ${Te.authorized} (cap ${Te.cap})`).join(", "),Se=Array.from($.entries()).map(([me,Te])=>`${me}: ${Te.authorized} → ${Te.cap}`).join(", "),Y=ae?A?$.size===1?`Above team cap: ${ve} — actions require approval`:`Above team cap (${$.size}): ${ve} — actions require approval`:$.size===1?`Reduced by hard cap: ${Se}`:`Reduced by hard cap (${$.size}): ${Se}`:"",ce=ae?A?"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,ie=_r(e.profile_id),te=ie.name,ze=s?n.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:[n.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[te,"@",s.version," available"]}),s.whatsNew?n.jsxs(n.Fragment,{children:[" — ",s.whatsNew]}):null,n.jsx("br",{}),n.jsxs("span",{children:["This mandate stays on ",e.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,Ue=O!=null&&e.authorization_id===O;return n.jsx("div",{className:`card mandate-card${Ue?" card-highlight":""}`,style:{marginBottom:0},children:n.jsxs("div",{className:"id-body",children:[e.created_at&&n.jsxs("div",{className:"obj-line",children:["since ",new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})]}),ze,x&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",n.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:x})]}),n.jsxs("div",{className:"auth-card-header",children:[n.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:e.title||te}),n.jsx(yS,{status:_}),U&&n.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-primary)",background:"transparent",border:"1px dashed var(--text-primary)",borderRadius:"4px",padding:"2px 6px"},children:"Needs re-approval"}),ie.testSetup&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),_==="active"&&e.earliest_expiry&&n.jsx(jS,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),_==="expired"&&(()=>{const me=u0(e,_);return me?n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(me.iso).toLocaleString()}`,children:new Date(me.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}):null})()]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[(e.required_domains.length>1||e.missing_domains.length>0)&&e.required_domains.map(me=>n.jsx(vS,{domain:me,attested:e.attested_domains.includes(me)},me)),e.deferred_commitment_domains.length>0&&n.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"}),ae&&n.jsx("span",{title:ce,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"transparent",color:"var(--text-primary)",border:A?"1px dashed var(--text-primary)":"2px solid var(--text-primary)",fontWeight:600,cursor:"help"},children:Y}),ne&&n.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.65rem",padding:"0.15rem 0.5rem",borderRadius:"0.25rem",background:"transparent",color:"var(--text-primary)",fontWeight:600,border:"1px dashed var(--text-primary)",cursor:"pointer",lineHeight:1.4},onClick:()=>k(e),disabled:v===e.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:v===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),X.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:X.map(([me,Te],Le)=>{const ge=$.get(me);return n.jsxs("span",{children:[Le>0&&" · ",ge?A?n.jsxs("span",{title:`Team cap on ${me} is ${ge.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${ge.authorized}.`,children:[n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[ee(me),": ",Q(me,Te)]}),n.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",ge.cap]})]}):n.jsxs("span",{title:`Team cap on ${me} is ${ge.cap} with no approvers configured (hard cap). Authorized for ${ge.authorized}; effective ${ge.cap}.`,children:[n.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[ee(me),": ",Q(me,Te)]}),n.jsxs("span",{style:{marginLeft:"0.25rem",fontWeight:700},children:["→"," ",ge.cap]})]}):n.jsxs("span",{children:[ee(me),": ",Q(me,Te)]})]},me)})}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[V&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>B(e.authorization_id,!Z),disabled:I===e.authorization_id,title:Z?"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:I===e.authorization_id?Z?"Unarchiving…":"Archiving…":Z?"↩ Unarchive":"⊟ Archive"}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>N(e),children:M?"▲ Hide Details":"▼ Details"})]}),M&&n.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[X.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),n.jsx("dl",{className:"review-grid",children:X.map(([me,Te])=>{var Le;return n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{title:(Le=Ne.get(me))==null?void 0:Le.hint,children:ee(me)}),n.jsx("dd",{children:Q(me,Te)})]},me)})})]}),(re==null?void 0:re.context)&&Object.keys(re.context).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Scope"}),n.jsx("dl",{className:"review-grid",children:Object.entries(re.context).map(([me,Te])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:me}),n.jsx("dd",{title:String(Te),children:Np(me,Te,re.contextLabels)})]},me))})]}),n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),f===e.authorization_id?n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):re?n.jsx("div",{className:"gate-content-block",children:n.jsx("div",{className:"gate-content-item",children:n.jsx("div",{className:"gate-content-text",children:re.gateContent.intent})})}):n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(e.created_at).toLocaleString(),e.earliest_expiry&&` · Expires: ${new Date(e.earliest_expiry).toLocaleString()}`]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:e.authorization_id}),n.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>S(e.authorization_id),children:p===e.authorization_id?"copied":"copy"})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!x&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>k(e),disabled:v===e.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:v===e.authorization_id?"Copying…":"⧉ Copy"}),!x&&(_==="active"||_==="pending")&&n.jsx("button",{className:U?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>k(e,{asEdit:!0}),disabled:v===e.authorization_id,title:U?"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:U?"⚠ Re-approve":"✎ Edit"}),!x&&de&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>T(e),children:"↻ Extend"}),x&&b&&_!=="revoked"?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>E(e.authorization_id,x,te),disabled:g===e.authorization_id,children:g===e.authorization_id?"Revoking…":"Revoke"}):!x&&(_==="active"||_==="pending")?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>E(e.authorization_id),disabled:g===e.authorization_id,children:g===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]})},e.authorization_id)}function AS(){const[e,s]=h.useState([]),[a,o]=h.useState(!0),[l,u]=h.useState([]),[f,p]=h.useState(!1),[g,v]=h.useState(new Map),[y,w]=h.useState("mine"),[x,b]=h.useState("active"),[N,S]=h.useState(null),[k,E]=h.useState(null),[T,P]=ys(),[I,B]=h.useState(()=>T.get("new")==="1"),[O]=h.useState(()=>T.get("profile")),[K,_]=h.useState(()=>T.get("highlight")),[U,Z]=h.useState(null),[V,M]=h.useState({}),[re,de]=h.useState(null),[X,xe]=h.useState(null),[Ne,ee]=h.useState(null),[Q,q]=h.useState(new Set),[A,$]=h.useState(null),[ae,ne]=h.useState(new Set),[ve,Se]=h.useState(null),[Y,ce]=h.useState(null),[ie,te]=h.useState(new Set),ze=Sn(),{group:Ue,groupId:fe,domain:me,mode:Te,activeTeam:Le}=wt(),ge=(Le==null?void 0:Le.isAdmin)===!0,[nt,Ze]=h.useState(()=>new Map),[Ye,He]=h.useState([]);h.useEffect(()=>{z.getLabelManifests().then(He).catch(()=>{})},[]);const dt=h.useCallback(()=>{o(!0),z.getMyAttestations().then(s).catch(()=>{}).finally(()=>o(!1))},[]),ft=h.useCallback(()=>{z.getArchivedMandates().then(ue=>ne(new Set(ue))).catch(()=>{})},[]);h.useEffect(()=>{ft()},[ft]);const Me=h.useCallback(()=>{z.getEnrichedAuthorizations().then(ue=>te(new Set(ue.filter(Ce=>Ce.needsReapproval).map(Ce=>Ce.authorizationId)))).catch(()=>{})},[]);h.useEffect(()=>{Me()},[Me]);const pe=async(ue,Ce)=>{Se(ue);try{const Re=await z.setMandateArchived(ue,Ce);ne(new Set(Re)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(Re){alert(Re instanceof Error?Re.message:"Failed to update archive")}finally{Se(null)}},Pe=h.useCallback(()=>{fe&&(p(!0),z.listTeamAuthorizations(fe).then(u).catch(()=>{}).finally(()=>p(!1)))},[fe]);Oe("attestation-changed",()=>{dt(),ge&&fe&&Pe(),Me()}),h.useEffect(()=>{if(!K)return;T.get("highlight")&&(T.delete("highlight"),P(T,{replace:!0}));const ue=window.setTimeout(()=>_(null),3e3);return()=>window.clearTimeout(ue)},[]),Ot(dt,3e5),h.useEffect(()=>{y==="team"&&ge&&fe&&l.length===0&&!f&&Pe()},[y,ge,fe,l.length,f,Pe]),h.useEffect(()=>{let ue=!1;return z.listProfiles().then(Ce=>{if(ue)return;const Re=jt=>jt.replace(/@.*$/,"").split("/").pop()??jt,De=jt=>jt.split("@")[1]??"",Xe=new Map;for(const jt of Ce){const St=Re(jt.id),zr=Xe.get(St);(!zr||De(jt.id).localeCompare(De(zr.id),void 0,{numeric:!0})>0)&&Xe.set(St,jt)}v(Xe)}).catch(()=>{}),()=>{ue=!0}},[]);const Be=h.useCallback(ue=>{const Ce=St=>St.replace(/@.*$/,"").split("/").pop()??St,Re=St=>St.split("@")[1]??"",De=g.get(Ce(ue));if(!De)return;const Xe=Re(ue),jt=Re(De.id);if(!(!Xe||!jt))return jt.localeCompare(Xe,void 0,{numeric:!0})>0?De:void 0},[g]),G=h.useCallback(ue=>Dn(ue,[...g.values()]),[g]);h.useEffect(()=>{if(Te!=="team"||!fe)return;const ue=y==="mine"?e:l;if(ue.length===0)return;const Ce=[...new Set(ue.map(Re=>Re.profile_id))].filter(Re=>!nt.has(Re));if(Ce.length!==0){Ze(Re=>{const De=new Map(Re);for(const Xe of Ce)De.set(Xe,null);return De});for(const Re of Ce)Promise.all([z.getTeamProfileConfig(fe,Re),z.getApproversPubkeys(fe,Re).catch(()=>null)]).then(([De,Xe])=>{const jt=De&&Xe?{...De,keyedApprovers:Xe.map(St=>St.userId)}:De;Ze(St=>new Map(St).set(Re,jt))}).catch(()=>{})}},[e,l,y,fe,Te,nt]);const J=async ue=>{if(U===ue.authorization_id){Z(null);return}Z(ue.authorization_id);const Ce=ue.authorization_id;if(!(Ce in V)){de(ue.authorization_id);try{const Re=await z.getGateContent(Ce);M(De=>({...De,[Ce]:Re}))}catch{M(Re=>({...Re,[Ce]:null}))}finally{de(null)}}},ye=ue=>{navigator.clipboard.writeText(ue).then(()=>{ee(ue),setTimeout(()=>ee(null),2e3)})},Ve=async(ue,Ce)=>{var Re;if(!fe){alert("No active group; cannot copy mandate.");return}ce(ue.authorization_id);try{const De=ue.authorization_id;let Xe=V[De]??null;De in V||(Xe=await z.getGateContent(De),M(kn=>({...kn,[De]:Xe})));const jt=Object.fromEntries(Object.entries(ue.frame).filter(([kn])=>kn!=="profile"&&kn!=="path")),St=(Xe==null?void 0:Xe.context)??{},zr=((Re=Xe==null?void 0:Xe.gateContent)==null?void 0:Re.intent)??"",hr=ue.deferred_commitment_domains.length>0?"review":"automatic",Fr=ue.attested_domains[0]||me||"owner",Vn=Date.parse(ue.created_at),mr=ue.earliest_expiry?Date.parse(ue.earliest_expiry):NaN,lo=Number.isFinite(Vn)&&Number.isFinite(mr)&&mr>Vn?Math.round((mr-Vn)/1e3):void 0;let ya=ue.profile_id,va=jt,bn=St,xs;const xa=await z.listProfiles(),Mr=Pp(ue.profile_id,xa);if(Mr&&Mr.id!==ue.profile_id){const kn=await z.getProfile(Mr.id);ya=Mr.id,va=_p(jt,kn),bn=Lp(St,kn),xs=ue.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ya,groupId:fe,groupName:(Ue==null?void 0:Ue.name)??null,domain:Fr,isPersonal:!!(Ue!=null&&Ue.isPersonal),upgradedFromProfileId:xs})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:va,context:bn,gateContent:{intent:zr},templateMode:hr,templateTtl:lo})),Ce!=null&&Ce.asEdit?sessionStorage.setItem("agentEditReplaces",ue.authorization_id):sessionStorage.removeItem("agentEditReplaces"),ze("/mandates/new/intent")}catch(De){alert(De instanceof Error?De.message:"Failed to copy mandate")}finally{ce(null)}},Ge=async(ue,Ce,Re)=>{const De=Ce&&Re?`Revoke ${Ce}'s ${Re} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(De)){$(ue);try{await z.revokeAttestation(ue),q(Xe=>new Set(Xe).add(ue)),z.resyncGates().catch(()=>{}),Ce&&fe&&Pe()}catch(Xe){alert(Xe instanceof Error?Xe.message:"Failed to revoke mandate")}finally{$(null)}}},rt=y==="mine"?e:l,Vt=y==="mine"?a:f,Dt=y==="mine"?{revokedSet:Q,archivedSet:ae}:{revokedSet:Q},et=ue=>Mi(ue,Dt),W={active:0,pending:0,expired:0,revoked:0,archived:0};for(const ue of rt)W[et(ue)]+=1;const we=y==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],Ie=(()=>{const ue=new Map;for(const Ce of rt){if(et(Ce)!==x)continue;const Re=Rn(Ce.profile_id),De=ue.get(Re);De?De.count+=1:ue.set(Re,{shortId:Re,icon:Pr(Ce.profile_id),name:G(Ce.profile_id),count:1})}return[...ue.values()].sort((Ce,Re)=>Ce.name.localeCompare(Re.name))})(),st=Ie.reduce((ue,Ce)=>ue+Ce.count,0),yt=CS(rt.filter(ue=>{if(et(ue)!==x||N!==null&&Rn(ue.profile_id)!==N)return!1;if(k!==null){const Ce=ue.deferred_commitment_domains.length>0;if(k==="review"&&!Ce||k==="auto"&&Ce)return!1}return!0}),Dt,K),qe=h.useMemo(()=>{const ue=new Map;for(const Ce of yt){const Re=Rn(Ce.profile_id);let De=ue.get(Re);De||(De={shortId:Re,icon:Pr(Ce.profile_id),name:G(Ce.profile_id),items:[]},ue.set(Re,De)),De.items.push(Ce)}return[...ue.values()].sort((Ce,Re)=>Re.items.length-Ce.items.length||Ce.name.localeCompare(Re.name))},[yt,G]),Et=h.useCallback(ue=>[...new Set(Ye.filter(Ce=>{var Re;return Ce.profile===ue||Object.values(((Re=Ce.toolGating)==null?void 0:Re.overrides)??{}).some(De=>(De==null?void 0:De.profile)===ue)}).map(Ce=>Ce.name))],[Ye]),kt={revokedSet:Q,expandedHash:U,gateCache:V,gateLoading:re,copiedHash:Ne,revokingHash:A,copyingHash:Y,profileConfigCache:nt,mode:Te,activeDomain:me,group:Ue,groupId:fe,onExpand:J,onCopyHash:ye,onCopy:Ve,onRevoke:Ge,onExtend:xe,highlightHash:K},Zt={...kt,archivedSet:ae,archivingHash:ve,onArchive:pe,needsReapprovalSet:ie};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Mandates"}),n.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),n.jsx("button",{className:"btn btn-primary",onClick:()=>B(!0),children:"+ New mandate"})]}),I&&n.jsx("div",{className:"modal-backdrop",onClick:()=>{B(!1),(T.get("new")||T.get("profile"))&&(T.delete("new"),T.delete("profile"),P(T,{replace:!0}))},children:n.jsxs("div",{className:"modal",onClick:ue=>ue.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h2",{className:"modal-title",children:"New mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>{B(!1),(T.get("new")||T.get("profile"))&&(T.delete("new"),T.delete("profile"),P(T,{replace:!0}))},children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.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."}),n.jsx(pS,{onDismiss:()=>B(!1),preselectProfileId:O})]})]})}),ge&&n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[n.jsx("button",{className:`nav-tab${y==="mine"?" active":""}`,onClick:()=>{w("mine"),b("active"),S(null),E(null),Z(null)},children:"Mine"}),n.jsx("button",{className:`nav-tab${y==="team"?" active":""}`,onClick:()=>{w("team"),b("active"),S(null),E(null),Z(null)},children:"Team"})]}),n.jsx("div",{className:"nav-tabs",children:we.map(ue=>n.jsxs("button",{className:`nav-tab${x===ue?" active":""}`,onClick:()=>{b(ue),S(null),E(null)},children:[ue.charAt(0).toUpperCase()+ue.slice(1)," (",W[ue],")"]},ue))}),st>0&&n.jsxs("div",{className:"mandate-filters",children:[n.jsx(eu,{areas:Ie,selected:N,onSelect:S,totalCount:st}),n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which mode",children:["auto","review"].map(ue=>{const Ce=k===ue;return n.jsx("button",{type:"button",role:"tab",className:"ftab","data-testid":`mode-filter-${ue}`,"aria-selected":Ce,onClick:()=>E(Ce?null:ue),children:ue==="auto"?"Automatic":"Review"},ue)})})]}),Vt&&rt.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):yt.length===0?n.jsx(fs,{icon:"☰",title:"No mandates",text:x==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${x} mandates found.`}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:qe.map(ue=>n.jsxs("section",{"data-testid":"mandate-area","data-area":ue.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(ga,{icon:ue.icon}),n.jsx("b",{children:ue.name}),n.jsxs("span",{className:"meta",children:[ue.items.length," mandate",ue.items.length===1?"":"s",Et(ue.shortId).length>0&&n.jsxs(n.Fragment,{children:[" · via ",Et(ue.shortId).join(", ")]})]})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:ue.items.map(Ce=>{const Re=y==="team"?Ce:null,De=Re!=null&&Re.owner?Re.owner.name??Re.owner.email??Re.owner.userId:void 0;return n.jsx(TS,{item:Ce,newerProfile:Be(Ce.profile_id),area:ue.name,ownerLabel:De,isAdmin:ge,...y==="mine"?Zt:kt},Ce.authorization_id)})})]},ue.shortId))}),X&&n.jsx(kS,{item:X,onClose:()=>xe(null),onSuccess:()=>{xe(null),dt()}})]})}function Ri(e){return typeof e=="string"&&e.length>0}function IS(e){if(e===null||typeof e!="object")return!1;const s=e;return!(!Ri(s.filename)||!Ri(s.contentType)||!Ri(s.contentBase64)||!Ri(s.sha256)||s.pages!==void 0&&typeof s.pages!="number")}function zp(e){return e.length<=9?e:`${e.slice(0,4)}…${e.slice(-4)}`}function RS(e){return`data:${e.contentType};base64,${e.contentBase64}`}function PS(e){if(e!==void 0)return e===1?"1 page":`${e} pages`}function $S(e){const s=atob(e.contentBase64),a=new Uint8Array(new ArrayBuffer(s.length));for(let o=0;o<s.length;o++)a[o]=s.charCodeAt(o);return a}function Pt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Rt(e,s=!1){return e==null?"—":typeof e=="string"?e:typeof e=="boolean"?String(e):typeof e=="number"?s||Number.isInteger(e)?String(e):String(Math.round(e*100)/100):"—"}function _S(e){return e==null?!1:typeof e=="string"||Array.isArray(e)?e.length>0:!0}function Fp(e,s){return e.length===0?"—":e.every(a=>!Pt(a)&&!Array.isArray(a))?e.map(a=>Rt(a,s)).join(", "):e.length===1?"1 entry":`${e.length} entries`}function In(e,s,a){const o=s?Object.keys(s).filter(l=>l in e):Object.keys(e);return o.length===0?"—":o.map(l=>{var g,v;const u=e[l],f=((g=s==null?void 0:s[l])==null?void 0:g.title)??Ht(l),p=Pt(u)?In(u,(v=s==null?void 0:s[l])==null?void 0:v.properties,a):Array.isArray(u)?Fp(u,a):Rt(u,a);return`${f}: ${p}`}).join(" · ")}function Mp(e,s,a){const o=s?Object.keys(s).filter(p=>e.some(g=>p in g)):[...new Set(e.flatMap(p=>Object.keys(p)))],l=o.map(p=>{var g,v,y;return{key:p,label:(a&&((v=(g=a.hints)==null?void 0:g.labels)==null?void 0:v[`${a.pathPrefix}.${p}`]))??((y=s==null?void 0:s[p])==null?void 0:y.title)??Ht(p)}}),u=!!a,f=e.map(p=>({cells:o.map(g=>{var x,b,N;const v=p[g];if(a&&!Pt(v)&&hs((x=a.hints)==null?void 0:x.money,`${a.pathPrefix}.${g}`))return{...Wp(v,a.currency),sealed:u};const y=Pt(v)?In(v,(b=s==null?void 0:s[g])==null?void 0:b.properties,!1):Rt(v),w=Pt(v)?In(v,(N=s==null?void 0:s[g])==null?void 0:N.properties,!0):Rt(v,!0);return w===y?{value:y,sealed:u}:{value:y,valueTitle:w,sealed:u}})}));return{columns:l,rows:f}}function LS(e){return Pt(e)?In(e,void 0,!1):Array.isArray(e)?Fp(e,!1):Rt(e)}function Op(e,s){return Array.isArray(e)&&e.length>0&&e.every(Pt)?{table:Mp(e,void 0,{hints:s==null?void 0:s.hints,pathPrefix:`${(s==null?void 0:s.key)??""}[]`,currency:s==null?void 0:s.currency})}:Pt(e)?{text:In(e,void 0,!1)}:null}function zS(e){return e.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 FS(e,s){var l;if(Array.isArray(e)){if(e.length===0)return{value:"—"};if(e.every(y=>!Pt(y)&&!Array.isArray(y))){if(e.every(x=>typeof x=="string"))return{lines:e};const y=e.map(x=>Rt(x)).join(", "),w=e.map(x=>Rt(x,!0)).join(", ");return w===y?{value:y}:{value:y,valueTitle:w}}const u=(l=s==null?void 0:s.items)==null?void 0:l.properties,f=e.map(y=>Pt(y)?In(y,u,!1):Rt(y)),p=e.map(y=>Pt(y)?In(y,u,!0):Rt(y,!0)),g=f.map((y,w)=>y===p[w]?void 0:p[w]),v=e.every(Pt)?Mp(e,u):void 0;return{lines:f,...g.some(y=>y!==void 0)?{lineTitles:g}:{},...v?{table:v}:{}}}if(Pt(e)){const u=s==null?void 0:s.properties,f=u?Object.keys(u).filter(v=>v in e):Object.keys(e);if(f.length>0&&f.every(v=>!Pt(e[v])&&!Array.isArray(e[v])))return{sublist:f.map(y=>{var S;const w=e[y],x=((S=u==null?void 0:u[y])==null?void 0:S.title)??Ht(y),b=Rt(w),N=Rt(w,!0);return N===b?{key:y,label:x,value:b}:{key:y,label:x,value:b,valueTitle:N}})};const p=In(e,u,!1),g=In(e,u,!0);return g===p?{value:p}:{value:p,valueTitle:g}}if(typeof e=="string"&&(s==null?void 0:s.contentMediaType)==="text/x-diff")return{diffLines:zS(e)};const a=Rt(e),o=Rt(e,!0);return o===a?{value:a}:{value:a,valueTitle:o}}function MS(e){let s;try{s=JSON.parse(e)}catch{return null}return Pt(s)?s:null}function fr(e){const s=e!=null&&e.structured&&Object.keys(e.structured).length>0?e.structured:void 0;if(s)return{obj:s,schema:e==null?void 0:e.outputSchema};const a=e!=null&&e.text?MS(e.text):null;return a?{obj:a}:null}function Yi(e){const s=fr(e);if(!s)return[];const{obj:a,schema:o}=s,l=(o==null?void 0:o.properties)??{},u=[...new Set([...Object.keys(l),...Object.keys(a)])],f=[];for(const p of u){if(!(p in a))continue;const g=l[p],v=(g==null?void 0:g.title)??Ht(p),y={key:p,label:v,...FS(a[p],g)};g!=null&&g.description&&(y.description=g.description),f.push(y)}return f}function Bp(e,s){const a=fr(e);if(a){const l=Yi(e),u=s==null?void 0:s.fields;let f;if(u&&u.length>0){const v=new Map(l.map(y=>[y.key,y]));f=u.map(y=>v.get(y)).filter(y=>y!==void 0)}else f=l.filter(v=>_S(a.obj[v.key]));const p=new Set(f.map(v=>v.key)),g=l.filter(v=>!p.has(v.key));return{kind:"structured",fields:f,moreFields:g,totalFields:l.length}}const o=e==null?void 0:e.text;return o&&o.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:o}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function zh(e){return e?e.lines?`lines:${JSON.stringify(e.lines)}`:e.sublist?`sublist:${JSON.stringify(e.sublist.map(s=>[s.key,s.value]))}`:e.diffLines?`diffLines:${JSON.stringify(e.diffLines)}`:`value:${e.value??""}`:""}function Pi(e){return{kind:e.length>0?"structured":"empty",fields:e,moreFields:[],totalFields:e.length}}function OS(e,s,a){const o=fr(e),l=fr(s);if(!o&&!l){const x=(e==null?void 0:e.text)??"",b=(s==null?void 0:s.text)??"";return x===b?{approved:Pi([]),current:Pi([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:x},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:b},unchanged:!1}}const u=new Map(Yi(e).map(x=>[x.key,x])),f=new Map(Yi(s).map(x=>[x.key,x])),g=[...new Set([...u.keys(),...f.keys()])].filter(x=>x===(a==null?void 0:a.excludeKey)?!1:zh(u.get(x))!==zh(f.get(x))),v=a!=null&&a.fields&&a.fields.length>0?[...a.fields.filter(x=>g.includes(x)),...g.filter(x=>!a.fields.includes(x))]:g,y=v.map(x=>u.get(x)).filter(x=>x!==void 0),w=v.map(x=>f.get(x)).filter(x=>x!==void 0);return{approved:Pi(y),current:Pi(w),unchanged:g.length===0}}function BS(e){const s=e==null?void 0:e.structured;if(Array.isArray(s)&&s.every(Pt))return s;if(e!=null&&e.text){let a;try{a=JSON.parse(e.text)}catch{return null}if(Array.isArray(a)&&a.every(Pt))return a}return null}function oo(e){const s=Rt(e),a=Rt(e,!0);return a===s?{value:s}:{value:s,valueTitle:a}}function Dp(e){return!e||e.status!=="ok"?[]:Yi(e.body)}function jc(e){if(!e)return"Not read.";switch(e.status){case"not_found":return e.message?`The system answered: ${e.message}`:"Not found in the system.";case"none":return"Nothing to read.";default:return"Not available right now."}}function Up(e,s,a){var g;const o=Dp(e);if(o.length===0)return{rawId:Rt(s),context:[],unresolved:jc(e)};const l=e&&e.status==="ok"?(g=fr(e.body))==null?void 0:g.obj:void 0,u=o.find(v=>["name","title","label"].includes(v.key))??o.find(v=>typeof(l==null?void 0:l[v.key])=="string"&&!v.lines&&!v.sublist&&!v.diffLines),f=a==null?void 0:a.pathPrefix,p=o.filter(v=>v.key!==(u==null?void 0:u.key)&&v.key!=="id").map(v=>{var N,S;if(!f)return v;const y=`${f}.${v.key}`,w=ua(a==null?void 0:a.displayHints,y,v.label);if(!hs((N=a==null?void 0:a.displayHints)==null?void 0:N.money,y)&&!hs((S=a==null?void 0:a.displayHints)==null?void 0:S.percent,y))return w===v.label?v:{...v,label:w};const{value:x,valueTitle:b}=Ji(l==null?void 0:l[v.key],a==null?void 0:a.displayHints,y,a==null?void 0:a.currency);return{...v,label:w,value:x,valueTitle:b}});return{name:u==null?void 0:u.value,rawId:Rt(s),context:p}}const DS=new Set(["id","name","title","label"]);function hs(e,s){return!!(e!=null&&e.includes(s))}function ua(e,s,a){var o;return((o=e==null?void 0:e.labels)==null?void 0:o[s])??a}function Wp(e,s){const a=typeof e=="number"?e:Number(e);return Number.isFinite(a)?{value:`${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${s?` ${s}`:""}`}:oo(e)}function US(e){return typeof e!="number"&&typeof e!="string"?oo(e):{value:`${e} %`}}function Ji(e,s,a,o){return hs(s==null?void 0:s.money,a)?Wp(e,o):hs(s==null?void 0:s.percent,a)?US(e):oo(e)}function Hp(e,s){return hs(e==null?void 0:e.hidden,s)}function WS(e,s,a){var f;const o=e==null?void 0:e.currencyField;if(!o)return;const l=o.indexOf(".");if(l<0){const p=s[o];return typeof p=="string"?p:void 0}const u=(f=a(o.slice(0,l)))==null?void 0:f[o.slice(l+1)];return typeof u=="string"?u:void 0}function HS(e,s,a,o){const l=e.forEach??"",u=e.attach,f=e.elements??[],p=Math.min(s.length,f.length),g=s.slice(0,p),v=f.slice(0,p),y=[...new Set(g.flatMap(S=>Object.keys(S)))].filter(S=>S!==e.sourceArg).filter(S=>!Hp(a,`${l}[].${S}`)),w=new Map;if(u)for(const S of v)for(const k of Dp(S))w.has(k.key)||w.set(k.key,k.label);const x=u?[...w.keys()].filter(S=>!DS.has(S)):[],b=[];u&&b.push({key:`__attach:${u}`,label:ua(a,`${l}[].${u}`,Ht(e.sourceArg??u))});for(const S of y)b.push({key:`bound:${S}`,label:ua(a,`${l}[].${S}`,Ht(S))});for(const S of x)b.push({key:`attached:${S}`,label:ua(a,`${l}[].${u}.${S}`,w.get(S)??Ht(S))});const N=g.map((S,k)=>{var I;const E=v[k],T=[];if(u){const B=Up(E,e.sourceArg?S[e.sourceArg]:void 0),O=B.name?`${B.name} (${B.rawId})`:B.unresolved?`${B.rawId} — ${B.unresolved}`:B.rawId;T.push({value:O,sealed:!1})}for(const B of y){const{value:O,valueTitle:K}=Ji(S[B],a,`${l}[].${B}`,o);T.push({value:O,valueTitle:K,sealed:!0})}const P=E&&E.status==="ok"?(I=fr(E.body))==null?void 0:I.obj:void 0;for(const B of x){const O=P==null?void 0:P[B],{value:K,valueTitle:_}=O!==void 0?Ji(O,a,`${l}[].${u}.${B}`,o):{value:"—",valueTitle:void 0};T.push({value:K,valueTitle:_,sealed:!1})}return{cells:T}});return{columns:b,rows:N,...e.overflow?{overflowNote:`${e.overflow.total-e.overflow.shown} more not shown`}:{}}}function VS(e){return`${Ht(e)} — from the system`}function GS(e){var l;const s=VS(e.tool),a=e.result;if(e.kind==="document"){if(a&&a.status==="ok"){const u=(l=fr(a.body))==null?void 0:l.obj;return u&&IS(u)?{heading:s,document:u}:{heading:s,note:"Could not show a preview — the connector’s answer was not in the expected shape."}}return(a==null?void 0:a.status)==="unavailable"&&a.reason==="no_connector"?null:{heading:s,note:jc(a)}}if(!a||a.status!=="ok")return{heading:s,note:jc(a)};const o=BS(a.body);if(o){if(o.length===0)return{heading:s,note:"Nothing found."};const u=[...new Set(o.flatMap(g=>Object.keys(g)))],f=u.map(g=>({key:g,label:Ht(g)})),p=o.map(g=>({cells:u.map(v=>({...oo(g[v]),sealed:!1}))}));return{heading:s,table:{columns:f,rows:p}}}return{heading:s,body:Bp(a.body,{fields:e.fields})}}function KS(e,s,a){const o=new Map(s.filter(x=>x.attach&&!x.forEach).map(x=>[x.attach,x])),l=new Map(s.filter(x=>x.forEach).map(x=>[x.forEach,x])),u=s.filter(x=>!x.attach&&!x.forEach),p=WS(a,e,x=>{var N,S;const b=(N=o.get(x))==null?void 0:N.result;return b&&b.status==="ok"?(S=fr(b.body))==null?void 0:S.obj:void 0}),g=(a==null?void 0:a.order)??[],v=[...new Set([...g,...Object.keys(e)])],y=[];for(const x of v){if(!(x in e)||Zm.has(x)||Hp(a,x))continue;const b=ua(a,x,Ht(x)),N=l.get(x);if(N){const I=Array.isArray(e[x])?e[x]:[];y.push({kind:"table",key:x,label:b,table:HS(N,I,a,p)});continue}const S=o.get(x);if(S){const I=Up(S.result,e[x],{pathPrefix:x,displayHints:a,currency:p});y.push({kind:"identity",key:x,label:b,identity:I});continue}const k=e[x],E=Op(k,{key:x,hints:a,currency:p});if(E&&"table"in E){y.push({kind:"table",key:x,label:b,table:E.table});continue}if(E&&Pt(k)){const I=In(k,void 0,!0);y.push({kind:"scalar",key:x,label:b,value:E.text,...I!==E.text?{valueTitle:I}:{}});continue}if(Array.isArray(k)){y.push({kind:"scalar",key:x,label:b,value:k.length===0?"—":k.map(I=>Rt(I)).join(", ")});continue}const{value:T,valueTitle:P}=Ji(k,a,x,p);y.push({kind:"scalar",key:x,label:b,value:T,valueTitle:P})}const w=u.map(GS).filter(x=>x!==null);return{rows:y,sections:w}}function Vp(e){const s=e.approved?e.proposalArgs:e.sentArgs;return rj(e.tool,s??null,e.manifests)??e.label}function qS(e){if(e.offDevice)return{level:"off-device"};const s=e.sentArgs??e.proposalArgs,a=s?e.sentArgsCheck??"unchecked":"unchecked";return e.hasHashToCheck&&e.boundContent!==void 0?{level:"sealed",check:e.hashVerified===!0?"ok":"failed",bound:e.boundContent,extras:s?YS(e.boundContent,s):null,argsCheck:a}:s?{level:"recorded",content:s,check:a}:e.boundContent!==void 0?{level:"recorded",content:e.boundContent,check:"unchecked"}:{level:"not-kept",reason:e.sentArgsOmitted==="too_large"?"too_large":"older"}}function YS(e,s){const a={};for(const[o,l]of Object.entries(s))(typeof e=="string"?l===e:o in e)||(a[o]=l);return Object.keys(a).length>0?a:null}function Gp(e,s,a){return ep(e,s).map(o=>{var l;return{...o,inTicket:QS(o.value,(l=s==null?void 0:s.executionMapping)==null?void 0:l[o.key],a)}})}function JS(e,s){if(String(e)===String(s))return!0;if(typeof e=="boolean"||typeof s=="boolean"||e===""||s===""||e===null||s===null)return!1;const a=Number(e),o=Number(s);return Number.isFinite(a)&&Number.isFinite(o)&&a===o}function QS(e,s,a){return!s||!a||e===void 0||e===null?!1:(typeof s=="string"?[{field:s}]:Array.isArray(s)?s:[s]).some(l=>{if(!(l.field in a))return!1;const u=a[l.field];return l.divisor?Number.isFinite(Number(e))&&Number(e)/l.divisor===Number(u):l.transform==="join"?(Array.isArray(e)?e:[e]).map(p=>p&&typeof p=="object"&&"email"in p?String(p.email):String(p)).join(",")===String(u):l.transform?!1:JS(e,u)})}function sc(e){return e==null?"—":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):LS(e)}function XS(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function Fh(e,s){return Object.entries(e).filter(([a,o])=>!XS(o)&&!(s&&a in s&&sc(s[a])===sc(o))).map(([a,o])=>({key:a,label:Ht(a),value:sc(o)}))}function ZS(e,s){const a=e.structuredContent;if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.keys(a).length>0)return{kind:"rows",rows:Fh(a,s)};const o=e.text.trim();if(o.startsWith("{"))try{const l=JSON.parse(o);if(l&&typeof l=="object"&&!Array.isArray(l)&&Object.keys(l).length>0)return{kind:"rows",rows:Fh(l,s)}}catch{}return{kind:"text",text:e.text}}const Mh=new Map;function eb(e){let s=Mh.get(e);return s||(s=z.getProposal(e).catch(()=>null),Mh.set(e,s)),s}let ls=null;function tb(e){if(!ls||e*1e3>ls.fetchedAtMs){const s={fetchedAtMs:Date.now(),map:z.getTicketHeadlines().catch(()=>(ls===s&&(ls=null),{}))};ls=s}return ls.map}function nb({proposal:e,tool:s,manifests:a,label:o}){const l=io(e);return n.jsx(n.Fragment,{children:Vp({tool:s,manifests:a,label:o,approved:!0,proposalArgs:l.toolArgs})})}function rb({ticketId:e,timestamp:s,proposalId:a,tool:o,manifests:l,label:u}){const[f,p]=h.useState(null),[g,v]=h.useState(null);return h.useEffect(()=>{let y=!0;return p(null),v(null),a?eb(a).then(w=>{y&&p(w)}):tb(s).then(w=>{y&&v(w[e]??null)}),()=>{y=!1}},[a,e,s]),a?f?n.jsx(nb,{proposal:f,tool:o,manifests:l,label:u}):n.jsx(n.Fragment,{children:u}):n.jsx(n.Fragment,{children:Vp({tool:o,manifests:l,label:u,approved:!1,sentArgs:g})})}function fa({table:e}){return e.columns.length===0?n.jsx("p",{className:"preview-note",children:"Nothing to show."}):n.jsxs(n.Fragment,{children:[n.jsxs("table",{className:"preview-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.columns.map(s=>n.jsx("th",{children:s.label},s.key))})}),n.jsx("tbody",{children:e.rows.map((s,a)=>n.jsx("tr",{children:s.cells.map((o,l)=>n.jsx("td",{className:o.sealed?"src-tag-value src-tag-sealed-cell":"src-tag-value src-tag-system-cell",title:o.valueTitle,children:o.value},l))},a))})]}),e.overflowNote&&n.jsx("p",{className:"preview-note",children:e.overflowNote})]})}const sb=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function ab(e,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:sb.test(e)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function Ar(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Oh({row:e,which:s}){const a=vs(e.profileRef),o=tp(e.value,a,s);return o.length===0?n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:o.map(l=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-secondary)"},title:l.hint,children:l.label}),n.jsxs("dd",{style:{margin:0,fontWeight:600},children:[l.value,l.unknown&&n.jsx("span",{className:"msg-error",style:{marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},l.key))})}function ib({row:e}){const s=vs(e.profileRef),a=(s==null?void 0:s.id)??e.profileRef??"";return n.jsxs(n.Fragment,{children:[(s==null?void 0:s.name)??Bt(a),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function Kp({row:e,altText:s}){if(e.kind==="list"||e.kind==="object"){const a=Op(e.value);if(a&&"table"in a)return n.jsx(fa,{table:a.table});if(a)return n.jsx(n.Fragment,{children:a.text})}switch(e.kind){case"profile":return n.jsx(ib,{row:e});case"profile-limits":return n.jsx(Oh,{row:e,which:"limits"});case"profile-scope":return n.jsx(Oh,{row:e,which:"scope"});case"markdown":return n.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Ar(e.value)});case"list":return Array.isArray(e.value)?n.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:e.value.map((a,o)=>n.jsx("li",{children:Ar(a)},o))}):n.jsx(n.Fragment,{children:Ar(e.value)});case"money":return n.jsxs(n.Fragment,{children:[Ar(e.value),e.currency?` ${e.currency}`:""]});case"object":return n.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Ar(e.value)});default:return ab(e.key,e.value)?n.jsx("img",{src:e.value,alt:s??e.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):n.jsx(n.Fragment,{children:Ar(e.value)})}}function Sc({args:e,display:s,heading:a="Details",requestRefArg:o}){const l=ep(e,s);if(l.length===0)return null;const u=typeof e.altText=="string"?e.altText:void 0;return n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a&&n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:a}),n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:l.map(f=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:f.hint,children:f.key===o?"Replying to":f.label}),n.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:f.key===o?n.jsx("span",{"data-testid":"request-ref",title:Ar(f.value),children:"the message shown under Request"}):n.jsx(Kp,{row:f,altText:u})})]},f.key))})]})}function ob(e){const s=h.useMemo(()=>typeof URL>"u"||typeof URL.createObjectURL!="function"||typeof Blob>"u"?RS(e):URL.createObjectURL(new Blob([$S(e)],{type:e.contentType})),[e.contentBase64,e.contentType]);return h.useEffect(()=>()=>{s.startsWith("blob:")&&URL.revokeObjectURL(s)},[s]),s}function qp({doc:e,systemName:s,heading:a,sourceLine:o,trailingNote:l}){const u=ob(e),f=PS(e.pages),p=s?`Rendered by ${s}`:"Rendered",g=n.jsxs(n.Fragment,{children:[p," from the template and the values above. Not issued yet — no number is used until you approve."]});return n.jsxs("div",{className:"document-preview-box","data-testid":"document-preview",children:[n.jsx("h4",{children:a??"The PDF as it will be issued"}),n.jsxs("div",{className:"document-preview-body",children:[n.jsx("object",{data:u,type:e.contentType,className:"document-preview-frame","aria-label":`Preview of ${e.filename}`,children:n.jsxs("p",{className:"preview-note",children:["This browser can't preview the PDF inline. ",n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),"."]})}),n.jsxs("div",{className:"document-preview-meta",children:[n.jsx("div",{className:"document-preview-filename",children:e.filename}),f&&n.jsx("div",{className:"preview-note",children:f}),o&&n.jsx("div",{className:"preview-note",children:o}),n.jsxs("div",{className:"preview-note",children:["Fingerprint ",n.jsx("span",{className:"id-raw",title:e.sha256,children:zp(e.sha256)})]}),n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),l!==null&&n.jsx("p",{className:"preview-note",children:l??g})]})]})]})}const lb="_attachmentsSealed";function cb(e){if(e===null||typeof e!="object")return!1;const s=e;return typeof s.connector=="string"&&typeof s.kind=="string"&&typeof s.id=="string"&&typeof s.filename=="string"&&typeof s.contentType=="string"&&typeof s.sha256=="string"&&typeof s.bytes=="number"}function ub(e){if(e===null||typeof e!="object")return!1;const s=e;return typeof s.placeholder=="string"&&typeof s.connector=="string"&&typeof s.kind=="string"&&typeof s.id=="string"&&typeof s.value=="string"}function tu(e){const s={attachments:[],inserts:[]};if(!e)return s;const a=e[lb];if(a===null||typeof a!="object")return s;const o=a,l=Array.isArray(o.attachments)?o.attachments.filter(cb):[],u=Array.isArray(o.inserts)?o.inserts.filter(ub):[];return{attachments:l,inserts:u}}function db(e){return!Number.isFinite(e)||e<0?"—":e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function fb(e){return tu(e).attachments.length===0?[]:[{key:"attachment-source",label:"attachment from an allowed source",ok:!0,valueText:"",limitText:""}]}function Yp(e,s,a,o){var u,f,p;const l=(p=(f=(u=e==null?void 0:e.find(g=>g.id===s))==null?void 0:u.documents)==null?void 0:f[a])==null?void 0:p.label;if(l)return l.replace(/\{id\}/g,o)}function hb(e,s){return!e||!s||s==="loading"?null:s.status==="ok"?{key:"attachment-same-file",label:`same file as ${e}`,ok:!0,valueText:"",limitText:""}:s.status==="changed"?{key:"attachment-same-file",label:"attachment changed since it was sealed",ok:!1,valueText:"",limitText:""}:null}function mb({a:e,manifests:s,preview:a}){const o=Hn(e.connector,s),l=Yp(s,e.connector,e.kind,e.id),u=n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"src-tag-value src-tag-system-cell",children:["from ",o]}),l?n.jsxs(n.Fragment,{children:[" — ",l]}):null]});return a&&a!=="loading"&&a.status==="ok"?n.jsx(qp,{doc:{filename:a.filename,contentType:a.contentType,contentBase64:a.contentBase64,sha256:a.sha256},heading:"Attachment",sourceLine:u,trailingNote:null}):n.jsxs("div",{className:"document-preview-box","data-testid":"attachment-sealed",children:[n.jsx("h4",{children:"Attachment"}),n.jsxs("div",{className:"document-preview-meta",children:[n.jsx("div",{className:"document-preview-filename",children:e.filename}),n.jsx("div",{className:"preview-note",children:db(e.bytes)}),n.jsx("div",{className:"preview-note",children:u}),n.jsxs("div",{className:"preview-note",children:["Fingerprint ",n.jsx("span",{className:"id-raw",title:e.sha256,children:zp(e.sha256)})]}),!a||a==="loading"?n.jsx("div",{className:"preview-note",children:"Loading preview…"}):a.status==="changed"?n.jsx("p",{className:"preview-note","data-testid":"attachment-changed",style:{color:"var(--check-failed)",fontWeight:700},children:"✕ changed since it was sealed"}):n.jsx("div",{className:"preview-note",children:"Preview not available."})]})]})}function pb({i:e,manifests:s}){const a=Hn(e.connector,s);return n.jsxs("div",{className:"preview-box preview-box-sys","data-testid":"insert-sealed",children:[n.jsxs("h4",{children:["From ",a," — inserted by the gateway"]}),n.jsx("div",{style:{color:"var(--prov-system)",fontWeight:600,wordBreak:"break-word"},children:e.value})]})}function Jp({attachments:e,inserts:s,manifests:a,fetchPreview:o,onChecks:l}){const[u,f]=h.useState({});return h.useEffect(()=>{if(!o)return;let p=!0;for(const g of e)f(v=>v[g.sha256]?v:{...v,[g.sha256]:"loading"}),o(g.sha256).then(v=>{p&&f(y=>({...y,[g.sha256]:v}))}).catch(()=>{p&&f(v=>({...v,[g.sha256]:{status:"unavailable",message:"Could not fetch the preview."}}))});return()=>{p=!1}},[e.map(p=>p.sha256).join(","),o]),h.useEffect(()=>{if(!l)return;const p=e.map(g=>hb(Yp(a,g.connector,g.kind,g.id),u[g.sha256])).filter(g=>g!==null);l(p)},[e,a,u,l]),e.length===0&&s.length===0?null:n.jsxs(n.Fragment,{children:[e.map(p=>n.jsx(mb,{a:p,manifests:a,preview:u[p.sha256]},`${p.connector}:${p.kind}:${p.id}`)),s.map(p=>n.jsx(pb,{i:p,manifests:a},`${p.placeholder}:${p.connector}:${p.kind}:${p.id}`))]})}let $i=null;function gb(){return $i||($i=z.getToolDisplay().catch(()=>($i=null,{}))),$i}function Qp({args:e,display:s,executionContext:a,sealed:o}){const l=Gp(e,s,a);return l.length===0?null:n.jsx("dl",{className:"ticket-sent-fields",children:l.map(u=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{title:u.hint,children:u.label}),n.jsxs("dd",{className:o?"is-sealed":void 0,children:[n.jsx(Kp,{row:u}),u.inTicket&&n.jsx("span",{className:"ticket-sent-tag",title:"This value is also in the signed ticket",children:"in the ticket"})]})]},u.key))})}function Bh({content:e,display:s,executionContext:a,sealed:o}){return typeof e=="string"?n.jsx("p",{className:`ticket-sent-text${o?" is-sealed":""}`,children:e}):n.jsx(Qp,{args:e,display:s,executionContext:a,sealed:o})}function Dh({check:e}){return e==="match"?n.jsx("p",{className:"ticket-sent-check",children:"✓ Matches what this gateway executed"}):e==="mismatch"?n.jsx("p",{className:"ticket-sent-check is-failed",children:"✕ Does not match what this gateway executed"}):n.jsx("p",{className:"ticket-sent-check is-neutral",children:"Could not be checked against this gateway's execution record."})}function yb({view:e,display:s,executionContext:a}){return e.level==="off-device"?n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-what-was-done","data-bound":"off-device",children:[n.jsx("h4",{children:"What was sent"}),n.jsx("p",{className:"ticket-sent-empty",children:"Only on the gateway that ran it — this device has no local copy. The signed ticket still proves the limits it ran under."})]}):e.level==="not-kept"?n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-what-was-done","data-bound":"not-kept","data-reason":e.reason,children:[n.jsx("h4",{children:"What was sent"}),n.jsxs("p",{className:"ticket-sent-empty",children:[e.reason==="too_large"?"Not kept — what was sent was too large to keep on this device.":"Not kept — this ticket is older than the release that started keeping it."," ","The signed ticket still proves the limits it ran under."]})]}):e.level==="sealed"?n.jsxs("div",{className:"ticket-sent-box is-sealed","data-testid":"ticket-what-was-done","data-bound":"sealed","data-check":e.check,children:[n.jsxs("h4",{children:["What was sent ",n.jsx("span",{className:"ticket-sent-q",children:"sealed in the ticket"})]}),n.jsx(Bh,{content:e.bound,display:s,executionContext:a,sealed:!0}),e.check==="ok"?n.jsx("p",{className:"ticket-sent-check",children:"✓ Matches the fingerprint in the signed ticket"}):n.jsx("p",{className:"ticket-sent-check is-failed",children:"✕ Does not match the fingerprint in the signed ticket — this local copy was changed"}),e.extras&&Gp(e.extras,s,a).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ticket-sent-sub",children:"Also sent — recorded by this gateway, not sealed in the ticket"}),n.jsx(Qp,{args:e.extras,display:s,executionContext:a,sealed:!1}),e.argsCheck==="mismatch"&&n.jsx(Dh,{check:"mismatch"})]})]}):n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-what-was-done","data-bound":"recorded","data-check":e.check,children:[n.jsxs("h4",{children:["What was sent ",n.jsx("span",{className:"ticket-sent-q",children:"recorded by this gateway — not sealed in the ticket"})]}),n.jsx(Bh,{content:e.content,display:s,executionContext:a,sealed:!1}),n.jsx(Dh,{check:e.check})]})}const Uh=5;function vb({result:e,systemName:s,sent:a}){const o=ZS(e,a),[l,u]=h.useState(!1);return n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-result","data-ok":e.ok?"true":"false",children:[n.jsxs("h4",{children:["Result ",n.jsxs("span",{className:"ticket-sent-q",children:["what ",s," answered"]})]}),!e.ok&&n.jsx("p",{className:"ticket-sent-check",children:"The action failed."}),o.kind==="rows"?n.jsx("dl",{className:"ticket-sent-fields",children:(l?o.rows:o.rows.slice(0,Uh)).map(f=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{children:f.label}),n.jsx("dd",{className:"is-system",children:f.value})]},f.key))}):n.jsx("p",{className:"ticket-sent-text is-system",children:o.text}),o.kind==="rows"&&o.rows.length>Uh&&n.jsx("button",{type:"button",className:"ticket-sent-more",onClick:()=>u(f=>!f),children:l?"Show less":`Show all ${o.rows.length}`}),e.truncated&&n.jsx("p",{className:"ticket-sent-check is-neutral",children:"Shortened to fit what this device keeps."})]})}function Wh(e){var a;const s=[e.entry.sentArgs,(a=e.entry.proposal)==null?void 0:a.toolArgs,e.entry.boundContent];for(const o of s)if(o&&typeof o=="object"&&!Array.isArray(o))return o;return null}function Xp({receipt:e,manifests:s}){var N;const[a,o]=h.useState(void 0),[l,u]=h.useState(null),[f,p]=h.useState(void 0),g=!!(e.contentHash&&e.contentBinding);h.useEffect(()=>{let S=!0;return gb().then(k=>{S&&p(k[e.action])}),()=>{S=!1}},[e.action]),h.useEffect(()=>{let S=!0;return o(void 0),u(null),(async()=>{let k;try{k=await z.getArchivedReceipt(e.id)}catch{S&&o(null);return}let E=null;const T=k==null?void 0:k.entry.boundContent;if(T!==void 0&&g)try{E=await op(e.contentBinding.kind,T)===e.contentHash}catch{E=!1}S&&(u(E),o(k))})(),()=>{S=!1}},[e.id,e.contentHash,e.contentBinding,g]);const v=h.useCallback(S=>z.getReceiptAttachmentPreview(e.id,S),[e.id]);if(a===void 0)return n.jsx("div",{className:"ticket-sent-box ticket-sent-loading","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const y=(N=a==null?void 0:a.entry.proposal)==null?void 0:N.toolArgs,w=qS({offDevice:a===null,boundContent:a==null?void 0:a.entry.boundContent,sentArgs:a==null?void 0:a.entry.sentArgs,sentArgsOmitted:a==null?void 0:a.entry.sentArgsOmitted,proposalArgs:y&&typeof y=="object"&&!Array.isArray(y)?y:void 0,hasHashToCheck:g,hashVerified:l,sentArgsCheck:a==null?void 0:a.sentArgsCheck}),x=Hn(Wn(e.action).integrationId,s),b=tu((a?Wh(a):null)??void 0);return n.jsxs(n.Fragment,{children:[n.jsx(yb,{view:w,display:f,executionContext:e.executionContext}),n.jsx(Jp,{attachments:b.attachments,inserts:b.inserts,manifests:s,fetchPreview:v}),(a==null?void 0:a.result)&&n.jsx(vb,{result:a.result,systemName:x,sent:Wh(a)})]})}const Hh=500;function bc(e){return e.length>Hh?`${e.slice(0,Hh)}…`:e}function Vh(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function xb(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Zp(e,s,a){switch(e.status){case"none":return e.reason==="no_target"?{heading:"Nothing to read beforehand",note:`This action does not refer to an existing record — nothing to read beforehand. Showing exactly what will be sent to ${s}.`}:{heading:"No preview declared",note:`No preview declared for this tool — showing exactly what will be sent to ${s}.`};case"unavailable":return e.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:e.message?`Preview not available — ${bc(e.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:e.message?`Not found in your system — ${bc(e.message)}`:"Not found in your system."};case"ok":{if("reads"in e)return{heading:`What will be created in ${s}`,note:`Read by the gateway, not by the AI — read at ${xb(e.readAt)}.`,creation:KS(a??{},e.reads,e.display)};const o=Bp(e.body,{fields:e.fields}),l={heading:`From ${s}, before it runs`,note:`Read by the gateway with ${e.tool} when you opened this card — the AI is not involved.`,rendered:o},u=e.version;if(u&&(l.versionNote=`You approve ${u.field} ${u.approved}; if it changes, ${s} refuses it.`,u.stale)){const f=OS(e.body,u.currentBody,{fields:e.fields,excludeKey:u.field});l.stale={heading:`A newer ${u.field} exists (${u.current})`,approvedLabel:`${Vh(u.field)} ${u.approved}`,currentLabel:`${Vh(u.field)} ${u.current}`,...f.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:f.approved,currentRendered:f.current}}}return l}}}function wb(e,s){if(e.state!=="failed")return null;const a=e.detail?bc(e.detail):void 0;return e.outcome==="changed"?{heading:"Changed since your approval",note:`The record changed in ${s} since you approved it — nothing was done. Ask the AI to request it again.`}:{heading:`Refused by ${s}`,note:`${s} refused it${a?`: ${a}`:""} — nothing was done. Ask the AI to request it again.`}}function jb(e){return e!==null&&e!=="loading"&&e!=="ok"&&e!=="stale"}function Gh({row:e}){return n.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[e.label,e.description&&n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:e.description})]})}function Sb({row:e}){return e.sublist?n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:e.sublist.map(s=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:s.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},title:s.valueTitle,children:s.value})]},s.key))}):e.diffLines?n.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:e.diffLines.map((s,a)=>n.jsx("div",{style:s.kind==="remove"?{textDecoration:"line-through",color:"var(--text-muted)"}:s.kind==="add"?{fontWeight:600}:void 0,children:s.text||" "},a))}):e.table?n.jsx(fa,{table:e.table}):e.lines?n.jsx("div",{children:e.lines.map((s,a)=>{var o;return n.jsx("div",{title:(o=e.lineTitles)==null?void 0:o[a],children:s},a)})}):n.jsx("span",{title:e.valueTitle,children:e.value})}function kc({rows:e}){return n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.map(s=>s.table?n.jsxs("div",{style:{gridColumn:"1 / -1"},children:[n.jsx(Gh,{row:s}),n.jsx(fa,{table:s.table})]},s.key):n.jsxs(h.Fragment,{children:[n.jsx(Gh,{row:s}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:n.jsx(Sb,{row:s})})]},s.key))})}function ac({rendered:e}){return e.kind==="empty"?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):e.kind==="text"?n.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.text}):n.jsxs(n.Fragment,{children:[n.jsx(kc,{rows:e.fields}),e.moreFields.length>0&&n.jsxs("details",{style:{fontSize:"0.8rem"},children:[n.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",e.totalFields,")"]}),n.jsx(kc,{rows:e.moreFields})]})]})}function bb({identity:e}){return e.unresolved?n.jsxs("span",{children:[n.jsx("span",{className:"id-raw",children:e.rawId})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["— ",e.unresolved]})]}):n.jsxs("span",{children:[e.name&&n.jsx("span",{className:"src-tag-value src-tag-system-cell",children:e.name})," ",n.jsx("span",{className:"id-raw",children:e.rawId}),e.context.length>0&&n.jsx("span",{className:"creation-context",children:e.context.map(s=>{var a,o;return n.jsxs("span",{children:[" · ",s.label," ",s.value??((a=s.lines)==null?void 0:a.join(", "))??((o=s.sublist)==null?void 0:o.map(l=>l.value).join(", "))]},s.key)})})]})}function kb({view:e,systemName:s}){return n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.rows.map(a=>a.kind==="table"?null:n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:a.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:a.kind==="identity"?n.jsx(bb,{identity:a.identity}):n.jsx("span",{className:"src-tag-value src-tag-sealed-cell",title:a.valueTitle,children:a.value})})]},a.key))}),e.rows.filter(a=>a.kind==="table").map(a=>n.jsxs("div",{style:{margin:"0.5rem 0"},children:[n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:a.label}),n.jsx(fa,{table:a.table})]},a.key)),e.sections.map((a,o)=>n.jsx("div",{className:"creation-own-section",children:a.document?n.jsx(qp,{doc:a.document,systemName:s}):n.jsxs(n.Fragment,{children:[n.jsxs("h5",{children:[a.heading," ",n.jsx("span",{className:"src-tag src-tag-system",children:"from the system"})]}),a.table&&n.jsx(fa,{table:a.table}),a.body&&n.jsx(kc,{rows:a.body.fields}),a.note&&n.jsx("p",{className:"preview-note",children:a.note})]})},o))]})}function eg({resp:e,systemName:s,toolArgs:a,sealed:o}){const l=Zp(e,s,a??void 0),u=e.status==="ok"?l.stale?"stale":"ok":e.status;return u==="none"?n.jsx("p",{className:"sr-only","data-testid":"approval-preview","data-preview-status":"none",children:l.note}):n.jsxs("div",{className:`preview-box preview-box-${u}`,"data-testid":"approval-preview","data-preview-status":u,children:[n.jsxs("h4",{children:[l.heading,l.creation&&(o?n.jsx(n.Fragment,{children:n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})}):n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"}))]}),l.creation&&n.jsx(kb,{view:l.creation,systemName:s}),l.rendered&&n.jsx(ac,{rendered:l.rendered}),n.jsx("p",{className:"preview-note",children:l.note}),l.versionNote&&!l.stale&&n.jsx("p",{className:"preview-note",children:l.versionNote}),l.stale&&n.jsxs("div",{className:"preview-stale",children:[n.jsx("h5",{children:l.stale.heading}),l.stale.unchangedNote?n.jsx("p",{className:"preview-note",children:l.stale.unchangedNote}):n.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.5rem 0 0"},children:[n.jsx("dt",{children:l.stale.approvedLabel}),n.jsx("dd",{children:n.jsx(ac,{rendered:l.stale.approvedRendered})}),n.jsx("dt",{children:l.stale.currentLabel}),n.jsx("dd",{children:n.jsx(ac,{rendered:l.stale.currentRendered})})]})]})]})}function Nb({proposalId:e,systemName:s,toolArgs:a,sealed:o,onTone:l,onData:u}){const[f,p]=h.useState(null),[g,v]=h.useState(!1);return h.useEffect(()=>{let y=!0;return p(null),v(!1),z.getProposalPreview(e).then(w=>{y&&p(w)}).catch(()=>{y&&v(!0)}),()=>{y=!1}},[e]),h.useEffect(()=>{if(g){l==null||l("unavailable"),u==null||u({status:"unavailable",reason:"connector_error"});return}if(!f){u==null||u(null);return}const y=Zp(f,s,a??void 0);l==null||l(f.status==="ok"?y.stale?"stale":"ok":f.status),u==null||u(f)},[f,g,s,l,u]),g?n.jsxs("div",{className:"preview-box preview-box-unavailable","data-testid":"approval-preview","data-preview-status":"unavailable",children:[n.jsx("h4",{children:"Preview not available"}),n.jsx("p",{className:"preview-note",children:"Preview not available on this gateway."})]}):f?n.jsx(eg,{resp:f,systemName:s,toolArgs:a,sealed:o}):n.jsxs("div",{className:"preview-box preview-box-loading","data-testid":"approval-preview","data-preview-status":"loading","aria-busy":"true",children:["Reading from ",s,"…"]})}const ic=6;function Qi(e){if(!e)return;const s=Date.parse(e);return Number.isNaN(s)?e:new Date(s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Cb(e){if(!e)return{first:""};const s=e.split(`
|
|
85
|
-
`);return s.length<=ic?{first:e}:{first:s.slice(0,ic).join(`
|
|
86
|
-
`),more:s.slice(ic).join(`
|
|
87
|
-
`)}}const Eb="Linked by the AI",Tb="linked automatically — this action already carried a reference to it";function Ab(e){if(e.status==="none")return{state:"none",note:"No request linked.",chain:[]};if(e.status==="unreadable")return{state:"unreadable",note:`Request: link not readable (${e.reason}).`,chain:[]};if(e.status==="not_found")return{state:"not_found",note:"Request: this message no longer exists.",chain:[]};const{first:s,more:a}=Cb(e.body),o=[e.connector,e.kind,e.author?`from ${e.author}`:void 0,Qi(e.at)].filter(l=>!!l);return{state:"ok",implicit:e.implicit,tag:Eb,...e.implicit?{implicitNote:Tb}:{},metaLine:o.join(" · "),title:e.title,bodyFirst:s,bodyMore:a,attribution:e.author?`— from ${e.author}, not checked`:void 0,chain:e.chain.map(l=>({...l,at:Qi(l.at)}))}}const ra="Read by the gateway — same customer, not matched to this request";function Ib(e){const s=e.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${e.matchedKeyValue} (${s})`}function Rb(e){var l;const s=!!e.aiWritten,a=s?"Activity":e.type??e.kind??"Entry";let o;if(s){const u=((l=e.aiWritten)==null?void 0:l.at)!==void 0?Qi(new Date(e.aiWritten.at).toISOString()):void 0;o=u?`— Written by the AI via Suveren, ${u} — not checked`:"— Written by the AI via Suveren — not checked"}else o=e.author?`— from ${e.author}, not checked`:"— not checked";return{headLabel:a,at:Qi(e.at),title:e.title,body:e.body,attribution:o,aiWritten:s}}function Pb(e){if(e.status==="no_customer_link")return{state:"no_customer_link",label:ra,note:"No customer link — nothing to match history against.",matchNotes:[],items:[]};if(e.status==="no_match")return{state:"no_match",label:ra,note:"No match — no connector here matches on this customer's available identity key.",matchNotes:[],items:[]};if(e.status==="unreachable")return{state:"unreachable",label:ra,note:`${e.connectorIds.join(", ")} not reachable — history could not be read.`,matchNotes:[],items:[]};const s=e.matches.flatMap(l=>l.items.map(u=>({it:u,m:l}))).sort((l,u)=>(Date.parse(u.it.at??"")||0)-(Date.parse(l.it.at??"")||0)).map(({it:l})=>Rb(l)),a=e.matches.map(Ib),o=e.unreachableConnectorIds.length>0?`${e.unreachableConnectorIds.join(", ")} not reachable — showing what could be read.`:void 0;return s.length===0?{state:"empty",label:ra,note:"Nothing in the last few days.",matchNotes:a,items:[],unreachableNote:o}:{state:"ok",label:ra,note:"",matchNotes:a,items:s,unreachableNote:o}}function tg({resp:e}){const s=Ab(e.request),a=Pb(e.history);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"au10-request","data-request-status":s.state,children:[n.jsxs("h4",{children:["Request",s.tag&&n.jsx("span",{className:"src-tag src-tag-ai",children:s.tag})]}),s.state!=="ok"?n.jsx("p",{className:"au10-req-state",children:s.note}):n.jsxs(n.Fragment,{children:[s.implicitNote&&n.jsx("p",{className:"au10-req-meta",style:{marginTop:"-0.1rem"},children:s.implicitNote}),s.metaLine&&n.jsx("p",{className:"au10-req-meta",children:s.metaLine}),s.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:s.title})}),s.bodyFirst&&n.jsx("p",{className:"au10-req-quote",children:s.bodyFirst}),s.bodyMore&&n.jsxs("details",{children:[n.jsx("summary",{children:"Show more"}),n.jsx("p",{className:"au10-req-quote",children:s.bodyMore})]}),s.attribution&&n.jsx("p",{className:"au10-req-attrib",children:s.attribution}),s.chain.length>0&&n.jsxs("details",{className:"au10-chain",children:[n.jsxs("summary",{children:["Earlier in this thread (",s.chain.length,")"]}),s.chain.map((o,l)=>n.jsxs("div",{className:"au10-chain-item",children:[(o.author||o.at)&&n.jsxs("p",{className:"au10-req-meta",children:[o.author?n.jsxs(n.Fragment,{children:["from ",n.jsx("b",{children:o.author})]}):null,o.author&&o.at?" · ":"",o.at]}),o.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:o.title})}),o.body&&n.jsx("p",{className:"au10-req-quote",children:o.body}),o.author&&n.jsxs("p",{className:"au10-req-attrib",children:["— from ",o.author,", not checked"]})]},l))]})]})]}),n.jsxs("div",{className:`preview-box ${a.state==="unreachable"?"preview-box-unreachable":"preview-box-sys"}`,"data-testid":"au10-history","data-history-status":a.state,children:[n.jsxs("h4",{children:["History",n.jsx("span",{className:"src-tag src-tag-system",children:a.label})]}),a.state!=="ok"?n.jsx("p",{className:"au10-hist-state",children:a.note}):n.jsxs(n.Fragment,{children:[a.matchNotes.map((o,l)=>n.jsx("p",{className:"preview-note",style:{marginTop:0},children:o},l)),n.jsx("ul",{className:"au10-hist-list",children:a.items.map((o,l)=>n.jsxs("li",{className:"au10-hist-item",children:[n.jsxs("div",{className:"au10-hist-head",children:[n.jsxs("span",{children:[o.aiWritten&&n.jsx("span",{className:"au10-dot au10-dot-ai"}),o.headLabel]}),n.jsx("span",{children:o.at})]}),o.title&&n.jsx("div",{className:"au10-hist-title",children:o.title}),o.body&&n.jsx("div",{className:"au10-hist-body",children:o.body}),n.jsx("p",{className:"au10-hist-attrib",children:o.attribution})]},l))}),a.unreachableNote&&n.jsx("p",{className:"preview-note",children:a.unreachableNote})]})]})]})}function $b({proposalId:e,onData:s}){const[a,o]=h.useState(null),[l,u]=h.useState(!1);return h.useEffect(()=>{let f=!0;return o(null),u(!1),z.getProposalRequestContext(e).then(p=>{f&&o(p)}).catch(()=>{f&&u(!0)}),()=>{f=!1}},[e]),h.useEffect(()=>{s==null||s(l?null:a)},[a,l,s]),l||!a?null:n.jsx(tg,{resp:a})}function _b(e,s,a){const o=Object.entries(e??{});if(o.length===0)return{entry:void 0,otherCount:0};const u=o.find(([,p])=>p.by===s)??(a?o.find(([p])=>p===`domain:${a}`):void 0),f=u?o.length-1:o.length;return{entry:u==null?void 0:u[1],otherCount:f}}function Lb(e){return e.offDevice?"off-device":e.recordedHash?e.localHash===e.recordedHash?"verified":"mismatch":"unchecked"}function zb(e){if(!(e<=0))return`${e} other approver${e===1?"":"s"} recorded their own.`}function Fb(e){return new Date(e).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function ng({proposalId:e,tool:s,manifests:a}){const{user:o,domain:l}=wt(),[u,f]=h.useState(null),[p,g]=h.useState(null),[v,y]=h.useState(!1);if(h.useEffect(()=>{let P=!0;return f(null),g(null),y(!1),Promise.all([z.getShownSnapshot(e),z.getProposal(e)]).then(([I,B])=>{P&&(f(I),g(B))}).catch(()=>{P&&y(!0)}),()=>{P=!1}},[e]),v||!u||!p)return null;const w=u.status==="off_device",{entry:x,otherCount:b}=_b(p.shownHashes,(o==null?void 0:o.id)??"",l),N=Lb({offDevice:w,recordedHash:x==null?void 0:x.hash,localHash:u.status==="ok"?u.shownHash:void 0}),S=zb(b);if(w)return n.jsxs("div",{className:"ticket-box ticket-shown-off-device","data-testid":"au10-shown","data-shown-status":"off-device",children:[n.jsx("h4",{children:"What you saw"}),n.jsx("p",{className:"ticket-done-note",children:"Only on the approving gateway — this device has no local copy."})]});const{snapshot:k}=u,{integrationId:E}=Wn(s),T=Hn(E,a);return n.jsxs("div",{className:`ticket-box ticket-shown-${N}`,"data-testid":"au10-shown","data-shown-status":N,children:[n.jsxs("h4",{children:["What you saw (read ",Fb(k.readAt),")",N==="verified"&&n.jsx("span",{className:"src-tag src-tag-sealed",children:"verified"}),N==="mismatch"&&n.jsx("span",{className:"src-tag src-tag-danger",children:"does not match what was approved"})]}),n.jsx(eg,{resp:k.preview,systemName:T,toolArgs:k.toolArgs,sealed:k.sealed}),n.jsx(tg,{resp:k.requestContext}),N==="verified"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ Matches the fingerprint recorded with your approval."}),N==="mismatch"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This copy differs from the fingerprint recorded with your approval."}),N==="unchecked"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-neutral",children:"This device's copy of what was shown, kept locally — the Authority Server does not record a fingerprint for you to check it against."}),S&&n.jsx("p",{className:"ticket-done-note ticket-done-note-neutral","data-testid":"au10-shown-others",children:S})]})}function sa({label:e,children:s}){return n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"receipt-row-label",children:e}),n.jsx("dd",{className:"receipt-row-value",children:s})]})}function Mb({receipt:e,manifests:s,localAuth:a,localUnavailable:o,signature:l,grantTitle:u,ownerLabel:f,spUrl:p,formatDate:g,onOpenComplete:v,isNew:y=!1,defaultOpen:w=!1}){var Z;const x=vs(e.profileId),b=Fw(e,x),N=Mw(a==null?void 0:a.context,x),S=Bw(e,(a==null?void 0:a.bounds)??e.limits,x),k=a==null?void 0:a.intent,E=_r(e.profileId).testSetup||ro(e.action),[T,P]=h.useState(!1),[I,B]=h.useState(w),O=Date.now(),K=Lr(),_=$r(e.profileId,K),U=l==="valid"||l==="valid-legacy";return n.jsxs("div",{className:`ticket-obj ticket-obj-card${y?" is-new":""}${I?" is-open":""}`,"data-new":y?"true":"false",children:[n.jsxs("div",{className:"ticket-obj-main",children:[n.jsxs("button",{type:"button",className:"ticket-obj-head","aria-expanded":I,onClick:()=>B(V=>!V),children:[n.jsx(us,{profileId:e.profileId,area:_,system:pa(e.action,s),time:Hi(e.timestamp,O),leading:y?n.jsx("span",{className:"seen-dot is-new","aria-label":"new since your last visit"}):void 0}),n.jsxs("div",{className:"receipt-head",children:[n.jsx("span",{className:"receipt-what","data-testid":"ticket-headline",children:n.jsx(rb,{ticketId:e.id,timestamp:e.timestamp,proposalId:e.proposalId,tool:e.action,manifests:s,label:ao(e,s)})}),n.jsx("span",{className:"receipt-tag",children:Ui(e)?"approved":"automatic"}),e.contentHash&&n.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(Z=e.contentBinding)!=null&&Z.fields?`Sealed in the ticket: ${e.contentBinding.fields.join(", ")} — exactly this content was sent`:"Sealed in the ticket — exactly this content was sent",children:"content sealed"}),E&&n.jsx("span",{className:"sim-mark",children:"Test setup"})]}),n.jsx(da,{title:u,area:_}),b&&n.jsx("div",{className:"receipt-scope",children:b})]}),I&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"receipt-when",children:g(e.timestamp)}),n.jsx(Xp,{receipt:e,manifests:s}),e.proposalId&&n.jsx(ng,{proposalId:e.proposalId,tool:e.action,manifests:s}),n.jsxs("dl",{className:"receipt-rows",children:[n.jsxs(sa,{label:"mandate",children:[n.jsx("strong",{children:u||Uw(e.profileId)})," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),f&&n.jsx(sa,{label:"owner",children:f}),N&&n.jsxs(sa,{label:"allowed",children:[N," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),S&&n.jsxs(sa,{label:"used",children:[n.jsx("span",{className:"receipt-num",children:S})," ",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx(sa,{label:"intent",children:k?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:`intent-text${T?"":" intent-clamped"}`,children:k}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>P(!T),children:T?"Show less":"Show full intent"})," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}):n.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"})})]}),n.jsxs("div",{className:"receipt-foot",children:[l==="valid"&&n.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"}),l==="valid-legacy"&&n.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"}),l==="invalid"&&n.jsx("span",{className:"receipt-tamper",title:"The stored ticket does not match what was signed.",children:"⚠ Signature check FAILED"}),n.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:v,children:"Complete ticket"}),p&&n.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",n.jsx("a",{className:"receipt-link",href:`${p}/r/${e.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),n.jsxs("details",{className:"receipt-more",children:[n.jsx("summary",{children:"Raw"}),n.jsxs("div",{className:"receipt-kv",children:[n.jsxs("div",{children:["ticket · ",e.id]}),n.jsxs("div",{children:["action · ",e.action]}),n.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&n.jsxs("div",{children:["mandate · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&n.jsxs("div",{children:["scope ·"," ",Object.entries(e.executionContext).map(([V,M])=>`${V}=${M}`).join(" · ")]}),(a==null?void 0:a.boundsHash)&&n.jsxs("div",{children:["bounds hash · ",a.boundsHash]}),(a==null?void 0:a.contextHash)&&n.jsxs("div",{children:["scope hash · ",a.contextHash]}),e.contentHash&&n.jsxs("div",{children:["content · ",e.contentHash]}),e.proposalId&&n.jsxs("div",{children:["proposal · ",e.proposalId]}),n.jsxs("div",{children:["signature · ",e.signature]})]})]})]})]}),n.jsxs("div",{className:"ticket-obj-stub",children:[n.jsx("span",{className:"ticket-obj-no",title:e.id,children:ip(e.id)}),n.jsx("span",{className:"ticket-obj-time",children:Hi(e.timestamp,O)}),U&&n.jsx("span",{className:"ticket-obj-sig",title:"Signature checked on this device",children:"✓ verified"})]})]})}function Ob({receipt:e,onClose:s}){const[a,o]=h.useState(null),[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState(!0),[y,w]=h.useState(!1);h.useEffect(()=>{let k=!1;return v(!0),z.getArchivedReceipt(e.id).then(E=>{k||(o(E),u(E?"local":"authority-server"),p((E==null?void 0:E.signature)??null))}).catch(()=>{k||u("authority-server")}).finally(()=>{k||v(!1)}),()=>{k=!0}},[e.id]);const x=a?a.entry:{receipt:e},b=JSON.stringify(x,null,2);function N(){const k=URL.createObjectURL(new Blob([b],{type:"application/json"})),E=document.createElement("a");E.href=k,E.download=`suveren-ticket-${e.id.slice(0,8)}.json`,E.click(),URL.revokeObjectURL(k)}async function S(){try{await navigator.clipboard.writeText(b),w(!0),setTimeout(()=>w(!1),2e3)}catch{w(!1)}}return n.jsx("div",{className:"modal-backdrop",onClick:k=>k.target===k.currentTarget&&s(),children:n.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:"Complete ticket"}),n.jsx("button",{className:"modal-close",onClick:s,"aria-label":"Close",children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[f==="valid"&&n.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."}),f==="valid-legacy"&&n.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."}),f==="invalid"&&n.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."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:g?"Loading…":l==="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."}),n.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:b})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:N,children:"Download"}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:S,children:y?"Copied":"Copy"})]})]})})}function Bb(e){return new Date(e*1e3).toLocaleString()}function Db(e,s){if(s==="all")return!0;const a=s==="1d"?1:s==="7d"?7:30,o=Math.floor(Date.now()/1e3)-a*86400;return e.timestamp>=o}function Ub(e,s,a){const o=s.trim().toLowerCase();return o?[...a,e.id,e.action,e.profileId,JSON.stringify(e.executionContext??{})].some(u=>typeof u=="string"&&u.toLowerCase().includes(o)):!0}function Kh(e,s){const a=new Map(e.map(o=>[o.id,o]));for(const o of s)a.set(o.id,o);return[...a.values()].sort((o,l)=>l.timestamp-o.timestamp)}function Wb(){const{activeTeam:e,groupId:s}=wt(),a=(e==null?void 0:e.isAdmin)===!0,[o,l]=h.useState("mine"),[u,f]=ys(),p=Hw(u.get("filter")),g=W=>{const we=new URLSearchParams(u);W==="all"?we.delete("filter"):we.set("filter",W),f(we,{replace:!0})},v=Jm(u.get("area")),y=W=>{const we=new URLSearchParams(u);W===null?we.delete("area"):we.set("area",W),f(we,{replace:!0})},w=Lr(),[x,b]=h.useState(null),N=h.useRef(!1),[S,k]=h.useState([]),[E,T]=h.useState([]),[P,I]=h.useState(""),[B,O]=h.useState(!0),[K,_]=h.useState({}),[U,Z]=h.useState(new Set),[V,M]=h.useState(""),[re,de]=h.useState(new Set),[X,xe]=h.useState("all"),[Ne,ee]=h.useState(!1),[Q,q]=h.useState(!1),[A,$]=h.useState(null),[ae,ne]=h.useState({}),[ve,Se]=h.useState(!1),[Y,ce]=h.useState({}),[ie,te]=h.useState({}),[ze,Ue]=h.useState(null),[fe,me]=h.useState(null),[Te,Le]=h.useState(!1),[ge,nt]=h.useState(!1),Ze=h.useRef(""),Ye=h.useCallback(W=>o==="team"&&a&&s?z.listTeamReceiptsPage(s,{before:W,limit:200}):z.getMyReceiptsPage({before:W,limit:200}),[o,a,s]),He=h.useCallback(()=>{const W=o==="team"?`team:${s}`:"mine",we=Ze.current!==W;Ze.current=W,O(!0),nt(!1),Ye().then(Ie=>{k(st=>we?Ie.receipts:Kh(st,Ie.receipts)),me(st=>we?Ie.nextBefore:st??Ie.nextBefore)}).catch(()=>{we&&k([]),nt(!0)}).finally(()=>O(!1))},[Ye,o,s]),dt=h.useCallback(()=>{!fe||Te||(Le(!0),nt(!1),Ye(fe).then(W=>{k(we=>Kh(we,W.receipts)),me(W.nextBefore)}).catch(()=>nt(!0)).finally(()=>Le(!1)))},[fe,Te,Ye]);Ot(He,12e4);const ft=h.useCallback(()=>{He(),x!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||z.markTicketsSeen(Date.now()).catch(()=>{}))},[He,x]);Oe("ticket-recorded",ft),h.useEffect(()=>{B||N.current||(N.current=!0,z.getLastSeenTicketsAt().then(W=>(b(W),z.markTicketsSeen(Date.now()))).catch(()=>b(Number.POSITIVE_INFINITY)))},[B]),h.useEffect(()=>{z.getLabelManifests().then(T).catch(()=>{}),fetch("/health").then(W=>W.json()).then(W=>{typeof W.spUrl=="string"&&I(W.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),h.useEffect(()=>{z.getLocalAuthorizations().then(({authorizations:W,signatures:we})=>{ne(W),ce(we),Se(!1)}).catch(()=>{ne({}),ce({}),Se(!0)}),z.getMyAttestations().then(W=>{const we={};for(const Ie of W)Ie.authorization_id&&Ie.title&&(we[Ie.authorization_id]=Ie.title);te(we)}).catch(()=>{})},[]),h.useEffect(()=>{o!=="team"||Object.keys(K).length>0||z.listUsers().then(W=>{const we={};for(const Ie of W)we[Ie.id]={name:Ie.name,email:Ie.email};_(we)}).catch(()=>{})},[o,K]);const Me=h.useMemo(()=>{const W=new Set;for(const we of S)W.add(we.action);return[...W].sort()},[S]),pe=h.useMemo(()=>{if(o!=="team")return[];const W=new Set;for(const we of S)we.userId&&W.add(we.userId);return[...W].map(we=>{var Ie;return{id:we,label:(Ie=K[we])!=null&&Ie.name?`${K[we].name} (${K[we].email})`:we}}).sort((we,Ie)=>we.label.localeCompare(Ie.label))},[o,S,K]),Pe=h.useMemo(()=>S.filter(W=>!(!Ub(W,V,[Dn(W.profileId,w),ao(W,E),Hn(Wn(W.action).integrationId,E),W.authorizationId?ie[W.authorizationId]:null])||re.size>0&&!re.has(W.action)||U.size>0&&W.userId&&!U.has(W.userId)||!Db(W,X))),[S,V,w,E,ie,re,U,X]),Be=h.useMemo(()=>{const W={automatic:0,approved:0,all:0};for(const we of Pe)W.all+=1,W[yc(we,"approved")?"approved":"automatic"]+=1;return W},[Pe]),G=h.useMemo(()=>Pe.filter(W=>yc(W,p)),[Pe,p]),J=h.useMemo(()=>{const W=new Map;for(const we of G){const Ie=Rn(we.profileId),st=W.get(Ie);st?st.count+=1:W.set(Ie,{shortId:Ie,icon:Pr(we.profileId),name:Dn(we.profileId,w),count:1})}return[...W.values()].sort((we,Ie)=>we.name.localeCompare(Ie.name))},[G,w]),ye=h.useMemo(()=>G.filter(W=>Qm(W.profileId,v)),[G,v]),Ve=h.useMemo(()=>x===null?0:ye.filter(W=>Wi(W,x)).length,[ye,x]),Ge=re.size>0||U.size>0||X!=="all";function rt(W){de(we=>{const Ie=new Set(we);return Ie.has(W)?Ie.delete(W):Ie.add(W),Ie})}function Vt(W){Z(we=>{const Ie=new Set(we);return Ie.has(W)?Ie.delete(W):Ie.add(W),Ie})}function Dt(){de(new Set),Z(new Set),xe("all"),M("")}async function et(){q(!0),$(null);try{const{bundle:W,filename:we}=await z.fetchEvidenceBundle(),Ie=URL.createObjectURL(new Blob([JSON.stringify(W,null,2)],{type:"application/json"})),st=document.createElement("a");st.href=Ie,st.download=we,st.click(),URL.revokeObjectURL(Ie);const yt=W.sources??{};yt.authorityServer?yt.local||$(`Downloaded Authority Server history only — ${yt.localError??"local archive unavailable."}`):$(`Downloaded local evidence only — ${yt.asError??"Authority Server export unavailable."}`)}catch(W){$(`Export failed: ${W instanceof Error?W.message:String(W)}`)}finally{q(!1)}}return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Tickets"}),n.jsxs("p",{className:"page-subtitle",children:["Execution history for agent actions.",Ve>0&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("b",{"data-testid":"tickets-new-count",children:[Ve," new since your last visit"]})]})]})]}),n.jsx("button",{className:"btn btn-secondary",onClick:et,disabled:Q,children:Q?"Preparing…":"Download evidence"})]}),A&&n.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:A}),a&&n.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(W=>n.jsx("button",{onClick:()=>l(W),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:o===W?"2px solid var(--accent)":"2px solid transparent",color:o===W?"var(--text-primary)":"var(--text-tertiary)",fontWeight:o===W?600:500},children:W==="mine"?"Mine":"Team"},W))}),n.jsxs("div",{className:"tickets-toolbar",children:[n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which tickets",children:Ww.map(W=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`tickets-filter-${W}`,"aria-selected":p===W,onClick:()=>g(W),children:[W==="automatic"?"Automatic":W==="approved"?"Approved":"All",n.jsx("span",{className:"n",children:Be[W]})]},W))}),n.jsxs("div",{className:"search-filter-bar",children:[n.jsxs("div",{className:"search-input-wrap",children:[n.jsx("span",{className:"search-icon",children:"⌕"}),n.jsx("input",{type:"text",className:"form-input search-input","data-testid":"tickets-search",placeholder:"Search tickets","aria-label":"Search tickets",value:V,onChange:W=>M(W.target.value)}),V&&n.jsx("button",{className:"search-clear",onClick:()=>M(""),children:"×"})]}),n.jsxs("button",{className:`btn btn-sm btn-secondary${Ne?" active":""}`,onClick:()=>ee(!Ne),children:["Filters",Ge?` (${re.size+(X!=="all"?1:0)})`:""]})]})]}),p==="automatic"&&n.jsx("p",{className:"page-subtitle",style:{marginTop:"-0.25rem"},children:'Automatic — no person approved these. Approved tickets are under "Approved".'}),n.jsx(eu,{areas:J,selected:v,onSelect:y,totalCount:G.length}),Ne&&n.jsxs("div",{className:"filter-panel",children:[Me.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Action"}),n.jsx("div",{className:"filter-chips",children:Me.map(W=>n.jsx("button",{className:`filter-chip${re.has(W)?" selected":""}`,onClick:()=>rt(W),children:W},W))})]}),o==="team"&&pe.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Owner"}),n.jsx("div",{className:"filter-chips",children:pe.map(W=>n.jsx("button",{className:`filter-chip${U.has(W.id)?" selected":""}`,onClick:()=>Vt(W.id),children:W.label},W.id))})]}),n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Time range"}),n.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([W,we])=>n.jsx("button",{className:`filter-chip${X===W?" selected":""}`,onClick:()=>xe(W),children:we},W))})]})]}),Ge&&n.jsxs("div",{className:"active-filters",children:[[...re].map(W=>n.jsxs("span",{className:"active-chip",onClick:()=>rt(W),children:[W," ",n.jsx("span",{className:"chip-remove",children:"×"})]},W)),[...U].map(W=>{const we=K[W],Ie=we?we.name:W;return n.jsxs("span",{className:"active-chip",onClick:()=>Vt(W),children:[Ie," ",n.jsx("span",{className:"chip-remove",children:"×"})]},W)}),X!=="all"&&n.jsxs("span",{className:"active-chip",onClick:()=>xe("all"),children:[X==="1d"?"Today":X==="7d"?"7 days":"30 days"," ",n.jsx("span",{className:"chip-remove",children:"×"})]}),n.jsx("button",{className:"clear-filters",onClick:Dt,children:"Clear all"})]}),ge&&n.jsx("div",{className:"card note-stopped",style:{marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-error",style:{fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),B&&S.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ye.length===0?n.jsx(fs,{icon:"⌕",title:S.length===0?"No tickets in the last 30 days":"No matching tickets",text:S.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:ye.length===S.length?`${S.length} ticket${S.length!==1?"s":""}`:`${ye.length} of ${S.length} tickets`}),n.jsx("div",{className:"timeline",children:ye.map(W=>{const we=W.userId?K[W.userId]:void 0;return n.jsx("div",{className:"timeline-event",children:n.jsx(Mb,{receipt:W,manifests:E,localAuth:W.authorizationId?ae[W.authorizationId]:void 0,localUnavailable:ve,signature:Y[W.id],grantTitle:W.authorizationId?ie[W.authorizationId]:null,ownerLabel:o==="team"&&W.userId?we?`${we.name} (${we.email})`:W.userId:null,spUrl:P,formatDate:Bb,onOpenComplete:()=>Ue(W),isNew:x!==null&&Wi(W,x),defaultOpen:ye.length===1})},W.id)})})]}),ze&&n.jsx(Ob,{receipt:ze,onClose:()=>Ue(null)}),fe&&n.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:dt,disabled:Te,children:Te?"Loading…":"Load older"})})]})}function Hb(){const[e,s]=h.useState(null),[a,o]=h.useState({}),[l,u]=h.useState(!1),f=Lr(),[p,g]=ys(),v=Jm(p.get("area")),y=h.useCallback(O=>{const K=new URLSearchParams(p);O===null?K.delete("area"):K.set("area",O),g(K,{replace:!0})},[p,g]),[w,x]=h.useState({}),b=h.useCallback(()=>{z.getMyAttestations().then(O=>{const K={};for(const _ of O)_.title&&(K[_.authorization_id]=_.title);x(K)}).catch(()=>{})},[]);h.useEffect(()=>{b()},[b]),Ot(b,3e5);const[N,S]=h.useState(null),k=h.useRef(!1),E=h.useCallback(()=>{z.getDenials({limit:200}).then(({records:O})=>{s(O),u(!1)}).catch(()=>u(!0))},[]);h.useEffect(()=>{E()},[E]),Ot(E,6e4),h.useEffect(()=>{if(!e)return;const O=[...new Set(e.map(K=>K.profile).filter(K=>!!K))].filter(K=>!(K in a));O.length!==0&&Promise.all(O.map(K=>z.getProfile(K).catch(()=>null))).then(K=>{o(_=>{const U={..._};return O.forEach((Z,V)=>{K[V]&&(U[Z]=K[V])}),U})})},[e,a]),h.useEffect(()=>{!e||k.current||(k.current=!0,z.getLastSeenBlockedAt().then(O=>(S(O),z.markBlockedSeen(Date.now()))).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[e]);const T=h.useCallback(()=>{E(),b(),N!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||z.markBlockedSeen(Date.now()).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[E,b,N]);Oe("denial-recorded",T);const P=h.useMemo(()=>{const O=new Map;for(const K of e??[]){const _=K.profile??K.integrationId,U=Rn(_),Z=O.get(U);Z?Z.count+=1:O.set(U,{shortId:U,icon:Pr(_),name:Dn(_,f),count:1})}return[...O.values()].sort((K,_)=>K.name.localeCompare(_.name))},[e,f]);if(l)return n.jsx(fs,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(e===null)return null;const I=L0(e,Date.now()),B=e.filter(O=>Qm(O.profile??O.integrationId,v));return n.jsxs("div",{className:"blocked-page",children:[n.jsxs("div",{className:"page-header blocked-header",children:[n.jsx("h1",{className:"page-title",children:"Blocked actions"}),n.jsxs("span",{className:"blocked-today",children:[I," today · nothing ran"]})]}),e.length===0?n.jsx(fs,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):n.jsxs(n.Fragment,{children:[n.jsx(eu,{areas:P,selected:v,onSelect:y,totalCount:e.length}),n.jsx("div",{className:"blocked-list",children:B.map((O,K)=>{const _=_0(O,O.profile?a[O.profile]:void 0,w),U=N!==null&&O.ts>N,Z=O.profile??O.integrationId;return n.jsx("div",{className:"card blocked-item blocked-card","data-seen":U?"false":"true",children:n.jsxs("div",{className:"id-body",children:[n.jsx(us,{profileId:Z,area:Dn(Z,f),system:O.integrationId?Hn(O.integrationId,void 0):void 0,time:M0(O.ts,Date.now()),trailing:U?n.jsx("span",{className:"new-pill",children:"New"}):void 0}),n.jsxs("div",{className:"blocked-row-head",children:[n.jsx("span",{className:`blocked-dot blocked-dot-${no(O)}`,"aria-hidden":"true"}),n.jsx("span",{className:"blocked-title",children:_.title})]}),n.jsx(da,{title:Fm(O,w),area:Dn(Z,f)}),n.jsx("div",{className:"blocked-sentence",children:_.sentence}),n.jsx("div",{className:"blocked-source",children:_.sourceLine.map((V,M)=>V.dim?n.jsx("span",{className:"mandate-id",children:V.text},M):n.jsx("span",{children:V.text},M))}),n.jsxs("details",{children:[n.jsx("summary",{children:"What you can do"}),n.jsx("div",{className:"blocked-advice",children:_.whatYouCanDo})]})]})},`${O.ts}-${K}`)})})]})]})}const Vb={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function Gb(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{s(await z.getAutostart())}catch(v){u(v instanceof Error?v.message:"Could not read autostart state")}},[]);h.useEffect(()=>{f()},[f]);const p=h.useCallback(async()=>{if(!(!(e!=null&&e.supported)||a)){o(!0),u(null);try{await z.setAutostart(!e.installed)}catch(v){u(v instanceof Error?v.message:"Failed")}finally{try{s(await z.getAutostart()),u(null)}catch(v){u(v instanceof Error?v.message:"Could not re-read state")}o(!1)}}},[e,a,f]);if(!e)return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read autostart state: ${l}`:"Checking…"})]});const g=Vb[e.platform]??"a login service";return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),n.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:e.supported?n.jsxs(n.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",g," — no admin rights needed."]}):e.reason})]}),e.supported&&n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.installed,className:e.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Working…":e.installed?"Turn off":"Turn on"})]}),e.supported&&n.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",n.jsx("strong",{children:e.installed?"On — starts from your next login":"Off"})]}),e.supported&&n.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 ",n.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}function Kb(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{const g=await z.getGatewaySettings();s(g.desktopNotifications),u(null)}catch(g){u(g instanceof Error?g.message:"Could not read notification setting")}},[]);h.useEffect(()=>{f()},[f]);const p=h.useCallback(async()=>{if(!(e===null||a)){o(!0),u(null);try{const g=await z.setGatewaySettings({desktopNotifications:!e});s(g.desktopNotifications)}catch(g){u(g instanceof Error?g.message:"Failed to save"),await f()}finally{o(!1)}}},[e,a,f]);return e===null?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read the setting: ${l}`:"Checking…"})]}):n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),n.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."})]}),n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e,className:e?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":e?"Turn off":"Turn on"})]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}const qh={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function qb(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{s(await z.getIdentityDisclosure()),u(null)}catch(y){u(y instanceof Error?y.message:"Could not read the setting")}},[]);h.useEffect(()=>{f()},[f]);const p=h.useCallback(async()=>{if(!(!e||a)){o(!0),u(null);try{s(await z.setIdentityDisclosure(!e.always))}catch(y){u(y instanceof Error?y.message:"Failed to save"),await f()}finally{o(!1)}}},[e,a,f]),g=n.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!e)return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[g,n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read the setting: ${l}`:"Checking…"})]});const v=e.verified&&e.name?`${e.name} — ${e.method==="as_vouched"?`${qh.as_vouched} ${e.verifier}`:qh[e.method??""]??e.method}`:null;return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[g,n.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[e.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:v?`Your identity: ${v}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.always,className:e.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":e.always?"Turn off":"Always show my name"})]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}const Yb={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 Jb(){const{version:e,latestVersion:s,updateAvailable:a,installMethod:o}=Mc();return e?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",n.jsx("strong",{children:e}),a&&s?n.jsxs(n.Fragment,{children:[" — ",n.jsx("strong",{children:s})," is available"]}):null]}),n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[Yb[o]??"Update checking is unavailable",o==="dev"&&n.jsx(n.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Nc({title:e}){return n.jsxs("span",{className:"it-locked-badge",title:e,children:[n.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function Yh(e){return e===!0}function Qb(){const[e,s]=h.useState(null),[a,o]=h.useState(null);h.useEffect(()=>{let f=!1;return z.getAsPairing().then(p=>{f||s(p)}).catch(p=>{f||o(p instanceof Error?p.message:"Could not read Authority Server info")}),()=>{f=!0}},[]);const l=Yh(e==null?void 0:e.asUrlLockedByPolicy),u=Yh(e==null?void 0:e.pinTlsLockedByPolicy);return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),l&&n.jsx(Nc,{})]}),!e&&!a&&n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),a&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.5rem 0 0",fontSize:"0.9rem"},children:a}),e&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"URL:"})," ",n.jsx("code",{children:e.asUrl})]}),e.paired&&e.fingerprint?n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"Key fingerprint:"})," ",n.jsx("code",{children:e.fingerprint}),n.jsx("br",{}),n.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."})]}):n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:"Not yet paired — sign in once to pin this server's key."}),(e.tlsPinFingerprint||e.pinTlsEnabled)&&n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"TLS certificate pin:"})," ",u&&n.jsx(Nc,{title:"TLS pinning is set by your IT policy"})," ",e.tlsPinFingerprint?n.jsx("code",{children:e.tlsPinFingerprint}):n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",e.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),n.jsx("br",{}),n.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[e.pinTlsEnabled?n.jsxs(n.Fragment,{children:["TLS pinning is ON",u?n.jsx(n.Fragment,{children:", set by your organization's IT policy"}):n.jsxs(n.Fragment,{children:[" (",n.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."]}):n.jsxs(n.Fragment,{children:["Captured at sign-in; not currently enforced",u?n.jsx(n.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):n.jsxs(n.Fragment,{children:[" (",n.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."]})]}),l?n.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."}):n.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:"," ",n.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 Xb(){const{simulation:e,locked:s}=Ym();return s?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),n.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:['Blocks every real connector without a manifest "simulation" marker.',e!==null&&n.jsxs(n.Fragment,{children:[" ","Currently ",n.jsx("strong",{children:e?"ON":"OFF"}),e?" — real systems are not reachable from this gateway.":"."]})]})]}),n.jsx(Nc,{})]}),n.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Simulation mode is set by your organization's IT policy",e!==null?` (currently ${e?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const Zb={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"]}},aa=["AI Assistant","Authority Server","This computer","Security","Version"],ia={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function ek(){const[e,s]=h.useState(""),[a,o]=h.useState("openrouter"),[l,u]=h.useState("openai-compatible"),[f,p]=h.useState("https://openrouter.ai/api/v1"),[g,v]=h.useState("google/gemma-4-31b-it"),[y,w]=h.useState(""),[x,b]=h.useState(!1),[N,S]=h.useState(!1),[k,E]=h.useState(!1),[T,P]=h.useState(null),[I,B]=h.useState([]),[O,K]=h.useState(!1),[_,U]=h.useState(null),[Z,V]=h.useState(""),M=h.useCallback(Q=>{s(Q),setTimeout(()=>s(""),3e3)},[]),re=h.useCallback(async(Q,q,A)=>{K(!0),U(null);try{const $=await z.aiModels({provider:Q,endpoint:q,...A?{apiKey:A}:{}});$.ok&&$.models.length>0?(B($.models),U(`${$.models.length} models available`)):(B([]),U($.message||"No models returned — using defaults"))}catch($){B([]),U($ instanceof Error?$.message:"Failed to load models")}finally{K(!1)}},[]),de=h.useCallback(async()=>{try{const Q=await z.getCredential("ai-config");if(b(Q.configured),Q.configured&&Q.fields){const q=Q.fields.provider||"openai-compatible",A=Q.fields.endpoint||"";Q.fields.provider&&u(q),Q.fields.endpoint&&p(A),Q.fields.model&&v(Q.fields.model),A.includes("openai.com")?o("openai"):A.includes("groq.com")?o("groq"):A.includes("together.xyz")?o("together"):A.includes("openrouter.ai")?o("openrouter"):o("ollama"),A&&re(q,A)}}catch{}},[re]);h.useEffect(()=>{de()},[de]);const X=Q=>{o(Q),B([]),U(null),V("");const q=Zb[Q];q&&(u(q.provider),p(q.endpoint),v(""),re(q.provider,q.endpoint,y||void 0))},xe=()=>re(l,f,y||void 0),Ne=async()=>{S(!0);try{await z.setCredential("ai-config",{provider:l,endpoint:f,model:g,...y?{apiKey:y}:{}}),b(!0),M("AI configuration saved!")}catch{M("Failed to save AI config")}finally{S(!1)}},ee=async()=>{E(!0),P(null);try{const Q=await z.aiTest({provider:l,endpoint:f,model:g,...y?{apiKey:y}:{}});P(Q.ok?`OK: ${Q.message}`:`Failed: ${Q.message}`)}catch(Q){P(`Error: ${Q instanceof Error?Q.message:"Unknown"}`)}finally{E(!1)}};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Settings"}),n.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),e&&n.jsx("div",{className:"alert alert-success",children:e}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:ia,children:aa[0]}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",children:"Configuration"}),n.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."}),x&&n.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[n.jsx("span",{className:"status-banner-icon",children:"✓"}),n.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:"Provider Preset"}),n.jsxs("select",{className:"form-input",value:a,onChange:Q=>X(Q.target.value),children:[n.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),n.jsx("option",{value:"ollama",children:"Ollama (local)"}),n.jsx("option",{value:"openai",children:"OpenAI"}),n.jsx("option",{value:"groq",children:"Groq"}),n.jsx("option",{value:"together",children:"Together"})]})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsxs("label",{className:"form-label",children:["API Key ",l==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),n.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:y,onChange:Q=>w(Q.target.value),onBlur:()=>{y.trim()&&re(l,f,y.trim())},placeholder:x?"••••••••••••••••":"sk-... (not needed for Ollama)"}),n.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."})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("label",{className:"form-label",children:"Model"}),n.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:xe,disabled:O,title:"Re-fetch the model list from the provider",children:O?"Loading…":"↻ Refresh"})]}),I.length===0?n.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:O?"Loading models…":l==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const Q=I,q=Q.includes(g),A=Q.length>12,$=Z.trim().toLowerCase();let ae=$?Q.filter(ne=>ne.toLowerCase().includes($)):Q;return q&&!ae.includes(g)&&(ae=[g,...ae]),n.jsxs(n.Fragment,{children:[A&&n.jsx("input",{className:"form-input",value:Z,onChange:ne=>V(ne.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),n.jsxs("select",{className:"form-input",value:q?g:"__unset__",onChange:ne=>v(ne.target.value==="__unset__"?"":ne.target.value),children:[n.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),ae.map(ne=>n.jsx("option",{value:ne,children:ne},ne)),$&&ae.length===0&&n.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",Z,"”"]})]})]})})(),_&&n.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:_})]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[n.jsx("button",{className:"btn btn-primary",onClick:Ne,disabled:N||!g.trim(),title:g.trim()?void 0:"Select a model first",children:N?"Saving...":"Save & Encrypt"}),x&&n.jsx("button",{className:"btn btn-ghost",onClick:ee,disabled:k,children:k?"Testing...":"Test Connection"})]}),T&&n.jsx("div",{className:`alert ${T.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:T})]}),n.jsx(tk,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:ia,children:aa[1]}),n.jsx(Qb,{}),n.jsx(qb,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:ia,children:aa[2]}),n.jsx(Gb,{}),n.jsx(Kb,{}),n.jsx(Xb,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:ia,children:aa[3]}),n.jsx("div",{className:"card",style:{padding:"1.5rem"},children:n.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),n.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[n.jsx("li",{children:"Every tool call verified against your mandate bounds"}),n.jsx("li",{children:"Credentials never exposed to agents through MCP"}),n.jsx("li",{children:"Every action produces a signed ticket"})]})]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),n.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[n.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),n.jsx("li",{children:"For best security, run agents in sandboxed environments"}),n.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})})]}),n.jsxs("section",{children:[n.jsx("h2",{style:ia,children:aa[4]}),n.jsx(Jb,{})]})]})}function tk(){const[e,s]=h.useState(null),[a,o]=h.useState({intent:"",context:""}),[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState(null),[y,w]=h.useState(!1),x=h.useCallback(async()=>{if(!y)try{const S=await z.getAIPrompts();s(S),o({intent:S.intent.current,context:S.context.current}),w(!0)}catch(S){p(S instanceof Error?S.message:"Failed to load prompts")}},[y]),b=async S=>{if(e){u(S),p(null);try{const k=a[S],E=k.trim()===e[S].default.trim()?"":k;await z.setAIPrompt(S,E);const T=await z.getAIPrompts();s(T),o({intent:T.intent.current,context:T.context.current}),v(S),setTimeout(()=>v(null),2e3)}catch(k){p(k instanceof Error?k.message:"Save failed")}finally{u(null)}}},N=async S=>{if(confirm(`Revert ${S} prompt to the built-in default?`)){u(S),p(null);try{await z.setAIPrompt(S,"");const k=await z.getAIPrompts();s(k),o({intent:k.intent.current,context:k.context.current})}catch(k){p(k instanceof Error?k.message:"Revert failed")}finally{u(null)}}};return n.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:S=>{S.currentTarget.open&&x()},children:[n.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),n.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."}),f&&n.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:f}),!y&&!f&&n.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&n.jsxs(n.Fragment,{children:[n.jsx(Jh,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:e.intent,draft:a.intent,onChange:S=>o(k=>({...k,intent:S})),onSave:()=>b("intent"),onRevert:()=>N("intent"),saving:l==="intent",justSaved:g==="intent"}),n.jsx(Jh,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:e.context,draft:a.context,onChange:S=>o(k=>({...k,context:S})),onSave:()=>b("context"),onRevert:()=>N("context"),saving:l==="context",justSaved:g==="context"})]})]})}function Jh({kind:e,label:s,description:a,state:o,draft:l,onChange:u,onSave:f,onRevert:p,saving:g,justSaved:v}){const y=l!==o.current;return n.jsxs("section",{style:{marginBottom:"1.5rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:s}),n.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:a})]}),o.overridden&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),n.jsx("textarea",{className:"form-textarea",value:l,onChange:w=>u(w.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${s} system prompt`}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:f,disabled:g||!y,children:g?"Saving…":"Save"}),o.overridden&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:p,disabled:g,title:"Discard the override and use the built-in default",children:"Revert to default"}),v&&n.jsx("span",{className:"msg-ok",style:{fontSize:"0.78rem"},children:"Saved"}),y&&!g&&!v&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),n.jsxs("details",{style:{marginTop:"0.5rem"},children:[n.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),n.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})]}),n.jsx("span",{style:{display:"none"},children:e})]})}function nk(e){return e.proposalId?"review":"automatic"}function Qh(e,s,a={}){const o=a.status??"pending",l=a.includeAutonomous??!1,u=[];for(const f of e)o==="pending"&&f.status!=="pending"||a.profile&&f.profileId!==a.profile||u.push({kind:"proposal",id:f.id,sortTimestamp:f.createdAt,commitmentMode:"review",profileId:f.profileId,proposal:f});if(o==="all")for(const f of s){const p=nk(f);!l&&p==="automatic"||a.profile&&f.profileId!==a.profile||u.push({kind:"receipt",id:f.id,sortTimestamp:f.timestamp,commitmentMode:p,profileId:f.profileId,receipt:f})}return u.sort((f,p)=>p.sortTimestamp-f.sortTimestamp),typeof a.limit=="number"&&a.limit>0?u.slice(0,a.limit):u}const rk=["https://","http://"];function rg(e,s){return e!=null&&e.length?e.flatMap(a=>{const o=a.template.replace(/\{(\w+)\}/g,(l,u)=>{const f=s[u];return typeof f=="string"||typeof f=="number"?String(f):"\0"});return o.includes("\0")||/\{|\}/.test(o)?[]:rk.some(l=>o.toLowerCase().startsWith(l))?[{label:a.label,href:o,description:a.description}]:[]}):[]}function sg(e,s){const a=e-Math.floor(s/1e3);if(a<=0)return{label:"expired",urgent:!1,expired:!0};const o=Math.floor(a/86400),l=Math.floor(a%86400/3600),u=Math.floor(a%3600/60);let f;return o>0?f=`expires in ${o}d ${l}h`:l>0?f=`expires in ${l}h ${u}m`:f=`expires in ${Math.max(1,u)}m`,{label:f,urgent:a<2*3600,expired:!1}}function nu({profileId:e,declared:s}){const{icon:a}=_r(e,s),o=$w(e);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"id-rail",children:[n.jsx(Rp,{icon:a,className:"id-rail-icon"}),n.jsx("span",{className:"id-rail-name",children:o})]}),n.jsx("div",{className:"id-sep"})]})}function sk({proposalId:e,systemName:s}){const[a,o]=h.useState(null);if(h.useEffect(()=>{let u=!0;return o(null),z.getProposalOutcome(e).then(f=>{u&&o(f)}).catch(()=>{}),()=>{u=!1}},[e]),!a)return null;const l=wb(a,s);return l?n.jsxs("div",{className:"outcome-box",children:[n.jsx("h4",{children:l.heading}),n.jsx("p",{className:"outcome-note",children:l.note})]}):null}function ak({text:e}){return n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"ai-text",children:[n.jsxs("h4",{children:["Text — written by the AI",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})]})}let oc=null;function ik(){return oc||(oc=z.getEnrichedAuthorizations().then(e=>new Map(e.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),oc}function ok(e){const[s,a]=h.useState(void 0);return h.useEffect(()=>{let o=!0;if(e)return ik().then(l=>{o&&a(l.get(e))}),()=>{o=!1}},[e]),s}function lk(e,s){const[a,o]=h.useState(null),[l,u]=h.useState(!1),[f,p]=h.useState(null);return h.useEffect(()=>{let g=!0;return o(null),p(null),u(!0),(async()=>{var v;try{try{const x=await z.getGateContent(e);if((v=x==null?void 0:x.gateContent)!=null&&v.intent){g&&o(x.gateContent.intent);return}}catch{}const y=await z.getAttestationIntent(e);if(!y){g&&p("Intent not available or you are not an authorized approver.");return}const w=await z.decryptIntent({intentCiphertext:y.intentCiphertext,encryptedKey:y.encryptedKey,approverId:s});g&&o(w)}catch(y){g&&p(y instanceof Error?y.message:"Failed to decrypt intent")}finally{g&&u(!1)}})(),()=>{g=!1}},[e,s]),{intent:a,loading:l,error:f}}function Xh(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const s={};for(const[a,o]of Object.entries(e))(typeof o=="string"||typeof o=="number")&&(s[a]=o);return s}function ck(e){const s=Xh(e.limits),a=Xh(e.scope),o=typeof e.intent=="string"?e.intent:"",l={bounds:s,context:a,gateContent:{intent:o}};return(e.mode==="automatic"||e.mode==="review")&&(l.templateMode=e.mode),typeof e.duration_hours=="number"&&e.duration_hours>0&&(l.templateTtl=Math.round(e.duration_hours*3600)),l}function ag(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(s=>ag(s)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}const uk="setup__create_mandate";function ig({proposal:e,currentUserId:s,proposalLinks:a,toolDisplay:o,manifests:l,onContentState:u,onShownSnapshot:f,nameOf:p}){var Ue,fe,me,Te,Le;const[g,v]=h.useState(!1),[y,w]=h.useState(!1),[x,b]=h.useState(null),N=Sn(),{group:S,groupId:k,domain:E}=wt(),T=Object.entries(e.executionContext),P=vs(e.profileId),I=ok(e.authorizationId),B=_w(e.tool),{integrationId:O}=Wn(e.tool),K=Hn(O,l),{intent:_,loading:U,error:Z}=lk(e.authorizationId,s),V=io(e),M=V.toolArgs!==null,[re,de]=h.useState([]),X=[...Dw(e.executionContext,I,P),...fb(V.toolArgs),...re],xe=h.useMemo(()=>tu(V.toolArgs),[V.toolArgs]),Ne=h.useCallback(ge=>z.getProposalAttachmentPreview(e.id,ge),[e.id]);h.useEffect(()=>{u==null||u({loading:V.loading,readable:M})},[V.loading,M]);const ee=Xw(e),Q=V.toolArgs?rg(a,V.toolArgs):[],q=async()=>{if(!k){b("No active workspace; cannot open the mandate screen.");return}w(!0),b(null);try{if(!V.toolArgs){b("This content is not readable on this device yet.");return}const ge=V.toolArgs,nt=typeof ge.profile=="string"?ge.profile:"",Ze=await z.listProfiles(),Ye=Pp(nt,Ze);if(!Ye){b(`Unknown profile "${nt}".`);return}const He=await z.getProfile(Ye.id),dt=ck(ge),ft=_p(dt.bounds,He),Me=Lp(dt.context,He);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Ye.id,groupId:k,groupName:(S==null?void 0:S.name)??null,domain:E,isPersonal:!!(S!=null&&S.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...dt,bounds:ft,context:Me})),sessionStorage.setItem("agentReplacesProposal",e.id),N("/mandates/new/intent")}catch(ge){b(ge instanceof Error?ge.message:"Could not open the mandate screen.")}finally{w(!1)}},[A,$]=h.useState(null),ae=jb(A),[ne,ve]=h.useState(null),[Se,Y]=h.useState(null);h.useEffect(()=>{if(!ne||!Se){f==null||f(null);return}const ge=ne.status==="ok"?ne.readAt:Date.now();f==null||f({readAt:ge,preview:ne,requestContext:Se,...V.toolArgs?{toolArgs:V.toolArgs}:{},sealed:V.sealed})},[ne,Se,V.toolArgs,V.sealed,f]);const{toolName:ce}=Wn(e.tool),ie=(Le=(Te=(me=(fe=(Ue=l==null?void 0:l.find(ge=>ge.id===O))==null?void 0:Ue.toolGating)==null?void 0:fe.overrides)==null?void 0:me[ce])==null?void 0:Te.sourceFromArg)==null?void 0:Le.arg,te=V.toolArgs?n.jsx(Sc,{args:V.toolArgs,display:o,heading:"",requestRefArg:ie}):null,ze=V.toolArgs?n.jsxs(n.Fragment,{children:[n.jsx(Sc,{args:V.toolArgs,display:o,heading:"",requestRefArg:ie}),T.length>0&&n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:T.map(([ge,nt],Ze)=>{const{label:Ye,hint:He}=zw(ge,P);return n.jsxs("span",{children:[Ze>0&&" · ",n.jsxs("span",{title:He,children:[Ye,"=",ag(nt)]})]},ge)})})]}):null;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"approval-summary","data-testid":"approval-summary",children:mp(e.tool,V.toolArgs,l)}),n.jsx("div",{className:"approval-headline",children:B}),V.sealed&&V.undecryptable&&n.jsxs("div",{className:"preview-box","data-testid":"proposal-undecryptable",style:{marginBottom:"0.5rem"},children:[n.jsx("strong",{children:"Encrypted for another device."}),n.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."})]}),V.sealed&&V.loading&&n.jsx("div",{className:"preview-box","data-testid":"proposal-decrypting",style:{marginBottom:"0.5rem"},children:"Decrypting…"}),ae&&M&&n.jsxs("div",{className:"preview-box preview-box-ok","data-testid":"bound-values-open",style:{marginBottom:"0.5rem"},children:[n.jsxs("h4",{children:["What will be sent",V.sealed?n.jsx(n.Fragment,{children:n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})}):n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),te]}),M&&V.toolArgs&&uh(V.toolArgs,o)!==void 0&&n.jsx(ak,{text:uh(V.toolArgs,o)}),M&&n.jsx(Jp,{attachments:xe.attachments,inserts:xe.inserts,manifests:l,fetchPreview:Ne,onChecks:de}),ee.length>0&&n.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: ",ee.map(ge=>(p==null?void 0:p(ge))??ge).join(", ")," — shared automatically once they sign in on a device."]}),M&&n.jsx(Nb,{proposalId:e.id,systemName:K,toolArgs:V.toolArgs,sealed:V.sealed,onTone:$,onData:ve}),M&&n.jsx($b,{proposalId:e.id,onData:Y}),M&&n.jsxs("details",{className:"creation-legend-fold",children:[n.jsx("summary",{"aria-label":"What the marks mean",children:"?"}),n.jsxs("p",{className:"creation-legend","data-testid":"au10-legend",children:[n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-sealed"}),"sealed — approved and executed exactly so"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot creation-legend-dot-system"}),"from the system — read by the gateway, not by the AI"]}),n.jsxs("span",{children:[n.jsx("i",{className:"creation-legend-dot au10-dot-ai"}),"the AI's own claim or text — not checked"]}),V.sealed&&n.jsx("span",{children:"Decrypted on this device — suveren.ai stores only an unreadable copy and its fingerprint."})]})]}),X.length>0&&n.jsxs("div",{className:"limit-checks",children:[n.jsx("h4",{children:"Within your limits"}),n.jsx("ul",{className:"limit-check-list",children:X.map(ge=>n.jsxs("li",{className:ge.ok?"ok":"bad",children:[n.jsx("span",{className:"limit-check-icon",children:ge.ok?"✓":"✗"}),n.jsxs("span",{children:[ge.label,ge.valueText||ge.limitText?` ${ge.valueText} — your limit ${ge.limitText}`:""]})]},ge.key))})]}),n.jsxs("div",{className:"mandate-intent",children:[n.jsxs("dl",{children:[n.jsx("dt",{children:"Mandate"}),n.jsx("dd",{children:n.jsx("strong",{children:(P==null?void 0:P.name)??Bt(e.profileId)})})]}),n.jsxs("dl",{children:[n.jsx("dt",{children:"Intent"}),n.jsx("dd",{children:Z?n.jsx("p",{className:"msg-error",style:{fontSize:"0.8rem",margin:0},children:Z}):_!==null?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:`intent-text${g?"":" intent-clamped"}`,children:_}),n.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>v(!g),children:g?"Show less":"Show full intent"})]}):U?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"Loading intent…"}):n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]})]}),M&&Q.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:Q.map(ge=>n.jsxs("a",{href:ge.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:ge.description??ge.href,children:[ge.label," ↗"]},ge.label))}),!ae&&M&&n.jsxs("details",{className:"proposal-args-fold",style:{marginBottom:"0.75rem"},children:[n.jsx("summary",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",cursor:"pointer"},children:"Details (exactly what is bound)"}),n.jsx("div",{style:{marginTop:"0.5rem"},children:ze})]}),M&&e.tool===uk&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.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 ",n.jsx("strong",{children:"your words"})," once you approve. Edit it first — nothing is created until you sign on the mandate screen."]}),n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm","data-testid":"edit-before-signing",onClick:q,disabled:y,children:y?"Opening…":"Edit before signing"}),x&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.8rem",margin:"0.4rem 0 0"},children:x})]})]})}function og({note:e,onNoteChange:s,onSend:a,onCancel:o,sending:l,error:u}){return n.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:"var(--radius-md)",background:"var(--bg-main)",padding:"0.75rem 0.875rem",marginTop:"0.5rem"},children:[n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:[n.jsx("strong",{style:{color:"var(--text-primary)"},children:"What should change?"})," (the AI will read this)"]}),n.jsx("div",{style:{display:"flex",gap:"0.375rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:Yj.map(f=>n.jsx("button",{type:"button",className:`filter-chip${Ep(e,f)?" selected":""}`,onClick:()=>s(Qj(e,f)),disabled:l,children:f},f))}),n.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:e,maxLength:qi,onChange:f=>s(f.target.value),rows:3,placeholder:"What should the AI do differently?",disabled:l,style:{width:"100%",resize:"vertical",fontFamily:"inherit"}}),n.jsxs("div",{style:{textAlign:"right",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[e.length," / ",qi]}),u&&n.jsx("div",{className:"error-message",style:{marginTop:"0.4rem"},children:u}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.5rem"},children:[n.jsx("button",{"data-testid":"btn-send-back",className:"btn btn-primary",onClick:a,disabled:l,children:l?"Sending…":"Send back for change"}),n.jsx("button",{className:"btn btn-ghost",onClick:o,disabled:l,children:"Cancel"})]}),n.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 dk={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},fk={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},Zh={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function lc(e){const s=Date.now()-e*1e3,a=s/36e5;return a<48?a<1?`${Math.max(1,Math.round(s/6e4))}m ago`:`${Math.round(a)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function hk(e){return e.split("__").pop()??e}function mk(e){const s=e.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function lg(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(s=>lg(s)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function em({item:e,onApprove:s,onReject:a,onChangeNeeded:o,resolving:l,proposalLinks:u,toolDisplay:f,manifests:p,currentUserId:g,inRow:v=!1}){const y=e.kind==="proposal",w=y?e.proposal.status:"executed",x=y?e.proposal.tool:e.receipt.action,b=hk(x),N=mk(x),{integrationId:S}=Wn(x),k=Hn(S,p),[E,T]=h.useState(!1),[P,I]=h.useState(""),[B,O]=h.useState(""),K=h.useRef(null),_=async()=>{const ne=K.current;if(!(!ne||!y))try{const{shownHash:ve}=await z.saveShownSnapshot(e.proposal.id,ne);return ve}catch{return}},U=async()=>{const ne=Zc(P);if(!ne.valid){O(ne.error);return}O("");const ve=await _();o==null||o(e.id,ne.trimmed,ve)},Z=y&&w==="rejected"?tS(e.proposal,g??""):null,V=y&&w==="refused"?nS(e.proposal):null,M=Zw(y?e.proposal.rejectedBy??e.proposal.approverRejectedBy??null:null),re=io(y?e.proposal:{toolArgs:void 0,content:void 0}),de=y?re.toolArgs:null,X=y?e.proposal.executionContext:e.receipt.executionContext,xe=y?null:e.receipt.cumulativeState,[Ne,ee]=h.useState(!0),[Q,q]=h.useState(!1),A=y&&re.toolArgs?rg(u,re.toolArgs):[],$=Object.entries(X??{}),ae=_r(e.profileId).testSetup||ro(x);return n.jsxs("div",{className:v?"card card-in-row":"card id-card",children:[!v&&n.jsx(nu,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[v?ae?n.jsx("div",{style:{marginBottom:"0.5rem"},children:n.jsx("span",{className:"sim-mark",children:"Test setup"})}):null:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:b}),ae&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),e.commitmentMode==="automatic"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[y&&w==="pending"&&(()=>{const ne=sg(e.proposal.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:ne.urgent?600:400,whiteSpace:"nowrap"},children:ne.label})})(),n.jsx("span",{"data-testid":Z||V?"outcome-kind":void 0,className:`status-badge ${Z?Zh[Z.kind]:V?Zh.REFUSED:fk[w]}`,children:Z?Z.kind:V?V.kind:dk[w]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:lc(e.sortTimestamp)})]})]}),y&&e.proposal.status==="executed"&&n.jsx(sk,{proposalId:e.proposal.id,systemName:k}),Z&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By ",Z.who,", ",lc(Z.at)]}),(M??Z.note)&&n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[Z.kind==="CHANGE NEEDED"?"Change: ":"Note: ",M??Z.note]})]}),V&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By the Authority Server, ",lc(V.at)]}),n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",V.message]})]}),N&&n.jsx("div",{className:"note-attention",style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-attention",children:"Irreversible action"})}),y&&typeof(de==null?void 0:de._imagePreview)=="string"&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),n.jsx("img",{src:de._imagePreview,alt:typeof(de==null?void 0:de.altText)=="string"?de.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),y&&w==="pending"?n.jsx(ig,{proposal:e.proposal,currentUserId:g??"",proposalLinks:u,toolDisplay:f,manifests:p,onContentState:({loading:ne,readable:ve})=>{q(ne),ee(ve)},onShownSnapshot:ne=>{K.current=ne}}):n.jsxs(n.Fragment,{children:[A.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:A.map(ne=>n.jsxs("a",{href:ne.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:ne.description??ne.href,children:[ne.label," ↗"]},ne.label))}),y?n.jsxs(n.Fragment,{children:[de&&n.jsx(Sc,{args:de,display:f}),$.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:$.map(([ne,ve])=>`${ne}=${lg(ve)}`).join(" · ")})]}):n.jsxs(n.Fragment,{children:[n.jsx(Xp,{receipt:e.receipt,manifests:p}),e.receipt.proposalId&&n.jsx(ng,{proposalId:e.receipt.proposalId,tool:e.receipt.action,manifests:p})]})]}),xe&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",xe.daily.count," action",xe.daily.count===1?"":"s",xe.daily.amount>0?`, ${xe.daily.amount}`:""," · ","this month: ",xe.monthly.count,xe.monthly.amount>0?`, ${xe.monthly.amount}`:""]}),y&&w==="pending"&&cp({loading:Q,readable:Ne})&&(E?n.jsx(og,{note:P,onNoteChange:I,onSend:U,onCancel:()=>{T(!1),I(""),O("")},sending:!!l,error:B}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"approval-resp",children:"Approving sends exactly this. Your approval is recorded with your name."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:async()=>s==null?void 0:s(e.id,await _()),disabled:l,children:l?"Approving…":"Approve"}),n.jsxs("button",{"data-testid":"btn-change-needed",className:"btn btn-outline-strong",onClick:()=>T(!0),disabled:l,children:[n.jsx("span",{"aria-hidden":"true",children:"↩"})," Change needed"]}),n.jsxs("button",{"data-testid":"btn-reject",className:"btn btn-outline-strong",onClick:async()=>a==null?void 0:a(e.id,await _()),disabled:l,children:[n.jsx("span",{"aria-hidden":"true",children:"✕"})," Reject"]})]})]})),!v&&n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[y?"Proposal":"Ticket",": ",e.id]})]})]})}function pk(e,s=[]){const a=new Map;for(const o of e){const l=o.name&&o.email?`${o.name} (${o.email})`:o.name||o.email||o.id;a.set(o.id,l)}for(const o of s){const l=o.userId??o.id;l&&(o.name&&o.email?a.set(l,`${o.name} (${o.email})`):o.name&&a.set(l,o.name))}return a}function gk(e,s){return e.map(a=>s.get(a)??a)}function cg(e){var b;const{groupId:s}=wt(),a=vs(e.profileId),[o,l]=h.useState(null),[u,f]=h.useState(new Map),[p,g]=h.useState(!0);h.useEffect(()=>{let N=!0;if(!s){g(!1);return}return g(!0),Promise.all([z.getTeamProfileConfig(s,e.profileId).catch(()=>null),z.getGroupById(s).catch(()=>null),z.listUsers().catch(()=>[])]).then(([S,k,E])=>{N&&(l(S),f(pk(E,(k==null?void 0:k.members)??[])))}).finally(()=>{N&&g(!1)}),()=>{N=!1}},[s,e.profileId]);const v=Qx(o??{}),y=gk(e.pendingApprovers??[],u),w=N=>u.get(N)??N,x=o&&((b=a==null?void 0:a.boundsSchema)!=null&&b.fields)?hj(e.executionContext,o,a.boundsSchema.fields):null;return{loading:p,profileConfig:o,requiredApprovals:v,approverNames:y,nameOf:w,aboveCapReason:x}}function ug(e,s){return!!e.createdBy&&!!s&&e.createdBy===s}function dg(e){return(e.pendingApprovers??[]).filter(s=>s!==e.createdBy)}function yk(e){const s=Date.now()-e*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function vk({proposal:e,currentUserId:s,onAction:a,onMessage:o,proposalLinks:l,toolDisplay:u,manifests:f,inRow:p=!1}){const[g,v]=h.useState(!1),[y,w]=h.useState(!1),[x,b]=h.useState(!1),[N,S]=h.useState(""),[k,E]=h.useState(""),[T,P]=h.useState(!1),[I,B]=h.useState(!1),[O,K]=h.useState(!0),_=h.useRef(null),U=async()=>{const $=_.current;if($)try{const{shownHash:ae}=await z.saveShownSnapshot(e.id,$);return ae}catch{return}},Z=_r(e.profileId).testSetup||ro(e.tool),V=dg(e),M=e.approvedBy??{},re=Object.keys(M).length,de=s in M,X=cg(e),xe=ug(e,s),Ne=$=>{const ae=$ instanceof Error?$.message:"Approval failed";return ae.includes("APPROVER_IS_PROPOSER")?"You can't approve your own action. Ask another approver.":ae.includes("APPROVAL_IMPOSSIBLE")?"This action cannot be approved — there is no one else eligible to approve it. Ask a team admin to add another approver.":ae},ee=async()=>{if(Vc()){o(Gc);return}v(!0),o("");try{const $=await ca(e),ae=await U(),ne=await z.approveProposal(e.id,$,ae);try{const ce=await z.getAttestationIntent(e.authorizationId);if(ce){const ie=await z.decryptIntent({intentCiphertext:ce.intentCiphertext,encryptedKey:ce.encryptedKey,approverId:s});await z.storeApprovedIntent(e.authorizationId,ie)}}catch{}const{requiredApprovals:ve,approvedCount:Se}=ne,Y=ve!==void 0&&Se!==void 0?ve-Se:void 0;o(Y===void 0?"Approved.":Y>0?`Approved. ${Y} more approval${Y===1?"":"s"} still needed.`:"Approved — the required number of approvals is met; the action is ready to execute."),a()}catch($){o(Ne($))}finally{v(!1)}},Q=async()=>{w(!0),o("");try{const $=await ca(e),ae=await U();await z.rejectProposal(e.id,Tp(),$,ae),o("Action rejected."),a()}catch($){o($ instanceof Error?$.message:"Rejection failed")}finally{w(!1)}},q=async()=>{const $=Zc(N);if(!$.valid){E($.error);return}E(""),P(!0),o("");try{const{noteEncrypted:ae}=await z.encryptProposalNote($.trimmed,up(e,s)),ne=await ca(e),ve=await U();await z.rejectProposal(e.id,{outcome:"change_needed",noteEncrypted:ae},ne,ve),o("Sent back for a change."),a()}catch(ae){o(ae instanceof Error?ae.message:"Failed to send back")}finally{P(!1)}},A=g||y||T;return n.jsxs("div",{className:p?"card card-in-row":"card id-card",children:[!p&&n.jsx(nu,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:p?"none":"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[Z&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const $=sg(e.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:$.urgent?600:400,whiteSpace:"nowrap"},children:$.label})})(),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:yk(e.createdAt)})]})]}),n.jsxs("div",{className:"approver-progress",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Needs ",X.requiredApprovals," approval",X.requiredApprovals===1?"":"s"," from:"," ",V.map(($,ae)=>n.jsxs("span",{className:`who${$ in M?" done":""}`,style:{marginLeft:ae===0?"0.25rem":"0.5rem",fontWeight:$ in M?600:void 0},children:[$ in M?"✓ ":"",X.nameOf($),$===s?" (you)":"",ae<V.length-1?",":""]},$)),X.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",re," of ",X.requiredApprovals,")"]})]}),X.aboveCapReason&&n.jsxs("div",{className:"over-limit-box","data-testid":"above-cap-reason",style:{display:"flex",gap:"0.5rem",alignItems:"flex-start",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.6rem 0.8rem",marginBottom:"0.6rem",fontSize:"0.82rem"},children:[n.jsx("span",{style:{fontWeight:700,whiteSpace:"nowrap"},children:"Above the team limit:"}),n.jsxs("span",{children:[X.aboveCapReason.fieldLabel,X.aboveCapReason.value!==void 0?` ${X.aboveCapReason.value}`:""," (limit ",String(X.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${X.nameOf(e.createdBy)}.`:""]})]}),n.jsx(ig,{proposal:e,currentUserId:s,proposalLinks:l,toolDisplay:u,manifests:f,nameOf:X.nameOf,onContentState:({loading:$,readable:ae})=>{B($),K(ae)},onShownSnapshot:$=>{_.current=$}}),!de&&cp({loading:I,readable:O})&&(x?n.jsx(og,{note:N,onNoteChange:S,onSend:q,onCancel:()=>{b(!1),S(""),E("")},sending:T,error:k}):n.jsxs(n.Fragment,{children:[!xe&&n.jsx("p",{className:"approval-resp",children:"Approving sends exactly this. Your approval is recorded with your name."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem",flexWrap:"wrap",alignItems:"center"},children:[xe?n.jsx("p",{className:"blocked-note","data-testid":"cant-approve-own-action",style:{fontSize:"0.82rem",color:"var(--text-tertiary)",margin:0},children:n.jsx("strong",{children:"You can't approve your own action."})}):n.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:A,children:g?"Approving...":"Approve"}),n.jsxs("button",{"data-testid":"btn-change-needed",className:"btn btn-outline-strong",onClick:()=>b(!0),disabled:A,children:[n.jsx("span",{"aria-hidden":"true",children:"↩"})," Change needed"]}),n.jsxs("button",{"data-testid":"btn-reject",className:"btn btn-outline-strong",onClick:Q,disabled:A,children:[n.jsx("span",{"aria-hidden":"true",children:"✕"})," ",y?"Rejecting...":"Reject"]})]})]})),de&&n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:["You approved this action.",X.requiredApprovals>1&&re<X.requiredApprovals?` Waiting on ${X.requiredApprovals-re} more approval(s).`:""]}),!p&&n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})]})}function tm({proposal:e,manifests:s,titles:a,open:o,onToggle:l,who:u,children:f}){const p=Date.now(),g=ap(e.expiresAt,p),v=Lr(),y=h.useRef(null);return h.useEffect(()=>{var w;o&&((w=y.current)==null||w.scrollIntoView({block:"nearest"}))},[o]),n.jsxs("div",{ref:y,className:`appr-item${o?" is-open":""}`,"data-testid":"approval-row","data-proposal-id":e.id,children:[n.jsxs("button",{type:"button",className:"appr-item-head","aria-expanded":o,onClick:l,children:[n.jsxs("div",{className:"appr-item-main",children:[n.jsx(us,{profileId:e.profileId,area:$r(e.profileId,v),system:pa(e.tool,s),time:sp(e.createdAt,p)}),n.jsx("div",{className:"appr-item-sum","data-testid":"approval-row-summary",children:n.jsx(pp,{proposal:e,manifests:s})}),n.jsx(da,{title:e.authorizationId?a[e.authorizationId]:void 0,area:$r(e.profileId,v)}),g&&n.jsx("div",{className:"obj-due",children:g}),u&&n.jsx("div",{className:"appr-item-who",children:u})]}),n.jsx("span",{className:"appr-item-chev","aria-hidden":"true",children:"›"})]}),o&&n.jsx("div",{className:"appr-item-body",children:f})]})}function xk(){const{domain:e,user:s}=wt(),a=(s==null?void 0:s.id)??"",[o,l]=h.useState("awaiting-me"),[u,f]=h.useState([]),[p,g]=h.useState([]),[v,y]=h.useState({}),[w,x]=h.useState(!0),[b,N]=h.useState(""),S=h.useCallback(async()=>{try{const G=await z.getProposalsForApprover();f(G)}catch{}finally{x(!1)}},[]);Oe("proposal-added",S),Oe("proposal-approved",S),Oe("proposal-rejected",S),Oe("proposal-resolved",S),Ot(S,3e4);const[k,E]=h.useState([]),T=h.useCallback(async()=>{try{const G=await z.getMyProposals(e);E(G)}catch{}},[e]);Oe("proposal-added",T),Oe("proposal-approved",T),Oe("proposal-rejected",T),Oe("proposal-resolved",T),Oe("execution-failed",T),Ot(T,3e4,e);const P=h.useMemo(()=>k.filter(G=>{var J;return G.status==="pending"&&(((J=G.pendingApprovers)==null?void 0:J.length)??0)===0}),[k]),I=h.useMemo(()=>Qh(P,[],{status:"pending"}),[P]),[B,O]=h.useState([]),K=h.useCallback(async()=>{if(a)try{const J=(await z.getMyProposals(e)).filter(ye=>ye.status==="pending"&&ye.pendingApprovers&&ye.pendingApprovers.includes(a)&&ye.approvedBy&&a in ye.approvedBy);O(J)}catch{}},[a,e]);Oe("proposal-approved",K),Oe("proposal-rejected",K),Ot(K,3e4,`${a}:${e}`);const[_,U]=h.useState([]),Z=h.useCallback(async()=>{try{const G=await z.getProposalsCreatedByMe();if(G!==null){U(G);return}U(await z.getMyPendingProposals())}catch{}},[]);Oe("proposal-added",Z),Oe("proposal-approved",Z),Oe("proposal-rejected",Z),Ot(Z,3e4),h.useEffect(()=>{z.getLabelManifests().then(g).catch(()=>{}),z.getToolDisplay().then(y).catch(()=>{})},[]);const V=G=>{var J;return(J=p.find(ye=>ye.id===G.split("__")[0]))==null?void 0:J.proposalLinks};h.useEffect(()=>{S(),T(),K(),Z()},[]);const[M,re]=h.useState([]),[de,X]=h.useState([]),[xe,Ne]=h.useState(!0),[ee,Q]=h.useState(null),[q,A]=h.useState(""),[$,ae]=h.useState("pending"),[ne,ve]=h.useState(null),[Se,Y]=h.useState(!1),ce=h.useCallback(async()=>{try{const{proposals:G,receipts:J}=await z.getThread({domain:e,status:$,sinceDays:7});re(G),X(J)}catch{}finally{Ne(!1)}},[e,$]);Ot(ce,3e4,`${e}:${$}`);const ie=async(G,J,ye,Ve)=>{if(J==="commit"&&Vc()){A(Gc);return}Q(G),A("");try{const Ge=M.find(W=>W.id===G)??k.find(W=>W.id===G),rt=Jx(Ge,e),Vt=Ge?await ca(Ge):void 0;let Dt=ye??{};if((ye==null?void 0:ye.outcome)==="change_needed"&&ye.note){const W=Ge?up(Ge,a):[a],{noteEncrypted:we}=await z.encryptProposalNote(ye.note,W);Dt={outcome:"change_needed",noteEncrypted:we}}const et=await z.resolveProposal(G,J,rt,{...Dt,contentHash:Vt,shownHash:Ve});A(J==="commit"?`Action approved. Status: ${et.status}`:(ye==null?void 0:ye.outcome)==="change_needed"?"Sent back for a change.":"Action rejected."),await Promise.all([ce(),T()])}catch(Ge){A(Ge instanceof Error?Ge.message:"Failed")}finally{Q(null)}},te=(G,J)=>ie(G,"commit",void 0,J),ze=(G,J)=>ie(G,"reject",Tp(),J),Ue=(G,J,ye)=>ie(G,"reject",Xj(J),ye),fe=h.useMemo(()=>{const G=new Set;for(const J of M)G.add(J.profileId);for(const J of de)G.add(J.profileId);return Array.from(G).sort()},[M,de]),me=h.useMemo(()=>Qh(M,de,{status:$,profile:ne??void 0,includeAutonomous:Se}),[M,de,$,ne,Se]),Te=h.useCallback(()=>{S(),K()},[S,K]),Le=h.useMemo(()=>{const G=new Set,J=[];for(const ye of[...B,..._])G.has(ye.id)||(G.add(ye.id),J.push(ye));return J.sort((ye,Ve)=>Ve.createdAt-ye.createdAt)},[B,_]),ge=u.length+I.length,[nt]=ys(),[Ze,Ye]=h.useState(()=>nt.get("open")),He=h.useMemo(()=>[...I.map(G=>G.kind==="proposal"?G.proposal.id:G.id),...u.map(G=>G.id)],[I,u]),dt=h.useRef([]),ft=h.useRef(null);h.useEffect(()=>{const G=dt.current;if(dt.current=He,He.length===1&&Ze===null&&ft.current!==He[0]){ft.current=He[0],Ye(He[0]);return}if(Ze&&!He.includes(Ze)&&G.includes(Ze)){const J=G.indexOf(Ze),ye=G.slice(J+1).find(Ve=>He.includes(Ve))??He[0]??null;Ye(ye)}},[He,Ze]);const Me=G=>Ye(J=>J===G?null:G),[pe,Pe]=h.useState({});h.useEffect(()=>{z.getMyAttestations().then(G=>{const J={};for(const ye of G)ye.authorization_id&&ye.title&&(J[ye.authorization_id]=ye.title);Pe(J)}).catch(()=>{})},[]);const Be=Le.length;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Approvals"}),n.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."}),n.jsx(Km,{what:"approve"})]}),n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[n.jsxs("button",{className:`nav-tab${o==="awaiting-me"?" active":""}`,onClick:()=>l("awaiting-me"),children:["Awaiting me ",ge>0&&n.jsx("span",{className:"pill-count",style:{marginLeft:"0.4rem"},children:ge})]}),n.jsxs("button",{className:`nav-tab${o==="awaiting-others"?" active":""}`,onClick:()=>l("awaiting-others"),children:["Awaiting others ",Be>0&&n.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:Be})]}),n.jsx("button",{className:`nav-tab${o==="all"?" active":""}`,onClick:()=>{l("all"),ce()},children:"All"})]}),o==="awaiting-me"&&n.jsx(n.Fragment,{children:w&&ge===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ge===0?n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[n.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):n.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[(b||q)&&n.jsx("div",{className:"alert alert-success",children:b||q}),I.map(G=>{const J=n.jsx(em,{proposalLinks:G.kind==="proposal"?V(G.proposal.tool):void 0,toolDisplay:G.kind==="proposal"?v[G.proposal.tool]:void 0,manifests:p,currentUserId:a,item:G,onApprove:te,onReject:ze,onChangeNeeded:Ue,resolving:ee===G.id,inRow:G.kind==="proposal"},G.id);if(G.kind!=="proposal")return J;const ye=G.proposal.id;return n.jsx(tm,{proposal:G.proposal,manifests:p,titles:pe,open:Ze===ye,onToggle:()=>Me(ye),children:J},ye)}),u.map(G=>n.jsx(tm,{proposal:G,manifests:p,titles:pe,open:Ze===G.id,onToggle:()=>Me(G.id),who:"Team approval — other people are involved",children:n.jsx(vk,{inRow:!0,proposal:G,currentUserId:a,onAction:Te,onMessage:N,proposalLinks:V(G.tool),toolDisplay:v[G.tool],manifests:p},G.id)},G.id))]})}),o==="awaiting-others"&&n.jsx(n.Fragment,{children:Le.length===0?n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[n.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:Le.map(G=>n.jsx(jk,{proposal:G,currentUserId:a,onCancel:async()=>{try{await z.rejectProposal(G.id,{reason:"cancelled by creator"}),K(),T()}catch(J){alert(J instanceof Error?J.message:"Cancel failed")}},onWithdraw:async()=>{const J=await ca(G);await z.withdrawProposal(G.id,void 0,J),Z(),K()}},G.id))})}),o==="all"&&n.jsxs(n.Fragment,{children:[q&&n.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:q}),n.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[n.jsx("button",{className:`filter-chip ${$==="pending"?"selected":""}`,onClick:()=>ae("pending"),children:"Pending"}),n.jsx("button",{className:`filter-chip ${$==="all"?"selected":""}`,onClick:()=>ae("all"),children:"All"}),fe.length>0&&n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),fe.map(G=>n.jsx("button",{className:`filter-chip ${ne===G?"selected":""}`,onClick:()=>ve(ne===G?null:G),children:Bt(G)},G)),$==="all"&&n.jsxs(n.Fragment,{children:[n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),n.jsxs("button",{className:`filter-chip ${Se?"selected":""}`,onClick:()=>Y(!Se),title:"Include actions executed without human review (automatic commitment mode)",children:[Se?"✓ ":"","Autonomous actions"]})]})]}),xe&&me.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):me.length===0?n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[n.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:$==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:$==="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."})]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:me.map(G=>n.jsx(em,{proposalLinks:G.kind==="proposal"?V(G.proposal.tool):void 0,toolDisplay:G.kind==="proposal"?v[G.proposal.tool]:void 0,manifests:p,currentUserId:a,item:G,onApprove:te,onReject:ze,onChangeNeeded:Ue,resolving:ee===G.id},G.id))})]})]})}function wk(e){const s=Date.now()-e*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function jk({proposal:e,currentUserId:s,onCancel:a,onWithdraw:o}){const[l,u]=h.useState(!1),[f,p]=h.useState(!1),[g,v]=h.useState(""),y=cg(e),w=ug(e,s),x=dg(e),b=e.approvedBy??{},N=Object.keys(b).length,S=x.length>0,k=async()=>{u(!0);try{await a()}finally{u(!1)}},E=async()=>{p(!0),v("");try{await o()}catch(P){v(P instanceof Error?P.message:"Withdraw failed")}finally{p(!1)}},T=_r(e.profileId).testSetup||ro(e.tool);return n.jsxs("div",{className:"card id-card",children:[n.jsx(nu,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:e.tool.split("__").pop()??e.tool}),T&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:wk(e.createdAt)})]}),S&&n.jsxs("div",{className:"approver-progress",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Needs ",y.requiredApprovals," approval",y.requiredApprovals===1?"":"s"," from:"," ",x.map((P,I)=>n.jsxs("span",{className:`who${P in b?" done":""}`,style:{marginLeft:I===0?"0.25rem":"0.5rem",fontWeight:P in b?600:void 0},children:[P in b?"✓ ":"",y.nameOf(P),P===s?" (you)":"",I<x.length-1?",":""]},P)),y.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",N," of ",y.requiredApprovals,")"]})]}),y.aboveCapReason&&n.jsxs("div",{className:"over-limit-box","data-testid":"above-cap-reason",style:{display:"flex",gap:"0.5rem",alignItems:"flex-start",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.6rem 0.8rem",marginBottom:"0.6rem",fontSize:"0.82rem"},children:[n.jsx("span",{style:{fontWeight:700,whiteSpace:"nowrap"},children:"Above the team limit:"}),n.jsxs("span",{children:[y.aboveCapReason.fieldLabel,y.aboveCapReason.value!==void 0?` ${y.aboveCapReason.value}`:""," (limit ",String(y.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${y.nameOf(e.createdBy)}.`:""]})]}),S&&w&&n.jsx("p",{"data-testid":"cant-approve-own-action",style:{fontSize:"0.82rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:n.jsx("strong",{children:"You can't approve your own action."})}),S&&w?n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"0.35rem",marginTop:"0.5rem"},children:[n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:E,disabled:f,children:f?"Withdrawing...":"Withdraw"}),g&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.78rem",margin:0},children:g})]}):n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:k,disabled:l,children:l?"Cancelling...":"Cancel"})})]})]})}const Sk=`# Agent Brief
|
|
88
|
-
|
|
89
|
-
You act on my behalf through Suveren — the gateway that gates every
|
|
90
|
-
privileged tool call you make. Suveren implements the bounded-authority
|
|
91
|
-
model from the open Human Agency Protocol (HAP): each mandate
|
|
92
|
-
describes an area of authority, a set of numeric limits, and a scope.
|
|
93
|
-
Operate inside those bounds or the Gatekeeper will reject your action.
|
|
94
|
-
|
|
95
|
-
## Before you act in a domain
|
|
96
|
-
|
|
97
|
-
1. Call \`list-authorizations(domain: "<domain>")\` to load the full
|
|
98
|
-
intent, scope, and usage for that area. The session brief shows only
|
|
99
|
-
a one-line summary per mandate — the Intent paragraph lives behind
|
|
100
|
-
that call, and often contains soft rules you MUST honor (e.g. "never
|
|
101
|
-
publish on weekends", "only reply in English").
|
|
102
|
-
2. If the action would exceed a bound or fall outside the scope, stop
|
|
103
|
-
and explain what would be blocked instead of trying.
|
|
104
|
-
3. If you're not sure whether an action is covered, ask me first.
|
|
105
|
-
|
|
106
|
-
## How to handle reviews
|
|
107
|
-
|
|
108
|
-
Mandates in review mode require my approval before the action
|
|
109
|
-
executes. When you propose an action:
|
|
110
|
-
- Include everything I need to judge it (title, recipients, amounts,
|
|
111
|
-
dates, attendees) in the tool arguments.
|
|
112
|
-
- Don't batch unrelated proposals — one proposal per decision.
|
|
113
|
-
|
|
114
|
-
## Standing orders
|
|
115
|
-
|
|
116
|
-
(Add your own here. Examples:)
|
|
117
|
-
|
|
118
|
-
- Every morning, summarize today's calendar and flag conflicts.
|
|
119
|
-
- On Fridays, give me a weekly review: what's done, what slipped, what's
|
|
120
|
-
next.
|
|
121
|
-
- Never email anyone outside the company without asking first.
|
|
122
|
-
- When drafting posts, prefer plain language over marketing copy.
|
|
123
|
-
`;function bk(){const[e,s]=h.useState(""),[a,o]=h.useState(""),[l,u]=h.useState(!0),[f,p]=h.useState(!1),[g,v]=h.useState(null),[y,w]=h.useState(!1),x=e!==a,b=new Blob([e]).size,N=16*1024;h.useEffect(()=>{if(!x)return;const T=I=>{I.preventDefault(),I.returnValue=""},P=I=>{var K,_;if(I.defaultPrevented||I.button!==0||I.metaKey||I.ctrlKey||I.shiftKey||I.altKey)return;const B=(_=(K=I.target)==null?void 0:K.closest)==null?void 0:_.call(K,"a");if(!B||!B.href)return;let O;try{O=new URL(B.href)}catch{return}O.origin===window.location.origin&&O.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(I.preventDefault(),I.stopPropagation()))};return window.addEventListener("beforeunload",T),document.addEventListener("click",P,!0),()=>{window.removeEventListener("beforeunload",T),document.removeEventListener("click",P,!0)}},[x]),h.useEffect(()=>{let T=!1;return z.getAgentContext().then(P=>{T||(s(P),o(P))}).catch(P=>{T||v({kind:"error",text:P instanceof Error?P.message:"Failed to load context"})}).finally(()=>{T||u(!1)}),()=>{T=!0}},[]);const S=async()=>{p(!0),v(null);try{await z.saveAgentContext(e),o(e),v({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(T){v({kind:"error",text:T instanceof Error?T.message:"Save failed"})}finally{p(!1)}},k=()=>{s(a),v(null)},E=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||s(Sk)};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Agent Brief"}),n.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!e.trim()&&!l&&n.jsx("button",{className:"btn btn-primary btn-sm",onClick:E,disabled:f,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),g&&n.jsx("div",{className:g.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:g.text}),n.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[n.jsx("div",{className:"card intent-pane chat",children:n.jsx(Gi,{target:{kind:"context"},currentText:e,onApply:T=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||s(T)},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…"})}),n.jsxs("div",{className:"card intent-pane document",children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[n.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),n.jsxs("span",{className:b>N?"msg-error":void 0,style:{fontSize:"0.75rem",color:b>N?void 0:"var(--text-muted)"},children:[b.toLocaleString()," / ",N.toLocaleString()," bytes"]})]}),n.jsx("textarea",{className:"form-textarea",value:e,onChange:T=>s(T.target.value),placeholder:l?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:l,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),n.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:k,disabled:f||!x,children:"Revert"}),n.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:S,disabled:f||!x||b>N||l,children:f?"Saving…":"Save"})]})]}),n.jsx("button",{type:"button",className:"floating-help",onClick:()=>w(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),n.jsx(wp,{open:y,onClose:()=>w(!1),ariaLabel:"Brief assistant",children:n.jsx(Gi,{target:{kind:"context"},currentText:e,onApply:T=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(s(T),w(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function kk(e){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function Nk(e){const s=e.find(l=>{var u;return l.kind==="sv-mandate"&&l.status!=="unverifiable"&&typeof((u=l.data)==null?void 0:u.profile)=="string"});if(!s)return null;const a=s.data;if(typeof a.profileLabel=="string"&&a.profileLabel)return a.profileLabel;const o=a.profile.split("@")[0].split("/").pop();return o?o.charAt(0).toUpperCase()+o.slice(1):null}function Ck(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Ek(e,s){const a=s.emailExportError?"cases unknown":`${s.coveredCases.length}/${s.loadedCases.length} cases`;return`${e.signaturesValid>0?`${e.signaturesValid} ✓ tickets`:`${e.signaturesValid} tickets`} · ${a} · ${s.ticketsReferenced.length}/${s.ticketsInPeriod.length} tickets covered`}function Tk(e){return e.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:e.emailExportError}:{kind:"ok",text:`${e.coveredCases.length} of ${e.loadedCases.length}`}}function Ak(e){return e.periodStart!==null?null:e.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:e.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function nm(e,s="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:s}}function Ik(e){return/Labels?$/.test(e)||e==="limits"||e==="fields"}function Rk(e,s){const a=s[e];return a==null||a===""||Ik(e)?null:typeof a=="object"?JSON.stringify(a):String(a)}function Pk(e){const s=[];return e.missingCases.length>0&&s.push(`cases ${e.missingCases.join(", ")}`),e.ticketsNotReferenced.length>0&&s.push(`${e.ticketsNotReferenced.length} ticket${e.ticketsNotReferenced.length===1?"":"s"}`),s.length>0?`Not in the report: ${s.join(" · ")}`:null}function $k(e,s){var a;if(s)return s;if(!e)return null;if(e.kind==="sv-ticket")return e.attrs.ref||null;if(e.kind==="sv-approval"||e.kind==="sv-mandate")return e.attrs.ticket||null;if(e.kind==="sv-case"){const o=(a=e.data)==null?void 0:a.goal;return(o==null?void 0:o.ticketId)??null}return null}const _k="allow-popups allow-popups-to-escape-sandbox",Lk="AI analysis — not verified",zk="Green = verified by the gateway — raw signed fields only",Fk="Grey dashed = the AI's own analysis, not verified",Mk="= translation by the AI, not verified",Ok="Übersetzung anzeigen / show translation";function rm(e){var a;const s=((a=e.formatNotice)==null?void 0:a.blocksNotShown)??0;return s<=0?null:`${s} ${s===1?"block was":"blocks were"} not shown — not in the allowed form (the AI's own text belongs in an AI block). Ask the AI to write the report again.`}function Bk(e){return(e.elements??[]).length===0&&e.renderedHtml.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<[^>]+>/g,"").replace(/ /g," ").trim()===""}function Dk(e,s){return s&&e.renderedHtmlGloss?e.renderedHtmlGloss:e.renderedHtml}function Uk(e,s,a){const o=new URLSearchParams(e);return o.set("element",s),a?o.set("ticket",a):o.delete("ticket"),o}const Wk={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function Hk(e){return e.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${Wk[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function Vk(e){if(!e||e.kind!=="sv-case"||!e.data)return[];const s=Array.isArray(e.data.steps)?e.data.steps:[],a=e.data.goal,o=[...s.map(l=>({n:l,isGoal:!1})),...a?[{n:a,isGoal:!0}]:[]].filter(l=>typeof l.n.ticketId=="string"&&l.n.ticketId);return o.sort((l,u)=>(l.n.time??0)-(u.n.time??0)),o.map(({n:l,isGoal:u})=>({ticketId:l.ticketId,label:String(l.action??l.ticketId),isGoal:u}))}function Gk(e){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>body{margin:12px;background:#fff}</style></head><body>${e}</body></html>`}const ru={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},Kk={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function qk(e,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"]}[e].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 Yk(e,s){const a=Kk[e].filter(o=>s[o]!==void 0);return a.length===0?null:n.jsxs("details",{style:{marginTop:"0.5rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),n.jsx("dl",{style:{...ru,marginTop:"0.5rem"},children:a.map(o=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:o}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])})]},o))})]})}function cc(e,s){return s?n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:e}),s.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",s.reason??"no further detail."]}):n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:ru,children:qk(e,s.data??{}).map(({label:a,value:o})=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:a}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:o})]},a))}),Yk(e,s.data??{})]})]}):null}function Jk({report:e,elementId:s,ticketParam:a,onClose:o,onSelectTicket:l}){var w;const u=e.elements.find(x=>x.id===s),f=$k(u,a),p=f?e.ticketDetails[f]:void 0,g=Vk(u),v=(w=e.proof.verifiedValues.find(x=>x.elementId===s))==null?void 0:w.summary,y=h.useRef(null);return h.useEffect(()=>{const x=y.current;if(!x||typeof x.getBoundingClientRect!="function")return;const b=x.getBoundingClientRect().top;(b<0||b>window.innerHeight-80)&&x.scrollIntoView({block:"start",behavior:"smooth"})},[s,a]),n.jsxs("div",{className:"card reports-detail",ref:y,children:[n.jsxs("div",{className:"card-header",children:[n.jsx("div",{className:"card-title",children:"Details"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,children:"Close"})]}),v&&n.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:v}),g.length>0&&n.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:g.map(x=>n.jsxs("button",{type:"button",className:`btn btn-sm ${x.ticketId===f?"btn-secondary":"btn-ghost"}`,"aria-pressed":x.ticketId===f,onClick:()=>l(x.ticketId),children:[x.isGoal?"Goal: ":"",x.label]},x.ticketId))}),!u&&n.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),u&&!f&&(u.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",u.reason??"no further detail."]}):n.jsx("dl",{style:ru,children:Object.keys(u.data??{}).map(x=>{const b=Rk(x,u.data??{});return b===null?null:n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:x}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:b})]},x)})})),p&&n.jsxs(n.Fragment,{children:[cc("Ticket",p.ticket),cc("Mandate",p.mandate),cc("Approval",p.approval)]}),f&&!p&&n.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",f,"."]})]})}async function Qk(e){const{html:s,filename:a}=await e.exportReport();e.download(s,a),await e.refresh()}function sm({detail:e}){return e?n.jsxs("details",{style:{marginTop:"0.25rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),n.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:e})]}):null}function Xk({report:e,open:s,selectedId:a,onOpenElement:o,detail:l}){const{proof:u,coverage:f}=e,p=Hk(e.elements),g=Pk(f),v=Tk(f),y=Ak(f),w=nm(u.signaturesValid),x=nm(u.recordsChecked);return n.jsxs("div",{className:`reports-side${s?" reports-side-open":""}`,children:[l,n.jsxs("div",{className:"card",children:[n.jsx("div",{className:"card-title",children:"Proof"}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets referenced"}),n.jsx("b",{children:u.ticketsReferenced.length})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Signatures valid"}),n.jsx("b",{className:w.kind==="ok"?"msg-ok":void 0,children:w.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Records checked"}),n.jsx("b",{className:x.kind==="ok"?"msg-ok":void 0,children:x.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Not verifiable"}),n.jsx("b",{children:u.unverifiableCount})]}),p.map(b=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===b.elementId?" reports-row-selected":""}`,onClick:()=>o(b.elementId),children:[n.jsx("span",{children:b.text}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},b.elementId))]}),n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Coverage"}),v.kind==="error"?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"reports-error",role:"alert",children:v.text}),n.jsx(sm,{detail:v.detail})]}):n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Cases"}),n.jsx("b",{children:v.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets in test period"}),n.jsxs("b",{children:[f.ticketsReferenced.length," of ",f.ticketsInPeriod.length]})]}),y&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:y.detail?"reports-error":"reports-note",role:y.detail?"alert":void 0,children:y.text}),n.jsx(sm,{detail:y.detail})]}),g&&n.jsx("p",{className:"reports-missing",children:g})]}),u.verifiedValues.length>0&&n.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Checked values"}),u.verifiedValues.map(b=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===b.elementId?" reports-row-selected":""}`,onClick:()=>o(b.elementId),title:"Show details",children:[n.jsx("span",{children:b.summary}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},b.elementId))]})]})}function Zk(){const[e,s]=h.useState(null),[a,o]=h.useState(!0),[l,u]=h.useState(null),[f,p]=h.useState(!1),[g,v]=h.useState(!1),[y,w]=h.useState(null),[x,b]=h.useState(!1),[N,S]=h.useState(!1),[k,E]=ys(),T=h.useCallback(()=>z.getReport().then(({report:M})=>s(M)).catch(M=>u(M instanceof Error?M.message:String(M))),[]),P=h.useCallback(()=>{o(!0),u(null),T().finally(()=>o(!1))},[T]);h.useEffect(()=>{P()},[P]),h.useEffect(()=>{e&&z.markReportSeen(Date.now()).then(()=>window.dispatchEvent(new Event("suveren:report-seen-changed"))).catch(()=>{})},[e==null?void 0:e.savedAt]);const I=h.useCallback(()=>{p(!0),z.recheckReport().then(({report:M})=>s(M)).catch(M=>u(M instanceof Error?M.message:String(M))).finally(()=>p(!1))},[]),B=h.useCallback(async()=>{v(!0),w(null);try{await Qk({exportReport:()=>z.exportReportWithProof(),download:(M,re)=>{const de=URL.createObjectURL(new Blob([M],{type:"text/html"})),X=document.createElement("a");X.href=de,X.download=re,X.click(),URL.revokeObjectURL(de)},refresh:T})}catch(M){w(M instanceof Error?M.message:String(M))}finally{v(!1)}},[T]),O=k.get("element"),K=k.get("ticket"),_=h.useCallback((M,re)=>{E(Uk(k,M,re))},[k,E]),U=h.useCallback(()=>{const M=new URLSearchParams(k);M.delete("element"),M.delete("ticket"),E(M,{replace:!0})},[k,E]);if(a)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(l)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(fs,{icon:"⚠",title:"Report unavailable",text:l})]});if(!e)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(fs,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const Z=kk(e.renderedHtml),V=Nk(e.elements);return n.jsx("div",{className:"page-inner reports-page",children:n.jsxs("div",{className:"reports-layout",children:[n.jsxs("div",{className:"reports-bar",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:Z}),n.jsxs("p",{className:"reports-period","data-testid":"report-period",title:Di(e.coverage).title,children:[n.jsx("b",{children:Di(e.coverage).text})," · written ",Om(e.savedAt,Date.now())]}),n.jsxs("p",{className:"page-subtitle",children:[V?`written by the AI under mandate ${V} · `:"","checked ",Ck(e.checkedAt)]})]}),n.jsxs("div",{className:"reports-bar-actions",children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:I,disabled:f,children:f?"Checking…":"Check again"}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:B,disabled:g,children:g?"Exporting…":"Export with proof"})]})]}),y&&n.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",y]}),n.jsxs("div",{className:"reports-summary-chip",children:[n.jsx("span",{children:Ek(e.proof,e.coverage)}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>b(M=>!M),children:x?"hide":"details"})]}),n.jsxs("div",{className:"reports-grid",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"reports-legend",role:"note",children:[n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-v"}),zk]}),n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-a"}),Fk," (“",Lk,"”)"]}),e.renderedHtmlGloss&&n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",Mk]})]}),rm(e)&&n.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:rm(e)}),e.renderedHtmlGloss&&n.jsxs("label",{className:"reports-gloss-switch",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:N,onChange:M=>S(M.target.checked)}),n.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:n.jsx("span",{className:"reports-gloss-thumb"})}),n.jsx("span",{children:Ok})]}),n.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."}),Bk(e)?n.jsxs("div",{className:"note-stopped","data-testid":"report-empty",style:{padding:"var(--space-4)"},children:[n.jsx("span",{className:"msg-error",children:"Nothing in this report can be shown."})," ","Ask the AI to write it again — its own text inside an AI block, the checked values as gateway elements."]}):n.jsx("iframe",{title:"Report",sandbox:_k,srcDoc:Gk(Dk(e,N)),className:"reports-iframe"})]}),n.jsx(Xk,{report:e,open:x||!!O,selectedId:O,onOpenElement:M=>_(M),detail:O?n.jsx(Jk,{report:e,elementId:O,ticketParam:K,onClose:U,onSelectTicket:M=>_(O,M)}):void 0})]})]})})}function cs({to:e}){const{search:s,hash:a}=Xt();return n.jsx(Bn,{to:`${e}${s}${a}`,replace:!0})}function eN({children:e}){const{user:s,mode:a,domain:o}=wt();return s?a==="team"&&!o?n.jsx(Bn,{to:"/onboarding",replace:!0}):n.jsx(n.Fragment,{children:e}):n.jsx(Bn,{to:"/login",replace:!0})}function tN(){const{user:e,handleSessionLocked:s,refreshGroups:a}=wt();return Oe("session-locked",o=>{const l=o==null?void 0:o.message;s(l)}),Oe("team-membership-changed",()=>{a()}),n.jsxs(hx,{children:[n.jsx(it,{path:"/login",element:e?n.jsx(Bn,{to:"/",replace:!0}):n.jsx(pw,{})}),n.jsx(it,{path:"/onboarding",element:e?n.jsx(jw,{}):n.jsx(Bn,{to:"/login",replace:!0})}),n.jsxs(it,{element:n.jsx(eN,{children:n.jsx(mw,{})}),children:[n.jsx(it,{path:"/",element:n.jsx(lj,{})}),n.jsx(it,{path:"/mandates",element:n.jsx(AS,{})}),n.jsx(it,{path:"/mandates/new/intent",element:n.jsx(Oj,{})}),n.jsx(it,{path:"/mandates/new/sign",element:n.jsx(rS,{})}),n.jsx(it,{path:"/integrations",element:n.jsx(uS,{})}),n.jsx(it,{path:"/team",element:n.jsx(dS,{})}),n.jsx(it,{path:"/tickets",element:n.jsx(Wb,{})}),n.jsx(it,{path:"/blocked",element:n.jsx(Hb,{})}),n.jsx(it,{path:"/approvals",element:n.jsx(xk,{})}),n.jsx(it,{path:"/reports",element:n.jsx(Zk,{})}),n.jsx(it,{path:"/agent/new",element:n.jsx(Bn,{to:"/mandates?new=1",replace:!0})}),n.jsx(it,{path:"/agent/gate",element:n.jsx(cs,{to:"/mandates/new/intent"})}),n.jsx(it,{path:"/agent/review",element:n.jsx(cs,{to:"/mandates/new/sign"})}),n.jsx(it,{path:"/authorizations",element:n.jsx(cs,{to:"/mandates"})}),n.jsx(it,{path:"/groups",element:n.jsx(cs,{to:"/team"})}),n.jsx(it,{path:"/audit",element:n.jsx(cs,{to:"/tickets"})}),n.jsx(it,{path:"/proposals",element:n.jsx(cs,{to:"/approvals"})}),n.jsx(it,{path:"/agent-brief",element:n.jsx(bk,{})}),n.jsx(it,{path:"/settings",element:n.jsx(ek,{})}),n.jsx(it,{path:"/settings/services",element:n.jsx(Bn,{to:"/settings",replace:!0})}),n.jsx(it,{path:"/deploy",element:n.jsx(Bn,{to:"/integrations",replace:!0})})]}),n.jsx(it,{path:"*",element:n.jsx(Bn,{to:"/",replace:!0})})]})}function nN(){return n.jsx(Mx,{children:n.jsx(e0,{children:n.jsx(r0,{children:n.jsx(tN,{})})})})}uv.createRoot(document.getElementById("root")).render(n.jsx(h.StrictMode,{children:n.jsx(nN,{})}));
|