@suveren/gateway 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
var Mm=Object.defineProperty;var Fm=(e,t,n)=>t in e?Mm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Sr=(e,t,n)=>Fm(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 o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();var Nu={exports:{}},za={},Eu={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 ms=Symbol.for("react.element"),Om=Symbol.for("react.portal"),Bm=Symbol.for("react.fragment"),Dm=Symbol.for("react.strict_mode"),Um=Symbol.for("react.profiler"),Wm=Symbol.for("react.provider"),Hm=Symbol.for("react.context"),Vm=Symbol.for("react.forward_ref"),Gm=Symbol.for("react.suspense"),Km=Symbol.for("react.memo"),Ym=Symbol.for("react.lazy"),Gl=Symbol.iterator;function Qm(e){return e===null||typeof e!="object"?null:(e=Gl&&e[Gl]||e["@@iterator"],typeof e=="function"?e:null)}var Tu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Iu=Object.assign,Ru={};function hr(e,t,n){this.props=e,this.context=t,this.refs=Ru,this.updater=n||Tu}hr.prototype.isReactComponent={};hr.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")};hr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Pu(){}Pu.prototype=hr.prototype;function Oi(e,t,n){this.props=e,this.context=t,this.refs=Ru,this.updater=n||Tu}var Bi=Oi.prototype=new Pu;Bi.constructor=Oi;Iu(Bi,hr.prototype);Bi.isPureReactComponent=!0;var Kl=Array.isArray,_u=Object.prototype.hasOwnProperty,Di={current:null},Au={key:!0,ref:!0,__self:!0,__source:!0};function zu(e,t,n){var r,a={},o=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(o=""+t.key),t)_u.call(t,r)&&!Au.hasOwnProperty(r)&&(a[r]=t[r]);var c=arguments.length-2;if(c===1)a.children=n;else if(1<c){for(var l=Array(c),d=0;d<c;d++)l[d]=arguments[d+2];a.children=l}if(e&&e.defaultProps)for(r in c=e.defaultProps,c)a[r]===void 0&&(a[r]=c[r]);return{$$typeof:ms,type:e,key:o,ref:i,props:a,_owner:Di.current}}function Jm(e,t){return{$$typeof:ms,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ui(e){return typeof e=="object"&&e!==null&&e.$$typeof===ms}function Xm(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Yl=/\/+/g;function to(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Xm(""+e.key):t.toString(36)}function Hs(e,t,n,r,a){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var i=!1;if(e===null)i=!0;else switch(o){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case ms:case Om:i=!0}}if(i)return i=e,a=a(i),e=r===""?"."+to(i,0):r,Kl(a)?(n="",e!=null&&(n=e.replace(Yl,"$&/")+"/"),Hs(a,t,n,"",function(d){return d})):a!=null&&(Ui(a)&&(a=Jm(a,n+(!a.key||i&&i.key===a.key?"":(""+a.key).replace(Yl,"$&/")+"/")+e)),t.push(a)),1;if(i=0,r=r===""?".":r+":",Kl(e))for(var c=0;c<e.length;c++){o=e[c];var l=r+to(o,c);i+=Hs(o,t,n,l,a)}else if(l=Qm(e),typeof l=="function")for(e=l.call(e),c=0;!(o=e.next()).done;)o=o.value,l=r+to(o,c++),i+=Hs(o,t,n,l,a);else if(o==="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 i}function js(e,t,n){if(e==null)return e;var r=[],a=0;return Hs(e,r,"","",function(o){return t.call(n,o,a++)}),r}function qm(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 Ze={current:null},Vs={transition:null},Zm={ReactCurrentDispatcher:Ze,ReactCurrentBatchConfig:Vs,ReactCurrentOwner:Di};function $u(){throw Error("act(...) is not supported in production builds of React.")}le.Children={map:js,forEach:function(e,t,n){js(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return js(e,function(){t++}),t},toArray:function(e){return js(e,function(t){return t})||[]},only:function(e){if(!Ui(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};le.Component=hr;le.Fragment=Bm;le.Profiler=Um;le.PureComponent=Oi;le.StrictMode=Dm;le.Suspense=Gm;le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Zm;le.act=$u;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=Iu({},e.props),a=e.key,o=e.ref,i=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,i=Di.current),t.key!==void 0&&(a=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in t)_u.call(t,l)&&!Au.hasOwnProperty(l)&&(r[l]=t[l]===void 0&&c!==void 0?c[l]:t[l])}var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){c=Array(l);for(var d=0;d<l;d++)c[d]=arguments[d+2];r.children=c}return{$$typeof:ms,type:e.type,key:a,ref:o,props:r,_owner:i}};le.createContext=function(e){return e={$$typeof:Hm,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:Wm,_context:e},e.Consumer=e};le.createElement=zu;le.createFactory=function(e){var t=zu.bind(null,e);return t.type=e,t};le.createRef=function(){return{current:null}};le.forwardRef=function(e){return{$$typeof:Vm,render:e}};le.isValidElement=Ui;le.lazy=function(e){return{$$typeof:Ym,_payload:{_status:-1,_result:e},_init:qm}};le.memo=function(e,t){return{$$typeof:Km,type:e,compare:t===void 0?null:t}};le.startTransition=function(e){var t=Vs.transition;Vs.transition={};try{e()}finally{Vs.transition=t}};le.unstable_act=$u;le.useCallback=function(e,t){return Ze.current.useCallback(e,t)};le.useContext=function(e){return Ze.current.useContext(e)};le.useDebugValue=function(){};le.useDeferredValue=function(e){return Ze.current.useDeferredValue(e)};le.useEffect=function(e,t){return Ze.current.useEffect(e,t)};le.useId=function(){return Ze.current.useId()};le.useImperativeHandle=function(e,t,n){return Ze.current.useImperativeHandle(e,t,n)};le.useInsertionEffect=function(e,t){return Ze.current.useInsertionEffect(e,t)};le.useLayoutEffect=function(e,t){return Ze.current.useLayoutEffect(e,t)};le.useMemo=function(e,t){return Ze.current.useMemo(e,t)};le.useReducer=function(e,t,n){return Ze.current.useReducer(e,t,n)};le.useRef=function(e){return Ze.current.useRef(e)};le.useState=function(e){return Ze.current.useState(e)};le.useSyncExternalStore=function(e,t,n){return Ze.current.useSyncExternalStore(e,t,n)};le.useTransition=function(){return Ze.current.useTransition()};le.version="18.3.1";Eu.exports=le;var u=Eu.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 ep=u,tp=Symbol.for("react.element"),np=Symbol.for("react.fragment"),rp=Object.prototype.hasOwnProperty,sp=ep.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ap={key:!0,ref:!0,__self:!0,__source:!0};function Lu(e,t,n){var r,a={},o=null,i=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(i=t.ref);for(r in t)rp.call(t,r)&&!ap.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:tp,type:e,key:o,ref:i,props:a,_owner:sp.current}}za.Fragment=np;za.jsx=Lu;za.jsxs=Lu;Nu.exports=za;var s=Nu.exports,Mu={exports:{}},pt={},Fu={exports:{}},Ou={};/**
|
|
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(L,$){var H=L.length;L.push($);e:for(;0<H;){var R=H-1>>>1,F=L[R];if(0<a(F,$))L[R]=$,L[H]=F,H=R;else break e}}function n(L){return L.length===0?null:L[0]}function r(L){if(L.length===0)return null;var $=L[0],H=L.pop();if(H!==$){L[0]=H;e:for(var R=0,F=L.length,Y=F>>>1;R<Y;){var X=2*(R+1)-1,te=L[X],ue=X+1,pe=L[ue];if(0>a(te,H))ue<F&&0>a(pe,te)?(L[R]=pe,L[ue]=H,R=ue):(L[R]=te,L[X]=H,R=X);else if(ue<F&&0>a(pe,H))L[R]=pe,L[ue]=H,R=ue;else break e}}return $}function a(L,$){var H=L.sortIndex-$.sortIndex;return H!==0?H:L.id-$.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,c=i.now();e.unstable_now=function(){return i.now()-c}}var l=[],d=[],f=1,p=null,m=3,w=!1,v=!1,x=!1,j=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(L){for(var $=n(d);$!==null;){if($.callback===null)r(d);else if($.startTime<=L)r(d),$.sortIndex=$.expirationTime,t(l,$);else break;$=n(d)}}function S(L){if(x=!1,y(L),!v)if(n(l)!==null)v=!0,B(k);else{var $=n(d);$!==null&&ne(S,$.startTime-L)}}function k(L,$){v=!1,x&&(x=!1,g(P),P=-1),w=!0;var H=m;try{for(y($),p=n(l);p!==null&&(!(p.expirationTime>$)||L&&!U());){var R=p.callback;if(typeof R=="function"){p.callback=null,m=p.priorityLevel;var F=R(p.expirationTime<=$);$=e.unstable_now(),typeof F=="function"?p.callback=F:p===n(l)&&r(l),y($)}else r(l);p=n(l)}if(p!==null)var Y=!0;else{var X=n(d);X!==null&&ne(S,X.startTime-$),Y=!1}return Y}finally{p=null,m=H,w=!1}}var N=!1,C=null,P=-1,E=5,z=-1;function U(){return!(e.unstable_now()-z<E)}function V(){if(C!==null){var L=e.unstable_now();z=L;var $=!0;try{$=C(!0,L)}finally{$?Q():(N=!1,C=null)}}else N=!1}var Q;if(typeof h=="function")Q=function(){h(V)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,A=D.port2;D.port1.onmessage=V,Q=function(){A.postMessage(null)}}else Q=function(){j(V,0)};function B(L){C=L,N||(N=!0,Q())}function ne(L,$){P=j(function(){L(e.unstable_now())},$)}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(L){L.callback=null},e.unstable_continueExecution=function(){v||w||(v=!0,B(k))},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(l)},e.unstable_next=function(L){switch(m){case 1:case 2:case 3:var $=3;break;default:$=m}var H=m;m=$;try{return L()}finally{m=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(L,$){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var H=m;m=L;try{return $()}finally{m=H}},e.unstable_scheduleCallback=function(L,$,H){var R=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?R+H:R):H=R,L){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,L={id:f++,callback:$,priorityLevel:L,startTime:H,expirationTime:F,sortIndex:-1},H>R?(L.sortIndex=H,t(d,L),n(l)===null&&L===n(d)&&(x?(g(P),P=-1):x=!0,ne(S,H-R))):(L.sortIndex=F,t(l,L),v||w||(v=!0,B(k))),L},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(L){var $=m;return function(){var H=m;m=$;try{return L.apply(this,arguments)}finally{m=H}}}})(Ou);Fu.exports=Ou;var op=Fu.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 ip=u,mt=op;function M(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 Bu=new Set,Qr={};function Bn(e,t){lr(e,t),lr(e+"Capture",t)}function lr(e,t){for(Qr[e]=t,e=0;e<t.length;e++)Bu.add(t[e])}var Yt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Lo=Object.prototype.hasOwnProperty,lp=/^[: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]*$/,Ql={},Jl={};function cp(e){return Lo.call(Jl,e)?!0:Lo.call(Ql,e)?!1:lp.test(e)?Jl[e]=!0:(Ql[e]=!0,!1)}function up(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 dp(e,t,n,r){if(t===null||typeof t>"u"||up(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 et(e,t,n,r,a,o,i){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=o,this.removeEmptyString=i}var He={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){He[e]=new et(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 et(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){He[e]=new et(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){He[e]=new et(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 et(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){He[e]=new et(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){He[e]=new et(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){He[e]=new et(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){He[e]=new et(e,5,!1,e.toLowerCase(),null,!1,!1)});var Wi=/[\-:]([a-z])/g;function Hi(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(Wi,Hi);He[t]=new et(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(Wi,Hi);He[t]=new et(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(Wi,Hi);He[t]=new et(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){He[e]=new et(e,1,!1,e.toLowerCase(),null,!1,!1)});He.xlinkHref=new et("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){He[e]=new et(e,1,!1,e.toLowerCase(),null,!0,!0)});function Vi(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")&&(dp(t,n,a,r)&&(n=null),r||a===null?cp(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=ip.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ks=Symbol.for("react.element"),Hn=Symbol.for("react.portal"),Vn=Symbol.for("react.fragment"),Gi=Symbol.for("react.strict_mode"),Mo=Symbol.for("react.profiler"),Du=Symbol.for("react.provider"),Uu=Symbol.for("react.context"),Ki=Symbol.for("react.forward_ref"),Fo=Symbol.for("react.suspense"),Oo=Symbol.for("react.suspense_list"),Yi=Symbol.for("react.memo"),sn=Symbol.for("react.lazy"),Wu=Symbol.for("react.offscreen"),Xl=Symbol.iterator;function jr(e){return e===null||typeof e!="object"?null:(e=Xl&&e[Xl]||e["@@iterator"],typeof e=="function"?e:null)}var Ee=Object.assign,no;function zr(e){if(no===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);no=t&&t[1]||""}return`
|
|
34
|
+
`+no+e}var ro=!1;function so(e,t){if(!e||ro)return"";ro=!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
|
+
`),o=r.stack.split(`
|
|
36
|
+
`),i=a.length-1,c=o.length-1;1<=i&&0<=c&&a[i]!==o[c];)c--;for(;1<=i&&0<=c;i--,c--)if(a[i]!==o[c]){if(i!==1||c!==1)do if(i--,c--,0>c||a[i]!==o[c]){var l=`
|
|
37
|
+
`+a[i].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}while(1<=i&&0<=c);break}}}finally{ro=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?zr(e):""}function fp(e){switch(e.tag){case 5:return zr(e.type);case 16:return zr("Lazy");case 13:return zr("Suspense");case 19:return zr("SuspenseList");case 0:case 2:case 15:return e=so(e.type,!1),e;case 11:return e=so(e.type.render,!1),e;case 1:return e=so(e.type,!0),e;default:return""}}function Bo(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 Vn:return"Fragment";case Hn:return"Portal";case Mo:return"Profiler";case Gi:return"StrictMode";case Fo:return"Suspense";case Oo:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Uu:return(e.displayName||"Context")+".Consumer";case Du:return(e._context.displayName||"Context")+".Provider";case Ki:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Yi:return t=e.displayName||null,t!==null?t:Bo(e.type)||"Memo";case sn:t=e._payload,e=e._init;try{return Bo(e(t))}catch{}}return null}function mp(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 Bo(t);case 8:return t===Gi?"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 Hu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function pp(e){var t=Hu(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,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function bs(e){e._valueTracker||(e._valueTracker=pp(e))}function Vu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Hu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function oa(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 Do(e,t){var n=t.checked;return Ee({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ql(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 Gu(e,t){t=t.checked,t!=null&&Vi(e,"checked",t,!1)}function Uo(e,t){Gu(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")?Wo(e,t.type,n):t.hasOwnProperty("defaultValue")&&Wo(e,t.type,xn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Zl(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 Wo(e,t,n){(t!=="number"||oa(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var $r=Array.isArray;function nr(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 Ho(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(M(91));return Ee({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function ec(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(M(92));if($r(n)){if(1<n.length)throw Error(M(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:xn(n)}}function Ku(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 tc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Yu(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 Vo(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Yu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Cs,Qu=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(Cs=Cs||document.createElement("div"),Cs.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Cs.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Jr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Or={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},hp=["Webkit","ms","Moz","O"];Object.keys(Or).forEach(function(e){hp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Or[t]=Or[e]})});function Ju(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Or.hasOwnProperty(e)&&Or[e]?(""+t).trim():t+"px"}function Xu(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=Ju(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var gp=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 Go(e,t){if(t){if(gp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(M(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(M(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(M(61))}if(t.style!=null&&typeof t.style!="object")throw Error(M(62))}}function Ko(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 Yo=null;function Qi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Qo=null,rr=null,sr=null;function nc(e){if(e=gs(e)){if(typeof Qo!="function")throw Error(M(280));var t=e.stateNode;t&&(t=Oa(t),Qo(e.stateNode,e.type,t))}}function qu(e){rr?sr?sr.push(e):sr=[e]:rr=e}function Zu(){if(rr){var e=rr,t=sr;if(sr=rr=null,nc(e),t)for(e=0;e<t.length;e++)nc(t[e])}}function ed(e,t){return e(t)}function td(){}var ao=!1;function nd(e,t,n){if(ao)return e(t,n);ao=!0;try{return ed(e,t,n)}finally{ao=!1,(rr!==null||sr!==null)&&(td(),Zu())}}function Xr(e,t){var n=e.stateNode;if(n===null)return null;var r=Oa(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(M(231,t,typeof n));return n}var Jo=!1;if(Yt)try{var kr={};Object.defineProperty(kr,"passive",{get:function(){Jo=!0}}),window.addEventListener("test",kr,kr),window.removeEventListener("test",kr,kr)}catch{Jo=!1}function yp(e,t,n,r,a,o,i,c,l){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(f){this.onError(f)}}var Br=!1,ia=null,la=!1,Xo=null,vp={onError:function(e){Br=!0,ia=e}};function xp(e,t,n,r,a,o,i,c,l){Br=!1,ia=null,yp.apply(vp,arguments)}function wp(e,t,n,r,a,o,i,c,l){if(xp.apply(this,arguments),Br){if(Br){var d=ia;Br=!1,ia=null}else throw Error(M(198));la||(la=!0,Xo=d)}}function Dn(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 rd(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 rc(e){if(Dn(e)!==e)throw Error(M(188))}function Sp(e){var t=e.alternate;if(!t){if(t=Dn(e),t===null)throw Error(M(188));return t!==e?null:e}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return rc(a),e;if(o===r)return rc(a),t;o=o.sibling}throw Error(M(188))}if(n.return!==r.return)n=a,r=o;else{for(var i=!1,c=a.child;c;){if(c===n){i=!0,n=a,r=o;break}if(c===r){i=!0,r=a,n=o;break}c=c.sibling}if(!i){for(c=o.child;c;){if(c===n){i=!0,n=o,r=a;break}if(c===r){i=!0,r=o,n=a;break}c=c.sibling}if(!i)throw Error(M(189))}}if(n.alternate!==r)throw Error(M(190))}if(n.tag!==3)throw Error(M(188));return n.stateNode.current===n?e:t}function sd(e){return e=Sp(e),e!==null?ad(e):null}function ad(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=ad(e);if(t!==null)return t;e=e.sibling}return null}var od=mt.unstable_scheduleCallback,sc=mt.unstable_cancelCallback,jp=mt.unstable_shouldYield,kp=mt.unstable_requestPaint,Re=mt.unstable_now,bp=mt.unstable_getCurrentPriorityLevel,Ji=mt.unstable_ImmediatePriority,id=mt.unstable_UserBlockingPriority,ca=mt.unstable_NormalPriority,Cp=mt.unstable_LowPriority,ld=mt.unstable_IdlePriority,$a=null,Ot=null;function Np(e){if(Ot&&typeof Ot.onCommitFiberRoot=="function")try{Ot.onCommitFiberRoot($a,e,void 0,(e.current.flags&128)===128)}catch{}}var _t=Math.clz32?Math.clz32:Ip,Ep=Math.log,Tp=Math.LN2;function Ip(e){return e>>>=0,e===0?32:31-(Ep(e)/Tp|0)|0}var Ns=64,Es=4194304;function Lr(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 ua(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,a=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var c=i&~a;c!==0?r=Lr(c):(o&=i,o!==0&&(r=Lr(o)))}else i=n&~a,i!==0?r=Lr(i):o!==0&&(r=Lr(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&a)&&(a=r&-r,o=t&-t,a>=o||a===16&&(o&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-_t(t),a=1<<n,r|=e[n],t&=~a;return r}function Rp(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 Pp(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,o=e.pendingLanes;0<o;){var i=31-_t(o),c=1<<i,l=a[i];l===-1?(!(c&n)||c&r)&&(a[i]=Rp(c,t)):l<=t&&(e.expiredLanes|=c),o&=~c}}function qo(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function cd(){var e=Ns;return Ns<<=1,!(Ns&4194240)&&(Ns=64),e}function oo(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function ps(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-_t(t),e[t]=n}function _p(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-_t(n),o=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~o}}function Xi(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-_t(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var he=0;function ud(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var dd,qi,fd,md,pd,Zo=!1,Ts=[],dn=null,fn=null,mn=null,qr=new Map,Zr=new Map,on=[],Ap="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 ac(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":qr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Zr.delete(t.pointerId)}}function br(e,t,n,r,a,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[a]},t!==null&&(t=gs(t),t!==null&&qi(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function zp(e,t,n,r,a){switch(t){case"focusin":return dn=br(dn,e,t,n,r,a),!0;case"dragenter":return fn=br(fn,e,t,n,r,a),!0;case"mouseover":return mn=br(mn,e,t,n,r,a),!0;case"pointerover":var o=a.pointerId;return qr.set(o,br(qr.get(o)||null,e,t,n,r,a)),!0;case"gotpointercapture":return o=a.pointerId,Zr.set(o,br(Zr.get(o)||null,e,t,n,r,a)),!0}return!1}function hd(e){var t=In(e.target);if(t!==null){var n=Dn(t);if(n!==null){if(t=n.tag,t===13){if(t=rd(n),t!==null){e.blockedOn=t,pd(e.priority,function(){fd(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 Gs(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=ei(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Yo=r,n.target.dispatchEvent(r),Yo=null}else return t=gs(n),t!==null&&qi(t),e.blockedOn=n,!1;t.shift()}return!0}function oc(e,t,n){Gs(e)&&n.delete(t)}function $p(){Zo=!1,dn!==null&&Gs(dn)&&(dn=null),fn!==null&&Gs(fn)&&(fn=null),mn!==null&&Gs(mn)&&(mn=null),qr.forEach(oc),Zr.forEach(oc)}function Cr(e,t){e.blockedOn===t&&(e.blockedOn=null,Zo||(Zo=!0,mt.unstable_scheduleCallback(mt.unstable_NormalPriority,$p)))}function es(e){function t(a){return Cr(a,e)}if(0<Ts.length){Cr(Ts[0],e);for(var n=1;n<Ts.length;n++){var r=Ts[n];r.blockedOn===e&&(r.blockedOn=null)}}for(dn!==null&&Cr(dn,e),fn!==null&&Cr(fn,e),mn!==null&&Cr(mn,e),qr.forEach(t),Zr.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);)hd(n),n.blockedOn===null&&on.shift()}var ar=Zt.ReactCurrentBatchConfig,da=!0;function Lp(e,t,n,r){var a=he,o=ar.transition;ar.transition=null;try{he=1,Zi(e,t,n,r)}finally{he=a,ar.transition=o}}function Mp(e,t,n,r){var a=he,o=ar.transition;ar.transition=null;try{he=4,Zi(e,t,n,r)}finally{he=a,ar.transition=o}}function Zi(e,t,n,r){if(da){var a=ei(e,t,n,r);if(a===null)yo(e,t,r,fa,n),ac(e,r);else if(zp(a,e,t,n,r))r.stopPropagation();else if(ac(e,r),t&4&&-1<Ap.indexOf(e)){for(;a!==null;){var o=gs(a);if(o!==null&&dd(o),o=ei(e,t,n,r),o===null&&yo(e,t,r,fa,n),o===a)break;a=o}a!==null&&r.stopPropagation()}else yo(e,t,r,null,n)}}var fa=null;function ei(e,t,n,r){if(fa=null,e=Qi(r),e=In(e),e!==null)if(t=Dn(e),t===null)e=null;else if(n=t.tag,n===13){if(e=rd(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 fa=e,null}function gd(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(bp()){case Ji:return 1;case id:return 4;case ca:case Cp:return 16;case ld:return 536870912;default:return 16}default:return 16}}var cn=null,el=null,Ks=null;function yd(){if(Ks)return Ks;var e,t=el,n=t.length,r,a="value"in cn?cn.value:cn.textContent,o=a.length;for(e=0;e<n&&t[e]===a[e];e++);var i=n-e;for(r=1;r<=i&&t[n-r]===a[o-r];r++);return Ks=a.slice(e,1<r?1-r:void 0)}function Ys(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 ic(){return!1}function ht(e){function t(n,r,a,o,i){this._reactName=n,this._targetInst=a,this.type=r,this.nativeEvent=o,this.target=i,this.currentTarget=null;for(var c in e)e.hasOwnProperty(c)&&(n=e[c],this[c]=n?n(o):o[c]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Is:ic,this.isPropagationStopped=ic,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 gr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},tl=ht(gr),hs=Ee({},gr,{view:0,detail:0}),Fp=ht(hs),io,lo,Nr,La=Ee({},hs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nl,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!==Nr&&(Nr&&e.type==="mousemove"?(io=e.screenX-Nr.screenX,lo=e.screenY-Nr.screenY):lo=io=0,Nr=e),io)},movementY:function(e){return"movementY"in e?e.movementY:lo}}),lc=ht(La),Op=Ee({},La,{dataTransfer:0}),Bp=ht(Op),Dp=Ee({},hs,{relatedTarget:0}),co=ht(Dp),Up=Ee({},gr,{animationName:0,elapsedTime:0,pseudoElement:0}),Wp=ht(Up),Hp=Ee({},gr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Vp=ht(Hp),Gp=Ee({},gr,{data:0}),cc=ht(Gp),Kp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Yp={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"},Qp={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Jp(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Qp[e])?!!t[e]:!1}function nl(){return Jp}var Xp=Ee({},hs,{key:function(e){if(e.key){var t=Kp[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ys(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Yp[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nl,charCode:function(e){return e.type==="keypress"?Ys(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ys(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),qp=ht(Xp),Zp=Ee({},La,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),uc=ht(Zp),eh=Ee({},hs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nl}),th=ht(eh),nh=Ee({},gr,{propertyName:0,elapsedTime:0,pseudoElement:0}),rh=ht(nh),sh=Ee({},La,{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}),ah=ht(sh),oh=[9,13,27,32],rl=Yt&&"CompositionEvent"in window,Dr=null;Yt&&"documentMode"in document&&(Dr=document.documentMode);var ih=Yt&&"TextEvent"in window&&!Dr,vd=Yt&&(!rl||Dr&&8<Dr&&11>=Dr),dc=" ",fc=!1;function xd(e,t){switch(e){case"keyup":return oh.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Gn=!1;function lh(e,t){switch(e){case"compositionend":return wd(t);case"keypress":return t.which!==32?null:(fc=!0,dc);case"textInput":return e=t.data,e===dc&&fc?null:e;default:return null}}function ch(e,t){if(Gn)return e==="compositionend"||!rl&&xd(e,t)?(e=yd(),Ks=el=cn=null,Gn=!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 vd&&t.locale!=="ko"?null:t.data;default:return null}}var uh={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 mc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!uh[e.type]:t==="textarea"}function Sd(e,t,n,r){qu(r),t=ma(t,"onChange"),0<t.length&&(n=new tl("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Ur=null,ts=null;function dh(e){_d(e,0)}function Ma(e){var t=Qn(e);if(Vu(t))return e}function fh(e,t){if(e==="change")return t}var jd=!1;if(Yt){var uo;if(Yt){var fo="oninput"in document;if(!fo){var pc=document.createElement("div");pc.setAttribute("oninput","return;"),fo=typeof pc.oninput=="function"}uo=fo}else uo=!1;jd=uo&&(!document.documentMode||9<document.documentMode)}function hc(){Ur&&(Ur.detachEvent("onpropertychange",kd),ts=Ur=null)}function kd(e){if(e.propertyName==="value"&&Ma(ts)){var t=[];Sd(t,ts,e,Qi(e)),nd(dh,t)}}function mh(e,t,n){e==="focusin"?(hc(),Ur=t,ts=n,Ur.attachEvent("onpropertychange",kd)):e==="focusout"&&hc()}function ph(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ma(ts)}function hh(e,t){if(e==="click")return Ma(t)}function gh(e,t){if(e==="input"||e==="change")return Ma(t)}function yh(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var zt=typeof Object.is=="function"?Object.is:yh;function ns(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(!Lo.call(t,a)||!zt(e[a],t[a]))return!1}return!0}function gc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function yc(e,t){var n=gc(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=gc(n)}}function bd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?bd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Cd(){for(var e=window,t=oa();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=oa(e.document)}return t}function sl(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 vh(e){var t=Cd(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&bd(n.ownerDocument.documentElement,n)){if(r!==null&&sl(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,o=Math.min(r.start,a);r=r.end===void 0?o:Math.min(r.end,a),!e.extend&&o>r&&(a=r,r=o,o=a),a=yc(n,o);var i=yc(n,r);a&&i&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.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 xh=Yt&&"documentMode"in document&&11>=document.documentMode,Kn=null,ti=null,Wr=null,ni=!1;function vc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ni||Kn==null||Kn!==oa(r)||(r=Kn,"selectionStart"in r&&sl(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}),Wr&&ns(Wr,r)||(Wr=r,r=ma(ti,"onSelect"),0<r.length&&(t=new tl("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Kn)))}function Rs(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Yn={animationend:Rs("Animation","AnimationEnd"),animationiteration:Rs("Animation","AnimationIteration"),animationstart:Rs("Animation","AnimationStart"),transitionend:Rs("Transition","TransitionEnd")},mo={},Nd={};Yt&&(Nd=document.createElement("div").style,"AnimationEvent"in window||(delete Yn.animationend.animation,delete Yn.animationiteration.animation,delete Yn.animationstart.animation),"TransitionEvent"in window||delete Yn.transitionend.transition);function Fa(e){if(mo[e])return mo[e];if(!Yn[e])return e;var t=Yn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Nd)return mo[e]=t[n];return e}var Ed=Fa("animationend"),Td=Fa("animationiteration"),Id=Fa("animationstart"),Rd=Fa("transitionend"),Pd=new Map,xc="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 Sn(e,t){Pd.set(e,t),Bn(t,[e])}for(var po=0;po<xc.length;po++){var ho=xc[po],wh=ho.toLowerCase(),Sh=ho[0].toUpperCase()+ho.slice(1);Sn(wh,"on"+Sh)}Sn(Ed,"onAnimationEnd");Sn(Td,"onAnimationIteration");Sn(Id,"onAnimationStart");Sn("dblclick","onDoubleClick");Sn("focusin","onFocus");Sn("focusout","onBlur");Sn(Rd,"onTransitionEnd");lr("onMouseEnter",["mouseout","mouseover"]);lr("onMouseLeave",["mouseout","mouseover"]);lr("onPointerEnter",["pointerout","pointerover"]);lr("onPointerLeave",["pointerout","pointerover"]);Bn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Bn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Bn("onBeforeInput",["compositionend","keypress","textInput","paste"]);Bn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Bn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Bn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Mr="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(" "),jh=new Set("cancel close invalid load scroll toggle".split(" ").concat(Mr));function wc(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,wp(r,t,void 0,e),e.currentTarget=null}function _d(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 o=void 0;if(t)for(var i=r.length-1;0<=i;i--){var c=r[i],l=c.instance,d=c.currentTarget;if(c=c.listener,l!==o&&a.isPropagationStopped())break e;wc(a,c,d),o=l}else for(i=0;i<r.length;i++){if(c=r[i],l=c.instance,d=c.currentTarget,c=c.listener,l!==o&&a.isPropagationStopped())break e;wc(a,c,d),o=l}}}if(la)throw e=Xo,la=!1,Xo=null,e}function we(e,t){var n=t[ii];n===void 0&&(n=t[ii]=new Set);var r=e+"__bubble";n.has(r)||(Ad(t,e,2,!1),n.add(r))}function go(e,t,n){var r=0;t&&(r|=4),Ad(n,e,r,t)}var Ps="_reactListening"+Math.random().toString(36).slice(2);function rs(e){if(!e[Ps]){e[Ps]=!0,Bu.forEach(function(n){n!=="selectionchange"&&(jh.has(n)||go(n,!1,e),go(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ps]||(t[Ps]=!0,go("selectionchange",!1,t))}}function Ad(e,t,n,r){switch(gd(t)){case 1:var a=Lp;break;case 4:a=Mp;break;default:a=Zi}n=a.bind(null,t,n,e),a=void 0,!Jo||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 yo(e,t,n,r,a){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var i=r.tag;if(i===3||i===4){var c=r.stateNode.containerInfo;if(c===a||c.nodeType===8&&c.parentNode===a)break;if(i===4)for(i=r.return;i!==null;){var l=i.tag;if((l===3||l===4)&&(l=i.stateNode.containerInfo,l===a||l.nodeType===8&&l.parentNode===a))return;i=i.return}for(;c!==null;){if(i=In(c),i===null)return;if(l=i.tag,l===5||l===6){r=o=i;continue e}c=c.parentNode}}r=r.return}nd(function(){var d=o,f=Qi(n),p=[];e:{var m=Pd.get(e);if(m!==void 0){var w=tl,v=e;switch(e){case"keypress":if(Ys(n)===0)break e;case"keydown":case"keyup":w=qp;break;case"focusin":v="focus",w=co;break;case"focusout":v="blur",w=co;break;case"beforeblur":case"afterblur":w=co;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=lc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":w=Bp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":w=th;break;case Ed:case Td:case Id:w=Wp;break;case Rd:w=rh;break;case"scroll":w=Fp;break;case"wheel":w=ah;break;case"copy":case"cut":case"paste":w=Vp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":w=uc}var x=(t&4)!==0,j=!x&&e==="scroll",g=x?m!==null?m+"Capture":null:m;x=[];for(var h=d,y;h!==null;){y=h;var S=y.stateNode;if(y.tag===5&&S!==null&&(y=S,g!==null&&(S=Xr(h,g),S!=null&&x.push(ss(h,S,y)))),j)break;h=h.return}0<x.length&&(m=new w(m,v,null,n,f),p.push({event:m,listeners:x}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",w=e==="mouseout"||e==="pointerout",m&&n!==Yo&&(v=n.relatedTarget||n.fromElement)&&(In(v)||v[Qt]))break e;if((w||m)&&(m=f.window===f?f:(m=f.ownerDocument)?m.defaultView||m.parentWindow:window,w?(v=n.relatedTarget||n.toElement,w=d,v=v?In(v):null,v!==null&&(j=Dn(v),v!==j||v.tag!==5&&v.tag!==6)&&(v=null)):(w=null,v=d),w!==v)){if(x=lc,S="onMouseLeave",g="onMouseEnter",h="mouse",(e==="pointerout"||e==="pointerover")&&(x=uc,S="onPointerLeave",g="onPointerEnter",h="pointer"),j=w==null?m:Qn(w),y=v==null?m:Qn(v),m=new x(S,h+"leave",w,n,f),m.target=j,m.relatedTarget=y,S=null,In(f)===d&&(x=new x(g,h+"enter",v,n,f),x.target=y,x.relatedTarget=j,S=x),j=S,w&&v)t:{for(x=w,g=v,h=0,y=x;y;y=Un(y))h++;for(y=0,S=g;S;S=Un(S))y++;for(;0<h-y;)x=Un(x),h--;for(;0<y-h;)g=Un(g),y--;for(;h--;){if(x===g||g!==null&&x===g.alternate)break t;x=Un(x),g=Un(g)}x=null}else x=null;w!==null&&Sc(p,m,w,x,!1),v!==null&&j!==null&&Sc(p,j,v,x,!0)}}e:{if(m=d?Qn(d):window,w=m.nodeName&&m.nodeName.toLowerCase(),w==="select"||w==="input"&&m.type==="file")var k=fh;else if(mc(m))if(jd)k=gh;else{k=ph;var N=mh}else(w=m.nodeName)&&w.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(k=hh);if(k&&(k=k(e,d))){Sd(p,k,n,f);break e}N&&N(e,m,d),e==="focusout"&&(N=m._wrapperState)&&N.controlled&&m.type==="number"&&Wo(m,"number",m.value)}switch(N=d?Qn(d):window,e){case"focusin":(mc(N)||N.contentEditable==="true")&&(Kn=N,ti=d,Wr=null);break;case"focusout":Wr=ti=Kn=null;break;case"mousedown":ni=!0;break;case"contextmenu":case"mouseup":case"dragend":ni=!1,vc(p,n,f);break;case"selectionchange":if(xh)break;case"keydown":case"keyup":vc(p,n,f)}var C;if(rl)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 Gn?xd(e,n)&&(P="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(P="onCompositionStart");P&&(vd&&n.locale!=="ko"&&(Gn||P!=="onCompositionStart"?P==="onCompositionEnd"&&Gn&&(C=yd()):(cn=f,el="value"in cn?cn.value:cn.textContent,Gn=!0)),N=ma(d,P),0<N.length&&(P=new cc(P,e,null,n,f),p.push({event:P,listeners:N}),C?P.data=C:(C=wd(n),C!==null&&(P.data=C)))),(C=ih?lh(e,n):ch(e,n))&&(d=ma(d,"onBeforeInput"),0<d.length&&(f=new cc("onBeforeInput","beforeinput",null,n,f),p.push({event:f,listeners:d}),f.data=C))}_d(p,t)})}function ss(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ma(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,o=a.stateNode;a.tag===5&&o!==null&&(a=o,o=Xr(e,n),o!=null&&r.unshift(ss(e,o,a)),o=Xr(e,t),o!=null&&r.push(ss(e,o,a))),e=e.return}return r}function Un(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Sc(e,t,n,r,a){for(var o=t._reactName,i=[];n!==null&&n!==r;){var c=n,l=c.alternate,d=c.stateNode;if(l!==null&&l===r)break;c.tag===5&&d!==null&&(c=d,a?(l=Xr(n,o),l!=null&&i.unshift(ss(n,l,c))):a||(l=Xr(n,o),l!=null&&i.push(ss(n,l,c)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var kh=/\r\n?/g,bh=/\u0000|\uFFFD/g;function jc(e){return(typeof e=="string"?e:""+e).replace(kh,`
|
|
38
|
+
`).replace(bh,"")}function _s(e,t,n){if(t=jc(t),jc(e)!==t&&n)throw Error(M(425))}function pa(){}var ri=null,si=null;function ai(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 oi=typeof setTimeout=="function"?setTimeout:void 0,Ch=typeof clearTimeout=="function"?clearTimeout:void 0,kc=typeof Promise=="function"?Promise:void 0,Nh=typeof queueMicrotask=="function"?queueMicrotask:typeof kc<"u"?function(e){return kc.resolve(null).then(e).catch(Eh)}:oi;function Eh(e){setTimeout(function(){throw e})}function vo(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),es(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);es(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 bc(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 yr=Math.random().toString(36).slice(2),Ft="__reactFiber$"+yr,as="__reactProps$"+yr,Qt="__reactContainer$"+yr,ii="__reactEvents$"+yr,Th="__reactListeners$"+yr,Ih="__reactHandles$"+yr;function In(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=bc(e);e!==null;){if(n=e[Ft])return n;e=bc(e)}return t}e=n,n=e.parentNode}return null}function gs(e){return e=e[Ft]||e[Qt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Qn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(M(33))}function Oa(e){return e[as]||null}var li=[],Jn=-1;function jn(e){return{current:e}}function Se(e){0>Jn||(e.current=li[Jn],li[Jn]=null,Jn--)}function xe(e,t){Jn++,li[Jn]=e.current,e.current=t}var wn={},Ye=jn(wn),at=jn(!1),$n=wn;function cr(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={},o;for(o in n)a[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function ot(e){return e=e.childContextTypes,e!=null}function ha(){Se(at),Se(Ye)}function Cc(e,t,n){if(Ye.current!==wn)throw Error(M(168));xe(Ye,t),xe(at,n)}function zd(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(M(108,mp(e)||"Unknown",a));return Ee({},n,r)}function ga(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||wn,$n=Ye.current,xe(Ye,e),xe(at,at.current),!0}function Nc(e,t,n){var r=e.stateNode;if(!r)throw Error(M(169));n?(e=zd(e,t,$n),r.__reactInternalMemoizedMergedChildContext=e,Se(at),Se(Ye),xe(Ye,e)):Se(at),xe(at,n)}var Wt=null,Ba=!1,xo=!1;function $d(e){Wt===null?Wt=[e]:Wt.push(e)}function Rh(e){Ba=!0,$d(e)}function kn(){if(!xo&&Wt!==null){xo=!0;var e=0,t=he;try{var n=Wt;for(he=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Wt=null,Ba=!1}catch(a){throw Wt!==null&&(Wt=Wt.slice(e+1)),od(Ji,kn),a}finally{he=t,xo=!1}}return null}var Xn=[],qn=0,ya=null,va=0,xt=[],wt=0,Ln=null,Vt=1,Gt="";function Nn(e,t){Xn[qn++]=va,Xn[qn++]=ya,ya=e,va=t}function Ld(e,t,n){xt[wt++]=Vt,xt[wt++]=Gt,xt[wt++]=Ln,Ln=e;var r=Vt;e=Gt;var a=32-_t(r)-1;r&=~(1<<a),n+=1;var o=32-_t(t)+a;if(30<o){var i=a-a%5;o=(r&(1<<i)-1).toString(32),r>>=i,a-=i,Vt=1<<32-_t(t)+a|n<<a|r,Gt=o+e}else Vt=1<<o|n<<a|r,Gt=e}function al(e){e.return!==null&&(Nn(e,1),Ld(e,1,0))}function ol(e){for(;e===ya;)ya=Xn[--qn],Xn[qn]=null,va=Xn[--qn],Xn[qn]=null;for(;e===Ln;)Ln=xt[--wt],xt[wt]=null,Gt=xt[--wt],xt[wt]=null,Vt=xt[--wt],xt[wt]=null}var ft=null,dt=null,ke=!1,Rt=null;function Md(e,t){var n=St(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 Ec(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=Ln!==null?{id:Vt,overflow:Gt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=St(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ft=e,dt=null,!0):!1;default:return!1}}function ci(e){return(e.mode&1)!==0&&(e.flags&128)===0}function ui(e){if(ke){var t=dt;if(t){var n=t;if(!Ec(e,t)){if(ci(e))throw Error(M(418));t=pn(n.nextSibling);var r=ft;t&&Ec(e,t)?Md(r,n):(e.flags=e.flags&-4097|2,ke=!1,ft=e)}}else{if(ci(e))throw Error(M(418));e.flags=e.flags&-4097|2,ke=!1,ft=e}}}function Tc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ft=e}function As(e){if(e!==ft)return!1;if(!ke)return Tc(e),ke=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!ai(e.type,e.memoizedProps)),t&&(t=dt)){if(ci(e))throw Fd(),Error(M(418));for(;t;)Md(e,t),t=pn(t.nextSibling)}if(Tc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(M(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 Fd(){for(var e=dt;e;)e=pn(e.nextSibling)}function ur(){dt=ft=null,ke=!1}function il(e){Rt===null?Rt=[e]:Rt.push(e)}var Ph=Zt.ReactCurrentBatchConfig;function Er(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(M(309));var r=n.stateNode}if(!r)throw Error(M(147,e));var a=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(i){var c=a.refs;i===null?delete c[o]:c[o]=i},t._stringRef=o,t)}if(typeof e!="string")throw Error(M(284));if(!n._owner)throw Error(M(290,e))}return e}function zs(e,t){throw e=Object.prototype.toString.call(t),Error(M(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Ic(e){var t=e._init;return t(e._payload)}function Od(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 o(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 i(g){return e&&g.alternate===null&&(g.flags|=2),g}function c(g,h,y,S){return h===null||h.tag!==6?(h=No(y,g.mode,S),h.return=g,h):(h=a(h,y),h.return=g,h)}function l(g,h,y,S){var k=y.type;return k===Vn?f(g,h,y.props.children,S,y.key):h!==null&&(h.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===sn&&Ic(k)===h.type)?(S=a(h,y.props),S.ref=Er(g,h,y),S.return=g,S):(S=ta(y.type,y.key,y.props,null,g.mode,S),S.ref=Er(g,h,y),S.return=g,S)}function d(g,h,y,S){return h===null||h.tag!==4||h.stateNode.containerInfo!==y.containerInfo||h.stateNode.implementation!==y.implementation?(h=Eo(y,g.mode,S),h.return=g,h):(h=a(h,y.children||[]),h.return=g,h)}function f(g,h,y,S,k){return h===null||h.tag!==7?(h=zn(y,g.mode,S,k),h.return=g,h):(h=a(h,y),h.return=g,h)}function p(g,h,y){if(typeof h=="string"&&h!==""||typeof h=="number")return h=No(""+h,g.mode,y),h.return=g,h;if(typeof h=="object"&&h!==null){switch(h.$$typeof){case ks:return y=ta(h.type,h.key,h.props,null,g.mode,y),y.ref=Er(g,null,h),y.return=g,y;case Hn:return h=Eo(h,g.mode,y),h.return=g,h;case sn:var S=h._init;return p(g,S(h._payload),y)}if($r(h)||jr(h))return h=zn(h,g.mode,y,null),h.return=g,h;zs(g,h)}return null}function m(g,h,y,S){var k=h!==null?h.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return k!==null?null:c(g,h,""+y,S);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case ks:return y.key===k?l(g,h,y,S):null;case Hn:return y.key===k?d(g,h,y,S):null;case sn:return k=y._init,m(g,h,k(y._payload),S)}if($r(y)||jr(y))return k!==null?null:f(g,h,y,S,null);zs(g,y)}return null}function w(g,h,y,S,k){if(typeof S=="string"&&S!==""||typeof S=="number")return g=g.get(y)||null,c(h,g,""+S,k);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case ks:return g=g.get(S.key===null?y:S.key)||null,l(h,g,S,k);case Hn:return g=g.get(S.key===null?y:S.key)||null,d(h,g,S,k);case sn:var N=S._init;return w(g,h,y,N(S._payload),k)}if($r(S)||jr(S))return g=g.get(y)||null,f(h,g,S,k,null);zs(h,S)}return null}function v(g,h,y,S){for(var k=null,N=null,C=h,P=h=0,E=null;C!==null&&P<y.length;P++){C.index>P?(E=C,C=null):E=C.sibling;var z=m(g,C,y[P],S);if(z===null){C===null&&(C=E);break}e&&C&&z.alternate===null&&t(g,C),h=o(z,h,P),N===null?k=z:N.sibling=z,N=z,C=E}if(P===y.length)return n(g,C),ke&&Nn(g,P),k;if(C===null){for(;P<y.length;P++)C=p(g,y[P],S),C!==null&&(h=o(C,h,P),N===null?k=C:N.sibling=C,N=C);return ke&&Nn(g,P),k}for(C=r(g,C);P<y.length;P++)E=w(C,g,P,y[P],S),E!==null&&(e&&E.alternate!==null&&C.delete(E.key===null?P:E.key),h=o(E,h,P),N===null?k=E:N.sibling=E,N=E);return e&&C.forEach(function(U){return t(g,U)}),ke&&Nn(g,P),k}function x(g,h,y,S){var k=jr(y);if(typeof k!="function")throw Error(M(150));if(y=k.call(y),y==null)throw Error(M(151));for(var N=k=null,C=h,P=h=0,E=null,z=y.next();C!==null&&!z.done;P++,z=y.next()){C.index>P?(E=C,C=null):E=C.sibling;var U=m(g,C,z.value,S);if(U===null){C===null&&(C=E);break}e&&C&&U.alternate===null&&t(g,C),h=o(U,h,P),N===null?k=U:N.sibling=U,N=U,C=E}if(z.done)return n(g,C),ke&&Nn(g,P),k;if(C===null){for(;!z.done;P++,z=y.next())z=p(g,z.value,S),z!==null&&(h=o(z,h,P),N===null?k=z:N.sibling=z,N=z);return ke&&Nn(g,P),k}for(C=r(g,C);!z.done;P++,z=y.next())z=w(C,g,P,z.value,S),z!==null&&(e&&z.alternate!==null&&C.delete(z.key===null?P:z.key),h=o(z,h,P),N===null?k=z:N.sibling=z,N=z);return e&&C.forEach(function(V){return t(g,V)}),ke&&Nn(g,P),k}function j(g,h,y,S){if(typeof y=="object"&&y!==null&&y.type===Vn&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case ks:e:{for(var k=y.key,N=h;N!==null;){if(N.key===k){if(k=y.type,k===Vn){if(N.tag===7){n(g,N.sibling),h=a(N,y.props.children),h.return=g,g=h;break e}}else if(N.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===sn&&Ic(k)===N.type){n(g,N.sibling),h=a(N,y.props),h.ref=Er(g,N,y),h.return=g,g=h;break e}n(g,N);break}else t(g,N);N=N.sibling}y.type===Vn?(h=zn(y.props.children,g.mode,S,y.key),h.return=g,g=h):(S=ta(y.type,y.key,y.props,null,g.mode,S),S.ref=Er(g,h,y),S.return=g,g=S)}return i(g);case Hn:e:{for(N=y.key;h!==null;){if(h.key===N)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=Eo(y,g.mode,S),h.return=g,g=h}return i(g);case sn:return N=y._init,j(g,h,N(y._payload),S)}if($r(y))return v(g,h,y,S);if(jr(y))return x(g,h,y,S);zs(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=No(y,g.mode,S),h.return=g,g=h),i(g)):n(g,h)}return j}var dr=Od(!0),Bd=Od(!1),xa=jn(null),wa=null,Zn=null,ll=null;function cl(){ll=Zn=wa=null}function ul(e){var t=xa.current;Se(xa),e._currentValue=t}function di(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 or(e,t){wa=e,ll=Zn=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(ll!==e)if(e={context:e,memoizedValue:t,next:null},Zn===null){if(wa===null)throw Error(M(308));Zn=e,wa.dependencies={lanes:0,firstContext:e}}else Zn=Zn.next=e;return t}var Rn=null;function dl(e){Rn===null?Rn=[e]:Rn.push(e)}function Dd(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,dl(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 fl(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ud(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,fe&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,dl(r)):(t.next=a.next,a.next=t),r.interleaved=t,Jt(e,n)}function Qs(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,Xi(e,n)}}function Rc(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var a=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?a=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?a=o=t:o=o.next=t}else a=o=t;n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:o,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 Sa(e,t,n,r){var a=e.updateQueue;an=!1;var o=a.firstBaseUpdate,i=a.lastBaseUpdate,c=a.shared.pending;if(c!==null){a.shared.pending=null;var l=c,d=l.next;l.next=null,i===null?o=d:i.next=d,i=l;var f=e.alternate;f!==null&&(f=f.updateQueue,c=f.lastBaseUpdate,c!==i&&(c===null?f.firstBaseUpdate=d:c.next=d,f.lastBaseUpdate=l))}if(o!==null){var p=a.baseState;i=0,f=d=l=null,c=o;do{var m=c.lane,w=c.eventTime;if((r&m)===m){f!==null&&(f=f.next={eventTime:w,lane:0,tag:c.tag,payload:c.payload,callback:c.callback,next:null});e:{var v=e,x=c;switch(m=t,w=n,x.tag){case 1:if(v=x.payload,typeof v=="function"){p=v.call(w,p,m);break e}p=v;break e;case 3:v.flags=v.flags&-65537|128;case 0:if(v=x.payload,m=typeof v=="function"?v.call(w,p,m):v,m==null)break e;p=Ee({},p,m);break e;case 2:an=!0}}c.callback!==null&&c.lane!==0&&(e.flags|=64,m=a.effects,m===null?a.effects=[c]:m.push(c))}else w={eventTime:w,lane:m,tag:c.tag,payload:c.payload,callback:c.callback,next:null},f===null?(d=f=w,l=p):f=f.next=w,i|=m;if(c=c.next,c===null){if(c=a.shared.pending,c===null)break;m=c,c=m.next,m.next=null,a.lastBaseUpdate=m,a.shared.pending=null}}while(!0);if(f===null&&(l=p),a.baseState=l,a.firstBaseUpdate=d,a.lastBaseUpdate=f,t=a.shared.interleaved,t!==null){a=t;do i|=a.lane,a=a.next;while(a!==t)}else o===null&&(a.shared.lanes=0);Fn|=i,e.lanes=i,e.memoizedState=p}}function Pc(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(M(191,a));a.call(r)}}}var ys={},Bt=jn(ys),os=jn(ys),is=jn(ys);function Pn(e){if(e===ys)throw Error(M(174));return e}function ml(e,t){switch(xe(is,t),xe(os,e),xe(Bt,ys),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Vo(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Vo(t,e)}Se(Bt),xe(Bt,t)}function fr(){Se(Bt),Se(os),Se(is)}function Wd(e){Pn(is.current);var t=Pn(Bt.current),n=Vo(t,e.type);t!==n&&(xe(os,e),xe(Bt,n))}function pl(e){os.current===e&&(Se(Bt),Se(os))}var Ce=jn(0);function ja(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 wo=[];function hl(){for(var e=0;e<wo.length;e++)wo[e]._workInProgressVersionPrimary=null;wo.length=0}var Js=Zt.ReactCurrentDispatcher,So=Zt.ReactCurrentBatchConfig,Mn=0,Ne=null,ze=null,Me=null,ka=!1,Hr=!1,ls=0,_h=0;function Ve(){throw Error(M(321))}function gl(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 yl(e,t,n,r,a,o){if(Mn=o,Ne=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Js.current=e===null||e.memoizedState===null?Lh:Mh,e=n(r,a),Hr){o=0;do{if(Hr=!1,ls=0,25<=o)throw Error(M(301));o+=1,Me=ze=null,t.updateQueue=null,Js.current=Fh,e=n(r,a)}while(Hr)}if(Js.current=ba,t=ze!==null&&ze.next!==null,Mn=0,Me=ze=Ne=null,ka=!1,t)throw Error(M(300));return e}function vl(){var e=ls!==0;return ls=0,e}function Mt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Me===null?Ne.memoizedState=Me=e:Me=Me.next=e,Me}function bt(){if(ze===null){var e=Ne.alternate;e=e!==null?e.memoizedState:null}else e=ze.next;var t=Me===null?Ne.memoizedState:Me.next;if(t!==null)Me=t,ze=e;else{if(e===null)throw Error(M(310));ze=e,e={memoizedState:ze.memoizedState,baseState:ze.baseState,baseQueue:ze.baseQueue,queue:ze.queue,next:null},Me===null?Ne.memoizedState=Me=e:Me=Me.next=e}return Me}function cs(e,t){return typeof t=="function"?t(e):t}function jo(e){var t=bt(),n=t.queue;if(n===null)throw Error(M(311));n.lastRenderedReducer=e;var r=ze,a=r.baseQueue,o=n.pending;if(o!==null){if(a!==null){var i=a.next;a.next=o.next,o.next=i}r.baseQueue=a=o,n.pending=null}if(a!==null){o=a.next,r=r.baseState;var c=i=null,l=null,d=o;do{var f=d.lane;if((Mn&f)===f)l!==null&&(l=l.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 p={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};l===null?(c=l=p,i=r):l=l.next=p,Ne.lanes|=f,Fn|=f}d=d.next}while(d!==null&&d!==o);l===null?i=r:l.next=c,zt(r,t.memoizedState)||(st=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=l,n.lastRenderedState=r}if(e=n.interleaved,e!==null){a=e;do o=a.lane,Ne.lanes|=o,Fn|=o,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function ko(e){var t=bt(),n=t.queue;if(n===null)throw Error(M(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var i=a=a.next;do o=e(o,i.action),i=i.next;while(i!==a);zt(o,t.memoizedState)||(st=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Hd(){}function Vd(e,t){var n=Ne,r=bt(),a=t(),o=!zt(r.memoizedState,a);if(o&&(r.memoizedState=a,st=!0),r=r.queue,xl(Yd.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||Me!==null&&Me.memoizedState.tag&1){if(n.flags|=2048,us(9,Kd.bind(null,n,r,a,t),void 0,null),Fe===null)throw Error(M(349));Mn&30||Gd(n,t,a)}return a}function Gd(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ne.updateQueue,t===null?(t={lastEffect:null,stores:null},Ne.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Kd(e,t,n,r){t.value=n,t.getSnapshot=r,Qd(t)&&Jd(e)}function Yd(e,t,n){return n(function(){Qd(t)&&Jd(e)})}function Qd(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!zt(e,n)}catch{return!0}}function Jd(e){var t=Jt(e,1);t!==null&&At(t,e,1,-1)}function _c(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:cs,lastRenderedState:e},t.queue=e,e=e.dispatch=$h.bind(null,Ne,e),[t.memoizedState,e]}function us(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Ne.updateQueue,t===null?(t={lastEffect:null,stores:null},Ne.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 Xd(){return bt().memoizedState}function Xs(e,t,n,r){var a=Mt();Ne.flags|=e,a.memoizedState=us(1|t,n,void 0,r===void 0?null:r)}function Da(e,t,n,r){var a=bt();r=r===void 0?null:r;var o=void 0;if(ze!==null){var i=ze.memoizedState;if(o=i.destroy,r!==null&&gl(r,i.deps)){a.memoizedState=us(t,n,o,r);return}}Ne.flags|=e,a.memoizedState=us(1|t,n,o,r)}function Ac(e,t){return Xs(8390656,8,e,t)}function xl(e,t){return Da(2048,8,e,t)}function qd(e,t){return Da(4,2,e,t)}function Zd(e,t){return Da(4,4,e,t)}function ef(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 tf(e,t,n){return n=n!=null?n.concat([e]):null,Da(4,4,ef.bind(null,t,e),n)}function wl(){}function nf(e,t){var n=bt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&gl(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function rf(e,t){var n=bt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&gl(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function sf(e,t,n){return Mn&21?(zt(n,t)||(n=cd(),Ne.lanes|=n,Fn|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,st=!0),e.memoizedState=n)}function Ah(e,t){var n=he;he=n!==0&&4>n?n:4,e(!0);var r=So.transition;So.transition={};try{e(!1),t()}finally{he=n,So.transition=r}}function af(){return bt().memoizedState}function zh(e,t,n){var r=yn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},of(e))lf(t,n);else if(n=Dd(e,t,n,r),n!==null){var a=qe();At(n,e,r,a),cf(n,t,r)}}function $h(e,t,n){var r=yn(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(of(e))lf(t,a);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,c=o(i,n);if(a.hasEagerState=!0,a.eagerState=c,zt(c,i)){var l=t.interleaved;l===null?(a.next=a,dl(t)):(a.next=l.next,l.next=a),t.interleaved=a;return}}catch{}finally{}n=Dd(e,t,a,r),n!==null&&(a=qe(),At(n,e,r,a),cf(n,t,r))}}function of(e){var t=e.alternate;return e===Ne||t!==null&&t===Ne}function lf(e,t){Hr=ka=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function cf(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xi(e,n)}}var ba={readContext:kt,useCallback:Ve,useContext:Ve,useEffect:Ve,useImperativeHandle:Ve,useInsertionEffect:Ve,useLayoutEffect:Ve,useMemo:Ve,useReducer:Ve,useRef:Ve,useState:Ve,useDebugValue:Ve,useDeferredValue:Ve,useTransition:Ve,useMutableSource:Ve,useSyncExternalStore:Ve,useId:Ve,unstable_isNewReconciler:!1},Lh={readContext:kt,useCallback:function(e,t){return Mt().memoizedState=[e,t===void 0?null:t],e},useContext:kt,useEffect:Ac,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Xs(4194308,4,ef.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Xs(4194308,4,e,t)},useInsertionEffect:function(e,t){return Xs(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=zh.bind(null,Ne,e),[r.memoizedState,e]},useRef:function(e){var t=Mt();return e={current:e},t.memoizedState=e},useState:_c,useDebugValue:wl,useDeferredValue:function(e){return Mt().memoizedState=e},useTransition:function(){var e=_c(!1),t=e[0];return e=Ah.bind(null,e[1]),Mt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ne,a=Mt();if(ke){if(n===void 0)throw Error(M(407));n=n()}else{if(n=t(),Fe===null)throw Error(M(349));Mn&30||Gd(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Ac(Yd.bind(null,r,o,e),[e]),r.flags|=2048,us(9,Kd.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Mt(),t=Fe.identifierPrefix;if(ke){var n=Gt,r=Vt;n=(r&~(1<<32-_t(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ls++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=_h++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Mh={readContext:kt,useCallback:nf,useContext:kt,useEffect:xl,useImperativeHandle:tf,useInsertionEffect:qd,useLayoutEffect:Zd,useMemo:rf,useReducer:jo,useRef:Xd,useState:function(){return jo(cs)},useDebugValue:wl,useDeferredValue:function(e){var t=bt();return sf(t,ze.memoizedState,e)},useTransition:function(){var e=jo(cs)[0],t=bt().memoizedState;return[e,t]},useMutableSource:Hd,useSyncExternalStore:Vd,useId:af,unstable_isNewReconciler:!1},Fh={readContext:kt,useCallback:nf,useContext:kt,useEffect:xl,useImperativeHandle:tf,useInsertionEffect:qd,useLayoutEffect:Zd,useMemo:rf,useReducer:ko,useRef:Xd,useState:function(){return ko(cs)},useDebugValue:wl,useDeferredValue:function(e){var t=bt();return ze===null?t.memoizedState=e:sf(t,ze.memoizedState,e)},useTransition:function(){var e=ko(cs)[0],t=bt().memoizedState;return[e,t]},useMutableSource:Hd,useSyncExternalStore:Vd,useId:af,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 fi(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 Ua={isMounted:function(e){return(e=e._reactInternals)?Dn(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=qe(),a=yn(e),o=Kt(r,a);o.payload=t,n!=null&&(o.callback=n),t=hn(e,o,a),t!==null&&(At(t,e,a,r),Qs(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=qe(),a=yn(e),o=Kt(r,a);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=hn(e,o,a),t!==null&&(At(t,e,a,r),Qs(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=qe(),r=yn(e),a=Kt(n,r);a.tag=2,t!=null&&(a.callback=t),t=hn(e,a,r),t!==null&&(At(t,e,r,n),Qs(t,e,r))}};function zc(e,t,n,r,a,o,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,i):t.prototype&&t.prototype.isPureReactComponent?!ns(n,r)||!ns(a,o):!0}function uf(e,t,n){var r=!1,a=wn,o=t.contextType;return typeof o=="object"&&o!==null?o=kt(o):(a=ot(t)?$n:Ye.current,r=t.contextTypes,o=(r=r!=null)?cr(e,a):wn),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ua,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=o),t}function $c(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&&Ua.enqueueReplaceState(t,t.state,null)}function mi(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},fl(e);var o=t.contextType;typeof o=="object"&&o!==null?a.context=kt(o):(o=ot(t)?$n:Ye.current,a.context=cr(e,o)),a.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(fi(e,t,o,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&&Ua.enqueueReplaceState(a,a.state,null),Sa(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function mr(e,t){try{var n="",r=t;do n+=fp(r),r=r.return;while(r);var a=n}catch(o){a=`
|
|
39
|
+
Error generating stack: `+o.message+`
|
|
40
|
+
`+o.stack}return{value:e,source:t,stack:a,digest:null}}function bo(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function pi(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Oh=typeof WeakMap=="function"?WeakMap:Map;function df(e,t,n){n=Kt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Na||(Na=!0,bi=r),pi(e,t)},n}function ff(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(){pi(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){pi(e,t),typeof r!="function"&&(gn===null?gn=new Set([this]):gn.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function Lc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Oh;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=Zh.bind(null,e,t,n),t.then(e,e))}function Mc(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 Fc(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 Bh=Zt.ReactCurrentOwner,st=!1;function Je(e,t,n,r){t.child=e===null?Bd(t,null,n,r):dr(t,e.child,n,r)}function Oc(e,t,n,r,a){n=n.render;var o=t.ref;return or(t,a),r=yl(e,t,n,r,o,a),n=vl(),e!==null&&!st?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Xt(e,t,a)):(ke&&n&&al(t),t.flags|=1,Je(e,t,r,a),t.child)}function Bc(e,t,n,r,a){if(e===null){var o=n.type;return typeof o=="function"&&!Tl(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,mf(e,t,o,r,a)):(e=ta(n.type,null,r,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&a)){var i=o.memoizedProps;if(n=n.compare,n=n!==null?n:ns,n(i,r)&&e.ref===t.ref)return Xt(e,t,a)}return t.flags|=1,e=vn(o,r),e.ref=t.ref,e.return=t,t.child=e}function mf(e,t,n,r,a){if(e!==null){var o=e.memoizedProps;if(ns(o,r)&&e.ref===t.ref)if(st=!1,t.pendingProps=r=o,(e.lanes&a)!==0)e.flags&131072&&(st=!0);else return t.lanes=e.lanes,Xt(e,t,a)}return hi(e,t,n,r,a)}function pf(e,t,n){var r=t.pendingProps,a=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},xe(tr,ut),ut|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,xe(tr,ut),ut|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,xe(tr,ut),ut|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,xe(tr,ut),ut|=r;return Je(e,t,a,n),t.child}function hf(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function hi(e,t,n,r,a){var o=ot(n)?$n:Ye.current;return o=cr(t,o),or(t,a),n=yl(e,t,n,r,o,a),r=vl(),e!==null&&!st?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Xt(e,t,a)):(ke&&r&&al(t),t.flags|=1,Je(e,t,n,a),t.child)}function Dc(e,t,n,r,a){if(ot(n)){var o=!0;ga(t)}else o=!1;if(or(t,a),t.stateNode===null)qs(e,t),uf(t,n,r),mi(t,n,r,a),r=!0;else if(e===null){var i=t.stateNode,c=t.memoizedProps;i.props=c;var l=i.context,d=n.contextType;typeof d=="object"&&d!==null?d=kt(d):(d=ot(n)?$n:Ye.current,d=cr(t,d));var f=n.getDerivedStateFromProps,p=typeof f=="function"||typeof i.getSnapshotBeforeUpdate=="function";p||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(c!==r||l!==d)&&$c(t,i,r,d),an=!1;var m=t.memoizedState;i.state=m,Sa(t,r,i,a),l=t.memoizedState,c!==r||m!==l||at.current||an?(typeof f=="function"&&(fi(t,n,f,r),l=t.memoizedState),(c=an||zc(t,n,c,r,m,l,d))?(p||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),i.props=r,i.state=l,i.context=d,r=c):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,Ud(e,t),c=t.memoizedProps,d=t.type===t.elementType?c:Tt(t.type,c),i.props=d,p=t.pendingProps,m=i.context,l=n.contextType,typeof l=="object"&&l!==null?l=kt(l):(l=ot(n)?$n:Ye.current,l=cr(t,l));var w=n.getDerivedStateFromProps;(f=typeof w=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(c!==p||m!==l)&&$c(t,i,r,l),an=!1,m=t.memoizedState,i.state=m,Sa(t,r,i,a);var v=t.memoizedState;c!==p||m!==v||at.current||an?(typeof w=="function"&&(fi(t,n,w,r),v=t.memoizedState),(d=an||zc(t,n,d,r,m,v,l)||!1)?(f||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,v,l),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,v,l)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||c===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=v),i.props=r,i.state=v,i.context=l,r=d):(typeof i.componentDidUpdate!="function"||c===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||c===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return gi(e,t,n,r,o,a)}function gi(e,t,n,r,a,o){hf(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return a&&Nc(t,n,!1),Xt(e,t,o);r=t.stateNode,Bh.current=t;var c=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=dr(t,e.child,null,o),t.child=dr(t,null,c,o)):Je(e,t,c,o),t.memoizedState=r.state,a&&Nc(t,n,!0),t.child}function gf(e){var t=e.stateNode;t.pendingContext?Cc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Cc(e,t.context,!1),ml(e,t.containerInfo)}function Uc(e,t,n,r,a){return ur(),il(a),t.flags|=256,Je(e,t,n,r),t.child}var yi={dehydrated:null,treeContext:null,retryLane:0};function vi(e){return{baseLanes:e,cachePool:null,transitions:null}}function yf(e,t,n){var r=t.pendingProps,a=Ce.current,o=!1,i=(t.flags&128)!==0,c;if((c=i)||(c=e!==null&&e.memoizedState===null?!1:(a&2)!==0),c?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),xe(Ce,a&1),e===null)return ui(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):(i=r.children,e=r.fallback,o?(r=t.mode,o=t.child,i={mode:"hidden",children:i},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=i):o=Va(i,r,0,null),e=zn(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=vi(n),t.memoizedState=yi,e):Sl(t,i));if(a=e.memoizedState,a!==null&&(c=a.dehydrated,c!==null))return Dh(e,t,i,r,c,a,n);if(o){o=r.fallback,i=t.mode,a=e.child,c=a.sibling;var l={mode:"hidden",children:r.children};return!(i&1)&&t.child!==a?(r=t.child,r.childLanes=0,r.pendingProps=l,t.deletions=null):(r=vn(a,l),r.subtreeFlags=a.subtreeFlags&14680064),c!==null?o=vn(c,o):(o=zn(o,i,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,i=e.child.memoizedState,i=i===null?vi(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},o.memoizedState=i,o.childLanes=e.childLanes&~n,t.memoizedState=yi,r}return o=e.child,e=o.sibling,r=vn(o,{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 Sl(e,t){return t=Va({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function $s(e,t,n,r){return r!==null&&il(r),dr(t,e.child,null,n),e=Sl(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Dh(e,t,n,r,a,o,i){if(n)return t.flags&256?(t.flags&=-257,r=bo(Error(M(422))),$s(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,a=t.mode,r=Va({mode:"visible",children:r.children},a,0,null),o=zn(o,a,i,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&dr(t,e.child,null,i),t.child.memoizedState=vi(i),t.memoizedState=yi,o);if(!(t.mode&1))return $s(e,t,i,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var c=r.dgst;return r=c,o=Error(M(419)),r=bo(o,r,void 0),$s(e,t,i,r)}if(c=(i&e.childLanes)!==0,st||c){if(r=Fe,r!==null){switch(i&-i){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|i)?0:a,a!==0&&a!==o.retryLane&&(o.retryLane=a,Jt(e,a),At(r,e,a,-1))}return El(),r=bo(Error(M(421))),$s(e,t,i,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=eg.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,dt=pn(a.nextSibling),ft=t,ke=!0,Rt=null,e!==null&&(xt[wt++]=Vt,xt[wt++]=Gt,xt[wt++]=Ln,Vt=e.id,Gt=e.overflow,Ln=t),t=Sl(t,r.children),t.flags|=4096,t)}function Wc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),di(e.return,t,n)}function Co(e,t,n,r,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=a)}function vf(e,t,n){var r=t.pendingProps,a=r.revealOrder,o=r.tail;if(Je(e,t,r.children,n),r=Ce.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&&Wc(e,n,t);else if(e.tag===19)Wc(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(Ce,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&&ja(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Co(t,!1,a,n,o);break;case"backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&ja(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Co(t,!0,n,null,o);break;case"together":Co(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function qs(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),Fn|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(M(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 Uh(e,t,n){switch(t.tag){case 3:gf(t),ur();break;case 5:Wd(t);break;case 1:ot(t.type)&&ga(t);break;case 4:ml(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;xe(xa,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(xe(Ce,Ce.current&1),t.flags|=128,null):n&t.child.childLanes?yf(e,t,n):(xe(Ce,Ce.current&1),e=Xt(e,t,n),e!==null?e.sibling:null);xe(Ce,Ce.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return vf(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),xe(Ce,Ce.current),r)break;return null;case 22:case 23:return t.lanes=0,pf(e,t,n)}return Xt(e,t,n)}var xf,xi,wf,Sf;xf=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}};xi=function(){};wf=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,Pn(Bt.current);var o=null;switch(n){case"input":a=Do(e,a),r=Do(e,r),o=[];break;case"select":a=Ee({},a,{value:void 0}),r=Ee({},r,{value:void 0}),o=[];break;case"textarea":a=Ho(e,a),r=Ho(e,r),o=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=pa)}Go(n,r);var i;n=null;for(d in a)if(!r.hasOwnProperty(d)&&a.hasOwnProperty(d)&&a[d]!=null)if(d==="style"){var c=a[d];for(i in c)c.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Qr.hasOwnProperty(d)?o||(o=[]):(o=o||[]).push(d,null));for(d in r){var l=r[d];if(c=a!=null?a[d]:void 0,r.hasOwnProperty(d)&&l!==c&&(l!=null||c!=null))if(d==="style")if(c){for(i in c)!c.hasOwnProperty(i)||l&&l.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in l)l.hasOwnProperty(i)&&c[i]!==l[i]&&(n||(n={}),n[i]=l[i])}else n||(o||(o=[]),o.push(d,n)),n=l;else d==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(o=o||[]).push(d,l)):d==="children"?typeof l!="string"&&typeof l!="number"||(o=o||[]).push(d,""+l):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Qr.hasOwnProperty(d)?(l!=null&&d==="onScroll"&&we("scroll",e),o||c===l||(o=[])):(o=o||[]).push(d,l))}n&&(o=o||[]).push("style",n);var d=o;(t.updateQueue=d)&&(t.flags|=4)}};Sf=function(e,t,n,r){n!==r&&(t.flags|=4)};function Tr(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 Ge(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 Wh(e,t,n){var r=t.pendingProps;switch(ol(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ge(t),null;case 1:return ot(t.type)&&ha(),Ge(t),null;case 3:return r=t.stateNode,fr(),Se(at),Se(Ye),hl(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(As(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Rt!==null&&(Ei(Rt),Rt=null))),xi(e,t),Ge(t),null;case 5:pl(t);var a=Pn(is.current);if(n=t.type,e!==null&&t.stateNode!=null)wf(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(M(166));return Ge(t),null}if(e=Pn(Bt.current),As(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Ft]=t,r[as]=o,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<Mr.length;a++)we(Mr[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":ql(r,o),we("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},we("invalid",r);break;case"textarea":ec(r,o),we("invalid",r)}Go(n,o),a=null;for(var i in o)if(o.hasOwnProperty(i)){var c=o[i];i==="children"?typeof c=="string"?r.textContent!==c&&(o.suppressHydrationWarning!==!0&&_s(r.textContent,c,e),a=["children",c]):typeof c=="number"&&r.textContent!==""+c&&(o.suppressHydrationWarning!==!0&&_s(r.textContent,c,e),a=["children",""+c]):Qr.hasOwnProperty(i)&&c!=null&&i==="onScroll"&&we("scroll",r)}switch(n){case"input":bs(r),Zl(r,o,!0);break;case"textarea":bs(r),tc(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=pa)}r=a,t.updateQueue=r,r!==null&&(t.flags|=4)}else{i=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Yu(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[Ft]=t,e[as]=r,xf(e,t,!1,!1),t.stateNode=e;e:{switch(i=Ko(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<Mr.length;a++)we(Mr[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":ql(e,r),a=Do(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":ec(e,r),a=Ho(e,r),we("invalid",e);break;default:a=r}Go(n,a),c=a;for(o in c)if(c.hasOwnProperty(o)){var l=c[o];o==="style"?Xu(e,l):o==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&Qu(e,l)):o==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&Jr(e,l):typeof l=="number"&&Jr(e,""+l):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Qr.hasOwnProperty(o)?l!=null&&o==="onScroll"&&we("scroll",e):l!=null&&Vi(e,o,l,i))}switch(n){case"input":bs(e),Zl(e,r,!1);break;case"textarea":bs(e),tc(e);break;case"option":r.value!=null&&e.setAttribute("value",""+xn(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?nr(e,!!r.multiple,o,!1):r.defaultValue!=null&&nr(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=pa)}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 Ge(t),null;case 6:if(e&&t.stateNode!=null)Sf(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(M(166));if(n=Pn(is.current),Pn(Bt.current),As(t)){if(r=t.stateNode,n=t.memoizedProps,r[Ft]=t,(o=r.nodeValue!==n)&&(e=ft,e!==null))switch(e.tag){case 3:_s(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&_s(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Ft]=t,t.stateNode=r}return Ge(t),null;case 13:if(Se(Ce),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ke&&dt!==null&&t.mode&1&&!(t.flags&128))Fd(),ur(),t.flags|=98560,o=!1;else if(o=As(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(M(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(M(317));o[Ft]=t}else ur(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ge(t),o=!1}else Rt!==null&&(Ei(Rt),Rt=null),o=!0;if(!o)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||Ce.current&1?$e===0&&($e=3):El())),t.updateQueue!==null&&(t.flags|=4),Ge(t),null);case 4:return fr(),xi(e,t),e===null&&rs(t.stateNode.containerInfo),Ge(t),null;case 10:return ul(t.type._context),Ge(t),null;case 17:return ot(t.type)&&ha(),Ge(t),null;case 19:if(Se(Ce),o=t.memoizedState,o===null)return Ge(t),null;if(r=(t.flags&128)!==0,i=o.rendering,i===null)if(r)Tr(o,!1);else{if($e!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=ja(e),i!==null){for(t.flags|=128,Tr(o,!1),r=i.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,i=o.alternate,i===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=i.childLanes,o.lanes=i.lanes,o.child=i.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=i.memoizedProps,o.memoizedState=i.memoizedState,o.updateQueue=i.updateQueue,o.type=i.type,e=i.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return xe(Ce,Ce.current&1|2),t.child}e=e.sibling}o.tail!==null&&Re()>pr&&(t.flags|=128,r=!0,Tr(o,!1),t.lanes=4194304)}else{if(!r)if(e=ja(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Tr(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!ke)return Ge(t),null}else 2*Re()-o.renderingStartTime>pr&&n!==1073741824&&(t.flags|=128,r=!0,Tr(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Re(),t.sibling=null,n=Ce.current,xe(Ce,r?n&1|2:n&1),t):(Ge(t),null);case 22:case 23:return Nl(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ut&1073741824&&(Ge(t),t.subtreeFlags&6&&(t.flags|=8192)):Ge(t),null;case 24:return null;case 25:return null}throw Error(M(156,t.tag))}function Hh(e,t){switch(ol(t),t.tag){case 1:return ot(t.type)&&ha(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return fr(),Se(at),Se(Ye),hl(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return pl(t),null;case 13:if(Se(Ce),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(M(340));ur()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Se(Ce),null;case 4:return fr(),null;case 10:return ul(t.type._context),null;case 22:case 23:return Nl(),null;case 24:return null;default:return null}}var Ls=!1,Ke=!1,Vh=typeof WeakSet=="function"?WeakSet:Set,K=null;function er(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Te(e,t,r)}else n.current=null}function wi(e,t,n){try{n()}catch(r){Te(e,t,r)}}var Hc=!1;function Gh(e,t){if(ri=da,e=Cd(),sl(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,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,c=-1,l=-1,d=0,f=0,p=e,m=null;t:for(;;){for(var w;p!==n||a!==0&&p.nodeType!==3||(c=i+a),p!==o||r!==0&&p.nodeType!==3||(l=i+r),p.nodeType===3&&(i+=p.nodeValue.length),(w=p.firstChild)!==null;)m=p,p=w;for(;;){if(p===e)break t;if(m===n&&++d===a&&(c=i),m===o&&++f===r&&(l=i),(w=p.nextSibling)!==null)break;p=m,m=p.parentNode}p=w}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(si={focusedElem:e,selectionRange:n},da=!1,K=t;K!==null;)if(t=K,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,K=e;else for(;K!==null;){t=K;try{var v=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var x=v.memoizedProps,j=v.memoizedState,g=t.stateNode,h=g.getSnapshotBeforeUpdate(t.elementType===t.type?x:Tt(t.type,x),j);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(M(163))}}catch(S){Te(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,K=e;break}K=t.return}return v=Hc,Hc=!1,v}function Vr(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 o=a.destroy;a.destroy=void 0,o!==void 0&&wi(t,n,o)}a=a.next}while(a!==r)}}function Wa(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 Si(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 jf(e){var t=e.alternate;t!==null&&(e.alternate=null,jf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ft],delete t[as],delete t[ii],delete t[Th],delete t[Ih])),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 kf(e){return e.tag===5||e.tag===3||e.tag===4}function Vc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||kf(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 ji(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=pa));else if(r!==4&&(e=e.child,e!==null))for(ji(e,t,n),e=e.sibling;e!==null;)ji(e,t,n),e=e.sibling}function ki(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(ki(e,t,n),e=e.sibling;e!==null;)ki(e,t,n),e=e.sibling}var Ue=null,It=!1;function rn(e,t,n){for(n=n.child;n!==null;)bf(e,t,n),n=n.sibling}function bf(e,t,n){if(Ot&&typeof Ot.onCommitFiberUnmount=="function")try{Ot.onCommitFiberUnmount($a,n)}catch{}switch(n.tag){case 5:Ke||er(n,t);case 6:var r=Ue,a=It;Ue=null,rn(e,t,n),Ue=r,It=a,Ue!==null&&(It?(e=Ue,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ue.removeChild(n.stateNode));break;case 18:Ue!==null&&(It?(e=Ue,n=n.stateNode,e.nodeType===8?vo(e.parentNode,n):e.nodeType===1&&vo(e,n),es(e)):vo(Ue,n.stateNode));break;case 4:r=Ue,a=It,Ue=n.stateNode.containerInfo,It=!0,rn(e,t,n),Ue=r,It=a;break;case 0:case 11:case 14:case 15:if(!Ke&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){a=r=r.next;do{var o=a,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&wi(n,t,i),a=a.next}while(a!==r)}rn(e,t,n);break;case 1:if(!Ke&&(er(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(c){Te(n,t,c)}rn(e,t,n);break;case 21:rn(e,t,n);break;case 22:n.mode&1?(Ke=(r=Ke)||n.memoizedState!==null,rn(e,t,n),Ke=r):rn(e,t,n);break;default:rn(e,t,n)}}function Gc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Vh),t.forEach(function(r){var a=tg.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 o=e,i=t,c=i;e:for(;c!==null;){switch(c.tag){case 5:Ue=c.stateNode,It=!1;break e;case 3:Ue=c.stateNode.containerInfo,It=!0;break e;case 4:Ue=c.stateNode.containerInfo,It=!0;break e}c=c.return}if(Ue===null)throw Error(M(160));bf(o,i,a),Ue=null,It=!1;var l=a.alternate;l!==null&&(l.return=null),a.return=null}catch(d){Te(a,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Cf(t,e),t=t.sibling}function Cf(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{Vr(3,e,e.return),Wa(3,e)}catch(x){Te(e,e.return,x)}try{Vr(5,e,e.return)}catch(x){Te(e,e.return,x)}}break;case 1:Et(t,e),Lt(e),r&512&&n!==null&&er(n,n.return);break;case 5:if(Et(t,e),Lt(e),r&512&&n!==null&&er(n,n.return),e.flags&32){var a=e.stateNode;try{Jr(a,"")}catch(x){Te(e,e.return,x)}}if(r&4&&(a=e.stateNode,a!=null)){var o=e.memoizedProps,i=n!==null?n.memoizedProps:o,c=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{c==="input"&&o.type==="radio"&&o.name!=null&&Gu(a,o),Ko(c,i);var d=Ko(c,o);for(i=0;i<l.length;i+=2){var f=l[i],p=l[i+1];f==="style"?Xu(a,p):f==="dangerouslySetInnerHTML"?Qu(a,p):f==="children"?Jr(a,p):Vi(a,f,p,d)}switch(c){case"input":Uo(a,o);break;case"textarea":Ku(a,o);break;case"select":var m=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!o.multiple;var w=o.value;w!=null?nr(a,!!o.multiple,w,!1):m!==!!o.multiple&&(o.defaultValue!=null?nr(a,!!o.multiple,o.defaultValue,!0):nr(a,!!o.multiple,o.multiple?[]:"",!1))}a[as]=o}catch(x){Te(e,e.return,x)}}break;case 6:if(Et(t,e),Lt(e),r&4){if(e.stateNode===null)throw Error(M(162));a=e.stateNode,o=e.memoizedProps;try{a.nodeValue=o}catch(x){Te(e,e.return,x)}}break;case 3:if(Et(t,e),Lt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{es(t.containerInfo)}catch(x){Te(e,e.return,x)}break;case 4:Et(t,e),Lt(e);break;case 13:Et(t,e),Lt(e),a=e.child,a.flags&8192&&(o=a.memoizedState!==null,a.stateNode.isHidden=o,!o||a.alternate!==null&&a.alternate.memoizedState!==null||(bl=Re())),r&4&&Gc(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Ke=(d=Ke)||f,Et(t,e),Ke=d):Et(t,e),Lt(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(K=e,f=e.child;f!==null;){for(p=K=f;K!==null;){switch(m=K,w=m.child,m.tag){case 0:case 11:case 14:case 15:Vr(4,m,m.return);break;case 1:er(m,m.return);var v=m.stateNode;if(typeof v.componentWillUnmount=="function"){r=m,n=m.return;try{t=r,v.props=t.memoizedProps,v.state=t.memoizedState,v.componentWillUnmount()}catch(x){Te(r,n,x)}}break;case 5:er(m,m.return);break;case 22:if(m.memoizedState!==null){Yc(p);continue}}w!==null?(w.return=m,K=w):Yc(p)}f=f.sibling}e:for(f=null,p=e;;){if(p.tag===5){if(f===null){f=p;try{a=p.stateNode,d?(o=a.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(c=p.stateNode,l=p.memoizedProps.style,i=l!=null&&l.hasOwnProperty("display")?l.display:null,c.style.display=Ju("display",i))}catch(x){Te(e,e.return,x)}}}else if(p.tag===6){if(f===null)try{p.stateNode.nodeValue=d?"":p.memoizedProps}catch(x){Te(e,e.return,x)}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===e)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===e)break e;for(;p.sibling===null;){if(p.return===null||p.return===e)break e;f===p&&(f=null),p=p.return}f===p&&(f=null),p.sibling.return=p.return,p=p.sibling}}break;case 19:Et(t,e),Lt(e),r&4&&Gc(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(kf(n)){var r=n;break e}n=n.return}throw Error(M(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(Jr(a,""),r.flags&=-33);var o=Vc(e);ki(e,o,a);break;case 3:case 4:var i=r.stateNode.containerInfo,c=Vc(e);ji(e,c,i);break;default:throw Error(M(161))}}catch(l){Te(e,e.return,l)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Kh(e,t,n){K=e,Nf(e)}function Nf(e,t,n){for(var r=(e.mode&1)!==0;K!==null;){var a=K,o=a.child;if(a.tag===22&&r){var i=a.memoizedState!==null||Ls;if(!i){var c=a.alternate,l=c!==null&&c.memoizedState!==null||Ke;c=Ls;var d=Ke;if(Ls=i,(Ke=l)&&!d)for(K=a;K!==null;)i=K,l=i.child,i.tag===22&&i.memoizedState!==null?Qc(a):l!==null?(l.return=i,K=l):Qc(a);for(;o!==null;)K=o,Nf(o),o=o.sibling;K=a,Ls=c,Ke=d}Kc(e)}else a.subtreeFlags&8772&&o!==null?(o.return=a,K=o):Kc(e)}}function Kc(e){for(;K!==null;){var t=K;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ke||Wa(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Ke)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 o=t.updateQueue;o!==null&&Pc(t,o,r);break;case 3:var i=t.updateQueue;if(i!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Pc(t,i,n)}break;case 5:var c=t.stateNode;if(n===null&&t.flags&4){n=c;var l=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.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 p=f.dehydrated;p!==null&&es(p)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(M(163))}Ke||t.flags&512&&Si(t)}catch(m){Te(t,t.return,m)}}if(t===e){K=null;break}if(n=t.sibling,n!==null){n.return=t.return,K=n;break}K=t.return}}function Yc(e){for(;K!==null;){var t=K;if(t===e){K=null;break}var n=t.sibling;if(n!==null){n.return=t.return,K=n;break}K=t.return}}function Qc(e){for(;K!==null;){var t=K;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Wa(4,t)}catch(l){Te(t,n,l)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(l){Te(t,a,l)}}var o=t.return;try{Si(t)}catch(l){Te(t,o,l)}break;case 5:var i=t.return;try{Si(t)}catch(l){Te(t,i,l)}}}catch(l){Te(t,t.return,l)}if(t===e){K=null;break}var c=t.sibling;if(c!==null){c.return=t.return,K=c;break}K=t.return}}var Yh=Math.ceil,Ca=Zt.ReactCurrentDispatcher,jl=Zt.ReactCurrentOwner,jt=Zt.ReactCurrentBatchConfig,fe=0,Fe=null,Ae=null,We=0,ut=0,tr=jn(0),$e=0,ds=null,Fn=0,Ha=0,kl=0,Gr=null,rt=null,bl=0,pr=1/0,Ut=null,Na=!1,bi=null,gn=null,Ms=!1,un=null,Ea=0,Kr=0,Ci=null,Zs=-1,ea=0;function qe(){return fe&6?Re():Zs!==-1?Zs:Zs=Re()}function yn(e){return e.mode&1?fe&2&&We!==0?We&-We:Ph.transition!==null?(ea===0&&(ea=cd()),ea):(e=he,e!==0||(e=window.event,e=e===void 0?16:gd(e.type)),e):1}function At(e,t,n,r){if(50<Kr)throw Kr=0,Ci=null,Error(M(185));ps(e,n,r),(!(fe&2)||e!==Fe)&&(e===Fe&&(!(fe&2)&&(Ha|=n),$e===4&&ln(e,We)),it(e,r),n===1&&fe===0&&!(t.mode&1)&&(pr=Re()+500,Ba&&kn()))}function it(e,t){var n=e.callbackNode;Pp(e,t);var r=ua(e,e===Fe?We:0);if(r===0)n!==null&&sc(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&sc(n),t===1)e.tag===0?Rh(Jc.bind(null,e)):$d(Jc.bind(null,e)),Nh(function(){!(fe&6)&&kn()}),n=null;else{switch(ud(r)){case 1:n=Ji;break;case 4:n=id;break;case 16:n=ca;break;case 536870912:n=ld;break;default:n=ca}n=zf(n,Ef.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function Ef(e,t){if(Zs=-1,ea=0,fe&6)throw Error(M(327));var n=e.callbackNode;if(ir()&&e.callbackNode!==n)return null;var r=ua(e,e===Fe?We:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Ta(e,r);else{t=r;var a=fe;fe|=2;var o=If();(Fe!==e||We!==t)&&(Ut=null,pr=Re()+500,An(e,t));do try{Xh();break}catch(c){Tf(e,c)}while(!0);cl(),Ca.current=o,fe=a,Ae!==null?t=0:(Fe=null,We=0,t=$e)}if(t!==0){if(t===2&&(a=qo(e),a!==0&&(r=a,t=Ni(e,a))),t===1)throw n=ds,An(e,0),ln(e,r),it(e,Re()),n;if(t===6)ln(e,r);else{if(a=e.current.alternate,!(r&30)&&!Qh(a)&&(t=Ta(e,r),t===2&&(o=qo(e),o!==0&&(r=o,t=Ni(e,o))),t===1))throw n=ds,An(e,0),ln(e,r),it(e,Re()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(M(345));case 2:En(e,rt,Ut);break;case 3:if(ln(e,r),(r&130023424)===r&&(t=bl+500-Re(),10<t)){if(ua(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){qe(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=oi(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 i=31-_t(r);o=1<<i,i=t[i],i>a&&(a=i),r&=~o}if(r=a,r=Re()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Yh(r/1960))-r,10<r){e.timeoutHandle=oi(En.bind(null,e,rt,Ut),r);break}En(e,rt,Ut);break;case 5:En(e,rt,Ut);break;default:throw Error(M(329))}}}return it(e,Re()),e.callbackNode===n?Ef.bind(null,e):null}function Ni(e,t){var n=Gr;return e.current.memoizedState.isDehydrated&&(An(e,t).flags|=256),e=Ta(e,t),e!==2&&(t=rt,rt=n,t!==null&&Ei(t)),e}function Ei(e){rt===null?rt=e:rt.push.apply(rt,e)}function Qh(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],o=a.getSnapshot;a=a.value;try{if(!zt(o(),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&=~kl,t&=~Ha,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-_t(t),r=1<<n;e[n]=-1,t&=~r}}function Jc(e){if(fe&6)throw Error(M(327));ir();var t=ua(e,0);if(!(t&1))return it(e,Re()),null;var n=Ta(e,t);if(e.tag!==0&&n===2){var r=qo(e);r!==0&&(t=r,n=Ni(e,r))}if(n===1)throw n=ds,An(e,0),ln(e,t),it(e,Re()),n;if(n===6)throw Error(M(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,En(e,rt,Ut),it(e,Re()),null}function Cl(e,t){var n=fe;fe|=1;try{return e(t)}finally{fe=n,fe===0&&(pr=Re()+500,Ba&&kn())}}function On(e){un!==null&&un.tag===0&&!(fe&6)&&ir();var t=fe;fe|=1;var n=jt.transition,r=he;try{if(jt.transition=null,he=1,e)return e()}finally{he=r,jt.transition=n,fe=t,!(fe&6)&&kn()}}function Nl(){ut=tr.current,Se(tr)}function An(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Ch(n)),Ae!==null)for(n=Ae.return;n!==null;){var r=n;switch(ol(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&ha();break;case 3:fr(),Se(at),Se(Ye),hl();break;case 5:pl(r);break;case 4:fr();break;case 13:Se(Ce);break;case 19:Se(Ce);break;case 10:ul(r.type._context);break;case 22:case 23:Nl()}n=n.return}if(Fe=e,Ae=e=vn(e.current,null),We=ut=t,$e=0,ds=null,kl=Ha=Fn=0,rt=Gr=null,Rn!==null){for(t=0;t<Rn.length;t++)if(n=Rn[t],r=n.interleaved,r!==null){n.interleaved=null;var a=r.next,o=n.pending;if(o!==null){var i=o.next;o.next=a,r.next=i}n.pending=r}Rn=null}return e}function Tf(e,t){do{var n=Ae;try{if(cl(),Js.current=ba,ka){for(var r=Ne.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}ka=!1}if(Mn=0,Me=ze=Ne=null,Hr=!1,ls=0,jl.current=null,n===null||n.return===null){$e=1,ds=t,Ae=null;break}e:{var o=e,i=n.return,c=n,l=t;if(t=We,c.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var d=l,f=c,p=f.tag;if(!(f.mode&1)&&(p===0||p===11||p===15)){var m=f.alternate;m?(f.updateQueue=m.updateQueue,f.memoizedState=m.memoizedState,f.lanes=m.lanes):(f.updateQueue=null,f.memoizedState=null)}var w=Mc(i);if(w!==null){w.flags&=-257,Fc(w,i,c,o,t),w.mode&1&&Lc(o,d,t),t=w,l=d;var v=t.updateQueue;if(v===null){var x=new Set;x.add(l),t.updateQueue=x}else v.add(l);break e}else{if(!(t&1)){Lc(o,d,t),El();break e}l=Error(M(426))}}else if(ke&&c.mode&1){var j=Mc(i);if(j!==null){!(j.flags&65536)&&(j.flags|=256),Fc(j,i,c,o,t),il(mr(l,c));break e}}o=l=mr(l,c),$e!==4&&($e=2),Gr===null?Gr=[o]:Gr.push(o),o=i;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=df(o,l,t);Rc(o,g);break e;case 1:c=l;var h=o.type,y=o.stateNode;if(!(o.flags&128)&&(typeof h.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(gn===null||!gn.has(y)))){o.flags|=65536,t&=-t,o.lanes|=t;var S=ff(o,c,t);Rc(o,S);break e}}o=o.return}while(o!==null)}Pf(n)}catch(k){t=k,Ae===n&&n!==null&&(Ae=n=n.return);continue}break}while(!0)}function If(){var e=Ca.current;return Ca.current=ba,e===null?ba:e}function El(){($e===0||$e===3||$e===2)&&($e=4),Fe===null||!(Fn&268435455)&&!(Ha&268435455)||ln(Fe,We)}function Ta(e,t){var n=fe;fe|=2;var r=If();(Fe!==e||We!==t)&&(Ut=null,An(e,t));do try{Jh();break}catch(a){Tf(e,a)}while(!0);if(cl(),fe=n,Ca.current=r,Ae!==null)throw Error(M(261));return Fe=null,We=0,$e}function Jh(){for(;Ae!==null;)Rf(Ae)}function Xh(){for(;Ae!==null&&!jp();)Rf(Ae)}function Rf(e){var t=Af(e.alternate,e,ut);e.memoizedProps=e.pendingProps,t===null?Pf(e):Ae=t,jl.current=null}function Pf(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=Hh(n,t),n!==null){n.flags&=32767,Ae=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{$e=6,Ae=null;return}}else if(n=Wh(n,t,ut),n!==null){Ae=n;return}if(t=t.sibling,t!==null){Ae=t;return}Ae=t=e}while(t!==null);$e===0&&($e=5)}function En(e,t,n){var r=he,a=jt.transition;try{jt.transition=null,he=1,qh(e,t,n,r)}finally{jt.transition=a,he=r}return null}function qh(e,t,n,r){do ir();while(un!==null);if(fe&6)throw Error(M(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(M(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(_p(e,o),e===Fe&&(Ae=Fe=null,We=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Ms||(Ms=!0,zf(ca,function(){return ir(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=jt.transition,jt.transition=null;var i=he;he=1;var c=fe;fe|=4,jl.current=null,Gh(e,n),Cf(n,e),vh(si),da=!!ri,si=ri=null,e.current=n,Kh(n),kp(),fe=c,he=i,jt.transition=o}else e.current=n;if(Ms&&(Ms=!1,un=e,Ea=a),o=e.pendingLanes,o===0&&(gn=null),Np(n.stateNode),it(e,Re()),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(Na)throw Na=!1,e=bi,bi=null,e;return Ea&1&&e.tag!==0&&ir(),o=e.pendingLanes,o&1?e===Ci?Kr++:(Kr=0,Ci=e):Kr=0,kn(),null}function ir(){if(un!==null){var e=ud(Ea),t=jt.transition,n=he;try{if(jt.transition=null,he=16>e?16:e,un===null)var r=!1;else{if(e=un,un=null,Ea=0,fe&6)throw Error(M(331));var a=fe;for(fe|=4,K=e.current;K!==null;){var o=K,i=o.child;if(K.flags&16){var c=o.deletions;if(c!==null){for(var l=0;l<c.length;l++){var d=c[l];for(K=d;K!==null;){var f=K;switch(f.tag){case 0:case 11:case 15:Vr(8,f,o)}var p=f.child;if(p!==null)p.return=f,K=p;else for(;K!==null;){f=K;var m=f.sibling,w=f.return;if(jf(f),f===d){K=null;break}if(m!==null){m.return=w,K=m;break}K=w}}}var v=o.alternate;if(v!==null){var x=v.child;if(x!==null){v.child=null;do{var j=x.sibling;x.sibling=null,x=j}while(x!==null)}}K=o}}if(o.subtreeFlags&2064&&i!==null)i.return=o,K=i;else e:for(;K!==null;){if(o=K,o.flags&2048)switch(o.tag){case 0:case 11:case 15:Vr(9,o,o.return)}var g=o.sibling;if(g!==null){g.return=o.return,K=g;break e}K=o.return}}var h=e.current;for(K=h;K!==null;){i=K;var y=i.child;if(i.subtreeFlags&2064&&y!==null)y.return=i,K=y;else e:for(i=h;K!==null;){if(c=K,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:Wa(9,c)}}catch(k){Te(c,c.return,k)}if(c===i){K=null;break e}var S=c.sibling;if(S!==null){S.return=c.return,K=S;break e}K=c.return}}if(fe=a,kn(),Ot&&typeof Ot.onPostCommitFiberRoot=="function")try{Ot.onPostCommitFiberRoot($a,e)}catch{}r=!0}return r}finally{he=n,jt.transition=t}}return!1}function Xc(e,t,n){t=mr(n,t),t=df(e,t,1),e=hn(e,t,1),t=qe(),e!==null&&(ps(e,1,t),it(e,t))}function Te(e,t,n){if(e.tag===3)Xc(e,e,n);else for(;t!==null;){if(t.tag===3){Xc(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=mr(n,e),e=ff(t,e,1),t=hn(t,e,1),e=qe(),t!==null&&(ps(t,1,e),it(t,e));break}}t=t.return}}function Zh(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=qe(),e.pingedLanes|=e.suspendedLanes&n,Fe===e&&(We&n)===n&&($e===4||$e===3&&(We&130023424)===We&&500>Re()-bl?An(e,0):kl|=n),it(e,t)}function _f(e,t){t===0&&(e.mode&1?(t=Es,Es<<=1,!(Es&130023424)&&(Es=4194304)):t=1);var n=qe();e=Jt(e,t),e!==null&&(ps(e,t,n),it(e,n))}function eg(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),_f(e,n)}function tg(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(M(314))}r!==null&&r.delete(t),_f(e,n)}var Af;Af=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,Uh(e,t,n);st=!!(e.flags&131072)}else st=!1,ke&&t.flags&1048576&&Ld(t,va,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;qs(e,t),e=t.pendingProps;var a=cr(t,Ye.current);or(t,n),a=yl(null,t,r,e,a,n);var o=vl();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,ot(r)?(o=!0,ga(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,fl(t),a.updater=Ua,t.stateNode=a,a._reactInternals=t,mi(t,r,e,n),t=gi(null,t,r,!0,o,n)):(t.tag=0,ke&&o&&al(t),Je(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(qs(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=rg(r),e=Tt(r,e),a){case 0:t=hi(null,t,r,e,n);break e;case 1:t=Dc(null,t,r,e,n);break e;case 11:t=Oc(null,t,r,e,n);break e;case 14:t=Bc(null,t,r,Tt(r.type,e),n);break e}throw Error(M(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Tt(r,a),hi(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Tt(r,a),Dc(e,t,r,a,n);case 3:e:{if(gf(t),e===null)throw Error(M(387));r=t.pendingProps,o=t.memoizedState,a=o.element,Ud(e,t),Sa(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=mr(Error(M(423)),t),t=Uc(e,t,r,n,a);break e}else if(r!==a){a=mr(Error(M(424)),t),t=Uc(e,t,r,n,a);break e}else for(dt=pn(t.stateNode.containerInfo.firstChild),ft=t,ke=!0,Rt=null,n=Bd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(ur(),r===a){t=Xt(e,t,n);break e}Je(e,t,r,n)}t=t.child}return t;case 5:return Wd(t),e===null&&ui(t),r=t.type,a=t.pendingProps,o=e!==null?e.memoizedProps:null,i=a.children,ai(r,a)?i=null:o!==null&&ai(r,o)&&(t.flags|=32),hf(e,t),Je(e,t,i,n),t.child;case 6:return e===null&&ui(t),null;case 13:return yf(e,t,n);case 4:return ml(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=dr(t,null,r,n):Je(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Tt(r,a),Oc(e,t,r,a,n);case 7:return Je(e,t,t.pendingProps,n),t.child;case 8:return Je(e,t,t.pendingProps.children,n),t.child;case 12:return Je(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,o=t.memoizedProps,i=a.value,xe(xa,r._currentValue),r._currentValue=i,o!==null)if(zt(o.value,i)){if(o.children===a.children&&!at.current){t=Xt(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){i=o.child;for(var l=c.firstContext;l!==null;){if(l.context===r){if(o.tag===1){l=Kt(-1,n&-n),l.tag=2;var d=o.updateQueue;if(d!==null){d=d.shared;var f=d.pending;f===null?l.next=l:(l.next=f.next,f.next=l),d.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),di(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(M(341));i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),di(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}Je(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,or(t,n),a=kt(a),r=r(a),t.flags|=1,Je(e,t,r,n),t.child;case 14:return r=t.type,a=Tt(r,t.pendingProps),a=Tt(r.type,a),Bc(e,t,r,a,n);case 15:return mf(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:Tt(r,a),qs(e,t),t.tag=1,ot(r)?(e=!0,ga(t)):e=!1,or(t,n),uf(t,r,a),mi(t,r,a,n),gi(null,t,r,!0,e,n);case 19:return vf(e,t,n);case 22:return pf(e,t,n)}throw Error(M(156,t.tag))};function zf(e,t){return od(e,t)}function ng(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 St(e,t,n,r){return new ng(e,t,n,r)}function Tl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function rg(e){if(typeof e=="function")return Tl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ki)return 11;if(e===Yi)return 14}return 2}function vn(e,t){var n=e.alternate;return n===null?(n=St(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 ta(e,t,n,r,a,o){var i=2;if(r=e,typeof e=="function")Tl(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Vn:return zn(n.children,a,o,t);case Gi:i=8,a|=8;break;case Mo:return e=St(12,n,t,a|2),e.elementType=Mo,e.lanes=o,e;case Fo:return e=St(13,n,t,a),e.elementType=Fo,e.lanes=o,e;case Oo:return e=St(19,n,t,a),e.elementType=Oo,e.lanes=o,e;case Wu:return Va(n,a,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Du:i=10;break e;case Uu:i=9;break e;case Ki:i=11;break e;case Yi:i=14;break e;case sn:i=16,r=null;break e}throw Error(M(130,e==null?e:typeof e,""))}return t=St(i,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function zn(e,t,n,r){return e=St(7,e,r,t),e.lanes=n,e}function Va(e,t,n,r){return e=St(22,e,r,t),e.elementType=Wu,e.lanes=n,e.stateNode={isHidden:!1},e}function No(e,t,n){return e=St(6,e,null,t),e.lanes=n,e}function Eo(e,t,n){return t=St(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function sg(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=oo(0),this.expirationTimes=oo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=oo(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Il(e,t,n,r,a,o,i,c,l){return e=new sg(e,t,n,c,l),t===1?(t=1,o===!0&&(t|=8)):t=0,o=St(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fl(o),e}function ag(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Hn,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function $f(e){if(!e)return wn;e=e._reactInternals;e:{if(Dn(e)!==e||e.tag!==1)throw Error(M(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ot(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(M(171))}if(e.tag===1){var n=e.type;if(ot(n))return zd(e,n,t)}return t}function Lf(e,t,n,r,a,o,i,c,l){return e=Il(n,r,!0,e,a,o,i,c,l),e.context=$f(null),n=e.current,r=qe(),a=yn(n),o=Kt(r,a),o.callback=t??null,hn(n,o,a),e.current.lanes=a,ps(e,a,r),it(e,r),e}function Ga(e,t,n,r){var a=t.current,o=qe(),i=yn(a);return n=$f(n),t.context===null?t.context=n:t.pendingContext=n,t=Kt(o,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=hn(a,t,i),e!==null&&(At(e,a,i,o),Qs(e,a,i)),i}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 qc(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Rl(e,t){qc(e,t),(e=e.alternate)&&qc(e,t)}function og(){return null}var Mf=typeof reportError=="function"?reportError:function(e){console.error(e)};function Pl(e){this._internalRoot=e}Ka.prototype.render=Pl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(M(409));Ga(e,t,null,null)};Ka.prototype.unmount=Pl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;On(function(){Ga(null,e,null,null)}),t[Qt]=null}};function Ka(e){this._internalRoot=e}Ka.prototype.unstable_scheduleHydration=function(e){if(e){var t=md();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&&hd(e)}};function _l(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Ya(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Zc(){}function ig(e,t,n,r,a){if(a){if(typeof r=="function"){var o=r;r=function(){var d=Ia(i);o.call(d)}}var i=Lf(t,r,e,0,null,!1,!1,"",Zc);return e._reactRootContainer=i,e[Qt]=i.current,rs(e.nodeType===8?e.parentNode:e),On(),i}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var c=r;r=function(){var d=Ia(l);c.call(d)}}var l=Il(e,0,!1,null,null,!1,!1,"",Zc);return e._reactRootContainer=l,e[Qt]=l.current,rs(e.nodeType===8?e.parentNode:e),On(function(){Ga(t,l,n,r)}),l}function Qa(e,t,n,r,a){var o=n._reactRootContainer;if(o){var i=o;if(typeof a=="function"){var c=a;a=function(){var l=Ia(i);c.call(l)}}Ga(t,i,e,a)}else i=ig(n,t,e,a,r);return Ia(i)}dd=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Lr(t.pendingLanes);n!==0&&(Xi(t,n|1),it(t,Re()),!(fe&6)&&(pr=Re()+500,kn()))}break;case 13:On(function(){var r=Jt(e,1);if(r!==null){var a=qe();At(r,e,1,a)}}),Rl(e,1)}};qi=function(e){if(e.tag===13){var t=Jt(e,134217728);if(t!==null){var n=qe();At(t,e,134217728,n)}Rl(e,134217728)}};fd=function(e){if(e.tag===13){var t=yn(e),n=Jt(e,t);if(n!==null){var r=qe();At(n,e,t,r)}Rl(e,t)}};md=function(){return he};pd=function(e,t){var n=he;try{return he=e,t()}finally{he=n}};Qo=function(e,t,n){switch(t){case"input":if(Uo(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=Oa(r);if(!a)throw Error(M(90));Vu(r),Uo(r,a)}}}break;case"textarea":Ku(e,n);break;case"select":t=n.value,t!=null&&nr(e,!!n.multiple,t,!1)}};ed=Cl;td=On;var lg={usingClientEntryPoint:!1,Events:[gs,Qn,Oa,qu,Zu,Cl]},Ir={findFiberByHostInstance:In,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},cg={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=sd(e),e===null?null:e.stateNode},findFiberByHostInstance:Ir.findFiberByHostInstance||og,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 Fs=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Fs.isDisabled&&Fs.supportsFiber)try{$a=Fs.inject(cg),Ot=Fs}catch{}}pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=lg;pt.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!_l(t))throw Error(M(200));return ag(e,t,null,n)};pt.createRoot=function(e,t){if(!_l(e))throw Error(M(299));var n=!1,r="",a=Mf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=Il(e,1,!1,null,null,n,!1,r,a),e[Qt]=t.current,rs(e.nodeType===8?e.parentNode:e),new Pl(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(M(188)):(e=Object.keys(e).join(","),Error(M(268,e)));return e=sd(t),e=e===null?null:e.stateNode,e};pt.flushSync=function(e){return On(e)};pt.hydrate=function(e,t,n){if(!Ya(t))throw Error(M(200));return Qa(null,e,t,!0,n)};pt.hydrateRoot=function(e,t,n){if(!_l(e))throw Error(M(405));var r=n!=null&&n.hydratedSources||null,a=!1,o="",i=Mf;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=Lf(t,null,e,1,n??null,a,!1,o,i),e[Qt]=t.current,rs(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 Ka(t)};pt.render=function(e,t,n){if(!Ya(t))throw Error(M(200));return Qa(null,e,t,!1,n)};pt.unmountComponentAtNode=function(e){if(!Ya(e))throw Error(M(40));return e._reactRootContainer?(On(function(){Qa(null,null,e,!1,function(){e._reactRootContainer=null,e[Qt]=null})}),!0):!1};pt.unstable_batchedUpdates=Cl;pt.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Ya(n))throw Error(M(200));if(e==null||e._reactInternals===void 0)throw Error(M(38));return Qa(e,t,n,!1,r)};pt.version="18.3.1-next-f1338f8080-20240426";function Ff(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ff)}catch(e){console.error(e)}}Ff(),Mu.exports=pt;var Of=Mu.exports,Bf,eu=Of;Bf=eu.createRoot,eu.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 tu="popstate";function nu(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function ug(e={}){function t(r,a){var d;let o=(d=a.state)==null?void 0:d.masked,{pathname:i,search:c,hash:l}=o||r.location;return Ti("",{pathname:i,search:c,hash:l},a.state&&a.state.usr||null,a.state&&a.state.key||"default",o?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,a){return typeof a=="string"?a:fs(a)}return fg(t,n,null,e)}function be(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ct(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function dg(){return Math.random().toString(36).substring(2,10)}function ru(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 Ti(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?vr(t):t,state:n,key:t&&t.key||r||dg(),unstable_mask:a}}function fs({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 vr(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 fg(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:o=!1}=r,i=a.history,c="POP",l=null,d=f();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function f(){return(i.state||{idx:null}).idx}function p(){c="POP";let j=f(),g=j==null?null:j-d;d=j,l&&l({action:c,location:x.location,delta:g})}function m(j,g){c="PUSH";let h=nu(j)?j:Ti(x.location,j,g);d=f()+1;let y=ru(h,d),S=x.createHref(h.unstable_mask||h);try{i.pushState(y,"",S)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;a.location.assign(S)}o&&l&&l({action:c,location:x.location,delta:1})}function w(j,g){c="REPLACE";let h=nu(j)?j:Ti(x.location,j,g);d=f();let y=ru(h,d),S=x.createHref(h.unstable_mask||h);i.replaceState(y,"",S),o&&l&&l({action:c,location:x.location,delta:0})}function v(j){return mg(j)}let x={get action(){return c},get location(){return e(a,i)},listen(j){if(l)throw new Error("A history only accepts one active listener");return a.addEventListener(tu,p),l=j,()=>{a.removeEventListener(tu,p),l=null}},createHref(j){return t(a,j)},createURL:v,encodeLocation(j){let g=v(j);return{pathname:g.pathname,search:g.search,hash:g.hash}},push:m,replace:w,go(j){return i.go(j)}};return x}function mg(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:fs(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Df(e,t,n="/"){return pg(e,t,n,!1)}function pg(e,t,n,r){let a=typeof t=="string"?vr(t):t,o=qt(a.pathname||"/",n);if(o==null)return null;let i=Uf(e);hg(i);let c=null;for(let l=0;c==null&&l<i.length;++l){let d=Ng(o);c=bg(i[l],d,r)}return c}function Uf(e,t=[],n=[],r="",a=!1){let o=(i,c,l=a,d)=>{let f={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:c,route:i};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&l)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 p=Dt([r,f.relativePath]),m=n.concat(f);i.children&&i.children.length>0&&(be(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),Uf(i.children,t,m,p,l)),!(i.path==null&&!i.index)&&t.push({path:p,score:jg(p,i.index),routesMeta:m})};return e.forEach((i,c)=>{var l;if(i.path===""||!((l=i.path)!=null&&l.includes("?")))o(i,c);else for(let d of Wf(i.path))o(i,c,!0,d)}),t}function Wf(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return a?[o,""]:[o];let i=Wf(r.join("/")),c=[];return c.push(...i.map(l=>l===""?o:[o,l].join("/"))),a&&c.push(...i),c.map(l=>e.startsWith("/")&&l===""?"/":l)}function hg(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:kg(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var gg=/^:[\w-]+$/,yg=3,vg=2,xg=1,wg=10,Sg=-2,su=e=>e==="*";function jg(e,t){let n=e.split("/"),r=n.length;return n.some(su)&&(r+=Sg),t&&(r+=vg),n.filter(a=>!su(a)).reduce((a,o)=>a+(gg.test(o)?yg:o===""?xg:wg),r)}function kg(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 bg(e,t,n=!1){let{routesMeta:r}=e,a={},o="/",i=[];for(let c=0;c<r.length;++c){let l=r[c],d=c===r.length-1,f=o==="/"?t:t.slice(o.length)||"/",p=Ra({path:l.relativePath,caseSensitive:l.caseSensitive,end:d},f),m=l.route;if(!p&&d&&n&&!r[r.length-1].route.index&&(p=Ra({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},f)),!p)return null;Object.assign(a,p.params),i.push({params:a,pathname:Dt([o,p.pathname]),pathnameBase:Rg(Dt([o,p.pathnameBase])),route:m}),p.pathnameBase!=="/"&&(o=Dt([o,p.pathnameBase]))}return i}function Ra(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Cg(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let o=a[0],i=o.replace(/(.)\/+$/,"$1"),c=a.slice(1);return{params:r.reduce((d,{paramName:f,isOptional:p},m)=>{if(f==="*"){let v=c[m]||"";i=o.slice(0,o.length-v.length).replace(/(.)\/+$/,"$1")}const w=c[m];return p&&!w?d[f]=void 0:d[f]=(w||"").replace(/%2F/g,"/"),d},{}),pathname:o,pathnameBase:i,pattern:e}}function Cg(e,t=!1,n=!0){Ct(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,(i,c,l,d,f)=>{if(r.push({paramName:c,isOptional:l!=null}),l){let p=f.charAt(d+i.length);return p&&p!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}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 Ng(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ct(!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 Eg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Tg(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?vr(e):e,o;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?o=au(n.substring(1),"/"):o=au(n,t)):o=t,{pathname:o,search:Pg(r),hash:_g(a)}}function au(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 To(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 Ig(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Al(e){let t=Ig(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Ja(e,t,n,r=!1){let a;typeof e=="string"?a=vr(e):(a={...e},be(!a.pathname||!a.pathname.includes("?"),To("?","pathname","search",a)),be(!a.pathname||!a.pathname.includes("#"),To("#","pathname","hash",a)),be(!a.search||!a.search.includes("#"),To("#","search","hash",a)));let o=e===""||a.pathname==="",i=o?"/":a.pathname,c;if(i==null)c=n;else{let p=t.length-1;if(!r&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),p-=1;a.pathname=m.join("/")}c=p>=0?t[p]:"/"}let l=Tg(a,c),d=i&&i!=="/"&&i.endsWith("/"),f=(o||i===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(d||f)&&(l.pathname+="/"),l}var Dt=e=>e.join("/").replace(/\/\/+/g,"/"),Rg=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Pg=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,_g=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Ag=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 zg(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function $g(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Hf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Vf(e,t){let n=e;if(typeof n!="string"||!Eg.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(Hf)try{let o=new URL(window.location.href),i=n.startsWith("//")?new URL(o.protocol+n):new URL(n),c=qt(i.pathname,t);i.origin===o.origin&&c!=null?n=c+i.search+i.hash:a=!0}catch{Ct(!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 Gf=["POST","PUT","PATCH","DELETE"];new Set(Gf);var Lg=["GET",...Gf];new Set(Lg);var xr=u.createContext(null);xr.displayName="DataRouter";var Xa=u.createContext(null);Xa.displayName="DataRouterState";var Mg=u.createContext(!1),Kf=u.createContext({isTransitioning:!1});Kf.displayName="ViewTransition";var Fg=u.createContext(new Map);Fg.displayName="Fetchers";var Og=u.createContext(null);Og.displayName="Await";var gt=u.createContext(null);gt.displayName="Navigation";var vs=u.createContext(null);vs.displayName="Location";var $t=u.createContext({outlet:null,matches:[],isDataRoute:!1});$t.displayName="Route";var zl=u.createContext(null);zl.displayName="RouteError";var Yf="REACT_ROUTER_ERROR",Bg="REDIRECT",Dg="ROUTE_ERROR_RESPONSE";function Ug(e){if(e.startsWith(`${Yf}:${Bg}:{`))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 Wg(e){if(e.startsWith(`${Yf}:${Dg}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Ag(t.status,t.statusText,t.data)}catch{}}function Hg(e,{relative:t}={}){be(wr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=u.useContext(gt),{hash:a,pathname:o,search:i}=xs(e,{relative:t}),c=o;return n!=="/"&&(c=o==="/"?n:Dt([n,o])),r.createHref({pathname:c,search:i,hash:a})}function wr(){return u.useContext(vs)!=null}function yt(){return be(wr(),"useLocation() may be used only in the context of a <Router> component."),u.useContext(vs).location}var Qf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Jf(e){u.useContext(gt).static||u.useLayoutEffect(e)}function en(){let{isDataRoute:e}=u.useContext($t);return e?ay():Vg()}function Vg(){be(wr(),"useNavigate() may be used only in the context of a <Router> component.");let e=u.useContext(xr),{basename:t,navigator:n}=u.useContext(gt),{matches:r}=u.useContext($t),{pathname:a}=yt(),o=JSON.stringify(Al(r)),i=u.useRef(!1);return Jf(()=>{i.current=!0}),u.useCallback((l,d={})=>{if(Ct(i.current,Qf),!i.current)return;if(typeof l=="number"){n.go(l);return}let f=Ja(l,JSON.parse(o),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,o,a,e])}var Gg=u.createContext(null);function Kg(e){let t=u.useContext($t).outlet;return u.useMemo(()=>t&&u.createElement(Gg.Provider,{value:e},t),[t,e])}function xs(e,{relative:t}={}){let{matches:n}=u.useContext($t),{pathname:r}=yt(),a=JSON.stringify(Al(n));return u.useMemo(()=>Ja(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Yg(e,t){return Xf(e,t)}function Xf(e,t,n){var j;be(wr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=u.useContext(gt),{matches:a}=u.useContext($t),o=a[a.length-1],i=o?o.params:{},c=o?o.pathname:"/",l=o?o.pathnameBase:"/",d=o&&o.route;{let g=d&&d.path||"";Zf(c,!d||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (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(),p;if(t){let g=typeof t=="string"?vr(t):t;be(l==="/"||((j=g.pathname)==null?void 0:j.startsWith(l)),`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 "${l}" but pathname "${g.pathname}" was given in the \`location\` prop.`),p=g}else p=f;let m=p.pathname||"/",w=m;if(l!=="/"){let g=l.replace(/^\//,"").split("/");w="/"+m.replace(/^\//,"").split("/").slice(g.length).join("/")}let v=Df(e,{pathname:w});Ct(d||v!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Ct(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.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 x=Zg(v&&v.map(g=>Object.assign({},g,{params:Object.assign({},i,g.params),pathname:Dt([l,r.encodeLocation?r.encodeLocation(g.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?l:Dt([l,r.encodeLocation?r.encodeLocation(g.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),a,n);return t&&x?u.createElement(vs.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...p},navigationType:"POP"}},x):x}function Qg(){let e=sy(),t=zg(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},o={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=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:o},"ErrorBoundary")," or"," ",u.createElement("code",{style:o},"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,i)}var Jg=u.createElement(Qg,null),qf=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=Wg(e.digest);n&&(e=n)}let t=e!==void 0?u.createElement($t.Provider,{value:this.props.routeContext},u.createElement(zl.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?u.createElement(Xg,{error:e},t):t}};qf.contextType=Mg;var Io=new WeakMap;function Xg({children:e,error:t}){let{basename:n}=u.useContext(gt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Ug(t.digest);if(r){let a=Io.get(t);if(a)throw a;let o=Vf(r.location,n);if(Hf&&!Io.get(t))if(o.isExternal||r.reloadDocument)window.location.href=o.absoluteURL||o.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:r.replace}));throw Io.set(t,i),i}return u.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return e}function qg({routeContext:e,match:t,children:n}){let r=u.useContext(xr);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 Zg(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,o=r==null?void 0:r.errors;if(o!=null){let f=a.findIndex(p=>p.route.id&&(o==null?void 0:o[p.route.id])!==void 0);be(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),a=a.slice(0,Math.min(a.length,f+1))}let i=!1,c=-1;if(n&&r){i=r.renderFallback;for(let f=0;f<a.length;f++){let p=a[f];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(c=f),p.route.id){let{loaderData:m,errors:w}=r,v=p.route.loader&&!m.hasOwnProperty(p.route.id)&&(!w||w[p.route.id]===void 0);if(p.route.lazy||v){n.isStatic&&(i=!0),c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}}let l=n==null?void 0:n.onError,d=r&&l?(f,p)=>{var m,w;l(f,{location:r.location,params:((w=(m=r.matches)==null?void 0:m[0])==null?void 0:w.params)??{},unstable_pattern:$g(r.matches),errorInfo:p})}:void 0;return a.reduceRight((f,p,m)=>{let w,v=!1,x=null,j=null;r&&(w=o&&p.route.id?o[p.route.id]:void 0,x=p.route.errorElement||Jg,i&&(c<0&&m===0?(Zf("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),v=!0,j=null):c===m&&(v=!0,j=p.route.hydrateFallbackElement||null)));let g=t.concat(a.slice(0,m+1)),h=()=>{let y;return w?y=x:v?y=j:p.route.Component?y=u.createElement(p.route.Component,null):p.route.element?y=p.route.element:y=f,u.createElement(qg,{match:p,routeContext:{outlet:f,matches:g,isDataRoute:r!=null},children:y})};return r&&(p.route.ErrorBoundary||p.route.errorElement||m===0)?u.createElement(qf,{location:r.location,revalidation:r.revalidation,component:x,error:w,children:h(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:d}):h()},null)}function $l(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ey(e){let t=u.useContext(xr);return be(t,$l(e)),t}function ty(e){let t=u.useContext(Xa);return be(t,$l(e)),t}function ny(e){let t=u.useContext($t);return be(t,$l(e)),t}function Ll(e){let t=ny(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 ry(){return Ll("useRouteId")}function sy(){var r;let e=u.useContext(zl),t=ty("useRouteError"),n=Ll("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function ay(){let{router:e}=ey("useNavigate"),t=Ll("useNavigate"),n=u.useRef(!1);return Jf(()=>{n.current=!0}),u.useCallback(async(a,o={})=>{Ct(n.current,Qf),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...o}))},[e,t])}var ou={};function Zf(e,t,n){!t&&!ou[e]&&(ou[e]=!0,Ct(!1,n))}u.memo(oy);function oy({routes:e,future:t,state:n,isStatic:r,onError:a}){return Xf(e,void 0,{state:n,isStatic:r,onError:a})}function Ht({to:e,replace:t,state:n,relative:r}){be(wr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=u.useContext(gt);Ct(!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:o}=u.useContext($t),{pathname:i}=yt(),c=en(),l=Ja(e,Al(o),i,r==="path"),d=JSON.stringify(l);return u.useEffect(()=>{c(JSON.parse(d),{replace:t,state:n,relative:r})},[c,d,r,t,n]),null}function iy(e){return Kg(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 ly({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:o=!1,unstable_useTransitions:i}){be(!wr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),l=u.useMemo(()=>({basename:c,navigator:a,static:o,unstable_useTransitions:i,future:{}}),[c,a,o,i]);typeof n=="string"&&(n=vr(n));let{pathname:d="/",search:f="",hash:p="",state:m=null,key:w="default",unstable_mask:v}=n,x=u.useMemo(()=>{let j=qt(d,c);return j==null?null:{location:{pathname:j,search:f,hash:p,state:m,key:w,unstable_mask:v},navigationType:r}},[c,d,f,p,m,w,r,v]);return Ct(x!=null,`<Router basename="${c}"> is not able to match the URL "${d}${f}${p}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:u.createElement(gt.Provider,{value:l},u.createElement(vs.Provider,{children:t,value:x}))}function cy({children:e,location:t}){return Yg(Ii(e),t)}function Ii(e,t=[]){let n=[];return u.Children.forEach(e,(r,a)=>{if(!u.isValidElement(r))return;let o=[...t,a];if(r.type===u.Fragment){n.push.apply(n,Ii(r.props.children,o));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 i={id:r.props.id||o.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&&(i.children=Ii(r.props.children,o)),n.push(i)}),n}var na="get",ra="application/x-www-form-urlencoded";function qa(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function uy(e){return qa(e)&&e.tagName.toLowerCase()==="button"}function dy(e){return qa(e)&&e.tagName.toLowerCase()==="form"}function fy(e){return qa(e)&&e.tagName.toLowerCase()==="input"}function my(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function py(e,t){return e.button===0&&(!t||t==="_self")&&!my(e)}function Ri(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 hy(e,t){let n=Ri(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(o=>{n.append(a,o)})}),n}var Os=null;function gy(){if(Os===null)try{new FormData(document.createElement("form"),0),Os=!1}catch{Os=!0}return Os}var yy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ro(e){return e!=null&&!yy.has(e)?(Ct(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ra}"`),null):e}function vy(e,t){let n,r,a,o,i;if(dy(e)){let c=e.getAttribute("action");r=c?qt(c,t):null,n=e.getAttribute("method")||na,a=Ro(e.getAttribute("enctype"))||ra,o=new FormData(e)}else if(uy(e)||fy(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||c.getAttribute("action");if(r=l?qt(l,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||na,a=Ro(e.getAttribute("formenctype"))||Ro(c.getAttribute("enctype"))||ra,o=new FormData(c,e),!gy()){let{name:d,type:f,value:p}=e;if(f==="image"){let m=d?`${d}.`:"";o.append(`${m}x`,"0"),o.append(`${m}y`,"0")}else d&&o.append(d,p)}}else{if(qa(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=na,r=null,a=ra,i=e}return o&&a==="text/plain"&&(i=o,o=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:o,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Ml(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function xy(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 wy(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 Sy(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 jy(e,t,n){let r=await Promise.all(e.map(async a=>{let o=t.routes[a.route.id];if(o){let i=await wy(o,n);return i.links?i.links():[]}return[]}));return Ny(r.flat(1).filter(Sy).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function iu(e,t,n,r,a,o){let i=(l,d)=>n[d]?l.route.id!==n[d].route.id:!0,c=(l,d)=>{var f;return n[d].pathname!==l.pathname||((f=n[d].route.path)==null?void 0:f.endsWith("*"))&&n[d].params["*"]!==l.params["*"]};return o==="assets"?t.filter((l,d)=>i(l,d)||c(l,d)):o==="data"?t.filter((l,d)=>{var p;let f=r.routes[l.route.id];if(!f||!f.hasLoader)return!1;if(i(l,d)||c(l,d))return!0;if(l.route.shouldRevalidate){let m=l.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((p=n[0])==null?void 0:p.params)||{},nextUrl:new URL(e,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function ky(e,t,{includeHydrateFallback:n}={}){return by(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let o=[a.module];return a.clientActionModule&&(o=o.concat(a.clientActionModule)),a.clientLoaderModule&&(o=o.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(o=o.concat(a.hydrateFallbackModule)),a.imports&&(o=o.concat(a.imports)),o}).flat(1))}function by(e){return[...new Set(e)]}function Cy(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Ny(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let o=JSON.stringify(Cy(a));return n.has(o)||(n.add(o),r.push({key:o,link:a})),r},[])}function em(){let e=u.useContext(xr);return Ml(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Ey(){let e=u.useContext(Xa);return Ml(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Fl=u.createContext(void 0);Fl.displayName="FrameworkContext";function tm(){let e=u.useContext(Fl);return Ml(e,"You must render this element inside a <HydratedRouter> element"),e}function Ty(e,t){let n=u.useContext(Fl),[r,a]=u.useState(!1),[o,i]=u.useState(!1),{onFocus:c,onBlur:l,onMouseEnter:d,onMouseLeave:f,onTouchStart:p}=t,m=u.useRef(null);u.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let x=g=>{g.forEach(h=>{i(h.isIntersecting)})},j=new IntersectionObserver(x,{threshold:.5});return m.current&&j.observe(m.current),()=>{j.disconnect()}}},[e]),u.useEffect(()=>{if(r){let x=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(x)}}},[r]);let w=()=>{a(!0)},v=()=>{a(!1),i(!1)};return n?e!=="intent"?[o,m,{}]:[o,m,{onFocus:Rr(c,w),onBlur:Rr(l,v),onMouseEnter:Rr(d,w),onMouseLeave:Rr(f,v),onTouchStart:Rr(p,w)}]:[!1,m,{}]}function Rr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Iy({page:e,...t}){let{router:n}=em(),r=u.useMemo(()=>Df(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?u.createElement(Py,{page:e,matches:r,...t}):null}function Ry(e){let{manifest:t,routeModules:n}=tm(),[r,a]=u.useState([]);return u.useEffect(()=>{let o=!1;return jy(e,t,n).then(i=>{o||a(i)}),()=>{o=!0}},[e,t,n]),r}function Py({page:e,matches:t,...n}){let r=yt(),{future:a,manifest:o,routeModules:i}=tm(),{basename:c}=em(),{loaderData:l,matches:d}=Ey(),f=u.useMemo(()=>iu(e,t,d,o,r,"data"),[e,t,d,o,r]),p=u.useMemo(()=>iu(e,t,d,o,r,"assets"),[e,t,d,o,r]),m=u.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let x=new Set,j=!1;if(t.forEach(h=>{var S;let y=o.routes[h.route.id];!y||!y.hasLoader||(!f.some(k=>k.route.id===h.route.id)&&h.route.id in l&&((S=i[h.route.id])!=null&&S.shouldRevalidate)||y.hasClientLoader?j=!0:x.add(h.route.id))}),x.size===0)return[];let g=xy(e,c,a.unstable_trailingSlashAwareDataRequests,"data");return j&&x.size>0&&g.searchParams.set("_routes",t.filter(h=>x.has(h.route.id)).map(h=>h.route.id).join(",")),[g.pathname+g.search]},[c,a.unstable_trailingSlashAwareDataRequests,l,r,o,f,t,e,i]),w=u.useMemo(()=>ky(p,o),[p,o]),v=Ry(p);return u.createElement(u.Fragment,null,m.map(x=>u.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),w.map(x=>u.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),v.map(({key:x,link:j})=>u.createElement("link",{key:x,nonce:n.nonce,...j,crossOrigin:j.crossOrigin??n.crossOrigin})))}function _y(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Ay=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Ay&&(window.__reactRouterVersion="7.13.1")}catch{}function zy({basename:e,children:t,unstable_useTransitions:n,window:r}){let a=u.useRef();a.current==null&&(a.current=ug({window:r,v5Compat:!0}));let o=a.current,[i,c]=u.useState({action:o.action,location:o.location}),l=u.useCallback(d=>{n===!1?c(d):u.startTransition(()=>c(d))},[n]);return u.useLayoutEffect(()=>o.listen(l),[o,l]),u.createElement(ly,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o,unstable_useTransitions:n})}var nm=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Xe=u.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:o,replace:i,unstable_mask:c,state:l,target:d,to:f,preventScrollReset:p,viewTransition:m,unstable_defaultShouldRevalidate:w,...v},x){let{basename:j,navigator:g,unstable_useTransitions:h}=u.useContext(gt),y=typeof f=="string"&&nm.test(f),S=Vf(f,j);f=S.to;let k=Hg(f,{relative:a}),N=yt(),C=null;if(c){let A=Ja(c,[],N.unstable_mask?N.unstable_mask.pathname:"/",!0);j!=="/"&&(A.pathname=A.pathname==="/"?j:Dt([j,A.pathname])),C=g.createHref(A)}let[P,E,z]=Ty(r,v),U=My(f,{replace:i,unstable_mask:c,state:l,target:d,preventScrollReset:p,relative:a,viewTransition:m,unstable_defaultShouldRevalidate:w,unstable_useTransitions:h});function V(A){t&&t(A),A.defaultPrevented||U(A)}let Q=!(S.isExternal||o),D=u.createElement("a",{...v,...z,href:(Q?C:void 0)||S.absoluteURL||k,onClick:Q?V:t,ref:_y(x,E),target:d,"data-discover":!y&&n==="render"?"true":void 0});return P&&!y?u.createElement(u.Fragment,null,D,u.createElement(Iy,{page:k})):D});Xe.displayName="Link";var Ol=u.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:o,to:i,viewTransition:c,children:l,...d},f){let p=xs(i,{relative:d.relative}),m=yt(),w=u.useContext(Xa),{navigator:v,basename:x}=u.useContext(gt),j=w!=null&&Uy(p)&&c===!0,g=v.encodeLocation?v.encodeLocation(p).pathname:p.pathname,h=m.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&&x&&(y=qt(y,x)||y);const S=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let k=h===g||!a&&h.startsWith(g)&&h.charAt(S)==="/",N=y!=null&&(y===g||!a&&y.startsWith(g)&&y.charAt(g.length)==="/"),C={isActive:k,isPending:N,isTransitioning:j},P=k?t:void 0,E;typeof r=="function"?E=r(C):E=[r,k?"active":null,N?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let z=typeof o=="function"?o(C):o;return u.createElement(Xe,{...d,"aria-current":P,className:E,ref:f,style:z,to:i,viewTransition:c},typeof l=="function"?l(C):l)});Ol.displayName="NavLink";var $y=u.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:o,method:i=na,action:c,onSubmit:l,relative:d,preventScrollReset:f,viewTransition:p,unstable_defaultShouldRevalidate:m,...w},v)=>{let{unstable_useTransitions:x}=u.useContext(gt),j=By(),g=Dy(c,{relative:d}),h=i.toLowerCase()==="get"?"get":"post",y=typeof c=="string"&&nm.test(c),S=k=>{if(l&&l(k),k.defaultPrevented)return;k.preventDefault();let N=k.nativeEvent.submitter,C=(N==null?void 0:N.getAttribute("formmethod"))||i,P=()=>j(N||k.currentTarget,{fetcherKey:t,method:C,navigate:n,replace:a,state:o,relative:d,preventScrollReset:f,viewTransition:p,unstable_defaultShouldRevalidate:m});x&&n!==!1?u.startTransition(()=>P()):P()};return u.createElement("form",{ref:v,method:h,action:g,onSubmit:r?l:S,...w,"data-discover":!y&&e==="render"?"true":void 0})});$y.displayName="Form";function Ly(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function rm(e){let t=u.useContext(xr);return be(t,Ly(e)),t}function My(e,{target:t,replace:n,unstable_mask:r,state:a,preventScrollReset:o,relative:i,viewTransition:c,unstable_defaultShouldRevalidate:l,unstable_useTransitions:d}={}){let f=en(),p=yt(),m=xs(e,{relative:i});return u.useCallback(w=>{if(py(w,t)){w.preventDefault();let v=n!==void 0?n:fs(p)===fs(m),x=()=>f(e,{replace:v,unstable_mask:r,state:a,preventScrollReset:o,relative:i,viewTransition:c,unstable_defaultShouldRevalidate:l});d?u.startTransition(()=>x()):x()}},[p,f,m,n,r,a,t,e,o,i,c,l,d])}function sm(e){Ct(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(Ri(e)),n=u.useRef(!1),r=yt(),a=u.useMemo(()=>hy(r.search,n.current?null:t.current),[r.search]),o=en(),i=u.useCallback((c,l)=>{const d=Ri(typeof c=="function"?c(new URLSearchParams(a)):c);n.current=!0,o("?"+d,l)},[o,a]);return[a,i]}var Fy=0,Oy=()=>`__${String(++Fy)}__`;function By(){let{router:e}=rm("useSubmit"),{basename:t}=u.useContext(gt),n=ry(),r=e.fetch,a=e.navigate;return u.useCallback(async(o,i={})=>{let{action:c,method:l,encType:d,formData:f,body:p}=vy(o,t);if(i.navigate===!1){let m=i.fetcherKey||Oy();await r(m,n,i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:p,formMethod:i.method||l,formEncType:i.encType||d,flushSync:i.flushSync})}else await a(i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:p,formMethod:i.method||l,formEncType:i.encType||d,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[r,a,t,n])}function Dy(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),o={...xs(e||".",{relative:t})},i=yt();if(e==null){o.search=i.search;let c=new URLSearchParams(o.search),l=c.getAll("index");if(l.some(f=>f==="")){c.delete("index"),l.filter(p=>p).forEach(p=>c.append("index",p));let f=c.toString();o.search=f?`?${f}`:""}}return(!e||e===".")&&a.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(o.pathname=o.pathname==="/"?n:Dt([n,o.pathname])),fs(o)}function Uy(e,{relative:t}={}){let n=u.useContext(Kf);be(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=rm("useViewTransitionState"),a=xs(e,{relative:t});if(!n.isTransitioning)return!1;let o=qt(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=qt(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ra(a.pathname,i)!=null||Ra(a.pathname,o)!=null}class am extends Error{constructor(n){super("different_account");Sr(this,"summary");this.name="DifferentAccountError",this.summary=n}}class Wy{constructor(){Sr(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 o=await r.json().catch(()=>({}));if(o!=null&&o.wouldWipe)throw new am(o.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!r.ok){const o=await r.json().catch(()=>({error:"Invalid API key"}));throw new Error(o.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(o=>{var i,c;return{authorization_id:o.authorization_id,profile_id:o.profileId,path:o.path,title:o.title??null,sp_status:o.status??null,frame:o.bounds??o.frame??{},required_domains:o.requiredDomains??[],attested_domains:o.attestedDomains??[],missing_domains:(o.requiredDomains??[]).filter(l=>!(o.attestedDomains??[]).includes(l)),deferred_commitment_domains:o.deferredCommitmentDomains??[],approvers_frozen:o.approversFrozen??[],above_cap:o.aboveCap??!1,created_at:o.createdAt?new Date(o.createdAt*1e3).toISOString():"",earliest_expiry:(i=o.attestations)!=null&&i.length?new Date(Math.min(...o.attestations.map(l=>l.expiresAt))*1e3).toISOString():null,remaining_seconds:(c=o.attestations)!=null&&c.length?Math.max(0,Math.min(...o.attestations.map(l=>l.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 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 o=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(o.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 o=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(o.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 o=await a.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(o.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 getApproversPubkeys(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}/approvers/pubkeys`);return r.ok?(await r.json()).approvers??[]:[]}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 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 o=await a.json().catch(()=>({error:"Failed"}));throw new Error(o.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 c,l;const o=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:(c=a.attestations)!=null&&c.length?new Date(Math.min(...a.attestations.map(d=>d.expiresAt))*1e3).toISOString():null,remaining_seconds:(l=a.attestations)!=null&&l.length?Math.max(0,Math.min(...a.attestations.map(d=>d.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:o}})}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 o=await a.json();return{receipts:o.receipts??[],nextBefore:o.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(),o=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts${a?"?"+a:""}`);if(!o.ok)throw new Error(`Failed to fetch team receipts: ${o.status}`);const i=await o.json();return{receipts:i.receipts??[],nextBefore:i.nextBefore??null}}async getThread(t){const n=t.sinceDays??7,r=t.status??"pending",a=t.domain||"owner",o=await this.getProposals(a);let i=[];if(r==="all"){const c=[],l=new Date;for(let f=0;f<n;f++){const p=new Date(l);p.setUTCDate(l.getUTCDate()-f),c.push(p.toISOString().slice(0,10))}i=(await Promise.all(c.map(f=>this.getMyReceipts({date:f,profile:t.profile})))).flat()}return{proposals:o,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 I=new Wy,om=u.createContext(null);function Hy({children:e}){const[t,n]=u.useState(null),[r,a]=u.useState("personal"),[o,i]=u.useState(null),[c,l]=u.useState(""),[d,f]=u.useState(null),[p,m]=u.useState(null),[w,v]=u.useState(!1),[x,j]=u.useState(""),g=u.useRef(!1),h=u.useRef(null),y=u.useCallback(async()=>{if(g.current)try{const E=await I.getMyTeam();if(E){const{group:z,membership:U}=E;f(z),m(U),a("team"),i(z);const V=h.current??U.domains[0]??"owner";l(V)}else f(null),m(null),a("personal")}catch{}},[]);u.useEffect(()=>{const E=()=>{document.visibilityState==="visible"&&y()};return document.addEventListener("visibilitychange",E),()=>document.removeEventListener("visibilitychange",E)},[y]),u.useEffect(()=>{fetch("/health").then(E=>E.json()).then(E=>{var z;((z=E.session)==null?void 0:z.lockedReason)==="as-url-changed"&&j(`Authority Server changed to ${E.spUrl??"a new server"} — sign in again.`)}).catch(()=>{})},[]);const S=u.useCallback(async(E,z={})=>{v(!0),j("");try{I.setApiKey(E),g.current=!0;const U=await I.login(E,z);n(U),h.current=U.id;const V=await I.getGroups(),Q=V.find(D=>D.isPersonal)??V[0]??null;i(Q),l("owner"),await y()}catch(U){throw I.clearApiKey(),g.current=!1,j(U instanceof Error?U.message:"Login failed"),U}finally{v(!1)}},[y]),k=u.useCallback(async()=>{await I.logout(),I.clearApiKey(),g.current=!1,h.current=null,n(null),i(null),l(""),f(null),m(null),a("personal"),j("")},[]),N=u.useCallback(E=>{I.clearApiKey(),g.current=!1,h.current=null,n(null),i(null),l(""),f(null),m(null),a("personal"),j(E??"Your sign-in ended after 30 days or was revoked. Sign in again.")},[]),C=u.useCallback(()=>j(""),[]),P=u.useCallback((E,z)=>{i(E),l(z)},[]);return s.jsx(om.Provider,{value:{user:t,mode:r,group:o,domain:c,groupId:(o==null?void 0:o.id)??null,activeTeam:d,activeMembership:p,isLoading:w,error:x,login:S,logout:k,clearError:C,handleSessionLocked:N,activeGroup:o,activeDomain:c,groups:o?[o]:[],setActiveContext:P,refreshGroups:y},children:e})}function Oe(){const e=u.useContext(om);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const im=u.createContext(null);function Vy({children:e}){const{user:t}=Oe(),n=u.useRef(null),[r,a]=u.useState(!1),o=u.useRef(new Map),i=u.useCallback((c,l)=>{const d=o.current;return d.has(c)||d.set(c,new Set),d.get(c).add(l),()=>{var f;(f=d.get(c))==null||f.delete(l)}},[]);return u.useEffect(()=>{if(!t){n.current&&(n.current.close(),n.current=null,a(!1));return}if(n.current)return;const c=I.getApiKey();if(!c)return;const l=new EventSource(`/events?key=${encodeURIComponent(c)}`);n.current=l,l.onopen=()=>a(!0),l.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)l.addEventListener(f,p=>{let m;try{m=JSON.parse(p.data)}catch{m=null}const w=o.current.get(f);if(w)for(const v of w)try{v(m)}catch(x){console.error(`[EventSource] handler for "${f}" threw:`,x)}});return()=>{l.close(),n.current=null,a(!1)}},[t]),s.jsx(im.Provider,{value:{connected:r,addListener:i},children:e})}function me(e,t){const n=u.useContext(im);if(!n)return;const{addListener:r}=n;u.useEffect(()=>r(e,t),[e,t,r])}const Yr="suveren-theme",lu="hap-theme";function Bs(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(lu);t!==null&&localStorage.getItem(Yr)===null&&localStorage.setItem(Yr,t),t!==null&&localStorage.removeItem(lu)})();function lm(){const[e,t]=u.useState(()=>{const o=localStorage.getItem(Yr);return o==="light"||o==="dark"?o:"system"}),[n,r]=u.useState(()=>Bs(e));u.useEffect(()=>{const o=document.documentElement,i=Bs(e);o.setAttribute("data-theme",i),e==="system"?localStorage.removeItem(Yr):localStorage.setItem(Yr,e),r(Bs(e))},[e]),u.useEffect(()=>{if(e!=="system")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>r(Bs("system"));return o.addEventListener("change",i),()=>o.removeEventListener("change",i)},[e]);const a=u.useCallback(()=>{t(o=>o==="system"?"light":o==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:n,toggle:a}}const Gy=5*60*1e3,Ky=2e3;function Bl(){const[e,t]=u.useState(!1),[n,r]=u.useState("docker"),[a,o]=u.useState(""),[i,c]=u.useState(null),[l,d]=u.useState(!1),[f,p]=u.useState(!1),[m,w]=u.useState(!1),v=u.useRef(null);return u.useEffect(()=>{let x=!1;const j=(y=!1)=>{fetch(y?"/health?refresh=1":"/health").then(S=>S.json()).then(S=>{x||(S.installMethod&&r(S.installMethod),typeof S.latestVersion<"u"&&c(S.latestVersion),S.updateAvailable&&t(!0),S.version&&(o(S.version),v.current===null?v.current=S.version:S.version!==v.current&&S.version!=="dev"&&d(!0)))}).catch(()=>{})};j(!0);const g=setInterval(()=>j(!1),m?Ky:Gy),h=()=>{document.visibilityState==="visible"&&j(!1)};return document.addEventListener("visibilitychange",h),window.addEventListener("focus",h),()=>{x=!0,clearInterval(g),document.removeEventListener("visibilitychange",h),window.removeEventListener("focus",h)}},[m]),{updateAvailable:e&&!f,installMethod:n,version:a,latestVersion:i,serverRestarted:l,startFastPolling:()=>w(!0),dismiss:()=>p(!0)}}function Yy({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 Qy(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const cu={system:"◑",light:"☀",dark:"☾"};function Dl({onMenuToggle:e}){const{user:t,logout:n}=Oe(),{theme:r,toggle:a}=lm(),{version:o,updateAvailable:i,latestVersion:c}=Bl(),l=Qy(o);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(Yy,{size:20}),s.jsx("span",{className:"logo",children:"Suveren"}),s.jsx("span",{className:"version-badge",children:"Local Gateway"}),l&&s.jsxs("span",{className:"gw-version",title:i&&c?`Running v${l} — v${c} is available`:"Running gateway version","data-stale":i?"true":void 0,children:["v",l,i&&c?` → ${c}`:""]})]}),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:cu[r]}),s.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):s.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:cu[r]})}),t&&e&&s.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function Ul(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 cm(e){return e==="expired"||e==="revoked"}function um(e,t){var n;return!!((n=t==null?void 0:t.archivedSet)!=null&&n.has(e.authorization_id))&&cm(Ul(e,t))}function Pa(e,t){return um(e,t)?"archived":Ul(e,t)}function dm(e,t){const n={active:[],pending:[],expired:[],revoked:[],archived:[]};for(const r of e)n[Pa(r,t)].push(r);return n}function Jy(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 Pt(e,t,n){const r=u.useRef(e);r.current=e,u.useEffect(()=>{let a=null;const o=()=>typeof document>"u"?!0:document.visibilityState==="visible",i=()=>{o()&&r.current()},c=()=>{a===null&&(a=setInterval(i,t))},l=()=>{a!==null&&(clearInterval(a),a=null)},d=()=>{o()?(r.current(),c()):l()};return o()&&(r.current(),c()),document.addEventListener("visibilitychange",d),()=>{l(),document.removeEventListener("visibilitychange",d)}},[t,n])}const fm=u.createContext(null),Xy=3e4,qy=5e3,Zy=3e5;function ev(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 tv({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,p]=await Promise.all([I.getIntegrationManifests().catch(()=>(d=!0,{manifests:[]})),I.getMcpHealth().catch(()=>null)]);n(w=>({...w,manifests:f.manifests,integrations:(p==null?void 0:p.integrations)??w.integrations,activeSessions:(p==null?void 0:p.activeSessions)??w.activeSessions,mcpServerUp:!!p,manifestsError:d,fetchCount:w.fetchCount+1}));const m=f.manifests.filter(w=>w.oauth);if(m.length>0){const w=await Promise.all(m.map(async v=>[v.id,await I.getOAuthHealth(v.id)]));n(v=>({...v,authHealth:Object.fromEntries(w)}))}},[]),o=t.fetchCount>0&&t.manifests.some(d=>{const f=t.integrations.find(p=>p.id===d.id);return f&&!f.running&&!f.paused});me("integration-changed",a),Pt(a,o?qy:Zy);const i=u.useMemo(()=>{const d=new Map(t.integrations.map(m=>[m.id,m])),f=Date.now();o&&r.current===null?r.current=f:o||(r.current=null);const p=r.current!==null&&f-r.current<Xy;return t.manifests.map(m=>{const w=d.get(m.id),v=ev(w,t.fetchCount,p),x=t.authHealth[m.id];return{id:m.id,manifest:m,integration:w,state:v,authStatus:x==null?void 0:x.status,authAccount:x==null?void 0:x.account,authError:x==null?void 0:x.error}})},[t,o]),c=u.useMemo(()=>i.filter(d=>d.state==="not-running"||d.state==="error"||d.authStatus==="failed").length,[i]),l={loading:t.fetchCount===0,mcpServerUp:t.mcpServerUp,manifestsError:t.manifestsError,entries:i,attentionCount:c,activeSessions:t.activeSessions,refresh:a};return s.jsx(fm.Provider,{value:l,children:e})}function Wl(){const e=u.useContext(fm);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const nv=[{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:"/team",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"Settings",statusKey:"assistant"}];function rv(){const{activeDomain:e}=Oe(),[t,n]=u.useState({}),r=u.useCallback(async()=>{try{const[a,o,i,c,l,d]=await Promise.all([I.getCredential("ai-config").catch(()=>null),I.getMyAttestations().catch(()=>null),I.getProposals(e||"owner").catch(()=>null),I.getProposalsForApprover().catch(()=>null),I.getAgentContext().catch(()=>""),I.getArchivedMandates().catch(()=>[])]),f={};if(a&&!a.configured&&(f.assistant=1),o){const v=dm(o,{archivedSet:new Set(d)}).expired.length;v>0&&(f.authorizations=v)}const p=(i==null?void 0:i.length)??0,m=(c==null?void 0:c.length)??0,w=p+m;w>0&&(f.proposals=w),(!l||!l.trim())&&(f.brief=1),n(f)}catch{}},[e]);return me("attestation-changed",r),me("proposal-added",r),me("proposal-resolved",r),me("proposal-approved",r),me("proposal-rejected",r),me("team-membership-changed",r),u.useEffect(()=>(window.addEventListener("suveren:archived-changed",r),()=>window.removeEventListener("suveren:archived-changed",r)),[r]),Pt(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},av={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 ov(){const{mode:e,group:t,domain:n,activeTeam:r}=Oe(),a=rv(),{attentionCount:o}=Wl(),i={...a};o>0&&(i.integrations=o);const c=nv.filter(m=>!m.teamOnly||e==="team"),l=u.useRef(null),[d,f]=u.useState(null),p=yt();return u.useEffect(()=>{if(l.current===null){l.current=e;return}l.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"),l.current=e)},[e,r]),u.useEffect(()=>{f(null)},[p.pathname]),s.jsxs("div",{className:"sidebar",children:[s.jsx("ul",{className:"sidebar-nav",children:c.map(m=>{const w=m.statusKey?i[m.statusKey]:0;return s.jsx("li",{children:s.jsxs(Ol,{to:m.to,end:m.to==="/",className:({isActive:v})=>`sidebar-item${v?" active":""}`,children:[s.jsx("span",{className:"icon",children:m.icon}),m.label,w?s.jsx("span",{style:sv,children:w}):null]})},m.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:av,role:"status","aria-live":"polite",children:d})]})}const Po="suveren:updatedTo";function iv(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 lv="Updates for this gateway come from your company's IT — no action needed here.";function cv(e){return e==="managed"?"update-banner is-managed":"update-banner"}const uv="Download the new installer and run it. Your settings and mandates stay.";function dv(e){const t="https://github.com/suverenai/suveren-gateway/releases";return e?`${t}/tag/v${e}`:`${t}/latest`}function fv(){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 mm(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:a,startFastPolling:o,dismiss:i}=Bl(),[c,l]=u.useState(!1),[d,f]=u.useState(!1),[p,m]=u.useState(()=>{try{const y=sessionStorage.getItem(Po);if(y)return sessionStorage.removeItem(Po),y}catch{}return null}),w=iv(t),v=u.useRef(null),x=y=>{try{sessionStorage.setItem(Po,y||r||"✓")}catch{}window.location.reload()};u.useEffect(()=>{if(!p)return;const y=setTimeout(()=>m(null),6e3);return()=>clearTimeout(y)},[p]),u.useEffect(()=>{if(!c||!a)return;const y=()=>fv()?!1:(x(n),!0);if(y())return;const S=setInterval(y,1500);return()=>clearInterval(S)},[c,a,n]),u.useEffect(()=>(document.body.classList.toggle("is-updating",c),()=>document.body.classList.remove("is-updating")),[c]);const j=e&&!c&&!p||!!p&&!c;u.useEffect(()=>{if(!j){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 N;const k=((N=v.current)==null?void 0:N.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${k}px`)};y();const S=new ResizeObserver(y);return v.current&&S.observe(v.current),()=>{S.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[j]);const g=()=>{l(!0),o()},h=async()=>{if(w)try{await navigator.clipboard.writeText(w),f(!0),setTimeout(()=>f(!1),1800)}catch{}};return s.jsxs(s.Fragment,{children:[p&&!c&&s.jsx("div",{ref:v,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",p&&p!=="✓"?` — ${p} is live`:" — now live","."]}),s.jsx("button",{className:"update-banner-x",onClick:()=>m(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!c&&!p&&s.jsxs("div",{ref:v,className:cv(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:dv(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:i,"aria-label":"Dismiss",children:"×"})]})]}),t==="managed"&&s.jsx("p",{className:"update-banner-hint",children:lv}),t==="msi"&&s.jsx("p",{className:"update-banner-hint",children:uv})]}),c&&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:()=>x(n),children:"Reload now"}),s.jsx("button",{className:"btn btn-secondary",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}function pm(){const[e,t]=u.useState(!1);return u.useEffect(()=>{let n=!1;const r=()=>{fetch("/health").then(i=>i.json()).then(i=>{n||t(i.simulation===!0)}).catch(()=>{})};r();const a=setInterval(r,3e4),o=()=>{document.visibilityState==="visible"&&r()};return document.addEventListener("visibilitychange",o),()=>{n=!0,clearInterval(a),document.removeEventListener("visibilitychange",o)}},[]),e}function hm(){const e=pm(),t=u.useRef(null);return u.useEffect(()=>{if(!e){document.documentElement.style.removeProperty("--sim-banner-h");return}const n=()=>{var o;const a=((o=t.current)==null?void 0:o.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 mv={system:"◑",light:"☀",dark:"☾"},pv=[{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:"/team",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"Settings"}];function hv({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:a,logout:o}=Oe(),{theme:i,toggle:c}=lm(),l=yt();return u.useEffect(()=>{t()},[l.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:pv.map(d=>s.jsxs(Ol,{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:()=>{c()},children:[s.jsx("span",{className:"icon",children:mv[i]}),"Theme: ",i]}),s.jsx("button",{className:"mobile-menu-action",onClick:()=>{o(),t()},children:"Logout"})]})]})]}):null}function gm(e){return e.status==="pending"}function gv(e,t){return e.filter(gm).length+t.length}const Cn=["proposal-added","proposal-resolved","proposal-approved","proposal-rejected","action-approval-needed","action-resolved","team-membership-changed"],yv=500;function ym(){const{user:e,domain:t}=Oe(),[n,r]=u.useState(0),a=u.useRef(null),o=u.useCallback(async()=>{if(!e){r(0);return}try{const[c,l]=await Promise.all([I.getProposals(t||"owner").catch(()=>[]),I.getProposalsForApprover().catch(()=>[])]);r(gv(c,l))}catch{r(0)}},[e,t]),i=u.useCallback(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{o()},yv)},[o]);return u.useEffect(()=>(o(),()=>{a.current&&clearTimeout(a.current)}),[o]),me(Cn[0],i),me(Cn[1],i),me(Cn[2],i),me(Cn[3],i),me(Cn[4],i),me(Cn[5],i),me(Cn[6],i),n}const uu="Suveren",vv="/favicon.svg",xv="M 104.94 61.85 A 41 41 0 1 1 45.39 27.47",Ds={x1:74.54,y1:22.74,x2:94.46,y2:34.24},wv=14,Sv="#f59e0b";function jv(e){const t=Hl(e);return t>0?`(${t}) ${uu}`:uu}function Hl(e){return Number.isFinite(e)&&e>0?Math.floor(e):0}function kv(){const e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" fill="none">
|
|
52
|
+
<path class="m" d="${xv}"/>
|
|
53
|
+
<line class="m" x1="${Ds.x1}" y1="${Ds.y1}" x2="${Ds.x2}" y2="${Ds.y2}"/>
|
|
54
|
+
<circle cx="103" cy="103" r="25" fill="${Sv}"/>
|
|
55
|
+
<style>.m{stroke:#111111;stroke-width:${wv};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 bv(){return document.querySelector('link[rel="icon"]')}function vm(e){const t=Hl(e);document.title=jv(t),xm(t);const n=bv();if(!n)return;const r=t>0?kv():vv;n.getAttribute("href")!==r&&n.setAttribute("href",r)}function Cv(){vm(0)}function xm(e,t=globalThis.navigator){var a;if(!t||typeof t.setAppBadge!="function")return;const n=Hl(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 Nv(){const e=ym();return u.useEffect(()=>{vm(e)},[e]),u.useEffect(()=>Cv,[]),null}const wm="suveren:dockBadgePrompt";function Ev(){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(wm))return!1}catch{}return!0}function Tv(){const[e,t]=u.useState(!1),n=ym();if(u.useEffect(()=>{t(Ev())},[]),!e)return null;const r=()=>{try{localStorage.setItem(wm,"1")}catch{}t(!1)},a=async()=>{try{await Notification.requestPermission()==="granted"&&xm(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 Iv(){const[e,t]=u.useState(!1);return s.jsxs(tv,{children:[s.jsx(Nv,{}),s.jsx(Dl,{onMenuToggle:()=>t(!e)}),s.jsx(mm,{}),s.jsx(hm,{}),s.jsx(ov,{}),s.jsx(hv,{open:e,onClose:()=>t(!1)}),s.jsx("div",{className:"main-content",children:s.jsxs("div",{className:"page-inner",children:[s.jsx(Tv,{}),s.jsx(iy,{})]})})]})}function Rv(){const[e,t]=u.useState(""),{login:n,isLoading:r,error:a,clearError:o}=Oe(),[i,c]=u.useState(null),l=async()=>{if(e.trim()){o();try{await n(e)}catch(p){if(p instanceof am){c(p.summary);return}}}},d=async()=>{c(null),o();try{await n(e,{confirmWipe:!0})}catch{}},f=()=>{c(null)};return s.jsxs(s.Fragment,{children:[s.jsx(Dl,{}),s.jsx(mm,{}),s.jsx(hm,{}),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:p=>t(p.target.value),onKeyDown:p=>p.key==="Enter"&&l(),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:l,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((p,m)=>s.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:m<2?"0.5rem":0},children:[s.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[m+1,"."]}),p]},m))})]})]})})]}),i&&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:p=>p.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:[i.credentialCount," stored service credential",i.credentialCount===1?"":"s",i.credentialIds.length>0&&s.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",i.credentialIds.slice(0,5).join(", "),i.credentialIds.length>5?`, +${i.credentialIds.length-5} more`:"",")"]})]}),s.jsxs("li",{children:[i.serviceCount," configured integration",i.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 Pv(){const{setActiveContext:e}=Oe(),t=en(),[n,r]=u.useState(""),[a,o]=u.useState(""),[i,c]=u.useState(""),[l,d]=u.useState(!1),f=async()=>{if(n.trim()){d(!0),c("");try{const m=await I.joinGroup(n.trim());e(m,m.myDomains[0]||""),t("/")}catch(m){c(m instanceof Error?m.message:"Failed to join group")}finally{d(!1)}}},p=async()=>{if(a.trim()){d(!0),c("");try{const m=await I.createGroup(a.trim());e(m,m.myDomains[0]||""),t("/")}catch(m){c(m instanceof Error?m.message:"Failed to create group")}finally{d(!1)}}};return s.jsxs(s.Fragment,{children:[s.jsx(Dl,{}),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."})]}),i&&s.jsx("div",{className:"error-message",children:i}),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:m=>r(m.target.value),onKeyDown:m=>m.key==="Enter"&&f(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:l}),s.jsx("button",{className:"btn btn-primary",onClick:f,disabled:l,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:m=>o(m.target.value),onKeyDown:m=>m.key==="Enter"&&p(),style:{flex:1},disabled:l}),s.jsx("button",{className:"btn btn-secondary",onClick:p,disabled:l,children:"Create"})]})]})]})})]})}const Pi="suveren-setup-ai-skipped",_i="suveren-setup-agent-done",Ai="suveren-setup-dismissed",_v={"hap-setup-ai-skipped":Pi,"hap-setup-agent-done":_i,"hap-setup-dismissed":Ai};function Av(){for(const[e,t]of Object.entries(_v)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}Av();const _o={"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 zv({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:a}){const[o,i]=u.useState(()=>localStorage.getItem(Pi)==="true"),[c,l]=u.useState(()=>localStorage.getItem(_i)==="true"),[d,f]=u.useState(()=>localStorage.getItem(Ai)==="true"),[p,m]=u.useState(null),[w,v]=u.useState("claude-code"),[x,j]=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":o?"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||c?"done":"pending"}],h=g.filter(E=>E.status==="done"||E.status==="skipped").length,y=h===g.length,S=u.useCallback(()=>{localStorage.setItem(Pi,"true"),i(!0)},[]),k=u.useCallback(()=>{localStorage.setItem(_i,"true"),l(!0),m(null)},[]),N=u.useCallback(()=>{localStorage.setItem(Ai,"true"),f(!0)},[]),C=u.useCallback(async E=>{try{await navigator.clipboard.writeText(E),j(!0),setTimeout(()=>j(!1),2e3)}catch{}},[]);if(d||y)return null;const P=g.findIndex(E=>E.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:N,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((E,z)=>{const U=z===P,V=E.status==="done"||E.status==="skipped"?"●":"○",Q=E.status==="done"?"var(--success)":E.status==="skipped"?"var(--text-tertiary)":U?"var(--accent)":"var(--text-tertiary)";return s.jsxs("div",{children:[s.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:U?"0.75rem":"0.25rem 0",borderRadius:U?"0.5rem":void 0,background:U?"var(--accent-subtle)":void 0},children:[s.jsx("span",{style:{color:Q,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:[E.to&&E.status==="pending"?s.jsx(Xe,{to:E.to,style:{fontSize:"0.9rem",fontWeight:U?600:500,color:U?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:E.label}):E.status==="pending"&&z===3?s.jsx("button",{onClick:()=>m(p===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:U?600:500,color:U?"var(--accent)":"var(--text-primary)"},children:E.label}):s.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:E.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:E.label}),E.optional&&E.status==="pending"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),E.status==="skipped"&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),E.detail&&E.status==="pending"&&U&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:E.detail})]}),E.optional&&E.status==="pending"&&s.jsx("button",{onClick:S,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),E.to&&E.status==="pending"&&s.jsx(Xe,{to:E.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),z===3&&p===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(_o).map(([D,A])=>s.jsx("button",{onClick:()=>v(D),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:w===D?600:400,background:w===D?"var(--accent-subtle)":"transparent",color:w===D?"var(--accent)":"var(--text-secondary)",border:`1px solid ${w===D?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:A.label},D))}),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:_o[w].snippet(a)}),s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>C(_o[w].snippet(a)),children:x?"Copied":"Copy"}),s.jsx("button",{className:"btn btn-primary btn-sm",onClick:k,children:"Done"})]})]})]},z)})}),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 Ao(){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 $v={gmail:"Gmail",calendar:"Google Calendar",crm:"CRM",linkedin:"LinkedIn",records:"Records",mollie:"Mollie"},Sm=e=>$v[e]??e,Lv={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 Mv(e){return Lv[e]??{chip:"Blocked",sev:"info"}}function Fv(e){const t=Sm(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 Ov(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 du=5,Bv=24*60*60*1e3,sa=7;function Dv(e,t){const n=t-sa*Bv;return{recent:e.filter(r=>r.ts>=n),all:e}}function Uv(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,o]=u.useState(!1),i=u.useCallback(()=>{I.getDenials({limit:200}).then(({records:m})=>{t(m),o(!1)}).catch(()=>o(!0))},[]);if(u.useEffect(()=>{i()},[i]),Pt(i,12e4),a||e===null)return null;const{recent:c,all:l}=Dv(e,Date.now()),d=n?l:c.slice(0,du),f=l.length-c.length,p=(m,w)=>{const v=Mv(m.reason);return s.jsxs("div",{className:"rb-row",children:[s.jsx("span",{className:`rb-dot ${v.sev==="act"?"act":v.sev==="info"?"info":""}`,"aria-hidden":"true"}),s.jsxs("div",{className:"rb-body",children:[s.jsx("div",{className:"rb-line",children:Fv(m)}),s.jsxs("div",{className:"rb-meta",children:[s.jsx("span",{className:`rb-chip ${v.sev==="act"?"act":v.sev==="warn"?"warn":""}`,children:v.chip}),s.jsx("span",{className:"rb-via",children:Sm(m.integrationId)})]}),v.fixTo&&s.jsx(Xe,{className:"rb-fix",to:v.fixTo,children:"Set a read window →"})]}),s.jsx("div",{className:"rb-when",children:Ov(m.ts,Date.now())})]},`${m.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?l.length:c.length)>0&&s.jsx("span",{className:"rb-count",children:n?l.length:c.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 ",sa," 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 ${sa} 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(p)}),!n&&l.length>d.length&&s.jsx("div",{className:"rb-foot",children:s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!0),children:["View all ",l.length," blocks from the last 30 days"]})}),n&&l.length>Math.min(c.length,du)&&s.jsx("div",{className:"rb-foot",children:s.jsxs("button",{className:"rb-viewall",type:"button",onClick:()=>r(!1),children:["Show only the last ",sa," days"]})})]})]})}function Wv(){const[e,t]=u.useState([]);return Pt(async()=>{try{const{skipped:r}=await I.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 Hv(e,t){const n=e.simulation;return n?(((t==null?void 0:t[n.field])??"").trim().toLowerCase()||n.default.trim().toLowerCase())==="simulation":!1}function zi(e){return!!(e!=null&&e.simulation)}function Vv(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"&&(zi(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 Gv(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 Kv=30*60;function zo(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Yv(){const{domain:e}=Oe(),[t,n]=u.useState([]),[r,a]=u.useState([]),[o,i]=u.useState([]),[c,l]=u.useState(!0),[d,f]=u.useState(!1),[p,m]=u.useState([]),[w,v]=u.useState(!1),[x,j]=u.useState(!1),{entries:g,activeSessions:h,loading:y}=Wl(),S=!y,k=u.useCallback(()=>{I.getMyAttestations().then(B=>{n(B),f(!0)}).catch(()=>f(!0)),I.getArchivedMandates().then(m).catch(()=>m([])),I.getProposals(e||"owner").then(B=>{a(B),v(!0)}).catch(()=>v(!0)),I.getProposalsForApprover().then(B=>i(B)).catch(()=>i([])),I.getCredential("ai-config").then(B=>{l(B.configured),j(!0)}).catch(()=>j(!0))},[e]);me("attestation-changed",k),me("proposal-added",k),me("proposal-resolved",k),me("proposal-approved",k),me("proposal-rejected",k),Pt(k,3e5,e);const N=d&&w&&x&&S,C=dm(t,{archivedSet:new Set(p)}),P=C.active,E=C.expired,z=P.filter(B=>B.remaining_seconds!==null&&B.remaining_seconds<=Kv),U=r.filter(gm),V=g.filter(B=>B.state==="running"),Q=g.filter(B=>B.state==="starting"),D=Gv(g),A=[];for(const B of o)A.push({label:"Approval needed",detail:`${B.tool} — above-cap action under ${zo(B.profileId)}`,to:"/approvals",color:"var(--warning)"});for(const B of U)A.push({label:"Approval pending",detail:`${B.tool} awaiting your approval`,to:"/approvals",color:"var(--warning)"});for(const B of z){const ne=Math.ceil((B.remaining_seconds??0)/60);A.push({label:"Expiring soon",detail:`${B.title??zo(B.profile_id)} — ${ne} min remaining`,to:"/mandates",color:"var(--warning)"})}for(const B of E)A.push({label:"Expired",detail:B.title??zo(B.profile_id),to:"/mandates",color:"var(--danger)"});A.push(...Vv(g));for(const B of Q)A.push({label:"Integration starting",detail:`${B.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const B of g)B.authStatus==="failed"&&B.state!=="not-running"&&B.state!=="error"&&B.state!=="paused"&&A.push({label:"Reconnect needed",detail:`${B.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return c||A.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"})}),N&&s.jsx(zv,{aiConfigured:c,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(Xe,{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(Xe,{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:U.length>0?"var(--warning)":"var(--text-tertiary)"},children:U.length}):s.jsx(_n,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),s.jsx(Xe,{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:E.length>0?"var(--danger)":"var(--text-tertiary)"},children:E.length}):s.jsx(_n,{variant:"title"}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),s.jsx(Xe,{to:"/integrations",style:{textDecoration:"none"},children:s.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[S?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"}),A.length>0&&s.jsx("span",{className:"rb-count",children:A.length})]}),A.length>0?s.jsx("div",{className:"attention-rows",children:A.map((B,ne)=>s.jsxs(Xe,{to:B.to,className:"attention-row",children:[s.jsx("span",{className:"attention-dot",style:{background:B.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:B.label}),s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B.detail})]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]},ne))}):N?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(Ao,{}),s.jsx(Ao,{}),s.jsx(Ao,{})]})]}),D&&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:[D.count," real system",D.count===1?"":"s"," ",D.count===1?"is":"are"," paused"]})," ","while simulation mode is on — ",D.namesText,"."]})]}),s.jsx(Wv,{}),s.jsx(Uv,{})]})}const Qv=["Scope & Limits","Intent","Sign"];function jm({currentStep:e,onStepClick:t}){const n=en();return s.jsxs("div",{className:"wizard-progress",children:[s.jsx("ol",{className:"wizard-steps",children:Qv.map((r,a)=>{const o=a+2,i=o<e,c=o===e,l=o-1<e,d=i&&!!t;return s.jsxs("li",{className:`wizard-step${l?" reached":""}`,"aria-current":c?"step":void 0,children:[s.jsx("button",{type:"button",className:`step-circle${i?" completed":""}${c?" current":""}`,onClick:d?()=>t(o):void 0,disabled:!d,"aria-label":`${r}${i?" (done)":c?" (current)":""}`,children:i?"✓":a+1}),s.jsx("span",{className:`step-label-text${c?" current":i?" completed":""}`,children:r})]},o)})}),s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm wizard-cancel",onClick:()=>n("/mandates?new=1"),children:"Cancel"})]})}const Jv=40;function Pe(e,t){const n=e.lastIndexOf("/"),r=n>=0?e.slice(n+1):e,a=r.indexOf("@"),o=a>=0?r.slice(0,a):r;return(o.charAt(0).toUpperCase()+o.slice(1)).slice(0,Jv)}function Xv({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 qv({integrationId:e,field:t,value:n,onChange:r,disabled:a,onLabels:o}){const[i,c]=u.useState(null),[l,d]=u.useState(null),[f,p]=u.useState(!0);u.useEffect(()=>{let v=!1;return I.discoverScopeField(e,t).then(x=>{var j;v||(c(x.options),p(!1),(j=x.options)!=null&&j.length&&(o==null||o(Object.fromEntries(x.options.map(g=>[g.value,g.label])))))}).catch(x=>{v||(d(x instanceof Error?x.message:String(x)),p(!1))}),()=>{v=!0}},[e,t]);const m=new Set(n.split(",").map(v=>v.trim()).filter(Boolean)),w=v=>{const x=new Set(m);x.has(v)?x.delete(v):x.add(v),r(Array.from(x).join(","))};return f?s.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):l||!i?s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",l??"no response","). Enter values manually, separated by commas."]}),s.jsx("input",{className:"form-input",type:"text",value:n,onChange:v=>r(v.target.value),disabled:a})]}):i.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:i.map(v=>{const x=v.extras??{},j=typeof x.access=="string"?x.access:void 0,g=j==="reader",h=x.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:m.has(String(v.value)),onChange:()=>w(String(v.value)),disabled:a||g}),s.jsx("span",{children:v.label||v.value}),h&&s.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),j&&s.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",j]})]},v.value)})})}function Vl(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 Zv(e,t){return t!==void 0?String(t):Vl(e)===1?"1":""}function fu(e,t){const n=Vl(e);return t===""?n:Math.max(n,Number(t))}function ex(e){return e.replace(/@.*$/,"").split("/").pop()??e}function tx(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function nx(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function rx(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function mu(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==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function ax(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function ox(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 ix(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 lx({id:e,value:t,onChange:n,disabled:r,placeholder:a,unit:o,min:i=0}){const c=ax(o),l=ox(o),d=sx(o),f=ix(t,o),p=t===""?null:Number(t),m=()=>{const v=t===""?0:Number(t),x=v%c,j=x===0?v+c:v+(c-x);n(String(j))},w=()=>{const v=t===""?0:Number(t);if(v<=i)return;const x=v%c,j=x===0?v-c:v-x;n(String(Math.max(i,j)))};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)<=i,"aria-label":"Decrease",children:"−"}),s.jsx("input",{id:e,className:"stepper-input",type:"number",min:i,step:c,value:t,placeholder:a??String(i),onChange:v=>n(v.target.value),onFocus:v=>v.target.select(),disabled:r}),s.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:m,disabled:r,"aria-label":"Increase",children:"+"}),d&&s.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:d})]}),l.length>0&&!r&&s.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:l.map(v=>s.jsx("button",{type:"button",className:`preset-chip${p===v.value?" preset-chip-selected":""}`,onClick:()=>n(String(v.value)),children:v.label},v.value))}),f&&s.jsxs("div",{className:"bounded-input-echo",children:["≈ ",f]})]})}function pu({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(o=>!o),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:o}){const[i,c]=u.useState(""),[l,d]=u.useState(!1),f=u.useRef(null),p=t?t.split(",").map(g=>g.trim()).filter(Boolean):[],m=g=>{const h=g.trim();if(!h)return;if(!mu(h,a)){d(!0);return}d(!1);const y=p.includes(h)?p:[...p,h];n(y.join(",")),c("")},w=g=>{const h=p.filter((y,S)=>S!==g);n(h.join(","))},v=g=>{g.key==="Enter"||g.key===","||g.key==="Tab"?i.trim()&&(g.preventDefault(),m(i)):g.key==="Backspace"&&!i&&p.length>0&&w(p.length-1)},x=g=>{const h=g.clipboardData.getData("text");if(h.includes(",")){g.preventDefault();const S=h.split(",").map(N=>N.trim()).filter(Boolean).filter(N=>mu(N,a)),k=[...new Set([...p,...S])];n(k.join(",")),c(""),d(!1)}},j=a==="email"?"Type email and press Enter...":"Type domain and press Enter...";return s.jsxs("div",{className:`tag-input${l?" tag-input-invalid":""}`,onClick:()=>{var g;return(g=f.current)==null?void 0:g.focus()},children:[p.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:i,onChange:g=>{c(g.target.value),d(!1)},onKeyDown:v,onPaste:x,onBlur:()=>{i.trim()&&m(i)},placeholder:p.length===0?o??j:""})]})}function ux({id:e,options:t,value:n,onChange:r,disabled:a}){const o=n?n.split(",").map(c=>c.trim()).filter(Boolean):[],i=c=>{const l=o.includes(c)?o.filter(d=>d!==c):[...o,c];r(l.join(","))};return s.jsx("div",{className:"checkbox-group",id:e,children:t.map(c=>s.jsxs("label",{className:`checkbox-pill${o.includes(c)?" checkbox-pill-selected":""}`,children:[s.jsx("input",{type:"checkbox",checked:o.includes(c),onChange:()=>i(c),disabled:a}),s.jsx("span",{children:c})]},c))})}function hu({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:a,readOnly:o,twoColumn:i,discoveryIntegrationId:c,onLabels:l}){const d=tx(e,t),f=`${a}-field-${e}`,p=s.jsx(s.Fragment,{children:rx(t)?s.jsx(ux,{id:f,options:t.enum,value:n,onChange:m=>r(e,m),disabled:o}):(()=>{const m=t.boundType;return(m==null?void 0:m.kind)==="enum"&&Array.isArray(m.values)})()?s.jsxs("select",{id:f,className:"form-select",value:n,onChange:m=>r(e,m.target.value),disabled:o,children:[s.jsx("option",{value:"",children:"Select..."}),t.boundType.values.map(m=>s.jsx("option",{value:m,children:m},m))]}):"enum"in t&&t.enum?s.jsxs("select",{id:f,className:"form-select",value:n,onChange:m=>r(e,m.target.value),disabled:o,children:[s.jsx("option",{value:"",children:"Select..."}),t.enum.map(m=>s.jsx("option",{value:m,children:m},m))]}):t.type==="number"?s.jsx(lx,{id:f,value:n,onChange:m=>r(e,m),disabled:o,unit:t.unit,min:Vl(t)}):nx(t)?s.jsx(cx,{id:f,value:n,onChange:m=>r(e,m),disabled:o,format:t.format}):c?s.jsx(qv,{integrationId:c,field:e,value:n,onChange:m=>r(e,m),disabled:o,onLabels:m=>l==null?void 0:l(e,m)}):s.jsx("input",{id:f,className:"form-input",type:"text",value:n,onChange:m=>r(e,m.target.value),disabled:o})});return i?s.jsxs("div",{className:"bounds-field-row",children:[s.jsx("div",{className:"bounds-field-label",children:s.jsx(pu,{htmlFor:f,label:d,description:t.description})}),s.jsx("div",{className:"bounds-field-input",children:p})]},`${a}-${e}`):s.jsxs("div",{className:"form-group",children:[s.jsx(pu,{htmlFor:f,label:d,description:t.description}),p]},`${a}-${e}`)}function dx(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 o=!1;for(const[i,c]of Object.entries(n)){const l=e[i];if(l===""||l===void 0)continue;const d=Number(l);if(!isNaN(d)&&d>c){o=!0;break}}return o?r?"above-approvers":"hard-ceiling":"within-cap"}function fx(e,t){const n=new Set;if(!t)return n;for(const[r,a]of Object.entries(t)){const o=e[r];if(o===""||o===void 0)continue;const i=Number(o);!isNaN(i)&&i>a&&n.add(r)}return n}function mx({profile:e,onConfirm:t,onCancel:n,readOnly:r,initialBounds:a,initialContext:o,initialFrame:i,profileConfig:c,approverNames:l,adminName:d}){const f=e.boundsSchema??e.frameSchema,p=e.contextSchema,m=f?Object.entries(f.fields).filter(([R,F])=>!(R==="profile"||R==="path"||F.enforced===!1||F.enforcedBy==="gatekeeper")):[],w=f?Object.entries(f.fields).filter(([,R])=>R.enforcedBy==="gatekeeper").filter(([,R])=>R.enforced!==!1).map(([R,F])=>F.displayName??R):[],v=p&&p.keyOrder.length>0?Object.entries(p.fields):[],x=a??i??{},j=o??{},g={};for(const[R,F]of m)g[R]=Zv(F,x[R]);const h={};for(const[R]of v)h[R]=j[R]!==void 0?String(j[R]):"";const[y,S]=u.useState(g),[k,N]=u.useState(h),[C,P]=u.useState({}),[E,z]=u.useState(null);u.useEffect(()=>{const R=ex(e.id);I.getIntegrationManifests().then(({manifests:F})=>{const Y=F.find(X=>X.profile===R&&X.contextDiscovery&&Object.keys(X.contextDiscovery).length>0);z(Y??null)}).catch(()=>z(null))},[e.id]);const U=dx(y,c),V=fx(y,c==null?void 0:c.caps),Q=(R,F)=>{S(Y=>({...Y,[R]:F}))},D=(R,F)=>{N(Y=>({...Y,[R]:F}))},A=()=>{const R={profile:e.id};for(const[Y,X]of m)X.type==="number"?R[Y]=fu(X,y[Y]):R[Y]=y[Y];const F={};for(const[Y,X]of v)X.type==="number"?F[Y]=k[Y]===""?0:Number(k[Y]):F[Y]=k[Y];return[R,F]},B=()=>{const[R,F]=A();t(R,F,C)},ne=()=>{const R=(c==null?void 0:c.caps)??{},F={...y};for(const te of V)R[te]!==void 0&&(F[te]=String(R[te]));S(F);const Y={profile:e.id};for(const[te,ue]of m)ue.type==="number"?Y[te]=fu(ue,F[te]??""):Y[te]=F[te]??"";const X={};for(const[te,ue]of v)ue.type==="number"?X[te]=k[te]===""?0:Number(k[te]):X[te]=k[te];t(Y,X,C)},L=R=>{const F=c==null?void 0:c.caps;if(!F||F[R]===void 0)return null;const Y=F[R],X=V.has(R);return U==="hard-ceiling"&&X?s.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",Y," — exceeds team ceiling"]}):U==="above-approvers"&&X?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"]})},$=()=>{var R;if(U==="no-config")return null;if(U==="approvers-dormant"){const F=l&&l.length>0?l.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(U==="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(U==="above-approvers"){const F=l&&l.length>0?l.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(U==="hard-ceiling"){const F=Array.from(V)[0],Y=F?(R=c==null?void 0:c.caps)==null?void 0:R[F]:void 0,X=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 ",X," 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:ne,children:"Save below cap"}),n&&s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},H=U==="hard-ceiling";return s.jsxs("div",{children:[v.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"})]})]}),v.map(([R,F])=>{var X;const Y=!!((X=E==null?void 0:E.contextDiscovery)!=null&&X[R]);return s.jsx(hu,{fieldKey:R,fieldDef:F,value:k[R],onChange:D,prefix:"context",readOnly:r,discoveryIntegrationId:Y?E.id:void 0,onLabels:(te,ue)=>P(pe=>({...pe,[te]:ue}))},`context-${R}`)})]}),m.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:m.map(([R,F])=>{var Y;return s.jsxs("div",{style:{display:"contents"},children:[s.jsx(hu,{fieldKey:R,fieldDef:F,value:y[R],onChange:Q,prefix:"bounds",readOnly:r,twoColumn:!0}),U!=="no-config"&&((Y=c==null?void 0:c.caps)==null?void 0:Y[R])!==void 0&&s.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:L(R)})]},`bounds-${R}`)})}),$(),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(Xe,{to:"/integrations",children:"Integrations"}),"."]})]}),s.jsx("button",{className:"btn btn-primary",onClick:B,disabled:H,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function px(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 hx(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const gx="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 _a({target:e,currentText:t,onApply:n,greeting:r,placeholder:a,title:o}){const[i,c]=u.useState([{role:"assistant",content:r??gx}]),[l,d]=u.useState(""),[f,p]=u.useState(!1),[m,w]=u.useState(null),v=u.useRef(null),x=u.useRef(null);u.useEffect(()=>{const h=v.current;if(!h)return;const y=i[i.length-1],S=x.current;!f&&(y==null?void 0:y.role)==="assistant"&&i.length>1&&S?h.scrollTop=S.offsetTop:h.scrollTop=h.scrollHeight},[i,f]);const j=async()=>{const h=l.trim();if(!h||f)return;const y=[...i,{role:"user",content:h}];c(y),d(""),w(null),p(!0);try{const S=await I.aiChat({target:e,currentText:t,messages:y.filter((k,N)=>!(N===0&&k.role==="assistant"))});S.success&&S.reply?c(k=>[...k,{role:"assistant",content:S.reply}]):w(S.error??"AI returned no reply")}catch(S){w(S instanceof Error?S.message:"Chat failed")}finally{p(!1)}},g=h=>{h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),j())};return s.jsxs("div",{className:"intent-chat",children:[s.jsx("h3",{className:"card-title",children:o??"AI Assistant"}),s.jsxs("div",{ref:v,className:"chat-messages",children:[i.map((h,y)=>{const S=h.role==="assistant"?px(h.content):null,k=S?hx(h.content):h.content;return s.jsx("div",{className:`chat-msg ${h.role}`,ref:y===i.length-1?x:void 0,children:s.jsxs("div",{className:"chat-msg-body",children:[k&&s.jsx("div",{className:"chat-msg-prose",children:k}),S!==null&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"chat-fenced-block",children:S}),s.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(S),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…"})})]}),m&&s.jsx("div",{className:"error-message",children:m}),s.jsxs("div",{className:"chat-composer",children:[s.jsxs("div",{className:"chat-composer-pill",children:[s.jsx("textarea",{className:"chat-input",value:l,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:j,disabled:f||!l.trim(),"aria-label":"Send",children:"↑"})]}),s.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function km({open:e,onClose:t,children:n,ariaLabel:r}){const a=u.useRef(null),o=u.useRef(null);return u.useEffect(()=>{var c;if(!e)return;o.current=document.activeElement,document.body.style.overflow="hidden";const i=l=>{l.key==="Escape"&&t()};return document.addEventListener("keydown",i),(c=a.current)==null||c.focus(),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="",o.current instanceof HTMLElement&&o.current.focus()}},[e,t]),Of.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 yx(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vx(e,t,n){if(t.length===0)return[{text:e,label:e,matched:null}];const r=[],a=new Set;for(const l of t)if(!(!l.scope||l.scope==="all (unscoped)"))for(const d of[l.scope,...l.scope.split(",").map(f=>f.trim())]){const f=d.toLowerCase();d&&!a.has(f)&&(a.add(f),r.push(d))}r.sort((l,d)=>d.length-l.length);const o=l=>{const d=l.toLowerCase();return t.filter(f=>{var p,m;return((p=f.scope)==null?void 0:p.toLowerCase())===d||((m=f.scope)==null?void 0:m.split(",").map(w=>w.trim().toLowerCase()).includes(d))})},i=["\\[\\d+\\]",...r.map(yx)],c=new RegExp(`(${i.join("|")})`,"gi");return e.split(c).filter(l=>l!=="").map(l=>{const d=/^\[(\d+)\]$/.exec(l);if(d){const f=t[Number(d[1])-1];if(f){const p=f.scope&&f.scope!=="all (unscoped)"?f.scope:"all recipients",m=n?`${n}: ${p}`:p;return{text:l,label:m,matched:[f]}}}else if(r.some(f=>f.toLowerCase()===l.toLowerCase())){const f=o(l);if(f.length>0)return{text:l,label:l,matched:f}}return{text:l,label:l,matched:null}})}const gu=`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 xx(e,t,n,r){return vx(e,t,r).map((a,o)=>{if(!a.matched)return s.jsx("span",{children:a.text},o);const i=a.matched;return s.jsx("button",{type:"button",onClick:()=>n(i),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:a.label},o)})}function wx(){var se;const e=en(),[t]=sm(),n=Number(t.get("step"))||2,[r,a]=u.useState(null),[o,i]=u.useState(null),[c,l]=u.useState(n),[d,f]=u.useState(null),[p,m]=u.useState(null),[w,v]=u.useState({}),[x,j]=u.useState(gu),[g,h]=u.useState(!1),[y,S]=u.useState(!0),[k,N]=u.useState(null),[C,P]=u.useState([]),[E,z]=u.useState(void 0),[U,V]=u.useState(!1),[Q,D]=u.useState(null),[A,B]=u.useState(null),[ne,L]=u.useState(null),[$,H]=u.useState([]),[R,F]=u.useState(null);u.useEffect(()=>{var ye;const _=sessionStorage.getItem("agentAuth");if(!_){e("/mandates?new=1");return}const J=JSON.parse(_);a(J);const ae=sessionStorage.getItem("agentGate");if(ae){const ve=JSON.parse(ae);ve.bounds&&f(ve.bounds),ve.context&&m(ve.context),(ye=ve.gateContent)!=null&&ye.intent&&j(ve.gateContent.intent)}I.getProfile(J.profileId).then(ve=>i(ve)).catch(()=>e("/mandates?new=1")).finally(()=>S(!1)),J.groupId&&Promise.all([I.getTeamProfileConfig(J.groupId,J.profileId).catch(()=>null),I.getGroupById(J.groupId).catch(()=>null),I.listUsers().catch(()=>[])]).then(([ve,Le,tt])=>{if(N(ve),ve){const Be=new Map;for(const ce of tt){const ct=ce.name&&ce.email?`${ce.name} (${ce.email})`:ce.name||ce.email||ce.id;Be.set(ce.id,ct)}const lt=(Le==null?void 0:Le.members)??[];for(const ce of lt){const ct=ce.userId??ce.id;ct&&(ce.name&&ce.email?Be.set(ct,`${ce.name} (${ce.email})`):ce.name&&Be.set(ct,ce.name))}const nt=(ve.approvers??[]).map(ce=>Be.get(ce)??ce);P(nt);const De=lt.find(ce=>ce.role==="admin");if(De){const ce=De.userId??De.id;ce&&z(Be.get(ce)??De.name)}}})},[e]);const Y=d?Object.entries(d).filter(([_])=>_!=="profile"&&_!=="path").map(([_,J])=>`${_} = ${J}`).join(", "):"",X=(_,J,ae)=>{f(_),m(J),ae&&v(ae),l(3)},te=x.trim()!==gu.trim()&&x.trim()!=="",ue=_=>{te&&!confirm("Replace your current intent with the AI draft?")||j(_)},pe=()=>{const _=o==null?void 0:o.ttl,J={intent:x},ae=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...ae,bounds:d,context:p,contextLabels:w,gateContent:J,ttlConfig:_})),e("/mandates/new/sign")},ee=async()=>{if(r){V(!0),D(null),B(null),L(null),H([]),F(null);try{const _=await I.aiIntentReview({profileId:r.profileId,newIntent:x,context:p??void 0});H(_.grants??[]),_.success?_.review?D(_.review):B(_.note??"No other mandates on this profile to compare against."):L(_.error??"Check failed.")}catch(_){L(_ instanceof Error?_.message:"Check failed.")}finally{V(!1)}}},ie=_=>{j(_),(Q||A||ne)&&(D(null),B(null),L(null),H([]),F(null))};return y||!r||!o?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):s.jsxs(s.Fragment,{children:[s.jsx(jm,{currentStep:c,onStepClick:_=>{_>=2&&l(_)}}),s.jsx(Xv,{profileId:r.profileId,bounds:Y||void 0,groupName:r.groupName,domain:r.domain}),c===2&&s.jsx("div",{className:"card",children:s.jsx(mx,{profile:o,onConfirm:X,onCancel:()=>e("/mandates?new=1"),initialBounds:d||void 0,initialContext:p||void 0,profileConfig:k,approverNames:C,adminName:E})}),c===3&&s.jsxs("div",{className:"intent-layout",children:[s.jsx("div",{className:"card intent-pane chat tool",children:s.jsx(_a,{target:{kind:"intent",profileId:r.profileId,bounds:Y||void 0},currentText:x,onApply:ue})}),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:x,onChange:_=>ie(_.target.value)}),s.jsxs("div",{className:"char-counter",children:[x.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:ee,disabled:U||!te,children:U?"Checking…":"Check against my other grants"}),ne&&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:ne})]}),A&&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:A})]}),Q&&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:xx(Q,$,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:()=>l(2),children:"Back"}),s.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:pe,disabled:!te,children:"Continue to Review"})]}),(((se=k==null?void 0:k.approvers)==null?void 0:se.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(km,{open:g,onClose:()=>h(!1),ariaLabel:"Intent assistant",children:s.jsx(_a,{target:{kind:"intent",profileId:r.profileId,bounds:Y||void 0},currentText:x,onApply:_=>{ue(_),h(!1)}})}),R&&s.jsx("div",{className:"modal-backdrop",onClick:_=>_.target===_.currentTarget&&F(null),children:s.jsxs("div",{className:"modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{className:"modal-title",children:R.length>1?`Existing mandates (${R.length})`:"Existing mandate"}),s.jsx("button",{className:"modal-close",onClick:()=>F(null),children:"×"})]}),s.jsx("div",{className:"modal-body",children:R.map((_,J)=>{var ae;return s.jsxs("div",{style:{marginBottom:J<R.length-1?"1rem":0,paddingBottom:J<R.length-1?"1rem":0,borderBottom:J<R.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:_.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:((ae=_.intent)==null?void 0:ae.trim())||"(no intent recorded)"}),Object.entries(_.bounds).filter(([ye])=>ye!=="profile"&&ye!=="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(_.bounds).filter(([ye])=>ye!=="profile"&&ye!=="path").map(([ye,ve])=>`${ye}: ${ve}`).join(" · ")})]})]},J)})})]})})]})]})}function Sx(e){return e.normalize("NFC").replace(/\r\n?/g,`
|
|
65
|
+
`).split(`
|
|
66
|
+
`).map(a=>a.replace(/[ \t]+$/,"")).join(`
|
|
67
|
+
`).replace(/\n+$/,"")}async function bm(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")}class jx extends Error{constructor(n,r,a){super(a);Sr(this,"code");Sr(this,"field");this.name="CanonicalValueError",this.code=n,this.field=r}}function kx(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 Cm(e,t,n){const r=[];for(const a of t){const o=e[a];if(o==null)continue;const i=String(o);if(i.includes(`
|
|
68
|
+
`)||i.includes("\r"))throw new jx(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}=${kx(i)}`)}return r.join(`
|
|
69
|
+
`)}async function aa(e,t){const n=t.boundsSchema??t.frameSchema;if(!n)throw new Error("Profile has no boundsSchema or frameSchema");const r=Cm(e,n.keyOrder,"BOUNDS_INVALID_VALUE");return`sha256:${await bm(r)}`}async function Nm(e,t){const n=t.contextSchema?Cm(e,t.contextSchema.keyOrder,"CONTEXT_INVALID_VALUE"):"";return`sha256:${await bm(n)}`}async function Aa(e){const t=new TextEncoder().encode(Sx(e)),n=await crypto.subtle.digest("SHA-256",t);return`sha256:${Array.from(new Uint8Array(n)).map(o=>o.toString(16).padStart(2,"0")).join("")}`}function Em(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 bx(e){const t=e.commitment_modes;return t===void 0?["review","automatic"]:Array.isArray(t)?["review","automatic"].filter(n=>t.includes(n)):[]}function Cx(e){return e==="per-action"?"review":"automatic"}function yu(e){return e?bx(e).map(t=>t==="review"?"per-action":"immediate"):["per-action","immediate"]}function Nx(e,t){return t.includes(e)?e:t[0]??null}function vu(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function Ex(e,t){for(const n of e)if(t.has(n))return!0;return!1}function Tx(e,t,n){for(const r of e){const a=vu(t[r]),o=vu(n[r]);if(!(a.size===0||o.size===0)&&!Ex(a,o))return!1}return!0}function Ix(e){return e.length>24?`${e.slice(0,10)}…`:e}function Tm(e,t,n){const r=n==null?void 0:n[e];return String(t).split(",").map(o=>o.trim()).filter(Boolean).map(o=>{const i=r==null?void 0:r[o];return i?`${i} (${Ix(o)})`:o}).join(", ")}function Im(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 Rx(){var b,O;const e=en(),{user:t,mode:n,domain:r}=Oe(),[a,o]=u.useState(null),[i,c]=u.useState(null),[l,d]=u.useState(null),[f,p]=u.useState("per-action"),[m,w]=u.useState(1800),[v,x]=u.useState(86400),[j,g]=u.useState(""),[h,y]=u.useState("hours"),[S,k]=u.useState(""),[N,C]=u.useState(!0),[P,E]=u.useState(!1),[z,U]=u.useState(""),[V,Q]=u.useState(null),[D,A]=u.useState([]),[B,ne]=u.useState(!1),[L,$]=u.useState([]),[H,R]=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),ge=JSON.parse(G),Qe={bounds:ge.bounds??{},context:ge.context??{},contextLabels:ge.contextLabels??void 0,gateContent:ge.gateContent};o(re),c(Qe),ge.ttlConfig&&(w(ge.ttlConfig.default??1800),x(ge.ttlConfig.max??86400)),ge.templateMode==="automatic"?p("immediate"):ge.templateMode==="review"&&p("per-action");const bn=((nn=ge.ttlConfig)==null?void 0:nn.max)??86400;if(typeof ge.templateTtl=="number"&&ge.templateTtl>0){const _e=Math.min(ge.templateTtl,bn);w(_e),[3600,86400,604800,2592e3,31536e3].includes(_e)||(_e%86400===0?(g(String(_e/86400)),y("days")):(g(String(Math.max(1,Math.round(_e/3600)))),y("hours")))}I.getProfile(re.profileId).then(_e=>{var vt;if(d(_e),!S){const W=_e.name??((vt=re.profileId.split("/").pop())==null?void 0:vt.replace(/@.*$/,""))??"",q=[];if(Qe.context&&_e.contextSchema)for(const de of _e.contextSchema.keyOrder){const Z=Qe.context[de];if(Z!==void 0&&Z!==""){const Ie=String(Z).split(",").map(Nt=>Nt.trim()).filter(Boolean);q.push(Ie.join(", "))}}const oe=q.length>0?`${W}: ${q.join(" · ")}`:W;k(oe)}}).catch(()=>{}),re.isPersonal?ne(!0):Promise.all([I.getTeamProfileConfig(re.groupId,re.profileId).catch(()=>null),I.getGroupById(re.groupId).catch(()=>null),I.listUsers().catch(()=>[])]).then(([_e,vt,W])=>{if(Q(_e),_e){const q=new Map;for(const Z of W){const Ie=Z.name&&Z.email?`${Z.name} (${Z.email})`:Z.name||Z.email||Z.id;q.set(Z.id,Ie)}const oe=(vt==null?void 0:vt.members)??[];for(const Z of oe){const Ie=Z.userId??Z.id;Ie&&(Z.name&&Z.email?q.set(Ie,`${Z.name} (${Z.email})`):Z.name&&q.set(Ie,Z.name))}const de=(_e.approvers??[]).map(Z=>q.get(Z)??Z);A(de)}}).finally(()=>{ne(!0)})},[e]),u.useEffect(()=>{if(!(a!=null&&a.profileId))return;const T=a.profileId,G=sessionStorage.getItem("agentEditReplaces");I.getEnrichedAuthorizations().then(re=>{const ge=re.filter(Qe=>Qe.profileId===T&&Qe.authorizationId!==G).map(Qe=>({authorizationId:Qe.authorizationId,bounds:Qe.bounds,context:Qe.context??{},intent:Qe.intent}));$(ge)}).catch(()=>$([]))},[a==null?void 0:a.profileId]),u.useEffect(()=>{if(!l)return;const T=Nx(f,yu(l));T&&T!==f&&p(T)},[l,f]),u.useEffect(()=>{if(!i||!l||L.length===0){R(0);return}let T=!1;return(async()=>{const G=await aa(i.bounds,l),re=await Promise.all(L.map(ge=>aa(ge.bounds,l).catch(()=>null)));T||R(re.filter(ge=>ge===G).length)})().catch(()=>{T||R(0)}),()=>{T=!0}},[i,l,L]);const F=async()=>{if(!(!a||!i||!l||!t)){if(!a.groupId){U("No active group; cannot create mandate.");return}E(!0),U("");try{const T=r||a.domain||"owner",G=await aa(i.bounds,l),re=await Nm(i.context,l),[ge,Qe]=await Promise.all([Aa(i.gateContent.intent),Aa(JSON.stringify({profile:a.profileId,domain:T,group:a.groupId}))]);let bn,nn,_e,vt;if(a.isTeam){const de=await I.getApproversPubkeys(a.groupId,a.profileId);if(de.length>0){const Z=await I.encryptIntent(i.gateContent.intent,de);bn=Z.intentCiphertext,nn=Z.encryptedKeys,_e=Z.approversFrozen,vt=Z.intentDisclosureHash}}const W=`authz_${crypto.randomUUID()}`,q=sessionStorage.getItem("agentEditReplaces")||void 0,oe=await I.attest({authorization_id:W,replaces:q,profile_id:a.profileId,bounds:i.bounds,bounds_hash:G,context_hash:re,domain:T,did:t.did,gate_content_hashes:{intent:ge},execution_context_hash:Qe,group_id:a.groupId,ttl:m,commitment_mode:Cx(f),title:S.trim(),intent_ciphertext:bn,encrypted_keys:nn,approvers_frozen:_e,intent_disclosure_hash:vt,disclose_identity:N});try{await I.pushGateContent(Em(oe,{boundsHash:G,contextHash:re,context:i.context,contextLabels:i.contextLabels,gateContent:i.gateContent}))}catch(de){try{await I.revokeAttestation(W,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Mandate signed but gate content delivery failed. The mandate was revoked. Please try again. (${de instanceof Error?de.message:"Unknown error"})`)}if(q)try{await I.revokeAttestation(q,`Replaced by ${W} (edit)`),I.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/mandates?highlight=${encodeURIComponent(W)}`)}catch(T){U(T instanceof Error?T.message:"Signing the mandate failed")}finally{E(!1)}}};if(!a||!i)return s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const Y=Object.entries(i.bounds).filter(([T])=>T!=="profile"&&T!=="path"),X=Object.entries(i.context),ue=((V==null?void 0:V.caps)!=null?Object.keys(V.caps):[]).length!==0,pe=D.length>0?D.join(", "):((V==null?void 0:V.approvers)??[]).join(", "),ee=ue?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${pe}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",ie=ue?`Over-cap actions will be reviewed by you and ${pe}. Within-cap actions run per the mode you chose above.`:`Approvers ${pe} can read your intent but won't gate any action — no caps configured on this profile.`,se=!!((b=V==null?void 0:V.approvers)!=null&&b.length),_=Im({isPersonal:a.isPersonal,configLoaded:B,approvers:V==null?void 0:V.approvers,userId:t==null?void 0:t.id,profileName:Pe(a.profileId),teamName:a.groupName}),J=!_.can,ae=yu(l),ye=ae.length===0,ve=m>v,Le={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"},tt={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"},Be=((O=l==null?void 0:l.contextSchema)==null?void 0:O.keyOrder)??[],lt=L.filter(T=>Tx(Be,i.context,T.context)),nt=lt.length>0,De=Pe(a.profileId),ce=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=>ce(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(jm,{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."}),z&&s.jsx("div",{className:"error-message",children:z}),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:S,onChange:T=>k(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:[ae.includes("per-action")&&s.jsxs("button",{onClick:()=>p("per-action"),style:tt,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."})]}),ae.includes("immediate")&&s.jsxs("button",{onClick:()=>p("immediate"),style:Le,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."})]})]}),ae.length===1&&s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:ae[0]==="per-action"?"This profile only allows review: you approve each action before it runs.":"This profile only allows automatic mode."}),ye&&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<=v).map(T=>s.jsx("button",{onClick:()=>{w(T.seconds),g("")},style:{padding:"0.5rem 0.85rem",border:m===T.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:m===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:j,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,v))}}}),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(j,10);if(G>0){const re=T.target.value==="days"?G*86400:G*3600;w(Math.min(re,v))}},children:[s.jsx("option",{value:"hours",children:"hours"}),s.jsx("option",{value:"days",children:"days"})]})]}),ve&&s.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",v>=86400?`${Math.floor(v/86400)} days`:`${Math.floor(v/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:N,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:i.gateContent.intent})]}),(!!Y.length||!!X.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:[X.map(([T,G])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:T}),s.jsx("dd",{children:Tm(T,G,i.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:B?_.can?s.jsxs(s.Fragment,{children:[pe,s.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:ee})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{color:"var(--danger)",fontWeight:600},children:_.code==="PROFILE_NOT_ENABLED_FOR_GROUP"?`Not enabled for ${a.groupName??"this team"}`:"You cannot give this mandate"}),_.code==="OWNER_NOT_APPROVER"&&s.jsx("div",{children:pe}),s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[_.reason," ",_.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||!S.trim()||J||ye,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:se?"block":"none"},children:ie})]})]})}const Px={card:"💳",mail:"✉️"};function Rm(e){return Px[e]??"🔧"}function _x(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 Ax=[0,7,30,90,365,3650];function Us(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 zx(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 $o({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:a}){var tn;const[o,i]=u.useState({}),[c,l]=u.useState(!1),[d,f]=u.useState(!1),[p,m]=u.useState({}),[w,v]=u.useState({}),[x,j]=u.useState(void 0),[g,h]=u.useState(!1),[y,S]=u.useState(null),[k,N]=u.useState(!1),[C,P]=u.useState(!1),[E,z]=u.useState(!1),[U,V]=u.useState(!1),[Q,D]=u.useState({}),[A,B]=u.useState(null),[ne,L]=u.useState(!1),[$,H]=u.useState(null),[R,F]=u.useState(!1);u.useEffect(()=>{let b=!1;return I.getCredential(e.id).then(O=>{var T;if(!(b||!O.configured)){if(l(!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]);m(G)}if(v(O.secrets??{}),j(O.updatedAt),e.oauth){const G=((T=O.fieldNames)==null?void 0:T.includes(e.oauth.tokenStorage))??!1;h(G),G&&I.getOAuthHealth(e.id).then(re=>{b||S(re)})}}}).catch(()=>{}),()=>{b=!0}},[e.id,e.oauth]);const Y=_x(e.toolGating),X=t?t.readAgeDays??null:void 0,te=ne&&A?A.value:X,ue=async b=>{B({value:b}),L(!0),H(null);try{await I.setReadPolicy(e.id,b),a(b===null?`${e.name} read window now follows your mandate`:`${e.name} read window set to ${Us(b).toLowerCase()}`),r()}catch(O){H(O instanceof Error?O.message:"Could not save")}finally{L(!1),B(null)}},pe=!!e.oauth||e.credentials.fields.some(b=>!b.optional),ee=e.oauth?g:c,ie=!pe||ee,se=n==="starting"?"starting":ie?t!=null&&t.running?"running":!c&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&c&&!g?"needs-oauth":"unconfigured",_=async()=>{if(e.credentials.fields.some(O=>{var T;return(T=o[O.key])==null?void 0:T.trim()})){N(!0);try{await I.setCredential(e.id,o),l(!0),i({}),e.oauth?a(`${e.name} credentials saved!`):(a(`${e.name} credentials saved — starting integration...`),await Le())}catch{a(`Failed to save ${e.name} credentials`)}finally{N(!1)}}},J=()=>{const b={};for(const O of e.credentials.fields){const T=o[O.key];O.type==="password"?T!=null&&T.trim()&&(b[O.key]=T):T!=null&&T!==(p[O.key]??"")&&(b[O.key]=T)}return b},ae=Object.keys(J()).length>0,ye=async()=>{const b=J();if(Object.keys(b).length!==0){N(!0);try{await I.setCredential(e.id,b),i({}),l(!0),e.oauth?a(`${e.name} credentials saved — now click Connect.`):(V(!1),a(`${e.name} credentials updated — restarting...`),await Le())}catch{a(`Failed to update ${e.name} credentials`)}finally{N(!1)}}},ve=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const b=setInterval(async()=>{var O;try{const T=await I.getCredential(e.id);T.configured&&e.oauth&&((O=T.fieldNames)!=null&&O.includes(e.oauth.tokenStorage))&&(h(!0),V(!1),S(null),clearInterval(b),a(`${e.name} connected — starting integration...`),I.getOAuthHealth(e.id).then(S).catch(()=>{}),await Le())}catch{}},2e3);setTimeout(()=>clearInterval(b),12e4)},Le=async()=>{z(!0);try{const b=await I.activateIntegration(e.id);b.warning?a(b.warning):a(`${e.name} integration started with ${b.tools.length} tools`),r()}catch(b){a(`Failed to start ${e.name}: ${b instanceof Error?b.message:"Unknown error"}`)}finally{z(!1)}},tt=async()=>{try{await I.removeMcpIntegration(e.id),a(`${e.name} integration removed`),r()}catch{a(`Failed to remove ${e.name}`)}},Be=Rm(e.icon),lt=zx(t),nt=se==="running"?{c:"int-chip-ok",t:"Running"}:se==="starting"?{c:"int-chip-idle",t:"Starting"}:lt.chip,De=e.oauth&&g&&(y==null?void 0:y.status)==="failed",ce=pe?De?{c:"int-chip-bad",t:"Auth failed"}:ee?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},ct=b=>b.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:Be}),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:[se!=="unconfigured"&&se!=="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 ${ce.c}`,children:[s.jsx("span",{className:"int-dot"}),ce.t]}),Hv(e,p)&&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&&!U&&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:ve,children:["Reconnect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{i({...p}),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&&(se!=="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((b,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:b.title}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[ct(b.description),b.link&&s.jsxs(s.Fragment,{children:[" ",s.jsxs("a",{href:b.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},O))})]}),se==="starting"&&s.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[s.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),U&&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(b=>{var O;return s.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[s.jsx("label",{className:"form-label",children:b.label}),b.type==="password"?s.jsxs("div",{className:"cred-field",children:[s.jsx("input",{className:"form-input",type:Q[b.key]?"text":"password",name:`${e.id}-${b.key}-credential`,autoComplete:"new-password",placeholder:(O=w[b.key])!=null&&O.preview?`Unchanged — ends in ${w[b.key].preview}`:d?"Unchanged — paste a new value to replace":b.placeholder,value:o[b.key]||"",onChange:T=>i(G=>({...G,[b.key]:T.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>D(T=>({...T,[b.key]:!T[b.key]})),children:Q[b.key]?"hide":"show"})]}):s.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${b.key}-credential`,autoComplete:"off",placeholder:b.placeholder,value:o[b.key]||"",onChange:T=>i(G=>({...G,[b.key]:T.target.value}))})]},b.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:ye,disabled:k||!ae,children:k?"Saving…":"Save"}),!ae&&!k&&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:ve,children:["Connect ",e.name]}),s.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{V(!1),i({})},children:"Cancel"})]})]}),!U&&se==="running"&&t&&s.jsxs(s.Fragment,{children:[(Object.keys(p).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(b=>{const O=b.type==="password",T=w[b.key];return!O&&p[b.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:b.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":p[b.key],O&&x&&s.jsxs("span",{style:{color:"var(--text-muted)",fontFamily:"inherit"},children:[" ","· added ",new Date(x).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]})]},b.key)})}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx(Xe,{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:()=>{i({...p}),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:tt,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&&te!==void 0&&!R&&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:te===null?"window from your mandate":Us(te).toLowerCase()}),ne&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"saving…"}),$&&s.jsx("span",{style:{fontSize:"0.78rem",color:"var(--danger)"},children:$})]}),s.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>F(!0),children:"Edit"})]})}),Y&&te!==void 0&&R&&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:[Ax.map(b=>{const O=te===b;return s.jsx("button",{className:`btn btn-sm ${O?"btn-primary":"btn-secondary"}`,"aria-pressed":O,disabled:ne,onClick:()=>ue(b),children:Us(b)},b)}),s.jsx("button",{className:`btn btn-sm ${te===null?"btn-primary":"btn-ghost"}`,"aria-pressed":te===null,disabled:ne,onClick:()=>ue(null),title:"Clear the local setting and use the read window from your signed mandate instead.",children:Us(null)})]}),s.jsx("div",{style:{fontSize:"0.78rem",marginTop:"0.5rem"},children:$?s.jsx("span",{style:{color:"var(--danger)"},children:$}):ne?s.jsx("span",{style:{color:"var(--text-muted)"},children:"Saving…"}):te===null?s.jsx("span",{style:{color:"var(--text-muted)"},children:"Using the window from your mandate. If none is set there, reads are blocked."}):te===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 ",te," days is blocked, whoever it is from."]})})]}),s.jsx("div",{style:{display:"none"},children:s.jsx(Xe,{to:"/mandates?new=1",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Give your agent a mandate"})})]}),se==="unconfigured"&&(()=>{const b=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=o[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:()=>{l(!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:Q[G.key]?"text":"password",name:`${e.id}-${G.key}-credential`,autoComplete:"new-password",placeholder:G.placeholder,value:o[G.key]||"",onChange:re=>i(ge=>({...ge,[G.key]:re.target.value}))}),s.jsx("button",{className:"cred-toggle",onClick:()=>D(re=>({...re,[G.key]:!re[G.key]})),children:Q[G.key]?"hide":"show"})]}):s.jsx("input",{className:"form-input",type:"text",name:`${e.id}-${G.key}-credential`,autoComplete:"off",placeholder:G.placeholder,value:o[G.key]||"",onChange:re=>i(ge=>({...ge,[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:_,disabled:k||O&&!e.credentials.fields.filter(G=>!G.optional).every(G=>{var re;return(re=o[G.key])==null?void 0:re.trim()}),children:k?"Saving...":"Save & Encrypt"}),b&&!T&&s.jsx("button",{className:"btn btn-primary",onClick:Le,disabled:E,children:E?"Starting...":`Activate ${e.name}`})]})]})})(),se==="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:ve,children:["Connect ",e.name," Account"]}),s.jsx("button",{className:"btn btn-ghost",onClick:()=>l(!1),children:"Change Credentials"})]})]}),se==="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:Le,disabled:E,children:E?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&s.jsx("button",{className:"btn btn-ghost",onClick:()=>l(!1),children:"Update Credentials"}),e.oauth&&s.jsx("button",{className:"btn btn-ghost",onClick:()=>{l(!1),h(!1)},children:"Change Credentials"})]})]}),se==="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:Le,disabled:E,children:E?"Starting...":"Start"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:tt,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:tt,children:"Disable"})})]}))]})}function $x(e,t){if(!t)return{grouped:!1,testSystems:[],realErrors:[],pausedReal:[],ungrouped:e};const n=e.filter(i=>zi(i.manifest)),r=e.filter(i=>!zi(i.manifest)),a=r.filter(i=>i.state==="error"),o=r.filter(i=>i.state!=="error");return{grouped:!0,testSystems:n,realErrors:a,pausedReal:o,ungrouped:[]}}function Lx({entry:e}){return s.jsxs("div",{className:"int-paused-row",children:[s.jsx("span",{"aria-hidden":"true",children:Rm(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 Mx(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:a}=Wl(),o=pm(),[i,c]=u.useState(""),l=u.useCallback(f=>{c(f),setTimeout(()=>c(""),5e3)},[]),d=$x(r,o);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."})]}),i&&s.jsx("div",{className:"alert alert-success",children:i}),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($o,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:l},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($o,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:l},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(Lx,{entry:f},f.id))]})]}),r.length===0&&s.jsx(xu,{manifestsError:n})]}):s.jsxs(s.Fragment,{children:[r.map(f=>s.jsx($o,{manifest:f.manifest,integration:f.integration,state:f.state,onStatusChange:a,onSuccess:l},f.id)),r.length===0&&s.jsx(xu,{manifestsError:n})]})]})}function xu({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 Fx(){var U,V,Q;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Oe(),[a,o]=u.useState(null),[i,c]=u.useState(!1),[l,d]=u.useState(""),[f,p]=u.useState(""),[m,w]=u.useState(!1),[v,x]=u.useState(""),[j,g]=u.useState("");u.useEffect(()=>{fetch("/health").then(D=>D.json()).then(D=>{typeof D.spUrl=="string"&&g(D.spUrl)}).catch(()=>{})},[]),u.useEffect(()=>{if(!e){o(null);return}I.getGroupById(e.id).then(D=>{const A=D.group??D,B=D.members??[],ne=D.isAdmin??!1,L=B.map($=>{const H=$.userId||$.id||"",R=$.role||(ne&&H===A.createdBy?"admin":"member");return{id:H,name:$.name||H.slice(0,8)||"Member",email:$.email||"",domains:$.domains||[],role:R,isAdmin:R==="admin"||ne&&H===A.createdBy}});o({id:A.id,name:A.name,members:L})}).catch(()=>o(null))},[e==null?void 0:e.id]);const h=(a==null?void 0:a.members.filter(D=>D.isAdmin))??[],y=(e==null?void 0:e.isAdmin)===!0&&h.length<=1&&h.some(D=>D.id===(r==null?void 0:r.id)),S=(e==null?void 0:e.name)??"",k=v.trim()===S&&!i,N=()=>{x(""),w(!0)},C=()=>{w(!1),x("")},P=async()=>{if(!(!e||!k)){c(!0),d("");try{await I.leaveTeam(e.id),await n(),p("You have left the team."),o(null),C()}catch(D){d(D instanceof Error?D.message:"Failed to leave team")}finally{c(!1)}}},E=e&&j?`${j}/dashboard/groups/${e.id}`:void 0,z=j?`${j}/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."})]})}),l&&s.jsx("div",{className:"error-message",children:l}),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:[((U=a==null?void 0:a.members)==null?void 0:U.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"})]}),(Q=a==null?void 0:a.members)==null?void 0:Q.map(D=>s.jsxs("div",{className:"member-row",children:[s.jsx("div",{className:"member-avatar",children:D.name.split(" ").map(A=>A[0]).join("").slice(0,2).toUpperCase()}),s.jsxs("div",{className:"member-info",children:[s.jsx("div",{className:"member-name",children:D.name}),s.jsx("div",{className:"member-email",children:D.email})]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:D.role})]},D.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:[E&&s.jsx("a",{className:"btn btn-secondary btn-sm",href:E,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:N,disabled:i||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."}),z&&s.jsx("a",{className:"btn btn-primary btn-sm",href:z,target:"_blank",rel:"noopener noreferrer",children:"Open Authority Server dashboard →"})]}),m&&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:D=>D.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 ",S,"?"]}),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:S})," to confirm:"]}),s.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:v,onChange:D=>x(D.target.value),placeholder:S,disabled:i,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:i,children:"Cancel"}),s.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:P,disabled:!k,children:i?"Leaving...":"Leave team"})]})]})})]})}const $i=e=>e.replace(/@.*$/,"").split("/").pop()??e,wu=e=>e.split("@")[1]??"";function Ox(e,t){const n=new Map;for(const r of e){const a=$i(r.id);if(!t.has(a))continue;const o=n.get(a);(!o||wu(r.id).localeCompare(wu(o.id),void 0,{numeric:!0})>0)&&n.set(a,r)}return n}function Bx(e,t,n,r){var c;const a=new Set([...t.filter(l=>l.profile).map(l=>l.profile),...r.map(l=>$i(l.profile))]),o=Ox(e,a),i=[];for(const l of t){const d=l.profile?o.get(l.profile):void 0;d&&i.push({key:`connector:${l.id}`,name:l.name,description:l.description||d.description,profile:d,kind:"connector",ready:((c=n.find(f=>f.id===l.id))==null?void 0:c.running)===!0,setupId:l.id})}for(const l of r){const d=o.get($i(l.profile));d&&i.push({key:`builtin:${l.id}`,name:l.name,description:l.description||d.description,profile:d,kind:"builtin",ready:l.available,unavailableReason:l.available?void 0:"Available only while simulation mode is on."})}return i}function Dx({onDismiss:e}){const t=en(),{group:n,groupId:r,domain:a,user:o}=Oe(),[i,c]=u.useState([]),[l,d]=u.useState([]),[f,p]=u.useState([]),[m,w]=u.useState([]),[v,x]=u.useState(!0),[j,g]=u.useState({});u.useEffect(()=>{Promise.all([I.listProfiles().catch(()=>[]),I.getIntegrationManifests().then(C=>C.manifests??[]).catch(()=>[]),I.getMcpHealth().catch(()=>null)]).then(async([C,P,E])=>{if(c(C),d(P),p((E==null?void 0:E.integrations)??[]),w((E==null?void 0:E.builtins)??[]),r){const z=await Promise.all(C.map(V=>I.getTeamProfileConfig(r,V.id).catch(()=>null))),U={};C.forEach((V,Q)=>{const D=z[Q];D&&(U[V.id]=D)}),g(U)}}).finally(()=>x(!1))},[r]);const h=Bx(i,l,f,m),y=C=>{var P;return Im({isPersonal:!!(n!=null&&n.isPersonal),configLoaded:!v,approvers:(P=j[C.id])==null?void 0:P.approvers,userId:o==null?void 0:o.id,profileName:Pe(C.id),teamName:n==null?void 0:n.name})},S=C=>C in j,k=C=>{if(!r){console.error("No active group when creating authorization");return}const P=S(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")},N=C=>{r&&k(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
|
+
`}),v?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(Xe,{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,E=S(P.id),z=y(P),U=!C.ready||!z.can;return s.jsxs("div",{className:"card",style:U?{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}),E?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}),z.can?C.ready?s.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>N(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(Xe,{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:[z.reason," ",s.jsx("span",{style:{color:"var(--text-tertiary)"},children:z.fix})]})]})]},C.key)})})]})}const Ux={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function Wx({status:e,label:t}){return s.jsx("span",{className:`status-badge status-${e}`,children:t||Ux[e]})}function Hx({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,Fr=3600,Ws=60,Vx=30*Tn;function Gx(e){if(e<=0)return"Expired";if(e>90*Tn){const t=Math.floor(e/Vx);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/Fr);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*Fr){const t=Math.floor(e/Fr),n=Math.floor(e%Fr/Ws);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=Ws){const t=Math.floor(e/Ws),n=Math.floor(e%Ws);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function Kx({expiresAt:e}){const[t,n]=u.useState(()=>e-Date.now()/1e3),r=t<2*Fr;u.useEffect(()=>{const o=setInterval(()=>n(e-Date.now()/1e3),r?1e3:6e4);return()=>clearInterval(o)},[e,r]);const a=t<300;return s.jsx("span",{className:`ttl-badge ${a?"ttl-warn":"ttl-ok"}`,children:Gx(t)})}function Pm({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 Yx(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 Qx=[{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 Jx({item:e,onClose:t,onSuccess:n}){var y;const{user:r,activeDomain:a,groupId:o}=Oe(),[i,c]=u.useState(null);u.useEffect(()=>{let S=!1;return I.getProfile(e.profile_id).then(k=>{var N;S||c(((N=k==null?void 0:k.ttl)==null?void 0:N.max)??null)}).catch(()=>{}),()=>{S=!0}},[e.profile_id]);const l=e.remaining_seconds??0,d=Qx.filter(S=>S.seconds>l&&(i===null||S.seconds<=i)),f=((y=d[0])==null?void 0:y.seconds)??2592e3,[p,m]=u.useState(f);u.useEffect(()=>{var S;if(i!==null&&p>i){const k=(S=d[d.length-1])==null?void 0:S.seconds;k&&m(k)}},[i]);const[w,v]=u.useState(!1),[x,j]=u.useState(""),g=Object.entries(e.frame).filter(([S])=>S!=="profile"&&S!=="path"),h=async()=>{var S;if(r){v(!0),j("");try{const k=e.authorization_id,N=await I.getGateContent(k);if(!N)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 I.getProfile(e.profile_id),P=e.frame,E=N.context??{},z=e.attested_domains[0]||a||"owner",U=await aa(P,C),V=await Nm(E,C),[Q,D]=await Promise.all([Aa(N.gateContent.intent),Aa(JSON.stringify({profile:e.profile_id,path:e.path,domain:z}))]);if(!o)throw new Error("No active group; cannot extend mandate.");const A=(((S=e.deferred_commitment_domains)==null?void 0:S.length)??0)>0?"review":"automatic",B=await I.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:P,bounds_hash:U,context_hash:V,domain:z,did:r.did,gate_content_hashes:{intent:Q},execution_context_hash:D,group_id:o,commitment_mode:A,ttl:p});await I.pushGateContent(Em(B,{boundsHash:U,contextHash:V,context:E,path:e.path,gateContent:N.gateContent})),n()}catch(k){j(k instanceof Error?k.message:"Extension failed")}finally{v(!1)}}};return s.jsx("div",{className:"modal-backdrop",onClick:S=>S.target===S.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(([S,k])=>`${S}=${k}`).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"}),l>0&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",Yx(l),". 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(S=>s.jsx("button",{className:`btn ${p===S.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>m(S.seconds),style:{minWidth:"3.5rem"},children:S.label},S.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)."}),x&&s.jsx("div",{className:"error-message",children:x})]}),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 Xx(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 o=Pa(r,t),i=Pa(a,t),c={active:0,pending:1,expired:2,revoked:3,archived:4};return c[o]!==c[i]?c[o]-c[i]:new Date(a.created_at).getTime()-new Date(r.created_at).getTime()})}function qx({item:e,newerProfile:t,revokedSet:n,expandedHash:r,gateCache:a,gateLoading:o,copiedHash:i,revokingHash:c,copyingHash:l,profileConfigCache:d,mode:f,ownerLabel:p,isAdmin:m,onExpand:w,onCopyHash:v,onCopy:x,onRevoke:j,onExtend:g,archivedSet:h,archivingHash:y,onArchive:S,highlightHash:k}){var pe;const N=Ul(e,{revokedSet:n}),C=um(e,{revokedSet:n,archivedSet:h}),P=!p&&!!S&&cm(N),E=r===e.authorization_id,z=a[e.authorization_id],U=N==="active"||N==="pending"||N==="expired",V=Object.entries(e.frame).filter(([ee])=>ee!=="profile"&&ee!=="path"),Q=d.get(e.profile_id)??null,D=(((pe=Q==null?void 0:Q.approvers)==null?void 0:pe.length)??0)>0,A=new Map;if(Q!=null&&Q.caps&&f==="team")for(const[ee,ie]of V){const se=Q.caps[ee];se!==void 0&&Number(ie)>se&&A.set(ee,{authorized:Number(ie),cap:se})}const B=A.size>0,ne=e.approvers_frozen??[],L=(Q==null?void 0:Q.approvers)??[],$=f==="team"&&ne.length>0&&L.length>0&&(ne.length!==L.length||ne.some(ee=>!L.includes(ee))||L.some(ee=>!ne.includes(ee))),H=Array.from(A.entries()).map(([ee,ie])=>`${ee}: ${ie.authorized} (cap ${ie.cap})`).join(", "),R=Array.from(A.entries()).map(([ee,ie])=>`${ee}: ${ie.authorized} → ${ie.cap}`).join(", "),F=B?D?A.size===1?`Above team cap: ${H} — actions require approval`:`Above team cap (${A.size}): ${H} — actions require approval`:A.size===1?`Reduced by hard cap: ${R}`:`Reduced by hard cap (${A.size}): ${R}`:"",Y=B?D?"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,X=Pe(e.profile_id),te=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:[X,"@",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,ue=k!=null&&e.authorization_id===k;return s.jsxs("div",{className:`card${ue?" card-highlight":""}`,style:{marginBottom:0},children:[te,p&&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:p})]}),s.jsxs("div",{className:"auth-card-header",children:[s.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:X}),e.title&&s.jsx("span",{style:{fontWeight:500,fontSize:"0.85rem",color:"var(--text-secondary)"},children:e.title}),s.jsx(Wx,{status:N}),N==="active"&&e.earliest_expiry&&s.jsx(Kx,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),N==="expired"&&(()=>{const ee=Jy(e,N);return ee?s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},title:`Expired ${new Date(ee.iso).toLocaleString()}`,children:new Date(ee.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(ee=>s.jsx(Hx,{domain:ee,attested:e.attested_domains.includes(ee)},ee)),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"}),B&&s.jsx("span",{title:Y,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:D?"var(--accent-subtle)":"var(--danger-subtle)",color:D?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:F}),$&&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:()=>x(e),disabled:l===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:l===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(([ee,ie],se)=>{const _=A.get(ee);return s.jsxs("span",{children:[se>0&&" · ",_?D?s.jsxs("span",{title:`Team cap on ${ee} is ${_.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${_.authorized}.`,children:[s.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[ee,"=",String(ie)]}),s.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",_.cap]})]}):s.jsxs("span",{title:`Team cap on ${ee} is ${_.cap} with no approvers configured (hard cap). Authorized for ${_.authorized}; effective ${_.cap}.`,children:[s.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[ee,"=",String(ie)]}),s.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",_.cap]})]}):s.jsxs("span",{children:[ee,"=",String(ie)]})]},ee)})}),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:()=>S(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:E?"▲ Hide Details":"▼ Details"})]}),E&&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(([ee,ie])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:ee}),s.jsx("dd",{children:String(ie)})]},ee))})]}),(z==null?void 0:z.context)&&Object.keys(z.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(z.context).map(([ee,ie])=>s.jsxs("span",{style:{display:"contents"},children:[s.jsx("dt",{children:ee}),s.jsx("dd",{title:String(ie),children:Tm(ee,ie,z.contextLabels)})]},ee))})]}),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"}),o===e.authorization_id?s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):z?s.jsx("div",{className:"gate-content-block",children:s.jsx("div",{className:"gate-content-item",children:s.jsx("div",{className:"gate-content-text",children:z.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:()=>v(e.authorization_id),children:i===e.authorization_id?"copied":"copy"})]}),s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!p&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>x(e),disabled:l===e.authorization_id,title:"Start a new mandate pre-filled with these bounds, scope, and intent",children:l===e.authorization_id?"Copying…":"⧉ Copy"}),!p&&(N==="active"||N==="pending")&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>x(e,{asEdit:!0}),disabled:l===e.authorization_id,title:"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new mandate revokes this one",children:"✎ Edit"}),!p&&U&&s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>g(e),children:"↻ Extend"}),p&&m&&N!=="revoked"?s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>j(e.authorization_id,p,X),disabled:c===e.authorization_id,children:c===e.authorization_id?"Revoking…":"Revoke"}):!p&&(N==="active"||N==="pending")?s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>j(e.authorization_id),disabled:c===e.authorization_id,children:c===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]},e.authorization_id)}function Zx(){const[e,t]=u.useState([]),[n,r]=u.useState(!0),[a,o]=u.useState([]),[i,c]=u.useState(!1),[l,d]=u.useState(new Map),[f,p]=u.useState("mine"),[m,w]=u.useState("active"),[v,x]=u.useState(null),[j,g]=u.useState(null),[h,y]=sm(),[S,k]=u.useState(()=>h.get("new")==="1"),[N,C]=u.useState(()=>h.get("highlight")),[P,E]=u.useState(null),[z,U]=u.useState({}),[V,Q]=u.useState(null),[D,A]=u.useState(null),[B,ne]=u.useState(null),[L,$]=u.useState(new Set),[H,R]=u.useState(null),[F,Y]=u.useState(new Set),[X,te]=u.useState(null),[ue,pe]=u.useState(null),ee=en(),{group:ie,groupId:se,domain:_,mode:J,activeTeam:ae}=Oe(),ye=(ae==null?void 0:ae.isAdmin)===!0,[ve,Le]=u.useState(()=>new Map),tt=u.useCallback(()=>{r(!0),I.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),Be=u.useCallback(()=>{I.getArchivedMandates().then(W=>Y(new Set(W))).catch(()=>{})},[]);u.useEffect(()=>{Be()},[Be]);const lt=async(W,q)=>{te(W);try{const oe=await I.setMandateArchived(W,q);Y(new Set(oe)),window.dispatchEvent(new Event("suveren:archived-changed"))}catch(oe){alert(oe instanceof Error?oe.message:"Failed to update archive")}finally{te(null)}},nt=u.useCallback(()=>{se&&(c(!0),I.listTeamAuthorizations(se).then(o).catch(()=>{}).finally(()=>c(!1)))},[se]);me("attestation-changed",()=>{tt(),ye&&se&&nt()}),u.useEffect(()=>{if(!N)return;h.get("highlight")&&(h.delete("highlight"),y(h,{replace:!0}));const W=window.setTimeout(()=>C(null),3e3);return()=>window.clearTimeout(W)},[]),Pt(tt,3e5),u.useEffect(()=>{f==="team"&&ye&&se&&a.length===0&&!i&&nt()},[f,ye,se,a.length,i,nt]),u.useEffect(()=>{let W=!1;return I.listProfiles().then(q=>{if(W)return;const oe=Ie=>Ie.replace(/@.*$/,"").split("/").pop()??Ie,de=Ie=>Ie.split("@")[1]??"",Z=new Map;for(const Ie of q){const Nt=oe(Ie.id),ws=Z.get(Nt);(!ws||de(Ie.id).localeCompare(de(ws.id),void 0,{numeric:!0})>0)&&Z.set(Nt,Ie)}d(Z)}).catch(()=>{}),()=>{W=!0}},[]);const De=u.useCallback(W=>{const q=Nt=>Nt.replace(/@.*$/,"").split("/").pop()??Nt,oe=Nt=>Nt.split("@")[1]??"",de=l.get(q(W));if(!de)return;const Z=oe(W),Ie=oe(de.id);if(!(!Z||!Ie))return Ie.localeCompare(Z,void 0,{numeric:!0})>0?de:void 0},[l]);u.useEffect(()=>{if(J!=="team"||!se)return;const W=f==="mine"?e:a;if(W.length===0)return;const q=[...new Set(W.map(oe=>oe.profile_id))].filter(oe=>!ve.has(oe));if(q.length!==0){Le(oe=>{const de=new Map(oe);for(const Z of q)de.set(Z,null);return de});for(const oe of q)I.getTeamProfileConfig(se,oe).then(de=>{Le(Z=>new Map(Z).set(oe,de))}).catch(()=>{})}},[e,a,f,se,J,ve]);const ce=async W=>{if(P===W.authorization_id){E(null);return}E(W.authorization_id);const q=W.authorization_id;if(!(q in z)){Q(W.authorization_id);try{const oe=await I.getGateContent(q);U(de=>({...de,[q]:oe}))}catch{U(oe=>({...oe,[q]:null}))}finally{Q(null)}}},ct=W=>{navigator.clipboard.writeText(W).then(()=>{ne(W),setTimeout(()=>ne(null),2e3)})},tn=async(W,q)=>{var oe;if(!se){alert("No active group; cannot copy mandate.");return}pe(W.authorization_id);try{const de=W.authorization_id;let Z=z[de]??null;de in z||(Z=await I.getGateContent(de),U(Ss=>({...Ss,[de]:Z})));const Ie=Object.fromEntries(Object.entries(W.frame).filter(([Ss])=>Ss!=="profile"&&Ss!=="path")),Nt=(Z==null?void 0:Z.context)??{},ws=((oe=Z==null?void 0:Z.gateContent)==null?void 0:oe.intent)??"",zm=W.deferred_commitment_domains.length>0?"review":"automatic",$m=W.attested_domains[0]||_||"owner",Za=Date.parse(W.created_at),eo=W.earliest_expiry?Date.parse(W.earliest_expiry):NaN,Lm=Number.isFinite(Za)&&Number.isFinite(eo)&&eo>Za?Math.round((eo-Za)/1e3):void 0;sessionStorage.setItem("agentAuth",JSON.stringify({profileId:W.profile_id,groupId:se,groupName:(ie==null?void 0:ie.name)??null,domain:$m,isPersonal:!!(ie!=null&&ie.isPersonal)})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:Ie,context:Nt,gateContent:{intent:ws},templateMode:zm,templateTtl:Lm})),q!=null&&q.asEdit?sessionStorage.setItem("agentEditReplaces",W.authorization_id):sessionStorage.removeItem("agentEditReplaces"),ee("/mandates/new/intent")}catch(de){alert(de instanceof Error?de.message:"Failed to copy mandate")}finally{pe(null)}},b=async(W,q,oe)=>{const de=q&&oe?`Revoke ${q}'s ${oe} mandate? This cannot be undone.`:"Revoke this mandate? The agent will no longer be able to execute actions under it.";if(confirm(de)){R(W);try{await I.revokeAttestation(W),$(Z=>new Set(Z).add(W)),I.resyncGates().catch(()=>{}),q&&se&&nt()}catch(Z){alert(Z instanceof Error?Z.message:"Failed to revoke mandate")}finally{R(null)}}},O=f==="mine"?e:a,T=f==="mine"?n:i,G=f==="mine"?{revokedSet:L,archivedSet:F}:{revokedSet:L},re=W=>Pa(W,G),ge={active:0,pending:0,expired:0,revoked:0,archived:0};for(const W of O)ge[re(W)]+=1;const Qe=f==="mine"?["active","pending","expired","revoked","archived"]:["active","pending","expired","revoked"],bn=(()=>{const W=new Map;for(const q of O){if(re(q)!==m)continue;const oe=W.get(q.profile_id)??{count:0,review:!1};oe.count+=1,q.deferred_commitment_domains.length>0&&(oe.review=!0),W.set(q.profile_id,oe)}return Array.from(W.entries()).map(([q,oe])=>({profileId:q,...oe})).sort((q,oe)=>Pe(q.profileId).localeCompare(Pe(oe.profileId)))})(),nn=Xx(O.filter(W=>{if(re(W)!==m||v!==null&&W.profile_id!==v)return!1;if(j!==null){const q=W.deferred_commitment_domains.length>0;if(j==="review"&&!q||j==="auto"&&q)return!1}return!0}),G,N),_e={revokedSet:L,expandedHash:P,gateCache:z,gateLoading:V,copiedHash:B,revokingHash:H,copyingHash:ue,profileConfigCache:ve,mode:J,activeDomain:_,group:ie,groupId:se,onExpand:ce,onCopyHash:ct,onCopy:tn,onRevoke:b,onExtend:A,highlightHash:N},vt={..._e,archivedSet:F,archivingHash:X,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:()=>k(!0),children:"+ New mandate"})]}),S&&s.jsx("div",{className:"modal-backdrop",onClick:()=>{k(!1),h.get("new")&&(h.delete("new"),y(h,{replace:!0}))},children:s.jsxs("div",{className:"modal",onClick:W=>W.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:()=>{k(!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(Dx,{onDismiss:()=>k(!1)})]})]})}),ye&&s.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[s.jsx("button",{className:`nav-tab${f==="mine"?" active":""}`,onClick:()=>{p("mine"),w("active"),x(null),g(null),E(null)},children:"Mine"}),s.jsx("button",{className:`nav-tab${f==="team"?" active":""}`,onClick:()=>{p("team"),w("active"),x(null),g(null),E(null)},children:"Team"})]}),s.jsx("div",{className:"nav-tabs",children:Qe.map(W=>s.jsxs("button",{className:`nav-tab${m===W?" active":""}`,onClick:()=>{w(W),x(null),g(null)},children:[W.charAt(0).toUpperCase()+W.slice(1)," (",ge[W],")"]},W))}),bn.length>0&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[bn.map(W=>{const q=v===W.profileId;return s.jsx("button",{className:`btn btn-sm ${q?"btn-primary":"btn-secondary"}`,onClick:()=>x(q?null:W.profileId),children:Pe(W.profileId)},W.profileId)}),s.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(W=>{const q=j===W;return s.jsx("button",{className:`btn btn-sm ${q?"btn-primary":"btn-secondary"}`,onClick:()=>g(q?null:W),children:W==="auto"?"Auto":"Review"},W)})]}),T&&O.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):nn.length===0?s.jsx(Pm,{icon:"☰",title:"No mandates",text:m==="archived"?"Nothing archived. Archive an expired or revoked mandate to move it here.":`No ${m} mandates found.`}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:nn.map(W=>{const q=f==="team"?W:null,oe=q!=null&&q.owner?q.owner.name??q.owner.email??q.owner.userId:void 0;return s.jsx(qx,{item:W,newerProfile:De(W.profile_id),ownerLabel:oe,isAdmin:ye,...f==="mine"?vt:_e},W.authorization_id)})}),D&&s.jsx(Jx,{item:D,onClose:()=>A(null),onSuccess:()=>{A(null),tt()}})]})}function e0(e){const t=e.indexOf("__");return t<0?{integrationId:"",toolName:e}:{integrationId:e.slice(0,t),toolName:e.slice(t+2)}}function t0(e,t){var l,d,f;const{integrationId:n,toolName:r}=e0(e.action),a=t.find(p=>p.id===n),o=(d=(l=a==null?void 0:a.toolGating)==null?void 0:l.overrides)==null?void 0:d[r];if(o!=null&&o.actionLabel)return o.actionLabel;const i=Pe(e.profileId),c=(f=e.executionContext)==null?void 0:f.action_type;return typeof c=="string"&&c?`${i} · ${c}`:`${i} · ${r}`}function n0(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(o=>o.trim()).filter(Boolean).join(", "))}return t.join(" · ")}function r0(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 o=n.replace(/^allowed_/,"").replace(/_/g," ");t.push(`${o} ${a.split(",").map(i=>i.trim()).filter(Boolean).join(", ")}`)}return t.join(" · ")}function s0(e,t){var o,i;const n=[{window:"daily",label:"today"},{window:"monthly",label:"this month"}],r=e.actionType??(typeof((o=e.executionContext)==null?void 0:o.action_type)=="string"?e.executionContext.action_type:void 0),a=[];for(const{window:c,label:l}of n){const d=(i=e.cumulativeState)==null?void 0:i[c];if(!d)continue;const f=`_${c}_max`,p=Object.keys(t??{}).filter(j=>j.endsWith(f)),m=(r&&p.find(j=>j.startsWith(`${r}_`)))??(p.length===1?p[0]:void 0),v=(m?/^(amount|spend)_/.test(m):!1)?d.amount:d.count,x=m?Number(t==null?void 0:t[m]):NaN;m&&Number.isFinite(x)?a.push(`${v} of ${x} ${l}`):a.push(`${d.count} ${d.count===1?"call":"calls"} ${l}`)}return a.join(" · ")}function a0(e){return typeof e.proposalId=="string"&&e.proposalId.length>0}function o0(e){const t=Pe(e),n=e.split("@")[1];return n?`${t}@${n}`:t}function Pr({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 i0({receipt:e,manifests:t,localAuth:n,localUnavailable:r,signature:a,grantTitle:o,ownerLabel:i,spUrl:c,formatDate:l,onOpenComplete:d}){var v;const f=n0(e),p=r0(n==null?void 0:n.context),m=s0(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:t0(e,t)}),s.jsx("span",{className:"receipt-tag",children:a0(e)?"review":"automatic"}),e.contentHash&&s.jsx("span",{className:"receipt-tag receipt-tag-bound",title:(v=e.contentBinding)!=null&&v.fields?`The ticket binds: ${e.contentBinding.fields.join(", ")}`:"This exact content was authorized",children:"content bound"}),s.jsx("span",{className:"auth-card-time",children:l(e.timestamp)})]}),f&&s.jsx("div",{className:"receipt-scope",children:f}),s.jsxs("dl",{className:"receipt-rows",children:[s.jsx(Pr,{label:"mandate",children:s.jsx("strong",{children:o||o0(e.profileId)})}),i&&s.jsx(Pr,{label:"owner",children:i}),p&&s.jsx(Pr,{label:"allowed",children:p}),m&&s.jsx(Pr,{label:"used",children:s.jsx("span",{className:"receipt-num",children:m})}),s.jsx(Pr,{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"}),c&&s.jsxs("span",{className:"receipt-public",children:["redacted, shareable:"," ",s.jsx("a",{className:"receipt-link",href:`${c}/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(([x,j])=>`${x}=${j}`).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 l0({receipt:e,onClose:t}){const[n,r]=u.useState(null),[a,o]=u.useState(null),[i,c]=u.useState(null),[l,d]=u.useState(!0),[f,p]=u.useState(!1);u.useEffect(()=>{let j=!1;return d(!0),I.getArchivedReceipt(e.id).then(g=>{j||(r(g),o(g?"local":"authority-server"),c((g==null?void 0:g.signature)??null))}).catch(()=>{j||o("authority-server")}).finally(()=>{j||d(!1)}),()=>{j=!0}},[e.id]);const m=n?n.entry:{receipt:e},w=JSON.stringify(m,null,2);function v(){const j=URL.createObjectURL(new Blob([w],{type:"application/json"})),g=document.createElement("a");g.href=j,g.download=`suveren-ticket-${e.id.slice(0,8)}.json`,g.click(),URL.revokeObjectURL(j)}async function x(){try{await navigator.clipboard.writeText(w),p(!0),setTimeout(()=>p(!1),2e3)}catch{p(!1)}}return s.jsx("div",{className:"modal-backdrop",onClick:j=>j.target===j.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:[i==="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."}),i==="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:l?"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:v,children:"Download"}),s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:x,children:f?"Copied":"Copy"})]})]})})}function c0(e){return new Date(e*1e3).toLocaleString()}function u0(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 d0(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 Su(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 f0(){const{activeTeam:e,groupId:t}=Oe(),n=(e==null?void 0:e.isAdmin)===!0,[r,a]=u.useState("mine"),[o,i]=u.useState([]),[c,l]=u.useState([]),[d,f]=u.useState(""),[p,m]=u.useState(!0),[w,v]=u.useState({}),[x,j]=u.useState(new Set),[g,h]=u.useState(""),[y,S]=u.useState(new Set),[k,N]=u.useState(new Set),[C,P]=u.useState("all"),[E,z]=u.useState(!1),[U,V]=u.useState(!1),[Q,D]=u.useState(null),[A,B]=u.useState({}),[ne,L]=u.useState(!1),[$,H]=u.useState({}),[R,F]=u.useState({}),[Y,X]=u.useState(null),[te,ue]=u.useState(null),[pe,ee]=u.useState(!1),[ie,se]=u.useState(!1),_=u.useRef(""),J=u.useCallback(b=>r==="team"&&n&&t?I.listTeamReceiptsPage(t,{before:b,limit:200}):I.getMyReceiptsPage({before:b,limit:200}),[r,n,t]),ae=u.useCallback(()=>{const b=r==="team"?`team:${t}`:"mine",O=_.current!==b;_.current=b,m(!0),se(!1),J().then(T=>{i(G=>O?T.receipts:Su(G,T.receipts)),ue(G=>O?T.nextBefore:G??T.nextBefore)}).catch(()=>{O&&i([]),se(!0)}).finally(()=>m(!1))},[J,r,t]),ye=u.useCallback(()=>{!te||pe||(ee(!0),se(!1),J(te).then(b=>{i(O=>Su(O,b.receipts)),ue(b.nextBefore)}).catch(()=>se(!0)).finally(()=>ee(!1)))},[te,pe,J]);Pt(ae,12e4),u.useEffect(()=>{I.getIntegrationManifests().then(({manifests:b})=>l(b)).catch(()=>{}),fetch("/health").then(b=>b.json()).then(b=>{typeof b.spUrl=="string"&&f(b.spUrl.replace(/\/$/,""))}).catch(()=>{})},[]),u.useEffect(()=>{I.getLocalAuthorizations().then(({authorizations:b,signatures:O})=>{B(b),H(O),L(!1)}).catch(()=>{B({}),H({}),L(!0)}),I.getMyAttestations().then(b=>{const O={};for(const T of b)T.authorization_id&&T.title&&(O[T.authorization_id]=T.title);F(O)}).catch(()=>{})},[]),u.useEffect(()=>{r!=="team"||Object.keys(w).length>0||I.listUsers().then(b=>{const O={};for(const T of b)O[T.id]={name:T.name,email:T.email};v(O)}).catch(()=>{})},[r,w]);const ve=u.useMemo(()=>{const b=new Set;for(const O of o)b.add(Pe(O.profileId));return[...b].sort()},[o]),Le=u.useMemo(()=>{const b=new Set;for(const O of o)b.add(O.action);return[...b].sort()},[o]),tt=u.useMemo(()=>{if(r!=="team")return[];const b=new Set;for(const O of o)O.userId&&b.add(O.userId);return[...b].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,o,w]),Be=u.useMemo(()=>o.filter(b=>!(!d0(b,g)||y.size>0&&!y.has(Pe(b.profileId))||k.size>0&&!k.has(b.action)||x.size>0&&b.userId&&!x.has(b.userId)||!u0(b,C))),[o,g,y,k,x,C]),lt=y.size>0||k.size>0||x.size>0||C!=="all";function nt(b){S(O=>{const T=new Set(O);return T.has(b)?T.delete(b):T.add(b),T})}function De(b){N(O=>{const T=new Set(O);return T.has(b)?T.delete(b):T.add(b),T})}function ce(b){j(O=>{const T=new Set(O);return T.has(b)?T.delete(b):T.add(b),T})}function ct(){S(new Set),N(new Set),j(new Set),P("all"),h("")}async function tn(){V(!0),D(null);try{const{bundle:b,filename:O}=await I.fetchEvidenceBundle(),T=URL.createObjectURL(new Blob([JSON.stringify(b,null,2)],{type:"application/json"})),G=document.createElement("a");G.href=T,G.download=O,G.click(),URL.revokeObjectURL(T);const re=b.sources??{};re.authorityServer?re.local||D(`Downloaded Authority Server history only — ${re.localError??"local archive unavailable."}`):D(`Downloaded local evidence only — ${re.asError??"Authority Server export unavailable."}`)}catch(b){D(`Export failed: ${b instanceof Error?b.message:String(b)}`)}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:U,children:U?"Preparing…":"Download evidence"})]}),Q&&s.jsx("div",{style:{marginBottom:"1rem",color:"var(--text-tertiary)",fontSize:"0.875rem"},children:Q}),n&&s.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(b=>s.jsx("button",{onClick:()=>a(b),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===b?"2px solid var(--accent)":"2px solid transparent",color:r===b?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===b?600:500},children:b==="mine"?"Mine":"Team"},b))}),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:b=>h(b.target.value)}),g&&s.jsx("button",{className:"search-clear",onClick:()=>h(""),children:"×"})]}),s.jsxs("button",{className:`btn btn-sm btn-secondary${E?" active":""}`,onClick:()=>z(!E),children:["Filters",lt?` (${y.size+k.size+(C!=="all"?1:0)})`:""]})]}),E&&s.jsxs("div",{className:"filter-panel",children:[ve.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Profile"}),s.jsx("div",{className:"filter-chips",children:ve.map(b=>s.jsx("button",{className:`filter-chip${y.has(b)?" selected":""}`,onClick:()=>nt(b),children:b},b))})]}),Le.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Action"}),s.jsx("div",{className:"filter-chips",children:Le.map(b=>s.jsx("button",{className:`filter-chip${k.has(b)?" selected":""}`,onClick:()=>De(b),children:b},b))})]}),r==="team"&&tt.length>1&&s.jsxs("div",{className:"filter-section",children:[s.jsx("div",{className:"filter-label",children:"Owner"}),s.jsx("div",{className:"filter-chips",children:tt.map(b=>s.jsx("button",{className:`filter-chip${x.has(b.id)?" selected":""}`,onClick:()=>ce(b.id),children:b.label},b.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(([b,O])=>s.jsx("button",{className:`filter-chip${C===b?" selected":""}`,onClick:()=>P(b),children:O},b))})]})]}),lt&&s.jsxs("div",{className:"active-filters",children:[[...y].map(b=>s.jsxs("span",{className:"active-chip",onClick:()=>nt(b),children:[b," ",s.jsx("span",{className:"chip-remove",children:"×"})]},b)),[...k].map(b=>s.jsxs("span",{className:"active-chip",onClick:()=>De(b),children:[b," ",s.jsx("span",{className:"chip-remove",children:"×"})]},b)),[...x].map(b=>{const O=w[b],T=O?O.name:b;return s.jsxs("span",{className:"active-chip",onClick:()=>ce(b),children:[T," ",s.jsx("span",{className:"chip-remove",children:"×"})]},b)}),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"})]}),ie&&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."})}),p&&o.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):Be.length===0?s.jsx(Pm,{icon:"⌕",title:o.length===0?"No tickets in the last 30 days":"No matching tickets",text:o.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:Be.length===o.length?`${o.length} ticket${o.length!==1?"s":""}`:`${Be.length} of ${o.length} tickets`}),s.jsx("div",{className:"timeline",children:Be.map(b=>{const O=b.userId?w[b.userId]:void 0;return s.jsx("div",{className:"timeline-event",children:s.jsx(i0,{receipt:b,manifests:c,localAuth:b.authorizationId?A[b.authorizationId]:void 0,localUnavailable:ne,signature:$[b.id],grantTitle:b.authorizationId?R[b.authorizationId]:null,ownerLabel:r==="team"&&b.userId?O?`${O.name} (${O.email})`:b.userId:null,spUrl:d,formatDate:c0,onOpenComplete:()=>X(b)})},b.id)})})]}),Y&&s.jsx(l0,{receipt:Y,onClose:()=>X(null)}),te&&s.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:s.jsx("button",{className:"btn btn-secondary btn-sm",onClick:ye,disabled:pe,children:pe?"Loading…":"Load older"})})]})}const m0={darwin:"a macOS login item",win32:"a Windows scheduled task",linux:"a systemd user service"};function p0(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,o]=u.useState(null),i=u.useCallback(async()=>{try{t(await I.getAutostart())}catch(d){o(d instanceof Error?d.message:"Could not read autostart state")}},[]);u.useEffect(()=>{i()},[i]);const c=u.useCallback(async()=>{if(!(!(e!=null&&e.supported)||n)){r(!0),o(null);try{await I.setAutostart(!e.installed)}catch(d){o(d instanceof Error?d.message:"Failed")}finally{try{t(await I.getAutostart()),o(null)}catch(d){o(d instanceof Error?d.message:"Could not re-read state")}r(!1)}}},[e,n,i]);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 l=m0[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 ",l," — no admin rights needed."]}):e.reason})]}),e.supported&&s.jsx("button",{type:"button",onClick:()=>void c(),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 h0(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,o]=u.useState(null),i=u.useCallback(async()=>{try{const l=await I.getGatewaySettings();t(l.desktopNotifications),o(null)}catch(l){o(l instanceof Error?l.message:"Could not read notification setting")}},[]);u.useEffect(()=>{i()},[i]);const c=u.useCallback(async()=>{if(!(e===null||n)){r(!0),o(null);try{const l=await I.setGatewaySettings({desktopNotifications:!e});t(l.desktopNotifications)}catch(l){o(l instanceof Error?l.message:"Failed to save"),await i()}finally{r(!1)}}},[e,n,i]);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 c(),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 g0={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 y0(){const{version:e,latestVersion:t,updateAvailable:n,installMethod:r}=Bl();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:[g0[r]??"Update checking is unavailable",r==="dev"&&s.jsx(s.Fragment,{children:" — a development checkout is not told about published releases."})]})]}):null}function Li({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 ju(e){return e===!0}function v0(){const[e,t]=u.useState(null),[n,r]=u.useState(null);u.useEffect(()=>{let i=!1;return I.getAsPairing().then(c=>{i||t(c)}).catch(c=>{i||r(c instanceof Error?c.message:"Could not read Authority Server info")}),()=>{i=!0}},[]);const a=ju(e==null?void 0:e.asUrlLockedByPolicy),o=ju(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(Li,{})]}),!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:"})," ",o&&s.jsx(Li,{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",o?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",o?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 x0(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 w0(){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(x0(r))}).catch(()=>{}),()=>{n=!0}},[]),e}function S0(){const{simulation:e,locked:t}=w0();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(Li,{})]}),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 j0={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"]}},_r=["AI Assistant","Authority Server","This computer","Security","Version"],Ar={fontSize:"1rem",fontWeight:700,marginBottom:"1rem"};function k0(){const[e,t]=u.useState(""),[n,r]=u.useState("openrouter"),[a,o]=u.useState("openai-compatible"),[i,c]=u.useState("https://openrouter.ai/api/v1"),[l,d]=u.useState("google/gemma-4-31b-it"),[f,p]=u.useState(""),[m,w]=u.useState(!1),[v,x]=u.useState(!1),[j,g]=u.useState(!1),[h,y]=u.useState(null),[S,k]=u.useState([]),[N,C]=u.useState(!1),[P,E]=u.useState(null),[z,U]=u.useState(""),V=u.useCallback($=>{t($),setTimeout(()=>t(""),3e3)},[]),Q=u.useCallback(async($,H,R)=>{C(!0),E(null);try{const F=await I.aiModels({provider:$,endpoint:H,...R?{apiKey:R}:{}});F.ok&&F.models.length>0?(k(F.models),E(`${F.models.length} models available`)):(k([]),E(F.message||"No models returned — using defaults"))}catch(F){k([]),E(F instanceof Error?F.message:"Failed to load models")}finally{C(!1)}},[]),D=u.useCallback(async()=>{try{const $=await I.getCredential("ai-config");if(w($.configured),$.configured&&$.fields){const H=$.fields.provider||"openai-compatible",R=$.fields.endpoint||"";$.fields.provider&&o(H),$.fields.endpoint&&c(R),$.fields.model&&d($.fields.model),R.includes("openai.com")?r("openai"):R.includes("groq.com")?r("groq"):R.includes("together.xyz")?r("together"):R.includes("openrouter.ai")?r("openrouter"):r("ollama"),R&&Q(H,R)}}catch{}},[Q]);u.useEffect(()=>{D()},[D]);const A=$=>{r($),k([]),E(null),U("");const H=j0[$];H&&(o(H.provider),c(H.endpoint),d(""),Q(H.provider,H.endpoint,f||void 0))},B=()=>Q(a,i,f||void 0),ne=async()=>{x(!0);try{await I.setCredential("ai-config",{provider:a,endpoint:i,model:l,...f?{apiKey:f}:{}}),w(!0),V("AI configuration saved!")}catch{V("Failed to save AI config")}finally{x(!1)}},L=async()=>{g(!0),y(null);try{const $=await I.aiTest({provider:a,endpoint:i,model:l,...f?{apiKey:f}:{}});y($.ok?`OK: ${$.message}`:`Failed: ${$.message}`)}catch($){y(`Error: ${$ instanceof Error?$.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:Ar,children:_r[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."}),m&&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($.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:$=>p($.target.value),onBlur:()=>{f.trim()&&Q(a,i,f.trim())},placeholder:m?"••••••••••••••••":"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:B,disabled:N,title:"Re-fetch the model list from the provider",children:N?"Loading…":"↻ Refresh"})]}),S.length===0?s.jsx("div",{className:"form-input",style:{display:"flex",alignItems:"center",minHeight:"2.5rem",color:"var(--text-secondary)",fontSize:"0.85rem"},children:N?"Loading models…":a==="ollama"?"Start Ollama locally, then ↻ Refresh to load models.":"Enter a valid API key above to load available models."}):(()=>{const $=S,H=$.includes(l),R=$.length>12,F=z.trim().toLowerCase();let Y=F?$.filter(X=>X.toLowerCase().includes(F)):$;return H&&!Y.includes(l)&&(Y=[l,...Y]),s.jsxs(s.Fragment,{children:[R&&s.jsx("input",{className:"form-input",value:z,onChange:X=>U(X.target.value),placeholder:"Filter models… (e.g. kimi)",style:{marginBottom:"0.375rem"}}),s.jsxs("select",{className:"form-input",value:H?l:"__unset__",onChange:X=>d(X.target.value==="__unset__"?"":X.target.value),children:[s.jsx("option",{value:"__unset__",disabled:!0,children:"Select a model…"}),Y.map(X=>s.jsx("option",{value:X,children:X},X)),F&&Y.length===0&&s.jsxs("option",{value:"__unset__",disabled:!0,children:["No models match “",z,"”"]})]})]})})(),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:ne,disabled:v||!l.trim(),title:l.trim()?void 0:"Select a model first",children:v?"Saving...":"Save & Encrypt"}),m&&s.jsx("button",{className:"btn btn-ghost",onClick:L,disabled:j,children:j?"Testing...":"Test Connection"})]}),h&&s.jsx("div",{className:`alert ${h.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:h})]}),s.jsx(b0,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Ar,children:_r[1]}),s.jsx(v0,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Ar,children:_r[2]}),s.jsx(p0,{}),s.jsx(h0,{}),s.jsx(S0,{})]}),s.jsxs("section",{style:{marginBottom:"2rem"},children:[s.jsx("h2",{style:Ar,children:_r[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:Ar,children:_r[4]}),s.jsx(y0,{})]})]})}function b0(){const[e,t]=u.useState(null),[n,r]=u.useState({intent:"",context:""}),[a,o]=u.useState(null),[i,c]=u.useState(null),[l,d]=u.useState(null),[f,p]=u.useState(!1),m=u.useCallback(async()=>{if(!f)try{const x=await I.getAIPrompts();t(x),r({intent:x.intent.current,context:x.context.current}),p(!0)}catch(x){c(x instanceof Error?x.message:"Failed to load prompts")}},[f]),w=async x=>{if(e){o(x),c(null);try{const j=n[x],g=j.trim()===e[x].default.trim()?"":j;await I.setAIPrompt(x,g);const h=await I.getAIPrompts();t(h),r({intent:h.intent.current,context:h.context.current}),d(x),setTimeout(()=>d(null),2e3)}catch(j){c(j instanceof Error?j.message:"Save failed")}finally{o(null)}}},v=async x=>{if(confirm(`Revert ${x} prompt to the built-in default?`)){o(x),c(null);try{await I.setAIPrompt(x,"");const j=await I.getAIPrompts();t(j),r({intent:j.intent.current,context:j.context.current})}catch(j){c(j instanceof Error?j.message:"Revert failed")}finally{o(null)}}};return s.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:x=>{x.currentTarget.open&&m()},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."}),i&&s.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:i}),!f&&!i&&s.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&s.jsxs(s.Fragment,{children:[s.jsx(ku,{kind:"intent",label:"Intent — per-mandate",description:"Used on the Intent gate when creating a new mandate.",state:e.intent,draft:n.intent,onChange:x=>r(j=>({...j,intent:x})),onSave:()=>w("intent"),onRevert:()=>v("intent"),saving:a==="intent",justSaved:l==="intent"}),s.jsx(ku,{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:x=>r(j=>({...j,context:x})),onSave:()=>w("context"),onRevert:()=>v("context"),saving:a==="context",justSaved:l==="context"})]})]})}function ku({kind:e,label:t,description:n,state:r,draft:a,onChange:o,onSave:i,onRevert:c,saving:l,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:p=>o(p.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:i,disabled:l||!f,children:l?"Saving…":"Save"}),r.overridden&&s.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:c,disabled:l,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&&!l&&!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 C0(e){return e.proposalId?"review":"automatic"}function bu(e,t,n={}){const r=n.status??"pending",a=n.includeAutonomous??!1,o=[];for(const i of e)r==="pending"&&i.status!=="pending"||n.profile&&i.profileId!==n.profile||o.push({kind:"proposal",id:i.id,sortTimestamp:i.createdAt,commitmentMode:"review",profileId:i.profileId,proposal:i});if(r==="all")for(const i of t){const c=C0(i);!a&&c==="automatic"||n.profile&&i.profileId!==n.profile||o.push({kind:"receipt",id:i.id,sortTimestamp:i.timestamp,commitmentMode:c,profileId:i.profileId,receipt:i})}return o.sort((i,c)=>c.sortTimestamp-i.sortTimestamp),typeof n.limit=="number"&&n.limit>0?o.slice(0,n.limit):o}const N0=["https://","http://"];function _m(e,t){return e!=null&&e.length?e.flatMap(n=>{const r=n.template.replace(/\{(\w+)\}/g,(a,o)=>{const i=t[o];return typeof i=="string"||typeof i=="number"?String(i):"\0"});return r.includes("\0")||/\{|\}/.test(r)?[]:N0.some(a=>r.toLowerCase().startsWith(a))?[{label:n.label,href:r,description:n.description}]:[]}):[]}function E0({profileId:e}){return s.jsx("span",{className:"profile-badge",children:Pe(e)})}function Am(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),o=Math.floor(n%3600/60);let i;return r>0?i=`expires in ${r}d ${a}h`:a>0?i=`expires in ${a}h ${o}m`:i=`expires in ${Math.max(1,o)}m`,{label:i,urgent:n<2*3600,expired:!1}}const T0={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},I0={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function R0(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 P0(e){return e.split("__").pop()??e}function _0(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}const A0=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]),z0=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function $0(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:z0.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function Mi(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=>Mi(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Cu({item:e,onApprove:t,onReject:n,resolving:r,proposalLinks:a}){const o=e.kind==="proposal",i=o?e.proposal.status:"executed",c=o?e.proposal.tool:e.receipt.action,l=P0(c),d=_0(c),f=o?e.proposal.toolArgs:null,p=o?e.proposal.executionContext:e.receipt.executionContext,m=o?null:e.receipt.cumulativeState,w=o?_m(a,e.proposal.toolArgs):[],v=f?Object.entries(f).filter(([j])=>!A0.has(j)):[],x=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(E0,{profileId:e.profileId}),s.jsx("code",{style:{fontSize:"0.85rem"},children:l}),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&&i==="pending"&&(()=>{const j=Am(e.proposal.expiresAt,Date.now());return s.jsx("span",{style:{fontSize:"0.72rem",color:j.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:j.urgent?600:400,whiteSpace:"nowrap"},children:j.label})})(),s.jsx("span",{className:`status-badge ${I0[i]}`,children:T0[i]}),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:R0(e.sortTimestamp)})]})]}),d&&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(f==null?void 0:f._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:f._imagePreview,alt:typeof(f==null?void 0:f.altText)=="string"?f.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),w.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:w.map(j=>s.jsxs("a",{href:j.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:j.description??j.href,children:[j.label," ↗"]},j.label))}),o&&v.length>0&&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:"Arguments"}),s.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:v.map(([j,g])=>s.jsxs(u.Fragment,{children:[s.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:j}),s.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:$0(j,g)?s.jsx("img",{src:g,alt:typeof(f==null?void 0:f.altText)=="string"?f.altText:j,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"},onError:h=>{const y=h.currentTarget,S=y.parentElement;if(!S)return;y.style.display="none";const k=document.createElement("span");k.textContent=g,k.style.color="var(--text-tertiary)",S.appendChild(k)}}):Mi(g)})]},j))})]}),x.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:x.map(([j,g])=>`${j}=${Mi(g)}`).join(" · ")}),m&&s.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",m.daily.count," action",m.daily.count===1?"":"s",m.daily.amount>0?`, ${m.daily.amount}`:""," · ","this month: ",m.monthly.count,m.monthly.amount>0?`, ${m.monthly.amount}`:""]}),o&&i==="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]})]})}const L0=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function Fi(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=>Fi(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function M0(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 F0({proposal:e,currentUserId:t,onAction:n,onMessage:r,proposalLinks:a}){const[o,i]=u.useState(!1),[c,l]=u.useState(!1),[d,f]=u.useState(null),[p,m]=u.useState(!1),[w,v]=u.useState(null),[x,j]=u.useState(!1),g=e.tool.split("__").pop()??e.tool,h=Object.entries(e.toolArgs).filter(([A])=>!L0.has(A)),y=Object.entries(e.executionContext),S=_m(a,e.toolArgs),k=e.pendingApprovers??[],N=e.approvedBy??{},C=Object.keys(N).length,P=k.filter(A=>!(A in N)).length,E=t in N,z=async()=>{if(d===null){m(!0),v(null);try{const A=await I.getAttestationIntent(e.authorizationId);if(!A){v("Intent not available or you are not an authorized approver.");return}const B=await I.decryptIntent({intentCiphertext:A.intentCiphertext,encryptedKey:A.encryptedKey,approverId:t});f(B)}catch(A){v(A instanceof Error?A.message:"Failed to decrypt intent")}finally{m(!1)}}},U=async()=>{x?j(!1):(j(!0),await z())},V=async()=>{i(!0),r("");try{await I.approveProposal(e.id);try{if(d===null){const A=await I.getAttestationIntent(e.authorizationId);if(A){const B=await I.decryptIntent({intentCiphertext:A.intentCiphertext,encryptedKey:A.encryptedKey,approverId:t});f(B),await I.storeApprovedIntent(e.authorizationId,B)}}else await I.storeApprovedIntent(e.authorizationId,d)}catch{}r(`Approved. ${P-1>0?`${P-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(A){r(A instanceof Error?A.message:"Approval failed")}finally{i(!1)}},Q=async()=>{const A=prompt("Rejection reason (optional):");if(A!==null){l(!0),r("");try{await I.rejectProposal(e.id,A||void 0),r("Action rejected."),n()}catch(B){r(B instanceof Error?B.message:"Rejection failed")}finally{l(!1)}}},D=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 A=Am(e.expiresAt,Date.now());return s.jsx("span",{style:{fontSize:"0.72rem",color:A.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:A.urgent?600:400,whiteSpace:"nowrap"},children:A.label})})(),s.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:M0(e.createdAt)})]})]}),s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[C," of ",k.length," approver",k.length===1?"":"s"," signed off",k.map(A=>{const B=A in N;return s.jsxs("span",{style:{marginLeft:"0.5rem",color:B?"var(--success, green)":"var(--text-tertiary)"},children:[B?"✓":"○"," ",A===t?"You":A]},A)})]}),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:g})]}),S.length>0&&s.jsx("div",{style:{marginBottom:"0.75rem",display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:S.map(A=>s.jsxs("a",{href:A.href,target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-sm",style:{textDecoration:"none"},title:A.description??A.href,children:[A.label," ↗"]},A.label))}),h.length>0&&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.25rem"},children:"Arguments"}),s.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:h.map(([A,B])=>s.jsxs(u.Fragment,{children:[s.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:A}),s.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:Fi(B)})]},A))})]}),y.length>0&&s.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:y.map(([A,B])=>`${A}=${Fi(B)}`).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:U,disabled:p,children:[x?"▲ Hide intent":"▼ Show intent",p&&" (decrypting...)"]}),x&&s.jsx("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-main)",borderRadius:"0.375rem",border:"1px solid var(--border)"},children:w?s.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:w}):d!==null?s.jsx("p",{style:{fontSize:"0.85rem",margin:0,whiteSpace:"pre-wrap",color:"var(--text-primary)"},children:d}):s.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this mandate."})})]}),!E&&s.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[s.jsx("button",{className:"btn btn-primary",onClick:V,disabled:D,children:o?"Approving...":"Approve"}),s.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:Q,disabled:D,children:c?"Rejecting...":"Reject"})]}),E&&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 O0(){const{domain:e,user:t}=Oe(),n=(t==null?void 0:t.id)??"",[r,a]=u.useState("awaiting-me"),[o,i]=u.useState([]),[c,l]=u.useState([]),[d,f]=u.useState(!0),[p,m]=u.useState(""),w=u.useCallback(async()=>{try{const _=await I.getProposalsForApprover();i(_)}catch{}finally{f(!1)}},[]);me("proposal-added",w),me("proposal-approved",w),me("proposal-rejected",w),me("proposal-resolved",w),Pt(w,3e4);const[v,x]=u.useState([]),j=u.useCallback(async()=>{try{const _=await I.getProposals(e||"owner");x(_)}catch{}},[e]);me("proposal-added",j),me("proposal-approved",j),me("proposal-rejected",j),me("proposal-resolved",j),Pt(j,3e4,e);const g=u.useMemo(()=>v.filter(_=>{var J;return _.status==="pending"&&(((J=_.pendingApprovers)==null?void 0:J.length)??0)===0}),[v]),h=u.useMemo(()=>bu(g,[],{status:"pending"}),[g]),[y,S]=u.useState([]),k=u.useCallback(async()=>{if(n)try{const J=(await I.getProposals(e||"owner")).filter(ae=>ae.status==="pending"&&ae.pendingApprovers&&ae.pendingApprovers.includes(n)&&ae.approvedBy&&n in ae.approvedBy);S(J)}catch{}},[n,e]);me("proposal-approved",k),me("proposal-rejected",k),Pt(k,3e4,`${n}:${e}`),u.useEffect(()=>{I.getIntegrationManifests().then(_=>l(_.manifests??[])).catch(()=>{})},[]);const N=_=>{var J;return(J=c.find(ae=>ae.id===_.split("__")[0]))==null?void 0:J.proposalLinks};u.useEffect(()=>{w(),j(),k()},[]);const[C,P]=u.useState([]),[E,z]=u.useState([]),[U,V]=u.useState(!0),[Q,D]=u.useState(null),[A,B]=u.useState(""),[ne,L]=u.useState("pending"),[$,H]=u.useState(null),[R,F]=u.useState(!1),Y=u.useCallback(async()=>{try{const{proposals:_,receipts:J}=await I.getThread({domain:e,status:ne,sinceDays:7});P(_),z(J)}catch{}finally{V(!1)}},[e,ne]);Pt(Y,3e4,`${e}:${ne}`);const X=async(_,J)=>{D(_),B("");try{const ae=e||"owner",ye=await I.resolveProposal(_,J,ae);B(J==="commit"?`Action approved. Status: ${ye.status}`:"Action rejected."),await Promise.all([Y(),j()])}catch(ae){B(ae instanceof Error?ae.message:"Failed")}finally{D(null)}},te=u.useMemo(()=>{const _=new Set;for(const J of C)_.add(J.profileId);for(const J of E)_.add(J.profileId);return Array.from(_).sort()},[C,E]),ue=u.useMemo(()=>bu(C,E,{status:ne,profile:$??void 0,includeAutonomous:R}),[C,E,ne,$,R]),pe=u.useCallback(()=>{w(),k()},[w,k]),ee=u.useMemo(()=>{const _=new Set,J=[];for(const ae of y)_.has(ae.id)||(_.add(ae.id),J.push(ae));return J.sort((ae,ye)=>ye.createdAt-ae.createdAt)},[y]),ie=o.length+h.length,se=ee.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 ",ie>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:ie})]}),s.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>a("awaiting-others"),children:["Awaiting others ",se>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:se})]}),s.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{a("all"),Y()},children:"All"})]}),r==="awaiting-me"&&s.jsx(s.Fragment,{children:d&&ie===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ie===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:[(p||A)&&s.jsx("div",{className:"alert alert-success",children:p||A}),h.map(_=>s.jsx(Cu,{proposalLinks:_.kind==="proposal"?N(_.proposal.tool):void 0,item:_,onApprove:J=>X(J,"commit"),onReject:J=>X(J,"reject"),resolving:Q===_.id},_.id)),o.map(_=>s.jsx(F0,{proposal:_,currentUserId:n,onAction:pe,onMessage:m,proposalLinks:N(_.tool)},_.id))]})}),r==="awaiting-others"&&s.jsx(s.Fragment,{children:ee.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:ee.map(_=>s.jsx(D0,{proposal:_,currentUserId:n,onCancel:async()=>{try{await I.rejectProposal(_.id,"cancelled by creator"),k(),j()}catch(J){alert(J instanceof Error?J.message:"Cancel failed")}}},_.id))})}),r==="all"&&s.jsxs(s.Fragment,{children:[A&&s.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:A}),s.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[s.jsx("button",{className:`filter-chip ${ne==="pending"?"selected":""}`,onClick:()=>L("pending"),children:"Pending"}),s.jsx("button",{className:`filter-chip ${ne==="all"?"selected":""}`,onClick:()=>L("all"),children:"All"}),te.length>0&&s.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),te.map(_=>s.jsx("button",{className:`filter-chip ${$===_?"selected":""}`,onClick:()=>H($===_?null:_),children:Pe(_)},_)),ne==="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 ${R?"selected":""}`,onClick:()=>F(!R),title:"Include actions executed without human review (automatic commitment mode)",children:[R?"✓ ":"","Autonomous actions"]})]})]}),U&&ue.length===0?s.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):ue.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:ne==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),s.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:ne==="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:ue.map(_=>s.jsx(Cu,{proposalLinks:_.kind==="proposal"?N(_.proposal.tool):void 0,item:_,onApprove:J=>X(J,"commit"),onReject:J=>X(J,"reject"),resolving:Q===_.id},_.id))})]})]})}function B0(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 D0({proposal:e,currentUserId:t,onCancel:n}){var d;const[r,a]=u.useState(!1),o=Object.keys(e.approvedBy??{}),i=(e.pendingApprovers??[]).filter(f=>!(f in(e.approvedBy??{}))),c=(((d=e.pendingApprovers)==null?void 0:d.length)??0)>0,l=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)}),c&&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:B0(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})}),c&&s.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[o.map(f=>s.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:f===t?"You approved":`${f} approved`},f)),i.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:l,disabled:r,children:r?"Cancelling...":"Cancel"})})]})}const U0=`# Agent Brief
|
|
75
|
+
|
|
76
|
+
You act on my behalf through Suveren — the gateway that gates every
|
|
77
|
+
privileged tool call you make. Suveren implements the bounded-authority
|
|
78
|
+
model from the open Human Agency Protocol (HAP): each mandate
|
|
79
|
+
describes an area of authority, a set of numeric limits, and a scope.
|
|
80
|
+
Operate inside those bounds or the Gatekeeper will reject your action.
|
|
81
|
+
|
|
82
|
+
## Before you act in a domain
|
|
83
|
+
|
|
84
|
+
1. Call \`list-authorizations(domain: "<domain>")\` to load the full
|
|
85
|
+
intent, scope, and usage for that area. The session brief shows only
|
|
86
|
+
a one-line summary per mandate — the Intent paragraph lives behind
|
|
87
|
+
that call, and often contains soft rules you MUST honor (e.g. "never
|
|
88
|
+
publish on weekends", "only reply in English").
|
|
89
|
+
2. If the action would exceed a bound or fall outside the scope, stop
|
|
90
|
+
and explain what would be blocked instead of trying.
|
|
91
|
+
3. If you're not sure whether an action is covered, ask me first.
|
|
92
|
+
|
|
93
|
+
## How to handle reviews
|
|
94
|
+
|
|
95
|
+
Mandates in review mode require my approval before the action
|
|
96
|
+
executes. When you propose an action:
|
|
97
|
+
- Include everything I need to judge it (title, recipients, amounts,
|
|
98
|
+
dates, attendees) in the tool arguments.
|
|
99
|
+
- Don't batch unrelated proposals — one proposal per decision.
|
|
100
|
+
|
|
101
|
+
## Standing orders
|
|
102
|
+
|
|
103
|
+
(Add your own here. Examples:)
|
|
104
|
+
|
|
105
|
+
- Every morning, summarize today's calendar and flag conflicts.
|
|
106
|
+
- On Fridays, give me a weekly review: what's done, what slipped, what's
|
|
107
|
+
next.
|
|
108
|
+
- Never email anyone outside the company without asking first.
|
|
109
|
+
- When drafting posts, prefer plain language over marketing copy.
|
|
110
|
+
`;function W0(){const[e,t]=u.useState(""),[n,r]=u.useState(""),[a,o]=u.useState(!0),[i,c]=u.useState(!1),[l,d]=u.useState(null),[f,p]=u.useState(!1),m=e!==n,w=new Blob([e]).size,v=16*1024;u.useEffect(()=>{if(!m)return;const h=S=>{S.preventDefault(),S.returnValue=""},y=S=>{var C,P;if(S.defaultPrevented||S.button!==0||S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const k=(P=(C=S.target)==null?void 0:C.closest)==null?void 0:P.call(C,"a");if(!k||!k.href)return;let N;try{N=new URL(k.href)}catch{return}N.origin===window.location.origin&&N.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(S.preventDefault(),S.stopPropagation()))};return window.addEventListener("beforeunload",h),document.addEventListener("click",y,!0),()=>{window.removeEventListener("beforeunload",h),document.removeEventListener("click",y,!0)}},[m]),u.useEffect(()=>{let h=!1;return I.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||o(!1)}),()=>{h=!0}},[]);const x=async()=>{c(!0),d(null);try{await I.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{c(!1)}},j=()=>{t(n),d(null)},g=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(U0)};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:i,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),l&&s.jsx("div",{className:l.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:l.text}),s.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[s.jsx("div",{className:"card intent-pane chat",children:s.jsx(_a,{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>v?"var(--danger)":"var(--text-muted)"},children:[w.toLocaleString()," / ",v.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:j,disabled:i||!m,children:"Revert"}),s.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:x,disabled:i||!m||w>v||a,children:i?"Saving…":"Save"})]})]}),s.jsx("button",{type:"button",className:"floating-help",onClick:()=>p(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),s.jsx(km,{open:f,onClose:()=>p(!1),ariaLabel:"Brief assistant",children:s.jsx(_a,{target:{kind:"context"},currentText:e,onApply:h=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(h),p(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Wn({to:e}){const{search:t,hash:n}=yt();return s.jsx(Ht,{to:`${e}${t}${n}`,replace:!0})}function H0({children:e}){const{user:t,mode:n,domain:r}=Oe();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 V0(){const{user:e,handleSessionLocked:t}=Oe();return me("session-locked",n=>{const r=n==null?void 0:n.message;t(r)}),s.jsxs(cy,{children:[s.jsx(je,{path:"/login",element:e?s.jsx(Ht,{to:"/",replace:!0}):s.jsx(Rv,{})}),s.jsx(je,{path:"/onboarding",element:e?s.jsx(Pv,{}):s.jsx(Ht,{to:"/login",replace:!0})}),s.jsxs(je,{element:s.jsx(H0,{children:s.jsx(Iv,{})}),children:[s.jsx(je,{path:"/",element:s.jsx(Yv,{})}),s.jsx(je,{path:"/mandates",element:s.jsx(Zx,{})}),s.jsx(je,{path:"/mandates/new/intent",element:s.jsx(wx,{})}),s.jsx(je,{path:"/mandates/new/sign",element:s.jsx(Rx,{})}),s.jsx(je,{path:"/integrations",element:s.jsx(Mx,{})}),s.jsx(je,{path:"/team",element:s.jsx(Fx,{})}),s.jsx(je,{path:"/tickets",element:s.jsx(f0,{})}),s.jsx(je,{path:"/approvals",element:s.jsx(O0,{})}),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(Wn,{to:"/mandates/new/intent"})}),s.jsx(je,{path:"/agent/review",element:s.jsx(Wn,{to:"/mandates/new/sign"})}),s.jsx(je,{path:"/authorizations",element:s.jsx(Wn,{to:"/mandates"})}),s.jsx(je,{path:"/groups",element:s.jsx(Wn,{to:"/team"})}),s.jsx(je,{path:"/audit",element:s.jsx(Wn,{to:"/tickets"})}),s.jsx(je,{path:"/proposals",element:s.jsx(Wn,{to:"/approvals"})}),s.jsx(je,{path:"/agent-brief",element:s.jsx(W0,{})}),s.jsx(je,{path:"/settings",element:s.jsx(k0,{})}),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 G0(){return s.jsx(zy,{children:s.jsx(Hy,{children:s.jsx(Vy,{children:s.jsx(V0,{})})})})}Bf(document.getElementById("root")).render(s.jsx(u.StrictMode,{children:s.jsx(G0,{})}));
|