@abstractframework/observer 0.1.5 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -6
- package/bin/cli.js +18 -2
- package/dist/assets/index-BaIjLQ02.css +1 -0
- package/dist/assets/index-Bp9AQ5i5.js +143 -0
- package/dist/assets/index-Bp9AQ5i5.js.map +1 -0
- package/dist/index.html +2 -2
- package/package.json +3 -3
- package/dist/assets/index-CAHIX5pe.css +0 -1
- package/dist/assets/index-bs9O5NZX.js +0 -143
- package/dist/assets/index-bs9O5NZX.js.map +0 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
var $x=Object.defineProperty;var Ax=(e,t,r)=>t in e?$x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var vu=(e,t,r)=>Ax(e,typeof t!="symbol"?t+"":t,r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))o(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&o(c)}).observe(document,{childList:!0,subtree:!0});function r(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(l){if(l.ep)return;l.ep=!0;const u=r(l);fetch(l.href,u)}})();function th(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vf={exports:{}},wu={},qf={exports:{}},wn={};/**
|
|
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 pp;function Tx(){if(pp)return wn;pp=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),_=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),x=Symbol.iterator;function v(N){return N===null||typeof N!="object"?null:(N=x&&N[x]||N["@@iterator"],typeof N=="function"?N:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,S={};function T(N,B,Z){this.props=N,this.context=B,this.refs=S,this.updater=Z||b}T.prototype.isReactComponent={},T.prototype.setState=function(N,B){if(typeof N!="object"&&typeof N!="function"&&N!=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,N,B,"setState")},T.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function M(){}M.prototype=T.prototype;function D(N,B,Z){this.props=N,this.context=B,this.refs=S,this.updater=Z||b}var L=D.prototype=new M;L.constructor=D,j(L,T.prototype),L.isPureReactComponent=!0;var I=Array.isArray,G=Object.prototype.hasOwnProperty,ne={current:null},Y={key:!0,ref:!0,__self:!0,__source:!0};function oe(N,B,Z){var te,he={},Ae=null,se=null;if(B!=null)for(te in B.ref!==void 0&&(se=B.ref),B.key!==void 0&&(Ae=""+B.key),B)G.call(B,te)&&!Y.hasOwnProperty(te)&&(he[te]=B[te]);var ve=arguments.length-2;if(ve===1)he.children=Z;else if(1<ve){for(var Re=Array(ve),Qe=0;Qe<ve;Qe++)Re[Qe]=arguments[Qe+2];he.children=Re}if(N&&N.defaultProps)for(te in ve=N.defaultProps,ve)he[te]===void 0&&(he[te]=ve[te]);return{$$typeof:e,type:N,key:Ae,ref:se,props:he,_owner:ne.current}}function le(N,B){return{$$typeof:e,type:N.type,key:B,ref:N.ref,props:N.props,_owner:N._owner}}function _e(N){return typeof N=="object"&&N!==null&&N.$$typeof===e}function Te(N){var B={"=":"=0",":":"=2"};return"$"+N.replace(/[=:]/g,function(Z){return B[Z]})}var $e=/\/+/g;function K(N,B){return typeof N=="object"&&N!==null&&N.key!=null?Te(""+N.key):B.toString(36)}function U(N,B,Z,te,he){var Ae=typeof N;(Ae==="undefined"||Ae==="boolean")&&(N=null);var se=!1;if(N===null)se=!0;else switch(Ae){case"string":case"number":se=!0;break;case"object":switch(N.$$typeof){case e:case t:se=!0}}if(se)return se=N,he=he(se),N=te===""?"."+K(se,0):te,I(he)?(Z="",N!=null&&(Z=N.replace($e,"$&/")+"/"),U(he,B,Z,"",function(Qe){return Qe})):he!=null&&(_e(he)&&(he=le(he,Z+(!he.key||se&&se.key===he.key?"":(""+he.key).replace($e,"$&/")+"/")+N)),B.push(he)),1;if(se=0,te=te===""?".":te+":",I(N))for(var ve=0;ve<N.length;ve++){Ae=N[ve];var Re=te+K(Ae,ve);se+=U(Ae,B,Z,Re,he)}else if(Re=v(N),typeof Re=="function")for(N=Re.call(N),ve=0;!(Ae=N.next()).done;)Ae=Ae.value,Re=te+K(Ae,ve++),se+=U(Ae,B,Z,Re,he);else if(Ae==="object")throw B=String(N),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(N).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.");return se}function X(N,B,Z){if(N==null)return N;var te=[],he=0;return U(N,te,"","",function(Ae){return B.call(Z,Ae,he++)}),te}function V(N){if(N._status===-1){var B=N._result;B=B(),B.then(function(Z){(N._status===0||N._status===-1)&&(N._status=1,N._result=Z)},function(Z){(N._status===0||N._status===-1)&&(N._status=2,N._result=Z)}),N._status===-1&&(N._status=0,N._result=B)}if(N._status===1)return N._result.default;throw N._result}var J={current:null},k={transition:null},z={ReactCurrentDispatcher:J,ReactCurrentBatchConfig:k,ReactCurrentOwner:ne};function F(){throw Error("act(...) is not supported in production builds of React.")}return wn.Children={map:X,forEach:function(N,B,Z){X(N,function(){B.apply(this,arguments)},Z)},count:function(N){var B=0;return X(N,function(){B++}),B},toArray:function(N){return X(N,function(B){return B})||[]},only:function(N){if(!_e(N))throw Error("React.Children.only expected to receive a single React element child.");return N}},wn.Component=T,wn.Fragment=r,wn.Profiler=l,wn.PureComponent=D,wn.StrictMode=o,wn.Suspense=h,wn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=z,wn.act=F,wn.cloneElement=function(N,B,Z){if(N==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+N+".");var te=j({},N.props),he=N.key,Ae=N.ref,se=N._owner;if(B!=null){if(B.ref!==void 0&&(Ae=B.ref,se=ne.current),B.key!==void 0&&(he=""+B.key),N.type&&N.type.defaultProps)var ve=N.type.defaultProps;for(Re in B)G.call(B,Re)&&!Y.hasOwnProperty(Re)&&(te[Re]=B[Re]===void 0&&ve!==void 0?ve[Re]:B[Re])}var Re=arguments.length-2;if(Re===1)te.children=Z;else if(1<Re){ve=Array(Re);for(var Qe=0;Qe<Re;Qe++)ve[Qe]=arguments[Qe+2];te.children=ve}return{$$typeof:e,type:N.type,key:he,ref:Ae,props:te,_owner:se}},wn.createContext=function(N){return N={$$typeof:c,_currentValue:N,_currentValue2:N,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},N.Provider={$$typeof:u,_context:N},N.Consumer=N},wn.createElement=oe,wn.createFactory=function(N){var B=oe.bind(null,N);return B.type=N,B},wn.createRef=function(){return{current:null}},wn.forwardRef=function(N){return{$$typeof:d,render:N}},wn.isValidElement=_e,wn.lazy=function(N){return{$$typeof:g,_payload:{_status:-1,_result:N},_init:V}},wn.memo=function(N,B){return{$$typeof:_,type:N,compare:B===void 0?null:B}},wn.startTransition=function(N){var B=k.transition;k.transition={};try{N()}finally{k.transition=B}},wn.unstable_act=F,wn.useCallback=function(N,B){return J.current.useCallback(N,B)},wn.useContext=function(N){return J.current.useContext(N)},wn.useDebugValue=function(){},wn.useDeferredValue=function(N){return J.current.useDeferredValue(N)},wn.useEffect=function(N,B){return J.current.useEffect(N,B)},wn.useId=function(){return J.current.useId()},wn.useImperativeHandle=function(N,B,Z){return J.current.useImperativeHandle(N,B,Z)},wn.useInsertionEffect=function(N,B){return J.current.useInsertionEffect(N,B)},wn.useLayoutEffect=function(N,B){return J.current.useLayoutEffect(N,B)},wn.useMemo=function(N,B){return J.current.useMemo(N,B)},wn.useReducer=function(N,B,Z){return J.current.useReducer(N,B,Z)},wn.useRef=function(N){return J.current.useRef(N)},wn.useState=function(N){return J.current.useState(N)},wn.useSyncExternalStore=function(N,B,Z){return J.current.useSyncExternalStore(N,B,Z)},wn.useTransition=function(){return J.current.useTransition()},wn.version="18.3.1",wn}var gp;function Yu(){return gp||(gp=1,qf.exports=Tx()),qf.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 _p;function Mx(){if(_p)return wu;_p=1;var e=Yu(),t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function c(d,h,_){var g,x={},v=null,b=null;_!==void 0&&(v=""+_),h.key!==void 0&&(v=""+h.key),h.ref!==void 0&&(b=h.ref);for(g in h)o.call(h,g)&&!u.hasOwnProperty(g)&&(x[g]=h[g]);if(d&&d.defaultProps)for(g in h=d.defaultProps,h)x[g]===void 0&&(x[g]=h[g]);return{$$typeof:t,type:d,key:v,ref:b,props:x,_owner:l.current}}return wu.Fragment=r,wu.jsx=c,wu.jsxs=c,wu}var yp;function zx(){return yp||(yp=1,Vf.exports=Mx()),Vf.exports}var s=zx(),m=Yu();const Ee=th(m);var jd={},Gf={exports:{}},hi={},Yf={exports:{}},Xf={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/var xp;function Rx(){return xp||(xp=1,(function(e){function t(k,z){var F=k.length;k.push(z);e:for(;0<F;){var N=F-1>>>1,B=k[N];if(0<l(B,z))k[N]=z,k[F]=B,F=N;else break e}}function r(k){return k.length===0?null:k[0]}function o(k){if(k.length===0)return null;var z=k[0],F=k.pop();if(F!==z){k[0]=F;e:for(var N=0,B=k.length,Z=B>>>1;N<Z;){var te=2*(N+1)-1,he=k[te],Ae=te+1,se=k[Ae];if(0>l(he,F))Ae<B&&0>l(se,he)?(k[N]=se,k[Ae]=F,N=Ae):(k[N]=he,k[te]=F,N=te);else if(Ae<B&&0>l(se,F))k[N]=se,k[Ae]=F,N=Ae;else break e}}return z}function l(k,z){var F=k.sortIndex-z.sortIndex;return F!==0?F:k.id-z.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var h=[],_=[],g=1,x=null,v=3,b=!1,j=!1,S=!1,T=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function L(k){for(var z=r(_);z!==null;){if(z.callback===null)o(_);else if(z.startTime<=k)o(_),z.sortIndex=z.expirationTime,t(h,z);else break;z=r(_)}}function I(k){if(S=!1,L(k),!j)if(r(h)!==null)j=!0,V(G);else{var z=r(_);z!==null&&J(I,z.startTime-k)}}function G(k,z){j=!1,S&&(S=!1,M(oe),oe=-1),b=!0;var F=v;try{for(L(z),x=r(h);x!==null&&(!(x.expirationTime>z)||k&&!Te());){var N=x.callback;if(typeof N=="function"){x.callback=null,v=x.priorityLevel;var B=N(x.expirationTime<=z);z=e.unstable_now(),typeof B=="function"?x.callback=B:x===r(h)&&o(h),L(z)}else o(h);x=r(h)}if(x!==null)var Z=!0;else{var te=r(_);te!==null&&J(I,te.startTime-z),Z=!1}return Z}finally{x=null,v=F,b=!1}}var ne=!1,Y=null,oe=-1,le=5,_e=-1;function Te(){return!(e.unstable_now()-_e<le)}function $e(){if(Y!==null){var k=e.unstable_now();_e=k;var z=!0;try{z=Y(!0,k)}finally{z?K():(ne=!1,Y=null)}}else ne=!1}var K;if(typeof D=="function")K=function(){D($e)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,X=U.port2;U.port1.onmessage=$e,K=function(){X.postMessage(null)}}else K=function(){T($e,0)};function V(k){Y=k,ne||(ne=!0,K())}function J(k,z){oe=T(function(){k(e.unstable_now())},z)}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(k){k.callback=null},e.unstable_continueExecution=function(){j||b||(j=!0,V(G))},e.unstable_forceFrameRate=function(k){0>k||125<k?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):le=0<k?Math.floor(1e3/k):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_getFirstCallbackNode=function(){return r(h)},e.unstable_next=function(k){switch(v){case 1:case 2:case 3:var z=3;break;default:z=v}var F=v;v=z;try{return k()}finally{v=F}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(k,z){switch(k){case 1:case 2:case 3:case 4:case 5:break;default:k=3}var F=v;v=k;try{return z()}finally{v=F}},e.unstable_scheduleCallback=function(k,z,F){var N=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?N+F:N):F=N,k){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=F+B,k={id:g++,callback:z,priorityLevel:k,startTime:F,expirationTime:B,sortIndex:-1},F>N?(k.sortIndex=F,t(_,k),r(h)===null&&k===r(_)&&(S?(M(oe),oe=-1):S=!0,J(I,F-N))):(k.sortIndex=B,t(h,k),j||b||(j=!0,V(G))),k},e.unstable_shouldYield=Te,e.unstable_wrapCallback=function(k){var z=v;return function(){var F=v;v=z;try{return k.apply(this,arguments)}finally{v=F}}}})(Xf)),Xf}var vp;function Lx(){return vp||(vp=1,Yf.exports=Rx()),Yf.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 wp;function Px(){if(wp)return hi;wp=1;var e=Yu(),t=Lx();function r(n){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+n,a=1;a<arguments.length;a++)i+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+n+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,l={};function u(n,i){c(n,i),c(n+"Capture",i)}function c(n,i){for(l[n]=i,n=0;n<i.length;n++)o.add(i[n])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,_=/^[: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]*$/,g={},x={};function v(n){return h.call(x,n)?!0:h.call(g,n)?!1:_.test(n)?x[n]=!0:(g[n]=!0,!1)}function b(n,i,a,f){if(a!==null&&a.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return f?!1:a!==null?!a.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function j(n,i,a,f){if(i===null||typeof i>"u"||b(n,i,a,f))return!0;if(f)return!1;if(a!==null)switch(a.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function S(n,i,a,f,p,y,A){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=f,this.attributeNamespace=p,this.mustUseProperty=a,this.propertyName=n,this.type=i,this.sanitizeURL=y,this.removeEmptyString=A}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){T[n]=new S(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var i=n[0];T[i]=new S(i,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){T[n]=new S(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){T[n]=new S(n,2,!1,n,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(n){T[n]=new S(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){T[n]=new S(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){T[n]=new S(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){T[n]=new S(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){T[n]=new S(n,5,!1,n.toLowerCase(),null,!1,!1)});var M=/[\-:]([a-z])/g;function D(n){return n[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(n){var i=n.replace(M,D);T[i]=new S(i,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var i=n.replace(M,D);T[i]=new S(i,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var i=n.replace(M,D);T[i]=new S(i,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){T[n]=new S(n,1,!1,n.toLowerCase(),null,!1,!1)}),T.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){T[n]=new S(n,1,!1,n.toLowerCase(),null,!0,!0)});function L(n,i,a,f){var p=T.hasOwnProperty(i)?T[i]:null;(p!==null?p.type!==0:f||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(j(i,a,p,f)&&(a=null),f||p===null?v(i)&&(a===null?n.removeAttribute(i):n.setAttribute(i,""+a)):p.mustUseProperty?n[p.propertyName]=a===null?p.type===3?!1:"":a:(i=p.attributeName,f=p.attributeNamespace,a===null?n.removeAttribute(i):(p=p.type,a=p===3||p===4&&a===!0?"":""+a,f?n.setAttributeNS(f,i,a):n.setAttribute(i,a))))}var I=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,G=Symbol.for("react.element"),ne=Symbol.for("react.portal"),Y=Symbol.for("react.fragment"),oe=Symbol.for("react.strict_mode"),le=Symbol.for("react.profiler"),_e=Symbol.for("react.provider"),Te=Symbol.for("react.context"),$e=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),J=Symbol.for("react.offscreen"),k=Symbol.iterator;function z(n){return n===null||typeof n!="object"?null:(n=k&&n[k]||n["@@iterator"],typeof n=="function"?n:null)}var F=Object.assign,N;function B(n){if(N===void 0)try{throw Error()}catch(a){var i=a.stack.trim().match(/\n( *(at )?)/);N=i&&i[1]||""}return`
|
|
34
|
+
`+N+n}var Z=!1;function te(n,i){if(!n||Z)return"";Z=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(we){var f=we}Reflect.construct(n,[],i)}else{try{i.call()}catch(we){f=we}n.call(i.prototype)}else{try{throw Error()}catch(we){f=we}n()}}catch(we){if(we&&f&&typeof we.stack=="string"){for(var p=we.stack.split(`
|
|
35
|
+
`),y=f.stack.split(`
|
|
36
|
+
`),A=p.length-1,q=y.length-1;1<=A&&0<=q&&p[A]!==y[q];)q--;for(;1<=A&&0<=q;A--,q--)if(p[A]!==y[q]){if(A!==1||q!==1)do if(A--,q--,0>q||p[A]!==y[q]){var ee=`
|
|
37
|
+
`+p[A].replace(" at new "," at ");return n.displayName&&ee.includes("<anonymous>")&&(ee=ee.replace("<anonymous>",n.displayName)),ee}while(1<=A&&0<=q);break}}}finally{Z=!1,Error.prepareStackTrace=a}return(n=n?n.displayName||n.name:"")?B(n):""}function he(n){switch(n.tag){case 5:return B(n.type);case 16:return B("Lazy");case 13:return B("Suspense");case 19:return B("SuspenseList");case 0:case 2:case 15:return n=te(n.type,!1),n;case 11:return n=te(n.type.render,!1),n;case 1:return n=te(n.type,!0),n;default:return""}}function Ae(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case Y:return"Fragment";case ne:return"Portal";case le:return"Profiler";case oe:return"StrictMode";case K:return"Suspense";case U:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Te:return(n.displayName||"Context")+".Consumer";case _e:return(n._context.displayName||"Context")+".Provider";case $e:var i=n.render;return n=n.displayName,n||(n=i.displayName||i.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case X:return i=n.displayName||null,i!==null?i:Ae(n.type)||"Memo";case V:i=n._payload,n=n._init;try{return Ae(n(i))}catch{}}return null}function se(n){var i=n.type;switch(n.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=i.render,n=n.displayName||n.name||"",i.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ae(i);case 8:return i===oe?"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 i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function ve(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Re(n){var i=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function Qe(n){var i=Re(n)?"checked":"value",a=Object.getOwnPropertyDescriptor(n.constructor.prototype,i),f=""+n[i];if(!n.hasOwnProperty(i)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var p=a.get,y=a.set;return Object.defineProperty(n,i,{configurable:!0,get:function(){return p.call(this)},set:function(A){f=""+A,y.call(this,A)}}),Object.defineProperty(n,i,{enumerable:a.enumerable}),{getValue:function(){return f},setValue:function(A){f=""+A},stopTracking:function(){n._valueTracker=null,delete n[i]}}}}function Pe(n){n._valueTracker||(n._valueTracker=Qe(n))}function de(n){if(!n)return!1;var i=n._valueTracker;if(!i)return!0;var a=i.getValue(),f="";return n&&(f=Re(n)?n.checked?"true":"false":n.value),n=f,n!==a?(i.setValue(n),!0):!1}function be(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Fe(n,i){var a=i.checked;return F({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??n._wrapperState.initialChecked})}function Xe(n,i){var a=i.defaultValue==null?"":i.defaultValue,f=i.checked!=null?i.checked:i.defaultChecked;a=ve(i.value!=null?i.value:a),n._wrapperState={initialChecked:f,initialValue:a,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function tt(n,i){i=i.checked,i!=null&&L(n,"checked",i,!1)}function ze(n,i){tt(n,i);var a=ve(i.value),f=i.type;if(a!=null)f==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+a):n.value!==""+a&&(n.value=""+a);else if(f==="submit"||f==="reset"){n.removeAttribute("value");return}i.hasOwnProperty("value")?lt(n,i.type,a):i.hasOwnProperty("defaultValue")&<(n,i.type,ve(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(n.defaultChecked=!!i.defaultChecked)}function Oe(n,i,a){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var f=i.type;if(!(f!=="submit"&&f!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+n._wrapperState.initialValue,a||i===n.value||(n.value=i),n.defaultValue=i}a=n.name,a!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,a!==""&&(n.name=a)}function lt(n,i,a){(i!=="number"||be(n.ownerDocument)!==n)&&(a==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+a&&(n.defaultValue=""+a))}var xe=Array.isArray;function Et(n,i,a,f){if(n=n.options,i){i={};for(var p=0;p<a.length;p++)i["$"+a[p]]=!0;for(a=0;a<n.length;a++)p=i.hasOwnProperty("$"+n[a].value),n[a].selected!==p&&(n[a].selected=p),p&&f&&(n[a].defaultSelected=!0)}else{for(a=""+ve(a),i=null,p=0;p<n.length;p++){if(n[p].value===a){n[p].selected=!0,f&&(n[p].defaultSelected=!0);return}i!==null||n[p].disabled||(i=n[p])}i!==null&&(i.selected=!0)}}function yt(n,i){if(i.dangerouslySetInnerHTML!=null)throw Error(r(91));return F({},i,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function sn(n,i){var a=i.value;if(a==null){if(a=i.children,i=i.defaultValue,a!=null){if(i!=null)throw Error(r(92));if(xe(a)){if(1<a.length)throw Error(r(93));a=a[0]}i=a}i==null&&(i=""),a=i}n._wrapperState={initialValue:ve(a)}}function ln(n,i){var a=ve(i.value),f=ve(i.defaultValue);a!=null&&(a=""+a,a!==n.value&&(n.value=a),i.defaultValue==null&&n.defaultValue!==a&&(n.defaultValue=a)),f!=null&&(n.defaultValue=""+f)}function Xt(n){var i=n.textContent;i===n._wrapperState.initialValue&&i!==""&&i!==null&&(n.value=i)}function je(n){switch(n){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 ue(n,i){return n==null||n==="http://www.w3.org/1999/xhtml"?je(i):n==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var Ne,$t=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,a,f,p){MSApp.execUnsafeLocalFunction(function(){return n(i,a,f,p)})}:n})(function(n,i){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=i;else{for(Ne=Ne||document.createElement("div"),Ne.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=Ne.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;i.firstChild;)n.appendChild(i.firstChild)}});function pt(n,i){if(i){var a=n.firstChild;if(a&&a===n.lastChild&&a.nodeType===3){a.nodeValue=i;return}}n.textContent=i}var qt={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},Dn=["Webkit","ms","Moz","O"];Object.keys(qt).forEach(function(n){Dn.forEach(function(i){i=i+n.charAt(0).toUpperCase()+n.substring(1),qt[i]=qt[n]})});function nn(n,i,a){return i==null||typeof i=="boolean"||i===""?"":a||typeof i!="number"||i===0||qt.hasOwnProperty(n)&&qt[n]?(""+i).trim():i+"px"}function cn(n,i){n=n.style;for(var a in i)if(i.hasOwnProperty(a)){var f=a.indexOf("--")===0,p=nn(a,i[a],f);a==="float"&&(a="cssFloat"),f?n.setProperty(a,p):n[a]=p}}var vn=F({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 Sn(n,i){if(i){if(vn[n]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(r(137,n));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(r(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(r(61))}if(i.style!=null&&typeof i.style!="object")throw Error(r(62))}}function cr(n,i){if(n.indexOf("-")===-1)return typeof i.is=="string";switch(n){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 Qt=null;function Zn(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var ls=null,Un=null,me=null;function ke(n){if(n=Tl(n)){if(typeof ls!="function")throw Error(r(280));var i=n.stateNode;i&&(i=ac(i),ls(n.stateNode,n.type,i))}}function ct(n){Un?me?me.push(n):me=[n]:Un=n}function it(){if(Un){var n=Un,i=me;if(me=Un=null,ke(n),i)for(n=0;n<i.length;n++)ke(i[n])}}function bt(n,i){return n(i)}function zt(){}var Ut=!1;function Ot(n,i,a){if(Ut)return n(i,a);Ut=!0;try{return bt(n,i,a)}finally{Ut=!1,(Un!==null||me!==null)&&(zt(),it())}}function pn(n,i){var a=n.stateNode;if(a===null)return null;var f=ac(a);if(f===null)return null;a=f[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(f=!f.disabled)||(n=n.type,f=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!f;break e;default:n=!1}if(n)return null;if(a&&typeof a!="function")throw Error(r(231,i,typeof a));return a}var It=!1;if(d)try{var _n={};Object.defineProperty(_n,"passive",{get:function(){It=!0}}),window.addEventListener("test",_n,_n),window.removeEventListener("test",_n,_n)}catch{It=!1}function un(n,i,a,f,p,y,A,q,ee){var we=Array.prototype.slice.call(arguments,3);try{i.apply(a,we)}catch(We){this.onError(We)}}var Gt=!1,Zt=null,Vt=!1,rt=null,jn={onError:function(n){Gt=!0,Zt=n}};function Rn(n,i,a,f,p,y,A,q,ee){Gt=!1,Zt=null,un.apply(jn,arguments)}function kn(n,i,a,f,p,y,A,q,ee){if(Rn.apply(this,arguments),Gt){if(Gt){var we=Zt;Gt=!1,Zt=null}else throw Error(r(198));Vt||(Vt=!0,rt=we)}}function Nn(n){var i=n,a=n;if(n.alternate)for(;i.return;)i=i.return;else{n=i;do i=n,(i.flags&4098)!==0&&(a=i.return),n=i.return;while(n)}return i.tag===3?a:null}function ar(n){if(n.tag===13){var i=n.memoizedState;if(i===null&&(n=n.alternate,n!==null&&(i=n.memoizedState)),i!==null)return i.dehydrated}return null}function Ir(n){if(Nn(n)!==n)throw Error(r(188))}function Sr(n){var i=n.alternate;if(!i){if(i=Nn(n),i===null)throw Error(r(188));return i!==n?null:n}for(var a=n,f=i;;){var p=a.return;if(p===null)break;var y=p.alternate;if(y===null){if(f=p.return,f!==null){a=f;continue}break}if(p.child===y.child){for(y=p.child;y;){if(y===a)return Ir(p),n;if(y===f)return Ir(p),i;y=y.sibling}throw Error(r(188))}if(a.return!==f.return)a=p,f=y;else{for(var A=!1,q=p.child;q;){if(q===a){A=!0,a=p,f=y;break}if(q===f){A=!0,f=p,a=y;break}q=q.sibling}if(!A){for(q=y.child;q;){if(q===a){A=!0,a=y,f=p;break}if(q===f){A=!0,f=y,a=p;break}q=q.sibling}if(!A)throw Error(r(189))}}if(a.alternate!==f)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?n:i}function Fr(n){return n=Sr(n),n!==null?Ws(n):null}function Ws(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var i=Ws(n);if(i!==null)return i;n=n.sibling}return null}var Es=t.unstable_scheduleCallback,lo=t.unstable_cancelCallback,Ri=t.unstable_shouldYield,cs=t.unstable_requestPaint,En=t.unstable_now,us=t.unstable_getCurrentPriorityLevel,Jr=t.unstable_ImmediatePriority,Or=t.unstable_UserBlockingPriority,mr=t.unstable_NormalPriority,st=t.unstable_LowPriority,St=t.unstable_IdlePriority,dn=null,Dr=null;function jr(n){if(Dr&&typeof Dr.onCommitFiberRoot=="function")try{Dr.onCommitFiberRoot(dn,n,void 0,(n.current.flags&128)===128)}catch{}}var kr=Math.clz32?Math.clz32:Hs,hr=Math.log,Io=Math.LN2;function Hs(n){return n>>>=0,n===0?32:31-(hr(n)/Io|0)|0}var Bn=64,ur=4194304;function dr(n){switch(n&-n){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 n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Me(n,i){var a=n.pendingLanes;if(a===0)return 0;var f=0,p=n.suspendedLanes,y=n.pingedLanes,A=a&268435455;if(A!==0){var q=A&~p;q!==0?f=dr(q):(y&=A,y!==0&&(f=dr(y)))}else A=a&~p,A!==0?f=dr(A):y!==0&&(f=dr(y));if(f===0)return 0;if(i!==0&&i!==f&&(i&p)===0&&(p=f&-f,y=i&-i,p>=y||p===16&&(y&4194240)!==0))return i;if((f&4)!==0&&(f|=a&16),i=n.entangledLanes,i!==0)for(n=n.entanglements,i&=f;0<i;)a=31-kr(i),p=1<<a,f|=n[a],i&=~p;return f}function Gn(n,i){switch(n){case 1:case 2:case 4:return i+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 i+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 Ge(n,i){for(var a=n.suspendedLanes,f=n.pingedLanes,p=n.expirationTimes,y=n.pendingLanes;0<y;){var A=31-kr(y),q=1<<A,ee=p[A];ee===-1?((q&a)===0||(q&f)!==0)&&(p[A]=Gn(q,i)):ee<=i&&(n.expiredLanes|=q),y&=~q}}function Yn(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function er(){var n=Bn;return Bn<<=1,(Bn&4194240)===0&&(Bn=64),n}function pr(n){for(var i=[],a=0;31>a;a++)i.push(n);return i}function Nr(n,i,a){n.pendingLanes|=i,i!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,i=31-kr(i),n[i]=a}function Cr(n,i){var a=n.pendingLanes&~i;n.pendingLanes=i,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=i,n.mutableReadLanes&=i,n.entangledLanes&=i,i=n.entanglements;var f=n.eventTimes;for(n=n.expirationTimes;0<a;){var p=31-kr(a),y=1<<p;i[p]=0,f[p]=-1,n[p]=-1,a&=~y}}function Li(n,i){var a=n.entangledLanes|=i;for(n=n.entanglements;a;){var f=31-kr(a),p=1<<f;p&i|n[f]&i&&(n[f]|=i),a&=~p}}var rn=0;function Er(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var Vs,$s,tr,fr,gi,Ln=!1,Br=[],$r=null,Qr=null,Ur=null,As=new Map,Zr=new Map,es=[],gr="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 Pi(n,i){switch(n){case"focusin":case"focusout":$r=null;break;case"dragenter":case"dragleave":Qr=null;break;case"mouseover":case"mouseout":Ur=null;break;case"pointerover":case"pointerout":As.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Zr.delete(i.pointerId)}}function Wr(n,i,a,f,p,y){return n===null||n.nativeEvent!==y?(n={blockedOn:i,domEventName:a,eventSystemFlags:f,nativeEvent:y,targetContainers:[p]},i!==null&&(i=Tl(i),i!==null&&$s(i)),n):(n.eventSystemFlags|=f,i=n.targetContainers,p!==null&&i.indexOf(p)===-1&&i.push(p),n)}function Ii(n,i,a,f,p){switch(i){case"focusin":return $r=Wr($r,n,i,a,f,p),!0;case"dragenter":return Qr=Wr(Qr,n,i,a,f,p),!0;case"mouseover":return Ur=Wr(Ur,n,i,a,f,p),!0;case"pointerover":var y=p.pointerId;return As.set(y,Wr(As.get(y)||null,n,i,a,f,p)),!0;case"gotpointercapture":return y=p.pointerId,Zr.set(y,Wr(Zr.get(y)||null,n,i,a,f,p)),!0}return!1}function Fi(n){var i=oi(n.target);if(i!==null){var a=Nn(i);if(a!==null){if(i=a.tag,i===13){if(i=ar(a),i!==null){n.blockedOn=i,gi(n.priority,function(){tr(a)});return}}else if(i===3&&a.stateNode.current.memoizedState.isDehydrated){n.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Ts(n){if(n.blockedOn!==null)return!1;for(var i=n.targetContainers;0<i.length;){var a=ie(n.domEventName,n.eventSystemFlags,i[0],n.nativeEvent);if(a===null){a=n.nativeEvent;var f=new a.constructor(a.type,a);Qt=f,a.target.dispatchEvent(f),Qt=null}else return i=Tl(a),i!==null&&$s(i),n.blockedOn=a,!1;i.shift()}return!0}function Oi(n,i,a){Ts(n)&&a.delete(i)}function ua(){Ln=!1,$r!==null&&Ts($r)&&($r=null),Qr!==null&&Ts(Qr)&&(Qr=null),Ur!==null&&Ts(Ur)&&(Ur=null),As.forEach(Oi),Zr.forEach(Oi)}function Ms(n,i){n.blockedOn===i&&(n.blockedOn=null,Ln||(Ln=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ua)))}function qs(n){function i(p){return Ms(p,n)}if(0<Br.length){Ms(Br[0],n);for(var a=1;a<Br.length;a++){var f=Br[a];f.blockedOn===n&&(f.blockedOn=null)}}for($r!==null&&Ms($r,n),Qr!==null&&Ms(Qr,n),Ur!==null&&Ms(Ur,n),As.forEach(i),Zr.forEach(i),a=0;a<es.length;a++)f=es[a],f.blockedOn===n&&(f.blockedOn=null);for(;0<es.length&&(a=es[0],a.blockedOn===null);)Fi(a),a.blockedOn===null&&es.shift()}var Hr=I.ReactCurrentBatchConfig,zs=!0;function Di(n,i,a,f){var p=rn,y=Hr.transition;Hr.transition=null;try{rn=1,Ar(n,i,a,f)}finally{rn=p,Hr.transition=y}}function Fo(n,i,a,f){var p=rn,y=Hr.transition;Hr.transition=null;try{rn=4,Ar(n,i,a,f)}finally{rn=p,Hr.transition=y}}function Ar(n,i,a,f){if(zs){var p=ie(n,i,a,f);if(p===null)Go(n,i,f,R,a),Pi(n,f);else if(Ii(p,n,i,a,f))f.stopPropagation();else if(Pi(n,f),i&4&&-1<gr.indexOf(n)){for(;p!==null;){var y=Tl(p);if(y!==null&&Vs(y),y=ie(n,i,a,f),y===null&&Go(n,i,f,R,a),y===p)break;p=y}p!==null&&f.stopPropagation()}else Go(n,i,f,null,a)}}var R=null;function ie(n,i,a,f){if(R=null,n=Zn(f),n=oi(n),n!==null)if(i=Nn(n),i===null)n=null;else if(a=i.tag,a===13){if(n=ar(i),n!==null)return n;n=null}else if(a===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;n=null}else i!==n&&(n=null);return R=n,null}function Ce(n){switch(n){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(us()){case Jr:return 1;case Or:return 4;case mr:case st:return 16;case St:return 536870912;default:return 16}default:return 16}}var Ie=null,De=null,at=null;function At(){if(at)return at;var n,i=De,a=i.length,f,p="value"in Ie?Ie.value:Ie.textContent,y=p.length;for(n=0;n<a&&i[n]===p[n];n++);var A=a-n;for(f=1;f<=A&&i[a-f]===p[y-f];f++);return at=p.slice(n,1<f?1-f:void 0)}function Rt(n){var i=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&i===13&&(n=13)):n=i,n===10&&(n=13),32<=n||n===13?n:0}function Lt(){return!0}function Kt(){return!1}function nt(n){function i(a,f,p,y,A){this._reactName=a,this._targetInst=p,this.type=f,this.nativeEvent=y,this.target=A,this.currentTarget=null;for(var q in n)n.hasOwnProperty(q)&&(a=n[q],this[q]=a?a(y):y[q]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?Lt:Kt,this.isPropagationStopped=Kt,this}return F(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Lt)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Lt)},persist:function(){},isPersistent:Lt}),i}var yn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},en=nt(yn),fn=F({},yn,{view:0,detail:0}),or=nt(fn),An,Tr,bs,_i=F({},fn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ls,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==bs&&(bs&&n.type==="mousemove"?(An=n.screenX-bs.screenX,Tr=n.screenY-bs.screenY):Tr=An=0,bs=n),An)},movementY:function(n){return"movementY"in n?n.movementY:Tr}}),Rs=nt(_i),co=F({},_i,{dataTransfer:0}),yl=nt(co),uo=F({},fn,{relatedTarget:0}),fo=nt(uo),mo=F({},yn,{animationName:0,elapsedTime:0,pseudoElement:0}),Ia=nt(mo),Gs=F({},yn,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),ec=nt(Gs),ho=F({},yn,{data:0}),xl=nt(ho),Oo={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},da={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"},po={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Bi(n){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(n):(n=po[n])?!!i[n]:!1}function Ls(){return Bi}var vl=F({},fn,{key:function(n){if(n.key){var i=Oo[n.key]||n.key;if(i!=="Unidentified")return i}return n.type==="keypress"?(n=Rt(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?da[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ls,charCode:function(n){return n.type==="keypress"?Rt(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Rt(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),fa=nt(vl),go=F({},_i,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),_o=nt(go),yo=F({},fn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ls}),Do=nt(yo),ma=F({},yn,{propertyName:0,elapsedTime:0,pseudoElement:0}),Fa=nt(ma),wl=F({},_i,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),Bo=nt(wl),bl=[9,13,27,32],Ui=d&&"CompositionEvent"in window,yi=null;d&&"documentMode"in document&&(yi=document.documentMode);var tc=d&&"TextEvent"in window&&!yi,Oa=d&&(!Ui||yi&&8<yi&&11>=yi),Sl=" ",jl=!1;function Uo(n,i){switch(n){case"keyup":return bl.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ys(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Ps=!1;function nc(n,i){switch(n){case"compositionend":return Ys(i);case"keypress":return i.which!==32?null:(jl=!0,Sl);case"textInput":return n=i.data,n===Sl&&jl?null:n;default:return null}}function Wo(n,i){if(Ps)return n==="compositionend"||!Ui&&Uo(n,i)?(n=At(),at=De=Ie=null,Ps=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return Oa&&i.locale!=="ko"?null:i.data;default:return null}}var kl={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 ha(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i==="input"?!!kl[n.type]:i==="textarea"}function Wi(n,i,a,f){ct(f),i=Ua(i,"onChange"),0<i.length&&(a=new en("onChange","change",null,a,f),n.push({event:a,listeners:i}))}var Mr=null,ds=null;function pa(n){wa(n,0)}function ri(n){var i=Ha(n);if(de(i))return n}function ga(n,i){if(n==="change")return i}var Hi=!1;if(d){var fs;if(d){var Vi="oninput"in document;if(!Vi){var Cn=document.createElement("div");Cn.setAttribute("oninput","return;"),Vi=typeof Cn.oninput=="function"}fs=Vi}else fs=!1;Hi=fs&&(!document.documentMode||9<document.documentMode)}function ts(){Mr&&(Mr.detachEvent("onpropertychange",lr),ds=Mr=null)}function lr(n){if(n.propertyName==="value"&&ri(ds)){var i=[];Wi(i,ds,n,Zn(n)),Ot(pa,i)}}function nr(n,i,a){n==="focusin"?(ts(),Mr=i,ds=a,Mr.attachEvent("onpropertychange",lr)):n==="focusout"&&ts()}function xo(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return ri(ds)}function si(n,i){if(n==="click")return ri(i)}function vo(n,i){if(n==="input"||n==="change")return ri(i)}function ms(n,i){return n===i&&(n!==0||1/n===1/i)||n!==n&&i!==i}var ns=typeof Object.is=="function"?Object.is:ms;function Xs(n,i){if(ns(n,i))return!0;if(typeof n!="object"||n===null||typeof i!="object"||i===null)return!1;var a=Object.keys(n),f=Object.keys(i);if(a.length!==f.length)return!1;for(f=0;f<a.length;f++){var p=a[f];if(!h.call(i,p)||!ns(n[p],i[p]))return!1}return!0}function hs(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Vn(n,i){var a=hs(n);n=0;for(var f;a;){if(a.nodeType===3){if(f=n+a.textContent.length,n<=i&&f>=i)return{node:a,offset:i-n};n=f}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=hs(a)}}function ps(n,i){return n&&i?n===i?!0:n&&n.nodeType===3?!1:i&&i.nodeType===3?ps(n,i.parentNode):"contains"in n?n.contains(i):n.compareDocumentPosition?!!(n.compareDocumentPosition(i)&16):!1:!1}function xi(){for(var n=window,i=be();i instanceof n.HTMLIFrameElement;){try{var a=typeof i.contentWindow.location.href=="string"}catch{a=!1}if(a)n=i.contentWindow;else break;i=be(n.document)}return i}function _a(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i&&(i==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||i==="textarea"||n.contentEditable==="true")}function Ho(n){var i=xi(),a=n.focusedElem,f=n.selectionRange;if(i!==a&&a&&a.ownerDocument&&ps(a.ownerDocument.documentElement,a)){if(f!==null&&_a(a)){if(i=f.start,n=f.end,n===void 0&&(n=i),"selectionStart"in a)a.selectionStart=i,a.selectionEnd=Math.min(n,a.value.length);else if(n=(i=a.ownerDocument||document)&&i.defaultView||window,n.getSelection){n=n.getSelection();var p=a.textContent.length,y=Math.min(f.start,p);f=f.end===void 0?y:Math.min(f.end,p),!n.extend&&y>f&&(p=f,f=y,y=p),p=Vn(a,y);var A=Vn(a,f);p&&A&&(n.rangeCount!==1||n.anchorNode!==p.node||n.anchorOffset!==p.offset||n.focusNode!==A.node||n.focusOffset!==A.offset)&&(i=i.createRange(),i.setStart(p.node,p.offset),n.removeAllRanges(),y>f?(n.addRange(i),n.extend(A.node,A.offset)):(i.setEnd(A.node,A.offset),n.addRange(i)))}}for(i=[],n=a;n=n.parentNode;)n.nodeType===1&&i.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<i.length;a++)n=i[a],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var qi=d&&"documentMode"in document&&11>=document.documentMode,jt=null,ya=null,Vr=null,gn=!1;function zr(n,i,a){var f=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;gn||jt==null||jt!==be(f)||(f=jt,"selectionStart"in f&&_a(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),Vr&&Xs(Vr,f)||(Vr=f,f=Ua(ya,"onSelect"),0<f.length&&(i=new en("onSelect","select",null,i,a),n.push({event:i,listeners:f}),i.target=jt)))}function vi(n,i){var a={};return a[n.toLowerCase()]=i.toLowerCase(),a["Webkit"+n]="webkit"+i,a["Moz"+n]="moz"+i,a}var wo={animationend:vi("Animation","AnimationEnd"),animationiteration:vi("Animation","AnimationIteration"),animationstart:vi("Animation","AnimationStart"),transitionend:vi("Transition","TransitionEnd")},ii={},rc={};d&&(rc=document.createElement("div").style,"AnimationEvent"in window||(delete wo.animationend.animation,delete wo.animationiteration.animation,delete wo.animationstart.animation),"TransitionEvent"in window||delete wo.transitionend.transition);function Yt(n){if(ii[n])return ii[n];if(!wo[n])return n;var i=wo[n],a;for(a in i)if(i.hasOwnProperty(a)&&a in rc)return ii[n]=i[a];return n}var sc=Yt("animationend"),Vo=Yt("animationiteration"),ic=Yt("animationstart"),Nl=Yt("transitionend"),Cl=new Map,oc="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 Gi(n,i){Cl.set(n,i),u(i,[n])}for(var El=0;El<oc.length;El++){var xa=oc[El],Yc=xa.toLowerCase(),Xc=xa[0].toUpperCase()+xa.slice(1);Gi(Yc,"on"+Xc)}Gi(sc,"onAnimationEnd"),Gi(Vo,"onAnimationIteration"),Gi(ic,"onAnimationStart"),Gi("dblclick","onDoubleClick"),Gi("focusin","onFocus"),Gi("focusout","onBlur"),Gi(Nl,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var va="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(" "),Kc=new Set("cancel close invalid load scroll toggle".split(" ").concat(va));function Da(n,i,a){var f=n.type||"unknown-event";n.currentTarget=a,kn(f,i,void 0,n),n.currentTarget=null}function wa(n,i){i=(i&4)!==0;for(var a=0;a<n.length;a++){var f=n[a],p=f.event;f=f.listeners;e:{var y=void 0;if(i)for(var A=f.length-1;0<=A;A--){var q=f[A],ee=q.instance,we=q.currentTarget;if(q=q.listener,ee!==y&&p.isPropagationStopped())break e;Da(p,q,we),y=ee}else for(A=0;A<f.length;A++){if(q=f[A],ee=q.instance,we=q.currentTarget,q=q.listener,ee!==y&&p.isPropagationStopped())break e;Da(p,q,we),y=ee}}}if(Vt)throw n=rt,Vt=!1,rt=null,n}function In(n,i){var a=i[qn];a===void 0&&(a=i[qn]=new Set);var f=n+"__bubble";a.has(f)||(Ba(i,n,2,!1),a.add(f))}function $l(n,i,a){var f=0;i&&(f|=4),Ba(a,n,f,i)}var Xn="_reactListening"+Math.random().toString(36).slice(2);function qo(n){if(!n[Xn]){n[Xn]=!0,o.forEach(function(a){a!=="selectionchange"&&(Kc.has(a)||$l(a,!1,n),$l(a,!0,n))});var i=n.nodeType===9?n:n.ownerDocument;i===null||i[Xn]||(i[Xn]=!0,$l("selectionchange",!1,i))}}function Ba(n,i,a,f){switch(Ce(i)){case 1:var p=Di;break;case 4:p=Fo;break;default:p=Ar}a=p.bind(null,i,a,n),p=void 0,!It||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(p=!0),f?p!==void 0?n.addEventListener(i,a,{capture:!0,passive:p}):n.addEventListener(i,a,!0):p!==void 0?n.addEventListener(i,a,{passive:p}):n.addEventListener(i,a,!1)}function Go(n,i,a,f,p){var y=f;if((i&1)===0&&(i&2)===0&&f!==null)e:for(;;){if(f===null)return;var A=f.tag;if(A===3||A===4){var q=f.stateNode.containerInfo;if(q===p||q.nodeType===8&&q.parentNode===p)break;if(A===4)for(A=f.return;A!==null;){var ee=A.tag;if((ee===3||ee===4)&&(ee=A.stateNode.containerInfo,ee===p||ee.nodeType===8&&ee.parentNode===p))return;A=A.return}for(;q!==null;){if(A=oi(q),A===null)return;if(ee=A.tag,ee===5||ee===6){f=y=A;continue e}q=q.parentNode}}f=f.return}Ot(function(){var we=y,We=Zn(a),qe=[];e:{var Ue=Cl.get(n);if(Ue!==void 0){var ht=en,wt=n;switch(n){case"keypress":if(Rt(a)===0)break e;case"keydown":case"keyup":ht=fa;break;case"focusin":wt="focus",ht=fo;break;case"focusout":wt="blur",ht=fo;break;case"beforeblur":case"afterblur":ht=fo;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ht=Rs;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ht=yl;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ht=Do;break;case sc:case Vo:case ic:ht=Ia;break;case Nl:ht=Fa;break;case"scroll":ht=or;break;case"wheel":ht=Bo;break;case"copy":case"cut":case"paste":ht=ec;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ht=_o}var Nt=(i&4)!==0,Pr=!Nt&&n==="scroll",pe=Nt?Ue!==null?Ue+"Capture":null:Ue;Nt=[];for(var ce=we,ge;ce!==null;){ge=ce;var Je=ge.stateNode;if(ge.tag===5&&Je!==null&&(ge=Je,pe!==null&&(Je=pn(ce,pe),Je!=null&&Nt.push(bo(ce,Je,ge)))),Pr)break;ce=ce.return}0<Nt.length&&(Ue=new ht(Ue,wt,null,a,We),qe.push({event:Ue,listeners:Nt}))}}if((i&7)===0){e:{if(Ue=n==="mouseover"||n==="pointerover",ht=n==="mouseout"||n==="pointerout",Ue&&a!==Qt&&(wt=a.relatedTarget||a.fromElement)&&(oi(wt)||wt[yr]))break e;if((ht||Ue)&&(Ue=We.window===We?We:(Ue=We.ownerDocument)?Ue.defaultView||Ue.parentWindow:window,ht?(wt=a.relatedTarget||a.toElement,ht=we,wt=wt?oi(wt):null,wt!==null&&(Pr=Nn(wt),wt!==Pr||wt.tag!==5&&wt.tag!==6)&&(wt=null)):(ht=null,wt=we),ht!==wt)){if(Nt=Rs,Je="onMouseLeave",pe="onMouseEnter",ce="mouse",(n==="pointerout"||n==="pointerover")&&(Nt=_o,Je="onPointerLeave",pe="onPointerEnter",ce="pointer"),Pr=ht==null?Ue:Ha(ht),ge=wt==null?Ue:Ha(wt),Ue=new Nt(Je,ce+"leave",ht,a,We),Ue.target=Pr,Ue.relatedTarget=ge,Je=null,oi(We)===we&&(Nt=new Nt(pe,ce+"enter",wt,a,We),Nt.target=ge,Nt.relatedTarget=Pr,Je=Nt),Pr=Je,ht&&wt)t:{for(Nt=ht,pe=wt,ce=0,ge=Nt;ge;ge=Yo(ge))ce++;for(ge=0,Je=pe;Je;Je=Yo(Je))ge++;for(;0<ce-ge;)Nt=Yo(Nt),ce--;for(;0<ge-ce;)pe=Yo(pe),ge--;for(;ce--;){if(Nt===pe||pe!==null&&Nt===pe.alternate)break t;Nt=Yo(Nt),pe=Yo(pe)}Nt=null}else Nt=null;ht!==null&&Al(qe,Ue,ht,Nt,!1),wt!==null&&Pr!==null&&Al(qe,Pr,wt,Nt,!0)}}e:{if(Ue=we?Ha(we):window,ht=Ue.nodeName&&Ue.nodeName.toLowerCase(),ht==="select"||ht==="input"&&Ue.type==="file")var Mt=ga;else if(ha(Ue))if(Hi)Mt=vo;else{Mt=xo;var Dt=nr}else(ht=Ue.nodeName)&&ht.toLowerCase()==="input"&&(Ue.type==="checkbox"||Ue.type==="radio")&&(Mt=si);if(Mt&&(Mt=Mt(n,we))){Wi(qe,Mt,a,We);break e}Dt&&Dt(n,Ue,we),n==="focusout"&&(Dt=Ue._wrapperState)&&Dt.controlled&&Ue.type==="number"&<(Ue,"number",Ue.value)}switch(Dt=we?Ha(we):window,n){case"focusin":(ha(Dt)||Dt.contentEditable==="true")&&(jt=Dt,ya=we,Vr=null);break;case"focusout":Vr=ya=jt=null;break;case"mousedown":gn=!0;break;case"contextmenu":case"mouseup":case"dragend":gn=!1,zr(qe,a,We);break;case"selectionchange":if(qi)break;case"keydown":case"keyup":zr(qe,a,We)}var Bt;if(Ui)e:{switch(n){case"compositionstart":var Jt="onCompositionStart";break e;case"compositionend":Jt="onCompositionEnd";break e;case"compositionupdate":Jt="onCompositionUpdate";break e}Jt=void 0}else Ps?Uo(n,a)&&(Jt="onCompositionEnd"):n==="keydown"&&a.keyCode===229&&(Jt="onCompositionStart");Jt&&(Oa&&a.locale!=="ko"&&(Ps||Jt!=="onCompositionStart"?Jt==="onCompositionEnd"&&Ps&&(Bt=At()):(Ie=We,De="value"in Ie?Ie.value:Ie.textContent,Ps=!0)),Dt=Ua(we,Jt),0<Dt.length&&(Jt=new xl(Jt,n,null,a,We),qe.push({event:Jt,listeners:Dt}),Bt?Jt.data=Bt:(Bt=Ys(a),Bt!==null&&(Jt.data=Bt)))),(Bt=tc?nc(n,a):Wo(n,a))&&(we=Ua(we,"onBeforeInput"),0<we.length&&(We=new xl("onBeforeInput","beforeinput",null,a,We),qe.push({event:We,listeners:we}),We.data=Bt))}wa(qe,i)})}function bo(n,i,a){return{instance:n,listener:i,currentTarget:a}}function Ua(n,i){for(var a=i+"Capture",f=[];n!==null;){var p=n,y=p.stateNode;p.tag===5&&y!==null&&(p=y,y=pn(n,a),y!=null&&f.unshift(bo(n,y,p)),y=pn(n,i),y!=null&&f.push(bo(n,y,p))),n=n.return}return f}function Yo(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function Al(n,i,a,f,p){for(var y=i._reactName,A=[];a!==null&&a!==f;){var q=a,ee=q.alternate,we=q.stateNode;if(ee!==null&&ee===f)break;q.tag===5&&we!==null&&(q=we,p?(ee=pn(a,y),ee!=null&&A.unshift(bo(a,ee,q))):p||(ee=pn(a,y),ee!=null&&A.push(bo(a,ee,q)))),a=a.return}A.length!==0&&n.push({event:i,listeners:A})}var C=/\r\n?/g,W=/\u0000|\uFFFD/g;function O(n){return(typeof n=="string"?n:""+n).replace(C,`
|
|
38
|
+
`).replace(W,"")}function fe(n,i,a){if(i=O(i),O(n)!==i&&a)throw Error(r(425))}function Se(){}var et=null,Ye=null;function Ze(n,i){return n==="textarea"||n==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var He=typeof setTimeout=="function"?setTimeout:void 0,Wt=typeof clearTimeout=="function"?clearTimeout:void 0,xn=typeof Promise=="function"?Promise:void 0,Fn=typeof queueMicrotask=="function"?queueMicrotask:typeof xn<"u"?function(n){return xn.resolve(null).then(n).catch($n)}:He;function $n(n){setTimeout(function(){throw n})}function Ks(n,i){var a=i,f=0;do{var p=a.nextSibling;if(n.removeChild(a),p&&p.nodeType===8)if(a=p.data,a==="/$"){if(f===0){n.removeChild(p),qs(i);return}f--}else a!=="$"&&a!=="$?"&&a!=="$!"||f++;a=p}while(a);qs(i)}function Ss(n){for(;n!=null;n=n.nextSibling){var i=n.nodeType;if(i===1||i===3)break;if(i===8){if(i=n.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return n}function Yi(n){n=n.previousSibling;for(var i=0;n;){if(n.nodeType===8){var a=n.data;if(a==="$"||a==="$!"||a==="$?"){if(i===0)return n;i--}else a==="/$"&&i++}n=n.previousSibling}return null}var Is=Math.random().toString(36).slice(2),_r="__reactFiber$"+Is,wi="__reactProps$"+Is,yr="__reactContainer$"+Is,qn="__reactEvents$"+Is,Wa="__reactListeners$"+Is,ba="__reactHandles$"+Is;function oi(n){var i=n[_r];if(i)return i;for(var a=n.parentNode;a;){if(i=a[yr]||a[_r]){if(a=i.alternate,i.child!==null||a!==null&&a.child!==null)for(n=Yi(n);n!==null;){if(a=n[_r])return a;n=Yi(n)}return i}n=a,a=n.parentNode}return null}function Tl(n){return n=n[_r]||n[yr],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function Ha(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(r(33))}function ac(n){return n[wi]||null}var Jc=[],Va=-1;function Xo(n){return{current:n}}function Kn(n){0>Va||(n.current=Jc[Va],Jc[Va]=null,Va--)}function Wn(n,i){Va++,Jc[Va]=n.current,n.current=i}var Xi={},gs=Xo(Xi),Fs=Xo(!1),So=Xi;function qa(n,i){var a=n.type.contextTypes;if(!a)return Xi;var f=n.stateNode;if(f&&f.__reactInternalMemoizedUnmaskedChildContext===i)return f.__reactInternalMemoizedMaskedChildContext;var p={},y;for(y in a)p[y]=i[y];return f&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=i,n.__reactInternalMemoizedMaskedChildContext=p),p}function rs(n){return n=n.childContextTypes,n!=null}function bi(){Kn(Fs),Kn(gs)}function qr(n,i,a){if(gs.current!==Xi)throw Error(r(168));Wn(gs,i),Wn(Fs,a)}function Si(n,i,a){var f=n.stateNode;if(i=i.childContextTypes,typeof f.getChildContext!="function")return a;f=f.getChildContext();for(var p in f)if(!(p in i))throw Error(r(108,se(n)||"Unknown",p));return F({},a,f)}function lc(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Xi,So=gs.current,Wn(gs,n),Wn(Fs,Fs.current),!0}function cc(n,i,a){var f=n.stateNode;if(!f)throw Error(r(169));a?(n=Si(n,i,So),f.__reactInternalMemoizedMergedChildContext=n,Kn(Fs),Kn(gs),Wn(gs,n)):Kn(Fs),Wn(Fs,a)}var jo=null,Ga=!1,Qc=!1;function Qu(n){jo===null?jo=[n]:jo.push(n)}function pf(n){Ga=!0,Qu(n)}function Os(){if(!Qc&&jo!==null){Qc=!0;var n=0,i=rn;try{var a=jo;for(rn=1;n<a.length;n++){var f=a[n];do f=f(!0);while(f!==null)}jo=null,Ga=!1}catch(p){throw jo!==null&&(jo=jo.slice(n+1)),Es(Jr,Os),p}finally{rn=i,Qc=!1}}return null}var ji=[],Js=0,ki=null,_s=0,ss=[],ai=0,Ko=null,Rr=1,Ni="";function Jo(n,i){ji[Js++]=_s,ji[Js++]=ki,ki=n,_s=i}function Zc(n,i,a){ss[ai++]=Rr,ss[ai++]=Ni,ss[ai++]=Ko,Ko=n;var f=Rr;n=Ni;var p=32-kr(f)-1;f&=~(1<<p),a+=1;var y=32-kr(i)+p;if(30<y){var A=p-p%5;y=(f&(1<<A)-1).toString(32),f>>=A,p-=A,Rr=1<<32-kr(i)+p|a<<p|f,Ni=y+n}else Rr=1<<y|a<<p|f,Ni=n}function eu(n){n.return!==null&&(Jo(n,1),Zc(n,1,0))}function tu(n){for(;n===ki;)ki=ji[--Js],ji[Js]=null,_s=ji[--Js],ji[Js]=null;for(;n===Ko;)Ko=ss[--ai],ss[ai]=null,Ni=ss[--ai],ss[ai]=null,Rr=ss[--ai],ss[ai]=null}var Jn=null,is=null,Qn=!1,li=null;function Ht(n,i){var a=ro(5,null,null,0);a.elementType="DELETED",a.stateNode=i,a.return=n,i=n.deletions,i===null?(n.deletions=[a],n.flags|=16):i.push(a)}function nu(n,i){switch(n.tag){case 5:var a=n.type;return i=i.nodeType!==1||a.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(n.stateNode=i,Jn=n,is=Ss(i.firstChild),!0):!1;case 6:return i=n.pendingProps===""||i.nodeType!==3?null:i,i!==null?(n.stateNode=i,Jn=n,is=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(a=Ko!==null?{id:Rr,overflow:Ni}:null,n.memoizedState={dehydrated:i,treeContext:a,retryLane:1073741824},a=ro(18,null,null,0),a.stateNode=i,a.return=n,n.child=a,Jn=n,is=null,!0):!1;default:return!1}}function Ci(n){return(n.mode&1)!==0&&(n.flags&128)===0}function ru(n){if(Qn){var i=is;if(i){var a=i;if(!nu(n,i)){if(Ci(n))throw Error(r(418));i=Ss(a.nextSibling);var f=Jn;i&&nu(n,i)?Ht(f,a):(n.flags=n.flags&-4097|2,Qn=!1,Jn=n)}}else{if(Ci(n))throw Error(r(418));n.flags=n.flags&-4097|2,Qn=!1,Jn=n}}}function Zu(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;Jn=n}function Ml(n){if(n!==Jn)return!1;if(!Qn)return Zu(n),Qn=!0,!1;var i;if((i=n.tag!==3)&&!(i=n.tag!==5)&&(i=n.type,i=i!=="head"&&i!=="body"&&!Ze(n.type,n.memoizedProps)),i&&(i=is)){if(Ci(n))throw uc(),Error(r(418));for(;i;)Ht(n,i),i=Ss(i.nextSibling)}if(Zu(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));e:{for(n=n.nextSibling,i=0;n;){if(n.nodeType===8){var a=n.data;if(a==="/$"){if(i===0){is=Ss(n.nextSibling);break e}i--}else a!=="$"&&a!=="$!"&&a!=="$?"||i++}n=n.nextSibling}is=null}}else is=Jn?Ss(n.stateNode.nextSibling):null;return!0}function uc(){for(var n=is;n;)n=Ss(n.nextSibling)}function Ei(){is=Jn=null,Qn=!1}function Ya(n){li===null?li=[n]:li.push(n)}var gf=I.ReactCurrentBatchConfig;function ci(n,i,a){if(n=a.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(r(309));var f=a.stateNode}if(!f)throw Error(r(147,n));var p=f,y=""+n;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===y?i.ref:(i=function(A){var q=p.refs;A===null?delete q[y]:q[y]=A},i._stringRef=y,i)}if(typeof n!="string")throw Error(r(284));if(!a._owner)throw Error(r(290,n))}return n}function Xa(n,i){throw n=Object.prototype.toString.call(i),Error(r(31,n==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":n))}function dc(n){var i=n._init;return i(n._payload)}function ys(n){function i(pe,ce){if(n){var ge=pe.deletions;ge===null?(pe.deletions=[ce],pe.flags|=16):ge.push(ce)}}function a(pe,ce){if(!n)return null;for(;ce!==null;)i(pe,ce),ce=ce.sibling;return null}function f(pe,ce){for(pe=new Map;ce!==null;)ce.key!==null?pe.set(ce.key,ce):pe.set(ce.index,ce),ce=ce.sibling;return pe}function p(pe,ce){return pe=il(pe,ce),pe.index=0,pe.sibling=null,pe}function y(pe,ce,ge){return pe.index=ge,n?(ge=pe.alternate,ge!==null?(ge=ge.index,ge<ce?(pe.flags|=2,ce):ge):(pe.flags|=2,ce)):(pe.flags|=1048576,ce)}function A(pe){return n&&pe.alternate===null&&(pe.flags|=2),pe}function q(pe,ce,ge,Je){return ce===null||ce.tag!==6?(ce=Of(ge,pe.mode,Je),ce.return=pe,ce):(ce=p(ce,ge),ce.return=pe,ce)}function ee(pe,ce,ge,Je){var Mt=ge.type;return Mt===Y?We(pe,ce,ge.props.children,Je,ge.key):ce!==null&&(ce.elementType===Mt||typeof Mt=="object"&&Mt!==null&&Mt.$$typeof===V&&dc(Mt)===ce.type)?(Je=p(ce,ge.props),Je.ref=ci(pe,ce,ge),Je.return=pe,Je):(Je=gd(ge.type,ge.key,ge.props,null,pe.mode,Je),Je.ref=ci(pe,ce,ge),Je.return=pe,Je)}function we(pe,ce,ge,Je){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==ge.containerInfo||ce.stateNode.implementation!==ge.implementation?(ce=Df(ge,pe.mode,Je),ce.return=pe,ce):(ce=p(ce,ge.children||[]),ce.return=pe,ce)}function We(pe,ce,ge,Je,Mt){return ce===null||ce.tag!==7?(ce=Hl(ge,pe.mode,Je,Mt),ce.return=pe,ce):(ce=p(ce,ge),ce.return=pe,ce)}function qe(pe,ce,ge){if(typeof ce=="string"&&ce!==""||typeof ce=="number")return ce=Of(""+ce,pe.mode,ge),ce.return=pe,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case G:return ge=gd(ce.type,ce.key,ce.props,null,pe.mode,ge),ge.ref=ci(pe,null,ce),ge.return=pe,ge;case ne:return ce=Df(ce,pe.mode,ge),ce.return=pe,ce;case V:var Je=ce._init;return qe(pe,Je(ce._payload),ge)}if(xe(ce)||z(ce))return ce=Hl(ce,pe.mode,ge,null),ce.return=pe,ce;Xa(pe,ce)}return null}function Ue(pe,ce,ge,Je){var Mt=ce!==null?ce.key:null;if(typeof ge=="string"&&ge!==""||typeof ge=="number")return Mt!==null?null:q(pe,ce,""+ge,Je);if(typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case G:return ge.key===Mt?ee(pe,ce,ge,Je):null;case ne:return ge.key===Mt?we(pe,ce,ge,Je):null;case V:return Mt=ge._init,Ue(pe,ce,Mt(ge._payload),Je)}if(xe(ge)||z(ge))return Mt!==null?null:We(pe,ce,ge,Je,null);Xa(pe,ge)}return null}function ht(pe,ce,ge,Je,Mt){if(typeof Je=="string"&&Je!==""||typeof Je=="number")return pe=pe.get(ge)||null,q(ce,pe,""+Je,Mt);if(typeof Je=="object"&&Je!==null){switch(Je.$$typeof){case G:return pe=pe.get(Je.key===null?ge:Je.key)||null,ee(ce,pe,Je,Mt);case ne:return pe=pe.get(Je.key===null?ge:Je.key)||null,we(ce,pe,Je,Mt);case V:var Dt=Je._init;return ht(pe,ce,ge,Dt(Je._payload),Mt)}if(xe(Je)||z(Je))return pe=pe.get(ge)||null,We(ce,pe,Je,Mt,null);Xa(ce,Je)}return null}function wt(pe,ce,ge,Je){for(var Mt=null,Dt=null,Bt=ce,Jt=ce=0,vs=null;Bt!==null&&Jt<ge.length;Jt++){Bt.index>Jt?(vs=Bt,Bt=null):vs=Bt.sibling;var Pn=Ue(pe,Bt,ge[Jt],Je);if(Pn===null){Bt===null&&(Bt=vs);break}n&&Bt&&Pn.alternate===null&&i(pe,Bt),ce=y(Pn,ce,Jt),Dt===null?Mt=Pn:Dt.sibling=Pn,Dt=Pn,Bt=vs}if(Jt===ge.length)return a(pe,Bt),Qn&&Jo(pe,Jt),Mt;if(Bt===null){for(;Jt<ge.length;Jt++)Bt=qe(pe,ge[Jt],Je),Bt!==null&&(ce=y(Bt,ce,Jt),Dt===null?Mt=Bt:Dt.sibling=Bt,Dt=Bt);return Qn&&Jo(pe,Jt),Mt}for(Bt=f(pe,Bt);Jt<ge.length;Jt++)vs=ht(Bt,pe,Jt,ge[Jt],Je),vs!==null&&(n&&vs.alternate!==null&&Bt.delete(vs.key===null?Jt:vs.key),ce=y(vs,ce,Jt),Dt===null?Mt=vs:Dt.sibling=vs,Dt=vs);return n&&Bt.forEach(function(ol){return i(pe,ol)}),Qn&&Jo(pe,Jt),Mt}function Nt(pe,ce,ge,Je){var Mt=z(ge);if(typeof Mt!="function")throw Error(r(150));if(ge=Mt.call(ge),ge==null)throw Error(r(151));for(var Dt=Mt=null,Bt=ce,Jt=ce=0,vs=null,Pn=ge.next();Bt!==null&&!Pn.done;Jt++,Pn=ge.next()){Bt.index>Jt?(vs=Bt,Bt=null):vs=Bt.sibling;var ol=Ue(pe,Bt,Pn.value,Je);if(ol===null){Bt===null&&(Bt=vs);break}n&&Bt&&ol.alternate===null&&i(pe,Bt),ce=y(ol,ce,Jt),Dt===null?Mt=ol:Dt.sibling=ol,Dt=ol,Bt=vs}if(Pn.done)return a(pe,Bt),Qn&&Jo(pe,Jt),Mt;if(Bt===null){for(;!Pn.done;Jt++,Pn=ge.next())Pn=qe(pe,Pn.value,Je),Pn!==null&&(ce=y(Pn,ce,Jt),Dt===null?Mt=Pn:Dt.sibling=Pn,Dt=Pn);return Qn&&Jo(pe,Jt),Mt}for(Bt=f(pe,Bt);!Pn.done;Jt++,Pn=ge.next())Pn=ht(Bt,pe,Jt,Pn.value,Je),Pn!==null&&(n&&Pn.alternate!==null&&Bt.delete(Pn.key===null?Jt:Pn.key),ce=y(Pn,ce,Jt),Dt===null?Mt=Pn:Dt.sibling=Pn,Dt=Pn);return n&&Bt.forEach(function(Ex){return i(pe,Ex)}),Qn&&Jo(pe,Jt),Mt}function Pr(pe,ce,ge,Je){if(typeof ge=="object"&&ge!==null&&ge.type===Y&&ge.key===null&&(ge=ge.props.children),typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case G:e:{for(var Mt=ge.key,Dt=ce;Dt!==null;){if(Dt.key===Mt){if(Mt=ge.type,Mt===Y){if(Dt.tag===7){a(pe,Dt.sibling),ce=p(Dt,ge.props.children),ce.return=pe,pe=ce;break e}}else if(Dt.elementType===Mt||typeof Mt=="object"&&Mt!==null&&Mt.$$typeof===V&&dc(Mt)===Dt.type){a(pe,Dt.sibling),ce=p(Dt,ge.props),ce.ref=ci(pe,Dt,ge),ce.return=pe,pe=ce;break e}a(pe,Dt);break}else i(pe,Dt);Dt=Dt.sibling}ge.type===Y?(ce=Hl(ge.props.children,pe.mode,Je,ge.key),ce.return=pe,pe=ce):(Je=gd(ge.type,ge.key,ge.props,null,pe.mode,Je),Je.ref=ci(pe,ce,ge),Je.return=pe,pe=Je)}return A(pe);case ne:e:{for(Dt=ge.key;ce!==null;){if(ce.key===Dt)if(ce.tag===4&&ce.stateNode.containerInfo===ge.containerInfo&&ce.stateNode.implementation===ge.implementation){a(pe,ce.sibling),ce=p(ce,ge.children||[]),ce.return=pe,pe=ce;break e}else{a(pe,ce);break}else i(pe,ce);ce=ce.sibling}ce=Df(ge,pe.mode,Je),ce.return=pe,pe=ce}return A(pe);case V:return Dt=ge._init,Pr(pe,ce,Dt(ge._payload),Je)}if(xe(ge))return wt(pe,ce,ge,Je);if(z(ge))return Nt(pe,ce,ge,Je);Xa(pe,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"?(ge=""+ge,ce!==null&&ce.tag===6?(a(pe,ce.sibling),ce=p(ce,ge),ce.return=pe,pe=ce):(a(pe,ce),ce=Of(ge,pe.mode,Je),ce.return=pe,pe=ce),A(pe)):a(pe,ce)}return Pr}var Qo=ys(!0),ed=ys(!1),zl=Xo(null),fc=null,Sa=null,mc=null;function hc(){mc=Sa=fc=null}function Rl(n){var i=zl.current;Kn(zl),n._currentValue=i}function su(n,i,a){for(;n!==null;){var f=n.alternate;if((n.childLanes&i)!==i?(n.childLanes|=i,f!==null&&(f.childLanes|=i)):f!==null&&(f.childLanes&i)!==i&&(f.childLanes|=i),n===a)break;n=n.return}}function ja(n,i){fc=n,mc=Sa=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&i)!==0&&(di=!0),n.firstContext=null)}function Qs(n){var i=n._currentValue;if(mc!==n)if(n={context:n,memoizedValue:i,next:null},Sa===null){if(fc===null)throw Error(r(308));Sa=n,fc.dependencies={lanes:0,firstContext:n}}else Sa=Sa.next=n;return i}var Zo=null;function pc(n){Zo===null?Zo=[n]:Zo.push(n)}function iu(n,i,a,f){var p=i.interleaved;return p===null?(a.next=a,pc(i)):(a.next=p.next,p.next=a),i.interleaved=a,Ki(n,f)}function Ki(n,i){n.lanes|=i;var a=n.alternate;for(a!==null&&(a.lanes|=i),a=n,n=n.return;n!==null;)n.childLanes|=i,a=n.alternate,a!==null&&(a.childLanes|=i),a=n,n=n.return;return a.tag===3?a.stateNode:null}var ko=!1;function gc(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ou(n,i){n=n.updateQueue,i.updateQueue===n&&(i.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function Ji(n,i){return{eventTime:n,lane:i,tag:0,payload:null,callback:null,next:null}}function No(n,i,a){var f=n.updateQueue;if(f===null)return null;if(f=f.shared,(Mn&2)!==0){var p=f.pending;return p===null?i.next=i:(i.next=p.next,p.next=i),f.pending=i,Ki(n,a)}return p=f.interleaved,p===null?(i.next=i,pc(f)):(i.next=p.next,p.next=i),f.interleaved=i,Ki(n,a)}function Ll(n,i,a){if(i=i.updateQueue,i!==null&&(i=i.shared,(a&4194240)!==0)){var f=i.lanes;f&=n.pendingLanes,a|=f,i.lanes=a,Li(n,a)}}function au(n,i){var a=n.updateQueue,f=n.alternate;if(f!==null&&(f=f.updateQueue,a===f)){var p=null,y=null;if(a=a.firstBaseUpdate,a!==null){do{var A={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};y===null?p=y=A:y=y.next=A,a=a.next}while(a!==null);y===null?p=y=i:y=y.next=i}else p=y=i;a={baseState:f.baseState,firstBaseUpdate:p,lastBaseUpdate:y,shared:f.shared,effects:f.effects},n.updateQueue=a;return}n=a.lastBaseUpdate,n===null?a.firstBaseUpdate=i:n.next=i,a.lastBaseUpdate=i}function Pl(n,i,a,f){var p=n.updateQueue;ko=!1;var y=p.firstBaseUpdate,A=p.lastBaseUpdate,q=p.shared.pending;if(q!==null){p.shared.pending=null;var ee=q,we=ee.next;ee.next=null,A===null?y=we:A.next=we,A=ee;var We=n.alternate;We!==null&&(We=We.updateQueue,q=We.lastBaseUpdate,q!==A&&(q===null?We.firstBaseUpdate=we:q.next=we,We.lastBaseUpdate=ee))}if(y!==null){var qe=p.baseState;A=0,We=we=ee=null,q=y;do{var Ue=q.lane,ht=q.eventTime;if((f&Ue)===Ue){We!==null&&(We=We.next={eventTime:ht,lane:0,tag:q.tag,payload:q.payload,callback:q.callback,next:null});e:{var wt=n,Nt=q;switch(Ue=i,ht=a,Nt.tag){case 1:if(wt=Nt.payload,typeof wt=="function"){qe=wt.call(ht,qe,Ue);break e}qe=wt;break e;case 3:wt.flags=wt.flags&-65537|128;case 0:if(wt=Nt.payload,Ue=typeof wt=="function"?wt.call(ht,qe,Ue):wt,Ue==null)break e;qe=F({},qe,Ue);break e;case 2:ko=!0}}q.callback!==null&&q.lane!==0&&(n.flags|=64,Ue=p.effects,Ue===null?p.effects=[q]:Ue.push(q))}else ht={eventTime:ht,lane:Ue,tag:q.tag,payload:q.payload,callback:q.callback,next:null},We===null?(we=We=ht,ee=qe):We=We.next=ht,A|=Ue;if(q=q.next,q===null){if(q=p.shared.pending,q===null)break;Ue=q,q=Ue.next,Ue.next=null,p.lastBaseUpdate=Ue,p.shared.pending=null}}while(!0);if(We===null&&(ee=qe),p.baseState=ee,p.firstBaseUpdate=we,p.lastBaseUpdate=We,i=p.shared.interleaved,i!==null){p=i;do A|=p.lane,p=p.next;while(p!==i)}else y===null&&(p.shared.lanes=0);Dl|=A,n.lanes=A,n.memoizedState=qe}}function lu(n,i,a){if(n=i.effects,i.effects=null,n!==null)for(i=0;i<n.length;i++){var f=n[i],p=f.callback;if(p!==null){if(f.callback=null,f=a,typeof p!="function")throw Error(r(191,p));p.call(f)}}}var Ka={},$i=Xo(Ka),Ja=Xo(Ka),Qa=Xo(Ka);function ea(n){if(n===Ka)throw Error(r(174));return n}function _c(n,i){switch(Wn(Qa,i),Wn(Ja,n),Wn($i,Ka),n=i.nodeType,n){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:ue(null,"");break;default:n=n===8?i.parentNode:i,i=n.namespaceURI||null,n=n.tagName,i=ue(i,n)}Kn($i),Wn($i,i)}function ka(){Kn($i),Kn(Ja),Kn(Qa)}function cu(n){ea(Qa.current);var i=ea($i.current),a=ue(i,n.type);i!==a&&(Wn(Ja,n),Wn($i,a))}function yc(n){Ja.current===n&&(Kn($i),Kn(Ja))}var rr=Xo(0);function Il(n){for(var i=n;i!==null;){if(i.tag===13){var a=i.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var xc=[];function vc(){for(var n=0;n<xc.length;n++)xc[n]._workInProgressVersionPrimary=null;xc.length=0}var Fl=I.ReactCurrentDispatcher,wc=I.ReactCurrentBatchConfig,ta=0,sr=null,xr=null,Lr=null,w=!1,$=!1,P=0,E=0;function H(){throw Error(r(321))}function Q(n,i){if(i===null)return!1;for(var a=0;a<i.length&&a<n.length;a++)if(!ns(n[a],i[a]))return!1;return!0}function ae(n,i,a,f,p,y){if(ta=y,sr=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,Fl.current=n===null||n.memoizedState===null?rd:mu,n=a(f,p),$){y=0;do{if($=!1,P=0,25<=y)throw Error(r(301));y+=1,Lr=xr=null,i.updateQueue=null,Fl.current=jc,n=a(f,p)}while($)}if(Fl.current=Ea,i=xr!==null&&xr.next!==null,ta=0,Lr=xr=sr=null,w=!1,i)throw Error(r(300));return n}function re(){var n=P!==0;return P=0,n}function Le(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Lr===null?sr.memoizedState=Lr=n:Lr=Lr.next=n,Lr}function ye(){if(xr===null){var n=sr.alternate;n=n!==null?n.memoizedState:null}else n=xr.next;var i=Lr===null?sr.memoizedState:Lr.next;if(i!==null)Lr=i,xr=n;else{if(n===null)throw Error(r(310));xr=n,n={memoizedState:xr.memoizedState,baseState:xr.baseState,baseQueue:xr.baseQueue,queue:xr.queue,next:null},Lr===null?sr.memoizedState=Lr=n:Lr=Lr.next=n}return Lr}function Be(n,i){return typeof i=="function"?i(n):i}function vt(n){var i=ye(),a=i.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=n;var f=xr,p=f.baseQueue,y=a.pending;if(y!==null){if(p!==null){var A=p.next;p.next=y.next,y.next=A}f.baseQueue=p=y,a.pending=null}if(p!==null){y=p.next,f=f.baseState;var q=A=null,ee=null,we=y;do{var We=we.lane;if((ta&We)===We)ee!==null&&(ee=ee.next={lane:0,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null}),f=we.hasEagerState?we.eagerState:n(f,we.action);else{var qe={lane:We,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null};ee===null?(q=ee=qe,A=f):ee=ee.next=qe,sr.lanes|=We,Dl|=We}we=we.next}while(we!==null&&we!==y);ee===null?A=f:ee.next=q,ns(f,i.memoizedState)||(di=!0),i.memoizedState=f,i.baseState=A,i.baseQueue=ee,a.lastRenderedState=f}if(n=a.interleaved,n!==null){p=n;do y=p.lane,sr.lanes|=y,Dl|=y,p=p.next;while(p!==n)}else p===null&&(a.lanes=0);return[i.memoizedState,a.dispatch]}function ut(n){var i=ye(),a=i.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=n;var f=a.dispatch,p=a.pending,y=i.memoizedState;if(p!==null){a.pending=null;var A=p=p.next;do y=n(y,A.action),A=A.next;while(A!==p);ns(y,i.memoizedState)||(di=!0),i.memoizedState=y,i.baseQueue===null&&(i.baseState=y),a.lastRenderedState=y}return[y,f]}function mt(){}function Ct(n,i){var a=sr,f=ye(),p=i(),y=!ns(f.memoizedState,p);if(y&&(f.memoizedState=p,di=!0),f=f.queue,Ai(mn.bind(null,a,f,n),[n]),f.getSnapshot!==i||y||Lr!==null&&Lr.memoizedState.tag&1){if(a.flags|=2048,xt(9,kt.bind(null,a,f,p,i),void 0,null),xs===null)throw Error(r(349));(ta&30)!==0||ot(a,i,p)}return p}function ot(n,i,a){n.flags|=16384,n={getSnapshot:i,value:a},i=sr.updateQueue,i===null?(i={lastEffect:null,stores:null},sr.updateQueue=i,i.stores=[n]):(a=i.stores,a===null?i.stores=[n]:a.push(n))}function kt(n,i,a,f){i.value=a,i.getSnapshot=f,on(i)&&Ve(n)}function mn(n,i,a){return a(function(){on(i)&&Ve(n)})}function on(n){var i=n.getSnapshot;n=n.value;try{var a=i();return!ns(n,a)}catch{return!0}}function Ve(n){var i=Ki(n,1);i!==null&&To(i,n,1,-1)}function Ke(n){var i=Le();return typeof n=="function"&&(n=n()),i.memoizedState=i.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Be,lastRenderedState:n},i.queue=n,n=n.dispatch=Zi.bind(null,sr,n),[i.memoizedState,n]}function xt(n,i,a,f){return n={tag:n,create:i,destroy:a,deps:f,next:null},i=sr.updateQueue,i===null?(i={lastEffect:null,stores:null},sr.updateQueue=i,i.lastEffect=n.next=n):(a=i.lastEffect,a===null?i.lastEffect=n.next=n:(f=a.next,a.next=n,n.next=f,i.lastEffect=n)),n}function tn(){return ye().memoizedState}function Tt(n,i,a,f){var p=Le();sr.flags|=n,p.memoizedState=xt(1|i,a,void 0,f===void 0?null:f)}function Hn(n,i,a,f){var p=ye();f=f===void 0?null:f;var y=void 0;if(xr!==null){var A=xr.memoizedState;if(y=A.destroy,f!==null&&Q(f,A.deps)){p.memoizedState=xt(i,a,y,f);return}}sr.flags|=n,p.memoizedState=xt(1|i,a,y,f)}function Ds(n,i){return Tt(8390656,8,n,i)}function Ai(n,i){return Hn(2048,8,n,i)}function ui(n,i){return Hn(4,2,n,i)}function vr(n,i){return Hn(4,4,n,i)}function td(n,i){if(typeof i=="function")return n=n(),i(n),function(){i(null)};if(i!=null)return n=n(),i.current=n,function(){i.current=null}}function nd(n,i,a){return a=a!=null?a.concat([n]):null,Hn(4,4,td.bind(null,i,n),a)}function bc(){}function uu(n,i){var a=ye();i=i===void 0?null:i;var f=a.memoizedState;return f!==null&&i!==null&&Q(i,f[1])?f[0]:(a.memoizedState=[n,i],n)}function du(n,i){var a=ye();i=i===void 0?null:i;var f=a.memoizedState;return f!==null&&i!==null&&Q(i,f[1])?f[0]:(n=n(),a.memoizedState=[n,i],n)}function gt(n,i,a){return(ta&21)===0?(n.baseState&&(n.baseState=!1,di=!0),n.memoizedState=a):(ns(a,i)||(a=er(),sr.lanes|=a,Dl|=a,n.baseState=!0),i)}function Co(n,i){var a=rn;rn=a!==0&&4>a?a:4,n(!0);var f=wc.transition;wc.transition={};try{n(!1),i()}finally{rn=a,wc.transition=f}}function Na(){return ye().memoizedState}function Qi(n,i,a){var f=rl(n);if(a={lane:f,action:a,hasEagerState:!1,eagerState:null,next:null},Ca(n))Sc(i,a);else if(a=iu(n,i,a,f),a!==null){var p=ti();To(a,n,f,p),fu(a,i,f)}}function Zi(n,i,a){var f=rl(n),p={lane:f,action:a,hasEagerState:!1,eagerState:null,next:null};if(Ca(n))Sc(i,p);else{var y=n.alternate;if(n.lanes===0&&(y===null||y.lanes===0)&&(y=i.lastRenderedReducer,y!==null))try{var A=i.lastRenderedState,q=y(A,a);if(p.hasEagerState=!0,p.eagerState=q,ns(q,A)){var ee=i.interleaved;ee===null?(p.next=p,pc(i)):(p.next=ee.next,ee.next=p),i.interleaved=p;return}}catch{}finally{}a=iu(n,i,p,f),a!==null&&(p=ti(),To(a,n,f,p),fu(a,i,f))}}function Ca(n){var i=n.alternate;return n===sr||i!==null&&i===sr}function Sc(n,i){$=w=!0;var a=n.pending;a===null?i.next=i:(i.next=a.next,a.next=i),n.pending=i}function fu(n,i,a){if((a&4194240)!==0){var f=i.lanes;f&=n.pendingLanes,a|=f,i.lanes=a,Li(n,a)}}var Ea={readContext:Qs,useCallback:H,useContext:H,useEffect:H,useImperativeHandle:H,useInsertionEffect:H,useLayoutEffect:H,useMemo:H,useReducer:H,useRef:H,useState:H,useDebugValue:H,useDeferredValue:H,useTransition:H,useMutableSource:H,useSyncExternalStore:H,useId:H,unstable_isNewReconciler:!1},rd={readContext:Qs,useCallback:function(n,i){return Le().memoizedState=[n,i===void 0?null:i],n},useContext:Qs,useEffect:Ds,useImperativeHandle:function(n,i,a){return a=a!=null?a.concat([n]):null,Tt(4194308,4,td.bind(null,i,n),a)},useLayoutEffect:function(n,i){return Tt(4194308,4,n,i)},useInsertionEffect:function(n,i){return Tt(4,2,n,i)},useMemo:function(n,i){var a=Le();return i=i===void 0?null:i,n=n(),a.memoizedState=[n,i],n},useReducer:function(n,i,a){var f=Le();return i=a!==void 0?a(i):i,f.memoizedState=f.baseState=i,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:i},f.queue=n,n=n.dispatch=Qi.bind(null,sr,n),[f.memoizedState,n]},useRef:function(n){var i=Le();return n={current:n},i.memoizedState=n},useState:Ke,useDebugValue:bc,useDeferredValue:function(n){return Le().memoizedState=n},useTransition:function(){var n=Ke(!1),i=n[0];return n=Co.bind(null,n[1]),Le().memoizedState=n,[i,n]},useMutableSource:function(){},useSyncExternalStore:function(n,i,a){var f=sr,p=Le();if(Qn){if(a===void 0)throw Error(r(407));a=a()}else{if(a=i(),xs===null)throw Error(r(349));(ta&30)!==0||ot(f,i,a)}p.memoizedState=a;var y={value:a,getSnapshot:i};return p.queue=y,Ds(mn.bind(null,f,y,n),[n]),f.flags|=2048,xt(9,kt.bind(null,f,y,a,i),void 0,null),a},useId:function(){var n=Le(),i=xs.identifierPrefix;if(Qn){var a=Ni,f=Rr;a=(f&~(1<<32-kr(f)-1)).toString(32)+a,i=":"+i+"R"+a,a=P++,0<a&&(i+="H"+a.toString(32)),i+=":"}else a=E++,i=":"+i+"r"+a.toString(32)+":";return n.memoizedState=i},unstable_isNewReconciler:!1},mu={readContext:Qs,useCallback:uu,useContext:Qs,useEffect:Ai,useImperativeHandle:nd,useInsertionEffect:ui,useLayoutEffect:vr,useMemo:du,useReducer:vt,useRef:tn,useState:function(){return vt(Be)},useDebugValue:bc,useDeferredValue:function(n){var i=ye();return gt(i,xr.memoizedState,n)},useTransition:function(){var n=vt(Be)[0],i=ye().memoizedState;return[n,i]},useMutableSource:mt,useSyncExternalStore:Ct,useId:Na,unstable_isNewReconciler:!1},jc={readContext:Qs,useCallback:uu,useContext:Qs,useEffect:Ai,useImperativeHandle:nd,useInsertionEffect:ui,useLayoutEffect:vr,useMemo:du,useReducer:ut,useRef:tn,useState:function(){return ut(Be)},useDebugValue:bc,useDeferredValue:function(n){var i=ye();return xr===null?i.memoizedState=n:gt(i,xr.memoizedState,n)},useTransition:function(){var n=ut(Be)[0],i=ye().memoizedState;return[n,i]},useMutableSource:mt,useSyncExternalStore:Ct,useId:Na,unstable_isNewReconciler:!1};function Tn(n,i){if(n&&n.defaultProps){i=F({},i),n=n.defaultProps;for(var a in n)i[a]===void 0&&(i[a]=n[a]);return i}return i}function wr(n,i,a,f){i=n.memoizedState,a=a(f,i),a=a==null?i:F({},i,a),n.memoizedState=a,n.lanes===0&&(n.updateQueue.baseState=a)}var Gr={isMounted:function(n){return(n=n._reactInternals)?Nn(n)===n:!1},enqueueSetState:function(n,i,a){n=n._reactInternals;var f=ti(),p=rl(n),y=Ji(f,p);y.payload=i,a!=null&&(y.callback=a),i=No(n,y,p),i!==null&&(To(i,n,p,f),Ll(i,n,p))},enqueueReplaceState:function(n,i,a){n=n._reactInternals;var f=ti(),p=rl(n),y=Ji(f,p);y.tag=1,y.payload=i,a!=null&&(y.callback=a),i=No(n,y,p),i!==null&&(To(i,n,p,f),Ll(i,n,p))},enqueueForceUpdate:function(n,i){n=n._reactInternals;var a=ti(),f=rl(n),p=Ji(a,f);p.tag=2,i!=null&&(p.callback=i),i=No(n,p,f),i!==null&&(To(i,n,f,a),Ll(i,n,f))}};function eo(n,i,a,f,p,y,A){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(f,y,A):i.prototype&&i.prototype.isPureReactComponent?!Xs(a,f)||!Xs(p,y):!0}function to(n,i,a){var f=!1,p=Xi,y=i.contextType;return typeof y=="object"&&y!==null?y=Qs(y):(p=rs(i)?So:gs.current,f=i.contextTypes,y=(f=f!=null)?qa(n,p):Xi),i=new i(a,y),n.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=Gr,n.stateNode=i,i._reactInternals=n,f&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=p,n.__reactInternalMemoizedMaskedChildContext=y),i}function Zs(n,i,a,f){n=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(a,f),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(a,f),i.state!==n&&Gr.enqueueReplaceState(i,i.state,null)}function Ol(n,i,a,f){var p=n.stateNode;p.props=a,p.state=n.memoizedState,p.refs={},gc(n);var y=i.contextType;typeof y=="object"&&y!==null?p.context=Qs(y):(y=rs(i)?So:gs.current,p.context=qa(n,y)),p.state=n.memoizedState,y=i.getDerivedStateFromProps,typeof y=="function"&&(wr(n,i,y,a),p.state=n.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(i=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),i!==p.state&&Gr.enqueueReplaceState(p,p.state,null),Pl(n,a,p,f),p.state=n.memoizedState),typeof p.componentDidMount=="function"&&(n.flags|=4194308)}function na(n,i){try{var a="",f=i;do a+=he(f),f=f.return;while(f);var p=a}catch(y){p=`
|
|
39
|
+
Error generating stack: `+y.message+`
|
|
40
|
+
`+y.stack}return{value:n,source:i,stack:p,digest:null}}function Eo(n,i,a){return{value:n,source:null,stack:a??null,digest:i??null}}function ra(n,i){try{console.error(i.value)}catch(a){setTimeout(function(){throw a})}}var Za=typeof WeakMap=="function"?WeakMap:Map;function jh(n,i,a){a=Ji(-1,a),a.tag=3,a.payload={element:null};var f=i.value;return a.callback=function(){ud||(ud=!0,Tf=f),ra(n,i)},a}function kh(n,i,a){a=Ji(-1,a),a.tag=3;var f=n.type.getDerivedStateFromError;if(typeof f=="function"){var p=i.value;a.payload=function(){return f(p)},a.callback=function(){ra(n,i)}}var y=n.stateNode;return y!==null&&typeof y.componentDidCatch=="function"&&(a.callback=function(){ra(n,i),typeof f!="function"&&(tl===null?tl=new Set([this]):tl.add(this));var A=i.stack;this.componentDidCatch(i.value,{componentStack:A!==null?A:""})}),a}function Nh(n,i,a){var f=n.pingCache;if(f===null){f=n.pingCache=new Za;var p=new Set;f.set(i,p)}else p=f.get(i),p===void 0&&(p=new Set,f.set(i,p));p.has(a)||(p.add(a),n=_x.bind(null,n,i,a),i.then(n,n))}function Ch(n){do{var i;if((i=n.tag===13)&&(i=n.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return n;n=n.return}while(n!==null);return null}function Eh(n,i,a,f,p){return(n.mode&1)===0?(n===i?n.flags|=65536:(n.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(i=Ji(-1,1),i.tag=2,No(a,i,1))),a.lanes|=1),n):(n.flags|=65536,n.lanes=p,n)}var sx=I.ReactCurrentOwner,di=!1;function ei(n,i,a,f){i.child=n===null?ed(i,null,a,f):Qo(i,n.child,a,f)}function $h(n,i,a,f,p){a=a.render;var y=i.ref;return ja(i,p),f=ae(n,i,a,f,y,p),a=re(),n!==null&&!di?(i.updateQueue=n.updateQueue,i.flags&=-2053,n.lanes&=~p,$a(n,i,p)):(Qn&&a&&eu(i),i.flags|=1,ei(n,i,f,p),i.child)}function Ah(n,i,a,f,p){if(n===null){var y=a.type;return typeof y=="function"&&!Ff(y)&&y.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(i.tag=15,i.type=y,Th(n,i,y,f,p)):(n=gd(a.type,null,f,i,i.mode,p),n.ref=i.ref,n.return=i,i.child=n)}if(y=n.child,(n.lanes&p)===0){var A=y.memoizedProps;if(a=a.compare,a=a!==null?a:Xs,a(A,f)&&n.ref===i.ref)return $a(n,i,p)}return i.flags|=1,n=il(y,f),n.ref=i.ref,n.return=i,i.child=n}function Th(n,i,a,f,p){if(n!==null){var y=n.memoizedProps;if(Xs(y,f)&&n.ref===i.ref)if(di=!1,i.pendingProps=f=y,(n.lanes&p)!==0)(n.flags&131072)!==0&&(di=!0);else return i.lanes=n.lanes,$a(n,i,p)}return _f(n,i,a,f,p)}function Mh(n,i,a){var f=i.pendingProps,p=f.children,y=n!==null?n.memoizedState:null;if(f.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},Wn(Nc,Ti),Ti|=a;else{if((a&1073741824)===0)return n=y!==null?y.baseLanes|a:a,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:n,cachePool:null,transitions:null},i.updateQueue=null,Wn(Nc,Ti),Ti|=n,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},f=y!==null?y.baseLanes:a,Wn(Nc,Ti),Ti|=f}else y!==null?(f=y.baseLanes|a,i.memoizedState=null):f=a,Wn(Nc,Ti),Ti|=f;return ei(n,i,p,a),i.child}function zh(n,i){var a=i.ref;(n===null&&a!==null||n!==null&&n.ref!==a)&&(i.flags|=512,i.flags|=2097152)}function _f(n,i,a,f,p){var y=rs(a)?So:gs.current;return y=qa(i,y),ja(i,p),a=ae(n,i,a,f,y,p),f=re(),n!==null&&!di?(i.updateQueue=n.updateQueue,i.flags&=-2053,n.lanes&=~p,$a(n,i,p)):(Qn&&f&&eu(i),i.flags|=1,ei(n,i,a,p),i.child)}function Rh(n,i,a,f,p){if(rs(a)){var y=!0;lc(i)}else y=!1;if(ja(i,p),i.stateNode===null)id(n,i),to(i,a,f),Ol(i,a,f,p),f=!0;else if(n===null){var A=i.stateNode,q=i.memoizedProps;A.props=q;var ee=A.context,we=a.contextType;typeof we=="object"&&we!==null?we=Qs(we):(we=rs(a)?So:gs.current,we=qa(i,we));var We=a.getDerivedStateFromProps,qe=typeof We=="function"||typeof A.getSnapshotBeforeUpdate=="function";qe||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(q!==f||ee!==we)&&Zs(i,A,f,we),ko=!1;var Ue=i.memoizedState;A.state=Ue,Pl(i,f,A,p),ee=i.memoizedState,q!==f||Ue!==ee||Fs.current||ko?(typeof We=="function"&&(wr(i,a,We,f),ee=i.memoizedState),(q=ko||eo(i,a,q,f,Ue,ee,we))?(qe||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(i.flags|=4194308)):(typeof A.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=f,i.memoizedState=ee),A.props=f,A.state=ee,A.context=we,f=q):(typeof A.componentDidMount=="function"&&(i.flags|=4194308),f=!1)}else{A=i.stateNode,ou(n,i),q=i.memoizedProps,we=i.type===i.elementType?q:Tn(i.type,q),A.props=we,qe=i.pendingProps,Ue=A.context,ee=a.contextType,typeof ee=="object"&&ee!==null?ee=Qs(ee):(ee=rs(a)?So:gs.current,ee=qa(i,ee));var ht=a.getDerivedStateFromProps;(We=typeof ht=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(q!==qe||Ue!==ee)&&Zs(i,A,f,ee),ko=!1,Ue=i.memoizedState,A.state=Ue,Pl(i,f,A,p);var wt=i.memoizedState;q!==qe||Ue!==wt||Fs.current||ko?(typeof ht=="function"&&(wr(i,a,ht,f),wt=i.memoizedState),(we=ko||eo(i,a,we,f,Ue,wt,ee)||!1)?(We||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(f,wt,ee),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(f,wt,ee)),typeof A.componentDidUpdate=="function"&&(i.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof A.componentDidUpdate!="function"||q===n.memoizedProps&&Ue===n.memoizedState||(i.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||q===n.memoizedProps&&Ue===n.memoizedState||(i.flags|=1024),i.memoizedProps=f,i.memoizedState=wt),A.props=f,A.state=wt,A.context=ee,f=we):(typeof A.componentDidUpdate!="function"||q===n.memoizedProps&&Ue===n.memoizedState||(i.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||q===n.memoizedProps&&Ue===n.memoizedState||(i.flags|=1024),f=!1)}return yf(n,i,a,f,y,p)}function yf(n,i,a,f,p,y){zh(n,i);var A=(i.flags&128)!==0;if(!f&&!A)return p&&cc(i,a,!1),$a(n,i,y);f=i.stateNode,sx.current=i;var q=A&&typeof a.getDerivedStateFromError!="function"?null:f.render();return i.flags|=1,n!==null&&A?(i.child=Qo(i,n.child,null,y),i.child=Qo(i,null,q,y)):ei(n,i,q,y),i.memoizedState=f.state,p&&cc(i,a,!0),i.child}function Lh(n){var i=n.stateNode;i.pendingContext?qr(n,i.pendingContext,i.pendingContext!==i.context):i.context&&qr(n,i.context,!1),_c(n,i.containerInfo)}function Ph(n,i,a,f,p){return Ei(),Ya(p),i.flags|=256,ei(n,i,a,f),i.child}var xf={dehydrated:null,treeContext:null,retryLane:0};function vf(n){return{baseLanes:n,cachePool:null,transitions:null}}function Ih(n,i,a){var f=i.pendingProps,p=rr.current,y=!1,A=(i.flags&128)!==0,q;if((q=A)||(q=n!==null&&n.memoizedState===null?!1:(p&2)!==0),q?(y=!0,i.flags&=-129):(n===null||n.memoizedState!==null)&&(p|=1),Wn(rr,p&1),n===null)return ru(i),n=i.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((i.mode&1)===0?i.lanes=1:n.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(A=f.children,n=f.fallback,y?(f=i.mode,y=i.child,A={mode:"hidden",children:A},(f&1)===0&&y!==null?(y.childLanes=0,y.pendingProps=A):y=_d(A,f,0,null),n=Hl(n,f,a,null),y.return=i,n.return=i,y.sibling=n,i.child=y,i.child.memoizedState=vf(a),i.memoizedState=xf,n):wf(i,A));if(p=n.memoizedState,p!==null&&(q=p.dehydrated,q!==null))return ix(n,i,A,f,q,p,a);if(y){y=f.fallback,A=i.mode,p=n.child,q=p.sibling;var ee={mode:"hidden",children:f.children};return(A&1)===0&&i.child!==p?(f=i.child,f.childLanes=0,f.pendingProps=ee,i.deletions=null):(f=il(p,ee),f.subtreeFlags=p.subtreeFlags&14680064),q!==null?y=il(q,y):(y=Hl(y,A,a,null),y.flags|=2),y.return=i,f.return=i,f.sibling=y,i.child=f,f=y,y=i.child,A=n.child.memoizedState,A=A===null?vf(a):{baseLanes:A.baseLanes|a,cachePool:null,transitions:A.transitions},y.memoizedState=A,y.childLanes=n.childLanes&~a,i.memoizedState=xf,f}return y=n.child,n=y.sibling,f=il(y,{mode:"visible",children:f.children}),(i.mode&1)===0&&(f.lanes=a),f.return=i,f.sibling=null,n!==null&&(a=i.deletions,a===null?(i.deletions=[n],i.flags|=16):a.push(n)),i.child=f,i.memoizedState=null,f}function wf(n,i){return i=_d({mode:"visible",children:i},n.mode,0,null),i.return=n,n.child=i}function sd(n,i,a,f){return f!==null&&Ya(f),Qo(i,n.child,null,a),n=wf(i,i.pendingProps.children),n.flags|=2,i.memoizedState=null,n}function ix(n,i,a,f,p,y,A){if(a)return i.flags&256?(i.flags&=-257,f=Eo(Error(r(422))),sd(n,i,A,f)):i.memoizedState!==null?(i.child=n.child,i.flags|=128,null):(y=f.fallback,p=i.mode,f=_d({mode:"visible",children:f.children},p,0,null),y=Hl(y,p,A,null),y.flags|=2,f.return=i,y.return=i,f.sibling=y,i.child=f,(i.mode&1)!==0&&Qo(i,n.child,null,A),i.child.memoizedState=vf(A),i.memoizedState=xf,y);if((i.mode&1)===0)return sd(n,i,A,null);if(p.data==="$!"){if(f=p.nextSibling&&p.nextSibling.dataset,f)var q=f.dgst;return f=q,y=Error(r(419)),f=Eo(y,f,void 0),sd(n,i,A,f)}if(q=(A&n.childLanes)!==0,di||q){if(f=xs,f!==null){switch(A&-A){case 4:p=2;break;case 16:p=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:p=32;break;case 536870912:p=268435456;break;default:p=0}p=(p&(f.suspendedLanes|A))!==0?0:p,p!==0&&p!==y.retryLane&&(y.retryLane=p,Ki(n,p),To(f,n,p,-1))}return If(),f=Eo(Error(r(421))),sd(n,i,A,f)}return p.data==="$?"?(i.flags|=128,i.child=n.child,i=yx.bind(null,n),p._reactRetry=i,null):(n=y.treeContext,is=Ss(p.nextSibling),Jn=i,Qn=!0,li=null,n!==null&&(ss[ai++]=Rr,ss[ai++]=Ni,ss[ai++]=Ko,Rr=n.id,Ni=n.overflow,Ko=i),i=wf(i,f.children),i.flags|=4096,i)}function Fh(n,i,a){n.lanes|=i;var f=n.alternate;f!==null&&(f.lanes|=i),su(n.return,i,a)}function bf(n,i,a,f,p){var y=n.memoizedState;y===null?n.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:f,tail:a,tailMode:p}:(y.isBackwards=i,y.rendering=null,y.renderingStartTime=0,y.last=f,y.tail=a,y.tailMode=p)}function Oh(n,i,a){var f=i.pendingProps,p=f.revealOrder,y=f.tail;if(ei(n,i,f.children,a),f=rr.current,(f&2)!==0)f=f&1|2,i.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=i.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Fh(n,a,i);else if(n.tag===19)Fh(n,a,i);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break e;for(;n.sibling===null;){if(n.return===null||n.return===i)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}f&=1}if(Wn(rr,f),(i.mode&1)===0)i.memoizedState=null;else switch(p){case"forwards":for(a=i.child,p=null;a!==null;)n=a.alternate,n!==null&&Il(n)===null&&(p=a),a=a.sibling;a=p,a===null?(p=i.child,i.child=null):(p=a.sibling,a.sibling=null),bf(i,!1,p,a,y);break;case"backwards":for(a=null,p=i.child,i.child=null;p!==null;){if(n=p.alternate,n!==null&&Il(n)===null){i.child=p;break}n=p.sibling,p.sibling=a,a=p,p=n}bf(i,!0,a,null,y);break;case"together":bf(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function id(n,i){(i.mode&1)===0&&n!==null&&(n.alternate=null,i.alternate=null,i.flags|=2)}function $a(n,i,a){if(n!==null&&(i.dependencies=n.dependencies),Dl|=i.lanes,(a&i.childLanes)===0)return null;if(n!==null&&i.child!==n.child)throw Error(r(153));if(i.child!==null){for(n=i.child,a=il(n,n.pendingProps),i.child=a,a.return=i;n.sibling!==null;)n=n.sibling,a=a.sibling=il(n,n.pendingProps),a.return=i;a.sibling=null}return i.child}function ox(n,i,a){switch(i.tag){case 3:Lh(i),Ei();break;case 5:cu(i);break;case 1:rs(i.type)&&lc(i);break;case 4:_c(i,i.stateNode.containerInfo);break;case 10:var f=i.type._context,p=i.memoizedProps.value;Wn(zl,f._currentValue),f._currentValue=p;break;case 13:if(f=i.memoizedState,f!==null)return f.dehydrated!==null?(Wn(rr,rr.current&1),i.flags|=128,null):(a&i.child.childLanes)!==0?Ih(n,i,a):(Wn(rr,rr.current&1),n=$a(n,i,a),n!==null?n.sibling:null);Wn(rr,rr.current&1);break;case 19:if(f=(a&i.childLanes)!==0,(n.flags&128)!==0){if(f)return Oh(n,i,a);i.flags|=128}if(p=i.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),Wn(rr,rr.current),f)break;return null;case 22:case 23:return i.lanes=0,Mh(n,i,a)}return $a(n,i,a)}var Dh,Sf,Bh,Uh;Dh=function(n,i){for(var a=i.child;a!==null;){if(a.tag===5||a.tag===6)n.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===i)break;for(;a.sibling===null;){if(a.return===null||a.return===i)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},Sf=function(){},Bh=function(n,i,a,f){var p=n.memoizedProps;if(p!==f){n=i.stateNode,ea($i.current);var y=null;switch(a){case"input":p=Fe(n,p),f=Fe(n,f),y=[];break;case"select":p=F({},p,{value:void 0}),f=F({},f,{value:void 0}),y=[];break;case"textarea":p=yt(n,p),f=yt(n,f),y=[];break;default:typeof p.onClick!="function"&&typeof f.onClick=="function"&&(n.onclick=Se)}Sn(a,f);var A;a=null;for(we in p)if(!f.hasOwnProperty(we)&&p.hasOwnProperty(we)&&p[we]!=null)if(we==="style"){var q=p[we];for(A in q)q.hasOwnProperty(A)&&(a||(a={}),a[A]="")}else we!=="dangerouslySetInnerHTML"&&we!=="children"&&we!=="suppressContentEditableWarning"&&we!=="suppressHydrationWarning"&&we!=="autoFocus"&&(l.hasOwnProperty(we)?y||(y=[]):(y=y||[]).push(we,null));for(we in f){var ee=f[we];if(q=p!=null?p[we]:void 0,f.hasOwnProperty(we)&&ee!==q&&(ee!=null||q!=null))if(we==="style")if(q){for(A in q)!q.hasOwnProperty(A)||ee&&ee.hasOwnProperty(A)||(a||(a={}),a[A]="");for(A in ee)ee.hasOwnProperty(A)&&q[A]!==ee[A]&&(a||(a={}),a[A]=ee[A])}else a||(y||(y=[]),y.push(we,a)),a=ee;else we==="dangerouslySetInnerHTML"?(ee=ee?ee.__html:void 0,q=q?q.__html:void 0,ee!=null&&q!==ee&&(y=y||[]).push(we,ee)):we==="children"?typeof ee!="string"&&typeof ee!="number"||(y=y||[]).push(we,""+ee):we!=="suppressContentEditableWarning"&&we!=="suppressHydrationWarning"&&(l.hasOwnProperty(we)?(ee!=null&&we==="onScroll"&&In("scroll",n),y||q===ee||(y=[])):(y=y||[]).push(we,ee))}a&&(y=y||[]).push("style",a);var we=y;(i.updateQueue=we)&&(i.flags|=4)}},Uh=function(n,i,a,f){a!==f&&(i.flags|=4)};function hu(n,i){if(!Qn)switch(n.tailMode){case"hidden":i=n.tail;for(var a=null;i!==null;)i.alternate!==null&&(a=i),i=i.sibling;a===null?n.tail=null:a.sibling=null;break;case"collapsed":a=n.tail;for(var f=null;a!==null;)a.alternate!==null&&(f=a),a=a.sibling;f===null?i||n.tail===null?n.tail=null:n.tail.sibling=null:f.sibling=null}}function Bs(n){var i=n.alternate!==null&&n.alternate.child===n.child,a=0,f=0;if(i)for(var p=n.child;p!==null;)a|=p.lanes|p.childLanes,f|=p.subtreeFlags&14680064,f|=p.flags&14680064,p.return=n,p=p.sibling;else for(p=n.child;p!==null;)a|=p.lanes|p.childLanes,f|=p.subtreeFlags,f|=p.flags,p.return=n,p=p.sibling;return n.subtreeFlags|=f,n.childLanes=a,i}function ax(n,i,a){var f=i.pendingProps;switch(tu(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Bs(i),null;case 1:return rs(i.type)&&bi(),Bs(i),null;case 3:return f=i.stateNode,ka(),Kn(Fs),Kn(gs),vc(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(n===null||n.child===null)&&(Ml(i)?i.flags|=4:n===null||n.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,li!==null&&(Rf(li),li=null))),Sf(n,i),Bs(i),null;case 5:yc(i);var p=ea(Qa.current);if(a=i.type,n!==null&&i.stateNode!=null)Bh(n,i,a,f,p),n.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!f){if(i.stateNode===null)throw Error(r(166));return Bs(i),null}if(n=ea($i.current),Ml(i)){f=i.stateNode,a=i.type;var y=i.memoizedProps;switch(f[_r]=i,f[wi]=y,n=(i.mode&1)!==0,a){case"dialog":In("cancel",f),In("close",f);break;case"iframe":case"object":case"embed":In("load",f);break;case"video":case"audio":for(p=0;p<va.length;p++)In(va[p],f);break;case"source":In("error",f);break;case"img":case"image":case"link":In("error",f),In("load",f);break;case"details":In("toggle",f);break;case"input":Xe(f,y),In("invalid",f);break;case"select":f._wrapperState={wasMultiple:!!y.multiple},In("invalid",f);break;case"textarea":sn(f,y),In("invalid",f)}Sn(a,y),p=null;for(var A in y)if(y.hasOwnProperty(A)){var q=y[A];A==="children"?typeof q=="string"?f.textContent!==q&&(y.suppressHydrationWarning!==!0&&fe(f.textContent,q,n),p=["children",q]):typeof q=="number"&&f.textContent!==""+q&&(y.suppressHydrationWarning!==!0&&fe(f.textContent,q,n),p=["children",""+q]):l.hasOwnProperty(A)&&q!=null&&A==="onScroll"&&In("scroll",f)}switch(a){case"input":Pe(f),Oe(f,y,!0);break;case"textarea":Pe(f),Xt(f);break;case"select":case"option":break;default:typeof y.onClick=="function"&&(f.onclick=Se)}f=p,i.updateQueue=f,f!==null&&(i.flags|=4)}else{A=p.nodeType===9?p:p.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=je(a)),n==="http://www.w3.org/1999/xhtml"?a==="script"?(n=A.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof f.is=="string"?n=A.createElement(a,{is:f.is}):(n=A.createElement(a),a==="select"&&(A=n,f.multiple?A.multiple=!0:f.size&&(A.size=f.size))):n=A.createElementNS(n,a),n[_r]=i,n[wi]=f,Dh(n,i,!1,!1),i.stateNode=n;e:{switch(A=cr(a,f),a){case"dialog":In("cancel",n),In("close",n),p=f;break;case"iframe":case"object":case"embed":In("load",n),p=f;break;case"video":case"audio":for(p=0;p<va.length;p++)In(va[p],n);p=f;break;case"source":In("error",n),p=f;break;case"img":case"image":case"link":In("error",n),In("load",n),p=f;break;case"details":In("toggle",n),p=f;break;case"input":Xe(n,f),p=Fe(n,f),In("invalid",n);break;case"option":p=f;break;case"select":n._wrapperState={wasMultiple:!!f.multiple},p=F({},f,{value:void 0}),In("invalid",n);break;case"textarea":sn(n,f),p=yt(n,f),In("invalid",n);break;default:p=f}Sn(a,p),q=p;for(y in q)if(q.hasOwnProperty(y)){var ee=q[y];y==="style"?cn(n,ee):y==="dangerouslySetInnerHTML"?(ee=ee?ee.__html:void 0,ee!=null&&$t(n,ee)):y==="children"?typeof ee=="string"?(a!=="textarea"||ee!=="")&&pt(n,ee):typeof ee=="number"&&pt(n,""+ee):y!=="suppressContentEditableWarning"&&y!=="suppressHydrationWarning"&&y!=="autoFocus"&&(l.hasOwnProperty(y)?ee!=null&&y==="onScroll"&&In("scroll",n):ee!=null&&L(n,y,ee,A))}switch(a){case"input":Pe(n),Oe(n,f,!1);break;case"textarea":Pe(n),Xt(n);break;case"option":f.value!=null&&n.setAttribute("value",""+ve(f.value));break;case"select":n.multiple=!!f.multiple,y=f.value,y!=null?Et(n,!!f.multiple,y,!1):f.defaultValue!=null&&Et(n,!!f.multiple,f.defaultValue,!0);break;default:typeof p.onClick=="function"&&(n.onclick=Se)}switch(a){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}}f&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return Bs(i),null;case 6:if(n&&i.stateNode!=null)Uh(n,i,n.memoizedProps,f);else{if(typeof f!="string"&&i.stateNode===null)throw Error(r(166));if(a=ea(Qa.current),ea($i.current),Ml(i)){if(f=i.stateNode,a=i.memoizedProps,f[_r]=i,(y=f.nodeValue!==a)&&(n=Jn,n!==null))switch(n.tag){case 3:fe(f.nodeValue,a,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&fe(f.nodeValue,a,(n.mode&1)!==0)}y&&(i.flags|=4)}else f=(a.nodeType===9?a:a.ownerDocument).createTextNode(f),f[_r]=i,i.stateNode=f}return Bs(i),null;case 13:if(Kn(rr),f=i.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(Qn&&is!==null&&(i.mode&1)!==0&&(i.flags&128)===0)uc(),Ei(),i.flags|=98560,y=!1;else if(y=Ml(i),f!==null&&f.dehydrated!==null){if(n===null){if(!y)throw Error(r(318));if(y=i.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(r(317));y[_r]=i}else Ei(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Bs(i),y=!1}else li!==null&&(Rf(li),li=null),y=!0;if(!y)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=a,i):(f=f!==null,f!==(n!==null&&n.memoizedState!==null)&&f&&(i.child.flags|=8192,(i.mode&1)!==0&&(n===null||(rr.current&1)!==0?os===0&&(os=3):If())),i.updateQueue!==null&&(i.flags|=4),Bs(i),null);case 4:return ka(),Sf(n,i),n===null&&qo(i.stateNode.containerInfo),Bs(i),null;case 10:return Rl(i.type._context),Bs(i),null;case 17:return rs(i.type)&&bi(),Bs(i),null;case 19:if(Kn(rr),y=i.memoizedState,y===null)return Bs(i),null;if(f=(i.flags&128)!==0,A=y.rendering,A===null)if(f)hu(y,!1);else{if(os!==0||n!==null&&(n.flags&128)!==0)for(n=i.child;n!==null;){if(A=Il(n),A!==null){for(i.flags|=128,hu(y,!1),f=A.updateQueue,f!==null&&(i.updateQueue=f,i.flags|=4),i.subtreeFlags=0,f=a,a=i.child;a!==null;)y=a,n=f,y.flags&=14680066,A=y.alternate,A===null?(y.childLanes=0,y.lanes=n,y.child=null,y.subtreeFlags=0,y.memoizedProps=null,y.memoizedState=null,y.updateQueue=null,y.dependencies=null,y.stateNode=null):(y.childLanes=A.childLanes,y.lanes=A.lanes,y.child=A.child,y.subtreeFlags=0,y.deletions=null,y.memoizedProps=A.memoizedProps,y.memoizedState=A.memoizedState,y.updateQueue=A.updateQueue,y.type=A.type,n=A.dependencies,y.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),a=a.sibling;return Wn(rr,rr.current&1|2),i.child}n=n.sibling}y.tail!==null&&En()>Cc&&(i.flags|=128,f=!0,hu(y,!1),i.lanes=4194304)}else{if(!f)if(n=Il(A),n!==null){if(i.flags|=128,f=!0,a=n.updateQueue,a!==null&&(i.updateQueue=a,i.flags|=4),hu(y,!0),y.tail===null&&y.tailMode==="hidden"&&!A.alternate&&!Qn)return Bs(i),null}else 2*En()-y.renderingStartTime>Cc&&a!==1073741824&&(i.flags|=128,f=!0,hu(y,!1),i.lanes=4194304);y.isBackwards?(A.sibling=i.child,i.child=A):(a=y.last,a!==null?a.sibling=A:i.child=A,y.last=A)}return y.tail!==null?(i=y.tail,y.rendering=i,y.tail=i.sibling,y.renderingStartTime=En(),i.sibling=null,a=rr.current,Wn(rr,f?a&1|2:a&1),i):(Bs(i),null);case 22:case 23:return Pf(),f=i.memoizedState!==null,n!==null&&n.memoizedState!==null!==f&&(i.flags|=8192),f&&(i.mode&1)!==0?(Ti&1073741824)!==0&&(Bs(i),i.subtreeFlags&6&&(i.flags|=8192)):Bs(i),null;case 24:return null;case 25:return null}throw Error(r(156,i.tag))}function lx(n,i){switch(tu(i),i.tag){case 1:return rs(i.type)&&bi(),n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 3:return ka(),Kn(Fs),Kn(gs),vc(),n=i.flags,(n&65536)!==0&&(n&128)===0?(i.flags=n&-65537|128,i):null;case 5:return yc(i),null;case 13:if(Kn(rr),n=i.memoizedState,n!==null&&n.dehydrated!==null){if(i.alternate===null)throw Error(r(340));Ei()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 19:return Kn(rr),null;case 4:return ka(),null;case 10:return Rl(i.type._context),null;case 22:case 23:return Pf(),null;case 24:return null;default:return null}}var od=!1,Us=!1,cx=typeof WeakSet=="function"?WeakSet:Set,_t=null;function kc(n,i){var a=n.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(f){br(n,i,f)}else a.current=null}function jf(n,i,a){try{a()}catch(f){br(n,i,f)}}var Wh=!1;function ux(n,i){if(et=zs,n=xi(),_a(n)){if("selectionStart"in n)var a={start:n.selectionStart,end:n.selectionEnd};else e:{a=(a=n.ownerDocument)&&a.defaultView||window;var f=a.getSelection&&a.getSelection();if(f&&f.rangeCount!==0){a=f.anchorNode;var p=f.anchorOffset,y=f.focusNode;f=f.focusOffset;try{a.nodeType,y.nodeType}catch{a=null;break e}var A=0,q=-1,ee=-1,we=0,We=0,qe=n,Ue=null;t:for(;;){for(var ht;qe!==a||p!==0&&qe.nodeType!==3||(q=A+p),qe!==y||f!==0&&qe.nodeType!==3||(ee=A+f),qe.nodeType===3&&(A+=qe.nodeValue.length),(ht=qe.firstChild)!==null;)Ue=qe,qe=ht;for(;;){if(qe===n)break t;if(Ue===a&&++we===p&&(q=A),Ue===y&&++We===f&&(ee=A),(ht=qe.nextSibling)!==null)break;qe=Ue,Ue=qe.parentNode}qe=ht}a=q===-1||ee===-1?null:{start:q,end:ee}}else a=null}a=a||{start:0,end:0}}else a=null;for(Ye={focusedElem:n,selectionRange:a},zs=!1,_t=i;_t!==null;)if(i=_t,n=i.child,(i.subtreeFlags&1028)!==0&&n!==null)n.return=i,_t=n;else for(;_t!==null;){i=_t;try{var wt=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(wt!==null){var Nt=wt.memoizedProps,Pr=wt.memoizedState,pe=i.stateNode,ce=pe.getSnapshotBeforeUpdate(i.elementType===i.type?Nt:Tn(i.type,Nt),Pr);pe.__reactInternalSnapshotBeforeUpdate=ce}break;case 3:var ge=i.stateNode.containerInfo;ge.nodeType===1?ge.textContent="":ge.nodeType===9&&ge.documentElement&&ge.removeChild(ge.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(Je){br(i,i.return,Je)}if(n=i.sibling,n!==null){n.return=i.return,_t=n;break}_t=i.return}return wt=Wh,Wh=!1,wt}function pu(n,i,a){var f=i.updateQueue;if(f=f!==null?f.lastEffect:null,f!==null){var p=f=f.next;do{if((p.tag&n)===n){var y=p.destroy;p.destroy=void 0,y!==void 0&&jf(i,a,y)}p=p.next}while(p!==f)}}function ad(n,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var a=i=i.next;do{if((a.tag&n)===n){var f=a.create;a.destroy=f()}a=a.next}while(a!==i)}}function kf(n){var i=n.ref;if(i!==null){var a=n.stateNode;switch(n.tag){case 5:n=a;break;default:n=a}typeof i=="function"?i(n):i.current=n}}function Hh(n){var i=n.alternate;i!==null&&(n.alternate=null,Hh(i)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(i=n.stateNode,i!==null&&(delete i[_r],delete i[wi],delete i[qn],delete i[Wa],delete i[ba])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function Vh(n){return n.tag===5||n.tag===3||n.tag===4}function qh(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Vh(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Nf(n,i,a){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?a.nodeType===8?a.parentNode.insertBefore(n,i):a.insertBefore(n,i):(a.nodeType===8?(i=a.parentNode,i.insertBefore(n,a)):(i=a,i.appendChild(n)),a=a._reactRootContainer,a!=null||i.onclick!==null||(i.onclick=Se));else if(f!==4&&(n=n.child,n!==null))for(Nf(n,i,a),n=n.sibling;n!==null;)Nf(n,i,a),n=n.sibling}function Cf(n,i,a){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?a.insertBefore(n,i):a.appendChild(n);else if(f!==4&&(n=n.child,n!==null))for(Cf(n,i,a),n=n.sibling;n!==null;)Cf(n,i,a),n=n.sibling}var js=null,$o=!1;function el(n,i,a){for(a=a.child;a!==null;)Gh(n,i,a),a=a.sibling}function Gh(n,i,a){if(Dr&&typeof Dr.onCommitFiberUnmount=="function")try{Dr.onCommitFiberUnmount(dn,a)}catch{}switch(a.tag){case 5:Us||kc(a,i);case 6:var f=js,p=$o;js=null,el(n,i,a),js=f,$o=p,js!==null&&($o?(n=js,a=a.stateNode,n.nodeType===8?n.parentNode.removeChild(a):n.removeChild(a)):js.removeChild(a.stateNode));break;case 18:js!==null&&($o?(n=js,a=a.stateNode,n.nodeType===8?Ks(n.parentNode,a):n.nodeType===1&&Ks(n,a),qs(n)):Ks(js,a.stateNode));break;case 4:f=js,p=$o,js=a.stateNode.containerInfo,$o=!0,el(n,i,a),js=f,$o=p;break;case 0:case 11:case 14:case 15:if(!Us&&(f=a.updateQueue,f!==null&&(f=f.lastEffect,f!==null))){p=f=f.next;do{var y=p,A=y.destroy;y=y.tag,A!==void 0&&((y&2)!==0||(y&4)!==0)&&jf(a,i,A),p=p.next}while(p!==f)}el(n,i,a);break;case 1:if(!Us&&(kc(a,i),f=a.stateNode,typeof f.componentWillUnmount=="function"))try{f.props=a.memoizedProps,f.state=a.memoizedState,f.componentWillUnmount()}catch(q){br(a,i,q)}el(n,i,a);break;case 21:el(n,i,a);break;case 22:a.mode&1?(Us=(f=Us)||a.memoizedState!==null,el(n,i,a),Us=f):el(n,i,a);break;default:el(n,i,a)}}function Yh(n){var i=n.updateQueue;if(i!==null){n.updateQueue=null;var a=n.stateNode;a===null&&(a=n.stateNode=new cx),i.forEach(function(f){var p=xx.bind(null,n,f);a.has(f)||(a.add(f),f.then(p,p))})}}function Ao(n,i){var a=i.deletions;if(a!==null)for(var f=0;f<a.length;f++){var p=a[f];try{var y=n,A=i,q=A;e:for(;q!==null;){switch(q.tag){case 5:js=q.stateNode,$o=!1;break e;case 3:js=q.stateNode.containerInfo,$o=!0;break e;case 4:js=q.stateNode.containerInfo,$o=!0;break e}q=q.return}if(js===null)throw Error(r(160));Gh(y,A,p),js=null,$o=!1;var ee=p.alternate;ee!==null&&(ee.return=null),p.return=null}catch(we){br(p,i,we)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)Xh(i,n),i=i.sibling}function Xh(n,i){var a=n.alternate,f=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Ao(i,n),sa(n),f&4){try{pu(3,n,n.return),ad(3,n)}catch(Nt){br(n,n.return,Nt)}try{pu(5,n,n.return)}catch(Nt){br(n,n.return,Nt)}}break;case 1:Ao(i,n),sa(n),f&512&&a!==null&&kc(a,a.return);break;case 5:if(Ao(i,n),sa(n),f&512&&a!==null&&kc(a,a.return),n.flags&32){var p=n.stateNode;try{pt(p,"")}catch(Nt){br(n,n.return,Nt)}}if(f&4&&(p=n.stateNode,p!=null)){var y=n.memoizedProps,A=a!==null?a.memoizedProps:y,q=n.type,ee=n.updateQueue;if(n.updateQueue=null,ee!==null)try{q==="input"&&y.type==="radio"&&y.name!=null&&tt(p,y),cr(q,A);var we=cr(q,y);for(A=0;A<ee.length;A+=2){var We=ee[A],qe=ee[A+1];We==="style"?cn(p,qe):We==="dangerouslySetInnerHTML"?$t(p,qe):We==="children"?pt(p,qe):L(p,We,qe,we)}switch(q){case"input":ze(p,y);break;case"textarea":ln(p,y);break;case"select":var Ue=p._wrapperState.wasMultiple;p._wrapperState.wasMultiple=!!y.multiple;var ht=y.value;ht!=null?Et(p,!!y.multiple,ht,!1):Ue!==!!y.multiple&&(y.defaultValue!=null?Et(p,!!y.multiple,y.defaultValue,!0):Et(p,!!y.multiple,y.multiple?[]:"",!1))}p[wi]=y}catch(Nt){br(n,n.return,Nt)}}break;case 6:if(Ao(i,n),sa(n),f&4){if(n.stateNode===null)throw Error(r(162));p=n.stateNode,y=n.memoizedProps;try{p.nodeValue=y}catch(Nt){br(n,n.return,Nt)}}break;case 3:if(Ao(i,n),sa(n),f&4&&a!==null&&a.memoizedState.isDehydrated)try{qs(i.containerInfo)}catch(Nt){br(n,n.return,Nt)}break;case 4:Ao(i,n),sa(n);break;case 13:Ao(i,n),sa(n),p=n.child,p.flags&8192&&(y=p.memoizedState!==null,p.stateNode.isHidden=y,!y||p.alternate!==null&&p.alternate.memoizedState!==null||(Af=En())),f&4&&Yh(n);break;case 22:if(We=a!==null&&a.memoizedState!==null,n.mode&1?(Us=(we=Us)||We,Ao(i,n),Us=we):Ao(i,n),sa(n),f&8192){if(we=n.memoizedState!==null,(n.stateNode.isHidden=we)&&!We&&(n.mode&1)!==0)for(_t=n,We=n.child;We!==null;){for(qe=_t=We;_t!==null;){switch(Ue=_t,ht=Ue.child,Ue.tag){case 0:case 11:case 14:case 15:pu(4,Ue,Ue.return);break;case 1:kc(Ue,Ue.return);var wt=Ue.stateNode;if(typeof wt.componentWillUnmount=="function"){f=Ue,a=Ue.return;try{i=f,wt.props=i.memoizedProps,wt.state=i.memoizedState,wt.componentWillUnmount()}catch(Nt){br(f,a,Nt)}}break;case 5:kc(Ue,Ue.return);break;case 22:if(Ue.memoizedState!==null){Qh(qe);continue}}ht!==null?(ht.return=Ue,_t=ht):Qh(qe)}We=We.sibling}e:for(We=null,qe=n;;){if(qe.tag===5){if(We===null){We=qe;try{p=qe.stateNode,we?(y=p.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none"):(q=qe.stateNode,ee=qe.memoizedProps.style,A=ee!=null&&ee.hasOwnProperty("display")?ee.display:null,q.style.display=nn("display",A))}catch(Nt){br(n,n.return,Nt)}}}else if(qe.tag===6){if(We===null)try{qe.stateNode.nodeValue=we?"":qe.memoizedProps}catch(Nt){br(n,n.return,Nt)}}else if((qe.tag!==22&&qe.tag!==23||qe.memoizedState===null||qe===n)&&qe.child!==null){qe.child.return=qe,qe=qe.child;continue}if(qe===n)break e;for(;qe.sibling===null;){if(qe.return===null||qe.return===n)break e;We===qe&&(We=null),qe=qe.return}We===qe&&(We=null),qe.sibling.return=qe.return,qe=qe.sibling}}break;case 19:Ao(i,n),sa(n),f&4&&Yh(n);break;case 21:break;default:Ao(i,n),sa(n)}}function sa(n){var i=n.flags;if(i&2){try{e:{for(var a=n.return;a!==null;){if(Vh(a)){var f=a;break e}a=a.return}throw Error(r(160))}switch(f.tag){case 5:var p=f.stateNode;f.flags&32&&(pt(p,""),f.flags&=-33);var y=qh(n);Cf(n,y,p);break;case 3:case 4:var A=f.stateNode.containerInfo,q=qh(n);Nf(n,q,A);break;default:throw Error(r(161))}}catch(ee){br(n,n.return,ee)}n.flags&=-3}i&4096&&(n.flags&=-4097)}function dx(n,i,a){_t=n,Kh(n)}function Kh(n,i,a){for(var f=(n.mode&1)!==0;_t!==null;){var p=_t,y=p.child;if(p.tag===22&&f){var A=p.memoizedState!==null||od;if(!A){var q=p.alternate,ee=q!==null&&q.memoizedState!==null||Us;q=od;var we=Us;if(od=A,(Us=ee)&&!we)for(_t=p;_t!==null;)A=_t,ee=A.child,A.tag===22&&A.memoizedState!==null?Zh(p):ee!==null?(ee.return=A,_t=ee):Zh(p);for(;y!==null;)_t=y,Kh(y),y=y.sibling;_t=p,od=q,Us=we}Jh(n)}else(p.subtreeFlags&8772)!==0&&y!==null?(y.return=p,_t=y):Jh(n)}}function Jh(n){for(;_t!==null;){var i=_t;if((i.flags&8772)!==0){var a=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:Us||ad(5,i);break;case 1:var f=i.stateNode;if(i.flags&4&&!Us)if(a===null)f.componentDidMount();else{var p=i.elementType===i.type?a.memoizedProps:Tn(i.type,a.memoizedProps);f.componentDidUpdate(p,a.memoizedState,f.__reactInternalSnapshotBeforeUpdate)}var y=i.updateQueue;y!==null&&lu(i,y,f);break;case 3:var A=i.updateQueue;if(A!==null){if(a=null,i.child!==null)switch(i.child.tag){case 5:a=i.child.stateNode;break;case 1:a=i.child.stateNode}lu(i,A,a)}break;case 5:var q=i.stateNode;if(a===null&&i.flags&4){a=q;var ee=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":ee.autoFocus&&a.focus();break;case"img":ee.src&&(a.src=ee.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var we=i.alternate;if(we!==null){var We=we.memoizedState;if(We!==null){var qe=We.dehydrated;qe!==null&&qs(qe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}Us||i.flags&512&&kf(i)}catch(Ue){br(i,i.return,Ue)}}if(i===n){_t=null;break}if(a=i.sibling,a!==null){a.return=i.return,_t=a;break}_t=i.return}}function Qh(n){for(;_t!==null;){var i=_t;if(i===n){_t=null;break}var a=i.sibling;if(a!==null){a.return=i.return,_t=a;break}_t=i.return}}function Zh(n){for(;_t!==null;){var i=_t;try{switch(i.tag){case 0:case 11:case 15:var a=i.return;try{ad(4,i)}catch(ee){br(i,a,ee)}break;case 1:var f=i.stateNode;if(typeof f.componentDidMount=="function"){var p=i.return;try{f.componentDidMount()}catch(ee){br(i,p,ee)}}var y=i.return;try{kf(i)}catch(ee){br(i,y,ee)}break;case 5:var A=i.return;try{kf(i)}catch(ee){br(i,A,ee)}}}catch(ee){br(i,i.return,ee)}if(i===n){_t=null;break}var q=i.sibling;if(q!==null){q.return=i.return,_t=q;break}_t=i.return}}var fx=Math.ceil,ld=I.ReactCurrentDispatcher,Ef=I.ReactCurrentOwner,no=I.ReactCurrentBatchConfig,Mn=0,xs=null,Yr=null,ks=0,Ti=0,Nc=Xo(0),os=0,gu=null,Dl=0,cd=0,$f=0,_u=null,fi=null,Af=0,Cc=1/0,Aa=null,ud=!1,Tf=null,tl=null,dd=!1,nl=null,fd=0,yu=0,Mf=null,md=-1,hd=0;function ti(){return(Mn&6)!==0?En():md!==-1?md:md=En()}function rl(n){return(n.mode&1)===0?1:(Mn&2)!==0&&ks!==0?ks&-ks:gf.transition!==null?(hd===0&&(hd=er()),hd):(n=rn,n!==0||(n=window.event,n=n===void 0?16:Ce(n.type)),n)}function To(n,i,a,f){if(50<yu)throw yu=0,Mf=null,Error(r(185));Nr(n,a,f),((Mn&2)===0||n!==xs)&&(n===xs&&((Mn&2)===0&&(cd|=a),os===4&&sl(n,ks)),mi(n,f),a===1&&Mn===0&&(i.mode&1)===0&&(Cc=En()+500,Ga&&Os()))}function mi(n,i){var a=n.callbackNode;Ge(n,i);var f=Me(n,n===xs?ks:0);if(f===0)a!==null&&lo(a),n.callbackNode=null,n.callbackPriority=0;else if(i=f&-f,n.callbackPriority!==i){if(a!=null&&lo(a),i===1)n.tag===0?pf(tp.bind(null,n)):Qu(tp.bind(null,n)),Fn(function(){(Mn&6)===0&&Os()}),a=null;else{switch(Er(f)){case 1:a=Jr;break;case 4:a=Or;break;case 16:a=mr;break;case 536870912:a=St;break;default:a=mr}a=cp(a,ep.bind(null,n))}n.callbackPriority=i,n.callbackNode=a}}function ep(n,i){if(md=-1,hd=0,(Mn&6)!==0)throw Error(r(327));var a=n.callbackNode;if(Ec()&&n.callbackNode!==a)return null;var f=Me(n,n===xs?ks:0);if(f===0)return null;if((f&30)!==0||(f&n.expiredLanes)!==0||i)i=pd(n,f);else{i=f;var p=Mn;Mn|=2;var y=rp();(xs!==n||ks!==i)&&(Aa=null,Cc=En()+500,Ul(n,i));do try{px();break}catch(q){np(n,q)}while(!0);hc(),ld.current=y,Mn=p,Yr!==null?i=0:(xs=null,ks=0,i=os)}if(i!==0){if(i===2&&(p=Yn(n),p!==0&&(f=p,i=zf(n,p))),i===1)throw a=gu,Ul(n,0),sl(n,f),mi(n,En()),a;if(i===6)sl(n,f);else{if(p=n.current.alternate,(f&30)===0&&!mx(p)&&(i=pd(n,f),i===2&&(y=Yn(n),y!==0&&(f=y,i=zf(n,y))),i===1))throw a=gu,Ul(n,0),sl(n,f),mi(n,En()),a;switch(n.finishedWork=p,n.finishedLanes=f,i){case 0:case 1:throw Error(r(345));case 2:Wl(n,fi,Aa);break;case 3:if(sl(n,f),(f&130023424)===f&&(i=Af+500-En(),10<i)){if(Me(n,0)!==0)break;if(p=n.suspendedLanes,(p&f)!==f){ti(),n.pingedLanes|=n.suspendedLanes&p;break}n.timeoutHandle=He(Wl.bind(null,n,fi,Aa),i);break}Wl(n,fi,Aa);break;case 4:if(sl(n,f),(f&4194240)===f)break;for(i=n.eventTimes,p=-1;0<f;){var A=31-kr(f);y=1<<A,A=i[A],A>p&&(p=A),f&=~y}if(f=p,f=En()-f,f=(120>f?120:480>f?480:1080>f?1080:1920>f?1920:3e3>f?3e3:4320>f?4320:1960*fx(f/1960))-f,10<f){n.timeoutHandle=He(Wl.bind(null,n,fi,Aa),f);break}Wl(n,fi,Aa);break;case 5:Wl(n,fi,Aa);break;default:throw Error(r(329))}}}return mi(n,En()),n.callbackNode===a?ep.bind(null,n):null}function zf(n,i){var a=_u;return n.current.memoizedState.isDehydrated&&(Ul(n,i).flags|=256),n=pd(n,i),n!==2&&(i=fi,fi=a,i!==null&&Rf(i)),n}function Rf(n){fi===null?fi=n:fi.push.apply(fi,n)}function mx(n){for(var i=n;;){if(i.flags&16384){var a=i.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var f=0;f<a.length;f++){var p=a[f],y=p.getSnapshot;p=p.value;try{if(!ns(y(),p))return!1}catch{return!1}}}if(a=i.child,i.subtreeFlags&16384&&a!==null)a.return=i,i=a;else{if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function sl(n,i){for(i&=~$f,i&=~cd,n.suspendedLanes|=i,n.pingedLanes&=~i,n=n.expirationTimes;0<i;){var a=31-kr(i),f=1<<a;n[a]=-1,i&=~f}}function tp(n){if((Mn&6)!==0)throw Error(r(327));Ec();var i=Me(n,0);if((i&1)===0)return mi(n,En()),null;var a=pd(n,i);if(n.tag!==0&&a===2){var f=Yn(n);f!==0&&(i=f,a=zf(n,f))}if(a===1)throw a=gu,Ul(n,0),sl(n,i),mi(n,En()),a;if(a===6)throw Error(r(345));return n.finishedWork=n.current.alternate,n.finishedLanes=i,Wl(n,fi,Aa),mi(n,En()),null}function Lf(n,i){var a=Mn;Mn|=1;try{return n(i)}finally{Mn=a,Mn===0&&(Cc=En()+500,Ga&&Os())}}function Bl(n){nl!==null&&nl.tag===0&&(Mn&6)===0&&Ec();var i=Mn;Mn|=1;var a=no.transition,f=rn;try{if(no.transition=null,rn=1,n)return n()}finally{rn=f,no.transition=a,Mn=i,(Mn&6)===0&&Os()}}function Pf(){Ti=Nc.current,Kn(Nc)}function Ul(n,i){n.finishedWork=null,n.finishedLanes=0;var a=n.timeoutHandle;if(a!==-1&&(n.timeoutHandle=-1,Wt(a)),Yr!==null)for(a=Yr.return;a!==null;){var f=a;switch(tu(f),f.tag){case 1:f=f.type.childContextTypes,f!=null&&bi();break;case 3:ka(),Kn(Fs),Kn(gs),vc();break;case 5:yc(f);break;case 4:ka();break;case 13:Kn(rr);break;case 19:Kn(rr);break;case 10:Rl(f.type._context);break;case 22:case 23:Pf()}a=a.return}if(xs=n,Yr=n=il(n.current,null),ks=Ti=i,os=0,gu=null,$f=cd=Dl=0,fi=_u=null,Zo!==null){for(i=0;i<Zo.length;i++)if(a=Zo[i],f=a.interleaved,f!==null){a.interleaved=null;var p=f.next,y=a.pending;if(y!==null){var A=y.next;y.next=p,f.next=A}a.pending=f}Zo=null}return n}function np(n,i){do{var a=Yr;try{if(hc(),Fl.current=Ea,w){for(var f=sr.memoizedState;f!==null;){var p=f.queue;p!==null&&(p.pending=null),f=f.next}w=!1}if(ta=0,Lr=xr=sr=null,$=!1,P=0,Ef.current=null,a===null||a.return===null){os=1,gu=i,Yr=null;break}e:{var y=n,A=a.return,q=a,ee=i;if(i=ks,q.flags|=32768,ee!==null&&typeof ee=="object"&&typeof ee.then=="function"){var we=ee,We=q,qe=We.tag;if((We.mode&1)===0&&(qe===0||qe===11||qe===15)){var Ue=We.alternate;Ue?(We.updateQueue=Ue.updateQueue,We.memoizedState=Ue.memoizedState,We.lanes=Ue.lanes):(We.updateQueue=null,We.memoizedState=null)}var ht=Ch(A);if(ht!==null){ht.flags&=-257,Eh(ht,A,q,y,i),ht.mode&1&&Nh(y,we,i),i=ht,ee=we;var wt=i.updateQueue;if(wt===null){var Nt=new Set;Nt.add(ee),i.updateQueue=Nt}else wt.add(ee);break e}else{if((i&1)===0){Nh(y,we,i),If();break e}ee=Error(r(426))}}else if(Qn&&q.mode&1){var Pr=Ch(A);if(Pr!==null){(Pr.flags&65536)===0&&(Pr.flags|=256),Eh(Pr,A,q,y,i),Ya(na(ee,q));break e}}y=ee=na(ee,q),os!==4&&(os=2),_u===null?_u=[y]:_u.push(y),y=A;do{switch(y.tag){case 3:y.flags|=65536,i&=-i,y.lanes|=i;var pe=jh(y,ee,i);au(y,pe);break e;case 1:q=ee;var ce=y.type,ge=y.stateNode;if((y.flags&128)===0&&(typeof ce.getDerivedStateFromError=="function"||ge!==null&&typeof ge.componentDidCatch=="function"&&(tl===null||!tl.has(ge)))){y.flags|=65536,i&=-i,y.lanes|=i;var Je=kh(y,q,i);au(y,Je);break e}}y=y.return}while(y!==null)}ip(a)}catch(Mt){i=Mt,Yr===a&&a!==null&&(Yr=a=a.return);continue}break}while(!0)}function rp(){var n=ld.current;return ld.current=Ea,n===null?Ea:n}function If(){(os===0||os===3||os===2)&&(os=4),xs===null||(Dl&268435455)===0&&(cd&268435455)===0||sl(xs,ks)}function pd(n,i){var a=Mn;Mn|=2;var f=rp();(xs!==n||ks!==i)&&(Aa=null,Ul(n,i));do try{hx();break}catch(p){np(n,p)}while(!0);if(hc(),Mn=a,ld.current=f,Yr!==null)throw Error(r(261));return xs=null,ks=0,os}function hx(){for(;Yr!==null;)sp(Yr)}function px(){for(;Yr!==null&&!Ri();)sp(Yr)}function sp(n){var i=lp(n.alternate,n,Ti);n.memoizedProps=n.pendingProps,i===null?ip(n):Yr=i,Ef.current=null}function ip(n){var i=n;do{var a=i.alternate;if(n=i.return,(i.flags&32768)===0){if(a=ax(a,i,Ti),a!==null){Yr=a;return}}else{if(a=lx(a,i),a!==null){a.flags&=32767,Yr=a;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{os=6,Yr=null;return}}if(i=i.sibling,i!==null){Yr=i;return}Yr=i=n}while(i!==null);os===0&&(os=5)}function Wl(n,i,a){var f=rn,p=no.transition;try{no.transition=null,rn=1,gx(n,i,a,f)}finally{no.transition=p,rn=f}return null}function gx(n,i,a,f){do Ec();while(nl!==null);if((Mn&6)!==0)throw Error(r(327));a=n.finishedWork;var p=n.finishedLanes;if(a===null)return null;if(n.finishedWork=null,n.finishedLanes=0,a===n.current)throw Error(r(177));n.callbackNode=null,n.callbackPriority=0;var y=a.lanes|a.childLanes;if(Cr(n,y),n===xs&&(Yr=xs=null,ks=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||dd||(dd=!0,cp(mr,function(){return Ec(),null})),y=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||y){y=no.transition,no.transition=null;var A=rn;rn=1;var q=Mn;Mn|=4,Ef.current=null,ux(n,a),Xh(a,n),Ho(Ye),zs=!!et,Ye=et=null,n.current=a,dx(a),cs(),Mn=q,rn=A,no.transition=y}else n.current=a;if(dd&&(dd=!1,nl=n,fd=p),y=n.pendingLanes,y===0&&(tl=null),jr(a.stateNode),mi(n,En()),i!==null)for(f=n.onRecoverableError,a=0;a<i.length;a++)p=i[a],f(p.value,{componentStack:p.stack,digest:p.digest});if(ud)throw ud=!1,n=Tf,Tf=null,n;return(fd&1)!==0&&n.tag!==0&&Ec(),y=n.pendingLanes,(y&1)!==0?n===Mf?yu++:(yu=0,Mf=n):yu=0,Os(),null}function Ec(){if(nl!==null){var n=Er(fd),i=no.transition,a=rn;try{if(no.transition=null,rn=16>n?16:n,nl===null)var f=!1;else{if(n=nl,nl=null,fd=0,(Mn&6)!==0)throw Error(r(331));var p=Mn;for(Mn|=4,_t=n.current;_t!==null;){var y=_t,A=y.child;if((_t.flags&16)!==0){var q=y.deletions;if(q!==null){for(var ee=0;ee<q.length;ee++){var we=q[ee];for(_t=we;_t!==null;){var We=_t;switch(We.tag){case 0:case 11:case 15:pu(8,We,y)}var qe=We.child;if(qe!==null)qe.return=We,_t=qe;else for(;_t!==null;){We=_t;var Ue=We.sibling,ht=We.return;if(Hh(We),We===we){_t=null;break}if(Ue!==null){Ue.return=ht,_t=Ue;break}_t=ht}}}var wt=y.alternate;if(wt!==null){var Nt=wt.child;if(Nt!==null){wt.child=null;do{var Pr=Nt.sibling;Nt.sibling=null,Nt=Pr}while(Nt!==null)}}_t=y}}if((y.subtreeFlags&2064)!==0&&A!==null)A.return=y,_t=A;else e:for(;_t!==null;){if(y=_t,(y.flags&2048)!==0)switch(y.tag){case 0:case 11:case 15:pu(9,y,y.return)}var pe=y.sibling;if(pe!==null){pe.return=y.return,_t=pe;break e}_t=y.return}}var ce=n.current;for(_t=ce;_t!==null;){A=_t;var ge=A.child;if((A.subtreeFlags&2064)!==0&&ge!==null)ge.return=A,_t=ge;else e:for(A=ce;_t!==null;){if(q=_t,(q.flags&2048)!==0)try{switch(q.tag){case 0:case 11:case 15:ad(9,q)}}catch(Mt){br(q,q.return,Mt)}if(q===A){_t=null;break e}var Je=q.sibling;if(Je!==null){Je.return=q.return,_t=Je;break e}_t=q.return}}if(Mn=p,Os(),Dr&&typeof Dr.onPostCommitFiberRoot=="function")try{Dr.onPostCommitFiberRoot(dn,n)}catch{}f=!0}return f}finally{rn=a,no.transition=i}}return!1}function op(n,i,a){i=na(a,i),i=jh(n,i,1),n=No(n,i,1),i=ti(),n!==null&&(Nr(n,1,i),mi(n,i))}function br(n,i,a){if(n.tag===3)op(n,n,a);else for(;i!==null;){if(i.tag===3){op(i,n,a);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(tl===null||!tl.has(f))){n=na(a,n),n=kh(i,n,1),i=No(i,n,1),n=ti(),i!==null&&(Nr(i,1,n),mi(i,n));break}}i=i.return}}function _x(n,i,a){var f=n.pingCache;f!==null&&f.delete(i),i=ti(),n.pingedLanes|=n.suspendedLanes&a,xs===n&&(ks&a)===a&&(os===4||os===3&&(ks&130023424)===ks&&500>En()-Af?Ul(n,0):$f|=a),mi(n,i)}function ap(n,i){i===0&&((n.mode&1)===0?i=1:(i=ur,ur<<=1,(ur&130023424)===0&&(ur=4194304)));var a=ti();n=Ki(n,i),n!==null&&(Nr(n,i,a),mi(n,a))}function yx(n){var i=n.memoizedState,a=0;i!==null&&(a=i.retryLane),ap(n,a)}function xx(n,i){var a=0;switch(n.tag){case 13:var f=n.stateNode,p=n.memoizedState;p!==null&&(a=p.retryLane);break;case 19:f=n.stateNode;break;default:throw Error(r(314))}f!==null&&f.delete(i),ap(n,a)}var lp;lp=function(n,i,a){if(n!==null)if(n.memoizedProps!==i.pendingProps||Fs.current)di=!0;else{if((n.lanes&a)===0&&(i.flags&128)===0)return di=!1,ox(n,i,a);di=(n.flags&131072)!==0}else di=!1,Qn&&(i.flags&1048576)!==0&&Zc(i,_s,i.index);switch(i.lanes=0,i.tag){case 2:var f=i.type;id(n,i),n=i.pendingProps;var p=qa(i,gs.current);ja(i,a),p=ae(null,i,f,n,p,a);var y=re();return i.flags|=1,typeof p=="object"&&p!==null&&typeof p.render=="function"&&p.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,rs(f)?(y=!0,lc(i)):y=!1,i.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,gc(i),p.updater=Gr,i.stateNode=p,p._reactInternals=i,Ol(i,f,n,a),i=yf(null,i,f,!0,y,a)):(i.tag=0,Qn&&y&&eu(i),ei(null,i,p,a),i=i.child),i;case 16:f=i.elementType;e:{switch(id(n,i),n=i.pendingProps,p=f._init,f=p(f._payload),i.type=f,p=i.tag=wx(f),n=Tn(f,n),p){case 0:i=_f(null,i,f,n,a);break e;case 1:i=Rh(null,i,f,n,a);break e;case 11:i=$h(null,i,f,n,a);break e;case 14:i=Ah(null,i,f,Tn(f.type,n),a);break e}throw Error(r(306,f,""))}return i;case 0:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Tn(f,p),_f(n,i,f,p,a);case 1:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Tn(f,p),Rh(n,i,f,p,a);case 3:e:{if(Lh(i),n===null)throw Error(r(387));f=i.pendingProps,y=i.memoizedState,p=y.element,ou(n,i),Pl(i,f,null,a);var A=i.memoizedState;if(f=A.element,y.isDehydrated)if(y={element:f,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},i.updateQueue.baseState=y,i.memoizedState=y,i.flags&256){p=na(Error(r(423)),i),i=Ph(n,i,f,a,p);break e}else if(f!==p){p=na(Error(r(424)),i),i=Ph(n,i,f,a,p);break e}else for(is=Ss(i.stateNode.containerInfo.firstChild),Jn=i,Qn=!0,li=null,a=ed(i,null,f,a),i.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Ei(),f===p){i=$a(n,i,a);break e}ei(n,i,f,a)}i=i.child}return i;case 5:return cu(i),n===null&&ru(i),f=i.type,p=i.pendingProps,y=n!==null?n.memoizedProps:null,A=p.children,Ze(f,p)?A=null:y!==null&&Ze(f,y)&&(i.flags|=32),zh(n,i),ei(n,i,A,a),i.child;case 6:return n===null&&ru(i),null;case 13:return Ih(n,i,a);case 4:return _c(i,i.stateNode.containerInfo),f=i.pendingProps,n===null?i.child=Qo(i,null,f,a):ei(n,i,f,a),i.child;case 11:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Tn(f,p),$h(n,i,f,p,a);case 7:return ei(n,i,i.pendingProps,a),i.child;case 8:return ei(n,i,i.pendingProps.children,a),i.child;case 12:return ei(n,i,i.pendingProps.children,a),i.child;case 10:e:{if(f=i.type._context,p=i.pendingProps,y=i.memoizedProps,A=p.value,Wn(zl,f._currentValue),f._currentValue=A,y!==null)if(ns(y.value,A)){if(y.children===p.children&&!Fs.current){i=$a(n,i,a);break e}}else for(y=i.child,y!==null&&(y.return=i);y!==null;){var q=y.dependencies;if(q!==null){A=y.child;for(var ee=q.firstContext;ee!==null;){if(ee.context===f){if(y.tag===1){ee=Ji(-1,a&-a),ee.tag=2;var we=y.updateQueue;if(we!==null){we=we.shared;var We=we.pending;We===null?ee.next=ee:(ee.next=We.next,We.next=ee),we.pending=ee}}y.lanes|=a,ee=y.alternate,ee!==null&&(ee.lanes|=a),su(y.return,a,i),q.lanes|=a;break}ee=ee.next}}else if(y.tag===10)A=y.type===i.type?null:y.child;else if(y.tag===18){if(A=y.return,A===null)throw Error(r(341));A.lanes|=a,q=A.alternate,q!==null&&(q.lanes|=a),su(A,a,i),A=y.sibling}else A=y.child;if(A!==null)A.return=y;else for(A=y;A!==null;){if(A===i){A=null;break}if(y=A.sibling,y!==null){y.return=A.return,A=y;break}A=A.return}y=A}ei(n,i,p.children,a),i=i.child}return i;case 9:return p=i.type,f=i.pendingProps.children,ja(i,a),p=Qs(p),f=f(p),i.flags|=1,ei(n,i,f,a),i.child;case 14:return f=i.type,p=Tn(f,i.pendingProps),p=Tn(f.type,p),Ah(n,i,f,p,a);case 15:return Th(n,i,i.type,i.pendingProps,a);case 17:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Tn(f,p),id(n,i),i.tag=1,rs(f)?(n=!0,lc(i)):n=!1,ja(i,a),to(i,f,p),Ol(i,f,p,a),yf(null,i,f,!0,n,a);case 19:return Oh(n,i,a);case 22:return Mh(n,i,a)}throw Error(r(156,i.tag))};function cp(n,i){return Es(n,i)}function vx(n,i,a,f){this.tag=n,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=f,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ro(n,i,a,f){return new vx(n,i,a,f)}function Ff(n){return n=n.prototype,!(!n||!n.isReactComponent)}function wx(n){if(typeof n=="function")return Ff(n)?1:0;if(n!=null){if(n=n.$$typeof,n===$e)return 11;if(n===X)return 14}return 2}function il(n,i){var a=n.alternate;return a===null?(a=ro(n.tag,i,n.key,n.mode),a.elementType=n.elementType,a.type=n.type,a.stateNode=n.stateNode,a.alternate=n,n.alternate=a):(a.pendingProps=i,a.type=n.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=n.flags&14680064,a.childLanes=n.childLanes,a.lanes=n.lanes,a.child=n.child,a.memoizedProps=n.memoizedProps,a.memoizedState=n.memoizedState,a.updateQueue=n.updateQueue,i=n.dependencies,a.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},a.sibling=n.sibling,a.index=n.index,a.ref=n.ref,a}function gd(n,i,a,f,p,y){var A=2;if(f=n,typeof n=="function")Ff(n)&&(A=1);else if(typeof n=="string")A=5;else e:switch(n){case Y:return Hl(a.children,p,y,i);case oe:A=8,p|=8;break;case le:return n=ro(12,a,i,p|2),n.elementType=le,n.lanes=y,n;case K:return n=ro(13,a,i,p),n.elementType=K,n.lanes=y,n;case U:return n=ro(19,a,i,p),n.elementType=U,n.lanes=y,n;case J:return _d(a,p,y,i);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case _e:A=10;break e;case Te:A=9;break e;case $e:A=11;break e;case X:A=14;break e;case V:A=16,f=null;break e}throw Error(r(130,n==null?n:typeof n,""))}return i=ro(A,a,i,p),i.elementType=n,i.type=f,i.lanes=y,i}function Hl(n,i,a,f){return n=ro(7,n,f,i),n.lanes=a,n}function _d(n,i,a,f){return n=ro(22,n,f,i),n.elementType=J,n.lanes=a,n.stateNode={isHidden:!1},n}function Of(n,i,a){return n=ro(6,n,null,i),n.lanes=a,n}function Df(n,i,a){return i=ro(4,n.children!==null?n.children:[],n.key,i),i.lanes=a,i.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},i}function bx(n,i,a,f,p){this.tag=i,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=pr(0),this.expirationTimes=pr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pr(0),this.identifierPrefix=f,this.onRecoverableError=p,this.mutableSourceEagerHydrationData=null}function Bf(n,i,a,f,p,y,A,q,ee){return n=new bx(n,i,a,q,ee),i===1?(i=1,y===!0&&(i|=8)):i=0,y=ro(3,null,null,i),n.current=y,y.stateNode=n,y.memoizedState={element:f,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},gc(y),n}function Sx(n,i,a){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ne,key:f==null?null:""+f,children:n,containerInfo:i,implementation:a}}function up(n){if(!n)return Xi;n=n._reactInternals;e:{if(Nn(n)!==n||n.tag!==1)throw Error(r(170));var i=n;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(rs(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(r(171))}if(n.tag===1){var a=n.type;if(rs(a))return Si(n,a,i)}return i}function dp(n,i,a,f,p,y,A,q,ee){return n=Bf(a,f,!0,n,p,y,A,q,ee),n.context=up(null),a=n.current,f=ti(),p=rl(a),y=Ji(f,p),y.callback=i??null,No(a,y,p),n.current.lanes=p,Nr(n,p,f),mi(n,f),n}function yd(n,i,a,f){var p=i.current,y=ti(),A=rl(p);return a=up(a),i.context===null?i.context=a:i.pendingContext=a,i=Ji(y,A),i.payload={element:n},f=f===void 0?null:f,f!==null&&(i.callback=f),n=No(p,i,A),n!==null&&(To(n,p,A,y),Ll(n,p,A)),A}function xd(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function fp(n,i){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var a=n.retryLane;n.retryLane=a!==0&&a<i?a:i}}function Uf(n,i){fp(n,i),(n=n.alternate)&&fp(n,i)}function jx(){return null}var mp=typeof reportError=="function"?reportError:function(n){console.error(n)};function Wf(n){this._internalRoot=n}vd.prototype.render=Wf.prototype.render=function(n){var i=this._internalRoot;if(i===null)throw Error(r(409));yd(n,i,null,null)},vd.prototype.unmount=Wf.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var i=n.containerInfo;Bl(function(){yd(null,n,null,null)}),i[yr]=null}};function vd(n){this._internalRoot=n}vd.prototype.unstable_scheduleHydration=function(n){if(n){var i=fr();n={blockedOn:null,target:n,priority:i};for(var a=0;a<es.length&&i!==0&&i<es[a].priority;a++);es.splice(a,0,n),a===0&&Fi(n)}};function Hf(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function wd(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function hp(){}function kx(n,i,a,f,p){if(p){if(typeof f=="function"){var y=f;f=function(){var we=xd(A);y.call(we)}}var A=dp(i,f,n,0,null,!1,!1,"",hp);return n._reactRootContainer=A,n[yr]=A.current,qo(n.nodeType===8?n.parentNode:n),Bl(),A}for(;p=n.lastChild;)n.removeChild(p);if(typeof f=="function"){var q=f;f=function(){var we=xd(ee);q.call(we)}}var ee=Bf(n,0,!1,null,null,!1,!1,"",hp);return n._reactRootContainer=ee,n[yr]=ee.current,qo(n.nodeType===8?n.parentNode:n),Bl(function(){yd(i,ee,a,f)}),ee}function bd(n,i,a,f,p){var y=a._reactRootContainer;if(y){var A=y;if(typeof p=="function"){var q=p;p=function(){var ee=xd(A);q.call(ee)}}yd(i,A,n,p)}else A=kx(a,i,n,p,f);return xd(A)}Vs=function(n){switch(n.tag){case 3:var i=n.stateNode;if(i.current.memoizedState.isDehydrated){var a=dr(i.pendingLanes);a!==0&&(Li(i,a|1),mi(i,En()),(Mn&6)===0&&(Cc=En()+500,Os()))}break;case 13:Bl(function(){var f=Ki(n,1);if(f!==null){var p=ti();To(f,n,1,p)}}),Uf(n,1)}},$s=function(n){if(n.tag===13){var i=Ki(n,134217728);if(i!==null){var a=ti();To(i,n,134217728,a)}Uf(n,134217728)}},tr=function(n){if(n.tag===13){var i=rl(n),a=Ki(n,i);if(a!==null){var f=ti();To(a,n,i,f)}Uf(n,i)}},fr=function(){return rn},gi=function(n,i){var a=rn;try{return rn=n,i()}finally{rn=a}},ls=function(n,i,a){switch(i){case"input":if(ze(n,a),i=a.name,a.type==="radio"&&i!=null){for(a=n;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<a.length;i++){var f=a[i];if(f!==n&&f.form===n.form){var p=ac(f);if(!p)throw Error(r(90));de(f),ze(f,p)}}}break;case"textarea":ln(n,a);break;case"select":i=a.value,i!=null&&Et(n,!!a.multiple,i,!1)}},bt=Lf,zt=Bl;var Nx={usingClientEntryPoint:!1,Events:[Tl,Ha,ac,ct,it,Lf]},xu={findFiberByHostInstance:oi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Cx={bundleType:xu.bundleType,version:xu.version,rendererPackageName:xu.rendererPackageName,rendererConfig:xu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:I.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=Fr(n),n===null?null:n.stateNode},findFiberByHostInstance:xu.findFiberByHostInstance||jx,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 Sd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Sd.isDisabled&&Sd.supportsFiber)try{dn=Sd.inject(Cx),Dr=Sd}catch{}}return hi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Nx,hi.createPortal=function(n,i){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Hf(i))throw Error(r(200));return Sx(n,i,null,a)},hi.createRoot=function(n,i){if(!Hf(n))throw Error(r(299));var a=!1,f="",p=mp;return i!=null&&(i.unstable_strictMode===!0&&(a=!0),i.identifierPrefix!==void 0&&(f=i.identifierPrefix),i.onRecoverableError!==void 0&&(p=i.onRecoverableError)),i=Bf(n,1,!1,null,null,a,!1,f,p),n[yr]=i.current,qo(n.nodeType===8?n.parentNode:n),new Wf(i)},hi.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var i=n._reactInternals;if(i===void 0)throw typeof n.render=="function"?Error(r(188)):(n=Object.keys(n).join(","),Error(r(268,n)));return n=Fr(i),n=n===null?null:n.stateNode,n},hi.flushSync=function(n){return Bl(n)},hi.hydrate=function(n,i,a){if(!wd(i))throw Error(r(200));return bd(null,n,i,!0,a)},hi.hydrateRoot=function(n,i,a){if(!Hf(n))throw Error(r(405));var f=a!=null&&a.hydratedSources||null,p=!1,y="",A=mp;if(a!=null&&(a.unstable_strictMode===!0&&(p=!0),a.identifierPrefix!==void 0&&(y=a.identifierPrefix),a.onRecoverableError!==void 0&&(A=a.onRecoverableError)),i=dp(i,null,n,1,a??null,p,!1,y,A),n[yr]=i.current,qo(n),f)for(n=0;n<f.length;n++)a=f[n],p=a._getVersion,p=p(a._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[a,p]:i.mutableSourceEagerHydrationData.push(a,p);return new vd(i)},hi.render=function(n,i,a){if(!wd(i))throw Error(r(200));return bd(null,n,i,!1,a)},hi.unmountComponentAtNode=function(n){if(!wd(n))throw Error(r(40));return n._reactRootContainer?(Bl(function(){bd(null,null,n,!1,function(){n._reactRootContainer=null,n[yr]=null})}),!0):!1},hi.unstable_batchedUpdates=Lf,hi.unstable_renderSubtreeIntoContainer=function(n,i,a,f){if(!wd(a))throw Error(r(200));if(n==null||n._reactInternals===void 0)throw Error(r(38));return bd(n,i,a,!1,f)},hi.version="18.3.1-next-f1338f8080-20240426",hi}var bp;function Xg(){if(bp)return Gf.exports;bp=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Gf.exports=Px(),Gf.exports}var Sp;function Ix(){if(Sp)return jd;Sp=1;var e=Xg();return jd.createRoot=e.createRoot,jd.hydrateRoot=e.hydrateRoot,jd}var Fx=Ix();const Ox=th(Fx);function Kg(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Jg(e){return Array.isArray(e)}function Dx(e){const t=e.trim();if(!t)return e;if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function Bx(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}async function Ux(e){const t=String(e||"");if(t)try{await navigator.clipboard.writeText(t)}catch{const r=document.createElement("textarea");r.value=t,document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}}function Pc({kind:e,children:t}){return s.jsx("span",{className:`json-token ${e}`,children:t})}function Wx(e){return e===null?s.jsx(Pc,{kind:"null",children:"null"}):typeof e=="string"?s.jsx(Pc,{kind:"string",children:JSON.stringify(e)}):typeof e=="number"?s.jsx(Pc,{kind:"number",children:String(e)}):typeof e=="boolean"?s.jsx(Pc,{kind:"boolean",children:e?"true":"false"}):s.jsx(Pc,{kind:"string",children:JSON.stringify(String(e))})}function Hx(e){return Jg(e)?e.length===1?"1 item":`${e.length} items`:Kg(e)?Object.keys(e).length===1?"1 key":`${Object.keys(e).length} keys`:""}function Qg(e){const{label:t,value:r,depth:o,collapse_after_depth:l,trailing_comma:u}=e,c=o*14,d=Kg(r),h=Jg(r),_=d||h,g=o<l,[x,v]=m.useState(g),b=t?s.jsxs(s.Fragment,{children:[s.jsx(Pc,{kind:"key",children:JSON.stringify(t)}),": "]}):null;if(!_)return s.jsxs("div",{className:"json-viewer__line",style:{paddingLeft:c},children:[b,Wx(r),u?",":""]});const j=h?"[":"{",S=h?"]":"}",T=Hx(r),M=x?`${j}`:`${j}…${S}${T?` (${T})`:""}`,D=h?r.map((L,I)=>({key:String(I),label:void 0,value:L})):Object.entries(r).map(([L,I])=>({key:L,label:L,value:I}));return s.jsxs("details",{className:"json-viewer__details",open:x,onToggle:L=>v(L.currentTarget.open),children:[s.jsxs("summary",{className:"json-viewer__summary",style:{paddingLeft:c},children:[b,s.jsx("span",{className:"json-viewer__caret","aria-hidden":"true",children:x?"▾":"▸"}),s.jsx("span",{className:"json-viewer__punct",children:M}),!x&&u?s.jsx("span",{className:"json-viewer__punct",children:","}):null]}),x?s.jsx("div",{className:"json-viewer__children",children:D.length===0?s.jsxs("div",{className:"json-viewer__line",style:{paddingLeft:c},children:[s.jsx("span",{className:"json-viewer__punct",children:S}),u?",":""]}):s.jsxs(s.Fragment,{children:[D.map((L,I)=>{const G=I===D.length-1;return s.jsx(Qg,{label:L.label,value:L.value,depth:o+1,collapse_after_depth:l,trailing_comma:!G},`${o}:${t||"root"}:${L.key}`)}),s.jsxs("div",{className:"json-viewer__line",style:{paddingLeft:c},children:[s.jsx("span",{className:"json-viewer__punct",children:S}),u?",":""]})]})}):null]})}function Zg(e){const{value:t,className:r,showCopy:o=!0}=e,l=Number.isFinite(e.collapseAfterDepth??NaN)?Number(e.collapseAfterDepth):3,u=m.useMemo(()=>typeof t=="string"?Dx(t):t,[t]),c=m.useMemo(()=>Bx(t),[t]),d=["json-viewer","run-details-output",r].filter(Boolean).join(" ");return s.jsxs("div",{className:d,children:[o?s.jsx("div",{className:"json-viewer__toolbar",children:s.jsx("button",{type:"button",className:"modal-button json-viewer__copy",onClick:()=>void Ux(c),children:"Copy"})}):null,s.jsx("div",{className:"json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:s.jsx(Qg,{value:u,depth:0,collapse_after_depth:l,trailing_comma:!1})})]})}function Kf(e){const t=[],r=String(e??"");let o=0,l="";const u=()=>{l&&(t.push(l),l="")};for(;o<r.length;){const c=r[o];if(c==="`"){const d=r.indexOf("`",o+1);if(d!==-1){u(),t.push(s.jsx("code",{children:r.slice(o+1,d)},`code:${o}`)),o=d+1;continue}}if(c==="*"&&r[o+1]==="*"){const d=r.indexOf("**",o+2);if(d!==-1){u(),t.push(s.jsx("strong",{children:r.slice(o+2,d)},`bold:${o}`)),o=d+2;continue}}l+=c,o+=1}return u(),t}function Vx(e){return String(e??"").replace(/\r\n/g,`
|
|
41
|
+
`).replace(/\r/g,`
|
|
42
|
+
`).split(`
|
|
43
|
+
`)}function qx({text:e,className:t}){const r=Vx(e),o=[];let l=0;for(;l<r.length;){const c=r[l],d=String(c??"");if(!d.trim()){l+=1;continue}if(d.trim().startsWith("```")){const v=d.trim().replace(/```/g,"").trim(),b=[];for(l+=1;l<r.length&&!String(r[l]??"").trim().startsWith("```");)b.push(String(r[l]??"")),l+=1;l<r.length&&(l+=1);const j=b.join(`
|
|
44
|
+
`);o.push(s.jsx("pre",{className:"mf-md_pre",children:s.jsx("code",{className:v?`language-${v}`:void 0,children:j})},`pre:${l}`));continue}const h=d.match(/^(#{1,3})\s+(.*)$/);if(h){const x=h[1].length,v=h[2]||"",b=Kf(v);x===1?o.push(s.jsx("h1",{children:b},`h1:${l}`)):x===2?o.push(s.jsx("h2",{children:b},`h2:${l}`)):o.push(s.jsx("h3",{children:b},`h3:${l}`)),l+=1;continue}const _=x=>{const v=x.trimStart();return v.startsWith("- ")||v.startsWith("* ")};if(_(d)){const x=[];for(;l<r.length&&_(String(r[l]??""));){const v=String(r[l]??"").trimStart();x.push(v.slice(2)),l+=1}o.push(s.jsx("ul",{className:"mf-md_ul",children:x.map((v,b)=>s.jsx("li",{children:Kf(v)},`li:${l}:${b}`))},`ul:${l}`));continue}const g=[];for(;l<r.length&&String(r[l]??"").trim();)g.push(String(r[l]??"")),l+=1;o.push(s.jsx("p",{className:"mf-md_p",children:g.map((x,v)=>s.jsxs(Ee.Fragment,{children:[Kf(x),v<g.length-1?s.jsx("br",{}):null]},`pl:${l}:${v}`))},`p:${l}`))}const u=["mf-md",t].filter(Boolean).join(" ");return s.jsx("div",{className:u,children:o})}async function Gx(e){const t=String(e||"");if(t)try{await navigator.clipboard.writeText(t)}catch{const r=document.createElement("textarea");r.value=t,document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}}function ni(e){return!e||typeof e!="object"?null:e}function Cm(e,t){const r=String(e||"").replace(/\s+/g," ").trim();return r?r.length<=t?r:`${r.slice(0,Math.max(0,t-1)).trimEnd()}…`:""}function jp(e){const t=ni(e);if(!t)return null;const r=typeof t.role=="string"?String(t.role).trim():"",o=typeof t.content=="string"?String(t.content):"";if(!r||o==="")return null;const l=typeof t.name=="string"?String(t.name).trim():"";return{role:r,content:o,name:l||void 0}}function Yx(e){if(Array.isArray(e)){if(e.length===0)return null;const r=[];for(const o of e){const l=jp(o);if(!l)return null;r.push(l)}return r}const t=jp(e);return t?[t]:null}function Xx(e){const t=String(e||"").trim();if(!t)return null;const r=t[0],o=t[t.length-1];if(!(r==="{"&&o==="}"||r==="["&&o==="]"))return null;try{const u=JSON.parse(t);return u&&typeof u=="object"||Array.isArray(u)?u:null}catch{return null}}function Kx(e){const t=String(e||"");return t.trim()?!!(t.includes("```")||/\n\s*#{1,3}\s+/.test(t)||/\n\s*[-*]\s+/.test(t)||/\n\s*\d+[\.\)]\s+/.test(t)||t.includes("**")||t.includes("`")):!1}function kp({text:e}){const t=String(e||""),r=Xx(t);if(r!==null)return s.jsx(Zg,{value:r});const o=t.trim();return o.startsWith("{")||o.startsWith("[")?s.jsx("pre",{className:"run-details-output",children:t||"(none)"}):t.includes(`
|
|
45
|
+
`)||Kx(t)?s.jsx("div",{className:"run-details-output",children:s.jsx(qx,{text:t})}):s.jsx("pre",{className:"run-details-output",children:t||"(none)"})}function e_({value:e}){if(e==null)return s.jsx("pre",{className:"run-details-output",children:"(none)"});const t=Yx(e);return t?s.jsx("div",{className:"mf-msg-list",children:t.map((r,o)=>s.jsxs("div",{className:"mf-msg",children:[s.jsxs("div",{className:"mf-msg-meta",children:[s.jsx("span",{className:`mf-msg-role ${r.role}`,children:r.role}),r.name?s.jsx("span",{className:"mf-msg-name",children:r.name}):null]}),s.jsx("div",{className:"mf-msg-content",children:s.jsx(kp,{text:r.content})})]},`${r.role}:${o}`))}):typeof e=="string"?s.jsx(kp,{text:e}):s.jsx(Zg,{value:e})}function t_(e){const t=e.effect;return!t||typeof t!="object"?null:t}function _l(e){const t=t_(e);return(t&&typeof t.type=="string"?t.type:"")||"effect"}function of(e){const t=t_(e),r=t==null?void 0:t.payload;return!r||typeof r!="object"?null:r}function nh(e){const t=e.result;return!t||typeof t!="object"?null:t}function n_(e){if(_l(e)!=="tool_calls")return[];const r=nh(e),o=r&&Array.isArray(r.results)?r.results:null;if(!o)return[];const l=[];for(const u of o){const c=ni(u);if(!c)continue;const d=typeof c.name=="string"?c.name.trim():"";d&&l.push({call_id:typeof c.call_id=="string"?c.call_id:void 0,name:d,success:!!c.success,output:c.output,error:c.error})}return l}function r_(e){if(_l(e)!=="tool_calls")return[];const r=of(e),o=r&&Array.isArray(r.tool_calls)?r.tool_calls:null;if(!o)return[];const l=[];for(const u of o){const c=ni(u);if(!c)continue;const d=typeof c.name=="string"?c.name.trim():"";if(!d)continue;const h=ni(c.args)||ni(c.arguments)||{};l.push({call_id:typeof c.call_id=="string"?c.call_id:void 0,name:d,args:h})}return l}function af(e){const t=e.error;if(typeof t=="string")return t.trim();const r=ni(t);if(r){const o=typeof r.message=="string"?r.message.trim():"",l=typeof r.stack=="string"?r.stack.trim():"";return o||l||""}return""}function s_(e){if(!e)return"";const t=e.reasoning;if(typeof t=="string")return t.trim();const r=ni(t);return r&&typeof r.text=="string"?r.text.trim():""}function i_(e){const t=_l(e),r=of(e),o=nh(e),l=(u,c)=>{const d=String(u||"").replace(/\s+/g," ").trim();return d?d.length<=c?d:`${d.slice(0,Math.max(0,c-1)).trimEnd()}…`:""};if(t==="llm_call"){const u=o==null?void 0:o.content,c=typeof u=="string"?u.replace(/\s+/g," ").trim():"",d=s_(o),h=Array.isArray(o==null?void 0:o.tool_calls)?o.tool_calls:null,g=!!(h&&h.length>0)?d||c:c||d;return l(g,220)}if(t==="tool_calls"){const u=o&&Array.isArray(o.results)?o.results:null;if(!u)return"";const c=u.filter(d=>{var h;return((h=ni(d))==null?void 0:h.success)===!1});return c.length>0?`${c.length} tool call(s) failed`:`${u.length} tool call(s) executed`}return t==="ask_user"&&r&&typeof r.prompt=="string"?String(r.prompt).trim():""}function Gd(e){const t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||af(e.step)?"failed":t}function Jx(e){const t=e.map(r=>Gd(r));return t.some(r=>r==="failed")?"failed":t.some(r=>r==="waiting")?"waiting":t.some(r=>r==="running")?"running":"completed"}function Jf(e){return e.filter(t=>!t.hidden)}function Qx(e){const t=_l(e),r=af(e);return Jf(t==="llm_call"?[{id:"system",label:"System"},{id:"user",label:"User"},{id:"tools",label:"Tools"},{id:"response",label:"Response"},{id:"reasoning",label:"Reasoning"},{id:"errors",label:"Errors",hidden:!r},{id:"raw",label:"Raw"}]:t==="tool_calls"?[{id:"tools",label:"Tools"},{id:"errors",label:"Errors",hidden:!r},{id:"raw",label:"Raw"}]:[{id:"errors",label:"Errors",hidden:!r},{id:"raw",label:"Raw"}])}function Zx(e){const t=_l(e);return t==="llm_call"?"user":t==="tool_calls"?"tools":af(e)?"errors":"raw"}function ev(e){const t=new Map,r=of(e),o=r&&Array.isArray(r.tools)?r.tools:null;if(!o)return t;for(const l of o){const u=ni(l);if(!u)continue;const c=typeof u.name=="string"?u.name.trim():"";if(!c)continue;const h=(Array.isArray(u.parameters)?u.parameters:[]).map(_=>{const g=ni(_);return(g&&typeof g.id=="string"?g.id.trim():"")||""}).filter(Boolean);t.set(c,h)}return t}function o_(e,t,r){const o=Object.keys(t||{}),l=r&&r.length?r.filter(h=>o.includes(h)):[],u=o.filter(h=>!l.includes(h)).sort(),c=[...l,...u],d=c.slice(0,5).map(h=>{const _=t[h];return typeof _=="string"?`${h}=${JSON.stringify(Cm(_,42))}`:typeof _=="number"||typeof _=="boolean"?`${h}=${String(_)}`:_==null?`${h}=null`:`${h}=${Cm(JSON.stringify(_),42)}`});return`${e}(${d.join(", ")}${c.length>5?", …":""})`}function tv(e){const t=e.ts?String(e.ts):"";if(!t)return"";try{const r=new Date(t);return Number.isFinite(r.getTime())?r.toLocaleTimeString():""}catch{return""}}function Qf({item:e,label:t,toolDefs:r,defaultOpen:o=!1}){const l=e.step,u=_l(l),c=Qx(l),d=Zx(l),[h,_]=m.useState(d),[g,x]=m.useState(!!o),v=of(l),b=nh(l),j=af(l),S=tv(e),T=e.nodeId?String(e.nodeId):"",M=e.runId?String(e.runId):"",D=u==="tool_calls"?r_(l):[],L=u==="tool_calls"?n_(l):[],I=D.map(_e=>o_(_e.name,_e.args,r.get(_e.name)||null)),ne=(()=>{if(h==="raw")return l;if(h==="errors")return j||null;if(u==="llm_call"){const _e=v||{},Te=typeof _e.system_prompt=="string"?String(_e.system_prompt):"",$e=typeof _e.prompt=="string"?String(_e.prompt):"",K=ni(b==null?void 0:b.metadata),U=K?ni(K._runtime_observability):null,X=U?ni(U.llm_generate_kwargs):null,V=X&&Array.isArray(X.messages)?X.messages:null,J=K?ni(K._provider_request):null,k=J?ni(J.payload):null,z=k&&Array.isArray(k.messages)?k.messages:null,F=Array.isArray(_e.messages)?_e.messages:[],N=V||z||F,B=N.filter(te=>String((te==null?void 0:te.role)||"").trim()==="system"),Z=N.filter(te=>String((te==null?void 0:te.role)||"").trim()==="user");if(h==="system"){const te=[],he=Te.trim(),Ae=!!he&&B.some(se=>typeof(se==null?void 0:se.content)=="string"&&String(se.content).trim()===he);return he&&!Ae&&te.push({role:"system",name:"system_prompt",content:Te}),te.push(...B),te}if(h==="user"){const te=[],he=$e.trim(),Ae=!!he&&Z.some(se=>typeof(se==null?void 0:se.content)=="string"&&String(se.content).trim()===he);return he&&!Ae&&te.push({role:"user",name:"prompt",content:$e}),te.push(...Z),te}if(h==="tools")return _e.tools||[];if(h==="response"){const te=b==null?void 0:b.content;if(typeof te=="string"&&te.trim())return te;const he=b==null?void 0:b.output;if(he!==void 0)return he;const Ae=Array.isArray(b==null?void 0:b.tool_calls)?b.tool_calls:null;return Ae&&Ae.length?{tool_calls:Ae}:b}if(h==="reasoning")return s_(b)||null}return u==="tool_calls"&&h==="tools"?{tool_calls:D,tool_signatures:I,results:L}:l})(),Y=i_(l),oe=Gd(e),le=oe==="completed"?"OK":oe==="failed"?"ERROR":oe==="waiting"?"WAITING":oe.toUpperCase();return s.jsxs("details",{className:`agent-trace-entry ${oe}`,open:g,onToggle:_e=>x(_e.currentTarget.open),children:[s.jsxs("summary",{className:"agent-trace-summary",children:[s.jsx("span",{className:`agent-trace-status ${oe}`,children:le}),s.jsx("span",{className:"agent-cycle-stage",children:t}),s.jsx("span",{className:"agent-trace-kind",children:u}),S?s.jsx("span",{className:"agent-trace-node",children:S}):null,T?s.jsx("span",{className:"agent-trace-node",children:T}):null,M?s.jsx("span",{className:"agent-trace-run",children:M}):null]}),Y?s.jsx("div",{className:"agent-trace-preview",children:Y}):null,s.jsxs("div",{className:"agent-trace-body",children:[s.jsx("div",{className:"agent-trace-tabs",children:c.map(_e=>s.jsx("button",{type:"button",className:`agent-trace-tab ${_e.id===h?"active":""}`,onClick:()=>_(_e.id),children:_e.label},_e.id))}),s.jsx(e_,{value:ne})]})]})}function nv({acts:e}){const t=e.flatMap(u=>n_(u.step)),r=t.filter(u=>u.success===!1),o=r.length?`${r.length} error(s)`:t.length?`${t.length} tool result(s)`:"(none)",l=r.length?"failed":"completed";return s.jsxs("details",{className:`agent-trace-entry ${l}`,open:!1,children:[s.jsxs("summary",{className:"agent-trace-summary",children:[s.jsx("span",{className:`agent-trace-status ${l}`,children:r.length?"ERROR":"OK"}),s.jsx("span",{className:"agent-cycle-stage",children:"observe"}),s.jsx("span",{className:"agent-trace-kind",children:"OBSERVATIONS"}),s.jsx("span",{className:"agent-trace-preview-inline",children:o})]}),s.jsx("div",{className:"agent-observe-body",children:t.length===0?s.jsx("div",{className:"agent-observe-empty",children:"(no tool results)"}):s.jsx("div",{className:"agent-observe-results",children:t.map((u,c)=>{const d=u.success?"completed":"failed",h=u.success?"OK":"ERROR",_=u.success?u.output:u.error??u.output;return s.jsxs("details",{className:`agent-observe-result ${d}`,open:!1,children:[s.jsxs("summary",{className:"agent-observe-summary",children:[s.jsx("span",{className:`agent-trace-status ${d}`,children:h}),s.jsx("span",{className:"agent-observe-name",children:u.name}),u.call_id?s.jsx("span",{className:"agent-observe-callid",children:u.call_id}):null]}),s.jsx(e_,{value:_})]},`${u.name}:${u.call_id||""}:${c}`)})})})]})}function rv({items:e,subRunId:t,title:r,subtitle:o,onOpenSubRun:l,defaultOpenLatest:u=!0}){const c=m.useMemo(()=>{const x=Array.isArray(e)?e.slice():[];return x.sort((v,b)=>{const j=v.ts?new Date(v.ts).getTime():NaN,S=b.ts?new Date(b.ts).getTime():NaN;return Number.isFinite(j)&&Number.isFinite(S)?j-S:0}),x},[e]),d=m.useMemo(()=>{const x=[];let v=null,b=0;for(const j of c){const S=_l(j.step);if(S==="llm_call"){b+=1,v={id:`cycle:${j.runId}:${b}:${j.ts||""}`,index:b,items:[j],think:j,acts:[],others:[],status:Gd(j),ts:j.ts},x.push(v);continue}v||(b+=1,v={id:`cycle:${j.runId}:${b}:${j.ts||""}`,index:b,items:[],think:null,acts:[],others:[],status:Gd(j),ts:j.ts},x.push(v)),v.items.push(j),S==="tool_calls"?v.acts.push(j):v.others.push(j),v.status=Jx(v.items)}return x},[c]),h=typeof r=="string"&&r.trim()?r.trim():"Agent calls",_=typeof o=="string"&&o.trim()?o.trim():"Live per-effect trace (LLM/tool calls).",g=typeof t=="string"?t.trim():"";return s.jsxs("div",{className:"agent-trace-panel",children:[s.jsxs("div",{className:"agent-trace-header",children:[s.jsx("div",{className:"agent-trace-title",children:h}),s.jsxs("div",{className:"agent-trace-subtitle",children:[_,g?s.jsxs("span",{className:"agent-trace-subrun",children:[" ","sub_run_id: ",g,s.jsx("button",{type:"button",className:"agent-trace-copy",onClick:x=>{x.stopPropagation(),Gx(g)},title:`Copy sub_run_id: ${g}`,"aria-label":"Copy sub run id",children:"⧉"}),l?s.jsx("button",{type:"button",className:"agent-trace-open",onClick:x=>{x.stopPropagation(),l()},title:"Open sub-run",children:"Open"}):null]}):null]})]}),c.length===0?s.jsx("div",{className:"agent-trace-empty",children:"No trace entries yet."}):s.jsxs("div",{className:"agent-cycle-list",children:[s.jsxs("div",{className:"agent-cycle-meta",children:[d.length," cycle(s)"]}),d.map(x=>{const v=x.status,b=v==="completed"?"OK":v==="failed"?"ERROR":v==="waiting"?"WAITING":v.toUpperCase(),j=v==="completed"?"✓":v==="failed"?"✗":"",S=j?`${j} ${b}`:b,T=x.think?i_(x.think.step):"",M=x.think?ev(x.think.step):new Map,L=x.acts.flatMap(G=>r_(G.step)).map(G=>o_(G.name,G.args,M.get(G.name)||null)),I=u&&x.index===d.length;return s.jsxs("details",{className:`agent-cycle ${v}`,open:I,children:[s.jsxs("summary",{className:"agent-cycle-summary",children:[s.jsx("span",{className:`agent-trace-status ${v}`,children:S}),s.jsx("span",{className:"agent-cycle-label",children:"cycle"}),s.jsxs("span",{className:"agent-cycle-index",children:["#",x.index]}),L.length?s.jsxs("span",{className:"agent-trace-badges",children:[L.slice(0,3).map(G=>s.jsx("span",{className:"run-metric-badge metric-tool",title:G,children:Cm(G,62)},G)),L.length>3?s.jsxs("span",{className:"run-metric-badge metric-tool",children:["+",L.length-3]}):null]}):null,s.jsx("span",{className:"agent-cycle-spacer"}),T?s.jsx("span",{className:"agent-cycle-preview",children:T}):null]}),s.jsxs("div",{className:"agent-cycle-body",children:[x.think?s.jsx(Qf,{item:x.think,label:"think",toolDefs:M,defaultOpen:I}):null,x.acts.map(G=>s.jsx(Qf,{item:G,label:"act",toolDefs:M},G.id)),s.jsx(nv,{acts:x.acts}),x.others.length?s.jsxs("div",{className:"agent-cycle-others",children:[s.jsx("div",{className:"agent-cycle-others-title",children:"other"}),x.others.map(G=>{const ne=I&&_l(G.step)==="answer_user";return s.jsx(Qf,{item:G,label:"other",toolDefs:M,defaultOpen:ne},G.id)})]}):null]})]},x.id)})]})]})}function Lo(e){return typeof e=="string"?e.trim():""}function sv(e){var t;return Lo(e.run_id)||Lo((t=e.record)==null?void 0:t.run_id)}function Em(e){return Lo(e==null?void 0:e.node_id)}const iv=new Set(["reason","act","observe","thought","think"]);function $m(e){const t=Lo(e);if(!t.includes("::"))return t;const r=t.split("::");if(r.length<2)return t;const o=String(r[r.length-1]||"").trim().toLowerCase();return iv.has(o)?r.slice(0,-1).join("::"):t}function a_(e){var t;return Lo((t=e==null?void 0:e.effect)==null?void 0:t.type)}function ov(e){return Lo(e==null?void 0:e.status)||"unknown"}function Np(e){return Lo(e==null?void 0:e.step_id)}function av(e){return Lo(e==null?void 0:e.ended_at)||Lo(e==null?void 0:e.started_at)}function lv(e){const t=new Map,r=new Map;for(const l of e){const u=$m(Em(l));if(!u)continue;const c=a_(l);c==="llm_call"?t.set(u,(t.get(u)||0)+1):c==="tool_calls"&&r.set(u,(r.get(u)||0)+1)}const o=l=>{let u="",c=-1;for(const[d,h]of l)h>c&&(u=d,c=h);return u};return o(t)||o(r)||""}function cv(e,t){const r=Lo(t.run_id);if(!r)return{run_id:"",node_id:"",items:[]};const o=(Array.isArray(e)?e:[]).filter(b=>b&&b.record&&sv(b)===r).map(b=>({cursor:b.cursor,record:b.record})).sort((b,j)=>(b.cursor||0)-(j.cursor||0)),l=o.map(b=>b.record),u=$m(Lo(t.node_id)),c=u||lv(l),d=new Set(["llm_call","tool_calls","ask_user","answer_user"]);let h=o.filter(b=>d.has(a_(b.record)));u&&(h=h.filter(b=>$m(Em(b.record))===u));const _=new Map,g=[];for(const b of h){const j=Np(b.record);if(!j){g.push(b);continue}const S=_.get(j);(!S||(b.cursor||0)>(S.cursor||0))&&_.set(j,b)}const v=[...g,...Array.from(_.values())].sort((b,j)=>(b.cursor||0)-(j.cursor||0)).map(b=>{const j=b.record,S=Em(j)||"(node?)",T=av(j),M=Np(j);return{id:`ledger:${r}:${b.cursor}:${M||""}`,runId:r,nodeId:S,ts:T||void 0,status:ov(j),step:j}});return{run_id:r,node_id:c,items:v}}function l_(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function c_(e){return Array.isArray(e)}function uv(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}async function dv(e){const t=String(e||"");if(t)try{await navigator.clipboard.writeText(t)}catch{const r=document.createElement("textarea");r.value=t,document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r)}}function Ic({kind:e,children:t}){return s.jsx("span",{className:`pc-json-token ${e}`,children:t})}function fv(e){return e===null?s.jsx(Ic,{kind:"null",children:"null"}):typeof e=="string"?s.jsx(Ic,{kind:"string",children:JSON.stringify(e)}):typeof e=="number"?s.jsx(Ic,{kind:"number",children:String(e)}):typeof e=="boolean"?s.jsx(Ic,{kind:"boolean",children:e?"true":"false"}):s.jsx(Ic,{kind:"string",children:JSON.stringify(String(e))})}function mv(e){return c_(e)?e.length===1?"1 item":`${e.length} items`:l_(e)?Object.keys(e).length===1?"1 key":`${Object.keys(e).length} keys`:""}function u_(e){const{label:t,value:r,depth:o,collapseAfterDepth:l,trailingComma:u}=e,c=o*14,d=l_(r),h=c_(r),_=d||h,g=o<l,[x,v]=m.useState(g),b=t?s.jsxs(s.Fragment,{children:[s.jsx(Ic,{kind:"key",children:JSON.stringify(t)}),": "]}):null;if(!_)return s.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:c},children:[b,fv(r),u?",":""]});const j=h?"[":"{",S=h?"]":"}",T=mv(r),M=x?`${j}`:`${j}…${S}${T?` (${T})`:""}`,D=h?r.map((L,I)=>({key:String(I),label:void 0,value:L})):Object.entries(r).map(([L,I])=>({key:L,label:L,value:I}));return s.jsxs("details",{className:"pc-json-viewer__details",open:x,onToggle:L=>v(L.currentTarget.open),children:[s.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:c},children:[b,s.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:x?"▾":"▸"}),s.jsx("span",{className:"pc-json-viewer__punct",children:M}),!x&&u?s.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),x?s.jsx("div",{className:"pc-json-viewer__children",children:D.length===0?s.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:c},children:[s.jsx("span",{className:"pc-json-viewer__punct",children:S}),u?",":""]}):s.jsxs(s.Fragment,{children:[D.map((L,I)=>{const G=I===D.length-1;return s.jsx(u_,{label:L.label,value:L.value,depth:o+1,collapseAfterDepth:l,trailingComma:!G},`${o}:${t||"root"}:${L.key}`)}),s.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:c},children:[s.jsx("span",{className:"pc-json-viewer__punct",children:S}),u?",":""]})]})}):null]})}function hv(e){const{value:t,className:r,showCopy:o=!0}=e,l=Number.isFinite(e.collapseAfterDepth??NaN)?Number(e.collapseAfterDepth):3,u=m.useMemo(()=>uv(t),[t]),c=["pc-json-viewer",r].filter(Boolean).join(" ");return s.jsxs("div",{className:c,children:[o?s.jsx("div",{className:"pc-json-viewer__toolbar",children:s.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__copy",onClick:()=>void dv(u),children:"Copy"})}):null,s.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:s.jsx(u_,{value:t,depth:0,collapseAfterDepth:l,trailingComma:!1})})]})}function kd(e,t){const r=String(e??"");if(!t||!t.needles.length)return[r];const o=[],l=r.toLowerCase();let u=0;for(;u<r.length;){let c=-1,d="";for(let g=0;g<t.needlesLower.length;g++){const x=t.needlesLower[g];if(!x)continue;const v=l.indexOf(x,u);if(v===-1)continue;const b=t.needles[g]||"";b&&(c===-1||v<c||v===c&&b.length>d.length)&&(c=v,d=b)}if(c===-1||!d){o.push(r.slice(u));break}c>u&&o.push(r.slice(u,c));const h=t.hits===0&&t.id?t.id:void 0,_=r.slice(c,c+d.length);o.push(s.jsx("span",{id:h,className:t.className,children:_},`hl:${t.hits}`)),t.hits+=1,u=c+d.length}return o}function Vl(e,t){const r=[],o=String(e??"");let l=0,u="";const c=()=>{if(u){for(const d of kd(u,t))r.push(d);u=""}};for(;l<o.length;){const d=o[l];if(d==="`"){const h=o.indexOf("`",l+1);if(h!==-1){c();const _=o.slice(l+1,h);r.push(s.jsx("code",{children:t?kd(_,t):_},`code:${l}`)),l=h+1;continue}}if(d==="*"&&o[l+1]==="*"){const h=o.indexOf("**",l+2);if(h!==-1){c();const _=o.slice(l+2,h);r.push(s.jsx("strong",{children:t?kd(_,t):_},`bold:${l}`)),l=h+2;continue}}if(d==="*"&&o[l+1]!=="*"){const h=o.indexOf("*",l+1);if(h!==-1){c();const _=o.slice(l+1,h);r.push(s.jsx("em",{children:t?kd(_,t):_},`em:${l}`)),l=h+1;continue}}u+=d,l+=1}return c(),r}function pv(e){return String(e??"").replace(/\r\n/g,`
|
|
46
|
+
`).replace(/\r/g,`
|
|
47
|
+
`).split(`
|
|
48
|
+
`)}function Cp(e){let t=String(e??"").trim();return t?(t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(r=>String(r??"").trim())):[]}function gv(e){let t=String(e??"").trim();if(!t)return!1;t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1));const r=t.split("|").map(o=>String(o??"").trim());return r.length<2?!1:r.every(o=>/^:?-{3,}:?$/.test(o))}function ao({text:e,className:t,highlight:r,highlights:o,highlightClassName:l,highlightId:u}){const c=pv(e),d=[],h=[];Array.isArray(o)&&h.push(...o),typeof r=="string"&&r.trim()&&h.push(r);const _=Array.from(new Set(h.map(b=>String(b??"").trim()).filter(Boolean))).filter(b=>b.length>=4),g=_.length?{needles:_,needlesLower:_.map(b=>b.toLowerCase()),className:l||"pc-md_hl",id:u,hits:0}:null;let x=0;for(;x<c.length;){const b=String(c[x]??"");if(!b.trim()){x+=1;continue}const j=b.trim();if(j==="---"||j==="___"||j==="***"||/^(-{3,}|_{3,}|\*{3,})$/.test(j)){d.push(s.jsx("hr",{className:"pc-md_hr"},`hr:${x}`)),x+=1;continue}if(b.trim().startsWith("```")){const I=b.trim().replace(/```/g,"").trim(),G=[];for(x+=1;x<c.length&&!String(c[x]??"").trim().startsWith("```");)G.push(String(c[x]??"")),x+=1;x<c.length&&(x+=1);const ne=G.join(`
|
|
49
|
+
`);d.push(s.jsx("pre",{className:"pc-md_pre",children:s.jsx("code",{className:I?`language-${I}`:void 0,children:ne})},`pre:${x}`));continue}const S=b.match(/^(#{1,5})\s+(.*)$/);if(S){const L=S[1].length,I=S[2]||"",G=Vl(I,g);L===1?d.push(s.jsx("h1",{children:G},`h1:${x}`)):L===2?d.push(s.jsx("h2",{children:G},`h2:${x}`)):L===3?d.push(s.jsx("h3",{children:G},`h3:${x}`)):L===4?d.push(s.jsx("h4",{children:G},`h4:${x}`)):d.push(s.jsx("h5",{children:G},`h5:${x}`)),x+=1;continue}if(b.trimStart().startsWith(">")){const L=[];for(;x<c.length&&String(c[x]??"").trimStart().startsWith(">");){const G=String(c[x]??"").trimStart();L.push(G.replace(/^>\s?/,"")),x+=1}d.push(s.jsx("blockquote",{className:"pc-md_quote",children:L.map((I,G)=>s.jsxs(Ee.Fragment,{children:[Vl(I,g),G<L.length-1?s.jsx("br",{}):null]},`q:${x}:${G}`))},`quote:${x}`));continue}if(b.includes("|")&&x+1<c.length&&gv(String(c[x+1]??""))){const L=Cp(b),I=Math.max(1,L.length),G=[];for(x+=2;x<c.length;){const ne=String(c[x]??"");if(!ne.trim()||!ne.includes("|"))break;const Y=Cp(ne),oe=[];for(let le=0;le<I;le++)oe.push(Y[le]??"");G.push(oe),x+=1}d.push(s.jsx("div",{className:"pc-md_table_wrap",children:s.jsxs("table",{className:"pc-md_table",children:[s.jsx("thead",{children:s.jsx("tr",{children:L.slice(0,I).map((ne,Y)=>s.jsx("th",{children:Vl(ne,g)},`th:${x}:${Y}`))})}),s.jsx("tbody",{children:G.map((ne,Y)=>s.jsx("tr",{children:ne.map((oe,le)=>s.jsx("td",{children:Vl(oe,g)},`td:${x}:${Y}:${le}`))},`tr:${x}:${Y}`))})]})},`table:${x}`));continue}const T=L=>/^\s*\d+\.\s+/.test(L);if(T(b)){const L=[];for(;x<c.length&&T(String(c[x]??""));){const I=String(c[x]??"");L.push(I.replace(/^\s*\d+\.\s+/,"")),x+=1}d.push(s.jsx("ol",{className:"pc-md_ol",children:L.map((I,G)=>s.jsx("li",{children:Vl(I,g)},`oli:${x}:${G}`))},`ol:${x}`));continue}const M=L=>{const I=L.trimStart();return I.startsWith("- ")||I.startsWith("* ")};if(M(b)){const L=[];for(;x<c.length&&M(String(c[x]??""));){const I=String(c[x]??"").trimStart();L.push(I.slice(2)),x+=1}d.push(s.jsx("ul",{className:"pc-md_ul",children:L.map((I,G)=>s.jsx("li",{children:Vl(I,g)},`li:${x}:${G}`))},`ul:${x}`));continue}const D=[];for(;x<c.length&&String(c[x]??"").trim();)D.push(String(c[x]??"")),x+=1;d.push(s.jsx("p",{className:"pc-md_p",children:D.map((L,I)=>s.jsxs(Ee.Fragment,{children:[Vl(L,g),I<D.length-1?s.jsx("br",{}):null]},`pl:${x}:${I}`))},`p:${x}`))}const v=["pc-md",t].filter(Boolean).join(" ");return s.jsx("div",{className:v,children:d})}function d_(e){const t=String(e??"").trim();if(!t||!(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")))return null;try{return JSON.parse(t)}catch{return null}}function _v(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function yv(e){const t=String(e.role||"message").trim()||"message",r=String(e.title||"").trim(),o=String(e.ts||"").trim(),l=[t];return r&&l.push(r),o&&l.push(o),l.join(" · ")}function xv(e){return e.endsWith(`
|
|
50
|
+
`)?e:`${e}
|
|
51
|
+
`}function vv(e){return String(e||"").trimStart().startsWith("```")}function wv(e,t){const o=[`# ${String((t==null?void 0:t.heading)||"Chat").trim()||"Chat"}`,""];for(const l of e){const u=yv(l);o.push(`## ${u}`,"");const c=String(l.content||""),d=d_(c);d!==null&&!vv(c)?o.push("```json",_v(d).trimEnd(),"```",""):o.push(xv(c).trimEnd(),""),o.push("---","")}for(;o.length&&!o[o.length-1].trim();)o.pop();return o.length&&o[o.length-1]==="---"&&o.pop(),`${o.join(`
|
|
52
|
+
`).trimEnd()}
|
|
53
|
+
`}async function Ns(e){const t=String(e||"");if(!t)return!1;try{return await navigator.clipboard.writeText(t),!0}catch{try{const r=document.createElement("textarea");return r.value=t,r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r),!0}catch{return!1}}}function bv(e){const t=String(e.filename||"").trim()||"export.txt",r=String(e.text||""),o=String(e.mime),l=new Blob([r],{type:o}),u=URL.createObjectURL(l),c=document.createElement("a");c.href=u,c.download=t,document.body.appendChild(c),c.click(),c.remove(),window.setTimeout(()=>URL.revokeObjectURL(u),1e3)}function Sv(e){const t=String(e.text??""),r=d_(t),o=["pc-chat-content",e.className].filter(Boolean).join(" ");return r!==null?s.jsx("div",{className:o,children:s.jsx(hv,{value:r,collapseAfterDepth:e.jsonCollapseAfterDepth})}):e.renderMarkdown?s.jsx("div",{className:o,children:e.renderMarkdown(t)}):s.jsx("div",{className:o,children:s.jsx(ao,{text:t})})}const Bd=Ee.forwardRef(function(t,r){const o=typeof t.rows=="number"&&Number.isFinite(t.rows)?Math.max(1,Math.trunc(t.rows)):3,l=!!t.disabled,u=!!t.busy,c=!l&&!u&&!!String(t.value||"").trim();return s.jsxs("div",{className:["pc-composer",t.className].filter(Boolean).join(" "),children:[s.jsx("textarea",{ref:r,className:["pc-composer__textarea",t.textareaClassName].filter(Boolean).join(" "),value:t.value,onChange:d=>t.onChange(d.target.value),rows:o,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off",placeholder:t.placeholder||"",disabled:l,autoFocus:!!t.autoFocus,onKeyDown:d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),t.onSubmit())}}),s.jsxs("div",{className:"pc-composer__row",children:[s.jsx("div",{className:"pc-composer__actions",children:t.actions}),s.jsx("button",{type:"button",className:t.sendButtonClassName||"pc-btn",disabled:!c,onClick:()=>t.onSubmit(),children:u?t.busyLabel||"Thinking…":t.sendLabel||"Send"})]})]})}),f_=[{id:"dark",label:"Dark (Abstract)",group:"dark",swatches:["#1a1a2e","#16213e","#0f3460","#e94560","#60a5fa","#27ae60"]},{id:"catppuccin-mocha",label:"Catppuccin Mocha",group:"dark",swatches:["#1e1e2e","#181825","#313244","#cba6f7","#89b4fa","#a6e3a1"]},{id:"catppuccin-macchiato",label:"Catppuccin Macchiato",group:"dark",swatches:["#24273a","#1e2030","#363a4f","#c6a0f6","#8aadf4","#a6da95"]},{id:"catppuccin-frappe",label:"Catppuccin Frappe",group:"dark",swatches:["#303446","#292c3c","#414559","#ca9ee6","#8caaee","#a6d189"]},{id:"rose-pine",label:"Rose Pine",group:"dark",swatches:["#191724","#1f1d2e","#26233a","#c4a7e7","#31748f","#9ccfd8"]},{id:"rose-pine-moon",label:"Rose Pine Moon",group:"dark",swatches:["#232136","#2a273f","#393552","#c4a7e7","#3e8fb0","#9ccfd8"]},{id:"tokyo-night",label:"Tokyo Night",group:"dark",swatches:["#1a1b26","#24283b","#414868","#7aa2f7","#2ac3de","#9ece6a"]},{id:"nord",label:"Nord",group:"dark",swatches:["#2e3440","#3b4252","#434c5e","#88c0d0","#5e81ac","#a3be8c"]},{id:"one-dark",label:"One Dark",group:"dark",swatches:["#282c34","#21252b","#3a3f4b","#61afef","#c678dd","#98c379"]},{id:"dracula",label:"Dracula",group:"dark",swatches:["#282a36","#343746","#44475a","#ff79c6","#8be9fd","#50fa7b"]},{id:"monokai",label:"Monokai",group:"dark",swatches:["#272822","#2d2e27","#3e3d32","#66d9ef","#a1efe4","#a6e22e"]},{id:"gruvbox",label:"Gruvbox",group:"dark",swatches:["#282828","#3c3836","#504945","#fe8019","#83a598","#b8bb26"]},{id:"solarized-dark",label:"Solarized Dark",group:"dark",swatches:["#002b36","#073642","#0b4b5a","#268bd2","#2aa198","#859900"]},{id:"everforest-dark",label:"Everforest Dark",group:"dark",swatches:["#2b3339","#323c41","#3a464c","#a7c080","#7fbbb3","#a7c080"]},{id:"catppuccin-latte",label:"Catppuccin Latte",group:"light",swatches:["#eff1f5","#e6e9ef","#ccd0da","#8839ef","#1e66f5","#40a02b"]},{id:"rose-pine-dawn",label:"Rose Pine Dawn",group:"light",swatches:["#faf4ed","#fffaf3","#f2e9e1","#907aa9","#56949f","#286983"]},{id:"one-light",label:"One Light",group:"light",swatches:["#fafafa","#ffffff","#e5e5e6","#4078f2","#a626a4","#50a14f"]},{id:"everforest-light",label:"Everforest Light",group:"light",swatches:["#fdf6e3","#fffbef","#e8e0cc","#4f8f5a","#3a94c5","#4f8f5a"]},{id:"solarized-light",label:"Solarized Light",group:"light",swatches:["#fdf6e3","#eee8d5","#e3ddc9","#268bd2","#2aa198","#859900"]},{id:"light",label:"Light",group:"light",swatches:["#f7f7fb","#ffffff","#e6e8f0","#e94560","#2563eb","#16a34a"]}];f_.map(e=>({id:e.id,label:e.label}));function jv(e){return`theme-${String(e||"").trim()||"dark"}`}function kv(e){try{const t=document.documentElement,r=Array.from(t.classList).filter(o=>o.startsWith("theme-"));for(const o of r)t.classList.remove(o);t.classList.add(jv(e))}catch{}}const Am=[{id:"sm",label:"Small",scale:.9},{id:"md",label:"Medium",scale:1},{id:"lg",label:"Large",scale:1.1},{id:"xl",label:"Extra Large",scale:1.2}],Tm=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function Nv(e){const t=String(e).trim();return Am.find(r=>r.id===t)||Am[1]}function Cv(e){const t=String(e).trim();return Tm.find(r=>r.id===t)||Tm[1]}function Ev(e){try{const t=document.documentElement,r=Nv(e.font_scale||"md"),o=Cv(e.header_density||"standard");t.style.setProperty("--font-scale",String(r.scale)),t.style.setProperty("--header-density",String(o.density))}catch{}}var $v=Xg();function $c(...e){return e.filter(Boolean).join(" ")}function Hc({value:e,options:t,placeholder:r="Select…",disabled:o=!1,loading:l=!1,searchable:u=!0,searchPlaceholder:c="Search…",allowCustom:d=!1,clearable:h=!1,minPopoverWidth:_=240,variant:g="panel",className:x,triggerClassName:v,onChange:b,renderOption:j,renderValue:S}){const T=m.useRef(null),M=m.useRef(null),D=m.useRef(null),[L,I]=m.useState(!1),[G,ne]=m.useState(""),[Y,oe]=m.useState(0),[le,_e]=m.useState("bottom"),[Te,$e]=m.useState({left:0,top:0,width:0}),K=m.useMemo(()=>{const se=String(e??"");return t.find(ve=>ve.value===se)||null},[t,e]),U=m.useMemo(()=>(K==null?void 0:K.label)||String(e||"").trim()||"",[K,e]),X=m.useMemo(()=>{const se=G.trim().toLowerCase();return se?t.filter(ve=>ve.label.toLowerCase().includes(se)||ve.value.toLowerCase().includes(se)):t},[t,G]),V=m.useMemo(()=>{if(!d)return null;const se=G.trim();return!se||t.some(Re=>Re.value===se)?null:{value:se,label:`Use "${se}"`}},[d,t,G]),J=m.useMemo(()=>V?[V,...X]:X,[V,X]),k=m.useCallback(()=>{const se=T.current;if(!se)return;const ve=se.getBoundingClientRect(),Re=Math.max(ve.width,_),Qe=Math.max(8,Math.min(ve.left,window.innerWidth-Re-8)),Pe=window.innerHeight-ve.bottom,de=ve.top,be=Pe>=220||Pe>=de?"bottom":"top";_e(be);const Fe=be==="bottom"?ve.bottom+6:ve.top-6;$e({left:Qe,top:Fe,width:Re})},[_]),z=m.useCallback(()=>{I(!1),ne("")},[]);m.useEffect(()=>{if(!L)return;k();const se=()=>k();return window.addEventListener("resize",se),window.addEventListener("scroll",se,!0),()=>{window.removeEventListener("resize",se),window.removeEventListener("scroll",se,!0)}},[L,k]),m.useEffect(()=>{if(!L)return;const se=ve=>{var Qe,Pe;const Re=ve.target;Re&&((Qe=T.current)!=null&&Qe.contains(Re)||(Pe=M.current)!=null&&Pe.contains(Re)||z())};return document.addEventListener("mousedown",se,!0),()=>document.removeEventListener("mousedown",se,!0)},[L,z]),m.useEffect(()=>{if(!L)return;const se=Math.max(0,J.findIndex(ve=>ve.value===e));oe(se===-1?0:se),u&&setTimeout(()=>{var ve;return(ve=D.current)==null?void 0:ve.focus()},0)},[L,u,e,J]);const F=se=>{b(se),z()},N=se=>{o||(se.key==="Enter"||se.key===" "?(se.preventDefault(),I(ve=>!ve)):se.key==="ArrowDown"&&(se.preventDefault(),I(!0)))},B=se=>{if(se.key==="Escape"){se.preventDefault(),z();return}if(se.key==="ArrowDown"){se.preventDefault(),oe(ve=>Math.min(ve+1,Math.max(0,J.length-1)));return}if(se.key==="ArrowUp"){se.preventDefault(),oe(ve=>Math.max(ve-1,0));return}if(se.key==="Enter"){se.preventDefault();const ve=J[Y];ve&&F(ve.value)}},Z=!!String(e||"").trim(),te=Z?U:r,he=s.jsx("span",{className:$c("af-select-value",!Z&&"af-select-value--placeholder"),children:l?"Loading…":te}),Ae=S?S(K,String(e||"")):he;return s.jsxs("span",{className:$c("af-select",g==="pin"?"af-select--pin":"af-select--panel",x),children:[s.jsxs("button",{ref:T,type:"button",className:$c("af-select-trigger",v),disabled:o,onMouseDown:se=>se.stopPropagation(),onClick:se=>{se.stopPropagation(),!o&&I(ve=>!ve)},onKeyDown:N,"aria-haspopup":"listbox","aria-expanded":L,children:[Ae,h&&Z?s.jsx("span",{className:"af-select-clear",role:"button",tabIndex:-1,onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),b(""),z()},title:"Clear",children:"×"}):null,s.jsx("span",{className:$c("af-select-caret",L&&"af-select-caret--open"),children:"▾"})]}),L?$v.createPortal(s.jsxs("div",{ref:M,className:$c("af-select-popover",le==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${Te.left}px`,top:`${Te.top}px`,width:`${Te.width}px`},onMouseDown:se=>se.stopPropagation(),onClick:se=>se.stopPropagation(),onKeyDown:B,role:"listbox",tabIndex:-1,children:[u?s.jsx("div",{className:"af-select-search",children:s.jsx("input",{ref:D,className:"af-select-search-input",value:G,onChange:se=>ne(se.target.value),placeholder:c,onKeyDown:B})}):null,s.jsx("div",{className:"af-select-options",children:J.length===0?s.jsx("div",{className:"af-select-empty",children:"No results"}):J.map((se,ve)=>{var Fe;const Re=se.value===e,Qe=ve===Y,Pe=String(se.group||"").trim(),de=ve>0?String(((Fe=J[ve-1])==null?void 0:Fe.group)||"").trim():"",be=!!Pe&&Pe!==de;return s.jsxs(Ee.Fragment,{children:[be?s.jsx("div",{className:"af-select-group",children:Pe}):null,s.jsx("div",{className:$c("af-select-option",Re&&"af-select-option--selected",Qe&&"af-select-option--highlighted"),onMouseEnter:()=>oe(ve),onMouseDown:Xe=>{Xe.preventDefault(),Xe.stopPropagation()},onClick:()=>F(se.value),children:j?j(se,{selected:Re,highlighted:Qe}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"af-select-option-label",children:se.label}),Re?s.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},se.value)})})]}),document.body):null]})}function Av(e){const t=new Set,r=[];for(const o of e||[]){if(!o||typeof o!="object")continue;const l=String(o.name||"").trim();!l||t.has(l)||(t.add(l),r.push({name:l,display_name:typeof o.display_name=="string"?o.display_name:void 0}))}return r.sort((o,l)=>o.name.localeCompare(l.name)),r}function Tv(e){const t=new Set,r=[];for(const o of e||[]){const l=String(o||"").trim();!l||t.has(l)||(t.add(l),r.push(l))}return r.sort(),r}function Mv(e){const t=e.disabled===!0,r=e.layout||"stack",o=e.allowGatewayDefault!==!1,l=String(e.gatewayDefaultLabel||"(gateway default)"),u=String(e.providerLabel||"Provider"),c=String(e.modelLabel||"Model"),d=String(e.providerPlaceholder||"(select)"),h=String(e.modelPlaceholder||"(select)"),_=String(e.provider||"").trim(),g=String(e.model||"").trim(),x=Av(e.providers),v=Tv(e.models),b=t||!!e.loadingProviders,j=t||!!e.loadingModels,S=[...o?[{value:"",label:l}]:[],...x.map(M=>({value:M.name,label:M.display_name?`${M.display_name} (${M.name})`:M.name}))],T=[...o?[{value:"",label:l}]:[],...v.map(M=>({value:M,label:M}))];return s.jsxs("div",{className:e.className,style:r==="row"?{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"flex-start"}:{display:"flex",flexDirection:"column",gap:"10px"},children:[s.jsxs("div",{style:r==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[s.jsx("label",{children:u}),s.jsx(Hc,{value:_,options:S,placeholder:o?l:d,disabled:b,loading:!!e.loadingProviders,searchable:!0,allowCustom:e.allowCustomProvider===!0,clearable:o,variant:"panel",triggerClassName:e.selectClassName,onChange:M=>e.onChange({provider:String(M||"").trim(),model:""})}),e.loadingProviders?s.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading providers…"}):null,e.providerError?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"12px",marginTop:"6px"},children:e.providerError}):null]}),s.jsxs("div",{style:r==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[s.jsx("label",{children:c}),s.jsx(Hc,{value:g,options:T,placeholder:o?l:h,disabled:j,loading:!!e.loadingModels,searchable:!0,allowCustom:e.allowCustomModel===!0,clearable:o,variant:"panel",triggerClassName:e.selectClassName,onChange:M=>e.onChange({provider:_,model:String(M||"").trim()})}),e.loadingModels?s.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading models…"}):null,e.modelError?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"12px",marginTop:"6px"},children:e.modelError}):null]})]})}function zv(e){return e==="light"?"Light":"Dark"}function Rv(e){const t=e.themes&&e.themes.length?e.themes:f_,r=e.showSwatches!==!1,o=e.variant||"panel",l=m.useMemo(()=>{const c={};for(const d of t)c[d.id]=d;return c},[t]),u=m.useMemo(()=>t.map(c=>({value:c.id,label:c.label,group:zv(c.group)})),[t]);return s.jsx(Hc,{value:e.value,options:u,placeholder:e.placeholder||"Select theme…",disabled:e.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:o,className:e.className,triggerClassName:e.triggerClassName,onChange:c=>e.onChange(String(c||"").trim()),renderValue:(c,d)=>{const h=String(d||"").trim(),_=l[h],g=(_==null?void 0:_.label)||h||e.placeholder||"Select theme…",x=(_==null?void 0:_.swatches)||null,v=!h;return s.jsxs("span",{className:"af-theme-value",children:[s.jsx("span",{className:`af-theme-label ${v?"af-theme-label--placeholder":""}`.trim(),children:g}),r&&x?s.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:x.map((b,j)=>s.jsx("span",{className:"af-theme-swatch",style:{background:b}},`${h}:${j}`))}):null]})},renderOption:(c,d)=>{const h=String(c.value||"").trim(),_=l[h],g=(_==null?void 0:_.swatches)||null;return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"af-theme-option-label",children:c.label}),s.jsxs("span",{className:"af-theme-option-right",children:[r&&g?s.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:g.map((x,v)=>s.jsx("span",{className:"af-theme-swatch",style:{background:x}},`${h}:${v}`))}):null,d.selected?s.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function Lv(e){const t=e.scales&&e.scales.length?e.scales:Am,r=e.variant||"panel",o=m.useMemo(()=>t.map(l=>({value:l.id,label:l.label})),[t]);return s.jsx(Hc,{value:e.value,options:o,placeholder:e.placeholder||"Font size…",disabled:e.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:e.className,triggerClassName:e.triggerClassName,onChange:l=>e.onChange(String(l||"").trim())})}function Pv(e){const t=e.densities&&e.densities.length?e.densities:Tm,r=e.variant||"panel",o=m.useMemo(()=>t.map(l=>({value:l.id,label:l.label})),[t]);return s.jsx(Hc,{value:e.value,options:o,placeholder:e.placeholder||"Header size…",disabled:e.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:e.className,triggerClassName:e.triggerClassName,onChange:l=>e.onChange(String(l||"").trim())})}function Iv(e){switch(e){case"chat":return s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"});case"plus":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 5v14"}),s.jsx("path",{d:"M5 12h14"})]});case"history":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 7v5l3 3"})]});case"refresh":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M21 12a9 9 0 0 0-15.5-6.4L3 8"}),s.jsx("path",{d:"M3 3v5h5"}),s.jsx("path",{d:"M3 12a9 9 0 0 0 15.5 6.4L21 16"}),s.jsx("path",{d:"M21 21v-5h-5"})]});case"settings":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 6h16"}),s.jsx("circle",{cx:"8",cy:"6",r:"2"}),s.jsx("path",{d:"M4 12h16"}),s.jsx("circle",{cx:"16",cy:"12",r:"2"}),s.jsx("path",{d:"M4 18h16"}),s.jsx("circle",{cx:"10",cy:"18",r:"2"})]});case"user":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"8",r:"4"}),s.jsx("path",{d:"M4 21a8 8 0 0 1 16 0"})]});case"bot":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 2v3"}),s.jsx("rect",{x:"5",y:"6",width:"14",height:"14",rx:"3"}),s.jsx("circle",{cx:"9",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"15",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M9 17h6"})]});case"paperclip":return s.jsx("path",{d:"M21.44 11.05l-9.19 9.19a5.5 5.5 0 0 1-7.78-7.78l9.19-9.19a3.5 3.5 0 0 1 4.95 4.95l-9.2 9.19a1.5 1.5 0 0 1-2.12-2.12l8.49-8.48"});case"mic":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3z"}),s.jsx("path",{d:"M19 11a7 7 0 0 1-14 0"}),s.jsx("path",{d:"M12 18v4"}),s.jsx("path",{d:"M8 22h8"})]});case"speaker":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),s.jsx("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"}),s.jsx("path",{d:"M18 6a9 9 0 0 1 0 12"})]});case"pause":return s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"})]});case"terminal":return s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",ry:"2"}),s.jsx("path",{d:"M7 9l3 3-3 3"}),s.jsx("path",{d:"M12 15h5"})]});case"edit":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]});case"download":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("path",{d:"M7 10l5 5 5-5"}),s.jsx("path",{d:"M12 15V3"})]});case"loader":return s.jsx("path",{d:"M21 12a9 9 0 1 1-3.3-6.9"});case"info":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 16v-4"}),s.jsx("circle",{cx:"12",cy:"8",r:"0.75",fill:"currentColor",stroke:"none"})]});case"warning":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 3l10 18H2L12 3z"}),s.jsx("path",{d:"M12 9v4"}),s.jsx("circle",{cx:"12",cy:"17",r:"0.75",fill:"currentColor",stroke:"none"})]});case"error":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M15 9l-6 6"}),s.jsx("path",{d:"M9 9l6 6"})]});case"copy":return s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]});case"check":return s.jsx("path",{d:"M20 6L9 17l-5-5"});case"x":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]});case"chevronDown":return s.jsx("path",{d:"M6 9l6 6 6-6"});case"chevronRight":return s.jsx("path",{d:"M9 18l6-6-6-6"});case"trash":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),s.jsx("path",{d:"M6 6l1 16h10l1-16"}),s.jsx("path",{d:"M10 11v6"}),s.jsx("path",{d:"M14 11v6"})]});case"send":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M22 2L11 13"}),s.jsx("path",{d:"M22 2L15 22l-4-9-9-4 20-7z"})]});default:return null}}function On({name:e,size:t=16,className:r,title:o,...l}){const u=o?void 0:!0;return s.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:r,"aria-hidden":u,role:o?"img":"presentation",...l,children:[o?s.jsx("title",{children:o}):null,Iv(e)]})}function Fv(e){const t=String(e.role||"").trim().toLowerCase()||"system",r=String(e.kind||"").trim().toLowerCase(),o=String(e.level||"").trim().toLowerCase();return t==="system"&&r==="report_bug"?{label:String(e.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:t==="system"&&r==="report_feature"?{label:String(e.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:t==="user"?{label:"You",icon:"user",variant:"user"}:t==="assistant"?{label:"Agent",icon:"bot",variant:"assistant"}:{label:String(e.title||"").trim()||(o==="error"?"Error":o==="warn"?"Warning":"System"),icon:o==="error"?"error":o==="warn"?"warning":"info",variant:o==="error"?"error":o==="warn"?"warn":"status"}}function Ov(e){var j;const t=e.message,r=m.useMemo(()=>Fv(t),[t.kind,t.level,t.role,t.title]),o=String(t.ts||"").trim(),l=o?new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",[u,c]=m.useState("idle"),d=typeof e.onSpeakToggle=="function"&&r.variant==="assistant"&&!!String(t.content||"").trim(),h=d&&((j=e.getSpeakState)==null?void 0:j.call(e,t))||"idle",_=h==="loading"?"loader":h==="playing"?"pause":"speaker",g=h==="loading"?"Generating audio…":h==="playing"?"Pause":h==="paused"?"Resume":"Speak (TTS)",x=e.showCopy!==!1,v=Array.isArray(e.attachments)?e.attachments:[],b=Array.isArray(e.stats)?e.stats:[];return s.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${r.variant}`,e.className].filter(Boolean).join(" "),children:[s.jsxs("div",{className:"pc-chat-header",children:[s.jsx("div",{className:"pc-chat-avatar","aria-hidden":"true",children:s.jsx(On,{name:r.icon,size:14})}),s.jsx("span",{className:"pc-chat-role",children:r.label}),s.jsx("span",{className:"pc-chat-header-spacer"}),l?s.jsx("span",{className:"pc-chat-time",children:l}):null,s.jsxs("div",{className:"pc-chat-header-actions",children:[d?s.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":g,title:g,onClick:()=>{var S;return(S=e.onSpeakToggle)==null?void 0:S.call(e,t)},children:s.jsx(On,{name:_,size:22})}):null,x?s.jsx("button",{className:`pc-chat-icon-btn ${u!=="idle"?`pc-chat-icon-btn--${u}`:""}`.trim(),type:"button","aria-label":"Copy message",title:u==="idle"?"Copy":u==="copied"?"Copied":"Copy failed",onClick:async()=>{const S=await Ns(String(t.content||""));c(S?"copied":"failed"),window.setTimeout(()=>c("idle"),900)},children:s.jsx(On,{name:"copy",size:22})}):null]})]}),s.jsx("div",{className:"pc-chat-body",children:s.jsx(Sv,{text:String(t.content||""),renderMarkdown:e.renderMarkdown,jsonCollapseAfterDepth:e.jsonCollapseAfterDepth})}),v.length?s.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:v.slice(0,24).map((S,T)=>{const M=String(S.label||"").trim()||"attachment",D=String(S.target||"").trim(),L=String(S.title||"").trim(),I=!!S.disabled||typeof S.onClick!="function";return s.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:L||M,onClick:I?void 0:S.onClick,disabled:I,children:[s.jsx(On,{name:"paperclip",size:14}),D?s.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${D}`,children:D}):null,s.jsx("span",{className:"pc-chat-attachment-name",children:M})]},S.id||`${M}:${T}`)})}):null,b.length?s.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:b.slice(0,12).map((S,T)=>{const M=String(S.label||"").trim();if(!M)return null;const D=String(S.title||"").trim(),L=typeof S.onClick=="function";return s.jsxs("button",{type:"button",className:["pc-chat-stat",L?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:D||void 0,onClick:L?()=>{var I;return(I=S.onClick)==null?void 0:I.call(S)}:void 0,disabled:!L,children:[S.icon?s.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:S.icon}):null,s.jsx("span",{className:"pc-chat-stat-label",children:M})]},S.id||`${M}:${T}`)})}):null]})}function Dv(e,t){const r=Math.max(0,Math.trunc(t));return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function Ud(e){const t=typeof e.autoScrollThresholdPx=="number"&&Number.isFinite(e.autoScrollThresholdPx)?e.autoScrollThresholdPx:120,r=e.autoScroll!==!1,o=m.useRef(null),l=m.useRef(null),[u,c]=m.useState(!0),d=m.useMemo(()=>Array.isArray(e.messages)?e.messages:[],[e.messages]);return m.useEffect(()=>{if(!r)return;const h=o.current;if(!h)return;const _=()=>{c(Dv(h,t))};return h.addEventListener("scroll",_,{passive:!0}),_(),()=>h.removeEventListener("scroll",_)},[r,t]),m.useEffect(()=>{var h;r&&u&&((h=l.current)==null||h.scrollIntoView({block:"end"}))},[r,u,d.length]),s.jsxs("div",{ref:o,className:["pc-chat-thread",e.className].filter(Boolean).join(" "),children:[d.length?null:e.empty||null,d.map((h,_)=>s.jsx(Ov,{message:h,...e.messageProps||{}},String(h.id||"")||String(h.ts||"")+":"+String(h.role||"")+":"+_)),s.jsx("div",{ref:l})]})}class Yd{constructor(t){this._maxSize=Yd._normalizeMaxSize(t),this._values=[]}get maxSize(){return this._maxSize}get size(){return this._values.length}static _normalizeMaxSize(t){const r=Number(t);return!Number.isFinite(r)||r<=0?1:Math.min(1e3,Math.floor(r))}setMaxSize(t){const r=Yd._normalizeMaxSize(t);this._maxSize=r,this._values.length>r&&(this._values=this._values.slice(this._values.length-r))}clear(){this._values=[]}push(t){const r=Number(t),o=Number.isFinite(r)?r:null;this._values.push(o),this._values.length>this._maxSize&&this._values.splice(0,this._values.length-this._maxSize)}values(){return this._values.slice()}last(){return this._values.length?this._values[this._values.length-1]:null}}function Bv(e){try{return new URL(String(e)),!0}catch{return!1}}function Uv({baseUrl:e,endpoint:t}){const r=String(t||"/api/gateway/host/metrics/gpu");return Bv(r)?r:e&&String(e).trim()?new URL(r,String(e)).toString():r}async function Wv({token:e,getToken:t}){if(typeof t=="function"){const r=await t();return r==null?"":String(r)}return e==null?"":String(e)}function Hv({token:e}){const t=String(e||"").trim();return t?{Authorization:`Bearer ${t}`}:{}}function Vv(e){if(!e||typeof e!="object")return null;const t=Number(e.utilization_gpu_pct);if(Number.isFinite(t))return t;const r=e.gpus;if(Array.isArray(r)&&r.length){const o=r.map(u=>Number(u&&u.utilization_gpu_pct)).filter(u=>Number.isFinite(u));return o.length?o.reduce((u,c)=>u+c,0)/o.length:null}return null}async function qv({baseUrl:e,endpoint:t,token:r,getToken:o,signal:l,fetchImpl:u}={}){const c=Uv({baseUrl:e,endpoint:t}),d=await Wv({token:r,getToken:o}),h=u||globalThis.fetch;if(typeof h!="function")return{ok:!1,status:0,error:"fetch_unavailable",payload:null};let _;try{_=await h(c,{method:"GET",headers:{Accept:"application/json",...Hv({token:d})},signal:l})}catch(x){return{ok:!1,status:0,error:"network_error",detail:x instanceof Error?x.message:String(x),payload:null}}let g=null;try{g=await _.json()}catch{g=null}return{ok:_.ok,status:_.status,error:_.ok?null:"http_error",payload:g}}const bu=Object.freeze({tickMs:1500,historySize:20,endpoint:"/api/gateway/host/metrics/gpu",baseUrl:"",mode:"full"});function Gv(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Ep(e,t,r){return Number.isFinite(e)?Math.min(r,Math.max(t,e)):t}function $p(e,t){const r=Number(e);return Number.isFinite(r)?Math.floor(r):t}function Zf(e,t=1){const r=Ep(Number(e)/100,0,1),o=Math.round(140-140*r),l=Ep(Number(t),0,1);return l>=1?`hsl(${o} 85% 55%)`:`hsl(${o} 85% 55% / ${l})`}function Ap(e){const t={...bu,...e||{}};return t.tickMs=Math.max(250,$p(t.tickMs,bu.tickMs)),t.historySize=Math.max(1,Math.min(200,$p(t.historySize,bu.historySize))),t.endpoint=String(t.endpoint||bu.endpoint),t.baseUrl=String(t.baseUrl||""),t.mode=String(t.mode||bu.mode).trim().toLowerCase(),t.mode!=="icon"&&(t.mode="full"),t}function Yv(){return`
|
|
54
|
+
:host{display:inline-block;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,"Apple Color Emoji","Segoe UI Emoji";line-height:1}
|
|
55
|
+
.wrap{box-sizing:border-box;display:flex;flex-direction:column;gap:6px;padding:var(--monitor-gpu-padding,8px 10px);border:1px solid var(--monitor-gpu-border,#2a2f3a);border-radius:var(--monitor-gpu-radius,10px);background:var(--monitor-gpu-bg,#0b1020);color:var(--monitor-gpu-fg,#e7eaf0);width:var(--monitor-gpu-width,180px)}
|
|
56
|
+
.wrap.icon{gap:var(--monitor-gpu-gap,4px);padding:var(--monitor-gpu-padding,4px);border-radius:var(--monitor-gpu-radius,999px);width:var(--monitor-gpu-width,30px);background:linear-gradient(180deg,rgba(255,255,255,0.08),rgba(255,255,255,0.02)),var(--monitor-gpu-bg,#0b1020);box-shadow:0 0 14px var(--monitor-gpu-accent-glow, rgba(76,195,255,0.18))}
|
|
57
|
+
.wrap.icon .top{display:none}
|
|
58
|
+
.wrap.icon .bars{height:var(--monitor-gpu-bars-height,18px)}
|
|
59
|
+
.top{display:flex;align-items:baseline;justify-content:space-between;gap:10px}
|
|
60
|
+
.label{font-size:var(--monitor-gpu-font-size,var(--font-size-sm,12px));opacity:.9}
|
|
61
|
+
.value{font-variant-numeric:tabular-nums;font-size:var(--monitor-gpu-font-size,var(--font-size-sm,12px));opacity:.95}
|
|
62
|
+
.bars{display:flex;align-items:flex-end;gap:2px;height:var(--monitor-gpu-bars-height,34px);overflow:hidden}
|
|
63
|
+
.bar{flex:1;min-width:0;border-radius:2px;background:var(--monitor-gpu-bar,#4cc3ff);height:2px;opacity:.9;transition:height .25s ease, background .25s ease, opacity .25s ease}
|
|
64
|
+
.bar.missing{background:var(--monitor-gpu-bar-missing,#62708a);opacity:.35}
|
|
65
|
+
.bar.error{background:var(--monitor-gpu-bar-error,#ff6b6b);opacity:.7}
|
|
66
|
+
.muted{opacity:.6}
|
|
67
|
+
`}class Xv{constructor(t,r={}){if(!t||typeof t!="object")throw new TypeError("target element is required");this._target=t,this._opts=Ap(r),this._buffer=new Yd(this._opts.historySize),this._timer=null,this._timer_gen=0,this._running=!1,this._abort=null,this._resumeTimer=null,this._mounted=!1,this._els=null,this._token=r.token,this._getToken=r.getToken,this._stoppedForAuth=!1}get options(){return{...this._opts}}set token(t){this._token=t,String(this._token||"").trim()&&this._stoppedForAuth&&(this._stoppedForAuth=!1,this.start())}get token(){return this._token}set getToken(t){this._getToken=t}get getToken(){return this._getToken}mount(){if(this._mounted)return;if(typeof document>"u")throw new Error("MonitorGpuWidget requires a browser DOM");const t=this._target;t.textContent="";const r=document.createElement("style");r.textContent=Yv();const o=document.createElement("div");o.className=this._opts.mode==="icon"?"wrap icon":"wrap";const l=document.createElement("div");l.className="top";const u=document.createElement("div");u.className="label",u.textContent="GPU";const c=document.createElement("div");c.className="value muted",c.textContent="—",l.appendChild(u),l.appendChild(c);const d=document.createElement("div");d.className="bars",o.appendChild(l),o.appendChild(d),t.appendChild(r),t.appendChild(o),this._els={wrap:o,value:c,bars:d},this._mounted=!0,this._rebuildBars(),this._render()}start(){this.mount(),!this._running&&(this._running=!0,this._timer_gen+=1,this._poll_loop(this._timer_gen))}stop(){this._running=!1,this._timer_gen+=1,this._timer&&(clearTimeout(this._timer),this._timer=null),this._resumeTimer&&(clearTimeout(this._resumeTimer),this._resumeTimer=null),this._abort&&(this._abort.abort(),this._abort=null)}destroy(){this.stop(),this._target&&this._mounted&&(this._target.textContent=""),this._mounted=!1,this._els=null}setOptions(t){const r=Ap({...this._opts,...t||{}}),o=r.historySize!==this._opts.historySize,l=r.tickMs!==this._opts.tickMs,u=r.mode!==this._opts.mode;this._opts=r,u&&this._mounted&&this._els&&this._els.wrap&&(this._els.wrap.className=r.mode==="icon"?"wrap icon":"wrap"),o&&(this._buffer.setMaxSize(r.historySize),this._mounted&&this._rebuildBars()),l&&this._running?(this.stop(),this.start()):this._mounted&&this._render()}push(t){this._buffer.push(t),this._render()}_rebuildBars(){if(!this._els)return;const{bars:t}=this._els;t.textContent="";for(let r=0;r<this._opts.historySize;r+=1){const o=document.createElement("div");o.className="bar missing",o.style.height="2px",t.appendChild(o)}}_render({error:t=!1}={}){if(!this._els)return;const{wrap:r,value:o,bars:l}=this._els,u=this._buffer.values(),c=this._buffer.last(),d=Number.isFinite(c)?Math.max(0,Math.min(100,c)):null;d==null?(o.textContent=t?"N/A":"—",o.classList.add("muted")):(o.textContent=`${d.toFixed(0)}%`,o.classList.remove("muted")),r&&(r.title=d==null?"GPU —":`GPU ${d.toFixed(0)}%`,d==null?(r.style.removeProperty("--monitor-gpu-accent"),r.style.removeProperty("--monitor-gpu-accent-glow")):(r.style.setProperty("--monitor-gpu-accent",Zf(d,.95)),r.style.setProperty("--monitor-gpu-accent-glow",Zf(d,.35))));const h=Array.from(l.children),_=Math.max(0,h.length-u.length),g=Math.max(2,l&&typeof l.clientHeight=="number"&&l.clientHeight>0?l.clientHeight:34);for(let x=0;x<h.length;x+=1){const v=h[x],b=x-_,j=b>=0?u[b]:null,S=Number.isFinite(j)?j:null,T=S==null?0:Gv(S/100),M=Math.max(2,Math.min(g,Math.round(T*g)));v.style.height=`${M}px`,v.style.background=S==null?"":Zf(S),v.className="bar",S==null&&v.classList.add("missing"),t&&v.classList.add("error")}}async _tick(){const t=String(this._token||"").trim(),r=this._getToken,o=!!t||typeof r=="function";this._abort&&this._abort.abort(),this._abort=new AbortController;const l=await qv({baseUrl:this._opts.baseUrl,endpoint:this._opts.endpoint,token:t,getToken:r,signal:this._abort.signal}),u=l&&l.payload,c=u&&typeof u=="object"?u.supported!==!1:!0,d=Vv(u);if(!l.ok){if(this._buffer.push(null),this._render({error:!0}),l.status===401||l.status===403){const h=String(this._token||"").trim(),_=typeof this._getToken=="function";if(!o&&(!!h||_))return;this._stoppedForAuth=!0,this.stop()}else l.status===429&&(this.stop(),this._resumeTimer=setTimeout(()=>{this._resumeTimer=null,this._mounted&&this.start()},3e4));return}if(!c||d==null){this._buffer.push(null),this._render();return}this._buffer.push(d),this._render()}async _poll_loop(t){!this._running||t!==this._timer_gen||(await this._tick(),!(!this._running||t!==this._timer_gen)&&(this._timer=setTimeout(()=>{this._timer=null,this._poll_loop(t)},this._opts.tickMs)))}}function Kv(e="monitor-gpu"){if(typeof globalThis>"u"||typeof globalThis.customElements>"u"||globalThis.customElements.get(e))return;const t=globalThis.HTMLElement||class{};class r extends t{static get observedAttributes(){return["tick-ms","history-size","endpoint","base-url","mode"]}constructor(){super(),this._shadow=this.attachShadow?this.attachShadow({mode:"open"}):null;const l=this._shadow||this;this._controller=new Xv(l,{}),this._upgradeProperty("token"),this._upgradeProperty("getToken"),this._upgradeProperty("mode")}_upgradeProperty(l){if(!Object.prototype.hasOwnProperty.call(this,l))return;const u=this[l];try{delete this[l]}catch{}this[l]=u}connectedCallback(){this._controller.setOptions(this._readAttrs());const l=()=>{this.isConnected&&this._controller.start()};typeof queueMicrotask=="function"?queueMicrotask(l):Promise.resolve().then(l)}disconnectedCallback(){this._controller.destroy()}attributeChangedCallback(){this._controller.setOptions(this._readAttrs())}_readAttrs(){const l=this.getAttribute("tick-ms"),u=this.getAttribute("history-size"),c=this.getAttribute("endpoint"),d=this.getAttribute("base-url"),h=this.getAttribute("mode");return{...l!=null?{tickMs:l}:{},...u!=null?{historySize:u}:{},...c!=null?{endpoint:c}:{},...d!=null?{baseUrl:d}:{},...h!=null?{mode:h}:{}}}set token(l){this._controller.token=l}get token(){return this._controller.token}set getToken(l){this._controller.getToken=l}get getToken(){return this._controller.getToken}set tickMs(l){this._controller.setOptions({tickMs:l})}get tickMs(){return this._controller.options.tickMs}set historySize(l){this._controller.setOptions({historySize:l})}get historySize(){return this._controller.options.historySize}set endpoint(l){this._controller.setOptions({endpoint:l})}get endpoint(){return this._controller.options.endpoint}set baseUrl(l){this._controller.setOptions({baseUrl:l})}get baseUrl(){return this._controller.options.baseUrl}set mode(l){this._controller.setOptions({mode:l})}get mode(){return this._controller.options.mode}}globalThis.customElements.define(e,r)}class Jv{constructor(){vu(this,"_buffer","");vu(this,"_current",{data_lines:[]})}push(t,r){for(this._buffer+=t;;){const o=this._buffer.indexOf(`
|
|
68
|
+
`);if(o===-1)return;const l=this._buffer.slice(0,o);this._buffer=this._buffer.slice(o+1);const u=l.endsWith("\r")?l.slice(0,-1):l;if(u.startsWith(":"))continue;if(u===""){if(this._current.data_lines.length>0||this._current.event||this._current.id){const _={id:this._current.id,event:this._current.event,data:this._current.data_lines.join(`
|
|
69
|
+
`)};r(_)}this._current={data_lines:[]};continue}const c=u.indexOf(":"),d=c===-1?u:u.slice(0,c),h=c===-1?"":u.slice(c+1).trimStart();if(d==="id"){this._current.id=h;continue}if(d==="event"){this._current.event=h;continue}if(d==="data"){this._current.data_lines.push(h);continue}}}}function dt(e,t){const r=(e||"").trim().replace(/\/+$/,"");return r?`${r}${t}`:t}function ft(e){const t=(e||"").trim();return t?{Authorization:`Bearer ${t}`}:{}}async function Pt(e){try{const t=await e.text();return t!=null&&t.trim()?t.trim():`${e.status}`}catch{return`${e.status}`}}class Qv{constructor(t){vu(this,"_cfg");this._cfg={...t,base_url:(t.base_url||"").trim()}}async start_run(t,r,o){const l=String((o==null?void 0:o.bundle_id)||"").trim(),u=(o==null?void 0:o.session_id)===null||(o==null?void 0:o.session_id)===void 0?"":String(o.session_id||"").trim(),c=String(t||"").trim(),d={input_data:r||{}};l&&(d.bundle_id=l),c&&(d.flow_id=c),u&&(d.session_id=u);const h=await fetch(dt(this._cfg.base_url,"/api/gateway/runs/start"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(d)});if(!h.ok)throw new Error(`start_run failed: ${h.status}`);const _=await h.json(),g=_==null?void 0:_.run_id;if(typeof g!="string"||!g)throw new Error("start_run: missing run_id");return g}async schedule_run(t){const r=String((t==null?void 0:t.bundle_id)||"").trim(),o=String((t==null?void 0:t.flow_id)||"").trim();if(!r)throw new Error("schedule_run: bundle_id is required");if(!o)throw new Error("schedule_run: flow_id is required");const l={bundle_id:r,flow_id:o,input_data:(t==null?void 0:t.input_data)||{}},u=(t==null?void 0:t.start_at)===null||(t==null?void 0:t.start_at)===void 0?"":String(t.start_at||"").trim();u&&(l.start_at=u);const c=(t==null?void 0:t.interval)===null||(t==null?void 0:t.interval)===void 0?"":String(t.interval||"").trim();c&&(l.interval=c),typeof(t==null?void 0:t.repeat_count)=="number"&&Number.isFinite(t.repeat_count)&&(l.repeat_count=Number(t.repeat_count));const d=(t==null?void 0:t.repeat_until)===null||(t==null?void 0:t.repeat_until)===void 0?"":String(t.repeat_until||"").trim();d&&(l.repeat_until=d),typeof(t==null?void 0:t.share_context)=="boolean"&&(l.share_context=!!t.share_context);const h=(t==null?void 0:t.session_id)===null||(t==null?void 0:t.session_id)===void 0?"":String(t.session_id||"").trim();h&&(l.session_id=h);const _=await fetch(dt(this._cfg.base_url,"/api/gateway/runs/schedule"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(l)});if(!_.ok)throw new Error(`schedule_run failed: ${_.status}`);const g=await _.json(),x=g==null?void 0:g.run_id;if(typeof x!="string"||!x)throw new Error("schedule_run: missing run_id");return x}async get_run(t){const r=await fetch(dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(t)}`),{headers:{...ft(this._cfg.auth_token)}});if(!r.ok)throw new Error(`get_run failed: ${await Pt(r)}`);return await r.json()}async get_run_history_bundle(t,r){const o=String(t||"").trim();if(!o)throw new Error("get_run_history_bundle: run_id is required");const l=new URLSearchParams;(r==null?void 0:r.include_subruns)===!1&&l.set("include_subruns","false"),(r==null?void 0:r.include_session)===!0&&l.set("include_session","true"),typeof(r==null?void 0:r.session_turn_limit)=="number"&&Number.isFinite(r.session_turn_limit)&&l.set("session_turn_limit",String(Math.max(1,Math.trunc(r.session_turn_limit)))),r!=null&&r.ledger_mode&&l.set("ledger_mode",String(r.ledger_mode)),typeof(r==null?void 0:r.ledger_max_items)=="number"&&Number.isFinite(r.ledger_max_items)&&l.set("ledger_max_items",String(Math.max(0,Math.trunc(r.ledger_max_items))));const u=dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/history_bundle?${l.toString()}`),c=await fetch(u,{headers:{...ft(this._cfg.auth_token)}});if(!c.ok)throw new Error(`get_run_history_bundle failed: ${await Pt(c)}`);return await c.json()}async list_runs(t){const r=typeof(t==null?void 0:t.limit)=="number"?t.limit:50,o=String((t==null?void 0:t.status)||"").trim(),l=String((t==null?void 0:t.workflow_id)||"").trim(),u=String((t==null?void 0:t.session_id)||"").trim(),c=(t==null?void 0:t.root_only)===!0,d=new URLSearchParams;d.set("limit",String(r)),o&&d.set("status",o),l&&d.set("workflow_id",l),u&&d.set("session_id",u),c&&d.set("root_only","true");const h=dt(this._cfg.base_url,`/api/gateway/runs?${d.toString()}`),_=await fetch(h,{headers:{...ft(this._cfg.auth_token)}});if(!_.ok)throw new Error(`list_runs failed: ${await Pt(_)}`);return await _.json()}async list_processes(){const t=await fetch(dt(this._cfg.base_url,"/api/gateway/processes"),{headers:{...ft(this._cfg.auth_token)}});if(!t.ok)throw new Error(`list_processes failed: ${await Pt(t)}`);return await t.json()}async list_process_env_vars(){const t=await fetch(dt(this._cfg.base_url,"/api/gateway/processes/env"),{headers:{...ft(this._cfg.auth_token)}});if(!t.ok)throw new Error(`list_process_env_vars failed: ${await Pt(t)}`);return await t.json()}async update_process_env_vars(t){const r={},o=t!=null&&t.set&&typeof t.set=="object"?t.set:{},l=Array.isArray(t==null?void 0:t.unset)?t==null?void 0:t.unset:[];o&&Object.keys(o).length&&(r.set=o),l&&l.length&&(r.unset=l);const u=await fetch(dt(this._cfg.base_url,"/api/gateway/processes/env"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(r)});if(!u.ok)throw new Error(`update_process_env_vars failed: ${await Pt(u)}`);return await u.json()}async start_process(t){const r=String(t||"").trim(),o=await fetch(dt(this._cfg.base_url,`/api/gateway/processes/${encodeURIComponent(r)}/start`),{method:"POST",headers:{...ft(this._cfg.auth_token)}});if(!o.ok)throw new Error(`start_process failed: ${await Pt(o)}`);return await o.json()}async stop_process(t){const r=String(t||"").trim(),o=await fetch(dt(this._cfg.base_url,`/api/gateway/processes/${encodeURIComponent(r)}/stop`),{method:"POST",headers:{...ft(this._cfg.auth_token)}});if(!o.ok)throw new Error(`stop_process failed: ${await Pt(o)}`);return await o.json()}async restart_process(t){const r=String(t||"").trim(),o=await fetch(dt(this._cfg.base_url,`/api/gateway/processes/${encodeURIComponent(r)}/restart`),{method:"POST",headers:{...ft(this._cfg.auth_token)}});if(!o.ok)throw new Error(`restart_process failed: ${await Pt(o)}`);return await o.json()}async redeploy_process(t){const r=String(t||"").trim(),o=await fetch(dt(this._cfg.base_url,`/api/gateway/processes/${encodeURIComponent(r)}/redeploy`),{method:"POST",headers:{...ft(this._cfg.auth_token)}});if(!o.ok)throw new Error(`redeploy_process failed: ${await Pt(o)}`);return await o.json()}async process_log_tail(t,r){const o=String(t||"").trim(),l=typeof(r==null?void 0:r.max_bytes)=="number"?Math.max(1024,Math.min(4e5,Math.floor(r.max_bytes))):8e4,u=dt(this._cfg.base_url,`/api/gateway/processes/${encodeURIComponent(o)}/logs/tail?max_bytes=${encodeURIComponent(String(l))}`),c=await fetch(u,{headers:{...ft(this._cfg.auth_token)}});if(!c.ok)throw new Error(`process_log_tail failed: ${await Pt(c)}`);return await c.json()}async get_run_input_data(t){const r=String(t||"").trim();if(!r)throw new Error("get_run_input_data: run_id is required");const o=await fetch(dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(r)}/input_data`),{headers:{...ft(this._cfg.auth_token)}});if(!o.ok)throw new Error(`get_run_input_data failed: ${await Pt(o)}`);return await o.json()}async list_run_artifacts(t,r){const o=String(t||"").trim();if(!o)throw new Error("list_run_artifacts: run_id is required");const l=typeof(r==null?void 0:r.limit)=="number"?r.limit:200,u=dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/artifacts?limit=${encodeURIComponent(String(l))}`),c=await fetch(u,{headers:{...ft(this._cfg.auth_token)}});if(!c.ok)throw new Error(`list_run_artifacts failed: ${await Pt(c)}`);return await c.json()}async download_run_artifact_content(t,r){const o=String(t||"").trim(),l=String(r||"").trim();if(!o)throw new Error("download_run_artifact_content: run_id is required");if(!l)throw new Error("download_run_artifact_content: artifact_id is required");const u=dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/artifacts/${encodeURIComponent(l)}/content`),c=await fetch(u,{headers:{...ft(this._cfg.auth_token)}});if(!c.ok)throw new Error(`download_run_artifact_content failed: ${await Pt(c)}`);return await c.blob()}async get_ledger(t,r){const o=Number((r==null?void 0:r.after)||0),l=Number((r==null?void 0:r.limit)||0),u=dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(t)}/ledger?after=${encodeURIComponent(String(o))}&limit=${encodeURIComponent(String(l))}`),c=await fetch(u,{headers:{...ft(this._cfg.auth_token)}});if(!c.ok)throw new Error(`get_ledger failed: ${c.status}`);const d=await c.json(),h=Array.isArray(d==null?void 0:d.items)?d.items:[],_=typeof(d==null?void 0:d.next_after)=="number"?d.next_after:o;return{items:h,next_after:_}}async get_ledger_batch(t){const r=Array.isArray(t==null?void 0:t.runs)?t.runs:[],o=Number((t==null?void 0:t.limit)||0),l=await fetch(dt(this._cfg.base_url,"/api/gateway/runs/ledger/batch"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify({runs:r,limit:o})});if(!l.ok)throw new Error(`get_ledger_batch failed: ${l.status}`);const u=await l.json(),d=(u&&typeof u=="object"?u:{}).runs;return{runs:d&&typeof d=="object"?d:{}}}async generate_run_summary(t,r){const o=String(t||"").trim();if(!o)throw new Error("generate_run_summary: run_id is required");const l={include_subruns:(r==null?void 0:r.include_subruns)!==!1},u=typeof(r==null?void 0:r.provider)=="string"?String(r.provider).trim():"";u&&(l.provider=u);const c=typeof(r==null?void 0:r.model)=="string"?String(r.model).trim():"";c&&(l.model=c);const d=await fetch(dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/summary`),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(l)});if(!d.ok)throw new Error(`generate_run_summary failed: ${d.status}`);return await d.json()}async run_chat(t,r){const o=String(t||"").trim();if(!o)throw new Error("run_chat: run_id is required");const l={include_subruns:(r==null?void 0:r.include_subruns)!==!1,messages:Array.isArray(r==null?void 0:r.messages)?r.messages:[],persist:!!(r!=null&&r.persist)},u=typeof(r==null?void 0:r.provider)=="string"?String(r.provider).trim():"";u&&(l.provider=u);const c=typeof(r==null?void 0:r.model)=="string"?String(r.model).trim():"";c&&(l.model=c);const d=await fetch(dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/chat`),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(l)});if(!d.ok)throw new Error(`run_chat failed: ${d.status}`);return await d.json()}async audio_transcribe(t,r){const o=String(t||"").trim();if(!o)throw new Error("audio_transcribe: run_id is required");const l=r==null?void 0:r.audio_artifact;if(!l||typeof l!="object")throw new Error("audio_transcribe: audio_artifact is required");if(!String(l.$artifact||"").trim())throw new Error("audio_transcribe: audio_artifact.$artifact is required");const c={audio_artifact:l},d=String((r==null?void 0:r.language)||"").trim();d&&(c.language=d);const h=String((r==null?void 0:r.request_id)||"").trim();h&&(c.request_id=h);const _=await fetch(dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/audio/transcribe`),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(c)});if(!_.ok)throw new Error(`audio_transcribe failed: ${await Pt(_)}`);const g=await _.json(),x=String((g==null?void 0:g.text)||"");return{ok:!!(g!=null&&g.ok),run_id:String((g==null?void 0:g.run_id)||""),request_id:String((g==null?void 0:g.request_id)||""),text:x,transcript_artifact:g==null?void 0:g.transcript_artifact}}async voice_tts(t,r){const o=String(t||"").trim();if(!o)throw new Error("voice_tts: run_id is required");const l=String((r==null?void 0:r.text)||"").trim();if(!l)throw new Error("voice_tts: text is required");const u={text:l},c=String((r==null?void 0:r.voice)||"").trim();c&&(u.voice=c);const d=String((r==null?void 0:r.format)||"").trim();d&&(u.format=d);const h=String((r==null?void 0:r.request_id)||"").trim();h&&(u.request_id=h);const _=await fetch(dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/voice/tts`),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(u)});if(!_.ok)throw new Error(`voice_tts failed: ${await Pt(_)}`);const g=await _.json();return{ok:!!(g!=null&&g.ok),run_id:String((g==null?void 0:g.run_id)||""),request_id:String((g==null?void 0:g.request_id)||""),audio_artifact:g==null?void 0:g.audio_artifact}}async save_chat_thread(t,r){const o=String(t||"").trim();if(!o)throw new Error("save_chat_thread: run_id is required");const l={include_subruns:(r==null?void 0:r.include_subruns)!==!1,messages:Array.isArray(r==null?void 0:r.messages)?r.messages:[]},u=typeof(r==null?void 0:r.provider)=="string"?String(r.provider).trim():"";u&&(l.provider=u);const c=typeof(r==null?void 0:r.model)=="string"?String(r.model).trim():"";c&&(l.model=c);const d=typeof(r==null?void 0:r.title)=="string"?String(r.title).trim():"";d&&(l.title=d);const h=await fetch(dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/chat_threads`),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(l)});if(!h.ok)throw new Error(`save_chat_thread failed: ${await Pt(h)}`);return await h.json()}async list_bundles(){const t=await fetch(dt(this._cfg.base_url,"/api/gateway/bundles"),{headers:{...ft(this._cfg.auth_token)}});if(!t.ok)throw new Error(`list_bundles failed: ${t.status}`);return await t.json()}async reload_bundles(){const t=await fetch(dt(this._cfg.base_url,"/api/gateway/bundles/reload"),{method:"POST",headers:{...ft(this._cfg.auth_token)}});if(!t.ok)throw new Error(`reload_bundles failed: ${t.status}`);return await t.json()}async upload_bundle(t,r){const o=(r==null?void 0:r.overwrite)===!0,l=(r==null?void 0:r.reload)!==!1,u=new FormData;u.set("overwrite",o?"true":"false"),u.set("reload",l?"true":"false"),u.set("file",t,t.name||"upload.flow");const c=await fetch(dt(this._cfg.base_url,"/api/gateway/bundles/upload"),{method:"POST",headers:{...ft(this._cfg.auth_token)},body:u});if(!c.ok)throw new Error(`upload_bundle failed: ${await Pt(c)}`);return await c.json()}async attachments_upload(t,r,o){const l=String(t||"").trim();if(!l)throw new Error("attachments_upload: session_id is required");if(!r)throw new Error("attachments_upload: file is required");const u=String((o==null?void 0:o.filename)||"").trim()||String((r==null?void 0:r.name)||"").trim()||"upload.bin",c=String((o==null?void 0:o.content_type)||"").trim()||String((r==null?void 0:r.type)||"").trim(),d=new FormData;d.append("session_id",l),d.append("file",r,u),d.append("filename",u),c&&d.append("content_type",c);const h=await fetch(dt(this._cfg.base_url,"/api/gateway/attachments/upload"),{method:"POST",headers:{...ft(this._cfg.auth_token)},body:d});if(!h.ok)throw new Error(`attachments_upload failed: ${await Pt(h)}`);const _=await h.json(),g=_==null?void 0:_.attachment;if(!g||typeof g!="object")throw new Error("attachments_upload: missing attachment");if(!String(g.$artifact||"").trim())throw new Error("attachments_upload: missing attachment.$artifact");return g}async remove_bundle(t,r){const o=String(t||"").trim();if(!o)throw new Error("remove_bundle: bundle_id is required");const l=new URLSearchParams,u=String((r==null?void 0:r.bundle_version)||"").trim();u&&l.set("bundle_version",u),l.set("reload",(r==null?void 0:r.reload)===!1?"false":"true");const c=dt(this._cfg.base_url,`/api/gateway/bundles/${encodeURIComponent(o)}?${l.toString()}`),d=await fetch(c,{method:"DELETE",headers:{...ft(this._cfg.auth_token)}});if(!d.ok)throw new Error(`remove_bundle failed: ${await Pt(d)}`);return await d.json()}async discovery_tools(){const t=await fetch(dt(this._cfg.base_url,"/api/gateway/discovery/tools"),{headers:{...ft(this._cfg.auth_token)}});if(!t.ok)throw new Error(`discovery_tools failed: ${t.status}`);return await t.json()}async discovery_providers(t){const r=(t==null?void 0:t.include_models)===!0,o=dt(this._cfg.base_url,`/api/gateway/discovery/providers?include_models=${encodeURIComponent(String(r))}`),l=await fetch(o,{headers:{...ft(this._cfg.auth_token)}});if(!l.ok)throw new Error(`discovery_providers failed: ${l.status}`);return await l.json()}async discovery_provider_models(t){const r=String(t||"").trim();if(!r)throw new Error("discovery_provider_models: provider_name is required");const o=await fetch(dt(this._cfg.base_url,`/api/gateway/discovery/providers/${encodeURIComponent(r)}/models`),{headers:{...ft(this._cfg.auth_token)}});if(!o.ok)throw new Error(`discovery_provider_models failed: ${o.status}`);return await o.json()}async get_bundle(t){const r=String(t||"").trim();if(!r)throw new Error("get_bundle: bundle_id is required");const o=await fetch(dt(this._cfg.base_url,`/api/gateway/bundles/${encodeURIComponent(r)}`),{headers:{...ft(this._cfg.auth_token)}});if(!o.ok)throw new Error(`get_bundle failed: ${o.status}`);return await o.json()}async get_bundle_flow(t,r){const o=String(t||"").trim(),l=String(r||"").trim();if(!o)throw new Error("get_bundle_flow: bundle_id is required");if(!l)throw new Error("get_bundle_flow: flow_id is required");const u=await fetch(dt(this._cfg.base_url,`/api/gateway/bundles/${encodeURIComponent(o)}/flows/${encodeURIComponent(l)}`),{headers:{...ft(this._cfg.auth_token)}});if(!u.ok)throw new Error(`get_bundle_flow failed: ${u.status}`);return await u.json()}async get_workflow_flow(t){const r=String(t||"").trim();if(!r)throw new Error("get_workflow_flow: workflow_id is required");const o=await fetch(dt(this._cfg.base_url,`/api/gateway/workflows/${encodeURIComponent(r)}/flow`),{headers:{...ft(this._cfg.auth_token)}});if(!o.ok)throw new Error(`get_workflow_flow failed: ${o.status}`);return await o.json()}async submit_command(t){const r=await fetch(dt(this._cfg.base_url,"/api/gateway/commands"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(t)});if(!r.ok)throw new Error(`submit_command failed: ${r.status}`);return await r.json()}async kg_query(t){const r=String((t==null?void 0:t.scope)||"session").trim().toLowerCase(),o=String((t==null?void 0:t.order)||"desc").trim().toLowerCase(),l=typeof(t==null?void 0:t.limit)=="number"&&Number.isFinite(t.limit)?Number(t.limit):500,u={scope:r,order:o,limit:l},c=String((t==null?void 0:t.run_id)||"").trim();c&&(u.run_id=c);const d=String((t==null?void 0:t.session_id)||"").trim();d&&(u.session_id=d);const h=String((t==null?void 0:t.owner_id)||"").trim();h&&(u.owner_id=h),t!=null&&t.all_owners&&(u.all_owners=!0);const _=String((t==null?void 0:t.subject)||"").trim();_&&(u.subject=_);const g=String((t==null?void 0:t.predicate)||"").trim();g&&(u.predicate=g);const x=String((t==null?void 0:t.object)||"").trim();x&&(u.object=x);const v=String((t==null?void 0:t.since)||"").trim();v&&(u.since=v);const b=String((t==null?void 0:t.until)||"").trim();b&&(u.until=b);const j=String((t==null?void 0:t.active_at)||"").trim();j&&(u.active_at=j);const S=String((t==null?void 0:t.query_text)||"").trim();S&&(u.query_text=S),typeof(t==null?void 0:t.min_score)=="number"&&Number.isFinite(t.min_score)&&(u.min_score=Number(t.min_score));const T=await fetch(dt(this._cfg.base_url,"/api/gateway/kg/query"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(u)});if(!T.ok)throw new Error(`kg_query failed: ${await Pt(T)}`);return await T.json()}async list_bug_reports(){const t=await fetch(dt(this._cfg.base_url,"/api/gateway/reports/bugs"),{headers:{...ft(this._cfg.auth_token)}});if(!t.ok)throw new Error(`list_bug_reports failed: ${await Pt(t)}`);return await t.json()}async list_feature_requests(){const t=await fetch(dt(this._cfg.base_url,"/api/gateway/reports/features"),{headers:{...ft(this._cfg.auth_token)}});if(!t.ok)throw new Error(`list_feature_requests failed: ${await Pt(t)}`);return await t.json()}async get_bug_report_content(t){const r=String(t||"").trim();if(!r)throw new Error("get_bug_report_content: filename is required");const o=await fetch(dt(this._cfg.base_url,`/api/gateway/reports/bugs/${encodeURIComponent(r)}/content`),{headers:{...ft(this._cfg.auth_token)}});if(!o.ok)throw new Error(`get_bug_report_content failed: ${await Pt(o)}`);return await o.json()}async get_feature_request_content(t){const r=String(t||"").trim();if(!r)throw new Error("get_feature_request_content: filename is required");const o=await fetch(dt(this._cfg.base_url,`/api/gateway/reports/features/${encodeURIComponent(r)}/content`),{headers:{...ft(this._cfg.auth_token)}});if(!o.ok)throw new Error(`get_feature_request_content failed: ${await Pt(o)}`);return await o.json()}async email_list_accounts(){const t=await fetch(dt(this._cfg.base_url,"/api/gateway/email/accounts"),{headers:{...ft(this._cfg.auth_token)}});if(!t.ok)throw new Error(`email_list_accounts failed: ${await Pt(t)}`);return await t.json()}async email_list_messages(t){const r=new URLSearchParams,o=String((t==null?void 0:t.account)||"").trim();o&&r.set("account",o);const l=String((t==null?void 0:t.mailbox)||"").trim();l&&r.set("mailbox",l);const u=String((t==null?void 0:t.since)||"").trim();u&&r.set("since",u);const c=String((t==null?void 0:t.status)||"").trim();c&&r.set("status",c);const d=typeof(t==null?void 0:t.limit)=="number"&&Number.isFinite(t.limit)?Number(t.limit):20;r.set("limit",String(d));const h=dt(this._cfg.base_url,`/api/gateway/email/messages?${r.toString()}`),_=await fetch(h,{headers:{...ft(this._cfg.auth_token)}});if(!_.ok)throw new Error(`email_list_messages failed: ${await Pt(_)}`);return await _.json()}async email_read_message(t,r){const o=String(t||"").trim();if(!o)throw new Error("email_read_message: uid is required");const l=new URLSearchParams,u=String((r==null?void 0:r.account)||"").trim();u&&l.set("account",u);const c=String((r==null?void 0:r.mailbox)||"").trim();c&&l.set("mailbox",c);const d=typeof(r==null?void 0:r.max_body_chars)=="number"&&Number.isFinite(r.max_body_chars)?Number(r.max_body_chars):2e4;l.set("max_body_chars",String(d));const h=dt(this._cfg.base_url,`/api/gateway/email/messages/${encodeURIComponent(o)}?${l.toString()}`),_=await fetch(h,{headers:{...ft(this._cfg.auth_token)}});if(!_.ok)throw new Error(`email_read_message failed: ${await Pt(_)}`);return await _.json()}async email_send(t){if(!String((t==null?void 0:t.subject)||"").trim())throw new Error("email_send: subject is required");const o=await fetch(dt(this._cfg.base_url,"/api/gateway/email/send"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(t||{})});if(!o.ok)throw new Error(`email_send failed: ${await Pt(o)}`);return await o.json()}async triage_run(t){const r={};typeof(t==null?void 0:t.write_drafts)=="boolean"&&(r.write_drafts=!!t.write_drafts),typeof(t==null?void 0:t.enable_llm)=="boolean"&&(r.enable_llm=!!t.enable_llm);const o=await fetch(dt(this._cfg.base_url,"/api/gateway/triage/run"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(r)});if(!o.ok)throw new Error(`triage_run failed: ${await Pt(o)}`);return await o.json()}async list_triage_decisions(t){const r=new URLSearchParams,o=String((t==null?void 0:t.status)||"").trim();o&&r.set("status",o);const l=typeof(t==null?void 0:t.limit)=="number"&&Number.isFinite(t.limit)?Number(t.limit):200;r.set("limit",String(l));const u=dt(this._cfg.base_url,`/api/gateway/triage/decisions?${r.toString()}`),c=await fetch(u,{headers:{...ft(this._cfg.auth_token)}});if(!c.ok)throw new Error(`list_triage_decisions failed: ${await Pt(c)}`);return await c.json()}async apply_triage_decision(t,r){const o=String(t||"").trim();if(!o)throw new Error("apply_triage_decision: decision_id is required");const l=String((r==null?void 0:r.action)||"").trim();if(!l)throw new Error("apply_triage_decision: action is required");const u={action:l};if(l==="defer"){const d=r==null?void 0:r.defer_days;typeof d=="number"&&Number.isFinite(d)&&d>0&&(u.defer_days=Number(d))}const c=await fetch(dt(this._cfg.base_url,`/api/gateway/triage/decisions/${encodeURIComponent(o)}/apply`),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(u)});if(!c.ok)throw new Error(`apply_triage_decision failed: ${await Pt(c)}`);return await c.json()}async backlog_list(t){const r=String(t||"").trim();if(!r)throw new Error("backlog_list: kind is required");const o=await fetch(dt(this._cfg.base_url,`/api/gateway/backlog/${encodeURIComponent(r)}`),{headers:{...ft(this._cfg.auth_token)}});if(!o.ok)throw new Error(`backlog_list failed: ${await Pt(o)}`);return await o.json()}async backlog_content(t,r){const o=String(t||"").trim(),l=String(r||"").trim();if(!o)throw new Error("backlog_content: kind is required");if(!l)throw new Error("backlog_content: filename is required");const u=await fetch(dt(this._cfg.base_url,`/api/gateway/backlog/${encodeURIComponent(o)}/${encodeURIComponent(l)}/content`),{headers:{...ft(this._cfg.auth_token)}});if(!u.ok)throw new Error(`backlog_content failed: ${await Pt(u)}`);return await u.json()}async backlog_template(){const t=await fetch(dt(this._cfg.base_url,"/api/gateway/backlog/template"),{headers:{...ft(this._cfg.auth_token)}});if(!t.ok)throw new Error(`backlog_template failed: ${await Pt(t)}`);return await t.json()}async backlog_move(t){const r=String((t==null?void 0:t.from_kind)||"").trim(),o=String((t==null?void 0:t.to_kind)||"").trim(),l=String((t==null?void 0:t.filename)||"").trim();if(!r)throw new Error("backlog_move: from_kind is required");if(!o)throw new Error("backlog_move: to_kind is required");if(!l)throw new Error("backlog_move: filename is required");const u=await fetch(dt(this._cfg.base_url,"/api/gateway/backlog/move"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify({from_kind:r,to_kind:o,filename:l})});if(!u.ok)throw new Error(`backlog_move failed: ${await Pt(u)}`);return await u.json()}async backlog_update(t){const r=String((t==null?void 0:t.kind)||"").trim(),o=String((t==null?void 0:t.filename)||"").trim();if(!r)throw new Error("backlog_update: kind is required");if(!o)throw new Error("backlog_update: filename is required");const u={content:String((t==null?void 0:t.content)??"")},c=String((t==null?void 0:t.expected_sha256)||"").trim();c&&(u.expected_sha256=c);const d=await fetch(dt(this._cfg.base_url,`/api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(o)}/update`),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(u)});if(!d.ok)throw new Error(`backlog_update failed: ${await Pt(d)}`);return await d.json()}async backlog_create(t){const r=String((t==null?void 0:t.kind)||"").trim(),o=String((t==null?void 0:t.package)||"").trim(),l=String((t==null?void 0:t.title)||"").trim();if(!r)throw new Error("backlog_create: kind is required");if(!o)throw new Error("backlog_create: package is required");if(!l)throw new Error("backlog_create: title is required");const u={kind:r,package:o,title:l},c=String((t==null?void 0:t.task_type)||"").trim();c&&(u.task_type=c);const d=String((t==null?void 0:t.summary)||"").trim();d&&(u.summary=d);const h=(t==null?void 0:t.content)==null?"":String((t==null?void 0:t.content)??"");h.trim()&&(u.content=h);const _=await fetch(dt(this._cfg.base_url,"/api/gateway/backlog/create"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(u)});if(!_.ok)throw new Error(`backlog_create failed: ${await Pt(_)}`);return await _.json()}async backlog_execute(t){const r=String((t==null?void 0:t.kind)||"").trim(),o=String((t==null?void 0:t.filename)||"").trim();if(!r)throw new Error("backlog_execute: kind is required");if(!o)throw new Error("backlog_execute: filename is required");const l=new URLSearchParams,u=String((t==null?void 0:t.execution_mode)||"").trim();u&&l.set("execution_mode",u);const c=dt(this._cfg.base_url,`/api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(o)}/execute${l.toString()?`?${l.toString()}`:""}`),d=await fetch(c,{method:"POST",headers:{...ft(this._cfg.auth_token)}});if(!d.ok)throw new Error(`backlog_execute failed: ${await Pt(d)}`);return await d.json()}async backlog_execute_batch(t){const r=Array.isArray(t==null?void 0:t.items)?t.items:[];if(!r.length)throw new Error("backlog_execute_batch: items are required");const o={items:r.map(c=>({kind:String((c==null?void 0:c.kind)||"").trim(),filename:String((c==null?void 0:c.filename)||"").trim()}))},l=String((t==null?void 0:t.execution_mode)||"").trim();l&&(o.execution_mode=l);const u=await fetch(dt(this._cfg.base_url,"/api/gateway/backlog/execute_batch"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(o)});if(!u.ok)throw new Error(`backlog_execute_batch failed: ${await Pt(u)}`);return await u.json()}async backlog_merge(t){const r=String((t==null?void 0:t.kind)||"").trim(),o=String((t==null?void 0:t.package)||"").trim(),l=String((t==null?void 0:t.title)||"").trim(),u=Array.isArray(t==null?void 0:t.items)?t.items:[];if(!r)throw new Error("backlog_merge: kind is required");if(!o)throw new Error("backlog_merge: package is required");if(!l)throw new Error("backlog_merge: title is required");if(u.length<2)throw new Error("backlog_merge: at least 2 items are required");const c={kind:r,package:o,title:l,items:u.map(g=>({kind:String((g==null?void 0:g.kind)||"").trim(),filename:String((g==null?void 0:g.filename)||"").trim()}))},d=String((t==null?void 0:t.task_type)||"").trim();d&&(c.task_type=d);const h=String((t==null?void 0:t.summary)||"").trim();h&&(c.summary=h);const _=await fetch(dt(this._cfg.base_url,"/api/gateway/backlog/merge"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(c)});if(!_.ok)throw new Error(`backlog_merge failed: ${await Pt(_)}`);return await _.json()}async backlog_exec_config(){const t=await fetch(dt(this._cfg.base_url,"/api/gateway/backlog/exec/config"),{headers:{...ft(this._cfg.auth_token)}});if(!t.ok)throw new Error(`backlog_exec_config failed: ${await Pt(t)}`);return await t.json()}async backlog_exec_requests(t){const r=new URLSearchParams,o=String((t==null?void 0:t.status)||"").trim();o&&r.set("status",o);const l=typeof(t==null?void 0:t.limit)=="number"&&Number.isFinite(t.limit)?Number(t.limit):200;r.set("limit",String(l));const u=dt(this._cfg.base_url,`/api/gateway/backlog/exec/requests?${r.toString()}`),c=await fetch(u,{headers:{...ft(this._cfg.auth_token)}});if(!c.ok)throw new Error(`backlog_exec_requests failed: ${await Pt(c)}`);return await c.json()}async backlog_exec_request(t,r){const o=String(t||"").trim();if(!o)throw new Error("backlog_exec_request: request_id is required");const l=new URLSearchParams;(r==null?void 0:r.include_prompt)===!0&&l.set("include_prompt","true");const u=dt(this._cfg.base_url,`/api/gateway/backlog/exec/requests/${encodeURIComponent(o)}?${l.toString()}`),c=await fetch(u,{headers:{...ft(this._cfg.auth_token)}});if(!c.ok)throw new Error(`backlog_exec_request failed: ${await Pt(c)}`);return await c.json()}async backlog_exec_feedback(t){const r=String((t==null?void 0:t.request_id)||"").trim();if(!r)throw new Error("backlog_exec_feedback: request_id is required");const o=String((t==null?void 0:t.feedback)??"");if(!o.trim())throw new Error("backlog_exec_feedback: feedback is required");const l={feedback:o},u=dt(this._cfg.base_url,`/api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/feedback`),c=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(l)});if(!c.ok)throw new Error(`backlog_exec_feedback failed: ${await Pt(c)}`);return await c.json()}async backlog_exec_promote(t){const r=String((t==null?void 0:t.request_id)||"").trim();if(!r)throw new Error("backlog_exec_promote: request_id is required");const o={};(t==null?void 0:t.redeploy)===!0&&(o.redeploy=!0);const l=dt(this._cfg.base_url,`/api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/promote`),u=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(o)});if(!u.ok)throw new Error(`backlog_exec_promote failed: ${await Pt(u)}`);return await u.json()}async backlog_exec_deploy_uat(t){const r=String((t==null?void 0:t.request_id)||"").trim();if(!r)throw new Error("backlog_exec_deploy_uat: request_id is required");const o=dt(this._cfg.base_url,`/api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/uat/deploy`),l=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:"{}"});if(!l.ok)throw new Error(`backlog_exec_deploy_uat failed: ${await Pt(l)}`);return await l.json()}async backlog_exec_log_tail(t){const r=String((t==null?void 0:t.request_id)||"").trim();if(!r)throw new Error("backlog_exec_log_tail: request_id is required");const o=new URLSearchParams,l=String((t==null?void 0:t.name)||"").trim();l&&o.set("name",l);const u=typeof(t==null?void 0:t.max_bytes)=="number"&&Number.isFinite(t.max_bytes)?Number(t.max_bytes):0;u>0&&o.set("max_bytes",String(Math.floor(u)));const c=dt(this._cfg.base_url,`/api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/logs/tail?${o.toString()}`),d=await fetch(c,{headers:{...ft(this._cfg.auth_token)}});if(!d.ok)throw new Error(`backlog_exec_log_tail failed: ${await Pt(d)}`);return await d.json()}async backlog_exec_active_items(t){const r=new URLSearchParams,o=String((t==null?void 0:t.status)||"").trim();o&&r.set("status",o);const l=typeof(t==null?void 0:t.limit)=="number"&&Number.isFinite(t.limit)?Number(t.limit):600;r.set("limit",String(l));const u=dt(this._cfg.base_url,`/api/gateway/backlog/exec/active_items?${r.toString()}`),c=await fetch(u,{headers:{...ft(this._cfg.auth_token)}});if(!c.ok)throw new Error(`backlog_exec_active_items failed: ${await Pt(c)}`);return await c.json()}async backlog_upload_attachment(t){const r=String((t==null?void 0:t.kind)||"").trim(),o=String((t==null?void 0:t.filename)||"").trim(),l=t==null?void 0:t.file;if(!r)throw new Error("backlog_upload_attachment: kind is required");if(!o)throw new Error("backlog_upload_attachment: filename is required");if(!l)throw new Error("backlog_upload_attachment: file is required");const u=(t==null?void 0:t.overwrite)===!0,c=new FormData;c.set("overwrite",u?"true":"false"),c.set("file",l,l.name||"attachment");const d=await fetch(dt(this._cfg.base_url,`/api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(o)}/attachments/upload`),{method:"POST",headers:{...ft(this._cfg.auth_token)},body:c});if(!d.ok)throw new Error(`backlog_upload_attachment failed: ${await Pt(d)}`);return await d.json()}async backlog_assist(t){const r=String((t==null?void 0:t.kind)||"").trim(),o=String((t==null?void 0:t.package)||"").trim(),l=String((t==null?void 0:t.title)||"").trim();if(!r)throw new Error("backlog_assist: kind is required");if(!o)throw new Error("backlog_assist: package is required");if(!l)throw new Error("backlog_assist: title is required");const u=Array.isArray(t==null?void 0:t.messages)?t.messages:[],c={kind:r,package:o,title:l,messages:u},d=String((t==null?void 0:t.summary)||"").trim();d&&(c.summary=d);const h=(t==null?void 0:t.draft_markdown)==null?"":String(t.draft_markdown??"");h.trim()&&(c.draft_markdown=h);const _=String((t==null?void 0:t.provider)||"").trim();_&&(c.provider=_);const g=String((t==null?void 0:t.model)||"").trim();g&&(c.model=g);const x=await fetch(dt(this._cfg.base_url,"/api/gateway/backlog/assist"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(c)});if(!x.ok)throw new Error(`backlog_assist failed: ${await Pt(x)}`);return await x.json()}async backlog_maintain(t){const r=String((t==null?void 0:t.kind)||"").trim(),o=String((t==null?void 0:t.filename)||"").trim(),l=String((t==null?void 0:t.package)||"").trim(),u=String((t==null?void 0:t.title)||"").trim();if(!r)throw new Error("backlog_maintain: kind is required");if(!o)throw new Error("backlog_maintain: filename is required");if(!l)throw new Error("backlog_maintain: package is required");if(!u)throw new Error("backlog_maintain: title is required");const c=Array.isArray(t==null?void 0:t.messages)?t.messages:[],d={kind:r,filename:o,package:l,title:u,messages:c},h=String((t==null?void 0:t.summary)||"").trim();h&&(d.summary=h);const _=(t==null?void 0:t.draft_markdown)==null?"":String(t.draft_markdown??"");_.trim()&&(d.draft_markdown=_);const g=String((t==null?void 0:t.provider)||"").trim();g&&(d.provider=g);const x=String((t==null?void 0:t.model)||"").trim();x&&(d.model=x);const v=await fetch(dt(this._cfg.base_url,"/api/gateway/backlog/maintain"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(d)});if(!v.ok)throw new Error(`backlog_maintain failed: ${await Pt(v)}`);return await v.json()}async backlog_advisor(t){const o={messages:Array.isArray(t==null?void 0:t.messages)?t.messages:[]},l=String((t==null?void 0:t.provider)||"").trim();l&&(o.provider=l);const u=String((t==null?void 0:t.model)||"").trim();u&&(o.model=u);const c=String((t==null?void 0:t.agent)||"").trim();c&&(o.agent=c),(t==null?void 0:t.include_trace)===!0&&(o.include_trace=!0);const d=String((t==null?void 0:t.focus_kind)||"").trim();d&&(o.focus_kind=d);const h=String((t==null?void 0:t.focus_type)||"").trim();h&&(o.focus_type=h);const _=await fetch(dt(this._cfg.base_url,"/api/gateway/backlog/advisor"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(o)});if(!_.ok)throw new Error(`backlog_advisor failed: ${await Pt(_)}`);return await _.json()}async bug_report_create(t){const r=String((t==null?void 0:t.session_id)||"").trim();if(!r)throw new Error("bug_report_create: session_id is required");const o=String((t==null?void 0:t.description)||"").trim();if(!o)throw new Error("bug_report_create: description is required");const l={session_id:r,description:o},u=String((t==null?void 0:t.active_run_id)||"").trim();u&&(l.active_run_id=u);const c=String((t==null?void 0:t.workflow_id)||"").trim();c&&(l.workflow_id=c);const d=String((t==null?void 0:t.client)||"").trim();d&&(l.client=d);const h=String((t==null?void 0:t.client_version)||"").trim();h&&(l.client_version=h);const _=String((t==null?void 0:t.user_agent)||"").trim();_&&(l.user_agent=_);const g=String((t==null?void 0:t.url)||"").trim();g&&(l.url=g);const x=String((t==null?void 0:t.provider)||"").trim();x&&(l.provider=x);const v=String((t==null?void 0:t.model)||"").trim();v&&(l.model=v);const b=String((t==null?void 0:t.template)||"").trim();b&&(l.template=b);const j=t==null?void 0:t.context;j&&typeof j=="object"&&(l.context=j);const S=await fetch(dt(this._cfg.base_url,"/api/gateway/bugs/report"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(l)});if(!S.ok)throw new Error(`bug_report_create failed: ${await Pt(S)}`);return await S.json()}async feature_report_create(t){const r=String((t==null?void 0:t.session_id)||"").trim();if(!r)throw new Error("feature_report_create: session_id is required");const o=String((t==null?void 0:t.description)||"").trim();if(!o)throw new Error("feature_report_create: description is required");const l={session_id:r,description:o},u=String((t==null?void 0:t.active_run_id)||"").trim();u&&(l.active_run_id=u);const c=String((t==null?void 0:t.workflow_id)||"").trim();c&&(l.workflow_id=c);const d=String((t==null?void 0:t.client)||"").trim();d&&(l.client=d);const h=String((t==null?void 0:t.client_version)||"").trim();h&&(l.client_version=h);const _=String((t==null?void 0:t.user_agent)||"").trim();_&&(l.user_agent=_);const g=String((t==null?void 0:t.url)||"").trim();g&&(l.url=g);const x=String((t==null?void 0:t.provider)||"").trim();x&&(l.provider=x);const v=String((t==null?void 0:t.model)||"").trim();v&&(l.model=v);const b=String((t==null?void 0:t.template)||"").trim();b&&(l.template=b);const j=t==null?void 0:t.context;j&&typeof j=="object"&&(l.context=j);const S=await fetch(dt(this._cfg.base_url,"/api/gateway/features/report"),{method:"POST",headers:{"Content-Type":"application/json",...ft(this._cfg.auth_token)},body:JSON.stringify(l)});if(!S.ok)throw new Error(`feature_report_create failed: ${await Pt(S)}`);return await S.json()}async stream_ledger(t,r){const o=Number((r==null?void 0:r.after)||0),l=r.on_step,u=r.signal,c=dt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(t)}/ledger/stream?after=${encodeURIComponent(String(o))}`),d=await fetch(c,{headers:{Accept:"text/event-stream",...ft(this._cfg.auth_token)},signal:u});if(!d.ok)throw new Error(`stream_ledger failed: ${d.status}`);if(!d.body)throw new Error("stream_ledger: response body is missing");const h=d.body.getReader(),_=new TextDecoder("utf-8"),g=new Jv;for(;;){const{value:x,done:v}=await h.read();if(v)return;const b=_.decode(x,{stream:!0});g.push(b,j=>{if(!(j.event!=="step"||!j.data))try{const S=JSON.parse(j.data);S&&typeof S.cursor=="number"&&S.record&&l(S)}catch{}})}}}function Xr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id_${Date.now()}_${Math.random().toString(16).slice(2)}`}function Zv(e){const t=(e||"").trim();return t?{Authorization:`Bearer ${t}`}:{}}class ew{constructor(t){vu(this,"_cfg");this._cfg={...t,url:(t.url||"").trim()}}async call_tool(t){const r=String((t==null?void 0:t.name)||"").trim(),o=String((t==null?void 0:t.call_id)||(t==null?void 0:t.id)||Xr()),l=t!=null&&t.arguments&&typeof t.arguments=="object"?t.arguments:{};if(!r)return{call_id:o,name:"",success:!1,output:null,error:"Missing tool name"};const u={jsonrpc:"2.0",id:Xr(),method:"tools/call",params:{name:r,arguments:l}},c=await fetch(this._cfg.url,{method:"POST",headers:{"Content-Type":"application/json",...Zv(this._cfg.auth_token)},body:JSON.stringify(u)});if(!c.ok)return{call_id:o,name:r,success:!1,output:null,error:`Worker HTTP ${c.status}`};const d=await c.json().catch(()=>null),h=d==null?void 0:d.result,_=!!(h!=null&&h.isError),x=(Array.isArray(h==null?void 0:h.content)?h.content:[]).find(b=>b&&b.type==="text"&&typeof b.text=="string"),v=(x==null?void 0:x.text)??"";return _?{call_id:o,name:r,success:!1,output:null,error:v||"Tool failed"}:{call_id:o,name:r,success:!0,output:v,error:null}}}function ul(e){var o;const t=e,r=(o=t==null?void 0:t.result)==null?void 0:o.wait;return!r||typeof r!="object"?null:r}function Nd(e){var u,c,d;const t=e,r=t==null?void 0:t.effect;if(!r||typeof r!="object"||String(r.type||"")!=="emit_event")return null;const o=String(((u=r==null?void 0:r.payload)==null?void 0:u.name)||((c=r==null?void 0:r.payload)==null?void 0:c.event_name)||"").trim();if(!o)return null;const l=(d=r==null?void 0:r.payload)==null?void 0:d.payload;return{name:o,payload:l}}function m_(e){const t=e,r=t==null?void 0:t.details;if(!r||typeof r!="object")return[];const o=r==null?void 0:r.tool_calls;return Array.isArray(o)?o:[]}const tw={execution:"#FFFFFF",string:"#FF00FF",number:"#00FF00",boolean:"#FF0000",object:"#00FFFF",array:"#FF8800",tools:"#FF8800",provider:"#00D2FF",model:"#9D4EDD",agent:"#4488FF",any:"#888888"},nw=[{type:"execution",label:"Execution",shape:"▷",description:"Controls flow order"},{type:"string",label:"String",shape:"●",description:"Text data"},{type:"number",label:"Number",shape:"●",description:"Integer or float"},{type:"boolean",label:"Boolean",shape:"◇",description:"True/False"},{type:"object",label:"Object",shape:"●",description:"JSON objects"},{type:"array",label:"Array",shape:"■",description:"Collections"},{type:"tools",label:"Tools",shape:"■",description:"Tool allowlist (string[])"},{type:"provider",label:"Provider",shape:"●",description:"LLM provider id/name (string-like)"},{type:"model",label:"Model",shape:"●",description:"LLM model id/name (string-like)"},{type:"agent",label:"Agent",shape:"⬢",description:"Agent reference"},{type:"any",label:"Any",shape:"●",description:"Accepts any type"}];function rw(){const[e,t]=m.useState(!0);return s.jsxs("div",{className:"pin-legend",children:[s.jsxs("button",{className:"pin-legend-toggle mono",type:"button",onClick:()=>t(r=>!r),title:"Pin Type Legend",children:[e?"?":"×"," Pin Types"]}),e?null:s.jsxs("div",{className:"pin-legend-content",children:[nw.map(r=>s.jsxs("div",{className:"pin-legend-row",children:[s.jsx("span",{className:"pin-legend-shape",style:{color:tw[r.type]},children:r.shape}),s.jsx("span",{className:"pin-legend-label mono",children:r.label}),s.jsx("span",{className:"pin-legend-desc mono",children:r.description})]},r.type)),s.jsxs("div",{className:"pin-legend-rules mono",children:[s.jsx("strong",{children:"Connection Rules:"}),s.jsxs("ul",{children:[s.jsx("li",{children:"Execution connects to Execution only"}),s.jsx("li",{children:'"Any" type accepts all data types'}),s.jsx("li",{children:"Same types always compatible"}),s.jsx("li",{children:"Array and Object are interchangeable"}),s.jsx("li",{children:'"Tools" is compatible with Array (specialized string[])'})]})]})]})]})}function zn(e){return typeof e=="string"?e:e==null?"":String(e)}function Tp(e,t){const r=zn(e).trim();return r.length<=t?r:`${r.slice(0,Math.max(0,t-1))}…`}function h_(e){const t=zn(e==null?void 0:e.targetHandle),r=zn(e==null?void 0:e.sourceHandle);return!!(t==="exec-in"||r==="exec-out"||t.includes("exec")||r.includes("exec"))}function p_(e){if(!e||typeof e!="object")return"";const t=e!=null&&e.data&&typeof e.data=="object"?e.data:{};return zn((t==null?void 0:t.nodeType)||(e==null?void 0:e.type)||"").trim()}function g_(e){if(!e||typeof e!="object")return"";const t=e!=null&&e.data&&typeof e.data=="object"?e.data:{},r=(t==null?void 0:t.subflowId)||(t==null?void 0:t.flowId),o=zn(r).trim();if(!o)return"";if(o.includes(":")){const l=o.split(":",2);if(l.length===2&&l[1])return l[1].trim()}return o}function sw(e){const t=zn(e==null?void 0:e.entryNode).trim();if(t)return t;const r=Array.isArray(e==null?void 0:e.nodes)?e.nodes:[];for(const o of r)if(p_(o)==="on_flow_start"){const l=zn(o==null?void 0:o.id).trim();if(l)return l}return""}function em(e){const t=e!=null&&e.position&&typeof e.position=="object"?e.position:{},r=typeof t.x=="number"?t.x:0,o=typeof t.y=="number"?t.y:0;return{x:r,y:o}}function Su(e,t){const r=zn(e).trim(),o=zn(t).trim();return o?r?`${r}::${o}`:o:""}function iw(e){const t=e.root&&typeof e.root=="object"?e.root:{};if(!e.expand_subflows)return t;const r=[],o=[],l=new Set,u=(c,d,h,_)=>{if(!c||typeof c!="object"||r.length>=e.max_nodes||o.length>=e.max_edges)return;const g=Array.isArray(c.nodes)?c.nodes:[],x=Array.isArray(c.edges)?c.edges:[];for(const v of g){const b=zn(v==null?void 0:v.id).trim();if(!b)continue;const j=Su(d,b);if(!j||l.has(j))continue;const S=em(v),T={...v,id:j,position:{x:S.x+h.x,y:S.y+h.y}};if(r.push(T),l.add(j),r.length>=e.max_nodes)break}for(const v of x){if(!h_(v))continue;const b=zn(v==null?void 0:v.source).trim(),j=zn(v==null?void 0:v.target).trim();if(!b||!j)continue;const S=Su(d,b),T=Su(d,j);if(!S||!T)continue;const M=zn(v==null?void 0:v.id).trim(),D=M?`${S}->${T}::${M}`:`${S}->${T}`;if(o.push({...v,id:D,source:S,target:T}),o.length>=e.max_edges)break}if(!(_>=e.max_depth))for(const v of g){if(r.length>=e.max_nodes||o.length>=e.max_edges)return;if(p_(v)!=="subflow")continue;const b=g_(v);if(!b)continue;const j=e.flow_by_id[b];if(!j||typeof j!="object")continue;const S=Su(d,zn(v==null?void 0:v.id));if(!S)continue;const T=sw(j);if(!T)continue;const D=(Array.isArray(j.nodes)?j.nodes:[]).find(le=>zn(le==null?void 0:le.id).trim()===T)||null;if(!D)continue;const L=em(v),I=em(D),Y={x:L.x+h.x+240-I.x,y:L.y+h.y+0-I.y},oe=Su(S,T);o.push({id:`${S}=>${oe}`,source:S,target:oe,sourceHandle:"exec-out",targetHandle:"exec-in"}),u(j,S,Y,_+1)}};return u(t,"",{x:0,y:0},0),{...t,id:zn(t.id),nodes:r,edges:o}}function ow(e){const t=zn(e).trim().toLowerCase();return t?!!(t.startsWith("literal")||t.includes("literal")||t==="concat"||t==="join"||t==="cast"||t==="parse_json"||t==="stringify_json"||t==="break_object"||t==="get_property"||t==="set_property"||t.includes("get_property")||t.includes("set_property")||t==="get_variable"||t==="set_variable"||t.includes("get_variable")||t.includes("set_variable")||t==="json_schema"):!1}function aw(e){const t=e.nodes.filter(u=>e.keep_id(u.id)),r=new Set(t.map(u=>u.id)),o={};for(const u of e.edges)o[u.source]||(o[u.source]=[]),o[u.source].push(u.target);const l=new Map;for(const u of t){const c=new Set,d=(o[u.id]||[]).slice();for(;d.length;){const h=d.pop();if(!h||c.has(h))continue;if(c.add(h),r.has(h)){const g=`${u.id}->${h}`;l.has(g)||l.set(g,{id:g,source:u.id,target:h});continue}const _=o[h]||[];for(const g of _)c.has(g)||d.push(g);if(l.size>=e.max_edges)break}if(l.size>=e.max_edges)break}return{nodes:t,edges:Array.from(l.values())}}function Mp(e,t){const l=Math.max(t.w*8,160),u=Math.max(t.h*8,120),c=Math.max(160,Math.min(l,e.w)),d=Math.max(120,Math.min(u,e.h));return{x:e.x,y:e.y,w:c,h:d}}function lw(e){const t=typeof e.now_ms=="number"?e.now_ms:Date.now(),r=e.flow,o=zn(e.active_node_id),l=e.recent_nodes||{},u=e.visited_nodes||{},c=e.highlight_path===!0,d=typeof e.vertical_compact=="number"?Math.max(.4,Math.min(1,e.vertical_compact)):.78,{nodes:h,edges:_,bounds:g}=m.useMemo(()=>{const k=iw({root:r||{},flow_by_id:e.flow_by_id||{},expand_subflows:e.expand_subflows===!0,max_depth:3,max_nodes:700,max_edges:900}),z=Array.isArray(k.nodes)?k.nodes:[],F=Array.isArray(k.edges)?k.edges:[];let N=[];for(const ze of z){const Oe=zn(ze==null?void 0:ze.id).trim();if(!Oe)continue;const lt=ze!=null&&ze.position&&typeof ze.position=="object"?ze.position:{},xe=typeof lt.x=="number"?lt.x:0,Et=typeof lt.y=="number"?lt.y:0,yt=ze!=null&&ze.data&&typeof ze.data=="object"?ze.data:{},sn=zn((yt==null?void 0:yt.label)||(ze==null?void 0:ze.label)||Oe)||Oe,ln=zn((yt==null?void 0:yt.nodeType)||(ze==null?void 0:ze.type)||"unknown")||"unknown",Xt=zn((yt==null?void 0:yt.headerColor)||(ze==null?void 0:ze.headerColor)||"")||"",je=yt!=null&&yt.eventConfig&&typeof yt.eventConfig=="object"?yt.eventConfig:null,ue=je&&typeof je.schedule=="string"?zn(je.schedule).trim():"",Ne=je&&typeof je.recurrent=="boolean"?!!je.recurrent:void 0,$t=ln==="subflow"?g_(ze):"",pt=ue||Ne!==void 0||$t?{schedule:ue||void 0,recurrent:Ne,subflow_id:$t||void 0}:void 0;N.push({id:Oe,x:xe,y:Et,label:sn,type:ln,color:Xt,meta:pt})}const B={};for(const ze of N)B[ze.id]=ze;let Z=[];for(const ze of F){if(!h_(ze))continue;const Oe=zn(ze==null?void 0:ze.source).trim(),lt=zn(ze==null?void 0:ze.target).trim();!Oe||!lt||Z.push({id:zn((ze==null?void 0:ze.id)||`${Oe}->${lt}`),source:Oe,target:lt})}const te=new Set(N.map(ze=>ze.id));if(Z=Z.filter(ze=>te.has(ze.source)&&te.has(ze.target)),e.simplify===!0){const Oe=aw({nodes:N,edges:Z,keep_id:lt=>{if(o&<===o)return!0;const xe=B[lt];if(!xe)return!1;const Et=zn(xe.type).trim().toLowerCase();return Et==="on_flow_start"||Et==="on_flow_end"||Et==="subflow"?!0:!ow(Et)},max_edges:900});N=Oe.nodes,Z=Oe.edges}if(e.prefer_vertical===!0&&N.length>=2){const ze=N.map(yt=>yt.x),Oe=N.map(yt=>yt.y),lt=Math.max(...ze)-Math.min(...ze),xe=Math.max(...Oe)-Math.min(...Oe);lt>=xe&&(N=N.map(yt=>({...yt,x:yt.y,y:yt.x})));const Et=Math.min(...N.map(yt=>yt.y));N=N.map(yt=>({...yt,y:Et+(yt.y-Et)*d}))}const he={};for(const ze of N)he[ze.id]=ze;const Ae=160,se=56,ve=Ae/2,Re=se/2;let Qe=0,Pe=0,de=0,be=0;N.length&&(Qe=Math.min(...N.map(ze=>ze.x)),Pe=Math.min(...N.map(ze=>ze.y)),de=Math.max(...N.map(ze=>ze.x+Ae)),be=Math.max(...N.map(ze=>ze.y+se)));let Fe=0;if(Z.length){const ze=new Set(Z.map(Oe=>`${Oe.source}->${Oe.target}`));for(const Oe of Z){if(!ze.has(`${Oe.target}->${Oe.source}`))continue;const lt=he[Oe.source],xe=he[Oe.target];if(!lt||!xe)continue;const Et=lt.x+ve,yt=lt.y+Re,sn=xe.x+ve,ln=xe.y+Re,Xt=Math.max(1,Math.hypot(sn-Et,ln-yt)),je=Math.max(28,Math.min(72,Xt*.14)),ue=Math.min(200,je*3.5);ue>Fe&&(Fe=ue)}}const Xe=60+Fe,tt={x:Qe-Xe,y:Pe-Xe,w:de-Qe+Xe*2,h:be-Pe+Xe*2,node_w:Ae,node_h:se};return{nodes:N,edges:Z,bounds:tt}},[r,e.flow_by_id,e.expand_subflows,e.simplify,e.prefer_vertical,o,d]);if(!r)return s.jsx("div",{className:"graph_empty mono",children:"(no graph loaded)"});const x=m.useRef(null),[v,b]=m.useState(()=>({x:g.x,y:g.y,w:g.w,h:g.h})),j=m.useRef(v);j.current=v,m.useEffect(()=>{b({x:g.x,y:g.y,w:g.w,h:g.h})},[g.x,g.y,g.w,g.h]);const S=m.useRef(new Map),T=m.useRef(null),M=`${v.x} ${v.y} ${v.w} ${v.h}`,D={};for(const k of h)D[k.id]=k;const L=k=>{let z=zn(k).trim();if(!z)return"";if(D[z])return z;for(;z.includes("::");)if(z=z.slice(0,Math.max(0,z.lastIndexOf("::"))),D[z])return z;return""},I=L(o),G={};for(const[k,z]of Object.entries(l)){if(typeof z!="number")continue;const F=L(k);F&&(G[F]=Math.max(G[F]||0,z))}const ne={};if(c)for(const[k,z]of Object.entries(u)){if(typeof z!="number")continue;const F=L(k);F&&(ne[F]=typeof ne[F]=="number"?Math.min(ne[F],z):z)}const Y=zn(e.schedule_next_in).trim(),oe=zn(e.schedule_interval).trim(),le=e.node_last_ms&&typeof e.node_last_ms=="object"?e.node_last_ms:{},_e=k=>{try{const z=new Date(k),F=String(z.getHours()).padStart(2,"0"),N=String(z.getMinutes()).padStart(2,"0");return`${F}:${N}`}catch{return""}},Te=(k,z)=>{var Z,te;const F=zn((Z=k.meta)==null?void 0:Z.schedule).trim();if(!(((te=k.meta)==null?void 0:te.recurrent)===!0))return z&&Y?`next ${Y}`:F&&F.length<=12&&!F.includes("T")?`in ${F}`:"scheduled";const B=F||oe;return B?z&&Y?`${B} • next ${Y}`:`every ${B}`:z&&Y?`next ${Y}`:"scheduled"},$e=k=>{var Ae;const z=zn((Ae=k.meta)==null?void 0:Ae.subflow_id).trim(),F=z&&e.flow_by_id?e.flow_by_id[z]:null,B=zn(F==null?void 0:F.name).trim()||z||k.label||k.id,Z=typeof le[k.id]=="number"?Number(le[k.id]):null,te=Z!==null?_e(Z):"",he=te?`last ${te}`:"subflow";return{label:B,sub:he}},K=(k,z,F)=>{const N=F||j.current,B=x.current;if(!B)return{x:k,y:z};const Z=B.getBoundingClientRect(),te=Z.width>0?(k-Z.left)/Z.width:0,he=Z.height>0?(z-Z.top)/Z.height:0;return{x:N.x+te*N.w,y:N.y+he*N.h}},U=(k,z,F)=>{const N=F||j.current,B=Math.max(.12,Math.min(8,z)),Z=N.w*B,te=N.h*B,he=N.w>0?(k.x-N.x)/N.w:.5,Ae=N.h>0?(k.y-N.y)/N.h:.5,se=k.x-he*Z,ve=k.y-Ae*te;b(Mp({x:se,y:ve,w:Z,h:te},g))},X=(k,z,F)=>{const N=F||j.current,B=x.current;if(!B)return;const Z=B.getBoundingClientRect(),te=.88,he=Z.width>0?k/Z.width*N.w*te:0,Ae=Z.height>0?z/Z.height*N.h*te:0;b(se=>Mp({x:(F||se).x-he,y:(F||se).y-Ae,w:(F||se).w,h:(F||se).h},g))},V=m.useMemo(()=>{const k=new Set;for(const z of _)k.add(`${z.source}->${z.target}`);return k},[_]),J=(k,z,F,N)=>{const B=g.node_w,Z=g.node_h,te=Math.abs(F),he=Math.abs(N);if(te<1e-6&&he<1e-6)return{x:k,y:z};const Ae=te>1e-6?B/2/te:Number.POSITIVE_INFINITY,se=he>1e-6?Z/2/he:Number.POSITIVE_INFINITY,ve=Math.min(Ae,se);return{x:k+F*ve,y:z+N*ve}};return s.jsxs("div",{className:"graph_wrap",children:[s.jsxs("div",{className:"graph_corner",children:[s.jsxs("div",{className:"graph_corner_buttons",children:[s.jsx("button",{className:"btn graph_corner_btn",type:"button",onClick:()=>b({x:g.x,y:g.y,w:g.w,h:g.h}),title:"Recenter",children:"⤢"}),s.jsx("button",{className:"btn graph_corner_btn",type:"button",onClick:()=>{const k=x.current;if(!k)return;const z=k.getBoundingClientRect(),F=K(z.left+z.width/2,z.top+z.height/2);U(F,.84)},title:"Zoom in",children:"+"}),s.jsx("button",{className:"btn graph_corner_btn",type:"button",onClick:()=>{const k=x.current;if(!k)return;const z=k.getBoundingClientRect(),F=K(z.left+z.width/2,z.top+z.height/2);U(F,1.18)},title:"Zoom out",children:"−"})]}),s.jsx(rw,{})]}),s.jsxs("svg",{ref:x,className:"graph_svg",viewBox:M,role:"img","aria-label":"Workflow execution graph",onWheel:k=>{k.preventDefault();const z=K(k.clientX,k.clientY),F=typeof k.deltaY=="number"?k.deltaY:0,N=typeof k.deltaMode=="number"?Number(k.deltaMode):0,B=N===1?F*24:N===2?F*800:F,Z=45e-5*1.15*1.1;let te=Math.exp(B*Z);te=Math.max(.86,Math.min(1.16,te)),U(z,te)},onPointerDown:k=>{var F,N;(N=(F=k.currentTarget).setPointerCapture)==null||N.call(F,k.pointerId),S.current.set(k.pointerId,{x:k.clientX,y:k.clientY});const z=Array.from(S.current.values());if(z.length===1)T.current={mode:"pan",start_view:j.current,start_client:{x:k.clientX,y:k.clientY},start_dist:0,anchor_svg:{x:0,y:0}};else if(z.length>=2){const B=z[0],Z=z[1],te=B.x-Z.x,he=B.y-Z.y,Ae=Math.max(1,Math.hypot(te,he)),se={x:(B.x+Z.x)/2,y:(B.y+Z.y)/2},ve=j.current;T.current={mode:"pinch",start_view:ve,start_client:se,start_dist:Ae,anchor_svg:K(se.x,se.y,ve)}}},onPointerMove:k=>{if(!S.current.has(k.pointerId))return;S.current.set(k.pointerId,{x:k.clientX,y:k.clientY});const z=T.current;if(!z)return;const F=Array.from(S.current.values());if(z.mode==="pan"&&F.length===1){const N=k.clientX-z.start_client.x,B=k.clientY-z.start_client.y;X(N,B,z.start_view)}else if(z.mode==="pinch"&&F.length>=2){const N=F[0],B=F[1],Z=N.x-B.x,te=N.y-B.y,he=Math.max(1,Math.hypot(Z,te)),Ae=z.start_dist/he;U(z.anchor_svg,Ae,z.start_view)}},onPointerUp:k=>{S.current.delete(k.pointerId),S.current.size===0&&(T.current=null)},onPointerCancel:k=>{S.current.delete(k.pointerId),S.current.size===0&&(T.current=null)},children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"rgba(148,163,184,0.55)"})}),s.jsxs("filter",{id:"glow",children:[s.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"coloredBlur"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]})]}),_.map(k=>{const z=D[k.source],F=D[k.target];if(!z||!F)return null;const N=z.x+g.node_w/2,B=z.y+g.node_h/2,Z=F.x+g.node_w/2,te=F.y+g.node_h/2,he=Z-N,Ae=te-B,se=J(N,B,he,Ae),ve=J(Z,te,-he,-Ae),Re=k.source!==k.target&&V.has(`${k.target}->${k.source}`),Qe=Math.max(1,Math.hypot(he,Ae)),Pe=-Ae/Qe,de=he/Qe,be=String(k.source)<String(k.target)?1:-1,Xe=Math.abs(he)>=Math.abs(Ae)?he>=0:Ae>=0,tt=!Re||Xe,ze=Math.max(28,Math.min(72,Qe*.14)),Oe=Math.min(200,ze*3.5),lt=Re&&!tt?Oe*be:0,xe=(se.x+ve.x)/2+Pe*lt,Et=(se.y+ve.y)/2+de*lt,yt=Re&&!tt?`M ${se.x} ${se.y} Q ${xe} ${Et} ${ve.x} ${ve.y}`:`M ${se.x} ${se.y} L ${ve.x} ${ve.y}`,sn=c&&ne&&ne[k.source]!==void 0&&ne[k.target]!==void 0;return s.jsx("path",{d:yt,className:`graph_edge ${sn?"visited":""}`,markerEnd:"url(#arrow)",fill:"none"},k.id)}),h.map(k=>{const F=(typeof G[k.id]=="number"?G[k.id]:0)>t,N=I&&k.id===I,B=c&&ne&&ne[k.id]!==void 0,Z=`graph_node ${N?"active":F?"recent":""} ${B?"visited":""}`,te=k.color||"rgba(255,255,255,0.16)";let he=k.label||k.id,Ae=k.type;if(k.type==="on_schedule")Ae=Te(k,!!N);else if(k.type==="subflow"){const Re=$e(k);he=Re.label,Ae=Re.sub}const se=Tp(he,22),ve=Tp(Ae,22);return s.jsxs("g",{className:Z,transform:`translate(${k.x}, ${k.y})`,children:[s.jsx("rect",{className:"graph_node_bg",width:g.node_w,height:g.node_h,rx:12,ry:12}),s.jsx("rect",{className:"graph_node_bar",width:g.node_w,height:6,rx:12,ry:12,fill:te}),s.jsx("text",{className:"graph_node_label",x:12,y:28,children:se}),s.jsx("text",{className:"graph_node_type",x:12,y:46,children:ve}),k.type==="on_schedule"?s.jsx("text",{className:"graph_node_icon",x:g.node_w-18,y:18,children:"⏰"}):null]},k.id)})]})]})}function rh(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function __(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:rh(e)?`Object(${Object.keys(e).length})`:typeof e}function zp(e,t){const r={},o=(l,u,c)=>{if(Array.isArray(l)){c>=t.depth_threshold&&l.length>=t.min_items&&(r[u]=!0),l.forEach((d,h)=>o(d,`${u}[${h}]`,c+1));return}if(rh(l)){const d=Object.keys(l);c>=t.depth_threshold&&d.length>=t.min_items&&(r[u]=!0),d.forEach(h=>o(l[h],`${u}.${h}`,c+1))}};return o(e,"$",0),r}function y_(e){const t=typeof e.max_string_len=="number"?e.max_string_len:240,r=m.useMemo(()=>e.value,[e.value]),[o,l]=m.useState(()=>zp(r,{depth_threshold:2,min_items:6})),[u,c]=m.useState({});m.useEffect(()=>{l(zp(r,{depth_threshold:2,min_items:6})),c({})},[r]);const d=_=>l(g=>({...g,[_]:!g[_]})),h=_=>c(g=>({...g,[_]:!g[_]}));return s.jsx("div",{className:"json_viewer",children:sh({value:r,path:"$",depth:0,is_last:!0,collapsed:o,expanded_string:u,toggle_collapse:d,toggle_string:h,max_string_len:t})})}function sh(e){const t=e.value,r=e.prefix||null;return t===null?so(e.depth,r,s.jsx("span",{className:"json_null",children:"null"}),e.is_last):t===void 0?so(e.depth,r,s.jsx("span",{className:"json_null",children:"undefined"}),e.is_last):typeof t=="string"?so(e.depth,r,cw(t,e),e.is_last):typeof t=="number"?so(e.depth,r,s.jsx("span",{className:"json_number",children:String(t)}),e.is_last):typeof t=="boolean"?so(e.depth,r,s.jsx("span",{className:"json_bool",children:String(t)}),e.is_last):Array.isArray(t)?uw(t,e):rh(t)?dw(t,e):so(e.depth,r,s.jsx("span",{className:"json_string",children:JSON.stringify(String(t))}),e.is_last)}function cw(e,t){const r=t.expanded_string[t.path]===!0,o=e.length>t.max_string_len,l=o&&!r?e.slice(0,t.max_string_len):e,u=JSON.stringify(l);return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"json_string",children:u}),o?s.jsxs(s.Fragment,{children:[r?null:s.jsx("span",{className:"json_ellipsis",children:"…"}),s.jsx("button",{className:"json_toggle json_toggle_inline",onClick:()=>t.toggle_string(t.path),title:r?"Collapse string":"Expand string",children:r?"−":"+"}),s.jsxs("span",{className:"json_hint",children:[e.length," chars"]})]}):null]})}function uw(e,t){const r=t.collapsed[t.path]===!0,o=e.length;return r?so(t.depth,t.prefix,s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"json_toggle",onClick:()=>t.toggle_collapse(t.path),title:"Expand",children:"▶"}),s.jsx("span",{className:"json_brace",children:"["}),s.jsx("span",{className:"json_hint",children:__(e)}),s.jsx("span",{className:"json_brace",children:"]"}),s.jsxs("span",{className:"json_hint",children:[" ",o]})]}),t.is_last):s.jsxs(s.Fragment,{children:[so(t.depth,t.prefix,s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"json_toggle",onClick:()=>t.toggle_collapse(t.path),title:"Collapse",children:"▼"}),s.jsx("span",{className:"json_brace",children:"["})]}),!0),e.map((l,u)=>sh({...t,value:l,path:`${t.path}[${u}]`,depth:t.depth+1,is_last:u===e.length-1,prefix:null})),so(t.depth,null,s.jsx("span",{className:"json_brace",children:"]"}),t.is_last)]})}function dw(e,t){const r=t.collapsed[t.path]===!0,o=Object.keys(e),l=o.length;return r?so(t.depth,t.prefix,s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"json_toggle",onClick:()=>t.toggle_collapse(t.path),title:"Expand",children:"▶"}),s.jsx("span",{className:"json_brace",children:"{"}),s.jsx("span",{className:"json_hint",children:__(e)}),s.jsx("span",{className:"json_brace",children:"}"}),s.jsxs("span",{className:"json_hint",children:[" ",l]})]}),t.is_last):s.jsxs(s.Fragment,{children:[so(t.depth,t.prefix,s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"json_toggle",onClick:()=>t.toggle_collapse(t.path),title:"Collapse",children:"▼"}),s.jsx("span",{className:"json_brace",children:"{"})]}),!0),o.map((u,c)=>{const d=`${t.path}.${u}`,h=c===o.length-1,_=e[u],g=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"json_key",children:JSON.stringify(u)}),s.jsx("span",{className:"json_colon",children:": "})]});return sh({...t,value:_,path:d,depth:t.depth+1,is_last:h,prefix:g})}),so(t.depth,null,s.jsx("span",{className:"json_brace",children:"}"}),t.is_last)]})}function so(e,t,r,o){return s.jsxs("div",{className:"json_line",style:{paddingLeft:`${e*14}px`},children:[t?s.jsx("span",{className:"json_prefix",children:t}):null,r,o?null:s.jsx("span",{className:"json_comma",children:","})]})}function fw(){var t;if(typeof window>"u")return!1;const e=navigator;return!!((t=e==null?void 0:e.mediaDevices)!=null&&t.getUserMedia)&&typeof window.MediaRecorder=="function"}function mw(){if(typeof window>"u")return!1;const e=window;return!!(e!=null&&e.AudioContext||e!=null&&e.webkitAudioContext)}function hw(){const e=window.MediaRecorder,t=o=>{var l;try{return!!((l=e==null?void 0:e.isTypeSupported)!=null&&l.call(e,o))}catch{return!1}},r=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];for(const o of r)if(t(o))return o;return""}async function pw(e,t){var l;const r=t.slice(0),o=(l=e.decodeAudioData)==null?void 0:l.bind(e);if(typeof o!="function")throw new Error("decodeAudioData not available");try{const u=o(r);if(u&&typeof u.then=="function")return await u}catch{}return await new Promise((u,c)=>{try{o(r,u,c)}catch(d){c(d)}})}function x_(e){const t=X=>{var V;return(V=e.on_error)==null?void 0:V.call(e,X)},r=m.useMemo(()=>mw(),[]),o=m.useMemo(()=>fw(),[]),[l,u]=m.useState({key:"",status:"idle"}),c=m.useRef(""),d=m.useRef(""),h=m.useRef(null),_=m.useRef(null),g=m.useRef(null),x=m.useRef(null),v=m.useRef(0),b=m.useRef(0),j=()=>{try{const X=globalThis,V=(X==null?void 0:X.AudioContext)||(X==null?void 0:X.webkitAudioContext);if(!V)return null;if(!h.current){const z=new V,F=z.createGain();F.gain.value=1,F.connect(z.destination),h.current=z,_.current=F}const J=h.current,k=_.current;if(!J||!k)return null;try{J.state==="suspended"&&J.resume()}catch{}return{ctx:J,gain:k}}catch{return null}},S=()=>{const X=g.current;if(g.current=null,!!X){try{X.onended=null}catch{}try{X.stop()}catch{}try{X.disconnect()}catch{}}},T=()=>{S(),d.current="",c.current="",x.current=null,v.current=0,b.current=0,u({key:"",status:"idle"})};m.useEffect(()=>()=>{var X,V;T();try{(X=_.current)==null||X.disconnect()}catch{}try{(V=h.current)==null||V.close()}catch{}h.current=null,_.current=null,x.current=null},[]);const M=async(X,V,J)=>{const k=j();if(!k)throw new Error("TTS playback is not supported in this browser");const{ctx:z,gain:F}=k;try{z.state==="suspended"&&await z.resume()}catch{}S();const N=z.createBufferSource();N.buffer=V,N.connect(F);const B=Number.isFinite(Number(V.duration))?Number(V.duration):0,Z=Math.max(0,Math.min(Number(J||0),B>0?Math.max(0,B-.01):0));b.current=z.currentTime-Z,v.current=Z,g.current=N,c.current=X,N.onended=()=>{g.current===N&&(g.current=null,v.current=0,b.current=0,c.current="",u({key:"",status:"idle"}))},N.start(0,Z),u({key:X,status:"playing"})},D=async(X,V)=>{const J=String(X||"").trim(),k=String(V||"").trim();if(!J||!k)return;const z=e.gateway,F=String(e.run_id||"").trim();if(!z){t==null||t("Connect to the gateway first.");return}if(!F){t==null||t("Voice store not available (missing run_id).");return}const N=j();if(!N){t==null||t("TTS playback is not supported in this browser.");return}const B=l.key===J;if(B&&l.status==="playing"){const Z=Math.max(0,N.ctx.currentTime-Number(b.current||0));v.current=Z,S(),u({key:J,status:"paused"});return}if(B&&l.status==="paused"){const Z=x.current;if(Z){t==null||t("");try{await M(J,Z,v.current)}catch(te){t==null||t(String((te==null?void 0:te.message)||te||"TTS play failed")),u({key:"",status:"idle"})}return}}if(!(B&&l.status==="loading")){S(),x.current=null,v.current=0,b.current=0,c.current=J,d.current=J,u({key:J,status:"loading"}),t==null||t("");try{const Z=await z.voice_tts(F,{text:k,request_id:Xr()}),te=Z==null?void 0:Z.audio_artifact,he=te&&typeof te=="object"&&!Array.isArray(te)?String(te.$artifact||"").trim():"";if(!he)throw new Error("TTS failed: missing audio artifact");const se=await(await z.download_run_artifact_content(F,he)).arrayBuffer();if(d.current!==J)return;const ve=await pw(N.ctx,se);if(d.current!==J)return;x.current=ve,v.current=0,await M(J,ve,0)}catch(Z){d.current===J&&(d.current="",c.current="",u({key:"",status:"idle"})),t==null||t(String((Z==null?void 0:Z.message)||Z||"TTS failed"))}}},[L,I]=m.useState(!1),[G,ne]=m.useState(!1),Y=m.useRef(null),oe=m.useRef(null),le=m.useRef([]),_e=m.useRef("");function Te(){var X,V;try{(V=(X=Y.current)==null?void 0:X.getTracks)==null||V.call(X).forEach(J=>{try{J.stop()}catch{}})}catch{}Y.current=null}m.useEffect(()=>()=>{var X,V;try{(V=(X=oe.current)==null?void 0:X.stop)==null||V.call(X)}catch{}oe.current=null,Te()},[]);async function $e(X,V){var F;if(t==null||t(""),!X||!X.size||G)return;const J=e.gateway,k=String(e.session_id||"").trim(),z=String(e.run_id||"").trim();if(!J){t==null||t("Connect to the gateway first.");return}if(!k){t==null||t("Voice input unavailable (missing session_id).");return}if(!z){t==null||t("Voice input unavailable (missing run_id).");return}ne(!0);try{const N=String(V||X.type||"").toLowerCase(),B=N.includes("mp4")?"m4a":N.includes("ogg")?"ogg":N.includes("wav")?"wav":"webm",Z=new File([X],`recording.${B}`,{type:N||"audio/webm"}),te=await J.attachments_upload(k,Z,{filename:Z.name,content_type:Z.type}),he=await J.audio_transcribe(z,{audio_artifact:te,request_id:Xr()}),Ae=String((he==null?void 0:he.text)||"").trim();Ae&&((F=e.on_transcript)==null||F.call(e,Ae))}catch(N){t==null||t(String((N==null?void 0:N.message)||N||"Transcription failed"))}finally{ne(!1)}}async function K(){if(t==null||t(""),!o){t==null||t("Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(!G&&!(L||oe.current)){le.current=[];try{const X=await navigator.mediaDevices.getUserMedia({audio:!0});Y.current=X;const V=hw();_e.current=V;const J=V?new MediaRecorder(X,{mimeType:V}):new MediaRecorder(X);oe.current=J,J.ondataavailable=k=>{try{k!=null&&k.data&&le.current.push(k.data)}catch{}},J.onerror=()=>{t==null||t("Recording failed.")},J.onstop=()=>{I(!1),Te(),oe.current=null;try{const k=new Blob(le.current,{type:_e.current||""});$e(k,_e.current)}catch(k){t==null||t(String((k==null?void 0:k.message)||k||"Failed to build recording"))}},J.start(),I(!0)}catch(X){Te(),oe.current=null,I(!1);const V=String((X==null?void 0:X.message)||X||"Failed to access microphone");t==null||t(V.toLowerCase().includes("permission")?`Microphone permission denied: ${V}`:V)}}}function U(){const X=oe.current;if(!(!L||!X)){oe.current=null,I(!1);try{X.stop()}catch(V){t==null||t(String((V==null?void 0:V.message)||V||"Failed to stop recording"))}}}return m.useEffect(()=>{if(!L)return;const X=()=>U();return window.addEventListener("pointerup",X),window.addEventListener("pointercancel",X),()=>{window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X)}},[L]),{tts_supported:r,tts_playback:l,toggle_tts:D,stop_tts:T,voice_ptt_supported:o,voice_ptt_recording:L,voice_ptt_busy:G,start_voice_ptt_recording:K,stop_voice_ptt_recording:U}}function tm(e,t){const r=String(e||"").replace(/\r/g,"").trim();if(!r)return"";const l=(r.split(`
|
|
70
|
+
`,1)[0]||"").trim();return l.length<=t?l:`${l.slice(0,Math.max(0,t-1))}…`}function gw(e){const t=String(e||"").trim();if(t.length<2)return t;const r=t[0],o=t[t.length-1];return r==="'"&&o==="'"||r==='"'&&o==='"'?t.slice(1,-1):t}function v_(e){const t=String(e||"").trim();if(!t)return"";const r=t.match(/^(?:\/bin\/)?(?:zsh|bash)\s+-lc\s+([\s\S]+)$/);return r?gw(String(r[1]||"").trim()):t}function _w(e,t){const r=String(e||"").trim().toLowerCase();if(r==="error"||r==="turn.failed")return"error";if(r==="turn.completed"||r==="turn.succeeded"||r==="turn.success")return"ok";const o=t&&typeof t=="object"?t:null,l=o&&typeof o.item=="object"?o.item:null;if(l&&String(l.type||"").trim()==="command_execution"){const u=String(l.status||"").trim().toLowerCase();if(u==="failed")return"error";const c=l.exit_code,d=typeof c=="number"?c:Number.isFinite(Number(c))?Number(c):null;if(d!=null)return d===0?"ok":"error";if(u==="completed")return"ok"}return"info"}function yw(e,t){var _;const r=t&&typeof t=="object"?t:{},o=r.item&&typeof r.item=="object"?r.item:null,l=o?String(o.type||"").trim():"",u=o?String(o.text||"").trim():"",c=o?String(o.command||"").trim():"",d=o&&Array.isArray(o.items)?o.items:[],h=String((r==null?void 0:r.message)||((_=r==null?void 0:r.error)==null?void 0:_.message)||"").trim();if(l==="command_execution"&&c)return v_(c)||c;if(l==="todo_list"&&d.length>0){const g=d.length,x=d.filter(M=>(M&&M.completed)===!0).length,v=d.find(M=>(M&&M.completed)!==!0),b=String((v==null?void 0:v.text)||"").trim(),j=g>1?` (+${g-1})`:"",S=g>0?` (${x}/${g})`:"",T=b?`todo: ${b}${j}`:`todo list (${g})`;return tm(`${T}${S}`,96)}return u?tm(u,96)||u:h?tm(h,96)||h:l||String(e||"").trim()||"event"}function Rp(e){const t=new Date(e),r=o=>String(o).padStart(2,"0");return`${r(t.getHours())}:${r(t.getMinutes())}`}function xw(e){var o,l,u;const t=e&&typeof e=="object"?e:{},r=[t.at,t.created_at,t.timestamp,t.time,t.ts,t.datetime,(o=t.item)==null?void 0:o.at,(l=t.item)==null?void 0:l.created_at,(u=t.item)==null?void 0:u.timestamp];for(const c of r)if(c!=null){if(typeof c=="number"&&Number.isFinite(c)){const d=c>1e11?c:c*1e3;return Rp(d)}if(typeof c=="string"){const d=c.trim();if(!d)continue;const h=Date.parse(d.replace(/(\.\d{3})\d+/,"$1"));if(Number.isFinite(h))return Rp(h)}}return null}function Lp(e){const t=Array.from(new Set(e.map(r=>String(r||"").trim()).filter(Boolean)));return t.sort((r,o)=>r.localeCompare(o)),t}function w_(e){const t=e.disabled===!0,r=m.useMemo(()=>Lp(e.options||[]),[e.options]),o=m.useMemo(()=>Lp(e.value||[]),[e.value]),[l,u]=m.useState(!1),[c,d]=m.useState(""),h=m.useMemo(()=>{const x=c.trim().toLowerCase();return x?r.filter(v=>v.toLowerCase().includes(x)):r},[r,c]),_=m.useMemo(()=>new Set(o),[o]),g=typeof e.max_list_height_px=="number"?e.max_list_height_px:220;return s.jsxs("div",{className:"multi_select",children:[s.jsxs("div",{className:"multi_select_row",children:[s.jsxs("button",{className:"btn",type:"button",onClick:()=>u(x=>!x),disabled:t||!r.length,"aria-expanded":l,children:[l?"Hide":"Select"," • ",o.length>0?`${o.length} of ${r.length}`:e.placeholder||"(none)"]}),s.jsx("button",{className:"btn",type:"button",onClick:()=>e.onChange(r.slice()),disabled:t||!r.length||o.length===r.length,title:"Select all",children:"All"}),s.jsx("button",{className:"btn",type:"button",onClick:()=>e.onChange([]),disabled:t||o.length===0,title:"Clear selection",children:"Clear"})]}),o.length>0?s.jsx("div",{className:"multi_select_chips",children:o.map(x=>s.jsxs("span",{className:"multi_select_chip",title:x,onClick:()=>{if(t)return;const v=new Set(_);v.delete(x),e.onChange(Array.from(v.values()))},children:[x,t?null:s.jsx("span",{className:"multi_select_chip_x",children:"×"})]},x))}):null,l?s.jsxs("div",{className:"multi_select_panel",children:[s.jsx("input",{className:"mono",value:c,onChange:x=>d(String(x.target.value||"")),placeholder:"filter…",disabled:t}),s.jsxs("div",{className:"multi_select_list",style:{maxHeight:`${g}px`},children:[h.map(x=>{const v=_.has(x);return s.jsxs("label",{className:`multi_select_item mono ${v?"checked":""}`,children:[s.jsx("input",{type:"checkbox",checked:v,disabled:t,onChange:b=>{const j=new Set(_);b.target.checked?j.add(x):j.delete(x),e.onChange(Array.from(j.values()))}}),s.jsx("span",{children:x})]},x)}),h.length?null:s.jsx("div",{className:"mono muted",children:"(no matches)"})]})]}):null]})}function Mi({open:e,title:t,children:r,actions:o,variant:l="default",onClose:u}){if(m.useEffect(()=>{if(!e)return;const d=h=>{h.key==="Escape"&&u()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e,u]),!e)return null;const c=l==="fullscreen";return s.jsx("div",{className:`modal_backdrop${c?" fullscreen":""}`,onMouseDown:d=>{d.target===d.currentTarget&&u()},children:s.jsxs("div",{className:`modal_panel${c?" fullscreen":""}`,children:[s.jsxs("div",{className:"modal_header",children:[s.jsx("div",{className:"modal_title",children:t}),s.jsx("button",{className:"btn",onClick:u,children:"Close"})]}),s.jsx("div",{className:"modal_body",children:r}),o?s.jsx("div",{className:"modal_footer",children:o}):null]})})}function ia(e){return e!=="processing"&&e!=="failed"}function Pu(e){const t=String(e||"").trim().toLowerCase();return t==="bug"||t==="feature"||t==="task"?t:"task"}function b_(e){return e.toUpperCase()}function Pp(e){return e==="bug"?"danger":e==="feature"?"ok":"task"}function S_(e){const t=String(e||"").trim();return t.replace(/^\[(bug|feature|task)\]\s*/i,"").trim()||t}function oa(e,t){const r=String(e||"");return r.length<=t?r:`${r.slice(0,Math.max(0,t-1))}…`}function nm(e){return typeof(e==null?void 0:e.parsed)=="boolean"?!!e.parsed:typeof e.item_id=="number"&&e.item_id>0}function vw(e){const t=String((e==null?void 0:e.package)||"").trim();if(t)return t;const o=String((e==null?void 0:e.filename)||"").trim().split("-");return o.length>=2?String(o[1]||"").trim():""}function Mm(e=new Date){const t=d=>String(d).padStart(2,"0"),r=-e.getTimezoneOffset(),o=r>=0?"+":"-",l=Math.abs(r),u=t(Math.floor(l/60)),c=t(l%60);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())} ${o}${u}${c}`}function ww(e){try{return JSON.parse(e)}catch{return null}}function Ip(e,t){return e.scrollHeight-e.scrollTop-e.clientHeight<=t}function bw(e){const t=String(e||"").replace(/\r/g,"").trim();if(!t)return"";const r=t.split(`
|
|
71
|
+
`),o=[];for(const l of r){const u=String(l||"");if(!u.trim()){if(o.length)break;continue}if(o.push(u),o.length>=6)break}return o.join(`
|
|
72
|
+
`).trim()}function rm(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const r=t.replace(/(\.\d{3})\d+/,"$1"),o=Date.parse(r);return Number.isFinite(o)?o:null}function Cd(e){if(!Number.isFinite(e))return"";const t=Math.max(0,Math.floor(e/1e3)),r=t%60,o=Math.floor(t/60),l=o%60,u=Math.floor(o/60),c=u%24,d=Math.floor(u/24);return d>0?`${d}d ${c}h`:u>0?`${u}h ${l}m`:o>0?`${o}m ${r}s`:`${t}s`}async function zm(e){const t=String(e||""),r=new TextEncoder().encode(t),o=globalThis.crypto;if(!o||!o.subtle||typeof o.subtle.digest!="function")return"";const l=await o.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(l)).map(u=>u.toString(16).padStart(2,"0")).join("")}const Sw=/^[a-zA-Z0-9_-]+$/;function Fp(e){return Sw.test(String(e||"").trim())}async function jw(e){const t=String(e).trim();if(!t)throw new Error("session_id is required");if(Fp(t)){const o=`session_memory_${t}`;if(Fp(o))return o}return`session_memory_sha_${(await zm(t)).slice(0,32)}`}function kw(e){const t=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches,[r,o]=m.useState(t);return m.useEffect(()=>{var c;if(typeof window>"u"||typeof window.matchMedia!="function")return;const l=window.matchMedia(e),u=()=>o(l.matches);return u(),typeof l.addEventListener=="function"?l.addEventListener("change",u):(c=l.addListener)==null||c.call(l,u),()=>{var d;typeof l.removeEventListener=="function"?l.removeEventListener("change",u):(d=l.removeListener)==null||d.call(l,u)}},[e]),r}function Nw(e,t){const r=String(t.package_name).trim()||"{Package}",o=S_(String(t.title||"").trim()||"{Title}"),l=String(t.summary||"").trim(),u=Pu(t.task_type),c=`# {ID}-${r}: [${b_(u)}] ${o}`.trim();let d=String(e||"");d=d.split("{Package}").join(r).split("{Title}").join(o);const h=d.split(/\r?\n/);let _=!1;for(let j=0;j<h.length;j+=1){const S=String(h[j]||"");if(S.trim().startsWith("# ")){h[j]=c,_=!0;break}if(S.trim())break}_||(h.unshift("",c),h.shift());const g=`> Created: ${String(t.created_at||"").trim()}`.trim();let x=!1;for(let j=0;j<Math.min(h.length,40);j+=1)if(String(h[j]||"").trim().toLowerCase().startsWith("> created:")){h[j]=g,x=!0;break}if(!x){const j=h.length>1&&!String(h[1]||"").trim()?2:1;h.splice(j,0,g,"")}const v=`> Type: ${u}`.trim();let b=!1;for(let j=0;j<Math.min(h.length,60);j+=1)if(String(h[j]||"").trim().toLowerCase().startsWith("> type:")){h[j]=v,b=!0;break}if(!b){let j=-1;for(let S=0;S<Math.min(h.length,60);S+=1)if(String(h[S]||"").trim().toLowerCase().startsWith("> created:")){j=S;break}if(j>=0){const S=j+1;S<h.length&&!String(h[S]||"").trim()?h.splice(S,0,v):h.splice(S,0,v,"")}else{const S=h.length>1&&!String(h[1]||"").trim()?2:1;h.splice(S,0,v,"")}}if(l){for(let j=0;j<h.length;j+=1)if(String(h[j]||"").trim().toLowerCase()==="## summary"){let S=j+1;for(;S<h.length&&!String(h[S]||"").trim();)S+=1;(S<h.length?String(h[S]||""):"").trim().toLowerCase().startsWith("one paragraph describing")?h[S]=l:h.splice(j+1,0,l,"");break}}return d=h.join(`
|
|
73
|
+
`),d.endsWith(`
|
|
74
|
+
`)||(d+=`
|
|
75
|
+
`),d}function al(e){return String(e||"").split(/\r?\n/).map(t=>t.trim()).filter(Boolean)}function Cw(e){const t=String(e.package_name||"").trim()||"{Package}",r=S_(String(e.title||"").trim()||"{Title}"),o=Pu(e.task_type),l=String(e.created_at||"").trim()||Mm(),u=String(e.diagram||"").trim(),c=String(e.context||"").trim(),d=[];return d.push(`# {ID}-${t}: [${b_(o)}] ${r}`),d.push(""),d.push(`> Created: ${l}`),d.push(`> Type: ${o}`),d.push(""),d.push("## Summary"),d.push(e.summary.trim()||"One paragraph describing what this task accomplishes (user value + outcome)."),d.push(""),d.push("## Diagram"),d.push("```"),d.push(u||`ASCII diagram of the system change.
|
|
76
|
+
Show inputs/outputs and where code lives.`),d.push("```"),d.push(""),d.push("## Context"),d.push(c||"(why is this needed? link to evidence: bug/feature report paths, discussions, etc.)"),d.push(""),d.push("## Scope"),d.push("### Included"),e.included.length?d.push(...e.included.map(h=>`- ${h}`)):d.push("- "),d.push(""),d.push("### Excluded"),e.excluded.length?d.push(...e.excluded.map(h=>`- ${h}`)):d.push("- "),d.push(""),d.push("## Implementation Plan"),e.plan.length?d.push(...e.plan.map((h,_)=>`${_+1}. ${h}`)):d.push("1. "),d.push(""),d.push("## Dependencies"),e.dependencies.length?d.push(...e.dependencies.map(h=>`- ${h}`)):d.push("- Related backlog items / ADRs"),d.push(""),d.push("## Acceptance Criteria"),e.acceptance.length?d.push(...e.acceptance.map(h=>`- [ ] ${h}`)):d.push("- [ ] Criterion 1 (clear, testable)"),d.push(""),d.push("## Testing (ADR-0019)"),d.push("- Level A:"),e.tests_a.length?d.push(...e.tests_a.map(h=>` - \`${h}\``)):d.push(" - `...`"),d.push("- Level B:"),e.tests_b.length?d.push(...e.tests_b.map(h=>` - \`${h}\``)):d.push(" - `...`"),d.push("- Level C (optional / opt-in):"),e.tests_c.length?d.push(...e.tests_c.map(h=>` - \`${h}\``)):d.push(" - n/a"),d.push(""),d.push("## Related"),d.push("- ADRs:"),d.push("- Code:"),d.push("- Reports:"),e.attachments.length&&(d.push("- Attachments:"),d.push(...e.attachments.map(h=>` - ${h}`))),d.push(""),d.push("---"),d.push("## Report (added when completed)"),d.push(""),d.push("> Completed: YYYY-MM-DD"),d.push(""),d.push("### What changed"),d.push("- "),d.push(""),d.push("### Security / hardening"),d.push("- "),d.push(""),d.push("### Testing (ADR-0019)"),d.push("Levels executed:"),d.push("- A:"),d.push("- B:"),d.push("- C (if any):"),d.push(""),d.push("Commands run:"),d.push("- `...`"),d.push(""),d.push("### Follow-ups"),d.push("- "),d.push(""),d.join(`
|
|
77
|
+
`)}function Op(e,t){const r=t.map(h=>String(h||"").trim()).filter(Boolean);if(!r.length)return e;const o=String(e||"").split(/\r?\n/),l=o.map(h=>h.toLowerCase()),u=l.findIndex(h=>h.trim()==="## related");if(u<0)return`${String(e||"").trimEnd()}
|
|
78
|
+
|
|
79
|
+
## Related
|
|
80
|
+
- Attachments:
|
|
81
|
+
${r.map(_=>` - ${_}`).join(`
|
|
82
|
+
`)}
|
|
83
|
+
`;let c=-1;for(let h=u+1;h<o.length;h+=1){const _=l[h].trim();if(_.startsWith("## ")||_.startsWith("---"))break;if(_.startsWith("- attachments:")){c=h;break}}const d=["- Attachments:",...r.map(h=>` - ${h}`)];if(c>=0){let h=c+1;for(;h<o.length&&l[h].trim().startsWith(" -");)h+=1;o.splice(h,0,...r.map(_=>` - ${_}`))}else{let h=u+1;for(let _=u+1;_<o.length;_+=1){const g=l[_].trim();if(g.startsWith("## ")||g.startsWith("---")){h=_;break}h=_+1}o.splice(h,0,...d,"")}return o.join(`
|
|
84
|
+
`)}function Ew(e){var Al;const t=e.gateway,r=e.gateway_connected,o=String(e.maintenance_ai_provider||"").trim(),l=String(e.maintenance_ai_model||"").trim(),u=String(e.backlog_advisor_agent||"").trim(),[c,d]=m.useState("planned"),h=kw("(max-width: 900px)"),[_,g]=m.useState("list"),[x,v]=m.useState([]),[b,j]=m.useState(!1),[S,T]=m.useState(""),[M,D]=m.useState([]),[L,I]=m.useState(""),[G,ne]=m.useState("all"),[Y,oe]=m.useState(null),[le,_e]=m.useState(""),[Te,$e]=m.useState(""),[K,U]=m.useState(!1),[X,V]=m.useState(""),[J,k]=m.useState(!1),[z,F]=m.useState(""),[N,B]=m.useState(!1),[Z,te]=m.useState(""),[he,Ae]=m.useState(!1),[se,ve]=m.useState(""),[Re,Qe]=m.useState([]),[Pe,de]=m.useState(""),[be,Fe]=m.useState(!1),[Xe,tt]=m.useState(""),[ze,Oe]=m.useState(!1),[lt,xe]=m.useState([]),[Et,yt]=m.useState(""),[sn,ln]=m.useState(!1),[Xt,je]=m.useState(""),[ue,Ne]=m.useState(!1),[$t,pt]=m.useState([]),qt=m.useRef(null),Dn=m.useRef(null),nn=String(e.voice_session_id||"").trim()||"abstractobserver_backlog_advisor",[cn,vn]=m.useState(""),[Sn,cr]=m.useState("");m.useEffect(()=>{(async()=>{try{const C=await jw(nn);vn(C)}catch{vn("")}})()},[nn]);const Qt=x_({gateway:r?t:null,session_id:nn,run_id:cn,on_error:cr,on_transcript:C=>{const W=String(C||"").trim();W&&(yt(O=>{const fe=String(O||"");return fe.trim()?`${fe.trimEnd()}
|
|
85
|
+
${W}`:W}),window.setTimeout(()=>{var O;return(O=qt.current)==null?void 0:O.focus()},0))}}),Zn=m.useRef(null),[ls,Un]=m.useState(!1),[me,ke]=m.useState(""),[ct,it]=m.useState([]),[bt,zt]=m.useState(!1),[Ut,Ot]=m.useState(null),[pn,It]=m.useState("uat"),[_n,un]=m.useState([]),[Gt,Zt]=m.useState(!1),[Vt,rt]=m.useState(!1),[jn,Rn]=m.useState(""),[kn,Nn]=m.useState("uat"),[ar,Ir]=m.useState(!1),[Sr,Fr]=m.useState(""),[Ws,Es]=m.useState("framework"),[lo,Ri]=m.useState("task"),[cs,En]=m.useState(""),[us,Jr]=m.useState(!1),[Or,mr]=m.useState(""),[st,St]=m.useState(null),[dn,Dr]=m.useState(!1),[jr,kr]=m.useState(""),[hr,Io]=m.useState([]),[Hs,Bn]=m.useState(!1),[ur,dr]=m.useState(""),[Me,Gn]=m.useState(null),[Ge,Yn]=m.useState(null),[er,pr]=m.useState(!1),[Nr,Cr]=m.useState(""),[Li,rn]=m.useState(""),[Er,Vs]=m.useState(!1),[$s,tr]=m.useState(""),[fr,gi]=m.useState("events"),[Ln,Br]=m.useState(""),[$r,Qr]=m.useState(!1),[Ur,As]=m.useState(""),[Zr,es]=m.useState(!1),[gr,Pi]=m.useState(!0),Wr=m.useRef(null),Ii=m.useRef(!0),[Fi,Ts]=m.useState(!1),[Oi,ua]=m.useState(""),[Ms,qs]=m.useState([]),[Hr,zs]=m.useState(""),[Di,Fo]=m.useState("events"),[Ar,R]=m.useState(""),[ie,Ce]=m.useState(!1),[Ie,De]=m.useState(""),[at,At]=m.useState(!1),[Rt,Lt]=m.useState(""),Kt=m.useRef(null),[nt,yn]=m.useState("tasks"),[en,fn]=m.useState(!1),[or,An]=m.useState(""),[Tr,bs]=m.useState(!1),[_i,Rs]=m.useState(""),[co,yl]=m.useState("proposed"),[uo,fo]=m.useState("feature"),[mo,Ia]=m.useState("framework"),[Gs,ec]=m.useState(""),[ho,xl]=m.useState(""),[Oo,da]=m.useState(""),[po,Bi]=m.useState(""),[Ls,vl]=m.useState(!1),[fa,go]=m.useState(""),[_o,yo]=m.useState(""),[Do,ma]=m.useState(""),[Fa,wl]=m.useState(""),[Bo,bl]=m.useState(""),[Ui,yi]=m.useState(""),[tc,Oa]=m.useState(""),[Sl,jl]=m.useState(""),[Uo,Ys]=m.useState(""),[Ps,nc]=m.useState(""),[Wo,kl]=m.useState([]),[ha,Wi]=m.useState(!1),[Mr,ds]=m.useState(""),[pa,ri]=m.useState([]),[ga,Hi]=m.useState(""),[fs,Vi]=m.useState(!1),Cn=c==="processing"||c==="failed"||c==="completed"&&nt==="runs";m.useEffect(()=>{h&&g("list")},[h,c,nt]),m.useEffect(()=>{if(!ze)return;const C=W=>{W.key==="Escape"&&Oe(!1)};return window.addEventListener("keydown",C),setTimeout(()=>{var W;return(W=qt.current)==null?void 0:W.focus()},0),()=>window.removeEventListener("keydown",C)},[ze]);const ts=m.useMemo(()=>{if(fr!=="events")return null;const C=String(Ln||""),W=C.split(/\r?\n/).filter(Se=>String(Se||"").trim().length>0),O=[];let fe=0;for(let Se=0;Se<W.length;Se+=1){const et=String(W[Se]||"").trim(),Ye=ww(et);if(!Ye||typeof Ye!="object"){fe+=1,O.push({idx:Se,type:"raw",payload:null,raw:et});continue}const Ze=String(Ye.type||Ye.event||"event");O.push({idx:Se,type:Ze,payload:Ye,raw:et})}return{total:W.length,bad:fe,events:O,raw:C}},[Ln,fr]),lr=m.useMemo(()=>{if(!ts)return null;let C=0,W=0,O=0,fe=0,Se=0;for(const Ye of ts.events){const Ze=Ye.payload,He=Ze&&typeof Ze.usage=="object"?Ze.usage:null;He&&(Number.isFinite(Number(He.input_tokens))&&(C+=Number(He.input_tokens)),Number.isFinite(Number(He.cached_input_tokens))&&(W+=Number(He.cached_input_tokens)),Number.isFinite(Number(He.output_tokens))&&(O+=Number(He.output_tokens)));const Wt=Ze&&typeof Ze.item=="object"?Ze.item:null;Wt&&String(Wt.type||"").trim()==="command_execution"&&(fe+=1,String(Wt.status||"").trim().toLowerCase()==="failed"&&(Se+=1))}return{has_tokens:C>0||O>0||W>0,input_tokens:C,cached_input_tokens:W,output_tokens:O,total_tokens:C+O,command_count:fe,command_fail_count:Se}},[ts]),nr=m.useMemo(()=>{const C=rm(Me==null?void 0:Me.created_at),W=rm(Me==null?void 0:Me.started_at),O=rm(Me==null?void 0:Me.finished_at),fe=Date.now(),Se=String((Me==null?void 0:Me.status)||"").trim().toLowerCase(),et=O??(Se==="running"?fe:null),Ye=O!=null,Ze=C!=null&&W!=null?Math.max(0,W-C):null,He=W!=null&&et!=null?Math.max(0,et-W):null,Wt=C!=null&&et!=null?Math.max(0,et-C):null,xn=!Ye&&C!=null?Math.max(0,fe-C):null;return{is_done:Ye,queue_delay_ms:Ze,run_ms:He,total_ms:Wt,age_ms:xn}},[Me==null?void 0:Me.created_at,Me==null?void 0:Me.started_at,Me==null?void 0:Me.finished_at,Me==null?void 0:Me.status]);function xo(C){return C==="processing"?"queued,running,awaiting_qa":C==="failed"?"failed":C==="completed"&&nt==="runs"?"completed,promoted":""}function si(C,W){const O=C&&typeof C=="object"?C:{},fe=O.backlog&&typeof O.backlog=="object"?O.backlog:{},Se=O.result&&typeof O.result=="object"?O.result:{},et=O.executor&&typeof O.executor=="object"?O.executor:{},Ye=String(Se.last_message||"").trim(),Ze=String(O.target_model||et.model||"").trim(),He=String(O.target_reasoning_effort||et.reasoning_effort||"").trim();return{request_id:W,status:String(O.status||"unknown"),created_at:O.created_at??null,started_at:O.started_at??null,finished_at:O.finished_at??null,backlog_relpath:fe.relpath??null,backlog_kind:fe.kind??null,backlog_filename:fe.filename??null,target_agent:O.target_agent??null,target_model:Ze||null,target_reasoning_effort:He||null,executor_type:et.type??null,ok:typeof Se.ok=="boolean"?Se.ok:null,exit_code:typeof Se.exit_code=="number"?Se.exit_code:Se.exit_code??null,error:typeof Se.error=="string"?Se.error:Se.error??null,run_dir_relpath:O.run_dir_relpath??null,last_message:Ye?Ye.slice(0,1200):null}}async function vo(C){const W=C||(ia(c)?c:"planned"),O=await t.backlog_list(W);let fe=Array.isArray(O==null?void 0:O.items)?O.items:[];if(W==="planned")try{const Se=await t.backlog_exec_active_items({status:"queued,running,awaiting_qa",limit:1200}),et=Array.isArray(Se==null?void 0:Se.items)?Se.items:[],Ye=new Set(et.filter(He=>String((He==null?void 0:He.kind)||"").trim()==="planned").map(He=>String((He==null?void 0:He.filename)||"").trim()).filter(Boolean)),Ze=Array.from(Ye);Ze.sort(),D(Ze),Ye.size&&(fe=fe.filter(He=>!Ye.has(String(He.filename||"").trim())))}catch{D([])}else D([]);return v(fe),Y&&C===void 0&&!fe.some(Se=>Se.filename===Y.filename)&&(oe(null),_e(""),$e(""),V(""),B(!1),te(""),ve("")),fe}async function ms(C){if(Hs)return hr;dr(""),Bn(!0);const W=C||c;try{const O=xo(W),fe=await t.backlog_exec_requests({status:O,limit:200}),Se=Array.isArray(fe==null?void 0:fe.requests)?fe.requests:[];if(Io(Se),W==="processing"&&(Me!=null&&Me.request_id)&&!Se.some(et=>et.request_id===Me.request_id))try{const et=await t.backlog_exec_request(Me.request_id),Ye=et==null?void 0:et.payload,Ze=String((Ye==null?void 0:Ye.status)||"").trim().toLowerCase();Ze==="failed"?d("failed"):(Ze==="completed"||Ze==="promoted")&&(yn("runs"),d("completed")),(Ze==="failed"||Ze==="completed"||Ze==="promoted")&&(Yn(Ye),Gn(si(Ye,Me.request_id)))}catch{}if(Me!=null&&Me.request_id){const et=Se.find(Ye=>Ye.request_id===Me.request_id)||null;et&&Gn(et)}return Se}catch(O){return Io([]),dr(String((O==null?void 0:O.message)||O||"Failed to load backlog exec requests")),[]}finally{Bn(!1)}}async function ns(){if(r){if(Cn){await ms();return}if(!b){T(""),j(!0);try{await vo()}catch(C){v([]),T(String((C==null?void 0:C.message)||C||"Failed to load backlog list"))}finally{j(!1)}}}}m.useEffect(()=>{ns()},[c,nt,r]),m.useEffect(()=>{if(c!=="planned"){un([]);return}const C=new Set(x.map(W=>String(W.filename||"").trim()).filter(Boolean));un(W=>W.filter(O=>C.has(O)))},[c,x]),m.useEffect(()=>{en&&r&&Nl()},[en,r]),m.useEffect(()=>{bt&&r&&Ho()},[bt,r]),m.useEffect(()=>{Gt&&r&&Ho()},[Gt,r]),m.useEffect(()=>{r&&Cn&&Ho()},[Cn,r]),m.useEffect(()=>{if(!r||!Cn)return;const W=setInterval(()=>void ms(c),c==="processing"?2e3:5e3);return()=>clearInterval(W)},[c,nt,r,Cn,Me==null?void 0:Me.request_id]),m.useEffect(()=>{r&&Cn&&Me!=null&&Me.request_id&&gn({request_id:Me.request_id,name:fr})},[Me==null?void 0:Me.request_id,fr,Cn,r]),m.useEffect(()=>{Ii.current=!0},[Me==null?void 0:Me.request_id,fr]),m.useEffect(()=>{if(!Wr.current||!Ii.current)return;const W=window.requestAnimationFrame(()=>{const O=Wr.current;O&&(O.scrollTop=O.scrollHeight)});return()=>window.cancelAnimationFrame(W)},[Ln,fr,Me==null?void 0:Me.request_id]),m.useEffect(()=>{if(!r||!Cn||!(Me!=null&&Me.request_id))return;const C=String(Me.status||"").trim().toLowerCase();if(C!=="running"&&gr!==!0)return;const O=setInterval(()=>{gn({request_id:Me.request_id,name:fr})},C==="running"?1500:2500);return()=>clearInterval(O)},[Me==null?void 0:Me.request_id,Me==null?void 0:Me.status,fr,Cn,r,gr]),m.useEffect(()=>{g("list"),Cn?Y&&(oe(null),_e(""),$e(""),V(""),B(!1),te(""),ve(""),Qe([]),de(""),Fe(!1),tt(""),Un(!1),ke(""),it([])):Me&&(Gn(null),Yn(null),Cr(""),Br(""),As(""),es(!1))},[Cn]);async function Xs(C,W){const O=(W==null?void 0:W.kind)||(ia(c)?c:"planned");oe(C),h&&g("detail"),B(!1),te(""),ve(""),Qe([]),de(""),Fe(!1),tt(""),Un(!1),ke(""),it([]),F(""),_e(""),$e(""),V(""),U(!0);try{const fe=await t.backlog_content(O,C.filename),Se=String((fe==null?void 0:fe.content)||"");_e(Se),$e(await zm(Se))}catch(fe){V(String((fe==null?void 0:fe.message)||fe||"Failed to load backlog item"))}finally{U(!1)}}const hs=m.useMemo(()=>{const C=String(L||"").trim().toLowerCase(),W=String(G||"all").trim().toLowerCase();return x.filter(O=>W&&W!=="all"&&Pu(O.task_type)!==W?!1:C?`${O.item_id||""} ${O.package||""} ${O.title||""} ${O.task_type||""} ${O.summary||""} ${O.filename||""}`.toLowerCase().includes(C):!0)},[x,L,G]),Vn=m.useMemo(()=>{if(c!=="planned")return[];const C=new Set(_n.map(O=>String(O||"").trim()).filter(Boolean)),W=x.filter(O=>C.has(String(O.filename||"").trim()));return W.sort((O,fe)=>String(O.filename||"").localeCompare(String(fe.filename||""))),W},[x,_n,c]),ps=m.useMemo(()=>{const C=String(L||"").trim().toLowerCase();return C?hr.filter(W=>`${W.request_id||""} ${W.status||""} ${W.backlog_filename||""} ${W.backlog_relpath||""} ${W.target_model||""} ${W.target_reasoning_effort||""} ${W.error||""} ${W.last_message||""}`.toLowerCase().includes(C)):hr},[hr,L]);async function xi(C){if(Y&&ia(c)&&!J){F(""),k(!0);try{await t.backlog_move({from_kind:c,to_kind:C,filename:Y.filename}),d(C),I("");const O=(await vo(C)).find(fe=>fe.filename===Y.filename)||null;oe(O),_e(""),$e(""),V(""),O&&await Xs(O,{kind:C})}catch(W){F(String((W==null?void 0:W.message)||W||"Backlog move failed"))}finally{k(!1)}}}async function _a(){if(Y&&ia(c)&&!he){ve(""),Ae(!0);try{const C=await t.backlog_update({kind:c,filename:Y.filename,content:Z,expected_sha256:Te||null}),W=Z.endsWith(`
|
|
86
|
+
`)?Z:`${Z}
|
|
87
|
+
`;_e(W),$e(String((C==null?void 0:C.sha256)||"")),B(!1),await ns()}catch(C){ve(String((C==null?void 0:C.message)||C||"Save failed"))}finally{Ae(!1)}}}async function Ho(){if(!r)return null;if(dn)return st;kr(""),Dr(!0);try{const C=await t.backlog_exec_config();return St(C),C}catch(C){const W=String((C==null?void 0:C.message)||C||"Failed to load backlog exec config");return kr(W),St(null),null}finally{Dr(!1)}}async function qi(C){if(r){Gn(C),h&&g("detail"),Yn(null),Cr(""),pr(!0),tr(""),rn(""),Br(""),As(""),es(!1);try{const W=await t.backlog_exec_request(C.request_id);Yn((W==null?void 0:W.payload)??null)}catch(W){Cr(String((W==null?void 0:W.message)||W||"Failed to load request"))}finally{pr(!1)}}}async function jt(){if(!r)return;const C=String((Me==null?void 0:Me.request_id)||"").trim();if(!C||Er)return;const W=String(Li||"");if(!W.trim()){tr("Feedback is required.");return}tr(""),Vs(!0);try{const O=await t.backlog_exec_feedback({request_id:C,feedback:W}),fe=(O==null?void 0:O.payload)??null;Yn(fe),fe&&Gn(si(fe,C)),rn(""),d("processing"),await ms("processing")}catch(O){tr(String((O==null?void 0:O.message)||O||"Failed to send feedback"))}finally{Vs(!1)}}async function ya(){if(!r)return;const C=String((Me==null?void 0:Me.request_id)||"").trim();if(C&&!Er){tr(""),Vs(!0);try{const W=await t.backlog_exec_promote({request_id:C,redeploy:!0}),O=(W==null?void 0:W.payload)??null;Yn(O),O&&Gn(si(O,C)),rn(""),yn("runs"),d("completed"),await ms("completed"),await ms("processing")}catch(W){tr(String((W==null?void 0:W.message)||W||"Failed to promote to prod"));try{const O=await t.backlog_exec_request(C),fe=(O==null?void 0:O.payload)??null;Yn(fe),fe&&Gn(si(fe,C))}catch{}}finally{Vs(!1)}}}async function Vr(){if(!r)return;const C=String((Me==null?void 0:Me.request_id)||"").trim();if(C&&!Er){tr(""),Vs(!0);try{const W=await t.backlog_exec_deploy_uat({request_id:C}),O=(W==null?void 0:W.payload)??null;Yn(O),O&&Gn(si(O,C)),d("processing"),await ms("processing")}catch(W){tr(String((W==null?void 0:W.message)||W||"Failed to deploy to UAT"))}finally{Vs(!1)}}}async function gn(C){if(!r)return;const W=String((C==null?void 0:C.request_id)||(Me==null?void 0:Me.request_id)||"").trim();if(!W)return;const O=(C==null?void 0:C.name)||fr,fe=typeof(C==null?void 0:C.max_bytes)=="number"&&Number.isFinite(C.max_bytes)?Number(C.max_bytes):16e4;if(!$r){As(""),Qr(!0);try{const Se=await t.backlog_exec_log_tail({request_id:W,name:String(O),max_bytes:fe});Br(String((Se==null?void 0:Se.content)||"")),es(!!(Se!=null&&Se.truncated))}catch(Se){As(String((Se==null?void 0:Se.message)||Se||"Failed to load logs"))}finally{Qr(!1)}}}function zr(C){if(!C||typeof C!="object")return"";const W=C.$artifact;return typeof W=="string"?W.trim():""}async function vi(C){var fe;if(!r)return;const W=String((C==null?void 0:C.request_id)||Hr||"").trim();if(!W)return;const O=(C==null?void 0:C.name)||Di;if(!ie){De(""),Ce(!0),At(!1);try{const Se=await t.backlog_exec_request(W),et=Se==null?void 0:Se.payload,Ye=(fe=et==null?void 0:et.result)==null?void 0:fe.ledger,Ze=String((Ye==null?void 0:Ye.ledger_run_id)||"").trim(),He=Ye==null?void 0:Ye.log_artifacts,Wt=He?He[String(O)]:null,xn=zr(Wt);if(Ze&&xn){const Ks=await(await t.download_run_artifact_content(Ze,xn)).text();R(Ks);return}const Fn=await t.backlog_exec_log_tail({request_id:W,name:String(O),max_bytes:4e5});R(String((Fn==null?void 0:Fn.content)||"")),At(!!(Fn!=null&&Fn.truncated)),Fn!=null&&Fn.truncated&&De("Legacy fallback: log is truncated (this exec request predates ledger log capture).")}catch(Se){De(String((Se==null?void 0:Se.message)||Se||"Failed to load execution log"))}finally{Ce(!1)}}}async function wo(C){if(!r)return;const W=String(C||"").trim();if(W){Ts(!0),ua(W),qs([]),zs(""),Fo("events"),R(""),De(""),At(!1),Lt("");try{const O=await t.backlog_exec_requests({status:"completed,failed",limit:500}),Se=(Array.isArray(O==null?void 0:O.requests)?O.requests:[]).filter(Ye=>String(Ye.backlog_filename||"").trim()===W);if(Se.sort((Ye,Ze)=>{const He=String(Ye.finished_at||Ye.started_at||Ye.created_at||"");return String(Ze.finished_at||Ze.started_at||Ze.created_at||"").localeCompare(He)}),qs(Se),!Se.length){De("No execution logs found for this backlog item.");return}const et=String(Se[0].request_id||"").trim();zs(et),await vi({request_id:et,name:"events"}),setTimeout(()=>{var Ye;return(Ye=Kt.current)==null?void 0:Ye.focus()},0)}catch(O){De(String((O==null?void 0:O.message)||O||"Failed to load execution logs"))}}}function ii(C){const W=String(Rt||"");if(!W)return;const O=String(Ar||"");if(!O)return;const fe=Kt.current;if(!fe)return;const Se=typeof fe.selectionStart=="number"?fe.selectionStart:0,et=typeof fe.selectionEnd=="number"?fe.selectionEnd:0;let Ye=-1;if(C===1){const Ze=Math.min(O.length,Math.max(0,et));Ye=O.indexOf(W,Ze),Ye<0&&Ze>0&&(Ye=O.indexOf(W,0))}else{const Ze=Math.min(O.length,Math.max(0,Se-1));Ye=O.lastIndexOf(W,Ze),Ye<0&&Ze<O.length-1&&(Ye=O.lastIndexOf(W,O.length))}if(!(Ye<0))try{fe.focus(),fe.setSelectionRange(Ye,Ye+W.length)}catch{}}async function rc(){if(Ut&&!J){F(""),k(!0);try{const C=st||await Ho();if(!C){F("Could not load gateway exec config.");return}const W=C.runner_alive!==!1,O=C.codex_available!==!1;if(C.runner_enabled!==!0){F("Backlog exec runner is disabled on this gateway.");return}if(!W){F(C.runner_error?`Backlog exec runner not running: ${C.runner_error}`:"Backlog exec runner is not running.");return}if(!O){const He=String(C.codex_bin||"codex");F(`Codex not found on gateway: ${He}`);return}if(C.can_execute!==!0){F("Backlog exec is not available on this gateway (misconfigured executor).");return}const fe=await t.backlog_execute({kind:Ut.kind,filename:Ut.filename,execution_mode:pn}),Se=String((fe==null?void 0:fe.request_id)||"").trim();if(!Se)throw new Error("No request_id returned");zt(!1),Ot(null),d("processing"),yn("tasks"),I(""),oe(null),_e(""),$e(""),V(""),B(!1),te(""),ve(""),Qe([]),de(""),Fe(!1),tt(""),Un(!1),ke(""),it([]);const et={request_id:Se,status:"queued"};Gn(et),Yn(null),Cr("");const Ze=(await ms("processing")).find(He=>He.request_id===Se)||null;Ze?await qi(Ze):await qi(et)}catch(C){F(String((C==null?void 0:C.message)||C||"Execute failed"))}finally{k(!1)}}}async function Yt(){if(!Vt&&Vn.length){if(Vn.length<2){Rn("Select at least 2 planned backlog items.");return}Rn(""),rt(!0);try{const C=st||await Ho();if(!C){Rn("Could not load gateway exec config.");return}const W=C.runner_alive!==!1,O=C.codex_available!==!1;if(C.runner_enabled!==!0){Rn("Backlog exec runner is disabled on this gateway.");return}if(!W){Rn(C.runner_error?`Backlog exec runner not running: ${C.runner_error}`:"Backlog exec runner is not running.");return}if(!O){const He=String(C.codex_bin||"codex");Rn(`Codex not found on gateway: ${He}`);return}if(C.can_execute!==!0){Rn("Backlog exec is not available on this gateway (misconfigured executor).");return}const fe=await t.backlog_execute_batch({items:Vn.map(He=>({kind:"planned",filename:He.filename})),execution_mode:kn}),Se=String((fe==null?void 0:fe.request_id)||"").trim();if(!Se)throw new Error("No request_id returned");Zt(!1),un([]),d("processing"),yn("tasks"),I(""),oe(null),_e(""),$e(""),V(""),B(!1),te(""),ve("");const et={request_id:Se,status:"queued"};Gn(et),Yn(null),Cr("");const Ze=(await ms("processing")).find(He=>He.request_id===Se)||null;Ze?await qi(Ze):await qi(et)}catch(C){Rn(String((C==null?void 0:C.message)||C||"Execute batch failed"))}finally{rt(!1)}}}async function sc(){if(us)return;if(Vn.length<2){mr("Select at least 2 planned backlog items.");return}const C=Sr.trim();if(!C){mr("Title is required.");return}const W=Ws.trim().toLowerCase();if(!W){mr("Package is required.");return}mr(""),Jr(!0);try{const O=await t.backlog_merge({kind:"planned",package:W,title:C,task_type:lo,summary:cs.trim()||null,items:Vn.map(Ze=>({kind:"planned",filename:Ze.filename}))}),fe=String((O==null?void 0:O.kind)||"").trim(),Se=String((O==null?void 0:O.filename)||"").trim();if(!fe||!Se)throw new Error("Merge succeeded but returned an invalid response");Ir(!1),Fr(""),En(""),un([]),d(fe),I("");const Ye=(await vo(fe)).find(Ze=>Ze.filename===Se)||null;Ye&&await Xs(Ye,{kind:fe})}catch(O){mr(String((O==null?void 0:O.message)||O||"Merge failed"))}finally{Jr(!1)}}function Vo(){yl("proposed"),fo("feature"),Ia("framework"),ec(""),xl(""),da(""),Bi(""),vl(!1),go(""),yo(""),ma(""),wl(""),bl(""),yi(""),Oa(""),jl(""),Ys(""),nc(""),kl([]),Wi(!1),ds(""),ri([]),Hi(""),Vi(!1)}async function ic(){const C=String(or||"").trim();if(C)return C;if(Tr)return"";Rs(""),bs(!0);try{const W=await t.backlog_template(),O=String((W==null?void 0:W.content)||"");return An(O),O}catch(W){return Rs(String((W==null?void 0:W.message)||W||"Failed to load backlog template")),""}finally{bs(!1)}}async function Nl(C){if(!r)return;const W=(C==null?void 0:C.force)===!0;if(!W&&Oo.trim())return;const O=await ic();if(!O.trim())return;const fe=String(mo||"").trim().toLowerCase()||"{Package}",Se=Mm(),et=Nw(O,{package_name:fe,title:Gs,task_type:uo,summary:ho,created_at:Se});da(Ye=>W||!String(Ye||"").trim()?et:Ye)}function Cl(C){if(Oo.trim()&&!globalThis.confirm("Overwrite the current draft markdown with a guided draft?"))return;const W=String(mo||"").trim().toLowerCase()||"{Package}",O=Mm(),fe=Cw({package_name:W,title:Gs,task_type:uo,summary:ho,diagram:fa,context:_o,included:al(Do),excluded:al(Fa),plan:al(Bo),dependencies:al(Ui),acceptance:al(tc),tests_a:al(Sl),tests_b:al(Uo),tests_c:al(Ps),created_at:O,attachments:[]});da(fe)}async function oc(){var W;if(Ls)return;Bi(""),vl(!0),ds("");let C="";try{const O=String(mo||"").trim().toLowerCase(),fe=await t.backlog_create({kind:co,package:O,title:Gs,task_type:uo,summary:ho||null,content:Oo||null}),Se=String((fe==null?void 0:fe.kind)||"").trim(),et=String((fe==null?void 0:fe.filename)||"").trim(),Ye=[...Wo||[]];if(Se&&et&&Ye.length){Wi(!0);try{const Wt=[];for(const xn of Ye){const Fn=await t.backlog_upload_attachment({kind:Se,filename:et,file:xn,overwrite:!1}),$n=String(((W=Fn==null?void 0:Fn.stored)==null?void 0:W.relpath)||"").trim();$n&&Wt.push($n)}if(Wt.length){const xn=await t.backlog_content(Se,et),Fn=String((xn==null?void 0:xn.content)||""),$n=await zm(Fn),Ks=Op(Fn,Wt);await t.backlog_update({kind:Se,filename:et,content:Ks,expected_sha256:$n||null})}}catch(Wt){C=String((Wt==null?void 0:Wt.message)||Wt||"Attachment upload failed"),ds(C)}finally{Wi(!1)}}fn(!1),Vo(),Se&&d(Se);const He=(await vo(Se)).find(Wt=>Wt.filename===et)||null;He&&await Xs(He,{kind:Se}),C&&F(`Created task, but attachments failed: ${C}`)}catch(O){Bi(String((O==null?void 0:O.message)||O||"Create failed"))}finally{vl(!1)}}async function Gi(){if(fs)return;Bi("");const C=ga.trim();if(!C)return;if(!Gs.trim()){Bi("Title is required before using AI assist.");return}const W=String(mo||"").trim().toLowerCase();if(!W){Bi("Package is required before using AI assist.");return}const O={id:Xr(),role:"user",content:C,ts:new Date().toISOString()},fe=[...pa,O];ri(fe),Hi(""),Vi(!0);try{const Se=await t.backlog_assist({kind:co,package:W,title:Gs,summary:ho||null,draft_markdown:Oo||null,messages:fe.map(Ze=>({role:Ze.role,content:Ze.content})),provider:o||null,model:l||null}),et=String((Se==null?void 0:Se.reply)||"").trim(),Ye=String((Se==null?void 0:Se.draft_markdown)||"").trim();et&&ri(Ze=>[...Ze,{id:Xr(),role:"assistant",content:et,ts:new Date().toISOString()}]),Ye&&da(Ye)}catch(Se){Bi(String((Se==null?void 0:Se.message)||Se||"AI assist failed"))}finally{Vi(!1)}}async function El(C){var W;if(Y&&ia(c)&&C.length&&r&&!ls){ke(""),Un(!0);try{const O=[];for(const fe of C){const Se=await t.backlog_upload_attachment({kind:c,filename:Y.filename,file:fe,overwrite:!1}),et=String(((W=Se==null?void 0:Se.stored)==null?void 0:W.relpath)||"").trim();et&&O.push(et)}O.length&&(it(fe=>[...O,...fe].slice(0,12)),te(fe=>Op(String(fe||""),O)))}catch(O){ke(String((O==null?void 0:O.message)||O||"Attachment upload failed"))}finally{Un(!1)}}}async function xa(){if(be||!Y||!ia(c)||!r)return;if(!(c==="planned"||c==="proposed"||c==="recurrent"||c==="deprecated")){tt("Maintenance chat is only available for planned/proposed/recurrent/deprecated items.");return}tt("");const W=Pe.trim();if(!W)return;const O={id:Xr(),role:"user",content:W,ts:new Date().toISOString()},fe=[...Re,O];Qe(fe),de(""),Fe(!0);try{const Se=vw(Y);if(!Se)throw new Error("Backlog item missing package (cannot maintain)");const et=await t.backlog_maintain({kind:c,filename:Y.filename,package:Se,title:Y.title||Y.filename,summary:Y.summary||null,draft_markdown:Z||null,messages:fe.map(He=>({role:He.role,content:He.content})),provider:o||null,model:l||null}),Ye=String((et==null?void 0:et.reply)||"").trim(),Ze=String((et==null?void 0:et.draft_markdown)||"").trim();Ye&&Qe(He=>[...He,{id:Xr(),role:"assistant",content:Ye,ts:new Date().toISOString()}]),Ze&&te(Ze)}catch(Se){tt(String((Se==null?void 0:Se.message)||Se||"Maintenance AI failed"))}finally{Fe(!1)}}async function Yc(){if(sn||!r)return;if(Qt.voice_ptt_busy){cr("Wait for transcription to finish.");return}je(""),cr("");const C=Et.trim();if(!C)return;const W={id:Xr(),role:"user",content:C,ts:new Date().toISOString()},O=[...lt,W];xe(O),yt(""),ln(!0);try{const fe=await t.backlog_advisor({messages:O.map(Ze=>({role:Ze.role,content:Ze.content})),provider:o||null,model:l||null,agent:u||null,include_trace:ue,focus_kind:c,focus_type:G}),Se=ue&&Array.isArray(fe==null?void 0:fe.tool_trace)?fe.tool_trace:[],et=String((fe==null?void 0:fe.run_id)||"").trim(),Ye=String((fe==null?void 0:fe.reply)||"").trim();if(ue&&Se.length){const Ze={id:Xr(),role:"system",title:"Tool execution",level:"info",ts:new Date().toISOString(),content:JSON.stringify({run_id:et||null,tool_trace:Se},null,2)};xe(He=>[...He,Ze])}Ye&&xe(Ze=>[...Ze,{id:Xr(),role:"assistant",content:Ye,ts:new Date().toISOString()}])}catch(fe){je(String((fe==null?void 0:fe.message)||fe||"Backlog advisor failed"))}finally{ln(!1)}}async function Xc(C){var Ye;const W=Array.from(C||[]);if(!W.length)return;const O=[],fe=[],Se=6,et=2e4;for(const Ze of W.slice(0,Se)){const He=String((Ze==null?void 0:Ze.name)||"").trim()||"attachment";fe.push(He);try{const Wt=await Ze.text(),xn=Wt.length>et?`${Wt.slice(0,et)}
|
|
88
|
+
…(truncated)…
|
|
89
|
+
`:Wt;O.push(`[attached file: ${He}]
|
|
90
|
+
|
|
91
|
+
\`\`\`
|
|
92
|
+
${xn}
|
|
93
|
+
\`\`\``)}catch{O.push(`[attached file: ${He}] (unreadable in browser)`)}}pt(Ze=>[...fe,...Ze].slice(0,12)),yt(Ze=>{const He=String(Ze||"").trim(),Wt=O.join(`
|
|
94
|
+
|
|
95
|
+
`);return He?`${He}
|
|
96
|
+
|
|
97
|
+
${Wt}`:Wt});try{(Ye=qt.current)==null||Ye.focus()}catch{}}function va(C){const W=String(C.id||C.ts||"").trim(),O=String(C.content||"").trim();!W||!O||(cr(""),Qt.toggle_tts(W,O))}function Kc(C){const W=String(C.id||C.ts||"").trim(),O=Qt.tts_playback;return!W||!O.key||O.key!==W?"idle":O.status}function Da(){Qt.stop_voice_ptt_recording(),Qt.stop_tts()}const wa=Y&&nm(Y)?Pu(Y.task_type):null,In=!!(Y&&c==="planned"),$l=!!(Y&&c==="proposed"),Xn=!!(Y&&c==="planned"),qo=!!(Y&&ia(c)&&c!=="deprecated"&&c!=="trash"),Ba=!!(Y&&ia(c)&&c!=="trash"),Go=!!(Y&&c==="trash"),bo=!!(Y&&c==="deprecated"),Ua=!h||_==="list",Yo=!h||_==="detail";return s.jsxs("div",{className:"page backlog_page",children:[s.jsxs("div",{className:"page_inner",children:[s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"title",children:[s.jsx("h1",{children:"Backlog"}),r&&st?s.jsxs("span",{className:"badge",style:{background:st.runner_alive?"rgba(34, 197, 94, 0.14)":"rgba(239, 68, 68, 0.14)",borderColor:st.runner_alive?"rgba(34, 197, 94, 0.35)":"rgba(239, 68, 68, 0.35)"},title:st.codex_model||st.codex_reasoning_effort?`codex: ${String(st.codex_model||"").trim()||"?"}${st.codex_reasoning_effort?` (reasoning ${st.codex_reasoning_effort})`:""}`:void 0,children:["exec worker ",st.runner_alive?"on":"off",!h&&st.codex_model?` · ${st.codex_model}`:"",!h&&st.codex_reasoning_effort?` · ${st.codex_reasoning_effort}`:""]}):null]}),s.jsxs("div",{className:"row backlog_toolbar",style:{alignItems:"center",justifyContent:"space-between"},children:[s.jsxs("div",{className:"tab_bar backlog_tabs",style:{paddingBottom:0,borderBottom:"none"},children:[s.jsx("button",{className:`tab ${c==="processing"?"active":""}`,onClick:()=>d("processing"),children:"Processing"}),s.jsx("button",{className:`tab ${c==="planned"?"active":""}`,onClick:()=>d("planned"),children:"Planned"}),s.jsx("button",{className:`tab ${c==="proposed"?"active":""}`,onClick:()=>d("proposed"),children:"Proposed"}),s.jsx("button",{className:`tab ${c==="recurrent"?"active":""}`,onClick:()=>d("recurrent"),children:"Recurrent"}),s.jsx("button",{className:`tab ${c==="completed"?"active":""}`,onClick:()=>d("completed"),children:"Completed"}),s.jsx("button",{className:`tab ${c==="failed"?"active":""}`,onClick:()=>d("failed"),children:"Failed"}),s.jsx("button",{className:`tab ${c==="deprecated"?"active":""}`,onClick:()=>d("deprecated"),children:"Deprecated"}),s.jsx("button",{className:`tab ${c==="trash"?"active":""}`,onClick:()=>d("trash"),children:"Trash"})]}),s.jsxs("div",{className:"row backlog_toolbar_actions",style:{gap:"8px",justifyContent:"flex-end"},children:[s.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(!0),disabled:!r,title:"New task","aria-label":"New task",children:[s.jsx(On,{name:"plus",size:16}),s.jsx("span",{className:"btn_label",children:"New"})]}),s.jsxs("button",{className:`btn btn_icon ${(Cn?Hs:b)?"is_loading":""}`,onClick:()=>void ns(),disabled:!r||(Cn?Hs:b),title:"Refresh","aria-label":"Refresh",children:[s.jsx(On,{name:"refresh",size:16}),s.jsx("span",{className:"btn_label",children:Cn?Hs?"Refreshing":"Refresh":b?"Refreshing":"Refresh"})]})]})]}),s.jsx("div",{className:`row backlog_filters ${c==="completed"?"backlog_filters_completed":""}`,style:{marginTop:"10px",alignItems:c==="completed"?"flex-start":"center",justifyContent:"space-between"},children:c==="completed"?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"backlog_filters_left",children:s.jsx("div",{className:"field backlog_search_field",children:s.jsx("input",{value:L,onChange:C=>I(C.target.value),placeholder:Cn?"Search exec requests (id/status/backlog/error…)":"Search backlog (id/title/package/filename…)"})})}),s.jsxs("div",{className:"backlog_filters_right",children:[s.jsxs("div",{className:"tab_bar backlog_completed_view_tabs",style:{paddingBottom:0,borderBottom:"none"},children:[s.jsx("button",{className:`tab ${nt==="tasks"?"active":""}`,onClick:()=>yn("tasks"),children:"Tasks"}),s.jsx("button",{className:`tab ${nt==="runs"?"active":""}`,onClick:()=>yn("runs"),children:"Runs"})]}),s.jsxs("div",{className:"backlog_completed_meta_row",children:[Cn?null:s.jsx("div",{className:"field backlog_type_filter_field",children:s.jsxs("select",{value:G,onChange:C=>ne(C.target.value),title:"Filter by type",children:[s.jsx("option",{value:"all",children:"all"}),s.jsx("option",{value:"task",children:"task"}),s.jsx("option",{value:"bug",children:"bug"}),s.jsx("option",{value:"feature",children:"feature"})]})}),s.jsx("div",{className:"mono muted backlog_count",style:{fontSize:"var(--font-size-sm)"},children:Cn?`${ps.length}/${hr.length}`:`${hs.length}/${x.length}`})]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"field backlog_search_field",children:s.jsx("input",{value:L,onChange:C=>I(C.target.value),placeholder:Cn?"Search exec requests (id/status/backlog/error…)":"Search backlog (id/title/package/filename…)"})}),Cn?null:s.jsx("div",{className:"field backlog_type_filter_field",children:s.jsxs("select",{value:G,onChange:C=>ne(C.target.value),title:"Filter by type",children:[s.jsx("option",{value:"all",children:"all"}),s.jsx("option",{value:"task",children:"task"}),s.jsx("option",{value:"bug",children:"bug"}),s.jsx("option",{value:"feature",children:"feature"})]})}),s.jsx("div",{className:"mono muted backlog_count",style:{fontSize:"var(--font-size-sm)"},children:Cn?`${ps.length}/${hr.length}`:`${hs.length}/${x.length}`})]})}),!Cn&&c==="planned"&&M.length?s.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:[M.length," planned item",M.length===1?"":"s"," hidden while queued/running."," ",s.jsx("button",{className:"btn",style:{padding:"4px 10px",marginLeft:"6px"},onClick:()=>d("processing"),disabled:!r,children:"View processing"})]}):null,!Cn&&c==="planned"?s.jsxs("details",{style:{marginTop:"10px"},children:[s.jsx("summary",{className:"mono muted",style:{cursor:"pointer",fontSize:"var(--font-size-sm)"},children:"Batch actions (shared context)"}),s.jsxs("div",{style:{marginTop:"10px"},children:[s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select multiple planned backlog items to either execute them sequentially in a single exec worker (one Codex run) or merge them into a master backlog item."}),s.jsx("div",{style:{marginTop:"10px"},children:s.jsx(w_,{options:x.map(C=>String(C.filename||"").trim()).filter(Boolean),value:_n,disabled:!r||b,placeholder:"(no items selected)",onChange:C=>un(C)})}),s.jsxs("div",{className:"row",style:{gap:"8px",marginTop:"10px",flexWrap:"wrap"},children:[s.jsx("button",{className:"btn primary",disabled:!r||Vn.length<2,onClick:()=>{Rn(""),Nn("uat"),Zt(!0)},children:"Execute batch"}),s.jsx("button",{className:"btn",disabled:!r||Vn.length<2,onClick:()=>{const C=(()=>{const W=Vn.map(fe=>String(fe.package||"").trim()).filter(Boolean);if(!W.length)return"framework";const O=W[0];return W.every(fe=>fe===O)?O:"framework"})();Es(C),Ri("task"),Fr(`Master backlog (${Vn.length} items)`),En(""),mr(""),Ir(!0)},children:"Merge → master"})]})]})]}):null,!Cn&&S?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",marginTop:"8px",fontSize:"var(--font-size-sm)"},children:S}):null,Cn&&ur?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",marginTop:"8px",fontSize:"var(--font-size-sm)"},children:ur}):null,!Cn&&!S&&!b&&!x.length?s.jsx("div",{className:"mono muted",style:{marginTop:"8px",fontSize:"var(--font-size-sm)"},children:"No items (or backlog browsing not configured on this gateway)."}):null,Cn&&!ur&&!Hs&&!hr.length?s.jsx("div",{className:"mono muted",style:{marginTop:"8px",fontSize:"var(--font-size-sm)"},children:"No exec requests found."}):null]}),s.jsxs("div",{className:"inbox_layout",children:[Ua?s.jsx("div",{className:"card inbox_sidebar",children:s.jsx("div",{className:"inbox_list",children:Cn?ps.length?ps.map(C=>{const W=(Me==null?void 0:Me.request_id)===C.request_id,O=String(C.status||"").trim().toLowerCase(),fe=O==="completed"||O==="promoted"?"ok":O==="failed"?"danger":O==="running"?"info":O==="queued"||O==="awaiting_qa"?"warn":"muted";return s.jsxs("button",{className:`inbox_item ${W?"active":""}`,onClick:()=>void qi(C),children:[s.jsxs("div",{className:"inbox_item_title",children:[s.jsx("span",{className:`chip ${fe} mono`,children:O||"unknown"}),s.jsx("span",{className:"item_title_text",children:oa(C.backlog_filename||C.backlog_relpath||"request",56)})]}),s.jsx("div",{className:"inbox_item_meta mono muted",children:oa(C.request_id,80)}),C.error?s.jsx("div",{className:"inbox_item_meta mono",style:{color:"rgba(239, 68, 68, 0.9)"},children:oa(C.error,180)}):null]},`exec:${C.request_id}`)}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No requests."}):hs.length?hs.map(C=>{const W=(Y==null?void 0:Y.filename)===C.filename,O=nm(C),fe=Pu(C.task_type);return s.jsxs("button",{className:`inbox_item ${W?"active":""}`,onClick:()=>void Xs(C),children:[s.jsxs("div",{className:"inbox_item_title",children:[O?null:s.jsx("span",{className:"pill unparsed",children:"unparsed"}),C.item_id?s.jsxs("span",{className:"chip info mono",children:["#",C.item_id]}):null,O?s.jsx("span",{className:`chip ${Pp(fe)} mono`,children:fe}):null,C.package?s.jsx("span",{className:"chip muted mono",children:C.package}):null,s.jsx("span",{className:"item_title_text",children:oa(C.title||C.filename,56)})]}),C.summary?s.jsx("div",{className:"item_summary_text",children:s.jsx(ao,{text:bw(C.summary),className:"backlog_summary_md"})}):null,s.jsx("div",{className:"inbox_item_meta mono muted",children:C.filename})]},`${c}:${C.filename}`)}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No items."})})}):null,Yo?s.jsx("div",{className:"card inbox_viewer",children:Cn?Me?s.jsxs("div",{className:"inbox_detail",children:[s.jsxs("div",{className:"inbox_detail_header",children:[s.jsxs("div",{className:"inbox_detail_title",children:[s.jsx("span",{className:"mono",style:{fontWeight:700},children:Me.backlog_filename||Me.backlog_relpath||Me.request_id}),(()=>{const C=String(Me.status||"").trim().toLowerCase(),W=C==="completed"||C==="promoted"?"ok":C==="failed"?"danger":C==="running"?"info":C==="queued"||C==="awaiting_qa"?"warn":"muted";return s.jsx("span",{className:`chip mono ${W}`,children:C||"unknown"})})(),s.jsx("span",{className:"chip mono muted",children:oa(Me.request_id,16)})]}),s.jsxs("div",{className:"inbox_detail_actions",children:[h?s.jsx("button",{className:"btn",onClick:()=>g("list"),disabled:er,children:"Back"}):null,s.jsxs("button",{className:"btn btn_icon",onClick:()=>Ns(Me.request_id),disabled:er,"aria-label":"Copy request id",title:"Copy request id",children:[s.jsx(On,{name:"copy",size:16}),h?null:"Copy request id"]}),Me.backlog_relpath?s.jsxs("button",{className:"btn btn_icon",onClick:()=>Ns(Me.backlog_relpath||""),disabled:er,"aria-label":"Copy backlog path",title:"Copy backlog path",children:[s.jsx(On,{name:"copy",size:16}),h?null:"Copy backlog path"]}):null,(()=>{var O;const W=(Array.isArray((O=Ge==null?void 0:Ge.backlog_queue)==null?void 0:O.items)?Ge.backlog_queue.items:[]).map(fe=>String((fe==null?void 0:fe.relpath)||"").trim()).filter(Boolean);return W.length?s.jsxs("button",{className:"btn btn_icon",onClick:()=>Ns(W.join(`
|
|
98
|
+
`)),disabled:er,"aria-label":"Copy backlog paths",title:"Copy backlog paths",children:[s.jsx(On,{name:"copy",size:16}),h?null:"Copy backlog paths"]}):null})(),Me.run_dir_relpath?s.jsxs("button",{className:"btn btn_icon",onClick:()=>Ns(Me.run_dir_relpath||""),disabled:er,"aria-label":"Copy run dir",title:"Copy run dir",children:[s.jsx(On,{name:"copy",size:16}),h?null:"Copy run dir"]}):null]})]}),s.jsxs("div",{className:"inbox_detail_meta mono muted",style:{fontSize:"var(--font-size-sm)"},children:[Me.created_at?`created ${new Date(Me.created_at).toLocaleString()}`:"",Me.started_at?` • started ${new Date(Me.started_at).toLocaleString()}`:"",Me.finished_at?` • finished ${new Date(Me.finished_at).toLocaleString()}`:""]}),Me.error?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Me.error}):null,Nr?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Nr}):null,s.jsx("div",{style:{marginTop:"12px"},children:er?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading…"}):s.jsxs(s.Fragment,{children:[(()=>{if(String(Me.status||"").trim().toLowerCase()!=="awaiting_qa")return null;const W=String((Ge==null?void 0:Ge.execution_mode)||"").trim().toLowerCase()||"uat",O=String((Ge==null?void 0:Ge.candidate_relpath)||"").trim(),fe=String((Ge==null?void 0:Ge.candidate_patch_relpath)||"").trim(),Se=String((Ge==null?void 0:Ge.candidate_manifest_relpath)||"").trim(),et=String((Ge==null?void 0:Ge.uat_current_relpath)||"").trim(),Ye=String((Ge==null?void 0:Ge.uat_lock_owner_request_id)||"").trim(),Ze=!!(Ge!=null&&Ge.uat_lock_acquired),He=!!(Ge!=null&&Ge.uat_pending),Wt=(Ge==null?void 0:Ge.uat_deploy)??null,xn=String((Ge==null?void 0:Ge.uat_deploy_error)||"").trim(),Fn=Ge==null?void 0:Ge.attempt,$n=(Ge==null?void 0:Ge.promotion_report)??null,Ks=!!($n!=null&&$n.blocked),Ss=String(($n==null?void 0:$n.reason)||"").trim(),Yi=Array.isArray($n==null?void 0:$n.conflicts)?($n==null?void 0:$n.conflicts).slice(0,8):[],Is=typeof($n==null?void 0:$n.conflicts_total)=="number"?Number($n.conflicts_total):Yi.length;let _r="",wi="";const yr=[];try{const qn=Wt==null?void 0:Wt.processes;if(qn&&typeof qn=="object"&&!Array.isArray(qn)){typeof qn.status=="string"&&(_r=String(qn.status||"").trim()),typeof qn.reason=="string"&&(wi=String(qn.reason||"").trim());for(const[Wa,ba]of Object.entries(qn)){if(!ba||typeof ba!="object"||Array.isArray(ba))continue;const oi=ba.probe;!oi||typeof oi!="object"||oi.ok===!1&&yr.push(String(Wa))}}}catch{}return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"section_title",children:"QA decision"}),s.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:[s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"mode:"})," ",W]}),typeof Fn=="number"?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"attempt:"})," ",Fn]}):null,O?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"candidate:"})," ",O]}):null,Se?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"manifest:"})," ",Se]}):null,fe?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"patch:"})," ",fe]}):null,et?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"uat_current:"})," ",et]}):null,W==="uat"&&Ye?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"uat_lock:"})," ",Ye,Ze?" (owned)":He?" (pending)":""]}):null]}),W==="inplace"?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Inplace mode: prod may already be mutated. Approving only finalizes the request status."}):W==="uat"&&He&&Ye&&!Ze?s.jsxs("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:["UAT currently points to ",oa(Ye,16),". Click “Restart UAT” to switch the shared UAT stack to this request."]}):W==="uat"&&Ze?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"UAT URLs: gateway `http://localhost:6081`, observer `http://localhost:6082`, code `http://localhost:6083`, flow `http://localhost:6084`"}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:"UAT is intentionally short-lived: promoting or iterating will stop the shared UAT services."}),yr.length?s.jsxs("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:["UAT may be unreachable: URL probe failed for ",yr.slice(0,4).join(", "),yr.length>4?"…":"",". Click “Restart UAT” and check process logs."]}):null]}):null,W==="uat"&&_r==="skipped"&&wi==="process_manager_disabled"?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"UAT services were not started: process manager is disabled. Restart the gateway with `ABSTRACTGATEWAY_ENABLE_PROCESS_MANAGER=1`."}):null,xn?s.jsxs("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:["UAT deploy failed: ",xn]}):null,Ks&&Ss==="conflicts"?s.jsxs("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:["Promotion blocked: prod diverged from the candidate base (",Is," conflict",Is===1?"":"s","). Use “Iterate” to re-run the request on top of current prod, or resolve conflicts manually.",Yi.length?s.jsx("ul",{style:{marginTop:"8px",paddingLeft:"18px"},children:Yi.map((qn,Wa)=>s.jsxs("li",{children:[String((qn==null?void 0:qn.repo)||""),"/",String((qn==null?void 0:qn.path)||"")," (",String((qn==null?void 0:qn.reason)||"conflict"),")"]},`c:${Wa}`))}):null]}):null,s.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[fe?s.jsxs("button",{className:"btn btn_icon",onClick:()=>Ns(fe),disabled:Er,children:[s.jsx(On,{name:"copy",size:16}),"Copy patch path"]}):null,Se?s.jsxs("button",{className:"btn btn_icon",onClick:()=>Ns(Se),disabled:Er,children:[s.jsx(On,{name:"copy",size:16}),"Copy manifest path"]}):null,O?s.jsxs("button",{className:"btn btn_icon",onClick:()=>Ns(O),disabled:Er,children:[s.jsx(On,{name:"copy",size:16}),"Copy candidate path"]}):null]}),s.jsx("div",{style:{marginTop:"10px"},children:s.jsx("textarea",{value:Li,onChange:qn=>rn(qn.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",resize:"vertical",minHeight:"72px"},disabled:Er})}),$s?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:$s}):null,s.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[W==="uat"?s.jsx("button",{className:"btn",onClick:()=>void Vr(),disabled:Er,children:"Restart UAT"}):null,s.jsx("button",{className:"btn primary",onClick:()=>void ya(),disabled:Er,children:W==="inplace"?"Approve (finalize)":"Approve → promote to prod"}),s.jsx("button",{className:"btn",onClick:()=>void jt(),disabled:Er,children:"Iterate (send feedback)"})]}),s.jsx("div",{className:"section_divider"})]})})(),(()=>{if(String(Me.status||"").trim().toLowerCase()!=="promoted")return null;const W=String((Ge==null?void 0:Ge.promoted_at)||"").trim(),O=(Ge==null?void 0:Ge.promotion)??null,fe=(Ge==null?void 0:Ge.promotion_report)??null,Se=typeof(O==null?void 0:O.copied)=="number"?Number(O==null?void 0:O.copied):null,et=typeof(O==null?void 0:O.deleted)=="number"?Number(O==null?void 0:O.deleted):null,Ye=String((O==null?void 0:O.manifest_sha256)||"").trim(),Ze=String((O==null?void 0:O.mode)||"").trim(),He=(fe==null?void 0:fe.redeploy)??null,Wt=String((He==null?void 0:He.status)||"").trim(),xn=String((He==null?void 0:He.reason)||"").trim(),Fn=String((fe==null?void 0:fe.redeploy_error)||"").trim();return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"section_title",children:"Promotion"}),s.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:[W?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"promoted_at:"})," ",new Date(W).toLocaleString()]}):null,Ze?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"mode:"})," ",Ze]}):null,Ye?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"manifest_sha256:"})," ",Ye.slice(0,16),"…"]}):null,Se!=null?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"files_copied:"})," ",Se]}):null,et!=null?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"files_deleted:"})," ",et]}):null,Wt?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"redeploy:"})," ",Wt,xn?` (${xn})`:""]}):null,Fn?s.jsxs("div",{style:{color:"rgba(239, 68, 68, 0.9)"},children:[s.jsx("span",{className:"mono muted",children:"redeploy_error:"})," ",Fn]}):null]}),s.jsx("div",{className:"section_divider"})]})})(),s.jsx("div",{className:"section_title",children:"Execution"}),s.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:[s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"status:"})," ",Me.status||"unknown"]}),Me.executor_type?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"executor:"})," ",Me.executor_type]}):null,Me.target_agent?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"target_agent:"})," ",Me.target_agent]}):null,Me.target_model?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"model:"})," ",Me.target_model,Me.target_reasoning_effort?` (reasoning ${Me.target_reasoning_effort})`:""]}):null,Me.exit_code!=null?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"exit_code:"})," ",String(Me.exit_code)]}):null,Me.run_dir_relpath?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"run_dir:"})," ",Me.run_dir_relpath]}):null,nr.age_ms!=null?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"age:"})," ",Cd(nr.age_ms)]}):null,nr.queue_delay_ms!=null?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"queue_delay:"})," ",Cd(nr.queue_delay_ms)]}):null,nr.run_ms!=null?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"run_time:"})," ",Cd(nr.run_ms)]}):null,nr.total_ms!=null&&nr.is_done?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"total_time:"})," ",Cd(nr.total_ms)]}):null,lr?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"commands:"})," ",lr.command_count.toLocaleString(),lr.command_fail_count?` (${lr.command_fail_count.toLocaleString()} failed)`:""]}):null,s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"tokens:"})," ",lr!=null&&lr.has_tokens?s.jsxs(s.Fragment,{children:["in ",lr.input_tokens.toLocaleString(),lr.cached_input_tokens?` (cached ${lr.cached_input_tokens.toLocaleString()})`:"",", out ",lr.output_tokens.toLocaleString(),", total ",lr.total_tokens.toLocaleString()]}):s.jsx("span",{className:"mono muted",children:fr==="events"?"n/a":'select "events"'})]})]}),(()=>{const C=Ge&&typeof Ge.promotion=="object"?Ge.promotion:null;if(!C)return null;const W=Ge&&typeof Ge.promotion_report=="object"?Ge.promotion_report:null,O=String((C==null?void 0:C.mode)||"").trim(),fe=(C==null?void 0:C.copied)!=null?String(C.copied):"",Se=(C==null?void 0:C.deleted)!=null?String(C.deleted):"",et=String((C==null?void 0:C.manifest_sha256)||"").trim(),Ye=W&&typeof W.redeploy=="object"?W.redeploy:null,Ze=Ye?String(Ye.status||"").trim():"";return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Promotion"}),s.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:[O?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"mode:"})," ",O]}):null,fe?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"copied:"})," ",fe," files"]}):null,Se?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"deleted:"})," ",Se," files"]}):null,et?s.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("div",{style:{minWidth:"180px"},children:[s.jsx("span",{className:"mono muted",children:"manifest_sha256:"})," ",et.slice(0,16),"…"]}),s.jsxs("button",{className:"btn btn_icon",onClick:()=>Ns(et),disabled:Er,children:[s.jsx(On,{name:"copy",size:16}),"Copy sha"]})]}):null,Ze?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"redeploy:"})," ",Ze]}):null]})]})})(),(()=>{var O;const W=(Array.isArray((O=Ge==null?void 0:Ge.backlog_queue)==null?void 0:O.items)?Ge.backlog_queue.items:[]).map(fe=>String((fe==null?void 0:fe.relpath)||"").trim()).filter(Boolean);return W.length?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Backlog queue"}),s.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:W.map(fe=>s.jsx("div",{children:fe},`bq:${fe}`))})]}):null})(),(()=>{var W;const C=String(((W=Ge==null?void 0:Ge.result)==null?void 0:W.last_message)||Me.last_message||"").trim();return C?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Last message"}),s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:C})]}):null})(),s.jsx("div",{className:"section_divider"}),s.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",gap:"8px",marginTop:"8px"},children:[s.jsx("div",{className:"section_title",style:{marginTop:0},children:"Live logs"}),s.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center",justifyContent:"flex-end",flexWrap:"wrap"},children:[s.jsxs("select",{value:fr,onChange:C=>gi(C.target.value),children:[s.jsx("option",{value:"events",children:"events"}),s.jsx("option",{value:"stderr",children:"stderr"}),s.jsx("option",{value:"last_message",children:"last message"})]}),s.jsx("button",{className:`btn ${gr?"primary":""}`,onClick:()=>Pi(C=>!C),disabled:!(Me!=null&&Me.request_id),children:gr?"Auto on":"Auto off"}),s.jsxs("button",{className:`btn btn_icon ${$r?"is_loading":""}`,onClick:()=>void gn(),disabled:$r||!(Me!=null&&Me.request_id),"aria-label":"Refresh logs",title:"Refresh logs",children:[s.jsx(On,{name:"refresh",size:16}),h?null:$r?"Loading…":"Refresh"]})]})]}),Ur?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Ur}):null,!Ur&&Zr?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:"(tail truncated)"}):null,fr==="events"&&ts?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"exec_log_scroll",ref:Wr,onScroll:C=>{Ii.current=Ip(C.currentTarget,12)},children:ts.events.length===0?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"(no events yet)"}):ts.events.map(C=>{var wi;const W=C.payload,O=W&&typeof W.item=="object"?W.item:null,fe=O?String(O.type||"").trim():"",Se=O?String(O.id||"").trim():"",et=W?String(W.thread_id||"").trim():"",Ye=_w(C.type,W),Ze=Ye==="error"?"danger":Ye==="ok"?"ok":"info",He=xw(W),Wt=yw(C.type,W),xn=String((W==null?void 0:W.message)||((wi=W==null?void 0:W.error)==null?void 0:wi.message)||"").trim(),Fn=O?String(O.text||"").trim():"",$n=O?String(O.command||"").trim():"",Ks=O?String(O.status||"").trim():"",Ss=O&&O.exit_code!=null?String(O.exit_code):"",Yi=O?String(O.aggregated_output||"").trim():"",Is=O&&Array.isArray(O.items)?O.items:[],_r=$n?v_($n)||$n:"";return s.jsxs("details",{className:`exec_event ${Ye}`,children:[s.jsxs("summary",{className:"exec_event_summary",children:[He?s.jsx("span",{className:"exec_event_when mono muted",children:He}):null,He?s.jsx("span",{className:"exec_event_sep mono muted",children:"|"}):null,s.jsx("span",{className:"exec_event_main mono",title:Wt,children:Wt}),s.jsx("span",{className:`chip mono ${Ze}`,children:fe||C.type}),Ss?s.jsxs("span",{className:"mono muted exec_event_right",children:["exit=",Ss]}):null]}),s.jsxs("div",{className:"exec_event_body",children:[s.jsxs("div",{className:"row exec_event_meta",children:[s.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:C.type}),Se?s.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:Se}):null,et?s.jsxs("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["thread ",oa(et,18)]}):null]}),xn?s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:xn}):null,Is&&Is.length>0?s.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Is.map((yr,qn)=>s.jsxs("div",{children:[(yr&&yr.completed)===!0?"✓":"○"," ",String((yr==null?void 0:yr.text)||"").trim()]},`${C.idx}-todo-${qn}`))}):null,$n?s.jsxs("div",{style:{marginTop:"8px"},children:[s.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["command_execution ",Ks?`(${Ks})`:""," ",Ss?`exit=${Ss}`:""]}),s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"6px"},children:_r})]}):null,Yi?s.jsxs("details",{style:{marginTop:"8px"},children:[s.jsxs("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:["output (",Yi.length.toLocaleString()," chars)"]}),s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Yi})]}):null,Fn?s.jsx("div",{style:{marginTop:"8px"},children:s.jsx(ao,{text:Fn})}):null]})]},`${Se||C.idx}-${C.type}`)})}),s.jsxs("details",{style:{marginTop:"8px"},children:[s.jsxs("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:["Raw JSONL",ts.bad?` (${ts.bad} unparsable line(s))`:""]}),s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px",maxHeight:"240px",overflow:"auto"},children:ts.raw||""})]})]}):s.jsx("div",{className:"exec_log_scroll",ref:Wr,onScroll:C=>{Ii.current=Ip(C.currentTarget,12)},children:s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)"},children:(()=>{var W;if(String(Ln||"").trim())return Ln;if(fr==="last_message"){const O=String(((W=Ge==null?void 0:Ge.result)==null?void 0:W.last_message)||Me.last_message||"").trim();if(O)return O;const fe=String(Me.status||"").trim().toLowerCase();return fe==="queued"||fe==="running"?"(last message is written when the run finishes — use events for live output)":"(no last message yet)"}return fr==="stderr"?"(no stderr yet)":"(no logs yet)"})()})}),(Al=Ge==null?void 0:Ge.result)!=null&&Al.logs?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Logs"}),s.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:[Ge.result.logs.events_relpath?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"events:"})," ",Ge.result.logs.events_relpath]}):null,Ge.result.logs.stderr_relpath?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"stderr:"})," ",Ge.result.logs.stderr_relpath]}):null,Ge.result.logs.last_message_relpath?s.jsxs("div",{children:[s.jsx("span",{className:"mono muted",children:"last_message:"})," ",Ge.result.logs.last_message_relpath]}):null]})]}):null]})})]}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select an exec request."}):Y?s.jsxs("div",{className:"inbox_detail",children:[s.jsxs("div",{className:"inbox_detail_header",children:[s.jsxs("div",{className:"inbox_detail_title",children:[s.jsx("span",{className:"mono",style:{fontWeight:700},children:Y.title||Y.filename}),Y.item_id?s.jsxs("span",{className:"chip mono muted",children:["#",Y.item_id]}):null,Y.package?s.jsx("span",{className:"chip mono muted",children:Y.package}):null,wa?s.jsx("span",{className:`chip ${Pp(wa)} mono`,children:wa}):null,nm(Y)?null:s.jsx("span",{className:"chip mono muted",children:"unparsed"}),s.jsxs("span",{className:"chip mono muted backlog_path_chip",children:[s.jsx("span",{className:"mono",children:Y.filename}),s.jsx("button",{className:"chip_icon_btn",type:"button",onClick:()=>Ns(`docs/backlog/${String(c)}/${Y.filename}`),"aria-label":"Copy path",title:"Copy path",disabled:J,children:s.jsx(On,{name:"copy",size:14})})]})]}),s.jsxs("div",{className:"inbox_detail_actions",children:[h?s.jsx("button",{className:"btn",onClick:()=>g("list"),disabled:J,children:"Back"}):null,c==="completed"&&nt==="tasks"?s.jsx("button",{className:"btn",onClick:()=>void wo(Y.filename),disabled:J||!r,children:"Execution log"}):null,In?s.jsx("button",{className:"btn primary",onClick:()=>{F(""),It("uat"),Ot({kind:"planned",filename:Y.filename,title:Y.title||Y.filename}),zt(!0)},disabled:J,children:"Execute"}):null,$l?s.jsx("button",{className:"btn primary",onClick:()=>void xi("planned"),disabled:J,children:"Elevate → planned"}):null,Xn?s.jsx("button",{className:"btn",onClick:()=>void xi("proposed"),disabled:J,children:"Downgrade → proposed"}):null,bo?s.jsx("button",{className:"btn",onClick:()=>void xi("proposed"),disabled:J,children:"Restore → proposed"}):null,Go?s.jsx("button",{className:"btn",onClick:()=>void xi("proposed"),disabled:J,children:"Restore → proposed"}):null,qo?s.jsx("button",{className:"btn",onClick:()=>void xi("deprecated"),disabled:J,children:"Deprecate"}):null,Ba?s.jsxs("button",{className:"btn btn_icon",onClick:()=>void xi("trash"),disabled:J,"aria-label":"Trash",title:"Trash",children:[s.jsx(On,{name:"trash",size:16}),h?null:"Trash"]}):null,N?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>B(!1),disabled:he,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:()=>void _a(),disabled:he,children:he?"Saving…":"Save"})]}):s.jsxs("button",{className:"btn btn_icon",onClick:()=>{B(!0),te(le),ve(""),Qe([]),de(""),tt(""),ke(""),it([])},disabled:K||he,"aria-label":"Edit",title:"Edit",children:[s.jsx(On,{name:"edit",size:16}),h?null:"Edit"]})]})]}),s.jsxs("div",{className:"inbox_detail_meta mono muted",style:{fontSize:"var(--font-size-sm)"},children:[String(c),Te?` • sha ${oa(Te,10)}`:""]}),z?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:z}):null,se?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:se}):null,X?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:X}):null,K?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading…"}):N?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"field",style:{marginTop:"8px"},children:s.jsx("textarea",{value:Z,onChange:C=>te(C.target.value),rows:18,className:"mono"})}),s.jsxs("div",{className:"backlog_edit_sticky",children:[s.jsx("div",{className:"section_title",style:{marginTop:0},children:"Maintenance AI (chat)"}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Ask the maintainer to refine this backlog item. Provider/model can be set in Settings (blank = gateway default)."}),s.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)",marginTop:"6px"},children:["Using:"," ",s.jsxs("span",{className:"mono",children:[o||"(gateway default)"," / ",l||"(gateway default)"]})]}),s.jsxs("div",{className:"row",style:{marginTop:"10px",justifyContent:"space-between",gap:"10px",flexWrap:"wrap"},children:[s.jsx("input",{ref:Zn,type:"file",multiple:!0,style:{display:"none"},onChange:C=>{const W=Array.from(C.target.files||[]);W.length&&(El(W),C.currentTarget.value="")}}),s.jsx("button",{type:"button",className:"btn",onClick:()=>{var C;return(C=Zn.current)==null?void 0:C.click()},disabled:!r||!Y||!ia(c)||ls,children:ls?"Uploading…":"Attach files"}),ct.length?s.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["Last attached: ",ct[0]]}):null]}),me?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:me}):null,s.jsx("div",{className:"section_divider",style:{marginTop:"10px"}}),s.jsx(Ud,{messages:Re,className:"backlog_chat_thread_small",empty:s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No messages yet."})}),s.jsx("div",{style:{marginTop:"10px"},children:s.jsx(Bd,{value:Pe,onChange:de,onSubmit:()=>void xa(),placeholder:"Message to maintainer (e.g. improve acceptance criteria…)",disabled:!r||be||!Y||!ia(c),busy:be,rows:3,sendButtonClassName:"btn primary"})}),Xe?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Xe}):null]})]}):le?s.jsx(ao,{text:le}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No content loaded."})]}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select a backlog item."})}):null]})]}),s.jsxs(Mi,{open:bt,title:"Execute backlog item?",onClose:()=>{zt(!1),Ot(null)},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{zt(!1),Ot(null)},disabled:J,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:()=>void rc(),disabled:J||dn||!Ut||(st==null?void 0:st.can_execute)!==!0,children:J?"Executing…":"Execute"})]}),children:[s.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:["Target:"," ",s.jsx("span",{className:"mono",style:{fontWeight:700},children:Ut?Ut.title:"(unknown)"})]}),s.jsxs("div",{style:{marginTop:"10px"},children:[s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"6px"},children:"Execution mode"}),s.jsxs("select",{className:"input",value:pn,onChange:C=>It(C.target.value),disabled:J,style:{width:"100%"},children:[s.jsx("option",{value:"uat",children:"UAT (staged, safe)"}),s.jsx("option",{value:"inplace",children:"Inplace (dangerous, edits prod)"})]}),pn==="inplace"?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Warning: inplace runs directly in the prod workspace. Use only when you understand the risk."}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"The run will execute in a candidate workspace. When it reaches “awaiting QA”, click “Restart UAT” to deploy it to the shared UAT stack. After you promote or iterate, UAT services are stopped automatically."})]}),dn?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!dn&&(st==null?void 0:st.can_execute)!==!0?s.jsxs("div",{style:{marginTop:"10px"},children:[s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:(st==null?void 0:st.runner_enabled)!==!0?"Backlog exec runner is disabled on this gateway.":(st==null?void 0:st.runner_alive)===!1?"Backlog exec runner is not running on this gateway.":(st==null?void 0:st.codex_available)===!1?`Codex not found on gateway: ${String((st==null?void 0:st.codex_bin)||"codex")}`:"Backlog exec is not available on this gateway."}),st!=null&&st.runner_error?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:st.runner_error}):null,s.jsxs("details",{style:{marginTop:"8px"},children:[s.jsx("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:"Setup"}),s.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:[s.jsx("div",{children:"Docs: `docs/backlog/README.md`"}),s.jsx("div",{style:{marginTop:"6px"},children:"Required env (example):"}),s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["ABSTRACTGATEWAY_BACKLOG_EXEC_RUNNER=1","ABSTRACTGATEWAY_BACKLOG_EXECUTOR=codex_cli","ABSTRACTGATEWAY_BACKLOG_CODEX_BIN=codex","ABSTRACTGATEWAY_BACKLOG_CODEX_MODEL=gpt-5.2"].join(`
|
|
99
|
+
`)}),s.jsx("button",{className:"btn",style:{marginTop:"8px"},onClick:()=>Ns(["ABSTRACTGATEWAY_BACKLOG_EXEC_RUNNER=1","ABSTRACTGATEWAY_BACKLOG_EXECUTOR=codex_cli","ABSTRACTGATEWAY_BACKLOG_CODEX_BIN=codex","ABSTRACTGATEWAY_BACKLOG_CODEX_MODEL=gpt-5.2"].join(`
|
|
100
|
+
`)),children:"Copy setup"})]})]})]}):null,jr?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:jr}):null,z?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:z}):null]}),s.jsxs(Mi,{open:Gt,title:"Execute batch (single context)?",onClose:()=>{Zt(!1),Rn("")},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{Zt(!1),Rn("")},disabled:Vt,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:()=>void Yt(),disabled:Vt||dn||Vn.length<2||(st==null?void 0:st.can_execute)!==!0,children:Vt?"Executing…":"Execute batch"})]}),children:[s.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:["Items:"," ",s.jsx("span",{className:"mono",style:{fontWeight:700},children:Vn.length})]}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"This queues a single exec request whose prompt includes all selected backlog items (in order), so the agent keeps a shared growing context."}),s.jsxs("div",{style:{marginTop:"10px"},children:[s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"6px"},children:"Execution mode"}),s.jsxs("select",{className:"input",value:kn,onChange:C=>Nn(C.target.value),disabled:Vt,style:{width:"100%"},children:[s.jsx("option",{value:"uat",children:"UAT (staged, safe)"}),s.jsx("option",{value:"inplace",children:"Inplace (dangerous, edits prod)"})]}),kn==="inplace"?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Warning: inplace runs directly in the prod workspace (for the entire batch). Use only when you understand the risk."}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"The batch will execute in a candidate workspace. When it reaches “awaiting QA”, click “Restart UAT” to deploy it to the shared UAT stack. After you promote or iterate, UAT services are stopped automatically."})]}),Vn.length?s.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:Vn.map(C=>s.jsxs("div",{children:["- docs/backlog/planned/",C.filename]},`batchitem:${C.filename}`))}):null,dn?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!dn&&(st==null?void 0:st.can_execute)!==!0?s.jsxs("div",{style:{marginTop:"10px"},children:[s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:(st==null?void 0:st.runner_enabled)!==!0?"Backlog exec runner is disabled on this gateway.":(st==null?void 0:st.runner_alive)===!1?"Backlog exec runner is not running on this gateway.":(st==null?void 0:st.codex_available)===!1?`Codex not found on gateway: ${String((st==null?void 0:st.codex_bin)||"codex")}`:"Backlog exec is not available on this gateway."}),st!=null&&st.runner_error?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:st.runner_error}):null]}):null,jr?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:jr}):null,jn?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:jn}):null]}),s.jsxs(Mi,{open:ar,title:"Merge planned items into master backlog?",onClose:()=>{Ir(!1),mr("")},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{Ir(!1),mr("")},disabled:us,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:()=>void sc(),disabled:us||Vn.length<2||!Sr.trim()||!Ws.trim(),children:us?"Merging…":"Create master"})]}),children:[s.jsxs("div",{className:"row",style:{gap:"10px",flexWrap:"wrap"},children:[s.jsx("div",{className:"col",style:{minWidth:220},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Package"}),s.jsx("input",{value:Ws,onChange:C=>Es(C.target.value),placeholder:"framework"})]})}),s.jsx("div",{className:"col",style:{minWidth:220},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Type"}),s.jsxs("select",{value:lo,onChange:C=>Ri(C.target.value),children:[s.jsx("option",{value:"task",children:"task"}),s.jsx("option",{value:"feature",children:"feature"}),s.jsx("option",{value:"bug",children:"bug"})]})]})})]}),s.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[s.jsx("label",{children:"Title"}),s.jsx("input",{value:Sr,onChange:C=>Fr(C.target.value),placeholder:"Master backlog"})]}),s.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[s.jsx("label",{children:"Summary (optional)"}),s.jsx("textarea",{value:cs,onChange:C=>En(C.target.value),rows:3})]}),Vn.length?s.jsxs("div",{style:{marginTop:"10px"},children:[s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Referenced backlog items:"}),s.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:Vn.map(C=>s.jsxs("div",{children:["- docs/backlog/planned/",C.filename]},`mergeitem:${C.filename}`))})]}):null,Or?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:Or}):null]}),s.jsx(Mi,{open:Fi,title:Oi?`Execution log — ${Oi}`:"Execution log",variant:"fullscreen",onClose:()=>{Ts(!1),ua(""),qs([]),zs(""),R(""),De(""),At(!1),Lt("")},children:s.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[s.jsxs("div",{className:"row",style:{alignItems:"flex-end",gap:"10px",flexWrap:"wrap"},children:[s.jsx("div",{className:"col",style:{minWidth:420,flex:"0 0 auto"},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Execution"}),s.jsxs("select",{value:Hr,onChange:C=>{const W=String(C.target.value||"").trim();zs(W),R(""),De(""),At(!1),W&&vi({request_id:W,name:Di}),setTimeout(()=>{var O;return(O=Kt.current)==null?void 0:O.focus()},0)},disabled:ie||!Ms.length,children:[Ms.length?null:s.jsx("option",{value:"",children:"(none)"}),Ms.map(C=>{const W=String(C.finished_at||C.started_at||C.created_at||"").trim(),O=W?`${W} • ${oa(C.request_id,16)} • ${String(C.status||"").trim()}`:`${oa(C.request_id,16)} • ${String(C.status||"").trim()}`;return s.jsx("option",{value:C.request_id,children:O},`execfull:${C.request_id}`)})]})]})}),s.jsx("div",{className:"col",style:{minWidth:180,flex:"0 0 auto"},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Log"}),s.jsxs("select",{value:Di,onChange:C=>{const W=C.target.value;Fo(W),R(""),De(""),At(!1),Hr&&vi({request_id:Hr,name:W}),setTimeout(()=>{var O;return(O=Kt.current)==null?void 0:O.focus()},0)},disabled:ie||!Hr,children:[s.jsx("option",{value:"events",children:"events"}),s.jsx("option",{value:"stderr",children:"stderr"}),s.jsx("option",{value:"last_message",children:"last_message"})]})]})}),s.jsx("div",{className:"col",style:{minWidth:240,flex:"1 1 240px"},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Search"}),s.jsx("input",{value:Rt,onChange:C=>Lt(C.target.value),placeholder:"Find…",onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),ii(C.shiftKey?-1:1))}})]})}),s.jsxs("div",{className:"col",style:{flex:"0 0 auto",display:"flex",gap:"6px"},children:[s.jsx("button",{className:"btn",onClick:()=>ii(-1),disabled:!Rt.trim()||!Ar.trim(),children:"Prev"}),s.jsx("button",{className:"btn",onClick:()=>ii(1),disabled:!Rt.trim()||!Ar.trim(),children:"Next"}),s.jsx("button",{className:"btn",onClick:()=>void vi(),disabled:ie||!Hr,children:ie?"Loading…":"Refresh"}),s.jsx("button",{className:"btn",onClick:()=>Ns(Ar),disabled:!Ar.trim(),children:"Copy"})]})]}),Ie?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:Ie}):null,!Ie&&at?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Showing only the tail of this log."}):null,s.jsx("div",{style:{flex:"1 1 auto",marginTop:"10px"},children:s.jsx("textarea",{ref:Kt,value:Ar||"(no log loaded)",readOnly:!0,className:"mono",style:{width:"100%",height:"100%",resize:"none",borderRadius:"12px",border:"1px solid var(--border)",background:"rgba(0, 0, 0, 0.18)",color:"var(--text)",padding:"12px",fontSize:"var(--font-size-sm)",lineHeight:"16px"}})})]})}),s.jsxs(Mi,{open:en,title:"New backlog task",onClose:()=>{fn(!1),Vo()},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{fn(!1),Vo()},disabled:Ls||fs,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:()=>void oc(),disabled:Ls||!Gs.trim()||!mo.trim(),children:Ls?"Creating…":"Create"})]}),children:[s.jsxs("div",{className:"row",children:[s.jsx("div",{className:"col",style:{minWidth:220},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Kind"}),s.jsxs("select",{value:co,onChange:C=>yl(C.target.value),children:[s.jsx("option",{value:"proposed",children:"proposed"}),s.jsx("option",{value:"planned",children:"planned"}),s.jsx("option",{value:"recurrent",children:"recurrent"})]})]})}),s.jsx("div",{className:"col",style:{minWidth:220},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Type"}),s.jsxs("select",{value:uo,onChange:C=>fo(C.target.value),children:[s.jsx("option",{value:"feature",children:"feature"}),s.jsx("option",{value:"bug",children:"bug"}),s.jsx("option",{value:"task",children:"task"})]})]})}),s.jsx("div",{className:"col",style:{minWidth:220},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Package"}),s.jsx("input",{value:mo,onChange:C=>Ia(C.target.value),placeholder:"framework"})]})})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Title"}),s.jsx("input",{value:Gs,onChange:C=>ec(C.target.value),placeholder:"Short descriptive title"})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Summary (optional)"}),s.jsx("textarea",{value:ho,onChange:C=>xl(C.target.value),rows:3,placeholder:"One paragraph summary"})]}),s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Guided fields (optional)"}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Use this to generate a structured draft without editing markdown directly. One item per line for list fields."}),s.jsx("div",{style:{marginTop:"8px"},children:s.jsxs("details",{children:[s.jsx("summary",{className:"mono",style:{cursor:"pointer"},children:"Show guided fields"}),s.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[s.jsx("label",{children:"Diagram (ASCII)"}),s.jsx("textarea",{value:fa,onChange:C=>go(C.target.value),rows:4,className:"mono",placeholder:"(optional) ascii diagram"})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Context"}),s.jsx("textarea",{value:_o,onChange:C=>yo(C.target.value),rows:4,placeholder:"Why is this needed? Link to evidence (reports, discussions, etc.)."})]}),s.jsxs("div",{className:"row",children:[s.jsx("div",{className:"col",style:{minWidth:260},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Scope: Included (1 per line)"}),s.jsx("textarea",{value:Do,onChange:C=>ma(C.target.value),rows:4,className:"mono",placeholder:"..."})]})}),s.jsx("div",{className:"col",style:{minWidth:260},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Scope: Excluded (1 per line)"}),s.jsx("textarea",{value:Fa,onChange:C=>wl(C.target.value),rows:4,className:"mono",placeholder:"..."})]})})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Implementation Plan (1 per line)"}),s.jsx("textarea",{value:Bo,onChange:C=>bl(C.target.value),rows:4,className:"mono",placeholder:"..."})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Dependencies (1 per line)"}),s.jsx("textarea",{value:Ui,onChange:C=>yi(C.target.value),rows:3,className:"mono",placeholder:"Related backlog items / ADRs / external libs…"})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Acceptance Criteria (1 per line)"}),s.jsx("textarea",{value:tc,onChange:C=>Oa(C.target.value),rows:4,className:"mono",placeholder:"..."})]}),s.jsxs("div",{className:"row",children:[s.jsx("div",{className:"col",style:{minWidth:260},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Testing Level A (1 per line)"}),s.jsx("textarea",{value:Sl,onChange:C=>jl(C.target.value),rows:3,className:"mono",placeholder:"cd pkg && pytest -q ..."})]})}),s.jsx("div",{className:"col",style:{minWidth:260},children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Testing Level B (1 per line)"}),s.jsx("textarea",{value:Uo,onChange:C=>Ys(C.target.value),rows:3,className:"mono",placeholder:"run local gateway + manual verification..."})]})})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Testing Level C (1 per line)"}),s.jsx("textarea",{value:Ps,onChange:C=>nc(C.target.value),rows:2,className:"mono",placeholder:"(optional / opt-in)"})]}),s.jsx("div",{className:"row",style:{marginTop:"10px",justifyContent:"flex-end"},children:s.jsx("button",{className:"btn",onClick:()=>Cl(),disabled:Ls||fs,children:"Generate draft from guided fields"})})]})}),s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Attachments (optional)"}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Upload screenshots/diagrams to `docs/backlog/assets/<id>/` and link them under `## Related` after the task is created."}),s.jsx("div",{className:"field",style:{marginTop:"8px"},children:s.jsx("input",{type:"file",multiple:!0,onChange:C=>{const W=Array.from(C.target.files||[]);W.length&&(kl(O=>[...O,...W]),C.currentTarget.value="")}})}),Wo.length?s.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:Wo.map((C,W)=>s.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",marginTop:"4px"},children:[s.jsxs("span",{className:"mono muted",style:{paddingRight:"10px"},children:[C.name," (",Math.round(C.size/1024)," KB)"]}),s.jsx("button",{className:"btn",onClick:()=>kl(O=>O.filter((fe,Se)=>Se!==W)),disabled:Ls||ha,children:"Remove"})]},`${C.name}_${C.size}_${W}`))}):null,ha?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Uploading attachments…"}):null,Mr?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Mr}):null,s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Draft (Markdown)"}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Prefilled from `docs/backlog/template.md` (editable). AI assist can also refine the draft."}),Tr?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Loading template…"}):null,_i?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:_i}):null,s.jsx("div",{className:"row",style:{marginTop:"10px",justifyContent:"flex-end",gap:"8px"},children:s.jsx("button",{className:"btn",onClick:()=>{Oo.trim()&&!globalThis.confirm("Reset the draft markdown to the backlog template?")||Nl({force:!0})},disabled:Ls||fs||Tr||!r,children:"Reset from template"})}),s.jsx("div",{className:"field",children:s.jsx("textarea",{value:Oo,onChange:C=>da(C.target.value),rows:10,className:"mono",placeholder:"(optional) full markdown draft"})}),s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"AI Assist (chat)"}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Use this to iteratively refine a backlog draft; assistant replies can also update the draft markdown."}),s.jsx(Ud,{messages:pa,className:"backlog_chat_thread_small",empty:s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No messages yet."})}),s.jsx("div",{style:{marginTop:"10px"},children:s.jsx(Bd,{value:ga,onChange:Hi,onSubmit:()=>void Gi(),placeholder:"Message to AI (e.g. refine acceptance criteria…)",disabled:!r||!Gs.trim(),busy:fs,rows:3,sendButtonClassName:"btn primary"})}),po?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:po}):null]}),s.jsx("button",{className:`advisor_toggle ${ze?"open":""}`,onClick:()=>{Oe(C=>{const W=!C;return W||Da(),W})},title:"Open backlog advisor (read-only)","aria-label":"Open backlog advisor",children:s.jsx("span",{className:"advisor_toggle_label",children:"Advisor"})}),ze?s.jsx("div",{className:"drawer_backdrop",onMouseDown:C=>{C.target===C.currentTarget&&(Da(),Oe(!1))},children:s.jsxs("div",{className:"drawer_panel",children:[s.jsxs("div",{className:"drawer_header",children:[s.jsxs("div",{className:"col",style:{gap:2},children:[s.jsx("div",{className:"drawer_title",children:"Backlog advisor"}),s.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["Read-only. Agent: ",u||"basic-agent"," • Using: ",o||"(gateway default)"," / ",l||"(gateway default)"]})]}),s.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[s.jsxs("button",{className:`btn btn_icon ${ue?"primary":""}`,onClick:()=>Ne(C=>!C),disabled:sn,title:ue?"Hide tool execution":"Show tool execution","aria-label":ue?"Hide tool execution":"Show tool execution",children:[s.jsx(On,{name:"terminal",size:16}),h?null:ue?"Tools on":"Tools"]}),s.jsx("button",{className:"btn",onClick:()=>xe([]),disabled:sn||!lt.length,children:"Clear"}),s.jsx("button",{className:"btn",onClick:()=>{Da(),Oe(!1)},children:"Close"})]})]}),s.jsxs("div",{className:"drawer_body",children:[s.jsx(Ud,{messages:lt,className:"drawer_chat_thread",messageProps:Qt.tts_supported&&r&&cn.trim()?{onSpeakToggle:va,getSpeakState:Kc,jsonCollapseAfterDepth:4}:{jsonCollapseAfterDepth:4},empty:s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Ask about the backlog, e.g. “What are the top 5 planned items to focus on next and why?”"})}),s.jsxs("div",{className:"drawer_footer",children:[s.jsx("input",{ref:Dn,type:"file",multiple:!0,style:{display:"none"},onChange:C=>{const W=Array.from(C.currentTarget.files||[]);C.currentTarget.value="",W.length&&Xc(W)}}),s.jsx(Bd,{ref:qt,value:Et,onChange:yt,onSubmit:()=>void Yc(),placeholder:"Message to backlog advisor…",disabled:!r,busy:sn||Qt.voice_ptt_busy,rows:3,sendButtonClassName:"btn primary",busyLabel:Qt.voice_ptt_busy?"Transcribing…":"Thinking…",actions:s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:`btn btn_icon voice_btn${Qt.voice_ptt_recording?" danger":""}`,type:"button",disabled:!r||!cn.trim()||sn||Qt.voice_ptt_busy||!Qt.voice_ptt_supported,title:Qt.voice_ptt_supported?Qt.voice_ptt_busy?"Transcribing…":Qt.voice_ptt_recording?"Recording… release to transcribe":"Hold to talk (record + transcribe)":"Voice recording is not supported in this browser","aria-label":"Voice input",onPointerDown:C=>{var W,O;if(!(!r||!cn.trim()||sn||Qt.voice_ptt_busy||!Qt.voice_ptt_supported)){C.preventDefault();try{(O=(W=C.currentTarget)==null?void 0:W.setPointerCapture)==null||O.call(W,C.pointerId)}catch{}Qt.start_voice_ptt_recording()}},onPointerUp:C=>{C.preventDefault(),Qt.stop_voice_ptt_recording()},onPointerCancel:C=>{C.preventDefault(),Qt.stop_voice_ptt_recording()},children:[s.jsx(On,{name:Qt.voice_ptt_recording?"x":"mic",size:16}),h?null:Qt.voice_ptt_busy?"Transcribing…":Qt.voice_ptt_recording?"Recording…":"Voice"]}),s.jsxs("button",{className:"btn btn_icon",type:"button",onClick:()=>{var C;return(C=Dn.current)==null?void 0:C.click()},disabled:sn,title:"Attach a local file to your message","aria-label":"Attach file",children:[s.jsx(On,{name:"paperclip",size:16}),h?null:"Attach"]})]})}),$t.length?s.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Last attached: ",$t[0]]}):null,Xt?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Xt}):null,Sn?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Sn}):null,r?null:s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Connect the gateway in Settings to use the advisor."})]})]})]})}):null]})}function Cs(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let r=0,o;r<e.length;r++)(o=Cs(e[r]))!==""&&(t+=(t&&" ")+o);else for(let r in e)e[r]&&(t+=(t&&" ")+r);return t}var sm={exports:{}},im={},om={exports:{}},am={};/**
|
|
101
|
+
* @license React
|
|
102
|
+
* use-sync-external-store-shim.production.js
|
|
103
|
+
*
|
|
104
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
105
|
+
*
|
|
106
|
+
* This source code is licensed under the MIT license found in the
|
|
107
|
+
* LICENSE file in the root directory of this source tree.
|
|
108
|
+
*/var Dp;function $w(){if(Dp)return am;Dp=1;var e=Yu();function t(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}var r=typeof Object.is=="function"?Object.is:t,o=e.useState,l=e.useEffect,u=e.useLayoutEffect,c=e.useDebugValue;function d(x,v){var b=v(),j=o({inst:{value:b,getSnapshot:v}}),S=j[0].inst,T=j[1];return u(function(){S.value=b,S.getSnapshot=v,h(S)&&T({inst:S})},[x,b,v]),l(function(){return h(S)&&T({inst:S}),x(function(){h(S)&&T({inst:S})})},[x]),c(b),b}function h(x){var v=x.getSnapshot;x=x.value;try{var b=v();return!r(x,b)}catch{return!0}}function _(x,v){return v()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?_:d;return am.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,am}var Bp;function Aw(){return Bp||(Bp=1,om.exports=$w()),om.exports}/**
|
|
109
|
+
* @license React
|
|
110
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
111
|
+
*
|
|
112
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
113
|
+
*
|
|
114
|
+
* This source code is licensed under the MIT license found in the
|
|
115
|
+
* LICENSE file in the root directory of this source tree.
|
|
116
|
+
*/var Up;function Tw(){if(Up)return im;Up=1;var e=Yu(),t=Aw();function r(_,g){return _===g&&(_!==0||1/_===1/g)||_!==_&&g!==g}var o=typeof Object.is=="function"?Object.is:r,l=t.useSyncExternalStore,u=e.useRef,c=e.useEffect,d=e.useMemo,h=e.useDebugValue;return im.useSyncExternalStoreWithSelector=function(_,g,x,v,b){var j=u(null);if(j.current===null){var S={hasValue:!1,value:null};j.current=S}else S=j.current;j=d(function(){function M(ne){if(!D){if(D=!0,L=ne,ne=v(ne),b!==void 0&&S.hasValue){var Y=S.value;if(b(Y,ne))return I=Y}return I=ne}if(Y=I,o(L,ne))return Y;var oe=v(ne);return b!==void 0&&b(Y,oe)?(L=ne,Y):(L=ne,I=oe)}var D=!1,L,I,G=x===void 0?null:x;return[function(){return M(g())},G===null?void 0:function(){return M(G())}]},[g,x,v,b]);var T=l(_,j[0],j[1]);return c(function(){S.hasValue=!0,S.value=T},[T]),h(T),T},im}var Wp;function Mw(){return Wp||(Wp=1,sm.exports=Tw()),sm.exports}var zw=Mw();const Rw=th(zw),Lw={},Hp=e=>{let t;const r=new Set,o=(g,x)=>{const v=typeof g=="function"?g(t):g;if(!Object.is(v,t)){const b=t;t=x??(typeof v!="object"||v===null)?v:Object.assign({},t,v),r.forEach(j=>j(t,b))}},l=()=>t,h={setState:o,getState:l,getInitialState:()=>_,subscribe:g=>(r.add(g),()=>r.delete(g)),destroy:()=>{(Lw?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},_=t=e(o,l,h);return h},Pw=e=>e?Hp(e):Hp,{useDebugValue:Iw}=Ee,{useSyncExternalStoreWithSelector:Fw}=Rw,Ow=e=>e;function j_(e,t=Ow,r){const o=Fw(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return Iw(o),o}const Vp=(e,t)=>{const r=Pw(e),o=(l,u=t)=>j_(r,l,u);return Object.assign(o,r),o},Dw=(e,t)=>e?Vp(e,t):Vp;function ws(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,l]of e)if(!Object.is(l,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const o of r)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}var Bw={value:()=>{}};function lf(){for(var e=0,t=arguments.length,r={},o;e<t;++e){if(!(o=arguments[e]+"")||o in r||/[\s.]/.test(o))throw new Error("illegal type: "+o);r[o]=[]}return new Wd(r)}function Wd(e){this._=e}function Uw(e,t){return e.trim().split(/^|\s+/).map(function(r){var o="",l=r.indexOf(".");if(l>=0&&(o=r.slice(l+1),r=r.slice(0,l)),r&&!t.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:o}})}Wd.prototype=lf.prototype={constructor:Wd,on:function(e,t){var r=this._,o=Uw(e+"",r),l,u=-1,c=o.length;if(arguments.length<2){for(;++u<c;)if((l=(e=o[u]).type)&&(l=Ww(r[l],e.name)))return l;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++u<c;)if(l=(e=o[u]).type)r[l]=qp(r[l],e.name,t);else if(t==null)for(l in r)r[l]=qp(r[l],e.name,null);return this},copy:function(){var e={},t=this._;for(var r in t)e[r]=t[r].slice();return new Wd(e)},call:function(e,t){if((l=arguments.length-2)>0)for(var r=new Array(l),o=0,l,u;o<l;++o)r[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(u=this._[e],o=0,l=u.length;o<l;++o)u[o].value.apply(t,r)},apply:function(e,t,r){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],l=0,u=o.length;l<u;++l)o[l].value.apply(t,r)}};function Ww(e,t){for(var r=0,o=e.length,l;r<o;++r)if((l=e[r]).name===t)return l.value}function qp(e,t,r){for(var o=0,l=e.length;o<l;++o)if(e[o].name===t){e[o]=Bw,e=e.slice(0,o).concat(e.slice(o+1));break}return r!=null&&e.push({name:t,value:r}),e}var Rm="http://www.w3.org/1999/xhtml";const Gp={svg:"http://www.w3.org/2000/svg",xhtml:Rm,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function cf(e){var t=e+="",r=t.indexOf(":");return r>=0&&(t=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),Gp.hasOwnProperty(t)?{space:Gp[t],local:e}:e}function Hw(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===Rm&&t.documentElement.namespaceURI===Rm?t.createElement(e):t.createElementNS(r,e)}}function Vw(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function k_(e){var t=cf(e);return(t.local?Vw:Hw)(t)}function qw(){}function ih(e){return e==null?qw:function(){return this.querySelector(e)}}function Gw(e){typeof e!="function"&&(e=ih(e));for(var t=this._groups,r=t.length,o=new Array(r),l=0;l<r;++l)for(var u=t[l],c=u.length,d=o[l]=new Array(c),h,_,g=0;g<c;++g)(h=u[g])&&(_=e.call(h,h.__data__,g,u))&&("__data__"in h&&(_.__data__=h.__data__),d[g]=_);return new zi(o,this._parents)}function Yw(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Xw(){return[]}function N_(e){return e==null?Xw:function(){return this.querySelectorAll(e)}}function Kw(e){return function(){return Yw(e.apply(this,arguments))}}function Jw(e){typeof e=="function"?e=Kw(e):e=N_(e);for(var t=this._groups,r=t.length,o=[],l=[],u=0;u<r;++u)for(var c=t[u],d=c.length,h,_=0;_<d;++_)(h=c[_])&&(o.push(e.call(h,h.__data__,_,c)),l.push(h));return new zi(o,l)}function C_(e){return function(){return this.matches(e)}}function E_(e){return function(t){return t.matches(e)}}var Qw=Array.prototype.find;function Zw(e){return function(){return Qw.call(this.children,e)}}function e0(){return this.firstElementChild}function t0(e){return this.select(e==null?e0:Zw(typeof e=="function"?e:E_(e)))}var n0=Array.prototype.filter;function r0(){return Array.from(this.children)}function s0(e){return function(){return n0.call(this.children,e)}}function i0(e){return this.selectAll(e==null?r0:s0(typeof e=="function"?e:E_(e)))}function o0(e){typeof e!="function"&&(e=C_(e));for(var t=this._groups,r=t.length,o=new Array(r),l=0;l<r;++l)for(var u=t[l],c=u.length,d=o[l]=[],h,_=0;_<c;++_)(h=u[_])&&e.call(h,h.__data__,_,u)&&d.push(h);return new zi(o,this._parents)}function $_(e){return new Array(e.length)}function a0(){return new zi(this._enter||this._groups.map($_),this._parents)}function Xd(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Xd.prototype={constructor:Xd,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function l0(e){return function(){return e}}function c0(e,t,r,o,l,u){for(var c=0,d,h=t.length,_=u.length;c<_;++c)(d=t[c])?(d.__data__=u[c],o[c]=d):r[c]=new Xd(e,u[c]);for(;c<h;++c)(d=t[c])&&(l[c]=d)}function u0(e,t,r,o,l,u,c){var d,h,_=new Map,g=t.length,x=u.length,v=new Array(g),b;for(d=0;d<g;++d)(h=t[d])&&(v[d]=b=c.call(h,h.__data__,d,t)+"",_.has(b)?l[d]=h:_.set(b,h));for(d=0;d<x;++d)b=c.call(e,u[d],d,u)+"",(h=_.get(b))?(o[d]=h,h.__data__=u[d],_.delete(b)):r[d]=new Xd(e,u[d]);for(d=0;d<g;++d)(h=t[d])&&_.get(v[d])===h&&(l[d]=h)}function d0(e){return e.__data__}function f0(e,t){if(!arguments.length)return Array.from(this,d0);var r=t?u0:c0,o=this._parents,l=this._groups;typeof e!="function"&&(e=l0(e));for(var u=l.length,c=new Array(u),d=new Array(u),h=new Array(u),_=0;_<u;++_){var g=o[_],x=l[_],v=x.length,b=m0(e.call(g,g&&g.__data__,_,o)),j=b.length,S=d[_]=new Array(j),T=c[_]=new Array(j),M=h[_]=new Array(v);r(g,x,S,T,M,b,t);for(var D=0,L=0,I,G;D<j;++D)if(I=S[D]){for(D>=L&&(L=D+1);!(G=T[L])&&++L<j;);I._next=G||null}}return c=new zi(c,o),c._enter=d,c._exit=h,c}function m0(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function h0(){return new zi(this._exit||this._groups.map($_),this._parents)}function p0(e,t,r){var o=this.enter(),l=this,u=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(l=t(l),l&&(l=l.selection())),r==null?u.remove():r(u),o&&l?o.merge(l).order():l}function g0(e){for(var t=e.selection?e.selection():e,r=this._groups,o=t._groups,l=r.length,u=o.length,c=Math.min(l,u),d=new Array(l),h=0;h<c;++h)for(var _=r[h],g=o[h],x=_.length,v=d[h]=new Array(x),b,j=0;j<x;++j)(b=_[j]||g[j])&&(v[j]=b);for(;h<l;++h)d[h]=r[h];return new zi(d,this._parents)}function _0(){for(var e=this._groups,t=-1,r=e.length;++t<r;)for(var o=e[t],l=o.length-1,u=o[l],c;--l>=0;)(c=o[l])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function y0(e){e||(e=x0);function t(x,v){return x&&v?e(x.__data__,v.__data__):!x-!v}for(var r=this._groups,o=r.length,l=new Array(o),u=0;u<o;++u){for(var c=r[u],d=c.length,h=l[u]=new Array(d),_,g=0;g<d;++g)(_=c[g])&&(h[g]=_);h.sort(t)}return new zi(l,this._parents).order()}function x0(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function v0(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function w0(){return Array.from(this)}function b0(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var o=e[t],l=0,u=o.length;l<u;++l){var c=o[l];if(c)return c}return null}function S0(){let e=0;for(const t of this)++e;return e}function j0(){return!this.node()}function k0(e){for(var t=this._groups,r=0,o=t.length;r<o;++r)for(var l=t[r],u=0,c=l.length,d;u<c;++u)(d=l[u])&&e.call(d,d.__data__,u,l);return this}function N0(e){return function(){this.removeAttribute(e)}}function C0(e){return function(){this.removeAttributeNS(e.space,e.local)}}function E0(e,t){return function(){this.setAttribute(e,t)}}function $0(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function A0(e,t){return function(){var r=t.apply(this,arguments);r==null?this.removeAttribute(e):this.setAttribute(e,r)}}function T0(e,t){return function(){var r=t.apply(this,arguments);r==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,r)}}function M0(e,t){var r=cf(e);if(arguments.length<2){var o=this.node();return r.local?o.getAttributeNS(r.space,r.local):o.getAttribute(r)}return this.each((t==null?r.local?C0:N0:typeof t=="function"?r.local?T0:A0:r.local?$0:E0)(r,t))}function A_(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function z0(e){return function(){this.style.removeProperty(e)}}function R0(e,t,r){return function(){this.style.setProperty(e,t,r)}}function L0(e,t,r){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,r)}}function P0(e,t,r){return arguments.length>1?this.each((t==null?z0:typeof t=="function"?L0:R0)(e,t,r??"")):Vc(this.node(),e)}function Vc(e,t){return e.style.getPropertyValue(t)||A_(e).getComputedStyle(e,null).getPropertyValue(t)}function I0(e){return function(){delete this[e]}}function F0(e,t){return function(){this[e]=t}}function O0(e,t){return function(){var r=t.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function D0(e,t){return arguments.length>1?this.each((t==null?I0:typeof t=="function"?O0:F0)(e,t)):this.node()[e]}function T_(e){return e.trim().split(/^|\s+/)}function oh(e){return e.classList||new M_(e)}function M_(e){this._node=e,this._names=T_(e.getAttribute("class")||"")}M_.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function z_(e,t){for(var r=oh(e),o=-1,l=t.length;++o<l;)r.add(t[o])}function R_(e,t){for(var r=oh(e),o=-1,l=t.length;++o<l;)r.remove(t[o])}function B0(e){return function(){z_(this,e)}}function U0(e){return function(){R_(this,e)}}function W0(e,t){return function(){(t.apply(this,arguments)?z_:R_)(this,e)}}function H0(e,t){var r=T_(e+"");if(arguments.length<2){for(var o=oh(this.node()),l=-1,u=r.length;++l<u;)if(!o.contains(r[l]))return!1;return!0}return this.each((typeof t=="function"?W0:t?B0:U0)(r,t))}function V0(){this.textContent=""}function q0(e){return function(){this.textContent=e}}function G0(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Y0(e){return arguments.length?this.each(e==null?V0:(typeof e=="function"?G0:q0)(e)):this.node().textContent}function X0(){this.innerHTML=""}function K0(e){return function(){this.innerHTML=e}}function J0(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Q0(e){return arguments.length?this.each(e==null?X0:(typeof e=="function"?J0:K0)(e)):this.node().innerHTML}function Z0(){this.nextSibling&&this.parentNode.appendChild(this)}function eb(){return this.each(Z0)}function tb(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function nb(){return this.each(tb)}function rb(e){var t=typeof e=="function"?e:k_(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function sb(){return null}function ib(e,t){var r=typeof e=="function"?e:k_(e),o=t==null?sb:typeof t=="function"?t:ih(t);return this.select(function(){return this.insertBefore(r.apply(this,arguments),o.apply(this,arguments)||null)})}function ob(){var e=this.parentNode;e&&e.removeChild(this)}function ab(){return this.each(ob)}function lb(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function cb(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ub(e){return this.select(e?cb:lb)}function db(e){return arguments.length?this.property("__data__",e):this.node().__data__}function fb(e){return function(t){e.call(this,t,this.__data__)}}function mb(e){return e.trim().split(/^|\s+/).map(function(t){var r="",o=t.indexOf(".");return o>=0&&(r=t.slice(o+1),t=t.slice(0,o)),{type:t,name:r}})}function hb(e){return function(){var t=this.__on;if(t){for(var r=0,o=-1,l=t.length,u;r<l;++r)u=t[r],(!e.type||u.type===e.type)&&u.name===e.name?this.removeEventListener(u.type,u.listener,u.options):t[++o]=u;++o?t.length=o:delete this.__on}}}function pb(e,t,r){return function(){var o=this.__on,l,u=fb(t);if(o){for(var c=0,d=o.length;c<d;++c)if((l=o[c]).type===e.type&&l.name===e.name){this.removeEventListener(l.type,l.listener,l.options),this.addEventListener(l.type,l.listener=u,l.options=r),l.value=t;return}}this.addEventListener(e.type,u,r),l={type:e.type,name:e.name,value:t,listener:u,options:r},o?o.push(l):this.__on=[l]}}function gb(e,t,r){var o=mb(e+""),l,u=o.length,c;if(arguments.length<2){var d=this.node().__on;if(d){for(var h=0,_=d.length,g;h<_;++h)for(l=0,g=d[h];l<u;++l)if((c=o[l]).type===g.type&&c.name===g.name)return g.value}return}for(d=t?pb:hb,l=0;l<u;++l)this.each(d(o[l],t,r));return this}function L_(e,t,r){var o=A_(e),l=o.CustomEvent;typeof l=="function"?l=new l(t,r):(l=o.document.createEvent("Event"),r?(l.initEvent(t,r.bubbles,r.cancelable),l.detail=r.detail):l.initEvent(t,!1,!1)),e.dispatchEvent(l)}function _b(e,t){return function(){return L_(this,e,t)}}function yb(e,t){return function(){return L_(this,e,t.apply(this,arguments))}}function xb(e,t){return this.each((typeof t=="function"?yb:_b)(e,t))}function*vb(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var o=e[t],l=0,u=o.length,c;l<u;++l)(c=o[l])&&(yield c)}var P_=[null];function zi(e,t){this._groups=e,this._parents=t}function Xu(){return new zi([[document.documentElement]],P_)}function wb(){return this}zi.prototype=Xu.prototype={constructor:zi,select:Gw,selectAll:Jw,selectChild:t0,selectChildren:i0,filter:o0,data:f0,enter:a0,exit:h0,join:p0,merge:g0,selection:wb,order:_0,sort:y0,call:v0,nodes:w0,node:b0,size:S0,empty:j0,each:k0,attr:M0,style:P0,property:D0,classed:H0,text:Y0,html:Q0,raise:eb,lower:nb,append:rb,insert:ib,remove:ab,clone:ub,datum:db,on:gb,dispatch:xb,[Symbol.iterator]:vb};function io(e){return typeof e=="string"?new zi([[document.querySelector(e)]],[document.documentElement]):new zi([[e]],P_)}function bb(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Mo(e,t){if(e=bb(e),t===void 0&&(t=e.currentTarget),t){var r=t.ownerSVGElement||t;if(r.createSVGPoint){var o=r.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var l=t.getBoundingClientRect();return[e.clientX-l.left-t.clientLeft,e.clientY-l.top-t.clientTop]}}return[e.pageX,e.pageY]}const Sb={passive:!1},Iu={capture:!0,passive:!1};function lm(e){e.stopImmediatePropagation()}function Bc(e){e.preventDefault(),e.stopImmediatePropagation()}function I_(e){var t=e.document.documentElement,r=io(e).on("dragstart.drag",Bc,Iu);"onselectstart"in t?r.on("selectstart.drag",Bc,Iu):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function F_(e,t){var r=e.document.documentElement,o=io(e).on("dragstart.drag",null);t&&(o.on("click.drag",Bc,Iu),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in r?o.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}const Ed=e=>()=>e;function Lm(e,{sourceEvent:t,subject:r,target:o,identifier:l,active:u,x:c,y:d,dx:h,dy:_,dispatch:g}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:l,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:d,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:_,enumerable:!0,configurable:!0},_:{value:g}})}Lm.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function jb(e){return!e.ctrlKey&&!e.button}function kb(){return this.parentNode}function Nb(e,t){return t??{x:e.x,y:e.y}}function Cb(){return navigator.maxTouchPoints||"ontouchstart"in this}function Eb(){var e=jb,t=kb,r=Nb,o=Cb,l={},u=lf("start","drag","end"),c=0,d,h,_,g,x=0;function v(I){I.on("mousedown.drag",b).filter(o).on("touchstart.drag",T).on("touchmove.drag",M,Sb).on("touchend.drag touchcancel.drag",D).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(I,G){if(!(g||!e.call(this,I,G))){var ne=L(this,t.call(this,I,G),I,G,"mouse");ne&&(io(I.view).on("mousemove.drag",j,Iu).on("mouseup.drag",S,Iu),I_(I.view),lm(I),_=!1,d=I.clientX,h=I.clientY,ne("start",I))}}function j(I){if(Bc(I),!_){var G=I.clientX-d,ne=I.clientY-h;_=G*G+ne*ne>x}l.mouse("drag",I)}function S(I){io(I.view).on("mousemove.drag mouseup.drag",null),F_(I.view,_),Bc(I),l.mouse("end",I)}function T(I,G){if(e.call(this,I,G)){var ne=I.changedTouches,Y=t.call(this,I,G),oe=ne.length,le,_e;for(le=0;le<oe;++le)(_e=L(this,Y,I,G,ne[le].identifier,ne[le]))&&(lm(I),_e("start",I,ne[le]))}}function M(I){var G=I.changedTouches,ne=G.length,Y,oe;for(Y=0;Y<ne;++Y)(oe=l[G[Y].identifier])&&(Bc(I),oe("drag",I,G[Y]))}function D(I){var G=I.changedTouches,ne=G.length,Y,oe;for(g&&clearTimeout(g),g=setTimeout(function(){g=null},500),Y=0;Y<ne;++Y)(oe=l[G[Y].identifier])&&(lm(I),oe("end",I,G[Y]))}function L(I,G,ne,Y,oe,le){var _e=u.copy(),Te=Mo(le||ne,G),$e,K,U;if((U=r.call(I,new Lm("beforestart",{sourceEvent:ne,target:v,identifier:oe,active:c,x:Te[0],y:Te[1],dx:0,dy:0,dispatch:_e}),Y))!=null)return $e=U.x-Te[0]||0,K=U.y-Te[1]||0,function X(V,J,k){var z=Te,F;switch(V){case"start":l[oe]=X,F=c++;break;case"end":delete l[oe],--c;case"drag":Te=Mo(k||J,G),F=c;break}_e.call(V,I,new Lm(V,{sourceEvent:J,subject:U,target:v,identifier:oe,active:F,x:Te[0]+$e,y:Te[1]+K,dx:Te[0]-z[0],dy:Te[1]-z[1],dispatch:_e}),Y)}}return v.filter=function(I){return arguments.length?(e=typeof I=="function"?I:Ed(!!I),v):e},v.container=function(I){return arguments.length?(t=typeof I=="function"?I:Ed(I),v):t},v.subject=function(I){return arguments.length?(r=typeof I=="function"?I:Ed(I),v):r},v.touchable=function(I){return arguments.length?(o=typeof I=="function"?I:Ed(!!I),v):o},v.on=function(){var I=u.on.apply(u,arguments);return I===u?v:I},v.clickDistance=function(I){return arguments.length?(x=(I=+I)*I,v):Math.sqrt(x)},v}function ah(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function O_(e,t){var r=Object.create(e.prototype);for(var o in t)r[o]=t[o];return r}function Ku(){}var Fu=.7,Kd=1/Fu,Uc="\\s*([+-]?\\d+)\\s*",Ou="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",la="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",$b=/^#([0-9a-f]{3,8})$/,Ab=new RegExp(`^rgb\\(${Uc},${Uc},${Uc}\\)$`),Tb=new RegExp(`^rgb\\(${la},${la},${la}\\)$`),Mb=new RegExp(`^rgba\\(${Uc},${Uc},${Uc},${Ou}\\)$`),zb=new RegExp(`^rgba\\(${la},${la},${la},${Ou}\\)$`),Rb=new RegExp(`^hsl\\(${Ou},${la},${la}\\)$`),Lb=new RegExp(`^hsla\\(${Ou},${la},${la},${Ou}\\)$`),Yp={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ah(Ku,Du,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Xp,formatHex:Xp,formatHex8:Pb,formatHsl:Ib,formatRgb:Kp,toString:Kp});function Xp(){return this.rgb().formatHex()}function Pb(){return this.rgb().formatHex8()}function Ib(){return D_(this).formatHsl()}function Kp(){return this.rgb().formatRgb()}function Du(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=$b.exec(e))?(r=t[1].length,t=parseInt(t[1],16),r===6?Jp(t):r===3?new pi(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?$d(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?$d(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Ab.exec(e))?new pi(t[1],t[2],t[3],1):(t=Tb.exec(e))?new pi(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Mb.exec(e))?$d(t[1],t[2],t[3],t[4]):(t=zb.exec(e))?$d(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Rb.exec(e))?eg(t[1],t[2]/100,t[3]/100,1):(t=Lb.exec(e))?eg(t[1],t[2]/100,t[3]/100,t[4]):Yp.hasOwnProperty(e)?Jp(Yp[e]):e==="transparent"?new pi(NaN,NaN,NaN,0):null}function Jp(e){return new pi(e>>16&255,e>>8&255,e&255,1)}function $d(e,t,r,o){return o<=0&&(e=t=r=NaN),new pi(e,t,r,o)}function Fb(e){return e instanceof Ku||(e=Du(e)),e?(e=e.rgb(),new pi(e.r,e.g,e.b,e.opacity)):new pi}function Pm(e,t,r,o){return arguments.length===1?Fb(e):new pi(e,t,r,o??1)}function pi(e,t,r,o){this.r=+e,this.g=+t,this.b=+r,this.opacity=+o}ah(pi,Pm,O_(Ku,{brighter(e){return e=e==null?Kd:Math.pow(Kd,e),new pi(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,e),new pi(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new pi(Kl(this.r),Kl(this.g),Kl(this.b),Jd(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Qp,formatHex:Qp,formatHex8:Ob,formatRgb:Zp,toString:Zp}));function Qp(){return`#${Yl(this.r)}${Yl(this.g)}${Yl(this.b)}`}function Ob(){return`#${Yl(this.r)}${Yl(this.g)}${Yl(this.b)}${Yl((isNaN(this.opacity)?1:this.opacity)*255)}`}function Zp(){const e=Jd(this.opacity);return`${e===1?"rgb(":"rgba("}${Kl(this.r)}, ${Kl(this.g)}, ${Kl(this.b)}${e===1?")":`, ${e})`}`}function Jd(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Kl(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Yl(e){return e=Kl(e),(e<16?"0":"")+e.toString(16)}function eg(e,t,r,o){return o<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new zo(e,t,r,o)}function D_(e){if(e instanceof zo)return new zo(e.h,e.s,e.l,e.opacity);if(e instanceof Ku||(e=Du(e)),!e)return new zo;if(e instanceof zo)return e;e=e.rgb();var t=e.r/255,r=e.g/255,o=e.b/255,l=Math.min(t,r,o),u=Math.max(t,r,o),c=NaN,d=u-l,h=(u+l)/2;return d?(t===u?c=(r-o)/d+(r<o)*6:r===u?c=(o-t)/d+2:c=(t-r)/d+4,d/=h<.5?u+l:2-u-l,c*=60):d=h>0&&h<1?0:c,new zo(c,d,h,e.opacity)}function Db(e,t,r,o){return arguments.length===1?D_(e):new zo(e,t,r,o??1)}function zo(e,t,r,o){this.h=+e,this.s=+t,this.l=+r,this.opacity=+o}ah(zo,Db,O_(Ku,{brighter(e){return e=e==null?Kd:Math.pow(Kd,e),new zo(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,e),new zo(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,o=r+(r<.5?r:1-r)*t,l=2*r-o;return new pi(cm(e>=240?e-240:e+120,l,o),cm(e,l,o),cm(e<120?e+240:e-120,l,o),this.opacity)},clamp(){return new zo(tg(this.h),Ad(this.s),Ad(this.l),Jd(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Jd(this.opacity);return`${e===1?"hsl(":"hsla("}${tg(this.h)}, ${Ad(this.s)*100}%, ${Ad(this.l)*100}%${e===1?")":`, ${e})`}`}}));function tg(e){return e=(e||0)%360,e<0?e+360:e}function Ad(e){return Math.max(0,Math.min(1,e||0))}function cm(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const B_=e=>()=>e;function Bb(e,t){return function(r){return e+r*t}}function Ub(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(o){return Math.pow(e+o*t,r)}}function Wb(e){return(e=+e)==1?U_:function(t,r){return r-t?Ub(t,r,e):B_(isNaN(t)?r:t)}}function U_(e,t){var r=t-e;return r?Bb(e,r):B_(isNaN(e)?t:e)}const ng=(function e(t){var r=Wb(t);function o(l,u){var c=r((l=Pm(l)).r,(u=Pm(u)).r),d=r(l.g,u.g),h=r(l.b,u.b),_=U_(l.opacity,u.opacity);return function(g){return l.r=c(g),l.g=d(g),l.b=h(g),l.opacity=_(g),l+""}}return o.gamma=e,o})(1);function ml(e,t){return e=+e,t=+t,function(r){return e*(1-r)+t*r}}var Im=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,um=new RegExp(Im.source,"g");function Hb(e){return function(){return e}}function Vb(e){return function(t){return e(t)+""}}function qb(e,t){var r=Im.lastIndex=um.lastIndex=0,o,l,u,c=-1,d=[],h=[];for(e=e+"",t=t+"";(o=Im.exec(e))&&(l=um.exec(t));)(u=l.index)>r&&(u=t.slice(r,u),d[c]?d[c]+=u:d[++c]=u),(o=o[0])===(l=l[0])?d[c]?d[c]+=l:d[++c]=l:(d[++c]=null,h.push({i:c,x:ml(o,l)})),r=um.lastIndex;return r<t.length&&(u=t.slice(r),d[c]?d[c]+=u:d[++c]=u),d.length<2?h[0]?Vb(h[0].x):Hb(t):(t=h.length,function(_){for(var g=0,x;g<t;++g)d[(x=h[g]).i]=x.x(_);return d.join("")})}var rg=180/Math.PI,Fm={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function W_(e,t,r,o,l,u){var c,d,h;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(h=e*r+t*o)&&(r-=e*h,o-=t*h),(d=Math.sqrt(r*r+o*o))&&(r/=d,o/=d,h/=d),e*o<t*r&&(e=-e,t=-t,h=-h,c=-c),{translateX:l,translateY:u,rotate:Math.atan2(t,e)*rg,skewX:Math.atan(h)*rg,scaleX:c,scaleY:d}}var Td;function Gb(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fm:W_(t.a,t.b,t.c,t.d,t.e,t.f)}function Yb(e){return e==null||(Td||(Td=document.createElementNS("http://www.w3.org/2000/svg","g")),Td.setAttribute("transform",e),!(e=Td.transform.baseVal.consolidate()))?Fm:(e=e.matrix,W_(e.a,e.b,e.c,e.d,e.e,e.f))}function H_(e,t,r,o){function l(_){return _.length?_.pop()+" ":""}function u(_,g,x,v,b,j){if(_!==x||g!==v){var S=b.push("translate(",null,t,null,r);j.push({i:S-4,x:ml(_,x)},{i:S-2,x:ml(g,v)})}else(x||v)&&b.push("translate("+x+t+v+r)}function c(_,g,x,v){_!==g?(_-g>180?g+=360:g-_>180&&(_+=360),v.push({i:x.push(l(x)+"rotate(",null,o)-2,x:ml(_,g)})):g&&x.push(l(x)+"rotate("+g+o)}function d(_,g,x,v){_!==g?v.push({i:x.push(l(x)+"skewX(",null,o)-2,x:ml(_,g)}):g&&x.push(l(x)+"skewX("+g+o)}function h(_,g,x,v,b,j){if(_!==x||g!==v){var S=b.push(l(b)+"scale(",null,",",null,")");j.push({i:S-4,x:ml(_,x)},{i:S-2,x:ml(g,v)})}else(x!==1||v!==1)&&b.push(l(b)+"scale("+x+","+v+")")}return function(_,g){var x=[],v=[];return _=e(_),g=e(g),u(_.translateX,_.translateY,g.translateX,g.translateY,x,v),c(_.rotate,g.rotate,x,v),d(_.skewX,g.skewX,x,v),h(_.scaleX,_.scaleY,g.scaleX,g.scaleY,x,v),_=g=null,function(b){for(var j=-1,S=v.length,T;++j<S;)x[(T=v[j]).i]=T.x(b);return x.join("")}}}var Xb=H_(Gb,"px, ","px)","deg)"),Kb=H_(Yb,", ",")",")"),Jb=1e-12;function sg(e){return((e=Math.exp(e))+1/e)/2}function Qb(e){return((e=Math.exp(e))-1/e)/2}function Zb(e){return((e=Math.exp(2*e))-1)/(e+1)}const eS=(function e(t,r,o){function l(u,c){var d=u[0],h=u[1],_=u[2],g=c[0],x=c[1],v=c[2],b=g-d,j=x-h,S=b*b+j*j,T,M;if(S<Jb)M=Math.log(v/_)/t,T=function(Y){return[d+Y*b,h+Y*j,_*Math.exp(t*Y*M)]};else{var D=Math.sqrt(S),L=(v*v-_*_+o*S)/(2*_*r*D),I=(v*v-_*_-o*S)/(2*v*r*D),G=Math.log(Math.sqrt(L*L+1)-L),ne=Math.log(Math.sqrt(I*I+1)-I);M=(ne-G)/t,T=function(Y){var oe=Y*M,le=sg(G),_e=_/(r*D)*(le*Zb(t*oe+G)-Qb(G));return[d+_e*b,h+_e*j,_*le/sg(t*oe+G)]}}return T.duration=M*1e3*t/Math.SQRT2,T}return l.rho=function(u){var c=Math.max(.001,+u),d=c*c,h=d*d;return e(c,d,h)},l})(Math.SQRT2,2,4);var qc=0,Ru=0,ju=0,V_=1e3,Qd,Lu,Zd=0,Ql=0,uf=0,Bu=typeof performance=="object"&&performance.now?performance:Date,q_=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function lh(){return Ql||(q_(tS),Ql=Bu.now()+uf)}function tS(){Ql=0}function ef(){this._call=this._time=this._next=null}ef.prototype=G_.prototype={constructor:ef,restart:function(e,t,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?lh():+r)+(t==null?0:+t),!this._next&&Lu!==this&&(Lu?Lu._next=this:Qd=this,Lu=this),this._call=e,this._time=r,Om()},stop:function(){this._call&&(this._call=null,this._time=1/0,Om())}};function G_(e,t,r){var o=new ef;return o.restart(e,t,r),o}function nS(){lh(),++qc;for(var e=Qd,t;e;)(t=Ql-e._time)>=0&&e._call.call(void 0,t),e=e._next;--qc}function ig(){Ql=(Zd=Bu.now())+uf,qc=Ru=0;try{nS()}finally{qc=0,sS(),Ql=0}}function rS(){var e=Bu.now(),t=e-Zd;t>V_&&(uf-=t,Zd=e)}function sS(){for(var e,t=Qd,r,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(r=t._next,t._next=null,t=e?e._next=r:Qd=r);Lu=e,Om(o)}function Om(e){if(!qc){Ru&&(Ru=clearTimeout(Ru));var t=e-Ql;t>24?(e<1/0&&(Ru=setTimeout(ig,e-Bu.now()-uf)),ju&&(ju=clearInterval(ju))):(ju||(Zd=Bu.now(),ju=setInterval(rS,V_)),qc=1,q_(ig))}}function og(e,t,r){var o=new ef;return t=t==null?0:+t,o.restart(l=>{o.stop(),e(l+t)},t,r),o}var iS=lf("start","end","cancel","interrupt"),oS=[],Y_=0,ag=1,Dm=2,Hd=3,lg=4,Bm=5,Vd=6;function df(e,t,r,o,l,u){var c=e.__transition;if(!c)e.__transition={};else if(r in c)return;aS(e,r,{name:t,index:o,group:l,on:iS,tween:oS,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Y_})}function ch(e,t){var r=Po(e,t);if(r.state>Y_)throw new Error("too late; already scheduled");return r}function ca(e,t){var r=Po(e,t);if(r.state>Hd)throw new Error("too late; already running");return r}function Po(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw new Error("transition not found");return r}function aS(e,t,r){var o=e.__transition,l;o[t]=r,r.timer=G_(u,0,r.time);function u(_){r.state=ag,r.timer.restart(c,r.delay,r.time),r.delay<=_&&c(_-r.delay)}function c(_){var g,x,v,b;if(r.state!==ag)return h();for(g in o)if(b=o[g],b.name===r.name){if(b.state===Hd)return og(c);b.state===lg?(b.state=Vd,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete o[g]):+g<t&&(b.state=Vd,b.timer.stop(),b.on.call("cancel",e,e.__data__,b.index,b.group),delete o[g])}if(og(function(){r.state===Hd&&(r.state=lg,r.timer.restart(d,r.delay,r.time),d(_))}),r.state=Dm,r.on.call("start",e,e.__data__,r.index,r.group),r.state===Dm){for(r.state=Hd,l=new Array(v=r.tween.length),g=0,x=-1;g<v;++g)(b=r.tween[g].value.call(e,e.__data__,r.index,r.group))&&(l[++x]=b);l.length=x+1}}function d(_){for(var g=_<r.duration?r.ease.call(null,_/r.duration):(r.timer.restart(h),r.state=Bm,1),x=-1,v=l.length;++x<v;)l[x].call(e,g);r.state===Bm&&(r.on.call("end",e,e.__data__,r.index,r.group),h())}function h(){r.state=Vd,r.timer.stop(),delete o[t];for(var _ in o)return;delete e.__transition}}function qd(e,t){var r=e.__transition,o,l,u=!0,c;if(r){t=t==null?null:t+"";for(c in r){if((o=r[c]).name!==t){u=!1;continue}l=o.state>Dm&&o.state<Bm,o.state=Vd,o.timer.stop(),o.on.call(l?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete r[c]}u&&delete e.__transition}}function lS(e){return this.each(function(){qd(this,e)})}function cS(e,t){var r,o;return function(){var l=ca(this,e),u=l.tween;if(u!==r){o=r=u;for(var c=0,d=o.length;c<d;++c)if(o[c].name===t){o=o.slice(),o.splice(c,1);break}}l.tween=o}}function uS(e,t,r){var o,l;if(typeof r!="function")throw new Error;return function(){var u=ca(this,e),c=u.tween;if(c!==o){l=(o=c).slice();for(var d={name:t,value:r},h=0,_=l.length;h<_;++h)if(l[h].name===t){l[h]=d;break}h===_&&l.push(d)}u.tween=l}}function dS(e,t){var r=this._id;if(e+="",arguments.length<2){for(var o=Po(this.node(),r).tween,l=0,u=o.length,c;l<u;++l)if((c=o[l]).name===e)return c.value;return null}return this.each((t==null?cS:uS)(r,e,t))}function uh(e,t,r){var o=e._id;return e.each(function(){var l=ca(this,o);(l.value||(l.value={}))[t]=r.apply(this,arguments)}),function(l){return Po(l,o).value[t]}}function X_(e,t){var r;return(typeof t=="number"?ml:t instanceof Du?ng:(r=Du(t))?(t=r,ng):qb)(e,t)}function fS(e){return function(){this.removeAttribute(e)}}function mS(e){return function(){this.removeAttributeNS(e.space,e.local)}}function hS(e,t,r){var o,l=r+"",u;return function(){var c=this.getAttribute(e);return c===l?null:c===o?u:u=t(o=c,r)}}function pS(e,t,r){var o,l=r+"",u;return function(){var c=this.getAttributeNS(e.space,e.local);return c===l?null:c===o?u:u=t(o=c,r)}}function gS(e,t,r){var o,l,u;return function(){var c,d=r(this),h;return d==null?void this.removeAttribute(e):(c=this.getAttribute(e),h=d+"",c===h?null:c===o&&h===l?u:(l=h,u=t(o=c,d)))}}function _S(e,t,r){var o,l,u;return function(){var c,d=r(this),h;return d==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),h=d+"",c===h?null:c===o&&h===l?u:(l=h,u=t(o=c,d)))}}function yS(e,t){var r=cf(e),o=r==="transform"?Kb:X_;return this.attrTween(e,typeof t=="function"?(r.local?_S:gS)(r,o,uh(this,"attr."+e,t)):t==null?(r.local?mS:fS)(r):(r.local?pS:hS)(r,o,t))}function xS(e,t){return function(r){this.setAttribute(e,t.call(this,r))}}function vS(e,t){return function(r){this.setAttributeNS(e.space,e.local,t.call(this,r))}}function wS(e,t){var r,o;function l(){var u=t.apply(this,arguments);return u!==o&&(r=(o=u)&&vS(e,u)),r}return l._value=t,l}function bS(e,t){var r,o;function l(){var u=t.apply(this,arguments);return u!==o&&(r=(o=u)&&xS(e,u)),r}return l._value=t,l}function SS(e,t){var r="attr."+e;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;var o=cf(e);return this.tween(r,(o.local?wS:bS)(o,t))}function jS(e,t){return function(){ch(this,e).delay=+t.apply(this,arguments)}}function kS(e,t){return t=+t,function(){ch(this,e).delay=t}}function NS(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?jS:kS)(t,e)):Po(this.node(),t).delay}function CS(e,t){return function(){ca(this,e).duration=+t.apply(this,arguments)}}function ES(e,t){return t=+t,function(){ca(this,e).duration=t}}function $S(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?CS:ES)(t,e)):Po(this.node(),t).duration}function AS(e,t){if(typeof t!="function")throw new Error;return function(){ca(this,e).ease=t}}function TS(e){var t=this._id;return arguments.length?this.each(AS(t,e)):Po(this.node(),t).ease}function MS(e,t){return function(){var r=t.apply(this,arguments);if(typeof r!="function")throw new Error;ca(this,e).ease=r}}function zS(e){if(typeof e!="function")throw new Error;return this.each(MS(this._id,e))}function RS(e){typeof e!="function"&&(e=C_(e));for(var t=this._groups,r=t.length,o=new Array(r),l=0;l<r;++l)for(var u=t[l],c=u.length,d=o[l]=[],h,_=0;_<c;++_)(h=u[_])&&e.call(h,h.__data__,_,u)&&d.push(h);return new La(o,this._parents,this._name,this._id)}function LS(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,r=e._groups,o=t.length,l=r.length,u=Math.min(o,l),c=new Array(o),d=0;d<u;++d)for(var h=t[d],_=r[d],g=h.length,x=c[d]=new Array(g),v,b=0;b<g;++b)(v=h[b]||_[b])&&(x[b]=v);for(;d<o;++d)c[d]=t[d];return new La(c,this._parents,this._name,this._id)}function PS(e){return(e+"").trim().split(/^|\s+/).every(function(t){var r=t.indexOf(".");return r>=0&&(t=t.slice(0,r)),!t||t==="start"})}function IS(e,t,r){var o,l,u=PS(t)?ch:ca;return function(){var c=u(this,e),d=c.on;d!==o&&(l=(o=d).copy()).on(t,r),c.on=l}}function FS(e,t){var r=this._id;return arguments.length<2?Po(this.node(),r).on.on(e):this.each(IS(r,e,t))}function OS(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;t&&t.removeChild(this)}}function DS(){return this.on("end.remove",OS(this._id))}function BS(e){var t=this._name,r=this._id;typeof e!="function"&&(e=ih(e));for(var o=this._groups,l=o.length,u=new Array(l),c=0;c<l;++c)for(var d=o[c],h=d.length,_=u[c]=new Array(h),g,x,v=0;v<h;++v)(g=d[v])&&(x=e.call(g,g.__data__,v,d))&&("__data__"in g&&(x.__data__=g.__data__),_[v]=x,df(_[v],t,r,v,_,Po(g,r)));return new La(u,this._parents,t,r)}function US(e){var t=this._name,r=this._id;typeof e!="function"&&(e=N_(e));for(var o=this._groups,l=o.length,u=[],c=[],d=0;d<l;++d)for(var h=o[d],_=h.length,g,x=0;x<_;++x)if(g=h[x]){for(var v=e.call(g,g.__data__,x,h),b,j=Po(g,r),S=0,T=v.length;S<T;++S)(b=v[S])&&df(b,t,r,S,v,j);u.push(v),c.push(g)}return new La(u,c,t,r)}var WS=Xu.prototype.constructor;function HS(){return new WS(this._groups,this._parents)}function VS(e,t){var r,o,l;return function(){var u=Vc(this,e),c=(this.style.removeProperty(e),Vc(this,e));return u===c?null:u===r&&c===o?l:l=t(r=u,o=c)}}function K_(e){return function(){this.style.removeProperty(e)}}function qS(e,t,r){var o,l=r+"",u;return function(){var c=Vc(this,e);return c===l?null:c===o?u:u=t(o=c,r)}}function GS(e,t,r){var o,l,u;return function(){var c=Vc(this,e),d=r(this),h=d+"";return d==null&&(h=d=(this.style.removeProperty(e),Vc(this,e))),c===h?null:c===o&&h===l?u:(l=h,u=t(o=c,d))}}function YS(e,t){var r,o,l,u="style."+t,c="end."+u,d;return function(){var h=ca(this,e),_=h.on,g=h.value[u]==null?d||(d=K_(t)):void 0;(_!==r||l!==g)&&(o=(r=_).copy()).on(c,l=g),h.on=o}}function XS(e,t,r){var o=(e+="")=="transform"?Xb:X_;return t==null?this.styleTween(e,VS(e,o)).on("end.style."+e,K_(e)):typeof t=="function"?this.styleTween(e,GS(e,o,uh(this,"style."+e,t))).each(YS(this._id,e)):this.styleTween(e,qS(e,o,t),r).on("end.style."+e,null)}function KS(e,t,r){return function(o){this.style.setProperty(e,t.call(this,o),r)}}function JS(e,t,r){var o,l;function u(){var c=t.apply(this,arguments);return c!==l&&(o=(l=c)&&KS(e,c,r)),o}return u._value=t,u}function QS(e,t,r){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,JS(e,t,r??""))}function ZS(e){return function(){this.textContent=e}}function ej(e){return function(){var t=e(this);this.textContent=t??""}}function tj(e){return this.tween("text",typeof e=="function"?ej(uh(this,"text",e)):ZS(e==null?"":e+""))}function nj(e){return function(t){this.textContent=e.call(this,t)}}function rj(e){var t,r;function o(){var l=e.apply(this,arguments);return l!==r&&(t=(r=l)&&nj(l)),t}return o._value=e,o}function sj(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,rj(e))}function ij(){for(var e=this._name,t=this._id,r=J_(),o=this._groups,l=o.length,u=0;u<l;++u)for(var c=o[u],d=c.length,h,_=0;_<d;++_)if(h=c[_]){var g=Po(h,t);df(h,e,r,_,c,{time:g.time+g.delay+g.duration,delay:0,duration:g.duration,ease:g.ease})}return new La(o,this._parents,e,r)}function oj(){var e,t,r=this,o=r._id,l=r.size();return new Promise(function(u,c){var d={value:c},h={value:function(){--l===0&&u()}};r.each(function(){var _=ca(this,o),g=_.on;g!==e&&(t=(e=g).copy(),t._.cancel.push(d),t._.interrupt.push(d),t._.end.push(h)),_.on=t}),l===0&&u()})}var aj=0;function La(e,t,r,o){this._groups=e,this._parents=t,this._name=r,this._id=o}function J_(){return++aj}var Ta=Xu.prototype;La.prototype={constructor:La,select:BS,selectAll:US,selectChild:Ta.selectChild,selectChildren:Ta.selectChildren,filter:RS,merge:LS,selection:HS,transition:ij,call:Ta.call,nodes:Ta.nodes,node:Ta.node,size:Ta.size,empty:Ta.empty,each:Ta.each,on:FS,attr:yS,attrTween:SS,style:XS,styleTween:QS,text:tj,textTween:sj,remove:DS,tween:dS,delay:NS,duration:$S,ease:TS,easeVarying:zS,end:oj,[Symbol.iterator]:Ta[Symbol.iterator]};function lj(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var cj={time:null,delay:0,duration:250,ease:lj};function uj(e,t){for(var r;!(r=e.__transition)||!(r=r[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return r}function dj(e){var t,r;e instanceof La?(t=e._id,e=e._name):(t=J_(),(r=cj).time=lh(),e=e==null?null:e+"");for(var o=this._groups,l=o.length,u=0;u<l;++u)for(var c=o[u],d=c.length,h,_=0;_<d;++_)(h=c[_])&&df(h,e,t,_,c,r||uj(h,t));return new La(o,this._parents,e,t)}Xu.prototype.interrupt=lS;Xu.prototype.transition=dj;const Md=e=>()=>e;function fj(e,{sourceEvent:t,target:r,transform:o,dispatch:l}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:l}})}function za(e,t,r){this.k=e,this.x=t,this.y=r}za.prototype={constructor:za,scale:function(e){return e===1?this:new za(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new za(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ra=new za(1,0,0);za.prototype;function dm(e){e.stopImmediatePropagation()}function ku(e){e.preventDefault(),e.stopImmediatePropagation()}function mj(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function hj(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function cg(){return this.__zoom||Ra}function pj(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function gj(){return navigator.maxTouchPoints||"ontouchstart"in this}function _j(e,t,r){var o=e.invertX(t[0][0])-r[0][0],l=e.invertX(t[1][0])-r[1][0],u=e.invertY(t[0][1])-r[0][1],c=e.invertY(t[1][1])-r[1][1];return e.translate(l>o?(o+l)/2:Math.min(0,o)||Math.max(0,l),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function Q_(){var e=mj,t=hj,r=_j,o=pj,l=gj,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,h=eS,_=lf("start","zoom","end"),g,x,v,b=500,j=150,S=0,T=10;function M(U){U.property("__zoom",cg).on("wheel.zoom",oe,{passive:!1}).on("mousedown.zoom",le).on("dblclick.zoom",_e).filter(l).on("touchstart.zoom",Te).on("touchmove.zoom",$e).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}M.transform=function(U,X,V,J){var k=U.selection?U.selection():U;k.property("__zoom",cg),U!==k?G(U,X,V,J):k.interrupt().each(function(){ne(this,arguments).event(J).start().zoom(null,typeof X=="function"?X.apply(this,arguments):X).end()})},M.scaleBy=function(U,X,V,J){M.scaleTo(U,function(){var k=this.__zoom.k,z=typeof X=="function"?X.apply(this,arguments):X;return k*z},V,J)},M.scaleTo=function(U,X,V,J){M.transform(U,function(){var k=t.apply(this,arguments),z=this.__zoom,F=V==null?I(k):typeof V=="function"?V.apply(this,arguments):V,N=z.invert(F),B=typeof X=="function"?X.apply(this,arguments):X;return r(L(D(z,B),F,N),k,c)},V,J)},M.translateBy=function(U,X,V,J){M.transform(U,function(){return r(this.__zoom.translate(typeof X=="function"?X.apply(this,arguments):X,typeof V=="function"?V.apply(this,arguments):V),t.apply(this,arguments),c)},null,J)},M.translateTo=function(U,X,V,J,k){M.transform(U,function(){var z=t.apply(this,arguments),F=this.__zoom,N=J==null?I(z):typeof J=="function"?J.apply(this,arguments):J;return r(Ra.translate(N[0],N[1]).scale(F.k).translate(typeof X=="function"?-X.apply(this,arguments):-X,typeof V=="function"?-V.apply(this,arguments):-V),z,c)},J,k)};function D(U,X){return X=Math.max(u[0],Math.min(u[1],X)),X===U.k?U:new za(X,U.x,U.y)}function L(U,X,V){var J=X[0]-V[0]*U.k,k=X[1]-V[1]*U.k;return J===U.x&&k===U.y?U:new za(U.k,J,k)}function I(U){return[(+U[0][0]+ +U[1][0])/2,(+U[0][1]+ +U[1][1])/2]}function G(U,X,V,J){U.on("start.zoom",function(){ne(this,arguments).event(J).start()}).on("interrupt.zoom end.zoom",function(){ne(this,arguments).event(J).end()}).tween("zoom",function(){var k=this,z=arguments,F=ne(k,z).event(J),N=t.apply(k,z),B=V==null?I(N):typeof V=="function"?V.apply(k,z):V,Z=Math.max(N[1][0]-N[0][0],N[1][1]-N[0][1]),te=k.__zoom,he=typeof X=="function"?X.apply(k,z):X,Ae=h(te.invert(B).concat(Z/te.k),he.invert(B).concat(Z/he.k));return function(se){if(se===1)se=he;else{var ve=Ae(se),Re=Z/ve[2];se=new za(Re,B[0]-ve[0]*Re,B[1]-ve[1]*Re)}F.zoom(null,se)}})}function ne(U,X,V){return!V&&U.__zooming||new Y(U,X)}function Y(U,X){this.that=U,this.args=X,this.active=0,this.sourceEvent=null,this.extent=t.apply(U,X),this.taps=0}Y.prototype={event:function(U){return U&&(this.sourceEvent=U),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(U,X){return this.mouse&&U!=="mouse"&&(this.mouse[1]=X.invert(this.mouse[0])),this.touch0&&U!=="touch"&&(this.touch0[1]=X.invert(this.touch0[0])),this.touch1&&U!=="touch"&&(this.touch1[1]=X.invert(this.touch1[0])),this.that.__zoom=X,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(U){var X=io(this.that).datum();_.call(U,this.that,new fj(U,{sourceEvent:this.sourceEvent,target:M,transform:this.that.__zoom,dispatch:_}),X)}};function oe(U,...X){if(!e.apply(this,arguments))return;var V=ne(this,X).event(U),J=this.__zoom,k=Math.max(u[0],Math.min(u[1],J.k*Math.pow(2,o.apply(this,arguments)))),z=Mo(U);if(V.wheel)(V.mouse[0][0]!==z[0]||V.mouse[0][1]!==z[1])&&(V.mouse[1]=J.invert(V.mouse[0]=z)),clearTimeout(V.wheel);else{if(J.k===k)return;V.mouse=[z,J.invert(z)],qd(this),V.start()}ku(U),V.wheel=setTimeout(F,j),V.zoom("mouse",r(L(D(J,k),V.mouse[0],V.mouse[1]),V.extent,c));function F(){V.wheel=null,V.end()}}function le(U,...X){if(v||!e.apply(this,arguments))return;var V=U.currentTarget,J=ne(this,X,!0).event(U),k=io(U.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",Z,!0),z=Mo(U,V),F=U.clientX,N=U.clientY;I_(U.view),dm(U),J.mouse=[z,this.__zoom.invert(z)],qd(this),J.start();function B(te){if(ku(te),!J.moved){var he=te.clientX-F,Ae=te.clientY-N;J.moved=he*he+Ae*Ae>S}J.event(te).zoom("mouse",r(L(J.that.__zoom,J.mouse[0]=Mo(te,V),J.mouse[1]),J.extent,c))}function Z(te){k.on("mousemove.zoom mouseup.zoom",null),F_(te.view,J.moved),ku(te),J.event(te).end()}}function _e(U,...X){if(e.apply(this,arguments)){var V=this.__zoom,J=Mo(U.changedTouches?U.changedTouches[0]:U,this),k=V.invert(J),z=V.k*(U.shiftKey?.5:2),F=r(L(D(V,z),J,k),t.apply(this,X),c);ku(U),d>0?io(this).transition().duration(d).call(G,F,J,U):io(this).call(M.transform,F,J,U)}}function Te(U,...X){if(e.apply(this,arguments)){var V=U.touches,J=V.length,k=ne(this,X,U.changedTouches.length===J).event(U),z,F,N,B;for(dm(U),F=0;F<J;++F)N=V[F],B=Mo(N,this),B=[B,this.__zoom.invert(B),N.identifier],k.touch0?!k.touch1&&k.touch0[2]!==B[2]&&(k.touch1=B,k.taps=0):(k.touch0=B,z=!0,k.taps=1+!!g);g&&(g=clearTimeout(g)),z&&(k.taps<2&&(x=B[0],g=setTimeout(function(){g=null},b)),qd(this),k.start())}}function $e(U,...X){if(this.__zooming){var V=ne(this,X).event(U),J=U.changedTouches,k=J.length,z,F,N,B;for(ku(U),z=0;z<k;++z)F=J[z],N=Mo(F,this),V.touch0&&V.touch0[2]===F.identifier?V.touch0[0]=N:V.touch1&&V.touch1[2]===F.identifier&&(V.touch1[0]=N);if(F=V.that.__zoom,V.touch1){var Z=V.touch0[0],te=V.touch0[1],he=V.touch1[0],Ae=V.touch1[1],se=(se=he[0]-Z[0])*se+(se=he[1]-Z[1])*se,ve=(ve=Ae[0]-te[0])*ve+(ve=Ae[1]-te[1])*ve;F=D(F,Math.sqrt(se/ve)),N=[(Z[0]+he[0])/2,(Z[1]+he[1])/2],B=[(te[0]+Ae[0])/2,(te[1]+Ae[1])/2]}else if(V.touch0)N=V.touch0[0],B=V.touch0[1];else return;V.zoom("touch",r(L(F,N,B),V.extent,c))}}function K(U,...X){if(this.__zooming){var V=ne(this,X).event(U),J=U.changedTouches,k=J.length,z,F;for(dm(U),v&&clearTimeout(v),v=setTimeout(function(){v=null},b),z=0;z<k;++z)F=J[z],V.touch0&&V.touch0[2]===F.identifier?delete V.touch0:V.touch1&&V.touch1[2]===F.identifier&&delete V.touch1;if(V.touch1&&!V.touch0&&(V.touch0=V.touch1,delete V.touch1),V.touch0)V.touch0[1]=this.__zoom.invert(V.touch0[0]);else if(V.end(),V.taps===2&&(F=Mo(F,this),Math.hypot(x[0]-F[0],x[1]-F[1])<T)){var N=io(this).on("dblclick.zoom");N&&N.apply(this,arguments)}}}return M.wheelDelta=function(U){return arguments.length?(o=typeof U=="function"?U:Md(+U),M):o},M.filter=function(U){return arguments.length?(e=typeof U=="function"?U:Md(!!U),M):e},M.touchable=function(U){return arguments.length?(l=typeof U=="function"?U:Md(!!U),M):l},M.extent=function(U){return arguments.length?(t=typeof U=="function"?U:Md([[+U[0][0],+U[0][1]],[+U[1][0],+U[1][1]]]),M):t},M.scaleExtent=function(U){return arguments.length?(u[0]=+U[0],u[1]=+U[1],M):[u[0],u[1]]},M.translateExtent=function(U){return arguments.length?(c[0][0]=+U[0][0],c[1][0]=+U[1][0],c[0][1]=+U[0][1],c[1][1]=+U[1][1],M):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},M.constrain=function(U){return arguments.length?(r=U,M):r},M.duration=function(U){return arguments.length?(d=+U,M):d},M.interpolate=function(U){return arguments.length?(h=U,M):h},M.on=function(){var U=_.on.apply(_,arguments);return U===_?M:U},M.clickDistance=function(U){return arguments.length?(S=(U=+U)*U,M):Math.sqrt(S)},M.tapDistance=function(U){return arguments.length?(T=+U,M):T},M}const ff=m.createContext(null),yj=ff.Provider,Pa={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},Z_=Pa.error001();function ir(e,t){const r=m.useContext(ff);if(r===null)throw new Error(Z_);return j_(r,e,t)}const as=()=>{const e=m.useContext(ff);if(e===null)throw new Error(Z_);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},xj=e=>e.userSelectionActive?"none":"all";function Uu({position:e,children:t,className:r,style:o,...l}){const u=ir(xj),c=`${e}`.split("-");return Ee.createElement("div",{className:Cs(["react-flow__panel",r,...c]),style:{...o,pointerEvents:u},...l},t)}function vj({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:Ee.createElement(Uu,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},Ee.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const wj=({x:e,y:t,label:r,labelStyle:o={},labelShowBg:l=!0,labelBgStyle:u={},labelBgPadding:c=[2,4],labelBgBorderRadius:d=2,children:h,className:_,...g})=>{const x=m.useRef(null),[v,b]=m.useState({x:0,y:0,width:0,height:0}),j=Cs(["react-flow__edge-textwrapper",_]);return m.useEffect(()=>{if(x.current){const S=x.current.getBBox();b({x:S.x,y:S.y,width:S.width,height:S.height})}},[r]),typeof r>"u"||!r?null:Ee.createElement("g",{transform:`translate(${e-v.width/2} ${t-v.height/2})`,className:j,visibility:v.width?"visible":"hidden",...g},l&&Ee.createElement("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:d,ry:d}),Ee.createElement("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:x,style:o},r),h)};var bj=m.memo(wj);const dh=e=>({width:e.offsetWidth,height:e.offsetHeight}),Gc=(e,t=0,r=1)=>Math.min(Math.max(e,t),r),fh=(e={x:0,y:0},t)=>({x:Gc(e.x,t[0][0],t[1][0]),y:Gc(e.y,t[0][1],t[1][1])}),ug=(e,t,r)=>e<t?Gc(Math.abs(e-t),1,50)/50:e>r?-Gc(Math.abs(e-r),1,50)/50:0,ey=(e,t)=>{const r=ug(e.x,35,t.width-35)*20,o=ug(e.y,35,t.height-35)*20;return[r,o]},ty=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},ny=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Wu=({x:e,y:t,width:r,height:o})=>({x:e,y:t,x2:e+r,y2:t+o}),ry=({x:e,y:t,x2:r,y2:o})=>({x:e,y:t,width:r-e,height:o-t}),dg=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),Sj=(e,t)=>ry(ny(Wu(e),Wu(t))),Um=(e,t)=>{const r=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(r*o)},jj=e=>oo(e.width)&&oo(e.height)&&oo(e.x)&&oo(e.y),oo=e=>!isNaN(e)&&isFinite(e),Kr=Symbol.for("internals"),sy=["Enter"," ","Escape"],kj=(e,t)=>{},Nj=e=>"nativeEvent"in e;function Wm(e){var l,u;const t=Nj(e)?e.nativeEvent:e,r=((u=(l=t.composedPath)==null?void 0:l.call(t))==null?void 0:u[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(r==null?void 0:r.nodeName)||(r==null?void 0:r.hasAttribute("contenteditable"))||!!(r!=null&&r.closest(".nokey"))}const iy=e=>"clientX"in e,gl=(e,t)=>{var u,c;const r=iy(e),o=r?e.clientX:(u=e.touches)==null?void 0:u[0].clientX,l=r?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:o-((t==null?void 0:t.left)??0),y:l-((t==null?void 0:t.top)??0)}},tf=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Ju=({id:e,path:t,labelX:r,labelY:o,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:_,style:g,markerEnd:x,markerStart:v,interactionWidth:b=20})=>Ee.createElement(Ee.Fragment,null,Ee.createElement("path",{id:e,style:g,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:x,markerStart:v}),b&&Ee.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:b,className:"react-flow__edge-interaction"}),l&&oo(r)&&oo(o)?Ee.createElement(bj,{x:r,y:o,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:_}):null);Ju.displayName="BaseEdge";function Nu(e,t,r){return r===void 0?r:o=>{const l=t().edges.find(u=>u.id===e);l&&r(o,{...l})}}function oy({sourceX:e,sourceY:t,targetX:r,targetY:o}){const l=Math.abs(r-e)/2,u=r<e?r+l:r-l,c=Math.abs(o-t)/2,d=o<t?o+c:o-c;return[u,d,l,c]}function ay({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:l,sourceControlY:u,targetControlX:c,targetControlY:d}){const h=e*.125+l*.375+c*.375+r*.125,_=t*.125+u*.375+d*.375+o*.125,g=Math.abs(h-e),x=Math.abs(_-t);return[h,_,g,x]}var Zl;(function(e){e.Strict="strict",e.Loose="loose"})(Zl||(Zl={}));var Xl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Xl||(Xl={}));var Hu;(function(e){e.Partial="partial",e.Full="full"})(Hu||(Hu={}));var pl;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(pl||(pl={}));var Vu;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Vu||(Vu={}));var Ft;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ft||(Ft={}));function fg({pos:e,x1:t,y1:r,x2:o,y2:l}){return e===Ft.Left||e===Ft.Right?[.5*(t+o),r]:[t,.5*(r+l)]}function ly({sourceX:e,sourceY:t,sourcePosition:r=Ft.Bottom,targetX:o,targetY:l,targetPosition:u=Ft.Top}){const[c,d]=fg({pos:r,x1:e,y1:t,x2:o,y2:l}),[h,_]=fg({pos:u,x1:o,y1:l,x2:e,y2:t}),[g,x,v,b]=ay({sourceX:e,sourceY:t,targetX:o,targetY:l,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:_});return[`M${e},${t} C${c},${d} ${h},${_} ${o},${l}`,g,x,v,b]}const mh=m.memo(({sourceX:e,sourceY:t,targetX:r,targetY:o,sourcePosition:l=Ft.Bottom,targetPosition:u=Ft.Top,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:_,labelBgPadding:g,labelBgBorderRadius:x,style:v,markerEnd:b,markerStart:j,interactionWidth:S})=>{const[T,M,D]=ly({sourceX:e,sourceY:t,sourcePosition:l,targetX:r,targetY:o,targetPosition:u});return Ee.createElement(Ju,{path:T,labelX:M,labelY:D,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:_,labelBgPadding:g,labelBgBorderRadius:x,style:v,markerEnd:b,markerStart:j,interactionWidth:S})});mh.displayName="SimpleBezierEdge";const mg={[Ft.Left]:{x:-1,y:0},[Ft.Right]:{x:1,y:0},[Ft.Top]:{x:0,y:-1},[Ft.Bottom]:{x:0,y:1}},Cj=({source:e,sourcePosition:t=Ft.Bottom,target:r})=>t===Ft.Left||t===Ft.Right?e.x<r.x?{x:1,y:0}:{x:-1,y:0}:e.y<r.y?{x:0,y:1}:{x:0,y:-1},hg=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Ej({source:e,sourcePosition:t=Ft.Bottom,target:r,targetPosition:o=Ft.Top,center:l,offset:u}){const c=mg[t],d=mg[o],h={x:e.x+c.x*u,y:e.y+c.y*u},_={x:r.x+d.x*u,y:r.y+d.y*u},g=Cj({source:h,sourcePosition:t,target:_}),x=g.x!==0?"x":"y",v=g[x];let b=[],j,S;const T={x:0,y:0},M={x:0,y:0},[D,L,I,G]=oy({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(c[x]*d[x]===-1){j=l.x||D,S=l.y||L;const Y=[{x:j,y:h.y},{x:j,y:_.y}],oe=[{x:h.x,y:S},{x:_.x,y:S}];c[x]===v?b=x==="x"?Y:oe:b=x==="x"?oe:Y}else{const Y=[{x:h.x,y:_.y}],oe=[{x:_.x,y:h.y}];if(x==="x"?b=c.x===v?oe:Y:b=c.y===v?Y:oe,t===o){const K=Math.abs(e[x]-r[x]);if(K<=u){const U=Math.min(u-1,u-K);c[x]===v?T[x]=(h[x]>e[x]?-1:1)*U:M[x]=(_[x]>r[x]?-1:1)*U}}if(t!==o){const K=x==="x"?"y":"x",U=c[x]===d[K],X=h[K]>_[K],V=h[K]<_[K];(c[x]===1&&(!U&&X||U&&V)||c[x]!==1&&(!U&&V||U&&X))&&(b=x==="x"?Y:oe)}const le={x:h.x+T.x,y:h.y+T.y},_e={x:_.x+M.x,y:_.y+M.y},Te=Math.max(Math.abs(le.x-b[0].x),Math.abs(_e.x-b[0].x)),$e=Math.max(Math.abs(le.y-b[0].y),Math.abs(_e.y-b[0].y));Te>=$e?(j=(le.x+_e.x)/2,S=b[0].y):(j=b[0].x,S=(le.y+_e.y)/2)}return[[e,{x:h.x+T.x,y:h.y+T.y},...b,{x:_.x+M.x,y:_.y+M.y},r],j,S,I,G]}function $j(e,t,r,o){const l=Math.min(hg(e,t)/2,hg(t,r)/2,o),{x:u,y:c}=t;if(e.x===u&&u===r.x||e.y===c&&c===r.y)return`L${u} ${c}`;if(e.y===c){const _=e.x<r.x?-1:1,g=e.y<r.y?1:-1;return`L ${u+l*_},${c}Q ${u},${c} ${u},${c+l*g}`}const d=e.x<r.x?1:-1,h=e.y<r.y?-1:1;return`L ${u},${c+l*h}Q ${u},${c} ${u+l*d},${c}`}function Hm({sourceX:e,sourceY:t,sourcePosition:r=Ft.Bottom,targetX:o,targetY:l,targetPosition:u=Ft.Top,borderRadius:c=5,centerX:d,centerY:h,offset:_=20}){const[g,x,v,b,j]=Ej({source:{x:e,y:t},sourcePosition:r,target:{x:o,y:l},targetPosition:u,center:{x:d,y:h},offset:_});return[g.reduce((T,M,D)=>{let L="";return D>0&&D<g.length-1?L=$j(g[D-1],M,g[D+1],c):L=`${D===0?"M":"L"}${M.x} ${M.y}`,T+=L,T},""),x,v,b,j]}const mf=m.memo(({sourceX:e,sourceY:t,targetX:r,targetY:o,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:_,style:g,sourcePosition:x=Ft.Bottom,targetPosition:v=Ft.Top,markerEnd:b,markerStart:j,pathOptions:S,interactionWidth:T})=>{const[M,D,L]=Hm({sourceX:e,sourceY:t,sourcePosition:x,targetX:r,targetY:o,targetPosition:v,borderRadius:S==null?void 0:S.borderRadius,offset:S==null?void 0:S.offset});return Ee.createElement(Ju,{path:M,labelX:D,labelY:L,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:_,style:g,markerEnd:b,markerStart:j,interactionWidth:T})});mf.displayName="SmoothStepEdge";const hh=m.memo(e=>{var t;return Ee.createElement(mf,{...e,pathOptions:m.useMemo(()=>{var r;return{borderRadius:0,offset:(r=e.pathOptions)==null?void 0:r.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});hh.displayName="StepEdge";function Aj({sourceX:e,sourceY:t,targetX:r,targetY:o}){const[l,u,c,d]=oy({sourceX:e,sourceY:t,targetX:r,targetY:o});return[`M ${e},${t}L ${r},${o}`,l,u,c,d]}const ph=m.memo(({sourceX:e,sourceY:t,targetX:r,targetY:o,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:_,style:g,markerEnd:x,markerStart:v,interactionWidth:b})=>{const[j,S,T]=Aj({sourceX:e,sourceY:t,targetX:r,targetY:o});return Ee.createElement(Ju,{path:j,labelX:S,labelY:T,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:_,style:g,markerEnd:x,markerStart:v,interactionWidth:b})});ph.displayName="StraightEdge";function zd(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function pg({pos:e,x1:t,y1:r,x2:o,y2:l,c:u}){switch(e){case Ft.Left:return[t-zd(t-o,u),r];case Ft.Right:return[t+zd(o-t,u),r];case Ft.Top:return[t,r-zd(r-l,u)];case Ft.Bottom:return[t,r+zd(l-r,u)]}}function cy({sourceX:e,sourceY:t,sourcePosition:r=Ft.Bottom,targetX:o,targetY:l,targetPosition:u=Ft.Top,curvature:c=.25}){const[d,h]=pg({pos:r,x1:e,y1:t,x2:o,y2:l,c}),[_,g]=pg({pos:u,x1:o,y1:l,x2:e,y2:t,c}),[x,v,b,j]=ay({sourceX:e,sourceY:t,targetX:o,targetY:l,sourceControlX:d,sourceControlY:h,targetControlX:_,targetControlY:g});return[`M${e},${t} C${d},${h} ${_},${g} ${o},${l}`,x,v,b,j]}const nf=m.memo(({sourceX:e,sourceY:t,targetX:r,targetY:o,sourcePosition:l=Ft.Bottom,targetPosition:u=Ft.Top,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:_,labelBgPadding:g,labelBgBorderRadius:x,style:v,markerEnd:b,markerStart:j,pathOptions:S,interactionWidth:T})=>{const[M,D,L]=cy({sourceX:e,sourceY:t,sourcePosition:l,targetX:r,targetY:o,targetPosition:u,curvature:S==null?void 0:S.curvature});return Ee.createElement(Ju,{path:M,labelX:D,labelY:L,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:_,labelBgPadding:g,labelBgBorderRadius:x,style:v,markerEnd:b,markerStart:j,interactionWidth:T})});nf.displayName="BezierEdge";const gh=m.createContext(null),Tj=gh.Provider;gh.Consumer;const Mj=()=>m.useContext(gh),zj=e=>"id"in e&&"source"in e&&"target"in e,Rj=({source:e,sourceHandle:t,target:r,targetHandle:o})=>`reactflow__edge-${e}${t||""}-${r}${o||""}`,Vm=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`,Lj=(e,t)=>t.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),Pj=(e,t)=>{if(!e.source||!e.target)return t;let r;return zj(e)?r={...e}:r={...e,id:Rj(e)},Lj(r,t)?t:t.concat(r)},qm=({x:e,y:t},[r,o,l],u,[c,d])=>{const h={x:(e-r)/l,y:(t-o)/l};return u?{x:c*Math.round(h.x/c),y:d*Math.round(h.y/d)}:h},uy=({x:e,y:t},[r,o,l])=>({x:e*l+r,y:t*l+o}),Jl=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const r=(e.width??0)*t[0],o=(e.height??0)*t[1],l={x:e.position.x-r,y:e.position.y-o};return{...l,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-r,y:e.positionAbsolute.y-o}:l}},hf=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((o,l)=>{const{x:u,y:c}=Jl(l,t).positionAbsolute;return ny(o,Wu({x:u,y:c,width:l.width||0,height:l.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ry(r)},dy=(e,t,[r,o,l]=[0,0,1],u=!1,c=!1,d=[0,0])=>{const h={x:(t.x-r)/l,y:(t.y-o)/l,width:t.width/l,height:t.height/l},_=[];return e.forEach(g=>{const{width:x,height:v,selectable:b=!0,hidden:j=!1}=g;if(c&&!b||j)return!1;const{positionAbsolute:S}=Jl(g,d),T={x:S.x,y:S.y,width:x||0,height:v||0},M=Um(h,T),D=typeof x>"u"||typeof v>"u"||x===null||v===null,L=u&&M>0,I=(x||0)*(v||0);(D||L||M>=I||g.dragging)&&_.push(g)}),_},fy=(e,t)=>{const r=e.map(o=>o.id);return t.filter(o=>r.includes(o.source)||r.includes(o.target))},my=(e,t,r,o,l,u=.1)=>{const c=t/(e.width*(1+u)),d=r/(e.height*(1+u)),h=Math.min(c,d),_=Gc(h,o,l),g=e.x+e.width/2,x=e.y+e.height/2,v=t/2-g*_,b=r/2-x*_;return{x:v,y:b,zoom:_}},ql=(e,t=0)=>e.transition().duration(t);function gg(e,t,r,o){return(t[r]||[]).reduce((l,u)=>{var c,d;return`${e.id}-${u.id}-${r}`!==o&&l.push({id:u.id||null,type:r,nodeId:e.id,x:(((c=e.positionAbsolute)==null?void 0:c.x)??0)+u.x+u.width/2,y:(((d=e.positionAbsolute)==null?void 0:d.y)??0)+u.y+u.height/2}),l},[])}function Ij(e,t,r,o,l,u){const{x:c,y:d}=gl(e),_=t.elementsFromPoint(c,d).find(j=>j.classList.contains("react-flow__handle"));if(_){const j=_.getAttribute("data-nodeid");if(j){const S=_h(void 0,_),T=_.getAttribute("data-handleid"),M=u({nodeId:j,id:T,type:S});if(M){const D=l.find(L=>L.nodeId===j&&L.type===S&&L.id===T);return{handle:{id:T,type:S,nodeId:j,x:(D==null?void 0:D.x)||r.x,y:(D==null?void 0:D.y)||r.y},validHandleResult:M}}}}let g=[],x=1/0;if(l.forEach(j=>{const S=Math.sqrt((j.x-r.x)**2+(j.y-r.y)**2);if(S<=o){const T=u(j);S<=x&&(S<x?g=[{handle:j,validHandleResult:T}]:S===x&&g.push({handle:j,validHandleResult:T}),x=S)}}),!g.length)return{handle:null,validHandleResult:hy()};if(g.length===1)return g[0];const v=g.some(({validHandleResult:j})=>j.isValid),b=g.some(({handle:j})=>j.type==="target");return g.find(({handle:j,validHandleResult:S})=>b?j.type==="target":v?S.isValid:!0)||g[0]}const Fj={source:null,target:null,sourceHandle:null,targetHandle:null},hy=()=>({handleDomNode:null,isValid:!1,connection:Fj,endHandle:null});function py(e,t,r,o,l,u,c){const d=l==="target",h=c.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),_={...hy(),handleDomNode:h};if(h){const g=_h(void 0,h),x=h.getAttribute("data-nodeid"),v=h.getAttribute("data-handleid"),b=h.classList.contains("connectable"),j=h.classList.contains("connectableend"),S={source:d?x:r,sourceHandle:d?v:o,target:d?r:x,targetHandle:d?o:v};_.connection=S,b&&j&&(t===Zl.Strict?d&&g==="source"||!d&&g==="target":x!==r||v!==o)&&(_.endHandle={nodeId:x,handleId:v,type:g},_.isValid=u(S))}return _}function Oj({nodes:e,nodeId:t,handleId:r,handleType:o}){return e.reduce((l,u)=>{if(u[Kr]){const{handleBounds:c}=u[Kr];let d=[],h=[];c&&(d=gg(u,c,"source",`${t}-${r}-${o}`),h=gg(u,c,"target",`${t}-${r}-${o}`)),l.push(...d,...h)}return l},[])}function _h(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function fm(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function Dj(e,t){let r=null;return t?r="valid":e&&!t&&(r="invalid"),r}function gy({event:e,handleId:t,nodeId:r,onConnect:o,isTarget:l,getState:u,setState:c,isValidConnection:d,edgeUpdaterType:h,onEdgeUpdateEnd:_}){const g=ty(e.target),{connectionMode:x,domNode:v,autoPanOnConnect:b,connectionRadius:j,onConnectStart:S,panBy:T,getNodes:M,cancelConnection:D}=u();let L=0,I;const{x:G,y:ne}=gl(e),Y=g==null?void 0:g.elementFromPoint(G,ne),oe=_h(h,Y),le=v==null?void 0:v.getBoundingClientRect();if(!le||!oe)return;let _e,Te=gl(e,le),$e=!1,K=null,U=!1,X=null;const V=Oj({nodes:M(),nodeId:r,handleId:t,handleType:oe}),J=()=>{if(!b)return;const[F,N]=ey(Te,le);T({x:F,y:N}),L=requestAnimationFrame(J)};c({connectionPosition:Te,connectionStatus:null,connectionNodeId:r,connectionHandleId:t,connectionHandleType:oe,connectionStartHandle:{nodeId:r,handleId:t,type:oe},connectionEndHandle:null}),S==null||S(e,{nodeId:r,handleId:t,handleType:oe});function k(F){const{transform:N}=u();Te=gl(F,le);const{handle:B,validHandleResult:Z}=Ij(F,g,qm(Te,N,!1,[1,1]),j,V,te=>py(te,x,r,t,l?"target":"source",d,g));if(I=B,$e||(J(),$e=!0),X=Z.handleDomNode,K=Z.connection,U=Z.isValid,c({connectionPosition:I&&U?uy({x:I.x,y:I.y},N):Te,connectionStatus:Dj(!!I,U),connectionEndHandle:Z.endHandle}),!I&&!U&&!X)return fm(_e);K.source!==K.target&&X&&(fm(_e),_e=X,X.classList.add("connecting","react-flow__handle-connecting"),X.classList.toggle("valid",U),X.classList.toggle("react-flow__handle-valid",U))}function z(F){var N,B;(I||X)&&K&&U&&(o==null||o(K)),(B=(N=u()).onConnectEnd)==null||B.call(N,F),h&&(_==null||_(F)),fm(_e),D(),cancelAnimationFrame(L),$e=!1,U=!1,K=null,X=null,g.removeEventListener("mousemove",k),g.removeEventListener("mouseup",z),g.removeEventListener("touchmove",k),g.removeEventListener("touchend",z)}g.addEventListener("mousemove",k),g.addEventListener("mouseup",z),g.addEventListener("touchmove",k),g.addEventListener("touchend",z)}const _g=()=>!0,Bj=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),Uj=(e,t,r)=>o=>{const{connectionStartHandle:l,connectionEndHandle:u,connectionClickStartHandle:c}=o;return{connecting:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===t&&(l==null?void 0:l.type)===r||(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.handleId)===t&&(u==null?void 0:u.type)===r,clickConnecting:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.handleId)===t&&(c==null?void 0:c.type)===r}},_y=m.forwardRef(({type:e="source",position:t=Ft.Top,isValidConnection:r,isConnectable:o=!0,isConnectableStart:l=!0,isConnectableEnd:u=!0,id:c,onConnect:d,children:h,className:_,onMouseDown:g,onTouchStart:x,...v},b)=>{var le,_e;const j=c||null,S=e==="target",T=as(),M=Mj(),{connectOnClick:D,noPanClassName:L}=ir(Bj,ws),{connecting:I,clickConnecting:G}=ir(Uj(M,j,e),ws);M||(_e=(le=T.getState()).onError)==null||_e.call(le,"010",Pa.error010());const ne=Te=>{const{defaultEdgeOptions:$e,onConnect:K,hasDefaultEdges:U}=T.getState(),X={...$e,...Te};if(U){const{edges:V,setEdges:J}=T.getState();J(Pj(X,V))}K==null||K(X),d==null||d(X)},Y=Te=>{if(!M)return;const $e=iy(Te);l&&($e&&Te.button===0||!$e)&&gy({event:Te,handleId:j,nodeId:M,onConnect:ne,isTarget:S,getState:T.getState,setState:T.setState,isValidConnection:r||T.getState().isValidConnection||_g}),$e?g==null||g(Te):x==null||x(Te)},oe=Te=>{const{onClickConnectStart:$e,onClickConnectEnd:K,connectionClickStartHandle:U,connectionMode:X,isValidConnection:V}=T.getState();if(!M||!U&&!l)return;if(!U){$e==null||$e(Te,{nodeId:M,handleId:j,handleType:e}),T.setState({connectionClickStartHandle:{nodeId:M,type:e,handleId:j}});return}const J=ty(Te.target),k=r||V||_g,{connection:z,isValid:F}=py({nodeId:M,id:j,type:e},X,U.nodeId,U.handleId||null,U.type,k,J);F&&ne(z),K==null||K(Te),T.setState({connectionClickStartHandle:null})};return Ee.createElement("div",{"data-handleid":j,"data-nodeid":M,"data-handlepos":t,"data-id":`${M}-${j}-${e}`,className:Cs(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",L,_,{source:!S,target:S,connectable:o,connectablestart:l,connectableend:u,connecting:G,connectionindicator:o&&(l&&!I||u&&I)}]),onMouseDown:Y,onTouchStart:Y,onClick:D?oe:void 0,ref:b,...v},h)});_y.displayName="Handle";var rf=m.memo(_y);const yy=({data:e,isConnectable:t,targetPosition:r=Ft.Top,sourcePosition:o=Ft.Bottom})=>Ee.createElement(Ee.Fragment,null,Ee.createElement(rf,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label,Ee.createElement(rf,{type:"source",position:o,isConnectable:t}));yy.displayName="DefaultNode";var Gm=m.memo(yy);const xy=({data:e,isConnectable:t,sourcePosition:r=Ft.Bottom})=>Ee.createElement(Ee.Fragment,null,e==null?void 0:e.label,Ee.createElement(rf,{type:"source",position:r,isConnectable:t}));xy.displayName="InputNode";var vy=m.memo(xy);const wy=({data:e,isConnectable:t,targetPosition:r=Ft.Top})=>Ee.createElement(Ee.Fragment,null,Ee.createElement(rf,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label);wy.displayName="OutputNode";var by=m.memo(wy);const yh=()=>null;yh.displayName="GroupNode";const Wj=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected)}),Rd=e=>e.id;function Hj(e,t){return ws(e.selectedNodes.map(Rd),t.selectedNodes.map(Rd))&&ws(e.selectedEdges.map(Rd),t.selectedEdges.map(Rd))}const Sy=m.memo(({onSelectionChange:e})=>{const t=as(),{selectedNodes:r,selectedEdges:o}=ir(Wj,Hj);return m.useEffect(()=>{const l={nodes:r,edges:o};e==null||e(l),t.getState().onSelectionChange.forEach(u=>u(l))},[r,o,e]),null});Sy.displayName="SelectionListener";const Vj=e=>!!e.onSelectionChange;function qj({onSelectionChange:e}){const t=ir(Vj);return e||t?Ee.createElement(Sy,{onSelectionChange:e}):null}const Gj=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Ac(e,t){m.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function bn(e,t,r){m.useEffect(()=>{typeof t<"u"&&r({[e]:t})},[t])}const Yj=({nodes:e,edges:t,defaultNodes:r,defaultEdges:o,onConnect:l,onConnectStart:u,onConnectEnd:c,onClickConnectStart:d,onClickConnectEnd:h,nodesDraggable:_,nodesConnectable:g,nodesFocusable:x,edgesFocusable:v,edgesUpdatable:b,elevateNodesOnSelect:j,minZoom:S,maxZoom:T,nodeExtent:M,onNodesChange:D,onEdgesChange:L,elementsSelectable:I,connectionMode:G,snapGrid:ne,snapToGrid:Y,translateExtent:oe,connectOnClick:le,defaultEdgeOptions:_e,fitView:Te,fitViewOptions:$e,onNodesDelete:K,onEdgesDelete:U,onNodeDrag:X,onNodeDragStart:V,onNodeDragStop:J,onSelectionDrag:k,onSelectionDragStart:z,onSelectionDragStop:F,noPanClassName:N,nodeOrigin:B,rfId:Z,autoPanOnConnect:te,autoPanOnNodeDrag:he,onError:Ae,connectionRadius:se,isValidConnection:ve,nodeDragThreshold:Re})=>{const{setNodes:Qe,setEdges:Pe,setDefaultNodesAndEdges:de,setMinZoom:be,setMaxZoom:Fe,setTranslateExtent:Xe,setNodeExtent:tt,reset:ze}=ir(Gj,ws),Oe=as();return m.useEffect(()=>{const lt=o==null?void 0:o.map(xe=>({...xe,..._e}));return de(r,lt),()=>{ze()}},[]),bn("defaultEdgeOptions",_e,Oe.setState),bn("connectionMode",G,Oe.setState),bn("onConnect",l,Oe.setState),bn("onConnectStart",u,Oe.setState),bn("onConnectEnd",c,Oe.setState),bn("onClickConnectStart",d,Oe.setState),bn("onClickConnectEnd",h,Oe.setState),bn("nodesDraggable",_,Oe.setState),bn("nodesConnectable",g,Oe.setState),bn("nodesFocusable",x,Oe.setState),bn("edgesFocusable",v,Oe.setState),bn("edgesUpdatable",b,Oe.setState),bn("elementsSelectable",I,Oe.setState),bn("elevateNodesOnSelect",j,Oe.setState),bn("snapToGrid",Y,Oe.setState),bn("snapGrid",ne,Oe.setState),bn("onNodesChange",D,Oe.setState),bn("onEdgesChange",L,Oe.setState),bn("connectOnClick",le,Oe.setState),bn("fitViewOnInit",Te,Oe.setState),bn("fitViewOnInitOptions",$e,Oe.setState),bn("onNodesDelete",K,Oe.setState),bn("onEdgesDelete",U,Oe.setState),bn("onNodeDrag",X,Oe.setState),bn("onNodeDragStart",V,Oe.setState),bn("onNodeDragStop",J,Oe.setState),bn("onSelectionDrag",k,Oe.setState),bn("onSelectionDragStart",z,Oe.setState),bn("onSelectionDragStop",F,Oe.setState),bn("noPanClassName",N,Oe.setState),bn("nodeOrigin",B,Oe.setState),bn("rfId",Z,Oe.setState),bn("autoPanOnConnect",te,Oe.setState),bn("autoPanOnNodeDrag",he,Oe.setState),bn("onError",Ae,Oe.setState),bn("connectionRadius",se,Oe.setState),bn("isValidConnection",ve,Oe.setState),bn("nodeDragThreshold",Re,Oe.setState),Ac(e,Qe),Ac(t,Pe),Ac(S,be),Ac(T,Fe),Ac(oe,Xe),Ac(M,tt),null},yg={display:"none"},Xj={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},jy="react-flow__node-desc",ky="react-flow__edge-desc",Kj="react-flow__aria-live",Jj=e=>e.ariaLiveMessage;function Qj({rfId:e}){const t=ir(Jj);return Ee.createElement("div",{id:`${Kj}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Xj},t)}function Zj({rfId:e,disableKeyboardA11y:t}){return Ee.createElement(Ee.Fragment,null,Ee.createElement("div",{id:`${jy}-${e}`,style:yg},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),Ee.createElement("div",{id:`${ky}-${e}`,style:yg},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&Ee.createElement(Qj,{rfId:e}))}var qu=(e=null,t={actInsideInputWithModifier:!0})=>{const[r,o]=m.useState(!1),l=m.useRef(!1),u=m.useRef(new Set([])),[c,d]=m.useMemo(()=>{if(e!==null){const _=(Array.isArray(e)?e:[e]).filter(x=>typeof x=="string").map(x=>x.split("+")),g=_.reduce((x,v)=>x.concat(...v),[]);return[_,g]}return[[],[]]},[e]);return m.useEffect(()=>{const h=typeof document<"u"?document:null,_=(t==null?void 0:t.target)||h;if(e!==null){const g=b=>{if(l.current=b.ctrlKey||b.metaKey||b.shiftKey,(!l.current||l.current&&!t.actInsideInputWithModifier)&&Wm(b))return!1;const S=vg(b.code,d);u.current.add(b[S]),xg(c,u.current,!1)&&(b.preventDefault(),o(!0))},x=b=>{if((!l.current||l.current&&!t.actInsideInputWithModifier)&&Wm(b))return!1;const S=vg(b.code,d);xg(c,u.current,!0)?(o(!1),u.current.clear()):u.current.delete(b[S]),b.key==="Meta"&&u.current.clear(),l.current=!1},v=()=>{u.current.clear(),o(!1)};return _==null||_.addEventListener("keydown",g),_==null||_.addEventListener("keyup",x),window.addEventListener("blur",v),()=>{_==null||_.removeEventListener("keydown",g),_==null||_.removeEventListener("keyup",x),window.removeEventListener("blur",v)}}},[e,o]),r};function xg(e,t,r){return e.filter(o=>r||o.length===t.size).some(o=>o.every(l=>t.has(l)))}function vg(e,t){return t.includes(e)?"code":"key"}function Ny(e,t,r,o){var c,d;if(!e.parentNode)return r;const l=t.get(e.parentNode),u=Jl(l,o);return Ny(l,t,{x:(r.x??0)+u.x,y:(r.y??0)+u.y,z:(((c=l[Kr])==null?void 0:c.z)??0)>(r.z??0)?((d=l[Kr])==null?void 0:d.z)??0:r.z??0},o)}function Cy(e,t,r){e.forEach(o=>{var l;if(o.parentNode&&!e.has(o.parentNode))throw new Error(`Parent node ${o.parentNode} not found`);if(o.parentNode||r!=null&&r[o.id]){const{x:u,y:c,z:d}=Ny(o,e,{...o.position,z:((l=o[Kr])==null?void 0:l.z)??0},t);o.positionAbsolute={x:u,y:c},o[Kr].z=d,r!=null&&r[o.id]&&(o[Kr].isParent=!0)}})}function mm(e,t,r,o){const l=new Map,u={},c=o?1e3:0;return e.forEach(d=>{var v;const h=(oo(d.zIndex)?d.zIndex:0)+(d.selected?c:0),_=t.get(d.id),g={...d,positionAbsolute:{x:d.position.x,y:d.position.y}};d.parentNode&&(u[d.parentNode]=!0);const x=(_==null?void 0:_.type)&&(_==null?void 0:_.type)!==d.type;Object.defineProperty(g,Kr,{enumerable:!1,value:{handleBounds:x||(v=_==null?void 0:_[Kr])==null?void 0:v.handleBounds,z:h}}),l.set(d.id,g)}),Cy(l,r,u),l}function Ey(e,t={}){const{getNodes:r,width:o,height:l,minZoom:u,maxZoom:c,d3Zoom:d,d3Selection:h,fitViewOnInitDone:_,fitViewOnInit:g,nodeOrigin:x}=e(),v=t.initial&&!_&&g;if(d&&h&&(v||!t.initial)){const j=r().filter(T=>{var D;const M=t.includeHiddenNodes?T.width&&T.height:!T.hidden;return(D=t.nodes)!=null&&D.length?M&&t.nodes.some(L=>L.id===T.id):M}),S=j.every(T=>T.width&&T.height);if(j.length>0&&S){const T=hf(j,x),{x:M,y:D,zoom:L}=my(T,o,l,t.minZoom??u,t.maxZoom??c,t.padding??.1),I=Ra.translate(M,D).scale(L);return typeof t.duration=="number"&&t.duration>0?d.transform(ql(h,t.duration),I):d.transform(h,I),!0}}return!1}function ek(e,t){return e.forEach(r=>{const o=t.get(r.id);o&&t.set(o.id,{...o,[Kr]:o[Kr],selected:r.selected})}),new Map(t)}function tk(e,t){return t.map(r=>{const o=e.find(l=>l.id===r.id);return o&&(r.selected=o.selected),r})}function Ld({changedNodes:e,changedEdges:t,get:r,set:o}){const{nodeInternals:l,edges:u,onNodesChange:c,onEdgesChange:d,hasDefaultNodes:h,hasDefaultEdges:_}=r();e!=null&&e.length&&(h&&o({nodeInternals:ek(e,l)}),c==null||c(e)),t!=null&&t.length&&(_&&o({edges:tk(t,u)}),d==null||d(t))}const Tc=()=>{},nk={zoomIn:Tc,zoomOut:Tc,zoomTo:Tc,getZoom:()=>1,setViewport:Tc,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Tc,fitBounds:Tc,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},rk=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),sk=()=>{const e=as(),{d3Zoom:t,d3Selection:r}=ir(rk,ws);return m.useMemo(()=>r&&t?{zoomIn:l=>t.scaleBy(ql(r,l==null?void 0:l.duration),1.2),zoomOut:l=>t.scaleBy(ql(r,l==null?void 0:l.duration),1/1.2),zoomTo:(l,u)=>t.scaleTo(ql(r,u==null?void 0:u.duration),l),getZoom:()=>e.getState().transform[2],setViewport:(l,u)=>{const[c,d,h]=e.getState().transform,_=Ra.translate(l.x??c,l.y??d).scale(l.zoom??h);t.transform(ql(r,u==null?void 0:u.duration),_)},getViewport:()=>{const[l,u,c]=e.getState().transform;return{x:l,y:u,zoom:c}},fitView:l=>Ey(e.getState,l),setCenter:(l,u,c)=>{const{width:d,height:h,maxZoom:_}=e.getState(),g=typeof(c==null?void 0:c.zoom)<"u"?c.zoom:_,x=d/2-l*g,v=h/2-u*g,b=Ra.translate(x,v).scale(g);t.transform(ql(r,c==null?void 0:c.duration),b)},fitBounds:(l,u)=>{const{width:c,height:d,minZoom:h,maxZoom:_}=e.getState(),{x:g,y:x,zoom:v}=my(l,c,d,h,_,(u==null?void 0:u.padding)??.1),b=Ra.translate(g,x).scale(v);t.transform(ql(r,u==null?void 0:u.duration),b)},project:l=>{const{transform:u,snapToGrid:c,snapGrid:d}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),qm(l,u,c,d)},screenToFlowPosition:l=>{const{transform:u,snapToGrid:c,snapGrid:d,domNode:h}=e.getState();if(!h)return l;const{x:_,y:g}=h.getBoundingClientRect(),x={x:l.x-_,y:l.y-g};return qm(x,u,c,d)},flowToScreenPosition:l=>{const{transform:u,domNode:c}=e.getState();if(!c)return l;const{x:d,y:h}=c.getBoundingClientRect(),_=uy(l,u);return{x:_.x+d,y:_.y+h}},viewportInitialized:!0}:nk,[t,r])};function xh(){const e=sk(),t=as(),r=m.useCallback(()=>t.getState().getNodes().map(S=>({...S})),[]),o=m.useCallback(S=>t.getState().nodeInternals.get(S),[]),l=m.useCallback(()=>{const{edges:S=[]}=t.getState();return S.map(T=>({...T}))},[]),u=m.useCallback(S=>{const{edges:T=[]}=t.getState();return T.find(M=>M.id===S)},[]),c=m.useCallback(S=>{const{getNodes:T,setNodes:M,hasDefaultNodes:D,onNodesChange:L}=t.getState(),I=T(),G=typeof S=="function"?S(I):S;if(D)M(G);else if(L){const ne=G.length===0?I.map(Y=>({type:"remove",id:Y.id})):G.map(Y=>({item:Y,type:"reset"}));L(ne)}},[]),d=m.useCallback(S=>{const{edges:T=[],setEdges:M,hasDefaultEdges:D,onEdgesChange:L}=t.getState(),I=typeof S=="function"?S(T):S;if(D)M(I);else if(L){const G=I.length===0?T.map(ne=>({type:"remove",id:ne.id})):I.map(ne=>({item:ne,type:"reset"}));L(G)}},[]),h=m.useCallback(S=>{const T=Array.isArray(S)?S:[S],{getNodes:M,setNodes:D,hasDefaultNodes:L,onNodesChange:I}=t.getState();if(L){const ne=[...M(),...T];D(ne)}else if(I){const G=T.map(ne=>({item:ne,type:"add"}));I(G)}},[]),_=m.useCallback(S=>{const T=Array.isArray(S)?S:[S],{edges:M=[],setEdges:D,hasDefaultEdges:L,onEdgesChange:I}=t.getState();if(L)D([...M,...T]);else if(I){const G=T.map(ne=>({item:ne,type:"add"}));I(G)}},[]),g=m.useCallback(()=>{const{getNodes:S,edges:T=[],transform:M}=t.getState(),[D,L,I]=M;return{nodes:S().map(G=>({...G})),edges:T.map(G=>({...G})),viewport:{x:D,y:L,zoom:I}}},[]),x=m.useCallback(({nodes:S,edges:T})=>{const{nodeInternals:M,getNodes:D,edges:L,hasDefaultNodes:I,hasDefaultEdges:G,onNodesDelete:ne,onEdgesDelete:Y,onNodesChange:oe,onEdgesChange:le}=t.getState(),_e=(S||[]).map(X=>X.id),Te=(T||[]).map(X=>X.id),$e=D().reduce((X,V)=>{const J=!_e.includes(V.id)&&V.parentNode&&X.find(z=>z.id===V.parentNode);return(typeof V.deletable=="boolean"?V.deletable:!0)&&(_e.includes(V.id)||J)&&X.push(V),X},[]),K=L.filter(X=>typeof X.deletable=="boolean"?X.deletable:!0),U=K.filter(X=>Te.includes(X.id));if($e||U){const X=fy($e,K),V=[...U,...X],J=V.reduce((k,z)=>(k.includes(z.id)||k.push(z.id),k),[]);if((G||I)&&(G&&t.setState({edges:L.filter(k=>!J.includes(k.id))}),I&&($e.forEach(k=>{M.delete(k.id)}),t.setState({nodeInternals:new Map(M)}))),J.length>0&&(Y==null||Y(V),le&&le(J.map(k=>({id:k,type:"remove"})))),$e.length>0&&(ne==null||ne($e),oe)){const k=$e.map(z=>({id:z.id,type:"remove"}));oe(k)}}},[]),v=m.useCallback(S=>{const T=jj(S),M=T?null:t.getState().nodeInternals.get(S.id);return!T&&!M?[null,null,T]:[T?S:dg(M),M,T]},[]),b=m.useCallback((S,T=!0,M)=>{const[D,L,I]=v(S);return D?(M||t.getState().getNodes()).filter(G=>{if(!I&&(G.id===L.id||!G.positionAbsolute))return!1;const ne=dg(G),Y=Um(ne,D);return T&&Y>0||Y>=D.width*D.height}):[]},[]),j=m.useCallback((S,T,M=!0)=>{const[D]=v(S);if(!D)return!1;const L=Um(D,T);return M&&L>0||L>=D.width*D.height},[]);return m.useMemo(()=>({...e,getNodes:r,getNode:o,getEdges:l,getEdge:u,setNodes:c,setEdges:d,addNodes:h,addEdges:_,toObject:g,deleteElements:x,getIntersectingNodes:b,isNodeIntersecting:j}),[e,r,o,l,u,c,d,h,_,g,x,b,j])}const ik={actInsideInputWithModifier:!1};var ok=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const r=as(),{deleteElements:o}=xh(),l=qu(e,ik),u=qu(t);m.useEffect(()=>{if(l){const{edges:c,getNodes:d}=r.getState(),h=d().filter(g=>g.selected),_=c.filter(g=>g.selected);o({nodes:h,edges:_}),r.setState({nodesSelectionActive:!1})}},[l]),m.useEffect(()=>{r.setState({multiSelectionActive:u})},[u])};function ak(e){const t=as();m.useEffect(()=>{let r;const o=()=>{var u,c;if(!e.current)return;const l=dh(e.current);(l.height===0||l.width===0)&&((c=(u=t.getState()).onError)==null||c.call(u,"004",Pa.error004())),t.setState({width:l.width||500,height:l.height||500})};return o(),window.addEventListener("resize",o),e.current&&(r=new ResizeObserver(()=>o()),r.observe(e.current)),()=>{window.removeEventListener("resize",o),r&&e.current&&r.unobserve(e.current)}},[])}const vh={position:"absolute",width:"100%",height:"100%",top:0,left:0},lk=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Pd=e=>({x:e.x,y:e.y,zoom:e.k}),Mc=(e,t)=>e.target.closest(`.${t}`),wg=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),bg=e=>{const t=e.ctrlKey&&tf()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},ck=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),uk=({onMove:e,onMoveStart:t,onMoveEnd:r,onPaneContextMenu:o,zoomOnScroll:l=!0,zoomOnPinch:u=!0,panOnScroll:c=!1,panOnScrollSpeed:d=.5,panOnScrollMode:h=Xl.Free,zoomOnDoubleClick:_=!0,elementsSelectable:g,panOnDrag:x=!0,defaultViewport:v,translateExtent:b,minZoom:j,maxZoom:S,zoomActivationKeyCode:T,preventScrolling:M=!0,children:D,noWheelClassName:L,noPanClassName:I})=>{const G=m.useRef(),ne=as(),Y=m.useRef(!1),oe=m.useRef(!1),le=m.useRef(null),_e=m.useRef({x:0,y:0,zoom:0}),{d3Zoom:Te,d3Selection:$e,d3ZoomHandler:K,userSelectionActive:U}=ir(ck,ws),X=qu(T),V=m.useRef(0),J=m.useRef(!1),k=m.useRef();return ak(le),m.useEffect(()=>{if(le.current){const z=le.current.getBoundingClientRect(),F=Q_().scaleExtent([j,S]).translateExtent(b),N=io(le.current).call(F),B=Ra.translate(v.x,v.y).scale(Gc(v.zoom,j,S)),Z=[[0,0],[z.width,z.height]],te=F.constrain()(B,Z,b);F.transform(N,te),F.wheelDelta(bg),ne.setState({d3Zoom:F,d3Selection:N,d3ZoomHandler:N.on("wheel.zoom"),transform:[te.x,te.y,te.k],domNode:le.current.closest(".react-flow")})}},[]),m.useEffect(()=>{$e&&Te&&(c&&!X&&!U?$e.on("wheel.zoom",z=>{if(Mc(z,L))return!1;z.preventDefault(),z.stopImmediatePropagation();const F=$e.property("__zoom").k||1,N=tf();if(z.ctrlKey&&u&&N){const Re=Mo(z),Qe=bg(z),Pe=F*Math.pow(2,Qe);Te.scaleTo($e,Pe,Re,z);return}const B=z.deltaMode===1?20:1;let Z=h===Xl.Vertical?0:z.deltaX*B,te=h===Xl.Horizontal?0:z.deltaY*B;!N&&z.shiftKey&&h!==Xl.Vertical&&(Z=z.deltaY*B,te=0),Te.translateBy($e,-(Z/F)*d,-(te/F)*d,{internal:!0});const he=Pd($e.property("__zoom")),{onViewportChangeStart:Ae,onViewportChange:se,onViewportChangeEnd:ve}=ne.getState();clearTimeout(k.current),J.current||(J.current=!0,t==null||t(z,he),Ae==null||Ae(he)),J.current&&(e==null||e(z,he),se==null||se(he),k.current=setTimeout(()=>{r==null||r(z,he),ve==null||ve(he),J.current=!1},150))},{passive:!1}):typeof K<"u"&&$e.on("wheel.zoom",function(z,F){if(!M||Mc(z,L))return null;z.preventDefault(),K.call(this,z,F)},{passive:!1}))},[U,c,h,$e,Te,K,X,u,M,L,t,e,r]),m.useEffect(()=>{Te&&Te.on("start",z=>{var B,Z;if(!z.sourceEvent||z.sourceEvent.internal)return null;V.current=(B=z.sourceEvent)==null?void 0:B.button;const{onViewportChangeStart:F}=ne.getState(),N=Pd(z.transform);Y.current=!0,_e.current=N,((Z=z.sourceEvent)==null?void 0:Z.type)==="mousedown"&&ne.setState({paneDragging:!0}),F==null||F(N),t==null||t(z.sourceEvent,N)})},[Te,t]),m.useEffect(()=>{Te&&(U&&!Y.current?Te.on("zoom",null):U||Te.on("zoom",z=>{var N;const{onViewportChange:F}=ne.getState();if(ne.setState({transform:[z.transform.x,z.transform.y,z.transform.k]}),oe.current=!!(o&&wg(x,V.current??0)),(e||F)&&!((N=z.sourceEvent)!=null&&N.internal)){const B=Pd(z.transform);F==null||F(B),e==null||e(z.sourceEvent,B)}}))},[U,Te,e,x,o]),m.useEffect(()=>{Te&&Te.on("end",z=>{if(!z.sourceEvent||z.sourceEvent.internal)return null;const{onViewportChangeEnd:F}=ne.getState();if(Y.current=!1,ne.setState({paneDragging:!1}),o&&wg(x,V.current??0)&&!oe.current&&o(z.sourceEvent),oe.current=!1,(r||F)&&lk(_e.current,z.transform)){const N=Pd(z.transform);_e.current=N,clearTimeout(G.current),G.current=setTimeout(()=>{F==null||F(N),r==null||r(z.sourceEvent,N)},c?150:0)}})},[Te,c,x,r,o]),m.useEffect(()=>{Te&&Te.filter(z=>{const F=X||l,N=u&&z.ctrlKey;if((x===!0||Array.isArray(x)&&x.includes(1))&&z.button===1&&z.type==="mousedown"&&(Mc(z,"react-flow__node")||Mc(z,"react-flow__edge")))return!0;if(!x&&!F&&!c&&!_&&!u||U||!_&&z.type==="dblclick"||Mc(z,L)&&z.type==="wheel"||Mc(z,I)&&(z.type!=="wheel"||c&&z.type==="wheel"&&!X)||!u&&z.ctrlKey&&z.type==="wheel"||!F&&!c&&!N&&z.type==="wheel"||!x&&(z.type==="mousedown"||z.type==="touchstart")||Array.isArray(x)&&!x.includes(z.button)&&(z.type==="mousedown"||z.type==="touchstart"))return!1;const B=Array.isArray(x)&&x.includes(z.button)||!z.button||z.button<=1;return(!z.ctrlKey||z.type==="wheel")&&B})},[U,Te,l,u,c,_,x,g,X]),Ee.createElement("div",{className:"react-flow__renderer",ref:le,style:vh},D)},dk=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function fk(){const{userSelectionActive:e,userSelectionRect:t}=ir(dk,ws);return e&&t?Ee.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function Sg(e,t){const r=e.find(o=>o.id===t.parentNode);if(r){const o=t.position.x+t.width-r.width,l=t.position.y+t.height-r.height;if(o>0||l>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,o>0&&(r.style.width+=o),l>0&&(r.style.height+=l),t.position.x<0){const u=Math.abs(t.position.x);r.position.x=r.position.x-u,r.style.width+=u,t.position.x=0}if(t.position.y<0){const u=Math.abs(t.position.y);r.position.y=r.position.y-u,r.style.height+=u,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function mk(e,t){if(e.some(o=>o.type==="reset"))return e.filter(o=>o.type==="reset").map(o=>o.item);const r=e.filter(o=>o.type==="add").map(o=>o.item);return t.reduce((o,l)=>{const u=e.filter(d=>d.id===l.id);if(u.length===0)return o.push(l),o;const c={...l};for(const d of u)if(d)switch(d.type){case"select":{c.selected=d.selected;break}case"position":{typeof d.position<"u"&&(c.position=d.position),typeof d.positionAbsolute<"u"&&(c.positionAbsolute=d.positionAbsolute),typeof d.dragging<"u"&&(c.dragging=d.dragging),c.expandParent&&Sg(o,c);break}case"dimensions":{typeof d.dimensions<"u"&&(c.width=d.dimensions.width,c.height=d.dimensions.height),typeof d.updateStyle<"u"&&(c.style={...c.style||{},...d.dimensions}),typeof d.resizing=="boolean"&&(c.resizing=d.resizing),c.expandParent&&Sg(o,c);break}case"remove":return o}return o.push(c),o},r)}function hk(e,t){return mk(e,t)}const hl=(e,t)=>({id:e,type:"select",selected:t});function Oc(e,t){return e.reduce((r,o)=>{const l=t.includes(o.id);return!o.selected&&l?(o.selected=!0,r.push(hl(o.id,!0))):o.selected&&!l&&(o.selected=!1,r.push(hl(o.id,!1))),r},[])}const hm=(e,t)=>r=>{r.target===t.current&&(e==null||e(r))},pk=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),$y=m.memo(({isSelecting:e,selectionMode:t=Hu.Full,panOnDrag:r,onSelectionStart:o,onSelectionEnd:l,onPaneClick:u,onPaneContextMenu:c,onPaneScroll:d,onPaneMouseEnter:h,onPaneMouseMove:_,onPaneMouseLeave:g,children:x})=>{const v=m.useRef(null),b=as(),j=m.useRef(0),S=m.useRef(0),T=m.useRef(),{userSelectionActive:M,elementsSelectable:D,dragging:L}=ir(pk,ws),I=()=>{b.setState({userSelectionActive:!1,userSelectionRect:null}),j.current=0,S.current=0},G=K=>{u==null||u(K),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},ne=K=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){K.preventDefault();return}c==null||c(K)},Y=d?K=>d(K):void 0,oe=K=>{const{resetSelectedElements:U,domNode:X}=b.getState();if(T.current=X==null?void 0:X.getBoundingClientRect(),!D||!e||K.button!==0||K.target!==v.current||!T.current)return;const{x:V,y:J}=gl(K,T.current);U(),b.setState({userSelectionRect:{width:0,height:0,startX:V,startY:J,x:V,y:J}}),o==null||o(K)},le=K=>{const{userSelectionRect:U,nodeInternals:X,edges:V,transform:J,onNodesChange:k,onEdgesChange:z,nodeOrigin:F,getNodes:N}=b.getState();if(!e||!T.current||!U)return;b.setState({userSelectionActive:!0,nodesSelectionActive:!1});const B=gl(K,T.current),Z=U.startX??0,te=U.startY??0,he={...U,x:B.x<Z?B.x:Z,y:B.y<te?B.y:te,width:Math.abs(B.x-Z),height:Math.abs(B.y-te)},Ae=N(),se=dy(X,he,J,t===Hu.Partial,!0,F),ve=fy(se,V).map(Qe=>Qe.id),Re=se.map(Qe=>Qe.id);if(j.current!==Re.length){j.current=Re.length;const Qe=Oc(Ae,Re);Qe.length&&(k==null||k(Qe))}if(S.current!==ve.length){S.current=ve.length;const Qe=Oc(V,ve);Qe.length&&(z==null||z(Qe))}b.setState({userSelectionRect:he})},_e=K=>{if(K.button!==0)return;const{userSelectionRect:U}=b.getState();!M&&U&&K.target===v.current&&(G==null||G(K)),b.setState({nodesSelectionActive:j.current>0}),I(),l==null||l(K)},Te=K=>{M&&(b.setState({nodesSelectionActive:j.current>0}),l==null||l(K)),I()},$e=D&&(e||M);return Ee.createElement("div",{className:Cs(["react-flow__pane",{dragging:L,selection:e}]),onClick:$e?void 0:hm(G,v),onContextMenu:hm(ne,v),onWheel:hm(Y,v),onMouseEnter:$e?void 0:h,onMouseDown:$e?oe:void 0,onMouseMove:$e?le:_,onMouseUp:$e?_e:void 0,onMouseLeave:$e?Te:g,ref:v,style:vh},x,Ee.createElement(fk,null))});$y.displayName="Pane";function Ay(e,t){if(!e.parentNode)return!1;const r=t.get(e.parentNode);return r?r.selected?!0:Ay(r,t):!1}function jg(e,t,r){let o=e;do{if(o!=null&&o.matches(t))return!0;if(o===r.current)return!1;o=o.parentElement}while(o);return!1}function gk(e,t,r,o){return Array.from(e.values()).filter(l=>(l.selected||l.id===o)&&(!l.parentNode||!Ay(l,e))&&(l.draggable||t&&typeof l.draggable>"u")).map(l=>{var u,c;return{id:l.id,position:l.position||{x:0,y:0},positionAbsolute:l.positionAbsolute||{x:0,y:0},distance:{x:r.x-(((u=l.positionAbsolute)==null?void 0:u.x)??0),y:r.y-(((c=l.positionAbsolute)==null?void 0:c.y)??0)},delta:{x:0,y:0},extent:l.extent,parentNode:l.parentNode,width:l.width,height:l.height,expandParent:l.expandParent}})}function _k(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function Ty(e,t,r,o,l=[0,0],u){const c=_k(e,e.extent||o);let d=c;if(e.extent==="parent"&&!e.expandParent)if(e.parentNode&&e.width&&e.height){const g=r.get(e.parentNode),{x,y:v}=Jl(g,l).positionAbsolute;d=g&&oo(x)&&oo(v)&&oo(g.width)&&oo(g.height)?[[x+e.width*l[0],v+e.height*l[1]],[x+g.width-e.width+e.width*l[0],v+g.height-e.height+e.height*l[1]]]:d}else u==null||u("005",Pa.error005()),d=c;else if(e.extent&&e.parentNode&&e.extent!=="parent"){const g=r.get(e.parentNode),{x,y:v}=Jl(g,l).positionAbsolute;d=[[e.extent[0][0]+x,e.extent[0][1]+v],[e.extent[1][0]+x,e.extent[1][1]+v]]}let h={x:0,y:0};if(e.parentNode){const g=r.get(e.parentNode);h=Jl(g,l).positionAbsolute}const _=d&&d!=="parent"?fh(t,d):t;return{position:{x:_.x-h.x,y:_.y-h.y},positionAbsolute:_}}function pm({nodeId:e,dragItems:t,nodeInternals:r}){const o=t.map(l=>({...r.get(l.id),position:l.position,positionAbsolute:l.positionAbsolute}));return[e?o.find(l=>l.id===e):o[0],o]}const kg=(e,t,r,o)=>{const l=t.querySelectorAll(e);if(!l||!l.length)return null;const u=Array.from(l),c=t.getBoundingClientRect(),d={x:c.width*o[0],y:c.height*o[1]};return u.map(h=>{const _=h.getBoundingClientRect();return{id:h.getAttribute("data-handleid"),position:h.getAttribute("data-handlepos"),x:(_.left-c.left-d.x)/r,y:(_.top-c.top-d.y)/r,...dh(h)}})};function Cu(e,t,r){return r===void 0?r:o=>{const l=t().nodeInternals.get(e);l&&r(o,{...l})}}function Ym({id:e,store:t,unselect:r=!1,nodeRef:o}){const{addSelectedNodes:l,unselectNodesAndEdges:u,multiSelectionActive:c,nodeInternals:d,onError:h}=t.getState(),_=d.get(e);if(!_){h==null||h("012",Pa.error012(e));return}t.setState({nodesSelectionActive:!1}),_.selected?(r||_.selected&&c)&&(u({nodes:[_],edges:[]}),requestAnimationFrame(()=>{var g;return(g=o==null?void 0:o.current)==null?void 0:g.blur()})):l([e])}function yk(){const e=as();return m.useCallback(({sourceEvent:r})=>{const{transform:o,snapGrid:l,snapToGrid:u}=e.getState(),c=r.touches?r.touches[0].clientX:r.clientX,d=r.touches?r.touches[0].clientY:r.clientY,h={x:(c-o[0])/o[2],y:(d-o[1])/o[2]};return{xSnapped:u?l[0]*Math.round(h.x/l[0]):h.x,ySnapped:u?l[1]*Math.round(h.y/l[1]):h.y,...h}},[])}function gm(e){return(t,r,o)=>e==null?void 0:e(t,o)}function My({nodeRef:e,disabled:t=!1,noDragClassName:r,handleSelector:o,nodeId:l,isSelectable:u,selectNodesOnDrag:c}){const d=as(),[h,_]=m.useState(!1),g=m.useRef([]),x=m.useRef({x:null,y:null}),v=m.useRef(0),b=m.useRef(null),j=m.useRef({x:0,y:0}),S=m.useRef(null),T=m.useRef(!1),M=m.useRef(!1),D=yk();return m.useEffect(()=>{if(e!=null&&e.current){const L=io(e.current),I=({x:Y,y:oe})=>{const{nodeInternals:le,onNodeDrag:_e,onSelectionDrag:Te,updateNodePositions:$e,nodeExtent:K,snapGrid:U,snapToGrid:X,nodeOrigin:V,onError:J}=d.getState();x.current={x:Y,y:oe};let k=!1,z={x:0,y:0,x2:0,y2:0};if(g.current.length>1&&K){const N=hf(g.current,V);z=Wu(N)}if(g.current=g.current.map(N=>{const B={x:Y-N.distance.x,y:oe-N.distance.y};X&&(B.x=U[0]*Math.round(B.x/U[0]),B.y=U[1]*Math.round(B.y/U[1]));const Z=[[K[0][0],K[0][1]],[K[1][0],K[1][1]]];g.current.length>1&&K&&!N.extent&&(Z[0][0]=N.positionAbsolute.x-z.x+K[0][0],Z[1][0]=N.positionAbsolute.x+(N.width??0)-z.x2+K[1][0],Z[0][1]=N.positionAbsolute.y-z.y+K[0][1],Z[1][1]=N.positionAbsolute.y+(N.height??0)-z.y2+K[1][1]);const te=Ty(N,B,le,Z,V,J);return k=k||N.position.x!==te.position.x||N.position.y!==te.position.y,N.position=te.position,N.positionAbsolute=te.positionAbsolute,N}),!k)return;$e(g.current,!0,!0),_(!0);const F=l?_e:gm(Te);if(F&&S.current){const[N,B]=pm({nodeId:l,dragItems:g.current,nodeInternals:le});F(S.current,N,B)}},G=()=>{if(!b.current)return;const[Y,oe]=ey(j.current,b.current);if(Y!==0||oe!==0){const{transform:le,panBy:_e}=d.getState();x.current.x=(x.current.x??0)-Y/le[2],x.current.y=(x.current.y??0)-oe/le[2],_e({x:Y,y:oe})&&I(x.current)}v.current=requestAnimationFrame(G)},ne=Y=>{var V;const{nodeInternals:oe,multiSelectionActive:le,nodesDraggable:_e,unselectNodesAndEdges:Te,onNodeDragStart:$e,onSelectionDragStart:K}=d.getState();M.current=!0;const U=l?$e:gm(K);(!c||!u)&&!le&&l&&((V=oe.get(l))!=null&&V.selected||Te()),l&&u&&c&&Ym({id:l,store:d,nodeRef:e});const X=D(Y);if(x.current=X,g.current=gk(oe,_e,X,l),U&&g.current){const[J,k]=pm({nodeId:l,dragItems:g.current,nodeInternals:oe});U(Y.sourceEvent,J,k)}};if(t)L.on(".drag",null);else{const Y=Eb().on("start",oe=>{const{domNode:le,nodeDragThreshold:_e}=d.getState();_e===0&&ne(oe);const Te=D(oe);x.current=Te,b.current=(le==null?void 0:le.getBoundingClientRect())||null,j.current=gl(oe.sourceEvent,b.current)}).on("drag",oe=>{var $e,K;const le=D(oe),{autoPanOnNodeDrag:_e,nodeDragThreshold:Te}=d.getState();if(!T.current&&M.current&&_e&&(T.current=!0,G()),!M.current){const U=le.xSnapped-((($e=x==null?void 0:x.current)==null?void 0:$e.x)??0),X=le.ySnapped-(((K=x==null?void 0:x.current)==null?void 0:K.y)??0);Math.sqrt(U*U+X*X)>Te&&ne(oe)}(x.current.x!==le.xSnapped||x.current.y!==le.ySnapped)&&g.current&&M.current&&(S.current=oe.sourceEvent,j.current=gl(oe.sourceEvent,b.current),I(le))}).on("end",oe=>{if(M.current&&(_(!1),T.current=!1,M.current=!1,cancelAnimationFrame(v.current),g.current)){const{updateNodePositions:le,nodeInternals:_e,onNodeDragStop:Te,onSelectionDragStop:$e}=d.getState(),K=l?Te:gm($e);if(le(g.current,!1,!1),K){const[U,X]=pm({nodeId:l,dragItems:g.current,nodeInternals:_e});K(oe.sourceEvent,U,X)}}}).filter(oe=>{const le=oe.target;return!oe.button&&(!r||!jg(le,`.${r}`,e))&&(!o||jg(le,o,e))});return L.call(Y),()=>{L.on(".drag",null)}}}},[e,t,r,o,u,d,l,c,D]),h}function zy(){const e=as();return m.useCallback(r=>{const{nodeInternals:o,nodeExtent:l,updateNodePositions:u,getNodes:c,snapToGrid:d,snapGrid:h,onError:_,nodesDraggable:g}=e.getState(),x=c().filter(D=>D.selected&&(D.draggable||g&&typeof D.draggable>"u")),v=d?h[0]:5,b=d?h[1]:5,j=r.isShiftPressed?4:1,S=r.x*v*j,T=r.y*b*j,M=x.map(D=>{if(D.positionAbsolute){const L={x:D.positionAbsolute.x+S,y:D.positionAbsolute.y+T};d&&(L.x=h[0]*Math.round(L.x/h[0]),L.y=h[1]*Math.round(L.y/h[1]));const{positionAbsolute:I,position:G}=Ty(D,L,o,l,void 0,_);D.position=G,D.positionAbsolute=I}return D});u(M,!0,!1)},[])}const Wc={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Eu=e=>{const t=({id:r,type:o,data:l,xPos:u,yPos:c,xPosOrigin:d,yPosOrigin:h,selected:_,onClick:g,onMouseEnter:x,onMouseMove:v,onMouseLeave:b,onContextMenu:j,onDoubleClick:S,style:T,className:M,isDraggable:D,isSelectable:L,isConnectable:I,isFocusable:G,selectNodesOnDrag:ne,sourcePosition:Y,targetPosition:oe,hidden:le,resizeObserver:_e,dragHandle:Te,zIndex:$e,isParent:K,noDragClassName:U,noPanClassName:X,initialized:V,disableKeyboardA11y:J,ariaLabel:k,rfId:z,hasHandleBounds:F})=>{const N=as(),B=m.useRef(null),Z=m.useRef(Y),te=m.useRef(oe),he=m.useRef(o),Ae=L||D||g||x||v||b,se=zy(),ve=Cu(r,N.getState,x),Re=Cu(r,N.getState,v),Qe=Cu(r,N.getState,b),Pe=Cu(r,N.getState,j),de=Cu(r,N.getState,S),be=tt=>{const{nodeDragThreshold:ze}=N.getState();if(L&&(!ne||!D||ze>0)&&Ym({id:r,store:N,nodeRef:B}),g){const Oe=N.getState().nodeInternals.get(r);Oe&&g(tt,{...Oe})}},Fe=tt=>{if(!Wm(tt))if(sy.includes(tt.key)&&L){const ze=tt.key==="Escape";Ym({id:r,store:N,unselect:ze,nodeRef:B})}else!J&&D&&_&&Object.prototype.hasOwnProperty.call(Wc,tt.key)&&(N.setState({ariaLiveMessage:`Moved selected node ${tt.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~u}, y: ${~~c}`}),se({x:Wc[tt.key].x,y:Wc[tt.key].y,isShiftPressed:tt.shiftKey}))};m.useEffect(()=>()=>{B.current&&(_e==null||_e.unobserve(B.current))},[]),m.useEffect(()=>{if(B.current&&!le){const tt=B.current;(!V||!F)&&(_e==null||_e.unobserve(tt),_e==null||_e.observe(tt))}},[le,V,F]),m.useEffect(()=>{const tt=he.current!==o,ze=Z.current!==Y,Oe=te.current!==oe;B.current&&(tt||ze||Oe)&&(tt&&(he.current=o),ze&&(Z.current=Y),Oe&&(te.current=oe),N.getState().updateNodeDimensions([{id:r,nodeElement:B.current,forceUpdate:!0}]))},[r,o,Y,oe]);const Xe=My({nodeRef:B,disabled:le||!D,noDragClassName:U,handleSelector:Te,nodeId:r,isSelectable:L,selectNodesOnDrag:ne});return le?null:Ee.createElement("div",{className:Cs(["react-flow__node",`react-flow__node-${o}`,{[X]:D},M,{selected:_,selectable:L,parent:K,dragging:Xe}]),ref:B,style:{zIndex:$e,transform:`translate(${d}px,${h}px)`,pointerEvents:Ae?"all":"none",visibility:V?"visible":"hidden",...T},"data-id":r,"data-testid":`rf__node-${r}`,onMouseEnter:ve,onMouseMove:Re,onMouseLeave:Qe,onContextMenu:Pe,onClick:be,onDoubleClick:de,onKeyDown:G?Fe:void 0,tabIndex:G?0:void 0,role:G?"button":void 0,"aria-describedby":J?void 0:`${jy}-${z}`,"aria-label":k},Ee.createElement(Tj,{value:r},Ee.createElement(e,{id:r,data:l,type:o,xPos:u,yPos:c,selected:_,isConnectable:I,sourcePosition:Y,targetPosition:oe,dragging:Xe,dragHandle:Te,zIndex:$e})))};return t.displayName="NodeWrapper",m.memo(t)};const xk=e=>{const t=e.getNodes().filter(r=>r.selected);return{...hf(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function vk({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:r}){const o=as(),{width:l,height:u,x:c,y:d,transformString:h,userSelectionActive:_}=ir(xk,ws),g=zy(),x=m.useRef(null);if(m.useEffect(()=>{var j;r||(j=x.current)==null||j.focus({preventScroll:!0})},[r]),My({nodeRef:x}),_||!l||!u)return null;const v=e?j=>{const S=o.getState().getNodes().filter(T=>T.selected);e(j,S)}:void 0,b=j=>{Object.prototype.hasOwnProperty.call(Wc,j.key)&&g({x:Wc[j.key].x,y:Wc[j.key].y,isShiftPressed:j.shiftKey})};return Ee.createElement("div",{className:Cs(["react-flow__nodesselection","react-flow__container",t]),style:{transform:h}},Ee.createElement("div",{ref:x,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:r?void 0:-1,onKeyDown:r?void 0:b,style:{width:l,height:u,top:d,left:c}}))}var wk=m.memo(vk);const bk=e=>e.nodesSelectionActive,Ry=({children:e,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:o,onPaneMouseLeave:l,onPaneContextMenu:u,onPaneScroll:c,deleteKeyCode:d,onMove:h,onMoveStart:_,onMoveEnd:g,selectionKeyCode:x,selectionOnDrag:v,selectionMode:b,onSelectionStart:j,onSelectionEnd:S,multiSelectionKeyCode:T,panActivationKeyCode:M,zoomActivationKeyCode:D,elementsSelectable:L,zoomOnScroll:I,zoomOnPinch:G,panOnScroll:ne,panOnScrollSpeed:Y,panOnScrollMode:oe,zoomOnDoubleClick:le,panOnDrag:_e,defaultViewport:Te,translateExtent:$e,minZoom:K,maxZoom:U,preventScrolling:X,onSelectionContextMenu:V,noWheelClassName:J,noPanClassName:k,disableKeyboardA11y:z})=>{const F=ir(bk),N=qu(x),B=qu(M),Z=B||_e,te=B||ne,he=N||v&&Z!==!0;return ok({deleteKeyCode:d,multiSelectionKeyCode:T}),Ee.createElement(uk,{onMove:h,onMoveStart:_,onMoveEnd:g,onPaneContextMenu:u,elementsSelectable:L,zoomOnScroll:I,zoomOnPinch:G,panOnScroll:te,panOnScrollSpeed:Y,panOnScrollMode:oe,zoomOnDoubleClick:le,panOnDrag:!N&&Z,defaultViewport:Te,translateExtent:$e,minZoom:K,maxZoom:U,zoomActivationKeyCode:D,preventScrolling:X,noWheelClassName:J,noPanClassName:k},Ee.createElement($y,{onSelectionStart:j,onSelectionEnd:S,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:o,onPaneMouseLeave:l,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:Z,isSelecting:!!he,selectionMode:b},e,F&&Ee.createElement(wk,{onSelectionContextMenu:V,noPanClassName:k,disableKeyboardA11y:z})))};Ry.displayName="FlowRenderer";var Sk=m.memo(Ry);function jk(e){return ir(m.useCallback(r=>e?dy(r.nodeInternals,{x:0,y:0,width:r.width,height:r.height},r.transform,!0):r.getNodes(),[e]))}function kk(e){const t={input:Eu(e.input||vy),default:Eu(e.default||Gm),output:Eu(e.output||by),group:Eu(e.group||yh)},r={},o=Object.keys(e).filter(l=>!["input","default","output","group"].includes(l)).reduce((l,u)=>(l[u]=Eu(e[u]||Gm),l),r);return{...t,...o}}const Nk=({x:e,y:t,width:r,height:o,origin:l})=>!r||!o?{x:e,y:t}:l[0]<0||l[1]<0||l[0]>1||l[1]>1?{x:e,y:t}:{x:e-r*l[0],y:t-o*l[1]},Ck=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),Ly=e=>{const{nodesDraggable:t,nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,updateNodeDimensions:u,onError:c}=ir(Ck,ws),d=jk(e.onlyRenderVisibleElements),h=m.useRef(),_=m.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const g=new ResizeObserver(x=>{const v=x.map(b=>({id:b.target.getAttribute("data-id"),nodeElement:b.target,forceUpdate:!0}));u(v)});return h.current=g,g},[]);return m.useEffect(()=>()=>{var g;(g=h==null?void 0:h.current)==null||g.disconnect()},[]),Ee.createElement("div",{className:"react-flow__nodes",style:vh},d.map(g=>{var G,ne,Y;let x=g.type||"default";e.nodeTypes[x]||(c==null||c("003",Pa.error003(x)),x="default");const v=e.nodeTypes[x]||e.nodeTypes.default,b=!!(g.draggable||t&&typeof g.draggable>"u"),j=!!(g.selectable||l&&typeof g.selectable>"u"),S=!!(g.connectable||r&&typeof g.connectable>"u"),T=!!(g.focusable||o&&typeof g.focusable>"u"),M=e.nodeExtent?fh(g.positionAbsolute,e.nodeExtent):g.positionAbsolute,D=(M==null?void 0:M.x)??0,L=(M==null?void 0:M.y)??0,I=Nk({x:D,y:L,width:g.width??0,height:g.height??0,origin:e.nodeOrigin});return Ee.createElement(v,{key:g.id,id:g.id,className:g.className,style:g.style,type:x,data:g.data,sourcePosition:g.sourcePosition||Ft.Bottom,targetPosition:g.targetPosition||Ft.Top,hidden:g.hidden,xPos:D,yPos:L,xPosOrigin:I.x,yPosOrigin:I.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!g.selected,isDraggable:b,isSelectable:j,isConnectable:S,isFocusable:T,resizeObserver:_,dragHandle:g.dragHandle,zIndex:((G=g[Kr])==null?void 0:G.z)??0,isParent:!!((ne=g[Kr])!=null&&ne.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!g.width&&!!g.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:g.ariaLabel,hasHandleBounds:!!((Y=g[Kr])!=null&&Y.handleBounds)})}))};Ly.displayName="NodeRenderer";var Ek=m.memo(Ly);const $k=(e,t,r)=>r===Ft.Left?e-t:r===Ft.Right?e+t:e,Ak=(e,t,r)=>r===Ft.Top?e-t:r===Ft.Bottom?e+t:e,Ng="react-flow__edgeupdater",Cg=({position:e,centerX:t,centerY:r,radius:o=10,onMouseDown:l,onMouseEnter:u,onMouseOut:c,type:d})=>Ee.createElement("circle",{onMouseDown:l,onMouseEnter:u,onMouseOut:c,className:Cs([Ng,`${Ng}-${d}`]),cx:$k(t,o,e),cy:Ak(r,o,e),r:o,stroke:"transparent",fill:"transparent"}),Tk=()=>!0;var zc=e=>{const t=({id:r,className:o,type:l,data:u,onClick:c,onEdgeDoubleClick:d,selected:h,animated:_,label:g,labelStyle:x,labelShowBg:v,labelBgStyle:b,labelBgPadding:j,labelBgBorderRadius:S,style:T,source:M,target:D,sourceX:L,sourceY:I,targetX:G,targetY:ne,sourcePosition:Y,targetPosition:oe,elementsSelectable:le,hidden:_e,sourceHandleId:Te,targetHandleId:$e,onContextMenu:K,onMouseEnter:U,onMouseMove:X,onMouseLeave:V,edgeUpdaterRadius:J,onEdgeUpdate:k,onEdgeUpdateStart:z,onEdgeUpdateEnd:F,markerEnd:N,markerStart:B,rfId:Z,ariaLabel:te,isFocusable:he,isUpdatable:Ae,pathOptions:se,interactionWidth:ve})=>{const Re=m.useRef(null),[Qe,Pe]=m.useState(!1),[de,be]=m.useState(!1),Fe=as(),Xe=m.useMemo(()=>`url('#${Vm(B,Z)}')`,[B,Z]),tt=m.useMemo(()=>`url('#${Vm(N,Z)}')`,[N,Z]);if(_e)return null;const ze=pt=>{var Sn;const{edges:qt,addSelectedEdges:Dn,unselectNodesAndEdges:nn,multiSelectionActive:cn}=Fe.getState(),vn=qt.find(cr=>cr.id===r);vn&&(le&&(Fe.setState({nodesSelectionActive:!1}),vn.selected&&cn?(nn({nodes:[],edges:[vn]}),(Sn=Re.current)==null||Sn.blur()):Dn([r])),c&&c(pt,vn))},Oe=Nu(r,Fe.getState,d),lt=Nu(r,Fe.getState,K),xe=Nu(r,Fe.getState,U),Et=Nu(r,Fe.getState,X),yt=Nu(r,Fe.getState,V),sn=(pt,qt)=>{if(pt.button!==0)return;const{edges:Dn,isValidConnection:nn}=Fe.getState(),cn=qt?D:M,vn=(qt?$e:Te)||null,Sn=qt?"target":"source",cr=nn||Tk,Qt=qt,Zn=Dn.find(me=>me.id===r);be(!0),z==null||z(pt,Zn,Sn);const ls=me=>{be(!1),F==null||F(me,Zn,Sn)};gy({event:pt,handleId:vn,nodeId:cn,onConnect:me=>k==null?void 0:k(Zn,me),isTarget:Qt,getState:Fe.getState,setState:Fe.setState,isValidConnection:cr,edgeUpdaterType:Sn,onEdgeUpdateEnd:ls})},ln=pt=>sn(pt,!0),Xt=pt=>sn(pt,!1),je=()=>Pe(!0),ue=()=>Pe(!1),Ne=!le&&!c,$t=pt=>{var qt;if(sy.includes(pt.key)&&le){const{unselectNodesAndEdges:Dn,addSelectedEdges:nn,edges:cn}=Fe.getState();pt.key==="Escape"?((qt=Re.current)==null||qt.blur(),Dn({edges:[cn.find(Sn=>Sn.id===r)]})):nn([r])}};return Ee.createElement("g",{className:Cs(["react-flow__edge",`react-flow__edge-${l}`,o,{selected:h,animated:_,inactive:Ne,updating:Qe}]),onClick:ze,onDoubleClick:Oe,onContextMenu:lt,onMouseEnter:xe,onMouseMove:Et,onMouseLeave:yt,onKeyDown:he?$t:void 0,tabIndex:he?0:void 0,role:he?"button":"img","data-testid":`rf__edge-${r}`,"aria-label":te===null?void 0:te||`Edge from ${M} to ${D}`,"aria-describedby":he?`${ky}-${Z}`:void 0,ref:Re},!de&&Ee.createElement(e,{id:r,source:M,target:D,selected:h,animated:_,label:g,labelStyle:x,labelShowBg:v,labelBgStyle:b,labelBgPadding:j,labelBgBorderRadius:S,data:u,style:T,sourceX:L,sourceY:I,targetX:G,targetY:ne,sourcePosition:Y,targetPosition:oe,sourceHandleId:Te,targetHandleId:$e,markerStart:Xe,markerEnd:tt,pathOptions:se,interactionWidth:ve}),Ae&&Ee.createElement(Ee.Fragment,null,(Ae==="source"||Ae===!0)&&Ee.createElement(Cg,{position:Y,centerX:L,centerY:I,radius:J,onMouseDown:ln,onMouseEnter:je,onMouseOut:ue,type:"source"}),(Ae==="target"||Ae===!0)&&Ee.createElement(Cg,{position:oe,centerX:G,centerY:ne,radius:J,onMouseDown:Xt,onMouseEnter:je,onMouseOut:ue,type:"target"})))};return t.displayName="EdgeWrapper",m.memo(t)};function Mk(e){const t={default:zc(e.default||nf),straight:zc(e.bezier||ph),step:zc(e.step||hh),smoothstep:zc(e.step||mf),simplebezier:zc(e.simplebezier||mh)},r={},o=Object.keys(e).filter(l=>!["default","bezier"].includes(l)).reduce((l,u)=>(l[u]=zc(e[u]||nf),l),r);return{...t,...o}}function Eg(e,t,r=null){const o=((r==null?void 0:r.x)||0)+t.x,l=((r==null?void 0:r.y)||0)+t.y,u=(r==null?void 0:r.width)||t.width,c=(r==null?void 0:r.height)||t.height;switch(e){case Ft.Top:return{x:o+u/2,y:l};case Ft.Right:return{x:o+u,y:l+c/2};case Ft.Bottom:return{x:o+u/2,y:l+c};case Ft.Left:return{x:o,y:l+c/2}}}function $g(e,t){return e?e.length===1||!t?e[0]:t&&e.find(r=>r.id===t)||null:null}const zk=(e,t,r,o,l,u)=>{const c=Eg(r,e,t),d=Eg(u,o,l);return{sourceX:c.x,sourceY:c.y,targetX:d.x,targetY:d.y}};function Rk({sourcePos:e,targetPos:t,sourceWidth:r,sourceHeight:o,targetWidth:l,targetHeight:u,width:c,height:d,transform:h}){const _={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+r,t.x+l),y2:Math.max(e.y+o,t.y+u)};_.x===_.x2&&(_.x2+=1),_.y===_.y2&&(_.y2+=1);const g=Wu({x:(0-h[0])/h[2],y:(0-h[1])/h[2],width:c/h[2],height:d/h[2]}),x=Math.max(0,Math.min(g.x2,_.x2)-Math.max(g.x,_.x)),v=Math.max(0,Math.min(g.y2,_.y2)-Math.max(g.y,_.y));return Math.ceil(x*v)>0}function Ag(e){var o,l,u,c,d;const t=((o=e==null?void 0:e[Kr])==null?void 0:o.handleBounds)||null,r=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.x)<"u"&&typeof((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.y)<"u";return[{x:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.x)||0,y:((d=e==null?void 0:e.positionAbsolute)==null?void 0:d.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!r]}const Lk=[{level:0,isMaxLevel:!0,edges:[]}];function Pk(e,t,r=!1){let o=-1;const l=e.reduce((c,d)=>{var g,x;const h=oo(d.zIndex);let _=h?d.zIndex:0;if(r){const v=t.get(d.target),b=t.get(d.source),j=d.selected||(v==null?void 0:v.selected)||(b==null?void 0:b.selected),S=Math.max(((g=b==null?void 0:b[Kr])==null?void 0:g.z)||0,((x=v==null?void 0:v[Kr])==null?void 0:x.z)||0,1e3);_=(h?d.zIndex:0)+(j?S:0)}return c[_]?c[_].push(d):c[_]=[d],o=_>o?_:o,c},{}),u=Object.entries(l).map(([c,d])=>{const h=+c;return{edges:d,level:h,isMaxLevel:h===o}});return u.length===0?Lk:u}function Ik(e,t,r){const o=ir(m.useCallback(l=>e?l.edges.filter(u=>{const c=t.get(u.source),d=t.get(u.target);return(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&(d==null?void 0:d.width)&&(d==null?void 0:d.height)&&Rk({sourcePos:c.positionAbsolute||{x:0,y:0},targetPos:d.positionAbsolute||{x:0,y:0},sourceWidth:c.width,sourceHeight:c.height,targetWidth:d.width,targetHeight:d.height,width:l.width,height:l.height,transform:l.transform})}):l.edges,[e,t]));return Pk(o,t,r)}const Fk=({color:e="none",strokeWidth:t=1})=>Ee.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),Ok=({color:e="none",strokeWidth:t=1})=>Ee.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Tg={[Vu.Arrow]:Fk,[Vu.ArrowClosed]:Ok};function Dk(e){const t=as();return m.useMemo(()=>{var l,u;return Object.prototype.hasOwnProperty.call(Tg,e)?Tg[e]:((u=(l=t.getState()).onError)==null||u.call(l,"009",Pa.error009(e)),null)},[e])}const Bk=({id:e,type:t,color:r,width:o=12.5,height:l=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:d="auto-start-reverse"})=>{const h=Dk(t);return h?Ee.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${l}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:d,refX:"0",refY:"0"},Ee.createElement(h,{color:r,strokeWidth:c})):null},Uk=({defaultColor:e,rfId:t})=>r=>{const o=[];return r.edges.reduce((l,u)=>([u.markerStart,u.markerEnd].forEach(c=>{if(c&&typeof c=="object"){const d=Vm(c,t);o.includes(d)||(l.push({id:d,color:c.color||e,...c}),o.push(d))}}),l),[]).sort((l,u)=>l.id.localeCompare(u.id))},Py=({defaultColor:e,rfId:t})=>{const r=ir(m.useCallback(Uk({defaultColor:e,rfId:t}),[e,t]),(o,l)=>!(o.length!==l.length||o.some((u,c)=>u.id!==l[c].id)));return Ee.createElement("defs",null,r.map(o=>Ee.createElement(Bk,{id:o.id,key:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient})))};Py.displayName="MarkerDefinitions";var Wk=m.memo(Py);const Hk=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),Iy=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:r,rfId:o,edgeTypes:l,noPanClassName:u,onEdgeUpdate:c,onEdgeContextMenu:d,onEdgeMouseEnter:h,onEdgeMouseMove:_,onEdgeMouseLeave:g,onEdgeClick:x,edgeUpdaterRadius:v,onEdgeDoubleClick:b,onEdgeUpdateStart:j,onEdgeUpdateEnd:S,children:T})=>{const{edgesFocusable:M,edgesUpdatable:D,elementsSelectable:L,width:I,height:G,connectionMode:ne,nodeInternals:Y,onError:oe}=ir(Hk,ws),le=Ik(t,Y,r);return I?Ee.createElement(Ee.Fragment,null,le.map(({level:_e,edges:Te,isMaxLevel:$e})=>Ee.createElement("svg",{key:_e,style:{zIndex:_e},width:I,height:G,className:"react-flow__edges react-flow__container"},$e&&Ee.createElement(Wk,{defaultColor:e,rfId:o}),Ee.createElement("g",null,Te.map(K=>{const[U,X,V]=Ag(Y.get(K.source)),[J,k,z]=Ag(Y.get(K.target));if(!V||!z)return null;let F=K.type||"default";l[F]||(oe==null||oe("011",Pa.error011(F)),F="default");const N=l[F]||l.default,B=ne===Zl.Strict?k.target:(k.target??[]).concat(k.source??[]),Z=$g(X.source,K.sourceHandle),te=$g(B,K.targetHandle),he=(Z==null?void 0:Z.position)||Ft.Bottom,Ae=(te==null?void 0:te.position)||Ft.Top,se=!!(K.focusable||M&&typeof K.focusable>"u"),ve=typeof c<"u"&&(K.updatable||D&&typeof K.updatable>"u");if(!Z||!te)return oe==null||oe("008",Pa.error008(Z,K)),null;const{sourceX:Re,sourceY:Qe,targetX:Pe,targetY:de}=zk(U,Z,he,J,te,Ae);return Ee.createElement(N,{key:K.id,id:K.id,className:Cs([K.className,u]),type:F,data:K.data,selected:!!K.selected,animated:!!K.animated,hidden:!!K.hidden,label:K.label,labelStyle:K.labelStyle,labelShowBg:K.labelShowBg,labelBgStyle:K.labelBgStyle,labelBgPadding:K.labelBgPadding,labelBgBorderRadius:K.labelBgBorderRadius,style:K.style,source:K.source,target:K.target,sourceHandleId:K.sourceHandle,targetHandleId:K.targetHandle,markerEnd:K.markerEnd,markerStart:K.markerStart,sourceX:Re,sourceY:Qe,targetX:Pe,targetY:de,sourcePosition:he,targetPosition:Ae,elementsSelectable:L,onEdgeUpdate:c,onContextMenu:d,onMouseEnter:h,onMouseMove:_,onMouseLeave:g,onClick:x,edgeUpdaterRadius:v,onEdgeDoubleClick:b,onEdgeUpdateStart:j,onEdgeUpdateEnd:S,rfId:o,ariaLabel:K.ariaLabel,isFocusable:se,isUpdatable:ve,pathOptions:"pathOptions"in K?K.pathOptions:void 0,interactionWidth:K.interactionWidth})})))),T):null};Iy.displayName="EdgeRenderer";var Vk=m.memo(Iy);const qk=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Gk({children:e}){const t=ir(qk);return Ee.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function Yk(e){const t=xh(),r=m.useRef(!1);m.useEffect(()=>{!r.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),r.current=!0)},[e,t.viewportInitialized])}const Xk={[Ft.Left]:Ft.Right,[Ft.Right]:Ft.Left,[Ft.Top]:Ft.Bottom,[Ft.Bottom]:Ft.Top},Fy=({nodeId:e,handleType:t,style:r,type:o=pl.Bezier,CustomComponent:l,connectionStatus:u})=>{var ne,Y,oe;const{fromNode:c,handleId:d,toX:h,toY:_,connectionMode:g}=ir(m.useCallback(le=>({fromNode:le.nodeInternals.get(e),handleId:le.connectionHandleId,toX:(le.connectionPosition.x-le.transform[0])/le.transform[2],toY:(le.connectionPosition.y-le.transform[1])/le.transform[2],connectionMode:le.connectionMode}),[e]),ws),x=(ne=c==null?void 0:c[Kr])==null?void 0:ne.handleBounds;let v=x==null?void 0:x[t];if(g===Zl.Loose&&(v=v||(x==null?void 0:x[t==="source"?"target":"source"])),!c||!v)return null;const b=d?v.find(le=>le.id===d):v[0],j=b?b.x+b.width/2:(c.width??0)/2,S=b?b.y+b.height/2:c.height??0,T=(((Y=c.positionAbsolute)==null?void 0:Y.x)??0)+j,M=(((oe=c.positionAbsolute)==null?void 0:oe.y)??0)+S,D=b==null?void 0:b.position,L=D?Xk[D]:null;if(!D||!L)return null;if(l)return Ee.createElement(l,{connectionLineType:o,connectionLineStyle:r,fromNode:c,fromHandle:b,fromX:T,fromY:M,toX:h,toY:_,fromPosition:D,toPosition:L,connectionStatus:u});let I="";const G={sourceX:T,sourceY:M,sourcePosition:D,targetX:h,targetY:_,targetPosition:L};return o===pl.Bezier?[I]=cy(G):o===pl.Step?[I]=Hm({...G,borderRadius:0}):o===pl.SmoothStep?[I]=Hm(G):o===pl.SimpleBezier?[I]=ly(G):I=`M${T},${M} ${h},${_}`,Ee.createElement("path",{d:I,fill:"none",className:"react-flow__connection-path",style:r})};Fy.displayName="ConnectionLine";const Kk=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function Jk({containerStyle:e,style:t,type:r,component:o}){const{nodeId:l,handleType:u,nodesConnectable:c,width:d,height:h,connectionStatus:_}=ir(Kk,ws);return!(l&&u&&d&&c)?null:Ee.createElement("svg",{style:e,width:d,height:h,className:"react-flow__edges react-flow__connectionline react-flow__container"},Ee.createElement("g",{className:Cs(["react-flow__connection",_])},Ee.createElement(Fy,{nodeId:l,handleType:u,style:t,type:r,CustomComponent:o,connectionStatus:_})))}function Mg(e,t){return m.useRef(null),as(),m.useMemo(()=>t(e),[e])}const Oy=({nodeTypes:e,edgeTypes:t,onMove:r,onMoveStart:o,onMoveEnd:l,onInit:u,onNodeClick:c,onEdgeClick:d,onNodeDoubleClick:h,onEdgeDoubleClick:_,onNodeMouseEnter:g,onNodeMouseMove:x,onNodeMouseLeave:v,onNodeContextMenu:b,onSelectionContextMenu:j,onSelectionStart:S,onSelectionEnd:T,connectionLineType:M,connectionLineStyle:D,connectionLineComponent:L,connectionLineContainerStyle:I,selectionKeyCode:G,selectionOnDrag:ne,selectionMode:Y,multiSelectionKeyCode:oe,panActivationKeyCode:le,zoomActivationKeyCode:_e,deleteKeyCode:Te,onlyRenderVisibleElements:$e,elementsSelectable:K,selectNodesOnDrag:U,defaultViewport:X,translateExtent:V,minZoom:J,maxZoom:k,preventScrolling:z,defaultMarkerColor:F,zoomOnScroll:N,zoomOnPinch:B,panOnScroll:Z,panOnScrollSpeed:te,panOnScrollMode:he,zoomOnDoubleClick:Ae,panOnDrag:se,onPaneClick:ve,onPaneMouseEnter:Re,onPaneMouseMove:Qe,onPaneMouseLeave:Pe,onPaneScroll:de,onPaneContextMenu:be,onEdgeUpdate:Fe,onEdgeContextMenu:Xe,onEdgeMouseEnter:tt,onEdgeMouseMove:ze,onEdgeMouseLeave:Oe,edgeUpdaterRadius:lt,onEdgeUpdateStart:xe,onEdgeUpdateEnd:Et,noDragClassName:yt,noWheelClassName:sn,noPanClassName:ln,elevateEdgesOnSelect:Xt,disableKeyboardA11y:je,nodeOrigin:ue,nodeExtent:Ne,rfId:$t})=>{const pt=Mg(e,kk),qt=Mg(t,Mk);return Yk(u),Ee.createElement(Sk,{onPaneClick:ve,onPaneMouseEnter:Re,onPaneMouseMove:Qe,onPaneMouseLeave:Pe,onPaneContextMenu:be,onPaneScroll:de,deleteKeyCode:Te,selectionKeyCode:G,selectionOnDrag:ne,selectionMode:Y,onSelectionStart:S,onSelectionEnd:T,multiSelectionKeyCode:oe,panActivationKeyCode:le,zoomActivationKeyCode:_e,elementsSelectable:K,onMove:r,onMoveStart:o,onMoveEnd:l,zoomOnScroll:N,zoomOnPinch:B,zoomOnDoubleClick:Ae,panOnScroll:Z,panOnScrollSpeed:te,panOnScrollMode:he,panOnDrag:se,defaultViewport:X,translateExtent:V,minZoom:J,maxZoom:k,onSelectionContextMenu:j,preventScrolling:z,noDragClassName:yt,noWheelClassName:sn,noPanClassName:ln,disableKeyboardA11y:je},Ee.createElement(Gk,null,Ee.createElement(Vk,{edgeTypes:qt,onEdgeClick:d,onEdgeDoubleClick:_,onEdgeUpdate:Fe,onlyRenderVisibleElements:$e,onEdgeContextMenu:Xe,onEdgeMouseEnter:tt,onEdgeMouseMove:ze,onEdgeMouseLeave:Oe,onEdgeUpdateStart:xe,onEdgeUpdateEnd:Et,edgeUpdaterRadius:lt,defaultMarkerColor:F,noPanClassName:ln,elevateEdgesOnSelect:!!Xt,disableKeyboardA11y:je,rfId:$t},Ee.createElement(Jk,{style:D,type:M,component:L,containerStyle:I})),Ee.createElement("div",{className:"react-flow__edgelabel-renderer"}),Ee.createElement(Ek,{nodeTypes:pt,onNodeClick:c,onNodeDoubleClick:h,onNodeMouseEnter:g,onNodeMouseMove:x,onNodeMouseLeave:v,onNodeContextMenu:b,selectNodesOnDrag:U,onlyRenderVisibleElements:$e,noPanClassName:ln,noDragClassName:yt,disableKeyboardA11y:je,nodeOrigin:ue,nodeExtent:Ne,rfId:$t})))};Oy.displayName="GraphView";var Qk=m.memo(Oy);const Xm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ll={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Xm,nodeExtent:Xm,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Zl.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:kj,isValidConnection:void 0},Zk=()=>Dw((e,t)=>({...ll,setNodes:r=>{const{nodeInternals:o,nodeOrigin:l,elevateNodesOnSelect:u}=t();e({nodeInternals:mm(r,o,l,u)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:r=>{const{defaultEdgeOptions:o={}}=t();e({edges:r.map(l=>({...o,...l}))})},setDefaultNodesAndEdges:(r,o)=>{const l=typeof r<"u",u=typeof o<"u",c=l?mm(r,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:c,edges:u?o:[],hasDefaultNodes:l,hasDefaultEdges:u})},updateNodeDimensions:r=>{const{onNodesChange:o,nodeInternals:l,fitViewOnInit:u,fitViewOnInitDone:c,fitViewOnInitOptions:d,domNode:h,nodeOrigin:_}=t(),g=h==null?void 0:h.querySelector(".react-flow__viewport");if(!g)return;const x=window.getComputedStyle(g),{m22:v}=new window.DOMMatrixReadOnly(x.transform),b=r.reduce((S,T)=>{const M=l.get(T.id);if(M){const D=dh(T.nodeElement);!!(D.width&&D.height&&(M.width!==D.width||M.height!==D.height||T.forceUpdate))&&(l.set(M.id,{...M,[Kr]:{...M[Kr],handleBounds:{source:kg(".source",T.nodeElement,v,_),target:kg(".target",T.nodeElement,v,_)}},...D}),S.push({id:M.id,type:"dimensions",dimensions:D}))}return S},[]);Cy(l,_);const j=c||u&&!c&&Ey(t,{initial:!0,...d});e({nodeInternals:new Map(l),fitViewOnInitDone:j}),(b==null?void 0:b.length)>0&&(o==null||o(b))},updateNodePositions:(r,o=!0,l=!1)=>{const{triggerNodeChanges:u}=t(),c=r.map(d=>{const h={id:d.id,type:"position",dragging:l};return o&&(h.positionAbsolute=d.positionAbsolute,h.position=d.position),h});u(c)},triggerNodeChanges:r=>{const{onNodesChange:o,nodeInternals:l,hasDefaultNodes:u,nodeOrigin:c,getNodes:d,elevateNodesOnSelect:h}=t();if(r!=null&&r.length){if(u){const _=hk(r,d()),g=mm(_,l,c,h);e({nodeInternals:g})}o==null||o(r)}},addSelectedNodes:r=>{const{multiSelectionActive:o,edges:l,getNodes:u}=t();let c,d=null;o?c=r.map(h=>hl(h,!0)):(c=Oc(u(),r),d=Oc(l,[])),Ld({changedNodes:c,changedEdges:d,get:t,set:e})},addSelectedEdges:r=>{const{multiSelectionActive:o,edges:l,getNodes:u}=t();let c,d=null;o?c=r.map(h=>hl(h,!0)):(c=Oc(l,r),d=Oc(u(),[])),Ld({changedNodes:d,changedEdges:c,get:t,set:e})},unselectNodesAndEdges:({nodes:r,edges:o}={})=>{const{edges:l,getNodes:u}=t(),c=r||u(),d=o||l,h=c.map(g=>(g.selected=!1,hl(g.id,!1))),_=d.map(g=>hl(g.id,!1));Ld({changedNodes:h,changedEdges:_,get:t,set:e})},setMinZoom:r=>{const{d3Zoom:o,maxZoom:l}=t();o==null||o.scaleExtent([r,l]),e({minZoom:r})},setMaxZoom:r=>{const{d3Zoom:o,minZoom:l}=t();o==null||o.scaleExtent([l,r]),e({maxZoom:r})},setTranslateExtent:r=>{var o;(o=t().d3Zoom)==null||o.translateExtent(r),e({translateExtent:r})},resetSelectedElements:()=>{const{edges:r,getNodes:o}=t(),u=o().filter(d=>d.selected).map(d=>hl(d.id,!1)),c=r.filter(d=>d.selected).map(d=>hl(d.id,!1));Ld({changedNodes:u,changedEdges:c,get:t,set:e})},setNodeExtent:r=>{const{nodeInternals:o}=t();o.forEach(l=>{l.positionAbsolute=fh(l.position,r)}),e({nodeExtent:r,nodeInternals:new Map(o)})},panBy:r=>{const{transform:o,width:l,height:u,d3Zoom:c,d3Selection:d,translateExtent:h}=t();if(!c||!d||!r.x&&!r.y)return!1;const _=Ra.translate(o[0]+r.x,o[1]+r.y).scale(o[2]),g=[[0,0],[l,u]],x=c==null?void 0:c.constrain()(_,g,h);return c.transform(d,x),o[0]!==x.x||o[1]!==x.y||o[2]!==x.k},cancelConnection:()=>e({connectionNodeId:ll.connectionNodeId,connectionHandleId:ll.connectionHandleId,connectionHandleType:ll.connectionHandleType,connectionStatus:ll.connectionStatus,connectionStartHandle:ll.connectionStartHandle,connectionEndHandle:ll.connectionEndHandle}),reset:()=>e({...ll})}),Object.is),wh=({children:e})=>{const t=m.useRef(null);return t.current||(t.current=Zk()),Ee.createElement(yj,{value:t.current},e)};wh.displayName="ReactFlowProvider";const Dy=({children:e})=>m.useContext(ff)?Ee.createElement(Ee.Fragment,null,e):Ee.createElement(wh,null,e);Dy.displayName="ReactFlowWrapper";const eN={input:vy,default:Gm,output:by,group:yh},tN={default:nf,straight:ph,step:hh,smoothstep:mf,simplebezier:mh},nN=[0,0],rN=[15,15],sN={x:0,y:0,zoom:1},iN={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},By=m.forwardRef(({nodes:e,edges:t,defaultNodes:r,defaultEdges:o,className:l,nodeTypes:u=eN,edgeTypes:c=tN,onNodeClick:d,onEdgeClick:h,onInit:_,onMove:g,onMoveStart:x,onMoveEnd:v,onConnect:b,onConnectStart:j,onConnectEnd:S,onClickConnectStart:T,onClickConnectEnd:M,onNodeMouseEnter:D,onNodeMouseMove:L,onNodeMouseLeave:I,onNodeContextMenu:G,onNodeDoubleClick:ne,onNodeDragStart:Y,onNodeDrag:oe,onNodeDragStop:le,onNodesDelete:_e,onEdgesDelete:Te,onSelectionChange:$e,onSelectionDragStart:K,onSelectionDrag:U,onSelectionDragStop:X,onSelectionContextMenu:V,onSelectionStart:J,onSelectionEnd:k,connectionMode:z=Zl.Strict,connectionLineType:F=pl.Bezier,connectionLineStyle:N,connectionLineComponent:B,connectionLineContainerStyle:Z,deleteKeyCode:te="Backspace",selectionKeyCode:he="Shift",selectionOnDrag:Ae=!1,selectionMode:se=Hu.Full,panActivationKeyCode:ve="Space",multiSelectionKeyCode:Re=tf()?"Meta":"Control",zoomActivationKeyCode:Qe=tf()?"Meta":"Control",snapToGrid:Pe=!1,snapGrid:de=rN,onlyRenderVisibleElements:be=!1,selectNodesOnDrag:Fe=!0,nodesDraggable:Xe,nodesConnectable:tt,nodesFocusable:ze,nodeOrigin:Oe=nN,edgesFocusable:lt,edgesUpdatable:xe,elementsSelectable:Et,defaultViewport:yt=sN,minZoom:sn=.5,maxZoom:ln=2,translateExtent:Xt=Xm,preventScrolling:je=!0,nodeExtent:ue,defaultMarkerColor:Ne="#b1b1b7",zoomOnScroll:$t=!0,zoomOnPinch:pt=!0,panOnScroll:qt=!1,panOnScrollSpeed:Dn=.5,panOnScrollMode:nn=Xl.Free,zoomOnDoubleClick:cn=!0,panOnDrag:vn=!0,onPaneClick:Sn,onPaneMouseEnter:cr,onPaneMouseMove:Qt,onPaneMouseLeave:Zn,onPaneScroll:ls,onPaneContextMenu:Un,children:me,onEdgeUpdate:ke,onEdgeContextMenu:ct,onEdgeDoubleClick:it,onEdgeMouseEnter:bt,onEdgeMouseMove:zt,onEdgeMouseLeave:Ut,onEdgeUpdateStart:Ot,onEdgeUpdateEnd:pn,edgeUpdaterRadius:It=10,onNodesChange:_n,onEdgesChange:un,noDragClassName:Gt="nodrag",noWheelClassName:Zt="nowheel",noPanClassName:Vt="nopan",fitView:rt=!1,fitViewOptions:jn,connectOnClick:Rn=!0,attributionPosition:kn,proOptions:Nn,defaultEdgeOptions:ar,elevateNodesOnSelect:Ir=!0,elevateEdgesOnSelect:Sr=!1,disableKeyboardA11y:Fr=!1,autoPanOnConnect:Ws=!0,autoPanOnNodeDrag:Es=!0,connectionRadius:lo=20,isValidConnection:Ri,onError:cs,style:En,id:us,nodeDragThreshold:Jr,...Or},mr)=>{const st=us||"1";return Ee.createElement("div",{...Or,style:{...En,...iN},ref:mr,className:Cs(["react-flow",l]),"data-testid":"rf__wrapper",id:us},Ee.createElement(Dy,null,Ee.createElement(Qk,{onInit:_,onMove:g,onMoveStart:x,onMoveEnd:v,onNodeClick:d,onEdgeClick:h,onNodeMouseEnter:D,onNodeMouseMove:L,onNodeMouseLeave:I,onNodeContextMenu:G,onNodeDoubleClick:ne,nodeTypes:u,edgeTypes:c,connectionLineType:F,connectionLineStyle:N,connectionLineComponent:B,connectionLineContainerStyle:Z,selectionKeyCode:he,selectionOnDrag:Ae,selectionMode:se,deleteKeyCode:te,multiSelectionKeyCode:Re,panActivationKeyCode:ve,zoomActivationKeyCode:Qe,onlyRenderVisibleElements:be,selectNodesOnDrag:Fe,defaultViewport:yt,translateExtent:Xt,minZoom:sn,maxZoom:ln,preventScrolling:je,zoomOnScroll:$t,zoomOnPinch:pt,zoomOnDoubleClick:cn,panOnScroll:qt,panOnScrollSpeed:Dn,panOnScrollMode:nn,panOnDrag:vn,onPaneClick:Sn,onPaneMouseEnter:cr,onPaneMouseMove:Qt,onPaneMouseLeave:Zn,onPaneScroll:ls,onPaneContextMenu:Un,onSelectionContextMenu:V,onSelectionStart:J,onSelectionEnd:k,onEdgeUpdate:ke,onEdgeContextMenu:ct,onEdgeDoubleClick:it,onEdgeMouseEnter:bt,onEdgeMouseMove:zt,onEdgeMouseLeave:Ut,onEdgeUpdateStart:Ot,onEdgeUpdateEnd:pn,edgeUpdaterRadius:It,defaultMarkerColor:Ne,noDragClassName:Gt,noWheelClassName:Zt,noPanClassName:Vt,elevateEdgesOnSelect:Sr,rfId:st,disableKeyboardA11y:Fr,nodeOrigin:Oe,nodeExtent:ue}),Ee.createElement(Yj,{nodes:e,edges:t,defaultNodes:r,defaultEdges:o,onConnect:b,onConnectStart:j,onConnectEnd:S,onClickConnectStart:T,onClickConnectEnd:M,nodesDraggable:Xe,nodesConnectable:tt,nodesFocusable:ze,edgesFocusable:lt,edgesUpdatable:xe,elementsSelectable:Et,elevateNodesOnSelect:Ir,minZoom:sn,maxZoom:ln,nodeExtent:ue,onNodesChange:_n,onEdgesChange:un,snapToGrid:Pe,snapGrid:de,connectionMode:z,translateExtent:Xt,connectOnClick:Rn,defaultEdgeOptions:ar,fitView:rt,fitViewOptions:jn,onNodesDelete:_e,onEdgesDelete:Te,onNodeDragStart:Y,onNodeDrag:oe,onNodeDragStop:le,onSelectionDrag:U,onSelectionDragStart:K,onSelectionDragStop:X,noPanClassName:Vt,nodeOrigin:Oe,rfId:st,autoPanOnConnect:Ws,autoPanOnNodeDrag:Es,onError:cs,connectionRadius:lo,isValidConnection:Ri,nodeDragThreshold:Jr}),Ee.createElement(qj,{onSelectionChange:$e}),me,Ee.createElement(vj,{proOptions:Nn,position:kn}),Ee.createElement(Zj,{rfId:st,disableKeyboardA11y:Fr})))});By.displayName="ReactFlow";const Uy=({id:e,x:t,y:r,width:o,height:l,style:u,color:c,strokeColor:d,strokeWidth:h,className:_,borderRadius:g,shapeRendering:x,onClick:v,selected:b})=>{const{background:j,backgroundColor:S}=u||{},T=c||j||S;return Ee.createElement("rect",{className:Cs(["react-flow__minimap-node",{selected:b},_]),x:t,y:r,rx:g,ry:g,width:o,height:l,fill:T,stroke:d,strokeWidth:h,shapeRendering:x,onClick:v?M=>v(M,e):void 0})};Uy.displayName="MiniMapNode";var oN=m.memo(Uy);const aN=e=>e.nodeOrigin,lN=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),_m=e=>e instanceof Function?e:()=>e;function cN({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:l=2,nodeComponent:u=oN,onClick:c}){const d=ir(lN,ws),h=ir(aN),_=_m(t),g=_m(e),x=_m(r),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return Ee.createElement(Ee.Fragment,null,d.map(b=>{const{x:j,y:S}=Jl(b,h).positionAbsolute;return Ee.createElement(u,{key:b.id,x:j,y:S,width:b.width,height:b.height,style:b.style,selected:b.selected,className:x(b),color:_(b),borderRadius:o,strokeColor:g(b),strokeWidth:l,shapeRendering:v,onClick:c,id:b.id})}))}var uN=m.memo(cN);const dN=200,fN=150,mN=e=>{const t=e.getNodes(),r={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:r,boundingRect:t.length>0?Sj(hf(t,e.nodeOrigin),r):r,rfId:e.rfId}},hN="react-flow__minimap-desc";function Wy({style:e,className:t,nodeStrokeColor:r="transparent",nodeColor:o="#e2e2e2",nodeClassName:l="",nodeBorderRadius:u=5,nodeStrokeWidth:c=2,nodeComponent:d,maskColor:h="rgb(240, 240, 240, 0.6)",maskStrokeColor:_="none",maskStrokeWidth:g=1,position:x="bottom-right",onClick:v,onNodeClick:b,pannable:j=!1,zoomable:S=!1,ariaLabel:T="React Flow mini map",inversePan:M=!1,zoomStep:D=10,offsetScale:L=5}){const I=as(),G=m.useRef(null),{boundingRect:ne,viewBB:Y,rfId:oe}=ir(mN,ws),le=(e==null?void 0:e.width)??dN,_e=(e==null?void 0:e.height)??fN,Te=ne.width/le,$e=ne.height/_e,K=Math.max(Te,$e),U=K*le,X=K*_e,V=L*K,J=ne.x-(U-ne.width)/2-V,k=ne.y-(X-ne.height)/2-V,z=U+V*2,F=X+V*2,N=`${hN}-${oe}`,B=m.useRef(0);B.current=K,m.useEffect(()=>{if(G.current){const he=io(G.current),Ae=Re=>{const{transform:Qe,d3Selection:Pe,d3Zoom:de}=I.getState();if(Re.sourceEvent.type!=="wheel"||!Pe||!de)return;const be=-Re.sourceEvent.deltaY*(Re.sourceEvent.deltaMode===1?.05:Re.sourceEvent.deltaMode?1:.002)*D,Fe=Qe[2]*Math.pow(2,be);de.scaleTo(Pe,Fe)},se=Re=>{const{transform:Qe,d3Selection:Pe,d3Zoom:de,translateExtent:be,width:Fe,height:Xe}=I.getState();if(Re.sourceEvent.type!=="mousemove"||!Pe||!de)return;const tt=B.current*Math.max(1,Qe[2])*(M?-1:1),ze={x:Qe[0]-Re.sourceEvent.movementX*tt,y:Qe[1]-Re.sourceEvent.movementY*tt},Oe=[[0,0],[Fe,Xe]],lt=Ra.translate(ze.x,ze.y).scale(Qe[2]),xe=de.constrain()(lt,Oe,be);de.transform(Pe,xe)},ve=Q_().on("zoom",j?se:null).on("zoom.wheel",S?Ae:null);return he.call(ve),()=>{he.on("zoom",null)}}},[j,S,M,D]);const Z=v?he=>{const Ae=Mo(he);v(he,{x:Ae[0],y:Ae[1]})}:void 0,te=b?(he,Ae)=>{const se=I.getState().nodeInternals.get(Ae);b(he,se)}:void 0;return Ee.createElement(Uu,{position:x,style:e,className:Cs(["react-flow__minimap",t]),"data-testid":"rf__minimap"},Ee.createElement("svg",{width:le,height:_e,viewBox:`${J} ${k} ${z} ${F}`,role:"img","aria-labelledby":N,ref:G,onClick:Z},T&&Ee.createElement("title",{id:N},T),Ee.createElement(uN,{onClick:te,nodeColor:o,nodeStrokeColor:r,nodeBorderRadius:u,nodeClassName:l,nodeStrokeWidth:c,nodeComponent:d}),Ee.createElement("path",{className:"react-flow__minimap-mask",d:`M${J-V},${k-V}h${z+V*2}v${F+V*2}h${-z-V*2}z
|
|
117
|
+
M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fill:h,fillRule:"evenodd",stroke:_,strokeWidth:g,pointerEvents:"none"})))}Wy.displayName="MiniMap";var pN=m.memo(Wy);function gN(){return Ee.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},Ee.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function _N(){return Ee.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},Ee.createElement("path",{d:"M0 0h32v4.2H0z"}))}function yN(){return Ee.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},Ee.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function xN(){return Ee.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},Ee.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function vN(){return Ee.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},Ee.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const Dc=({children:e,className:t,...r})=>Ee.createElement("button",{type:"button",className:Cs(["react-flow__controls-button",t]),...r},e);Dc.displayName="ControlButton";const wN=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Hy=({style:e,showZoom:t=!0,showFitView:r=!0,showInteractive:o=!0,fitViewOptions:l,onZoomIn:u,onZoomOut:c,onFitView:d,onInteractiveChange:h,className:_,children:g,position:x="bottom-left"})=>{const v=as(),[b,j]=m.useState(!1),{isInteractive:S,minZoomReached:T,maxZoomReached:M}=ir(wN,ws),{zoomIn:D,zoomOut:L,fitView:I}=xh();if(m.useEffect(()=>{j(!0)},[]),!b)return null;const G=()=>{D(),u==null||u()},ne=()=>{L(),c==null||c()},Y=()=>{I(l),d==null||d()},oe=()=>{v.setState({nodesDraggable:!S,nodesConnectable:!S,elementsSelectable:!S}),h==null||h(!S)};return Ee.createElement(Uu,{className:Cs(["react-flow__controls",_]),position:x,style:e,"data-testid":"rf__controls"},t&&Ee.createElement(Ee.Fragment,null,Ee.createElement(Dc,{onClick:G,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:M},Ee.createElement(gN,null)),Ee.createElement(Dc,{onClick:ne,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:T},Ee.createElement(_N,null))),r&&Ee.createElement(Dc,{className:"react-flow__controls-fitview",onClick:Y,title:"fit view","aria-label":"fit view"},Ee.createElement(yN,null)),o&&Ee.createElement(Dc,{className:"react-flow__controls-interactive",onClick:oe,title:"toggle interactivity","aria-label":"toggle interactivity"},S?Ee.createElement(vN,null):Ee.createElement(xN,null)),g)};Hy.displayName="Controls";var bN=m.memo(Hy),Ro;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ro||(Ro={}));function SN({color:e,dimensions:t,lineWidth:r}){return Ee.createElement("path",{stroke:e,strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function jN({color:e,radius:t}){return Ee.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const kN={[Ro.Dots]:"#91919a",[Ro.Lines]:"#eee",[Ro.Cross]:"#e2e2e2"},NN={[Ro.Dots]:1,[Ro.Lines]:1,[Ro.Cross]:6},CN=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Vy({id:e,variant:t=Ro.Dots,gap:r=20,size:o,lineWidth:l=1,offset:u=2,color:c,style:d,className:h}){const _=m.useRef(null),{transform:g,patternId:x}=ir(CN,ws),v=c||kN[t],b=o||NN[t],j=t===Ro.Dots,S=t===Ro.Cross,T=Array.isArray(r)?r:[r,r],M=[T[0]*g[2]||1,T[1]*g[2]||1],D=b*g[2],L=S?[D,D]:M,I=j?[D/u,D/u]:[L[0]/u,L[1]/u];return Ee.createElement("svg",{className:Cs(["react-flow__background",h]),style:{...d,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:_,"data-testid":"rf__background"},Ee.createElement("pattern",{id:x+e,x:g[0]%M[0],y:g[1]%M[1],width:M[0],height:M[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${I[0]},-${I[1]})`},j?Ee.createElement(jN,{color:v,radius:D/u}):Ee.createElement(SN,{dimensions:L,color:v,lineWidth:l})),Ee.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${x+e})`}))}Vy.displayName="Background";var EN=m.memo(Vy);function qy(e,t={}){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:null;if(!r)return null;const o=typeof r.x=="number"&&Number.isFinite(r.x)?r.x:null,l=typeof r.y=="number"&&Number.isFinite(r.y)?r.y:null,u=typeof r.zoom=="number"&&Number.isFinite(r.zoom)?r.zoom:null;if(o===null||l===null||u===null)return null;const c=typeof t.maxAbsTranslate=="number"&&Number.isFinite(t.maxAbsTranslate)?Math.abs(t.maxAbsTranslate):1e6;if(Math.abs(o)>c||Math.abs(l)>c)return null;const d=typeof t.minZoom=="number"&&Number.isFinite(t.minZoom)?t.minZoom:.025,h=typeof t.maxZoom=="number"&&Number.isFinite(t.maxZoom)?t.maxZoom:6,_=Math.min(d,h),g=Math.max(d,h);return{x:o,y:l,zoom:Math.min(g,Math.max(_,u))}}function sf(e){const t=String(e||"").trim();if(!t)return"";const r=t.indexOf(":");return r!==-1&&r<t.length-1?t.slice(r+1):t}function $N(e){const t=String(e||"").trim();if(!t)return"entity";const r=t.indexOf(":");if(r<=0||r>=t.length-1)return"entity";const o=t.slice(0,r).toLowerCase(),l=t.slice(r+1).toLowerCase();if(o==="ex"){const u=l.indexOf("-"),c=u>0?l.slice(0,u):l;return c==="person"?"person":c==="org"?"org":c==="concept"?"concept":c==="claim"?"claim":c==="event"?"event":c==="doc"?"doc":c==="thing"?"thing":"entity"}return o==="schema"||o==="skos"||o==="dcterms"||o==="rdf"||o==="cito"?"vocab":"entity"}function AN(e){const t=String(e||"").trim();if(!t)return"";const r=t.indexOf(":");if(r<=0||r>=t.length-1)return sf(t);const o=t.slice(0,r).toLowerCase(),l=t.slice(r+1);if(o==="ex"){const u=l.indexOf("-");if(u>0&&u<l.length-1)return l.slice(u+1)}return sf(t)}function Km(e){const o=Math.max(1,Math.ceil(Math.sqrt(e.length))),l={};for(let u=0;u<e.length;u++){const c=Math.floor(u/o),d=u%o;l[e[u]]={x:d*240,y:c*120}}return l}function Jm(e){const t=String(e??"");let r=2166136261;for(let o=0;o<t.length;o++)r^=t.charCodeAt(o),r=Math.imul(r,16777619);return r>>>0}function Gy(e){let t=e>>>0;return()=>{t+=1831565813;let r=Math.imul(t^t>>>15,1|t);return r^=r+Math.imul(r^r>>>7,61|r),((r^r>>>14)>>>0)/4294967296}}function TN(e,t){const r={},o=e.length;if(!o)return r;const l=Math.max(260,Math.sqrt(o)*150),u=t%360*Math.PI/180;for(let c=0;c<o;c++){const d=u+2*Math.PI*c/o;r[e[c]]={x:l*Math.cos(d),y:l*Math.sin(d)}}return r}function zg(e,t,r){var j;const o={};if(!e.length)return o;const l=new Map;for(const S of e)l.set(S,new Set);for(const S of t){const T=String((S==null?void 0:S.source)||"").trim(),M=String((S==null?void 0:S.target)||"").trim();if(!T||!M||T===M)continue;const D=l.get(T),L=l.get(M);D&&D.add(M),L&&L.add(T)}let u=e[0],c=-1;for(const S of e){const T=((j=l.get(S))==null?void 0:j.size)??0;(T>c||T===c&&S.localeCompare(u)<0)&&(u=S,c=T)}const d=new Map,h=[];for(d.set(u,0),h.push(u);h.length;){const S=h.shift(),T=d.get(S)??0,M=Array.from(l.get(S)??[]);M.sort((D,L)=>D.localeCompare(L));for(const D of M)d.has(D)||(d.set(D,T+1),h.push(D))}let _=0;for(const S of d.values())_=Math.max(_,S);for(const S of e)d.has(S)||d.set(S,_+1);const g=new Map;for(const S of e){const T=d.get(S)??0,M=g.get(T);M?M.push(S):g.set(T,[S])}const x=Array.from(g.keys()).sort((S,T)=>S-T),v=260,b=r%360*Math.PI/180;for(const S of x){const T=g.get(S)||[];if(T.sort((I,G)=>I.localeCompare(G)),S===0){if(T.length===1)o[T[0]]={x:0,y:0};else for(let G=0;G<T.length;G++){const ne=b+2*Math.PI*G/T.length;o[T[G]]={x:80*Math.cos(ne),y:80*Math.sin(ne)}}continue}const M=v*S,D=T.length;if(D===1){o[T[0]]={x:M,y:0};continue}const L=b+S*.35;for(let I=0;I<D;I++){const G=L+2*Math.PI*I/D;o[T[I]]={x:M*Math.cos(G),y:M*Math.sin(G)}}}return o}function Fc(e,t={}){const r=t.kind??"grid",o=typeof t.seed=="number"&&Number.isFinite(t.seed)?Math.trunc(t.seed):0,l=e.nodes.map(u=>u.id);if(r==="grid")return Km(l);if(r==="circle")return TN(l,o);if(r==="radial")return zg(l,e.edges,o);if(r==="force"){const u=zg(l,e.edges,o),c=Gy(o||1),d=Math.max(10,Math.min(42,Math.sqrt(l.length)*2.75)),h={};for(const _ of l){const g=u[_]||{x:0,y:0};h[_]={x:g.x+(c()-.5)*d,y:g.y+(c()-.5)*d}}return h}return Km(l)}function MN(e){return Array.isArray(e)?e.filter(t=>t&&typeof t=="object"&&typeof t.subject=="string"&&typeof t.predicate=="string"&&typeof t.object=="string"):[]}function zN(e,t={}){const r=!!(t.groupEdges??!0),o=Math.max(1,t.maxEdgeLabelPredicates??3),l=MN(e),u=new Set;for(const v of l){const b=String(v.subject||"").trim(),j=String(v.object||"").trim();b&&u.add(b),j&&u.add(j)}const c=Array.from(u);c.sort((v,b)=>v.localeCompare(b));const d=Km(c),h=c.map(v=>({id:v,type:"default",data:{label:AN(v),kind:$N(v)},position:d[v]||{x:0,y:0}})),_=new Map,g=(v,b)=>{const j=String(v.subject||"").trim(),S=String(v.object||"").trim(),T=String(v.predicate||"").trim();return r?`edge:${j}:${S}`:`edge:${b}:${j}:${T}:${S}`};for(let v=0;v<l.length;v++){const b=l[v],j=g(b,v),S=_.get(j);S?S.push(b):_.set(j,[b])}const x=[];for(const[v,b]of _.entries()){const j=b[0],S=String(j.subject||"").trim(),T=String(j.object||"").trim();if(!S||!T)continue;const M=new Map;for(const Y of b){const oe=String(Y.predicate||"").trim();oe&&M.set(oe,(M.get(oe)||0)+1)}const D=Array.from(M.entries());D.sort((Y,oe)=>oe[1]-Y[1]||Y[0].localeCompare(oe[0]));const I=D.slice(0,o).map(([Y,oe])=>oe>1?`${sf(Y)}×${oe}`:sf(Y)).join(" | "),G=D.length>o?` +${D.length-o}`:"",ne=`${I}${G}`.trim();x.push({id:v,source:S,target:T,label:ne,animated:!1,data:{assertions:b,predicateSummary:ne}})}return{nodes:h,edges:x}}function RN(e,t,r,o={}){const l=o.directed!==!1,u=String(t||"").trim(),c=String(r||"").trim();if(!u||!c)return null;if(u===c)return{nodeIds:[u],edgeIds:[]};const d=new Map,h=(S,T,M)=>{const D=d.get(S);D?D.push({to:T,edgeId:M}):d.set(S,[{to:T,edgeId:M}])};for(const S of e.edges)h(S.source,S.target,S.id),l||h(S.target,S.source,S.id);const _=[u],g=new Map,x=new Map;for(g.set(u,null),x.set(u,null);_.length;){const S=_.shift(),T=d.get(S)||[];for(const M of T)if(!g.has(M.to)){if(g.set(M.to,S),x.set(M.to,M.edgeId),M.to===c){_.length=0;break}_.push(M.to)}}if(!g.has(c))return null;const v=[],b=[];let j=c;for(;j;){v.push(j);const S=x.get(j);S&&b.push(S),j=g.get(j)||null}return v.reverse(),b.reverse(),{nodeIds:v,edgeIds:b}}const Rg={seed:1,dt:1,springLength:240,springStrength:.03,repulsionStrength:9e3,centeringStrength:.003,damping:.85,maxSpeed:90,maxRepulsionNodes:320};function Id(e,t={}){const r={...Rg,...t,seed:typeof t.seed=="number"&&Number.isFinite(t.seed)?Math.trunc(t.seed):Rg.seed},o=e.nodes.map(b=>b.id),l=o.length,u=new Float64Array(2*l),c=new Float64Array(2*l),d=new Float64Array(2*l),h=new Map;for(let b=0;b<l;b++)h.set(o[b],b);const _=t.positions??Fc(e,{kind:"force",seed:r.seed}),g=Gy(r.seed||1),x=Math.max(8,Math.min(38,Math.sqrt(l)*2.25));for(let b=0;b<l;b++){const j=o[b],S=_[j],T=typeof(S==null?void 0:S.x)=="number"&&Number.isFinite(S.x)?S.x:(g()-.5)*500,M=typeof(S==null?void 0:S.y)=="number"&&Number.isFinite(S.y)?S.y:(g()-.5)*500;u[2*b]=T+(g()-.5)*x,u[2*b+1]=M+(g()-.5)*x,c[2*b]=0,c[2*b+1]=0}const v=[];for(const b of e.edges){const j=h.get(String((b==null?void 0:b.source)||"").trim()),S=h.get(String((b==null?void 0:b.target)||"").trim());typeof j!="number"||typeof S!="number"||j===S||v.push(j,S)}return{nodeIds:o,pos:u,vel:c,acc:d,edges:new Uint32Array(v),options:r,tick:0}}function LN(e,t=1){const r=e.nodeIds.length;if(!r)return;const o=e.options,l=o.dt;for(let u=0;u<Math.max(1,Math.trunc(t));u++){if(e.acc.fill(0),r<=o.maxRepulsionNodes){const b=o.repulsionStrength;for(let j=0;j<r;j++){const S=e.pos[2*j],T=e.pos[2*j+1];for(let M=j+1;M<r;M++){const D=e.pos[2*M]-S,L=e.pos[2*M+1]-T,I=D*D+L*L+1e-6,G=1/Math.sqrt(I),ne=b/I,Y=ne*D*G,oe=ne*L*G;e.acc[2*j]-=Y,e.acc[2*j+1]-=oe,e.acc[2*M]+=Y,e.acc[2*M+1]+=oe}}}const d=o.springLength,h=o.springStrength,_=e.edges;for(let b=0;b<_.length;b+=2){const j=_[b],S=_[b+1],T=e.pos[2*j],M=e.pos[2*j+1],D=e.pos[2*S],L=e.pos[2*S+1],I=D-T,G=L-M,ne=I*I+G*G+1e-6,Y=Math.sqrt(ne),oe=h*(Y-d),le=oe*I/Y,_e=oe*G/Y;e.acc[2*j]+=le,e.acc[2*j+1]+=_e,e.acc[2*S]-=le,e.acc[2*S+1]-=_e}const g=o.centeringStrength;for(let b=0;b<r;b++)e.acc[2*b]+=-g*e.pos[2*b],e.acc[2*b+1]+=-g*e.pos[2*b+1];const x=o.damping,v=o.maxSpeed;for(let b=0;b<r;b++){let j=(e.vel[2*b]+e.acc[2*b]*l)*x,S=(e.vel[2*b+1]+e.acc[2*b+1]*l)*x;const T=Math.sqrt(j*j+S*S);if(T>v){const M=v/T;j*=M,S*=M}e.vel[2*b]=j,e.vel[2*b+1]=S,e.pos[2*b]+=j*l,e.pos[2*b+1]+=S*l}e.tick+=1}}function PN(e){const t=e.nodeIds.length;if(!t)return 0;let r=0;for(let o=0;o<t;o++){const l=e.vel[2*o],u=e.vel[2*o+1];r+=Math.sqrt(l*l+u*u)}return r/t}function IN(e){const t={},r=e.nodeIds.length;for(let o=0;o<r;o++)t[e.nodeIds[o]]={x:e.pos[2*o],y:e.pos[2*o+1]};return t}function Lg(e,t="session"){const r=String(e??"").trim().toLowerCase();return r==="run"||r==="session"||r==="global"||r==="all"?r:t}function FN(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(pointer: coarse)").matches||window.matchMedia("(max-width: 720px)").matches}catch{return!1}}function ON(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[s.jsx("rect",{x:"3",y:"3",width:"3",height:"3",rx:"1"}),s.jsx("rect",{x:"3",y:"7",width:"3",height:"3",rx:"1"}),s.jsx("rect",{x:"3",y:"11",width:"3",height:"3",rx:"1"}),s.jsx("rect",{x:"8",y:"3.5",width:"6",height:"2",rx:"1",fill:"none",strokeWidth:"1.4"}),s.jsx("rect",{x:"8",y:"7.5",width:"6",height:"2",rx:"1",fill:"none",strokeWidth:"1.4"}),s.jsx("rect",{x:"8",y:"11.5",width:"6",height:"2",rx:"1",fill:"none",strokeWidth:"1.4"})]})}function Yy(e,t,r,o){const l=typeof e=="number"&&Number.isFinite(e)?e:o;return Math.min(r,Math.max(t,l))}function $u(e){const t=Yy(e,.6,2.4,1),r=240*t,o=9e3*t*t;return{springLength:r,repulsionStrength:o}}const Gu="abstractuic_amx_saved_layouts_v1",Qm=.025,Zm=6,Xy=1e6;function bh(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function eh(e,t="grid"){const r=String(e??"").trim().toLowerCase();return r==="grid"||r==="circle"||r==="radial"||r==="force"?r:t}function DN(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:null;if(!t)return null;const r=typeof t.x=="number"&&Number.isFinite(t.x)?t.x:null,o=typeof t.y=="number"&&Number.isFinite(t.y)?t.y:null;return r===null||o===null?null:{x:r,y:o}}function Pg(e){const t=bh();if(!t)return null;const r=String(e??"").trim();if(!r)return null;try{const o=t.getItem(Gu);if(!o)return null;const l=JSON.parse(o),u=l&&typeof l=="object"&&!Array.isArray(l)?l:null;if(!u)return null;const c=u[r],d=c&&typeof c=="object"&&!Array.isArray(c)?c:null;if(!d)return null;const h=d.version===1?1:null;if(h===null)return null;const _=eh(d.kind,"grid"),g=typeof d.seed=="number"&&Number.isFinite(d.seed)?Math.trunc(d.seed):Jm(r),x=d.positions&&typeof d.positions=="object"&&!Array.isArray(d.positions)?d.positions:null,v={};if(x)for(const[S,T]of Object.entries(x)){const M=DN(T);M&&(v[String(S)]=M)}const b=qy(d.viewport,{minZoom:Qm,maxZoom:Zm,maxAbsTranslate:Xy})??void 0,j=typeof d.saved_at=="string"&&d.saved_at.trim()?d.saved_at.trim():"";return{version:h,kind:_,seed:g,positions:v,viewport:b,saved_at:j}}catch{return null}}function BN(e,t){const r=bh();if(!r)return;const o=String(e??"").trim();if(o)try{const l=r.getItem(Gu),u=l?JSON.parse(l):null,c=u&&typeof u=="object"&&!Array.isArray(u)?{...u}:{};c[o]=t,r.setItem(Gu,JSON.stringify(c))}catch{}}function UN(e){const t=bh();if(!t)return;const r=String(e??"").trim();if(r)try{const o=t.getItem(Gu);if(!o)return;const l=JSON.parse(o),u=l&&typeof l=="object"&&!Array.isArray(l)?{...l}:null;if(!u||!(r in u))return;delete u[r],t.setItem(Gu,JSON.stringify(u))}catch{}}function WN(e){const t=String(e??"").trim();if(!t)return;const r=Number(t);if(Number.isFinite(r))return r}function ym(e,t){const r=!!(t!=null&&t.allowZero),o=!!(t!=null&&t.allowNegativeOne),l=String(e??"").trim();if(!l)return;const u=Number(l);if(!Number.isFinite(u))return;const c=Math.trunc(u);if(o&&c===-1)return-1;if(!(!r&&c<=0)&&!(r&&c<0))return c}function HN(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e,r=typeof t.recall_level=="string"?t.recall_level:"",o=t.applied&&typeof t.applied=="object"&&!Array.isArray(t.applied)?t.applied:null,l=[];return r&&l.push(`recall_level=${r}`),o&&(typeof o.limit=="number"&&l.push(`limit=${o.limit}`),typeof o.min_score=="number"&&l.push(`min_score=${o.min_score}`),typeof o.max_input_tokens=="number"&&l.push(`max_input_tokens=${o.max_input_tokens}`)),l.length?l.join(" · "):null}function VN(e){if(!e||typeof e!="object")return null;const t=[],r=typeof e.scope=="string"?e.scope.trim():"",o=typeof e.owner_id=="string"?e.owner_id.trim():"";r&&t.push(`scope=${r}`),o&&t.push(`owner_id=${o}`);const l=typeof e.confidence=="number"&&Number.isFinite(e.confidence)?e.confidence:null;l!==null&&t.push(`confidence=${l.toFixed(3)}`);const u=e.provenance&&typeof e.provenance=="object"&&!Array.isArray(e.provenance)?e.provenance:null;if(u){const _=typeof u.writer_run_id=="string"?u.writer_run_id.trim():"",g=typeof u.writer_workflow_id=="string"?u.writer_workflow_id.trim():"";_&&t.push(`writer_run_id=${_}`),g&&t.push(`writer_workflow_id=${g}`)}const c=e.attributes&&typeof e.attributes=="object"&&!Array.isArray(e.attributes)?e.attributes:null,d=c&&c._retrieval&&typeof c._retrieval=="object"&&!Array.isArray(c._retrieval)?c._retrieval:null,h=d&&typeof d.score=="number"&&Number.isFinite(d.score)?d.score:null;return h!==null&&t.push(`score=${h.toFixed(3)}`),t.length?t.join(" · "):null}function qN(e,t){const r=String(e??""),o=String(t??"").trim();if(!o)return r;const l=r.toLowerCase().indexOf(o.toLowerCase());if(l<0)return r;const u=r.slice(0,l),c=r.slice(l,l+o.length),d=r.slice(l+o.length);return s.jsxs(s.Fragment,{children:[u,s.jsx("span",{className:"amx-hl",children:c}),d]})}function Au(e){const t=String(e??"").trim().toLowerCase();return t==="person"?{stroke:"rgba(96, 165, 250, 0.82)",bg:"rgba(96, 165, 250, 0.10)",minimap:"rgba(96, 165, 250, 0.85)"}:t==="org"?{stroke:"rgba(34, 197, 94, 0.78)",bg:"rgba(34, 197, 94, 0.10)",minimap:"rgba(34, 197, 94, 0.82)"}:t==="concept"?{stroke:"rgba(168, 85, 247, 0.78)",bg:"rgba(168, 85, 247, 0.10)",minimap:"rgba(168, 85, 247, 0.82)"}:t==="claim"?{stroke:"rgba(251, 191, 36, 0.78)",bg:"rgba(251, 191, 36, 0.10)",minimap:"rgba(251, 191, 36, 0.82)"}:t==="event"?{stroke:"rgba(239, 68, 68, 0.74)",bg:"rgba(239, 68, 68, 0.10)",minimap:"rgba(239, 68, 68, 0.80)"}:t==="doc"?{stroke:"rgba(14, 165, 233, 0.74)",bg:"rgba(14, 165, 233, 0.10)",minimap:"rgba(14, 165, 233, 0.80)"}:t==="vocab"?{stroke:"rgba(148, 163, 184, 0.55)",bg:"rgba(148, 163, 184, 0.06)",minimap:"rgba(148, 163, 184, 0.70)"}:t==="thing"?{stroke:"rgba(255, 255, 255, 0.20)",bg:"rgba(255, 255, 255, 0.04)",minimap:"rgba(255, 255, 255, 0.30)"}:{stroke:"rgba(255, 255, 255, 0.14)",bg:"rgba(0, 0, 0, 0.18)",minimap:"rgba(255, 255, 255, 0.24)"}}function GN(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const r=t.replace(/(\.\d{3})\d+/,"$1"),o=Date.parse(r);return Number.isFinite(o)?o:null}function Tu(e){const t=GN(e);if(t===null)return"";const r=new Date(t),o=r.getUTCFullYear(),l=String(r.getUTCMonth()+1).padStart(2,"0"),u=String(r.getUTCDate()).padStart(2,"0"),c=String(r.getUTCHours()).padStart(2,"0"),d=String(r.getUTCMinutes()).padStart(2,"0");return`${o}/${l}/${u} ${c}:${d}`}function Ky(e){const t=String(e??"").trim();if(!t)return"";const r=t.indexOf(":");return r!==-1&&r<t.length-1?t.slice(r+1):t}function xm(e,t){const r=String(e??"").trim().toLowerCase();return!!(r&&t.has(r))}function YN(e,t={}){const r=Math.max(1,t.maxPredicates??3),o=new Map;for(const h of e){const _=String((h==null?void 0:h.predicate)||"").trim();_&&o.set(_,(o.get(_)||0)+1)}const l=Array.from(o.entries());l.sort((h,_)=>_[1]-h[1]||h[0].localeCompare(_[0]));const c=l.slice(0,r).map(([h,_])=>{const g=Ky(h);return _>1?`${g}×${_}`:g}).join(" | "),d=l.length>r?` +${l.length-r}`:"";return`${c}${d}`.trim()}function XN({resetKey:e,queryMode:t,items:r,activeMemoryText:o,packets:l,packetsVersion:u,packedCount:c,dropped:d,estimatedTokens:h,effort:_,warnings:g,onQuery:x,onItemsReplace:v,onOpenSpan:b,onOpenTranscript:j}){var Ar;const S=m.useRef(null),T=m.useMemo(()=>{const R=r==null?void 0:r[0],ie=r==null?void 0:r[r.length-1],Ce=R?`${R.subject}|${R.predicate}|${R.object}`:"",Ie=ie?`${ie.subject}|${ie.predicate}|${ie.object}`:"";return`${(r==null?void 0:r.length)||0}:${Ce}:${Ie}`},[r]),M=String(e??T),D=t==="replace"?"replace":"override",[L,I]=m.useState(null),[G,ne]=m.useState(null),[Y,oe]=m.useState(!1),[le,_e]=m.useState(""),[Te,$e]=m.useState(!1),[K,U]=m.useState("");m.useEffect(()=>{I(null),ne(null),_e(""),oe(!1),U(""),$e(!1)},[M]);const[X,V]=m.useState(""),[J,k]=m.useState(!0),[z,F]=m.useState(!1),[N,B]=m.useState(!0),[Z]=m.useState(()=>({compact:FN(),show:!1})),te=Z.compact,[he,Ae]=m.useState(Z.show),[se,ve]=m.useState(!1),Re=M,Qe=m.useMemo(()=>Jm(Re),[Re]),[Pe,de]=m.useState("grid"),[be,Fe]=m.useState(Qe),[Xe,tt]=m.useState(!1),[ze,Oe]=m.useState(1),lt=m.useRef(null),xe=m.useRef(null),Et=m.useRef(!1),[yt,sn]=m.useState(0),ln=m.useRef(null),Xt=m.useRef(0),je=m.useRef(0),ue=m.useRef(0),Ne=m.useRef(0),[$t,pt]=m.useState(!1),[qt,Dn]=m.useState(""),[nn,cn]=m.useState({}),vn=m.useRef({});m.useEffect(()=>{vn.current=nn},[nn]);const[Sn,cr]=m.useState(""),[Qt,Zn]=m.useState(""),ls=m.useMemo(()=>{var ie;const R=(ie=r==null?void 0:r[0])==null?void 0:ie.scope;return Lg(R,"session")},[r]),[Un,me]=m.useState(ls),[ke,ct]=m.useState("standard"),[it,bt]=m.useState(""),[zt,Ut]=m.useState(""),[Ot,pn]=m.useState(""),[It,_n]=m.useState(""),[un,Gt]=m.useState(""),[Zt,Vt]=m.useState(""),[rt,jn]=m.useState(""),[Rn,kn]=m.useState("qwen/qwen3-next-80b");m.useEffect(()=>{me(ls)},[M]);const Nn=Array.isArray(r)?r:[],ar=typeof o=="string"?o:"",Ir=Array.isArray(l)?l:[],Sr=typeof u=="number"?u:void 0,Fr=typeof c=="number"?c:void 0,Ws=typeof d=="number"?d:void 0,Es=typeof h=="number"?h:void 0,lo=_,Ri=g,cs=D==="override"&&(L!=null&&L.items)&&Array.isArray(L.items)?L.items:Nn,En=typeof(L==null?void 0:L.active_memory_text)=="string"&&L.active_memory_text.trim()?L.active_memory_text:ar,us=(L==null?void 0:L.effort)??lo,Jr=(L==null?void 0:L.warnings)??Ri,Or=m.useMemo(()=>new Set(["rdf:type","schema:name","skos:preflabel","skos:altlabel","dcterms:title","dcterms:identifier"]),[]),mr=m.useMemo(()=>N?cs:(cs||[]).filter(R=>!xm(R==null?void 0:R.predicate,Or)),[cs,N,Or]),st=m.useMemo(()=>zN(cs,{groupEdges:J}),[cs,J]),St=m.useMemo(()=>{if(N)return st;const R=[];for(const ie of st.edges){const Ie=(ie&&ie.data&&Array.isArray(ie.data.assertions)?ie.data.assertions:[]).filter(at=>!xm(at==null?void 0:at.predicate,Or));if(!Ie.length)continue;const De=YN(Ie);R.push({...ie,label:De,data:{...ie.data,assertions:Ie,predicateSummary:De}})}return{nodes:st.nodes,edges:R}},[st,N,Or]),dn=m.useMemo(()=>St.nodes.map(R=>R.id),[St.nodes]),Dr=m.useMemo(()=>{const R=dn[0]||"",ie=dn[dn.length-1]||"";return`${dn.length}:${R}:${ie}`},[dn]),jr=m.useMemo(()=>{var ie;const R=new Map;for(const Ce of St.nodes)R.set(Ce.id,String(((ie=Ce.data)==null?void 0:ie.label)||Ce.id));return R},[St.nodes]),kr=m.useMemo(()=>{var ie;const R=new Map;for(const Ce of St.nodes)R.set(Ce.id,String(((ie=Ce.data)==null?void 0:ie.kind)||""));return R},[St.nodes]),hr=X.trim().toLowerCase(),Io=m.useMemo(()=>{var ie;if(!hr)return new Set;const R=new Set;for(const Ce of St.nodes){const Ie=String(Ce.id||"").toLowerCase(),De=String(((ie=Ce.data)==null?void 0:ie.label)||"").toLowerCase();(Ie.includes(hr)||De.includes(hr))&&R.add(Ce.id)}return R},[St.nodes,hr]),Hs=m.useCallback((R,ie)=>{const Ce={};for(const Ie of dn){const De=R[Ie]||ie[Ie];Ce[Ie]=De?{x:De.x,y:De.y}:{x:0,y:0}}return Ce},[dn]);m.useEffect(()=>{cn(R=>{const ie=Fc(St,{kind:Pe,seed:be}),Ce={};for(const Ie of dn){const De=R[Ie]||ie[Ie];Ce[Ie]=De?{x:De.x,y:De.y}:{x:0,y:0}}return Ce})},[St,Pe,be,dn,Dr]),m.useEffect(()=>{if(!Et.current)return;const R=S.current;if(!(!R||typeof R.fitView!="function")&&dn.length){Et.current=!1;try{R.fitView({padding:.2,duration:0})}catch{try{R.fitView({padding:.2})}catch{}}}},[dn.length,Dr,nn]),m.useEffect(()=>{tt(!1),lt.current=null,xe.current=null,Et.current=!1,Xt.current=0,je.current=0,ue.current=0;const R=Pg(Re);if(R&&Object.keys(R.positions||{}).length){if(de(R.kind),Fe(R.seed),pt(!0),Dn(R.saved_at||""),R.viewport){xe.current=R.viewport;const De=S.current;if(De&&typeof De.setViewport=="function"){try{De.setViewport(R.viewport,{duration:0})}catch{try{De.setViewport(R.viewport)}catch{}}xe.current=null}}else Et.current=!0;const Ie=Fc(St,{kind:R.kind,seed:R.seed});cn(Hs(R.positions,Ie));return}pt(!1),Dn("");const ie=Jm(Re);Fe(ie);const Ce=Fc(St,{kind:Pe,seed:ie});cn(Ce),Pe==="force"&&St.nodes.length>0&&St.nodes.length<=320&&(lt.current=Id(St,{seed:ie,positions:Ce,...$u(ze)}),tt(!0))},[Re]);const Bn=m.useMemo(()=>{const R=String(Sn||"").trim(),ie=String(Qt||"").trim();return!R||!ie?null:RN(St,R,ie,{directed:z})},[St,Sn,Qt,z]),ur=!!(Bn&&String(Sn||"").trim()&&String(Qt||"").trim()),dr=m.useMemo(()=>{const R=String(Sn||"").trim(),ie=String(Qt||"").trim();if(!R||!ie)return null;const Ce=z,Ie=new Map,De=(Rt,Lt)=>{const Kt=Ie.get(Rt);Kt?Kt.push(Lt):Ie.set(Rt,[Lt])};for(const Rt of St.edges)De(Rt.source,Rt.target),Ce||De(Rt.target,Rt.source);const at=new Set,At=[];for(at.add(R),At.push(R);At.length;){const Rt=At.shift(),Lt=Ie.get(Rt)||[];for(const Kt of Lt)at.has(Kt)||(at.add(Kt),At.push(Kt))}return{reachableFromStart:at.size,endReachable:at.has(ie),nodes:St.nodes.length,edges:St.edges.length,assertions:mr.length}},[z,St.edges,St.nodes.length,Qt,Sn,mr.length]),Me=m.useMemo(()=>new Set((Bn==null?void 0:Bn.nodeIds)||[]),[Bn]),Gn=m.useMemo(()=>new Set((Bn==null?void 0:Bn.edgeIds)||[]),[Bn]),[Ge,Yn]=m.useState(""),[er,pr]=m.useState(""),Nr=!!(String(Ge||"").trim()||String(er||"").trim()),Cr=m.useMemo(()=>{const R=new Set,ie=new Set,Ce=String(Ge||"").trim(),Ie=String(er||"").trim();if(Ce){R.add(Ce);for(const De of St.edges)(De.source===Ce||De.target===Ce)&&(ie.add(De.id),R.add(De.source),R.add(De.target));return{nodes:R,edges:ie}}if(Ie){const De=St.edges.find(at=>at.id===Ie);De&&(ie.add(De.id),R.add(De.source),R.add(De.target))}return{nodes:R,edges:ie}},[St.edges,er,Ge]);m.useEffect(()=>{Yn(""),pr(""),cr(""),Zn("")},[M]);const[Li,rn]=m.useState(!1);m.useEffect(()=>{rn(!1)},[M]),m.useEffect(()=>{Xe||(lt.current=null)},[Xe]),m.useEffect(()=>{if(Pe!=="force")return;const R=lt.current;if(!R)return;const ie=$u(ze);R.options.springLength=ie.springLength,R.options.repulsionStrength=ie.repulsionStrength},[Pe,ze]),m.useEffect(()=>{Pe!=="force"&&Xe&&tt(!1)},[Pe,Xe]),m.useEffect(()=>{if(!Xe||Pe!=="force"||St.nodes.length===0||typeof window>"u"||typeof window.requestAnimationFrame!="function")return;lt.current||(lt.current=Id(St,{seed:be,positions:vn.current,...$u(ze)}));let R=0,ie=0,Ce=0;const Ie=St.nodes.length<=140?2:1,De=1600,at=.08,At=Rt=>{if(R=window.requestAnimationFrame(At),Rt-ie<33)return;ie=Rt;const Lt=lt.current;if(!Lt){tt(!1);return}LN(Lt,Ie),Ce+=Ie,cn(IN(Lt)),(PN(Lt)<=at||Ce>=De)&&tt(!1)};return R=window.requestAnimationFrame(At),()=>{window.cancelAnimationFrame(R)}},[St,Pe,Xe,be]);const Er=m.useMemo(()=>St.nodes.map(R=>{var fn;const ie=Me.has(R.id),Ce=Io.has(R.id),Ie=Ge===R.id,De=Nr&&Cr.nodes.has(R.id),at=Au((fn=R.data)==null?void 0:fn.kind),At="rgba(34, 211, 238, 0.88)",Rt=Ce?"0 0 0 1px rgba(34, 211, 238, 0.34), 0 0 16px rgba(34, 211, 238, 0.26), 0 0 44px rgba(34, 211, 238, 0.14)":"",Lt=ie?"rgba(168, 85, 247, 0.9)":Ce?At:at.stroke,Kt=Ie?"0 0 0 2px rgba(255,255,255,0.20), 0 18px 46px rgba(0,0,0,0.55)":De?"0 0 0 1px rgba(96, 165, 250, 0.28), 0 12px 34px rgba(0,0,0,0.45)":void 0,nt=Rt&&Kt?`${Rt}, ${Kt}`:Kt||Rt||void 0,yn=ie?"rgba(168, 85, 247, 0.10)":Ce?"rgba(34, 211, 238, 0.08)":at.bg,en=ur?ie||Ie?1:.16:Nr?De||Ie?1:.1:1;return{...R,position:nn[R.id]?{x:nn[R.id].x,y:nn[R.id].y}:R.position,style:{...R.style||{},border:`1px solid ${Lt}`,borderRadius:10,background:yn,color:"rgba(255,255,255,0.92)",opacity:en,padding:8,fontSize:12,boxShadow:nt,width:180,cursor:"pointer"}}}),[St.nodes,ur,Io,nn,Ge,Me,Nr,Cr.nodes]),Vs=m.useMemo(()=>St.edges.map(R=>{const ie=Gn.has(R.id),Ce=er===R.id,Ie=Nr&&Cr.edges.has(R.id),De=ie?"rgba(168, 85, 247, 0.9)":Nr?Ie||Ce?"rgba(96, 165, 250, 0.55)":"rgba(255,255,255,0.14)":"rgba(255,255,255,0.18)",at=ie?2.75:Nr?Ie||Ce?2.25:1.25:1.5,At=Ce?"drop-shadow(0 0 10px rgba(168, 85, 247, 0.25))":void 0,Rt=ie?"rgba(168, 85, 247, 0.9)":ur?"rgba(255,255,255,0.10)":"rgba(255,255,255,0.28)",Lt=ur?ie||Ce?1:.1:Nr?Ie||Ce?1:.08:1,Kt=ur?ie||Ce?1:0:Nr?Ie||Ce?1:0:1,nt=ur?ie||Ce?String(R.label||""):"":String(R.label||"");return{...R,label:nt,style:{...R.style||{},stroke:De,strokeWidth:at,filter:At,opacity:Lt},animated:!1,markerEnd:{type:Vu.ArrowClosed,color:Rt,width:20,height:20},labelShowBg:!0,labelBgPadding:[6,3],labelBgBorderRadius:10,labelBgStyle:{fill:`rgba(0, 0, 0, ${.38*Kt})`,stroke:`rgba(255, 255, 255, ${.14*Kt})`,strokeWidth:1},labelStyle:{fill:`rgba(255, 255, 255, ${.92*Kt})`,fontSize:10,fontWeight:600,letterSpacing:.2,textTransform:"lowercase"}}}),[St.edges,ur,er,Gn,Nr,Cr.edges]),$s=m.useMemo(()=>{if(!er)return[];const R=St.edges.find(Ce=>Ce.id===er),ie=R&&R.data&&Array.isArray(R.data.assertions)?R.data.assertions:[];return Array.isArray(ie)?ie:[]},[St.edges,er]),tr=m.useMemo(()=>er&&St.edges.find(R=>R.id===er)||null,[St.edges,er]),fr=m.useMemo(()=>{const R=String(Ge||"").trim();return R?cs.filter(ie=>!ie||typeof ie!="object"||!(ie.subject===R||ie.object===R)?!1:N?!0:!xm(ie.predicate,Or)):[]},[cs,Ge,N,Or]),gi=m.useMemo(()=>er?$s:fr,[$s,er,fr]),Ln=m.useMemo(()=>{const R=new Map;for(const ie of gi){if(!ie||typeof ie!="object")continue;const Ce=ie.provenance&&typeof ie.provenance=="object"&&!Array.isArray(ie.provenance)?ie.provenance:null,Ie=Ce&&typeof Ce.span_id=="string"?Ce.span_id.trim():"",De=Ce&&typeof Ce.writer_run_id=="string"?Ce.writer_run_id.trim():"",at=typeof ie.owner_id=="string"?ie.owner_id.trim():"",At=De||at;if(!At||!Ie)continue;const Rt=`${At}|${Ie}`,Lt=R.get(Rt),Kt=typeof ie.observed_at=="string"?ie.observed_at.trim():"";Lt?(Lt.count+=1,Kt&&(!Lt.last_observed_at||Kt>Lt.last_observed_at)&&(Lt.last_observed_at=Kt,Lt.last_observed_at_fmt=Tu(Kt),Lt.assertion=ie)):R.set(Rt,{span_run_id:At,span_id:Ie,writer_run_id:De,count:1,last_observed_at:Kt,last_observed_at_fmt:Tu(Kt),assertion:ie})}return Array.from(R.values()).sort((ie,Ce)=>String(Ce.last_observed_at||"").localeCompare(String(ie.last_observed_at||"")))},[gi]),Br=m.useMemo(()=>{const R=new Map;for(const ie of gi){if(!ie||typeof ie!="object")continue;const Ce=ie.provenance&&typeof ie.provenance=="object"&&!Array.isArray(ie.provenance)?ie.provenance:null,Ie=Ce&&typeof Ce.span_id=="string"?Ce.span_id.trim():"",De=Ce&&typeof Ce.writer_run_id=="string"?Ce.writer_run_id.trim():"";if(!De||Ie)continue;const at=R.get(De),At=typeof ie.observed_at=="string"?ie.observed_at.trim():"";at?(at.count+=1,At&&(!at.last_observed_at||At>at.last_observed_at)&&(at.last_observed_at=At,at.last_observed_at_fmt=Tu(At),at.assertion=ie)):R.set(De,{run_id:De,count:1,last_observed_at:At,last_observed_at_fmt:Tu(At),assertion:ie})}return Array.from(R.values()).sort((ie,Ce)=>String(Ce.last_observed_at||"").localeCompare(String(ie.last_observed_at||"")))},[gi]),$r=m.useCallback(R=>{const ie=String(R.run_id||"").trim(),Ce=typeof R.span_id=="string"?String(R.span_id).trim():"";if(ie){if(j){try{j({run_id:ie,span_id:Ce||void 0,assertion:R.assertion})}catch{}return}if(b&&Ce)try{b({run_id:ie,span_id:Ce,assertion:R.assertion})}catch{}}},[b,j]),Qr=m.useCallback(async R=>{const ie=String(R??"");if(ie)try{await navigator.clipboard.writeText(ie)}catch{}},[]),Ur=m.useCallback(()=>{const R=S.current;if(!(!R||typeof R.fitView!="function")){if(Ge&&typeof R.getNode=="function"){const ie=R.getNode(Ge);if(ie){R.fitView({nodes:[ie],padding:.55,duration:350});return}}R.fitView({padding:.2,duration:350})}},[Ge]),As=m.useCallback(R=>{const ie=R.kind,Ce=Math.trunc(R.seed);tt(!1),lt.current=null,xe.current=null,de(ie),Fe(Ce);const Ie=Fc(St,{kind:ie,seed:Ce});cn(Ie),ie==="force"&&(R.autoPlay??!0)&&St.nodes.length>0&&St.nodes.length<=320&&(lt.current=Id(St,{seed:Ce,positions:Ie,...$u(ze)}),tt(!0))},[St,ze]),Zr=m.useCallback(()=>{if(Pe==="force"){if(Xe){tt(!1);return}lt.current=Id(St,{seed:be,positions:vn.current,...$u(ze)}),tt(!0)}},[St,Pe,Xe,be,ze]);m.useEffect(()=>()=>{typeof window>"u"||typeof window.cancelAnimationFrame=="function"&&Ne.current&&window.cancelAnimationFrame(Ne.current)},[]);const es=m.useCallback(()=>{const R=S.current;if(!R||typeof R.getViewport!="function"||!dn.length)return null;const ie=ln.current;if(!ie)return null;const Ce=ie.getBoundingClientRect();if(!Number.isFinite(Ce.width)||!Number.isFinite(Ce.height)||Ce.width<64||Ce.height<64)return null;const Ie=R.getViewport(),De=typeof(Ie==null?void 0:Ie.zoom)=="number"&&Number.isFinite(Ie.zoom)?Ie.zoom:null,at=typeof(Ie==null?void 0:Ie.x)=="number"&&Number.isFinite(Ie.x)?Ie.x:null,At=typeof(Ie==null?void 0:Ie.y)=="number"&&Number.isFinite(Ie.y)?Ie.y:null;if(De===null||at===null||At===null||De<=0)return null;const Rt=140,Lt=Math.min(dn.length,180),Kt=vn.current;let nt=0,yn=0;for(const en of dn){const fn=Kt[en];if(!fn||!Number.isFinite(fn.x)||!Number.isFinite(fn.y))continue;yn+=1;const or=[{x:fn.x,y:fn.y},{x:fn.x+90,y:fn.y+24}];for(const An of or){const Tr=An.x*De+at,bs=An.y*De+At;if(Tr>-Rt&&Tr<Ce.width+Rt&&bs>-Rt&&bs<Ce.height+Rt)return!1}if(nt++,nt>=Lt)break}return yn?!0:null},[dn]),gr=m.useCallback(R=>{typeof window>"u"||typeof window.requestAnimationFrame!="function"||Ne.current||(Ne.current=window.requestAnimationFrame(()=>{Ne.current=0;const ie=es();if(ie===null){if(ue.current>=12)return;ue.current+=1,window.setTimeout(()=>gr(`${R}:probe`),120);return}if(ie!==!0){ue.current=0,je.current=0;return}ue.current=0;const Ce=S.current;if(Ce&&typeof Ce.fitView=="function")try{Ce.fitView({padding:.2,duration:0})}catch{try{Ce.fitView({padding:.2})}catch{}}if(je.current+=1,je.current>=4&&Xt.current<1){je.current=0,Xt.current+=1,sn(Ie=>Ie+1);return}je.current<8&&window.setTimeout(()=>gr(`${R}:retry`),220)}))},[es]);m.useEffect(()=>{je.current=0,Xt.current=0,ue.current=0,gr("mount")},[M,gr]),m.useEffect(()=>{gr("graph change")},[Dr,gr]),m.useEffect(()=>{const R=ln.current;if(!R||typeof window>"u"||typeof ResizeObserver!="function")return;const ie=new ResizeObserver(()=>gr("resize"));return ie.observe(R),()=>ie.disconnect()},[gr]);const Pi=m.useCallback(()=>{const R=new Date().toISOString(),ie={};for(const At of dn){const Rt=vn.current[At];Rt&&typeof Rt.x=="number"&&typeof Rt.y=="number"&&(ie[At]={x:Rt.x,y:Rt.y})}const Ce=S.current,Ie=Ce&&typeof Ce.toObject=="function"?Ce.toObject():null,De=Ie&&Ie.viewport?Ie.viewport:Ce&&typeof Ce.getViewport=="function"?Ce.getViewport():null,at=qy(De,{minZoom:Qm,maxZoom:Zm,maxAbsTranslate:Xy})??void 0;BN(Re,{version:1,kind:Pe,seed:be,positions:ie,viewport:at,saved_at:R}),pt(!0),Dn(R),tt(!1)},[Re,Pe,be,dn]),Wr=m.useCallback(()=>{const R=Pg(Re);if(!R)return;tt(!1),lt.current=null,de(R.kind),Fe(R.seed),pt(!0),Dn(R.saved_at||""),xe.current=R.viewport||null,Et.current=!R.viewport;const ie=Fc(St,{kind:R.kind,seed:R.seed});if(cn(Hs(R.positions,ie)),R.viewport){const Ce=S.current;if(Ce&&typeof Ce.setViewport=="function"){try{Ce.setViewport(R.viewport,{duration:0})}catch{try{Ce.setViewport(R.viewport)}catch{}}xe.current=null}}},[Hs,St,Re]),Ii=m.useCallback(()=>{UN(Re),pt(!1),Dn("")},[Re]),Fi=m.useCallback(R=>{if(!Array.isArray(R)||R.length===0)return;let ie=!1;cn(Ce=>{let Ie=Ce,De=!1;for(const at of R){const At=at&&typeof at=="object"&&"id"in at&&typeof at.id=="string"?String(at.id):"",Rt=(at==null?void 0:at.type)==="position"?at==null?void 0:at.position:null;At&&Rt&&typeof Rt.x=="number"&&typeof Rt.y=="number"&&(De||(Ie={...Ce},De=!0),Ie[At]={x:Rt.x,y:Rt.y},at!=null&&at.dragging&&(ie=!0))}return De?Ie:Ce}),ie&&Xe&&tt(!1)},[Xe]),Ts=m.useMemo(()=>{const R=new Map;for(const ie of St.edges)R.set(ie.id,ie);return R},[St.edges]),Oi=m.useMemo(()=>{var Ie;if(!Bn)return[];const R=Bn.nodeIds||[],ie=Bn.edgeIds||[],Ce=[];for(let De=0;De<Math.min(R.length-1,ie.length);De++){const at=R[De],At=R[De+1],Rt=ie[De],Lt=Ts.get(Rt),Kt=String(((Ie=Lt==null?void 0:Lt.data)==null?void 0:Ie.predicateSummary)||(Lt==null?void 0:Lt.label)||"").trim(),nt=Lt&&Lt.source===at&&Lt.target===At?"forward":Lt&&Lt.source===At&&Lt.target===at?"reverse":"unknown";Ce.push({from:at,to:At,edgeId:Rt,predicate:Kt,dir:nt})}return Ce},[Ts,Bn]),ua=m.useCallback(async()=>{if(x){_e(""),U(""),oe(!0);try{const R=WN(un),ie=ym(Zt,{allowZero:!0,allowNegativeOne:!0}),Ce=ym(rt,{allowZero:!0}),Ie=await x({scope:Un,owner_id:void 0,recall_level:ke,query_text:it||void 0,subject:zt||void 0,predicate:Ot||void 0,object:It||void 0,min_score:R,limit:ie,max_input_tokens:Ce,model:Rn||void 0});I(Ie),ne("live query"),D==="replace"&&v&&Ie&&Array.isArray(Ie.items)&&v(Ie.items,{kind:"live query",result:Ie})}catch(R){const ie=R instanceof Error?R.message:String(R);_e(ie||"Query failed")}finally{oe(!1)}}},[Zt,rt,un,Rn,It,v,x,Ot,D,it,ke,Un,zt]),Ms=m.useCallback(async()=>{if(!x)return;const R=String(Sn||"").trim(),ie=String(Qt||"").trim();if(!R||!ie)return;const Ce=Math.max(200,ym(Zt)??80),Ie=60;U(""),_e(""),$e(!0);try{const De=[],at=new Set,At=en=>{if(!en||typeof en!="object"||typeof en.subject!="string"||typeof en.predicate!="string"||typeof en.object!="string")return;const fn=`${en.subject}|${en.predicate}|${en.object}|${String(en.observed_at||"")}|${String(en.scope||"")}|${String(en.owner_id||"")}`;at.has(fn)||(at.add(fn),De.push(en))};for(const en of cs)At(en);const Rt=z,Lt=new Set,Kt=[R],nt=new Set([R]),yn=async en=>{const fn=await x({scope:Un,recall_level:ke,min_score:0,limit:Ce,subject:en,query_text:void 0,max_input_tokens:0,model:void 0});if(fn&&Array.isArray(fn.items)){for(const or of fn.items)if(At(or),typeof or.subject=="string"&&or.subject.trim()===en&&typeof or.object=="string"){const An=or.object.trim();An&&!nt.has(An)&&(nt.add(An),Kt.push(An))}}if(!Rt){const or=await x({scope:Un,recall_level:ke,min_score:0,limit:Ce,object:en,query_text:void 0,max_input_tokens:0,model:void 0});if(or&&Array.isArray(or.items)){for(const An of or.items)if(At(An),typeof An.object=="string"&&An.object.trim()===en&&typeof An.subject=="string"){const Tr=An.subject.trim();Tr&&!nt.has(Tr)&&(nt.add(Tr),Kt.push(Tr))}}}};for(;Kt.length&&Lt.size<Ie&&!nt.has(ie);){const en=Kt.shift();!en||Lt.has(en)||(Lt.add(en),await yn(en))}I({ok:!0,count:De.length,items:De,active_memory_text:En,raw:{expanded_for_path:!0,expanded_nodes:Lt.size,discovered_nodes:nt.size,merged:De.length,directed:Rt}}),ne("expanded neighborhood"),D==="replace"&&v&&v(De,{kind:"expanded neighborhood",result:{ok:!0,count:De.length,items:De,active_memory_text:En,raw:{expanded_for_path:!0,expanded_nodes:Lt.size,discovered_nodes:nt.size,merged:De.length,directed:Rt}}})}catch(De){const at=De instanceof Error?De.message:String(De);U(at||"Expand neighborhood failed")}finally{$e(!1)}},[z,En,cs,Zt,v,x,Qt,Sn,D,ke,Un]),qs=m.useCallback(()=>{I(null),ne(null),_e(""),oe(!1),U(""),$e(!1),cr(""),Zn(""),Yn(""),pr("")},[]),Hr="Search KG",zs=St.nodes.length,Di=St.edges.length,Fo=mr.length;return s.jsxs("div",{className:"amx-root",children:[s.jsxs("div",{className:"amx-left",children:[s.jsx("div",{className:"amx-graphbar",role:"toolbar","aria-label":"Graph layout controls",children:s.jsxs("div",{className:"amx-graphbar-row",children:[s.jsx("span",{className:"amx-graphbar-title",children:"layout"}),s.jsxs("select",{value:Pe,onChange:R=>de(eh(R.target.value,Pe)),disabled:!dn.length,children:[s.jsx("option",{value:"grid",children:"grid (deterministic)"}),s.jsx("option",{value:"radial",children:"radial (bfs)"}),s.jsx("option",{value:"circle",children:"circle"}),s.jsx("option",{value:"force",children:"force (simulation)"})]}),Pe==="force"?s.jsxs("label",{className:"amx-graphbar-spread",children:[s.jsx("span",{className:"amx-graphbar-title",children:"spread"}),s.jsx("input",{type:"range",min:"0.7",max:"2.2",step:"0.1",value:ze,onChange:R=>Oe(Yy(Number(R.target.value),.7,2.2,1))}),s.jsxs("span",{className:"amx-small",children:[ze.toFixed(1),"×"]})]}):null,s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>As({kind:Pe,seed:be}),disabled:!dn.length,children:"Apply"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:Zr,disabled:!dn.length||Pe!=="force",children:Xe?"Pause simulation":"Play simulation"})]})}),s.jsxs("div",{className:"amx-graph","aria-label":"Knowledge graph",ref:ln,children:[s.jsx(wh,{children:s.jsxs(By,{nodes:Er,edges:Vs,defaultViewport:{x:0,y:0,zoom:1},minZoom:Qm,maxZoom:Zm,onInit:R=>{S.current=R;const ie=xe.current;if(ie&&typeof R.setViewport=="function")try{R.setViewport(ie,{duration:0})}catch{try{R.setViewport(ie)}catch{}}if(Et.current&&typeof R.fitView=="function")try{R.fitView({padding:.2,duration:0})}catch{try{R.fitView({padding:.2})}catch{}}xe.current=null,Et.current=!1,gr("init")},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,onNodesChange:Fi,onNodeClick:(R,ie)=>{pr(""),Yn(ie.id)},onEdgeClick:(R,ie)=>{Yn(""),pr(ie.id)},onPaneClick:()=>{Yn(""),pr("")},children:[s.jsx(bN,{className:"amx-flow-controls",children:s.jsx(Dc,{type:"button",className:`amx-control-legend ${se?"amx-control-legend-active":""}`,onClick:()=>ve(R=>!R),title:se?"Hide node color legend":"Show node color legend","aria-label":se?"Hide node color legend":"Show node color legend",children:s.jsx(ON,{})})}),s.jsx(Uu,{position:"bottom-right",className:"amx-panel-bottom-right",children:s.jsx("div",{className:"amx-panel-toggles",children:s.jsx("button",{type:"button",className:"amx-minimap-toggle",onClick:()=>Ae(R=>!R),title:he?"Hide minimap preview":"Show minimap preview","aria-label":he?"Hide minimap preview":"Show minimap preview",children:he?"minimap on":"minimap off"})})}),he?s.jsx(pN,{position:"bottom-right",pannable:!0,zoomable:!0,maskColor:"rgba(0,0,0,0.45)",style:{background:"rgba(12, 18, 34, 0.88)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:10,width:te?120:160,height:te?80:110,marginBottom:56},nodeColor:R=>{var ie;return Au((ie=R.data)==null?void 0:ie.kind).minimap}}):null,se?s.jsxs(Uu,{position:"bottom-left",className:"amx-legend-panel",children:[s.jsx("div",{className:"amx-legend-title",children:"node colors"}),s.jsx("div",{className:"amx-legend",children:[{k:"person",label:"person"},{k:"org",label:"org"},{k:"concept",label:"concept"},{k:"claim",label:"claim"},{k:"event",label:"event"},{k:"doc",label:"doc"},{k:"vocab",label:"vocab"}].map(({k:R,label:ie})=>s.jsx("span",{className:"amx-legend-item",style:{borderColor:Au(R).stroke},children:ie},R))})]}):null,s.jsx(EN,{gap:20,size:1,color:"rgba(255,255,255,0.06)"})]})},yt),s.jsxs("details",{className:"amx-panel amx-controls",children:[s.jsxs("summary",{children:[s.jsx("span",{className:"amx-controls-title",children:Hr}),s.jsxs("span",{className:"amx-small",children:[Fo," assertions · ",zs," nodes · ",Di," edges"]})]}),s.jsxs("div",{className:"amx-toolbar",style:{marginTop:10},children:[s.jsxs("div",{className:"amx-toolbar-grid",children:[s.jsxs("label",{children:["search / highlight",s.jsx("input",{value:X,onChange:R=>V(R.target.value),placeholder:"filter nodes by id/label"})]}),s.jsxs("label",{children:["group edges",s.jsxs("select",{value:String(J),onChange:R=>k(R.target.value==="true"),children:[s.jsx("option",{value:"true",children:"group (subject→object)"}),s.jsx("option",{value:"false",children:"no grouping"})]})]}),s.jsxs("label",{children:["view",s.jsxs("select",{value:String(N),onChange:R=>B(R.target.value==="true"),children:[s.jsx("option",{value:"true",children:"all assertions"}),s.jsx("option",{value:"false",children:"hide rdf:type / labels"})]})]}),s.jsxs("label",{children:["path mode",s.jsxs("select",{value:String(z),onChange:R=>F(R.target.value==="true"),children:[s.jsx("option",{value:"false",children:"undirected"}),s.jsx("option",{value:"true",children:"directed"})]})]})]}),s.jsxs("details",{className:"amx-details",children:[s.jsx("summary",{children:"layout"}),s.jsxs("div",{className:"amx-toolbar-grid",style:{marginTop:10},children:[s.jsxs("label",{children:["layout",s.jsxs("select",{value:Pe,onChange:R=>de(eh(R.target.value,Pe)),children:[s.jsx("option",{value:"grid",children:"grid (deterministic)"}),s.jsx("option",{value:"radial",children:"radial (bfs)"}),s.jsx("option",{value:"circle",children:"circle"}),s.jsx("option",{value:"force",children:"force (simulation)"})]})]}),s.jsxs("label",{children:["seed",s.jsx("input",{type:"number",step:"1",value:be,onChange:R=>Fe(Math.trunc(Number(R.target.value||0)||0))})]})]}),s.jsxs("div",{className:"amx-actions",style:{marginTop:10},children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>As({kind:Pe,seed:be}),disabled:!dn.length,children:"Apply layout"}),Pe==="force"?s.jsx("button",{type:"button",className:"amx-btn",onClick:Zr,disabled:!dn.length,children:Xe?"Pause simulation":"Play simulation"}):null,s.jsx("button",{type:"button",className:"amx-btn",onClick:Pi,disabled:!dn.length,children:"Save layout"}),$t?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:Wr,children:"Load saved"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:Ii,children:"Clear saved"})]}):null]}),s.jsxs("div",{className:"amx-small",style:{marginTop:10,opacity:.9},children:["Drag nodes to adjust manually; use ",s.jsx("span",{className:"amx-mono",children:"Save layout"})," for a stable, replayable view.",$t?s.jsxs("span",{children:[" ","(saved",qt?`: ${qt}`:"",")"]}):s.jsx("span",{children:" (no saved layout)"})]})]}),s.jsxs("details",{className:"amx-details",children:[s.jsx("summary",{children:"path"}),s.jsxs("div",{className:"amx-toolbar-grid",style:{marginTop:10},children:[s.jsxs("label",{children:["path start",s.jsxs("select",{value:Sn,onChange:R=>cr(R.target.value),children:[s.jsx("option",{value:"",children:"(none)"}),dn.map(R=>s.jsx("option",{value:R,children:(()=>{const ie=jr.get(R)||R;return ie===R?ie:`${ie} (${R})`})()},R))]})]}),s.jsxs("label",{children:["path end",s.jsxs("select",{value:Qt,onChange:R=>Zn(R.target.value),children:[s.jsx("option",{value:"",children:"(none)"}),dn.map(R=>s.jsx("option",{value:R,children:(()=>{const ie=jr.get(R)||R;return ie===R?ie:`${ie} (${R})`})()},R))]})]})]}),Bn?s.jsx("div",{className:"amx-small",style:{marginTop:10},children:Oi.map((R,ie)=>{const Ce=jr.get(R.from)||R.from,Ie=jr.get(R.to)||R.to,De=R.dir==="reverse"?" ← ":" → ",at=R.predicate?` (${R.predicate})`:"";return s.jsxs("div",{children:[ie===0?s.jsx("span",{children:Ce}):null,De,s.jsxs("span",{children:[Ie,at]})]},`${R.edgeId}:${ie}`)})}):Sn&&Qt?s.jsxs("div",{className:"amx-small",style:{marginTop:10,opacity:.9},children:["No path found in the current subgraph (",(dr==null?void 0:dr.assertions)??Fo," assertions · ",(dr==null?void 0:dr.nodes)??St.nodes.length," nodes ·"," ",(dr==null?void 0:dr.edges)??St.edges.length," edges). Start reaches ",(dr==null?void 0:dr.reachableFromStart)??0," nodes.",x?s.jsx("div",{style:{marginTop:10},children:s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void Ms(),disabled:Te,children:Te?"Expanding…":"Expand neighborhood"})}):null]}):s.jsx("div",{className:"amx-small",style:{marginTop:10},children:"(no path)"})]}),s.jsxs("details",{className:"amx-details",children:[s.jsx("summary",{children:"query"}),s.jsxs("div",{className:"amx-toolbar-grid",style:{marginTop:10},children:[s.jsxs("label",{children:["query_text (semantic)",s.jsx("input",{value:it,onChange:R=>bt(R.target.value),placeholder:"e.g. emotion chip"})]}),s.jsxs("label",{children:["subject (exact)",s.jsx("input",{value:zt,onChange:R=>Ut(R.target.value),placeholder:"e.g. ex:person-data"})]}),s.jsxs("label",{children:["predicate (exact)",s.jsx("input",{value:Ot,onChange:R=>pn(R.target.value),placeholder:"e.g. schema:about"})]}),s.jsxs("label",{children:["object (exact)",s.jsx("input",{value:It,onChange:R=>_n(R.target.value),placeholder:"e.g. ex:concept-emotion-chip"})]}),s.jsxs("label",{children:["min_score",s.jsx("input",{type:"number",step:"any",value:un,onChange:R=>Gt(R.target.value),placeholder:"(auto)"})]}),s.jsxs("label",{children:["limit",s.jsx("input",{type:"number",min:"-1",step:"1",value:Zt,onChange:R=>Vt(R.target.value),placeholder:"0/-1 = unlimited (if supported)"})]})]})]}),s.jsxs("details",{className:"amx-details",children:[s.jsx("summary",{children:"advanced"}),s.jsxs("div",{className:"amx-toolbar-grid",style:{marginTop:10},children:[s.jsxs("label",{children:["scope",s.jsxs("select",{value:Un,onChange:R=>me(Lg(R.target.value,Un)),children:[s.jsx("option",{value:"run",children:"run"}),s.jsx("option",{value:"session",children:"session"}),s.jsx("option",{value:"global",children:"global"}),s.jsx("option",{value:"all",children:"all"})]})]}),s.jsxs("label",{children:["recall level",s.jsxs("select",{value:ke,onChange:R=>ct(R.target.value||"standard"),children:[s.jsx("option",{value:"urgent",children:"urgent"}),s.jsx("option",{value:"standard",children:"standard"}),s.jsx("option",{value:"deep",children:"deep"})]})]}),s.jsxs("label",{children:["max_input_tokens",s.jsx("input",{type:"number",min:"0",step:"1",value:rt,onChange:R=>jn(R.target.value),placeholder:"(auto)"})]}),s.jsxs("label",{children:["model (budgeting)",s.jsx("input",{value:Rn,onChange:R=>kn(R.target.value),placeholder:"qwen/qwen3-next-80b"})]})]})]}),s.jsxs("div",{className:"amx-actions",children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void ua(),disabled:!x||Y,children:Y?"Querying…":"Query store"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:qs,disabled:!L&&!le&&!Y,children:"Reset to step output"}),L?s.jsxs("span",{className:"amx-small",children:["showing: ",G||"live query"]}):s.jsx("span",{className:"amx-small",children:"showing: step output"}),le?s.jsx("span",{className:"amx-small",style:{color:"rgba(255, 80, 80, 0.95)"},children:le}):null,K?s.jsx("span",{className:"amx-small",style:{color:"rgba(255, 80, 80, 0.95)"},children:K}):null]})]})]})]})]}),s.jsxs("div",{className:"amx-right",children:[s.jsxs("div",{className:"amx-panel",children:[s.jsx("h3",{children:"Details"}),s.jsx("div",{className:"amx-small",style:{marginBottom:8},children:"Derived from `memory_kg_query` packetization (max_input_tokens); safe to inject into an LLM system prompt."}),(()=>{const R=HN(us);return R?s.jsx("div",{className:"amx-small",style:{marginBottom:8,opacity:.9},children:R}):null})(),(()=>{const R=Jr;if(!R)return null;const ie=typeof R=="string"?R:Array.isArray(R)?R.map(Ce=>String(Ce)).join(" · "):JSON.stringify(R);return!ie||!ie.trim()?null:s.jsx("div",{className:"amx-small",style:{marginBottom:8,color:"rgba(255, 180, 90, 0.95)"},children:ie})})(),s.jsx("div",{className:"amx-small",style:{marginBottom:8,opacity:.9},children:(()=>{const R=(L==null?void 0:L.packets_version)??Sr,ie=(L==null?void 0:L.packed_count)??Fr,Ce=(L==null?void 0:L.dropped)??Ws,Ie=(L==null?void 0:L.estimated_tokens)??Es,De=[];return typeof R=="number"&&De.push(`packets_v${R}`),typeof ie=="number"&&De.push(`packed=${ie}`),typeof Ce=="number"&&De.push(`dropped=${Ce}`),typeof Ie=="number"&&De.push(`est_tokens=${Ie}`),De.length?De.join(" · "):"No packetization stats (set max_input_tokens > 0)."})()}),s.jsx("div",{className:"amx-active-memory",children:qN(En||"(empty)",X)}),(()=>{const R=L!=null&&L.packets&&Array.isArray(L.packets)?L.packets:Ir;return!Array.isArray(R)||R.length===0?null:s.jsxs("div",{style:{marginTop:10},children:[s.jsxs("button",{type:"button",className:"amx-btn",onClick:()=>rn(ie=>!ie),children:[Li?"Hide":"Show"," packets (",R.length,")"]}),Li?s.jsx("div",{className:"amx-list",style:{marginTop:10},children:R.slice(0,120).map((ie,Ce)=>{const Ie=ie&&typeof ie=="object"&&!Array.isArray(ie)?ie:null,De=Ie&&typeof Ie.statement=="string"?Ie.statement:typeof ie=="string"?ie:"",at=Ie&&(typeof Ie.retrieval_score=="number"||typeof Ie.retrieval_score=="string")?Ie.retrieval_score:null,At=Ie&&typeof Ie.observed_at=="string"?Ie.observed_at:null;return s.jsxs("div",{className:"amx-item",children:[s.jsx("div",{className:"amx-mono",children:De||"(packet)"}),At||at!==null?s.jsxs("div",{className:"amx-small",children:[At?`[${At}]`:null,At&&at!==null?" ":null,at!==null?`score:${at}`:null]}):null]},Ce)})}):null]})})(),s.jsx("div",{style:{marginTop:14,marginBottom:12,borderTop:"1px solid rgba(255,255,255,0.08)"}}),s.jsx("div",{className:"amx-small",style:{marginBottom:8,fontWeight:700,opacity:.9},children:"Inspect"}),s.jsx("div",{className:"amx-small",style:{marginBottom:8},children:"Click a node or edge to inspect its assertions."}),Ge?s.jsxs("div",{className:"amx-item",style:{marginBottom:10,display:"flex",justifyContent:"space-between",gap:10,alignItems:"center"},children:[s.jsxs("div",{style:{minWidth:0},children:[s.jsx("div",{className:"amx-mono",style:{fontSize:11,opacity:.95},children:jr.get(Ge)||Ge}),s.jsxs("div",{className:"amx-small",children:["kind=",kr.get(Ge)||"entity"," · id=",Ge]})]}),s.jsxs("div",{className:"amx-actions",children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void Qr(Ge),children:"Copy id"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:Ur,children:"Focus"})]})]}):tr&&tr.source&&tr.target?s.jsxs("div",{className:"amx-item",style:{marginBottom:10,display:"flex",justifyContent:"space-between",gap:10,alignItems:"center"},children:[s.jsxs("div",{style:{minWidth:0},children:[s.jsxs("div",{className:"amx-mono",style:{fontSize:11,opacity:.95},children:[tr.source," —",String(tr.label||((Ar=tr.data)==null?void 0:Ar.predicateSummary)||"").trim()||"?","→ ",tr.target]}),s.jsxs("div",{className:"amx-small",children:["edge_id=",tr.id]})]}),s.jsxs("div",{className:"amx-actions",children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void Qr(tr.id),children:"Copy id"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:Ur,children:"Fit"})]})]}):s.jsx("div",{className:"amx-small",style:{marginBottom:10,opacity:.9},children:"(no selection)"}),s.jsx("div",{className:"amx-list",children:gi.slice(0,80).map((R,ie)=>{const Ce=String(R.subject||"").trim(),Ie=String(R.predicate||"").trim(),De=String(R.object||"").trim(),at=jr.get(Ce)||Ce,At=jr.get(De)||De,Rt=kr.get(Ce)||"entity",Lt=kr.get(De)||"entity",Kt=Au(Rt),nt=Au(Lt),yn=Tu(R.observed_at),en=VN(R),fn=R.provenance&&typeof R.provenance=="object"&&!Array.isArray(R.provenance)?R.provenance:null,or=fn&&typeof fn.span_id=="string"?fn.span_id.trim():"",An=fn&&typeof fn.writer_run_id=="string"?fn.writer_run_id.trim():"",Tr=typeof R.owner_id=="string"?R.owner_id.trim():"",bs=An||Tr,_i=!!((j||b)&&or&&bs),Rs=!!(j&&An&&!or),co=_i||Rs;return s.jsxs("div",{className:"amx-item amx-triple-card",children:[s.jsxs("div",{className:"amx-triple-row",children:[s.jsx("button",{type:"button",className:"amx-term",style:{borderColor:Kt.stroke,background:Kt.bg},title:Ce,onClick:()=>{Ce&&(pr(""),Yn(Ce))},children:at||Ce||"(subject)"}),s.jsx("span",{className:"amx-arrow",children:"—"}),s.jsx("span",{className:"amx-predicate",title:Ie,children:Ky(Ie)||"(predicate)"}),s.jsx("span",{className:"amx-arrow",children:"→"}),s.jsx("button",{type:"button",className:"amx-term",style:{borderColor:nt.stroke,background:nt.bg},title:De,onClick:()=>{De&&(pr(""),Yn(De))},children:At||De||"(object)"})]}),s.jsxs("div",{className:"amx-triple-meta",children:[yn?s.jsxs("span",{className:"amx-small",title:String(R.observed_at||""),children:["[",yn,"]"]}):null,en?s.jsx("span",{className:"amx-small",children:en}):null]}),or||An?s.jsxs("div",{className:"amx-triple-actions",children:[or?s.jsxs("span",{className:"amx-small",children:["span:",or]}):null,An?s.jsxs("span",{className:"amx-small",children:["run:",An]}):null,co?s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>{if(_i&&or&&bs){$r({run_id:bs,span_id:or,assertion:R});return}Rs&&An&&$r({run_id:An,assertion:R})},children:"Open transcript"}):null]}):null]},ie)})})]}),s.jsxs("div",{className:"amx-panel",children:[s.jsx("h3",{children:"Transcript"}),s.jsx("div",{className:"amx-small",style:{marginBottom:8},children:"Pivot from a triple to its provenance transcript (span/note artifact, or run input fallback)."}),Ln.length?s.jsxs("div",{style:{marginBottom:12},children:[s.jsx("div",{className:"amx-small",style:{marginBottom:6,opacity:.85},children:"spans"}),s.jsx("div",{className:"amx-list",style:{maxHeight:320},children:Ln.slice(0,60).map(R=>s.jsxs("div",{className:"amx-item",style:{display:"flex",justifyContent:"space-between",gap:10,alignItems:"center"},children:[s.jsxs("div",{style:{minWidth:0},children:[s.jsxs("div",{className:"amx-mono",style:{fontSize:11,opacity:.95},children:["span:",R.span_id]}),s.jsxs("div",{className:"amx-small",children:["run_id=",R.span_run_id," · assertions=",R.count,R.last_observed_at_fmt?` · last=[${R.last_observed_at_fmt}]`:""]})]}),b||j?s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>$r({run_id:R.span_run_id,span_id:R.span_id,assertion:R.assertion}),children:"Open transcript"}):null]},`${R.span_run_id}|${R.span_id}`))})]}):null,j&&Br.length?s.jsxs("div",{style:{marginBottom:12},children:[s.jsx("div",{className:"amx-small",style:{marginBottom:6,opacity:.85},children:"runs (fallback)"}),s.jsx("div",{className:"amx-list",style:{maxHeight:240},children:Br.slice(0,40).map(R=>s.jsxs("div",{className:"amx-item",style:{display:"flex",justifyContent:"space-between",gap:10,alignItems:"center"},children:[s.jsxs("div",{style:{minWidth:0},children:[s.jsxs("div",{className:"amx-mono",style:{fontSize:11,opacity:.95},children:["run:",R.run_id]}),s.jsxs("div",{className:"amx-small",children:["assertions=",R.count,R.last_observed_at_fmt?` · last=[${R.last_observed_at_fmt}]`:""]})]}),s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>$r({run_id:R.run_id,assertion:R.assertion}),children:"Open transcript"})]},R.run_id))})]}):null,!Ln.length&&!(j&&Br.length)?s.jsx("div",{className:"amx-small",children:"(no provenance)"}):null]})]})]})}function vm(e,t="session"){const r=String(e||"").trim().toLowerCase();return r==="run"||r==="session"||r==="global"||r==="all"?r:t}function dl(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const r=t.replace(/(\.\d{3})\d+/,"$1"),o=Date.parse(r);return Number.isFinite(o)?o:null}function Gl(e){if(typeof e!="number"||!Number.isFinite(e))return"—";const t=new Date(e),r=t.getUTCFullYear(),o=String(t.getUTCMonth()+1).padStart(2,"0"),l=String(t.getUTCDate()).padStart(2,"0"),u=String(t.getUTCHours()).padStart(2,"0"),c=String(t.getUTCMinutes()).padStart(2,"0");return`${r}/${o}/${l} ${u}:${c}`}function KN(e){const t=String(e??"").trim();if(!t)return"";if(/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}$/.test(t))return t;const r=dl(t);return r!==null?Gl(r):t}function Sh(e){const t=typeof e=="string"?e:String(e??"");return t?!t.includes("\\n")&&!t.includes("\\r")&&!t.includes("\\t")?t:t.replace(/\\r\\n/g,`
|
|
118
|
+
`).replace(/\\n/g,`
|
|
119
|
+
`).replace(/\\t/g," "):""}function Jy(e){return String(e??"").replace(/[*_`~]/g,"")}function Fd(e,t){const r=!!(t!=null&&t.strip_punct),o=Sh(e);let l=Jy(o).replace(/\s+/g," ").trim().toLowerCase();return r&&(l=l.replace(/[^\p{L}\p{N}\s]+/gu,"").replace(/\s+/g," ").trim()),l}function Od(e,t){const r=String(t??"").trim();if(!r)return!1;const o=Fd(r,{strip_punct:!1});if(!o)return!1;if(Fd(String(e??""),{strip_punct:!1}).includes(o))return!0;const u=Fd(r,{strip_punct:!0});return u?Fd(String(e??""),{strip_punct:!0}).includes(u):!1}function Ig(e){const t=Sh(e).trim();if(!t)return[];const r=[],o=c=>{const d=String(c??"").replace(/\s+/g," ").trim();d&&(d.length<6||r.includes(d)||r.push(d))},l=t.search(/[`*_~]/);if(l>0){const c=t.slice(0,l);c.replace(/\s+/g," ").trim().length>=10&&o(c)}const u=[/`([^`]+)`/g,/\*\*([^*]+)\*\*/g,/__([^_]+)__/g,/\*([^*]+)\*/g,/_([^_]+)_/g];for(const c of u){let d;for(;(d=c.exec(t))!==null;){const h=String(d[1]??"").trim();h&&o(h)}}return o(Jy(t)),r}function JN(e){const t=String(e??"").replace(/\r\n/g,`
|
|
120
|
+
`).replace(/\r/g,`
|
|
121
|
+
`);if(!t)return null;const r=t.split(`
|
|
122
|
+
`);let o;const l=[],u=[];let c=null,d=[],h=!1;const _=()=>{if(!c)return;const v=d.join(`
|
|
123
|
+
`).trim();v&&u.push({role:c,lines:[v]}),c=null,d=[]};for(const v of r){const b=o?null:v.match(/^\s*created_at\s*=\s*(.+)\s*$/i);if(b&&b[1]){o=b[1].trim();continue}const j=v.match(/^\s*(USER|ASSISTANT|SYSTEM)\s*:\s*(.*)$/i);if(j){h=!0,_();const S=String(j[1]||"").trim().toLowerCase();c=S==="user"?"user":S==="assistant"?"assistant":"system";const T=String(j[2]??"");d=T?[T]:[];continue}c?d.push(v):l.push(v)}if(_(),!h||!u.length)return null;const g=l.join(`
|
|
124
|
+
`).trim(),x={messages:[]};o&&(x.created_at=o),g&&x.messages.push({role:"system",content:g});for(const v of u)x.messages.push({role:v.role,content:v.lines.join(`
|
|
125
|
+
`)});return x.messages.length?x:null}function Fg(e,t){const r=String(e||""),o=String(t||"");return o>r?o:r}function Og(e){const t=String((e==null?void 0:e.subject)||"").trim(),r=String((e==null?void 0:e.predicate)||"").trim(),o=String((e==null?void 0:e.object)||"").trim(),l=String((e==null?void 0:e.observed_at)||"").trim(),u=String((e==null?void 0:e.scope)||"").trim(),c=String((e==null?void 0:e.owner_id)||"").trim();return`${t}|${r}|${o}|${l}|${u}|${c}`}function QN(e){const t=String((e==null?void 0:e.observed_at)||"").trim(),r=String((e==null?void 0:e.subject)||"").trim(),o=String((e==null?void 0:e.predicate)||"").trim(),l=String((e==null?void 0:e.object)||"").trim(),u=String((e==null?void 0:e.scope)||"").trim(),c=String((e==null?void 0:e.owner_id)||"").trim(),d=[];u&&d.push(`scope=${u}`),c&&d.push(`owner=${c}`);const h=d.length?` (${d.join(", ")})`:"";return`${t?`[${t}] `:""}${r} --${o}--> ${l}${h}`}function ZN({gateway:e,selected_run_id:t,selected_session_id:r}){const[o,l]=m.useState(String(t||"").trim()),[u,c]=m.useState(String(r||"").trim()),[d,h]=m.useState("all"),_=d==="all",[g,x]=m.useState(!0),[v,b]=m.useState(750),[j,S]=m.useState(5e3),[T,M]=m.useState([]),[D,L]=m.useState(void 0),[I,G]=m.useState(""),[ne,Y]=m.useState(!1),[oe,le]=m.useState([]),[_e,Te]=m.useState(!1),[$e,K]=m.useState(!1),[U,X]=m.useState(""),[V,J]=m.useState(""),[k,z]=m.useState(""),[F,N]=m.useState(""),[B,Z]=m.useState("artifact"),[te,he]=m.useState(null),[Ae,se]=m.useState(""),[ve,Re]=m.useState(null),Qe=m.useRef(!1),Pe=m.useMemo(()=>{const me=ve,ke=me!=null&&me.attributes&&typeof me.attributes=="object"&&!Array.isArray(me.attributes)?me.attributes:null;return(ke&&typeof ke.evidence_quote=="string"?String(ke.evidence_quote):"").trim()},[ve]),de=m.useMemo(()=>{const me=te,ke=me&&typeof me=="object"&&!Array.isArray(me)?me:null,ct=ke&&typeof ke.note=="string"?String(ke.note):"";return Sh(ct).trim()},[te]),be=m.useMemo(()=>{const me=te&&typeof te=="object"&&!Array.isArray(te)?te:null,ke=me&&Array.isArray(me.messages)?me.messages:null;return Array.isArray(ke)?ke:null},[te]),Fe=m.useMemo(()=>{const me=de,ke=Pe;return!me||!ke?!1:Od(me,ke)},[Pe,de]),Xe=m.useMemo(()=>{const me=be,ke=Pe;if(!me||!ke)return[];const ct=[];for(let it=0;it<Math.min(me.length,500);it++){const bt=me[it],zt=(bt==null?void 0:bt.content)==null?"":String(bt.content);Od(zt,ke)&&ct.push(it)}return ct},[Pe,be]),tt=m.useMemo(()=>new Set(Xe),[Xe]),ze=Xe.length?Xe[0]:null,Oe=m.useCallback(me=>{const ke=document.getElementById(`source_msg_${me}`);ke&&typeof ke.scrollIntoView=="function"&&ke.scrollIntoView({block:"center",behavior:"smooth"})},[]),lt=m.useCallback(()=>{const me=document.getElementById("source_note_hit_0")||document.getElementById("source_note_msg_hit_0");me&&typeof me.scrollIntoView=="function"&&me.scrollIntoView({block:"center",behavior:"smooth"})},[]);m.useEffect(()=>{if(_e&&!($e||U)&&!Qe.current){if(ze!==null){Qe.current=!0,window.setTimeout(()=>Oe(ze),0);return}if(Fe){Qe.current=!0,window.setTimeout(()=>lt(),0);return}}},[Oe,lt,U,ze,$e,Fe,_e]);const xe=m.useRef(new Set),Et=m.useRef(""),yt=m.useRef(null),sn=m.useRef(null);m.useEffect(()=>{l(String(t||"").trim())},[t]),m.useEffect(()=>{c(String(r||"").trim())},[r]);const ln=m.useMemo(()=>{const me=String(o||"").trim(),ke=String(u||"").trim();return`mindmap:${d}:${me}:${ke}`},[o,u,d]),Xt=m.useMemo(()=>{let me=null,ke=null;for(const ct of T){const it=dl(ct==null?void 0:ct.observed_at);it!==null&&(me=me===null?it:Math.min(me,it),ke=ke===null?it:Math.max(ke,it))}return{min_ms:me,max_ms:ke}},[T]),je=1e3,ue=m.useMemo(()=>{const me=Xt.min_ms,ke=Xt.max_ms;if(typeof me!="number"||typeof ke!="number"||!Number.isFinite(me)||!Number.isFinite(ke))return null;if(ke<=me)return{min_ms:me,max_ms:me,real_max_ms:ke};const ct=me+Math.ceil((ke-me)/je)*je;return{min_ms:me,max_ms:ct,real_max_ms:ke}},[Xt.max_ms,Xt.min_ms]),[Ne,$t]=m.useState(!0),[pt,qt]=m.useState(null);m.useEffect(()=>{Ne&&ue&&qt(ue.max_ms)},[Ne,ue]);const Dn=m.useMemo(()=>{const me=typeof pt=="number"?pt:null;return me===null?T:T.filter(ke=>{const ct=dl(ke==null?void 0:ke.observed_at);return ct===null?!0:ct<=me})},[T,pt]),nn=m.useCallback((me,ke)=>{const ct=Array.isArray(me)?me:[],it=String(Et.current||"").trim(),bt=new Set,zt=[];let Ut="";for(const Ot of ct){if(!Ot||typeof Ot!="object"||typeof Ot.subject!="string"||typeof Ot.predicate!="string"||typeof Ot.object!="string")continue;const pn=Og(Ot);if(bt.has(pn))continue;bt.add(pn),zt.push(Ot);const It=String(Ot.observed_at||"").trim();It&&(Ut=Fg(Ut,It))}M(zt),L(ke==null?void 0:ke.warnings),xe.current=bt,Et.current=Ut||it},[]),cn=m.useCallback(async me=>{const ke=vm(me.scope,"session"),ct=String(me.subject||"").trim(),it=String(me.predicate||"").trim(),bt=String(me.object||"").trim(),zt=String(me.since||"").trim(),Ut=String(me.until||"").trim(),Ot=String(me.active_at||"").trim(),pn=String(me.query_text||"").trim(),It=typeof me.min_score=="number"&&Number.isFinite(me.min_score)?Number(me.min_score):void 0,_n=me.order==="asc"?"asc":"desc",un=typeof me.limit=="number"&&Number.isFinite(me.limit)?Number(me.limit):0,Gt=String(o||"").trim(),Zt=String(u||"").trim(),Vt={scope:ke,all_owners:_,limit:un,order:_n};ct&&(Vt.subject=ct),it&&(Vt.predicate=it),bt&&(Vt.object=bt),zt&&(Vt.since=zt),Ut&&(Vt.until=Ut),Ot&&(Vt.active_at=Ot),pn&&(Vt.query_text=pn),typeof It=="number"&&(Vt.min_score=It),_||(ke==="run"?Gt&&(Vt.run_id=Gt):ke==="session"?Zt?Vt.session_id=Zt:Gt&&(Vt.run_id=Gt):ke==="all"&&(Gt?Vt.run_id=Gt:Zt&&(Vt.session_id=Zt)));try{const rt=await e.kg_query(Vt),jn=Array.isArray(rt==null?void 0:rt.items)?rt.items:[],Rn=rt==null?void 0:rt.warnings;return{ok:(rt==null?void 0:rt.ok)!==!1,count:Number((rt==null?void 0:rt.count)||jn.length),items:jn,warnings:Rn,raw:rt}}catch(rt){const jn=rt instanceof Error?rt.message:String(rt);if(jn.includes("Run '")&&jn.includes("not found")&&!Zt&&(ke==="session"||ke==="all")&&Gt){const kn=await e.kg_query({...Vt,run_id:void 0,session_id:Gt}),Nn=Array.isArray(kn==null?void 0:kn.items)?kn.items:[],ar=kn==null?void 0:kn.warnings;return{ok:(kn==null?void 0:kn.ok)!==!1,count:Number((kn==null?void 0:kn.count)||Nn.length),items:Nn,warnings:ar,raw:kn}}throw new Error(jn||"KG query failed")}},[_,e,o,u]),vn=m.useCallback(async me=>{var it;const ke=String(me.run_id||"").trim(),ct=String(me.span_id||"").trim();if(!(!ke||!ct)){Te(!0),K(!0),X(""),z(ke),N(ct),Z("artifact"),J(`source span:${ct}`),he(null),se(""),Re(me.assertion&&typeof me.assertion=="object"?me.assertion:null),Qe.current=!1;try{const bt=[ke],zt=typeof((it=me.assertion)==null?void 0:it.owner_id)=="string"?String(me.assertion.owner_id).trim():"";zt&&zt!==ke&&bt.push(zt);let Ut=null,Ot=null;for(const pn of bt)try{Ot=await(await e.download_run_artifact_content(pn,ct)).text(),pn!==ke&&z(pn);break}catch(It){Ut=It instanceof Error?It.message:String(It)}if(Ot==null)throw new Error(Ut||"Failed to load source span");se(Ot);try{const pn=JSON.parse(Ot);he(pn)}catch{he(null)}}catch(bt){const zt=bt instanceof Error?bt.message:String(bt);X(zt||"Failed to load source span")}finally{K(!1)}}},[e]),Sn=m.useCallback(async me=>{const ke=String(me.run_id||"").trim();if(!ke)return null;try{const ct=await e.list_run_artifacts(ke,{limit:200}),bt=(Array.isArray(ct==null?void 0:ct.items)?ct.items:[]).map(It=>{const _n=typeof(It==null?void 0:It.artifact_id)=="string"?String(It.artifact_id).trim():"",un=It!=null&&It.tags&&typeof It.tags=="object"&&!Array.isArray(It.tags)?It.tags:null,Gt=un&&typeof un.kind=="string"?String(un.kind).trim():"";return{artifact_id:_n,kind:Gt}}).filter(It=>!!(It.artifact_id&&(It.kind==="conversation_span"||It.kind==="memory_note")));if(!bt.length)return null;if(bt.length===1)return bt[0].artifact_id;const zt=me.assertion,Ut=zt!=null&&zt.attributes&&typeof zt.attributes=="object"&&!Array.isArray(zt.attributes)?zt.attributes:null,pn=(Ut&&typeof Ut.evidence_quote=="string"?String(Ut.evidence_quote):"").trim();if(!pn)return null;for(const It of bt.slice(0,10))try{const un=await(await e.download_run_artifact_content(ke,It.artifact_id)).text(),Gt=JSON.parse(un);if(Gt&&typeof Gt=="object"){const Zt=typeof Gt.note=="string"?String(Gt.note):"";if(Zt&&Zt.includes(pn))return It.artifact_id;const Vt=Array.isArray(Gt.messages)?Gt.messages:null;if(Vt){for(const rt of Vt.slice(0,200))if(((rt==null?void 0:rt.content)==null?"":String(rt.content)).includes(pn))return It.artifact_id}}}catch{}}catch{}return null},[e]),cr=m.useCallback(async me=>{const ke=String(me.run_id||"").trim();if(ke){Te(!0),K(!0),X(""),z(ke),N(""),Z("run_input"),J(`transcript run:${ke}`),he(null),se(""),Re(me.assertion&&typeof me.assertion=="object"?me.assertion:null),Qe.current=!1;try{const ct=await Sn({run_id:ke,assertion:me.assertion});if(ct){await vn({run_id:ke,span_id:ct,assertion:me.assertion});return}const it=await e.get_run_input_data(ke),bt=it&&typeof it=="object"&&!Array.isArray(it)?it.input_data:null,zt={kind:"run_input_data",run_id:ke};if(it&&typeof(it==null?void 0:it.workflow_id)=="string"&&(zt.workflow_id=String(it.workflow_id)),bt&&typeof bt=="object"&&!Array.isArray(bt)){const Ut=bt.context,pn=(Ut&&typeof Ut=="object"&&Array.isArray(Ut.messages)?Ut.messages:null)||(Array.isArray(bt.messages)?bt.messages:null);Array.isArray(pn)&&(zt.messages=pn);const It=["text","prompt","task","message"];for(const _n of It){const un=bt[_n];if(typeof un=="string"&&un.trim()){zt.note=un.trim();break}}zt.input_data=bt}!zt.messages&&!zt.note&&(zt.note=JSON.stringify(bt??it??{},null,2));try{const Ut=await e.get_run(ke),Ot=Ut&&typeof(Ut==null?void 0:Ut.created_at)=="string"?String(Ut.created_at):"";Ot&&(zt.created_at=Ot)}catch{}he(zt),se(JSON.stringify(it,null,2))}catch(ct){const it=ct instanceof Error?ct.message:String(ct);X(it||"Failed to load run input transcript")}finally{K(!1)}}},[e,vn,Sn]),Qt=m.useCallback(async()=>{G(""),Y(!0);try{const me=d==="all"?"all":d,ke=await cn({scope:me,limit:0,order:"desc"});nn(ke.items||[],{warnings:ke.warnings}),yt.current={scope:me}}catch(me){const ke=me instanceof Error?me.message:String(me);G(ke||"Load failed")}finally{Y(!1)}},[cn,nn,d]);m.useEffect(()=>{T.length||Qt()},[]);const Zn=m.useCallback(async me=>{const ke=vm(me.scope,"session");return sn.current=me,await cn({scope:ke,subject:me.subject,predicate:me.predicate,object:me.object,query_text:me.query_text,min_score:me.min_score,since:me.since,until:me.until,active_at:me.active_at,limit:typeof me.limit=="number"?me.limit:0,order:"desc"})},[cn]),ls=m.useCallback((me,ke)=>{var ct;if((ke==null?void 0:ke.kind)==="live query"){const it=sn.current;it&&(yt.current={scope:vm(it.scope,"session"),subject:typeof it.subject=="string"?it.subject:void 0,predicate:typeof it.predicate=="string"?it.predicate:void 0,object:typeof it.object=="string"?it.object:void 0})}nn(me,{warnings:(ct=ke==null?void 0:ke.result)==null?void 0:ct.warnings})},[nn]),Un=m.useCallback(async()=>{const me=yt.current;if(!me)return;const ke=String(Et.current||"").trim(),ct=await cn({scope:me.scope,subject:me.subject,predicate:me.predicate,object:me.object,since:ke||void 0,order:"asc",limit:0}),it=Array.isArray(ct.items)?ct.items:[];if(!it.length)return;const zt=Date.now()+Math.max(250,Math.min(2e4,j)),Ut=xe.current,Ot=[],pn=[];let It=String(Et.current||"").trim();for(const _n of it){if(!_n||typeof _n!="object"||typeof _n.subject!="string"||typeof _n.predicate!="string"||typeof _n.object!="string")continue;const un=Og(_n);if(Ut.has(un))continue;Ut.add(un),Ot.push(_n),pn.push({id:un,assertion:_n,expires_at_ms:zt});const Gt=String(_n.observed_at||"").trim();Gt&&(It=Fg(It,Gt))}Ot.length&&(Et.current=It,M(_n=>{const un=_n.concat(Ot);return un.sort((Gt,Zt)=>String((Zt==null?void 0:Zt.observed_at)||"").localeCompare(String((Gt==null?void 0:Gt.observed_at)||""))),un}),le(_n=>{const un=_n.concat(pn);return un.sort((Gt,Zt)=>Zt.expires_at_ms-Gt.expires_at_ms),un.slice(0,30)}))},[j,cn]);return m.useEffect(()=>{if(!g)return;let me=!1,ke=null;const ct=async()=>{if(!me){try{await Un()}catch{}me||(ke=window.setTimeout(()=>void ct(),Math.max(250,Math.min(6e4,v))))}};return ct(),()=>{me=!0,ke!==null&&window.clearTimeout(ke)}},[g,v,Un]),m.useEffect(()=>{if(!oe.length)return;const me=window.setInterval(()=>{const ke=Date.now();le(ct=>ct.filter(it=>it.expires_at_ms>ke))},250);return()=>window.clearInterval(me)},[oe.length]),s.jsxs("div",{className:"mindmap_root",children:[s.jsxs("div",{className:"mindmap_bar",children:[s.jsx("button",{className:"btn",onClick:()=>void Qt(),disabled:ne,children:ne?"Loading…":"Load snapshot"}),s.jsxs("label",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",children:"source"}),s.jsxs("select",{value:d,onChange:me=>{const ke=String(me.target.value||"").trim();(ke==="all"||ke==="global"||ke==="session"||ke==="run")&&h(ke)},children:[s.jsx("option",{value:"all",children:"all memory"}),s.jsx("option",{value:"global",children:"global"}),s.jsx("option",{value:"session",children:"session"}),s.jsx("option",{value:"run",children:"run"})]})]}),s.jsxs("label",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",children:"live"}),s.jsx("input",{type:"checkbox",checked:g,onChange:me=>x(!!me.target.checked)})]}),d==="session"?s.jsxs("label",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",children:"session_id"}),s.jsx("input",{className:"mono",value:u,onChange:me=>c(String(me.target.value||"")),placeholder:"(required)"})]}):null,d==="run"?s.jsxs("label",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",children:"run_id"}),s.jsx("input",{className:"mono",value:o,onChange:me=>l(String(me.target.value||"")),placeholder:"(required)"})]}):null,s.jsxs("details",{className:"mindmap_details",children:[s.jsx("summary",{className:"mono muted",children:"advanced"}),s.jsx("div",{className:"mindmap_advanced",children:s.jsxs("div",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",style:{width:84},children:"poll_ms"}),s.jsx("input",{type:"number",min:250,max:6e4,step:50,value:v,onChange:me=>b(Math.max(250,Number(me.target.value||0)||750))}),s.jsx("span",{className:"mono muted",children:"highlight_ms"}),s.jsx("input",{type:"number",min:250,max:2e4,step:250,value:j,onChange:me=>S(Math.max(250,Number(me.target.value||0)||5e3))})]})})]})]}),I?s.jsx("div",{className:"mindmap_error mono",children:I}):null,s.jsxs("div",{className:"mindmap_explorer",children:[s.jsx(XN,{title:"mindmap",resetKey:ln,queryMode:"replace",items:Dn,warnings:D,onQuery:Zn,onItemsReplace:ls,onOpenSpan:({run_id:me,span_id:ke,assertion:ct})=>{vn({run_id:me,span_id:ke,assertion:ct})},onOpenTranscript:({run_id:me,span_id:ke,assertion:ct})=>{const it=String(me||"").trim(),bt=typeof ke=="string"?String(ke).trim():"";it&&(bt?vn({run_id:it,span_id:bt,assertion:ct}):cr({run_id:it,assertion:ct}))}},ln),oe.length?s.jsxs("div",{className:"mindmap_recent mindmap_overlay mindmap_overlay_recent",children:[s.jsx("div",{className:"mindmap_recent_title mono muted",children:"new assertions"}),s.jsx("div",{className:"mindmap_recent_list",children:oe.slice().sort((me,ke)=>ke.expires_at_ms-me.expires_at_ms).slice(0,12).map(me=>s.jsx("div",{className:"mindmap_recent_item mono",children:QN(me.assertion)},me.id))})]}):null,ue?s.jsx("div",{className:"mindmap_timeline mindmap_overlay mindmap_overlay_timeline",children:s.jsxs("div",{className:"mindmap_timeline_row",children:[s.jsx("div",{className:"mindmap_timeline_label mono muted",children:Gl(Math.min(typeof pt=="number"?pt:ue.max_ms,ue.real_max_ms))}),s.jsx("input",{className:"mindmap_slider",type:"range",min:ue.min_ms,max:ue.max_ms,step:je,value:typeof pt=="number"?pt:ue.max_ms,onChange:me=>{const ke=Number(me.target.value||0);qt(ke),$t(ke>=ue.max_ms)}}),s.jsxs("div",{className:"mindmap_timeline_counts mono muted",children:[Dn.length.toLocaleString(),"/",T.length.toLocaleString()]})]})}):null]}),s.jsxs(Mi,{open:_e,title:V||"source",onClose:()=>{Te(!1)},children:[$e?s.jsx("div",{className:"mono muted",children:"Loading…"}):null,U?s.jsx("div",{className:"mindmap_error mono",children:U}):null,!$e&&!U?s.jsxs("div",{className:"source_span",children:[(()=>{const me=ve;if(!me)return null;const ke=String(me.subject||"").trim(),ct=String(me.predicate||"").trim(),it=String(me.object||"").trim(),bt=Gl(dl(me.observed_at)),zt=me.attributes&&typeof me.attributes=="object"&&!Array.isArray(me.attributes)?me.attributes:null,Ut=zt&&typeof zt.evidence_quote=="string"?String(zt.evidence_quote):"",Ot=zt&&typeof zt.original_context=="string"?String(zt.original_context):"";return s.jsxs("div",{className:"source_header",children:[s.jsxs("div",{className:"mono source_triple",title:`${ke} --${ct}--> ${it}`,children:[ke," ",s.jsxs("span",{className:"muted",children:["—",ct,"→"]})," ",it," ",bt?s.jsxs("span",{className:"muted",children:["[",bt,"]"]}):null]}),Ut?s.jsxs("div",{className:"source_evidence",children:[s.jsx("div",{className:"mono muted",style:{fontSize:11,marginBottom:6},children:"evidence_quote"}),s.jsx("pre",{className:"mono source_evidence_quote",children:Ut}),Ot?s.jsxs("details",{className:"source_evidence_more",children:[s.jsx("summary",{className:"mono muted",children:"original_context"}),s.jsx("pre",{className:"mono source_evidence_quote",children:Ot})]}):null]}):null]})})(),s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:["run_id=",k," · ",B==="artifact"?`span_id=${F}`:"source=input_data"]}),s.jsxs("div",{className:"source_actions",children:[ze!==null?s.jsx("button",{className:"btn",onClick:()=>Oe(ze),children:"Jump to evidence"}):null,ze===null&&Fe?s.jsx("button",{className:"btn",onClick:()=>lt(),children:"Jump to evidence"}):null]}),(()=>{const me=te,ke=me&&typeof me=="object"&&!Array.isArray(me)?me:null,ct=be,it=de,bt=ke&&typeof ke.created_at=="string"?String(ke.created_at):"",zt=bt?dl(bt):null,Ut=zt!==null?Gl(zt):bt,Ot=ke&&ke.span&&typeof ke.span=="object"&&!Array.isArray(ke.span)?ke.span:null,pn=Ot&&typeof Ot.from_timestamp=="string"?String(Ot.from_timestamp):"",It=Ot&&typeof Ot.to_timestamp=="string"?String(Ot.to_timestamp):"",_n=pn?dl(pn):null,un=It?dl(It):null,Gt=_n!==null&&un!==null?`${Gl(_n)} → ${Gl(un)}`:"";if(it){const Zt=JN(it);if(Zt){const Vt=Pe,rt=Vt?Zt.messages.findIndex(Nn=>Od(Nn.content,Vt)):-1,jn=Vt?Ig(Vt):[],Rn=Zt.created_at||bt,kn=Rn?KN(Rn):bt?Ut:"";return s.jsx("div",{className:"source_chat",children:Zt.messages.map((Nn,ar)=>{const Ir=Nn.role,Sr=!!(Vt&&Od(Nn.content,Vt)),Fr=Ir==="user"?"USER":Ir==="assistant"?"ASSISTANT":"SYSTEM";return s.jsxs("div",{id:ar===rt?"source_note_msg_hit_0":void 0,className:`source_msg source_${Ir} ${Sr?"source_match":""}`,children:[s.jsxs("div",{className:"source_msg_meta mono muted",children:[s.jsxs("span",{children:["#",ar+1," · ",Fr,Sr?s.jsx("span",{className:"source_match_badge",children:"evidence"}):null]}),kn?s.jsx("span",{title:Rn||"",children:kn}):null]}),s.jsx("div",{className:"source_msg_body",children:s.jsx(ao,{text:Nn.content,highlights:Sr&&jn.length?jn:void 0,highlightClassName:"source_note_hit",highlightId:ar===rt?"source_note_hit_0":void 0})})]},`note_msg:${ar}`)})})}return s.jsxs("div",{className:"source_note",children:[bt?s.jsx("div",{className:"mono muted",style:{marginBottom:10},children:s.jsxs("span",{title:bt,children:["created_at=",Ut]})}):null,s.jsx(ao,{text:it,highlights:Pe?Ig(Pe):void 0,highlightClassName:"source_note_hit",highlightId:"source_note_hit_0"})]})}if(ct){const Zt=new Map;for(const rt of ct){const jn=typeof(rt==null?void 0:rt.role)=="string"?String(rt.role):"unknown";Zt.set(jn,(Zt.get(jn)||0)+1)}const Vt=Array.from(Zt.entries()).sort((rt,jn)=>jn[1]-rt[1]||rt[0].localeCompare(jn[0])).map(([rt,jn])=>`${rt}×${jn}`).join(" · ");return s.jsxs("div",{className:"source_chat",children:[bt?s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:[s.jsxs("span",{title:bt,children:["created_at=",Ut]})," · messages=",ct.length]}):null,Gt?s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:["span=",Gt]}):null,Vt?s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:["participants: ",Vt]}):null,ct.slice(0,200).map((rt,jn)=>{var Ws,Es;const Rn=typeof(rt==null?void 0:rt.role)=="string"?String(rt.role):"unknown",kn=(rt==null?void 0:rt.content)==null?"":String(rt.content),Nn=typeof(rt==null?void 0:rt.timestamp)=="string"?String(rt.timestamp):"",ar=Nn?dl(Nn):null,Ir=ar!==null?Gl(ar):Nn,Sr=typeof(rt==null?void 0:rt.message_id)=="string"?String(rt.message_id):typeof((Ws=rt==null?void 0:rt.metadata)==null?void 0:Ws.message_id)=="string"?String(rt.metadata.message_id):typeof((Es=rt==null?void 0:rt.metadata)==null?void 0:Es.id)=="string"?String(rt.metadata.id):"",Fr=tt.has(jn);return s.jsxs("div",{id:`source_msg_${jn}`,className:`source_msg source_${Rn} ${Fr?"source_match":""}`,children:[s.jsxs("div",{className:"source_msg_meta mono muted",children:[s.jsxs("span",{children:["#",jn+1," · ",Rn,Fr?s.jsx("span",{className:"source_match_badge",children:"evidence"}):null,Sr?s.jsx("span",{className:"source_msg_id",children:Sr}):null]}),Nn?s.jsx("span",{title:Nn,children:Ir}):null]}),s.jsx("div",{className:"source_msg_body",children:s.jsx(ao,{text:kn})})]},jn)})]})}return s.jsx("pre",{className:"mono source_raw",style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:(typeof me=="string"?me:Ae)||"(empty)"})})()]}):null]})]})}function wm(e,t){const r=String(e||"");return r.length<=t?r:`${r.slice(0,Math.max(0,t-1))}…`}function e1(e){const t=String(e||"").trim().toLowerCase();return t==="running"?{cls:"ok",label:"running"}:t==="stopped"?{cls:"muted",label:"stopped"}:t.includes("restart")?{cls:"warn",label:t}:t.includes("error")||t.includes("failed")?{cls:"danger",label:t||"error"}:{cls:"warn",label:t||"unknown"}}function Dg(e){const t=r=>{const o=String((r==null?void 0:r.id)||"").trim(),l=o.endsWith("_uat")?o.slice(0,-4):o;return l==="gateway"?0:l==="build"?1:l==="abstractobserver"?2:l==="abstractcode_web"?3:l==="abstractflow_backend"?4:l==="abstractflow_frontend"?5:10};return[...e||[]].sort((r,o)=>{const l=t(r),u=t(o);if(l!==u)return l-u;const c=String((r==null?void 0:r.label)||(r==null?void 0:r.id)||"").toLowerCase(),d=String((o==null?void 0:o.label)||(o==null?void 0:o.id)||"").toLowerCase();return c<d?-1:c>d?1:0})}function t1(e){const t=String(e||"").trim().toLowerCase();return t==="override"?{cls:"ok",label:"override"}:t.startsWith("inherited")?{cls:"info",label:t}:t==="unset"?{cls:"warn",label:"unset"}:!t||t==="missing"?{cls:"muted",label:"missing"}:{cls:"muted",label:t}}function n1({gateway:e,gateway_connected:t}){const[r,o]=m.useState("prod"),[l,u]=m.useState(null),[c,d]=m.useState([]),[h,_]=m.useState(!1),[g,x]=m.useState(""),[v,b]=m.useState(!1),[j,S]=m.useState(null),[T,M]=m.useState([]),[D,L]=m.useState(!1),[I,G]=m.useState(""),[ne,Y]=m.useState({}),[oe,le]=m.useState(!1),[_e,Te]=m.useState(null),[$e,K]=m.useState(""),[U,X]=m.useState(""),[V,J]=m.useState(!1),k=m.useRef(null),z=m.useMemo(()=>Dg(c.filter(de=>!String((de==null?void 0:de.id)||"").trim().endsWith("_uat"))),[c]),F=m.useMemo(()=>Dg(c.filter(de=>String((de==null?void 0:de.id)||"").trim().endsWith("_uat"))),[c]),N=r==="uat"?F:z,B=m.useCallback(async()=>{if(t){_(!0),x("");try{const de=await e.list_processes();u(!!(de!=null&&de.enabled));const be=Array.isArray(de==null?void 0:de.processes)?de.processes:[];d(be)}catch(de){x(String((de==null?void 0:de.message)||de||"Failed to list processes"))}finally{_(!1)}}},[e,t]),Z=m.useCallback(async()=>{if(t){L(!0),G("");try{const de=await e.list_process_env_vars();S(!!(de!=null&&de.enabled));const be=Array.isArray(de==null?void 0:de.vars)?de.vars:[];M(be);const Fe=String((de==null?void 0:de.error)||"").trim();Fe&&G(Fe)}catch(de){G(String((de==null?void 0:de.message)||de||"Failed to list env vars"))}finally{L(!1)}}},[e,t]),te=m.useCallback(async()=>{if(!t)return;const de=_e;if(de){J(!0);try{const be=await e.process_log_tail(String(de.id||""),{max_bytes:16e4}),Fe=String((be==null?void 0:be.content)||""),Xe=typeof(be==null?void 0:be.bytes)=="number"?Number(be.bytes):0,tt=!!(be!=null&&be.truncated),ze=String((be==null?void 0:be.log_relpath)||"");K(Fe),X(`${Xe.toLocaleString()} bytes${tt?" (tail)":""}${ze?` • ${ze}`:""}`)}catch(be){K(""),X(""),x(String((be==null?void 0:be.message)||be||"Failed to read logs"))}finally{J(!1)}}},[e,t,_e]),he=m.useCallback(async de=>{Te(de),le(!0)},[]),Ae=m.useCallback(()=>{le(!1),Te(null),K(""),X("")},[]);m.useEffect(()=>{t&&B()},[t,B]),m.useEffect(()=>{if(!t||r==="env"||!v)return;const de=window.setInterval(()=>void B(),2e3);return()=>window.clearInterval(de)},[t,r,v,B]),m.useEffect(()=>{t&&r==="env"&&Z()},[t,r,Z]),m.useEffect(()=>{if(t&&oe)return te(),k.current&&window.clearInterval(k.current),k.current=window.setInterval(()=>void te(),1500),()=>{k.current&&window.clearInterval(k.current),k.current=null}},[t,oe,te]);async function se(de,be){x("");try{be==="start"?await e.start_process(de.id):be==="stop"?await e.stop_process(de.id):be==="restart"?await e.restart_process(de.id):be==="redeploy"&&await e.redeploy_process(de.id),await B()}catch(Fe){x(String((Fe==null?void 0:Fe.message)||Fe||`Failed to ${be}`))}}async function ve(de){const be=String(de||"").trim();if(be){G("");try{const Fe=String((ne==null?void 0:ne[be])??""),Xe=await e.update_process_env_vars({set:{[be]:Fe}});S(!!(Xe!=null&&Xe.enabled)),M(Array.isArray(Xe==null?void 0:Xe.vars)?Xe.vars:[]),Y(ze=>({...ze||{},[be]:""}));const tt=String((Xe==null?void 0:Xe.error)||"").trim();tt&&G(tt)}catch(Fe){G(String((Fe==null?void 0:Fe.message)||Fe||"Failed to set env var"))}}}async function Re(de){const be=String(de||"").trim();if(be){G("");try{const Fe=await e.update_process_env_vars({unset:[be]});S(!!(Fe!=null&&Fe.enabled)),M(Array.isArray(Fe==null?void 0:Fe.vars)?Fe.vars:[]),Y(tt=>({...tt||{},[be]:""}));const Xe=String((Fe==null?void 0:Fe.error)||"").trim();Xe&&G(Xe)}catch(Fe){G(String((Fe==null?void 0:Fe.message)||Fe||"Failed to unset env var"))}}}const Qe=l===null?"…":l?"enabled":"disabled",Pe=j===null?"…":j?"enabled":"disabled";return s.jsx("div",{className:"page page_scroll",children:s.jsxs("div",{className:"page_inner constrained",children:[s.jsxs("div",{className:"card",children:[s.jsxs("div",{className:"title",children:[s.jsx("h1",{children:"Process manager"}),s.jsxs("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",marginTop:"10px"},children:[s.jsx("button",{className:`nav_tab ${r==="prod"?"active":""}`,onClick:()=>o("prod"),children:"Production"}),s.jsx("button",{className:`nav_tab ${r==="uat"?"active":""}`,onClick:()=>o("uat"),children:"UAT"}),s.jsx("button",{className:`nav_tab ${r==="env"?"active":""}`,onClick:()=>o("env"),children:"ENV"})]})]}),t?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mono muted",style:{marginTop:"6px"},children:["Process manager: ",Qe]}),r!=="env"&&l===!1?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(148, 163, 184, 0.25)",marginTop:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"hint"}),s.jsx("span",{className:"mono",children:"server"})]}),s.jsxs("div",{className:"body mono",children:["To manage processes, set ",s.jsx("span",{className:"mono",children:"ABSTRACTGATEWAY_ENABLE_PROCESS_MANAGER=1"})," and"," ",s.jsx("span",{className:"mono",children:"ABSTRACTGATEWAY_TRIAGE_REPO_ROOT"})," (your AbstractFramework checkout root) on the gateway host."]})]}):null,r!=="env"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"actions",style:{marginTop:"10px"},children:[s.jsxs("button",{className:`btn btn_icon ${h?"is_loading":""}`,onClick:()=>void B(),disabled:!t||h,children:[s.jsx(On,{name:"refresh",size:16}),h?"Refreshing…":"Refresh"]}),s.jsxs("label",{className:"btn",style:{display:"inline-flex",alignItems:"center",gap:"8px"},children:[s.jsx("input",{type:"checkbox",checked:v,onChange:de=>b(!!de.target.checked)}),"auto"]})]}),g?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)",marginTop:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"error"}),s.jsx("span",{className:"mono",children:"processes"})]}),s.jsx("div",{className:"body mono",children:g})]}):null,s.jsx("div",{style:{marginTop:"12px"},children:N.map(de=>{const be=String(de.id||"").trim(),Fe=String(de.label||be).trim()||be,Xe=e1(String(de.status||"")),ze=String(de.status||"").trim().toLowerCase()==="running",Oe=Array.isArray(de==null?void 0:de.actions)?de.actions.map(qt=>String(qt||"").trim()):[],lt=Oe.includes("start"),xe=Oe.includes("stop"),Et=Oe.includes("restart"),yt=Oe.includes("redeploy"),sn=Oe.includes("logs"),ln=typeof(de==null?void 0:de.pid)=="number"?Number(de.pid):null,Xt=String((de==null?void 0:de.url)||"").trim(),je=String((de==null?void 0:de.description)||"").trim(),ue=String((de==null?void 0:de.last_error)||"").trim(),Ne=typeof(de==null?void 0:de.exit_code)=="number"?Number(de.exit_code):null,$t=[];ln&&$t.push(`pid ${ln}`),Ne!==null&&$t.push(`exit ${Ne}`);const pt=$t.join(" • ");return s.jsxs("div",{className:"log_item",style:{marginBottom:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:be}),s.jsx("span",{className:`tag ${Xe.cls}`,children:Xe.label})]}),s.jsxs("div",{className:"body",children:[s.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"10px",flexWrap:"wrap"},children:s.jsxs("div",{children:[s.jsx("div",{style:{fontWeight:700},children:Fe}),je?s.jsx("div",{className:"mono muted",style:{marginTop:"4px"},children:wm(je,220)}):null,pt?s.jsx("div",{className:"mono muted",style:{marginTop:"6px",fontSize:"var(--font-size-sm)"},children:pt}):null,Xt?s.jsx("div",{className:"mono muted",style:{marginTop:pt?"4px":"6px",fontSize:"var(--font-size-sm)"},children:ze?s.jsx("a",{href:Xt,target:"_blank",rel:"noreferrer",className:"mono",style:{opacity:.95},children:Xt}):s.jsx("span",{className:"mono",children:Xt})}):null]})}),ue?s.jsx("div",{className:"mono",style:{marginTop:"8px",color:"var(--error)"},children:wm(ue,360)}):null,s.jsxs("div",{className:"actions",style:{marginTop:"10px"},children:[lt?s.jsx("button",{className:"btn primary",onClick:()=>void se(de,"start"),disabled:h,children:"Start"}):null,xe?s.jsx("button",{className:"btn danger",onClick:()=>void se(de,"stop"),disabled:h,children:"Stop"}):null,Et?s.jsx("button",{className:"btn",onClick:()=>void se(de,"restart"),disabled:h,children:"Restart"}):null,yt?s.jsx("button",{className:"btn",onClick:()=>void se(de,"redeploy"),disabled:h,children:"Redeploy"}):null,sn?s.jsx("button",{className:"btn",onClick:()=>void he(de),disabled:h,children:"Logs"}):null]})]})]},be)})})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Write-only: the gateway will never return env var values to the browser. Use this for integration config (email, notifications, …)."}),s.jsxs("div",{className:"mono muted",style:{marginTop:"6px"},children:["Env vars: ",Pe]}),j===!1?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(148, 163, 184, 0.25)",marginTop:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"hint"}),s.jsx("span",{className:"mono",children:"server"})]}),s.jsxs("div",{className:"body mono",children:["Set ",s.jsx("span",{className:"mono",children:"ABSTRACTGATEWAY_ENABLE_PROCESS_MANAGER=1"})," on the gateway host."]})]}):null,s.jsx("div",{className:"actions",style:{marginTop:"10px"},children:s.jsxs("button",{className:`btn btn_icon ${D?"is_loading":""}`,onClick:()=>void Z(),disabled:!t||D,children:[s.jsx(On,{name:"refresh",size:16}),D?"Refreshing…":"Refresh"]})}),I?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)",marginTop:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"error"}),s.jsx("span",{className:"mono",children:"env"})]}),s.jsx("div",{className:"body mono",children:I})]}):null,s.jsxs("div",{style:{marginTop:"12px"},children:[T.map(de=>{const be=String((de==null?void 0:de.key)||"").trim();if(!be)return null;const Fe=String((de==null?void 0:de.label)||be).trim()||be,Xe=String((de==null?void 0:de.description)||"").trim(),tt=String((de==null?void 0:de.source)||"").trim(),ze=!!(de!=null&&de.secret),Oe=String((de==null?void 0:de.updated_at)||"").trim(),lt=t1(tt),xe=String((ne==null?void 0:ne[be])??"");return s.jsxs("div",{className:"log_item",style:{marginBottom:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:be}),s.jsx("span",{className:`chip mono ${lt.cls}`,children:lt.label})]}),s.jsxs("div",{className:"body",children:[s.jsx("div",{style:{fontWeight:700},children:Fe}),Xe?s.jsx("div",{className:"mono muted",style:{marginTop:"4px"},children:wm(Xe,280)}):null,Oe?s.jsxs("div",{className:"mono muted",style:{marginTop:"6px",fontSize:"var(--font-size-sm)"},children:["updated ",Oe]}):null,s.jsxs("div",{className:"actions",style:{marginTop:"10px",alignItems:"center"},children:[s.jsx("input",{className:"input",value:xe,onChange:Et=>Y(yt=>({...yt||{},[be]:String(Et.target.value||"")})),placeholder:ze?"••••••••":"value",type:ze?"password":"text",style:{flex:"1 1 320px",minWidth:"220px"},autoComplete:"off",spellCheck:!1}),s.jsx("button",{className:"btn primary",onClick:()=>void ve(be),disabled:D,children:"Set"}),s.jsx("button",{className:"btn",onClick:()=>void Re(be),disabled:D,children:"Unset"})]})]})]},`env:${be}`)}),T.length?null:s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No env vars available (process manager must be enabled)."})]})]})]}):s.jsxs("div",{className:"mono muted",children:["Not connected. Open"," ",s.jsx("span",{className:"mono",style:{opacity:.9},children:"Settings"})," ","to connect to a gateway."]})]}),oe&&_e?s.jsxs(Mi,{open:oe,title:`${String(_e.label||_e.id||"logs").trim()||"Logs"}`,onClose:Ae,children:[s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:U}),s.jsxs("div",{className:"actions",style:{marginTop:"10px"},children:[s.jsxs("button",{className:`btn btn_icon ${V?"is_loading":""}`,onClick:()=>void te(),disabled:V,children:[s.jsx(On,{name:"refresh",size:16}),V?"Refreshing…":"Refresh"]}),s.jsxs("button",{className:"btn btn_icon",onClick:()=>{try{navigator.clipboard.writeText($e||"")}catch{}},disabled:!$e,children:[s.jsx(On,{name:"copy",size:16}),"Copy"]})]}),s.jsx("pre",{className:"mono",style:{marginTop:"10px",padding:"10px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.12)",background:"rgba(0,0,0,0.22)",overflowX:"auto",maxHeight:"55vh",whiteSpace:"pre-wrap"},children:$e||"(no logs yet)"})]}):null]})})}function Bg(e){const t=String(e||"").trim();if(!t)return"";const r=Date.parse(t);return Number.isFinite(r)?new Date(r).toLocaleString():t}function Mu(e,t){const r=String(e||"");return r.length<=t?r:`${r.slice(0,Math.max(0,t-1))}…`}function bm(e){const t=String(e||"").split(/[,\n]/g).map(r=>r.trim()).filter(Boolean);return t.length<=1?t[0]||"":t}function r1(e){const t=e.gateway,[r,o]=m.useState([]),[l,u]=m.useState(""),[c,d]=m.useState(""),[h,_]=m.useState(""),[g,x]=m.useState("7d"),[v,b]=m.useState("unread"),[j,S]=m.useState(25),[T,M]=m.useState(!1),[D,L]=m.useState(!1),[I,G]=m.useState(!1),[ne,Y]=m.useState(!1),[oe,le]=m.useState(""),[_e,Te]=m.useState(""),[$e,K]=m.useState(""),[U,X]=m.useState([]),[V,J]=m.useState(""),[k,z]=m.useState(null),[F,N]=m.useState(!1),[B,Z]=m.useState(""),[te,he]=m.useState(""),[Ae,se]=m.useState(""),[ve,Re]=m.useState(""),[Qe,Pe]=m.useState(""),de=e.enabled,be=m.useMemo(()=>(Array.isArray(r)?r:[]).map(Ne=>({account:String((Ne==null?void 0:Ne.account)||"").trim(),can_read:(Ne==null?void 0:Ne.can_read)!==!1,can_send:(Ne==null?void 0:Ne.can_send)!==!1,label:""})).filter(Ne=>!!Ne.account),[r]),Fe=m.useMemo(()=>{const ue=String(c||"").trim();return ue&&be.find(Ne=>Ne.account===ue)||null},[be,c]),Xe=!!(Fe!=null&&Fe.can_read),tt=!!(Fe!=null&&Fe.can_send),ze=m.useMemo(()=>be.map(ue=>{const Ne=ue.can_read?ue.can_send?"":" (read-only)":" (send-only)";return{...ue,label:`${ue.account}${Ne}`}}),[be]);async function Oe(){if(de){le(""),M(!0);try{const ue=await t.email_list_accounts();o(Array.isArray(ue==null?void 0:ue.accounts)?ue.accounts:[]),u(String((ue==null?void 0:ue.default_account)||"").trim())}catch(ue){le(String((ue==null?void 0:ue.message)||ue||"Failed to list email accounts")),o([]),u("")}finally{M(!1)}}}m.useEffect(()=>{Oe()},[de]),m.useEffect(()=>{if(!de)return;const ue=String(c||"").trim();if(ue&&be.some($t=>$t.account===ue))return;const Ne=String(localStorage.getItem("abstractobserver_email_account")||"").trim();if(Ne&&be.some($t=>$t.account===Ne)){d(Ne);return}if(l&&be.some($t=>$t.account===l)){d(l);return}be.length&&d(be[0].account)},[de,c,l,be]),m.useEffect(()=>{const ue=String(c||"").trim();ue&&localStorage.setItem("abstractobserver_email_account",ue)},[c]);async function lt(){if(!de)return;const ue=String(c||"").trim();if(ue){if(!Xe){le("Selected account is not allowed to read email."),X([]),J(""),z(null);return}le(""),L(!0);try{const Ne=await t.email_list_messages({account:ue,mailbox:String(h||"").trim()||void 0,since:String(g||"").trim()||void 0,status:v,limit:j});X(Array.isArray(Ne==null?void 0:Ne.messages)?Ne.messages:[]),String(V||"").trim()&&!Array.isArray(Ne==null?void 0:Ne.messages)&&(J(""),z(null))}catch(Ne){le(String((Ne==null?void 0:Ne.message)||Ne||"Failed to list emails")),X([]),J(""),z(null)}finally{L(!1)}}}m.useEffect(()=>{de&&String(c||"").trim()&<()},[de,c]);async function xe(ue){if(!de)return;const Ne=String(c||"").trim(),$t=String(ue||"").trim();if(!(!Ne||!$t)&&Xe){J($t),z(null),Te(""),G(!0);try{const pt=await t.email_read_message($t,{account:Ne,mailbox:String(h||"").trim()||void 0,max_body_chars:2e4});z(pt)}catch(pt){Te(String((pt==null?void 0:pt.message)||pt||"Failed to read email"))}finally{G(!1)}}}function Et(ue){K(""),Z(String((ue==null?void 0:ue.to)||"").trim()),he(""),se(""),Re(String((ue==null?void 0:ue.subject)||"").trim()),Pe(String((ue==null?void 0:ue.body)||"")),N(!0)}function yt(){if(!k)return;const ue=String((k==null?void 0:k.from)||"").trim(),Ne=String((k==null?void 0:k.subject)||"").trim(),$t=Ne.toLowerCase().startsWith("re:")?Ne:`Re: ${Ne||"(no subject)"}`,pt=String((k==null?void 0:k.body_text)||"").trim(),qt=`
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
On ${Bg((k==null?void 0:k.date)||"")}, ${ue} wrote:
|
|
129
|
+
|
|
130
|
+
${pt}`;Et({to:ue,subject:$t,body:qt})}async function sn(){if(!de||ne)return;const ue=String(c||"").trim();if(ue){if(!tt){K("Selected account is not allowed to send email.");return}K(""),Y(!0);try{const Ne=bm(B);if(!Ne)throw new Error("to is required");const $t=String(ve||"").trim();if(!$t)throw new Error("subject is required");const pt=String(Qe||"").trim();if(!pt)throw new Error("body is required");await t.email_send({account:ue,to:Ne,subject:$t,body_text:pt,cc:bm(te),bcc:bm(Ae)}),N(!1),Z(""),he(""),se(""),Re(""),Pe(""),await lt()}catch(Ne){K(String((Ne==null?void 0:Ne.message)||Ne||"Failed to send email"))}finally{Y(!1)}}}const ln=m.useMemo(()=>{const ue=String(V||"").trim();return ue&&U.find(Ne=>String((Ne==null?void 0:Ne.uid)||"").trim()===ue)||null},[U,V]),Xt=String((k==null?void 0:k.body_text)||"").trim()||String((k==null?void 0:k.body_html)||"").trim(),je=String((k==null?void 0:k.body_text)||"").trim()?"Body (text)":String((k==null?void 0:k.body_html)||"").trim()?"Body (html, raw)":"Body";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"inbox_layout",children:[s.jsxs("div",{className:"card inbox_sidebar",children:[s.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between"},children:[s.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center"},children:[s.jsx("select",{value:c,onChange:ue=>d(String(ue.target.value||"")),disabled:!de||T,children:ze.length?ze.map(ue=>s.jsx("option",{value:ue.account,children:ue.label},ue.account)):s.jsx("option",{value:"",children:"(no accounts)"})}),s.jsx("button",{className:"btn",onClick:()=>void Oe(),disabled:!de||T,children:T?"Loading…":"Accounts"})]}),s.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[s.jsx("button",{className:"btn",onClick:()=>void lt(),disabled:!de||D||!String(c||"").trim()||!Xe,children:D?"Refreshing…":"Refresh"}),s.jsx("button",{className:"btn primary",onClick:()=>Et(),disabled:!de||!String(c||"").trim()||!tt,children:"Compose"})]})]}),s.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center",flexWrap:"wrap"},children:[s.jsxs("div",{className:"field",style:{margin:0,minWidth:120,flex:"1 1 120px"},children:[s.jsx("label",{children:"Since"}),s.jsx("input",{value:g,onChange:ue=>x(String(ue.target.value||"")),placeholder:"7d"})]}),s.jsxs("div",{className:"field",style:{margin:0,minWidth:120,flex:"0 0 120px"},children:[s.jsx("label",{children:"Status"}),s.jsxs("select",{value:v,onChange:ue=>b(String(ue.target.value||"all")),children:[s.jsx("option",{value:"all",children:"all"}),s.jsx("option",{value:"unread",children:"unread"}),s.jsx("option",{value:"read",children:"read"})]})]}),s.jsxs("div",{className:"field",style:{margin:0,minWidth:120,flex:"0 0 120px"},children:[s.jsx("label",{children:"Limit"}),s.jsx("input",{value:String(j),onChange:ue=>S(Number(ue.target.value||"0")||25),inputMode:"numeric",placeholder:"25"})]}),s.jsxs("div",{className:"field",style:{margin:0,minWidth:160,flex:"1 1 160px"},children:[s.jsx("label",{children:"Mailbox"}),s.jsx("input",{value:h,onChange:ue=>_(String(ue.target.value||"")),placeholder:"INBOX"})]}),s.jsx("div",{className:"row",style:{gap:"8px",alignItems:"center",marginTop:"18px"},children:s.jsx("button",{className:"btn",onClick:()=>void lt(),disabled:!de||D||!String(c||"").trim()||!Xe,children:"Apply"})})]}),oe?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:oe}):null,s.jsx("div",{className:"inbox_list",children:U.length?U.map(ue=>{const Ne=String((ue==null?void 0:ue.uid)||"").trim(),$t=!!Ne&&Ne===String(V||"").trim(),pt=String((ue==null?void 0:ue.subject)||"").trim()||"(no subject)",qt=String((ue==null?void 0:ue.from)||"").trim(),Dn=String((ue==null?void 0:ue.date)||"").trim(),nn=!!(ue!=null&&ue.seen);return s.jsxs("button",{className:`inbox_item ${$t?"active":""}`,onClick:()=>void xe(Ne),children:[s.jsxs("div",{className:"inbox_item_title",children:[s.jsx("span",{className:`pill ${nn?"approved":"pending"}`,children:nn?"read":"unread"}),s.jsx("span",{className:"item_title_text",children:Mu(pt,52)})]}),s.jsx("div",{className:"inbox_item_meta mono muted",children:Mu(qt,60)||"(from?)"}),s.jsxs("div",{className:"inbox_item_meta mono muted",children:[Mu(Dn,36)||"(date?)"," • uid ",Mu(Ne,10)]})]},Ne||Math.random())}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No messages."})})]}),s.jsx("div",{className:"card inbox_viewer",children:V?I?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading email…"}):_e?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:_e}):k?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",gap:"8px",flexWrap:"wrap"},children:[s.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center",flexWrap:"wrap"},children:[s.jsx("div",{className:"mono",style:{fontWeight:700},children:String((k==null?void 0:k.subject)||"").trim()||"(no subject)"}),s.jsx("span",{className:"pill muted",children:String((k==null?void 0:k.account)||"").trim()||c}),s.jsx("span",{className:"pill muted",children:String((k==null?void 0:k.mailbox)||"").trim()||"(mailbox?)"}),s.jsxs("span",{className:"pill muted",children:["uid ",Mu(String((k==null?void 0:k.uid)||V),12)]})]}),s.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[s.jsx("button",{className:"btn",onClick:()=>Ns(String((k==null?void 0:k.message_id)||"")),disabled:!String((k==null?void 0:k.message_id)||"").trim(),title:"Copy Message-ID",children:"Copy msg-id"}),s.jsx("button",{className:"btn",onClick:()=>Ns(String(V||"")),disabled:!String(V||"").trim(),title:"Copy UID",children:"Copy uid"}),s.jsx("button",{className:"btn primary",onClick:()=>yt(),disabled:!tt||!String((k==null?void 0:k.from)||"").trim(),children:"Reply"})]})]}),s.jsx("div",{className:"section_divider"}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"From"}),s.jsx("div",{className:"mono",children:String((k==null?void 0:k.from)||"").trim()||"(from?)"})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"To"}),s.jsx("div",{className:"mono",children:String((k==null?void 0:k.to)||"").trim()||"(to?)"})]}),String((k==null?void 0:k.cc)||"").trim()?s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Cc"}),s.jsx("div",{className:"mono",children:String((k==null?void 0:k.cc)||"").trim()})]}):null,s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Date"}),s.jsx("div",{className:"mono",children:Bg(String((k==null?void 0:k.date)||(ln==null?void 0:ln.date)||"").trim())||String((k==null?void 0:k.date)||(ln==null?void 0:ln.date)||"").trim()||"(date?)"})]}),Array.isArray(k==null?void 0:k.attachments)&&k.attachments.length?s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Attachments"}),s.jsx("div",{className:"mono",children:k.attachments.map((ue,Ne)=>s.jsxs("div",{children:[String((ue==null?void 0:ue.filename)||"").trim()||"(file?)"," ",s.jsx("span",{className:"muted",children:String((ue==null?void 0:ue.content_type)||"").trim()?`(${String((ue==null?void 0:ue.content_type)||"").trim()})`:""})]},`${(ue==null?void 0:ue.filename)||""}:${Ne}`))})]}):null,s.jsx("div",{className:"section_divider"}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:je}),s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",wordBreak:"break-word",padding:"10px",borderRadius:"10px",border:"1px solid rgba(255, 255, 255, 0.10)",background:"rgba(0, 0, 0, 0.12)",maxHeight:"60vh",overflow:"auto"},children:Xt||"(empty)"})]})]}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select an email to read."}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select an email to read."})})]}),s.jsxs(Mi,{open:F,title:`Compose (${String(c||"").trim()||"account"})`,onClose:()=>{ne||N(!1)},actions:s.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[$e?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginRight:"auto"},children:$e}):null,s.jsx("button",{className:"btn",onClick:()=>N(!1),disabled:ne,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:()=>void sn(),disabled:ne,children:ne?"Sending…":"Send"})]}),children:[s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"To"}),s.jsx("input",{value:B,onChange:ue=>Z(String(ue.target.value||"")),placeholder:"you@example.com"})]}),s.jsxs("div",{className:"row",style:{gap:"10px",flexWrap:"wrap"},children:[s.jsxs("div",{className:"field",style:{flex:"1 1 220px"},children:[s.jsx("label",{children:"Cc"}),s.jsx("input",{value:te,onChange:ue=>he(String(ue.target.value||"")),placeholder:"(optional)"})]}),s.jsxs("div",{className:"field",style:{flex:"1 1 220px"},children:[s.jsx("label",{children:"Bcc"}),s.jsx("input",{value:Ae,onChange:ue=>se(String(ue.target.value||"")),placeholder:"(optional)"})]})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Subject"}),s.jsx("input",{value:ve,onChange:ue=>Re(String(ue.target.value||"")),placeholder:"Subject"})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Body (text)"}),s.jsx("textarea",{value:Qe,onChange:ue=>Pe(String(ue.target.value||"")),placeholder:"Write your message…"})]}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:"Tip: separate multiple recipients with commas or newlines."})]})]})}function Ug(e){const t=String(e||"").trim();if(!t)return"";const r=t.split("/").filter(Boolean);return r.length?r[r.length-1]:""}function Dd(e){const t=String(e||"").trim();if(!t)return"";const r=Date.parse(t);return Number.isFinite(r)?new Date(r).toLocaleString():t}function Rc(e,t){const r=String(e||"");return r.length<=t?r:`${r.slice(0,Math.max(0,t-1))}…`}function s1(e){const t=e.gateway,r=!!e.enable_triage,[o,l]=m.useState(r?"messages":"email"),[u,c]=m.useState([]),[d,h]=m.useState([]),[_,g]=m.useState([]),[x,v]=m.useState(!1),[b,j]=m.useState(""),[S,T]=m.useState(null),[M,D]=m.useState(""),[L,I]=m.useState(!1),[G,ne]=m.useState(""),[Y,oe]=m.useState("pending"),[le,_e]=m.useState(null),[Te,$e]=m.useState(""),[K,U]=m.useState(null),[X,V]=m.useState(""),[J,k]=m.useState(!1),[z,F]=m.useState(!1),[N,B]=m.useState(""),[Z,te]=m.useState(""),he=!!Z,[Ae,se]=m.useState(""),[ve,Re]=m.useState(""),[Qe,Pe]=m.useState(""),[de,be]=m.useState(!1),Fe=e.gateway_connected;m.useEffect(()=>{!r&&o!=="email"&&l("email")},[r,o]);const Xe=m.useMemo(()=>o==="bugs"?u:o==="features"?d:[],[o,u,d]);m.useEffect(()=>{o==="email"&&(j(""),v(!1))},[o]);async function tt(){const je=await t.list_bug_reports();c(Array.isArray(je==null?void 0:je.items)?je.items:[])}async function ze(){const je=await t.list_feature_requests();h(Array.isArray(je==null?void 0:je.items)?je.items:[])}async function Oe(){const je=await t.list_triage_decisions({status:Y||void 0,limit:500}),ue=Array.isArray(je==null?void 0:je.decisions)?je.decisions:[];g(ue),le&&!ue.some(Ne=>Ne.decision_id===le.decision_id)&&(_e(null),$e(""),U(null),V(""))}async function lt(){if(Fe&&r&&o!=="email"){j(""),v(!0);try{o==="bugs"?await tt():o==="features"?await ze():await Oe()}catch(je){j(String((je==null?void 0:je.message)||je||"Refresh failed"))}finally{v(!1)}}}m.useEffect(()=>{lt()},[o,Fe,Y,r]);async function xe(je){T(je),D(""),ne(""),I(!0);try{if(je.report_type==="bug"){const ue=await t.get_bug_report_content(je.filename);D(String((ue==null?void 0:ue.content)||""))}else{const ue=await t.get_feature_request_content(je.filename);D(String((ue==null?void 0:ue.content)||""))}}catch(ue){ne(String((ue==null?void 0:ue.message)||ue||"Failed to load report"))}finally{I(!1)}}async function Et(je){_e(je),$e(""),U(null),V("");const ue=Ug(je.report_relpath);if(ue)try{if(je.report_type==="bug"){const Ne=await t.get_bug_report_content(ue);$e(String((Ne==null?void 0:Ne.content)||""))}else if(je.report_type==="feature"){const Ne=await t.get_feature_request_content(ue);$e(String((Ne==null?void 0:Ne.content)||""))}}catch(Ne){V(String((Ne==null?void 0:Ne.message)||Ne||"Failed to load report"))}}async function yt(je){V(""),U(null);const ue=String(je.draft_relpath||"").trim();if(!ue)return;const Ne=Ug(ue);if(Ne)try{const $t=await t.backlog_content("proposed",Ne);U($t)}catch($t){V(String(($t==null?void 0:$t.message)||$t||"Failed to load draft (is repo root configured on gateway?)"))}}async function sn(je,ue){if(le&&!J){V(""),k(!0);try{const Ne=await t.apply_triage_decision(le.decision_id,{action:je,defer_days:ue??null});await Oe();const $t=String(Y||"").trim().toLowerCase(),pt=String((Ne==null?void 0:Ne.status)||"").trim().toLowerCase();if(!(!$t||$t===pt))_e(null),$e(""),U(null);else if(_e(Ne),String(Ne.draft_relpath||"").trim())try{await yt(Ne)}catch{}}catch(Ne){V(String((Ne==null?void 0:Ne.message)||Ne||"Decision action failed"))}finally{k(!1)}}}async function ln(){if(!z){j(""),F(!0);try{const je=await t.triage_run({write_drafts:!1,enable_llm:!1});B(`Scanned ${(je==null?void 0:je.reports)??0} report(s); updated ${(je==null?void 0:je.updated_decisions)??0} decision(s).`),await Oe()}catch(je){j(String((je==null?void 0:je.message)||je||"Triage failed"))}finally{F(!1)}}}m.useEffect(()=>{he&&(Pe(""),Re(""),be(!1),se(String(e.default_session_id||"").trim()))},[he,e.default_session_id]);async function Xt(){var je,ue;if(Z&&!de){Pe(""),be(!0);try{const Ne=String(Ae||"").trim();if(!Ne)throw new Error("session_id is required");const $t=String(ve||"").trim();if(!$t)throw new Error("description is required");const pt={session_id:Ne,description:$t,active_run_id:String(e.default_active_run_id||"").trim()||void 0,workflow_id:String(e.default_workflow_id||"").trim()||void 0,client:"abstractobserver/web",client_version:"",user_agent:String(((je=globalThis==null?void 0:globalThis.navigator)==null?void 0:je.userAgent)||""),url:String(((ue=globalThis==null?void 0:globalThis.location)==null?void 0:ue.href)||"")};if(Z==="bug"){const qt=await t.bug_report_create(pt),Dn=String((qt==null?void 0:qt.filename)||"").trim();te(""),l("bugs");const nn=await t.list_bug_reports(),cn=Array.isArray(nn==null?void 0:nn.items)?nn.items:[];c(cn);const vn=cn.find(Sn=>Sn.filename===Dn)||null;vn&&await xe(vn)}else{const qt=await t.feature_report_create(pt),Dn=String((qt==null?void 0:qt.filename)||"").trim();te(""),l("features");const nn=await t.list_feature_requests(),cn=Array.isArray(nn==null?void 0:nn.items)?nn.items:[];h(cn);const vn=cn.find(Sn=>Sn.filename===Dn)||null;vn&&await xe(vn)}}catch(Ne){Pe(String((Ne==null?void 0:Ne.message)||Ne||"Failed to create report"))}finally{be(!1)}}}return s.jsxs("div",{className:"page",children:[s.jsxs("div",{className:"page_inner",children:[s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"title",children:s.jsx("h1",{children:"Inbox"})}),s.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between"},children:[s.jsx("div",{className:"tab_bar",style:{paddingBottom:0,borderBottom:"none"},children:r?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:`tab ${o==="messages"?"active":""}`,onClick:()=>l("messages"),children:"Messages"}),s.jsx("button",{className:`tab ${o==="email"?"active":""}`,onClick:()=>l("email"),children:"Email"}),s.jsx("button",{className:`tab ${o==="bugs"?"active":""}`,onClick:()=>l("bugs"),children:"Bugs"}),s.jsx("button",{className:`tab ${o==="features"?"active":""}`,onClick:()=>l("features"),children:"Features"})]}):s.jsx("button",{className:`tab ${o==="email"?"active":""}`,onClick:()=>l("email"),children:"Email"})}),s.jsx("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:r?s.jsxs(s.Fragment,{children:[o==="messages"?s.jsxs(s.Fragment,{children:[s.jsxs("select",{value:Y,onChange:je=>oe(String(je.target.value)),title:"Filter triage decisions by status",children:[s.jsx("option",{value:"pending",children:"pending"}),s.jsx("option",{value:"approved",children:"approved"}),s.jsx("option",{value:"deferred",children:"deferred"}),s.jsx("option",{value:"rejected",children:"rejected"}),s.jsx("option",{value:"",children:"all"})]}),s.jsx("button",{className:"btn",onClick:()=>void lt(),disabled:!Fe||x,children:x?"Refreshing…":"Refresh"}),s.jsx("button",{className:"btn primary",onClick:()=>void ln(),disabled:!Fe||z,children:z?"Running…":"Run triage"})]}):o==="email"?null:s.jsx("button",{className:"btn",onClick:()=>void lt(),disabled:!Fe||x,children:x?"Refreshing…":"Refresh"}),s.jsx("button",{className:"btn",onClick:()=>te("bug"),disabled:!Fe,children:"File bug"}),s.jsx("button",{className:"btn",onClick:()=>te("feature"),disabled:!Fe,children:"File feature"})]}):null})]}),r&&o!=="email"&&N?s.jsx("div",{className:"mono muted",style:{marginTop:"8px",fontSize:"var(--font-size-sm)"},children:N}):null,r&&o!=="email"&&b?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",marginTop:"8px",fontSize:"var(--font-size-sm)"},children:b}):null]}),o==="email"?s.jsx(r1,{gateway:t,enabled:Fe}):s.jsxs("div",{className:"inbox_layout",children:[s.jsx("div",{className:"card inbox_sidebar",children:o==="messages"?s.jsx("div",{className:"inbox_list",children:_.length?_.map(je=>{const ue=(le==null?void 0:le.decision_id)===je.decision_id,Ne=Array.isArray(je.missing_fields)?je.missing_fields.length:0;return s.jsxs("button",{className:`inbox_item ${ue?"active":""}`,onClick:()=>void Et(je),children:[s.jsxs("div",{className:"inbox_item_title",children:[s.jsx("span",{className:`pill ${String(je.status||"").toLowerCase()}`,children:String(je.status||"pending")}),s.jsx("span",{className:"mono",children:je.report_type}),s.jsx("span",{className:"mono muted",children:Rc(je.decision_id,10)})]}),s.jsxs("div",{className:"inbox_item_meta mono muted",children:[Ne?`${Ne} missing`:"complete"," • ",Dd(je.updated_at||je.created_at)||"(time?)"]}),s.jsx("div",{className:"inbox_item_meta mono",children:Rc(je.report_relpath||"",46)})]},je.decision_id)}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No decisions."})}):s.jsx("div",{className:"inbox_list",children:Xe.length?Xe.map(je=>{const ue=(S==null?void 0:S.filename)===je.filename&&(S==null?void 0:S.report_type)===je.report_type,Ne=String(je.triage_status||"").trim().toLowerCase();return s.jsxs("button",{className:`inbox_item ${ue?"active":""}`,onClick:()=>void xe(je),children:[s.jsxs("div",{className:"inbox_item_title",children:[Ne?s.jsx("span",{className:`pill ${Ne}`,children:Ne}):null,s.jsx("span",{className:"mono",children:Rc(je.title||je.filename,46)})]}),s.jsxs("div",{className:"inbox_item_meta mono muted",children:[Dd(je.created_at)||"(time?)"," • ",je.session_id?Rc(je.session_id,12):"session?"]}),s.jsx("div",{className:"inbox_item_meta mono",children:je.filename})]},je.relpath)}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No reports."})})}),s.jsx("div",{className:"card inbox_viewer",children:o==="messages"?le?s.jsxs("div",{className:"inbox_detail",children:[s.jsxs("div",{className:"inbox_detail_header",children:[s.jsxs("div",{className:"inbox_detail_title",children:[s.jsx("span",{className:"mono",style:{fontWeight:700},children:"Triage decision"}),s.jsx("span",{className:"chip mono muted",children:le.report_type}),s.jsx("span",{className:"chip mono muted",children:le.status}),s.jsx("span",{className:"chip mono muted",children:Rc(le.decision_id,16)})]}),s.jsxs("div",{className:"inbox_detail_actions",children:[s.jsx("button",{className:"btn",onClick:()=>{Ns(le.report_relpath||"")},children:"Copy report path"}),le.draft_relpath?s.jsx("button",{className:"btn",onClick:()=>void yt(le),children:"Load draft"}):null,s.jsx("button",{className:"btn primary",onClick:()=>void sn("approve"),disabled:J,children:"Approve"}),s.jsx("button",{className:"btn",onClick:()=>void sn("defer",1),disabled:J,children:"Defer 1d"}),s.jsx("button",{className:"btn",onClick:()=>void sn("defer",7),disabled:J,children:"Defer 7d"}),s.jsx("button",{className:"btn",onClick:()=>void sn("reject"),disabled:J,children:"Reject"})]})]}),s.jsxs("div",{className:"inbox_detail_meta mono muted",style:{fontSize:"var(--font-size-sm)"},children:[le.updated_at?`updated ${Dd(le.updated_at)}`:null,le.created_at?`${le.updated_at?" • ":""}created ${Dd(le.created_at)}`:null,le.defer_until?` • defer until ${le.defer_until}`:null]}),X?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:X}):null,s.jsxs("div",{className:"row",style:{gap:"12px"},children:[s.jsxs("div",{className:"col",style:{minWidth:240},children:[s.jsx("div",{className:"section_title",children:"Missing fields"}),le.missing_fields&&le.missing_fields.length?s.jsx("ul",{className:"inbox_list_ul mono",children:le.missing_fields.map(je=>s.jsx("li",{children:je},je))}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"None."}),s.jsx("div",{className:"section_title",style:{marginTop:"10px"},children:"Possible duplicates"}),le.duplicates&&le.duplicates.length?s.jsx("ul",{className:"inbox_list_ul mono",children:le.duplicates.slice(0,20).map((je,ue)=>{const Ne=String((je==null?void 0:je.title)||(je==null?void 0:je.ref)||(je==null?void 0:je.kind)||"duplicate").trim(),$t=typeof(je==null?void 0:je.score)=="number"&&Number.isFinite(je.score)?` (score ${je.score.toFixed(2)})`:"";return s.jsxs("li",{children:[Ne,$t]},`${Ne}_${ue}`)})}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"None."})]}),s.jsxs("div",{className:"col",style:{minWidth:240},children:[s.jsx("div",{className:"section_title",children:"Draft"}),le.draft_relpath?s.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:[s.jsx("div",{className:"mono muted",children:"path"}),s.jsx("div",{className:"mono",children:le.draft_relpath})]}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No draft yet. Approve to generate one (requires repo mounted on gateway host)."})]})]}),K?s.jsxs("div",{className:"inbox_markdown",children:[s.jsx("div",{className:"section_title",children:"Draft content"}),s.jsx(ao,{text:String(K.content||"")})]}):null,s.jsxs("div",{className:"inbox_markdown",children:[s.jsx("div",{className:"section_title",children:"Source report"}),Te?s.jsx(ao,{text:Te}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No report preview loaded."})]})]}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select a decision."}):S?s.jsxs("div",{className:"inbox_detail",children:[s.jsxs("div",{className:"inbox_detail_header",children:[s.jsxs("div",{className:"inbox_detail_title",children:[s.jsx("span",{className:"mono",style:{fontWeight:700},children:S.report_type==="bug"?"Bug report":"Feature request"}),S.triage_status?s.jsx("span",{className:`pill ${S.triage_status}`,children:S.triage_status}):null,s.jsx("span",{className:"chip mono muted",children:S.filename}),S.session_id?s.jsx("span",{className:"chip mono muted",children:Rc(S.session_id,16)}):null]}),s.jsx("div",{className:"inbox_detail_actions",children:s.jsx("button",{className:"btn",onClick:()=>{Ns(S.relpath||"")},children:"Copy path"})})]}),G?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:G}):null,L?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading…"}):M?s.jsx(ao,{text:M}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No content loaded."})]}):s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select a report."})})]})]}),s.jsxs(Mi,{open:he,title:Z==="bug"?"File bug report":"File feature request",onClose:()=>te(""),actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>te(""),disabled:de,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:()=>void Xt(),disabled:de,children:de?"Submitting…":"Submit"})]}),children:[s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Session ID"}),s.jsx("input",{value:Ae,onChange:je=>se(je.target.value),placeholder:"session id (required)"}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"This correlates runs + attachments (via the session memory run)."})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:Z==="bug"?"Bug description":"Feature description"}),s.jsx("textarea",{value:ve,onChange:je=>Re(je.target.value),placeholder:Z==="bug"?"What is broken? What did you expect?":"What do you want to be able to do?",rows:6})]}),Qe?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Qe}):null]})]})}function i1(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const r=Date.parse(t);return Number.isFinite(r)?r:null}function o1(e){const t=Date.now(),r=e.getTime(),o=t-r,l=Math.floor(o/1e3),u=Math.floor(l/60),c=Math.floor(u/60),d=Math.floor(c/24);return l<60?"Just now":u<60?`${u}m ago`:c<24?`${c}h ago`:d<=3?`${d}d ago`:e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Qy(e){const t=i1(e);return t===null?"—":o1(new Date(t))}function a1(e,t){const r=String(e||"");return r.length<=t?r:`${r.slice(0,Math.max(0,t-1))}…`}function Zy(e){const t=typeof e.workflow_id=="string"?String(e.workflow_id).trim():"",r=String(e.status||"").trim().toLowerCase(),o=String(e.waiting_reason||"").trim().toLowerCase(),l=!!e.is_scheduled||t&&t.startsWith("scheduled:"),u=!!e.paused,c={completed:{label:"Completed",cls:"success"},failed:{label:"Failed",cls:"error"},cancelled:{label:"Cancelled",cls:"muted"},waiting:{label:"Waiting",cls:"warning"},running:{label:"Running",cls:"info"}};return l&&u?{label:"Suspended",cls:"scheduled"}:r==="waiting"&&l?{label:"Scheduled",cls:"scheduled"}:r==="running"&&l&&o==="until"?{label:"Scheduled",cls:"scheduled"}:c[r]||{label:e.status||"Unknown",cls:"muted"}}function ex(e,t){const r=String(e||"").trim();if(r){const o=t[r];if(o){const u=o.split(/[·:]/);return u.length>1?u[u.length-1].trim():o.trim()}const l=r.indexOf(":");if(l>0)return r.slice(l+1).trim()||r.slice(0,l).trim();if(/[a-z]/i.test(r))return r}return"(unknown workflow)"}function l1({run:e,workflow_label_by_id:t,selected:r,onClick:o}){const l=typeof e.workflow_id=="string"?String(e.workflow_id):"",u=typeof e.schedule_target_workflow_id=="string"?String(e.schedule_target_workflow_id):"",c=u.trim()?u:l,d=ex(c,t),h=Zy(e),_=Qy(e.updated_at||e.created_at),g=typeof e.ledger_len=="number"&&e.ledger_len>0?e.ledger_len:null,x=!!e.is_scheduled||l&&l.startsWith("scheduled:"),v=String(e.schedule_interval||"").trim(),b=[];x&&b.push(v?`every ${v}`:"scheduled"),g!==null&&b.push(`${g} steps`);const j=b.join(" • ");return s.jsxs("button",{className:`run_card ${r?"selected":""}`,onClick:o,type:"button",children:[s.jsxs("div",{className:"run_card_header",children:[s.jsx("span",{className:"run_card_name",children:d}),s.jsx("span",{className:`run_card_status ${h.cls}`,children:h.label})]}),s.jsxs("div",{className:"run_card_time",children:[s.jsx("span",{children:_}),s.jsx("span",{className:"run_card_sep",children:"•"}),s.jsx("span",{className:"mono",children:a1(e.run_id,8)})]}),j?s.jsx("div",{className:"run_card_meta",children:j}):null]})}function c1({run:e,workflow_label_by_id:t}){const r=typeof e.workflow_id=="string"?String(e.workflow_id):"",o=typeof e.schedule_target_workflow_id=="string"?String(e.schedule_target_workflow_id):"",l=o.trim()?o:r,u=ex(l,t),c=Zy(e),d=Qy(e.updated_at||e.created_at);return s.jsxs("div",{className:"run_selected_badge",children:[s.jsx("span",{className:"run_selected_name",children:u}),s.jsx("span",{className:`run_selected_status ${c.cls}`,children:c.label}),s.jsx("span",{className:"run_selected_time",children:d})]})}function u1({runs:e,selected_run_id:t,workflow_label_by_id:r,disabled:o,loading:l,onSelect:u}){const[c,d]=m.useState(!1),[h,_]=m.useState(""),[g,x]=m.useState(null),v=m.useRef(null),b=m.useRef(null);m.useEffect(()=>{if(!c)return;const T=M=>{v.current&&(v.current.contains(M.target)||d(!1))};return window.addEventListener("mousedown",T),()=>window.removeEventListener("mousedown",T)},[c]),m.useEffect(()=>{if(!c)return;const T=()=>{if(!b.current)return;const M=b.current.getBoundingClientRect(),D=12,L=Math.min(720,window.innerWidth-D*2);let I=M.left,G=Math.max(M.width,L);G>window.innerWidth-D*2&&(G=window.innerWidth-D*2),I+G>window.innerWidth-D&&(I=Math.max(D,window.innerWidth-D-G)),I<D&&(I=D);const ne=320,Y=520,oe=window.innerHeight-M.bottom-D,le=M.top-D,_e=oe<ne&&le>oe;let Te=Math.max(ne,_e?le:oe);Te=Math.min(Te,Y,window.innerHeight-D*2);let $e=_e?M.top-8-Te:M.bottom+8;$e=Math.min($e,window.innerHeight-D-Te),$e=Math.max(D,$e),x({left:I,width:G,height:Te,top:$e})};return T(),window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}},[c]);const j=m.useMemo(()=>{const T=String(t||"").trim();return T?e.find(M=>String(M.run_id||"").trim()===T)||{run_id:T}:null},[e,t]),S=m.useMemo(()=>{const T=String(h||"").trim().toLowerCase();return T?e.filter(M=>{const D=String(M.run_id||"").toLowerCase(),L=typeof M.workflow_id=="string"?String(M.workflow_id).toLowerCase():"",I=typeof M.schedule_target_workflow_id=="string"?String(M.schedule_target_workflow_id).toLowerCase():"",G=L?String(r[String(M.workflow_id)]||"").toLowerCase():"",ne=I?String(r[String(M.schedule_target_workflow_id)]||"").toLowerCase():"",Y=typeof M.status=="string"?String(M.status).toLowerCase():"";return D.includes(T)||L.includes(T)||G.includes(T)||I.includes(T)||ne.includes(T)||Y.includes(T)}):e},[e,h,r]);return s.jsxs("div",{className:"run_picker",ref:v,children:[s.jsxs("button",{className:"run_picker_btn",ref:b,onClick:()=>{o||d(T=>!T)},disabled:o,type:"button",children:[l?s.jsx("span",{className:"muted",children:"Loading runs…"}):j?s.jsx(c1,{run:j,workflow_label_by_id:r}):s.jsx("span",{className:"run_picker_placeholder",children:"Select a run to observe"}),s.jsx("span",{className:"run_picker_chevron",children:c?"▲":"▼"})]}),c?s.jsxs("div",{className:"run_picker_panel",style:g?{left:`${g.left}px`,width:`${g.width}px`,height:`${g.height}px`,top:`${g.top}px`}:void 0,children:[s.jsx("div",{className:"run_picker_header",children:s.jsx("input",{className:"run_picker_filter",value:h,onChange:T=>_(T.target.value),placeholder:"Search runs by name, status..."})}),s.jsx("div",{className:"run_picker_grid",children:S.length?S.map(T=>{const M=String(T.run_id||"").trim();if(!M)return null;const D=String(t||"").trim()===M;return s.jsx(l1,{run:T,workflow_label_by_id:r,selected:D,onClick:()=>{d(!1),u(M)}},M)}):s.jsxs("div",{className:"run_picker_empty",children:[s.jsx("span",{className:"run_picker_empty_icon",children:"◇"}),s.jsx("span",{children:"No runs found"})]})})]}):null]})}function tx(e,t=!1){const r=typeof window<"u"?window.__ABSTRACT_UI_CONFIG__:void 0,o=r==null?void 0:r[e];if(o==null||o==="")return t;if(typeof o=="boolean")return o;const l=String(o).trim().toLowerCase();return["1","true","yes","on"].includes(l)?!0:["0","false","no","off"].includes(l)?!1:(console.warn(`#FALLBACK: ui_config.${e}="${o}" is not a boolean; defaulting to ${t?"true":"false"}.`),t)}const cl=tx("enable_backlog"),d1=tx("enable_inbox_triage");function hn(){return new Date().toISOString()}function Sm(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function aa(e,t){try{const r=JSON.stringify(e);return typeof r!="string"?String(e):r.length<=t?r:`${r.slice(0,Math.max(0,t-1))}…`}catch{const r=String(e);return r.length<=t?r:`${r.slice(0,Math.max(0,t-1))}…`}}function jm(e){const t=String(e||"").trim(),r=t.indexOf(":");return r<=0||r>=t.length-1?null:{bundle_id:t.slice(0,r),flow_id:t.slice(r+1)}}function zu(e){const t=String(e||"").trim();return t.startsWith("abstractcode.")?`abstract.${t.slice(13)}`:t}function km(e){const t=String(e||"").trim();return t.startsWith("abstract.")||t.startsWith("abstractcode.")}function f1(e){const t=String(e||"").trim();if(t.startsWith("evt:")){const r=t.split(":",4);if(r.length===4&&r[3])return String(r[3]).trim()}return t}function m1(e){if(!e||typeof e!="object")return[];const t=Array.isArray(e.nodes)?e.nodes:[];if(!t.length)return[];let r=null;for(const d of t){if(!d||typeof d!="object")continue;const h=d.data&&typeof d.data=="object"?d.data:{};if(String(h.nodeType||d.type||"").trim()==="on_flow_start"){r=d;break}}if(!r)return[];const o=r.data&&typeof r.data=="object"?r.data:{},l=Array.isArray(o.outputs)?o.outputs:[],u=o.pinDefaults&&typeof o.pinDefaults=="object"?o.pinDefaults:{},c=[];for(const d of l){if(!d||typeof d!="object")continue;const h=String(d.id||"").trim();if(!h)continue;const _=String(d.type||"").trim();if(_==="execution"||h==="exec-out"||h==="exec")continue;const g=String(d.label||h).trim()||h,x={id:h,label:g,type:_||"unknown"};u&&Object.prototype.hasOwnProperty.call(u,h)&&(x.default=u[h]),c.push(x)}return c}function an(e,t){const r=typeof(t==null?void 0:t.max_chars)=="number"?t.max_chars:360,o=typeof(t==null?void 0:t.max_lines)=="number"?t.max_lines:2,u=String(e||"").replace(/\r\n/g,`
|
|
131
|
+
`).replace(/\r/g,`
|
|
132
|
+
`).split(`
|
|
133
|
+
`),c=u.slice(0,Math.max(1,o)).join(`
|
|
134
|
+
`),d=u.length>o,h=c.length>r?`${c.slice(0,Math.max(0,r-1))}…`:c;return d&&h===c?`${c}…`:h}function Ma(e,t){const r=String(e||"");return r.length<=t?r:`${r.slice(0,Math.max(0,t-1))}…`}const h1=/^[a-zA-Z0-9_-]+$/;function Wg(e){return h1.test(String(e||"").trim())}async function p1(e){const t=String(e||""),r=new TextEncoder().encode(t),o=globalThis.crypto;if(!o||!o.subtle||typeof o.subtle.digest!="function")throw new Error("crypto.subtle.digest not available");const l=await o.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(l)).map(u=>u.toString(16).padStart(2,"0")).join("")}async function Hg(e){const t=String(e||"").trim();if(!t)throw new Error("session_id is required");if(Wg(t)){const o=`session_memory_${t}`;if(Wg(o))return o}return`session_memory_sha_${(await p1(t)).slice(0,32)}`}function Vg(e){const t=String(e||"").trim();return t&&t.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"untitled"}function Lc(e){if(typeof e=="string")return{text:e,duration:-1};if(e&&typeof e=="object"){const t=typeof e.text=="string"?String(e.text):typeof e.value=="string"?String(e.value):typeof e.message=="string"?String(e.message):aa(e,320),r=typeof e.duration=="number"?Number(e.duration):-1;return{text:t,duration:r}}return{text:aa(e,320),duration:-1}}function nx(e){var c,d,h,_,g,x,v,b,j;if(!e||typeof e!="object")return"";const t=String(((c=e==null?void 0:e.effect)==null?void 0:c.type)||"").trim(),r=e==null?void 0:e.result,o=S=>typeof S=="string"?S.trim():S==null?"":typeof S=="number"||typeof S=="boolean"?String(S):"",l=S=>{if(!S||typeof S!="object")return"";const T=S,M=[T.response,T.answer,T.message,T.text,T.content];for(const D of M){const L=o(D);if(L)return L}return""};if(t==="answer_user"){const S=o(r==null?void 0:r.message)||o((d=r==null?void 0:r.output)==null?void 0:d.message)||o((h=r==null?void 0:r.output)==null?void 0:h.response)||o((g=(_=e==null?void 0:e.effect)==null?void 0:_.payload)==null?void 0:g.message)||o((v=(x=e==null?void 0:e.effect)==null?void 0:x.payload)==null?void 0:v.text)||o((j=(b=e==null?void 0:e.effect)==null?void 0:b.payload)==null?void 0:j.content);if(S)return S}if(t==="llm_call"){const S=l(r)||o(r==null?void 0:r.output)||l(r==null?void 0:r.output)||o(r==null?void 0:r.response);if(S)return S}return o(r==null?void 0:r.output)||l(r==null?void 0:r.output)||l(r)||o(r==null?void 0:r.response)}const qg=new Set(["abstract.status","abstract.summary","abstract.chat"]);function g1(e){if(!e)return!1;if(e.kind==="error")return!0;if(e.kind==="info")return!1;const t=String(e.emit_name||"").trim();if((e.kind==="event"||e.kind==="message")&&t)return!qg.has(t);const r=String(e.effect_type||"").trim();if(r){if(r==="tool_calls"||r==="llm_call"||r==="ask_user"||r==="answer_user"||r==="memory_compact"||r==="start_subworkflow")return!0;if(r==="emit_event")return!(t&&qg.has(t))}if(String(e.status||"").trim()==="waiting"){const u=ul(e.data),c=String((u==null?void 0:u.reason)||"").trim();return!!(c==="user"||c==="event"||m_(u).length)}return!!nx(e.data)}function _1(){try{const e=localStorage.getItem("abstractobserver_settings");if(!e)throw new Error("missing");const t=JSON.parse(e);return{gateway_url:String((t==null?void 0:t.gateway_url)||""),auth_token:String((t==null?void 0:t.auth_token)||""),worker_url:String((t==null?void 0:t.worker_url)||""),worker_token:String((t==null?void 0:t.worker_token)||""),theme:String((t==null?void 0:t.theme)||"dark"),font_scale:String((t==null?void 0:t.font_scale)||(t==null?void 0:t.fontScale)||"md").trim()||"md",header_density:String((t==null?void 0:t.header_density)||(t==null?void 0:t.headerDensity)||"standard").trim()||"standard",auto_connect_gateway:(t==null?void 0:t.auto_connect_gateway)!==!1,maintenance_ai_provider:String((t==null?void 0:t.maintenance_ai_provider)||""),maintenance_ai_model:String((t==null?void 0:t.maintenance_ai_model)||""),backlog_advisor_agent:String((t==null?void 0:t.backlog_advisor_agent)||(t==null?void 0:t.backlogAdvisorAgent)||"")}}catch{return{gateway_url:"",auth_token:"",worker_url:"",worker_token:"",theme:"dark",font_scale:"md",header_density:"standard",auto_connect_gateway:!0,maintenance_ai_provider:"",maintenance_ai_model:"",backlog_advisor_agent:""}}}function y1(e){localStorage.setItem("abstractobserver_settings",JSON.stringify(e))}function Nm(e){var l;const t=String((e==null?void 0:e.node_id)||""),r=String((e==null?void 0:e.status)||""),o=String(((l=e==null?void 0:e.effect)==null?void 0:l.type)||"");return`${t||"(node?)"} • ${r||"(status?)"} • ${o||"(effect?)"}`}function x1(e){return!!(e&&String(e.status||"")==="waiting")}function fl(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const r=t.replace(/(\.\d{3})\d+/,"$1"),o=Date.parse(r);return Number.isFinite(o)?o:null}function v1(e){const t=Date.now()-e,r=Math.floor(t/1e3),o=Math.floor(r/60),l=Math.floor(o/60),u=Math.floor(l/24);return r<60?"just now":o<60?`${o}m ago`:l<24?`${l}h ago`:u<=3?`${u}d ago`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function rx(e){const t=fl(e);return t===null?"—":v1(t)}function Gg(e){if(!Number.isFinite(e))return"";const t=Math.floor(e/1e3);if(t<=0)return"now";const r=Math.floor(t/60),o=Math.floor(r/60),l=Math.floor(o/24),u=t%60,c=r%60,d=o%24;return l>0?`${l}d ${d}h`:o>0?`${o}h ${c}m`:r>0?`${r}m ${u}s`:`${t}s`}function Yg(e){const t=String(e||"").trim();return t?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t):!1}function w1(){try{const t=String(window.location.hash||"").replace(/^#/,"").split("/").filter(Boolean),r=t.length?String(t[t.length-1]||"").trim():"";if(Yg(r))return r;const l=String(window.location.pathname||"").split("/").filter(Boolean),u=l.length?String(l[l.length-1]||"").trim():"";if(Yg(u))return u}catch{}return""}function b1(){try{const e="abstractobserver_session_id_v1",t=window.sessionStorage.getItem(e);if(t&&t.trim())return t.trim();const r=globalThis.crypto,l=`obs_${r&&typeof r.randomUUID=="function"?r.randomUUID():`${Math.random().toString(16).slice(2)}_${Date.now().toString(16)}`}`;return window.sessionStorage.setItem(e,l),l}catch{return""}}function S1(){var ja,Qs,Zo,pc,iu,Ki,ko,gc,ou,Ji,No,Ll,au,Pl,lu,Ka,$i,Ja,Qa,ea,_c,ka,cu,yc,rr,Il,xc,vc,Fl,wc,ta,sr,xr,Lr;const[e,t]=m.useState("observe");m.useEffect(()=>{!cl&&(e==="backlog"||e==="processes")&&t("observe")},[e,cl]);const[r,o]=m.useState(()=>_1()),l=typeof window<"u"&&((ja=window.__ABSTRACT_UI_CONFIG__)==null?void 0:ja.monitor_gpu)===!0,u=m.useRef(null),[c,d]=m.useState(""),[h,_]=m.useState(""),[g,x]=m.useState(()=>w1()),[v,b]=m.useState(""),[j,S]=m.useState(""),[T,M]=m.useState("{}"),[D]=m.useState(()=>b1()),[L,I]=m.useState(null),[G,ne]=m.useState(!1),[Y,oe]=m.useState(""),[le,_e]=m.useState(!1),[Te,$e]=m.useState(""),[K,U]=m.useState(!1),[X,V]=m.useState([]),[J,k]=m.useState([]),[z,F]=m.useState(!1),[N,B]=m.useState(!1),[Z,te]=m.useState([]),[he,Ae]=m.useState([]),[se,ve]=m.useState({}),[Re,Qe]=m.useState(!1),[Pe,de]=m.useState(!1),[be,Fe]=m.useState(!1),[Xe,tt]=m.useState([]),[ze,Oe]=m.useState([]),lt=m.useRef(0),[xe,Et]=m.useState(null),[yt,sn]=m.useState(""),[ln,Xt]=m.useState(""),[je,ue]=m.useState(!1),[Ne,$t]=m.useState(!1),pt=m.useRef(null),[qt,Dn]=m.useState({}),[nn,cn]=m.useState({}),[vn,Sn]=m.useState("now"),[cr,Qt]=m.useState(""),[Zn,ls]=m.useState("once"),[Un,me]=m.useState(1),[ke,ct]=m.useState("days"),[it,bt]=m.useState(2),[zt,Ut]=m.useState(""),[Ot,pn]=m.useState("23:59"),[It,_n]=m.useState(!0),[un,Gt]=m.useState(!1),[Zt,Vt]=m.useState(""),[rt,jn]=m.useState(!0),[Rn,kn]=m.useState(""),[Nn,ar]=m.useState(!1),[Ir,Sr]=m.useState(!1),[Fr,Ws]=m.useState(6),[Es,lo]=m.useState("standard"),[Ri,cs]=m.useState(""),[En,us]=m.useState(""),[Jr,Or]=m.useState(!1),[mr,st]=m.useState(!1),[St,dn]=m.useState("pause"),[Dr,jr]=m.useState(""),[kr,hr]=m.useState(""),[Io,Hs]=m.useState(""),Bn=m.useRef(null),ur=m.useRef(null),[dr,Me]=m.useState(!1),Gn=m.useRef(null),[Ge,Yn]=m.useState(""),[er,pr]=m.useState(""),[Nr,Cr]=m.useState(""),[Li,rn]=m.useState(""),[Er,Vs]=m.useState(""),[$s,tr]=m.useState(!1),[fr,gi]=m.useState("idle"),[Ln,Br]=m.useState([]),$r=m.useRef(null),[Qr,Ur]=m.useState(!1),[As,Zr]=m.useState(""),[es,gr]=m.useState(""),[Pi,Wr]=m.useState(""),[Ii,Fi]=m.useState([]),[Ts,Oi]=m.useState(!1),[ua,Ms]=m.useState(""),[qs,Hr]=m.useState(""),[zs,Di]=m.useState(!1),[Fo,Ar]=m.useState(""),R=m.useMemo(()=>{if(!Ln.length)return"";try{return JSON.stringify(Ln.map(w=>({role:w.role,content:w.content,ts:w.ts})))}catch{return"1"}},[Ln]),ie=m.useMemo(()=>Ln.length?Pi?R!==Pi:!0:!1,[R,Ln.length,Pi]),Ce=m.useMemo(()=>Ii.map(w=>{const $=String(w.title||"").trim()||`Chat ${String(w.thread_id||"").slice(0,8)}`,P=String(w.created_at||"").trim(),E=P?P.replace("T"," ").slice(0,19):"",H=String(w.run_id||"").trim()?String(w.run_id).slice(0,8):"",Q=[$,E&&`(${E})`,H&&`run ${H}`].filter(Boolean).join(" • ");return{value:String(w.thread_id||""),label:Q}}),[Ii]);m.useEffect(()=>{l&&Kv()},[l]),m.useEffect(()=>{if(!l)return;const w=u.current;w&&(w.token=r.auth_token||"")},[l,r.auth_token]);const[Ie,De]=m.useState([]),[at,At]=m.useState({}),[Rt,Lt]=m.useState({}),[Kt,nt]=m.useState(""),[yn,en]=m.useState("ledger"),[fn,or]=m.useState(!0),[An,Tr]=m.useState("steps"),[bs,_i]=m.useState(""),[Rs,co]=m.useState(""),[yl,uo]=m.useState([]),[fo,mo]=m.useState(!1),[Ia,Gs]=m.useState(""),[ec,ho]=m.useState(!1),[xl,Oo]=m.useState(""),[da,po]=m.useState(""),[Bi,Ls]=m.useState(""),[vl,fa]=m.useState(!1),[go,_o]=m.useState(""),[yo,Do]=m.useState(null),[ma,Fa]=m.useState({}),[wl,Bo]=m.useState(!1),[bl,Ui]=m.useState(""),[yi,tc]=m.useState(!1),[Oa,Sl]=m.useState(!1),[jl,Uo]=m.useState(()=>Date.now()),[Ys,Ps]=m.useState(""),[nc,Wo]=m.useState({}),[kl,ha]=m.useState({}),Wi=m.useRef([]),Mr=m.useRef(null),ds=m.useRef(""),pa=m.useRef({}),ri=m.useRef({}),ga=m.useRef({}),Hi=m.useRef(new Set),[fs,Vi]=m.useState([]),Cn=m.useRef(""),ts=m.useRef({}),lr=m.useRef(null),nr=m.useRef(null),xo=m.useRef(0),si=m.useRef({}),vo=m.useRef(!1),ms=m.useRef(new Set),[ns,Xs]=m.useState(""),[hs,Vn]=m.useState(""),ps=m.useRef(""),[xi,_a]=m.useState(!1),[Ho,qi]=m.useState(""),jt=m.useMemo(()=>new Qv({base_url:r.gateway_url,auth_token:r.auth_token}),[r]),ya=m.useMemo(()=>r.worker_url.trim()?new ew({url:r.worker_url.trim(),auth_token:r.worker_token}):null,[r.worker_url,r.worker_token]),Vr=Xe.length?Xe[Xe.length-1].record:null,gn=m.useMemo(()=>ul(Vr),[Vr]),zr=m.useMemo(()=>{const w=j.trim();if(!L||!w||String(L.bundle_id||"").trim()&&String(L.bundle_id||"").trim()!==w)return null;const $=Array.isArray(L.entrypoints)?L.entrypoints:[];if(!$.length)return null;const P=v.trim();if(P)return $.find(H=>String(H.flow_id||"").trim()===P)||null;if($.length===1)return $[0];const E=String(L.default_entrypoint||"").trim();return E&&$.find(H=>String(H.flow_id||"").trim()===E)||null},[L,j,v]),vi=m.useMemo(()=>{const w=zr==null?void 0:zr.inputs;return Array.isArray(w)?w:[]},[zr]),wo=m.useMemo(()=>m1(yo),[yo]),ii=m.useMemo(()=>vi.length?vi:wo,[vi,wo]),rc=m.useMemo(()=>{const w=typeof(xe==null?void 0:xe.workflow_id)=="string"?String(xe.workflow_id):"",$=jm(w);if($&&L&&String(L.bundle_id||"").trim()===$.bundle_id){const H=(Array.isArray(L.entrypoints)?L.entrypoints:[]).find(Q=>String((Q==null?void 0:Q.flow_id)||"").trim()===$.flow_id);if(H&&H.node_index&&typeof H.node_index=="object")return H.node_index}const P=zr==null?void 0:zr.node_index;return P&&typeof P=="object"?P:{}},[xe,L,zr]);m.useEffect(()=>{y1(r)},[r]),m.useEffect(()=>{kv(r.theme)},[r.theme]),m.useEffect(()=>{Ev({font_scale:r.font_scale,header_density:r.header_density})},[r.font_scale,r.header_density]),m.useEffect(()=>()=>{lr.current&&lr.current.abort(),nr.current&&nr.current.abort(),Bn.current&&window.clearTimeout(Bn.current),ur.current&&window.clearTimeout(ur.current),Mr.current&&window.clearTimeout(Mr.current),Gn.current&&window.clearTimeout(Gn.current)},[]),m.useEffect(()=>{var w;r.auto_connect_gateway&&(!r.gateway_url.trim()&&typeof window<"u"&&!((w=window.location)!=null&&w.origin)||bo())},[r.auto_connect_gateway]);const Yt=m.useMemo(()=>{const w=T.trim();if(!w)return{};try{const $=JSON.parse(w);return typeof $!="object"||$===null||Array.isArray($)?null:$}catch{return null}},[T]),sc=typeof(Yt==null?void 0:Yt.prompt)=="string"?String(Yt.prompt):"",Vo=typeof(Yt==null?void 0:Yt.provider)=="string"?String(Yt.provider):"",ic=typeof(Yt==null?void 0:Yt.model)=="string"?String(Yt.model):"",Nl=typeof(Yt==null?void 0:Yt.workspace_root)=="string"?String(Yt.workspace_root):"",Cl=typeof(Yt==null?void 0:Yt.workspace_access_mode)=="string"?String(Yt.workspace_access_mode):"",oc=m.useMemo(()=>{const w=Yt==null?void 0:Yt.workspace_allowed_paths;return Array.isArray(w)?w.map($=>String($||"").trim()).filter(Boolean).join(`
|
|
135
|
+
`):typeof w=="string"?String(w):""},[Yt]),Gi=m.useMemo(()=>{const w=Yt==null?void 0:Yt.workspace_ignored_paths;return Array.isArray(w)?w.map($=>String($||"").trim()).filter(Boolean).join(`
|
|
136
|
+
`):typeof w=="string"?String(w):""},[Yt]),El=ii.length>0&&!!j.trim(),xa=w=>{const $=String(w||"").trim().toLowerCase();return $==="object"||$==="memory"||$==="assertion"||$==="assertions"||$==="any"};m.useEffect(()=>{cn({})},[j,v]),m.useEffect(()=>{Yt!==null&&Dn(w=>{const $={};for(const P of ii){if(!P||typeof P!="object")continue;const E=String(P.id||"").trim();if(!E)continue;const H=String(P.type||"").trim();if(!xa(H))continue;if(String(nn[E]||"").trim()){$[E]=typeof w[E]=="string"?w[E]:"";continue}const ae=Yt==null?void 0:Yt[E];ae===void 0?$[E]="":$[E]=Sm(ae)}return $})},[ii,Yt,nn]);const Yc=j.trim()&&v.trim()?`${j.trim()}:${v.trim()}`:"",Xc=m.useMemo(()=>{const w={};for(const $ of X){const P=String($.workflow_id||"").trim(),E=String($.label||"").trim();P&&E&&(w[P]=E)}return w},[X]),va=m.useMemo(()=>{const w=new Set;for(const $ of Array.isArray(he)?he:[]){const P=String(($==null?void 0:$.name)||"").trim();P&&w.add(P)}return Array.from(w).sort()},[he]),Kc=m.useMemo(()=>{const w=[];for(const $ of Array.isArray(he)?he:[]){const P=String(($==null?void 0:$.name)||"").trim();if(!P)continue;const E=String(($==null?void 0:$.display_name)||"").trim();w.push({name:P,display_name:E||void 0})}return w},[he]),Da=m.useMemo(()=>{const w=new Set;for(const $ of Z||[]){if(!$||typeof $!="object")continue;const P=String($.name||"").trim();P&&w.add(P)}return Array.from(w).sort()},[Z]),wa=m.useMemo(()=>{const w=r.maintenance_ai_provider.trim();if(!w)return{models:[],error:""};const $=se[w];return $?{models:(Array.isArray($.models)?$.models:[]).map(E=>String(E||"").trim()).filter(Boolean),error:String($.error||"")}:{models:[],error:""}},[se,r.maintenance_ai_provider]),In=r.maintenance_ai_provider.trim(),$l=!!(In&&K&&!Object.prototype.hasOwnProperty.call(se,In));m.useEffect(()=>{const w=Vo.trim();if(!w||se[w]||ts.current[w])return;ts.current[w]=!0;let $=!1;return(async()=>{try{const E=await jt.discovery_provider_models(w);if($)return;const H=Array.isArray(E==null?void 0:E.models)?E.models:[],Q=typeof(E==null?void 0:E.error)=="string"?String(E.error):"";ve(ae=>({...ae,[w]:{models:H,error:Q||void 0}}))}catch(E){if($)return;ve(H=>({...H,[w]:{models:[],error:String((E==null?void 0:E.message)||E||"Failed to load models")}}))}finally{delete ts.current[w]}})(),()=>{$=!0}},[Vo,se,jt]),m.useEffect(()=>{const w=r.maintenance_ai_provider.trim();if(!w||!K||se[w]||ts.current[w])return;ts.current[w]=!0;let $=!1;return(async()=>{try{const E=await jt.discovery_provider_models(w);if($)return;const H=Array.isArray(E==null?void 0:E.models)?E.models:[],Q=typeof(E==null?void 0:E.error)=="string"?String(E.error):"";ve(ae=>({...ae,[w]:{models:H,error:Q||void 0}}))}catch(E){if($)return;ve(H=>({...H,[w]:{models:[],error:String((E==null?void 0:E.message)||E||"Failed to load models")}}))}finally{delete ts.current[w]}})(),()=>{$=!0}},[r.maintenance_ai_provider,se,jt,K]);function Xn(w,$){const P=String(w||"").trim();if(!P)return;let E={};try{const H=JSON.parse(T||"{}");typeof H=="object"&&H!==null&&!Array.isArray(H)&&(E=H)}catch{E={}}if($==null){delete E[P],M(JSON.stringify(E,null,2));return}if(typeof $=="string"){const H=String($||"").trim();H?E[P]=H:delete E[P]}else if(Array.isArray($)){const H=$.map(Q=>Q).filter(Q=>Q!=null);H.length?E[P]=H:delete E[P]}else E[P]=$;M(JSON.stringify(E,null,2))}async function qo(w){const $=String(w||"").trim();if(!$)return oe("Missing bundle_id"),null;oe(""),ne(!0);try{const P=await jt.get_bundle($);return I(P),He({ts:hn(),kind:"info",title:`Loaded bundle ${$}`}),P}catch(P){return I(null),oe(String((P==null?void 0:P.message)||P||"Failed to load bundle")),null}finally{ne(!1)}}function Ba(w){const $=[],P=Array.isArray(w==null?void 0:w.items)?w.items:[];for(const E of P){const H=String((E==null?void 0:E.bundle_id)||"").trim();if(!H)continue;const Q=Array.isArray(E==null?void 0:E.entrypoints)?E.entrypoints:[];if(Q.length)for(const ae of Q){const re=String((ae==null?void 0:ae.flow_id)||"").trim();if(!re)continue;const Le=`${H}:${re}`,ye=String((ae==null?void 0:ae.name)||"").trim(),Be=ye?`${H} · ${ye}`:`${H} · ${re}`,vt=String((ae==null?void 0:ae.description)||"").trim();$.push({workflow_id:Le,bundle_id:H,flow_id:re,label:Be,description:vt||void 0})}}return $.sort((E,H)=>E.label.localeCompare(H.label)),$}async function Go(){if(!z){F(!0);try{const w=await jt.list_runs({limit:200,root_only:!0}),P=(Array.isArray(w==null?void 0:w.items)?w.items:[]).map(E=>{var H,Q,ae,re,Le,ye;return{run_id:String((E==null?void 0:E.run_id)||"").trim(),workflow_id:typeof(E==null?void 0:E.workflow_id)=="string"?String(E.workflow_id):(E==null?void 0:E.workflow_id)??null,status:typeof(E==null?void 0:E.status)=="string"?String(E.status):"",created_at:typeof(E==null?void 0:E.created_at)=="string"?String(E.created_at):(E==null?void 0:E.created_at)??null,updated_at:typeof(E==null?void 0:E.updated_at)=="string"?String(E.updated_at):(E==null?void 0:E.updated_at)??null,ledger_len:typeof(E==null?void 0:E.ledger_len)=="number"?Number(E.ledger_len):(E==null?void 0:E.ledger_len)??null,parent_run_id:typeof(E==null?void 0:E.parent_run_id)=="string"?String(E.parent_run_id):(E==null?void 0:E.parent_run_id)??null,session_id:typeof(E==null?void 0:E.session_id)=="string"?String(E.session_id):(E==null?void 0:E.session_id)??null,is_scheduled:typeof(E==null?void 0:E.is_scheduled)=="boolean"?!!E.is_scheduled:(E==null?void 0:E.is_scheduled)??null,paused:typeof(E==null?void 0:E.paused)=="boolean"?!!E.paused:(E==null?void 0:E.paused)??null,waiting_reason:typeof((H=E==null?void 0:E.waiting)==null?void 0:H.reason)=="string"?String(E.waiting.reason):((Q=E==null?void 0:E.waiting)==null?void 0:Q.reason)??null,schedule_interval:typeof((ae=E==null?void 0:E.schedule)==null?void 0:ae.interval)=="string"?String(E.schedule.interval).trim():((re=E==null?void 0:E.schedule)==null?void 0:re.interval)??null,schedule_target_workflow_id:typeof((Le=E==null?void 0:E.schedule)==null?void 0:Le.target_workflow_id)=="string"?String(E.schedule.target_workflow_id).trim():((ye=E==null?void 0:E.schedule)==null?void 0:ye.target_workflow_id)??null}}).filter(E=>!!E.run_id).filter(E=>!String(E.parent_run_id||"").trim());k(P)}catch(w){He({ts:hn(),kind:"error",title:"Refresh runs failed",preview:an(String((w==null?void 0:w.message)||w||""))})}finally{F(!1)}}}async function bo(){var w,$,P,E;$e(""),U(!1),_e(!0);try{const H=String(r.gateway_url||"").trim();if(H){const ye=H.toLowerCase();if(!ye.startsWith("http://")&&!ye.startsWith("https://"))throw new Error("Gateway URL must start with http:// or https:// (or leave it blank to use same origin / dev proxy).");try{if(String(((w=window==null?void 0:window.location)==null?void 0:w.protocol)||"")==="https:"&&ye.startsWith("http://"))throw new Error("Gateway URL is http:// but this page is https:// (mixed content is blocked). Use https:// or leave Gateway URL blank to use same origin /api proxy.");const vt=new URL(H),ut=String((($=window==null?void 0:window.location)==null?void 0:$.hostname)||"").trim().toLowerCase(),mt=String(vt.hostname||"").trim().toLowerCase(),Ct=ot=>ot==="localhost"||ot==="127.0.0.1"||ot==="::1";if(Ct(mt)&&ut&&!Ct(ut))throw new Error("Gateway URL points to localhost, which from this device is not your machine. Use the gateway's public URL (e.g. an ngrok https URL) or leave Gateway URL blank to use same origin /api proxy.")}catch(Be){throw new Error(String((Be==null?void 0:Be.message)||Be||"Invalid Gateway URL"))}}const Q=await jt.list_bundles(),ae=Ba(Q);V(ae);try{await Go()}catch(ye){k([]),He({ts:hn(),kind:"error",title:"Discovery runs failed",preview:an(String((ye==null?void 0:ye.message)||ye||""))})}const[re,Le]=await Promise.allSettled([jt.discovery_tools(),jt.discovery_providers({include_models:!1})]);if(re.status==="fulfilled"){const ye=Array.isArray((P=re.value)==null?void 0:P.items)?re.value.items:[];te(ye)}else te([]),He({ts:hn(),kind:"error",title:"Discovery tools failed",preview:an(String(re.reason||""))});if(Le.status==="fulfilled"){const ye=Array.isArray((E=Le.value)==null?void 0:E.items)?Le.value.items:[];Ae(ye)}else Ae([]),He({ts:hn(),kind:"error",title:"Discovery providers failed",preview:an(String(Le.reason||""))});ve({}),U(!0),He({ts:hn(),kind:"info",title:"Gateway discovery loaded",preview:an(`workflows: ${ae.length}`)})}catch(H){$e(String((H==null?void 0:H.message)||H||"Discovery failed"))}finally{_e(!1)}}async function Ua(){if(!(N||le)){B(!0);try{await jt.reload_bundles();const w=await jt.list_bundles(),$=Ba(w);V($),He({ts:hn(),kind:"info",title:"Bundles reloaded",preview:an(`workflows: ${$.length}`)})}catch(w){const $=String((w==null?void 0:w.message)||w||"Bundle reload failed");He({ts:hn(),kind:"error",title:"Bundle reload failed",preview:an($),data:{error:$}})}finally{B(!1)}}}async function Yo(w){if(Ne||le||!K)return;const $=w;if($){$t(!0),nt("");try{const P=await jt.upload_bundle($,{overwrite:!1,reload:!0});He({ts:hn(),kind:"info",title:"Bundle uploaded",preview:an(String((P==null?void 0:P.bundle_ref)||""))});const E=await jt.list_bundles(),H=Ba(E);V(H)}catch(P){const E=String((P==null?void 0:P.message)||P||"Upload failed");nt(E),He({ts:hn(),kind:"error",title:"Upload .flow failed",preview:an(E),data:{error:E}})}finally{$t(!1);try{pt.current&&(pt.current.value="")}catch{}}}}function Al(){ba(),S(""),b(""),_o(""),I(null),oe(""),ne(!1),V([]),k([]),te([]),Ae([]),ve({}),$e(""),U(!1),He({ts:hn(),kind:"info",title:"Gateway disconnected"})}async function C(w){const $=String(w??"");if($){try{await navigator.clipboard.writeText($),Wt("Copied to clipboard",2);return}catch{}try{const P=document.createElement("textarea");P.value=$,P.style.position="fixed",P.style.left="-9999px",P.style.top="0",P.style.opacity="0",document.body.appendChild(P),P.focus(),P.select(),document.execCommand("copy"),document.body.removeChild(P),Wt("Copied to clipboard",2)}catch{Wt("Copy failed",2)}}}m.useEffect(()=>{const w=c.trim();if(!Re||!w)return;let $=!1;const P=async()=>{try{const H=await jt.get_run(w);$||Et(H)}catch{}};P();const E=window.setInterval(P,2e3);return()=>{$=!0,window.clearInterval(E)}},[Re,c,jt]);const W=m.useMemo(()=>{const w=xe==null?void 0:xe.session_id;return typeof w=="string"?w.trim():w==null?"":String(w||"").trim()},[xe]),O=m.useMemo(()=>{const w=String(W||"").trim();return w||String(D||"").trim()},[W,D]);m.useEffect(()=>{if(!K||!O){Vs(""),rn("");return}(async()=>{try{const w=await Hg(O);Vs(w)}catch{Vs("")}})()},[K,O]);const fe=x_({gateway:K?jt:null,session_id:O,run_id:Er,on_error:rn,on_transcript:w=>{const $=String(w||"").trim();$&&(pr(P=>{const E=String(P||"");return E.trim()?`${E.trimEnd()}
|
|
137
|
+
${$}`:$}),window.setTimeout(()=>{var P;return(P=$r.current)==null?void 0:P.focus()},0))}});function Se(w,$){try{const P=URL.createObjectURL(w),E=document.createElement("a");E.href=P,E.download=$||"download",E.rel="noreferrer",document.body.appendChild(E),E.click(),document.body.removeChild(E),window.setTimeout(()=>URL.revokeObjectURL(P),5e3)}catch{}}async function et(){if(!fo){if(!K||!W){co(""),uo([]),Gs("");return}mo(!0),Gs("");try{const w=await Hg(W);co(w);const $=await jt.list_run_artifacts(w,{limit:800}),E=(Array.isArray($==null?void 0:$.items)?$.items:[]).filter(H=>{const Q=H==null?void 0:H.tags;return Q&&typeof Q=="object"&&String(Q.kind||"").trim()==="attachment"});uo(E)}catch(w){const $=String((w==null?void 0:w.message)||w||"Failed to load session attachments"),P=$.toLowerCase();$.includes("404")||P.includes("session_memory_")&&P.includes("not found")||P.includes('"detail"')&&P.includes("not found")&&P.includes("session_memory_")?(uo([]),Gs("")):(uo([]),Gs($)),co("")}finally{mo(!1)}}}async function Ye(w){const $=String(Rs||"").trim();if(!$){Wt("No session attachment store yet",2);return}const P=String((w==null?void 0:w.artifact_id)||"").trim();if(!P)return;const E=w!=null&&w.tags&&typeof w.tags=="object"?w.tags:{},H=String(E.filename||"").trim(),Q=String(E.path||"").trim(),ae=H||(Q?Q.split("/").pop():"")||P,re=Vg(ae);try{const Le=await jt.download_run_artifact_content($,P);Se(Le,re),Wt("Downloaded attachment",2)}catch(Le){Wt(String((Le==null?void 0:Le.message)||Le||"Download failed"),3)}}async function Ze(w){const $=String(Rs||"").trim(),P=String((w==null?void 0:w.artifact_id)||"").trim();if(!$||!P)return;const E=w!=null&&w.tags&&typeof w.tags=="object"?w.tags:{},H=String(E.filename||"").trim(),Q=String(E.path||"").trim(),ae=Q?`@${Q}`:H||P,re=typeof(w==null?void 0:w.size_bytes)=="number"?Number(w.size_bytes):null,Le=String((w==null?void 0:w.content_type)||E.content_type||"").trim().toLowerCase();if(Oo(ae),po(""),Ls(""),ho(!0),typeof re=="number"&&re>1e6){po(`(Attachment is ${re.toLocaleString()} bytes; download to view.)`);return}if(!(!Le||Le.startsWith("text/")||Le.includes("json")||Le.includes("yaml")||Le.includes("toml")||Le.includes("xml"))){po(`(Binary attachment: ${Le||"unknown"}; download to view.)`);return}fa(!0);try{const vt=await(await jt.download_run_artifact_content($,P)).text(),ut=14e3,mt=vt.length>ut?`${vt.slice(0,Math.max(0,ut-1))}…`:vt;po(mt)}catch(Be){Ls(String((Be==null?void 0:Be.message)||Be||"Preview failed"))}finally{fa(!1)}}m.useEffect(()=>{et()},[jt,K,W]);function He(w){const $=String(w.id||"").trim()||Xr();De(P=>[{...w,id:$},...P].slice(0,800))}function Wt(w,$){Hs(w),ur.current&&window.clearTimeout(ur.current),Me(!1),window.requestAnimationFrame(()=>Me(!0)),ur.current=window.setTimeout(()=>{Me(!1),ur.current=null},1500),Bn.current&&(window.clearTimeout(Bn.current),Bn.current=null),$>0&&(Bn.current=window.setTimeout(()=>{Hs(""),Bn.current=null},Math.max(1,$)*1e3))}function xn(w,$){const P=String(w||"").trim(),E=String($||"").trim();if(!E)return"";const H=P?String(pa.current[P]||"").trim():"";return H?`${H}::${E}`:E}function Fn(w,$,P){const E=String(w||"").trim(),H=String($||"").trim(),Q=String(P||"").trim();if(!E||!H||!Q)return;const ae=xn(E,H);ae&&(pa.current[Q]=ae,ri.current[Q]=E,ga.current[Q]={parent_run_id:E,parent_node_id:H},Hi.current.has(Q)||(Hi.current.add(Q),Vi(re=>re.includes(Q)?re:[...re,Q])))}function $n(w){const $=String(w||"").trim();if(!$)return;const P=Date.now(),E=ds.current;ds.current=$,Uo(P),Wo(H=>{const Q={};for(const[ye,Be]of Object.entries(H))typeof Be=="number"&&Be>P&&(Q[ye]=Be);Q[$]=Math.max(Q[$]||0,P+2e3),E&&E!==$&&(Q[E]=Math.max(Q[E]||0,P+2e3));const ae=Object.keys(Q);if(ae.length<=200)return Q;const re=ae.sort((ye,Be)=>(Q[Be]||0)-(Q[ye]||0)).slice(0,200),Le={};for(const ye of re)Le[ye]=Q[ye]||0;return Le}),ha(H=>{if(typeof H[$]=="number")return H;const Q={...H,[$]:P};if(Wi.current.push($),Wi.current.length>8e3){const ae=Wi.current.splice(0,1500);for(const re of ae)delete Q[re]}return Q}),Mr.current&&window.clearTimeout(Mr.current),Mr.current=window.setTimeout(()=>{const H=Date.now();Wo(Q=>{const ae={};for(const[re,Le]of Object.entries(Q))typeof Le=="number"&&Le>H&&(ae[re]=Le);return ae}),Uo(H),Mr.current=null},2200)}function Ks(w){var mt,Ct;lt.current=w.cursor,tt(ot=>[...ot,{cursor:w.cursor,record:w.record}]),c.trim()&&ms.current.add(`${c.trim()}:${w.cursor}`);const $=Nd(w.record),P=$&&$.name?zu($.name):"",E=w.record,H=typeof(E==null?void 0:E.node_id)=="string"?E.node_id:"",Q=typeof(E==null?void 0:E.status)=="string"?E.status:"",ae=typeof((mt=E==null?void 0:E.effect)==null?void 0:mt.type)=="string"?E.effect.type:"",re=typeof(E==null?void 0:E.run_id)=="string"?E.run_id:"",Le=re||c.trim();if(P==="abstract.status"&&Le===c.trim()){const{text:ot,duration:kt}=Lc($==null?void 0:$.payload);Wt(ot,kt)}const ye=H?xn(Le,H):"";if(Q==="waiting"){const ot=ul(E);if(String((ot==null?void 0:ot.reason)||"").trim()==="subworkflow"){const mn=typeof((Ct=ot==null?void 0:ot.details)==null?void 0:Ct.sub_run_id)=="string"?String(ot.details.sub_run_id):"";mn&&H&&Fn(Le,H,mn)}}if(H&&($n(xn(Le,H)),Q==="waiting"||Q==="running")){const ot=xn(Le,H);ot&&(ds.current=ot,Ps(ot))}let Be="step",vt=ye||H||"(node?)",ut="";if($&&$.name&&km($.name))Be=P==="abstract.message"?"message":"event",vt=P||$.name,ut=an(Lc($==null?void 0:$.payload).text);else if(E!=null&&E.error)Be="error",vt="error",ut=an(aa(E.error,360));else if(Q==="waiting"){const ot=ul(E),kt=String((ot==null?void 0:ot.reason)||"").trim();ut=an(kt?`waiting • ${kt}`:"waiting")}else E!=null&&E.result?ut=an(aa(E.result,360)):ae?ut=an(ae):ut=an(Nm(E));He({id:`step:${re||c.trim()||"?"}:${w.cursor}`,ts:String((E==null?void 0:E.ended_at)||(E==null?void 0:E.started_at)||hn()),kind:Be,title:vt,preview:ut,data:E,cursor:w.cursor,run_id:re||c.trim()||void 0,node_id:ye||H,status:Q,effect_type:ae,emit_name:P||($==null?void 0:$.name)||void 0})}function Ss(w,$){var Ct,ot;xo.current=Math.max(xo.current,$.cursor);const P=`${w}:${$.cursor}`;if(!!ms.current.has(P))return;ms.current.add(P),Oe(kt=>[...kt,{run_id:w,cursor:$.cursor,record:$.record}]);const H=Nd($.record),Q=H&&H.name?zu(H.name):"",ae=$.record,re=typeof(ae==null?void 0:ae.node_id)=="string"?ae.node_id:"",Le=re?xn(w,re):"",ye=typeof(ae==null?void 0:ae.status)=="string"?ae.status:"",Be=typeof((Ct=ae==null?void 0:ae.effect)==null?void 0:Ct.type)=="string"?ae.effect.type:"";if(ye==="waiting"){const kt=ul(ae);if(String((kt==null?void 0:kt.reason)||"").trim()==="subworkflow"){const on=typeof((ot=kt==null?void 0:kt.details)==null?void 0:ot.sub_run_id)=="string"?String(kt.details.sub_run_id):"";on&&re&&Fn(w,re,on),on&&ps.current.trim()===String(w||"").trim()&&(ps.current=on,Vn(on))}}if(re&&($n(xn(w,re)),ye==="waiting"||ye==="running")){const kt=xn(w,re);kt&&(ds.current=kt,Ps(kt))}if((ye==="completed"||ye==="failed")&&ps.current.trim()===String(w||"").trim()){const kt=String(ri.current[String(w||"").trim()]||"").trim();kt&&kt!==c.trim()?(ps.current=kt,Vn(kt)):(ps.current="",Vn(""))}if(Q==="abstract.status"&&w===c.trim()){const{text:kt,duration:mn}=Lc(H==null?void 0:H.payload);Wt(kt,mn)}let vt="step",ut=Le||re||"(node?)",mt="";if(H&&H.name&&km(H.name))vt=Q==="abstract.message"?"message":"event",ut=`subrun • ${Q||H.name}`,mt=an(Lc(H==null?void 0:H.payload).text);else if(ae!=null&&ae.error)vt="error",ut="error",mt=an(aa(ae.error,360));else if(ye==="waiting"){const kt=ul(ae),mn=String((kt==null?void 0:kt.reason)||"").trim();mt=an(mn?`waiting • ${mn}`:"waiting")}else ae!=null&&ae.result?mt=an(aa(ae.result,360)):Be?mt=an(Be):mt=an(Nm(ae));He({id:`step:${w}:${$.cursor}`,ts:String((ae==null?void 0:ae.ended_at)||(ae==null?void 0:ae.started_at)||hn()),kind:vt,title:ut,preview:mt,data:ae,cursor:$.cursor,run_id:w,node_id:Le||re,status:ye,effect_type:Be,emit_name:Q||(H==null?void 0:H.name)||""})}function Yi(w,$){var ot,kt;const P=String(w||"").trim();if(!P)return;const E=`${P}:${$.cursor}`;if(!!ms.current.has(E))return;ms.current.add(E),Oe(mn=>[...mn,{run_id:P,cursor:$.cursor,record:$.record}]);const Q=Nd($.record),ae=Q&&Q.name?zu(Q.name):"",re=$.record,Le=typeof(re==null?void 0:re.node_id)=="string"?re.node_id:"",ye=Le?xn(P,Le):"",Be=typeof(re==null?void 0:re.status)=="string"?re.status:"",vt=typeof((ot=re==null?void 0:re.effect)==null?void 0:ot.type)=="string"?re.effect.type:"";if(Be==="waiting"){const mn=ul(re);if(String((mn==null?void 0:mn.reason)||"").trim()==="subworkflow"){const Ve=typeof((kt=mn==null?void 0:mn.details)==null?void 0:kt.sub_run_id)=="string"?String(mn.details.sub_run_id):"";Ve&&Le&&Fn(P,Le,Ve)}}if(Le&&($n(xn(P,Le)),Be==="waiting"||Be==="running")){const mn=xn(P,Le);mn&&(ds.current=mn,Ps(mn))}if(ae==="abstract.status"&&P===c.trim()){const{text:mn,duration:on}=Lc(Q==null?void 0:Q.payload);Wt(mn,on)}let ut="step",mt=ye||Le||"(node?)",Ct="";if(Q&&Q.name&&km(Q.name))ut=ae==="abstract.message"?"message":"event",mt=`subrun • ${ae||Q.name}`,Ct=an(Lc(Q==null?void 0:Q.payload).text);else if(re!=null&&re.error)ut="error",mt="error",Ct=an(aa(re.error,360));else if(Be==="waiting"){const mn=ul(re),on=String((mn==null?void 0:mn.reason)||"").trim();Ct=an(on?`waiting • ${on}`:"waiting")}else re!=null&&re.result?Ct=an(aa(re.result,360)):vt?Ct=an(vt):Ct=an(Nm(re));He({id:`step:${P}:${$.cursor}`,ts:String((re==null?void 0:re.ended_at)||(re==null?void 0:re.started_at)||hn()),kind:ut,title:mt,preview:Ct,data:re,cursor:$.cursor,run_id:P,node_id:ye||Le,status:Be,effect_type:vt,emit_name:ae||(Q==null?void 0:Q.name)||""})}async function Is(w,$){let P=$.after;for(;;){const E=await jt.get_ledger(w,{after:P,limit:200}),H=Array.isArray(E.items)?E.items:[];if(!H.length)return lt.current=P,P;const Q=P;for(let ae=0;ae<H.length;ae++){const re=H[ae];Ks({cursor:Q+ae+1,record:re})}P=typeof E.next_after=="number"?E.next_after:P}}async function _r(w){var Q,ae;const $=String(w||"").trim();nt(""),de(!0),Qe(!1),tt([]),lt.current=0,Oe([]),ms.current=new Set,De([]),At({}),Lt({}),Tr("steps"),_i(""),Hs(""),Et(null),Yn(""),Ps(""),ds.current="",Wo({}),ha({}),Wi.current=[],Uo(Date.now()),pa.current=$?{[$]:""}:{},ri.current={},ga.current={},Hi.current=new Set,Vi([]),Cn.current="",ps.current="",Vn(""),si.current={},Mr.current&&window.clearTimeout(Mr.current),Mr.current=null,Gn.current&&window.clearTimeout(Gn.current),Gn.current=null,lr.current&&lr.current.abort(),nr.current&&nr.current.abort(),nr.current=null,xo.current=0,Xs("");const P=new AbortController;lr.current=P;let E=!1;try{let re="",Le="";try{const ye=await jt.get_run($);Et(ye);const Be=typeof(ye==null?void 0:ye.workflow_id)=="string"?String(ye.workflow_id):"",vt=jm(Be);vt&&(re=vt.bundle_id,Le=vt.flow_id)}catch{}try{const ye=await jt.get_run_input_data($);typeof(ye==null?void 0:ye.bundle_id)=="string"&&(re=String(ye.bundle_id||"").trim()||re),typeof(ye==null?void 0:ye.flow_id)=="string"&&(Le=String(ye.flow_id||"").trim()||Le);const Be=ye&&typeof ye.input_data=="object"&&ye.input_data&&!Array.isArray(ye.input_data)?ye.input_data:null;Be&&M(JSON.stringify(Be,null,2))}catch{}re&&Le&&(S(re),b(Le),_o(Le),await qo(re)),await Is($,{after:0});try{const ye=await jt.get_run_history_bundle($,{include_subruns:!0,include_session:!1,ledger_mode:"tail",ledger_max_items:1}),Be=ye&&typeof ye=="object"?ye.ledgers:null,ut=(Be&&typeof Be=="object"?Object.keys(Be):[]).map(mt=>String(mt||"").trim()).filter(Boolean).filter(mt=>mt!==$);if(ut.length){for(const mt of ut)Hi.current.add(mt);Vi(mt=>Array.from(new Set([...mt,...ut])));try{const mt=typeof((Q=Be==null?void 0:Be[$])==null?void 0:Q.total)=="number"?Number(Be[$].total):0;let Ct="",ot=-1;for(const kt of ut){const mn=typeof((ae=Be==null?void 0:Be[kt])==null?void 0:ae.total)=="number"?Number(Be[kt].total):0;mn>ot&&(Ct=kt,ot=mn)}Ct&&ot>Math.max(mt*3,mt+20)&&(ps.current=Ct,Vn(Ct))}catch{}}}catch{}Qe(!0),He({ts:hn(),kind:"info",title:`Attached to run ${$}`,data:{run_id:$}}),E=!0}catch(re){const Le=String((re==null?void 0:re.message)||re||"unknown error");nt(Le),He({ts:hn(),kind:"error",title:"Connection error",preview:an(Le),data:{error:Le}}),Qe(!1)}finally{de(!1)}if(!E||P.signal.aborted)return;(async()=>{let re=250;for(;!P.signal.aborted;){try{const Le=await Is($,{after:lt.current});await jt.stream_ledger($,{after:Le,on_step:Ks,signal:P.signal})}catch(Le){if(P.signal.aborted)break;const ye=String((Le==null?void 0:Le.message)||Le||"stream error");He({ts:hn(),kind:"error",title:"Ledger stream error (will retry)",preview:an(ye),data:{error:ye}})}if(P.signal.aborted)break;await new Promise(Le=>setTimeout(Le,re)),re=Math.min(5e3,Math.floor(re*1.6))}})()}async function wi(){const w=v.trim(),$=j.trim();if(!w||!$){const P="Select a workflow first (Start Workflow → pick a workflow).";return nt(P),P}nt(""),de(!0);try{let P={};const E=T.trim();if(E)try{if(P=JSON.parse(E),typeof P!="object"||P===null||Array.isArray(P))throw new Error("input_data must be a JSON object")}catch(ye){const Be=`Invalid input_data JSON: ${String((ye==null?void 0:ye.message)||ye)}`;return nt(Be),Be}const H=(ii||[]).find(ye=>ye&&typeof ye=="object"&&ye.id==="prompt"),Q=H&&typeof H=="object"&&Object.prototype.hasOwnProperty.call(H,"default"),ae=P==null?void 0:P.prompt,re=typeof ae=="string"?ae.trim():"";if(H&&!Q&&!re){const ye="Missing required input_data.prompt";return nt(ye),ye}const Le=await jt.start_run(w,P,{bundle_id:$,session_id:String(D||"").trim()||null});return _(Le),d(Le),sn(""),await _r(Le),Go(),null}catch(P){const E=String((P==null?void 0:P.message)||P||"start failed");return nt(E),E}finally{de(!1)}}async function yr(w){const $=v.trim(),P=j.trim();if(!$||!P){const E="Select a workflow first (Start Workflow → pick a workflow).";return nt(E),E}if(je)return"Schedule already in progress";Xt(""),nt(""),ue(!0),de(!0);try{let E={};const H=T.trim();if(H)try{if(E=JSON.parse(H),typeof E!="object"||E===null||Array.isArray(E))throw new Error("input_data must be a JSON object")}catch(Ke){const xt=`Invalid input_data JSON: ${String((Ke==null?void 0:Ke.message)||Ke)}`;return Xt(xt),xt}const Q=(ii||[]).find(Ke=>Ke&&typeof Ke=="object"&&Ke.id==="prompt"),ae=Q&&typeof Q=="object"&&Object.prototype.hasOwnProperty.call(Q,"default"),re=E==null?void 0:E.prompt,Le=typeof re=="string"?re.trim():"";if(Q&&!ae&&!Le){const Ke="Missing required input_data.prompt";return Xt(Ke),Ke}let ye=null,Be=null;if(w.start_mode==="now")ye="now",Be=new Date;else{const Ke=String(w.start_at_local||"").trim();if(!Ke){const tn="Pick a start date/time (or choose 'now').";return Xt(tn),tn}const xt=new Date(Ke);if(!Number.isFinite(xt.getTime())){const tn="Invalid start date/time";return Xt(tn),tn}ye=xt.toISOString(),Be=new Date(ye)}const vt=Number.isFinite(w.every_n)?w.every_n:1,ut=Math.max(1,Math.min(1e4,Math.floor(vt))),mt=String(w.every_unit||"").trim();let Ct="1d";mt==="minutes"?Ct=`${ut}m`:mt==="hours"?Ct=`${ut}h`:mt==="days"?Ct=`${ut}d`:mt==="weeks"?Ct=`${ut*7}d`:mt==="months"&&(Ct=`${ut*30}d`);const ot=w.repeat_mode,kt=ot==="once"?null:Ct,mn=ot==="count"?Math.max(1,Math.floor(Number.isFinite(w.repeat_count)?w.repeat_count:1)):null;let on=null;if(ot==="until"){const Ke=String(w.repeat_until_date_local||"").trim(),xt=String(w.repeat_until_time_local||"").trim()||"23:59";if(!Ke){const Tt="Pick an end date (Until).";return Xt(Tt),Tt}const tn=new Date(`${Ke}T${xt}`);if(!Number.isFinite(tn.getTime())){const Tt="Invalid end date/time";return Xt(Tt),Tt}if(on=tn.toISOString(),Be&&Number.isFinite(Be.getTime())&&tn.getTime()<Be.getTime()){const Tt="End date must be after the start date.";return Xt(Tt),Tt}}const Ve=await jt.schedule_run({bundle_id:P,flow_id:$,input_data:E,start_at:ye,interval:kt,repeat_count:mn,repeat_until:on,share_context:!!w.share_context,session_id:String(D||"").trim()||null});return _(Ve),d(Ve),Xt(""),await _r(Ve),Go(),null}catch(E){const H=String((E==null?void 0:E.message)||E||"schedule failed");return Xt(H),nt(H),H}finally{de(!1),ue(!1)}}async function qn(){sn(""),Xt("");const $=vn!=="now"||Zn!=="once"?await yr({start_mode:vn,start_at_local:cr,repeat_mode:Zn,every_n:Un,every_unit:ke,repeat_count:it,repeat_until_date_local:zt,repeat_until_time_local:Ot,share_context:It}):await wi();$&&sn($)}async function Wa(w){const $=String(w||"").trim();$&&(nt(""),_($),d($),await _r($))}m.useEffect(()=>{const w=String(g||"").trim();if(!w)return;let $=!1;return(async()=>{try{if(K||await bo(),$)return;await Wa(w)}catch(P){$||nt(String((P==null?void 0:P.message)||P||"Failed to attach run from URL"))}finally{$||x("")}})(),()=>{$=!0}},[g]);function ba(){lr.current&&lr.current.abort(),lr.current=null,nr.current&&nr.current.abort(),nr.current=null,xo.current=0,Xs(""),d(""),_(""),pa.current={},ri.current={},ga.current={},Hi.current=new Set,Vi([]),Cn.current="",ps.current="",Vn(""),si.current={},Yn(""),Mr.current&&window.clearTimeout(Mr.current),Mr.current=null,Gn.current&&window.clearTimeout(Gn.current),Gn.current=null,Qe(!1),de(!1),Fe(!1),lt.current=0,tt([]),Oe([]),ms.current=new Set,Et(null),De([]),At({}),Ps(""),ds.current="",Wo({}),ha({}),Wi.current=[],Uo(Date.now()),Wt("",-1),nt(""),_a(!1),qi(""),Br([]),pr(""),Cr(""),tr(!1),Ur(!1),Zr(""),gr(""),Wr(""),Fi([]),Oi(!1),Ms(""),Hr(""),Di(!1),Ar("")}m.useEffect(()=>{Br([]),pr(""),Cr(""),tr(!1),Ur(!1),Zr(""),gr(""),Wr(""),Fi([]),Oi(!1),Ms(""),Hr(""),Di(!1),Ar("")},[c]),m.useEffect(()=>{yn==="chat"&&c.trim()&&K&&Xi()},[yn,c,K,xe==null?void 0:xe.workflow_id]);async function oi(w,$){const P=c.trim();if(!P)return nt("Missing run_id"),"Missing run_id";nt("");try{const E={},H=String(($==null?void 0:$.reason)||"").trim();H&&(E.reason=H),await jt.submit_command({command_id:Xr(),run_id:P,type:w,payload:E,client_id:"web_pwa"}),He({ts:hn(),kind:"info",title:`${w} submitted`,preview:H?`reason: ${H}`:"",data:{type:w,reason:H}});try{const Q=await jt.get_run(P);Et(Q)}catch{}return null}catch(E){const H=String((E==null?void 0:E.message)||E||`${w} failed`);return nt(H),H}}async function Tl(){var P;const w=c.trim();if(!w){nt("Select a run first.");return}if(!K){nt("Connect to the gateway first.");return}if(be)return;const $=String(((P=xe==null?void 0:xe.waiting)==null?void 0:P.reason)||"").trim().toLowerCase()||String(qr||"").trim().toLowerCase();if(!Rr||ki||Js||ji.toLowerCase()!=="waiting"||$!=="until"){nt("This run is not a scheduled wait that can be triggered now.");return}nt(""),Fe(!0);try{const E={payload:{mode:"run_now",requested_at:hn()}},H=String(bi||"").trim();H&&(E.wait_key=H),await jt.submit_command({command_id:Xr(),run_id:w,type:"resume",payload:E,client_id:"web_pwa"}),He({ts:hn(),kind:"info",title:"Scheduled run triggered",preview:an(`run ${w}`),data:{run_id:w,until:Si||null}});try{const Q=await jt.get_run(w);Et(Q)}catch{}}catch(E){nt(String((E==null?void 0:E.message)||E||"Failed to trigger scheduled run"))}finally{Fe(!1)}}async function Ha(w){const $=c.trim();if(!$)return nt("Missing run_id"),"Missing run_id";if(Nn)return"Schedule update already in progress";const P=String(w.interval||"").trim();if(!/^\s*(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)\s*$/i.test(P)){const H="Invalid interval (expected like '20m', '1h', '0.5s', '250ms')";return kn(H),H}kn(""),nt(""),ar(!0),de(!0);try{await jt.submit_command({command_id:Xr(),run_id:$,type:"update_schedule",payload:{interval:P,apply_immediately:w.apply_immediately!==!1},client_id:"web_pwa"}),He({ts:hn(),kind:"info",title:"Schedule updated",preview:an(`interval: ${P}`),data:{interval:P},run_id:$});try{const H=await jt.get_run($);Et(H)}catch{}return null}catch(H){const Q=String((H==null?void 0:H.message)||H||"update_schedule failed");return kn(Q),nt(Q),Q}finally{de(!1),ar(!1)}}async function ac(w){const $=c.trim();if(!$)return nt("Missing run_id"),"Missing run_id";if(Jr)return"Compaction already in progress";const P=typeof(w==null?void 0:w.preserve_recent)=="number"?w.preserve_recent:Fr,E=Math.max(0,Math.min(500,Math.floor(Number.isFinite(P)?P:6))),H=(w==null?void 0:w.compression_mode)||Es,Q=String((w==null?void 0:w.focus)??Ri??"").trim();us(""),nt(""),Or(!0),de(!0);try{const ae={preserve_recent:E,compression_mode:H};return Q&&(ae.focus=Q),await jt.submit_command({command_id:Xr(),run_id:$,type:"compact_memory",payload:ae,client_id:"web_pwa"}),He({ts:hn(),kind:"info",title:"Compaction requested",preview:an(`mode: ${H} • preserve_recent: ${E}`),data:ae,run_id:$}),null}catch(ae){const re=String((ae==null?void 0:ae.message)||ae||"compact_memory failed");return us(re),nt(re),re}finally{de(!1),Or(!1)}}async function Jc(){const w=c.trim();if(!w){qi("Missing run_id");return}if(!xi){qi(""),_a(!0);try{const $=r.maintenance_ai_provider.trim(),P=r.maintenance_ai_model.trim();await jt.generate_run_summary(w,{provider:$||void 0,model:P||void 0,include_subruns:!0}),He({ts:hn(),kind:"info",title:"Summary generation requested",preview:an(`run ${w}`)})}catch($){qi(String(($==null?void 0:$.message)||$||"Failed to generate summary"))}finally{_a(!1)}}}async function Va(){const w=c.trim();if(!w){Cr("Select a run first.");return}if(!K){Cr("Connect to the gateway first.");return}const $=er.trim();if(!$||$s)return;if(fe.voice_ptt_busy){rn("Wait for transcription to finish.");return}Cr(""),rn(""),tr(!0);const E={id:`local:${Xr()}`,role:"user",content:$,ts:hn()};Br(H=>[...H,E]),pr("");try{const H=[...Ln,E].slice(-20).map(Be=>({role:Be.role,content:Be.content})),Q=r.maintenance_ai_provider.trim(),ae=r.maintenance_ai_model.trim(),re=await jt.run_chat(w,{provider:Q||void 0,model:ae||void 0,include_subruns:!0,messages:H}),Le=String((re==null?void 0:re.answer)||"").trim()||"(empty response)",ye=String((re==null?void 0:re.generated_at)||"").trim()||hn();Br(Be=>[...Be,{id:`local:${Xr()}`,role:"assistant",content:Le,ts:ye}])}catch(H){Cr(String((H==null?void 0:H.message)||H||"Chat failed")),Br(Q=>[...Q,{id:`local:${Xr()}`,role:"assistant",content:"(error: failed to generate answer)",ts:hn()}])}finally{tr(!1)}}function Xo(w){const $=String(w.id||w.ts||"").trim(),P=String(w.content||"").trim();!$||!P||(rn(""),fe.toggle_tts($,P))}function Kn(w){const $=String(w.id||w.ts||"").trim(),P=fe.tts_playback;return!$||!P.key||P.key!==$?"idle":P.status}function Wn(w){if(!Ln.length)return;const $=c.trim(),P=$?`Run ${$}`:"Chat",E=wv(Ln.map(H=>({role:H.role,content:H.content,ts:H.ts})),{heading:P});if(w==="download"){const H=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-"),Q=`abstractobserver-chat-${Vg($||"run")}-${H}.md`;bv({filename:Q,text:E,mime:"text/markdown;charset=utf-8"});return}(async()=>{const H=await Ns(E);gi(H?"copied":"failed"),window.setTimeout(()=>gi("idle"),900)})()}async function Xi(){const w=typeof(xe==null?void 0:xe.workflow_id)=="string"?String(xe.workflow_id).trim():"";if(!w){Fi([]);return}if(K&&!Ts){Ms(""),Oi(!0);try{const $=await jt.list_runs({limit:200,workflow_id:w,root_only:!0}),P=Array.isArray($==null?void 0:$.items)?$.items:[],E=[];for(const ye of P){const Be=typeof(ye==null?void 0:ye.run_id)=="string"?String(ye.run_id).trim():"";if(!Be)continue;const vt=typeof(ye==null?void 0:ye.ledger_len)=="number"?Number(ye.ledger_len):0;E.push({run_id:Be,ledger_len:Number.isFinite(vt)?vt:0})}if(!E.length){Fi([]);return}const H=400,Q=E.map(ye=>({run_id:ye.run_id,after:Math.max(0,(ye.ledger_len||0)-H)})),ae=await jt.get_ledger_batch({runs:Q,limit:H}),re=[],Le=new Set;for(const ye of E){const Be=ae!=null&&ae.runs&&typeof ae.runs=="object"?ae.runs[ye.run_id]:null,vt=Array.isArray(Be==null?void 0:Be.items)?Be.items:[];for(const ut of vt){const mt=ut==null?void 0:ut.effect;if(!mt||typeof mt!="object"||String(mt.type||"")!=="emit_event")continue;const Ct=mt.payload;if(!Ct||typeof Ct!="object"||String(Ct.name||"")!=="abstract.chat.thread")continue;const ot=Ct.payload;if(!ot||typeof ot!="object")continue;const kt=typeof ot.thread_id=="string"?String(ot.thread_id).trim():"";if(!kt||Le.has(kt))continue;Le.add(kt);const mn=typeof ot.created_at=="string"?String(ot.created_at):"",on=typeof ot.title=="string"?String(ot.title):"",Ve=typeof ot.workflow_id=="string"?String(ot.workflow_id):w,Ke=typeof ot.run_id=="string"?String(ot.run_id):ye.run_id,xt=typeof ot.provider=="string"?String(ot.provider):"",tn=typeof ot.model=="string"?String(ot.model):"",Tt=typeof ot.message_count=="number"?Number(ot.message_count):null,Hn=ot.chat_artifact,Ds=Hn&&typeof Hn=="object"&&typeof Hn.$artifact=="string"?String(Hn.$artifact):"";Ds&&re.push({thread_id:kt,created_at:mn,title:on||`Chat ${kt.slice(0,8)}`,run_id:Ke,workflow_id:Ve,message_count:Tt,provider:xt,model:tn,artifact_id:Ds})}}re.sort((ye,Be)=>String(Be.created_at||"").localeCompare(String(ye.created_at||""))),Fi(re)}catch($){Ms(String(($==null?void 0:$.message)||$||"Failed to load saved discussions"))}finally{Oi(!1)}}}async function gs(){const w=c.trim();if(!w){Zr("Select a run first.");return}if(!K){Zr("Connect to the gateway first.");return}if(Ln.length&&!Qr){Zr(""),Ur(!0);try{const $=r.maintenance_ai_provider.trim(),P=r.maintenance_ai_model.trim(),E=await jt.save_chat_thread(w,{provider:$||void 0,model:P||void 0,include_subruns:!0,messages:Ln.map(ae=>({role:ae.role,content:ae.content,ts:ae.ts}))}),H=typeof(E==null?void 0:E.created_at)=="string"?String(E.created_at):hn();gr(H);try{const ae=JSON.stringify(Ln.map(re=>({role:re.role,content:re.content,ts:re.ts})));Wr(ae)}catch{Wr("1")}typeof(E==null?void 0:E.thread_id)=="string"&&String(E.thread_id).trim()&&Hr(String(E.thread_id).trim());const Q=!!(E!=null&&E.duplicate);Wt(Q?"Already saved":"Saved discussion",2),await Xi()}catch($){Zr(String(($==null?void 0:$.message)||$||"Failed to save discussion"))}finally{Ur(!1)}}}async function Fs(){const w=String(qs||"").trim();if(!w)return;const $=Ii.find(H=>String(H.thread_id||"").trim()===w)||null;if(!$){Ar("Saved discussion not found (refresh list).");return}if(!K){Ar("Connect to the gateway first.");return}if(zs)return;const P=Ln.length>0,E=(()=>{if(!P)return!1;if(!Pi)return!0;try{return JSON.stringify(Ln.map(Q=>({role:Q.role,content:Q.content,ts:Q.ts})))!==Pi}catch{return!0}})();if(!(P&&E&&!window.confirm("Replace the current chat with the selected saved discussion? Unsaved changes will be lost."))){Ar(""),Di(!0);try{const Q=await(await jt.download_run_artifact_content($.run_id,$.artifact_id)).text(),ae=JSON.parse(Q),re=Array.isArray(ae==null?void 0:ae.messages)?ae.messages:[],Le=typeof(ae==null?void 0:ae.created_at)=="string"?String(ae.created_at):String($.created_at||""),ye=[];for(let Be=0;Be<re.length;Be++){const vt=re[Be];if(!vt||typeof vt!="object")continue;const ut=String(vt.role||"").trim()==="assistant"?"assistant":"user",mt=typeof vt.content=="string"?String(vt.content):"";if(!mt.trim())continue;const Ct=typeof vt.ts=="string"?String(vt.ts):Le||hn();ye.push({id:`thread:${w}:${Be}`,role:ut,content:mt.trim(),ts:Ct})}Br(ye),pr(""),Cr(""),Zr(""),gr(Le||"");try{const Be=JSON.stringify(ye.map(vt=>({role:vt.role,content:vt.content,ts:vt.ts})));Wr(Be)}catch{Wr("1")}Wt("Loaded discussion",2)}catch(H){Ar(String((H==null?void 0:H.message)||H||"Failed to load saved discussion"))}finally{Di(!1)}}}async function So(w){const $=c.trim(),P=String((gn==null?void 0:gn.wait_key)||"").trim();if(!$||!P){nt("No active wait to resume");return}if(String((gn==null?void 0:gn.reason)||"").trim()==="subworkflow"){nt("This run is waiting on a subworkflow; attach to the child run instead of resuming manually.");return}nt(""),Fe(!0);try{await jt.submit_command({command_id:Xr(),run_id:$,type:"resume",payload:{wait_key:P,payload:w||{}},client_id:"web_pwa"}),He({ts:hn(),kind:"info",title:"Resume submitted",preview:an(`wait_key: ${P}`),data:{wait_key:P,payload:w||{}}}),Yn(P),Gn.current&&window.clearTimeout(Gn.current),Gn.current=window.setTimeout(()=>{Yn(E=>E===P?"":E)},2e3)}catch(E){nt(String((E==null?void 0:E.message)||E||"resume failed"))}finally{Fe(!1)}}async function qa(w){if(!ya){nt("No worker configured");return}if(!be){nt(""),Fe(!0);try{const $=[];for(const P of w){const E=await ya.call_tool(P);$.push(E)}await So({mode:"executed",results:$})}finally{Fe(!1)}}}const rs=m.useMemo(()=>m_(gn),[gn]),bi=String((gn==null?void 0:gn.wait_key)||"").trim(),qr=String((gn==null?void 0:gn.reason)||"").trim(),Si=typeof(gn==null?void 0:gn.until)=="string"?String(gn.until):"",lc=qr==="until"&&!!Si,cc=x1(Vr)&&(!!bi||lc),jo=qr==="user",Ga=qr==="event"?zu(f1(bi)):"",Qc=qr==="event"&&Ga==="abstract.ask",Qu=rs.length>0,pf=cc&&bi&&(jo||Qc||Qu)&&Ge!==bi,Os=typeof((Qs=gn==null?void 0:gn.details)==null?void 0:Qs.sub_run_id)=="string"?String(gn.details.sub_run_id):"",ji=typeof(xe==null?void 0:xe.status)=="string"?String(xe.status):"",Js=!!(xe!=null&&xe.paused),ki=ji==="completed"||ji==="failed"||ji==="cancelled",_s=xe!=null&&xe.schedule&&typeof xe.schedule=="object"?xe.schedule:null,ss=typeof(_s==null?void 0:_s.interval)=="string"?String(_s.interval).trim():"",ai=typeof(_s==null?void 0:_s.share_context)=="boolean"?!!_s.share_context:null,Ko=typeof(_s==null?void 0:_s.repeat_count)=="number"?Number(_s.repeat_count):null,Rr=!!(xe!=null&&xe.is_scheduled)||!!_s||typeof(xe==null?void 0:xe.workflow_id)=="string"&&String(xe.workflow_id).startsWith("scheduled:"),Ni=Rr&&!!ss,Jo=Rr?Js?"Resume schedule":"Suspend schedule":ji==="running"&&!Js?"Pause":"Resume",Zc=Rr?Js?"resume":"pause":Jo==="Pause"?"pause":"resume",eu=Rr?!c.trim()||Pe||be||ki:!c.trim()||Pe||be||ki||Zc==="resume"&&!Js,tu=Rr&&!Js&&!ki&&!Pe&&!be&&ji.toLowerCase()==="waiting"&&(String(((Zo=xe==null?void 0:xe.waiting)==null?void 0:Zo.reason)||"").trim().toLowerCase()==="until"||qr==="until")&&!!String(Si||"").trim(),Jn=(pc=xe==null?void 0:xe.limits)==null?void 0:pc.tokens,is=typeof(Jn==null?void 0:Jn.pct)=="number"?Number(Jn.pct):null,Qn=Jn==null?void 0:Jn.estimated_used,li=(Jn==null?void 0:Jn.max_input_tokens)??(Jn==null?void 0:Jn.max_tokens),Ht=m.useMemo(()=>{var on;const w={};for(const Ve of Z||[]){if(!Ve||typeof Ve!="object")continue;const Ke=String(Ve.name||"").trim();Ke&&(w[Ke]=Ve)}const $=Ve=>{const Ke=w[String(Ve||"").trim()],xt=Ke&&typeof Ke=="object"?Ke.toolset:"";return typeof xt=="string"?xt.trim():""},P=Ve=>Ve==null?"":typeof Ve=="boolean"?Ve?"true":"false":typeof Ve=="number"?String(Ve):typeof Ve=="string"?an(Ve,{max_chars:160,max_lines:2}):an(aa(Ve,160),{max_chars:160,max_lines:2}),E=(Ve,Ke)=>{const xt=String(Ve||"").trim(),tn=Ke&&typeof Ke=="object"?Ke:{},Tt=w[xt],Hn=Tt&&typeof Tt=="object"?Tt.parameters:null,Ds=Object.keys(Hn&&typeof Hn=="object"?Hn:tn),Ai=[],ui=new Set;for(const vr of Ds)typeof vr!="string"||!vr.trim()||ui.has(vr)||(ui.add(vr),Object.prototype.hasOwnProperty.call(tn,vr)&&Ai.push([vr,tn[vr]]));for(const vr of Object.keys(tn))ui.has(vr)||Ai.push([vr,tn[vr]]);return Ai},H=(Ve,Ke)=>{const xt=E(Ve,Ke);return xt.length?P(xt[0][1]):""},Q=(Ve,Ke)=>{const xt=String(Ve||"").trim()||"tool",Tt=E(xt,Ke).slice(0,2);if(!Tt.length)return`${xt}()`;if(Tt.length===1)return`${xt}(${P(Tt[0][1])})`;const Hn=Tt.map(([Ds,Ai])=>`${Ds}=${P(Ai)}`).join(", ");return`${xt}(${Hn})`},ae=Ve=>{var bc,uu,du;const Ke={steps:Ve.length,tool_calls_effects:0,tool_calls:0,unique_tools:0,llm_calls:0,llm_missing_responses:0,prompt_tokens:0,completion_tokens:0,total_tokens:0,started_at:"",ended_at:"",duration_s:0,errors:0},xt=[],tn=[],Tt=[],Hn=new Set,Ds=[],Ai=[];let ui=null,vr=null;const td=gt=>{if(!gt||typeof gt!="object")return"";const Co=gt.prompt;if(typeof Co=="string"&&Co.trim())return Co.trim();const Na=gt.messages;if(Array.isArray(Na))for(let Qi=Na.length-1;Qi>=0;Qi--){const Zi=Na[Qi];if(!Zi||typeof Zi!="object"||String(Zi.role||"")!=="user")continue;const Ca=Zi.content;if(typeof Ca=="string"&&Ca.trim())return Ca.trim()}return""},nd=gt=>gt==null?"":typeof gt=="string"?an(gt,{max_chars:2400,max_lines:32}):an(Sm(gt),{max_chars:2400,max_lines:32});for(const gt of Ve){const Co=typeof(gt==null?void 0:gt.run_id)=="string"?String(gt.run_id):"",Na=typeof(gt==null?void 0:gt.node_id)=="string"?String(gt.node_id):"",Qi=String((gt==null?void 0:gt.ended_at)||(gt==null?void 0:gt.started_at)||"").trim(),Zi=fl(Qi);Zi!==null&&((ui===null||Zi<ui)&&(ui=Zi),(vr===null||Zi>vr)&&(vr=Zi)),gt!=null&>.error&&(Ke.errors+=1);const Ca=typeof((bc=gt==null?void 0:gt.effect)==null?void 0:bc.type)=="string"?String(gt.effect.type):"";if(Ca==="llm_call"){Ke.llm_calls+=1;const Tn=(uu=gt==null?void 0:gt.effect)==null?void 0:uu.payload,wr=gt!=null&>.result&&typeof gt.result=="object"?gt.result.usage||gt.result.token_usage:null;let Gr=0,eo=0,to=0;wr&&typeof wr=="object"&&(Gr=Number(wr.prompt_tokens??wr.input_tokens??0),eo=Number(wr.completion_tokens??wr.output_tokens??0),to=Number(wr.total_tokens??Gr+eo),Number.isFinite(Gr)&&(Ke.prompt_tokens+=Gr),Number.isFinite(eo)&&(Ke.completion_tokens+=eo),Number.isFinite(to)&&(Ke.total_tokens+=to));const Zs=Tn&&typeof Tn=="object"&&typeof Tn.provider=="string"?String(Tn.provider):"",Ol=Tn&&typeof Tn=="object"&&typeof Tn.model=="string"?String(Tn.model):"",na=td(Tn),Eo=gt!=null&>.result&&typeof gt.result=="object"&&typeof gt.result.content=="string"?String(gt.result.content):gt!=null&>.result&&typeof gt.result=="object"&&typeof gt.result.response=="string"?String(gt.result.response):typeof(gt==null?void 0:gt.result)=="string"?String(gt.result):"",ra=!String(Eo||"").trim();ra&&(Ke.llm_missing_responses+=1),Ai.length<80&&Ai.push({ts:Qi,run_id:Co,node_id:Na,provider:Zs,model:Ol,prompt_preview:an(na,{max_chars:1800,max_lines:24}),response_preview:an(String(Eo||""),{max_chars:1800,max_lines:24}),missing_response:ra,tokens:{prompt:Number.isFinite(Gr)?Gr:0,completion:Number.isFinite(eo)?eo:0,total:Number.isFinite(to)?to:0}})}if(Ca!=="tool_calls")continue;Ke.tool_calls_effects+=1;const Sc=(du=gt==null?void 0:gt.effect)==null?void 0:du.payload,fu=Sc&&typeof Sc=="object"?Sc.tool_calls:null,Ea=Array.isArray(fu)?fu:[];if(!Ea.length)continue;Ke.tool_calls+=Ea.length;const rd=gt!=null&>.result&&typeof gt.result=="object"?gt.result.results:null,mu=Array.isArray(rd)?rd:[],jc=new Map;for(const Tn of mu){if(!Tn||typeof Tn!="object")continue;const wr=String(Tn.call_id||Tn.id||"").trim();wr&&!jc.has(wr)&&jc.set(wr,Tn)}for(let Tn=0;Tn<Ea.length;Tn++){const wr=Ea[Tn];if(!wr||typeof wr!="object")continue;const Gr=String(wr.name||"").trim();if(!Gr)continue;Hn.add(Gr);const eo=wr.arguments,to=String(wr.call_id||wr.id||"").trim(),Zs=to&&jc.has(to)?jc.get(to):Tn<mu.length?mu[Tn]:null,Ol=Zs&&typeof Zs=="object"&&typeof Zs.success=="boolean"?!!Zs.success:null,na=Zs&&typeof Zs=="object"?Zs.output:null,Eo=Zs&&typeof Zs=="object"?Zs.error:null;Ds.length<240&&Ds.push({ts:Qi,run_id:Co,node_id:Na,name:Gr,signature:Q(Gr,eo),success:Ol,output_preview:nd(na),error:typeof Eo=="string"||Eo?String(Eo):""});const ra=$(Gr),Za=H(Gr,eo);ra==="files"&&Za?xt.push({tool:Gr,file_path:Za,run_id:Co,ts:Qi}):ra==="system"&&Za?tn.push({command:Za,run_id:Co,ts:Qi}):ra==="web"&&Za&&Tt.push({tool:Gr,value:Za,run_id:Co,ts:Qi})}}return Ke.unique_tools=Hn.size,ui!==null&&(Ke.started_at=new Date(ui).toISOString()),vr!==null&&(Ke.ended_at=new Date(vr).toISOString()),ui!==null&&vr!==null&&(Ke.duration_s=Math.max(0,Math.round((vr-ui)/1e3))),{stats:Ke,files:xt,commands:tn,web:Tt,tools_used:Array.from(Hn).sort(),tool_calls_detail:Ds,llm_calls_detail:Ai}},re=[],Le={},ye=c.trim(),Be=Ve=>{if(!Ve)return;re.push(Ve);const xt=(typeof(Ve==null?void 0:Ve.run_id)=="string"?String(Ve.run_id||"").trim():"")||ye||"unknown";Le[xt]||(Le[xt]=[]),Le[xt].push(Ve)};for(const Ve of Xe)Ve&&Ve.record&&Be(Ve.record);for(const Ve of ze)Ve&&Ve.record&&Be(Ve.record);const vt=ae(re),ut={};for(const[Ve,Ke]of Object.entries(Le))ut[Ve]=ae(Ke);const mt=fs.map(Ve=>{const Ke=String(Ve||"").trim();if(!Ke)return null;const xt=String(ri.current[Ke]||"").trim(),tn=ga.current[Ke],Tt=tn?String(tn.parent_node_id||"").trim():"";return{run_id:Ke,parent_run_id:xt,parent_node_id:Tt,digest:ut[Ke]||null}}).filter(Boolean);mt.sort((Ve,Ke)=>Ve.run_id<Ke.run_id?-1:Ve.run_id>Ke.run_id?1:0);let Ct=null;for(const Ve of Xe){const Ke=Ve.record,xt=Nd(Ke);if((xt&&xt.name?zu(xt.name):"")!=="abstract.summary")continue;const Tt=xt!=null&&xt.payload&&typeof xt.payload=="object"?xt.payload:{},Hn=typeof(Tt==null?void 0:Tt.text)=="string"?String(Tt.text):"";Hn.trim()&&(Ct={cursor:Ve.cursor,ts:String((Ke==null?void 0:Ke.ended_at)||(Ke==null?void 0:Ke.started_at)||""),text:Hn,provider:typeof(Tt==null?void 0:Tt.provider)=="string"?String(Tt.provider):void 0,model:typeof(Tt==null?void 0:Tt.model)=="string"?String(Tt.model):void 0,generated_at:typeof(Tt==null?void 0:Tt.generated_at)=="string"?String(Tt.generated_at):void 0,source:Tt==null?void 0:Tt.source})}const ot=Ct?fl(Ct.generated_at||Ct.ts):null;let kt=null;for(const Ve of re){if((typeof((on=Ve==null?void 0:Ve.effect)==null?void 0:on.type)=="string"?String(Ve.effect.type):"")==="emit_event")continue;const xt=String((Ve==null?void 0:Ve.ended_at)||(Ve==null?void 0:Ve.started_at)||"").trim(),tn=fl(xt);tn!==null&&(kt===null||tn>kt)&&(kt=tn)}const mn=ot!==null&&kt!==null?kt>ot:!1;return{overall:vt,per_run:ut,subruns:mt,latest_summary:Ct,summary_outdated:mn}},[Xe,ze,c,fs,Z]);m.useEffect(()=>{ps.current=hs.trim()},[hs]),m.useEffect(()=>{const w=c.trim(),$=Os.trim();if(!(Re&&qr==="subworkflow"&&!!$&&$!==w)){Cn.current="",hs.trim()&&Vn("");return}Cn.current!==$&&(Cn.current=$,ps.current=$,Vn($))},[Re,c,qr,Os,hs]),m.useEffect(()=>{Fa({})},[j]);const nu=m.useMemo(()=>((Array.isArray(L==null?void 0:L.entrypoints)?L==null?void 0:L.entrypoints:[])||[]).map($=>String(($==null?void 0:$.flow_id)||"").trim()).filter(Boolean),[L]),Ci=m.useMemo(()=>{const w=String((xe==null?void 0:xe.workflow_id)||"").trim();return Re&&w.startsWith("scheduled:")?w:""},[Re,xe==null?void 0:xe.workflow_id]),ru=m.useMemo(()=>{var ae;if(!Re||!c.trim()||!Ci.trim())return Ys;const w=String((xe==null?void 0:xe.status)||"").trim().toLowerCase(),$=String((xe==null?void 0:xe.current_node)||"").trim();if(w!=="waiting"&&w!=="running"||!$)return Ys;const P=xn(c.trim(),$);if(!P)return Ys;const E=String(qr||((ae=xe==null?void 0:xe.waiting)==null?void 0:ae.reason)||"").trim().toLowerCase(),H=typeof(Vr==null?void 0:Vr.node_id)=="string"?String(Vr.node_id).trim():"",Q=typeof(Vr==null?void 0:Vr.status)=="string"?String(Vr.status).trim().toLowerCase():"";return w==="waiting"&&E==="until"||!Ys.trim()||(Q==="waiting"||Q==="running")&&!H?P:Ys},[Re,c,Ci,xe==null?void 0:xe.status,xe==null?void 0:xe.current_node,(iu=xe==null?void 0:xe.waiting)==null?void 0:iu.reason,qr,Ys,Vr]),Zu=m.useMemo(()=>{const w={},$=c.trim(),P=(E,H)=>{if(!H)return;const Q=typeof(H==null?void 0:H.node_id)=="string"?String(H.node_id).trim():"";if(!Q)return;const ae=xn(E,Q);if(!ae)return;const re=String((H==null?void 0:H.ended_at)||(H==null?void 0:H.started_at)||"").trim(),Le=fl(re);Le!==null&&(w[ae]=Math.max(w[ae]||0,Le))};for(const E of Xe)E&&E.record&&P($,E.record);for(const E of ze)E&&E.record&&P(String(E.run_id||"").trim(),E.record);return w},[Xe,ze,c,fs]);m.useEffect(()=>{var P;if(!Re||!c.trim()||!Ci.trim())return;const w=String((xe==null?void 0:xe.current_node)||"").trim();!w||String(((P=xe==null?void 0:xe.waiting)==null?void 0:P.reason)||"").trim()==="subworkflow"||$n(xn(c.trim(),w))},[Re,c,Ci,xe==null?void 0:xe.current_node,(Ki=xe==null?void 0:xe.waiting)==null?void 0:Ki.reason]),m.useEffect(()=>{const w=String((zr==null?void 0:zr.flow_id)||"").trim();w&&(go.trim()||_o(w))},[zr,go]),m.useEffect(()=>{const w=Ci.trim(),$=j.trim(),P=go.trim();if(w){let H=!1;return Bo(!0),Ui(""),jt.get_workflow_flow(w).then(Q=>{if(H)return;const ae=Q==null?void 0:Q.flow;Do(ae&&typeof ae=="object"?ae:null)}).catch(Q=>{H||(Do(null),Ui(String((Q==null?void 0:Q.message)||Q||"Failed to load workflow flow")))}).finally(()=>{H||Bo(!1)}),()=>{H=!0}}if(!$||!P){Do(null),Ui(""),Bo(!1);return}let E=!1;return Bo(!0),Ui(""),jt.get_bundle_flow($,P).then(H=>{if(E)return;const Q=H==null?void 0:H.flow,ae=Q&&typeof Q=="object"?Q:null;Do(ae),ae&&Fa(re=>({...re,[P]:ae}))}).catch(H=>{E||(Do(null),Ui(String((H==null?void 0:H.message)||H||"Failed to load flow")))}).finally(()=>{E||Bo(!1)}),()=>{E=!0}},[Ci,j,go,jt]),m.useEffect(()=>{const w=j.trim();if(!yi||!w||!yo)return;let $=!1;const P=3,E=ye=>{const Be=Array.isArray(ye==null?void 0:ye.nodes)?ye.nodes:[],vt=[];for(const ut of Be){const mt=ut!=null&&ut.data&&typeof ut.data=="object"?ut.data:{};if(String((mt==null?void 0:mt.nodeType)||(ut==null?void 0:ut.type)||"").trim()!=="subflow")continue;const ot=(mt==null?void 0:mt.subflowId)||(mt==null?void 0:mt.flowId),kt=typeof ot=="string"?ot.trim():"";kt&&vt.push(kt.includes(":")?kt.split(":",2)[1]:kt)}return vt},H=new Set,Q=new Set,ae=(ye,Be)=>{if(!(!ye||Be>=P))for(const vt of E(ye)){const ut=String(vt||"").trim();if(!ut||H.has(ut))continue;H.add(ut),Q.add(ut);const mt=ma[ut];mt&&ae(mt,Be+1)}};ae(yo,0);const re=Array.from(Q).filter(ye=>!ma[ye]).slice(0,20);return re.length?((async()=>{for(const ye of re){if($)return;try{const Be=await jt.get_bundle_flow(w,ye),vt=Be==null?void 0:Be.flow,ut=vt&&typeof vt=="object"?vt:null;if(!ut)continue;Fa(mt=>mt[ye]?mt:{...mt,[ye]:ut})}catch{}}})(),()=>{$=!0}):void 0},[yi,j,yo,ma,jt]);const Ml=m.useMemo(()=>{const $=(Array.isArray(L==null?void 0:L.flows)?L==null?void 0:L.flows:[]).map(P=>String(P||"").trim()).filter(Boolean);return $.length?Array.from(new Set($)).sort():Array.from(new Set(nu)).sort()},[L,nu]);m.useEffect(()=>{ki&&Ys.trim()&&(Ps(""),ds.current="")},[ki,c,Ys]),m.useEffect(()=>{const w=hs.trim(),$=c.trim();if(!(Re&&!!w&&w!==$)){nr.current&&nr.current.abort(),nr.current=null,xo.current=0,ns&&Xs("");return}if(ns===w)return;nr.current&&nr.current.abort();const E=new AbortController;nr.current=E,xo.current=0,Xs(w),He({ts:hn(),kind:"info",title:`Following run ${w} (status/events)`});let H=250;return(async()=>{for(;!E.signal.aborted;){try{await jt.stream_ledger(w,{after:xo.current,on_step:ae=>Ss(w,ae),signal:E.signal});return}catch(ae){if(E.signal.aborted)break;const re=String((ae==null?void 0:ae.message)||ae||"stream error");He({ts:hn(),kind:"error",title:"Child ledger stream error (will retry)",preview:an(re),data:{child_run_id:w,error:re}})}if(E.signal.aborted)break;await new Promise(ae=>setTimeout(ae,H)),H=Math.min(5e3,Math.floor(H*1.6))}})(),()=>{E.abort()}},[Re,hs,c,jt,ns]),m.useEffect(()=>{if(!Re||!c.trim())return;let w=!1;const $=async()=>{if(!w&&!vo.current&&fs.length){vo.current=!0;try{const E=fs.map(re=>String(re||"").trim()).filter(Boolean);if(!E.length)return;const H=E.map(re=>({run_id:re,after:Number(si.current[re]||0)})),Q=await jt.get_ledger_batch({runs:H,limit:200}),ae=Q&&typeof Q=="object"?Q.runs:{};for(const re of E){if(w)return;const Le=ae&&typeof ae=="object"?ae[re]:null,ye=Array.isArray(Le==null?void 0:Le.items)?Le.items:[],Be=typeof(Le==null?void 0:Le.next_after)=="number"?Le.next_after:Number(si.current[re]||0),vt=Number(si.current[re]||0);for(let ut=0;ut<ye.length;ut++){const mt=ye[ut];Yi(re,{cursor:vt+ut+1,record:mt})}si.current[re]=Be}}catch(E){if(w)return;He({ts:hn(),kind:"error",title:"Subrun digest poll failed",preview:an(String((E==null?void 0:E.message)||E||""))})}finally{vo.current=!1}}};$();const P=window.setInterval(()=>void $(),2e3);return()=>{w=!0,window.clearInterval(P),vo.current=!1}},[Re,c,fs,jt]);const uc=m.useMemo(()=>fn?Ie.filter(g1):Ie,[fn,Ie]),Ei=m.useMemo(()=>{const w=c.trim(),$=[];for(const P of Xe)!P||!P.record||$.push({run_id:w,cursor:P.cursor,record:P.record});for(const P of ze)!P||!P.record||$.push({run_id:String(P.run_id||"").trim(),cursor:P.cursor,record:P.record});return $},[Xe,ze,c]),Ya=m.useMemo(()=>{var $,P,E;const w={};for(const H of Ei){const Q=String(H.run_id||(($=H.record)==null?void 0:$.run_id)||"").trim();!Q||String(((E=(P=H.record)==null?void 0:P.effect)==null?void 0:E.type)||"").trim()!=="llm_call"||(w[Q]=(w[Q]||0)+1)}return w},[Ei]),gf=m.useMemo(()=>{const w=hs.trim();if(w)return w;let $="",P=-1;for(const[E,H]of Object.entries(Ya))H>P&&($=E,P=H);return $||c.trim()},[Ya,hs,c]),ci=(bs.trim()||gf).trim(),Xa=m.useMemo(()=>{var H;const w=new Set,$=c.trim(),P=hs.trim();$&&w.add($),P&&w.add(P);for(const Q of fs){const ae=String(Q||"").trim();ae&&w.add(ae)}for(const Q of Ei){const ae=String(Q.run_id||((H=Q.record)==null?void 0:H.run_id)||"").trim();ae&&w.add(ae)}const E=Array.from(w);return E.sort((Q,ae)=>$&&Q===$&&ae!==$?-1:$&&ae===$&&Q!==$?1:P&&Q===P&&ae!==P?-1:P&&ae===P&&Q!==P?1:Q<ae?-1:Q>ae?1:0),E},[c,hs,fs,Ei]),dc=m.useMemo(()=>cv(Ei,{run_id:ci}),[Ei,ci]),ys=m.useMemo(()=>{const w=c.trim();return w&&J.find($=>String($.run_id||"").trim()===w)||null},[J,c]),Qo=String((xe==null?void 0:xe.status)||(ys==null?void 0:ys.status)||"").trim(),ed=String(qr||((ko=xe==null?void 0:xe.waiting)==null?void 0:ko.reason)||(ys==null?void 0:ys.waiting_reason)||"").trim().toLowerCase(),zl=!!(xe!=null&&xe.is_scheduled||ys!=null&&ys.is_scheduled),fc=!!(xe!=null&&xe.paused||ys!=null&&ys.paused),Sa=zl&&Qo.toLowerCase()==="waiting",mc=Sa&&ed==="until",hc=fl(Si),Rl=mc&&hc!==null?Gg(hc-Date.now()):"",su=zl&&fc?"Suspended":Sa?"Scheduled":Qo;return s.jsxs("div",{className:"app-shell",children:[s.jsxs("div",{className:"app-header",children:[s.jsxs("div",{className:"logo",title:"AbstractObserver (Web/PWA)",children:[s.jsx("span",{className:"logo-icon","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"4.2",transform:"rotate(-18 12 12)",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",opacity:"0.75"}),s.jsx("circle",{cx:"12",cy:"12",r:"4.7",fill:"currentColor",opacity:"0.95"}),s.jsx("circle",{cx:"10.3",cy:"10.7",r:"1.6",fill:"#ffffff",opacity:"0.18"}),s.jsx("circle",{cx:"19",cy:"13.6",r:"1.2",fill:"currentColor"})]})}),s.jsx("span",{className:"logo_name",children:"AbstractObserver"})]}),s.jsxs("div",{className:"app_nav",children:[s.jsx("button",{className:`nav_tab ${e==="observe"?"active":""}`,onClick:()=>t("observe"),children:"Observe"}),s.jsx("button",{className:`nav_tab ${e==="launch"?"active":""}`,onClick:()=>t("launch"),children:"Launch"}),s.jsx("button",{className:`nav_tab ${e==="mindmap"?"active":""}`,onClick:()=>t("mindmap"),children:"Mindmap"}),cl?s.jsx("button",{className:`nav_tab ${e==="backlog"?"active":""}`,onClick:()=>t("backlog"),children:"Backlog"}):null,s.jsx("button",{className:`nav_tab ${e==="inbox"?"active":""}`,onClick:()=>t("inbox"),children:"Inbox"})]}),s.jsxs("div",{className:"status_pills",children:[l?s.jsx("monitor-gpu",{ref:u,mode:"icon","history-size":"5","tick-ms":"1500","base-url":r.gateway_url,title:"GPU usage (host)",style:{"--monitor-gpu-width":"34px","--monitor-gpu-bars-height":"22px","--monitor-gpu-padding":"2px 4px","--monitor-gpu-radius":"999px","--monitor-gpu-bg":"rgba(0,0,0,0.22)","--monitor-gpu-border":"rgba(255,255,255,0.16)",flexShrink:0}}):null,cl?s.jsx("button",{className:`header_icon_btn ${e==="processes"?"active":""}`,title:"Processes","aria-label":"Processes",type:"button",onClick:()=>t("processes"),children:s.jsx(On,{name:"terminal",size:16})}):null,s.jsx("button",{className:`header_icon_btn ${e==="settings"?"active":""}`,title:"Settings","aria-label":"Settings",type:"button",onClick:()=>t("settings"),children:s.jsx(On,{name:"settings",size:16})}),s.jsx("span",{className:`gateway_led ${K?"ok":le?"warn":"err"}`,title:`Gateway: ${K?"connected":le?"connecting":"disconnected"}`,"aria-hidden":"true"})]})]}),s.jsxs("div",{className:"app-body",children:[e==="settings"?s.jsx("div",{className:"page page_scroll",children:s.jsx("div",{className:"page_inner constrained",children:s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"title",children:s.jsx("h1",{children:"Settings"})}),s.jsx("div",{className:"section_title",children:"Appearance"}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Theme"}),s.jsx(Rv,{value:r.theme,onChange:w=>o($=>({...$,theme:w}))}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:"Stored locally in this browser (no server round-trip)."})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Font size"}),s.jsx(Lv,{value:r.font_scale,onChange:w=>o($=>({...$,font_scale:w}))})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Header size"}),s.jsx(Pv,{value:r.header_density,onChange:w=>o($=>({...$,header_density:w}))})]}),s.jsx("div",{className:"section_title",children:"Gateway"}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Gateway URL (blank = same origin / dev proxy)"}),s.jsxs("div",{className:"field_inline",children:[s.jsx("input",{value:r.gateway_url,onChange:w=>o($=>({...$,gateway_url:w.target.value})),placeholder:"https://your-gateway-host"}),s.jsx("button",{className:"btn",onClick:K?Al:bo,disabled:le,children:le?"Connecting…":K?"Disconnect":"Connect"})]}),Te?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Te}):null]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Auto-connect to gateway on load"}),s.jsxs("select",{value:r.auto_connect_gateway?"on":"off",onChange:w=>o($=>({...$,auto_connect_gateway:w.target.value==="on"})),children:[s.jsx("option",{value:"on",children:"On"}),s.jsx("option",{value:"off",children:"Off"})]})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Gateway token (Authorization: Bearer …)"}),s.jsx("input",{type:"password",value:r.auth_token,onChange:w=>o($=>({...$,auth_token:w.target.value})),placeholder:"(optional for localhost dev)"})]}),s.jsx("div",{className:"section_title",children:"Maintenance AI"}),s.jsx(Mv,{className:"field",providerLabel:"Provider (blank = gateway default)",modelLabel:"Model (blank = gateway default)",providerPlaceholder:"lmstudio",modelPlaceholder:"qwen/qwen3-next-80b",provider:r.maintenance_ai_provider,model:r.maintenance_ai_model,providers:Kc,models:wa.models,loadingProviders:le,loadingModels:$l,modelError:In?wa.error:"",allowCustomProvider:!0,allowCustomModel:!0,allowGatewayDefault:!0,gatewayDefaultLabel:"(gateway default)",selectClassName:"mono",onChange:w=>o($=>({...$,maintenance_ai_provider:w.provider,maintenance_ai_model:w.model}))}),s.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Used for in-editor maintenance chat",cl?" and backlog AI assist":"",". Defaults follow `ABSTRACTGATEWAY_PROVIDER` / `ABSTRACTGATEWAY_MODEL`."]}),cl?s.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[s.jsx("label",{children:"Backlog advisor agent (bundle id; blank = basic-agent)"}),s.jsx("input",{className:"mono",value:r.backlog_advisor_agent,onChange:w=>o($=>({...$,backlog_advisor_agent:String(w.target.value||"")})),placeholder:"basic-agent"}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:"Used by Backlog → Advisor drawer. Must be a bundle available on the gateway (e.g. `basic-agent`, `advanced-agent`)."})]}):null,s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Remote Tool Worker (MCP)"}),s.jsxs("details",{children:[s.jsx("summary",{className:"mono muted",style:{cursor:"pointer"},children:"Advanced"}),s.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[s.jsx("label",{children:"Tool worker endpoint (MCP HTTP)"}),s.jsx("input",{className:"mono",value:r.worker_url,onChange:w=>o($=>({...$,worker_url:w.target.value})),placeholder:"https://your-mcp-worker-endpoint"})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Tool worker token (Authorization: Bearer …)"}),s.jsx("input",{className:"mono",type:"password",value:r.worker_token,onChange:w=>o($=>({...$,worker_token:w.target.value})),placeholder:"(optional)"})]}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Used to execute tool waits from the UI (advanced / potentially dangerous)."})]})]})})}):null,e==="launch"?s.jsx("div",{className:"page page_scroll",children:s.jsx("div",{className:"page_inner constrained",children:s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"title",children:s.jsx("h1",{children:"Launch"})}),K?null:s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(245, 158, 11, 0.35)"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"gateway"}),s.jsx("span",{className:"mono",children:hn()})]}),s.jsxs("div",{className:"body mono",children:["Not connected. Open"," ",s.jsx("button",{className:"btn",onClick:()=>t("settings"),children:"Settings"})," ","to connect to a gateway."]})]}),s.jsxs("div",{className:"launch_workflow_bar",children:[s.jsxs("select",{className:"launch_workflow_select",value:Yc,onChange:async w=>{const $=String(w.target.value||"").trim();if(!$)return;const P=jm($);P&&(S(P.bundle_id),b(P.flow_id),_o(P.flow_id),await qo(P.bundle_id))},disabled:le||!X.length,children:[s.jsx("option",{value:"",children:X.length?"(select workflow)":"(connect in Settings)"}),X.map(w=>s.jsx("option",{value:w.workflow_id,children:w.label},w.workflow_id))]}),s.jsx("input",{ref:pt,type:"file",accept:".flow",style:{display:"none"},onChange:w=>{const $=w.target.files&&w.target.files.length?w.target.files[0]:null;$&&Yo($)}}),s.jsx("button",{type:"button",className:"btn launch_btn_upload",onClick:()=>{var w;return(w=pt.current)==null?void 0:w.click()},disabled:!K||le||Ne||Pe||be,title:"Upload a .flow bundle",children:Ne?"…":"Upload"}),s.jsxs("button",{type:"button",className:"btn launch_btn_reload",onClick:()=>void Ua(),disabled:!K||le||N||Pe||be,title:"Reload picks up server-side edits",children:[s.jsx(On,{name:"refresh",size:14}),N?"…":"Reload"]})]}),s.jsxs("div",{className:"field",children:[zr!=null&&zr.description?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:String(zr.description)}):null,G?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading workflow…"}):null,Y?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Y}):null]}),s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Inputs"}),!j.trim()||!v.trim()?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Select a workflow above to configure inputs."}):Yt===null?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)",marginTop:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"input error"}),s.jsx("span",{className:"mono",children:hn()})]}),s.jsx("div",{className:"body mono",children:"Invalid input JSON. Fix it in Advanced JSON."})]}):El?s.jsx("div",{className:"launch_inputs",children:(()=>{const w=Pe||be,$=[],P=[];for(const Q of ii){if(!Q||typeof Q!="object")continue;const ae=String(Q.id||"").trim();if(!ae)continue;const re=String(Q.type||"").trim().toLowerCase();re==="tools"||re==="array"||xa(re)||ae==="prompt"||ae==="system"?$.push(Q):P.push(Q)}const E=Q=>String(Q||"").trim().replace(/_/g," ").replace(/\b\w/g,ae=>ae.toUpperCase()),H=(Q,ae)=>{const re=String(Q.id||"").trim();if(!re)return null;const Le=String(Q.label||re).trim()||re,ye=Le===re?E(re):Le,Be=String(Q.type||"").trim().toLowerCase(),vt=Object.prototype.hasOwnProperty.call(Q,"default"),ut=vt?Q.default:void 0,mt=vt?aa(ut,80):"",Ct=Yt==null?void 0:Yt[re],ot=vt?`${mt}`:"";if(Be==="tools"){const on=Array.isArray(Ct)?Ct.map(xt=>String(xt||"").trim()).filter(Boolean):[],Ve=Array.isArray(ut)?ut.map(xt=>String(xt||"").trim()).filter(Boolean):[],Ke=Array.from(new Set([...Da,...on,...Ve])).sort();return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ye}),s.jsx(w_,{options:Ke,value:on,disabled:w,placeholder:"(no tools selected)",onChange:xt=>Xn(re,xt)})]},re)}if(Be==="provider"){const on=typeof Ct=="string"?String(Ct):"";return s.jsxs("div",{className:ae||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ye}),s.jsxs("select",{value:on,onChange:Ve=>Xn(re,Ve.target.value),disabled:w,children:[s.jsx("option",{value:"",children:ot||"(select)"}),va.map(Ve=>s.jsx("option",{value:Ve,children:Ve},Ve))]})]},re)}if(Be==="model"){const on=typeof Ct=="string"?String(Ct):"",Ve=String((Yt==null?void 0:Yt.provider)||"").trim(),Ke=Ve?se[Ve]:void 0,xt=Ke&&Array.isArray(Ke.models)?Ke.models.map(tn=>String(tn||"").trim()).filter(Boolean):[];return s.jsxs("div",{className:ae||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ye}),xt.length?s.jsxs("select",{value:on,onChange:tn=>Xn(re,tn.target.value),disabled:w,children:[s.jsx("option",{value:"",children:ot||"(select)"}),xt.map(tn=>s.jsx("option",{value:tn,children:tn},tn))]}):s.jsx("input",{className:"mono",value:on,onChange:tn=>Xn(re,tn.target.value),placeholder:ot||"model id",disabled:w})]},re)}if(Be==="boolean"){const on=typeof Ct=="boolean"?Ct?"true":"false":"";return s.jsxs("div",{className:ae||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ye}),s.jsxs("select",{value:on,onChange:Ve=>{const Ke=String(Ve.target.value||"").trim();Ke?Xn(re,Ke==="true"):Xn(re,void 0)},disabled:w,children:[s.jsx("option",{value:"",children:ot||"(default)"}),s.jsx("option",{value:"true",children:"Yes"}),s.jsx("option",{value:"false",children:"No"})]})]},re)}if(Be==="number"){const on=typeof Ct=="number"&&Number.isFinite(Ct)?String(Ct):"";return s.jsxs("div",{className:ae||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ye}),s.jsx("input",{type:"number",value:on,onChange:Ve=>{const Ke=String(Ve.target.value||"").trim();if(!Ke){Xn(re,void 0);return}const xt=Number(Ke);Number.isFinite(xt)&&Xn(re,xt)},placeholder:ot,disabled:w})]},re)}if(Be==="array"){const on=Array.isArray(Ct)?Ct.map(Ve=>String(Ve||"").trim()).filter(Boolean).join(`
|
|
138
|
+
`):"";return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ye}),s.jsx("textarea",{className:"mono",value:on,onChange:Ve=>{const Ke=String(Ve.target.value||"").split(/\r?\n/g).map(xt=>String(xt||"").trim()).filter(Boolean);Xn(re,Ke.length?Ke:void 0)},placeholder:ot||"(one item per line)",rows:2,disabled:w})]},re)}if(xa(Be)){const on=typeof qt[re]=="string"?qt[re]:"",Ve=String(nn[re]||"").trim();return s.jsxs("div",{className:"launch_field_wide",children:[s.jsxs("label",{className:"launch_label",children:[ye," ",s.jsx("span",{className:"launch_label_type",children:Be})]}),s.jsx("textarea",{className:"mono",value:on,onChange:Ke=>{const xt=String(Ke.target.value??"");Dn(Tt=>({...Tt,[re]:xt}));const tn=xt.trim();if(!tn){cn(Tt=>{const Hn={...Tt};return delete Hn[re],Hn}),Xn(re,void 0);return}try{const Tt=JSON.parse(tn);cn(Hn=>{const Ds={...Hn};return delete Ds[re],Ds}),Xn(re,Tt)}catch(Tt){cn(Hn=>({...Hn,[re]:String((Tt==null?void 0:Tt.message)||Tt||"Invalid JSON")}))}},placeholder:ot||"{...}",rows:3,disabled:w}),Ve?s.jsx("div",{className:"launch_field_error",children:Ve}):null]},re)}const kt=typeof Ct=="string"?String(Ct):"";return re==="prompt"||re==="system"?s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ye}),s.jsx("textarea",{className:"mono",value:kt,onChange:on=>Xn(re,on.target.value),placeholder:ot||(re==="prompt"?"What should the agent do?":"System instructions (optional)"),rows:3,disabled:w})]},re):s.jsxs("div",{className:ae||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ye}),s.jsx("input",{className:"mono",value:kt,onChange:on=>Xn(re,on.target.value),placeholder:ot,disabled:w})]},re)};return $.sort((Q,ae)=>{const re={system:0,prompt:1,tools:2};return(re[String(Q.id||"")]??10)-(re[String(ae.id||"")]??10)}),s.jsxs(s.Fragment,{children:[$.map(Q=>H(Q)),P.length>0?s.jsx("div",{className:"launch_grid",children:P.map(Q=>H(Q,"launch_grid_cell"))}):null]})})()}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[s.jsx("label",{children:"Prompt (common)"}),s.jsx("textarea",{className:"mono",value:sc,onChange:w=>Xn("prompt",w.target.value),placeholder:"What do you want the workflow/agent to do?",rows:3,disabled:Pe||be})]}),s.jsxs("div",{className:"row",children:[s.jsx("div",{className:"col",children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Provider (common)"}),s.jsx("input",{className:"mono",value:Vo,onChange:w=>Xn("provider",w.target.value),placeholder:"lmstudio / ollama / openai / ...",disabled:Pe||be})]})}),s.jsx("div",{className:"col",children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Model (common)"}),s.jsx("input",{className:"mono",value:ic,onChange:w=>Xn("model",w.target.value),placeholder:"qwen/qwen3-next-80b / gpt-4.1 / ...",disabled:Pe||be})]})})]})]}),s.jsxs("details",{style:{marginTop:"10px"},children:[s.jsx("summary",{className:"mono muted",style:{cursor:"pointer"},children:"Workspace"}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Controls what the agent can access via filesystem tools."}),s.jsxs("div",{className:"launch_grid",style:{marginTop:"8px"},children:[s.jsxs("div",{className:"launch_grid_cell",style:{gridColumn:"1 / -1"},children:[s.jsx("label",{className:"launch_label",children:"Workspace Root"}),s.jsx("input",{className:"mono",value:Nl,onChange:w=>Xn("workspace_root",w.target.value),placeholder:"/path/to/workspace",disabled:Pe||be}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-xxs)"},children:"Empty = gateway default (isolated per-run workspace)"})]}),s.jsxs("div",{className:"launch_grid_cell",children:[s.jsx("label",{className:"launch_label",children:"Access Mode"}),s.jsxs("select",{className:"mono",value:(Cl||"workspace_only").trim()||"workspace_only",onChange:w=>Xn("workspace_access_mode",w.target.value),disabled:Pe||be,children:[s.jsx("option",{value:"workspace_only",children:"workspace_only"}),s.jsx("option",{value:"workspace_or_allowed",children:"workspace_or_allowed"}),s.jsx("option",{value:"all_except_ignored",children:"all_except_ignored"})]}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-xxs)"},children:"workspace_only: absolute paths must stay under root. workspace_or_allowed: allow additional roots."})]})]}),(Cl||"").trim()==="workspace_or_allowed"?s.jsxs("div",{className:"field",style:{marginTop:"8px"},children:[s.jsx("label",{className:"launch_label",children:"Allowed Paths"}),s.jsx("textarea",{className:"mono",rows:3,value:oc,onChange:w=>Xn("workspace_allowed_paths",w.target.value),placeholder:`/path/to/project
|
|
139
|
+
/path/to/workspace`,disabled:Pe||be,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off"}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-xxs)"},children:"Newline-separated directories (absolute or relative to workspace_root)"})]}):null,s.jsxs("div",{className:"field",style:{marginTop:"8px"},children:[s.jsx("label",{className:"launch_label",children:"Ignored Paths"}),s.jsx("textarea",{className:"mono",rows:3,value:Gi,onChange:w=>Xn("workspace_ignored_paths",w.target.value),placeholder:`node_modules
|
|
140
|
+
runtime
|
|
141
|
+
secret`,disabled:Pe||be,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off"}),s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-xxs)"},children:"Newline-separated paths to block (absolute or relative to workspace_root)"})]})]}),s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Schedule"}),ln?s.jsxs("div",{className:"observe_context_card error",style:{marginTop:"6px"},children:[s.jsx("span",{className:"chip mono danger",children:"error"}),s.jsx("span",{className:"mono",children:ln})]}):null,s.jsxs("div",{className:"sched_grid",children:[s.jsxs("div",{className:"sched_cell",children:[s.jsx("label",{className:"launch_label",children:"Start"}),s.jsxs("div",{className:"sched_radio_row",children:[s.jsxs("label",{className:"sched_radio",children:[s.jsx("input",{type:"radio",name:"schedule_start",checked:vn==="now",onChange:()=>Sn("now")}),s.jsx("span",{children:"Now"})]}),s.jsxs("label",{className:"sched_radio",children:[s.jsx("input",{type:"radio",name:"schedule_start",checked:vn==="at",onChange:()=>Sn("at")}),s.jsx("span",{children:"Scheduled"})]})]}),vn==="at"?s.jsx("input",{type:"datetime-local",value:cr,onChange:w=>Qt(w.target.value),style:{marginTop:"6px"}}):null]}),s.jsxs("div",{className:"sched_cell",children:[s.jsx("label",{className:"launch_label",children:"Cadence"}),s.jsxs("select",{value:Zn,onChange:w=>ls(w.target.value),children:[s.jsx("option",{value:"once",children:"Run once"}),s.jsx("option",{value:"forever",children:"Repeat forever"}),s.jsx("option",{value:"count",children:"Repeat N times"}),s.jsx("option",{value:"until",children:"Repeat until date"})]})]}),Zn!=="once"?s.jsxs("div",{className:"sched_cell",children:[s.jsx("label",{className:"launch_label",children:"Every"}),s.jsxs("div",{className:"sched_inline",children:[s.jsx("input",{type:"number",min:1,value:String(Un),onChange:w=>me(Math.max(1,parseInt(w.target.value||"1",10)||1)),style:{width:"70px"}}),s.jsxs("select",{value:ke,onChange:w=>ct(w.target.value),children:[s.jsx("option",{value:"minutes",children:"min"}),s.jsx("option",{value:"hours",children:"hours"}),s.jsx("option",{value:"days",children:"days"}),s.jsx("option",{value:"weeks",children:"weeks"}),s.jsx("option",{value:"months",children:"months"})]})]})]}):null,Zn==="count"?s.jsxs("div",{className:"sched_cell",children:[s.jsx("label",{className:"launch_label",children:"Total runs"}),s.jsx("input",{type:"number",min:1,value:String(it),onChange:w=>bt(Math.max(1,parseInt(w.target.value||"1",10)||1)),style:{width:"100px"}})]}):null,Zn==="until"?s.jsxs("div",{className:"sched_cell",children:[s.jsx("label",{className:"launch_label",children:"End date"}),s.jsxs("div",{className:"sched_inline",children:[s.jsx("input",{type:"date",value:zt,onChange:w=>Ut(w.target.value)}),s.jsx("input",{type:"time",value:Ot,onChange:w=>pn(w.target.value)})]})]}):null]}),s.jsxs("label",{className:"launch_checkbox",style:{marginTop:"8px"},children:[s.jsx("input",{type:"checkbox",checked:It,onChange:w=>_n(!!w.target.checked)}),s.jsxs("span",{children:["Share context across executions ",s.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xxs)",fontWeight:400},children:"(when disabled, each run gets its own isolated session)"})]})]}),s.jsx("div",{className:"section_divider"}),yt?s.jsxs("div",{className:"observe_context_card error",style:{marginBottom:"10px"},children:[s.jsx("span",{className:"chip mono danger",children:"error"}),s.jsx("span",{className:"mono",children:yt})]}):null,s.jsx("div",{className:"launch_actions_bar",children:s.jsx("button",{className:"launch_submit_btn",onClick:()=>void qn(),disabled:Pe||be||le||G||je||!K||!j.trim()||!v.trim()||Yt===null,children:vn!=="now"||Zn!=="once"?"Launch (scheduled)":"Launch now"})})]})})}):null,cl&&e==="backlog"?s.jsx(Ew,{gateway:jt,gateway_connected:K,maintenance_ai_provider:r.maintenance_ai_provider,maintenance_ai_model:r.maintenance_ai_model,backlog_advisor_agent:r.backlog_advisor_agent,voice_session_id:D}):null,e==="inbox"?s.jsx(s1,{gateway:jt,gateway_connected:K,enable_triage:d1,default_session_id:W||c||D,default_active_run_id:c,default_workflow_id:(xe==null?void 0:xe.workflow_id)??(ys==null?void 0:ys.workflow_id)??null}):null,cl&&e==="processes"?s.jsx(n1,{gateway:jt,gateway_connected:K}):null,e==="mindmap"?s.jsx("div",{className:"page mindmap_page",children:K?s.jsx("div",{className:"mindmap_full",children:s.jsx(ZN,{gateway:jt,selected_run_id:c,selected_session_id:W||D})}):s.jsx("div",{className:"page_inner constrained",children:s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"title",children:s.jsx("h1",{children:"Mindmap"})}),s.jsxs("div",{className:"mono muted",children:["Not connected. Open"," ",s.jsx("button",{className:"btn",onClick:()=>t("settings"),children:"Settings"})," ","to connect to a gateway."]})]})})}):null,e==="observe"?s.jsxs("div",{className:"page observe_page",children:[s.jsxs("div",{className:"observe_toolbar",children:[s.jsxs("div",{className:"observe_toolbar_row",children:[s.jsx(u1,{runs:J,selected_run_id:c,workflow_label_by_id:Xc,disabled:!K||z||le||Pe||be,loading:z,onSelect:w=>void Wa(w)}),s.jsxs("button",{className:"btn btn_icon",onClick:Go,disabled:!K||z||le,title:"Refresh runs",children:[s.jsx(On,{name:"refresh",size:14}),z?"…":"Refresh"]}),s.jsxs("button",{className:"btn btn_icon",onClick:ba,disabled:!c.trim()&&!Re,title:"Disconnect from run",children:[s.jsx(On,{name:"x",size:14}),"Disconnect"]}),s.jsx("span",{className:"observe_toolbar_sep"}),s.jsx("button",{className:"btn",onClick:()=>{if(Zc==="pause"){dn("pause"),jr(""),hr(""),st(!0);return}oi("resume")},disabled:eu,children:Jo}),tu?s.jsx("button",{className:"btn primary",onClick:()=>void Tl(),disabled:!c.trim()||Pe||be||ki||Js,children:"Run now"}):null,s.jsx("button",{className:"btn danger",onClick:()=>{dn("cancel"),jr(""),hr(""),st(!0)},disabled:!c.trim()||Pe||be||ki,children:"Cancel"})]}),cc||Rr||Kt?s.jsxs("div",{className:"observe_toolbar_context",children:[cc?s.jsxs("div",{className:"observe_context_card info",children:[s.jsxs("div",{className:"observe_context_label",children:[s.jsx("span",{className:"chip mono info",children:Rr?Js?"suspended":"scheduled":"waiting"}),s.jsx("span",{className:"mono muted",children:qr||"unknown"})]}),s.jsxs("div",{className:"observe_context_body",children:[bi?s.jsxs("span",{className:"mono",title:bi,children:[s.jsx("span",{className:"muted",children:"wait_key"}),": ",Ma(bi,46)]}):null,qr==="event"&&Ga?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"event"}),": ",Ga]}):null,qr==="subworkflow"&&Os?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"child"}),": ",Ma(Os,18)]}):null,qr==="until"&&Si?s.jsxs("span",{className:"mono",title:Si,children:[s.jsx("span",{className:"muted",children:"until"}),": ",Ma(Si,46)]}):null,qr==="until"&&Si?s.jsx("span",{className:"mono muted",children:(()=>{const w=fl(Si),$=w!==null?new Date(w).toLocaleString():Si,P=w!==null?Gg(w-Date.now()):"";return`Next at ${$}${P?` (in ${P})`:""}`})()}):null]}),qr==="subworkflow"&&Os?s.jsxs("div",{className:"observe_context_actions",children:[s.jsx("button",{className:"btn primary",onClick:async()=>{d(Os),await _r(Os)},disabled:Pe,children:"Attach to child"}),h.trim()&&h.trim()!==c.trim()?s.jsx("button",{className:"btn",onClick:async()=>{d(h.trim()),await _r(h.trim())},disabled:Pe,children:"Back to root"}):null]}):null]}):null,Rr?s.jsxs("div",{className:"observe_context_card muted",children:[s.jsxs("div",{className:"observe_context_label",children:[s.jsx("span",{className:"chip mono muted",children:"schedule"}),s.jsx("span",{className:"mono muted",children:Ni?`every ${ss}`:"once"})]}),s.jsxs("div",{className:"observe_context_body",children:[ss?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"interval"}),": ",ss]}):null,s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"share ctx"}),": ",ai?"yes":"no"]}),typeof Ko=="number"?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"repeats"}),": ",Ko]}):null]}),is!==null?s.jsxs("div",{className:"observe_context_budget",children:[s.jsxs("span",{className:"mono muted",children:[typeof Qn=="number"&&typeof li=="number"?`${Qn.toLocaleString()} / ${li.toLocaleString()}`:"",` • ${Math.round(Math.max(0,Math.min(1,is))*100)}%`]}),s.jsx("div",{className:"observe_budget_bar",children:s.jsx("div",{className:"observe_budget_fill",style:{width:`${Math.round(Math.max(0,Math.min(1,is))*100)}%`,background:is>=.9?"rgba(239, 68, 68, 0.9)":is>=.75?"rgba(245, 158, 11, 0.9)":"rgba(34, 197, 94, 0.9)"}})})]}):null,s.jsxs("div",{className:"observe_context_actions",children:[Ni?s.jsx("button",{className:"btn",onClick:()=>{Vt(ss||""),jn(!0),kn(""),Gt(!0)},disabled:Pe||Nn,children:"Edit schedule"}):null,Ni?s.jsx("button",{className:"btn",onClick:()=>{us(""),Sr(!0)},disabled:Pe||Jr,children:"Compact context"}):null]})]}):null,Kt?s.jsxs("div",{className:"observe_context_card error",children:[s.jsx("span",{className:"chip mono danger",children:"error"}),s.jsx("span",{className:"mono",children:Kt})]}):null]}):null]}),s.jsxs("div",{className:"card panel_card card_scroll observe_viewer observe_viewer_full",children:[s.jsxs("div",{className:"tab_bar",style:{justifyContent:"space-between"},children:[s.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[s.jsx("button",{className:`tab mono ${yn==="ledger"?"active":""}`,onClick:()=>en("ledger"),children:"Ledger"}),s.jsx("button",{className:`tab mono ${yn==="graph"?"active":""}`,onClick:()=>en("graph"),children:"Graph"}),s.jsx("button",{className:`tab mono ${yn==="digest"?"active":""}`,onClick:()=>en("digest"),children:"Digest"}),s.jsx("button",{className:`tab mono ${yn==="attachments"?"active":""}`,onClick:()=>en("attachments"),children:"Attachments"}),s.jsx("button",{className:`tab mono ${yn==="chat"?"active":""}`,onClick:()=>en("chat"),children:"Chat"})]}),yn==="ledger"&&(uc.length>0||An==="cycles")?s.jsxs("div",{className:"tab_bar_controls",children:[s.jsxs("div",{className:"seg_toggle mono",children:[s.jsx("button",{className:`seg_btn ${An==="steps"?"active":""}`,onClick:()=>Tr("steps"),children:"Steps"}),s.jsx("button",{className:`seg_btn ${An==="cycles"?"active":""}`,onClick:()=>Tr("cycles"),children:"Cycles"})]}),An==="steps"?s.jsx("button",{className:`seg_action mono ${fn?"active":""}`,onClick:()=>or(w=>!w),title:fn?"Showing condensed view":"Showing all steps",children:fn?"Condensed":"All"}):s.jsxs("select",{className:"mono seg_select",value:ci,onChange:w=>_i(String(w.target.value||"")),disabled:!Xa.length,title:"Select run for cycles view",children:[Xa.length?null:s.jsx("option",{value:"",children:"(no runs)"}),Xa.map(w=>{const $=typeof Ya[w]=="number"?Number(Ya[w]):0,P=`${Ma(w,18)}${$?` • ${$} llm`:""}`;return s.jsx("option",{value:w,children:P},w)})]}),s.jsx("button",{className:"seg_action mono",disabled:!Xe.length&&!ze.length,title:"Copy full ledger as JSONL",onClick:()=>{const P=[...Xe.map(Q=>({run_id:c.trim()||Q.record.run_id||"",cursor:Q.cursor,record:Q.record})),...ze.map(Q=>({run_id:Q.run_id,cursor:Q.cursor,record:Q.record}))].map(Q=>{var Le,ye;const ae=String(((Le=Q.record)==null?void 0:Le.ended_at)||((ye=Q.record)==null?void 0:ye.started_at)||"").trim(),re=fl(ae);return{...Q,_ms:re??0}});P.sort((Q,ae)=>(Q._ms||0)-(ae._ms||0));const H=(P.length>5e3?P.slice(P.length-5e3):P).map(({_ms:Q,...ae})=>JSON.stringify(ae)).join(`
|
|
142
|
+
`);C(H)},children:"Copy JSONL"})]}):null,yn==="graph"?s.jsxs("div",{className:"tab_bar_controls",children:[s.jsx("button",{className:`seg_action mono ${yi?"active":""}`,onClick:()=>tc(w=>!w),children:"Subflows"}),s.jsx("button",{className:`seg_action mono ${Oa?"active":""}`,onClick:()=>Sl(w=>!w),children:"Path"}),Ml.length?s.jsx("select",{className:"mono seg_select",value:go,onChange:w=>_o(String(w.target.value||"")),disabled:!!Ci.trim()||!j.trim()||wl,children:Ml.map(w=>s.jsx("option",{value:w,children:w},w))}):null]}):null,yn==="digest"&&((ou=(gc=Ht==null?void 0:Ht.overall)==null?void 0:gc.stats)!=null&&ou.steps)?s.jsx("div",{className:"tab_bar_controls",children:s.jsx("button",{className:"seg_action mono",onClick:()=>{C(JSON.stringify(Ht,null,2))},disabled:!((No=(Ji=Ht==null?void 0:Ht.overall)==null?void 0:Ji.stats)!=null&&No.steps),children:"Copy JSON"})}):null]}),yn==="ledger"?s.jsx(s.Fragment,{children:An==="steps"?s.jsxs("div",{className:"log log_scroll",children:[uc.map(w=>s.jsx(k1,{item:w,open:at[w.id]===!0,on_toggle:()=>At($=>({...$,[w.id]:!$[w.id]})),response_open:Rt[w.id]===!0,on_toggle_response:()=>Lt($=>({...$,[w.id]:!$[w.id]})),node_index:rc,on_copy:$=>void C($)},w.id)),uc.length?null:s.jsx("div",{className:"mono muted",style:{padding:"10px 12px"},children:"(no ledger items)"})]}):s.jsx("div",{className:"log log_scroll",children:s.jsx(rv,{items:dc.items,title:"Agent",subtitle:dc.node_id?`node_id: ${dc.node_id}`:"Live per-effect trace (LLM/tool calls).",subRunId:ci,onOpenSubRun:ci&&ci!==c.trim()?()=>{d(ci),_r(ci)}:void 0})})}):null,yn==="graph"?s.jsxs(s.Fragment,{children:[bl?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"graph error"}),s.jsx("span",{className:"mono",children:hn()})]}),s.jsx("div",{className:"body mono",children:bl})]}):null,wl?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(96, 165, 250, 0.25)"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"loading"}),s.jsx("span",{className:"mono",children:Ci.trim()?Ci.trim():go})]}),s.jsx("div",{className:"body mono",children:"Loading graph…"})]}):null,s.jsx("div",{className:"graph_panel",children:s.jsx(lw,{flow:yo,flow_by_id:ma,expand_subflows:yi,simplify:!0,prefer_vertical:!0,vertical_compact:.78,schedule_next_in:Rl,schedule_interval:ss,node_last_ms:Zu,active_node_id:ru,recent_nodes:nc,visited_nodes:kl,highlight_path:Oa,now_ms:jl})})]}):null,yn==="digest"?s.jsxs("div",{className:"log log_scroll",style:{marginTop:"6px"},children:[s.jsxs("div",{className:"log_item",style:{borderColor:Ht!=null&&Ht.latest_summary?Ht!=null&&Ht.summary_outdated?"rgba(239, 68, 68, 0.45)":"rgba(34, 197, 94, 0.35)":"rgba(96, 165, 250, 0.25)"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"summary"}),s.jsx("span",{className:"mono",children:Ht!=null&&Ht.latest_summary?Ht!=null&&Ht.summary_outdated?"outdated":"current":"(none)"})]}),s.jsx("div",{className:"body",style:{whiteSpace:"pre-wrap"},children:Ht!=null&&Ht.latest_summary?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:[Ht.latest_summary.generated_at||Ht.latest_summary.ts||""," •"," ",Ht.latest_summary.provider||"provider?"," • ",Ht.latest_summary.model||"model?"]}),s.jsx(ao,{text:Ht.latest_summary.text})]}):s.jsx("div",{className:"mono muted",children:"No summary yet."})}),s.jsx("div",{className:"actions",children:s.jsx("button",{className:"btn primary",onClick:()=>void Jc(),disabled:!c.trim()||xi,children:xi?"Generating…":Ht!=null&&Ht.latest_summary?"Regenerate":"Generate"})}),Ho?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Ho}):null]}),Ht?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(148, 163, 184, 0.25)"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"overall"}),s.jsxs("span",{className:"mono",children:[((au=(Ll=Ht.overall)==null?void 0:Ll.stats)==null?void 0:au.steps)??0," steps"]})]}),s.jsxs("div",{className:"body mono",children:[s.jsxs("div",{children:["tools: ",((lu=(Pl=Ht.overall)==null?void 0:Pl.stats)==null?void 0:lu.tool_calls)??0," calls • ",(($i=(Ka=Ht.overall)==null?void 0:Ka.stats)==null?void 0:$i.unique_tools)??0," unique"]}),s.jsxs("div",{children:["llm: ",((Qa=(Ja=Ht.overall)==null?void 0:Ja.stats)==null?void 0:Qa.llm_calls)??0," calls • missing ",((_c=(ea=Ht.overall)==null?void 0:ea.stats)==null?void 0:_c.llm_missing_responses)??0]}),s.jsxs("div",{children:["tokens: ",((cu=(ka=Ht.overall)==null?void 0:ka.stats)==null?void 0:cu.prompt_tokens)??0," / ",((rr=(yc=Ht.overall)==null?void 0:yc.stats)==null?void 0:rr.completion_tokens)??0," • total"," ",((xc=(Il=Ht.overall)==null?void 0:Il.stats)==null?void 0:xc.total_tokens)??0]}),s.jsxs("div",{children:["duration:"," ",typeof((Fl=(vc=Ht.overall)==null?void 0:vc.stats)==null?void 0:Fl.duration_s)=="number"?`${Math.round(Ht.overall.stats.duration_s)}s`:((ta=(wc=Ht.overall)==null?void 0:wc.stats)==null?void 0:ta.duration_s)??0," • ","errors: ",((xr=(sr=Ht.overall)==null?void 0:sr.stats)==null?void 0:xr.errors)??0]})]})]}),Array.isArray((Lr=Ht.overall)==null?void 0:Lr.tools_used)&&Ht.overall.tools_used.length?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(148, 163, 184, 0.25)"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"tools used"}),s.jsx("span",{className:"mono",children:Ht.overall.tools_used.length})]}),s.jsx("div",{className:"body mono",children:Ht.overall.tools_used.join(", ")})]}):null,s.jsxs("details",{style:{marginTop:"10px"},children:[s.jsx("summary",{className:"mono muted",style:{cursor:"pointer"},children:"Advanced: digest JSON"}),s.jsx("div",{className:"log_item",style:{borderColor:"rgba(148, 163, 184, 0.25)",marginTop:"10px"},children:s.jsx("div",{className:"body mono",children:s.jsx(y_,{value:Ht,max_string_len:240})})})]})]}):s.jsx("div",{className:"mono muted",style:{padding:"10px 12px"},children:"(no digest)"})]}):null,yn==="attachments"?s.jsxs("div",{className:"log log_scroll",style:{marginTop:"6px"},children:[s.jsxs("div",{className:"log_actions",style:{marginTop:"6px",flexWrap:"wrap"},children:[s.jsx("button",{className:"btn",onClick:()=>void et(),disabled:!K||fo||!W,children:fo?"Refreshing…":"Refresh"}),W?s.jsxs("span",{className:"chip mono muted",title:W,children:["session ",Ma(W,18)]}):s.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No session id (pick a run)"}),Rs.trim()?s.jsxs("span",{className:"chip mono muted",title:Rs,children:["store ",Ma(Rs,18)]}):null]}),Ia?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"error"}),s.jsx("span",{className:"mono",children:hn()})]}),s.jsx("div",{className:"body mono",children:Ia})]}):null,s.jsxs("div",{className:"log",style:{marginTop:"10px"},children:[!fo&&!Ia&&!yl.length?s.jsx("div",{className:"chat_empty_hint",children:"No session attachments."}):null,yl.map(w=>{const $=String((w==null?void 0:w.artifact_id)||"").trim();if(!$)return null;const P=w!=null&&w.tags&&typeof w.tags=="object"?w.tags:{},E=String((P==null?void 0:P.filename)||"").trim(),H=String((P==null?void 0:P.path)||"").trim(),Q=String((P==null?void 0:P.sha256)||"").trim(),ae=String((w==null?void 0:w.content_type)||"").trim(),re=typeof(w==null?void 0:w.size_bytes)=="number"?Number(w.size_bytes):null,Le=H?`@${H}`:E||$;return s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(148, 163, 184, 0.25)"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:Le}),s.jsx("span",{className:"mono",children:Ma($,18)})]}),s.jsxs("div",{className:"body",children:[Q?s.jsxs("div",{className:"mono",children:[s.jsx("span",{className:"muted",children:"sha256"}),": ",Ma(Q,18)]}):null,ae?s.jsxs("div",{className:"mono",children:[s.jsx("span",{className:"muted",children:"type"}),": ",ae]}):null,typeof re=="number"?s.jsxs("div",{className:"mono",children:[s.jsx("span",{className:"muted",children:"size"}),": ",re.toLocaleString()," bytes"]}):null]}),s.jsxs("div",{className:"actions",children:[s.jsx("button",{className:"btn",onClick:()=>void C($),children:"Copy id"}),s.jsx("button",{className:"btn",onClick:()=>void Ze(w),disabled:!Rs.trim(),children:"Preview"}),s.jsx("button",{className:"btn",onClick:()=>void Ye(w),disabled:!Rs.trim(),children:"Download"})]})]},$)}),s.jsxs(Mi,{open:ec,title:xl||"Attachment",onClose:()=>{ho(!1),po(""),Ls(""),fa(!1)},actions:s.jsx(s.Fragment,{children:s.jsx("button",{className:"btn",onClick:()=>{ho(!1),po(""),Ls(""),fa(!1)},children:"Close"})}),children:[vl?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:"Loading…"}):null,Bi?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:Bi}):null,s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",maxHeight:"62vh",overflow:"auto",margin:0},children:da||"(empty)"})]})]})]}):null,yn==="chat"?s.jsxs("div",{className:"log log_scroll",style:{marginTop:"6px"},children:[s.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"6px"},children:["Using Maintenance AI from Settings: ",r.maintenance_ai_provider.trim()||"(gateway default)"," /"," ",r.maintenance_ai_model.trim()||"(gateway default)"]}),s.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[s.jsx("label",{children:"Saved discussions"}),s.jsxs("div",{className:"actions",style:{justifyContent:"space-between",alignItems:"center",gap:"10px",flexWrap:"wrap",marginTop:0},children:[s.jsx("div",{style:{flex:1,minWidth:260},children:s.jsx(Hc,{value:qs,options:Ce,placeholder:Ts?"Loading…":Ce.length?"Select a saved discussion…":"(none saved)",disabled:!c.trim()||!K||!Ce.length,loading:Ts,searchable:!0,clearable:!0,onChange:w=>{Hr(w),Ar("")}})}),s.jsxs("div",{className:"actions",style:{justifyContent:"flex-end",marginTop:0},children:[s.jsx("button",{className:"btn",type:"button",disabled:!qs.trim()||!K||zs,onClick:()=>void Fs(),children:zs?"Loading…":"Load"}),s.jsx("button",{className:"btn",type:"button",disabled:!Ln.length||$s||Qr||zs,onClick:()=>{Br([]),pr(""),Cr(""),Zr(""),gr(""),Wr("")},children:"Clear"}),s.jsx("button",{className:"btn",type:"button",onClick:()=>void Xi(),disabled:!c.trim()||!K||Ts,children:Ts?"Refreshing…":"Refresh"})]})]}),s.jsxs("div",{className:"actions",style:{justifyContent:"flex-end",marginTop:"8px",flexWrap:"wrap"},children:[s.jsx("button",{className:"btn",type:"button",disabled:!Ln.length||!c.trim()||!K||Qr||!ie,onClick:()=>void gs(),title:ie?"":"No changes since last save",children:Qr?"Saving…":!ie&&es?"Saved":"Save discussion"}),s.jsx("button",{className:"btn",type:"button",disabled:!Ln.length,onClick:()=>Wn("download"),children:"Export Markdown"}),s.jsx("button",{className:"btn",type:"button",disabled:!Ln.length,onClick:()=>Wn("copy"),children:fr==="copied"?"Copied":fr==="failed"?"Copy failed":"Copy Markdown"})]}),s.jsx("div",{className:"chat_hint",children:"Read-only. No tools. Grounded in the parent run + subflows ledger."}),es?s.jsxs("div",{className:"chat_hint",children:["Last saved: ",rx(es)]}):null,As?s.jsx("div",{className:"chat_hint",style:{color:"rgba(239, 68, 68, 0.9)"},children:As}):null,Fo?s.jsx("div",{className:"chat_hint",style:{color:"rgba(239, 68, 68, 0.9)"},children:Fo}):null,ua?s.jsx("div",{className:"chat_hint",style:{color:"rgba(239, 68, 68, 0.9)"},children:ua}):null]}),Nr?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"error"}),s.jsx("span",{className:"mono",children:hn()})]}),s.jsx("div",{className:"body mono",children:Nr})]}):null,Li?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"voice"}),s.jsx("span",{className:"mono",children:hn()})]}),s.jsx("div",{className:"body mono",children:Li})]}):null,s.jsx("div",{className:"chat_messages",style:{marginTop:"10px"},children:s.jsx(Ud,{messages:Ln,className:"log_scroll",messageProps:fe.tts_supported&&K&&Er.trim()?{onSpeakToggle:Xo,getSpeakState:Kn,jsonCollapseAfterDepth:4}:{jsonCollapseAfterDepth:4},empty:s.jsx("div",{className:"chat_empty_hint",children:"Ask about this run (why failed, which tools, what happened in subflows)."})})}),s.jsx("div",{className:"chat_composer",style:{marginTop:"10px"},children:s.jsx(Bd,{ref:$r,value:er,onChange:pr,onSubmit:()=>void Va(),placeholder:"Ask about this run…",disabled:!c.trim()||!K||$s,busy:$s||fe.voice_ptt_busy,busyLabel:fe.voice_ptt_busy?"Transcribing…":"Thinking…",rows:3,sendButtonClassName:"btn primary",actions:s.jsxs("button",{className:`btn btn_icon voice_btn${fe.voice_ptt_recording?" danger":""}`,type:"button",disabled:!K||!O.trim()||!Er.trim()||$s||fe.voice_ptt_busy||!fe.voice_ptt_supported,title:fe.voice_ptt_supported?fe.voice_ptt_busy?"Transcribing…":fe.voice_ptt_recording?"Recording… release to transcribe":"Hold to talk (record + transcribe)":"Voice recording is not supported in this browser","aria-label":"Voice input",onPointerDown:w=>{var $,P;if(!(!K||!O.trim()||!Er.trim()||$s||fe.voice_ptt_busy||!fe.voice_ptt_supported)){w.preventDefault();try{(P=($=w.currentTarget)==null?void 0:$.setPointerCapture)==null||P.call($,w.pointerId)}catch{}fe.start_voice_ptt_recording()}},onPointerUp:w=>{w.preventDefault(),fe.stop_voice_ptt_recording()},onPointerCancel:w=>{w.preventDefault(),fe.stop_voice_ptt_recording()},children:[s.jsx(On,{name:fe.voice_ptt_recording?"x":"mic",size:16}),fe.voice_ptt_busy?"Transcribing…":fe.voice_ptt_recording?"Recording…":"Voice"]})})})]}):null,s.jsxs("div",{className:`status_bar ${dr?"pulse":""}`,children:[s.jsx("strong",{children:"Run"}),":"," ",c.trim()?s.jsx("span",{className:"mono",children:su||Qo||"unknown"}):s.jsx("span",{className:"mono",children:"(none)"}),c.trim()&&mc&&Rl?s.jsxs("span",{className:"mono muted",children:[" • next in ",Rl]}):null,Io?s.jsxs("span",{className:"mono muted",children:[" • ",Io]}):null]})]})]}):null,un?s.jsxs(Mi,{open:un,title:"Edit schedule",onClose:()=>{Gt(!1),Vt(""),jn(!0),kn(""),ar(!1)},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{Gt(!1),Vt(""),jn(!0),kn(""),ar(!1)},disabled:Pe||Nn,children:"Back"}),s.jsx("button",{className:"btn primary",onClick:async()=>{await Ha({interval:Zt,apply_immediately:rt})||(Gt(!1),kn(""),ar(!1))},disabled:Pe||Nn||!Zt.trim(),children:"Save"})]}),children:[Rn?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)",marginBottom:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"error"}),s.jsx("span",{className:"mono",children:hn()})]}),s.jsx("div",{className:"body mono",children:Rn})]}):null,s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Interval"}),s.jsx("input",{className:"mono",value:Zt,onChange:w=>Vt(String(w.target.value||"")),placeholder:"20m / 1h / 0.5s / 250ms",disabled:Pe||Nn}),s.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:["Accepted units: ",s.jsx("span",{className:"mono",children:"ms"}),", ",s.jsx("span",{className:"mono",children:"s"}),", ",s.jsx("span",{className:"mono",children:"m"}),","," ",s.jsx("span",{className:"mono",children:"h"}),", ",s.jsx("span",{className:"mono",children:"d"}),". This updates the existing scheduled run in place (no context loss)."]})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Quick picks"}),s.jsx("div",{className:"actions",style:{gap:"8px",flexWrap:"wrap"},children:["15m","30m","1h","2h","6h","1d"].map(w=>s.jsx("button",{className:"btn",onClick:()=>Vt(w),disabled:Pe||Nn,children:w},w))})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Apply"}),s.jsxs("label",{style:{display:"flex",gap:"10px",alignItems:"center"},children:[s.jsx("input",{type:"checkbox",checked:rt,onChange:w=>jn(!!w.target.checked),disabled:Pe||Nn}),"Apply immediately (recompute next run from now if waiting)"]})]})]}):null,Ir?s.jsxs(Mi,{open:Ir,title:"Compact scheduled context",onClose:()=>{Sr(!1),us(""),Or(!1)},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{Sr(!1),us(""),Or(!1)},disabled:Pe||Jr,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:async()=>{await ac({preserve_recent:Fr,compression_mode:Es,focus:Ri})||(Sr(!1),us(""),Or(!1))},disabled:Pe||Jr,children:Jr?"Compacting…":"Compact"})]}),children:[En?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)",marginBottom:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"error"}),s.jsx("span",{className:"mono",children:hn()})]}),s.jsx("div",{className:"body mono",children:En})]}):null,s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Preserve recent turns"}),s.jsx("input",{type:"number",min:1,value:String(Fr),onChange:w=>Ws(Math.max(1,parseInt(w.target.value||"6",10)||6)),disabled:Pe||Jr})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Mode"}),s.jsxs("select",{value:Es,onChange:w=>lo(w.target.value),disabled:Pe||Jr,children:[s.jsx("option",{value:"light",children:"light"}),s.jsx("option",{value:"standard",children:"standard"}),s.jsx("option",{value:"heavy",children:"heavy"})]})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Focus (optional)"}),s.jsx("input",{className:"mono",value:Ri,onChange:w=>cs(String(w.target.value||"")),placeholder:"e.g. important decisions, next steps…",disabled:Pe||Jr})]})]}):null,mr?s.jsxs(Mi,{open:mr,title:St==="cancel"?"Cancel run":Rr?"Suspend schedule":"Pause run",onClose:()=>{st(!1),jr(""),hr("")},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{st(!1),jr(""),hr("")},disabled:Pe||be,children:"Back"}),s.jsx("button",{className:`btn ${St==="cancel"?"danger":"primary"}`,onClick:async()=>{hr("");const w=await oi(St,{reason:Dr});if(w){hr(w);return}st(!1),jr(""),hr("")},disabled:Pe||be,children:St==="pause"?Rr?"Suspend":"Pause":"Cancel"})]}),children:[kr?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)",marginBottom:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"error"}),s.jsx("span",{className:"mono",children:hn()})]}),s.jsx("div",{className:"body mono",children:kr})]}):null,s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Reason (optional)"}),s.jsx("input",{className:"mono",value:Dr,onChange:w=>jr(w.target.value),placeholder:"reason…"})]})]}):null,pf?s.jsx("div",{className:"overlay",children:s.jsxs("div",{className:"modal",children:[s.jsxs("h2",{className:"mono",children:["Run is waiting (",String((gn==null?void 0:gn.reason)||"unknown"),")"]}),s.jsxs("p",{className:"mono",children:["wait_key: ",String((gn==null?void 0:gn.wait_key)||"")]}),rs.length?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Tool calls (from wait.details.tool_calls)"}),s.jsx("textarea",{className:"mono",readOnly:!0,value:Sm(rs)})]}),s.jsxs("div",{className:"actions",children:[s.jsx("button",{className:"btn primary",disabled:!ya||be,onClick:()=>qa(rs),children:"Execute via tool worker + resume"}),s.jsx("button",{className:"btn",disabled:be,onClick:()=>So({approved:!0}),children:"Resume (manual / advanced)"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Prompt"}),s.jsx("textarea",{className:"mono",readOnly:!0,value:String((gn==null?void 0:gn.prompt)||"")||"(no prompt provided)"})]}),s.jsx(j1,{wait:gn,disabled:be,on_submit:w=>So({response:w})})]})]})}):null]})]})}function j1(e){const[t,r]=m.useState(""),o=Array.isArray(e.wait.choices)?e.wait.choices:[],l=e.wait.allow_free_text!==!1,u=e.disabled===!0;return s.jsxs(s.Fragment,{children:[o.length?s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Choices"}),s.jsxs("select",{className:"mono",value:t,onChange:c=>r(c.target.value),children:[s.jsx("option",{value:"",children:"(select)"}),o.map((c,d)=>s.jsx("option",{value:String(c),children:String(c)},d))]})]}):null,l?s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Response"}),s.jsx("input",{className:"mono",value:t,onChange:c=>r(c.target.value),placeholder:"Type response…"})]}):null,s.jsx("div",{className:"actions",children:s.jsx("button",{className:"btn primary",disabled:u||!t.trim(),onClick:()=>e.on_submit(t.trim()),children:"Submit response"})})]})}function k1(e){const t=e.item,r=String(t.node_id||"").trim(),o=r&&e.node_index&&typeof e.node_index=="object"?e.node_index[r]:null,l=typeof(o==null?void 0:o.label)=="string"&&o.label.trim()?o.label.trim():r||t.title,u=typeof(o==null?void 0:o.type)=="string"&&o.type.trim()?o.type.trim():"",c=typeof(o==null?void 0:o.headerColor)=="string"&&o.headerColor.trim()?o.headerColor.trim():"",d=t.kind==="step"?l:t.title,h=c||(t.kind==="error"?"rgba(239, 68, 68, 0.85)":t.kind==="message"?"rgba(167, 139, 250, 0.85)":t.kind==="event"?"rgba(96, 165, 250, 0.85)":t.status==="waiting"?"rgba(96, 165, 250, 0.65)":t.status==="completed"?"rgba(34, 197, 94, 0.65)":"rgba(255, 255, 255, 0.14)"),_=String(t.status||"").trim(),g=_.toLowerCase(),x=g==="completed"?"ok":g==="failed"?"danger":g==="waiting"?"warn":g==="running"?"info":"muted",v=nx(t.data),b=!!(v&&v.trim()),j=rx(t.ts);return s.jsxs("div",{className:`lc ${x}`,style:{"--lc-accent":h},children:[s.jsxs("div",{className:"lc_header",children:[s.jsx("span",{className:"lc_title",children:d}),s.jsxs("div",{className:"lc_header_right",children:[_?s.jsx("span",{className:`lc_status ${x}`,children:_}):null,s.jsx("span",{className:"lc_time",title:t.ts,children:j})]})]}),s.jsxs("div",{className:"lc_meta",children:[u?s.jsx("span",{className:"lc_chip",children:u}):null,t.effect_type?s.jsx("span",{className:"lc_chip",children:String(t.effect_type)}):null,t.cursor?s.jsxs("span",{className:"lc_chip",children:["#",t.cursor]}):null,t.run_id?s.jsx("span",{className:"lc_chip",children:Ma(String(t.run_id),10)}):null,t.kind!=="step"&&r?s.jsx("span",{className:"lc_chip",children:r}):null]}),t.preview?s.jsx("div",{className:"lc_preview",children:t.preview}):null,t.data?s.jsxs("div",{className:"lc_actions",children:[b?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"lc_btn",onClick:e.on_toggle_response,children:e.response_open?"Fold Response":"Unfold Response"}),s.jsx("button",{className:"lc_btn",onClick:()=>e.on_copy(String(v||"")),children:"Copy Response"})]}):null,s.jsx("button",{className:"lc_btn",onClick:e.on_toggle,children:e.open?"Fold JSON":"Unfold JSON"}),s.jsx("button",{className:"lc_btn",onClick:()=>{try{e.on_copy(JSON.stringify(t.data,null,2))}catch{e.on_copy(String(t.data))}},children:"Copy JSON"})]}):null,e.response_open&&b?s.jsx("div",{className:"lc_body",children:s.jsx(ao,{text:String(v||"")})}):null,e.open&&t.data?s.jsx("div",{className:"lc_body lc_body_json mono",children:s.jsx(y_,{value:t.data,max_string_len:220})}):null]})}if("serviceWorker"in navigator){window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js").then(t=>t.update()).catch(()=>{})});let e=!1;navigator.serviceWorker.addEventListener("controllerchange",()=>{e||(e=!0,window.location.reload())})}Ox.createRoot(document.getElementById("root")).render(s.jsx(Ee.StrictMode,{children:s.jsx(S1,{})}));
|
|
143
|
+
//# sourceMappingURL=index-Bp9AQ5i5.js.map
|