@suveren/gateway 0.35.2 → 0.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/suveren-gateway.js +28 -1
- package/content/integrations/calendar.json +2 -0
- package/content/integrations/erp.json +5 -3
- package/content/integrations/gmail.json +2 -0
- package/content/integrations/linkedin.json +3 -0
- package/content/integrations/mail.json +9 -0
- package/dist/control-plane/index.mjs +8 -0
- package/dist/mcp-server/http.mjs +94 -37
- package/dist/ui/assets/index-BQ5Pr6As.js +123 -0
- package/dist/ui/index.html +1 -1
- package/lib/autostart-templates.d.mts +7 -0
- package/lib/autostart-templates.mjs +30 -0
- package/node_modules/@hap/core/dist/index.d.mts +25 -1
- package/node_modules/@hap/core/dist/index.d.ts +25 -1
- package/node_modules/@hap/core/dist/index.js +18 -0
- package/node_modules/@hap/core/dist/index.mjs +16 -0
- package/node_modules/@hap/core/package.json +1 -1
- package/node_modules/@hap/core/src/content-binding.ts +26 -1
- package/node_modules/@hap/core/src/types.ts +17 -0
- package/node_modules/postcss/lib/processor.js +1 -1
- package/node_modules/postcss/lib/stringify.js +30 -8
- package/node_modules/postcss/package.json +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/index-BONNmuPw.js +0 -123
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
var Yy=Object.defineProperty;var Jy=(e,s,a)=>s in e?Yy(e,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[s]=a;var Qs=(e,s,a)=>Jy(e,typeof s!="symbol"?s+"":s,a);(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))o(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const f of u.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&o(f)}).observe(document,{childList:!0,subtree:!0});function a(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(l){if(l.ep)return;l.ep=!0;const u=a(l);fetch(l.href,u)}})();var Hl={exports:{}},Xs={},Vl={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 Pf;function Qy(){if(Pf)return De;Pf=1;var e=Symbol.for("react.element"),s=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),f=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),w=Symbol.iterator;function x(A){return A===null||typeof A!="object"?null:(A=w&&A[w]||A["@@iterator"],typeof A=="function"?A:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},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 E(){}E.prototype=N.prototype;function T(A,_,se){this.props=A,this.context=_,this.refs=S,this.updater=se||b}var P=T.prototype=new E;P.constructor=T,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=T,De.StrictMode=o,De.Suspense=g,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:p,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 $f;function Cc(){return $f||($f=1,Vl.exports=Qy()),Vl.exports}/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.production.min.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var _f;function Xy(){if(_f)return Xs;_f=1;var e=Cc(),s=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function f(p,g,v){var y,w={},x=null,b=null;v!==void 0&&(x=""+v),g.key!==void 0&&(x=""+g.key),g.ref!==void 0&&(b=g.ref);for(y in g)o.call(g,y)&&!u.hasOwnProperty(y)&&(w[y]=g[y]);if(p&&p.defaultProps)for(y in g=p.defaultProps,g)w[y]===void 0&&(w[y]=g[y]);return{$$typeof:s,type:p,key:x,ref:b,props:w,_owner:l.current}}return Xs.Fragment=a,Xs.jsx=f,Xs.jsxs=f,Xs}var Lf;function Zy(){return Lf||(Lf=1,Hl.exports=Xy()),Hl.exports}var n=Zy(),h=Cc(),Ni={},Gl={exports:{}},Qt={},Kl={exports:{}},ql={};/**
|
|
18
|
-
* @license React
|
|
19
|
-
* scheduler.production.min.js
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var zf;function ev(){return zf||(zf=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,p=f.now();e.unstable_now=function(){return f.now()-p}}var g=[],v=[],y=1,w=null,x=3,b=!1,k=!1,S=!1,N=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function P(X){for(var Q=a(v);Q!==null;){if(Q.callback===null)o(v);else if(Q.startTime<=X)o(v),Q.sortIndex=Q.expirationTime,s(g,Q);else break;Q=a(v)}}function I(X){if(S=!1,P(X),!k)if(a(g)!==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,E(z),z=-1),b=!0;var Y=x;try{for(P(Q),w=a(g);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(g)&&o(g),P(Q)}else o(g);w=a(g)}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 T=="function")ne=function(){T(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(g)},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(g)===null&&X===a(v)&&(S?(E(z),z=-1):S=!0,Ne(I,Y-A))):(X.sortIndex=_,s(g,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}}}})(ql)),ql}var Ff;function tv(){return Ff||(Ff=1,Kl.exports=ev()),Kl.exports}/**
|
|
26
|
-
* @license React
|
|
27
|
-
* react-dom.production.min.js
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the MIT license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var Mf;function nv(){if(Mf)return Qt;Mf=1;var e=Cc(),s=tv();function a(t){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;i<arguments.length;i++)r+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,l={};function u(t,r){f(t,r),f(t+"Capture",r)}function f(t,r){for(l[t]=r,t=0;t<r.length;t++)o.add(r[t])}var p=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,y={},w={};function x(t){return g.call(w,t)?!0:g.call(y,t)?!1:v.test(t)?w[t]=!0:(y[t]=!0,!1)}function b(t,r,i,c){if(i!==null&&i.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return c?!1:i!==null?!i.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function 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 E=/[\-:]([a-z])/g;function T(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var r=t.replace(E,T);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(E,T);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(E,T);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 Vt(t,r){t=t.style;for(var i in r)if(r.hasOwnProperty(i)){var c=i.indexOf("--")===0,d=rt(i,r[i],c);i==="float"&&(i="cssFloat"),c?t.setProperty(i,d):t[i]=d}}var Bt=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(Bt[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 Zt(){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(),Zt())}}function Xe(t,r){var i=t.stateNode;if(i===null)return null;var c=Ba(i);if(c===null)return null;i=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(i&&typeof i!="function")throw Error(a(231,r,typeof i));return i}var Ct=!1;if(p)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 hr=!1,Fr=null,Vn=!1,mr=null,lo={onError:function(t){hr=!0,Fr=t}};function ya(t,r,i,c,d,m,j,C,R){hr=!1,Fr=null,zr.apply(lo,arguments)}function va(t,r,i,c,d,m,j,C,R){if(ya.apply(this,arguments),hr){if(hr){var V=Fr;hr=!1,Fr=null}else throw Error(a(198));Vn||(Vn=!0,mr=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?ru(t):null}function ru(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var r=ru(t);if(r!==null)return r;t=t.sibling}return null}var su=s.unstable_scheduleCallback,au=s.unstable_cancelCallback,ig=s.unstable_shouldYield,og=s.unstable_requestPaint,vt=s.unstable_now,lg=s.unstable_getCurrentPriorityLevel,co=s.unstable_ImmediatePriority,iu=s.unstable_UserBlockingPriority,wa=s.unstable_NormalPriority,cg=s.unstable_LowPriority,ou=s.unstable_IdlePriority,ja=null,Nn=null;function ug(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:hg,dg=Math.log,fg=Math.LN2;function hg(t){return t>>>=0,t===0?32:31-(dg(t)/fg|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 mg(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 pg(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]=mg(C,r)):R<=r&&(t.expiredLanes|=C),m&=~C}}function uo(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function lu(){var t=Sa;return Sa<<=1,(Sa&4194240)===0&&(Sa=64),t}function fo(t){for(var r=[],i=0;31>i;i++)r.push(t);return r}function 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 gg(t,r){var i=t.pendingLanes&~r;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=r,t.mutableReadLanes&=r,t.entangledLanes&=r,r=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<i;){var d=31-hn(i),m=1<<d;r[d]=0,c[d]=-1,t[d]=-1,i&=~m}}function ho(t,r){var i=t.entangledLanes|=r;for(t=t.entanglements;i;){var c=31-hn(i),d=1<<c;d&r|t[c]&r&&(t[c]|=r),i&=~d}}var tt=0;function cu(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var uu,mo,du,fu,hu,po=!1,Na=[],Gn=null,Kn=null,qn=null,ws=new Map,js=new Map,Yn=[],yg="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 mu(t,r){switch(t){case"focusin":case"focusout":Gn=null;break;case"dragenter":case"dragleave":Kn=null;break;case"mouseover":case"mouseout":qn=null;break;case"pointerover":case"pointerout":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&&mo(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,d!==null&&r.indexOf(d)===-1&&r.push(d),t)}function vg(t,r,i,c,d){switch(r){case"focusin":return Gn=Ss(Gn,t,r,i,c,d),!0;case"dragenter":return Kn=Ss(Kn,t,r,i,c,d),!0;case"mouseover":return qn=Ss(qn,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 pu(t){var r=pr(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,hu(t.priority,function(){du(i)});return}}else if(r===3&&i.stateNode.current.memoizedState.isDehydrated){t.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Ca(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var i=yo(t.domEventName,t.eventSystemFlags,r[0],t.nativeEvent);if(i===null){i=t.nativeEvent;var c=new i.constructor(i.type,i);xe=c,i.target.dispatchEvent(c),xe=null}else return r=zs(i),r!==null&&mo(r),t.blockedOn=i,!1;r.shift()}return!0}function gu(t,r,i){Ca(t)&&i.delete(r)}function xg(){po=!1,Gn!==null&&Ca(Gn)&&(Gn=null),Kn!==null&&Ca(Kn)&&(Kn=null),qn!==null&&Ca(qn)&&(qn=null),ws.forEach(gu),js.forEach(gu)}function bs(t,r){t.blockedOn===r&&(t.blockedOn=null,po||(po=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,xg)))}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(Gn!==null&&bs(Gn,t),Kn!==null&&bs(Kn,t),qn!==null&&bs(qn,t),ws.forEach(r),js.forEach(r),i=0;i<Yn.length;i++)c=Yn[i],c.blockedOn===t&&(c.blockedOn=null);for(;0<Yn.length&&(i=Yn[0],i.blockedOn===null);)pu(i),i.blockedOn===null&&Yn.shift()}var Or=I.ReactCurrentBatchConfig,Ea=!0;function wg(t,r,i,c){var d=tt,m=Or.transition;Or.transition=null;try{tt=1,go(t,r,i,c)}finally{tt=d,Or.transition=m}}function jg(t,r,i,c){var d=tt,m=Or.transition;Or.transition=null;try{tt=4,go(t,r,i,c)}finally{tt=d,Or.transition=m}}function go(t,r,i,c){if(Ea){var d=yo(t,r,i,c);if(d===null)_o(t,r,c,Ta,i),mu(t,c);else if(vg(d,t,r,i,c))c.stopPropagation();else if(mu(t,c),r&4&&-1<yg.indexOf(t)){for(;d!==null;){var m=zs(d);if(m!==null&&uu(m),m=yo(t,r,i,c),m===null&&_o(t,r,c,Ta,i),m===d)break;d=m}d!==null&&c.stopPropagation()}else _o(t,r,c,null,i)}}var Ta=null;function yo(t,r,i,c){if(Ta=null,t=Ae(c),t=pr(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 yu(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(lg()){case co:return 1;case iu:return 4;case wa:case cg:return 16;case ou:return 536870912;default:return 16}default:return 16}}var Jn=null,vo=null,Aa=null;function vu(){if(Aa)return Aa;var t,r=vo,i=r.length,c,d="value"in Jn?Jn.value:Jn.textContent,m=d.length;for(t=0;t<i&&r[t]===d[t];t++);var j=i-t;for(c=1;c<=j&&r[i-c]===d[m-c];c++);return Aa=d.slice(t,1<c?1-c:void 0)}function Ia(t){var r=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&r===13&&(t=13)):t=r,t===10&&(t=13),32<=t||t===13?t:0}function Ra(){return!0}function xu(){return!1}function en(t){function r(i,c,d,m,j){this._reactName=i,this._targetInst=d,this.type=c,this.nativeEvent=m,this.target=j,this.currentTarget=null;for(var C in t)t.hasOwnProperty(C)&&(i=t[C],this[C]=i?i(m):m[C]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?Ra:xu,this.isPropagationStopped=xu,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},xo=en(Br),Ns=Y({},Br,{view:0,detail:0}),Sg=en(Ns),wo,jo,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:bo,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Cs&&(Cs&&t.type==="mousemove"?(wo=t.screenX-Cs.screenX,jo=t.screenY-Cs.screenY):jo=wo=0,Cs=t),wo)},movementY:function(t){return"movementY"in t?t.movementY:jo}}),wu=en(Pa),bg=Y({},Pa,{dataTransfer:0}),kg=en(bg),Ng=Y({},Ns,{relatedTarget:0}),So=en(Ng),Cg=Y({},Br,{animationName:0,elapsedTime:0,pseudoElement:0}),Eg=en(Cg),Tg=Y({},Br,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Ag=en(Tg),Ig=Y({},Br,{data:0}),ju=en(Ig),Rg={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Pg={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"},$g={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function _g(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=$g[t])?!!r[t]:!1}function bo(){return _g}var Lg=Y({},Ns,{key:function(t){if(t.key){var r=Rg[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"?Pg[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:bo,charCode:function(t){return t.type==="keypress"?Ia(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Ia(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),zg=en(Lg),Fg=Y({},Pa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Su=en(Fg),Mg=Y({},Ns,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:bo}),Og=en(Mg),Bg=Y({},Br,{propertyName:0,elapsedTime:0,pseudoElement:0}),Dg=en(Bg),Ug=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}),Wg=en(Ug),Hg=[9,13,27,32],ko=p&&"CompositionEvent"in window,Es=null;p&&"documentMode"in document&&(Es=document.documentMode);var Vg=p&&"TextEvent"in window&&!Es,bu=p&&(!ko||Es&&8<Es&&11>=Es),ku=" ",Nu=!1;function Cu(t,r){switch(t){case"keyup":return Hg.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Eu(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Dr=!1;function Gg(t,r){switch(t){case"compositionend":return Eu(r);case"keypress":return r.which!==32?null:(Nu=!0,ku);case"textInput":return t=r.data,t===ku&&Nu?null:t;default:return null}}function Kg(t,r){if(Dr)return t==="compositionend"||!ko&&Cu(t,r)?(t=vu(),Aa=vo=Jn=null,Dr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return bu&&r.locale!=="ko"?null:r.data;default:return null}}var qg={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 Tu(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!qg[t.type]:r==="textarea"}function Au(t,r,i,c){St(c),r=Fa(r,"onChange"),0<r.length&&(i=new xo("onChange","change",null,i,c),t.push({event:i,listeners:r}))}var Ts=null,As=null;function Yg(t){Ku(t,0)}function $a(t){var r=Gr(t);if(be(r))return t}function Jg(t,r){if(t==="change")return r}var Iu=!1;if(p){var No;if(p){var Co="oninput"in document;if(!Co){var Ru=document.createElement("div");Ru.setAttribute("oninput","return;"),Co=typeof Ru.oninput=="function"}No=Co}else No=!1;Iu=No&&(!document.documentMode||9<document.documentMode)}function Pu(){Ts&&(Ts.detachEvent("onpropertychange",$u),As=Ts=null)}function $u(t){if(t.propertyName==="value"&&$a(As)){var r=[];Au(r,As,t,Ae(t)),Be(Yg,r)}}function Qg(t,r,i){t==="focusin"?(Pu(),Ts=r,As=i,Ts.attachEvent("onpropertychange",$u)):t==="focusout"&&Pu()}function Xg(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return $a(As)}function Zg(t,r){if(t==="click")return $a(r)}function ey(t,r){if(t==="input"||t==="change")return $a(r)}function ty(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var mn=typeof Object.is=="function"?Object.is:ty;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(!g.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 Lu(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 zu(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?zu(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function Fu(){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 Eo(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}function ny(t){var r=Fu(),i=t.focusedElem,c=t.selectionRange;if(r!==i&&i&&i.ownerDocument&&zu(i.ownerDocument.documentElement,i)){if(c!==null&&Eo(i)){if(r=c.start,t=c.end,t===void 0&&(t=r),"selectionStart"in i)i.selectionStart=r,i.selectionEnd=Math.min(t,i.value.length);else if(t=(r=i.ownerDocument||document)&&r.defaultView||window,t.getSelection){t=t.getSelection();var d=i.textContent.length,m=Math.min(c.start,d);c=c.end===void 0?m:Math.min(c.end,d),!t.extend&&m>c&&(d=c,c=m,m=d),d=Lu(i,m);var j=Lu(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 ry=p&&"documentMode"in document&&11>=document.documentMode,Ur=null,To=null,Rs=null,Ao=!1;function Mu(t,r,i){var c=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Ao||Ur==null||Ur!==oe(c)||(c=Ur,"selectionStart"in c&&Eo(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Rs&&Is(Rs,c)||(Rs=c,c=Fa(To,"onSelect"),0<c.length&&(r=new xo("onSelect","select",null,r,i),t.push({event:r,listeners:c}),r.target=Ur)))}function _a(t,r){var i={};return i[t.toLowerCase()]=r.toLowerCase(),i["Webkit"+t]="webkit"+r,i["Moz"+t]="moz"+r,i}var Wr={animationend:_a("Animation","AnimationEnd"),animationiteration:_a("Animation","AnimationIteration"),animationstart:_a("Animation","AnimationStart"),transitionend:_a("Transition","TransitionEnd")},Io={},Ou={};p&&(Ou=document.createElement("div").style,"AnimationEvent"in window||(delete Wr.animationend.animation,delete Wr.animationiteration.animation,delete Wr.animationstart.animation),"TransitionEvent"in window||delete Wr.transitionend.transition);function La(t){if(Io[t])return Io[t];if(!Wr[t])return t;var r=Wr[t],i;for(i in r)if(r.hasOwnProperty(i)&&i in Ou)return Io[t]=r[i];return t}var Bu=La("animationend"),Du=La("animationiteration"),Uu=La("animationstart"),Wu=La("transitionend"),Hu=new Map,Vu="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Qn(t,r){Hu.set(t,r),u(r,[t])}for(var Ro=0;Ro<Vu.length;Ro++){var Po=Vu[Ro],sy=Po.toLowerCase(),ay=Po[0].toUpperCase()+Po.slice(1);Qn(sy,"on"+ay)}Qn(Bu,"onAnimationEnd"),Qn(Du,"onAnimationIteration"),Qn(Uu,"onAnimationStart"),Qn("dblclick","onDoubleClick"),Qn("focusin","onFocus"),Qn("focusout","onBlur"),Qn(Wu,"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(" "),iy=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ps));function Gu(t,r,i){var c=t.type||"unknown-event";t.currentTarget=i,va(c,r,void 0,t),t.currentTarget=null}function Ku(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;Gu(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;Gu(d,C,V),m=R}}}if(Vn)throw t=mr,Vn=!1,mr=null,t}function ot(t,r){var i=r[Bo];i===void 0&&(i=r[Bo]=new Set);var c=t+"__bubble";i.has(c)||(qu(r,t,2,!1),i.add(c))}function $o(t,r,i){var c=0;r&&(c|=4),qu(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"&&(iy.has(i)||$o(i,!1,t),$o(i,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[za]||(r[za]=!0,$o("selectionchange",!1,r))}}function qu(t,r,i,c){switch(yu(r)){case 1:var d=wg;break;case 4:d=jg;break;default:d=go}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=pr(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=Hu.get(t);if(re!==void 0){var je=xo,ke=t;switch(t){case"keypress":if(Ia(i)===0)break e;case"keydown":case"keyup":je=zg;break;case"focusin":ke="focus",je=So;break;case"focusout":ke="blur",je=So;break;case"beforeblur":case"afterblur":je=So;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=wu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=kg;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=Og;break;case Bu:case Du:case Uu:je=Eg;break;case Wu:je=Dg;break;case"scroll":je=Sg;break;case"wheel":je=Wg;break;case"copy":case"cut":case"paste":je=Ag;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=Su}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)&&(pr(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?pr(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=wu,he="onMouseLeave",F="onMouseEnter",$="mouse",(t==="pointerout"||t==="pointerover")&&(Ee=Su,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,pr(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&&Yu(ce,re,je,Ee,!1),ke!==null&&xt!==null&&Yu(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=Jg;else if(Tu(re))if(Iu)Te=ey;else{Te=Xg;var Pe=Qg}else(je=re.nodeName)&&je.toLowerCase()==="input"&&(re.type==="checkbox"||re.type==="radio")&&(Te=Zg);if(Te&&(Te=Te(t,V))){Au(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":(Tu(Pe)||Pe.contentEditable==="true")&&(Ur=Pe,To=V,Rs=null);break;case"focusout":Rs=To=Ur=null;break;case"mousedown":Ao=!0;break;case"contextmenu":case"mouseup":case"dragend":Ao=!1,Mu(ce,i,ae);break;case"selectionchange":if(ry)break;case"keydown":case"keyup":Mu(ce,i,ae)}var $e;if(ko)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?Cu(t,i)&&(_e="onCompositionEnd"):t==="keydown"&&i.keyCode===229&&(_e="onCompositionStart");_e&&(bu&&i.locale!=="ko"&&(Dr||_e!=="onCompositionStart"?_e==="onCompositionEnd"&&Dr&&($e=vu()):(Jn=ae,vo="value"in Jn?Jn.value:Jn.textContent,Dr=!0)),Pe=Fa(V,_e),0<Pe.length&&(_e=new ju(_e,t,null,i,ae),ce.push({event:_e,listeners:Pe}),$e?_e.data=$e:($e=Eu(i),$e!==null&&(_e.data=$e)))),($e=Vg?Gg(t,i):Kg(t,i))&&(V=Fa(V,"onBeforeInput"),0<V.length&&(ae=new ju("onBeforeInput","beforeinput",null,i,ae),ce.push({event:ae,listeners:V}),ae.data=$e))}Ku(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 Yu(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 oy=/\r\n?/g,ly=/\u0000|\uFFFD/g;function Ju(t){return(typeof t=="string"?t:""+t).replace(oy,`
|
|
38
|
-
`).replace(ly,"")}function Ma(t,r,i){if(r=Ju(r),Ju(t)!==r&&i)throw Error(a(425))}function Oa(){}var Lo=null,zo=null;function Fo(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Mo=typeof setTimeout=="function"?setTimeout:void 0,cy=typeof clearTimeout=="function"?clearTimeout:void 0,Qu=typeof Promise=="function"?Promise:void 0,uy=typeof queueMicrotask=="function"?queueMicrotask:typeof Qu<"u"?function(t){return Qu.resolve(null).then(t).catch(dy)}:Mo;function dy(t){setTimeout(function(){throw t})}function Oo(t,r){var i=r,c=0;do{var d=i.nextSibling;if(t.removeChild(i),d&&d.nodeType===8)if(i=d.data,i==="/$"){if(c===0){t.removeChild(d),ks(r);return}c--}else i!=="$"&&i!=="$?"&&i!=="$!"||c++;i=d}while(i);ks(r)}function Xn(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return t}function Xu(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,Bo="__reactEvents$"+Vr,fy="__reactListeners$"+Vr,hy="__reactHandles$"+Vr;function pr(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=Xu(t);t!==null;){if(i=t[Cn])return i;t=Xu(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 Do=[],Kr=-1;function Zn(t){return{current:t}}function lt(t){0>Kr||(t.current=Do[Kr],Do[Kr]=null,Kr--)}function at(t,r){Kr++,Do[Kr]=t.current,t.current=r}var er={},$t=Zn(er),Gt=Zn(!1),gr=er;function qr(t,r){var i=t.type.contextTypes;if(!i)return er;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var d={},m;for(m in i)d[m]=r[m];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=r,t.__reactInternalMemoizedMaskedChildContext=d),d}function Kt(t){return t=t.childContextTypes,t!=null}function Da(){lt(Gt),lt($t)}function Zu(t,r,i){if($t.current!==er)throw Error(a(168));at($t,r),at(Gt,i)}function ed(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||er,gr=$t.current,at($t,t),at(Gt,Gt.current),!0}function td(t,r,i){var c=t.stateNode;if(!c)throw Error(a(169));i?(t=ed(t,r,gr),c.__reactInternalMemoizedMergedChildContext=t,lt(Gt),lt($t),at($t,t)):lt(Gt),at(Gt,i)}var Pn=null,Wa=!1,Uo=!1;function nd(t){Pn===null?Pn=[t]:Pn.push(t)}function my(t){Wa=!0,nd(t)}function tr(){if(!Uo&&Pn!==null){Uo=!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)),su(co,tr),d}finally{tt=r,Uo=!1}}return null}var Yr=[],Jr=0,Ha=null,Va=0,an=[],on=0,yr=null,$n=1,_n="";function vr(t,r){Yr[Jr++]=Va,Yr[Jr++]=Ha,Ha=t,Va=r}function rd(t,r,i){an[on++]=$n,an[on++]=_n,an[on++]=yr,yr=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 Wo(t){t.return!==null&&(vr(t,1),rd(t,1,0))}function Ho(t){for(;t===Ha;)Ha=Yr[--Jr],Yr[Jr]=null,Va=Yr[--Jr],Yr[Jr]=null;for(;t===yr;)yr=an[--on],an[on]=null,_n=an[--on],an[on]=null,$n=an[--on],an[on]=null}var tn=null,nn=null,ct=!1,pn=null;function sd(t,r){var i=dn(5,null,null,0);i.elementType="DELETED",i.stateNode=r,i.return=t,r=t.deletions,r===null?(t.deletions=[i],t.flags|=16):r.push(i)}function ad(t,r){switch(t.tag){case 5:var i=t.type;return r=r.nodeType!==1||i.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(t.stateNode=r,tn=t,nn=Xn(r.firstChild),!0):!1;case 6:return r=t.pendingProps===""||r.nodeType!==3?null:r,r!==null?(t.stateNode=r,tn=t,nn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(i=yr!==null?{id:$n,overflow:_n}:null,t.memoizedState={dehydrated:r,treeContext:i,retryLane:1073741824},i=dn(18,null,null,0),i.stateNode=r,i.return=t,t.child=i,tn=t,nn=null,!0):!1;default:return!1}}function Vo(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Go(t){if(ct){var r=nn;if(r){var i=r;if(!ad(t,r)){if(Vo(t))throw Error(a(418));r=Xn(i.nextSibling);var c=tn;r&&ad(t,r)?sd(c,i):(t.flags=t.flags&-4097|2,ct=!1,tn=t)}}else{if(Vo(t))throw Error(a(418));t.flags=t.flags&-4097|2,ct=!1,tn=t}}}function id(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;tn=t}function Ga(t){if(t!==tn)return!1;if(!ct)return id(t),ct=!0,!1;var r;if((r=t.tag!==3)&&!(r=t.tag!==5)&&(r=t.type,r=r!=="head"&&r!=="body"&&!Fo(t.type,t.memoizedProps)),r&&(r=nn)){if(Vo(t))throw od(),Error(a(418));for(;r;)sd(t,r),r=Xn(r.nextSibling)}if(id(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(a(317));e:{for(t=t.nextSibling,r=0;t;){if(t.nodeType===8){var i=t.data;if(i==="/$"){if(r===0){nn=Xn(t.nextSibling);break e}r--}else i!=="$"&&i!=="$!"&&i!=="$?"||r++}t=t.nextSibling}nn=null}}else nn=tn?Xn(t.stateNode.nextSibling):null;return!0}function od(){for(var t=nn;t;)t=Xn(t.nextSibling)}function Qr(){nn=tn=null,ct=!1}function Ko(t){pn===null?pn=[t]:pn.push(t)}var py=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 ld(t){var r=t._init;return r(t._payload)}function cd(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=cr(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?($=Ml(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&&ld(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?($=Ol(D,F.mode,he),$.return=F,$):($=d($,D.children||[]),$.return=F,$)}function ae(F,$,D,he,Te){return $===null||$.tag!==7?($=Cr(D,F.mode,he,Te),$.return=F,$):($=d($,D),$.return=F,$)}function ce(F,$,D){if(typeof $=="string"&&$!==""||typeof $=="number")return $=Ml(""+$,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 $=Ol($,F.mode,D),$.return=F,$;case pe:var he=$._init;return ce(F,he($._payload),D)}if(Ye($)||Q($))return $=Cr($,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&&vr(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&&vr(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(ur){return r(F,ur)}),ct&&vr(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 ur=re(F,$e,Qe.value,he);if(ur===null){$e===null&&($e=At);break}t&&$e&&ur.alternate===null&&r(F,$e),$=m(ur,$,_e),Pe===null?Te=ur:Pe.sibling=ur,Pe=ur,$e=At}if(Qe.done)return i(F,$e),ct&&vr(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&&vr(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(qy){return r(F,qy)}),ct&&vr(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&&ld(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?($=Cr(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}$=Ol(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,$),$=Ml(D,F.mode,he),$.return=F,F=$),j(F)):i(F,$)}return xt}var Xr=cd(!0),ud=cd(!1),qa=Zn(null),Ya=null,Zr=null,qo=null;function Yo(){qo=Zr=Ya=null}function Jo(t){var r=qa.current;lt(qa),t._currentValue=r}function Qo(t,r,i){for(;t!==null;){var c=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),t===i)break;t=t.return}}function es(t,r){Ya=t,qo=Zr=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&r)!==0&&(qt=!0),t.firstContext=null)}function ln(t){var r=t._currentValue;if(qo!==t)if(t={context:t,memoizedValue:r,next:null},Zr===null){if(Ya===null)throw Error(a(308));Zr=t,Ya.dependencies={lanes:0,firstContext:t}}else Zr=Zr.next=t;return r}var xr=null;function Xo(t){xr===null?xr=[t]:xr.push(t)}function dd(t,r,i,c){var d=r.interleaved;return d===null?(i.next=i,Xo(r)):(i.next=d.next,d.next=i),r.interleaved=i,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 nr=!1;function Zo(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function fd(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 rr(t,r,i){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(Je&2)!==0){var d=c.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),c.pending=r,Ln(t,i)}return d=c.interleaved,d===null?(r.next=r,Xo(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,ho(t,i)}}function hd(t,r){var i=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,i===c)){var d=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var j={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};m===null?d=m=j:m=m.next=j,i=i.next}while(i!==null);m===null?d=m=r:m=m.next=r}else d=m=r;i={baseState:c.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:c.shared,effects:c.effects},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=r:t.next=r,i.lastBaseUpdate=r}function Qa(t,r,i,c){var d=t.updateQueue;nr=!1;var m=d.firstBaseUpdate,j=d.lastBaseUpdate,C=d.shared.pending;if(C!==null){d.shared.pending=null;var R=C,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:nr=!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);Sr|=j,t.lanes=j,t.memoizedState=ce}}function md(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=Zn(Ms),Os=Zn(Ms),Bs=Zn(Ms);function wr(t){if(t===Ms)throw Error(a(174));return t}function el(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 pd(t){wr(Bs.current);var r=wr(En.current),i=Oe(r,t.type);r!==i&&(at(Os,t),at(En,i))}function tl(t){Os.current===t&&(lt(En),lt(Os))}var ht=Zn(0);function Xa(t){for(var r=t;r!==null;){if(r.tag===13){var i=r.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var nl=[];function rl(){for(var t=0;t<nl.length;t++)nl[t]._workInProgressVersionPrimary=null;nl.length=0}var Za=I.ReactCurrentDispatcher,sl=I.ReactCurrentBatchConfig,jr=0,mt=null,bt=null,Et=null,ei=!1,Ds=!1,Us=0,gy=0;function _t(){throw Error(a(321))}function al(t,r){if(r===null)return!1;for(var i=0;i<r.length&&i<t.length;i++)if(!mn(t[i],r[i]))return!1;return!0}function il(t,r,i,c,d,m){if(jr=m,mt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Za.current=t===null||t.memoizedState===null?wy:jy,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=Sy,t=i(c,d)}while(Ds)}if(Za.current=ri,r=bt!==null&&bt.next!==null,jr=0,Et=bt=mt=null,ei=!1,r)throw Error(a(300));return t}function ol(){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 cn(){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 ll(t){var r=cn(),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((jr&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,Sr|=ae}V=V.next}while(V!==null&&V!==m);R===null?j=c:R.next=C,mn(c,r.memoizedState)||(qt=!0),r.memoizedState=c,r.baseState=j,r.baseQueue=R,i.lastRenderedState=c}if(t=i.interleaved,t!==null){d=t;do m=d.lane,mt.lanes|=m,Sr|=m,d=d.next;while(d!==t)}else d===null&&(i.lanes=0);return[r.memoizedState,i.dispatch]}function cl(t){var r=cn(),i=r.queue;if(i===null)throw Error(a(311));i.lastRenderedReducer=t;var c=i.dispatch,d=i.pending,m=r.memoizedState;if(d!==null){i.pending=null;var j=d=d.next;do m=t(m,j.action),j=j.next;while(j!==d);mn(m,r.memoizedState)||(qt=!0),r.memoizedState=m,r.baseQueue===null&&(r.baseState=m),i.lastRenderedState=m}return[m,c]}function gd(){}function yd(t,r){var i=mt,c=cn(),d=r(),m=!mn(c.memoizedState,d);if(m&&(c.memoizedState=d,qt=!0),c=c.queue,ul(wd.bind(null,i,c,t),[t]),c.getSnapshot!==r||m||Et!==null&&Et.memoizedState.tag&1){if(i.flags|=2048,Hs(9,xd.bind(null,i,c,d,r),void 0,null),Tt===null)throw Error(a(349));(jr&30)!==0||vd(i,r,d)}return d}function vd(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 xd(t,r,i,c){r.value=i,r.getSnapshot=c,jd(r)&&Sd(t)}function wd(t,r,i){return i(function(){jd(r)&&Sd(t)})}function jd(t){var r=t.getSnapshot;t=t.value;try{var i=r();return!mn(t,i)}catch{return!0}}function Sd(t){var r=Ln(t,1);r!==null&&xn(r,t,1,-1)}function bd(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=xy.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 kd(){return cn().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=cn();c=c===void 0?null:c;var m=void 0;if(bt!==null){var j=bt.memoizedState;if(m=j.destroy,c!==null&&al(c,j.deps)){d.memoizedState=Hs(r,i,m,c);return}}mt.flags|=t,d.memoizedState=Hs(1|r,i,m,c)}function Nd(t,r){return ti(8390656,8,t,r)}function ul(t,r){return ni(2048,8,t,r)}function Cd(t,r){return ni(4,2,t,r)}function Ed(t,r){return ni(4,4,t,r)}function Td(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 Ad(t,r,i){return i=i!=null?i.concat([t]):null,ni(4,4,Td.bind(null,r,t),i)}function dl(){}function Id(t,r){var i=cn();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&al(r,c[1])?c[0]:(i.memoizedState=[t,r],t)}function Rd(t,r){var i=cn();r=r===void 0?null:r;var c=i.memoizedState;return c!==null&&r!==null&&al(r,c[1])?c[0]:(t=t(),i.memoizedState=[t,r],t)}function Pd(t,r,i){return(jr&21)===0?(t.baseState&&(t.baseState=!1,qt=!0),t.memoizedState=i):(mn(i,r)||(i=lu(),mt.lanes|=i,Sr|=i,t.baseState=!0),r)}function yy(t,r){var i=tt;tt=i!==0&&4>i?i:4,t(!0);var c=sl.transition;sl.transition={};try{t(!1),r()}finally{tt=i,sl.transition=c}}function $d(){return cn().memoizedState}function vy(t,r,i){var c=or(t);if(i={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null},_d(t))Ld(r,i);else if(i=dd(t,r,i,c),i!==null){var d=Ut();xn(i,t,c,d),zd(i,r,c)}}function xy(t,r,i){var c=or(t),d={lane:c,action:i,hasEagerState:!1,eagerState:null,next:null};if(_d(t))Ld(r,d);else{var m=t.alternate;if(t.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var j=r.lastRenderedState,C=m(j,i);if(d.hasEagerState=!0,d.eagerState=C,mn(C,j)){var R=r.interleaved;R===null?(d.next=d,Xo(r)):(d.next=R.next,R.next=d),r.interleaved=d;return}}catch{}finally{}i=dd(t,r,d,c),i!==null&&(d=Ut(),xn(i,t,c,d),zd(i,r,c))}}function _d(t){var r=t.alternate;return t===mt||r!==null&&r===mt}function Ld(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 zd(t,r,i){if((i&4194240)!==0){var c=r.lanes;c&=t.pendingLanes,i|=c,r.lanes=i,ho(t,i)}}var ri={readContext:ln,useCallback:_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},wy={readContext:ln,useCallback:function(t,r){return Tn().memoizedState=[t,r===void 0?null:r],t},useContext:ln,useEffect:Nd,useImperativeHandle:function(t,r,i){return i=i!=null?i.concat([t]):null,ti(4194308,4,Td.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=vy.bind(null,mt,t),[c.memoizedState,t]},useRef:function(t){var r=Tn();return t={current:t},r.memoizedState=t},useState:bd,useDebugValue:dl,useDeferredValue:function(t){return Tn().memoizedState=t},useTransition:function(){var t=bd(!1),r=t[0];return t=yy.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));(jr&30)!==0||vd(c,r,i)}d.memoizedState=i;var m={value:i,getSnapshot:r};return d.queue=m,Nd(wd.bind(null,c,m,t),[t]),c.flags|=2048,Hs(9,xd.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=gy++,r=":"+r+"r"+i.toString(32)+":";return t.memoizedState=r},unstable_isNewReconciler:!1},jy={readContext:ln,useCallback:Id,useContext:ln,useEffect:ul,useImperativeHandle:Ad,useInsertionEffect:Cd,useLayoutEffect:Ed,useMemo:Rd,useReducer:ll,useRef:kd,useState:function(){return ll(Ws)},useDebugValue:dl,useDeferredValue:function(t){var r=cn();return Pd(r,bt.memoizedState,t)},useTransition:function(){var t=ll(Ws)[0],r=cn().memoizedState;return[t,r]},useMutableSource:gd,useSyncExternalStore:yd,useId:$d,unstable_isNewReconciler:!1},Sy={readContext:ln,useCallback:Id,useContext:ln,useEffect:ul,useImperativeHandle:Ad,useInsertionEffect:Cd,useLayoutEffect:Ed,useMemo:Rd,useReducer:cl,useRef:kd,useState:function(){return cl(Ws)},useDebugValue:dl,useDeferredValue:function(t){var r=cn();return bt===null?r.memoizedState=t:Pd(r,bt.memoizedState,t)},useTransition:function(){var t=cl(Ws)[0],r=cn().memoizedState;return[t,r]},useMutableSource:gd,useSyncExternalStore:yd,useId:$d,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 fl(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=Ut(),d=or(t),m=zn(c,d);m.payload=r,i!=null&&(m.callback=i),r=rr(t,m,d),r!==null&&(xn(r,t,d,c),Ja(r,t,d))},enqueueReplaceState:function(t,r,i){t=t._reactInternals;var c=Ut(),d=or(t),m=zn(c,d);m.tag=1,m.payload=r,i!=null&&(m.callback=i),r=rr(t,m,d),r!==null&&(xn(r,t,d,c),Ja(r,t,d))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var i=Ut(),c=or(t),d=zn(i,c);d.tag=2,r!=null&&(d.callback=r),r=rr(t,d,c),r!==null&&(xn(r,t,c,i),Ja(r,t,c))}};function Fd(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 Md(t,r,i){var c=!1,d=er,m=r.contextType;return typeof m=="object"&&m!==null?m=ln(m):(d=Kt(r)?gr:$t.current,c=r.contextTypes,m=(c=c!=null)?qr(t,d):er),r=new r(i,m),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=si,t.stateNode=r,r._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=d,t.__reactInternalMemoizedMaskedChildContext=m),r}function Od(t,r,i,c){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(i,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(i,c),r.state!==t&&si.enqueueReplaceState(r,r.state,null)}function hl(t,r,i,c){var d=t.stateNode;d.props=i,d.state=t.memoizedState,d.refs={},Zo(t);var m=r.contextType;typeof m=="object"&&m!==null?d.context=ln(m):(m=Kt(r)?gr:$t.current,d.context=qr(t,m)),d.state=t.memoizedState,m=r.getDerivedStateFromProps,typeof m=="function"&&(fl(t,r,m,i),d.state=t.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(r=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),r!==d.state&&si.enqueueReplaceState(d,d.state,null),Qa(t,i,d,c),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308)}function ns(t,r){try{var i="",c=r;do i+=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 ml(t,r,i){return{value:t,source:null,stack:i??null,digest:r??null}}function pl(t,r){try{console.error(r.value)}catch(i){setTimeout(function(){throw i})}}var by=typeof WeakMap=="function"?WeakMap:Map;function Bd(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,Il=c),pl(t,r)},i}function Dd(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(){pl(t,r)}}var m=t.stateNode;return m!==null&&typeof m.componentDidCatch=="function"&&(i.callback=function(){pl(t,r),typeof c!="function"&&(ar===null?ar=new Set([this]):ar.add(this));var j=r.stack;this.componentDidCatch(r.value,{componentStack:j!==null?j:""})}),i}function Ud(t,r,i){var c=t.pingCache;if(c===null){c=t.pingCache=new by;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=Fy.bind(null,t,r,i),r.then(t,t))}function Wd(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 Hd(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,rr(i,r,1))),i.lanes|=1),t):(t.flags|=65536,t.lanes=d,t)}var ky=I.ReactCurrentOwner,qt=!1;function Dt(t,r,i,c){r.child=t===null?ud(r,null,i,c):Xr(r,t.child,i,c)}function Vd(t,r,i,c,d){i=i.render;var m=r.ref;return es(r,d),c=il(t,r,i,c,m,d),i=ol(),t!==null&&!qt?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~d,Fn(t,r,d)):(ct&&i&&Wo(r),r.flags|=1,Dt(t,r,c,d),r.child)}function Gd(t,r,i,c,d){if(t===null){var m=i.type;return typeof m=="function"&&!Fl(m)&&m.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(r.tag=15,r.type=m,Kd(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=cr(m,c),t.ref=r.ref,t.return=r,r.child=t}function Kd(t,r,i,c,d){if(t!==null){var m=t.memoizedProps;if(Is(m,c)&&t.ref===r.ref)if(qt=!1,r.pendingProps=c=m,(t.lanes&d)!==0)(t.flags&131072)!==0&&(qt=!0);else return r.lanes=t.lanes,Fn(t,r,d)}return gl(t,r,i,c,d)}function qd(t,r,i){var c=r.pendingProps,d=c.children,m=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},at(ss,rn),rn|=i;else{if((i&1073741824)===0)return t=m!==null?m.baseLanes|i:i,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:t,cachePool:null,transitions:null},r.updateQueue=null,at(ss,rn),rn|=t,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=m!==null?m.baseLanes:i,at(ss,rn),rn|=c}else m!==null?(c=m.baseLanes|i,r.memoizedState=null):c=i,at(ss,rn),rn|=c;return Dt(t,r,d,i),r.child}function Yd(t,r){var i=r.ref;(t===null&&i!==null||t!==null&&t.ref!==i)&&(r.flags|=512,r.flags|=2097152)}function gl(t,r,i,c,d){var m=Kt(i)?gr:$t.current;return m=qr(r,m),es(r,d),i=il(t,r,i,c,m,d),c=ol(),t!==null&&!qt?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~d,Fn(t,r,d)):(ct&&c&&Wo(r),r.flags|=1,Dt(t,r,i,d),r.child)}function Jd(t,r,i,c,d){if(Kt(i)){var m=!0;Ua(r)}else m=!1;if(es(r,d),r.stateNode===null)ii(t,r),Md(r,i,c),hl(r,i,c,d),c=!0;else if(t===null){var j=r.stateNode,C=r.memoizedProps;j.props=C;var R=j.context,V=i.contextType;typeof V=="object"&&V!==null?V=ln(V):(V=Kt(i)?gr:$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)&&Od(r,j,c,V),nr=!1;var re=r.memoizedState;j.state=re,Qa(r,c,j,d),R=r.memoizedState,C!==c||re!==R||Gt.current||nr?(typeof ae=="function"&&(fl(r,i,ae,c),R=r.memoizedState),(C=nr||Fd(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,fd(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=ln(R):(R=Kt(i)?gr:$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)&&Od(r,j,c,R),nr=!1,re=r.memoizedState,j.state=re,Qa(r,c,j,d);var ke=r.memoizedState;C!==ce||re!==ke||Gt.current||nr?(typeof je=="function"&&(fl(r,i,je,c),ke=r.memoizedState),(V=nr||Fd(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 yl(t,r,i,c,m,d)}function yl(t,r,i,c,d,m){Yd(t,r);var j=(r.flags&128)!==0;if(!c&&!j)return d&&td(r,i,!1),Fn(t,r,m);c=r.stateNode,ky.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)):Dt(t,r,C,m),r.memoizedState=c.state,d&&td(r,i,!0),r.child}function Qd(t){var r=t.stateNode;r.pendingContext?Zu(t,r.pendingContext,r.pendingContext!==r.context):r.context&&Zu(t,r.context,!1),el(t,r.containerInfo)}function Xd(t,r,i,c,d){return Qr(),Ko(d),r.flags|=256,Dt(t,r,i,c),r.child}var vl={dehydrated:null,treeContext:null,retryLane:0};function xl(t){return{baseLanes:t,cachePool:null,transitions:null}}function Zd(t,r,i){var c=r.pendingProps,d=ht.current,m=!1,j=(r.flags&128)!==0,C;if((C=j)||(C=t!==null&&t.memoizedState===null?!1:(d&2)!==0),C?(m=!0,r.flags&=-129):(t===null||t.memoizedState!==null)&&(d|=1),at(ht,d&1),t===null)return Go(r),t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((r.mode&1)===0?r.lanes=1:t.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(j=c.children,t=c.fallback,m?(c=r.mode,m=r.child,j={mode:"hidden",children:j},(c&1)===0&&m!==null?(m.childLanes=0,m.pendingProps=j):m=vi(j,c,0,null),t=Cr(t,c,i,null),m.return=r,t.return=r,m.sibling=t,r.child=m,r.child.memoizedState=xl(i),r.memoizedState=vl,t):wl(r,j));if(d=t.memoizedState,d!==null&&(C=d.dehydrated,C!==null))return Ny(t,r,j,c,C,d,i);if(m){m=c.fallback,j=r.mode,d=t.child,C=d.sibling;var R={mode:"hidden",children:c.children};return(j&1)===0&&r.child!==d?(c=r.child,c.childLanes=0,c.pendingProps=R,r.deletions=null):(c=cr(d,R),c.subtreeFlags=d.subtreeFlags&14680064),C!==null?m=cr(C,m):(m=Cr(m,j,i,null),m.flags|=2),m.return=r,c.return=r,c.sibling=m,r.child=c,c=m,m=r.child,j=t.child.memoizedState,j=j===null?xl(i):{baseLanes:j.baseLanes|i,cachePool:null,transitions:j.transitions},m.memoizedState=j,m.childLanes=t.childLanes&~i,r.memoizedState=vl,c}return m=t.child,t=m.sibling,c=cr(m,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=i),c.return=r,c.sibling=null,t!==null&&(i=r.deletions,i===null?(r.deletions=[t],r.flags|=16):i.push(t)),r.child=c,r.memoizedState=null,c}function wl(t,r){return r=vi({mode:"visible",children:r},t.mode,0,null),r.return=t,t.child=r}function ai(t,r,i,c){return c!==null&&Ko(c),Xr(r,t.child,null,i),t=wl(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function Ny(t,r,i,c,d,m,j){if(i)return r.flags&256?(r.flags&=-257,c=ml(Error(a(422))),ai(t,r,j,c)):r.memoizedState!==null?(r.child=t.child,r.flags|=128,null):(m=c.fallback,d=r.mode,c=vi({mode:"visible",children:c.children},d,0,null),m=Cr(m,d,j,null),m.flags|=2,c.return=r,m.return=r,c.sibling=m,r.child=c,(r.mode&1)!==0&&Xr(r,t.child,null,j),r.child.memoizedState=xl(j),r.memoizedState=vl,m);if((r.mode&1)===0)return ai(t,r,j,null);if(d.data==="$!"){if(c=d.nextSibling&&d.nextSibling.dataset,c)var C=c.dgst;return c=C,m=Error(a(419)),c=ml(m,c,void 0),ai(t,r,j,c)}if(C=(j&t.childLanes)!==0,qt||C){if(c=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 zl(),c=ml(Error(a(421))),ai(t,r,j,c)}return d.data==="$?"?(r.flags|=128,r.child=t.child,r=My.bind(null,t),d._reactRetry=r,null):(t=m.treeContext,nn=Xn(d.nextSibling),tn=r,ct=!0,pn=null,t!==null&&(an[on++]=$n,an[on++]=_n,an[on++]=yr,$n=t.id,_n=t.overflow,yr=r),r=wl(r,c.children),r.flags|=4096,r)}function ef(t,r,i){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),Qo(t.return,r,i)}function jl(t,r,i,c,d){var m=t.memoizedState;m===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:i,tailMode:d}:(m.isBackwards=r,m.rendering=null,m.renderingStartTime=0,m.last=c,m.tail=i,m.tailMode=d)}function tf(t,r,i){var c=r.pendingProps,d=c.revealOrder,m=c.tail;if(Dt(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&&ef(t,i,r);else if(t.tag===19)ef(t,i,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(at(ht,c),(r.mode&1)===0)r.memoizedState=null;else switch(d){case"forwards":for(i=r.child,d=null;i!==null;)t=i.alternate,t!==null&&Xa(t)===null&&(d=i),i=i.sibling;i=d,i===null?(d=r.child,r.child=null):(d=i.sibling,i.sibling=null),jl(r,!1,d,i,m);break;case"backwards":for(i=null,d=r.child,r.child=null;d!==null;){if(t=d.alternate,t!==null&&Xa(t)===null){r.child=d;break}t=d.sibling,d.sibling=i,i=d,d=t}jl(r,!0,i,null,m);break;case"together":jl(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ii(t,r){(r.mode&1)===0&&t!==null&&(t.alternate=null,r.alternate=null,r.flags|=2)}function Fn(t,r,i){if(t!==null&&(r.dependencies=t.dependencies),Sr|=r.lanes,(i&r.childLanes)===0)return null;if(t!==null&&r.child!==t.child)throw Error(a(153));if(r.child!==null){for(t=r.child,i=cr(t,t.pendingProps),r.child=i,i.return=r;t.sibling!==null;)t=t.sibling,i=i.sibling=cr(t,t.pendingProps),i.return=r;i.sibling=null}return r.child}function Cy(t,r,i){switch(r.tag){case 3:Qd(r),Qr();break;case 5:pd(r);break;case 1:Kt(r.type)&&Ua(r);break;case 4:el(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,d=r.memoizedProps.value;at(qa,c._currentValue),c._currentValue=d;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(at(ht,ht.current&1),r.flags|=128,null):(i&r.child.childLanes)!==0?Zd(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 tf(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,qd(t,r,i)}return Fn(t,r,i)}var nf,Sl,rf,sf;nf=function(t,r){for(var i=r.child;i!==null;){if(i.tag===5||i.tag===6)t.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},Sl=function(){},rf=function(t,r,i,c){var d=t.memoizedProps;if(d!==c){t=r.stateNode,wr(En.current);var m=null;switch(i){case"input":d=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)}},sf=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 Ey(t,r,i){var c=r.pendingProps;switch(Ho(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lt(r),null;case 1:return Kt(r.type)&&Da(),Lt(r),null;case 3:return c=r.stateNode,ts(),lt(Gt),lt($t),rl(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Ga(r)?r.flags|=4:t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,pn!==null&&($l(pn),pn=null))),Sl(t,r),Lt(r),null;case 5:tl(r);var d=wr(Bs.current);if(i=r.type,t!==null&&r.stateNode!=null)rf(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=wr(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,nf(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"?Vt(t,R):m==="dangerouslySetInnerHTML"?(R=R?R.__html:void 0,R!=null&&J(t,R)):m==="children"?typeof R=="string"?(i!=="textarea"||R!=="")&&ye(t,R):typeof R=="number"&&ye(t,""+R):m!=="suppressContentEditableWarning"&&m!=="suppressHydrationWarning"&&m!=="autoFocus"&&(l.hasOwnProperty(m)?R!=null&&m==="onScroll"&&ot("scroll",t):R!=null&&P(t,m,R,j))}switch(i){case"input":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)sf(t,r,t.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(a(166));if(i=wr(Bs.current),wr(En.current),Ga(r)){if(c=r.stateNode,i=r.memoizedProps,c[Cn]=r,(m=c.nodeValue!==i)&&(t=tn,t!==null))switch(t.tag){case 3:Ma(c.nodeValue,i,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Ma(c.nodeValue,i,(t.mode&1)!==0)}m&&(r.flags|=4)}else c=(i.nodeType===9?i:i.ownerDocument).createTextNode(c),c[Cn]=r,r.stateNode=c}return Lt(r),null;case 13:if(lt(ht),c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(ct&&nn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)od(),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&&($l(pn),pn=null),m=!0;if(!m)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=i,r):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(t===null||(ht.current&1)!==0?kt===0&&(kt=3):zl())),r.updateQueue!==null&&(r.flags|=4),Lt(r),null);case 4:return ts(),Sl(t,r),t===null&&$s(r.stateNode.containerInfo),Lt(r),null;case 10:return Jo(r.type._context),Lt(r),null;case 17:return Kt(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 Ll(),c=r.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(rn&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 Ty(t,r){switch(Ho(r),r.tag){case 1:return Kt(r.type)&&Da(),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return ts(),lt(Gt),lt($t),rl(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 5:return tl(r),null;case 13:if(lt(ht),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(a(340));Qr()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return lt(ht),null;case 4:return ts(),null;case 10:return Jo(r.type._context),null;case 22:case 23:return Ll(),null;case 24:return null;default:return null}}var oi=!1,zt=!1,Ay=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 bl(t,r,i){try{i()}catch(c){pt(t,r,c)}}var af=!1;function Iy(t,r){if(Lo=Ea,t=Fu(),Eo(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var c=i.getSelection&&i.getSelection();if(c&&c.rangeCount!==0){i=c.anchorNode;var d=c.anchorOffset,m=c.focusNode;c=c.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var j=0,C=-1,R=-1,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(zo={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=af,af=!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&&bl(r,i,m)}d=d.next}while(d!==c)}}function li(t,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var c=i.create;i.destroy=c()}i=i.next}while(i!==r)}}function kl(t){var r=t.ref;if(r!==null){var i=t.stateNode;switch(t.tag){case 5:t=i;break;default:t=i}typeof r=="function"?r(t):r.current=t}}function of(t){var r=t.alternate;r!==null&&(t.alternate=null,of(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[Bo],delete r[fy],delete r[hy])),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 lf(t){return t.tag===5||t.tag===3||t.tag===4}function cf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||lf(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Nl(t,r,i){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?i.nodeType===8?i.parentNode.insertBefore(t,r):i.insertBefore(t,r):(i.nodeType===8?(r=i.parentNode,r.insertBefore(t,i)):(r=i,r.appendChild(t)),i=i._reactRootContainer,i!=null||r.onclick!==null||(r.onclick=Oa));else if(c!==4&&(t=t.child,t!==null))for(Nl(t,r,i),t=t.sibling;t!==null;)Nl(t,r,i),t=t.sibling}function Cl(t,r,i){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?i.insertBefore(t,r):i.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(Cl(t,r,i),t=t.sibling;t!==null;)Cl(t,r,i),t=t.sibling}var It=null,yn=!1;function sr(t,r,i){for(i=i.child;i!==null;)uf(t,r,i),i=i.sibling}function uf(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,sr(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?Oo(t.parentNode,i):t.nodeType===1&&Oo(t,i),ks(t)):Oo(It,i.stateNode));break;case 4:c=It,d=yn,It=i.stateNode.containerInfo,yn=!0,sr(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)&&bl(i,r,j),d=d.next}while(d!==c)}sr(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)}sr(t,r,i);break;case 21:sr(t,r,i);break;case 22:i.mode&1?(zt=(c=zt)||i.memoizedState!==null,sr(t,r,i),zt=c):sr(t,r,i);break;default:sr(t,r,i)}}function df(t){var r=t.updateQueue;if(r!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new Ay),r.forEach(function(c){var d=Oy.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));uf(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;)ff(r,t),r=r.sibling}function ff(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"?Vt(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||(Al=vt())),c&4&&df(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){pf(ce);continue}}je!==null?(je.return=re,Se=je):pf(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&&df(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(lf(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=cf(t);Cl(t,m,d);break;case 3:case 4:var j=c.stateNode.containerInfo,C=cf(t);Nl(t,C,j);break;default:throw Error(a(161))}}catch(R){pt(t,t.return,R)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function Ry(t,r,i){Se=t,hf(t)}function hf(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?gf(d):R!==null?(R.return=j,Se=R):gf(d);for(;m!==null;)Se=m,hf(m),m=m.sibling;Se=d,oi=C,zt=V}mf(t)}else(d.subtreeFlags&8772)!==0&&m!==null?(m.return=d,Se=m):mf(t)}}function mf(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&&md(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}md(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&&kl(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 pf(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 gf(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{kl(r)}catch(R){pt(r,m,R)}break;case 5:var j=r.return;try{kl(r)}catch(R){pt(r,j,R)}}}catch(R){pt(r,r.return,R)}if(r===t){Se=null;break}var C=r.sibling;if(C!==null){C.return=r.return,Se=C;break}Se=r.return}}var Py=Math.ceil,ci=I.ReactCurrentDispatcher,El=I.ReactCurrentOwner,un=I.ReactCurrentBatchConfig,Je=0,Tt=null,jt=null,Rt=0,rn=0,ss=Zn(0),kt=0,Ks=null,Sr=0,ui=0,Tl=0,qs=null,Yt=null,Al=0,as=1/0,Mn=null,di=!1,Il=null,ar=null,fi=!1,ir=null,hi=0,Ys=0,Rl=null,mi=-1,pi=0;function Ut(){return(Je&6)!==0?vt():mi!==-1?mi:mi=vt()}function or(t){return(t.mode&1)===0?1:(Je&2)!==0&&Rt!==0?Rt&-Rt:py.transition!==null?(pi===0&&(pi=lu()),pi):(t=tt,t!==0||(t=window.event,t=t===void 0?16:yu(t.type)),t)}function xn(t,r,i,c){if(50<Ys)throw Ys=0,Rl=null,Error(a(185));xs(t,i,c),((Je&2)===0||t!==Tt)&&(t===Tt&&((Je&2)===0&&(ui|=i),kt===4&&lr(t,Rt)),Jt(t,c),i===1&&Je===0&&(r.mode&1)===0&&(as=vt()+500,Wa&&tr()))}function Jt(t,r){var i=t.callbackNode;pg(t,r);var c=ka(t,t===Tt?Rt:0);if(c===0)i!==null&&au(i),t.callbackNode=null,t.callbackPriority=0;else if(r=c&-c,t.callbackPriority!==r){if(i!=null&&au(i),r===1)t.tag===0?my(vf.bind(null,t)):nd(vf.bind(null,t)),uy(function(){(Je&6)===0&&tr()}),i=null;else{switch(cu(c)){case 1:i=co;break;case 4:i=iu;break;case 16:i=wa;break;case 536870912:i=ou;break;default:i=wa}i=Cf(i,yf.bind(null,t))}t.callbackPriority=r,t.callbackNode=i}}function yf(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=wf();(Tt!==t||Rt!==r)&&(Mn=null,as=vt()+500,kr(t,r));do try{Ly();break}catch(C){xf(t,C)}while(!0);Yo(),ci.current=m,Je=d,jt!==null?r=0:(Tt=null,Rt=0,r=kt)}if(r!==0){if(r===2&&(d=uo(t),d!==0&&(c=d,r=Pl(t,d))),r===1)throw i=Ks,kr(t,0),lr(t,c),Jt(t,vt()),i;if(r===6)lr(t,c);else{if(d=t.current.alternate,(c&30)===0&&!$y(d)&&(r=gi(t,c),r===2&&(m=uo(t),m!==0&&(c=m,r=Pl(t,m))),r===1))throw i=Ks,kr(t,0),lr(t,c),Jt(t,vt()),i;switch(t.finishedWork=d,t.finishedLanes=c,r){case 0:case 1:throw Error(a(345));case 2:Nr(t,Yt,Mn);break;case 3:if(lr(t,c),(c&130023424)===c&&(r=Al+500-vt(),10<r)){if(ka(t,0)!==0)break;if(d=t.suspendedLanes,(d&c)!==c){Ut(),t.pingedLanes|=t.suspendedLanes&d;break}t.timeoutHandle=Mo(Nr.bind(null,t,Yt,Mn),r);break}Nr(t,Yt,Mn);break;case 4:if(lr(t,c),(c&4194240)===c)break;for(r=t.eventTimes,d=-1;0<c;){var j=31-hn(c);m=1<<j,j=r[j],j>d&&(d=j),c&=~m}if(c=d,c=vt()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*Py(c/1960))-c,10<c){t.timeoutHandle=Mo(Nr.bind(null,t,Yt,Mn),c);break}Nr(t,Yt,Mn);break;case 5:Nr(t,Yt,Mn);break;default:throw Error(a(329))}}}return Jt(t,vt()),t.callbackNode===i?yf.bind(null,t):null}function Pl(t,r){var i=qs;return t.current.memoizedState.isDehydrated&&(kr(t,r).flags|=256),t=gi(t,r),t!==2&&(r=Yt,Yt=i,r!==null&&$l(r)),t}function $l(t){Yt===null?Yt=t:Yt.push.apply(Yt,t)}function $y(t){for(var r=t;;){if(r.flags&16384){var i=r.updateQueue;if(i!==null&&(i=i.stores,i!==null))for(var c=0;c<i.length;c++){var d=i[c],m=d.getSnapshot;d=d.value;try{if(!mn(m(),d))return!1}catch{return!1}}}if(i=r.child,r.subtreeFlags&16384&&i!==null)i.return=r,r=i;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function lr(t,r){for(r&=~Tl,r&=~ui,t.suspendedLanes|=r,t.pingedLanes&=~r,t=t.expirationTimes;0<r;){var i=31-hn(r),c=1<<i;t[i]=-1,r&=~c}}function vf(t){if((Je&6)!==0)throw Error(a(327));is();var r=ka(t,0);if((r&1)===0)return Jt(t,vt()),null;var i=gi(t,r);if(t.tag!==0&&i===2){var c=uo(t);c!==0&&(r=c,i=Pl(t,c))}if(i===1)throw i=Ks,kr(t,0),lr(t,r),Jt(t,vt()),i;if(i===6)throw Error(a(345));return t.finishedWork=t.current.alternate,t.finishedLanes=r,Nr(t,Yt,Mn),Jt(t,vt()),null}function _l(t,r){var i=Je;Je|=1;try{return t(r)}finally{Je=i,Je===0&&(as=vt()+500,Wa&&tr())}}function br(t){ir!==null&&ir.tag===0&&(Je&6)===0&&is();var r=Je;Je|=1;var i=un.transition,c=tt;try{if(un.transition=null,tt=1,t)return t()}finally{tt=c,un.transition=i,Je=r,(Je&6)===0&&tr()}}function Ll(){rn=ss.current,lt(ss)}function kr(t,r){t.finishedWork=null,t.finishedLanes=0;var i=t.timeoutHandle;if(i!==-1&&(t.timeoutHandle=-1,cy(i)),jt!==null)for(i=jt.return;i!==null;){var c=i;switch(Ho(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Da();break;case 3:ts(),lt(Gt),lt($t),rl();break;case 5:tl(c);break;case 4:ts();break;case 13:lt(ht);break;case 19:lt(ht);break;case 10:Jo(c.type._context);break;case 22:case 23:Ll()}i=i.return}if(Tt=t,jt=t=cr(t.current,null),Rt=rn=r,kt=0,Ks=null,Tl=ui=Sr=0,Yt=qs=null,xr!==null){for(r=0;r<xr.length;r++)if(i=xr[r],c=i.interleaved,c!==null){i.interleaved=null;var d=c.next,m=i.pending;if(m!==null){var j=m.next;m.next=d,c.next=j}i.pending=c}xr=null}return t}function xf(t,r){do{var i=jt;try{if(Yo(),Za.current=ri,ei){for(var c=mt.memoizedState;c!==null;){var d=c.queue;d!==null&&(d.pending=null),c=c.next}ei=!1}if(jr=0,Et=bt=mt=null,Ds=!1,Us=0,El.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=Wd(j);if(je!==null){je.flags&=-257,Hd(je,j,C,m,r),je.mode&1&&Ud(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){Ud(m,V,r),zl();break e}R=Error(a(426))}}else if(ct&&C.mode&1){var xt=Wd(j);if(xt!==null){(xt.flags&65536)===0&&(xt.flags|=256),Hd(xt,j,C,m,r),Ko(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=Bd(m,R,r);hd(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"&&(ar===null||!ar.has(D)))){m.flags|=65536,r&=-r,m.lanes|=r;var he=Dd(m,C,r);hd(m,he);break e}}m=m.return}while(m!==null)}Sf(i)}catch(Te){r=Te,jt===i&&i!==null&&(jt=i=i.return);continue}break}while(!0)}function wf(){var t=ci.current;return ci.current=ri,t===null?ri:t}function zl(){(kt===0||kt===3||kt===2)&&(kt=4),Tt===null||(Sr&268435455)===0&&(ui&268435455)===0||lr(Tt,Rt)}function gi(t,r){var i=Je;Je|=2;var c=wf();(Tt!==t||Rt!==r)&&(Mn=null,kr(t,r));do try{_y();break}catch(d){xf(t,d)}while(!0);if(Yo(),Je=i,ci.current=c,jt!==null)throw Error(a(261));return Tt=null,Rt=0,kt}function _y(){for(;jt!==null;)jf(jt)}function Ly(){for(;jt!==null&&!ig();)jf(jt)}function jf(t){var r=Nf(t.alternate,t,rn);t.memoizedProps=t.pendingProps,r===null?Sf(t):jt=r,El.current=null}function Sf(t){var r=t;do{var i=r.alternate;if(t=r.return,(r.flags&32768)===0){if(i=Ey(i,r,rn),i!==null){jt=i;return}}else{if(i=Ty(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 Nr(t,r,i){var c=tt,d=un.transition;try{un.transition=null,tt=1,zy(t,r,i,c)}finally{un.transition=d,tt=c}return null}function zy(t,r,i,c){do is();while(ir!==null);if((Je&6)!==0)throw Error(a(327));i=t.finishedWork;var d=t.finishedLanes;if(i===null)return null;if(t.finishedWork=null,t.finishedLanes=0,i===t.current)throw Error(a(177));t.callbackNode=null,t.callbackPriority=0;var m=i.lanes|i.childLanes;if(gg(t,m),t===Tt&&(jt=Tt=null,Rt=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||fi||(fi=!0,Cf(wa,function(){return is(),null})),m=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||m){m=un.transition,un.transition=null;var j=tt;tt=1;var C=Je;Je|=4,El.current=null,Iy(t,i),ff(i,t),ny(zo),Ea=!!Lo,zo=Lo=null,t.current=i,Ry(i),og(),Je=C,tt=j,un.transition=m}else t.current=i;if(fi&&(fi=!1,ir=t,hi=d),m=t.pendingLanes,m===0&&(ar=null),ug(i.stateNode),Jt(t,vt()),r!==null)for(c=t.onRecoverableError,i=0;i<r.length;i++)d=r[i],c(d.value,{componentStack:d.stack,digest:d.digest});if(di)throw di=!1,t=Il,Il=null,t;return(hi&1)!==0&&t.tag!==0&&is(),m=t.pendingLanes,(m&1)!==0?t===Rl?Ys++:(Ys=0,Rl=t):Ys=0,tr(),null}function is(){if(ir!==null){var t=cu(hi),r=un.transition,i=tt;try{if(un.transition=null,tt=16>t?16:t,ir===null)var c=!1;else{if(t=ir,ir=null,hi=0,(Je&6)!==0)throw Error(a(331));var d=Je;for(Je|=4,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(of(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,tr(),Nn&&typeof Nn.onPostCommitFiberRoot=="function")try{Nn.onPostCommitFiberRoot(ja,t)}catch{}c=!0}return c}finally{tt=i,un.transition=r}}return!1}function bf(t,r,i){r=ns(i,r),r=Bd(t,r,1),t=rr(t,r,1),r=Ut(),t!==null&&(xs(t,1,r),Jt(t,r))}function pt(t,r,i){if(t.tag===3)bf(t,t,i);else for(;r!==null;){if(r.tag===3){bf(r,t,i);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(ar===null||!ar.has(c))){t=ns(i,t),t=Dd(r,t,1),r=rr(r,t,1),t=Ut(),r!==null&&(xs(r,1,t),Jt(r,t));break}}r=r.return}}function Fy(t,r,i){var c=t.pingCache;c!==null&&c.delete(r),r=Ut(),t.pingedLanes|=t.suspendedLanes&i,Tt===t&&(Rt&i)===i&&(kt===4||kt===3&&(Rt&130023424)===Rt&&500>vt()-Al?kr(t,0):Tl|=i),Jt(t,r)}function kf(t,r){r===0&&((t.mode&1)===0?r=1:(r=ba,ba<<=1,(ba&130023424)===0&&(ba=4194304)));var i=Ut();t=Ln(t,r),t!==null&&(xs(t,r,i),Jt(t,i))}function My(t){var r=t.memoizedState,i=0;r!==null&&(i=r.retryLane),kf(t,i)}function Oy(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),kf(t,i)}var Nf;Nf=function(t,r,i){if(t!==null)if(t.memoizedProps!==r.pendingProps||Gt.current)qt=!0;else{if((t.lanes&i)===0&&(r.flags&128)===0)return qt=!1,Cy(t,r,i);qt=(t.flags&131072)!==0}else qt=!1,ct&&(r.flags&1048576)!==0&&rd(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=il(null,r,c,t,d,i);var m=ol();return r.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Kt(c)?(m=!0,Ua(r)):m=!1,r.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Zo(r),d.updater=si,r.stateNode=d,d._reactInternals=r,hl(r,c,t,i),r=yl(null,r,c,!0,m,i)):(r.tag=0,ct&&m&&Wo(r),Dt(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=Dy(c),t=gn(c,t),d){case 0:r=gl(null,r,c,t,i);break e;case 1:r=Jd(null,r,c,t,i);break e;case 11:r=Vd(null,r,c,t,i);break e;case 14:r=Gd(null,r,c,gn(c.type,t),i);break e}throw Error(a(306,c,""))}return r;case 0:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),gl(t,r,c,d,i);case 1:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),Jd(t,r,c,d,i);case 3:e:{if(Qd(r),t===null)throw Error(a(387));c=r.pendingProps,m=r.memoizedState,d=m.element,fd(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=Xd(t,r,c,i,d);break e}else if(c!==d){d=ns(Error(a(424)),r),r=Xd(t,r,c,i,d);break e}else for(nn=Xn(r.stateNode.containerInfo.firstChild),tn=r,ct=!0,pn=null,i=ud(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}Dt(t,r,c,i)}r=r.child}return r;case 5:return pd(r),t===null&&Go(r),c=r.type,d=r.pendingProps,m=t!==null?t.memoizedProps:null,j=d.children,Fo(c,d)?j=null:m!==null&&Fo(c,m)&&(r.flags|=32),Yd(t,r),Dt(t,r,j,i),r.child;case 6:return t===null&&Go(r),null;case 13:return Zd(t,r,i);case 4:return el(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=Xr(r,null,c,i):Dt(t,r,c,i),r.child;case 11:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),Vd(t,r,c,d,i);case 7:return Dt(t,r,r.pendingProps,i),r.child;case 8:return Dt(t,r,r.pendingProps.children,i),r.child;case 12:return Dt(t,r,r.pendingProps.children,i),r.child;case 10:e:{if(c=r.type._context,d=r.pendingProps,m=r.memoizedProps,j=d.value,at(qa,c._currentValue),c._currentValue=j,m!==null)if(mn(m.value,j)){if(m.children===d.children&&!Gt.current){r=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),Qo(m.return,i,r),C.lanes|=i;break}R=R.next}}else if(m.tag===10)j=m.type===r.type?null:m.child;else if(m.tag===18){if(j=m.return,j===null)throw Error(a(341));j.lanes|=i,C=j.alternate,C!==null&&(C.lanes|=i),Qo(j,i,r),j=m.sibling}else j=m.child;if(j!==null)j.return=m;else for(j=m;j!==null;){if(j===r){j=null;break}if(m=j.sibling,m!==null){m.return=j.return,j=m;break}j=j.return}m=j}Dt(t,r,d.children,i),r=r.child}return r;case 9:return d=r.type,c=r.pendingProps.children,es(r,i),d=ln(d),c=c(d),r.flags|=1,Dt(t,r,c,i),r.child;case 14:return c=r.type,d=gn(c,r.pendingProps),d=gn(c.type,d),Gd(t,r,c,d,i);case 15:return Kd(t,r,r.type,r.pendingProps,i);case 17:return c=r.type,d=r.pendingProps,d=r.elementType===c?d:gn(c,d),ii(t,r),r.tag=1,Kt(c)?(t=!0,Ua(r)):t=!1,es(r,i),Md(r,c,d),hl(r,c,d,i),yl(null,r,c,!0,t,i);case 19:return tf(t,r,i);case 22:return qd(t,r,i)}throw Error(a(156,r.tag))};function Cf(t,r){return su(t,r)}function By(t,r,i,c){this.tag=t,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dn(t,r,i,c){return new By(t,r,i,c)}function Fl(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Dy(t){if(typeof t=="function")return Fl(t)?1:0;if(t!=null){if(t=t.$$typeof,t===O)return 11;if(t===ee)return 14}return 2}function cr(t,r){var i=t.alternate;return i===null?(i=dn(t.tag,r,t.key,t.mode),i.elementType=t.elementType,i.type=t.type,i.stateNode=t.stateNode,i.alternate=t,t.alternate=i):(i.pendingProps=r,i.type=t.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=t.flags&14680064,i.childLanes=t.childLanes,i.lanes=t.lanes,i.child=t.child,i.memoizedProps=t.memoizedProps,i.memoizedState=t.memoizedState,i.updateQueue=t.updateQueue,r=t.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},i.sibling=t.sibling,i.index=t.index,i.ref=t.ref,i}function yi(t,r,i,c,d,m){var j=2;if(c=t,typeof t=="function")Fl(t)&&(j=1);else if(typeof t=="string")j=5;else e:switch(t){case q:return Cr(i.children,d,m,r);case z:j=8,d|=8;break;case U:return t=dn(12,i,r,d|2),t.elementType=U,t.lanes=m,t;case ne:return t=dn(13,i,r,d),t.elementType=ne,t.lanes=m,t;case fe:return t=dn(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=dn(j,i,r,d),r.elementType=t,r.type=c,r.lanes=m,r}function Cr(t,r,i,c){return t=dn(7,t,c,r),t.lanes=i,t}function vi(t,r,i,c){return t=dn(22,t,c,r),t.elementType=Ne,t.lanes=i,t.stateNode={isHidden:!1},t}function Ml(t,r,i){return t=dn(6,t,null,r),t.lanes=i,t}function Ol(t,r,i){return r=dn(4,t.children!==null?t.children:[],t.key,r),r.lanes=i,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}function Uy(t,r,i,c,d){this.tag=r,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=fo(0),this.expirationTimes=fo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fo(0),this.identifierPrefix=c,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function Bl(t,r,i,c,d,m,j,C,R){return t=new Uy(t,r,i,C,R),r===1?(r=1,m===!0&&(r|=8)):r=0,m=dn(3,null,null,r),t.current=m,m.stateNode=t,m.memoizedState={element:c,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zo(m),t}function Wy(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 Ef(t){if(!t)return er;t=t._reactInternals;e:{if(bn(t)!==t||t.tag!==1)throw Error(a(170));var r=t;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Kt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(a(171))}if(t.tag===1){var i=t.type;if(Kt(i))return ed(t,i,r)}return r}function Tf(t,r,i,c,d,m,j,C,R){return t=Bl(i,c,!0,t,d,m,j,C,R),t.context=Ef(null),i=t.current,c=Ut(),d=or(i),m=zn(c,d),m.callback=r??null,rr(i,m,d),t.current.lanes=d,xs(t,d,c),Jt(t,c),t}function xi(t,r,i,c){var d=r.current,m=Ut(),j=or(d);return i=Ef(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=rr(d,r,j),t!==null&&(xn(t,d,j,m),Ja(t,d,j)),j}function wi(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function Af(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var i=t.retryLane;t.retryLane=i!==0&&i<r?i:r}}function Dl(t,r){Af(t,r),(t=t.alternate)&&Af(t,r)}function Hy(){return null}var If=typeof reportError=="function"?reportError:function(t){console.error(t)};function Ul(t){this._internalRoot=t}ji.prototype.render=Ul.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(a(409));xi(t,r,null,null)},ji.prototype.unmount=Ul.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;br(function(){xi(null,t,null,null)}),r[Rn]=null}};function ji(t){this._internalRoot=t}ji.prototype.unstable_scheduleHydration=function(t){if(t){var r=fu();t={blockedOn:null,target:t,priority:r};for(var i=0;i<Yn.length&&r!==0&&r<Yn[i].priority;i++);Yn.splice(i,0,t),i===0&&pu(t)}};function Wl(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Si(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Rf(){}function Vy(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=Tf(r,c,t,0,null,!1,!1,"",Rf);return t._reactRootContainer=j,t[Rn]=j.current,$s(t.nodeType===8?t.parentNode:t),br(),j}for(;d=t.lastChild;)t.removeChild(d);if(typeof c=="function"){var C=c;c=function(){var V=wi(R);C.call(V)}}var R=Bl(t,0,!1,null,null,!1,!1,"",Rf);return t._reactRootContainer=R,t[Rn]=R.current,$s(t.nodeType===8?t.parentNode:t),br(function(){xi(r,R,i,c)}),R}function bi(t,r,i,c,d){var m=i._reactRootContainer;if(m){var j=m;if(typeof d=="function"){var C=d;d=function(){var R=wi(j);C.call(R)}}xi(r,j,t,d)}else j=Vy(i,r,t,d,c);return wi(j)}uu=function(t){switch(t.tag){case 3:var r=t.stateNode;if(r.current.memoizedState.isDehydrated){var i=vs(r.pendingLanes);i!==0&&(ho(r,i|1),Jt(r,vt()),(Je&6)===0&&(as=vt()+500,tr()))}break;case 13:br(function(){var c=Ln(t,1);if(c!==null){var d=Ut();xn(c,t,1,d)}}),Dl(t,1)}},mo=function(t){if(t.tag===13){var r=Ln(t,134217728);if(r!==null){var i=Ut();xn(r,t,134217728,i)}Dl(t,134217728)}},du=function(t){if(t.tag===13){var r=or(t),i=Ln(t,r);if(i!==null){var c=Ut();xn(i,t,r,c)}Dl(t,r)}},fu=function(){return tt},hu=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=br;var Gy={usingClientEntryPoint:!1,Events:[zs,Gr,Ba,St,Zt,_l]},Js={findFiberByHostInstance:pr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Ky={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||Hy,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(Ky),Nn=ki}catch{}}return Qt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Gy,Qt.createPortal=function(t,r){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Wl(r))throw Error(a(200));return Wy(t,r,null,i)},Qt.createRoot=function(t,r){if(!Wl(t))throw Error(a(299));var i=!1,c="",d=If;return r!=null&&(r.unstable_strictMode===!0&&(i=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(d=r.onRecoverableError)),r=Bl(t,1,!1,null,null,i,!1,c,d),t[Rn]=r.current,$s(t.nodeType===8?t.parentNode:t),new Ul(r)},Qt.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(a(188)):(t=Object.keys(t).join(","),Error(a(268,t)));return t=kn(r),t=t===null?null:t.stateNode,t},Qt.flushSync=function(t){return br(t)},Qt.hydrate=function(t,r,i){if(!Si(r))throw Error(a(200));return bi(null,t,r,!0,i)},Qt.hydrateRoot=function(t,r,i){if(!Wl(t))throw Error(a(405));var c=i!=null&&i.hydratedSources||null,d=!1,m="",j=If;if(i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(j=i.onRecoverableError)),r=Tf(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)},Qt.render=function(t,r,i){if(!Si(r))throw Error(a(200));return bi(null,t,r,!1,i)},Qt.unmountComponentAtNode=function(t){if(!Si(t))throw Error(a(40));return t._reactRootContainer?(br(function(){bi(null,null,t,!1,function(){t._reactRootContainer=null,t[Rn]=null})}),!0):!1},Qt.unstable_batchedUpdates=_l,Qt.unstable_renderSubtreeIntoContainer=function(t,r,i,c){if(!Si(i))throw Error(a(200));if(t==null||t._reactInternals===void 0)throw Error(a(38));return bi(t,r,i,!1,c)},Qt.version="18.3.1-next-f1338f8080-20240426",Qt}var Of;function rm(){if(Of)return Gl.exports;Of=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(s){console.error(s)}}return e(),Gl.exports=nv(),Gl.exports}var Bf;function rv(){if(Bf)return Ni;Bf=1;var e=rm();return Ni.createRoot=e.createRoot,Ni.hydrateRoot=e.hydrateRoot,Ni}var sv=rv();/**
|
|
41
|
-
* react-router v7.18.4
|
|
42
|
-
*
|
|
43
|
-
* Copyright (c) Remix Software Inc.
|
|
44
|
-
*
|
|
45
|
-
* This source code is licensed under the MIT license found in the
|
|
46
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
47
|
-
*
|
|
48
|
-
* @license MIT
|
|
49
|
-
*/var Ec=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,sm=/^[\\/]{2}/;function av(e,s){return s+e.replace(/\\/g,"/")}var Df="popstate";function Uf(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function iv(e={}){function s(o,l){var v;let u=(v=l.state)==null?void 0:v.masked,{pathname:f,search:p,hash:g}=u||o.location;return uc("",{pathname:f,search:p,hash:g},l.state&&l.state.usr||null,l.state&&l.state.key||"default",u?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function a(o,l){return typeof l=="string"?l:Rr(l)}return lv(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 ov(){return Math.random().toString(36).substring(2,10)}function Wf(e,s){return{usr:e.state,key:e.key,idx:s,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function uc(e,s,a=null,o,l){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof s=="string"?hs(s):s,state:a,key:s&&s.key||o||ov(),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 lv(e,s,a,o={}){let{window:l=document.defaultView,v5Compat:u=!1}=o,f=l.history,p="POP",g=null,v=y();v==null&&(v=0,f.replaceState({...f.state,idx:v},""));function y(){return(f.state||{idx:null}).idx}function w(){p="POP";let N=y(),E=N==null?null:N-v;v=N,g&&g({action:p,location:S.location,delta:E})}function x(N,E){p="PUSH";let T=Uf(N)?N:uc(S.location,N,E);v=y()+1;let P=Wf(T,v),I=S.createHref(T.mask||T);try{f.pushState(P,"",I)}catch(B){if(B instanceof DOMException&&B.name==="DataCloneError")throw B;l.location.assign(I)}u&&g&&g({action:p,location:S.location,delta:1})}function b(N,E){p="REPLACE";let T=Uf(N)?N:uc(S.location,N,E);v=y();let P=Wf(T,v),I=S.createHref(T.mask||T);f.replaceState(P,"",I),u&&g&&g({action:p,location:S.location,delta:0})}function k(N){return cv(l,N)}let S={get action(){return p},get location(){return e(l,f)},listen(N){if(g)throw new Error("A history only accepts one active listener");return l.addEventListener(Df,w),g=N,()=>{l.removeEventListener(Df,w),g=null}},createHref(N){return s(l,N)},createURL:k,encodeLocation(N){let E=k(N);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:x,replace:b,go(N){return f.go(N)}};return S}function cv(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&&sm.test(l)&&(l=o+l),new URL(l,o)}function am(e,s,a="/"){return uv(e,s,a,!1)}function uv(e,s,a,o,l){let u=typeof s=="string"?hs(s):s,f=Un(u.pathname||"/",a);if(f==null)return null;let p=dv(e),g=null,v=Sv(f);for(let y=0;g==null&&y<p.length;++y)g=jv(p[y],v,o);return g}function dv(e){let s=im(e);return fv(s),s}function im(e,s=[],a=[],o="",l=!1){let u=(f,p,g=l,v)=>{let y={relativePath:v===void 0?f.path||"":v,caseSensitive:f.caseSensitive===!0,childrenIndex:p,route:f};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&g)return;ut(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let w=wn([o,y.relativePath]),x=a.concat(y);f.children&&f.children.length>0&&(ut(f.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${w}".`),im(f.children,s,x,w,g)),!(f.path==null&&!f.index)&&s.push({path:w,score:xv(w,f.index),routesMeta:x.map((b,k)=>{let[S,N]=cm(b.relativePath,b.caseSensitive,k===x.length-1);return{...b,matcher:S,compiledParams:N}})})};return e.forEach((f,p)=>{var g;if(f.path===""||!((g=f.path)!=null&&g.includes("?")))u(f,p);else for(let v of om(f.path))u(f,p,!0,v)}),s}function om(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=om(o.join("/")),p=[];return p.push(...f.map(g=>g===""?u:[u,g].join("/"))),l&&p.push(...f),p.map(g=>e.startsWith("/")&&g===""?"/":g)}function fv(e){e.sort((s,a)=>s.score!==a.score?a.score-s.score:wv(s.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var hv=/^:[\w-]+$/,mv=3,pv=2,gv=1,yv=10,vv=-2,Hf=e=>e==="*";function xv(e,s){let a=e.split("/"),o=a.length;return a.some(Hf)&&(o+=vv),s&&(o+=pv),a.filter(l=>!Hf(l)).reduce((l,u)=>l+(hv.test(u)?mv:u===""?gv:yv),o)}function wv(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 jv(e,s,a=!1){let{routesMeta:o}=e,l={},u="/",f=[];for(let p=0;p<o.length;++p){let g=o[p],v=p===o.length-1,y=u==="/"?s:s.slice(u.length)||"/",w={path:g.relativePath,caseSensitive:g.caseSensitive,end:v},x=g.matcher&&g.compiledParams?lm(w,y,g.matcher,g.compiledParams):Fi(w,y),b=g.route;if(!x&&v&&a&&!o[o.length-1].route.index&&(x=Fi({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},y)),!x)return null;Object.assign(l,x.params),f.push({params:l,pathname:wn([u,x.pathname]),pathnameBase:Nv(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]=cm(e.path,e.caseSensitive,e.end);return lm(e,s,a,o)}function lm(e,s,a,o){let l=s.match(a);if(!l)return null;let u=l[0],f=ds(u,1),p=l.slice(1);return{params:o.reduce((v,{paramName:y,isOptional:w},x)=>{if(y==="*"){let k=p[x]||"";f=ds(u.slice(0,u.length-k.length),1)}const b=p[x];return w&&!b?v[y]=void 0:v[y]=(b||"").replace(/%2F/g,"/"),v},{}),pathname:u,pathnameBase:f,pattern:e}}function cm(e,s=!1,a=!0){fn(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(f,p,g,v,y)=>{if(o.push({paramName:p,isOptional:g!=null}),g){let w=y.charAt(v+f.length);return w&&w!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,s?void 0:"i"),o]}function Sv(e){try{return e.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return fn(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),e}}function Un(e,s){if(s==="/")return e;if(!e.toLowerCase().startsWith(s.toLowerCase()))return null;let a=s.endsWith("/")?s.length-1:s.length,o=e.charAt(a);return o&&o!=="/"?null:e.slice(a)||"/"}function bv(e,s="/"){let{pathname:a,search:o="",hash:l=""}=typeof e=="string"?hs(e):e,u;return a?(a=um(a),a.startsWith("/")||a.startsWith("\\")?u=Vf(a.substring(1),"/"):u=Vf(a,s)):u=s,{pathname:u,search:Cv(o),hash:Ev(l)}}function Vf(e,s){let a=ds(s).split("/");return e.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function Yl(e,s,a,o){return`Cannot include a '${e}' character in a manually specified \`to.${s}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function kv(e){return e.filter((s,a)=>a===0||s.route.path&&s.route.path.length>0)}function Tc(e){let s=kv(e);return s.map((a,o)=>o===s.length-1?a.pathname:a.pathnameBase)}function Xi(e,s,a,o=!1){let l;typeof e=="string"?l=hs(e):(l={...e},ut(!l.pathname||!l.pathname.includes("?"),Yl("?","pathname","search",l)),ut(!l.pathname||!l.pathname.includes("#"),Yl("#","pathname","hash",l)),ut(!l.search||!l.search.includes("#"),Yl("#","search","hash",l)));let u=e===""||l.pathname==="",f=u?"/":l.pathname,p;if(f==null)p=a;else{let w=s.length-1;if(!o&&f.startsWith("..")){let x=f.split("/");for(;x[0]==="..";)x.shift(),w-=1;l.pathname=x.join("/")}p=w>=0?s[w]:"/"}let g=bv(l,p),v=f&&f!=="/"&&f.endsWith("/"),y=(u||f===".")&&a.endsWith("/");return!g.pathname.endsWith("/")&&(v||y)&&(g.pathname+="/"),g}var um=e=>e.replace(/[\\/]{2,}/g,"/"),wn=e=>um(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 Nv=e=>ds(e).replace(/^\/*/,"/"),Cv=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ev=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Tv=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 Av(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Iv(e){let s=e.map(a=>a.route.path).filter(Boolean);return wn(s)||"/"}var dm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fm(e,s){let a=e;if(typeof a!="string"||!Ec.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,l=!1;if(dm)try{let u=new URL(window.location.href),f=sm.test(a)?new URL(av(a,u.protocol)):new URL(a),p=Un(f.pathname,s);f.origin===u.origin&&p!=null?a=p+f.search+f.hash:l=!0}catch{fn(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:l,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Gf=new URL("http://localhost");function Ac(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),Gf)}catch{return Gf}}function Jl(e,s){return e.origin===s.origin&&(e.origin!=="null"||e.protocol===s.protocol&&e.host===s.host)}function Rv(e,s){if(e.startsWith("//"))return!0;let a=s.protocol.toLowerCase();return e.toLowerCase().startsWith(a)?s.host===""||e.slice(a.length).startsWith("//"):!1}function Ic(e,s,a,o){let l=null;try{l=e==null?null:new URL(e,a)}catch{}let u=new URL(s,a),f=l!=null&&!Jl(l,a),p=!Jl(u,a);if(o==="reject"){if(f||p)throw new Error("External navigation is not allowed")}else if(p&&(l==null||!Rv(e,l)||!Jl(l,u)))throw new Error("External navigation is not allowed")}var hm=["POST","PUT","PATCH","DELETE"];new Set(hm);var Pv=["GET",...hm];new Set(Pv);var $v=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function _v(e){try{return $v.includes(new URL(e).protocol)}catch{return!1}}var ms=h.createContext(null);ms.displayName="DataRouter";var Zi=h.createContext(null);Zi.displayName="DataRouterState";var mm=h.createContext(!1);function Lv(){return h.useContext(mm)}var pm=h.createContext({isTransitioning:!1});pm.displayName="ViewTransition";var zv=h.createContext(new Map);zv.displayName="Fetchers";var Fv=h.createContext(null);Fv.displayName="Await";var sn=h.createContext(null);sn.displayName="Navigation";var fa=h.createContext(null);fa.displayName="Location";var jn=h.createContext({outlet:null,matches:[],isDataRoute:!1});jn.displayName="Route";var Rc=h.createContext(null);Rc.displayName="RouteError";var gm="REACT_ROUTER_ERROR",Mv="REDIRECT",Ov="ROUTE_ERROR_RESPONSE";function Bv(e){if(e.startsWith(`${gm}:${Mv}:{`))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 Dv(e){if(e.startsWith(`${gm}:${Ov}:{`))try{let s=JSON.parse(e.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new Tv(s.status,s.statusText,s.data)}catch{}}function Uv(e,{relative:s}={}){ut(ps(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:o}=h.useContext(sn),{hash:l,pathname:u,search:f}=ha(e,{relative:s}),p=u;return a!=="/"&&(p=u==="/"?a:wn([a,u])),o.createHref({pathname:p,search:f,hash:l})}function ps(){return h.useContext(fa)!=null}function Xt(){return ut(ps(),"useLocation() may be used only in the context of a <Router> component."),h.useContext(fa).location}var ym="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function vm(e){h.useContext(sn).static||h.useLayoutEffect(e)}function Sn(){let{isDataRoute:e}=h.useContext(jn);return e?rx():Wv()}function Wv(){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(sn),{matches:o}=h.useContext(jn),{pathname:l}=Xt(),u=JSON.stringify(Tc(o)),f=h.useRef(!1);return vm(()=>{f.current=!0}),h.useCallback((g,v={})=>{if(fn(f.current,ym),!f.current)return;if(typeof g=="number"){a.go(g);return}let y=Xi(g,JSON.parse(u),l,v.relative==="path");e==null&&s!=="/"&&(y.pathname=y.pathname==="/"?s:wn([s,y.pathname])),Ic(typeof g=="string"?g:Rr(g),a.createHref(y),Ac(a),"reject"),(v.replace?a.replace:a.push)(y,v.state,v)},[s,a,u,l,e])}var Hv=h.createContext(null);function Vv(e){let s=h.useContext(jn).outlet;return h.useMemo(()=>s&&h.createElement(Hv.Provider,{value:e},s),[s,e])}function ha(e,{relative:s}={}){let{matches:a}=h.useContext(jn),{pathname:o}=Xt(),l=JSON.stringify(Tc(a));return h.useMemo(()=>Xi(e,JSON.parse(l),o,s==="path"),[e,l,o,s])}function Gv(e,s){return xm(e,s)}function xm(e,s,a){var N;ut(ps(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=h.useContext(sn),{matches:l}=h.useContext(jn),u=l[l.length-1],f=u?u.params:{},p=u?u.pathname:"/",g=u?u.pathnameBase:"/",v=u&&u.route;{let E=v&&v.path||"";jm(p,!v||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${p}" (under <Route path="${E}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
50
|
-
|
|
51
|
-
Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let y=Xt(),w;if(s){let E=typeof s=="string"?hs(s):s;ut(g==="/"||((N=E.pathname)==null?void 0:N.startsWith(g)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${g}" but pathname "${E.pathname}" was given in the \`location\` prop.`),w=E}else w=y;let x=w.pathname||"/",b=x;if(g!=="/"){let E=g.replace(/^\//,"").split("/");b="/"+x.replace(/^\//,"").split("/").slice(E.length).join("/")}let k=a&&a.state.matches.length?a.state.matches.map(E=>Object.assign(E,{route:a.manifest[E.route.id]||E.route})):am(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=Qv(k&&k.map(E=>Object.assign({},E,{params:Object.assign({},f,E.params),pathname:wn([g,o.encodeLocation?o.encodeLocation(E.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?g:wn([g,o.encodeLocation?o.encodeLocation(E.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),l,a);return s&&S?h.createElement(fa.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...w},navigationType:"POP"}},S):S}function Kv(){let e=nx(),s=Av(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 qv=h.createElement(Kv,null),wm=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=Dv(e.digest);a&&(e=a)}let s=e!==void 0?h.createElement(jn.Provider,{value:this.props.routeContext},h.createElement(Rc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?h.createElement(Yv,{error:e},s):s}};wm.contextType=mm;var Ql=new WeakMap;function Yv({children:e,error:s}){let{basename:a,navigator:o}=h.useContext(sn);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let l=Bv(s.digest);if(l){let u=Ql.get(s);if(u)throw u;let f=fm(l.location,a),p=f.absoluteURL||f.to;if(Ic(l.location,p,Ac(o),"allow-explicit"),_v(p))throw new Error("Invalid redirect location");if(dm&&!Ql.get(s))if(f.isExternal||l.reloadDocument)window.location.href=p;else{const g=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(f.to,{replace:l.replace}));throw Ql.set(s,g),g}return h.createElement("meta",{httpEquiv:"refresh",content:`0;url=${p}`})}}return e}function Jv({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 Qv(e,s=[],a){let o=a==null?void 0:a.state;if(e==null){if(!o)return null;if(o.errors)e=o.matches;else if(s.length===0&&!o.initialized&&o.matches.length>0)e=o.matches;else return null}let l=e,u=o==null?void 0:o.errors;if(u!=null){let y=l.findIndex(w=>w.route.id&&(u==null?void 0:u[w.route.id])!==void 0);ut(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),l=l.slice(0,Math.min(l.length,y+1))}let f=!1,p=-1;if(a&&o){f=o.renderFallback;for(let y=0;y<l.length;y++){let w=l[y];if((w.route.HydrateFallback||w.route.hydrateFallbackElement)&&(p=y),w.route.id){let{loaderData:x,errors:b}=o,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),p>=0?l=l.slice(0,p+1):l=[l[0]];break}}}}let g=a==null?void 0:a.onError,v=o&&g?(y,w)=>{var x,b;g(y,{location:o.location,params:((b=(x=o.matches)==null?void 0:x[0])==null?void 0:b.params)??{},pattern:Iv(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||qv,f&&(p<0&&x===0?(jm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,N=null):p===x&&(k=!0,N=w.route.hydrateFallbackElement||null)));let E=s.concat(l.slice(0,x+1)),T=()=>{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(Jv,{match:w,routeContext:{outlet:y,matches:E,isDataRoute:o!=null},children:P})};return o&&(w.route.ErrorBoundary||w.route.errorElement||x===0)?h.createElement(wm,{location:o.location,revalidation:o.revalidation,component:S,error:b,children:T(),routeContext:{outlet:null,matches:E,isDataRoute:!0},onError:v}):T()},null)}function Pc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Xv(e){let s=h.useContext(ms);return ut(s,Pc(e)),s}function Zv(e){let s=h.useContext(Zi);return ut(s,Pc(e)),s}function ex(e){let s=h.useContext(jn);return ut(s,Pc(e)),s}function $c(e){let s=ex(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 tx(){return $c("useRouteId")}function nx(){var o;let e=h.useContext(Rc),s=Zv("useRouteError"),a=$c("useRouteError");return e!==void 0?e:(o=s.errors)==null?void 0:o[a]}function rx(){let{router:e}=Xv("useNavigate"),s=$c("useNavigate"),a=h.useRef(!1);return vm(()=>{a.current=!0}),h.useCallback(async(l,u={})=>{fn(a.current,ym),a.current&&(typeof l=="number"?await e.navigate(l):await e.navigate(l,{fromRouteId:s,...u}))},[e,s])}var Kf={};function jm(e,s,a){!s&&!Kf[e]&&(Kf[e]=!0,fn(!1,a))}h.memo(sx);function sx({routes:e,manifest:s,future:a,state:o,isStatic:l,onError:u}){return xm(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(sn);fn(!l,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:f}=h.useContext(jn),{pathname:p}=Xt(),g=Sn(),v=Xi(e,Tc(f),p,o==="path");Ic(typeof e=="string"?e:Rr(e),u.createHref(v),Ac(u),"reject");let y=JSON.stringify(v);return h.useEffect(()=>{g(JSON.parse(y),{replace:s,state:a,relative:o})},[g,y,o,s,a]),null}function ax(e){return Vv(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 ix({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 p=e.replace(/^\/*/,"/"),g=h.useMemo(()=>({basename:p,navigator:l,static:u,useTransitions:f,future:{}}),[p,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=Un(v,p);return N==null?null:{location:{pathname:N,search:y,hash:w,state:x,key:b,mask:k},navigationType:o}},[p,v,y,w,x,b,o,k]);return fn(S!=null,`<Router basename="${p}"> is not able to match the URL "${v}${y}${w}" because it does not start with the basename, so the <Router> won't render anything.`),S==null?null:h.createElement(sn.Provider,{value:g},h.createElement(fa.Provider,{children:s,value:S}))}function ox({children:e,location:s}){return Gv(dc(e),s)}function dc(e,s=[]){let a=[];return h.Children.forEach(e,(o,l)=>{if(!h.isValidElement(o))return;let u=[...s,l];if(o.type===h.Fragment){a.push.apply(a,dc(o.props.children,u));return}ut(o.type===it,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ut(!o.props.index||!o.props.children,"An index route cannot have child routes.");let f={id:o.props.id||u.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(f.children=dc(o.props.children,u)),a.push(f)}),a}var _i="get",Li="application/x-www-form-urlencoded";function eo(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function lx(e){return eo(e)&&e.tagName.toLowerCase()==="button"}function cx(e){return eo(e)&&e.tagName.toLowerCase()==="form"}function ux(e){return eo(e)&&e.tagName.toLowerCase()==="input"}function dx(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function fx(e,s){return e.button===0&&(!s||s==="_self")&&!dx(e)}function fc(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((s,a)=>{let o=e[a];return s.concat(Array.isArray(o)?o.map(l=>[a,l]):[[a,o]])},[]))}function hx(e,s){let a=fc(e);return s&&s.forEach((o,l)=>{a.has(l)||s.getAll(l).forEach(u=>{a.append(l,u)})}),a}var Ci=null;function mx(){if(Ci===null)try{new FormData(document.createElement("form"),0),Ci=!1}catch{Ci=!0}return Ci}var px=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Xl(e){return e!=null&&!px.has(e)?(fn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Li}"`),null):e}function gx(e,s){let a,o,l,u,f;if(cx(e)){let p=e.getAttribute("action");o=p?Un(p,s):null,a=e.getAttribute("method")||_i,l=Xl(e.getAttribute("enctype"))||Li,u=new FormData(e)}else if(lx(e)||ux(e)&&(e.type==="submit"||e.type==="image")){let p=e.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=e.getAttribute("formaction")||p.getAttribute("action");if(o=g?Un(g,s):null,a=e.getAttribute("formmethod")||p.getAttribute("method")||_i,l=Xl(e.getAttribute("formenctype"))||Xl(p.getAttribute("enctype"))||Li,u=new FormData(p,e),!mx()){let{name:v,type:y,value:w}=e;if(y==="image"){let x=v?`${v}.`:"";u.append(`${x}x`,"0"),u.append(`${x}y`,"0")}else v&&u.append(v,w)}}else{if(eo(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a=_i,o=null,l=Li,f=e}return u&&l==="text/plain"&&(f=u,u=void 0),{action:o,method:a.toLowerCase(),encType:l,formData:u,body:f}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function _c(e,s){if(e===!1||e===null||typeof e>"u")throw new Error(s)}function Sm(e,s,a,o){let l=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a?l.pathname.endsWith("/")?l.pathname=`${l.pathname}_.${o}`:l.pathname=`${l.pathname}.${o}`:l.pathname==="/"?l.pathname=`_root.${o}`:s&&Un(l.pathname,s)==="/"?l.pathname=`${ds(s)}/_root.${o}`:l.pathname=`${ds(l.pathname)}.${o}`,l}async function yx(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 vx(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 xx(e,s,a){let o=await Promise.all(e.map(async l=>{let u=s.routes[l.route.id];if(u){let f=await yx(u,a);return f.links?f.links():[]}return[]}));return bx(o.flat(1).filter(vx).filter(l=>l.rel==="stylesheet"||l.rel==="preload").map(l=>l.rel==="stylesheet"?{...l,rel:"prefetch",as:"style"}:{...l,rel:"prefetch"}))}function qf(e,s,a,o,l,u){let f=(g,v)=>a[v]?g.route.id!==a[v].route.id:!0,p=(g,v)=>{var y;return a[v].pathname!==g.pathname||((y=a[v].route.path)==null?void 0:y.endsWith("*"))&&a[v].params["*"]!==g.params["*"]};return u==="assets"?s.filter((g,v)=>f(g,v)||p(g,v)):u==="data"?s.filter((g,v)=>{var w;let y=o.routes[g.route.id];if(!y||!y.hasLoader)return!1;if(f(g,v)||p(g,v))return!0;if(g.route.shouldRevalidate){let x=g.route.shouldRevalidate({currentUrl:new URL(l.pathname+l.search+l.hash,window.origin),currentParams:((w=a[0])==null?void 0:w.params)||{},nextUrl:new URL(e,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function wx(e,s,{includeHydrateFallback:a}={}){return jx(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 jx(e){return[...new Set(e)]}function Sx(e){let s={},a=Object.keys(e).sort();for(let o of a)s[o]=e[o];return s}function bx(e,s){let a=new Set;return new Set(s),e.reduce((o,l)=>{let u=JSON.stringify(Sx(l));return a.has(u)||(a.add(u),o.push({key:u,link:l})),o},[])}function Lc(){let e=h.useContext(ms);return _c(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function kx(){let e=h.useContext(Zi);return _c(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var zc=h.createContext(void 0);zc.displayName="FrameworkContext";function to(){let e=h.useContext(zc);return _c(e,"You must render this element inside a <HydratedRouter> element"),e}function Nx(e,s){let a=h.useContext(zc),[o,l]=h.useState(!1),[u,f]=h.useState(!1),{onFocus:p,onBlur:g,onMouseEnter:v,onMouseLeave:y,onTouchStart:w}=s,x=h.useRef(null);h.useEffect(()=>{if(e==="render"&&f(!0),e==="viewport"){let S=E=>{E.forEach(T=>{f(T.isIntersecting)})},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(p,b),onBlur:Zs(g,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 Cx({page:e,...s}){let a=Lv(),{nonce:o}=to(),{router:l}=Lc(),u=h.useMemo(()=>am(l.routes,e,l.basename),[l.routes,e,l.basename]);return u?(s.nonce==null&&o&&(s={...s,nonce:o}),a?h.createElement(Tx,{page:e,matches:u,...s}):h.createElement(Ax,{page:e,matches:u,...s})):null}function Ex(e){let{manifest:s,routeModules:a}=to(),[o,l]=h.useState([]);return h.useEffect(()=>{let u=!1;return xx(e,s,a).then(f=>{u||l(f)}),()=>{u=!0}},[e,s,a]),o}function Tx({page:e,matches:s,...a}){let o=Xt(),{future:l}=to(),{basename:u}=Lc(),f=h.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let p=Sm(e,u,l.v8_trailingSlashAwareDataRequests,"rsc"),g=!1,v=[];for(let y of s)typeof y.route.shouldRevalidate=="function"?g=!0:v.push(y.route.id);return g&&v.length>0&&p.searchParams.set("_routes",v.join(",")),[p.pathname+p.search]},[u,l.v8_trailingSlashAwareDataRequests,e,o,s]);return h.createElement(h.Fragment,null,f.map(p=>h.createElement("link",{key:p,rel:"prefetch",as:"fetch",href:p,...a})))}function Ax({page:e,matches:s,...a}){let o=Xt(),{future:l,manifest:u,routeModules:f}=to(),{basename:p}=Lc(),{loaderData:g,matches:v}=kx(),y=h.useMemo(()=>qf(e,s,v,u,o,"data"),[e,s,v,u,o]),w=h.useMemo(()=>qf(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(T=>{var I;let P=u.routes[T.route.id];!P||!P.hasLoader||(!y.some(B=>B.route.id===T.route.id)&&T.route.id in g&&((I=f[T.route.id])!=null&&I.shouldRevalidate)||P.hasClientLoader?N=!0:S.add(T.route.id))}),S.size===0)return[];let E=Sm(e,p,l.v8_trailingSlashAwareDataRequests,"data");return N&&S.size>0&&E.searchParams.set("_routes",s.filter(T=>S.has(T.route.id)).map(T=>T.route.id).join(",")),[E.pathname+E.search]},[p,l.v8_trailingSlashAwareDataRequests,g,o,u,y,s,e,f]),b=h.useMemo(()=>wx(w,u),[w,u]),k=Ex(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 Ix(...e){return s=>{e.forEach(a=>{typeof a=="function"?a(s):a!=null&&(a.current=s)})}}var Rx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Rx&&(window.__reactRouterVersion="7.18.4")}catch{}function Px({basename:e,children:s,useTransitions:a,window:o}){let l=h.useRef();l.current==null&&(l.current=iv({window:o,v5Compat:!0}));let u=l.current,[f,p]=h.useState({action:u.action,location:u.location}),g=h.useCallback(v=>{a===!1?p(v):h.startTransition(()=>p(v))},[a]);return h.useLayoutEffect(()=>u.listen(g),[u,g]),h.createElement(ix,{basename:e,children:s,location:f.location,navigationType:f.action,navigator:u,useTransitions:a})}var gt=h.forwardRef(function({onClick:s,discover:a="render",prefetch:o="none",relative:l,reloadDocument:u,replace:f,mask:p,state:g,target:v,to:y,preventScrollReset:w,viewTransition:x,defaultShouldRevalidate:b,...k},S){let{basename:N,navigator:E,useTransitions:T}=h.useContext(sn),P=typeof y=="string"&&Ec.test(y),I=fm(y,N);y=I.to;let B=Uv(y,{relative:l}),M=Xt(),q=null;if(p){let ee=Xi(p,[],M.mask?M.mask.pathname:"/",!0);N!=="/"&&(ee.pathname=ee.pathname==="/"?N:wn([N,ee.pathname])),q=E.createHref(ee)}let[z,U,Z]=Nx(o,k),G=Lx(y,{replace:f,mask:p,state:g,target:v,preventScrollReset:w,relative:l,viewTransition:x,defaultShouldRevalidate:b,useTransitions:T});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:Ix(S,U),target:v,"data-discover":!P&&a==="render"?"true":void 0});return z&&!P?h.createElement(h.Fragment,null,fe,h.createElement(Cx,{page:B})):fe});gt.displayName="Link";var Fc=h.forwardRef(function({"aria-current":s="page",caseSensitive:a=!1,className:o="",end:l=!1,style:u,to:f,viewTransition:p,children:g,...v},y){let w=ha(f,{relative:v.relative}),x=Xt(),b=h.useContext(Zi),{navigator:k,basename:S}=h.useContext(sn),N=b!=null&&Bx(w)&&p===!0,E=k.encodeLocation?k.encodeLocation(w).pathname:w.pathname,T=x.pathname,P=b&&b.navigation&&b.navigation.location?b.navigation.location.pathname:null;a||(T=T.toLowerCase(),P=P?P.toLowerCase():null,E=E.toLowerCase()),P&&S&&(P=Un(P,S)||P);const I=E!=="/"&&E.endsWith("/")?E.length-1:E.length;let B=T===E||!l&&T.startsWith(E)&&T.charAt(I)==="/",M=P!=null&&(P===E||!l&&P.startsWith(E)&&P.charAt(E.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:p},typeof g=="function"?g(q):g)});Fc.displayName="NavLink";var $x=h.forwardRef(({discover:e="render",fetcherKey:s,navigate:a,reloadDocument:o,replace:l,state:u,method:f=_i,action:p,onSubmit:g,relative:v,preventScrollReset:y,viewTransition:w,defaultShouldRevalidate:x,...b},k)=>{let{useTransitions:S}=h.useContext(sn),N=Mx(),E=Ox(p,{relative:v}),T=f.toLowerCase()==="get"?"get":"post",P=typeof p=="string"&&Ec.test(p),I=B=>{if(g&&g(B),B.defaultPrevented)return;B.preventDefault();let 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:T,action:E,onSubmit:o?g:I,...b,"data-discover":!P&&e==="render"?"true":void 0})});$x.displayName="Form";function _x(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bm(e){let s=h.useContext(ms);return ut(s,_x(e)),s}function Lx(e,{target:s,replace:a,mask:o,state:l,preventScrollReset:u,relative:f,viewTransition:p,defaultShouldRevalidate:g,useTransitions:v}={}){let y=Sn(),w=Xt(),x=ha(e,{relative:f});return h.useCallback(b=>{if(fx(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:p,defaultShouldRevalidate:g});v?h.startTransition(()=>S()):S()}},[w,y,x,a,o,l,s,e,u,f,p,g,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(fc(e)),a=h.useRef(!1),o=Xt(),l=h.useMemo(()=>hx(o.search,a.current?null:s.current),[o.search]),u=Sn(),f=h.useCallback((p,g)=>{const v=fc(typeof p=="function"?p(new URLSearchParams(l)):p);a.current=!0,u("?"+v,g)},[u,l]);return[l,f]}var zx=0,Fx=()=>`__${String(++zx)}__`;function Mx(){let{router:e}=bm("useSubmit"),{basename:s}=h.useContext(sn),a=tx(),o=e.fetch,l=e.navigate;return h.useCallback(async(u,f={})=>{let{action:p,method:g,encType:v,formData:y,body:w}=gx(u,s);if(f.navigate===!1){let x=f.fetcherKey||Fx();await o(x,a,f.action||p,{defaultShouldRevalidate:f.defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:w,formMethod:f.method||g,formEncType:f.encType||v,flushSync:f.flushSync})}else await l(f.action||p,{defaultShouldRevalidate:f.defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:w,formMethod:f.method||g,formEncType:f.encType||v,replace:f.replace,state:f.state,fromRouteId:a,flushSync:f.flushSync,viewTransition:f.viewTransition})},[o,l,s,a])}function Ox(e,{relative:s}={}){let{basename:a}=h.useContext(sn),o=h.useContext(jn);ut(o,"useFormAction must be used inside a RouteContext");let[l]=o.matches.slice(-1),u={...ha(e||".",{relative:s})},f=Xt();if(e==null){u.search=f.search;let p=new URLSearchParams(u.search),g=p.getAll("index");if(g.some(y=>y==="")){p.delete("index"),g.filter(w=>w).forEach(w=>p.append("index",w));let y=p.toString();u.search=y?`?${y}`:""}}return(!e||e===".")&&l.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(u.pathname=u.pathname==="/"?a:wn([a,u.pathname])),Rr(u)}function Bx(e,{relative:s}={}){let a=h.useContext(pm);ut(a!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=bm("useViewTransitionState"),l=ha(e,{relative:s});if(!a.isTransitioning)return!1;let u=Un(a.currentLocation.pathname,o)||a.currentLocation.pathname,f=Un(a.nextLocation.pathname,o)||a.nextLocation.pathname;return Fi(l.pathname,f)!=null||Fi(l.pathname,u)!=null}var Dx=rm();const Ir="owner";function Ux(e){const s=e||Ir;return s===Ir?[Ir]:[s,Ir]}function Wx(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 Hx(e,s){const a=s||Ir,o=(e==null?void 0:e.pendingDomains)??[];return o.includes(a)?a:o.includes(Ir)?Ir:a}class km extends Error{constructor(a){super("different_account");Qs(this,"summary");this.name="DifferentAccountError",this.summary=a}}function Nm(e){return e.grantors??e.approvers}function Vx(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 Gx(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 Kx{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 km(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,p;return{authorization_id:u.authorization_id,profile_id:u.profileId,path:u.path,title:u.title??null,sp_status:u.status??null,frame:u.bounds??u.frame??{},required_domains:u.requiredDomains??[],attested_domains:u.attestedDomains??[],missing_domains:(u.requiredDomains??[]).filter(g=>!(u.attestedDomains??[]).includes(g)),deferred_commitment_domains:u.deferredCommitmentDomains??[],approvers_frozen:u.approversFrozen??[],above_cap:u.aboveCap??!1,created_at:u.createdAt?new Date(u.createdAt*1e3).toISOString():"",earliest_expiry:(f=u.attestations)!=null&&f.length?new Date(Math.min(...u.attestations.map(g=>g.expiresAt))*1e3).toISOString():null,remaining_seconds:(p=u.attestations)!=null&&p.length?Math.max(0,Math.min(...u.attestations.map(g=>g.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(s){const a=new URLSearchParams;s!=null&&s.since&&a.set("since",String(s.since)),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString()?`?${a.toString()}`:"",l=await this.fetch(`/denials${o}`);if(!l.ok)throw new Error(`Failed to fetch denials: ${l.status}`);return l.json()}async getMyReceipts(s){const a=new URLSearchParams;s!=null&&s.date&&a.set("date",s.date),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),l=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);return(await l.json()).tickets??[]}async fetchEvidenceBundle(){var l;const s=await this.fetch("/api/evidence-export"),a=await s.json();if(!s.ok)throw new Error(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?Gx(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(Ux(s).map(l=>this.getProposals(l,a)));return Wx(o)}async resolveProposal(s,a,o,l){const{noteEncrypted:u,contentHash:f,shownHash:p,note:g,...v}=l??{},y=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/resolve`,{method:"POST",body:JSON.stringify({action:a,domain:o,...v,...u?{note_encrypted:u}:g?{note:g}:{},...f?{content_hash:f}:{},...p?{shown_hash:p}:{}})});if(!y.ok){const w=await y.json().catch(()=>({error:"Failed"}));throw new Error(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:p,note:g,...v}=a??{};u={...v,...p?{note_encrypted:p}:g?{note:g}:{}}}o&&(u.content_hash=o),l&&(u.shown_hash=l);const f=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/reject`,{method:"POST",body:JSON.stringify(u)});if(!f.ok){const p=await f.json().catch(()=>({error:"Failed"}));throw new Error(Ge(p,`rejectProposal failed: ${f.status}`))}return f.json()}async getProposalsCreatedByMe(){const s=await this.fetch("/api/proposals?creator=me");if(s.status===400)return null;if(!s.ok)throw new Error(`Failed to fetch my proposals: ${s.status}`);return(await s.json()).proposals??[]}async withdrawProposal(s,a,o,l){const{noteEncrypted:u,note:f}=a??{},p={...u?{note_encrypted:u}:f?{note:f}:{}};o&&(p.content_hash=o),l&&(p.shown_hash=l);const g=await this.fetch(`/api/proposals/${encodeURIComponent(s)}/withdraw`,{method:"POST",body:JSON.stringify(p)});if(!g.ok){const v=await g.json().catch(()=>({error:"Failed"}));throw new Error(Ge(v,`withdrawProposal failed: ${g.status}`))}return g.json()}async getProposalPreview(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/preview`);if(!a.ok)throw new Error(`Failed to fetch preview: ${a.status}`);return a.json()}async getProposalRequestContext(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/request-context`);if(!a.ok)throw new Error(`Failed to fetch request context: ${a.status}`);return a.json()}async saveShownSnapshot(s,a){const o=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/shown-snapshot`,{method:"POST",body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to store the shown snapshot: ${o.status}`);return o.json()}async getShownSnapshot(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/shown-snapshot`);if(!a.ok)throw new Error(`Failed to fetch the shown snapshot: ${a.status}`);return a.json()}async getProposalOutcome(s){const a=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/outcome`);if(!a.ok)throw new Error(`Failed to fetch outcome: ${a.status}`);return a.json()}async getProposalAttachmentPreview(s,a){const o=await this.fetch(`/proposal-status/${encodeURIComponent(s)}/attachment-preview/${encodeURIComponent(a)}`);if(!o.ok)throw new Error(`Failed to fetch attachment preview: ${o.status}`);return o.json()}async getReceiptAttachmentPreview(s,a){const o=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(s)}/attachment-preview/${encodeURIComponent(a)}`);if(!o.ok)throw new Error(`Failed to fetch attachment preview: ${o.status}`);return o.json()}async getAttestationIntent(s){const a=await this.fetch(`/api/authorizations/${encodeURIComponent(s)}/intent`);return a.status===404||a.status===403||!a.ok?null:a.json()}async decryptIntent(s){const a=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const l=await a.json().catch(()=>({error:"Decryption failed"}));throw new Error(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 p,g;const u=l.owner??{userId:""};return{authorization_id:l.authorization_id??l.authorizationId,profile_id:l.profileId??l.profile_id,path:l.path??"",title:l.title??null,sp_status:l.status??l.sp_status??null,frame:l.bounds??l.frame??{},required_domains:l.requiredDomains??l.required_domains??[],attested_domains:l.attestedDomains??l.attested_domains??[],missing_domains:(l.requiredDomains??l.required_domains??[]).filter(v=>!(l.attestedDomains??l.attested_domains??[]).includes(v)),deferred_commitment_domains:l.deferredCommitmentDomains??l.deferred_commitment_domains??[],approvers_frozen:l.approversFrozen??l.approvers_frozen??[],above_cap:l.aboveCap??l.above_cap??!1,created_at:l.createdAt?new Date(l.createdAt*1e3).toISOString():l.created_at??"",earliest_expiry:(p=l.mandates)!=null&&p.length?new Date(Math.min(...l.mandates.map(v=>v.expiresAt))*1e3).toISOString():null,remaining_seconds:(g=l.mandates)!=null&&g.length?Math.max(0,Math.min(...l.mandates.map(v=>v.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:u}})}async listTeamReceipts(s){const a=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets`);if(!a.ok)throw new Error(`Failed to fetch team receipts: ${a.status}`);return(await a.json()).tickets??[]}async getMyReceiptsPage(s){const a=new URLSearchParams;s!=null&&s.before&&a.set("before",s.before),s!=null&&s.profile&&a.set("profile",s.profile),s!=null&&s.limit&&a.set("limit",String(s.limit));const o=a.toString(),l=await this.fetch(`/api/tickets/mine${o?"?"+o:""}`);if(!l.ok)throw new Error(`Failed to fetch receipts: ${l.status}`);const u=await l.json();return{receipts:u.tickets??[],nextBefore:u.nextBefore??null}}async listTeamReceiptsPage(s,a){const o=new URLSearchParams;a!=null&&a.before&&o.set("before",a.before),a!=null&&a.profile&&o.set("profile",a.profile),a!=null&&a.limit&&o.set("limit",String(a.limit));const l=o.toString(),u=await this.fetch(`/api/groups/${encodeURIComponent(s)}/tickets${l?"?"+l:""}`);if(!u.ok)throw new Error(`Failed to fetch team receipts: ${u.status}`);const f=await u.json();return{receipts:f.tickets??[],nextBefore:f.nextBefore??null}}async getThread(s){const a=s.sinceDays??7,o=s.status??"pending",l=await this.getMyProposals(s.domain,o);let u=[];if(o==="all"){const f=[],p=new Date;for(let v=0;v<a;v++){const y=new Date(p);y.setUTCDate(p.getUTCDate()-v),f.push(y.toISOString().slice(0,10))}u=(await Promise.all(f.map(v=>this.getMyReceipts({date:v,profile:s.profile})))).flat()}return{proposals:l,receipts:u}}async getAutostart(){const s=await this.fetch("/autostart");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async setAutostart(s){const a=await this.fetch("/autostart",{method:s?"POST":"DELETE"});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.message||`HTTP ${a.status}`)}}async getAsPairing(){const s=await this.fetch("/as-pairing");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getSkippedCommitments(){const s=await this.fetch("/skipped-commitments");if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async getMyPendingProposals(){const s=await this.fetch("/my-pending-proposals");return s.ok?(await s.json().catch(()=>({proposals:[]}))).proposals??[]:[]}async getGateContent(s){const a=await this.fetch(`/gate-content?path=${encodeURIComponent(s)}`);if(!a.ok)throw new Error(`Failed to fetch gate content: ${a.status}`);return(await a.json()).entry??null}async resyncGates(){const s=await this.fetch("/resync-gates",{method:"POST"});if(!s.ok)throw new Error(`Failed to resync gates: ${s.status}`)}async getEnrichedAuthorizations(){const s=await this.fetch("/active-authorizations");if(!s.ok)throw new Error(`Failed to fetch authorizations: ${s.status}`);return(await s.json()).authorizations??[]}async pushGateContent(s){const a=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(s)});if(!a.ok){const o=await a.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(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 Kx,Cm=h.createContext(null);function qx({children:e}){const[s,a]=h.useState(null),[o,l]=h.useState("personal"),[u,f]=h.useState(null),[p,g]=h.useState(""),[v,y]=h.useState(null),[w,x]=h.useState(null),[b,k]=h.useState(null),[S,N]=h.useState(!1),[E,T]=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";g(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"&&T(`Authority Server changed to ${G.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const M=h.useCallback(async(G,O={})=>{N(!0),T("");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),g("owner"),await B()}catch(ne){throw L.clearApiKey(),P.current=!1,T(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),g(""),y(null),x(null),k(null),l("personal"),T("")},[]),z=h.useCallback(G=>{L.clearApiKey(),P.current=!1,I.current=null,a(null),f(null),g(""),y(null),x(null),k(null),l("personal"),T(G??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),U=h.useCallback(()=>T(""),[]),Z=h.useCallback((G,O)=>{f(G),g(O)},[]);return n.jsx(Cm.Provider,{value:{user:s,mode:o,group:u,domain:p,groupId:(u==null?void 0:u.id)??null,activeTeam:v,activeMembership:w,pendingRequest:b,isLoading:S,error:E,login:M,logout:q,clearError:U,handleSessionLocked:z,activeGroup:u,activeDomain:p,groups:u?[u]:[],setActiveContext:Z,refreshGroups:B},children:e})}function wt(){const e=h.useContext(Cm);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Yx={"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},Jx=Object.keys(Yx),Em=h.createContext(null);function Qx({children:e}){const{user:s}=wt(),a=h.useRef(null),[o,l]=h.useState(!1),u=h.useRef(new Map),f=h.useCallback((p,g)=>{const v=u.current;return v.has(p)||v.set(p,new Set),v.get(p).add(g),()=>{var y;(y=v.get(p))==null||y.delete(g)}},[]);return h.useEffect(()=>{if(!s){a.current&&(a.current.close(),a.current=null,l(!1));return}if(a.current)return;const p=L.getApiKey();if(!p)return;const g=new EventSource(`/events?key=${encodeURIComponent(p)}`);a.current=g,g.onopen=()=>l(!0),g.onerror=()=>l(!1);for(const v of Jx)g.addEventListener(v,y=>{let w;try{w=JSON.parse(y.data)}catch{w=null}const x=u.current.get(v);if(x)for(const b of x)try{b(w)}catch(k){console.error(`[EventSource] handler for "${v}" threw:`,k)}});return()=>{g.close(),a.current=null,l(!1)}},[s]),n.jsx(Em.Provider,{value:{connected:o,addListener:f},children:e})}function Me(e,s){const a=h.useContext(Em);if(!a)return;const{addListener:o}=a;h.useEffect(()=>o(e,s),[e,s,o])}const ia="suveren-theme",Yf="hap-theme";function Ei(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const s=localStorage.getItem(Yf);s!==null&&localStorage.getItem(ia)===null&&localStorage.setItem(ia,s),s!==null&&localStorage.removeItem(Yf)})();function Tm(){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 Xx=300*1e3,Zx=2e3;function Mc(){const[e,s]=h.useState(!1),[a,o]=h.useState("docker"),[l,u]=h.useState(""),[f,p]=h.useState(null),[g,v]=h.useState(!1),[y,w]=h.useState(!1),[x,b]=h.useState(!1),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"&&p(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 E=setInterval(()=>N(!1),x?Zx:Xx),T=()=>{document.visibilityState==="visible"&&N(!1)};return document.addEventListener("visibilitychange",T),window.addEventListener("focus",T),()=>{S=!0,clearInterval(E),document.removeEventListener("visibilitychange",T),window.removeEventListener("focus",T)}},[x]),{updateAvailable:e&&!y,installMethod:a,version:l,latestVersion:f,serverRestarted:g,startFastPolling:()=>b(!0),dismiss:()=>w(!0)}}function e0(e){return!e||typeof e!="object"?{managed:!1}:{managed:Array.isArray(e.policyLocked)&&e.policyLocked.includes("team")}}function t0(){const[e,s]=h.useState({managed:!1});return h.useEffect(()=>{let a=!1;return fetch("/health").then(o=>o.json()).then(o=>{a||s(e0(o))}).catch(()=>{}),()=>{a=!0}},[]),e}function n0({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 r0(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Jf={system:"◑",light:"☀",dark:"☾"};function Oc({onMenuToggle:e}){const{user:s,logout:a,mode:o,activeTeam:l}=wt(),{theme:u,toggle:f}=Tm(),{version:p,updateAvailable:g,latestVersion:v}=Mc(),{managed:y}=t0(),w=r0(p),x=o==="team"&&l?`Team ${l.name}`:"Personal";return n.jsx("nav",{className:"top-nav",children:n.jsxs("div",{className:"top-nav-inner",children:[n.jsxs("div",{className:"logo-group",children:[n.jsx(n0,{size:20}),n.jsx("span",{className:"logo",children:"Suveren"}),n.jsx("span",{className:"version-badge",children:"Local Gateway"}),w&&n.jsxs("span",{className:"gw-version",title:g&&v?`Running v${w} — v${v} is available`:"Running gateway version","data-stale":g?"true":void 0,children:["v",w,g&&v?` → ${v}`:""]})]}),n.jsx("div",{className:"nav-spacer"}),n.jsx("div",{className:"nav-actions nav-actions-desktop",children:s?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"workspace-pill","data-managed":y?"true":void 0,title:y?`${x} — set by your IT`:x,children:[x,y&&n.jsx("span",{className:"workspace-pill-it",children:" · set by your IT"})]}),n.jsx("span",{className:"user-chip",children:n.jsx("strong",{children:s.name})}),n.jsx("button",{className:"theme-toggle",onClick:f,title:`Theme: ${u}`,children:Jf[u]}),n.jsx("button",{className:"nav-logout",onClick:a,children:"Logout"})]}):n.jsx("button",{className:"theme-toggle",onClick:f,title:`Theme: ${u}`,children:Jf[u]})}),s&&e&&n.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function Bc(e,s){var a;if((a=s==null?void 0:s.revokedSet)!=null&&a.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function Am(e){return e==="expired"||e==="revoked"}function Im(e,s){var a;return!!((a=s==null?void 0:s.archivedSet)!=null&&a.has(e.authorization_id))&&Am(Bc(e,s))}function Mi(e,s){return Im(e,s)?"archived":Bc(e,s)}function Rm(e,s){const a={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const o of e)a[Mi(o,s)].push(o);return a}function s0(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 Mt(e,s,a){const o=h.useRef(e);o.current=e,h.useEffect(()=>{let l=null;const u=()=>typeof document>"u"?!0:document.visibilityState==="visible",f=()=>{u()&&o.current()},p=()=>{l===null&&(l=setInterval(f,s))},g=()=>{l!==null&&(clearInterval(l),l=null)},v=()=>{u()?(o.current(),p()):g()};return u()&&(o.current(),p()),document.addEventListener("visibilitychange",v),()=>{g(),document.removeEventListener("visibilitychange",v)}},[s,a])}function Dc(){const[e,s]=h.useState(!1);return h.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(f=>f.json()).then(f=>{a||s(f.simulation===!0)}).catch(()=>{})};o();const l=setInterval(o,3e4),u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,clearInterval(l),document.removeEventListener("visibilitychange",u)}},[]),e}function a0(e,s){const a=e.simulation;return a?(((s==null?void 0:s[a.field])??"").trim().toLowerCase()||a.default.trim().toLowerCase())==="simulation":!1}function Oi(e){return!!(e!=null&&e.simulation)}function Qf(e,s){return Pm(e,e.modeLabels,s)}function Xf(e,s){return Pm(e,e.modeNotes,s)}function Pm(e,s,a){const o=e.simulation;if(!s||!o)return;const l=((a==null?void 0:a[o.field])??"").trim().toLowerCase()||o.default.trim().toLowerCase(),u=s[l];if(u===void 0)return;if(typeof u=="string")return u;const f=e.adapterField,p=f?((a==null?void 0:a[f])??"").trim().toLowerCase():"";return p?u[p]:void 0}function Bi(e,s){var a;return s&&(!Oi(e.manifest)||((a=e.integration)==null?void 0:a.paused)==="simulation")}function i0(e,s=!1){var o;const a=[];for(const l of e)Bi(l,s)||(l.state==="error"?a.push({label:"Integration error",detail:(o=l.integration)!=null&&o.error?`${l.manifest.name}: ${l.integration.error}`:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"}):l.state==="not-running"&&(Oi(l.manifest)?a.push({label:`${l.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--text-primary)"}):a.push({label:"Integration stopped",detail:`${l.manifest.name} is not running`,to:"/integrations",color:"var(--text-primary)"})));return a}function o0(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 $m=h.createContext(null),l0=3e4,c0=5e3,u0=3e5;function d0(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 f0({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),Mt(l,u?c0:u0);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<l0;return s.manifests.map(b=>{const k=y.get(b.id),S=d0(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]),p=Dc(),g=h.useMemo(()=>f.filter(y=>!Bi(y,p)&&(y.state==="not-running"||y.state==="error"||y.authStatus==="failed")).length,[f,p]),v={loading:s.fetchCount===0,mcpServerUp:s.mcpServerUp,manifestsError:s.manifestsError,entries:f,attentionCount:g,activeSessions:s.activeSessions,refresh:l};return n.jsx($m.Provider,{value:v,children:e})}function Uc(){const e=h.useContext($m);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const h0={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Wc=e=>h0[e]??e,m0={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 p0(e){return(e&&m0[e])??{chip:"Blocked",sev:"info"}}function g0(e){const s=Wc(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?n.jsxs(n.Fragment,{children:["Tried to read your ",n.jsx("b",{children:e.target??"restricted"})," calendar"]}):n.jsxs(n.Fragment,{children:["Tried to read a restricted location in ",s]});case"spam":return n.jsxs(n.Fragment,{children:["Tried to open a message in ",n.jsx("b",{children:"spam or trash"})]});case"age":return n.jsxs(n.Fragment,{children:["Tried to read ",s," older than your read window"]});case"unset_age":return n.jsxs(n.Fragment,{children:["Your ",s," has ",n.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return n.jsxs(n.Fragment,{children:["Read access isn't granted on your ",s," mandate"]});case"ungoverned":return n.jsxs(n.Fragment,{children:["A ",s," tool isn't configured for safe reading"]});case"query_unsafe":return n.jsx(n.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return n.jsx(n.Fragment,{children:e.detail})}}function _m(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 y0=5,v0=1440*60*1e3,x0=7;function w0(e,s){const a=s-x0*v0;return{recent:e.filter(o=>o.ts>=a),all:e}}function j0(){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]),Mt(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:p}=w0(e,Date.now()),g=p.filter(w=>w.ts>l);if(g.length===0)return null;const v=g.slice(0,y0),y=(w,x)=>{const b=p0(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:g0(w)}),n.jsxs("div",{className:"rb-meta",children:[n.jsx("span",{className:`rb-chip ${b.sev==="act"?"act":b.sev==="warn"?"warn":""}`,children:b.chip}),n.jsx("span",{className:"rb-via",children:Wc(w.integrationId)})]}),b.fixTo&&n.jsx(gt,{className:"rb-fix",to:b.fixTo,children:"Set a read window →"})]}),n.jsx("div",{className:"rb-when",children:_m(w.ts,Date.now())})]},`${w.ts}-${x}`)};return n.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[n.jsxs("div",{className:"card-header",children:[n.jsx("h2",{className:"card-title",children:"Recent blocks"}),n.jsx("span",{className:"rb-count",children:g.length})]}),n.jsx("p",{className:"rb-sub",children:"New since you last looked. Limits you set that stopped your agent — the gateway doing its job."}),n.jsx("div",{className:"rb-rows",children:v.map(y)}),n.jsxs(gt,{className:"col-btn",to:"/blocked",children:["View all ",p.length," blocks from the last 30 days ›"]})]})}function no(e){return e.kind??"read"}function S0(e,s){var u,f,p,g;if(!s)return"";if(!e)return s;const a=(f=(u=e.scopeSchema)==null?void 0:u.fields)==null?void 0:f[s];if(a!=null&&a.displayName)return a.displayName;const o=((p=e.boundsSchema)==null?void 0:p.fields)??{};if((g=o[s])!=null&&g.displayName)return o[s].displayName;const l=Object.values(o).find(v=>v.boundType&&"of"in v.boundType&&v.boundType.of===s);return l!=null&&l.displayName?l.displayName:s}const b0={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"},k0={bound:"Nothing ran. To allow this, raise the limit on the mandate (needs your signature) — or ask the AI to stay within it.",scope:"Nothing ran. To allow this, widen the mandate's scope (needs your signature) — or ask the AI to stay within it.",cumulative:"Nothing ran. Possible again once the window resets — or raise the limit in the mandate.",simulation:"Nothing ran. Turn off simulation mode in Settings to use real systems.",not_authorized:"Nothing ran. Grant a mandate for this, or ask the decision owner.",read:"Nothing was read."};function Zf(e){return e===void 0?"":typeof e=="number"?e.toLocaleString():e}function N0(e,s){const a=no(e),o=Zf(e.value),l=Zf(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 Lm(e,s){if(e.mandateId){const a=s==null?void 0:s[e.mandateId];if(a)return a}return e.mandateTitle}function C0(e,s){const a=Lm(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 E0(e,s){const a=no(e),o=Wc(e.integrationId),l=e.who==="authority-server"?"refused by the Authority Server":a==="read"?"refused by this gateway":"refused by this gateway, before anything ran",u=e.code?` (${e.code})`:"";return[{text:`${o} · ${e.tool}`},...C0(e,s),{text:` · ${l}${u}`}]}function T0(e,s,a){const o=no(e),l=S0(s,e.field);return{title:b0[o],sentence:N0(e,l),sourceLine:E0(e,a),whatYouCanDo:k0[o]}}function A0(e,s){const a=new Date(s);return a.setHours(0,0,0,0),e.filter(o=>o.ts>=a.getTime()).length}function I0(e,s){return e.filter(a=>a.ts>s).length}const R0=1440*60*1e3;function P0(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-R0?`Yesterday · ${a}`:`${new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})} · ${a}`}function zm(e,s){return!!e&&e.savedAt*1e3>s}function $0(e){const s=/<h[1-3][^>]*>([\s\S]*?)<\/h[1-3]>/i.exec(e),a=s?s[1].replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/\s+/g," ").trim():"";return a?a.length>80?`${a.slice(0,79)}…`:a:"Report"}function _0(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 eh=(e,s)=>new Date(e*1e3).toLocaleString(s,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),th=(e,s)=>new Date(e*1e3).toLocaleString(s,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});function Di(e,s){const a=e==null?void 0:e.window;return a?{text:`Covers ${eh(a.start,s)} → ${eh(a.end,s)} (${a.days} day${a.days===1?"":"s"})`,title:`From ${th(a.start,s)} to ${th(a.end,s)}. Tickets up to 2 minutes after the end count, for small clock differences.`}:{text:"Period not recorded"}}function Fm(e,s,a){const o=new Date(e*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"}),u=Math.floor((s-e*1e3)/864e5);if(new Date(s).toDateString()===o.toDateString())return`today ${l}`;const p=`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`;return u>=2?`${p} (${u} days ago)`:p}const L0=[{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 z0(){const{activeDomain:e}=wt(),[s,a]=h.useState({}),o=h.useCallback(async()=>{try{const[l,u,f,p,g,v,y,w,x,b]=await Promise.all([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 T=Rm(u,{archivedSet:new Set(v)}).expired.length;T>0&&(k.authorizations=T)}const S=(f==null?void 0:f.length)??0,N=(p==null?void 0:p.length)??0,E=S+N;if(E>0&&(k.proposals=E),(!g||!g.trim())&&(k.brief=1),y){const T=I0(y.records,w);T>0&&(k.blocked=T)}zm(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]),Mt(o,3e5,e),s}const F0={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},M0={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 O0(){const{mode:e,activeTeam:s}=wt(),a=z0(),{attentionCount:o}=Uc(),l={...a};o>0&&(l.integrations=o);const u=L0.filter(y=>!y.teamOnly||e==="team"),f=h.useRef(null),[p,g]=h.useState(null),v=Xt();return h.useEffect(()=>{if(f.current===null){f.current=e;return}f.current!==e&&(e==="team"&&s?g(`You are now acting in team context — ${s.name}`):e==="personal"&&g("You have left the team — back to personal context"),f.current=e)},[e,s]),h.useEffect(()=>{g(null)},[v.pathname]),n.jsxs("div",{className:"sidebar",children:[["top","core","setup"].map(y=>{const w=u.filter(x=>(x.group??"setup")===y);return w.length===0?null:n.jsxs("div",{className:`sidebar-${y}`,children:[y==="setup"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-divider"}),n.jsx("div",{className:"sidebar-group-label",children:"Setup"})]}),n.jsx("ul",{className:"sidebar-nav",children:w.map(x=>{const b=x.statusKey?l[x.statusKey]:0;return n.jsx("li",{children:n.jsxs(Fc,{to:x.to,end:x.to==="/",className:({isActive: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:F0,className:x.quietCount?"nav-count-quiet":void 0,title:x.quietCount?"Expired mandates":void 0,children:b}):null]})},x.to)})})]},y)}),p&&n.jsx("div",{style:M0,role:"status","aria-live":"polite",children:p})]})}const Zl="suveren:updatedTo";function B0(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 D0="Updates for this gateway come from your company's IT — no action needed here.";function U0(e){return e==="managed"?"update-banner is-managed":"update-banner"}const W0="Download the new installer and run it. Your settings and mandates stay.";function H0(e){const s="https://github.com/suverenai/suveren-gateway/releases";return e?`${s}/tag/v${e}`:`${s}/latest`}function V0(){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 Mm(){const{updateAvailable:e,installMethod:s,version:a,latestVersion:o,serverRestarted:l,startFastPolling:u,dismiss:f}=Mc(),[p,g]=h.useState(!1),[v,y]=h.useState(!1),[w,x]=h.useState(()=>{try{const P=sessionStorage.getItem(Zl);if(P)return sessionStorage.removeItem(Zl),P}catch{}return null}),b=B0(s),k=h.useRef(null),S=P=>{try{sessionStorage.setItem(Zl,P||o||"✓")}catch{}window.location.reload()};h.useEffect(()=>{if(!w)return;const P=setTimeout(()=>x(null),6e3);return()=>clearTimeout(P)},[w]),h.useEffect(()=>{if(!p||!l)return;const P=()=>V0()?!1:(S(a),!0);if(P())return;const I=setInterval(P,1500);return()=>clearInterval(I)},[p,l,a]),h.useEffect(()=>(document.body.classList.toggle("is-updating",p),()=>document.body.classList.remove("is-updating")),[p]);const N=e&&!p&&!w||!!w&&!p;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 E=()=>{g(!0),u()},T=async()=>{if(b)try{await navigator.clipboard.writeText(b),y(!0),setTimeout(()=>y(!1),1800)}catch{}};return n.jsxs(n.Fragment,{children:[w&&!p&&n.jsx("div",{ref: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&&!p&&!w&&n.jsxs("div",{ref:k,className:U0(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:H0(o),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),s!=="managed"&&s!=="msi"&&n.jsx("button",{className:"btn btn-sm btn-secondary",onClick:E,children:"Update"}),n.jsx("button",{className:"update-banner-x",onClick:f,"aria-label":"Dismiss",children:"×"})]})]}),s==="managed"&&n.jsx("p",{className:"update-banner-hint",children:D0}),s==="msi"&&n.jsx("p",{className:"update-banner-hint",children:W0})]}),p&&n.jsx("div",{className:"update-overlay",children:n.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[n.jsx("div",{className:"update-spinner"}),n.jsxs("h2",{children:["Finishing the update","…"]}),n.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",n.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),n.jsxs("div",{className:"update-cmd-row",children:[n.jsx("code",{className:"update-cmd",children:b}),n.jsx("button",{className:"btn btn-sm btn-primary",onClick:T,children:v?"Copied":"Copy"})]}),n.jsxs("div",{className:"update-status",children:[n.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),n.jsxs("div",{className:"update-overlay-actions",children:[n.jsx("button",{className:"btn btn-primary",onClick:()=>S(a),children:"Reload now"}),n.jsx("button",{className:"btn btn-secondary",onClick:()=>g(!1),children:"Cancel"})]})]})})]})}function Om(){const e=Dc(),s=h.useRef(null);return h.useEffect(()=>{if(!e){document.documentElement.style.removeProperty("--sim-banner-h");return}const a=()=>{var u;const l=((u=s.current)==null?void 0:u.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${l}px`)};a();const o=new ResizeObserver(a);return s.current&&o.observe(s.current),()=>{o.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[e]),e?n.jsx("div",{ref:s,className:"simulation-banner",role:"status","aria-live":"polite",children:n.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const G0={system:"◑",light:"☀",dark:"☾"},K0=[{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 q0({open:e,onClose:s}){const{user:a,activeGroup:o,activeDomain:l,logout:u}=wt(),{theme:f,toggle:p}=Tm(),g=Xt();return h.useEffect(()=>{s()},[g.pathname]),e?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mobile-menu-backdrop",onClick:s}),n.jsxs("div",{className:"mobile-menu-panel",children:[a&&n.jsxs("div",{className:"mobile-menu-header",children:[n.jsx("strong",{children:a.name}),n.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:o?`${o.name} / ${l}`:l||"personal"})]}),n.jsx("nav",{className:"mobile-menu-nav",children:K0.map(v=>n.jsxs(Fc,{to:v.to,end:v.to==="/",className:({isActive:y})=>`mobile-menu-item${y?" active":""}`,onClick:s,children:[n.jsx("span",{className:"icon",children:v.icon}),v.label]},v.to))}),n.jsxs("div",{className:"mobile-menu-footer",children:[n.jsxs("button",{className:"mobile-menu-action",onClick:()=>{p()},children:[n.jsx("span",{className:"icon",children:G0[f]}),"Theme: ",f]}),n.jsx("button",{className:"mobile-menu-action",onClick:()=>{u(),s()},children:"Logout"})]})]})]}):null}function Bm(e){return e.status==="pending"}function Y0(e,s){return e.filter(Bm).length+s.length}const Er=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],J0=500;function Dm(){const{user:e,domain:s}=wt(),[a,o]=h.useState(0),l=h.useRef(null),u=h.useCallback(async()=>{if(!e){o(0);return}try{const[p,g]=await Promise.all([L.getMyProposals(s).catch(()=>[]),L.getProposalsForApprover().catch(()=>[])]);o(Y0(p,g))}catch{o(0)}},[e,s]),f=h.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{u()},J0)},[u]);return h.useEffect(()=>(u(),()=>{l.current&&clearTimeout(l.current)}),[u]),Me(Er[0],f),Me(Er[1],f),Me(Er[2],f),Me(Er[3],f),Me(Er[4],f),Me(Er[5],f),Me(Er[6],f),a}const nh="Suveren",Q0="/favicon.svg",X0="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},Z0=14,ew="#f59e0b";function tw(e){const s=Hc(e);return s>0?`(${s}) ${nh}`:nh}function Hc(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function nw(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
52
|
-
<path class="m" d="${X0}"/>
|
|
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="${ew}"/>
|
|
55
|
-
<style>.m{stroke:#111111;stroke-width:${Z0};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 rw(){return document.querySelector('link[rel="icon"]')}function Um(e){const s=Hc(e);document.title=tw(s),Wm(s);const a=rw();if(!a)return;const o=s>0?nw():Q0;a.getAttribute("href")!==o&&a.setAttribute("href",o)}function sw(){Um(0)}function Wm(e,s=globalThis.navigator){var l;if(!s||typeof s.setAppBadge!="function")return;const a=Hc(e),o=a>0?s.setAppBadge(a):s.clearAppBadge?s.clearAppBadge():s.setAppBadge(0);(l=o==null?void 0:o.catch)==null||l.call(o,()=>{})}function aw(){const e=Dm();return h.useEffect(()=>{Um(e)},[e]),h.useEffect(()=>sw,[]),null}const Hm="suveren:dockBadgePrompt";function iw(){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(Hm))return!1}catch{}return!0}function ow(){const[e,s]=h.useState(!1),a=Dm();if(h.useEffect(()=>{s(iw())},[]),!e)return null;const o=()=>{try{localStorage.setItem(Hm,"1")}catch{}s(!1)},l=async()=>{try{await Notification.requestPermission()==="granted"&&Wm(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 lw(){const[e,s]=h.useState(!1);return n.jsxs(f0,{children:[n.jsx(aw,{}),n.jsx(Oc,{onMenuToggle:()=>s(!e)}),n.jsx(Mm,{}),n.jsx(Om,{}),n.jsx(O0,{}),n.jsx(q0,{open:e,onClose:()=>s(!1)}),n.jsx("div",{className:"main-content",children:n.jsxs("div",{className:"page-inner",children:[n.jsx(ow,{}),n.jsx(ax,{})]})})]})}function Vm({what:e}){return n.jsxs("div",{className:"human-only-note",role:"note",children:[n.jsx("strong",{children:"Only you."})," ",e==="sign-in"?"Never let an AI or a browser it controls sign in here or see this key.":"Approve only yourself. Never let an AI or a browser it controls open this page or approve for you."]})}function Vc(){return typeof navigator<"u"&&navigator.webdriver===!0}const Gc="This browser is controlled by automation. Sign-in and approvals are for a person only — open the gateway in your own browser.";function cw(){const[e,s]=h.useState(""),{login:a,isLoading:o,error:l,clearError:u}=wt(),[f,p]=h.useState(null),g=Vc(),v=async()=>{if(!(!e.trim()||g)){u();try{await a(e)}catch(x){if(x instanceof km){p(x.summary);return}}}},y=async()=>{p(null),u();try{await a(e,{confirmWipe:!0})}catch{}},w=()=>{p(null)};return n.jsxs(n.Fragment,{children:[n.jsx(Oc,{}),n.jsx(Mm,{}),n.jsx(Om,{}),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(Vm,{what:"sign-in"}),g&&n.jsx("div",{className:"error-message",children:Gc}),l&&n.jsx("div",{className:"error-message",children:l}),n.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[n.jsx("label",{className:"form-label",children:"API Key"}),n.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:x=>s(x.target.value),onKeyDown:x=>x.key==="Enter"&&v(),disabled:o,style:{padding:"0.75rem"}}),n.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),n.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:v,disabled:o||g,style:{marginBottom:"2rem"},children:o?"Signing in...":"Sign In"}),n.jsx("div",{className:"login-divider",children:"New here?"}),n.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[n.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",n.jsx("br",{}),"then come back to sign in."]}),n.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-full",style:{textDecoration:"none"},children:"Create Account"})]}),n.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[n.jsxs(n.Fragment,{children:["Create an account at ",n.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)"},children:"Suveren"})]}),"Join or create a team to get domain authority","Sign in here with your API key to start giving mandates"].map((x,b)=>n.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:b<2?"0.5rem":0},children:[n.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[b+1,"."]}),x]},b))})]})]})})]}),f&&n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-main) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:w,children:n.jsxs("div",{className:"card",onClick:x=>x.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[n.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["This gateway already holds data for another account. Signing in with this API key will ",n.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),n.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[n.jsxs("li",{children:[f.credentialCount," stored service credential",f.credentialCount===1?"":"s",f.credentialIds.length>0&&n.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",f.credentialIds.slice(0,5).join(", "),f.credentialIds.length>5?`, +${f.credentialIds.length-5} more`:"",")"]})]}),n.jsxs("li",{children:[f.serviceCount," configured integration",f.serviceCount===1?"":"s"]}),n.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),n.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Mandates and tickets on the Authority Server are NOT affected — only this gateway's local state is wiped."}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:"If this isn't what you wanted, cancel and sign back in with the original API key, or use a different gateway instance for this account."}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:w,disabled:o,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:y,disabled:o,children:o?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function uw(e,s){return!s&&e!=null}function dw(e,s){return e==="join-waiting"&&s==="team"}function fw(e,s,a,o){return a!=null||e!=="join-waiting"||s==="team"?null:o}function hw(e){return`${e} personal mandate${e===1?"":"s"}`}function mw({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 pw(){const{mode:e,pendingRequest:s,refreshGroups:a}=wt(),o=Sn(),[l,u]=h.useState("choose"),[f,p]=h.useState(""),[g,v]=h.useState(""),[y,w]=h.useState(null),[x,b]=h.useState(null),[k,S]=h.useState(""),[N,E]=h.useState(""),[T,P]=h.useState(!1),I=h.useRef(!1);h.useEffect(()=>{uw(s,I.current)&&(I.current=!0,u("join-waiting"))},[s]),h.useEffect(()=>{dw(l,e)&&o("/")},[l,e,o]);const B=h.useRef(null);h.useEffect(()=>{if(s){B.current=s.groupName;return}const O=fw(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"),E(""),w(null),b(null),p(""),v("")},[]),q=async()=>{if(f.trim()){P(!0),E("");try{const O=await L.getJoinPreview(f.trim());w(O),u("join-preview")}catch(O){E(O instanceof Error?O.message:"Invalid or expired invite code")}finally{P(!1)}}},z=async()=>{P(!0),E("");try{await L.requestToJoinGroup(f.trim()),await a(),u("join-waiting")}catch(O){E(O instanceof Error?O.message:"Failed to join group")}finally{P(!1)}},U=async()=>{P(!0),E("");try{await L.withdrawJoinRequest(),await a(),M()}catch(O){E(O instanceof Error?O.message:"Failed to withdraw request")}finally{P(!1)}},Z=async()=>{u("create"),E(""),P(!0);try{const O=await L.getCreatePreview();b(O)}catch(O){E(O instanceof Error?O.message:"Failed to load preview")}finally{P(!1)}},G=async()=>{if(g.trim()){P(!0),E("");try{await L.createGroup(g.trim()),await a(),o("/")}catch(O){E(O instanceof Error?O.message:"Failed to create group")}finally{P(!1)}}};return n.jsxs(n.Fragment,{children:[n.jsx(Oc,{}),n.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:n.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[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=>p(O.target.value),onKeyDown:O=>O.key==="Enter"&&q(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:T}),n.jsx("button",{className:"btn btn-primary",onClick:q,disabled:T||!f.trim(),children:T?"Checking…":"Continue"})]})]}),n.jsxs("div",{className:"card",children:[n.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new team"}),n.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members."}),n.jsx("button",{className:"btn btn-secondary",onClick:Z,disabled:T,children:"Create a team"})]})]}),l==="join-preview"&&y&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Join team ",y.groupName,"?"]}),n.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Your account ",n.jsx("strong",{children:"moves to the team"}),". From then on you work under the team's rules — its approvers and limits."]}),n.jsx(mw,{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:T,children:T?"Asking…":"Ask to join"}),n.jsx("button",{className:"btn btn-ghost",onClick:M,disabled:T,children:"Cancel"})]})]}),l==="join-waiting"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request sent to team ",(s==null?void 0:s.groupName)??""]}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Waiting for the team admin to confirm. Until then your account stays Personal and your mandates keep working."}),n.jsx("button",{className:"btn btn-secondary",onClick:U,disabled:T,children:T?"Withdrawing…":"Withdraw request"})]}),l==="join-declined"&&n.jsxs("div",{className:"card",children:[n.jsxs("h3",{style:{marginBottom:"0.25rem"},children:["Request to ",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:T,children:"Back"})]}),l==="create"&&n.jsxs("div",{className:"card",children:[n.jsx("h3",{style:{marginBottom:"0.75rem"},children:"Create a team"}),n.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[n.jsx("label",{style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:"Team name"}),n.jsx("input",{className:"form-input",placeholder:"e.g., Acme Corp",value:g,onChange:O=>v(O.target.value),onKeyDown:O=>O.key==="Enter"&&G(),disabled:T,autoFocus:!0})]}),x&&n.jsxs("div",{className:"alert alert-info",style:{color:"white"},children:["Your account moves to the new team. Your ",hw(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:T||!g.trim(),children:T?"Creating…":"Create team and move my account"}),n.jsx("button",{className:"btn btn-ghost",onClick:M,disabled:T,children:"Cancel"})]})]})]})})]})}const rh={"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`}},sh=["claude-code","claude-desktop","chatgpt-codex","other"];function hc({mcpEndpoint:e}){const[s,a]=h.useState(sh[0]),[o,l]=h.useState(!1),u=h.useCallback(async p=>{try{await navigator.clipboard.writeText(p),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},[]),f=rh[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:sh.map(p=>n.jsx("button",{className:`mcp-tab${s===p?" active":""}`,onClick:()=>a(p),children:rh[p].label},p))}),n.jsx("pre",{className:"mcp-snippet",children:f}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>u(f),children:o?"Copied":"Copy"})]})}const mc="suveren-setup-ai-skipped",pc="suveren-setup-agent-done",gc="suveren-setup-dismissed",gw={"hap-setup-ai-skipped":mc,"hap-setup-agent-done":pc,"hap-setup-dismissed":gc};function yw(){for(const[e,s]of Object.entries(gw)){const a=localStorage.getItem(e);a!==null&&localStorage.getItem(s)===null&&localStorage.setItem(s,a),a!==null&&localStorage.removeItem(e)}}yw();function vw({aiConfigured:e,hasRunningIntegration:s,hasActiveAuth:a,hasAgentConnected:o,mcpEndpoint:l}){const[u,f]=h.useState(()=>localStorage.getItem(mc)==="true"),[p,g]=h.useState(()=>localStorage.getItem(pc)==="true"),[v,y]=h.useState(()=>localStorage.getItem(gc)==="true"),[w,x]=h.useState(null),b=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":u?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:s?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:a?"done":"pending"},{label:"Connect your agent",status:o||p?"done":"pending"}],k=b.filter(I=>I.status==="done"||I.status==="skipped").length,S=k===b.length,N=h.useCallback(()=>{localStorage.setItem(mc,"true"),f(!0)},[]),E=h.useCallback(()=>{localStorage.setItem(pc,"true"),g(!0),x(null)},[]),T=h.useCallback(()=>{localStorage.setItem(gc,"true"),y(!0)},[]);if(v||S)return null;const P=b.findIndex(I=>I.status==="pending");return n.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[n.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),n.jsx("button",{onClick:T,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:b.map((I,B)=>{const 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(hc,{mcpEndpoint:l}),n.jsx("button",{className:"btn btn-primary btn-sm",style:{marginTop:"0.75rem"},onClick:E,children:"Done"})]})]},B)})}),n.jsxs("div",{style:{marginTop:"1.25rem"},children:[n.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:n.jsx("div",{style:{height:"100%",width:`${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 Gm(e,s=null){const a=[e.hasContact,e.hasDelegationMandate,e.delegationProposalCount>0],o=a.every(Boolean),l=e.otherMandateCount===0&&!o,u=a.findIndex(v=>!v),f=s!==null&&a[s]===!1?s:u,p=e.managed?"managed":"self",g=v=>a[v]?{status:"done"}:v!==f?{status:"todo"}:v===1?{status:"open",variant:p,simulationOn:e.simulationOn}:v===0?{status:"open",variant:p}:{status:"open"};return{visible:l,step1:g(0),step2:g(1),step3:g(2)}}const xw="/mandates?new=1&profile=delegation";function ah({text:e}){const[s,a]=h.useState(!1),o=h.useCallback(async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[e]);return n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:o,children:s?"Copied":"Copy"})}function ec({todo:e,onOpen:s,children:a}){return e?n.jsx("button",{type:"button",className:"flow-step-title flow-todo-title flow-step-open-btn",onClick:s,children:a}):n.jsx("span",{className:"flow-step-title",children:a})}function ww({contact:e,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u,mcpEndpoint:f}){const p={hasContact:e!==null,hasDelegationMandate:s,otherMandateCount:a,delegationProposalCount:o,managed:l,simulationOn:u},[g,v]=h.useState(null),y=Gm(p,g);if(!y.visible)return null;const w=`Please connect to the Suveren gateway: MCP server at ${f}/mcp`;return n.jsxs("div",{className:"card setup-card",children:[n.jsx("h2",{className:"card-title",children:"Get started"}),n.jsx("p",{className:"setup-intro",children:"You decide what your AI can do — it acts only within that. Every action that changes something gets a signed ticket."}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step1.status==="open"?"open":y.step1.status==="done"?"done":"todo"}`,children:y.step1.status==="done"?"✓":"1"}),y.step1.status==="done"&&e?n.jsxs("span",{className:"flow-step-title flow-done-title",children:[e.clientName," connected · last contact ",_m(Date.parse(e.lastSeenAt),Date.now()).toLowerCase()]}):n.jsx(ec,{todo:y.step1.status==="todo",onOpen:()=>v(0),children:"Connect your AI"})]}),y.step1.status==="open"&&n.jsx("div",{className:"flow-step-body",children:y.step1.variant==="managed"?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Your IT sets up the connection. Open your AI — if Suveren isn't there, contact your IT."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"For your IT"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(hc,{mcpEndpoint:f})})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Ask your AI to connect to Suveren. Copy this into it:"}),n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.75rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:w}),n.jsx(ah,{text:w})]})}),n.jsx("p",{className:"cta-helper",style:{marginTop:0,marginBottom:"0.75rem"},children:"If your AI can't add it itself, it will tell you how. In ChatGPT, use a local session."}),n.jsxs("details",{className:"int-details",children:[n.jsx("summary",{children:"Set it up by hand"}),n.jsx("div",{style:{marginTop:"0.75rem"},children:n.jsx(hc,{mcpEndpoint:f})})]})]})})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step2.status==="open"?"open":y.step2.status==="done"?"done":"todo"}`,children:y.step2.status==="done"?"✓":"2"}),y.step2.status==="done"?n.jsxs("span",{className:"flow-step-title flow-done-title",children:["Delegation mandate given · ",n.jsx(gt,{to:"/mandates",children:"review or revoke under Mandates"})]}):n.jsx(ec,{todo:y.step2.status==="todo",onOpen:()=>v(1),children:"Give the Delegation mandate"})]}),y.step2.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("p",{children:"Delegation lets your AI propose the rest of its own setup — new mandates and its working instructions. It can only propose; nothing changes until you approve it."}),n.jsxs("ul",{className:"bound-list",children:[n.jsx("li",{children:"Read the setup guides"}),n.jsx("li",{children:"Propose new mandates — each waits for your approval"}),n.jsx("li",{children:"Propose an updated agent brief — also waits for your approval"})]}),y.step2.simulationOn?n.jsxs(n.Fragment,{children:[n.jsx(gt,{to:xw,className:"btn btn-primary",children:"Give the Delegation mandate →"}),n.jsx("p",{className:"cta-helper",children:"You set the daily limit in the next step."}),y.step2.variant==="managed"&&n.jsx("p",{className:"managed-note",children:"In a company team you may need approver rights — ask your IT if the button is refused."})]}):n.jsx("p",{className:"managed-note",style:{marginTop:0},children:y.step2.variant==="managed"?"Delegation works in simulation mode only. Ask your IT to turn on simulation mode.":n.jsxs(n.Fragment,{children:["Delegation works in simulation mode only. Turn it on with ",n.jsx("code",{children:"suveren-gateway simulation on"})," and restart."]})})]})]}),n.jsxs("div",{className:"flow-step",children:[n.jsxs("div",{className:"flow-step-head",children:[n.jsx("span",{className:`flow-step-marker flow-${y.step3.status==="open"?"open":"todo"}`,children:"3"}),n.jsx(ec,{todo:y.step3.status==="todo",onOpen:()=>v(2),children:"Ask your AI: “How do I start with Suveren?”"})]}),y.step3.status==="open"&&n.jsxs("div",{className:"flow-step-body",children:[n.jsx("div",{className:"gate-content-block",style:{marginBottom:"0.875rem"},children:n.jsxs("div",{className:"quote-box",children:[n.jsx("span",{className:"quote-text",children:"“How do I start with Suveren?”"}),n.jsx(ah,{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 jw(){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 Sw(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 Km(){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(Sw(o))}).catch(()=>{}),()=>{a=!0}},[]),e}function bw(e){return!e||typeof e!="object"?!1:Array.isArray(e.policyLocked)&&e.policyLocked.length>0}function kw(){const[e,s]=h.useState(!1);return h.useEffect(()=>{let a=!1;const o=()=>{fetch("/health").then(f=>f.json()).then(f=>{a||s(bw(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 ih=new Map;function qm(e){let s=ih.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,p)=>(p.id.split("@")[1]??"").localeCompare(f.id.split("@")[1]??"",void 0,{numeric:!0}));if(!u[0])return null;a=u[0].id}return await L.getProfile(a)}catch{return null}})(),ih.set(e,s)),s}function ma(e){const[s,a]=h.useState(null);return h.useEffect(()=>{let o=!0;return e&&qm(e).then(l=>{o&&a(l)}),()=>{o=!1}},[e]),s}const oh=40;function Ot(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,oh):(u.charAt(0).toUpperCase()+u.slice(1)).slice(0,oh)}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=Ot(e,s==null?void 0:s.name);return{icon:o,name:l,testSetup:a==="delegation"}}function ro(e){return e.startsWith("setup__")}const Nw={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 Nw[In(e)]??"unknown"}function lh(e){const s=e.indexOf("@");return s>=0?e.slice(s+1):""}function Dn(e,s){const a=In(e),o=s.filter(l=>In(l.id)===a).sort((l,u)=>lh(u.id).localeCompare(lh(l.id),void 0,{numeric:!0}))[0];return Ot(e,o==null?void 0:o.name)}function Cw(e,s){const a=e==null?void 0:e.trim();return a?a.toLowerCase()!==s.trim().toLowerCase():!1}function Ym(e){return e&&e.trim()?e.trim():null}function Jm(e,s){return s===null||In(e)===s}let tc=null;function Ew(){return tc||(tc=L.listProfiles().catch(()=>[])),tc}function Lr(){const[e,s]=h.useState([]);return h.useEffect(()=>{let a=!0;return Ew().then(o=>{a&&s(o)}),()=>{a=!1}},[]),e}function Tw(e){const s=Lr();return Dn(e,s)}function so(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}const Qm=new Set(["ticket_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview","_source","_attachmentsSealed"]);function Ht(e){const s=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s.charAt(0).toUpperCase()+s.slice(1)}function Wn(e){const s=e.indexOf("__");return s<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,s),toolName:e.slice(s+2)}}function Aw(e){const{integrationId:s,toolName:a}=Wn(e);return s?`${s} · ${a}`:a}function Hn(e,s){const a=s==null?void 0:s.find(o=>o.id===e);return a!=null&&a.name?a.name:e?e.toUpperCase():"the system"}function Iw(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
|
|
66
|
-
`)||e.length>120)?"markdown":"text"}function Xm(e,s){var f,p;const a=(s==null?void 0:s.approvalView)??{},o=((f=s==null?void 0:s.inputSchema)==null?void 0:f.properties)??{},l=[...new Set([...Object.keys(a),...Object.keys(o),...Object.keys(e)])],u=[];for(const g of l){if(!(g in e)||Qm.has(g)||g===(s==null?void 0:s.aiTextArg))continue;const v=e[g],y=a[g]??{},w=y.kind??Iw(v),x={key:g,label:y.label??Ht(g),kind:w,value:v,hint:(p=o[g])==null?void 0:p.description};w==="money"&&y.currencyArg&&typeof e[y.currencyArg]=="string"&&(x.currency=e[y.currencyArg]),w==="profile"&&typeof v=="string"&&(x.profileRef=v),(w==="profile-limits"||w==="profile-scope")&&y.profileArg&&typeof e[y.profileArg]=="string"&&(x.profileRef=e[y.profileArg]),u.push(x)}return u}function ch(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 Rw(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 Pw(e,s,a){if(!e||typeof e!="object"||Array.isArray(e))return[];const o=a==="limits"?s==null?void 0:s.boundsSchema:s==null?void 0:s.scopeSchema,l=(o==null?void 0:o.fields)??{},u=[...new Set([...(o==null?void 0:o.keyOrder)??[],...Object.keys(e)])],f=[];for(const p of u){if(p==="profile"||!(p in e))continue;const g=e[p],v=l[p],y=so(v==null?void 0:v.unit),w=Array.isArray(g)?g.join(", "):String(g);f.push({key:p,label:(v==null?void 0:v.displayName)??Ht(p),value:y?`${w} ${y}`:w,hint:v==null?void 0:v.description,unknown:s?!v:void 0})}return f}function Zm(e){const s=e.indexOf("__");return s<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,s),toolName:e.slice(s+2)}}function ao(e,s){var g,v,y;const{integrationId:a,toolName:o}=Zm(e.action),l=s.find(w=>w.id===a),u=(v=(g=l==null?void 0:l.toolGating)==null?void 0:g.overrides)==null?void 0:v[o];if(u!=null&&u.actionLabel)return u.actionLabel;const f=Ot(e.profileId),p=(y=e.executionContext)==null?void 0:y.action_type;return typeof p=="string"&&p?`${f} · ${p}`:`${f} · ${o}`}function $w(e,s){var l;const a=(l=s==null?void 0:s.scopeSchema)==null?void 0:l.fields;if(!a)return"";const o=[];for(const[u,f]of Object.entries(e.executionContext??{})){if(!(u in a))continue;const p=String(f??"").trim();p&&o.push(p.split(",").map(g=>g.trim()).filter(Boolean).join(", "))}return o.join(" · ")}function _w(e,s){var l,u;if(!e)return"";const a=((l=s==null?void 0:s.scopeSchema)==null?void 0:l.fields)??{},o=[];for(const[f,p]of Object.entries(e)){if(f==="action_type")continue;const g=String(p??"").trim();if(!g)continue;const v=((u=a[f])==null?void 0:u.displayName)??f;o.push(`${v} ${g.split(",").map(y=>y.trim()).filter(Boolean).join(", ")}`)}return o.join(" · ")}function uh(e){return e.appliesTo}function Lw(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=uh(b);return!S||!u||S.includes(u)}),g=(u?f.find(([,x])=>{var b;return(b=uh(x))==null?void 0:b.includes(u)}):void 0)??(f.length===1?f[0]:void 0);return g?{key:g[0],isAmount:((w=g[1].boundType)==null?void 0:w.kind)==="cumulative_sum"}:void 0}function ep(e,s,a,o){var p;const l=(p=e.cumulativeState)==null?void 0:p[o];if(!l)return null;const u=Lw(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 zw(e,s,a){const o=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],l=[];for(const{window:u,label:f}of o){const p=ep(e,s,a,u);p&&l.push("limit"in p?`${p.used} of ${p.limit} ${f}`:`${p.count} ${p.count===1?"call":"calls"} ${f}`)}return l.join(" · ")}function Fw(e,s,a){var u;const o=(u=a==null?void 0:a.boundsSchema)==null?void 0:u.fields;if(!e||!s||!o)return[];const l=[];for(const[f,p]of Object.entries(o)){const g=p.boundType;if(!g||g.kind!=="per_transaction")continue;const v=g.of;if(!(v in e)||!(f in s))continue;const y=Number(e[v]),w=Number(s[f]);if(!Number.isFinite(y)||!Number.isFinite(w))continue;const x=so(p.unit),b=p.displayName??Ht(v),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 Ui(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function Mw(e){const s=Ot(e),a=e.split("@")[1];return a?`${s}@${a}`:s}const Ow=["automatic","approved","all"];function Bw(e){return e==="automatic"||e==="approved"?e:"all"}function yc(e,s){return s==="all"?!0:s==="approved"?Ui(e):!Ui(e)}function $r(e,s){return Dn(e,s)}function pa(e,s){return Hn(Zm(e).integrationId,s)}function Dw(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 tp(e,s){const a=Dw(e*1e3,s);return a==="just now"?"waiting just now":`waiting ${a}`}const Uw=24*3600;function np(e,s,a){const o=e-Math.floor(s/1e3);return o<=0||o>Uw?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 rp(e){return e.replace(/-/g,"").slice(0,8)}function Ww(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 Kc(e,s){return Ww(e*1e3,s)}function Wi(e,s){return e.timestamp*1e3>s}function Hw(e,s){var l;const a=new Map;for(const u of e){if(Ui(u))continue;const f=ao(u,s.manifests),g=`${u.authorizationId??u.profileId}|${u.action}`;let v=a.get(g);v||(v={key:g,area:$r(u.profileId,s.catalog),system:pa(u.action,s.manifests),profileId:u.profileId,mandateTitle:u.authorizationId?(l=s.titles)==null?void 0:l[u.authorizationId]:void 0,label:f,count:0,newCount:0,latestSec:0,tickets:[]},a.set(g,v)),v.count+=1,Wi(u,s.lastSeenMs)&&(v.newCount+=1),v.latestSec=Math.max(v.latestSec,u.timestamp),v.tickets.push(u)}const o=[...a.values()];for(const u of o)u.tickets.sort((f,p)=>p.timestamp-f.timestamp);return o.sort((u,f)=>+(f.newCount>0)-+(u.newCount>0)||f.latestSec-u.latestSec)}function Vw(e,s){var l,u,f,p,g;const a=new Map;for(const v of e){if(!v.authorizationId||!Kc(v.timestamp,s.nowMs))continue;const y=a.get(v.authorizationId);(!y||v.timestamp>y.timestamp||v.timestamp===y.timestamp&&(((u=(l=v.cumulativeState)==null?void 0:l.daily)==null?void 0:u.count)??0)>(((p=(f=y.cumulativeState)==null?void 0:f.daily)==null?void 0:p.count)??0))&&a.set(v.authorizationId,v)}const o=[];for(const[v,y]of a){const w=ep(y,s.boundsOf(v)??y.limits,s.profileOf(y.profileId),"daily"),x={authorizationId:v,area:$r(y.profileId,s.catalog),system:pa(y.action,s.manifests),profileId:y.profileId,mandateTitle:(g=s.titles)==null?void 0:g[v]};w&&"limit"in w?o.push({...x,used:w.used,limit:w.limit,ratio:w.limit>0?w.used/w.limit:0}):o.push({...x,used:w?w.count:1,ratio:0})}return o.sort((v,y)=>y.ratio-v.ratio||v.area.localeCompare(y.area))}function dh(e){return e.ratio>=.8}function Hi(e,s,a){const o=new Date(e*1e3),l=o.toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"});return Kc(e,s)?`today ${l}`:`${o.toLocaleDateString(a,{day:"numeric",month:"short"})}, ${l}`}const Gw={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:Gw[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 ca({title:e,area:s}){return Cw(e,s)?n.jsxs("div",{className:"obj-mandate-line","data-testid":"mandate-line",children:["Mandate: ",e]}):null}async function fh(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 Kw(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
67
|
-
`).split(`
|
|
68
|
-
`).map(l=>l.replace(/[ \t]+$/,"")).join(`
|
|
69
|
-
`).replace(/\n+$/,"")}function vc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":vc(l)).join(",")+"]";const s=e,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+vc(l))}return"{"+a.join(",")+"}"}async function sp(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 fh(vc(s))}`}if(typeof s!="string")throw new Error('content_binding kind="text" expects a string, got an object');return`sha256:${await fh(Kw(s))}`}async function ap(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 qw(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 ip(e){return!e.loading&&e.readable}function op(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 ap(e);if(s)return sp("jcs",s)}function Yw(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 Jw={toolArgs:null,loading:!1,sealed:!1,undecryptable:!1};function io(e){var o;const[s,a]=h.useState(Jw);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 ap(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 hh=140,mh=60,Qw=/\{([^{}]+)\}/g;function lp(e,s){var u,f;const{integrationId:a,toolName:o}=Wn(e),l=s==null?void 0:s.find(p=>p.id===a);return((f=(u=l==null?void 0:l.toolGating)==null?void 0:u.overrides)==null?void 0:f[o])??void 0}function cp(e,s){let a=e;for(const o of s.split(".")){if(a===null||typeof a!="object")return;a=a[o]}return a}function ph(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0}function Xw(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>mh?`${l.slice(0,mh-1).trimEnd()}…`:l}function gh(e,s,a,o){let l=!1;const u=e.replace(Qw,(f,p)=>{const[g,v]=p.split("|").map(w=>w.trim()),y=g.split(",").map(w=>cp(s,w.trim())).find(ph);return ph(y)?Xw(y,v,a,o):(l=!0,"")});return l?null:u}function up(e,s,a={}){const o=cp(s,a.currencyField??"currency"),l=typeof o=="string"?o:void 0,u=e.replace(/\[([^[\]]*)\]/g,(g,v)=>gh(v,s,l,a.locale)??""),f=gh(u,s,l,a.locale);if(f===null)return null;const p=f.replace(/\s+/g," ").trim();return p.length>hh?`${p.slice(0,hh-1).trimEnd()}…`:p}function dp(e,s,a,o){var f;const l=Ht(Wn(e).toolName),u=lp(e,a);return!(u!=null&&u.summary)||!s?l:up(u.summary,s,{currencyField:(f=u.display)==null?void 0:f.currencyField,locale:o})??l}function Zw(e,s,a,o){var u;const l=lp(e,a);return!(l!=null&&l.summary)||!s?null:up(l.summary,s,{currencyField:(u=l.display)==null?void 0:u.currencyField,locale:o})}function fp({proposal:e,manifests:s}){const a=io(e);return n.jsx(n.Fragment,{children:dp(e.tool,a.toolArgs,s)})}function nc({variant:e="base",style:s,className:a,...o}){const l=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return n.jsx("span",{className:`${l}${a?` ${a}`:""}`,style:s,role:"status","aria-busy":"true","aria-label":o["aria-label"]??"Loading"})}const os=5;function ej({auths:e,activeCount:s,waiting:a,waitingReady:o}){const[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState([]),[y,w]=h.useState({}),[x,b]=h.useState({}),k=h.useCallback(()=>{L.getMyReceiptsPage({limit:200}).then(z=>u(z.receipts)).catch(()=>u(z=>z??[])),L.getLastSeenTicketsAt().then(p).catch(()=>p(Number.POSITIVE_INFINITY))},[]);Mt(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]),E=Date.now(),T=h.useMemo(()=>{const z=Date.now();return(l??[]).filter(U=>Kc(U.timestamp,z))},[l]);h.useEffect(()=>{const z=[...new Set(T.map(U=>U.profileId))].filter(U=>!(U in x));z.length!==0&&Promise.all(z.map(U=>qm(U).then(Z=>[U,Z]).catch(()=>[U,null]))).then(U=>b(Z=>({...Z,...Object.fromEntries(U)})))},[T,x]);const P=h.useMemo(()=>Hw(T,{catalog:S,manifests:g,titles:N,lastSeenMs:f??Number.POSITIVE_INFINITY}),[T,S,g,N,f]),I=T.filter(z=>yc(z,"approved")).length,B=h.useMemo(()=>Vw(T,{nowMs:Date.now(),catalog:S,manifests:g,titles:N,boundsOf:z=>{var U;return(U=y[z])==null?void 0:U.bounds},profileOf:z=>x[z]}),[T,S,g,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=np(z.expiresAt,E);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,g),time:tp(z.createdAt,E)}),n.jsx("div",{className:"appr-item-sum",children:n.jsx(fp,{proposal:z,manifests:g})}),n.jsx(ca,{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(nc,{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(nc,{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(ca,{title:z.mandateTitle,area:z.area}),n.jsxs("span",{className:"meta",children:[z.newCount>0?`${z.newCount} new`:"seen"," · latest ",Hi(z.latestSec,E)]})]})]}),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${Wi(U,f??Number.POSITIVE_INFINITY)?" is-new":""}`}),ao(U,g),n.jsxs("span",{className:"t",children:[Hi(U.timestamp,E)," · ",rp(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(nc,{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${dh(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:[dh(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 tj(){const[e,s]=h.useState(null),[a,o]=h.useState(Number.POSITIVE_INFINITY),l=h.useCallback(()=>{Promise.all([L.getReport().then(p=>p.report).catch(()=>null),L.getLastSeenReportAt().catch(()=>Number.POSITIVE_INFINITY)]).then(([p,g])=>{s(p),o(g)})},[]);if(Mt(l,3e5),Me("report-written",l),!e||!zm(e,a))return null;const{verified:u,unchecked:f}=_0(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:$0(e.renderedHtml)})," — ",n.jsx("span",{title:Di(e.coverage).title,children:Di(e.coverage).text})," · written ",Fm(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 nj(){const[e,s]=h.useState([]);return Mt(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))})]})}const rj=1800;function ea(e){return e.replace(/@.*$/,"").split("/").pop()??e}function sj(){const{domain:e}=wt(),[s,a]=h.useState([]),[o,l]=h.useState([]),[u,f]=h.useState([]),[p,g]=h.useState(!0),[v,y]=h.useState(!1),[w,x]=h.useState([]),[b,k]=h.useState(!1),[S,N]=h.useState(!1),[E,T]=h.useState(null),[P,I]=h.useState(!1),{entries:B,activeSessions:M,loading:q}=Uc(),z=jw(),U=!q,{simulation:Z}=Km(),G=Z===!0,O=kw(),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=>{g(le.configured),N(!0)}).catch(()=>N(!0)),L.getAgentContact().then(le=>{T(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),Mt(ne,3e5,e);const fe=v&&b&&S&&U&&P&&Z!==null,ee=Rm(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=Gm({hasContact:E!==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<=rj),te=o.filter(Bm),H=B.filter(le=>le.state==="running"),ie=B.filter(le=>le.state==="starting"),ue=o0(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(...i0(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 p||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(ww,{contact:E,hasDelegationMandate:X,otherMandateCount:Q,delegationProposalCount:Y,managed:O,simulationOn:G,mcpEndpoint:z}):!G&&n.jsx(vw,{aiConfigured:p,hasRunningIntegration:H.length>0,hasActiveAuth:pe.length>0,hasAgentConnected:M>0,mcpEndpoint:z})),!_&&n.jsxs(n.Fragment,{children:[n.jsx(ej,{auths:s,activeCount:pe.length,waiting:ge,waitingReady:b}),n.jsx(tj,{}),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(nj,{}),n.jsx(j0,{})]})}const aj=["Scope & Limits","Intent","Sign"];function hp({currentStep:e,onStepClick:s}){const a=Sn();return n.jsxs("div",{className:"wizard-progress",children:[n.jsx("ol",{className:"wizard-steps",children:aj.map((o,l)=>{const u=l+2,f=u<e,p=u===e,g=u-1<e,v=f&&!!s;return n.jsxs("li",{className:`wizard-step${g?" reached":""}`,"aria-current":p?"step":void 0,children:[n.jsx("button",{type:"button",className:`step-circle${f?" completed":""}${p?" current":""}`,onClick:v?()=>s(u):void 0,disabled:!v,"aria-label":`${o}${f?" (done)":p?" (current)":""}`,children:f?"✓":l+1}),n.jsx("span",{className:`step-label-text${p?" current":f?" completed":""}`,children:o})]},u)})}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>a("/mandates?new=1"),children:"Cancel"})]})}function ij({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:"})," ",Ot(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 oj({integrationId:e,field:s,value:a,onChange:o,disabled:l,onLabels:u}){const[f,p]=h.useState(null),[g,v]=h.useState(null),[y,w]=h.useState(!0);h.useEffect(()=>{let k=!1;return L.discoverScopeField(e,s).then(S=>{var N;k||(p(S.options),w(!1),(N=S.options)!=null&&N.length&&(u==null||u(Object.fromEntries(S.options.map(E=>[E.value,E.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,"…"]}):g||!f?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"msg-attention",style:{fontSize:"0.8rem",marginBottom:"0.5rem"},children:["Couldn't fetch options (",g??"no response","). Enter values manually, separated by commas."]}),n.jsx("input",{className:"form-input",type:"text",value:a,onChange: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,E=N==="reader",T=S.primary===!0;return n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:E?"var(--text-tertiary)":"var(--text-primary)",cursor:l||E?"not-allowed":"pointer"},title:E?"Read-only — you can authorize list/read but not writes":void 0,children:[n.jsx("input",{type:"checkbox",checked:x.has(String(k.value)),onChange:()=>b(String(k.value)),disabled:l||E}),n.jsx("span",{children:k.label||k.value}),T&&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 qc(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 yh(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):qc(e)===1?"1":""}function xc(e){const s=e.maximum;return typeof s=="number"&&Number.isFinite(s)?s:void 0}function vh(e,s){const a=qc(e),o=xc(e),l=s===""?a:Math.max(a,Number(s));return o!==void 0?Math.min(o,l):l}function lj(e,s){var o;const a=(o=e.capKinds)==null?void 0:o[s];return a||(e.approvers.length>0?"approval":"hard")}function Yc(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":lj(e,a)}function mp(e,s,a){const o=e.indexOf(s),l=e.indexOf(a);return o===-1||l===-1?!1:l<o}function Vi(e,s){var a;return((a=e.caps)==null?void 0:a[s])!==void 0}function cj(e,s,a){const o=Object.entries(s.caps??{}).filter(([u])=>Yc(s,a[u],u)==="approval");if(o.length===0)return null;const l=u=>{var f;return((f=a[u])==null?void 0:f.displayName)??u};for(const[u,f]of o){const p=a[u],g=p==null?void 0:p.boundType,v=(g==null?void 0:g.kind)==="per_transaction"||(g==null?void 0:g.kind)==="cumulative_sum"?g.of:void 0,y=v?e[v]:void 0;if(typeof f=="number"&&typeof y=="number"&&y>f)return{field:u,fieldLabel:l(u),cap:f,value:y}}if(o.length===1){const[u,f]=o[0];return{field:u,fieldLabel:l(u),cap:f}}return null}function uj(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Jc(e,s){return s.displayName?s.displayName:e.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function dj(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function fj(e){var a;const s=e;return!!(s.enum&&((a=s.constraint)!=null&&a.enforceable.includes("subset")))}function xh(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 hj(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function mj(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 pj(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 gj({id:e,value:s,onChange:a,disabled:o,placeholder:l,unit:u,min:f=0,max:p}){const g=hj(u),v=mj(u).filter(S=>p===void 0||S.value<=p),y=so(u),w=pj(s,u),x=s===""?null:Number(s),b=()=>{const S=s===""?0:Number(s),N=S%g,E=N===0?S+g:S+(g-N);a(String(p!==void 0?Math.min(p,E):E))},k=()=>{const S=s===""?0:Number(s);if(S<=f)return;const N=S%g,E=N===0?S-g:S-N;a(String(Math.max(f,E)))};return n.jsxs("div",{className:"bounded-input",children:[n.jsxs("div",{className:"bounded-input-field",children:[n.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:k,disabled:o||s===""||Number(s)<=f,"aria-label":"Decrease",children:"−"}),n.jsx("input",{id:e,className:"stepper-input",type:"number",min:f,max:p,step:g,value:s,placeholder:l??String(f),onChange:S=>{const N=S.target.value;a(p!==void 0&&N!==""&&Number(N)>p?String(p):N)},onFocus:S=>S.target.select(),disabled:o}),n.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:b,disabled:o||p!==void 0&&s!==""&&Number(s)>=p,"aria-label":"Increase",children:"+"}),y&&n.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:y})]}),v.length>0&&!o&&n.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:v.map(S=>n.jsx("button",{type:"button",className:`preset-chip${x===S.value?" preset-chip-selected":""}`,onClick:()=>a(String(S.value)),children:S.label},S.value))}),w&&n.jsxs("div",{className:"bounded-input-echo",children:["≈ ",w]})]})}function wh({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 yj({id:e,value:s,onChange:a,disabled:o,format:l,placeholder:u}){const[f,p]=h.useState(""),[g,v]=h.useState(!1),y=h.useRef(null),w=s?s.split(",").map(E=>E.trim()).filter(Boolean):[],x=E=>{const T=E.trim();if(!T)return;if(!xh(T,l)){v(!0);return}v(!1);const P=w.includes(T)?w:[...w,T];a(P.join(",")),p("")},b=E=>{const T=w.filter((P,I)=>I!==E);a(T.join(","))},k=E=>{E.key==="Enter"||E.key===","||E.key==="Tab"?f.trim()&&(E.preventDefault(),x(f)):E.key==="Backspace"&&!f&&w.length>0&&b(w.length-1)},S=E=>{const T=E.clipboardData.getData("text");if(T.includes(",")){E.preventDefault();const I=T.split(",").map(M=>M.trim()).filter(Boolean).filter(M=>xh(M,l)),B=[...new Set([...w,...I])];a(B.join(",")),p(""),v(!1)}},N=l==="email"?"Type email and press Enter...":"Type domain and press Enter...";return n.jsxs("div",{className:`tag-input${g?" tag-input-invalid":""}`,onClick:()=>{var E;return(E=y.current)==null?void 0:E.focus()},children:[w.map((E,T)=>n.jsxs("span",{className:"tag-pill",children:[E,!o&&n.jsx("button",{type:"button",className:"tag-remove",onClick:P=>{P.stopPropagation(),b(T)},"aria-label":`Remove ${E}`,children:"×"})]},E)),!o&&n.jsx("input",{ref:y,id:e,className:"tag-input-field",type:"text",value:f,onChange:E=>{p(E.target.value),v(!1)},onKeyDown:k,onPaste:S,onBlur:()=>{f.trim()&&x(f)},placeholder:w.length===0?u??N:""})]})}function vj({id:e,options:s,value:a,onChange:o,disabled:l}){const u=a?a.split(",").map(p=>p.trim()).filter(Boolean):[],f=p=>{const g=u.includes(p)?u.filter(v=>v!==p):[...u,p];o(g.join(","))};return n.jsx("div",{className:"checkbox-group",id:e,children:s.map(p=>n.jsxs("label",{className:`checkbox-pill${u.includes(p)?" checkbox-pill-selected":""}`,children:[n.jsx("input",{type:"checkbox",checked:u.includes(p),onChange:()=>f(p),disabled:l}),n.jsx("span",{children:p})]},p))})}function jh({fieldKey:e,fieldDef:s,value:a,onChange:o,prefix:l,readOnly:u,twoColumn:f,discoveryIntegrationId:p,onLabels:g,capMax:v,enumAllowedFrom:y}){const w=Jc(e,s),x=`${l}-field-${e}`,b=n.jsx(n.Fragment,{children:fj(s)?n.jsx(vj,{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(gj,{id:x,value:a,onChange:k=>o(e,k),disabled:u,unit:s.unit,min:qc(s),max:v!==void 0?Math.min(v,xc(s)??v):xc(s)}):dj(s)?n.jsx(yj,{id:x,value:a,onChange:k=>o(e,k),disabled:u,format:s.format}):p?n.jsx(oj,{integrationId:p,field:e,value:a,onChange:k=>o(e,k),disabled:u,onLabels:k=>g==null?void 0:g(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(wh,{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(wh,{htmlFor:x,label:w,description:s.description}),b]},`${l}-${e}`)}function xj(e,s,a,o){if(!o||!Vi(o,e))return null;const l=o.caps[e],u=Yc(o,s,e);let f=!1;if(typeof l=="number"){const p=a===""?NaN:Number(a);f=!Number.isNaN(p)&&p>l}else if(typeof l=="string"&&a!==""){const p=s.boundType;f=(p==null?void 0:p.kind)==="enum"?mp(p.values??[],l,a):!1}return{kind:u,cap:l,violating:f}}function Sh(e,s,a,o){if(!o||!Vi(o,e))return a;const l=Yc(o,s,e),u=o.caps[e];if(l!=="hard")return a;if(typeof u=="number"){const f=a===""?NaN:Number(a);return String(Number.isNaN(f)?u:Math.min(f,u))}if(typeof u=="string"){const f=s.boundType,p=(f==null?void 0:f.kind)==="enum"?f.values??[]:[];return a!==""&&mp(p,u,a)?u:a}return a}function wj(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 jj(e,s){return so(s.unit)||Jc(e,s).toLowerCase()}function pp(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 Sj(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 — ",Jc(e,s).toLowerCase()," is capped at"," ",String(a.cap)," for this profile."]}):n.jsxs("span",{className:"cap-note hard","data-testid":`cap-note-${e}`,children:["Team limit ",String(a.cap),u?" — read limits are always hard, no approval path exists for this cap.":""]});const p=jj(e,s),g=pp(o,l);return n.jsxs("span",{className:"cap-note soft","data-testid":`cap-note-${e}`,children:["Every ",p," above ",String(a.cap)," goes to ",g," for approval."]})}function bj({profile:e,onConfirm:s,onCancel:a,readOnly:o,initialBounds:l,initialContext:u,initialFrame:f,profileConfig:p,approverNames:g,adminName:v}){var te;const y=e.boundsSchema,w=e.scopeSchema,x=H=>!!p&&Vi(p,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??{},E=u??{},T={};for(const[H,ie]of b)T[H]=Sh(H,ie,yh(ie,N[H]),p);const P={};for(const[H]of S)P[H]=E[H]!==void 0?String(E[H]):"";const[I,B]=h.useState(T),[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]:yh(ve,N[ge]),qe=Sh(ge,ve,le,p);ue[ge]!==qe&&(ue[ge]=qe,ie=!0)}return ie?ue:H})},[p]);const[G,O]=h.useState(null);h.useEffect(()=>{const H=uj(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]=xj(H,ie,I[H]??"",p);const fe=Object.entries(ne).filter(([,H])=>(H==null?void 0:H.kind)==="hard"&&H.violating).map(([H])=>H),ee=!!p&&(((te=p.approvers)==null?void 0:te.length)??0)>0&&b.every(([H])=>!Vi(p,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]=vh(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]=vh(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=pp(p,g);return n.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--accent)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[n.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",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(jh,{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(jh,{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"?wj(ie,ue.cap):void 0}),ue&&n.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:Sj(H,ie,ue,p,g)})]},`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 kj(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 Nj(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Cj="Tell me what your agent should do — I'll help shape it. Or ask me to draft a full intent and we'll iterate.";function Gi({target:e,currentText:s,onApply:a,greeting:o,placeholder:l,title:u}){const[f,p]=h.useState([{role:"assistant",content:o??Cj}]),[g,v]=h.useState(""),[y,w]=h.useState(!1),[x,b]=h.useState(null),k=h.useRef(null),S=h.useRef(null);h.useEffect(()=>{const T=k.current;if(!T)return;const P=f[f.length-1],I=S.current;!y&&(P==null?void 0:P.role)==="assistant"&&f.length>1&&I?T.scrollTop=I.offsetTop:T.scrollTop=T.scrollHeight},[f,y]);const N=async()=>{const T=g.trim();if(!T||y)return;const P=[...f,{role:"user",content:T}];p(P),v(""),b(null),w(!0);try{const I=await L.aiChat({target:e,currentText:s,messages:P.filter((B,M)=>!(M===0&&B.role==="assistant"))});I.success&&I.reply?p(B=>[...B,{role:"assistant",content:I.reply}]):b(I.error??"AI returned no reply")}catch(I){b(I instanceof Error?I.message:"Chat failed")}finally{w(!1)}},E=T=>{T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),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((T,P)=>{const I=T.role==="assistant"?kj(T.content):null,B=I?Nj(T.content):T.content;return n.jsx("div",{className:`chat-msg ${T.role}`,ref:P===f.length-1?S:void 0,children:n.jsxs("div",{className:"chat-msg-body",children:[B&&n.jsx("div",{className:"chat-msg-prose",children:B}),I!==null&&n.jsxs(n.Fragment,{children:[n.jsx("pre",{className:"chat-fenced-block",children:I}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>a(I),children:"Apply this draft"})]})]})},P)}),y&&n.jsx("div",{className:"chat-msg assistant",children:n.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),x&&n.jsx("div",{className:"error-message",children:x}),n.jsxs("div",{className:"chat-composer",children:[n.jsxs("div",{className:"chat-composer-pill",children:[n.jsx("textarea",{className:"chat-input",value:g,onChange:T=>v(T.target.value),onKeyDown:E,placeholder:l??"Ask for help articulating the intent…",rows:1,disabled:y}),n.jsx("button",{type:"button",className:"chat-send-btn",onClick:N,disabled:y||!g.trim(),"aria-label":"Send",children:"↑"})]}),n.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function gp({open:e,onClose:s,children:a,ariaLabel:o}){const l=h.useRef(null),u=h.useRef(null);return h.useEffect(()=>{var p;if(!e)return;u.current=document.activeElement,document.body.style.overflow="hidden";const f=g=>{g.key==="Escape"&&s()};return document.addEventListener("keydown",f),(p=l.current)==null||p.focus(),()=>{document.removeEventListener("keydown",f),document.body.style.overflow="",u.current instanceof HTMLElement&&u.current.focus()}},[e,s]),Dx.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 Ej(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Tj(e,s,a){if(s.length===0)return[{text:e,label:e,matched:null}];const o=[],l=new Set;for(const g of s)if(!(!g.scope||g.scope==="all (unscoped)"))for(const v of[g.scope,...g.scope.split(",").map(y=>y.trim())]){const y=v.toLowerCase();v&&!l.has(y)&&(l.add(y),o.push(v))}o.sort((g,v)=>v.length-g.length);const u=g=>{const v=g.toLowerCase();return s.filter(y=>{var w,x;return((w=y.scope)==null?void 0:w.toLowerCase())===v||((x=y.scope)==null?void 0:x.split(",").map(b=>b.trim().toLowerCase()).includes(v))})},f=["\\[\\d+\\]",...o.map(Ej)],p=new RegExp(`(${f.join("|")})`,"gi");return e.split(p).filter(g=>g!=="").map(g=>{const v=/^\[(\d+)\]$/.exec(g);if(v){const y=s[Number(v[1])-1];if(y){const w=y.scope&&y.scope!=="all (unscoped)"?y.scope:"all recipients",x=a?`${a}: ${w}`:w;return{text:g,label:x,matched:[y]}}}else if(o.some(y=>y.toLowerCase()===g.toLowerCase())){const y=u(g);if(y.length>0)return{text:g,label:g,matched:y}}return{text:g,label:g,matched:null}})}const bh=`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 Aj(e,s,a,o){return Tj(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 Ij(){var be;const e=Sn(),[s]=gs(),a=Number(s.get("step"))||2,[o,l]=h.useState(null),[u,f]=h.useState(null),[p,g]=h.useState(a),[v,y]=h.useState(null),[w,x]=h.useState(null),[b,k]=h.useState({}),[S,N]=h.useState(bh),[E,T]=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),g(3)},ue=S.trim()!==bh.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(hp,{currentStep:p,onStepClick:oe=>{oe>=2&&g(oe)}}),n.jsx(ij,{profileId:o.profileId,bounds:H||void 0,groupName:o.groupName,domain:o.domain}),p===2&&n.jsx("div",{className:"card",children:n.jsx(bj,{profile:u,onConfirm:ie,onCancel:()=>e("/mandates?new=1"),initialBounds:v||void 0,initialContext:w||void 0,profileConfig:q,approverNames:U,adminName:G})}),p===3&&n.jsxs("div",{className:`intent-layout${P?"":" no-chat"}`,children:[P&&n.jsx("div",{className:"card intent-pane chat tool",children:n.jsx(Gi,{target:{kind:"intent",profileId:o.profileId,bounds: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:Aj(ee,A,te,Ot(o.profileId))}),n.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),n.jsxs("div",{className:"intent-footer",children:[n.jsx("button",{className:"btn btn-ghost",onClick:()=>g(2),children:"Back"}),n.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick: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:()=>T(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),n.jsx(gp,{open:E,onClose:()=>T(!1),ariaLabel:"Intent assistant",children:n.jsx(Gi,{target:{kind:"intent",profileId:o.profileId,bounds:H||void 0},currentText:S,onApply:oe=>{ge(oe),T(!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 Rj(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
74
|
-
`).split(`
|
|
75
|
-
`).map(l=>l.replace(/[ \t]+$/,"")).join(`
|
|
76
|
-
`).replace(/\n+$/,"")}async function Qc(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 Pj extends Error{constructor(a,o,l){super(l);Qs(this,"code");Qs(this,"field");this.name="CanonicalValueError",this.code=a,this.field=o}}function $j(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 yp(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 Pj(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}=${$j(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=yp(e,a.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await Qc(o)}`}async function vp(e,s){const a=s.scopeSchema?yp(e,s.scopeSchema.keyOrder,"SCOPE_INVALID_VALUE"):"";return`sha256:${await Qc(a)}`}function wc(e){if(e===void 0)throw new Error("canonicalize: undefined is not serializable");if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`canonicalize: ${e} is not a valid JSON number`);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(l=>l===void 0?"null":wc(l)).join(",")+"]";const s=e,a=[];for(const o of Object.keys(s).sort()){const l=s[o];l!==void 0&&a.push(JSON.stringify(o)+":"+wc(l))}return"{"+a.join(",")+"}"}async function xp(e){return`sha256:${await Qc(wc(e))}`}async function Ki(e){const s=new TextEncoder().encode(Rj(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 wp(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 _j(e){const s=e.commitment_modes;return s===void 0?["review","automatic"]:Array.isArray(s)?["review","automatic"].filter(a=>s.includes(a)):[]}function Lj(e){return e==="per-action"?"review":"automatic"}function kh(e){return e?_j(e).map(s=>s==="review"?"per-action":"immediate"):["per-action","immediate"]}function zj(e,s){return s.includes(e)?e:s[0]??null}function Nh(e){return e==null?new Set:new Set(String(e).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean))}function Fj(e,s){for(const a of e)if(s.has(a))return!0;return!1}function Mj(e,s,a){for(const o of e){const l=Nh(s[o]),u=Nh(a[o]);if(!(l.size===0||u.size===0)&&!Fj(l,u))return!1}return!0}function Oj(e){return e.length>24?`${e.slice(0,10)}…`:e}function jp(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} (${Oj(u)})`:u}).join(", ")}function Sp(e){var l;if(e.isPersonal)return{can:!0};if(!e.configLoaded)return{can:!0};const s=e.teamName?`"${e.teamName}"`:"this team";return e.grantors!=="all"&&(((l=e.grantors)==null?void 0:l.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${s}.`,fix:`Ask an admin of ${s} to enable ${e.profileName} and name who may give its mandates.`}:e.grantors==="all"||!!e.userId&&e.grantors.includes(e.userId)?{can:!0}:{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${e.profileName}'s grantors in ${s} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}}const qi=500,Bj=["Lower the discount","Other recipient","Shorter","Different wording"];function Xc(e){const s=e.trim();return s.length===0?{valid:!1,error:"Describe what should change."}:s.length>qi?{valid:!1,error:`At most ${qi} characters (currently ${s.length}).`}:{valid:!0,trimmed:s}}function Dj(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bp(e,s){return e.toLowerCase().includes(s.toLowerCase())}function Uj(e,s){const a=e.trim();if(a.length===0)return s;if(!bp(a,s))return`${a}. ${s}`;const o=new RegExp(`\\.?\\s*${Dj(s)}\\.?`,"i");return a.replace(o,"").replace(/\s{2,}/g," ").replace(/^\.\s*/,"").trim()}function kp(){return{outcome:"rejected"}}function Wj(e){const s=Xc(e);if(!s.valid)throw new Error(s.error);return{outcome:"change_needed",note:s.trimmed}}function Ch(){return{outcome:"replaced"}}function Hj(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 Vj={rejected:"REJECTED",change_needed:"CHANGE NEEDED",replaced:"REPLACED"};function Gj(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:Vj[o],who:a.userId===s?"You":a.userId,at:a.at,note:l}}function Kj(e){return e.refusal?{kind:"REFUSED",at:e.refusal.at,message:e.refusal.message}:null}function qj(){var Oe,K;const e=Sn(),{user:s,mode:a,domain:o}=wt(),[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState(null),[y,w]=h.useState("per-action"),[x,b]=h.useState(1800),[k,S]=h.useState(86400),[N,E]=h.useState(""),[T,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 Bt;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),p(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 Vt=((Bt=Ve.ttlConfig)==null?void 0:Bt.max)??86400;if(typeof Ve.templateTtl=="number"&&Ve.templateTtl>0){const et=Math.min(Ve.templateTtl,Vt);b(et),[3600,86400,604800,2592e3,31536e3].includes(et)||(et%86400===0?(E(String(et/86400)),P("days")):(E(String(Math.max(1,Math.round(et/3600)))),P("hours")))}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(!g)return;const J=zj(y,kh(g));J&&J!==y&&w(J)},[g,y]),h.useEffect(()=>{if(!f||!g||Y.length===0){se(0);return}let J=!1;return(async()=>{const ye=await zi(f.bounds,g),He=await Promise.all(Y.map(Ve=>zi(Ve.bounds,g).catch(()=>null)));J||se(He.filter(Ve=>Ve===ye).length)})().catch(()=>{J||se(0)}),()=>{J=!0}},[f,g,Y]);const te=async()=>{if(!(!l||!f||!g||!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,g),He=await vp(f.context,g),[Ve,rt]=await Promise.all([Ki(f.gateContent.intent),Ki(JSON.stringify({profile:l.profileId,domain:J,group:l.groupId}))]);let Vt,Bt,et,W;if(l.isTeam){const St=await L.getApproversPubkeys(l.groupId,l.profileId);if(St.length>0){const Zt=await L.encryptIntent(f.gateContent.intent,St);Vt=Zt.intentCiphertext,Bt=Zt.encryptedKeys,et=Zt.approversFrozen,W=Zt.intentDisclosureHash}}const xe=`authz_${crypto.randomUUID()}`,Ae=sessionStorage.getItem("agentEditReplaces")||void 0,st=sessionStorage.getItem("agentReplacesProposal")||void 0,yt=await xp(g),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:Lj(y),title:I.trim(),intent_ciphertext:Vt,encrypted_keys:Bt,approvers_frozen:et,intent_disclosure_hash:W,disclose_identity:M});try{await L.pushGateContent(wp(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 Zt=Hj(St,(s==null?void 0:s.id)??"");Zt?Zt.route==="approver"?await L.rejectProposal(st,Ch()):await L.resolveProposal(st,"reject",Zt.domain,Ch()):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=Sp({isPersonal:l.isPersonal,configLoaded:X,grantors:fe?Nm(fe):void 0,userId:s==null?void 0:s.id,profileName:Ot(l.profileId),teamName:l.groupName}),Le=!oe.can,ze=kh(g),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=g==null?void 0:g.scopeSchema)==null?void 0:K.keyOrder)??[],We=Y.filter(J=>Mj(Ye,f.context,J.context)),dt=We.length>0,ft=Ot(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(hp,{currentStep:4,onStepClick:J=>{J<=3&&e(`/mandates/new/intent?step=${J}`)}}),n.jsxs("div",{className:"card",children:[n.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),n.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),l.upgradedFromProfileId&&g&&n.jsxs("div",{className:"hint-box",role:"note",style:{marginBottom:"1rem"},children:[n.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),n.jsxs("div",{className:"hint-body",children:["Updated to ",Ot(l.profileId)," ",g.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. ${Ot(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),E("")},style:{padding:"0.5rem 0.85rem",border:x===J.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:x===J.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:J.label},J.seconds)),n.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[n.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:N,onChange:J=>{E(J.target.value);const ye=parseInt(J.target.value,10);if(ye>0){const He=T==="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:T,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:jp(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:[Ot(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 Yj={card:"💳",mail:"✉️"};function Np(e){return Yj[e]??"🔧"}function Cp(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 Eh(e,s){const a=new Map;for(const o of e)for(const l of Cp(o.manifest)){let u=a.get(l);u||(u={shortId:l,icon:Pr(l),name:Dn(l,s),entries:[]},a.set(l,u)),u.entries.push(o)}return[...a.values()].sort((o,l)=>o.name.localeCompare(l.name))}function Jj(e,s){if(!s)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const a=e.filter(f=>Oi(f.manifest)&&!Bi(f,s)),o=e.filter(f=>!Oi(f.manifest)||Bi(f,s)),l=o.filter(f=>f.state==="error"),u=o.filter(f=>f.state!=="error");return{grouped:!0,testSystems:a,realErrors:l,pausedReal:u,ungrouped:[]}}function Qj(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 Xj=[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 Zj(e){return(e==null?void 0:e.paused)==="simulation"?{chip:{c:"int-chip-paused",t:"Paused"},showStart:!1}:e&&!e.running&&e.error?{chip:{c:"int-chip-bad",t:"Crashed"},showStart:!0}:{chip:{c:"int-chip-idle",t:"Stopped"},showStart:!0}}function rc({manifest:e,integration:s,state:a,onStatusChange:o,onSuccess:l}){var Fe;const[u,f]=h.useState({}),[p,g]=h.useState(!1),[v,y]=h.useState(!1),[w,x]=h.useState({}),[b,k]=h.useState({}),[S,N]=h.useState(void 0),[E,T]=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(g(!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;T(K),K&&L.getOAuthHealth(e.id).then(J=>{me||I(J)})}}}).catch(()=>{}),()=>{me=!0}},[e.id,e.oauth]);const se=Qj(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?E:p,ve=!ue||ge,le=a==="starting"?"starting":ve?s!=null&&s.running?"running":!p&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&p&&!E?"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),g(!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({}),g(!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))&&(T(!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=Np(e.icon),Ze=Zj(s),Ye=le==="running"?{c:"int-chip-ok",t:"Running"}:le==="starting"?{c:"int-chip-idle",t:"Starting"}:Ze.chip,We=e.oauth&&E&&(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.jsxs("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:[e.name,Qf(e,w)&&n.jsxs("span",{style:{fontWeight:400,color:"var(--text-muted)"},children:[" · ",Qf(e,w)]}),Xf(e,w)&&n.jsx("span",{className:"card-mode-note","data-testid":"integration-mode-note",children:Xf(e,w)})]}),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]}),a0(e,w)&&n.jsxs("span",{className:"int-chip int-chip-sim",title:"This connector answers from a simulated system with test data. Nothing reaches your real systems.",children:[n.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),e.oauth&&E&&n.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:P!=null&&P.account?n.jsxs(n.Fragment,{children:["Connected as ",n.jsx("b",{children:P.account})]}):n.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),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:Cp(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:[Xj.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:()=>{g(!0),e.oauth&&T(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),e.setupHint&&!v&&n.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(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:()=>g(!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:()=>g(!1),children:"Update Credentials"}),e.oauth&&n.jsx("button",{className:"btn btn-ghost",onClick:()=>{g(!1),T(!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 Th({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 eS({entry:e}){return n.jsxs("div",{className:"int-paused-row",children:[n.jsx("span",{"aria-hidden":"true",children:Np(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 tS(){const{loading:e,mcpServerUp:s,manifestsError:a,entries:o,refresh:l}=Uc(),u=Dc(),[f,p]=h.useState(""),g=Lr(),v=h.useCallback(w=>{p(w),setTimeout(()=>p(""),5e3)},[]),y=Jj(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"}),Eh(y.testSystems,g).map(w=>n.jsx(Th,{group:w,children:w.entries.map(x=>n.jsx(rc,{manifest:x.manifest,integration:x.integration,state:x.state,onStatusChange:l,onSuccess:v},x.id))},w.shortId))]}),(y.realErrors.length>0||y.pausedReal.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"int-group-label",children:"Real systems"}),y.realErrors.map(w=>n.jsx(rc,{manifest:w.manifest,integration:w.integration,state:w.state,onStatusChange:l,onSuccess:v},w.id)),y.pausedReal.length>0&&n.jsxs("details",{className:"int-paused-group",open:!0,children:[n.jsxs("summary",{children:["Paused while simulation mode is on (",y.pausedReal.length,")"]}),n.jsxs("p",{className:"int-paused-group-note",children:["Nothing is lost — mandates, credentials and data stay. They start again when simulation mode is switched off (",n.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),y.pausedReal.map(w=>n.jsx(eS,{entry:w},w.id))]})]}),o.length===0&&n.jsx(Ah,{manifestsError:a})]}):n.jsxs(n.Fragment,{children:[Eh(o,g).map(w=>n.jsx(Th,{group:w,children:w.entries.map(x=>n.jsx(rc,{manifest:x.manifest,integration:x.integration,state:x.state,onStatusChange:l,onSuccess:v},x.id))},w.shortId)),o.length===0&&n.jsx(Ah,{manifestsError:a})]})]})}function Ah({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 nS(){var O,ne,fe;const{activeTeam:e,activeMembership:s,refreshGroups:a,user:o}=wt(),l=Sn(),[u,f]=h.useState(null),[p,g]=h.useState(!1),[v,y]=h.useState(""),[w,x]=h.useState(""),[b,k]=h.useState(!1),[S,N]=h.useState(""),[E,T]=h.useState("");h.useEffect(()=>{fetch("/health").then(ee=>ee.json()).then(ee=>{typeof ee.spUrl=="string"&&T(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&&!p,q=()=>{N(""),k(!0)},z=()=>{k(!1),N("")},U=async()=>{if(!(!e||!M)){g(!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{g(!1)}}},Z=e&&E?`${E}/dashboard/groups/${e.id}`:void 0,G=E?`${E}/dashboard/groups`:void 0;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"page-header",children:n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:"Team"}),n.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),v&&n.jsx("div",{className:"error-message",children:v}),w&&n.jsx("div",{className:"alert alert-success",children:w}),e?n.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[n.jsxs("div",{className:"card-header",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"card-title",children:e.name}),n.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((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:p||I,children:"Leave team"})})]})]}):n.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[n.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),n.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",maxWidth:480,marginLeft:"auto",marginRight:"auto"},children:"Every mandate you create here is in your personal context. An account is Personal or in one team — joining or creating a team moves it."}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",justifyContent:"center",flexWrap:"wrap"},children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>l("/onboarding"),children:"Join or create a team"}),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:p,autoFocus:!0})]}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick:z,disabled:p,children:"Cancel"}),n.jsx("button",{className:"btn btn-outline-strong",onClick:U,disabled:!M,children:p?"Leaving...":"Leave team"})]})]})})]})}function Zc({areas:e,selected:s,onSelect:a,totalCount:o}){return e.length<2?null:n.jsxs("div",{className:"ftabs",role:"tablist","aria-label":"Which area","data-testid":"area-filter",children:[n.jsxs("button",{type:"button",role:"tab",className:"ftab","aria-selected":s===null,onClick:()=>a(null),children:["All ",n.jsx("span",{className:"n",children:o})]}),e.map(l=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`area-filter-${l.shortId}`,"aria-selected":s===l.shortId,onClick:()=>a(s===l.shortId?null:l.shortId),children:[n.jsx(ga,{icon:l.icon})," ",l.name," ",n.jsx("span",{className:"n",children:l.count})]},l.shortId))]})}const dr=e=>e.replace(/@.*$/,"").split("/").pop()??e,Ih=e=>e.split("@")[1]??"";function Rh(e){var a;const s=e.profile?[dr(e.profile)]:[];for(const o of Object.values(((a=e.toolGating)==null?void 0:a.overrides)??{})){const l=o==null?void 0:o.profile;l&&!s.includes(dr(l))&&s.push(dr(l))}return s}function rS(e,s){const a=new Map;for(const o of e){const l=dr(o.id);if(!s.has(l))continue;const u=a.get(l);(!u||Ih(o.id).localeCompare(Ih(u.id),void 0,{numeric:!0})>0)&&a.set(l,o)}return a}function sS(e,s,a,o){var p;const l=new Set([...s.flatMap(g=>Rh(g)),...o.map(g=>dr(g.profile))]),u=rS(e,l),f=[];for(const g of s){const v=Rh(g);for(const[y,w]of v.entries()){const x=u.get(w);x&&f.push({key:y===0?`connector:${g.id}`:`connector:${g.id}:${w}`,name:v.length>1?`${g.name} — ${x.name??w}`:g.name,description:g.description||x.description,profile:x,kind:"connector",ready:((p=a.find(b=>b.id===g.id))==null?void 0:p.running)===!0,setupId:g.id,...g.intentHint&&y===0?{intentHint:g.intentHint}:{}})}}for(const g of o){const v=u.get(dr(g.profile));v&&f.push({key:`builtin:${g.id}`,name:g.name,description:g.description||v.description,profile:v,kind:"builtin",ready:g.available,unavailableReason:g.available?void 0:"Available only while simulation mode is on.",...g.intentHint?{intentHint:g.intentHint}:{}})}return f}function aS(e,s,a){if(s)return e.find(o=>dr(o.profile.id)===dr(s)&&o.ready&&a(o))}function Ep({icon:e,className:s}){return n.jsx(ga,{icon:e,className:s})}function iS({onDismiss:e,preselectProfileId:s}){const a=Sn(),{group:o,groupId:l,domain:u,user:f}=wt(),[p,g]=h.useState([]),[v,y]=h.useState([]),[w,x]=h.useState([]),[b,k]=h.useState([]),[S,N]=h.useState(!0),[E,T]=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(g(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)}),T(ne)}}).finally(()=>N(!1))},[l]);const P=sS(p,v,w,b),I=U=>{const Z=E[U.id];return Sp({isPersonal:!!(o!=null&&o.isPersonal),configLoaded:!S,grantors:Z?Nm(Z):void 0,userId:f==null?void 0:f.id,profileName:Ot(U.id),teamName:o==null?void 0:o.name})},B=U=>U in E,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=aS(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(Ep,{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 oS={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function lS({status:e,label:s}){return n.jsx("span",{className:`status-badge status-${e}`,children:s||oS[e]})}function cS({domain:e,attested:s}){const a=s===!0?"domain-attested":s===!1?"domain-missing":"";return n.jsx("span",{className:`domain-badge ${a}`,style:{fontSize:"0.75rem"},children:e})}const Tr=86400,aa=3600,Ii=60,uS=30*Tr;function dS(e){if(e<=0)return"Expired";if(e>90*Tr){const s=Math.floor(e/uS);return`${s} ${s===1?"month":"months"} remaining`}if(e>7*Tr){const s=Math.floor(e/Tr);return`${s} ${s===1?"day":"days"} remaining`}if(e>=2*Tr){const s=Math.floor(e/Tr),a=Math.floor(e%Tr/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 fS({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:dS(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 hS(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 mS=[{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 pS({item:e,onClose:s,onSuccess:a}){var P;const{user:o,activeDomain:l,groupId:u}=wt(),[f,p]=h.useState(null);h.useEffect(()=>{let I=!1;return L.getProfile(e.profile_id).then(B=>{var M;I||p(((M=B==null?void 0:B.ttl)==null?void 0:M.max)??null)}).catch(()=>{}),()=>{I=!0}},[e.profile_id]);const g=e.remaining_seconds??0,v=mS.filter(I=>I.seconds>g&&(f===null||I.seconds<=f)),y=((P=v[0])==null?void 0:P.seconds)??2592e3,[w,x]=h.useState(y);h.useEffect(()=>{var I;if(f!==null&&w>f){const B=(I=v[v.length-1])==null?void 0:I.seconds;B&&x(B)}},[f]);const[b,k]=h.useState(!1),[S,N]=h.useState(""),E=Object.entries(e.frame).filter(([I])=>I!=="profile"&&I!=="path"),T=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 vp(U,q),[ne,fe]=await Promise.all([Ki(M.gateContent.intent),Ki(JSON.stringify({profile:e.profile_id,path:e.path,domain:Z}))]);if(!u)throw new Error("No active group; cannot extend mandate.");const ee=(((I=e.deferred_commitment_domains)==null?void 0:I.length)??0)>0?"review":"automatic",pe=await xp(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(wp(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:[Ot(e.profile_id)," / ",e.path]}),E.length>0&&n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:E.map(([I,B])=>`${I}=${B}`).join(" · ")})]}),n.jsxs("div",{style:{marginBottom:"1rem"},children:[n.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),g>0&&n.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",hS(g),". Only longer durations are shown."]}),n.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:v.length===0?n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):v.map(I=>n.jsx("button",{className:`btn ${w===I.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>x(I.seconds),style:{minWidth:"3.5rem"},children:I.label},I.seconds))})]}),n.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, scope, and gate content will be re-signed with a new TTL (measured from now)."}),S&&n.jsx("div",{className:"error-message",children:S})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-secondary",onClick:s,disabled:b,children:"Cancel"}),n.jsx("button",{className:"btn btn-primary",onClick:T,disabled:b,children:b?"Extending...":"Extend"})]})]})})}function Ph(e){return e.replace(/@.*$/,"").split("/").pop()??e}function $h(e){return e.split("@")[1]??""}function gS(e,s){return $h(e).localeCompare($h(s),void 0,{numeric:!0})>0}function Tp(e,s){const a=Ph(e);let o;for(const l of s)Ph(l.id)===a&&(!o||gS(l.id,o.id))&&(o=l);return o}function Ap(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 Ip(e,s){return Ap(e,s.boundsSchema)}function Rp(e,s){return Ap(e,s.scopeSchema)}function yS(e,s,a){return[...e].sort((o,l)=>{if(a){if(o.authorization_id===a&&l.authorization_id!==a)return-1;if(l.authorization_id===a&&o.authorization_id!==a)return 1}const u=Mi(o,s),f=Mi(l,s),p={active:0,pending:1,expired:2,revoked:3,archived:4};return p[u]!==p[f]?p[u]-p[f]:new Date(l.created_at).getTime()-new Date(o.created_at).getTime()})}function vS({item:e,newerProfile:s,area:a,revokedSet:o,expandedHash:l,gateCache:u,gateLoading:f,copiedHash:p,revokingHash:g,copyingHash:v,profileConfigCache:y,mode:w,ownerLabel:x,isAdmin:b,onExpand:k,onCopyHash:S,onCopy:N,onRevoke:E,onExtend:T,archivedSet:P,archivingHash:I,onArchive:B,highlightHash:M,needsReapprovalSet:q}){var qe;const z=Bc(e,{revokedSet:o}),U=z==="active"&&((q==null?void 0:q.has(e.authorization_id))??!1),Z=Im(e,{revokedSet:o,archivedSet:P}),G=!x&&!!B&&Am(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(lS,{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(fS,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),z==="expired"&&(()=>{const be=s0(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(cS,{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:jp(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:p===e.authorization_id?"copied":"copy"})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!x&&n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>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:()=>T(e),children:"↻ Extend"}),x&&b&&z!=="revoked"?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>E(e.authorization_id,x,ge),disabled:g===e.authorization_id,children:g===e.authorization_id?"Revoking…":"Revoke"}):!x&&(z==="active"||z==="pending")?n.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>E(e.authorization_id),disabled:g===e.authorization_id,children:g===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]})},e.authorization_id)}function xS(){const[e,s]=h.useState([]),[a,o]=h.useState(!0),[l,u]=h.useState([]),[f,p]=h.useState(!1),[g,v]=h.useState(new Map),[y,w]=h.useState("mine"),[x,b]=h.useState("active"),[k,S]=h.useState(null),[N,E]=h.useState(null),[T,P]=gs(),[I,B]=h.useState(()=>T.get("new")==="1"),[M]=h.useState(()=>T.get("profile")),[q,z]=h.useState(()=>T.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&&(p(!0),L.listTeamAuthorizations(oe).then(u).catch(()=>{}).finally(()=>p(!1)))},[oe]);Me("attestation-changed",()=>{dt(),we&&oe&&Re(),Fe()}),h.useEffect(()=>{if(!q)return;T.get("highlight")&&(T.delete("highlight"),P(T,{replace:!0}));const de=window.setTimeout(()=>z(null),3e3);return()=>window.clearTimeout(de)},[]),Mt(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=g.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},[g]),K=h.useCallback(de=>Dn(de,[...g.values()]),[g]);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)??"",hr=de.deferred_commitment_domains.length>0?"review":"automatic",Fr=de.attested_domains[0]||Le||"owner",Vn=Date.parse(de.created_at),mr=de.earliest_expiry?Date.parse(de.earliest_expiry):NaN,lo=Number.isFinite(Vn)&&Number.isFinite(mr)&&mr>Vn?Math.round((mr-Vn)/1e3):void 0;let ya=de.profile_id,va=Ct,bn=Pt,ys;const xa=await L.listProfiles(),Mr=Tp(de.profile_id,xa);if(Mr&&Mr.id!==de.profile_id){const kn=await L.getProfile(Mr.id);ya=Mr.id,va=Ip(Ct,kn),bn=Rp(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:hr,templateTtl:lo})),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,Vt=y==="mine"?a:f,Bt=y==="mine"?{revokedSet:Q,archivedSet:se}:{revokedSet:Q},et=de=>Mi(de,Bt),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=yS(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}),Bt,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},Zt={...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),(T.get("new")||T.get("profile"))&&(T.delete("new"),T.delete("profile"),P(T,{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),(T.get("new")||T.get("profile"))&&(T.delete("new"),T.delete("profile"),P(T,{replace:!0}))},children:"×"})]}),n.jsxs("div",{className:"modal-body",children:[n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem",marginTop:0,marginBottom:"1rem"},children:"What should your agent be able to do? Pick a profile, set limits, then authorize."}),n.jsx(iS,{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),E(null),Z(null)},children:"Mine"}),n.jsx("button",{className:`nav-tab${y==="team"?" active":""}`,onClick:()=>{w("team"),b("active"),S(null),E(null),Z(null)},children:"Team"})]}),n.jsx("div",{className:"nav-tabs",children:xe.map(de=>n.jsxs("button",{className:`nav-tab${x===de?" active":""}`,onClick:()=>{b(de),S(null),E(null)},children:[de.charAt(0).toUpperCase()+de.slice(1)," (",W[de],")"]},de))}),st>0&&n.jsxs("div",{className:"mandate-filters",children:[n.jsx(Zc,{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:()=>E(Ce?null:de),children:de==="auto"?"Automatic":"Review"},de)})})]}),Vt&&rt.length===0?n.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):yt.length===0?n.jsx(fs,{icon:"☰",title:"No mandates",text:x==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${x} mandates found.`}):n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children: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(vS,{item:Ce,newerProfile:Oe(Ce.profile_id),area:de.name,ownerLabel:Be,isAdmin:we,...y==="mine"?Zt:St},Ce.authorization_id)})})]},de.shortId))}),ee&&n.jsx(pS,{item:ee,onClose:()=>pe(null),onSuccess:()=>{pe(null),dt()}})]})}function Pp(e){const s=e.approved?e.proposalArgs:e.sentArgs;return Zw(e.tool,s??null,e.manifests)??e.label}function wS(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?jS(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 jS(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 $p(e,s,a){return Xm(e,s).map(o=>{var l;return{...o,inTicket:bS(o.value,(l=s==null?void 0:s.executionMapping)==null?void 0:l[o.key],a)}})}function SS(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 bS(e,s,a){return!s||!a||e===void 0||e===null?!1:(typeof s=="string"?[{field:s}]:Array.isArray(s)?s:[s]).some(l=>{if(!(l.field in a))return!1;const u=a[l.field];return l.divisor?Number.isFinite(Number(e))&&Number(e)/l.divisor===Number(u):l.transform==="join"?(Array.isArray(e)?e:[e]).map(p=>p&&typeof p=="object"&&"email"in p?String(p.email):String(p)).join(",")===String(u):l.transform?!1:SS(e,u)})}function sc(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 kS(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 _h(e,s){return Object.entries(e).filter(([a,o])=>!kS(o)&&!(s&&a in s&&sc(s[a])===sc(o))).map(([a,o])=>({key:a,label:Ht(a),value:sc(o)}))}function NS(e,s){const a=e.structuredContent;if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.keys(a).length>0)return{kind:"rows",rows:_h(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:_h(l,s)}}catch{}return{kind:"text",text:e.text}}const Lh=new Map;function CS(e){let s=Lh.get(e);return s||(s=L.getProposal(e).catch(()=>null),Lh.set(e,s)),s}let ls=null;function ES(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 TS({proposal:e,tool:s,manifests:a,label:o}){const l=io(e);return n.jsx(n.Fragment,{children:Pp({tool:s,manifests:a,label:o,approved:!0,proposalArgs:l.toolArgs})})}function AS({ticketId:e,timestamp:s,proposalId:a,tool:o,manifests:l,label:u}){const[f,p]=h.useState(null),[g,v]=h.useState(null);return h.useEffect(()=>{let y=!0;return p(null),v(null),a?CS(a).then(w=>{y&&p(w)}):ES(s).then(w=>{y&&v(w[e]??null)}),()=>{y=!1}},[a,e,s]),a?f?n.jsx(TS,{proposal:f,tool:o,manifests:l,label:u}):n.jsx(n.Fragment,{children:u}):n.jsx(n.Fragment,{children:Pp({tool:o,manifests:l,label:u,approved:!1,sentArgs:g})})}function Ri(e){return typeof e=="string"&&e.length>0}function IS(e){if(e===null||typeof e!="object")return!1;const s=e;return!(!Ri(s.filename)||!Ri(s.contentType)||!Ri(s.contentBase64)||!Ri(s.sha256)||s.pages!==void 0&&typeof s.pages!="number")}function _p(e){return e.length<=9?e:`${e.slice(0,4)}…${e.slice(-4)}`}function RS(e){return`data:${e.contentType};base64,${e.contentBase64}`}function PS(e){if(e!==void 0)return e===1?"1 page":`${e} pages`}function $S(e){const s=atob(e.contentBase64),a=new Uint8Array(new ArrayBuffer(s.length));for(let o=0;o<s.length;o++)a[o]=s.charCodeAt(o);return a}function Wt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ft(e,s=!1){return e==null?"—":typeof e=="string"?e:typeof e=="boolean"?String(e):typeof e=="number"?s||Number.isInteger(e)?String(e):String(Math.round(e*100)/100):"—"}function _S(e){return e==null?!1:typeof e=="string"||Array.isArray(e)?e.length>0:!0}function Bn(e,s,a){const o=s?Object.keys(s).filter(l=>l in e):Object.keys(e);return o.length===0?"—":o.map(l=>{var g,v;const u=e[l],f=((g=s==null?void 0:s[l])==null?void 0:g.title)??Ht(l),p=Wt(u)?Bn(u,(v=s==null?void 0:s[l])==null?void 0:v.properties,a):Ft(u,a);return`${f}: ${p}`}).join(" · ")}function Lp(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)??Ht(u)}}),l=e.map(u=>({cells:a.map(f=>{var y,w;const p=u[f],g=Wt(p)?Bn(p,(y=s==null?void 0:s[f])==null?void 0:y.properties,!1):Ft(p),v=Wt(p)?Bn(p,(w=s==null?void 0:s[f])==null?void 0:w.properties,!0):Ft(p,!0);return v===g?{value:g,sealed:!1}:{value:g,valueTitle:v,sealed:!1}})}));return{columns:o,rows:l}}function zp(e){return Array.isArray(e)&&e.length>0&&e.every(Wt)?{table:Lp(e,void 0)}:Wt(e)?{text:Bn(e,void 0,!1)}:null}function LS(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 zS(e,s){var l;if(Array.isArray(e)){if(e.length===0)return{value:"—"};if(e.every(y=>!Wt(y)&&!Array.isArray(y))){if(e.every(x=>typeof x=="string"))return{lines:e};const y=e.map(x=>Ft(x)).join(", "),w=e.map(x=>Ft(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=>Wt(y)?Bn(y,u,!1):Ft(y)),p=e.map(y=>Wt(y)?Bn(y,u,!0):Ft(y,!0)),g=f.map((y,w)=>y===p[w]?void 0:p[w]),v=e.every(Wt)?Lp(e,u):void 0;return{lines:f,...g.some(y=>y!==void 0)?{lineTitles:g}:{},...v?{table:v}:{}}}if(Wt(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=>!Wt(e[v])&&!Array.isArray(e[v])))return{sublist:f.map(y=>{var S;const w=e[y],x=((S=u==null?void 0:u[y])==null?void 0:S.title)??Ht(y),b=Ft(w),k=Ft(w,!0);return k===b?{key:y,label:x,value:b}:{key:y,label:x,value:b,valueTitle:k}})};const p=Bn(e,u,!1),g=Bn(e,u,!0);return g===p?{value:p}:{value:p,valueTitle:g}}if(typeof e=="string"&&(s==null?void 0:s.contentMediaType)==="text/x-diff")return{diffLines:LS(e)};const a=Ft(e),o=Ft(e,!0);return o===a?{value:a}:{value:a,valueTitle:o}}function FS(e){let s;try{s=JSON.parse(e)}catch{return null}return Wt(s)?s:null}function fr(e){const s=e!=null&&e.structured&&Object.keys(e.structured).length>0?e.structured:void 0;if(s)return{obj:s,schema:e==null?void 0:e.outputSchema};const a=e!=null&&e.text?FS(e.text):null;return a?{obj:a}:null}function Yi(e){const s=fr(e);if(!s)return[];const{obj:a,schema:o}=s,l=(o==null?void 0:o.properties)??{},u=[...new Set([...Object.keys(l),...Object.keys(a)])],f=[];for(const p of u){if(!(p in a))continue;const g=l[p],v=(g==null?void 0:g.title)??Ht(p),y={key:p,label:v,...zS(a[p],g)};g!=null&&g.description&&(y.description=g.description),f.push(y)}return f}function Fp(e,s){const a=fr(e);if(a){const l=Yi(e),u=s==null?void 0:s.fields;let f;if(u&&u.length>0){const v=new Map(l.map(y=>[y.key,y]));f=u.map(y=>v.get(y)).filter(y=>y!==void 0)}else f=l.filter(v=>_S(a.obj[v.key]));const p=new Set(f.map(v=>v.key)),g=l.filter(v=>!p.has(v.key));return{kind:"structured",fields:f,moreFields:g,totalFields:l.length}}const o=e==null?void 0:e.text;return o&&o.trim().length>0?{kind:"text",fields:[],moreFields:[],totalFields:0,text:o}:{kind:"empty",fields:[],moreFields:[],totalFields:0}}function zh(e){return e?e.lines?`lines:${JSON.stringify(e.lines)}`:e.sublist?`sublist:${JSON.stringify(e.sublist.map(s=>[s.key,s.value]))}`:e.diffLines?`diffLines:${JSON.stringify(e.diffLines)}`:`value:${e.value??""}`:""}function Pi(e){return{kind:e.length>0?"structured":"empty",fields:e,moreFields:[],totalFields:e.length}}function MS(e,s,a){const o=fr(e),l=fr(s);if(!o&&!l){const x=(e==null?void 0:e.text)??"",b=(s==null?void 0:s.text)??"";return x===b?{approved:Pi([]),current:Pi([]),unchanged:!0}:{approved:{kind:"text",fields:[],moreFields:[],totalFields:0,text:x},current:{kind:"text",fields:[],moreFields:[],totalFields:0,text:b},unchanged:!1}}const u=new Map(Yi(e).map(x=>[x.key,x])),f=new Map(Yi(s).map(x=>[x.key,x])),g=[...new Set([...u.keys(),...f.keys()])].filter(x=>x===(a==null?void 0:a.excludeKey)?!1:zh(u.get(x))!==zh(f.get(x))),v=a!=null&&a.fields&&a.fields.length>0?[...a.fields.filter(x=>g.includes(x)),...g.filter(x=>!a.fields.includes(x))]:g,y=v.map(x=>u.get(x)).filter(x=>x!==void 0),w=v.map(x=>f.get(x)).filter(x=>x!==void 0);return{approved:Pi(y),current:Pi(w),unchanged:g.length===0}}function OS(e){const s=e==null?void 0:e.structured;if(Array.isArray(s)&&s.every(Wt))return s;if(e!=null&&e.text){let a;try{a=JSON.parse(e.text)}catch{return null}if(Array.isArray(a)&&a.every(Wt))return a}return null}function oo(e){const s=Ft(e),a=Ft(e,!0);return a===s?{value:s}:{value:s,valueTitle:a}}function Mp(e){return!e||e.status!=="ok"?[]:Yi(e.body)}function jc(e){if(!e)return"Not read.";switch(e.status){case"not_found":return e.message?`The system answered: ${e.message}`:"Not found in the system.";case"none":return"Nothing to read.";default:return"Not available right now."}}function Op(e,s,a){var g;const o=Mp(e);if(o.length===0)return{rawId:Ft(s),context:[],unresolved:jc(e)};const l=e&&e.status==="ok"?(g=fr(e.body))==null?void 0:g.obj:void 0,u=o.find(v=>["name","title","label"].includes(v.key))??o.find(v=>typeof(l==null?void 0:l[v.key])=="string"&&!v.lines&&!v.sublist&&!v.diffLines),f=a==null?void 0:a.pathPrefix,p=o.filter(v=>v.key!==(u==null?void 0:u.key)&&v.key!=="id").map(v=>{var k,S;if(!f)return v;const y=`${f}.${v.key}`,w=la(a==null?void 0:a.displayHints,y,v.label);if(!ua((k=a==null?void 0:a.displayHints)==null?void 0:k.money,y)&&!ua((S=a==null?void 0:a.displayHints)==null?void 0:S.percent,y))return w===v.label?v:{...v,label:w};const{value:x,valueTitle:b}=Ji(l==null?void 0:l[v.key],a==null?void 0:a.displayHints,y,a==null?void 0:a.currency);return{...v,label:w,value:x,valueTitle:b}});return{name:u==null?void 0:u.value,rawId:Ft(s),context:p}}const BS=new Set(["id","name","title","label"]);function ua(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 DS(e,s){const a=typeof e=="number"?e:Number(e);return Number.isFinite(a)?{value:`${a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${s?` ${s}`:""}`}:oo(e)}function US(e){return typeof e!="number"&&typeof e!="string"?oo(e):{value:`${e} %`}}function Ji(e,s,a,o){return ua(s==null?void 0:s.money,a)?DS(e,o):ua(s==null?void 0:s.percent,a)?US(e):oo(e)}function Bp(e,s){return ua(e==null?void 0:e.hidden,s)}function WS(e,s,a){var f;const o=e==null?void 0:e.currencyField;if(!o)return;const l=o.indexOf(".");if(l<0){const p=s[o];return typeof p=="string"?p:void 0}const u=(f=a(o.slice(0,l)))==null?void 0:f[o.slice(l+1)];return typeof u=="string"?u:void 0}function HS(e,s,a,o){const l=e.forEach??"",u=e.attach,f=e.elements??[],p=Math.min(s.length,f.length),g=s.slice(0,p),v=f.slice(0,p),y=[...new Set(g.flatMap(S=>Object.keys(S)))].filter(S=>S!==e.sourceArg).filter(S=>!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=>!BS.has(S)):[],b=[];u&&b.push({key:`__attach:${u}`,label:la(a,`${l}[].${u}`,Ht(e.sourceArg??u))});for(const S of y)b.push({key:`bound:${S}`,label:la(a,`${l}[].${S}`,Ht(S))});for(const S of x)b.push({key:`attached:${S}`,label:la(a,`${l}[].${u}.${S}`,w.get(S)??Ht(S))});const k=g.map((S,N)=>{var I;const E=v[N],T=[];if(u){const B=Op(E,e.sourceArg?S[e.sourceArg]:void 0),M=B.name?`${B.name} (${B.rawId})`:B.unresolved?`${B.rawId} — ${B.unresolved}`:B.rawId;T.push({value:M,sealed:!1})}for(const B of y){const{value:M,valueTitle:q}=Ji(S[B],a,`${l}[].${B}`,o);T.push({value:M,valueTitle:q,sealed:!0})}const P=E&&E.status==="ok"?(I=fr(E.body))==null?void 0:I.obj:void 0;for(const B of x){const M=P==null?void 0:P[B],{value:q,valueTitle:z}=M!==void 0?Ji(M,a,`${l}[].${u}.${B}`,o):{value:"—",valueTitle:void 0};T.push({value:q,valueTitle:z,sealed:!1})}return{cells:T}});return{columns:b,rows:k,...e.overflow?{overflowNote:`${e.overflow.total-e.overflow.shown} more not shown`}:{}}}function VS(e){return`${Ht(e)} — from the system`}function GS(e){var l;const s=VS(e.tool),a=e.result;if(e.kind==="document"){if(a&&a.status==="ok"){const u=(l=fr(a.body))==null?void 0:l.obj;return u&&IS(u)?{heading:s,document:u}:{heading:s,note:"Could not show a preview — the connector’s answer was not in the expected shape."}}return(a==null?void 0:a.status)==="unavailable"&&a.reason==="no_connector"?null:{heading:s,note:jc(a)}}if(!a||a.status!=="ok")return{heading:s,note:jc(a)};const o=OS(a.body);if(o){if(o.length===0)return{heading:s,note:"Nothing found."};const u=[...new Set(o.flatMap(g=>Object.keys(g)))],f=u.map(g=>({key:g,label:Ht(g)})),p=o.map(g=>({cells:u.map(v=>({...oo(g[v]),sealed:!1}))}));return{heading:s,table:{columns:f,rows:p}}}return{heading:s,body:Fp(a.body,{fields:e.fields})}}function KS(e,s,a){const o=new Map(s.filter(x=>x.attach&&!x.forEach).map(x=>[x.attach,x])),l=new Map(s.filter(x=>x.forEach).map(x=>[x.forEach,x])),u=s.filter(x=>!x.attach&&!x.forEach),p=WS(a,e,x=>{var k,S;const b=(k=o.get(x))==null?void 0:k.result;return b&&b.status==="ok"?(S=fr(b.body))==null?void 0:S.obj:void 0}),g=(a==null?void 0:a.order)??[],v=[...new Set([...g,...Object.keys(e)])],y=[];for(const x of v){if(!(x in e)||Qm.has(x)||Bp(a,x))continue;const b=la(a,x,Ht(x)),k=l.get(x);if(k){const I=Array.isArray(e[x])?e[x]:[];y.push({kind:"table",key:x,label:b,table:HS(k,I,a,p)});continue}const S=o.get(x);if(S){const I=Op(S.result,e[x],{pathPrefix:x,displayHints:a,currency:p});y.push({kind:"identity",key:x,label:b,identity:I});continue}const N=e[x],E=zp(N);if(E&&"table"in E){y.push({kind:"table",key:x,label:b,table:E.table});continue}if(E&&Wt(N)){const I=Bn(N,void 0,!0);y.push({kind:"scalar",key:x,label:b,value:E.text,...I!==E.text?{valueTitle:I}:{}});continue}if(Array.isArray(N)){y.push({kind:"scalar",key:x,label:b,value:N.length===0?"—":N.map(I=>Ft(I)).join(", ")});continue}const{value:T,valueTitle:P}=Ji(N,a,x,p);y.push({kind:"scalar",key:x,label:b,value:T,valueTitle:P})}const w=u.map(GS).filter(x=>x!==null);return{rows:y,sections:w}}function da({table:e}){return e.columns.length===0?n.jsx("p",{className:"preview-note",children:"Nothing to show."}):n.jsxs(n.Fragment,{children:[n.jsxs("table",{className:"preview-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.columns.map(s=>n.jsx("th",{children:s.label},s.key))})}),n.jsx("tbody",{children:e.rows.map((s,a)=>n.jsx("tr",{children:s.cells.map((o,l)=>n.jsx("td",{className:o.sealed?"src-tag-value src-tag-sealed-cell":"src-tag-value src-tag-system-cell",title:o.valueTitle,children:o.value},l))},a))})]}),e.overflowNote&&n.jsx("p",{className:"preview-note",children:e.overflowNote})]})}const qS=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function YS(e,s){return typeof s!="string"?!1:/^data:image\//i.test(s)?!0:qS.test(e)?/^https?:\/\//.test(s):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(s)}function Ar(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Fh({row:e,which:s}){const a=ma(e.profileRef),o=Pw(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 JS({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)??Ot(a),n.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:a})]})}function Dp({row:e,altText:s}){if(e.kind==="list"||e.kind==="object"){const a=zp(e.value);if(a&&"table"in a)return n.jsx(da,{table:a.table});if(a)return n.jsx(n.Fragment,{children:a.text})}switch(e.kind){case"profile":return n.jsx(JS,{row:e});case"profile-limits":return n.jsx(Fh,{row:e,which:"limits"});case"profile-scope":return n.jsx(Fh,{row:e,which:"scope"});case"markdown":return n.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Ar(e.value)});case"list":return Array.isArray(e.value)?n.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:e.value.map((a,o)=>n.jsx("li",{children:Ar(a)},o))}):n.jsx(n.Fragment,{children:Ar(e.value)});case"money":return n.jsxs(n.Fragment,{children:[Ar(e.value),e.currency?` ${e.currency}`:""]});case"object":return n.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Ar(e.value)});default:return YS(e.key,e.value)?n.jsx("img",{src:e.value,alt:s??e.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):n.jsx(n.Fragment,{children:Ar(e.value)})}}function Sc({args:e,display:s,heading:a="Details",requestRefArg:o}){const l=Xm(e,s);if(l.length===0)return null;const u=typeof e.altText=="string"?e.altText:void 0;return n.jsxs("div",{style:{marginBottom:"0.75rem"},children:[a&&n.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:a}),n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:l.map(f=>n.jsxs(h.Fragment,{children:[n.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:f.hint,children:f.key===o?"Replying to":f.label}),n.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:f.key===o?n.jsx("span",{"data-testid":"request-ref",title:Ar(f.value),children:"the message shown under Request"}):n.jsx(Dp,{row:f,altText:u})})]},f.key))})]})}function QS(e){const s=h.useMemo(()=>typeof URL>"u"||typeof URL.createObjectURL!="function"||typeof Blob>"u"?RS(e):URL.createObjectURL(new Blob([$S(e)],{type:e.contentType})),[e.contentBase64,e.contentType]);return h.useEffect(()=>()=>{s.startsWith("blob:")&&URL.revokeObjectURL(s)},[s]),s}function Up({doc:e,systemName:s,heading:a,sourceLine:o,trailingNote:l}){const u=QS(e),f=PS(e.pages),p=s?`Rendered by ${s}`:"Rendered",g=n.jsxs(n.Fragment,{children:[p," from the template and the values above. Not issued yet — no number is used until you approve."]});return n.jsxs("div",{className:"document-preview-box","data-testid":"document-preview",children:[n.jsx("h4",{children:a??"The PDF as it will be issued"}),n.jsxs("div",{className:"document-preview-body",children:[n.jsx("object",{data:u,type:e.contentType,className:"document-preview-frame","aria-label":`Preview of ${e.filename}`,children:n.jsxs("p",{className:"preview-note",children:["This browser can't preview the PDF inline. ",n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),"."]})}),n.jsxs("div",{className:"document-preview-meta",children:[n.jsx("div",{className:"document-preview-filename",children:e.filename}),f&&n.jsx("div",{className:"preview-note",children:f}),o&&n.jsx("div",{className:"preview-note",children:o}),n.jsxs("div",{className:"preview-note",children:["Fingerprint ",n.jsx("span",{className:"id-raw",title:e.sha256,children:_p(e.sha256)})]}),n.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:"Open full preview"}),l!==null&&n.jsx("p",{className:"preview-note",children:l??g})]})]})]})}const XS="_attachmentsSealed";function ZS(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 eb(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 eu(e){const s={attachments:[],inserts:[]};if(!e)return s;const a=e[XS];if(a===null||typeof a!="object")return s;const o=a,l=Array.isArray(o.attachments)?o.attachments.filter(ZS):[],u=Array.isArray(o.inserts)?o.inserts.filter(eb):[];return{attachments:l,inserts:u}}function tb(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 nb(e){return eu(e).attachments.length===0?[]:[{key:"attachment-source",label:"attachment from an allowed source",ok:!0,valueText:"",limitText:""}]}function Wp(e,s,a,o){var u,f,p;const l=(p=(f=(u=e==null?void 0:e.find(g=>g.id===s))==null?void 0:u.documents)==null?void 0:f[a])==null?void 0:p.label;if(l)return l.replace(/\{id\}/g,o)}function rb(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 sb({a:e,manifests:s,preview:a}){const o=Hn(e.connector,s),l=Wp(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(Up,{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:tb(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:_p(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 ab({i:e,manifests:s}){const a=Hn(e.connector,s);return n.jsxs("div",{className:"preview-box preview-box-sys","data-testid":"insert-sealed",children:[n.jsxs("h4",{children:["From ",a," — inserted by the gateway"]}),n.jsx("div",{style:{color:"var(--prov-system)",fontWeight:600,wordBreak:"break-word"},children:e.value})]})}function Hp({attachments:e,inserts:s,manifests:a,fetchPreview:o,onChecks:l}){const[u,f]=h.useState({});return h.useEffect(()=>{if(!o)return;let p=!0;for(const g of e)f(v=>v[g.sha256]?v:{...v,[g.sha256]:"loading"}),o(g.sha256).then(v=>{p&&f(y=>({...y,[g.sha256]:v}))}).catch(()=>{p&&f(v=>({...v,[g.sha256]:{status:"unavailable",message:"Could not fetch the preview."}}))});return()=>{p=!1}},[e.map(p=>p.sha256).join(","),o]),h.useEffect(()=>{if(!l)return;const p=e.map(g=>rb(Wp(a,g.connector,g.kind,g.id),u[g.sha256])).filter(g=>g!==null);l(p)},[e,a,u,l]),e.length===0&&s.length===0?null:n.jsxs(n.Fragment,{children:[e.map(p=>n.jsx(sb,{a:p,manifests:a,preview:u[p.sha256]},`${p.connector}:${p.kind}:${p.id}`)),s.map(p=>n.jsx(ab,{i:p,manifests:a},`${p.placeholder}:${p.connector}:${p.kind}:${p.id}`))]})}let $i=null;function ib(){return $i||($i=L.getToolDisplay().catch(()=>($i=null,{}))),$i}function Vp({args:e,display:s,executionContext:a,sealed:o}){const l=$p(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(Dp,{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 Mh({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(Vp,{args:e,display:s,executionContext:a,sealed:o})}function Oh({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 ob({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(Mh,{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&&$p(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(Vp,{args:e.extras,display:s,executionContext:a,sealed:!1}),e.argsCheck==="mismatch"&&n.jsx(Oh,{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(Mh,{content:e.content,display:s,executionContext:a,sealed:!1}),n.jsx(Oh,{check:e.check})]})}const Bh=5;function lb({result:e,systemName:s,sent:a}){const o=NS(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,Bh)).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>Bh&&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 Dh(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 Gp({receipt:e,manifests:s}){var k;const[a,o]=h.useState(void 0),[l,u]=h.useState(null),[f,p]=h.useState(void 0),g=!!(e.contentHash&&e.contentBinding);h.useEffect(()=>{let S=!0;return ib().then(N=>{S&&p(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 E=null;const T=N==null?void 0:N.entry.boundContent;if(T!==void 0&&g)try{E=await sp(e.contentBinding.kind,T)===e.contentHash}catch{E=!1}S&&(u(E),o(N))})(),()=>{S=!1}},[e.id,e.contentHash,e.contentBinding,g]);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=wS({offDevice:a===null,boundContent:a==null?void 0:a.entry.boundContent,sentArgs:a==null?void 0:a.entry.sentArgs,sentArgsOmitted:a==null?void 0:a.entry.sentArgsOmitted,proposalArgs:y&&typeof y=="object"&&!Array.isArray(y)?y:void 0,hasHashToCheck:g,hashVerified:l,sentArgsCheck:a==null?void 0:a.sentArgsCheck}),x=Hn(Wn(e.action).integrationId,s),b=eu((a?Dh(a):null)??void 0);return n.jsxs(n.Fragment,{children:[n.jsx(ob,{view:w,display:f,executionContext:e.executionContext}),n.jsx(Hp,{attachments:b.attachments,inserts:b.inserts,manifests:s,fetchPreview:v}),(a==null?void 0:a.result)&&n.jsx(lb,{result:a.result,systemName:x,sent:Dh(a)})]})}const Uh=500;function bc(e){return e.length>Uh?`${e.slice(0,Uh)}…`:e}function Wh(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function cb(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Kp(e,s,a){switch(e.status){case"none":return e.reason==="no_target"?{heading:"Nothing to read beforehand",note:`This action does not refer to an existing record — nothing to read beforehand. Showing exactly what will be sent to ${s}.`}:{heading:"No preview declared",note:`No preview declared for this tool — showing exactly what will be sent to ${s}.`};case"unavailable":return e.reason==="no_connector"?{heading:"Preview not available",note:"Preview not available on this gateway."}:{heading:"Preview not available",note:e.message?`Preview not available — ${bc(e.message)}`:"Preview not available."};case"not_found":return{heading:"Not found in your system",note:e.message?`Not found in your system — ${bc(e.message)}`:"Not found in your system."};case"ok":{if("reads"in e)return{heading:`What will be created in ${s}`,note:`Read by the gateway, not by the AI — read at ${cb(e.readAt)}.`,creation:KS(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=MS(e.body,u.currentBody,{fields:e.fields,excludeKey:u.field});l.stale={heading:`A newer ${u.field} exists (${u.current})`,approvedLabel:`${Wh(u.field)} ${u.approved}`,currentLabel:`${Wh(u.field)} ${u.current}`,...f.unchanged?{unchangedNote:"No visible change in the fields."}:{approvedRendered:f.approved,currentRendered:f.current}}}return l}}}function ub(e,s){if(e.state!=="failed")return null;const a=e.detail?bc(e.detail):void 0;return e.outcome==="changed"?{heading:"Changed since your approval",note:`The record changed in ${s} since you approved it — nothing was done. Ask the AI to request it again.`}:{heading:`Refused by ${s}`,note:`${s} refused it${a?`: ${a}`:""} — nothing was done. Ask the AI to request it again.`}}function db(e){return e!==null&&e!=="loading"&&e!=="ok"&&e!=="stale"}function Hh({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 fb({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(da,{table:e.table}):e.lines?n.jsx("div",{children:e.lines.map((s,a)=>{var o;return n.jsx("div",{title:(o=e.lineTitles)==null?void 0:o[a],children:s},a)})}):n.jsx("span",{title:e.valueTitle,children:e.value})}function kc({rows:e}){return n.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.map(s=>s.table?n.jsxs("div",{style:{gridColumn:"1 / -1"},children:[n.jsx(Hh,{row:s}),n.jsx(da,{table:s.table})]},s.key):n.jsxs(h.Fragment,{children:[n.jsx(Hh,{row:s}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:n.jsx(fb,{row:s})})]},s.key))})}function ac({rendered:e}){return e.kind==="empty"?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.85rem",margin:"0.4rem 0"},children:"No fields returned."}):e.kind==="text"?n.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.85rem",margin:"0.4rem 0"},children:e.text}):n.jsxs(n.Fragment,{children:[n.jsx(kc,{rows:e.fields}),e.moreFields.length>0&&n.jsxs("details",{style:{fontSize:"0.8rem"},children:[n.jsxs("summary",{style:{cursor:"pointer",color:"var(--text-tertiary)"},children:["All fields (",e.totalFields,")"]}),n.jsx(kc,{rows:e.moreFields})]})]})}function hb({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 mb({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(hb,{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(da,{table:a.table})]},a.key)),e.sections.map((a,o)=>n.jsx("div",{className:"creation-own-section",children:a.document?n.jsx(Up,{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(da,{table:a.table}),a.body&&n.jsx(kc,{rows:a.body.fields}),a.note&&n.jsx("p",{className:"preview-note",children:a.note})]})},o))]})}function qp({resp:e,systemName:s,toolArgs:a,sealed:o}){const l=Kp(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(mb,{view:l.creation,systemName:s}),l.rendered&&n.jsx(ac,{rendered:l.rendered}),n.jsx("p",{className:"preview-note",children:l.note}),l.versionNote&&!l.stale&&n.jsx("p",{className:"preview-note",children:l.versionNote}),l.stale&&n.jsxs("div",{className:"preview-stale",children:[n.jsx("h5",{children:l.stale.heading}),l.stale.unchangedNote?n.jsx("p",{className:"preview-note",children:l.stale.unchangedNote}):n.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.3rem 0.75rem",fontSize:"0.85rem",margin:"0.5rem 0 0"},children:[n.jsx("dt",{children:l.stale.approvedLabel}),n.jsx("dd",{children:n.jsx(ac,{rendered:l.stale.approvedRendered})}),n.jsx("dt",{children:l.stale.currentLabel}),n.jsx("dd",{children:n.jsx(ac,{rendered:l.stale.currentRendered})})]})]})]})}function pb({proposalId:e,systemName:s,toolArgs:a,sealed:o,onTone:l,onData:u}){const[f,p]=h.useState(null),[g,v]=h.useState(!1);return h.useEffect(()=>{let y=!0;return p(null),v(!1),L.getProposalPreview(e).then(w=>{y&&p(w)}).catch(()=>{y&&v(!0)}),()=>{y=!1}},[e]),h.useEffect(()=>{if(g){l==null||l("unavailable"),u==null||u({status:"unavailable",reason:"connector_error"});return}if(!f){u==null||u(null);return}const y=Kp(f,s,a??void 0);l==null||l(f.status==="ok"?y.stale?"stale":"ok":f.status),u==null||u(f)},[f,g,s,l,u]),g?n.jsxs("div",{className:"preview-box preview-box-unavailable","data-testid":"approval-preview","data-preview-status":"unavailable",children:[n.jsx("h4",{children:"Preview not available"}),n.jsx("p",{className:"preview-note",children:"Preview not available on this gateway."})]}):f?n.jsx(qp,{resp:f,systemName:s,toolArgs:a,sealed:o}):n.jsxs("div",{className:"preview-box preview-box-loading","data-testid":"approval-preview","data-preview-status":"loading","aria-busy":"true",children:["Reading from ",s,"…"]})}const ic=6;function Qi(e){if(!e)return;const s=Date.parse(e);return Number.isNaN(s)?e:new Date(s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function gb(e){if(!e)return{first:""};const s=e.split(`
|
|
85
|
-
`);return s.length<=ic?{first:e}:{first:s.slice(0,ic).join(`
|
|
86
|
-
`),more:s.slice(ic).join(`
|
|
87
|
-
`)}}const yb="Linked by the AI",vb="linked automatically — this action already carried a reference to it";function xb(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}=gb(e.body),o=[e.connector,e.kind,e.author?`from ${e.author}`:void 0,Qi(e.at)].filter(l=>!!l);return{state:"ok",implicit:e.implicit,tag:yb,...e.implicit?{implicitNote:vb}:{},metaLine:o.join(" · "),title:e.title,bodyFirst:s,bodyMore:a,attribution:e.author?`— from ${e.author}, not checked`:void 0,chain:e.chain.map(l=>({...l,at:Qi(l.at)}))}}const ta="Read by the gateway — same customer, not matched to this request";function wb(e){const s=e.matchedKeyType==="email_domain"?"matched by email domain":"matched by email";return`Latest entries for ${e.matchedKeyValue} (${s})`}function jb(e){var l;const s=!!e.aiWritten,a=s?"Activity":e.type??e.kind??"Entry";let o;if(s){const u=((l=e.aiWritten)==null?void 0:l.at)!==void 0?Qi(new Date(e.aiWritten.at).toISOString()):void 0;o=u?`— Written by the AI via Suveren, ${u} — not checked`:"— Written by the AI via Suveren — not checked"}else o=e.author?`— from ${e.author}, not checked`:"— not checked";return{headLabel:a,at:Qi(e.at),title:e.title,body:e.body,attribution:o,aiWritten:s}}function Sb(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})=>jb(l)),a=e.matches.map(wb),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 Yp({resp:e}){const s=xb(e.request),a=Sb(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 bb({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(p=>{f&&o(p)}).catch(()=>{f&&u(!0)}),()=>{f=!1}},[e]),h.useEffect(()=>{s==null||s(l?null:a)},[a,l,s]),l||!a?null:n.jsx(Yp,{resp:a})}function kb(e,s,a){const o=Object.entries(e??{});if(o.length===0)return{entry:void 0,otherCount:0};const u=o.find(([,p])=>p.by===s)??(a?o.find(([p])=>p===`domain:${a}`):void 0),f=u?o.length-1:o.length;return{entry:u==null?void 0:u[1],otherCount:f}}function Nb(e){return e.offDevice?"off-device":e.recordedHash?e.localHash===e.recordedHash?"verified":"mismatch":"unchecked"}function Cb(e){if(!(e<=0))return`${e} other approver${e===1?"":"s"} recorded their own.`}function Eb(e){return new Date(e).toLocaleString([],{hour:"2-digit",minute:"2-digit"})}function Jp({proposalId:e,tool:s,manifests:a}){const{user:o,domain:l}=wt(),[u,f]=h.useState(null),[p,g]=h.useState(null),[v,y]=h.useState(!1);if(h.useEffect(()=>{let P=!0;return f(null),g(null),y(!1),Promise.all([L.getShownSnapshot(e),L.getProposal(e)]).then(([I,B])=>{P&&(f(I),g(B))}).catch(()=>{P&&y(!0)}),()=>{P=!1}},[e]),v||!u||!p)return null;const w=u.status==="off_device",{entry:x,otherCount:b}=kb(p.shownHashes,(o==null?void 0:o.id)??"",l),k=Nb({offDevice:w,recordedHash:x==null?void 0:x.hash,localHash:u.status==="ok"?u.shownHash:void 0}),S=Cb(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:E}=Wn(s),T=Hn(E,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 ",Eb(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(qp,{resp:N.preview,systemName:T,toolArgs:N.toolArgs,sealed:N.sealed}),n.jsx(Yp,{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 Tb({receipt:e,manifests:s,localAuth:a,localUnavailable:o,signature:l,grantTitle:u,ownerLabel:f,spUrl:p,formatDate:g,onOpenComplete:v,isNew:y=!1,defaultOpen:w=!1}){var Z;const x=ma(e.profileId),b=$w(e,x),k=_w(a==null?void 0:a.context,x),S=zw(e,(a==null?void 0:a.bounds)??e.limits,x),N=a==null?void 0:a.intent,E=_r(e.profileId).testSetup||ro(e.action),[T,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:Hi(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(AS,{ticketId:e.id,timestamp:e.timestamp,proposalId:e.proposalId,tool:e.action,manifests:s,label:ao(e,s)})}),n.jsx("span",{className:"receipt-tag",children:Ui(e)?"approved":"automatic"}),e.contentHash&&n.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(Z=e.contentBinding)!=null&&Z.fields?`Sealed in the ticket: ${e.contentBinding.fields.join(", ")} — exactly this content was sent`:"Sealed in the ticket — exactly this content was sent",children:"content sealed"}),E&&n.jsx("span",{className:"sim-mark",children:"Test setup"})]}),n.jsx(ca,{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:g(e.timestamp)}),n.jsx(Gp,{receipt:e,manifests:s}),e.proposalId&&n.jsx(Jp,{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||Mw(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${T?"":" intent-clamped"}`,children:N}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>P(!T),children:T?"Show less":"Show full intent"})," ",n.jsx("span",{className:"src-tag src-tag-local",children:"local"})]}):n.jsx("span",{className:"receipt-absent",children:o?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]}),n.jsxs("div",{className:"receipt-foot",children:[l==="valid"&&n.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued — no Authority Server involved.",children:"✓ Verified on this device"}),l==="valid-legacy"&&n.jsx("span",{className:"receipt-verified",title:"Ed25519 signature checked on this device against the issuer key archived when the ticket was issued. This ticket was issued before protocol 0.7 and is checked with that version's format.",children:"✓ Verified on this device · issued before protocol 0.7"}),l==="invalid"&&n.jsx("span",{className:"receipt-tamper",title:"The stored ticket does not match what was signed.",children:"⚠ Signature check FAILED"}),n.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:v,children:"Complete ticket"}),p&&n.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",n.jsx("a",{className:"receipt-link",href:`${p}/r/${e.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),n.jsxs("details",{className:"receipt-more",children:[n.jsx("summary",{children:"Raw"}),n.jsxs("div",{className:"receipt-kv",children:[n.jsxs("div",{children:["ticket · ",e.id]}),n.jsxs("div",{children:["action · ",e.action]}),n.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&n.jsxs("div",{children:["mandate · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&n.jsxs("div",{children:["scope ·"," ",Object.entries(e.executionContext).map(([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:rp(e.id)}),n.jsx("span",{className:"ticket-obj-time",children:Hi(e.timestamp,M)}),U&&n.jsx("span",{className:"ticket-obj-sig",title:"Signature checked on this device",children:"✓ verified"})]})]})}function Ab({receipt:e,onClose:s}){const[a,o]=h.useState(null),[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState(!0),[y,w]=h.useState(!1);h.useEffect(()=>{let N=!1;return v(!0),L.getArchivedReceipt(e.id).then(E=>{N||(o(E),u(E?"local":"authority-server"),p((E==null?void 0:E.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"})),E=document.createElement("a");E.href=N,E.download=`suveren-ticket-${e.id.slice(0,8)}.json`,E.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:g?"Loading…":l==="local"?"Held on this device — the signed ticket, the mandate it ran under, and the issuer key. Anyone with this file and that key can verify it offline, without Suveren.":"No local copy of this ticket (it predates local archiving, or ran on another device). Shown from the Authority Server — complete and signed, but it needs the server to retrieve."}),n.jsx("pre",{style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.68rem",lineHeight:1.65,margin:0,background:"var(--accent-subtle)",border:"1px solid var(--border)",borderRadius:"6px",padding:"0.75rem 0.85rem",overflowX:"auto",maxHeight:"22rem",overflowY:"auto"},children:b})]}),n.jsxs("div",{className:"modal-footer",children:[n.jsx("button",{className:"btn btn-primary btn-sm",onClick:k,children:"Download"}),n.jsx("button",{className:"btn btn-secondary btn-sm",onClick:S,children:y?"Copied":"Copy"})]})]})})}function Ib(e){return new Date(e*1e3).toLocaleString()}function Rb(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 Pb(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 Vh(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 $b(){const{activeTeam:e,groupId:s}=wt(),a=(e==null?void 0:e.isAdmin)===!0,[o,l]=h.useState("mine"),[u,f]=gs(),p=Bw(u.get("filter")),g=W=>{const xe=new URLSearchParams(u);W==="all"?xe.delete("filter"):xe.set("filter",W),f(xe,{replace:!0})},v=Ym(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([]),[E,T]=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:Vh(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=>Vh(xe,W.receipts)),Le(W.nextBefore)}).catch(()=>nt(!0)).finally(()=>Ue(!1)))},[oe,ze,Ye]);Mt(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(T).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=>!(!Pb(W,G,[Dn(W.profileId,w),ao(W,E),Hn(Wn(W.action).integrationId,E),W.authorizationId?ve[W.authorizationId]:null])||ne.size>0&&!ne.has(W.action)||U.size>0&&W.userId&&!U.has(W.userId)||!Rb(W,ee))),[S,G,w,E,ve,ne,U,ee]),Oe=h.useMemo(()=>{const W={automatic:0,approved:0,all:0};for(const xe of Re)W.all+=1,W[yc(xe,"approved")?"approved":"automatic"]+=1;return W},[Re]),K=h.useMemo(()=>Re.filter(W=>yc(W,p)),[Re,p]),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:Dn(xe.profileId,w),count:1})}return[...W.values()].sort((xe,Ae)=>xe.name.localeCompare(Ae.name))},[K,w]),ye=h.useMemo(()=>K.filter(W=>Jm(W.profileId,v)),[K,v]),He=h.useMemo(()=>x===null?0:ye.filter(W=>Wi(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 Vt(W){Z(xe=>{const Ae=new Set(xe);return Ae.has(W)?Ae.delete(W):Ae.add(W),Ae})}function Bt(){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:Ow.map(W=>n.jsxs("button",{type:"button",role:"tab",className:"ftab","data-testid":`tickets-filter-${W}`,"aria-selected":p===W,onClick:()=>g(W),children:[W==="automatic"?"Automatic":W==="approved"?"Approved":"All",n.jsx("span",{className:"n",children: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)})`:""]})]})]}),p==="automatic"&&n.jsx("p",{className:"page-subtitle",style:{marginTop:"-0.25rem"},children:'Automatic — no person approved these. Approved tickets are under "Approved".'}),n.jsx(Zc,{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:()=>Vt(W.id),children:W.label},W.id))})]}),n.jsxs("div",{className:"filter-section",children:[n.jsx("div",{className:"filter-label",children:"Time range"}),n.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([W,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:()=>Vt(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:Bt,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(Tb,{receipt:W,manifests:E,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:Ib,onOpenComplete:()=>be(W),isNew:x!==null&&Wi(W,x),defaultOpen:ye.length===1})},W.id)})})]}),qe&&n.jsx(Ab,{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 _b(){const[e,s]=h.useState(null),[a,o]=h.useState({}),[l,u]=h.useState(!1),f=Lr(),[p,g]=gs(),v=Ym(p.get("area")),y=h.useCallback(M=>{const q=new URLSearchParams(p);M===null?q.delete("area"):q.set("area",M),g(q,{replace:!0})},[p,g]),[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]),Mt(b,3e5);const[k,S]=h.useState(null),N=h.useRef(!1),E=h.useCallback(()=>{L.getDenials({limit:200}).then(({records:M})=>{s(M),u(!1)}).catch(()=>u(!0))},[]);h.useEffect(()=>{E()},[E]),Mt(E,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 T=h.useCallback(()=>{E(),b(),k!==null&&(typeof document<"u"&&document.visibilityState!=="visible"||L.markBlockedSeen(Date.now()).then(()=>{window.dispatchEvent(new Event("suveren:blocked-seen-changed"))}).catch(()=>{}))},[E,b,k]);Me("denial-recorded",T);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:Dn(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=A0(e,Date.now()),B=e.filter(M=>Jm(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(Zc,{areas:P,selected:v,onSelect:y,totalCount:e.length}),n.jsx("div",{className:"blocked-list",children:B.map((M,q)=>{const z=T0(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:Dn(Z,f),system:M.integrationId?Hn(M.integrationId,void 0):void 0,time:P0(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-${no(M)}`,"aria-hidden":"true"}),n.jsx("span",{className:"blocked-title",children:z.title})]}),n.jsx(ca,{title:Lm(M,w),area:Dn(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 Lb={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function zb(){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 p=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 g=Lb[e.platform]??"a login service";return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),n.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:e.supported?n.jsxs(n.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",g," — no admin rights needed."]}):e.reason})]}),e.supported&&n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.installed,className:e.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Working…":e.installed?"Turn off":"Turn on"})]}),e.supported&&n.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",n.jsx("strong",{children:e.installed?"On — starts from your next login":"Off"})]}),e.supported&&n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Turning this on doesn't interrupt the gateway you're using — it takes effect at your next login. After any restart Suveren comes back ",n.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}function Fb(){const[e,s]=h.useState(null),[a,o]=h.useState(!1),[l,u]=h.useState(null),f=h.useCallback(async()=>{try{const g=await L.getGatewaySettings();s(g.desktopNotifications),u(null)}catch(g){u(g instanceof Error?g.message:"Could not read notification setting")}},[]);h.useEffect(()=>{f()},[f]);const p=h.useCallback(async()=>{if(!(e===null||a)){o(!0),u(null);try{const g=await L.setGatewaySettings({desktopNotifications:!e});s(g.desktopNotifications)}catch(g){u(g instanceof Error?g.message:"Failed to save"),await f()}finally{o(!1)}}},[e,a,f]);return e===null?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read the setting: ${l}`:"Checking…"})]}):n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),n.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:"Tells you something is waiting for review — never what it is, and never with an approve button. Open Suveren to see and decide. At most one notification a minute; the browser tab always shows the count."})]}),n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e,className:e?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":e?"Turn off":"Turn on"})]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}const Gh={as_vouched:"verified by",eudi:"verified with an EU digital identity (EUDI)"};function Mb(){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 p=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]),g=n.jsx("h3",{className:"card-title",style:{margin:0},children:"Your name on mandates and tickets"});if(!e)return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[g,n.jsx("p",{role:l?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:l?`Could not read the setting: ${l}`:"Checking…"})]});const v=e.verified&&e.name?`${e.name} — ${e.method==="as_vouched"?`${Gh.as_vouched} ${e.verifier}`:Gh[e.method??""]??e.method}`:null;return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[g,n.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:[e.always?"On: your verified name is attached to every mandate you give — including ones the setup AI proposes and you approve — and to the tickets under them.":"Off: each mandate asks whether to show your name. Mandates the setup AI proposes carry no name."," ","Mandates already given stay as they are."]}),n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:v?`Your identity: ${v}.`:"Your identity is not verified yet — no name can be shown until it is."})]}),n.jsx("button",{type:"button",onClick:()=>void p(),disabled:a,"aria-pressed":e.always,className:e.always?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:a?"Saving…":e.always?"Turn off":"Always show my name"})]}),l&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.75rem 0 0",fontSize:"0.85rem"},children:l})]})}const Ob={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 Bb(){const{version:e,latestVersion:s,updateAvailable:a,installMethod:o}=Mc();return e?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",n.jsx("strong",{children:e}),a&&s?n.jsxs(n.Fragment,{children:[" — ",n.jsx("strong",{children:s})," is available"]}):null]}),n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[Ob[o]??"Update checking is unavailable",o==="dev"&&n.jsx(n.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Nc({title:e}){return n.jsxs("span",{className:"it-locked-badge",title:e,children:[n.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function Kh(e){return e===!0}function Db(){const[e,s]=h.useState(null),[a,o]=h.useState(null);h.useEffect(()=>{let f=!1;return L.getAsPairing().then(p=>{f||s(p)}).catch(p=>{f||o(p instanceof Error?p.message:"Could not read Authority Server info")}),()=>{f=!0}},[]);const l=Kh(e==null?void 0:e.asUrlLockedByPolicy),u=Kh(e==null?void 0:e.pinTlsLockedByPolicy);return n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),l&&n.jsx(Nc,{})]}),!e&&!a&&n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),a&&n.jsx("p",{role:"alert",className:"msg-error",style:{margin:"0.5rem 0 0",fontSize:"0.9rem"},children:a}),e&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"URL:"})," ",n.jsx("code",{children:e.asUrl})]}),e.paired&&e.fingerprint?n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"Key fingerprint:"})," ",n.jsx("code",{children:e.fingerprint}),n.jsx("br",{}),n.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Compare this with the fingerprint on the Authority Server's own admin page over a second channel (phone, video call) to confirm this gateway is talking to the right server."})]}):n.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:"Not yet paired — sign in once to pin this server's key."}),(e.tlsPinFingerprint||e.pinTlsEnabled)&&n.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[n.jsx("strong",{children:"TLS certificate pin:"})," ",u&&n.jsx(Nc,{title:"TLS pinning is set by your IT policy"})," ",e.tlsPinFingerprint?n.jsx("code",{children:e.tlsPinFingerprint}):n.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["not yet captured — this URL has no recorded pairing over TLS",e.pinTlsEnabled?"; sign in to establish one (re-pairing required)":""]}),n.jsx("br",{}),n.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[e.pinTlsEnabled?n.jsxs(n.Fragment,{children:["TLS pinning is ON",u?n.jsx(n.Fragment,{children:", set by your organization's IT policy"}):n.jsxs(n.Fragment,{children:[" (",n.jsx("code",{children:"config set pin-tls on"}),")"]}),". Every connection to the Authority Server must present this certificate's public key, or the gateway refuses it and locks."]}):n.jsxs(n.Fragment,{children:["Captured at sign-in; not currently enforced",u?n.jsx(n.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):n.jsxs(n.Fragment,{children:[" (",n.jsx("code",{children:"config set pin-tls on"})," to require it on every connection)"]}),"."]})," ","A certificate renewal with the SAME key keeps this pin; a NEW key needs re-pairing."]})]}),l?n.jsx("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This Authority Server URL is set by your organization's IT policy and cannot be changed from this computer. Contact your IT administrator if it needs to change."}):n.jsxs("p",{style:{margin:"0.75rem 0 0",fontSize:"0.8rem",color:"var(--text-tertiary)"},children:["To point this gateway at a different Authority Server:"," ",n.jsx("code",{children:"suveren-gateway config set as-url <url>"}),", then restart. Changing it ends the current sign-in and clears cached mandates — you sign in again against the new server."]})]})]})}function Ub(){const{simulation:e,locked:s}=Km();return s?n.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[n.jsxs("div",{children:[n.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),n.jsxs("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:['Blocks every real connector without a manifest "simulation" marker.',e!==null&&n.jsxs(n.Fragment,{children:[" ","Currently ",n.jsx("strong",{children:e?"ON":"OFF"}),e?" — real systems are not reachable from this gateway.":"."]})]})]}),n.jsx(Nc,{})]}),n.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.78rem",color:"var(--text-tertiary)"},children:["Simulation mode is set by your organization's IT policy",e!==null?` (currently ${e?"on":"off"})`:""," and cannot be changed from this computer — not even from the command line."]})]}):null}const Wb={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 Hb(){const[e,s]=h.useState(""),[a,o]=h.useState("openrouter"),[l,u]=h.useState("openai-compatible"),[f,p]=h.useState("https://openrouter.ai/api/v1"),[g,v]=h.useState("google/gemma-4-31b-it"),[y,w]=h.useState(""),[x,b]=h.useState(!1),[k,S]=h.useState(!1),[N,E]=h.useState(!1),[T,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&&p(A),Q.fields.model&&v(Q.fields.model),A.includes("openai.com")?o("openai"):A.includes("groq.com")?o("groq"):A.includes("together.xyz")?o("together"):A.includes("openrouter.ai")?o("openrouter"):o("ollama"),A&&ne(Y,A)}}catch{}},[ne]);h.useEffect(()=>{fe()},[fe]);const ee=Q=>{o(Q),B([]),U(null),G("");const Y=Wb[Q];Y&&(u(Y.provider),p(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:g,...y?{apiKey:y}:{}}),b(!0),O("AI configuration saved!")}catch{O("Failed to save AI config")}finally{S(!1)}},X=async()=>{E(!0),P(null);try{const Q=await L.aiTest({provider:l,endpoint:f,model:g,...y?{apiKey:y}:{}});P(Q.ok?`OK: ${Q.message}`:`Failed: ${Q.message}`)}catch(Q){P(`Error: ${Q instanceof Error?Q.message:"Unknown"}`)}finally{E(!1)}};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Settings"}),n.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),e&&n.jsx("div",{className:"alert alert-success",children:e}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style: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(g),A=Q.length>12,_=Z.trim().toLowerCase();let se=_?Q.filter(te=>te.toLowerCase().includes(_)):Q;return Y&&!se.includes(g)&&(se=[g,...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?g:"__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||!g.trim(),title:g.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"})]}),T&&n.jsx("div",{className:`alert ${T.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:T})]}),n.jsx(Vb,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:sa,children:ra[1]}),n.jsx(Db,{}),n.jsx(Mb,{})]}),n.jsxs("section",{style:{marginBottom:"2rem"},children:[n.jsx("h2",{style:sa,children:ra[2]}),n.jsx(zb,{}),n.jsx(Fb,{}),n.jsx(Ub,{})]}),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(Bb,{})]})]})}function Vb(){const[e,s]=h.useState(null),[a,o]=h.useState({intent:"",context:""}),[l,u]=h.useState(null),[f,p]=h.useState(null),[g,v]=h.useState(null),[y,w]=h.useState(!1),x=h.useCallback(async()=>{if(!y)try{const S=await L.getAIPrompts();s(S),o({intent:S.intent.current,context:S.context.current}),w(!0)}catch(S){p(S instanceof Error?S.message:"Failed to load prompts")}},[y]),b=async S=>{if(e){u(S),p(null);try{const N=a[S],E=N.trim()===e[S].default.trim()?"":N;await L.setAIPrompt(S,E);const T=await L.getAIPrompts();s(T),o({intent:T.intent.current,context:T.context.current}),v(S),setTimeout(()=>v(null),2e3)}catch(N){p(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),p(null);try{await L.setAIPrompt(S,"");const N=await L.getAIPrompts();s(N),o({intent:N.intent.current,context:N.context.current})}catch(N){p(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(qh,{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:g==="intent"}),n.jsx(qh,{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:g==="context"})]})]})}function qh({kind:e,label:s,description:a,state:o,draft:l,onChange:u,onSave:f,onRevert:p,saving:g,justSaved:v}){const y=l!==o.current;return n.jsxs("section",{style:{marginBottom:"1.5rem"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:s}),n.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:a})]}),o.overridden&&n.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),n.jsx("textarea",{className:"form-textarea",value:l,onChange:w=>u(w.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${s} system prompt`}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:f,disabled:g||!y,children:g?"Saving…":"Save"}),o.overridden&&n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:p,disabled:g,title:"Discard the override and use the built-in default",children:"Revert to default"}),v&&n.jsx("span",{className:"msg-ok",style:{fontSize:"0.78rem"},children:"Saved"}),y&&!g&&!v&&n.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),n.jsxs("details",{style:{marginTop:"0.5rem"},children:[n.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),n.jsx("pre",{style:{marginTop:"0.5rem",padding:"0.75rem 1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",fontSize:"0.78rem",lineHeight:1.55,whiteSpace:"pre-wrap",maxHeight:"20rem",overflowY:"auto"},children:o.default})]}),n.jsx("span",{style:{display:"none"},children:e})]})}function Gb(e){return e.proposalId?"review":"automatic"}function Yh(e,s,a={}){const o=a.status??"pending",l=a.includeAutonomous??!1,u=[];for(const f of e)o==="pending"&&f.status!=="pending"||a.profile&&f.profileId!==a.profile||u.push({kind:"proposal",id:f.id,sortTimestamp:f.createdAt,commitmentMode:"review",profileId:f.profileId,proposal:f});if(o==="all")for(const f of s){const p=Gb(f);!l&&p==="automatic"||a.profile&&f.profileId!==a.profile||u.push({kind:"receipt",id:f.id,sortTimestamp:f.timestamp,commitmentMode:p,profileId:f.profileId,receipt:f})}return u.sort((f,p)=>p.sortTimestamp-f.sortTimestamp),typeof a.limit=="number"&&a.limit>0?u.slice(0,a.limit):u}const Kb=["https://","http://"];function Qp(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)?[]:Kb.some(l=>o.toLowerCase().startsWith(l))?[{label:a.label,href:o,description:a.description}]:[]}):[]}function Xp(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 tu({profileId:e,declared:s}){const{icon:a}=_r(e,s),o=Tw(e);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"id-rail",children:[n.jsx(Ep,{icon:a,className:"id-rail-icon"}),n.jsx("span",{className:"id-rail-name",children:o})]}),n.jsx("div",{className:"id-sep"})]})}function qb({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=ub(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 Yb({text:e}){return n.jsxs("div",{className:"preview-box preview-box-ai","data-testid":"ai-text",children:[n.jsxs("h4",{children:["Text — written by the AI",n.jsx("span",{className:"src-tag src-tag-sealed",children:"sealed"})]}),n.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})]})}let oc=null;function Jb(){return oc||(oc=L.getEnrichedAuthorizations().then(e=>new Map(e.map(s=>[s.authorizationId,s.bounds]))).catch(()=>new Map)),oc}function Qb(e){const[s,a]=h.useState(void 0);return h.useEffect(()=>{let o=!0;if(e)return Jb().then(l=>{o&&a(l.get(e))}),()=>{o=!1}},[e]),s}function Xb(e,s){const[a,o]=h.useState(null),[l,u]=h.useState(!1),[f,p]=h.useState(null);return h.useEffect(()=>{let g=!0;return o(null),p(null),u(!0),(async()=>{var v;try{try{const x=await L.getGateContent(e);if((v=x==null?void 0:x.gateContent)!=null&&v.intent){g&&o(x.gateContent.intent);return}}catch{}const y=await L.getAttestationIntent(e);if(!y){g&&p("Intent not available or you are not an authorized approver.");return}const w=await L.decryptIntent({intentCiphertext:y.intentCiphertext,encryptedKey:y.encryptedKey,approverId:s});g&&o(w)}catch(y){g&&p(y instanceof Error?y.message:"Failed to decrypt intent")}finally{g&&u(!1)}})(),()=>{g=!1}},[e,s]),{intent:a,loading:l,error:f}}function Jh(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 Zb(e){const s=Jh(e.limits),a=Jh(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 Zp(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=>Zp(s)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}const ek="setup__create_mandate";function eg({proposal:e,currentUserId:s,proposalLinks:a,toolDisplay:o,manifests:l,onContentState:u,onShownSnapshot:f,nameOf:p}){var be,oe,Le,ze,Ue;const[g,v]=h.useState(!1),[y,w]=h.useState(!1),[x,b]=h.useState(null),k=Sn(),{group:S,groupId:N,domain:E}=wt(),T=Object.entries(e.executionContext),P=ma(e.profileId),I=Qb(e.authorizationId),B=Aw(e.tool),{integrationId:M}=Wn(e.tool),q=Hn(M,l),{intent:z,loading:U,error:Z}=Xb(e.authorizationId,s),G=io(e),O=G.toolArgs!==null,[ne,fe]=h.useState([]),ee=[...Fw(e.executionContext,I,P),...nb(G.toolArgs),...ne],pe=h.useMemo(()=>eu(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=qw(e),Q=G.toolArgs?Qp(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=Tp(nt,Ze);if(!Ye){b(`Unknown profile "${nt}".`);return}const We=await L.getProfile(Ye.id),dt=Zb(we),ft=Ip(dt.bounds,We),Fe=Rp(dt.context,We);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:Ye.id,groupId:N,groupName:(S==null?void 0:S.name)??null,domain:E,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=db(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}=Wn(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(Sc,{args:G.toolArgs,display:o,heading:"",requestRefArg:ve}):null,qe=G.toolArgs?n.jsxs(n.Fragment,{children:[n.jsx(Sc,{args:G.toolArgs,display:o,heading:"",requestRefArg:ve}),T.length>0&&n.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:T.map(([we,nt],Ze)=>{const{label:Ye,hint:We}=Rw(we,P);return n.jsxs("span",{children:[Ze>0&&" · ",n.jsxs("span",{title:We,children:[Ye,"=",Zp(nt)]})]},we)})})]}):null;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"approval-summary","data-testid":"approval-summary",children:dp(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&&ch(G.toolArgs,o)!==void 0&&n.jsx(Yb,{text:ch(G.toolArgs,o)}),O&&n.jsx(Hp,{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=>(p==null?void 0:p(we))??we).join(", ")," — shared automatically once they sign in on a device."]}),O&&n.jsx(pb,{proposalId:e.id,systemName:q,toolArgs:G.toolArgs,sealed:G.sealed,onTone:_,onData:H}),O&&n.jsx(bb,{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)??Ot(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${g?"":" intent-clamped"}`,children:z}),n.jsx("button",{className:"btn btn-ghost btn-sm intent-toggle",onClick:()=>v(!g),children:g?"Show less":"Show full intent"})]}):U?n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"Loading intent…"}):n.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]})]}),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===ek&&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 tg({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:Bj.map(f=>n.jsx("button",{type:"button",className:`filter-chip${bp(e,f)?" selected":""}`,onClick:()=>s(Uj(e,f)),disabled:l,children:f},f))}),n.jsx("textarea",{"data-testid":"change-note",className:"form-input",value:e,maxLength:qi,onChange:f=>s(f.target.value),rows:3,placeholder:"What should the AI do differently?",disabled:l,style:{width:"100%",resize:"vertical",fontFamily:"inherit"}}),n.jsxs("div",{style:{textAlign:"right",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[e.length," / ",qi]}),u&&n.jsx("div",{className:"error-message",style:{marginTop:"0.4rem"},children:u}),n.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.5rem"},children:[n.jsx("button",{"data-testid":"btn-send-back",className:"btn btn-primary",onClick:a,disabled:l,children:l?"Sending…":"Send back for change"}),n.jsx("button",{className:"btn btn-ghost",onClick:o,disabled:l,children:"Cancel"})]}),n.jsx("p",{style:{fontSize:"0.72rem",color:"var(--text-tertiary)",marginTop:"0.5rem",marginBottom:0},children:"The AI is told: adjust and propose again — a new proposal you approve again. Nothing runs from this one."})]})}const tk={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired",refused:"Refused"},nk={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 lc(e){const s=Date.now()-e*1e3,a=s/36e5;return a<48?a<1?`${Math.max(1,Math.round(s/6e4))}m ago`:`${Math.round(a)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function rk(e){return e.split("__").pop()??e}function sk(e){const s=e.toLowerCase();return s.includes("delete")||s.includes("refund")||s.includes("cancel")||s.includes("revoke")}function ng(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=>ng(s)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Xh({item:e,onApprove:s,onReject:a,onChangeNeeded:o,resolving:l,proposalLinks:u,toolDisplay:f,manifests:p,currentUserId:g,inRow:v=!1}){const y=e.kind==="proposal",w=y?e.proposal.status:"executed",x=y?e.proposal.tool:e.receipt.action,b=rk(x),k=sk(x),{integrationId:S}=Wn(x),N=Hn(S,p),[E,T]=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=Xc(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"?Gj(e.proposal,g??""):null,G=y&&w==="refused"?Kj(e.proposal):null,O=Yw(y?e.proposal.rejectedBy??e.proposal.approverRejectedBy??null:null),ne=io(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?Qp(u,ne.toolArgs):[],_=Object.entries(ee??{}),se=_r(e.profileId).testSetup||ro(x);return n.jsxs("div",{className:v?"card card-in-row":"card id-card",children:[!v&&n.jsx(tu,{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=Xp(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:nk[w]}`,children:Z?Z.kind:G?G.kind:tk[w]}),n.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:lc(e.sortTimestamp)})]})]}),y&&e.proposal.status==="executed"&&n.jsx(qb,{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,", ",lc(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, ",lc(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(eg,{proposal:e.proposal,currentUserId:g??"",proposalLinks:u,toolDisplay:f,manifests:p,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(Sc,{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}=${ng(H)}`).join(" · ")})]}):n.jsxs(n.Fragment,{children:[n.jsx(Gp,{receipt:e.receipt,manifests:p}),e.receipt.proposalId&&n.jsx(Jp,{proposalId:e.receipt.proposalId,tool:e.receipt.action,manifests:p})]})]}),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"&&ip({loading:Q,readable:Ne})&&(E?n.jsx(tg,{note:P,onNoteChange:I,onSend:U,onCancel:()=>{T(!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:()=>T(!0),disabled:l,children:[n.jsx("span",{"aria-hidden":"true",children:"↩"})," Change needed"]}),n.jsxs("button",{"data-testid":"btn-reject",className:"btn btn-outline-strong",onClick:async()=>a==null?void 0:a(e.id,await 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 ak(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 ik(e,s){return e.map(a=>s.get(a)??a)}function rg(e){var b;const{groupId:s}=wt(),a=ma(e.profileId),[o,l]=h.useState(null),[u,f]=h.useState(new Map),[p,g]=h.useState(!0);h.useEffect(()=>{let k=!0;if(!s){g(!1);return}return g(!0),Promise.all([L.getTeamProfileConfig(s,e.profileId).catch(()=>null),L.getGroupById(s).catch(()=>null),L.listUsers().catch(()=>[])]).then(([S,N,E])=>{k&&(l(S),f(ak(E,(N==null?void 0:N.members)??[])))}).finally(()=>{k&&g(!1)}),()=>{k=!1}},[s,e.profileId]);const v=Vx(o??{}),y=ik(e.pendingApprovers??[],u),w=k=>u.get(k)??k,x=o&&((b=a==null?void 0:a.boundsSchema)!=null&&b.fields)?cj(e.executionContext,o,a.boundsSchema.fields):null;return{loading:p,profileConfig:o,requiredApprovals:v,approverNames:y,nameOf:w,aboveCapReason:x}}function sg(e,s){return!!e.createdBy&&!!s&&e.createdBy===s}function ag(e){return(e.pendingApprovers??[]).filter(s=>s!==e.createdBy)}function ok(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 lk({proposal:e,currentUserId:s,onAction:a,onMessage:o,proposalLinks:l,toolDisplay:u,manifests:f,inRow:p=!1}){const[g,v]=h.useState(!1),[y,w]=h.useState(!1),[x,b]=h.useState(!1),[k,S]=h.useState(""),[N,E]=h.useState(""),[T,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||ro(e.tool),G=ag(e),O=e.approvedBy??{},ne=Object.keys(O).length,fe=s in O,ee=rg(e),pe=sg(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(Vc()){o(Gc);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,kp(),_,se),o("Action rejected."),a()}catch(_){o(_ instanceof Error?_.message:"Rejection failed")}finally{w(!1)}},Y=async()=>{const _=Xc(k);if(!_.valid){E(_.error);return}E(""),P(!0),o("");try{const{noteEncrypted:se}=await L.encryptProposalNote(_.trimmed,op(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=g||y||T;return n.jsxs("div",{className:p?"card card-in-row":"card id-card",children:[!p&&n.jsx(tu,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:p?"none":"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[Z&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const _=Xp(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:ok(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(eg,{proposal:e,currentUserId:s,proposalLinks:l,toolDisplay:u,manifests:f,nameOf:ee.nameOf,onContentState:({loading:_,readable:se})=>{B(_),q(se)},onShownSnapshot:_=>{z.current=_}}),!fe&&ip({loading:I,readable:M})&&(x?n.jsx(tg,{note:k,onNoteChange:S,onSend:Y,onCancel:()=>{b(!1),S(""),E("")},sending:T,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:g?"Approving...":"Approve"}),n.jsxs("button",{"data-testid":"btn-change-needed",className:"btn btn-outline-strong",onClick:()=>b(!0),disabled:A,children:[n.jsx("span",{"aria-hidden":"true",children:"↩"})," Change needed"]}),n.jsxs("button",{"data-testid":"btn-reject",className:"btn btn-outline-strong",onClick:Q,disabled:A,children:[n.jsx("span",{"aria-hidden":"true",children:"✕"})," ",y?"Rejecting...":"Reject"]})]})]})),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).`:""]}),!p&&n.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})]})}function Zh({proposal:e,manifests:s,titles:a,open:o,onToggle:l,who:u,children:f}){const p=Date.now(),g=np(e.expiresAt,p),v=Lr(),y=h.useRef(null);return h.useEffect(()=>{var w;o&&((w=y.current)==null||w.scrollIntoView({block:"nearest"}))},[o]),n.jsxs("div",{ref:y,className:`appr-item${o?" is-open":""}`,"data-testid":"approval-row","data-proposal-id":e.id,children:[n.jsxs("button",{type:"button",className:"appr-item-head","aria-expanded":o,onClick:l,children:[n.jsxs("div",{className:"appr-item-main",children:[n.jsx(us,{profileId:e.profileId,area:$r(e.profileId,v),system:pa(e.tool,s),time:tp(e.createdAt,p)}),n.jsx("div",{className:"appr-item-sum","data-testid":"approval-row-summary",children:n.jsx(fp,{proposal:e,manifests:s})}),n.jsx(ca,{title:e.authorizationId?a[e.authorizationId]:void 0,area:$r(e.profileId,v)}),g&&n.jsx("div",{className:"obj-due",children:g}),u&&n.jsx("div",{className:"appr-item-who",children:u})]}),n.jsx("span",{className:"appr-item-chev","aria-hidden":"true",children:"›"})]}),o&&n.jsx("div",{className:"appr-item-body",children:f})]})}function ck(){const{domain:e,user:s}=wt(),a=(s==null?void 0:s.id)??"",[o,l]=h.useState("awaiting-me"),[u,f]=h.useState([]),[p,g]=h.useState([]),[v,y]=h.useState({}),[w,x]=h.useState(!0),[b,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),Mt(S,3e4);const[N,E]=h.useState([]),T=h.useCallback(async()=>{try{const K=await L.getMyProposals(e);E(K)}catch{}},[e]);Me("proposal-added",T),Me("proposal-approved",T),Me("proposal-rejected",T),Me("proposal-resolved",T),Me("execution-failed",T),Mt(T,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(()=>Yh(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),Mt(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),Mt(Z,3e4),h.useEffect(()=>{L.getLabelManifests().then(g).catch(()=>{}),L.getToolDisplay().then(y).catch(()=>{})},[]);const G=K=>{var J;return(J=p.find(ye=>ye.id===K.split("__")[0]))==null?void 0:J.proposalLinks};h.useEffect(()=>{S(),T(),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,_]);Mt(ge,3e4,`${e}:${_}`);const ve=async(K,J,ye,He)=>{if(J==="commit"&&Vc()){A(Gc);return}Q(K),A("");try{const Ve=O.find(W=>W.id===K)??N.find(W=>W.id===K),rt=Hx(Ve,e),Vt=Ve?await oa(Ve):void 0;let Bt=ye??{};if((ye==null?void 0:ye.outcome)==="change_needed"&&ye.note){const W=Ve?op(Ve,a):[a],{noteEncrypted:xe}=await L.encryptProposalNote(ye.note,W);Bt={outcome:"change_needed",noteEncrypted:xe}}const et=await L.resolveProposal(K,J,rt,{...Bt,contentHash:Vt,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(),T()])}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",kp(),J),be=(K,J,ye)=>ve(K,"reject",Wj(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(()=>Yh(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(Vm,{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(Xh,{proposalLinks:K.kind==="proposal"?G(K.proposal.tool):void 0,toolDisplay:K.kind==="proposal"?v[K.proposal.tool]:void 0,manifests:p,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(Zh,{proposal:K.proposal,manifests:p,titles:me,open:Ze===ye,onToggle:()=>Fe(ye),children:J},ye)}),u.map(K=>n.jsx(Zh,{proposal:K,manifests:p,titles:me,open:Ze===K.id,onToggle:()=>Fe(K.id),who:"Team approval — other people are involved",children:n.jsx(lk,{inRow:!0,proposal:K,currentUserId:a,onAction:ze,onMessage:k,proposalLinks:G(K.tool),toolDisplay:v[K.tool],manifests:p},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(dk,{proposal:K,currentUserId:a,onCancel:async()=>{try{await L.rejectProposal(K.id,{reason:"cancelled by creator"}),q(),T()}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:Ot(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(Xh,{proposalLinks:K.kind==="proposal"?G(K.proposal.tool):void 0,toolDisplay:K.kind==="proposal"?v[K.proposal.tool]:void 0,manifests:p,currentUserId:a,item:K,onApprove:le,onReject:qe,onChangeNeeded:be,resolving:X===K.id},K.id))})]})]})}function uk(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 dk({proposal:e,currentUserId:s,onCancel:a,onWithdraw:o}){const[l,u]=h.useState(!1),[f,p]=h.useState(!1),[g,v]=h.useState(""),y=rg(e),w=sg(e,s),x=ag(e),b=e.approvedBy??{},k=Object.keys(b).length,S=x.length>0,N=async()=>{u(!0);try{await a()}finally{u(!1)}},E=async()=>{p(!0),v("");try{await o()}catch(P){v(P instanceof Error?P.message:"Withdraw failed")}finally{p(!1)}},T=_r(e.profileId).testSetup||ro(e.tool);return n.jsxs("div",{className:"card id-card",children:[n.jsx(tu,{profileId:e.profileId}),n.jsxs("div",{className:"id-body",children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[n.jsx("code",{style:{fontSize:"0.85rem"},children:e.tool.split("__").pop()??e.tool}),T&&n.jsx("span",{className:"sim-mark",children:"Test setup"}),n.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:uk(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:E,disabled:f,children:f?"Withdrawing...":"Withdraw"}),g&&n.jsx("p",{className:"msg-error",style:{fontSize:"0.78rem",margin:0},children:g})]}):n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:n.jsx("button",{className:"btn btn-outline-strong btn-sm",onClick:N,disabled:l,children:l?"Cancelling...":"Cancel"})})]})]})}const fk=`# 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 hk(){const[e,s]=h.useState(""),[a,o]=h.useState(""),[l,u]=h.useState(!0),[f,p]=h.useState(!1),[g,v]=h.useState(null),[y,w]=h.useState(!1),x=e!==a,b=new Blob([e]).size,k=16*1024;h.useEffect(()=>{if(!x)return;const T=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",T),document.addEventListener("click",P,!0),()=>{window.removeEventListener("beforeunload",T),document.removeEventListener("click",P,!0)}},[x]),h.useEffect(()=>{let T=!1;return L.getAgentContext().then(P=>{T||(s(P),o(P))}).catch(P=>{T||v({kind:"error",text:P instanceof Error?P.message:"Failed to load context"})}).finally(()=>{T||u(!1)}),()=>{T=!0}},[]);const S=async()=>{p(!0),v(null);try{await L.saveAgentContext(e),o(e),v({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(T){v({kind:"error",text:T instanceof Error?T.message:"Save failed"})}finally{p(!1)}},N=()=>{s(a),v(null)},E=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||s(fk)};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"page-header",children:[n.jsx("h1",{className:"page-title",children:"Agent Brief"}),n.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!e.trim()&&!l&&n.jsx("button",{className:"btn btn-primary btn-sm",onClick:E,disabled:f,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),g&&n.jsx("div",{className:g.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:g.text}),n.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[n.jsx("div",{className:"card intent-pane chat",children:n.jsx(Gi,{target:{kind:"context"},currentText:e,onApply:T=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||s(T)},greeting:"Tell me what your agent should know — I'll help shape your standing orders. Or ask me to draft a full brief and we'll iterate.",placeholder:"Ask for help with your brief…"})}),n.jsxs("div",{className:"card intent-pane document",children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[n.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),n.jsxs("span",{className:b>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:T=>s(T.target.value),placeholder:l?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:l,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),n.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[n.jsx("button",{className:"btn btn-ghost",onClick: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(gp,{open:y,onClose:()=>w(!1),ariaLabel:"Brief assistant",children:n.jsx(Gi,{target:{kind:"context"},currentText:e,onApply:T=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(s(T),w(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function mk(e){const s=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return s&&s[1].replace(/<[^>]+>/g,"").trim()||"Report"}function pk(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 gk(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function yk(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 vk(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 xk(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 em(e,s="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:s}}function wk(e){return/Labels?$/.test(e)||e==="limits"||e==="fields"}function jk(e,s){const a=s[e];return a==null||a===""||wk(e)?null:typeof a=="object"?JSON.stringify(a):String(a)}function Sk(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 bk(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 kk="allow-popups allow-popups-to-escape-sandbox",Nk="AI analysis — not verified",Ck="Green = verified by the gateway — raw signed fields only",Ek="Grey dashed = the AI's own analysis, not verified",Tk="= translation by the AI, not verified",Ak="Übersetzung anzeigen / show translation";function tm(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 Ik(e){return(e.elements??[]).length===0&&e.renderedHtml.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<[^>]+>/g,"").replace(/ /g," ").trim()===""}function Rk(e,s){return s&&e.renderedHtmlGloss?e.renderedHtmlGloss:e.renderedHtml}function Pk(e,s,a){const o=new URLSearchParams(e);return o.set("element",s),a?o.set("ticket",a):o.delete("ticket"),o}const $k={"sv-ticket":"Action","sv-approval":"Approval","sv-mandate":"Mandate","sv-record":"Record","sv-case":"Case","sv-metric":"Figure"};function _k(e){return e.filter(s=>s.status==="unverifiable").map(s=>({elementId:s.id,text:`${$k[s.kind]??"Element"}: ${s.reason??"could not be checked"}`}))}function Lk(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 zk(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 nu={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},Fk={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function Mk(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 Ok(e,s){const a=Fk[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:{...nu,marginTop:"0.5rem"},children:a.map(o=>n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:o}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof s[o]=="object"?JSON.stringify(s[o]):String(s[o])})]},o))})]})}function cc(e,s){return s?n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:e}),s.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",s.reason??"no further detail."]}):n.jsxs(n.Fragment,{children:[n.jsx("dl",{style:nu,children:Mk(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))}),Ok(e,s.data??{})]})]}):null}function Bk({report:e,elementId:s,ticketParam:a,onClose:o,onSelectTicket:l}){var w;const u=e.elements.find(x=>x.id===s),f=bk(u,a),p=f?e.ticketDetails[f]:void 0,g=Lk(u),v=(w=e.proof.verifiedValues.find(x=>x.elementId===s))==null?void 0:w.summary,y=h.useRef(null);return h.useEffect(()=>{const x=y.current;if(!x||typeof x.getBoundingClientRect!="function")return;const b=x.getBoundingClientRect().top;(b<0||b>window.innerHeight-80)&&x.scrollIntoView({block:"start",behavior:"smooth"})},[s,a]),n.jsxs("div",{className:"card reports-detail",ref:y,children:[n.jsxs("div",{className:"card-header",children:[n.jsx("div",{className:"card-title",children:"Details"}),n.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:o,children:"Close"})]}),v&&n.jsx("p",{className:"page-subtitle",style:{marginTop:0},children:v}),g.length>0&&n.jsx("div",{className:"reports-case-steps",role:"group","aria-label":"Case steps",children:g.map(x=>n.jsxs("button",{type:"button",className:`btn btn-sm ${x.ticketId===f?"btn-secondary":"btn-ghost"}`,"aria-pressed":x.ticketId===f,onClick:()=>l(x.ticketId),children:[x.isGoal?"Goal: ":"",x.label]},x.ticketId))}),!u&&n.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),u&&!f&&(u.status==="unverifiable"?n.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",u.reason??"no further detail."]}):n.jsx("dl",{style:nu,children:Object.keys(u.data??{}).map(x=>{const b=jk(x,u.data??{});return b===null?null:n.jsxs("div",{style:{display:"contents"},children:[n.jsx("dt",{style:{color:"var(--text-muted)"},children:x}),n.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:b})]},x)})})),p&&n.jsxs(n.Fragment,{children:[cc("Ticket",p.ticket),cc("Mandate",p.mandate),cc("Approval",p.approval)]}),f&&!p&&n.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",f,"."]})]})}async function Dk(e){const{html:s,filename:a}=await e.exportReport();e.download(s,a),await e.refresh()}function nm({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 Uk({report:e,open:s,selectedId:a,onOpenElement:o,detail:l}){const{proof:u,coverage:f}=e,p=_k(e.elements),g=Sk(f),v=vk(f),y=xk(f),w=em(u.signaturesValid),x=em(u.recordsChecked);return n.jsxs("div",{className:`reports-side${s?" reports-side-open":""}`,children:[l,n.jsxs("div",{className:"card",children:[n.jsx("div",{className:"card-title",children:"Proof"}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Tickets referenced"}),n.jsx("b",{children:u.ticketsReferenced.length})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Signatures valid"}),n.jsx("b",{className:w.kind==="ok"?"msg-ok":void 0,children:w.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Records checked"}),n.jsx("b",{className:x.kind==="ok"?"msg-ok":void 0,children:x.text})]}),n.jsxs("div",{className:"reports-row",children:[n.jsx("span",{children:"Not verifiable"}),n.jsx("b",{children:u.unverifiableCount})]}),p.map(b=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button reports-row-bad${a===b.elementId?" reports-row-selected":""}`,onClick:()=>o(b.elementId),children:[n.jsx("span",{children:b.text}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},b.elementId))]}),n.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Coverage"}),v.kind==="error"?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"reports-error",role:"alert",children:v.text}),n.jsx(nm,{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(nm,{detail:y.detail})]}),g&&n.jsx("p",{className:"reports-missing",children:g})]}),u.verifiedValues.length>0&&n.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[n.jsx("div",{className:"card-title",children:"Checked values"}),u.verifiedValues.map(b=>n.jsxs("button",{type:"button",className:`reports-row reports-row-button${a===b.elementId?" reports-row-selected":""}`,onClick:()=>o(b.elementId),title:"Show details",children:[n.jsx("span",{children:b.summary}),n.jsx("span",{"aria-hidden":"true",children:"›"})]},b.elementId))]})]})}function Wk(){const[e,s]=h.useState(null),[a,o]=h.useState(!0),[l,u]=h.useState(null),[f,p]=h.useState(!1),[g,v]=h.useState(!1),[y,w]=h.useState(null),[x,b]=h.useState(!1),[k,S]=h.useState(!1),[N,E]=gs(),T=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),T().finally(()=>o(!1))},[T]);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(()=>{p(!0),L.recheckReport().then(({report:O})=>s(O)).catch(O=>u(O instanceof Error?O.message:String(O))).finally(()=>p(!1))},[]),B=h.useCallback(async()=>{v(!0),w(null);try{await Dk({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:T})}catch(O){w(O instanceof Error?O.message:String(O))}finally{v(!1)}},[T]),M=N.get("element"),q=N.get("ticket"),z=h.useCallback((O,ne)=>{E(Pk(N,O,ne))},[N,E]),U=h.useCallback(()=>{const O=new URLSearchParams(N);O.delete("element"),O.delete("ticket"),E(O,{replace:!0})},[N,E]);if(a)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(l)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(fs,{icon:"⚠",title:"Report unavailable",text:l})]});if(!e)return n.jsxs("div",{className:"page-inner",children:[n.jsx("div",{className:"page-header",children:n.jsx("h1",{className:"page-title",children:"Reports"})}),n.jsx(fs,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const Z=mk(e.renderedHtml),G=pk(e.elements);return n.jsx("div",{className:"page-inner reports-page",children:n.jsxs("div",{className:"reports-layout",children:[n.jsxs("div",{className:"reports-bar",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"page-title",children:Z}),n.jsxs("p",{className:"reports-period","data-testid":"report-period",title:Di(e.coverage).title,children:[n.jsx("b",{children:Di(e.coverage).text})," · written ",Fm(e.savedAt,Date.now())]}),n.jsxs("p",{className:"page-subtitle",children:[G?`written by the AI under mandate ${G} · `:"","checked ",gk(e.checkedAt)]})]}),n.jsxs("div",{className:"reports-bar-actions",children:[n.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:I,disabled:f,children:f?"Checking…":"Check again"}),n.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:B,disabled:g,children:g?"Exporting…":"Export with proof"})]})]}),y&&n.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",y]}),n.jsxs("div",{className:"reports-summary-chip",children:[n.jsx("span",{children:yk(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"}),Ck]}),n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("span",{className:"reports-sw reports-sw-a"}),Ek," (“",Nk,"”)"]}),e.renderedHtmlGloss&&n.jsxs("span",{className:"reports-legend-chip",children:[n.jsx("i",{className:"reports-gloss-swatch",children:"Abc"})," ",Tk]})]}),tm(e)&&n.jsx("p",{className:"reports-error",role:"status",style:{margin:"0 0 0.5rem 0"},children:tm(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:Ak})]}),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."}),Ik(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:kk,srcDoc:zk(Rk(e,k)),className:"reports-iframe"})]}),n.jsx(Uk,{report:e,open:x||!!M,selectedId:M,onOpenElement:O=>z(O),detail:M?n.jsx(Bk,{report:e,elementId:M,ticketParam:q,onClose:U,onSelectTicket:O=>z(M,O)}):void 0})]})]})})}function cs({to:e}){const{search:s,hash:a}=Xt();return n.jsx(On,{to:`${e}${s}${a}`,replace:!0})}function Hk({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 Vk(){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(ox,{children:[n.jsx(it,{path:"/login",element:e?n.jsx(On,{to:"/",replace:!0}):n.jsx(cw,{})}),n.jsx(it,{path:"/onboarding",element:e?n.jsx(pw,{}):n.jsx(On,{to:"/login",replace:!0})}),n.jsxs(it,{element:n.jsx(Hk,{children:n.jsx(lw,{})}),children:[n.jsx(it,{path:"/",element:n.jsx(sj,{})}),n.jsx(it,{path:"/mandates",element:n.jsx(xS,{})}),n.jsx(it,{path:"/mandates/new/intent",element:n.jsx(Ij,{})}),n.jsx(it,{path:"/mandates/new/sign",element:n.jsx(qj,{})}),n.jsx(it,{path:"/integrations",element:n.jsx(tS,{})}),n.jsx(it,{path:"/team",element:n.jsx(nS,{})}),n.jsx(it,{path:"/tickets",element:n.jsx($b,{})}),n.jsx(it,{path:"/blocked",element:n.jsx(_b,{})}),n.jsx(it,{path:"/approvals",element:n.jsx(ck,{})}),n.jsx(it,{path:"/reports",element:n.jsx(Wk,{})}),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(hk,{})}),n.jsx(it,{path:"/settings",element:n.jsx(Hb,{})}),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 Gk(){return n.jsx(Px,{children:n.jsx(qx,{children:n.jsx(Qx,{children:n.jsx(Vk,{})})})})}sv.createRoot(document.getElementById("root")).render(n.jsx(h.StrictMode,{children:n.jsx(Gk,{})}));
|