@suveren/gateway 0.18.1 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,111 +0,0 @@
1
- var Xm=Object.defineProperty;var qm=(e,t,n)=>t in e?Xm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var kr=(e,t,n)=>qm(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();var $u={exports:{}},Ma={},Lu={exports:{}},le={};/**
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 hs=Symbol.for("react.element"),Zm=Symbol.for("react.portal"),ep=Symbol.for("react.fragment"),tp=Symbol.for("react.strict_mode"),np=Symbol.for("react.profiler"),rp=Symbol.for("react.provider"),sp=Symbol.for("react.context"),ap=Symbol.for("react.forward_ref"),ip=Symbol.for("react.suspense"),op=Symbol.for("react.memo"),lp=Symbol.for("react.lazy"),Xl=Symbol.iterator;function cp(e){return e===null||typeof e!="object"?null:(e=Xl&&e[Xl]||e["@@iterator"],typeof e=="function"?e:null)}var Mu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Fu=Object.assign,Ou={};function yr(e,t,n){this.props=e,this.context=t,this.refs=Ou,this.updater=n||Mu}yr.prototype.isReactComponent={};yr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};yr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Bu(){}Bu.prototype=yr.prototype;function Uo(e,t,n){this.props=e,this.context=t,this.refs=Ou,this.updater=n||Mu}var Wo=Uo.prototype=new Bu;Wo.constructor=Uo;Fu(Wo,yr.prototype);Wo.isPureReactComponent=!0;var ql=Array.isArray,Du=Object.prototype.hasOwnProperty,Ho={current:null},Uu={key:!0,ref:!0,__self:!0,__source:!0};function Wu(e,t,n){var r,a={},i=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)Du.call(t,r)&&!Uu.hasOwnProperty(r)&&(a[r]=t[r]);var l=arguments.length-2;if(l===1)a.children=n;else if(1<l){for(var c=Array(l),d=0;d<l;d++)c[d]=arguments[d+2];a.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)a[r]===void 0&&(a[r]=l[r]);return{$$typeof:hs,type:e,key:i,ref:o,props:a,_owner:Ho.current}}function up(e,t){return{$$typeof:hs,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Vo(e){return typeof e=="object"&&e!==null&&e.$$typeof===hs}function dp(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Zl=/\/+/g;function si(e,t){return typeof e=="object"&&e!==null&&e.key!=null?dp(""+e.key):t.toString(36)}function Gs(e,t,n,r,a){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case hs:case Zm:o=!0}}if(o)return o=e,a=a(o),e=r===""?"."+si(o,0):r,ql(a)?(n="",e!=null&&(n=e.replace(Zl,"$&/")+"/"),Gs(a,t,n,"",function(d){return d})):a!=null&&(Vo(a)&&(a=up(a,n+(!a.key||o&&o.key===a.key?"":(""+a.key).replace(Zl,"$&/")+"/")+e)),t.push(a)),1;if(o=0,r=r===""?".":r+":",ql(e))for(var l=0;l<e.length;l++){i=e[l];var c=r+si(i,l);o+=Gs(i,t,n,c,a)}else if(c=cp(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=r+si(i,l++),o+=Gs(i,t,n,c,a);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return o}function bs(e,t,n){if(e==null)return e;var r=[],a=0;return Gs(e,r,"","",function(i){return t.call(n,i,a++)}),r}function fp(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var et={current:null},Ks={transition:null},mp={ReactCurrentDispatcher:et,ReactCurrentBatchConfig:Ks,ReactCurrentOwner:Ho};function Hu(){throw Error("act(...) is not supported in production builds of React.")}le.Children={map:bs,forEach:function(e,t,n){bs(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return bs(e,function(){t++}),t},toArray:function(e){return bs(e,function(t){return t})||[]},only:function(e){if(!Vo(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};le.Component=yr;le.Fragment=ep;le.Profiler=np;le.PureComponent=Uo;le.StrictMode=tp;le.Suspense=ip;le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=mp;le.act=Hu;le.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=Fu({},e.props),a=e.key,i=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,o=Ho.current),t.key!==void 0&&(a=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)Du.call(t,c)&&!Uu.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var d=0;d<c;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:hs,type:e.type,key:a,ref:i,props:r,_owner:o}};le.createContext=function(e){return e={$$typeof:sp,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:rp,_context:e},e.Consumer=e};le.createElement=Wu;le.createFactory=function(e){var t=Wu.bind(null,e);return t.type=e,t};le.createRef=function(){return{current:null}};le.forwardRef=function(e){return{$$typeof:ap,render:e}};le.isValidElement=Vo;le.lazy=function(e){return{$$typeof:lp,_payload:{_status:-1,_result:e},_init:fp}};le.memo=function(e,t){return{$$typeof:op,type:e,compare:t===void 0?null:t}};le.startTransition=function(e){var t=Ks.transition;Ks.transition={};try{e()}finally{Ks.transition=t}};le.unstable_act=Hu;le.useCallback=function(e,t){return et.current.useCallback(e,t)};le.useContext=function(e){return et.current.useContext(e)};le.useDebugValue=function(){};le.useDeferredValue=function(e){return et.current.useDeferredValue(e)};le.useEffect=function(e,t){return et.current.useEffect(e,t)};le.useId=function(){return et.current.useId()};le.useImperativeHandle=function(e,t,n){return et.current.useImperativeHandle(e,t,n)};le.useInsertionEffect=function(e,t){return et.current.useInsertionEffect(e,t)};le.useLayoutEffect=function(e,t){return et.current.useLayoutEffect(e,t)};le.useMemo=function(e,t){return et.current.useMemo(e,t)};le.useReducer=function(e,t,n){return et.current.useReducer(e,t,n)};le.useRef=function(e){return et.current.useRef(e)};le.useState=function(e){return et.current.useState(e)};le.useSyncExternalStore=function(e,t,n){return et.current.useSyncExternalStore(e,t,n)};le.useTransition=function(){return et.current.useTransition()};le.version="18.3.1";Lu.exports=le;var u=Lu.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 pp=u,hp=Symbol.for("react.element"),gp=Symbol.for("react.fragment"),yp=Object.prototype.hasOwnProperty,vp=pp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,xp={key:!0,ref:!0,__self:!0,__source:!0};function Vu(e,t,n){var r,a={},i=null,o=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)yp.call(t,r)&&!xp.hasOwnProperty(r)&&(a[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)a[r]===void 0&&(a[r]=t[r]);return{$$typeof:hp,type:e,key:i,ref:o,props:a,_owner:vp.current}}Ma.Fragment=gp;Ma.jsx=Vu;Ma.jsxs=Vu;$u.exports=Ma;var s=$u.exports,Gu={exports:{}},pt={},Ku={exports:{}},Yu={};/**
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
- */(function(e){function t($,A){var H=$.length;$.push(A);e:for(;0<H;){var I=H-1>>>1,F=$[I];if(0<a(F,A))$[I]=A,$[H]=F,H=I;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var A=$[0],H=$.pop();if(H!==A){$[0]=H;e:for(var I=0,F=$.length,Y=F>>>1;I<Y;){var q=2*(I+1)-1,ne=$[q],ce=q+1,he=$[ce];if(0>a(ne,H))ce<F&&0>a(he,ne)?($[I]=he,$[ce]=H,I=ce):($[I]=ne,$[q]=H,I=q);else if(ce<F&&0>a(he,H))$[I]=he,$[ce]=H,I=ce;else break e}}return A}function a($,A){var H=$.sortIndex-A.sortIndex;return H!==0?H:$.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],d=[],f=1,m=null,p=3,w=!1,x=!1,v=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y($){for(var A=n(d);A!==null;){if(A.callback===null)r(d);else if(A.startTime<=$)r(d),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(d)}}function j($){if(v=!1,y($),!x)if(n(c)!==null)x=!0,D(b);else{var A=n(d);A!==null&&oe(j,A.startTime-$)}}function b($,A){x=!1,v&&(v=!1,g(P),P=-1),w=!0;var H=p;try{for(y(A),m=n(c);m!==null&&(!(m.expirationTime>A)||$&&!M());){var I=m.callback;if(typeof I=="function"){m.callback=null,p=m.priorityLevel;var F=I(m.expirationTime<=A);A=e.unstable_now(),typeof F=="function"?m.callback=F:m===n(c)&&r(c),y(A)}else r(c);m=n(c)}if(m!==null)var Y=!0;else{var q=n(d);q!==null&&oe(j,q.startTime-A),Y=!1}return Y}finally{m=null,p=H,w=!1}}var E=!1,C=null,P=-1,N=5,_=-1;function M(){return!(e.unstable_now()-_<N)}function V(){if(C!==null){var $=e.unstable_now();_=$;var A=!0;try{A=C(!0,$)}finally{A?J():(E=!1,C=null)}}else E=!1}var J;if(typeof h=="function")J=function(){h(V)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,z=B.port2;B.port1.onmessage=V,J=function(){z.postMessage(null)}}else J=function(){S(V,0)};function D($){C=$,E||(E=!0,J())}function oe($,A){P=S(function(){$(e.unstable_now())},A)}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($){$.callback=null},e.unstable_continueExecution=function(){x||w||(x=!0,D(b))},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):N=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function($){switch(p){case 1:case 2:case 3:var A=3;break;default:A=p}var H=p;p=A;try{return $()}finally{p=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,A){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var H=p;p=$;try{return A()}finally{p=H}},e.unstable_scheduleCallback=function($,A,H){var I=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?I+H:I):H=I,$){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=H+F,$={id:f++,callback:A,priorityLevel:$,startTime:H,expirationTime:F,sortIndex:-1},H>I?($.sortIndex=H,t(d,$),n(c)===null&&$===n(d)&&(v?(g(P),P=-1):v=!0,oe(j,H-I))):($.sortIndex=F,t(c,$),x||w||(x=!0,D(b))),$},e.unstable_shouldYield=M,e.unstable_wrapCallback=function($){var A=p;return function(){var H=p;p=A;try{return $.apply(this,arguments)}finally{p=H}}}})(Yu);Ku.exports=Yu;var wp=Ku.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 jp=u,mt=wp;function L(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Qu=new Set,Xr={};function Dn(e,t){ur(e,t),ur(e+"Capture",t)}function ur(e,t){for(Xr[e]=t,e=0;e<t.length;e++)Qu.add(t[e])}var Yt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Bi=Object.prototype.hasOwnProperty,Sp=/^[: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]*$/,ec={},tc={};function kp(e){return Bi.call(tc,e)?!0:Bi.call(ec,e)?!1:Sp.test(e)?tc[e]=!0:(ec[e]=!0,!1)}function bp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Np(e,t,n,r){if(t===null||typeof t>"u"||bp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function tt(e,t,n,r,a,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var He={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){He[e]=new tt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];He[t]=new tt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){He[e]=new tt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){He[e]=new tt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){He[e]=new tt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){He[e]=new tt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){He[e]=new tt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){He[e]=new tt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){He[e]=new tt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Go=/[\-:]([a-z])/g;function Ko(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Go,Ko);He[t]=new tt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Go,Ko);He[t]=new tt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Go,Ko);He[t]=new tt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){He[e]=new tt(e,1,!1,e.toLowerCase(),null,!1,!1)});He.xlinkHref=new tt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){He[e]=new tt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Yo(e,t,n,r){var a=He.hasOwnProperty(t)?He[t]:null;(a!==null?a.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Np(t,n,a,r)&&(n=null),r||a===null?kp(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):a.mustUseProperty?e[a.propertyName]=n===null?a.type===3?!1:"":n:(t=a.attributeName,r=a.attributeNamespace,n===null?e.removeAttribute(t):(a=a.type,n=a===3||a===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Zt=jp.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Ns=Symbol.for("react.element"),Gn=Symbol.for("react.portal"),Kn=Symbol.for("react.fragment"),Qo=Symbol.for("react.strict_mode"),Di=Symbol.for("react.profiler"),Ju=Symbol.for("react.provider"),Xu=Symbol.for("react.context"),Jo=Symbol.for("react.forward_ref"),Ui=Symbol.for("react.suspense"),Wi=Symbol.for("react.suspense_list"),Xo=Symbol.for("react.memo"),sn=Symbol.for("react.lazy"),qu=Symbol.for("react.offscreen"),nc=Symbol.iterator;function br(e){return e===null||typeof e!="object"?null:(e=nc&&e[nc]||e["@@iterator"],typeof e=="function"?e:null)}var Ee=Object.assign,ai;function Lr(e){if(ai===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);ai=t&&t[1]||""}return`
34
- `+ai+e}var ii=!1;function oi(e,t){if(!e||ii)return"";ii=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var a=d.stack.split(`
35
- `),i=r.stack.split(`
36
- `),o=a.length-1,l=i.length-1;1<=o&&0<=l&&a[o]!==i[l];)l--;for(;1<=o&&0<=l;o--,l--)if(a[o]!==i[l]){if(o!==1||l!==1)do if(o--,l--,0>l||a[o]!==i[l]){var c=`
37
- `+a[o].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=o&&0<=l);break}}}finally{ii=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Lr(e):""}function Cp(e){switch(e.tag){case 5:return Lr(e.type);case 16:return Lr("Lazy");case 13:return Lr("Suspense");case 19:return Lr("SuspenseList");case 0:case 2:case 15:return e=oi(e.type,!1),e;case 11:return e=oi(e.type.render,!1),e;case 1:return e=oi(e.type,!0),e;default:return""}}function Hi(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Kn:return"Fragment";case Gn:return"Portal";case Di:return"Profiler";case Qo:return"StrictMode";case Ui:return"Suspense";case Wi:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Xu:return(e.displayName||"Context")+".Consumer";case Ju:return(e._context.displayName||"Context")+".Provider";case Jo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Xo:return t=e.displayName||null,t!==null?t:Hi(e.type)||"Memo";case sn:t=e._payload,e=e._init;try{return Hi(e(t))}catch{}}return null}function Ep(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Hi(t);case 8:return t===Qo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function xn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Zu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Tp(e){var t=Zu(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var a=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Cs(e){e._valueTracker||(e._valueTracker=Tp(e))}function ed(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Zu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function la(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Vi(e,t){var n=t.checked;return Ee({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function rc(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=xn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function td(e,t){t=t.checked,t!=null&&Yo(e,"checked",t,!1)}function Gi(e,t){td(e,t);var n=xn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ki(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ki(e,t.type,xn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function sc(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ki(e,t,n){(t!=="number"||la(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Mr=Array.isArray;function sr(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+xn(n),t=null,a=0;a<e.length;a++){if(e[a].value===n){e[a].selected=!0,r&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function Yi(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(L(91));return Ee({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function ac(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(L(92));if(Mr(n)){if(1<n.length)throw Error(L(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:xn(n)}}function nd(e,t){var n=xn(t.value),r=xn(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function ic(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function rd(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Qi(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?rd(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Es,sd=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,a){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,a)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Es=Es||document.createElement("div"),Es.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Es.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function qr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Dr={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},Rp=["Webkit","ms","Moz","O"];Object.keys(Dr).forEach(function(e){Rp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Dr[t]=Dr[e]})});function ad(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Dr.hasOwnProperty(e)&&Dr[e]?(""+t).trim():t+"px"}function id(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=ad(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var Pp=Ee({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 Ji(e,t){if(t){if(Pp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(L(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(L(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(L(61))}if(t.style!=null&&typeof t.style!="object")throw Error(L(62))}}function Xi(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var qi=null;function qo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Zi=null,ar=null,ir=null;function oc(e){if(e=vs(e)){if(typeof Zi!="function")throw Error(L(280));var t=e.stateNode;t&&(t=Ua(t),Zi(e.stateNode,e.type,t))}}function od(e){ar?ir?ir.push(e):ir=[e]:ar=e}function ld(){if(ar){var e=ar,t=ir;if(ir=ar=null,oc(e),t)for(e=0;e<t.length;e++)oc(t[e])}}function cd(e,t){return e(t)}function ud(){}var li=!1;function dd(e,t,n){if(li)return e(t,n);li=!0;try{return cd(e,t,n)}finally{li=!1,(ar!==null||ir!==null)&&(ud(),ld())}}function Zr(e,t){var n=e.stateNode;if(n===null)return null;var r=Ua(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(L(231,t,typeof n));return n}var eo=!1;if(Yt)try{var Nr={};Object.defineProperty(Nr,"passive",{get:function(){eo=!0}}),window.addEventListener("test",Nr,Nr),window.removeEventListener("test",Nr,Nr)}catch{eo=!1}function Ip(e,t,n,r,a,i,o,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(f){this.onError(f)}}var Ur=!1,ca=null,ua=!1,to=null,Ap={onError:function(e){Ur=!0,ca=e}};function _p(e,t,n,r,a,i,o,l,c){Ur=!1,ca=null,Ip.apply(Ap,arguments)}function zp(e,t,n,r,a,i,o,l,c){if(_p.apply(this,arguments),Ur){if(Ur){var d=ca;Ur=!1,ca=null}else throw Error(L(198));ua||(ua=!0,to=d)}}function Un(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function fd(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function lc(e){if(Un(e)!==e)throw Error(L(188))}function $p(e){var t=e.alternate;if(!t){if(t=Un(e),t===null)throw Error(L(188));return t!==e?null:e}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var i=a.alternate;if(i===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===i.child){for(i=a.child;i;){if(i===n)return lc(a),e;if(i===r)return lc(a),t;i=i.sibling}throw Error(L(188))}if(n.return!==r.return)n=a,r=i;else{for(var o=!1,l=a.child;l;){if(l===n){o=!0,n=a,r=i;break}if(l===r){o=!0,r=a,n=i;break}l=l.sibling}if(!o){for(l=i.child;l;){if(l===n){o=!0,n=i,r=a;break}if(l===r){o=!0,r=i,n=a;break}l=l.sibling}if(!o)throw Error(L(189))}}if(n.alternate!==r)throw Error(L(190))}if(n.tag!==3)throw Error(L(188));return n.stateNode.current===n?e:t}function md(e){return e=$p(e),e!==null?pd(e):null}function pd(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=pd(e);if(t!==null)return t;e=e.sibling}return null}var hd=mt.unstable_scheduleCallback,cc=mt.unstable_cancelCallback,Lp=mt.unstable_shouldYield,Mp=mt.unstable_requestPaint,_e=mt.unstable_now,Fp=mt.unstable_getCurrentPriorityLevel,Zo=mt.unstable_ImmediatePriority,gd=mt.unstable_UserBlockingPriority,da=mt.unstable_NormalPriority,Op=mt.unstable_LowPriority,yd=mt.unstable_IdlePriority,Fa=null,Ot=null;function Bp(e){if(Ot&&typeof Ot.onCommitFiberRoot=="function")try{Ot.onCommitFiberRoot(Fa,e,void 0,(e.current.flags&128)===128)}catch{}}var At=Math.clz32?Math.clz32:Wp,Dp=Math.log,Up=Math.LN2;function Wp(e){return e>>>=0,e===0?32:31-(Dp(e)/Up|0)|0}var Ts=64,Rs=4194304;function Fr(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function fa(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,a=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var l=o&~a;l!==0?r=Fr(l):(i&=o,i!==0&&(r=Fr(i)))}else o=n&~a,o!==0?r=Fr(o):i!==0&&(r=Fr(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&a)&&(a=r&-r,i=t&-t,a>=i||a===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-At(t),a=1<<n,r|=e[n],t&=~a;return r}function Hp(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Vp(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-At(i),l=1<<o,c=a[o];c===-1?(!(l&n)||l&r)&&(a[o]=Hp(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function no(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function vd(){var e=Ts;return Ts<<=1,!(Ts&4194240)&&(Ts=64),e}function ci(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function gs(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-At(t),e[t]=n}function Gp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var a=31-At(n),i=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~i}}function el(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-At(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var ye=0;function xd(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var wd,tl,jd,Sd,kd,ro=!1,Ps=[],dn=null,fn=null,mn=null,es=new Map,ts=new Map,on=[],Kp="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 uc(e,t){switch(e){case"focusin":case"focusout":dn=null;break;case"dragenter":case"dragleave":fn=null;break;case"mouseover":case"mouseout":mn=null;break;case"pointerover":case"pointerout":es.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ts.delete(t.pointerId)}}function Cr(e,t,n,r,a,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[a]},t!==null&&(t=vs(t),t!==null&&tl(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function Yp(e,t,n,r,a){switch(t){case"focusin":return dn=Cr(dn,e,t,n,r,a),!0;case"dragenter":return fn=Cr(fn,e,t,n,r,a),!0;case"mouseover":return mn=Cr(mn,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return es.set(i,Cr(es.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,ts.set(i,Cr(ts.get(i)||null,e,t,n,r,a)),!0}return!1}function bd(e){var t=Rn(e.target);if(t!==null){var n=Un(t);if(n!==null){if(t=n.tag,t===13){if(t=fd(n),t!==null){e.blockedOn=t,kd(e.priority,function(){jd(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ys(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=so(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);qi=r,n.target.dispatchEvent(r),qi=null}else return t=vs(n),t!==null&&tl(t),e.blockedOn=n,!1;t.shift()}return!0}function dc(e,t,n){Ys(e)&&n.delete(t)}function Qp(){ro=!1,dn!==null&&Ys(dn)&&(dn=null),fn!==null&&Ys(fn)&&(fn=null),mn!==null&&Ys(mn)&&(mn=null),es.forEach(dc),ts.forEach(dc)}function Er(e,t){e.blockedOn===t&&(e.blockedOn=null,ro||(ro=!0,mt.unstable_scheduleCallback(mt.unstable_NormalPriority,Qp)))}function ns(e){function t(a){return Er(a,e)}if(0<Ps.length){Er(Ps[0],e);for(var n=1;n<Ps.length;n++){var r=Ps[n];r.blockedOn===e&&(r.blockedOn=null)}}for(dn!==null&&Er(dn,e),fn!==null&&Er(fn,e),mn!==null&&Er(mn,e),es.forEach(t),ts.forEach(t),n=0;n<on.length;n++)r=on[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<on.length&&(n=on[0],n.blockedOn===null);)bd(n),n.blockedOn===null&&on.shift()}var or=Zt.ReactCurrentBatchConfig,ma=!0;function Jp(e,t,n,r){var a=ye,i=or.transition;or.transition=null;try{ye=1,nl(e,t,n,r)}finally{ye=a,or.transition=i}}function Xp(e,t,n,r){var a=ye,i=or.transition;or.transition=null;try{ye=4,nl(e,t,n,r)}finally{ye=a,or.transition=i}}function nl(e,t,n,r){if(ma){var a=so(e,t,n,r);if(a===null)xi(e,t,r,pa,n),uc(e,r);else if(Yp(a,e,t,n,r))r.stopPropagation();else if(uc(e,r),t&4&&-1<Kp.indexOf(e)){for(;a!==null;){var i=vs(a);if(i!==null&&wd(i),i=so(e,t,n,r),i===null&&xi(e,t,r,pa,n),i===a)break;a=i}a!==null&&r.stopPropagation()}else xi(e,t,r,null,n)}}var pa=null;function so(e,t,n,r){if(pa=null,e=qo(r),e=Rn(e),e!==null)if(t=Un(e),t===null)e=null;else if(n=t.tag,n===13){if(e=fd(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return pa=e,null}function Nd(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Fp()){case Zo:return 1;case gd:return 4;case da:case Op:return 16;case yd:return 536870912;default:return 16}default:return 16}}var cn=null,rl=null,Qs=null;function Cd(){if(Qs)return Qs;var e,t=rl,n=t.length,r,a="value"in cn?cn.value:cn.textContent,i=a.length;for(e=0;e<n&&t[e]===a[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===a[i-r];r++);return Qs=a.slice(e,1<r?1-r:void 0)}function Js(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Is(){return!0}function fc(){return!1}function ht(e){function t(n,r,a,i,o){this._reactName=n,this._targetInst=a,this.type=r,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Is:fc,this.isPropagationStopped=fc,this}return Ee(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Is)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Is)},persist:function(){},isPersistent:Is}),t}var vr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},sl=ht(vr),ys=Ee({},vr,{view:0,detail:0}),qp=ht(ys),ui,di,Tr,Oa=Ee({},ys,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:al,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Tr&&(Tr&&e.type==="mousemove"?(ui=e.screenX-Tr.screenX,di=e.screenY-Tr.screenY):di=ui=0,Tr=e),ui)},movementY:function(e){return"movementY"in e?e.movementY:di}}),mc=ht(Oa),Zp=Ee({},Oa,{dataTransfer:0}),eh=ht(Zp),th=Ee({},ys,{relatedTarget:0}),fi=ht(th),nh=Ee({},vr,{animationName:0,elapsedTime:0,pseudoElement:0}),rh=ht(nh),sh=Ee({},vr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ah=ht(sh),ih=Ee({},vr,{data:0}),pc=ht(ih),oh={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},lh={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"},ch={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function uh(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=ch[e])?!!t[e]:!1}function al(){return uh}var dh=Ee({},ys,{key:function(e){if(e.key){var t=oh[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Js(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?lh[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:al,charCode:function(e){return e.type==="keypress"?Js(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Js(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),fh=ht(dh),mh=Ee({},Oa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),hc=ht(mh),ph=Ee({},ys,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:al}),hh=ht(ph),gh=Ee({},vr,{propertyName:0,elapsedTime:0,pseudoElement:0}),yh=ht(gh),vh=Ee({},Oa,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),xh=ht(vh),wh=[9,13,27,32],il=Yt&&"CompositionEvent"in window,Wr=null;Yt&&"documentMode"in document&&(Wr=document.documentMode);var jh=Yt&&"TextEvent"in window&&!Wr,Ed=Yt&&(!il||Wr&&8<Wr&&11>=Wr),gc=" ",yc=!1;function Td(e,t){switch(e){case"keyup":return wh.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Rd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Yn=!1;function Sh(e,t){switch(e){case"compositionend":return Rd(t);case"keypress":return t.which!==32?null:(yc=!0,gc);case"textInput":return e=t.data,e===gc&&yc?null:e;default:return null}}function kh(e,t){if(Yn)return e==="compositionend"||!il&&Td(e,t)?(e=Cd(),Qs=rl=cn=null,Yn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Ed&&t.locale!=="ko"?null:t.data;default:return null}}var bh={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 vc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!bh[e.type]:t==="textarea"}function Pd(e,t,n,r){od(r),t=ha(t,"onChange"),0<t.length&&(n=new sl("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Hr=null,rs=null;function Nh(e){Dd(e,0)}function Ba(e){var t=Xn(e);if(ed(t))return e}function Ch(e,t){if(e==="change")return t}var Id=!1;if(Yt){var mi;if(Yt){var pi="oninput"in document;if(!pi){var xc=document.createElement("div");xc.setAttribute("oninput","return;"),pi=typeof xc.oninput=="function"}mi=pi}else mi=!1;Id=mi&&(!document.documentMode||9<document.documentMode)}function wc(){Hr&&(Hr.detachEvent("onpropertychange",Ad),rs=Hr=null)}function Ad(e){if(e.propertyName==="value"&&Ba(rs)){var t=[];Pd(t,rs,e,qo(e)),dd(Nh,t)}}function Eh(e,t,n){e==="focusin"?(wc(),Hr=t,rs=n,Hr.attachEvent("onpropertychange",Ad)):e==="focusout"&&wc()}function Th(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ba(rs)}function Rh(e,t){if(e==="click")return Ba(t)}function Ph(e,t){if(e==="input"||e==="change")return Ba(t)}function Ih(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var zt=typeof Object.is=="function"?Object.is:Ih;function ss(e,t){if(zt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!Bi.call(t,a)||!zt(e[a],t[a]))return!1}return!0}function jc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Sc(e,t){var n=jc(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=jc(n)}}function _d(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?_d(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function zd(){for(var e=window,t=la();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=la(e.document)}return t}function ol(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Ah(e){var t=zd(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&_d(n.ownerDocument.documentElement,n)){if(r!==null&&ol(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=n.textContent.length,i=Math.min(r.start,a);r=r.end===void 0?i:Math.min(r.end,a),!e.extend&&i>r&&(a=r,r=i,i=a),a=Sc(n,i);var o=Sc(n,r);a&&o&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var _h=Yt&&"documentMode"in document&&11>=document.documentMode,Qn=null,ao=null,Vr=null,io=!1;function kc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;io||Qn==null||Qn!==la(r)||(r=Qn,"selectionStart"in r&&ol(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Vr&&ss(Vr,r)||(Vr=r,r=ha(ao,"onSelect"),0<r.length&&(t=new sl("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Qn)))}function As(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Jn={animationend:As("Animation","AnimationEnd"),animationiteration:As("Animation","AnimationIteration"),animationstart:As("Animation","AnimationStart"),transitionend:As("Transition","TransitionEnd")},hi={},$d={};Yt&&($d=document.createElement("div").style,"AnimationEvent"in window||(delete Jn.animationend.animation,delete Jn.animationiteration.animation,delete Jn.animationstart.animation),"TransitionEvent"in window||delete Jn.transitionend.transition);function Da(e){if(hi[e])return hi[e];if(!Jn[e])return e;var t=Jn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in $d)return hi[e]=t[n];return e}var Ld=Da("animationend"),Md=Da("animationiteration"),Fd=Da("animationstart"),Od=Da("transitionend"),Bd=new Map,bc="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function jn(e,t){Bd.set(e,t),Dn(t,[e])}for(var gi=0;gi<bc.length;gi++){var yi=bc[gi],zh=yi.toLowerCase(),$h=yi[0].toUpperCase()+yi.slice(1);jn(zh,"on"+$h)}jn(Ld,"onAnimationEnd");jn(Md,"onAnimationIteration");jn(Fd,"onAnimationStart");jn("dblclick","onDoubleClick");jn("focusin","onFocus");jn("focusout","onBlur");jn(Od,"onTransitionEnd");ur("onMouseEnter",["mouseout","mouseover"]);ur("onMouseLeave",["mouseout","mouseover"]);ur("onPointerEnter",["pointerout","pointerover"]);ur("onPointerLeave",["pointerout","pointerover"]);Dn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Dn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Dn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Dn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Dn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Dn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Or="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(" "),Lh=new Set("cancel close invalid load scroll toggle".split(" ").concat(Or));function Nc(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,zp(r,t,void 0,e),e.currentTarget=null}function Dd(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var o=r.length-1;0<=o;o--){var l=r[o],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==i&&a.isPropagationStopped())break e;Nc(a,l,d),i=c}else for(o=0;o<r.length;o++){if(l=r[o],c=l.instance,d=l.currentTarget,l=l.listener,c!==i&&a.isPropagationStopped())break e;Nc(a,l,d),i=c}}}if(ua)throw e=to,ua=!1,to=null,e}function we(e,t){var n=t[fo];n===void 0&&(n=t[fo]=new Set);var r=e+"__bubble";n.has(r)||(Ud(t,e,2,!1),n.add(r))}function vi(e,t,n){var r=0;t&&(r|=4),Ud(n,e,r,t)}var _s="_reactListening"+Math.random().toString(36).slice(2);function as(e){if(!e[_s]){e[_s]=!0,Qu.forEach(function(n){n!=="selectionchange"&&(Lh.has(n)||vi(n,!1,e),vi(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[_s]||(t[_s]=!0,vi("selectionchange",!1,t))}}function Ud(e,t,n,r){switch(Nd(t)){case 1:var a=Jp;break;case 4:a=Xp;break;default:a=nl}n=a.bind(null,t,n,e),a=void 0,!eo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),r?a!==void 0?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):a!==void 0?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function xi(e,t,n,r,a){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var l=r.stateNode.containerInfo;if(l===a||l.nodeType===8&&l.parentNode===a)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===a||c.nodeType===8&&c.parentNode===a))return;o=o.return}for(;l!==null;){if(o=Rn(l),o===null)return;if(c=o.tag,c===5||c===6){r=i=o;continue e}l=l.parentNode}}r=r.return}dd(function(){var d=i,f=qo(n),m=[];e:{var p=Bd.get(e);if(p!==void 0){var w=sl,x=e;switch(e){case"keypress":if(Js(n)===0)break e;case"keydown":case"keyup":w=fh;break;case"focusin":x="focus",w=fi;break;case"focusout":x="blur",w=fi;break;case"beforeblur":case"afterblur":w=fi;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":w=mc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":w=eh;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":w=hh;break;case Ld:case Md:case Fd:w=rh;break;case Od:w=yh;break;case"scroll":w=qp;break;case"wheel":w=xh;break;case"copy":case"cut":case"paste":w=ah;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":w=hc}var v=(t&4)!==0,S=!v&&e==="scroll",g=v?p!==null?p+"Capture":null:p;v=[];for(var h=d,y;h!==null;){y=h;var j=y.stateNode;if(y.tag===5&&j!==null&&(y=j,g!==null&&(j=Zr(h,g),j!=null&&v.push(is(h,j,y)))),S)break;h=h.return}0<v.length&&(p=new w(p,x,null,n,f),m.push({event:p,listeners:v}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",w=e==="mouseout"||e==="pointerout",p&&n!==qi&&(x=n.relatedTarget||n.fromElement)&&(Rn(x)||x[Qt]))break e;if((w||p)&&(p=f.window===f?f:(p=f.ownerDocument)?p.defaultView||p.parentWindow:window,w?(x=n.relatedTarget||n.toElement,w=d,x=x?Rn(x):null,x!==null&&(S=Un(x),x!==S||x.tag!==5&&x.tag!==6)&&(x=null)):(w=null,x=d),w!==x)){if(v=mc,j="onMouseLeave",g="onMouseEnter",h="mouse",(e==="pointerout"||e==="pointerover")&&(v=hc,j="onPointerLeave",g="onPointerEnter",h="pointer"),S=w==null?p:Xn(w),y=x==null?p:Xn(x),p=new v(j,h+"leave",w,n,f),p.target=S,p.relatedTarget=y,j=null,Rn(f)===d&&(v=new v(g,h+"enter",x,n,f),v.target=y,v.relatedTarget=S,j=v),S=j,w&&x)t:{for(v=w,g=x,h=0,y=v;y;y=Wn(y))h++;for(y=0,j=g;j;j=Wn(j))y++;for(;0<h-y;)v=Wn(v),h--;for(;0<y-h;)g=Wn(g),y--;for(;h--;){if(v===g||g!==null&&v===g.alternate)break t;v=Wn(v),g=Wn(g)}v=null}else v=null;w!==null&&Cc(m,p,w,v,!1),x!==null&&S!==null&&Cc(m,S,x,v,!0)}}e:{if(p=d?Xn(d):window,w=p.nodeName&&p.nodeName.toLowerCase(),w==="select"||w==="input"&&p.type==="file")var b=Ch;else if(vc(p))if(Id)b=Ph;else{b=Th;var E=Eh}else(w=p.nodeName)&&w.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(b=Rh);if(b&&(b=b(e,d))){Pd(m,b,n,f);break e}E&&E(e,p,d),e==="focusout"&&(E=p._wrapperState)&&E.controlled&&p.type==="number"&&Ki(p,"number",p.value)}switch(E=d?Xn(d):window,e){case"focusin":(vc(E)||E.contentEditable==="true")&&(Qn=E,ao=d,Vr=null);break;case"focusout":Vr=ao=Qn=null;break;case"mousedown":io=!0;break;case"contextmenu":case"mouseup":case"dragend":io=!1,kc(m,n,f);break;case"selectionchange":if(_h)break;case"keydown":case"keyup":kc(m,n,f)}var C;if(il)e:{switch(e){case"compositionstart":var P="onCompositionStart";break e;case"compositionend":P="onCompositionEnd";break e;case"compositionupdate":P="onCompositionUpdate";break e}P=void 0}else Yn?Td(e,n)&&(P="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(P="onCompositionStart");P&&(Ed&&n.locale!=="ko"&&(Yn||P!=="onCompositionStart"?P==="onCompositionEnd"&&Yn&&(C=Cd()):(cn=f,rl="value"in cn?cn.value:cn.textContent,Yn=!0)),E=ha(d,P),0<E.length&&(P=new pc(P,e,null,n,f),m.push({event:P,listeners:E}),C?P.data=C:(C=Rd(n),C!==null&&(P.data=C)))),(C=jh?Sh(e,n):kh(e,n))&&(d=ha(d,"onBeforeInput"),0<d.length&&(f=new pc("onBeforeInput","beforeinput",null,n,f),m.push({event:f,listeners:d}),f.data=C))}Dd(m,t)})}function is(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ha(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,i=a.stateNode;a.tag===5&&i!==null&&(a=i,i=Zr(e,n),i!=null&&r.unshift(is(e,i,a)),i=Zr(e,t),i!=null&&r.push(is(e,i,a))),e=e.return}return r}function Wn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Cc(e,t,n,r,a){for(var i=t._reactName,o=[];n!==null&&n!==r;){var l=n,c=l.alternate,d=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&d!==null&&(l=d,a?(c=Zr(n,i),c!=null&&o.unshift(is(n,c,l))):a||(c=Zr(n,i),c!=null&&o.push(is(n,c,l)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Mh=/\r\n?/g,Fh=/\u0000|\uFFFD/g;function Ec(e){return(typeof e=="string"?e:""+e).replace(Mh,`
38
- `).replace(Fh,"")}function zs(e,t,n){if(t=Ec(t),Ec(e)!==t&&n)throw Error(L(425))}function ga(){}var oo=null,lo=null;function co(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var uo=typeof setTimeout=="function"?setTimeout:void 0,Oh=typeof clearTimeout=="function"?clearTimeout:void 0,Tc=typeof Promise=="function"?Promise:void 0,Bh=typeof queueMicrotask=="function"?queueMicrotask:typeof Tc<"u"?function(e){return Tc.resolve(null).then(e).catch(Dh)}:uo;function Dh(e){setTimeout(function(){throw e})}function wi(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&a.nodeType===8)if(n=a.data,n==="/$"){if(r===0){e.removeChild(a),ns(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);ns(t)}function pn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Rc(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var xr=Math.random().toString(36).slice(2),Ft="__reactFiber$"+xr,os="__reactProps$"+xr,Qt="__reactContainer$"+xr,fo="__reactEvents$"+xr,Uh="__reactListeners$"+xr,Wh="__reactHandles$"+xr;function Rn(e){var t=e[Ft];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Qt]||n[Ft]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Rc(e);e!==null;){if(n=e[Ft])return n;e=Rc(e)}return t}e=n,n=e.parentNode}return null}function vs(e){return e=e[Ft]||e[Qt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Xn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(L(33))}function Ua(e){return e[os]||null}var mo=[],qn=-1;function Sn(e){return{current:e}}function Se(e){0>qn||(e.current=mo[qn],mo[qn]=null,qn--)}function xe(e,t){qn++,mo[qn]=e.current,e.current=t}var wn={},Qe=Sn(wn),at=Sn(!1),Ln=wn;function dr(e,t){var n=e.type.contextTypes;if(!n)return wn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a={},i;for(i in n)a[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function it(e){return e=e.childContextTypes,e!=null}function ya(){Se(at),Se(Qe)}function Pc(e,t,n){if(Qe.current!==wn)throw Error(L(168));xe(Qe,t),xe(at,n)}function Wd(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var a in r)if(!(a in t))throw Error(L(108,Ep(e)||"Unknown",a));return Ee({},n,r)}function va(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||wn,Ln=Qe.current,xe(Qe,e),xe(at,at.current),!0}function Ic(e,t,n){var r=e.stateNode;if(!r)throw Error(L(169));n?(e=Wd(e,t,Ln),r.__reactInternalMemoizedMergedChildContext=e,Se(at),Se(Qe),xe(Qe,e)):Se(at),xe(at,n)}var Wt=null,Wa=!1,ji=!1;function Hd(e){Wt===null?Wt=[e]:Wt.push(e)}function Hh(e){Wa=!0,Hd(e)}function kn(){if(!ji&&Wt!==null){ji=!0;var e=0,t=ye;try{var n=Wt;for(ye=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Wt=null,Wa=!1}catch(a){throw Wt!==null&&(Wt=Wt.slice(e+1)),hd(Zo,kn),a}finally{ye=t,ji=!1}}return null}var Zn=[],er=0,xa=null,wa=0,xt=[],wt=0,Mn=null,Vt=1,Gt="";function Cn(e,t){Zn[er++]=wa,Zn[er++]=xa,xa=e,wa=t}function Vd(e,t,n){xt[wt++]=Vt,xt[wt++]=Gt,xt[wt++]=Mn,Mn=e;var r=Vt;e=Gt;var a=32-At(r)-1;r&=~(1<<a),n+=1;var i=32-At(t)+a;if(30<i){var o=a-a%5;i=(r&(1<<o)-1).toString(32),r>>=o,a-=o,Vt=1<<32-At(t)+a|n<<a|r,Gt=i+e}else Vt=1<<i|n<<a|r,Gt=e}function ll(e){e.return!==null&&(Cn(e,1),Vd(e,1,0))}function cl(e){for(;e===xa;)xa=Zn[--er],Zn[er]=null,wa=Zn[--er],Zn[er]=null;for(;e===Mn;)Mn=xt[--wt],xt[wt]=null,Gt=xt[--wt],xt[wt]=null,Vt=xt[--wt],xt[wt]=null}var ft=null,dt=null,ke=!1,Pt=null;function Gd(e,t){var n=jt(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function Ac(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,ft=e,dt=pn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ft=e,dt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Mn!==null?{id:Vt,overflow:Gt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=jt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ft=e,dt=null,!0):!1;default:return!1}}function po(e){return(e.mode&1)!==0&&(e.flags&128)===0}function ho(e){if(ke){var t=dt;if(t){var n=t;if(!Ac(e,t)){if(po(e))throw Error(L(418));t=pn(n.nextSibling);var r=ft;t&&Ac(e,t)?Gd(r,n):(e.flags=e.flags&-4097|2,ke=!1,ft=e)}}else{if(po(e))throw Error(L(418));e.flags=e.flags&-4097|2,ke=!1,ft=e}}}function _c(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ft=e}function $s(e){if(e!==ft)return!1;if(!ke)return _c(e),ke=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!co(e.type,e.memoizedProps)),t&&(t=dt)){if(po(e))throw Kd(),Error(L(418));for(;t;)Gd(e,t),t=pn(t.nextSibling)}if(_c(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(L(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){dt=pn(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}dt=null}}else dt=ft?pn(e.stateNode.nextSibling):null;return!0}function Kd(){for(var e=dt;e;)e=pn(e.nextSibling)}function fr(){dt=ft=null,ke=!1}function ul(e){Pt===null?Pt=[e]:Pt.push(e)}var Vh=Zt.ReactCurrentBatchConfig;function Rr(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(L(309));var r=n.stateNode}if(!r)throw Error(L(147,e));var a=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(o){var l=a.refs;o===null?delete l[i]:l[i]=o},t._stringRef=i,t)}if(typeof e!="string")throw Error(L(284));if(!n._owner)throw Error(L(290,e))}return e}function Ls(e,t){throw e=Object.prototype.toString.call(t),Error(L(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function zc(e){var t=e._init;return t(e._payload)}function Yd(e){function t(g,h){if(e){var y=g.deletions;y===null?(g.deletions=[h],g.flags|=16):y.push(h)}}function n(g,h){if(!e)return null;for(;h!==null;)t(g,h),h=h.sibling;return null}function r(g,h){for(g=new Map;h!==null;)h.key!==null?g.set(h.key,h):g.set(h.index,h),h=h.sibling;return g}function a(g,h){return g=vn(g,h),g.index=0,g.sibling=null,g}function i(g,h,y){return g.index=y,e?(y=g.alternate,y!==null?(y=y.index,y<h?(g.flags|=2,h):y):(g.flags|=2,h)):(g.flags|=1048576,h)}function o(g){return e&&g.alternate===null&&(g.flags|=2),g}function l(g,h,y,j){return h===null||h.tag!==6?(h=Ti(y,g.mode,j),h.return=g,h):(h=a(h,y),h.return=g,h)}function c(g,h,y,j){var b=y.type;return b===Kn?f(g,h,y.props.children,j,y.key):h!==null&&(h.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===sn&&zc(b)===h.type)?(j=a(h,y.props),j.ref=Rr(g,h,y),j.return=g,j):(j=ra(y.type,y.key,y.props,null,g.mode,j),j.ref=Rr(g,h,y),j.return=g,j)}function d(g,h,y,j){return h===null||h.tag!==4||h.stateNode.containerInfo!==y.containerInfo||h.stateNode.implementation!==y.implementation?(h=Ri(y,g.mode,j),h.return=g,h):(h=a(h,y.children||[]),h.return=g,h)}function f(g,h,y,j,b){return h===null||h.tag!==7?(h=$n(y,g.mode,j,b),h.return=g,h):(h=a(h,y),h.return=g,h)}function m(g,h,y){if(typeof h=="string"&&h!==""||typeof h=="number")return h=Ti(""+h,g.mode,y),h.return=g,h;if(typeof h=="object"&&h!==null){switch(h.$$typeof){case Ns:return y=ra(h.type,h.key,h.props,null,g.mode,y),y.ref=Rr(g,null,h),y.return=g,y;case Gn:return h=Ri(h,g.mode,y),h.return=g,h;case sn:var j=h._init;return m(g,j(h._payload),y)}if(Mr(h)||br(h))return h=$n(h,g.mode,y,null),h.return=g,h;Ls(g,h)}return null}function p(g,h,y,j){var b=h!==null?h.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return b!==null?null:l(g,h,""+y,j);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Ns:return y.key===b?c(g,h,y,j):null;case Gn:return y.key===b?d(g,h,y,j):null;case sn:return b=y._init,p(g,h,b(y._payload),j)}if(Mr(y)||br(y))return b!==null?null:f(g,h,y,j,null);Ls(g,y)}return null}function w(g,h,y,j,b){if(typeof j=="string"&&j!==""||typeof j=="number")return g=g.get(y)||null,l(h,g,""+j,b);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Ns:return g=g.get(j.key===null?y:j.key)||null,c(h,g,j,b);case Gn:return g=g.get(j.key===null?y:j.key)||null,d(h,g,j,b);case sn:var E=j._init;return w(g,h,y,E(j._payload),b)}if(Mr(j)||br(j))return g=g.get(y)||null,f(h,g,j,b,null);Ls(h,j)}return null}function x(g,h,y,j){for(var b=null,E=null,C=h,P=h=0,N=null;C!==null&&P<y.length;P++){C.index>P?(N=C,C=null):N=C.sibling;var _=p(g,C,y[P],j);if(_===null){C===null&&(C=N);break}e&&C&&_.alternate===null&&t(g,C),h=i(_,h,P),E===null?b=_:E.sibling=_,E=_,C=N}if(P===y.length)return n(g,C),ke&&Cn(g,P),b;if(C===null){for(;P<y.length;P++)C=m(g,y[P],j),C!==null&&(h=i(C,h,P),E===null?b=C:E.sibling=C,E=C);return ke&&Cn(g,P),b}for(C=r(g,C);P<y.length;P++)N=w(C,g,P,y[P],j),N!==null&&(e&&N.alternate!==null&&C.delete(N.key===null?P:N.key),h=i(N,h,P),E===null?b=N:E.sibling=N,E=N);return e&&C.forEach(function(M){return t(g,M)}),ke&&Cn(g,P),b}function v(g,h,y,j){var b=br(y);if(typeof b!="function")throw Error(L(150));if(y=b.call(y),y==null)throw Error(L(151));for(var E=b=null,C=h,P=h=0,N=null,_=y.next();C!==null&&!_.done;P++,_=y.next()){C.index>P?(N=C,C=null):N=C.sibling;var M=p(g,C,_.value,j);if(M===null){C===null&&(C=N);break}e&&C&&M.alternate===null&&t(g,C),h=i(M,h,P),E===null?b=M:E.sibling=M,E=M,C=N}if(_.done)return n(g,C),ke&&Cn(g,P),b;if(C===null){for(;!_.done;P++,_=y.next())_=m(g,_.value,j),_!==null&&(h=i(_,h,P),E===null?b=_:E.sibling=_,E=_);return ke&&Cn(g,P),b}for(C=r(g,C);!_.done;P++,_=y.next())_=w(C,g,P,_.value,j),_!==null&&(e&&_.alternate!==null&&C.delete(_.key===null?P:_.key),h=i(_,h,P),E===null?b=_:E.sibling=_,E=_);return e&&C.forEach(function(V){return t(g,V)}),ke&&Cn(g,P),b}function S(g,h,y,j){if(typeof y=="object"&&y!==null&&y.type===Kn&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Ns:e:{for(var b=y.key,E=h;E!==null;){if(E.key===b){if(b=y.type,b===Kn){if(E.tag===7){n(g,E.sibling),h=a(E,y.props.children),h.return=g,g=h;break e}}else if(E.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===sn&&zc(b)===E.type){n(g,E.sibling),h=a(E,y.props),h.ref=Rr(g,E,y),h.return=g,g=h;break e}n(g,E);break}else t(g,E);E=E.sibling}y.type===Kn?(h=$n(y.props.children,g.mode,j,y.key),h.return=g,g=h):(j=ra(y.type,y.key,y.props,null,g.mode,j),j.ref=Rr(g,h,y),j.return=g,g=j)}return o(g);case Gn:e:{for(E=y.key;h!==null;){if(h.key===E)if(h.tag===4&&h.stateNode.containerInfo===y.containerInfo&&h.stateNode.implementation===y.implementation){n(g,h.sibling),h=a(h,y.children||[]),h.return=g,g=h;break e}else{n(g,h);break}else t(g,h);h=h.sibling}h=Ri(y,g.mode,j),h.return=g,g=h}return o(g);case sn:return E=y._init,S(g,h,E(y._payload),j)}if(Mr(y))return x(g,h,y,j);if(br(y))return v(g,h,y,j);Ls(g,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,h!==null&&h.tag===6?(n(g,h.sibling),h=a(h,y),h.return=g,g=h):(n(g,h),h=Ti(y,g.mode,j),h.return=g,g=h),o(g)):n(g,h)}return S}var mr=Yd(!0),Qd=Yd(!1),ja=Sn(null),Sa=null,tr=null,dl=null;function fl(){dl=tr=Sa=null}function ml(e){var t=ja.current;Se(ja),e._currentValue=t}function go(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function lr(e,t){Sa=e,dl=tr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(st=!0),e.firstContext=null)}function kt(e){var t=e._currentValue;if(dl!==e)if(e={context:e,memoizedValue:t,next:null},tr===null){if(Sa===null)throw Error(L(308));tr=e,Sa.dependencies={lanes:0,firstContext:e}}else tr=tr.next=e;return t}var Pn=null;function pl(e){Pn===null?Pn=[e]:Pn.push(e)}function Jd(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,pl(t)):(n.next=a.next,a.next=n),t.interleaved=n,Jt(e,r)}function Jt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var an=!1;function hl(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xd(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Kt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function hn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,pe&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,Jt(e,n)}return a=r.interleaved,a===null?(t.next=t,pl(r)):(t.next=a.next,a.next=t),r.interleaved=t,Jt(e,n)}function Xs(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,el(e,n)}}function $c(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var a=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?a=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?a=i=t:i=i.next=t}else a=i=t;n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ka(e,t,n,r){var a=e.updateQueue;an=!1;var i=a.firstBaseUpdate,o=a.lastBaseUpdate,l=a.shared.pending;if(l!==null){a.shared.pending=null;var c=l,d=c.next;c.next=null,o===null?i=d:o.next=d,o=c;var f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==o&&(l===null?f.firstBaseUpdate=d:l.next=d,f.lastBaseUpdate=c))}if(i!==null){var m=a.baseState;o=0,f=d=c=null,l=i;do{var p=l.lane,w=l.eventTime;if((r&p)===p){f!==null&&(f=f.next={eventTime:w,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var x=e,v=l;switch(p=t,w=n,v.tag){case 1:if(x=v.payload,typeof x=="function"){m=x.call(w,m,p);break e}m=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=v.payload,p=typeof x=="function"?x.call(w,m,p):x,p==null)break e;m=Ee({},m,p);break e;case 2:an=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=a.effects,p===null?a.effects=[l]:p.push(l))}else w={eventTime:w,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(d=f=w,c=m):f=f.next=w,o|=p;if(l=l.next,l===null){if(l=a.shared.pending,l===null)break;p=l,l=p.next,p.next=null,a.lastBaseUpdate=p,a.shared.pending=null}}while(!0);if(f===null&&(c=m),a.baseState=c,a.firstBaseUpdate=d,a.lastBaseUpdate=f,t=a.shared.interleaved,t!==null){a=t;do o|=a.lane,a=a.next;while(a!==t)}else i===null&&(a.shared.lanes=0);On|=o,e.lanes=o,e.memoizedState=m}}function Lc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],a=r.callback;if(a!==null){if(r.callback=null,r=n,typeof a!="function")throw Error(L(191,a));a.call(r)}}}var xs={},Bt=Sn(xs),ls=Sn(xs),cs=Sn(xs);function In(e){if(e===xs)throw Error(L(174));return e}function gl(e,t){switch(xe(cs,t),xe(ls,e),xe(Bt,xs),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Qi(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Qi(t,e)}Se(Bt),xe(Bt,t)}function pr(){Se(Bt),Se(ls),Se(cs)}function qd(e){In(cs.current);var t=In(Bt.current),n=Qi(t,e.type);t!==n&&(xe(ls,e),xe(Bt,n))}function yl(e){ls.current===e&&(Se(Bt),Se(ls))}var Ne=Sn(0);function ba(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Si=[];function vl(){for(var e=0;e<Si.length;e++)Si[e]._workInProgressVersionPrimary=null;Si.length=0}var qs=Zt.ReactCurrentDispatcher,ki=Zt.ReactCurrentBatchConfig,Fn=0,Ce=null,Le=null,Fe=null,Na=!1,Gr=!1,us=0,Gh=0;function Ge(){throw Error(L(321))}function xl(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!zt(e[n],t[n]))return!1;return!0}function wl(e,t,n,r,a,i){if(Fn=i,Ce=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,qs.current=e===null||e.memoizedState===null?Jh:Xh,e=n(r,a),Gr){i=0;do{if(Gr=!1,us=0,25<=i)throw Error(L(301));i+=1,Fe=Le=null,t.updateQueue=null,qs.current=qh,e=n(r,a)}while(Gr)}if(qs.current=Ca,t=Le!==null&&Le.next!==null,Fn=0,Fe=Le=Ce=null,Na=!1,t)throw Error(L(300));return e}function jl(){var e=us!==0;return us=0,e}function Mt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Fe===null?Ce.memoizedState=Fe=e:Fe=Fe.next=e,Fe}function bt(){if(Le===null){var e=Ce.alternate;e=e!==null?e.memoizedState:null}else e=Le.next;var t=Fe===null?Ce.memoizedState:Fe.next;if(t!==null)Fe=t,Le=e;else{if(e===null)throw Error(L(310));Le=e,e={memoizedState:Le.memoizedState,baseState:Le.baseState,baseQueue:Le.baseQueue,queue:Le.queue,next:null},Fe===null?Ce.memoizedState=Fe=e:Fe=Fe.next=e}return Fe}function ds(e,t){return typeof t=="function"?t(e):t}function bi(e){var t=bt(),n=t.queue;if(n===null)throw Error(L(311));n.lastRenderedReducer=e;var r=Le,a=r.baseQueue,i=n.pending;if(i!==null){if(a!==null){var o=a.next;a.next=i.next,i.next=o}r.baseQueue=a=i,n.pending=null}if(a!==null){i=a.next,r=r.baseState;var l=o=null,c=null,d=i;do{var f=d.lane;if((Fn&f)===f)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var m={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=m,o=r):c=c.next=m,Ce.lanes|=f,On|=f}d=d.next}while(d!==null&&d!==i);c===null?o=r:c.next=l,zt(r,t.memoizedState)||(st=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){a=e;do i=a.lane,Ce.lanes|=i,On|=i,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Ni(e){var t=bt(),n=t.queue;if(n===null)throw Error(L(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,i=t.memoizedState;if(a!==null){n.pending=null;var o=a=a.next;do i=e(i,o.action),o=o.next;while(o!==a);zt(i,t.memoizedState)||(st=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function Zd(){}function ef(e,t){var n=Ce,r=bt(),a=t(),i=!zt(r.memoizedState,a);if(i&&(r.memoizedState=a,st=!0),r=r.queue,Sl(rf.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Fe!==null&&Fe.memoizedState.tag&1){if(n.flags|=2048,fs(9,nf.bind(null,n,r,a,t),void 0,null),Oe===null)throw Error(L(349));Fn&30||tf(n,t,a)}return a}function tf(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ce.updateQueue,t===null?(t={lastEffect:null,stores:null},Ce.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function nf(e,t,n,r){t.value=n,t.getSnapshot=r,sf(t)&&af(e)}function rf(e,t,n){return n(function(){sf(t)&&af(e)})}function sf(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!zt(e,n)}catch{return!0}}function af(e){var t=Jt(e,1);t!==null&&_t(t,e,1,-1)}function Mc(e){var t=Mt();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ds,lastRenderedState:e},t.queue=e,e=e.dispatch=Qh.bind(null,Ce,e),[t.memoizedState,e]}function fs(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Ce.updateQueue,t===null?(t={lastEffect:null,stores:null},Ce.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function of(){return bt().memoizedState}function Zs(e,t,n,r){var a=Mt();Ce.flags|=e,a.memoizedState=fs(1|t,n,void 0,r===void 0?null:r)}function Ha(e,t,n,r){var a=bt();r=r===void 0?null:r;var i=void 0;if(Le!==null){var o=Le.memoizedState;if(i=o.destroy,r!==null&&xl(r,o.deps)){a.memoizedState=fs(t,n,i,r);return}}Ce.flags|=e,a.memoizedState=fs(1|t,n,i,r)}function Fc(e,t){return Zs(8390656,8,e,t)}function Sl(e,t){return Ha(2048,8,e,t)}function lf(e,t){return Ha(4,2,e,t)}function cf(e,t){return Ha(4,4,e,t)}function uf(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function df(e,t,n){return n=n!=null?n.concat([e]):null,Ha(4,4,uf.bind(null,t,e),n)}function kl(){}function ff(e,t){var n=bt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&xl(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function mf(e,t){var n=bt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&xl(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function pf(e,t,n){return Fn&21?(zt(n,t)||(n=vd(),Ce.lanes|=n,On|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,st=!0),e.memoizedState=n)}function Kh(e,t){var n=ye;ye=n!==0&&4>n?n:4,e(!0);var r=ki.transition;ki.transition={};try{e(!1),t()}finally{ye=n,ki.transition=r}}function hf(){return bt().memoizedState}function Yh(e,t,n){var r=yn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},gf(e))yf(t,n);else if(n=Jd(e,t,n,r),n!==null){var a=Ze();_t(n,e,r,a),vf(n,t,r)}}function Qh(e,t,n){var r=yn(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(gf(e))yf(t,a);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,l=i(o,n);if(a.hasEagerState=!0,a.eagerState=l,zt(l,o)){var c=t.interleaved;c===null?(a.next=a,pl(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=Jd(e,t,a,r),n!==null&&(a=Ze(),_t(n,e,r,a),vf(n,t,r))}}function gf(e){var t=e.alternate;return e===Ce||t!==null&&t===Ce}function yf(e,t){Gr=Na=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function vf(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,el(e,n)}}var Ca={readContext:kt,useCallback:Ge,useContext:Ge,useEffect:Ge,useImperativeHandle:Ge,useInsertionEffect:Ge,useLayoutEffect:Ge,useMemo:Ge,useReducer:Ge,useRef:Ge,useState:Ge,useDebugValue:Ge,useDeferredValue:Ge,useTransition:Ge,useMutableSource:Ge,useSyncExternalStore:Ge,useId:Ge,unstable_isNewReconciler:!1},Jh={readContext:kt,useCallback:function(e,t){return Mt().memoizedState=[e,t===void 0?null:t],e},useContext:kt,useEffect:Fc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Zs(4194308,4,uf.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Zs(4194308,4,e,t)},useInsertionEffect:function(e,t){return Zs(4,2,e,t)},useMemo:function(e,t){var n=Mt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Mt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Yh.bind(null,Ce,e),[r.memoizedState,e]},useRef:function(e){var t=Mt();return e={current:e},t.memoizedState=e},useState:Mc,useDebugValue:kl,useDeferredValue:function(e){return Mt().memoizedState=e},useTransition:function(){var e=Mc(!1),t=e[0];return e=Kh.bind(null,e[1]),Mt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ce,a=Mt();if(ke){if(n===void 0)throw Error(L(407));n=n()}else{if(n=t(),Oe===null)throw Error(L(349));Fn&30||tf(r,t,n)}a.memoizedState=n;var i={value:n,getSnapshot:t};return a.queue=i,Fc(rf.bind(null,r,i,e),[e]),r.flags|=2048,fs(9,nf.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Mt(),t=Oe.identifierPrefix;if(ke){var n=Gt,r=Vt;n=(r&~(1<<32-At(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=us++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Gh++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Xh={readContext:kt,useCallback:ff,useContext:kt,useEffect:Sl,useImperativeHandle:df,useInsertionEffect:lf,useLayoutEffect:cf,useMemo:mf,useReducer:bi,useRef:of,useState:function(){return bi(ds)},useDebugValue:kl,useDeferredValue:function(e){var t=bt();return pf(t,Le.memoizedState,e)},useTransition:function(){var e=bi(ds)[0],t=bt().memoizedState;return[e,t]},useMutableSource:Zd,useSyncExternalStore:ef,useId:hf,unstable_isNewReconciler:!1},qh={readContext:kt,useCallback:ff,useContext:kt,useEffect:Sl,useImperativeHandle:df,useInsertionEffect:lf,useLayoutEffect:cf,useMemo:mf,useReducer:Ni,useRef:of,useState:function(){return Ni(ds)},useDebugValue:kl,useDeferredValue:function(e){var t=bt();return Le===null?t.memoizedState=e:pf(t,Le.memoizedState,e)},useTransition:function(){var e=Ni(ds)[0],t=bt().memoizedState;return[e,t]},useMutableSource:Zd,useSyncExternalStore:ef,useId:hf,unstable_isNewReconciler:!1};function Tt(e,t){if(e&&e.defaultProps){t=Ee({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function yo(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ee({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Va={isMounted:function(e){return(e=e._reactInternals)?Un(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ze(),a=yn(e),i=Kt(r,a);i.payload=t,n!=null&&(i.callback=n),t=hn(e,i,a),t!==null&&(_t(t,e,a,r),Xs(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ze(),a=yn(e),i=Kt(r,a);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=hn(e,i,a),t!==null&&(_t(t,e,a,r),Xs(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ze(),r=yn(e),a=Kt(n,r);a.tag=2,t!=null&&(a.callback=t),t=hn(e,a,r),t!==null&&(_t(t,e,r,n),Xs(t,e,r))}};function Oc(e,t,n,r,a,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,o):t.prototype&&t.prototype.isPureReactComponent?!ss(n,r)||!ss(a,i):!0}function xf(e,t,n){var r=!1,a=wn,i=t.contextType;return typeof i=="object"&&i!==null?i=kt(i):(a=it(t)?Ln:Qe.current,r=t.contextTypes,i=(r=r!=null)?dr(e,a):wn),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Va,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=i),t}function Bc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Va.enqueueReplaceState(t,t.state,null)}function vo(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},hl(e);var i=t.contextType;typeof i=="object"&&i!==null?a.context=kt(i):(i=it(t)?Ln:Qe.current,a.context=dr(e,i)),a.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(yo(e,t,i,n),a.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(t=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),t!==a.state&&Va.enqueueReplaceState(a,a.state,null),ka(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function hr(e,t){try{var n="",r=t;do n+=Cp(r),r=r.return;while(r);var a=n}catch(i){a=`
39
- Error generating stack: `+i.message+`
40
- `+i.stack}return{value:e,source:t,stack:a,digest:null}}function Ci(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function xo(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Zh=typeof WeakMap=="function"?WeakMap:Map;function wf(e,t,n){n=Kt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Ta||(Ta=!0,Ro=r),xo(e,t)},n}function jf(e,t,n){n=Kt(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var a=t.value;n.payload=function(){return r(a)},n.callback=function(){xo(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){xo(e,t),typeof r!="function"&&(gn===null?gn=new Set([this]):gn.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function Dc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Zh;var a=new Set;r.set(t,a)}else a=r.get(t),a===void 0&&(a=new Set,r.set(t,a));a.has(n)||(a.add(n),e=mg.bind(null,e,t,n),t.then(e,e))}function Uc(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Wc(e,t,n,r,a){return e.mode&1?(e.flags|=65536,e.lanes=a,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Kt(-1,1),t.tag=2,hn(n,t,1))),n.lanes|=1),e)}var eg=Zt.ReactCurrentOwner,st=!1;function Xe(e,t,n,r){t.child=e===null?Qd(t,null,n,r):mr(t,e.child,n,r)}function Hc(e,t,n,r,a){n=n.render;var i=t.ref;return lr(t,a),r=wl(e,t,n,r,i,a),n=jl(),e!==null&&!st?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Xt(e,t,a)):(ke&&n&&ll(t),t.flags|=1,Xe(e,t,r,a),t.child)}function Vc(e,t,n,r,a){if(e===null){var i=n.type;return typeof i=="function"&&!Il(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,Sf(e,t,i,r,a)):(e=ra(n.type,null,r,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&a)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:ss,n(o,r)&&e.ref===t.ref)return Xt(e,t,a)}return t.flags|=1,e=vn(i,r),e.ref=t.ref,e.return=t,t.child=e}function Sf(e,t,n,r,a){if(e!==null){var i=e.memoizedProps;if(ss(i,r)&&e.ref===t.ref)if(st=!1,t.pendingProps=r=i,(e.lanes&a)!==0)e.flags&131072&&(st=!0);else return t.lanes=e.lanes,Xt(e,t,a)}return wo(e,t,n,r,a)}function kf(e,t,n){var r=t.pendingProps,a=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},xe(rr,ut),ut|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,xe(rr,ut),ut|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,xe(rr,ut),ut|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,xe(rr,ut),ut|=r;return Xe(e,t,a,n),t.child}function bf(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function wo(e,t,n,r,a){var i=it(n)?Ln:Qe.current;return i=dr(t,i),lr(t,a),n=wl(e,t,n,r,i,a),r=jl(),e!==null&&!st?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Xt(e,t,a)):(ke&&r&&ll(t),t.flags|=1,Xe(e,t,n,a),t.child)}function Gc(e,t,n,r,a){if(it(n)){var i=!0;va(t)}else i=!1;if(lr(t,a),t.stateNode===null)ea(e,t),xf(t,n,r),vo(t,n,r,a),r=!0;else if(e===null){var o=t.stateNode,l=t.memoizedProps;o.props=l;var c=o.context,d=n.contextType;typeof d=="object"&&d!==null?d=kt(d):(d=it(n)?Ln:Qe.current,d=dr(t,d));var f=n.getDerivedStateFromProps,m=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function";m||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==r||c!==d)&&Bc(t,o,r,d),an=!1;var p=t.memoizedState;o.state=p,ka(t,r,o,a),c=t.memoizedState,l!==r||p!==c||at.current||an?(typeof f=="function"&&(yo(t,n,f,r),c=t.memoizedState),(l=an||Oc(t,n,l,r,p,c,d))?(m||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=d,r=l):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,Xd(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Tt(t.type,l),o.props=d,m=t.pendingProps,p=o.context,c=n.contextType,typeof c=="object"&&c!==null?c=kt(c):(c=it(n)?Ln:Qe.current,c=dr(t,c));var w=n.getDerivedStateFromProps;(f=typeof w=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==m||p!==c)&&Bc(t,o,r,c),an=!1,p=t.memoizedState,o.state=p,ka(t,r,o,a);var x=t.memoizedState;l!==m||p!==x||at.current||an?(typeof w=="function"&&(yo(t,n,w,r),x=t.memoizedState),(d=an||Oc(t,n,d,r,p,x,c)||!1)?(f||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,x,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,x,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=x),o.props=r,o.state=x,o.context=c,r=d):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return jo(e,t,n,r,i,a)}function jo(e,t,n,r,a,i){bf(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return a&&Ic(t,n,!1),Xt(e,t,i);r=t.stateNode,eg.current=t;var l=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=mr(t,e.child,null,i),t.child=mr(t,null,l,i)):Xe(e,t,l,i),t.memoizedState=r.state,a&&Ic(t,n,!0),t.child}function Nf(e){var t=e.stateNode;t.pendingContext?Pc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Pc(e,t.context,!1),gl(e,t.containerInfo)}function Kc(e,t,n,r,a){return fr(),ul(a),t.flags|=256,Xe(e,t,n,r),t.child}var So={dehydrated:null,treeContext:null,retryLane:0};function ko(e){return{baseLanes:e,cachePool:null,transitions:null}}function Cf(e,t,n){var r=t.pendingProps,a=Ne.current,i=!1,o=(t.flags&128)!==0,l;if((l=o)||(l=e!==null&&e.memoizedState===null?!1:(a&2)!==0),l?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),xe(Ne,a&1),e===null)return ho(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,i?(r=t.mode,i=t.child,o={mode:"hidden",children:o},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Ya(o,r,0,null),e=$n(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=ko(n),t.memoizedState=So,e):bl(t,o));if(a=e.memoizedState,a!==null&&(l=a.dehydrated,l!==null))return tg(e,t,o,r,l,a,n);if(i){i=r.fallback,o=t.mode,a=e.child,l=a.sibling;var c={mode:"hidden",children:r.children};return!(o&1)&&t.child!==a?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=vn(a,c),r.subtreeFlags=a.subtreeFlags&14680064),l!==null?i=vn(l,i):(i=$n(i,o,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,o=e.child.memoizedState,o=o===null?ko(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=So,r}return i=e.child,e=i.sibling,r=vn(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function bl(e,t){return t=Ya({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ms(e,t,n,r){return r!==null&&ul(r),mr(t,e.child,null,n),e=bl(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function tg(e,t,n,r,a,i,o){if(n)return t.flags&256?(t.flags&=-257,r=Ci(Error(L(422))),Ms(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,a=t.mode,r=Ya({mode:"visible",children:r.children},a,0,null),i=$n(i,a,o,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&mr(t,e.child,null,o),t.child.memoizedState=ko(o),t.memoizedState=So,i);if(!(t.mode&1))return Ms(e,t,o,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(L(419)),r=Ci(i,r,void 0),Ms(e,t,o,r)}if(l=(o&e.childLanes)!==0,st||l){if(r=Oe,r!==null){switch(o&-o){case 4:a=2;break;case 16:a=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:a=32;break;case 536870912:a=268435456;break;default:a=0}a=a&(r.suspendedLanes|o)?0:a,a!==0&&a!==i.retryLane&&(i.retryLane=a,Jt(e,a),_t(r,e,a,-1))}return Pl(),r=Ci(Error(L(421))),Ms(e,t,o,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=pg.bind(null,e),a._reactRetry=t,null):(e=i.treeContext,dt=pn(a.nextSibling),ft=t,ke=!0,Pt=null,e!==null&&(xt[wt++]=Vt,xt[wt++]=Gt,xt[wt++]=Mn,Vt=e.id,Gt=e.overflow,Mn=t),t=bl(t,r.children),t.flags|=4096,t)}function Yc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),go(e.return,t,n)}function Ei(e,t,n,r,a){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=a)}function Ef(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;if(Xe(e,t,r.children,n),r=Ne.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Yc(e,n,t);else if(e.tag===19)Yc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(xe(Ne,r),!(t.mode&1))t.memoizedState=null;else switch(a){case"forwards":for(n=t.child,a=null;n!==null;)e=n.alternate,e!==null&&ba(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Ei(t,!1,a,n,i);break;case"backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&ba(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Ei(t,!0,n,null,i);break;case"together":Ei(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function ea(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Xt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),On|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(L(153));if(t.child!==null){for(e=t.child,n=vn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=vn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function ng(e,t,n){switch(t.tag){case 3:Nf(t),fr();break;case 5:qd(t);break;case 1:it(t.type)&&va(t);break;case 4:gl(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;xe(ja,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(xe(Ne,Ne.current&1),t.flags|=128,null):n&t.child.childLanes?Cf(e,t,n):(xe(Ne,Ne.current&1),e=Xt(e,t,n),e!==null?e.sibling:null);xe(Ne,Ne.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Ef(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),xe(Ne,Ne.current),r)break;return null;case 22:case 23:return t.lanes=0,kf(e,t,n)}return Xt(e,t,n)}var Tf,bo,Rf,Pf;Tf=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};bo=function(){};Rf=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,In(Bt.current);var i=null;switch(n){case"input":a=Vi(e,a),r=Vi(e,r),i=[];break;case"select":a=Ee({},a,{value:void 0}),r=Ee({},r,{value:void 0}),i=[];break;case"textarea":a=Yi(e,a),r=Yi(e,r),i=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=ga)}Ji(n,r);var o;n=null;for(d in a)if(!r.hasOwnProperty(d)&&a.hasOwnProperty(d)&&a[d]!=null)if(d==="style"){var l=a[d];for(o in l)l.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Xr.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in r){var c=r[d];if(l=a!=null?a[d]:void 0,r.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="style")if(l){for(o in l)!l.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in c)c.hasOwnProperty(o)&&l[o]!==c[o]&&(n||(n={}),n[o]=c[o])}else n||(i||(i=[]),i.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Xr.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&we("scroll",e),i||l===c||(i=[])):(i=i||[]).push(d,c))}n&&(i=i||[]).push("style",n);var d=i;(t.updateQueue=d)&&(t.flags|=4)}};Pf=function(e,t,n,r){n!==r&&(t.flags|=4)};function Pr(e,t){if(!ke)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ke(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags&14680064,r|=a.flags&14680064,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function rg(e,t,n){var r=t.pendingProps;switch(cl(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ke(t),null;case 1:return it(t.type)&&ya(),Ke(t),null;case 3:return r=t.stateNode,pr(),Se(at),Se(Qe),vl(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&($s(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Pt!==null&&(Ao(Pt),Pt=null))),bo(e,t),Ke(t),null;case 5:yl(t);var a=In(cs.current);if(n=t.type,e!==null&&t.stateNode!=null)Rf(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(L(166));return Ke(t),null}if(e=In(Bt.current),$s(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Ft]=t,r[os]=i,e=(t.mode&1)!==0,n){case"dialog":we("cancel",r),we("close",r);break;case"iframe":case"object":case"embed":we("load",r);break;case"video":case"audio":for(a=0;a<Or.length;a++)we(Or[a],r);break;case"source":we("error",r);break;case"img":case"image":case"link":we("error",r),we("load",r);break;case"details":we("toggle",r);break;case"input":rc(r,i),we("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},we("invalid",r);break;case"textarea":ac(r,i),we("invalid",r)}Ji(n,i),a=null;for(var o in i)if(i.hasOwnProperty(o)){var l=i[o];o==="children"?typeof l=="string"?r.textContent!==l&&(i.suppressHydrationWarning!==!0&&zs(r.textContent,l,e),a=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&zs(r.textContent,l,e),a=["children",""+l]):Xr.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&we("scroll",r)}switch(n){case"input":Cs(r),sc(r,i,!0);break;case"textarea":Cs(r),ic(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=ga)}r=a,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=rd(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Ft]=t,e[os]=r,Tf(e,t,!1,!1),t.stateNode=e;e:{switch(o=Xi(n,r),n){case"dialog":we("cancel",e),we("close",e),a=r;break;case"iframe":case"object":case"embed":we("load",e),a=r;break;case"video":case"audio":for(a=0;a<Or.length;a++)we(Or[a],e);a=r;break;case"source":we("error",e),a=r;break;case"img":case"image":case"link":we("error",e),we("load",e),a=r;break;case"details":we("toggle",e),a=r;break;case"input":rc(e,r),a=Vi(e,r),we("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=Ee({},r,{value:void 0}),we("invalid",e);break;case"textarea":ac(e,r),a=Yi(e,r),we("invalid",e);break;default:a=r}Ji(n,a),l=a;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?id(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&sd(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&qr(e,c):typeof c=="number"&&qr(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Xr.hasOwnProperty(i)?c!=null&&i==="onScroll"&&we("scroll",e):c!=null&&Yo(e,i,c,o))}switch(n){case"input":Cs(e),sc(e,r,!1);break;case"textarea":Cs(e),ic(e);break;case"option":r.value!=null&&e.setAttribute("value",""+xn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?sr(e,!!r.multiple,i,!1):r.defaultValue!=null&&sr(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=ga)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Ke(t),null;case 6:if(e&&t.stateNode!=null)Pf(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(L(166));if(n=In(cs.current),In(Bt.current),$s(t)){if(r=t.stateNode,n=t.memoizedProps,r[Ft]=t,(i=r.nodeValue!==n)&&(e=ft,e!==null))switch(e.tag){case 3:zs(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&zs(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Ft]=t,t.stateNode=r}return Ke(t),null;case 13:if(Se(Ne),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ke&&dt!==null&&t.mode&1&&!(t.flags&128))Kd(),fr(),t.flags|=98560,i=!1;else if(i=$s(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(L(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(L(317));i[Ft]=t}else fr(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ke(t),i=!1}else Pt!==null&&(Ao(Pt),Pt=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Ne.current&1?Me===0&&(Me=3):Pl())),t.updateQueue!==null&&(t.flags|=4),Ke(t),null);case 4:return pr(),bo(e,t),e===null&&as(t.stateNode.containerInfo),Ke(t),null;case 10:return ml(t.type._context),Ke(t),null;case 17:return it(t.type)&&ya(),Ke(t),null;case 19:if(Se(Ne),i=t.memoizedState,i===null)return Ke(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)Pr(i,!1);else{if(Me!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=ba(e),o!==null){for(t.flags|=128,Pr(i,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return xe(Ne,Ne.current&1|2),t.child}e=e.sibling}i.tail!==null&&_e()>gr&&(t.flags|=128,r=!0,Pr(i,!1),t.lanes=4194304)}else{if(!r)if(e=ba(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Pr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!ke)return Ke(t),null}else 2*_e()-i.renderingStartTime>gr&&n!==1073741824&&(t.flags|=128,r=!0,Pr(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=_e(),t.sibling=null,n=Ne.current,xe(Ne,r?n&1|2:n&1),t):(Ke(t),null);case 22:case 23:return Rl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ut&1073741824&&(Ke(t),t.subtreeFlags&6&&(t.flags|=8192)):Ke(t),null;case 24:return null;case 25:return null}throw Error(L(156,t.tag))}function sg(e,t){switch(cl(t),t.tag){case 1:return it(t.type)&&ya(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return pr(),Se(at),Se(Qe),vl(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return yl(t),null;case 13:if(Se(Ne),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(L(340));fr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Se(Ne),null;case 4:return pr(),null;case 10:return ml(t.type._context),null;case 22:case 23:return Rl(),null;case 24:return null;default:return null}}var Fs=!1,Ye=!1,ag=typeof WeakSet=="function"?WeakSet:Set,Q=null;function nr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Re(e,t,r)}else n.current=null}function No(e,t,n){try{n()}catch(r){Re(e,t,r)}}var Qc=!1;function ig(e,t){if(oo=ma,e=zd(),ol(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,l=-1,c=-1,d=0,f=0,m=e,p=null;t:for(;;){for(var w;m!==n||a!==0&&m.nodeType!==3||(l=o+a),m!==i||r!==0&&m.nodeType!==3||(c=o+r),m.nodeType===3&&(o+=m.nodeValue.length),(w=m.firstChild)!==null;)p=m,m=w;for(;;){if(m===e)break t;if(p===n&&++d===a&&(l=o),p===i&&++f===r&&(c=o),(w=m.nextSibling)!==null)break;m=p,p=m.parentNode}m=w}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(lo={focusedElem:e,selectionRange:n},ma=!1,Q=t;Q!==null;)if(t=Q,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var v=x.memoizedProps,S=x.memoizedState,g=t.stateNode,h=g.getSnapshotBeforeUpdate(t.elementType===t.type?v:Tt(t.type,v),S);g.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(L(163))}}catch(j){Re(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return x=Qc,Qc=!1,x}function Kr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&e)===e){var i=a.destroy;a.destroy=void 0,i!==void 0&&No(t,n,i)}a=a.next}while(a!==r)}}function Ga(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Co(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function If(e){var t=e.alternate;t!==null&&(e.alternate=null,If(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ft],delete t[os],delete t[fo],delete t[Uh],delete t[Wh])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Af(e){return e.tag===5||e.tag===3||e.tag===4}function Jc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Af(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Eo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ga));else if(r!==4&&(e=e.child,e!==null))for(Eo(e,t,n),e=e.sibling;e!==null;)Eo(e,t,n),e=e.sibling}function To(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(To(e,t,n),e=e.sibling;e!==null;)To(e,t,n),e=e.sibling}var Ue=null,Rt=!1;function rn(e,t,n){for(n=n.child;n!==null;)_f(e,t,n),n=n.sibling}function _f(e,t,n){if(Ot&&typeof Ot.onCommitFiberUnmount=="function")try{Ot.onCommitFiberUnmount(Fa,n)}catch{}switch(n.tag){case 5:Ye||nr(n,t);case 6:var r=Ue,a=Rt;Ue=null,rn(e,t,n),Ue=r,Rt=a,Ue!==null&&(Rt?(e=Ue,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ue.removeChild(n.stateNode));break;case 18:Ue!==null&&(Rt?(e=Ue,n=n.stateNode,e.nodeType===8?wi(e.parentNode,n):e.nodeType===1&&wi(e,n),ns(e)):wi(Ue,n.stateNode));break;case 4:r=Ue,a=Rt,Ue=n.stateNode.containerInfo,Rt=!0,rn(e,t,n),Ue=r,Rt=a;break;case 0:case 11:case 14:case 15:if(!Ye&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){a=r=r.next;do{var i=a,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&No(n,t,o),a=a.next}while(a!==r)}rn(e,t,n);break;case 1:if(!Ye&&(nr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Re(n,t,l)}rn(e,t,n);break;case 21:rn(e,t,n);break;case 22:n.mode&1?(Ye=(r=Ye)||n.memoizedState!==null,rn(e,t,n),Ye=r):rn(e,t,n);break;default:rn(e,t,n)}}function Xc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new ag),t.forEach(function(r){var a=hg.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function Et(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r];try{var i=e,o=t,l=o;e:for(;l!==null;){switch(l.tag){case 5:Ue=l.stateNode,Rt=!1;break e;case 3:Ue=l.stateNode.containerInfo,Rt=!0;break e;case 4:Ue=l.stateNode.containerInfo,Rt=!0;break e}l=l.return}if(Ue===null)throw Error(L(160));_f(i,o,a),Ue=null,Rt=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(d){Re(a,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)zf(t,e),t=t.sibling}function zf(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Et(t,e),Lt(e),r&4){try{Kr(3,e,e.return),Ga(3,e)}catch(v){Re(e,e.return,v)}try{Kr(5,e,e.return)}catch(v){Re(e,e.return,v)}}break;case 1:Et(t,e),Lt(e),r&512&&n!==null&&nr(n,n.return);break;case 5:if(Et(t,e),Lt(e),r&512&&n!==null&&nr(n,n.return),e.flags&32){var a=e.stateNode;try{qr(a,"")}catch(v){Re(e,e.return,v)}}if(r&4&&(a=e.stateNode,a!=null)){var i=e.memoizedProps,o=n!==null?n.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&td(a,i),Xi(l,o);var d=Xi(l,i);for(o=0;o<c.length;o+=2){var f=c[o],m=c[o+1];f==="style"?id(a,m):f==="dangerouslySetInnerHTML"?sd(a,m):f==="children"?qr(a,m):Yo(a,f,m,d)}switch(l){case"input":Gi(a,i);break;case"textarea":nd(a,i);break;case"select":var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!i.multiple;var w=i.value;w!=null?sr(a,!!i.multiple,w,!1):p!==!!i.multiple&&(i.defaultValue!=null?sr(a,!!i.multiple,i.defaultValue,!0):sr(a,!!i.multiple,i.multiple?[]:"",!1))}a[os]=i}catch(v){Re(e,e.return,v)}}break;case 6:if(Et(t,e),Lt(e),r&4){if(e.stateNode===null)throw Error(L(162));a=e.stateNode,i=e.memoizedProps;try{a.nodeValue=i}catch(v){Re(e,e.return,v)}}break;case 3:if(Et(t,e),Lt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{ns(t.containerInfo)}catch(v){Re(e,e.return,v)}break;case 4:Et(t,e),Lt(e);break;case 13:Et(t,e),Lt(e),a=e.child,a.flags&8192&&(i=a.memoizedState!==null,a.stateNode.isHidden=i,!i||a.alternate!==null&&a.alternate.memoizedState!==null||(El=_e())),r&4&&Xc(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Ye=(d=Ye)||f,Et(t,e),Ye=d):Et(t,e),Lt(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(Q=e,f=e.child;f!==null;){for(m=Q=f;Q!==null;){switch(p=Q,w=p.child,p.tag){case 0:case 11:case 14:case 15:Kr(4,p,p.return);break;case 1:nr(p,p.return);var x=p.stateNode;if(typeof x.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,x.props=t.memoizedProps,x.state=t.memoizedState,x.componentWillUnmount()}catch(v){Re(r,n,v)}}break;case 5:nr(p,p.return);break;case 22:if(p.memoizedState!==null){Zc(m);continue}}w!==null?(w.return=p,Q=w):Zc(m)}f=f.sibling}e:for(f=null,m=e;;){if(m.tag===5){if(f===null){f=m;try{a=m.stateNode,d?(i=a.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=m.stateNode,c=m.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=ad("display",o))}catch(v){Re(e,e.return,v)}}}else if(m.tag===6){if(f===null)try{m.stateNode.nodeValue=d?"":m.memoizedProps}catch(v){Re(e,e.return,v)}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===e)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===e)break e;for(;m.sibling===null;){if(m.return===null||m.return===e)break e;f===m&&(f=null),m=m.return}f===m&&(f=null),m.sibling.return=m.return,m=m.sibling}}break;case 19:Et(t,e),Lt(e),r&4&&Xc(e);break;case 21:break;default:Et(t,e),Lt(e)}}function Lt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Af(n)){var r=n;break e}n=n.return}throw Error(L(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(qr(a,""),r.flags&=-33);var i=Jc(e);To(e,i,a);break;case 3:case 4:var o=r.stateNode.containerInfo,l=Jc(e);Eo(e,l,o);break;default:throw Error(L(161))}}catch(c){Re(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function og(e,t,n){Q=e,$f(e)}function $f(e,t,n){for(var r=(e.mode&1)!==0;Q!==null;){var a=Q,i=a.child;if(a.tag===22&&r){var o=a.memoizedState!==null||Fs;if(!o){var l=a.alternate,c=l!==null&&l.memoizedState!==null||Ye;l=Fs;var d=Ye;if(Fs=o,(Ye=c)&&!d)for(Q=a;Q!==null;)o=Q,c=o.child,o.tag===22&&o.memoizedState!==null?eu(a):c!==null?(c.return=o,Q=c):eu(a);for(;i!==null;)Q=i,$f(i),i=i.sibling;Q=a,Fs=l,Ye=d}qc(e)}else a.subtreeFlags&8772&&i!==null?(i.return=a,Q=i):qc(e)}}function qc(e){for(;Q!==null;){var t=Q;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ye||Ga(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Ye)if(n===null)r.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:Tt(t.type,n.memoizedProps);r.componentDidUpdate(a,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Lc(t,i,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Lc(t,o,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var f=d.memoizedState;if(f!==null){var m=f.dehydrated;m!==null&&ns(m)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(L(163))}Ye||t.flags&512&&Co(t)}catch(p){Re(t,t.return,p)}}if(t===e){Q=null;break}if(n=t.sibling,n!==null){n.return=t.return,Q=n;break}Q=t.return}}function Zc(e){for(;Q!==null;){var t=Q;if(t===e){Q=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Q=n;break}Q=t.return}}function eu(e){for(;Q!==null;){var t=Q;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Ga(4,t)}catch(c){Re(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(c){Re(t,a,c)}}var i=t.return;try{Co(t)}catch(c){Re(t,i,c)}break;case 5:var o=t.return;try{Co(t)}catch(c){Re(t,o,c)}}}catch(c){Re(t,t.return,c)}if(t===e){Q=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Q=l;break}Q=t.return}}var lg=Math.ceil,Ea=Zt.ReactCurrentDispatcher,Nl=Zt.ReactCurrentOwner,St=Zt.ReactCurrentBatchConfig,pe=0,Oe=null,$e=null,We=0,ut=0,rr=Sn(0),Me=0,ms=null,On=0,Ka=0,Cl=0,Yr=null,rt=null,El=0,gr=1/0,Ut=null,Ta=!1,Ro=null,gn=null,Os=!1,un=null,Ra=0,Qr=0,Po=null,ta=-1,na=0;function Ze(){return pe&6?_e():ta!==-1?ta:ta=_e()}function yn(e){return e.mode&1?pe&2&&We!==0?We&-We:Vh.transition!==null?(na===0&&(na=vd()),na):(e=ye,e!==0||(e=window.event,e=e===void 0?16:Nd(e.type)),e):1}function _t(e,t,n,r){if(50<Qr)throw Qr=0,Po=null,Error(L(185));gs(e,n,r),(!(pe&2)||e!==Oe)&&(e===Oe&&(!(pe&2)&&(Ka|=n),Me===4&&ln(e,We)),ot(e,r),n===1&&pe===0&&!(t.mode&1)&&(gr=_e()+500,Wa&&kn()))}function ot(e,t){var n=e.callbackNode;Vp(e,t);var r=fa(e,e===Oe?We:0);if(r===0)n!==null&&cc(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&cc(n),t===1)e.tag===0?Hh(tu.bind(null,e)):Hd(tu.bind(null,e)),Bh(function(){!(pe&6)&&kn()}),n=null;else{switch(xd(r)){case 1:n=Zo;break;case 4:n=gd;break;case 16:n=da;break;case 536870912:n=yd;break;default:n=da}n=Wf(n,Lf.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Lf(e,t){if(ta=-1,na=0,pe&6)throw Error(L(327));var n=e.callbackNode;if(cr()&&e.callbackNode!==n)return null;var r=fa(e,e===Oe?We:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Pa(e,r);else{t=r;var a=pe;pe|=2;var i=Ff();(Oe!==e||We!==t)&&(Ut=null,gr=_e()+500,zn(e,t));do try{dg();break}catch(l){Mf(e,l)}while(!0);fl(),Ea.current=i,pe=a,$e!==null?t=0:(Oe=null,We=0,t=Me)}if(t!==0){if(t===2&&(a=no(e),a!==0&&(r=a,t=Io(e,a))),t===1)throw n=ms,zn(e,0),ln(e,r),ot(e,_e()),n;if(t===6)ln(e,r);else{if(a=e.current.alternate,!(r&30)&&!cg(a)&&(t=Pa(e,r),t===2&&(i=no(e),i!==0&&(r=i,t=Io(e,i))),t===1))throw n=ms,zn(e,0),ln(e,r),ot(e,_e()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(L(345));case 2:En(e,rt,Ut);break;case 3:if(ln(e,r),(r&130023424)===r&&(t=El+500-_e(),10<t)){if(fa(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){Ze(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=uo(En.bind(null,e,rt,Ut),t);break}En(e,rt,Ut);break;case 4:if(ln(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var o=31-At(r);i=1<<o,o=t[o],o>a&&(a=o),r&=~i}if(r=a,r=_e()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*lg(r/1960))-r,10<r){e.timeoutHandle=uo(En.bind(null,e,rt,Ut),r);break}En(e,rt,Ut);break;case 5:En(e,rt,Ut);break;default:throw Error(L(329))}}}return ot(e,_e()),e.callbackNode===n?Lf.bind(null,e):null}function Io(e,t){var n=Yr;return e.current.memoizedState.isDehydrated&&(zn(e,t).flags|=256),e=Pa(e,t),e!==2&&(t=rt,rt=n,t!==null&&Ao(t)),e}function Ao(e){rt===null?rt=e:rt.push.apply(rt,e)}function cg(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var a=n[r],i=a.getSnapshot;a=a.value;try{if(!zt(i(),a))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ln(e,t){for(t&=~Cl,t&=~Ka,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-At(t),r=1<<n;e[n]=-1,t&=~r}}function tu(e){if(pe&6)throw Error(L(327));cr();var t=fa(e,0);if(!(t&1))return ot(e,_e()),null;var n=Pa(e,t);if(e.tag!==0&&n===2){var r=no(e);r!==0&&(t=r,n=Io(e,r))}if(n===1)throw n=ms,zn(e,0),ln(e,t),ot(e,_e()),n;if(n===6)throw Error(L(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,En(e,rt,Ut),ot(e,_e()),null}function Tl(e,t){var n=pe;pe|=1;try{return e(t)}finally{pe=n,pe===0&&(gr=_e()+500,Wa&&kn())}}function Bn(e){un!==null&&un.tag===0&&!(pe&6)&&cr();var t=pe;pe|=1;var n=St.transition,r=ye;try{if(St.transition=null,ye=1,e)return e()}finally{ye=r,St.transition=n,pe=t,!(pe&6)&&kn()}}function Rl(){ut=rr.current,Se(rr)}function zn(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Oh(n)),$e!==null)for(n=$e.return;n!==null;){var r=n;switch(cl(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&ya();break;case 3:pr(),Se(at),Se(Qe),vl();break;case 5:yl(r);break;case 4:pr();break;case 13:Se(Ne);break;case 19:Se(Ne);break;case 10:ml(r.type._context);break;case 22:case 23:Rl()}n=n.return}if(Oe=e,$e=e=vn(e.current,null),We=ut=t,Me=0,ms=null,Cl=Ka=On=0,rt=Yr=null,Pn!==null){for(t=0;t<Pn.length;t++)if(n=Pn[t],r=n.interleaved,r!==null){n.interleaved=null;var a=r.next,i=n.pending;if(i!==null){var o=i.next;i.next=a,r.next=o}n.pending=r}Pn=null}return e}function Mf(e,t){do{var n=$e;try{if(fl(),qs.current=Ca,Na){for(var r=Ce.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}Na=!1}if(Fn=0,Fe=Le=Ce=null,Gr=!1,us=0,Nl.current=null,n===null||n.return===null){Me=1,ms=t,$e=null;break}e:{var i=e,o=n.return,l=n,c=t;if(t=We,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,f=l,m=f.tag;if(!(f.mode&1)&&(m===0||m===11||m===15)){var p=f.alternate;p?(f.updateQueue=p.updateQueue,f.memoizedState=p.memoizedState,f.lanes=p.lanes):(f.updateQueue=null,f.memoizedState=null)}var w=Uc(o);if(w!==null){w.flags&=-257,Wc(w,o,l,i,t),w.mode&1&&Dc(i,d,t),t=w,c=d;var x=t.updateQueue;if(x===null){var v=new Set;v.add(c),t.updateQueue=v}else x.add(c);break e}else{if(!(t&1)){Dc(i,d,t),Pl();break e}c=Error(L(426))}}else if(ke&&l.mode&1){var S=Uc(o);if(S!==null){!(S.flags&65536)&&(S.flags|=256),Wc(S,o,l,i,t),ul(hr(c,l));break e}}i=c=hr(c,l),Me!==4&&(Me=2),Yr===null?Yr=[i]:Yr.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var g=wf(i,c,t);$c(i,g);break e;case 1:l=c;var h=i.type,y=i.stateNode;if(!(i.flags&128)&&(typeof h.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(gn===null||!gn.has(y)))){i.flags|=65536,t&=-t,i.lanes|=t;var j=jf(i,l,t);$c(i,j);break e}}i=i.return}while(i!==null)}Bf(n)}catch(b){t=b,$e===n&&n!==null&&($e=n=n.return);continue}break}while(!0)}function Ff(){var e=Ea.current;return Ea.current=Ca,e===null?Ca:e}function Pl(){(Me===0||Me===3||Me===2)&&(Me=4),Oe===null||!(On&268435455)&&!(Ka&268435455)||ln(Oe,We)}function Pa(e,t){var n=pe;pe|=2;var r=Ff();(Oe!==e||We!==t)&&(Ut=null,zn(e,t));do try{ug();break}catch(a){Mf(e,a)}while(!0);if(fl(),pe=n,Ea.current=r,$e!==null)throw Error(L(261));return Oe=null,We=0,Me}function ug(){for(;$e!==null;)Of($e)}function dg(){for(;$e!==null&&!Lp();)Of($e)}function Of(e){var t=Uf(e.alternate,e,ut);e.memoizedProps=e.pendingProps,t===null?Bf(e):$e=t,Nl.current=null}function Bf(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=sg(n,t),n!==null){n.flags&=32767,$e=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Me=6,$e=null;return}}else if(n=rg(n,t,ut),n!==null){$e=n;return}if(t=t.sibling,t!==null){$e=t;return}$e=t=e}while(t!==null);Me===0&&(Me=5)}function En(e,t,n){var r=ye,a=St.transition;try{St.transition=null,ye=1,fg(e,t,n,r)}finally{St.transition=a,ye=r}return null}function fg(e,t,n,r){do cr();while(un!==null);if(pe&6)throw Error(L(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(L(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(Gp(e,i),e===Oe&&($e=Oe=null,We=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Os||(Os=!0,Wf(da,function(){return cr(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=St.transition,St.transition=null;var o=ye;ye=1;var l=pe;pe|=4,Nl.current=null,ig(e,n),zf(n,e),Ah(lo),ma=!!oo,lo=oo=null,e.current=n,og(n),Mp(),pe=l,ye=o,St.transition=i}else e.current=n;if(Os&&(Os=!1,un=e,Ra=a),i=e.pendingLanes,i===0&&(gn=null),Bp(n.stateNode),ot(e,_e()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],r(a.value,{componentStack:a.stack,digest:a.digest});if(Ta)throw Ta=!1,e=Ro,Ro=null,e;return Ra&1&&e.tag!==0&&cr(),i=e.pendingLanes,i&1?e===Po?Qr++:(Qr=0,Po=e):Qr=0,kn(),null}function cr(){if(un!==null){var e=xd(Ra),t=St.transition,n=ye;try{if(St.transition=null,ye=16>e?16:e,un===null)var r=!1;else{if(e=un,un=null,Ra=0,pe&6)throw Error(L(331));var a=pe;for(pe|=4,Q=e.current;Q!==null;){var i=Q,o=i.child;if(Q.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Q=d;Q!==null;){var f=Q;switch(f.tag){case 0:case 11:case 15:Kr(8,f,i)}var m=f.child;if(m!==null)m.return=f,Q=m;else for(;Q!==null;){f=Q;var p=f.sibling,w=f.return;if(If(f),f===d){Q=null;break}if(p!==null){p.return=w,Q=p;break}Q=w}}}var x=i.alternate;if(x!==null){var v=x.child;if(v!==null){x.child=null;do{var S=v.sibling;v.sibling=null,v=S}while(v!==null)}}Q=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,Q=o;else e:for(;Q!==null;){if(i=Q,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Kr(9,i,i.return)}var g=i.sibling;if(g!==null){g.return=i.return,Q=g;break e}Q=i.return}}var h=e.current;for(Q=h;Q!==null;){o=Q;var y=o.child;if(o.subtreeFlags&2064&&y!==null)y.return=o,Q=y;else e:for(o=h;Q!==null;){if(l=Q,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Ga(9,l)}}catch(b){Re(l,l.return,b)}if(l===o){Q=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,Q=j;break e}Q=l.return}}if(pe=a,kn(),Ot&&typeof Ot.onPostCommitFiberRoot=="function")try{Ot.onPostCommitFiberRoot(Fa,e)}catch{}r=!0}return r}finally{ye=n,St.transition=t}}return!1}function nu(e,t,n){t=hr(n,t),t=wf(e,t,1),e=hn(e,t,1),t=Ze(),e!==null&&(gs(e,1,t),ot(e,t))}function Re(e,t,n){if(e.tag===3)nu(e,e,n);else for(;t!==null;){if(t.tag===3){nu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(gn===null||!gn.has(r))){e=hr(n,e),e=jf(t,e,1),t=hn(t,e,1),e=Ze(),t!==null&&(gs(t,1,e),ot(t,e));break}}t=t.return}}function mg(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Ze(),e.pingedLanes|=e.suspendedLanes&n,Oe===e&&(We&n)===n&&(Me===4||Me===3&&(We&130023424)===We&&500>_e()-El?zn(e,0):Cl|=n),ot(e,t)}function Df(e,t){t===0&&(e.mode&1?(t=Rs,Rs<<=1,!(Rs&130023424)&&(Rs=4194304)):t=1);var n=Ze();e=Jt(e,t),e!==null&&(gs(e,t,n),ot(e,n))}function pg(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Df(e,n)}function hg(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(L(314))}r!==null&&r.delete(t),Df(e,n)}var Uf;Uf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||at.current)st=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return st=!1,ng(e,t,n);st=!!(e.flags&131072)}else st=!1,ke&&t.flags&1048576&&Vd(t,wa,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;ea(e,t),e=t.pendingProps;var a=dr(t,Qe.current);lr(t,n),a=wl(null,t,r,e,a,n);var i=jl();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,it(r)?(i=!0,va(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,hl(t),a.updater=Va,t.stateNode=a,a._reactInternals=t,vo(t,r,e,n),t=jo(null,t,r,!0,i,n)):(t.tag=0,ke&&i&&ll(t),Xe(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(ea(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=yg(r),e=Tt(r,e),a){case 0:t=wo(null,t,r,e,n);break e;case 1:t=Gc(null,t,r,e,n);break e;case 11:t=Hc(null,t,r,e,n);break e;case 14:t=Vc(null,t,r,Tt(r.type,e),n);break e}throw Error(L(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Tt(r,a),wo(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Tt(r,a),Gc(e,t,r,a,n);case 3:e:{if(Nf(t),e===null)throw Error(L(387));r=t.pendingProps,i=t.memoizedState,a=i.element,Xd(e,t),ka(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){a=hr(Error(L(423)),t),t=Kc(e,t,r,n,a);break e}else if(r!==a){a=hr(Error(L(424)),t),t=Kc(e,t,r,n,a);break e}else for(dt=pn(t.stateNode.containerInfo.firstChild),ft=t,ke=!0,Pt=null,n=Qd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(fr(),r===a){t=Xt(e,t,n);break e}Xe(e,t,r,n)}t=t.child}return t;case 5:return qd(t),e===null&&ho(t),r=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,o=a.children,co(r,a)?o=null:i!==null&&co(r,i)&&(t.flags|=32),bf(e,t),Xe(e,t,o,n),t.child;case 6:return e===null&&ho(t),null;case 13:return Cf(e,t,n);case 4:return gl(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=mr(t,null,r,n):Xe(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Tt(r,a),Hc(e,t,r,a,n);case 7:return Xe(e,t,t.pendingProps,n),t.child;case 8:return Xe(e,t,t.pendingProps.children,n),t.child;case 12:return Xe(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,i=t.memoizedProps,o=a.value,xe(ja,r._currentValue),r._currentValue=o,i!==null)if(zt(i.value,o)){if(i.children===a.children&&!at.current){t=Xt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){o=i.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Kt(-1,n&-n),c.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var f=d.pending;f===null?c.next=c:(c.next=f.next,f.next=c),d.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),go(i.return,n,t),l.lanes|=n;break}c=c.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(L(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),go(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Xe(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,lr(t,n),a=kt(a),r=r(a),t.flags|=1,Xe(e,t,r,n),t.child;case 14:return r=t.type,a=Tt(r,t.pendingProps),a=Tt(r.type,a),Vc(e,t,r,a,n);case 15:return Sf(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Tt(r,a),ea(e,t),t.tag=1,it(r)?(e=!0,va(t)):e=!1,lr(t,n),xf(t,r,a),vo(t,r,a,n),jo(null,t,r,!0,e,n);case 19:return Ef(e,t,n);case 22:return kf(e,t,n)}throw Error(L(156,t.tag))};function Wf(e,t){return hd(e,t)}function gg(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function jt(e,t,n,r){return new gg(e,t,n,r)}function Il(e){return e=e.prototype,!(!e||!e.isReactComponent)}function yg(e){if(typeof e=="function")return Il(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Jo)return 11;if(e===Xo)return 14}return 2}function vn(e,t){var n=e.alternate;return n===null?(n=jt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function ra(e,t,n,r,a,i){var o=2;if(r=e,typeof e=="function")Il(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Kn:return $n(n.children,a,i,t);case Qo:o=8,a|=8;break;case Di:return e=jt(12,n,t,a|2),e.elementType=Di,e.lanes=i,e;case Ui:return e=jt(13,n,t,a),e.elementType=Ui,e.lanes=i,e;case Wi:return e=jt(19,n,t,a),e.elementType=Wi,e.lanes=i,e;case qu:return Ya(n,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ju:o=10;break e;case Xu:o=9;break e;case Jo:o=11;break e;case Xo:o=14;break e;case sn:o=16,r=null;break e}throw Error(L(130,e==null?e:typeof e,""))}return t=jt(o,n,t,a),t.elementType=e,t.type=r,t.lanes=i,t}function $n(e,t,n,r){return e=jt(7,e,r,t),e.lanes=n,e}function Ya(e,t,n,r){return e=jt(22,e,r,t),e.elementType=qu,e.lanes=n,e.stateNode={isHidden:!1},e}function Ti(e,t,n){return e=jt(6,e,null,t),e.lanes=n,e}function Ri(e,t,n){return t=jt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function vg(e,t,n,r,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ci(0),this.expirationTimes=ci(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ci(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Al(e,t,n,r,a,i,o,l,c){return e=new vg(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=jt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},hl(i),e}function xg(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Gn,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function Hf(e){if(!e)return wn;e=e._reactInternals;e:{if(Un(e)!==e||e.tag!==1)throw Error(L(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(it(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(L(171))}if(e.tag===1){var n=e.type;if(it(n))return Wd(e,n,t)}return t}function Vf(e,t,n,r,a,i,o,l,c){return e=Al(n,r,!0,e,a,i,o,l,c),e.context=Hf(null),n=e.current,r=Ze(),a=yn(n),i=Kt(r,a),i.callback=t??null,hn(n,i,a),e.current.lanes=a,gs(e,a,r),ot(e,r),e}function Qa(e,t,n,r){var a=t.current,i=Ze(),o=yn(a);return n=Hf(n),t.context===null?t.context=n:t.pendingContext=n,t=Kt(i,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=hn(a,t,o),e!==null&&(_t(e,a,o,i),Xs(e,a,o)),o}function Ia(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function ru(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function _l(e,t){ru(e,t),(e=e.alternate)&&ru(e,t)}function wg(){return null}var Gf=typeof reportError=="function"?reportError:function(e){console.error(e)};function zl(e){this._internalRoot=e}Ja.prototype.render=zl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(L(409));Qa(e,t,null,null)};Ja.prototype.unmount=zl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Bn(function(){Qa(null,e,null,null)}),t[Qt]=null}};function Ja(e){this._internalRoot=e}Ja.prototype.unstable_scheduleHydration=function(e){if(e){var t=Sd();e={blockedOn:null,target:e,priority:t};for(var n=0;n<on.length&&t!==0&&t<on[n].priority;n++);on.splice(n,0,e),n===0&&bd(e)}};function $l(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Xa(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function su(){}function jg(e,t,n,r,a){if(a){if(typeof r=="function"){var i=r;r=function(){var d=Ia(o);i.call(d)}}var o=Vf(t,r,e,0,null,!1,!1,"",su);return e._reactRootContainer=o,e[Qt]=o.current,as(e.nodeType===8?e.parentNode:e),Bn(),o}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var l=r;r=function(){var d=Ia(c);l.call(d)}}var c=Al(e,0,!1,null,null,!1,!1,"",su);return e._reactRootContainer=c,e[Qt]=c.current,as(e.nodeType===8?e.parentNode:e),Bn(function(){Qa(t,c,n,r)}),c}function qa(e,t,n,r,a){var i=n._reactRootContainer;if(i){var o=i;if(typeof a=="function"){var l=a;a=function(){var c=Ia(o);l.call(c)}}Qa(t,o,e,a)}else o=jg(n,t,e,a,r);return Ia(o)}wd=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Fr(t.pendingLanes);n!==0&&(el(t,n|1),ot(t,_e()),!(pe&6)&&(gr=_e()+500,kn()))}break;case 13:Bn(function(){var r=Jt(e,1);if(r!==null){var a=Ze();_t(r,e,1,a)}}),_l(e,1)}};tl=function(e){if(e.tag===13){var t=Jt(e,134217728);if(t!==null){var n=Ze();_t(t,e,134217728,n)}_l(e,134217728)}};jd=function(e){if(e.tag===13){var t=yn(e),n=Jt(e,t);if(n!==null){var r=Ze();_t(n,e,t,r)}_l(e,t)}};Sd=function(){return ye};kd=function(e,t){var n=ye;try{return ye=e,t()}finally{ye=n}};Zi=function(e,t,n){switch(t){case"input":if(Gi(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=Ua(r);if(!a)throw Error(L(90));ed(r),Gi(r,a)}}}break;case"textarea":nd(e,n);break;case"select":t=n.value,t!=null&&sr(e,!!n.multiple,t,!1)}};cd=Tl;ud=Bn;var Sg={usingClientEntryPoint:!1,Events:[vs,Xn,Ua,od,ld,Tl]},Ir={findFiberByHostInstance:Rn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},kg={bundleType:Ir.bundleType,version:Ir.version,rendererPackageName:Ir.rendererPackageName,rendererConfig:Ir.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Zt.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=md(e),e===null?null:e.stateNode},findFiberByHostInstance:Ir.findFiberByHostInstance||wg,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 Bs=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Bs.isDisabled&&Bs.supportsFiber)try{Fa=Bs.inject(kg),Ot=Bs}catch{}}pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Sg;pt.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!$l(t))throw Error(L(200));return xg(e,t,null,n)};pt.createRoot=function(e,t){if(!$l(e))throw Error(L(299));var n=!1,r="",a=Gf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=Al(e,1,!1,null,null,n,!1,r,a),e[Qt]=t.current,as(e.nodeType===8?e.parentNode:e),new zl(t)};pt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(L(188)):(e=Object.keys(e).join(","),Error(L(268,e)));return e=md(t),e=e===null?null:e.stateNode,e};pt.flushSync=function(e){return Bn(e)};pt.hydrate=function(e,t,n){if(!Xa(t))throw Error(L(200));return qa(null,e,t,!0,n)};pt.hydrateRoot=function(e,t,n){if(!$l(e))throw Error(L(405));var r=n!=null&&n.hydratedSources||null,a=!1,i="",o=Gf;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=Vf(t,null,e,1,n??null,a,!1,i,o),e[Qt]=t.current,as(e),r)for(e=0;e<r.length;e++)n=r[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new Ja(t)};pt.render=function(e,t,n){if(!Xa(t))throw Error(L(200));return qa(null,e,t,!1,n)};pt.unmountComponentAtNode=function(e){if(!Xa(e))throw Error(L(40));return e._reactRootContainer?(Bn(function(){qa(null,null,e,!1,function(){e._reactRootContainer=null,e[Qt]=null})}),!0):!1};pt.unstable_batchedUpdates=Tl;pt.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Xa(n))throw Error(L(200));if(e==null||e._reactInternals===void 0)throw Error(L(38));return qa(e,t,n,!1,r)};pt.version="18.3.1-next-f1338f8080-20240426";function Kf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Kf)}catch(e){console.error(e)}}Kf(),Gu.exports=pt;var Yf=Gu.exports,Qf,au=Yf;Qf=au.createRoot,au.hydrateRoot;/**
41
- * react-router v7.13.1
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 iu="popstate";function ou(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function bg(e={}){function t(r,a){var d;let i=(d=a.state)==null?void 0:d.masked,{pathname:o,search:l,hash:c}=i||r.location;return _o("",{pathname:o,search:l,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default",i?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,a){return typeof a=="string"?a:ps(a)}return Cg(t,n,null,e)}function be(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Nt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Ng(){return Math.random().toString(36).substring(2,10)}function lu(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function _o(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?wr(t):t,state:n,key:t&&t.key||r||Ng(),unstable_mask:a}}function ps({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function wr(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Cg(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:i=!1}=r,o=a.history,l="POP",c=null,d=f();d==null&&(d=0,o.replaceState({...o.state,idx:d},""));function f(){return(o.state||{idx:null}).idx}function m(){l="POP";let S=f(),g=S==null?null:S-d;d=S,c&&c({action:l,location:v.location,delta:g})}function p(S,g){l="PUSH";let h=ou(S)?S:_o(v.location,S,g);d=f()+1;let y=lu(h,d),j=v.createHref(h.unstable_mask||h);try{o.pushState(y,"",j)}catch(b){if(b instanceof DOMException&&b.name==="DataCloneError")throw b;a.location.assign(j)}i&&c&&c({action:l,location:v.location,delta:1})}function w(S,g){l="REPLACE";let h=ou(S)?S:_o(v.location,S,g);d=f();let y=lu(h,d),j=v.createHref(h.unstable_mask||h);o.replaceState(y,"",j),i&&c&&c({action:l,location:v.location,delta:0})}function x(S){return Eg(S)}let v={get action(){return l},get location(){return e(a,o)},listen(S){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(iu,m),c=S,()=>{a.removeEventListener(iu,m),c=null}},createHref(S){return t(a,S)},createURL:x,encodeLocation(S){let g=x(S);return{pathname:g.pathname,search:g.search,hash:g.hash}},push:p,replace:w,go(S){return o.go(S)}};return v}function Eg(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),be(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:ps(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Jf(e,t,n="/"){return Tg(e,t,n,!1)}function Tg(e,t,n,r){let a=typeof t=="string"?wr(t):t,i=qt(a.pathname||"/",n);if(i==null)return null;let o=Xf(e);Rg(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let d=Bg(i);l=Fg(o[c],d,r)}return l}function Xf(e,t=[],n=[],r="",a=!1){let i=(o,l,c=a,d)=>{let f={relativePath:d===void 0?o.path||"":d,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&c)return;be(f.relativePath.startsWith(r),`Absolute route path "${f.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(r.length)}let m=Dt([r,f.relativePath]),p=n.concat(f);o.children&&o.children.length>0&&(be(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),Xf(o.children,t,p,m,c)),!(o.path==null&&!o.index)&&t.push({path:m,score:Lg(m,o.index),routesMeta:p})};return e.forEach((o,l)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))i(o,l);else for(let d of qf(o.path))i(o,l,!0,d)}),t}function qf(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let o=qf(r.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),a&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function Rg(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Mg(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Pg=/^:[\w-]+$/,Ig=3,Ag=2,_g=1,zg=10,$g=-2,cu=e=>e==="*";function Lg(e,t){let n=e.split("/"),r=n.length;return n.some(cu)&&(r+=$g),t&&(r+=Ag),n.filter(a=>!cu(a)).reduce((a,i)=>a+(Pg.test(i)?Ig:i===""?_g:zg),r)}function Mg(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function Fg(e,t,n=!1){let{routesMeta:r}=e,a={},i="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,f=i==="/"?t:t.slice(i.length)||"/",m=Aa({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),p=c.route;if(!m&&d&&n&&!r[r.length-1].route.index&&(m=Aa({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!m)return null;Object.assign(a,m.params),o.push({params:a,pathname:Dt([i,m.pathname]),pathnameBase:Hg(Dt([i,m.pathnameBase])),route:p}),m.pathnameBase!=="/"&&(i=Dt([i,m.pathnameBase]))}return o}function Aa(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Og(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((d,{paramName:f,isOptional:m},p)=>{if(f==="*"){let x=l[p]||"";o=i.slice(0,i.length-x.length).replace(/(.)\/+$/,"$1")}const w=l[p];return m&&!w?d[f]=void 0:d[f]=(w||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:o,pattern:e}}function Og(e,t=!1,n=!0){Nt(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 r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c,d,f)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let m=f.charAt(d+o.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function Bg(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Nt(!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 (${t}).`),e}}function qt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var Dg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Ug(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?wr(e):e,i;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?i=uu(n.substring(1),"/"):i=uu(n,t)):i=t,{pathname:i,search:Vg(r),hash:Gg(a)}}function uu(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function Pi(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Wg(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Ll(e){let t=Wg(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Za(e,t,n,r=!1){let a;typeof e=="string"?a=wr(e):(a={...e},be(!a.pathname||!a.pathname.includes("?"),Pi("?","pathname","search",a)),be(!a.pathname||!a.pathname.includes("#"),Pi("#","pathname","hash",a)),be(!a.search||!a.search.includes("#"),Pi("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=n;else{let m=t.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),m-=1;a.pathname=p.join("/")}l=m>=0?t[m]:"/"}let c=Ug(a,l),d=o&&o!=="/"&&o.endsWith("/"),f=(i||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Dt=e=>e.join("/").replace(/\/\/+/g,"/"),Hg=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Vg=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Gg=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Kg=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Yg(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Qg(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Zf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function em(e,t){let n=e;if(typeof n!="string"||!Dg.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(Zf)try{let i=new URL(window.location.href),o=n.startsWith("//")?new URL(i.protocol+n):new URL(n),l=qt(o.pathname,t);o.origin===i.origin&&l!=null?n=l+o.search+o.hash:a=!0}catch{Nt(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var tm=["POST","PUT","PATCH","DELETE"];new Set(tm);var Jg=["GET",...tm];new Set(Jg);var jr=u.createContext(null);jr.displayName="DataRouter";var ei=u.createContext(null);ei.displayName="DataRouterState";var Xg=u.createContext(!1),nm=u.createContext({isTransitioning:!1});nm.displayName="ViewTransition";var qg=u.createContext(new Map);qg.displayName="Fetchers";var Zg=u.createContext(null);Zg.displayName="Await";var gt=u.createContext(null);gt.displayName="Navigation";var ws=u.createContext(null);ws.displayName="Location";var $t=u.createContext({outlet:null,matches:[],isDataRoute:!1});$t.displayName="Route";var Ml=u.createContext(null);Ml.displayName="RouteError";var rm="REACT_ROUTER_ERROR",ey="REDIRECT",ty="ROUTE_ERROR_RESPONSE";function ny(e){if(e.startsWith(`${rm}:${ey}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function ry(e){if(e.startsWith(`${rm}:${ty}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Kg(t.status,t.statusText,t.data)}catch{}}function sy(e,{relative:t}={}){be(Sr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=u.useContext(gt),{hash:a,pathname:i,search:o}=js(e,{relative:t}),l=i;return n!=="/"&&(l=i==="/"?n:Dt([n,i])),r.createHref({pathname:l,search:o,hash:a})}function Sr(){return u.useContext(ws)!=null}function yt(){return be(Sr(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(ws).location}var sm="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function am(e){u.useContext(gt).static||u.useLayoutEffect(e)}function en(){let{isDataRoute:e}=u.useContext($t);return e?xy():ay()}function ay(){be(Sr(),"useNavigate() may be used only in the context of a <Router> component.");let e=u.useContext(jr),{basename:t,navigator:n}=u.useContext(gt),{matches:r}=u.useContext($t),{pathname:a}=yt(),i=JSON.stringify(Ll(r)),o=u.useRef(!1);return am(()=>{o.current=!0}),u.useCallback((c,d={})=>{if(Nt(o.current,sm),!o.current)return;if(typeof c=="number"){n.go(c);return}let f=Za(c,JSON.parse(i),a,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Dt([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,i,a,e])}var iy=u.createContext(null);function oy(e){let t=u.useContext($t).outlet;return u.useMemo(()=>t&&u.createElement(iy.Provider,{value:e},t),[t,e])}function js(e,{relative:t}={}){let{matches:n}=u.useContext($t),{pathname:r}=yt(),a=JSON.stringify(Ll(n));return u.useMemo(()=>Za(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function ly(e,t){return im(e,t)}function im(e,t,n){var S;be(Sr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=u.useContext(gt),{matches:a}=u.useContext($t),i=a[a.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",d=i&&i.route;{let g=d&&d.path||"";lm(l,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${g}">) 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="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let f=yt(),m;if(t){let g=typeof t=="string"?wr(t):t;be(c==="/"||((S=g.pathname)==null?void 0:S.startsWith(c)),`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 "${c}" but pathname "${g.pathname}" was given in the \`location\` prop.`),m=g}else m=f;let p=m.pathname||"/",w=p;if(c!=="/"){let g=c.replace(/^\//,"").split("/");w="/"+p.replace(/^\//,"").split("/").slice(g.length).join("/")}let x=Jf(e,{pathname:w});Nt(d||x!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Nt(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.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 v=my(x&&x.map(g=>Object.assign({},g,{params:Object.assign({},o,g.params),pathname:Dt([c,r.encodeLocation?r.encodeLocation(g.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:Dt([c,r.encodeLocation?r.encodeLocation(g.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),a,n);return t&&v?u.createElement(ws.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...m},navigationType:"POP"}},v):v}function cy(){let e=vy(),t=Yg(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=u.createElement(u.Fragment,null,u.createElement("p",null,"💿 Hey developer 👋"),u.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",u.createElement("code",{style:i},"ErrorBoundary")," or"," ",u.createElement("code",{style:i},"errorElement")," prop on your route.")),u.createElement(u.Fragment,null,u.createElement("h2",null,"Unexpected Application Error!"),u.createElement("h3",{style:{fontStyle:"italic"}},t),n?u.createElement("pre",{style:a},n):null,o)}var uy=u.createElement(cy,null),om=class extends u.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,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):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 n=ry(e.digest);n&&(e=n)}let t=e!==void 0?u.createElement($t.Provider,{value:this.props.routeContext},u.createElement(Ml.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?u.createElement(dy,{error:e},t):t}};om.contextType=Xg;var Ii=new WeakMap;function dy({children:e,error:t}){let{basename:n}=u.useContext(gt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=ny(t.digest);if(r){let a=Ii.get(t);if(a)throw a;let i=em(r.location,n);if(Zf&&!Ii.get(t))if(i.isExternal||r.reloadDocument)window.location.href=i.absoluteURL||i.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:r.replace}));throw Ii.set(t,o),o}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${i.absoluteURL||i.to}`})}}return e}function fy({routeContext:e,match:t,children:n}){let r=u.useContext(jr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),u.createElement($t.Provider,{value:e},n)}function my(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,i=r==null?void 0:r.errors;if(i!=null){let f=a.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);be(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,f+1))}let o=!1,l=-1;if(n&&r){o=r.renderFallback;for(let f=0;f<a.length;f++){let m=a[f];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=f),m.route.id){let{loaderData:p,errors:w}=r,x=m.route.loader&&!p.hasOwnProperty(m.route.id)&&(!w||w[m.route.id]===void 0);if(m.route.lazy||x){n.isStatic&&(o=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=n==null?void 0:n.onError,d=r&&c?(f,m)=>{var p,w;c(f,{location:r.location,params:((w=(p=r.matches)==null?void 0:p[0])==null?void 0:w.params)??{},unstable_pattern:Qg(r.matches),errorInfo:m})}:void 0;return a.reduceRight((f,m,p)=>{let w,x=!1,v=null,S=null;r&&(w=i&&m.route.id?i[m.route.id]:void 0,v=m.route.errorElement||uy,o&&(l<0&&p===0?(lm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,S=null):l===p&&(x=!0,S=m.route.hydrateFallbackElement||null)));let g=t.concat(a.slice(0,p+1)),h=()=>{let y;return w?y=v:x?y=S:m.route.Component?y=u.createElement(m.route.Component,null):m.route.element?y=m.route.element:y=f,u.createElement(fy,{match:m,routeContext:{outlet:f,matches:g,isDataRoute:r!=null},children:y})};return r&&(m.route.ErrorBoundary||m.route.errorElement||p===0)?u.createElement(om,{location:r.location,revalidation:r.revalidation,component:v,error:w,children:h(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:d}):h()},null)}function Fl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function py(e){let t=u.useContext(jr);return be(t,Fl(e)),t}function hy(e){let t=u.useContext(ei);return be(t,Fl(e)),t}function gy(e){let t=u.useContext($t);return be(t,Fl(e)),t}function Ol(e){let t=gy(e),n=t.matches[t.matches.length-1];return be(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function yy(){return Ol("useRouteId")}function vy(){var r;let e=u.useContext(Ml),t=hy("useRouteError"),n=Ol("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function xy(){let{router:e}=py("useNavigate"),t=Ol("useNavigate"),n=u.useRef(!1);return am(()=>{n.current=!0}),u.useCallback(async(a,i={})=>{Nt(n.current,sm),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...i}))},[e,t])}var du={};function lm(e,t,n){!t&&!du[e]&&(du[e]=!0,Nt(!1,n))}u.memo(wy);function wy({routes:e,future:t,state:n,isStatic:r,onError:a}){return im(e,void 0,{state:n,isStatic:r,onError:a})}function Ht({to:e,replace:t,state:n,relative:r}){be(Sr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=u.useContext(gt);Nt(!a,"<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:i}=u.useContext($t),{pathname:o}=yt(),l=en(),c=Za(e,Ll(i),o,r==="path"),d=JSON.stringify(c);return u.useEffect(()=>{l(JSON.parse(d),{replace:t,state:n,relative:r})},[l,d,r,t,n]),null}function jy(e){return oy(e.context)}function je(e){be(!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 Sy({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:i=!1,unstable_useTransitions:o}){be(!Sr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=u.useMemo(()=>({basename:l,navigator:a,static:i,unstable_useTransitions:o,future:{}}),[l,a,i,o]);typeof n=="string"&&(n=wr(n));let{pathname:d="/",search:f="",hash:m="",state:p=null,key:w="default",unstable_mask:x}=n,v=u.useMemo(()=>{let S=qt(d,l);return S==null?null:{location:{pathname:S,search:f,hash:m,state:p,key:w,unstable_mask:x},navigationType:r}},[l,d,f,m,p,w,r,x]);return Nt(v!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${m}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:u.createElement(gt.Provider,{value:c},u.createElement(ws.Provider,{children:t,value:v}))}function ky({children:e,location:t}){return ly(zo(e),t)}function zo(e,t=[]){let n=[];return u.Children.forEach(e,(r,a)=>{if(!u.isValidElement(r))return;let i=[...t,a];if(r.type===u.Fragment){n.push.apply(n,zo(r.props.children,i));return}be(r.type===je,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),be(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=zo(r.props.children,i)),n.push(o)}),n}var sa="get",aa="application/x-www-form-urlencoded";function ti(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function by(e){return ti(e)&&e.tagName.toLowerCase()==="button"}function Ny(e){return ti(e)&&e.tagName.toLowerCase()==="form"}function Cy(e){return ti(e)&&e.tagName.toLowerCase()==="input"}function Ey(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ty(e,t){return e.button===0&&(!t||t==="_self")&&!Ey(e)}function $o(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function Ry(e,t){let n=$o(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}var Ds=null;function Py(){if(Ds===null)try{new FormData(document.createElement("form"),0),Ds=!1}catch{Ds=!0}return Ds}var Iy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ai(e){return e!=null&&!Iy.has(e)?(Nt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${aa}"`),null):e}function Ay(e,t){let n,r,a,i,o;if(Ny(e)){let l=e.getAttribute("action");r=l?qt(l,t):null,n=e.getAttribute("method")||sa,a=Ai(e.getAttribute("enctype"))||aa,i=new FormData(e)}else if(by(e)||Cy(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(r=c?qt(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||sa,a=Ai(e.getAttribute("formenctype"))||Ai(l.getAttribute("enctype"))||aa,i=new FormData(l,e),!Py()){let{name:d,type:f,value:m}=e;if(f==="image"){let p=d?`${d}.`:"";i.append(`${p}x`,"0"),i.append(`${p}y`,"0")}else d&&i.append(d,m)}}else{if(ti(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=sa,r=null,a=aa,o=e}return i&&a==="text/plain"&&(o=i,i=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:i,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Bl(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function _y(e,t,n,r){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${r}`:a.pathname=`${a.pathname}.${r}`:a.pathname==="/"?a.pathname=`_root.${r}`:t&&qt(a.pathname,t)==="/"?a.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${r}`,a}async function zy(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function $y(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 Ly(e,t,n){let r=await Promise.all(e.map(async a=>{let i=t.routes[a.route.id];if(i){let o=await zy(i,n);return o.links?o.links():[]}return[]}));return By(r.flat(1).filter($y).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function fu(e,t,n,r,a,i){let o=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,l=(c,d)=>{var f;return n[d].pathname!==c.pathname||((f=n[d].route.path)==null?void 0:f.endsWith("*"))&&n[d].params["*"]!==c.params["*"]};return i==="assets"?t.filter((c,d)=>o(c,d)||l(c,d)):i==="data"?t.filter((c,d)=>{var m;let f=r.routes[c.route.id];if(!f||!f.hasLoader)return!1;if(o(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let p=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((m=n[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function My(e,t,{includeHydrateFallback:n}={}){return Fy(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let i=[a.module];return a.clientActionModule&&(i=i.concat(a.clientActionModule)),a.clientLoaderModule&&(i=i.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(i=i.concat(a.hydrateFallbackModule)),a.imports&&(i=i.concat(a.imports)),i}).flat(1))}function Fy(e){return[...new Set(e)]}function Oy(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function By(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let i=JSON.stringify(Oy(a));return n.has(i)||(n.add(i),r.push({key:i,link:a})),r},[])}function cm(){let e=u.useContext(jr);return Bl(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Dy(){let e=u.useContext(ei);return Bl(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Dl=u.createContext(void 0);Dl.displayName="FrameworkContext";function um(){let e=u.useContext(Dl);return Bl(e,"You must render this element inside a <HydratedRouter> element"),e}function Uy(e,t){let n=u.useContext(Dl),[r,a]=u.useState(!1),[i,o]=u.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:m}=t,p=u.useRef(null);u.useEffect(()=>{if(e==="render"&&o(!0),e==="viewport"){let v=g=>{g.forEach(h=>{o(h.isIntersecting)})},S=new IntersectionObserver(v,{threshold:.5});return p.current&&S.observe(p.current),()=>{S.disconnect()}}},[e]),u.useEffect(()=>{if(r){let v=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(v)}}},[r]);let w=()=>{a(!0)},x=()=>{a(!1),o(!1)};return n?e!=="intent"?[i,p,{}]:[i,p,{onFocus:Ar(l,w),onBlur:Ar(c,x),onMouseEnter:Ar(d,w),onMouseLeave:Ar(f,x),onTouchStart:Ar(m,w)}]:[!1,p,{}]}function Ar(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Wy({page:e,...t}){let{router:n}=cm(),r=u.useMemo(()=>Jf(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?u.createElement(Vy,{page:e,matches:r,...t}):null}function Hy(e){let{manifest:t,routeModules:n}=um(),[r,a]=u.useState([]);return u.useEffect(()=>{let i=!1;return Ly(e,t,n).then(o=>{i||a(o)}),()=>{i=!0}},[e,t,n]),r}function Vy({page:e,matches:t,...n}){let r=yt(),{future:a,manifest:i,routeModules:o}=um(),{basename:l}=cm(),{loaderData:c,matches:d}=Dy(),f=u.useMemo(()=>fu(e,t,d,i,r,"data"),[e,t,d,i,r]),m=u.useMemo(()=>fu(e,t,d,i,r,"assets"),[e,t,d,i,r]),p=u.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let v=new Set,S=!1;if(t.forEach(h=>{var j;let y=i.routes[h.route.id];!y||!y.hasLoader||(!f.some(b=>b.route.id===h.route.id)&&h.route.id in c&&((j=o[h.route.id])!=null&&j.shouldRevalidate)||y.hasClientLoader?S=!0:v.add(h.route.id))}),v.size===0)return[];let g=_y(e,l,a.unstable_trailingSlashAwareDataRequests,"data");return S&&v.size>0&&g.searchParams.set("_routes",t.filter(h=>v.has(h.route.id)).map(h=>h.route.id).join(",")),[g.pathname+g.search]},[l,a.unstable_trailingSlashAwareDataRequests,c,r,i,f,t,e,o]),w=u.useMemo(()=>My(m,i),[m,i]),x=Hy(m);return u.createElement(u.Fragment,null,p.map(v=>u.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),w.map(v=>u.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),x.map(({key:v,link:S})=>u.createElement("link",{key:v,nonce:n.nonce,...S,crossOrigin:S.crossOrigin??n.crossOrigin})))}function Gy(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Ky=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Ky&&(window.__reactRouterVersion="7.13.1")}catch{}function Yy({basename:e,children:t,unstable_useTransitions:n,window:r}){let a=u.useRef();a.current==null&&(a.current=bg({window:r,v5Compat:!0}));let i=a.current,[o,l]=u.useState({action:i.action,location:i.location}),c=u.useCallback(d=>{n===!1?l(d):u.startTransition(()=>l(d))},[n]);return u.useLayoutEffect(()=>i.listen(c),[i,c]),u.createElement(Sy,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:i,unstable_useTransitions:n})}var dm=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qe=u.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:i,replace:o,unstable_mask:l,state:c,target:d,to:f,preventScrollReset:m,viewTransition:p,unstable_defaultShouldRevalidate:w,...x},v){let{basename:S,navigator:g,unstable_useTransitions:h}=u.useContext(gt),y=typeof f=="string"&&dm.test(f),j=em(f,S);f=j.to;let b=sy(f,{relative:a}),E=yt(),C=null;if(l){let z=Za(l,[],E.unstable_mask?E.unstable_mask.pathname:"/",!0);S!=="/"&&(z.pathname=z.pathname==="/"?S:Dt([S,z.pathname])),C=g.createHref(z)}let[P,N,_]=Uy(r,x),M=Xy(f,{replace:o,unstable_mask:l,state:c,target:d,preventScrollReset:m,relative:a,viewTransition:p,unstable_defaultShouldRevalidate:w,unstable_useTransitions:h});function V(z){t&&t(z),z.defaultPrevented||M(z)}let J=!(j.isExternal||i),B=u.createElement("a",{...x,..._,href:(J?C:void 0)||j.absoluteURL||b,onClick:J?V:t,ref:Gy(v,N),target:d,"data-discover":!y&&n==="render"?"true":void 0});return P&&!y?u.createElement(u.Fragment,null,B,u.createElement(Wy,{page:b})):B});qe.displayName="Link";var Ul=u.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:i,to:o,viewTransition:l,children:c,...d},f){let m=js(o,{relative:d.relative}),p=yt(),w=u.useContext(ei),{navigator:x,basename:v}=u.useContext(gt),S=w!=null&&nv(m)&&l===!0,g=x.encodeLocation?x.encodeLocation(m).pathname:m.pathname,h=p.pathname,y=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;n||(h=h.toLowerCase(),y=y?y.toLowerCase():null,g=g.toLowerCase()),y&&v&&(y=qt(y,v)||y);const j=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let b=h===g||!a&&h.startsWith(g)&&h.charAt(j)==="/",E=y!=null&&(y===g||!a&&y.startsWith(g)&&y.charAt(g.length)==="/"),C={isActive:b,isPending:E,isTransitioning:S},P=b?t:void 0,N;typeof r=="function"?N=r(C):N=[r,b?"active":null,E?"pending":null,S?"transitioning":null].filter(Boolean).join(" ");let _=typeof i=="function"?i(C):i;return u.createElement(qe,{...d,"aria-current":P,className:N,ref:f,style:_,to:o,viewTransition:l},typeof c=="function"?c(C):c)});Ul.displayName="NavLink";var Qy=u.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:i,method:o=sa,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:m,unstable_defaultShouldRevalidate:p,...w},x)=>{let{unstable_useTransitions:v}=u.useContext(gt),S=ev(),g=tv(l,{relative:d}),h=o.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&dm.test(l),j=b=>{if(c&&c(b),b.defaultPrevented)return;b.preventDefault();let E=b.nativeEvent.submitter,C=(E==null?void 0:E.getAttribute("formmethod"))||o,P=()=>S(E||b.currentTarget,{fetcherKey:t,method:C,navigate:n,replace:a,state:i,relative:d,preventScrollReset:f,viewTransition:m,unstable_defaultShouldRevalidate:p});v&&n!==!1?u.startTransition(()=>P()):P()};return u.createElement("form",{ref:x,method:h,action:g,onSubmit:r?c:j,...w,"data-discover":!y&&e==="render"?"true":void 0})});Qy.displayName="Form";function Jy(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function fm(e){let t=u.useContext(jr);return be(t,Jy(e)),t}function Xy(e,{target:t,replace:n,unstable_mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,unstable_defaultShouldRevalidate:c,unstable_useTransitions:d}={}){let f=en(),m=yt(),p=js(e,{relative:o});return u.useCallback(w=>{if(Ty(w,t)){w.preventDefault();let x=n!==void 0?n:ps(m)===ps(p),v=()=>f(e,{replace:x,unstable_mask:r,state:a,preventScrollReset:i,relative:o,viewTransition:l,unstable_defaultShouldRevalidate:c});d?u.startTransition(()=>v()):v()}},[m,f,p,n,r,a,t,e,i,o,l,c,d])}function Wl(e){Nt(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 t=u.useRef($o(e)),n=u.useRef(!1),r=yt(),a=u.useMemo(()=>Ry(r.search,n.current?null:t.current),[r.search]),i=en(),o=u.useCallback((l,c)=>{const d=$o(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,i("?"+d,c)},[i,a]);return[a,o]}var qy=0,Zy=()=>`__${String(++qy)}__`;function ev(){let{router:e}=fm("useSubmit"),{basename:t}=u.useContext(gt),n=yy(),r=e.fetch,a=e.navigate;return u.useCallback(async(i,o={})=>{let{action:l,method:c,encType:d,formData:f,body:m}=Ay(i,t);if(o.navigate===!1){let p=o.fetcherKey||Zy();await r(p,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:f,body:m,formMethod:o.method||c,formEncType:o.encType||d,flushSync:o.flushSync})}else await a(o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:f,body:m,formMethod:o.method||c,formEncType:o.encType||d,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,a,t,n])}function tv(e,{relative:t}={}){let{basename:n}=u.useContext(gt),r=u.useContext($t);be(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),i={...js(e||".",{relative:t})},o=yt();if(e==null){i.search=o.search;let l=new URLSearchParams(i.search),c=l.getAll("index");if(c.some(f=>f==="")){l.delete("index"),c.filter(m=>m).forEach(m=>l.append("index",m));let f=l.toString();i.search=f?`?${f}`:""}}return(!e||e===".")&&a.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(i.pathname=i.pathname==="/"?n:Dt([n,i.pathname])),ps(i)}function nv(e,{relative:t}={}){let n=u.useContext(nm);be(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=fm("useViewTransitionState"),a=js(e,{relative:t});if(!n.isTransitioning)return!1;let i=qt(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=qt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Aa(a.pathname,o)!=null||Aa(a.pathname,i)!=null}const An="owner";function rv(e){const t=e||An;return t===An?[An]:[t,An]}function sv(e){const t=new Map;for(const n of e)for(const r of n)t.has(r.id)||t.set(r.id,r);return[...t.values()].sort((n,r)=>r.createdAt-n.createdAt)}function av(e,t){const n=t||An,r=(e==null?void 0:e.pendingDomains)??[];return r.includes(n)?n:r.includes(An)?An:n}class mm extends Error{constructor(n){super("different_account");kr(this,"summary");this.name="DifferentAccountError",this.summary=n}}function iv(e){const t=e==null?void 0:e.pubkeys;return!t||typeof t!="object"||Array.isArray(t)?[]:Object.entries(t).filter(n=>typeof n[1]=="string"&&n[1].length>0).map(([n,r])=>({userId:n,publicKey:r}))}class ov{constructor(){kr(this,"apiKey",null)}setApiKey(t){this.apiKey=t}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(t,n){return globalThis.fetch(t,{...n,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...n==null?void 0:n.headers}})}async login(t,n={}){const r=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":t,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:n.confirmWipe===!0})});if(r.status===409){const i=await r.json().catch(()=>({}));if(i!=null&&i.wouldWipe)throw new mm(i.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!r.ok){const i=await r.json().catch(()=>({error:"Invalid API key"}));throw new Error(i.error||`Login failed: ${r.status}`)}return(await r.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const t=await this.fetch("/api/groups");if(!t.ok)throw new Error(`Failed to fetch groups: ${t.status}`);const n=await t.json();return n.groups??n}async listProfiles(){const t=await this.fetch("/api/profiles");if(!t.ok)throw new Error(`Failed to fetch profiles: ${t.status}`);return(await t.json()).profiles}async getProfile(t){const n=await this.fetch(`/api/profiles/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch profile: ${n.status}`);return n.json()}async attest(t){const n=await this.fetch("/api/as/attest",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Attest failed: ${n.status}`)}return n.json()}async getPending(t){const n=await this.fetch(`/api/attestations/pending?domain=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch pending: ${n.status}`);const r=await n.json();return r.pending??r}async getMyAttestations(t){const n=t?`?status=${encodeURIComponent(t)}`:"",r=await this.fetch(`/api/attestations/mine${n}`);if(!r.ok)throw new Error(`Failed to fetch attestations: ${r.status}`);return((await r.json()).attestations??[]).map(i=>{var o,l;return{authorization_id:i.authorization_id,profile_id:i.profileId,path:i.path,title:i.title??null,sp_status:i.status??null,frame:i.bounds??i.frame??{},required_domains:i.requiredDomains??[],attested_domains:i.attestedDomains??[],missing_domains:(i.requiredDomains??[]).filter(c=>!(i.attestedDomains??[]).includes(c)),deferred_commitment_domains:i.deferredCommitmentDomains??[],approvers_frozen:i.approversFrozen??[],above_cap:i.aboveCap??!1,created_at:i.createdAt?new Date(i.createdAt*1e3).toISOString():"",earliest_expiry:(o=i.attestations)!=null&&o.length?new Date(Math.min(...i.attestations.map(c=>c.expiresAt))*1e3).toISOString():null,remaining_seconds:(l=i.attestations)!=null&&l.length?Math.max(0,Math.min(...i.attestations.map(c=>c.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getDenials(t){const n=new URLSearchParams;t!=null&&t.since&&n.set("since",String(t.since)),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString()?`?${n.toString()}`:"",a=await this.fetch(`/denials${r}`);if(!a.ok)throw new Error(`Failed to fetch denials: ${a.status}`);return a.json()}async getMyReceipts(t){const n=new URLSearchParams;t!=null&&t.date&&n.set("date",t.date),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);return(await a.json()).receipts??[]}async fetchEvidenceBundle(){var a;const t=await this.fetch("/api/evidence-export"),n=await t.json();if(!t.ok)throw new Error(n.error??`Export failed (${t.status})`);const r=((a=/filename="([^"]+)"/.exec(t.headers.get("content-disposition")??""))==null?void 0:a[1])??"suveren-evidence.json";return{bundle:n,filename:r}}async getLocalAuthorizations(){const t=await this.fetch("/api/evidence/authorizations");if(!t.ok)throw new Error(`Local evidence unavailable (${t.status})`);const n=await t.json();return{authorizations:n.authorizations??{},signatures:n.signatures??{}}}async getArchivedReceipt(t){const n=await this.fetch(`/api/evidence/receipt/${encodeURIComponent(t)}`);if(n.status===404)return null;if(!n.ok)throw new Error(`Local evidence unavailable (${n.status})`);return await n.json()}async getReport(){const t=await this.fetch("/api/report");if(!t.ok){const n=await t.json().catch(()=>({error:`Report unavailable (${t.status})`}));throw new Error(n.error??`Report unavailable (${t.status})`)}return t.json()}async saveReport(t){const n=await this.fetch("/api/report",{method:"POST",body:JSON.stringify({html:t})});if(!n.ok){const r=await n.json().catch(()=>({error:`Save failed (${n.status})`}));throw new Error(r.error??`Save failed (${n.status})`)}return n.json()}async recheckReport(){const t=await this.fetch("/api/report/recheck",{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({error:`Recheck failed (${t.status})`}));throw new Error(n.error??`Recheck failed (${t.status})`)}return t.json()}async exportReportWithProof(){var a;const t=await this.fetch("/api/report/export");if(!t.ok){const i=await t.json().catch(()=>({error:`Export failed (${t.status})`}));throw new Error(i.error??`Export failed (${t.status})`)}const n=await t.text(),r=((a=/filename="([^"]+)"/.exec(t.headers.get("content-disposition")??""))==null?void 0:a[1])??"suveren-report.html";return{html:n,filename:r}}async revokeAttestation(t,n){const r=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/revoke`,{method:"POST",body:JSON.stringify({reason:n??"Revoked by user"})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to revoke"}));throw new Error(a.error||`Revoke failed: ${r.status}`)}}async getAttestations(t){const n=await this.fetch(`/api/attestations?authorization_id=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch attestations: ${n.status}`);return n.json()}async getGroupById(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch group: ${n.status}`);return n.json()}async createGroup(t){const n=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:t})});if(!n.ok){const i=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||`Create group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:!0}}async joinGroup(t){const n=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:t})});if(!n.ok){const i=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(i.error||`Join group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:a.isAdmin||!1}}async inviteToGroup(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/invite`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Invite failed: ${n.status}`)}return n.json()}async getMyTeam(){const t=await this.fetch("/api/groups/me");if(!t.ok)return null;const n=await t.json();return n.group?{group:n.group,membership:n.membership}:null}async listUsers(){const t=await this.fetch("/api/users");return t.ok?(await t.json()).users??[]:[]}async setPubkey(t){const n=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(r.error||`setPubkey failed: ${n.status}`)}}async getPubkey(t){const n=await this.fetch(`/api/users/${encodeURIComponent(t)}/pubkey`);return n.status===404||!n.ok?null:(await n.json()).pubkey??null}async leaveTeam(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/leave`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to leave team"}));throw new Error(r.error||`Leave failed: ${n.status}`)}}async getVaultStatus(){const t=await this.fetch("/vault/status");if(!t.ok)throw new Error(`Failed to fetch vault status: ${t.status}`);return t.json()}async getGatewaySettings(){const t=await this.fetch("/api/gateway-settings");if(!t.ok)throw new Error(`Failed to load settings: ${t.status}`);return t.json()}async setGatewaySettings(t){const n=await this.fetch("/api/gateway-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`Failed to save settings: ${n.status}`);return n.json()}async getArchivedMandates(){const t=await this.fetch("/api/archived-mandates");if(!t.ok)throw new Error(`Failed to load archived mandates: ${t.status}`);return(await t.json()).archived}async setMandateArchived(t,n){const r=await this.fetch(`/api/archived-mandates/${encodeURIComponent(t)}`,{method:n?"PUT":"DELETE"});if(!r.ok)throw new Error(`Failed to ${n?"archive":"unarchive"} mandate: ${r.status}`);return(await r.json()).archived}async getCredential(t){const n=await this.fetch(`/vault/credentials/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to check credential: ${n.status}`);return n.json()}async setCredential(t,n){const r=await this.fetch(`/vault/credentials/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)});if(!r.ok)throw new Error(`Failed to save credential: ${r.status}`)}async testCredential(t){const n=await this.fetch(`/vault/test/${encodeURIComponent(t)}`,{method:"POST"});if(!n.ok)throw new Error(`Test failed: ${n.status}`);return n.json()}async aiAssist(t){const n=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI request failed"}))).error,disclaimer:"AI surfaces reality. You supply intent."}}async aiIntentReview(t){const n=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI request failed"}))).error}}async aiTest(t){const n=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(t??{})});if(!n.ok)throw new Error(`AI test failed: ${n.status}`);return n.json()}async aiModels(t){const n=await this.fetch("/ai/models",{method:"POST",body:JSON.stringify(t??{})});if(!n.ok)throw new Error(`Model list failed: ${n.status}`);return n.json()}async getMcpHealth(){const t=await this.fetch("/mcp/health");if(!t.ok)throw new Error(`MCP server unreachable: ${t.status}`);return t.json()}async getMcpIntegrations(){const t=await this.fetch("/mcp/integrations");if(!t.ok)throw new Error(`Failed to fetch integrations: ${t.status}`);return t.json()}async getOAuthHealth(t){try{const n=await this.fetch(`/auth/oauth/${encodeURIComponent(t)}/health`);return n.ok?await n.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const t=await this.fetch("/mcp/integrations/manifests");if(!t.ok)throw new Error(`Failed to fetch manifests: ${t.status}`);return t.json()}async discoverScopeField(t,n){const r=await this.fetch(`/integrations/${encodeURIComponent(t)}/discover/${encodeURIComponent(n)}`);if(!r.ok){const a=await r.json().catch(()=>({error:`Discovery failed: ${r.status}`}));throw new Error(a.error)}return r.json()}async activateIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}/activate`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`Failed: ${n.status}`)}return n.json()}async removeMcpIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`Failed to remove integration: ${n.status}`)}async setReadPolicy(t,n){const r=await this.fetch(`/integrations/${encodeURIComponent(t)}/read-policy`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({readAgeDays:n})});if(!r.ok){const a=await r.json().catch(()=>({error:`HTTP ${r.status}`}));throw new Error(a.error)}}async getTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`);if(r.status===404||!r.ok)return null;const a=await r.json();return(a==null?void 0:a.config)??null}async setTeamProfileConfig(t,n,r){const a=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify(r)});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(i.error||`setTeamProfileConfig failed: ${a.status}`)}}async encryptIntent(t,n){const r=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:t,recipients:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Encryption failed"}));throw new Error(a.error||`encryptIntent failed: ${r.status}`)}return r.json()}async getToolDisplay(){const t=await this.fetch("/tool-display");if(!t.ok)return{};const n=await t.json();return(n==null?void 0:n.tools)??{}}async getApproversPubkeys(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}/approvers/pubkeys`);return r.ok?iv(await r.json()):[]}async deleteTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"DELETE"});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(a.error||`deleteTeamProfileConfig failed: ${r.status}`)}}async getProposals(t){const n=await this.fetch(`/api/proposals?domain=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals??[]}async getMyProposals(t){const n=await Promise.all(rv(t).map(r=>this.getProposals(r)));return sv(n)}async resolveProposal(t,n,r){const a=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/resolve`,{method:"POST",body:JSON.stringify({action:n,domain:r})});if(!a.ok){const i=await a.json().catch(()=>({error:"Failed"}));throw new Error(i.error||`Failed: ${a.status}`)}return a.json()}async getProposalsForApprover(){const t=await this.fetch("/api/proposals?approver=me");if(!t.ok)throw new Error(`Failed to fetch approver proposals: ${t.status}`);return(await t.json()).proposals??[]}async approveProposal(t){const n=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/approve`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`approveProposal failed: ${n.status}`)}return n.json()}async rejectProposal(t,n){const r=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/reject`,{method:"POST",body:JSON.stringify({reason:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`rejectProposal failed: ${r.status}`)}return r.json()}async getAttestationIntent(t){const n=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/intent`);return n.status===404||n.status===403||!n.ok?null:n.json()}async decryptIntent(t){const n=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const a=await n.json().catch(()=>({error:"Decryption failed"}));throw new Error(a.error||`decryptIntent failed: ${n.status}`)}return(await n.json()).intent}async storeApprovedIntent(t,n){const r=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:t,intent:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`storeApprovedIntent failed: ${r.status}`)}}async listTeamAuthorizations(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/attestations`);if(!n.ok)throw new Error(`Failed to fetch team authorizations: ${n.status}`);return((await n.json()).items??[]).map(a=>{var l,c;const i=a.owner??{userId:""};return{authorization_id:a.authorization_id??a.authorizationId,profile_id:a.profileId??a.profile_id,path:a.path??"",title:a.title??null,sp_status:a.status??a.sp_status??null,frame:a.bounds??a.frame??{},required_domains:a.requiredDomains??a.required_domains??[],attested_domains:a.attestedDomains??a.attested_domains??[],missing_domains:(a.requiredDomains??a.required_domains??[]).filter(d=>!(a.attestedDomains??a.attested_domains??[]).includes(d)),deferred_commitment_domains:a.deferredCommitmentDomains??a.deferred_commitment_domains??[],approvers_frozen:a.approversFrozen??a.approvers_frozen??[],above_cap:a.aboveCap??a.above_cap??!1,created_at:a.createdAt?new Date(a.createdAt*1e3).toISOString():a.created_at??"",earliest_expiry:(l=a.attestations)!=null&&l.length?new Date(Math.min(...a.attestations.map(d=>d.expiresAt))*1e3).toISOString():null,remaining_seconds:(c=a.attestations)!=null&&c.length?Math.max(0,Math.min(...a.attestations.map(d=>d.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:i}})}async listTeamReceipts(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts`);if(!n.ok)throw new Error(`Failed to fetch team receipts: ${n.status}`);return(await n.json()).receipts??[]}async getMyReceiptsPage(t){const n=new URLSearchParams;t!=null&&t.before&&n.set("before",t.before),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);const i=await a.json();return{receipts:i.receipts??[],nextBefore:i.nextBefore??null}}async listTeamReceiptsPage(t,n){const r=new URLSearchParams;n!=null&&n.before&&r.set("before",n.before),n!=null&&n.profile&&r.set("profile",n.profile),n!=null&&n.limit&&r.set("limit",String(n.limit));const a=r.toString(),i=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts${a?"?"+a:""}`);if(!i.ok)throw new Error(`Failed to fetch team receipts: ${i.status}`);const o=await i.json();return{receipts:o.receipts??[],nextBefore:o.nextBefore??null}}async getThread(t){const n=t.sinceDays??7,r=t.status??"pending",a=await this.getMyProposals(t.domain);let i=[];if(r==="all"){const o=[],l=new Date;for(let d=0;d<n;d++){const f=new Date(l);f.setUTCDate(l.getUTCDate()-d),o.push(f.toISOString().slice(0,10))}i=(await Promise.all(o.map(d=>this.getMyReceipts({date:d,profile:t.profile})))).flat()}return{proposals:a,receipts:i}}async getAutostart(){const t=await this.fetch("/autostart");if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}async setAutostart(t){const n=await this.fetch("/autostart",{method:t?"POST":"DELETE"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.message||`HTTP ${n.status}`)}}async getAsPairing(){const t=await this.fetch("/as-pairing");if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}async getSkippedCommitments(){const t=await this.fetch("/skipped-commitments");if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}async getGateContent(t){const n=await this.fetch(`/gate-content?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch gate content: ${n.status}`);return(await n.json()).entry??null}async resyncGates(){const t=await this.fetch("/resync-gates",{method:"POST"});if(!t.ok)throw new Error(`Failed to resync gates: ${t.status}`)}async getEnrichedAuthorizations(){const t=await this.fetch("/active-authorizations");if(!t.ok)throw new Error(`Failed to fetch authorizations: ${t.status}`);return(await t.json()).authorizations??[]}async pushGateContent(t){const n=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(r.error||`Push gate content failed: ${n.status}`)}}async getAgentContext(){const t=await this.fetch("/agent-brief/context");if(!t.ok)throw new Error(`Failed to fetch agent context: ${t.status}`);return(await t.json()).content}async saveAgentContext(t){const n=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(r.error||`Save failed: ${n.status}`)}}async aiChat(t){const n=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI chat failed"}))).error||`Chat failed: ${n.status}`}}async getAIPrompts(){const t=await this.fetch("/ai-prompts");if(!t.ok)throw new Error(`Failed to load AI prompts: ${t.status}`);return t.json()}async setAIPrompt(t,n){const r=await this.fetch(`/ai-prompts/${t}`,{method:"PUT",body:JSON.stringify({value:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Save failed"}));throw new Error(a.error||`Save failed: ${r.status}`)}}}const R=new ov,pm=u.createContext(null);function lv({children:e}){const[t,n]=u.useState(null),[r,a]=u.useState("personal"),[i,o]=u.useState(null),[l,c]=u.useState(""),[d,f]=u.useState(null),[m,p]=u.useState(null),[w,x]=u.useState(!1),[v,S]=u.useState(""),g=u.useRef(!1),h=u.useRef(null),y=u.useCallback(async()=>{if(g.current)try{const N=await R.getMyTeam();if(N){const{group:_,membership:M}=N;f(_),p(M),a("team"),o(_);const V=h.current??M.domains[0]??"owner";c(V)}else f(null),p(null),a("personal")}catch{}},[]);u.useEffect(()=>{const N=()=>{document.visibilityState==="visible"&&y()};return document.addEventListener("visibilitychange",N),()=>document.removeEventListener("visibilitychange",N)},[y]),u.useEffect(()=>{fetch("/health").then(N=>N.json()).then(N=>{var _;((_=N.session)==null?void 0:_.lockedReason)==="as-url-changed"&&S(`Authority Server changed to ${N.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const j=u.useCallback(async(N,_={})=>{x(!0),S("");try{R.setApiKey(N),g.current=!0;const M=await R.login(N,_);n(M),h.current=M.id;const V=await R.getGroups(),J=V.find(B=>B.isPersonal)??V[0]??null;o(J),c("owner"),await y()}catch(M){throw R.clearApiKey(),g.current=!1,S(M instanceof Error?M.message:"Login failed"),M}finally{x(!1)}},[y]),b=u.useCallback(async()=>{await R.logout(),R.clearApiKey(),g.current=!1,h.current=null,n(null),o(null),c(""),f(null),p(null),a("personal"),S("")},[]),E=u.useCallback(N=>{R.clearApiKey(),g.current=!1,h.current=null,n(null),o(null),c(""),f(null),p(null),a("personal"),S(N??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),C=u.useCallback(()=>S(""),[]),P=u.useCallback((N,_)=>{o(N),c(_)},[]);return s.jsx(pm.Provider,{value:{user:t,mode:r,group:i,domain:l,groupId:(i==null?void 0:i.id)??null,activeTeam:d,activeMembership:m,isLoading:w,error:v,login:j,logout:b,clearError:C,handleSessionLocked:E,activeGroup:i,activeDomain:l,groups:i?[i]:[],setActiveContext:P,refreshGroups:y},children:e})}function Be(){const e=u.useContext(pm);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const hm=u.createContext(null);function cv({children:e}){const{user:t}=Be(),n=u.useRef(null),[r,a]=u.useState(!1),i=u.useRef(new Map),o=u.useCallback((l,c)=>{const d=i.current;return d.has(l)||d.set(l,new Set),d.get(l).add(c),()=>{var f;(f=d.get(l))==null||f.delete(c)}},[]);return u.useEffect(()=>{if(!t){n.current&&(n.current.close(),n.current=null,a(!1));return}if(n.current)return;const l=R.getApiKey();if(!l)return;const c=new EventSource(`/events?key=${encodeURIComponent(l)}`);n.current=c,c.onopen=()=>a(!0),c.onerror=()=>a(!1);const d=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected","session-locked"];for(const f of d)c.addEventListener(f,m=>{let p;try{p=JSON.parse(m.data)}catch{p=null}const w=i.current.get(f);if(w)for(const x of w)try{x(p)}catch(v){console.error(`[EventSource] handler for "${f}" threw:`,v)}});return()=>{c.close(),n.current=null,a(!1)}},[t]),s.jsx(hm.Provider,{value:{connected:r,addListener:o},children:e})}function ge(e,t){const n=u.useContext(hm);if(!n)return;const{addListener:r}=n;u.useEffect(()=>r(e,t),[e,t,r])}const Jr="suveren-theme",mu="hap-theme";function Us(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(mu);t!==null&&localStorage.getItem(Jr)===null&&localStorage.setItem(Jr,t),t!==null&&localStorage.removeItem(mu)})();function gm(){const[e,t]=u.useState(()=>{const i=localStorage.getItem(Jr);return i==="light"||i==="dark"?i:"system"}),[n,r]=u.useState(()=>Us(e));u.useEffect(()=>{const i=document.documentElement,o=Us(e);i.setAttribute("data-theme",o),e==="system"?localStorage.removeItem(Jr):localStorage.setItem(Jr,e),r(Us(e))},[e]),u.useEffect(()=>{if(e!=="system")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>r(Us("system"));return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[e]);const a=u.useCallback(()=>{t(i=>i==="system"?"light":i==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:n,toggle:a}}const uv=5*60*1e3,dv=2e3;function Hl(){const[e,t]=u.useState(!1),[n,r]=u.useState("docker"),[a,i]=u.useState(""),[o,l]=u.useState(null),[c,d]=u.useState(!1),[f,m]=u.useState(!1),[p,w]=u.useState(!1),x=u.useRef(null);return u.useEffect(()=>{let v=!1;const S=(y=!1)=>{fetch(y?"/health?refresh=1":"/health").then(j=>j.json()).then(j=>{v||(j.installMethod&&r(j.installMethod),typeof j.latestVersion<"u"&&l(j.latestVersion),j.updateAvailable&&t(!0),j.version&&(i(j.version),x.current===null?x.current=j.version:j.version!==x.current&&j.version!=="dev"&&d(!0)))}).catch(()=>{})};S(!0);const g=setInterval(()=>S(!1),p?dv:uv),h=()=>{document.visibilityState==="visible"&&S(!1)};return document.addEventListener("visibilitychange",h),window.addEventListener("focus",h),()=>{v=!0,clearInterval(g),document.removeEventListener("visibilitychange",h),window.removeEventListener("focus",h)}},[p]),{updateAvailable:e&&!f,installMethod:n,version:a,latestVersion:o,serverRestarted:c,startFastPolling:()=>w(!0),dismiss:()=>m(!0)}}function fv({size:e=20}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 128 128",fill:"none","aria-hidden":"true",focusable:"false",children:[s.jsx("path",{d:"M 104.6 58.29 A 41 41 0 1 1 48.64 25.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"}),s.jsx("line",{x1:"73.24",y1:"21.99",x2:"95.76",y2:"34.99",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round"})]})}function mv(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const pu={system:"◑",light:"☀",dark:"☾"};function Vl({onMenuToggle:e}){const{user:t,logout:n}=Be(),{theme:r,toggle:a}=gm(),{version:i,updateAvailable:o,latestVersion:l}=Hl(),c=mv(i);return s.jsx("nav",{className:"top-nav",children:s.jsxs("div",{className:"top-nav-inner",children:[s.jsxs("div",{className:"logo-group",children:[s.jsx(fv,{size:20}),s.jsx("span",{className:"logo",children:"Suveren"}),s.jsx("span",{className:"version-badge",children:"Local Gateway"}),c&&s.jsxs("span",{className:"gw-version",title:o&&l?`Running v${c} — v${l} is available`:"Running gateway version","data-stale":o?"true":void 0,children:["v",c,o&&l?` → ${l}`:""]})]}),s.jsx("div",{className:"nav-spacer"}),s.jsx("div",{className:"nav-actions nav-actions-desktop",children:t?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"user-chip",children:s.jsx("strong",{children:t.name})}),s.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:pu[r]}),s.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):s.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:pu[r]})}),t&&e&&s.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function Gl(e,t){var n;if((n=t==null?void 0:t.revokedSet)!=null&&n.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 ym(e){return e==="expired"||e==="revoked"}function vm(e,t){var n;return!!((n=t==null?void 0:t.archivedSet)!=null&&n.has(e.authorization_id))&&ym(Gl(e,t))}function _a(e,t){return vm(e,t)?"archived":Gl(e,t)}function xm(e,t){const n={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const r of e)n[_a(r,t)].push(r);return n}function pv(e,t){return t==="expired"?e.earliest_expiry?{iso:e.earliest_expiry,meaning:"expired"}:null:e.created_at?{iso:e.created_at,meaning:"created"}:null}function It(e,t,n){const r=u.useRef(e);r.current=e,u.useEffect(()=>{let a=null;const i=()=>typeof document>"u"?!0:document.visibilityState==="visible",o=()=>{i()&&r.current()},l=()=>{a===null&&(a=setInterval(o,t))},c=()=>{a!==null&&(clearInterval(a),a=null)},d=()=>{i()?(r.current(),l()):c()};return i()&&(r.current(),l()),document.addEventListener("visibilitychange",d),()=>{c(),document.removeEventListener("visibilitychange",d)}},[t,n])}const wm=u.createContext(null),hv=3e4,gv=5e3,yv=3e5;function vv(e,t,n){return t===0?"loading":e!=null&&e.running?"running":e!=null&&e.paused?"paused":e!=null&&e.error?"error":e&&n?"starting":"not-running"}function xv({children:e}){const[t,n]=u.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),r=u.useRef(null),a=u.useCallback(async()=>{let d=!1;const[f,m]=await Promise.all([R.getIntegrationManifests().catch(()=>(d=!0,{manifests:[]})),R.getMcpHealth().catch(()=>null)]);n(w=>({...w,manifests:f.manifests,integrations:(m==null?void 0:m.integrations)??w.integrations,activeSessions:(m==null?void 0:m.activeSessions)??w.activeSessions,mcpServerUp:!!m,manifestsError:d,fetchCount:w.fetchCount+1}));const p=f.manifests.filter(w=>w.oauth);if(p.length>0){const w=await Promise.all(p.map(async x=>[x.id,await R.getOAuthHealth(x.id)]));n(x=>({...x,authHealth:Object.fromEntries(w)}))}},[]),i=t.fetchCount>0&&t.manifests.some(d=>{const f=t.integrations.find(m=>m.id===d.id);return f&&!f.running&&!f.paused});ge("integration-changed",a),It(a,i?gv:yv);const o=u.useMemo(()=>{const d=new Map(t.integrations.map(p=>[p.id,p])),f=Date.now();i&&r.current===null?r.current=f:i||(r.current=null);const m=r.current!==null&&f-r.current<hv;return t.manifests.map(p=>{const w=d.get(p.id),x=vv(w,t.fetchCount,m),v=t.authHealth[p.id];return{id:p.id,manifest:p,integration:w,state:x,authStatus:v==null?void 0:v.status,authAccount:v==null?void 0:v.account,authError:v==null?void 0:v.error}})},[t,i]),l=u.useMemo(()=>o.filter(d=>d.state==="not-running"||d.state==="error"||d.authStatus==="failed").length,[o]),c={loading:t.fetchCount===0,mcpServerUp:t.mcpServerUp,manifestsError:t.manifestsError,entries:o,attentionCount:l,activeSessions:t.activeSessions,refresh:a};return s.jsx(wm.Provider,{value:c,children:e})}function Kl(){const e=u.useContext(wm);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const wv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/mandates",icon:"☰",label:"Mandates",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant"}];function jv(){const{activeDomain:e}=Be(),[t,n]=u.useState({}),r=u.useCallback(async()=>{try{const[a,i,o,l,c,d]=await Promise.all([R.getCredential("ai-config").catch(()=>null),R.getMyAttestations().catch(()=>null),R.getMyProposals(e).catch(()=>null),R.getProposalsForApprover().catch(()=>null),R.getAgentContext().catch(()=>""),R.getArchivedMandates().catch(()=>[])]),f={};if(a&&!a.configured&&(f.assistant=1),i){const x=xm(i,{archivedSet:new Set(d)}).expired.length;x>0&&(f.authorizations=x)}const m=(o==null?void 0:o.length)??0,p=(l==null?void 0:l.length)??0,w=m+p;w>0&&(f.proposals=w),(!c||!c.trim())&&(f.brief=1),n(f)}catch{}},[e]);return ge("attestation-changed",r),ge("proposal-added",r),ge("proposal-resolved",r),ge("proposal-approved",r),ge("proposal-rejected",r),ge("team-membership-changed",r),u.useEffect(()=>(window.addEventListener("suveren:archived-changed",r),()=>window.removeEventListener("suveren:archived-changed",r)),[r]),It(r,3e5,e),t}const Sv={marginLeft:"auto",minWidth:"1.25rem",height:"1.25rem",padding:"0 0.375rem",borderRadius:"0.625rem",background:"var(--warning)",color:"var(--bg-elevated)",fontSize:"0.7rem",fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},kv={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated, #1e1e2e)",color:"var(--text-primary, #e2e8f0)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function bv(){const{mode:e,group:t,domain:n,activeTeam:r}=Be(),a=jv(),{attentionCount:i}=Kl(),o={...a};i>0&&(o.integrations=i);const l=wv.filter(p=>!p.teamOnly||e==="team"),c=u.useRef(null),[d,f]=u.useState(null),m=yt();return u.useEffect(()=>{if(c.current===null){c.current=e;return}c.current!==e&&(e==="team"&&r?f(`You are now acting in team context — ${r.name}`):e==="personal"&&f("You have left the team — back to personal context"),c.current=e)},[e,r]),u.useEffect(()=>{f(null)},[m.pathname]),s.jsxs("div",{className:"sidebar",children:[s.jsx("ul",{className:"sidebar-nav",children:l.map(p=>{const w=p.statusKey?o[p.statusKey]:0;return s.jsx("li",{children:s.jsxs(Ul,{to:p.to,end:p.to==="/",className:({isActive:x})=>`sidebar-item${x?" active":""}`,children:[s.jsx("span",{className:"icon",children:p.icon}),p.label,w?s.jsx("span",{style:Sv,children:w}):null]})},p.to)})}),s.jsxs("div",{className:"sidebar-context",children:[s.jsx("div",{className:"ctx-label",children:"Active context"}),s.jsx("div",{className:"ctx-value",children:e==="personal"?"personal":t?`${t.name} / ${n}`:n})]}),d&&s.jsx("div",{style:kv,role:"status","aria-live":"polite",children:d})]})}const _i="suveren:updatedTo";function Nv(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 Cv="Updates for this gateway come from your company's IT — no action needed here.";function Ev(e){return e==="managed"?"update-banner is-managed":"update-banner"}const Tv="Download the new installer and run it. Your settings and mandates stay.";function Rv(e){const t="https://github.com/suverenai/suveren-gateway/releases";return e?`${t}/tag/v${e}`:`${t}/latest`}function Pv(){const e=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const n of e)if(!n.closest(".update-overlay"))return!0;const t=document.activeElement;if(t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable)){const n=t.value;if(n&&n.trim())return!0}return!1}function jm(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:a,startFastPolling:i,dismiss:o}=Hl(),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[m,p]=u.useState(()=>{try{const y=sessionStorage.getItem(_i);if(y)return sessionStorage.removeItem(_i),y}catch{}return null}),w=Nv(t),x=u.useRef(null),v=y=>{try{sessionStorage.setItem(_i,y||r||"✓")}catch{}window.location.reload()};u.useEffect(()=>{if(!m)return;const y=setTimeout(()=>p(null),6e3);return()=>clearTimeout(y)},[m]),u.useEffect(()=>{if(!l||!a)return;const y=()=>Pv()?!1:(v(n),!0);if(y())return;const j=setInterval(y,1500);return()=>clearInterval(j)},[l,a,n]),u.useEffect(()=>(document.body.classList.toggle("is-updating",l),()=>document.body.classList.remove("is-updating")),[l]);const S=e&&!l&&!m||!!m&&!l;u.useEffect(()=>{if(!S){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const y=()=>{var E;const b=((E=x.current)==null?void 0:E.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${b}px`)};y();const j=new ResizeObserver(y);return x.current&&j.observe(x.current),()=>{j.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[S]);const g=()=>{c(!0),i()},h=async()=>{if(w)try{await navigator.clipboard.writeText(w),f(!0),setTimeout(()=>f(!1),1800)}catch{}};return s.jsxs(s.Fragment,{children:[m&&!l&&s.jsx("div",{ref:x,className:"update-banner is-live",role:"status","aria-live":"polite",children:s.jsxs("div",{className:"update-banner-row",children:[s.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",m&&m!=="✓"?` — ${m} is live`:" — now live","."]}),s.jsx("button",{className:"update-banner-x",onClick:()=>p(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!m&&s.jsxs("div",{ref:x,className:Ev(t),role:"status","aria-live":"polite",children:[s.jsxs("div",{className:"update-banner-row",children:[s.jsx("span",{className:"update-banner-text",children:t==="msi"&&r?`Update available — version ${r}.`:"Update available."}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[t==="msi"&&s.jsx("a",{className:"btn btn-sm btn-secondary",href:Rv(r),target:"_blank",rel:"noopener noreferrer",children:"Download installer"}),t!=="managed"&&t!=="msi"&&s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:g,children:"Update"}),s.jsx("button",{className:"update-banner-x",onClick:o,"aria-label":"Dismiss",children:"×"})]})]}),t==="managed"&&s.jsx("p",{className:"update-banner-hint",children:Cv}),t==="msi"&&s.jsx("p",{className:"update-banner-hint",children:Tv})]}),l&&s.jsx("div",{className:"update-overlay",children:s.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[s.jsx("div",{className:"update-spinner"}),s.jsxs("h2",{children:["Finishing the update","…"]}),s.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",s.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),s.jsxs("div",{className:"update-cmd-row",children:[s.jsx("code",{className:"update-cmd",children:w}),s.jsx("button",{className:"btn btn-sm btn-primary",onClick:h,children:d?"Copied":"Copy"})]}),s.jsxs("div",{className:"update-status",children:[s.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),s.jsxs("div",{className:"update-overlay-actions",children:[s.jsx("button",{className:"btn btn-primary",onClick:()=>v(n),children:"Reload now"}),s.jsx("button",{className:"btn btn-secondary",onClick:()=>c(!1),children:"Cancel"})]})]})})]})}function Sm(){const[e,t]=u.useState(!1);return u.useEffect(()=>{let n=!1;const r=()=>{fetch("/health").then(o=>o.json()).then(o=>{n||t(o.simulation===!0)}).catch(()=>{})};r();const a=setInterval(r,3e4),i=()=>{document.visibilityState==="visible"&&r()};return document.addEventListener("visibilitychange",i),()=>{n=!0,clearInterval(a),document.removeEventListener("visibilitychange",i)}},[]),e}function km(){const e=Sm(),t=u.useRef(null);return u.useEffect(()=>{if(!e){document.documentElement.style.removeProperty("--sim-banner-h");return}const n=()=>{var i;const a=((i=t.current)==null?void 0:i.offsetHeight)??0;document.documentElement.style.setProperty("--sim-banner-h",`${a}px`)};n();const r=new ResizeObserver(n);return t.current&&r.observe(t.current),()=>{r.disconnect(),document.documentElement.style.removeProperty("--sim-banner-h")}},[e]),e?s.jsx("div",{ref:t,className:"simulation-banner",role:"status","aria-live":"polite",children:s.jsx("span",{className:"simulation-banner-text",children:"Simulation mode — real systems are blocked."})}):null}const Iv={system:"◑",light:"☀",dark:"☾"},Av=[{to:"/",icon:"□",label:"Dashboard"},{to:"/approvals",icon:"▷",label:"Pending Approvals"},{to:"/mandates",icon:"☰",label:"Mandates"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/tickets",icon:"▣",label:"Tickets"},{to:"/reports",icon:"▥",label:"Reports"},{to:"/team",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function _v({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:a,logout:i}=Be(),{theme:o,toggle:l}=gm(),c=yt();return u.useEffect(()=>{t()},[c.pathname]),e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mobile-menu-backdrop",onClick:t}),s.jsxs("div",{className:"mobile-menu-panel",children:[n&&s.jsxs("div",{className:"mobile-menu-header",children:[s.jsx("strong",{children:n.name}),s.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:r?`${r.name} / ${a}`:a||"personal"})]}),s.jsx("nav",{className:"mobile-menu-nav",children:Av.map(d=>s.jsxs(Ul,{to:d.to,end:d.to==="/",className:({isActive:f})=>`mobile-menu-item${f?" active":""}`,onClick:t,children:[s.jsx("span",{className:"icon",children:d.icon}),d.label]},d.to))}),s.jsxs("div",{className:"mobile-menu-footer",children:[s.jsxs("button",{className:"mobile-menu-action",onClick:()=>{l()},children:[s.jsx("span",{className:"icon",children:Iv[o]}),"Theme: ",o]}),s.jsx("button",{className:"mobile-menu-action",onClick:()=>{i(),t()},children:"Logout"})]})]})]}):null}function bm(e){return e.status==="pending"}function zv(e,t){return e.filter(bm).length+t.length}const Nn=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],$v=500;function Nm(){const{user:e,domain:t}=Be(),[n,r]=u.useState(0),a=u.useRef(null),i=u.useCallback(async()=>{if(!e){r(0);return}try{const[l,c]=await Promise.all([R.getMyProposals(t).catch(()=>[]),R.getProposalsForApprover().catch(()=>[])]);r(zv(l,c))}catch{r(0)}},[e,t]),o=u.useCallback(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i()},$v)},[i]);return u.useEffect(()=>(i(),()=>{a.current&&clearTimeout(a.current)}),[i]),ge(Nn[0],o),ge(Nn[1],o),ge(Nn[2],o),ge(Nn[3],o),ge(Nn[4],o),ge(Nn[5],o),ge(Nn[6],o),n}const hu="Suveren",Lv="/favicon.svg",Mv="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Ws={x1:74.54,y1:22.74,x2:94.46,y2:34.24},Fv=14,Ov="#f59e0b";function Bv(e){const t=Yl(e);return t>0?`(${t}) ${hu}`:hu}function Yl(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function Dv(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
52
- <path class="m" d="${Mv}"/>
53
- <line class="m" x1="${Ws.x1}" y1="${Ws.y1}" x2="${Ws.x2}" y2="${Ws.y2}"/>
54
- <circle cx="103" cy="103" r="25" fill="${Ov}"/>
55
- <style>.m{stroke:#111111;stroke-width:${Fv};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 Uv(){return document.querySelector('link[rel="icon"]')}function Cm(e){const t=Yl(e);document.title=Bv(t),Em(t);const n=Uv();if(!n)return;const r=t>0?Dv():Lv;n.getAttribute("href")!==r&&n.setAttribute("href",r)}function Wv(){Cm(0)}function Em(e,t=globalThis.navigator){var a;if(!t||typeof t.setAppBadge!="function")return;const n=Yl(e),r=n>0?t.setAppBadge(n):t.clearAppBadge?t.clearAppBadge():t.setAppBadge(0);(a=r==null?void 0:r.catch)==null||a.call(r,()=>{})}function Hv(){const e=Nm();return u.useEffect(()=>{Cm(e)},[e]),u.useEffect(()=>Wv,[]),null}const Tm="suveren:dockBadgePrompt";function Vv(){var r;if(typeof window>"u"||!("Notification"in window)||!("setAppBadge"in navigator)||!(((r=window.matchMedia)==null?void 0:r.call(window,"(display-mode: standalone)").matches)||navigator.standalone===!0))return!1;const t=navigator.userAgent;if(!(/Safari\//.test(t)&&!/Chrome\/|Chromium\/|Edg\//.test(t))||Notification.permission!=="default")return!1;try{if(localStorage.getItem(Tm))return!1}catch{}return!0}function Gv(){const[e,t]=u.useState(!1),n=Nm();if(u.useEffect(()=>{t(Vv())},[]),!e)return null;const r=()=>{try{localStorage.setItem(Tm,"1")}catch{}t(!1)},a=async()=>{try{await Notification.requestPermission()==="granted"&&Em(n)}catch{}r()};return s.jsxs("div",{className:"hint-box",style:{marginBottom:"1rem",alignItems:"center"},children:[s.jsxs("div",{className:"hint-body",children:[s.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."]}),s.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:a,children:"Allow"}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:r,"aria-label":"Not now",children:"Not now"})]})}function Kv(){const[e,t]=u.useState(!1);return s.jsxs(xv,{children:[s.jsx(Hv,{}),s.jsx(Vl,{onMenuToggle:()=>t(!e)}),s.jsx(jm,{}),s.jsx(km,{}),s.jsx(bv,{}),s.jsx(_v,{open:e,onClose:()=>t(!1)}),s.jsx("div",{className:"main-content",children:s.jsxs("div",{className:"page-inner",children:[s.jsx(Gv,{}),s.jsx(jy,{})]})})]})}function Yv(){const[e,t]=u.useState(""),{login:n,isLoading:r,error:a,clearError:i}=Be(),[o,l]=u.useState(null),c=async()=>{if(e.trim()){i();try{await n(e)}catch(m){if(m instanceof mm){l(m.summary);return}}}},d=async()=>{l(null),i();try{await n(e,{confirmWipe:!0})}catch{}},f=()=>{l(null)};return s.jsxs(s.Fragment,{children:[s.jsx(Vl,{}),s.jsx(jm,{}),s.jsx(km,{}),s.jsxs("div",{className:"login-split",children:[s.jsx("div",{className:"login-split-left",children:s.jsxs("div",{style:{maxWidth:"28rem"},children:[s.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."}),s.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."})]})}),s.jsx("div",{className:"login-split-right",children:s.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[s.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[s.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),s.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage mandates."})]}),a&&s.jsx("div",{className:"error-message",children:a}),s.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[s.jsx("label",{className:"form-label",children:"API Key"}),s.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:m=>t(m.target.value),onKeyDown:m=>m.key==="Enter"&&c(),disabled:r,style:{padding:"0.75rem"}}),s.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),s.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:c,disabled:r,style:{marginBottom:"2rem"},children:r?"Signing in...":"Sign In"}),s.jsx("div",{className:"login-divider",children:"New here?"}),s.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[s.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",s.jsx("br",{}),"then come back to sign in."]}),s.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"})]}),s.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),s.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[s.jsxs(s.Fragment,{children:["Create an account at ",s.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((m,p)=>s.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:p<2?"0.5rem":0},children:[s.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[p+1,"."]}),m]},p))})]})]})})]}),o&&s.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:f,children:s.jsxs("div",{className:"card",onClick:m=>m.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[s.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),s.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 ",s.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),s.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[s.jsxs("li",{children:[o.credentialCount," stored service credential",o.credentialCount===1?"":"s",o.credentialIds.length>0&&s.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",o.credentialIds.slice(0,5).join(", "),o.credentialIds.length>5?`, +${o.credentialIds.length-5} more`:"",")"]})]}),s.jsxs("li",{children:[o.serviceCount," configured integration",o.serviceCount===1?"":"s"]}),s.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),s.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),s.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."}),s.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."}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:f,disabled:r,children:"Cancel"}),s.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:d,disabled:r,children:r?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function Qv(){const{setActiveContext:e}=Be(),t=en(),[n,r]=u.useState(""),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(!1),f=async()=>{if(n.trim()){d(!0),l("");try{const p=await R.joinGroup(n.trim());e(p,p.myDomains[0]||""),t("/")}catch(p){l(p instanceof Error?p.message:"Failed to join group")}finally{d(!1)}}},m=async()=>{if(a.trim()){d(!0),l("");try{const p=await R.createGroup(a.trim());e(p,p.myDomains[0]||""),t("/")}catch(p){l(p instanceof Error?p.message:"Failed to create group")}finally{d(!1)}}};return s.jsxs(s.Fragment,{children:[s.jsx(Vl,{}),s.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:s.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[s.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[s.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join Your Team"}),s.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6},children:"Join an existing team or create a new one to share authority across domains."})]}),o&&s.jsx("div",{className:"error-message",children:o}),s.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[s.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing group"}),s.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),s.jsxs("div",{className:"invite-input-row",children:[s.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:n,onChange:p=>r(p.target.value),onKeyDown:p=>p.key==="Enter"&&f(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:c}),s.jsx("button",{className:"btn btn-primary",onClick:f,disabled:c,children:"Join"})]})]}),s.jsxs("div",{className:"card",children:[s.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new group"}),s.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members. Assign domains after creation."}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("input",{className:"form-input",placeholder:"Group name (e.g., Acme Corp)",value:a,onChange:p=>i(p.target.value),onKeyDown:p=>p.key==="Enter"&&m(),style:{flex:1},disabled:c}),s.jsx("button",{className:"btn btn-secondary",onClick:m,disabled:c,children:"Create"})]})]})]})})]})}const Lo="suveren-setup-ai-skipped",Mo="suveren-setup-agent-done",Fo="suveren-setup-dismissed",Jv={"hap-setup-ai-skipped":Lo,"hap-setup-agent-done":Mo,"hap-setup-dismissed":Fo};function Xv(){for(const[e,t]of Object.entries(Jv)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}Xv();const zi={"claude-code":{label:"Claude Code",snippet:e=>JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)},"claude-desktop":{label:"Claude Desktop",snippet:e=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
57
-
58
- ${JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)}`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
59
- SSE transport: GET ${e}/sse
60
- Health check: GET ${e}/health`}};function qv({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:a}){const[i,o]=u.useState(()=>localStorage.getItem(Lo)==="true"),[l,c]=u.useState(()=>localStorage.getItem(Mo)==="true"),[d,f]=u.useState(()=>localStorage.getItem(Fo)==="true"),[m,p]=u.useState(null),[w,x]=u.useState("claude-code"),[v,S]=u.useState(!1),g=[{label:"AI Assistant",detail:"A trusted AI helps you think through mandates — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":i?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:t?"done":"pending"},{label:"Give your agent a mandate",to:"/mandates?new=1",status:n?"done":"pending"},{label:"Connect your agent",status:r||l?"done":"pending"}],h=g.filter(N=>N.status==="done"||N.status==="skipped").length,y=h===g.length,j=u.useCallback(()=>{localStorage.setItem(Lo,"true"),o(!0)},[]),b=u.useCallback(()=>{localStorage.setItem(Mo,"true"),c(!0),p(null)},[]),E=u.useCallback(()=>{localStorage.setItem(Fo,"true"),f(!0)},[]),C=u.useCallback(async N=>{try{await navigator.clipboard.writeText(N),S(!0),setTimeout(()=>S(!1),2e3)}catch{}},[]);if(d||y)return null;const P=g.findIndex(N=>N.status==="pending");return s.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[s.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),s.jsx("button",{onClick:E,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:g.map((N,_)=>{const M=_===P,V=N.status==="done"||N.status==="skipped"?"●":"○",J=N.status==="done"?"var(--success)":N.status==="skipped"?"var(--text-tertiary)":M?"var(--accent)":"var(--text-tertiary)";return s.jsxs("div",{children:[s.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:[s.jsx("span",{style:{color:J,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:V}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[N.to&&N.status==="pending"?s.jsx(qe,{to:N.to,style:{fontSize:"0.9rem",fontWeight:M?600:500,color:M?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:N.label}):N.status==="pending"&&_===3?s.jsx("button",{onClick:()=>p(m===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:N.label}):s.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:N.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:N.label}),N.optional&&N.status==="pending"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),N.status==="skipped"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),N.detail&&N.status==="pending"&&M&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:N.detail})]}),N.optional&&N.status==="pending"&&s.jsx("button",{onClick:j,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),N.to&&N.status==="pending"&&s.jsx(qe,{to:N.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),_===3&&m===3&&s.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[s.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem",color:"var(--text-primary)"},children:"MCP Endpoint"}),s.jsx("div",{style:{fontFamily:"monospace",fontSize:"0.85rem",padding:"0.5rem 0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",marginBottom:"1rem",wordBreak:"break-all"},children:a}),s.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"0.75rem"},children:Object.entries(zi).map(([B,z])=>s.jsx("button",{onClick:()=>x(B),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:w===B?600:400,background:w===B?"var(--accent-subtle)":"transparent",color:w===B?"var(--accent)":"var(--text-secondary)",border:`1px solid ${w===B?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:z.label},B))}),s.jsx("pre",{style:{fontFamily:"monospace",fontSize:"0.78rem",lineHeight:1.6,padding:"0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",overflow:"auto",whiteSpace:"pre-wrap",margin:0,marginBottom:"0.75rem"},children:zi[w].snippet(a)}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>C(zi[w].snippet(a)),children:v?"Copied":"Copy"}),s.jsx("button",{className:"btn btn-primary btn-sm",onClick:b,children:"Done"})]})]})]},_)})}),s.jsxs("div",{style:{marginTop:"1.25rem"},children:[s.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:s.jsx("div",{style:{height:"100%",width:`${h/g.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),s.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[h," of ",g.length," complete"]})]})]})}function _n({variant:e="base",style:t,className:n,...r}){const a=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return s.jsx("span",{className:`${a}${n?` ${n}`:""}`,style:t,role:"status","aria-busy":"true","aria-label":r["aria-label"]??"Loading"})}function $i(){return s.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[s.jsx(_n,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),s.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[s.jsx(_n,{variant:"line",style:{width:"35%"}}),s.jsx(_n,{variant:"line-sm",style:{width:"65%"}})]})]})}const Zv={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Rm=e=>Zv[e]??e,ex={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 tx(e){return ex[e]??{chip:"Blocked",sev:"info"}}function nx(e){const t=Rm(e.integrationId);switch(e.reason){case"resource":return e.integrationId==="calendar"?s.jsxs(s.Fragment,{children:["Tried to read your ",s.jsx("b",{children:e.target??"restricted"})," calendar"]}):s.jsxs(s.Fragment,{children:["Tried to read a restricted location in ",t]});case"spam":return s.jsxs(s.Fragment,{children:["Tried to open a message in ",s.jsx("b",{children:"spam or trash"})]});case"age":return s.jsxs(s.Fragment,{children:["Tried to read ",t," older than your read window"]});case"unset_age":return s.jsxs(s.Fragment,{children:["Your ",t," has ",s.jsx("b",{children:"no read window set"}),", so reads are blocked"]});case"read_gate":return s.jsxs(s.Fragment,{children:["Read access isn't granted on your ",t," mandate"]});case"ungoverned":return s.jsxs(s.Fragment,{children:["A ",t," tool isn't configured for safe reading"]});case"query_unsafe":return s.jsx(s.Fragment,{children:"A search couldn't be safely limited and was refused"});default:return s.jsx(s.Fragment,{children:e.detail})}}function rx(e,t){const n=Math.max(0,(t-e)/1e3);if(n<60)return"Just now";if(n<3600)return`${Math.floor(n/60)} min ago`;if(n<86400)return`${Math.floor(n/3600)} hr ago`;const r=Math.floor(n/86400);return r===1?"Yesterday":`${r} days ago`}const gu=5,sx=24*60*60*1e3,ia=7;function ax(e,t){const n=t-ia*sx;return{recent:e.filter(r=>r.ts>=n),all:e}}function ix(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(!1),o=u.useCallback(()=>{R.getDenials({limit:200}).then(({records:p})=>{t(p),i(!1)}).catch(()=>i(!0))},[]);if(u.useEffect(()=>{o()},[o]),It(o,12e4),a||e===null)return null;const{recent:l,all:c}=ax(e,Date.now()),d=n?c:l.slice(0,gu),f=c.length-l.length,m=(p,w)=>{const x=tx(p.reason);return s.jsxs("div",{className:"rb-row",children:[s.jsx("span",{className:`rb-dot ${x.sev==="act"?"act":x.sev==="info"?"info":""}`,"aria-hidden":"true"}),s.jsxs("div",{className:"rb-body",children:[s.jsx("div",{className:"rb-line",children:nx(p)}),s.jsxs("div",{className:"rb-meta",children:[s.jsx("span",{className:`rb-chip ${x.sev==="act"?"act":x.sev==="warn"?"warn":""}`,children:x.chip}),s.jsx("span",{className:"rb-via",children:Rm(p.integrationId)})]}),x.fixTo&&s.jsx(qe,{className:"rb-fix",to:x.fixTo,children:"Set a read window →"})]}),s.jsx("div",{className:"rb-when",children:rx(p.ts,Date.now())})]},`${p.ts}-${w}`)};return s.jsxs("section",{className:"card recent-blocks","aria-label":"Recent blocks",style:{marginTop:"1.5rem"},children:[s.jsxs("div",{className:"card-header",children:[s.jsx("h2",{className:"card-title",children:"Recent blocks"}),(n?c.length:l.length)>0&&s.jsx("span",{className:"rb-count",children:n?c.length:l.length})]}),d.length===0?s.jsxs("div",{className:"rb-empty",children:[s.jsx("span",{className:"rb-mark","aria-hidden":"true",children:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6 9 17l-5-5"})})}),s.jsxs("h3",{children:["Nothing blocked in the last ",ia," days"]}),s.jsx("p",{children:"Your agent has stayed within every limit you set."}),f>0&&s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!0),children:["Show the last 30 days (",f,")"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"rb-sub",children:[n?"Last 30 days. ":`Last ${ia} days. `,"Limits you set that stopped your agent. Seeing them here means the gateway is doing its job."]}),s.jsx("div",{className:"rb-rows",children:d.map(m)}),!n&&c.length>d.length&&s.jsx("div",{className:"rb-foot",children:s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!0),children:["View all ",c.length," blocks from the last 30 days"]})}),n&&c.length>Math.min(l.length,gu)&&s.jsx("div",{className:"rb-foot",children:s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!1),children:["Show only the last ",ia," days"]})})]})]})}function ox(){const[e,t]=u.useState([]);return It(async()=>{try{const{skipped:r}=await R.getSkippedCommitments();t(r)}catch{}},3e4),e.length===0?null:s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"1.5rem",borderLeft:"3px solid var(--warn, #b58900)"},children:[s.jsxs("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:["Approved, but not run here (",e.length,")"]}),s.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."}),s.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",fontSize:"0.9rem"},children:e.map(r=>s.jsxs("li",{style:{marginBottom:"0.35rem"},children:[s.jsx("code",{children:r.tool})," ",s.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",r.id,")"]})]},r.id))})]})}function lx(e,t){const n=e.simulation;return n?(((t==null?void 0:t[n.field])??"").trim().toLowerCase()||n.default.trim().toLowerCase())==="simulation":!1}function Oo(e){return!!(e!=null&&e.simulation)}function cx(e){var n;const t=[];for(const r of e)r.state==="error"?t.push({label:"Integration error",detail:(n=r.integration)!=null&&n.error?`${r.manifest.name}: ${r.integration.error}`:`${r.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"}):r.state==="not-running"&&(Oo(r.manifest)?t.push({label:`${r.manifest.name} is not running`,detail:"Activate it to use it in the test.",to:"/integrations",color:"var(--danger)"}):t.push({label:"Integration stopped",detail:`${r.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"}));return t}function ux(e){const t=e.filter(n=>n.state==="paused");return t.length===0?null:{count:t.length,namesText:t.map(n=>n.manifest.name).join(", ")}}const dx=30*60;function Li(e){return e.replace(/@.*$/,"").split("/").pop()??e}function fx(){const{domain:e}=Be(),[t,n]=u.useState([]),[r,a]=u.useState([]),[i,o]=u.useState([]),[l,c]=u.useState(!0),[d,f]=u.useState(!1),[m,p]=u.useState([]),[w,x]=u.useState(!1),[v,S]=u.useState(!1),{entries:g,activeSessions:h,loading:y}=Kl(),j=!y,b=u.useCallback(()=>{R.getMyAttestations().then(D=>{n(D),f(!0)}).catch(()=>f(!0)),R.getArchivedMandates().then(p).catch(()=>p([])),R.getMyProposals(e).then(D=>{a(D),x(!0)}).catch(()=>x(!0)),R.getProposalsForApprover().then(D=>o(D)).catch(()=>o([])),R.getCredential("ai-config").then(D=>{c(D.configured),S(!0)}).catch(()=>S(!0))},[e]);ge("attestation-changed",b),ge("proposal-added",b),ge("proposal-resolved",b),ge("proposal-approved",b),ge("proposal-rejected",b),It(b,3e5,e);const E=d&&w&&v&&j,C=xm(t,{archivedSet:new Set(m)}),P=C.active,N=C.expired,_=P.filter(D=>D.remaining_seconds!==null&&D.remaining_seconds<=dx),M=r.filter(bm),V=g.filter(D=>D.state==="running"),J=g.filter(D=>D.state==="starting"),B=ux(g),z=[];for(const D of i)z.push({label:"Approval needed",detail:`${D.tool} — above-cap action under ${Li(D.profileId)}`,to:"/approvals",color:"var(--warning)"});for(const D of M)z.push({label:"Approval pending",detail:`${D.tool} awaiting your approval`,to:"/approvals",color:"var(--warning)"});for(const D of _){const oe=Math.ceil((D.remaining_seconds??0)/60);z.push({label:"Expiring soon",detail:`${D.title??Li(D.profile_id)} — ${oe} min remaining`,to:"/mandates",color:"var(--warning)"})}for(const D of N)z.push({label:"Expired",detail:D.title??Li(D.profile_id),to:"/mandates",color:"var(--danger)"});z.push(...cx(g));for(const D of J)z.push({label:"Integration starting",detail:`${D.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const D of g)D.authStatus==="failed"&&D.state!=="not-running"&&D.state!=="error"&&D.state!=="paused"&&z.push({label:"Reconnect needed",detail:`${D.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return l||z.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Dashboard"})}),E&&s.jsx(qv,{aiConfigured:l,hasRunningIntegration:V.length>0,hasActiveAuth:P.length>0,hasAgentConnected:h>0,mcpEndpoint:`http://localhost:${window.location.port==="3400"?"3430":"7430"}`}),s.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[s.jsx(qe,{to:"/mandates",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[d?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:P.length>0?"var(--success)":"var(--text-tertiary)"},children:P.length}):s.jsx(_n,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),s.jsx(qe,{to:"/approvals",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[w?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:M.length>0?"var(--warning)":"var(--text-tertiary)"},children:M.length}):s.jsx(_n,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),s.jsx(qe,{to:"/mandates",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[d?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:N.length>0?"var(--danger)":"var(--text-tertiary)"},children:N.length}):s.jsx(_n,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),s.jsx(qe,{to:"/integrations",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[j?s.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:V.length>0?"var(--success)":"var(--text-tertiary)"},children:V.length}):s.jsx(_n,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),s.jsxs("section",{className:"card attention","aria-label":"Needs your attention",children:[s.jsxs("div",{className:"card-header",children:[s.jsx("h2",{className:"card-title",children:"Needs your attention"}),z.length>0&&s.jsx("span",{className:"rb-count",children:z.length})]}),z.length>0?s.jsx("div",{className:"attention-rows",children:z.map((D,oe)=>s.jsxs(qe,{to:D.to,className:"attention-row",children:[s.jsx("span",{className:"attention-dot",style:{background:D.color},"aria-hidden":"true"}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:D.label}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D.detail})]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},oe))}):E?s.jsxs("div",{className:"all-clear",children:[s.jsx("span",{className:"rb-mark","aria-hidden":"true",children:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6 9 17l-5-5"})})}),s.jsx("h3",{children:"All clear"}),s.jsx("p",{children:"Nothing needs your attention."})]}):s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[s.jsx($i,{}),s.jsx($i,{}),s.jsx($i,{})]})]}),B&&s.jsxs("div",{className:"sim-paused-summary",role:"status",children:[s.jsx("span",{className:"sim-paused-summary-icon","aria-hidden":"true",children:"⏸"}),s.jsxs("span",{children:[s.jsxs("b",{children:[B.count," real system",B.count===1?"":"s"," ",B.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",B.namesText,"."]})]}),s.jsx(ox,{}),s.jsx(ix,{})]})}const mx=["Scope & Limits","Intent","Sign"];function Pm({currentStep:e,onStepClick:t}){const n=en();return s.jsxs("div",{className:"wizard-progress",children:[s.jsx("ol",{className:"wizard-steps",children:mx.map((r,a)=>{const i=a+2,o=i<e,l=i===e,c=i-1<e,d=o&&!!t;return s.jsxs("li",{className:`wizard-step${c?" reached":""}`,"aria-current":l?"step":void 0,children:[s.jsx("button",{type:"button",className:`step-circle${o?" completed":""}${l?" current":""}`,onClick:d?()=>t(i):void 0,disabled:!d,"aria-label":`${r}${o?" (done)":l?" (current)":""}`,children:o?"✓":a+1}),s.jsx("span",{className:`step-label-text${l?" current":o?" completed":""}`,children:r})]},i)})}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>n("/mandates?new=1"),children:"Cancel"})]})}const px=40;function Pe(e,t){const n=e.lastIndexOf("/"),r=n>=0?e.slice(n+1):e,a=r.indexOf("@"),i=a>=0?r.slice(0,a):r;return(i.charAt(0).toUpperCase()+i.slice(1)).slice(0,px)}function hx({profileId:e,bounds:t,groupName:n,domain:r,onSwitch:a}){return s.jsxs("div",{className:"context-strip",children:[n&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"context-strip-label",children:"Team:"}),s.jsxs("span",{children:[s.jsx("strong",{children:n}),r?` / ${r}`:""]})]}),e&&s.jsxs("span",{children:[s.jsx("strong",{children:"Profile:"})," ",Pe(e)]}),t&&s.jsxs("span",{children:[s.jsx("strong",{children:"Bounds:"})," ",t]}),a&&s.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:a,children:"Switch"})]})}function gx({integrationId:e,field:t,value:n,onChange:r,disabled:a,onLabels:i}){const[o,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState(!0);u.useEffect(()=>{let x=!1;return R.discoverScopeField(e,t).then(v=>{var S;x||(l(v.options),m(!1),(S=v.options)!=null&&S.length&&(i==null||i(Object.fromEntries(v.options.map(g=>[g.value,g.label])))))}).catch(v=>{x||(d(v instanceof Error?v.message:String(v)),m(!1))}),()=>{x=!0}},[e,t]);const p=new Set(n.split(",").map(x=>x.trim()).filter(Boolean)),w=x=>{const v=new Set(p);v.has(x)?v.delete(x):v.add(x),r(Array.from(v).join(","))};return f?s.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):c||!o?s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",c??"no response","). Enter values manually, separated by commas."]}),s.jsx("input",{className:"form-input",type:"text",value:n,onChange:x=>r(x.target.value),disabled:a})]}):o.length===0?s.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:o.map(x=>{const v=x.extras??{},S=typeof v.access=="string"?v.access:void 0,g=S==="reader",h=v.primary===!0;return s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:g?"var(--text-tertiary)":"var(--text-primary)",cursor:a||g?"not-allowed":"pointer"},title:g?"Read-only — you can authorize list/read but not writes":void 0,children:[s.jsx("input",{type:"checkbox",checked:p.has(String(x.value)),onChange:()=>w(String(x.value)),disabled:a||g}),s.jsx("span",{children:x.label||x.value}),h&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),S&&s.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",S]})]},x.value)})})}function Ql(e){if(e.type!=="number")return 0;const t=e.boundType,n=e.unit;return(t==null?void 0:t.kind)==="per_transaction"&&n==="count"?1:0}function yx(e,t){return t!==void 0?String(t):Ql(e)===1?"1":""}function yu(e,t){const n=Ql(e);return t===""?n:Math.max(n,Number(t))}function Im(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function vx(e){return e.replace(/@.*$/,"").split("/").pop()??e}function xx(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function wx(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function jx(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function vu(e,t){const n=e.trim();return n?t==="email"?n.includes("@")&&n.indexOf(".",n.indexOf("@"))>-1:t==="domain"?n.includes(".")&&!n.includes("@"):!0:!1}function Sx(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function kx(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 bx(e,t){if(!e||!t)return"";const n=Number(e);if(!Number.isFinite(n)||n<=0)return"";if(t==="minutes"&&n>=60){const r=Math.floor(n/60),a=n%60;return a===0?`${r} hour${r!==1?"s":""}`:`${r}h ${a}m`}if(t==="hours"&&n>=24&&n%24===0){const r=n/24;return`${r} day${r!==1?"s":""}`}if(t==="days"){if(n>=30&&n%30===0)return`${n/30} month${n/30!==1?"s":""}`;if(n>=7&&n%7===0)return`${n/7} week${n/7!==1?"s":""}`}return""}function Nx({id:e,value:t,onChange:n,disabled:r,placeholder:a,unit:i,min:o=0}){const l=Sx(i),c=kx(i),d=Im(i),f=bx(t,i),m=t===""?null:Number(t),p=()=>{const x=t===""?0:Number(t),v=x%l,S=v===0?x+l:x+(l-v);n(String(S))},w=()=>{const x=t===""?0:Number(t);if(x<=o)return;const v=x%l,S=v===0?x-l:x-v;n(String(Math.max(o,S)))};return s.jsxs("div",{className:"bounded-input",children:[s.jsxs("div",{className:"bounded-input-field",children:[s.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:w,disabled:r||t===""||Number(t)<=o,"aria-label":"Decrease",children:"−"}),s.jsx("input",{id:e,className:"stepper-input",type:"number",min:o,step:l,value:t,placeholder:a??String(o),onChange:x=>n(x.target.value),onFocus:x=>x.target.select(),disabled:r}),s.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:p,disabled:r,"aria-label":"Increase",children:"+"}),d&&s.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:d})]}),c.length>0&&!r&&s.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:c.map(x=>s.jsx("button",{type:"button",className:`preset-chip${m===x.value?" preset-chip-selected":""}`,onClick:()=>n(String(x.value)),children:x.label},x.value))}),f&&s.jsxs("div",{className:"bounded-input-echo",children:["≈ ",f]})]})}function xu({htmlFor:e,label:t,description:n}){const[r,a]=u.useState(!1);return s.jsxs("div",{className:"field-label-with-tip",children:[s.jsx("label",{className:"form-label",htmlFor:e,children:t}),n&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${t}" mean?`,"aria-expanded":r,onClick:()=>a(i=>!i),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onBlur:()=>a(!1),children:"i"}),r&&s.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:n})]})]})}function Cx({id:e,value:t,onChange:n,disabled:r,format:a,placeholder:i}){const[o,l]=u.useState(""),[c,d]=u.useState(!1),f=u.useRef(null),m=t?t.split(",").map(g=>g.trim()).filter(Boolean):[],p=g=>{const h=g.trim();if(!h)return;if(!vu(h,a)){d(!0);return}d(!1);const y=m.includes(h)?m:[...m,h];n(y.join(",")),l("")},w=g=>{const h=m.filter((y,j)=>j!==g);n(h.join(","))},x=g=>{g.key==="Enter"||g.key===","||g.key==="Tab"?o.trim()&&(g.preventDefault(),p(o)):g.key==="Backspace"&&!o&&m.length>0&&w(m.length-1)},v=g=>{const h=g.clipboardData.getData("text");if(h.includes(",")){g.preventDefault();const j=h.split(",").map(E=>E.trim()).filter(Boolean).filter(E=>vu(E,a)),b=[...new Set([...m,...j])];n(b.join(",")),l(""),d(!1)}},S=a==="email"?"Type email and press Enter...":"Type domain and press Enter...";return s.jsxs("div",{className:`tag-input${c?" tag-input-invalid":""}`,onClick:()=>{var g;return(g=f.current)==null?void 0:g.focus()},children:[m.map((g,h)=>s.jsxs("span",{className:"tag-pill",children:[g,!r&&s.jsx("button",{type:"button",className:"tag-remove",onClick:y=>{y.stopPropagation(),w(h)},"aria-label":`Remove ${g}`,children:"×"})]},g)),!r&&s.jsx("input",{ref:f,id:e,className:"tag-input-field",type:"text",value:o,onChange:g=>{l(g.target.value),d(!1)},onKeyDown:x,onPaste:v,onBlur:()=>{o.trim()&&p(o)},placeholder:m.length===0?i??S:""})]})}function Ex({id:e,options:t,value:n,onChange:r,disabled:a}){const i=n?n.split(",").map(l=>l.trim()).filter(Boolean):[],o=l=>{const c=i.includes(l)?i.filter(d=>d!==l):[...i,l];r(c.join(","))};return s.jsx("div",{className:"checkbox-group",id:e,children:t.map(l=>s.jsxs("label",{className:`checkbox-pill${i.includes(l)?" checkbox-pill-selected":""}`,children:[s.jsx("input",{type:"checkbox",checked:i.includes(l),onChange:()=>o(l),disabled:a}),s.jsx("span",{children:l})]},l))})}function wu({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:a,readOnly:i,twoColumn:o,discoveryIntegrationId:l,onLabels:c}){const d=xx(e,t),f=`${a}-field-${e}`,m=s.jsx(s.Fragment,{children:jx(t)?s.jsx(Ex,{id:f,options:t.enum,value:n,onChange:p=>r(e,p),disabled:i}):(()=>{const p=t.boundType;return(p==null?void 0:p.kind)==="enum"&&Array.isArray(p.values)})()?s.jsxs("select",{id:f,className:"form-select",value:n,onChange:p=>r(e,p.target.value),disabled:i,children:[s.jsx("option",{value:"",children:"Select..."}),t.boundType.values.map(p=>s.jsx("option",{value:p,children:p},p))]}):"enum"in t&&t.enum?s.jsxs("select",{id:f,className:"form-select",value:n,onChange:p=>r(e,p.target.value),disabled:i,children:[s.jsx("option",{value:"",children:"Select..."}),t.enum.map(p=>s.jsx("option",{value:p,children:p},p))]}):t.type==="number"?s.jsx(Nx,{id:f,value:n,onChange:p=>r(e,p),disabled:i,unit:t.unit,min:Ql(t)}):wx(t)?s.jsx(Cx,{id:f,value:n,onChange:p=>r(e,p),disabled:i,format:t.format}):l?s.jsx(gx,{integrationId:l,field:e,value:n,onChange:p=>r(e,p),disabled:i,onLabels:p=>c==null?void 0:c(e,p)}):s.jsx("input",{id:f,className:"form-input",type:"text",value:n,onChange:p=>r(e,p.target.value),disabled:i})});return o?s.jsxs("div",{className:"bounds-field-row",children:[s.jsx("div",{className:"bounds-field-label",children:s.jsx(xu,{htmlFor:f,label:d,description:t.description})}),s.jsx("div",{className:"bounds-field-input",children:m})]},`${a}-${e}`):s.jsxs("div",{className:"form-group",children:[s.jsx(xu,{htmlFor:f,label:d,description:t.description}),m]},`${a}-${e}`)}function Tx(e,t){if(!t)return"no-config";const n=t.caps,r=Array.isArray(t.approvers)&&t.approvers.length>0;if(!(n&&Object.keys(n).length>0))return r?"approvers-dormant":"no-config";let i=!1;for(const[o,l]of Object.entries(n)){const c=e[o];if(c===""||c===void 0)continue;const d=Number(c);if(!isNaN(d)&&d>l){i=!0;break}}return i?r?"above-approvers":"hard-ceiling":"within-cap"}function Rx(e,t){const n=new Set;if(!t)return n;for(const[r,a]of Object.entries(t)){const i=e[r];if(i===""||i===void 0)continue;const o=Number(i);!isNaN(o)&&o>a&&n.add(r)}return n}function Px({profile:e,onConfirm:t,onCancel:n,readOnly:r,initialBounds:a,initialContext:i,initialFrame:o,profileConfig:l,approverNames:c,adminName:d}){const f=e.boundsSchema??e.frameSchema,m=e.contextSchema,p=f?Object.entries(f.fields).filter(([I,F])=>!(I==="profile"||I==="path"||F.enforced===!1||F.enforcedBy==="gatekeeper")):[],w=f?Object.entries(f.fields).filter(([,I])=>I.enforcedBy==="gatekeeper").filter(([,I])=>I.enforced!==!1).map(([I,F])=>F.displayName??I):[],x=m&&m.keyOrder.length>0?Object.entries(m.fields):[],v=a??o??{},S=i??{},g={};for(const[I,F]of p)g[I]=yx(F,v[I]);const h={};for(const[I]of x)h[I]=S[I]!==void 0?String(S[I]):"";const[y,j]=u.useState(g),[b,E]=u.useState(h),[C,P]=u.useState({}),[N,_]=u.useState(null);u.useEffect(()=>{const I=vx(e.id);R.getIntegrationManifests().then(({manifests:F})=>{const Y=F.find(q=>q.profile===I&&q.contextDiscovery&&Object.keys(q.contextDiscovery).length>0);_(Y??null)}).catch(()=>_(null))},[e.id]);const M=Tx(y,l),V=Rx(y,l==null?void 0:l.caps),J=(I,F)=>{j(Y=>({...Y,[I]:F}))},B=(I,F)=>{E(Y=>({...Y,[I]:F}))},z=()=>{const I={profile:e.id};for(const[Y,q]of p)q.type==="number"?I[Y]=yu(q,y[Y]):I[Y]=y[Y];const F={};for(const[Y,q]of x)q.type==="number"?F[Y]=b[Y]===""?0:Number(b[Y]):F[Y]=b[Y];return[I,F]},D=()=>{const[I,F]=z();t(I,F,C)},oe=()=>{const I=(l==null?void 0:l.caps)??{},F={...y};for(const ne of V)I[ne]!==void 0&&(F[ne]=String(I[ne]));j(F);const Y={profile:e.id};for(const[ne,ce]of p)ce.type==="number"?Y[ne]=yu(ce,F[ne]??""):Y[ne]=F[ne]??"";const q={};for(const[ne,ce]of x)ce.type==="number"?q[ne]=b[ne]===""?0:Number(b[ne]):q[ne]=b[ne];t(Y,q,C)},$=I=>{const F=l==null?void 0:l.caps;if(!F||F[I]===void 0)return null;const Y=F[I],q=V.has(I);return M==="hard-ceiling"&&q?s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Y," — exceeds team ceiling"]}):M==="above-approvers"&&q?s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Y," — above cap"]}):s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Y," ok"]})},A=()=>{var I;if(M==="no-config")return null;if(M==="approvers-dormant"){const F=c&&c.length>0?c.join(", "):"the configured approvers";return s.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:[s.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",F]}),s.jsxs("div",{children:["No caps are set on this profile, so ",F," 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(M==="within-cap")return s.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--border)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:s.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(M==="above-approvers"){const F=c&&c.length>0?c.join(", "):"the required approvers";return s.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--warning)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[s.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),s.jsxs("div",{children:[s.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",F,". Within-cap actions run per the mode you choose."]})]})}if(M==="hard-ceiling"){const F=Array.from(V)[0],Y=F?(I=l==null?void 0:l.caps)==null?void 0:I[F]:void 0,q=d??"the team admin";return s.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--danger)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[s.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),s.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",Y??"the configured limit",". Lower your bound or ask ",q," to add an approver path above the cap."]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:oe,children:"Save below cap"}),n&&s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},H=M==="hard-ceiling";return s.jsxs("div",{children:[x.length>0&&s.jsxs("div",{className:"context-section",children:[s.jsxs("div",{className:"bounds-section-header",children:[s.jsx("span",{className:"bounds-section-icon",children:"🛡"}),s.jsxs("div",{children:[s.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),s.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the Authority Server"})]})]}),x.map(([I,F])=>{var q;const Y=!!((q=N==null?void 0:N.contextDiscovery)!=null&&q[I]);return s.jsx(wu,{fieldKey:I,fieldDef:F,value:b[I],onChange:B,prefix:"context",readOnly:r,discoveryIntegrationId:Y?N.id:void 0,onLabels:(ne,ce)=>P(he=>({...he,[ne]:ce}))},`context-${I}`)})]}),p.length>0&&s.jsxs("div",{className:"bounds-section",children:[s.jsxs("div",{className:"bounds-section-header",children:[s.jsx("span",{className:"bounds-section-icon",children:"🔒"}),s.jsxs("div",{children:[s.jsx("div",{className:"bounds-section-title",children:"Limits"}),s.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Authority Server"})]})]}),s.jsx("div",{className:"bounds-fields-grid",children:p.map(([I,F])=>{var Y;return s.jsxs("div",{style:{display:"contents"},children:[s.jsx(wu,{fieldKey:I,fieldDef:F,value:y[I],onChange:J,prefix:"bounds",readOnly:r,twoColumn:!0}),M!=="no-config"&&((Y=l==null?void 0:l.caps)==null?void 0:Y[I])!==void 0&&s.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:$(I)})]},`bounds-${I}`)})}),A(),w.length>0&&s.jsxs("div",{className:"bounds-local-note",style:{marginTop:"0.75rem",fontSize:"0.78rem",color:"var(--text-muted)"},children:[w.join(", ")," ",w.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"," ",s.jsx(qe,{to:"/integrations",children:"Integrations"}),"."]})]}),s.jsx("button",{className:"btn btn-primary",onClick:D,disabled:H,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function Ix(e){var n;const t=e.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((n=t==null?void 0:t[1])==null?void 0:n.trim())??null}function Ax(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const _x="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 za({target:e,currentText:t,onApply:n,greeting:r,placeholder:a,title:i}){const[o,l]=u.useState([{role:"assistant",content:r??_x}]),[c,d]=u.useState(""),[f,m]=u.useState(!1),[p,w]=u.useState(null),x=u.useRef(null),v=u.useRef(null);u.useEffect(()=>{const h=x.current;if(!h)return;const y=o[o.length-1],j=v.current;!f&&(y==null?void 0:y.role)==="assistant"&&o.length>1&&j?h.scrollTop=j.offsetTop:h.scrollTop=h.scrollHeight},[o,f]);const S=async()=>{const h=c.trim();if(!h||f)return;const y=[...o,{role:"user",content:h}];l(y),d(""),w(null),m(!0);try{const j=await R.aiChat({target:e,currentText:t,messages:y.filter((b,E)=>!(E===0&&b.role==="assistant"))});j.success&&j.reply?l(b=>[...b,{role:"assistant",content:j.reply}]):w(j.error??"AI returned no reply")}catch(j){w(j instanceof Error?j.message:"Chat failed")}finally{m(!1)}},g=h=>{h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),S())};return s.jsxs("div",{className:"intent-chat",children:[s.jsx("h3",{className:"card-title",children:i??"AI Assistant"}),s.jsxs("div",{ref:x,className:"chat-messages",children:[o.map((h,y)=>{const j=h.role==="assistant"?Ix(h.content):null,b=j?Ax(h.content):h.content;return s.jsx("div",{className:`chat-msg ${h.role}`,ref:y===o.length-1?v:void 0,children:s.jsxs("div",{className:"chat-msg-body",children:[b&&s.jsx("div",{className:"chat-msg-prose",children:b}),j!==null&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"chat-fenced-block",children:j}),s.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(j),children:"Apply this draft"})]})]})},y)}),f&&s.jsx("div",{className:"chat-msg assistant",children:s.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),p&&s.jsx("div",{className:"error-message",children:p}),s.jsxs("div",{className:"chat-composer",children:[s.jsxs("div",{className:"chat-composer-pill",children:[s.jsx("textarea",{className:"chat-input",value:c,onChange:h=>d(h.target.value),onKeyDown:g,placeholder:a??"Ask for help articulating the intent…",rows:1,disabled:f}),s.jsx("button",{type:"button",className:"chat-send-btn",onClick:S,disabled:f||!c.trim(),"aria-label":"Send",children:"↑"})]}),s.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Am({open:e,onClose:t,children:n,ariaLabel:r}){const a=u.useRef(null),i=u.useRef(null);return u.useEffect(()=>{var l;if(!e)return;i.current=document.activeElement,document.body.style.overflow="hidden";const o=c=>{c.key==="Escape"&&t()};return document.addEventListener("keydown",o),(l=a.current)==null||l.focus(),()=>{document.removeEventListener("keydown",o),document.body.style.overflow="",i.current instanceof HTMLElement&&i.current.focus()}},[e,t]),Yf.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:t,"aria-hidden":"true"}),s.jsxs("aside",{ref:a,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":r,tabIndex:-1,children:[s.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),s.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:t,"aria-label":"Close",children:"×"}),n]})]}),document.body)}function zx(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $x(e,t,n){if(t.length===0)return[{text:e,label:e,matched:null}];const r=[],a=new Set;for(const c of t)if(!(!c.scope||c.scope==="all (unscoped)"))for(const d of[c.scope,...c.scope.split(",").map(f=>f.trim())]){const f=d.toLowerCase();d&&!a.has(f)&&(a.add(f),r.push(d))}r.sort((c,d)=>d.length-c.length);const i=c=>{const d=c.toLowerCase();return t.filter(f=>{var m,p;return((m=f.scope)==null?void 0:m.toLowerCase())===d||((p=f.scope)==null?void 0:p.split(",").map(w=>w.trim().toLowerCase()).includes(d))})},o=["\\[\\d+\\]",...r.map(zx)],l=new RegExp(`(${o.join("|")})`,"gi");return e.split(l).filter(c=>c!=="").map(c=>{const d=/^\[(\d+)\]$/.exec(c);if(d){const f=t[Number(d[1])-1];if(f){const m=f.scope&&f.scope!=="all (unscoped)"?f.scope:"all recipients",p=n?`${n}: ${m}`:m;return{text:c,label:p,matched:[f]}}}else if(r.some(f=>f.toLowerCase()===c.toLowerCase())){const f=i(c);if(f.length>0)return{text:c,label:c,matched:f}}return{text:c,label:c,matched:null}})}const ju=`Why — What's the situation? Why does this need to happen?
61
-
62
- Goal — What should the agent try to achieve?
63
-
64
- Watch out — What should the agent avoid or be careful about?`;function Lx(e,t,n,r){return $x(e,t,r).map((a,i)=>{if(!a.matched)return s.jsx("span",{children:a.text},i);const o=a.matched;return s.jsx("button",{type:"button",onClick:()=>n(o),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:a.label},i)})}function Mx(){var ae;const e=en(),[t]=Wl(),n=Number(t.get("step"))||2,[r,a]=u.useState(null),[i,o]=u.useState(null),[l,c]=u.useState(n),[d,f]=u.useState(null),[m,p]=u.useState(null),[w,x]=u.useState({}),[v,S]=u.useState(ju),[g,h]=u.useState(!1),[y,j]=u.useState(!0),[b,E]=u.useState(null),[C,P]=u.useState([]),[N,_]=u.useState(void 0),[M,V]=u.useState(!1),[J,B]=u.useState(null),[z,D]=u.useState(null),[oe,$]=u.useState(null),[A,H]=u.useState([]),[I,F]=u.useState(null);u.useEffect(()=>{var Z;const K=sessionStorage.getItem("agentAuth");if(!K){e("/mandates?new=1");return}const fe=JSON.parse(K);a(fe);const W=sessionStorage.getItem("agentGate");if(W){const se=JSON.parse(W);se.bounds&&f(se.bounds),se.context&&p(se.context),(Z=se.gateContent)!=null&&Z.intent&&S(se.gateContent.intent)}R.getProfile(fe.profileId).then(se=>o(se)).catch(()=>e("/mandates?new=1")).finally(()=>j(!1)),fe.groupId&&Promise.all([R.getTeamProfileConfig(fe.groupId,fe.profileId).catch(()=>null),R.getGroupById(fe.groupId).catch(()=>null),R.listUsers().catch(()=>[])]).then(([se,Te,Ve])=>{if(E(se),se){const Ie=new Map;for(const de of Ve){const ct=de.name&&de.email?`${de.name} (${de.email})`:de.name||de.email||de.id;Ie.set(de.id,ct)}const lt=(Te==null?void 0:Te.members)??[];for(const de of lt){const ct=de.userId??de.id;ct&&(de.name&&de.email?Ie.set(ct,`${de.name} (${de.email})`):de.name&&Ie.set(ct,de.name))}const nt=(se.approvers??[]).map(de=>Ie.get(de)??de);P(nt);const De=lt.find(de=>de.role==="admin");if(De){const de=De.userId??De.id;de&&_(Ie.get(de)??De.name)}}})},[e]);const Y=d?Object.entries(d).filter(([K])=>K!=="profile"&&K!=="path").map(([K,fe])=>`${K} = ${fe}`).join(", "):"",q=(K,fe,W)=>{f(K),p(fe),W&&x(W),c(3)},ne=v.trim()!==ju.trim()&&v.trim()!=="",ce=K=>{ne&&!confirm("Replace your current intent with the AI draft?")||S(K)},he=()=>{const K=i==null?void 0:i.ttl,fe={intent:v},W=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...W,bounds:d,context:m,contextLabels:w,gateContent:fe,ttlConfig:K})),e("/mandates/new/sign")},te=async()=>{if(r){V(!0),B(null),D(null),$(null),H([]),F(null);try{const K=await R.aiIntentReview({profileId:r.profileId,newIntent:v,context:m??void 0});H(K.grants??[]),K.success?K.review?B(K.review):D(K.note??"No other mandates on this profile to compare against."):$(K.error??"Check failed.")}catch(K){$(K instanceof Error?K.message:"Check failed.")}finally{V(!1)}}},ue=K=>{S(K),(J||z||oe)&&(B(null),D(null),$(null),H([]),F(null))};return y||!r||!i?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):s.jsxs(s.Fragment,{children:[s.jsx(Pm,{currentStep:l,onStepClick:K=>{K>=2&&c(K)}}),s.jsx(hx,{profileId:r.profileId,bounds:Y||void 0,groupName:r.groupName,domain:r.domain}),l===2&&s.jsx("div",{className:"card",children:s.jsx(Px,{profile:i,onConfirm:q,onCancel:()=>e("/mandates?new=1"),initialBounds:d||void 0,initialContext:m||void 0,profileConfig:b,approverNames:C,adminName:N})}),l===3&&s.jsxs("div",{className:"intent-layout",children:[s.jsx("div",{className:"card intent-pane chat tool",children:s.jsx(za,{target:{kind:"intent",profileId:r.profileId,bounds:Y||void 0},currentText:v,onApply:ce})}),s.jsxs("div",{className:"card intent-pane document",children:[s.jsx("h3",{className:"card-title",children:"What should your agent know?"}),s.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[s.jsxs("div",{className:"field-label",children:[s.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),s.jsx("textarea",{className:"intent-textarea",value:v,onChange:K=>ue(K.target.value)}),s.jsxs("div",{className:"char-counter",children:[v.length," / 2000"]})]}),s.jsxs("div",{style:{marginTop:"0.5rem"},children:[s.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:te,disabled:M||!ne,children:M?"Checking…":"Check against my other grants"}),oe&&s.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeftColor:"var(--danger)"},children:[s.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),s.jsx("div",{className:"hint-body",children:oe})]}),z&&s.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[s.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),s.jsx("div",{className:"hint-body",children:z})]}),J&&s.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[s.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),s.jsxs("div",{className:"hint-body",children:[s.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),s.jsx("div",{style:{whiteSpace:"pre-wrap"},children:Lx(J,A,F,Pe(r.profileId))}),s.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),s.jsxs("div",{className:"intent-footer",children:[s.jsx("button",{className:"btn btn-ghost",onClick:()=>c(2),children:"Back"}),s.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:he,disabled:!ne,children:"Continue to Review"})]}),(((ae=b==null?void 0:b.approvers)==null?void 0:ae.length)??0)>0&&s.jsxs("div",{className:"hint-box",role:"note",children:[s.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),s.jsxs("div",{className:"hint-body",children:[s.jsxs("div",{className:"hint-head",children:["Visible to ",C.length>0?C.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",C.length>0?C.join(", "):"this profile's required approvers",". Only they can decrypt it — your Authority Server cannot. Each approver stores a copy as their accountability record."]})]})]}),s.jsx("button",{type:"button",className:"floating-help",onClick:()=>h(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),s.jsx(Am,{open:g,onClose:()=>h(!1),ariaLabel:"Intent assistant",children:s.jsx(za,{target:{kind:"intent",profileId:r.profileId,bounds:Y||void 0},currentText:v,onApply:K=>{ce(K),h(!1)}})}),I&&s.jsx("div",{className:"modal-backdrop",onClick:K=>K.target===K.currentTarget&&F(null),children:s.jsxs("div",{className:"modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:I.length>1?`Existing mandates (${I.length})`:"Existing mandate"}),s.jsx("button",{className:"modal-close",onClick:()=>F(null),children:"×"})]}),s.jsx("div",{className:"modal-body",children:I.map((K,fe)=>{var W;return s.jsxs("div",{style:{marginBottom:fe<I.length-1?"1rem":0,paddingBottom:fe<I.length-1?"1rem":0,borderBottom:fe<I.length-1?"1px solid var(--border)":"none"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),s.jsx("div",{style:{marginBottom:"0.75rem"},children:K.scope}),s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),s.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((W=K.intent)==null?void 0:W.trim())||"(no intent recorded)"}),Object.entries(K.bounds).filter(([Z])=>Z!=="profile"&&Z!=="path").length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),s.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(K.bounds).filter(([Z])=>Z!=="profile"&&Z!=="path").map(([Z,se])=>`${Z}: ${se}`).join(" · ")})]})]},fe)})})]})})]})]})}function Fx(e){return e.normalize("NFC").replace(/\r\n?/g,`
65
- `).split(`
66
- `).map(a=>a.replace(/[ \t]+$/,"")).join(`
67
- `).replace(/\n+$/,"")}async function _m(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(i=>i.toString(16).padStart(2,"0")).join("")}class Ox extends Error{constructor(n,r,a){super(a);kr(this,"code");kr(this,"field");this.name="CanonicalValueError",this.code=n,this.field=r}}function Bx(e){const t=new TextEncoder().encode(e);let n="";for(const r of t)r===61||r===37||r<32||r>126?n+="%"+r.toString(16).toUpperCase().padStart(2,"0"):n+=String.fromCharCode(r);return n}function zm(e,t,n){const r=[];for(const a of t){const i=e[a];if(i==null)continue;const o=String(i);if(o.includes(`
68
- `)||o.includes("\r"))throw new Ox(n,a,`Value for "${a}" contains a raw newline or carriage return. Refusing: a hash over stripped or normalized input would not represent what was authorized.`);r.push(`${a}=${Bx(o)}`)}return r.join(`
69
- `)}async function oa(e,t){const n=t.boundsSchema??t.frameSchema;if(!n)throw new Error("Profile has no boundsSchema or frameSchema");const r=zm(e,n.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await _m(r)}`}async function $m(e,t){const n=t.contextSchema?zm(e,t.contextSchema.keyOrder,"CONTEXT_INVALID_VALUE"):"";return`sha256:${await _m(n)}`}async function $a(e){const t=new TextEncoder().encode(Fx(e)),n=await crypto.subtle.digest("SHA-256",t);return`sha256:${Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}`}function Lm(e,t){if(!e.authorization_id)throw new Error("Attest 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??t.boundsHash,contextHash:t.contextHash,context:t.context,...t.contextLabels&&Object.keys(t.contextLabels).length>0?{contextLabels:t.contextLabels}:{},gateContent:t.gateContent,...t.path?{path:t.path}:{}}}function Dx(e){const t=e.commitment_modes;return t===void 0?["review","automatic"]:Array.isArray(t)?["review","automatic"].filter(n=>t.includes(n)):[]}function Ux(e){return e==="per-action"?"review":"automatic"}function Su(e){return e?Dx(e).map(t=>t==="review"?"per-action":"immediate"):["per-action","immediate"]}function Wx(e,t){return t.includes(e)?e:t[0]??null}function ku(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function Hx(e,t){for(const n of e)if(t.has(n))return!0;return!1}function Vx(e,t,n){for(const r of e){const a=ku(t[r]),i=ku(n[r]);if(!(a.size===0||i.size===0)&&!Hx(a,i))return!1}return!0}function Gx(e){return e.length>24?`${e.slice(0,10)}…`:e}function Mm(e,t,n){const r=n==null?void 0:n[e];return String(t).split(",").map(i=>i.trim()).filter(Boolean).map(i=>{const o=r==null?void 0:r[i];return o?`${o} (${Gx(i)})`:i}).join(", ")}function Fm(e){var n;if(e.isPersonal)return{can:!0};if(!e.configLoaded)return{can:!0};const t=e.teamName?`"${e.teamName}"`:"this team";return(((n=e.approvers)==null?void 0:n.length)??0)===0?{can:!1,code:"PROFILE_NOT_ENABLED_FOR_GROUP",reason:`Not enabled in ${t}.`,fix:`A team admin names who may give ${e.profileName} mandates.`}:!e.userId||!e.approvers.includes(e.userId)?{can:!1,code:"OWNER_NOT_APPROVER",reason:`Only ${e.profileName}'s approvers in ${t} can give this — you are not one of them.`,fix:"Ask one of them, or a team admin to add you."}:{can:!0}}function Kx(){var k,O;const e=en(),{user:t,mode:n,domain:r}=Be(),[a,i]=u.useState(null),[o,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState("per-action"),[p,w]=u.useState(1800),[x,v]=u.useState(86400),[S,g]=u.useState(""),[h,y]=u.useState("hours"),[j,b]=u.useState(""),[E,C]=u.useState(!0),[P,N]=u.useState(!1),[_,M]=u.useState(""),[V,J]=u.useState(null),[B,z]=u.useState([]),[D,oe]=u.useState(!1),[$,A]=u.useState([]),[H,I]=u.useState(0);u.useEffect(()=>{var nn;const T=sessionStorage.getItem("agentAuth"),G=sessionStorage.getItem("agentGate");if(!T||!G){e("/mandates?new=1");return}const re=JSON.parse(T),ve=JSON.parse(G),Je={bounds:ve.bounds??{},context:ve.context??{},contextLabels:ve.contextLabels??void 0,gateContent:ve.gateContent};i(re),l(Je),ve.ttlConfig&&(w(ve.ttlConfig.default??1800),v(ve.ttlConfig.max??86400)),ve.templateMode==="automatic"?m("immediate"):ve.templateMode==="review"&&m("per-action");const bn=((nn=ve.ttlConfig)==null?void 0:nn.max)??86400;if(typeof ve.templateTtl=="number"&&ve.templateTtl>0){const ze=Math.min(ve.templateTtl,bn);w(ze),[3600,86400,604800,2592e3,31536e3].includes(ze)||(ze%86400===0?(g(String(ze/86400)),y("days")):(g(String(Math.max(1,Math.round(ze/3600)))),y("hours")))}R.getProfile(re.profileId).then(ze=>{var vt;if(d(ze),!j){const U=ze.name??((vt=re.profileId.split("/").pop())==null?void 0:vt.replace(/@.*$/,""))??"",X=[];if(Je.context&&ze.contextSchema)for(const me of ze.contextSchema.keyOrder){const ee=Je.context[me];if(ee!==void 0&&ee!==""){const Ae=String(ee).split(",").map(Ct=>Ct.trim()).filter(Boolean);X.push(Ae.join(", "))}}const ie=X.length>0?`${U}: ${X.join(" · ")}`:U;b(ie)}}).catch(()=>{}),re.isPersonal?oe(!0):Promise.all([R.getTeamProfileConfig(re.groupId,re.profileId).catch(()=>null),R.getGroupById(re.groupId).catch(()=>null),R.listUsers().catch(()=>[])]).then(([ze,vt,U])=>{if(J(ze),ze){const X=new Map;for(const ee of U){const Ae=ee.name&&ee.email?`${ee.name} (${ee.email})`:ee.name||ee.email||ee.id;X.set(ee.id,Ae)}const ie=(vt==null?void 0:vt.members)??[];for(const ee of ie){const Ae=ee.userId??ee.id;Ae&&(ee.name&&ee.email?X.set(Ae,`${ee.name} (${ee.email})`):ee.name&&X.set(Ae,ee.name))}const me=(ze.approvers??[]).map(ee=>X.get(ee)??ee);z(me)}}).finally(()=>{oe(!0)})},[e]),u.useEffect(()=>{if(!(a!=null&&a.profileId))return;const T=a.profileId,G=sessionStorage.getItem("agentEditReplaces");R.getEnrichedAuthorizations().then(re=>{const ve=re.filter(Je=>Je.profileId===T&&Je.authorizationId!==G).map(Je=>({authorizationId:Je.authorizationId,bounds:Je.bounds,context:Je.context??{},intent:Je.intent}));A(ve)}).catch(()=>A([]))},[a==null?void 0:a.profileId]),u.useEffect(()=>{if(!c)return;const T=Wx(f,Su(c));T&&T!==f&&m(T)},[c,f]),u.useEffect(()=>{if(!o||!c||$.length===0){I(0);return}let T=!1;return(async()=>{const G=await oa(o.bounds,c),re=await Promise.all($.map(ve=>oa(ve.bounds,c).catch(()=>null)));T||I(re.filter(ve=>ve===G).length)})().catch(()=>{T||I(0)}),()=>{T=!0}},[o,c,$]);const F=async()=>{if(!(!a||!o||!c||!t)){if(!a.groupId){M("No active group; cannot create mandate.");return}N(!0),M("");try{const T=r||a.domain||"owner",G=await oa(o.bounds,c),re=await $m(o.context,c),[ve,Je]=await Promise.all([$a(o.gateContent.intent),$a(JSON.stringify({profile:a.profileId,domain:T,group:a.groupId}))]);let bn,nn,ze,vt;if(a.isTeam){const me=await R.getApproversPubkeys(a.groupId,a.profileId);if(me.length>0){const ee=await R.encryptIntent(o.gateContent.intent,me);bn=ee.intentCiphertext,nn=ee.encryptedKeys,ze=ee.approversFrozen,vt=ee.intentDisclosureHash}}const U=`authz_${crypto.randomUUID()}`,X=sessionStorage.getItem("agentEditReplaces")||void 0,ie=await R.attest({authorization_id:U,replaces:X,profile_id:a.profileId,bounds:o.bounds,bounds_hash:G,context_hash:re,domain:T,did:t.did,gate_content_hashes:{intent:ve},execution_context_hash:Je,group_id:a.groupId,ttl:p,commitment_mode:Ux(f),title:j.trim(),intent_ciphertext:bn,encrypted_keys:nn,approvers_frozen:ze,intent_disclosure_hash:vt,disclose_identity:E});try{await R.pushGateContent(Lm(ie,{boundsHash:G,contextHash:re,context:o.context,contextLabels:o.contextLabels,gateContent:o.gateContent}))}catch(me){try{await R.revokeAttestation(U,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${me instanceof Error?me.message:"Unknown error"})`)}if(X)try{await R.revokeAttestation(X,`Replaced by ${U} (edit)`),R.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/mandates?highlight=${encodeURIComponent(U)}`)}catch(T){M(T instanceof Error?T.message:"Signing the mandate failed")}finally{N(!1)}}};if(!a||!o)return s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const Y=Object.entries(o.bounds).filter(([T])=>T!=="profile"&&T!=="path"),q=Object.entries(o.context),ce=((V==null?void 0:V.caps)!=null?Object.keys(V.caps):[]).length!==0,he=B.length>0?B.join(", "):((V==null?void 0:V.approvers)??[]).join(", "),te=ce?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${he}, 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.",ue=ce?`Over-cap actions will be reviewed by you and ${he}. Within-cap actions run per the mode you chose above.`:`Approvers ${he} can read your intent but won't gate any action — no caps configured on this profile.`,ae=!!((k=V==null?void 0:V.approvers)!=null&&k.length),K=Fm({isPersonal:a.isPersonal,configLoaded:D,approvers:V==null?void 0:V.approvers,userId:t==null?void 0:t.id,profileName:Pe(a.profileId),teamName:a.groupName}),fe=!K.can,W=Su(c),Z=W.length===0,se=p>x,Te={flex:1,padding:"0.75rem",border:f==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:f==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Ve={flex:1,padding:"0.75rem",border:f==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:f==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Ie=((O=c==null?void 0:c.contextSchema)==null?void 0:O.keyOrder)??[],lt=$.filter(T=>Vx(Ie,o.context,T.context)),nt=lt.length>0,De=Pe(a.profileId),de=T=>{const G=Object.values(T).map(re=>String(re).trim()).filter(Boolean);return G.length>0?G.join(", "):"all (unscoped)"},ct=lt.map(T=>de(T.context)).join("; "),tn=`This grant's scope overlaps an existing grant on ${De} (scoped to: ${ct}). 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 s.jsxs(s.Fragment,{children:[s.jsx(Pm,{currentStep:4,onStepClick:T=>{T<=3&&e(`/mandates/new/intent?step=${T}`)}}),s.jsxs("div",{className:"card",children:[s.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),s.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your mandate details before signing."}),_&&s.jsx("div",{className:"error-message",children:_}),s.jsxs("div",{className:"field-editable",children:[s.jsxs("div",{className:"field-label",children:[s.jsx("span",{className:"pen",children:"✎"})," Title"]}),s.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Pe(a.profileId)}: daily operations`,value:j,onChange:T=>b(T.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),s.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this mandate on your dashboard."})]}),s.jsxs("div",{className:"field-editable",children:[s.jsxs("div",{className:"field-label",children:[s.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),s.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[W.includes("per-action")&&s.jsxs("button",{onClick:()=>m("per-action"),style:Ve,children:[s.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),W.includes("immediate")&&s.jsxs("button",{onClick:()=>m("immediate"),style:Te,children:[s.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]}),W.length===1&&s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:W[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),Z&&s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--danger)",marginTop:"0.25rem"},children:"This profile allows no commitment mode, so no mandate can be signed under it. Its publisher must fix the profile."})]}),s.jsxs("div",{className:"field-editable",children:[s.jsxs("div",{className:"field-label",children:[s.jsx("span",{className:"pen",children:"✎"})," Duration"]}),s.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(T=>T.seconds<=x).map(T=>s.jsx("button",{onClick:()=>{w(T.seconds),g("")},style:{padding:"0.5rem 0.85rem",border:p===T.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:p===T.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:T.label},T.seconds)),s.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[s.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:S,onChange:T=>{g(T.target.value);const G=parseInt(T.target.value,10);if(G>0){const re=h==="days"?G*86400:G*3600;w(Math.min(re,x))}}}),s.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:h,onChange:T=>{y(T.target.value);const G=parseInt(S,10);if(G>0){const re=T.target.value==="days"?G*86400:G*3600;w(Math.min(re,x))}},children:[s.jsx("option",{value:"hours",children:"hours"}),s.jsx("option",{value:"days",children:"days"})]})]}),se&&s.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",x>=86400?`${Math.floor(x/86400)} days`:`${Math.floor(x/3600)} hours`]})]})]}),s.jsx("div",{className:"field-editable",children:s.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[s.jsx("input",{type:"checkbox",checked:E,onChange:T=>C(T.target.checked),style:{marginTop:"0.15rem"}}),s.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this mandate",s.jsx("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.'})]})]})}),s.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),s.jsxs("div",{className:"info-block",children:[s.jsxs("div",{className:"info-head",children:[s.jsx("span",{className:"info-title",children:"Intent"}),s.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=3"),children:"edit in step 3"})]}),s.jsx("div",{style:{whiteSpace:"pre-wrap"},children:o.gateContent.intent})]}),(!!Y.length||!!q.length)&&s.jsxs("div",{className:"info-block",children:[s.jsxs("div",{className:"info-head",children:[s.jsx("span",{className:"info-title",children:"Scope & Limits"}),s.jsx("button",{className:"info-edit",onClick:()=>e("/mandates/new/intent?step=2"),children:"edit in step 2"})]}),s.jsxs("dl",{className:"info-kv",children:[q.map(([T,G])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:T}),s.jsx("dd",{children:Mm(T,G,o.contextLabels)})]},T)),Y.map(([T,G])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:T}),s.jsx("dd",{children:String(G)})]},T))]})]}),s.jsxs("div",{className:"info-block",children:[s.jsx("div",{className:"info-head",children:s.jsx("span",{className:"info-title",children:"Authority"})}),s.jsxs("dl",{className:"info-kv",children:[s.jsx("dt",{children:"Profile"}),s.jsxs("dd",{children:[Pe(a.profileId),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:a.profileId})]}),!a.isPersonal&&a.groupName&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Team"}),s.jsx("dd",{children:a.groupName})]}),!a.isPersonal&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Approvers"}),s.jsx("dd",{children:D?K.can?s.jsxs(s.Fragment,{children:[he,s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:te})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{color:"var(--danger)",fontWeight:600},children:K.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${a.groupName??"this team"}`:"You cannot give this mandate"}),K.code==="OWNER_NOT_APPROVER"&&s.jsx("div",{children:he}),s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[K.reason," ",K.fix]})]}):s.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),H>0?s.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[s.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),s.jsxs("div",{children:[H===1?`An active grant on ${De} already has exactly these limits.`:`${H} active grants on ${De} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",s.jsx("strong",{children:"Extend"})," on the Mandates page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,nt?s.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[s.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),s.jsx("div",{children:tn})]})]}):null,s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/mandates/new/intent"),children:"Back"}),s.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:F,disabled:P||!j.trim()||fe||Z,children:P?"Signing...":f==="immediate"?"Sign mandate":"Sign mandate (asks first)"})]}),s.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:ae?"block":"none"},children:ue})]})]})}const Yx={card:"💳",mail:"✉️"};function Om(e){return Yx[e]??"🔧"}function Qx(e){const t=e==null?void 0:e.overrides;return!t||typeof t!="object"?!1:Object.values(t).some(n=>{var r;return typeof((r=n==null?void 0:n.read)==null?void 0:r.ageField)=="string"})}const Jx=[0,7,30,90,365,3650];function Hs(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 Xx(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 Mi({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:a}){var tn;const[i,o]=u.useState({}),[l,c]=u.useState(!1),[d,f]=u.useState(!1),[m,p]=u.useState({}),[w,x]=u.useState({}),[v,S]=u.useState(void 0),[g,h]=u.useState(!1),[y,j]=u.useState(null),[b,E]=u.useState(!1),[C,P]=u.useState(!1),[N,_]=u.useState(!1),[M,V]=u.useState(!1),[J,B]=u.useState({}),[z,D]=u.useState(null),[oe,$]=u.useState(!1),[A,H]=u.useState(null),[I,F]=u.useState(!1);u.useEffect(()=>{let k=!1;return R.getCredential(e.id).then(O=>{var T;if(!(k||!O.configured)){if(c(!0),f(!0),O.fields){const G={};for(const re of e.credentials.fields)O.fields[re.key]!=null&&(G[re.key]=O.fields[re.key]);p(G)}if(x(O.secrets??{}),S(O.updatedAt),e.oauth){const G=((T=O.fieldNames)==null?void 0:T.includes(e.oauth.tokenStorage))??!1;h(G),G&&R.getOAuthHealth(e.id).then(re=>{k||j(re)})}}}).catch(()=>{}),()=>{k=!0}},[e.id,e.oauth]);const Y=Qx(e.toolGating),q=t?t.readAgeDays??null:void 0,ne=oe&&z?z.value:q,ce=async k=>{D({value:k}),$(!0),H(null);try{await R.setReadPolicy(e.id,k),a(k===null?`${e.name} read window now follows your mandate`:`${e.name} read window set to ${Hs(k).toLowerCase()}`),r()}catch(O){H(O instanceof Error?O.message:"Could not save")}finally{$(!1),D(null)}},he=!!e.oauth||e.credentials.fields.some(k=>!k.optional),te=e.oauth?g:l,ue=!he||te,ae=n==="starting"?"starting":ue?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!g?"needs-oauth":"unconfigured",K=async()=>{if(e.credentials.fields.some(O=>{var T;return(T=i[O.key])==null?void 0:T.trim()})){E(!0);try{await R.setCredential(e.id,i),c(!0),o({}),e.oauth?a(`${e.name} credentials saved!`):(a(`${e.name} credentials saved — starting integration...`),await Te())}catch{a(`Failed to save ${e.name} credentials`)}finally{E(!1)}}},fe=()=>{const k={};for(const O of e.credentials.fields){const T=i[O.key];O.type==="password"?T!=null&&T.trim()&&(k[O.key]=T):T!=null&&T!==(m[O.key]??"")&&(k[O.key]=T)}return k},W=Object.keys(fe()).length>0,Z=async()=>{const k=fe();if(Object.keys(k).length!==0){E(!0);try{await R.setCredential(e.id,k),o({}),c(!0),e.oauth?a(`${e.name} credentials saved — now click Connect.`):(V(!1),a(`${e.name} credentials updated — restarting...`),await Te())}catch{a(`Failed to update ${e.name} credentials`)}finally{E(!1)}}},se=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const k=setInterval(async()=>{var O;try{const T=await R.getCredential(e.id);T.configured&&e.oauth&&((O=T.fieldNames)!=null&&O.includes(e.oauth.tokenStorage))&&(h(!0),V(!1),j(null),clearInterval(k),a(`${e.name} connected — starting integration...`),R.getOAuthHealth(e.id).then(j).catch(()=>{}),await Te())}catch{}},2e3);setTimeout(()=>clearInterval(k),12e4)},Te=async()=>{_(!0);try{const k=await R.activateIntegration(e.id);k.warning?a(k.warning):a(`${e.name} integration started with ${k.tools.length} tools`),r()}catch(k){a(`Failed to start ${e.name}: ${k instanceof Error?k.message:"Unknown error"}`)}finally{_(!1)}},Ve=async()=>{try{await R.removeMcpIntegration(e.id),a(`${e.name} integration removed`),r()}catch{a(`Failed to remove ${e.name}`)}},Ie=Om(e.icon),lt=Xx(t),nt=ae==="running"?{c:"int-chip-ok",t:"Running"}:ae==="starting"?{c:"int-chip-idle",t:"Starting"}:lt.chip,De=e.oauth&&g&&(y==null?void 0:y.status)==="failed",de=he?De?{c:"int-chip-bad",t:"Auth failed"}:te?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},ct=k=>k.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return s.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[s.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:Ie}),s.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:e.name}),s.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[ae!=="unconfigured"&&ae!=="needs-oauth"&&s.jsxs("span",{className:`int-chip ${nt.c}`,children:[s.jsx("span",{className:"int-dot"}),nt.t]}),s.jsxs("span",{className:`int-chip ${de.c}`,children:[s.jsx("span",{className:"int-dot"}),de.t]}),lx(e,m)&&s.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:[s.jsx("span",{className:"int-dot"}),"Simulation"]})]})]}),e.oauth&&g&&s.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:y!=null&&y.account?s.jsxs(s.Fragment,{children:["Connected as ",s.jsx("b",{children:y.account})]}):s.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),De&&!M&&s.jsxs("div",{style:{marginTop:"0.7rem",border:"1px solid var(--danger)",borderRadius:"10px",padding:"0.8rem 0.95rem",background:"color-mix(in srgb, var(--danger) 5%, var(--bg-elevated))"},children:[s.jsxs("div",{style:{fontSize:"0.86rem",fontWeight:700},children:[e.name," stopped accepting the stored credentials"]}),s.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0.3rem 0 0",lineHeight:1.55},children:[(y==null?void 0:y.error)==="invalid_grant"?s.jsxs(s.Fragment,{children:["The refresh token was revoked (",s.jsx("code",{children:"invalid_grant"}),") — this usually follows a password change or a security checkup on the provider's side."]}):y!=null&&y.error?s.jsxs(s.Fragment,{children:["The provider reported ",s.jsx("code",{children:y.error}),"."]}):s.jsx(s.Fragment,{children:"The provider rejected the stored authentication."})," ","Your agent's ",e.name," actions are ",s.jsx("b",{children:"blocked"}),", not failing silently."]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.6rem"},children:[s.jsxs("button",{className:"btn btn-primary btn-sm",onClick:se,children:["Reconnect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{o({...m}),V(!0)},children:"Edit credentials"})]})]}),s.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[s.jsx("summary",{children:"Details"}),s.jsxs("div",{className:"int-meta",children:[s.jsx("span",{className:"int-k",children:"What"}),s.jsx("span",{children:e.description}),e.profile&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"int-k",children:"Profile"}),s.jsx("span",{children:e.profile})]}),e.oauth&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"int-k",children:"Scopes"}),s.jsx("span",{children:((tn=e.oauth.scopes)==null?void 0:tn.join(", "))||"—"})]}),t&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"int-k",children:"Tools"}),s.jsxs("span",{children:[t.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(ae!=="running"||De)&&s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsxs("button",{onClick:()=>P(!C),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[s.jsx("span",{style:{transition:"transform 0.2s",transform:C?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),C&&s.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((k,O)=>s.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[s.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:O+1}),s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:k.title}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[ct(k.description),k.link&&s.jsxs(s.Fragment,{children:[" ",s.jsxs("a",{href:k.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},O))})]}),ae==="starting"&&s.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[s.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),M&&s.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[s.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),d&&s.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(k=>{var O;return s.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[s.jsx("label",{className:"form-label",children:k.label}),k.type==="password"?s.jsxs("div",{className:"cred-field",children:[s.jsx("input",{className:"form-input",type:J[k.key]?"text":"password",name:`${e.id}-${k.key}-credential`,autoComplete:"new-password",placeholder:(O=w[k.key])!=null&&O.preview?`Unchanged — ends in ${w[k.key].preview}`:d?"Unchanged — paste a new value to replace":k.placeholder,value:i[k.key]||"",onChange:T=>o(G=>({...G,[k.key]:T.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>B(T=>({...T,[k.key]:!T[k.key]})),children:J[k.key]?"hide":"show"})]}):s.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${k.key}-credential`,autoComplete:"off",placeholder:k.placeholder,value:i[k.key]||"",onChange:T=>o(G=>({...G,[k.key]:T.target.value}))})]},k.key)}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[s.jsx("button",{className:"btn btn-primary btn-sm",onClick:Z,disabled:b||!W,children:b?"Saving…":"Save"}),!W&&!b&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)",alignSelf:"center"},children:"No changes yet"}),e.oauth&&s.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:se,children:["Connect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{V(!1),o({})},children:"Cancel"})]})]}),!M&&ae==="running"&&t&&s.jsxs(s.Fragment,{children:[(Object.keys(m).length>0||Object.keys(w).length>0)&&s.jsx("div",{style:{display:"grid",gap:"0.3rem",margin:"0.15rem 0 0.7rem",fontSize:"0.82rem"},children:e.credentials.fields.map(k=>{const O=k.type==="password",T=w[k.key];return!O&&m[k.key]==null||O&&T==null?null:s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"1rem"},children:[s.jsx("span",{style:{color:"var(--text-muted)"},children:k.label}),s.jsxs("span",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.78rem",textAlign:"right",wordBreak:"break-all"},children:[O?T.preview??"set":m[k.key],O&&v&&s.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(v).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},k.key)})}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx(qe,{to:"/mandates?new=1",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Give a mandate"}),(e.credentials.fields.length>0||e.oauth)&&s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{o({...m}),V(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Edit credentials"}),s.jsx("span",{style:{flex:1}}),s.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:Ve,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"})]}),Y&&ne!==void 0&&!I&&s.jsx("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"0.5rem",minWidth:0},children:[s.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Reads"}),s.jsx("span",{style:{fontSize:"0.82rem",color:"var(--text-muted)"},children:ne===null?"window from your mandate":Hs(ne).toLowerCase()}),oe&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),A&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:A})]}),s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>F(!0),children:"Edit"})]})}),Y&&ne!==void 0&&I&&s.jsxs("div",{style:{marginTop:"0.9rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.6rem",marginBottom:"0.35rem"},children:[s.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"How far back may your agent read?"}),s.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>F(!1),children:"Done"})]}),s.jsx("p",{style:{fontSize:"0.78rem",color:"var(--text-tertiary)",margin:"0 0 0.55rem"},children:"Applies immediately — no Save, no new mandate."}),s.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[Jx.map(k=>{const O=ne===k;return s.jsx("button",{className:`btn btn-sm ${O?"btn-primary":"btn-secondary"}`,"aria-pressed":O,disabled:oe,onClick:()=>ce(k),children:Hs(k)},k)}),s.jsx("button",{className:`btn btn-sm ${ne===null?"btn-primary":"btn-ghost"}`,"aria-pressed":ne===null,disabled:oe,onClick:()=>ce(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:Hs(null)})]}),s.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:A?s.jsx("span",{style:{color:"var(--danger)"},children:A}):oe?s.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):ne===null?s.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):ne===0?s.jsx("span",{style:{color:"var(--text-muted)"},children:"Your agent cannot read any mail."}):s.jsxs("span",{style:{color:"var(--text-muted)"},children:["Anything older than ",ne," days is blocked, whoever it is from."]})})]}),s.jsx("div",{style:{display:"none"},children:s.jsx(qe,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),ae==="unconfigured"&&(()=>{const k=e.credentials.fields.every(G=>G.optional),O=e.credentials.fields.some(G=>!G.optional),T=e.credentials.fields.some(G=>{var re;return(re=i[G.key])==null?void 0:re.trim()});return s.jsxs(s.Fragment,{children:[d&&s.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:[s.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"," ",s.jsx("button",{onClick:()=>{c(!0),e.oauth&&h(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!d&&s.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&&!d&&s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(G=>s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsx("label",{className:"form-label",children:G.label}),G.type==="password"?s.jsxs("div",{className:"cred-field",children:[s.jsx("input",{className:"form-input",type:J[G.key]?"text":"password",name:`${e.id}-${G.key}-credential`,autoComplete:"new-password",placeholder:G.placeholder,value:i[G.key]||"",onChange:re=>o(ve=>({...ve,[G.key]:re.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>B(re=>({...re,[G.key]:!re[G.key]})),children:J[G.key]?"hide":"show"})]}):s.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${G.key}-credential`,autoComplete:"off",placeholder:G.placeholder,value:i[G.key]||"",onChange:re=>o(ve=>({...ve,[G.key]:re.target.value}))})]},G.key)),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[T&&s.jsx("button",{className:"btn btn-primary",onClick:K,disabled:b||O&&!e.credentials.fields.filter(G=>!G.optional).every(G=>{var re;return(re=i[G.key])==null?void 0:re.trim()}),children:b?"Saving...":"Save & Encrypt"}),k&&!T&&s.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:N,children:N?"Starting...":`Activate ${e.name}`})]})]})})(),ae==="needs-oauth"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[s.jsxs("button",{className:"btn btn-primary",onClick:se,children:["Connect ",e.name," Account"]}),s.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Change Credentials"})]})]}),ae==="ready"&&!t&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[s.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:N,children:N?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&s.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Update Credentials"}),e.oauth&&s.jsx("button",{className:"btn btn-ghost",onClick:()=>{c(!1),h(!1)},children:"Change Credentials"})]})]}),ae==="ready"&&t&&!t.running&&(lt.showStart?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[s.jsx("span",{className:"service-status-dot"}),"Not running"]}),t.error&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:t.error}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:N,children:N?"Starting...":"Start"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:Ve,children:"Disable"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"service-status",style:{marginBottom:"0.5rem",color:"var(--text-muted)"},children:[s.jsx("span",{className:"service-status-dot",style:{background:"var(--text-muted)"}}),"Paused"]}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.75rem"},children:"Real systems are off while simulation mode is on."}),s.jsx("div",{style:{display:"flex",gap:"0.5rem"},children:s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:Ve,children:"Disable"})})]}))]})}function qx(e,t){if(!t)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const n=e.filter(o=>Oo(o.manifest)),r=e.filter(o=>!Oo(o.manifest)),a=r.filter(o=>o.state==="error"),i=r.filter(o=>o.state!=="error");return{grouped:!0,testSystems:n,realErrors:a,pausedReal:i,ungrouped:[]}}function Zx({entry:e}){return s.jsxs("div",{className:"int-paused-row",children:[s.jsx("span",{"aria-hidden":"true",children:Om(e.manifest.icon)}),s.jsx("span",{className:"int-paused-name",children:e.manifest.name}),s.jsxs("span",{className:"int-chip int-chip-paused",children:[s.jsx("span",{className:"int-dot"}),"Paused"]})]})}function e0(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:a}=Kl(),i=Sm(),[o,l]=u.useState(""),c=u.useCallback(f=>{l(f),setTimeout(()=>l(""),5e3)},[]),d=qx(r,i);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Integrations"}),s.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),o&&s.jsx("div",{className:"alert alert-success",children:o}),e?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):t===!1?s.jsxs("div",{className:"status-banner status-banner-error",children:[s.jsx("span",{className:"status-banner-icon",children:"!"}),s.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):d.grouped?s.jsxs(s.Fragment,{children:[d.testSystems.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"int-group-label",children:"Test systems"}),d.testSystems.map(f=>s.jsx(Mi,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:c},f.id))]}),(d.realErrors.length>0||d.pausedReal.length>0)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"int-group-label",children:"Real systems"}),d.realErrors.map(f=>s.jsx(Mi,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:c},f.id)),d.pausedReal.length>0&&s.jsxs("details",{className:"int-paused-group",open:!0,children:[s.jsxs("summary",{children:["Paused while simulation mode is on (",d.pausedReal.length,")"]}),s.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 (",s.jsx("code",{children:"suveren-gateway simulation off"}),")."]}),d.pausedReal.map(f=>s.jsx(Zx,{entry:f},f.id))]})]}),r.length===0&&s.jsx(bu,{manifestsError:n})]}):s.jsxs(s.Fragment,{children:[r.map(f=>s.jsx(Mi,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:c},f.id)),r.length===0&&s.jsx(bu,{manifestsError:n})]})]})}function bu({manifestsError:e}){return e?s.jsxs("div",{className:"status-banner status-banner-error",children:[s.jsx("span",{className:"status-banner-icon",children:"!"}),s.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"," ",s.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):s.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."})}function t0(){var M,V,J;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Be(),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(""),[f,m]=u.useState(""),[p,w]=u.useState(!1),[x,v]=u.useState(""),[S,g]=u.useState("");u.useEffect(()=>{fetch("/health").then(B=>B.json()).then(B=>{typeof B.spUrl=="string"&&g(B.spUrl)}).catch(()=>{})},[]),u.useEffect(()=>{if(!e){i(null);return}R.getGroupById(e.id).then(B=>{const z=B.group??B,D=B.members??[],oe=B.isAdmin??!1,$=D.map(A=>{const H=A.userId||A.id||"",I=A.role||(oe&&H===z.createdBy?"admin":"member");return{id:H,name:A.name||H.slice(0,8)||"Member",email:A.email||"",domains:A.domains||[],role:I,isAdmin:I==="admin"||oe&&H===z.createdBy}});i({id:z.id,name:z.name,members:$})}).catch(()=>i(null))},[e==null?void 0:e.id]);const h=(a==null?void 0:a.members.filter(B=>B.isAdmin))??[],y=(e==null?void 0:e.isAdmin)===!0&&h.length<=1&&h.some(B=>B.id===(r==null?void 0:r.id)),j=(e==null?void 0:e.name)??"",b=x.trim()===j&&!o,E=()=>{v(""),w(!0)},C=()=>{w(!1),v("")},P=async()=>{if(!(!e||!b)){l(!0),d("");try{await R.leaveTeam(e.id),await n(),m("You have left the team."),i(null),C()}catch(B){d(B instanceof Error?B.message:"Failed to leave team")}finally{l(!1)}}},N=e&&S?`${S}/dashboard/groups/${e.id}`:void 0,_=S?`${S}/dashboard/groups`:void 0;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"page-header",children:s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:"Team"}),s.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Authority Server dashboard."})]})}),c&&s.jsx("div",{className:"error-message",children:c}),f&&s.jsx("div",{className:"alert alert-success",children:f}),e?s.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[s.jsxs("div",{className:"card-header",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"card-title",children:e.name}),s.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((M=a==null?void 0:a.members)==null?void 0:M.length)??0," ",(((V=a==null?void 0:a.members)==null?void 0:V.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),s.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(J=a==null?void 0:a.members)==null?void 0:J.map(B=>s.jsxs("div",{className:"member-row",children:[s.jsx("div",{className:"member-avatar",children:B.name.split(" ").map(z=>z[0]).join("").slice(0,2).toUpperCase()}),s.jsxs("div",{className:"member-info",children:[s.jsx("div",{className:"member-name",children:B.name}),s.jsx("div",{className:"member-email",children:B.email})]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:B.role})]},B.id)),s.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[N&&s.jsx("a",{className:"btn btn-secondary btn-sm",href:N,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Authority Server →"}),s.jsx("span",{title:y?"You are the only admin. Transfer admin to another member in your Authority Server dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:s.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:E,disabled:o||y,children:"Leave team"})})]})]}):s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[s.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),s.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. You can join an existing team or create a new one in your Authority Server dashboard."}),_&&s.jsx("a",{className:"btn btn-primary btn-sm",href:_,target:"_blank",rel:"noopener noreferrer",children:"Open Authority Server dashboard →"})]}),p&&e&&s.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:C,children:s.jsxs("div",{className:"card",onClick:B=>B.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[s.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",j,"?"]}),s.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),s.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[s.jsx("li",{children:"Revoke all mandates you created in this team's context"}),s.jsx("li",{children:"Reject any pending action proposals you authored"}),s.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),s.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",s.jsx("strong",{children:"personal"})," mandates are not affected."]}),s.jsxs("div",{className:"form-group",children:[s.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",s.jsx("code",{children:j})," to confirm:"]}),s.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:x,onChange:B=>v(B.target.value),placeholder:j,disabled:o,autoFocus:!0})]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:C,disabled:o,children:"Cancel"}),s.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:P,disabled:!b,children:o?"Leaving...":"Leave team"})]})]})})]})}const Bo=e=>e.replace(/@.*$/,"").split("/").pop()??e,Nu=e=>e.split("@")[1]??"";function n0(e,t){const n=new Map;for(const r of e){const a=Bo(r.id);if(!t.has(a))continue;const i=n.get(a);(!i||Nu(r.id).localeCompare(Nu(i.id),void 0,{numeric:!0})>0)&&n.set(a,r)}return n}function r0(e,t,n,r){var l;const a=new Set([...t.filter(c=>c.profile).map(c=>c.profile),...r.map(c=>Bo(c.profile))]),i=n0(e,a),o=[];for(const c of t){const d=c.profile?i.get(c.profile):void 0;d&&o.push({key:`connector:${c.id}`,name:c.name,description:c.description||d.description,profile:d,kind:"connector",ready:((l=n.find(f=>f.id===c.id))==null?void 0:l.running)===!0,setupId:c.id})}for(const c of r){const d=i.get(Bo(c.profile));d&&o.push({key:`builtin:${c.id}`,name:c.name,description:c.description||d.description,profile:d,kind:"builtin",ready:c.available,unavailableReason:c.available?void 0:"Available only while simulation mode is on."})}return o}function s0({onDismiss:e}){const t=en(),{group:n,groupId:r,domain:a,user:i}=Be(),[o,l]=u.useState([]),[c,d]=u.useState([]),[f,m]=u.useState([]),[p,w]=u.useState([]),[x,v]=u.useState(!0),[S,g]=u.useState({});u.useEffect(()=>{Promise.all([R.listProfiles().catch(()=>[]),R.getIntegrationManifests().then(C=>C.manifests??[]).catch(()=>[]),R.getMcpHealth().catch(()=>null)]).then(async([C,P,N])=>{if(l(C),d(P),m((N==null?void 0:N.integrations)??[]),w((N==null?void 0:N.builtins)??[]),r){const _=await Promise.all(C.map(V=>R.getTeamProfileConfig(r,V.id).catch(()=>null))),M={};C.forEach((V,J)=>{const B=_[J];B&&(M[V.id]=B)}),g(M)}}).finally(()=>v(!1))},[r]);const h=r0(o,c,f,p),y=C=>{var P;return Fm({isPersonal:!!(n!=null&&n.isPersonal),configLoaded:!x,approvers:(P=S[C.id])==null?void 0:P.approvers,userId:i==null?void 0:i.id,profileName:Pe(C.id),teamName:n==null?void 0:n.name})},j=C=>C in S,b=C=>{if(!r){console.error("No active group when creating authorization");return}const P=j(C);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:C,groupId:r,groupName:(n==null?void 0:n.name)??null,domain:a,isTeam:P,isPersonal:!!(n!=null&&n.isPersonal)})),sessionStorage.removeItem("agentGate"),e==null||e(),t("/mandates/new/intent")},E=C=>{r&&b(C)};return s.jsxs(s.Fragment,{children:[s.jsx("style",{children:`
70
- .profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
71
- .profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
72
- @media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
73
- @media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
74
- `}),x?s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):h.length===0?s.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[s.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),s.jsx(qe,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):s.jsx("div",{className:"profile-grid",children:h.map(C=>{const P=C.profile,N=j(P.id),_=y(P),M=!C.ready||!_.can;return s.jsxs("div",{className:"card",style:M?{opacity:.7}:void 0,children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[s.jsx("h3",{className:"card-title",style:{margin:0},children:C.name}),N?s.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"}):n!=null&&n.isPersonal?s.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]}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:C.description}),_.can?C.ready?s.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>E(P.id),children:"Give a mandate"}):C.kind==="builtin"?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.5rem"},children:C.unavailableReason})]}):s.jsxs(qe,{to:`/integrations?setup=${C.setupId??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",C.name]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn btn-secondary btn-sm",disabled:!0,children:"Give a mandate"}),s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:[_.reason," ",s.jsx("span",{style:{color:"var(--text-tertiary)"},children:_.fix})]})]})]},C.key)})})]})}const a0={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function i0({status:e,label:t}){return s.jsx("span",{className:`status-badge status-${e}`,children:t||a0[e]})}function o0({domain:e,attested:t}){const n=t===!0?"domain-attested":t===!1?"domain-missing":"";return s.jsx("span",{className:`domain-badge ${n}`,style:{fontSize:"0.75rem"},children:e})}const Tn=86400,Br=3600,Vs=60,l0=30*Tn;function c0(e){if(e<=0)return"Expired";if(e>90*Tn){const t=Math.floor(e/l0);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*Tn){const t=Math.floor(e/Tn);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*Tn){const t=Math.floor(e/Tn),n=Math.floor(e%Tn/Br);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*Br){const t=Math.floor(e/Br),n=Math.floor(e%Br/Vs);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=Vs){const t=Math.floor(e/Vs),n=Math.floor(e%Vs);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function u0({expiresAt:e}){const[t,n]=u.useState(()=>e-Date.now()/1e3),r=t<2*Br;u.useEffect(()=>{const i=setInterval(()=>n(e-Date.now()/1e3),r?1e3:6e4);return()=>clearInterval(i)},[e,r]);const a=t<300;return s.jsx("span",{className:`ttl-badge ${a?"ttl-warn":"ttl-ok"}`,children:c0(t)})}function La({icon:e,title:t,text:n,children:r}){return s.jsxs("div",{className:"empty-state",children:[e&&s.jsx("div",{className:"empty-state-icon",children:e}),s.jsx("div",{className:"empty-state-title",children:t}),n&&s.jsx("div",{className:"empty-state-text",children:n}),r]})}function d0(e){const t=Math.floor(e/86400);if(t>=1)return`${t} day${t===1?"":"s"}`;const n=Math.floor(e/3600);if(n>=1)return`${n} hour${n===1?"":"s"}`;const r=Math.ceil(e/60);return`${r} minute${r===1?"":"s"}`}const f0=[{label:"30m",seconds:1800},{label:"1h",seconds:3600},{label:"2h",seconds:7200},{label:"4h",seconds:14400},{label:"8h",seconds:28800},{label:"24h",seconds:86400},{label:"7d",seconds:604800},{label:"30d",seconds:2592e3},{label:"1y",seconds:31536e3}];function m0({item:e,onClose:t,onSuccess:n}){var y;const{user:r,activeDomain:a,groupId:i}=Be(),[o,l]=u.useState(null);u.useEffect(()=>{let j=!1;return R.getProfile(e.profile_id).then(b=>{var E;j||l(((E=b==null?void 0:b.ttl)==null?void 0:E.max)??null)}).catch(()=>{}),()=>{j=!0}},[e.profile_id]);const c=e.remaining_seconds??0,d=f0.filter(j=>j.seconds>c&&(o===null||j.seconds<=o)),f=((y=d[0])==null?void 0:y.seconds)??2592e3,[m,p]=u.useState(f);u.useEffect(()=>{var j;if(o!==null&&m>o){const b=(j=d[d.length-1])==null?void 0:j.seconds;b&&p(b)}},[o]);const[w,x]=u.useState(!1),[v,S]=u.useState(""),g=Object.entries(e.frame).filter(([j])=>j!=="profile"&&j!=="path"),h=async()=>{var j;if(r){x(!0),S("");try{const b=e.authorization_id,E=await R.getGateContent(b);if(!E)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const C=await R.getProfile(e.profile_id),P=e.frame,N=E.context??{},_=e.attested_domains[0]||a||"owner",M=await oa(P,C),V=await $m(N,C),[J,B]=await Promise.all([$a(E.gateContent.intent),$a(JSON.stringify({profile:e.profile_id,path:e.path,domain:_}))]);if(!i)throw new Error("No active group; cannot extend mandate.");const z=(((j=e.deferred_commitment_domains)==null?void 0:j.length)??0)>0?"review":"automatic",D=await R.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:P,bounds_hash:M,context_hash:V,domain:_,did:r.did,gate_content_hashes:{intent:J},execution_context_hash:B,group_id:i,commitment_mode:z,ttl:m});await R.pushGateContent(Lm(D,{boundsHash:M,contextHash:V,context:N,path:e.path,gateContent:E.gateContent})),n()}catch(b){S(b instanceof Error?b.message:"Extension failed")}finally{x(!1)}}};return s.jsx("div",{className:"modal-backdrop",onClick:j=>j.target===j.currentTarget&&t(),children:s.jsxs("div",{className:"modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:"Extend mandate"}),s.jsx("button",{className:"modal-close",onClick:t,children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[s.jsxs("div",{style:{marginBottom:"1rem"},children:[s.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Pe(e.profile_id)," / ",e.path]}),g.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:g.map(([j,b])=>`${j}=${b}`).join(" · ")})]}),s.jsxs("div",{style:{marginBottom:"1rem"},children:[s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),c>0&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",d0(c),". Only longer durations are shown."]}),s.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:d.length===0?s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This mandate is already on the longest available duration. Nothing to extend."}):d.map(j=>s.jsx("button",{className:`btn ${m===j.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>p(j.seconds),style:{minWidth:"3.5rem"},children:j.label},j.seconds))})]}),s.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)."}),v&&s.jsx("div",{className:"error-message",children:v})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:t,disabled:w,children:"Cancel"}),s.jsx("button",{className:"btn btn-primary",onClick:h,disabled:w,children:w?"Extending...":"Extend"})]})]})})}function p0(e,t,n){return[...e].sort((r,a)=>{if(n){if(r.authorization_id===n&&a.authorization_id!==n)return-1;if(a.authorization_id===n&&r.authorization_id!==n)return 1}const i=_a(r,t),o=_a(a,t),l={active:0,pending:1,expired:2,revoked:3,archived:4};return l[i]!==l[o]?l[i]-l[o]:new Date(a.created_at).getTime()-new Date(r.created_at).getTime()})}function h0({item:e,newerProfile:t,revokedSet:n,expandedHash:r,gateCache:a,gateLoading:i,copiedHash:o,revokingHash:l,copyingHash:c,profileConfigCache:d,mode:f,ownerLabel:m,isAdmin:p,onExpand:w,onCopyHash:x,onCopy:v,onRevoke:S,onExtend:g,archivedSet:h,archivingHash:y,onArchive:j,highlightHash:b}){var he;const E=Gl(e,{revokedSet:n}),C=vm(e,{revokedSet:n,archivedSet:h}),P=!m&&!!j&&ym(E),N=r===e.authorization_id,_=a[e.authorization_id],M=E==="active"||E==="pending"||E==="expired",V=Object.entries(e.frame).filter(([te])=>te!=="profile"&&te!=="path"),J=d.get(e.profile_id)??null,B=(((he=J==null?void 0:J.approvers)==null?void 0:he.length)??0)>0,z=new Map;if(J!=null&&J.caps&&f==="team")for(const[te,ue]of V){const ae=J.caps[te];ae!==void 0&&Number(ue)>ae&&z.set(te,{authorized:Number(ue),cap:ae})}const D=z.size>0,oe=e.approvers_frozen??[],$=(J==null?void 0:J.approvers)??[],A=f==="team"&&oe.length>0&&$.length>0&&(oe.length!==$.length||oe.some(te=>!$.includes(te))||$.some(te=>!oe.includes(te))),H=Array.from(z.entries()).map(([te,ue])=>`${te}: ${ue.authorized} (cap ${ue.cap})`).join(", "),I=Array.from(z.entries()).map(([te,ue])=>`${te}: ${ue.authorized} → ${ue.cap}`).join(", "),F=D?B?z.size===1?`Above team cap: ${H} — actions require approval`:`Above team cap (${z.size}): ${H} — actions require approval`:z.size===1?`Reduced by hard cap: ${I}`:`Reduced by hard cap (${z.size}): ${I}`:"",Y=D?B?"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,q=Pe(e.profile_id),ne=t?s.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:[s.jsxs("strong",{style:{color:"var(--text-secondary)"},children:[q,"@",t.version," available"]}),t.whatsNew?s.jsxs(s.Fragment,{children:[" — ",t.whatsNew]}):null,s.jsx("br",{}),s.jsxs("span",{children:["This mandate stays on ",e.profile_id.split("@")[1]??"its pinned version","; authorize again to move it."]})]}):null,ce=b!=null&&e.authorization_id===b;return s.jsxs("div",{className:`card${ce?" card-highlight":""}`,style:{marginBottom:0},children:[ne,m&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",s.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:m})]}),s.jsxs("div",{className:"auth-card-header",children:[s.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:q}),e.title&&s.jsx("span",{style:{fontWeight:500,fontSize:"0.85rem",color:"var(--text-secondary)"},children:e.title}),s.jsx(i0,{status:E}),E==="active"&&e.earliest_expiry&&s.jsx(u0,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),E==="expired"&&(()=>{const te=pv(e,E);return te?s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(te.iso).toLocaleString()}`,children:new Date(te.iso).toLocaleDateString(void 0,{month:"short",day:"numeric"})}):null})()]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[e.required_domains.map(te=>s.jsx(o0,{domain:te,attested:e.attested_domains.includes(te)},te)),e.deferred_commitment_domains.length>0&&s.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"}),D&&s.jsx("span",{title:Y,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:B?"var(--accent-subtle)":"var(--danger-subtle)",color:B?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:F}),A&&s.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.65rem",padding:"0.15rem 0.5rem",borderRadius:"0.25rem",background:"var(--warning-subtle, rgba(234,179,8,0.12))",color:"var(--warning, #ca8a04)",fontWeight:600,border:"1px solid var(--warning-border, rgba(234,179,8,0.3))",cursor:"pointer",lineHeight:1.4},onClick:()=>v(e),disabled:c===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:c===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),V.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:V.map(([te,ue],ae)=>{const K=z.get(te);return s.jsxs("span",{children:[ae>0&&" · ",K?B?s.jsxs("span",{title:`Team cap on ${te} is ${K.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${K.authorized}.`,children:[s.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[te,"=",String(ue)]}),s.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",K.cap]})]}):s.jsxs("span",{title:`Team cap on ${te} is ${K.cap} with no approvers configured (hard cap). Authorized for ${K.authorized}; effective ${K.cap}.`,children:[s.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[te,"=",String(ue)]}),s.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",K.cap]})]}):s.jsxs("span",{children:[te,"=",String(ue)]})]},te)})}),s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:[P&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>j(e.authorization_id,!C),disabled:y===e.authorization_id,title:C?"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:y===e.authorization_id?C?"Unarchiving…":"Archiving…":C?"↩ Unarchive":"⊟ Archive"}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>w(e),children:N?"▲ Hide Details":"▼ Details"})]}),N&&s.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[V.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),s.jsx("dl",{className:"review-grid",children:V.map(([te,ue])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:te}),s.jsx("dd",{children:String(ue)})]},te))})]}),(_==null?void 0:_.context)&&Object.keys(_.context).length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Scope"}),s.jsx("dl",{className:"review-grid",children:Object.entries(_.context).map(([te,ue])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:te}),s.jsx("dd",{title:String(ue),children:Mm(te,ue,_.contextLabels)})]},te))})]}),s.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),i===e.authorization_id?s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):_?s.jsx("div",{className:"gate-content-block",children:s.jsx("div",{className:"gate-content-item",children:s.jsx("div",{className:"gate-content-text",children:_.gateContent.intent})})}):s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),s.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()}`]}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:e.authorization_id}),s.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>x(e.authorization_id),children:o===e.authorization_id?"copied":"copy"})]}),s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!m&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>v(e),disabled:c===e.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:c===e.authorization_id?"Copying…":"⧉ Copy"}),!m&&(E==="active"||E==="pending")&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>v(e,{asEdit:!0}),disabled:c===e.authorization_id,title:"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:"✎ Edit"}),!m&&M&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>g(e),children:"↻ Extend"}),m&&p&&E!=="revoked"?s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>S(e.authorization_id,m,q),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):!m&&(E==="active"||E==="pending")?s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>S(e.authorization_id),disabled:l===e.authorization_id,children:l===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]},e.authorization_id)}function g0(){const[e,t]=u.useState([]),[n,r]=u.useState(!0),[a,i]=u.useState([]),[o,l]=u.useState(!1),[c,d]=u.useState(new Map),[f,m]=u.useState("mine"),[p,w]=u.useState("active"),[x,v]=u.useState(null),[S,g]=u.useState(null),[h,y]=Wl(),[j,b]=u.useState(()=>h.get("new")==="1"),[E,C]=u.useState(()=>h.get("highlight")),[P,N]=u.useState(null),[_,M]=u.useState({}),[V,J]=u.useState(null),[B,z]=u.useState(null),[D,oe]=u.useState(null),[$,A]=u.useState(new Set),[H,I]=u.useState(null),[F,Y]=u.useState(new Set),[q,ne]=u.useState(null),[ce,he]=u.useState(null),te=en(),{group:ue,groupId:ae,domain:K,mode:fe,activeTeam:W}=Be(),Z=(W==null?void 0:W.isAdmin)===!0,[se,Te]=u.useState(()=>new Map),Ve=u.useCallback(()=>{r(!0),R.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),Ie=u.useCallback(()=>{R.getArchivedMandates().then(U=>Y(new Set(U))).catch(()=>{})},[]);u.useEffect(()=>{Ie()},[Ie]);const lt=async(U,X)=>{ne(U);try{const ie=await R.setMandateArchived(U,X);Y(new Set(ie)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(ie){alert(ie instanceof Error?ie.message:"Failed to update archive")}finally{ne(null)}},nt=u.useCallback(()=>{ae&&(l(!0),R.listTeamAuthorizations(ae).then(i).catch(()=>{}).finally(()=>l(!1)))},[ae]);ge("attestation-changed",()=>{Ve(),Z&&ae&&nt()}),u.useEffect(()=>{if(!E)return;h.get("highlight")&&(h.delete("highlight"),y(h,{replace:!0}));const U=window.setTimeout(()=>C(null),3e3);return()=>window.clearTimeout(U)},[]),It(Ve,3e5),u.useEffect(()=>{f==="team"&&Z&&ae&&a.length===0&&!o&&nt()},[f,Z,ae,a.length,o,nt]),u.useEffect(()=>{let U=!1;return R.listProfiles().then(X=>{if(U)return;const ie=Ae=>Ae.replace(/@.*$/,"").split("/").pop()??Ae,me=Ae=>Ae.split("@")[1]??"",ee=new Map;for(const Ae of X){const Ct=ie(Ae.id),Ss=ee.get(Ct);(!Ss||me(Ae.id).localeCompare(me(Ss.id),void 0,{numeric:!0})>0)&&ee.set(Ct,Ae)}d(ee)}).catch(()=>{}),()=>{U=!0}},[]);const De=u.useCallback(U=>{const X=Ct=>Ct.replace(/@.*$/,"").split("/").pop()??Ct,ie=Ct=>Ct.split("@")[1]??"",me=c.get(X(U));if(!me)return;const ee=ie(U),Ae=ie(me.id);if(!(!ee||!Ae))return Ae.localeCompare(ee,void 0,{numeric:!0})>0?me:void 0},[c]);u.useEffect(()=>{if(fe!=="team"||!ae)return;const U=f==="mine"?e:a;if(U.length===0)return;const X=[...new Set(U.map(ie=>ie.profile_id))].filter(ie=>!se.has(ie));if(X.length!==0){Te(ie=>{const me=new Map(ie);for(const ee of X)me.set(ee,null);return me});for(const ie of X)R.getTeamProfileConfig(ae,ie).then(me=>{Te(ee=>new Map(ee).set(ie,me))}).catch(()=>{})}},[e,a,f,ae,fe,se]);const de=async U=>{if(P===U.authorization_id){N(null);return}N(U.authorization_id);const X=U.authorization_id;if(!(X in _)){J(U.authorization_id);try{const ie=await R.getGateContent(X);M(me=>({...me,[X]:ie}))}catch{M(ie=>({...ie,[X]:null}))}finally{J(null)}}},ct=U=>{navigator.clipboard.writeText(U).then(()=>{oe(U),setTimeout(()=>oe(null),2e3)})},tn=async(U,X)=>{var ie;if(!ae){alert("No active group; cannot copy mandate.");return}he(U.authorization_id);try{const me=U.authorization_id;let ee=_[me]??null;me in _||(ee=await R.getGateContent(me),M(ks=>({...ks,[me]:ee})));const Ae=Object.fromEntries(Object.entries(U.frame).filter(([ks])=>ks!=="profile"&&ks!=="path")),Ct=(ee==null?void 0:ee.context)??{},Ss=((ie=ee==null?void 0:ee.gateContent)==null?void 0:ie.intent)??"",Ym=U.deferred_commitment_domains.length>0?"review":"automatic",Qm=U.attested_domains[0]||K||"owner",ni=Date.parse(U.created_at),ri=U.earliest_expiry?Date.parse(U.earliest_expiry):NaN,Jm=Number.isFinite(ni)&&Number.isFinite(ri)&&ri>ni?Math.round((ri-ni)/1e3):void 0;sessionStorage.setItem("agentAuth",JSON.stringify({profileId:U.profile_id,groupId:ae,groupName:(ue==null?void 0:ue.name)??null,domain:Qm,isPersonal:!!(ue!=null&&ue.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:Ae,context:Ct,gateContent:{intent:Ss},templateMode:Ym,templateTtl:Jm})),X!=null&&X.asEdit?sessionStorage.setItem("agentEditReplaces",U.authorization_id):sessionStorage.removeItem("agentEditReplaces"),te("/mandates/new/intent")}catch(me){alert(me instanceof Error?me.message:"Failed to copy mandate")}finally{he(null)}},k=async(U,X,ie)=>{const me=X&&ie?`Revoke ${X}'s ${ie} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(me)){I(U);try{await R.revokeAttestation(U),A(ee=>new Set(ee).add(U)),R.resyncGates().catch(()=>{}),X&&ae&&nt()}catch(ee){alert(ee instanceof Error?ee.message:"Failed to revoke mandate")}finally{I(null)}}},O=f==="mine"?e:a,T=f==="mine"?n:o,G=f==="mine"?{revokedSet:$,archivedSet:F}:{revokedSet:$},re=U=>_a(U,G),ve={active:0,pending:0,expired:0,revoked:0,archived:0};for(const U of O)ve[re(U)]+=1;const Je=f==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],bn=(()=>{const U=new Map;for(const X of O){if(re(X)!==p)continue;const ie=U.get(X.profile_id)??{count:0,review:!1};ie.count+=1,X.deferred_commitment_domains.length>0&&(ie.review=!0),U.set(X.profile_id,ie)}return Array.from(U.entries()).map(([X,ie])=>({profileId:X,...ie})).sort((X,ie)=>Pe(X.profileId).localeCompare(Pe(ie.profileId)))})(),nn=p0(O.filter(U=>{if(re(U)!==p||x!==null&&U.profile_id!==x)return!1;if(S!==null){const X=U.deferred_commitment_domains.length>0;if(S==="review"&&!X||S==="auto"&&X)return!1}return!0}),G,E),ze={revokedSet:$,expandedHash:P,gateCache:_,gateLoading:V,copiedHash:D,revokingHash:H,copyingHash:ce,profileConfigCache:se,mode:fe,activeDomain:K,group:ue,groupId:ae,onExpand:de,onCopyHash:ct,onCopy:tn,onRevoke:k,onExtend:z,highlightHash:E},vt={...ze,archivedSet:F,archivingHash:q,onArchive:lt};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:"Mandates"}),s.jsx("p",{className:"page-subtitle",children:"Active, pending, expired, and archived agent mandates."})]}),s.jsx("button",{className:"btn btn-primary",onClick:()=>b(!0),children:"+ New mandate"})]}),j&&s.jsx("div",{className:"modal-backdrop",onClick:()=>{b(!1),h.get("new")&&(h.delete("new"),y(h,{replace:!0}))},children:s.jsxs("div",{className:"modal",onClick:U=>U.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h2",{className:"modal-title",children:"New mandate"}),s.jsx("button",{className:"modal-close",onClick:()=>{b(!1),h.get("new")&&(h.delete("new"),y(h,{replace:!0}))},children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[s.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."}),s.jsx(s0,{onDismiss:()=>b(!1)})]})]})}),Z&&s.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[s.jsx("button",{className:`nav-tab${f==="mine"?" active":""}`,onClick:()=>{m("mine"),w("active"),v(null),g(null),N(null)},children:"Mine"}),s.jsx("button",{className:`nav-tab${f==="team"?" active":""}`,onClick:()=>{m("team"),w("active"),v(null),g(null),N(null)},children:"Team"})]}),s.jsx("div",{className:"nav-tabs",children:Je.map(U=>s.jsxs("button",{className:`nav-tab${p===U?" active":""}`,onClick:()=>{w(U),v(null),g(null)},children:[U.charAt(0).toUpperCase()+U.slice(1)," (",ve[U],")"]},U))}),bn.length>0&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[bn.map(U=>{const X=x===U.profileId;return s.jsx("button",{className:`btn btn-sm ${X?"btn-primary":"btn-secondary"}`,onClick:()=>v(X?null:U.profileId),children:Pe(U.profileId)},U.profileId)}),s.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(U=>{const X=S===U;return s.jsx("button",{className:`btn btn-sm ${X?"btn-primary":"btn-secondary"}`,onClick:()=>g(X?null:U),children:U==="auto"?"Auto":"Review"},U)})]}),T&&O.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):nn.length===0?s.jsx(La,{icon:"☰",title:"No mandates",text:p==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${p} mandates found.`}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:nn.map(U=>{const X=f==="team"?U:null,ie=X!=null&&X.owner?X.owner.name??X.owner.email??X.owner.userId:void 0;return s.jsx(h0,{item:U,newerProfile:De(U.profile_id),ownerLabel:ie,isAdmin:Z,...f==="mine"?vt:ze},U.authorization_id)})}),B&&s.jsx(m0,{item:B,onClose:()=>z(null),onSuccess:()=>{z(null),Ve()}})]})}function y0(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function v0(e,t){var c,d,f;const{integrationId:n,toolName:r}=y0(e.action),a=t.find(m=>m.id===n),i=(d=(c=a==null?void 0:a.toolGating)==null?void 0:c.overrides)==null?void 0:d[r];if(i!=null&&i.actionLabel)return i.actionLabel;const o=Pe(e.profileId),l=(f=e.executionContext)==null?void 0:f.action_type;return typeof l=="string"&&l?`${o} · ${l}`:`${o} · ${r}`}function x0(e){const t=[];for(const[n,r]of Object.entries(e.executionContext??{})){if(!n.startsWith("allowed_"))continue;const a=String(r??"").trim();a&&t.push(a.split(",").map(i=>i.trim()).filter(Boolean).join(", "))}return t.join(" · ")}function w0(e){if(!e)return"";const t=[];for(const[n,r]of Object.entries(e)){if(n==="action_type")continue;const a=String(r??"").trim();if(!a)continue;const i=n.replace(/^allowed_/,"").replace(/_/g," ");t.push(`${i} ${a.split(",").map(o=>o.trim()).filter(Boolean).join(", ")}`)}return t.join(" · ")}function j0(e,t){var i,o;const n=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],r=e.actionType??(typeof((i=e.executionContext)==null?void 0:i.action_type)=="string"?e.executionContext.action_type:void 0),a=[];for(const{window:l,label:c}of n){const d=(o=e.cumulativeState)==null?void 0:o[l];if(!d)continue;const f=`_${l}_max`,m=Object.keys(t??{}).filter(S=>S.endsWith(f)),p=(r&&m.find(S=>S.startsWith(`${r}_`)))??(m.length===1?m[0]:void 0),x=(p?/^(amount|spend)_/.test(p):!1)?d.amount:d.count,v=p?Number(t==null?void 0:t[p]):NaN;p&&Number.isFinite(v)?a.push(`${x} of ${v} ${c}`):a.push(`${d.count} ${d.count===1?"call":"calls"} ${c}`)}return a.join(" · ")}function S0(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function k0(e){const t=Pe(e),n=e.split("@")[1];return n?`${t}@${n}`:t}function _r({label:e,children:t}){return s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"receipt-row-label",children:e}),s.jsx("dd",{className:"receipt-row-value",children:t})]})}function b0({receipt:e,manifests:t,localAuth:n,localUnavailable:r,signature:a,grantTitle:i,ownerLabel:o,spUrl:l,formatDate:c,onOpenComplete:d}){var x;const f=x0(e),m=w0(n==null?void 0:n.context),p=j0(e,(n==null?void 0:n.bounds)??e.limits),w=n==null?void 0:n.intent;return s.jsxs("div",{className:"card",style:{marginBottom:0},children:[s.jsxs("div",{className:"receipt-head",children:[s.jsx("span",{className:"receipt-what",children:v0(e,t)}),s.jsx("span",{className:"receipt-tag",children:S0(e)?"review":"automatic"}),e.contentHash&&s.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(x=e.contentBinding)!=null&&x.fields?`The ticket binds: ${e.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),s.jsx("span",{className:"auth-card-time",children:c(e.timestamp)})]}),f&&s.jsx("div",{className:"receipt-scope",children:f}),s.jsxs("dl",{className:"receipt-rows",children:[s.jsx(_r,{label:"mandate",children:s.jsx("strong",{children:i||k0(e.profileId)})}),o&&s.jsx(_r,{label:"owner",children:o}),m&&s.jsx(_r,{label:"allowed",children:m}),p&&s.jsx(_r,{label:"used",children:s.jsx("span",{className:"receipt-num",children:p})}),s.jsx(_r,{label:"intent",children:w?s.jsx("span",{className:"receipt-intent",children:w}):s.jsx("span",{className:"receipt-absent",children:r?"local store unreachable — sign in to the gateway to read it":"not on this device — the Authority Server stores only its hash"})})]}),s.jsxs("div",{className:"receipt-foot",children:[a==="valid"&&s.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"}),a==="invalid"&&s.jsx("span",{className:"receipt-tamper",title:"The stored ticket does not match what was signed.",children:"⚠ Signature check FAILED"}),s.jsx("button",{type:"button",className:"receipt-evidence-link",onClick:d,children:"Complete ticket"}),l&&s.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",s.jsx("a",{className:"receipt-link",href:`${l}/r/${e.id}`,target:"_blank",rel:"noreferrer",children:"public link ↗"})]})]}),s.jsxs("details",{className:"receipt-more",children:[s.jsx("summary",{children:"Raw"}),s.jsxs("div",{className:"receipt-kv",children:[s.jsxs("div",{children:["ticket · ",e.id]}),s.jsxs("div",{children:["action · ",e.action]}),s.jsxs("div",{children:["profile · ",e.profileId]}),e.authorizationId&&s.jsxs("div",{children:["mandate · ",e.authorizationId]}),Object.keys(e.executionContext??{}).length>0&&s.jsxs("div",{children:["scope ·"," ",Object.entries(e.executionContext).map(([v,S])=>`${v}=${S}`).join(" · ")]}),(n==null?void 0:n.boundsHash)&&s.jsxs("div",{children:["bounds hash · ",n.boundsHash]}),(n==null?void 0:n.contextHash)&&s.jsxs("div",{children:["scope hash · ",n.contextHash]}),e.contentHash&&s.jsxs("div",{children:["content · ",e.contentHash]}),e.proposalId&&s.jsxs("div",{children:["proposal · ",e.proposalId]}),s.jsxs("div",{children:["signature · ",e.signature]})]})]})]})}function N0({receipt:e,onClose:t}){const[n,r]=u.useState(null),[a,i]=u.useState(null),[o,l]=u.useState(null),[c,d]=u.useState(!0),[f,m]=u.useState(!1);u.useEffect(()=>{let S=!1;return d(!0),R.getArchivedReceipt(e.id).then(g=>{S||(r(g),i(g?"local":"authority-server"),l((g==null?void 0:g.signature)??null))}).catch(()=>{S||i("authority-server")}).finally(()=>{S||d(!1)}),()=>{S=!0}},[e.id]);const p=n?n.entry:{receipt:e},w=JSON.stringify(p,null,2);function x(){const S=URL.createObjectURL(new Blob([w],{type:"application/json"})),g=document.createElement("a");g.href=S,g.download=`suveren-ticket-${e.id.slice(0,8)}.json`,g.click(),URL.revokeObjectURL(S)}async function v(){try{await navigator.clipboard.writeText(w),m(!0),setTimeout(()=>m(!1),2e3)}catch{m(!1)}}return s.jsx("div",{className:"modal-backdrop",onClick:S=>S.target===S.currentTarget&&t(),children:s.jsxs("div",{className:"modal",style:{maxWidth:"44rem"},children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:"Complete ticket"}),s.jsx("button",{className:"modal-close",onClick:t,"aria-label":"Close",children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[o==="valid"&&s.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."}),o==="invalid"&&s.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."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",margin:"0 0 0.75rem"},children:c?"Loading…":a==="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."}),s.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:w})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-primary btn-sm",onClick:x,children:"Download"}),s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:v,children:f?"Copied":"Copy"})]})]})})}function C0(e){return new Date(e*1e3).toLocaleString()}function E0(e,t){if(t==="all")return!0;const n=t==="1d"?1:t==="7d"?7:30,r=Math.floor(Date.now()/1e3)-n*86400;return e.timestamp>=r}function T0(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||Pe(e.profileId).toLowerCase().includes(n)||e.path.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)||e.attestationHash.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)||JSON.stringify(e.executionContext).toLowerCase().includes(n)}function Cu(e,t){const n=new Map(e.map(r=>[r.id,r]));for(const r of t)n.set(r.id,r);return[...n.values()].sort((r,a)=>a.timestamp-r.timestamp)}function R0(){const{activeTeam:e,groupId:t}=Be(),n=(e==null?void 0:e.isAdmin)===!0,[r,a]=u.useState("mine"),[i,o]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState(""),[m,p]=u.useState(!0),[w,x]=u.useState({}),[v,S]=u.useState(new Set),[g,h]=u.useState(""),[y,j]=u.useState(new Set),[b,E]=u.useState(new Set),[C,P]=u.useState("all"),[N,_]=u.useState(!1),[M,V]=u.useState(!1),[J,B]=u.useState(null),[z,D]=u.useState({}),[oe,$]=u.useState(!1),[A,H]=u.useState({}),[I,F]=u.useState({}),[Y,q]=u.useState(null),[ne,ce]=u.useState(null),[he,te]=u.useState(!1),[ue,ae]=u.useState(!1),K=u.useRef(""),fe=u.useCallback(k=>r==="team"&&n&&t?R.listTeamReceiptsPage(t,{before:k,limit:200}):R.getMyReceiptsPage({before:k,limit:200}),[r,n,t]),W=u.useCallback(()=>{const k=r==="team"?`team:${t}`:"mine",O=K.current!==k;K.current=k,p(!0),ae(!1),fe().then(T=>{o(G=>O?T.receipts:Cu(G,T.receipts)),ce(G=>O?T.nextBefore:G??T.nextBefore)}).catch(()=>{O&&o([]),ae(!0)}).finally(()=>p(!1))},[fe,r,t]),Z=u.useCallback(()=>{!ne||he||(te(!0),ae(!1),fe(ne).then(k=>{o(O=>Cu(O,k.receipts)),ce(k.nextBefore)}).catch(()=>ae(!0)).finally(()=>te(!1)))},[ne,he,fe]);It(W,12e4),u.useEffect(()=>{R.getIntegrationManifests().then(({manifests:k})=>c(k)).catch(()=>{}),fetch("/health").then(k=>k.json()).then(k=>{typeof k.spUrl=="string"&&f(k.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),u.useEffect(()=>{R.getLocalAuthorizations().then(({authorizations:k,signatures:O})=>{D(k),H(O),$(!1)}).catch(()=>{D({}),H({}),$(!0)}),R.getMyAttestations().then(k=>{const O={};for(const T of k)T.authorization_id&&T.title&&(O[T.authorization_id]=T.title);F(O)}).catch(()=>{})},[]),u.useEffect(()=>{r!=="team"||Object.keys(w).length>0||R.listUsers().then(k=>{const O={};for(const T of k)O[T.id]={name:T.name,email:T.email};x(O)}).catch(()=>{})},[r,w]);const se=u.useMemo(()=>{const k=new Set;for(const O of i)k.add(Pe(O.profileId));return[...k].sort()},[i]),Te=u.useMemo(()=>{const k=new Set;for(const O of i)k.add(O.action);return[...k].sort()},[i]),Ve=u.useMemo(()=>{if(r!=="team")return[];const k=new Set;for(const O of i)O.userId&&k.add(O.userId);return[...k].map(O=>{var T;return{id:O,label:(T=w[O])!=null&&T.name?`${w[O].name} (${w[O].email})`:O}}).sort((O,T)=>O.label.localeCompare(T.label))},[r,i,w]),Ie=u.useMemo(()=>i.filter(k=>!(!T0(k,g)||y.size>0&&!y.has(Pe(k.profileId))||b.size>0&&!b.has(k.action)||v.size>0&&k.userId&&!v.has(k.userId)||!E0(k,C))),[i,g,y,b,v,C]),lt=y.size>0||b.size>0||v.size>0||C!=="all";function nt(k){j(O=>{const T=new Set(O);return T.has(k)?T.delete(k):T.add(k),T})}function De(k){E(O=>{const T=new Set(O);return T.has(k)?T.delete(k):T.add(k),T})}function de(k){S(O=>{const T=new Set(O);return T.has(k)?T.delete(k):T.add(k),T})}function ct(){j(new Set),E(new Set),S(new Set),P("all"),h("")}async function tn(){V(!0),B(null);try{const{bundle:k,filename:O}=await R.fetchEvidenceBundle(),T=URL.createObjectURL(new Blob([JSON.stringify(k,null,2)],{type:"application/json"})),G=document.createElement("a");G.href=T,G.download=O,G.click(),URL.revokeObjectURL(T);const re=k.sources??{};re.authorityServer?re.local||B(`Downloaded Authority Server history only — ${re.localError??"local archive unavailable."}`):B(`Downloaded local evidence only — ${re.asError??"Authority Server export unavailable."}`)}catch(k){B(`Export failed: ${k instanceof Error?k.message:String(k)}`)}finally{V(!1)}}return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:"Tickets"}),s.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),s.jsx("button",{className:"btn btn-secondary",onClick:tn,disabled:M,children:M?"Preparing…":"Download evidence"})]}),J&&s.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:J}),n&&s.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(k=>s.jsx("button",{onClick:()=>a(k),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===k?"2px solid var(--accent)":"2px solid transparent",color:r===k?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===k?600:500},children:k==="mine"?"Mine":"Team"},k))}),s.jsxs("div",{className:"search-filter-bar",children:[s.jsxs("div",{className:"search-input-wrap",children:[s.jsx("span",{className:"search-icon",children:"⌕"}),s.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:g,onChange:k=>h(k.target.value)}),g&&s.jsx("button",{className:"search-clear",onClick:()=>h(""),children:"×"})]}),s.jsxs("button",{className:`btn btn-sm btn-secondary${N?" active":""}`,onClick:()=>_(!N),children:["Filters",lt?` (${y.size+b.size+(C!=="all"?1:0)})`:""]})]}),N&&s.jsxs("div",{className:"filter-panel",children:[se.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Profile"}),s.jsx("div",{className:"filter-chips",children:se.map(k=>s.jsx("button",{className:`filter-chip${y.has(k)?" selected":""}`,onClick:()=>nt(k),children:k},k))})]}),Te.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Action"}),s.jsx("div",{className:"filter-chips",children:Te.map(k=>s.jsx("button",{className:`filter-chip${b.has(k)?" selected":""}`,onClick:()=>De(k),children:k},k))})]}),r==="team"&&Ve.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Owner"}),s.jsx("div",{className:"filter-chips",children:Ve.map(k=>s.jsx("button",{className:`filter-chip${v.has(k.id)?" selected":""}`,onClick:()=>de(k.id),children:k.label},k.id))})]}),s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Time range"}),s.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([k,O])=>s.jsx("button",{className:`filter-chip${C===k?" selected":""}`,onClick:()=>P(k),children:O},k))})]})]}),lt&&s.jsxs("div",{className:"active-filters",children:[[...y].map(k=>s.jsxs("span",{className:"active-chip",onClick:()=>nt(k),children:[k," ",s.jsx("span",{className:"chip-remove",children:"×"})]},k)),[...b].map(k=>s.jsxs("span",{className:"active-chip",onClick:()=>De(k),children:[k," ",s.jsx("span",{className:"chip-remove",children:"×"})]},k)),[...v].map(k=>{const O=w[k],T=O?O.name:k;return s.jsxs("span",{className:"active-chip",onClick:()=>de(k),children:[T," ",s.jsx("span",{className:"chip-remove",children:"×"})]},k)}),C!=="all"&&s.jsxs("span",{className:"active-chip",onClick:()=>P("all"),children:[C==="1d"?"Today":C==="7d"?"7 days":"30 days"," ",s.jsx("span",{className:"chip-remove",children:"×"})]}),s.jsx("button",{className:"clear-filters",onClick:ct,children:"Clear all"})]}),ue&&s.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:s.jsx("span",{style:{color:"var(--danger, #c0392b)",fontSize:"0.85rem"},children:"Couldn’t load tickets — your session may have expired. Try signing out and back in."})}),m&&i.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Ie.length===0?s.jsx(La,{icon:"⌕",title:i.length===0?"No tickets in the last 30 days":"No matching tickets",text:i.length===0?"Tickets appear here after an agent uses an authorized tool. Older tickets can be loaded below.":"Try adjusting your search or filters."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:Ie.length===i.length?`${i.length} ticket${i.length!==1?"s":""}`:`${Ie.length} of ${i.length} tickets`}),s.jsx("div",{className:"timeline",children:Ie.map(k=>{const O=k.userId?w[k.userId]:void 0;return s.jsx("div",{className:"timeline-event",children:s.jsx(b0,{receipt:k,manifests:l,localAuth:k.authorizationId?z[k.authorizationId]:void 0,localUnavailable:oe,signature:A[k.id],grantTitle:k.authorizationId?I[k.authorizationId]:null,ownerLabel:r==="team"&&k.userId?O?`${O.name} (${O.email})`:k.userId:null,spUrl:d,formatDate:C0,onOpenComplete:()=>q(k)})},k.id)})})]}),Y&&s.jsx(N0,{receipt:Y,onClose:()=>q(null)}),ne&&s.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:Z,disabled:he,children:he?"Loading…":"Load older"})})]})}const P0={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function I0(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(null),o=u.useCallback(async()=>{try{t(await R.getAutostart())}catch(d){i(d instanceof Error?d.message:"Could not read autostart state")}},[]);u.useEffect(()=>{o()},[o]);const l=u.useCallback(async()=>{if(!(!(e!=null&&e.supported)||n)){r(!0),i(null);try{await R.setAutostart(!e.installed)}catch(d){i(d instanceof Error?d.message:"Failed")}finally{try{t(await R.getAutostart()),i(null)}catch(d){i(d instanceof Error?d.message:"Could not re-read state")}r(!1)}}},[e,n,o]);if(!e)return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),s.jsx("p",{role:a?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:a?`Could not read autostart state: ${a}`:"Checking…"})]});const c=P0[e.platform]??"a login service";return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsxs("div",{children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Keep Suveren running"}),s.jsx("p",{style:{color:"var(--text-secondary)",margin:"0.5rem 0 0",fontSize:"0.9rem"},children:e.supported?s.jsxs(s.Fragment,{children:["Starts automatically when you log in, and restarts if it crashes. Uses ",c," — no admin rights needed."]}):e.reason})]}),e.supported&&s.jsx("button",{type:"button",onClick:()=>void l(),disabled:n,"aria-pressed":e.installed,className:e.installed?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:n?"Working…":e.installed?"Turn off":"Turn on"})]}),e.supported&&s.jsxs("p",{style:{margin:"1rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:["Status: ",s.jsx("strong",{children:e.installed?"On — starts from your next login":"Off"})]}),e.supported&&s.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 ",s.jsx("strong",{children:"locked"}),": you enter your API key once to unlock it, because nothing stored on this machine can unlock it for you."]}),a&&s.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger, #c00)"},children:a})]})}function A0(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(null),o=u.useCallback(async()=>{try{const c=await R.getGatewaySettings();t(c.desktopNotifications),i(null)}catch(c){i(c instanceof Error?c.message:"Could not read notification setting")}},[]);u.useEffect(()=>{o()},[o]);const l=u.useCallback(async()=>{if(!(e===null||n)){r(!0),i(null);try{const c=await R.setGatewaySettings({desktopNotifications:!e});t(c.desktopNotifications)}catch(c){i(c instanceof Error?c.message:"Failed to save"),await o()}finally{r(!1)}}},[e,n,o]);return e===null?s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),s.jsx("p",{role:a?"alert":void 0,style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:a?`Could not read the setting: ${a}`:"Checking…"})]}):s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsxs("div",{children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Desktop notifications"}),s.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."})]}),s.jsx("button",{type:"button",onClick:()=>void l(),disabled:n,"aria-pressed":e,className:e?"btn btn-secondary":"btn btn-primary",style:{whiteSpace:"nowrap"},children:n?"Saving…":e?"Turn off":"Turn on"})]}),a&&s.jsx("p",{role:"alert",style:{margin:"0.75rem 0 0",fontSize:"0.85rem",color:"var(--danger)"},children:a})]})}const _0={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 z0(){const{version:e,latestVersion:t,updateAvailable:n,installMethod:r}=Hl();return e?s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Version"}),s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:["Running ",s.jsx("strong",{children:e}),n&&t?s.jsxs(s.Fragment,{children:[" — ",s.jsx("strong",{children:t})," is available"]}):null]}),s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.85rem",color:"var(--text-tertiary)"},children:[_0[r]??"Update checking is unavailable",r==="dev"&&s.jsx(s.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Do({title:e}){return s.jsxs("span",{className:"it-locked-badge",title:e,children:[s.jsx("span",{className:"lock-icon","aria-hidden":"true",children:"🔒"})," Set by your IT"]})}function Eu(e){return e===!0}function $0(){const[e,t]=u.useState(null),[n,r]=u.useState(null);u.useEffect(()=>{let o=!1;return R.getAsPairing().then(l=>{o||t(l)}).catch(l=>{o||r(l instanceof Error?l.message:"Could not read Authority Server info")}),()=>{o=!0}},[]);const a=Eu(e==null?void 0:e.asUrlLockedByPolicy),i=Eu(e==null?void 0:e.pinTlsLockedByPolicy);return s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Authority Server"}),a&&s.jsx(Do,{})]}),!e&&!n&&s.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Checking…"}),n&&s.jsx("p",{role:"alert",style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--danger, #c00)"},children:n}),e&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[s.jsx("strong",{children:"URL:"})," ",s.jsx("code",{children:e.asUrl})]}),e.paired&&e.fingerprint?s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[s.jsx("strong",{children:"Key fingerprint:"})," ",s.jsx("code",{children:e.fingerprint}),s.jsx("br",{}),s.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."})]}):s.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)&&s.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:"0.9rem",color:"var(--text-secondary)"},children:[s.jsx("strong",{children:"TLS certificate pin:"})," ",i&&s.jsx(Do,{title:"TLS pinning is set by your IT policy"})," ",e.tlsPinFingerprint?s.jsx("code",{children:e.tlsPinFingerprint}):s.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)":""]}),s.jsx("br",{}),s.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:[e.pinTlsEnabled?s.jsxs(s.Fragment,{children:["TLS pinning is ON",i?s.jsx(s.Fragment,{children:", set by your organization's IT policy"}):s.jsxs(s.Fragment,{children:[" (",s.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."]}):s.jsxs(s.Fragment,{children:["Captured at sign-in; not currently enforced",i?s.jsx(s.Fragment,{children:" — controlled by your organization's IT policy on this computer"}):s.jsxs(s.Fragment,{children:[" (",s.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."]})]}),a?s.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."}):s.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:"," ",s.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 L0(e){if(!e||typeof e!="object")return{simulation:null,locked:!1};const t=Array.isArray(e.policyLocked)&&e.policyLocked.includes("simulation");return{simulation:typeof e.simulation=="boolean"?e.simulation:null,locked:t}}function M0(){const[e,t]=u.useState({simulation:null,locked:!1});return u.useEffect(()=>{let n=!1;return fetch("/health").then(r=>r.json()).then(r=>{n||t(L0(r))}).catch(()=>{}),()=>{n=!0}},[]),e}function F0(){const{simulation:e,locked:t}=M0();return t?s.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[s.jsxs("div",{children:[s.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,margin:0},children:"Simulation mode"}),s.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&&s.jsxs(s.Fragment,{children:[" ","Currently ",s.jsx("strong",{children:e?"ON":"OFF"}),e?" — real systems are not reachable from this gateway.":"."]})]})]}),s.jsx(Do,{})]}),s.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 O0={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"]}},zr=["AI Assistant","Authority Server","This computer","Security","Version"],$r={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function B0(){const[e,t]=u.useState(""),[n,r]=u.useState("openrouter"),[a,i]=u.useState("openai-compatible"),[o,l]=u.useState("https://openrouter.ai/api/v1"),[c,d]=u.useState("google/gemma-4-31b-it"),[f,m]=u.useState(""),[p,w]=u.useState(!1),[x,v]=u.useState(!1),[S,g]=u.useState(!1),[h,y]=u.useState(null),[j,b]=u.useState([]),[E,C]=u.useState(!1),[P,N]=u.useState(null),[_,M]=u.useState(""),V=u.useCallback(A=>{t(A),setTimeout(()=>t(""),3e3)},[]),J=u.useCallback(async(A,H,I)=>{C(!0),N(null);try{const F=await R.aiModels({provider:A,endpoint:H,...I?{apiKey:I}:{}});F.ok&&F.models.length>0?(b(F.models),N(`${F.models.length} models available`)):(b([]),N(F.message||"No models returned — using defaults"))}catch(F){b([]),N(F instanceof Error?F.message:"Failed to load models")}finally{C(!1)}},[]),B=u.useCallback(async()=>{try{const A=await R.getCredential("ai-config");if(w(A.configured),A.configured&&A.fields){const H=A.fields.provider||"openai-compatible",I=A.fields.endpoint||"";A.fields.provider&&i(H),A.fields.endpoint&&l(I),A.fields.model&&d(A.fields.model),I.includes("openai.com")?r("openai"):I.includes("groq.com")?r("groq"):I.includes("together.xyz")?r("together"):I.includes("openrouter.ai")?r("openrouter"):r("ollama"),I&&J(H,I)}}catch{}},[J]);u.useEffect(()=>{B()},[B]);const z=A=>{r(A),b([]),N(null),M("");const H=O0[A];H&&(i(H.provider),l(H.endpoint),d(""),J(H.provider,H.endpoint,f||void 0))},D=()=>J(a,o,f||void 0),oe=async()=>{v(!0);try{await R.setCredential("ai-config",{provider:a,endpoint:o,model:c,...f?{apiKey:f}:{}}),w(!0),V("AI configuration saved!")}catch{V("Failed to save AI config")}finally{v(!1)}},$=async()=>{g(!0),y(null);try{const A=await R.aiTest({provider:a,endpoint:o,model:c,...f?{apiKey:f}:{}});y(A.ok?`OK: ${A.message}`:`Failed: ${A.message}`)}catch(A){y(`Error: ${A instanceof Error?A.message:"Unknown"}`)}finally{g(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Settings"}),s.jsx("p",{className:"page-subtitle",children:"Your AI assistant, the connection to your Authority Server, security and version."})]}),e&&s.jsx("div",{className:"alert alert-success",children:e}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:$r,children:zr[0]}),s.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Advisory AI to help you think through intent when giving mandates."}),s.jsxs("div",{className:"card",children:[s.jsx("h3",{className:"card-title",children:"Configuration"}),s.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."}),p&&s.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[s.jsx("span",{className:"status-banner-icon",children:"✓"}),s.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsx("label",{className:"form-label",children:"Provider Preset"}),s.jsxs("select",{className:"form-input",value:n,onChange:A=>z(A.target.value),children:[s.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),s.jsx("option",{value:"ollama",children:"Ollama (local)"}),s.jsx("option",{value:"openai",children:"OpenAI"}),s.jsx("option",{value:"groq",children:"Groq"}),s.jsx("option",{value:"together",children:"Together"})]})]}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsxs("label",{className:"form-label",children:["API Key ",a==="ollama"?"(not needed for Ollama)":"(required to load models)"]}),s.jsx("input",{className:"form-input",type:"password",name:"ai-provider-api-key-credential-top",autoComplete:"new-password",value:f,onChange:A=>m(A.target.value),onBlur:()=>{f.trim()&&J(a,o,f.trim())},placeholder:p?"••••••••••••••••":"sk-... (not needed for Ollama)"}),s.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."})]}),s.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s.jsx("label",{className:"form-label",children:"Model"}),s.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.75rem",padding:"0.125rem 0.5rem"},onClick:D,disabled:E,title:"Re-fetch the model list from the provider",children:E?"Loading…":"↻ Refresh"})]}),j.length===0?s.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:E?"Loading models…":a==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const A=j,H=A.includes(c),I=A.length>12,F=_.trim().toLowerCase();let Y=F?A.filter(q=>q.toLowerCase().includes(F)):A;return H&&!Y.includes(c)&&(Y=[c,...Y]),s.jsxs(s.Fragment,{children:[I&&s.jsx("input",{className:"form-input",value:_,onChange:q=>M(q.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),s.jsxs("select",{className:"form-input",value:H?c:"__unset__",onChange:q=>d(q.target.value==="__unset__"?"":q.target.value),children:[s.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),Y.map(q=>s.jsx("option",{value:q,children:q},q)),F&&Y.length===0&&s.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",_,"”"]})]})]})})(),P&&s.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",margin:"0.375rem 0 0"},children:P})]}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[s.jsx("button",{className:"btn btn-primary",onClick:oe,disabled:x||!c.trim(),title:c.trim()?void 0:"Select a model first",children:x?"Saving...":"Save & Encrypt"}),p&&s.jsx("button",{className:"btn btn-ghost",onClick:$,disabled:S,children:S?"Testing...":"Test Connection"})]}),h&&s.jsx("div",{className:`alert ${h.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:h})]}),s.jsx(D0,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:$r,children:zr[1]}),s.jsx($0,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:$r,children:zr[2]}),s.jsx(I0,{}),s.jsx(A0,{}),s.jsx(F0,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:$r,children:zr[3]}),s.jsx("div",{className:"card",style:{padding:"1.5rem"},children:s.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[s.jsxs("div",{style:{marginBottom:"1rem"},children:[s.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),s.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[s.jsx("li",{children:"Every tool call verified against your mandate bounds"}),s.jsx("li",{children:"Credentials never exposed to agents through MCP"}),s.jsx("li",{children:"Every action produces a signed ticket"})]})]}),s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),s.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[s.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),s.jsx("li",{children:"For best security, run agents in sandboxed environments"}),s.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})})]}),s.jsxs("section",{children:[s.jsx("h2",{style:$r,children:zr[4]}),s.jsx(z0,{})]})]})}function D0(){const[e,t]=u.useState(null),[n,r]=u.useState({intent:"",context:""}),[a,i]=u.useState(null),[o,l]=u.useState(null),[c,d]=u.useState(null),[f,m]=u.useState(!1),p=u.useCallback(async()=>{if(!f)try{const v=await R.getAIPrompts();t(v),r({intent:v.intent.current,context:v.context.current}),m(!0)}catch(v){l(v instanceof Error?v.message:"Failed to load prompts")}},[f]),w=async v=>{if(e){i(v),l(null);try{const S=n[v],g=S.trim()===e[v].default.trim()?"":S;await R.setAIPrompt(v,g);const h=await R.getAIPrompts();t(h),r({intent:h.intent.current,context:h.context.current}),d(v),setTimeout(()=>d(null),2e3)}catch(S){l(S instanceof Error?S.message:"Save failed")}finally{i(null)}}},x=async v=>{if(confirm(`Revert ${v} prompt to the built-in default?`)){i(v),l(null);try{await R.setAIPrompt(v,"");const S=await R.getAIPrompts();t(S),r({intent:S.intent.current,context:S.context.current})}catch(S){l(S instanceof Error?S.message:"Revert failed")}finally{i(null)}}};return s.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:v=>{v.currentTarget.open&&p()},children:[s.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),s.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."}),o&&s.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:o}),!f&&!o&&s.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&s.jsxs(s.Fragment,{children:[s.jsx(Tu,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:e.intent,draft:n.intent,onChange:v=>r(S=>({...S,intent:v})),onSave:()=>w("intent"),onRevert:()=>x("intent"),saving:a==="intent",justSaved:c==="intent"}),s.jsx(Tu,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:e.context,draft:n.context,onChange:v=>r(S=>({...S,context:v})),onSave:()=>w("context"),onRevert:()=>x("context"),saving:a==="context",justSaved:c==="context"})]})]})}function Tu({kind:e,label:t,description:n,state:r,draft:a,onChange:i,onSave:o,onRevert:l,saving:c,justSaved:d}){const f=a!==r.current;return s.jsxs("section",{style:{marginBottom:"1.5rem"},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:t}),s.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:n})]}),r.overridden&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),s.jsx("textarea",{className:"form-textarea",value:a,onChange:m=>i(m.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":`${t} system prompt`}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[s.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:o,disabled:c||!f,children:c?"Saving…":"Save"}),r.overridden&&s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:l,disabled:c,title:"Discard the override and use the built-in default",children:"Revert to default"}),d&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),f&&!c&&!d&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),s.jsxs("details",{style:{marginTop:"0.5rem"},children:[s.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),s.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:r.default})]}),s.jsx("span",{style:{display:"none"},children:e})]})}function U0(e){return e.proposalId?"review":"automatic"}function Ru(e,t,n={}){const r=n.status??"pending",a=n.includeAutonomous??!1,i=[];for(const o of e)r==="pending"&&o.status!=="pending"||n.profile&&o.profileId!==n.profile||i.push({kind:"proposal",id:o.id,sortTimestamp:o.createdAt,commitmentMode:"review",profileId:o.profileId,proposal:o});if(r==="all")for(const o of t){const l=U0(o);!a&&l==="automatic"||n.profile&&o.profileId!==n.profile||i.push({kind:"receipt",id:o.id,sortTimestamp:o.timestamp,commitmentMode:l,profileId:o.profileId,receipt:o})}return i.sort((o,l)=>l.sortTimestamp-o.sortTimestamp),typeof n.limit=="number"&&n.limit>0?i.slice(0,n.limit):i}const W0=["https://","http://"];function Bm(e,t){return e!=null&&e.length?e.flatMap(n=>{const r=n.template.replace(/\{(\w+)\}/g,(a,i)=>{const o=t[i];return typeof o=="string"||typeof o=="number"?String(o):"\0"});return r.includes("\0")||/\{|\}/.test(r)?[]:W0.some(a=>r.toLowerCase().startsWith(a))?[{label:n.label,href:r,description:n.description}]:[]}):[]}function H0({profileId:e}){return s.jsx("span",{className:"profile-badge",children:Pe(e)})}function Dm(e,t){const n=e-Math.floor(t/1e3);if(n<=0)return{label:"expired",urgent:!1,expired:!0};const r=Math.floor(n/86400),a=Math.floor(n%86400/3600),i=Math.floor(n%3600/60);let o;return r>0?o=`expires in ${r}d ${a}h`:a>0?o=`expires in ${a}h ${i}m`:o=`expires in ${Math.max(1,i)}m`,{label:o,urgent:n<2*3600,expired:!1}}const V0=new Set(["receipt_id","apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function Um(e){const t=e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function G0(e){return Array.isArray(e)?"list":e&&typeof e=="object"?"object":typeof e=="string"&&(e.includes(`
75
- `)||e.length>120)?"markdown":"text"}function K0(e,t){var o,l;const n=(t==null?void 0:t.approvalView)??{},r=((o=t==null?void 0:t.inputSchema)==null?void 0:o.properties)??{},a=[...new Set([...Object.keys(n),...Object.keys(r),...Object.keys(e)])],i=[];for(const c of a){if(!(c in e)||V0.has(c))continue;const d=e[c],f=n[c]??{},m=f.kind??G0(d),p={key:c,label:f.label??Um(c),kind:m,value:d,hint:(l=r[c])==null?void 0:l.description};m==="money"&&f.currencyArg&&typeof e[f.currencyArg]=="string"&&(p.currency=e[f.currencyArg]),m==="profile"&&typeof d=="string"&&(p.profileRef=d),(m==="profile-limits"||m==="profile-scope")&&f.profileArg&&typeof e[f.profileArg]=="string"&&(p.profileRef=e[f.profileArg]),i.push(p)}return i}function Y0(e,t,n){if(!e||typeof e!="object"||Array.isArray(e))return[];const r=n==="limits"?t==null?void 0:t.boundsSchema:t==null?void 0:t.contextSchema,a=(r==null?void 0:r.fields)??{},i=[...new Set([...(r==null?void 0:r.keyOrder)??[],...Object.keys(e)])],o=[];for(const l of i){if(l==="profile"||!(l in e))continue;const c=e[l],d=a[l],f=Im(d==null?void 0:d.unit),m=Array.isArray(c)?c.join(", "):String(c);o.push({key:l,label:(d==null?void 0:d.displayName)??Um(l),value:f?`${m} ${f}`:m,hint:d==null?void 0:d.description,unknown:t?!d:void 0})}return o}const Pu=new Map;function Q0(e){let t=Pu.get(e);return t||(t=(async()=>{try{let n=e;if(!e.includes("@")){const r=await R.listProfiles(),a=o=>o.replace(/@.*$/,"").split("/").pop(),i=r.filter(o=>a(o.id)===e).sort((o,l)=>(l.id.split("@")[1]??"").localeCompare(o.id.split("@")[1]??"",void 0,{numeric:!0}));if(!i[0])return null;n=i[0].id}return await R.getProfile(n)}catch{return null}})(),Pu.set(e,t)),t}function Wm(e){const[t,n]=u.useState(null);return u.useEffect(()=>{let r=!0;return e&&Q0(e).then(a=>{r&&n(a)}),()=>{r=!1}},[e]),t}const J0=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function X0(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:J0.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function Hn(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 Iu({row:e,which:t}){const n=Wm(e.profileRef),r=Y0(e.value,n,t);return r.length===0?s.jsx("span",{style:{color:"var(--text-tertiary)"},children:"none"}):s.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.15rem 0.75rem",margin:0},children:r.map(a=>s.jsxs(u.Fragment,{children:[s.jsx("dt",{style:{color:"var(--text-secondary)"},title:a.hint,children:a.label}),s.jsxs("dd",{style:{margin:0,fontWeight:600},children:[a.value,a.unknown&&s.jsx("span",{style:{color:"var(--danger)",fontWeight:400,marginLeft:"0.5rem"},children:"not defined by this profile"})]})]},a.key))})}function q0({row:e}){const t=Wm(e.profileRef),n=(t==null?void 0:t.id)??e.profileRef??"";return s.jsxs(s.Fragment,{children:[(t==null?void 0:t.name)??Pe(n),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:n})]})}function Z0({row:e,altText:t}){switch(e.kind){case"profile":return s.jsx(q0,{row:e});case"profile-limits":return s.jsx(Iu,{row:e,which:"limits"});case"profile-scope":return s.jsx(Iu,{row:e,which:"scope"});case"markdown":return s.jsx("div",{style:{whiteSpace:"pre-wrap",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.625rem"},children:Hn(e.value)});case"list":return Array.isArray(e.value)?s.jsx("ul",{style:{margin:0,paddingLeft:"1.1rem"},children:e.value.map((n,r)=>s.jsx("li",{children:Hn(n)},r))}):s.jsx(s.Fragment,{children:Hn(e.value)});case"money":return s.jsxs(s.Fragment,{children:[Hn(e.value),e.currency?` ${e.currency}`:""]});case"object":return s.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"0.8rem"},children:Hn(e.value)});default:return X0(e.key,e.value)?s.jsx("img",{src:e.value,alt:t??e.key,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}}):s.jsx(s.Fragment,{children:Hn(e.value)})}}function Hm({args:e,display:t}){const n=K0(e,t);if(n.length===0)return null;const r=typeof e.altText=="string"?e.altText:void 0;return s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Details"}),s.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.35rem 0.75rem",fontSize:"0.85rem",margin:0},children:n.map(a=>s.jsxs(u.Fragment,{children:[s.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},title:a.hint,children:a.label}),s.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:s.jsx(Z0,{row:a,altText:r})})]},a.key))})]})}const ew={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},tw={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function nw(e){const t=Date.now()-e*1e3,n=t/36e5;return n<48?n<1?`${Math.max(1,Math.round(t/6e4))}m ago`:`${Math.round(n)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function rw(e){return e.split("__").pop()??e}function sw(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}function Vm(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(t=>Vm(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Au({item:e,onApprove:t,onReject:n,resolving:r,proposalLinks:a,toolDisplay:i}){const o=e.kind==="proposal",l=o?e.proposal.status:"executed",c=o?e.proposal.tool:e.receipt.action,d=rw(c),f=sw(c),m=o?e.proposal.toolArgs:null,p=o?e.proposal.executionContext:e.receipt.executionContext,w=o?null:e.receipt.cumulativeState,x=o?Bm(a,e.proposal.toolArgs):[],v=Object.entries(p??{});return s.jsxs("div",{className:"card",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[s.jsx(H0,{profileId:e.profileId}),s.jsx("code",{style:{fontSize:"0.85rem"},children:d}),e.commitmentMode==="automatic"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),s.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[o&&l==="pending"&&(()=>{const S=Dm(e.proposal.expiresAt,Date.now());return s.jsx("span",{style:{fontSize:"0.72rem",color:S.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:S.urgent?600:400,whiteSpace:"nowrap"},children:S.label})})(),s.jsx("span",{className:`status-badge ${tw[l]}`,children:ew[l]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:nw(e.sortTimestamp)})]})]}),f&&s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",color:"var(--warning)",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:[s.jsx("span",{children:"⚠"}),s.jsx("span",{children:"Irreversible action"})]}),o&&typeof(m==null?void 0:m._imagePreview)=="string"&&s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),s.jsx("img",{src:m._imagePreview,alt:typeof(m==null?void 0:m.altText)=="string"?m.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),x.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:x.map(S=>s.jsxs("a",{href:S.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:S.description??S.href,children:[S.label," ↗"]},S.label))}),o&&m&&s.jsx(Hm,{args:m,display:i}),v.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:v.map(([S,g])=>`${S}=${Vm(g)}`).join(" · ")}),w&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",w.daily.count," action",w.daily.count===1?"":"s",w.daily.amount>0?`, ${w.daily.amount}`:""," · ","this month: ",w.monthly.count,w.monthly.amount>0?`, ${w.monthly.amount}`:""]}),o&&l==="pending"&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:()=>t==null?void 0:t(e.id),disabled:r,children:r?"Approving…":"Approve"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:()=>n==null?void 0:n(e.id),disabled:r,children:"Reject"})]}),s.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[o?"Proposal":"Ticket",": ",e.id]})]})}function Gm(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(t=>Gm(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function aw(e){const t=Date.now()-e*1e3,n=Math.floor(t/6e4);if(n<60)return`${Math.max(1,n)}m ago`;const r=Math.floor(t/36e5);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function iw({proposal:e,currentUserId:t,onAction:n,onMessage:r,proposalLinks:a,toolDisplay:i}){const[o,l]=u.useState(!1),[c,d]=u.useState(!1),[f,m]=u.useState(null),[p,w]=u.useState(!1),[x,v]=u.useState(null),[S,g]=u.useState(!1),h=e.tool.split("__").pop()??e.tool,y=Object.entries(e.executionContext),j=Bm(a,e.toolArgs),b=e.pendingApprovers??[],E=e.approvedBy??{},C=Object.keys(E).length,P=b.filter(z=>!(z in E)).length,N=t in E,_=async()=>{if(f===null){w(!0),v(null);try{const z=await R.getAttestationIntent(e.authorizationId);if(!z){v("Intent not available or you are not an authorized approver.");return}const D=await R.decryptIntent({intentCiphertext:z.intentCiphertext,encryptedKey:z.encryptedKey,approverId:t});m(D)}catch(z){v(z instanceof Error?z.message:"Failed to decrypt intent")}finally{w(!1)}}},M=async()=>{S?g(!1):(g(!0),await _())},V=async()=>{l(!0),r("");try{await R.approveProposal(e.id);try{if(f===null){const z=await R.getAttestationIntent(e.authorizationId);if(z){const D=await R.decryptIntent({intentCiphertext:z.intentCiphertext,encryptedKey:z.encryptedKey,approverId:t});m(D),await R.storeApprovedIntent(e.authorizationId,D)}}else await R.storeApprovedIntent(e.authorizationId,f)}catch{}r(`Approved. ${P-1>0?`${P-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(z){r(z instanceof Error?z.message:"Approval failed")}finally{l(!1)}},J=async()=>{const z=prompt("Rejection reason (optional):");if(z!==null){d(!0),r("");try{await R.rejectProposal(e.id,z||void 0),r("Action rejected."),n()}catch(D){r(D instanceof Error?D.message:"Rejection failed")}finally{d(!1)}}},B=o||c;return s.jsxs("div",{className:"card",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[s.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:Pe(e.profileId)}),s.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),s.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const z=Dm(e.expiresAt,Date.now());return s.jsx("span",{style:{fontSize:"0.72rem",color:z.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:z.urgent?600:400,whiteSpace:"nowrap"},children:z.label})})(),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:aw(e.createdAt)})]})]}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[C," of ",b.length," approver",b.length===1?"":"s"," signed off",b.map(z=>{const D=z in E;return s.jsxs("span",{style:{marginLeft:"0.5rem",color:D?"var(--success, green)":"var(--text-tertiary)"},children:[D?"✓":"○"," ",z===t?"You":z]},z)})]}),s.jsxs("div",{style:{marginBottom:"0.5rem"},children:[s.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Proposed action"}),s.jsx("code",{style:{fontSize:"0.85rem"},children:h})]}),j.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:j.map(z=>s.jsxs("a",{href:z.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:z.description??z.href,children:[z.label," ↗"]},z.label))}),s.jsx(Hm,{args:e.toolArgs,display:i}),y.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:y.map(([z,D])=>`${z}=${Gm(D)}`).join(" · ")}),s.jsxs("div",{style:{marginBottom:"0.75rem"},children:[s.jsxs("button",{className:"btn btn-ghost btn-sm",style:{padding:"0.2rem 0",fontSize:"0.75rem"},onClick:M,disabled:p,children:[S?"▲ Hide intent":"▼ Show intent",p&&" (decrypting...)"]}),S&&s.jsx("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-main)",borderRadius:"0.375rem",border:"1px solid var(--border)"},children:x?s.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:x}):f!==null?s.jsx("p",{style:{fontSize:"0.85rem",margin:0,whiteSpace:"pre-wrap",color:"var(--text-primary)"},children:f}):s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]}),!N&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:V,disabled:B,children:o?"Approving...":"Approve"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:J,disabled:B,children:c?"Rejecting...":"Reject"})]}),N&&s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),s.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})}function ow(){const{domain:e,user:t}=Be(),n=(t==null?void 0:t.id)??"",[r,a]=u.useState("awaiting-me"),[i,o]=u.useState([]),[l,c]=u.useState([]),[d,f]=u.useState({}),[m,p]=u.useState(!0),[w,x]=u.useState(""),v=u.useCallback(async()=>{try{const W=await R.getProposalsForApprover();o(W)}catch{}finally{p(!1)}},[]);ge("proposal-added",v),ge("proposal-approved",v),ge("proposal-rejected",v),ge("proposal-resolved",v),It(v,3e4);const[S,g]=u.useState([]),h=u.useCallback(async()=>{try{const W=await R.getMyProposals(e);g(W)}catch{}},[e]);ge("proposal-added",h),ge("proposal-approved",h),ge("proposal-rejected",h),ge("proposal-resolved",h),It(h,3e4,e);const y=u.useMemo(()=>S.filter(W=>{var Z;return W.status==="pending"&&(((Z=W.pendingApprovers)==null?void 0:Z.length)??0)===0}),[S]),j=u.useMemo(()=>Ru(y,[],{status:"pending"}),[y]),[b,E]=u.useState([]),C=u.useCallback(async()=>{if(n)try{const Z=(await R.getMyProposals(e)).filter(se=>se.status==="pending"&&se.pendingApprovers&&se.pendingApprovers.includes(n)&&se.approvedBy&&n in se.approvedBy);E(Z)}catch{}},[n,e]);ge("proposal-approved",C),ge("proposal-rejected",C),It(C,3e4,`${n}:${e}`),u.useEffect(()=>{R.getIntegrationManifests().then(W=>c(W.manifests??[])).catch(()=>{}),R.getToolDisplay().then(f).catch(()=>{})},[]);const P=W=>{var Z;return(Z=l.find(se=>se.id===W.split("__")[0]))==null?void 0:Z.proposalLinks};u.useEffect(()=>{v(),h(),C()},[]);const[N,_]=u.useState([]),[M,V]=u.useState([]),[J,B]=u.useState(!0),[z,D]=u.useState(null),[oe,$]=u.useState(""),[A,H]=u.useState("pending"),[I,F]=u.useState(null),[Y,q]=u.useState(!1),ne=u.useCallback(async()=>{try{const{proposals:W,receipts:Z}=await R.getThread({domain:e,status:A,sinceDays:7});_(W),V(Z)}catch{}finally{B(!1)}},[e,A]);It(ne,3e4,`${e}:${A}`);const ce=async(W,Z)=>{D(W),$("");try{const se=N.find(Ie=>Ie.id===W)??S.find(Ie=>Ie.id===W),Te=av(se,e),Ve=await R.resolveProposal(W,Z,Te);$(Z==="commit"?`Action approved. Status: ${Ve.status}`:"Action rejected."),await Promise.all([ne(),h()])}catch(se){$(se instanceof Error?se.message:"Failed")}finally{D(null)}},he=u.useMemo(()=>{const W=new Set;for(const Z of N)W.add(Z.profileId);for(const Z of M)W.add(Z.profileId);return Array.from(W).sort()},[N,M]),te=u.useMemo(()=>Ru(N,M,{status:A,profile:I??void 0,includeAutonomous:Y}),[N,M,A,I,Y]),ue=u.useCallback(()=>{v(),C()},[v,C]),ae=u.useMemo(()=>{const W=new Set,Z=[];for(const se of b)W.has(se.id)||(W.add(se.id),Z.push(se));return Z.sort((se,Te)=>Te.createdAt-se.createdAt)},[b]),K=i.length+j.length,fe=ae.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Pending Approvals"}),s.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."})]}),s.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[s.jsxs("button",{className:`nav-tab${r==="awaiting-me"?" active":""}`,onClick:()=>a("awaiting-me"),children:["Awaiting me ",K>0&&s.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--warning)",color:"var(--bg-elevated)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:K})]}),s.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>a("awaiting-others"),children:["Awaiting others ",fe>0&&s.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--border)",color:"var(--text-secondary)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:fe})]}),s.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{a("all"),ne()},children:"All"})]}),r==="awaiting-me"&&s.jsx(s.Fragment,{children:m&&K===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):K===0?s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[s.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(w||oe)&&s.jsx("div",{className:"alert alert-success",children:w||oe}),j.map(W=>s.jsx(Au,{proposalLinks:W.kind==="proposal"?P(W.proposal.tool):void 0,toolDisplay:W.kind==="proposal"?d[W.proposal.tool]:void 0,item:W,onApprove:Z=>ce(Z,"commit"),onReject:Z=>ce(Z,"reject"),resolving:z===W.id},W.id)),i.map(W=>s.jsx(iw,{proposal:W,currentUserId:n,onAction:ue,onMessage:x,proposalLinks:P(W.tool),toolDisplay:d[W.tool]},W.id))]})}),r==="awaiting-others"&&s.jsx(s.Fragment,{children:ae.length===0?s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[s.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:ae.map(W=>s.jsx(cw,{proposal:W,currentUserId:n,onCancel:async()=>{try{await R.rejectProposal(W.id,"cancelled by creator"),C(),h()}catch(Z){alert(Z instanceof Error?Z.message:"Cancel failed")}}},W.id))})}),r==="all"&&s.jsxs(s.Fragment,{children:[oe&&s.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:oe}),s.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[s.jsx("button",{className:`filter-chip ${A==="pending"?"selected":""}`,onClick:()=>H("pending"),children:"Pending"}),s.jsx("button",{className:`filter-chip ${A==="all"?"selected":""}`,onClick:()=>H("all"),children:"All"}),he.length>0&&s.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),he.map(W=>s.jsx("button",{className:`filter-chip ${I===W?"selected":""}`,onClick:()=>F(I===W?null:W),children:Pe(W)},W)),A==="all"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),s.jsxs("button",{className:`filter-chip ${Y?"selected":""}`,onClick:()=>q(!Y),title:"Include actions executed without human review (automatic commitment mode)",children:[Y?"✓ ":"","Autonomous actions"]})]})]}),J&&te.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):te.length===0?s.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[s.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:A==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:A==="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."})]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:te.map(W=>s.jsx(Au,{proposalLinks:W.kind==="proposal"?P(W.proposal.tool):void 0,toolDisplay:W.kind==="proposal"?d[W.proposal.tool]:void 0,item:W,onApprove:Z=>ce(Z,"commit"),onReject:Z=>ce(Z,"reject"),resolving:z===W.id},W.id))})]})]})}function lw(e){const t=Date.now()-e*1e3,n=Math.floor(t/6e4);if(n<60)return`${Math.max(1,n)}m ago`;const r=Math.floor(t/36e5);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function cw({proposal:e,currentUserId:t,onCancel:n}){var d;const[r,a]=u.useState(!1),i=Object.keys(e.approvedBy??{}),o=(e.pendingApprovers??[]).filter(f=>!(f in(e.approvedBy??{}))),l=(((d=e.pendingApprovers)==null?void 0:d.length)??0)>0,c=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){a(!0);try{await n()}finally{a(!1)}}};return s.jsxs("div",{className:"card",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[s.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:Pe(e.profileId)}),l&&s.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),s.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:lw(e.createdAt)})]}),s.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:s.jsx("code",{children:e.tool.split("__").pop()??e.tool})}),l&&s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[i.map(f=>s.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:f===t?"You approved":`${f} approved`},f)),o.map(f=>s.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",f===t?"you":f]},f))]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:s.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:c,disabled:r,children:r?"Cancelling...":"Cancel"})})]})}const uw=`# Agent Brief
76
-
77
- You act on my behalf through Suveren — the gateway that gates every
78
- privileged tool call you make. Suveren implements the bounded-authority
79
- model from the open Human Agency Protocol (HAP): each mandate
80
- describes an area of authority, a set of numeric limits, and a scope.
81
- Operate inside those bounds or the Gatekeeper will reject your action.
82
-
83
- ## Before you act in a domain
84
-
85
- 1. Call \`list-authorizations(domain: "<domain>")\` to load the full
86
- intent, scope, and usage for that area. The session brief shows only
87
- a one-line summary per mandate — the Intent paragraph lives behind
88
- that call, and often contains soft rules you MUST honor (e.g. "never
89
- publish on weekends", "only reply in English").
90
- 2. If the action would exceed a bound or fall outside the scope, stop
91
- and explain what would be blocked instead of trying.
92
- 3. If you're not sure whether an action is covered, ask me first.
93
-
94
- ## How to handle reviews
95
-
96
- Mandates in review mode require my approval before the action
97
- executes. When you propose an action:
98
- - Include everything I need to judge it (title, recipients, amounts,
99
- dates, attendees) in the tool arguments.
100
- - Don't batch unrelated proposals — one proposal per decision.
101
-
102
- ## Standing orders
103
-
104
- (Add your own here. Examples:)
105
-
106
- - Every morning, summarize today's calendar and flag conflicts.
107
- - On Fridays, give me a weekly review: what's done, what slipped, what's
108
- next.
109
- - Never email anyone outside the company without asking first.
110
- - When drafting posts, prefer plain language over marketing copy.
111
- `;function dw(){const[e,t]=u.useState(""),[n,r]=u.useState(""),[a,i]=u.useState(!0),[o,l]=u.useState(!1),[c,d]=u.useState(null),[f,m]=u.useState(!1),p=e!==n,w=new Blob([e]).size,x=16*1024;u.useEffect(()=>{if(!p)return;const h=j=>{j.preventDefault(),j.returnValue=""},y=j=>{var C,P;if(j.defaultPrevented||j.button!==0||j.metaKey||j.ctrlKey||j.shiftKey||j.altKey)return;const b=(P=(C=j.target)==null?void 0:C.closest)==null?void 0:P.call(C,"a");if(!b||!b.href)return;let E;try{E=new URL(b.href)}catch{return}E.origin===window.location.origin&&E.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(j.preventDefault(),j.stopPropagation()))};return window.addEventListener("beforeunload",h),document.addEventListener("click",y,!0),()=>{window.removeEventListener("beforeunload",h),document.removeEventListener("click",y,!0)}},[p]),u.useEffect(()=>{let h=!1;return R.getAgentContext().then(y=>{h||(t(y),r(y))}).catch(y=>{h||d({kind:"error",text:y instanceof Error?y.message:"Failed to load context"})}).finally(()=>{h||i(!1)}),()=>{h=!0}},[]);const v=async()=>{l(!0),d(null);try{await R.saveAgentContext(e),r(e),d({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(h){d({kind:"error",text:h instanceof Error?h.message:"Save failed"})}finally{l(!1)}},S=()=>{t(n),d(null)},g=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(uw)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"page-header",children:[s.jsx("h1",{className:"page-title",children:"Agent Brief"}),s.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()&&!a&&s.jsx("button",{className:"btn btn-primary btn-sm",onClick:g,disabled:o,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),c&&s.jsx("div",{className:c.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:c.text}),s.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[s.jsx("div",{className:"card intent-pane chat",children:s.jsx(za,{target:{kind:"context"},currentText:e,onApply:h=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(h)},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…"})}),s.jsxs("div",{className:"card intent-pane document",children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[s.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),s.jsxs("span",{style:{fontSize:"0.75rem",color:w>x?"var(--danger)":"var(--text-muted)"},children:[w.toLocaleString()," / ",x.toLocaleString()," bytes"]})]}),s.jsx("textarea",{className:"form-textarea",value:e,onChange:h=>t(h.target.value),placeholder:a?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:a,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),s.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[s.jsx("button",{className:"btn btn-ghost",onClick:S,disabled:o||!p,children:"Revert"}),s.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:v,disabled:o||!p||w>x||a,children:o?"Saving…":"Save"})]})]}),s.jsx("button",{type:"button",className:"floating-help",onClick:()=>m(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),s.jsx(Am,{open:f,onClose:()=>m(!1),ariaLabel:"Brief assistant",children:s.jsx(za,{target:{kind:"context"},currentText:e,onApply:h=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(h),m(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function fw(e){const t=/<h1[^>]*>([\s\S]*?)<\/h1>/i.exec(e);return t&&t[1].replace(/<[^>]+>/g,"").trim()||"Report"}function mw(e){const t=e.find(a=>{var i;return a.kind==="sv-mandate"&&a.status!=="unverifiable"&&typeof((i=a.data)==null?void 0:i.profile)=="string"});if(!t)return null;const n=t.data;if(typeof n.profileLabel=="string"&&n.profileLabel)return n.profileLabel;const r=n.profile.split("@")[0].split("/").pop();return r?r.charAt(0).toUpperCase()+r.slice(1):null}function pw(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function hw(e,t){const n=t.emailExportError?"cases unknown":`${t.coveredCases.length}/${t.loadedCases.length} cases`;return`${e.signaturesValid>0?`${e.signaturesValid} ✓ tickets`:`${e.signaturesValid} tickets`} · ${n} · ${t.ticketsReferenced.length}/${t.ticketsInPeriod.length} tickets covered`}function gw(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 yw(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 _u(e,t="none in this report"){return e>0?{kind:"ok",text:`${e} ✓`}:{kind:"neutral",text:t}}const vw=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Km(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return"unknown time";const n=new Date(t*1e3),r=String(n.getHours()).padStart(2,"0"),a=String(n.getMinutes()).padStart(2,"0");return`${n.getDate()} ${vw[n.getMonth()]}, ${r}:${a}`}function xw(e){if(typeof e!="string"||!e.trim())return;const t=/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}/.test(e)&&!/[zZ]|[+-]\d{2}:?\d{2}$/.test(e)?`${e.replace(" ","T")}Z`:e,n=Date.parse(t);return Number.isFinite(n)?Math.floor(n/1e3):void 0}function Fi(e){const t=e<0?"-":"",[n,r]=Math.abs(e).toString().split(".");return t+n.replace(/\B(?=(\d{3})+(?!\d))/g," ")+(r?`.${r}`:"")}const ww={EUR:"€",USD:"$",GBP:"£"};function jw(e,t){const n=typeof e=="number"?e:Number(e);if(!Number.isFinite(n))return String(e??"");if(!t)return Fi(n);const r=t.toUpperCase(),a=ww[r];return a?`${a} ${Fi(n)}`:`${r} ${Fi(n)}`}const Sw=new Set(["received_at","created_at","sent_at"]);function kw(e,t){const n=t[e];if(n==null||n===""||e==="currency")return null;if(e==="net_total")return jw(n,typeof t.currency=="string"?t.currency:void 0);if(Sw.has(e)){const r=xw(n);return r!==void 0?Km(r):String(n)}return typeof n=="object"?JSON.stringify(n):String(n)}function bw(e){const t=[];return e.missingCases.length>0&&t.push(`cases ${e.missingCases.join(", ")}`),e.ticketsNotReferenced.length>0&&t.push(`${e.ticketsNotReferenced.length} ticket${e.ticketsNotReferenced.length===1?"":"s"}`),t.length>0?`Not in the report: ${t.join(" · ")}`:null}function Nw(e,t){var n;if(t)return t;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 r=(n=e.data)==null?void 0:n.goal;return(r==null?void 0:r.ticketId)??null}return null}function Cw(e){const t=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;">`;return/<head[^>]*>/i.test(e)?e.replace(/<head([^>]*)>/i,n=>`${n}${t}`):/<html[^>]*>/i.test(e)?e.replace(/<html([^>]*)>/i,n=>`${n}<head>${t}</head>`):`<!doctype html><html><head>${t}</head><body>${e}</body></html>`}const Jl={display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",margin:0,fontSize:"0.85rem"},Ew={Ticket:["ticketId","action","time","authorizationId","limitsUsed"],Mandate:["authorizationId","profile","rawLimits","ownersRaw"],Approval:["ticketId","who","createdAt","decidedAt","waitSeconds","status"]};function Tw(e,t){if(e==="Ticket")return[{label:"Action",value:String(t.actionLabel??t.action??"unknown")},{label:"When",value:String(t.timeLabel??Km(t.time))},{label:"Mandate",value:String(t.profileLabel??t.profile??"unknown")}];if(e==="Mandate"){const n=[{label:"Mandate",value:String(t.profileLabel??t.profile??"unknown")},{label:"Owners",value:Array.isArray(t.owners)&&t.owners.length>0?t.owners.join(", "):"unknown owner"}];return Array.isArray(t.limits)&&t.limits.length>0&&n.push({label:"Limits",value:t.limits.join(" · ")}),t.mode&&n.push({label:"Commitment mode",value:String(t.mode)}),t.intent&&n.push({label:"Intent",value:String(t.intent)}),n}return[{label:"Approved by",value:String(t.whoLabel??"unknown")},{label:"Asked",value:String(t.createdAtLabel??"unknown")},{label:"Approved",value:String(t.decidedAtLabel??"unknown")},{label:"Waited",value:String(t.waitLabel??"unknown")}]}function Rw(e,t){const n=Ew[e].filter(r=>t[r]!==void 0);return n.length===0?null:s.jsxs("details",{style:{marginTop:"0.5rem"},children:[s.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical details"}),s.jsx("dl",{style:{...Jl,marginTop:"0.5rem"},children:n.map(r=>s.jsxs("div",{style:{display:"contents"},children:[s.jsx("dt",{style:{color:"var(--text-muted)"},children:r}),s.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:typeof t[r]=="object"?JSON.stringify(t[r]):String(t[r])})]},r))})]})}function Oi(e,t){return t?s.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[s.jsx("div",{className:"card-title",children:e}),t.status==="unverifiable"?s.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",t.reason??"no further detail."]}):s.jsxs(s.Fragment,{children:[s.jsx("dl",{style:Jl,children:Tw(e,t.data??{}).map(({label:n,value:r})=>s.jsxs("div",{style:{display:"contents"},children:[s.jsx("dt",{style:{color:"var(--text-muted)"},children:n}),s.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:r})]},n))}),Rw(e,t.data??{})]})]}):null}function Pw({report:e,elementId:t,ticketParam:n,onClose:r}){const a=e.elements.find(l=>l.id===t),i=Nw(a,n),o=i?e.ticketDetails[i]:void 0;return s.jsxs("div",{className:"card",style:{marginTop:"1rem"},children:[s.jsxs("div",{className:"card-header",children:[s.jsx("div",{className:"card-title",children:"Details"}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:r,children:"Close"})]}),!a&&s.jsx("p",{className:"page-subtitle",children:"This element is no longer in the report."}),a&&!i&&(a.status==="unverifiable"?s.jsxs("p",{className:"page-subtitle",children:["✗ not verifiable — ",a.reason??"no further detail."]}):s.jsx("dl",{style:Jl,children:Object.keys(a.data??{}).map(l=>{const c=kw(l,a.data??{});return c===null?null:s.jsxs("div",{style:{display:"contents"},children:[s.jsx("dt",{style:{color:"var(--text-muted)"},children:l}),s.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:c})]},l)})})),o&&s.jsxs(s.Fragment,{children:[Oi("Ticket",o.ticket),Oi("Mandate",o.mandate),Oi("Approval",o.approval)]}),i&&!o&&s.jsxs("p",{className:"page-subtitle",children:["No local detail for ticket ",i,"."]})]})}async function Iw(e){const{html:t,filename:n}=await e.exportReport();e.download(t,n),await e.refresh()}function zu({detail:e}){return e?s.jsxs("details",{style:{marginTop:"0.25rem"},children:[s.jsx("summary",{style:{cursor:"pointer",fontSize:"0.8rem",color:"var(--text-muted)"},children:"Technical detail"}),s.jsx("p",{className:"page-subtitle",style:{marginTop:"0.25rem",wordBreak:"break-word"},children:e})]}):null}function Aw({report:e,open:t}){const{proof:n,coverage:r}=e,a=bw(r),i=gw(r),o=yw(r),l=_u(n.signaturesValid),c=_u(n.recordsChecked);return s.jsxs("div",{className:`reports-side${t?" reports-side-open":""}`,children:[s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"card-title",children:"Proof"}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Tickets referenced"}),s.jsx("b",{children:n.ticketsReferenced.length})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Signatures valid"}),s.jsx("b",{style:l.kind==="ok"?{color:"var(--success)"}:void 0,children:l.text})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Records checked"}),s.jsx("b",{style:c.kind==="ok"?{color:"var(--success)"}:void 0,children:c.text})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Not verifiable"}),s.jsx("b",{children:n.unverifiableCount})]})]}),s.jsxs("div",{className:"card",style:{marginTop:"0.75rem"},children:[s.jsx("div",{className:"card-title",children:"Coverage"}),i.kind==="error"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"reports-error",role:"alert",children:i.text}),s.jsx(zu,{detail:i.detail})]}):s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Cases"}),s.jsx("b",{children:i.text})]}),s.jsxs("div",{className:"reports-row",children:[s.jsx("span",{children:"Tickets in test period"}),s.jsxs("b",{children:[r.ticketsReferenced.length," of ",r.ticketsInPeriod.length]})]}),o&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:o.detail?"reports-error":"reports-note",role:o.detail?"alert":void 0,children:o.text}),s.jsx(zu,{detail:o.detail})]}),a&&s.jsx("p",{className:"reports-missing",children:a})]}),n.verifiedValues.length>0&&s.jsxs("div",{className:"card reports-checked-values",style:{marginTop:"0.75rem"},children:[s.jsx("div",{className:"card-title",children:"Checked values"}),n.verifiedValues.map(d=>s.jsx("div",{className:"reports-row",children:s.jsx("span",{children:d.summary})},d.elementId))]})]})}function _w(){const[e,t]=u.useState(null),[n,r]=u.useState(!0),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(!1),[f,m]=u.useState(null),[p,w]=u.useState(!1),[x,v]=Wl(),S=u.useCallback(()=>R.getReport().then(({report:N})=>t(N)).catch(N=>i(N instanceof Error?N.message:String(N))),[]),g=u.useCallback(()=>{r(!0),i(null),S().finally(()=>r(!1))},[S]);u.useEffect(()=>{g()},[g]);const h=u.useCallback(()=>{l(!0),R.recheckReport().then(({report:N})=>t(N)).catch(N=>i(N instanceof Error?N.message:String(N))).finally(()=>l(!1))},[]),y=u.useCallback(async()=>{d(!0),m(null);try{await Iw({exportReport:()=>R.exportReportWithProof(),download:(N,_)=>{const M=URL.createObjectURL(new Blob([N],{type:"text/html"})),V=document.createElement("a");V.href=M,V.download=_,V.click(),URL.revokeObjectURL(M)},refresh:S})}catch(N){m(N instanceof Error?N.message:String(N))}finally{d(!1)}},[S]),j=x.get("element"),b=x.get("ticket"),E=u.useCallback(()=>{const N=new URLSearchParams(x);N.delete("element"),N.delete("ticket"),v(N,{replace:!0})},[x,v]);if(n)return s.jsxs("div",{className:"page-inner",children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Reports"})}),s.jsx("p",{className:"page-subtitle",children:"Loading…"})]});if(a)return s.jsxs("div",{className:"page-inner",children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Reports"})}),s.jsx(La,{icon:"⚠",title:"Report unavailable",text:a})]});if(!e)return s.jsxs("div",{className:"page-inner",children:[s.jsx("div",{className:"page-header",children:s.jsx("h1",{className:"page-title",children:"Reports"})}),s.jsx(La,{icon:"▢",title:"No report yet",text:"No report yet — the AI writes it with the Reporting mandate."})]});const C=fw(e.renderedHtml),P=mw(e.elements);return s.jsx("div",{className:"page-inner reports-page",children:s.jsxs("div",{className:"reports-layout",children:[s.jsxs("div",{className:"reports-bar",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"page-title",children:C}),s.jsxs("p",{className:"page-subtitle",children:[P?`written by the AI under mandate ${P} · `:"","checked ",pw(e.checkedAt)]})]}),s.jsxs("div",{className:"reports-bar-actions",children:[s.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:h,disabled:o,children:o?"Checking…":"Check again"}),s.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:y,disabled:c,children:c?"Exporting…":"Export with proof"})]})]}),f&&s.jsxs("p",{className:"reports-error",role:"alert",style:{margin:"0.5rem 0 0 0"},children:["Export failed: ",f]}),s.jsxs("div",{className:"reports-summary-chip",children:[s.jsx("span",{children:hw(e.proof,e.coverage)}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>w(N=>!N),children:p?"hide":"details"})]}),s.jsxs("div",{className:"reports-grid",children:[s.jsxs("div",{children:[s.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."}),s.jsx("iframe",{title:"Report",sandbox:"allow-top-navigation-by-user-activation",srcDoc:Cw(e.renderedHtml),className:"reports-iframe"}),j&&s.jsx(Pw,{report:e,elementId:j,ticketParam:b,onClose:E})]}),s.jsx(Aw,{report:e,open:p})]})]})})}function Vn({to:e}){const{search:t,hash:n}=yt();return s.jsx(Ht,{to:`${e}${t}${n}`,replace:!0})}function zw({children:e}){const{user:t,mode:n,domain:r}=Be();return t?n==="team"&&!r?s.jsx(Ht,{to:"/onboarding",replace:!0}):s.jsx(s.Fragment,{children:e}):s.jsx(Ht,{to:"/login",replace:!0})}function $w(){const{user:e,handleSessionLocked:t}=Be();return ge("session-locked",n=>{const r=n==null?void 0:n.message;t(r)}),s.jsxs(ky,{children:[s.jsx(je,{path:"/login",element:e?s.jsx(Ht,{to:"/",replace:!0}):s.jsx(Yv,{})}),s.jsx(je,{path:"/onboarding",element:e?s.jsx(Qv,{}):s.jsx(Ht,{to:"/login",replace:!0})}),s.jsxs(je,{element:s.jsx(zw,{children:s.jsx(Kv,{})}),children:[s.jsx(je,{path:"/",element:s.jsx(fx,{})}),s.jsx(je,{path:"/mandates",element:s.jsx(g0,{})}),s.jsx(je,{path:"/mandates/new/intent",element:s.jsx(Mx,{})}),s.jsx(je,{path:"/mandates/new/sign",element:s.jsx(Kx,{})}),s.jsx(je,{path:"/integrations",element:s.jsx(e0,{})}),s.jsx(je,{path:"/team",element:s.jsx(t0,{})}),s.jsx(je,{path:"/tickets",element:s.jsx(R0,{})}),s.jsx(je,{path:"/approvals",element:s.jsx(ow,{})}),s.jsx(je,{path:"/reports",element:s.jsx(_w,{})}),s.jsx(je,{path:"/agent/new",element:s.jsx(Ht,{to:"/mandates?new=1",replace:!0})}),s.jsx(je,{path:"/agent/gate",element:s.jsx(Vn,{to:"/mandates/new/intent"})}),s.jsx(je,{path:"/agent/review",element:s.jsx(Vn,{to:"/mandates/new/sign"})}),s.jsx(je,{path:"/authorizations",element:s.jsx(Vn,{to:"/mandates"})}),s.jsx(je,{path:"/groups",element:s.jsx(Vn,{to:"/team"})}),s.jsx(je,{path:"/audit",element:s.jsx(Vn,{to:"/tickets"})}),s.jsx(je,{path:"/proposals",element:s.jsx(Vn,{to:"/approvals"})}),s.jsx(je,{path:"/agent-brief",element:s.jsx(dw,{})}),s.jsx(je,{path:"/settings",element:s.jsx(B0,{})}),s.jsx(je,{path:"/settings/services",element:s.jsx(Ht,{to:"/settings",replace:!0})}),s.jsx(je,{path:"/deploy",element:s.jsx(Ht,{to:"/integrations",replace:!0})})]}),s.jsx(je,{path:"*",element:s.jsx(Ht,{to:"/",replace:!0})})]})}function Lw(){return s.jsx(Yy,{children:s.jsx(lv,{children:s.jsx(cv,{children:s.jsx($w,{})})})})}Qf(document.getElementById("root")).render(s.jsx(u.StrictMode,{children:s.jsx(Lw,{})}));