@suveren/gateway 0.31.0 → 0.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
var ty=Object.defineProperty;var ny=(t,s,a)=>s in t?ty(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Ds=(t,s,a)=>ny(t,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 Il={exports:{}},Us={},Al={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 yf;function ry(){if(yf)return We;yf=1;var t=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"),g=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),x=Symbol.iterator;function j(A){return A===null||typeof A!="object"?null:(A=x&&A[x]||A["@@iterator"],typeof A=="function"?A:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,S={};function k(A,_,re){this.props=A,this.context=_,this.refs=S,this.updater=re||N}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,_,re){this.props=A,this.context=_,this.refs=S,this.updater=re||N}var P=T.prototype=new E;P.constructor=T,b(P,k.prototype),P.isPureReactComponent=!0;var I=Array.isArray,U=Object.prototype.hasOwnProperty,V={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function J(A,_,re){var fe,L={},Z=null,ie=null;if(_!=null)for(fe in _.ref!==void 0&&(ie=_.ref),_.key!==void 0&&(Z=""+_.key),_)U.call(_,fe)&&!F.hasOwnProperty(fe)&&(L[fe]=_[fe]);var me=arguments.length-2;if(me===1)L.children=re;else if(1<me){for(var pe=Array(me),se=0;se<me;se++)pe[se]=arguments[se+2];L.children=pe}if(A&&A.defaultProps)for(fe in me=A.defaultProps,me)L[fe]===void 0&&(L[fe]=me[fe]);return{$$typeof:t,type:A,key:Z,ref:ie,props:L,_owner:V.current}}function Q(A,_){return{$$typeof:t,type:A.type,key:_,ref:A.ref,props:A.props,_owner:A._owner}}function te(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function ee(A){var _={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(re){return _[re]})}var z=/\/+/g;function oe(A,_){return typeof A=="object"&&A!==null&&A.key!=null?ee(""+A.key):_.toString(36)}function ue(A,_,re,fe,L){var Z=typeof A;(Z==="undefined"||Z==="boolean")&&(A=null);var ie=!1;if(A===null)ie=!0;else switch(Z){case"string":case"number":ie=!0;break;case"object":switch(A.$$typeof){case t:case s:ie=!0}}if(ie)return ie=A,L=L(ie),A=fe===""?"."+oe(ie,0):fe,I(L)?(re="",A!=null&&(re=A.replace(z,"$&/")+"/"),ue(L,_,re,"",function(se){return se})):L!=null&&(te(L)&&(L=Q(L,re+(!L.key||ie&&ie.key===L.key?"":(""+L.key).replace(z,"$&/")+"/")+A)),_.push(L)),1;if(ie=0,fe=fe===""?".":fe+":",I(A))for(var me=0;me<A.length;me++){Z=A[me];var pe=fe+oe(Z,me);ie+=ue(Z,_,re,pe,L)}else if(pe=j(A),typeof pe=="function")for(A=pe.call(A),me=0;!(Z=A.next()).done;)Z=Z.value,pe=fe+oe(Z,me++),ie+=ue(Z,_,re,pe,L);else if(Z==="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 ie}function Y(A,_,re){if(A==null)return A;var fe=[],L=0;return ue(A,fe,"","",function(Z){return _.call(re,Z,L++)}),fe}function je(A){if(A._status===-1){var _=A._result;_=_(),_.then(function(re){(A._status===0||A._status===-1)&&(A._status=1,A._result=re)},function(re){(A._status===0||A._status===-1)&&(A._status=2,A._result=re)}),A._status===-1&&(A._status=0,A._result=_)}if(A._status===1)return A._result.default;throw A._result}var xe={current:null},X={transition:null},q={ReactCurrentDispatcher:xe,ReactCurrentBatchConfig:X,ReactCurrentOwner:V};function G(){throw Error("act(...) is not supported in production builds of React.")}return We.Children={map:Y,forEach:function(A,_,re){Y(A,function(){_.apply(this,arguments)},re)},count:function(A){var _=0;return Y(A,function(){_++}),_},toArray:function(A){return Y(A,function(_){return _})||[]},only:function(A){if(!te(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=p,We.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,We.act=G,We.cloneElement=function(A,_,re){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var fe=b({},A.props),L=A.key,Z=A.ref,ie=A._owner;if(_!=null){if(_.ref!==void 0&&(Z=_.ref,ie=V.current),_.key!==void 0&&(L=""+_.key),A.type&&A.type.defaultProps)var me=A.type.defaultProps;for(pe in _)U.call(_,pe)&&!F.hasOwnProperty(pe)&&(fe[pe]=_[pe]===void 0&&me!==void 0?me[pe]:_[pe])}var pe=arguments.length-2;if(pe===1)fe.children=re;else if(1<pe){me=Array(pe);for(var se=0;se<pe;se++)me[se]=arguments[se+2];fe.children=me}return{$$typeof:t,type:A.type,key:L,ref:Z,props:fe,_owner:ie}},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=J,We.createFactory=function(A){var _=J.bind(null,A);return _.type=A,_},We.createRef=function(){return{current:null}},We.forwardRef=function(A){return{$$typeof:g,render:A}},We.isValidElement=te,We.lazy=function(A){return{$$typeof:y,_payload:{_status:-1,_result:A},_init:je}},We.memo=function(A,_){return{$$typeof:v,type:A,compare:_===void 0?null:_}},We.startTransition=function(A){var _=X.transition;X.transition={};try{A()}finally{X.transition=_}},We.unstable_act=G,We.useCallback=function(A,_){return xe.current.useCallback(A,_)},We.useContext=function(A){return xe.current.useContext(A)},We.useDebugValue=function(){},We.useDeferredValue=function(A){return xe.current.useDeferredValue(A)},We.useEffect=function(A,_){return xe.current.useEffect(A,_)},We.useId=function(){return xe.current.useId()},We.useImperativeHandle=function(A,_,re){return xe.current.useImperativeHandle(A,_,re)},We.useInsertionEffect=function(A,_){return xe.current.useInsertionEffect(A,_)},We.useLayoutEffect=function(A,_){return xe.current.useLayoutEffect(A,_)},We.useMemo=function(A,_){return xe.current.useMemo(A,_)},We.useReducer=function(A,_,re){return xe.current.useReducer(A,_,re)},We.useRef=function(A){return xe.current.useRef(A)},We.useState=function(A){return xe.current.useState(A)},We.useSyncExternalStore=function(A,_,re){return xe.current.useSyncExternalStore(A,_,re)},We.useTransition=function(){return xe.current.useTransition()},We.version="18.3.1",We}var vf;function oc(){return vf||(vf=1,Al.exports=ry()),Al.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 xf;function sy(){if(xf)return Us;xf=1;var t=oc(),s=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function f(g,p,v){var y,x={},j=null,N=null;v!==void 0&&(j=""+v),p.key!==void 0&&(j=""+p.key),p.ref!==void 0&&(N=p.ref);for(y in p)o.call(p,y)&&!u.hasOwnProperty(y)&&(x[y]=p[y]);if(g&&g.defaultProps)for(y in p=g.defaultProps,p)x[y]===void 0&&(x[y]=p[y]);return{$$typeof:s,type:g,key:j,ref:N,props:x,_owner:l.current}}return Us.Fragment=a,Us.jsx=f,Us.jsxs=f,Us}var wf;function ay(){return wf||(wf=1,Il.exports=sy()),Il.exports}var n=ay(),h=oc(),pi={},Rl={exports:{}},Wt={},Pl={exports:{}},$l={};/**
|
|
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 jf;function iy(){return jf||(jf=1,(function(t){function s(X,q){var G=X.length;X.push(q);e:for(;0<G;){var A=G-1>>>1,_=X[A];if(0<l(_,q))X[A]=q,X[G]=_,G=A;else break e}}function a(X){return X.length===0?null:X[0]}function o(X){if(X.length===0)return null;var q=X[0],G=X.pop();if(G!==q){X[0]=G;e:for(var A=0,_=X.length,re=_>>>1;A<re;){var fe=2*(A+1)-1,L=X[fe],Z=fe+1,ie=X[Z];if(0>l(L,G))Z<_&&0>l(ie,L)?(X[A]=ie,X[Z]=G,A=Z):(X[A]=L,X[fe]=G,A=fe);else if(Z<_&&0>l(ie,G))X[A]=ie,X[Z]=G,A=Z;else break e}}return q}function l(X,q){var G=X.sortIndex-q.sortIndex;return G!==0?G:X.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var f=Date,g=f.now();t.unstable_now=function(){return f.now()-g}}var p=[],v=[],y=1,x=null,j=3,N=!1,b=!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(X){for(var q=a(v);q!==null;){if(q.callback===null)o(v);else if(q.startTime<=X)o(v),q.sortIndex=q.expirationTime,s(p,q);else break;q=a(v)}}function I(X){if(S=!1,P(X),!b)if(a(p)!==null)b=!0,je(U);else{var q=a(v);q!==null&&xe(I,q.startTime-X)}}function U(X,q){b=!1,S&&(S=!1,E(J),J=-1),N=!0;var G=j;try{for(P(q),x=a(p);x!==null&&(!(x.expirationTime>q)||X&&!ee());){var A=x.callback;if(typeof A=="function"){x.callback=null,j=x.priorityLevel;var _=A(x.expirationTime<=q);q=t.unstable_now(),typeof _=="function"?x.callback=_:x===a(p)&&o(p),P(q)}else o(p);x=a(p)}if(x!==null)var re=!0;else{var fe=a(v);fe!==null&&xe(I,fe.startTime-q),re=!1}return re}finally{x=null,j=G,N=!1}}var V=!1,F=null,J=-1,Q=5,te=-1;function ee(){return!(t.unstable_now()-te<Q)}function z(){if(F!==null){var X=t.unstable_now();te=X;var q=!0;try{q=F(!0,X)}finally{q?oe():(V=!1,F=null)}}else V=!1}var oe;if(typeof T=="function")oe=function(){T(z)};else if(typeof MessageChannel<"u"){var ue=new MessageChannel,Y=ue.port2;ue.port1.onmessage=z,oe=function(){Y.postMessage(null)}}else oe=function(){k(z,0)};function je(X){F=X,V||(V=!0,oe())}function xe(X,q){J=k(function(){X(t.unstable_now())},q)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(X){X.callback=null},t.unstable_continueExecution=function(){b||N||(b=!0,je(U))},t.unstable_forceFrameRate=function(X){0>X||125<X?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<X?Math.floor(1e3/X):5},t.unstable_getCurrentPriorityLevel=function(){return j},t.unstable_getFirstCallbackNode=function(){return a(p)},t.unstable_next=function(X){switch(j){case 1:case 2:case 3:var q=3;break;default:q=j}var G=j;j=q;try{return X()}finally{j=G}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(X,q){switch(X){case 1:case 2:case 3:case 4:case 5:break;default:X=3}var G=j;j=X;try{return q()}finally{j=G}},t.unstable_scheduleCallback=function(X,q,G){var A=t.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?A+G:A):G=A,X){case 1:var _=-1;break;case 2:_=250;break;case 5:_=1073741823;break;case 4:_=1e4;break;default:_=5e3}return _=G+_,X={id:y++,callback:q,priorityLevel:X,startTime:G,expirationTime:_,sortIndex:-1},G>A?(X.sortIndex=G,s(v,X),a(p)===null&&X===a(v)&&(S?(E(J),J=-1):S=!0,xe(I,G-A))):(X.sortIndex=_,s(p,X),b||N||(b=!0,je(U))),X},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(X){var q=j;return function(){var G=j;j=q;try{return X.apply(this,arguments)}finally{j=G}}}})($l)),$l}var Sf;function oy(){return Sf||(Sf=1,Pl.exports=iy()),Pl.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 bf;function ly(){if(bf)return Wt;bf=1;var t=oc(),s=oy();function a(e){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i<arguments.length;i++)r+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+e+"; 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(e,r){f(e,r),f(e+"Capture",r)}function f(e,r){for(l[e]=r,e=0;e<r.length;e++)o.add(r[e])}var g=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=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={},x={};function j(e){return p.call(x,e)?!0:p.call(y,e)?!1:v.test(e)?x[e]=!0:(y[e]=!0,!1)}function N(e,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:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function b(e,r,i,c){if(r===null||typeof r>"u"||N(e,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(e,r,i,c,d,m,w){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=c,this.attributeNamespace=d,this.mustUseProperty=i,this.propertyName=e,this.type=r,this.sanitizeURL=m,this.removeEmptyString=w}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){k[e]=new S(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var r=e[0];k[r]=new S(r,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){k[e]=new S(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){k[e]=new S(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){k[e]=new S(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){k[e]=new S(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){k[e]=new S(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){k[e]=new S(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){k[e]=new S(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function T(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var r=e.replace(E,T);k[r]=new S(r,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var r=e.replace(E,T);k[r]=new S(r,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var r=e.replace(E,T);k[r]=new S(r,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){k[e]=new S(e,1,!1,e.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(e){k[e]=new S(e,1,!1,e.toLowerCase(),null,!0,!0)});function P(e,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")&&(b(r,i,d,c)&&(i=null),c||d===null?j(r)&&(i===null?e.removeAttribute(r):e.setAttribute(r,""+i)):d.mustUseProperty?e[d.propertyName]=i===null?d.type===3?!1:"":i:(r=d.attributeName,c=d.attributeNamespace,i===null?e.removeAttribute(r):(d=d.type,i=d===3||d===4&&i===!0?"":""+i,c?e.setAttributeNS(c,r,i):e.setAttribute(r,i))))}var I=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,U=Symbol.for("react.element"),V=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),J=Symbol.for("react.strict_mode"),Q=Symbol.for("react.profiler"),te=Symbol.for("react.provider"),ee=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),oe=Symbol.for("react.suspense"),ue=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),je=Symbol.for("react.lazy"),xe=Symbol.for("react.offscreen"),X=Symbol.iterator;function q(e){return e===null||typeof e!="object"?null:(e=X&&e[X]||e["@@iterator"],typeof e=="function"?e:null)}var G=Object.assign,A;function _(e){if(A===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);A=r&&r[1]||""}return`
|
|
34
|
-
`+A+e}var re=!1;function fe(e,r){if(!e||re)return"";re=!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(W){var c=W}Reflect.construct(e,[],r)}else{try{r.call()}catch(W){c=W}e.call(r.prototype)}else{try{throw Error()}catch(W){c=W}e()}}catch(W){if(W&&c&&typeof W.stack=="string"){for(var d=W.stack.split(`
|
|
35
|
-
`),m=c.stack.split(`
|
|
36
|
-
`),w=d.length-1,C=m.length-1;1<=w&&0<=C&&d[w]!==m[C];)C--;for(;1<=w&&0<=C;w--,C--)if(d[w]!==m[C]){if(w!==1||C!==1)do if(w--,C--,0>C||d[w]!==m[C]){var R=`
|
|
37
|
-
`+d[w].replace(" at new "," at ");return e.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",e.displayName)),R}while(1<=w&&0<=C);break}}}finally{re=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?_(e):""}function L(e){switch(e.tag){case 5:return _(e.type);case 16:return _("Lazy");case 13:return _("Suspense");case 19:return _("SuspenseList");case 0:case 2:case 15:return e=fe(e.type,!1),e;case 11:return e=fe(e.type.render,!1),e;case 1:return e=fe(e.type,!0),e;default:return""}}function Z(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case V:return"Portal";case Q:return"Profiler";case J:return"StrictMode";case oe:return"Suspense";case ue:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case z:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Y:return r=e.displayName||null,r!==null?r:Z(e.type)||"Memo";case je:r=e._payload,e=e._init;try{return Z(e(r))}catch{}}return null}function ie(e){var r=e.type;switch(e.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 e=r.render,e=e.displayName||e.name||"",r.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Z(r);case 8:return r===J?"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 me(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function pe(e){var r=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function se(e){var r=pe(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,r),c=""+e[r];if(!e.hasOwnProperty(r)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var d=i.get,m=i.set;return Object.defineProperty(e,r,{configurable:!0,get:function(){return d.call(this)},set:function(w){c=""+w,m.call(this,w)}}),Object.defineProperty(e,r,{enumerable:i.enumerable}),{getValue:function(){return c},setValue:function(w){c=""+w},stopTracking:function(){e._valueTracker=null,delete e[r]}}}}function be(e){e._valueTracker||(e._valueTracker=se(e))}function Le(e){if(!e)return!1;var r=e._valueTracker;if(!r)return!0;var i=r.getValue(),c="";return e&&(c=pe(e)?e.checked?"true":"false":e.value),e=c,e!==i?(r.setValue(e),!0):!1}function ge(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function $e(e,r){var i=r.checked;return G({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function qe(e,r){var i=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;i=me(r.value!=null?r.value:i),e._wrapperState={initialChecked:c,initialValue:i,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Ge(e,r){r=r.checked,r!=null&&P(e,"checked",r,!1)}function Me(e,r){Ge(e,r);var i=me(r.value),c=r.type;if(i!=null)c==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(c==="submit"||c==="reset"){e.removeAttribute("value");return}r.hasOwnProperty("value")?Ze(e,r.type,i):r.hasOwnProperty("defaultValue")&&Ze(e,r.type,me(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(e.defaultChecked=!!r.defaultChecked)}function xt(e,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=""+e._wrapperState.initialValue,i||r===e.value||(e.value=r),e.defaultValue=r}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function Ze(e,r,i){(r!=="number"||ge(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Xe=Array.isArray;function Je(e,r,i,c){if(e=e.options,r){r={};for(var d=0;d<i.length;d++)r["$"+i[d]]=!0;for(i=0;i<e.length;i++)d=r.hasOwnProperty("$"+e[i].value),e[i].selected!==d&&(e[i].selected=d),d&&c&&(e[i].defaultSelected=!0)}else{for(i=""+me(i),r=null,d=0;d<e.length;d++){if(e[d].value===i){e[d].selected=!0,c&&(e[d].defaultSelected=!0);return}r!==null||e[d].disabled||(r=e[d])}r!==null&&(r.selected=!0)}}function wt(e,r){if(r.dangerouslySetInnerHTML!=null)throw Error(a(91));return G({},r,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function mt(e,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(Xe(i)){if(1<i.length)throw Error(a(93));i=i[0]}r=i}r==null&&(r=""),i=r}e._wrapperState={initialValue:me(i)}}function ze(e,r){var i=me(r.value),c=me(r.defaultValue);i!=null&&(i=""+i,i!==e.value&&(e.value=i),r.defaultValue==null&&e.defaultValue!==i&&(e.defaultValue=i)),c!=null&&(e.defaultValue=""+c)}function he(e){var r=e.textContent;r===e._wrapperState.initialValue&&r!==""&&r!==null&&(e.value=r)}function Pe(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Fe(e,r){return e==null||e==="http://www.w3.org/1999/xhtml"?Pe(r):e==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var H,K=(function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,i,c,d){MSApp.execUnsafeLocalFunction(function(){return e(r,i,c,d)})}:e})(function(e,r){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=r;else{for(H=H||document.createElement("div"),H.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=H.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;r.firstChild;)e.appendChild(r.firstChild)}});function ye(e,r){if(r){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=r;return}}e.textContent=r}var He={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},Ue=["Webkit","ms","Moz","O"];Object.keys(He).forEach(function(e){Ue.forEach(function(r){r=r+e.charAt(0).toUpperCase()+e.substring(1),He[r]=He[e]})});function st(e,r,i){return r==null||typeof r=="boolean"||r===""?"":i||typeof r!="number"||r===0||He.hasOwnProperty(e)&&He[e]?(""+r).trim():r+"px"}function zt(e,r){e=e.style;for(var i in r)if(r.hasOwnProperty(i)){var c=i.indexOf("--")===0,d=st(i,r[i],c);i==="float"&&(i="cssFloat"),c?e.setProperty(i,d):e[i]=d}}var Ft=G({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 B(e,r){if(r){if(Ft[e]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(a(137,e));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 ve(e,r){if(e.indexOf("-")===-1)return typeof r.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ie=null;function et(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var le=null,Ne=null,we=null;function De(e){if(e=Cs(e)){if(typeof le!="function")throw Error(a(280));var r=e.stateNode;r&&(r=Aa(r),le(e.stateNode,e.type,r))}}function Oe(e){Ne?we?we.push(e):we=[e]:Ne=e}function tt(){if(Ne){var e=Ne,r=we;if(we=Ne=null,De(e),r)for(e=0;e<r.length;e++)De(r[e])}}function Gt(e,r){return e(r)}function tr(){}var is=!1;function la(e,r,i){if(is)return e(r,i);is=!0;try{return Gt(e,r,i)}finally{is=!1,(Ne!==null||we!==null)&&(tr(),tt())}}function Sn(e,r){var i=e.stateNode;if(i===null)return null;var c=Aa(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)||(e=e.type,c=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!c;break e;default:e=!1}if(e)return null;if(i&&typeof i!="function")throw Error(a(231,r,typeof i));return i}var nr=!1;if(g)try{var rr={};Object.defineProperty(rr,"passive",{get:function(){nr=!0}}),window.addEventListener("test",rr,rr),window.removeEventListener("test",rr,rr)}catch{nr=!1}function ca(e,r,i,c,d,m,w,C,R){var W=Array.prototype.slice.call(arguments,3);try{r.apply(i,W)}catch(ae){this.onError(ae)}}var _n=!1,sr=null,ar=!1,os=null,Cr={onError:function(e){_n=!0,sr=e}};function bn(e,r,i,c,d,m,w,C,R){_n=!1,sr=null,ca.apply(Cr,arguments)}function up(e,r,i,c,d,m,w,C,R){if(bn.apply(this,arguments),_n){if(_n){var W=sr;_n=!1,sr=null}else throw Error(a(198));ar||(ar=!0,os=W)}}function ir(e){var r=e,i=e;if(e.alternate)for(;r.return;)r=r.return;else{e=r;do r=e,(r.flags&4098)!==0&&(i=r.return),e=r.return;while(e)}return r.tag===3?i:null}function Oc(e){if(e.tag===13){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function Bc(e){if(ir(e)!==e)throw Error(a(188))}function dp(e){var r=e.alternate;if(!r){if(r=ir(e),r===null)throw Error(a(188));return r!==e?null:e}for(var i=e,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 Bc(d),e;if(m===c)return Bc(d),r;m=m.sibling}throw Error(a(188))}if(i.return!==c.return)i=d,c=m;else{for(var w=!1,C=d.child;C;){if(C===i){w=!0,i=d,c=m;break}if(C===c){w=!0,c=d,i=m;break}C=C.sibling}if(!w){for(C=m.child;C;){if(C===i){w=!0,i=m,c=d;break}if(C===c){w=!0,c=m,i=d;break}C=C.sibling}if(!w)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?e:r}function Dc(e){return e=dp(e),e!==null?Uc(e):null}function Uc(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var r=Uc(e);if(r!==null)return r;e=e.sibling}return null}var Wc=s.unstable_scheduleCallback,Hc=s.unstable_cancelCallback,fp=s.unstable_shouldYield,hp=s.unstable_requestPaint,pt=s.unstable_now,mp=s.unstable_getCurrentPriorityLevel,qi=s.unstable_ImmediatePriority,Vc=s.unstable_UserBlockingPriority,ua=s.unstable_NormalPriority,pp=s.unstable_LowPriority,Gc=s.unstable_IdlePriority,da=null,yn=null;function gp(e){if(yn&&typeof yn.onCommitFiberRoot=="function")try{yn.onCommitFiberRoot(da,e,void 0,(e.current.flags&128)===128)}catch{}}var on=Math.clz32?Math.clz32:xp,yp=Math.log,vp=Math.LN2;function xp(e){return e>>>=0,e===0?32:31-(yp(e)/vp|0)|0}var fa=64,ha=4194304;function ls(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ma(e,r){var i=e.pendingLanes;if(i===0)return 0;var c=0,d=e.suspendedLanes,m=e.pingedLanes,w=i&268435455;if(w!==0){var C=w&~d;C!==0?c=ls(C):(m&=w,m!==0&&(c=ls(m)))}else w=i&~d,w!==0?c=ls(w):m!==0&&(c=ls(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=e.entangledLanes,r!==0)for(e=e.entanglements,r&=c;0<r;)i=31-on(r),d=1<<i,c|=e[i],r&=~d;return c}function wp(e,r){switch(e){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 jp(e,r){for(var i=e.suspendedLanes,c=e.pingedLanes,d=e.expirationTimes,m=e.pendingLanes;0<m;){var w=31-on(m),C=1<<w,R=d[w];R===-1?((C&i)===0||(C&c)!==0)&&(d[w]=wp(C,r)):R<=r&&(e.expiredLanes|=C),m&=~C}}function Yi(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Kc(){var e=fa;return fa<<=1,(fa&4194240)===0&&(fa=64),e}function Ji(e){for(var r=[],i=0;31>i;i++)r.push(e);return r}function cs(e,r,i){e.pendingLanes|=r,r!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,r=31-on(r),e[r]=i}function Sp(e,r){var i=e.pendingLanes&~r;e.pendingLanes=r,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=r,e.mutableReadLanes&=r,e.entangledLanes&=r,r=e.entanglements;var c=e.eventTimes;for(e=e.expirationTimes;0<i;){var d=31-on(i),m=1<<d;r[d]=0,c[d]=-1,e[d]=-1,i&=~m}}function Qi(e,r){var i=e.entangledLanes|=r;for(e=e.entanglements;i;){var c=31-on(i),d=1<<c;d&r|e[c]&r&&(e[c]|=r),i&=~d}}var Qe=0;function qc(e){return e&=-e,1<e?4<e?(e&268435455)!==0?16:536870912:4:1}var Yc,Xi,Jc,Qc,Xc,Zi=!1,pa=[],Ln=null,zn=null,Fn=null,us=new Map,ds=new Map,Mn=[],bp="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Zc(e,r){switch(e){case"focusin":case"focusout":Ln=null;break;case"dragenter":case"dragleave":zn=null;break;case"mouseover":case"mouseout":Fn=null;break;case"pointerover":case"pointerout":us.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ds.delete(r.pointerId)}}function fs(e,r,i,c,d,m){return e===null||e.nativeEvent!==m?(e={blockedOn:r,domEventName:i,eventSystemFlags:c,nativeEvent:m,targetContainers:[d]},r!==null&&(r=Cs(r),r!==null&&Xi(r)),e):(e.eventSystemFlags|=c,r=e.targetContainers,d!==null&&r.indexOf(d)===-1&&r.push(d),e)}function kp(e,r,i,c,d){switch(r){case"focusin":return Ln=fs(Ln,e,r,i,c,d),!0;case"dragenter":return zn=fs(zn,e,r,i,c,d),!0;case"mouseover":return Fn=fs(Fn,e,r,i,c,d),!0;case"pointerover":var m=d.pointerId;return us.set(m,fs(us.get(m)||null,e,r,i,c,d)),!0;case"gotpointercapture":return m=d.pointerId,ds.set(m,fs(ds.get(m)||null,e,r,i,c,d)),!0}return!1}function eu(e){var r=or(e.target);if(r!==null){var i=ir(r);if(i!==null){if(r=i.tag,r===13){if(r=Oc(i),r!==null){e.blockedOn=r,Xc(e.priority,function(){Jc(i)});return}}else if(r===3&&i.stateNode.current.memoizedState.isDehydrated){e.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ga(e){if(e.blockedOn!==null)return!1;for(var r=e.targetContainers;0<r.length;){var i=to(e.domEventName,e.eventSystemFlags,r[0],e.nativeEvent);if(i===null){i=e.nativeEvent;var c=new i.constructor(i.type,i);Ie=c,i.target.dispatchEvent(c),Ie=null}else return r=Cs(i),r!==null&&Xi(r),e.blockedOn=i,!1;r.shift()}return!0}function tu(e,r,i){ga(e)&&i.delete(r)}function Np(){Zi=!1,Ln!==null&&ga(Ln)&&(Ln=null),zn!==null&&ga(zn)&&(zn=null),Fn!==null&&ga(Fn)&&(Fn=null),us.forEach(tu),ds.forEach(tu)}function hs(e,r){e.blockedOn===r&&(e.blockedOn=null,Zi||(Zi=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Np)))}function ms(e){function r(d){return hs(d,e)}if(0<pa.length){hs(pa[0],e);for(var i=1;i<pa.length;i++){var c=pa[i];c.blockedOn===e&&(c.blockedOn=null)}}for(Ln!==null&&hs(Ln,e),zn!==null&&hs(zn,e),Fn!==null&&hs(Fn,e),us.forEach(r),ds.forEach(r),i=0;i<Mn.length;i++)c=Mn[i],c.blockedOn===e&&(c.blockedOn=null);for(;0<Mn.length&&(i=Mn[0],i.blockedOn===null);)eu(i),i.blockedOn===null&&Mn.shift()}var Er=I.ReactCurrentBatchConfig,ya=!0;function Cp(e,r,i,c){var d=Qe,m=Er.transition;Er.transition=null;try{Qe=1,eo(e,r,i,c)}finally{Qe=d,Er.transition=m}}function Ep(e,r,i,c){var d=Qe,m=Er.transition;Er.transition=null;try{Qe=4,eo(e,r,i,c)}finally{Qe=d,Er.transition=m}}function eo(e,r,i,c){if(ya){var d=to(e,r,i,c);if(d===null)xo(e,r,c,va,i),Zc(e,c);else if(kp(d,e,r,i,c))c.stopPropagation();else if(Zc(e,c),r&4&&-1<bp.indexOf(e)){for(;d!==null;){var m=Cs(d);if(m!==null&&Yc(m),m=to(e,r,i,c),m===null&&xo(e,r,c,va,i),m===d)break;d=m}d!==null&&c.stopPropagation()}else xo(e,r,c,null,i)}}var va=null;function to(e,r,i,c){if(va=null,e=et(c),e=or(e),e!==null)if(r=ir(e),r===null)e=null;else if(i=r.tag,i===13){if(e=Oc(r),e!==null)return e;e=null}else if(i===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;e=null}else r!==e&&(e=null);return va=e,null}function nu(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(mp()){case qi:return 1;case Vc:return 4;case ua:case pp:return 16;case Gc:return 536870912;default:return 16}default:return 16}}var On=null,no=null,xa=null;function ru(){if(xa)return xa;var e,r=no,i=r.length,c,d="value"in On?On.value:On.textContent,m=d.length;for(e=0;e<i&&r[e]===d[e];e++);var w=i-e;for(c=1;c<=w&&r[i-c]===d[m-c];c++);return xa=d.slice(e,1<c?1-c:void 0)}function wa(e){var r=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&r===13&&(e=13)):e=r,e===10&&(e=13),32<=e||e===13?e:0}function ja(){return!0}function su(){return!1}function Kt(e){function r(i,c,d,m,w){this._reactName=i,this._targetInst=d,this.type=c,this.nativeEvent=m,this.target=w,this.currentTarget=null;for(var C in e)e.hasOwnProperty(C)&&(i=e[C],this[C]=i?i(m):m[C]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?ja:su,this.isPropagationStopped=su,this}return G(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=ja)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=ja)},persist:function(){},isPersistent:ja}),r}var Tr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ro=Kt(Tr),ps=G({},Tr,{view:0,detail:0}),Tp=Kt(ps),so,ao,gs,Sa=G({},ps,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:oo,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==gs&&(gs&&e.type==="mousemove"?(so=e.screenX-gs.screenX,ao=e.screenY-gs.screenY):ao=so=0,gs=e),so)},movementY:function(e){return"movementY"in e?e.movementY:ao}}),au=Kt(Sa),Ip=G({},Sa,{dataTransfer:0}),Ap=Kt(Ip),Rp=G({},ps,{relatedTarget:0}),io=Kt(Rp),Pp=G({},Tr,{animationName:0,elapsedTime:0,pseudoElement:0}),$p=Kt(Pp),_p=G({},Tr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Lp=Kt(_p),zp=G({},Tr,{data:0}),iu=Kt(zp),Fp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Mp={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"},Op={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Bp(e){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(e):(e=Op[e])?!!r[e]:!1}function oo(){return Bp}var Dp=G({},ps,{key:function(e){if(e.key){var r=Fp[e.key]||e.key;if(r!=="Unidentified")return r}return e.type==="keypress"?(e=wa(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Mp[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:oo,charCode:function(e){return e.type==="keypress"?wa(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?wa(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Up=Kt(Dp),Wp=G({},Sa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ou=Kt(Wp),Hp=G({},ps,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:oo}),Vp=Kt(Hp),Gp=G({},Tr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Kp=Kt(Gp),qp=G({},Sa,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Yp=Kt(qp),Jp=[9,13,27,32],lo=g&&"CompositionEvent"in window,ys=null;g&&"documentMode"in document&&(ys=document.documentMode);var Qp=g&&"TextEvent"in window&&!ys,lu=g&&(!lo||ys&&8<ys&&11>=ys),cu=" ",uu=!1;function du(e,r){switch(e){case"keyup":return Jp.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ir=!1;function Xp(e,r){switch(e){case"compositionend":return fu(r);case"keypress":return r.which!==32?null:(uu=!0,cu);case"textInput":return e=r.data,e===cu&&uu?null:e;default:return null}}function Zp(e,r){if(Ir)return e==="compositionend"||!lo&&du(e,r)?(e=ru(),xa=no=On=null,Ir=!1,e):null;switch(e){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 lu&&r.locale!=="ko"?null:r.data;default:return null}}var eg={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 hu(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r==="input"?!!eg[e.type]:r==="textarea"}function mu(e,r,i,c){Oe(c),r=Ea(r,"onChange"),0<r.length&&(i=new ro("onChange","change",null,i,c),e.push({event:i,listeners:r}))}var vs=null,xs=null;function tg(e){Pu(e,0)}function ba(e){var r=_r(e);if(Le(r))return e}function ng(e,r){if(e==="change")return r}var pu=!1;if(g){var co;if(g){var uo="oninput"in document;if(!uo){var gu=document.createElement("div");gu.setAttribute("oninput","return;"),uo=typeof gu.oninput=="function"}co=uo}else co=!1;pu=co&&(!document.documentMode||9<document.documentMode)}function yu(){vs&&(vs.detachEvent("onpropertychange",vu),xs=vs=null)}function vu(e){if(e.propertyName==="value"&&ba(xs)){var r=[];mu(r,xs,e,et(e)),la(tg,r)}}function rg(e,r,i){e==="focusin"?(yu(),vs=r,xs=i,vs.attachEvent("onpropertychange",vu)):e==="focusout"&&yu()}function sg(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ba(xs)}function ag(e,r){if(e==="click")return ba(r)}function ig(e,r){if(e==="input"||e==="change")return ba(r)}function og(e,r){return e===r&&(e!==0||1/e===1/r)||e!==e&&r!==r}var ln=typeof Object.is=="function"?Object.is:og;function ws(e,r){if(ln(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;var i=Object.keys(e),c=Object.keys(r);if(i.length!==c.length)return!1;for(c=0;c<i.length;c++){var d=i[c];if(!p.call(r,d)||!ln(e[d],r[d]))return!1}return!0}function xu(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function wu(e,r){var i=xu(e);e=0;for(var c;i;){if(i.nodeType===3){if(c=e+i.textContent.length,e<=r&&c>=r)return{node:i,offset:r-e};e=c}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=xu(i)}}function ju(e,r){return e&&r?e===r?!0:e&&e.nodeType===3?!1:r&&r.nodeType===3?ju(e,r.parentNode):"contains"in e?e.contains(r):e.compareDocumentPosition?!!(e.compareDocumentPosition(r)&16):!1:!1}function Su(){for(var e=window,r=ge();r instanceof e.HTMLIFrameElement;){try{var i=typeof r.contentWindow.location.href=="string"}catch{i=!1}if(i)e=r.contentWindow;else break;r=ge(e.document)}return r}function fo(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r&&(r==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||r==="textarea"||e.contentEditable==="true")}function lg(e){var r=Su(),i=e.focusedElem,c=e.selectionRange;if(r!==i&&i&&i.ownerDocument&&ju(i.ownerDocument.documentElement,i)){if(c!==null&&fo(i)){if(r=c.start,e=c.end,e===void 0&&(e=r),"selectionStart"in i)i.selectionStart=r,i.selectionEnd=Math.min(e,i.value.length);else if(e=(r=i.ownerDocument||document)&&r.defaultView||window,e.getSelection){e=e.getSelection();var d=i.textContent.length,m=Math.min(c.start,d);c=c.end===void 0?m:Math.min(c.end,d),!e.extend&&m>c&&(d=c,c=m,m=d),d=wu(i,m);var w=wu(i,c);d&&w&&(e.rangeCount!==1||e.anchorNode!==d.node||e.anchorOffset!==d.offset||e.focusNode!==w.node||e.focusOffset!==w.offset)&&(r=r.createRange(),r.setStart(d.node,d.offset),e.removeAllRanges(),m>c?(e.addRange(r),e.extend(w.node,w.offset)):(r.setEnd(w.node,w.offset),e.addRange(r)))}}for(r=[],e=i;e=e.parentNode;)e.nodeType===1&&r.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<r.length;i++)e=r[i],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var cg=g&&"documentMode"in document&&11>=document.documentMode,Ar=null,ho=null,js=null,mo=!1;function bu(e,r,i){var c=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;mo||Ar==null||Ar!==ge(c)||(c=Ar,"selectionStart"in c&&fo(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}),js&&ws(js,c)||(js=c,c=Ea(ho,"onSelect"),0<c.length&&(r=new ro("onSelect","select",null,r,i),e.push({event:r,listeners:c}),r.target=Ar)))}function ka(e,r){var i={};return i[e.toLowerCase()]=r.toLowerCase(),i["Webkit"+e]="webkit"+r,i["Moz"+e]="moz"+r,i}var Rr={animationend:ka("Animation","AnimationEnd"),animationiteration:ka("Animation","AnimationIteration"),animationstart:ka("Animation","AnimationStart"),transitionend:ka("Transition","TransitionEnd")},po={},ku={};g&&(ku=document.createElement("div").style,"AnimationEvent"in window||(delete Rr.animationend.animation,delete Rr.animationiteration.animation,delete Rr.animationstart.animation),"TransitionEvent"in window||delete Rr.transitionend.transition);function Na(e){if(po[e])return po[e];if(!Rr[e])return e;var r=Rr[e],i;for(i in r)if(r.hasOwnProperty(i)&&i in ku)return po[e]=r[i];return e}var Nu=Na("animationend"),Cu=Na("animationiteration"),Eu=Na("animationstart"),Tu=Na("transitionend"),Iu=new Map,Au="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Bn(e,r){Iu.set(e,r),u(r,[e])}for(var go=0;go<Au.length;go++){var yo=Au[go],ug=yo.toLowerCase(),dg=yo[0].toUpperCase()+yo.slice(1);Bn(ug,"on"+dg)}Bn(Nu,"onAnimationEnd"),Bn(Cu,"onAnimationIteration"),Bn(Eu,"onAnimationStart"),Bn("dblclick","onDoubleClick"),Bn("focusin","onFocus"),Bn("focusout","onBlur"),Bn(Tu,"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 Ss="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(" "),fg=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ss));function Ru(e,r,i){var c=e.type||"unknown-event";e.currentTarget=i,up(c,r,void 0,e),e.currentTarget=null}function Pu(e,r){r=(r&4)!==0;for(var i=0;i<e.length;i++){var c=e[i],d=c.event;c=c.listeners;e:{var m=void 0;if(r)for(var w=c.length-1;0<=w;w--){var C=c[w],R=C.instance,W=C.currentTarget;if(C=C.listener,R!==m&&d.isPropagationStopped())break e;Ru(d,C,W),m=R}else for(w=0;w<c.length;w++){if(C=c[w],R=C.instance,W=C.currentTarget,C=C.listener,R!==m&&d.isPropagationStopped())break e;Ru(d,C,W),m=R}}}if(ar)throw e=os,ar=!1,os=null,e}function at(e,r){var i=r[No];i===void 0&&(i=r[No]=new Set);var c=e+"__bubble";i.has(c)||($u(r,e,2,!1),i.add(c))}function vo(e,r,i){var c=0;r&&(c|=4),$u(i,e,c,r)}var Ca="_reactListening"+Math.random().toString(36).slice(2);function bs(e){if(!e[Ca]){e[Ca]=!0,o.forEach(function(i){i!=="selectionchange"&&(fg.has(i)||vo(i,!1,e),vo(i,!0,e))});var r=e.nodeType===9?e:e.ownerDocument;r===null||r[Ca]||(r[Ca]=!0,vo("selectionchange",!1,r))}}function $u(e,r,i,c){switch(nu(r)){case 1:var d=Cp;break;case 4:d=Ep;break;default:d=eo}i=d.bind(null,r,i,e),d=void 0,!nr||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(d=!0),c?d!==void 0?e.addEventListener(r,i,{capture:!0,passive:d}):e.addEventListener(r,i,!0):d!==void 0?e.addEventListener(r,i,{passive:d}):e.addEventListener(r,i,!1)}function xo(e,r,i,c,d){var m=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var w=c.tag;if(w===3||w===4){var C=c.stateNode.containerInfo;if(C===d||C.nodeType===8&&C.parentNode===d)break;if(w===4)for(w=c.return;w!==null;){var R=w.tag;if((R===3||R===4)&&(R=w.stateNode.containerInfo,R===d||R.nodeType===8&&R.parentNode===d))return;w=w.return}for(;C!==null;){if(w=or(C),w===null)return;if(R=w.tag,R===5||R===6){c=m=w;continue e}C=C.parentNode}}c=c.return}la(function(){var W=m,ae=et(i),ce=[];e:{var ne=Iu.get(e);if(ne!==void 0){var Se=ro,Ce=e;switch(e){case"keypress":if(wa(i)===0)break e;case"keydown":case"keyup":Se=Up;break;case"focusin":Ce="focus",Se=io;break;case"focusout":Ce="blur",Se=io;break;case"beforeblur":case"afterblur":Se=io;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":Se=au;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Se=Ap;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Se=Vp;break;case Nu:case Cu:case Eu:Se=$p;break;case Tu:Se=Kp;break;case"scroll":Se=Tp;break;case"wheel":Se=Yp;break;case"copy":case"cut":case"paste":Se=Lp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Se=ou}var Ee=(r&4)!==0,gt=!Ee&&e==="scroll",O=Ee?ne!==null?ne+"Capture":null:ne;Ee=[];for(var $=W,D;$!==null;){D=$;var de=D.stateNode;if(D.tag===5&&de!==null&&(D=de,O!==null&&(de=Sn($,O),de!=null&&Ee.push(ks($,de,D)))),gt)break;$=$.return}0<Ee.length&&(ne=new Se(ne,Ce,null,i,ae),ce.push({event:ne,listeners:Ee}))}}if((r&7)===0){e:{if(ne=e==="mouseover"||e==="pointerover",Se=e==="mouseout"||e==="pointerout",ne&&i!==Ie&&(Ce=i.relatedTarget||i.fromElement)&&(or(Ce)||Ce[kn]))break e;if((Se||ne)&&(ne=ae.window===ae?ae:(ne=ae.ownerDocument)?ne.defaultView||ne.parentWindow:window,Se?(Ce=i.relatedTarget||i.toElement,Se=W,Ce=Ce?or(Ce):null,Ce!==null&&(gt=ir(Ce),Ce!==gt||Ce.tag!==5&&Ce.tag!==6)&&(Ce=null)):(Se=null,Ce=W),Se!==Ce)){if(Ee=au,de="onMouseLeave",O="onMouseEnter",$="mouse",(e==="pointerout"||e==="pointerover")&&(Ee=ou,de="onPointerLeave",O="onPointerEnter",$="pointer"),gt=Se==null?ne:_r(Se),D=Ce==null?ne:_r(Ce),ne=new Ee(de,$+"leave",Se,i,ae),ne.target=gt,ne.relatedTarget=D,de=null,or(ae)===W&&(Ee=new Ee(O,$+"enter",Ce,i,ae),Ee.target=D,Ee.relatedTarget=gt,de=Ee),gt=de,Se&&Ce)t:{for(Ee=Se,O=Ce,$=0,D=Ee;D;D=Pr(D))$++;for(D=0,de=O;de;de=Pr(de))D++;for(;0<$-D;)Ee=Pr(Ee),$--;for(;0<D-$;)O=Pr(O),D--;for(;$--;){if(Ee===O||O!==null&&Ee===O.alternate)break t;Ee=Pr(Ee),O=Pr(O)}Ee=null}else Ee=null;Se!==null&&_u(ce,ne,Se,Ee,!1),Ce!==null&>!==null&&_u(ce,gt,Ce,Ee,!0)}}e:{if(ne=W?_r(W):window,Se=ne.nodeName&&ne.nodeName.toLowerCase(),Se==="select"||Se==="input"&&ne.type==="file")var Te=ng;else if(hu(ne))if(pu)Te=ig;else{Te=sg;var Ae=rg}else(Se=ne.nodeName)&&Se.toLowerCase()==="input"&&(ne.type==="checkbox"||ne.type==="radio")&&(Te=ag);if(Te&&(Te=Te(e,W))){mu(ce,Te,i,ae);break e}Ae&&Ae(e,ne,W),e==="focusout"&&(Ae=ne._wrapperState)&&Ae.controlled&&ne.type==="number"&&Ze(ne,"number",ne.value)}switch(Ae=W?_r(W):window,e){case"focusin":(hu(Ae)||Ae.contentEditable==="true")&&(Ar=Ae,ho=W,js=null);break;case"focusout":js=ho=Ar=null;break;case"mousedown":mo=!0;break;case"contextmenu":case"mouseup":case"dragend":mo=!1,bu(ce,i,ae);break;case"selectionchange":if(cg)break;case"keydown":case"keyup":bu(ce,i,ae)}var Re;if(lo)e:{switch(e){case"compositionstart":var _e="onCompositionStart";break e;case"compositionend":_e="onCompositionEnd";break e;case"compositionupdate":_e="onCompositionUpdate";break e}_e=void 0}else Ir?du(e,i)&&(_e="onCompositionEnd"):e==="keydown"&&i.keyCode===229&&(_e="onCompositionStart");_e&&(lu&&i.locale!=="ko"&&(Ir||_e!=="onCompositionStart"?_e==="onCompositionEnd"&&Ir&&(Re=ru()):(On=ae,no="value"in On?On.value:On.textContent,Ir=!0)),Ae=Ea(W,_e),0<Ae.length&&(_e=new iu(_e,e,null,i,ae),ce.push({event:_e,listeners:Ae}),Re?_e.data=Re:(Re=fu(i),Re!==null&&(_e.data=Re)))),(Re=Qp?Xp(e,i):Zp(e,i))&&(W=Ea(W,"onBeforeInput"),0<W.length&&(ae=new iu("onBeforeInput","beforeinput",null,i,ae),ce.push({event:ae,listeners:W}),ae.data=Re))}Pu(ce,r)})}function ks(e,r,i){return{instance:e,listener:r,currentTarget:i}}function Ea(e,r){for(var i=r+"Capture",c=[];e!==null;){var d=e,m=d.stateNode;d.tag===5&&m!==null&&(d=m,m=Sn(e,i),m!=null&&c.unshift(ks(e,m,d)),m=Sn(e,r),m!=null&&c.push(ks(e,m,d))),e=e.return}return c}function Pr(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function _u(e,r,i,c,d){for(var m=r._reactName,w=[];i!==null&&i!==c;){var C=i,R=C.alternate,W=C.stateNode;if(R!==null&&R===c)break;C.tag===5&&W!==null&&(C=W,d?(R=Sn(i,m),R!=null&&w.unshift(ks(i,R,C))):d||(R=Sn(i,m),R!=null&&w.push(ks(i,R,C)))),i=i.return}w.length!==0&&e.push({event:r,listeners:w})}var hg=/\r\n?/g,mg=/\u0000|\uFFFD/g;function Lu(e){return(typeof e=="string"?e:""+e).replace(hg,`
|
|
38
|
-
`).replace(mg,"")}function Ta(e,r,i){if(r=Lu(r),Lu(e)!==r&&i)throw Error(a(425))}function Ia(){}var wo=null,jo=null;function So(e,r){return e==="textarea"||e==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var bo=typeof setTimeout=="function"?setTimeout:void 0,pg=typeof clearTimeout=="function"?clearTimeout:void 0,zu=typeof Promise=="function"?Promise:void 0,gg=typeof queueMicrotask=="function"?queueMicrotask:typeof zu<"u"?function(e){return zu.resolve(null).then(e).catch(yg)}:bo;function yg(e){setTimeout(function(){throw e})}function ko(e,r){var i=r,c=0;do{var d=i.nextSibling;if(e.removeChild(i),d&&d.nodeType===8)if(i=d.data,i==="/$"){if(c===0){e.removeChild(d),ms(r);return}c--}else i!=="$"&&i!=="$?"&&i!=="$!"||c++;i=d}while(i);ms(r)}function Dn(e){for(;e!=null;e=e.nextSibling){var r=e.nodeType;if(r===1||r===3)break;if(r===8){if(r=e.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return e}function Fu(e){e=e.previousSibling;for(var r=0;e;){if(e.nodeType===8){var i=e.data;if(i==="$"||i==="$!"||i==="$?"){if(r===0)return e;r--}else i==="/$"&&r++}e=e.previousSibling}return null}var $r=Math.random().toString(36).slice(2),vn="__reactFiber$"+$r,Ns="__reactProps$"+$r,kn="__reactContainer$"+$r,No="__reactEvents$"+$r,vg="__reactListeners$"+$r,xg="__reactHandles$"+$r;function or(e){var r=e[vn];if(r)return r;for(var i=e.parentNode;i;){if(r=i[kn]||i[vn]){if(i=r.alternate,r.child!==null||i!==null&&i.child!==null)for(e=Fu(e);e!==null;){if(i=e[vn])return i;e=Fu(e)}return r}e=i,i=e.parentNode}return null}function Cs(e){return e=e[vn]||e[kn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function _r(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(a(33))}function Aa(e){return e[Ns]||null}var Co=[],Lr=-1;function Un(e){return{current:e}}function it(e){0>Lr||(e.current=Co[Lr],Co[Lr]=null,Lr--)}function nt(e,r){Lr++,Co[Lr]=e.current,e.current=r}var Wn={},Tt=Un(Wn),Mt=Un(!1),lr=Wn;function zr(e,r){var i=e.type.contextTypes;if(!i)return Wn;var c=e.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var d={},m;for(m in i)d[m]=r[m];return c&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=d),d}function Ot(e){return e=e.childContextTypes,e!=null}function Ra(){it(Mt),it(Tt)}function Mu(e,r,i){if(Tt.current!==Wn)throw Error(a(168));nt(Tt,r),nt(Mt,i)}function Ou(e,r,i){var c=e.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,ie(e)||"Unknown",d));return G({},i,c)}function Pa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Wn,lr=Tt.current,nt(Tt,e),nt(Mt,Mt.current),!0}function Bu(e,r,i){var c=e.stateNode;if(!c)throw Error(a(169));i?(e=Ou(e,r,lr),c.__reactInternalMemoizedMergedChildContext=e,it(Mt),it(Tt),nt(Tt,e)):it(Mt),nt(Mt,i)}var Nn=null,$a=!1,Eo=!1;function Du(e){Nn===null?Nn=[e]:Nn.push(e)}function wg(e){$a=!0,Du(e)}function Hn(){if(!Eo&&Nn!==null){Eo=!0;var e=0,r=Qe;try{var i=Nn;for(Qe=1;e<i.length;e++){var c=i[e];do c=c(!0);while(c!==null)}Nn=null,$a=!1}catch(d){throw Nn!==null&&(Nn=Nn.slice(e+1)),Wc(qi,Hn),d}finally{Qe=r,Eo=!1}}return null}var Fr=[],Mr=0,_a=null,La=0,Xt=[],Zt=0,cr=null,Cn=1,En="";function ur(e,r){Fr[Mr++]=La,Fr[Mr++]=_a,_a=e,La=r}function Uu(e,r,i){Xt[Zt++]=Cn,Xt[Zt++]=En,Xt[Zt++]=cr,cr=e;var c=Cn;e=En;var d=32-on(c)-1;c&=~(1<<d),i+=1;var m=32-on(r)+d;if(30<m){var w=d-d%5;m=(c&(1<<w)-1).toString(32),c>>=w,d-=w,Cn=1<<32-on(r)+d|i<<d|c,En=m+e}else Cn=1<<m|i<<d|c,En=e}function To(e){e.return!==null&&(ur(e,1),Uu(e,1,0))}function Io(e){for(;e===_a;)_a=Fr[--Mr],Fr[Mr]=null,La=Fr[--Mr],Fr[Mr]=null;for(;e===cr;)cr=Xt[--Zt],Xt[Zt]=null,En=Xt[--Zt],Xt[Zt]=null,Cn=Xt[--Zt],Xt[Zt]=null}var qt=null,Yt=null,ot=!1,cn=null;function Wu(e,r){var i=rn(5,null,null,0);i.elementType="DELETED",i.stateNode=r,i.return=e,r=e.deletions,r===null?(e.deletions=[i],e.flags|=16):r.push(i)}function Hu(e,r){switch(e.tag){case 5:var i=e.type;return r=r.nodeType!==1||i.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(e.stateNode=r,qt=e,Yt=Dn(r.firstChild),!0):!1;case 6:return r=e.pendingProps===""||r.nodeType!==3?null:r,r!==null?(e.stateNode=r,qt=e,Yt=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(i=cr!==null?{id:Cn,overflow:En}:null,e.memoizedState={dehydrated:r,treeContext:i,retryLane:1073741824},i=rn(18,null,null,0),i.stateNode=r,i.return=e,e.child=i,qt=e,Yt=null,!0):!1;default:return!1}}function Ao(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Ro(e){if(ot){var r=Yt;if(r){var i=r;if(!Hu(e,r)){if(Ao(e))throw Error(a(418));r=Dn(i.nextSibling);var c=qt;r&&Hu(e,r)?Wu(c,i):(e.flags=e.flags&-4097|2,ot=!1,qt=e)}}else{if(Ao(e))throw Error(a(418));e.flags=e.flags&-4097|2,ot=!1,qt=e}}}function Vu(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;qt=e}function za(e){if(e!==qt)return!1;if(!ot)return Vu(e),ot=!0,!1;var r;if((r=e.tag!==3)&&!(r=e.tag!==5)&&(r=e.type,r=r!=="head"&&r!=="body"&&!So(e.type,e.memoizedProps)),r&&(r=Yt)){if(Ao(e))throw Gu(),Error(a(418));for(;r;)Wu(e,r),r=Dn(r.nextSibling)}if(Vu(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));e:{for(e=e.nextSibling,r=0;e;){if(e.nodeType===8){var i=e.data;if(i==="/$"){if(r===0){Yt=Dn(e.nextSibling);break e}r--}else i!=="$"&&i!=="$!"&&i!=="$?"||r++}e=e.nextSibling}Yt=null}}else Yt=qt?Dn(e.stateNode.nextSibling):null;return!0}function Gu(){for(var e=Yt;e;)e=Dn(e.nextSibling)}function Or(){Yt=qt=null,ot=!1}function Po(e){cn===null?cn=[e]:cn.push(e)}var jg=I.ReactCurrentBatchConfig;function Es(e,r,i){if(e=i.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(a(309));var c=i.stateNode}if(!c)throw Error(a(147,e));var d=c,m=""+e;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===m?r.ref:(r=function(w){var C=d.refs;w===null?delete C[m]:C[m]=w},r._stringRef=m,r)}if(typeof e!="string")throw Error(a(284));if(!i._owner)throw Error(a(290,e))}return e}function Fa(e,r){throw e=Object.prototype.toString.call(r),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":e))}function Ku(e){var r=e._init;return r(e._payload)}function qu(e){function r(O,$){if(e){var D=O.deletions;D===null?(O.deletions=[$],O.flags|=16):D.push($)}}function i(O,$){if(!e)return null;for(;$!==null;)r(O,$),$=$.sibling;return null}function c(O,$){for(O=new Map;$!==null;)$.key!==null?O.set($.key,$):O.set($.index,$),$=$.sibling;return O}function d(O,$){return O=Xn(O,$),O.index=0,O.sibling=null,O}function m(O,$,D){return O.index=D,e?(D=O.alternate,D!==null?(D=D.index,D<$?(O.flags|=2,$):D):(O.flags|=2,$)):(O.flags|=1048576,$)}function w(O){return e&&O.alternate===null&&(O.flags|=2),O}function C(O,$,D,de){return $===null||$.tag!==6?($=bl(D,O.mode,de),$.return=O,$):($=d($,D),$.return=O,$)}function R(O,$,D,de){var Te=D.type;return Te===F?ae(O,$,D.props.children,de,D.key):$!==null&&($.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===je&&Ku(Te)===$.type)?(de=d($,D.props),de.ref=Es(O,$,D),de.return=O,de):(de=oi(D.type,D.key,D.props,null,O.mode,de),de.ref=Es(O,$,D),de.return=O,de)}function W(O,$,D,de){return $===null||$.tag!==4||$.stateNode.containerInfo!==D.containerInfo||$.stateNode.implementation!==D.implementation?($=kl(D,O.mode,de),$.return=O,$):($=d($,D.children||[]),$.return=O,$)}function ae(O,$,D,de,Te){return $===null||$.tag!==7?($=vr(D,O.mode,de,Te),$.return=O,$):($=d($,D),$.return=O,$)}function ce(O,$,D){if(typeof $=="string"&&$!==""||typeof $=="number")return $=bl(""+$,O.mode,D),$.return=O,$;if(typeof $=="object"&&$!==null){switch($.$$typeof){case U:return D=oi($.type,$.key,$.props,null,O.mode,D),D.ref=Es(O,null,$),D.return=O,D;case V:return $=kl($,O.mode,D),$.return=O,$;case je:var de=$._init;return ce(O,de($._payload),D)}if(Xe($)||q($))return $=vr($,O.mode,D,null),$.return=O,$;Fa(O,$)}return null}function ne(O,$,D,de){var Te=$!==null?$.key:null;if(typeof D=="string"&&D!==""||typeof D=="number")return Te!==null?null:C(O,$,""+D,de);if(typeof D=="object"&&D!==null){switch(D.$$typeof){case U:return D.key===Te?R(O,$,D,de):null;case V:return D.key===Te?W(O,$,D,de):null;case je:return Te=D._init,ne(O,$,Te(D._payload),de)}if(Xe(D)||q(D))return Te!==null?null:ae(O,$,D,de,null);Fa(O,D)}return null}function Se(O,$,D,de,Te){if(typeof de=="string"&&de!==""||typeof de=="number")return O=O.get(D)||null,C($,O,""+de,Te);if(typeof de=="object"&&de!==null){switch(de.$$typeof){case U:return O=O.get(de.key===null?D:de.key)||null,R($,O,de,Te);case V:return O=O.get(de.key===null?D:de.key)||null,W($,O,de,Te);case je:var Ae=de._init;return Se(O,$,D,Ae(de._payload),Te)}if(Xe(de)||q(de))return O=O.get(D)||null,ae($,O,de,Te,null);Fa($,de)}return null}function Ce(O,$,D,de){for(var Te=null,Ae=null,Re=$,_e=$=0,Nt=null;Re!==null&&_e<D.length;_e++){Re.index>_e?(Nt=Re,Re=null):Nt=Re.sibling;var Ye=ne(O,Re,D[_e],de);if(Ye===null){Re===null&&(Re=Nt);break}e&&Re&&Ye.alternate===null&&r(O,Re),$=m(Ye,$,_e),Ae===null?Te=Ye:Ae.sibling=Ye,Ae=Ye,Re=Nt}if(_e===D.length)return i(O,Re),ot&&ur(O,_e),Te;if(Re===null){for(;_e<D.length;_e++)Re=ce(O,D[_e],de),Re!==null&&($=m(Re,$,_e),Ae===null?Te=Re:Ae.sibling=Re,Ae=Re);return ot&&ur(O,_e),Te}for(Re=c(O,Re);_e<D.length;_e++)Nt=Se(Re,O,_e,D[_e],de),Nt!==null&&(e&&Nt.alternate!==null&&Re.delete(Nt.key===null?_e:Nt.key),$=m(Nt,$,_e),Ae===null?Te=Nt:Ae.sibling=Nt,Ae=Nt);return e&&Re.forEach(function(Zn){return r(O,Zn)}),ot&&ur(O,_e),Te}function Ee(O,$,D,de){var Te=q(D);if(typeof Te!="function")throw Error(a(150));if(D=Te.call(D),D==null)throw Error(a(151));for(var Ae=Te=null,Re=$,_e=$=0,Nt=null,Ye=D.next();Re!==null&&!Ye.done;_e++,Ye=D.next()){Re.index>_e?(Nt=Re,Re=null):Nt=Re.sibling;var Zn=ne(O,Re,Ye.value,de);if(Zn===null){Re===null&&(Re=Nt);break}e&&Re&&Zn.alternate===null&&r(O,Re),$=m(Zn,$,_e),Ae===null?Te=Zn:Ae.sibling=Zn,Ae=Zn,Re=Nt}if(Ye.done)return i(O,Re),ot&&ur(O,_e),Te;if(Re===null){for(;!Ye.done;_e++,Ye=D.next())Ye=ce(O,Ye.value,de),Ye!==null&&($=m(Ye,$,_e),Ae===null?Te=Ye:Ae.sibling=Ye,Ae=Ye);return ot&&ur(O,_e),Te}for(Re=c(O,Re);!Ye.done;_e++,Ye=D.next())Ye=Se(Re,O,_e,Ye.value,de),Ye!==null&&(e&&Ye.alternate!==null&&Re.delete(Ye.key===null?_e:Ye.key),$=m(Ye,$,_e),Ae===null?Te=Ye:Ae.sibling=Ye,Ae=Ye);return e&&Re.forEach(function(ey){return r(O,ey)}),ot&&ur(O,_e),Te}function gt(O,$,D,de){if(typeof D=="object"&&D!==null&&D.type===F&&D.key===null&&(D=D.props.children),typeof D=="object"&&D!==null){switch(D.$$typeof){case U:e:{for(var Te=D.key,Ae=$;Ae!==null;){if(Ae.key===Te){if(Te=D.type,Te===F){if(Ae.tag===7){i(O,Ae.sibling),$=d(Ae,D.props.children),$.return=O,O=$;break e}}else if(Ae.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===je&&Ku(Te)===Ae.type){i(O,Ae.sibling),$=d(Ae,D.props),$.ref=Es(O,Ae,D),$.return=O,O=$;break e}i(O,Ae);break}else r(O,Ae);Ae=Ae.sibling}D.type===F?($=vr(D.props.children,O.mode,de,D.key),$.return=O,O=$):(de=oi(D.type,D.key,D.props,null,O.mode,de),de.ref=Es(O,$,D),de.return=O,O=de)}return w(O);case V:e:{for(Ae=D.key;$!==null;){if($.key===Ae)if($.tag===4&&$.stateNode.containerInfo===D.containerInfo&&$.stateNode.implementation===D.implementation){i(O,$.sibling),$=d($,D.children||[]),$.return=O,O=$;break e}else{i(O,$);break}else r(O,$);$=$.sibling}$=kl(D,O.mode,de),$.return=O,O=$}return w(O);case je:return Ae=D._init,gt(O,$,Ae(D._payload),de)}if(Xe(D))return Ce(O,$,D,de);if(q(D))return Ee(O,$,D,de);Fa(O,D)}return typeof D=="string"&&D!==""||typeof D=="number"?(D=""+D,$!==null&&$.tag===6?(i(O,$.sibling),$=d($,D),$.return=O,O=$):(i(O,$),$=bl(D,O.mode,de),$.return=O,O=$),w(O)):i(O,$)}return gt}var Br=qu(!0),Yu=qu(!1),Ma=Un(null),Oa=null,Dr=null,$o=null;function _o(){$o=Dr=Oa=null}function Lo(e){var r=Ma.current;it(Ma),e._currentValue=r}function zo(e,r,i){for(;e!==null;){var c=e.alternate;if((e.childLanes&r)!==r?(e.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),e===i)break;e=e.return}}function Ur(e,r){Oa=e,$o=Dr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&r)!==0&&(Bt=!0),e.firstContext=null)}function en(e){var r=e._currentValue;if($o!==e)if(e={context:e,memoizedValue:r,next:null},Dr===null){if(Oa===null)throw Error(a(308));Dr=e,Oa.dependencies={lanes:0,firstContext:e}}else Dr=Dr.next=e;return r}var dr=null;function Fo(e){dr===null?dr=[e]:dr.push(e)}function Ju(e,r,i,c){var d=r.interleaved;return d===null?(i.next=i,Fo(r)):(i.next=d.next,d.next=i),r.interleaved=i,Tn(e,c)}function Tn(e,r){e.lanes|=r;var i=e.alternate;for(i!==null&&(i.lanes|=r),i=e,e=e.return;e!==null;)e.childLanes|=r,i=e.alternate,i!==null&&(i.childLanes|=r),i=e,e=e.return;return i.tag===3?i.stateNode:null}var Vn=!1;function Mo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Qu(e,r){e=e.updateQueue,r.updateQueue===e&&(r.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function In(e,r){return{eventTime:e,lane:r,tag:0,payload:null,callback:null,next:null}}function Gn(e,r,i){var c=e.updateQueue;if(c===null)return null;if(c=c.shared,(Ke&2)!==0){var d=c.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),c.pending=r,Tn(e,i)}return d=c.interleaved,d===null?(r.next=r,Fo(c)):(r.next=d.next,d.next=r),c.interleaved=r,Tn(e,i)}function Ba(e,r,i){if(r=r.updateQueue,r!==null&&(r=r.shared,(i&4194240)!==0)){var c=r.lanes;c&=e.pendingLanes,i|=c,r.lanes=i,Qi(e,i)}}function Xu(e,r){var i=e.updateQueue,c=e.alternate;if(c!==null&&(c=c.updateQueue,i===c)){var d=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var w={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};m===null?d=m=w:m=m.next=w,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},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=r:e.next=r,i.lastBaseUpdate=r}function Da(e,r,i,c){var d=e.updateQueue;Vn=!1;var m=d.firstBaseUpdate,w=d.lastBaseUpdate,C=d.shared.pending;if(C!==null){d.shared.pending=null;var R=C,W=R.next;R.next=null,w===null?m=W:w.next=W,w=R;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,C=ae.lastBaseUpdate,C!==w&&(C===null?ae.firstBaseUpdate=W:C.next=W,ae.lastBaseUpdate=R))}if(m!==null){var ce=d.baseState;w=0,ae=W=R=null,C=m;do{var ne=C.lane,Se=C.eventTime;if((c&ne)===ne){ae!==null&&(ae=ae.next={eventTime:Se,lane:0,tag:C.tag,payload:C.payload,callback:C.callback,next:null});e:{var Ce=e,Ee=C;switch(ne=r,Se=i,Ee.tag){case 1:if(Ce=Ee.payload,typeof Ce=="function"){ce=Ce.call(Se,ce,ne);break e}ce=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=Ee.payload,ne=typeof Ce=="function"?Ce.call(Se,ce,ne):Ce,ne==null)break e;ce=G({},ce,ne);break e;case 2:Vn=!0}}C.callback!==null&&C.lane!==0&&(e.flags|=64,ne=d.effects,ne===null?d.effects=[C]:ne.push(C))}else Se={eventTime:Se,lane:ne,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ae===null?(W=ae=Se,R=ce):ae=ae.next=Se,w|=ne;if(C=C.next,C===null){if(C=d.shared.pending,C===null)break;ne=C,C=ne.next,ne.next=null,d.lastBaseUpdate=ne,d.shared.pending=null}}while(!0);if(ae===null&&(R=ce),d.baseState=R,d.firstBaseUpdate=W,d.lastBaseUpdate=ae,r=d.shared.interleaved,r!==null){d=r;do w|=d.lane,d=d.next;while(d!==r)}else m===null&&(d.shared.lanes=0);mr|=w,e.lanes=w,e.memoizedState=ce}}function Zu(e,r,i){if(e=r.effects,r.effects=null,e!==null)for(r=0;r<e.length;r++){var c=e[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 Ts={},xn=Un(Ts),Is=Un(Ts),As=Un(Ts);function fr(e){if(e===Ts)throw Error(a(174));return e}function Oo(e,r){switch(nt(As,r),nt(Is,e),nt(xn,Ts),e=r.nodeType,e){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Fe(null,"");break;default:e=e===8?r.parentNode:r,r=e.namespaceURI||null,e=e.tagName,r=Fe(r,e)}it(xn),nt(xn,r)}function Wr(){it(xn),it(Is),it(As)}function ed(e){fr(As.current);var r=fr(xn.current),i=Fe(r,e.type);r!==i&&(nt(Is,e),nt(xn,i))}function Bo(e){Is.current===e&&(it(xn),it(Is))}var ut=Un(0);function Ua(e){for(var r=e;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===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Do=[];function Uo(){for(var e=0;e<Do.length;e++)Do[e]._workInProgressVersionPrimary=null;Do.length=0}var Wa=I.ReactCurrentDispatcher,Wo=I.ReactCurrentBatchConfig,hr=0,dt=null,jt=null,bt=null,Ha=!1,Rs=!1,Ps=0,Sg=0;function It(){throw Error(a(321))}function Ho(e,r){if(r===null)return!1;for(var i=0;i<r.length&&i<e.length;i++)if(!ln(e[i],r[i]))return!1;return!0}function Vo(e,r,i,c,d,m){if(hr=m,dt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Wa.current=e===null||e.memoizedState===null?Cg:Eg,e=i(c,d),Rs){m=0;do{if(Rs=!1,Ps=0,25<=m)throw Error(a(301));m+=1,bt=jt=null,r.updateQueue=null,Wa.current=Tg,e=i(c,d)}while(Rs)}if(Wa.current=Ka,r=jt!==null&&jt.next!==null,hr=0,bt=jt=dt=null,Ha=!1,r)throw Error(a(300));return e}function Go(){var e=Ps!==0;return Ps=0,e}function wn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return bt===null?dt.memoizedState=bt=e:bt=bt.next=e,bt}function tn(){if(jt===null){var e=dt.alternate;e=e!==null?e.memoizedState:null}else e=jt.next;var r=bt===null?dt.memoizedState:bt.next;if(r!==null)bt=r,jt=e;else{if(e===null)throw Error(a(310));jt=e,e={memoizedState:jt.memoizedState,baseState:jt.baseState,baseQueue:jt.baseQueue,queue:jt.queue,next:null},bt===null?dt.memoizedState=bt=e:bt=bt.next=e}return bt}function $s(e,r){return typeof r=="function"?r(e):r}function Ko(e){var r=tn(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var c=jt,d=c.baseQueue,m=i.pending;if(m!==null){if(d!==null){var w=d.next;d.next=m.next,m.next=w}c.baseQueue=d=m,i.pending=null}if(d!==null){m=d.next,c=c.baseState;var C=w=null,R=null,W=m;do{var ae=W.lane;if((hr&ae)===ae)R!==null&&(R=R.next={lane:0,action:W.action,hasEagerState:W.hasEagerState,eagerState:W.eagerState,next:null}),c=W.hasEagerState?W.eagerState:e(c,W.action);else{var ce={lane:ae,action:W.action,hasEagerState:W.hasEagerState,eagerState:W.eagerState,next:null};R===null?(C=R=ce,w=c):R=R.next=ce,dt.lanes|=ae,mr|=ae}W=W.next}while(W!==null&&W!==m);R===null?w=c:R.next=C,ln(c,r.memoizedState)||(Bt=!0),r.memoizedState=c,r.baseState=w,r.baseQueue=R,i.lastRenderedState=c}if(e=i.interleaved,e!==null){d=e;do m=d.lane,dt.lanes|=m,mr|=m,d=d.next;while(d!==e)}else d===null&&(i.lanes=0);return[r.memoizedState,i.dispatch]}function qo(e){var r=tn(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=e;var c=i.dispatch,d=i.pending,m=r.memoizedState;if(d!==null){i.pending=null;var w=d=d.next;do m=e(m,w.action),w=w.next;while(w!==d);ln(m,r.memoizedState)||(Bt=!0),r.memoizedState=m,r.baseQueue===null&&(r.baseState=m),i.lastRenderedState=m}return[m,c]}function td(){}function nd(e,r){var i=dt,c=tn(),d=r(),m=!ln(c.memoizedState,d);if(m&&(c.memoizedState=d,Bt=!0),c=c.queue,Yo(ad.bind(null,i,c,e),[e]),c.getSnapshot!==r||m||bt!==null&&bt.memoizedState.tag&1){if(i.flags|=2048,_s(9,sd.bind(null,i,c,d,r),void 0,null),kt===null)throw Error(a(349));(hr&30)!==0||rd(i,r,d)}return d}function rd(e,r,i){e.flags|=16384,e={getSnapshot:r,value:i},r=dt.updateQueue,r===null?(r={lastEffect:null,stores:null},dt.updateQueue=r,r.stores=[e]):(i=r.stores,i===null?r.stores=[e]:i.push(e))}function sd(e,r,i,c){r.value=i,r.getSnapshot=c,id(r)&&od(e)}function ad(e,r,i){return i(function(){id(r)&&od(e)})}function id(e){var r=e.getSnapshot;e=e.value;try{var i=r();return!ln(e,i)}catch{return!0}}function od(e){var r=Tn(e,1);r!==null&&hn(r,e,1,-1)}function ld(e){var r=wn();return typeof e=="function"&&(e=e()),r.memoizedState=r.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:$s,lastRenderedState:e},r.queue=e,e=e.dispatch=Ng.bind(null,dt,e),[r.memoizedState,e]}function _s(e,r,i,c){return e={tag:e,create:r,destroy:i,deps:c,next:null},r=dt.updateQueue,r===null?(r={lastEffect:null,stores:null},dt.updateQueue=r,r.lastEffect=e.next=e):(i=r.lastEffect,i===null?r.lastEffect=e.next=e:(c=i.next,i.next=e,e.next=c,r.lastEffect=e)),e}function cd(){return tn().memoizedState}function Va(e,r,i,c){var d=wn();dt.flags|=e,d.memoizedState=_s(1|r,i,void 0,c===void 0?null:c)}function Ga(e,r,i,c){var d=tn();c=c===void 0?null:c;var m=void 0;if(jt!==null){var w=jt.memoizedState;if(m=w.destroy,c!==null&&Ho(c,w.deps)){d.memoizedState=_s(r,i,m,c);return}}dt.flags|=e,d.memoizedState=_s(1|r,i,m,c)}function ud(e,r){return Va(8390656,8,e,r)}function Yo(e,r){return Ga(2048,8,e,r)}function dd(e,r){return Ga(4,2,e,r)}function fd(e,r){return Ga(4,4,e,r)}function hd(e,r){if(typeof r=="function")return e=e(),r(e),function(){r(null)};if(r!=null)return e=e(),r.current=e,function(){r.current=null}}function md(e,r,i){return i=i!=null?i.concat([e]):null,Ga(4,4,hd.bind(null,r,e),i)}function Jo(){}function pd(e,r){var i=tn();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&Ho(r,c[1])?c[0]:(i.memoizedState=[e,r],e)}function gd(e,r){var i=tn();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&Ho(r,c[1])?c[0]:(e=e(),i.memoizedState=[e,r],e)}function yd(e,r,i){return(hr&21)===0?(e.baseState&&(e.baseState=!1,Bt=!0),e.memoizedState=i):(ln(i,r)||(i=Kc(),dt.lanes|=i,mr|=i,e.baseState=!0),r)}function bg(e,r){var i=Qe;Qe=i!==0&&4>i?i:4,e(!0);var c=Wo.transition;Wo.transition={};try{e(!1),r()}finally{Qe=i,Wo.transition=c}}function vd(){return tn().memoizedState}function kg(e,r,i){var c=Jn(e);if(i={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null},xd(e))wd(r,i);else if(i=Ju(e,r,i,c),i!==null){var d=$t();hn(i,e,c,d),jd(i,r,c)}}function Ng(e,r,i){var c=Jn(e),d={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null};if(xd(e))wd(r,d);else{var m=e.alternate;if(e.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var w=r.lastRenderedState,C=m(w,i);if(d.hasEagerState=!0,d.eagerState=C,ln(C,w)){var R=r.interleaved;R===null?(d.next=d,Fo(r)):(d.next=R.next,R.next=d),r.interleaved=d;return}}catch{}finally{}i=Ju(e,r,d,c),i!==null&&(d=$t(),hn(i,e,c,d),jd(i,r,c))}}function xd(e){var r=e.alternate;return e===dt||r!==null&&r===dt}function wd(e,r){Rs=Ha=!0;var i=e.pending;i===null?r.next=r:(r.next=i.next,i.next=r),e.pending=r}function jd(e,r,i){if((i&4194240)!==0){var c=r.lanes;c&=e.pendingLanes,i|=c,r.lanes=i,Qi(e,i)}}var Ka={readContext:en,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useInsertionEffect:It,useLayoutEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useMutableSource:It,useSyncExternalStore:It,useId:It,unstable_isNewReconciler:!1},Cg={readContext:en,useCallback:function(e,r){return wn().memoizedState=[e,r===void 0?null:r],e},useContext:en,useEffect:ud,useImperativeHandle:function(e,r,i){return i=i!=null?i.concat([e]):null,Va(4194308,4,hd.bind(null,r,e),i)},useLayoutEffect:function(e,r){return Va(4194308,4,e,r)},useInsertionEffect:function(e,r){return Va(4,2,e,r)},useMemo:function(e,r){var i=wn();return r=r===void 0?null:r,e=e(),i.memoizedState=[e,r],e},useReducer:function(e,r,i){var c=wn();return r=i!==void 0?i(r):r,c.memoizedState=c.baseState=r,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},c.queue=e,e=e.dispatch=kg.bind(null,dt,e),[c.memoizedState,e]},useRef:function(e){var r=wn();return e={current:e},r.memoizedState=e},useState:ld,useDebugValue:Jo,useDeferredValue:function(e){return wn().memoizedState=e},useTransition:function(){var e=ld(!1),r=e[0];return e=bg.bind(null,e[1]),wn().memoizedState=e,[r,e]},useMutableSource:function(){},useSyncExternalStore:function(e,r,i){var c=dt,d=wn();if(ot){if(i===void 0)throw Error(a(407));i=i()}else{if(i=r(),kt===null)throw Error(a(349));(hr&30)!==0||rd(c,r,i)}d.memoizedState=i;var m={value:i,getSnapshot:r};return d.queue=m,ud(ad.bind(null,c,m,e),[e]),c.flags|=2048,_s(9,sd.bind(null,c,m,i,r),void 0,null),i},useId:function(){var e=wn(),r=kt.identifierPrefix;if(ot){var i=En,c=Cn;i=(c&~(1<<32-on(c)-1)).toString(32)+i,r=":"+r+"R"+i,i=Ps++,0<i&&(r+="H"+i.toString(32)),r+=":"}else i=Sg++,r=":"+r+"r"+i.toString(32)+":";return e.memoizedState=r},unstable_isNewReconciler:!1},Eg={readContext:en,useCallback:pd,useContext:en,useEffect:Yo,useImperativeHandle:md,useInsertionEffect:dd,useLayoutEffect:fd,useMemo:gd,useReducer:Ko,useRef:cd,useState:function(){return Ko($s)},useDebugValue:Jo,useDeferredValue:function(e){var r=tn();return yd(r,jt.memoizedState,e)},useTransition:function(){var e=Ko($s)[0],r=tn().memoizedState;return[e,r]},useMutableSource:td,useSyncExternalStore:nd,useId:vd,unstable_isNewReconciler:!1},Tg={readContext:en,useCallback:pd,useContext:en,useEffect:Yo,useImperativeHandle:md,useInsertionEffect:dd,useLayoutEffect:fd,useMemo:gd,useReducer:qo,useRef:cd,useState:function(){return qo($s)},useDebugValue:Jo,useDeferredValue:function(e){var r=tn();return jt===null?r.memoizedState=e:yd(r,jt.memoizedState,e)},useTransition:function(){var e=qo($s)[0],r=tn().memoizedState;return[e,r]},useMutableSource:td,useSyncExternalStore:nd,useId:vd,unstable_isNewReconciler:!1};function un(e,r){if(e&&e.defaultProps){r=G({},r),e=e.defaultProps;for(var i in e)r[i]===void 0&&(r[i]=e[i]);return r}return r}function Qo(e,r,i,c){r=e.memoizedState,i=i(c,r),i=i==null?r:G({},r,i),e.memoizedState=i,e.lanes===0&&(e.updateQueue.baseState=i)}var qa={isMounted:function(e){return(e=e._reactInternals)?ir(e)===e:!1},enqueueSetState:function(e,r,i){e=e._reactInternals;var c=$t(),d=Jn(e),m=In(c,d);m.payload=r,i!=null&&(m.callback=i),r=Gn(e,m,d),r!==null&&(hn(r,e,d,c),Ba(r,e,d))},enqueueReplaceState:function(e,r,i){e=e._reactInternals;var c=$t(),d=Jn(e),m=In(c,d);m.tag=1,m.payload=r,i!=null&&(m.callback=i),r=Gn(e,m,d),r!==null&&(hn(r,e,d,c),Ba(r,e,d))},enqueueForceUpdate:function(e,r){e=e._reactInternals;var i=$t(),c=Jn(e),d=In(i,c);d.tag=2,r!=null&&(d.callback=r),r=Gn(e,d,c),r!==null&&(hn(r,e,c,i),Ba(r,e,c))}};function Sd(e,r,i,c,d,m,w){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(c,m,w):r.prototype&&r.prototype.isPureReactComponent?!ws(i,c)||!ws(d,m):!0}function bd(e,r,i){var c=!1,d=Wn,m=r.contextType;return typeof m=="object"&&m!==null?m=en(m):(d=Ot(r)?lr:Tt.current,c=r.contextTypes,m=(c=c!=null)?zr(e,d):Wn),r=new r(i,m),e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=qa,e.stateNode=r,r._reactInternals=e,c&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=d,e.__reactInternalMemoizedMaskedChildContext=m),r}function kd(e,r,i,c){e=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(i,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(i,c),r.state!==e&&qa.enqueueReplaceState(r,r.state,null)}function Xo(e,r,i,c){var d=e.stateNode;d.props=i,d.state=e.memoizedState,d.refs={},Mo(e);var m=r.contextType;typeof m=="object"&&m!==null?d.context=en(m):(m=Ot(r)?lr:Tt.current,d.context=zr(e,m)),d.state=e.memoizedState,m=r.getDerivedStateFromProps,typeof m=="function"&&(Qo(e,r,m,i),d.state=e.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&&qa.enqueueReplaceState(d,d.state,null),Da(e,i,d,c),d.state=e.memoizedState),typeof d.componentDidMount=="function"&&(e.flags|=4194308)}function Hr(e,r){try{var i="",c=r;do i+=L(c),c=c.return;while(c);var d=i}catch(m){d=`
|
|
39
|
-
Error generating stack: `+m.message+`
|
|
40
|
-
`+m.stack}return{value:e,source:r,stack:d,digest:null}}function Zo(e,r,i){return{value:e,source:null,stack:i??null,digest:r??null}}function el(e,r){try{console.error(r.value)}catch(i){setTimeout(function(){throw i})}}var Ig=typeof WeakMap=="function"?WeakMap:Map;function Nd(e,r,i){i=In(-1,i),i.tag=3,i.payload={element:null};var c=r.value;return i.callback=function(){ti||(ti=!0,pl=c),el(e,r)},i}function Cd(e,r,i){i=In(-1,i),i.tag=3;var c=e.type.getDerivedStateFromError;if(typeof c=="function"){var d=r.value;i.payload=function(){return c(d)},i.callback=function(){el(e,r)}}var m=e.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(i.callback=function(){el(e,r),typeof c!="function"&&(qn===null?qn=new Set([this]):qn.add(this));var w=r.stack;this.componentDidCatch(r.value,{componentStack:w!==null?w:""})}),i}function Ed(e,r,i){var c=e.pingCache;if(c===null){c=e.pingCache=new Ig;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),e=Wg.bind(null,e,r,i),r.then(e,e))}function Td(e){do{var r;if((r=e.tag===13)&&(r=e.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return e;e=e.return}while(e!==null);return null}function Id(e,r,i,c,d){return(e.mode&1)===0?(e===r?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(r=In(-1,1),r.tag=2,Gn(i,r,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=d,e)}var Ag=I.ReactCurrentOwner,Bt=!1;function Pt(e,r,i,c){r.child=e===null?Yu(r,null,i,c):Br(r,e.child,i,c)}function Ad(e,r,i,c,d){i=i.render;var m=r.ref;return Ur(r,d),c=Vo(e,r,i,c,m,d),i=Go(),e!==null&&!Bt?(r.updateQueue=e.updateQueue,r.flags&=-2053,e.lanes&=~d,An(e,r,d)):(ot&&i&&To(r),r.flags|=1,Pt(e,r,c,d),r.child)}function Rd(e,r,i,c,d){if(e===null){var m=i.type;return typeof m=="function"&&!Sl(m)&&m.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(r.tag=15,r.type=m,Pd(e,r,m,c,d)):(e=oi(i.type,null,c,r,r.mode,d),e.ref=r.ref,e.return=r,r.child=e)}if(m=e.child,(e.lanes&d)===0){var w=m.memoizedProps;if(i=i.compare,i=i!==null?i:ws,i(w,c)&&e.ref===r.ref)return An(e,r,d)}return r.flags|=1,e=Xn(m,c),e.ref=r.ref,e.return=r,r.child=e}function Pd(e,r,i,c,d){if(e!==null){var m=e.memoizedProps;if(ws(m,c)&&e.ref===r.ref)if(Bt=!1,r.pendingProps=c=m,(e.lanes&d)!==0)(e.flags&131072)!==0&&(Bt=!0);else return r.lanes=e.lanes,An(e,r,d)}return tl(e,r,i,c,d)}function $d(e,r,i){var c=r.pendingProps,d=c.children,m=e!==null?e.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},nt(Gr,Jt),Jt|=i;else{if((i&1073741824)===0)return e=m!==null?m.baseLanes|i:i,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:e,cachePool:null,transitions:null},r.updateQueue=null,nt(Gr,Jt),Jt|=e,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=m!==null?m.baseLanes:i,nt(Gr,Jt),Jt|=c}else m!==null?(c=m.baseLanes|i,r.memoizedState=null):c=i,nt(Gr,Jt),Jt|=c;return Pt(e,r,d,i),r.child}function _d(e,r){var i=r.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(r.flags|=512,r.flags|=2097152)}function tl(e,r,i,c,d){var m=Ot(i)?lr:Tt.current;return m=zr(r,m),Ur(r,d),i=Vo(e,r,i,c,m,d),c=Go(),e!==null&&!Bt?(r.updateQueue=e.updateQueue,r.flags&=-2053,e.lanes&=~d,An(e,r,d)):(ot&&c&&To(r),r.flags|=1,Pt(e,r,i,d),r.child)}function Ld(e,r,i,c,d){if(Ot(i)){var m=!0;Pa(r)}else m=!1;if(Ur(r,d),r.stateNode===null)Ja(e,r),bd(r,i,c),Xo(r,i,c,d),c=!0;else if(e===null){var w=r.stateNode,C=r.memoizedProps;w.props=C;var R=w.context,W=i.contextType;typeof W=="object"&&W!==null?W=en(W):(W=Ot(i)?lr:Tt.current,W=zr(r,W));var ae=i.getDerivedStateFromProps,ce=typeof ae=="function"||typeof w.getSnapshotBeforeUpdate=="function";ce||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(C!==c||R!==W)&&kd(r,w,c,W),Vn=!1;var ne=r.memoizedState;w.state=ne,Da(r,c,w,d),R=r.memoizedState,C!==c||ne!==R||Mt.current||Vn?(typeof ae=="function"&&(Qo(r,i,ae,c),R=r.memoizedState),(C=Vn||Sd(r,i,C,c,ne,R,W))?(ce||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount()),typeof w.componentDidMount=="function"&&(r.flags|=4194308)):(typeof w.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=R),w.props=c,w.state=R,w.context=W,c=C):(typeof w.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{w=r.stateNode,Qu(e,r),C=r.memoizedProps,W=r.type===r.elementType?C:un(r.type,C),w.props=W,ce=r.pendingProps,ne=w.context,R=i.contextType,typeof R=="object"&&R!==null?R=en(R):(R=Ot(i)?lr:Tt.current,R=zr(r,R));var Se=i.getDerivedStateFromProps;(ae=typeof Se=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(C!==ce||ne!==R)&&kd(r,w,c,R),Vn=!1,ne=r.memoizedState,w.state=ne,Da(r,c,w,d);var Ce=r.memoizedState;C!==ce||ne!==Ce||Mt.current||Vn?(typeof Se=="function"&&(Qo(r,i,Se,c),Ce=r.memoizedState),(W=Vn||Sd(r,i,W,c,ne,Ce,R)||!1)?(ae||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(c,Ce,R),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(c,Ce,R)),typeof w.componentDidUpdate=="function"&&(r.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof w.componentDidUpdate!="function"||C===e.memoizedProps&&ne===e.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||C===e.memoizedProps&&ne===e.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=Ce),w.props=c,w.state=Ce,w.context=R,c=W):(typeof w.componentDidUpdate!="function"||C===e.memoizedProps&&ne===e.memoizedState||(r.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||C===e.memoizedProps&&ne===e.memoizedState||(r.flags|=1024),c=!1)}return nl(e,r,i,c,m,d)}function nl(e,r,i,c,d,m){_d(e,r);var w=(r.flags&128)!==0;if(!c&&!w)return d&&Bu(r,i,!1),An(e,r,m);c=r.stateNode,Ag.current=r;var C=w&&typeof i.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,e!==null&&w?(r.child=Br(r,e.child,null,m),r.child=Br(r,null,C,m)):Pt(e,r,C,m),r.memoizedState=c.state,d&&Bu(r,i,!0),r.child}function zd(e){var r=e.stateNode;r.pendingContext?Mu(e,r.pendingContext,r.pendingContext!==r.context):r.context&&Mu(e,r.context,!1),Oo(e,r.containerInfo)}function Fd(e,r,i,c,d){return Or(),Po(d),r.flags|=256,Pt(e,r,i,c),r.child}var rl={dehydrated:null,treeContext:null,retryLane:0};function sl(e){return{baseLanes:e,cachePool:null,transitions:null}}function Md(e,r,i){var c=r.pendingProps,d=ut.current,m=!1,w=(r.flags&128)!==0,C;if((C=w)||(C=e!==null&&e.memoizedState===null?!1:(d&2)!==0),C?(m=!0,r.flags&=-129):(e===null||e.memoizedState!==null)&&(d|=1),nt(ut,d&1),e===null)return Ro(r),e=r.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((r.mode&1)===0?r.lanes=1:e.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(w=c.children,e=c.fallback,m?(c=r.mode,m=r.child,w={mode:"hidden",children:w},(c&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=w):m=li(w,c,0,null),e=vr(e,c,i,null),m.return=r,e.return=r,m.sibling=e,r.child=m,r.child.memoizedState=sl(i),r.memoizedState=rl,e):al(r,w));if(d=e.memoizedState,d!==null&&(C=d.dehydrated,C!==null))return Rg(e,r,w,c,C,d,i);if(m){m=c.fallback,w=r.mode,d=e.child,C=d.sibling;var R={mode:"hidden",children:c.children};return(w&1)===0&&r.child!==d?(c=r.child,c.childLanes=0,c.pendingProps=R,r.deletions=null):(c=Xn(d,R),c.subtreeFlags=d.subtreeFlags&14680064),C!==null?m=Xn(C,m):(m=vr(m,w,i,null),m.flags|=2),m.return=r,c.return=r,c.sibling=m,r.child=c,c=m,m=r.child,w=e.child.memoizedState,w=w===null?sl(i):{baseLanes:w.baseLanes|i,cachePool:null,transitions:w.transitions},m.memoizedState=w,m.childLanes=e.childLanes&~i,r.memoizedState=rl,c}return m=e.child,e=m.sibling,c=Xn(m,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=i),c.return=r,c.sibling=null,e!==null&&(i=r.deletions,i===null?(r.deletions=[e],r.flags|=16):i.push(e)),r.child=c,r.memoizedState=null,c}function al(e,r){return r=li({mode:"visible",children:r},e.mode,0,null),r.return=e,e.child=r}function Ya(e,r,i,c){return c!==null&&Po(c),Br(r,e.child,null,i),e=al(r,r.pendingProps.children),e.flags|=2,r.memoizedState=null,e}function Rg(e,r,i,c,d,m,w){if(i)return r.flags&256?(r.flags&=-257,c=Zo(Error(a(422))),Ya(e,r,w,c)):r.memoizedState!==null?(r.child=e.child,r.flags|=128,null):(m=c.fallback,d=r.mode,c=li({mode:"visible",children:c.children},d,0,null),m=vr(m,d,w,null),m.flags|=2,c.return=r,m.return=r,c.sibling=m,r.child=c,(r.mode&1)!==0&&Br(r,e.child,null,w),r.child.memoizedState=sl(w),r.memoizedState=rl,m);if((r.mode&1)===0)return Ya(e,r,w,null);if(d.data==="$!"){if(c=d.nextSibling&&d.nextSibling.dataset,c)var C=c.dgst;return c=C,m=Error(a(419)),c=Zo(m,c,void 0),Ya(e,r,w,c)}if(C=(w&e.childLanes)!==0,Bt||C){if(c=kt,c!==null){switch(w&-w){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|w))!==0?0:d,d!==0&&d!==m.retryLane&&(m.retryLane=d,Tn(e,d),hn(c,e,d,-1))}return jl(),c=Zo(Error(a(421))),Ya(e,r,w,c)}return d.data==="$?"?(r.flags|=128,r.child=e.child,r=Hg.bind(null,e),d._reactRetry=r,null):(e=m.treeContext,Yt=Dn(d.nextSibling),qt=r,ot=!0,cn=null,e!==null&&(Xt[Zt++]=Cn,Xt[Zt++]=En,Xt[Zt++]=cr,Cn=e.id,En=e.overflow,cr=r),r=al(r,c.children),r.flags|=4096,r)}function Od(e,r,i){e.lanes|=r;var c=e.alternate;c!==null&&(c.lanes|=r),zo(e.return,r,i)}function il(e,r,i,c,d){var m=e.memoizedState;m===null?e.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 Bd(e,r,i){var c=r.pendingProps,d=c.revealOrder,m=c.tail;if(Pt(e,r,c.children,i),c=ut.current,(c&2)!==0)c=c&1|2,r.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=r.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Od(e,i,r);else if(e.tag===19)Od(e,i,r);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===r)break e;for(;e.sibling===null;){if(e.return===null||e.return===r)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}c&=1}if(nt(ut,c),(r.mode&1)===0)r.memoizedState=null;else switch(d){case"forwards":for(i=r.child,d=null;i!==null;)e=i.alternate,e!==null&&Ua(e)===null&&(d=i),i=i.sibling;i=d,i===null?(d=r.child,r.child=null):(d=i.sibling,i.sibling=null),il(r,!1,d,i,m);break;case"backwards":for(i=null,d=r.child,r.child=null;d!==null;){if(e=d.alternate,e!==null&&Ua(e)===null){r.child=d;break}e=d.sibling,d.sibling=i,i=d,d=e}il(r,!0,i,null,m);break;case"together":il(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Ja(e,r){(r.mode&1)===0&&e!==null&&(e.alternate=null,r.alternate=null,r.flags|=2)}function An(e,r,i){if(e!==null&&(r.dependencies=e.dependencies),mr|=r.lanes,(i&r.childLanes)===0)return null;if(e!==null&&r.child!==e.child)throw Error(a(153));if(r.child!==null){for(e=r.child,i=Xn(e,e.pendingProps),r.child=i,i.return=r;e.sibling!==null;)e=e.sibling,i=i.sibling=Xn(e,e.pendingProps),i.return=r;i.sibling=null}return r.child}function Pg(e,r,i){switch(r.tag){case 3:zd(r),Or();break;case 5:ed(r);break;case 1:Ot(r.type)&&Pa(r);break;case 4:Oo(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,d=r.memoizedProps.value;nt(Ma,c._currentValue),c._currentValue=d;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(nt(ut,ut.current&1),r.flags|=128,null):(i&r.child.childLanes)!==0?Md(e,r,i):(nt(ut,ut.current&1),e=An(e,r,i),e!==null?e.sibling:null);nt(ut,ut.current&1);break;case 19:if(c=(i&r.childLanes)!==0,(e.flags&128)!==0){if(c)return Bd(e,r,i);r.flags|=128}if(d=r.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),nt(ut,ut.current),c)break;return null;case 22:case 23:return r.lanes=0,$d(e,r,i)}return An(e,r,i)}var Dd,ol,Ud,Wd;Dd=function(e,r){for(var i=r.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===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}},ol=function(){},Ud=function(e,r,i,c){var d=e.memoizedProps;if(d!==c){e=r.stateNode,fr(xn.current);var m=null;switch(i){case"input":d=$e(e,d),c=$e(e,c),m=[];break;case"select":d=G({},d,{value:void 0}),c=G({},c,{value:void 0}),m=[];break;case"textarea":d=wt(e,d),c=wt(e,c),m=[];break;default:typeof d.onClick!="function"&&typeof c.onClick=="function"&&(e.onclick=Ia)}B(i,c);var w;i=null;for(W in d)if(!c.hasOwnProperty(W)&&d.hasOwnProperty(W)&&d[W]!=null)if(W==="style"){var C=d[W];for(w in C)C.hasOwnProperty(w)&&(i||(i={}),i[w]="")}else W!=="dangerouslySetInnerHTML"&&W!=="children"&&W!=="suppressContentEditableWarning"&&W!=="suppressHydrationWarning"&&W!=="autoFocus"&&(l.hasOwnProperty(W)?m||(m=[]):(m=m||[]).push(W,null));for(W in c){var R=c[W];if(C=d!=null?d[W]:void 0,c.hasOwnProperty(W)&&R!==C&&(R!=null||C!=null))if(W==="style")if(C){for(w in C)!C.hasOwnProperty(w)||R&&R.hasOwnProperty(w)||(i||(i={}),i[w]="");for(w in R)R.hasOwnProperty(w)&&C[w]!==R[w]&&(i||(i={}),i[w]=R[w])}else i||(m||(m=[]),m.push(W,i)),i=R;else W==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,C=C?C.__html:void 0,R!=null&&C!==R&&(m=m||[]).push(W,R)):W==="children"?typeof R!="string"&&typeof R!="number"||(m=m||[]).push(W,""+R):W!=="suppressContentEditableWarning"&&W!=="suppressHydrationWarning"&&(l.hasOwnProperty(W)?(R!=null&&W==="onScroll"&&at("scroll",e),m||C===R||(m=[])):(m=m||[]).push(W,R))}i&&(m=m||[]).push("style",i);var W=m;(r.updateQueue=W)&&(r.flags|=4)}},Wd=function(e,r,i,c){i!==c&&(r.flags|=4)};function Ls(e,r){if(!ot)switch(e.tailMode){case"hidden":r=e.tail;for(var i=null;r!==null;)r.alternate!==null&&(i=r),r=r.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?r||e.tail===null?e.tail=null:e.tail.sibling=null:c.sibling=null}}function At(e){var r=e.alternate!==null&&e.alternate.child===e.child,i=0,c=0;if(r)for(var d=e.child;d!==null;)i|=d.lanes|d.childLanes,c|=d.subtreeFlags&14680064,c|=d.flags&14680064,d.return=e,d=d.sibling;else for(d=e.child;d!==null;)i|=d.lanes|d.childLanes,c|=d.subtreeFlags,c|=d.flags,d.return=e,d=d.sibling;return e.subtreeFlags|=c,e.childLanes=i,r}function $g(e,r,i){var c=r.pendingProps;switch(Io(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return At(r),null;case 1:return Ot(r.type)&&Ra(),At(r),null;case 3:return c=r.stateNode,Wr(),it(Mt),it(Tt),Uo(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(e===null||e.child===null)&&(za(r)?r.flags|=4:e===null||e.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,cn!==null&&(vl(cn),cn=null))),ol(e,r),At(r),null;case 5:Bo(r);var d=fr(As.current);if(i=r.type,e!==null&&r.stateNode!=null)Ud(e,r,i,c,d),e.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!c){if(r.stateNode===null)throw Error(a(166));return At(r),null}if(e=fr(xn.current),za(r)){c=r.stateNode,i=r.type;var m=r.memoizedProps;switch(c[vn]=r,c[Ns]=m,e=(r.mode&1)!==0,i){case"dialog":at("cancel",c),at("close",c);break;case"iframe":case"object":case"embed":at("load",c);break;case"video":case"audio":for(d=0;d<Ss.length;d++)at(Ss[d],c);break;case"source":at("error",c);break;case"img":case"image":case"link":at("error",c),at("load",c);break;case"details":at("toggle",c);break;case"input":qe(c,m),at("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!m.multiple},at("invalid",c);break;case"textarea":mt(c,m),at("invalid",c)}B(i,m),d=null;for(var w in m)if(m.hasOwnProperty(w)){var C=m[w];w==="children"?typeof C=="string"?c.textContent!==C&&(m.suppressHydrationWarning!==!0&&Ta(c.textContent,C,e),d=["children",C]):typeof C=="number"&&c.textContent!==""+C&&(m.suppressHydrationWarning!==!0&&Ta(c.textContent,C,e),d=["children",""+C]):l.hasOwnProperty(w)&&C!=null&&w==="onScroll"&&at("scroll",c)}switch(i){case"input":be(c),xt(c,m,!0);break;case"textarea":be(c),he(c);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(c.onclick=Ia)}c=d,r.updateQueue=c,c!==null&&(r.flags|=4)}else{w=d.nodeType===9?d:d.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Pe(i)),e==="http://www.w3.org/1999/xhtml"?i==="script"?(e=w.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof c.is=="string"?e=w.createElement(i,{is:c.is}):(e=w.createElement(i),i==="select"&&(w=e,c.multiple?w.multiple=!0:c.size&&(w.size=c.size))):e=w.createElementNS(e,i),e[vn]=r,e[Ns]=c,Dd(e,r,!1,!1),r.stateNode=e;e:{switch(w=ve(i,c),i){case"dialog":at("cancel",e),at("close",e),d=c;break;case"iframe":case"object":case"embed":at("load",e),d=c;break;case"video":case"audio":for(d=0;d<Ss.length;d++)at(Ss[d],e);d=c;break;case"source":at("error",e),d=c;break;case"img":case"image":case"link":at("error",e),at("load",e),d=c;break;case"details":at("toggle",e),d=c;break;case"input":qe(e,c),d=$e(e,c),at("invalid",e);break;case"option":d=c;break;case"select":e._wrapperState={wasMultiple:!!c.multiple},d=G({},c,{value:void 0}),at("invalid",e);break;case"textarea":mt(e,c),d=wt(e,c),at("invalid",e);break;default:d=c}B(i,d),C=d;for(m in C)if(C.hasOwnProperty(m)){var R=C[m];m==="style"?zt(e,R):m==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&K(e,R)):m==="children"?typeof R=="string"?(i!=="textarea"||R!=="")&&ye(e,R):typeof R=="number"&&ye(e,""+R):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(l.hasOwnProperty(m)?R!=null&&m==="onScroll"&&at("scroll",e):R!=null&&P(e,m,R,w))}switch(i){case"input":be(e),xt(e,c,!1);break;case"textarea":be(e),he(e);break;case"option":c.value!=null&&e.setAttribute("value",""+me(c.value));break;case"select":e.multiple=!!c.multiple,m=c.value,m!=null?Je(e,!!c.multiple,m,!1):c.defaultValue!=null&&Je(e,!!c.multiple,c.defaultValue,!0);break;default:typeof d.onClick=="function"&&(e.onclick=Ia)}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 At(r),null;case 6:if(e&&r.stateNode!=null)Wd(e,r,e.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(a(166));if(i=fr(As.current),fr(xn.current),za(r)){if(c=r.stateNode,i=r.memoizedProps,c[vn]=r,(m=c.nodeValue!==i)&&(e=qt,e!==null))switch(e.tag){case 3:Ta(c.nodeValue,i,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ta(c.nodeValue,i,(e.mode&1)!==0)}m&&(r.flags|=4)}else c=(i.nodeType===9?i:i.ownerDocument).createTextNode(c),c[vn]=r,r.stateNode=c}return At(r),null;case 13:if(it(ut),c=r.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ot&&Yt!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Gu(),Or(),r.flags|=98560,m=!1;else if(m=za(r),c!==null&&c.dehydrated!==null){if(e===null){if(!m)throw Error(a(318));if(m=r.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(a(317));m[vn]=r}else Or(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;At(r),m=!1}else cn!==null&&(vl(cn),cn=null),m=!0;if(!m)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=i,r):(c=c!==null,c!==(e!==null&&e.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(e===null||(ut.current&1)!==0?St===0&&(St=3):jl())),r.updateQueue!==null&&(r.flags|=4),At(r),null);case 4:return Wr(),ol(e,r),e===null&&bs(r.stateNode.containerInfo),At(r),null;case 10:return Lo(r.type._context),At(r),null;case 17:return Ot(r.type)&&Ra(),At(r),null;case 19:if(it(ut),m=r.memoizedState,m===null)return At(r),null;if(c=(r.flags&128)!==0,w=m.rendering,w===null)if(c)Ls(m,!1);else{if(St!==0||e!==null&&(e.flags&128)!==0)for(e=r.child;e!==null;){if(w=Ua(e),w!==null){for(r.flags|=128,Ls(m,!1),c=w.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),r.subtreeFlags=0,c=i,i=r.child;i!==null;)m=i,e=c,m.flags&=14680066,w=m.alternate,w===null?(m.childLanes=0,m.lanes=e,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=w.childLanes,m.lanes=w.lanes,m.child=w.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=w.memoizedProps,m.memoizedState=w.memoizedState,m.updateQueue=w.updateQueue,m.type=w.type,e=w.dependencies,m.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),i=i.sibling;return nt(ut,ut.current&1|2),r.child}e=e.sibling}m.tail!==null&&pt()>Kr&&(r.flags|=128,c=!0,Ls(m,!1),r.lanes=4194304)}else{if(!c)if(e=Ua(w),e!==null){if(r.flags|=128,c=!0,i=e.updateQueue,i!==null&&(r.updateQueue=i,r.flags|=4),Ls(m,!0),m.tail===null&&m.tailMode==="hidden"&&!w.alternate&&!ot)return At(r),null}else 2*pt()-m.renderingStartTime>Kr&&i!==1073741824&&(r.flags|=128,c=!0,Ls(m,!1),r.lanes=4194304);m.isBackwards?(w.sibling=r.child,r.child=w):(i=m.last,i!==null?i.sibling=w:r.child=w,m.last=w)}return m.tail!==null?(r=m.tail,m.rendering=r,m.tail=r.sibling,m.renderingStartTime=pt(),r.sibling=null,i=ut.current,nt(ut,c?i&1|2:i&1),r):(At(r),null);case 22:case 23:return wl(),c=r.memoizedState!==null,e!==null&&e.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(Jt&1073741824)!==0&&(At(r),r.subtreeFlags&6&&(r.flags|=8192)):At(r),null;case 24:return null;case 25:return null}throw Error(a(156,r.tag))}function _g(e,r){switch(Io(r),r.tag){case 1:return Ot(r.type)&&Ra(),e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 3:return Wr(),it(Mt),it(Tt),Uo(),e=r.flags,(e&65536)!==0&&(e&128)===0?(r.flags=e&-65537|128,r):null;case 5:return Bo(r),null;case 13:if(it(ut),e=r.memoizedState,e!==null&&e.dehydrated!==null){if(r.alternate===null)throw Error(a(340));Or()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 19:return it(ut),null;case 4:return Wr(),null;case 10:return Lo(r.type._context),null;case 22:case 23:return wl(),null;case 24:return null;default:return null}}var Qa=!1,Rt=!1,Lg=typeof WeakSet=="function"?WeakSet:Set,ke=null;function Vr(e,r){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(c){ft(e,r,c)}else i.current=null}function ll(e,r,i){try{i()}catch(c){ft(e,r,c)}}var Hd=!1;function zg(e,r){if(wo=ya,e=Su(),fo(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.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 w=0,C=-1,R=-1,W=0,ae=0,ce=e,ne=null;t:for(;;){for(var Se;ce!==i||d!==0&&ce.nodeType!==3||(C=w+d),ce!==m||c!==0&&ce.nodeType!==3||(R=w+c),ce.nodeType===3&&(w+=ce.nodeValue.length),(Se=ce.firstChild)!==null;)ne=ce,ce=Se;for(;;){if(ce===e)break t;if(ne===i&&++W===d&&(C=w),ne===m&&++ae===c&&(R=w),(Se=ce.nextSibling)!==null)break;ce=ne,ne=ce.parentNode}ce=Se}i=C===-1||R===-1?null:{start:C,end:R}}else i=null}i=i||{start:0,end:0}}else i=null;for(jo={focusedElem:e,selectionRange:i},ya=!1,ke=r;ke!==null;)if(r=ke,e=r.child,(r.subtreeFlags&1028)!==0&&e!==null)e.return=r,ke=e;else for(;ke!==null;){r=ke;try{var Ce=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Ce!==null){var Ee=Ce.memoizedProps,gt=Ce.memoizedState,O=r.stateNode,$=O.getSnapshotBeforeUpdate(r.elementType===r.type?Ee:un(r.type,Ee),gt);O.__reactInternalSnapshotBeforeUpdate=$}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(de){ft(r,r.return,de)}if(e=r.sibling,e!==null){e.return=r.return,ke=e;break}ke=r.return}return Ce=Hd,Hd=!1,Ce}function zs(e,r,i){var c=r.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var d=c=c.next;do{if((d.tag&e)===e){var m=d.destroy;d.destroy=void 0,m!==void 0&&ll(r,i,m)}d=d.next}while(d!==c)}}function Xa(e,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var c=i.create;i.destroy=c()}i=i.next}while(i!==r)}}function cl(e){var r=e.ref;if(r!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof r=="function"?r(e):r.current=e}}function Vd(e){var r=e.alternate;r!==null&&(e.alternate=null,Vd(r)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(r=e.stateNode,r!==null&&(delete r[vn],delete r[Ns],delete r[No],delete r[vg],delete r[xg])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Gd(e){return e.tag===5||e.tag===3||e.tag===4}function Kd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Gd(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ul(e,r,i){var c=e.tag;if(c===5||c===6)e=e.stateNode,r?i.nodeType===8?i.parentNode.insertBefore(e,r):i.insertBefore(e,r):(i.nodeType===8?(r=i.parentNode,r.insertBefore(e,i)):(r=i,r.appendChild(e)),i=i._reactRootContainer,i!=null||r.onclick!==null||(r.onclick=Ia));else if(c!==4&&(e=e.child,e!==null))for(ul(e,r,i),e=e.sibling;e!==null;)ul(e,r,i),e=e.sibling}function dl(e,r,i){var c=e.tag;if(c===5||c===6)e=e.stateNode,r?i.insertBefore(e,r):i.appendChild(e);else if(c!==4&&(e=e.child,e!==null))for(dl(e,r,i),e=e.sibling;e!==null;)dl(e,r,i),e=e.sibling}var Ct=null,dn=!1;function Kn(e,r,i){for(i=i.child;i!==null;)qd(e,r,i),i=i.sibling}function qd(e,r,i){if(yn&&typeof yn.onCommitFiberUnmount=="function")try{yn.onCommitFiberUnmount(da,i)}catch{}switch(i.tag){case 5:Rt||Vr(i,r);case 6:var c=Ct,d=dn;Ct=null,Kn(e,r,i),Ct=c,dn=d,Ct!==null&&(dn?(e=Ct,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):Ct.removeChild(i.stateNode));break;case 18:Ct!==null&&(dn?(e=Ct,i=i.stateNode,e.nodeType===8?ko(e.parentNode,i):e.nodeType===1&&ko(e,i),ms(e)):ko(Ct,i.stateNode));break;case 4:c=Ct,d=dn,Ct=i.stateNode.containerInfo,dn=!0,Kn(e,r,i),Ct=c,dn=d;break;case 0:case 11:case 14:case 15:if(!Rt&&(c=i.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){d=c=c.next;do{var m=d,w=m.destroy;m=m.tag,w!==void 0&&((m&2)!==0||(m&4)!==0)&&ll(i,r,w),d=d.next}while(d!==c)}Kn(e,r,i);break;case 1:if(!Rt&&(Vr(i,r),c=i.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=i.memoizedProps,c.state=i.memoizedState,c.componentWillUnmount()}catch(C){ft(i,r,C)}Kn(e,r,i);break;case 21:Kn(e,r,i);break;case 22:i.mode&1?(Rt=(c=Rt)||i.memoizedState!==null,Kn(e,r,i),Rt=c):Kn(e,r,i);break;default:Kn(e,r,i)}}function Yd(e){var r=e.updateQueue;if(r!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Lg),r.forEach(function(c){var d=Vg.bind(null,e,c);i.has(c)||(i.add(c),c.then(d,d))})}}function fn(e,r){var i=r.deletions;if(i!==null)for(var c=0;c<i.length;c++){var d=i[c];try{var m=e,w=r,C=w;e:for(;C!==null;){switch(C.tag){case 5:Ct=C.stateNode,dn=!1;break e;case 3:Ct=C.stateNode.containerInfo,dn=!0;break e;case 4:Ct=C.stateNode.containerInfo,dn=!0;break e}C=C.return}if(Ct===null)throw Error(a(160));qd(m,w,d),Ct=null,dn=!1;var R=d.alternate;R!==null&&(R.return=null),d.return=null}catch(W){ft(d,r,W)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Jd(r,e),r=r.sibling}function Jd(e,r){var i=e.alternate,c=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(fn(r,e),jn(e),c&4){try{zs(3,e,e.return),Xa(3,e)}catch(Ee){ft(e,e.return,Ee)}try{zs(5,e,e.return)}catch(Ee){ft(e,e.return,Ee)}}break;case 1:fn(r,e),jn(e),c&512&&i!==null&&Vr(i,i.return);break;case 5:if(fn(r,e),jn(e),c&512&&i!==null&&Vr(i,i.return),e.flags&32){var d=e.stateNode;try{ye(d,"")}catch(Ee){ft(e,e.return,Ee)}}if(c&4&&(d=e.stateNode,d!=null)){var m=e.memoizedProps,w=i!==null?i.memoizedProps:m,C=e.type,R=e.updateQueue;if(e.updateQueue=null,R!==null)try{C==="input"&&m.type==="radio"&&m.name!=null&&Ge(d,m),ve(C,w);var W=ve(C,m);for(w=0;w<R.length;w+=2){var ae=R[w],ce=R[w+1];ae==="style"?zt(d,ce):ae==="dangerouslySetInnerHTML"?K(d,ce):ae==="children"?ye(d,ce):P(d,ae,ce,W)}switch(C){case"input":Me(d,m);break;case"textarea":ze(d,m);break;case"select":var ne=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!m.multiple;var Se=m.value;Se!=null?Je(d,!!m.multiple,Se,!1):ne!==!!m.multiple&&(m.defaultValue!=null?Je(d,!!m.multiple,m.defaultValue,!0):Je(d,!!m.multiple,m.multiple?[]:"",!1))}d[Ns]=m}catch(Ee){ft(e,e.return,Ee)}}break;case 6:if(fn(r,e),jn(e),c&4){if(e.stateNode===null)throw Error(a(162));d=e.stateNode,m=e.memoizedProps;try{d.nodeValue=m}catch(Ee){ft(e,e.return,Ee)}}break;case 3:if(fn(r,e),jn(e),c&4&&i!==null&&i.memoizedState.isDehydrated)try{ms(r.containerInfo)}catch(Ee){ft(e,e.return,Ee)}break;case 4:fn(r,e),jn(e);break;case 13:fn(r,e),jn(e),d=e.child,d.flags&8192&&(m=d.memoizedState!==null,d.stateNode.isHidden=m,!m||d.alternate!==null&&d.alternate.memoizedState!==null||(ml=pt())),c&4&&Yd(e);break;case 22:if(ae=i!==null&&i.memoizedState!==null,e.mode&1?(Rt=(W=Rt)||ae,fn(r,e),Rt=W):fn(r,e),jn(e),c&8192){if(W=e.memoizedState!==null,(e.stateNode.isHidden=W)&&!ae&&(e.mode&1)!==0)for(ke=e,ae=e.child;ae!==null;){for(ce=ke=ae;ke!==null;){switch(ne=ke,Se=ne.child,ne.tag){case 0:case 11:case 14:case 15:zs(4,ne,ne.return);break;case 1:Vr(ne,ne.return);var Ce=ne.stateNode;if(typeof Ce.componentWillUnmount=="function"){c=ne,i=ne.return;try{r=c,Ce.props=r.memoizedProps,Ce.state=r.memoizedState,Ce.componentWillUnmount()}catch(Ee){ft(c,i,Ee)}}break;case 5:Vr(ne,ne.return);break;case 22:if(ne.memoizedState!==null){Zd(ce);continue}}Se!==null?(Se.return=ne,ke=Se):Zd(ce)}ae=ae.sibling}e:for(ae=null,ce=e;;){if(ce.tag===5){if(ae===null){ae=ce;try{d=ce.stateNode,W?(m=d.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none"):(C=ce.stateNode,R=ce.memoizedProps.style,w=R!=null&&R.hasOwnProperty("display")?R.display:null,C.style.display=st("display",w))}catch(Ee){ft(e,e.return,Ee)}}}else if(ce.tag===6){if(ae===null)try{ce.stateNode.nodeValue=W?"":ce.memoizedProps}catch(Ee){ft(e,e.return,Ee)}}else if((ce.tag!==22&&ce.tag!==23||ce.memoizedState===null||ce===e)&&ce.child!==null){ce.child.return=ce,ce=ce.child;continue}if(ce===e)break e;for(;ce.sibling===null;){if(ce.return===null||ce.return===e)break e;ae===ce&&(ae=null),ce=ce.return}ae===ce&&(ae=null),ce.sibling.return=ce.return,ce=ce.sibling}}break;case 19:fn(r,e),jn(e),c&4&&Yd(e);break;case 21:break;default:fn(r,e),jn(e)}}function jn(e){var r=e.flags;if(r&2){try{e:{for(var i=e.return;i!==null;){if(Gd(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=Kd(e);dl(e,m,d);break;case 3:case 4:var w=c.stateNode.containerInfo,C=Kd(e);ul(e,C,w);break;default:throw Error(a(161))}}catch(R){ft(e,e.return,R)}e.flags&=-3}r&4096&&(e.flags&=-4097)}function Fg(e,r,i){ke=e,Qd(e)}function Qd(e,r,i){for(var c=(e.mode&1)!==0;ke!==null;){var d=ke,m=d.child;if(d.tag===22&&c){var w=d.memoizedState!==null||Qa;if(!w){var C=d.alternate,R=C!==null&&C.memoizedState!==null||Rt;C=Qa;var W=Rt;if(Qa=w,(Rt=R)&&!W)for(ke=d;ke!==null;)w=ke,R=w.child,w.tag===22&&w.memoizedState!==null?ef(d):R!==null?(R.return=w,ke=R):ef(d);for(;m!==null;)ke=m,Qd(m),m=m.sibling;ke=d,Qa=C,Rt=W}Xd(e)}else(d.subtreeFlags&8772)!==0&&m!==null?(m.return=d,ke=m):Xd(e)}}function Xd(e){for(;ke!==null;){var r=ke;if((r.flags&8772)!==0){var i=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Rt||Xa(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!Rt)if(i===null)c.componentDidMount();else{var d=r.elementType===r.type?i.memoizedProps:un(r.type,i.memoizedProps);c.componentDidUpdate(d,i.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var m=r.updateQueue;m!==null&&Zu(r,m,c);break;case 3:var w=r.updateQueue;if(w!==null){if(i=null,r.child!==null)switch(r.child.tag){case 5:i=r.child.stateNode;break;case 1:i=r.child.stateNode}Zu(r,w,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 W=r.alternate;if(W!==null){var ae=W.memoizedState;if(ae!==null){var ce=ae.dehydrated;ce!==null&&ms(ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}Rt||r.flags&512&&cl(r)}catch(ne){ft(r,r.return,ne)}}if(r===e){ke=null;break}if(i=r.sibling,i!==null){i.return=r.return,ke=i;break}ke=r.return}}function Zd(e){for(;ke!==null;){var r=ke;if(r===e){ke=null;break}var i=r.sibling;if(i!==null){i.return=r.return,ke=i;break}ke=r.return}}function ef(e){for(;ke!==null;){var r=ke;try{switch(r.tag){case 0:case 11:case 15:var i=r.return;try{Xa(4,r)}catch(R){ft(r,i,R)}break;case 1:var c=r.stateNode;if(typeof c.componentDidMount=="function"){var d=r.return;try{c.componentDidMount()}catch(R){ft(r,d,R)}}var m=r.return;try{cl(r)}catch(R){ft(r,m,R)}break;case 5:var w=r.return;try{cl(r)}catch(R){ft(r,w,R)}}}catch(R){ft(r,r.return,R)}if(r===e){ke=null;break}var C=r.sibling;if(C!==null){C.return=r.return,ke=C;break}ke=r.return}}var Mg=Math.ceil,Za=I.ReactCurrentDispatcher,fl=I.ReactCurrentOwner,nn=I.ReactCurrentBatchConfig,Ke=0,kt=null,vt=null,Et=0,Jt=0,Gr=Un(0),St=0,Fs=null,mr=0,ei=0,hl=0,Ms=null,Dt=null,ml=0,Kr=1/0,Rn=null,ti=!1,pl=null,qn=null,ni=!1,Yn=null,ri=0,Os=0,gl=null,si=-1,ai=0;function $t(){return(Ke&6)!==0?pt():si!==-1?si:si=pt()}function Jn(e){return(e.mode&1)===0?1:(Ke&2)!==0&&Et!==0?Et&-Et:jg.transition!==null?(ai===0&&(ai=Kc()),ai):(e=Qe,e!==0||(e=window.event,e=e===void 0?16:nu(e.type)),e)}function hn(e,r,i,c){if(50<Os)throw Os=0,gl=null,Error(a(185));cs(e,i,c),((Ke&2)===0||e!==kt)&&(e===kt&&((Ke&2)===0&&(ei|=i),St===4&&Qn(e,Et)),Ut(e,c),i===1&&Ke===0&&(r.mode&1)===0&&(Kr=pt()+500,$a&&Hn()))}function Ut(e,r){var i=e.callbackNode;jp(e,r);var c=ma(e,e===kt?Et:0);if(c===0)i!==null&&Hc(i),e.callbackNode=null,e.callbackPriority=0;else if(r=c&-c,e.callbackPriority!==r){if(i!=null&&Hc(i),r===1)e.tag===0?wg(nf.bind(null,e)):Du(nf.bind(null,e)),gg(function(){(Ke&6)===0&&Hn()}),i=null;else{switch(qc(c)){case 1:i=qi;break;case 4:i=Vc;break;case 16:i=ua;break;case 536870912:i=Gc;break;default:i=ua}i=df(i,tf.bind(null,e))}e.callbackPriority=r,e.callbackNode=i}}function tf(e,r){if(si=-1,ai=0,(Ke&6)!==0)throw Error(a(327));var i=e.callbackNode;if(qr()&&e.callbackNode!==i)return null;var c=ma(e,e===kt?Et:0);if(c===0)return null;if((c&30)!==0||(c&e.expiredLanes)!==0||r)r=ii(e,c);else{r=c;var d=Ke;Ke|=2;var m=sf();(kt!==e||Et!==r)&&(Rn=null,Kr=pt()+500,gr(e,r));do try{Dg();break}catch(C){rf(e,C)}while(!0);_o(),Za.current=m,Ke=d,vt!==null?r=0:(kt=null,Et=0,r=St)}if(r!==0){if(r===2&&(d=Yi(e),d!==0&&(c=d,r=yl(e,d))),r===1)throw i=Fs,gr(e,0),Qn(e,c),Ut(e,pt()),i;if(r===6)Qn(e,c);else{if(d=e.current.alternate,(c&30)===0&&!Og(d)&&(r=ii(e,c),r===2&&(m=Yi(e),m!==0&&(c=m,r=yl(e,m))),r===1))throw i=Fs,gr(e,0),Qn(e,c),Ut(e,pt()),i;switch(e.finishedWork=d,e.finishedLanes=c,r){case 0:case 1:throw Error(a(345));case 2:yr(e,Dt,Rn);break;case 3:if(Qn(e,c),(c&130023424)===c&&(r=ml+500-pt(),10<r)){if(ma(e,0)!==0)break;if(d=e.suspendedLanes,(d&c)!==c){$t(),e.pingedLanes|=e.suspendedLanes&d;break}e.timeoutHandle=bo(yr.bind(null,e,Dt,Rn),r);break}yr(e,Dt,Rn);break;case 4:if(Qn(e,c),(c&4194240)===c)break;for(r=e.eventTimes,d=-1;0<c;){var w=31-on(c);m=1<<w,w=r[w],w>d&&(d=w),c&=~m}if(c=d,c=pt()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*Mg(c/1960))-c,10<c){e.timeoutHandle=bo(yr.bind(null,e,Dt,Rn),c);break}yr(e,Dt,Rn);break;case 5:yr(e,Dt,Rn);break;default:throw Error(a(329))}}}return Ut(e,pt()),e.callbackNode===i?tf.bind(null,e):null}function yl(e,r){var i=Ms;return e.current.memoizedState.isDehydrated&&(gr(e,r).flags|=256),e=ii(e,r),e!==2&&(r=Dt,Dt=i,r!==null&&vl(r)),e}function vl(e){Dt===null?Dt=e:Dt.push.apply(Dt,e)}function Og(e){for(var r=e;;){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(!ln(m(),d))return!1}catch{return!1}}}if(i=r.child,r.subtreeFlags&16384&&i!==null)i.return=r,r=i;else{if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Qn(e,r){for(r&=~hl,r&=~ei,e.suspendedLanes|=r,e.pingedLanes&=~r,e=e.expirationTimes;0<r;){var i=31-on(r),c=1<<i;e[i]=-1,r&=~c}}function nf(e){if((Ke&6)!==0)throw Error(a(327));qr();var r=ma(e,0);if((r&1)===0)return Ut(e,pt()),null;var i=ii(e,r);if(e.tag!==0&&i===2){var c=Yi(e);c!==0&&(r=c,i=yl(e,c))}if(i===1)throw i=Fs,gr(e,0),Qn(e,r),Ut(e,pt()),i;if(i===6)throw Error(a(345));return e.finishedWork=e.current.alternate,e.finishedLanes=r,yr(e,Dt,Rn),Ut(e,pt()),null}function xl(e,r){var i=Ke;Ke|=1;try{return e(r)}finally{Ke=i,Ke===0&&(Kr=pt()+500,$a&&Hn())}}function pr(e){Yn!==null&&Yn.tag===0&&(Ke&6)===0&&qr();var r=Ke;Ke|=1;var i=nn.transition,c=Qe;try{if(nn.transition=null,Qe=1,e)return e()}finally{Qe=c,nn.transition=i,Ke=r,(Ke&6)===0&&Hn()}}function wl(){Jt=Gr.current,it(Gr)}function gr(e,r){e.finishedWork=null,e.finishedLanes=0;var i=e.timeoutHandle;if(i!==-1&&(e.timeoutHandle=-1,pg(i)),vt!==null)for(i=vt.return;i!==null;){var c=i;switch(Io(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Ra();break;case 3:Wr(),it(Mt),it(Tt),Uo();break;case 5:Bo(c);break;case 4:Wr();break;case 13:it(ut);break;case 19:it(ut);break;case 10:Lo(c.type._context);break;case 22:case 23:wl()}i=i.return}if(kt=e,vt=e=Xn(e.current,null),Et=Jt=r,St=0,Fs=null,hl=ei=mr=0,Dt=Ms=null,dr!==null){for(r=0;r<dr.length;r++)if(i=dr[r],c=i.interleaved,c!==null){i.interleaved=null;var d=c.next,m=i.pending;if(m!==null){var w=m.next;m.next=d,c.next=w}i.pending=c}dr=null}return e}function rf(e,r){do{var i=vt;try{if(_o(),Wa.current=Ka,Ha){for(var c=dt.memoizedState;c!==null;){var d=c.queue;d!==null&&(d.pending=null),c=c.next}Ha=!1}if(hr=0,bt=jt=dt=null,Rs=!1,Ps=0,fl.current=null,i===null||i.return===null){St=1,Fs=r,vt=null;break}e:{var m=e,w=i.return,C=i,R=r;if(r=Et,C.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var W=R,ae=C,ce=ae.tag;if((ae.mode&1)===0&&(ce===0||ce===11||ce===15)){var ne=ae.alternate;ne?(ae.updateQueue=ne.updateQueue,ae.memoizedState=ne.memoizedState,ae.lanes=ne.lanes):(ae.updateQueue=null,ae.memoizedState=null)}var Se=Td(w);if(Se!==null){Se.flags&=-257,Id(Se,w,C,m,r),Se.mode&1&&Ed(m,W,r),r=Se,R=W;var Ce=r.updateQueue;if(Ce===null){var Ee=new Set;Ee.add(R),r.updateQueue=Ee}else Ce.add(R);break e}else{if((r&1)===0){Ed(m,W,r),jl();break e}R=Error(a(426))}}else if(ot&&C.mode&1){var gt=Td(w);if(gt!==null){(gt.flags&65536)===0&&(gt.flags|=256),Id(gt,w,C,m,r),Po(Hr(R,C));break e}}m=R=Hr(R,C),St!==4&&(St=2),Ms===null?Ms=[m]:Ms.push(m),m=w;do{switch(m.tag){case 3:m.flags|=65536,r&=-r,m.lanes|=r;var O=Nd(m,R,r);Xu(m,O);break e;case 1:C=R;var $=m.type,D=m.stateNode;if((m.flags&128)===0&&(typeof $.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(qn===null||!qn.has(D)))){m.flags|=65536,r&=-r,m.lanes|=r;var de=Cd(m,C,r);Xu(m,de);break e}}m=m.return}while(m!==null)}of(i)}catch(Te){r=Te,vt===i&&i!==null&&(vt=i=i.return);continue}break}while(!0)}function sf(){var e=Za.current;return Za.current=Ka,e===null?Ka:e}function jl(){(St===0||St===3||St===2)&&(St=4),kt===null||(mr&268435455)===0&&(ei&268435455)===0||Qn(kt,Et)}function ii(e,r){var i=Ke;Ke|=2;var c=sf();(kt!==e||Et!==r)&&(Rn=null,gr(e,r));do try{Bg();break}catch(d){rf(e,d)}while(!0);if(_o(),Ke=i,Za.current=c,vt!==null)throw Error(a(261));return kt=null,Et=0,St}function Bg(){for(;vt!==null;)af(vt)}function Dg(){for(;vt!==null&&!fp();)af(vt)}function af(e){var r=uf(e.alternate,e,Jt);e.memoizedProps=e.pendingProps,r===null?of(e):vt=r,fl.current=null}function of(e){var r=e;do{var i=r.alternate;if(e=r.return,(r.flags&32768)===0){if(i=$g(i,r,Jt),i!==null){vt=i;return}}else{if(i=_g(i,r),i!==null){i.flags&=32767,vt=i;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{St=6,vt=null;return}}if(r=r.sibling,r!==null){vt=r;return}vt=r=e}while(r!==null);St===0&&(St=5)}function yr(e,r,i){var c=Qe,d=nn.transition;try{nn.transition=null,Qe=1,Ug(e,r,i,c)}finally{nn.transition=d,Qe=c}return null}function Ug(e,r,i,c){do qr();while(Yn!==null);if((Ke&6)!==0)throw Error(a(327));i=e.finishedWork;var d=e.finishedLanes;if(i===null)return null;if(e.finishedWork=null,e.finishedLanes=0,i===e.current)throw Error(a(177));e.callbackNode=null,e.callbackPriority=0;var m=i.lanes|i.childLanes;if(Sp(e,m),e===kt&&(vt=kt=null,Et=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||ni||(ni=!0,df(ua,function(){return qr(),null})),m=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||m){m=nn.transition,nn.transition=null;var w=Qe;Qe=1;var C=Ke;Ke|=4,fl.current=null,zg(e,i),Jd(i,e),lg(jo),ya=!!wo,jo=wo=null,e.current=i,Fg(i),hp(),Ke=C,Qe=w,nn.transition=m}else e.current=i;if(ni&&(ni=!1,Yn=e,ri=d),m=e.pendingLanes,m===0&&(qn=null),gp(i.stateNode),Ut(e,pt()),r!==null)for(c=e.onRecoverableError,i=0;i<r.length;i++)d=r[i],c(d.value,{componentStack:d.stack,digest:d.digest});if(ti)throw ti=!1,e=pl,pl=null,e;return(ri&1)!==0&&e.tag!==0&&qr(),m=e.pendingLanes,(m&1)!==0?e===gl?Os++:(Os=0,gl=e):Os=0,Hn(),null}function qr(){if(Yn!==null){var e=qc(ri),r=nn.transition,i=Qe;try{if(nn.transition=null,Qe=16>e?16:e,Yn===null)var c=!1;else{if(e=Yn,Yn=null,ri=0,(Ke&6)!==0)throw Error(a(331));var d=Ke;for(Ke|=4,ke=e.current;ke!==null;){var m=ke,w=m.child;if((ke.flags&16)!==0){var C=m.deletions;if(C!==null){for(var R=0;R<C.length;R++){var W=C[R];for(ke=W;ke!==null;){var ae=ke;switch(ae.tag){case 0:case 11:case 15:zs(8,ae,m)}var ce=ae.child;if(ce!==null)ce.return=ae,ke=ce;else for(;ke!==null;){ae=ke;var ne=ae.sibling,Se=ae.return;if(Vd(ae),ae===W){ke=null;break}if(ne!==null){ne.return=Se,ke=ne;break}ke=Se}}}var Ce=m.alternate;if(Ce!==null){var Ee=Ce.child;if(Ee!==null){Ce.child=null;do{var gt=Ee.sibling;Ee.sibling=null,Ee=gt}while(Ee!==null)}}ke=m}}if((m.subtreeFlags&2064)!==0&&w!==null)w.return=m,ke=w;else e:for(;ke!==null;){if(m=ke,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:zs(9,m,m.return)}var O=m.sibling;if(O!==null){O.return=m.return,ke=O;break e}ke=m.return}}var $=e.current;for(ke=$;ke!==null;){w=ke;var D=w.child;if((w.subtreeFlags&2064)!==0&&D!==null)D.return=w,ke=D;else e:for(w=$;ke!==null;){if(C=ke,(C.flags&2048)!==0)try{switch(C.tag){case 0:case 11:case 15:Xa(9,C)}}catch(Te){ft(C,C.return,Te)}if(C===w){ke=null;break e}var de=C.sibling;if(de!==null){de.return=C.return,ke=de;break e}ke=C.return}}if(Ke=d,Hn(),yn&&typeof yn.onPostCommitFiberRoot=="function")try{yn.onPostCommitFiberRoot(da,e)}catch{}c=!0}return c}finally{Qe=i,nn.transition=r}}return!1}function lf(e,r,i){r=Hr(i,r),r=Nd(e,r,1),e=Gn(e,r,1),r=$t(),e!==null&&(cs(e,1,r),Ut(e,r))}function ft(e,r,i){if(e.tag===3)lf(e,e,i);else for(;r!==null;){if(r.tag===3){lf(r,e,i);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(qn===null||!qn.has(c))){e=Hr(i,e),e=Cd(r,e,1),r=Gn(r,e,1),e=$t(),r!==null&&(cs(r,1,e),Ut(r,e));break}}r=r.return}}function Wg(e,r,i){var c=e.pingCache;c!==null&&c.delete(r),r=$t(),e.pingedLanes|=e.suspendedLanes&i,kt===e&&(Et&i)===i&&(St===4||St===3&&(Et&130023424)===Et&&500>pt()-ml?gr(e,0):hl|=i),Ut(e,r)}function cf(e,r){r===0&&((e.mode&1)===0?r=1:(r=ha,ha<<=1,(ha&130023424)===0&&(ha=4194304)));var i=$t();e=Tn(e,r),e!==null&&(cs(e,r,i),Ut(e,i))}function Hg(e){var r=e.memoizedState,i=0;r!==null&&(i=r.retryLane),cf(e,i)}function Vg(e,r){var i=0;switch(e.tag){case 13:var c=e.stateNode,d=e.memoizedState;d!==null&&(i=d.retryLane);break;case 19:c=e.stateNode;break;default:throw Error(a(314))}c!==null&&c.delete(r),cf(e,i)}var uf;uf=function(e,r,i){if(e!==null)if(e.memoizedProps!==r.pendingProps||Mt.current)Bt=!0;else{if((e.lanes&i)===0&&(r.flags&128)===0)return Bt=!1,Pg(e,r,i);Bt=(e.flags&131072)!==0}else Bt=!1,ot&&(r.flags&1048576)!==0&&Uu(r,La,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;Ja(e,r),e=r.pendingProps;var d=zr(r,Tt.current);Ur(r,i),d=Vo(null,r,c,e,d,i);var m=Go();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,Ot(c)?(m=!0,Pa(r)):m=!1,r.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Mo(r),d.updater=qa,r.stateNode=d,d._reactInternals=r,Xo(r,c,e,i),r=nl(null,r,c,!0,m,i)):(r.tag=0,ot&&m&&To(r),Pt(null,r,d,i),r=r.child),r;case 16:c=r.elementType;e:{switch(Ja(e,r),e=r.pendingProps,d=c._init,c=d(c._payload),r.type=c,d=r.tag=Kg(c),e=un(c,e),d){case 0:r=tl(null,r,c,e,i);break e;case 1:r=Ld(null,r,c,e,i);break e;case 11:r=Ad(null,r,c,e,i);break e;case 14:r=Rd(null,r,c,un(c.type,e),i);break e}throw Error(a(306,c,""))}return r;case 0:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:un(c,d),tl(e,r,c,d,i);case 1:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:un(c,d),Ld(e,r,c,d,i);case 3:e:{if(zd(r),e===null)throw Error(a(387));c=r.pendingProps,m=r.memoizedState,d=m.element,Qu(e,r),Da(r,c,null,i);var w=r.memoizedState;if(c=w.element,m.isDehydrated)if(m={element:c,isDehydrated:!1,cache:w.cache,pendingSuspenseBoundaries:w.pendingSuspenseBoundaries,transitions:w.transitions},r.updateQueue.baseState=m,r.memoizedState=m,r.flags&256){d=Hr(Error(a(423)),r),r=Fd(e,r,c,i,d);break e}else if(c!==d){d=Hr(Error(a(424)),r),r=Fd(e,r,c,i,d);break e}else for(Yt=Dn(r.stateNode.containerInfo.firstChild),qt=r,ot=!0,cn=null,i=Yu(r,null,c,i),r.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Or(),c===d){r=An(e,r,i);break e}Pt(e,r,c,i)}r=r.child}return r;case 5:return ed(r),e===null&&Ro(r),c=r.type,d=r.pendingProps,m=e!==null?e.memoizedProps:null,w=d.children,So(c,d)?w=null:m!==null&&So(c,m)&&(r.flags|=32),_d(e,r),Pt(e,r,w,i),r.child;case 6:return e===null&&Ro(r),null;case 13:return Md(e,r,i);case 4:return Oo(r,r.stateNode.containerInfo),c=r.pendingProps,e===null?r.child=Br(r,null,c,i):Pt(e,r,c,i),r.child;case 11:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:un(c,d),Ad(e,r,c,d,i);case 7:return Pt(e,r,r.pendingProps,i),r.child;case 8:return Pt(e,r,r.pendingProps.children,i),r.child;case 12:return Pt(e,r,r.pendingProps.children,i),r.child;case 10:e:{if(c=r.type._context,d=r.pendingProps,m=r.memoizedProps,w=d.value,nt(Ma,c._currentValue),c._currentValue=w,m!==null)if(ln(m.value,w)){if(m.children===d.children&&!Mt.current){r=An(e,r,i);break e}}else for(m=r.child,m!==null&&(m.return=r);m!==null;){var C=m.dependencies;if(C!==null){w=m.child;for(var R=C.firstContext;R!==null;){if(R.context===c){if(m.tag===1){R=In(-1,i&-i),R.tag=2;var W=m.updateQueue;if(W!==null){W=W.shared;var ae=W.pending;ae===null?R.next=R:(R.next=ae.next,ae.next=R),W.pending=R}}m.lanes|=i,R=m.alternate,R!==null&&(R.lanes|=i),zo(m.return,i,r),C.lanes|=i;break}R=R.next}}else if(m.tag===10)w=m.type===r.type?null:m.child;else if(m.tag===18){if(w=m.return,w===null)throw Error(a(341));w.lanes|=i,C=w.alternate,C!==null&&(C.lanes|=i),zo(w,i,r),w=m.sibling}else w=m.child;if(w!==null)w.return=m;else for(w=m;w!==null;){if(w===r){w=null;break}if(m=w.sibling,m!==null){m.return=w.return,w=m;break}w=w.return}m=w}Pt(e,r,d.children,i),r=r.child}return r;case 9:return d=r.type,c=r.pendingProps.children,Ur(r,i),d=en(d),c=c(d),r.flags|=1,Pt(e,r,c,i),r.child;case 14:return c=r.type,d=un(c,r.pendingProps),d=un(c.type,d),Rd(e,r,c,d,i);case 15:return Pd(e,r,r.type,r.pendingProps,i);case 17:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:un(c,d),Ja(e,r),r.tag=1,Ot(c)?(e=!0,Pa(r)):e=!1,Ur(r,i),bd(r,c,d),Xo(r,c,d,i),nl(null,r,c,!0,e,i);case 19:return Bd(e,r,i);case 22:return $d(e,r,i)}throw Error(a(156,r.tag))};function df(e,r){return Wc(e,r)}function Gg(e,r,i,c){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=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 rn(e,r,i,c){return new Gg(e,r,i,c)}function Sl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Kg(e){if(typeof e=="function")return Sl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===z)return 11;if(e===Y)return 14}return 2}function Xn(e,r){var i=e.alternate;return i===null?(i=rn(e.tag,r,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=r,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,r=e.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function oi(e,r,i,c,d,m){var w=2;if(c=e,typeof e=="function")Sl(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case F:return vr(i.children,d,m,r);case J:w=8,d|=8;break;case Q:return e=rn(12,i,r,d|2),e.elementType=Q,e.lanes=m,e;case oe:return e=rn(13,i,r,d),e.elementType=oe,e.lanes=m,e;case ue:return e=rn(19,i,r,d),e.elementType=ue,e.lanes=m,e;case xe:return li(i,d,m,r);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:w=10;break e;case ee:w=9;break e;case z:w=11;break e;case Y:w=14;break e;case je:w=16,c=null;break e}throw Error(a(130,e==null?e:typeof e,""))}return r=rn(w,i,r,d),r.elementType=e,r.type=c,r.lanes=m,r}function vr(e,r,i,c){return e=rn(7,e,c,r),e.lanes=i,e}function li(e,r,i,c){return e=rn(22,e,c,r),e.elementType=xe,e.lanes=i,e.stateNode={isHidden:!1},e}function bl(e,r,i){return e=rn(6,e,null,r),e.lanes=i,e}function kl(e,r,i){return r=rn(4,e.children!==null?e.children:[],e.key,r),r.lanes=i,r.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},r}function qg(e,r,i,c,d){this.tag=r,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ji(0),this.expirationTimes=Ji(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ji(0),this.identifierPrefix=c,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Nl(e,r,i,c,d,m,w,C,R){return e=new qg(e,r,i,C,R),r===1?(r=1,m===!0&&(r|=8)):r=0,m=rn(3,null,null,r),e.current=m,m.stateNode=e,m.memoizedState={element:c,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Mo(m),e}function Yg(e,r,i){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:V,key:c==null?null:""+c,children:e,containerInfo:r,implementation:i}}function ff(e){if(!e)return Wn;e=e._reactInternals;e:{if(ir(e)!==e||e.tag!==1)throw Error(a(170));var r=e;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Ot(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(a(171))}if(e.tag===1){var i=e.type;if(Ot(i))return Ou(e,i,r)}return r}function hf(e,r,i,c,d,m,w,C,R){return e=Nl(i,c,!0,e,d,m,w,C,R),e.context=ff(null),i=e.current,c=$t(),d=Jn(i),m=In(c,d),m.callback=r??null,Gn(i,m,d),e.current.lanes=d,cs(e,d,c),Ut(e,c),e}function ci(e,r,i,c){var d=r.current,m=$t(),w=Jn(d);return i=ff(i),r.context===null?r.context=i:r.pendingContext=i,r=In(m,w),r.payload={element:e},c=c===void 0?null:c,c!==null&&(r.callback=c),e=Gn(d,r,w),e!==null&&(hn(e,d,w,m),Ba(e,d,w)),w}function ui(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function mf(e,r){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var i=e.retryLane;e.retryLane=i!==0&&i<r?i:r}}function Cl(e,r){mf(e,r),(e=e.alternate)&&mf(e,r)}function Jg(){return null}var pf=typeof reportError=="function"?reportError:function(e){console.error(e)};function El(e){this._internalRoot=e}di.prototype.render=El.prototype.render=function(e){var r=this._internalRoot;if(r===null)throw Error(a(409));ci(e,r,null,null)},di.prototype.unmount=El.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var r=e.containerInfo;pr(function(){ci(null,e,null,null)}),r[kn]=null}};function di(e){this._internalRoot=e}di.prototype.unstable_scheduleHydration=function(e){if(e){var r=Qc();e={blockedOn:null,target:e,priority:r};for(var i=0;i<Mn.length&&r!==0&&r<Mn[i].priority;i++);Mn.splice(i,0,e),i===0&&eu(e)}};function Tl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function fi(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function gf(){}function Qg(e,r,i,c,d){if(d){if(typeof c=="function"){var m=c;c=function(){var W=ui(w);m.call(W)}}var w=hf(r,c,e,0,null,!1,!1,"",gf);return e._reactRootContainer=w,e[kn]=w.current,bs(e.nodeType===8?e.parentNode:e),pr(),w}for(;d=e.lastChild;)e.removeChild(d);if(typeof c=="function"){var C=c;c=function(){var W=ui(R);C.call(W)}}var R=Nl(e,0,!1,null,null,!1,!1,"",gf);return e._reactRootContainer=R,e[kn]=R.current,bs(e.nodeType===8?e.parentNode:e),pr(function(){ci(r,R,i,c)}),R}function hi(e,r,i,c,d){var m=i._reactRootContainer;if(m){var w=m;if(typeof d=="function"){var C=d;d=function(){var R=ui(w);C.call(R)}}ci(r,w,e,d)}else w=Qg(i,r,e,d,c);return ui(w)}Yc=function(e){switch(e.tag){case 3:var r=e.stateNode;if(r.current.memoizedState.isDehydrated){var i=ls(r.pendingLanes);i!==0&&(Qi(r,i|1),Ut(r,pt()),(Ke&6)===0&&(Kr=pt()+500,Hn()))}break;case 13:pr(function(){var c=Tn(e,1);if(c!==null){var d=$t();hn(c,e,1,d)}}),Cl(e,1)}},Xi=function(e){if(e.tag===13){var r=Tn(e,134217728);if(r!==null){var i=$t();hn(r,e,134217728,i)}Cl(e,134217728)}},Jc=function(e){if(e.tag===13){var r=Jn(e),i=Tn(e,r);if(i!==null){var c=$t();hn(i,e,r,c)}Cl(e,r)}},Qc=function(){return Qe},Xc=function(e,r){var i=Qe;try{return Qe=e,r()}finally{Qe=i}},le=function(e,r,i){switch(r){case"input":if(Me(e,i),r=i.name,i.type==="radio"&&r!=null){for(i=e;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!==e&&c.form===e.form){var d=Aa(c);if(!d)throw Error(a(90));Le(c),Me(c,d)}}}break;case"textarea":ze(e,i);break;case"select":r=i.value,r!=null&&Je(e,!!i.multiple,r,!1)}},Gt=xl,tr=pr;var Xg={usingClientEntryPoint:!1,Events:[Cs,_r,Aa,Oe,tt,xl]},Bs={findFiberByHostInstance:or,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Zg={bundleType:Bs.bundleType,version:Bs.version,rendererPackageName:Bs.rendererPackageName,rendererConfig:Bs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:I.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Dc(e),e===null?null:e.stateNode},findFiberByHostInstance:Bs.findFiberByHostInstance||Jg,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 mi=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!mi.isDisabled&&mi.supportsFiber)try{da=mi.inject(Zg),yn=mi}catch{}}return Wt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Xg,Wt.createPortal=function(e,r){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Tl(r))throw Error(a(200));return Yg(e,r,null,i)},Wt.createRoot=function(e,r){if(!Tl(e))throw Error(a(299));var i=!1,c="",d=pf;return r!=null&&(r.unstable_strictMode===!0&&(i=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(d=r.onRecoverableError)),r=Nl(e,1,!1,null,null,i,!1,c,d),e[kn]=r.current,bs(e.nodeType===8?e.parentNode:e),new El(r)},Wt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var r=e._reactInternals;if(r===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=Dc(r),e=e===null?null:e.stateNode,e},Wt.flushSync=function(e){return pr(e)},Wt.hydrate=function(e,r,i){if(!fi(r))throw Error(a(200));return hi(null,e,r,!0,i)},Wt.hydrateRoot=function(e,r,i){if(!Tl(e))throw Error(a(405));var c=i!=null&&i.hydratedSources||null,d=!1,m="",w=pf;if(i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(w=i.onRecoverableError)),r=hf(r,null,e,1,i??null,d,!1,m,w),e[kn]=r.current,bs(e),c)for(e=0;e<c.length;e++)i=c[e],d=i._getVersion,d=d(i._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[i,d]:r.mutableSourceEagerHydrationData.push(i,d);return new di(r)},Wt.render=function(e,r,i){if(!fi(r))throw Error(a(200));return hi(null,e,r,!1,i)},Wt.unmountComponentAtNode=function(e){if(!fi(e))throw Error(a(40));return e._reactRootContainer?(pr(function(){hi(null,null,e,!1,function(){e._reactRootContainer=null,e[kn]=null})}),!0):!1},Wt.unstable_batchedUpdates=xl,Wt.unstable_renderSubtreeIntoContainer=function(e,r,i,c){if(!fi(i))throw Error(a(200));if(e==null||e._reactInternals===void 0)throw Error(a(38));return hi(e,r,i,!1,c)},Wt.version="18.3.1-next-f1338f8080-20240426",Wt}var kf;function Eh(){if(kf)return Rl.exports;kf=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(s){console.error(s)}}return t(),Rl.exports=ly(),Rl.exports}var Nf;function cy(){if(Nf)return pi;Nf=1;var t=Eh();return pi.createRoot=t.createRoot,pi.hydrateRoot=t.hydrateRoot,pi}var uy=cy();/**
|
|
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 lc=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Th=/^[\\/]{2}/;function dy(t,s){return s+t.replace(/\\/g,"/")}var Cf="popstate";function Ef(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function fy(t={}){function s(o,l){var v;let u=(v=l.state)==null?void 0:v.masked,{pathname:f,search:g,hash:p}=u||o.location;return Gl("",{pathname:f,search:g,hash:p},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:kr(l)}return my(s,a,null,t)}function ct(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function an(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function hy(){return Math.random().toString(36).substring(2,10)}function Tf(t,s){return{usr:t.state,key:t.key,idx:s,masked:t.mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Gl(t,s,a=null,o,l){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof s=="string"?ts(s):s,state:a,key:s&&s.key||o||hy(),mask:l}}function kr({pathname:t="/",search:s="",hash:a=""}){return s&&s!=="?"&&(t+=s.charAt(0)==="?"?s:"?"+s),a&&a!=="#"&&(t+=a.charAt(0)==="#"?a:"#"+a),t}function ts(t){let s={};if(t){let a=t.indexOf("#");a>=0&&(s.hash=t.substring(a),t=t.substring(0,a));let o=t.indexOf("?");o>=0&&(s.search=t.substring(o),t=t.substring(0,o)),t&&(s.pathname=t)}return s}function my(t,s,a,o={}){let{window:l=document.defaultView,v5Compat:u=!1}=o,f=l.history,g="POP",p=null,v=y();v==null&&(v=0,f.replaceState({...f.state,idx:v},""));function y(){return(f.state||{idx:null}).idx}function x(){g="POP";let k=y(),E=k==null?null:k-v;v=k,p&&p({action:g,location:S.location,delta:E})}function j(k,E){g="PUSH";let T=Ef(k)?k:Gl(S.location,k,E);v=y()+1;let P=Tf(T,v),I=S.createHref(T.mask||T);try{f.pushState(P,"",I)}catch(U){if(U instanceof DOMException&&U.name==="DataCloneError")throw U;l.location.assign(I)}u&&p&&p({action:g,location:S.location,delta:1})}function N(k,E){g="REPLACE";let T=Ef(k)?k:Gl(S.location,k,E);v=y();let P=Tf(T,v),I=S.createHref(T.mask||T);f.replaceState(P,"",I),u&&p&&p({action:g,location:S.location,delta:0})}function b(k){return py(l,k)}let S={get action(){return g},get location(){return t(l,f)},listen(k){if(p)throw new Error("A history only accepts one active listener");return l.addEventListener(Cf,x),p=k,()=>{l.removeEventListener(Cf,x),p=null}},createHref(k){return s(l,k)},createURL:b,encodeLocation(k){let E=b(k);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:j,replace:N,go(k){return f.go(k)}};return S}function py(t,s,a=!1){let o="http://localhost";t&&(o=t.location.origin!=="null"?t.location.origin:t.location.href),ct(o,"No window.location.(origin|href) available to create URL");let l=typeof s=="string"?s:kr(s);return l=l.replace(/ $/,"%20"),!a&&Th.test(l)&&(l=o+l),new URL(l,o)}function Ih(t,s,a="/"){return gy(t,s,a,!1)}function gy(t,s,a,o,l){let u=typeof s=="string"?ts(s):s,f=$n(u.pathname||"/",a);if(f==null)return null;let g=yy(t),p=null,v=Ty(f);for(let y=0;p==null&&y<g.length;++y)p=Ey(g[y],v,o);return p}function yy(t){let s=Ah(t);return vy(s),s}function Ah(t,s=[],a=[],o="",l=!1){let u=(f,g,p=l,v)=>{let y={relativePath:v===void 0?f.path||"":v,caseSensitive:f.caseSensitive===!0,childrenIndex:g,route:f};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&p)return;ct(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 x=mn([o,y.relativePath]),j=a.concat(y);f.children&&f.children.length>0&&(ct(f.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${x}".`),Ah(f.children,s,j,x,p)),!(f.path==null&&!f.index)&&s.push({path:x,score:Ny(x,f.index),routesMeta:j.map((N,b)=>{let[S,k]=$h(N.relativePath,N.caseSensitive,b===j.length-1);return{...N,matcher:S,compiledParams:k}})})};return t.forEach((f,g)=>{var p;if(f.path===""||!((p=f.path)!=null&&p.includes("?")))u(f,g);else for(let v of Rh(f.path))u(f,g,!0,v)}),s}function Rh(t){let s=t.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=Rh(o.join("/")),g=[];return g.push(...f.map(p=>p===""?u:[u,p].join("/"))),l&&g.push(...f),g.map(p=>t.startsWith("/")&&p===""?"/":p)}function vy(t){t.sort((s,a)=>s.score!==a.score?a.score-s.score:Cy(s.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var xy=/^:[\w-]+$/,wy=3,jy=2,Sy=1,by=10,ky=-2,If=t=>t==="*";function Ny(t,s){let a=t.split("/"),o=a.length;return a.some(If)&&(o+=ky),s&&(o+=jy),a.filter(l=>!If(l)).reduce((l,u)=>l+(xy.test(u)?wy:u===""?Sy:by),o)}function Cy(t,s){return t.length===s.length&&t.slice(0,-1).every((o,l)=>o===s[l])?t[t.length-1]-s[s.length-1]:0}function Ey(t,s,a=!1){let{routesMeta:o}=t,l={},u="/",f=[];for(let g=0;g<o.length;++g){let p=o[g],v=g===o.length-1,y=u==="/"?s:s.slice(u.length)||"/",x={path:p.relativePath,caseSensitive:p.caseSensitive,end:v},j=p.matcher&&p.compiledParams?Ph(x,y,p.matcher,p.compiledParams):Ci(x,y),N=p.route;if(!j&&v&&a&&!o[o.length-1].route.index&&(j=Ci({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},y)),!j)return null;Object.assign(l,j.params),f.push({params:l,pathname:mn([u,j.pathname]),pathnameBase:Ry(mn([u,j.pathnameBase])),route:N}),j.pathnameBase!=="/"&&(u=mn([u,j.pathnameBase]))}return f}function Ci(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[a,o]=$h(t.path,t.caseSensitive,t.end);return Ph(t,s,a,o)}function Ph(t,s,a,o){let l=s.match(a);if(!l)return null;let u=l[0],f=Zr(u,1),g=l.slice(1);return{params:o.reduce((v,{paramName:y,isOptional:x},j)=>{if(y==="*"){let b=g[j]||"";f=Zr(u.slice(0,u.length-b.length),1)}const N=g[j];return x&&!N?v[y]=void 0:v[y]=(N||"").replace(/%2F/g,"/"),v},{}),pathname:u,pathnameBase:f,pattern:t}}function $h(t,s=!1,a=!0){an(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],l="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(f,g,p,v,y)=>{if(o.push({paramName:g,isOptional:p!=null}),p){let x=y.charAt(v+f.length);return x&&x!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),l+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":t!==""&&t!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,s?void 0:"i"),o]}function Ty(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return an(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),t}}function $n(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let a=s.endsWith("/")?s.length-1:s.length,o=t.charAt(a);return o&&o!=="/"?null:t.slice(a)||"/"}function Iy(t,s="/"){let{pathname:a,search:o="",hash:l=""}=typeof t=="string"?ts(t):t,u;return a?(a=_h(a),a.startsWith("/")||a.startsWith("\\")?u=Af(a.substring(1),"/"):u=Af(a,s)):u=s,{pathname:u,search:Py(o),hash:$y(l)}}function Af(t,s){let a=Zr(s).split("/");return t.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function _l(t,s,a,o){return`Cannot include a '${t}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Ay(t){return t.filter((s,a)=>a===0||s.route.path&&s.route.path.length>0)}function cc(t){let s=Ay(t);return s.map((a,o)=>o===s.length-1?a.pathname:a.pathnameBase)}function Bi(t,s,a,o=!1){let l;typeof t=="string"?l=ts(t):(l={...t},ct(!l.pathname||!l.pathname.includes("?"),_l("?","pathname","search",l)),ct(!l.pathname||!l.pathname.includes("#"),_l("#","pathname","hash",l)),ct(!l.search||!l.search.includes("#"),_l("#","search","hash",l)));let u=t===""||l.pathname==="",f=u?"/":l.pathname,g;if(f==null)g=a;else{let x=s.length-1;if(!o&&f.startsWith("..")){let j=f.split("/");for(;j[0]==="..";)j.shift(),x-=1;l.pathname=j.join("/")}g=x>=0?s[x]:"/"}let p=Iy(l,g),v=f&&f!=="/"&&f.endsWith("/"),y=(u||f===".")&&a.endsWith("/");return!p.pathname.endsWith("/")&&(v||y)&&(p.pathname+="/"),p}var _h=t=>t.replace(/[\\/]{2,}/g,"/"),mn=t=>_h(t.join("/"));function Zr(t,s=0){let a=t.length;for(;a>s&&t.charCodeAt(a-1)===47;)a--;return a===t.length?t:t.slice(0,a)}var Ry=t=>Zr(t).replace(/^\/*/,"/"),Py=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,$y=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,_y=class{constructor(t,s,a,o=!1){this.status=t,this.statusText=s||"",this.internal=o,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function Ly(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function zy(t){let s=t.map(a=>a.route.path).filter(Boolean);return mn(s)||"/"}var Lh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function zh(t,s){let a=t;if(typeof a!="string"||!lc.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,l=!1;if(Lh)try{let u=new URL(window.location.href),f=Th.test(a)?new URL(dy(a,u.protocol)):new URL(a),g=$n(f.pathname,s);f.origin===u.origin&&g!=null?a=g+f.search+f.hash:l=!0}catch{an(!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 Rf=new URL("http://localhost");function uc(t){if(t.createURL)return t.createURL("/");try{return new URL(t.createHref("/"),Rf)}catch{return Rf}}function Ll(t,s){return t.origin===s.origin&&(t.origin!=="null"||t.protocol===s.protocol&&t.host===s.host)}function Fy(t,s){if(t.startsWith("//"))return!0;let a=s.protocol.toLowerCase();return t.toLowerCase().startsWith(a)?s.host===""||t.slice(a.length).startsWith("//"):!1}function dc(t,s,a,o){let l=null;try{l=t==null?null:new URL(t,a)}catch{}let u=new URL(s,a),f=l!=null&&!Ll(l,a),g=!Ll(u,a);if(o==="reject"){if(f||g)throw new Error("External navigation is not allowed")}else if(g&&(l==null||!Fy(t,l)||!Ll(l,u)))throw new Error("External navigation is not allowed")}var Fh=["POST","PUT","PATCH","DELETE"];new Set(Fh);var My=["GET",...Fh];new Set(My);var Oy=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function By(t){try{return Oy.includes(new URL(t).protocol)}catch{return!1}}var ns=h.createContext(null);ns.displayName="DataRouter";var Di=h.createContext(null);Di.displayName="DataRouterState";var Mh=h.createContext(!1);function Dy(){return h.useContext(Mh)}var Oh=h.createContext({isTransitioning:!1});Oh.displayName="ViewTransition";var Uy=h.createContext(new Map);Uy.displayName="Fetchers";var Wy=h.createContext(null);Wy.displayName="Await";var Qt=h.createContext(null);Qt.displayName="Navigation";var na=h.createContext(null);na.displayName="Location";var pn=h.createContext({outlet:null,matches:[],isDataRoute:!1});pn.displayName="Route";var fc=h.createContext(null);fc.displayName="RouteError";var Bh="REACT_ROUTER_ERROR",Hy="REDIRECT",Vy="ROUTE_ERROR_RESPONSE";function Gy(t){if(t.startsWith(`${Bh}:${Hy}:{`))try{let s=JSON.parse(t.slice(28));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string"&&typeof s.location=="string"&&typeof s.reloadDocument=="boolean"&&typeof s.replace=="boolean")return s}catch{}}function Ky(t){if(t.startsWith(`${Bh}:${Vy}:{`))try{let s=JSON.parse(t.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new _y(s.status,s.statusText,s.data)}catch{}}function qy(t,{relative:s}={}){ct(rs(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:o}=h.useContext(Qt),{hash:l,pathname:u,search:f}=ra(t,{relative:s}),g=u;return a!=="/"&&(g=u==="/"?a:mn([a,u])),o.createHref({pathname:g,search:f,hash:l})}function rs(){return h.useContext(na)!=null}function Vt(){return ct(rs(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(na).location}var Dh="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Uh(t){h.useContext(Qt).static||h.useLayoutEffect(t)}function gn(){let{isDataRoute:t}=h.useContext(pn);return t?cv():Yy()}function Yy(){ct(rs(),"useNavigate() may be used only in the context of a <Router> component.");let t=h.useContext(ns),{basename:s,navigator:a}=h.useContext(Qt),{matches:o}=h.useContext(pn),{pathname:l}=Vt(),u=JSON.stringify(cc(o)),f=h.useRef(!1);return Uh(()=>{f.current=!0}),h.useCallback((p,v={})=>{if(an(f.current,Dh),!f.current)return;if(typeof p=="number"){a.go(p);return}let y=Bi(p,JSON.parse(u),l,v.relative==="path");t==null&&s!=="/"&&(y.pathname=y.pathname==="/"?s:mn([s,y.pathname])),dc(typeof p=="string"?p:kr(p),a.createHref(y),uc(a),"reject"),(v.replace?a.replace:a.push)(y,v.state,v)},[s,a,u,l,t])}var Jy=h.createContext(null);function Qy(t){let s=h.useContext(pn).outlet;return h.useMemo(()=>s&&h.createElement(Jy.Provider,{value:t},s),[s,t])}function ra(t,{relative:s}={}){let{matches:a}=h.useContext(pn),{pathname:o}=Vt(),l=JSON.stringify(cc(a));return h.useMemo(()=>Bi(t,JSON.parse(l),o,s==="path"),[t,l,o,s])}function Xy(t,s){return Wh(t,s)}function Wh(t,s,a){var k;ct(rs(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=h.useContext(Qt),{matches:l}=h.useContext(pn),u=l[l.length-1],f=u?u.params:{},g=u?u.pathname:"/",p=u?u.pathnameBase:"/",v=u&&u.route;{let E=v&&v.path||"";Vh(g,!v||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (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=Vt(),x;if(s){let E=typeof s=="string"?ts(s):s;ct(p==="/"||((k=E.pathname)==null?void 0:k.startsWith(p)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${E.pathname}" was given in the \`location\` prop.`),x=E}else x=y;let j=x.pathname||"/",N=j;if(p!=="/"){let E=p.replace(/^\//,"").split("/");N="/"+j.replace(/^\//,"").split("/").slice(E.length).join("/")}let b=a&&a.state.matches.length?a.state.matches.map(E=>Object.assign(E,{route:a.manifest[E.route.id]||E.route})):Ih(t,{pathname:N});an(v||b!=null,`No routes matched location "${x.pathname}${x.search}${x.hash}" `),an(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.length-1].route.lazy!==void 0,`Matched leaf route at location "${x.pathname}${x.search}${x.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=rv(b&&b.map(E=>Object.assign({},E,{params:Object.assign({},f,E.params),pathname:mn([p,o.encodeLocation?o.encodeLocation(E.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?p:mn([p,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(na.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...x},navigationType:"POP"}},S):S}function Zy(){let t=lv(),s=Ly(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),a=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},f=null;return console.error("Error handled by React Router default ErrorBoundary:",t),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 ev=h.createElement(Zy,null),Hh=class extends h.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,s){return s.location!==t.location||s.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:s.error,location:s.location,revalidation:t.revalidation||s.revalidation}}componentDidCatch(t,s){this.props.onError?this.props.onError(t,s):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const a=Ky(t.digest);a&&(t=a)}let s=t!==void 0?h.createElement(pn.Provider,{value:this.props.routeContext},h.createElement(fc.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?h.createElement(tv,{error:t},s):s}};Hh.contextType=Mh;var zl=new WeakMap;function tv({children:t,error:s}){let{basename:a,navigator:o}=h.useContext(Qt);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let l=Gy(s.digest);if(l){let u=zl.get(s);if(u)throw u;let f=zh(l.location,a),g=f.absoluteURL||f.to;if(dc(l.location,g,uc(o),"allow-explicit"),By(g))throw new Error("Invalid redirect location");if(Lh&&!zl.get(s))if(f.isExternal||l.reloadDocument)window.location.href=g;else{const p=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(f.to,{replace:l.replace}));throw zl.set(s,p),p}return h.createElement("meta",{httpEquiv:"refresh",content:`0;url=${g}`})}}return t}function nv({routeContext:t,match:s,children:a}){let o=h.useContext(ns);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),h.createElement(pn.Provider,{value:t},a)}function rv(t,s=[],a){let o=a==null?void 0:a.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let l=t,u=o==null?void 0:o.errors;if(u!=null){let y=l.findIndex(x=>x.route.id&&(u==null?void 0:u[x.route.id])!==void 0);ct(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,g=-1;if(a&&o){f=o.renderFallback;for(let y=0;y<l.length;y++){let x=l[y];if((x.route.HydrateFallback||x.route.hydrateFallbackElement)&&(g=y),x.route.id){let{loaderData:j,errors:N}=o,b=x.route.loader&&!j.hasOwnProperty(x.route.id)&&(!N||N[x.route.id]===void 0);if(x.route.lazy||b){a.isStatic&&(f=!0),g>=0?l=l.slice(0,g+1):l=[l[0]];break}}}}let p=a==null?void 0:a.onError,v=o&&p?(y,x)=>{var j,N;p(y,{location:o.location,params:((N=(j=o.matches)==null?void 0:j[0])==null?void 0:N.params)??{},pattern:zy(o.matches),errorInfo:x})}:void 0;return l.reduceRight((y,x,j)=>{let N,b=!1,S=null,k=null;o&&(N=u&&x.route.id?u[x.route.id]:void 0,S=x.route.errorElement||ev,f&&(g<0&&j===0?(Vh("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,k=null):g===j&&(b=!0,k=x.route.hydrateFallbackElement||null)));let E=s.concat(l.slice(0,j+1)),T=()=>{let P;return N?P=S:b?P=k:x.route.Component?P=h.createElement(x.route.Component,null):x.route.element?P=x.route.element:P=y,h.createElement(nv,{match:x,routeContext:{outlet:y,matches:E,isDataRoute:o!=null},children:P})};return o&&(x.route.ErrorBoundary||x.route.errorElement||j===0)?h.createElement(Hh,{location:o.location,revalidation:o.revalidation,component:S,error:N,children:T(),routeContext:{outlet:null,matches:E,isDataRoute:!0},onError:v}):T()},null)}function hc(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function sv(t){let s=h.useContext(ns);return ct(s,hc(t)),s}function av(t){let s=h.useContext(Di);return ct(s,hc(t)),s}function iv(t){let s=h.useContext(pn);return ct(s,hc(t)),s}function mc(t){let s=iv(t),a=s.matches[s.matches.length-1];return ct(a.route.id,`${t} can only be used on routes that contain a unique "id"`),a.route.id}function ov(){return mc("useRouteId")}function lv(){var o;let t=h.useContext(fc),s=av("useRouteError"),a=mc("useRouteError");return t!==void 0?t:(o=s.errors)==null?void 0:o[a]}function cv(){let{router:t}=sv("useNavigate"),s=mc("useNavigate"),a=h.useRef(!1);return Uh(()=>{a.current=!0}),h.useCallback(async(l,u={})=>{an(a.current,Dh),a.current&&(typeof l=="number"?await t.navigate(l):await t.navigate(l,{fromRouteId:s,...u}))},[t,s])}var Pf={};function Vh(t,s,a){!s&&!Pf[t]&&(Pf[t]=!0,an(!1,a))}h.memo(uv);function uv({routes:t,manifest:s,future:a,state:o,isStatic:l,onError:u}){return Wh(t,void 0,{manifest:s,state:o,isStatic:l,onError:u})}function Pn({to:t,replace:s,state:a,relative:o}){ct(rs(),"<Navigate> may be used only in the context of a <Router> component.");let{static:l,navigator:u}=h.useContext(Qt);an(!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(pn),{pathname:g}=Vt(),p=gn(),v=Bi(t,cc(f),g,o==="path");dc(typeof t=="string"?t:kr(t),u.createHref(v),uc(u),"reject");let y=JSON.stringify(v);return h.useEffect(()=>{p(JSON.parse(y),{replace:s,state:a,relative:o})},[p,y,o,s,a]),null}function dv(t){return Qy(t.context)}function rt(t){ct(!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 fv({basename:t="/",children:s=null,location:a,navigationType:o="POP",navigator:l,static:u=!1,useTransitions:f}){ct(!rs(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let g=t.replace(/^\/*/,"/"),p=h.useMemo(()=>({basename:g,navigator:l,static:u,useTransitions:f,future:{}}),[g,l,u,f]);typeof a=="string"&&(a=ts(a));let{pathname:v="/",search:y="",hash:x="",state:j=null,key:N="default",mask:b}=a,S=h.useMemo(()=>{let k=$n(v,g);return k==null?null:{location:{pathname:k,search:y,hash:x,state:j,key:N,mask:b},navigationType:o}},[g,v,y,x,j,N,o,b]);return an(S!=null,`<Router basename="${g}"> is not able to match the URL "${v}${y}${x}" because it does not start with the basename, so the <Router> won't render anything.`),S==null?null:h.createElement(Qt.Provider,{value:p},h.createElement(na.Provider,{children:s,value:S}))}function hv({children:t,location:s}){return Xy(Kl(t),s)}function Kl(t,s=[]){let a=[];return h.Children.forEach(t,(o,l)=>{if(!h.isValidElement(o))return;let u=[...s,l];if(o.type===h.Fragment){a.push.apply(a,Kl(o.props.children,u));return}ct(o.type===rt,`[${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>`),ct(!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=Kl(o.props.children,u)),a.push(f)}),a}var Si="get",bi="application/x-www-form-urlencoded";function Ui(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function mv(t){return Ui(t)&&t.tagName.toLowerCase()==="button"}function pv(t){return Ui(t)&&t.tagName.toLowerCase()==="form"}function gv(t){return Ui(t)&&t.tagName.toLowerCase()==="input"}function yv(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function vv(t,s){return t.button===0&&(!s||s==="_self")&&!yv(t)}function ql(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,a)=>{let o=t[a];return s.concat(Array.isArray(o)?o.map(l=>[a,l]):[[a,o]])},[]))}function xv(t,s){let a=ql(t);return s&&s.forEach((o,l)=>{a.has(l)||s.getAll(l).forEach(u=>{a.append(l,u)})}),a}var gi=null;function wv(){if(gi===null)try{new FormData(document.createElement("form"),0),gi=!1}catch{gi=!0}return gi}var jv=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Fl(t){return t!=null&&!jv.has(t)?(an(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${bi}"`),null):t}function Sv(t,s){let a,o,l,u,f;if(pv(t)){let g=t.getAttribute("action");o=g?$n(g,s):null,a=t.getAttribute("method")||Si,l=Fl(t.getAttribute("enctype"))||bi,u=new FormData(t)}else if(mv(t)||gv(t)&&(t.type==="submit"||t.type==="image")){let g=t.form;if(g==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=t.getAttribute("formaction")||g.getAttribute("action");if(o=p?$n(p,s):null,a=t.getAttribute("formmethod")||g.getAttribute("method")||Si,l=Fl(t.getAttribute("formenctype"))||Fl(g.getAttribute("enctype"))||bi,u=new FormData(g,t),!wv()){let{name:v,type:y,value:x}=t;if(y==="image"){let j=v?`${v}.`:"";u.append(`${j}x`,"0"),u.append(`${j}y`,"0")}else v&&u.append(v,x)}}else{if(Ui(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=Si,o=null,l=bi,f=t}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 pc(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function Gh(t,s,a,o){let l=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return a?l.pathname.endsWith("/")?l.pathname=`${l.pathname}_.${o}`:l.pathname=`${l.pathname}.${o}`:l.pathname==="/"?l.pathname=`_root.${o}`:s&&$n(l.pathname,s)==="/"?l.pathname=`${Zr(s)}/_root.${o}`:l.pathname=`${Zr(l.pathname)}.${o}`,l}async function bv(t,s){if(t.id in s)return s[t.id];try{let a=await import(t.module);return s[t.id]=a,a}catch(a){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function kv(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function Nv(t,s,a){let o=await Promise.all(t.map(async l=>{let u=s.routes[l.route.id];if(u){let f=await bv(u,a);return f.links?f.links():[]}return[]}));return Iv(o.flat(1).filter(kv).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function $f(t,s,a,o,l,u){let f=(p,v)=>a[v]?p.route.id!==a[v].route.id:!0,g=(p,v)=>{var y;return a[v].pathname!==p.pathname||((y=a[v].route.path)==null?void 0:y.endsWith("*"))&&a[v].params["*"]!==p.params["*"]};return u==="assets"?s.filter((p,v)=>f(p,v)||g(p,v)):u==="data"?s.filter((p,v)=>{var x;let y=o.routes[p.route.id];if(!y||!y.hasLoader)return!1;if(f(p,v)||g(p,v))return!0;if(p.route.shouldRevalidate){let j=p.route.shouldRevalidate({currentUrl:new URL(l.pathname+l.search+l.hash,window.origin),currentParams:((x=a[0])==null?void 0:x.params)||{},nextUrl:new URL(t,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof j=="boolean")return j}return!0}):[]}function Cv(t,s,{includeHydrateFallback:a}={}){return Ev(t.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 Ev(t){return[...new Set(t)]}function Tv(t){let s={},a=Object.keys(t).sort();for(let o of a)s[o]=t[o];return s}function Iv(t,s){let a=new Set;return new Set(s),t.reduce((o,l)=>{let u=JSON.stringify(Tv(l));return a.has(u)||(a.add(u),o.push({key:u,link:l})),o},[])}function gc(){let t=h.useContext(ns);return pc(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Av(){let t=h.useContext(Di);return pc(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var yc=h.createContext(void 0);yc.displayName="FrameworkContext";function Wi(){let t=h.useContext(yc);return pc(t,"You must render this element inside a <HydratedRouter> element"),t}function Rv(t,s){let a=h.useContext(yc),[o,l]=h.useState(!1),[u,f]=h.useState(!1),{onFocus:g,onBlur:p,onMouseEnter:v,onMouseLeave:y,onTouchStart:x}=s,j=h.useRef(null);h.useEffect(()=>{if(t==="render"&&f(!0),t==="viewport"){let S=E=>{E.forEach(T=>{f(T.isIntersecting)})},k=new IntersectionObserver(S,{threshold:.5});return j.current&&k.observe(j.current),()=>{k.disconnect()}}},[t]),h.useEffect(()=>{if(o){let S=setTimeout(()=>{f(!0)},100);return()=>{clearTimeout(S)}}},[o]);let N=()=>{l(!0)},b=()=>{l(!1),f(!1)};return a?t!=="intent"?[u,j,{}]:[u,j,{onFocus:Ws(g,N),onBlur:Ws(p,b),onMouseEnter:Ws(v,N),onMouseLeave:Ws(y,b),onTouchStart:Ws(x,N)}]:[!1,j,{}]}function Ws(t,s){return a=>{t&&t(a),a.defaultPrevented||s(a)}}function Pv({page:t,...s}){let a=Dy(),{nonce:o}=Wi(),{router:l}=gc(),u=h.useMemo(()=>Ih(l.routes,t,l.basename),[l.routes,t,l.basename]);return u?(s.nonce==null&&o&&(s={...s,nonce:o}),a?h.createElement(_v,{page:t,matches:u,...s}):h.createElement(Lv,{page:t,matches:u,...s})):null}function $v(t){let{manifest:s,routeModules:a}=Wi(),[o,l]=h.useState([]);return h.useEffect(()=>{let u=!1;return Nv(t,s,a).then(f=>{u||l(f)}),()=>{u=!0}},[t,s,a]),o}function _v({page:t,matches:s,...a}){let o=Vt(),{future:l}=Wi(),{basename:u}=gc(),f=h.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let g=Gh(t,u,l.v8_trailingSlashAwareDataRequests,"rsc"),p=!1,v=[];for(let y of s)typeof y.route.shouldRevalidate=="function"?p=!0:v.push(y.route.id);return p&&v.length>0&&g.searchParams.set("_routes",v.join(",")),[g.pathname+g.search]},[u,l.v8_trailingSlashAwareDataRequests,t,o,s]);return h.createElement(h.Fragment,null,f.map(g=>h.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...a})))}function Lv({page:t,matches:s,...a}){let o=Vt(),{future:l,manifest:u,routeModules:f}=Wi(),{basename:g}=gc(),{loaderData:p,matches:v}=Av(),y=h.useMemo(()=>$f(t,s,v,u,o,"data"),[t,s,v,u,o]),x=h.useMemo(()=>$f(t,s,v,u,o,"assets"),[t,s,v,u,o]),j=h.useMemo(()=>{if(t===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(U=>U.route.id===T.route.id)&&T.route.id in p&&((I=f[T.route.id])!=null&&I.shouldRevalidate)||P.hasClientLoader?k=!0:S.add(T.route.id))}),S.size===0)return[];let E=Gh(t,g,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]},[g,l.v8_trailingSlashAwareDataRequests,p,o,u,y,s,t,f]),N=h.useMemo(()=>Cv(x,u),[x,u]),b=$v(x);return h.createElement(h.Fragment,null,j.map(S=>h.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...a})),N.map(S=>h.createElement("link",{key:S,rel:"modulepreload",href:S,...a})),b.map(({key:S,link:k})=>h.createElement("link",{key:S,nonce:a.nonce,...k,crossOrigin:k.crossOrigin??a.crossOrigin})))}function zv(...t){return s=>{t.forEach(a=>{typeof a=="function"?a(s):a!=null&&(a.current=s)})}}var Fv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Fv&&(window.__reactRouterVersion="7.18.4")}catch{}function Mv({basename:t,children:s,useTransitions:a,window:o}){let l=h.useRef();l.current==null&&(l.current=fy({window:o,v5Compat:!0}));let u=l.current,[f,g]=h.useState({action:u.action,location:u.location}),p=h.useCallback(v=>{a===!1?g(v):h.startTransition(()=>g(v))},[a]);return h.useLayoutEffect(()=>u.listen(p),[u,p]),h.createElement(fv,{basename:t,children:s,location:f.location,navigationType:f.action,navigator:u,useTransitions:a})}var ht=h.forwardRef(function({onClick:s,discover:a="render",prefetch:o="none",relative:l,reloadDocument:u,replace:f,mask:g,state:p,target:v,to:y,preventScrollReset:x,viewTransition:j,defaultShouldRevalidate:N,...b},S){let{basename:k,navigator:E,useTransitions:T}=h.useContext(Qt),P=typeof y=="string"&&lc.test(y),I=zh(y,k);y=I.to;let U=qy(y,{relative:l}),V=Vt(),F=null;if(g){let Y=Bi(g,[],V.mask?V.mask.pathname:"/",!0);k!=="/"&&(Y.pathname=Y.pathname==="/"?k:mn([k,Y.pathname])),F=E.createHref(Y)}let[J,Q,te]=Rv(o,b),ee=Dv(y,{replace:f,mask:g,state:p,target:v,preventScrollReset:x,relative:l,viewTransition:j,defaultShouldRevalidate:N,useTransitions:T});function z(Y){s&&s(Y),Y.defaultPrevented||ee(Y)}let oe=!(I.isExternal||u),ue=h.createElement("a",{...b,...te,href:(oe?F:void 0)||I.absoluteURL||U,onClick:oe?z:s,ref:zv(S,Q),target:v,"data-discover":!P&&a==="render"?"true":void 0});return J&&!P?h.createElement(h.Fragment,null,ue,h.createElement(Pv,{page:U})):ue});ht.displayName="Link";var vc=h.forwardRef(function({"aria-current":s="page",caseSensitive:a=!1,className:o="",end:l=!1,style:u,to:f,viewTransition:g,children:p,...v},y){let x=ra(f,{relative:v.relative}),j=Vt(),N=h.useContext(Di),{navigator:b,basename:S}=h.useContext(Qt),k=N!=null&&Gv(x)&&g===!0,E=b.encodeLocation?b.encodeLocation(x).pathname:x.pathname,T=j.pathname,P=N&&N.navigation&&N.navigation.location?N.navigation.location.pathname:null;a||(T=T.toLowerCase(),P=P?P.toLowerCase():null,E=E.toLowerCase()),P&&S&&(P=$n(P,S)||P);const I=E!=="/"&&E.endsWith("/")?E.length-1:E.length;let U=T===E||!l&&T.startsWith(E)&&T.charAt(I)==="/",V=P!=null&&(P===E||!l&&P.startsWith(E)&&P.charAt(E.length)==="/"),F={isActive:U,isPending:V,isTransitioning:k},J=U?s:void 0,Q;typeof o=="function"?Q=o(F):Q=[o,U?"active":null,V?"pending":null,k?"transitioning":null].filter(Boolean).join(" ");let te=typeof u=="function"?u(F):u;return h.createElement(ht,{...v,"aria-current":J,className:Q,ref:y,style:te,to:f,viewTransition:g},typeof p=="function"?p(F):p)});vc.displayName="NavLink";var Ov=h.forwardRef(({discover:t="render",fetcherKey:s,navigate:a,reloadDocument:o,replace:l,state:u,method:f=Si,action:g,onSubmit:p,relative:v,preventScrollReset:y,viewTransition:x,defaultShouldRevalidate:j,...N},b)=>{let{useTransitions:S}=h.useContext(Qt),k=Hv(),E=Vv(g,{relative:v}),T=f.toLowerCase()==="get"?"get":"post",P=typeof g=="string"&&lc.test(g),I=U=>{if(p&&p(U),U.defaultPrevented)return;U.preventDefault();let V=U.nativeEvent.submitter,F=(V==null?void 0:V.getAttribute("formmethod"))||f,J=()=>k(V||U.currentTarget,{fetcherKey:s,method:F,navigate:a,replace:l,state:u,relative:v,preventScrollReset:y,viewTransition:x,defaultShouldRevalidate:j});S&&a!==!1?h.startTransition(()=>J()):J()};return h.createElement("form",{ref:b,method:T,action:E,onSubmit:o?p:I,...N,"data-discover":!P&&t==="render"?"true":void 0})});Ov.displayName="Form";function Bv(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Kh(t){let s=h.useContext(ns);return ct(s,Bv(t)),s}function Dv(t,{target:s,replace:a,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:g,defaultShouldRevalidate:p,useTransitions:v}={}){let y=gn(),x=Vt(),j=ra(t,{relative:f});return h.useCallback(N=>{if(vv(N,s)){N.preventDefault();let b=a!==void 0?a:kr(x)===kr(j),S=()=>y(t,{replace:b,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:g,defaultShouldRevalidate:p});v?h.startTransition(()=>S()):S()}},[x,y,j,a,o,l,s,t,u,f,g,p,v])}function sa(t){an(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(ql(t)),a=h.useRef(!1),o=Vt(),l=h.useMemo(()=>xv(o.search,a.current?null:s.current),[o.search]),u=gn(),f=h.useCallback((g,p)=>{const v=ql(typeof g=="function"?g(new URLSearchParams(l)):g);a.current=!0,u("?"+v,p)},[u,l]);return[l,f]}var Uv=0,Wv=()=>`__${String(++Uv)}__`;function Hv(){let{router:t}=Kh("useSubmit"),{basename:s}=h.useContext(Qt),a=ov(),o=t.fetch,l=t.navigate;return h.useCallback(async(u,f={})=>{let{action:g,method:p,encType:v,formData:y,body:x}=Sv(u,s);if(f.navigate===!1){let j=f.fetcherKey||Wv();await o(j,a,f.action||g,{defaultShouldRevalidate:f.defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:x,formMethod:f.method||p,formEncType:f.encType||v,flushSync:f.flushSync})}else await l(f.action||g,{defaultShouldRevalidate:f.defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:x,formMethod:f.method||p,formEncType:f.encType||v,replace:f.replace,state:f.state,fromRouteId:a,flushSync:f.flushSync,viewTransition:f.viewTransition})},[o,l,s,a])}function Vv(t,{relative:s}={}){let{basename:a}=h.useContext(Qt),o=h.useContext(pn);ct(o,"useFormAction must be used inside a RouteContext");let[l]=o.matches.slice(-1),u={...ra(t||".",{relative:s})},f=Vt();if(t==null){u.search=f.search;let g=new URLSearchParams(u.search),p=g.getAll("index");if(p.some(y=>y==="")){g.delete("index"),p.filter(x=>x).forEach(x=>g.append("index",x));let y=g.toString();u.search=y?`?${y}`:""}}return(!t||t===".")&&l.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(u.pathname=u.pathname==="/"?a:mn([a,u.pathname])),kr(u)}function Gv(t,{relative:s}={}){let a=h.useContext(Oh);ct(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Kh("useViewTransitionState"),l=ra(t,{relative:s});if(!a.isTransitioning)return!1;let u=$n(a.currentLocation.pathname,o)||a.currentLocation.pathname,f=$n(a.nextLocation.pathname,o)||a.nextLocation.pathname;return Ci(l.pathname,f)!=null||Ci(l.pathname,u)!=null}var Kv=Eh();const jr="owner";function qv(t){const s=t||jr;return s===jr?[jr]:[s,jr]}function Yv(t){const s=new Map;for(const a of t)for(const o of a)s.has(o.id)||s.set(o.id,o);return[...s.values()].sort((a,o)=>o.createdAt-a.createdAt)}function Jv(t,s){const a=s||jr,o=(t==null?void 0:t.pendingDomains)??[];return o.includes(a)?a:o.includes(jr)?jr:a}class qh extends Error{constructor(a){super("different_account");Ds(this,"summary");this.name="DifferentAccountError",this.summary=a}}function Yh(t){return t.grantors??t.approvers}function Qv(t){return t.approvals??1}function Ve(t,s){const a=t??{},o=Array.isArray(a.errors)?a.errors[0]:void 0;return o!=null&&o.message?o.code?`${o.message} (${o.code})`:o.message:o!=null&&o.code?o.code:a.error||a.detail||s}function Xv(t){const s=t==null?void 0:t.pubkeys;return!s||typeof s!="object"||Array.isArray(s)?[]:Object.entries(s).filter(a=>typeof a[1]=="string"&&a[1].length>0).map(([a,o])=>({userId:a,publicKey:o}))}class Zv{constructor(){Ds(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 qh(u.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!o.ok){const u=await o.json().catch(()=>({error:"Invalid API key"}));throw new Error(Ve(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(Ve(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,g;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(p=>!(u.attestedDomains??[]).includes(p)),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(p=>p.expiresAt))*1e3).toISOString():null,remaining_seconds:(g=u.attestations)!=null&&g.length?Math.max(0,Math.min(...u.attestations.map(p=>p.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(s){const a=new URLSearchParams;s!=null&&s.since&&a.set("since",String(s.since)),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString()?`?${a.toString()}`:"",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(Ve(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 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(Ve(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(Ve(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(Ve(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(Ve(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(Ve(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(Ve(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(Ve(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(Ve(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(Ve(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(Ve(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(Ve(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(Ve(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(Ve(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 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:Ve(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:Ve(o,"AI request failed")}}return a.json()}async aiTest(s){const a=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`AI test failed: ${a.status}`);return a.json()}async aiModels(s){const a=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`Model list failed: ${a.status}`);return a.json()}async getMcpHealth(){const s=await this.fetch("/mcp/health");if(!s.ok)throw new Error(`MCP server unreachable: ${s.status}`);return s.json()}async getAgentContact(){const s=await this.fetch("/mcp/agent-contact");if(!s.ok)throw new Error(`Failed to fetch agent contact: ${s.status}`);return s.json()}async getMcpIntegrations(){const s=await this.fetch("/mcp/integrations");if(!s.ok)throw new Error(`Failed to fetch integrations: ${s.status}`);return s.json()}async getOAuthHealth(s){try{const a=await this.fetch(`/auth/oauth/${encodeURIComponent(s)}/health`);return a.ok?await a.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const s=await this.fetch("/mcp/integrations/manifests");if(!s.ok)throw new Error(`Failed to fetch manifests: ${s.status}`);return s.json()}async discoverScopeField(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/discover/${encodeURIComponent(a)}`);if(!o.ok){const l=await o.json().catch(()=>({error:`Discovery failed: ${o.status}`}));throw new Error(Ve(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(Ve(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(Ve(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(Ve(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(Ve(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?Xv(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(Ve(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(qv(s).map(l=>this.getProposals(l,a)));return Yv(o)}async resolveProposal(s,a,o,l){const{noteEncrypted:u,contentHash:f,shownHash:g,note:p,...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}:p?{note:p}:{},...f?{content_hash:f}:{},...g?{shown_hash:g}:{}})});if(!y.ok){const x=await y.json().catch(()=>({error:"Failed"}));throw new Error(Ve(x,`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(Ve(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(Ve(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:g,note:p,...v}=a??{};u={...v,...g?{note_encrypted:g}:p?{note:p}:{}}}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 g=await f.json().catch(()=>({error:"Failed"}));throw new Error(Ve(g,`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??{},g={...u?{note_encrypted:u}:f?{note:f}:{}};o&&(g.content_hash=o),l&&(g.shown_hash=l);const p=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/withdraw`,{method:"POST",body:JSON.stringify(g)});if(!p.ok){const v=await p.json().catch(()=>({error:"Failed"}));throw new Error(Ve(v,`withdrawProposal failed: ${p.status}`))}return p.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 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(Ve(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(Ve(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(Ve(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(Ve(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 g,p;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:(g=l.mandates)!=null&&g.length?new Date(Math.min(...l.mandates.map(v=>v.expiresAt))*1e3).toISOString():null,remaining_seconds:(p=l.mandates)!=null&&p.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=[],g=new Date;for(let v=0;v<a;v++){const y=new Date(g);y.setUTCDate(g.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(Ve(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(Ve(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:Ve(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(Ve(l,`Save failed: ${o.status}`))}}}const M=new Zv,Jh=h.createContext(null);function ex({children:t}){const[s,a]=h.useState(null),[o,l]=h.useState("personal"),[u,f]=h.useState(null),[g,p]=h.useState(""),[v,y]=h.useState(null),[x,j]=h.useState(null),[N,b]=h.useState(null),[S,k]=h.useState(!1),[E,T]=h.useState(""),P=h.useRef(!1),I=h.useRef(null),U=h.useCallback(async()=>{if(P.current)try{const ee=await M.getMyTeam();if(b(ee.pendingRequest),ee.group&&ee.membership){const{group:z,membership:oe}=ee;y(z),j(oe),l("team"),f(z);const ue=I.current??oe.domains[0]??"owner";p(ue)}else y(null),j(null),l("personal")}catch{}},[]);h.useEffect(()=>{const ee=()=>{document.visibilityState==="visible"&&U()};return document.addEventListener("visibilitychange",ee),()=>document.removeEventListener("visibilitychange",ee)},[U]),h.useEffect(()=>{fetch("/health").then(ee=>ee.json()).then(ee=>{var z;((z=ee.session)==null?void 0:z.lockedReason)==="as-url-changed"&&T(`Authority Server changed to ${ee.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const V=h.useCallback(async(ee,z={})=>{k(!0),T("");try{M.setApiKey(ee),P.current=!0;const oe=await M.login(ee,z);a(oe),I.current=oe.id;const ue=await M.getGroups(),Y=ue.find(je=>je.isPersonal)??ue[0]??null;f(Y),p("owner"),await U()}catch(oe){throw M.clearApiKey(),P.current=!1,T(oe instanceof Error?oe.message:"Login failed"),oe}finally{k(!1)}},[U]),F=h.useCallback(async()=>{await M.logout(),M.clearApiKey(),P.current=!1,I.current=null,a(null),f(null),p(""),y(null),j(null),b(null),l("personal"),T("")},[]),J=h.useCallback(ee=>{M.clearApiKey(),P.current=!1,I.current=null,a(null),f(null),p(""),y(null),j(null),b(null),l("personal"),T(ee??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),Q=h.useCallback(()=>T(""),[]),te=h.useCallback((ee,z)=>{f(ee),p(z)},[]);return n.jsx(Jh.Provider,{value:{user:s,mode:o,group:u,domain:g,groupId:(u==null?void 0:u.id)??null,activeTeam:v,activeMembership:x,pendingRequest:N,isLoading:S,error:E,login:V,logout:F,clearError:Q,handleSessionLocked:J,activeGroup:u,activeDomain:g,groups:u?[u]:[],setActiveContext:te,refreshGroups:U},children:t})}function yt(){const t=h.useContext(Jh);if(!t)throw new Error("useAuth must be used within AuthProvider");return t}const tx={"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},nx=Object.keys(tx),Qh=h.createContext(null);function rx({children:t}){const{user:s}=yt(),a=h.useRef(null),[o,l]=h.useState(!1),u=h.useRef(new Map),f=h.useCallback((g,p)=>{const v=u.current;return v.has(g)||v.set(g,new Set),v.get(g).add(p),()=>{var y;(y=v.get(g))==null||y.delete(p)}},[]);return h.useEffect(()=>{if(!s){a.current&&(a.current.close(),a.current=null,l(!1));return}if(a.current)return;const g=M.getApiKey();if(!g)return;const p=new EventSource(`/events?key=${encodeURIComponent(g)}`);a.current=p,p.onopen=()=>l(!0),p.onerror=()=>l(!1);for(const v of nx)p.addEventListener(v,y=>{let x;try{x=JSON.parse(y.data)}catch{x=null}const j=u.current.get(v);if(j)for(const N of j)try{N(x)}catch(b){console.error(`[EventSource] handler for "${v}" threw:`,b)}});return()=>{p.close(),a.current=null,l(!1)}},[s]),n.jsx(Qh.Provider,{value:{connected:o,addListener:f},children:t})}function Be(t,s){const a=h.useContext(Qh);if(!a)return;const{addListener:o}=a;h.useEffect(()=>o(t,s),[t,s,o])}const Js="suveren-theme",_f="hap-theme";function yi(t){return t!=="system"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(_f);s!==null&&localStorage.getItem(Js)===null&&localStorage.setItem(Js,s),s!==null&&localStorage.removeItem(_f)})();function Xh(){const[t,s]=h.useState(()=>{const u=localStorage.getItem(Js);return u==="light"||u==="dark"?u:"system"}),[a,o]=h.useState(()=>yi(t));h.useEffect(()=>{const u=document.documentElement,f=yi(t);u.setAttribute("data-theme",f),t==="system"?localStorage.removeItem(Js):localStorage.setItem(Js,t),o(yi(t))},[t]),h.useEffect(()=>{if(t!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),f=()=>o(yi("system"));return u.addEventListener("change",f),()=>u.removeEventListener("change",f)},[t]);const l=h.useCallback(()=>{s(u=>u==="system"?"light":u==="light"?"dark":"system")},[]);return{theme:t,effectiveTheme:a,toggle:l}}const sx=300*1e3,ax=2e3;function xc(){const[t,s]=h.useState(!1),[a,o]=h.useState("docker"),[l,u]=h.useState(""),[f,g]=h.useState(null),[p,v]=h.useState(!1),[y,x]=h.useState(!1),[j,N]=h.useState(!1),b=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"&&g(I.latestVersion),I.updateAvailable&&s(!0),I.version&&(u(I.version),b.current===null?b.current=I.version:I.version!==b.current&&I.version!=="dev"&&v(!0)))}).catch(()=>{})};k(!0);const E=setInterval(()=>k(!1),j?ax:sx),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)}},[j]),{updateAvailable:t&&!y,installMethod:a,version:l,latestVersion:f,serverRestarted:p,startFastPolling:()=>N(!0),dismiss:()=>x(!0)}}function ix(t){return!t||typeof t!="object"?{managed:!1}:{managed:Array.isArray(t.policyLocked)&&t.policyLocked.includes("team")}}function ox(){const[t,s]=h.useState({managed:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(ix(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function lx({size:t=20}){return n.jsxs("svg",{width:t,height:t,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 cx(t){return t?t==="dev"?"dev":/^[0-9a-f]{40}$/i.test(t)?t.slice(0,7):t:""}const Lf={system:"◑",light:"☀",dark:"☾"};function wc({onMenuToggle:t}){const{user:s,logout:a,mode:o,activeTeam:l}=yt(),{theme:u,toggle:f}=Xh(),{version:g,updateAvailable:p,latestVersion:v}=xc(),{managed:y}=ox(),x=cx(g),j=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(lx,{size:20}),n.jsx("span",{className:"logo",children:"Suveren"}),n.jsx("span",{className:"version-badge",children:"Local Gateway"}),x&&n.jsxs("span",{className:"gw-version",title:p&&v?`Running v${x} — v${v} is available`:"Running gateway version","data-stale":p?"true":void 0,children:["v",x,p&&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?`${j} — set by your IT`:j,children:[j,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:Lf[u]}),n.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):n.jsx("button",{className:"theme-toggle",onClick:f,title:`Theme: ${u}`,children:Lf[u]})}),s&&t&&n.jsx("button",{className:"mobile-menu-btn",onClick:t,"aria-label":"Menu",children:"☰"})]})})}function jc(t,s){var a;if((a=s==null?void 0:s.revokedSet)!=null&&a.has(t.authorization_id))return"revoked";switch(t.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return t.remaining_seconds===null||t.remaining_seconds<=0?"expired":t.missing_domains.length>0?"pending":"active"}function Zh(t){return t==="expired"||t==="revoked"}function em(t,s){var a;return!!((a=s==null?void 0:s.archivedSet)!=null&&a.has(t.authorization_id))&&Zh(jc(t,s))}function Ei(t,s){return em(t,s)?"archived":jc(t,s)}function tm(t,s){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of t)a[Ei(o,s)].push(o);return a}function ux(t,s){return s==="expired"?t.earliest_expiry?{iso:t.earliest_expiry,meaning:"expired"}:null:t.created_at?{iso:t.created_at,meaning:"created"}:null}function Lt(t,s,a){const o=h.useRef(t);o.current=t,h.useEffect(()=>{let l=null;const u=()=>typeof document>"u"?!0:document.visibilityState==="visible",f=()=>{u()&&o.current()},g=()=>{l===null&&(l=setInterval(f,s))},p=()=>{l!==null&&(clearInterval(l),l=null)},v=()=>{u()?(o.current(),g()):p()};return u()&&(o.current(),g()),document.addEventListener("visibilitychange",v),()=>{p(),document.removeEventListener("visibilitychange",v)}},[s,a])}function Sc(){const[t,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)}},[]),t}function dx(t,s){const a=t.simulation;return a?(((s==null?void 0:s[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function Zs(t){return!!(t!=null&&t.simulation)}const nm=h.createContext(null),fx=3e4,hx=5e3,mx=3e5;function px(t,s,a){return s===0?"loading":t!=null&&t.running?"running":t!=null&&t.paused?"paused":t!=null&&t.error?"error":t&&a?"starting":"not-running"}function gx({children:t}){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[x,j]=await Promise.all([M.getIntegrationManifests().catch(()=>(y=!0,{manifests:[]})),M.getMcpHealth().catch(()=>null)]);a(b=>({...b,manifests:x.manifests,integrations:(j==null?void 0:j.integrations)??b.integrations,activeSessions:(j==null?void 0:j.activeSessions)??b.activeSessions,mcpServerUp:!!j,manifestsError:y,fetchCount:b.fetchCount+1}));const N=x.manifests.filter(b=>b.oauth);if(N.length>0){const b=await Promise.all(N.map(async S=>[S.id,await M.getOAuthHealth(S.id)]));a(S=>({...S,authHealth:Object.fromEntries(b)}))}},[]),u=s.fetchCount>0&&s.manifests.some(y=>{const x=s.integrations.find(j=>j.id===y.id);return x&&!x.running&&!x.paused});Be("integration-changed",l),Lt(l,u?hx:mx);const f=h.useMemo(()=>{const y=new Map(s.integrations.map(N=>[N.id,N])),x=Date.now();u&&o.current===null?o.current=x:u||(o.current=null);const j=o.current!==null&&x-o.current<fx;return s.manifests.map(N=>{const b=y.get(N.id),S=px(b,s.fetchCount,j),k=s.authHealth[N.id];return{id:N.id,manifest:N,integration:b,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]),g=Sc(),p=h.useMemo(()=>f.filter(y=>!(g&&!Zs(y.manifest))&&(y.state==="not-running"||y.state==="error"||y.authStatus==="failed")).length,[f,g]),v={loading:s.fetchCount===0,mcpServerUp:s.mcpServerUp,manifestsError:s.manifestsError,entries:f,attentionCount:p,activeSessions:s.activeSessions,refresh:l};return n.jsx(nm.Provider,{value:v,children:t})}function bc(){const t=h.useContext(nm);if(!t)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return t}const yx={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},kc=t=>yx[t]??t,vx={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 xx(t){return(t&&vx[t])??{chip:"Blocked",sev:"info"}}function wx(t){const s=kc(t.integrationId);switch(t.reason){case"resource":return t.integrationId==="calendar"?n.jsxs(n.Fragment,{children:["Tried to read your ",n.jsx("b",{children:t.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:t.detail})}}function rm(t,s){const a=Math.max(0,(s-t)/1e3);if(a<60)return"Just now";if(a<3600)return`${Math.floor(a/60)} min ago`;if(a<86400)return`${Math.floor(a/3600)} hr ago`;const o=Math.floor(a/86400);return o===1?"Yesterday":`${o} days ago`}const jx=5,Sx=1440*60*1e3,Yl=7;function bx(t,s){const a=s-Yl*Sx;return{recent:t.filter(o=>o.ts>=a),all:t}}function kx(){const[t,s]=h.useState(null),[a,o]=h.useState(!1),l=h.useCallback(()=>{M.getDenials({limit:200}).then(({records:v})=>{s(v),o(!1)}).catch(()=>o(!0))},[]);if(h.useEffect(()=>{l()},[l]),Lt(l,12e4),a||t===null)return null;const{recent:u,all:f}=bx(t,Date.now()),g=u.slice(0,jx),p=(v,y)=>{const x=xx(v.reason);return n.jsxs("div",{className:"rb-row",children:[n.jsx("span",{className:`rb-dot ${x.sev==="act"?"act":x.sev==="info"?"info":""}`,"aria-hidden":"true"}),n.jsxs("div",{className:"rb-body",children:[n.jsx("div",{className:"rb-line",children:wx(v)}),n.jsxs("div",{className:"rb-meta",children:[n.jsx("span",{className:`rb-chip ${x.sev==="act"?"act":x.sev==="warn"?"warn":""}`,children:x.chip}),n.jsx("span",{className:"rb-via",children:kc(v.integrationId)})]}),x.fixTo&&n.jsx(ht,{className:"rb-fix",to:x.fixTo,children:"Set a read window →"})]}),n.jsx("div",{className:"rb-when",children:rm(v.ts,Date.now())})]},`${v.ts}-${y}`)};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"}),u.length>0&&n.jsx("span",{className:"rb-count",children:u.length})]}),g.length===0?n.jsxs("div",{className:"rb-empty",children:[n.jsx("span",{className:"rb-mark","aria-hidden":"true",children:n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M20 6 9 17l-5-5"})})}),n.jsxs("h3",{children:["Nothing blocked in the last ",Yl," days"]}),n.jsx("p",{children:"Your agent has stayed within every limit you set."}),f.length>0&&n.jsxs(ht,{className:"col-btn",to:"/blocked",children:["View all ",f.length," blocks from the last 30 days ›"]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"rb-sub",children:[`Last ${Yl} days. `,"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."]}),n.jsx("div",{className:"rb-rows",children:g.map(p)}),n.jsxs(ht,{className:"col-btn",to:"/blocked",children:["View all ",f.length," blocks from the last 30 days ›"]})]})]})}function Hi(t){return t.kind??"read"}function Nx(t,s){var u,f,g,p;if(!s)return"";if(!t)return s;const a=(f=(u=t.scopeSchema)==null?void 0:u.fields)==null?void 0:f[s];if(a!=null&&a.displayName)return a.displayName;const o=((g=t.boundsSchema)==null?void 0:g.fields)??{};if((p=o[s])!=null&&p.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 Cx={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"},Ex={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 zf(t){return t===void 0?"":typeof t=="number"?t.toLocaleString():t}function Tx(t,s){const a=Hi(t),o=zf(t.value),l=zf(t.limit);switch(a){case"bound":return o&&l?`${s||"Value"} ${o} is above the limit ${l}.`:t.detail;case"scope":return o?`${s||"Value"} "${o}" is not within your mandate's allowed ${s||"scope"}.`:t.detail;case"cumulative":return o&&l?`${o} of ${l} used — the limit is reached.`:t.detail;case"simulation":return"Real systems are switched off while the gateway runs in simulation mode.";case"not_authorized":return"No mandate currently covers this action.";case"read":default:return t.detail}}function Ix(t,s){if(t.mandateId){const a=s==null?void 0:s[t.mandateId];if(a)return a}return t.mandateTitle}function Ax(t,s){const a=Ix(t,s);if(a){const o=[{text:` · mandate "${a}"`}];return t.mandateId&&o.push({text:` (${t.mandateId.slice(0,14)}…)`,dim:!0}),o}return t.mandateId?[{text:` · mandate ${t.mandateId.slice(0,14)}…`}]:[]}function Rx(t,s){const a=Hi(t),o=kc(t.integrationId),l=t.who==="authority-server"?"refused by the Authority Server":a==="read"?"refused by this gateway":"refused by this gateway, before anything ran",u=t.code?` (${t.code})`:"";return[{text:`${o} · ${t.tool}`},...Ax(t,s),{text:` · ${l}${u}`}]}function Px(t,s,a){const o=Hi(t),l=Nx(s,t.field);return{title:Cx[o],sentence:Tx(t,l),sourceLine:Rx(t,a),whatYouCanDo:Ex[o]}}function $x(t,s){const a=new Date(s);return a.setHours(0,0,0,0),t.filter(o=>o.ts>=a.getTime()).length}function _x(t,s){return t.filter(a=>a.ts>s).length}const Lx=1440*60*1e3;function zx(t,s){const a=new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),o=new Date(s);o.setHours(0,0,0,0);const l=o.getTime();return t>=l?`Today · ${a}`:t>=l-Lx?`Yesterday · ${a}`:`${new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})} · ${a}`}const Fx=[{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"},{to:"/tickets",icon:"▣",iconClass:"nav-ic-ticket",label:"Tickets",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:"/reports",icon:"▥",label:"Reports",group:"setup"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant",group:"setup"}];function Mx(){const{activeDomain:t}=yt(),[s,a]=h.useState({}),o=h.useCallback(async()=>{try{const[l,u,f,g,p,v,y,x]=await Promise.all([M.getCredential("ai-config").catch(()=>null),M.getMyAttestations().catch(()=>null),M.getMyProposals(t).catch(()=>null),M.getProposalsForApprover().catch(()=>null),M.getAgentContext().catch(()=>""),M.getArchivedMandates().catch(()=>[]),M.getDenials({limit:200}).catch(()=>null),M.getLastSeenBlockedAt().catch(()=>0)]),j={};if(l&&!l.configured&&(j.assistant=1),u){const k=tm(u,{archivedSet:new Set(v)}).expired.length;k>0&&(j.authorizations=k)}const N=(f==null?void 0:f.length)??0,b=(g==null?void 0:g.length)??0,S=N+b;if(S>0&&(j.proposals=S),(!p||!p.trim())&&(j.brief=1),y){const k=_x(y.records,x);k>0&&(j.blocked=k)}a(j)}catch{}},[t]);return Be("attestation-changed",o),Be("proposal-added",o),Be("proposal-resolved",o),Be("proposal-approved",o),Be("proposal-rejected",o),Be("team-membership-changed",o),Be("denial-recorded",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.removeEventListener("suveren:blocked-seen-changed",o)),[o]),Lt(o,3e5,t),s}const Ox={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},Bx={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 Dx(){const{mode:t,group:s,domain:a,activeTeam:o}=yt(),l=Mx(),{attentionCount:u}=bc(),f={...l};u>0&&(f.integrations=u);const g=Fx.filter(j=>!j.teamOnly||t==="team"),p=h.useRef(null),[v,y]=h.useState(null),x=Vt();return h.useEffect(()=>{if(p.current===null){p.current=t;return}p.current!==t&&(t==="team"&&o?y(`You are now acting in team context — ${o.name}`):t==="personal"&&y("You have left the team — back to personal context"),p.current=t)},[t,o]),h.useEffect(()=>{y(null)},[x.pathname]),n.jsxs("div",{className:"sidebar",children:[["top","core","setup"].map(j=>{const N=g.filter(b=>(b.group??"setup")===j);return N.length===0?null:n.jsxs("div",{className:`sidebar-${j}`,children:[j==="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:N.map(b=>{const S=b.statusKey?f[b.statusKey]:0;return n.jsx("li",{children:n.jsxs(vc,{to:b.to,end:b.to==="/",className:({isActive:k})=>`sidebar-item${k?" active":""}`,children:[n.jsx("span",{className:"icon",children:b.iconClass?n.jsx("span",{className:`nav-ic ${b.iconClass}`,"aria-hidden":"true"}):b.icon}),b.label,S?n.jsx("span",{style:Ox,children:S}):null]})},b.to)})})]},j)}),n.jsxs("div",{className:"sidebar-context",children:[n.jsx("div",{className:"ctx-label",children:"Active context"}),n.jsx("div",{className:"ctx-value",children:t==="personal"?"personal":s?`${s.name} / ${a}`:a})]}),v&&n.jsx("div",{style:Bx,role:"status","aria-live":"polite",children:v})]})}const Ml="suveren:updatedTo";function Ux(t){return t==="managed"||t==="msi"?null:t==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":t==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}const Wx="Updates for this gateway come from your company's IT — no action needed here.";function Hx(t){return t==="managed"?"update-banner is-managed":"update-banner"}const Vx="Download the new installer and run it. Your settings and mandates stay.";function Gx(t){const s="https://github.com/suverenai/suveren-gateway/releases";return t?`${s}/tag/v${t}`:`${s}/latest`}function Kx(){const t=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const a of t)if(!a.closest(".update-overlay"))return!0;const s=document.activeElement;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)){const a=s.value;if(a&&a.trim())return!0}return!1}function sm(){const{updateAvailable:t,installMethod:s,version:a,latestVersion:o,serverRestarted:l,startFastPolling:u,dismiss:f}=xc(),[g,p]=h.useState(!1),[v,y]=h.useState(!1),[x,j]=h.useState(()=>{try{const P=sessionStorage.getItem(Ml);if(P)return sessionStorage.removeItem(Ml),P}catch{}return null}),N=Ux(s),b=h.useRef(null),S=P=>{try{sessionStorage.setItem(Ml,P||o||"✓")}catch{}window.location.reload()};h.useEffect(()=>{if(!x)return;const P=setTimeout(()=>j(null),6e3);return()=>clearTimeout(P)},[x]),h.useEffect(()=>{if(!g||!l)return;const P=()=>Kx()?!1:(S(a),!0);if(P())return;const I=setInterval(P,1500);return()=>clearInterval(I)},[g,l,a]),h.useEffect(()=>(document.body.classList.toggle("is-updating",g),()=>document.body.classList.remove("is-updating")),[g]);const k=t&&!g&&!x||!!x&&!g;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 V;const U=((V=b.current)==null?void 0:V.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${U}px`)};P();const I=new ResizeObserver(P);return b.current&&I.observe(b.current),()=>{I.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[k]);const E=()=>{p(!0),u()},T=async()=>{if(N)try{await navigator.clipboard.writeText(N),y(!0),setTimeout(()=>y(!1),1800)}catch{}};return n.jsxs(n.Fragment,{children:[x&&!g&&n.jsx("div",{ref:b,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",x&&x!=="✓"?` — ${x} is live`:" — now live","."]}),n.jsx("button",{className:"update-banner-x",onClick:()=>j(null),"aria-label":"Dismiss",children:"×"})]})}),t&&!g&&!x&&n.jsxs("div",{ref:b,className:Hx(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:Gx(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:Wx}),s==="msi"&&n.jsx("p",{className:"update-banner-hint",children:Vx})]}),g&&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:N}),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:()=>p(!1),children:"Cancel"})]})]})})]})}function am(){const t=Sc(),s=h.useRef(null);return h.useEffect(()=>{if(!t){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")}},[t]),t?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 qx={system:"◑",light:"☀",dark:"☾"},Yx=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/blocked",icon:"⊘",label:"Blocked"},{to:"/team",icon:"◉",label:"Team"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/settings",icon:"⚙",label:"Settings"}];function Jx({open:t,onClose:s}){const{user:a,activeGroup:o,activeDomain:l,logout:u}=yt(),{theme:f,toggle:g}=Xh(),p=Vt();return h.useEffect(()=>{s()},[p.pathname]),t?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:Yx.map(v=>n.jsxs(vc,{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:()=>{g()},children:[n.jsx("span",{className:"icon",children:qx[f]}),"Theme: ",f]}),n.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),s()},children:"Logout"})]})]})]}):null}function im(t){return t.status==="pending"}function Qx(t,s){return t.filter(im).length+s.length}const xr=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],Xx=500;function om(){const{user:t,domain:s}=yt(),[a,o]=h.useState(0),l=h.useRef(null),u=h.useCallback(async()=>{if(!t){o(0);return}try{const[g,p]=await Promise.all([M.getMyProposals(s).catch(()=>[]),M.getProposalsForApprover().catch(()=>[])]);o(Qx(g,p))}catch{o(0)}},[t,s]),f=h.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{u()},Xx)},[u]);return h.useEffect(()=>(u(),()=>{l.current&&clearTimeout(l.current)}),[u]),Be(xr[0],f),Be(xr[1],f),Be(xr[2],f),Be(xr[3],f),Be(xr[4],f),Be(xr[5],f),Be(xr[6],f),a}const Ff="Suveren",Zx="/favicon.svg",e0="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",vi={x1:74.54,y1:22.74,x2:94.46,y2:34.24},t0=14,n0="#f59e0b";function r0(t){const s=Nc(t);return s>0?`(${s}) ${Ff}`:Ff}function Nc(t){return Number.isFinite(t)&&t>0?Math.floor(t):0}function s0(){const t=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
52
|
-
<path class="m" d="${e0}"/>
|
|
53
|
-
<line class="m" x1="${vi.x1}" y1="${vi.y1}" x2="${vi.x2}" y2="${vi.y2}"/>
|
|
54
|
-
<circle cx="103" cy="103" r="25" fill="${n0}"/>
|
|
55
|
-
<style>.m{stroke:#111111;stroke-width:${t0};fill:none;stroke-linecap:round}@media (prefers-color-scheme:dark){.m{stroke:#ffffff;stroke-width:13.3}}</style>
|
|
56
|
-
</svg>`;return`data:image/svg+xml,${encodeURIComponent(t)}`}function a0(){return document.querySelector('link[rel="icon"]')}function lm(t){const s=Nc(t);document.title=r0(s),cm(s);const a=a0();if(!a)return;const o=s>0?s0():Zx;a.getAttribute("href")!==o&&a.setAttribute("href",o)}function i0(){lm(0)}function cm(t,s=globalThis.navigator){var l;if(!s||typeof s.setAppBadge!="function")return;const a=Nc(t),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 o0(){const t=om();return h.useEffect(()=>{lm(t)},[t]),h.useEffect(()=>i0,[]),null}const um="suveren:dockBadgePrompt";function l0(){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(um))return!1}catch{}return!0}function c0(){const[t,s]=h.useState(!1),a=om();if(h.useEffect(()=>{s(l0())},[]),!t)return null;const o=()=>{try{localStorage.setItem(um,"1")}catch{}s(!1)},l=async()=>{try{await Notification.requestPermission()==="granted"&&cm(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 u0(){const[t,s]=h.useState(!1);return n.jsxs(gx,{children:[n.jsx(o0,{}),n.jsx(wc,{onMenuToggle:()=>s(!t)}),n.jsx(sm,{}),n.jsx(am,{}),n.jsx(Dx,{}),n.jsx(Jx,{open:t,onClose:()=>s(!1)}),n.jsx("div",{className:"main-content",children:n.jsxs("div",{className:"page-inner",children:[n.jsx(c0,{}),n.jsx(dv,{})]})})]})}function dm({what:t}){return n.jsxs("div",{className:"human-only-note",role:"note",children:[n.jsx("strong",{children:"Only you."})," ",t==="sign-in"?"Never let an AI or a browser it controls sign in here or see this key.":"Approve only yourself. Never let an AI or a browser it controls open this page or approve for you."]})}function Cc(){return typeof navigator<"u"&&navigator.webdriver===!0}const Ec="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function d0(){const[t,s]=h.useState(""),{login:a,isLoading:o,error:l,clearError:u}=yt(),[f,g]=h.useState(null),p=Cc(),v=async()=>{if(!(!t.trim()||p)){u();try{await a(t)}catch(j){if(j instanceof qh){g(j.summary);return}}}},y=async()=>{g(null),u();try{await a(t,{confirmWipe:!0})}catch{}},x=()=>{g(null)};return n.jsxs(n.Fragment,{children:[n.jsx(wc,{}),n.jsx(sm,{}),n.jsx(am,{}),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(dm,{what:"sign-in"}),p&&n.jsx("div",{className:"error-message",children:Ec}),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:t,onChange:j=>s(j.target.value),onKeyDown:j=>j.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||p,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((j,N)=>n.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:N<2?"0.5rem":0},children:[n.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[N+1,"."]}),j]},N))})]})]})})]}),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:x,children:n.jsxs("div",{className:"card",onClick:j=>j.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:x,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 f0(t,s){return!s&&t!=null}function h0(t,s){return t==="join-waiting"&&s==="team"}function m0(t,s,a,o){return a!=null||t!=="join-waiting"||s==="team"?null:o}function p0(t){return`${t} personal mandate${t===1?"":"s"}`}function g0({mandates:t,pendingProposals:s}){return t.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:t.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 y0(){const{mode:t,pendingRequest:s,refreshGroups:a}=yt(),o=gn(),[l,u]=h.useState("choose"),[f,g]=h.useState(""),[p,v]=h.useState(""),[y,x]=h.useState(null),[j,N]=h.useState(null),[b,S]=h.useState(""),[k,E]=h.useState(""),[T,P]=h.useState(!1),I=h.useRef(!1);h.useEffect(()=>{f0(s,I.current)&&(I.current=!0,u("join-waiting"))},[s]),h.useEffect(()=>{h0(l,t)&&o("/")},[l,t,o]);const U=h.useRef(null);h.useEffect(()=>{if(s){U.current=s.groupName;return}const z=m0(l,t,s,U.current);z&&(S(z),u("join-declined"),U.current=null)},[s,l,t]),h.useEffect(()=>{if(l!=="join-waiting")return;const z=setInterval(()=>{a()},5e3);return()=>clearInterval(z)},[l,a]);const V=h.useCallback(()=>{u("choose"),E(""),x(null),N(null),g(""),v("")},[]),F=async()=>{if(f.trim()){P(!0),E("");try{const z=await M.getJoinPreview(f.trim());x(z),u("join-preview")}catch(z){E(z instanceof Error?z.message:"Invalid or expired invite code")}finally{P(!1)}}},J=async()=>{P(!0),E("");try{await M.requestToJoinGroup(f.trim()),await a(),u("join-waiting")}catch(z){E(z instanceof Error?z.message:"Failed to join group")}finally{P(!1)}},Q=async()=>{P(!0),E("");try{await M.withdrawJoinRequest(),await a(),V()}catch(z){E(z instanceof Error?z.message:"Failed to withdraw request")}finally{P(!1)}},te=async()=>{u("create"),E(""),P(!0);try{const z=await M.getCreatePreview();N(z)}catch(z){E(z instanceof Error?z.message:"Failed to load preview")}finally{P(!1)}},ee=async()=>{if(p.trim()){P(!0),E("");try{await M.createGroup(p.trim()),await a(),o("/")}catch(z){E(z instanceof Error?z.message:"Failed to create group")}finally{P(!1)}}};return n.jsxs(n.Fragment,{children:[n.jsx(wc,{}),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:z=>g(z.target.value),onKeyDown:z=>z.key==="Enter"&&F(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:T}),n.jsx("button",{className:"btn btn-primary",onClick:F,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:te,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(g0,{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:J,disabled:T,children:T?"Asking…":"Ask to join"}),n.jsx("button",{className:"btn btn-ghost",onClick:V,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:Q,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 ",b," 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:V,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:p,onChange:z=>v(z.target.value),onKeyDown:z=>z.key==="Enter"&&ee(),disabled:T,autoFocus:!0})]}),j&&n.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",p0(j.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:ee,disabled:T||!p.trim(),children:T?"Creating…":"Create team and move my account"}),n.jsx("button",{className:"btn btn-ghost",onClick:V,disabled:T,children:"Cancel"})]})]})]})})]})}const Mf={"claude-code":{label:"Claude Code",snippet:t=>`claude mcp add --transport http suveren ${t}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:t=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json, then restart Claude Desktop:
|
|
57
|
-
|
|
58
|
-
${JSON.stringify({mcpServers:{suveren:{command:"npx",args:["mcp-remote@latest",`${t}/mcp`,"--allow-http"]}}},null,2)}`},"chatgpt-codex":{label:"ChatGPT / Codex",snippet:t=>`Add to ~/.codex/config.toml:
|
|
59
|
-
|
|
60
|
-
[mcp_servers.suveren]
|
|
61
|
-
url = "${t}/mcp"
|
|
62
|
-
|
|
63
|
-
Or: codex mcp add suveren --url ${t}/mcp`},other:{label:"Other",snippet:t=>`Streamable HTTP: POST ${t}/mcp
|
|
64
|
-
SSE transport: GET ${t}/sse
|
|
65
|
-
Health check: GET ${t}/health`}},Of=["claude-code","claude-desktop","chatgpt-codex","other"];function Jl({mcpEndpoint:t}){const[s,a]=h.useState(Of[0]),[o,l]=h.useState(!1),u=h.useCallback(async g=>{try{await navigator.clipboard.writeText(g),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},[]),f=Mf[s].snippet(t);return n.jsxs("div",{children:[n.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),n.jsx("div",{className:"mcp-endpoint",children:t}),n.jsx("div",{className:"mcp-tabs",children:Of.map(g=>n.jsx("button",{className:`mcp-tab${s===g?" active":""}`,onClick:()=>a(g),children:Mf[g].label},g))}),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 Ql="suveren-setup-ai-skipped",Xl="suveren-setup-agent-done",Zl="suveren-setup-dismissed",v0={"hap-setup-ai-skipped":Ql,"hap-setup-agent-done":Xl,"hap-setup-dismissed":Zl};function x0(){for(const[t,s]of Object.entries(v0)){const a=localStorage.getItem(t);a!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,a),a!==null&&localStorage.removeItem(t)}}x0();function w0({aiConfigured:t,hasRunningIntegration:s,hasActiveAuth:a,hasAgentConnected:o,mcpEndpoint:l}){const[u,f]=h.useState(()=>localStorage.getItem(Ql)==="true"),[g,p]=h.useState(()=>localStorage.getItem(Xl)==="true"),[v,y]=h.useState(()=>localStorage.getItem(Zl)==="true"),[x,j]=h.useState(null),N=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:t?"done":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||g?"done":"pending"}],b=N.filter(I=>I.status==="done"||I.status==="skipped").length,S=b===N.length,k=h.useCallback(()=>{localStorage.setItem(Ql,"true"),f(!0)},[]),E=h.useCallback(()=>{localStorage.setItem(Xl,"true"),p(!0),j(null)},[]),T=h.useCallback(()=>{localStorage.setItem(Zl,"true"),y(!0)},[]);if(v||S)return null;const P=N.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:N.map((I,U)=>{const V=U===P,F=I.status==="done"||I.status==="skipped"?"●":"○",J=I.status==="done"?"var(--text-primary)":I.status==="skipped"?"var(--text-tertiary)":V?"var(--accent)":"var(--text-tertiary)";return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:V?"0.75rem":"0.25rem 0",borderRadius:V?"0.5rem":void 0,background:V?"var(--accent-subtle)":void 0},children:[n.jsx("span",{style:{color:J,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:F}),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(ht,{to:I.to,style:{fontSize:"0.9rem",fontWeight:V?600:500,color:V?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:I.label}):I.status==="pending"&&U===3?n.jsx("button",{onClick:()=>j(x===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:V?600:500,color:V?"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"&&V&&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(ht,{to:I.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),U===3&&x===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(Jl,{mcpEndpoint:l}),n.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:E,children:"Done"})]})]},U)})}),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:`${b/N.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:[b," of ",N.length," complete"]})]})]})}function fm(t,s=null){const a=[t.hasContact,t.hasDelegationMandate,t.delegationProposalCount>0],o=a.every(Boolean),l=t.otherMandateCount===0&&!o,u=a.findIndex(v=>!v),f=s!==null&&a[s]===!1?s:u,g=t.managed?"managed":"self",p=v=>a[v]?{status:"done"}:v!==f?{status:"todo"}:v===1?{status:"open",variant:g,simulationOn:t.simulationOn}:v===0?{status:"open",variant:g}:{status:"open"};return{visible:l,step1:p(0),step2:p(1),step3:p(2)}}const j0="/mandates?new=1&profile=delegation";function Bf({text:t}){const[s,a]=h.useState(!1),o=h.useCallback(async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t]);return n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:o,children:s?"Copied":"Copy"})}function Ol({todo:t,onOpen:s,children:a}){return t?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 S0({contact:t,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u,mcpEndpoint:f}){const g={hasContact:t!==null,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u},[p,v]=h.useState(null),y=fm(g,p);if(!y.visible)return null;const x=`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"&&t?n.jsxs("span",{className:"flow-step-title flow-done-title",children:[t.clientName," connected · last contact ",rm(Date.parse(t.lastSeenAt),Date.now()).toLowerCase()]}):n.jsx(Ol,{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(Jl,{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:x}),n.jsx(Bf,{text:x})]})}),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(Jl,{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(ht,{to:"/mandates",children:"review or revoke under Mandates"})]}):n.jsx(Ol,{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(ht,{to:j0,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(Ol,{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(Bf,{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(ht,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function b0(){const[t,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}},[]),t}function k0(t){if(!t||typeof t!="object")return{simulation:null,locked:!1};const s=Array.isArray(t.policyLocked)&&t.policyLocked.includes("simulation");return{simulation:typeof t.simulation=="boolean"?t.simulation:null,locked:s}}function hm(){const[t,s]=h.useState({simulation:null,locked:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(k0(o))}).catch(()=>{}),()=>{a=!0}},[]),t}function N0(t){return!t||typeof t!="object"?!1:Array.isArray(t.policyLocked)&&t.policyLocked.length>0}function C0(){const[t,s]=h.useState(!1);return h.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(f=>f.json()).then(f=>{a||s(N0(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)}},[]),t}function Xr({variant:t="base",style:s,className:a,...o}){const l=t==="title"?"skeleton skeleton-title":t==="line"?"skeleton skeleton-line":t==="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"})}function Bl(){return n.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[n.jsx(Xr,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[n.jsx(Xr,{variant:"line",style:{width:"35%"}}),n.jsx(Xr,{variant:"line-sm",style:{width:"65%"}})]})]})}const Df=new Map;function mm(t){let s=Df.get(t);return s||(s=(async()=>{try{let a=t;if(!t.includes("@")){const o=await M.listProfiles(),l=f=>f.replace(/@.*$/,"").split("/").pop(),u=o.filter(f=>l(f.id)===t).sort((f,g)=>(g.id.split("@")[1]??"").localeCompare(f.id.split("@")[1]??"",void 0,{numeric:!0}));if(!u[0])return null;a=u[0].id}return await M.getProfile(a)}catch{return null}})(),Df.set(t,s)),s}function ss(t){const[s,a]=h.useState(null);return h.useEffect(()=>{let o=!0;return t&&mm(t).then(l=>{o&&a(l)}),()=>{o=!1}},[t]),s}const Uf=40,E0={delegation:"Delegation"};function lt(t,s){const a=t.lastIndexOf("/"),o=a>=0?t.slice(a+1):t,l=o.indexOf("@"),u=l>=0?o.slice(0,l):o,f=E0[u.toLowerCase()];return f||(s?s.slice(0,Uf):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,Uf))}function Vi(t){return!t||t==="count"?"":t==="minutes"?"min":t==="hours"?"hr":t==="days"?"days":t==="percent"?"%":t.startsWith("currency:")?t.slice(9):t}const T0=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function Ht(t){const s=t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)}function as(t){const s=t.indexOf("__");return s<0?{integrationId:"",toolName:t}:{integrationId:t.slice(0,s),toolName:t.slice(s+2)}}function I0(t){const{integrationId:s,toolName:a}=as(t);return s?`${s} · ${a}`:a}function aa(t,s){const a=s==null?void 0:s.find(o=>o.id===t);return a!=null&&a.name?a.name:t?t.toUpperCase():"the system"}function A0(t){return Array.isArray(t)?"list":t&&typeof t=="object"?"object":typeof t=="string"&&(t.includes(`
|
|
66
|
-
`)||t.length>120)?"markdown":"text"}function R0(t,s){var f,g;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(t)])],u=[];for(const p of l){if(!(p in t)||T0.has(p))continue;const v=t[p],y=a[p]??{},x=y.kind??A0(v),j={key:p,label:y.label??Ht(p),kind:x,value:v,hint:(g=o[p])==null?void 0:g.description};x==="money"&&y.currencyArg&&typeof t[y.currencyArg]=="string"&&(j.currency=t[y.currencyArg]),x==="profile"&&typeof v=="string"&&(j.profileRef=v),(x==="profile-limits"||x==="profile-scope")&&y.profileArg&&typeof t[y.profileArg]=="string"&&(j.profileRef=t[y.profileArg]),u.push(j)}return u}function pm(t,s){var o,l;const a=(l=(o=s==null?void 0:s.scopeSchema)==null?void 0:o.fields)==null?void 0:l[t];return a?{label:a.displayName??t,hint:a.description}:{label:t}}function P0(t,s,a){if(!t||typeof t!="object"||Array.isArray(t))return[];const o=a==="limits"?s==null?void 0:s.boundsSchema:s==null?void 0:s.scopeSchema,l=(o==null?void 0:o.fields)??{},u=[...new Set([...(o==null?void 0:o.keyOrder)??[],...Object.keys(t)])],f=[];for(const g of u){if(g==="profile"||!(g in t))continue;const p=t[g],v=l[g],y=Vi(v==null?void 0:v.unit),x=Array.isArray(p)?p.join(", "):String(p);f.push({key:g,label:(v==null?void 0:v.displayName)??Ht(g),value:y?`${x} ${y}`:x,hint:v==null?void 0:v.description,unknown:s?!v:void 0})}return f}function gm(t){const s=t.indexOf("__");return s<0?{integrationId:"",toolName:t}:{integrationId:t.slice(0,s),toolName:t.slice(s+2)}}function Tc(t,s){var p,v,y;const{integrationId:a,toolName:o}=gm(t.action),l=s.find(x=>x.id===a),u=(v=(p=l==null?void 0:l.toolGating)==null?void 0:p.overrides)==null?void 0:v[o];if(u!=null&&u.actionLabel)return u.actionLabel;const f=lt(t.profileId),g=(y=t.executionContext)==null?void 0:y.action_type;return typeof g=="string"&&g?`${f} · ${g}`:`${f} · ${o}`}function $0(t,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(t.executionContext??{})){if(!(u in a))continue;const g=String(f??"").trim();g&&o.push(g.split(",").map(p=>p.trim()).filter(Boolean).join(", "))}return o.join(" · ")}function _0(t,s){var l,u;if(!t)return"";const a=((l=s==null?void 0:s.scopeSchema)==null?void 0:l.fields)??{},o=[];for(const[f,g]of Object.entries(t)){if(f==="action_type")continue;const p=String(g??"").trim();if(!p)continue;const v=((u=a[f])==null?void 0:u.displayName)??f;o.push(`${v} ${p.split(",").map(y=>y.trim()).filter(Boolean).join(", ")}`)}return o.join(" · ")}function Wf(t){return t.appliesTo}function L0(t,s,a,o){var v,y,x;const l=(v=a==null?void 0:a.boundsSchema)==null?void 0:v.fields;if(!l||!s)return;const u=t.actionType??(typeof((y=t.executionContext)==null?void 0:y.action_type)=="string"?t.executionContext.action_type:void 0),f=Object.entries(l).filter(([j,N])=>{if(!(j in s))return!1;const b=N.boundType;if(!b||b.kind!=="cumulative_sum"&&b.kind!=="cumulative_count"||b.window!==o)return!1;const S=Wf(N);return!S||!u||S.includes(u)}),p=(u?f.find(([,j])=>{var N;return(N=Wf(j))==null?void 0:N.includes(u)}):void 0)??(f.length===1?f[0]:void 0);return p?{key:p[0],isAmount:((x=p[1].boundType)==null?void 0:x.kind)==="cumulative_sum"}:void 0}function ym(t,s,a,o){var g;const l=(g=t.cumulativeState)==null?void 0:g[o];if(!l)return null;const u=L0(t,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 z0(t,s,a){const o=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],l=[];for(const{window:u,label:f}of o){const g=ym(t,s,a,u);g&&l.push("limit"in g?`${g.used} of ${g.limit} ${f}`:`${g.count} ${g.count===1?"call":"calls"} ${f}`)}return l.join(" · ")}function F0(t,s,a){var u;const o=(u=a==null?void 0:a.boundsSchema)==null?void 0:u.fields;if(!t||!s||!o)return[];const l=[];for(const[f,g]of Object.entries(o)){const p=g.boundType;if(!p||p.kind!=="per_transaction")continue;const v=p.of;if(!(v in t)||!(f in s))continue;const y=Number(t[v]),x=Number(s[f]);if(!Number.isFinite(y)||!Number.isFinite(x))continue;const j=Vi(g.unit),N=g.displayName??Ht(v),b=S=>j?`${S.toLocaleString()} ${j}`:S.toLocaleString();l.push({key:f,label:N,ok:y<=x,valueText:b(y),limitText:b(x)})}return l}function Ti(t){return typeof t.proposalId=="string"&&t.proposalId.length>0}function M0(t){const s=lt(t),a=t.split("@")[1];return a?`${s}@${a}`:s}const O0=["automatic","approved","all"];function B0(t){return t==="automatic"||t==="approved"?t:"all"}function ec(t,s){return s==="all"?!0:s==="approved"?Ti(t):!Ti(t)}function ia(t,s,a){const o=t?a[t]:void 0;return o&&o.trim()?o:lt(s)}function oa(t,s){return aa(gm(t).integrationId,s)}function D0(t,s){const a=Math.max(0,Math.floor((s-t)/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 vm(t,s){const a=D0(t*1e3,s);return a==="just now"?"waiting just now":`waiting ${a}`}const U0=24*3600;function xm(t,s,a){const o=t-Math.floor(s/1e3);return o<=0||o>U0?null:`Decide by ${new Date(t*1e3).toLocaleString(a,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})} — otherwise it won't run`}function wm(t){return t.replace(/-/g,"").slice(0,8)}function W0(t,s){const a=new Date(t),o=new Date(s);return a.getFullYear()===o.getFullYear()&&a.getMonth()===o.getMonth()&&a.getDate()===o.getDate()}function Ic(t,s){return W0(t*1e3,s)}function Ii(t,s){return t.timestamp*1e3>s}function H0(t,s){const a=new Map;for(const l of t){if(Ti(l))continue;const u=Tc(l,s.manifests),g=`${l.authorizationId??l.profileId}|${l.action}`;let p=a.get(g);p||(p={key:g,area:ia(l.authorizationId,l.profileId,s.titles),system:oa(l.action,s.manifests),profileId:l.profileId,label:u,count:0,newCount:0,latestSec:0,tickets:[]},a.set(g,p)),p.count+=1,Ii(l,s.lastSeenMs)&&(p.newCount+=1),p.latestSec=Math.max(p.latestSec,l.timestamp),p.tickets.push(l)}const o=[...a.values()];for(const l of o)l.tickets.sort((u,f)=>f.timestamp-u.timestamp);return o.sort((l,u)=>+(u.newCount>0)-+(l.newCount>0)||u.latestSec-l.latestSec)}function V0(t,s){var l,u,f,g;const a=new Map;for(const p of t){if(!p.authorizationId||!Ic(p.timestamp,s.nowMs))continue;const v=a.get(p.authorizationId);(!v||p.timestamp>v.timestamp||p.timestamp===v.timestamp&&(((u=(l=p.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((g=(f=v.cumulativeState)==null?void 0:f.daily)==null?void 0:g.count)??0))&&a.set(p.authorizationId,p)}const o=[];for(const[p,v]of a){const y=ym(v,s.boundsOf(p)??v.limits,s.profileOf(v.profileId),"daily"),x={authorizationId:p,area:ia(p,v.profileId,s.titles),system:oa(v.action,s.manifests),profileId:v.profileId};y&&"limit"in y?o.push({...x,used:y.used,limit:y.limit,ratio:y.limit>0?y.used/y.limit:0}):o.push({...x,used:y?y.count:1,ratio:0})}return o.sort((p,v)=>v.ratio-p.ratio||p.area.localeCompare(v.area))}function Hf(t){return t.ratio>=.8}function Ai(t,s,a){const o=new Date(t*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"});return Ic(t,s)?`today ${l}`:`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`}const G0={mail:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),n.jsx("path",{d:"m3 7 9 6 9-6"})]}),users:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),n.jsx("path",{d:"M3.5 20c0-3.6 2.5-6.3 5.5-6.3s5.5 2.7 5.5 6.3"}),n.jsx("circle",{cx:"17.2",cy:"9.2",r:"2.3"}),n.jsx("path",{d:"M16.8 13.9c2.4.5 4.2 2.6 4.2 5.4"})]}),receipt:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h12v18l-2.2-1.4L14 21l-2-1.4L10 21l-2-1.4L6 21V3Z"}),n.jsx("line",{x1:"9",y1:"7.5",x2:"15",y2:"7.5"}),n.jsx("line",{x1:"9",y1:"11.5",x2:"15",y2:"11.5"}),n.jsx("line",{x1:"9",y1:"15.5",x2:"13",y2:"15.5"})]}),"credit-card":n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2.2"}),n.jsx("line",{x1:"2",y1:"10",x2:"22",y2:"10"}),n.jsx("line",{x1:"5.5",y1:"15",x2:"9.5",y2:"15"})]}),calendar:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"4.5",width:"18",height:"16.5",rx:"2"}),n.jsx("line",{x1:"3",y1:"9.5",x2:"21",y2:"9.5"}),n.jsx("line",{x1:"8",y1:"2.5",x2:"8",y2:"6.5"}),n.jsx("line",{x1:"16",y1:"2.5",x2:"16",y2:"6.5"})]}),megaphone:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 10.2v3.6c0 .7.6 1.2 1.2 1.2h2.6l6.4 4V5l-6.4 4H4.2C3.6 9 3 9.5 3 10.2Z"}),n.jsx("path",{d:"M14.5 8.3a4.3 4.3 0 0 1 0 7.4"}),n.jsx("path",{d:"M17.6 6a7.6 7.6 0 0 1 0 12"})]}),archive:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"3.5",width:"18",height:"5",rx:"1.2"}),n.jsx("path",{d:"M5 8.5V18a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5"}),n.jsx("line",{x1:"10",y1:"13",x2:"14",y2:"13"})]}),rocket:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 2.2c2.4 2 3.8 5.3 3.8 8.6 0 1.9-.9 3.9-.9 3.9H9.1s-.9-2-.9-3.9c0-3.3 1.4-6.6 3.8-8.6Z"}),n.jsx("path",{d:"M9 14.7 6.3 19.4l3.8-1.7"}),n.jsx("path",{d:"M15 14.7l2.7 4.7-3.8-1.7"}),n.jsx("circle",{cx:"12",cy:"9.3",r:"1.3"})]}),flask:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M9 3h6"}),n.jsx("path",{d:"M10 3v6.3l-5 9.1A2 2 0 0 0 6.7 21.5h10.6a2 2 0 0 0 1.7-3.1l-5-9.1V3"}),n.jsx("line",{x1:"8.3",y1:"14.5",x2:"15.7",y2:"14.5"})]}),"shopping-cart":n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"20",r:"1.4"}),n.jsx("circle",{cx:"18",cy:"20",r:"1.4"}),n.jsx("path",{d:"M2.5 3h2.4l2.1 11.2a2 2 0 0 0 2 1.6h8.6a2 2 0 0 0 2-1.6l1.4-7.6H6"})]}),"bar-chart":n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"4",y1:"20.5",x2:"20",y2:"20.5"}),n.jsx("rect",{x:"6",y:"13",width:"3.2",height:"7.5"}),n.jsx("rect",{x:"11.4",y:"8.5",width:"3.2",height:"12"}),n.jsx("rect",{x:"16.8",y:"4",width:"3.2",height:"16.5"})]}),"help-circle":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 Ac({icon:t,className:s}){return n.jsx("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:G0[t]})}const K0=new Set(["mail","users","receipt","credit-card","calendar","megaphone","archive","rocket","flask","shopping-cart","bar-chart","help-circle"]),q0={email:"mail",customers:"users",sales:"receipt",charge:"credit-card",calendar:"calendar",publish:"megaphone",records:"archive",deploy:"rocket",delegation:"flask",purchase:"shopping-cart",reporting:"bar-chart"};function Y0(t){const s=t.lastIndexOf("/"),a=s>=0?t.slice(s+1):t,o=a.indexOf("@");return(o>=0?a.slice(0,o):a).toLowerCase()}function er(t,s){const a=Y0(t),o=s!=null&&s.icon&&K0.has(s.icon)?s.icon:q0[a]??"help-circle",l=lt(t,s==null?void 0:s.name);return{icon:o,name:l,testSetup:a==="delegation"}}function Gi(t){return t.startsWith("setup__")}function br({profileId:t,area:s,system:a,time:o,trailing:l,leading:u}){const{icon:f}=er(t);return n.jsxs("div",{className:"obj-line",children:[u,n.jsx(Ac,{icon:f}),n.jsx("b",{children:s}),a&&n.jsxs("span",{children:["· ",a]}),o&&n.jsxs("span",{children:["· ",o]}),l&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"obj-line-sp"}),l]})]})}async function Vf(t){const s=new TextEncoder().encode(t),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}function J0(t){return t.normalize("NFC").replace(/\r\n?/g,`
|
|
67
|
-
`).split(`
|
|
68
|
-
`).map(l=>l.replace(/[ \t]+$/,"")).join(`
|
|
69
|
-
`).replace(/\n+$/,"")}function tc(t){if(t===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof t=="number"&&!Number.isFinite(t))throw new Error(`canonicalize: ${t} is not a valid JSON number`);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return"["+t.map(l=>l===void 0?"null":tc(l)).join(",")+"]";const s=t,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+tc(l))}return"{"+a.join(",")+"}"}async function jm(t,s){if(t==="jcs"){if(typeof s=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await Vf(tc(s))}`}if(typeof s!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await Vf(J0(s))}`}async function Sm(t){if(t.toolArgs)return t.toolArgs;if(!t.content)return null;try{const{plaintext:s}=await M.decryptProposalContent(t.content),a=JSON.parse(s);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function Q0(t){if(!t.content)return[];const s=new Set([...t.createdBy?[t.createdBy]:[],...t.pendingApprovers??[]]),a=new Set(Object.keys(t.content.keys));return Array.from(s).filter(o=>!a.has(o))}function bm(t){return!t.loading&&t.readable}function km(t,s){const a=new Set;if(t.content)for(const o of Object.keys(t.content.keys))a.add(o);else{t.createdBy&&a.add(t.createdBy);for(const o of t.pendingApprovers??[])a.add(o)}return s&&a.add(s),Array.from(a)}async function Qs(t){const s=await Sm(t);if(s)return jm("jcs",s)}function X0(t){var o;const[s,a]=h.useState((t==null?void 0:t.note)??null);return h.useEffect(()=>{let l=!0;if(t!=null&&t.note){a(t.note);return}if(!(t!=null&&t.noteEncrypted)){a(null);return}return a(null),M.decryptProposalContent(t.noteEncrypted).then(({plaintext:u})=>{l&&a(u)}).catch(()=>{l&&a(null)}),()=>{l=!1}},[t==null?void 0:t.note,(o=t==null?void 0:t.noteEncrypted)==null?void 0:o.ciphertext]),s}const Z0={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function Rc(t){var o;const[s,a]=h.useState(Z0);return h.useEffect(()=>{let l=!0;if(t.toolArgs){a({toolArgs:t.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!t.content){a({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return a({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const u=await Sm(t);l&&a({toolArgs:u,loading:!1,sealed:!0,undecryptable:u===null})})(),()=>{l=!1}},[(o=t.content)==null?void 0:o.ciphertext,t.toolArgs]),s}const Gf=140,Kf=60,ew=/\{([^{}]+)\}/g;function tw(t,s){var u,f;const{integrationId:a,toolName:o}=as(t),l=s==null?void 0:s.find(g=>g.id===a);return((f=(u=l==null?void 0:l.toolGating)==null?void 0:u.overrides)==null?void 0:f[o])??void 0}function Nm(t,s){let a=t;for(const o of s.split(".")){if(a===null||typeof a!="object")return;a=a[o]}return a}function qf(t){return t==null?!1:typeof t=="string"?t.trim().length>0:Array.isArray(t)?t.length>0:!0}function nw(t,s,a,o){if(s==="money"){const u=typeof t=="number"?t:Number(t);if(!Number.isFinite(u))return String(t);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`${t}%`;if(s==="date"){const u=new Date(String(t));return Number.isNaN(u.getTime())?String(t):u.toLocaleDateString(o,{day:"numeric",month:"short"})}if(Array.isArray(t)){const u=t.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 t=="object"?JSON.stringify(t):String(t);return s==="short"&&l.length>Kf?`${l.slice(0,Kf-1).trimEnd()}…`:l}function Yf(t,s,a,o){let l=!1;const u=t.replace(ew,(f,g)=>{const[p,v]=g.split("|").map(x=>x.trim()),y=p.split(",").map(x=>Nm(s,x.trim())).find(qf);return qf(y)?nw(y,v,a,o):(l=!0,"")});return l?null:u}function rw(t,s,a={}){const o=Nm(s,a.currencyField??"currency"),l=typeof o=="string"?o:void 0,u=t.replace(/\[([^[\]]*)\]/g,(p,v)=>Yf(v,s,l,a.locale)??""),f=Yf(u,s,l,a.locale);if(f===null)return null;const g=f.replace(/\s+/g," ").trim();return g.length>Gf?`${g.slice(0,Gf-1).trimEnd()}…`:g}function Cm(t,s,a,o){var f;const l=Ht(as(t).toolName),u=tw(t,a);return!(u!=null&&u.summary)||!s?l:rw(u.summary,s,{currencyField:(f=u.display)==null?void 0:f.currencyField,locale:o})??l}function Em({proposal:t,manifests:s}){const a=Rc(t);return n.jsx(n.Fragment,{children:Cm(t.tool,a.toolArgs,s)})}const Yr=5;function sw({auths:t,activeCount:s,waiting:a,waitingReady:o}){const[l,u]=h.useState(null),[f,g]=h.useState(null),[p,v]=h.useState([]),[y,x]=h.useState({}),[j,N]=h.useState({}),b=h.useCallback(()=>{M.getMyReceiptsPage({limit:200}).then(F=>u(F.receipts)).catch(()=>u(F=>F??[])),M.getLastSeenTicketsAt().then(g).catch(()=>g(Number.POSITIVE_INFINITY))},[]);Lt(b,3e5),Be("ticket-recorded",b),h.useEffect(()=>{M.getIntegrationManifests().then(({manifests:F})=>v(F)).catch(()=>{}),M.getLocalAuthorizations().then(({authorizations:F})=>x(F)).catch(()=>{})},[]);const S=h.useMemo(()=>{const F={};for(const J of t)J.authorization_id&&J.title&&(F[J.authorization_id]=J.title);return F},[t]),k=Date.now(),E=h.useMemo(()=>{const F=Date.now();return(l??[]).filter(J=>Ic(J.timestamp,F))},[l]);h.useEffect(()=>{const F=[...new Set(E.map(J=>J.profileId))].filter(J=>!(J in j));F.length!==0&&Promise.all(F.map(J=>mm(J).then(Q=>[J,Q]).catch(()=>[J,null]))).then(J=>N(Q=>({...Q,...Object.fromEntries(J)})))},[E,j]);const T=h.useMemo(()=>H0(E,{titles:S,manifests:p,lastSeenMs:f??Number.POSITIVE_INFINITY}),[E,S,p,f]),P=E.filter(F=>ec(F,"approved")).length,I=h.useMemo(()=>V0(E,{nowMs:Date.now(),titles:S,manifests:p,boundsOf:F=>{var J;return(J=y[F])==null?void 0:J.bounds},profileOf:F=>j[F]}),[E,S,p,y,j]),U=T.filter(F=>F.newCount>0).length,V=[...a].sort((F,J)=>F.createdAt-J.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?V.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing waits for your decision."}):V.slice(0,Yr).map(F=>{const J=xm(F.expiresAt,k);return n.jsxs(ht,{to:`/approvals?open=${encodeURIComponent(F.id)}`,className:"appr-item appr-item-link","data-testid":"dash-approval",children:[n.jsxs("div",{className:"appr-item-main",children:[n.jsx(br,{profileId:F.profileId,area:ia(F.authorizationId,F.profileId,S),system:oa(F.tool,p),time:vm(F.createdAt,k)}),n.jsx("div",{className:"appr-item-sum",children:n.jsx(Em,{proposal:F,manifests:p})}),J&&n.jsx("div",{className:"obj-due",children:J})]}),n.jsx("span",{className:"appr-item-chev","aria-hidden":"true",children:"›"})]},F.id)}):n.jsx(Xr,{variant:"line"}),V.length>0&&n.jsx(ht,{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"}),U>0&&n.jsxs("span",{className:"meta",children:[T.reduce((F,J)=>F+J.newCount,0)," new"]})]}),l===null?n.jsx(Xr,{variant:"line"}):T.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing was done automatically today."}):T.slice(0,Yr).map(F=>n.jsxs("details",{className:`auto-grp${F.newCount>0?"":" is-seen"}`,"data-testid":"auto-group",children:[n.jsxs("summary",{children:[n.jsx("span",{className:`seen-dot${F.newCount>0?" is-new":""}`,"aria-label":F.newCount>0?"new since your last visit":"seen"}),n.jsxs("span",{className:"auto-grp-txt",children:[n.jsx(br,{profileId:F.profileId,area:F.area,system:F.system}),n.jsxs("b",{children:[F.count," × ",F.label]}),n.jsxs("span",{className:"meta",children:[F.newCount>0?`${F.newCount} new`:"seen"," · latest ",Ai(F.latestSec,k)]})]})]}),n.jsxs("div",{className:"auto-grp-list",children:[F.tickets.slice(0,Yr).map(J=>n.jsxs("div",{className:"auto-grp-row",children:[n.jsx("span",{className:`seen-dot${Ii(J,f??Number.POSITIVE_INFINITY)?" is-new":""}`}),Tc(J,p),n.jsxs("span",{className:"t",children:[Ai(J.timestamp,k)," · ",wm(J.id)]})]},J.id)),F.tickets.length>Yr&&n.jsxs("div",{className:"auto-grp-row meta",children:["+ ",F.tickets.length-Yr," more in Tickets"]})]})]},F.key)),T.length>0&&n.jsx(ht,{to:"/tickets?filter=automatic",className:"col-btn","data-testid":"btn-automatic-tickets",children:"Automatic tickets ›"}),P>0&&n.jsxs("div",{className:"core-quiet-line",children:[P," approved today — ",n.jsx(ht,{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(Xr,{variant:"line"}):I.length===0?n.jsx("p",{className:"core-col-empty",children:"No mandate has acted today."}):I.slice(0,Yr).map(F=>n.jsxs("div",{className:"mandate-obj","data-testid":"mandate-at-work",children:[n.jsx(br,{profileId:F.profileId,area:F.area,system:F.system}),n.jsx("div",{className:`usage${Hf(F)?" is-near":""}`,children:F.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(F.ratio*100))}%`}})}),n.jsxs("span",{children:[Hf(F)?n.jsxs("b",{children:[F.used," of ",F.limit]}):`${F.used} of ${F.limit}`," today"]})]}):n.jsxs("span",{children:[F.used," ",F.used===1?"action":"actions"," today"]})})]},F.authorizationId)),l!==null&&s>I.length&&n.jsxs("div",{className:"meta",style:{marginTop:"var(--space-2)",fontSize:"var(--text-caption)"},children:[s-I.length," more mandate",s-I.length===1?"":"s"," in force — no actions today"]}),I.length>0&&n.jsx(ht,{to:"/mandates",className:"col-btn",children:"All mandates ›"})]})]})}function aw(){const[t,s]=h.useState([]);return Lt(async()=>{try{const{skipped:o}=await M.getSkippedCommitments();s(o)}catch{}},3e4),t.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 (",t.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:t.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))})]})}function iw(t,s){return s&&!Zs(t.manifest)}function ow(t,s=!1){var o;const a=[];for(const l of t)iw(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"&&(Zs(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 lw(t){const s=t.filter(a=>a.state==="paused");return s.length===0?null:{count:s.length,namesText:s.map(a=>a.manifest.name).join(", ")}}const cw=1800;function Hs(t){return t.replace(/@.*$/,"").split("/").pop()??t}function uw(){const{domain:t}=yt(),[s,a]=h.useState([]),[o,l]=h.useState([]),[u,f]=h.useState([]),[g,p]=h.useState(!0),[v,y]=h.useState(!1),[x,j]=h.useState([]),[N,b]=h.useState(!1),[S,k]=h.useState(!1),[E,T]=h.useState(null),[P,I]=h.useState(!1),{entries:U,activeSessions:V,loading:F}=bc(),J=b0(),Q=!F,{simulation:te}=hm(),ee=te===!0,z=C0(),oe=h.useCallback(()=>{M.getMyAttestations().then(se=>{a(se),y(!0)}).catch(()=>y(!0)),M.getArchivedMandates().then(j).catch(()=>j([])),M.getMyProposals(t).then(se=>{l(se),b(!0)}).catch(()=>b(!0)),M.getProposalsForApprover().then(se=>f(se)).catch(()=>f([])),M.getCredential("ai-config").then(se=>{p(se.configured),k(!0)}).catch(()=>k(!0)),M.getAgentContact().then(se=>{T(se.contact),I(!0)}).catch(()=>I(!0))},[t]);Be("attestation-changed",oe),Be("proposal-added",oe),Be("proposal-resolved",oe),Be("proposal-approved",oe),Be("proposal-rejected",oe),Be("execution-failed",oe),Lt(oe,3e5,t);const ue=v&&N&&S&&Q&&P&&te!==null,Y=tm(s,{archivedSet:new Set(x)}),je=Y.active,xe=Y.expired,X=je.some(se=>Hs(se.profile_id)==="delegation"),q=je.filter(se=>Hs(se.profile_id)!=="delegation").length,G=o.filter(se=>Hs(se.profileId)==="delegation").length,A=fm({hasContact:E!==null,hasDelegationMandate:X,otherMandateCount:q,delegationProposalCount:G,managed:z,simulationOn:ee}),_=ee&&A.visible,re=je.filter(se=>se.remaining_seconds!==null&&se.remaining_seconds<=cw),fe=o.filter(im),L=U.filter(se=>se.state==="running"),Z=U.filter(se=>se.state==="starting"),ie=lw(U),me=[...fe,...u.filter(se=>!fe.some(be=>be.id===se.id))],pe=[];for(const se of re){const be=Math.ceil((se.remaining_seconds??0)/60);pe.push({label:"Expiring soon",detail:`${se.title??Hs(se.profile_id)} — ${be} min remaining`,to:"/mandates",color:"var(--text-primary)"})}for(const se of xe)pe.push({label:"Expired",detail:se.title??Hs(se.profile_id),to:"/mandates",color:"var(--text-primary)"});pe.push(...ow(U,ee));for(const se of Z)pe.push({label:"Integration starting",detail:`${se.manifest.name} is coming up…`,to:"/integrations",color:"var(--text-primary)"});for(const se of U)se.authStatus==="failed"&&se.state!=="not-running"&&se.state!=="error"&&se.state!=="paused"&&pe.push({label:"Reconnect needed",detail:`${se.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--text-primary)"});return g||pe.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"})}),ue&&J&&(_?n.jsx(S0,{contact:E,hasDelegationMandate:X,otherMandateCount:q,delegationProposalCount:G,managed:z,simulationOn:ee,mcpEndpoint:J}):!ee&&n.jsx(w0,{aiConfigured:g,hasRunningIntegration:L.length>0,hasActiveAuth:je.length>0,hasAgentConnected:V>0,mcpEndpoint:J})),!_&&n.jsxs(n.Fragment,{children:[n.jsx(sw,{auths:s,activeCount:je.length,waiting:me,waitingReady:N}),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"}),pe.length>0&&n.jsx("span",{className:"rb-count",children:pe.length})]}),pe.length>0?n.jsx("div",{className:"attention-rows",children:pe.map((se,be)=>n.jsxs(ht,{to:se.to,className:"attention-row",children:[n.jsx("span",{className:"attention-dot",style:{background:se.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:se.label}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:se.detail})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},be))}):ue?n.jsxs("div",{className:"all-clear",children:[n.jsx("span",{className:"rb-mark","aria-hidden":"true",children:n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M20 6 9 17l-5-5"})})}),n.jsx("h3",{children:"All clear"}),n.jsx("p",{children:"Nothing needs your attention."})]}):n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[n.jsx(Bl,{}),n.jsx(Bl,{}),n.jsx(Bl,{})]})]})]}),ie&&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:[ie.count," real system",ie.count===1?"":"s"," ",ie.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",ie.namesText,"."]})]}),n.jsx(aw,{}),n.jsx(kx,{})]})}const dw=["Scope & Limits","Intent","Sign"];function Tm({currentStep:t,onStepClick:s}){const a=gn();return n.jsxs("div",{className:"wizard-progress",children:[n.jsx("ol",{className:"wizard-steps",children:dw.map((o,l)=>{const u=l+2,f=u<t,g=u===t,p=u-1<t,v=f&&!!s;return n.jsxs("li",{className:`wizard-step${p?" reached":""}`,"aria-current":g?"step":void 0,children:[n.jsx("button",{type:"button",className:`step-circle${f?" completed":""}${g?" current":""}`,onClick:v?()=>s(u):void 0,disabled:!v,"aria-label":`${o}${f?" (done)":g?" (current)":""}`,children:f?"✓":l+1}),n.jsx("span",{className:`step-label-text${g?" 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 fw({profileId:t,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}`:""]})]}),t&&n.jsxs("span",{children:[n.jsx("strong",{children:"Profile:"})," ",lt(t)]}),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 hw({integrationId:t,field:s,value:a,onChange:o,disabled:l,onLabels:u}){const[f,g]=h.useState(null),[p,v]=h.useState(null),[y,x]=h.useState(!0);h.useEffect(()=>{let b=!1;return M.discoverScopeField(t,s).then(S=>{var k;b||(g(S.options),x(!1),(k=S.options)!=null&&k.length&&(u==null||u(Object.fromEntries(S.options.map(E=>[E.value,E.label])))))}).catch(S=>{b||(v(S instanceof Error?S.message:String(S)),x(!1))}),()=>{b=!0}},[t,s]);const j=new Set(a.split(",").map(b=>b.trim()).filter(Boolean)),N=b=>{const S=new Set(j);S.has(b)?S.delete(b):S.add(b),o(Array.from(S).join(","))};return y?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",t,"…"]}):p||!f?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"msg-attention",style:{fontSize:"0.8rem",marginBottom:"0.5rem"},children:["Couldn't fetch options (",p??"no response","). Enter values manually, separated by commas."]}),n.jsx("input",{className:"form-input",type:"text",value:a,onChange:b=>o(b.target.value),disabled:l})]}):f.length===0?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",t," for this field."]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:f.map(b=>{const S=b.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:j.has(String(b.value)),onChange:()=>N(String(b.value)),disabled:l||E}),n.jsx("span",{children:b.label||b.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]})]},b.value)})})}function Pc(t){if(t.type!=="number")return 0;const s=t.boundType,a=t.unit;return(s==null?void 0:s.kind)==="per_transaction"&&a==="count"?1:0}function Jf(t,s){if(s!==void 0)return String(s);const a=t.default;return typeof a=="string"||typeof a=="number"&&Number.isFinite(a)?String(a):Pc(t)===1?"1":""}function nc(t){const s=t.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function Qf(t,s){const a=Pc(t),o=nc(t),l=s===""?a:Math.max(a,Number(s));return o!==void 0?Math.min(o,l):l}function mw(t,s){var o;const a=(o=t.capKinds)==null?void 0:o[s];return a||(t.approvers.length>0?"approval":"hard")}function $c(t,s,a){var o;return t.approvers.length===0||(s==null?void 0:s.enforcedBy)==="gatekeeper"||((o=s==null?void 0:s.boundType)==null?void 0:o.kind)==="enum"?"hard":mw(t,a)}function Im(t,s,a){const o=t.indexOf(s),l=t.indexOf(a);return o===-1||l===-1?!1:l<o}function Ri(t,s){var a;return((a=t.caps)==null?void 0:a[s])!==void 0}function pw(t,s,a){const o=Object.entries(s.caps??{}).filter(([u])=>$c(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 g=a[u],p=g==null?void 0:g.boundType,v=(p==null?void 0:p.kind)==="per_transaction"||(p==null?void 0:p.kind)==="cumulative_sum"?p.of:void 0,y=v?t[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 gw(t){return t.replace(/@.*$/,"").split("/").pop()??t}function _c(t,s){return s.displayName?s.displayName:t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function yw(t){return t.type==="string"&&(t.format==="email"||t.format==="domain")}function vw(t){var a;const s=t;return!!(s.enum&&((a=s.constraint)!=null&&a.enforceable.includes("subset")))}function Xf(t,s){const a=t.trim();return a?s==="email"?a.includes("@")&&a.indexOf(".",a.indexOf("@"))>-1:s==="domain"?a.includes(".")&&!a.includes("@"):!0:!1}function xw(t){return t?t==="minutes"?15:t==="percent"?5:t.startsWith("currency:")?10:1:1}function ww(t){return t?t==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:t==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:t==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:t==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:t.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function jw(t,s){if(!t||!s)return"";const a=Number(t);if(!Number.isFinite(a)||a<=0)return"";if(s==="minutes"&&a>=60){const o=Math.floor(a/60),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 Sw({id:t,value:s,onChange:a,disabled:o,placeholder:l,unit:u,min:f=0,max:g}){const p=xw(u),v=ww(u).filter(S=>g===void 0||S.value<=g),y=Vi(u),x=jw(s,u),j=s===""?null:Number(s),N=()=>{const S=s===""?0:Number(s),k=S%p,E=k===0?S+p:S+(p-k);a(String(g!==void 0?Math.min(g,E):E))},b=()=>{const S=s===""?0:Number(s);if(S<=f)return;const k=S%p,E=k===0?S-p: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:b,disabled:o||s===""||Number(s)<=f,"aria-label":"Decrease",children:"−"}),n.jsx("input",{id:t,className:"stepper-input",type:"number",min:f,max:g,step:p,value:s,placeholder:l??String(f),onChange:S=>{const k=S.target.value;a(g!==void 0&&k!==""&&Number(k)>g?String(g):k)},onFocus:S=>S.target.select(),disabled:o}),n.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:N,disabled:o||g!==void 0&&s!==""&&Number(s)>=g,"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${j===S.value?" preset-chip-selected":""}`,onClick:()=>a(String(S.value)),children:S.label},S.value))}),x&&n.jsxs("div",{className:"bounded-input-echo",children:["≈ ",x]})]})}function Zf({htmlFor:t,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:t,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 bw({id:t,value:s,onChange:a,disabled:o,format:l,placeholder:u}){const[f,g]=h.useState(""),[p,v]=h.useState(!1),y=h.useRef(null),x=s?s.split(",").map(E=>E.trim()).filter(Boolean):[],j=E=>{const T=E.trim();if(!T)return;if(!Xf(T,l)){v(!0);return}v(!1);const P=x.includes(T)?x:[...x,T];a(P.join(",")),g("")},N=E=>{const T=x.filter((P,I)=>I!==E);a(T.join(","))},b=E=>{E.key==="Enter"||E.key===","||E.key==="Tab"?f.trim()&&(E.preventDefault(),j(f)):E.key==="Backspace"&&!f&&x.length>0&&N(x.length-1)},S=E=>{const T=E.clipboardData.getData("text");if(T.includes(",")){E.preventDefault();const I=T.split(",").map(V=>V.trim()).filter(Boolean).filter(V=>Xf(V,l)),U=[...new Set([...x,...I])];a(U.join(",")),g(""),v(!1)}},k=l==="email"?"Type email and press Enter...":"Type domain and press Enter...";return n.jsxs("div",{className:`tag-input${p?" tag-input-invalid":""}`,onClick:()=>{var E;return(E=y.current)==null?void 0:E.focus()},children:[x.map((E,T)=>n.jsxs("span",{className:"tag-pill",children:[E,!o&&n.jsx("button",{type:"button",className:"tag-remove",onClick:P=>{P.stopPropagation(),N(T)},"aria-label":`Remove ${E}`,children:"×"})]},E)),!o&&n.jsx("input",{ref:y,id:t,className:"tag-input-field",type:"text",value:f,onChange:E=>{g(E.target.value),v(!1)},onKeyDown:b,onPaste:S,onBlur:()=>{f.trim()&&j(f)},placeholder:x.length===0?u??k:""})]})}function kw({id:t,options:s,value:a,onChange:o,disabled:l}){const u=a?a.split(",").map(g=>g.trim()).filter(Boolean):[],f=g=>{const p=u.includes(g)?u.filter(v=>v!==g):[...u,g];o(p.join(","))};return n.jsx("div",{className:"checkbox-group",id:t,children:s.map(g=>n.jsxs("label",{className:`checkbox-pill${u.includes(g)?" checkbox-pill-selected":""}`,children:[n.jsx("input",{type:"checkbox",checked:u.includes(g),onChange:()=>f(g),disabled:l}),n.jsx("span",{children:g})]},g))})}function eh({fieldKey:t,fieldDef:s,value:a,onChange:o,prefix:l,readOnly:u,twoColumn:f,discoveryIntegrationId:g,onLabels:p,capMax:v,enumAllowedFrom:y}){const x=_c(t,s),j=`${l}-field-${t}`,N=n.jsx(n.Fragment,{children:vw(s)?n.jsx(kw,{id:j,options:s.enum,value:a,onChange:b=>o(t,b),disabled:u}):(()=>{const b=s.boundType;return(b==null?void 0:b.kind)==="enum"&&Array.isArray(b.values)})()?n.jsxs("select",{id:j,className:"form-select",value:a,onChange:b=>o(t,b.target.value),disabled:u||y!==void 0&&s.boundType.values.length-y<=1,children:[n.jsx("option",{value:"",children:"Select..."}),s.boundType.values.map((b,S)=>n.jsx("option",{value:b,disabled:y!==void 0&&S<y,children:b},b))]}):s.enum?n.jsxs("select",{id:j,className:"form-select",value:a,onChange:b=>o(t,b.target.value),disabled:u,children:[n.jsx("option",{value:"",children:"Select..."}),s.enum.map(b=>n.jsx("option",{value:b,children:b},b))]}):s.type==="number"?n.jsx(Sw,{id:j,value:a,onChange:b=>o(t,b),disabled:u,unit:s.unit,min:Pc(s),max:v!==void 0?Math.min(v,nc(s)??v):nc(s)}):yw(s)?n.jsx(bw,{id:j,value:a,onChange:b=>o(t,b),disabled:u,format:s.format}):g?n.jsx(hw,{integrationId:g,field:t,value:a,onChange:b=>o(t,b),disabled:u,onLabels:b=>p==null?void 0:p(t,b)}):n.jsx("input",{id:j,className:"form-input",type:"text",value:a,onChange:b=>o(t,b.target.value),disabled:u})});return f?n.jsxs("div",{className:"bounds-field-row",children:[n.jsx("div",{className:"bounds-field-label",children:n.jsx(Zf,{htmlFor:j,label:x,description:s.description})}),n.jsx("div",{className:"bounds-field-input",children:N})]},`${l}-${t}`):n.jsxs("div",{className:"form-group",children:[n.jsx(Zf,{htmlFor:j,label:x,description:s.description}),N]},`${l}-${t}`)}function Nw(t,s,a,o){if(!o||!Ri(o,t))return null;const l=o.caps[t],u=$c(o,s,t);let f=!1;if(typeof l=="number"){const g=a===""?NaN:Number(a);f=!Number.isNaN(g)&&g>l}else if(typeof l=="string"&&a!==""){const g=s.boundType;f=(g==null?void 0:g.kind)==="enum"?Im(g.values??[],l,a):!1}return{kind:u,cap:l,violating:f}}function th(t,s,a,o){if(!o||!Ri(o,t))return a;const l=$c(o,s,t),u=o.caps[t];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,g=(f==null?void 0:f.kind)==="enum"?f.values??[]:[];return a!==""&&Im(g,u,a)?u:a}return a}function Cw(t,s){if(typeof s!="string")return;const a=t.boundType;if((a==null?void 0:a.kind)!=="enum")return;const o=(a.values??[]).indexOf(s);return o===-1?void 0:o}function Ew(t,s){return Vi(s.unit)||_c(t,s).toLowerCase()}function Am(t,s){if(s&&s.length>0)return s.join(" or ");const a=(t==null?void 0:t.approvers)??[];return a.length>0?a.join(" or "):"your team's approvers"}function Tw(t,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-${t}`,children:["Disabled by your team's policy — ",_c(t,s).toLowerCase()," is capped at"," ",String(a.cap)," for this profile."]}):n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${t}`,children:["Team limit ",String(a.cap),u?" — read limits are always hard, no approval path exists for this cap.":""]});const g=Ew(t,s),p=Am(o,l);return n.jsxs("span",{className:"cap-note soft","data-testid":`cap-note-${t}`,children:["Every ",g," above ",String(a.cap)," goes to ",p," for approval."]})}function Iw({profile:t,onConfirm:s,onCancel:a,readOnly:o,initialBounds:l,initialContext:u,initialFrame:f,profileConfig:g,approverNames:p,adminName:v}){var fe;const y=t.boundsSchema,x=t.scopeSchema,j=L=>!!g&&Ri(g,L),N=y?Object.entries(y.fields).filter(([L,Z])=>!(L==="profile"||L==="path"||Z.enforced===!1||Z.enforcedBy==="gatekeeper"&&!j(L))):[],b=y?Object.entries(y.fields).filter(([L,Z])=>Z.enforcedBy==="gatekeeper"&&!j(L)).filter(([,L])=>L.enforced!==!1).map(([L,Z])=>Z.displayName??L):[],S=x&&x.keyOrder.length>0?Object.entries(x.fields):[],k=l??f??{},E=u??{},T={};for(const[L,Z]of N)T[L]=th(L,Z,Jf(Z,k[L]),g);const P={};for(const[L]of S)P[L]=E[L]!==void 0?String(E[L]):"";const[I,U]=h.useState(T),[V,F]=h.useState(P),[J,Q]=h.useState({}),te=h.useRef(new Set);h.useEffect(()=>{U(L=>{let Z=!1;const ie={...L};for(const[me,pe]of N){if(te.current.has(me))continue;const se=L[me]!==void 0?L[me]:Jf(pe,k[me]),be=th(me,pe,se,g);ie[me]!==be&&(ie[me]=be,Z=!0)}return Z?ie:L})},[g]);const[ee,z]=h.useState(null);h.useEffect(()=>{const L=gw(t.id);M.getIntegrationManifests().then(({manifests:Z})=>{const ie=Z.find(me=>me.profile===L&&me.contextDiscovery&&Object.keys(me.contextDiscovery).length>0);z(ie??null)}).catch(()=>z(null))},[t.id]);const oe={};for(const[L,Z]of N)oe[L]=Nw(L,Z,I[L]??"",g);const ue=Object.entries(oe).filter(([,L])=>(L==null?void 0:L.kind)==="hard"&&L.violating).map(([L])=>L),Y=!!g&&(((fe=g.approvers)==null?void 0:fe.length)??0)>0&&N.every(([L])=>!Ri(g,L)),je=(L,Z)=>{te.current.add(L),U(ie=>({...ie,[L]:Z}))},xe=(L,Z)=>{F(ie=>({...ie,[L]:Z}))},X=()=>{const L={profile:t.id};for(const[ie,me]of N)me.type==="number"?L[ie]=Qf(me,I[ie]):L[ie]=I[ie];const Z={};for(const[ie,me]of S)me.type==="number"?Z[ie]=V[ie]===""?0:Number(V[ie]):Z[ie]=V[ie];return[L,Z]},q=()=>{const[L,Z]=X();s(L,Z,J)},G=()=>{var me;const L={...I};for(const pe of ue){const se=(me=oe[pe])==null?void 0:me.cap;se!==void 0&&(L[pe]=String(se))}U(L);const Z={profile:t.id};for(const[pe,se]of N)se.type==="number"?Z[pe]=Qf(se,L[pe]??""):Z[pe]=L[pe]??"";const ie={};for(const[pe,se]of S)se.type==="number"?ie[pe]=V[pe]===""?0:Number(V[pe]):ie[pe]=V[pe];s(Z,ie,J)},A=()=>{if(!Y)return null;const L=Am(g,p);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: ",L]}),n.jsxs("div",{children:["No caps are set on this profile, so ",L," won't gate any action under this mandate. Your intent will still be encrypted and shared with them as an accountability record — they can read what you authorised, even though they aren't reviewing individual actions."]})]})},_=()=>{if(ue.length===0)return null;const L=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 ",L," 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:G,children:"Save below cap"}),a&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})},re=ue.length>0;return n.jsxs("div",{children:[S.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"})]})]}),S.map(([L,Z])=>{var me;const ie=!!((me=ee==null?void 0:ee.contextDiscovery)!=null&&me[L]);return n.jsx(eh,{fieldKey:L,fieldDef:Z,value:V[L],onChange:xe,prefix:"context",readOnly:o,discoveryIntegrationId:ie?ee.id:void 0,onLabels:(pe,se)=>Q(be=>({...be,[pe]:se}))},`context-${L}`)})]}),N.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:N.map(([L,Z])=>{const ie=oe[L];return n.jsxs("div",{style:{display:"contents"},children:[n.jsx(eh,{fieldKey:L,fieldDef:Z,value:I[L],onChange:je,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"?Cw(Z,ie.cap):void 0}),ie&&n.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:Tw(L,Z,ie,g,p)})]},`bounds-${L}`)})}),A(),_(),b.length>0&&n.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[b.join(", ")," ",b.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(ht,{to:"/integrations",children:"Integrations"}),"."]})]}),n.jsx("button",{className:"btn btn-primary",onClick:q,disabled:re,style:{marginTop:"0.5rem"},children:o?"Next: Gates":"Next: Problem Statement"})]})}function Aw(t){var a;const s=t.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((a=s==null?void 0:s[1])==null?void 0:a.trim())??null}function Rw(t){return t.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Pw="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 Pi({target:t,currentText:s,onApply:a,greeting:o,placeholder:l,title:u}){const[f,g]=h.useState([{role:"assistant",content:o??Pw}]),[p,v]=h.useState(""),[y,x]=h.useState(!1),[j,N]=h.useState(null),b=h.useRef(null),S=h.useRef(null);h.useEffect(()=>{const T=b.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=p.trim();if(!T||y)return;const P=[...f,{role:"user",content:T}];g(P),v(""),N(null),x(!0);try{const I=await M.aiChat({target:t,currentText:s,messages:P.filter((U,V)=>!(V===0&&U.role==="assistant"))});I.success&&I.reply?g(U=>[...U,{role:"assistant",content:I.reply}]):N(I.error??"AI returned no reply")}catch(I){N(I instanceof Error?I.message:"Chat failed")}finally{x(!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:b,className:"chat-messages",children:[f.map((T,P)=>{const I=T.role==="assistant"?Aw(T.content):null,U=I?Rw(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:[U&&n.jsx("div",{className:"chat-msg-prose",children:U}),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…"})})]}),j&&n.jsx("div",{className:"error-message",children:j}),n.jsxs("div",{className:"chat-composer",children:[n.jsxs("div",{className:"chat-composer-pill",children:[n.jsx("textarea",{className:"chat-input",value:p,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||!p.trim(),"aria-label":"Send",children:"↑"})]}),n.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Rm({open:t,onClose:s,children:a,ariaLabel:o}){const l=h.useRef(null),u=h.useRef(null);return h.useEffect(()=>{var g;if(!t)return;u.current=document.activeElement,document.body.style.overflow="hidden";const f=p=>{p.key==="Escape"&&s()};return document.addEventListener("keydown",f),(g=l.current)==null||g.focus(),()=>{document.removeEventListener("keydown",f),document.body.style.overflow="",u.current instanceof HTMLElement&&u.current.focus()}},[t,s]),Kv.createPortal(n.jsxs(n.Fragment,{children:[n.jsx("div",{className:`bottom-sheet-backdrop${t?" is-open":""}`,onClick:s,"aria-hidden":"true"}),n.jsxs("aside",{ref:l,className:`bottom-sheet${t?" 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 $w(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _w(t,s,a){if(s.length===0)return[{text:t,label:t,matched:null}];const o=[],l=new Set;for(const p of s)if(!(!p.scope||p.scope==="all (unscoped)"))for(const v of[p.scope,...p.scope.split(",").map(y=>y.trim())]){const y=v.toLowerCase();v&&!l.has(y)&&(l.add(y),o.push(v))}o.sort((p,v)=>v.length-p.length);const u=p=>{const v=p.toLowerCase();return s.filter(y=>{var x,j;return((x=y.scope)==null?void 0:x.toLowerCase())===v||((j=y.scope)==null?void 0:j.split(",").map(N=>N.trim().toLowerCase()).includes(v))})},f=["\\[\\d+\\]",...o.map($w)],g=new RegExp(`(${f.join("|")})`,"gi");return t.split(g).filter(p=>p!=="").map(p=>{const v=/^\[(\d+)\]$/.exec(p);if(v){const y=s[Number(v[1])-1];if(y){const x=y.scope&&y.scope!=="all (unscoped)"?y.scope:"all recipients",j=a?`${a}: ${x}`:x;return{text:p,label:j,matched:[y]}}}else if(o.some(y=>y.toLowerCase()===p.toLowerCase())){const y=u(p);if(y.length>0)return{text:p,label:p,matched:y}}return{text:p,label:p,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 Lw(t,s,a,o){return _w(t,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 zw(){var Le;const t=gn(),[s]=sa(),a=Number(s.get("step"))||2,[o,l]=h.useState(null),[u,f]=h.useState(null),[g,p]=h.useState(a),[v,y]=h.useState(null),[x,j]=h.useState(null),[N,b]=h.useState({}),[S,k]=h.useState(nh),[E,T]=h.useState(!1),[P,I]=h.useState(null),[U,V]=h.useState(!0),[F,J]=h.useState(null),[Q,te]=h.useState([]),[ee,z]=h.useState(void 0),[oe,ue]=h.useState(!1),[Y,je]=h.useState(null),[xe,X]=h.useState(null),[q,G]=h.useState(null),[A,_]=h.useState([]),[re,fe]=h.useState(null);h.useEffect(()=>{var Ge;const ge=sessionStorage.getItem("agentAuth");if(!ge){t("/mandates?new=1");return}const $e=JSON.parse(ge);l($e),$e.intentHint&&k($e.intentHint),M.getCredential("ai-config").then(Me=>I(Me.configured)).catch(()=>I(!1));const qe=sessionStorage.getItem("agentGate");if(qe){const Me=JSON.parse(qe);Me.bounds&&y(Me.bounds),Me.context&&j(Me.context),(Ge=Me.gateContent)!=null&&Ge.intent&&k(Me.gateContent.intent)}M.getProfile($e.profileId).then(Me=>f(Me)).catch(()=>t("/mandates?new=1")).finally(()=>V(!1)),$e.groupId&&Promise.all([M.getTeamProfileConfig($e.groupId,$e.profileId).catch(()=>null),M.getGroupById($e.groupId).catch(()=>null),M.listUsers().catch(()=>[])]).then(([Me,xt,Ze])=>{if(J(Me),Me){const Xe=new Map;for(const ze of Ze){const he=ze.name&&ze.email?`${ze.name} (${ze.email})`:ze.name||ze.email||ze.id;Xe.set(ze.id,he)}const Je=(xt==null?void 0:xt.members)??[];for(const ze of Je){const he=ze.userId??ze.id;he&&(ze.name&&ze.email?Xe.set(he,`${ze.name} (${ze.email})`):ze.name&&Xe.set(he,ze.name))}const wt=(Me.approvers??[]).map(ze=>Xe.get(ze)??ze);te(wt);const mt=Je.find(ze=>ze.role==="admin");if(mt){const ze=mt.userId??mt.id;ze&&z(Xe.get(ze)??mt.name)}}})},[t]);const L=v?Object.entries(v).filter(([ge])=>ge!=="profile"&&ge!=="path").map(([ge,$e])=>`${ge} = ${$e}`).join(", "):"",Z=(ge,$e,qe)=>{y(ge),j($e),qe&&b(qe),p(3)},ie=S.trim()!==nh.trim()&&S.trim()!=="",me=ge=>{ie&&!confirm("Replace your current intent with the AI draft?")||k(ge)},pe=()=>{const ge=u==null?void 0:u.ttl,$e={intent:S},qe=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...qe,bounds:v,context:x,contextLabels:N,gateContent:$e,ttlConfig:ge})),t("/mandates/new/sign")},se=async()=>{if(o){ue(!0),je(null),X(null),G(null),_([]),fe(null);try{const ge=await M.aiIntentReview({profileId:o.profileId,newIntent:S,context:x??void 0});_(ge.grants??[]),ge.success?ge.review?je(ge.review):X(ge.note??"No other mandates on this profile to compare against."):G(ge.error??"Check failed.")}catch(ge){G(ge instanceof Error?ge.message:"Check failed.")}finally{ue(!1)}}},be=ge=>{k(ge),(Y||xe||q)&&(je(null),X(null),G(null),_([]),fe(null))};return U||!o||!u?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):n.jsxs(n.Fragment,{children:[n.jsx(Tm,{currentStep:g,onStepClick:ge=>{ge>=2&&p(ge)}}),n.jsx(fw,{profileId:o.profileId,bounds:L||void 0,groupName:o.groupName,domain:o.domain}),g===2&&n.jsx("div",{className:"card",children:n.jsx(Iw,{profile:u,onConfirm:Z,onCancel:()=>t("/mandates?new=1"),initialBounds:v||void 0,initialContext:x||void 0,profileConfig:F,approverNames:Q,adminName:ee})}),g===3&&n.jsxs("div",{className:`intent-layout${P?"":" no-chat"}`,children:[P&&n.jsx("div",{className:"card intent-pane chat tool",children:n.jsx(Pi,{target:{kind:"intent",profileId:o.profileId,bounds:L||void 0},currentText:S,onApply:me})}),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:ge=>be(ge.target.value)}),n.jsxs("div",{className:"char-counter",children:[S.length," / 2000"]})]}),P===!1&&n.jsxs("p",{className:"intent-ai-hint",children:[n.jsx(ht,{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:se,disabled:oe||!ie,children:oe?"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})]}),xe&&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:xe})]}),Y&&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:Lw(Y,A,fe,lt(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:()=>p(2),children:"Back"}),n.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:pe,disabled:!ie,children:"Continue to Review"})]}),(((Le=F==null?void 0:F.approvers)==null?void 0:Le.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 ",Q.length>0?Q.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",Q.length>0?Q.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(Rm,{open:E,onClose:()=>T(!1),ariaLabel:"Intent assistant",children:n.jsx(Pi,{target:{kind:"intent",profileId:o.profileId,bounds:L||void 0},currentText:S,onApply:ge=>{me(ge),T(!1)}})})]}),re&&n.jsx("div",{className:"modal-backdrop",onClick:ge=>ge.target===ge.currentTarget&&fe(null),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:re.length>1?`Existing mandates (${re.length})`:"Existing mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>fe(null),children:"×"})]}),n.jsx("div",{className:"modal-body",children:re.map((ge,$e)=>{var qe;return n.jsxs("div",{style:{marginBottom:$e<re.length-1?"1rem":0,paddingBottom:$e<re.length-1?"1rem":0,borderBottom:$e<re.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:ge.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:((qe=ge.intent)==null?void 0:qe.trim())||"(no intent recorded)"}),Object.entries(ge.bounds).filter(([Ge])=>Ge!=="profile"&&Ge!=="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(ge.bounds).filter(([Ge])=>Ge!=="profile"&&Ge!=="path").map(([Ge,Me])=>`${Ge}: ${Me}`).join(" · ")})]})]},$e)})})]})})]})]})}function Fw(t){return t.normalize("NFC").replace(/\r\n?/g,`
|
|
74
|
-
`).split(`
|
|
75
|
-
`).map(l=>l.replace(/[ \t]+$/,"")).join(`
|
|
76
|
-
`).replace(/\n+$/,"")}async function Lc(t){const a=new TextEncoder().encode(t),o=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(o)).map(u=>u.toString(16).padStart(2,"0")).join("")}class Mw extends Error{constructor(a,o,l){super(l);Ds(this,"code");Ds(this,"field");this.name="CanonicalValueError",this.code=a,this.field=o}}function Ow(t){const s=new TextEncoder().encode(t);let a="";for(const o of s)o===61||o===37||o<32||o>126?a+="%"+o.toString(16).toUpperCase().padStart(2,"0"):a+=String.fromCharCode(o);return a}function Pm(t,s,a){const o=[];for(const l of s){const u=t[l];if(u==null)continue;const f=String(u);if(f.includes(`
|
|
77
|
-
`)||f.includes("\r"))throw new Mw(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}=${Ow(f)}`)}return o.join(`
|
|
78
|
-
`)}async function ki(t,s){const a=s.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const o=Pm(t,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await Lc(o)}`}async function $m(t,s){const a=s.scopeSchema?Pm(t,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await Lc(a)}`}function rc(t){if(t===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof t=="number"&&!Number.isFinite(t))throw new Error(`canonicalize: ${t} is not a valid JSON number`);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return"["+t.map(l=>l===void 0?"null":rc(l)).join(",")+"]";const s=t,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+rc(l))}return"{"+a.join(",")+"}"}async function _m(t){return`sha256:${await Lc(rc(t))}`}async function $i(t){const s=new TextEncoder().encode(Fw(t)),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 Lm(t,s){if(!t.authorization_id)throw new Error("Signing result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:t.authorization_id,boundsHash:t.bounds_hash??s.boundsHash,contextHash:s.contextHash,context:s.context,...s.contextLabels&&Object.keys(s.contextLabels).length>0?{contextLabels:s.contextLabels}:{},gateContent:s.gateContent,...s.path?{path:s.path}:{}}}function Bw(t){const s=t.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(a=>s.includes(a)):[]}function Dw(t){return t==="per-action"?"review":"automatic"}function rh(t){return t?Bw(t).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function Uw(t,s){return s.includes(t)?t:s[0]??null}function sh(t){return t==null?new Set:new Set(String(t).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function Ww(t,s){for(const a of t)if(s.has(a))return!0;return!1}function Hw(t,s,a){for(const o of t){const l=sh(s[o]),u=sh(a[o]);if(!(l.size===0||u.size===0)&&!Ww(l,u))return!1}return!0}function Vw(t){return t.length>24?`${t.slice(0,10)}…`:t}function zm(t,s,a){const o=a==null?void 0:a[t];return String(s).split(",").map(u=>u.trim()).filter(Boolean).map(u=>{const f=o==null?void 0:o[u];return f?`${f} (${Vw(u)})`:u}).join(", ")}function Fm(t){var l;if(t.isPersonal)return{can:!0};if(!t.configLoaded)return{can:!0};const s=t.teamName?`"${t.teamName}"`:"this team";return t.grantors!=="all"&&(((l=t.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 ${t.profileName} and name who may give its mandates.`}:t.grantors==="all"||!!t.userId&&t.grantors.includes(t.userId)?{can:!0}:{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${t.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 _i=500,Gw=["Lower the discount","Other recipient","Shorter","Different wording"];function zc(t){const s=t.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>_i?{valid:!1,error:`At most ${_i} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function Kw(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Mm(t,s){return t.toLowerCase().includes(s.toLowerCase())}function qw(t,s){const a=t.trim();if(a.length===0)return s;if(!Mm(a,s))return`${a}. ${s}`;const o=new RegExp(`\\.?\\s*${Kw(s)}\\.?`,"i");return a.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function Om(){return{outcome:"rejected"}}function Yw(t){const s=zc(t);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function ah(){return{outcome:"replaced"}}function Jw(t,s){if((t.pendingApprovers??[]).includes(s))return{route:"approver"};const a=t.pendingDomains??[];return a.includes(s)?{route:"resolve",domain:s}:a.includes("owner")?{route:"resolve",domain:"owner"}:null}const Qw={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function Xw(t,s){const a=t.rejectedBy??t.approverRejectedBy;if(!a)return null;const o=a.outcome??"rejected",l=a.note??("reason"in a?a.reason:void 0);return{kind:Qw[o],who:a.userId===s?"You":a.userId,at:a.at,note:l}}function Zw(t){return t.refusal?{kind:"REFUSED",at:t.refusal.at,message:t.refusal.message}:null}function ej(){var Fe,H;const t=gn(),{user:s,mode:a,domain:o}=yt(),[l,u]=h.useState(null),[f,g]=h.useState(null),[p,v]=h.useState(null),[y,x]=h.useState("per-action"),[j,N]=h.useState(1800),[b,S]=h.useState(86400),[k,E]=h.useState(""),[T,P]=h.useState("hours"),[I,U]=h.useState(""),[V,F]=h.useState(!0),[J,Q]=h.useState(!1);h.useEffect(()=>{M.getIdentityDisclosure().then(K=>Q(K.always)).catch(()=>{})},[]);const[te,ee]=h.useState(!1),[z,oe]=h.useState(""),[ue,Y]=h.useState(null),[je,xe]=h.useState([]),[X,q]=h.useState(!1),[G,A]=h.useState([]),[_,re]=h.useState(0);h.useEffect(()=>{var Ft;const K=sessionStorage.getItem("agentAuth"),ye=sessionStorage.getItem("agentGate");if(!K||!ye){t("/mandates?new=1");return}const He=JSON.parse(K),Ue=JSON.parse(ye),st={bounds:Ue.bounds??{},context:Ue.context??{},contextLabels:Ue.contextLabels??void 0,gateContent:Ue.gateContent};u(He),g(st),Ue.ttlConfig&&(N(Ue.ttlConfig.default??1800),S(Ue.ttlConfig.max??86400)),Ue.templateMode==="automatic"?x("immediate"):Ue.templateMode==="review"&&x("per-action");const zt=((Ft=Ue.ttlConfig)==null?void 0:Ft.max)??86400;if(typeof Ue.templateTtl=="number"&&Ue.templateTtl>0){const B=Math.min(Ue.templateTtl,zt);N(B),[3600,86400,604800,2592e3,31536e3].includes(B)||(B%86400===0?(E(String(B/86400)),P("days")):(E(String(Math.max(1,Math.round(B/3600)))),P("hours")))}M.getProfile(He.profileId).then(B=>{var ve;if(v(B),!I){const Ie=B.name??((ve=He.profileId.split("/").pop())==null?void 0:ve.replace(/@.*$/,""))??"",et=[];if(st.context&&B.scopeSchema)for(const Ne of B.scopeSchema.keyOrder){const we=st.context[Ne];if(we!==void 0&&we!==""){const De=String(we).split(",").map(Oe=>Oe.trim()).filter(Boolean);et.push(De.join(", "))}}const le=et.length>0?`${Ie}: ${et.join(" · ")}`:Ie;U(le)}}).catch(()=>{}),He.isPersonal?q(!0):Promise.all([M.getTeamProfileConfig(He.groupId,He.profileId).catch(()=>null),M.getGroupById(He.groupId).catch(()=>null),M.listUsers().catch(()=>[])]).then(([B,ve,Ie])=>{if(Y(B),B){const et=new Map;for(const we of Ie){const De=we.name&&we.email?`${we.name} (${we.email})`:we.name||we.email||we.id;et.set(we.id,De)}const le=(ve==null?void 0:ve.members)??[];for(const we of le){const De=we.userId??we.id;De&&(we.name&&we.email?et.set(De,`${we.name} (${we.email})`):we.name&&et.set(De,we.name))}const Ne=(B.approvers??[]).map(we=>et.get(we)??we);xe(Ne)}}).finally(()=>{q(!0)})},[t]),h.useEffect(()=>{if(!(l!=null&&l.profileId))return;const K=l.profileId,ye=sessionStorage.getItem("agentEditReplaces");M.getEnrichedAuthorizations().then(He=>{const Ue=He.filter(st=>st.profileId===K&&st.authorizationId!==ye).map(st=>({authorizationId:st.authorizationId,bounds:st.bounds,context:st.context??{},intent:st.intent}));A(Ue)}).catch(()=>A([]))},[l==null?void 0:l.profileId]),h.useEffect(()=>{if(!p)return;const K=Uw(y,rh(p));K&&K!==y&&x(K)},[p,y]),h.useEffect(()=>{if(!f||!p||G.length===0){re(0);return}let K=!1;return(async()=>{const ye=await ki(f.bounds,p),He=await Promise.all(G.map(Ue=>ki(Ue.bounds,p).catch(()=>null)));K||re(He.filter(Ue=>Ue===ye).length)})().catch(()=>{K||re(0)}),()=>{K=!0}},[f,p,G]);const fe=async()=>{if(!(!l||!f||!p||!s)){if(!l.groupId){oe("No active group; cannot create mandate.");return}ee(!0),oe("");try{const K=o||l.domain||"owner",ye=await ki(f.bounds,p),He=await $m(f.context,p),[Ue,st]=await Promise.all([$i(f.gateContent.intent),$i(JSON.stringify({profile:l.profileId,domain:K,group:l.groupId}))]);let zt,Ft,B,ve;if(l.isTeam){const Oe=await M.getApproversPubkeys(l.groupId,l.profileId);if(Oe.length>0){const tt=await M.encryptIntent(f.gateContent.intent,Oe);zt=tt.intentCiphertext,Ft=tt.encryptedKeys,B=tt.approversFrozen,ve=tt.intentDisclosureHash}}const Ie=`authz_${crypto.randomUUID()}`,et=sessionStorage.getItem("agentEditReplaces")||void 0,le=sessionStorage.getItem("agentReplacesProposal")||void 0,Ne=await _m(p),we=await M.attest({authorization_id:Ie,replaces:et,profile_id:l.profileId,profile_hash:Ne,supported_versions:["0.7"],bounds:f.bounds,bounds_hash:ye,scope_hash:He,domain:K,did:s.did,mandate_owners:[{did:s.did}],gate_content_hashes:{intent:Ue},execution_context_hash:st,group_id:l.groupId,ttl:j,commitment_mode:Dw(y),title:I.trim(),intent_ciphertext:zt,encrypted_keys:Ft,approvers_frozen:B,intent_disclosure_hash:ve,disclose_identity:V});try{await M.pushGateContent(Lm(we,{boundsHash:ye,contextHash:He,context:f.context,contextLabels:f.contextLabels,gateContent:f.gateContent}))}catch(Oe){try{await M.revokeAttestation(Ie,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${Oe instanceof Error?Oe.message:"Unknown error"})`)}if(et)try{await M.revokeAttestation(et,`Replaced by ${Ie} (edit)`),M.resyncGates().catch(()=>{})}catch{}let De="";if(le)try{const Oe=await M.getProposal(le);if(Oe.status==="pending"){const tt=Jw(Oe,(s==null?void 0:s.id)??"");tt?tt.route==="approver"?await M.rejectProposal(le,ah()):await M.resolveProposal(le,"reject",tt.domain,ah()):De="you are not one of the people who may decide it"}}catch(Oe){De=Oe instanceof Error?Oe.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),De){oe(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${De}) — reject it under Approvals.`);return}t(`/mandates?highlight=${encodeURIComponent(Ie)}`)}catch(K){oe(K instanceof Error?K.message:"Signing the mandate failed")}finally{ee(!1)}}};if(!l||!f)return n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const L=Object.entries(f.bounds).filter(([K])=>K!=="profile"&&K!=="path"),Z=Object.entries(f.context),me=((ue==null?void 0:ue.caps)!=null?Object.keys(ue.caps):[]).length!==0,pe=je.length>0?je.join(", "):((ue==null?void 0:ue.approvers)??[]).join(", "),se=me?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${pe}, 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.",be=me?`Over-cap actions will be reviewed by you and ${pe}. Within-cap actions run per the mode you chose above.`:`Approvers ${pe} can read your intent but won't gate any action — no caps configured on this profile.`,Le=!!((Fe=ue==null?void 0:ue.approvers)!=null&&Fe.length),ge=Fm({isPersonal:l.isPersonal,configLoaded:X,grantors:ue?Yh(ue):void 0,userId:s==null?void 0:s.id,profileName:lt(l.profileId),teamName:l.groupName}),$e=!ge.can,qe=rh(p),Ge=qe.length===0,Me=j>b,xt={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"},Xe=((H=p==null?void 0:p.scopeSchema)==null?void 0:H.keyOrder)??[],Je=G.filter(K=>Hw(Xe,f.context,K.context)),wt=Je.length>0,mt=lt(l.profileId),ze=K=>{const ye=Object.values(K).map(He=>String(He).trim()).filter(Boolean);return ye.length>0?ye.join(", "):"all (unscoped)"},he=Je.map(K=>ze(K.context)).join("; "),Pe=`This grant's scope overlaps an existing grant on ${mt} (scoped to: ${he}). 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(Tm,{currentStep:4,onStepClick:K=>{K<=3&&t(`/mandates/new/intent?step=${K}`)}}),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&&p&&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 ",lt(l.profileId)," ",p.version," — the current version of this profile."]})]}),z&&n.jsx("div",{className:"error-message",children:z}),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. ${lt(l.profileId)}: daily operations`,value:I,onChange:K=>U(K.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:[qe.includes("per-action")&&n.jsxs("button",{onClick:()=>x("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."})]}),qe.includes("immediate")&&n.jsxs("button",{onClick:()=>x("immediate"),style:xt,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."})]})]}),qe.length===1&&n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:qe[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Ge&&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(K=>K.seconds<=b).map(K=>n.jsx("button",{onClick:()=>{N(K.seconds),E("")},style:{padding:"0.5rem 0.85rem",border:j===K.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:j===K.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:K.label},K.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:K=>{E(K.target.value);const ye=parseInt(K.target.value,10);if(ye>0){const He=T==="days"?ye*86400:ye*3600;N(Math.min(He,b))}}}),n.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:T,onChange:K=>{P(K.target.value);const ye=parseInt(k,10);if(ye>0){const He=K.target.value==="days"?ye*86400:ye*3600;N(Math.min(He,b))}},children:[n.jsx("option",{value:"hours",children:"hours"}),n.jsx("option",{value:"days",children:"days"})]})]}),Me&&n.jsxs("span",{className:"msg-error",style:{fontSize:"0.75rem"},children:["Maximum: ",b>=86400?`${Math.floor(b/86400)} days`:`${Math.floor(b/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:J||V,disabled:J,onChange:K=>F(K.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.',J&&" 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:()=>t("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:f.gateContent.intent})]}),(!!L.length||!!Z.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:()=>t("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),n.jsxs("dl",{className:"info-kv",children:[Z.map(([K,ye])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:K}),n.jsx("dd",{children:zm(K,ye,f.contextLabels)})]},K)),L.map(([K,ye])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:K}),n.jsx("dd",{children:String(ye)})]},K))]})]}),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:[lt(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:X?ge.can?n.jsxs(n.Fragment,{children:[pe,n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:se})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"msg-error",children:ge.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${l.groupName??"this team"}`:"You cannot give this mandate"}),ge.code==="OWNER_NOT_APPROVER"&&n.jsx("div",{children:pe}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[ge.reason," ",ge.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 ${mt} already has exactly these limits.`:`${_} active grants on ${mt} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",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,wt?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:()=>t("/mandates/new/intent"),children:"Back"}),n.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:fe,disabled:te||!I.trim()||$e||Ge,children:te?"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:Le?"block":"none"},children:be})]})]})}const tj={card:"💳",mail:"✉️"};function Bm(t){return tj[t]??"🔧"}function nj(t){const s=t==null?void 0:t.overrides;return!s||typeof s!="object"?!1:Object.values(s).some(a=>{var o;return typeof((o=a==null?void 0:a.read)==null?void 0:o.ageField)=="string"})}const rj=[0,7,30,90,365,3650];function xi(t){return t===null?"From your mandate":t===0?"Read nothing":t===1?"1 day back":t===365?"1 year back":t%365===0?`${t/365} years back`:`${t} days back`}function sj(t){return(t==null?void 0:t.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:t&&!t.running&&t.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function Dl({manifest:t,integration:s,state:a,onStatusChange:o,onSuccess:l}){var ze;const[u,f]=h.useState({}),[g,p]=h.useState(!1),[v,y]=h.useState(!1),[x,j]=h.useState({}),[N,b]=h.useState({}),[S,k]=h.useState(void 0),[E,T]=h.useState(!1),[P,I]=h.useState(null),[U,V]=h.useState(!1),[F,J]=h.useState(!1),[Q,te]=h.useState(!1),[ee,z]=h.useState(!1),[oe,ue]=h.useState({}),[Y,je]=h.useState(null),[xe,X]=h.useState(!1),[q,G]=h.useState(null),[A,_]=h.useState(!1);h.useEffect(()=>{let he=!1;return M.getCredential(t.id).then(Pe=>{var Fe;if(!(he||!Pe.configured)){if(p(!0),y(!0),Pe.fields){const H={};for(const K of t.credentials.fields)Pe.fields[K.key]!=null&&(H[K.key]=Pe.fields[K.key]);j(H)}if(b(Pe.secrets??{}),k(Pe.updatedAt),t.oauth){const H=((Fe=Pe.fieldNames)==null?void 0:Fe.includes(t.oauth.tokenStorage))??!1;T(H),H&&M.getOAuthHealth(t.id).then(K=>{he||I(K)})}}}).catch(()=>{}),()=>{he=!0}},[t.id,t.oauth]);const re=nj(t.toolGating),fe=s?s.readAgeDays??null:void 0,L=xe&&Y?Y.value:fe,Z=async he=>{je({value:he}),X(!0),G(null);try{await M.setReadPolicy(t.id,he),l(he===null?`${t.name} read window now follows your mandate`:`${t.name} read window set to ${xi(he).toLowerCase()}`),o()}catch(Pe){G(Pe instanceof Error?Pe.message:"Could not save")}finally{X(!1),je(null)}},ie=!!t.oauth||t.credentials.fields.some(he=>!he.optional),me=t.oauth?E:g,pe=!ie||me,se=a==="starting"?"starting":pe?s!=null&&s.running?"running":!g&&t.credentials.fields.length>0?"unconfigured":"ready":t.oauth&&g&&!E?"needs-oauth":"unconfigured",be=async()=>{if(t.credentials.fields.some(Pe=>{var Fe;return(Fe=u[Pe.key])==null?void 0:Fe.trim()})){V(!0);try{await M.setCredential(t.id,u),p(!0),f({}),t.oauth?l(`${t.name} credentials saved!`):(l(`${t.name} credentials saved — starting integration...`),await Ge())}catch{l(`Failed to save ${t.name} credentials`)}finally{V(!1)}}},Le=()=>{const he={};for(const Pe of t.credentials.fields){const Fe=u[Pe.key];Pe.type==="password"?Fe!=null&&Fe.trim()&&(he[Pe.key]=Fe):Fe!=null&&Fe!==(x[Pe.key]??"")&&(he[Pe.key]=Fe)}return he},ge=Object.keys(Le()).length>0,$e=async()=>{const he=Le();if(Object.keys(he).length!==0){V(!0);try{await M.setCredential(t.id,he),f({}),p(!0),t.oauth?l(`${t.name} credentials saved — now click Connect.`):(z(!1),l(`${t.name} credentials updated — restarting...`),await Ge())}catch{l(`Failed to update ${t.name} credentials`)}finally{V(!1)}}},qe=()=>{window.open(`/auth/oauth/${t.id}/start`,"_blank","width=600,height=700");const he=setInterval(async()=>{var Pe;try{const Fe=await M.getCredential(t.id);Fe.configured&&t.oauth&&((Pe=Fe.fieldNames)!=null&&Pe.includes(t.oauth.tokenStorage))&&(T(!0),z(!1),I(null),clearInterval(he),l(`${t.name} connected — starting integration...`),M.getOAuthHealth(t.id).then(I).catch(()=>{}),await Ge())}catch{}},2e3);setTimeout(()=>clearInterval(he),12e4)},Ge=async()=>{te(!0);try{const he=await M.activateIntegration(t.id);he.warning?l(he.warning):l(`${t.name} integration started with ${he.tools.length} tools`),o()}catch(he){l(`Failed to start ${t.name}: ${he instanceof Error?he.message:"Unknown error"}`)}finally{te(!1)}},Me=async()=>{try{await M.removeMcpIntegration(t.id),l(`${t.name} integration removed`),o()}catch{l(`Failed to remove ${t.name}`)}},xt=Bm(t.icon),Ze=sj(s),Xe=se==="running"?{c:"int-chip-ok",t:"Running"}:se==="starting"?{c:"int-chip-idle",t:"Starting"}:Ze.chip,Je=t.oauth&&E&&(P==null?void 0:P.status)==="failed",wt=ie?Je?{c:"int-chip-bad",t:"Auth failed"}:me?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},mt=he=>he.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${t.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:xt}),n.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:t.name}),n.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[se!=="unconfigured"&&se!=="needs-oauth"&&n.jsxs("span",{className:`int-chip ${Xe.c}`,children:[n.jsx("span",{className:"int-dot"}),Xe.t]}),n.jsxs("span",{className:`int-chip ${wt.c}`,children:[n.jsx("span",{className:"int-dot"}),wt.t]}),dx(t,x)&&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"]})]})]}),t.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"})}),Je&&!ee&&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:[t.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 ",t.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:qe,children:["Reconnect ",t.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{f({...x}),z(!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:t.description}),t.profile&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Profile"}),n.jsx("span",{children:t.profile})]}),t.oauth&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Scopes"}),n.jsx("span",{children:((ze=t.oauth.scopes)==null?void 0:ze.join(", "))||"—"})]}),s&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Tools"}),n.jsxs("span",{children:[s.toolCount," gated"]})]})]})]}),t.setupGuide&&t.setupGuide.length>0&&(se!=="running"||Je)&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsxs("button",{onClick:()=>J(!F),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:F?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",t.name]}),F&&n.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:t.setupGuide.map((he,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:he.title}),n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[mt(he.description),he.link&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("a",{href:he.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},Pe))})]}),se==="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…"]}),ee&&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.",t.oauth?" Save, then Connect to re-link the account.":""]}),t.credentials.fields.map(he=>{var Pe;return n.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[n.jsx("label",{className:"form-label",children:he.label}),he.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:oe[he.key]?"text":"password",name:`${t.id}-${he.key}-credential`,autoComplete:"new-password",placeholder:(Pe=N[he.key])!=null&&Pe.preview?`Unchanged — ends in ${N[he.key].preview}`:v?"Unchanged — paste a new value to replace":he.placeholder,value:u[he.key]||"",onChange:Fe=>f(H=>({...H,[he.key]:Fe.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>ue(Fe=>({...Fe,[he.key]:!Fe[he.key]})),children:oe[he.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${he.key}-credential`,autoComplete:"off",placeholder:he.placeholder,value:u[he.key]||"",onChange:Fe=>f(H=>({...H,[he.key]:Fe.target.value}))})]},he.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:$e,disabled:U||!ge,children:U?"Saving…":"Save"}),!ge&&!U&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),t.oauth&&n.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:qe,children:["Connect ",t.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{z(!1),f({})},children:"Cancel"})]})]}),!ee&&se==="running"&&s&&n.jsxs(n.Fragment,{children:[(Object.keys(x).length>0||Object.keys(N).length>0)&&n.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:t.credentials.fields.map(he=>{const Pe=he.type==="password",Fe=N[he.key];return!Pe&&x[he.key]==null||Pe&&Fe==null?null:n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[n.jsx("span",{style:{color:"var(--text-muted)"},children:he.label}),n.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[Pe?Fe.preview??"set":x[he.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"})]})]})]},he.key)})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[n.jsx(ht,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(t.credentials.fields.length>0||t.oauth)&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{f({...x}),z(!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:Me,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"})]}),re&&L!==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:L===null?"window from your mandate":xi(L).toLowerCase()}),xe&&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"})]})}),re&&L!==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:[rj.map(he=>{const Pe=L===he;return n.jsx("button",{className:`btn btn-sm ${Pe?"btn-primary":"btn-secondary"}`,"aria-pressed":Pe,disabled:xe,onClick:()=>Z(he),children:xi(he)},he)}),n.jsx("button",{className:`btn btn-sm ${L===null?"btn-primary":"btn-ghost"}`,"aria-pressed":L===null,disabled:xe,onClick:()=>Z(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:xi(null)})]}),n.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:q?n.jsx("span",{className:"msg-error",children:q}):xe?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):L===null?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):L===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 ",L," days is blocked, whoever it is from."]})})]}),n.jsx("div",{style:{display:"none"},children:n.jsx(ht,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),se==="unconfigured"&&(()=>{const he=t.credentials.fields.every(H=>H.optional),Pe=t.credentials.fields.some(H=>!H.optional),Fe=t.credentials.fields.some(H=>{var K;return(K=u[H.key])==null?void 0:K.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:()=>{p(!0),t.oauth&&T(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),t.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."}),t.setupHint&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:t.setupHint}),t.credentials.fields.map(H=>n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:H.label}),H.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:oe[H.key]?"text":"password",name:`${t.id}-${H.key}-credential`,autoComplete:"new-password",placeholder:H.placeholder,value:u[H.key]||"",onChange:K=>f(ye=>({...ye,[H.key]:K.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>ue(K=>({...K,[H.key]:!K[H.key]})),children:oe[H.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${t.id}-${H.key}-credential`,autoComplete:"off",placeholder:H.placeholder,value:u[H.key]||"",onChange:K=>f(ye=>({...ye,[H.key]:K.target.value}))})]},H.key)),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[Fe&&n.jsx("button",{className:"btn btn-primary",onClick:be,disabled:U||Pe&&!t.credentials.fields.filter(H=>!H.optional).every(H=>{var K;return(K=u[H.key])==null?void 0:K.trim()}),children:U?"Saving...":"Save & Encrypt"}),he&&!Fe&&n.jsx("button",{className:"btn btn-primary",onClick:Ge,disabled:Q,children:Q?"Starting...":`Activate ${t.name}`})]})]})})(),se==="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 ",t.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:qe,children:["Connect ",t.name," Account"]}),n.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Change Credentials"})]})]}),se==="ready"&&!s&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem"},children:["✓"," ",t.oauth?`${t.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:Ge,disabled:Q,children:Q?"Starting...":`Start ${t.name} Integration`}),!t.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Update Credentials"}),t.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>{p(!1),T(!1)},children:"Change Credentials"})]})]}),se==="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:Ge,disabled:Q,children:Q?"Starting...":"Start"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:Me,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:Me,children:"Disable"})})]}))]})}function aj(t,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:t};const a=t.filter(f=>Zs(f.manifest)),o=t.filter(f=>!Zs(f.manifest)),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 ij({entry:t}){return n.jsxs("div",{className:"int-paused-row",children:[n.jsx("span",{"aria-hidden":"true",children:Bm(t.manifest.icon)}),n.jsx("span",{className:"int-paused-name",children:t.manifest.name}),n.jsxs("span",{className:"int-chip int-chip-paused",children:[n.jsx("span",{className:"int-dot"}),"Paused"]})]})}function oj(){const{loading:t,mcpServerUp:s,manifestsError:a,entries:o,refresh:l}=bc(),u=Sc(),[f,g]=h.useState(""),p=h.useCallback(y=>{g(y),setTimeout(()=>g(""),5e3)},[]),v=aj(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}),t?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."})]}):v.grouped?n.jsxs(n.Fragment,{children:[v.testSystems.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Test systems"}),v.testSystems.map(y=>n.jsx(Dl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:l,onSuccess:p},y.id))]}),(v.realErrors.length>0||v.pausedReal.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Real systems"}),v.realErrors.map(y=>n.jsx(Dl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:l,onSuccess:p},y.id)),v.pausedReal.length>0&&n.jsxs("details",{className:"int-paused-group",open:!0,children:[n.jsxs("summary",{children:["Paused while simulation mode is on (",v.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"}),")."]}),v.pausedReal.map(y=>n.jsx(ij,{entry:y},y.id))]})]}),o.length===0&&n.jsx(ih,{manifestsError:a})]}):n.jsxs(n.Fragment,{children:[o.map(y=>n.jsx(Dl,{manifest:y.manifest,integration:y.integration,state:y.state,onStatusChange:l,onSuccess:p},y.id)),o.length===0&&n.jsx(ih,{manifestsError:a})]})]})}function ih({manifestsError:t}){return t?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 lj(){var z,oe,ue;const{activeTeam:t,activeMembership:s,refreshGroups:a,user:o}=yt(),l=gn(),[u,f]=h.useState(null),[g,p]=h.useState(!1),[v,y]=h.useState(""),[x,j]=h.useState(""),[N,b]=h.useState(!1),[S,k]=h.useState(""),[E,T]=h.useState("");h.useEffect(()=>{fetch("/health").then(Y=>Y.json()).then(Y=>{typeof Y.spUrl=="string"&&T(Y.spUrl)}).catch(()=>{})},[]),h.useEffect(()=>{if(!t){f(null);return}M.getGroupById(t.id).then(Y=>{const je=Y.group??Y,xe=Y.members??[],X=Y.isAdmin??!1,q=xe.map(G=>{const A=G.userId||G.id||"",_=G.role||(X&&A===je.createdBy?"admin":"member");return{id:A,name:G.name||A.slice(0,8)||"Member",email:G.email||"",domains:G.domains||[],role:_,isAdmin:_==="admin"||X&&A===je.createdBy}});f({id:je.id,name:je.name,members:q})}).catch(()=>f(null))},[t==null?void 0:t.id]);const P=(u==null?void 0:u.members.filter(Y=>Y.isAdmin))??[],I=(t==null?void 0:t.isAdmin)===!0&&P.length<=1&&P.some(Y=>Y.id===(o==null?void 0:o.id)),U=(t==null?void 0:t.name)??"",V=S.trim()===U&&!g,F=()=>{k(""),b(!0)},J=()=>{b(!1),k("")},Q=async()=>{if(!(!t||!V)){p(!0),y("");try{await M.leaveTeam(t.id),await a(),j("You have left the team."),f(null),J()}catch(Y){y(Y instanceof Error?Y.message:"Failed to leave team")}finally{p(!1)}}},te=t&&E?`${E}/dashboard/groups/${t.id}`:void 0,ee=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}),x&&n.jsx("div",{className:"alert alert-success",children:x}),t?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:t.name}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((z=u==null?void 0:u.members)==null?void 0:z.length)??0," ",(((oe=u==null?void 0:u.members)==null?void 0:oe.length)??0)===1?"member":"members",t.isAdmin&&" · You are admin"]})]}),n.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(ue=u==null?void 0:u.members)==null?void 0:ue.map(Y=>n.jsxs("div",{className:"member-row",children:[n.jsx("div",{className:"member-avatar",children:Y.name.split(" ").map(je=>je[0]).join("").slice(0,2).toUpperCase()}),n.jsxs("div",{className:"member-info",children:[n.jsx("div",{className:"member-name",children:Y.name}),n.jsx("div",{className:"member-email",children:Y.email})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Y.role})]},Y.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:[te&&n.jsx("a",{className:"btn btn-secondary btn-sm",href:te,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:F,disabled:g||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"}),ee&&n.jsx("a",{className:"btn btn-ghost btn-sm",href:ee,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),N&&t&&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:J,children:n.jsxs("div",{className:"card",onClick:Y=>Y.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 ",U,"?"]}),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:U})," to confirm:"]}),n.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:S,onChange:Y=>k(Y.target.value),placeholder:U,disabled:g,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:J,disabled:g,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:Q,disabled:!V,children:g?"Leaving...":"Leave team"})]})]})})]})}const ea=t=>t.replace(/@.*$/,"").split("/").pop()??t,oh=t=>t.split("@")[1]??"";function cj(t,s){const a=new Map;for(const o of t){const l=ea(o.id);if(!s.has(l))continue;const u=a.get(l);(!u||oh(o.id).localeCompare(oh(u.id),void 0,{numeric:!0})>0)&&a.set(l,o)}return a}function uj(t,s,a,o){var g;const l=new Set([...s.filter(p=>p.profile).map(p=>p.profile),...o.map(p=>ea(p.profile))]),u=cj(t,l),f=[];for(const p of s){const v=p.profile?u.get(p.profile):void 0;v&&f.push({key:`connector:${p.id}`,name:p.name,description:p.description||v.description,profile:v,kind:"connector",ready:((g=a.find(y=>y.id===p.id))==null?void 0:g.running)===!0,setupId:p.id,...p.intentHint?{intentHint:p.intentHint}:{}})}for(const p of o){const v=u.get(ea(p.profile));v&&f.push({key:`builtin:${p.id}`,name:p.name,description:p.description||v.description,profile:v,kind:"builtin",ready:p.available,unavailableReason:p.available?void 0:"Available only while simulation mode is on.",...p.intentHint?{intentHint:p.intentHint}:{}})}return f}function dj(t,s,a){if(s)return t.find(o=>ea(o.profile.id)===ea(s)&&o.ready&&a(o))}function fj({onDismiss:t,preselectProfileId:s}){const a=gn(),{group:o,groupId:l,domain:u,user:f}=yt(),[g,p]=h.useState([]),[v,y]=h.useState([]),[x,j]=h.useState([]),[N,b]=h.useState([]),[S,k]=h.useState(!0),[E,T]=h.useState({});h.useEffect(()=>{Promise.all([M.listProfiles().catch(()=>[]),M.getIntegrationManifests().then(Q=>Q.manifests??[]).catch(()=>[]),M.getMcpHealth().catch(()=>null)]).then(async([Q,te,ee])=>{if(p(Q),y(te),j((ee==null?void 0:ee.integrations)??[]),b((ee==null?void 0:ee.builtins)??[]),l){const z=await Promise.all(Q.map(ue=>M.getTeamProfileConfig(l,ue.id).catch(()=>null))),oe={};Q.forEach((ue,Y)=>{const je=z[Y];je&&(oe[ue.id]=je)}),T(oe)}}).finally(()=>k(!1))},[l]);const P=uj(g,v,x,N),I=Q=>{const te=E[Q.id];return Fm({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!S,grantors:te?Yh(te):void 0,userId:f==null?void 0:f.id,profileName:lt(Q.id),teamName:o==null?void 0:o.name})},U=Q=>Q in E,V=(Q,te)=>{if(!l){console.error("No active group when creating authorization");return}const ee=U(Q);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Q,groupId:l,groupName:(o==null?void 0:o.name)??null,domain:u,isTeam:ee,isPersonal:!!(o!=null&&o.isPersonal),...te?{intentHint:te}:{}})),sessionStorage.removeItem("agentGate"),t==null||t(),a("/mandates/new/intent")},F=(Q,te)=>{l&&V(Q,te)},J=h.useRef(!1);return h.useEffect(()=>{if(S||!s||J.current)return;const Q=dj(P,s,te=>I(te.profile).can);Q&&(J.current=!0,F(Q.profile.id,Q.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(ht,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>t==null?void 0:t(),children:"Go to Integrations"})]}):n.jsx("div",{className:"profile-grid",children:P.map(Q=>{const te=Q.profile,ee=U(te.id),z=I(te),oe=!Q.ready||!z.can,{icon:ue}=er(te.id,{name:te.name,icon:te.icon});return n.jsxs("div",{className:"card",style:oe?{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(Ac,{icon:ue,className:"profile-chip-icon"}),Q.name]}),ee?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:Q.description}),z.can?Q.ready?n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>F(te.id,Q.intentHint),children:"Give a mandate"}):Q.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:Q.unavailableReason})]}):n.jsxs(ht,{to:`/integrations?setup=${Q.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>t==null?void 0:t(),children:["Set up ",Q.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:[z.reason," ",n.jsx("span",{style:{color:"var(--text-tertiary)"},children:z.fix})]})]})]},Q.key)})})]})}const hj={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function mj({status:t,label:s}){return n.jsx("span",{className:`status-badge status-${t}`,children:s||hj[t]})}function pj({domain:t,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:t})}const wr=86400,Ys=3600,wi=60,gj=30*wr;function yj(t){if(t<=0)return"Expired";if(t>90*wr){const s=Math.floor(t/gj);return`${s} ${s===1?"month":"months"} remaining`}if(t>7*wr){const s=Math.floor(t/wr);return`${s} ${s===1?"day":"days"} remaining`}if(t>=2*wr){const s=Math.floor(t/wr),a=Math.floor(t%wr/Ys);return`${s} ${s===1?"day":"days"} ${a}h remaining`}if(t>=2*Ys){const s=Math.floor(t/Ys),a=Math.floor(t%Ys/wi);return`${s}h ${String(a).padStart(2,"0")}m remaining`}if(t>=wi){const s=Math.floor(t/wi),a=Math.floor(t%wi);return`${s}m ${String(a).padStart(2,"0")}s remaining`}return`${Math.floor(t)}s remaining`}function vj({expiresAt:t}){const[s,a]=h.useState(()=>t-Date.now()/1e3),o=s<2*Ys;h.useEffect(()=>{const u=setInterval(()=>a(t-Date.now()/1e3),o?1e3:6e4);return()=>clearInterval(u)},[t,o]);const l=s<300;return n.jsx("span",{className:`ttl-badge ${l?"ttl-warn":"ttl-ok"}`,children:yj(s)})}function es({icon:t,title:s,text:a,children:o}){return n.jsxs("div",{className:"empty-state",children:[t&&n.jsx("div",{className:"empty-state-icon",children:t}),n.jsx("div",{className:"empty-state-title",children:s}),a&&n.jsx("div",{className:"empty-state-text",children:a}),o]})}function xj(t){const s=Math.floor(t/86400);if(s>=1)return`${s} day${s===1?"":"s"}`;const a=Math.floor(t/3600);if(a>=1)return`${a} hour${a===1?"":"s"}`;const o=Math.ceil(t/60);return`${o} minute${o===1?"":"s"}`}const wj=[{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 jj({item:t,onClose:s,onSuccess:a}){var P;const{user:o,activeDomain:l,groupId:u}=yt(),[f,g]=h.useState(null);h.useEffect(()=>{let I=!1;return M.getProfile(t.profile_id).then(U=>{var V;I||g(((V=U==null?void 0:U.ttl)==null?void 0:V.max)??null)}).catch(()=>{}),()=>{I=!0}},[t.profile_id]);const p=t.remaining_seconds??0,v=wj.filter(I=>I.seconds>p&&(f===null||I.seconds<=f)),y=((P=v[0])==null?void 0:P.seconds)??2592e3,[x,j]=h.useState(y);h.useEffect(()=>{var I;if(f!==null&&x>f){const U=(I=v[v.length-1])==null?void 0:I.seconds;U&&j(U)}},[f]);const[N,b]=h.useState(!1),[S,k]=h.useState(""),E=Object.entries(t.frame).filter(([I])=>I!=="profile"&&I!=="path"),T=async()=>{var I;if(o){b(!0),k("");try{const U=t.authorization_id,V=await M.getGateContent(U);if(!V)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const F=await M.getProfile(t.profile_id),J=t.frame,Q=V.context??{},te=t.attested_domains[0]||l||"owner",ee=await ki(J,F),z=await $m(Q,F),[oe,ue]=await Promise.all([$i(V.gateContent.intent),$i(JSON.stringify({profile:t.profile_id,path:t.path,domain:te}))]);if(!u)throw new Error("No active group; cannot extend mandate.");const Y=(((I=t.deferred_commitment_domains)==null?void 0:I.length)??0)>0?"review":"automatic",je=await _m(F),xe=await M.attest({authorization_id:t.authorization_id,renew:!0,profile_id:t.profile_id,profile_hash:je,supported_versions:["0.7"],bounds:J,bounds_hash:ee,scope_hash:z,domain:te,did:o.did,mandate_owners:[{did:o.did}],gate_content_hashes:{intent:oe},execution_context_hash:ue,group_id:u,commitment_mode:Y,ttl:x});await M.pushGateContent(Lm(xe,{boundsHash:ee,contextHash:z,context:Q,path:t.path,gateContent:V.gateContent})),a()}catch(U){k(U instanceof Error?U.message:"Extension failed")}finally{b(!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:[lt(t.profile_id)," / ",t.path]}),E.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:E.map(([I,U])=>`${I}=${U}`).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"}),p>0&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",xj(p),". 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 ${x===I.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>j(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:N,children:"Cancel"}),n.jsx("button",{className:"btn btn-primary",onClick:T,disabled:N,children:N?"Extending...":"Extend"})]})]})})}function lh(t){return t.replace(/@.*$/,"").split("/").pop()??t}function ch(t){return t.split("@")[1]??""}function Sj(t,s){return ch(t).localeCompare(ch(s),void 0,{numeric:!0})>0}function Dm(t,s){const a=lh(t);let o;for(const l of s)lh(l.id)===a&&(!o||Sj(l.id,o.id))&&(o=l);return o}function Um(t,s){var o;if(!s)return{};const a={};for(const l of s.keyOrder){if(l==="profile"||l==="path")continue;if(t[l]!==void 0){a[l]=t[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 Wm(t,s){return Um(t,s.boundsSchema)}function Hm(t,s){return Um(t,s.scopeSchema)}function bj(t,s,a){return[...t].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=Ei(o,s),f=Ei(l,s),g={active:0,pending:1,expired:2,revoked:3,archived:4};return g[u]!==g[f]?g[u]-g[f]:new Date(l.created_at).getTime()-new Date(o.created_at).getTime()})}function kj({item:t,newerProfile:s,revokedSet:a,expandedHash:o,gateCache:l,gateLoading:u,copiedHash:f,revokingHash:g,copyingHash:p,profileConfigCache:v,mode:y,ownerLabel:x,isAdmin:j,onExpand:N,onCopyHash:b,onCopy:S,onRevoke:k,onExtend:E,archivedSet:T,archivingHash:P,onArchive:I,highlightHash:U,needsReapprovalSet:V}){var se;const F=jc(t,{revokedSet:a}),J=F==="active"&&((V==null?void 0:V.has(t.authorization_id))??!1),Q=em(t,{revokedSet:a,archivedSet:T}),te=!x&&!!I&&Zh(F),ee=o===t.authorization_id,z=l[t.authorization_id],oe=F==="active"||F==="pending"||F==="expired",ue=Object.entries(t.frame).filter(([be])=>be!=="profile"&&be!=="path"),Y=v.get(t.profile_id)??null,je=(((se=Y==null?void 0:Y.approvers)==null?void 0:se.length)??0)>0,xe=new Map;if(Y!=null&&Y.caps&&y==="team")for(const[be,Le]of ue){const ge=Y.caps[be];typeof ge=="number"&&Number(Le)>ge&&xe.set(be,{authorized:Number(Le),cap:ge})}const X=xe.size>0,q=t.approvers_frozen??[],G=(Y==null?void 0:Y.approvers)??[],A=y==="team"&&q.length>0&&G.length>0&&(q.length!==G.length||q.some(be=>!G.includes(be))||G.some(be=>!q.includes(be))),_=Array.from(xe.entries()).map(([be,Le])=>`${be}: ${Le.authorized} (cap ${Le.cap})`).join(", "),re=Array.from(xe.entries()).map(([be,Le])=>`${be}: ${Le.authorized} → ${Le.cap}`).join(", "),fe=X?je?xe.size===1?`Above team cap: ${_} — actions require approval`:`Above team cap (${xe.size}): ${_} — actions require approval`:xe.size===1?`Reduced by hard cap: ${re}`:`Reduced by hard cap (${xe.size}): ${re}`:"",L=X?je?"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,Z=er(t.profile_id),ie=Z.name,me=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:[ie,"@",s.version," available"]}),s.whatsNew?n.jsxs(n.Fragment,{children:[" — ",s.whatsNew]}):null,n.jsx("br",{}),n.jsxs("span",{children:["This mandate stays on ",t.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,pe=U!=null&&t.authorization_id===U;return n.jsx("div",{className:`card mandate-card${pe?" card-highlight":""}`,style:{marginBottom:0},children:n.jsxs("div",{className:"id-body",children:[n.jsx(br,{profileId:t.profile_id,area:lt(t.profile_id),time:t.created_at?`since ${new Date(t.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})}`:void 0}),me,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:t.title||ie}),n.jsx(mj,{status:F}),J&&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"}),Z.testSetup&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),F==="active"&&t.earliest_expiry&&n.jsx(vj,{expiresAt:new Date(t.earliest_expiry).getTime()/1e3}),F==="expired"&&(()=>{const be=ux(t,F);return be?n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(be.iso).toLocaleString()}`,children:new Date(be.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:[(t.required_domains.length>1||t.missing_domains.length>0)&&t.required_domains.map(be=>n.jsx(pj,{domain:be,attested:t.attested_domains.includes(be)},be)),t.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"}),X&&n.jsx("span",{title:L,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"transparent",color:"var(--text-primary)",border:je?"1px dashed var(--text-primary)":"2px solid var(--text-primary)",fontWeight:600,cursor:"help"},children:fe}),A&&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:()=>S(t),disabled:p===t.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:p===t.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),ue.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:ue.map(([be,Le],ge)=>{const $e=xe.get(be);return n.jsxs("span",{children:[ge>0&&" · ",$e?je?n.jsxs("span",{title:`Team cap on ${be} is ${$e.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${$e.authorized}.`,children:[n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[be,"=",String(Le)]}),n.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",$e.cap]})]}):n.jsxs("span",{title:`Team cap on ${be} is ${$e.cap} with no approvers configured (hard cap). Authorized for ${$e.authorized}; effective ${$e.cap}.`,children:[n.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[be,"=",String(Le)]}),n.jsxs("span",{style:{marginLeft:"0.25rem",fontWeight:700},children:["→"," ",$e.cap]})]}):n.jsxs("span",{children:[be,"=",String(Le)]})]},be)})}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[te&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>I(t.authorization_id,!Q),disabled:P===t.authorization_id,title:Q?"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:P===t.authorization_id?Q?"Unarchiving…":"Archiving…":Q?"↩ Unarchive":"⊟ Archive"}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>N(t),children:ee?"▲ Hide Details":"▼ Details"})]}),ee&&n.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[ue.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:ue.map(([be,Le])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:be}),n.jsx("dd",{children:String(Le)})]},be))})]}),(z==null?void 0:z.context)&&Object.keys(z.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(z.context).map(([be,Le])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:be}),n.jsx("dd",{title:String(Le),children:zm(be,Le,z.contextLabels)})]},be))})]}),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"}),u===t.authorization_id?n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):z?n.jsx("div",{className:"gate-content-block",children:n.jsx("div",{className:"gate-content-item",children:n.jsx("div",{className:"gate-content-text",children:z.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(t.created_at).toLocaleString(),t.earliest_expiry&&` · Expires: ${new Date(t.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:t.authorization_id}),n.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>b(t.authorization_id),children:f===t.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:()=>S(t),disabled:p===t.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:p===t.authorization_id?"Copying…":"⧉ Copy"}),!x&&(F==="active"||F==="pending")&&n.jsx("button",{className:J?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>S(t,{asEdit:!0}),disabled:p===t.authorization_id,title:J?"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:J?"⚠ Re-approve":"✎ Edit"}),!x&&oe&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>E(t),children:"↻ Extend"}),x&&j&&F!=="revoked"?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>k(t.authorization_id,x,ie),disabled:g===t.authorization_id,children:g===t.authorization_id?"Revoking…":"Revoke"}):!x&&(F==="active"||F==="pending")?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>k(t.authorization_id),disabled:g===t.authorization_id,children:g===t.authorization_id?"Revoking…":"Revoke"}):null]})]})]})},t.authorization_id)}function Nj(){const[t,s]=h.useState([]),[a,o]=h.useState(!0),[l,u]=h.useState([]),[f,g]=h.useState(!1),[p,v]=h.useState(new Map),[y,x]=h.useState("mine"),[j,N]=h.useState("active"),[b,S]=h.useState(null),[k,E]=h.useState(null),[T,P]=sa(),[I,U]=h.useState(()=>T.get("new")==="1"),[V]=h.useState(()=>T.get("profile")),[F,J]=h.useState(()=>T.get("highlight")),[Q,te]=h.useState(null),[ee,z]=h.useState({}),[oe,ue]=h.useState(null),[Y,je]=h.useState(null),[xe,X]=h.useState(null),[q,G]=h.useState(new Set),[A,_]=h.useState(null),[re,fe]=h.useState(new Set),[L,Z]=h.useState(null),[ie,me]=h.useState(null),[pe,se]=h.useState(new Set),be=gn(),{group:Le,groupId:ge,domain:$e,mode:qe,activeTeam:Ge}=yt(),Me=(Ge==null?void 0:Ge.isAdmin)===!0,[xt,Ze]=h.useState(()=>new Map),Xe=h.useCallback(()=>{o(!0),M.getMyAttestations().then(s).catch(()=>{}).finally(()=>o(!1))},[]),Je=h.useCallback(()=>{M.getArchivedMandates().then(le=>fe(new Set(le))).catch(()=>{})},[]);h.useEffect(()=>{Je()},[Je]);const wt=h.useCallback(()=>{M.getEnrichedAuthorizations().then(le=>se(new Set(le.filter(Ne=>Ne.needsReapproval).map(Ne=>Ne.authorizationId)))).catch(()=>{})},[]);h.useEffect(()=>{wt()},[wt]);const mt=async(le,Ne)=>{Z(le);try{const we=await M.setMandateArchived(le,Ne);fe(new Set(we)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(we){alert(we instanceof Error?we.message:"Failed to update archive")}finally{Z(null)}},ze=h.useCallback(()=>{ge&&(g(!0),M.listTeamAuthorizations(ge).then(u).catch(()=>{}).finally(()=>g(!1)))},[ge]);Be("attestation-changed",()=>{Xe(),Me&&ge&&ze(),wt()}),h.useEffect(()=>{if(!F)return;T.get("highlight")&&(T.delete("highlight"),P(T,{replace:!0}));const le=window.setTimeout(()=>J(null),3e3);return()=>window.clearTimeout(le)},[]),Lt(Xe,3e5),h.useEffect(()=>{y==="team"&&Me&&ge&&l.length===0&&!f&&ze()},[y,Me,ge,l.length,f,ze]),h.useEffect(()=>{let le=!1;return M.listProfiles().then(Ne=>{if(le)return;const we=tt=>tt.replace(/@.*$/,"").split("/").pop()??tt,De=tt=>tt.split("@")[1]??"",Oe=new Map;for(const tt of Ne){const Gt=we(tt.id),tr=Oe.get(Gt);(!tr||De(tt.id).localeCompare(De(tr.id),void 0,{numeric:!0})>0)&&Oe.set(Gt,tt)}v(Oe)}).catch(()=>{}),()=>{le=!0}},[]);const he=h.useCallback(le=>{const Ne=Gt=>Gt.replace(/@.*$/,"").split("/").pop()??Gt,we=Gt=>Gt.split("@")[1]??"",De=p.get(Ne(le));if(!De)return;const Oe=we(le),tt=we(De.id);if(!(!Oe||!tt))return tt.localeCompare(Oe,void 0,{numeric:!0})>0?De:void 0},[p]);h.useEffect(()=>{if(qe!=="team"||!ge)return;const le=y==="mine"?t:l;if(le.length===0)return;const Ne=[...new Set(le.map(we=>we.profile_id))].filter(we=>!xt.has(we));if(Ne.length!==0){Ze(we=>{const De=new Map(we);for(const Oe of Ne)De.set(Oe,null);return De});for(const we of Ne)M.getTeamProfileConfig(ge,we).then(De=>{Ze(Oe=>new Map(Oe).set(we,De))}).catch(()=>{})}},[t,l,y,ge,qe,xt]);const Pe=async le=>{if(Q===le.authorization_id){te(null);return}te(le.authorization_id);const Ne=le.authorization_id;if(!(Ne in ee)){ue(le.authorization_id);try{const we=await M.getGateContent(Ne);z(De=>({...De,[Ne]:we}))}catch{z(we=>({...we,[Ne]:null}))}finally{ue(null)}}},Fe=le=>{navigator.clipboard.writeText(le).then(()=>{X(le),setTimeout(()=>X(null),2e3)})},H=async(le,Ne)=>{var we;if(!ge){alert("No active group; cannot copy mandate.");return}me(le.authorization_id);try{const De=le.authorization_id;let Oe=ee[De]??null;De in ee||(Oe=await M.getGateContent(De),z(bn=>({...bn,[De]:Oe})));const tt=Object.fromEntries(Object.entries(le.frame).filter(([bn])=>bn!=="profile"&&bn!=="path")),Gt=(Oe==null?void 0:Oe.context)??{},tr=((we=Oe==null?void 0:Oe.gateContent)==null?void 0:we.intent)??"",is=le.deferred_commitment_domains.length>0?"review":"automatic",la=le.attested_domains[0]||$e||"owner",Sn=Date.parse(le.created_at),nr=le.earliest_expiry?Date.parse(le.earliest_expiry):NaN,rr=Number.isFinite(Sn)&&Number.isFinite(nr)&&nr>Sn?Math.round((nr-Sn)/1e3):void 0;let ca=le.profile_id,_n=tt,sr=Gt,ar;const os=await M.listProfiles(),Cr=Dm(le.profile_id,os);if(Cr&&Cr.id!==le.profile_id){const bn=await M.getProfile(Cr.id);ca=Cr.id,_n=Wm(tt,bn),sr=Hm(Gt,bn),ar=le.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ca,groupId:ge,groupName:(Le==null?void 0:Le.name)??null,domain:la,isPersonal:!!(Le!=null&&Le.isPersonal),upgradedFromProfileId:ar})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:_n,context:sr,gateContent:{intent:tr},templateMode:is,templateTtl:rr})),Ne!=null&&Ne.asEdit?sessionStorage.setItem("agentEditReplaces",le.authorization_id):sessionStorage.removeItem("agentEditReplaces"),be("/mandates/new/intent")}catch(De){alert(De instanceof Error?De.message:"Failed to copy mandate")}finally{me(null)}},K=async(le,Ne,we)=>{const De=Ne&&we?`Revoke ${Ne}'s ${we} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(De)){_(le);try{await M.revokeAttestation(le),G(Oe=>new Set(Oe).add(le)),M.resyncGates().catch(()=>{}),Ne&&ge&&ze()}catch(Oe){alert(Oe instanceof Error?Oe.message:"Failed to revoke mandate")}finally{_(null)}}},ye=y==="mine"?t:l,He=y==="mine"?a:f,Ue=y==="mine"?{revokedSet:q,archivedSet:re}:{revokedSet:q},st=le=>Ei(le,Ue),zt={active:0,pending:0,expired:0,revoked:0,archived:0};for(const le of ye)zt[st(le)]+=1;const Ft=y==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],B=(()=>{const le=new Map;for(const Ne of ye){if(st(Ne)!==j)continue;const we=le.get(Ne.profile_id)??{count:0,review:!1};we.count+=1,Ne.deferred_commitment_domains.length>0&&(we.review=!0),le.set(Ne.profile_id,we)}return Array.from(le.entries()).map(([Ne,we])=>({profileId:Ne,...we})).sort((Ne,we)=>lt(Ne.profileId).localeCompare(lt(we.profileId)))})(),ve=bj(ye.filter(le=>{if(st(le)!==j||b!==null&&le.profile_id!==b)return!1;if(k!==null){const Ne=le.deferred_commitment_domains.length>0;if(k==="review"&&!Ne||k==="auto"&&Ne)return!1}return!0}),Ue,F),Ie={revokedSet:q,expandedHash:Q,gateCache:ee,gateLoading:oe,copiedHash:xe,revokingHash:A,copyingHash:ie,profileConfigCache:xt,mode:qe,activeDomain:$e,group:Le,groupId:ge,onExpand:Pe,onCopyHash:Fe,onCopy:H,onRevoke:K,onExtend:je,highlightHash:F},et={...Ie,archivedSet:re,archivingHash:L,onArchive:mt,needsReapprovalSet:pe};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:()=>U(!0),children:"+ New mandate"})]}),I&&n.jsx("div",{className:"modal-backdrop",onClick:()=>{U(!1),(T.get("new")||T.get("profile"))&&(T.delete("new"),T.delete("profile"),P(T,{replace:!0}))},children:n.jsxs("div",{className:"modal",onClick:le=>le.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:()=>{U(!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(fj,{onDismiss:()=>U(!1),preselectProfileId:V})]})]})}),Me&&n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[n.jsx("button",{className:`nav-tab${y==="mine"?" active":""}`,onClick:()=>{x("mine"),N("active"),S(null),E(null),te(null)},children:"Mine"}),n.jsx("button",{className:`nav-tab${y==="team"?" active":""}`,onClick:()=>{x("team"),N("active"),S(null),E(null),te(null)},children:"Team"})]}),n.jsx("div",{className:"nav-tabs",children:Ft.map(le=>n.jsxs("button",{className:`nav-tab${j===le?" active":""}`,onClick:()=>{N(le),S(null),E(null)},children:[le.charAt(0).toUpperCase()+le.slice(1)," (",zt[le],")"]},le))}),B.length>0&&n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[B.map(le=>{const Ne=b===le.profileId;return n.jsx("button",{className:`btn btn-sm ${Ne?"btn-primary":"btn-secondary"}`,onClick:()=>S(Ne?null:le.profileId),children:lt(le.profileId)},le.profileId)}),n.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(le=>{const Ne=k===le;return n.jsx("button",{className:`btn btn-sm ${Ne?"btn-primary":"btn-secondary"}`,onClick:()=>E(Ne?null:le),children:le==="auto"?"Auto":"Review"},le)})]}),He&&ye.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ve.length===0?n.jsx(es,{icon:"☰",title:"No mandates",text:j==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${j} mandates found.`}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:ve.map(le=>{const Ne=y==="team"?le:null,we=Ne!=null&&Ne.owner?Ne.owner.name??Ne.owner.email??Ne.owner.userId:void 0;return n.jsx(kj,{item:le,newerProfile:he(le.profile_id),ownerLabel:we,isAdmin:Me,...y==="mine"?et:Ie},le.authorization_id)})}),Y&&n.jsx(jj,{item:Y,onClose:()=>je(null),onSuccess:()=>{je(null),Xe()}})]})}function sn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function _t(t,s=!1){return t==null?"—":typeof t=="string"?t:typeof t=="boolean"?String(t):typeof t=="number"?s||Number.isInteger(t)?String(t):String(Math.round(t*100)/100):"—"}function Cj(t){return t==null?!1:typeof t=="string"||Array.isArray(t)?t.length>0:!0}function Sr(t,s,a){const o=s?Object.keys(s).filter(l=>l in t):Object.keys(t);return o.length===0?"—":o.map(l=>{var p,v;const u=t[l],f=((p=s==null?void 0:s[l])==null?void 0:p.title)??Ht(l),g=sn(u)?Sr(u,(v=s==null?void 0:s[l])==null?void 0:v.properties,a):_t(u,a);return`${f}: ${g}`}).join(" · ")}function Ej(t,s){const a=s?Object.keys(s).filter(u=>t.some(f=>u in f)):[...new Set(t.flatMap(u=>Object.keys(u)))],o=a.map(u=>{var f;return{key:u,label:((f=s==null?void 0:s[u])==null?void 0:f.title)??Ht(u)}}),l=t.map(u=>({cells:a.map(f=>{var y,x;const g=u[f],p=sn(g)?Sr(g,(y=s==null?void 0:s[f])==null?void 0:y.properties,!1):_t(g),v=sn(g)?Sr(g,(x=s==null?void 0:s[f])==null?void 0:x.properties,!0):_t(g,!0);return v===p?{value:p,sealed:!1}:{value:p,valueTitle:v,sealed:!1}})}));return{columns:o,rows:l}}function Tj(t){return t.split(`
|
|
84
|
-
`).map(s=>s.startsWith("+")&&!s.startsWith("+++")?{text:s,kind:"add"}:s.startsWith("-")&&!s.startsWith("---")?{text:s,kind:"remove"}:{text:s,kind:"context"})}function Ij(t,s){var l;if(Array.isArray(t)){if(t.length===0)return{value:"—"};if(t.every(y=>!sn(y)&&!Array.isArray(y))){if(t.every(j=>typeof j=="string"))return{lines:t};const y=t.map(j=>_t(j)).join(", "),x=t.map(j=>_t(j,!0)).join(", ");return x===y?{value:y}:{value:y,valueTitle:x}}const u=(l=s==null?void 0:s.items)==null?void 0:l.properties,f=t.map(y=>sn(y)?Sr(y,u,!1):_t(y)),g=t.map(y=>sn(y)?Sr(y,u,!0):_t(y,!0)),p=f.map((y,x)=>y===g[x]?void 0:g[x]),v=t.every(sn)?Ej(t,u):void 0;return{lines:f,...p.some(y=>y!==void 0)?{lineTitles:p}:{},...v?{table:v}:{}}}if(sn(t)){const u=s==null?void 0:s.properties,f=u?Object.keys(u).filter(v=>v in t):Object.keys(t);if(f.length>0&&f.every(v=>!sn(t[v])&&!Array.isArray(t[v])))return{sublist:f.map(y=>{var S;const x=t[y],j=((S=u==null?void 0:u[y])==null?void 0:S.title)??Ht(y),N=_t(x),b=_t(x,!0);return b===N?{key:y,label:j,value:N}:{key:y,label:j,value:N,valueTitle:b}})};const g=Sr(t,u,!1),p=Sr(t,u,!0);return p===g?{value:g}:{value:g,valueTitle:p}}if(typeof t=="string"&&(s==null?void 0:s.contentMediaType)==="text/x-diff")return{diffLines:Tj(t)};const a=_t(t),o=_t(t,!0);return o===a?{value:a}:{value:a,valueTitle:o}}function Aj(t){let s;try{s=JSON.parse(t)}catch{return null}return sn(s)?s:null}function Nr(t){const s=t!=null&&t.structured&&Object.keys(t.structured).length>0?t.structured:void 0;if(s)return{obj:s,schema:t==null?void 0:t.outputSchema};const a=t!=null&&t.text?Aj(t.text):null;return a?{obj:a}:null}function Li(t){const s=Nr(t);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 g of u){if(!(g in a))continue;const p=l[g],v=(p==null?void 0:p.title)??Ht(g),y={key:g,label:v,...Ij(a[g],p)};p!=null&&p.description&&(y.description=p.description),f.push(y)}return f}function zi(t,s){const a=Nr(t);if(a){const l=Li(t),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=>Cj(a.obj[v.key]));const g=new Set(f.map(v=>v.key)),p=l.filter(v=>!g.has(v.key));return{kind:"structured",fields:f,moreFields:p,totalFields:l.length}}const o=t==null?void 0:t.text;return o&&o.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:o}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function uh(t){return t?t.lines?`lines:${JSON.stringify(t.lines)}`:t.sublist?`sublist:${JSON.stringify(t.sublist.map(s=>[s.key,s.value]))}`:t.diffLines?`diffLines:${JSON.stringify(t.diffLines)}`:`value:${t.value??""}`:""}function ji(t){return{kind:t.length>0?"structured":"empty",fields:t,moreFields:[],totalFields:t.length}}function Rj(t,s,a){const o=Nr(t),l=Nr(s);if(!o&&!l){const j=(t==null?void 0:t.text)??"",N=(s==null?void 0:s.text)??"";return j===N?{approved:ji([]),current:ji([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:j},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:N},unchanged:!1}}const u=new Map(Li(t).map(j=>[j.key,j])),f=new Map(Li(s).map(j=>[j.key,j])),p=[...new Set([...u.keys(),...f.keys()])].filter(j=>j===(a==null?void 0:a.excludeKey)?!1:uh(u.get(j))!==uh(f.get(j))),v=a!=null&&a.fields&&a.fields.length>0?[...a.fields.filter(j=>p.includes(j)),...p.filter(j=>!a.fields.includes(j))]:p,y=v.map(j=>u.get(j)).filter(j=>j!==void 0),x=v.map(j=>f.get(j)).filter(j=>j!==void 0);return{approved:ji(y),current:ji(x),unchanged:p.length===0}}function Pj(t){const s=t==null?void 0:t.structured;if(Array.isArray(s)&&s.every(sn))return s;if(t!=null&&t.text){let a;try{a=JSON.parse(t.text)}catch{return null}if(Array.isArray(a)&&a.every(sn))return a}return null}function Ki(t){const s=_t(t),a=_t(t,!0);return a===s?{value:s}:{value:s,valueTitle:a}}function Vm(t){return!t||t.status!=="ok"?[]:Li(t.body)}function Gm(t){if(!t)return"Not read.";switch(t.status){case"not_found":return"Not found in the system.";case"none":return"Nothing to read.";default:return"Not available right now."}}function Km(t,s,a){var p;const o=Vm(t);if(o.length===0)return{rawId:_t(s),context:[],unresolved:Gm(t)};const l=t&&t.status==="ok"?(p=Nr(t.body))==null?void 0:p.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,g=o.filter(v=>v.key!==(u==null?void 0:u.key)&&v.key!=="id").map(v=>{var b,S;if(!f)return v;const y=`${f}.${v.key}`,x=Xs(a==null?void 0:a.displayHints,y,v.label);if(!ta((b=a==null?void 0:a.displayHints)==null?void 0:b.money,y)&&!ta((S=a==null?void 0:a.displayHints)==null?void 0:S.percent,y))return x===v.label?v:{...v,label:x};const{value:j,valueTitle:N}=Fi(l==null?void 0:l[v.key],a==null?void 0:a.displayHints,y,a==null?void 0:a.currency);return{...v,label:x,value:j,valueTitle:N}});return{name:u==null?void 0:u.value,rawId:_t(s),context:g}}const $j=new Set(["id","name","title","label"]);function ta(t,s){return!!(t!=null&&t.includes(s))}function Xs(t,s,a){var o;return((o=t==null?void 0:t.labels)==null?void 0:o[s])??a}function _j(t,s){const a=typeof t=="number"?t:Number(t);return Number.isFinite(a)?{value:`${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${s?` ${s}`:""}`}:Ki(t)}function Lj(t){return typeof t!="number"&&typeof t!="string"?Ki(t):{value:`${t} %`}}function Fi(t,s,a,o){return ta(s==null?void 0:s.money,a)?_j(t,o):ta(s==null?void 0:s.percent,a)?Lj(t):Ki(t)}function qm(t,s){return ta(t==null?void 0:t.hidden,s)}function zj(t,s,a){var f;const o=t==null?void 0:t.currencyField;if(!o)return;const l=o.indexOf(".");if(l<0){const g=s[o];return typeof g=="string"?g: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 Fj(t,s,a,o){const l=t.forEach??"",u=t.attach,f=t.elements??[],g=Math.min(s.length,f.length),p=s.slice(0,g),v=f.slice(0,g),y=[...new Set(p.flatMap(S=>Object.keys(S)))].filter(S=>S!==t.sourceArg).filter(S=>!qm(a,`${l}[].${S}`)),x=new Map;if(u)for(const S of v)for(const k of Vm(S))x.has(k.key)||x.set(k.key,k.label);const j=u?[...x.keys()].filter(S=>!$j.has(S)):[],N=[];u&&N.push({key:`__attach:${u}`,label:Xs(a,`${l}[].${u}`,Ht(t.sourceArg??u))});for(const S of y)N.push({key:`bound:${S}`,label:Xs(a,`${l}[].${S}`,Ht(S))});for(const S of j)N.push({key:`attached:${S}`,label:Xs(a,`${l}[].${u}.${S}`,x.get(S)??Ht(S))});const b=p.map((S,k)=>{var I;const E=v[k],T=[];if(u){const U=Km(E,t.sourceArg?S[t.sourceArg]:void 0),V=U.name?`${U.name} (${U.rawId})`:U.unresolved?`${U.rawId} — ${U.unresolved}`:U.rawId;T.push({value:V,sealed:!1})}for(const U of y){const{value:V,valueTitle:F}=Fi(S[U],a,`${l}[].${U}`,o);T.push({value:V,valueTitle:F,sealed:!0})}const P=E&&E.status==="ok"?(I=Nr(E.body))==null?void 0:I.obj:void 0;for(const U of j){const V=P==null?void 0:P[U],{value:F,valueTitle:J}=V!==void 0?Fi(V,a,`${l}[].${u}.${U}`,o):{value:"—",valueTitle:void 0};T.push({value:F,valueTitle:J,sealed:!1})}return{cells:T}});return{columns:N,rows:b,...t.overflow?{overflowNote:`${t.overflow.total-t.overflow.shown} more not shown`}:{}}}function Mj(t){return`${Ht(t)} — from the system`}function Oj(t){const s=Mj(t.tool),a=t.result;if(!a||a.status!=="ok")return{heading:s,note:Gm(a)};const o=Pj(a.body);if(o){if(o.length===0)return{heading:s,note:"Nothing found."};const l=[...new Set(o.flatMap(g=>Object.keys(g)))],u=l.map(g=>({key:g,label:Ht(g)})),f=o.map(g=>({cells:l.map(p=>({...Ki(g[p]),sealed:!1}))}));return{heading:s,table:{columns:u,rows:f}}}return{heading:s,body:zi(a.body,{fields:t.fields})}}function Bj(t,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),g=zj(a,t,x=>{var N,b;const j=(N=o.get(x))==null?void 0:N.result;return j&&j.status==="ok"?(b=Nr(j.body))==null?void 0:b.obj:void 0}),p=(a==null?void 0:a.order)??[],v=[...new Set([...p,...Object.keys(t)])],y=[];for(const x of v){if(!(x in t)||qm(a,x))continue;const j=Xs(a,x,Ht(x)),N=l.get(x);if(N){const E=Array.isArray(t[x])?t[x]:[];y.push({kind:"table",key:x,label:j,table:Fj(N,E,a,g)});continue}const b=o.get(x);if(b){const E=Km(b.result,t[x],{pathPrefix:x,displayHints:a,currency:g});y.push({kind:"identity",key:x,label:j,identity:E});continue}const{value:S,valueTitle:k}=Fi(t[x],a,x,g);y.push({kind:"scalar",key:x,label:j,value:S,valueTitle:k})}return{rows:y,sections:u.map(Oj)}}function Dj(t){return t.offDevice?"off-device":t.boundContent===void 0?"none":t.hasHashToCheck?t.hashVerified===!0?"verified":"mismatch":"unchecked"}function Uj(t,s){return t===void 0?{kind:"empty",fields:[],moreFields:[],totalFields:0}:typeof t=="string"?zi({text:t}):zi({structured:t},{fields:s})}function Wj(t,s){return t?Object.entries(t).filter(([,a])=>a!=null&&a!=="").map(([a,o])=>({key:a,label:pm(a,s).label,value:String(o)})):[]}function Mi({table:t}){return t.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:t.columns.map(s=>n.jsx("th",{children:s.label},s.key))})}),n.jsx("tbody",{children:t.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))})]}),t.overflowNote&&n.jsx("p",{className:"preview-note",children:t.overflowNote})]})}function dh({row:t}){return n.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[t.label,t.description&&n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:t.description})]})}function Hj({row:t}){return t.sublist?n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:t.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))}):t.diffLines?n.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:t.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))}):t.table?n.jsx(Mi,{table:t.table}):t.lines?n.jsx("div",{children:t.lines.map((s,a)=>{var o;return n.jsx("div",{title:(o=t.lineTitles)==null?void 0:o[a],children:s},a)})}):n.jsx("span",{title:t.valueTitle,children:t.value})}function sc({rows:t}){return n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:t.map(s=>s.table?n.jsxs("div",{style:{gridColumn:"1 / -1"},children:[n.jsx(dh,{row:s}),n.jsx(Mi,{table:s.table})]},s.key):n.jsxs(h.Fragment,{children:[n.jsx(dh,{row:s}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:n.jsx(Hj,{row:s})})]},s.key))})}function Ni({rendered:t}){return t.kind==="empty"?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):t.kind==="text"?n.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:t.text}):n.jsxs(n.Fragment,{children:[n.jsx(sc,{rows:t.fields}),t.moreFields.length>0&&n.jsxs("details",{style:{fontSize:"0.8rem"},children:[n.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",t.totalFields,")"]}),n.jsx(sc,{rows:t.moreFields})]})]})}function Ym({receipt:t,profile:s}){var j;const[a,o]=h.useState(void 0),[l,u]=h.useState(null),f=!!(t.contentHash&&t.contentBinding);if(h.useEffect(()=>{let N=!0;return o(void 0),u(null),(async()=>{let b;try{b=await M.getArchivedReceipt(t.id)}catch{N&&o(null);return}let S=null;const k=b==null?void 0:b.entry.boundContent;if(k!==void 0&&f)try{S=await jm(t.contentBinding.kind,k)===t.contentHash}catch{S=!1}N&&(u(S),o(b))})(),()=>{N=!1}},[t.id,t.contentHash,t.contentBinding,f]),a===void 0)return n.jsx("div",{className:"ticket-done-box ticket-done-loading","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const g=a===null,p=a==null?void 0:a.entry.boundContent,v=Dj({offDevice:g,boundContent:p,hasHashToCheck:f,hashVerified:l});if(v==="off-device")return n.jsx("div",{className:"ticket-done-box ticket-done-off-device","data-testid":"ticket-what-was-done","data-bound":"off-device",children:n.jsx("p",{className:"ticket-done-note",children:"Content not on this device — only the signed values are shown."})});if(v==="none"){const N=Wj(t.executionContext,s);return n.jsxs("div",{className:"ticket-done-box","data-testid":"ticket-what-was-done","data-bound":"none",children:[n.jsx("h4",{children:"What was done"}),N.length>0?n.jsx("dl",{className:"ticket-done-fields",children:N.map(b=>n.jsxs("div",{className:"ticket-done-field-row",children:[n.jsx("dt",{children:b.label}),n.jsx("dd",{children:b.value})]},b.key))}):n.jsx("p",{className:"ticket-done-note",children:"No checked values recorded for this action."})]})}const y=Uj(p,(j=t.contentBinding)==null?void 0:j.fields),x=v==="verified"?"ticket-done-verified":v==="mismatch"?"ticket-done-mismatch":"ticket-done-unchecked";return n.jsxs("div",{className:`ticket-done-box ${x}`,"data-testid":"ticket-what-was-done","data-bound":v,children:[n.jsxs("h4",{children:["What was done",v!=="unchecked"&&n.jsxs(n.Fragment,{children:[" ",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]})]}),n.jsx(Ni,{rendered:y}),v==="verified"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ This exact content is bound by hash — any change after the fact would break the ticket."}),v==="mismatch"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This content does NOT match the ticket's signed hash — it may have been altered since archiving."}),v==="unchecked"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-neutral",children:"This content is kept on this device, but the ticket carries no content hash — it cannot be checked against the ticket."})]})}const fh=500;function ac(t){return t.length>fh?`${t.slice(0,fh)}…`:t}function hh(t){return t.length?t[0].toUpperCase()+t.slice(1):t}function Vj(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Jm(t,s,a){switch(t.status){case"none":return t.reason==="no_target"?{heading:"Nothing to read beforehand",note:`This action does not refer to an existing record — nothing to read beforehand. Showing exactly what will be sent to ${s}.`}:{heading:"No preview declared",note:`No preview declared for this tool — showing exactly what will be sent to ${s}.`};case"unavailable":return t.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:t.message?`Preview not available — ${ac(t.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:t.message?`Not found in your system — ${ac(t.message)}`:"Not found in your system."};case"ok":{if("reads"in t)return{heading:`What will be created in ${s}`,note:`Read by the gateway, not by the AI — read at ${Vj(t.readAt)}.`,creation:Bj(a??{},t.reads,t.display)};const o=zi(t.body,{fields:t.fields}),l={heading:`From ${s}, before it runs`,note:`Read by the gateway with ${t.tool} when you opened this card — the AI is not involved.`,rendered:o},u=t.version;if(u&&(l.versionNote=`You approve ${u.field} ${u.approved}; if it changes, ${s} refuses it.`,u.stale)){const f=Rj(t.body,u.currentBody,{fields:t.fields,excludeKey:u.field});l.stale={heading:`A newer ${u.field} exists (${u.current})`,approvedLabel:`${hh(u.field)} ${u.approved}`,currentLabel:`${hh(u.field)} ${u.current}`,...f.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:f.approved,currentRendered:f.current}}}return l}}}function Gj(t,s){if(t.state!=="failed")return null;const a=t.detail?ac(t.detail):void 0;return t.outcome==="changed"?{heading:"Changed since your approval",note:`The record changed in ${s} since you approved it — nothing was done. Ask the AI to request it again.`}:{heading:`Refused by ${s}`,note:`${s} refused it${a?`: ${a}`:""} — nothing was done. Ask the AI to request it again.`}}function Kj(t){return t!==null&&t!=="loading"&&t!=="ok"&&t!=="stale"}function qj({identity:t}){return t.unresolved?n.jsxs("span",{children:[n.jsx("span",{className:"id-raw",children:t.rawId})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["— ",t.unresolved]})]}):n.jsxs("span",{children:[t.name&&n.jsx("span",{className:"src-tag-value src-tag-system-cell",children:t.name})," ",n.jsx("span",{className:"id-raw",children:t.rawId}),t.context.length>0&&n.jsx("span",{className:"creation-context",children:t.context.map(s=>n.jsxs("span",{children:[" · ",s.label," ",s.value]},s.key))})]})}function Yj({view:t}){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:t.rows.map(s=>s.kind==="table"?null:n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:s.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:s.kind==="identity"?n.jsx(qj,{identity:s.identity}):n.jsx("span",{className:"src-tag-value src-tag-sealed-cell",title:s.valueTitle,children:s.value})})]},s.key))}),t.rows.filter(s=>s.kind==="table").map(s=>n.jsxs("div",{style:{margin:"0.5rem 0"},children:[n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:s.label}),n.jsx(Mi,{table:s.table})]},s.key)),t.sections.map((s,a)=>n.jsxs("div",{className:"creation-own-section",children:[n.jsxs("h5",{children:[s.heading," ",n.jsx("span",{className:"src-tag src-tag-system",children:"from the system"})]}),s.table&&n.jsx(Mi,{table:s.table}),s.body&&n.jsx(sc,{rows:s.body.fields}),s.note&&n.jsx("p",{className:"preview-note",children:s.note})]},a))]})}function Qm({resp:t,systemName:s,toolArgs:a,sealed:o}){const l=Jm(t,s,a??void 0),u=t.status==="ok"?l.stale?"stale":"ok":t.status;return u==="none"?n.jsx("p",{className:"preview-note","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(Yj,{view:l.creation}),l.rendered&&n.jsx(Ni,{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(Ni,{rendered:l.stale.approvedRendered})}),n.jsx("dt",{children:l.stale.currentLabel}),n.jsx("dd",{children:n.jsx(Ni,{rendered:l.stale.currentRendered})})]})]})]})}function Jj({proposalId:t,systemName:s,toolArgs:a,sealed:o,onTone:l,onData:u}){const[f,g]=h.useState(null),[p,v]=h.useState(!1);return h.useEffect(()=>{let y=!0;return g(null),v(!1),M.getProposalPreview(t).then(x=>{y&&g(x)}).catch(()=>{y&&v(!0)}),()=>{y=!1}},[t]),h.useEffect(()=>{if(p){l==null||l("unavailable"),u==null||u({status:"unavailable",reason:"connector_error"});return}if(!f){u==null||u(null);return}const y=Jm(f,s,a??void 0);l==null||l(f.status==="ok"?y.stale?"stale":"ok":f.status),u==null||u(f)},[f,p,s,l,u]),p?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(Qm,{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 Ul=6;function Oi(t){if(!t)return;const s=Date.parse(t);return Number.isNaN(s)?t:new Date(s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Qj(t){if(!t)return{first:""};const s=t.split(`
|
|
85
|
-
`);return s.length<=Ul?{first:t}:{first:s.slice(0,Ul).join(`
|
|
86
|
-
`),more:s.slice(Ul).join(`
|
|
87
|
-
`)}}const Xj="Linked by the AI",Zj="linked automatically — this action already carried a reference to it";function eS(t){if(t.status==="none")return{state:"none",note:"No request linked.",chain:[]};if(t.status==="unreadable")return{state:"unreadable",note:`Request: link not readable (${t.reason}).`,chain:[]};if(t.status==="not_found")return{state:"not_found",note:"Request: this message no longer exists.",chain:[]};const{first:s,more:a}=Qj(t.body),o=[t.connector,t.kind,t.author?`from ${t.author}`:void 0,Oi(t.at)].filter(l=>!!l);return{state:"ok",implicit:t.implicit,tag:Xj,...t.implicit?{implicitNote:Zj}:{},metaLine:o.join(" · "),title:t.title,bodyFirst:s,bodyMore:a,attribution:t.author?`— from ${t.author}, not checked`:void 0,chain:t.chain.map(l=>({...l,at:Oi(l.at)}))}}const Vs="Read by the gateway — same customer, not matched to this request";function tS(t){const s=t.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${t.matchedKeyValue} (${s})`}function nS(t){var l;const s=!!t.aiWritten,a=s?"Activity":t.type??t.kind??"Entry";let o;if(s){const u=((l=t.aiWritten)==null?void 0:l.at)!==void 0?Oi(new Date(t.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=t.author?`— from ${t.author}, not checked`:"— not checked";return{headLabel:a,at:Oi(t.at),title:t.title,body:t.body,attribution:o,aiWritten:s}}function rS(t){if(t.status==="no_customer_link")return{state:"no_customer_link",label:Vs,note:"No customer link — nothing to match history against.",matchNotes:[],items:[]};if(t.status==="no_match")return{state:"no_match",label:Vs,note:"No match — no connector here matches on this customer's available identity key.",matchNotes:[],items:[]};if(t.status==="unreachable")return{state:"unreachable",label:Vs,note:`${t.connectorIds.join(", ")} not reachable — history could not be read.`,matchNotes:[],items:[]};const s=t.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})=>nS(l)),a=t.matches.map(tS),o=t.unreachableConnectorIds.length>0?`${t.unreachableConnectorIds.join(", ")} not reachable — showing what could be read.`:void 0;return s.length===0?{state:"empty",label:Vs,note:"Nothing in the last few days.",matchNotes:a,items:[],unreachableNote:o}:{state:"ok",label:Vs,note:"",matchNotes:a,items:s,unreachableNote:o}}function Xm({resp:t}){const s=eS(t.request),a=rS(t.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 sS({proposalId:t,onData:s}){const[a,o]=h.useState(null),[l,u]=h.useState(!1);return h.useEffect(()=>{let f=!0;return o(null),u(!1),M.getProposalRequestContext(t).then(g=>{f&&o(g)}).catch(()=>{f&&u(!0)}),()=>{f=!1}},[t]),h.useEffect(()=>{s==null||s(l?null:a)},[a,l,s]),l||!a?null:n.jsx(Xm,{resp:a})}function aS(t,s,a){const o=Object.entries(t??{});if(o.length===0)return{entry:void 0,otherCount:0};const u=o.find(([,g])=>g.by===s)??(a?o.find(([g])=>g===`domain:${a}`):void 0),f=u?o.length-1:o.length;return{entry:u==null?void 0:u[1],otherCount:f}}function iS(t){return t.offDevice?"off-device":t.recordedHash?t.localHash===t.recordedHash?"verified":"mismatch":"unchecked"}function oS(t){if(!(t<=0))return`${t} other approver${t===1?"":"s"} recorded their own.`}function lS(t){return new Date(t).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function Zm({proposalId:t,tool:s,manifests:a}){const{user:o,domain:l}=yt(),[u,f]=h.useState(null),[g,p]=h.useState(null),[v,y]=h.useState(!1);if(h.useEffect(()=>{let P=!0;return f(null),p(null),y(!1),Promise.all([M.getShownSnapshot(t),M.getProposal(t)]).then(([I,U])=>{P&&(f(I),p(U))}).catch(()=>{P&&y(!0)}),()=>{P=!1}},[t]),v||!u||!g)return null;const x=u.status==="off_device",{entry:j,otherCount:N}=aS(g.shownHashes,(o==null?void 0:o.id)??"",l),b=iS({offDevice:x,recordedHash:j==null?void 0:j.hash,localHash:u.status==="ok"?u.shownHash:void 0}),S=oS(N);if(x)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}=as(s),T=aa(E,a);return n.jsxs("div",{className:`ticket-box ticket-shown-${b}`,"data-testid":"au10-shown","data-shown-status":b,children:[n.jsxs("h4",{children:["What you saw (read ",lS(k.readAt),")",b==="verified"&&n.jsx("span",{className:"src-tag src-tag-sealed",children:"verified"}),b==="mismatch"&&n.jsx("span",{className:"src-tag src-tag-danger",children:"does not match what was approved"})]}),n.jsx(Qm,{resp:k.preview,systemName:T,toolArgs:k.toolArgs,sealed:k.sealed}),n.jsx(Xm,{resp:k.requestContext}),b==="verified"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ Matches the fingerprint recorded with your approval."}),b==="mismatch"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This copy differs from the fingerprint recorded with your approval."}),b==="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 Gs({label:t,children:s}){return n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"receipt-row-label",children:t}),n.jsx("dd",{className:"receipt-row-value",children:s})]})}function cS({receipt:t,manifests:s,localAuth:a,localUnavailable:o,signature:l,grantTitle:u,ownerLabel:f,spUrl:g,formatDate:p,onOpenComplete:v,isNew:y=!1,defaultOpen:x=!1}){var Q;const j=ss(t.profileId),N=$0(t,j),b=_0(a==null?void 0:a.context,j),S=z0(t,(a==null?void 0:a.bounds)??t.limits,j),k=a==null?void 0:a.intent,E=er(t.profileId).testSetup||Gi(t.action),[T,P]=h.useState(!1),[I,U]=h.useState(x),V=Date.now(),F=ia(t.authorizationId,t.profileId,u?{[t.authorizationId??""]:u}:{}),J=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:()=>U(te=>!te),children:[n.jsx(br,{profileId:t.profileId,area:F,system:oa(t.action,s),time:Ai(t.timestamp,V),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",children:Tc(t,s)}),n.jsx("span",{className:"receipt-tag",children:Ti(t)?"approved":"automatic"}),t.contentHash&&n.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(Q=t.contentBinding)!=null&&Q.fields?`The ticket binds: ${t.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),E&&n.jsx("span",{className:"sim-mark",children:"Test setup"})]}),N&&n.jsx("div",{className:"receipt-scope",children:N})]}),I&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"receipt-when",children:p(t.timestamp)}),n.jsx(Ym,{receipt:t,profile:j}),t.proposalId&&n.jsx(Zm,{proposalId:t.proposalId,tool:t.action,manifests:s}),n.jsxs("dl",{className:"receipt-rows",children:[n.jsxs(Gs,{label:"mandate",children:[n.jsx("strong",{children:u||M0(t.profileId)})," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),f&&n.jsx(Gs,{label:"owner",children:f}),b&&n.jsxs(Gs,{label:"allowed",children:[b," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),S&&n.jsxs(Gs,{label:"used",children:[n.jsx("span",{className:"receipt-num",children:S})," ",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx(Gs,{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"}),g&&n.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",n.jsx("a",{className:"receipt-link",href:`${g}/r/${t.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 · ",t.id]}),n.jsxs("div",{children:["action · ",t.action]}),n.jsxs("div",{children:["profile · ",t.profileId]}),t.authorizationId&&n.jsxs("div",{children:["mandate · ",t.authorizationId]}),Object.keys(t.executionContext??{}).length>0&&n.jsxs("div",{children:["scope ·"," ",Object.entries(t.executionContext).map(([te,ee])=>`${te}=${ee}`).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]}),t.contentHash&&n.jsxs("div",{children:["content · ",t.contentHash]}),t.proposalId&&n.jsxs("div",{children:["proposal · ",t.proposalId]}),n.jsxs("div",{children:["signature · ",t.signature]})]})]})]})]}),n.jsxs("div",{className:"ticket-obj-stub",children:[n.jsx("span",{className:"ticket-obj-no",title:t.id,children:wm(t.id)}),n.jsx("span",{className:"ticket-obj-time",children:Ai(t.timestamp,V)}),J&&n.jsx("span",{className:"ticket-obj-sig",title:"Signature checked on this device",children:"✓ verified"})]})]})}function uS({receipt:t,onClose:s}){const[a,o]=h.useState(null),[l,u]=h.useState(null),[f,g]=h.useState(null),[p,v]=h.useState(!0),[y,x]=h.useState(!1);h.useEffect(()=>{let k=!1;return v(!0),M.getArchivedReceipt(t.id).then(E=>{k||(o(E),u(E?"local":"authority-server"),g((E==null?void 0:E.signature)??null))}).catch(()=>{k||u("authority-server")}).finally(()=>{k||v(!1)}),()=>{k=!0}},[t.id]);const j=a?a.entry:{receipt:t},N=JSON.stringify(j,null,2);function b(){const k=URL.createObjectURL(new Blob([N],{type:"application/json"})),E=document.createElement("a");E.href=k,E.download=`suveren-ticket-${t.id.slice(0,8)}.json`,E.click(),URL.revokeObjectURL(k)}async function S(){try{await navigator.clipboard.writeText(N),x(!0),setTimeout(()=>x(!1),2e3)}catch{x(!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:p?"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:N})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:b,children:"Download"}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:S,children:y?"Copied":"Copy"})]})]})})}function dS(t){return new Date(t*1e3).toLocaleString()}function fS(t,s){if(s==="all")return!0;const a=s==="1d"?1:s==="7d"?7:30,o=Math.floor(Date.now()/1e3)-a*86400;return t.timestamp>=o}function hS(t,s){if(!s)return!0;const a=s.toLowerCase();return t.profileId.toLowerCase().includes(a)||lt(t.profileId).toLowerCase().includes(a)||t.path.toLowerCase().includes(a)||t.action.toLowerCase().includes(a)||t.attestationHash.toLowerCase().includes(a)||t.id.toLowerCase().includes(a)||JSON.stringify(t.executionContext).toLowerCase().includes(a)}function mh(t,s){const a=new Map(t.map(o=>[o.id,o]));for(const o of s)a.set(o.id,o);return[...a.values()].sort((o,l)=>l.timestamp-o.timestamp)}function mS(){const{activeTeam:t,groupId:s}=yt(),a=(t==null?void 0:t.isAdmin)===!0,[o,l]=h.useState("mine"),[u,f]=sa(),g=B0(u.get("filter")),p=B=>{const ve=new URLSearchParams(u);B==="all"?ve.delete("filter"):ve.set("filter",B),f(ve,{replace:!0})},[v,y]=h.useState(null),x=h.useRef(!1),[j,N]=h.useState([]),[b,S]=h.useState([]),[k,E]=h.useState(""),[T,P]=h.useState(!0),[I,U]=h.useState({}),[V,F]=h.useState(new Set),[J,Q]=h.useState(""),[te,ee]=h.useState(new Set),[z,oe]=h.useState(new Set),[ue,Y]=h.useState("all"),[je,xe]=h.useState(!1),[X,q]=h.useState(!1),[G,A]=h.useState(null),[_,re]=h.useState({}),[fe,L]=h.useState(!1),[Z,ie]=h.useState({}),[me,pe]=h.useState({}),[se,be]=h.useState(null),[Le,ge]=h.useState(null),[$e,qe]=h.useState(!1),[Ge,Me]=h.useState(!1),xt=h.useRef(""),Ze=h.useCallback(B=>o==="team"&&a&&s?M.listTeamReceiptsPage(s,{before:B,limit:200}):M.getMyReceiptsPage({before:B,limit:200}),[o,a,s]),Xe=h.useCallback(()=>{const B=o==="team"?`team:${s}`:"mine",ve=xt.current!==B;xt.current=B,P(!0),Me(!1),Ze().then(Ie=>{N(et=>ve?Ie.receipts:mh(et,Ie.receipts)),ge(et=>ve?Ie.nextBefore:et??Ie.nextBefore)}).catch(()=>{ve&&N([]),Me(!0)}).finally(()=>P(!1))},[Ze,o,s]),Je=h.useCallback(()=>{!Le||$e||(qe(!0),Me(!1),Ze(Le).then(B=>{N(ve=>mh(ve,B.receipts)),ge(B.nextBefore)}).catch(()=>Me(!0)).finally(()=>qe(!1)))},[Le,$e,Ze]);Lt(Xe,12e4);const wt=h.useCallback(()=>{Xe(),v!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||M.markTicketsSeen(Date.now()).catch(()=>{}))},[Xe,v]);Be("ticket-recorded",wt),h.useEffect(()=>{T||x.current||(x.current=!0,M.getLastSeenTicketsAt().then(B=>(y(B),M.markTicketsSeen(Date.now()))).catch(()=>y(Number.POSITIVE_INFINITY)))},[T]),h.useEffect(()=>{M.getIntegrationManifests().then(({manifests:B})=>S(B)).catch(()=>{}),fetch("/health").then(B=>B.json()).then(B=>{typeof B.spUrl=="string"&&E(B.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),h.useEffect(()=>{M.getLocalAuthorizations().then(({authorizations:B,signatures:ve})=>{re(B),ie(ve),L(!1)}).catch(()=>{re({}),ie({}),L(!0)}),M.getMyAttestations().then(B=>{const ve={};for(const Ie of B)Ie.authorization_id&&Ie.title&&(ve[Ie.authorization_id]=Ie.title);pe(ve)}).catch(()=>{})},[]),h.useEffect(()=>{o!=="team"||Object.keys(I).length>0||M.listUsers().then(B=>{const ve={};for(const Ie of B)ve[Ie.id]={name:Ie.name,email:Ie.email};U(ve)}).catch(()=>{})},[o,I]);const mt=h.useMemo(()=>{const B=new Set;for(const ve of j)B.add(lt(ve.profileId));return[...B].sort()},[j]),ze=h.useMemo(()=>{const B=new Set;for(const ve of j)B.add(ve.action);return[...B].sort()},[j]),he=h.useMemo(()=>{if(o!=="team")return[];const B=new Set;for(const ve of j)ve.userId&&B.add(ve.userId);return[...B].map(ve=>{var Ie;return{id:ve,label:(Ie=I[ve])!=null&&Ie.name?`${I[ve].name} (${I[ve].email})`:ve}}).sort((ve,Ie)=>ve.label.localeCompare(Ie.label))},[o,j,I]),Pe=h.useMemo(()=>j.filter(B=>!(!hS(B,J)||te.size>0&&!te.has(lt(B.profileId))||z.size>0&&!z.has(B.action)||V.size>0&&B.userId&&!V.has(B.userId)||!fS(B,ue))),[j,J,te,z,V,ue]),Fe=h.useMemo(()=>{const B={automatic:0,approved:0,all:0};for(const ve of Pe)B.all+=1,B[ec(ve,"approved")?"approved":"automatic"]+=1;return B},[Pe]),H=h.useMemo(()=>Pe.filter(B=>ec(B,g)),[Pe,g]),K=h.useMemo(()=>v===null?0:H.filter(B=>Ii(B,v)).length,[H,v]),ye=te.size>0||z.size>0||V.size>0||ue!=="all";function He(B){ee(ve=>{const Ie=new Set(ve);return Ie.has(B)?Ie.delete(B):Ie.add(B),Ie})}function Ue(B){oe(ve=>{const Ie=new Set(ve);return Ie.has(B)?Ie.delete(B):Ie.add(B),Ie})}function st(B){F(ve=>{const Ie=new Set(ve);return Ie.has(B)?Ie.delete(B):Ie.add(B),Ie})}function zt(){ee(new Set),oe(new Set),F(new Set),Y("all"),Q("")}async function Ft(){q(!0),A(null);try{const{bundle:B,filename:ve}=await M.fetchEvidenceBundle(),Ie=URL.createObjectURL(new Blob([JSON.stringify(B,null,2)],{type:"application/json"})),et=document.createElement("a");et.href=Ie,et.download=ve,et.click(),URL.revokeObjectURL(Ie);const le=B.sources??{};le.authorityServer?le.local||A(`Downloaded Authority Server history only — ${le.localError??"local archive unavailable."}`):A(`Downloaded local evidence only — ${le.asError??"Authority Server export unavailable."}`)}catch(B){A(`Export failed: ${B instanceof Error?B.message:String(B)}`)}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.",K>0&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("b",{"data-testid":"tickets-new-count",children:[K," new since your last visit"]})]})]})]}),n.jsx("button",{className:"btn btn-secondary",onClick:Ft,disabled:X,children:X?"Preparing…":"Download evidence"})]}),G&&n.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:G}),a&&n.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(B=>n.jsx("button",{onClick:()=>l(B),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:o===B?"2px solid var(--accent)":"2px solid transparent",color:o===B?"var(--text-primary)":"var(--text-tertiary)",fontWeight:o===B?600:500},children:B==="mine"?"Mine":"Team"},B))}),n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which tickets",children:O0.map(B=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`tickets-filter-${B}`,"aria-selected":g===B,onClick:()=>p(B),children:[B==="automatic"?"Automatic":B==="approved"?"Approved":"All",n.jsx("span",{className:"n",children:Fe[B]})]},B))}),g==="automatic"&&n.jsx("p",{className:"page-subtitle",style:{marginTop:"-0.25rem"},children:'Automatic — no person approved these. Approved tickets are under "Approved".'}),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",placeholder:"Search by profile, action, path, or hash…",value:J,onChange:B=>Q(B.target.value)}),J&&n.jsx("button",{className:"search-clear",onClick:()=>Q(""),children:"×"})]}),n.jsxs("button",{className:`btn btn-sm btn-secondary${je?" active":""}`,onClick:()=>xe(!je),children:["Filters",ye?` (${te.size+z.size+(ue!=="all"?1:0)})`:""]})]}),je&&n.jsxs("div",{className:"filter-panel",children:[mt.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Profile"}),n.jsx("div",{className:"filter-chips",children:mt.map(B=>n.jsx("button",{className:`filter-chip${te.has(B)?" selected":""}`,onClick:()=>He(B),children:B},B))})]}),ze.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Action"}),n.jsx("div",{className:"filter-chips",children:ze.map(B=>n.jsx("button",{className:`filter-chip${z.has(B)?" selected":""}`,onClick:()=>Ue(B),children:B},B))})]}),o==="team"&&he.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Owner"}),n.jsx("div",{className:"filter-chips",children:he.map(B=>n.jsx("button",{className:`filter-chip${V.has(B.id)?" selected":""}`,onClick:()=>st(B.id),children:B.label},B.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(([B,ve])=>n.jsx("button",{className:`filter-chip${ue===B?" selected":""}`,onClick:()=>Y(B),children:ve},B))})]})]}),ye&&n.jsxs("div",{className:"active-filters",children:[[...te].map(B=>n.jsxs("span",{className:"active-chip",onClick:()=>He(B),children:[B," ",n.jsx("span",{className:"chip-remove",children:"×"})]},B)),[...z].map(B=>n.jsxs("span",{className:"active-chip",onClick:()=>Ue(B),children:[B," ",n.jsx("span",{className:"chip-remove",children:"×"})]},B)),[...V].map(B=>{const ve=I[B],Ie=ve?ve.name:B;return n.jsxs("span",{className:"active-chip",onClick:()=>st(B),children:[Ie," ",n.jsx("span",{className:"chip-remove",children:"×"})]},B)}),ue!=="all"&&n.jsxs("span",{className:"active-chip",onClick:()=>Y("all"),children:[ue==="1d"?"Today":ue==="7d"?"7 days":"30 days"," ",n.jsx("span",{className:"chip-remove",children:"×"})]}),n.jsx("button",{className:"clear-filters",onClick:zt,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."})}),T&&j.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):H.length===0?n.jsx(es,{icon:"⌕",title:j.length===0?"No tickets in the last 30 days":"No matching tickets",text:j.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:H.length===j.length?`${j.length} ticket${j.length!==1?"s":""}`:`${H.length} of ${j.length} tickets`}),n.jsx("div",{className:"timeline",children:H.map(B=>{const ve=B.userId?I[B.userId]:void 0;return n.jsx("div",{className:"timeline-event",children:n.jsx(cS,{receipt:B,manifests:b,localAuth:B.authorizationId?_[B.authorizationId]:void 0,localUnavailable:fe,signature:Z[B.id],grantTitle:B.authorizationId?me[B.authorizationId]:null,ownerLabel:o==="team"&&B.userId?ve?`${ve.name} (${ve.email})`:B.userId:null,spUrl:k,formatDate:dS,onOpenComplete:()=>be(B),isNew:v!==null&&Ii(B,v),defaultOpen:H.length===1})},B.id)})})]}),se&&n.jsx(uS,{receipt:se,onClose:()=>be(null)}),Le&&n.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:Je,disabled:$e,children:$e?"Loading…":"Load older"})})]})}function pS(){const[t,s]=h.useState(null),[a,o]=h.useState({}),[l,u]=h.useState(!1),[f,g]=h.useState({}),p=h.useCallback(()=>{M.getMyAttestations().then(S=>{const k={};for(const E of S)E.title&&(k[E.authorization_id]=E.title);g(k)}).catch(()=>{})},[]);h.useEffect(()=>{p()},[p]),Lt(p,3e5);const[v,y]=h.useState(null),x=h.useRef(!1),j=h.useCallback(()=>{M.getDenials({limit:200}).then(({records:S})=>{s(S),u(!1)}).catch(()=>u(!0))},[]);h.useEffect(()=>{j()},[j]),Lt(j,6e4),h.useEffect(()=>{if(!t)return;const S=[...new Set(t.map(k=>k.profile).filter(k=>!!k))].filter(k=>!(k in a));S.length!==0&&Promise.all(S.map(k=>M.getProfile(k).catch(()=>null))).then(k=>{o(E=>{const T={...E};return S.forEach((P,I)=>{k[I]&&(T[P]=k[I])}),T})})},[t,a]),h.useEffect(()=>{!t||x.current||(x.current=!0,M.getLastSeenBlockedAt().then(S=>(y(S),M.markBlockedSeen(Date.now()))).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[t]);const N=h.useCallback(()=>{j(),p(),v!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||M.markBlockedSeen(Date.now()).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[j,p,v]);if(Be("denial-recorded",N),l)return n.jsx(es,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(t===null)return null;const b=$x(t,Date.now());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:[b," today · nothing ran"]})]}),t.length===0?n.jsx(es,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):n.jsx("div",{className:"blocked-list",children:t.map((S,k)=>{const E=Px(S,S.profile?a[S.profile]:void 0,f),T=v!==null&&S.ts>v;return n.jsx("div",{className:"card blocked-item blocked-card","data-seen":T?"false":"true",children:n.jsxs("div",{className:"id-body",children:[n.jsx(br,{profileId:S.profile??S.integrationId,area:lt(S.profile??S.integrationId),system:S.integrationId?aa(S.integrationId,void 0):void 0,time:zx(S.ts,Date.now()),trailing:T?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-${Hi(S)}`,"aria-hidden":"true"}),n.jsx("span",{className:"blocked-title",children:E.title})]}),n.jsx("div",{className:"blocked-sentence",children:E.sentence}),n.jsx("div",{className:"blocked-source",children:E.sourceLine.map((P,I)=>P.dim?n.jsx("span",{className:"mandate-id",children:P.text},I):n.jsx("span",{children:P.text},I))}),n.jsxs("details",{children:[n.jsx("summary",{children:"What you can do"}),n.jsx("div",{className:"blocked-advice",children:E.whatYouCanDo})]})]})},`${S.ts}-${k}`)})})]})}const gS={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function yS(){const[t,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{s(await M.getAutostart())}catch(v){u(v instanceof Error?v.message:"Could not read autostart state")}},[]);h.useEffect(()=>{f()},[f]);const g=h.useCallback(async()=>{if(!(!(t!=null&&t.supported)||a)){o(!0),u(null);try{await M.setAutostart(!t.installed)}catch(v){u(v instanceof Error?v.message:"Failed")}finally{try{s(await M.getAutostart()),u(null)}catch(v){u(v instanceof Error?v.message:"Could not re-read state")}o(!1)}}},[t,a,f]);if(!t)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 p=gS[t.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:t.supported?n.jsxs(n.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",p," — no admin rights needed."]}):t.reason})]}),t.supported&&n.jsx("button",{type:"button",onClick:()=>void g(),disabled:a,"aria-pressed":t.installed,className:t.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Working…":t.installed?"Turn off":"Turn on"})]}),t.supported&&n.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",n.jsx("strong",{children:t.installed?"On — starts from your next login":"Off"})]}),t.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 vS(){const[t,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{const p=await M.getGatewaySettings();s(p.desktopNotifications),u(null)}catch(p){u(p instanceof Error?p.message:"Could not read notification setting")}},[]);h.useEffect(()=>{f()},[f]);const g=h.useCallback(async()=>{if(!(t===null||a)){o(!0),u(null);try{const p=await M.setGatewaySettings({desktopNotifications:!t});s(p.desktopNotifications)}catch(p){u(p instanceof Error?p.message:"Failed to save"),await f()}finally{o(!1)}}},[t,a,f]);return t===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 g(),disabled:a,"aria-pressed":t,className:t?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":t?"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 ph={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function xS(){const[t,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{s(await M.getIdentityDisclosure()),u(null)}catch(y){u(y instanceof Error?y.message:"Could not read the setting")}},[]);h.useEffect(()=>{f()},[f]);const g=h.useCallback(async()=>{if(!(!t||a)){o(!0),u(null);try{s(await M.setIdentityDisclosure(!t.always))}catch(y){u(y instanceof Error?y.message:"Failed to save"),await f()}finally{o(!1)}}},[t,a,f]),p=n.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!t)return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[p,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=t.verified&&t.name?`${t.name} — ${t.method==="as_vouched"?`${ph.as_vouched} ${t.verifier}`:ph[t.method??""]??t.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:[p,n.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[t.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),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 g(),disabled:a,"aria-pressed":t.always,className:t.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":t.always?"Turn off":"Always show my name"})]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}const wS={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 jS(){const{version:t,latestVersion:s,updateAvailable:a,installMethod:o}=xc();return t?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:t}),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:[wS[o]??"Update checking is unavailable",o==="dev"&&n.jsx(n.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function ic({title:t}){return n.jsxs("span",{className:"it-locked-badge",title:t,children:[n.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function gh(t){return t===!0}function SS(){const[t,s]=h.useState(null),[a,o]=h.useState(null);h.useEffect(()=>{let f=!1;return M.getAsPairing().then(g=>{f||s(g)}).catch(g=>{f||o(g instanceof Error?g.message:"Could not read Authority Server info")}),()=>{f=!0}},[]);const l=gh(t==null?void 0:t.asUrlLockedByPolicy),u=gh(t==null?void 0:t.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(ic,{})]}),!t&&!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}),t&&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:t.asUrl})]}),t.paired&&t.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:t.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."}),(t.tlsPinFingerprint||t.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(ic,{title:"TLS pinning is set by your IT policy"})," ",t.tlsPinFingerprint?n.jsx("code",{children:t.tlsPinFingerprint}):n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",t.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),n.jsx("br",{}),n.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[t.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 bS(){const{simulation:t,locked:s}=hm();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.',t!==null&&n.jsxs(n.Fragment,{children:[" ","Currently ",n.jsx("strong",{children:t?"ON":"OFF"}),t?" — real systems are not reachable from this gateway.":"."]})]})]}),n.jsx(ic,{})]}),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",t!==null?` (currently ${t?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const kS={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"]}},Ks=["AI Assistant","Authority Server","This computer","Security","Version"],qs={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function NS(){const[t,s]=h.useState(""),[a,o]=h.useState("openrouter"),[l,u]=h.useState("openai-compatible"),[f,g]=h.useState("https://openrouter.ai/api/v1"),[p,v]=h.useState("google/gemma-4-31b-it"),[y,x]=h.useState(""),[j,N]=h.useState(!1),[b,S]=h.useState(!1),[k,E]=h.useState(!1),[T,P]=h.useState(null),[I,U]=h.useState([]),[V,F]=h.useState(!1),[J,Q]=h.useState(null),[te,ee]=h.useState(""),z=h.useCallback(q=>{s(q),setTimeout(()=>s(""),3e3)},[]),oe=h.useCallback(async(q,G,A)=>{F(!0),Q(null);try{const _=await M.aiModels({provider:q,endpoint:G,...A?{apiKey:A}:{}});_.ok&&_.models.length>0?(U(_.models),Q(`${_.models.length} models available`)):(U([]),Q(_.message||"No models returned — using defaults"))}catch(_){U([]),Q(_ instanceof Error?_.message:"Failed to load models")}finally{F(!1)}},[]),ue=h.useCallback(async()=>{try{const q=await M.getCredential("ai-config");if(N(q.configured),q.configured&&q.fields){const G=q.fields.provider||"openai-compatible",A=q.fields.endpoint||"";q.fields.provider&&u(G),q.fields.endpoint&&g(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&&oe(G,A)}}catch{}},[oe]);h.useEffect(()=>{ue()},[ue]);const Y=q=>{o(q),U([]),Q(null),ee("");const G=kS[q];G&&(u(G.provider),g(G.endpoint),v(""),oe(G.provider,G.endpoint,y||void 0))},je=()=>oe(l,f,y||void 0),xe=async()=>{S(!0);try{await M.setCredential("ai-config",{provider:l,endpoint:f,model:p,...y?{apiKey:y}:{}}),N(!0),z("AI configuration saved!")}catch{z("Failed to save AI config")}finally{S(!1)}},X=async()=>{E(!0),P(null);try{const q=await M.aiTest({provider:l,endpoint:f,model:p,...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."})]}),t&&n.jsx("div",{className:"alert alert-success",children:t}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:qs,children:Ks[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."}),j&&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=>Y(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=>x(q.target.value),onBlur:()=>{y.trim()&&oe(l,f,y.trim())},placeholder:j?"••••••••••••••••":"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:je,disabled:V,title:"Re-fetch the model list from the provider",children:V?"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:V?"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,G=q.includes(p),A=q.length>12,_=te.trim().toLowerCase();let re=_?q.filter(fe=>fe.toLowerCase().includes(_)):q;return G&&!re.includes(p)&&(re=[p,...re]),n.jsxs(n.Fragment,{children:[A&&n.jsx("input",{className:"form-input",value:te,onChange:fe=>ee(fe.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),n.jsxs("select",{className:"form-input",value:G?p:"__unset__",onChange:fe=>v(fe.target.value==="__unset__"?"":fe.target.value),children:[n.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),re.map(fe=>n.jsx("option",{value:fe,children:fe},fe)),_&&re.length===0&&n.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",te,"”"]})]})]})})(),J&&n.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:J})]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[n.jsx("button",{className:"btn btn-primary",onClick:xe,disabled:b||!p.trim(),title:p.trim()?void 0:"Select a model first",children:b?"Saving...":"Save & Encrypt"}),j&&n.jsx("button",{className:"btn btn-ghost",onClick:X,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(CS,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:qs,children:Ks[1]}),n.jsx(SS,{}),n.jsx(xS,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:qs,children:Ks[2]}),n.jsx(yS,{}),n.jsx(vS,{}),n.jsx(bS,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:qs,children:Ks[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:qs,children:Ks[4]}),n.jsx(jS,{})]})]})}function CS(){const[t,s]=h.useState(null),[a,o]=h.useState({intent:"",context:""}),[l,u]=h.useState(null),[f,g]=h.useState(null),[p,v]=h.useState(null),[y,x]=h.useState(!1),j=h.useCallback(async()=>{if(!y)try{const S=await M.getAIPrompts();s(S),o({intent:S.intent.current,context:S.context.current}),x(!0)}catch(S){g(S instanceof Error?S.message:"Failed to load prompts")}},[y]),N=async S=>{if(t){u(S),g(null);try{const k=a[S],E=k.trim()===t[S].default.trim()?"":k;await M.setAIPrompt(S,E);const T=await M.getAIPrompts();s(T),o({intent:T.intent.current,context:T.context.current}),v(S),setTimeout(()=>v(null),2e3)}catch(k){g(k instanceof Error?k.message:"Save failed")}finally{u(null)}}},b=async S=>{if(confirm(`Revert ${S} prompt to the built-in default?`)){u(S),g(null);try{await M.setAIPrompt(S,"");const k=await M.getAIPrompts();s(k),o({intent:k.intent.current,context:k.context.current})}catch(k){g(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&&j()},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…"}),t&&n.jsxs(n.Fragment,{children:[n.jsx(yh,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:t.intent,draft:a.intent,onChange:S=>o(k=>({...k,intent:S})),onSave:()=>N("intent"),onRevert:()=>b("intent"),saving:l==="intent",justSaved:p==="intent"}),n.jsx(yh,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:t.context,draft:a.context,onChange:S=>o(k=>({...k,context:S})),onSave:()=>N("context"),onRevert:()=>b("context"),saving:l==="context",justSaved:p==="context"})]})]})}function yh({kind:t,label:s,description:a,state:o,draft:l,onChange:u,onSave:f,onRevert:g,saving:p,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:x=>u(x.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:p||!y,children:p?"Saving…":"Save"}),o.overridden&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:g,disabled:p,title:"Discard the override and use the built-in default",children:"Revert to default"}),v&&n.jsx("span",{className:"msg-ok",style:{fontSize:"0.78rem"},children:"Saved"}),y&&!p&&!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:t})]})}function ES(t){return t.proposalId?"review":"automatic"}function vh(t,s,a={}){const o=a.status??"pending",l=a.includeAutonomous??!1,u=[];for(const f of t)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 g=ES(f);!l&&g==="automatic"||a.profile&&f.profileId!==a.profile||u.push({kind:"receipt",id:f.id,sortTimestamp:f.timestamp,commitmentMode:g,profileId:f.profileId,receipt:f})}return u.sort((f,g)=>g.sortTimestamp-f.sortTimestamp),typeof a.limit=="number"&&a.limit>0?u.slice(0,a.limit):u}const TS=["https://","http://"];function ep(t,s){return t!=null&&t.length?t.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)?[]:TS.some(l=>o.toLowerCase().startsWith(l))?[{label:a.label,href:o,description:a.description}]:[]}):[]}function tp(t,s){const a=t-Math.floor(s/1e3);if(a<=0)return{label:"expired",urgent:!1,expired:!0};const o=Math.floor(a/86400),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}}const IS=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function AS(t,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:IS.test(t)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function Jr(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t,null,2)}catch{return String(t)}}function xh({row:t,which:s}){const a=ss(t.profileRef),o=P0(t.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 RS({row:t}){const s=ss(t.profileRef),a=(s==null?void 0:s.id)??t.profileRef??"";return n.jsxs(n.Fragment,{children:[(s==null?void 0:s.name)??lt(a),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function PS({row:t,altText:s}){switch(t.kind){case"profile":return n.jsx(RS,{row:t});case"profile-limits":return n.jsx(xh,{row:t,which:"limits"});case"profile-scope":return n.jsx(xh,{row:t,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:Jr(t.value)});case"list":return Array.isArray(t.value)?n.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:t.value.map((a,o)=>n.jsx("li",{children:Jr(a)},o))}):n.jsx(n.Fragment,{children:Jr(t.value)});case"money":return n.jsxs(n.Fragment,{children:[Jr(t.value),t.currency?` ${t.currency}`:""]});case"object":return n.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Jr(t.value)});default:return AS(t.key,t.value)?n.jsx("img",{src:t.value,alt:s??t.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):n.jsx(n.Fragment,{children:Jr(t.value)})}}function np({args:t,display:s,heading:a="Details"}){const o=R0(t,s);if(o.length===0)return null;const l=typeof t.altText=="string"?t.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:o.map(u=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:u.hint,children:u.label}),n.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:n.jsx(PS,{row:u,altText:l})})]},u.key))})]})}function Fc({profileId:t,declared:s}){const{icon:a,name:o}=er(t,s);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"id-rail",children:[n.jsx(Ac,{icon:a,className:"id-rail-icon"}),n.jsx("span",{className:"id-rail-name",children:o})]}),n.jsx("div",{className:"id-sep"})]})}function $S({proposalId:t,systemName:s}){const[a,o]=h.useState(null);if(h.useEffect(()=>{let u=!0;return o(null),M.getProposalOutcome(t).then(f=>{u&&o(f)}).catch(()=>{}),()=>{u=!1}},[t]),!a)return null;const l=Gj(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}let Wl=null;function _S(){return Wl||(Wl=M.getEnrichedAuthorizations().then(t=>new Map(t.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),Wl}function LS(t){const[s,a]=h.useState(void 0);return h.useEffect(()=>{let o=!0;if(t)return _S().then(l=>{o&&a(l.get(t))}),()=>{o=!1}},[t]),s}function zS(t,s){const[a,o]=h.useState(null),[l,u]=h.useState(!1),[f,g]=h.useState(null);return h.useEffect(()=>{let p=!0;return o(null),g(null),u(!0),(async()=>{var v;try{try{const j=await M.getGateContent(t);if((v=j==null?void 0:j.gateContent)!=null&&v.intent){p&&o(j.gateContent.intent);return}}catch{}const y=await M.getAttestationIntent(t);if(!y){p&&g("Intent not available or you are not an authorized approver.");return}const x=await M.decryptIntent({intentCiphertext:y.intentCiphertext,encryptedKey:y.encryptedKey,approverId:s});p&&o(x)}catch(y){p&&g(y instanceof Error?y.message:"Failed to decrypt intent")}finally{p&&u(!1)}})(),()=>{p=!1}},[t,s]),{intent:a,loading:l,error:f}}function wh(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const s={};for(const[a,o]of Object.entries(t))(typeof o=="string"||typeof o=="number")&&(s[a]=o);return s}function FS(t){const s=wh(t.limits),a=wh(t.scope),o=typeof t.intent=="string"?t.intent:"",l={bounds:s,context:a,gateContent:{intent:o}};return(t.mode==="automatic"||t.mode==="review")&&(l.templateMode=t.mode),typeof t.duration_hours=="number"&&t.duration_hours>0&&(l.templateTtl=Math.round(t.duration_hours*3600)),l}function rp(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.map(s=>rp(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}const MS="setup__create_mandate";function sp({proposal:t,currentUserId:s,proposalLinks:a,toolDisplay:o,manifests:l,onContentState:u,onShownSnapshot:f,nameOf:g}){const[p,v]=h.useState(!1),[y,x]=h.useState(!1),[j,N]=h.useState(null),b=gn(),{group:S,groupId:k,domain:E}=yt(),T=Object.entries(t.executionContext),P=ss(t.profileId),I=LS(t.authorizationId),U=F0(t.executionContext,I,P),V=I0(t.tool),{integrationId:F}=as(t.tool),J=aa(F,l),{intent:Q,loading:te,error:ee}=zS(t.authorizationId,s),z=Rc(t),oe=z.toolArgs!==null;h.useEffect(()=>{u==null||u({loading:z.loading,readable:oe})},[z.loading,oe]);const ue=Q0(t),Y=z.toolArgs?ep(a,z.toolArgs):[],je=async()=>{if(!k){N("No active workspace; cannot open the mandate screen.");return}x(!0),N(null);try{if(!z.toolArgs){N("This content is not readable on this device yet.");return}const L=z.toolArgs,Z=typeof L.profile=="string"?L.profile:"",ie=await M.listProfiles(),me=Dm(Z,ie);if(!me){N(`Unknown profile "${Z}".`);return}const pe=await M.getProfile(me.id),se=FS(L),be=Wm(se.bounds,pe),Le=Hm(se.context,pe);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:me.id,groupId:k,groupName:(S==null?void 0:S.name)??null,domain:E,isPersonal:!!(S!=null&&S.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...se,bounds:be,context:Le})),sessionStorage.setItem("agentReplacesProposal",t.id),b("/mandates/new/intent")}catch(L){N(L instanceof Error?L.message:"Could not open the mandate screen.")}finally{x(!1)}},[xe,X]=h.useState(null),q=Kj(xe),[G,A]=h.useState(null),[_,re]=h.useState(null);h.useEffect(()=>{if(!G||!_){f==null||f(null);return}const L=G.status==="ok"?G.readAt:Date.now();f==null||f({readAt:L,preview:G,requestContext:_,...z.toolArgs?{toolArgs:z.toolArgs}:{},sealed:z.sealed})},[G,_,z.toolArgs,z.sealed,f]);const fe=z.toolArgs?n.jsxs(n.Fragment,{children:[n.jsx(np,{args:z.toolArgs,display:o,heading:""}),T.length>0&&n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:T.map(([L,Z],ie)=>{const{label:me,hint:pe}=pm(L,P);return n.jsxs("span",{children:[ie>0&&" · ",n.jsxs("span",{title:pe,children:[me,"=",rp(Z)]})]},L)})})]}):null;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"approval-summary","data-testid":"approval-summary",children:Cm(t.tool,z.toolArgs,l)}),n.jsx("div",{className:"approval-headline",children:V}),z.sealed&&z.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."})]}),z.sealed&&z.loading&&n.jsx("div",{className:"preview-box","data-testid":"proposal-decrypting",style:{marginBottom:"0.5rem"},children:"Decrypting…"}),q&&oe&&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",z.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"})]}),fe,z.sealed&&n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"Decrypted on this device. suveren.ai stores only an unreadable copy and its fingerprint."})]}),ue.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: ",ue.map(L=>(g==null?void 0:g(L))??L).join(", ")," — shared automatically once they sign in on a device."]}),oe&&n.jsx(Jj,{proposalId:t.id,systemName:J,toolArgs:z.toolArgs,sealed:z.sealed,onTone:X,onData:A}),oe&&n.jsx(sS,{proposalId:t.id,onData:re}),oe&&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"]})]})]}),U.length>0&&n.jsxs("div",{className:"limit-checks",children:[n.jsx("h4",{children:"Within your limits"}),n.jsx("ul",{className:"limit-check-list",children:U.map(L=>n.jsxs("li",{className:L.ok?"ok":"bad",children:[n.jsx("span",{className:"limit-check-icon",children:L.ok?"✓":"✗"}),n.jsxs("span",{children:[L.label," ",L.valueText," — your limit ",L.limitText]})]},L.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)??lt(t.profileId)})})]}),n.jsxs("dl",{children:[n.jsx("dt",{children:"Intent"}),n.jsx("dd",{children:ee?n.jsx("p",{className:"msg-error",style:{fontSize:"0.8rem",margin:0},children:ee}):Q!==null?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:`intent-text${p?"":" intent-clamped"}`,children:Q}),n.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>v(!p),children:p?"Show less":"Show full intent"})]}):te?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."})})]})]}),oe&&Y.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:Y.map(L=>n.jsxs("a",{href:L.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:L.description??L.href,children:[L.label," ↗"]},L.label))}),!q&&oe&&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:fe})]}),oe&&t.tool===MS&&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:je,disabled:y,children:y?"Opening…":"Edit before signing"}),j&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.8rem",margin:"0.4rem 0 0"},children:j})]})]})}function ap({note:t,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:Gw.map(f=>n.jsx("button",{type:"button",className:`filter-chip${Mm(t,f)?" selected":""}`,onClick:()=>s(qw(t,f)),disabled:l,children:f},f))}),n.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:t,maxLength:_i,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:[t.length," / ",_i]}),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 OS={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},BS={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},jh={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function Hl(t){const s=Date.now()-t*1e3,a=s/36e5;return a<48?a<1?`${Math.max(1,Math.round(s/6e4))}m ago`:`${Math.round(a)}h ago`:new Date(t*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function DS(t){return t.split("__").pop()??t}function US(t){const s=t.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function ip(t){if(t==null)return"—";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.map(s=>ip(s)).join(", ");try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Sh({item:t,onApprove:s,onReject:a,onChangeNeeded:o,resolving:l,proposalLinks:u,toolDisplay:f,manifests:g,currentUserId:p,inRow:v=!1}){const y=t.kind==="proposal",x=y?t.proposal.status:"executed",j=y?t.proposal.tool:t.receipt.action,N=DS(j),b=US(j),{integrationId:S}=as(j),k=aa(S,g),[E,T]=h.useState(!1),[P,I]=h.useState(""),[U,V]=h.useState(""),F=h.useRef(null),J=async()=>{const L=F.current;if(!(!L||!y))try{const{shownHash:Z}=await M.saveShownSnapshot(t.proposal.id,L);return Z}catch{return}},Q=async()=>{const L=zc(P);if(!L.valid){V(L.error);return}V("");const Z=await J();o==null||o(t.id,L.trimmed,Z)},te=y&&x==="rejected"?Xw(t.proposal,p??""):null,ee=y&&x==="refused"?Zw(t.proposal):null,z=X0(y?t.proposal.rejectedBy??t.proposal.approverRejectedBy??null:null),oe=ss(t.profileId),ue=Rc(y?t.proposal:{toolArgs:void 0,content:void 0}),Y=y?ue.toolArgs:null,je=y?t.proposal.executionContext:t.receipt.executionContext,xe=y?null:t.receipt.cumulativeState,[X,q]=h.useState(!0),[G,A]=h.useState(!1),_=y&&ue.toolArgs?ep(u,ue.toolArgs):[],re=Object.entries(je??{}),fe=er(t.profileId).testSetup||Gi(j);return n.jsxs("div",{className:v?"card card-in-row":"card id-card",children:[!v&&n.jsx(Fc,{profileId:t.profileId}),n.jsxs("div",{className:"id-body",children:[v?fe?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:N}),fe&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),t.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&&x==="pending"&&(()=>{const L=tp(t.proposal.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:L.urgent?600:400,whiteSpace:"nowrap"},children:L.label})})(),n.jsx("span",{"data-testid":te||ee?"outcome-kind":void 0,className:`status-badge ${te?jh[te.kind]:ee?jh.REFUSED:BS[x]}`,children:te?te.kind:ee?ee.kind:OS[x]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Hl(t.sortTimestamp)})]})]}),y&&t.proposal.status==="executed"&&n.jsx($S,{proposalId:t.proposal.id,systemName:k}),te&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By ",te.who,", ",Hl(te.at)]}),(z??te.note)&&n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[te.kind==="CHANGE NEEDED"?"Change: ":"Note: ",z??te.note]})]}),ee&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By the Authority Server, ",Hl(ee.at)]}),n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",ee.message]})]}),b&&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(Y==null?void 0:Y._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:Y._imagePreview,alt:typeof(Y==null?void 0:Y.altText)=="string"?Y.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),y&&x==="pending"?n.jsx(sp,{proposal:t.proposal,currentUserId:p??"",proposalLinks:u,toolDisplay:f,manifests:g,onContentState:({loading:L,readable:Z})=>{A(L),q(Z)},onShownSnapshot:L=>{F.current=L}}):n.jsxs(n.Fragment,{children:[_.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:_.map(L=>n.jsxs("a",{href:L.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:L.description??L.href,children:[L.label," ↗"]},L.label))}),y?n.jsxs(n.Fragment,{children:[Y&&n.jsx(np,{args:Y,display:f}),re.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:re.map(([L,Z])=>`${L}=${ip(Z)}`).join(" · ")})]}):n.jsxs(n.Fragment,{children:[n.jsx(Ym,{receipt:t.receipt,profile:oe}),t.receipt.proposalId&&n.jsx(Zm,{proposalId:t.receipt.proposalId,tool:t.receipt.action,manifests:g})]})]}),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&&x==="pending"&&bm({loading:G,readable:X})&&(E?n.jsx(ap,{note:P,onNoteChange:I,onSend:Q,onCancel:()=>{T(!1),I(""),V("")},sending:!!l,error:U}):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(t.id,await J()),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(t.id,await J()),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",": ",t.id]})]})]})}function WS(t,s=[]){const a=new Map;for(const o of t){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 HS(t,s){return t.map(a=>s.get(a)??a)}function op(t){var N;const{groupId:s}=yt(),a=ss(t.profileId),[o,l]=h.useState(null),[u,f]=h.useState(new Map),[g,p]=h.useState(!0);h.useEffect(()=>{let b=!0;if(!s){p(!1);return}return p(!0),Promise.all([M.getTeamProfileConfig(s,t.profileId).catch(()=>null),M.getGroupById(s).catch(()=>null),M.listUsers().catch(()=>[])]).then(([S,k,E])=>{b&&(l(S),f(WS(E,(k==null?void 0:k.members)??[])))}).finally(()=>{b&&p(!1)}),()=>{b=!1}},[s,t.profileId]);const v=Qv(o??{}),y=HS(t.pendingApprovers??[],u),x=b=>u.get(b)??b,j=o&&((N=a==null?void 0:a.boundsSchema)!=null&&N.fields)?pw(t.executionContext,o,a.boundsSchema.fields):null;return{loading:g,profileConfig:o,requiredApprovals:v,approverNames:y,nameOf:x,aboveCapReason:j}}function lp(t,s){return!!t.createdBy&&!!s&&t.createdBy===s}function cp(t){return(t.pendingApprovers??[]).filter(s=>s!==t.createdBy)}function VS(t){const s=Date.now()-t*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function GS({proposal:t,currentUserId:s,onAction:a,onMessage:o,proposalLinks:l,toolDisplay:u,manifests:f,inRow:g=!1}){const[p,v]=h.useState(!1),[y,x]=h.useState(!1),[j,N]=h.useState(!1),[b,S]=h.useState(""),[k,E]=h.useState(""),[T,P]=h.useState(!1),[I,U]=h.useState(!1),[V,F]=h.useState(!0),J=h.useRef(null),Q=async()=>{const _=J.current;if(_)try{const{shownHash:re}=await M.saveShownSnapshot(t.id,_);return re}catch{return}},te=er(t.profileId).testSetup||Gi(t.tool),ee=cp(t),z=t.approvedBy??{},oe=Object.keys(z).length,ue=s in z,Y=op(t),je=lp(t,s),xe=_=>{const re=_ instanceof Error?_.message:"Approval failed";return re.includes("APPROVER_IS_PROPOSER")?"You can't approve your own action. Ask another approver.":re.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.":re},X=async()=>{if(Cc()){o(Ec);return}v(!0),o("");try{const _=await Qs(t),re=await Q(),fe=await M.approveProposal(t.id,_,re);try{const me=await M.getAttestationIntent(t.authorizationId);if(me){const pe=await M.decryptIntent({intentCiphertext:me.intentCiphertext,encryptedKey:me.encryptedKey,approverId:s});await M.storeApprovedIntent(t.authorizationId,pe)}}catch{}const{requiredApprovals:L,approvedCount:Z}=fe,ie=L!==void 0&&Z!==void 0?L-Z:void 0;o(ie===void 0?"Approved.":ie>0?`Approved. ${ie} more approval${ie===1?"":"s"} still needed.`:"Approved — the required number of approvals is met; the action is ready to execute."),a()}catch(_){o(xe(_))}finally{v(!1)}},q=async()=>{x(!0),o("");try{const _=await Qs(t),re=await Q();await M.rejectProposal(t.id,Om(),_,re),o("Action rejected."),a()}catch(_){o(_ instanceof Error?_.message:"Rejection failed")}finally{x(!1)}},G=async()=>{const _=zc(b);if(!_.valid){E(_.error);return}E(""),P(!0),o("");try{const{noteEncrypted:re}=await M.encryptProposalNote(_.trimmed,km(t,s)),fe=await Qs(t),L=await Q();await M.rejectProposal(t.id,{outcome:"change_needed",noteEncrypted:re},fe,L),o("Sent back for a change."),a()}catch(re){o(re instanceof Error?re.message:"Failed to send back")}finally{P(!1)}},A=p||y||T;return n.jsxs("div",{className:g?"card card-in-row":"card id-card",children:[!g&&n.jsx(Fc,{profileId:t.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:g?"none":"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[te&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const _=tp(t.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:VS(t.createdAt)})]})]}),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:"," ",ee.map((_,re)=>n.jsxs("span",{className:`who${_ in z?" done":""}`,style:{marginLeft:re===0?"0.25rem":"0.5rem",fontWeight:_ in z?600:void 0},children:[_ in z?"✓ ":"",Y.nameOf(_),_===s?" (you)":"",re<ee.length-1?",":""]},_)),Y.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",oe," 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),")."," ",t.createdBy?`Requested by ${Y.nameOf(t.createdBy)}.`:""]})]}),n.jsx(sp,{proposal:t,currentUserId:s,proposalLinks:l,toolDisplay:u,manifests:f,nameOf:Y.nameOf,onContentState:({loading:_,readable:re})=>{U(_),F(re)},onShownSnapshot:_=>{J.current=_}}),!ue&&bm({loading:I,readable:V})&&(j?n.jsx(ap,{note:b,onNoteChange:S,onSend:G,onCancel:()=>{N(!1),S(""),E("")},sending:T,error:k}):n.jsxs(n.Fragment,{children:[!je&&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:[je?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:X,disabled:A,children:p?"Approving...":"Approve"}),n.jsxs("button",{"data-testid":"btn-change-needed",className:"btn btn-outline-strong",onClick:()=>N(!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"]})]})]})),ue&&n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:["You approved this action.",Y.requiredApprovals>1&&oe<Y.requiredApprovals?` Waiting on ${Y.requiredApprovals-oe} more approval(s).`:""]}),!g&&n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",t.id]})]})]})}function bh({proposal:t,manifests:s,titles:a,open:o,onToggle:l,who:u,children:f}){const g=Date.now(),p=xm(t.expiresAt,g),v=h.useRef(null);return h.useEffect(()=>{var y;o&&((y=v.current)==null||y.scrollIntoView({block:"nearest"}))},[o]),n.jsxs("div",{ref:v,className:`appr-item${o?" is-open":""}`,"data-testid":"approval-row","data-proposal-id":t.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(br,{profileId:t.profileId,area:ia(t.authorizationId,t.profileId,a),system:oa(t.tool,s),time:vm(t.createdAt,g)}),n.jsx("div",{className:"appr-item-sum","data-testid":"approval-row-summary",children:n.jsx(Em,{proposal:t,manifests:s})}),p&&n.jsx("div",{className:"obj-due",children:p}),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 KS(){const{domain:t,user:s}=yt(),a=(s==null?void 0:s.id)??"",[o,l]=h.useState("awaiting-me"),[u,f]=h.useState([]),[g,p]=h.useState([]),[v,y]=h.useState({}),[x,j]=h.useState(!0),[N,b]=h.useState(""),S=h.useCallback(async()=>{try{const H=await M.getProposalsForApprover();f(H)}catch{}finally{j(!1)}},[]);Be("proposal-added",S),Be("proposal-approved",S),Be("proposal-rejected",S),Be("proposal-resolved",S),Lt(S,3e4);const[k,E]=h.useState([]),T=h.useCallback(async()=>{try{const H=await M.getMyProposals(t);E(H)}catch{}},[t]);Be("proposal-added",T),Be("proposal-approved",T),Be("proposal-rejected",T),Be("proposal-resolved",T),Be("execution-failed",T),Lt(T,3e4,t);const P=h.useMemo(()=>k.filter(H=>{var K;return H.status==="pending"&&(((K=H.pendingApprovers)==null?void 0:K.length)??0)===0}),[k]),I=h.useMemo(()=>vh(P,[],{status:"pending"}),[P]),[U,V]=h.useState([]),F=h.useCallback(async()=>{if(a)try{const K=(await M.getMyProposals(t)).filter(ye=>ye.status==="pending"&&ye.pendingApprovers&&ye.pendingApprovers.includes(a)&&ye.approvedBy&&a in ye.approvedBy);V(K)}catch{}},[a,t]);Be("proposal-approved",F),Be("proposal-rejected",F),Lt(F,3e4,`${a}:${t}`);const[J,Q]=h.useState([]),te=h.useCallback(async()=>{try{const H=await M.getProposalsCreatedByMe();if(H!==null){Q(H);return}Q(await M.getMyPendingProposals())}catch{}},[]);Be("proposal-added",te),Be("proposal-approved",te),Be("proposal-rejected",te),Lt(te,3e4),h.useEffect(()=>{M.getIntegrationManifests().then(H=>p(H.manifests??[])).catch(()=>{}),M.getToolDisplay().then(y).catch(()=>{})},[]);const ee=H=>{var K;return(K=g.find(ye=>ye.id===H.split("__")[0]))==null?void 0:K.proposalLinks};h.useEffect(()=>{S(),T(),F(),te()},[]);const[z,oe]=h.useState([]),[ue,Y]=h.useState([]),[je,xe]=h.useState(!0),[X,q]=h.useState(null),[G,A]=h.useState(""),[_,re]=h.useState("pending"),[fe,L]=h.useState(null),[Z,ie]=h.useState(!1),me=h.useCallback(async()=>{try{const{proposals:H,receipts:K}=await M.getThread({domain:t,status:_,sinceDays:7});oe(H),Y(K)}catch{}finally{xe(!1)}},[t,_]);Lt(me,3e4,`${t}:${_}`);const pe=async(H,K,ye,He)=>{if(K==="commit"&&Cc()){A(Ec);return}q(H),A("");try{const Ue=z.find(ve=>ve.id===H)??k.find(ve=>ve.id===H),st=Jv(Ue,t),zt=Ue?await Qs(Ue):void 0;let Ft=ye??{};if((ye==null?void 0:ye.outcome)==="change_needed"&&ye.note){const ve=Ue?km(Ue,a):[a],{noteEncrypted:Ie}=await M.encryptProposalNote(ye.note,ve);Ft={outcome:"change_needed",noteEncrypted:Ie}}const B=await M.resolveProposal(H,K,st,{...Ft,contentHash:zt,shownHash:He});A(K==="commit"?`Action approved. Status: ${B.status}`:(ye==null?void 0:ye.outcome)==="change_needed"?"Sent back for a change.":"Action rejected."),await Promise.all([me(),T()])}catch(Ue){A(Ue instanceof Error?Ue.message:"Failed")}finally{q(null)}},se=(H,K)=>pe(H,"commit",void 0,K),be=(H,K)=>pe(H,"reject",Om(),K),Le=(H,K,ye)=>pe(H,"reject",Yw(K),ye),ge=h.useMemo(()=>{const H=new Set;for(const K of z)H.add(K.profileId);for(const K of ue)H.add(K.profileId);return Array.from(H).sort()},[z,ue]),$e=h.useMemo(()=>vh(z,ue,{status:_,profile:fe??void 0,includeAutonomous:Z}),[z,ue,_,fe,Z]),qe=h.useCallback(()=>{S(),F()},[S,F]),Ge=h.useMemo(()=>{const H=new Set,K=[];for(const ye of[...U,...J])H.has(ye.id)||(H.add(ye.id),K.push(ye));return K.sort((ye,He)=>He.createdAt-ye.createdAt)},[U,J]),Me=u.length+I.length,[xt]=sa(),[Ze,Xe]=h.useState(()=>xt.get("open")),Je=h.useMemo(()=>[...I.map(H=>H.kind==="proposal"?H.proposal.id:H.id),...u.map(H=>H.id)],[I,u]),wt=h.useRef([]),mt=h.useRef(null);h.useEffect(()=>{const H=wt.current;if(wt.current=Je,Je.length===1&&Ze===null&&mt.current!==Je[0]){mt.current=Je[0],Xe(Je[0]);return}if(Ze&&!Je.includes(Ze)&&H.includes(Ze)){const K=H.indexOf(Ze),ye=H.slice(K+1).find(He=>Je.includes(He))??Je[0]??null;Xe(ye)}},[Je,Ze]);const ze=H=>Xe(K=>K===H?null:H),[he,Pe]=h.useState({});h.useEffect(()=>{M.getMyAttestations().then(H=>{const K={};for(const ye of H)ye.authorization_id&&ye.title&&(K[ye.authorization_id]=ye.title);Pe(K)}).catch(()=>{})},[]);const Fe=Ge.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(dm,{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 ",Me>0&&n.jsx("span",{className:"pill-count",style:{marginLeft:"0.4rem"},children:Me})]}),n.jsxs("button",{className:`nav-tab${o==="awaiting-others"?" active":""}`,onClick:()=>l("awaiting-others"),children:["Awaiting others ",Fe>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:Fe})]}),n.jsx("button",{className:`nav-tab${o==="all"?" active":""}`,onClick:()=>{l("all"),me()},children:"All"})]}),o==="awaiting-me"&&n.jsx(n.Fragment,{children:x&&Me===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Me===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:[(N||G)&&n.jsx("div",{className:"alert alert-success",children:N||G}),I.map(H=>{const K=n.jsx(Sh,{proposalLinks:H.kind==="proposal"?ee(H.proposal.tool):void 0,toolDisplay:H.kind==="proposal"?v[H.proposal.tool]:void 0,manifests:g,currentUserId:a,item:H,onApprove:se,onReject:be,onChangeNeeded:Le,resolving:X===H.id,inRow:H.kind==="proposal"},H.id);if(H.kind!=="proposal")return K;const ye=H.proposal.id;return n.jsx(bh,{proposal:H.proposal,manifests:g,titles:he,open:Ze===ye,onToggle:()=>ze(ye),children:K},ye)}),u.map(H=>n.jsx(bh,{proposal:H,manifests:g,titles:he,open:Ze===H.id,onToggle:()=>ze(H.id),who:"Team approval — other people are involved",children:n.jsx(GS,{inRow:!0,proposal:H,currentUserId:a,onAction:qe,onMessage:b,proposalLinks:ee(H.tool),toolDisplay:v[H.tool],manifests:g},H.id)},H.id))]})}),o==="awaiting-others"&&n.jsx(n.Fragment,{children:Ge.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:Ge.map(H=>n.jsx(YS,{proposal:H,currentUserId:a,onCancel:async()=>{try{await M.rejectProposal(H.id,{reason:"cancelled by creator"}),F(),T()}catch(K){alert(K instanceof Error?K.message:"Cancel failed")}},onWithdraw:async()=>{const K=await Qs(H);await M.withdrawProposal(H.id,void 0,K),te(),F()}},H.id))})}),o==="all"&&n.jsxs(n.Fragment,{children:[G&&n.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:G}),n.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[n.jsx("button",{className:`filter-chip ${_==="pending"?"selected":""}`,onClick:()=>re("pending"),children:"Pending"}),n.jsx("button",{className:`filter-chip ${_==="all"?"selected":""}`,onClick:()=>re("all"),children:"All"}),ge.length>0&&n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),ge.map(H=>n.jsx("button",{className:`filter-chip ${fe===H?"selected":""}`,onClick:()=>L(fe===H?null:H),children:lt(H)},H)),_==="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 ${Z?"selected":""}`,onClick:()=>ie(!Z),title:"Include actions executed without human review (automatic commitment mode)",children:[Z?"✓ ":"","Autonomous actions"]})]})]}),je&&$e.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):$e.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:$e.map(H=>n.jsx(Sh,{proposalLinks:H.kind==="proposal"?ee(H.proposal.tool):void 0,toolDisplay:H.kind==="proposal"?v[H.proposal.tool]:void 0,manifests:g,currentUserId:a,item:H,onApprove:se,onReject:be,onChangeNeeded:Le,resolving:X===H.id},H.id))})]})]})}function qS(t){const s=Date.now()-t*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function YS({proposal:t,currentUserId:s,onCancel:a,onWithdraw:o}){const[l,u]=h.useState(!1),[f,g]=h.useState(!1),[p,v]=h.useState(""),y=op(t),x=lp(t,s),j=cp(t),N=t.approvedBy??{},b=Object.keys(N).length,S=j.length>0,k=async()=>{u(!0);try{await a()}finally{u(!1)}},E=async()=>{g(!0),v("");try{await o()}catch(P){v(P instanceof Error?P.message:"Withdraw failed")}finally{g(!1)}},T=er(t.profileId).testSetup||Gi(t.tool);return n.jsxs("div",{className:"card id-card",children:[n.jsx(Fc,{profileId:t.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:t.tool.split("__").pop()??t.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:qS(t.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:"," ",j.map((P,I)=>n.jsxs("span",{className:`who${P in N?" done":""}`,style:{marginLeft:I===0?"0.25rem":"0.5rem",fontWeight:P in N?600:void 0},children:[P in N?"✓ ":"",y.nameOf(P),P===s?" (you)":"",I<j.length-1?",":""]},P)),y.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",b," 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),")."," ",t.createdBy?`Requested by ${y.nameOf(t.createdBy)}.`:""]})]}),S&&x&&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&&x?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"}),p&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.78rem",margin:0},children:p})]}):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 JS=`# 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 QS(){const[t,s]=h.useState(""),[a,o]=h.useState(""),[l,u]=h.useState(!0),[f,g]=h.useState(!1),[p,v]=h.useState(null),[y,x]=h.useState(!1),j=t!==a,N=new Blob([t]).size,b=16*1024;h.useEffect(()=>{if(!j)return;const T=I=>{I.preventDefault(),I.returnValue=""},P=I=>{var F,J;if(I.defaultPrevented||I.button!==0||I.metaKey||I.ctrlKey||I.shiftKey||I.altKey)return;const U=(J=(F=I.target)==null?void 0:F.closest)==null?void 0:J.call(F,"a");if(!U||!U.href)return;let V;try{V=new URL(U.href)}catch{return}V.origin===window.location.origin&&V.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)}},[j]),h.useEffect(()=>{let T=!1;return M.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()=>{g(!0),v(null);try{await M.saveAgentContext(t),o(t),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{g(!1)}},k=()=>{s(a),v(null)},E=()=>{t.trim()&&!confirm("Replace current context with the starter template?")||s(JS)};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."}),!t.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"})]}),p&&n.jsx("div",{className:p.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:p.text}),n.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[n.jsx("div",{className:"card intent-pane chat",children:n.jsx(Pi,{target:{kind:"context"},currentText:t,onApply:T=>{t.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:N>b?"msg-error":void 0,style:{fontSize:"0.75rem",color:N>b?void 0:"var(--text-muted)"},children:[N.toLocaleString()," / ",b.toLocaleString()," bytes"]})]}),n.jsx("textarea",{className:"form-textarea",value:t,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||!j,children:"Revert"}),n.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:S,disabled:f||!j||N>b||l,children:f?"Saving…":"Save"})]})]}),n.jsx("button",{type:"button",className:"floating-help",onClick:()=>x(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),n.jsx(Rm,{open:y,onClose:()=>x(!1),ariaLabel:"Brief assistant",children:n.jsx(Pi,{target:{kind:"context"},currentText:t,onApply:T=>{t.trim()&&!confirm("Replace the current context with the applied draft?")||(s(T),x(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function XS(t){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(t);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function ZS(t){const s=t.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 eb(t){return new Date(t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function tb(t,s){const a=s.emailExportError?"cases unknown":`${s.coveredCases.length}/${s.loadedCases.length} cases`;return`${t.signaturesValid>0?`${t.signaturesValid} ✓ tickets`:`${t.signaturesValid} tickets`} · ${a} · ${s.ticketsReferenced.length}/${s.ticketsInPeriod.length} tickets covered`}function nb(t){return t.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:t.emailExportError}:{kind:"ok",text:`${t.coveredCases.length} of ${t.loadedCases.length}`}}function rb(t){return t.periodStart!==null?null:t.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:t.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function kh(t,s="none in this report"){return t>0?{kind:"ok",text:`${t} ✓`}:{kind:"neutral",text:s}}function sb(t){return/Labels?$/.test(t)||t==="limits"||t==="fields"}function ab(t,s){const a=s[t];return a==null||a===""||sb(t)?null:typeof a=="object"?JSON.stringify(a):String(a)}function ib(t){const s=[];return t.missingCases.length>0&&s.push(`cases ${t.missingCases.join(", ")}`),t.ticketsNotReferenced.length>0&&s.push(`${t.ticketsNotReferenced.length} ticket${t.ticketsNotReferenced.length===1?"":"s"}`),s.length>0?`Not in the report: ${s.join(" · ")}`:null}function ob(t,s){var a;if(s)return s;if(!t)return null;if(t.kind==="sv-ticket")return t.attrs.ref||null;if(t.kind==="sv-approval"||t.kind==="sv-mandate")return t.attrs.ticket||null;if(t.kind==="sv-case"){const o=(a=t.data)==null?void 0:a.goal;return(o==null?void 0:o.ticketId)??null}return null}const lb="allow-popups allow-popups-to-escape-sandbox",cb="AI analysis — not verified",ub="Green = verified by the gateway — raw signed fields only",db="Grey dashed = the AI's own analysis, not verified",fb="= translation by the AI, not verified",hb="Übersetzung anzeigen / show translation";function Nh(t){var a;const s=((a=t.formatNotice)==null?void 0:a.blocksNotShown)??0;return s<=0?null:`This report was written in an older format — ${s} ${s===1?"block was":"blocks were"} not shown. Ask the AI to write it again.`}function mb(t,s){return s&&t.renderedHtmlGloss?t.renderedHtmlGloss:t.renderedHtml}function pb(t,s,a){const o=new URLSearchParams(t);return o.set("element",s),a?o.set("ticket",a):o.delete("ticket"),o}const gb={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function yb(t){return t.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${gb[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function vb(t){if(!t||t.kind!=="sv-case"||!t.data)return[];const s=Array.isArray(t.data.steps)?t.data.steps:[],a=t.data.goal,o=[...s.map(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 xb(t){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>body{margin:12px;background:#fff}</style></head><body>${t}</body></html>`}const Mc={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},wb={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function jb(t,s){return Array.isArray(s.fields)?s.fields.map(o=>({label:o.key,value:o.value})):{Ticket:["action","profile","time"],Mandate:["profile","mode","owners","intent"],Approval:["createdAt","decidedAt","whoLabel","status","waitSeconds"]}[t].filter(o=>s[o]!==void 0&&s[o]!==null).map(o=>({label:o,value:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])}))}function Sb(t,s){const a=wb[t].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:{...Mc,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 Vl(t,s){return s?n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:t}),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:Mc,children:jb(t,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))}),Sb(t,s.data??{})]})]}):null}function bb({report:t,elementId:s,ticketParam:a,onClose:o,onSelectTicket:l}){var x;const u=t.elements.find(j=>j.id===s),f=ob(u,a),g=f?t.ticketDetails[f]:void 0,p=vb(u),v=(x=t.proof.verifiedValues.find(j=>j.elementId===s))==null?void 0:x.summary,y=h.useRef(null);return h.useEffect(()=>{const j=y.current;if(!j||typeof j.getBoundingClientRect!="function")return;const N=j.getBoundingClientRect().top;(N<0||N>window.innerHeight-80)&&j.scrollIntoView({block:"start",behavior:"smooth"})},[s,a]),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}),p.length>0&&n.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:p.map(j=>n.jsxs("button",{type:"button",className:`btn btn-sm ${j.ticketId===f?"btn-secondary":"btn-ghost"}`,"aria-pressed":j.ticketId===f,onClick:()=>l(j.ticketId),children:[j.isGoal?"Goal: ":"",j.label]},j.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:Mc,children:Object.keys(u.data??{}).map(j=>{const N=ab(j,u.data??{});return N===null?null:n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:j}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:N})]},j)})})),g&&n.jsxs(n.Fragment,{children:[Vl("Ticket",g.ticket),Vl("Mandate",g.mandate),Vl("Approval",g.approval)]}),f&&!g&&n.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",f,"."]})]})}async function kb(t){const{html:s,filename:a}=await t.exportReport();t.download(s,a),await t.refresh()}function Ch({detail:t}){return t?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:t})]}):null}function Nb({report:t,open:s,selectedId:a,onOpenElement:o,detail:l}){const{proof:u,coverage:f}=t,g=yb(t.elements),p=ib(f),v=nb(f),y=rb(f),x=kh(u.signaturesValid),j=kh(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:x.kind==="ok"?"msg-ok":void 0,children:x.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Records checked"}),n.jsx("b",{className:j.kind==="ok"?"msg-ok":void 0,children:j.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Not verifiable"}),n.jsx("b",{children:u.unverifiableCount})]}),g.map(N=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),children:[n.jsx("span",{children:N.text}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},N.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(Ch,{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(Ch,{detail:y.detail})]}),p&&n.jsx("p",{className:"reports-missing",children:p})]}),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(N=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===N.elementId?" reports-row-selected":""}`,onClick:()=>o(N.elementId),title:"Show details",children:[n.jsx("span",{children:N.summary}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},N.elementId))]})]})}function Cb(){const[t,s]=h.useState(null),[a,o]=h.useState(!0),[l,u]=h.useState(null),[f,g]=h.useState(!1),[p,v]=h.useState(!1),[y,x]=h.useState(null),[j,N]=h.useState(!1),[b,S]=h.useState(!1),[k,E]=sa(),T=h.useCallback(()=>M.getReport().then(({report:z})=>s(z)).catch(z=>u(z instanceof Error?z.message:String(z))),[]),P=h.useCallback(()=>{o(!0),u(null),T().finally(()=>o(!1))},[T]);h.useEffect(()=>{P()},[P]);const I=h.useCallback(()=>{g(!0),M.recheckReport().then(({report:z})=>s(z)).catch(z=>u(z instanceof Error?z.message:String(z))).finally(()=>g(!1))},[]),U=h.useCallback(async()=>{v(!0),x(null);try{await kb({exportReport:()=>M.exportReportWithProof(),download:(z,oe)=>{const ue=URL.createObjectURL(new Blob([z],{type:"text/html"})),Y=document.createElement("a");Y.href=ue,Y.download=oe,Y.click(),URL.revokeObjectURL(ue)},refresh:T})}catch(z){x(z instanceof Error?z.message:String(z))}finally{v(!1)}},[T]),V=k.get("element"),F=k.get("ticket"),J=h.useCallback((z,oe)=>{E(pb(k,z,oe))},[k,E]),Q=h.useCallback(()=>{const z=new URLSearchParams(k);z.delete("element"),z.delete("ticket"),E(z,{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(es,{icon:"⚠",title:"Report unavailable",text:l})]});if(!t)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(es,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const te=XS(t.renderedHtml),ee=ZS(t.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:te}),n.jsxs("p",{className:"page-subtitle",children:[ee?`written by the AI under mandate ${ee} · `:"","checked ",eb(t.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:U,disabled:p,children:p?"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:tb(t.proof,t.coverage)}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>N(z=>!z),children:j?"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"}),ub]}),n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-a"}),db," (“",cb,"”)"]}),t.renderedHtmlGloss&&n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",fb]})]}),Nh(t)&&n.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:Nh(t)}),t.renderedHtmlGloss&&n.jsxs("label",{className:"reports-gloss-switch",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:b,onChange:z=>S(z.target.checked)}),n.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:n.jsx("span",{className:"reports-gloss-thumb"})}),n.jsx("span",{children:hb})]}),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."}),n.jsx("iframe",{title:"Report",sandbox:lb,srcDoc:xb(mb(t,b)),className:"reports-iframe"})]}),n.jsx(Nb,{report:t,open:j||!!V,selectedId:V,onOpenElement:z=>J(z),detail:V?n.jsx(bb,{report:t,elementId:V,ticketParam:F,onClose:Q,onSelectTicket:z=>J(V,z)}):void 0})]})]})})}function Qr({to:t}){const{search:s,hash:a}=Vt();return n.jsx(Pn,{to:`${t}${s}${a}`,replace:!0})}function Eb({children:t}){const{user:s,mode:a,domain:o}=yt();return s?a==="team"&&!o?n.jsx(Pn,{to:"/onboarding",replace:!0}):n.jsx(n.Fragment,{children:t}):n.jsx(Pn,{to:"/login",replace:!0})}function Tb(){const{user:t,handleSessionLocked:s,refreshGroups:a}=yt();return Be("session-locked",o=>{const l=o==null?void 0:o.message;s(l)}),Be("team-membership-changed",()=>{a()}),n.jsxs(hv,{children:[n.jsx(rt,{path:"/login",element:t?n.jsx(Pn,{to:"/",replace:!0}):n.jsx(d0,{})}),n.jsx(rt,{path:"/onboarding",element:t?n.jsx(y0,{}):n.jsx(Pn,{to:"/login",replace:!0})}),n.jsxs(rt,{element:n.jsx(Eb,{children:n.jsx(u0,{})}),children:[n.jsx(rt,{path:"/",element:n.jsx(uw,{})}),n.jsx(rt,{path:"/mandates",element:n.jsx(Nj,{})}),n.jsx(rt,{path:"/mandates/new/intent",element:n.jsx(zw,{})}),n.jsx(rt,{path:"/mandates/new/sign",element:n.jsx(ej,{})}),n.jsx(rt,{path:"/integrations",element:n.jsx(oj,{})}),n.jsx(rt,{path:"/team",element:n.jsx(lj,{})}),n.jsx(rt,{path:"/tickets",element:n.jsx(mS,{})}),n.jsx(rt,{path:"/blocked",element:n.jsx(pS,{})}),n.jsx(rt,{path:"/approvals",element:n.jsx(KS,{})}),n.jsx(rt,{path:"/reports",element:n.jsx(Cb,{})}),n.jsx(rt,{path:"/agent/new",element:n.jsx(Pn,{to:"/mandates?new=1",replace:!0})}),n.jsx(rt,{path:"/agent/gate",element:n.jsx(Qr,{to:"/mandates/new/intent"})}),n.jsx(rt,{path:"/agent/review",element:n.jsx(Qr,{to:"/mandates/new/sign"})}),n.jsx(rt,{path:"/authorizations",element:n.jsx(Qr,{to:"/mandates"})}),n.jsx(rt,{path:"/groups",element:n.jsx(Qr,{to:"/team"})}),n.jsx(rt,{path:"/audit",element:n.jsx(Qr,{to:"/tickets"})}),n.jsx(rt,{path:"/proposals",element:n.jsx(Qr,{to:"/approvals"})}),n.jsx(rt,{path:"/agent-brief",element:n.jsx(QS,{})}),n.jsx(rt,{path:"/settings",element:n.jsx(NS,{})}),n.jsx(rt,{path:"/settings/services",element:n.jsx(Pn,{to:"/settings",replace:!0})}),n.jsx(rt,{path:"/deploy",element:n.jsx(Pn,{to:"/integrations",replace:!0})})]}),n.jsx(rt,{path:"*",element:n.jsx(Pn,{to:"/",replace:!0})})]})}function Ib(){return n.jsx(Mv,{children:n.jsx(ex,{children:n.jsx(rx,{children:n.jsx(Tb,{})})})})}uy.createRoot(document.getElementById("root")).render(n.jsx(h.StrictMode,{children:n.jsx(Ib,{})}));
|