@suveren/gateway 0.33.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,123 @@
1
+ var Wy=Object.defineProperty;var Hy=(e,s,a)=>s in e?Wy(e,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[s]=a;var Qs=(e,s,a)=>Hy(e,typeof s!="symbol"?s+"":s,a);(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))o(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const f of u.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&o(f)}).observe(document,{childList:!0,subtree:!0});function a(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(l){if(l.ep)return;l.ep=!0;const u=a(l);fetch(l.href,u)}})();var Wl={exports:{}},Xs={},Hl={exports:{}},De={};/**
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 Rf;function Vy(){if(Rf)return De;Rf=1;var e=Symbol.for("react.element"),s=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),f=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),w=Symbol.iterator;function x(A){return A===null||typeof A!="object"?null:(A=w&&A[w]||A["@@iterator"],typeof A=="function"?A:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,S={};function N(A,_,se){this.props=A,this.context=_,this.refs=S,this.updater=se||b}N.prototype.isReactComponent={},N.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")},N.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function T(){}T.prototype=N.prototype;function E(A,_,se){this.props=A,this.context=_,this.refs=S,this.updater=se||b}var P=E.prototype=new T;P.constructor=E,k(P,N.prototype),P.isPureReactComponent=!0;var I=Array.isArray,B=Object.prototype.hasOwnProperty,M={current:null},q={key:!0,ref:!0,__self:!0,__source:!0};function z(A,_,se){var te,H={},ie=null,ue=null;if(_!=null)for(te in _.ref!==void 0&&(ue=_.ref),_.key!==void 0&&(ie=""+_.key),_)B.call(_,te)&&!q.hasOwnProperty(te)&&(H[te]=_[te]);var ge=arguments.length-2;if(ge===1)H.children=se;else if(1<ge){for(var ve=Array(ge),le=0;le<ge;le++)ve[le]=arguments[le+2];H.children=ve}if(A&&A.defaultProps)for(te in ge=A.defaultProps,ge)H[te]===void 0&&(H[te]=ge[te]);return{$$typeof:e,type:A,key:ie,ref:ue,props:H,_owner:M.current}}function U(A,_){return{$$typeof:e,type:A.type,key:_,ref:A.ref,props:A.props,_owner:A._owner}}function Z(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function G(A){var _={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(se){return _[se]})}var O=/\/+/g;function ne(A,_){return typeof A=="object"&&A!==null&&A.key!=null?G(""+A.key):_.toString(36)}function fe(A,_,se,te,H){var ie=typeof A;(ie==="undefined"||ie==="boolean")&&(A=null);var ue=!1;if(A===null)ue=!0;else switch(ie){case"string":case"number":ue=!0;break;case"object":switch(A.$$typeof){case e:case s:ue=!0}}if(ue)return ue=A,H=H(ue),A=te===""?"."+ne(ue,0):te,I(H)?(se="",A!=null&&(se=A.replace(O,"$&/")+"/"),fe(H,_,se,"",function(le){return le})):H!=null&&(Z(H)&&(H=U(H,se+(!H.key||ue&&ue.key===H.key?"":(""+H.key).replace(O,"$&/")+"/")+A)),_.push(H)),1;if(ue=0,te=te===""?".":te+":",I(A))for(var ge=0;ge<A.length;ge++){ie=A[ge];var ve=te+ne(ie,ge);ue+=fe(ie,_,se,ve,H)}else if(ve=x(A),typeof ve=="function")for(A=ve.call(A),ge=0;!(ie=A.next()).done;)ie=ie.value,ve=te+ne(ie,ge++),ue+=fe(ie,_,se,ve,H);else if(ie==="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 ue}function ee(A,_,se){if(A==null)return A;var te=[],H=0;return fe(A,te,"","",function(ie){return _.call(se,ie,H++)}),te}function pe(A){if(A._status===-1){var _=A._result;_=_(),_.then(function(se){(A._status===0||A._status===-1)&&(A._status=1,A._result=se)},function(se){(A._status===0||A._status===-1)&&(A._status=2,A._result=se)}),A._status===-1&&(A._status=0,A._result=_)}if(A._status===1)return A._result.default;throw A._result}var Ne={current:null},X={transition:null},Q={ReactCurrentDispatcher:Ne,ReactCurrentBatchConfig:X,ReactCurrentOwner:M};function Y(){throw Error("act(...) is not supported in production builds of React.")}return De.Children={map:ee,forEach:function(A,_,se){ee(A,function(){_.apply(this,arguments)},se)},count:function(A){var _=0;return ee(A,function(){_++}),_},toArray:function(A){return ee(A,function(_){return _})||[]},only:function(A){if(!Z(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},De.Component=N,De.Fragment=a,De.Profiler=l,De.PureComponent=E,De.StrictMode=o,De.Suspense=p,De.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Q,De.act=Y,De.cloneElement=function(A,_,se){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var te=k({},A.props),H=A.key,ie=A.ref,ue=A._owner;if(_!=null){if(_.ref!==void 0&&(ie=_.ref,ue=M.current),_.key!==void 0&&(H=""+_.key),A.type&&A.type.defaultProps)var ge=A.type.defaultProps;for(ve in _)B.call(_,ve)&&!q.hasOwnProperty(ve)&&(te[ve]=_[ve]===void 0&&ge!==void 0?ge[ve]:_[ve])}var ve=arguments.length-2;if(ve===1)te.children=se;else if(1<ve){ge=Array(ve);for(var le=0;le<ve;le++)ge[le]=arguments[le+2];te.children=ge}return{$$typeof:e,type:A.type,key:H,ref:ie,props:te,_owner:ue}},De.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},De.createElement=z,De.createFactory=function(A){var _=z.bind(null,A);return _.type=A,_},De.createRef=function(){return{current:null}},De.forwardRef=function(A){return{$$typeof:g,render:A}},De.isValidElement=Z,De.lazy=function(A){return{$$typeof:y,_payload:{_status:-1,_result:A},_init:pe}},De.memo=function(A,_){return{$$typeof:v,type:A,compare:_===void 0?null:_}},De.startTransition=function(A){var _=X.transition;X.transition={};try{A()}finally{X.transition=_}},De.unstable_act=Y,De.useCallback=function(A,_){return Ne.current.useCallback(A,_)},De.useContext=function(A){return Ne.current.useContext(A)},De.useDebugValue=function(){},De.useDeferredValue=function(A){return Ne.current.useDeferredValue(A)},De.useEffect=function(A,_){return Ne.current.useEffect(A,_)},De.useId=function(){return Ne.current.useId()},De.useImperativeHandle=function(A,_,se){return Ne.current.useImperativeHandle(A,_,se)},De.useInsertionEffect=function(A,_){return Ne.current.useInsertionEffect(A,_)},De.useLayoutEffect=function(A,_){return Ne.current.useLayoutEffect(A,_)},De.useMemo=function(A,_){return Ne.current.useMemo(A,_)},De.useReducer=function(A,_,se){return Ne.current.useReducer(A,_,se)},De.useRef=function(A){return Ne.current.useRef(A)},De.useState=function(A){return Ne.current.useState(A)},De.useSyncExternalStore=function(A,_,se){return Ne.current.useSyncExternalStore(A,_,se)},De.useTransition=function(){return Ne.current.useTransition()},De.version="18.3.1",De}var Pf;function Nc(){return Pf||(Pf=1,Hl.exports=Vy()),Hl.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 $f;function Gy(){if($f)return Xs;$f=1;var e=Nc(),s=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function f(g,p,v){var y,w={},x=null,b=null;v!==void 0&&(x=""+v),p.key!==void 0&&(x=""+p.key),p.ref!==void 0&&(b=p.ref);for(y in p)o.call(p,y)&&!u.hasOwnProperty(y)&&(w[y]=p[y]);if(g&&g.defaultProps)for(y in p=g.defaultProps,p)w[y]===void 0&&(w[y]=p[y]);return{$$typeof:s,type:g,key:x,ref:b,props:w,_owner:l.current}}return Xs.Fragment=a,Xs.jsx=f,Xs.jsxs=f,Xs}var _f;function Ky(){return _f||(_f=1,Wl.exports=Gy()),Wl.exports}var n=Ky(),h=Nc(),Ni={},Vl={exports:{}},Jt={},Gl={exports:{}},Kl={};/**
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 Lf;function qy(){return Lf||(Lf=1,(function(e){function s(X,Q){var Y=X.length;X.push(Q);e:for(;0<Y;){var A=Y-1>>>1,_=X[A];if(0<l(_,Q))X[A]=Q,X[Y]=_,Y=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],Y=X.pop();if(Y!==Q){X[0]=Y;e:for(var A=0,_=X.length,se=_>>>1;A<se;){var te=2*(A+1)-1,H=X[te],ie=te+1,ue=X[ie];if(0>l(H,Y))ie<_&&0>l(ue,H)?(X[A]=ue,X[ie]=Y,A=ie):(X[A]=H,X[te]=Y,A=te);else if(ie<_&&0>l(ue,Y))X[A]=ue,X[ie]=Y,A=ie;else break e}}return Q}function l(X,Q){var Y=X.sortIndex-Q.sortIndex;return Y!==0?Y:X.id-Q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var f=Date,g=f.now();e.unstable_now=function(){return f.now()-g}}var p=[],v=[],y=1,w=null,x=3,b=!1,k=!1,S=!1,N=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,E=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),!k)if(a(p)!==null)k=!0,pe(B);else{var Q=a(v);Q!==null&&Ne(I,Q.startTime-X)}}function B(X,Q){k=!1,S&&(S=!1,T(z),z=-1),b=!0;var Y=x;try{for(P(Q),w=a(p);w!==null&&(!(w.expirationTime>Q)||X&&!G());){var A=w.callback;if(typeof A=="function"){w.callback=null,x=w.priorityLevel;var _=A(w.expirationTime<=Q);Q=e.unstable_now(),typeof _=="function"?w.callback=_:w===a(p)&&o(p),P(Q)}else o(p);w=a(p)}if(w!==null)var se=!0;else{var te=a(v);te!==null&&Ne(I,te.startTime-Q),se=!1}return se}finally{w=null,x=Y,b=!1}}var M=!1,q=null,z=-1,U=5,Z=-1;function G(){return!(e.unstable_now()-Z<U)}function O(){if(q!==null){var X=e.unstable_now();Z=X;var Q=!0;try{Q=q(!0,X)}finally{Q?ne():(M=!1,q=null)}}else M=!1}var ne;if(typeof E=="function")ne=function(){E(O)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,ee=fe.port2;fe.port1.onmessage=O,ne=function(){ee.postMessage(null)}}else ne=function(){N(O,0)};function pe(X){q=X,M||(M=!0,ne())}function Ne(X,Q){z=N(function(){X(e.unstable_now())},Q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(X){X.callback=null},e.unstable_continueExecution=function(){k||b||(k=!0,pe(B))},e.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"):U=0<X?Math.floor(1e3/X):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return a(p)},e.unstable_next=function(X){switch(x){case 1:case 2:case 3:var Q=3;break;default:Q=x}var Y=x;x=Q;try{return X()}finally{x=Y}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(X,Q){switch(X){case 1:case 2:case 3:case 4:case 5:break;default:X=3}var Y=x;x=X;try{return Q()}finally{x=Y}},e.unstable_scheduleCallback=function(X,Q,Y){var A=e.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?A+Y:A):Y=A,X){case 1:var _=-1;break;case 2:_=250;break;case 5:_=1073741823;break;case 4:_=1e4;break;default:_=5e3}return _=Y+_,X={id:y++,callback:Q,priorityLevel:X,startTime:Y,expirationTime:_,sortIndex:-1},Y>A?(X.sortIndex=Y,s(v,X),a(p)===null&&X===a(v)&&(S?(T(z),z=-1):S=!0,Ne(I,Y-A))):(X.sortIndex=_,s(p,X),k||b||(k=!0,pe(B))),X},e.unstable_shouldYield=G,e.unstable_wrapCallback=function(X){var Q=x;return function(){var Y=x;x=Q;try{return X.apply(this,arguments)}finally{x=Y}}}})(Kl)),Kl}var zf;function Yy(){return zf||(zf=1,Gl.exports=qy()),Gl.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 Ff;function Jy(){if(Ff)return Jt;Ff=1;var e=Nc(),s=Yy();function a(t){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;i<arguments.length;i++)r+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,l={};function u(t,r){f(t,r),f(t+"Capture",r)}function f(t,r){for(l[t]=r,t=0;t<r.length;t++)o.add(r[t])}var 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={},w={};function x(t){return p.call(w,t)?!0:p.call(y,t)?!1:v.test(t)?w[t]=!0:(y[t]=!0,!1)}function b(t,r,i,c){if(i!==null&&i.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return c?!1:i!==null?!i.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function k(t,r,i,c){if(r===null||typeof r>"u"||b(t,r,i,c))return!0;if(c)return!1;if(i!==null)switch(i.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function S(t,r,i,c,d,m,j){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=c,this.attributeNamespace=d,this.mustUseProperty=i,this.propertyName=t,this.type=r,this.sanitizeURL=m,this.removeEmptyString=j}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){N[t]=new S(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var r=t[0];N[r]=new S(r,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){N[t]=new S(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){N[t]=new S(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){N[t]=new S(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){N[t]=new S(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){N[t]=new S(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){N[t]=new S(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){N[t]=new S(t,5,!1,t.toLowerCase(),null,!1,!1)});var T=/[\-:]([a-z])/g;function E(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var r=t.replace(T,E);N[r]=new S(r,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var r=t.replace(T,E);N[r]=new S(r,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var r=t.replace(T,E);N[r]=new S(r,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){N[t]=new S(t,1,!1,t.toLowerCase(),null,!1,!1)}),N.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){N[t]=new S(t,1,!1,t.toLowerCase(),null,!0,!0)});function P(t,r,i,c){var d=N.hasOwnProperty(r)?N[r]:null;(d!==null?d.type!==0:c||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(k(r,i,d,c)&&(i=null),c||d===null?x(r)&&(i===null?t.removeAttribute(r):t.setAttribute(r,""+i)):d.mustUseProperty?t[d.propertyName]=i===null?d.type===3?!1:"":i:(r=d.attributeName,c=d.attributeNamespace,i===null?t.removeAttribute(r):(d=d.type,i=d===3||d===4&&i===!0?"":""+i,c?t.setAttributeNS(c,r,i):t.setAttribute(r,i))))}var I=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,B=Symbol.for("react.element"),M=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),z=Symbol.for("react.strict_mode"),U=Symbol.for("react.profiler"),Z=Symbol.for("react.provider"),G=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),fe=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),pe=Symbol.for("react.lazy"),Ne=Symbol.for("react.offscreen"),X=Symbol.iterator;function Q(t){return t===null||typeof t!="object"?null:(t=X&&t[X]||t["@@iterator"],typeof t=="function"?t:null)}var Y=Object.assign,A;function _(t){if(A===void 0)try{throw Error()}catch(i){var r=i.stack.trim().match(/\n( *(at )?)/);A=r&&r[1]||""}return`
34
+ `+A+t}var se=!1;function te(t,r){if(!t||se)return"";se=!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(V){var c=V}Reflect.construct(t,[],r)}else{try{r.call()}catch(V){c=V}t.call(r.prototype)}else{try{throw Error()}catch(V){c=V}t()}}catch(V){if(V&&c&&typeof V.stack=="string"){for(var d=V.stack.split(`
35
+ `),m=c.stack.split(`
36
+ `),j=d.length-1,C=m.length-1;1<=j&&0<=C&&d[j]!==m[C];)C--;for(;1<=j&&0<=C;j--,C--)if(d[j]!==m[C]){if(j!==1||C!==1)do if(j--,C--,0>C||d[j]!==m[C]){var R=`
37
+ `+d[j].replace(" at new "," at ");return t.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",t.displayName)),R}while(1<=j&&0<=C);break}}}finally{se=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?_(t):""}function H(t){switch(t.tag){case 5:return _(t.type);case 16:return _("Lazy");case 13:return _("Suspense");case 19:return _("SuspenseList");case 0:case 2:case 15:return t=te(t.type,!1),t;case 11:return t=te(t.type.render,!1),t;case 1:return t=te(t.type,!0),t;default:return""}}function ie(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case q:return"Fragment";case M:return"Portal";case U:return"Profiler";case z:return"StrictMode";case ne:return"Suspense";case fe:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case G:return(t.displayName||"Context")+".Consumer";case Z:return(t._context.displayName||"Context")+".Provider";case O:var r=t.render;return t=t.displayName,t||(t=r.displayName||r.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ee:return r=t.displayName||null,r!==null?r:ie(t.type)||"Memo";case pe:r=t._payload,t=t._init;try{return ie(t(r))}catch{}}return null}function ue(t){var r=t.type;switch(t.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=r.render,t=t.displayName||t.name||"",r.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ie(r);case 8:return r===z?"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 ge(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function ve(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function le(t){var r=ve(t)?"checked":"value",i=Object.getOwnPropertyDescriptor(t.constructor.prototype,r),c=""+t[r];if(!t.hasOwnProperty(r)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var d=i.get,m=i.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return d.call(this)},set:function(j){c=""+j,m.call(this,j)}}),Object.defineProperty(t,r,{enumerable:i.enumerable}),{getValue:function(){return c},setValue:function(j){c=""+j},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function qe(t){t._valueTracker||(t._valueTracker=le(t))}function be(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var i=r.getValue(),c="";return t&&(c=ve(t)?t.checked?"true":"false":t.value),t=c,t!==i?(r.setValue(t),!0):!1}function oe(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Le(t,r){var i=r.checked;return Y({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??t._wrapperState.initialChecked})}function ze(t,r){var i=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;i=ge(r.value!=null?r.value:i),t._wrapperState={initialChecked:c,initialValue:i,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Ue(t,r){r=r.checked,r!=null&&P(t,"checked",r,!1)}function we(t,r){Ue(t,r);var i=ge(r.value),c=r.type;if(i!=null)c==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+i):t.value!==""+i&&(t.value=""+i);else if(c==="submit"||c==="reset"){t.removeAttribute("value");return}r.hasOwnProperty("value")?Ze(t,r.type,i):r.hasOwnProperty("defaultValue")&&Ze(t,r.type,ge(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(t.defaultChecked=!!r.defaultChecked)}function nt(t,r,i){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var c=r.type;if(!(c!=="submit"&&c!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+t._wrapperState.initialValue,i||r===t.value||(t.value=r),t.defaultValue=r}i=t.name,i!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,i!==""&&(t.name=i)}function Ze(t,r,i){(r!=="number"||oe(t.ownerDocument)!==t)&&(i==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+i&&(t.defaultValue=""+i))}var Ye=Array.isArray;function We(t,r,i,c){if(t=t.options,r){r={};for(var d=0;d<i.length;d++)r["$"+i[d]]=!0;for(i=0;i<t.length;i++)d=r.hasOwnProperty("$"+t[i].value),t[i].selected!==d&&(t[i].selected=d),d&&c&&(t[i].defaultSelected=!0)}else{for(i=""+ge(i),r=null,d=0;d<t.length;d++){if(t[d].value===i){t[d].selected=!0,c&&(t[d].defaultSelected=!0);return}r!==null||t[d].disabled||(r=t[d])}r!==null&&(r.selected=!0)}}function dt(t,r){if(r.dangerouslySetInnerHTML!=null)throw Error(a(91));return Y({},r,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function ft(t,r){var i=r.value;if(i==null){if(i=r.children,r=r.defaultValue,i!=null){if(r!=null)throw Error(a(92));if(Ye(i)){if(1<i.length)throw Error(a(93));i=i[0]}r=i}r==null&&(r=""),i=r}t._wrapperState={initialValue:ge(i)}}function Fe(t,r){var i=ge(r.value),c=ge(r.defaultValue);i!=null&&(i=""+i,i!==t.value&&(t.value=i),r.defaultValue==null&&t.defaultValue!==i&&(t.defaultValue=i)),c!=null&&(t.defaultValue=""+c)}function me(t){var r=t.textContent;r===t._wrapperState.initialValue&&r!==""&&r!==null&&(t.value=r)}function Re(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Oe(t,r){return t==null||t==="http://www.w3.org/1999/xhtml"?Re(r):t==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var K,J=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,i,c,d){MSApp.execUnsafeLocalFunction(function(){return t(r,i,c,d)})}:t})(function(t,r){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=r;else{for(K=K||document.createElement("div"),K.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=K.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;r.firstChild;)t.appendChild(r.firstChild)}});function ye(t,r){if(r){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=r;return}}t.textContent=r}var 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},Ve=["Webkit","ms","Moz","O"];Object.keys(He).forEach(function(t){Ve.forEach(function(r){r=r+t.charAt(0).toUpperCase()+t.substring(1),He[r]=He[t]})});function rt(t,r,i){return r==null||typeof r=="boolean"||r===""?"":i||typeof r!="number"||r===0||He.hasOwnProperty(t)&&He[t]?(""+r).trim():r+"px"}function Ht(t,r){t=t.style;for(var i in r)if(r.hasOwnProperty(i)){var c=i.indexOf("--")===0,d=rt(i,r[i],c);i==="float"&&(i="cssFloat"),c?t.setProperty(i,d):t[i]=d}}var Ot=Y({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function et(t,r){if(r){if(Ot[t]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(a(137,t));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(a(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(a(61))}if(r.style!=null&&typeof r.style!="object")throw Error(a(62))}}function W(t,r){if(t.indexOf("-")===-1)return typeof r.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var xe=null;function Ae(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var st=null,yt=null,Ke=null;function Nt(t){if(t=zs(t)){if(typeof st!="function")throw Error(a(280));var r=t.stateNode;r&&(r=Ba(r),st(t.stateNode,t.type,r))}}function St(t){yt?Ke?Ke.push(t):Ke=[t]:yt=t}function Xt(){if(yt){var t=yt,r=Ke;if(Ke=yt=null,Nt(t),r)for(t=0;t<r.length;t++)Nt(r[t])}}function de(t,r){return t(r)}function Ce(){}var Ie=!1;function Be(t,r,i){if(Ie)return t(r,i);Ie=!0;try{return de(t,r,i)}finally{Ie=!1,(yt!==null||Ke!==null)&&(Ce(),Xt())}}function Xe(t,r){var i=t.stateNode;if(i===null)return null;var c=Ba(i);if(c===null)return null;i=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(i&&typeof i!="function")throw Error(a(231,r,typeof i));return i}var Ct=!1;if(g)try{var Pt={};Object.defineProperty(Pt,"passive",{get:function(){Ct=!0}}),window.addEventListener("test",Pt,Pt),window.removeEventListener("test",Pt,Pt)}catch{Ct=!1}function zr(t,r,i,c,d,m,j,C,R){var V=Array.prototype.slice.call(arguments,3);try{r.apply(i,V)}catch(ae){this.onError(ae)}}var fr=!1,Fr=null,Hn=!1,hr=null,oo={onError:function(t){fr=!0,Fr=t}};function ya(t,r,i,c,d,m,j,C,R){fr=!1,Fr=null,zr.apply(oo,arguments)}function va(t,r,i,c,d,m,j,C,R){if(ya.apply(this,arguments),fr){if(fr){var V=Fr;fr=!1,Fr=null}else throw Error(a(198));Hn||(Hn=!0,hr=V)}}function bn(t){var r=t,i=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(i=r.return),t=r.return;while(t)}return r.tag===3?i:null}function ys(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function xa(t){if(bn(t)!==t)throw Error(a(188))}function Mr(t){var r=t.alternate;if(!r){if(r=bn(t),r===null)throw Error(a(188));return r!==t?null:t}for(var i=t,c=r;;){var d=i.return;if(d===null)break;var m=d.alternate;if(m===null){if(c=d.return,c!==null){i=c;continue}break}if(d.child===m.child){for(m=d.child;m;){if(m===i)return xa(d),t;if(m===c)return xa(d),r;m=m.sibling}throw Error(a(188))}if(i.return!==c.return)i=d,c=m;else{for(var j=!1,C=d.child;C;){if(C===i){j=!0,i=d,c=m;break}if(C===c){j=!0,c=d,i=m;break}C=C.sibling}if(!j){for(C=m.child;C;){if(C===i){j=!0,i=m,c=d;break}if(C===c){j=!0,c=m,i=d;break}C=C.sibling}if(!j)throw Error(a(189))}}if(i.alternate!==c)throw Error(a(190))}if(i.tag!==3)throw Error(a(188));return i.stateNode.current===i?t:r}function kn(t){return t=Mr(t),t!==null?nu(t):null}function nu(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var r=nu(t);if(r!==null)return r;t=t.sibling}return null}var ru=s.unstable_scheduleCallback,su=s.unstable_cancelCallback,eg=s.unstable_shouldYield,tg=s.unstable_requestPaint,vt=s.unstable_now,ng=s.unstable_getCurrentPriorityLevel,lo=s.unstable_ImmediatePriority,au=s.unstable_UserBlockingPriority,wa=s.unstable_NormalPriority,rg=s.unstable_LowPriority,iu=s.unstable_IdlePriority,ja=null,Nn=null;function sg(t){if(Nn&&typeof Nn.onCommitFiberRoot=="function")try{Nn.onCommitFiberRoot(ja,t,void 0,(t.current.flags&128)===128)}catch{}}var hn=Math.clz32?Math.clz32:og,ag=Math.log,ig=Math.LN2;function og(t){return t>>>=0,t===0?32:31-(ag(t)/ig|0)|0}var Sa=64,ba=4194304;function vs(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function ka(t,r){var i=t.pendingLanes;if(i===0)return 0;var c=0,d=t.suspendedLanes,m=t.pingedLanes,j=i&268435455;if(j!==0){var C=j&~d;C!==0?c=vs(C):(m&=j,m!==0&&(c=vs(m)))}else j=i&~d,j!==0?c=vs(j):m!==0&&(c=vs(m));if(c===0)return 0;if(r!==0&&r!==c&&(r&d)===0&&(d=c&-c,m=r&-r,d>=m||d===16&&(m&4194240)!==0))return r;if((c&4)!==0&&(c|=i&16),r=t.entangledLanes,r!==0)for(t=t.entanglements,r&=c;0<r;)i=31-hn(r),d=1<<i,c|=t[i],r&=~d;return c}function lg(t,r){switch(t){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function cg(t,r){for(var i=t.suspendedLanes,c=t.pingedLanes,d=t.expirationTimes,m=t.pendingLanes;0<m;){var j=31-hn(m),C=1<<j,R=d[j];R===-1?((C&i)===0||(C&c)!==0)&&(d[j]=lg(C,r)):R<=r&&(t.expiredLanes|=C),m&=~C}}function co(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function ou(){var t=Sa;return Sa<<=1,(Sa&4194240)===0&&(Sa=64),t}function uo(t){for(var r=[],i=0;31>i;i++)r.push(t);return r}function xs(t,r,i){t.pendingLanes|=r,r!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,r=31-hn(r),t[r]=i}function ug(t,r){var i=t.pendingLanes&~r;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=r,t.mutableReadLanes&=r,t.entangledLanes&=r,r=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<i;){var d=31-hn(i),m=1<<d;r[d]=0,c[d]=-1,t[d]=-1,i&=~m}}function fo(t,r){var i=t.entangledLanes|=r;for(t=t.entanglements;i;){var c=31-hn(i),d=1<<c;d&r|t[c]&r&&(t[c]|=r),i&=~d}}var tt=0;function lu(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var cu,ho,uu,du,fu,mo=!1,Na=[],Vn=null,Gn=null,Kn=null,ws=new Map,js=new Map,qn=[],dg="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 hu(t,r){switch(t){case"focusin":case"focusout":Vn=null;break;case"dragenter":case"dragleave":Gn=null;break;case"mouseover":case"mouseout":Kn=null;break;case"pointerover":case"pointerout":ws.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":js.delete(r.pointerId)}}function Ss(t,r,i,c,d,m){return t===null||t.nativeEvent!==m?(t={blockedOn:r,domEventName:i,eventSystemFlags:c,nativeEvent:m,targetContainers:[d]},r!==null&&(r=zs(r),r!==null&&ho(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,d!==null&&r.indexOf(d)===-1&&r.push(d),t)}function fg(t,r,i,c,d){switch(r){case"focusin":return Vn=Ss(Vn,t,r,i,c,d),!0;case"dragenter":return Gn=Ss(Gn,t,r,i,c,d),!0;case"mouseover":return Kn=Ss(Kn,t,r,i,c,d),!0;case"pointerover":var m=d.pointerId;return ws.set(m,Ss(ws.get(m)||null,t,r,i,c,d)),!0;case"gotpointercapture":return m=d.pointerId,js.set(m,Ss(js.get(m)||null,t,r,i,c,d)),!0}return!1}function mu(t){var r=mr(t.target);if(r!==null){var i=bn(r);if(i!==null){if(r=i.tag,r===13){if(r=ys(i),r!==null){t.blockedOn=r,fu(t.priority,function(){uu(i)});return}}else if(r===3&&i.stateNode.current.memoizedState.isDehydrated){t.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Ca(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var i=go(t.domEventName,t.eventSystemFlags,r[0],t.nativeEvent);if(i===null){i=t.nativeEvent;var c=new i.constructor(i.type,i);xe=c,i.target.dispatchEvent(c),xe=null}else return r=zs(i),r!==null&&ho(r),t.blockedOn=i,!1;r.shift()}return!0}function pu(t,r,i){Ca(t)&&i.delete(r)}function hg(){mo=!1,Vn!==null&&Ca(Vn)&&(Vn=null),Gn!==null&&Ca(Gn)&&(Gn=null),Kn!==null&&Ca(Kn)&&(Kn=null),ws.forEach(pu),js.forEach(pu)}function bs(t,r){t.blockedOn===r&&(t.blockedOn=null,mo||(mo=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,hg)))}function ks(t){function r(d){return bs(d,t)}if(0<Na.length){bs(Na[0],t);for(var i=1;i<Na.length;i++){var c=Na[i];c.blockedOn===t&&(c.blockedOn=null)}}for(Vn!==null&&bs(Vn,t),Gn!==null&&bs(Gn,t),Kn!==null&&bs(Kn,t),ws.forEach(r),js.forEach(r),i=0;i<qn.length;i++)c=qn[i],c.blockedOn===t&&(c.blockedOn=null);for(;0<qn.length&&(i=qn[0],i.blockedOn===null);)mu(i),i.blockedOn===null&&qn.shift()}var Or=I.ReactCurrentBatchConfig,Ea=!0;function mg(t,r,i,c){var d=tt,m=Or.transition;Or.transition=null;try{tt=1,po(t,r,i,c)}finally{tt=d,Or.transition=m}}function pg(t,r,i,c){var d=tt,m=Or.transition;Or.transition=null;try{tt=4,po(t,r,i,c)}finally{tt=d,Or.transition=m}}function po(t,r,i,c){if(Ea){var d=go(t,r,i,c);if(d===null)$o(t,r,c,Ta,i),hu(t,c);else if(fg(d,t,r,i,c))c.stopPropagation();else if(hu(t,c),r&4&&-1<dg.indexOf(t)){for(;d!==null;){var m=zs(d);if(m!==null&&cu(m),m=go(t,r,i,c),m===null&&$o(t,r,c,Ta,i),m===d)break;d=m}d!==null&&c.stopPropagation()}else $o(t,r,c,null,i)}}var Ta=null;function go(t,r,i,c){if(Ta=null,t=Ae(c),t=mr(t),t!==null)if(r=bn(t),r===null)t=null;else if(i=r.tag,i===13){if(t=ys(r),t!==null)return t;t=null}else if(i===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null);return Ta=t,null}function gu(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(ng()){case lo:return 1;case au:return 4;case wa:case rg:return 16;case iu:return 536870912;default:return 16}default:return 16}}var Yn=null,yo=null,Aa=null;function yu(){if(Aa)return Aa;var t,r=yo,i=r.length,c,d="value"in Yn?Yn.value:Yn.textContent,m=d.length;for(t=0;t<i&&r[t]===d[t];t++);var j=i-t;for(c=1;c<=j&&r[i-c]===d[m-c];c++);return Aa=d.slice(t,1<c?1-c:void 0)}function Ia(t){var r=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&r===13&&(t=13)):t=r,t===10&&(t=13),32<=t||t===13?t:0}function Ra(){return!0}function vu(){return!1}function Zt(t){function r(i,c,d,m,j){this._reactName=i,this._targetInst=d,this.type=c,this.nativeEvent=m,this.target=j,this.currentTarget=null;for(var C in t)t.hasOwnProperty(C)&&(i=t[C],this[C]=i?i(m):m[C]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?Ra:vu,this.isPropagationStopped=vu,this}return Y(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=Ra)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=Ra)},persist:function(){},isPersistent:Ra}),r}var Br={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},vo=Zt(Br),Ns=Y({},Br,{view:0,detail:0}),gg=Zt(Ns),xo,wo,Cs,Pa=Y({},Ns,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:So,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Cs&&(Cs&&t.type==="mousemove"?(xo=t.screenX-Cs.screenX,wo=t.screenY-Cs.screenY):wo=xo=0,Cs=t),xo)},movementY:function(t){return"movementY"in t?t.movementY:wo}}),xu=Zt(Pa),yg=Y({},Pa,{dataTransfer:0}),vg=Zt(yg),xg=Y({},Ns,{relatedTarget:0}),jo=Zt(xg),wg=Y({},Br,{animationName:0,elapsedTime:0,pseudoElement:0}),jg=Zt(wg),Sg=Y({},Br,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),bg=Zt(Sg),kg=Y({},Br,{data:0}),wu=Zt(kg),Ng={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Cg={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"},Eg={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Tg(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=Eg[t])?!!r[t]:!1}function So(){return Tg}var Ag=Y({},Ns,{key:function(t){if(t.key){var r=Ng[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Ia(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Cg[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:So,charCode:function(t){return t.type==="keypress"?Ia(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Ia(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),Ig=Zt(Ag),Rg=Y({},Pa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ju=Zt(Rg),Pg=Y({},Ns,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:So}),$g=Zt(Pg),_g=Y({},Br,{propertyName:0,elapsedTime:0,pseudoElement:0}),Lg=Zt(_g),zg=Y({},Pa,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Fg=Zt(zg),Mg=[9,13,27,32],bo=g&&"CompositionEvent"in window,Es=null;g&&"documentMode"in document&&(Es=document.documentMode);var Og=g&&"TextEvent"in window&&!Es,Su=g&&(!bo||Es&&8<Es&&11>=Es),bu=" ",ku=!1;function Nu(t,r){switch(t){case"keyup":return Mg.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cu(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Dr=!1;function Bg(t,r){switch(t){case"compositionend":return Cu(r);case"keypress":return r.which!==32?null:(ku=!0,bu);case"textInput":return t=r.data,t===bu&&ku?null:t;default:return null}}function Dg(t,r){if(Dr)return t==="compositionend"||!bo&&Nu(t,r)?(t=yu(),Aa=yo=Yn=null,Dr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Su&&r.locale!=="ko"?null:r.data;default:return null}}var Ug={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 Eu(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!Ug[t.type]:r==="textarea"}function Tu(t,r,i,c){St(c),r=Fa(r,"onChange"),0<r.length&&(i=new vo("onChange","change",null,i,c),t.push({event:i,listeners:r}))}var Ts=null,As=null;function Wg(t){Gu(t,0)}function $a(t){var r=Gr(t);if(be(r))return t}function Hg(t,r){if(t==="change")return r}var Au=!1;if(g){var ko;if(g){var No="oninput"in document;if(!No){var Iu=document.createElement("div");Iu.setAttribute("oninput","return;"),No=typeof Iu.oninput=="function"}ko=No}else ko=!1;Au=ko&&(!document.documentMode||9<document.documentMode)}function Ru(){Ts&&(Ts.detachEvent("onpropertychange",Pu),As=Ts=null)}function Pu(t){if(t.propertyName==="value"&&$a(As)){var r=[];Tu(r,As,t,Ae(t)),Be(Wg,r)}}function Vg(t,r,i){t==="focusin"?(Ru(),Ts=r,As=i,Ts.attachEvent("onpropertychange",Pu)):t==="focusout"&&Ru()}function Gg(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return $a(As)}function Kg(t,r){if(t==="click")return $a(r)}function qg(t,r){if(t==="input"||t==="change")return $a(r)}function Yg(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var mn=typeof Object.is=="function"?Object.is:Yg;function Is(t,r){if(mn(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var i=Object.keys(t),c=Object.keys(r);if(i.length!==c.length)return!1;for(c=0;c<i.length;c++){var d=i[c];if(!p.call(r,d)||!mn(t[d],r[d]))return!1}return!0}function $u(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function _u(t,r){var i=$u(t);t=0;for(var c;i;){if(i.nodeType===3){if(c=t+i.textContent.length,t<=r&&c>=r)return{node:i,offset:r-t};t=c}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=$u(i)}}function Lu(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?Lu(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function zu(){for(var t=window,r=oe();r instanceof t.HTMLIFrameElement;){try{var i=typeof r.contentWindow.location.href=="string"}catch{i=!1}if(i)t=r.contentWindow;else break;r=oe(t.document)}return r}function Co(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}function Jg(t){var r=zu(),i=t.focusedElem,c=t.selectionRange;if(r!==i&&i&&i.ownerDocument&&Lu(i.ownerDocument.documentElement,i)){if(c!==null&&Co(i)){if(r=c.start,t=c.end,t===void 0&&(t=r),"selectionStart"in i)i.selectionStart=r,i.selectionEnd=Math.min(t,i.value.length);else if(t=(r=i.ownerDocument||document)&&r.defaultView||window,t.getSelection){t=t.getSelection();var d=i.textContent.length,m=Math.min(c.start,d);c=c.end===void 0?m:Math.min(c.end,d),!t.extend&&m>c&&(d=c,c=m,m=d),d=_u(i,m);var j=_u(i,c);d&&j&&(t.rangeCount!==1||t.anchorNode!==d.node||t.anchorOffset!==d.offset||t.focusNode!==j.node||t.focusOffset!==j.offset)&&(r=r.createRange(),r.setStart(d.node,d.offset),t.removeAllRanges(),m>c?(t.addRange(r),t.extend(j.node,j.offset)):(r.setEnd(j.node,j.offset),t.addRange(r)))}}for(r=[],t=i;t=t.parentNode;)t.nodeType===1&&r.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<r.length;i++)t=r[i],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var Qg=g&&"documentMode"in document&&11>=document.documentMode,Ur=null,Eo=null,Rs=null,To=!1;function Fu(t,r,i){var c=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;To||Ur==null||Ur!==oe(c)||(c=Ur,"selectionStart"in c&&Co(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}),Rs&&Is(Rs,c)||(Rs=c,c=Fa(Eo,"onSelect"),0<c.length&&(r=new vo("onSelect","select",null,r,i),t.push({event:r,listeners:c}),r.target=Ur)))}function _a(t,r){var i={};return i[t.toLowerCase()]=r.toLowerCase(),i["Webkit"+t]="webkit"+r,i["Moz"+t]="moz"+r,i}var Wr={animationend:_a("Animation","AnimationEnd"),animationiteration:_a("Animation","AnimationIteration"),animationstart:_a("Animation","AnimationStart"),transitionend:_a("Transition","TransitionEnd")},Ao={},Mu={};g&&(Mu=document.createElement("div").style,"AnimationEvent"in window||(delete Wr.animationend.animation,delete Wr.animationiteration.animation,delete Wr.animationstart.animation),"TransitionEvent"in window||delete Wr.transitionend.transition);function La(t){if(Ao[t])return Ao[t];if(!Wr[t])return t;var r=Wr[t],i;for(i in r)if(r.hasOwnProperty(i)&&i in Mu)return Ao[t]=r[i];return t}var Ou=La("animationend"),Bu=La("animationiteration"),Du=La("animationstart"),Uu=La("transitionend"),Wu=new Map,Hu="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 Jn(t,r){Wu.set(t,r),u(r,[t])}for(var Io=0;Io<Hu.length;Io++){var Ro=Hu[Io],Xg=Ro.toLowerCase(),Zg=Ro[0].toUpperCase()+Ro.slice(1);Jn(Xg,"on"+Zg)}Jn(Ou,"onAnimationEnd"),Jn(Bu,"onAnimationIteration"),Jn(Du,"onAnimationStart"),Jn("dblclick","onDoubleClick"),Jn("focusin","onFocus"),Jn("focusout","onBlur"),Jn(Uu,"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 Ps="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(" "),ey=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ps));function Vu(t,r,i){var c=t.type||"unknown-event";t.currentTarget=i,va(c,r,void 0,t),t.currentTarget=null}function Gu(t,r){r=(r&4)!==0;for(var i=0;i<t.length;i++){var c=t[i],d=c.event;c=c.listeners;e:{var m=void 0;if(r)for(var j=c.length-1;0<=j;j--){var C=c[j],R=C.instance,V=C.currentTarget;if(C=C.listener,R!==m&&d.isPropagationStopped())break e;Vu(d,C,V),m=R}else for(j=0;j<c.length;j++){if(C=c[j],R=C.instance,V=C.currentTarget,C=C.listener,R!==m&&d.isPropagationStopped())break e;Vu(d,C,V),m=R}}}if(Hn)throw t=hr,Hn=!1,hr=null,t}function ot(t,r){var i=r[Oo];i===void 0&&(i=r[Oo]=new Set);var c=t+"__bubble";i.has(c)||(Ku(r,t,2,!1),i.add(c))}function Po(t,r,i){var c=0;r&&(c|=4),Ku(i,t,c,r)}var za="_reactListening"+Math.random().toString(36).slice(2);function $s(t){if(!t[za]){t[za]=!0,o.forEach(function(i){i!=="selectionchange"&&(ey.has(i)||Po(i,!1,t),Po(i,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[za]||(r[za]=!0,Po("selectionchange",!1,r))}}function Ku(t,r,i,c){switch(gu(r)){case 1:var d=mg;break;case 4:d=pg;break;default:d=po}i=d.bind(null,r,i,t),d=void 0,!Ct||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(d=!0),c?d!==void 0?t.addEventListener(r,i,{capture:!0,passive:d}):t.addEventListener(r,i,!0):d!==void 0?t.addEventListener(r,i,{passive:d}):t.addEventListener(r,i,!1)}function $o(t,r,i,c,d){var m=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var j=c.tag;if(j===3||j===4){var C=c.stateNode.containerInfo;if(C===d||C.nodeType===8&&C.parentNode===d)break;if(j===4)for(j=c.return;j!==null;){var R=j.tag;if((R===3||R===4)&&(R=j.stateNode.containerInfo,R===d||R.nodeType===8&&R.parentNode===d))return;j=j.return}for(;C!==null;){if(j=mr(C),j===null)return;if(R=j.tag,R===5||R===6){c=m=j;continue e}C=C.parentNode}}c=c.return}Be(function(){var V=m,ae=Ae(i),ce=[];e:{var re=Wu.get(t);if(re!==void 0){var je=vo,ke=t;switch(t){case"keypress":if(Ia(i)===0)break e;case"keydown":case"keyup":je=Ig;break;case"focusin":ke="focus",je=jo;break;case"focusout":ke="blur",je=jo;break;case"beforeblur":case"afterblur":je=jo;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=xu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=vg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=$g;break;case Ou:case Bu:case Du:je=jg;break;case Uu:je=Lg;break;case"scroll":je=gg;break;case"wheel":je=Fg;break;case"copy":case"cut":case"paste":je=bg;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=ju}var Ee=(r&4)!==0,xt=!Ee&&t==="scroll",F=Ee?re!==null?re+"Capture":null:re;Ee=[];for(var $=V,D;$!==null;){D=$;var he=D.stateNode;if(D.tag===5&&he!==null&&(D=he,F!==null&&(he=Xe($,F),he!=null&&Ee.push(_s($,he,D)))),xt)break;$=$.return}0<Ee.length&&(re=new je(re,ke,null,i,ae),ce.push({event:re,listeners:Ee}))}}if((r&7)===0){e:{if(re=t==="mouseover"||t==="pointerover",je=t==="mouseout"||t==="pointerout",re&&i!==xe&&(ke=i.relatedTarget||i.fromElement)&&(mr(ke)||ke[Rn]))break e;if((je||re)&&(re=ae.window===ae?ae:(re=ae.ownerDocument)?re.defaultView||re.parentWindow:window,je?(ke=i.relatedTarget||i.toElement,je=V,ke=ke?mr(ke):null,ke!==null&&(xt=bn(ke),ke!==xt||ke.tag!==5&&ke.tag!==6)&&(ke=null)):(je=null,ke=V),je!==ke)){if(Ee=xu,he="onMouseLeave",F="onMouseEnter",$="mouse",(t==="pointerout"||t==="pointerover")&&(Ee=ju,he="onPointerLeave",F="onPointerEnter",$="pointer"),xt=je==null?re:Gr(je),D=ke==null?re:Gr(ke),re=new Ee(he,$+"leave",je,i,ae),re.target=xt,re.relatedTarget=D,he=null,mr(ae)===V&&(Ee=new Ee(F,$+"enter",ke,i,ae),Ee.target=D,Ee.relatedTarget=xt,he=Ee),xt=he,je&&ke)t:{for(Ee=je,F=ke,$=0,D=Ee;D;D=Hr(D))$++;for(D=0,he=F;he;he=Hr(he))D++;for(;0<$-D;)Ee=Hr(Ee),$--;for(;0<D-$;)F=Hr(F),D--;for(;$--;){if(Ee===F||F!==null&&Ee===F.alternate)break t;Ee=Hr(Ee),F=Hr(F)}Ee=null}else Ee=null;je!==null&&qu(ce,re,je,Ee,!1),ke!==null&&xt!==null&&qu(ce,xt,ke,Ee,!0)}}e:{if(re=V?Gr(V):window,je=re.nodeName&&re.nodeName.toLowerCase(),je==="select"||je==="input"&&re.type==="file")var Te=Hg;else if(Eu(re))if(Au)Te=qg;else{Te=Gg;var Pe=Vg}else(je=re.nodeName)&&je.toLowerCase()==="input"&&(re.type==="checkbox"||re.type==="radio")&&(Te=Kg);if(Te&&(Te=Te(t,V))){Tu(ce,Te,i,ae);break e}Pe&&Pe(t,re,V),t==="focusout"&&(Pe=re._wrapperState)&&Pe.controlled&&re.type==="number"&&Ze(re,"number",re.value)}switch(Pe=V?Gr(V):window,t){case"focusin":(Eu(Pe)||Pe.contentEditable==="true")&&(Ur=Pe,Eo=V,Rs=null);break;case"focusout":Rs=Eo=Ur=null;break;case"mousedown":To=!0;break;case"contextmenu":case"mouseup":case"dragend":To=!1,Fu(ce,i,ae);break;case"selectionchange":if(Qg)break;case"keydown":case"keyup":Fu(ce,i,ae)}var $e;if(bo)e:{switch(t){case"compositionstart":var _e="onCompositionStart";break e;case"compositionend":_e="onCompositionEnd";break e;case"compositionupdate":_e="onCompositionUpdate";break e}_e=void 0}else Dr?Nu(t,i)&&(_e="onCompositionEnd"):t==="keydown"&&i.keyCode===229&&(_e="onCompositionStart");_e&&(Su&&i.locale!=="ko"&&(Dr||_e!=="onCompositionStart"?_e==="onCompositionEnd"&&Dr&&($e=yu()):(Yn=ae,yo="value"in Yn?Yn.value:Yn.textContent,Dr=!0)),Pe=Fa(V,_e),0<Pe.length&&(_e=new wu(_e,t,null,i,ae),ce.push({event:_e,listeners:Pe}),$e?_e.data=$e:($e=Cu(i),$e!==null&&(_e.data=$e)))),($e=Og?Bg(t,i):Dg(t,i))&&(V=Fa(V,"onBeforeInput"),0<V.length&&(ae=new wu("onBeforeInput","beforeinput",null,i,ae),ce.push({event:ae,listeners:V}),ae.data=$e))}Gu(ce,r)})}function _s(t,r,i){return{instance:t,listener:r,currentTarget:i}}function Fa(t,r){for(var i=r+"Capture",c=[];t!==null;){var d=t,m=d.stateNode;d.tag===5&&m!==null&&(d=m,m=Xe(t,i),m!=null&&c.unshift(_s(t,m,d)),m=Xe(t,r),m!=null&&c.push(_s(t,m,d))),t=t.return}return c}function Hr(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function qu(t,r,i,c,d){for(var m=r._reactName,j=[];i!==null&&i!==c;){var C=i,R=C.alternate,V=C.stateNode;if(R!==null&&R===c)break;C.tag===5&&V!==null&&(C=V,d?(R=Xe(i,m),R!=null&&j.unshift(_s(i,R,C))):d||(R=Xe(i,m),R!=null&&j.push(_s(i,R,C)))),i=i.return}j.length!==0&&t.push({event:r,listeners:j})}var ty=/\r\n?/g,ny=/\u0000|\uFFFD/g;function Yu(t){return(typeof t=="string"?t:""+t).replace(ty,`
38
+ `).replace(ny,"")}function Ma(t,r,i){if(r=Yu(r),Yu(t)!==r&&i)throw Error(a(425))}function Oa(){}var _o=null,Lo=null;function zo(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Fo=typeof setTimeout=="function"?setTimeout:void 0,ry=typeof clearTimeout=="function"?clearTimeout:void 0,Ju=typeof Promise=="function"?Promise:void 0,sy=typeof queueMicrotask=="function"?queueMicrotask:typeof Ju<"u"?function(t){return Ju.resolve(null).then(t).catch(ay)}:Fo;function ay(t){setTimeout(function(){throw t})}function Mo(t,r){var i=r,c=0;do{var d=i.nextSibling;if(t.removeChild(i),d&&d.nodeType===8)if(i=d.data,i==="/$"){if(c===0){t.removeChild(d),ks(r);return}c--}else i!=="$"&&i!=="$?"&&i!=="$!"||c++;i=d}while(i);ks(r)}function Qn(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return t}function Qu(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var i=t.data;if(i==="$"||i==="$!"||i==="$?"){if(r===0)return t;r--}else i==="/$"&&r++}t=t.previousSibling}return null}var Vr=Math.random().toString(36).slice(2),Cn="__reactFiber$"+Vr,Ls="__reactProps$"+Vr,Rn="__reactContainer$"+Vr,Oo="__reactEvents$"+Vr,iy="__reactListeners$"+Vr,oy="__reactHandles$"+Vr;function mr(t){var r=t[Cn];if(r)return r;for(var i=t.parentNode;i;){if(r=i[Rn]||i[Cn]){if(i=r.alternate,r.child!==null||i!==null&&i.child!==null)for(t=Qu(t);t!==null;){if(i=t[Cn])return i;t=Qu(t)}return r}t=i,i=t.parentNode}return null}function zs(t){return t=t[Cn]||t[Rn],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Gr(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(a(33))}function Ba(t){return t[Ls]||null}var Bo=[],Kr=-1;function Xn(t){return{current:t}}function lt(t){0>Kr||(t.current=Bo[Kr],Bo[Kr]=null,Kr--)}function at(t,r){Kr++,Bo[Kr]=t.current,t.current=r}var Zn={},$t=Xn(Zn),Vt=Xn(!1),pr=Zn;function qr(t,r){var i=t.type.contextTypes;if(!i)return Zn;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var d={},m;for(m in i)d[m]=r[m];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=r,t.__reactInternalMemoizedMaskedChildContext=d),d}function Gt(t){return t=t.childContextTypes,t!=null}function Da(){lt(Vt),lt($t)}function Xu(t,r,i){if($t.current!==Zn)throw Error(a(168));at($t,r),at(Vt,i)}function Zu(t,r,i){var c=t.stateNode;if(r=r.childContextTypes,typeof c.getChildContext!="function")return i;c=c.getChildContext();for(var d in c)if(!(d in r))throw Error(a(108,ue(t)||"Unknown",d));return Y({},i,c)}function Ua(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Zn,pr=$t.current,at($t,t),at(Vt,Vt.current),!0}function ed(t,r,i){var c=t.stateNode;if(!c)throw Error(a(169));i?(t=Zu(t,r,pr),c.__reactInternalMemoizedMergedChildContext=t,lt(Vt),lt($t),at($t,t)):lt(Vt),at(Vt,i)}var Pn=null,Wa=!1,Do=!1;function td(t){Pn===null?Pn=[t]:Pn.push(t)}function ly(t){Wa=!0,td(t)}function er(){if(!Do&&Pn!==null){Do=!0;var t=0,r=tt;try{var i=Pn;for(tt=1;t<i.length;t++){var c=i[t];do c=c(!0);while(c!==null)}Pn=null,Wa=!1}catch(d){throw Pn!==null&&(Pn=Pn.slice(t+1)),ru(lo,er),d}finally{tt=r,Do=!1}}return null}var Yr=[],Jr=0,Ha=null,Va=0,sn=[],an=0,gr=null,$n=1,_n="";function yr(t,r){Yr[Jr++]=Va,Yr[Jr++]=Ha,Ha=t,Va=r}function nd(t,r,i){sn[an++]=$n,sn[an++]=_n,sn[an++]=gr,gr=t;var c=$n;t=_n;var d=32-hn(c)-1;c&=~(1<<d),i+=1;var m=32-hn(r)+d;if(30<m){var j=d-d%5;m=(c&(1<<j)-1).toString(32),c>>=j,d-=j,$n=1<<32-hn(r)+d|i<<d|c,_n=m+t}else $n=1<<m|i<<d|c,_n=t}function Uo(t){t.return!==null&&(yr(t,1),nd(t,1,0))}function Wo(t){for(;t===Ha;)Ha=Yr[--Jr],Yr[Jr]=null,Va=Yr[--Jr],Yr[Jr]=null;for(;t===gr;)gr=sn[--an],sn[an]=null,_n=sn[--an],sn[an]=null,$n=sn[--an],sn[an]=null}var en=null,tn=null,ct=!1,pn=null;function rd(t,r){var i=un(5,null,null,0);i.elementType="DELETED",i.stateNode=r,i.return=t,r=t.deletions,r===null?(t.deletions=[i],t.flags|=16):r.push(i)}function sd(t,r){switch(t.tag){case 5:var i=t.type;return r=r.nodeType!==1||i.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(t.stateNode=r,en=t,tn=Qn(r.firstChild),!0):!1;case 6:return r=t.pendingProps===""||r.nodeType!==3?null:r,r!==null?(t.stateNode=r,en=t,tn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(i=gr!==null?{id:$n,overflow:_n}:null,t.memoizedState={dehydrated:r,treeContext:i,retryLane:1073741824},i=un(18,null,null,0),i.stateNode=r,i.return=t,t.child=i,en=t,tn=null,!0):!1;default:return!1}}function Ho(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Vo(t){if(ct){var r=tn;if(r){var i=r;if(!sd(t,r)){if(Ho(t))throw Error(a(418));r=Qn(i.nextSibling);var c=en;r&&sd(t,r)?rd(c,i):(t.flags=t.flags&-4097|2,ct=!1,en=t)}}else{if(Ho(t))throw Error(a(418));t.flags=t.flags&-4097|2,ct=!1,en=t}}}function ad(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;en=t}function Ga(t){if(t!==en)return!1;if(!ct)return ad(t),ct=!0,!1;var r;if((r=t.tag!==3)&&!(r=t.tag!==5)&&(r=t.type,r=r!=="head"&&r!=="body"&&!zo(t.type,t.memoizedProps)),r&&(r=tn)){if(Ho(t))throw id(),Error(a(418));for(;r;)rd(t,r),r=Qn(r.nextSibling)}if(ad(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(a(317));e:{for(t=t.nextSibling,r=0;t;){if(t.nodeType===8){var i=t.data;if(i==="/$"){if(r===0){tn=Qn(t.nextSibling);break e}r--}else i!=="$"&&i!=="$!"&&i!=="$?"||r++}t=t.nextSibling}tn=null}}else tn=en?Qn(t.stateNode.nextSibling):null;return!0}function id(){for(var t=tn;t;)t=Qn(t.nextSibling)}function Qr(){tn=en=null,ct=!1}function Go(t){pn===null?pn=[t]:pn.push(t)}var cy=I.ReactCurrentBatchConfig;function Fs(t,r,i){if(t=i.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(a(309));var c=i.stateNode}if(!c)throw Error(a(147,t));var d=c,m=""+t;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===m?r.ref:(r=function(j){var C=d.refs;j===null?delete C[m]:C[m]=j},r._stringRef=m,r)}if(typeof t!="string")throw Error(a(284));if(!i._owner)throw Error(a(290,t))}return t}function Ka(t,r){throw t=Object.prototype.toString.call(r),Error(a(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t))}function od(t){var r=t._init;return r(t._payload)}function ld(t){function r(F,$){if(t){var D=F.deletions;D===null?(F.deletions=[$],F.flags|=16):D.push($)}}function i(F,$){if(!t)return null;for(;$!==null;)r(F,$),$=$.sibling;return null}function c(F,$){for(F=new Map;$!==null;)$.key!==null?F.set($.key,$):F.set($.index,$),$=$.sibling;return F}function d(F,$){return F=lr(F,$),F.index=0,F.sibling=null,F}function m(F,$,D){return F.index=D,t?(D=F.alternate,D!==null?(D=D.index,D<$?(F.flags|=2,$):D):(F.flags|=2,$)):(F.flags|=1048576,$)}function j(F){return t&&F.alternate===null&&(F.flags|=2),F}function C(F,$,D,he){return $===null||$.tag!==6?($=Fl(D,F.mode,he),$.return=F,$):($=d($,D),$.return=F,$)}function R(F,$,D,he){var Te=D.type;return Te===q?ae(F,$,D.props.children,he,D.key):$!==null&&($.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===pe&&od(Te)===$.type)?(he=d($,D.props),he.ref=Fs(F,$,D),he.return=F,he):(he=yi(D.type,D.key,D.props,null,F.mode,he),he.ref=Fs(F,$,D),he.return=F,he)}function V(F,$,D,he){return $===null||$.tag!==4||$.stateNode.containerInfo!==D.containerInfo||$.stateNode.implementation!==D.implementation?($=Ml(D,F.mode,he),$.return=F,$):($=d($,D.children||[]),$.return=F,$)}function ae(F,$,D,he,Te){return $===null||$.tag!==7?($=Nr(D,F.mode,he,Te),$.return=F,$):($=d($,D),$.return=F,$)}function ce(F,$,D){if(typeof $=="string"&&$!==""||typeof $=="number")return $=Fl(""+$,F.mode,D),$.return=F,$;if(typeof $=="object"&&$!==null){switch($.$$typeof){case B:return D=yi($.type,$.key,$.props,null,F.mode,D),D.ref=Fs(F,null,$),D.return=F,D;case M:return $=Ml($,F.mode,D),$.return=F,$;case pe:var he=$._init;return ce(F,he($._payload),D)}if(Ye($)||Q($))return $=Nr($,F.mode,D,null),$.return=F,$;Ka(F,$)}return null}function re(F,$,D,he){var Te=$!==null?$.key:null;if(typeof D=="string"&&D!==""||typeof D=="number")return Te!==null?null:C(F,$,""+D,he);if(typeof D=="object"&&D!==null){switch(D.$$typeof){case B:return D.key===Te?R(F,$,D,he):null;case M:return D.key===Te?V(F,$,D,he):null;case pe:return Te=D._init,re(F,$,Te(D._payload),he)}if(Ye(D)||Q(D))return Te!==null?null:ae(F,$,D,he,null);Ka(F,D)}return null}function je(F,$,D,he,Te){if(typeof he=="string"&&he!==""||typeof he=="number")return F=F.get(D)||null,C($,F,""+he,Te);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case B:return F=F.get(he.key===null?D:he.key)||null,R($,F,he,Te);case M:return F=F.get(he.key===null?D:he.key)||null,V($,F,he,Te);case pe:var Pe=he._init;return je(F,$,D,Pe(he._payload),Te)}if(Ye(he)||Q(he))return F=F.get(D)||null,ae($,F,he,Te,null);Ka($,he)}return null}function ke(F,$,D,he){for(var Te=null,Pe=null,$e=$,_e=$=0,At=null;$e!==null&&_e<D.length;_e++){$e.index>_e?(At=$e,$e=null):At=$e.sibling;var Qe=re(F,$e,D[_e],he);if(Qe===null){$e===null&&($e=At);break}t&&$e&&Qe.alternate===null&&r(F,$e),$=m(Qe,$,_e),Pe===null?Te=Qe:Pe.sibling=Qe,Pe=Qe,$e=At}if(_e===D.length)return i(F,$e),ct&&yr(F,_e),Te;if($e===null){for(;_e<D.length;_e++)$e=ce(F,D[_e],he),$e!==null&&($=m($e,$,_e),Pe===null?Te=$e:Pe.sibling=$e,Pe=$e);return ct&&yr(F,_e),Te}for($e=c(F,$e);_e<D.length;_e++)At=je($e,F,_e,D[_e],he),At!==null&&(t&&At.alternate!==null&&$e.delete(At.key===null?_e:At.key),$=m(At,$,_e),Pe===null?Te=At:Pe.sibling=At,Pe=At);return t&&$e.forEach(function(cr){return r(F,cr)}),ct&&yr(F,_e),Te}function Ee(F,$,D,he){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 Pe=Te=null,$e=$,_e=$=0,At=null,Qe=D.next();$e!==null&&!Qe.done;_e++,Qe=D.next()){$e.index>_e?(At=$e,$e=null):At=$e.sibling;var cr=re(F,$e,Qe.value,he);if(cr===null){$e===null&&($e=At);break}t&&$e&&cr.alternate===null&&r(F,$e),$=m(cr,$,_e),Pe===null?Te=cr:Pe.sibling=cr,Pe=cr,$e=At}if(Qe.done)return i(F,$e),ct&&yr(F,_e),Te;if($e===null){for(;!Qe.done;_e++,Qe=D.next())Qe=ce(F,Qe.value,he),Qe!==null&&($=m(Qe,$,_e),Pe===null?Te=Qe:Pe.sibling=Qe,Pe=Qe);return ct&&yr(F,_e),Te}for($e=c(F,$e);!Qe.done;_e++,Qe=D.next())Qe=je($e,F,_e,Qe.value,he),Qe!==null&&(t&&Qe.alternate!==null&&$e.delete(Qe.key===null?_e:Qe.key),$=m(Qe,$,_e),Pe===null?Te=Qe:Pe.sibling=Qe,Pe=Qe);return t&&$e.forEach(function(Uy){return r(F,Uy)}),ct&&yr(F,_e),Te}function xt(F,$,D,he){if(typeof D=="object"&&D!==null&&D.type===q&&D.key===null&&(D=D.props.children),typeof D=="object"&&D!==null){switch(D.$$typeof){case B:e:{for(var Te=D.key,Pe=$;Pe!==null;){if(Pe.key===Te){if(Te=D.type,Te===q){if(Pe.tag===7){i(F,Pe.sibling),$=d(Pe,D.props.children),$.return=F,F=$;break e}}else if(Pe.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===pe&&od(Te)===Pe.type){i(F,Pe.sibling),$=d(Pe,D.props),$.ref=Fs(F,Pe,D),$.return=F,F=$;break e}i(F,Pe);break}else r(F,Pe);Pe=Pe.sibling}D.type===q?($=Nr(D.props.children,F.mode,he,D.key),$.return=F,F=$):(he=yi(D.type,D.key,D.props,null,F.mode,he),he.ref=Fs(F,$,D),he.return=F,F=he)}return j(F);case M:e:{for(Pe=D.key;$!==null;){if($.key===Pe)if($.tag===4&&$.stateNode.containerInfo===D.containerInfo&&$.stateNode.implementation===D.implementation){i(F,$.sibling),$=d($,D.children||[]),$.return=F,F=$;break e}else{i(F,$);break}else r(F,$);$=$.sibling}$=Ml(D,F.mode,he),$.return=F,F=$}return j(F);case pe:return Pe=D._init,xt(F,$,Pe(D._payload),he)}if(Ye(D))return ke(F,$,D,he);if(Q(D))return Ee(F,$,D,he);Ka(F,D)}return typeof D=="string"&&D!==""||typeof D=="number"?(D=""+D,$!==null&&$.tag===6?(i(F,$.sibling),$=d($,D),$.return=F,F=$):(i(F,$),$=Fl(D,F.mode,he),$.return=F,F=$),j(F)):i(F,$)}return xt}var Xr=ld(!0),cd=ld(!1),qa=Xn(null),Ya=null,Zr=null,Ko=null;function qo(){Ko=Zr=Ya=null}function Yo(t){var r=qa.current;lt(qa),t._currentValue=r}function Jo(t,r,i){for(;t!==null;){var c=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),t===i)break;t=t.return}}function es(t,r){Ya=t,Ko=Zr=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&r)!==0&&(Kt=!0),t.firstContext=null)}function on(t){var r=t._currentValue;if(Ko!==t)if(t={context:t,memoizedValue:r,next:null},Zr===null){if(Ya===null)throw Error(a(308));Zr=t,Ya.dependencies={lanes:0,firstContext:t}}else Zr=Zr.next=t;return r}var vr=null;function Qo(t){vr===null?vr=[t]:vr.push(t)}function ud(t,r,i,c){var d=r.interleaved;return d===null?(i.next=i,Qo(r)):(i.next=d.next,d.next=i),r.interleaved=i,Ln(t,c)}function Ln(t,r){t.lanes|=r;var i=t.alternate;for(i!==null&&(i.lanes|=r),i=t,t=t.return;t!==null;)t.childLanes|=r,i=t.alternate,i!==null&&(i.childLanes|=r),i=t,t=t.return;return i.tag===3?i.stateNode:null}var tr=!1;function Xo(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dd(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function zn(t,r){return{eventTime:t,lane:r,tag:0,payload:null,callback:null,next:null}}function nr(t,r,i){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(Je&2)!==0){var d=c.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),c.pending=r,Ln(t,i)}return d=c.interleaved,d===null?(r.next=r,Qo(c)):(r.next=d.next,d.next=r),c.interleaved=r,Ln(t,i)}function Ja(t,r,i){if(r=r.updateQueue,r!==null&&(r=r.shared,(i&4194240)!==0)){var c=r.lanes;c&=t.pendingLanes,i|=c,r.lanes=i,fo(t,i)}}function fd(t,r){var i=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,i===c)){var d=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var j={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};m===null?d=m=j:m=m.next=j,i=i.next}while(i!==null);m===null?d=m=r:m=m.next=r}else d=m=r;i={baseState:c.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:c.shared,effects:c.effects},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=r:t.next=r,i.lastBaseUpdate=r}function Qa(t,r,i,c){var d=t.updateQueue;tr=!1;var m=d.firstBaseUpdate,j=d.lastBaseUpdate,C=d.shared.pending;if(C!==null){d.shared.pending=null;var R=C,V=R.next;R.next=null,j===null?m=V:j.next=V,j=R;var ae=t.alternate;ae!==null&&(ae=ae.updateQueue,C=ae.lastBaseUpdate,C!==j&&(C===null?ae.firstBaseUpdate=V:C.next=V,ae.lastBaseUpdate=R))}if(m!==null){var ce=d.baseState;j=0,ae=V=R=null,C=m;do{var re=C.lane,je=C.eventTime;if((c&re)===re){ae!==null&&(ae=ae.next={eventTime:je,lane:0,tag:C.tag,payload:C.payload,callback:C.callback,next:null});e:{var ke=t,Ee=C;switch(re=r,je=i,Ee.tag){case 1:if(ke=Ee.payload,typeof ke=="function"){ce=ke.call(je,ce,re);break e}ce=ke;break e;case 3:ke.flags=ke.flags&-65537|128;case 0:if(ke=Ee.payload,re=typeof ke=="function"?ke.call(je,ce,re):ke,re==null)break e;ce=Y({},ce,re);break e;case 2:tr=!0}}C.callback!==null&&C.lane!==0&&(t.flags|=64,re=d.effects,re===null?d.effects=[C]:re.push(C))}else je={eventTime:je,lane:re,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ae===null?(V=ae=je,R=ce):ae=ae.next=je,j|=re;if(C=C.next,C===null){if(C=d.shared.pending,C===null)break;re=C,C=re.next,re.next=null,d.lastBaseUpdate=re,d.shared.pending=null}}while(!0);if(ae===null&&(R=ce),d.baseState=R,d.firstBaseUpdate=V,d.lastBaseUpdate=ae,r=d.shared.interleaved,r!==null){d=r;do j|=d.lane,d=d.next;while(d!==r)}else m===null&&(d.shared.lanes=0);jr|=j,t.lanes=j,t.memoizedState=ce}}function hd(t,r,i){if(t=r.effects,r.effects=null,t!==null)for(r=0;r<t.length;r++){var c=t[r],d=c.callback;if(d!==null){if(c.callback=null,c=i,typeof d!="function")throw Error(a(191,d));d.call(c)}}}var Ms={},En=Xn(Ms),Os=Xn(Ms),Bs=Xn(Ms);function xr(t){if(t===Ms)throw Error(a(174));return t}function Zo(t,r){switch(at(Bs,r),at(Os,t),at(En,Ms),t=r.nodeType,t){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Oe(null,"");break;default:t=t===8?r.parentNode:r,r=t.namespaceURI||null,t=t.tagName,r=Oe(r,t)}lt(En),at(En,r)}function ts(){lt(En),lt(Os),lt(Bs)}function md(t){xr(Bs.current);var r=xr(En.current),i=Oe(r,t.type);r!==i&&(at(Os,t),at(En,i))}function el(t){Os.current===t&&(lt(En),lt(Os))}var ht=Xn(0);function Xa(t){for(var r=t;r!==null;){if(r.tag===13){var i=r.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var tl=[];function nl(){for(var t=0;t<tl.length;t++)tl[t]._workInProgressVersionPrimary=null;tl.length=0}var Za=I.ReactCurrentDispatcher,rl=I.ReactCurrentBatchConfig,wr=0,mt=null,bt=null,Et=null,ei=!1,Ds=!1,Us=0,uy=0;function _t(){throw Error(a(321))}function sl(t,r){if(r===null)return!1;for(var i=0;i<r.length&&i<t.length;i++)if(!mn(t[i],r[i]))return!1;return!0}function al(t,r,i,c,d,m){if(wr=m,mt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Za.current=t===null||t.memoizedState===null?my:py,t=i(c,d),Ds){m=0;do{if(Ds=!1,Us=0,25<=m)throw Error(a(301));m+=1,Et=bt=null,r.updateQueue=null,Za.current=gy,t=i(c,d)}while(Ds)}if(Za.current=ri,r=bt!==null&&bt.next!==null,wr=0,Et=bt=mt=null,ei=!1,r)throw Error(a(300));return t}function il(){var t=Us!==0;return Us=0,t}function Tn(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Et===null?mt.memoizedState=Et=t:Et=Et.next=t,Et}function ln(){if(bt===null){var t=mt.alternate;t=t!==null?t.memoizedState:null}else t=bt.next;var r=Et===null?mt.memoizedState:Et.next;if(r!==null)Et=r,bt=t;else{if(t===null)throw Error(a(310));bt=t,t={memoizedState:bt.memoizedState,baseState:bt.baseState,baseQueue:bt.baseQueue,queue:bt.queue,next:null},Et===null?mt.memoizedState=Et=t:Et=Et.next=t}return Et}function Ws(t,r){return typeof r=="function"?r(t):r}function ol(t){var r=ln(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=t;var c=bt,d=c.baseQueue,m=i.pending;if(m!==null){if(d!==null){var j=d.next;d.next=m.next,m.next=j}c.baseQueue=d=m,i.pending=null}if(d!==null){m=d.next,c=c.baseState;var C=j=null,R=null,V=m;do{var ae=V.lane;if((wr&ae)===ae)R!==null&&(R=R.next={lane:0,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),c=V.hasEagerState?V.eagerState:t(c,V.action);else{var ce={lane:ae,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null};R===null?(C=R=ce,j=c):R=R.next=ce,mt.lanes|=ae,jr|=ae}V=V.next}while(V!==null&&V!==m);R===null?j=c:R.next=C,mn(c,r.memoizedState)||(Kt=!0),r.memoizedState=c,r.baseState=j,r.baseQueue=R,i.lastRenderedState=c}if(t=i.interleaved,t!==null){d=t;do m=d.lane,mt.lanes|=m,jr|=m,d=d.next;while(d!==t)}else d===null&&(i.lanes=0);return[r.memoizedState,i.dispatch]}function ll(t){var r=ln(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=t;var c=i.dispatch,d=i.pending,m=r.memoizedState;if(d!==null){i.pending=null;var j=d=d.next;do m=t(m,j.action),j=j.next;while(j!==d);mn(m,r.memoizedState)||(Kt=!0),r.memoizedState=m,r.baseQueue===null&&(r.baseState=m),i.lastRenderedState=m}return[m,c]}function pd(){}function gd(t,r){var i=mt,c=ln(),d=r(),m=!mn(c.memoizedState,d);if(m&&(c.memoizedState=d,Kt=!0),c=c.queue,cl(xd.bind(null,i,c,t),[t]),c.getSnapshot!==r||m||Et!==null&&Et.memoizedState.tag&1){if(i.flags|=2048,Hs(9,vd.bind(null,i,c,d,r),void 0,null),Tt===null)throw Error(a(349));(wr&30)!==0||yd(i,r,d)}return d}function yd(t,r,i){t.flags|=16384,t={getSnapshot:r,value:i},r=mt.updateQueue,r===null?(r={lastEffect:null,stores:null},mt.updateQueue=r,r.stores=[t]):(i=r.stores,i===null?r.stores=[t]:i.push(t))}function vd(t,r,i,c){r.value=i,r.getSnapshot=c,wd(r)&&jd(t)}function xd(t,r,i){return i(function(){wd(r)&&jd(t)})}function wd(t){var r=t.getSnapshot;t=t.value;try{var i=r();return!mn(t,i)}catch{return!0}}function jd(t){var r=Ln(t,1);r!==null&&xn(r,t,1,-1)}function Sd(t){var r=Tn();return typeof t=="function"&&(t=t()),r.memoizedState=r.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ws,lastRenderedState:t},r.queue=t,t=t.dispatch=hy.bind(null,mt,t),[r.memoizedState,t]}function Hs(t,r,i,c){return t={tag:t,create:r,destroy:i,deps:c,next:null},r=mt.updateQueue,r===null?(r={lastEffect:null,stores:null},mt.updateQueue=r,r.lastEffect=t.next=t):(i=r.lastEffect,i===null?r.lastEffect=t.next=t:(c=i.next,i.next=t,t.next=c,r.lastEffect=t)),t}function bd(){return ln().memoizedState}function ti(t,r,i,c){var d=Tn();mt.flags|=t,d.memoizedState=Hs(1|r,i,void 0,c===void 0?null:c)}function ni(t,r,i,c){var d=ln();c=c===void 0?null:c;var m=void 0;if(bt!==null){var j=bt.memoizedState;if(m=j.destroy,c!==null&&sl(c,j.deps)){d.memoizedState=Hs(r,i,m,c);return}}mt.flags|=t,d.memoizedState=Hs(1|r,i,m,c)}function kd(t,r){return ti(8390656,8,t,r)}function cl(t,r){return ni(2048,8,t,r)}function Nd(t,r){return ni(4,2,t,r)}function Cd(t,r){return ni(4,4,t,r)}function Ed(t,r){if(typeof r=="function")return t=t(),r(t),function(){r(null)};if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function Td(t,r,i){return i=i!=null?i.concat([t]):null,ni(4,4,Ed.bind(null,r,t),i)}function ul(){}function Ad(t,r){var i=ln();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&sl(r,c[1])?c[0]:(i.memoizedState=[t,r],t)}function Id(t,r){var i=ln();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&sl(r,c[1])?c[0]:(t=t(),i.memoizedState=[t,r],t)}function Rd(t,r,i){return(wr&21)===0?(t.baseState&&(t.baseState=!1,Kt=!0),t.memoizedState=i):(mn(i,r)||(i=ou(),mt.lanes|=i,jr|=i,t.baseState=!0),r)}function dy(t,r){var i=tt;tt=i!==0&&4>i?i:4,t(!0);var c=rl.transition;rl.transition={};try{t(!1),r()}finally{tt=i,rl.transition=c}}function Pd(){return ln().memoizedState}function fy(t,r,i){var c=ir(t);if(i={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null},$d(t))_d(r,i);else if(i=ud(t,r,i,c),i!==null){var d=Dt();xn(i,t,c,d),Ld(i,r,c)}}function hy(t,r,i){var c=ir(t),d={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null};if($d(t))_d(r,d);else{var m=t.alternate;if(t.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var j=r.lastRenderedState,C=m(j,i);if(d.hasEagerState=!0,d.eagerState=C,mn(C,j)){var R=r.interleaved;R===null?(d.next=d,Qo(r)):(d.next=R.next,R.next=d),r.interleaved=d;return}}catch{}finally{}i=ud(t,r,d,c),i!==null&&(d=Dt(),xn(i,t,c,d),Ld(i,r,c))}}function $d(t){var r=t.alternate;return t===mt||r!==null&&r===mt}function _d(t,r){Ds=ei=!0;var i=t.pending;i===null?r.next=r:(r.next=i.next,i.next=r),t.pending=r}function Ld(t,r,i){if((i&4194240)!==0){var c=r.lanes;c&=t.pendingLanes,i|=c,r.lanes=i,fo(t,i)}}var ri={readContext:on,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},my={readContext:on,useCallback:function(t,r){return Tn().memoizedState=[t,r===void 0?null:r],t},useContext:on,useEffect:kd,useImperativeHandle:function(t,r,i){return i=i!=null?i.concat([t]):null,ti(4194308,4,Ed.bind(null,r,t),i)},useLayoutEffect:function(t,r){return ti(4194308,4,t,r)},useInsertionEffect:function(t,r){return ti(4,2,t,r)},useMemo:function(t,r){var i=Tn();return r=r===void 0?null:r,t=t(),i.memoizedState=[t,r],t},useReducer:function(t,r,i){var c=Tn();return r=i!==void 0?i(r):r,c.memoizedState=c.baseState=r,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:r},c.queue=t,t=t.dispatch=fy.bind(null,mt,t),[c.memoizedState,t]},useRef:function(t){var r=Tn();return t={current:t},r.memoizedState=t},useState:Sd,useDebugValue:ul,useDeferredValue:function(t){return Tn().memoizedState=t},useTransition:function(){var t=Sd(!1),r=t[0];return t=dy.bind(null,t[1]),Tn().memoizedState=t,[r,t]},useMutableSource:function(){},useSyncExternalStore:function(t,r,i){var c=mt,d=Tn();if(ct){if(i===void 0)throw Error(a(407));i=i()}else{if(i=r(),Tt===null)throw Error(a(349));(wr&30)!==0||yd(c,r,i)}d.memoizedState=i;var m={value:i,getSnapshot:r};return d.queue=m,kd(xd.bind(null,c,m,t),[t]),c.flags|=2048,Hs(9,vd.bind(null,c,m,i,r),void 0,null),i},useId:function(){var t=Tn(),r=Tt.identifierPrefix;if(ct){var i=_n,c=$n;i=(c&~(1<<32-hn(c)-1)).toString(32)+i,r=":"+r+"R"+i,i=Us++,0<i&&(r+="H"+i.toString(32)),r+=":"}else i=uy++,r=":"+r+"r"+i.toString(32)+":";return t.memoizedState=r},unstable_isNewReconciler:!1},py={readContext:on,useCallback:Ad,useContext:on,useEffect:cl,useImperativeHandle:Td,useInsertionEffect:Nd,useLayoutEffect:Cd,useMemo:Id,useReducer:ol,useRef:bd,useState:function(){return ol(Ws)},useDebugValue:ul,useDeferredValue:function(t){var r=ln();return Rd(r,bt.memoizedState,t)},useTransition:function(){var t=ol(Ws)[0],r=ln().memoizedState;return[t,r]},useMutableSource:pd,useSyncExternalStore:gd,useId:Pd,unstable_isNewReconciler:!1},gy={readContext:on,useCallback:Ad,useContext:on,useEffect:cl,useImperativeHandle:Td,useInsertionEffect:Nd,useLayoutEffect:Cd,useMemo:Id,useReducer:ll,useRef:bd,useState:function(){return ll(Ws)},useDebugValue:ul,useDeferredValue:function(t){var r=ln();return bt===null?r.memoizedState=t:Rd(r,bt.memoizedState,t)},useTransition:function(){var t=ll(Ws)[0],r=ln().memoizedState;return[t,r]},useMutableSource:pd,useSyncExternalStore:gd,useId:Pd,unstable_isNewReconciler:!1};function gn(t,r){if(t&&t.defaultProps){r=Y({},r),t=t.defaultProps;for(var i in t)r[i]===void 0&&(r[i]=t[i]);return r}return r}function dl(t,r,i,c){r=t.memoizedState,i=i(c,r),i=i==null?r:Y({},r,i),t.memoizedState=i,t.lanes===0&&(t.updateQueue.baseState=i)}var si={isMounted:function(t){return(t=t._reactInternals)?bn(t)===t:!1},enqueueSetState:function(t,r,i){t=t._reactInternals;var c=Dt(),d=ir(t),m=zn(c,d);m.payload=r,i!=null&&(m.callback=i),r=nr(t,m,d),r!==null&&(xn(r,t,d,c),Ja(r,t,d))},enqueueReplaceState:function(t,r,i){t=t._reactInternals;var c=Dt(),d=ir(t),m=zn(c,d);m.tag=1,m.payload=r,i!=null&&(m.callback=i),r=nr(t,m,d),r!==null&&(xn(r,t,d,c),Ja(r,t,d))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var i=Dt(),c=ir(t),d=zn(i,c);d.tag=2,r!=null&&(d.callback=r),r=nr(t,d,c),r!==null&&(xn(r,t,c,i),Ja(r,t,c))}};function zd(t,r,i,c,d,m,j){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,m,j):r.prototype&&r.prototype.isPureReactComponent?!Is(i,c)||!Is(d,m):!0}function Fd(t,r,i){var c=!1,d=Zn,m=r.contextType;return typeof m=="object"&&m!==null?m=on(m):(d=Gt(r)?pr:$t.current,c=r.contextTypes,m=(c=c!=null)?qr(t,d):Zn),r=new r(i,m),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=si,t.stateNode=r,r._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=d,t.__reactInternalMemoizedMaskedChildContext=m),r}function Md(t,r,i,c){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(i,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(i,c),r.state!==t&&si.enqueueReplaceState(r,r.state,null)}function fl(t,r,i,c){var d=t.stateNode;d.props=i,d.state=t.memoizedState,d.refs={},Xo(t);var m=r.contextType;typeof m=="object"&&m!==null?d.context=on(m):(m=Gt(r)?pr:$t.current,d.context=qr(t,m)),d.state=t.memoizedState,m=r.getDerivedStateFromProps,typeof m=="function"&&(dl(t,r,m,i),d.state=t.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(r=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),r!==d.state&&si.enqueueReplaceState(d,d.state,null),Qa(t,i,d,c),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308)}function ns(t,r){try{var i="",c=r;do i+=H(c),c=c.return;while(c);var d=i}catch(m){d=`
39
+ Error generating stack: `+m.message+`
40
+ `+m.stack}return{value:t,source:r,stack:d,digest:null}}function hl(t,r,i){return{value:t,source:null,stack:i??null,digest:r??null}}function ml(t,r){try{console.error(r.value)}catch(i){setTimeout(function(){throw i})}}var yy=typeof WeakMap=="function"?WeakMap:Map;function Od(t,r,i){i=zn(-1,i),i.tag=3,i.payload={element:null};var c=r.value;return i.callback=function(){di||(di=!0,Al=c),ml(t,r)},i}function Bd(t,r,i){i=zn(-1,i),i.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var d=r.value;i.payload=function(){return c(d)},i.callback=function(){ml(t,r)}}var m=t.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(i.callback=function(){ml(t,r),typeof c!="function"&&(sr===null?sr=new Set([this]):sr.add(this));var j=r.stack;this.componentDidCatch(r.value,{componentStack:j!==null?j:""})}),i}function Dd(t,r,i){var c=t.pingCache;if(c===null){c=t.pingCache=new yy;var d=new Set;c.set(r,d)}else d=c.get(r),d===void 0&&(d=new Set,c.set(r,d));d.has(i)||(d.add(i),t=Ry.bind(null,t,r,i),r.then(t,t))}function Ud(t){do{var r;if((r=t.tag===13)&&(r=t.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return t;t=t.return}while(t!==null);return null}function Wd(t,r,i,c,d){return(t.mode&1)===0?(t===r?t.flags|=65536:(t.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(r=zn(-1,1),r.tag=2,nr(i,r,1))),i.lanes|=1),t):(t.flags|=65536,t.lanes=d,t)}var vy=I.ReactCurrentOwner,Kt=!1;function Bt(t,r,i,c){r.child=t===null?cd(r,null,i,c):Xr(r,t.child,i,c)}function Hd(t,r,i,c,d){i=i.render;var m=r.ref;return es(r,d),c=al(t,r,i,c,m,d),i=il(),t!==null&&!Kt?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~d,Fn(t,r,d)):(ct&&i&&Uo(r),r.flags|=1,Bt(t,r,c,d),r.child)}function Vd(t,r,i,c,d){if(t===null){var m=i.type;return typeof m=="function"&&!zl(m)&&m.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(r.tag=15,r.type=m,Gd(t,r,m,c,d)):(t=yi(i.type,null,c,r,r.mode,d),t.ref=r.ref,t.return=r,r.child=t)}if(m=t.child,(t.lanes&d)===0){var j=m.memoizedProps;if(i=i.compare,i=i!==null?i:Is,i(j,c)&&t.ref===r.ref)return Fn(t,r,d)}return r.flags|=1,t=lr(m,c),t.ref=r.ref,t.return=r,r.child=t}function Gd(t,r,i,c,d){if(t!==null){var m=t.memoizedProps;if(Is(m,c)&&t.ref===r.ref)if(Kt=!1,r.pendingProps=c=m,(t.lanes&d)!==0)(t.flags&131072)!==0&&(Kt=!0);else return r.lanes=t.lanes,Fn(t,r,d)}return pl(t,r,i,c,d)}function Kd(t,r,i){var c=r.pendingProps,d=c.children,m=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},at(ss,nn),nn|=i;else{if((i&1073741824)===0)return t=m!==null?m.baseLanes|i:i,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:t,cachePool:null,transitions:null},r.updateQueue=null,at(ss,nn),nn|=t,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=m!==null?m.baseLanes:i,at(ss,nn),nn|=c}else m!==null?(c=m.baseLanes|i,r.memoizedState=null):c=i,at(ss,nn),nn|=c;return Bt(t,r,d,i),r.child}function qd(t,r){var i=r.ref;(t===null&&i!==null||t!==null&&t.ref!==i)&&(r.flags|=512,r.flags|=2097152)}function pl(t,r,i,c,d){var m=Gt(i)?pr:$t.current;return m=qr(r,m),es(r,d),i=al(t,r,i,c,m,d),c=il(),t!==null&&!Kt?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~d,Fn(t,r,d)):(ct&&c&&Uo(r),r.flags|=1,Bt(t,r,i,d),r.child)}function Yd(t,r,i,c,d){if(Gt(i)){var m=!0;Ua(r)}else m=!1;if(es(r,d),r.stateNode===null)ii(t,r),Fd(r,i,c),fl(r,i,c,d),c=!0;else if(t===null){var j=r.stateNode,C=r.memoizedProps;j.props=C;var R=j.context,V=i.contextType;typeof V=="object"&&V!==null?V=on(V):(V=Gt(i)?pr:$t.current,V=qr(r,V));var ae=i.getDerivedStateFromProps,ce=typeof ae=="function"||typeof j.getSnapshotBeforeUpdate=="function";ce||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(C!==c||R!==V)&&Md(r,j,c,V),tr=!1;var re=r.memoizedState;j.state=re,Qa(r,c,j,d),R=r.memoizedState,C!==c||re!==R||Vt.current||tr?(typeof ae=="function"&&(dl(r,i,ae,c),R=r.memoizedState),(C=tr||zd(r,i,C,c,re,R,V))?(ce||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(r.flags|=4194308)):(typeof j.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=R),j.props=c,j.state=R,j.context=V,c=C):(typeof j.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{j=r.stateNode,dd(t,r),C=r.memoizedProps,V=r.type===r.elementType?C:gn(r.type,C),j.props=V,ce=r.pendingProps,re=j.context,R=i.contextType,typeof R=="object"&&R!==null?R=on(R):(R=Gt(i)?pr:$t.current,R=qr(r,R));var je=i.getDerivedStateFromProps;(ae=typeof je=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(C!==ce||re!==R)&&Md(r,j,c,R),tr=!1,re=r.memoizedState,j.state=re,Qa(r,c,j,d);var ke=r.memoizedState;C!==ce||re!==ke||Vt.current||tr?(typeof je=="function"&&(dl(r,i,je,c),ke=r.memoizedState),(V=tr||zd(r,i,V,c,re,ke,R)||!1)?(ae||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(c,ke,R),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(c,ke,R)),typeof j.componentDidUpdate=="function"&&(r.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof j.componentDidUpdate!="function"||C===t.memoizedProps&&re===t.memoizedState||(r.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||C===t.memoizedProps&&re===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=ke),j.props=c,j.state=ke,j.context=R,c=V):(typeof j.componentDidUpdate!="function"||C===t.memoizedProps&&re===t.memoizedState||(r.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||C===t.memoizedProps&&re===t.memoizedState||(r.flags|=1024),c=!1)}return gl(t,r,i,c,m,d)}function gl(t,r,i,c,d,m){qd(t,r);var j=(r.flags&128)!==0;if(!c&&!j)return d&&ed(r,i,!1),Fn(t,r,m);c=r.stateNode,vy.current=r;var C=j&&typeof i.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,t!==null&&j?(r.child=Xr(r,t.child,null,m),r.child=Xr(r,null,C,m)):Bt(t,r,C,m),r.memoizedState=c.state,d&&ed(r,i,!0),r.child}function Jd(t){var r=t.stateNode;r.pendingContext?Xu(t,r.pendingContext,r.pendingContext!==r.context):r.context&&Xu(t,r.context,!1),Zo(t,r.containerInfo)}function Qd(t,r,i,c,d){return Qr(),Go(d),r.flags|=256,Bt(t,r,i,c),r.child}var yl={dehydrated:null,treeContext:null,retryLane:0};function vl(t){return{baseLanes:t,cachePool:null,transitions:null}}function Xd(t,r,i){var c=r.pendingProps,d=ht.current,m=!1,j=(r.flags&128)!==0,C;if((C=j)||(C=t!==null&&t.memoizedState===null?!1:(d&2)!==0),C?(m=!0,r.flags&=-129):(t===null||t.memoizedState!==null)&&(d|=1),at(ht,d&1),t===null)return Vo(r),t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((r.mode&1)===0?r.lanes=1:t.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(j=c.children,t=c.fallback,m?(c=r.mode,m=r.child,j={mode:"hidden",children:j},(c&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=j):m=vi(j,c,0,null),t=Nr(t,c,i,null),m.return=r,t.return=r,m.sibling=t,r.child=m,r.child.memoizedState=vl(i),r.memoizedState=yl,t):xl(r,j));if(d=t.memoizedState,d!==null&&(C=d.dehydrated,C!==null))return xy(t,r,j,c,C,d,i);if(m){m=c.fallback,j=r.mode,d=t.child,C=d.sibling;var R={mode:"hidden",children:c.children};return(j&1)===0&&r.child!==d?(c=r.child,c.childLanes=0,c.pendingProps=R,r.deletions=null):(c=lr(d,R),c.subtreeFlags=d.subtreeFlags&14680064),C!==null?m=lr(C,m):(m=Nr(m,j,i,null),m.flags|=2),m.return=r,c.return=r,c.sibling=m,r.child=c,c=m,m=r.child,j=t.child.memoizedState,j=j===null?vl(i):{baseLanes:j.baseLanes|i,cachePool:null,transitions:j.transitions},m.memoizedState=j,m.childLanes=t.childLanes&~i,r.memoizedState=yl,c}return m=t.child,t=m.sibling,c=lr(m,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=i),c.return=r,c.sibling=null,t!==null&&(i=r.deletions,i===null?(r.deletions=[t],r.flags|=16):i.push(t)),r.child=c,r.memoizedState=null,c}function xl(t,r){return r=vi({mode:"visible",children:r},t.mode,0,null),r.return=t,t.child=r}function ai(t,r,i,c){return c!==null&&Go(c),Xr(r,t.child,null,i),t=xl(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function xy(t,r,i,c,d,m,j){if(i)return r.flags&256?(r.flags&=-257,c=hl(Error(a(422))),ai(t,r,j,c)):r.memoizedState!==null?(r.child=t.child,r.flags|=128,null):(m=c.fallback,d=r.mode,c=vi({mode:"visible",children:c.children},d,0,null),m=Nr(m,d,j,null),m.flags|=2,c.return=r,m.return=r,c.sibling=m,r.child=c,(r.mode&1)!==0&&Xr(r,t.child,null,j),r.child.memoizedState=vl(j),r.memoizedState=yl,m);if((r.mode&1)===0)return ai(t,r,j,null);if(d.data==="$!"){if(c=d.nextSibling&&d.nextSibling.dataset,c)var C=c.dgst;return c=C,m=Error(a(419)),c=hl(m,c,void 0),ai(t,r,j,c)}if(C=(j&t.childLanes)!==0,Kt||C){if(c=Tt,c!==null){switch(j&-j){case 4:d=2;break;case 16:d=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(c.suspendedLanes|j))!==0?0:d,d!==0&&d!==m.retryLane&&(m.retryLane=d,Ln(t,d),xn(c,t,d,-1))}return Ll(),c=hl(Error(a(421))),ai(t,r,j,c)}return d.data==="$?"?(r.flags|=128,r.child=t.child,r=Py.bind(null,t),d._reactRetry=r,null):(t=m.treeContext,tn=Qn(d.nextSibling),en=r,ct=!0,pn=null,t!==null&&(sn[an++]=$n,sn[an++]=_n,sn[an++]=gr,$n=t.id,_n=t.overflow,gr=r),r=xl(r,c.children),r.flags|=4096,r)}function Zd(t,r,i){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),Jo(t.return,r,i)}function wl(t,r,i,c,d){var m=t.memoizedState;m===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:i,tailMode:d}:(m.isBackwards=r,m.rendering=null,m.renderingStartTime=0,m.last=c,m.tail=i,m.tailMode=d)}function ef(t,r,i){var c=r.pendingProps,d=c.revealOrder,m=c.tail;if(Bt(t,r,c.children,i),c=ht.current,(c&2)!==0)c=c&1|2,r.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Zd(t,i,r);else if(t.tag===19)Zd(t,i,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(at(ht,c),(r.mode&1)===0)r.memoizedState=null;else switch(d){case"forwards":for(i=r.child,d=null;i!==null;)t=i.alternate,t!==null&&Xa(t)===null&&(d=i),i=i.sibling;i=d,i===null?(d=r.child,r.child=null):(d=i.sibling,i.sibling=null),wl(r,!1,d,i,m);break;case"backwards":for(i=null,d=r.child,r.child=null;d!==null;){if(t=d.alternate,t!==null&&Xa(t)===null){r.child=d;break}t=d.sibling,d.sibling=i,i=d,d=t}wl(r,!0,i,null,m);break;case"together":wl(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ii(t,r){(r.mode&1)===0&&t!==null&&(t.alternate=null,r.alternate=null,r.flags|=2)}function Fn(t,r,i){if(t!==null&&(r.dependencies=t.dependencies),jr|=r.lanes,(i&r.childLanes)===0)return null;if(t!==null&&r.child!==t.child)throw Error(a(153));if(r.child!==null){for(t=r.child,i=lr(t,t.pendingProps),r.child=i,i.return=r;t.sibling!==null;)t=t.sibling,i=i.sibling=lr(t,t.pendingProps),i.return=r;i.sibling=null}return r.child}function wy(t,r,i){switch(r.tag){case 3:Jd(r),Qr();break;case 5:md(r);break;case 1:Gt(r.type)&&Ua(r);break;case 4:Zo(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,d=r.memoizedProps.value;at(qa,c._currentValue),c._currentValue=d;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(at(ht,ht.current&1),r.flags|=128,null):(i&r.child.childLanes)!==0?Xd(t,r,i):(at(ht,ht.current&1),t=Fn(t,r,i),t!==null?t.sibling:null);at(ht,ht.current&1);break;case 19:if(c=(i&r.childLanes)!==0,(t.flags&128)!==0){if(c)return ef(t,r,i);r.flags|=128}if(d=r.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),at(ht,ht.current),c)break;return null;case 22:case 23:return r.lanes=0,Kd(t,r,i)}return Fn(t,r,i)}var tf,jl,nf,rf;tf=function(t,r){for(var i=r.child;i!==null;){if(i.tag===5||i.tag===6)t.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},jl=function(){},nf=function(t,r,i,c){var d=t.memoizedProps;if(d!==c){t=r.stateNode,xr(En.current);var m=null;switch(i){case"input":d=Le(t,d),c=Le(t,c),m=[];break;case"select":d=Y({},d,{value:void 0}),c=Y({},c,{value:void 0}),m=[];break;case"textarea":d=dt(t,d),c=dt(t,c),m=[];break;default:typeof d.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=Oa)}et(i,c);var j;i=null;for(V in d)if(!c.hasOwnProperty(V)&&d.hasOwnProperty(V)&&d[V]!=null)if(V==="style"){var C=d[V];for(j in C)C.hasOwnProperty(j)&&(i||(i={}),i[j]="")}else V!=="dangerouslySetInnerHTML"&&V!=="children"&&V!=="suppressContentEditableWarning"&&V!=="suppressHydrationWarning"&&V!=="autoFocus"&&(l.hasOwnProperty(V)?m||(m=[]):(m=m||[]).push(V,null));for(V in c){var R=c[V];if(C=d!=null?d[V]:void 0,c.hasOwnProperty(V)&&R!==C&&(R!=null||C!=null))if(V==="style")if(C){for(j in C)!C.hasOwnProperty(j)||R&&R.hasOwnProperty(j)||(i||(i={}),i[j]="");for(j in R)R.hasOwnProperty(j)&&C[j]!==R[j]&&(i||(i={}),i[j]=R[j])}else i||(m||(m=[]),m.push(V,i)),i=R;else V==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,C=C?C.__html:void 0,R!=null&&C!==R&&(m=m||[]).push(V,R)):V==="children"?typeof R!="string"&&typeof R!="number"||(m=m||[]).push(V,""+R):V!=="suppressContentEditableWarning"&&V!=="suppressHydrationWarning"&&(l.hasOwnProperty(V)?(R!=null&&V==="onScroll"&&ot("scroll",t),m||C===R||(m=[])):(m=m||[]).push(V,R))}i&&(m=m||[]).push("style",i);var V=m;(r.updateQueue=V)&&(r.flags|=4)}},rf=function(t,r,i,c){i!==c&&(r.flags|=4)};function Vs(t,r){if(!ct)switch(t.tailMode){case"hidden":r=t.tail;for(var i=null;r!==null;)r.alternate!==null&&(i=r),r=r.sibling;i===null?t.tail=null:i.sibling=null;break;case"collapsed":i=t.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function Lt(t){var r=t.alternate!==null&&t.alternate.child===t.child,i=0,c=0;if(r)for(var d=t.child;d!==null;)i|=d.lanes|d.childLanes,c|=d.subtreeFlags&14680064,c|=d.flags&14680064,d.return=t,d=d.sibling;else for(d=t.child;d!==null;)i|=d.lanes|d.childLanes,c|=d.subtreeFlags,c|=d.flags,d.return=t,d=d.sibling;return t.subtreeFlags|=c,t.childLanes=i,r}function jy(t,r,i){var c=r.pendingProps;switch(Wo(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lt(r),null;case 1:return Gt(r.type)&&Da(),Lt(r),null;case 3:return c=r.stateNode,ts(),lt(Vt),lt($t),nl(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Ga(r)?r.flags|=4:t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,pn!==null&&(Pl(pn),pn=null))),jl(t,r),Lt(r),null;case 5:el(r);var d=xr(Bs.current);if(i=r.type,t!==null&&r.stateNode!=null)nf(t,r,i,c,d),t.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!c){if(r.stateNode===null)throw Error(a(166));return Lt(r),null}if(t=xr(En.current),Ga(r)){c=r.stateNode,i=r.type;var m=r.memoizedProps;switch(c[Cn]=r,c[Ls]=m,t=(r.mode&1)!==0,i){case"dialog":ot("cancel",c),ot("close",c);break;case"iframe":case"object":case"embed":ot("load",c);break;case"video":case"audio":for(d=0;d<Ps.length;d++)ot(Ps[d],c);break;case"source":ot("error",c);break;case"img":case"image":case"link":ot("error",c),ot("load",c);break;case"details":ot("toggle",c);break;case"input":ze(c,m),ot("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!m.multiple},ot("invalid",c);break;case"textarea":ft(c,m),ot("invalid",c)}et(i,m),d=null;for(var j in m)if(m.hasOwnProperty(j)){var C=m[j];j==="children"?typeof C=="string"?c.textContent!==C&&(m.suppressHydrationWarning!==!0&&Ma(c.textContent,C,t),d=["children",C]):typeof C=="number"&&c.textContent!==""+C&&(m.suppressHydrationWarning!==!0&&Ma(c.textContent,C,t),d=["children",""+C]):l.hasOwnProperty(j)&&C!=null&&j==="onScroll"&&ot("scroll",c)}switch(i){case"input":qe(c),nt(c,m,!0);break;case"textarea":qe(c),me(c);break;case"select":case"option":break;default:typeof m.onClick=="function"&&(c.onclick=Oa)}c=d,r.updateQueue=c,c!==null&&(r.flags|=4)}else{j=d.nodeType===9?d:d.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=Re(i)),t==="http://www.w3.org/1999/xhtml"?i==="script"?(t=j.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof c.is=="string"?t=j.createElement(i,{is:c.is}):(t=j.createElement(i),i==="select"&&(j=t,c.multiple?j.multiple=!0:c.size&&(j.size=c.size))):t=j.createElementNS(t,i),t[Cn]=r,t[Ls]=c,tf(t,r,!1,!1),r.stateNode=t;e:{switch(j=W(i,c),i){case"dialog":ot("cancel",t),ot("close",t),d=c;break;case"iframe":case"object":case"embed":ot("load",t),d=c;break;case"video":case"audio":for(d=0;d<Ps.length;d++)ot(Ps[d],t);d=c;break;case"source":ot("error",t),d=c;break;case"img":case"image":case"link":ot("error",t),ot("load",t),d=c;break;case"details":ot("toggle",t),d=c;break;case"input":ze(t,c),d=Le(t,c),ot("invalid",t);break;case"option":d=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},d=Y({},c,{value:void 0}),ot("invalid",t);break;case"textarea":ft(t,c),d=dt(t,c),ot("invalid",t);break;default:d=c}et(i,d),C=d;for(m in C)if(C.hasOwnProperty(m)){var R=C[m];m==="style"?Ht(t,R):m==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&J(t,R)):m==="children"?typeof R=="string"?(i!=="textarea"||R!=="")&&ye(t,R):typeof R=="number"&&ye(t,""+R):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(l.hasOwnProperty(m)?R!=null&&m==="onScroll"&&ot("scroll",t):R!=null&&P(t,m,R,j))}switch(i){case"input":qe(t),nt(t,c,!1);break;case"textarea":qe(t),me(t);break;case"option":c.value!=null&&t.setAttribute("value",""+ge(c.value));break;case"select":t.multiple=!!c.multiple,m=c.value,m!=null?We(t,!!c.multiple,m,!1):c.defaultValue!=null&&We(t,!!c.multiple,c.defaultValue,!0);break;default:typeof d.onClick=="function"&&(t.onclick=Oa)}switch(i){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Lt(r),null;case 6:if(t&&r.stateNode!=null)rf(t,r,t.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(a(166));if(i=xr(Bs.current),xr(En.current),Ga(r)){if(c=r.stateNode,i=r.memoizedProps,c[Cn]=r,(m=c.nodeValue!==i)&&(t=en,t!==null))switch(t.tag){case 3:Ma(c.nodeValue,i,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Ma(c.nodeValue,i,(t.mode&1)!==0)}m&&(r.flags|=4)}else c=(i.nodeType===9?i:i.ownerDocument).createTextNode(c),c[Cn]=r,r.stateNode=c}return Lt(r),null;case 13:if(lt(ht),c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(ct&&tn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)id(),Qr(),r.flags|=98560,m=!1;else if(m=Ga(r),c!==null&&c.dehydrated!==null){if(t===null){if(!m)throw Error(a(318));if(m=r.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(a(317));m[Cn]=r}else Qr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Lt(r),m=!1}else pn!==null&&(Pl(pn),pn=null),m=!0;if(!m)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=i,r):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(t===null||(ht.current&1)!==0?kt===0&&(kt=3):Ll())),r.updateQueue!==null&&(r.flags|=4),Lt(r),null);case 4:return ts(),jl(t,r),t===null&&$s(r.stateNode.containerInfo),Lt(r),null;case 10:return Yo(r.type._context),Lt(r),null;case 17:return Gt(r.type)&&Da(),Lt(r),null;case 19:if(lt(ht),m=r.memoizedState,m===null)return Lt(r),null;if(c=(r.flags&128)!==0,j=m.rendering,j===null)if(c)Vs(m,!1);else{if(kt!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(j=Xa(t),j!==null){for(r.flags|=128,Vs(m,!1),c=j.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),r.subtreeFlags=0,c=i,i=r.child;i!==null;)m=i,t=c,m.flags&=14680066,j=m.alternate,j===null?(m.childLanes=0,m.lanes=t,m.child=null,m.subtreeFlags=0,m.memoizedProps=null,m.memoizedState=null,m.updateQueue=null,m.dependencies=null,m.stateNode=null):(m.childLanes=j.childLanes,m.lanes=j.lanes,m.child=j.child,m.subtreeFlags=0,m.deletions=null,m.memoizedProps=j.memoizedProps,m.memoizedState=j.memoizedState,m.updateQueue=j.updateQueue,m.type=j.type,t=j.dependencies,m.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),i=i.sibling;return at(ht,ht.current&1|2),r.child}t=t.sibling}m.tail!==null&&vt()>as&&(r.flags|=128,c=!0,Vs(m,!1),r.lanes=4194304)}else{if(!c)if(t=Xa(j),t!==null){if(r.flags|=128,c=!0,i=t.updateQueue,i!==null&&(r.updateQueue=i,r.flags|=4),Vs(m,!0),m.tail===null&&m.tailMode==="hidden"&&!j.alternate&&!ct)return Lt(r),null}else 2*vt()-m.renderingStartTime>as&&i!==1073741824&&(r.flags|=128,c=!0,Vs(m,!1),r.lanes=4194304);m.isBackwards?(j.sibling=r.child,r.child=j):(i=m.last,i!==null?i.sibling=j:r.child=j,m.last=j)}return m.tail!==null?(r=m.tail,m.rendering=r,m.tail=r.sibling,m.renderingStartTime=vt(),r.sibling=null,i=ht.current,at(ht,c?i&1|2:i&1),r):(Lt(r),null);case 22:case 23:return _l(),c=r.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(nn&1073741824)!==0&&(Lt(r),r.subtreeFlags&6&&(r.flags|=8192)):Lt(r),null;case 24:return null;case 25:return null}throw Error(a(156,r.tag))}function Sy(t,r){switch(Wo(r),r.tag){case 1:return Gt(r.type)&&Da(),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return ts(),lt(Vt),lt($t),nl(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 5:return el(r),null;case 13:if(lt(ht),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(a(340));Qr()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return lt(ht),null;case 4:return ts(),null;case 10:return Yo(r.type._context),null;case 22:case 23:return _l(),null;case 24:return null;default:return null}}var oi=!1,zt=!1,by=typeof WeakSet=="function"?WeakSet:Set,Se=null;function rs(t,r){var i=t.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(c){pt(t,r,c)}else i.current=null}function Sl(t,r,i){try{i()}catch(c){pt(t,r,c)}}var sf=!1;function ky(t,r){if(_o=Ea,t=zu(),Co(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var c=i.getSelection&&i.getSelection();if(c&&c.rangeCount!==0){i=c.anchorNode;var d=c.anchorOffset,m=c.focusNode;c=c.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var j=0,C=-1,R=-1,V=0,ae=0,ce=t,re=null;t:for(;;){for(var je;ce!==i||d!==0&&ce.nodeType!==3||(C=j+d),ce!==m||c!==0&&ce.nodeType!==3||(R=j+c),ce.nodeType===3&&(j+=ce.nodeValue.length),(je=ce.firstChild)!==null;)re=ce,ce=je;for(;;){if(ce===t)break t;if(re===i&&++V===d&&(C=j),re===m&&++ae===c&&(R=j),(je=ce.nextSibling)!==null)break;ce=re,re=ce.parentNode}ce=je}i=C===-1||R===-1?null:{start:C,end:R}}else i=null}i=i||{start:0,end:0}}else i=null;for(Lo={focusedElem:t,selectionRange:i},Ea=!1,Se=r;Se!==null;)if(r=Se,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,Se=t;else for(;Se!==null;){r=Se;try{var ke=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(ke!==null){var Ee=ke.memoizedProps,xt=ke.memoizedState,F=r.stateNode,$=F.getSnapshotBeforeUpdate(r.elementType===r.type?Ee:gn(r.type,Ee),xt);F.__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(he){pt(r,r.return,he)}if(t=r.sibling,t!==null){t.return=r.return,Se=t;break}Se=r.return}return ke=sf,sf=!1,ke}function Gs(t,r,i){var c=r.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var d=c=c.next;do{if((d.tag&t)===t){var m=d.destroy;d.destroy=void 0,m!==void 0&&Sl(r,i,m)}d=d.next}while(d!==c)}}function li(t,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var c=i.create;i.destroy=c()}i=i.next}while(i!==r)}}function bl(t){var r=t.ref;if(r!==null){var i=t.stateNode;switch(t.tag){case 5:t=i;break;default:t=i}typeof r=="function"?r(t):r.current=t}}function af(t){var r=t.alternate;r!==null&&(t.alternate=null,af(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&(delete r[Cn],delete r[Ls],delete r[Oo],delete r[iy],delete r[oy])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function of(t){return t.tag===5||t.tag===3||t.tag===4}function lf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||of(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function kl(t,r,i){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?i.nodeType===8?i.parentNode.insertBefore(t,r):i.insertBefore(t,r):(i.nodeType===8?(r=i.parentNode,r.insertBefore(t,i)):(r=i,r.appendChild(t)),i=i._reactRootContainer,i!=null||r.onclick!==null||(r.onclick=Oa));else if(c!==4&&(t=t.child,t!==null))for(kl(t,r,i),t=t.sibling;t!==null;)kl(t,r,i),t=t.sibling}function Nl(t,r,i){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?i.insertBefore(t,r):i.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(Nl(t,r,i),t=t.sibling;t!==null;)Nl(t,r,i),t=t.sibling}var It=null,yn=!1;function rr(t,r,i){for(i=i.child;i!==null;)cf(t,r,i),i=i.sibling}function cf(t,r,i){if(Nn&&typeof Nn.onCommitFiberUnmount=="function")try{Nn.onCommitFiberUnmount(ja,i)}catch{}switch(i.tag){case 5:zt||rs(i,r);case 6:var c=It,d=yn;It=null,rr(t,r,i),It=c,yn=d,It!==null&&(yn?(t=It,i=i.stateNode,t.nodeType===8?t.parentNode.removeChild(i):t.removeChild(i)):It.removeChild(i.stateNode));break;case 18:It!==null&&(yn?(t=It,i=i.stateNode,t.nodeType===8?Mo(t.parentNode,i):t.nodeType===1&&Mo(t,i),ks(t)):Mo(It,i.stateNode));break;case 4:c=It,d=yn,It=i.stateNode.containerInfo,yn=!0,rr(t,r,i),It=c,yn=d;break;case 0:case 11:case 14:case 15:if(!zt&&(c=i.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){d=c=c.next;do{var m=d,j=m.destroy;m=m.tag,j!==void 0&&((m&2)!==0||(m&4)!==0)&&Sl(i,r,j),d=d.next}while(d!==c)}rr(t,r,i);break;case 1:if(!zt&&(rs(i,r),c=i.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=i.memoizedProps,c.state=i.memoizedState,c.componentWillUnmount()}catch(C){pt(i,r,C)}rr(t,r,i);break;case 21:rr(t,r,i);break;case 22:i.mode&1?(zt=(c=zt)||i.memoizedState!==null,rr(t,r,i),zt=c):rr(t,r,i);break;default:rr(t,r,i)}}function uf(t){var r=t.updateQueue;if(r!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new by),r.forEach(function(c){var d=$y.bind(null,t,c);i.has(c)||(i.add(c),c.then(d,d))})}}function vn(t,r){var i=r.deletions;if(i!==null)for(var c=0;c<i.length;c++){var d=i[c];try{var m=t,j=r,C=j;e:for(;C!==null;){switch(C.tag){case 5:It=C.stateNode,yn=!1;break e;case 3:It=C.stateNode.containerInfo,yn=!0;break e;case 4:It=C.stateNode.containerInfo,yn=!0;break e}C=C.return}if(It===null)throw Error(a(160));cf(m,j,d),It=null,yn=!1;var R=d.alternate;R!==null&&(R.return=null),d.return=null}catch(V){pt(d,r,V)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)df(r,t),r=r.sibling}function df(t,r){var i=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(vn(r,t),An(t),c&4){try{Gs(3,t,t.return),li(3,t)}catch(Ee){pt(t,t.return,Ee)}try{Gs(5,t,t.return)}catch(Ee){pt(t,t.return,Ee)}}break;case 1:vn(r,t),An(t),c&512&&i!==null&&rs(i,i.return);break;case 5:if(vn(r,t),An(t),c&512&&i!==null&&rs(i,i.return),t.flags&32){var d=t.stateNode;try{ye(d,"")}catch(Ee){pt(t,t.return,Ee)}}if(c&4&&(d=t.stateNode,d!=null)){var m=t.memoizedProps,j=i!==null?i.memoizedProps:m,C=t.type,R=t.updateQueue;if(t.updateQueue=null,R!==null)try{C==="input"&&m.type==="radio"&&m.name!=null&&Ue(d,m),W(C,j);var V=W(C,m);for(j=0;j<R.length;j+=2){var ae=R[j],ce=R[j+1];ae==="style"?Ht(d,ce):ae==="dangerouslySetInnerHTML"?J(d,ce):ae==="children"?ye(d,ce):P(d,ae,ce,V)}switch(C){case"input":we(d,m);break;case"textarea":Fe(d,m);break;case"select":var re=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!m.multiple;var je=m.value;je!=null?We(d,!!m.multiple,je,!1):re!==!!m.multiple&&(m.defaultValue!=null?We(d,!!m.multiple,m.defaultValue,!0):We(d,!!m.multiple,m.multiple?[]:"",!1))}d[Ls]=m}catch(Ee){pt(t,t.return,Ee)}}break;case 6:if(vn(r,t),An(t),c&4){if(t.stateNode===null)throw Error(a(162));d=t.stateNode,m=t.memoizedProps;try{d.nodeValue=m}catch(Ee){pt(t,t.return,Ee)}}break;case 3:if(vn(r,t),An(t),c&4&&i!==null&&i.memoizedState.isDehydrated)try{ks(r.containerInfo)}catch(Ee){pt(t,t.return,Ee)}break;case 4:vn(r,t),An(t);break;case 13:vn(r,t),An(t),d=t.child,d.flags&8192&&(m=d.memoizedState!==null,d.stateNode.isHidden=m,!m||d.alternate!==null&&d.alternate.memoizedState!==null||(Tl=vt())),c&4&&uf(t);break;case 22:if(ae=i!==null&&i.memoizedState!==null,t.mode&1?(zt=(V=zt)||ae,vn(r,t),zt=V):vn(r,t),An(t),c&8192){if(V=t.memoizedState!==null,(t.stateNode.isHidden=V)&&!ae&&(t.mode&1)!==0)for(Se=t,ae=t.child;ae!==null;){for(ce=Se=ae;Se!==null;){switch(re=Se,je=re.child,re.tag){case 0:case 11:case 14:case 15:Gs(4,re,re.return);break;case 1:rs(re,re.return);var ke=re.stateNode;if(typeof ke.componentWillUnmount=="function"){c=re,i=re.return;try{r=c,ke.props=r.memoizedProps,ke.state=r.memoizedState,ke.componentWillUnmount()}catch(Ee){pt(c,i,Ee)}}break;case 5:rs(re,re.return);break;case 22:if(re.memoizedState!==null){mf(ce);continue}}je!==null?(je.return=re,Se=je):mf(ce)}ae=ae.sibling}e:for(ae=null,ce=t;;){if(ce.tag===5){if(ae===null){ae=ce;try{d=ce.stateNode,V?(m=d.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none"):(C=ce.stateNode,R=ce.memoizedProps.style,j=R!=null&&R.hasOwnProperty("display")?R.display:null,C.style.display=rt("display",j))}catch(Ee){pt(t,t.return,Ee)}}}else if(ce.tag===6){if(ae===null)try{ce.stateNode.nodeValue=V?"":ce.memoizedProps}catch(Ee){pt(t,t.return,Ee)}}else if((ce.tag!==22&&ce.tag!==23||ce.memoizedState===null||ce===t)&&ce.child!==null){ce.child.return=ce,ce=ce.child;continue}if(ce===t)break e;for(;ce.sibling===null;){if(ce.return===null||ce.return===t)break e;ae===ce&&(ae=null),ce=ce.return}ae===ce&&(ae=null),ce.sibling.return=ce.return,ce=ce.sibling}}break;case 19:vn(r,t),An(t),c&4&&uf(t);break;case 21:break;default:vn(r,t),An(t)}}function An(t){var r=t.flags;if(r&2){try{e:{for(var i=t.return;i!==null;){if(of(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=lf(t);Nl(t,m,d);break;case 3:case 4:var j=c.stateNode.containerInfo,C=lf(t);kl(t,C,j);break;default:throw Error(a(161))}}catch(R){pt(t,t.return,R)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function Ny(t,r,i){Se=t,ff(t)}function ff(t,r,i){for(var c=(t.mode&1)!==0;Se!==null;){var d=Se,m=d.child;if(d.tag===22&&c){var j=d.memoizedState!==null||oi;if(!j){var C=d.alternate,R=C!==null&&C.memoizedState!==null||zt;C=oi;var V=zt;if(oi=j,(zt=R)&&!V)for(Se=d;Se!==null;)j=Se,R=j.child,j.tag===22&&j.memoizedState!==null?pf(d):R!==null?(R.return=j,Se=R):pf(d);for(;m!==null;)Se=m,ff(m),m=m.sibling;Se=d,oi=C,zt=V}hf(t)}else(d.subtreeFlags&8772)!==0&&m!==null?(m.return=d,Se=m):hf(t)}}function hf(t){for(;Se!==null;){var r=Se;if((r.flags&8772)!==0){var i=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:zt||li(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!zt)if(i===null)c.componentDidMount();else{var d=r.elementType===r.type?i.memoizedProps:gn(r.type,i.memoizedProps);c.componentDidUpdate(d,i.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var m=r.updateQueue;m!==null&&hd(r,m,c);break;case 3:var j=r.updateQueue;if(j!==null){if(i=null,r.child!==null)switch(r.child.tag){case 5:i=r.child.stateNode;break;case 1:i=r.child.stateNode}hd(r,j,i)}break;case 5:var C=r.stateNode;if(i===null&&r.flags&4){i=C;var R=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":R.autoFocus&&i.focus();break;case"img":R.src&&(i.src=R.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var V=r.alternate;if(V!==null){var ae=V.memoizedState;if(ae!==null){var ce=ae.dehydrated;ce!==null&&ks(ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}zt||r.flags&512&&bl(r)}catch(re){pt(r,r.return,re)}}if(r===t){Se=null;break}if(i=r.sibling,i!==null){i.return=r.return,Se=i;break}Se=r.return}}function mf(t){for(;Se!==null;){var r=Se;if(r===t){Se=null;break}var i=r.sibling;if(i!==null){i.return=r.return,Se=i;break}Se=r.return}}function pf(t){for(;Se!==null;){var r=Se;try{switch(r.tag){case 0:case 11:case 15:var i=r.return;try{li(4,r)}catch(R){pt(r,i,R)}break;case 1:var c=r.stateNode;if(typeof c.componentDidMount=="function"){var d=r.return;try{c.componentDidMount()}catch(R){pt(r,d,R)}}var m=r.return;try{bl(r)}catch(R){pt(r,m,R)}break;case 5:var j=r.return;try{bl(r)}catch(R){pt(r,j,R)}}}catch(R){pt(r,r.return,R)}if(r===t){Se=null;break}var C=r.sibling;if(C!==null){C.return=r.return,Se=C;break}Se=r.return}}var Cy=Math.ceil,ci=I.ReactCurrentDispatcher,Cl=I.ReactCurrentOwner,cn=I.ReactCurrentBatchConfig,Je=0,Tt=null,jt=null,Rt=0,nn=0,ss=Xn(0),kt=0,Ks=null,jr=0,ui=0,El=0,qs=null,qt=null,Tl=0,as=1/0,Mn=null,di=!1,Al=null,sr=null,fi=!1,ar=null,hi=0,Ys=0,Il=null,mi=-1,pi=0;function Dt(){return(Je&6)!==0?vt():mi!==-1?mi:mi=vt()}function ir(t){return(t.mode&1)===0?1:(Je&2)!==0&&Rt!==0?Rt&-Rt:cy.transition!==null?(pi===0&&(pi=ou()),pi):(t=tt,t!==0||(t=window.event,t=t===void 0?16:gu(t.type)),t)}function xn(t,r,i,c){if(50<Ys)throw Ys=0,Il=null,Error(a(185));xs(t,i,c),((Je&2)===0||t!==Tt)&&(t===Tt&&((Je&2)===0&&(ui|=i),kt===4&&or(t,Rt)),Yt(t,c),i===1&&Je===0&&(r.mode&1)===0&&(as=vt()+500,Wa&&er()))}function Yt(t,r){var i=t.callbackNode;cg(t,r);var c=ka(t,t===Tt?Rt:0);if(c===0)i!==null&&su(i),t.callbackNode=null,t.callbackPriority=0;else if(r=c&-c,t.callbackPriority!==r){if(i!=null&&su(i),r===1)t.tag===0?ly(yf.bind(null,t)):td(yf.bind(null,t)),sy(function(){(Je&6)===0&&er()}),i=null;else{switch(lu(c)){case 1:i=lo;break;case 4:i=au;break;case 16:i=wa;break;case 536870912:i=iu;break;default:i=wa}i=Nf(i,gf.bind(null,t))}t.callbackPriority=r,t.callbackNode=i}}function gf(t,r){if(mi=-1,pi=0,(Je&6)!==0)throw Error(a(327));var i=t.callbackNode;if(is()&&t.callbackNode!==i)return null;var c=ka(t,t===Tt?Rt:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||r)r=gi(t,c);else{r=c;var d=Je;Je|=2;var m=xf();(Tt!==t||Rt!==r)&&(Mn=null,as=vt()+500,br(t,r));do try{Ay();break}catch(C){vf(t,C)}while(!0);qo(),ci.current=m,Je=d,jt!==null?r=0:(Tt=null,Rt=0,r=kt)}if(r!==0){if(r===2&&(d=co(t),d!==0&&(c=d,r=Rl(t,d))),r===1)throw i=Ks,br(t,0),or(t,c),Yt(t,vt()),i;if(r===6)or(t,c);else{if(d=t.current.alternate,(c&30)===0&&!Ey(d)&&(r=gi(t,c),r===2&&(m=co(t),m!==0&&(c=m,r=Rl(t,m))),r===1))throw i=Ks,br(t,0),or(t,c),Yt(t,vt()),i;switch(t.finishedWork=d,t.finishedLanes=c,r){case 0:case 1:throw Error(a(345));case 2:kr(t,qt,Mn);break;case 3:if(or(t,c),(c&130023424)===c&&(r=Tl+500-vt(),10<r)){if(ka(t,0)!==0)break;if(d=t.suspendedLanes,(d&c)!==c){Dt(),t.pingedLanes|=t.suspendedLanes&d;break}t.timeoutHandle=Fo(kr.bind(null,t,qt,Mn),r);break}kr(t,qt,Mn);break;case 4:if(or(t,c),(c&4194240)===c)break;for(r=t.eventTimes,d=-1;0<c;){var j=31-hn(c);m=1<<j,j=r[j],j>d&&(d=j),c&=~m}if(c=d,c=vt()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*Cy(c/1960))-c,10<c){t.timeoutHandle=Fo(kr.bind(null,t,qt,Mn),c);break}kr(t,qt,Mn);break;case 5:kr(t,qt,Mn);break;default:throw Error(a(329))}}}return Yt(t,vt()),t.callbackNode===i?gf.bind(null,t):null}function Rl(t,r){var i=qs;return t.current.memoizedState.isDehydrated&&(br(t,r).flags|=256),t=gi(t,r),t!==2&&(r=qt,qt=i,r!==null&&Pl(r)),t}function Pl(t){qt===null?qt=t:qt.push.apply(qt,t)}function Ey(t){for(var r=t;;){if(r.flags&16384){var i=r.updateQueue;if(i!==null&&(i=i.stores,i!==null))for(var c=0;c<i.length;c++){var d=i[c],m=d.getSnapshot;d=d.value;try{if(!mn(m(),d))return!1}catch{return!1}}}if(i=r.child,r.subtreeFlags&16384&&i!==null)i.return=r,r=i;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function or(t,r){for(r&=~El,r&=~ui,t.suspendedLanes|=r,t.pingedLanes&=~r,t=t.expirationTimes;0<r;){var i=31-hn(r),c=1<<i;t[i]=-1,r&=~c}}function yf(t){if((Je&6)!==0)throw Error(a(327));is();var r=ka(t,0);if((r&1)===0)return Yt(t,vt()),null;var i=gi(t,r);if(t.tag!==0&&i===2){var c=co(t);c!==0&&(r=c,i=Rl(t,c))}if(i===1)throw i=Ks,br(t,0),or(t,r),Yt(t,vt()),i;if(i===6)throw Error(a(345));return t.finishedWork=t.current.alternate,t.finishedLanes=r,kr(t,qt,Mn),Yt(t,vt()),null}function $l(t,r){var i=Je;Je|=1;try{return t(r)}finally{Je=i,Je===0&&(as=vt()+500,Wa&&er())}}function Sr(t){ar!==null&&ar.tag===0&&(Je&6)===0&&is();var r=Je;Je|=1;var i=cn.transition,c=tt;try{if(cn.transition=null,tt=1,t)return t()}finally{tt=c,cn.transition=i,Je=r,(Je&6)===0&&er()}}function _l(){nn=ss.current,lt(ss)}function br(t,r){t.finishedWork=null,t.finishedLanes=0;var i=t.timeoutHandle;if(i!==-1&&(t.timeoutHandle=-1,ry(i)),jt!==null)for(i=jt.return;i!==null;){var c=i;switch(Wo(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Da();break;case 3:ts(),lt(Vt),lt($t),nl();break;case 5:el(c);break;case 4:ts();break;case 13:lt(ht);break;case 19:lt(ht);break;case 10:Yo(c.type._context);break;case 22:case 23:_l()}i=i.return}if(Tt=t,jt=t=lr(t.current,null),Rt=nn=r,kt=0,Ks=null,El=ui=jr=0,qt=qs=null,vr!==null){for(r=0;r<vr.length;r++)if(i=vr[r],c=i.interleaved,c!==null){i.interleaved=null;var d=c.next,m=i.pending;if(m!==null){var j=m.next;m.next=d,c.next=j}i.pending=c}vr=null}return t}function vf(t,r){do{var i=jt;try{if(qo(),Za.current=ri,ei){for(var c=mt.memoizedState;c!==null;){var d=c.queue;d!==null&&(d.pending=null),c=c.next}ei=!1}if(wr=0,Et=bt=mt=null,Ds=!1,Us=0,Cl.current=null,i===null||i.return===null){kt=1,Ks=r,jt=null;break}e:{var m=t,j=i.return,C=i,R=r;if(r=Rt,C.flags|=32768,R!==null&&typeof R=="object"&&typeof R.then=="function"){var V=R,ae=C,ce=ae.tag;if((ae.mode&1)===0&&(ce===0||ce===11||ce===15)){var re=ae.alternate;re?(ae.updateQueue=re.updateQueue,ae.memoizedState=re.memoizedState,ae.lanes=re.lanes):(ae.updateQueue=null,ae.memoizedState=null)}var je=Ud(j);if(je!==null){je.flags&=-257,Wd(je,j,C,m,r),je.mode&1&&Dd(m,V,r),r=je,R=V;var ke=r.updateQueue;if(ke===null){var Ee=new Set;Ee.add(R),r.updateQueue=Ee}else ke.add(R);break e}else{if((r&1)===0){Dd(m,V,r),Ll();break e}R=Error(a(426))}}else if(ct&&C.mode&1){var xt=Ud(j);if(xt!==null){(xt.flags&65536)===0&&(xt.flags|=256),Wd(xt,j,C,m,r),Go(ns(R,C));break e}}m=R=ns(R,C),kt!==4&&(kt=2),qs===null?qs=[m]:qs.push(m),m=j;do{switch(m.tag){case 3:m.flags|=65536,r&=-r,m.lanes|=r;var F=Od(m,R,r);fd(m,F);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"&&(sr===null||!sr.has(D)))){m.flags|=65536,r&=-r,m.lanes|=r;var he=Bd(m,C,r);fd(m,he);break e}}m=m.return}while(m!==null)}jf(i)}catch(Te){r=Te,jt===i&&i!==null&&(jt=i=i.return);continue}break}while(!0)}function xf(){var t=ci.current;return ci.current=ri,t===null?ri:t}function Ll(){(kt===0||kt===3||kt===2)&&(kt=4),Tt===null||(jr&268435455)===0&&(ui&268435455)===0||or(Tt,Rt)}function gi(t,r){var i=Je;Je|=2;var c=xf();(Tt!==t||Rt!==r)&&(Mn=null,br(t,r));do try{Ty();break}catch(d){vf(t,d)}while(!0);if(qo(),Je=i,ci.current=c,jt!==null)throw Error(a(261));return Tt=null,Rt=0,kt}function Ty(){for(;jt!==null;)wf(jt)}function Ay(){for(;jt!==null&&!eg();)wf(jt)}function wf(t){var r=kf(t.alternate,t,nn);t.memoizedProps=t.pendingProps,r===null?jf(t):jt=r,Cl.current=null}function jf(t){var r=t;do{var i=r.alternate;if(t=r.return,(r.flags&32768)===0){if(i=jy(i,r,nn),i!==null){jt=i;return}}else{if(i=Sy(i,r),i!==null){i.flags&=32767,jt=i;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{kt=6,jt=null;return}}if(r=r.sibling,r!==null){jt=r;return}jt=r=t}while(r!==null);kt===0&&(kt=5)}function kr(t,r,i){var c=tt,d=cn.transition;try{cn.transition=null,tt=1,Iy(t,r,i,c)}finally{cn.transition=d,tt=c}return null}function Iy(t,r,i,c){do is();while(ar!==null);if((Je&6)!==0)throw Error(a(327));i=t.finishedWork;var d=t.finishedLanes;if(i===null)return null;if(t.finishedWork=null,t.finishedLanes=0,i===t.current)throw Error(a(177));t.callbackNode=null,t.callbackPriority=0;var m=i.lanes|i.childLanes;if(ug(t,m),t===Tt&&(jt=Tt=null,Rt=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||fi||(fi=!0,Nf(wa,function(){return is(),null})),m=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||m){m=cn.transition,cn.transition=null;var j=tt;tt=1;var C=Je;Je|=4,Cl.current=null,ky(t,i),df(i,t),Jg(Lo),Ea=!!_o,Lo=_o=null,t.current=i,Ny(i),tg(),Je=C,tt=j,cn.transition=m}else t.current=i;if(fi&&(fi=!1,ar=t,hi=d),m=t.pendingLanes,m===0&&(sr=null),sg(i.stateNode),Yt(t,vt()),r!==null)for(c=t.onRecoverableError,i=0;i<r.length;i++)d=r[i],c(d.value,{componentStack:d.stack,digest:d.digest});if(di)throw di=!1,t=Al,Al=null,t;return(hi&1)!==0&&t.tag!==0&&is(),m=t.pendingLanes,(m&1)!==0?t===Il?Ys++:(Ys=0,Il=t):Ys=0,er(),null}function is(){if(ar!==null){var t=lu(hi),r=cn.transition,i=tt;try{if(cn.transition=null,tt=16>t?16:t,ar===null)var c=!1;else{if(t=ar,ar=null,hi=0,(Je&6)!==0)throw Error(a(331));var d=Je;for(Je|=4,Se=t.current;Se!==null;){var m=Se,j=m.child;if((Se.flags&16)!==0){var C=m.deletions;if(C!==null){for(var R=0;R<C.length;R++){var V=C[R];for(Se=V;Se!==null;){var ae=Se;switch(ae.tag){case 0:case 11:case 15:Gs(8,ae,m)}var ce=ae.child;if(ce!==null)ce.return=ae,Se=ce;else for(;Se!==null;){ae=Se;var re=ae.sibling,je=ae.return;if(af(ae),ae===V){Se=null;break}if(re!==null){re.return=je,Se=re;break}Se=je}}}var ke=m.alternate;if(ke!==null){var Ee=ke.child;if(Ee!==null){ke.child=null;do{var xt=Ee.sibling;Ee.sibling=null,Ee=xt}while(Ee!==null)}}Se=m}}if((m.subtreeFlags&2064)!==0&&j!==null)j.return=m,Se=j;else e:for(;Se!==null;){if(m=Se,(m.flags&2048)!==0)switch(m.tag){case 0:case 11:case 15:Gs(9,m,m.return)}var F=m.sibling;if(F!==null){F.return=m.return,Se=F;break e}Se=m.return}}var $=t.current;for(Se=$;Se!==null;){j=Se;var D=j.child;if((j.subtreeFlags&2064)!==0&&D!==null)D.return=j,Se=D;else e:for(j=$;Se!==null;){if(C=Se,(C.flags&2048)!==0)try{switch(C.tag){case 0:case 11:case 15:li(9,C)}}catch(Te){pt(C,C.return,Te)}if(C===j){Se=null;break e}var he=C.sibling;if(he!==null){he.return=C.return,Se=he;break e}Se=C.return}}if(Je=d,er(),Nn&&typeof Nn.onPostCommitFiberRoot=="function")try{Nn.onPostCommitFiberRoot(ja,t)}catch{}c=!0}return c}finally{tt=i,cn.transition=r}}return!1}function Sf(t,r,i){r=ns(i,r),r=Od(t,r,1),t=nr(t,r,1),r=Dt(),t!==null&&(xs(t,1,r),Yt(t,r))}function pt(t,r,i){if(t.tag===3)Sf(t,t,i);else for(;r!==null;){if(r.tag===3){Sf(r,t,i);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(sr===null||!sr.has(c))){t=ns(i,t),t=Bd(r,t,1),r=nr(r,t,1),t=Dt(),r!==null&&(xs(r,1,t),Yt(r,t));break}}r=r.return}}function Ry(t,r,i){var c=t.pingCache;c!==null&&c.delete(r),r=Dt(),t.pingedLanes|=t.suspendedLanes&i,Tt===t&&(Rt&i)===i&&(kt===4||kt===3&&(Rt&130023424)===Rt&&500>vt()-Tl?br(t,0):El|=i),Yt(t,r)}function bf(t,r){r===0&&((t.mode&1)===0?r=1:(r=ba,ba<<=1,(ba&130023424)===0&&(ba=4194304)));var i=Dt();t=Ln(t,r),t!==null&&(xs(t,r,i),Yt(t,i))}function Py(t){var r=t.memoizedState,i=0;r!==null&&(i=r.retryLane),bf(t,i)}function $y(t,r){var i=0;switch(t.tag){case 13:var c=t.stateNode,d=t.memoizedState;d!==null&&(i=d.retryLane);break;case 19:c=t.stateNode;break;default:throw Error(a(314))}c!==null&&c.delete(r),bf(t,i)}var kf;kf=function(t,r,i){if(t!==null)if(t.memoizedProps!==r.pendingProps||Vt.current)Kt=!0;else{if((t.lanes&i)===0&&(r.flags&128)===0)return Kt=!1,wy(t,r,i);Kt=(t.flags&131072)!==0}else Kt=!1,ct&&(r.flags&1048576)!==0&&nd(r,Va,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;ii(t,r),t=r.pendingProps;var d=qr(r,$t.current);es(r,i),d=al(null,r,c,t,d,i);var m=il();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,Gt(c)?(m=!0,Ua(r)):m=!1,r.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Xo(r),d.updater=si,r.stateNode=d,d._reactInternals=r,fl(r,c,t,i),r=gl(null,r,c,!0,m,i)):(r.tag=0,ct&&m&&Uo(r),Bt(null,r,d,i),r=r.child),r;case 16:c=r.elementType;e:{switch(ii(t,r),t=r.pendingProps,d=c._init,c=d(c._payload),r.type=c,d=r.tag=Ly(c),t=gn(c,t),d){case 0:r=pl(null,r,c,t,i);break e;case 1:r=Yd(null,r,c,t,i);break e;case 11:r=Hd(null,r,c,t,i);break e;case 14:r=Vd(null,r,c,gn(c.type,t),i);break e}throw Error(a(306,c,""))}return r;case 0:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),pl(t,r,c,d,i);case 1:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),Yd(t,r,c,d,i);case 3:e:{if(Jd(r),t===null)throw Error(a(387));c=r.pendingProps,m=r.memoizedState,d=m.element,dd(t,r),Qa(r,c,null,i);var j=r.memoizedState;if(c=j.element,m.isDehydrated)if(m={element:c,isDehydrated:!1,cache:j.cache,pendingSuspenseBoundaries:j.pendingSuspenseBoundaries,transitions:j.transitions},r.updateQueue.baseState=m,r.memoizedState=m,r.flags&256){d=ns(Error(a(423)),r),r=Qd(t,r,c,i,d);break e}else if(c!==d){d=ns(Error(a(424)),r),r=Qd(t,r,c,i,d);break e}else for(tn=Qn(r.stateNode.containerInfo.firstChild),en=r,ct=!0,pn=null,i=cd(r,null,c,i),r.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Qr(),c===d){r=Fn(t,r,i);break e}Bt(t,r,c,i)}r=r.child}return r;case 5:return md(r),t===null&&Vo(r),c=r.type,d=r.pendingProps,m=t!==null?t.memoizedProps:null,j=d.children,zo(c,d)?j=null:m!==null&&zo(c,m)&&(r.flags|=32),qd(t,r),Bt(t,r,j,i),r.child;case 6:return t===null&&Vo(r),null;case 13:return Xd(t,r,i);case 4:return Zo(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=Xr(r,null,c,i):Bt(t,r,c,i),r.child;case 11:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),Hd(t,r,c,d,i);case 7:return Bt(t,r,r.pendingProps,i),r.child;case 8:return Bt(t,r,r.pendingProps.children,i),r.child;case 12:return Bt(t,r,r.pendingProps.children,i),r.child;case 10:e:{if(c=r.type._context,d=r.pendingProps,m=r.memoizedProps,j=d.value,at(qa,c._currentValue),c._currentValue=j,m!==null)if(mn(m.value,j)){if(m.children===d.children&&!Vt.current){r=Fn(t,r,i);break e}}else for(m=r.child,m!==null&&(m.return=r);m!==null;){var C=m.dependencies;if(C!==null){j=m.child;for(var R=C.firstContext;R!==null;){if(R.context===c){if(m.tag===1){R=zn(-1,i&-i),R.tag=2;var V=m.updateQueue;if(V!==null){V=V.shared;var ae=V.pending;ae===null?R.next=R:(R.next=ae.next,ae.next=R),V.pending=R}}m.lanes|=i,R=m.alternate,R!==null&&(R.lanes|=i),Jo(m.return,i,r),C.lanes|=i;break}R=R.next}}else if(m.tag===10)j=m.type===r.type?null:m.child;else if(m.tag===18){if(j=m.return,j===null)throw Error(a(341));j.lanes|=i,C=j.alternate,C!==null&&(C.lanes|=i),Jo(j,i,r),j=m.sibling}else j=m.child;if(j!==null)j.return=m;else for(j=m;j!==null;){if(j===r){j=null;break}if(m=j.sibling,m!==null){m.return=j.return,j=m;break}j=j.return}m=j}Bt(t,r,d.children,i),r=r.child}return r;case 9:return d=r.type,c=r.pendingProps.children,es(r,i),d=on(d),c=c(d),r.flags|=1,Bt(t,r,c,i),r.child;case 14:return c=r.type,d=gn(c,r.pendingProps),d=gn(c.type,d),Vd(t,r,c,d,i);case 15:return Gd(t,r,r.type,r.pendingProps,i);case 17:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),ii(t,r),r.tag=1,Gt(c)?(t=!0,Ua(r)):t=!1,es(r,i),Fd(r,c,d),fl(r,c,d,i),gl(null,r,c,!0,t,i);case 19:return ef(t,r,i);case 22:return Kd(t,r,i)}throw Error(a(156,r.tag))};function Nf(t,r){return ru(t,r)}function _y(t,r,i,c){this.tag=t,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function un(t,r,i,c){return new _y(t,r,i,c)}function zl(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ly(t){if(typeof t=="function")return zl(t)?1:0;if(t!=null){if(t=t.$$typeof,t===O)return 11;if(t===ee)return 14}return 2}function lr(t,r){var i=t.alternate;return i===null?(i=un(t.tag,r,t.key,t.mode),i.elementType=t.elementType,i.type=t.type,i.stateNode=t.stateNode,i.alternate=t,t.alternate=i):(i.pendingProps=r,i.type=t.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=t.flags&14680064,i.childLanes=t.childLanes,i.lanes=t.lanes,i.child=t.child,i.memoizedProps=t.memoizedProps,i.memoizedState=t.memoizedState,i.updateQueue=t.updateQueue,r=t.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},i.sibling=t.sibling,i.index=t.index,i.ref=t.ref,i}function yi(t,r,i,c,d,m){var j=2;if(c=t,typeof t=="function")zl(t)&&(j=1);else if(typeof t=="string")j=5;else e:switch(t){case q:return Nr(i.children,d,m,r);case z:j=8,d|=8;break;case U:return t=un(12,i,r,d|2),t.elementType=U,t.lanes=m,t;case ne:return t=un(13,i,r,d),t.elementType=ne,t.lanes=m,t;case fe:return t=un(19,i,r,d),t.elementType=fe,t.lanes=m,t;case Ne:return vi(i,d,m,r);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Z:j=10;break e;case G:j=9;break e;case O:j=11;break e;case ee:j=14;break e;case pe:j=16,c=null;break e}throw Error(a(130,t==null?t:typeof t,""))}return r=un(j,i,r,d),r.elementType=t,r.type=c,r.lanes=m,r}function Nr(t,r,i,c){return t=un(7,t,c,r),t.lanes=i,t}function vi(t,r,i,c){return t=un(22,t,c,r),t.elementType=Ne,t.lanes=i,t.stateNode={isHidden:!1},t}function Fl(t,r,i){return t=un(6,t,null,r),t.lanes=i,t}function Ml(t,r,i){return r=un(4,t.children!==null?t.children:[],t.key,r),r.lanes=i,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}function zy(t,r,i,c,d){this.tag=r,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=uo(0),this.expirationTimes=uo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=uo(0),this.identifierPrefix=c,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Ol(t,r,i,c,d,m,j,C,R){return t=new zy(t,r,i,C,R),r===1?(r=1,m===!0&&(r|=8)):r=0,m=un(3,null,null,r),t.current=m,m.stateNode=t,m.memoizedState={element:c,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Xo(m),t}function Fy(t,r,i){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:M,key:c==null?null:""+c,children:t,containerInfo:r,implementation:i}}function Cf(t){if(!t)return Zn;t=t._reactInternals;e:{if(bn(t)!==t||t.tag!==1)throw Error(a(170));var r=t;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Gt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(a(171))}if(t.tag===1){var i=t.type;if(Gt(i))return Zu(t,i,r)}return r}function Ef(t,r,i,c,d,m,j,C,R){return t=Ol(i,c,!0,t,d,m,j,C,R),t.context=Cf(null),i=t.current,c=Dt(),d=ir(i),m=zn(c,d),m.callback=r??null,nr(i,m,d),t.current.lanes=d,xs(t,d,c),Yt(t,c),t}function xi(t,r,i,c){var d=r.current,m=Dt(),j=ir(d);return i=Cf(i),r.context===null?r.context=i:r.pendingContext=i,r=zn(m,j),r.payload={element:t},c=c===void 0?null:c,c!==null&&(r.callback=c),t=nr(d,r,j),t!==null&&(xn(t,d,j,m),Ja(t,d,j)),j}function wi(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function Tf(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var i=t.retryLane;t.retryLane=i!==0&&i<r?i:r}}function Bl(t,r){Tf(t,r),(t=t.alternate)&&Tf(t,r)}function My(){return null}var Af=typeof reportError=="function"?reportError:function(t){console.error(t)};function Dl(t){this._internalRoot=t}ji.prototype.render=Dl.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(a(409));xi(t,r,null,null)},ji.prototype.unmount=Dl.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;Sr(function(){xi(null,t,null,null)}),r[Rn]=null}};function ji(t){this._internalRoot=t}ji.prototype.unstable_scheduleHydration=function(t){if(t){var r=du();t={blockedOn:null,target:t,priority:r};for(var i=0;i<qn.length&&r!==0&&r<qn[i].priority;i++);qn.splice(i,0,t),i===0&&mu(t)}};function Ul(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Si(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function If(){}function Oy(t,r,i,c,d){if(d){if(typeof c=="function"){var m=c;c=function(){var V=wi(j);m.call(V)}}var j=Ef(r,c,t,0,null,!1,!1,"",If);return t._reactRootContainer=j,t[Rn]=j.current,$s(t.nodeType===8?t.parentNode:t),Sr(),j}for(;d=t.lastChild;)t.removeChild(d);if(typeof c=="function"){var C=c;c=function(){var V=wi(R);C.call(V)}}var R=Ol(t,0,!1,null,null,!1,!1,"",If);return t._reactRootContainer=R,t[Rn]=R.current,$s(t.nodeType===8?t.parentNode:t),Sr(function(){xi(r,R,i,c)}),R}function bi(t,r,i,c,d){var m=i._reactRootContainer;if(m){var j=m;if(typeof d=="function"){var C=d;d=function(){var R=wi(j);C.call(R)}}xi(r,j,t,d)}else j=Oy(i,r,t,d,c);return wi(j)}cu=function(t){switch(t.tag){case 3:var r=t.stateNode;if(r.current.memoizedState.isDehydrated){var i=vs(r.pendingLanes);i!==0&&(fo(r,i|1),Yt(r,vt()),(Je&6)===0&&(as=vt()+500,er()))}break;case 13:Sr(function(){var c=Ln(t,1);if(c!==null){var d=Dt();xn(c,t,1,d)}}),Bl(t,1)}},ho=function(t){if(t.tag===13){var r=Ln(t,134217728);if(r!==null){var i=Dt();xn(r,t,134217728,i)}Bl(t,134217728)}},uu=function(t){if(t.tag===13){var r=ir(t),i=Ln(t,r);if(i!==null){var c=Dt();xn(i,t,r,c)}Bl(t,r)}},du=function(){return tt},fu=function(t,r){var i=tt;try{return tt=t,r()}finally{tt=i}},st=function(t,r,i){switch(r){case"input":if(we(t,i),r=i.name,i.type==="radio"&&r!=null){for(i=t;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<i.length;r++){var c=i[r];if(c!==t&&c.form===t.form){var d=Ba(c);if(!d)throw Error(a(90));be(c),we(c,d)}}}break;case"textarea":Fe(t,i);break;case"select":r=i.value,r!=null&&We(t,!!i.multiple,r,!1)}},de=$l,Ce=Sr;var By={usingClientEntryPoint:!1,Events:[zs,Gr,Ba,St,Xt,$l]},Js={findFiberByHostInstance:mr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Dy={bundleType:Js.bundleType,version:Js.version,rendererPackageName:Js.rendererPackageName,rendererConfig:Js.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:I.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=kn(t),t===null?null:t.stateNode},findFiberByHostInstance:Js.findFiberByHostInstance||My,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ki=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ki.isDisabled&&ki.supportsFiber)try{ja=ki.inject(Dy),Nn=ki}catch{}}return Jt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=By,Jt.createPortal=function(t,r){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ul(r))throw Error(a(200));return Fy(t,r,null,i)},Jt.createRoot=function(t,r){if(!Ul(t))throw Error(a(299));var i=!1,c="",d=Af;return r!=null&&(r.unstable_strictMode===!0&&(i=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(d=r.onRecoverableError)),r=Ol(t,1,!1,null,null,i,!1,c,d),t[Rn]=r.current,$s(t.nodeType===8?t.parentNode:t),new Dl(r)},Jt.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(a(188)):(t=Object.keys(t).join(","),Error(a(268,t)));return t=kn(r),t=t===null?null:t.stateNode,t},Jt.flushSync=function(t){return Sr(t)},Jt.hydrate=function(t,r,i){if(!Si(r))throw Error(a(200));return bi(null,t,r,!0,i)},Jt.hydrateRoot=function(t,r,i){if(!Ul(t))throw Error(a(405));var c=i!=null&&i.hydratedSources||null,d=!1,m="",j=Af;if(i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(j=i.onRecoverableError)),r=Ef(r,null,t,1,i??null,d,!1,m,j),t[Rn]=r.current,$s(t),c)for(t=0;t<c.length;t++)i=c[t],d=i._getVersion,d=d(i._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[i,d]:r.mutableSourceEagerHydrationData.push(i,d);return new ji(r)},Jt.render=function(t,r,i){if(!Si(r))throw Error(a(200));return bi(null,t,r,!1,i)},Jt.unmountComponentAtNode=function(t){if(!Si(t))throw Error(a(40));return t._reactRootContainer?(Sr(function(){bi(null,null,t,!1,function(){t._reactRootContainer=null,t[Rn]=null})}),!0):!1},Jt.unstable_batchedUpdates=$l,Jt.unstable_renderSubtreeIntoContainer=function(t,r,i,c){if(!Si(i))throw Error(a(200));if(t==null||t._reactInternals===void 0)throw Error(a(38));return bi(t,r,i,!1,c)},Jt.version="18.3.1-next-f1338f8080-20240426",Jt}var Mf;function em(){if(Mf)return Vl.exports;Mf=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(s){console.error(s)}}return e(),Vl.exports=Jy(),Vl.exports}var Of;function Qy(){if(Of)return Ni;Of=1;var e=em();return Ni.createRoot=e.createRoot,Ni.hydrateRoot=e.hydrateRoot,Ni}var Xy=Qy();/**
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 Cc=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,tm=/^[\\/]{2}/;function Zy(e,s){return s+e.replace(/\\/g,"/")}var Bf="popstate";function Df(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function ev(e={}){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 cc("",{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:Rr(l)}return nv(s,a,null,e)}function ut(e,s){if(e===!1||e===null||typeof e>"u")throw new Error(s)}function fn(e,s){if(!e){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function tv(){return Math.random().toString(36).substring(2,10)}function Uf(e,s){return{usr:e.state,key:e.key,idx:s,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function cc(e,s,a=null,o,l){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof s=="string"?hs(s):s,state:a,key:s&&s.key||o||tv(),mask:l}}function Rr({pathname:e="/",search:s="",hash:a=""}){return s&&s!=="?"&&(e+=s.charAt(0)==="?"?s:"?"+s),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function hs(e){let s={};if(e){let a=e.indexOf("#");a>=0&&(s.hash=e.substring(a),e=e.substring(0,a));let o=e.indexOf("?");o>=0&&(s.search=e.substring(o),e=e.substring(0,o)),e&&(s.pathname=e)}return s}function nv(e,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 w(){g="POP";let N=y(),T=N==null?null:N-v;v=N,p&&p({action:g,location:S.location,delta:T})}function x(N,T){g="PUSH";let E=Df(N)?N:cc(S.location,N,T);v=y()+1;let P=Uf(E,v),I=S.createHref(E.mask||E);try{f.pushState(P,"",I)}catch(B){if(B instanceof DOMException&&B.name==="DataCloneError")throw B;l.location.assign(I)}u&&p&&p({action:g,location:S.location,delta:1})}function b(N,T){g="REPLACE";let E=Df(N)?N:cc(S.location,N,T);v=y();let P=Uf(E,v),I=S.createHref(E.mask||E);f.replaceState(P,"",I),u&&p&&p({action:g,location:S.location,delta:0})}function k(N){return rv(l,N)}let S={get action(){return g},get location(){return e(l,f)},listen(N){if(p)throw new Error("A history only accepts one active listener");return l.addEventListener(Bf,w),p=N,()=>{l.removeEventListener(Bf,w),p=null}},createHref(N){return s(l,N)},createURL:k,encodeLocation(N){let T=k(N);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:x,replace:b,go(N){return f.go(N)}};return S}function rv(e,s,a=!1){let o="http://localhost";e&&(o=e.location.origin!=="null"?e.location.origin:e.location.href),ut(o,"No window.location.(origin|href) available to create URL");let l=typeof s=="string"?s:Rr(s);return l=l.replace(/ $/,"%20"),!a&&tm.test(l)&&(l=o+l),new URL(l,o)}function nm(e,s,a="/"){return sv(e,s,a,!1)}function sv(e,s,a,o,l){let u=typeof s=="string"?hs(s):s,f=Dn(u.pathname||"/",a);if(f==null)return null;let g=av(e),p=null,v=gv(f);for(let y=0;p==null&&y<g.length;++y)p=pv(g[y],v,o);return p}function av(e){let s=rm(e);return iv(s),s}function rm(e,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;ut(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let w=wn([o,y.relativePath]),x=a.concat(y);f.children&&f.children.length>0&&(ut(f.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${w}".`),rm(f.children,s,x,w,p)),!(f.path==null&&!f.index)&&s.push({path:w,score:hv(w,f.index),routesMeta:x.map((b,k)=>{let[S,N]=im(b.relativePath,b.caseSensitive,k===x.length-1);return{...b,matcher:S,compiledParams:N}})})};return e.forEach((f,g)=>{var p;if(f.path===""||!((p=f.path)!=null&&p.includes("?")))u(f,g);else for(let v of sm(f.path))u(f,g,!0,v)}),s}function sm(e){let s=e.split("/");if(s.length===0)return[];let[a,...o]=s,l=a.endsWith("?"),u=a.replace(/\?$/,"");if(o.length===0)return l?[u,""]:[u];let f=sm(o.join("/")),g=[];return g.push(...f.map(p=>p===""?u:[u,p].join("/"))),l&&g.push(...f),g.map(p=>e.startsWith("/")&&p===""?"/":p)}function iv(e){e.sort((s,a)=>s.score!==a.score?a.score-s.score:mv(s.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var ov=/^:[\w-]+$/,lv=3,cv=2,uv=1,dv=10,fv=-2,Wf=e=>e==="*";function hv(e,s){let a=e.split("/"),o=a.length;return a.some(Wf)&&(o+=fv),s&&(o+=cv),a.filter(l=>!Wf(l)).reduce((l,u)=>l+(ov.test(u)?lv:u===""?uv:dv),o)}function mv(e,s){return e.length===s.length&&e.slice(0,-1).every((o,l)=>o===s[l])?e[e.length-1]-s[s.length-1]:0}function pv(e,s,a=!1){let{routesMeta:o}=e,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)||"/",w={path:p.relativePath,caseSensitive:p.caseSensitive,end:v},x=p.matcher&&p.compiledParams?am(w,y,p.matcher,p.compiledParams):Fi(w,y),b=p.route;if(!x&&v&&a&&!o[o.length-1].route.index&&(x=Fi({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},y)),!x)return null;Object.assign(l,x.params),f.push({params:l,pathname:wn([u,x.pathname]),pathnameBase:xv(wn([u,x.pathnameBase])),route:b}),x.pathnameBase!=="/"&&(u=wn([u,x.pathnameBase]))}return f}function Fi(e,s){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,o]=im(e.path,e.caseSensitive,e.end);return am(e,s,a,o)}function am(e,s,a,o){let l=s.match(a);if(!l)return null;let u=l[0],f=ds(u,1),g=l.slice(1);return{params:o.reduce((v,{paramName:y,isOptional:w},x)=>{if(y==="*"){let k=g[x]||"";f=ds(u.slice(0,u.length-k.length),1)}const b=g[x];return w&&!b?v[y]=void 0:v[y]=(b||"").replace(/%2F/g,"/"),v},{}),pathname:u,pathnameBase:f,pattern:e}}function im(e,s=!1,a=!0){fn(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(f,g,p,v,y)=>{if(o.push({paramName:g,isOptional:p!=null}),p){let w=y.charAt(v+f.length);return w&&w!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,s?void 0:"i"),o]}function gv(e){try{return e.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return fn(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),e}}function Dn(e,s){if(s==="/")return e;if(!e.toLowerCase().startsWith(s.toLowerCase()))return null;let a=s.endsWith("/")?s.length-1:s.length,o=e.charAt(a);return o&&o!=="/"?null:e.slice(a)||"/"}function yv(e,s="/"){let{pathname:a,search:o="",hash:l=""}=typeof e=="string"?hs(e):e,u;return a?(a=om(a),a.startsWith("/")||a.startsWith("\\")?u=Hf(a.substring(1),"/"):u=Hf(a,s)):u=s,{pathname:u,search:wv(o),hash:jv(l)}}function Hf(e,s){let a=ds(s).split("/");return e.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function ql(e,s,a,o){return`Cannot include a '${e}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function vv(e){return e.filter((s,a)=>a===0||s.route.path&&s.route.path.length>0)}function Ec(e){let s=vv(e);return s.map((a,o)=>o===s.length-1?a.pathname:a.pathnameBase)}function Qi(e,s,a,o=!1){let l;typeof e=="string"?l=hs(e):(l={...e},ut(!l.pathname||!l.pathname.includes("?"),ql("?","pathname","search",l)),ut(!l.pathname||!l.pathname.includes("#"),ql("#","pathname","hash",l)),ut(!l.search||!l.search.includes("#"),ql("#","search","hash",l)));let u=e===""||l.pathname==="",f=u?"/":l.pathname,g;if(f==null)g=a;else{let w=s.length-1;if(!o&&f.startsWith("..")){let x=f.split("/");for(;x[0]==="..";)x.shift(),w-=1;l.pathname=x.join("/")}g=w>=0?s[w]:"/"}let p=yv(l,g),v=f&&f!=="/"&&f.endsWith("/"),y=(u||f===".")&&a.endsWith("/");return!p.pathname.endsWith("/")&&(v||y)&&(p.pathname+="/"),p}var om=e=>e.replace(/[\\/]{2,}/g,"/"),wn=e=>om(e.join("/"));function ds(e,s=0){let a=e.length;for(;a>s&&e.charCodeAt(a-1)===47;)a--;return a===e.length?e:e.slice(0,a)}var xv=e=>ds(e).replace(/^\/*/,"/"),wv=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,jv=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Sv=class{constructor(e,s,a,o=!1){this.status=e,this.statusText=s||"",this.internal=o,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function bv(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function kv(e){let s=e.map(a=>a.route.path).filter(Boolean);return wn(s)||"/"}var lm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function cm(e,s){let a=e;if(typeof a!="string"||!Cc.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,l=!1;if(lm)try{let u=new URL(window.location.href),f=tm.test(a)?new URL(Zy(a,u.protocol)):new URL(a),g=Dn(f.pathname,s);f.origin===u.origin&&g!=null?a=g+f.search+f.hash:l=!0}catch{fn(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:l,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Vf=new URL("http://localhost");function Tc(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),Vf)}catch{return Vf}}function Yl(e,s){return e.origin===s.origin&&(e.origin!=="null"||e.protocol===s.protocol&&e.host===s.host)}function Nv(e,s){if(e.startsWith("//"))return!0;let a=s.protocol.toLowerCase();return e.toLowerCase().startsWith(a)?s.host===""||e.slice(a.length).startsWith("//"):!1}function Ac(e,s,a,o){let l=null;try{l=e==null?null:new URL(e,a)}catch{}let u=new URL(s,a),f=l!=null&&!Yl(l,a),g=!Yl(u,a);if(o==="reject"){if(f||g)throw new Error("External navigation is not allowed")}else if(g&&(l==null||!Nv(e,l)||!Yl(l,u)))throw new Error("External navigation is not allowed")}var um=["POST","PUT","PATCH","DELETE"];new Set(um);var Cv=["GET",...um];new Set(Cv);var Ev=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Tv(e){try{return Ev.includes(new URL(e).protocol)}catch{return!1}}var ms=h.createContext(null);ms.displayName="DataRouter";var Xi=h.createContext(null);Xi.displayName="DataRouterState";var dm=h.createContext(!1);function Av(){return h.useContext(dm)}var fm=h.createContext({isTransitioning:!1});fm.displayName="ViewTransition";var Iv=h.createContext(new Map);Iv.displayName="Fetchers";var Rv=h.createContext(null);Rv.displayName="Await";var rn=h.createContext(null);rn.displayName="Navigation";var fa=h.createContext(null);fa.displayName="Location";var jn=h.createContext({outlet:null,matches:[],isDataRoute:!1});jn.displayName="Route";var Ic=h.createContext(null);Ic.displayName="RouteError";var hm="REACT_ROUTER_ERROR",Pv="REDIRECT",$v="ROUTE_ERROR_RESPONSE";function _v(e){if(e.startsWith(`${hm}:${Pv}:{`))try{let s=JSON.parse(e.slice(28));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string"&&typeof s.location=="string"&&typeof s.reloadDocument=="boolean"&&typeof s.replace=="boolean")return s}catch{}}function Lv(e){if(e.startsWith(`${hm}:${$v}:{`))try{let s=JSON.parse(e.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new Sv(s.status,s.statusText,s.data)}catch{}}function zv(e,{relative:s}={}){ut(ps(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:o}=h.useContext(rn),{hash:l,pathname:u,search:f}=ha(e,{relative:s}),g=u;return a!=="/"&&(g=u==="/"?a:wn([a,u])),o.createHref({pathname:g,search:f,hash:l})}function ps(){return h.useContext(fa)!=null}function Qt(){return ut(ps(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(fa).location}var mm="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function pm(e){h.useContext(rn).static||h.useLayoutEffect(e)}function Sn(){let{isDataRoute:e}=h.useContext(jn);return e?Qv():Fv()}function Fv(){ut(ps(),"useNavigate() may be used only in the context of a <Router> component.");let e=h.useContext(ms),{basename:s,navigator:a}=h.useContext(rn),{matches:o}=h.useContext(jn),{pathname:l}=Qt(),u=JSON.stringify(Ec(o)),f=h.useRef(!1);return pm(()=>{f.current=!0}),h.useCallback((p,v={})=>{if(fn(f.current,mm),!f.current)return;if(typeof p=="number"){a.go(p);return}let y=Qi(p,JSON.parse(u),l,v.relative==="path");e==null&&s!=="/"&&(y.pathname=y.pathname==="/"?s:wn([s,y.pathname])),Ac(typeof p=="string"?p:Rr(p),a.createHref(y),Tc(a),"reject"),(v.replace?a.replace:a.push)(y,v.state,v)},[s,a,u,l,e])}var Mv=h.createContext(null);function Ov(e){let s=h.useContext(jn).outlet;return h.useMemo(()=>s&&h.createElement(Mv.Provider,{value:e},s),[s,e])}function ha(e,{relative:s}={}){let{matches:a}=h.useContext(jn),{pathname:o}=Qt(),l=JSON.stringify(Ec(a));return h.useMemo(()=>Qi(e,JSON.parse(l),o,s==="path"),[e,l,o,s])}function Bv(e,s){return gm(e,s)}function gm(e,s,a){var N;ut(ps(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=h.useContext(rn),{matches:l}=h.useContext(jn),u=l[l.length-1],f=u?u.params:{},g=u?u.pathname:"/",p=u?u.pathnameBase:"/",v=u&&u.route;{let T=v&&v.path||"";vm(g,!v||T.endsWith("*")||T.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${g}" (under <Route path="${T}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
50
+
51
+ Please change the parent <Route path="${T}"> to <Route path="${T==="/"?"*":`${T}/*`}">.`)}let y=Qt(),w;if(s){let T=typeof s=="string"?hs(s):s;ut(p==="/"||((N=T.pathname)==null?void 0:N.startsWith(p)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${T.pathname}" was given in the \`location\` prop.`),w=T}else w=y;let x=w.pathname||"/",b=x;if(p!=="/"){let T=p.replace(/^\//,"").split("/");b="/"+x.replace(/^\//,"").split("/").slice(T.length).join("/")}let k=a&&a.state.matches.length?a.state.matches.map(T=>Object.assign(T,{route:a.manifest[T.route.id]||T.route})):nm(e,{pathname:b});fn(v||k!=null,`No routes matched location "${w.pathname}${w.search}${w.hash}" `),fn(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${w.pathname}${w.search}${w.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=Vv(k&&k.map(T=>Object.assign({},T,{params:Object.assign({},f,T.params),pathname:wn([p,o.encodeLocation?o.encodeLocation(T.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathname]),pathnameBase:T.pathnameBase==="/"?p:wn([p,o.encodeLocation?o.encodeLocation(T.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathnameBase])})),l,a);return s&&S?h.createElement(fa.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...w},navigationType:"POP"}},S):S}function Dv(){let e=Jv(),s=bv(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},f=null;return console.error("Error handled by React Router default ErrorBoundary:",e),f=h.createElement(h.Fragment,null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:u},"ErrorBoundary")," or"," ",h.createElement("code",{style:u},"errorElement")," prop on your route.")),h.createElement(h.Fragment,null,h.createElement("h2",null,"Unexpected Application Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},s),a?h.createElement("pre",{style:l},a):null,f)}var Uv=h.createElement(Dv,null),ym=class extends h.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,s){return s.location!==e.location||s.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:s.error,location:s.location,revalidation:e.revalidation||s.revalidation}}componentDidCatch(e,s){this.props.onError?this.props.onError(e,s):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const a=Lv(e.digest);a&&(e=a)}let s=e!==void 0?h.createElement(jn.Provider,{value:this.props.routeContext},h.createElement(Ic.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?h.createElement(Wv,{error:e},s):s}};ym.contextType=dm;var Jl=new WeakMap;function Wv({children:e,error:s}){let{basename:a,navigator:o}=h.useContext(rn);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let l=_v(s.digest);if(l){let u=Jl.get(s);if(u)throw u;let f=cm(l.location,a),g=f.absoluteURL||f.to;if(Ac(l.location,g,Tc(o),"allow-explicit"),Tv(g))throw new Error("Invalid redirect location");if(lm&&!Jl.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 Jl.set(s,p),p}return h.createElement("meta",{httpEquiv:"refresh",content:`0;url=${g}`})}}return e}function Hv({routeContext:e,match:s,children:a}){let o=h.useContext(ms);return o&&o.static&&o.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=s.route.id),h.createElement(jn.Provider,{value:e},a)}function Vv(e,s=[],a){let o=a==null?void 0:a.state;if(e==null){if(!o)return null;if(o.errors)e=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)e=o.matches;else return null}let l=e,u=o==null?void 0:o.errors;if(u!=null){let y=l.findIndex(w=>w.route.id&&(u==null?void 0:u[w.route.id])!==void 0);ut(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),l=l.slice(0,Math.min(l.length,y+1))}let f=!1,g=-1;if(a&&o){f=o.renderFallback;for(let y=0;y<l.length;y++){let w=l[y];if((w.route.HydrateFallback||w.route.hydrateFallbackElement)&&(g=y),w.route.id){let{loaderData:x,errors:b}=o,k=w.route.loader&&!x.hasOwnProperty(w.route.id)&&(!b||b[w.route.id]===void 0);if(w.route.lazy||k){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,w)=>{var x,b;p(y,{location:o.location,params:((b=(x=o.matches)==null?void 0:x[0])==null?void 0:b.params)??{},pattern:kv(o.matches),errorInfo:w})}:void 0;return l.reduceRight((y,w,x)=>{let b,k=!1,S=null,N=null;o&&(b=u&&w.route.id?u[w.route.id]:void 0,S=w.route.errorElement||Uv,f&&(g<0&&x===0?(vm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,N=null):g===x&&(k=!0,N=w.route.hydrateFallbackElement||null)));let T=s.concat(l.slice(0,x+1)),E=()=>{let P;return b?P=S:k?P=N:w.route.Component?P=h.createElement(w.route.Component,null):w.route.element?P=w.route.element:P=y,h.createElement(Hv,{match:w,routeContext:{outlet:y,matches:T,isDataRoute:o!=null},children:P})};return o&&(w.route.ErrorBoundary||w.route.errorElement||x===0)?h.createElement(ym,{location:o.location,revalidation:o.revalidation,component:S,error:b,children:E(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:v}):E()},null)}function Rc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Gv(e){let s=h.useContext(ms);return ut(s,Rc(e)),s}function Kv(e){let s=h.useContext(Xi);return ut(s,Rc(e)),s}function qv(e){let s=h.useContext(jn);return ut(s,Rc(e)),s}function Pc(e){let s=qv(e),a=s.matches[s.matches.length-1];return ut(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function Yv(){return Pc("useRouteId")}function Jv(){var o;let e=h.useContext(Ic),s=Kv("useRouteError"),a=Pc("useRouteError");return e!==void 0?e:(o=s.errors)==null?void 0:o[a]}function Qv(){let{router:e}=Gv("useNavigate"),s=Pc("useNavigate"),a=h.useRef(!1);return pm(()=>{a.current=!0}),h.useCallback(async(l,u={})=>{fn(a.current,mm),a.current&&(typeof l=="number"?await e.navigate(l):await e.navigate(l,{fromRouteId:s,...u}))},[e,s])}var Gf={};function vm(e,s,a){!s&&!Gf[e]&&(Gf[e]=!0,fn(!1,a))}h.memo(Xv);function Xv({routes:e,manifest:s,future:a,state:o,isStatic:l,onError:u}){return gm(e,void 0,{manifest:s,state:o,isStatic:l,onError:u})}function On({to:e,replace:s,state:a,relative:o}){ut(ps(),"<Navigate> may be used only in the context of a <Router> component.");let{static:l,navigator:u}=h.useContext(rn);fn(!l,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:f}=h.useContext(jn),{pathname:g}=Qt(),p=Sn(),v=Qi(e,Ec(f),g,o==="path");Ac(typeof e=="string"?e:Rr(e),u.createHref(v),Tc(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 Zv(e){return Ov(e.context)}function it(e){ut(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function ex({basename:e="/",children:s=null,location:a,navigationType:o="POP",navigator:l,static:u=!1,useTransitions:f}){ut(!ps(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let g=e.replace(/^\/*/,"/"),p=h.useMemo(()=>({basename:g,navigator:l,static:u,useTransitions:f,future:{}}),[g,l,u,f]);typeof a=="string"&&(a=hs(a));let{pathname:v="/",search:y="",hash:w="",state:x=null,key:b="default",mask:k}=a,S=h.useMemo(()=>{let N=Dn(v,g);return N==null?null:{location:{pathname:N,search:y,hash:w,state:x,key:b,mask:k},navigationType:o}},[g,v,y,w,x,b,o,k]);return fn(S!=null,`<Router basename="${g}"> is not able to match the URL "${v}${y}${w}" because it does not start with the basename, so the <Router> won't render anything.`),S==null?null:h.createElement(rn.Provider,{value:p},h.createElement(fa.Provider,{children:s,value:S}))}function tx({children:e,location:s}){return Bv(uc(e),s)}function uc(e,s=[]){let a=[];return h.Children.forEach(e,(o,l)=>{if(!h.isValidElement(o))return;let u=[...s,l];if(o.type===h.Fragment){a.push.apply(a,uc(o.props.children,u));return}ut(o.type===it,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ut(!o.props.index||!o.props.children,"An index route cannot have child routes.");let f={id:o.props.id||u.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(f.children=uc(o.props.children,u)),a.push(f)}),a}var _i="get",Li="application/x-www-form-urlencoded";function Zi(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function nx(e){return Zi(e)&&e.tagName.toLowerCase()==="button"}function rx(e){return Zi(e)&&e.tagName.toLowerCase()==="form"}function sx(e){return Zi(e)&&e.tagName.toLowerCase()==="input"}function ax(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ix(e,s){return e.button===0&&(!s||s==="_self")&&!ax(e)}function dc(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((s,a)=>{let o=e[a];return s.concat(Array.isArray(o)?o.map(l=>[a,l]):[[a,o]])},[]))}function ox(e,s){let a=dc(e);return s&&s.forEach((o,l)=>{a.has(l)||s.getAll(l).forEach(u=>{a.append(l,u)})}),a}var Ci=null;function lx(){if(Ci===null)try{new FormData(document.createElement("form"),0),Ci=!1}catch{Ci=!0}return Ci}var cx=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ql(e){return e!=null&&!cx.has(e)?(fn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Li}"`),null):e}function ux(e,s){let a,o,l,u,f;if(rx(e)){let g=e.getAttribute("action");o=g?Dn(g,s):null,a=e.getAttribute("method")||_i,l=Ql(e.getAttribute("enctype"))||Li,u=new FormData(e)}else if(nx(e)||sx(e)&&(e.type==="submit"||e.type==="image")){let g=e.form;if(g==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=e.getAttribute("formaction")||g.getAttribute("action");if(o=p?Dn(p,s):null,a=e.getAttribute("formmethod")||g.getAttribute("method")||_i,l=Ql(e.getAttribute("formenctype"))||Ql(g.getAttribute("enctype"))||Li,u=new FormData(g,e),!lx()){let{name:v,type:y,value:w}=e;if(y==="image"){let x=v?`${v}.`:"";u.append(`${x}x`,"0"),u.append(`${x}y`,"0")}else v&&u.append(v,w)}}else{if(Zi(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=_i,o=null,l=Li,f=e}return u&&l==="text/plain"&&(f=u,u=void 0),{action:o,method:a.toLowerCase(),encType:l,formData:u,body:f}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function $c(e,s){if(e===!1||e===null||typeof e>"u")throw new Error(s)}function xm(e,s,a,o){let l=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a?l.pathname.endsWith("/")?l.pathname=`${l.pathname}_.${o}`:l.pathname=`${l.pathname}.${o}`:l.pathname==="/"?l.pathname=`_root.${o}`:s&&Dn(l.pathname,s)==="/"?l.pathname=`${ds(s)}/_root.${o}`:l.pathname=`${ds(l.pathname)}.${o}`,l}async function dx(e,s){if(e.id in s)return s[e.id];try{let a=await import(e.module);return s[e.id]=a,a}catch(a){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function fx(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function hx(e,s,a){let o=await Promise.all(e.map(async l=>{let u=s.routes[l.route.id];if(u){let f=await dx(u,a);return f.links?f.links():[]}return[]}));return yx(o.flat(1).filter(fx).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function Kf(e,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 w;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 x=p.route.shouldRevalidate({currentUrl:new URL(l.pathname+l.search+l.hash,window.origin),currentParams:((w=a[0])==null?void 0:w.params)||{},nextUrl:new URL(e,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function mx(e,s,{includeHydrateFallback:a}={}){return px(e.map(o=>{let l=s.routes[o.route.id];if(!l)return[];let u=[l.module];return l.clientActionModule&&(u=u.concat(l.clientActionModule)),l.clientLoaderModule&&(u=u.concat(l.clientLoaderModule)),a&&l.hydrateFallbackModule&&(u=u.concat(l.hydrateFallbackModule)),l.imports&&(u=u.concat(l.imports)),u}).flat(1))}function px(e){return[...new Set(e)]}function gx(e){let s={},a=Object.keys(e).sort();for(let o of a)s[o]=e[o];return s}function yx(e,s){let a=new Set;return new Set(s),e.reduce((o,l)=>{let u=JSON.stringify(gx(l));return a.has(u)||(a.add(u),o.push({key:u,link:l})),o},[])}function _c(){let e=h.useContext(ms);return $c(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function vx(){let e=h.useContext(Xi);return $c(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Lc=h.createContext(void 0);Lc.displayName="FrameworkContext";function eo(){let e=h.useContext(Lc);return $c(e,"You must render this element inside a <HydratedRouter> element"),e}function xx(e,s){let a=h.useContext(Lc),[o,l]=h.useState(!1),[u,f]=h.useState(!1),{onFocus:g,onBlur:p,onMouseEnter:v,onMouseLeave:y,onTouchStart:w}=s,x=h.useRef(null);h.useEffect(()=>{if(e==="render"&&f(!0),e==="viewport"){let S=T=>{T.forEach(E=>{f(E.isIntersecting)})},N=new IntersectionObserver(S,{threshold:.5});return x.current&&N.observe(x.current),()=>{N.disconnect()}}},[e]),h.useEffect(()=>{if(o){let S=setTimeout(()=>{f(!0)},100);return()=>{clearTimeout(S)}}},[o]);let b=()=>{l(!0)},k=()=>{l(!1),f(!1)};return a?e!=="intent"?[u,x,{}]:[u,x,{onFocus:Zs(g,b),onBlur:Zs(p,k),onMouseEnter:Zs(v,b),onMouseLeave:Zs(y,k),onTouchStart:Zs(w,b)}]:[!1,x,{}]}function Zs(e,s){return a=>{e&&e(a),a.defaultPrevented||s(a)}}function wx({page:e,...s}){let a=Av(),{nonce:o}=eo(),{router:l}=_c(),u=h.useMemo(()=>nm(l.routes,e,l.basename),[l.routes,e,l.basename]);return u?(s.nonce==null&&o&&(s={...s,nonce:o}),a?h.createElement(Sx,{page:e,matches:u,...s}):h.createElement(bx,{page:e,matches:u,...s})):null}function jx(e){let{manifest:s,routeModules:a}=eo(),[o,l]=h.useState([]);return h.useEffect(()=>{let u=!1;return hx(e,s,a).then(f=>{u||l(f)}),()=>{u=!0}},[e,s,a]),o}function Sx({page:e,matches:s,...a}){let o=Qt(),{future:l}=eo(),{basename:u}=_c(),f=h.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let g=xm(e,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,e,o,s]);return h.createElement(h.Fragment,null,f.map(g=>h.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...a})))}function bx({page:e,matches:s,...a}){let o=Qt(),{future:l,manifest:u,routeModules:f}=eo(),{basename:g}=_c(),{loaderData:p,matches:v}=vx(),y=h.useMemo(()=>Kf(e,s,v,u,o,"data"),[e,s,v,u,o]),w=h.useMemo(()=>Kf(e,s,v,u,o,"assets"),[e,s,v,u,o]),x=h.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let S=new Set,N=!1;if(s.forEach(E=>{var I;let P=u.routes[E.route.id];!P||!P.hasLoader||(!y.some(B=>B.route.id===E.route.id)&&E.route.id in p&&((I=f[E.route.id])!=null&&I.shouldRevalidate)||P.hasClientLoader?N=!0:S.add(E.route.id))}),S.size===0)return[];let T=xm(e,g,l.v8_trailingSlashAwareDataRequests,"data");return N&&S.size>0&&T.searchParams.set("_routes",s.filter(E=>S.has(E.route.id)).map(E=>E.route.id).join(",")),[T.pathname+T.search]},[g,l.v8_trailingSlashAwareDataRequests,p,o,u,y,s,e,f]),b=h.useMemo(()=>mx(w,u),[w,u]),k=jx(w);return h.createElement(h.Fragment,null,x.map(S=>h.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...a})),b.map(S=>h.createElement("link",{key:S,rel:"modulepreload",href:S,...a})),k.map(({key:S,link:N})=>h.createElement("link",{key:S,nonce:a.nonce,...N,crossOrigin:N.crossOrigin??a.crossOrigin})))}function kx(...e){return s=>{e.forEach(a=>{typeof a=="function"?a(s):a!=null&&(a.current=s)})}}var Nx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Nx&&(window.__reactRouterVersion="7.18.4")}catch{}function Cx({basename:e,children:s,useTransitions:a,window:o}){let l=h.useRef();l.current==null&&(l.current=ev({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(ex,{basename:e,children:s,location:f.location,navigationType:f.action,navigator:u,useTransitions:a})}var gt=h.forwardRef(function({onClick:s,discover:a="render",prefetch:o="none",relative:l,reloadDocument:u,replace:f,mask:g,state:p,target:v,to:y,preventScrollReset:w,viewTransition:x,defaultShouldRevalidate:b,...k},S){let{basename:N,navigator:T,useTransitions:E}=h.useContext(rn),P=typeof y=="string"&&Cc.test(y),I=cm(y,N);y=I.to;let B=zv(y,{relative:l}),M=Qt(),q=null;if(g){let ee=Qi(g,[],M.mask?M.mask.pathname:"/",!0);N!=="/"&&(ee.pathname=ee.pathname==="/"?N:wn([N,ee.pathname])),q=T.createHref(ee)}let[z,U,Z]=xx(o,k),G=Ax(y,{replace:f,mask:g,state:p,target:v,preventScrollReset:w,relative:l,viewTransition:x,defaultShouldRevalidate:b,useTransitions:E});function O(ee){s&&s(ee),ee.defaultPrevented||G(ee)}let ne=!(I.isExternal||u),fe=h.createElement("a",{...k,...Z,href:(ne?q:void 0)||I.absoluteURL||B,onClick:ne?O:s,ref:kx(S,U),target:v,"data-discover":!P&&a==="render"?"true":void 0});return z&&!P?h.createElement(h.Fragment,null,fe,h.createElement(wx,{page:B})):fe});gt.displayName="Link";var zc=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 w=ha(f,{relative:v.relative}),x=Qt(),b=h.useContext(Xi),{navigator:k,basename:S}=h.useContext(rn),N=b!=null&&_x(w)&&g===!0,T=k.encodeLocation?k.encodeLocation(w).pathname:w.pathname,E=x.pathname,P=b&&b.navigation&&b.navigation.location?b.navigation.location.pathname:null;a||(E=E.toLowerCase(),P=P?P.toLowerCase():null,T=T.toLowerCase()),P&&S&&(P=Dn(P,S)||P);const I=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let B=E===T||!l&&E.startsWith(T)&&E.charAt(I)==="/",M=P!=null&&(P===T||!l&&P.startsWith(T)&&P.charAt(T.length)==="/"),q={isActive:B,isPending:M,isTransitioning:N},z=B?s:void 0,U;typeof o=="function"?U=o(q):U=[o,B?"active":null,M?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let Z=typeof u=="function"?u(q):u;return h.createElement(gt,{...v,"aria-current":z,className:U,ref:y,style:Z,to:f,viewTransition:g},typeof p=="function"?p(q):p)});zc.displayName="NavLink";var Ex=h.forwardRef(({discover:e="render",fetcherKey:s,navigate:a,reloadDocument:o,replace:l,state:u,method:f=_i,action:g,onSubmit:p,relative:v,preventScrollReset:y,viewTransition:w,defaultShouldRevalidate:x,...b},k)=>{let{useTransitions:S}=h.useContext(rn),N=Px(),T=$x(g,{relative:v}),E=f.toLowerCase()==="get"?"get":"post",P=typeof g=="string"&&Cc.test(g),I=B=>{if(p&&p(B),B.defaultPrevented)return;B.preventDefault();let M=B.nativeEvent.submitter,q=(M==null?void 0:M.getAttribute("formmethod"))||f,z=()=>N(M||B.currentTarget,{fetcherKey:s,method:q,navigate:a,replace:l,state:u,relative:v,preventScrollReset:y,viewTransition:w,defaultShouldRevalidate:x});S&&a!==!1?h.startTransition(()=>z()):z()};return h.createElement("form",{ref:k,method:E,action:T,onSubmit:o?p:I,...b,"data-discover":!P&&e==="render"?"true":void 0})});Ex.displayName="Form";function Tx(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function wm(e){let s=h.useContext(ms);return ut(s,Tx(e)),s}function Ax(e,{target:s,replace:a,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:g,defaultShouldRevalidate:p,useTransitions:v}={}){let y=Sn(),w=Qt(),x=ha(e,{relative:f});return h.useCallback(b=>{if(ix(b,s)){b.preventDefault();let k=a!==void 0?a:Rr(w)===Rr(x),S=()=>y(e,{replace:k,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:g,defaultShouldRevalidate:p});v?h.startTransition(()=>S()):S()}},[w,y,x,a,o,l,s,e,u,f,g,p,v])}function gs(e){fn(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let s=h.useRef(dc(e)),a=h.useRef(!1),o=Qt(),l=h.useMemo(()=>ox(o.search,a.current?null:s.current),[o.search]),u=Sn(),f=h.useCallback((g,p)=>{const v=dc(typeof g=="function"?g(new URLSearchParams(l)):g);a.current=!0,u("?"+v,p)},[u,l]);return[l,f]}var Ix=0,Rx=()=>`__${String(++Ix)}__`;function Px(){let{router:e}=wm("useSubmit"),{basename:s}=h.useContext(rn),a=Yv(),o=e.fetch,l=e.navigate;return h.useCallback(async(u,f={})=>{let{action:g,method:p,encType:v,formData:y,body:w}=ux(u,s);if(f.navigate===!1){let x=f.fetcherKey||Rx();await o(x,a,f.action||g,{defaultShouldRevalidate:f.defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:w,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:w,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 $x(e,{relative:s}={}){let{basename:a}=h.useContext(rn),o=h.useContext(jn);ut(o,"useFormAction must be used inside a RouteContext");let[l]=o.matches.slice(-1),u={...ha(e||".",{relative:s})},f=Qt();if(e==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(w=>w).forEach(w=>g.append("index",w));let y=g.toString();u.search=y?`?${y}`:""}}return(!e||e===".")&&l.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(u.pathname=u.pathname==="/"?a:wn([a,u.pathname])),Rr(u)}function _x(e,{relative:s}={}){let a=h.useContext(fm);ut(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=wm("useViewTransitionState"),l=ha(e,{relative:s});if(!a.isTransitioning)return!1;let u=Dn(a.currentLocation.pathname,o)||a.currentLocation.pathname,f=Dn(a.nextLocation.pathname,o)||a.nextLocation.pathname;return Fi(l.pathname,f)!=null||Fi(l.pathname,u)!=null}var Lx=em();const Ar="owner";function zx(e){const s=e||Ar;return s===Ar?[Ar]:[s,Ar]}function Fx(e){const s=new Map;for(const a of e)for(const o of a)s.has(o.id)||s.set(o.id,o);return[...s.values()].sort((a,o)=>o.createdAt-a.createdAt)}function Mx(e,s){const a=s||Ar,o=(e==null?void 0:e.pendingDomains)??[];return o.includes(a)?a:o.includes(Ar)?Ar:a}class jm extends Error{constructor(a){super("different_account");Qs(this,"summary");this.name="DifferentAccountError",this.summary=a}}function Sm(e){return e.grantors??e.approvers}function Ox(e){return e.approvals??1}function Ge(e,s){const a=e??{},o=Array.isArray(a.errors)?a.errors[0]:void 0;return o!=null&&o.message?o.code?`${o.message} (${o.code})`:o.message:o!=null&&o.code?o.code:a.error||a.detail||s}function Bx(e){const s=e==null?void 0:e.pubkeys;return!s||typeof s!="object"||Array.isArray(s)?[]:Object.entries(s).filter(a=>typeof a[1]=="string"&&a[1].length>0).map(([a,o])=>({userId:a,publicKey:o}))}class Dx{constructor(){Qs(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 jm(u.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!o.ok){const u=await o.json().catch(()=>({error:"Invalid API key"}));throw new Error(Ge(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(Ge(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(Ge(a,`Export failed (${s.status})`));const o=((l=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??""))==null?void 0:l[1])??"suveren-evidence.json";return{bundle:a,filename:o}}async getLocalAuthorizations(){const s=await this.fetch("/api/evidence/authorizations");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const a=await s.json();return{authorizations:a.authorizations??{},signatures:a.signatures??{}}}async getArchivedReceipt(s){const a=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}`);if(a.status===404)return null;if(!a.ok)throw new Error(`Local evidence unavailable (${a.status})`);return await a.json()}async getTicketHeadlines(){const s=await this.fetch("/api/evidence/headlines");if(!s.ok)throw new Error(`Local evidence unavailable (${s.status})`);const a=await s.json();return(a==null?void 0:a.headlines)??{}}async getReport(){const s=await this.fetch("/api/report");if(!s.ok){const a=await s.json().catch(()=>({error:`Report unavailable (${s.status})`}));throw new Error(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(o,`Leave failed: ${a.status}`))}}async getVaultStatus(){const s=await this.fetch("/vault/status");if(!s.ok)throw new Error(`Failed to fetch vault status: ${s.status}`);return s.json()}async getGatewaySettings(){const s=await this.fetch("/api/gateway-settings");if(!s.ok)throw new Error(`Failed to load settings: ${s.status}`);return s.json()}async setGatewaySettings(s){const a=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error(`Failed to save settings: ${a.status}`);return a.json()}async getArchivedMandates(){const s=await this.fetch("/api/archived-mandates");if(!s.ok)throw new Error(`Failed to load archived mandates: ${s.status}`);return(await s.json()).archived}async setMandateArchived(s,a){const o=await this.fetch(`/api/archived-mandates/${encodeURIComponent(s)}`,{method:a?"PUT":"DELETE"});if(!o.ok)throw new Error(`Failed to ${a?"archive":"unarchive"} mandate: ${o.status}`);return(await o.json()).archived}async getLastSeenBlockedAt(){const s=await this.fetch("/api/blocked-seen");if(!s.ok)throw new Error(`Failed to load last-seen: ${s.status}`);return(await s.json()).lastSeenBlockedAt}async markBlockedSeen(s=Date.now()){const a=await this.fetch("/api/blocked-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark blocked seen: ${a.status}`);return(await a.json()).lastSeenBlockedAt}async getLastSeenReportAt(){const s=await this.fetch("/api/report-seen");if(!s.ok)throw new Error(`Failed to load last-seen report: ${s.status}`);return(await s.json()).lastSeenReportAt}async markReportSeen(s=Date.now()){const a=await this.fetch("/api/report-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark report seen: ${a.status}`);return(await a.json()).lastSeenReportAt}async getLastSeenTicketsAt(){const s=await this.fetch("/api/tickets-seen");if(!s.ok)throw new Error(`Failed to load last-seen tickets: ${s.status}`);return(await s.json()).lastSeenTicketsAt}async markTicketsSeen(s=Date.now()){const a=await this.fetch("/api/tickets-seen",{method:"POST",body:JSON.stringify({ts:s})});if(!a.ok)throw new Error(`Failed to mark tickets seen: ${a.status}`);return(await a.json()).lastSeenTicketsAt}async getCredential(s){const a=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to check credential: ${a.status}`);return a.json()}async setCredential(s,a){const o=await this.fetch(`/vault/credentials/${encodeURIComponent(s)}`,{method:"PUT",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to save credential: ${o.status}`)}async testCredential(s){const a=await this.fetch(`/vault/test/${encodeURIComponent(s)}`,{method:"POST"});if(!a.ok)throw new Error(`Test failed: ${a.status}`);return a.json()}async aiAssist(s){const a=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"AI request failed"}));return{success:!1,error:Ge(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:Ge(o,"AI request failed")}}return a.json()}async aiTest(s){const a=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`AI test failed: ${a.status}`);return a.json()}async aiModels(s){const a=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(s??{})});if(!a.ok)throw new Error(`Model list failed: ${a.status}`);return a.json()}async getMcpHealth(){const s=await this.fetch("/mcp/health");if(!s.ok)throw new Error(`MCP server unreachable: ${s.status}`);return s.json()}async getAgentContact(){const s=await this.fetch("/mcp/agent-contact");if(!s.ok)throw new Error(`Failed to fetch agent contact: ${s.status}`);return s.json()}async getMcpIntegrations(){const s=await this.fetch("/mcp/integrations");if(!s.ok)throw new Error(`Failed to fetch integrations: ${s.status}`);return s.json()}async getOAuthHealth(s){try{const a=await this.fetch(`/auth/oauth/${encodeURIComponent(s)}/health`);return a.ok?await a.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const s=await this.fetch("/mcp/integrations/manifests");if(!s.ok)throw new Error(`Failed to fetch manifests: ${s.status}`);return s.json()}async getLabelManifests(){const{manifests:s,builtins:a}=await this.getIntegrationManifests();return[...s??[],...a??[]]}async discoverScopeField(s,a){const o=await this.fetch(`/integrations/${encodeURIComponent(s)}/discover/${encodeURIComponent(a)}`);if(!o.ok){const l=await o.json().catch(()=>({error:`Discovery failed: ${o.status}`}));throw new Error(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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?Bx(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(Ge(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(zx(s).map(l=>this.getProposals(l,a)));return Fx(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 w=await y.json().catch(()=>({error:"Failed"}));throw new Error(Ge(w,`Failed: ${y.status}`))}return y.json()}async getProposal(s){const a=await this.fetch(`/api/proposals/${encodeURIComponent(s)}`);if(!a.ok){const l=await a.json().catch(()=>({error:"Failed"}));throw new Error(Ge(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(Ge(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(Ge(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(Ge(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 getProposalAttachmentPreview(s,a){const o=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/attachment-preview/${encodeURIComponent(a)}`);if(!o.ok)throw new Error(`Failed to fetch attachment preview: ${o.status}`);return o.json()}async getReceiptAttachmentPreview(s,a){const o=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}/attachment-preview/${encodeURIComponent(a)}`);if(!o.ok)throw new Error(`Failed to fetch attachment preview: ${o.status}`);return o.json()}async getAttestationIntent(s){const a=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/intent`);return a.status===404||a.status===403||!a.ok?null:a.json()}async decryptIntent(s){const a=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const l=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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(Ge(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:Ge(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(Ge(l,`Save failed: ${o.status}`))}}}const L=new Dx,bm=h.createContext(null);function Ux({children:e}){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),[w,x]=h.useState(null),[b,k]=h.useState(null),[S,N]=h.useState(!1),[T,E]=h.useState(""),P=h.useRef(!1),I=h.useRef(null),B=h.useCallback(async()=>{if(P.current)try{const G=await L.getMyTeam();if(k(G.pendingRequest),G.group&&G.membership){const{group:O,membership:ne}=G;y(O),x(ne),l("team"),f(O);const fe=I.current??ne.domains[0]??"owner";p(fe)}else y(null),x(null),l("personal")}catch{}},[]);h.useEffect(()=>{const G=()=>{document.visibilityState==="visible"&&B()};return document.addEventListener("visibilitychange",G),()=>document.removeEventListener("visibilitychange",G)},[B]),h.useEffect(()=>{fetch("/health").then(G=>G.json()).then(G=>{var O;((O=G.session)==null?void 0:O.lockedReason)==="as-url-changed"&&E(`Authority Server changed to ${G.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const M=h.useCallback(async(G,O={})=>{N(!0),E("");try{L.setApiKey(G),P.current=!0;const ne=await L.login(G,O);a(ne),I.current=ne.id;const fe=await L.getGroups(),ee=fe.find(pe=>pe.isPersonal)??fe[0]??null;f(ee),p("owner"),await B()}catch(ne){throw L.clearApiKey(),P.current=!1,E(ne instanceof Error?ne.message:"Login failed"),ne}finally{N(!1)}},[B]),q=h.useCallback(async()=>{await L.logout(),L.clearApiKey(),P.current=!1,I.current=null,a(null),f(null),p(""),y(null),x(null),k(null),l("personal"),E("")},[]),z=h.useCallback(G=>{L.clearApiKey(),P.current=!1,I.current=null,a(null),f(null),p(""),y(null),x(null),k(null),l("personal"),E(G??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),U=h.useCallback(()=>E(""),[]),Z=h.useCallback((G,O)=>{f(G),p(O)},[]);return n.jsx(bm.Provider,{value:{user:s,mode:o,group:u,domain:g,groupId:(u==null?void 0:u.id)??null,activeTeam:v,activeMembership:w,pendingRequest:b,isLoading:S,error:T,login:M,logout:q,clearError:U,handleSessionLocked:z,activeGroup:u,activeDomain:g,groups:u?[u]:[],setActiveContext:Z,refreshGroups:B},children:e})}function wt(){const e=h.useContext(bm);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Wx={"integration-changed":!0,"attestation-changed":!0,"proposal-added":!0,"proposal-resolved":!0,"team-membership-changed":!0,"action-approval-needed":!0,"action-resolved":!0,"proposal-approved":!0,"proposal-rejected":!0,"session-locked":!0,"execution-failed":!0,"denial-recorded":!0,"ticket-recorded":!0,"report-written":!0},Hx=Object.keys(Wx),km=h.createContext(null);function Vx({children:e}){const{user:s}=wt(),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=L.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 Hx)p.addEventListener(v,y=>{let w;try{w=JSON.parse(y.data)}catch{w=null}const x=u.current.get(v);if(x)for(const b of x)try{b(w)}catch(k){console.error(`[EventSource] handler for "${v}" threw:`,k)}});return()=>{p.close(),a.current=null,l(!1)}},[s]),n.jsx(km.Provider,{value:{connected:o,addListener:f},children:e})}function Me(e,s){const a=h.useContext(km);if(!a)return;const{addListener:o}=a;h.useEffect(()=>o(e,s),[e,s,o])}const ia="suveren-theme",qf="hap-theme";function Ei(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(qf);s!==null&&localStorage.getItem(ia)===null&&localStorage.setItem(ia,s),s!==null&&localStorage.removeItem(qf)})();function Nm(){const[e,s]=h.useState(()=>{const u=localStorage.getItem(ia);return u==="light"||u==="dark"?u:"system"}),[a,o]=h.useState(()=>Ei(e));h.useEffect(()=>{const u=document.documentElement,f=Ei(e);u.setAttribute("data-theme",f),e==="system"?localStorage.removeItem(ia):localStorage.setItem(ia,e),o(Ei(e))},[e]),h.useEffect(()=>{if(e!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),f=()=>o(Ei("system"));return u.addEventListener("change",f),()=>u.removeEventListener("change",f)},[e]);const l=h.useCallback(()=>{s(u=>u==="system"?"light":u==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:a,toggle:l}}const Gx=300*1e3,Kx=2e3;function Fc(){const[e,s]=h.useState(!1),[a,o]=h.useState("docker"),[l,u]=h.useState(""),[f,g]=h.useState(null),[p,v]=h.useState(!1),[y,w]=h.useState(!1),[x,b]=h.useState(!1),k=h.useRef(null);return h.useEffect(()=>{let S=!1;const N=(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),k.current===null?k.current=I.version:I.version!==k.current&&I.version!=="dev"&&v(!0)))}).catch(()=>{})};N(!0);const T=setInterval(()=>N(!1),x?Kx:Gx),E=()=>{document.visibilityState==="visible"&&N(!1)};return document.addEventListener("visibilitychange",E),window.addEventListener("focus",E),()=>{S=!0,clearInterval(T),document.removeEventListener("visibilitychange",E),window.removeEventListener("focus",E)}},[x]),{updateAvailable:e&&!y,installMethod:a,version:l,latestVersion:f,serverRestarted:p,startFastPolling:()=>b(!0),dismiss:()=>w(!0)}}function qx(e){return!e||typeof e!="object"?{managed:!1}:{managed:Array.isArray(e.policyLocked)&&e.policyLocked.includes("team")}}function Yx(){const[e,s]=h.useState({managed:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(qx(o))}).catch(()=>{}),()=>{a=!0}},[]),e}function Jx({size:e=20}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),n.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function Qx(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Yf={system:"◑",light:"☀",dark:"☾"};function Mc({onMenuToggle:e}){const{user:s,logout:a,mode:o,activeTeam:l}=wt(),{theme:u,toggle:f}=Nm(),{version:g,updateAvailable:p,latestVersion:v}=Fc(),{managed:y}=Yx(),w=Qx(g),x=o==="team"&&l?`Team ${l.name}`:"Personal";return n.jsx("nav",{className:"top-nav",children:n.jsxs("div",{className:"top-nav-inner",children:[n.jsxs("div",{className:"logo-group",children:[n.jsx(Jx,{size:20}),n.jsx("span",{className:"logo",children:"Suveren"}),n.jsx("span",{className:"version-badge",children:"Local Gateway"}),w&&n.jsxs("span",{className:"gw-version",title:p&&v?`Running v${w} — v${v} is available`:"Running gateway version","data-stale":p?"true":void 0,children:["v",w,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?`${x} — set by your IT`:x,children:[x,y&&n.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),n.jsx("span",{className:"user-chip",children:n.jsx("strong",{children:s.name})}),n.jsx("button",{className:"theme-toggle",onClick:f,title:`Theme: ${u}`,children:Yf[u]}),n.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):n.jsx("button",{className:"theme-toggle",onClick:f,title:`Theme: ${u}`,children:Yf[u]})}),s&&e&&n.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function Oc(e,s){var a;if((a=s==null?void 0:s.revokedSet)!=null&&a.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function Cm(e){return e==="expired"||e==="revoked"}function Em(e,s){var a;return!!((a=s==null?void 0:s.archivedSet)!=null&&a.has(e.authorization_id))&&Cm(Oc(e,s))}function Mi(e,s){return Em(e,s)?"archived":Oc(e,s)}function Tm(e,s){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of e)a[Mi(o,s)].push(o);return a}function Xx(e,s){return s==="expired"?e.earliest_expiry?{iso:e.earliest_expiry,meaning:"expired"}:null:e.created_at?{iso:e.created_at,meaning:"created"}:null}function Ft(e,s,a){const o=h.useRef(e);o.current=e,h.useEffect(()=>{let l=null;const u=()=>typeof document>"u"?!0:document.visibilityState==="visible",f=()=>{u()&&o.current()},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 Bc(){const[e,s]=h.useState(!1);return h.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(f=>f.json()).then(f=>{a||s(f.simulation===!0)}).catch(()=>{})};o();const l=setInterval(o,3e4),u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}function Zx(e,s){const a=e.simulation;return a?(((s==null?void 0:s[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function ca(e){return!!(e!=null&&e.simulation)}const Am=h.createContext(null),e0=3e4,t0=5e3,n0=3e5;function r0(e,s,a){return s===0?"loading":e!=null&&e.running?"running":e!=null&&e.paused?"paused":e!=null&&e.error?"error":e&&a?"starting":"not-running"}function s0({children:e}){const[s,a]=h.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),o=h.useRef(null),l=h.useCallback(async()=>{let y=!1;const[w,x]=await Promise.all([L.getIntegrationManifests().catch(()=>(y=!0,{manifests:[]})),L.getMcpHealth().catch(()=>null)]);a(k=>({...k,manifests:w.manifests,integrations:(x==null?void 0:x.integrations)??k.integrations,activeSessions:(x==null?void 0:x.activeSessions)??k.activeSessions,mcpServerUp:!!x,manifestsError:y,fetchCount:k.fetchCount+1}));const b=w.manifests.filter(k=>k.oauth);if(b.length>0){const k=await Promise.all(b.map(async S=>[S.id,await L.getOAuthHealth(S.id)]));a(S=>({...S,authHealth:Object.fromEntries(k)}))}},[]),u=s.fetchCount>0&&s.manifests.some(y=>{const w=s.integrations.find(x=>x.id===y.id);return w&&!w.running&&!w.paused});Me("integration-changed",l),Ft(l,u?t0:n0);const f=h.useMemo(()=>{const y=new Map(s.integrations.map(b=>[b.id,b])),w=Date.now();u&&o.current===null?o.current=w:u||(o.current=null);const x=o.current!==null&&w-o.current<e0;return s.manifests.map(b=>{const k=y.get(b.id),S=r0(k,s.fetchCount,x),N=s.authHealth[b.id];return{id:b.id,manifest:b,integration:k,state:S,authStatus:N==null?void 0:N.status,authAccount:N==null?void 0:N.account,authError:N==null?void 0:N.error}})},[s,u]),g=Bc(),p=h.useMemo(()=>f.filter(y=>!(g&&!ca(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(Am.Provider,{value:v,children:e})}function Dc(){const e=h.useContext(Am);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const a0={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Uc=e=>a0[e]??e,i0={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 o0(e){return(e&&i0[e])??{chip:"Blocked",sev:"info"}}function l0(e){const s=Uc(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?n.jsxs(n.Fragment,{children:["Tried to read your ",n.jsx("b",{children:e.target??"restricted"})," calendar"]}):n.jsxs(n.Fragment,{children:["Tried to read a restricted location in ",s]});case"spam":return n.jsxs(n.Fragment,{children:["Tried to open a message in ",n.jsx("b",{children:"spam or trash"})]});case"age":return n.jsxs(n.Fragment,{children:["Tried to read ",s," older than your read window"]});case"unset_age":return n.jsxs(n.Fragment,{children:["Your ",s," has ",n.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return n.jsxs(n.Fragment,{children:["Read access isn't granted on your ",s," mandate"]});case"ungoverned":return n.jsxs(n.Fragment,{children:["A ",s," tool isn't configured for safe reading"]});case"query_unsafe":return n.jsx(n.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return n.jsx(n.Fragment,{children:e.detail})}}function Im(e,s){const a=Math.max(0,(s-e)/1e3);if(a<60)return"Just now";if(a<3600)return`${Math.floor(a/60)} min ago`;if(a<86400)return`${Math.floor(a/3600)} hr ago`;const o=Math.floor(a/86400);return o===1?"Yesterday":`${o} days ago`}const c0=5,u0=1440*60*1e3,d0=7;function f0(e,s){const a=s-d0*u0;return{recent:e.filter(o=>o.ts>=a),all:e}}function h0(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(()=>{L.getDenials({limit:200}).then(({records:w})=>{s(w),o(!1)}).catch(()=>o(!0)),L.getLastSeenBlockedAt().then(u).catch(()=>u(0))},[]);if(h.useEffect(()=>{f()},[f]),Ft(f,12e4),Me("denial-recorded",f),h.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",f),()=>window.removeEventListener("suveren:blocked-seen-changed",f)),[f]),a||e===null||l===null)return null;const{all:g}=f0(e,Date.now()),p=g.filter(w=>w.ts>l);if(p.length===0)return null;const v=p.slice(0,c0),y=(w,x)=>{const b=o0(w.reason);return n.jsxs("div",{className:"rb-row",children:[n.jsx("span",{className:`rb-dot ${b.sev==="act"?"act":b.sev==="info"?"info":""}`,"aria-hidden":"true"}),n.jsxs("div",{className:"rb-body",children:[n.jsx("div",{className:"rb-line",children:l0(w)}),n.jsxs("div",{className:"rb-meta",children:[n.jsx("span",{className:`rb-chip ${b.sev==="act"?"act":b.sev==="warn"?"warn":""}`,children:b.chip}),n.jsx("span",{className:"rb-via",children:Uc(w.integrationId)})]}),b.fixTo&&n.jsx(gt,{className:"rb-fix",to:b.fixTo,children:"Set a read window →"})]}),n.jsx("div",{className:"rb-when",children:Im(w.ts,Date.now())})]},`${w.ts}-${x}`)};return n.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[n.jsxs("div",{className:"card-header",children:[n.jsx("h2",{className:"card-title",children:"Recent blocks"}),n.jsx("span",{className:"rb-count",children:p.length})]}),n.jsx("p",{className:"rb-sub",children:"New since you last looked. Limits you set that stopped your agent — the gateway doing its job."}),n.jsx("div",{className:"rb-rows",children:v.map(y)}),n.jsxs(gt,{className:"col-btn",to:"/blocked",children:["View all ",g.length," blocks from the last 30 days ›"]})]})}function to(e){return e.kind??"read"}function m0(e,s){var u,f,g,p;if(!s)return"";if(!e)return s;const a=(f=(u=e.scopeSchema)==null?void 0:u.fields)==null?void 0:f[s];if(a!=null&&a.displayName)return a.displayName;const o=((g=e.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 p0={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"},g0={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 Jf(e){return e===void 0?"":typeof e=="number"?e.toLocaleString():e}function y0(e,s){const a=to(e),o=Jf(e.value),l=Jf(e.limit);switch(a){case"bound":return o&&l?`${s||"Value"} ${o} is above the limit ${l}.`:e.detail;case"scope":return o?`${s||"Value"} "${o}" is not within your mandate's allowed ${s||"scope"}.`:e.detail;case"cumulative":return o&&l?`${o} of ${l} used — the limit is reached.`:e.detail;case"simulation":return"Real systems are switched off while the gateway runs in simulation mode.";case"not_authorized":return"No mandate currently covers this action.";case"read":default:return e.detail}}function Rm(e,s){if(e.mandateId){const a=s==null?void 0:s[e.mandateId];if(a)return a}return e.mandateTitle}function v0(e,s){const a=Rm(e,s);if(a){const o=[{text:` · mandate "${a}"`}];return e.mandateId&&o.push({text:` (${e.mandateId.slice(0,14)}…)`,dim:!0}),o}return e.mandateId?[{text:` · mandate ${e.mandateId.slice(0,14)}…`}]:[]}function x0(e,s){const a=to(e),o=Uc(e.integrationId),l=e.who==="authority-server"?"refused by the Authority Server":a==="read"?"refused by this gateway":"refused by this gateway, before anything ran",u=e.code?` (${e.code})`:"";return[{text:`${o} · ${e.tool}`},...v0(e,s),{text:` · ${l}${u}`}]}function w0(e,s,a){const o=to(e),l=m0(s,e.field);return{title:p0[o],sentence:y0(e,l),sourceLine:x0(e,a),whatYouCanDo:g0[o]}}function j0(e,s){const a=new Date(s);return a.setHours(0,0,0,0),e.filter(o=>o.ts>=a.getTime()).length}function S0(e,s){return e.filter(a=>a.ts>s).length}const b0=1440*60*1e3;function k0(e,s){const a=new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),o=new Date(s);o.setHours(0,0,0,0);const l=o.getTime();return e>=l?`Today · ${a}`:e>=l-b0?`Yesterday · ${a}`:`${new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})} · ${a}`}function Pm(e,s){return!!e&&e.savedAt*1e3>s}function N0(e){const s=/<h[1-3][^>]*>([\s\S]*?)<\/h[1-3]>/i.exec(e),a=s?s[1].replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/\s+/g," ").trim():"";return a?a.length>80?`${a.slice(0,79)}…`:a:"Report"}function C0(e){var s,a;return{verified:((a=(s=e.proof)==null?void 0:s.verifiedValues)==null?void 0:a.length)??0,unchecked:(e.elements??[]).filter(o=>o.status==="unverifiable").length}}const Qf=(e,s)=>new Date(e*1e3).toLocaleString(s,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),Xf=(e,s)=>new Date(e*1e3).toLocaleString(s,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});function Oi(e,s){const a=e==null?void 0:e.window;return a?{text:`Covers ${Qf(a.start,s)} → ${Qf(a.end,s)} (${a.days} day${a.days===1?"":"s"})`,title:`From ${Xf(a.start,s)} to ${Xf(a.end,s)}. Tickets up to 2 minutes after the end count, for small clock differences.`}:{text:"Period not recorded"}}function $m(e,s,a){const o=new Date(e*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"}),u=Math.floor((s-e*1e3)/864e5);if(new Date(s).toDateString()===o.toDateString())return`today ${l}`;const g=`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`;return u>=2?`${g} (${u} days ago)`:g}const E0=[{to:"/",icon:"□",label:"Dashboard",group:"top"},{to:"/approvals",icon:"▷",iconClass:"nav-ic-approval",label:"Approvals",statusKey:"proposals",group:"core"},{to:"/mandates",icon:"☰",iconClass:"nav-ic-mandate",label:"Mandates",statusKey:"authorizations",group:"core",quietCount:!0},{to:"/tickets",icon:"▣",iconClass:"nav-ic-ticket",label:"Tickets",group:"core"},{to:"/reports",icon:"▥",label:"Reports",statusKey:"report",newLabel:!0,group:"core"},{to:"/blocked",icon:"⊘",iconClass:"nav-ic-blocked",label:"Blocked",statusKey:"blocked",group:"core"},{to:"/team",icon:"◉",label:"Team",teamOnly:!0,group:"setup"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief",group:"setup"},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations",group:"setup"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant",group:"setup"}];function T0(){const{activeDomain:e}=wt(),[s,a]=h.useState({}),o=h.useCallback(async()=>{try{const[l,u,f,g,p,v,y,w,x,b]=await Promise.all([L.getCredential("ai-config").catch(()=>null),L.getMyAttestations().catch(()=>null),L.getMyProposals(e).catch(()=>null),L.getProposalsForApprover().catch(()=>null),L.getAgentContext().catch(()=>""),L.getArchivedMandates().catch(()=>[]),L.getDenials({limit:200}).catch(()=>null),L.getLastSeenBlockedAt().catch(()=>0),L.getReport().catch(()=>null),L.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]),k={};if(l&&!l.configured&&(k.assistant=1),u){const E=Tm(u,{archivedSet:new Set(v)}).expired.length;E>0&&(k.authorizations=E)}const S=(f==null?void 0:f.length)??0,N=(g==null?void 0:g.length)??0,T=S+N;if(T>0&&(k.proposals=T),(!p||!p.trim())&&(k.brief=1),y){const E=S0(y.records,w);E>0&&(k.blocked=E)}Pm(x==null?void 0:x.report,b)&&(k.report=1),a(k)}catch{}},[e]);return Me("attestation-changed",o),Me("proposal-added",o),Me("proposal-resolved",o),Me("proposal-approved",o),Me("proposal-rejected",o),Me("team-membership-changed",o),Me("denial-recorded",o),Me("report-written",o),h.useEffect(()=>(window.addEventListener("suveren:archived-changed",o),()=>window.removeEventListener("suveren:archived-changed",o)),[o]),h.useEffect(()=>(window.addEventListener("suveren:blocked-seen-changed",o),window.addEventListener("suveren:report-seen-changed",o),()=>{window.removeEventListener("suveren:blocked-seen-changed",o),window.removeEventListener("suveren:report-seen-changed",o)}),[o]),Ft(o,3e5,e),s}const A0={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},I0={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 R0(){const{mode:e,activeTeam:s}=wt(),a=T0(),{attentionCount:o}=Dc(),l={...a};o>0&&(l.integrations=o);const u=E0.filter(y=>!y.teamOnly||e==="team"),f=h.useRef(null),[g,p]=h.useState(null),v=Qt();return h.useEffect(()=>{if(f.current===null){f.current=e;return}f.current!==e&&(e==="team"&&s?p(`You are now acting in team context — ${s.name}`):e==="personal"&&p("You have left the team — back to personal context"),f.current=e)},[e,s]),h.useEffect(()=>{p(null)},[v.pathname]),n.jsxs("div",{className:"sidebar",children:[["top","core","setup"].map(y=>{const w=u.filter(x=>(x.group??"setup")===y);return w.length===0?null:n.jsxs("div",{className:`sidebar-${y}`,children:[y==="setup"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-divider"}),n.jsx("div",{className:"sidebar-group-label",children:"Setup"})]}),n.jsx("ul",{className:"sidebar-nav",children:w.map(x=>{const b=x.statusKey?l[x.statusKey]:0;return n.jsx("li",{children:n.jsxs(zc,{to:x.to,end:x.to==="/",className:({isActive:k})=>`sidebar-item${k?" active":""}`,children:[n.jsx("span",{className:"icon",children:x.iconClass?n.jsx("span",{className:`nav-ic ${x.iconClass}`,"aria-hidden":"true"}):x.icon}),x.label,b?x.newLabel?n.jsx("span",{className:"nav-new","data-testid":`nav-new-${x.statusKey}`,children:"New"}):n.jsx("span",{style:A0,className:x.quietCount?"nav-count-quiet":void 0,title:x.quietCount?"Expired mandates":void 0,children:b}):null]})},x.to)})})]},y)}),g&&n.jsx("div",{style:I0,role:"status","aria-live":"polite",children:g})]})}const Xl="suveren:updatedTo";function P0(e){return e==="managed"||e==="msi"?null:e==="npm"?"npm install -g @suveren/gateway@latest && suveren-gateway restart":e==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}const $0="Updates for this gateway come from your company's IT — no action needed here.";function _0(e){return e==="managed"?"update-banner is-managed":"update-banner"}const L0="Download the new installer and run it. Your settings and mandates stay.";function z0(e){const s="https://github.com/suverenai/suveren-gateway/releases";return e?`${s}/tag/v${e}`:`${s}/latest`}function F0(){const e=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const a of e)if(!a.closest(".update-overlay"))return!0;const s=document.activeElement;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)){const a=s.value;if(a&&a.trim())return!0}return!1}function _m(){const{updateAvailable:e,installMethod:s,version:a,latestVersion:o,serverRestarted:l,startFastPolling:u,dismiss:f}=Fc(),[g,p]=h.useState(!1),[v,y]=h.useState(!1),[w,x]=h.useState(()=>{try{const P=sessionStorage.getItem(Xl);if(P)return sessionStorage.removeItem(Xl),P}catch{}return null}),b=P0(s),k=h.useRef(null),S=P=>{try{sessionStorage.setItem(Xl,P||o||"✓")}catch{}window.location.reload()};h.useEffect(()=>{if(!w)return;const P=setTimeout(()=>x(null),6e3);return()=>clearTimeout(P)},[w]),h.useEffect(()=>{if(!g||!l)return;const P=()=>F0()?!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 N=e&&!g&&!w||!!w&&!g;h.useEffect(()=>{if(!N){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 M;const B=((M=k.current)==null?void 0:M.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${B}px`)};P();const I=new ResizeObserver(P);return k.current&&I.observe(k.current),()=>{I.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[N]);const T=()=>{p(!0),u()},E=async()=>{if(b)try{await navigator.clipboard.writeText(b),y(!0),setTimeout(()=>y(!1),1800)}catch{}};return n.jsxs(n.Fragment,{children:[w&&!g&&n.jsx("div",{ref:k,className:"update-banner is-live",role:"status","aria-live":"polite",children:n.jsxs("div",{className:"update-banner-row",children:[n.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",w&&w!=="✓"?` — ${w} is live`:" — now live","."]}),n.jsx("button",{className:"update-banner-x",onClick:()=>x(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!g&&!w&&n.jsxs("div",{ref:k,className:_0(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:z0(o),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),s!=="managed"&&s!=="msi"&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:T,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:$0}),s==="msi"&&n.jsx("p",{className:"update-banner-hint",children:L0})]}),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:b}),n.jsx("button",{className:"btn btn-sm btn-primary",onClick:E,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 Lm(){const e=Bc(),s=h.useRef(null);return h.useEffect(()=>{if(!e){document.documentElement.style.removeProperty("--sim-banner-h");return}const a=()=>{var u;const l=((u=s.current)==null?void 0:u.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${l}px`)};a();const o=new ResizeObserver(a);return s.current&&o.observe(s.current),()=>{o.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[e]),e?n.jsx("div",{ref:s,className:"simulation-banner",role:"status","aria-live":"polite",children:n.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const M0={system:"◑",light:"☀",dark:"☾"},O0=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/blocked",icon:"⊘",label:"Blocked"},{to:"/team",icon:"◉",label:"Team"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function B0({open:e,onClose:s}){const{user:a,activeGroup:o,activeDomain:l,logout:u}=wt(),{theme:f,toggle:g}=Nm(),p=Qt();return h.useEffect(()=>{s()},[p.pathname]),e?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mobile-menu-backdrop",onClick:s}),n.jsxs("div",{className:"mobile-menu-panel",children:[a&&n.jsxs("div",{className:"mobile-menu-header",children:[n.jsx("strong",{children:a.name}),n.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:o?`${o.name} / ${l}`:l||"personal"})]}),n.jsx("nav",{className:"mobile-menu-nav",children:O0.map(v=>n.jsxs(zc,{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:M0[f]}),"Theme: ",f]}),n.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),s()},children:"Logout"})]})]})]}):null}function zm(e){return e.status==="pending"}function D0(e,s){return e.filter(zm).length+s.length}const Cr=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],U0=500;function Fm(){const{user:e,domain:s}=wt(),[a,o]=h.useState(0),l=h.useRef(null),u=h.useCallback(async()=>{if(!e){o(0);return}try{const[g,p]=await Promise.all([L.getMyProposals(s).catch(()=>[]),L.getProposalsForApprover().catch(()=>[])]);o(D0(g,p))}catch{o(0)}},[e,s]),f=h.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{u()},U0)},[u]);return h.useEffect(()=>(u(),()=>{l.current&&clearTimeout(l.current)}),[u]),Me(Cr[0],f),Me(Cr[1],f),Me(Cr[2],f),Me(Cr[3],f),Me(Cr[4],f),Me(Cr[5],f),Me(Cr[6],f),a}const Zf="Suveren",W0="/favicon.svg",H0="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Ti={x1:74.54,y1:22.74,x2:94.46,y2:34.24},V0=14,G0="#f59e0b";function K0(e){const s=Wc(e);return s>0?`(${s}) ${Zf}`:Zf}function Wc(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function q0(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
52
+ <path class="m" d="${H0}"/>
53
+ <line class="m" x1="${Ti.x1}" y1="${Ti.y1}" x2="${Ti.x2}" y2="${Ti.y2}"/>
54
+ <circle cx="103" cy="103" r="25" fill="${G0}"/>
55
+ <style>.m{stroke:#111111;stroke-width:${V0};fill:none;stroke-linecap:round}@media (prefers-color-scheme:dark){.m{stroke:#ffffff;stroke-width:13.3}}</style>
56
+ </svg>`;return`data:image/svg+xml,${encodeURIComponent(e)}`}function Y0(){return document.querySelector('link[rel="icon"]')}function Mm(e){const s=Wc(e);document.title=K0(s),Om(s);const a=Y0();if(!a)return;const o=s>0?q0():W0;a.getAttribute("href")!==o&&a.setAttribute("href",o)}function J0(){Mm(0)}function Om(e,s=globalThis.navigator){var l;if(!s||typeof s.setAppBadge!="function")return;const a=Wc(e),o=a>0?s.setAppBadge(a):s.clearAppBadge?s.clearAppBadge():s.setAppBadge(0);(l=o==null?void 0:o.catch)==null||l.call(o,()=>{})}function Q0(){const e=Fm();return h.useEffect(()=>{Mm(e)},[e]),h.useEffect(()=>J0,[]),null}const Bm="suveren:dockBadgePrompt";function X0(){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(Bm))return!1}catch{}return!0}function Z0(){const[e,s]=h.useState(!1),a=Fm();if(h.useEffect(()=>{s(X0())},[]),!e)return null;const o=()=>{try{localStorage.setItem(Bm,"1")}catch{}s(!1)},l=async()=>{try{await Notification.requestPermission()==="granted"&&Om(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 ew(){const[e,s]=h.useState(!1);return n.jsxs(s0,{children:[n.jsx(Q0,{}),n.jsx(Mc,{onMenuToggle:()=>s(!e)}),n.jsx(_m,{}),n.jsx(Lm,{}),n.jsx(R0,{}),n.jsx(B0,{open:e,onClose:()=>s(!1)}),n.jsx("div",{className:"main-content",children:n.jsxs("div",{className:"page-inner",children:[n.jsx(Z0,{}),n.jsx(Zv,{})]})})]})}function Dm({what:e}){return n.jsxs("div",{className:"human-only-note",role:"note",children:[n.jsx("strong",{children:"Only you."})," ",e==="sign-in"?"Never let an AI or a browser it controls sign in here or see this key.":"Approve only yourself. Never let an AI or a browser it controls open this page or approve for you."]})}function Hc(){return typeof navigator<"u"&&navigator.webdriver===!0}const Vc="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function tw(){const[e,s]=h.useState(""),{login:a,isLoading:o,error:l,clearError:u}=wt(),[f,g]=h.useState(null),p=Hc(),v=async()=>{if(!(!e.trim()||p)){u();try{await a(e)}catch(x){if(x instanceof jm){g(x.summary);return}}}},y=async()=>{g(null),u();try{await a(e,{confirmWipe:!0})}catch{}},w=()=>{g(null)};return n.jsxs(n.Fragment,{children:[n.jsx(Mc,{}),n.jsx(_m,{}),n.jsx(Lm,{}),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:Vc}),l&&n.jsx("div",{className:"error-message",children:l}),n.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[n.jsx("label",{className:"form-label",children:"API Key"}),n.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:x=>s(x.target.value),onKeyDown:x=>x.key==="Enter"&&v(),disabled:o,style:{padding:"0.75rem"}}),n.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),n.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:v,disabled:o||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((x,b)=>n.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:b<2?"0.5rem":0},children:[n.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[b+1,"."]}),x]},b))})]})]})})]}),f&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:w,children:n.jsxs("div",{className:"card",onClick:x=>x.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[n.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["This gateway already holds data for another account. Signing in with this API key will ",n.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsxs("li",{children:[f.credentialCount," stored service credential",f.credentialCount===1?"":"s",f.credentialIds.length>0&&n.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",f.credentialIds.slice(0,5).join(", "),f.credentialIds.length>5?`, +${f.credentialIds.length-5} more`:"",")"]})]}),n.jsxs("li",{children:[f.serviceCount," configured integration",f.serviceCount===1?"":"s"]}),n.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),n.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Mandates and tickets on the Authority Server are NOT affected — only this gateway's local state is wiped."}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:"If this isn't what you wanted, cancel and sign back in with the original API key, or use a different gateway instance for this account."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:w,disabled:o,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:y,disabled:o,children:o?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function nw(e,s){return!s&&e!=null}function rw(e,s){return e==="join-waiting"&&s==="team"}function sw(e,s,a,o){return a!=null||e!=="join-waiting"||s==="team"?null:o}function aw(e){return`${e} personal mandate${e===1?"":"s"}`}function iw({mandates:e,pendingProposals:s}){return e.length===0&&s===0?n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)"},children:"You have no personal mandates to end."}):n.jsxs("div",{style:{background:"var(--bg-elevated)",borderRadius:"0.5rem",padding:"0.75rem 1rem",margin:"0.75rem 0"},children:[n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Your personal mandates end"}),n.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,fontSize:"0.825rem"},children:e.map(a=>n.jsxs("li",{style:{display:"flex",justifyContent:"space-between",gap:"0.5rem",padding:"0.25rem 0",borderBottom:"1px solid var(--border)"},children:[n.jsx("span",{children:a.title||a.profileId}),n.jsx("span",{style:{color:"var(--text-tertiary)"},children:a.commitmentMode??""})]},a.id))}),n.jsxs("p",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem",marginBottom:0},children:["They stay in your history; their tickets stay verifiable.",s>0&&` ${s} personal proposal${s===1?"":"s"} waiting for approval end${s===1?"s":""} too.`]})]})}function ow(){const{mode:e,pendingRequest:s,refreshGroups:a}=wt(),o=Sn(),[l,u]=h.useState("choose"),[f,g]=h.useState(""),[p,v]=h.useState(""),[y,w]=h.useState(null),[x,b]=h.useState(null),[k,S]=h.useState(""),[N,T]=h.useState(""),[E,P]=h.useState(!1),I=h.useRef(!1);h.useEffect(()=>{nw(s,I.current)&&(I.current=!0,u("join-waiting"))},[s]),h.useEffect(()=>{rw(l,e)&&o("/")},[l,e,o]);const B=h.useRef(null);h.useEffect(()=>{if(s){B.current=s.groupName;return}const O=sw(l,e,s,B.current);O&&(S(O),u("join-declined"),B.current=null)},[s,l,e]),h.useEffect(()=>{if(l!=="join-waiting")return;const O=setInterval(()=>{a()},5e3);return()=>clearInterval(O)},[l,a]);const M=h.useCallback(()=>{u("choose"),T(""),w(null),b(null),g(""),v("")},[]),q=async()=>{if(f.trim()){P(!0),T("");try{const O=await L.getJoinPreview(f.trim());w(O),u("join-preview")}catch(O){T(O instanceof Error?O.message:"Invalid or expired invite code")}finally{P(!1)}}},z=async()=>{P(!0),T("");try{await L.requestToJoinGroup(f.trim()),await a(),u("join-waiting")}catch(O){T(O instanceof Error?O.message:"Failed to join group")}finally{P(!1)}},U=async()=>{P(!0),T("");try{await L.withdrawJoinRequest(),await a(),M()}catch(O){T(O instanceof Error?O.message:"Failed to withdraw request")}finally{P(!1)}},Z=async()=>{u("create"),T(""),P(!0);try{const O=await L.getCreatePreview();b(O)}catch(O){T(O instanceof Error?O.message:"Failed to load preview")}finally{P(!1)}},G=async()=>{if(p.trim()){P(!0),T("");try{await L.createGroup(p.trim()),await a(),o("/")}catch(O){T(O instanceof Error?O.message:"Failed to create group")}finally{P(!1)}}};return n.jsxs(n.Fragment,{children:[n.jsx(Mc,{}),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:[N&&n.jsx("div",{className:"error-message",children:N}),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:O=>g(O.target.value),onKeyDown:O=>O.key==="Enter"&&q(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:E}),n.jsx("button",{className:"btn btn-primary",onClick:q,disabled:E||!f.trim(),children:E?"Checking…":"Continue"})]})]}),n.jsxs("div",{className:"card",children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members."}),n.jsx("button",{className:"btn btn-secondary",onClick:Z,disabled:E,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(iw,{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:z,disabled:E,children:E?"Asking…":"Ask to join"}),n.jsx("button",{className:"btn btn-ghost",onClick:M,disabled:E,children:"Cancel"})]})]}),l==="join-waiting"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request sent to team ",(s==null?void 0:s.groupName)??""]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Waiting for the team admin to confirm. Until then your account stays Personal and your mandates keep working."}),n.jsx("button",{className:"btn btn-secondary",onClick:U,disabled:E,children:E?"Withdrawing…":"Withdraw request"})]}),l==="join-declined"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request to ",k," 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:M,disabled:E,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:O=>v(O.target.value),onKeyDown:O=>O.key==="Enter"&&G(),disabled:E,autoFocus:!0})]}),x&&n.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",aw(x.personalMandates.length)," end (kept in your history)."]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginTop:"1rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:G,disabled:E||!p.trim(),children:E?"Creating…":"Create team and move my account"}),n.jsx("button",{className:"btn btn-ghost",onClick:M,disabled:E,children:"Cancel"})]})]})]})})]})}const eh={"claude-code":{label:"Claude Code",snippet:e=>`claude mcp add --transport http suveren ${e}/mcp`},"claude-desktop":{label:"Claude Desktop",snippet:e=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json, then restart Claude Desktop:
57
+
58
+ ${JSON.stringify({mcpServers:{suveren:{command:"npx",args:["mcp-remote@latest",`${e}/mcp`,"--allow-http"]}}},null,2)}`},"chatgpt-codex":{label:"ChatGPT / Codex",snippet:e=>`Add to ~/.codex/config.toml:
59
+
60
+ [mcp_servers.suveren]
61
+ url = "${e}/mcp"
62
+
63
+ Or: codex mcp add suveren --url ${e}/mcp`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
64
+ SSE transport: GET ${e}/sse
65
+ Health check: GET ${e}/health`}},th=["claude-code","claude-desktop","chatgpt-codex","other"];function fc({mcpEndpoint:e}){const[s,a]=h.useState(th[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=eh[s].snippet(e);return n.jsxs("div",{children:[n.jsx("div",{className:"gate-content-label",children:"MCP Endpoint"}),n.jsx("div",{className:"mcp-endpoint",children:e}),n.jsx("div",{className:"mcp-tabs",children:th.map(g=>n.jsx("button",{className:`mcp-tab${s===g?" active":""}`,onClick:()=>a(g),children:eh[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 hc="suveren-setup-ai-skipped",mc="suveren-setup-agent-done",pc="suveren-setup-dismissed",lw={"hap-setup-ai-skipped":hc,"hap-setup-agent-done":mc,"hap-setup-dismissed":pc};function cw(){for(const[e,s]of Object.entries(lw)){const a=localStorage.getItem(e);a!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,a),a!==null&&localStorage.removeItem(e)}}cw();function uw({aiConfigured:e,hasRunningIntegration:s,hasActiveAuth:a,hasAgentConnected:o,mcpEndpoint:l}){const[u,f]=h.useState(()=>localStorage.getItem(hc)==="true"),[g,p]=h.useState(()=>localStorage.getItem(mc)==="true"),[v,y]=h.useState(()=>localStorage.getItem(pc)==="true"),[w,x]=h.useState(null),b=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":u?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:s?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:a?"done":"pending"},{label:"Connect your agent",status:o||g?"done":"pending"}],k=b.filter(I=>I.status==="done"||I.status==="skipped").length,S=k===b.length,N=h.useCallback(()=>{localStorage.setItem(hc,"true"),f(!0)},[]),T=h.useCallback(()=>{localStorage.setItem(mc,"true"),p(!0),x(null)},[]),E=h.useCallback(()=>{localStorage.setItem(pc,"true"),y(!0)},[]);if(v||S)return null;const P=b.findIndex(I=>I.status==="pending");return n.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[n.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),n.jsx("button",{onClick:E,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:b.map((I,B)=>{const M=B===P,q=I.status==="done"||I.status==="skipped"?"●":"○",z=I.status==="done"?"var(--text-primary)":I.status==="skipped"?"var(--text-tertiary)":M?"var(--accent)":"var(--text-tertiary)";return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:M?"0.75rem":"0.25rem 0",borderRadius:M?"0.5rem":void 0,background:M?"var(--accent-subtle)":void 0},children:[n.jsx("span",{style:{color:z,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:q}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[I.to&&I.status==="pending"?n.jsx(gt,{to:I.to,style:{fontSize:"0.9rem",fontWeight:M?600:500,color:M?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:I.label}):I.status==="pending"&&B===3?n.jsx("button",{onClick:()=>x(w===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:M?600:500,color:M?"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"&&M&&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:N,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),I.to&&I.status==="pending"&&n.jsx(gt,{to:I.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),B===3&&w===3&&n.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[n.jsx(fc,{mcpEndpoint:l}),n.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:T,children:"Done"})]})]},B)})}),n.jsxs("div",{style:{marginTop:"1.25rem"},children:[n.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:n.jsx("div",{style:{height:"100%",width:`${k/b.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),n.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[k," of ",b.length," complete"]})]})]})}function Um(e,s=null){const a=[e.hasContact,e.hasDelegationMandate,e.delegationProposalCount>0],o=a.every(Boolean),l=e.otherMandateCount===0&&!o,u=a.findIndex(v=>!v),f=s!==null&&a[s]===!1?s:u,g=e.managed?"managed":"self",p=v=>a[v]?{status:"done"}:v!==f?{status:"todo"}:v===1?{status:"open",variant:g,simulationOn:e.simulationOn}:v===0?{status:"open",variant:g}:{status:"open"};return{visible:l,step1:p(0),step2:p(1),step3:p(2)}}const dw="/mandates?new=1&profile=delegation";function nh({text:e}){const[s,a]=h.useState(!1),o=h.useCallback(async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[e]);return n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:o,children:s?"Copied":"Copy"})}function Zl({todo:e,onOpen:s,children:a}){return e?n.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:s,children:a}):n.jsx("span",{className:"flow-step-title",children:a})}function fw({contact:e,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u,mcpEndpoint:f}){const g={hasContact:e!==null,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u},[p,v]=h.useState(null),y=Um(g,p);if(!y.visible)return null;const w=`Please connect to the Suveren gateway: MCP server at ${f}/mcp`;return n.jsxs("div",{className:"card setup-card",children:[n.jsx("h2",{className:"card-title",children:"Get started"}),n.jsx("p",{className:"setup-intro",children:"You decide what your AI can do — it acts only within that. Every action that changes something gets a signed ticket."}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step1.status==="open"?"open":y.step1.status==="done"?"done":"todo"}`,children:y.step1.status==="done"?"✓":"1"}),y.step1.status==="done"&&e?n.jsxs("span",{className:"flow-step-title flow-done-title",children:[e.clientName," connected · last contact ",Im(Date.parse(e.lastSeenAt),Date.now()).toLowerCase()]}):n.jsx(Zl,{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(fc,{mcpEndpoint:f})})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:w}),n.jsx(nh,{text:w})]})}),n.jsx("p",{className:"cta-helper",style:{marginTop:0,marginBottom:"0.75rem"},children:"If your AI can't add it itself, it will tell you how. In ChatGPT, use a local session."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"Set it up by hand"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(fc,{mcpEndpoint:f})})]})]})})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step2.status==="open"?"open":y.step2.status==="done"?"done":"todo"}`,children:y.step2.status==="done"?"✓":"2"}),y.step2.status==="done"?n.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",n.jsx(gt,{to:"/mandates",children:"review or revoke under Mandates"})]}):n.jsx(Zl,{todo:y.step2.status==="todo",onOpen:()=>v(1),children:"Give the Delegation mandate"})]}),y.step2.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("p",{children:"Delegation lets your AI propose the rest of its own setup — new mandates and its working instructions. It can only propose; nothing changes until you approve it."}),n.jsxs("ul",{className:"bound-list",children:[n.jsx("li",{children:"Read the setup guides"}),n.jsx("li",{children:"Propose new mandates — each waits for your approval"}),n.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),y.step2.simulationOn?n.jsxs(n.Fragment,{children:[n.jsx(gt,{to:dw,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(Zl,{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(nh,{text:"How do I start with Suveren?"})]})}),n.jsxs("p",{children:["It will interview you, suggest test data, and propose mandates and a brief. Approve its proposals under ",n.jsx(gt,{to:"/approvals",children:"Approvals"}),"."]})]})]})]})}function hw(){const[e,s]=h.useState(null);return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{!a&&typeof o.mcpPort=="number"&&s(`http://localhost:${o.mcpPort}`)}).catch(()=>{}),()=>{a=!0}},[]),e}function mw(e){if(!e||typeof e!="object")return{simulation:null,locked:!1};const s=Array.isArray(e.policyLocked)&&e.policyLocked.includes("simulation");return{simulation:typeof e.simulation=="boolean"?e.simulation:null,locked:s}}function Wm(){const[e,s]=h.useState({simulation:null,locked:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(mw(o))}).catch(()=>{}),()=>{a=!0}},[]),e}function pw(e){return!e||typeof e!="object"?!1:Array.isArray(e.policyLocked)&&e.policyLocked.length>0}function gw(){const[e,s]=h.useState(!1);return h.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(f=>f.json()).then(f=>{a||s(pw(f))}).catch(()=>{})};o();const l=setInterval(o,3e4),u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}const rh=new Map;function Hm(e){let s=rh.get(e);return s||(s=(async()=>{try{let a=e;if(!e.includes("@")){const o=await L.listProfiles(),l=f=>f.replace(/@.*$/,"").split("/").pop(),u=o.filter(f=>l(f.id)===e).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 L.getProfile(a)}catch{return null}})(),rh.set(e,s)),s}function ma(e){const[s,a]=h.useState(null);return h.useEffect(()=>{let o=!0;return e&&Hm(e).then(l=>{o&&a(l)}),()=>{o=!1}},[e]),s}const sh=40;function Mt(e,s){const a=e.lastIndexOf("/"),o=a>=0?e.slice(a+1):e,l=o.indexOf("@"),u=l>=0?o.slice(0,l):o;return s?s.slice(0,sh):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,sh)}function In(e){const s=e.lastIndexOf("/"),a=s>=0?e.slice(s+1):e,o=a.indexOf("@");return(o>=0?a.slice(0,o):a).toLowerCase()}function _r(e,s){const a=In(e),o=Pr(e),l=Mt(e,s==null?void 0:s.name);return{icon:o,name:l,testSetup:a==="delegation"}}function no(e){return e.startsWith("setup__")}const yw={customers:"customers",email:"email",charge:"payments",sales:"sales",calendar:"calendar",records:"records",publish:"publishing",deploy:"deployments",purchase:"purchasing",reporting:"reports",delegation:"setup",invoicing:"invoicing"};function Pr(e){return yw[In(e)]??"unknown"}function ah(e){const s=e.indexOf("@");return s>=0?e.slice(s+1):""}function Bn(e,s){const a=In(e),o=s.filter(l=>In(l.id)===a).sort((l,u)=>ah(u.id).localeCompare(ah(l.id),void 0,{numeric:!0}))[0];return Mt(e,o==null?void 0:o.name)}function vw(e,s){const a=e==null?void 0:e.trim();return a?a.toLowerCase()!==s.trim().toLowerCase():!1}function Vm(e){return e&&e.trim()?e.trim():null}function Gm(e,s){return s===null||In(e)===s}let ec=null;function xw(){return ec||(ec=L.listProfiles().catch(()=>[])),ec}function Lr(){const[e,s]=h.useState([]);return h.useEffect(()=>{let a=!0;return xw().then(o=>{a&&s(o)}),()=>{a=!1}},[]),e}function ww(e){const s=Lr();return Bn(e,s)}function ro(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}const Km=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview","_source","_attachmentsSealed"]);function Wt(e){const s=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)}function Un(e){const s=e.indexOf("__");return s<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,s),toolName:e.slice(s+2)}}function jw(e){const{integrationId:s,toolName:a}=Un(e);return s?`${s} · ${a}`:a}function Wn(e,s){const a=s==null?void 0:s.find(o=>o.id===e);return a!=null&&a.name?a.name:e?e.toUpperCase():"the system"}function Sw(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
66
+ `)||e.length>120)?"markdown":"text"}function qm(e,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(e)])],u=[];for(const p of l){if(!(p in e)||Km.has(p)||p===(s==null?void 0:s.aiTextArg))continue;const v=e[p],y=a[p]??{},w=y.kind??Sw(v),x={key:p,label:y.label??Wt(p),kind:w,value:v,hint:(g=o[p])==null?void 0:g.description};w==="money"&&y.currencyArg&&typeof e[y.currencyArg]=="string"&&(x.currency=e[y.currencyArg]),w==="profile"&&typeof v=="string"&&(x.profileRef=v),(w==="profile-limits"||w==="profile-scope")&&y.profileArg&&typeof e[y.profileArg]=="string"&&(x.profileRef=e[y.profileArg]),u.push(x)}return u}function ih(e,s){const a=s==null?void 0:s.aiTextArg;if(!a)return;const o=e[a];return typeof o=="string"&&o.length>0?o:void 0}function bw(e,s){var o,l;const a=(l=(o=s==null?void 0:s.scopeSchema)==null?void 0:o.fields)==null?void 0:l[e];return a?{label:a.displayName??e,hint:a.description}:{label:e}}function kw(e,s,a){if(!e||typeof e!="object"||Array.isArray(e))return[];const o=a==="limits"?s==null?void 0:s.boundsSchema:s==null?void 0:s.scopeSchema,l=(o==null?void 0:o.fields)??{},u=[...new Set([...(o==null?void 0:o.keyOrder)??[],...Object.keys(e)])],f=[];for(const g of u){if(g==="profile"||!(g in e))continue;const p=e[g],v=l[g],y=ro(v==null?void 0:v.unit),w=Array.isArray(p)?p.join(", "):String(p);f.push({key:g,label:(v==null?void 0:v.displayName)??Wt(g),value:y?`${w} ${y}`:w,hint:v==null?void 0:v.description,unknown:s?!v:void 0})}return f}function Ym(e){const s=e.indexOf("__");return s<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,s),toolName:e.slice(s+2)}}function so(e,s){var p,v,y;const{integrationId:a,toolName:o}=Ym(e.action),l=s.find(w=>w.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=Mt(e.profileId),g=(y=e.executionContext)==null?void 0:y.action_type;return typeof g=="string"&&g?`${f} · ${g}`:`${f} · ${o}`}function Nw(e,s){var l;const a=(l=s==null?void 0:s.scopeSchema)==null?void 0:l.fields;if(!a)return"";const o=[];for(const[u,f]of Object.entries(e.executionContext??{})){if(!(u in a))continue;const g=String(f??"").trim();g&&o.push(g.split(",").map(p=>p.trim()).filter(Boolean).join(", "))}return o.join(" · ")}function Cw(e,s){var l,u;if(!e)return"";const a=((l=s==null?void 0:s.scopeSchema)==null?void 0:l.fields)??{},o=[];for(const[f,g]of Object.entries(e)){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 oh(e){return e.appliesTo}function Ew(e,s,a,o){var v,y,w;const l=(v=a==null?void 0:a.boundsSchema)==null?void 0:v.fields;if(!l||!s)return;const u=e.actionType??(typeof((y=e.executionContext)==null?void 0:y.action_type)=="string"?e.executionContext.action_type:void 0),f=Object.entries(l).filter(([x,b])=>{if(!(x in s))return!1;const k=b.boundType;if(!k||k.kind!=="cumulative_sum"&&k.kind!=="cumulative_count"||k.window!==o)return!1;const S=oh(b);return!S||!u||S.includes(u)}),p=(u?f.find(([,x])=>{var b;return(b=oh(x))==null?void 0:b.includes(u)}):void 0)??(f.length===1?f[0]:void 0);return p?{key:p[0],isAmount:((w=p[1].boundType)==null?void 0:w.kind)==="cumulative_sum"}:void 0}function Jm(e,s,a,o){var g;const l=(g=e.cumulativeState)==null?void 0:g[o];if(!l)return null;const u=Ew(e,s,a,o),f=u?Number(s==null?void 0:s[u.key]):NaN;return u&&Number.isFinite(f)?{used:u.isAmount?l.amount:l.count,limit:f}:{count:l.count}}function Tw(e,s,a){const o=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],l=[];for(const{window:u,label:f}of o){const g=Jm(e,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 Aw(e,s,a){var u;const o=(u=a==null?void 0:a.boundsSchema)==null?void 0:u.fields;if(!e||!s||!o)return[];const l=[];for(const[f,g]of Object.entries(o)){const p=g.boundType;if(!p||p.kind!=="per_transaction")continue;const v=p.of;if(!(v in e)||!(f in s))continue;const y=Number(e[v]),w=Number(s[f]);if(!Number.isFinite(y)||!Number.isFinite(w))continue;const x=ro(g.unit),b=g.displayName??Wt(v),k=S=>x?`${S.toLocaleString()} ${x}`:S.toLocaleString();l.push({key:f,label:b,ok:y<=w,valueText:k(y),limitText:k(w)})}return l}function Bi(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function Iw(e){const s=Mt(e),a=e.split("@")[1];return a?`${s}@${a}`:s}const Rw=["automatic","approved","all"];function Pw(e){return e==="automatic"||e==="approved"?e:"all"}function gc(e,s){return s==="all"?!0:s==="approved"?Bi(e):!Bi(e)}function $r(e,s){return Bn(e,s)}function pa(e,s){return Wn(Ym(e).integrationId,s)}function $w(e,s){const a=Math.max(0,Math.floor((s-e)/1e3));if(a<60)return"just now";const o=Math.floor(a/60);if(o<60)return`${o} min`;const l=Math.floor(o/60);if(l<24)return`${l} h`;const u=Math.floor(l/24);return`${u} ${u===1?"day":"days"}`}function Qm(e,s){const a=$w(e*1e3,s);return a==="just now"?"waiting just now":`waiting ${a}`}const _w=24*3600;function Xm(e,s,a){const o=e-Math.floor(s/1e3);return o<=0||o>_w?null:`Decide by ${new Date(e*1e3).toLocaleString(a,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})} — otherwise it won't run`}function Zm(e){return e.replace(/-/g,"").slice(0,8)}function Lw(e,s){const a=new Date(e),o=new Date(s);return a.getFullYear()===o.getFullYear()&&a.getMonth()===o.getMonth()&&a.getDate()===o.getDate()}function Gc(e,s){return Lw(e*1e3,s)}function Di(e,s){return e.timestamp*1e3>s}function zw(e,s){var l;const a=new Map;for(const u of e){if(Bi(u))continue;const f=so(u,s.manifests),p=`${u.authorizationId??u.profileId}|${u.action}`;let v=a.get(p);v||(v={key:p,area:$r(u.profileId,s.catalog),system:pa(u.action,s.manifests),profileId:u.profileId,mandateTitle:u.authorizationId?(l=s.titles)==null?void 0:l[u.authorizationId]:void 0,label:f,count:0,newCount:0,latestSec:0,tickets:[]},a.set(p,v)),v.count+=1,Di(u,s.lastSeenMs)&&(v.newCount+=1),v.latestSec=Math.max(v.latestSec,u.timestamp),v.tickets.push(u)}const o=[...a.values()];for(const u of o)u.tickets.sort((f,g)=>g.timestamp-f.timestamp);return o.sort((u,f)=>+(f.newCount>0)-+(u.newCount>0)||f.latestSec-u.latestSec)}function Fw(e,s){var l,u,f,g,p;const a=new Map;for(const v of e){if(!v.authorizationId||!Gc(v.timestamp,s.nowMs))continue;const y=a.get(v.authorizationId);(!y||v.timestamp>y.timestamp||v.timestamp===y.timestamp&&(((u=(l=v.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((g=(f=y.cumulativeState)==null?void 0:f.daily)==null?void 0:g.count)??0))&&a.set(v.authorizationId,v)}const o=[];for(const[v,y]of a){const w=Jm(y,s.boundsOf(v)??y.limits,s.profileOf(y.profileId),"daily"),x={authorizationId:v,area:$r(y.profileId,s.catalog),system:pa(y.action,s.manifests),profileId:y.profileId,mandateTitle:(p=s.titles)==null?void 0:p[v]};w&&"limit"in w?o.push({...x,used:w.used,limit:w.limit,ratio:w.limit>0?w.used/w.limit:0}):o.push({...x,used:w?w.count:1,ratio:0})}return o.sort((v,y)=>y.ratio-v.ratio||v.area.localeCompare(y.area))}function lh(e){return e.ratio>=.8}function Ui(e,s,a){const o=new Date(e*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"});return Gc(e,s)?`today ${l}`:`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`}const Mw={customers:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"8",r:"3.2"}),n.jsx("path",{d:"M3 19c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5"}),n.jsx("circle",{cx:"17",cy:"9",r:"2.4"}),n.jsx("path",{d:"M15.5 13.8c3 .1 5.5 2 5.5 5"})]}),email:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),n.jsx("path",{d:"m3.5 6 8.5 7 8.5-7"})]}),payments:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"1.5"}),n.jsx("path",{d:"M3 10h18M7 15h4"})]}),sales:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h9l4 4v14H6z"}),n.jsx("path",{d:"M15 3v4h4M9 12h7M9 16h5"})]}),calendar:n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3.5",y:"5",width:"17",height:"15",rx:"1.5"}),n.jsx("path",{d:"M3.5 10h17M8 3v4M16 3v4"})]}),records:n.jsx("path",{d:"M3 7h7l2 2h9v10H3z"}),publishing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 10v4l11 4V6z"}),n.jsx("path",{d:"M15 9.5c2 .3 3 1.3 3 2.5s-1 2.2-3 2.5M7 14.5 8.5 19h2.5l-1.3-4"})]}),deployments:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12 3v12M7 8l5-5 5 5"}),n.jsx("path",{d:"M4 15v5h16v-5"})]}),invoicing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 3h12v18l-2-1.3-2 1.3-2-1.3-2 1.3-2-1.3L6 21z"}),n.jsx("path",{d:"M9 8h6M9 12h6M9 16h3"})]}),purchasing:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3 4h2.5l2.2 11h10.6L20.5 7H6.4"}),n.jsx("circle",{cx:"9",cy:"19",r:"1.4"}),n.jsx("circle",{cx:"17",cy:"19",r:"1.4"})]}),reports:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 20V4M4 20h16"}),n.jsx("path",{d:"M8 16v-4M12 16V8M16 16v-6"})]}),setup:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 7h10M18 7h2M4 17h4M12 17h8"}),n.jsx("circle",{cx:"16",cy:"7",r:"2"}),n.jsx("circle",{cx:"10",cy:"17",r:"2"})]}),unknown:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"12",cy:"12",r:"9.2"}),n.jsx("path",{d:"M9.6 9.6a2.5 2.5 0 1 1 3.6 2.3c-.9.5-1.4 1.1-1.4 2.2"}),n.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"17.05"})]})};function ga({icon:e,className:s}){return n.jsx("svg",{className:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Mw[e]})}function us({profileId:e,area:s,system:a,time:o,trailing:l,leading:u}){return n.jsxs("div",{className:"obj-line",children:[u,n.jsx(ga,{icon:Pr(e)}),n.jsx("b",{children:s}),a&&n.jsxs("span",{children:["· via ",a]}),o&&n.jsxs("span",{children:["· ",o]}),l&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"obj-line-sp"}),l]})]})}function ua({title:e,area:s}){return vw(e,s)?n.jsxs("div",{className:"obj-mandate-line","data-testid":"mandate-line",children:["Mandate: ",e]}):null}async function ch(e){const s=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}function Ow(e){return e.normalize("NFC").replace(/\r\n?/g,`
67
+ `).split(`
68
+ `).map(l=>l.replace(/[ \t]+$/,"")).join(`
69
+ `).replace(/\n+$/,"")}function yc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":yc(l)).join(",")+"]";const s=e,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+yc(l))}return"{"+a.join(",")+"}"}async function ep(e,s){if(e==="jcs"){if(typeof s=="string")throw new Error('content_binding kind="jcs" expects a record payload (object), got a string');return`sha256:${await ch(yc(s))}`}if(typeof s!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await ch(Ow(s))}`}async function tp(e){if(e.toolArgs)return e.toolArgs;if(!e.content)return null;try{const{plaintext:s}=await L.decryptProposalContent(e.content),a=JSON.parse(s);return typeof a!="object"||a===null||Array.isArray(a)?null:a}catch{return null}}function Bw(e){if(!e.content)return[];const s=new Set([...e.createdBy?[e.createdBy]:[],...e.pendingApprovers??[]]),a=new Set(Object.keys(e.content.keys));return Array.from(s).filter(o=>!a.has(o))}function np(e){return!e.loading&&e.readable}function rp(e,s){const a=new Set;if(e.content)for(const o of Object.keys(e.content.keys))a.add(o);else{e.createdBy&&a.add(e.createdBy);for(const o of e.pendingApprovers??[])a.add(o)}return s&&a.add(s),Array.from(a)}async function oa(e){const s=await tp(e);if(s)return ep("jcs",s)}function Dw(e){var o;const[s,a]=h.useState((e==null?void 0:e.note)??null);return h.useEffect(()=>{let l=!0;if(e!=null&&e.note){a(e.note);return}if(!(e!=null&&e.noteEncrypted)){a(null);return}return a(null),L.decryptProposalContent(e.noteEncrypted).then(({plaintext:u})=>{l&&a(u)}).catch(()=>{l&&a(null)}),()=>{l=!1}},[e==null?void 0:e.note,(o=e==null?void 0:e.noteEncrypted)==null?void 0:o.ciphertext]),s}const Uw={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function ao(e){var o;const[s,a]=h.useState(Uw);return h.useEffect(()=>{let l=!0;if(e.toolArgs){a({toolArgs:e.toolArgs,loading:!1,sealed:!1,undecryptable:!1});return}if(!e.content){a({toolArgs:null,loading:!1,sealed:!1,undecryptable:!1});return}return a({toolArgs:null,loading:!0,sealed:!0,undecryptable:!1}),(async()=>{const u=await tp(e);l&&a({toolArgs:u,loading:!1,sealed:!0,undecryptable:u===null})})(),()=>{l=!1}},[(o=e.content)==null?void 0:o.ciphertext,e.toolArgs]),s}const uh=140,dh=60,Ww=/\{([^{}]+)\}/g;function sp(e,s){var u,f;const{integrationId:a,toolName:o}=Un(e),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 ap(e,s){let a=e;for(const o of s.split(".")){if(a===null||typeof a!="object")return;a=a[o]}return a}function fh(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0}function Hw(e,s,a,o){if(s==="money"){const u=typeof e=="number"?e:Number(e);if(!Number.isFinite(u))return String(e);if(a&&/^[A-Za-z]{3}$/.test(a))try{return new Intl.NumberFormat(o,{style:"currency",currency:a.toUpperCase()}).format(u)}catch{}return new Intl.NumberFormat(o,{maximumFractionDigits:2}).format(u)}if(s==="percent")return`${e}%`;if(s==="date"){const u=new Date(String(e));return Number.isNaN(u.getTime())?String(e):u.toLocaleDateString(o,{day:"numeric",month:"short"})}if(Array.isArray(e)){const u=e.map(f=>typeof f=="object"&&f!==null?JSON.stringify(f):String(f));return u.length>2?`${u.slice(0,2).join(", ")} +${u.length-2}`:u.join(", ")}const l=typeof e=="object"?JSON.stringify(e):String(e);return s==="short"&&l.length>dh?`${l.slice(0,dh-1).trimEnd()}…`:l}function hh(e,s,a,o){let l=!1;const u=e.replace(Ww,(f,g)=>{const[p,v]=g.split("|").map(w=>w.trim()),y=p.split(",").map(w=>ap(s,w.trim())).find(fh);return fh(y)?Hw(y,v,a,o):(l=!0,"")});return l?null:u}function ip(e,s,a={}){const o=ap(s,a.currencyField??"currency"),l=typeof o=="string"?o:void 0,u=e.replace(/\[([^[\]]*)\]/g,(p,v)=>hh(v,s,l,a.locale)??""),f=hh(u,s,l,a.locale);if(f===null)return null;const g=f.replace(/\s+/g," ").trim();return g.length>uh?`${g.slice(0,uh-1).trimEnd()}…`:g}function op(e,s,a,o){var f;const l=Wt(Un(e).toolName),u=sp(e,a);return!(u!=null&&u.summary)||!s?l:ip(u.summary,s,{currencyField:(f=u.display)==null?void 0:f.currencyField,locale:o})??l}function Vw(e,s,a,o){var u;const l=sp(e,a);return!(l!=null&&l.summary)||!s?null:ip(l.summary,s,{currencyField:(u=l.display)==null?void 0:u.currencyField,locale:o})}function lp({proposal:e,manifests:s}){const a=ao(e);return n.jsx(n.Fragment,{children:op(e.tool,a.toolArgs,s)})}function tc({variant:e="base",style:s,className:a,...o}){const l=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return n.jsx("span",{className:`${l}${a?` ${a}`:""}`,style:s,role:"status","aria-busy":"true","aria-label":o["aria-label"]??"Loading"})}const os=5;function Gw({auths:e,activeCount:s,waiting:a,waitingReady:o}){const[l,u]=h.useState(null),[f,g]=h.useState(null),[p,v]=h.useState([]),[y,w]=h.useState({}),[x,b]=h.useState({}),k=h.useCallback(()=>{L.getMyReceiptsPage({limit:200}).then(z=>u(z.receipts)).catch(()=>u(z=>z??[])),L.getLastSeenTicketsAt().then(g).catch(()=>g(Number.POSITIVE_INFINITY))},[]);Ft(k,3e5),Me("ticket-recorded",k),h.useEffect(()=>{L.getLabelManifests().then(v).catch(()=>{}),L.getLocalAuthorizations().then(({authorizations:z})=>w(z)).catch(()=>{})},[]);const S=Lr(),N=h.useMemo(()=>{const z={};for(const U of e)U.authorization_id&&U.title&&(z[U.authorization_id]=U.title);return z},[e]),T=Date.now(),E=h.useMemo(()=>{const z=Date.now();return(l??[]).filter(U=>Gc(U.timestamp,z))},[l]);h.useEffect(()=>{const z=[...new Set(E.map(U=>U.profileId))].filter(U=>!(U in x));z.length!==0&&Promise.all(z.map(U=>Hm(U).then(Z=>[U,Z]).catch(()=>[U,null]))).then(U=>b(Z=>({...Z,...Object.fromEntries(U)})))},[E,x]);const P=h.useMemo(()=>zw(E,{catalog:S,manifests:p,titles:N,lastSeenMs:f??Number.POSITIVE_INFINITY}),[E,S,p,N,f]),I=E.filter(z=>gc(z,"approved")).length,B=h.useMemo(()=>Fw(E,{nowMs:Date.now(),catalog:S,manifests:p,titles:N,boundsOf:z=>{var U;return(U=y[z])==null?void 0:U.bounds},profileOf:z=>x[z]}),[E,S,p,N,y,x]),M=P.filter(z=>z.newCount>0).length,q=[...a].sort((z,U)=>z.createdAt-U.createdAt);return n.jsxs("div",{className:"core-cols","data-testid":"core-cols",children:[n.jsxs("section",{"aria-label":"Waiting for you","data-testid":"col-waiting",children:[n.jsxs("div",{className:"core-col-h is-main",children:[n.jsx("h2",{children:"Waiting for you"}),a.length>0&&n.jsx("span",{className:"pill-count",children:a.length})]}),o?q.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing waits for your decision."}):q.slice(0,os).map(z=>{const U=Xm(z.expiresAt,T);return n.jsxs(gt,{to:`/approvals?open=${encodeURIComponent(z.id)}`,className:"appr-item appr-item-link","data-testid":"dash-approval",children:[n.jsxs("div",{className:"appr-item-main",children:[n.jsx(us,{profileId:z.profileId,area:$r(z.profileId,S),system:pa(z.tool,p),time:Qm(z.createdAt,T)}),n.jsx("div",{className:"appr-item-sum",children:n.jsx(lp,{proposal:z,manifests:p})}),n.jsx(ua,{title:z.authorizationId?N[z.authorizationId]:void 0,area:$r(z.profileId,S)}),U&&n.jsx("div",{className:"obj-due",children:U})]}),n.jsx("span",{className:"appr-item-chev","aria-hidden":"true",children:"›"})]},z.id)}):n.jsx(tc,{variant:"line"}),q.length>0&&n.jsx(gt,{to:"/approvals",className:"col-btn",children:"All approvals ›"})]}),n.jsxs("section",{"aria-label":"Done automatically","data-testid":"col-automatic",children:[n.jsxs("div",{className:"core-col-h",children:[n.jsx("h2",{children:"Done automatically"}),M>0&&n.jsxs("span",{className:"meta",children:[P.reduce((z,U)=>z+U.newCount,0)," new"]})]}),l===null?n.jsx(tc,{variant:"line"}):P.length===0?n.jsx("p",{className:"core-col-empty",children:"Nothing was done automatically today."}):P.slice(0,os).map(z=>n.jsxs("details",{className:`auto-grp${z.newCount>0?"":" is-seen"}`,"data-testid":"auto-group",children:[n.jsxs("summary",{children:[n.jsx("span",{className:`seen-dot${z.newCount>0?" is-new":""}`,"aria-label":z.newCount>0?"new since your last visit":"seen"}),n.jsxs("span",{className:"auto-grp-txt",children:[n.jsx(us,{profileId:z.profileId,area:z.area,system:z.system}),n.jsxs("b",{children:[z.count," × ",z.label]}),n.jsx(ua,{title:z.mandateTitle,area:z.area}),n.jsxs("span",{className:"meta",children:[z.newCount>0?`${z.newCount} new`:"seen"," · latest ",Ui(z.latestSec,T)]})]})]}),n.jsxs("div",{className:"auto-grp-list",children:[z.tickets.slice(0,os).map(U=>n.jsxs("div",{className:"auto-grp-row",children:[n.jsx("span",{className:`seen-dot${Di(U,f??Number.POSITIVE_INFINITY)?" is-new":""}`}),so(U,p),n.jsxs("span",{className:"t",children:[Ui(U.timestamp,T)," · ",Zm(U.id)]})]},U.id)),z.tickets.length>os&&n.jsxs("div",{className:"auto-grp-row meta",children:["+ ",z.tickets.length-os," more in Tickets"]})]})]},z.key)),P.length>0&&n.jsx(gt,{to:"/tickets?filter=automatic",className:"col-btn","data-testid":"btn-automatic-tickets",children:"Automatic tickets ›"}),I>0&&n.jsxs("div",{className:"core-quiet-line",children:[I," approved today — ",n.jsx(gt,{to:"/tickets?filter=approved",children:"see approved tickets"})]})]}),n.jsxs("section",{"aria-label":"Mandates at work today","data-testid":"col-mandates",children:[n.jsx("div",{className:"core-col-h",children:n.jsx("h2",{children:"Mandates at work today"})}),l===null?n.jsx(tc,{variant:"line"}):B.length===0?n.jsx("p",{className:"core-col-empty",children:"No mandate has acted today."}):B.slice(0,os).map(z=>n.jsxs("div",{className:"mandate-obj","data-testid":"mandate-at-work",children:[n.jsx(us,{profileId:z.profileId,area:z.area,system:z.system}),z.mandateTitle&&z.mandateTitle.trim().toLowerCase()!==z.area.trim().toLowerCase()&&n.jsx("div",{className:"mandate-obj-title",children:z.mandateTitle}),n.jsx("div",{className:`usage${lh(z)?" is-near":""}`,children:z.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(z.ratio*100))}%`}})}),n.jsxs("span",{children:[lh(z)?n.jsxs("b",{children:[z.used," of ",z.limit]}):`${z.used} of ${z.limit}`," today"]})]}):n.jsxs("span",{children:[z.used," ",z.used===1?"action":"actions"," today"]})})]},z.authorizationId)),l!==null&&s>B.length&&n.jsxs("div",{className:"meta",style:{marginTop:"var(--space-2)",fontSize:"var(--text-caption)"},children:[s-B.length," more mandate",s-B.length===1?"":"s"," in force — no actions today"]}),B.length>0&&n.jsx(gt,{to:"/mandates",className:"col-btn",children:"All mandates ›"})]})]})}function Kw(){const[e,s]=h.useState(null),[a,o]=h.useState(Number.POSITIVE_INFINITY),l=h.useCallback(()=>{Promise.all([L.getReport().then(g=>g.report).catch(()=>null),L.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]).then(([g,p])=>{s(g),o(p)})},[]);if(Ft(l,3e5),Me("report-written",l),!e||!Pm(e,a))return null;const{verified:u,unchecked:f}=C0(e);return n.jsxs("div",{className:"report-line","data-testid":"report-line",children:[n.jsx("span",{className:"nav-new",style:{marginLeft:0},children:"New"}),n.jsxs("span",{className:"report-line-text",children:[n.jsx("b",{children:N0(e.renderedHtml)})," — ",n.jsx("span",{title:Oi(e.coverage).title,children:Oi(e.coverage).text})," · written ",$m(e.savedAt,Date.now()),f===0?n.jsxs(n.Fragment,{children:[" · all ",u," value",u===1?"":"s"," verified"]}):n.jsxs(n.Fragment,{children:[" · ",u," value",u===1?"":"s"," verified · ",n.jsxs("b",{children:["✕ ",f," could not be checked"]})]})]}),n.jsx(gt,{to:"/reports",className:"col-btn",children:"Open report ›"})]})}function qw(){const[e,s]=h.useState([]);return Ft(async()=>{try{const{skipped:o}=await L.getSkippedCommitments();s(o)}catch{}},3e4),e.length===0?null:n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px dashed var(--text-primary)"},children:[n.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",e.length,")"]}),n.jsx("p",{style:{margin:"0.5rem 0 1rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"These were approved, but this gateway has no local record of asking for them — usually because a different device/installation of yours submitted them, or its local record is gone. Re-run the same request on this gateway to execute it here."}),n.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:e.map(o=>n.jsxs("li",{style:{marginBottom:"0.35rem"},children:[n.jsx("code",{children:o.tool})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",o.id,")"]})]},o.id))})]})}function Yw(e,s){return s&&!ca(e.manifest)}function Jw(e,s=!1){var o;const a=[];for(const l of e)Yw(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"&&(ca(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 Qw(e){const s=e.filter(a=>a.state==="paused");return s.length===0?null:{count:s.length,namesText:s.map(a=>a.manifest.name).join(", ")}}const Xw=1800;function ea(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Zw(){const{domain:e}=wt(),[s,a]=h.useState([]),[o,l]=h.useState([]),[u,f]=h.useState([]),[g,p]=h.useState(!0),[v,y]=h.useState(!1),[w,x]=h.useState([]),[b,k]=h.useState(!1),[S,N]=h.useState(!1),[T,E]=h.useState(null),[P,I]=h.useState(!1),{entries:B,activeSessions:M,loading:q}=Dc(),z=hw(),U=!q,{simulation:Z}=Wm(),G=Z===!0,O=gw(),ne=h.useCallback(()=>{L.getMyAttestations().then(le=>{a(le),y(!0)}).catch(()=>y(!0)),L.getArchivedMandates().then(x).catch(()=>x([])),L.getMyProposals(e).then(le=>{l(le),k(!0)}).catch(()=>k(!0)),L.getProposalsForApprover().then(le=>f(le)).catch(()=>f([])),L.getCredential("ai-config").then(le=>{p(le.configured),N(!0)}).catch(()=>N(!0)),L.getAgentContact().then(le=>{E(le.contact),I(!0)}).catch(()=>I(!0))},[e]);Me("attestation-changed",ne),Me("proposal-added",ne),Me("proposal-resolved",ne),Me("proposal-approved",ne),Me("proposal-rejected",ne),Me("execution-failed",ne),Ft(ne,3e5,e);const fe=v&&b&&S&&U&&P&&Z!==null,ee=Tm(s,{archivedSet:new Set(w)}),pe=ee.active,Ne=ee.expired,X=pe.some(le=>ea(le.profile_id)==="delegation"),Q=pe.filter(le=>ea(le.profile_id)!=="delegation").length,Y=o.filter(le=>ea(le.profileId)==="delegation").length,A=Um({hasContact:T!==null,hasDelegationMandate:X,otherMandateCount:Q,delegationProposalCount:Y,managed:O,simulationOn:G}),_=G&&A.visible,se=pe.filter(le=>le.remaining_seconds!==null&&le.remaining_seconds<=Xw),te=o.filter(zm),H=B.filter(le=>le.state==="running"),ie=B.filter(le=>le.state==="starting"),ue=Qw(B),ge=[...te,...u.filter(le=>!te.some(qe=>qe.id===le.id))],ve=[];for(const le of se){const qe=Math.ceil((le.remaining_seconds??0)/60);ve.push({label:"Expiring soon",detail:`${le.title??ea(le.profile_id)} — ${qe} min remaining`,to:"/mandates",color:"var(--text-primary)"})}for(const le of Ne)ve.push({label:"Expired",detail:le.title??ea(le.profile_id),to:"/mandates",color:"var(--text-primary)"});ve.push(...Jw(B,G));for(const le of ie)ve.push({label:"Integration starting",detail:`${le.manifest.name} is coming up…`,to:"/integrations",color:"var(--text-primary)"});for(const le of B)le.authStatus==="failed"&&le.state!=="not-running"&&le.state!=="error"&&le.state!=="paused"&&ve.push({label:"Reconnect needed",detail:`${le.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--text-primary)"});return g||ve.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"})}),fe&&z&&(_?n.jsx(fw,{contact:T,hasDelegationMandate:X,otherMandateCount:Q,delegationProposalCount:Y,managed:O,simulationOn:G,mcpEndpoint:z}):!G&&n.jsx(uw,{aiConfigured:g,hasRunningIntegration:H.length>0,hasActiveAuth:pe.length>0,hasAgentConnected:M>0,mcpEndpoint:z})),!_&&n.jsxs(n.Fragment,{children:[n.jsx(Gw,{auths:s,activeCount:pe.length,waiting:ge,waitingReady:b}),n.jsx(Kw,{}),ve.length>0&&n.jsxs("section",{className:"card attention attention-quiet","aria-label":"Setup — needs attention",children:[n.jsxs("div",{className:"card-header",children:[n.jsx("h2",{className:"card-title",children:"Setup — needs attention"}),n.jsx("span",{className:"rb-count",children:ve.length})]}),n.jsx("div",{className:"attention-rows",children:ve.map((le,qe)=>n.jsxs(gt,{to:le.to,className:"attention-row",children:[n.jsx("span",{className:"attention-dot",style:{background:le.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:le.label}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:le.detail})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},qe))})]})]}),ue&&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:[ue.count," real system",ue.count===1?"":"s"," ",ue.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",ue.namesText,"."]})]}),n.jsx(qw,{}),n.jsx(h0,{})]})}const ej=["Scope & Limits","Intent","Sign"];function cp({currentStep:e,onStepClick:s}){const a=Sn();return n.jsxs("div",{className:"wizard-progress",children:[n.jsx("ol",{className:"wizard-steps",children:ej.map((o,l)=>{const u=l+2,f=u<e,g=u===e,p=u-1<e,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 tj({profileId:e,bounds:s,groupName:a,domain:o,onSwitch:l}){return n.jsxs("div",{className:"context-strip",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"context-strip-label",children:"Team:"}),n.jsxs("span",{children:[n.jsx("strong",{children:a}),o?` / ${o}`:""]})]}),e&&n.jsxs("span",{children:[n.jsx("strong",{children:"Profile:"})," ",Mt(e)]}),s&&n.jsxs("span",{children:[n.jsx("strong",{children:"Bounds:"})," ",s]}),l&&n.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:l,children:"Switch"})]})}function nj({integrationId:e,field:s,value:a,onChange:o,disabled:l,onLabels:u}){const[f,g]=h.useState(null),[p,v]=h.useState(null),[y,w]=h.useState(!0);h.useEffect(()=>{let k=!1;return L.discoverScopeField(e,s).then(S=>{var N;k||(g(S.options),w(!1),(N=S.options)!=null&&N.length&&(u==null||u(Object.fromEntries(S.options.map(T=>[T.value,T.label])))))}).catch(S=>{k||(v(S instanceof Error?S.message:String(S)),w(!1))}),()=>{k=!0}},[e,s]);const x=new Set(a.split(",").map(k=>k.trim()).filter(Boolean)),b=k=>{const S=new Set(x);S.has(k)?S.delete(k):S.add(k),o(Array.from(S).join(","))};return y?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):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:k=>o(k.target.value),disabled:l})]}):f.length===0?n.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:f.map(k=>{const S=k.extras??{},N=typeof S.access=="string"?S.access:void 0,T=N==="reader",E=S.primary===!0;return n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:T?"var(--text-tertiary)":"var(--text-primary)",cursor:l||T?"not-allowed":"pointer"},title:T?"Read-only — you can authorize list/read but not writes":void 0,children:[n.jsx("input",{type:"checkbox",checked:x.has(String(k.value)),onChange:()=>b(String(k.value)),disabled:l||T}),n.jsx("span",{children:k.label||k.value}),E&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),N&&n.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",N]})]},k.value)})})}function Kc(e){if(e.type!=="number")return 0;const s=e.boundType,a=e.unit;return(s==null?void 0:s.kind)==="per_transaction"&&a==="count"?1:0}function mh(e,s){if(s!==void 0)return String(s);const a=e.default;return typeof a=="string"||typeof a=="number"&&Number.isFinite(a)?String(a):Kc(e)===1?"1":""}function vc(e){const s=e.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function ph(e,s){const a=Kc(e),o=vc(e),l=s===""?a:Math.max(a,Number(s));return o!==void 0?Math.min(o,l):l}function rj(e,s){var o;const a=(o=e.capKinds)==null?void 0:o[s];return a||(e.approvers.length>0?"approval":"hard")}function qc(e,s,a){var o;return e.approvers.length===0||(s==null?void 0:s.enforcedBy)==="gatekeeper"||((o=s==null?void 0:s.boundType)==null?void 0:o.kind)==="enum"?"hard":rj(e,a)}function up(e,s,a){const o=e.indexOf(s),l=e.indexOf(a);return o===-1||l===-1?!1:l<o}function Wi(e,s){var a;return((a=e.caps)==null?void 0:a[s])!==void 0}function sj(e,s,a){const o=Object.entries(s.caps??{}).filter(([u])=>qc(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?e[v]:void 0;if(typeof f=="number"&&typeof y=="number"&&y>f)return{field:u,fieldLabel:l(u),cap:f,value:y}}if(o.length===1){const[u,f]=o[0];return{field:u,fieldLabel:l(u),cap:f}}return null}function aj(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Yc(e,s){return s.displayName?s.displayName:e.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function ij(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function oj(e){var a;const s=e;return!!(s.enum&&((a=s.constraint)!=null&&a.enforceable.includes("subset")))}function gh(e,s){const a=e.trim();return a?s==="email"?a.includes("@")&&a.indexOf(".",a.indexOf("@"))>-1:s==="domain"?a.includes(".")&&!a.includes("@"):!0:!1}function lj(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function cj(e){return e?e==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:e==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:e==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:e==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:e.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function uj(e,s){if(!e||!s)return"";const a=Number(e);if(!Number.isFinite(a)||a<=0)return"";if(s==="minutes"&&a>=60){const o=Math.floor(a/60),l=a%60;return l===0?`${o} hour${o!==1?"s":""}`:`${o}h ${l}m`}if(s==="hours"&&a>=24&&a%24===0){const o=a/24;return`${o} day${o!==1?"s":""}`}if(s==="days"){if(a>=30&&a%30===0)return`${a/30} month${a/30!==1?"s":""}`;if(a>=7&&a%7===0)return`${a/7} week${a/7!==1?"s":""}`}return""}function dj({id:e,value:s,onChange:a,disabled:o,placeholder:l,unit:u,min:f=0,max:g}){const p=lj(u),v=cj(u).filter(S=>g===void 0||S.value<=g),y=ro(u),w=uj(s,u),x=s===""?null:Number(s),b=()=>{const S=s===""?0:Number(s),N=S%p,T=N===0?S+p:S+(p-N);a(String(g!==void 0?Math.min(g,T):T))},k=()=>{const S=s===""?0:Number(s);if(S<=f)return;const N=S%p,T=N===0?S-p:S-N;a(String(Math.max(f,T)))};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:k,disabled:o||s===""||Number(s)<=f,"aria-label":"Decrease",children:"−"}),n.jsx("input",{id:e,className:"stepper-input",type:"number",min:f,max:g,step:p,value:s,placeholder:l??String(f),onChange:S=>{const N=S.target.value;a(g!==void 0&&N!==""&&Number(N)>g?String(g):N)},onFocus:S=>S.target.select(),disabled:o}),n.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:b,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${x===S.value?" preset-chip-selected":""}`,onClick:()=>a(String(S.value)),children:S.label},S.value))}),w&&n.jsxs("div",{className:"bounded-input-echo",children:["≈ ",w]})]})}function yh({htmlFor:e,label:s,description:a}){const[o,l]=h.useState(!1);return n.jsxs("div",{className:"field-label-with-tip",children:[n.jsx("label",{className:"form-label",htmlFor:e,children:s}),a&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${s}" mean?`,"aria-expanded":o,onClick:()=>l(u=>!u),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onBlur:()=>l(!1),children:"i"}),o&&n.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:a})]})]})}function fj({id:e,value:s,onChange:a,disabled:o,format:l,placeholder:u}){const[f,g]=h.useState(""),[p,v]=h.useState(!1),y=h.useRef(null),w=s?s.split(",").map(T=>T.trim()).filter(Boolean):[],x=T=>{const E=T.trim();if(!E)return;if(!gh(E,l)){v(!0);return}v(!1);const P=w.includes(E)?w:[...w,E];a(P.join(",")),g("")},b=T=>{const E=w.filter((P,I)=>I!==T);a(E.join(","))},k=T=>{T.key==="Enter"||T.key===","||T.key==="Tab"?f.trim()&&(T.preventDefault(),x(f)):T.key==="Backspace"&&!f&&w.length>0&&b(w.length-1)},S=T=>{const E=T.clipboardData.getData("text");if(E.includes(",")){T.preventDefault();const I=E.split(",").map(M=>M.trim()).filter(Boolean).filter(M=>gh(M,l)),B=[...new Set([...w,...I])];a(B.join(",")),g(""),v(!1)}},N=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 T;return(T=y.current)==null?void 0:T.focus()},children:[w.map((T,E)=>n.jsxs("span",{className:"tag-pill",children:[T,!o&&n.jsx("button",{type:"button",className:"tag-remove",onClick:P=>{P.stopPropagation(),b(E)},"aria-label":`Remove ${T}`,children:"×"})]},T)),!o&&n.jsx("input",{ref:y,id:e,className:"tag-input-field",type:"text",value:f,onChange:T=>{g(T.target.value),v(!1)},onKeyDown:k,onPaste:S,onBlur:()=>{f.trim()&&x(f)},placeholder:w.length===0?u??N:""})]})}function hj({id:e,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:e,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 vh({fieldKey:e,fieldDef:s,value:a,onChange:o,prefix:l,readOnly:u,twoColumn:f,discoveryIntegrationId:g,onLabels:p,capMax:v,enumAllowedFrom:y}){const w=Yc(e,s),x=`${l}-field-${e}`,b=n.jsx(n.Fragment,{children:oj(s)?n.jsx(hj,{id:x,options:s.enum,value:a,onChange:k=>o(e,k),disabled:u}):(()=>{const k=s.boundType;return(k==null?void 0:k.kind)==="enum"&&Array.isArray(k.values)})()?n.jsxs("select",{id:x,className:"form-select",value:a,onChange:k=>o(e,k.target.value),disabled:u||y!==void 0&&s.boundType.values.length-y<=1,children:[n.jsx("option",{value:"",children:"Select..."}),s.boundType.values.map((k,S)=>n.jsx("option",{value:k,disabled:y!==void 0&&S<y,children:k},k))]}):s.enum?n.jsxs("select",{id:x,className:"form-select",value:a,onChange:k=>o(e,k.target.value),disabled:u,children:[n.jsx("option",{value:"",children:"Select..."}),s.enum.map(k=>n.jsx("option",{value:k,children:k},k))]}):s.type==="number"?n.jsx(dj,{id:x,value:a,onChange:k=>o(e,k),disabled:u,unit:s.unit,min:Kc(s),max:v!==void 0?Math.min(v,vc(s)??v):vc(s)}):ij(s)?n.jsx(fj,{id:x,value:a,onChange:k=>o(e,k),disabled:u,format:s.format}):g?n.jsx(nj,{integrationId:g,field:e,value:a,onChange:k=>o(e,k),disabled:u,onLabels:k=>p==null?void 0:p(e,k)}):n.jsx("input",{id:x,className:"form-input",type:"text",value:a,onChange:k=>o(e,k.target.value),disabled:u})});return f?n.jsxs("div",{className:"bounds-field-row",children:[n.jsx("div",{className:"bounds-field-label",children:n.jsx(yh,{htmlFor:x,label:w,description:s.description})}),n.jsx("div",{className:"bounds-field-input",children:b})]},`${l}-${e}`):n.jsxs("div",{className:"form-group",children:[n.jsx(yh,{htmlFor:x,label:w,description:s.description}),b]},`${l}-${e}`)}function mj(e,s,a,o){if(!o||!Wi(o,e))return null;const l=o.caps[e],u=qc(o,s,e);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"?up(g.values??[],l,a):!1}return{kind:u,cap:l,violating:f}}function xh(e,s,a,o){if(!o||!Wi(o,e))return a;const l=qc(o,s,e),u=o.caps[e];if(l!=="hard")return a;if(typeof u=="number"){const f=a===""?NaN:Number(a);return String(Number.isNaN(f)?u:Math.min(f,u))}if(typeof u=="string"){const f=s.boundType,g=(f==null?void 0:f.kind)==="enum"?f.values??[]:[];return a!==""&&up(g,u,a)?u:a}return a}function pj(e,s){if(typeof s!="string")return;const a=e.boundType;if((a==null?void 0:a.kind)!=="enum")return;const o=(a.values??[]).indexOf(s);return o===-1?void 0:o}function gj(e,s){return ro(s.unit)||Yc(e,s).toLowerCase()}function dp(e,s){if(s&&s.length>0)return s.join(" or ");const a=(e==null?void 0:e.approvers)??[];return a.length>0?a.join(" or "):"your team's approvers"}function yj(e,s,a,o,l){var v;const u=s.enforcedBy==="gatekeeper",f=((v=s.boundType)==null?void 0:v.kind)==="enum";if(a.kind==="hard")return f?n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Disabled by your team's policy — ",Yc(e,s).toLowerCase()," is capped at"," ",String(a.cap)," for this profile."]}):n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Team limit ",String(a.cap),u?" — read limits are always hard, no approval path exists for this cap.":""]});const g=gj(e,s),p=dp(o,l);return n.jsxs("span",{className:"cap-note soft","data-testid":`cap-note-${e}`,children:["Every ",g," above ",String(a.cap)," goes to ",p," for approval."]})}function vj({profile:e,onConfirm:s,onCancel:a,readOnly:o,initialBounds:l,initialContext:u,initialFrame:f,profileConfig:g,approverNames:p,adminName:v}){var te;const y=e.boundsSchema,w=e.scopeSchema,x=H=>!!g&&Wi(g,H),b=y?Object.entries(y.fields).filter(([H,ie])=>!(H==="profile"||H==="path"||ie.enforced===!1||ie.enforcedBy==="gatekeeper"&&!x(H))):[],k=y?Object.entries(y.fields).filter(([H,ie])=>ie.enforcedBy==="gatekeeper"&&!x(H)).filter(([,H])=>H.enforced!==!1).map(([H,ie])=>ie.displayName??H):[],S=w&&w.keyOrder.length>0?Object.entries(w.fields):[],N=l??f??{},T=u??{},E={};for(const[H,ie]of b)E[H]=xh(H,ie,mh(ie,N[H]),g);const P={};for(const[H]of S)P[H]=T[H]!==void 0?String(T[H]):"";const[I,B]=h.useState(E),[M,q]=h.useState(P),[z,U]=h.useState({}),Z=h.useRef(new Set);h.useEffect(()=>{B(H=>{let ie=!1;const ue={...H};for(const[ge,ve]of b){if(Z.current.has(ge))continue;const le=H[ge]!==void 0?H[ge]:mh(ve,N[ge]),qe=xh(ge,ve,le,g);ue[ge]!==qe&&(ue[ge]=qe,ie=!0)}return ie?ue:H})},[g]);const[G,O]=h.useState(null);h.useEffect(()=>{const H=aj(e.id);L.getIntegrationManifests().then(({manifests:ie})=>{const ue=ie.find(ge=>ge.profile===H&&ge.contextDiscovery&&Object.keys(ge.contextDiscovery).length>0);O(ue??null)}).catch(()=>O(null))},[e.id]);const ne={};for(const[H,ie]of b)ne[H]=mj(H,ie,I[H]??"",g);const fe=Object.entries(ne).filter(([,H])=>(H==null?void 0:H.kind)==="hard"&&H.violating).map(([H])=>H),ee=!!g&&(((te=g.approvers)==null?void 0:te.length)??0)>0&&b.every(([H])=>!Wi(g,H)),pe=(H,ie)=>{Z.current.add(H),B(ue=>({...ue,[H]:ie}))},Ne=(H,ie)=>{q(ue=>({...ue,[H]:ie}))},X=()=>{const H={profile:e.id};for(const[ue,ge]of b)ge.type==="number"?H[ue]=ph(ge,I[ue]):H[ue]=I[ue];const ie={};for(const[ue,ge]of S)ge.type==="number"?ie[ue]=M[ue]===""?0:Number(M[ue]):ie[ue]=M[ue];return[H,ie]},Q=()=>{const[H,ie]=X();s(H,ie,z)},Y=()=>{var ge;const H={...I};for(const ve of fe){const le=(ge=ne[ve])==null?void 0:ge.cap;le!==void 0&&(H[ve]=String(le))}B(H);const ie={profile:e.id};for(const[ve,le]of b)le.type==="number"?ie[ve]=ph(le,H[ve]??""):ie[ve]=H[ve]??"";const ue={};for(const[ve,le]of S)le.type==="number"?ue[ve]=M[ve]===""?0:Number(M[ve]):ue[ve]=M[ve];s(ie,ue,z)},A=()=>{if(!ee)return null;const H=dp(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: ",H]}),n.jsxs("div",{children:["No caps are set on this profile, so ",H," 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(fe.length===0)return null;const H=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 ",H," 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:Y,children:"Save below cap"}),a&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:a,children:"Cancel"})]})]})},se=fe.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(([H,ie])=>{var ge;const ue=!!((ge=G==null?void 0:G.contextDiscovery)!=null&&ge[H]);return n.jsx(vh,{fieldKey:H,fieldDef:ie,value:M[H],onChange:Ne,prefix:"context",readOnly:o,discoveryIntegrationId:ue?G.id:void 0,onLabels:(ve,le)=>U(qe=>({...qe,[ve]:le}))},`context-${H}`)})]}),b.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:b.map(([H,ie])=>{const ue=ne[H];return n.jsxs("div",{style:{display:"contents"},children:[n.jsx(vh,{fieldKey:H,fieldDef:ie,value:I[H],onChange:pe,prefix:"bounds",readOnly:o,twoColumn:!0,capMax:(ue==null?void 0:ue.kind)==="hard"&&typeof ue.cap=="number"?ue.cap:void 0,enumAllowedFrom:(ue==null?void 0:ue.kind)==="hard"?pj(ie,ue.cap):void 0}),ue&&n.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:yj(H,ie,ue,g,p)})]},`bounds-${H}`)})}),A(),_(),k.length>0&&n.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[k.join(", ")," ",k.length===1?"is":"are"," set on the integration, not here — reads are checked on this device, so the limit applies immediately and can be changed any time under"," ",n.jsx(gt,{to:"/integrations",children:"Integrations"}),"."]})]}),n.jsx("button",{className:"btn btn-primary",onClick:Q,disabled:se,style:{marginTop:"0.5rem"},children:o?"Next: Gates":"Next: Problem Statement"})]})}function xj(e){var a;const s=e.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((a=s==null?void 0:s[1])==null?void 0:a.trim())??null}function wj(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const jj="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 Hi({target:e,currentText:s,onApply:a,greeting:o,placeholder:l,title:u}){const[f,g]=h.useState([{role:"assistant",content:o??jj}]),[p,v]=h.useState(""),[y,w]=h.useState(!1),[x,b]=h.useState(null),k=h.useRef(null),S=h.useRef(null);h.useEffect(()=>{const E=k.current;if(!E)return;const P=f[f.length-1],I=S.current;!y&&(P==null?void 0:P.role)==="assistant"&&f.length>1&&I?E.scrollTop=I.offsetTop:E.scrollTop=E.scrollHeight},[f,y]);const N=async()=>{const E=p.trim();if(!E||y)return;const P=[...f,{role:"user",content:E}];g(P),v(""),b(null),w(!0);try{const I=await L.aiChat({target:e,currentText:s,messages:P.filter((B,M)=>!(M===0&&B.role==="assistant"))});I.success&&I.reply?g(B=>[...B,{role:"assistant",content:I.reply}]):b(I.error??"AI returned no reply")}catch(I){b(I instanceof Error?I.message:"Chat failed")}finally{w(!1)}},T=E=>{E.key==="Enter"&&!E.shiftKey&&!E.nativeEvent.isComposing&&(E.preventDefault(),N())};return n.jsxs("div",{className:"intent-chat",children:[n.jsx("h3",{className:"card-title",children:u??"AI Assistant"}),n.jsxs("div",{ref:k,className:"chat-messages",children:[f.map((E,P)=>{const I=E.role==="assistant"?xj(E.content):null,B=I?wj(E.content):E.content;return n.jsx("div",{className:`chat-msg ${E.role}`,ref:P===f.length-1?S:void 0,children:n.jsxs("div",{className:"chat-msg-body",children:[B&&n.jsx("div",{className:"chat-msg-prose",children:B}),I!==null&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{className:"chat-fenced-block",children:I}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>a(I),children:"Apply this draft"})]})]})},P)}),y&&n.jsx("div",{className:"chat-msg assistant",children:n.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),x&&n.jsx("div",{className:"error-message",children:x}),n.jsxs("div",{className:"chat-composer",children:[n.jsxs("div",{className:"chat-composer-pill",children:[n.jsx("textarea",{className:"chat-input",value:p,onChange:E=>v(E.target.value),onKeyDown:T,placeholder:l??"Ask for help articulating the intent…",rows:1,disabled:y}),n.jsx("button",{type:"button",className:"chat-send-btn",onClick:N,disabled:y||!p.trim(),"aria-label":"Send",children:"↑"})]}),n.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function fp({open:e,onClose:s,children:a,ariaLabel:o}){const l=h.useRef(null),u=h.useRef(null);return h.useEffect(()=>{var g;if(!e)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()}},[e,s]),Lx.createPortal(n.jsxs(n.Fragment,{children:[n.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:s,"aria-hidden":"true"}),n.jsxs("aside",{ref:l,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":o,tabIndex:-1,children:[n.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),n.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:s,"aria-label":"Close",children:"×"}),a]})]}),document.body)}function Sj(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bj(e,s,a){if(s.length===0)return[{text:e,label:e,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 w,x;return((w=y.scope)==null?void 0:w.toLowerCase())===v||((x=y.scope)==null?void 0:x.split(",").map(b=>b.trim().toLowerCase()).includes(v))})},f=["\\[\\d+\\]",...o.map(Sj)],g=new RegExp(`(${f.join("|")})`,"gi");return e.split(g).filter(p=>p!=="").map(p=>{const v=/^\[(\d+)\]$/.exec(p);if(v){const y=s[Number(v[1])-1];if(y){const w=y.scope&&y.scope!=="all (unscoped)"?y.scope:"all recipients",x=a?`${a}: ${w}`:w;return{text:p,label:x,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 wh=`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 kj(e,s,a,o){return bj(e,s,o).map((l,u)=>{if(!l.matched)return n.jsx("span",{children:l.text},u);const f=l.matched;return n.jsx("button",{type:"button",onClick:()=>a(f),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:l.label},u)})}function Nj(){var be;const e=Sn(),[s]=gs(),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),[w,x]=h.useState(null),[b,k]=h.useState({}),[S,N]=h.useState(wh),[T,E]=h.useState(!1),[P,I]=h.useState(null),[B,M]=h.useState(!0),[q,z]=h.useState(null),[U,Z]=h.useState([]),[G,O]=h.useState(void 0),[ne,fe]=h.useState(!1),[ee,pe]=h.useState(null),[Ne,X]=h.useState(null),[Q,Y]=h.useState(null),[A,_]=h.useState([]),[se,te]=h.useState(null);h.useEffect(()=>{var Ue;const oe=sessionStorage.getItem("agentAuth");if(!oe){e("/mandates?new=1");return}const Le=JSON.parse(oe);l(Le),Le.intentHint&&N(Le.intentHint),L.getCredential("ai-config").then(we=>I(we.configured)).catch(()=>I(!1));const ze=sessionStorage.getItem("agentGate");if(ze){const we=JSON.parse(ze);we.bounds&&y(we.bounds),we.context&&x(we.context),(Ue=we.gateContent)!=null&&Ue.intent&&N(we.gateContent.intent)}L.getProfile(Le.profileId).then(we=>f(we)).catch(()=>e("/mandates?new=1")).finally(()=>M(!1)),Le.groupId&&Promise.all([L.getTeamProfileConfig(Le.groupId,Le.profileId).catch(()=>null),L.getGroupById(Le.groupId).catch(()=>null),L.listUsers().catch(()=>[])]).then(([we,nt,Ze])=>{if(z(we),we){const Ye=new Map;for(const Fe of Ze){const me=Fe.name&&Fe.email?`${Fe.name} (${Fe.email})`:Fe.name||Fe.email||Fe.id;Ye.set(Fe.id,me)}const We=(nt==null?void 0:nt.members)??[];for(const Fe of We){const me=Fe.userId??Fe.id;me&&(Fe.name&&Fe.email?Ye.set(me,`${Fe.name} (${Fe.email})`):Fe.name&&Ye.set(me,Fe.name))}const dt=(we.approvers??[]).map(Fe=>Ye.get(Fe)??Fe);Z(dt);const ft=We.find(Fe=>Fe.role==="admin");if(ft){const Fe=ft.userId??ft.id;Fe&&O(Ye.get(Fe)??ft.name)}}})},[e]);const H=v?Object.entries(v).filter(([oe])=>oe!=="profile"&&oe!=="path").map(([oe,Le])=>`${oe} = ${Le}`).join(", "):"",ie=(oe,Le,ze)=>{y(oe),x(Le),ze&&k(ze),p(3)},ue=S.trim()!==wh.trim()&&S.trim()!=="",ge=oe=>{ue&&!confirm("Replace your current intent with the AI draft?")||N(oe)},ve=()=>{const oe=u==null?void 0:u.ttl,Le={intent:S},ze=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...ze,bounds:v,context:w,contextLabels:b,gateContent:Le,ttlConfig:oe})),e("/mandates/new/sign")},le=async()=>{if(o){fe(!0),pe(null),X(null),Y(null),_([]),te(null);try{const oe=await L.aiIntentReview({profileId:o.profileId,newIntent:S,context:w??void 0});_(oe.grants??[]),oe.success?oe.review?pe(oe.review):X(oe.note??"No other mandates on this profile to compare against."):Y(oe.error??"Check failed.")}catch(oe){Y(oe instanceof Error?oe.message:"Check failed.")}finally{fe(!1)}}},qe=oe=>{N(oe),(ee||Ne||Q)&&(pe(null),X(null),Y(null),_([]),te(null))};return B||!o||!u?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):n.jsxs(n.Fragment,{children:[n.jsx(cp,{currentStep:g,onStepClick:oe=>{oe>=2&&p(oe)}}),n.jsx(tj,{profileId:o.profileId,bounds:H||void 0,groupName:o.groupName,domain:o.domain}),g===2&&n.jsx("div",{className:"card",children:n.jsx(vj,{profile:u,onConfirm:ie,onCancel:()=>e("/mandates?new=1"),initialBounds:v||void 0,initialContext:w||void 0,profileConfig:q,approverNames:U,adminName:G})}),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(Hi,{target:{kind:"intent",profileId:o.profileId,bounds:H||void 0},currentText:S,onApply:ge})}),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:oe=>qe(oe.target.value)}),n.jsxs("div",{className:"char-counter",children:[S.length," / 2000"]})]}),P===!1&&n.jsxs("p",{className:"intent-ai-hint",children:[n.jsx(gt,{to:"/settings",children:"Set up an AI assistant in Settings"})," to get help writing this."]}),P&&n.jsxs("div",{style:{marginTop:"0.5rem"},children:[n.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:le,disabled:ne||!ue,children:ne?"Checking…":"Check against my other grants"}),Q&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeft:"3px solid var(--text-primary)"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),n.jsx("div",{className:"hint-body",children:Q})]}),Ne&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsx("div",{className:"hint-body",children:Ne})]}),ee&&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:kj(ee,A,te,Mt(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:ve,disabled:!ue,children:"Continue to Review"})]}),(((be=q==null?void 0:q.approvers)==null?void 0:be.length)??0)>0&&n.jsxs("div",{className:"hint-box",role:"note",children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:[n.jsxs("div",{className:"hint-head",children:["Visible to ",U.length>0?U.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",U.length>0?U.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),P&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"floating-help",onClick:()=>E(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),n.jsx(fp,{open:T,onClose:()=>E(!1),ariaLabel:"Intent assistant",children:n.jsx(Hi,{target:{kind:"intent",profileId:o.profileId,bounds:H||void 0},currentText:S,onApply:oe=>{ge(oe),E(!1)}})})]}),se&&n.jsx("div",{className:"modal-backdrop",onClick:oe=>oe.target===oe.currentTarget&&te(null),children:n.jsxs("div",{className:"modal",children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{className:"modal-title",children:se.length>1?`Existing mandates (${se.length})`:"Existing mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>te(null),children:"×"})]}),n.jsx("div",{className:"modal-body",children:se.map((oe,Le)=>{var ze;return n.jsxs("div",{style:{marginBottom:Le<se.length-1?"1rem":0,paddingBottom:Le<se.length-1?"1rem":0,borderBottom:Le<se.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:oe.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:((ze=oe.intent)==null?void 0:ze.trim())||"(no intent recorded)"}),Object.entries(oe.bounds).filter(([Ue])=>Ue!=="profile"&&Ue!=="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(oe.bounds).filter(([Ue])=>Ue!=="profile"&&Ue!=="path").map(([Ue,we])=>`${Ue}: ${we}`).join(" · ")})]})]},Le)})})]})})]})]})}function Cj(e){return e.normalize("NFC").replace(/\r\n?/g,`
74
+ `).split(`
75
+ `).map(l=>l.replace(/[ \t]+$/,"")).join(`
76
+ `).replace(/\n+$/,"")}async function Jc(e){const a=new TextEncoder().encode(e),o=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(o)).map(u=>u.toString(16).padStart(2,"0")).join("")}class Ej extends Error{constructor(a,o,l){super(l);Qs(this,"code");Qs(this,"field");this.name="CanonicalValueError",this.code=a,this.field=o}}function Tj(e){const s=new TextEncoder().encode(e);let a="";for(const o of s)o===61||o===37||o<32||o>126?a+="%"+o.toString(16).toUpperCase().padStart(2,"0"):a+=String.fromCharCode(o);return a}function hp(e,s,a){const o=[];for(const l of s){const u=e[l];if(u==null)continue;const f=String(u);if(f.includes(`
77
+ `)||f.includes("\r"))throw new Ej(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}=${Tj(f)}`)}return o.join(`
78
+ `)}async function zi(e,s){const a=s.boundsSchema;if(!a)throw new Error("Profile has no boundsSchema");const o=hp(e,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await Jc(o)}`}async function mp(e,s){const a=s.scopeSchema?hp(e,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await Jc(a)}`}function xc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":xc(l)).join(",")+"]";const s=e,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+xc(l))}return"{"+a.join(",")+"}"}async function pp(e){return`sha256:${await Jc(xc(e))}`}async function Vi(e){const s=new TextEncoder().encode(Cj(e)),a=await crypto.subtle.digest("SHA-256",s);return`sha256:${Array.from(new Uint8Array(a)).map(u=>u.toString(16).padStart(2,"0")).join("")}`}function gp(e,s){if(!e.authorization_id)throw new Error("Signing result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:e.authorization_id,boundsHash:e.bounds_hash??s.boundsHash,contextHash:s.contextHash,context:s.context,...s.contextLabels&&Object.keys(s.contextLabels).length>0?{contextLabels:s.contextLabels}:{},gateContent:s.gateContent,...s.path?{path:s.path}:{}}}function Aj(e){const s=e.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(a=>s.includes(a)):[]}function Ij(e){return e==="per-action"?"review":"automatic"}function jh(e){return e?Aj(e).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function Rj(e,s){return s.includes(e)?e:s[0]??null}function Sh(e){return e==null?new Set:new Set(String(e).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function Pj(e,s){for(const a of e)if(s.has(a))return!0;return!1}function $j(e,s,a){for(const o of e){const l=Sh(s[o]),u=Sh(a[o]);if(!(l.size===0||u.size===0)&&!Pj(l,u))return!1}return!0}function _j(e){return e.length>24?`${e.slice(0,10)}…`:e}function yp(e,s,a){const o=a==null?void 0:a[e];return String(s).split(",").map(u=>u.trim()).filter(Boolean).map(u=>{const f=o==null?void 0:o[u];return f?`${f} (${_j(u)})`:u}).join(", ")}function vp(e){var l;if(e.isPersonal)return{can:!0};if(!e.configLoaded)return{can:!0};const s=e.teamName?`"${e.teamName}"`:"this team";return e.grantors!=="all"&&(((l=e.grantors)==null?void 0:l.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${s}.`,fix:`Ask an admin of ${s} to enable ${e.profileName} and name who may give its mandates.`}:e.grantors==="all"||!!e.userId&&e.grantors.includes(e.userId)?{can:!0}:{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${e.profileName}'s grantors in ${s} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}}const Gi=500,Lj=["Lower the discount","Other recipient","Shorter","Different wording"];function Qc(e){const s=e.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>Gi?{valid:!1,error:`At most ${Gi} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function zj(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xp(e,s){return e.toLowerCase().includes(s.toLowerCase())}function Fj(e,s){const a=e.trim();if(a.length===0)return s;if(!xp(a,s))return`${a}. ${s}`;const o=new RegExp(`\\.?\\s*${zj(s)}\\.?`,"i");return a.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function wp(){return{outcome:"rejected"}}function Mj(e){const s=Qc(e);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function bh(){return{outcome:"replaced"}}function Oj(e,s){if((e.pendingApprovers??[]).includes(s))return{route:"approver"};const a=e.pendingDomains??[];return a.includes(s)?{route:"resolve",domain:s}:a.includes("owner")?{route:"resolve",domain:"owner"}:null}const Bj={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function Dj(e,s){const a=e.rejectedBy??e.approverRejectedBy;if(!a)return null;const o=a.outcome??"rejected",l=a.note??("reason"in a?a.reason:void 0);return{kind:Bj[o],who:a.userId===s?"You":a.userId,at:a.at,note:l}}function Uj(e){return e.refusal?{kind:"REFUSED",at:e.refusal.at,message:e.refusal.message}:null}function Wj(){var Oe,K;const e=Sn(),{user:s,mode:a,domain:o}=wt(),[l,u]=h.useState(null),[f,g]=h.useState(null),[p,v]=h.useState(null),[y,w]=h.useState("per-action"),[x,b]=h.useState(1800),[k,S]=h.useState(86400),[N,T]=h.useState(""),[E,P]=h.useState("hours"),[I,B]=h.useState(""),[M,q]=h.useState(!0),[z,U]=h.useState(!1);h.useEffect(()=>{L.getIdentityDisclosure().then(J=>U(J.always)).catch(()=>{})},[]);const[Z,G]=h.useState(!1),[O,ne]=h.useState(""),[fe,ee]=h.useState(null),[pe,Ne]=h.useState([]),[X,Q]=h.useState(!1),[Y,A]=h.useState([]),[_,se]=h.useState(0);h.useEffect(()=>{var Ot;const J=sessionStorage.getItem("agentAuth"),ye=sessionStorage.getItem("agentGate");if(!J||!ye){e("/mandates?new=1");return}const He=JSON.parse(J),Ve=JSON.parse(ye),rt={bounds:Ve.bounds??{},context:Ve.context??{},contextLabels:Ve.contextLabels??void 0,gateContent:Ve.gateContent};u(He),g(rt),Ve.ttlConfig&&(b(Ve.ttlConfig.default??1800),S(Ve.ttlConfig.max??86400)),Ve.templateMode==="automatic"?w("immediate"):Ve.templateMode==="review"&&w("per-action");const Ht=((Ot=Ve.ttlConfig)==null?void 0:Ot.max)??86400;if(typeof Ve.templateTtl=="number"&&Ve.templateTtl>0){const et=Math.min(Ve.templateTtl,Ht);b(et),[3600,86400,604800,2592e3,31536e3].includes(et)||(et%86400===0?(T(String(et/86400)),P("days")):(T(String(Math.max(1,Math.round(et/3600)))),P("hours")))}L.getProfile(He.profileId).then(et=>{var W;if(v(et),!I){const xe=et.name??((W=He.profileId.split("/").pop())==null?void 0:W.replace(/@.*$/,""))??"",Ae=[];if(rt.context&&et.scopeSchema)for(const yt of et.scopeSchema.keyOrder){const Ke=rt.context[yt];if(Ke!==void 0&&Ke!==""){const Nt=String(Ke).split(",").map(St=>St.trim()).filter(Boolean);Ae.push(Nt.join(", "))}}const st=Ae.length>0?`${xe}: ${Ae.join(" · ")}`:xe;B(st)}}).catch(()=>{}),He.isPersonal?Q(!0):Promise.all([L.getTeamProfileConfig(He.groupId,He.profileId).catch(()=>null),L.getGroupById(He.groupId).catch(()=>null),L.listUsers().catch(()=>[])]).then(([et,W,xe])=>{if(ee(et),et){const Ae=new Map;for(const Ke of xe){const Nt=Ke.name&&Ke.email?`${Ke.name} (${Ke.email})`:Ke.name||Ke.email||Ke.id;Ae.set(Ke.id,Nt)}const st=(W==null?void 0:W.members)??[];for(const Ke of st){const Nt=Ke.userId??Ke.id;Nt&&(Ke.name&&Ke.email?Ae.set(Nt,`${Ke.name} (${Ke.email})`):Ke.name&&Ae.set(Nt,Ke.name))}const yt=(et.approvers??[]).map(Ke=>Ae.get(Ke)??Ke);Ne(yt)}}).finally(()=>{Q(!0)})},[e]),h.useEffect(()=>{if(!(l!=null&&l.profileId))return;const J=l.profileId,ye=sessionStorage.getItem("agentEditReplaces");L.getEnrichedAuthorizations().then(He=>{const Ve=He.filter(rt=>rt.profileId===J&&rt.authorizationId!==ye).map(rt=>({authorizationId:rt.authorizationId,bounds:rt.bounds,context:rt.context??{},intent:rt.intent}));A(Ve)}).catch(()=>A([]))},[l==null?void 0:l.profileId]),h.useEffect(()=>{if(!p)return;const J=Rj(y,jh(p));J&&J!==y&&w(J)},[p,y]),h.useEffect(()=>{if(!f||!p||Y.length===0){se(0);return}let J=!1;return(async()=>{const ye=await zi(f.bounds,p),He=await Promise.all(Y.map(Ve=>zi(Ve.bounds,p).catch(()=>null)));J||se(He.filter(Ve=>Ve===ye).length)})().catch(()=>{J||se(0)}),()=>{J=!0}},[f,p,Y]);const te=async()=>{if(!(!l||!f||!p||!s)){if(!l.groupId){ne("No active group; cannot create mandate.");return}G(!0),ne("");try{const J=o||l.domain||"owner",ye=await zi(f.bounds,p),He=await mp(f.context,p),[Ve,rt]=await Promise.all([Vi(f.gateContent.intent),Vi(JSON.stringify({profile:l.profileId,domain:J,group:l.groupId}))]);let Ht,Ot,et,W;if(l.isTeam){const St=await L.getApproversPubkeys(l.groupId,l.profileId);if(St.length>0){const Xt=await L.encryptIntent(f.gateContent.intent,St);Ht=Xt.intentCiphertext,Ot=Xt.encryptedKeys,et=Xt.approversFrozen,W=Xt.intentDisclosureHash}}const xe=`authz_${crypto.randomUUID()}`,Ae=sessionStorage.getItem("agentEditReplaces")||void 0,st=sessionStorage.getItem("agentReplacesProposal")||void 0,yt=await pp(p),Ke=await L.attest({authorization_id:xe,replaces:Ae,profile_id:l.profileId,profile_hash:yt,supported_versions:["0.7"],bounds:f.bounds,bounds_hash:ye,scope_hash:He,domain:J,did:s.did,mandate_owners:[{did:s.did}],gate_content_hashes:{intent:Ve},execution_context_hash:rt,group_id:l.groupId,ttl:x,commitment_mode:Ij(y),title:I.trim(),intent_ciphertext:Ht,encrypted_keys:Ot,approvers_frozen:et,intent_disclosure_hash:W,disclose_identity:M});try{await L.pushGateContent(gp(Ke,{boundsHash:ye,contextHash:He,context:f.context,contextLabels:f.contextLabels,gateContent:f.gateContent}))}catch(St){try{await L.revokeAttestation(xe,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${St instanceof Error?St.message:"Unknown error"})`)}if(Ae)try{await L.revokeAttestation(Ae,`Replaced by ${xe} (edit)`),L.resyncGates().catch(()=>{})}catch{}let Nt="";if(st)try{const St=await L.getProposal(st);if(St.status==="pending"){const Xt=Oj(St,(s==null?void 0:s.id)??"");Xt?Xt.route==="approver"?await L.rejectProposal(st,bh()):await L.resolveProposal(st,"reject",Xt.domain,bh()):Nt="you are not one of the people who may decide it"}}catch(St){Nt=St instanceof Error?St.message:"unknown error"}if(sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),sessionStorage.removeItem("agentReplacesProposal"),Nt){ne(`Your mandate is signed and active. The AI's proposal could not be withdrawn (${Nt}) — reject it under Approvals.`);return}e(`/mandates?highlight=${encodeURIComponent(xe)}`)}catch(J){ne(J instanceof Error?J.message:"Signing the mandate failed")}finally{G(!1)}}};if(!l||!f)return n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const H=Object.entries(f.bounds).filter(([J])=>J!=="profile"&&J!=="path"),ie=Object.entries(f.context),ge=((fe==null?void 0:fe.caps)!=null?Object.keys(fe.caps):[]).length!==0,ve=pe.length>0?pe.join(", "):((fe==null?void 0:fe.approvers)??[]).join(", "),le=ge?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${ve}, 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.",qe=ge?`Over-cap actions will be reviewed by you and ${ve}. Within-cap actions run per the mode you chose above.`:`Approvers ${ve} can read your intent but won't gate any action — no caps configured on this profile.`,be=!!((Oe=fe==null?void 0:fe.approvers)!=null&&Oe.length),oe=vp({isPersonal:l.isPersonal,configLoaded:X,grantors:fe?Sm(fe):void 0,userId:s==null?void 0:s.id,profileName:Mt(l.profileId),teamName:l.groupName}),Le=!oe.can,ze=jh(p),Ue=ze.length===0,we=x>k,nt={flex:1,padding:"0.75rem",border:y==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:y==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Ze={flex:1,padding:"0.75rem",border:y==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius-md)",background:y==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Ye=((K=p==null?void 0:p.scopeSchema)==null?void 0:K.keyOrder)??[],We=Y.filter(J=>$j(Ye,f.context,J.context)),dt=We.length>0,ft=Mt(l.profileId),Fe=J=>{const ye=Object.values(J).map(He=>String(He).trim()).filter(Boolean);return ye.length>0?ye.join(", "):"all (unscoped)"},me=We.map(J=>Fe(J.context)).join("; "),Re=`This grant's scope overlaps an existing grant on ${ft} (scoped to: ${me}). 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(cp,{currentStep:4,onStepClick:J=>{J<=3&&e(`/mandates/new/intent?step=${J}`)}}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),l.upgradedFromProfileId&&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 ",Mt(l.profileId)," ",p.version," — the current version of this profile."]})]}),O&&n.jsx("div",{className:"error-message",children:O}),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. ${Mt(l.profileId)}: daily operations`,value:I,onChange:J=>B(J.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[ze.includes("per-action")&&n.jsxs("button",{onClick:()=>w("per-action"),style:Ze,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),ze.includes("immediate")&&n.jsxs("button",{onClick:()=>w("immediate"),style:nt,children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]}),ze.length===1&&n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:ze[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Ue&&n.jsx("div",{className:"msg-error",style:{fontSize:"0.75rem",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),n.jsxs("div",{className:"field-editable",children:[n.jsxs("div",{className:"field-label",children:[n.jsx("span",{className:"pen",children:"✎"})," Duration"]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter(J=>J.seconds<=k).map(J=>n.jsx("button",{onClick:()=>{b(J.seconds),T("")},style:{padding:"0.5rem 0.85rem",border:x===J.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:x===J.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:J.label},J.seconds)),n.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[n.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:N,onChange:J=>{T(J.target.value);const ye=parseInt(J.target.value,10);if(ye>0){const He=E==="days"?ye*86400:ye*3600;b(Math.min(He,k))}}}),n.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:E,onChange:J=>{P(J.target.value);const ye=parseInt(N,10);if(ye>0){const He=J.target.value==="days"?ye*86400:ye*3600;b(Math.min(He,k))}},children:[n.jsx("option",{value:"hours",children:"hours"}),n.jsx("option",{value:"days",children:"days"})]})]}),we&&n.jsxs("span",{className:"msg-error",style:{fontSize:"0.75rem"},children:["Maximum: ",k>=86400?`${Math.floor(k/86400)} days`:`${Math.floor(k/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:z||M,disabled:z,onChange:J=>q(J.target.checked),style:{marginTop:"0.15rem"}}),n.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",n.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.15rem"},children:['Adds "verified by Suveren" with your name to outgoing content. Takes effect only if your identity is verified; otherwise actions stay pseudonymous.',z&&" Always on — you chose this in Settings."]})]})]})}),n.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Intent"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:f.gateContent.intent})]}),(!!H.length||!!ie.length)&&n.jsxs("div",{className:"info-block",children:[n.jsxs("div",{className:"info-head",children:[n.jsx("span",{className:"info-title",children:"Scope & Limits"}),n.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),n.jsxs("dl",{className:"info-kv",children:[ie.map(([J,ye])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:J}),n.jsx("dd",{children:yp(J,ye,f.contextLabels)})]},J)),H.map(([J,ye])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:J}),n.jsx("dd",{children:String(ye)})]},J))]})]}),n.jsxs("div",{className:"info-block",children:[n.jsx("div",{className:"info-head",children:n.jsx("span",{className:"info-title",children:"Authority"})}),n.jsxs("dl",{className:"info-kv",children:[n.jsx("dt",{children:"Profile"}),n.jsxs("dd",{children:[Mt(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?oe.can?n.jsxs(n.Fragment,{children:[ve,n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:le})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"msg-error",children:oe.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${l.groupName??"this team"}`:"You cannot give this mandate"}),oe.code==="OWNER_NOT_APPROVER"&&n.jsx("div",{children:ve}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[oe.reason," ",oe.fix]})]}):n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),_>0?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),n.jsxs("div",{children:[_===1?`An active grant on ${ft} already has exactly these limits.`:`${_} active grants on ${ft} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",n.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,dt?n.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px dashed var(--border-strong)",borderLeft:"3px dashed var(--text-primary)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[n.jsx("span",{"aria-hidden":"true",style:{fontWeight:700},children:"!"}),n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,marginBottom:"0.2rem"},children:"Overlapping scope"}),n.jsx("div",{children:Re})]})]}):null,n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/mandates/new/intent"),children:"Back"}),n.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:te,disabled:Z||!I.trim()||Le||Ue,children:Z?"Signing...":y==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),n.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:be?"block":"none"},children:qe})]})]})}const Hj={card:"💳",mail:"✉️"};function jp(e){return Hj[e]??"🔧"}function Sp(e){var a;const s=[e.profile];for(const o of Object.values(((a=e.toolGating)==null?void 0:a.overrides)??{})){const l=o==null?void 0:o.profile;l&&!s.includes(l)&&s.push(l)}return s}function kh(e,s){const a=new Map;for(const o of e)for(const l of Sp(o.manifest)){let u=a.get(l);u||(u={shortId:l,icon:Pr(l),name:Bn(l,s),entries:[]},a.set(l,u)),u.entries.push(o)}return[...a.values()].sort((o,l)=>o.name.localeCompare(l.name))}function Vj(e,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const a=e.filter(f=>ca(f.manifest)),o=e.filter(f=>!ca(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 Gj(e){const s=e==null?void 0:e.overrides;return!s||typeof s!="object"?!1:Object.values(s).some(a=>{var o;return typeof((o=a==null?void 0:a.read)==null?void 0:o.ageField)=="string"})}const Kj=[0,7,30,90,365,3650];function Ai(e){return e===null?"From your mandate":e===0?"Read nothing":e===1?"1 day back":e===365?"1 year back":e%365===0?`${e/365} years back`:`${e} days back`}function qj(e){return(e==null?void 0:e.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:e&&!e.running&&e.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function nc({manifest:e,integration:s,state:a,onStatusChange:o,onSuccess:l}){var Fe;const[u,f]=h.useState({}),[g,p]=h.useState(!1),[v,y]=h.useState(!1),[w,x]=h.useState({}),[b,k]=h.useState({}),[S,N]=h.useState(void 0),[T,E]=h.useState(!1),[P,I]=h.useState(null),[B,M]=h.useState(!1),[q,z]=h.useState(!1),[U,Z]=h.useState(!1),[G,O]=h.useState(!1),[ne,fe]=h.useState({}),[ee,pe]=h.useState(null),[Ne,X]=h.useState(!1),[Q,Y]=h.useState(null),[A,_]=h.useState(!1);h.useEffect(()=>{let me=!1;return L.getCredential(e.id).then(Re=>{var Oe;if(!(me||!Re.configured)){if(p(!0),y(!0),Re.fields){const K={};for(const J of e.credentials.fields)Re.fields[J.key]!=null&&(K[J.key]=Re.fields[J.key]);x(K)}if(k(Re.secrets??{}),N(Re.updatedAt),e.oauth){const K=((Oe=Re.fieldNames)==null?void 0:Oe.includes(e.oauth.tokenStorage))??!1;E(K),K&&L.getOAuthHealth(e.id).then(J=>{me||I(J)})}}}).catch(()=>{}),()=>{me=!0}},[e.id,e.oauth]);const se=Gj(e.toolGating),te=s?s.readAgeDays??null:void 0,H=Ne&&ee?ee.value:te,ie=async me=>{pe({value:me}),X(!0),Y(null);try{await L.setReadPolicy(e.id,me),l(me===null?`${e.name} read window now follows your mandate`:`${e.name} read window set to ${Ai(me).toLowerCase()}`),o()}catch(Re){Y(Re instanceof Error?Re.message:"Could not save")}finally{X(!1),pe(null)}},ue=!!e.oauth||e.credentials.fields.some(me=>!me.optional),ge=e.oauth?T:g,ve=!ue||ge,le=a==="starting"?"starting":ve?s!=null&&s.running?"running":!g&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&g&&!T?"needs-oauth":"unconfigured",qe=async()=>{if(e.credentials.fields.some(Re=>{var Oe;return(Oe=u[Re.key])==null?void 0:Oe.trim()})){M(!0);try{await L.setCredential(e.id,u),p(!0),f({}),e.oauth?l(`${e.name} credentials saved!`):(l(`${e.name} credentials saved — starting integration...`),await Ue())}catch{l(`Failed to save ${e.name} credentials`)}finally{M(!1)}}},be=()=>{const me={};for(const Re of e.credentials.fields){const Oe=u[Re.key];Re.type==="password"?Oe!=null&&Oe.trim()&&(me[Re.key]=Oe):Oe!=null&&Oe!==(w[Re.key]??"")&&(me[Re.key]=Oe)}return me},oe=Object.keys(be()).length>0,Le=async()=>{const me=be();if(Object.keys(me).length!==0){M(!0);try{await L.setCredential(e.id,me),f({}),p(!0),e.oauth?l(`${e.name} credentials saved — now click Connect.`):(O(!1),l(`${e.name} credentials updated — restarting...`),await Ue())}catch{l(`Failed to update ${e.name} credentials`)}finally{M(!1)}}},ze=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const me=setInterval(async()=>{var Re;try{const Oe=await L.getCredential(e.id);Oe.configured&&e.oauth&&((Re=Oe.fieldNames)!=null&&Re.includes(e.oauth.tokenStorage))&&(E(!0),O(!1),I(null),clearInterval(me),l(`${e.name} connected — starting integration...`),L.getOAuthHealth(e.id).then(I).catch(()=>{}),await Ue())}catch{}},2e3);setTimeout(()=>clearInterval(me),12e4)},Ue=async()=>{Z(!0);try{const me=await L.activateIntegration(e.id);me.warning?l(me.warning):l(`${e.name} integration started with ${me.tools.length} tools`),o()}catch(me){l(`Failed to start ${e.name}: ${me instanceof Error?me.message:"Unknown error"}`)}finally{Z(!1)}},we=async()=>{try{await L.removeMcpIntegration(e.id),l(`${e.name} integration removed`),o()}catch{l(`Failed to remove ${e.name}`)}},nt=jp(e.icon),Ze=qj(s),Ye=le==="running"?{c:"int-chip-ok",t:"Running"}:le==="starting"?{c:"int-chip-idle",t:"Starting"}:Ze.chip,We=e.oauth&&T&&(P==null?void 0:P.status)==="failed",dt=ue?We?{c:"int-chip-bad",t:"Auth failed"}:ge?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},ft=me=>me.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return n.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[n.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:nt}),n.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:e.name}),n.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[le!=="unconfigured"&&le!=="needs-oauth"&&n.jsxs("span",{className:`int-chip ${Ye.c}`,children:[n.jsx("span",{className:"int-dot"}),Ye.t]}),n.jsxs("span",{className:`int-chip ${dt.c}`,children:[n.jsx("span",{className:"int-dot"}),dt.t]}),Zx(e,w)&&n.jsxs("span",{className:"int-chip int-chip-sim",title:"This connector answers from a simulated system with test data. Nothing reaches your real systems.",children:[n.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),e.oauth&&T&&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"})}),We&&!G&&n.jsxs("div",{style:{marginTop:"0.7rem",border:"2px solid var(--border-strong)",borderRadius:"10px",padding:"0.8rem 0.95rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[e.name," stopped accepting the stored credentials"]}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[(P==null?void 0:P.error)==="invalid_grant"?n.jsxs(n.Fragment,{children:["The refresh token was revoked (",n.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):P!=null&&P.error?n.jsxs(n.Fragment,{children:["The provider reported ",n.jsx("code",{children:P.error}),"."]}):n.jsx(n.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",e.name," actions are ",n.jsx("b",{children:"blocked"}),", not failing silently."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[n.jsxs("button",{className:"btn btn-primary btn-sm",onClick:ze,children:["Reconnect ",e.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{f({...w}),O(!0)},children:"Edit credentials"})]})]}),n.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[n.jsx("summary",{children:"Details"}),n.jsxs("div",{className:"int-meta",children:[n.jsx("span",{className:"int-k",children:"What"}),n.jsx("span",{children:e.description}),e.profile&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Profile"}),n.jsx("span",{children:Sp(e).join(", ")})]}),e.oauth&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Scopes"}),n.jsx("span",{children:((Fe=e.oauth.scopes)==null?void 0:Fe.join(", "))||"—"})]}),s&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"int-k",children:"Tools"}),n.jsxs("span",{children:[s.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(le!=="running"||We)&&n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[n.jsxs("button",{onClick:()=>z(!q),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:q?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),q&&n.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((me,Re)=>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:Re+1}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:me.title}),n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[ft(me.description),me.link&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("a",{href:me.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},Re))})]}),le==="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…"]}),G&&n.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[n.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),v&&n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.6rem"},children:["Leaving a secret blank keeps the stored one — editing other fields can never silently wipe it.",e.oauth?" Save, then Connect to re-link the account.":""]}),e.credentials.fields.map(me=>{var Re;return n.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[n.jsx("label",{className:"form-label",children:me.label}),me.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:ne[me.key]?"text":"password",name:`${e.id}-${me.key}-credential`,autoComplete:"new-password",placeholder:(Re=b[me.key])!=null&&Re.preview?`Unchanged — ends in ${b[me.key].preview}`:v?"Unchanged — paste a new value to replace":me.placeholder,value:u[me.key]||"",onChange:Oe=>f(K=>({...K,[me.key]:Oe.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>fe(Oe=>({...Oe,[me.key]:!Oe[me.key]})),children:ne[me.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${me.key}-credential`,autoComplete:"off",placeholder:me.placeholder,value:u[me.key]||"",onChange:Oe=>f(K=>({...K,[me.key]:Oe.target.value}))})]},me.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:Le,disabled:B||!oe,children:B?"Saving…":"Save"}),!oe&&!B&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),e.oauth&&n.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:ze,children:["Connect ",e.name]}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{O(!1),f({})},children:"Cancel"})]})]}),!G&&le==="running"&&s&&n.jsxs(n.Fragment,{children:[(Object.keys(w).length>0||Object.keys(b).length>0)&&n.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:e.credentials.fields.map(me=>{const Re=me.type==="password",Oe=b[me.key];return!Re&&w[me.key]==null||Re&&Oe==null?null:n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[n.jsx("span",{style:{color:"var(--text-muted)"},children:me.label}),n.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[Re?Oe.preview??"set":w[me.key],Re&&S&&n.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(S).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},me.key)})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[n.jsx(gt,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(e.credentials.fields.length>0||e.oauth)&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{f({...w}),O(!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:we,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"})]}),se&&H!==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:H===null?"window from your mandate":Ai(H).toLowerCase()}),Ne&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),Q&&n.jsx("span",{className:"msg-error",style:{fontSize:"0.78rem"},children:Q})]}),n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>_(!0),children:"Edit"})]})}),se&&H!==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:[Kj.map(me=>{const Re=H===me;return n.jsx("button",{className:`btn btn-sm ${Re?"btn-primary":"btn-secondary"}`,"aria-pressed":Re,disabled:Ne,onClick:()=>ie(me),children:Ai(me)},me)}),n.jsx("button",{className:`btn btn-sm ${H===null?"btn-primary":"btn-ghost"}`,"aria-pressed":H===null,disabled:Ne,onClick:()=>ie(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:Ai(null)})]}),n.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:Q?n.jsx("span",{className:"msg-error",children:Q}):Ne?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):H===null?n.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):H===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 ",H," days is blocked, whoever it is from."]})})]}),n.jsx("div",{style:{display:"none"},children:n.jsx(gt,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),le==="unconfigured"&&(()=>{const me=e.credentials.fields.every(K=>K.optional),Re=e.credentials.fields.some(K=>!K.optional),Oe=e.credentials.fields.some(K=>{var J;return(J=u[K.key])==null?void 0:J.trim()});return n.jsxs(n.Fragment,{children:[v&&n.jsxs("div",{className:"alert",style:{fontSize:"0.8rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.75rem",marginBottom:"0.75rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{style:{color:"var(--text-primary)"},children:"Credentials on file."})," ","Existing values are encrypted in the vault and not shown. Enter new values below to replace them, or"," ",n.jsx("button",{onClick:()=>{p(!0),e.oauth&&E(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),e.setupHint&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(K=>n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:K.label}),K.type==="password"?n.jsxs("div",{className:"cred-field",children:[n.jsx("input",{className:"form-input",type:ne[K.key]?"text":"password",name:`${e.id}-${K.key}-credential`,autoComplete:"new-password",placeholder:K.placeholder,value:u[K.key]||"",onChange:J=>f(ye=>({...ye,[K.key]:J.target.value}))}),n.jsx("button",{className:"cred-toggle",onClick:()=>fe(J=>({...J,[K.key]:!J[K.key]})),children:ne[K.key]?"hide":"show"})]}):n.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${K.key}-credential`,autoComplete:"off",placeholder:K.placeholder,value:u[K.key]||"",onChange:J=>f(ye=>({...ye,[K.key]:J.target.value}))})]},K.key)),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[Oe&&n.jsx("button",{className:"btn btn-primary",onClick:qe,disabled:B||Re&&!e.credentials.fields.filter(K=>!K.optional).every(K=>{var J;return(J=u[K.key])==null?void 0:J.trim()}),children:B?"Saving...":"Save & Encrypt"}),me&&!Oe&&n.jsx("button",{className:"btn btn-primary",onClick:Ue,disabled:U,children:U?"Starting...":`Activate ${e.name}`})]})]})})(),le==="needs-oauth"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[n.jsxs("button",{className:"btn btn-primary",onClick:ze,children:["Connect ",e.name," Account"]}),n.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Change Credentials"})]})]}),le==="ready"&&!s&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[n.jsx("button",{className:"btn btn-primary",onClick:Ue,disabled:U,children:U?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>p(!1),children:"Update Credentials"}),e.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>{p(!1),E(!1)},children:"Change Credentials"})]})]}),le==="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:Ue,disabled:U,children:U?"Starting...":"Start"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:we,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:we,children:"Disable"})})]}))]})}function Nh({group:e,children:s}){return n.jsxs("div",{className:"area-group","data-testid":"integration-area","data-area":e.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(ga,{icon:e.icon}),n.jsx("b",{children:e.name})]}),s]})}function Yj({entry:e}){return n.jsxs("div",{className:"int-paused-row",children:[n.jsx("span",{"aria-hidden":"true",children:jp(e.manifest.icon)}),n.jsx("span",{className:"int-paused-name",children:e.manifest.name}),n.jsxs("span",{className:"int-chip int-chip-paused",children:[n.jsx("span",{className:"int-dot"}),"Paused"]})]})}function Jj(){const{loading:e,mcpServerUp:s,manifestsError:a,entries:o,refresh:l}=Dc(),u=Bc(),[f,g]=h.useState(""),p=Lr(),v=h.useCallback(w=>{g(w),setTimeout(()=>g(""),5e3)},[]),y=Vj(o,u);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Integrations"}),n.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),f&&n.jsx("div",{className:"alert alert-success",children:f}),e?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):s===!1?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):y.grouped?n.jsxs(n.Fragment,{children:[y.testSystems.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Test systems"}),kh(y.testSystems,p).map(w=>n.jsx(Nh,{group:w,children:w.entries.map(x=>n.jsx(nc,{manifest:x.manifest,integration:x.integration,state:x.state,onStatusChange:l,onSuccess:v},x.id))},w.shortId))]}),(y.realErrors.length>0||y.pausedReal.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Real systems"}),y.realErrors.map(w=>n.jsx(nc,{manifest:w.manifest,integration:w.integration,state:w.state,onStatusChange:l,onSuccess:v},w.id)),y.pausedReal.length>0&&n.jsxs("details",{className:"int-paused-group",open:!0,children:[n.jsxs("summary",{children:["Paused while simulation mode is on (",y.pausedReal.length,")"]}),n.jsxs("p",{className:"int-paused-group-note",children:["Nothing is lost — mandates, credentials and data stay. They start again when simulation mode is switched off (",n.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),y.pausedReal.map(w=>n.jsx(Yj,{entry:w},w.id))]})]}),o.length===0&&n.jsx(Ch,{manifestsError:a})]}):n.jsxs(n.Fragment,{children:[kh(o,p).map(w=>n.jsx(Nh,{group:w,children:w.entries.map(x=>n.jsx(nc,{manifest:x.manifest,integration:x.integration,state:x.state,onStatusChange:l,onSuccess:v},x.id))},w.shortId)),o.length===0&&n.jsx(Ch,{manifestsError:a})]})]})}function Ch({manifestsError:e}){return e?n.jsxs("div",{className:"status-banner status-banner-error",children:[n.jsx("span",{className:"status-banner-icon",children:"!"}),n.jsxs("span",{className:"status-banner-text",children:["Couldn't load integrations — the gateway can't reach its MCP server (or you're signed out). Check the control-plane's"," ",n.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):n.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function Qj(){var O,ne,fe;const{activeTeam:e,activeMembership:s,refreshGroups:a,user:o}=wt(),l=Sn(),[u,f]=h.useState(null),[g,p]=h.useState(!1),[v,y]=h.useState(""),[w,x]=h.useState(""),[b,k]=h.useState(!1),[S,N]=h.useState(""),[T,E]=h.useState("");h.useEffect(()=>{fetch("/health").then(ee=>ee.json()).then(ee=>{typeof ee.spUrl=="string"&&E(ee.spUrl)}).catch(()=>{})},[]),h.useEffect(()=>{if(!e){f(null);return}L.getGroupById(e.id).then(ee=>{const pe=ee.group??ee,Ne=ee.members??[],X=ee.isAdmin??!1,Q=Ne.map(Y=>{const A=Y.userId||Y.id||"",_=Y.role||(X&&A===pe.createdBy?"admin":"member");return{id:A,name:Y.name||A.slice(0,8)||"Member",email:Y.email||"",domains:Y.domains||[],role:_,isAdmin:_==="admin"||X&&A===pe.createdBy}});f({id:pe.id,name:pe.name,members:Q})}).catch(()=>f(null))},[e==null?void 0:e.id]);const P=(u==null?void 0:u.members.filter(ee=>ee.isAdmin))??[],I=(e==null?void 0:e.isAdmin)===!0&&P.length<=1&&P.some(ee=>ee.id===(o==null?void 0:o.id)),B=(e==null?void 0:e.name)??"",M=S.trim()===B&&!g,q=()=>{N(""),k(!0)},z=()=>{k(!1),N("")},U=async()=>{if(!(!e||!M)){p(!0),y("");try{await L.leaveTeam(e.id),await a(),x("You have left the team."),f(null),z()}catch(ee){y(ee instanceof Error?ee.message:"Failed to leave team")}finally{p(!1)}}},Z=e&&T?`${T}/dashboard/groups/${e.id}`:void 0,G=T?`${T}/dashboard/groups`:void 0;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"page-header",children:n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Team"}),n.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),v&&n.jsx("div",{className:"error-message",children:v}),w&&n.jsx("div",{className:"alert alert-success",children:w}),e?n.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[n.jsxs("div",{className:"card-header",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"card-title",children:e.name}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((O=u==null?void 0:u.members)==null?void 0:O.length)??0," ",(((ne=u==null?void 0:u.members)==null?void 0:ne.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),n.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(fe=u==null?void 0:u.members)==null?void 0:fe.map(ee=>n.jsxs("div",{className:"member-row",children:[n.jsx("div",{className:"member-avatar",children:ee.name.split(" ").map(pe=>pe[0]).join("").slice(0,2).toUpperCase()}),n.jsxs("div",{className:"member-info",children:[n.jsx("div",{className:"member-name",children:ee.name}),n.jsx("div",{className:"member-email",children:ee.email})]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:ee.role})]},ee.id)),n.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[Z&&n.jsx("a",{className:"btn btn-secondary btn-sm",href:Z,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),n.jsx("span",{title:I?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:n.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:q,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"}),G&&n.jsx("a",{className:"btn btn-ghost btn-sm",href:G,target:"_blank",rel:"noopener noreferrer",children:"Manage teams in your Authority Server →"})]})]}),b&&e&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:z,children:n.jsxs("div",{className:"card",onClick:ee=>ee.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[n.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",B,"?"]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsx("li",{children:"Revoke all mandates you created in this team's context"}),n.jsx("li",{children:"Reject any pending action proposals you authored"}),n.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",n.jsx("strong",{children:"personal"})," mandates are not affected."]}),n.jsxs("div",{className:"form-group",children:[n.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",n.jsx("code",{children:B})," to confirm:"]}),n.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:S,onChange:ee=>N(ee.target.value),placeholder:B,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:z,disabled:g,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:U,disabled:!M,children:g?"Leaving...":"Leave team"})]})]})})]})}function Xc({areas:e,selected:s,onSelect:a,totalCount:o}){return e.length<2?null:n.jsxs("div",{className:"ftabs",role:"tablist","aria-label":"Which area","data-testid":"area-filter",children:[n.jsxs("button",{type:"button",role:"tab",className:"ftab","aria-selected":s===null,onClick:()=>a(null),children:["All ",n.jsx("span",{className:"n",children:o})]}),e.map(l=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`area-filter-${l.shortId}`,"aria-selected":s===l.shortId,onClick:()=>a(s===l.shortId?null:l.shortId),children:[n.jsx(ga,{icon:l.icon})," ",l.name," ",n.jsx("span",{className:"n",children:l.count})]},l.shortId))]})}const ur=e=>e.replace(/@.*$/,"").split("/").pop()??e,Eh=e=>e.split("@")[1]??"";function Th(e){var a;const s=e.profile?[ur(e.profile)]:[];for(const o of Object.values(((a=e.toolGating)==null?void 0:a.overrides)??{})){const l=o==null?void 0:o.profile;l&&!s.includes(ur(l))&&s.push(ur(l))}return s}function Xj(e,s){const a=new Map;for(const o of e){const l=ur(o.id);if(!s.has(l))continue;const u=a.get(l);(!u||Eh(o.id).localeCompare(Eh(u.id),void 0,{numeric:!0})>0)&&a.set(l,o)}return a}function Zj(e,s,a,o){var g;const l=new Set([...s.flatMap(p=>Th(p)),...o.map(p=>ur(p.profile))]),u=Xj(e,l),f=[];for(const p of s){const v=Th(p);for(const[y,w]of v.entries()){const x=u.get(w);x&&f.push({key:y===0?`connector:${p.id}`:`connector:${p.id}:${w}`,name:v.length>1?`${p.name} — ${x.name??w}`:p.name,description:p.description||x.description,profile:x,kind:"connector",ready:((g=a.find(b=>b.id===p.id))==null?void 0:g.running)===!0,setupId:p.id,...p.intentHint&&y===0?{intentHint:p.intentHint}:{}})}}for(const p of o){const v=u.get(ur(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 eS(e,s,a){if(s)return e.find(o=>ur(o.profile.id)===ur(s)&&o.ready&&a(o))}function bp({icon:e,className:s}){return n.jsx(ga,{icon:e,className:s})}function tS({onDismiss:e,preselectProfileId:s}){const a=Sn(),{group:o,groupId:l,domain:u,user:f}=wt(),[g,p]=h.useState([]),[v,y]=h.useState([]),[w,x]=h.useState([]),[b,k]=h.useState([]),[S,N]=h.useState(!0),[T,E]=h.useState({});h.useEffect(()=>{Promise.all([L.listProfiles().catch(()=>[]),L.getIntegrationManifests().then(U=>U.manifests??[]).catch(()=>[]),L.getMcpHealth().catch(()=>null)]).then(async([U,Z,G])=>{if(p(U),y(Z),x((G==null?void 0:G.integrations)??[]),k((G==null?void 0:G.builtins)??[]),l){const O=await Promise.all(U.map(fe=>L.getTeamProfileConfig(l,fe.id).catch(()=>null))),ne={};U.forEach((fe,ee)=>{const pe=O[ee];pe&&(ne[fe.id]=pe)}),E(ne)}}).finally(()=>N(!1))},[l]);const P=Zj(g,v,w,b),I=U=>{const Z=T[U.id];return vp({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!S,grantors:Z?Sm(Z):void 0,userId:f==null?void 0:f.id,profileName:Mt(U.id),teamName:o==null?void 0:o.name})},B=U=>U in T,M=(U,Z)=>{if(!l){console.error("No active group when creating authorization");return}const G=B(U);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:U,groupId:l,groupName:(o==null?void 0:o.name)??null,domain:u,isTeam:G,isPersonal:!!(o!=null&&o.isPersonal),...Z?{intentHint:Z}:{}})),sessionStorage.removeItem("agentGate"),e==null||e(),a("/mandates/new/intent")},q=(U,Z)=>{l&&M(U,Z)},z=h.useRef(!1);return h.useEffect(()=>{if(S||!s||z.current)return;const U=eS(P,s,Z=>I(Z.profile).can);U&&(z.current=!0,q(U.profile.id,U.intentHint))},[S,s]),n.jsxs(n.Fragment,{children:[n.jsx("style",{children:`
79
+ .profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
80
+ .profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
81
+ @media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
82
+ @media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
83
+ `}),S?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):P.length===0?n.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[n.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),n.jsx(gt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):n.jsx("div",{className:"profile-grid",children:P.map(U=>{const Z=U.profile,G=B(Z.id),O=I(Z),ne=!U.ready||!O.can,{icon:fe}=_r(Z.id,{name:Z.name});return n.jsxs("div",{className:"card",style:ne?{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(bp,{icon:fe,className:"profile-chip-icon"}),U.name]}),G?n.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Team"}):o!=null&&o.isPersonal?n.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--bg-main)",color:"var(--text-tertiary)",fontWeight:600,border:"1px solid var(--border)"},children:"Personal"}):null]}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:U.description}),O.can?U.ready?n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>q(Z.id,U.intentHint),children:"Give a mandate"}):U.kind==="builtin"?n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:U.unavailableReason})]}):n.jsxs(gt,{to:`/integrations?setup=${U.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",U.name]}):n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[O.reason," ",n.jsx("span",{style:{color:"var(--text-tertiary)"},children:O.fix})]})]})]},U.key)})})]})}const nS={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function rS({status:e,label:s}){return n.jsx("span",{className:`status-badge status-${e}`,children:s||nS[e]})}function sS({domain:e,attested:s}){const a=s===!0?"domain-attested":s===!1?"domain-missing":"";return n.jsx("span",{className:`domain-badge ${a}`,style:{fontSize:"0.75rem"},children:e})}const Er=86400,aa=3600,Ii=60,aS=30*Er;function iS(e){if(e<=0)return"Expired";if(e>90*Er){const s=Math.floor(e/aS);return`${s} ${s===1?"month":"months"} remaining`}if(e>7*Er){const s=Math.floor(e/Er);return`${s} ${s===1?"day":"days"} remaining`}if(e>=2*Er){const s=Math.floor(e/Er),a=Math.floor(e%Er/aa);return`${s} ${s===1?"day":"days"} ${a}h remaining`}if(e>=2*aa){const s=Math.floor(e/aa),a=Math.floor(e%aa/Ii);return`${s}h ${String(a).padStart(2,"0")}m remaining`}if(e>=Ii){const s=Math.floor(e/Ii),a=Math.floor(e%Ii);return`${s}m ${String(a).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function oS({expiresAt:e}){const[s,a]=h.useState(()=>e-Date.now()/1e3),o=s<2*aa;h.useEffect(()=>{const u=setInterval(()=>a(e-Date.now()/1e3),o?1e3:6e4);return()=>clearInterval(u)},[e,o]);const l=s<300;return n.jsx("span",{className:`ttl-badge ${l?"ttl-warn":"ttl-ok"}`,children:iS(s)})}function fs({icon:e,title:s,text:a,children:o}){return n.jsxs("div",{className:"empty-state",children:[e&&n.jsx("div",{className:"empty-state-icon",children:e}),n.jsx("div",{className:"empty-state-title",children:s}),a&&n.jsx("div",{className:"empty-state-text",children:a}),o]})}function lS(e){const s=Math.floor(e/86400);if(s>=1)return`${s} day${s===1?"":"s"}`;const a=Math.floor(e/3600);if(a>=1)return`${a} hour${a===1?"":"s"}`;const o=Math.ceil(e/60);return`${o} minute${o===1?"":"s"}`}const cS=[{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 uS({item:e,onClose:s,onSuccess:a}){var P;const{user:o,activeDomain:l,groupId:u}=wt(),[f,g]=h.useState(null);h.useEffect(()=>{let I=!1;return L.getProfile(e.profile_id).then(B=>{var M;I||g(((M=B==null?void 0:B.ttl)==null?void 0:M.max)??null)}).catch(()=>{}),()=>{I=!0}},[e.profile_id]);const p=e.remaining_seconds??0,v=cS.filter(I=>I.seconds>p&&(f===null||I.seconds<=f)),y=((P=v[0])==null?void 0:P.seconds)??2592e3,[w,x]=h.useState(y);h.useEffect(()=>{var I;if(f!==null&&w>f){const B=(I=v[v.length-1])==null?void 0:I.seconds;B&&x(B)}},[f]);const[b,k]=h.useState(!1),[S,N]=h.useState(""),T=Object.entries(e.frame).filter(([I])=>I!=="profile"&&I!=="path"),E=async()=>{var I;if(o){k(!0),N("");try{const B=e.authorization_id,M=await L.getGateContent(B);if(!M)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const q=await L.getProfile(e.profile_id),z=e.frame,U=M.context??{},Z=e.attested_domains[0]||l||"owner",G=await zi(z,q),O=await mp(U,q),[ne,fe]=await Promise.all([Vi(M.gateContent.intent),Vi(JSON.stringify({profile:e.profile_id,path:e.path,domain:Z}))]);if(!u)throw new Error("No active group; cannot extend mandate.");const ee=(((I=e.deferred_commitment_domains)==null?void 0:I.length)??0)>0?"review":"automatic",pe=await pp(q),Ne=await L.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,profile_hash:pe,supported_versions:["0.7"],bounds:z,bounds_hash:G,scope_hash:O,domain:Z,did:o.did,mandate_owners:[{did:o.did}],gate_content_hashes:{intent:ne},execution_context_hash:fe,group_id:u,commitment_mode:ee,ttl:w});await L.pushGateContent(gp(Ne,{boundsHash:G,contextHash:O,context:U,path:e.path,gateContent:M.gateContent})),a()}catch(B){N(B instanceof Error?B.message:"Extension failed")}finally{k(!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:[Mt(e.profile_id)," / ",e.path]}),T.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:T.map(([I,B])=>`${I}=${B}`).join(" · ")})]}),n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),p>0&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",lS(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 ${w===I.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>x(I.seconds),style:{minWidth:"3.5rem"},children:I.label},I.seconds))})]}),n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),S&&n.jsx("div",{className:"error-message",children:S})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-secondary",onClick:s,disabled:b,children:"Cancel"}),n.jsx("button",{className:"btn btn-primary",onClick:E,disabled:b,children:b?"Extending...":"Extend"})]})]})})}function Ah(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Ih(e){return e.split("@")[1]??""}function dS(e,s){return Ih(e).localeCompare(Ih(s),void 0,{numeric:!0})>0}function kp(e,s){const a=Ah(e);let o;for(const l of s)Ah(l.id)===a&&(!o||dS(l.id,o.id))&&(o=l);return o}function Np(e,s){var o;if(!s)return{};const a={};for(const l of s.keyOrder){if(l==="profile"||l==="path")continue;if(e[l]!==void 0){a[l]=e[l];continue}const u=(o=s.fields[l])==null?void 0:o.default;(typeof u=="string"||typeof u=="number"&&Number.isFinite(u))&&(a[l]=u)}return a}function Cp(e,s){return Np(e,s.boundsSchema)}function Ep(e,s){return Np(e,s.scopeSchema)}function fS(e,s,a){return[...e].sort((o,l)=>{if(a){if(o.authorization_id===a&&l.authorization_id!==a)return-1;if(l.authorization_id===a&&o.authorization_id!==a)return 1}const u=Mi(o,s),f=Mi(l,s),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 hS({item:e,newerProfile:s,area:a,revokedSet:o,expandedHash:l,gateCache:u,gateLoading:f,copiedHash:g,revokingHash:p,copyingHash:v,profileConfigCache:y,mode:w,ownerLabel:x,isAdmin:b,onExpand:k,onCopyHash:S,onCopy:N,onRevoke:T,onExtend:E,archivedSet:P,archivingHash:I,onArchive:B,highlightHash:M,needsReapprovalSet:q}){var qe;const z=Oc(e,{revokedSet:o}),U=z==="active"&&((q==null?void 0:q.has(e.authorization_id))??!1),Z=Em(e,{revokedSet:o,archivedSet:P}),G=!x&&!!B&&Cm(z),O=l===e.authorization_id,ne=u[e.authorization_id],fe=z==="active"||z==="pending"||z==="expired",ee=Object.entries(e.frame).filter(([be])=>be!=="profile"&&be!=="path"),pe=y.get(e.profile_id)??null,Ne=(((qe=pe==null?void 0:pe.approvers)==null?void 0:qe.length)??0)>0,X=new Map;if(pe!=null&&pe.caps&&w==="team")for(const[be,oe]of ee){const Le=pe.caps[be];typeof Le=="number"&&Number(oe)>Le&&X.set(be,{authorized:Number(oe),cap:Le})}const Q=X.size>0,Y=e.approvers_frozen??[],A=(pe==null?void 0:pe.approvers)??[],_=w==="team"&&Y.length>0&&A.length>0&&(Y.length!==A.length||Y.some(be=>!A.includes(be))||A.some(be=>!Y.includes(be))),se=Array.from(X.entries()).map(([be,oe])=>`${be}: ${oe.authorized} (cap ${oe.cap})`).join(", "),te=Array.from(X.entries()).map(([be,oe])=>`${be}: ${oe.authorized} → ${oe.cap}`).join(", "),H=Q?Ne?X.size===1?`Above team cap: ${se} — actions require approval`:`Above team cap (${X.size}): ${se} — actions require approval`:X.size===1?`Reduced by hard cap: ${te}`:`Reduced by hard cap (${X.size}): ${te}`:"",ie=Q?Ne?"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,ue=_r(e.profile_id),ge=ue.name,ve=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:[ge,"@",s.version," available"]}),s.whatsNew?n.jsxs(n.Fragment,{children:[" — ",s.whatsNew]}):null,n.jsx("br",{}),n.jsxs("span",{children:["This mandate stays on ",e.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,le=M!=null&&e.authorization_id===M;return n.jsx("div",{className:`card mandate-card${le?" card-highlight":""}`,style:{marginBottom:0},children:n.jsxs("div",{className:"id-body",children:[e.created_at&&n.jsxs("div",{className:"obj-line",children:["since ",new Date(e.created_at).toLocaleDateString(void 0,{day:"numeric",month:"short"})]}),ve,x&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",n.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:x})]}),n.jsxs("div",{className:"auth-card-header",children:[n.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:e.title||ge}),n.jsx(rS,{status:z}),U&&n.jsx("span",{title:"The Authority Server no longer verifies this mandate's protocol version. Re-approve it to keep using this authority.",style:{fontSize:"0.75rem",fontWeight:700,color:"var(--text-primary)",background:"transparent",border:"1px dashed var(--text-primary)",borderRadius:"4px",padding:"2px 6px"},children:"Needs re-approval"}),ue.testSetup&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),z==="active"&&e.earliest_expiry&&n.jsx(oS,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),z==="expired"&&(()=>{const be=Xx(e,z);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:[(e.required_domains.length>1||e.missing_domains.length>0)&&e.required_domains.map(be=>n.jsx(sS,{domain:be,attested:e.attested_domains.includes(be)},be)),e.deferred_commitment_domains.length>0&&n.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Review Mode"}),Q&&n.jsx("span",{title:ie,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"transparent",color:"var(--text-primary)",border:Ne?"1px dashed var(--text-primary)":"2px solid var(--text-primary)",fontWeight:600,cursor:"help"},children:H}),_&&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:()=>N(e),disabled:v===e.authorization_id,title:"The approver list for this profile has changed since this mandate was created. Copy to reissue with the current approvers.",children:v===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),ee.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:ee.map(([be,oe],Le)=>{const ze=X.get(be);return n.jsxs("span",{children:[Le>0&&" · ",ze?Ne?n.jsxs("span",{title:`Team cap on ${be} is ${ze.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${ze.authorized}.`,children:[n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[be,"=",String(oe)]}),n.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",ze.cap]})]}):n.jsxs("span",{title:`Team cap on ${be} is ${ze.cap} with no approvers configured (hard cap). Authorized for ${ze.authorized}; effective ${ze.cap}.`,children:[n.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[be,"=",String(oe)]}),n.jsxs("span",{style:{marginLeft:"0.25rem",fontWeight:700},children:["→"," ",ze.cap]})]}):n.jsxs("span",{children:[be,"=",String(oe)]})]},be)})}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[G&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>B(e.authorization_id,!Z),disabled:I===e.authorization_id,title:Z?"Move back to the Expired or Revoked list":"Hide from the list and the nav badge. Nothing is deleted: the mandate and its tickets stay stored and verifiable.",children:I===e.authorization_id?Z?"Unarchiving…":"Archiving…":Z?"↩ Unarchive":"⊟ Archive"}),n.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>k(e),children:O?"▲ Hide Details":"▼ Details"})]}),O&&n.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[ee.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:ee.map(([be,oe])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:be}),n.jsx("dd",{children:String(oe)})]},be))})]}),(ne==null?void 0:ne.context)&&Object.keys(ne.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(ne.context).map(([be,oe])=>n.jsxs("span",{style:{display:"contents"},children:[n.jsx("dt",{children:be}),n.jsx("dd",{title:String(oe),children:yp(be,oe,ne.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"}),f===e.authorization_id?n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):ne?n.jsx("div",{className:"gate-content-block",children:n.jsx("div",{className:"gate-content-item",children:n.jsx("div",{className:"gate-content-text",children:ne.gateContent.intent})})}):n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(e.created_at).toLocaleString(),e.earliest_expiry&&` · Expires: ${new Date(e.earliest_expiry).toLocaleString()}`]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:e.authorization_id}),n.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>S(e.authorization_id),children:g===e.authorization_id?"copied":"copy"})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!x&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>N(e),disabled:v===e.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:v===e.authorization_id?"Copying…":"⧉ Copy"}),!x&&(z==="active"||z==="pending")&&n.jsx("button",{className:U?"btn btn-primary btn-sm":"btn btn-secondary btn-sm",onClick:()=>N(e,{asEdit:!0}),disabled:v===e.authorization_id,title:U?"The Authority Server no longer verifies this mandate's protocol version. Re-approving opens the ceremony pre-filled with the same bounds, scope, and intent; signing it revokes this one.":"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:U?"⚠ Re-approve":"✎ Edit"}),!x&&fe&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>E(e),children:"↻ Extend"}),x&&b&&z!=="revoked"?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>T(e.authorization_id,x,ge),disabled:p===e.authorization_id,children:p===e.authorization_id?"Revoking…":"Revoke"}):!x&&(z==="active"||z==="pending")?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>T(e.authorization_id),disabled:p===e.authorization_id,children:p===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]})},e.authorization_id)}function mS(){const[e,s]=h.useState([]),[a,o]=h.useState(!0),[l,u]=h.useState([]),[f,g]=h.useState(!1),[p,v]=h.useState(new Map),[y,w]=h.useState("mine"),[x,b]=h.useState("active"),[k,S]=h.useState(null),[N,T]=h.useState(null),[E,P]=gs(),[I,B]=h.useState(()=>E.get("new")==="1"),[M]=h.useState(()=>E.get("profile")),[q,z]=h.useState(()=>E.get("highlight")),[U,Z]=h.useState(null),[G,O]=h.useState({}),[ne,fe]=h.useState(null),[ee,pe]=h.useState(null),[Ne,X]=h.useState(null),[Q,Y]=h.useState(new Set),[A,_]=h.useState(null),[se,te]=h.useState(new Set),[H,ie]=h.useState(null),[ue,ge]=h.useState(null),[ve,le]=h.useState(new Set),qe=Sn(),{group:be,groupId:oe,domain:Le,mode:ze,activeTeam:Ue}=wt(),we=(Ue==null?void 0:Ue.isAdmin)===!0,[nt,Ze]=h.useState(()=>new Map),[Ye,We]=h.useState([]);h.useEffect(()=>{L.getLabelManifests().then(We).catch(()=>{})},[]);const dt=h.useCallback(()=>{o(!0),L.getMyAttestations().then(s).catch(()=>{}).finally(()=>o(!1))},[]),ft=h.useCallback(()=>{L.getArchivedMandates().then(de=>te(new Set(de))).catch(()=>{})},[]);h.useEffect(()=>{ft()},[ft]);const Fe=h.useCallback(()=>{L.getEnrichedAuthorizations().then(de=>le(new Set(de.filter(Ce=>Ce.needsReapproval).map(Ce=>Ce.authorizationId)))).catch(()=>{})},[]);h.useEffect(()=>{Fe()},[Fe]);const me=async(de,Ce)=>{ie(de);try{const Ie=await L.setMandateArchived(de,Ce);te(new Set(Ie)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(Ie){alert(Ie instanceof Error?Ie.message:"Failed to update archive")}finally{ie(null)}},Re=h.useCallback(()=>{oe&&(g(!0),L.listTeamAuthorizations(oe).then(u).catch(()=>{}).finally(()=>g(!1)))},[oe]);Me("attestation-changed",()=>{dt(),we&&oe&&Re(),Fe()}),h.useEffect(()=>{if(!q)return;E.get("highlight")&&(E.delete("highlight"),P(E,{replace:!0}));const de=window.setTimeout(()=>z(null),3e3);return()=>window.clearTimeout(de)},[]),Ft(dt,3e5),h.useEffect(()=>{y==="team"&&we&&oe&&l.length===0&&!f&&Re()},[y,we,oe,l.length,f,Re]),h.useEffect(()=>{let de=!1;return L.listProfiles().then(Ce=>{if(de)return;const Ie=Ct=>Ct.replace(/@.*$/,"").split("/").pop()??Ct,Be=Ct=>Ct.split("@")[1]??"",Xe=new Map;for(const Ct of Ce){const Pt=Ie(Ct.id),zr=Xe.get(Pt);(!zr||Be(Ct.id).localeCompare(Be(zr.id),void 0,{numeric:!0})>0)&&Xe.set(Pt,Ct)}v(Xe)}).catch(()=>{}),()=>{de=!0}},[]);const Oe=h.useCallback(de=>{const Ce=Pt=>Pt.replace(/@.*$/,"").split("/").pop()??Pt,Ie=Pt=>Pt.split("@")[1]??"",Be=p.get(Ce(de));if(!Be)return;const Xe=Ie(de),Ct=Ie(Be.id);if(!(!Xe||!Ct))return Ct.localeCompare(Xe,void 0,{numeric:!0})>0?Be:void 0},[p]),K=h.useCallback(de=>Bn(de,[...p.values()]),[p]);h.useEffect(()=>{if(ze!=="team"||!oe)return;const de=y==="mine"?e:l;if(de.length===0)return;const Ce=[...new Set(de.map(Ie=>Ie.profile_id))].filter(Ie=>!nt.has(Ie));if(Ce.length!==0){Ze(Ie=>{const Be=new Map(Ie);for(const Xe of Ce)Be.set(Xe,null);return Be});for(const Ie of Ce)L.getTeamProfileConfig(oe,Ie).then(Be=>{Ze(Xe=>new Map(Xe).set(Ie,Be))}).catch(()=>{})}},[e,l,y,oe,ze,nt]);const J=async de=>{if(U===de.authorization_id){Z(null);return}Z(de.authorization_id);const Ce=de.authorization_id;if(!(Ce in G)){fe(de.authorization_id);try{const Ie=await L.getGateContent(Ce);O(Be=>({...Be,[Ce]:Ie}))}catch{O(Ie=>({...Ie,[Ce]:null}))}finally{fe(null)}}},ye=de=>{navigator.clipboard.writeText(de).then(()=>{X(de),setTimeout(()=>X(null),2e3)})},He=async(de,Ce)=>{var Ie;if(!oe){alert("No active group; cannot copy mandate.");return}ge(de.authorization_id);try{const Be=de.authorization_id;let Xe=G[Be]??null;Be in G||(Xe=await L.getGateContent(Be),O(kn=>({...kn,[Be]:Xe})));const Ct=Object.fromEntries(Object.entries(de.frame).filter(([kn])=>kn!=="profile"&&kn!=="path")),Pt=(Xe==null?void 0:Xe.context)??{},zr=((Ie=Xe==null?void 0:Xe.gateContent)==null?void 0:Ie.intent)??"",fr=de.deferred_commitment_domains.length>0?"review":"automatic",Fr=de.attested_domains[0]||Le||"owner",Hn=Date.parse(de.created_at),hr=de.earliest_expiry?Date.parse(de.earliest_expiry):NaN,oo=Number.isFinite(Hn)&&Number.isFinite(hr)&&hr>Hn?Math.round((hr-Hn)/1e3):void 0;let ya=de.profile_id,va=Ct,bn=Pt,ys;const xa=await L.listProfiles(),Mr=kp(de.profile_id,xa);if(Mr&&Mr.id!==de.profile_id){const kn=await L.getProfile(Mr.id);ya=Mr.id,va=Cp(Ct,kn),bn=Ep(Pt,kn),ys=de.profile_id}sessionStorage.setItem("agentAuth",JSON.stringify({profileId:ya,groupId:oe,groupName:(be==null?void 0:be.name)??null,domain:Fr,isPersonal:!!(be!=null&&be.isPersonal),upgradedFromProfileId:ys})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:va,context:bn,gateContent:{intent:zr},templateMode:fr,templateTtl:oo})),Ce!=null&&Ce.asEdit?sessionStorage.setItem("agentEditReplaces",de.authorization_id):sessionStorage.removeItem("agentEditReplaces"),qe("/mandates/new/intent")}catch(Be){alert(Be instanceof Error?Be.message:"Failed to copy mandate")}finally{ge(null)}},Ve=async(de,Ce,Ie)=>{const Be=Ce&&Ie?`Revoke ${Ce}'s ${Ie} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(Be)){_(de);try{await L.revokeAttestation(de),Y(Xe=>new Set(Xe).add(de)),L.resyncGates().catch(()=>{}),Ce&&oe&&Re()}catch(Xe){alert(Xe instanceof Error?Xe.message:"Failed to revoke mandate")}finally{_(null)}}},rt=y==="mine"?e:l,Ht=y==="mine"?a:f,Ot=y==="mine"?{revokedSet:Q,archivedSet:se}:{revokedSet:Q},et=de=>Mi(de,Ot),W={active:0,pending:0,expired:0,revoked:0,archived:0};for(const de of rt)W[et(de)]+=1;const xe=y==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],Ae=(()=>{const de=new Map;for(const Ce of rt){if(et(Ce)!==x)continue;const Ie=In(Ce.profile_id),Be=de.get(Ie);Be?Be.count+=1:de.set(Ie,{shortId:Ie,icon:Pr(Ce.profile_id),name:K(Ce.profile_id),count:1})}return[...de.values()].sort((Ce,Ie)=>Ce.name.localeCompare(Ie.name))})(),st=Ae.reduce((de,Ce)=>de+Ce.count,0),yt=fS(rt.filter(de=>{if(et(de)!==x||k!==null&&In(de.profile_id)!==k)return!1;if(N!==null){const Ce=de.deferred_commitment_domains.length>0;if(N==="review"&&!Ce||N==="auto"&&Ce)return!1}return!0}),Ot,q),Ke=h.useMemo(()=>{const de=new Map;for(const Ce of yt){const Ie=In(Ce.profile_id);let Be=de.get(Ie);Be||(Be={shortId:Ie,icon:Pr(Ce.profile_id),name:K(Ce.profile_id),items:[]},de.set(Ie,Be)),Be.items.push(Ce)}return[...de.values()].sort((Ce,Ie)=>Ie.items.length-Ce.items.length||Ce.name.localeCompare(Ie.name))},[yt,K]),Nt=h.useCallback(de=>[...new Set(Ye.filter(Ce=>{var Ie;return Ce.profile===de||Object.values(((Ie=Ce.toolGating)==null?void 0:Ie.overrides)??{}).some(Be=>(Be==null?void 0:Be.profile)===de)}).map(Ce=>Ce.name))],[Ye]),St={revokedSet:Q,expandedHash:U,gateCache:G,gateLoading:ne,copiedHash:Ne,revokingHash:A,copyingHash:ue,profileConfigCache:nt,mode:ze,activeDomain:Le,group:be,groupId:oe,onExpand:J,onCopyHash:ye,onCopy:He,onRevoke:Ve,onExtend:pe,highlightHash:q},Xt={...St,archivedSet:se,archivingHash:H,onArchive:me,needsReapprovalSet:ve};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Mandates"}),n.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),n.jsx("button",{className:"btn btn-primary",onClick:()=>B(!0),children:"+ New mandate"})]}),I&&n.jsx("div",{className:"modal-backdrop",onClick:()=>{B(!1),(E.get("new")||E.get("profile"))&&(E.delete("new"),E.delete("profile"),P(E,{replace:!0}))},children:n.jsxs("div",{className:"modal",onClick:de=>de.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h2",{className:"modal-title",children:"New mandate"}),n.jsx("button",{className:"modal-close",onClick:()=>{B(!1),(E.get("new")||E.get("profile"))&&(E.delete("new"),E.delete("profile"),P(E,{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(tS,{onDismiss:()=>B(!1),preselectProfileId:M})]})]})}),we&&n.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[n.jsx("button",{className:`nav-tab${y==="mine"?" active":""}`,onClick:()=>{w("mine"),b("active"),S(null),T(null),Z(null)},children:"Mine"}),n.jsx("button",{className:`nav-tab${y==="team"?" active":""}`,onClick:()=>{w("team"),b("active"),S(null),T(null),Z(null)},children:"Team"})]}),n.jsx("div",{className:"nav-tabs",children:xe.map(de=>n.jsxs("button",{className:`nav-tab${x===de?" active":""}`,onClick:()=>{b(de),S(null),T(null)},children:[de.charAt(0).toUpperCase()+de.slice(1)," (",W[de],")"]},de))}),st>0&&n.jsxs("div",{className:"mandate-filters",children:[n.jsx(Xc,{areas:Ae,selected:k,onSelect:S,totalCount:st}),n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which mode",children:["auto","review"].map(de=>{const Ce=N===de;return n.jsx("button",{type:"button",role:"tab",className:"ftab","data-testid":`mode-filter-${de}`,"aria-selected":Ce,onClick:()=>T(Ce?null:de),children:de==="auto"?"Automatic":"Review"},de)})})]}),Ht&&rt.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):yt.length===0?n.jsx(fs,{icon:"☰",title:"No mandates",text:x==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${x} mandates found.`}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:Ke.map(de=>n.jsxs("section",{"data-testid":"mandate-area","data-area":de.shortId,children:[n.jsxs("div",{className:"area-group-h",children:[n.jsx(ga,{icon:de.icon}),n.jsx("b",{children:de.name}),n.jsxs("span",{className:"meta",children:[de.items.length," mandate",de.items.length===1?"":"s",Nt(de.shortId).length>0&&n.jsxs(n.Fragment,{children:[" · via ",Nt(de.shortId).join(", ")]})]})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:de.items.map(Ce=>{const Ie=y==="team"?Ce:null,Be=Ie!=null&&Ie.owner?Ie.owner.name??Ie.owner.email??Ie.owner.userId:void 0;return n.jsx(hS,{item:Ce,newerProfile:Oe(Ce.profile_id),area:de.name,ownerLabel:Be,isAdmin:we,...y==="mine"?Xt:St},Ce.authorization_id)})})]},de.shortId))}),ee&&n.jsx(uS,{item:ee,onClose:()=>pe(null),onSuccess:()=>{pe(null),dt()}})]})}function Tp(e){const s=e.approved?e.proposalArgs:e.sentArgs;return Vw(e.tool,s??null,e.manifests)??e.label}function pS(e){if(e.offDevice)return{level:"off-device"};const s=e.sentArgs??e.proposalArgs,a=s?e.sentArgsCheck??"unchecked":"unchecked";return e.hasHashToCheck&&e.boundContent!==void 0?{level:"sealed",check:e.hashVerified===!0?"ok":"failed",bound:e.boundContent,extras:s?gS(e.boundContent,s):null,argsCheck:a}:s?{level:"recorded",content:s,check:a}:e.boundContent!==void 0?{level:"recorded",content:e.boundContent,check:"unchecked"}:{level:"not-kept",reason:e.sentArgsOmitted==="too_large"?"too_large":"older"}}function gS(e,s){const a={};for(const[o,l]of Object.entries(s))(typeof e=="string"?l===e:o in e)||(a[o]=l);return Object.keys(a).length>0?a:null}function Ap(e,s,a){return qm(e,s).map(o=>{var l;return{...o,inTicket:vS(o.value,(l=s==null?void 0:s.executionMapping)==null?void 0:l[o.key],a)}})}function yS(e,s){if(String(e)===String(s))return!0;if(typeof e=="boolean"||typeof s=="boolean"||e===""||s===""||e===null||s===null)return!1;const a=Number(e),o=Number(s);return Number.isFinite(a)&&Number.isFinite(o)&&a===o}function vS(e,s,a){return!s||!a||e===void 0||e===null?!1:(typeof s=="string"?[{field:s}]:Array.isArray(s)?s:[s]).some(l=>{if(!(l.field in a))return!1;const u=a[l.field];return l.divisor?Number.isFinite(Number(e))&&Number(e)/l.divisor===Number(u):l.transform==="join"?(Array.isArray(e)?e:[e]).map(g=>g&&typeof g=="object"&&"email"in g?String(g.email):String(g)).join(",")===String(u):l.transform?!1:yS(e,u)})}function rc(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function xS(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function Rh(e,s){return Object.entries(e).filter(([a,o])=>!xS(o)&&!(s&&a in s&&rc(s[a])===rc(o))).map(([a,o])=>({key:a,label:Wt(a),value:rc(o)}))}function wS(e,s){const a=e.structuredContent;if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.keys(a).length>0)return{kind:"rows",rows:Rh(a,s)};const o=e.text.trim();if(o.startsWith("{"))try{const l=JSON.parse(o);if(l&&typeof l=="object"&&!Array.isArray(l)&&Object.keys(l).length>0)return{kind:"rows",rows:Rh(l,s)}}catch{}return{kind:"text",text:e.text}}const Ph=new Map;function jS(e){let s=Ph.get(e);return s||(s=L.getProposal(e).catch(()=>null),Ph.set(e,s)),s}let ls=null;function SS(e){if(!ls||e*1e3>ls.fetchedAtMs){const s={fetchedAtMs:Date.now(),map:L.getTicketHeadlines().catch(()=>(ls===s&&(ls=null),{}))};ls=s}return ls.map}function bS({proposal:e,tool:s,manifests:a,label:o}){const l=ao(e);return n.jsx(n.Fragment,{children:Tp({tool:s,manifests:a,label:o,approved:!0,proposalArgs:l.toolArgs})})}function kS({ticketId:e,timestamp:s,proposalId:a,tool:o,manifests:l,label:u}){const[f,g]=h.useState(null),[p,v]=h.useState(null);return h.useEffect(()=>{let y=!0;return g(null),v(null),a?jS(a).then(w=>{y&&g(w)}):SS(s).then(w=>{y&&v(w[e]??null)}),()=>{y=!1}},[a,e,s]),a?f?n.jsx(bS,{proposal:f,tool:o,manifests:l,label:u}):n.jsx(n.Fragment,{children:u}):n.jsx(n.Fragment,{children:Tp({tool:o,manifests:l,label:u,approved:!1,sentArgs:p})})}const NS=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function CS(e,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:NS.test(e)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function Tr(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function $h({row:e,which:s}){const a=ma(e.profileRef),o=kw(e.value,a,s);return o.length===0?n.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:o.map(l=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-secondary)"},title:l.hint,children:l.label}),n.jsxs("dd",{style:{margin:0,fontWeight:600},children:[l.value,l.unknown&&n.jsx("span",{className:"msg-error",style:{marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},l.key))})}function ES({row:e}){const s=ma(e.profileRef),a=(s==null?void 0:s.id)??e.profileRef??"";return n.jsxs(n.Fragment,{children:[(s==null?void 0:s.name)??Mt(a),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function Ip({row:e,altText:s}){switch(e.kind){case"profile":return n.jsx(ES,{row:e});case"profile-limits":return n.jsx($h,{row:e,which:"limits"});case"profile-scope":return n.jsx($h,{row:e,which:"scope"});case"markdown":return n.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Tr(e.value)});case"list":return Array.isArray(e.value)?n.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:e.value.map((a,o)=>n.jsx("li",{children:Tr(a)},o))}):n.jsx(n.Fragment,{children:Tr(e.value)});case"money":return n.jsxs(n.Fragment,{children:[Tr(e.value),e.currency?` ${e.currency}`:""]});case"object":return n.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Tr(e.value)});default:return CS(e.key,e.value)?n.jsx("img",{src:e.value,alt:s??e.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):n.jsx(n.Fragment,{children:Tr(e.value)})}}function wc({args:e,display:s,heading:a="Details",requestRefArg:o}){const l=qm(e,s);if(l.length===0)return null;const u=typeof e.altText=="string"?e.altText:void 0;return n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a&&n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:a}),n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:l.map(f=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:f.hint,children:f.key===o?"Replying to":f.label}),n.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:f.key===o?n.jsx("span",{"data-testid":"request-ref",title:Tr(f.value),children:"the message shown under Request"}):n.jsx(Ip,{row:f,altText:u})})]},f.key))})]})}function Ri(e){return typeof e=="string"&&e.length>0}function TS(e){if(e===null||typeof e!="object")return!1;const s=e;return!(!Ri(s.filename)||!Ri(s.contentType)||!Ri(s.contentBase64)||!Ri(s.sha256)||s.pages!==void 0&&typeof s.pages!="number")}function Rp(e){return e.length<=9?e:`${e.slice(0,4)}…${e.slice(-4)}`}function AS(e){return`data:${e.contentType};base64,${e.contentBase64}`}function IS(e){if(e!==void 0)return e===1?"1 page":`${e} pages`}function Pp({doc:e,systemName:s,heading:a,sourceLine:o,trailingNote:l}){const u=AS(e),f=IS(e.pages),g=s?`Rendered by ${s}`:"Rendered",p=n.jsxs(n.Fragment,{children:[g," from the template and the values above. Not issued yet — no number is used until you approve."]});return n.jsxs("div",{className:"document-preview-box","data-testid":"document-preview",children:[n.jsx("h4",{children:a??"The PDF as it will be issued"}),n.jsxs("div",{className:"document-preview-body",children:[n.jsx("object",{data:u,type:e.contentType,className:"document-preview-frame","aria-label":`Preview of ${e.filename}`,children:n.jsxs("p",{className:"preview-note",children:["This browser can't preview the PDF inline. ",n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),"."]})}),n.jsxs("div",{className:"document-preview-meta",children:[n.jsx("div",{className:"document-preview-filename",children:e.filename}),f&&n.jsx("div",{className:"preview-note",children:f}),o&&n.jsx("div",{className:"preview-note",children:o}),n.jsxs("div",{className:"preview-note",children:["Fingerprint ",n.jsx("span",{className:"id-raw",title:e.sha256,children:Rp(e.sha256)})]}),n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),l!==null&&n.jsx("p",{className:"preview-note",children:l??p})]})]})]})}const RS="_attachmentsSealed";function PS(e){if(e===null||typeof e!="object")return!1;const s=e;return typeof s.connector=="string"&&typeof s.kind=="string"&&typeof s.id=="string"&&typeof s.filename=="string"&&typeof s.contentType=="string"&&typeof s.sha256=="string"&&typeof s.bytes=="number"}function $S(e){if(e===null||typeof e!="object")return!1;const s=e;return typeof s.placeholder=="string"&&typeof s.connector=="string"&&typeof s.kind=="string"&&typeof s.id=="string"&&typeof s.value=="string"}function Zc(e){const s={attachments:[],inserts:[]};if(!e)return s;const a=e[RS];if(a===null||typeof a!="object")return s;const o=a,l=Array.isArray(o.attachments)?o.attachments.filter(PS):[],u=Array.isArray(o.inserts)?o.inserts.filter($S):[];return{attachments:l,inserts:u}}function _S(e){return!Number.isFinite(e)||e<0?"—":e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function LS(e){return Zc(e).attachments.length===0?[]:[{key:"attachment-source",label:"attachment from an allowed source",ok:!0,valueText:"",limitText:""}]}function $p(e,s,a,o){var u,f,g;const l=(g=(f=(u=e==null?void 0:e.find(p=>p.id===s))==null?void 0:u.documents)==null?void 0:f[a])==null?void 0:g.label;if(l)return l.replace(/\{id\}/g,o)}function zS(e,s){return!e||!s||s==="loading"?null:s.status==="ok"?{key:"attachment-same-file",label:`same file as issued ${e}`,ok:!0,valueText:"",limitText:""}:s.status==="changed"?{key:"attachment-same-file",label:"attachment changed since it was sealed",ok:!1,valueText:"",limitText:""}:null}function FS({a:e,manifests:s,preview:a}){const o=Wn(e.connector,s),l=$p(s,e.connector,e.kind,e.id),u=n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"src-tag-value src-tag-system-cell",children:["from ",o]}),l?n.jsxs(n.Fragment,{children:[" — ",l]}):null]});return a&&a!=="loading"&&a.status==="ok"?n.jsx(Pp,{doc:{filename:a.filename,contentType:a.contentType,contentBase64:a.contentBase64,sha256:a.sha256},heading:"Attachment",sourceLine:u,trailingNote:null}):n.jsxs("div",{className:"document-preview-box","data-testid":"attachment-sealed",children:[n.jsx("h4",{children:"Attachment"}),n.jsxs("div",{className:"document-preview-meta",children:[n.jsx("div",{className:"document-preview-filename",children:e.filename}),n.jsx("div",{className:"preview-note",children:_S(e.bytes)}),n.jsx("div",{className:"preview-note",children:u}),n.jsxs("div",{className:"preview-note",children:["Fingerprint ",n.jsx("span",{className:"id-raw",title:e.sha256,children:Rp(e.sha256)})]}),!a||a==="loading"?n.jsx("div",{className:"preview-note",children:"Loading preview…"}):a.status==="changed"?n.jsx("p",{className:"preview-note","data-testid":"attachment-changed",style:{color:"var(--check-failed)",fontWeight:700},children:"✕ changed since it was sealed"}):n.jsx("div",{className:"preview-note",children:"Preview not available."})]})]})}function MS({i:e,manifests:s}){const a=Wn(e.connector,s);return n.jsxs("div",{className:"preview-box preview-box-sys","data-testid":"insert-sealed",children:[n.jsxs("h4",{children:["From ",a," — inserted by the gateway"]}),n.jsx("div",{style:{color:"var(--prov-system)",fontWeight:600,wordBreak:"break-word"},children:e.value})]})}function _p({attachments:e,inserts:s,manifests:a,fetchPreview:o,onChecks:l}){const[u,f]=h.useState({});return h.useEffect(()=>{if(!o)return;let g=!0;for(const p of e)f(v=>v[p.sha256]?v:{...v,[p.sha256]:"loading"}),o(p.sha256).then(v=>{g&&f(y=>({...y,[p.sha256]:v}))}).catch(()=>{g&&f(v=>({...v,[p.sha256]:{status:"unavailable",message:"Could not fetch the preview."}}))});return()=>{g=!1}},[e.map(g=>g.sha256).join(","),o]),h.useEffect(()=>{if(!l)return;const g=e.map(p=>zS($p(a,p.connector,p.kind,p.id),u[p.sha256])).filter(p=>p!==null);l(g)},[e,a,u,l]),e.length===0&&s.length===0?null:n.jsxs(n.Fragment,{children:[e.map(g=>n.jsx(FS,{a:g,manifests:a,preview:u[g.sha256]},`${g.connector}:${g.kind}:${g.id}`)),s.map(g=>n.jsx(MS,{i:g,manifests:a},`${g.placeholder}:${g.connector}:${g.kind}:${g.id}`))]})}let Pi=null;function OS(){return Pi||(Pi=L.getToolDisplay().catch(()=>(Pi=null,{}))),Pi}function Lp({args:e,display:s,executionContext:a,sealed:o}){const l=Ap(e,s,a);return l.length===0?null:n.jsx("dl",{className:"ticket-sent-fields",children:l.map(u=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{title:u.hint,children:u.label}),n.jsxs("dd",{className:o?"is-sealed":void 0,children:[n.jsx(Ip,{row:u}),u.inTicket&&n.jsx("span",{className:"ticket-sent-tag",title:"This value is also in the signed ticket",children:"in the ticket"})]})]},u.key))})}function _h({content:e,display:s,executionContext:a,sealed:o}){return typeof e=="string"?n.jsx("p",{className:`ticket-sent-text${o?" is-sealed":""}`,children:e}):n.jsx(Lp,{args:e,display:s,executionContext:a,sealed:o})}function Lh({check:e}){return e==="match"?n.jsx("p",{className:"ticket-sent-check",children:"✓ Matches what this gateway executed"}):e==="mismatch"?n.jsx("p",{className:"ticket-sent-check is-failed",children:"✕ Does not match what this gateway executed"}):n.jsx("p",{className:"ticket-sent-check is-neutral",children:"Could not be checked against this gateway's execution record."})}function BS({view:e,display:s,executionContext:a}){return e.level==="off-device"?n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-what-was-done","data-bound":"off-device",children:[n.jsx("h4",{children:"What was sent"}),n.jsx("p",{className:"ticket-sent-empty",children:"Only on the gateway that ran it — this device has no local copy. The signed ticket still proves the limits it ran under."})]}):e.level==="not-kept"?n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-what-was-done","data-bound":"not-kept","data-reason":e.reason,children:[n.jsx("h4",{children:"What was sent"}),n.jsxs("p",{className:"ticket-sent-empty",children:[e.reason==="too_large"?"Not kept — what was sent was too large to keep on this device.":"Not kept — this ticket is older than the release that started keeping it."," ","The signed ticket still proves the limits it ran under."]})]}):e.level==="sealed"?n.jsxs("div",{className:"ticket-sent-box is-sealed","data-testid":"ticket-what-was-done","data-bound":"sealed","data-check":e.check,children:[n.jsxs("h4",{children:["What was sent ",n.jsx("span",{className:"ticket-sent-q",children:"sealed in the ticket"})]}),n.jsx(_h,{content:e.bound,display:s,executionContext:a,sealed:!0}),e.check==="ok"?n.jsx("p",{className:"ticket-sent-check",children:"✓ Matches the fingerprint in the signed ticket"}):n.jsx("p",{className:"ticket-sent-check is-failed",children:"✕ Does not match the fingerprint in the signed ticket — this local copy was changed"}),e.extras&&Ap(e.extras,s,a).length>0&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ticket-sent-sub",children:"Also sent — recorded by this gateway, not sealed in the ticket"}),n.jsx(Lp,{args:e.extras,display:s,executionContext:a,sealed:!1}),e.argsCheck==="mismatch"&&n.jsx(Lh,{check:"mismatch"})]})]}):n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-what-was-done","data-bound":"recorded","data-check":e.check,children:[n.jsxs("h4",{children:["What was sent ",n.jsx("span",{className:"ticket-sent-q",children:"recorded by this gateway — not sealed in the ticket"})]}),n.jsx(_h,{content:e.content,display:s,executionContext:a,sealed:!1}),n.jsx(Lh,{check:e.check})]})}const zh=5;function DS({result:e,systemName:s,sent:a}){const o=wS(e,a),[l,u]=h.useState(!1);return n.jsxs("div",{className:"ticket-sent-box","data-testid":"ticket-result","data-ok":e.ok?"true":"false",children:[n.jsxs("h4",{children:["Result ",n.jsxs("span",{className:"ticket-sent-q",children:["what ",s," answered"]})]}),!e.ok&&n.jsx("p",{className:"ticket-sent-check",children:"The action failed."}),o.kind==="rows"?n.jsx("dl",{className:"ticket-sent-fields",children:(l?o.rows:o.rows.slice(0,zh)).map(f=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{children:f.label}),n.jsx("dd",{className:"is-system",children:f.value})]},f.key))}):n.jsx("p",{className:"ticket-sent-text is-system",children:o.text}),o.kind==="rows"&&o.rows.length>zh&&n.jsx("button",{type:"button",className:"ticket-sent-more",onClick:()=>u(f=>!f),children:l?"Show less":`Show all ${o.rows.length}`}),e.truncated&&n.jsx("p",{className:"ticket-sent-check is-neutral",children:"Shortened to fit what this device keeps."})]})}function Fh(e){var a;const s=[e.entry.sentArgs,(a=e.entry.proposal)==null?void 0:a.toolArgs,e.entry.boundContent];for(const o of s)if(o&&typeof o=="object"&&!Array.isArray(o))return o;return null}function zp({receipt:e,manifests:s}){var k;const[a,o]=h.useState(void 0),[l,u]=h.useState(null),[f,g]=h.useState(void 0),p=!!(e.contentHash&&e.contentBinding);h.useEffect(()=>{let S=!0;return OS().then(N=>{S&&g(N[e.action])}),()=>{S=!1}},[e.action]),h.useEffect(()=>{let S=!0;return o(void 0),u(null),(async()=>{let N;try{N=await L.getArchivedReceipt(e.id)}catch{S&&o(null);return}let T=null;const E=N==null?void 0:N.entry.boundContent;if(E!==void 0&&p)try{T=await ep(e.contentBinding.kind,E)===e.contentHash}catch{T=!1}S&&(u(T),o(N))})(),()=>{S=!1}},[e.id,e.contentHash,e.contentBinding,p]);const v=h.useCallback(S=>L.getReceiptAttachmentPreview(e.id,S),[e.id]);if(a===void 0)return n.jsx("div",{className:"ticket-sent-box ticket-sent-loading","data-testid":"ticket-what-was-done","data-bound":"loading","aria-busy":"true",children:"Loading…"});const y=(k=a==null?void 0:a.entry.proposal)==null?void 0:k.toolArgs,w=pS({offDevice:a===null,boundContent:a==null?void 0:a.entry.boundContent,sentArgs:a==null?void 0:a.entry.sentArgs,sentArgsOmitted:a==null?void 0:a.entry.sentArgsOmitted,proposalArgs:y&&typeof y=="object"&&!Array.isArray(y)?y:void 0,hasHashToCheck:p,hashVerified:l,sentArgsCheck:a==null?void 0:a.sentArgsCheck}),x=Wn(Un(e.action).integrationId,s),b=Zc((a?Fh(a):null)??void 0);return n.jsxs(n.Fragment,{children:[n.jsx(BS,{view:w,display:f,executionContext:e.executionContext}),n.jsx(_p,{attachments:b.attachments,inserts:b.inserts,manifests:s,fetchPreview:v}),(a==null?void 0:a.result)&&n.jsx(DS,{result:a.result,systemName:x,sent:Fh(a)})]})}function dn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ut(e,s=!1){return e==null?"—":typeof e=="string"?e:typeof e=="boolean"?String(e):typeof e=="number"?s||Number.isInteger(e)?String(e):String(Math.round(e*100)/100):"—"}function US(e){return e==null?!1:typeof e=="string"||Array.isArray(e)?e.length>0:!0}function Ir(e,s,a){const o=s?Object.keys(s).filter(l=>l in e):Object.keys(e);return o.length===0?"—":o.map(l=>{var p,v;const u=e[l],f=((p=s==null?void 0:s[l])==null?void 0:p.title)??Wt(l),g=dn(u)?Ir(u,(v=s==null?void 0:s[l])==null?void 0:v.properties,a):Ut(u,a);return`${f}: ${g}`}).join(" · ")}function WS(e,s){const a=s?Object.keys(s).filter(u=>e.some(f=>u in f)):[...new Set(e.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)??Wt(u)}}),l=e.map(u=>({cells:a.map(f=>{var y,w;const g=u[f],p=dn(g)?Ir(g,(y=s==null?void 0:s[f])==null?void 0:y.properties,!1):Ut(g),v=dn(g)?Ir(g,(w=s==null?void 0:s[f])==null?void 0:w.properties,!0):Ut(g,!0);return v===p?{value:p,sealed:!1}:{value:p,valueTitle:v,sealed:!1}})}));return{columns:o,rows:l}}function HS(e){return e.split(`
84
+ `).map(s=>s.startsWith("+")&&!s.startsWith("+++")?{text:s,kind:"add"}:s.startsWith("-")&&!s.startsWith("---")?{text:s,kind:"remove"}:{text:s,kind:"context"})}function VS(e,s){var l;if(Array.isArray(e)){if(e.length===0)return{value:"—"};if(e.every(y=>!dn(y)&&!Array.isArray(y))){if(e.every(x=>typeof x=="string"))return{lines:e};const y=e.map(x=>Ut(x)).join(", "),w=e.map(x=>Ut(x,!0)).join(", ");return w===y?{value:y}:{value:y,valueTitle:w}}const u=(l=s==null?void 0:s.items)==null?void 0:l.properties,f=e.map(y=>dn(y)?Ir(y,u,!1):Ut(y)),g=e.map(y=>dn(y)?Ir(y,u,!0):Ut(y,!0)),p=f.map((y,w)=>y===g[w]?void 0:g[w]),v=e.every(dn)?WS(e,u):void 0;return{lines:f,...p.some(y=>y!==void 0)?{lineTitles:p}:{},...v?{table:v}:{}}}if(dn(e)){const u=s==null?void 0:s.properties,f=u?Object.keys(u).filter(v=>v in e):Object.keys(e);if(f.length>0&&f.every(v=>!dn(e[v])&&!Array.isArray(e[v])))return{sublist:f.map(y=>{var S;const w=e[y],x=((S=u==null?void 0:u[y])==null?void 0:S.title)??Wt(y),b=Ut(w),k=Ut(w,!0);return k===b?{key:y,label:x,value:b}:{key:y,label:x,value:b,valueTitle:k}})};const g=Ir(e,u,!1),p=Ir(e,u,!0);return p===g?{value:g}:{value:g,valueTitle:p}}if(typeof e=="string"&&(s==null?void 0:s.contentMediaType)==="text/x-diff")return{diffLines:HS(e)};const a=Ut(e),o=Ut(e,!0);return o===a?{value:a}:{value:a,valueTitle:o}}function GS(e){let s;try{s=JSON.parse(e)}catch{return null}return dn(s)?s:null}function dr(e){const s=e!=null&&e.structured&&Object.keys(e.structured).length>0?e.structured:void 0;if(s)return{obj:s,schema:e==null?void 0:e.outputSchema};const a=e!=null&&e.text?GS(e.text):null;return a?{obj:a}:null}function Ki(e){const s=dr(e);if(!s)return[];const{obj:a,schema:o}=s,l=(o==null?void 0:o.properties)??{},u=[...new Set([...Object.keys(l),...Object.keys(a)])],f=[];for(const g of u){if(!(g in a))continue;const p=l[g],v=(p==null?void 0:p.title)??Wt(g),y={key:g,label:v,...VS(a[g],p)};p!=null&&p.description&&(y.description=p.description),f.push(y)}return f}function Fp(e,s){const a=dr(e);if(a){const l=Ki(e),u=s==null?void 0:s.fields;let f;if(u&&u.length>0){const v=new Map(l.map(y=>[y.key,y]));f=u.map(y=>v.get(y)).filter(y=>y!==void 0)}else f=l.filter(v=>US(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=e==null?void 0:e.text;return o&&o.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:o}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function Mh(e){return e?e.lines?`lines:${JSON.stringify(e.lines)}`:e.sublist?`sublist:${JSON.stringify(e.sublist.map(s=>[s.key,s.value]))}`:e.diffLines?`diffLines:${JSON.stringify(e.diffLines)}`:`value:${e.value??""}`:""}function $i(e){return{kind:e.length>0?"structured":"empty",fields:e,moreFields:[],totalFields:e.length}}function KS(e,s,a){const o=dr(e),l=dr(s);if(!o&&!l){const x=(e==null?void 0:e.text)??"",b=(s==null?void 0:s.text)??"";return x===b?{approved:$i([]),current:$i([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:x},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:b},unchanged:!1}}const u=new Map(Ki(e).map(x=>[x.key,x])),f=new Map(Ki(s).map(x=>[x.key,x])),p=[...new Set([...u.keys(),...f.keys()])].filter(x=>x===(a==null?void 0:a.excludeKey)?!1:Mh(u.get(x))!==Mh(f.get(x))),v=a!=null&&a.fields&&a.fields.length>0?[...a.fields.filter(x=>p.includes(x)),...p.filter(x=>!a.fields.includes(x))]:p,y=v.map(x=>u.get(x)).filter(x=>x!==void 0),w=v.map(x=>f.get(x)).filter(x=>x!==void 0);return{approved:$i(y),current:$i(w),unchanged:p.length===0}}function qS(e){const s=e==null?void 0:e.structured;if(Array.isArray(s)&&s.every(dn))return s;if(e!=null&&e.text){let a;try{a=JSON.parse(e.text)}catch{return null}if(Array.isArray(a)&&a.every(dn))return a}return null}function io(e){const s=Ut(e),a=Ut(e,!0);return a===s?{value:s}:{value:s,valueTitle:a}}function Mp(e){return!e||e.status!=="ok"?[]:Ki(e.body)}function jc(e){if(!e)return"Not read.";switch(e.status){case"not_found":return"Not found in the system.";case"none":return"Nothing to read.";default:return"Not available right now."}}function Op(e,s,a){var p;const o=Mp(e);if(o.length===0)return{rawId:Ut(s),context:[],unresolved:jc(e)};const l=e&&e.status==="ok"?(p=dr(e.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 k,S;if(!f)return v;const y=`${f}.${v.key}`,w=la(a==null?void 0:a.displayHints,y,v.label);if(!da((k=a==null?void 0:a.displayHints)==null?void 0:k.money,y)&&!da((S=a==null?void 0:a.displayHints)==null?void 0:S.percent,y))return w===v.label?v:{...v,label:w};const{value:x,valueTitle:b}=qi(l==null?void 0:l[v.key],a==null?void 0:a.displayHints,y,a==null?void 0:a.currency);return{...v,label:w,value:x,valueTitle:b}});return{name:u==null?void 0:u.value,rawId:Ut(s),context:g}}const YS=new Set(["id","name","title","label"]);function da(e,s){return!!(e!=null&&e.includes(s))}function la(e,s,a){var o;return((o=e==null?void 0:e.labels)==null?void 0:o[s])??a}function JS(e,s){const a=typeof e=="number"?e:Number(e);return Number.isFinite(a)?{value:`${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${s?` ${s}`:""}`}:io(e)}function QS(e){return typeof e!="number"&&typeof e!="string"?io(e):{value:`${e} %`}}function qi(e,s,a,o){return da(s==null?void 0:s.money,a)?JS(e,o):da(s==null?void 0:s.percent,a)?QS(e):io(e)}function Bp(e,s){return da(e==null?void 0:e.hidden,s)}function XS(e,s,a){var f;const o=e==null?void 0:e.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 ZS(e,s,a,o){const l=e.forEach??"",u=e.attach,f=e.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!==e.sourceArg).filter(S=>!Bp(a,`${l}[].${S}`)),w=new Map;if(u)for(const S of v)for(const N of Mp(S))w.has(N.key)||w.set(N.key,N.label);const x=u?[...w.keys()].filter(S=>!YS.has(S)):[],b=[];u&&b.push({key:`__attach:${u}`,label:la(a,`${l}[].${u}`,Wt(e.sourceArg??u))});for(const S of y)b.push({key:`bound:${S}`,label:la(a,`${l}[].${S}`,Wt(S))});for(const S of x)b.push({key:`attached:${S}`,label:la(a,`${l}[].${u}.${S}`,w.get(S)??Wt(S))});const k=p.map((S,N)=>{var I;const T=v[N],E=[];if(u){const B=Op(T,e.sourceArg?S[e.sourceArg]:void 0),M=B.name?`${B.name} (${B.rawId})`:B.unresolved?`${B.rawId} — ${B.unresolved}`:B.rawId;E.push({value:M,sealed:!1})}for(const B of y){const{value:M,valueTitle:q}=qi(S[B],a,`${l}[].${B}`,o);E.push({value:M,valueTitle:q,sealed:!0})}const P=T&&T.status==="ok"?(I=dr(T.body))==null?void 0:I.obj:void 0;for(const B of x){const M=P==null?void 0:P[B],{value:q,valueTitle:z}=M!==void 0?qi(M,a,`${l}[].${u}.${B}`,o):{value:"—",valueTitle:void 0};E.push({value:q,valueTitle:z,sealed:!1})}return{cells:E}});return{columns:b,rows:k,...e.overflow?{overflowNote:`${e.overflow.total-e.overflow.shown} more not shown`}:{}}}function eb(e){return`${Wt(e)} — from the system`}function tb(e){var l;const s=eb(e.tool),a=e.result;if(e.kind==="document"){if(a&&a.status==="ok"){const u=(l=dr(a.body))==null?void 0:l.obj;return u&&TS(u)?{heading:s,document:u}:{heading:s,note:"Could not show a preview — the connector’s answer was not in the expected shape."}}return(a==null?void 0:a.status)==="unavailable"&&a.reason==="no_connector"?null:{heading:s,note:jc(a)}}if(!a||a.status!=="ok")return{heading:s,note:jc(a)};const o=qS(a.body);if(o){if(o.length===0)return{heading:s,note:"Nothing found."};const u=[...new Set(o.flatMap(p=>Object.keys(p)))],f=u.map(p=>({key:p,label:Wt(p)})),g=o.map(p=>({cells:u.map(v=>({...io(p[v]),sealed:!1}))}));return{heading:s,table:{columns:f,rows:g}}}return{heading:s,body:Fp(a.body,{fields:e.fields})}}function nb(e,s,a){const o=new Map(s.filter(x=>x.attach&&!x.forEach).map(x=>[x.attach,x])),l=new Map(s.filter(x=>x.forEach).map(x=>[x.forEach,x])),u=s.filter(x=>!x.attach&&!x.forEach),g=XS(a,e,x=>{var k,S;const b=(k=o.get(x))==null?void 0:k.result;return b&&b.status==="ok"?(S=dr(b.body))==null?void 0:S.obj:void 0}),p=(a==null?void 0:a.order)??[],v=[...new Set([...p,...Object.keys(e)])],y=[];for(const x of v){if(!(x in e)||Km.has(x)||Bp(a,x))continue;const b=la(a,x,Wt(x)),k=l.get(x);if(k){const E=Array.isArray(e[x])?e[x]:[];y.push({kind:"table",key:x,label:b,table:ZS(k,E,a,g)});continue}const S=o.get(x);if(S){const E=Op(S.result,e[x],{pathPrefix:x,displayHints:a,currency:g});y.push({kind:"identity",key:x,label:b,identity:E});continue}const{value:N,valueTitle:T}=qi(e[x],a,x,g);y.push({kind:"scalar",key:x,label:b,value:N,valueTitle:T})}const w=u.map(tb).filter(x=>x!==null);return{rows:y,sections:w}}const Oh=500;function Sc(e){return e.length>Oh?`${e.slice(0,Oh)}…`:e}function Bh(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function rb(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Dp(e,s,a){switch(e.status){case"none":return e.reason==="no_target"?{heading:"Nothing to read beforehand",note:`This action does not refer to an existing record — nothing to read beforehand. Showing exactly what will be sent to ${s}.`}:{heading:"No preview declared",note:`No preview declared for this tool — showing exactly what will be sent to ${s}.`};case"unavailable":return e.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:e.message?`Preview not available — ${Sc(e.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:e.message?`Not found in your system — ${Sc(e.message)}`:"Not found in your system."};case"ok":{if("reads"in e)return{heading:`What will be created in ${s}`,note:`Read by the gateway, not by the AI — read at ${rb(e.readAt)}.`,creation:nb(a??{},e.reads,e.display)};const o=Fp(e.body,{fields:e.fields}),l={heading:`From ${s}, before it runs`,note:`Read by the gateway with ${e.tool} when you opened this card — the AI is not involved.`,rendered:o},u=e.version;if(u&&(l.versionNote=`You approve ${u.field} ${u.approved}; if it changes, ${s} refuses it.`,u.stale)){const f=KS(e.body,u.currentBody,{fields:e.fields,excludeKey:u.field});l.stale={heading:`A newer ${u.field} exists (${u.current})`,approvedLabel:`${Bh(u.field)} ${u.approved}`,currentLabel:`${Bh(u.field)} ${u.current}`,...f.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:f.approved,currentRendered:f.current}}}return l}}}function sb(e,s){if(e.state!=="failed")return null;const a=e.detail?Sc(e.detail):void 0;return e.outcome==="changed"?{heading:"Changed since your approval",note:`The record changed in ${s} since you approved it — nothing was done. Ask the AI to request it again.`}:{heading:`Refused by ${s}`,note:`${s} refused it${a?`: ${a}`:""} — nothing was done. Ask the AI to request it again.`}}function ab(e){return e!==null&&e!=="loading"&&e!=="ok"&&e!=="stale"}function Yi({table:e}){return e.columns.length===0?n.jsx("p",{className:"preview-note",children:"Nothing to show."}):n.jsxs(n.Fragment,{children:[n.jsxs("table",{className:"preview-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.columns.map(s=>n.jsx("th",{children:s.label},s.key))})}),n.jsx("tbody",{children:e.rows.map((s,a)=>n.jsx("tr",{children:s.cells.map((o,l)=>n.jsx("td",{className:o.sealed?"src-tag-value src-tag-sealed-cell":"src-tag-value src-tag-system-cell",title:o.valueTitle,children:o.value},l))},a))})]}),e.overflowNote&&n.jsx("p",{className:"preview-note",children:e.overflowNote})]})}function Dh({row:e}){return n.jsxs("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:[e.label,e.description&&n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.72rem",fontWeight:400,whiteSpace:"normal",marginTop:"0.1rem"},children:e.description})]})}function ib({row:e}){return e.sublist?n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.6rem",margin:0},children:e.sublist.map(s=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:s.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},title:s.valueTitle,children:s.value})]},s.key))}):e.diffLines?n.jsx("div",{style:{fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.8rem"},children:e.diffLines.map((s,a)=>n.jsx("div",{style:s.kind==="remove"?{textDecoration:"line-through",color:"var(--text-muted)"}:s.kind==="add"?{fontWeight:600}:void 0,children:s.text||" "},a))}):e.table?n.jsx(Yi,{table:e.table}):e.lines?n.jsx("div",{children:e.lines.map((s,a)=>{var o;return n.jsx("div",{title:(o=e.lineTitles)==null?void 0:o[a],children:s},a)})}):n.jsx("span",{title:e.valueTitle,children:e.value})}function bc({rows:e}){return n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.map(s=>s.table?n.jsxs("div",{style:{gridColumn:"1 / -1"},children:[n.jsx(Dh,{row:s}),n.jsx(Yi,{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(ib,{row:s})})]},s.key))})}function sc({rendered:e}){return e.kind==="empty"?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):e.kind==="text"?n.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.text}):n.jsxs(n.Fragment,{children:[n.jsx(bc,{rows:e.fields}),e.moreFields.length>0&&n.jsxs("details",{style:{fontSize:"0.8rem"},children:[n.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",e.totalFields,")"]}),n.jsx(bc,{rows:e.moreFields})]})]})}function ob({identity:e}){return e.unresolved?n.jsxs("span",{children:[n.jsx("span",{className:"id-raw",children:e.rawId})," ",n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["— ",e.unresolved]})]}):n.jsxs("span",{children:[e.name&&n.jsx("span",{className:"src-tag-value src-tag-system-cell",children:e.name})," ",n.jsx("span",{className:"id-raw",children:e.rawId}),e.context.length>0&&n.jsx("span",{className:"creation-context",children:e.context.map(s=>n.jsxs("span",{children:[" · ",s.label," ",s.value]},s.key))})]})}function lb({view:e,systemName:s}){return n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.rows.map(a=>a.kind==="table"?null:n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:a.label}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:a.kind==="identity"?n.jsx(ob,{identity:a.identity}):n.jsx("span",{className:"src-tag-value src-tag-sealed-cell",title:a.valueTitle,children:a.value})})]},a.key))}),e.rows.filter(a=>a.kind==="table").map(a=>n.jsxs("div",{style:{margin:"0.5rem 0"},children:[n.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.78rem",marginBottom:"0.2rem"},children:a.label}),n.jsx(Yi,{table:a.table})]},a.key)),e.sections.map((a,o)=>n.jsx("div",{className:"creation-own-section",children:a.document?n.jsx(Pp,{doc:a.document,systemName:s}):n.jsxs(n.Fragment,{children:[n.jsxs("h5",{children:[a.heading," ",n.jsx("span",{className:"src-tag src-tag-system",children:"from the system"})]}),a.table&&n.jsx(Yi,{table:a.table}),a.body&&n.jsx(bc,{rows:a.body.fields}),a.note&&n.jsx("p",{className:"preview-note",children:a.note})]})},o))]})}function Up({resp:e,systemName:s,toolArgs:a,sealed:o}){const l=Dp(e,s,a??void 0),u=e.status==="ok"?l.stale?"stale":"ok":e.status;return u==="none"?n.jsx("p",{className:"sr-only","data-testid":"approval-preview","data-preview-status":"none",children:l.note}):n.jsxs("div",{className:`preview-box preview-box-${u}`,"data-testid":"approval-preview","data-preview-status":u,children:[n.jsxs("h4",{children:[l.heading,l.creation&&(o?n.jsx(n.Fragment,{children:n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})}):n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"}))]}),l.creation&&n.jsx(lb,{view:l.creation,systemName:s}),l.rendered&&n.jsx(sc,{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(sc,{rendered:l.stale.approvedRendered})}),n.jsx("dt",{children:l.stale.currentLabel}),n.jsx("dd",{children:n.jsx(sc,{rendered:l.stale.currentRendered})})]})]})]})}function cb({proposalId:e,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),L.getProposalPreview(e).then(w=>{y&&g(w)}).catch(()=>{y&&v(!0)}),()=>{y=!1}},[e]),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=Dp(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(Up,{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 ac=6;function Ji(e){if(!e)return;const s=Date.parse(e);return Number.isNaN(s)?e:new Date(s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ub(e){if(!e)return{first:""};const s=e.split(`
85
+ `);return s.length<=ac?{first:e}:{first:s.slice(0,ac).join(`
86
+ `),more:s.slice(ac).join(`
87
+ `)}}const db="Linked by the AI",fb="linked automatically — this action already carried a reference to it";function hb(e){if(e.status==="none")return{state:"none",note:"No request linked.",chain:[]};if(e.status==="unreadable")return{state:"unreadable",note:`Request: link not readable (${e.reason}).`,chain:[]};if(e.status==="not_found")return{state:"not_found",note:"Request: this message no longer exists.",chain:[]};const{first:s,more:a}=ub(e.body),o=[e.connector,e.kind,e.author?`from ${e.author}`:void 0,Ji(e.at)].filter(l=>!!l);return{state:"ok",implicit:e.implicit,tag:db,...e.implicit?{implicitNote:fb}:{},metaLine:o.join(" · "),title:e.title,bodyFirst:s,bodyMore:a,attribution:e.author?`— from ${e.author}, not checked`:void 0,chain:e.chain.map(l=>({...l,at:Ji(l.at)}))}}const ta="Read by the gateway — same customer, not matched to this request";function mb(e){const s=e.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${e.matchedKeyValue} (${s})`}function pb(e){var l;const s=!!e.aiWritten,a=s?"Activity":e.type??e.kind??"Entry";let o;if(s){const u=((l=e.aiWritten)==null?void 0:l.at)!==void 0?Ji(new Date(e.aiWritten.at).toISOString()):void 0;o=u?`— Written by the AI via Suveren, ${u} — not checked`:"— Written by the AI via Suveren — not checked"}else o=e.author?`— from ${e.author}, not checked`:"— not checked";return{headLabel:a,at:Ji(e.at),title:e.title,body:e.body,attribution:o,aiWritten:s}}function gb(e){if(e.status==="no_customer_link")return{state:"no_customer_link",label:ta,note:"No customer link — nothing to match history against.",matchNotes:[],items:[]};if(e.status==="no_match")return{state:"no_match",label:ta,note:"No match — no connector here matches on this customer's available identity key.",matchNotes:[],items:[]};if(e.status==="unreachable")return{state:"unreachable",label:ta,note:`${e.connectorIds.join(", ")} not reachable — history could not be read.`,matchNotes:[],items:[]};const s=e.matches.flatMap(l=>l.items.map(u=>({it:u,m:l}))).sort((l,u)=>(Date.parse(u.it.at??"")||0)-(Date.parse(l.it.at??"")||0)).map(({it:l})=>pb(l)),a=e.matches.map(mb),o=e.unreachableConnectorIds.length>0?`${e.unreachableConnectorIds.join(", ")} not reachable — showing what could be read.`:void 0;return s.length===0?{state:"empty",label:ta,note:"Nothing in the last few days.",matchNotes:a,items:[],unreachableNote:o}:{state:"ok",label:ta,note:"",matchNotes:a,items:s,unreachableNote:o}}function Wp({resp:e}){const s=hb(e.request),a=gb(e.history);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"au10-request","data-request-status":s.state,children:[n.jsxs("h4",{children:["Request",s.tag&&n.jsx("span",{className:"src-tag src-tag-ai",children:s.tag})]}),s.state!=="ok"?n.jsx("p",{className:"au10-req-state",children:s.note}):n.jsxs(n.Fragment,{children:[s.implicitNote&&n.jsx("p",{className:"au10-req-meta",style:{marginTop:"-0.1rem"},children:s.implicitNote}),s.metaLine&&n.jsx("p",{className:"au10-req-meta",children:s.metaLine}),s.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:s.title})}),s.bodyFirst&&n.jsx("p",{className:"au10-req-quote",children:s.bodyFirst}),s.bodyMore&&n.jsxs("details",{children:[n.jsx("summary",{children:"Show more"}),n.jsx("p",{className:"au10-req-quote",children:s.bodyMore})]}),s.attribution&&n.jsx("p",{className:"au10-req-attrib",children:s.attribution}),s.chain.length>0&&n.jsxs("details",{className:"au10-chain",children:[n.jsxs("summary",{children:["Earlier in this thread (",s.chain.length,")"]}),s.chain.map((o,l)=>n.jsxs("div",{className:"au10-chain-item",children:[(o.author||o.at)&&n.jsxs("p",{className:"au10-req-meta",children:[o.author?n.jsxs(n.Fragment,{children:["from ",n.jsx("b",{children:o.author})]}):null,o.author&&o.at?" · ":"",o.at]}),o.title&&n.jsx("p",{className:"au10-req-meta",children:n.jsx("b",{children:o.title})}),o.body&&n.jsx("p",{className:"au10-req-quote",children:o.body}),o.author&&n.jsxs("p",{className:"au10-req-attrib",children:["— from ",o.author,", not checked"]})]},l))]})]})]}),n.jsxs("div",{className:`preview-box ${a.state==="unreachable"?"preview-box-unreachable":"preview-box-sys"}`,"data-testid":"au10-history","data-history-status":a.state,children:[n.jsxs("h4",{children:["History",n.jsx("span",{className:"src-tag src-tag-system",children:a.label})]}),a.state!=="ok"?n.jsx("p",{className:"au10-hist-state",children:a.note}):n.jsxs(n.Fragment,{children:[a.matchNotes.map((o,l)=>n.jsx("p",{className:"preview-note",style:{marginTop:0},children:o},l)),n.jsx("ul",{className:"au10-hist-list",children:a.items.map((o,l)=>n.jsxs("li",{className:"au10-hist-item",children:[n.jsxs("div",{className:"au10-hist-head",children:[n.jsxs("span",{children:[o.aiWritten&&n.jsx("span",{className:"au10-dot au10-dot-ai"}),o.headLabel]}),n.jsx("span",{children:o.at})]}),o.title&&n.jsx("div",{className:"au10-hist-title",children:o.title}),o.body&&n.jsx("div",{className:"au10-hist-body",children:o.body}),n.jsx("p",{className:"au10-hist-attrib",children:o.attribution})]},l))}),a.unreachableNote&&n.jsx("p",{className:"preview-note",children:a.unreachableNote})]})]})]})}function yb({proposalId:e,onData:s}){const[a,o]=h.useState(null),[l,u]=h.useState(!1);return h.useEffect(()=>{let f=!0;return o(null),u(!1),L.getProposalRequestContext(e).then(g=>{f&&o(g)}).catch(()=>{f&&u(!0)}),()=>{f=!1}},[e]),h.useEffect(()=>{s==null||s(l?null:a)},[a,l,s]),l||!a?null:n.jsx(Wp,{resp:a})}function vb(e,s,a){const o=Object.entries(e??{});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 xb(e){return e.offDevice?"off-device":e.recordedHash?e.localHash===e.recordedHash?"verified":"mismatch":"unchecked"}function wb(e){if(!(e<=0))return`${e} other approver${e===1?"":"s"} recorded their own.`}function jb(e){return new Date(e).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function Hp({proposalId:e,tool:s,manifests:a}){const{user:o,domain:l}=wt(),[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([L.getShownSnapshot(e),L.getProposal(e)]).then(([I,B])=>{P&&(f(I),p(B))}).catch(()=>{P&&y(!0)}),()=>{P=!1}},[e]),v||!u||!g)return null;const w=u.status==="off_device",{entry:x,otherCount:b}=vb(g.shownHashes,(o==null?void 0:o.id)??"",l),k=xb({offDevice:w,recordedHash:x==null?void 0:x.hash,localHash:u.status==="ok"?u.shownHash:void 0}),S=wb(b);if(w)return n.jsxs("div",{className:"ticket-box ticket-shown-off-device","data-testid":"au10-shown","data-shown-status":"off-device",children:[n.jsx("h4",{children:"What you saw"}),n.jsx("p",{className:"ticket-done-note",children:"Only on the approving gateway — this device has no local copy."})]});const{snapshot:N}=u,{integrationId:T}=Un(s),E=Wn(T,a);return n.jsxs("div",{className:`ticket-box ticket-shown-${k}`,"data-testid":"au10-shown","data-shown-status":k,children:[n.jsxs("h4",{children:["What you saw (read ",jb(N.readAt),")",k==="verified"&&n.jsx("span",{className:"src-tag src-tag-sealed",children:"verified"}),k==="mismatch"&&n.jsx("span",{className:"src-tag src-tag-danger",children:"does not match what was approved"})]}),n.jsx(Up,{resp:N.preview,systemName:E,toolArgs:N.toolArgs,sealed:N.sealed}),n.jsx(Wp,{resp:N.requestContext}),k==="verified"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-ok",children:"✓ Matches the fingerprint recorded with your approval."}),k==="mismatch"&&n.jsx("p",{className:"ticket-done-note ticket-done-note-bad",children:"⚠ This copy differs from the fingerprint recorded with your approval."}),k==="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 na({label:e,children:s}){return n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"receipt-row-label",children:e}),n.jsx("dd",{className:"receipt-row-value",children:s})]})}function Sb({receipt:e,manifests:s,localAuth:a,localUnavailable:o,signature:l,grantTitle:u,ownerLabel:f,spUrl:g,formatDate:p,onOpenComplete:v,isNew:y=!1,defaultOpen:w=!1}){var Z;const x=ma(e.profileId),b=Nw(e,x),k=Cw(a==null?void 0:a.context,x),S=Tw(e,(a==null?void 0:a.bounds)??e.limits,x),N=a==null?void 0:a.intent,T=_r(e.profileId).testSetup||no(e.action),[E,P]=h.useState(!1),[I,B]=h.useState(w),M=Date.now(),q=Lr(),z=$r(e.profileId,q),U=l==="valid"||l==="valid-legacy";return n.jsxs("div",{className:`ticket-obj ticket-obj-card${y?" is-new":""}${I?" is-open":""}`,"data-new":y?"true":"false",children:[n.jsxs("div",{className:"ticket-obj-main",children:[n.jsxs("button",{type:"button",className:"ticket-obj-head","aria-expanded":I,onClick:()=>B(G=>!G),children:[n.jsx(us,{profileId:e.profileId,area:z,system:pa(e.action,s),time:Ui(e.timestamp,M),leading:y?n.jsx("span",{className:"seen-dot is-new","aria-label":"new since your last visit"}):void 0}),n.jsxs("div",{className:"receipt-head",children:[n.jsx("span",{className:"receipt-what","data-testid":"ticket-headline",children:n.jsx(kS,{ticketId:e.id,timestamp:e.timestamp,proposalId:e.proposalId,tool:e.action,manifests:s,label:so(e,s)})}),n.jsx("span",{className:"receipt-tag",children:Bi(e)?"approved":"automatic"}),e.contentHash&&n.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(Z=e.contentBinding)!=null&&Z.fields?`Sealed in the ticket: ${e.contentBinding.fields.join(", ")} — exactly this content was sent`:"Sealed in the ticket — exactly this content was sent",children:"content sealed"}),T&&n.jsx("span",{className:"sim-mark",children:"Test setup"})]}),n.jsx(ua,{title:u,area:z}),b&&n.jsx("div",{className:"receipt-scope",children:b})]}),I&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"receipt-when",children:p(e.timestamp)}),n.jsx(zp,{receipt:e,manifests:s}),e.proposalId&&n.jsx(Hp,{proposalId:e.proposalId,tool:e.action,manifests:s}),n.jsxs("dl",{className:"receipt-rows",children:[n.jsxs(na,{label:"mandate",children:[n.jsx("strong",{children:u||Iw(e.profileId)})," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),f&&n.jsx(na,{label:"owner",children:f}),k&&n.jsxs(na,{label:"allowed",children:[k," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}),S&&n.jsxs(na,{label:"used",children:[n.jsx("span",{className:"receipt-num",children:S})," ",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx(na,{label:"intent",children:N?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:`intent-text${E?"":" intent-clamped"}`,children:N}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>P(!E),children:E?"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/${e.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),n.jsxs("details",{className:"receipt-more",children:[n.jsx("summary",{children:"Raw"}),n.jsxs("div",{className:"receipt-kv",children:[n.jsxs("div",{children:["ticket · ",e.id]}),n.jsxs("div",{children:["action · ",e.action]}),n.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&n.jsxs("div",{children:["mandate · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&n.jsxs("div",{children:["scope ·"," ",Object.entries(e.executionContext).map(([G,O])=>`${G}=${O}`).join(" · ")]}),(a==null?void 0:a.boundsHash)&&n.jsxs("div",{children:["bounds hash · ",a.boundsHash]}),(a==null?void 0:a.contextHash)&&n.jsxs("div",{children:["scope hash · ",a.contextHash]}),e.contentHash&&n.jsxs("div",{children:["content · ",e.contentHash]}),e.proposalId&&n.jsxs("div",{children:["proposal · ",e.proposalId]}),n.jsxs("div",{children:["signature · ",e.signature]})]})]})]})]}),n.jsxs("div",{className:"ticket-obj-stub",children:[n.jsx("span",{className:"ticket-obj-no",title:e.id,children:Zm(e.id)}),n.jsx("span",{className:"ticket-obj-time",children:Ui(e.timestamp,M)}),U&&n.jsx("span",{className:"ticket-obj-sig",title:"Signature checked on this device",children:"✓ verified"})]})]})}function bb({receipt:e,onClose:s}){const[a,o]=h.useState(null),[l,u]=h.useState(null),[f,g]=h.useState(null),[p,v]=h.useState(!0),[y,w]=h.useState(!1);h.useEffect(()=>{let N=!1;return v(!0),L.getArchivedReceipt(e.id).then(T=>{N||(o(T),u(T?"local":"authority-server"),g((T==null?void 0:T.signature)??null))}).catch(()=>{N||u("authority-server")}).finally(()=>{N||v(!1)}),()=>{N=!0}},[e.id]);const x=a?a.entry:{receipt:e},b=JSON.stringify(x,null,2);function k(){const N=URL.createObjectURL(new Blob([b],{type:"application/json"})),T=document.createElement("a");T.href=N,T.download=`suveren-ticket-${e.id.slice(0,8)}.json`,T.click(),URL.revokeObjectURL(N)}async function S(){try{await navigator.clipboard.writeText(b),w(!0),setTimeout(()=>w(!1),2e3)}catch{w(!1)}}return n.jsx("div",{className:"modal-backdrop",onClick:N=>N.target===N.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:b})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:k,children:"Download"}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:S,children:y?"Copied":"Copy"})]})]})})}function kb(e){return new Date(e*1e3).toLocaleString()}function Nb(e,s){if(s==="all")return!0;const a=s==="1d"?1:s==="7d"?7:30,o=Math.floor(Date.now()/1e3)-a*86400;return e.timestamp>=o}function Cb(e,s,a){const o=s.trim().toLowerCase();return o?[...a,e.id,e.action,e.profileId,JSON.stringify(e.executionContext??{})].some(u=>typeof u=="string"&&u.toLowerCase().includes(o)):!0}function Uh(e,s){const a=new Map(e.map(o=>[o.id,o]));for(const o of s)a.set(o.id,o);return[...a.values()].sort((o,l)=>l.timestamp-o.timestamp)}function Eb(){const{activeTeam:e,groupId:s}=wt(),a=(e==null?void 0:e.isAdmin)===!0,[o,l]=h.useState("mine"),[u,f]=gs(),g=Pw(u.get("filter")),p=W=>{const xe=new URLSearchParams(u);W==="all"?xe.delete("filter"):xe.set("filter",W),f(xe,{replace:!0})},v=Vm(u.get("area")),y=W=>{const xe=new URLSearchParams(u);W===null?xe.delete("area"):xe.set("area",W),f(xe,{replace:!0})},w=Lr(),[x,b]=h.useState(null),k=h.useRef(!1),[S,N]=h.useState([]),[T,E]=h.useState([]),[P,I]=h.useState(""),[B,M]=h.useState(!0),[q,z]=h.useState({}),[U,Z]=h.useState(new Set),[G,O]=h.useState(""),[ne,fe]=h.useState(new Set),[ee,pe]=h.useState("all"),[Ne,X]=h.useState(!1),[Q,Y]=h.useState(!1),[A,_]=h.useState(null),[se,te]=h.useState({}),[H,ie]=h.useState(!1),[ue,ge]=h.useState({}),[ve,le]=h.useState({}),[qe,be]=h.useState(null),[oe,Le]=h.useState(null),[ze,Ue]=h.useState(!1),[we,nt]=h.useState(!1),Ze=h.useRef(""),Ye=h.useCallback(W=>o==="team"&&a&&s?L.listTeamReceiptsPage(s,{before:W,limit:200}):L.getMyReceiptsPage({before:W,limit:200}),[o,a,s]),We=h.useCallback(()=>{const W=o==="team"?`team:${s}`:"mine",xe=Ze.current!==W;Ze.current=W,M(!0),nt(!1),Ye().then(Ae=>{N(st=>xe?Ae.receipts:Uh(st,Ae.receipts)),Le(st=>xe?Ae.nextBefore:st??Ae.nextBefore)}).catch(()=>{xe&&N([]),nt(!0)}).finally(()=>M(!1))},[Ye,o,s]),dt=h.useCallback(()=>{!oe||ze||(Ue(!0),nt(!1),Ye(oe).then(W=>{N(xe=>Uh(xe,W.receipts)),Le(W.nextBefore)}).catch(()=>nt(!0)).finally(()=>Ue(!1)))},[oe,ze,Ye]);Ft(We,12e4);const ft=h.useCallback(()=>{We(),x!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||L.markTicketsSeen(Date.now()).catch(()=>{}))},[We,x]);Me("ticket-recorded",ft),h.useEffect(()=>{B||k.current||(k.current=!0,L.getLastSeenTicketsAt().then(W=>(b(W),L.markTicketsSeen(Date.now()))).catch(()=>b(Number.POSITIVE_INFINITY)))},[B]),h.useEffect(()=>{L.getLabelManifests().then(E).catch(()=>{}),fetch("/health").then(W=>W.json()).then(W=>{typeof W.spUrl=="string"&&I(W.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),h.useEffect(()=>{L.getLocalAuthorizations().then(({authorizations:W,signatures:xe})=>{te(W),ge(xe),ie(!1)}).catch(()=>{te({}),ge({}),ie(!0)}),L.getMyAttestations().then(W=>{const xe={};for(const Ae of W)Ae.authorization_id&&Ae.title&&(xe[Ae.authorization_id]=Ae.title);le(xe)}).catch(()=>{})},[]),h.useEffect(()=>{o!=="team"||Object.keys(q).length>0||L.listUsers().then(W=>{const xe={};for(const Ae of W)xe[Ae.id]={name:Ae.name,email:Ae.email};z(xe)}).catch(()=>{})},[o,q]);const Fe=h.useMemo(()=>{const W=new Set;for(const xe of S)W.add(xe.action);return[...W].sort()},[S]),me=h.useMemo(()=>{if(o!=="team")return[];const W=new Set;for(const xe of S)xe.userId&&W.add(xe.userId);return[...W].map(xe=>{var Ae;return{id:xe,label:(Ae=q[xe])!=null&&Ae.name?`${q[xe].name} (${q[xe].email})`:xe}}).sort((xe,Ae)=>xe.label.localeCompare(Ae.label))},[o,S,q]),Re=h.useMemo(()=>S.filter(W=>!(!Cb(W,G,[Bn(W.profileId,w),so(W,T),Wn(Un(W.action).integrationId,T),W.authorizationId?ve[W.authorizationId]:null])||ne.size>0&&!ne.has(W.action)||U.size>0&&W.userId&&!U.has(W.userId)||!Nb(W,ee))),[S,G,w,T,ve,ne,U,ee]),Oe=h.useMemo(()=>{const W={automatic:0,approved:0,all:0};for(const xe of Re)W.all+=1,W[gc(xe,"approved")?"approved":"automatic"]+=1;return W},[Re]),K=h.useMemo(()=>Re.filter(W=>gc(W,g)),[Re,g]),J=h.useMemo(()=>{const W=new Map;for(const xe of K){const Ae=In(xe.profileId),st=W.get(Ae);st?st.count+=1:W.set(Ae,{shortId:Ae,icon:Pr(xe.profileId),name:Bn(xe.profileId,w),count:1})}return[...W.values()].sort((xe,Ae)=>xe.name.localeCompare(Ae.name))},[K,w]),ye=h.useMemo(()=>K.filter(W=>Gm(W.profileId,v)),[K,v]),He=h.useMemo(()=>x===null?0:ye.filter(W=>Di(W,x)).length,[ye,x]),Ve=ne.size>0||U.size>0||ee!=="all";function rt(W){fe(xe=>{const Ae=new Set(xe);return Ae.has(W)?Ae.delete(W):Ae.add(W),Ae})}function Ht(W){Z(xe=>{const Ae=new Set(xe);return Ae.has(W)?Ae.delete(W):Ae.add(W),Ae})}function Ot(){fe(new Set),Z(new Set),pe("all"),O("")}async function et(){Y(!0),_(null);try{const{bundle:W,filename:xe}=await L.fetchEvidenceBundle(),Ae=URL.createObjectURL(new Blob([JSON.stringify(W,null,2)],{type:"application/json"})),st=document.createElement("a");st.href=Ae,st.download=xe,st.click(),URL.revokeObjectURL(Ae);const yt=W.sources??{};yt.authorityServer?yt.local||_(`Downloaded Authority Server history only — ${yt.localError??"local archive unavailable."}`):_(`Downloaded local evidence only — ${yt.asError??"Authority Server export unavailable."}`)}catch(W){_(`Export failed: ${W instanceof Error?W.message:String(W)}`)}finally{Y(!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.",He>0&&n.jsxs(n.Fragment,{children:[" ",n.jsxs("b",{"data-testid":"tickets-new-count",children:[He," new since your last visit"]})]})]})]}),n.jsx("button",{className:"btn btn-secondary",onClick:et,disabled:Q,children:Q?"Preparing…":"Download evidence"})]}),A&&n.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:A}),a&&n.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(W=>n.jsx("button",{onClick:()=>l(W),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:o===W?"2px solid var(--accent)":"2px solid transparent",color:o===W?"var(--text-primary)":"var(--text-tertiary)",fontWeight:o===W?600:500},children:W==="mine"?"Mine":"Team"},W))}),n.jsxs("div",{className:"tickets-toolbar",children:[n.jsx("div",{className:"ftabs",role:"tablist","aria-label":"Which tickets",children:Rw.map(W=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`tickets-filter-${W}`,"aria-selected":g===W,onClick:()=>p(W),children:[W==="automatic"?"Automatic":W==="approved"?"Approved":"All",n.jsx("span",{className:"n",children:Oe[W]})]},W))}),n.jsxs("div",{className:"search-filter-bar",children:[n.jsxs("div",{className:"search-input-wrap",children:[n.jsx("span",{className:"search-icon",children:"⌕"}),n.jsx("input",{type:"text",className:"form-input search-input","data-testid":"tickets-search",placeholder:"Search tickets","aria-label":"Search tickets",value:G,onChange:W=>O(W.target.value)}),G&&n.jsx("button",{className:"search-clear",onClick:()=>O(""),children:"×"})]}),n.jsxs("button",{className:`btn btn-sm btn-secondary${Ne?" active":""}`,onClick:()=>X(!Ne),children:["Filters",Ve?` (${ne.size+(ee!=="all"?1:0)})`:""]})]})]}),g==="automatic"&&n.jsx("p",{className:"page-subtitle",style:{marginTop:"-0.25rem"},children:'Automatic — no person approved these. Approved tickets are under "Approved".'}),n.jsx(Xc,{areas:J,selected:v,onSelect:y,totalCount:K.length}),Ne&&n.jsxs("div",{className:"filter-panel",children:[Fe.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Action"}),n.jsx("div",{className:"filter-chips",children:Fe.map(W=>n.jsx("button",{className:`filter-chip${ne.has(W)?" selected":""}`,onClick:()=>rt(W),children:W},W))})]}),o==="team"&&me.length>1&&n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Owner"}),n.jsx("div",{className:"filter-chips",children:me.map(W=>n.jsx("button",{className:`filter-chip${U.has(W.id)?" selected":""}`,onClick:()=>Ht(W.id),children:W.label},W.id))})]}),n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Time range"}),n.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([W,xe])=>n.jsx("button",{className:`filter-chip${ee===W?" selected":""}`,onClick:()=>pe(W),children:xe},W))})]})]}),Ve&&n.jsxs("div",{className:"active-filters",children:[[...ne].map(W=>n.jsxs("span",{className:"active-chip",onClick:()=>rt(W),children:[W," ",n.jsx("span",{className:"chip-remove",children:"×"})]},W)),[...U].map(W=>{const xe=q[W],Ae=xe?xe.name:W;return n.jsxs("span",{className:"active-chip",onClick:()=>Ht(W),children:[Ae," ",n.jsx("span",{className:"chip-remove",children:"×"})]},W)}),ee!=="all"&&n.jsxs("span",{className:"active-chip",onClick:()=>pe("all"),children:[ee==="1d"?"Today":ee==="7d"?"7 days":"30 days"," ",n.jsx("span",{className:"chip-remove",children:"×"})]}),n.jsx("button",{className:"clear-filters",onClick:Ot,children:"Clear all"})]}),we&&n.jsx("div",{className:"card note-stopped",style:{marginBottom:"0.75rem"},children:n.jsx("span",{className:"msg-error",style:{fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),B&&S.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ye.length===0?n.jsx(fs,{icon:"⌕",title:S.length===0?"No tickets in the last 30 days":"No matching tickets",text:S.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:ye.length===S.length?`${S.length} ticket${S.length!==1?"s":""}`:`${ye.length} of ${S.length} tickets`}),n.jsx("div",{className:"timeline",children:ye.map(W=>{const xe=W.userId?q[W.userId]:void 0;return n.jsx("div",{className:"timeline-event",children:n.jsx(Sb,{receipt:W,manifests:T,localAuth:W.authorizationId?se[W.authorizationId]:void 0,localUnavailable:H,signature:ue[W.id],grantTitle:W.authorizationId?ve[W.authorizationId]:null,ownerLabel:o==="team"&&W.userId?xe?`${xe.name} (${xe.email})`:W.userId:null,spUrl:P,formatDate:kb,onOpenComplete:()=>be(W),isNew:x!==null&&Di(W,x),defaultOpen:ye.length===1})},W.id)})})]}),qe&&n.jsx(bb,{receipt:qe,onClose:()=>be(null)}),oe&&n.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:dt,disabled:ze,children:ze?"Loading…":"Load older"})})]})}function Tb(){const[e,s]=h.useState(null),[a,o]=h.useState({}),[l,u]=h.useState(!1),f=Lr(),[g,p]=gs(),v=Vm(g.get("area")),y=h.useCallback(M=>{const q=new URLSearchParams(g);M===null?q.delete("area"):q.set("area",M),p(q,{replace:!0})},[g,p]),[w,x]=h.useState({}),b=h.useCallback(()=>{L.getMyAttestations().then(M=>{const q={};for(const z of M)z.title&&(q[z.authorization_id]=z.title);x(q)}).catch(()=>{})},[]);h.useEffect(()=>{b()},[b]),Ft(b,3e5);const[k,S]=h.useState(null),N=h.useRef(!1),T=h.useCallback(()=>{L.getDenials({limit:200}).then(({records:M})=>{s(M),u(!1)}).catch(()=>u(!0))},[]);h.useEffect(()=>{T()},[T]),Ft(T,6e4),h.useEffect(()=>{if(!e)return;const M=[...new Set(e.map(q=>q.profile).filter(q=>!!q))].filter(q=>!(q in a));M.length!==0&&Promise.all(M.map(q=>L.getProfile(q).catch(()=>null))).then(q=>{o(z=>{const U={...z};return M.forEach((Z,G)=>{q[G]&&(U[Z]=q[G])}),U})})},[e,a]),h.useEffect(()=>{!e||N.current||(N.current=!0,L.getLastSeenBlockedAt().then(M=>(S(M),L.markBlockedSeen(Date.now()))).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[e]);const E=h.useCallback(()=>{T(),b(),k!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||L.markBlockedSeen(Date.now()).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[T,b,k]);Me("denial-recorded",E);const P=h.useMemo(()=>{const M=new Map;for(const q of e??[]){const z=q.profile??q.integrationId,U=In(z),Z=M.get(U);Z?Z.count+=1:M.set(U,{shortId:U,icon:Pr(z),name:Bn(z,f),count:1})}return[...M.values()].sort((q,z)=>q.name.localeCompare(z.name))},[e,f]);if(l)return n.jsx(fs,{icon:"⛔",title:"Could not load blocked actions",text:"Try again shortly."});if(e===null)return null;const I=j0(e,Date.now()),B=e.filter(M=>Gm(M.profile??M.integrationId,v));return n.jsxs("div",{className:"blocked-page",children:[n.jsxs("div",{className:"page-header blocked-header",children:[n.jsx("h1",{className:"page-title",children:"Blocked actions"}),n.jsxs("span",{className:"blocked-today",children:[I," today · nothing ran"]})]}),e.length===0?n.jsx(fs,{icon:"✓",title:"Nothing blocked",text:"Every call your agent made stayed within its mandate."}):n.jsxs(n.Fragment,{children:[n.jsx(Xc,{areas:P,selected:v,onSelect:y,totalCount:e.length}),n.jsx("div",{className:"blocked-list",children:B.map((M,q)=>{const z=w0(M,M.profile?a[M.profile]:void 0,w),U=k!==null&&M.ts>k,Z=M.profile??M.integrationId;return n.jsx("div",{className:"card blocked-item blocked-card","data-seen":U?"false":"true",children:n.jsxs("div",{className:"id-body",children:[n.jsx(us,{profileId:Z,area:Bn(Z,f),system:M.integrationId?Wn(M.integrationId,void 0):void 0,time:k0(M.ts,Date.now()),trailing:U?n.jsx("span",{className:"new-pill",children:"New"}):void 0}),n.jsxs("div",{className:"blocked-row-head",children:[n.jsx("span",{className:`blocked-dot blocked-dot-${to(M)}`,"aria-hidden":"true"}),n.jsx("span",{className:"blocked-title",children:z.title})]}),n.jsx(ua,{title:Rm(M,w),area:Bn(Z,f)}),n.jsx("div",{className:"blocked-sentence",children:z.sentence}),n.jsx("div",{className:"blocked-source",children:z.sourceLine.map((G,O)=>G.dim?n.jsx("span",{className:"mandate-id",children:G.text},O):n.jsx("span",{children:G.text},O))}),n.jsxs("details",{children:[n.jsx("summary",{children:"What you can do"}),n.jsx("div",{className:"blocked-advice",children:z.whatYouCanDo})]})]})},`${M.ts}-${q}`)})})]})]})}const Ab={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function Ib(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{s(await L.getAutostart())}catch(v){u(v instanceof Error?v.message:"Could not read autostart state")}},[]);h.useEffect(()=>{f()},[f]);const g=h.useCallback(async()=>{if(!(!(e!=null&&e.supported)||a)){o(!0),u(null);try{await L.setAutostart(!e.installed)}catch(v){u(v instanceof Error?v.message:"Failed")}finally{try{s(await L.getAutostart()),u(null)}catch(v){u(v instanceof Error?v.message:"Could not re-read state")}o(!1)}}},[e,a,f]);if(!e)return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read autostart state: ${l}`:"Checking…"})]});const p=Ab[e.platform]??"a login service";return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),n.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:e.supported?n.jsxs(n.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",p," — no admin rights needed."]}):e.reason})]}),e.supported&&n.jsx("button",{type:"button",onClick:()=>void g(),disabled:a,"aria-pressed":e.installed,className:e.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Working…":e.installed?"Turn off":"Turn on"})]}),e.supported&&n.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",n.jsx("strong",{children:e.installed?"On — starts from your next login":"Off"})]}),e.supported&&n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Turning this on doesn't interrupt the gateway you're using — it takes effect at your next login. After any restart Suveren comes back ",n.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}function Rb(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{const p=await L.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(!(e===null||a)){o(!0),u(null);try{const p=await L.setGatewaySettings({desktopNotifications:!e});s(p.desktopNotifications)}catch(p){u(p instanceof Error?p.message:"Failed to save"),await f()}finally{o(!1)}}},[e,a,f]);return e===null?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read the setting: ${l}`:"Checking…"})]}):n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),n.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:"Tells you something is waiting for review — never what it is, and never with an approve button. Open Suveren to see and decide. At most one notification a minute; the browser tab always shows the count."})]}),n.jsx("button",{type:"button",onClick:()=>void g(),disabled:a,"aria-pressed":e,className:e?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":e?"Turn off":"Turn on"})]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}const Wh={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function Pb(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{s(await L.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(!(!e||a)){o(!0),u(null);try{s(await L.setIdentityDisclosure(!e.always))}catch(y){u(y instanceof Error?y.message:"Failed to save"),await f()}finally{o(!1)}}},[e,a,f]),p=n.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!e)return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[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=e.verified&&e.name?`${e.name} — ${e.method==="as_vouched"?`${Wh.as_vouched} ${e.verifier}`:Wh[e.method??""]??e.method}`:null;return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[p,n.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[e.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:v?`Your identity: ${v}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),n.jsx("button",{type:"button",onClick:()=>void g(),disabled:a,"aria-pressed":e.always,className:e.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":e.always?"Turn off":"Always show my name"})]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}const $b={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 _b(){const{version:e,latestVersion:s,updateAvailable:a,installMethod:o}=Fc();return e?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",n.jsx("strong",{children:e}),a&&s?n.jsxs(n.Fragment,{children:[" — ",n.jsx("strong",{children:s})," is available"]}):null]}),n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[$b[o]??"Update checking is unavailable",o==="dev"&&n.jsx(n.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function kc({title:e}){return n.jsxs("span",{className:"it-locked-badge",title:e,children:[n.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function Hh(e){return e===!0}function Lb(){const[e,s]=h.useState(null),[a,o]=h.useState(null);h.useEffect(()=>{let f=!1;return L.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=Hh(e==null?void 0:e.asUrlLockedByPolicy),u=Hh(e==null?void 0:e.pinTlsLockedByPolicy);return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),l&&n.jsx(kc,{})]}),!e&&!a&&n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),a&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.5rem 0 0",fontSize:"0.9rem"},children:a}),e&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"URL:"})," ",n.jsx("code",{children:e.asUrl})]}),e.paired&&e.fingerprint?n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"Key fingerprint:"})," ",n.jsx("code",{children:e.fingerprint}),n.jsx("br",{}),n.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Compare this with the fingerprint on the Authority Server's own admin page over a second channel (phone, video call) to confirm this gateway is talking to the right server."})]}):n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:"Not yet paired — sign in once to pin this server's key."}),(e.tlsPinFingerprint||e.pinTlsEnabled)&&n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"TLS certificate pin:"})," ",u&&n.jsx(kc,{title:"TLS pinning is set by your IT policy"})," ",e.tlsPinFingerprint?n.jsx("code",{children:e.tlsPinFingerprint}):n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",e.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),n.jsx("br",{}),n.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[e.pinTlsEnabled?n.jsxs(n.Fragment,{children:["TLS pinning is ON",u?n.jsx(n.Fragment,{children:", set by your organization's IT policy"}):n.jsxs(n.Fragment,{children:[" (",n.jsx("code",{children:"config set pin-tls on"}),")"]}),". Every connection to the Authority Server must present this certificate's public key, or the gateway refuses it and locks."]}):n.jsxs(n.Fragment,{children:["Captured at sign-in; not currently enforced",u?n.jsx(n.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):n.jsxs(n.Fragment,{children:[" (",n.jsx("code",{children:"config set pin-tls on"})," to require it on every connection)"]}),"."]})," ","A certificate renewal with the SAME key keeps this pin; a NEW key needs re-pairing."]})]}),l?n.jsx("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This Authority Server URL is set by your organization's IT policy and cannot be changed from this computer. Contact your IT administrator if it needs to change."}):n.jsxs("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:["To point this gateway at a different Authority Server:"," ",n.jsx("code",{children:"suveren-gateway config set as-url <url>"}),", then restart. Changing it ends the current sign-in and clears cached mandates — you sign in again against the new server."]})]})]})}function zb(){const{simulation:e,locked:s}=Wm();return s?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),n.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:['Blocks every real connector without a manifest "simulation" marker.',e!==null&&n.jsxs(n.Fragment,{children:[" ","Currently ",n.jsx("strong",{children:e?"ON":"OFF"}),e?" — real systems are not reachable from this gateway.":"."]})]})]}),n.jsx(kc,{})]}),n.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Simulation mode is set by your organization's IT policy",e!==null?` (currently ${e?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const Fb={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"]}},ra=["AI Assistant","Authority Server","This computer","Security","Version"],sa={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function Mb(){const[e,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,w]=h.useState(""),[x,b]=h.useState(!1),[k,S]=h.useState(!1),[N,T]=h.useState(!1),[E,P]=h.useState(null),[I,B]=h.useState([]),[M,q]=h.useState(!1),[z,U]=h.useState(null),[Z,G]=h.useState(""),O=h.useCallback(Q=>{s(Q),setTimeout(()=>s(""),3e3)},[]),ne=h.useCallback(async(Q,Y,A)=>{q(!0),U(null);try{const _=await L.aiModels({provider:Q,endpoint:Y,...A?{apiKey:A}:{}});_.ok&&_.models.length>0?(B(_.models),U(`${_.models.length} models available`)):(B([]),U(_.message||"No models returned — using defaults"))}catch(_){B([]),U(_ instanceof Error?_.message:"Failed to load models")}finally{q(!1)}},[]),fe=h.useCallback(async()=>{try{const Q=await L.getCredential("ai-config");if(b(Q.configured),Q.configured&&Q.fields){const Y=Q.fields.provider||"openai-compatible",A=Q.fields.endpoint||"";Q.fields.provider&&u(Y),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&&ne(Y,A)}}catch{}},[ne]);h.useEffect(()=>{fe()},[fe]);const ee=Q=>{o(Q),B([]),U(null),G("");const Y=Fb[Q];Y&&(u(Y.provider),g(Y.endpoint),v(""),ne(Y.provider,Y.endpoint,y||void 0))},pe=()=>ne(l,f,y||void 0),Ne=async()=>{S(!0);try{await L.setCredential("ai-config",{provider:l,endpoint:f,model:p,...y?{apiKey:y}:{}}),b(!0),O("AI configuration saved!")}catch{O("Failed to save AI config")}finally{S(!1)}},X=async()=>{T(!0),P(null);try{const Q=await L.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{T(!1)}};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Settings"}),n.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),e&&n.jsx("div",{className:"alert alert-success",children:e}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:sa,children:ra[0]}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",children:"Configuration"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Connect a trusted AI model that has access to your intent — problem, objective, and tradeoffs — to help you think through mandates. Keys are encrypted in your vault."}),x&&n.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[n.jsx("span",{className:"status-banner-icon",children:"✓"}),n.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{className:"form-label",children:"Provider Preset"}),n.jsxs("select",{className:"form-input",value:a,onChange:Q=>ee(Q.target.value),children:[n.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),n.jsx("option",{value:"ollama",children:"Ollama (local)"}),n.jsx("option",{value:"openai",children:"OpenAI"}),n.jsx("option",{value:"groq",children:"Groq"}),n.jsx("option",{value:"together",children:"Together"})]})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsxs("label",{className:"form-label",children:["API Key ",l==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),n.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:y,onChange:Q=>w(Q.target.value),onBlur:()=>{y.trim()&&ne(l,f,y.trim())},placeholder:x?"••••••••••••••••":"sk-... (not needed for Ollama)"}),n.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:"Each provider uses its own key — paste it and the model list loads automatically."})]}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("label",{className:"form-label",children:"Model"}),n.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:pe,disabled:M,title:"Re-fetch the model list from the provider",children:M?"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:M?"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,Y=Q.includes(p),A=Q.length>12,_=Z.trim().toLowerCase();let se=_?Q.filter(te=>te.toLowerCase().includes(_)):Q;return Y&&!se.includes(p)&&(se=[p,...se]),n.jsxs(n.Fragment,{children:[A&&n.jsx("input",{className:"form-input",value:Z,onChange:te=>G(te.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),n.jsxs("select",{className:"form-input",value:Y?p:"__unset__",onChange:te=>v(te.target.value==="__unset__"?"":te.target.value),children:[n.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),se.map(te=>n.jsx("option",{value:te,children:te},te)),_&&se.length===0&&n.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",Z,"”"]})]})]})})(),z&&n.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:z})]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[n.jsx("button",{className:"btn btn-primary",onClick:Ne,disabled:k||!p.trim(),title:p.trim()?void 0:"Select a model first",children:k?"Saving...":"Save & Encrypt"}),x&&n.jsx("button",{className:"btn btn-ghost",onClick:X,disabled:N,children:N?"Testing...":"Test Connection"})]}),E&&n.jsx("div",{className:`alert ${E.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:E})]}),n.jsx(Ob,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:sa,children:ra[1]}),n.jsx(Lb,{}),n.jsx(Pb,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:sa,children:ra[2]}),n.jsx(Ib,{}),n.jsx(Rb,{}),n.jsx(zb,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:sa,children:ra[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:sa,children:ra[4]}),n.jsx(_b,{})]})]})}function Ob(){const[e,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,w]=h.useState(!1),x=h.useCallback(async()=>{if(!y)try{const S=await L.getAIPrompts();s(S),o({intent:S.intent.current,context:S.context.current}),w(!0)}catch(S){g(S instanceof Error?S.message:"Failed to load prompts")}},[y]),b=async S=>{if(e){u(S),g(null);try{const N=a[S],T=N.trim()===e[S].default.trim()?"":N;await L.setAIPrompt(S,T);const E=await L.getAIPrompts();s(E),o({intent:E.intent.current,context:E.context.current}),v(S),setTimeout(()=>v(null),2e3)}catch(N){g(N instanceof Error?N.message:"Save failed")}finally{u(null)}}},k=async S=>{if(confirm(`Revert ${S} prompt to the built-in default?`)){u(S),g(null);try{await L.setAIPrompt(S,"");const N=await L.getAIPrompts();s(N),o({intent:N.intent.current,context:N.context.current})}catch(N){g(N instanceof Error?N.message:"Revert failed")}finally{u(null)}}};return n.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:S=>{S.currentTarget.open&&x()},children:[n.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",margin:"0.75rem 0 1rem 0",lineHeight:1.55},children:"These are the system prompts the AI assistant sees when helping you write Intent (per-mandate) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),f&&n.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:f}),!y&&!f&&n.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&n.jsxs(n.Fragment,{children:[n.jsx(Vh,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:e.intent,draft:a.intent,onChange:S=>o(N=>({...N,intent:S})),onSave:()=>b("intent"),onRevert:()=>k("intent"),saving:l==="intent",justSaved:p==="intent"}),n.jsx(Vh,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:e.context,draft:a.context,onChange:S=>o(N=>({...N,context:S})),onSave:()=>b("context"),onRevert:()=>k("context"),saving:l==="context",justSaved:p==="context"})]})]})}function Vh({kind:e,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:w=>u(w.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${s} system prompt`}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:f,disabled: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:e})]})}function Bb(e){return e.proposalId?"review":"automatic"}function Gh(e,s,a={}){const o=a.status??"pending",l=a.includeAutonomous??!1,u=[];for(const f of e)o==="pending"&&f.status!=="pending"||a.profile&&f.profileId!==a.profile||u.push({kind:"proposal",id:f.id,sortTimestamp:f.createdAt,commitmentMode:"review",profileId:f.profileId,proposal:f});if(o==="all")for(const f of s){const g=Bb(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 Db=["https://","http://"];function Vp(e,s){return e!=null&&e.length?e.flatMap(a=>{const o=a.template.replace(/\{(\w+)\}/g,(l,u)=>{const f=s[u];return typeof f=="string"||typeof f=="number"?String(f):"\0"});return o.includes("\0")||/\{|\}/.test(o)?[]:Db.some(l=>o.toLowerCase().startsWith(l))?[{label:a.label,href:o,description:a.description}]:[]}):[]}function Gp(e,s){const a=e-Math.floor(s/1e3);if(a<=0)return{label:"expired",urgent:!1,expired:!0};const o=Math.floor(a/86400),l=Math.floor(a%86400/3600),u=Math.floor(a%3600/60);let f;return o>0?f=`expires in ${o}d ${l}h`:l>0?f=`expires in ${l}h ${u}m`:f=`expires in ${Math.max(1,u)}m`,{label:f,urgent:a<2*3600,expired:!1}}function eu({profileId:e,declared:s}){const{icon:a}=_r(e,s),o=ww(e);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"id-rail",children:[n.jsx(bp,{icon:a,className:"id-rail-icon"}),n.jsx("span",{className:"id-rail-name",children:o})]}),n.jsx("div",{className:"id-sep"})]})}function Ub({proposalId:e,systemName:s}){const[a,o]=h.useState(null);if(h.useEffect(()=>{let u=!0;return o(null),L.getProposalOutcome(e).then(f=>{u&&o(f)}).catch(()=>{}),()=>{u=!1}},[e]),!a)return null;const l=sb(a,s);return l?n.jsxs("div",{className:"outcome-box",children:[n.jsx("h4",{children:l.heading}),n.jsx("p",{className:"outcome-note",children:l.note})]}):null}function Wb({text:e}){return n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"ai-text",children:[n.jsxs("h4",{children:["Text — written by the AI",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})]})}let ic=null;function Hb(){return ic||(ic=L.getEnrichedAuthorizations().then(e=>new Map(e.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),ic}function Vb(e){const[s,a]=h.useState(void 0);return h.useEffect(()=>{let o=!0;if(e)return Hb().then(l=>{o&&a(l.get(e))}),()=>{o=!1}},[e]),s}function Gb(e,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 x=await L.getGateContent(e);if((v=x==null?void 0:x.gateContent)!=null&&v.intent){p&&o(x.gateContent.intent);return}}catch{}const y=await L.getAttestationIntent(e);if(!y){p&&g("Intent not available or you are not an authorized approver.");return}const w=await L.decryptIntent({intentCiphertext:y.intentCiphertext,encryptedKey:y.encryptedKey,approverId:s});p&&o(w)}catch(y){p&&g(y instanceof Error?y.message:"Failed to decrypt intent")}finally{p&&u(!1)}})(),()=>{p=!1}},[e,s]),{intent:a,loading:l,error:f}}function Kh(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const s={};for(const[a,o]of Object.entries(e))(typeof o=="string"||typeof o=="number")&&(s[a]=o);return s}function Kb(e){const s=Kh(e.limits),a=Kh(e.scope),o=typeof e.intent=="string"?e.intent:"",l={bounds:s,context:a,gateContent:{intent:o}};return(e.mode==="automatic"||e.mode==="review")&&(l.templateMode=e.mode),typeof e.duration_hours=="number"&&e.duration_hours>0&&(l.templateTtl=Math.round(e.duration_hours*3600)),l}function Kp(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(s=>Kp(s)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}const qb="setup__create_mandate";function qp({proposal:e,currentUserId:s,proposalLinks:a,toolDisplay:o,manifests:l,onContentState:u,onShownSnapshot:f,nameOf:g}){var be,oe,Le,ze,Ue;const[p,v]=h.useState(!1),[y,w]=h.useState(!1),[x,b]=h.useState(null),k=Sn(),{group:S,groupId:N,domain:T}=wt(),E=Object.entries(e.executionContext),P=ma(e.profileId),I=Vb(e.authorizationId),B=jw(e.tool),{integrationId:M}=Un(e.tool),q=Wn(M,l),{intent:z,loading:U,error:Z}=Gb(e.authorizationId,s),G=ao(e),O=G.toolArgs!==null,[ne,fe]=h.useState([]),ee=[...Aw(e.executionContext,I,P),...LS(G.toolArgs),...ne],pe=h.useMemo(()=>Zc(G.toolArgs),[G.toolArgs]),Ne=h.useCallback(we=>L.getProposalAttachmentPreview(e.id,we),[e.id]);h.useEffect(()=>{u==null||u({loading:G.loading,readable:O})},[G.loading,O]);const X=Bw(e),Q=G.toolArgs?Vp(a,G.toolArgs):[],Y=async()=>{if(!N){b("No active workspace; cannot open the mandate screen.");return}w(!0),b(null);try{if(!G.toolArgs){b("This content is not readable on this device yet.");return}const we=G.toolArgs,nt=typeof we.profile=="string"?we.profile:"",Ze=await L.listProfiles(),Ye=kp(nt,Ze);if(!Ye){b(`Unknown profile "${nt}".`);return}const We=await L.getProfile(Ye.id),dt=Kb(we),ft=Cp(dt.bounds,We),Fe=Ep(dt.context,We);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Ye.id,groupId:N,groupName:(S==null?void 0:S.name)??null,domain:T,isPersonal:!!(S!=null&&S.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({...dt,bounds:ft,context:Fe})),sessionStorage.setItem("agentReplacesProposal",e.id),k("/mandates/new/intent")}catch(we){b(we instanceof Error?we.message:"Could not open the mandate screen.")}finally{w(!1)}},[A,_]=h.useState(null),se=ab(A),[te,H]=h.useState(null),[ie,ue]=h.useState(null);h.useEffect(()=>{if(!te||!ie){f==null||f(null);return}const we=te.status==="ok"?te.readAt:Date.now();f==null||f({readAt:we,preview:te,requestContext:ie,...G.toolArgs?{toolArgs:G.toolArgs}:{},sealed:G.sealed})},[te,ie,G.toolArgs,G.sealed,f]);const{toolName:ge}=Un(e.tool),ve=(Ue=(ze=(Le=(oe=(be=l==null?void 0:l.find(we=>we.id===M))==null?void 0:be.toolGating)==null?void 0:oe.overrides)==null?void 0:Le[ge])==null?void 0:ze.sourceFromArg)==null?void 0:Ue.arg,le=G.toolArgs?n.jsx(wc,{args:G.toolArgs,display:o,heading:"",requestRefArg:ve}):null,qe=G.toolArgs?n.jsxs(n.Fragment,{children:[n.jsx(wc,{args:G.toolArgs,display:o,heading:"",requestRefArg:ve}),E.length>0&&n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:E.map(([we,nt],Ze)=>{const{label:Ye,hint:We}=bw(we,P);return n.jsxs("span",{children:[Ze>0&&" · ",n.jsxs("span",{title:We,children:[Ye,"=",Kp(nt)]})]},we)})})]}):null;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"approval-summary","data-testid":"approval-summary",children:op(e.tool,G.toolArgs,l)}),n.jsx("div",{className:"approval-headline",children:B}),G.sealed&&G.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."})]}),G.sealed&&G.loading&&n.jsx("div",{className:"preview-box","data-testid":"proposal-decrypting",style:{marginBottom:"0.5rem"},children:"Decrypting…"}),se&&O&&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",G.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"})]}),le]}),O&&G.toolArgs&&ih(G.toolArgs,o)!==void 0&&n.jsx(Wb,{text:ih(G.toolArgs,o)}),O&&n.jsx(_p,{attachments:pe.attachments,inserts:pe.inserts,manifests:l,fetchPreview:Ne,onChecks:fe}),X.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: ",X.map(we=>(g==null?void 0:g(we))??we).join(", ")," — shared automatically once they sign in on a device."]}),O&&n.jsx(cb,{proposalId:e.id,systemName:q,toolArgs:G.toolArgs,sealed:G.sealed,onTone:_,onData:H}),O&&n.jsx(yb,{proposalId:e.id,onData:ue}),O&&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"]}),G.sealed&&n.jsx("span",{children:"Decrypted on this device — suveren.ai stores only an unreadable copy and its fingerprint."})]})]}),ee.length>0&&n.jsxs("div",{className:"limit-checks",children:[n.jsx("h4",{children:"Within your limits"}),n.jsx("ul",{className:"limit-check-list",children:ee.map(we=>n.jsxs("li",{className:we.ok?"ok":"bad",children:[n.jsx("span",{className:"limit-check-icon",children:we.ok?"✓":"✗"}),n.jsxs("span",{children:[we.label,we.valueText||we.limitText?` ${we.valueText} — your limit ${we.limitText}`:""]})]},we.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)??Mt(e.profileId)})})]}),n.jsxs("dl",{children:[n.jsx("dt",{children:"Intent"}),n.jsx("dd",{children:Z?n.jsx("p",{className:"msg-error",style:{fontSize:"0.8rem",margin:0},children:Z}):z!==null?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:`intent-text${p?"":" intent-clamped"}`,children:z}),n.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>v(!p),children:p?"Show less":"Show full intent"})]}):U?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"Loading intent…"}):n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]})]}),O&&Q.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:Q.map(we=>n.jsxs("a",{href:we.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:we.description??we.href,children:[we.label," ↗"]},we.label))}),!se&&O&&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:qe})]}),O&&e.tool===qb&&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:Y,disabled:y,children:y?"Opening…":"Edit before signing"}),x&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.8rem",margin:"0.4rem 0 0"},children:x})]})]})}function Yp({note:e,onNoteChange:s,onSend:a,onCancel:o,sending:l,error:u}){return n.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:"var(--radius-md)",background:"var(--bg-main)",padding:"0.75rem 0.875rem",marginTop:"0.5rem"},children:[n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:[n.jsx("strong",{style:{color:"var(--text-primary)"},children:"What should change?"})," (the AI will read this)"]}),n.jsx("div",{style:{display:"flex",gap:"0.375rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:Lj.map(f=>n.jsx("button",{type:"button",className:`filter-chip${xp(e,f)?" selected":""}`,onClick:()=>s(Fj(e,f)),disabled:l,children:f},f))}),n.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:e,maxLength:Gi,onChange:f=>s(f.target.value),rows:3,placeholder:"What should the AI do differently?",disabled:l,style:{width:"100%",resize:"vertical",fontFamily:"inherit"}}),n.jsxs("div",{style:{textAlign:"right",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[e.length," / ",Gi]}),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 Yb={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},Jb={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired",refused:"status-revoked"},qh={REJECTED:"status-revoked","CHANGE NEEDED":"status-change-needed",REPLACED:"status-replaced",REFUSED:"status-revoked"};function oc(e){const s=Date.now()-e*1e3,a=s/36e5;return a<48?a<1?`${Math.max(1,Math.round(s/6e4))}m ago`:`${Math.round(a)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Qb(e){return e.split("__").pop()??e}function Xb(e){const s=e.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function Jp(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(s=>Jp(s)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Yh({item:e,onApprove:s,onReject:a,onChangeNeeded:o,resolving:l,proposalLinks:u,toolDisplay:f,manifests:g,currentUserId:p,inRow:v=!1}){const y=e.kind==="proposal",w=y?e.proposal.status:"executed",x=y?e.proposal.tool:e.receipt.action,b=Qb(x),k=Xb(x),{integrationId:S}=Un(x),N=Wn(S,g),[T,E]=h.useState(!1),[P,I]=h.useState(""),[B,M]=h.useState(""),q=h.useRef(null),z=async()=>{const te=q.current;if(!(!te||!y))try{const{shownHash:H}=await L.saveShownSnapshot(e.proposal.id,te);return H}catch{return}},U=async()=>{const te=Qc(P);if(!te.valid){M(te.error);return}M("");const H=await z();o==null||o(e.id,te.trimmed,H)},Z=y&&w==="rejected"?Dj(e.proposal,p??""):null,G=y&&w==="refused"?Uj(e.proposal):null,O=Dw(y?e.proposal.rejectedBy??e.proposal.approverRejectedBy??null:null),ne=ao(y?e.proposal:{toolArgs:void 0,content:void 0}),fe=y?ne.toolArgs:null,ee=y?e.proposal.executionContext:e.receipt.executionContext,pe=y?null:e.receipt.cumulativeState,[Ne,X]=h.useState(!0),[Q,Y]=h.useState(!1),A=y&&ne.toolArgs?Vp(u,ne.toolArgs):[],_=Object.entries(ee??{}),se=_r(e.profileId).testSetup||no(x);return n.jsxs("div",{className:v?"card card-in-row":"card id-card",children:[!v&&n.jsx(eu,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[v?se?n.jsx("div",{style:{marginBottom:"0.5rem"},children:n.jsx("span",{className:"sim-mark",children:"Test setup"})}):null:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:b}),se&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),e.commitmentMode==="automatic"&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[y&&w==="pending"&&(()=>{const te=Gp(e.proposal.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:te.urgent?600:400,whiteSpace:"nowrap"},children:te.label})})(),n.jsx("span",{"data-testid":Z||G?"outcome-kind":void 0,className:`status-badge ${Z?qh[Z.kind]:G?qh.REFUSED:Jb[w]}`,children:Z?Z.kind:G?G.kind:Yb[w]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:oc(e.sortTimestamp)})]})]}),y&&e.proposal.status==="executed"&&n.jsx(Ub,{proposalId:e.proposal.id,systemName:N}),Z&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By ",Z.who,", ",oc(Z.at)]}),(O??Z.note)&&n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:[Z.kind==="CHANGE NEEDED"?"Change: ":"Note: ",O??Z.note]})]}),G&&n.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:[n.jsxs("div",{children:["By the Authority Server, ",oc(G.at)]}),n.jsxs("div",{"data-testid":"outcome-note",style:{marginTop:"0.2rem"},children:["Reason: ",G.message]})]}),k&&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(fe==null?void 0:fe._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:fe._imagePreview,alt:typeof(fe==null?void 0:fe.altText)=="string"?fe.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),y&&w==="pending"?n.jsx(qp,{proposal:e.proposal,currentUserId:p??"",proposalLinks:u,toolDisplay:f,manifests:g,onContentState:({loading:te,readable:H})=>{Y(te),X(H)},onShownSnapshot:te=>{q.current=te}}):n.jsxs(n.Fragment,{children:[A.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:A.map(te=>n.jsxs("a",{href:te.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:te.description??te.href,children:[te.label," ↗"]},te.label))}),y?n.jsxs(n.Fragment,{children:[fe&&n.jsx(wc,{args:fe,display:f}),_.length>0&&n.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:_.map(([te,H])=>`${te}=${Jp(H)}`).join(" · ")})]}):n.jsxs(n.Fragment,{children:[n.jsx(zp,{receipt:e.receipt,manifests:g}),e.receipt.proposalId&&n.jsx(Hp,{proposalId:e.receipt.proposalId,tool:e.receipt.action,manifests:g})]})]}),pe&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",pe.daily.count," action",pe.daily.count===1?"":"s",pe.daily.amount>0?`, ${pe.daily.amount}`:""," · ","this month: ",pe.monthly.count,pe.monthly.amount>0?`, ${pe.monthly.amount}`:""]}),y&&w==="pending"&&np({loading:Q,readable:Ne})&&(T?n.jsx(Yp,{note:P,onNoteChange:I,onSend:U,onCancel:()=>{E(!1),I(""),M("")},sending:!!l,error:B}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"approval-resp",children:"Approving sends exactly this. Your approval is recorded with your name."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[n.jsx("button",{className:"btn btn-primary",onClick:async()=>s==null?void 0:s(e.id,await z()),disabled:l,children:l?"Approving…":"Approve"}),n.jsxs("button",{"data-testid":"btn-change-needed",className:"btn btn-outline-strong",onClick:()=>E(!0),disabled:l,children:[n.jsx("span",{"aria-hidden":"true",children:"↩"})," Change needed"]}),n.jsxs("button",{"data-testid":"btn-reject",className:"btn btn-outline-strong",onClick:async()=>a==null?void 0:a(e.id,await z()),disabled:l,children:[n.jsx("span",{"aria-hidden":"true",children:"✕"})," Reject"]})]})]})),!v&&n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[y?"Proposal":"Ticket",": ",e.id]})]})]})}function Zb(e,s=[]){const a=new Map;for(const o of e){const l=o.name&&o.email?`${o.name} (${o.email})`:o.name||o.email||o.id;a.set(o.id,l)}for(const o of s){const l=o.userId??o.id;l&&(o.name&&o.email?a.set(l,`${o.name} (${o.email})`):o.name&&a.set(l,o.name))}return a}function ek(e,s){return e.map(a=>s.get(a)??a)}function Qp(e){var b;const{groupId:s}=wt(),a=ma(e.profileId),[o,l]=h.useState(null),[u,f]=h.useState(new Map),[g,p]=h.useState(!0);h.useEffect(()=>{let k=!0;if(!s){p(!1);return}return p(!0),Promise.all([L.getTeamProfileConfig(s,e.profileId).catch(()=>null),L.getGroupById(s).catch(()=>null),L.listUsers().catch(()=>[])]).then(([S,N,T])=>{k&&(l(S),f(Zb(T,(N==null?void 0:N.members)??[])))}).finally(()=>{k&&p(!1)}),()=>{k=!1}},[s,e.profileId]);const v=Ox(o??{}),y=ek(e.pendingApprovers??[],u),w=k=>u.get(k)??k,x=o&&((b=a==null?void 0:a.boundsSchema)!=null&&b.fields)?sj(e.executionContext,o,a.boundsSchema.fields):null;return{loading:g,profileConfig:o,requiredApprovals:v,approverNames:y,nameOf:w,aboveCapReason:x}}function Xp(e,s){return!!e.createdBy&&!!s&&e.createdBy===s}function Zp(e){return(e.pendingApprovers??[]).filter(s=>s!==e.createdBy)}function tk(e){const s=Date.now()-e*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function nk({proposal:e,currentUserId:s,onAction:a,onMessage:o,proposalLinks:l,toolDisplay:u,manifests:f,inRow:g=!1}){const[p,v]=h.useState(!1),[y,w]=h.useState(!1),[x,b]=h.useState(!1),[k,S]=h.useState(""),[N,T]=h.useState(""),[E,P]=h.useState(!1),[I,B]=h.useState(!1),[M,q]=h.useState(!0),z=h.useRef(null),U=async()=>{const _=z.current;if(_)try{const{shownHash:se}=await L.saveShownSnapshot(e.id,_);return se}catch{return}},Z=_r(e.profileId).testSetup||no(e.tool),G=Zp(e),O=e.approvedBy??{},ne=Object.keys(O).length,fe=s in O,ee=Qp(e),pe=Xp(e,s),Ne=_=>{const se=_ instanceof Error?_.message:"Approval failed";return se.includes("APPROVER_IS_PROPOSER")?"You can't approve your own action. Ask another approver.":se.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.":se},X=async()=>{if(Hc()){o(Vc);return}v(!0),o("");try{const _=await oa(e),se=await U(),te=await L.approveProposal(e.id,_,se);try{const ge=await L.getAttestationIntent(e.authorizationId);if(ge){const ve=await L.decryptIntent({intentCiphertext:ge.intentCiphertext,encryptedKey:ge.encryptedKey,approverId:s});await L.storeApprovedIntent(e.authorizationId,ve)}}catch{}const{requiredApprovals:H,approvedCount:ie}=te,ue=H!==void 0&&ie!==void 0?H-ie:void 0;o(ue===void 0?"Approved.":ue>0?`Approved. ${ue} more approval${ue===1?"":"s"} still needed.`:"Approved — the required number of approvals is met; the action is ready to execute."),a()}catch(_){o(Ne(_))}finally{v(!1)}},Q=async()=>{w(!0),o("");try{const _=await oa(e),se=await U();await L.rejectProposal(e.id,wp(),_,se),o("Action rejected."),a()}catch(_){o(_ instanceof Error?_.message:"Rejection failed")}finally{w(!1)}},Y=async()=>{const _=Qc(k);if(!_.valid){T(_.error);return}T(""),P(!0),o("");try{const{noteEncrypted:se}=await L.encryptProposalNote(_.trimmed,rp(e,s)),te=await oa(e),H=await U();await L.rejectProposal(e.id,{outcome:"change_needed",noteEncrypted:se},te,H),o("Sent back for a change."),a()}catch(se){o(se instanceof Error?se.message:"Failed to send back")}finally{P(!1)}},A=p||y||E;return n.jsxs("div",{className:g?"card card-in-row":"card id-card",children:[!g&&n.jsx(eu,{profileId:e.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:[Z&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const _=Gp(e.expiresAt,Date.now());return n.jsx("span",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",fontWeight:_.urgent?600:400,whiteSpace:"nowrap"},children:_.label})})(),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:tk(e.createdAt)})]})]}),n.jsxs("div",{className:"approver-progress",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Needs ",ee.requiredApprovals," approval",ee.requiredApprovals===1?"":"s"," from:"," ",G.map((_,se)=>n.jsxs("span",{className:`who${_ in O?" done":""}`,style:{marginLeft:se===0?"0.25rem":"0.5rem",fontWeight:_ in O?600:void 0},children:[_ in O?"✓ ":"",ee.nameOf(_),_===s?" (you)":"",se<G.length-1?",":""]},_)),ee.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",ne," of ",ee.requiredApprovals,")"]})]}),ee.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:[ee.aboveCapReason.fieldLabel,ee.aboveCapReason.value!==void 0?` ${ee.aboveCapReason.value}`:""," (limit ",String(ee.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${ee.nameOf(e.createdBy)}.`:""]})]}),n.jsx(qp,{proposal:e,currentUserId:s,proposalLinks:l,toolDisplay:u,manifests:f,nameOf:ee.nameOf,onContentState:({loading:_,readable:se})=>{B(_),q(se)},onShownSnapshot:_=>{z.current=_}}),!fe&&np({loading:I,readable:M})&&(x?n.jsx(Yp,{note:k,onNoteChange:S,onSend:Y,onCancel:()=>{b(!1),S(""),T("")},sending:E,error:N}):n.jsxs(n.Fragment,{children:[!pe&&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:[pe?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:()=>b(!0),disabled:A,children:[n.jsx("span",{"aria-hidden":"true",children:"↩"})," Change needed"]}),n.jsxs("button",{"data-testid":"btn-reject",className:"btn btn-outline-strong",onClick:Q,disabled:A,children:[n.jsx("span",{"aria-hidden":"true",children:"✕"})," ",y?"Rejecting...":"Reject"]})]})]})),fe&&n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:["You approved this action.",ee.requiredApprovals>1&&ne<ee.requiredApprovals?` Waiting on ${ee.requiredApprovals-ne} more approval(s).`:""]}),!g&&n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})]})}function Jh({proposal:e,manifests:s,titles:a,open:o,onToggle:l,who:u,children:f}){const g=Date.now(),p=Xm(e.expiresAt,g),v=Lr(),y=h.useRef(null);return h.useEffect(()=>{var w;o&&((w=y.current)==null||w.scrollIntoView({block:"nearest"}))},[o]),n.jsxs("div",{ref:y,className:`appr-item${o?" is-open":""}`,"data-testid":"approval-row","data-proposal-id":e.id,children:[n.jsxs("button",{type:"button",className:"appr-item-head","aria-expanded":o,onClick:l,children:[n.jsxs("div",{className:"appr-item-main",children:[n.jsx(us,{profileId:e.profileId,area:$r(e.profileId,v),system:pa(e.tool,s),time:Qm(e.createdAt,g)}),n.jsx("div",{className:"appr-item-sum","data-testid":"approval-row-summary",children:n.jsx(lp,{proposal:e,manifests:s})}),n.jsx(ua,{title:e.authorizationId?a[e.authorizationId]:void 0,area:$r(e.profileId,v)}),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 rk(){const{domain:e,user:s}=wt(),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({}),[w,x]=h.useState(!0),[b,k]=h.useState(""),S=h.useCallback(async()=>{try{const K=await L.getProposalsForApprover();f(K)}catch{}finally{x(!1)}},[]);Me("proposal-added",S),Me("proposal-approved",S),Me("proposal-rejected",S),Me("proposal-resolved",S),Ft(S,3e4);const[N,T]=h.useState([]),E=h.useCallback(async()=>{try{const K=await L.getMyProposals(e);T(K)}catch{}},[e]);Me("proposal-added",E),Me("proposal-approved",E),Me("proposal-rejected",E),Me("proposal-resolved",E),Me("execution-failed",E),Ft(E,3e4,e);const P=h.useMemo(()=>N.filter(K=>{var J;return K.status==="pending"&&(((J=K.pendingApprovers)==null?void 0:J.length)??0)===0}),[N]),I=h.useMemo(()=>Gh(P,[],{status:"pending"}),[P]),[B,M]=h.useState([]),q=h.useCallback(async()=>{if(a)try{const J=(await L.getMyProposals(e)).filter(ye=>ye.status==="pending"&&ye.pendingApprovers&&ye.pendingApprovers.includes(a)&&ye.approvedBy&&a in ye.approvedBy);M(J)}catch{}},[a,e]);Me("proposal-approved",q),Me("proposal-rejected",q),Ft(q,3e4,`${a}:${e}`);const[z,U]=h.useState([]),Z=h.useCallback(async()=>{try{const K=await L.getProposalsCreatedByMe();if(K!==null){U(K);return}U(await L.getMyPendingProposals())}catch{}},[]);Me("proposal-added",Z),Me("proposal-approved",Z),Me("proposal-rejected",Z),Ft(Z,3e4),h.useEffect(()=>{L.getLabelManifests().then(p).catch(()=>{}),L.getToolDisplay().then(y).catch(()=>{})},[]);const G=K=>{var J;return(J=g.find(ye=>ye.id===K.split("__")[0]))==null?void 0:J.proposalLinks};h.useEffect(()=>{S(),E(),q(),Z()},[]);const[O,ne]=h.useState([]),[fe,ee]=h.useState([]),[pe,Ne]=h.useState(!0),[X,Q]=h.useState(null),[Y,A]=h.useState(""),[_,se]=h.useState("pending"),[te,H]=h.useState(null),[ie,ue]=h.useState(!1),ge=h.useCallback(async()=>{try{const{proposals:K,receipts:J}=await L.getThread({domain:e,status:_,sinceDays:7});ne(K),ee(J)}catch{}finally{Ne(!1)}},[e,_]);Ft(ge,3e4,`${e}:${_}`);const ve=async(K,J,ye,He)=>{if(J==="commit"&&Hc()){A(Vc);return}Q(K),A("");try{const Ve=O.find(W=>W.id===K)??N.find(W=>W.id===K),rt=Mx(Ve,e),Ht=Ve?await oa(Ve):void 0;let Ot=ye??{};if((ye==null?void 0:ye.outcome)==="change_needed"&&ye.note){const W=Ve?rp(Ve,a):[a],{noteEncrypted:xe}=await L.encryptProposalNote(ye.note,W);Ot={outcome:"change_needed",noteEncrypted:xe}}const et=await L.resolveProposal(K,J,rt,{...Ot,contentHash:Ht,shownHash:He});A(J==="commit"?`Action approved. Status: ${et.status}`:(ye==null?void 0:ye.outcome)==="change_needed"?"Sent back for a change.":"Action rejected."),await Promise.all([ge(),E()])}catch(Ve){A(Ve instanceof Error?Ve.message:"Failed")}finally{Q(null)}},le=(K,J)=>ve(K,"commit",void 0,J),qe=(K,J)=>ve(K,"reject",wp(),J),be=(K,J,ye)=>ve(K,"reject",Mj(J),ye),oe=h.useMemo(()=>{const K=new Set;for(const J of O)K.add(J.profileId);for(const J of fe)K.add(J.profileId);return Array.from(K).sort()},[O,fe]),Le=h.useMemo(()=>Gh(O,fe,{status:_,profile:te??void 0,includeAutonomous:ie}),[O,fe,_,te,ie]),ze=h.useCallback(()=>{S(),q()},[S,q]),Ue=h.useMemo(()=>{const K=new Set,J=[];for(const ye of[...B,...z])K.has(ye.id)||(K.add(ye.id),J.push(ye));return J.sort((ye,He)=>He.createdAt-ye.createdAt)},[B,z]),we=u.length+I.length,[nt]=gs(),[Ze,Ye]=h.useState(()=>nt.get("open")),We=h.useMemo(()=>[...I.map(K=>K.kind==="proposal"?K.proposal.id:K.id),...u.map(K=>K.id)],[I,u]),dt=h.useRef([]),ft=h.useRef(null);h.useEffect(()=>{const K=dt.current;if(dt.current=We,We.length===1&&Ze===null&&ft.current!==We[0]){ft.current=We[0],Ye(We[0]);return}if(Ze&&!We.includes(Ze)&&K.includes(Ze)){const J=K.indexOf(Ze),ye=K.slice(J+1).find(He=>We.includes(He))??We[0]??null;Ye(ye)}},[We,Ze]);const Fe=K=>Ye(J=>J===K?null:K),[me,Re]=h.useState({});h.useEffect(()=>{L.getMyAttestations().then(K=>{const J={};for(const ye of K)ye.authorization_id&&ye.title&&(J[ye.authorization_id]=ye.title);Re(J)}).catch(()=>{})},[]);const Oe=Ue.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 ",we>0&&n.jsx("span",{className:"pill-count",style:{marginLeft:"0.4rem"},children:we})]}),n.jsxs("button",{className:`nav-tab${o==="awaiting-others"?" active":""}`,onClick:()=>l("awaiting-others"),children:["Awaiting others ",Oe>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:Oe})]}),n.jsx("button",{className:`nav-tab${o==="all"?" active":""}`,onClick:()=>{l("all"),ge()},children:"All"})]}),o==="awaiting-me"&&n.jsx(n.Fragment,{children:w&&we===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):we===0?n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[n.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):n.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[(b||Y)&&n.jsx("div",{className:"alert alert-success",children:b||Y}),I.map(K=>{const J=n.jsx(Yh,{proposalLinks:K.kind==="proposal"?G(K.proposal.tool):void 0,toolDisplay:K.kind==="proposal"?v[K.proposal.tool]:void 0,manifests:g,currentUserId:a,item:K,onApprove:le,onReject:qe,onChangeNeeded:be,resolving:X===K.id,inRow:K.kind==="proposal"},K.id);if(K.kind!=="proposal")return J;const ye=K.proposal.id;return n.jsx(Jh,{proposal:K.proposal,manifests:g,titles:me,open:Ze===ye,onToggle:()=>Fe(ye),children:J},ye)}),u.map(K=>n.jsx(Jh,{proposal:K,manifests:g,titles:me,open:Ze===K.id,onToggle:()=>Fe(K.id),who:"Team approval — other people are involved",children:n.jsx(nk,{inRow:!0,proposal:K,currentUserId:a,onAction:ze,onMessage:k,proposalLinks:G(K.tool),toolDisplay:v[K.tool],manifests:g},K.id)},K.id))]})}),o==="awaiting-others"&&n.jsx(n.Fragment,{children:Ue.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:Ue.map(K=>n.jsx(ak,{proposal:K,currentUserId:a,onCancel:async()=>{try{await L.rejectProposal(K.id,{reason:"cancelled by creator"}),q(),E()}catch(J){alert(J instanceof Error?J.message:"Cancel failed")}},onWithdraw:async()=>{const J=await oa(K);await L.withdrawProposal(K.id,void 0,J),Z(),q()}},K.id))})}),o==="all"&&n.jsxs(n.Fragment,{children:[Y&&n.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:Y}),n.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[n.jsx("button",{className:`filter-chip ${_==="pending"?"selected":""}`,onClick:()=>se("pending"),children:"Pending"}),n.jsx("button",{className:`filter-chip ${_==="all"?"selected":""}`,onClick:()=>se("all"),children:"All"}),oe.length>0&&n.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),oe.map(K=>n.jsx("button",{className:`filter-chip ${te===K?"selected":""}`,onClick:()=>H(te===K?null:K),children:Mt(K)},K)),_==="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 ${ie?"selected":""}`,onClick:()=>ue(!ie),title:"Include actions executed without human review (automatic commitment mode)",children:[ie?"✓ ":"","Autonomous actions"]})]})]}),pe&&Le.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Le.length===0?n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[n.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:_==="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:Le.map(K=>n.jsx(Yh,{proposalLinks:K.kind==="proposal"?G(K.proposal.tool):void 0,toolDisplay:K.kind==="proposal"?v[K.proposal.tool]:void 0,manifests:g,currentUserId:a,item:K,onApprove:le,onReject:qe,onChangeNeeded:be,resolving:X===K.id},K.id))})]})]})}function sk(e){const s=Date.now()-e*1e3,a=Math.floor(s/6e4);if(a<60)return`${Math.max(1,a)}m ago`;const o=Math.floor(s/36e5);return o<48?`${o}h ago`:`${Math.floor(o/24)}d ago`}function ak({proposal:e,currentUserId:s,onCancel:a,onWithdraw:o}){const[l,u]=h.useState(!1),[f,g]=h.useState(!1),[p,v]=h.useState(""),y=Qp(e),w=Xp(e,s),x=Zp(e),b=e.approvedBy??{},k=Object.keys(b).length,S=x.length>0,N=async()=>{u(!0);try{await a()}finally{u(!1)}},T=async()=>{g(!0),v("");try{await o()}catch(P){v(P instanceof Error?P.message:"Withdraw failed")}finally{g(!1)}},E=_r(e.profileId).testSetup||no(e.tool);return n.jsxs("div",{className:"card id-card",children:[n.jsx(eu,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:e.tool.split("__").pop()??e.tool}),E&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:sk(e.createdAt)})]}),S&&n.jsxs("div",{className:"approver-progress",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Needs ",y.requiredApprovals," approval",y.requiredApprovals===1?"":"s"," from:"," ",x.map((P,I)=>n.jsxs("span",{className:`who${P in b?" done":""}`,style:{marginLeft:I===0?"0.25rem":"0.5rem",fontWeight:P in b?600:void 0},children:[P in b?"✓ ":"",y.nameOf(P),P===s?" (you)":"",I<x.length-1?",":""]},P)),y.requiredApprovals>1&&n.jsxs("span",{style:{marginLeft:"0.5rem"},children:["(",k," of ",y.requiredApprovals,")"]})]}),y.aboveCapReason&&n.jsxs("div",{className:"over-limit-box","data-testid":"above-cap-reason",style:{display:"flex",gap:"0.5rem",alignItems:"flex-start",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.6rem 0.8rem",marginBottom:"0.6rem",fontSize:"0.82rem"},children:[n.jsx("span",{style:{fontWeight:700,whiteSpace:"nowrap"},children:"Above the team limit:"}),n.jsxs("span",{children:[y.aboveCapReason.fieldLabel,y.aboveCapReason.value!==void 0?` ${y.aboveCapReason.value}`:""," (limit ",String(y.aboveCapReason.cap),")."," ",e.createdBy?`Requested by ${y.nameOf(e.createdBy)}.`:""]})]}),S&&w&&n.jsx("p",{"data-testid":"cant-approve-own-action",style:{fontSize:"0.82rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:n.jsx("strong",{children:"You can't approve your own action."})}),S&&w?n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"0.35rem",marginTop:"0.5rem"},children:[n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:T,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:N,disabled:l,children:l?"Cancelling...":"Cancel"})})]})]})}const ik=`# 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 ok(){const[e,s]=h.useState(""),[a,o]=h.useState(""),[l,u]=h.useState(!0),[f,g]=h.useState(!1),[p,v]=h.useState(null),[y,w]=h.useState(!1),x=e!==a,b=new Blob([e]).size,k=16*1024;h.useEffect(()=>{if(!x)return;const E=I=>{I.preventDefault(),I.returnValue=""},P=I=>{var q,z;if(I.defaultPrevented||I.button!==0||I.metaKey||I.ctrlKey||I.shiftKey||I.altKey)return;const B=(z=(q=I.target)==null?void 0:q.closest)==null?void 0:z.call(q,"a");if(!B||!B.href)return;let M;try{M=new URL(B.href)}catch{return}M.origin===window.location.origin&&M.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(I.preventDefault(),I.stopPropagation()))};return window.addEventListener("beforeunload",E),document.addEventListener("click",P,!0),()=>{window.removeEventListener("beforeunload",E),document.removeEventListener("click",P,!0)}},[x]),h.useEffect(()=>{let E=!1;return L.getAgentContext().then(P=>{E||(s(P),o(P))}).catch(P=>{E||v({kind:"error",text:P instanceof Error?P.message:"Failed to load context"})}).finally(()=>{E||u(!1)}),()=>{E=!0}},[]);const S=async()=>{g(!0),v(null);try{await L.saveAgentContext(e),o(e),v({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(E){v({kind:"error",text:E instanceof Error?E.message:"Save failed"})}finally{g(!1)}},N=()=>{s(a),v(null)},T=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||s(ik)};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Agent Brief"}),n.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!e.trim()&&!l&&n.jsx("button",{className:"btn btn-primary btn-sm",onClick:T,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(Hi,{target:{kind:"context"},currentText:e,onApply:E=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||s(E)},greeting:"Tell me what your agent should know — I'll help shape your standing orders. Or ask me to draft a full brief and we'll iterate.",placeholder:"Ask for help with your brief…"})}),n.jsxs("div",{className:"card intent-pane document",children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[n.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),n.jsxs("span",{className:b>k?"msg-error":void 0,style:{fontSize:"0.75rem",color:b>k?void 0:"var(--text-muted)"},children:[b.toLocaleString()," / ",k.toLocaleString()," bytes"]})]}),n.jsx("textarea",{className:"form-textarea",value:e,onChange:E=>s(E.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:N,disabled:f||!x,children:"Revert"}),n.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:S,disabled:f||!x||b>k||l,children:f?"Saving…":"Save"})]})]}),n.jsx("button",{type:"button",className:"floating-help",onClick:()=>w(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),n.jsx(fp,{open:y,onClose:()=>w(!1),ariaLabel:"Brief assistant",children:n.jsx(Hi,{target:{kind:"context"},currentText:e,onApply:E=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(s(E),w(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function lk(e){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function ck(e){const s=e.find(l=>{var u;return l.kind==="sv-mandate"&&l.status!=="unverifiable"&&typeof((u=l.data)==null?void 0:u.profile)=="string"});if(!s)return null;const a=s.data;if(typeof a.profileLabel=="string"&&a.profileLabel)return a.profileLabel;const o=a.profile.split("@")[0].split("/").pop();return o?o.charAt(0).toUpperCase()+o.slice(1):null}function uk(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function dk(e,s){const a=s.emailExportError?"cases unknown":`${s.coveredCases.length}/${s.loadedCases.length} cases`;return`${e.signaturesValid>0?`${e.signaturesValid} ✓ tickets`:`${e.signaturesValid} tickets`} · ${a} · ${s.ticketsReferenced.length}/${s.ticketsInPeriod.length} tickets covered`}function fk(e){return e.emailExportError?{kind:"error",text:"Cases: unknown — the email simulator could not be read.",detail:e.emailExportError}:{kind:"ok",text:`${e.coveredCases.length} of ${e.loadedCases.length}`}}function hk(e){return e.periodStart!==null?null:e.emailExportError?{text:"Test period start unknown — the email simulator could not be read. All saved tickets were counted.",detail:e.emailExportError}:{text:"Test period start unknown — all saved tickets were counted."}}function Qh(e,s="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:s}}function mk(e){return/Labels?$/.test(e)||e==="limits"||e==="fields"}function pk(e,s){const a=s[e];return a==null||a===""||mk(e)?null:typeof a=="object"?JSON.stringify(a):String(a)}function gk(e){const s=[];return e.missingCases.length>0&&s.push(`cases ${e.missingCases.join(", ")}`),e.ticketsNotReferenced.length>0&&s.push(`${e.ticketsNotReferenced.length} ticket${e.ticketsNotReferenced.length===1?"":"s"}`),s.length>0?`Not in the report: ${s.join(" · ")}`:null}function yk(e,s){var a;if(s)return s;if(!e)return null;if(e.kind==="sv-ticket")return e.attrs.ref||null;if(e.kind==="sv-approval"||e.kind==="sv-mandate")return e.attrs.ticket||null;if(e.kind==="sv-case"){const o=(a=e.data)==null?void 0:a.goal;return(o==null?void 0:o.ticketId)??null}return null}const vk="allow-popups allow-popups-to-escape-sandbox",xk="AI analysis — not verified",wk="Green = verified by the gateway — raw signed fields only",jk="Grey dashed = the AI's own analysis, not verified",Sk="= translation by the AI, not verified",bk="Übersetzung anzeigen / show translation";function Xh(e){var a;const s=((a=e.formatNotice)==null?void 0:a.blocksNotShown)??0;return s<=0?null:`${s} ${s===1?"block was":"blocks were"} not shown — not in the allowed form (the AI's own text belongs in an AI block). Ask the AI to write the report again.`}function kk(e){return(e.elements??[]).length===0&&e.renderedHtml.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").trim()===""}function Nk(e,s){return s&&e.renderedHtmlGloss?e.renderedHtmlGloss:e.renderedHtml}function Ck(e,s,a){const o=new URLSearchParams(e);return o.set("element",s),a?o.set("ticket",a):o.delete("ticket"),o}const Ek={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function Tk(e){return e.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${Ek[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function Ak(e){if(!e||e.kind!=="sv-case"||!e.data)return[];const s=Array.isArray(e.data.steps)?e.data.steps:[],a=e.data.goal,o=[...s.map(l=>({n:l,isGoal:!1})),...a?[{n:a,isGoal:!0}]:[]].filter(l=>typeof l.n.ticketId=="string"&&l.n.ticketId);return o.sort((l,u)=>(l.n.time??0)-(u.n.time??0)),o.map(({n:l,isGoal:u})=>({ticketId:l.ticketId,label:String(l.action??l.ticketId),isGoal:u}))}function Ik(e){return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>body{margin:12px;background:#fff}</style></head><body>${e}</body></html>`}const tu={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},Rk={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function Pk(e,s){return Array.isArray(s.fields)?s.fields.map(o=>({label:o.key,value:o.value})):{Ticket:["action","profile","time"],Mandate:["profile","mode","owners","intent"],Approval:["createdAt","decidedAt","whoLabel","status","waitSeconds"]}[e].filter(o=>s[o]!==void 0&&s[o]!==null).map(o=>({label:o,value:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])}))}function $k(e,s){const a=Rk[e].filter(o=>s[o]!==void 0);return a.length===0?null:n.jsxs("details",{style:{marginTop:"0.5rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),n.jsx("dl",{style:{...tu,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 lc(e,s){return s?n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:e}),s.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",s.reason??"no further detail."]}):n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:tu,children:Pk(e,s.data??{}).map(({label:a,value:o})=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:a}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:o})]},a))}),$k(e,s.data??{})]})]}):null}function _k({report:e,elementId:s,ticketParam:a,onClose:o,onSelectTicket:l}){var w;const u=e.elements.find(x=>x.id===s),f=yk(u,a),g=f?e.ticketDetails[f]:void 0,p=Ak(u),v=(w=e.proof.verifiedValues.find(x=>x.elementId===s))==null?void 0:w.summary,y=h.useRef(null);return h.useEffect(()=>{const x=y.current;if(!x||typeof x.getBoundingClientRect!="function")return;const b=x.getBoundingClientRect().top;(b<0||b>window.innerHeight-80)&&x.scrollIntoView({block:"start",behavior:"smooth"})},[s,a]),n.jsxs("div",{className:"card reports-detail",ref:y,children:[n.jsxs("div",{className:"card-header",children:[n.jsx("div",{className:"card-title",children:"Details"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,children:"Close"})]}),v&&n.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:v}),p.length>0&&n.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:p.map(x=>n.jsxs("button",{type:"button",className:`btn btn-sm ${x.ticketId===f?"btn-secondary":"btn-ghost"}`,"aria-pressed":x.ticketId===f,onClick:()=>l(x.ticketId),children:[x.isGoal?"Goal: ":"",x.label]},x.ticketId))}),!u&&n.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),u&&!f&&(u.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",u.reason??"no further detail."]}):n.jsx("dl",{style:tu,children:Object.keys(u.data??{}).map(x=>{const b=pk(x,u.data??{});return b===null?null:n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:x}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:b})]},x)})})),g&&n.jsxs(n.Fragment,{children:[lc("Ticket",g.ticket),lc("Mandate",g.mandate),lc("Approval",g.approval)]}),f&&!g&&n.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",f,"."]})]})}async function Lk(e){const{html:s,filename:a}=await e.exportReport();e.download(s,a),await e.refresh()}function Zh({detail:e}){return e?n.jsxs("details",{style:{marginTop:"0.25rem"},children:[n.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),n.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:e})]}):null}function zk({report:e,open:s,selectedId:a,onOpenElement:o,detail:l}){const{proof:u,coverage:f}=e,g=Tk(e.elements),p=gk(f),v=fk(f),y=hk(f),w=Qh(u.signaturesValid),x=Qh(u.recordsChecked);return n.jsxs("div",{className:`reports-side${s?" reports-side-open":""}`,children:[l,n.jsxs("div",{className:"card",children:[n.jsx("div",{className:"card-title",children:"Proof"}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets referenced"}),n.jsx("b",{children:u.ticketsReferenced.length})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Signatures valid"}),n.jsx("b",{className:w.kind==="ok"?"msg-ok":void 0,children:w.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Records checked"}),n.jsx("b",{className:x.kind==="ok"?"msg-ok":void 0,children:x.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Not verifiable"}),n.jsx("b",{children:u.unverifiableCount})]}),g.map(b=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===b.elementId?" reports-row-selected":""}`,onClick:()=>o(b.elementId),children:[n.jsx("span",{children:b.text}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},b.elementId))]}),n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Coverage"}),v.kind==="error"?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"reports-error",role:"alert",children:v.text}),n.jsx(Zh,{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(Zh,{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(b=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===b.elementId?" reports-row-selected":""}`,onClick:()=>o(b.elementId),title:"Show details",children:[n.jsx("span",{children:b.summary}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},b.elementId))]})]})}function Fk(){const[e,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,w]=h.useState(null),[x,b]=h.useState(!1),[k,S]=h.useState(!1),[N,T]=gs(),E=h.useCallback(()=>L.getReport().then(({report:O})=>s(O)).catch(O=>u(O instanceof Error?O.message:String(O))),[]),P=h.useCallback(()=>{o(!0),u(null),E().finally(()=>o(!1))},[E]);h.useEffect(()=>{P()},[P]),h.useEffect(()=>{e&&L.markReportSeen(Date.now()).then(()=>window.dispatchEvent(new Event("suveren:report-seen-changed"))).catch(()=>{})},[e==null?void 0:e.savedAt]);const I=h.useCallback(()=>{g(!0),L.recheckReport().then(({report:O})=>s(O)).catch(O=>u(O instanceof Error?O.message:String(O))).finally(()=>g(!1))},[]),B=h.useCallback(async()=>{v(!0),w(null);try{await Lk({exportReport:()=>L.exportReportWithProof(),download:(O,ne)=>{const fe=URL.createObjectURL(new Blob([O],{type:"text/html"})),ee=document.createElement("a");ee.href=fe,ee.download=ne,ee.click(),URL.revokeObjectURL(fe)},refresh:E})}catch(O){w(O instanceof Error?O.message:String(O))}finally{v(!1)}},[E]),M=N.get("element"),q=N.get("ticket"),z=h.useCallback((O,ne)=>{T(Ck(N,O,ne))},[N,T]),U=h.useCallback(()=>{const O=new URLSearchParams(N);O.delete("element"),O.delete("ticket"),T(O,{replace:!0})},[N,T]);if(a)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(l)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(fs,{icon:"⚠",title:"Report unavailable",text:l})]});if(!e)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(fs,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const Z=lk(e.renderedHtml),G=ck(e.elements);return n.jsx("div",{className:"page-inner reports-page",children:n.jsxs("div",{className:"reports-layout",children:[n.jsxs("div",{className:"reports-bar",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:Z}),n.jsxs("p",{className:"reports-period","data-testid":"report-period",title:Oi(e.coverage).title,children:[n.jsx("b",{children:Oi(e.coverage).text})," · written ",$m(e.savedAt,Date.now())]}),n.jsxs("p",{className:"page-subtitle",children:[G?`written by the AI under mandate ${G} · `:"","checked ",uk(e.checkedAt)]})]}),n.jsxs("div",{className:"reports-bar-actions",children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:I,disabled:f,children:f?"Checking…":"Check again"}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:B,disabled: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:dk(e.proof,e.coverage)}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>b(O=>!O),children:x?"hide":"details"})]}),n.jsxs("div",{className:"reports-grid",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"reports-legend",role:"note",children:[n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-v"}),wk]}),n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-a"}),jk," (“",xk,"”)"]}),e.renderedHtmlGloss&&n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",Sk]})]}),Xh(e)&&n.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:Xh(e)}),e.renderedHtmlGloss&&n.jsxs("label",{className:"reports-gloss-switch",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:k,onChange:O=>S(O.target.checked)}),n.jsx("span",{className:"reports-gloss-track","aria-hidden":"true",children:n.jsx("span",{className:"reports-gloss-thumb"})}),n.jsx("span",{children:bk})]}),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."}),kk(e)?n.jsxs("div",{className:"note-stopped","data-testid":"report-empty",style:{padding:"var(--space-4)"},children:[n.jsx("span",{className:"msg-error",children:"Nothing in this report can be shown."})," ","Ask the AI to write it again — its own text inside an AI block, the checked values as gateway elements."]}):n.jsx("iframe",{title:"Report",sandbox:vk,srcDoc:Ik(Nk(e,k)),className:"reports-iframe"})]}),n.jsx(zk,{report:e,open:x||!!M,selectedId:M,onOpenElement:O=>z(O),detail:M?n.jsx(_k,{report:e,elementId:M,ticketParam:q,onClose:U,onSelectTicket:O=>z(M,O)}):void 0})]})]})})}function cs({to:e}){const{search:s,hash:a}=Qt();return n.jsx(On,{to:`${e}${s}${a}`,replace:!0})}function Mk({children:e}){const{user:s,mode:a,domain:o}=wt();return s?a==="team"&&!o?n.jsx(On,{to:"/onboarding",replace:!0}):n.jsx(n.Fragment,{children:e}):n.jsx(On,{to:"/login",replace:!0})}function Ok(){const{user:e,handleSessionLocked:s,refreshGroups:a}=wt();return Me("session-locked",o=>{const l=o==null?void 0:o.message;s(l)}),Me("team-membership-changed",()=>{a()}),n.jsxs(tx,{children:[n.jsx(it,{path:"/login",element:e?n.jsx(On,{to:"/",replace:!0}):n.jsx(tw,{})}),n.jsx(it,{path:"/onboarding",element:e?n.jsx(ow,{}):n.jsx(On,{to:"/login",replace:!0})}),n.jsxs(it,{element:n.jsx(Mk,{children:n.jsx(ew,{})}),children:[n.jsx(it,{path:"/",element:n.jsx(Zw,{})}),n.jsx(it,{path:"/mandates",element:n.jsx(mS,{})}),n.jsx(it,{path:"/mandates/new/intent",element:n.jsx(Nj,{})}),n.jsx(it,{path:"/mandates/new/sign",element:n.jsx(Wj,{})}),n.jsx(it,{path:"/integrations",element:n.jsx(Jj,{})}),n.jsx(it,{path:"/team",element:n.jsx(Qj,{})}),n.jsx(it,{path:"/tickets",element:n.jsx(Eb,{})}),n.jsx(it,{path:"/blocked",element:n.jsx(Tb,{})}),n.jsx(it,{path:"/approvals",element:n.jsx(rk,{})}),n.jsx(it,{path:"/reports",element:n.jsx(Fk,{})}),n.jsx(it,{path:"/agent/new",element:n.jsx(On,{to:"/mandates?new=1",replace:!0})}),n.jsx(it,{path:"/agent/gate",element:n.jsx(cs,{to:"/mandates/new/intent"})}),n.jsx(it,{path:"/agent/review",element:n.jsx(cs,{to:"/mandates/new/sign"})}),n.jsx(it,{path:"/authorizations",element:n.jsx(cs,{to:"/mandates"})}),n.jsx(it,{path:"/groups",element:n.jsx(cs,{to:"/team"})}),n.jsx(it,{path:"/audit",element:n.jsx(cs,{to:"/tickets"})}),n.jsx(it,{path:"/proposals",element:n.jsx(cs,{to:"/approvals"})}),n.jsx(it,{path:"/agent-brief",element:n.jsx(ok,{})}),n.jsx(it,{path:"/settings",element:n.jsx(Mb,{})}),n.jsx(it,{path:"/settings/services",element:n.jsx(On,{to:"/settings",replace:!0})}),n.jsx(it,{path:"/deploy",element:n.jsx(On,{to:"/integrations",replace:!0})})]}),n.jsx(it,{path:"*",element:n.jsx(On,{to:"/",replace:!0})})]})}function Bk(){return n.jsx(Cx,{children:n.jsx(Ux,{children:n.jsx(Vx,{children:n.jsx(Ok,{})})})})}Xy.createRoot(document.getElementById("root")).render(n.jsx(h.StrictMode,{children:n.jsx(Bk,{})}));