@abstractframework/observer 0.1.12 → 0.1.13
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 +5 -4
- package/dist/assets/index-BHHnK0PW.css +1 -0
- package/dist/assets/index-BNRMqyx3.js +140 -0
- package/dist/assets/index-BNRMqyx3.js.map +1 -0
- package/dist/index.html +2 -2
- package/package.json +6 -3
- package/dist/assets/index-D6ILADyf.css +0 -1
- package/dist/assets/index-DdaTQ1ps.js +0 -140
- package/dist/assets/index-DdaTQ1ps.js.map +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var nx=Object.defineProperty;var rx=(e,t,n)=>t in e?nx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ua=(e,t,n)=>rx(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))o(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();function Y_(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kh={exports:{}},gd={},Nh={exports:{}},Ut={};/**
|
|
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 $p;function sx(){if($p)return Ut;$p=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.iterator;function w($){return $===null||typeof $!="object"?null:($=v&&$[v]||$["@@iterator"],typeof $=="function"?$:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,S={};function R($,Y,se){this.props=$,this.context=Y,this.refs=S,this.updater=se||b}R.prototype.isReactComponent={},R.prototype.setState=function($,Y){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,Y,"setState")},R.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function T(){}T.prototype=R.prototype;function D($,Y,se){this.props=$,this.context=Y,this.refs=S,this.updater=se||b}var q=D.prototype=new T;q.constructor=D,C(q,R.prototype),q.isPureReactComponent=!0;var P=Array.isArray,K=Object.prototype.hasOwnProperty,Q={current:null},Z={key:!0,ref:!0,__self:!0,__source:!0};function ee($,Y,se){var le,he={},be=null,je=null;if(Y!=null)for(le in Y.ref!==void 0&&(je=Y.ref),Y.key!==void 0&&(be=""+Y.key),Y)K.call(Y,le)&&!Z.hasOwnProperty(le)&&(he[le]=Y[le]);var Ce=arguments.length-2;if(Ce===1)he.children=se;else if(1<Ce){for(var Fe=Array(Ce),Ke=0;Ke<Ce;Ke++)Fe[Ke]=arguments[Ke+2];he.children=Fe}if($&&$.defaultProps)for(le in Ce=$.defaultProps,Ce)he[le]===void 0&&(he[le]=Ce[le]);return{$$typeof:e,type:$,key:be,ref:je,props:he,_owner:Q.current}}function ue($,Y){return{$$typeof:e,type:$.type,key:Y,ref:$.ref,props:$.props,_owner:$._owner}}function de($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function pe($){var Y={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(se){return Y[se]})}var F=/\/+/g;function E($,Y){return typeof $=="object"&&$!==null&&$.key!=null?pe(""+$.key):Y.toString(36)}function j($,Y,se,le,he){var be=typeof $;(be==="undefined"||be==="boolean")&&($=null);var je=!1;if($===null)je=!0;else switch(be){case"string":case"number":je=!0;break;case"object":switch($.$$typeof){case e:case t:je=!0}}if(je)return je=$,he=he(je),$=le===""?"."+E(je,0):le,P(he)?(se="",$!=null&&(se=$.replace(F,"$&/")+"/"),j(he,Y,se,"",function(Ke){return Ke})):he!=null&&(de(he)&&(he=ue(he,se+(!he.key||je&&je.key===he.key?"":(""+he.key).replace(F,"$&/")+"/")+$)),Y.push(he)),1;if(je=0,le=le===""?".":le+":",P($))for(var Ce=0;Ce<$.length;Ce++){be=$[Ce];var Fe=le+E(be,Ce);je+=j(be,Y,se,Fe,he)}else if(Fe=w($),typeof Fe=="function")for($=Fe.call($),Ce=0;!(be=$.next()).done;)be=be.value,Fe=le+E(be,Ce++),je+=j(be,Y,se,Fe,he);else if(be==="object")throw Y=String($),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.");return je}function L($,Y,se){if($==null)return $;var le=[],he=0;return j($,le,"","",function(be){return Y.call(se,be,he++)}),le}function z($){if($._status===-1){var Y=$._result;Y=Y(),Y.then(function(se){($._status===0||$._status===-1)&&($._status=1,$._result=se)},function(se){($._status===0||$._status===-1)&&($._status=2,$._result=se)}),$._status===-1&&($._status=0,$._result=Y)}if($._status===1)return $._result.default;throw $._result}var te={current:null},I={transition:null},O={ReactCurrentDispatcher:te,ReactCurrentBatchConfig:I,ReactCurrentOwner:Q};function G(){throw Error("act(...) is not supported in production builds of React.")}return Ut.Children={map:L,forEach:function($,Y,se){L($,function(){Y.apply(this,arguments)},se)},count:function($){var Y=0;return L($,function(){Y++}),Y},toArray:function($){return L($,function(Y){return Y})||[]},only:function($){if(!de($))throw Error("React.Children.only expected to receive a single React element child.");return $}},Ut.Component=R,Ut.Fragment=n,Ut.Profiler=a,Ut.PureComponent=D,Ut.StrictMode=o,Ut.Suspense=m,Ut.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=O,Ut.act=G,Ut.cloneElement=function($,Y,se){if($==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+$+".");var le=C({},$.props),he=$.key,be=$.ref,je=$._owner;if(Y!=null){if(Y.ref!==void 0&&(be=Y.ref,je=Q.current),Y.key!==void 0&&(he=""+Y.key),$.type&&$.type.defaultProps)var Ce=$.type.defaultProps;for(Fe in Y)K.call(Y,Fe)&&!Z.hasOwnProperty(Fe)&&(le[Fe]=Y[Fe]===void 0&&Ce!==void 0?Ce[Fe]:Y[Fe])}var Fe=arguments.length-2;if(Fe===1)le.children=se;else if(1<Fe){Ce=Array(Fe);for(var Ke=0;Ke<Fe;Ke++)Ce[Ke]=arguments[Ke+2];le.children=Ce}return{$$typeof:e,type:$.type,key:he,ref:be,props:le,_owner:je}},Ut.createContext=function($){return $={$$typeof:d,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},$.Provider={$$typeof:l,_context:$},$.Consumer=$},Ut.createElement=ee,Ut.createFactory=function($){var Y=ee.bind(null,$);return Y.type=$,Y},Ut.createRef=function(){return{current:null}},Ut.forwardRef=function($){return{$$typeof:u,render:$}},Ut.isValidElement=de,Ut.lazy=function($){return{$$typeof:g,_payload:{_status:-1,_result:$},_init:z}},Ut.memo=function($,Y){return{$$typeof:y,type:$,compare:Y===void 0?null:Y}},Ut.startTransition=function($){var Y=I.transition;I.transition={};try{$()}finally{I.transition=Y}},Ut.unstable_act=G,Ut.useCallback=function($,Y){return te.current.useCallback($,Y)},Ut.useContext=function($){return te.current.useContext($)},Ut.useDebugValue=function(){},Ut.useDeferredValue=function($){return te.current.useDeferredValue($)},Ut.useEffect=function($,Y){return te.current.useEffect($,Y)},Ut.useId=function(){return te.current.useId()},Ut.useImperativeHandle=function($,Y,se){return te.current.useImperativeHandle($,Y,se)},Ut.useInsertionEffect=function($,Y){return te.current.useInsertionEffect($,Y)},Ut.useLayoutEffect=function($,Y){return te.current.useLayoutEffect($,Y)},Ut.useMemo=function($,Y){return te.current.useMemo($,Y)},Ut.useReducer=function($,Y,se){return te.current.useReducer($,Y,se)},Ut.useRef=function($){return te.current.useRef($)},Ut.useState=function($){return te.current.useState($)},Ut.useSyncExternalStore=function($,Y,se){return te.current.useSyncExternalStore($,Y,se)},Ut.useTransition=function(){return te.current.useTransition()},Ut.version="18.3.1",Ut}var Mp;function Kd(){return Mp||(Mp=1,Nh.exports=sx()),Nh.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 Ap;function ix(){if(Ap)return gd;Ap=1;var e=Kd(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function d(u,m,y){var g,v={},w=null,b=null;y!==void 0&&(w=""+y),m.key!==void 0&&(w=""+m.key),m.ref!==void 0&&(b=m.ref);for(g in m)o.call(m,g)&&!l.hasOwnProperty(g)&&(v[g]=m[g]);if(u&&u.defaultProps)for(g in m=u.defaultProps,m)v[g]===void 0&&(v[g]=m[g]);return{$$typeof:t,type:u,key:w,ref:b,props:v,_owner:a.current}}return gd.Fragment=n,gd.jsx=d,gd.jsxs=d,gd}var Tp;function ox(){return Tp||(Tp=1,kh.exports=ix()),kh.exports}var s=ox(),h=Kd();const ye=Y_(h);var rm={},Ch={exports:{}},Ns={},Eh={exports:{}},$h={};/**
|
|
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 Rp;function ax(){return Rp||(Rp=1,(function(e){function t(I,O){var G=I.length;I.push(O);e:for(;0<G;){var $=G-1>>>1,Y=I[$];if(0<a(Y,O))I[$]=O,I[G]=Y,G=$;else break e}}function n(I){return I.length===0?null:I[0]}function o(I){if(I.length===0)return null;var O=I[0],G=I.pop();if(G!==O){I[0]=G;e:for(var $=0,Y=I.length,se=Y>>>1;$<se;){var le=2*($+1)-1,he=I[le],be=le+1,je=I[be];if(0>a(he,G))be<Y&&0>a(je,he)?(I[$]=je,I[be]=G,$=be):(I[$]=he,I[le]=G,$=le);else if(be<Y&&0>a(je,G))I[$]=je,I[be]=G,$=be;else break e}}return O}function a(I,O){var G=I.sortIndex-O.sortIndex;return G!==0?G:I.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var d=Date,u=d.now();e.unstable_now=function(){return d.now()-u}}var m=[],y=[],g=1,v=null,w=3,b=!1,C=!1,S=!1,R=typeof setTimeout=="function"?setTimeout:null,T=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 q(I){for(var O=n(y);O!==null;){if(O.callback===null)o(y);else if(O.startTime<=I)o(y),O.sortIndex=O.expirationTime,t(m,O);else break;O=n(y)}}function P(I){if(S=!1,q(I),!C)if(n(m)!==null)C=!0,z(K);else{var O=n(y);O!==null&&te(P,O.startTime-I)}}function K(I,O){C=!1,S&&(S=!1,T(ee),ee=-1),b=!0;var G=w;try{for(q(O),v=n(m);v!==null&&(!(v.expirationTime>O)||I&&!pe());){var $=v.callback;if(typeof $=="function"){v.callback=null,w=v.priorityLevel;var Y=$(v.expirationTime<=O);O=e.unstable_now(),typeof Y=="function"?v.callback=Y:v===n(m)&&o(m),q(O)}else o(m);v=n(m)}if(v!==null)var se=!0;else{var le=n(y);le!==null&&te(P,le.startTime-O),se=!1}return se}finally{v=null,w=G,b=!1}}var Q=!1,Z=null,ee=-1,ue=5,de=-1;function pe(){return!(e.unstable_now()-de<ue)}function F(){if(Z!==null){var I=e.unstable_now();de=I;var O=!0;try{O=Z(!0,I)}finally{O?E():(Q=!1,Z=null)}}else Q=!1}var E;if(typeof D=="function")E=function(){D(F)};else if(typeof MessageChannel<"u"){var j=new MessageChannel,L=j.port2;j.port1.onmessage=F,E=function(){L.postMessage(null)}}else E=function(){R(F,0)};function z(I){Z=I,Q||(Q=!0,E())}function te(I,O){ee=R(function(){I(e.unstable_now())},O)}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(I){I.callback=null},e.unstable_continueExecution=function(){C||b||(C=!0,z(K))},e.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ue=0<I?Math.floor(1e3/I):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_getFirstCallbackNode=function(){return n(m)},e.unstable_next=function(I){switch(w){case 1:case 2:case 3:var O=3;break;default:O=w}var G=w;w=O;try{return I()}finally{w=G}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(I,O){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var G=w;w=I;try{return O()}finally{w=G}},e.unstable_scheduleCallback=function(I,O,G){var $=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?$+G:$):G=$,I){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=G+Y,I={id:g++,callback:O,priorityLevel:I,startTime:G,expirationTime:Y,sortIndex:-1},G>$?(I.sortIndex=G,t(y,I),n(m)===null&&I===n(y)&&(S?(T(ee),ee=-1):S=!0,te(P,G-$))):(I.sortIndex=Y,t(m,I),C||b||(C=!0,z(K))),I},e.unstable_shouldYield=pe,e.unstable_wrapCallback=function(I){var O=w;return function(){var G=w;w=O;try{return I.apply(this,arguments)}finally{w=G}}}})($h)),$h}var Lp;function lx(){return Lp||(Lp=1,Eh.exports=ax()),Eh.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 Pp;function cx(){if(Pp)return Ns;Pp=1;var e=Kd(),t=lx();function n(r){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+r,c=1;c<arguments.length;c++)i+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+r+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,a={};function l(r,i){d(r,i),d(r+"Capture",i)}function d(r,i){for(a[r]=i,r=0;r<i.length;r++)o.add(i[r])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,y=/^[: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={},v={};function w(r){return m.call(v,r)?!0:m.call(g,r)?!1:y.test(r)?v[r]=!0:(g[r]=!0,!1)}function b(r,i,c,f){if(c!==null&&c.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return f?!1:c!==null?!c.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function C(r,i,c,f){if(i===null||typeof i>"u"||b(r,i,c,f))return!0;if(f)return!1;if(c!==null)switch(c.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(r,i,c,f,p,x,M){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=f,this.attributeNamespace=p,this.mustUseProperty=c,this.propertyName=r,this.type=i,this.sanitizeURL=x,this.removeEmptyString=M}var R={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){R[r]=new S(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var i=r[0];R[i]=new S(i,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){R[r]=new S(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){R[r]=new S(r,2,!1,r,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(r){R[r]=new S(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){R[r]=new S(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){R[r]=new S(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){R[r]=new S(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){R[r]=new S(r,5,!1,r.toLowerCase(),null,!1,!1)});var T=/[\-:]([a-z])/g;function D(r){return r[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(r){var i=r.replace(T,D);R[i]=new S(i,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var i=r.replace(T,D);R[i]=new S(i,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var i=r.replace(T,D);R[i]=new S(i,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){R[r]=new S(r,1,!1,r.toLowerCase(),null,!1,!1)}),R.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){R[r]=new S(r,1,!1,r.toLowerCase(),null,!0,!0)});function q(r,i,c,f){var p=R.hasOwnProperty(i)?R[i]:null;(p!==null?p.type!==0:f||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(C(i,c,p,f)&&(c=null),f||p===null?w(i)&&(c===null?r.removeAttribute(i):r.setAttribute(i,""+c)):p.mustUseProperty?r[p.propertyName]=c===null?p.type===3?!1:"":c:(i=p.attributeName,f=p.attributeNamespace,c===null?r.removeAttribute(i):(p=p.type,c=p===3||p===4&&c===!0?"":""+c,f?r.setAttributeNS(f,i,c):r.setAttribute(i,c))))}var P=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,K=Symbol.for("react.element"),Q=Symbol.for("react.portal"),Z=Symbol.for("react.fragment"),ee=Symbol.for("react.strict_mode"),ue=Symbol.for("react.profiler"),de=Symbol.for("react.provider"),pe=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),te=Symbol.for("react.offscreen"),I=Symbol.iterator;function O(r){return r===null||typeof r!="object"?null:(r=I&&r[I]||r["@@iterator"],typeof r=="function"?r:null)}var G=Object.assign,$;function Y(r){if($===void 0)try{throw Error()}catch(c){var i=c.stack.trim().match(/\n( *(at )?)/);$=i&&i[1]||""}return`
|
|
34
|
+
`+$+r}var se=!1;function le(r,i){if(!r||se)return"";se=!0;var c=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(_e){var f=_e}Reflect.construct(r,[],i)}else{try{i.call()}catch(_e){f=_e}r.call(i.prototype)}else{try{throw Error()}catch(_e){f=_e}r()}}catch(_e){if(_e&&f&&typeof _e.stack=="string"){for(var p=_e.stack.split(`
|
|
35
|
+
`),x=f.stack.split(`
|
|
36
|
+
`),M=p.length-1,X=x.length-1;1<=M&&0<=X&&p[M]!==x[X];)X--;for(;1<=M&&0<=X;M--,X--)if(p[M]!==x[X]){if(M!==1||X!==1)do if(M--,X--,0>X||p[M]!==x[X]){var re=`
|
|
37
|
+
`+p[M].replace(" at new "," at ");return r.displayName&&re.includes("<anonymous>")&&(re=re.replace("<anonymous>",r.displayName)),re}while(1<=M&&0<=X);break}}}finally{se=!1,Error.prepareStackTrace=c}return(r=r?r.displayName||r.name:"")?Y(r):""}function he(r){switch(r.tag){case 5:return Y(r.type);case 16:return Y("Lazy");case 13:return Y("Suspense");case 19:return Y("SuspenseList");case 0:case 2:case 15:return r=le(r.type,!1),r;case 11:return r=le(r.type.render,!1),r;case 1:return r=le(r.type,!0),r;default:return""}}function be(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case Z:return"Fragment";case Q:return"Portal";case ue:return"Profiler";case ee:return"StrictMode";case E:return"Suspense";case j:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case pe:return(r.displayName||"Context")+".Consumer";case de:return(r._context.displayName||"Context")+".Provider";case F:var i=r.render;return r=r.displayName,r||(r=i.displayName||i.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case L:return i=r.displayName||null,i!==null?i:be(r.type)||"Memo";case z:i=r._payload,r=r._init;try{return be(r(i))}catch{}}return null}function je(r){var i=r.type;switch(r.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 r=i.render,r=r.displayName||r.name||"",i.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return be(i);case 8:return i===ee?"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 Ce(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Fe(r){var i=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function Ke(r){var i=Fe(r)?"checked":"value",c=Object.getOwnPropertyDescriptor(r.constructor.prototype,i),f=""+r[i];if(!r.hasOwnProperty(i)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var p=c.get,x=c.set;return Object.defineProperty(r,i,{configurable:!0,get:function(){return p.call(this)},set:function(M){f=""+M,x.call(this,M)}}),Object.defineProperty(r,i,{enumerable:c.enumerable}),{getValue:function(){return f},setValue:function(M){f=""+M},stopTracking:function(){r._valueTracker=null,delete r[i]}}}}function Ye(r){r._valueTracker||(r._valueTracker=Ke(r))}function Ct(r){if(!r)return!1;var i=r._valueTracker;if(!i)return!0;var c=i.getValue(),f="";return r&&(f=Fe(r)?r.checked?"true":"false":r.value),r=f,r!==c?(i.setValue(r),!0):!1}function wt(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function lt(r,i){var c=i.checked;return G({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:c??r._wrapperState.initialChecked})}function yt(r,i){var c=i.defaultValue==null?"":i.defaultValue,f=i.checked!=null?i.checked:i.defaultChecked;c=Ce(i.value!=null?i.value:c),r._wrapperState={initialChecked:f,initialValue:c,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function rt(r,i){i=i.checked,i!=null&&q(r,"checked",i,!1)}function Ne(r,i){rt(r,i);var c=Ce(i.value),f=i.type;if(c!=null)f==="number"?(c===0&&r.value===""||r.value!=c)&&(r.value=""+c):r.value!==""+c&&(r.value=""+c);else if(f==="submit"||f==="reset"){r.removeAttribute("value");return}i.hasOwnProperty("value")?it(r,i.type,c):i.hasOwnProperty("defaultValue")&&it(r,i.type,Ce(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(r.defaultChecked=!!i.defaultChecked)}function Oe(r,i,c){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=""+r._wrapperState.initialValue,c||i===r.value||(r.value=i),r.defaultValue=i}c=r.name,c!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,c!==""&&(r.name=c)}function it(r,i,c){(i!=="number"||wt(r.ownerDocument)!==r)&&(c==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+c&&(r.defaultValue=""+c))}var ve=Array.isArray;function Ie(r,i,c,f){if(r=r.options,i){i={};for(var p=0;p<c.length;p++)i["$"+c[p]]=!0;for(c=0;c<r.length;c++)p=i.hasOwnProperty("$"+r[c].value),r[c].selected!==p&&(r[c].selected=p),p&&f&&(r[c].defaultSelected=!0)}else{for(c=""+Ce(c),i=null,p=0;p<r.length;p++){if(r[p].value===c){r[p].selected=!0,f&&(r[p].defaultSelected=!0);return}i!==null||r[p].disabled||(i=r[p])}i!==null&&(i.selected=!0)}}function Ge(r,i){if(i.dangerouslySetInnerHTML!=null)throw Error(n(91));return G({},i,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Mt(r,i){var c=i.value;if(c==null){if(c=i.children,i=i.defaultValue,c!=null){if(i!=null)throw Error(n(92));if(ve(c)){if(1<c.length)throw Error(n(93));c=c[0]}i=c}i==null&&(i=""),c=i}r._wrapperState={initialValue:Ce(c)}}function Bt(r,i){var c=Ce(i.value),f=Ce(i.defaultValue);c!=null&&(c=""+c,c!==r.value&&(r.value=c),i.defaultValue==null&&r.defaultValue!==c&&(r.defaultValue=c)),f!=null&&(r.defaultValue=""+f)}function dn(r){var i=r.textContent;i===r._wrapperState.initialValue&&i!==""&&i!==null&&(r.value=i)}function Ft(r){switch(r){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 At(r,i){return r==null||r==="http://www.w3.org/1999/xhtml"?Ft(i):r==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var fn,Kn=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,c,f,p){MSApp.execUnsafeLocalFunction(function(){return r(i,c,f,p)})}:r})(function(r,i){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=i;else{for(fn=fn||document.createElement("div"),fn.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=fn.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;i.firstChild;)r.appendChild(i.firstChild)}});function jt(r,i){if(i){var c=r.firstChild;if(c&&c===r.lastChild&&c.nodeType===3){c.nodeValue=i;return}}r.textContent=i}var mn={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},Hn=["Webkit","ms","Moz","O"];Object.keys(mn).forEach(function(r){Hn.forEach(function(i){i=i+r.charAt(0).toUpperCase()+r.substring(1),mn[i]=mn[r]})});function Nn(r,i,c){return i==null||typeof i=="boolean"||i===""?"":c||typeof i!="number"||i===0||mn.hasOwnProperty(r)&&mn[r]?(""+i).trim():i+"px"}function yn(r,i){r=r.style;for(var c in i)if(i.hasOwnProperty(c)){var f=c.indexOf("--")===0,p=Nn(c,i[c],f);c==="float"&&(c="cssFloat"),f?r.setProperty(c,p):r[c]=p}}var Cn=G({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 Jt(r,i){if(i){if(Cn[r]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(n(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(n(61))}if(i.style!=null&&typeof i.style!="object")throw Error(n(62))}}function cr(r,i){if(r.indexOf("-")===-1)return typeof i.is=="string";switch(r){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 hn=null;function Wn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var vn=null,Ln=null,ne=null;function ge(r){if(r=_l(r)){if(typeof vn!="function")throw Error(n(280));var i=r.stateNode;i&&(i=Sc(i),vn(r.stateNode,r.type,i))}}function Te(r){Ln?ne?ne.push(r):ne=[r]:Ln=r}function qe(){if(Ln){var r=Ln,i=ne;if(ne=Ln=null,ge(r),i)for(r=0;r<i.length;r++)ge(i[r])}}function He(r,i){return r(i)}function ot(){}var pt=!1;function vt(r,i,c){if(pt)return r(i,c);pt=!0;try{return He(r,i,c)}finally{pt=!1,(Ln!==null||ne!==null)&&(ot(),qe())}}function zt(r,i){var c=r.stateNode;if(c===null)return null;var f=Sc(c);if(f===null)return null;c=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)||(r=r.type,f=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!f;break e;default:r=!1}if(r)return null;if(c&&typeof c!="function")throw Error(n(231,i,typeof c));return c}var ct=!1;if(u)try{var It={};Object.defineProperty(It,"passive",{get:function(){ct=!0}}),window.addEventListener("test",It,It),window.removeEventListener("test",It,It)}catch{ct=!1}function qt(r,i,c,f,p,x,M,X,re){var _e=Array.prototype.slice.call(arguments,3);try{i.apply(c,_e)}catch(Me){this.onError(Me)}}var ce=!1,kt=null,Lt=!1,Ve=null,en={onError:function(r){ce=!0,kt=r}};function _n(r,i,c,f,p,x,M,X,re){ce=!1,kt=null,qt.apply(en,arguments)}function ln(r,i,c,f,p,x,M,X,re){if(_n.apply(this,arguments),ce){if(ce){var _e=kt;ce=!1,kt=null}else throw Error(n(198));Lt||(Lt=!0,Ve=_e)}}function pn(r){var i=r,c=r;if(r.alternate)for(;i.return;)i=i.return;else{r=i;do i=r,(i.flags&4098)!==0&&(c=i.return),r=i.return;while(r)}return i.tag===3?c:null}function er(r){if(r.tag===13){var i=r.memoizedState;if(i===null&&(r=r.alternate,r!==null&&(i=r.memoizedState)),i!==null)return i.dehydrated}return null}function Gr(r){if(pn(r)!==r)throw Error(n(188))}function Cr(r){var i=r.alternate;if(!i){if(i=pn(r),i===null)throw Error(n(188));return i!==r?null:r}for(var c=r,f=i;;){var p=c.return;if(p===null)break;var x=p.alternate;if(x===null){if(f=p.return,f!==null){c=f;continue}break}if(p.child===x.child){for(x=p.child;x;){if(x===c)return Gr(p),r;if(x===f)return Gr(p),i;x=x.sibling}throw Error(n(188))}if(c.return!==f.return)c=p,f=x;else{for(var M=!1,X=p.child;X;){if(X===c){M=!0,c=p,f=x;break}if(X===f){M=!0,f=p,c=x;break}X=X.sibling}if(!M){for(X=x.child;X;){if(X===c){M=!0,c=x,f=p;break}if(X===f){M=!0,f=x,c=p;break}X=X.sibling}if(!M)throw Error(n(189))}}if(c.alternate!==f)throw Error(n(190))}if(c.tag!==3)throw Error(n(188));return c.stateNode.current===c?r:i}function Kr(r){return r=Cr(r),r!==null?Gs(r):null}function Gs(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var i=Gs(r);if(i!==null)return i;r=r.sibling}return null}var $s=t.unstable_scheduleCallback,gi=t.unstable_cancelCallback,Ks=t.unstable_shouldYield,Ir=t.unstable_requestPaint,sn=t.unstable_now,ea=t.unstable_getCurrentPriorityLevel,Yr=t.unstable_ImmediatePriority,Ms=t.unstable_UserBlockingPriority,As=t.unstable_NormalPriority,Ys=t.unstable_LowPriority,st=t.unstable_IdlePriority,tn=null,Er=null;function yi(r){if(Er&&typeof Er.onCommitFiberRoot=="function")try{Er.onCommitFiberRoot(tn,r,void 0,(r.current.flags&128)===128)}catch{}}var yr=Math.clz32?Math.clz32:tl,ta=Math.log,el=Math.LN2;function tl(r){return r>>>=0,r===0?32:31-(ta(r)/el|0)|0}var qn=64,as=4194304;function Yn(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function Xs(r,i){var c=r.pendingLanes;if(c===0)return 0;var f=0,p=r.suspendedLanes,x=r.pingedLanes,M=c&268435455;if(M!==0){var X=M&~p;X!==0?f=Yn(X):(x&=M,x!==0&&(f=Yn(x)))}else M=c&~p,M!==0?f=Yn(M):x!==0&&(f=Yn(x));if(f===0)return 0;if(i!==0&&i!==f&&(i&p)===0&&(p=f&-f,x=i&-i,p>=x||p===16&&(x&4194240)!==0))return i;if((f&4)!==0&&(f|=c&16),i=r.entangledLanes,i!==0)for(r=r.entanglements,i&=f;0<i;)c=31-yr(i),p=1<<c,f|=r[c],i&=~p;return f}function na(r,i){switch(r){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 zn(r,i){for(var c=r.suspendedLanes,f=r.pingedLanes,p=r.expirationTimes,x=r.pendingLanes;0<x;){var M=31-yr(x),X=1<<M,re=p[M];re===-1?((X&c)===0||(X&f)!==0)&&(p[M]=na(X,i)):re<=i&&(r.expiredLanes|=X),x&=~X}}function ls(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Xn(){var r=qn;return qn<<=1,(qn&4194240)===0&&(qn=64),r}function cs(r){for(var i=[],c=0;31>c;c++)i.push(r);return i}function Dn(r,i,c){r.pendingLanes|=i,i!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,i=31-yr(i),r[i]=c}function us(r,i){var c=r.pendingLanes&~i;r.pendingLanes=i,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=i,r.mutableReadLanes&=i,r.entangledLanes&=i,i=r.entanglements;var f=r.eventTimes;for(r=r.expirationTimes;0<c;){var p=31-yr(c),x=1<<p;i[p]=0,f[p]=-1,r[p]=-1,c&=~x}}function Js(r,i){var c=r.entangledLanes|=i;for(r=r.entanglements;c;){var f=31-yr(c),p=1<<f;p&i|r[f]&i&&(r[f]|=i),c&=~p}}var Kt=0;function uo(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var ra,sa,Dr,nl,Zs,fo=!1,vi=[],tr=null,nr=null,$r=null,wi=new Map,ds=new Map,Fr=[],fs="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 rl(r,i){switch(r){case"focusin":case"focusout":tr=null;break;case"dragenter":case"dragleave":nr=null;break;case"mouseover":case"mouseout":$r=null;break;case"pointerover":case"pointerout":wi.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":ds.delete(i.pointerId)}}function ms(r,i,c,f,p,x){return r===null||r.nativeEvent!==x?(r={blockedOn:i,domEventName:c,eventSystemFlags:f,nativeEvent:x,targetContainers:[p]},i!==null&&(i=_l(i),i!==null&&sa(i)),r):(r.eventSystemFlags|=f,i=r.targetContainers,p!==null&&i.indexOf(p)===-1&&i.push(p),r)}function oc(r,i,c,f,p){switch(i){case"focusin":return tr=ms(tr,r,i,c,f,p),!0;case"dragenter":return nr=ms(nr,r,i,c,f,p),!0;case"mouseover":return $r=ms($r,r,i,c,f,p),!0;case"pointerover":var x=p.pointerId;return wi.set(x,ms(wi.get(x)||null,r,i,c,f,p)),!0;case"gotpointercapture":return x=p.pointerId,ds.set(x,ms(ds.get(x)||null,r,i,c,f,p)),!0}return!1}function Qs(r){var i=Zi(r.target);if(i!==null){var c=pn(i);if(c!==null){if(i=c.tag,i===13){if(i=er(c),i!==null){r.blockedOn=i,Zs(r.priority,function(){Dr(c)});return}}else if(i===3&&c.stateNode.current.memoizedState.isDehydrated){r.blockedOn=c.tag===3?c.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Ki(r){if(r.blockedOn!==null)return!1;for(var i=r.targetContainers;0<i.length;){var c=ae(r.domEventName,r.eventSystemFlags,i[0],r.nativeEvent);if(c===null){c=r.nativeEvent;var f=new c.constructor(c.type,c);hn=f,c.target.dispatchEvent(f),hn=null}else return i=_l(c),i!==null&&sa(i),r.blockedOn=c,!1;i.shift()}return!0}function ia(r,i,c){Ki(r)&&c.delete(i)}function xi(){fo=!1,tr!==null&&Ki(tr)&&(tr=null),nr!==null&&Ki(nr)&&(nr=null),$r!==null&&Ki($r)&&($r=null),wi.forEach(ia),ds.forEach(ia)}function hs(r,i){r.blockedOn===i&&(r.blockedOn=null,fo||(fo=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,xi)))}function mo(r){function i(p){return hs(p,r)}if(0<vi.length){hs(vi[0],r);for(var c=1;c<vi.length;c++){var f=vi[c];f.blockedOn===r&&(f.blockedOn=null)}}for(tr!==null&&hs(tr,r),nr!==null&&hs(nr,r),$r!==null&&hs($r,r),wi.forEach(i),ds.forEach(i),c=0;c<Fr.length;c++)f=Fr[c],f.blockedOn===r&&(f.blockedOn=null);for(;0<Fr.length&&(c=Fr[0],c.blockedOn===null);)Qs(c),c.blockedOn===null&&Fr.shift()}var ei=P.ReactCurrentBatchConfig,vr=!0;function wu(r,i,c,f){var p=Kt,x=ei.transition;ei.transition=null;try{Kt=1,ho(r,i,c,f)}finally{Kt=p,ei.transition=x}}function Ts(r,i,c,f){var p=Kt,x=ei.transition;ei.transition=null;try{Kt=4,ho(r,i,c,f)}finally{Kt=p,ei.transition=x}}function ho(r,i,c,f){if(vr){var p=ae(r,i,c,f);if(p===null)ma(r,i,f,B,c),rl(r,f);else if(oc(p,r,i,c,f))f.stopPropagation();else if(rl(r,f),i&4&&-1<fs.indexOf(r)){for(;p!==null;){var x=_l(p);if(x!==null&&ra(x),x=ae(r,i,c,f),x===null&&ma(r,i,f,B,c),x===p)break;p=x}p!==null&&f.stopPropagation()}else ma(r,i,f,null,c)}}var B=null;function ae(r,i,c,f){if(B=null,r=Wn(f),r=Zi(r),r!==null)if(i=pn(r),i===null)r=null;else if(c=i.tag,c===13){if(r=er(i),r!==null)return r;r=null}else if(c===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;r=null}else i!==r&&(r=null);return B=r,null}function xe(r){switch(r){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(ea()){case Yr:return 1;case Ms:return 4;case As:case Ys:return 16;case st:return 536870912;default:return 16}default:return 16}}var ke=null,Ee=null,We=null;function ft(){if(We)return We;var r,i=Ee,c=i.length,f,p="value"in ke?ke.value:ke.textContent,x=p.length;for(r=0;r<c&&i[r]===p[r];r++);var M=c-r;for(f=1;f<=M&&i[c-f]===p[x-f];f++);return We=p.slice(r,1<f?1-f:void 0)}function nt(r){var i=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&i===13&&(r=13)):r=i,r===10&&(r=13),32<=r||r===13?r:0}function ut(){return!0}function Dt(){return!1}function Vt(r){function i(c,f,p,x,M){this._reactName=c,this._targetInst=p,this.type=f,this.nativeEvent=x,this.target=M,this.currentTarget=null;for(var X in r)r.hasOwnProperty(X)&&(c=r[X],this[X]=c?c(x):x[X]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?ut:Dt,this.isPropagationStopped=Dt,this}return G(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var c=this.nativeEvent;c&&(c.preventDefault?c.preventDefault():typeof c.returnValue!="unknown"&&(c.returnValue=!1),this.isDefaultPrevented=ut)},stopPropagation:function(){var c=this.nativeEvent;c&&(c.stopPropagation?c.stopPropagation():typeof c.cancelBubble!="unknown"&&(c.cancelBubble=!0),this.isPropagationStopped=ut)},persist:function(){},isPersistent:ut}),i}var Yt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Et=Vt(Yt),Zt=G({},Yt,{view:0,detail:0}),En=Vt(Zt),cn,Br,Jn,bi=G({},Zt,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:dc,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==Jn&&(Jn&&r.type==="mousemove"?(cn=r.screenX-Jn.screenX,Br=r.screenY-Jn.screenY):Br=cn=0,Jn=r),cn)},movementY:function(r){return"movementY"in r?r.movementY:Br}}),Si=Vt(bi),_o=G({},bi,{dataTransfer:0}),po=Vt(_o),xu=G({},Zt,{relatedTarget:0}),go=Vt(xu),sl=G({},Yt,{animationName:0,elapsedTime:0,pseudoElement:0}),ac=Vt(sl),Qd=G({},Yt,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),lc=Vt(Qd),bu=G({},Yt,{data:0}),il=Vt(bu),cc={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uc={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"},ef={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function yo(r){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(r):(r=ef[r])?!!i[r]:!1}function dc(){return yo}var Su=G({},Zt,{key:function(r){if(r.key){var i=cc[r.key]||r.key;if(i!=="Unidentified")return i}return r.type==="keypress"?(r=nt(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?uc[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:dc,charCode:function(r){return r.type==="keypress"?nt(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?nt(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),ju=Vt(Su),ku=G({},bi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),fc=Vt(ku),rh=G({},Zt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:dc}),Nu=Vt(rh),sh=G({},Yt,{propertyName:0,elapsedTime:0,pseudoElement:0}),tf=Vt(sh),Cu=G({},bi,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),Wt=Vt(Cu),Eu=[9,13,27,32],$u=u&&"CompositionEvent"in window,Rs=null;u&&"documentMode"in document&&(Rs=document.documentMode);var ih=u&&"TextEvent"in window&&!Rs,ol=u&&(!$u||Rs&&8<Rs&&11>=Rs),nf=" ",rr=!1;function Ls(r,i){switch(r){case"keyup":return Eu.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function oa(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var aa=!1;function al(r,i){switch(r){case"compositionend":return oa(i);case"keypress":return i.which!==32?null:(rr=!0,nf);case"textInput":return r=i.data,r===nf&&rr?null:r;default:return null}}function Mu(r,i){if(aa)return r==="compositionend"||!$u&&Ls(r,i)?(r=ft(),We=Ee=ke=null,aa=!1,r):null;switch(r){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 ol&&i.locale!=="ko"?null:i.data;default:return null}}var oh={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 Au(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i==="input"?!!oh[r.type]:i==="textarea"}function mc(r,i,c,f){Te(f),i=Ei(i,"onChange"),0<i.length&&(c=new Et("onChange","change",null,c,f),r.push({event:c,listeners:i}))}var vo=null,la=null;function hc(r){ji(r,0)}function ll(r){var i=Co(r);if(Ct(i))return r}function rf(r,i){if(r==="change")return i}var sf=!1;if(u){var ca;if(u){var _c="oninput"in document;if(!_c){var pc=document.createElement("div");pc.setAttribute("oninput","return;"),_c=typeof pc.oninput=="function"}ca=_c}else ca=!1;sf=ca&&(!document.documentMode||9<document.documentMode)}function of(){vo&&(vo.detachEvent("onpropertychange",gc),la=vo=null)}function gc(r){if(r.propertyName==="value"&&ll(la)){var i=[];mc(i,la,r,Wn(r)),vt(hc,i)}}function ah(r,i,c){r==="focusin"?(of(),vo=i,la=c,vo.attachEvent("onpropertychange",gc)):r==="focusout"&&of()}function af(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return ll(la)}function lh(r,i){if(r==="click")return ll(i)}function Tu(r,i){if(r==="input"||r==="change")return ll(i)}function ch(r,i){return r===i&&(r!==0||1/r===1/i)||r!==r&&i!==i}var Xr=typeof Object.is=="function"?Object.is:ch;function cl(r,i){if(Xr(r,i))return!0;if(typeof r!="object"||r===null||typeof i!="object"||i===null)return!1;var c=Object.keys(r),f=Object.keys(i);if(c.length!==f.length)return!1;for(f=0;f<c.length;f++){var p=c[f];if(!m.call(i,p)||!Xr(r[p],i[p]))return!1}return!0}function lf(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function cf(r,i){var c=lf(r);r=0;for(var f;c;){if(c.nodeType===3){if(f=r+c.textContent.length,r<=i&&f>=i)return{node:c,offset:i-r};r=f}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=lf(c)}}function wo(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?wo(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function Ru(){for(var r=window,i=wt();i instanceof r.HTMLIFrameElement;){try{var c=typeof i.contentWindow.location.href=="string"}catch{c=!1}if(c)r=i.contentWindow;else break;i=wt(r.document)}return i}function ua(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i&&(i==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||i==="textarea"||r.contentEditable==="true")}function uh(r){var i=Ru(),c=r.focusedElem,f=r.selectionRange;if(i!==c&&c&&c.ownerDocument&&wo(c.ownerDocument.documentElement,c)){if(f!==null&&ua(c)){if(i=f.start,r=f.end,r===void 0&&(r=i),"selectionStart"in c)c.selectionStart=i,c.selectionEnd=Math.min(r,c.value.length);else if(r=(i=c.ownerDocument||document)&&i.defaultView||window,r.getSelection){r=r.getSelection();var p=c.textContent.length,x=Math.min(f.start,p);f=f.end===void 0?x:Math.min(f.end,p),!r.extend&&x>f&&(p=f,f=x,x=p),p=cf(c,x);var M=cf(c,f);p&&M&&(r.rangeCount!==1||r.anchorNode!==p.node||r.anchorOffset!==p.offset||r.focusNode!==M.node||r.focusOffset!==M.offset)&&(i=i.createRange(),i.setStart(p.node,p.offset),r.removeAllRanges(),x>f?(r.addRange(i),r.extend(M.node,M.offset)):(i.setEnd(M.node,M.offset),r.addRange(i)))}}for(i=[],r=c;r=r.parentNode;)r.nodeType===1&&i.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof c.focus=="function"&&c.focus(),c=0;c<i.length;c++)r=i[c],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var yc=u&&"documentMode"in document&&11>=document.documentMode,Ps=null,xo=null,ti=null,bo=!1;function ul(r,i,c){var f=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;bo||Ps==null||Ps!==wt(f)||(f=Ps,"selectionStart"in f&&ua(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}),ti&&cl(ti,f)||(ti=f,f=Ei(xo,"onSelect"),0<f.length&&(i=new Et("onSelect","select",null,i,c),r.push({event:i,listeners:f}),i.target=Ps)))}function da(r,i){var c={};return c[r.toLowerCase()]=i.toLowerCase(),c["Webkit"+r]="webkit"+i,c["Moz"+r]="moz"+i,c}var So={animationend:da("Animation","AnimationEnd"),animationiteration:da("Animation","AnimationIteration"),animationstart:da("Animation","AnimationStart"),transitionend:da("Transition","TransitionEnd")},jo={},Lu={};u&&(Lu=document.createElement("div").style,"AnimationEvent"in window||(delete So.animationend.animation,delete So.animationiteration.animation,delete So.animationstart.animation),"TransitionEvent"in window||delete So.transitionend.transition);function Yi(r){if(jo[r])return jo[r];if(!So[r])return r;var i=So[r],c;for(c in i)if(i.hasOwnProperty(c)&&c in Lu)return jo[r]=i[c];return r}var dl=Yi("animationend"),uf=Yi("animationiteration"),Pu=Yi("animationstart"),df=Yi("transitionend"),ff=new Map,fl="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 wr(r,i){ff.set(r,i),l(i,[r])}for(var Xi=0;Xi<fl.length;Xi++){var Ou=fl[Xi],vc=Ou.toLowerCase(),dh=Ou[0].toUpperCase()+Ou.slice(1);wr(vc,"on"+dh)}wr(dl,"onAnimationEnd"),wr(uf,"onAnimationIteration"),wr(Pu,"onAnimationStart"),wr("dblclick","onDoubleClick"),wr("focusin","onFocus"),wr("focusout","onBlur"),wr(df,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ko="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(" "),ml=new Set("cancel close invalid load scroll toggle".split(" ").concat(ko));function Jr(r,i,c){var f=r.type||"unknown-event";r.currentTarget=c,ln(f,i,void 0,r),r.currentTarget=null}function ji(r,i){i=(i&4)!==0;for(var c=0;c<r.length;c++){var f=r[c],p=f.event;f=f.listeners;e:{var x=void 0;if(i)for(var M=f.length-1;0<=M;M--){var X=f[M],re=X.instance,_e=X.currentTarget;if(X=X.listener,re!==x&&p.isPropagationStopped())break e;Jr(p,X,_e),x=re}else for(M=0;M<f.length;M++){if(X=f[M],re=X.instance,_e=X.currentTarget,X=X.listener,re!==x&&p.isPropagationStopped())break e;Jr(p,X,_e),x=re}}}if(Lt)throw r=Ve,Lt=!1,Ve=null,r}function un(r,i){var c=i[Iu];c===void 0&&(c=i[Iu]=new Set);var f=r+"__bubble";c.has(f)||(ni(i,r,2,!1),c.add(f))}function ki(r,i,c){var f=0;i&&(f|=4),ni(c,r,f,i)}var fa="_reactListening"+Math.random().toString(36).slice(2);function Ni(r){if(!r[fa]){r[fa]=!0,o.forEach(function(c){c!=="selectionchange"&&(ml.has(c)||ki(c,!1,r),ki(c,!0,r))});var i=r.nodeType===9?r:r.ownerDocument;i===null||i[fa]||(i[fa]=!0,ki("selectionchange",!1,i))}}function ni(r,i,c,f){switch(xe(i)){case 1:var p=wu;break;case 4:p=Ts;break;default:p=ho}c=p.bind(null,i,c,r),p=void 0,!ct||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(p=!0),f?p!==void 0?r.addEventListener(i,c,{capture:!0,passive:p}):r.addEventListener(i,c,!0):p!==void 0?r.addEventListener(i,c,{passive:p}):r.addEventListener(i,c,!1)}function ma(r,i,c,f,p){var x=f;if((i&1)===0&&(i&2)===0&&f!==null)e:for(;;){if(f===null)return;var M=f.tag;if(M===3||M===4){var X=f.stateNode.containerInfo;if(X===p||X.nodeType===8&&X.parentNode===p)break;if(M===4)for(M=f.return;M!==null;){var re=M.tag;if((re===3||re===4)&&(re=M.stateNode.containerInfo,re===p||re.nodeType===8&&re.parentNode===p))return;M=M.return}for(;X!==null;){if(M=Zi(X),M===null)return;if(re=M.tag,re===5||re===6){f=x=M;continue e}X=X.parentNode}}f=f.return}vt(function(){var _e=x,Me=Wn(c),Re=[];e:{var $e=ff.get(r);if($e!==void 0){var Xe=Et,Qe=r;switch(r){case"keypress":if(nt(c)===0)break e;case"keydown":case"keyup":Xe=ju;break;case"focusin":Qe="focus",Xe=go;break;case"focusout":Qe="blur",Xe=go;break;case"beforeblur":case"afterblur":Xe=go;break;case"click":if(c.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Xe=Si;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Xe=po;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Xe=Nu;break;case dl:case uf:case Pu:Xe=ac;break;case df:Xe=tf;break;case"scroll":Xe=En;break;case"wheel":Xe=Wt;break;case"copy":case"cut":case"paste":Xe=lc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Xe=fc}var et=(i&4)!==0,Qn=!et&&r==="scroll",fe=et?$e!==null?$e+"Capture":null:$e;et=[];for(var oe=_e,me;oe!==null;){me=oe;var De=me.stateNode;if(me.tag===5&&De!==null&&(me=De,fe!==null&&(De=zt(oe,fe),De!=null&&et.push(Ci(oe,De,me)))),Qn)break;oe=oe.return}0<et.length&&($e=new Xe($e,Qe,null,c,Me),Re.push({event:$e,listeners:et}))}}if((i&7)===0){e:{if($e=r==="mouseover"||r==="pointerover",Xe=r==="mouseout"||r==="pointerout",$e&&c!==hn&&(Qe=c.relatedTarget||c.fromElement)&&(Zi(Qe)||Qe[ii]))break e;if((Xe||$e)&&($e=Me.window===Me?Me:($e=Me.ownerDocument)?$e.defaultView||$e.parentWindow:window,Xe?(Qe=c.relatedTarget||c.toElement,Xe=_e,Qe=Qe?Zi(Qe):null,Qe!==null&&(Qn=pn(Qe),Qe!==Qn||Qe.tag!==5&&Qe.tag!==6)&&(Qe=null)):(Xe=null,Qe=_e),Xe!==Qe)){if(et=Si,De="onMouseLeave",fe="onMouseEnter",oe="mouse",(r==="pointerout"||r==="pointerover")&&(et=fc,De="onPointerLeave",fe="onPointerEnter",oe="pointer"),Qn=Xe==null?$e:Co(Xe),me=Qe==null?$e:Co(Qe),$e=new et(De,oe+"leave",Xe,c,Me),$e.target=Qn,$e.relatedTarget=me,De=null,Zi(Me)===_e&&(et=new et(fe,oe+"enter",Qe,c,Me),et.target=me,et.relatedTarget=Qn,De=et),Qn=De,Xe&&Qe)t:{for(et=Xe,fe=Qe,oe=0,me=et;me;me=Zr(me))oe++;for(me=0,De=fe;De;De=Zr(De))me++;for(;0<oe-me;)et=Zr(et),oe--;for(;0<me-oe;)fe=Zr(fe),me--;for(;oe--;){if(et===fe||fe!==null&&et===fe.alternate)break t;et=Zr(et),fe=Zr(fe)}et=null}else et=null;Xe!==null&&Mr(Re,$e,Xe,et,!1),Qe!==null&&Qn!==null&&Mr(Re,Qn,Qe,et,!0)}}e:{if($e=_e?Co(_e):window,Xe=$e.nodeName&&$e.nodeName.toLowerCase(),Xe==="select"||Xe==="input"&&$e.type==="file")var tt=rf;else if(Au($e))if(sf)tt=Tu;else{tt=af;var mt=ah}else(Xe=$e.nodeName)&&Xe.toLowerCase()==="input"&&($e.type==="checkbox"||$e.type==="radio")&&(tt=lh);if(tt&&(tt=tt(r,_e))){mc(Re,tt,c,Me);break e}mt&&mt(r,$e,_e),r==="focusout"&&(mt=$e._wrapperState)&&mt.controlled&&$e.type==="number"&&it($e,"number",$e.value)}switch(mt=_e?Co(_e):window,r){case"focusin":(Au(mt)||mt.contentEditable==="true")&&(Ps=mt,xo=_e,ti=null);break;case"focusout":ti=xo=Ps=null;break;case"mousedown":bo=!0;break;case"contextmenu":case"mouseup":case"dragend":bo=!1,ul(Re,c,Me);break;case"selectionchange":if(yc)break;case"keydown":case"keyup":ul(Re,c,Me)}var ht;if($u)e:{switch(r){case"compositionstart":var bt="onCompositionStart";break e;case"compositionend":bt="onCompositionEnd";break e;case"compositionupdate":bt="onCompositionUpdate";break e}bt=void 0}else aa?Ls(r,c)&&(bt="onCompositionEnd"):r==="keydown"&&c.keyCode===229&&(bt="onCompositionStart");bt&&(ol&&c.locale!=="ko"&&(aa||bt!=="onCompositionStart"?bt==="onCompositionEnd"&&aa&&(ht=ft()):(ke=Me,Ee="value"in ke?ke.value:ke.textContent,aa=!0)),mt=Ei(_e,bt),0<mt.length&&(bt=new il(bt,r,null,c,Me),Re.push({event:bt,listeners:mt}),ht?bt.data=ht:(ht=oa(c),ht!==null&&(bt.data=ht)))),(ht=ih?al(r,c):Mu(r,c))&&(_e=Ei(_e,"onBeforeInput"),0<_e.length&&(Me=new il("onBeforeInput","beforeinput",null,c,Me),Re.push({event:Me,listeners:_e}),Me.data=ht))}ji(Re,i)})}function Ci(r,i,c){return{instance:r,listener:i,currentTarget:c}}function Ei(r,i){for(var c=i+"Capture",f=[];r!==null;){var p=r,x=p.stateNode;p.tag===5&&x!==null&&(p=x,x=zt(r,c),x!=null&&f.unshift(Ci(r,x,p)),x=zt(r,i),x!=null&&f.push(Ci(r,x,p))),r=r.return}return f}function Zr(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function Mr(r,i,c,f,p){for(var x=i._reactName,M=[];c!==null&&c!==f;){var X=c,re=X.alternate,_e=X.stateNode;if(re!==null&&re===f)break;X.tag===5&&_e!==null&&(X=_e,p?(re=zt(c,x),re!=null&&M.unshift(Ci(c,re,X))):p||(re=zt(c,x),re!=null&&M.push(Ci(c,re,X)))),c=c.return}M.length!==0&&r.push({event:i,listeners:M})}var No=/\r\n?/g,ha=/\u0000|\uFFFD/g;function hl(r){return(typeof r=="string"?r:""+r).replace(No,`
|
|
38
|
+
`).replace(ha,"")}function ri(r,i,c){if(i=hl(i),hl(r)!==i&&c)throw Error(n(425))}function _a(){}var pa=null,_s=null;function si(r,i){return r==="textarea"||r==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var ps=typeof setTimeout=="function"?setTimeout:void 0,mf=typeof clearTimeout=="function"?clearTimeout:void 0,wc=typeof Promise=="function"?Promise:void 0,fh=typeof queueMicrotask=="function"?queueMicrotask:typeof wc<"u"?function(r){return wc.resolve(null).then(r).catch(xc)}:ps;function xc(r){setTimeout(function(){throw r})}function bc(r,i){var c=i,f=0;do{var p=c.nextSibling;if(r.removeChild(c),p&&p.nodeType===8)if(c=p.data,c==="/$"){if(f===0){r.removeChild(p),mo(i);return}f--}else c!=="$"&&c!=="$?"&&c!=="$!"||f++;c=p}while(c);mo(i)}function gs(r){for(;r!=null;r=r.nextSibling){var i=r.nodeType;if(i===1||i===3)break;if(i===8){if(i=r.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return r}function zu(r){r=r.previousSibling;for(var i=0;r;){if(r.nodeType===8){var c=r.data;if(c==="$"||c==="$!"||c==="$?"){if(i===0)return r;i--}else c==="/$"&&i++}r=r.previousSibling}return null}var Ji=Math.random().toString(36).slice(2),Os="__reactFiber$"+Ji,ga="__reactProps$"+Ji,ii="__reactContainer$"+Ji,Iu="__reactEvents$"+Ji,hf="__reactListeners$"+Ji,mh="__reactHandles$"+Ji;function Zi(r){var i=r[Os];if(i)return i;for(var c=r.parentNode;c;){if(i=c[ii]||c[Os]){if(c=i.alternate,i.child!==null||c!==null&&c.child!==null)for(r=zu(r);r!==null;){if(c=r[Os])return c;r=zu(r)}return i}r=c,c=r.parentNode}return null}function _l(r){return r=r[Os]||r[ii],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function Co(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function Sc(r){return r[ga]||null}var jc=[],ya=-1;function $i(r){return{current:r}}function on(r){0>ya||(r.current=jc[ya],jc[ya]=null,ya--)}function wn(r,i){ya++,jc[ya]=r.current,r.current=i}var ys={},sr=$i(ys),ur=$i(!1),Qi=ys;function zs(r,i){var c=r.type.contextTypes;if(!c)return ys;var f=r.stateNode;if(f&&f.__reactInternalMemoizedUnmaskedChildContext===i)return f.__reactInternalMemoizedMaskedChildContext;var p={},x;for(x in c)p[x]=i[x];return f&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=i,r.__reactInternalMemoizedMaskedChildContext=p),p}function Ur(r){return r=r.childContextTypes,r!=null}function Eo(){on(ur),on(sr)}function _f(r,i,c){if(sr.current!==ys)throw Error(n(168));wn(sr,i),wn(ur,c)}function $o(r,i,c){var f=r.stateNode;if(i=i.childContextTypes,typeof f.getChildContext!="function")return c;f=f.getChildContext();for(var p in f)if(!(p in i))throw Error(n(108,je(r)||"Unknown",p));return G({},c,f)}function kc(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||ys,Qi=sr.current,wn(sr,r),wn(ur,ur.current),!0}function pl(r,i,c){var f=r.stateNode;if(!f)throw Error(n(169));c?(r=$o(r,i,Qi),f.__reactInternalMemoizedMergedChildContext=r,on(ur),on(sr),wn(sr,r)):on(ur),wn(ur,c)}var Mi=null,Is=!1,Nc=!1;function va(r){Mi===null?Mi=[r]:Mi.push(r)}function gl(r){Is=!0,va(r)}function Ai(){if(!Nc&&Mi!==null){Nc=!0;var r=0,i=Kt;try{var c=Mi;for(Kt=1;r<c.length;r++){var f=c[r];do f=f(!0);while(f!==null)}Mi=null,Is=!1}catch(p){throw Mi!==null&&(Mi=Mi.slice(r+1)),$s(Yr,Ai),p}finally{Kt=i,Nc=!1}}return null}var eo=[],oi=0,wa=null,Ti=0,Hr=[],vs=0,ai=null,li=1,Ri="";function Mo(r,i){eo[oi++]=Ti,eo[oi++]=wa,wa=r,Ti=i}function to(r,i,c){Hr[vs++]=li,Hr[vs++]=Ri,Hr[vs++]=ai,ai=r;var f=li;r=Ri;var p=32-yr(f)-1;f&=~(1<<p),c+=1;var x=32-yr(i)+p;if(30<x){var M=p-p%5;x=(f&(1<<M)-1).toString(32),f>>=M,p-=M,li=1<<32-yr(i)+p|c<<p|f,Ri=x+r}else li=1<<x|c<<p|f,Ri=r}function dr(r){r.return!==null&&(Mo(r,1),to(r,1,0))}function xa(r){for(;r===wa;)wa=eo[--oi],eo[oi]=null,Ti=eo[--oi],eo[oi]=null;for(;r===ai;)ai=Hr[--vs],Hr[vs]=null,Ri=Hr[--vs],Hr[vs]=null,li=Hr[--vs],Hr[vs]=null}var Ar=null,Qr=null,$n=!1,Wr=null;function pf(r,i){var c=fi(5,null,null,0);c.elementType="DELETED",c.stateNode=i,c.return=r,i=r.deletions,i===null?(r.deletions=[c],r.flags|=16):i.push(c)}function ba(r,i){switch(r.tag){case 5:var c=r.type;return i=i.nodeType!==1||c.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(r.stateNode=i,Ar=r,Qr=gs(i.firstChild),!0):!1;case 6:return i=r.pendingProps===""||i.nodeType!==3?null:i,i!==null?(r.stateNode=i,Ar=r,Qr=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(c=ai!==null?{id:li,overflow:Ri}:null,r.memoizedState={dehydrated:i,treeContext:c,retryLane:1073741824},c=fi(18,null,null,0),c.stateNode=i,c.return=r,r.child=c,Ar=r,Qr=null,!0):!1;default:return!1}}function Cc(r){return(r.mode&1)!==0&&(r.flags&128)===0}function Ao(r){if($n){var i=Qr;if(i){var c=i;if(!ba(r,i)){if(Cc(r))throw Error(n(418));i=gs(c.nextSibling);var f=Ar;i&&ba(r,i)?pf(f,c):(r.flags=r.flags&-4097|2,$n=!1,Ar=r)}}else{if(Cc(r))throw Error(n(418));r.flags=r.flags&-4097|2,$n=!1,Ar=r}}}function Du(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Ar=r}function yl(r){if(r!==Ar)return!1;if(!$n)return Du(r),$n=!0,!1;var i;if((i=r.tag!==3)&&!(i=r.tag!==5)&&(i=r.type,i=i!=="head"&&i!=="body"&&!si(r.type,r.memoizedProps)),i&&(i=Qr)){if(Cc(r))throw gf(),Error(n(418));for(;i;)pf(r,i),i=gs(i.nextSibling)}if(Du(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,i=0;r;){if(r.nodeType===8){var c=r.data;if(c==="/$"){if(i===0){Qr=gs(r.nextSibling);break e}i--}else c!=="$"&&c!=="$!"&&c!=="$?"||i++}r=r.nextSibling}Qr=null}}else Qr=Ar?gs(r.stateNode.nextSibling):null;return!0}function gf(){for(var r=Qr;r;)r=gs(r.nextSibling)}function To(){Qr=Ar=null,$n=!1}function Ec(r){Wr===null?Wr=[r]:Wr.push(r)}var yf=P.ReactCurrentBatchConfig;function vl(r,i,c){if(r=c.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(c._owner){if(c=c._owner,c){if(c.tag!==1)throw Error(n(309));var f=c.stateNode}if(!f)throw Error(n(147,r));var p=f,x=""+r;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===x?i.ref:(i=function(M){var X=p.refs;M===null?delete X[x]:X[x]=M},i._stringRef=x,i)}if(typeof r!="string")throw Error(n(284));if(!c._owner)throw Error(n(290,r))}return r}function wl(r,i){throw r=Object.prototype.toString.call(i),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":r))}function xl(r){var i=r._init;return i(r._payload)}function vf(r){function i(fe,oe){if(r){var me=fe.deletions;me===null?(fe.deletions=[oe],fe.flags|=16):me.push(oe)}}function c(fe,oe){if(!r)return null;for(;oe!==null;)i(fe,oe),oe=oe.sibling;return null}function f(fe,oe){for(fe=new Map;oe!==null;)oe.key!==null?fe.set(oe.key,oe):fe.set(oe.index,oe),oe=oe.sibling;return fe}function p(fe,oe){return fe=Fa(fe,oe),fe.index=0,fe.sibling=null,fe}function x(fe,oe,me){return fe.index=me,r?(me=fe.alternate,me!==null?(me=me.index,me<oe?(fe.flags|=2,oe):me):(fe.flags|=2,oe)):(fe.flags|=1048576,oe)}function M(fe){return r&&fe.alternate===null&&(fe.flags|=2),fe}function X(fe,oe,me,De){return oe===null||oe.tag!==6?(oe=vh(me,fe.mode,De),oe.return=fe,oe):(oe=p(oe,me),oe.return=fe,oe)}function re(fe,oe,me,De){var tt=me.type;return tt===Z?Me(fe,oe,me.props.children,De,me.key):oe!==null&&(oe.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===z&&xl(tt)===oe.type)?(De=p(oe,me.props),De.ref=vl(fe,oe,me),De.return=fe,De):(De=Yf(me.type,me.key,me.props,null,fe.mode,De),De.ref=vl(fe,oe,me),De.return=fe,De)}function _e(fe,oe,me,De){return oe===null||oe.tag!==4||oe.stateNode.containerInfo!==me.containerInfo||oe.stateNode.implementation!==me.implementation?(oe=wh(me,fe.mode,De),oe.return=fe,oe):(oe=p(oe,me.children||[]),oe.return=fe,oe)}function Me(fe,oe,me,De,tt){return oe===null||oe.tag!==7?(oe=ql(me,fe.mode,De,tt),oe.return=fe,oe):(oe=p(oe,me),oe.return=fe,oe)}function Re(fe,oe,me){if(typeof oe=="string"&&oe!==""||typeof oe=="number")return oe=vh(""+oe,fe.mode,me),oe.return=fe,oe;if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case K:return me=Yf(oe.type,oe.key,oe.props,null,fe.mode,me),me.ref=vl(fe,null,oe),me.return=fe,me;case Q:return oe=wh(oe,fe.mode,me),oe.return=fe,oe;case z:var De=oe._init;return Re(fe,De(oe._payload),me)}if(ve(oe)||O(oe))return oe=ql(oe,fe.mode,me,null),oe.return=fe,oe;wl(fe,oe)}return null}function $e(fe,oe,me,De){var tt=oe!==null?oe.key:null;if(typeof me=="string"&&me!==""||typeof me=="number")return tt!==null?null:X(fe,oe,""+me,De);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case K:return me.key===tt?re(fe,oe,me,De):null;case Q:return me.key===tt?_e(fe,oe,me,De):null;case z:return tt=me._init,$e(fe,oe,tt(me._payload),De)}if(ve(me)||O(me))return tt!==null?null:Me(fe,oe,me,De,null);wl(fe,me)}return null}function Xe(fe,oe,me,De,tt){if(typeof De=="string"&&De!==""||typeof De=="number")return fe=fe.get(me)||null,X(oe,fe,""+De,tt);if(typeof De=="object"&&De!==null){switch(De.$$typeof){case K:return fe=fe.get(De.key===null?me:De.key)||null,re(oe,fe,De,tt);case Q:return fe=fe.get(De.key===null?me:De.key)||null,_e(oe,fe,De,tt);case z:var mt=De._init;return Xe(fe,oe,me,mt(De._payload),tt)}if(ve(De)||O(De))return fe=fe.get(me)||null,Me(oe,fe,De,tt,null);wl(oe,De)}return null}function Qe(fe,oe,me,De){for(var tt=null,mt=null,ht=oe,bt=oe=0,jr=null;ht!==null&&bt<me.length;bt++){ht.index>bt?(jr=ht,ht=null):jr=ht.sibling;var nn=$e(fe,ht,me[bt],De);if(nn===null){ht===null&&(ht=jr);break}r&&ht&&nn.alternate===null&&i(fe,ht),oe=x(nn,oe,bt),mt===null?tt=nn:mt.sibling=nn,mt=nn,ht=jr}if(bt===me.length)return c(fe,ht),$n&&Mo(fe,bt),tt;if(ht===null){for(;bt<me.length;bt++)ht=Re(fe,me[bt],De),ht!==null&&(oe=x(ht,oe,bt),mt===null?tt=ht:mt.sibling=ht,mt=ht);return $n&&Mo(fe,bt),tt}for(ht=f(fe,ht);bt<me.length;bt++)jr=Xe(ht,fe,bt,me[bt],De),jr!==null&&(r&&jr.alternate!==null&&ht.delete(jr.key===null?bt:jr.key),oe=x(jr,oe,bt),mt===null?tt=jr:mt.sibling=jr,mt=jr);return r&&ht.forEach(function(Ba){return i(fe,Ba)}),$n&&Mo(fe,bt),tt}function et(fe,oe,me,De){var tt=O(me);if(typeof tt!="function")throw Error(n(150));if(me=tt.call(me),me==null)throw Error(n(151));for(var mt=tt=null,ht=oe,bt=oe=0,jr=null,nn=me.next();ht!==null&&!nn.done;bt++,nn=me.next()){ht.index>bt?(jr=ht,ht=null):jr=ht.sibling;var Ba=$e(fe,ht,nn.value,De);if(Ba===null){ht===null&&(ht=jr);break}r&&ht&&Ba.alternate===null&&i(fe,ht),oe=x(Ba,oe,bt),mt===null?tt=Ba:mt.sibling=Ba,mt=Ba,ht=jr}if(nn.done)return c(fe,ht),$n&&Mo(fe,bt),tt;if(ht===null){for(;!nn.done;bt++,nn=me.next())nn=Re(fe,nn.value,De),nn!==null&&(oe=x(nn,oe,bt),mt===null?tt=nn:mt.sibling=nn,mt=nn);return $n&&Mo(fe,bt),tt}for(ht=f(fe,ht);!nn.done;bt++,nn=me.next())nn=Xe(ht,fe,bt,nn.value,De),nn!==null&&(r&&nn.alternate!==null&&ht.delete(nn.key===null?bt:nn.key),oe=x(nn,oe,bt),mt===null?tt=nn:mt.sibling=nn,mt=nn);return r&&ht.forEach(function(tx){return i(fe,tx)}),$n&&Mo(fe,bt),tt}function Qn(fe,oe,me,De){if(typeof me=="object"&&me!==null&&me.type===Z&&me.key===null&&(me=me.props.children),typeof me=="object"&&me!==null){switch(me.$$typeof){case K:e:{for(var tt=me.key,mt=oe;mt!==null;){if(mt.key===tt){if(tt=me.type,tt===Z){if(mt.tag===7){c(fe,mt.sibling),oe=p(mt,me.props.children),oe.return=fe,fe=oe;break e}}else if(mt.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===z&&xl(tt)===mt.type){c(fe,mt.sibling),oe=p(mt,me.props),oe.ref=vl(fe,mt,me),oe.return=fe,fe=oe;break e}c(fe,mt);break}else i(fe,mt);mt=mt.sibling}me.type===Z?(oe=ql(me.props.children,fe.mode,De,me.key),oe.return=fe,fe=oe):(De=Yf(me.type,me.key,me.props,null,fe.mode,De),De.ref=vl(fe,oe,me),De.return=fe,fe=De)}return M(fe);case Q:e:{for(mt=me.key;oe!==null;){if(oe.key===mt)if(oe.tag===4&&oe.stateNode.containerInfo===me.containerInfo&&oe.stateNode.implementation===me.implementation){c(fe,oe.sibling),oe=p(oe,me.children||[]),oe.return=fe,fe=oe;break e}else{c(fe,oe);break}else i(fe,oe);oe=oe.sibling}oe=wh(me,fe.mode,De),oe.return=fe,fe=oe}return M(fe);case z:return mt=me._init,Qn(fe,oe,mt(me._payload),De)}if(ve(me))return Qe(fe,oe,me,De);if(O(me))return et(fe,oe,me,De);wl(fe,me)}return typeof me=="string"&&me!==""||typeof me=="number"?(me=""+me,oe!==null&&oe.tag===6?(c(fe,oe.sibling),oe=p(oe,me),oe.return=fe,fe=oe):(c(fe,oe),oe=vh(me,fe.mode,De),oe.return=fe,fe=oe),M(fe)):c(fe,oe)}return Qn}var Sa=vf(!0),wf=vf(!1),$c=$i(null),ja=null,ka=null,bl=null;function Fu(){bl=ka=ja=null}function Mc(r){var i=$c.current;on($c),r._currentValue=i}function Bu(r,i,c){for(;r!==null;){var f=r.alternate;if((r.childLanes&i)!==i?(r.childLanes|=i,f!==null&&(f.childLanes|=i)):f!==null&&(f.childLanes&i)!==i&&(f.childLanes|=i),r===c)break;r=r.return}}function no(r,i){ja=r,bl=ka=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&i)!==0&&(On=!0),r.firstContext=null)}function Le(r){var i=r._currentValue;if(bl!==r)if(r={context:r,memoizedValue:i,next:null},ka===null){if(ja===null)throw Error(n(308));ka=r,ja.dependencies={lanes:0,firstContext:r}}else ka=ka.next=r;return i}var Ro=null;function Uu(r){Ro===null?Ro=[r]:Ro.push(r)}function Hu(r,i,c,f){var p=i.interleaved;return p===null?(c.next=c,Uu(i)):(c.next=p.next,p.next=c),i.interleaved=c,ci(r,f)}function ci(r,i){r.lanes|=i;var c=r.alternate;for(c!==null&&(c.lanes|=i),c=r,r=r.return;r!==null;)r.childLanes|=i,c=r.alternate,c!==null&&(c.childLanes|=i),c=r,r=r.return;return c.tag===3?c.stateNode:null}var ro=!1;function Na(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function xr(r,i){r=r.updateQueue,i.updateQueue===r&&(i.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function Tt(r,i){return{eventTime:r,lane:i,tag:0,payload:null,callback:null,next:null}}function Pn(r,i,c){var f=r.updateQueue;if(f===null)return null;if(f=f.shared,(Gt&2)!==0){var p=f.pending;return p===null?i.next=i:(i.next=p.next,p.next=i),f.pending=i,ci(r,c)}return p=f.interleaved,p===null?(i.next=i,Uu(f)):(i.next=p.next,p.next=i),f.interleaved=i,ci(r,c)}function Ca(r,i,c){if(i=i.updateQueue,i!==null&&(i=i.shared,(c&4194240)!==0)){var f=i.lanes;f&=r.pendingLanes,c|=f,i.lanes=c,Js(r,c)}}function Wu(r,i){var c=r.updateQueue,f=r.alternate;if(f!==null&&(f=f.updateQueue,c===f)){var p=null,x=null;if(c=c.firstBaseUpdate,c!==null){do{var M={eventTime:c.eventTime,lane:c.lane,tag:c.tag,payload:c.payload,callback:c.callback,next:null};x===null?p=x=M:x=x.next=M,c=c.next}while(c!==null);x===null?p=x=i:x=x.next=i}else p=x=i;c={baseState:f.baseState,firstBaseUpdate:p,lastBaseUpdate:x,shared:f.shared,effects:f.effects},r.updateQueue=c;return}r=c.lastBaseUpdate,r===null?c.firstBaseUpdate=i:r.next=i,c.lastBaseUpdate=i}function Li(r,i,c,f){var p=r.updateQueue;ro=!1;var x=p.firstBaseUpdate,M=p.lastBaseUpdate,X=p.shared.pending;if(X!==null){p.shared.pending=null;var re=X,_e=re.next;re.next=null,M===null?x=_e:M.next=_e,M=re;var Me=r.alternate;Me!==null&&(Me=Me.updateQueue,X=Me.lastBaseUpdate,X!==M&&(X===null?Me.firstBaseUpdate=_e:X.next=_e,Me.lastBaseUpdate=re))}if(x!==null){var Re=p.baseState;M=0,Me=_e=re=null,X=x;do{var $e=X.lane,Xe=X.eventTime;if((f&$e)===$e){Me!==null&&(Me=Me.next={eventTime:Xe,lane:0,tag:X.tag,payload:X.payload,callback:X.callback,next:null});e:{var Qe=r,et=X;switch($e=i,Xe=c,et.tag){case 1:if(Qe=et.payload,typeof Qe=="function"){Re=Qe.call(Xe,Re,$e);break e}Re=Qe;break e;case 3:Qe.flags=Qe.flags&-65537|128;case 0:if(Qe=et.payload,$e=typeof Qe=="function"?Qe.call(Xe,Re,$e):Qe,$e==null)break e;Re=G({},Re,$e);break e;case 2:ro=!0}}X.callback!==null&&X.lane!==0&&(r.flags|=64,$e=p.effects,$e===null?p.effects=[X]:$e.push(X))}else Xe={eventTime:Xe,lane:$e,tag:X.tag,payload:X.payload,callback:X.callback,next:null},Me===null?(_e=Me=Xe,re=Re):Me=Me.next=Xe,M|=$e;if(X=X.next,X===null){if(X=p.shared.pending,X===null)break;$e=X,X=$e.next,$e.next=null,p.lastBaseUpdate=$e,p.shared.pending=null}}while(!0);if(Me===null&&(re=Re),p.baseState=re,p.firstBaseUpdate=_e,p.lastBaseUpdate=Me,i=p.shared.interleaved,i!==null){p=i;do M|=p.lane,p=p.next;while(p!==i)}else x===null&&(p.shared.lanes=0);zi|=M,r.lanes=M,r.memoizedState=Re}}function qu(r,i,c){if(r=i.effects,i.effects=null,r!==null)for(i=0;i<r.length;i++){var f=r[i],p=f.callback;if(p!==null){if(f.callback=null,f=c,typeof p!="function")throw Error(n(191,p));p.call(f)}}}var gt={},ui=$i(gt),Lo=$i(gt),Sl=$i(gt);function Po(r){if(r===gt)throw Error(n(174));return r}function Ac(r,i){switch(wn(Sl,i),wn(Lo,r),wn(ui,gt),r=i.nodeType,r){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:At(null,"");break;default:r=r===8?i.parentNode:i,i=r.namespaceURI||null,r=r.tagName,i=At(i,r)}on(ui),wn(ui,i)}function Ea(){on(ui),on(Lo),on(Sl)}function xf(r){Po(Sl.current);var i=Po(ui.current),c=At(i,r.type);i!==c&&(wn(Lo,r),wn(ui,c))}function Vu(r){Lo.current===r&&(on(ui),on(Lo))}var Sn=$i(0);function Tc(r){for(var i=r;i!==null;){if(i.tag===13){var c=i.memoizedState;if(c!==null&&(c=c.dehydrated,c===null||c.data==="$?"||c.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===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var qr=[];function jl(){for(var r=0;r<qr.length;r++)qr[r]._workInProgressVersionPrimary=null;qr.length=0}var Rc=P.ReactCurrentDispatcher,Gu=P.ReactCurrentBatchConfig,Oo=0,Mn=null,Fn=null,ir=null,xn=!1,$a=!1,zo=0,Tr=0;function fr(){throw Error(n(321))}function Io(r,i){if(i===null)return!1;for(var c=0;c<i.length&&c<r.length;c++)if(!Xr(r[c],i[c]))return!1;return!0}function kl(r,i,c,f,p,x){if(Oo=x,Mn=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,Rc.current=r===null||r.memoizedState===null?Tf:Rf,r=c(f,p),$a){x=0;do{if($a=!1,zo=0,25<=x)throw Error(n(301));x+=1,ir=Fn=null,i.updateQueue=null,Rc.current=Lf,r=c(f,p)}while($a)}if(Rc.current=Pi,i=Fn!==null&&Fn.next!==null,Oo=0,ir=Fn=Mn=null,xn=!1,i)throw Error(n(300));return r}function Do(){var r=zo!==0;return zo=0,r}function ws(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ir===null?Mn.memoizedState=ir=r:ir=ir.next=r,ir}function xs(){if(Fn===null){var r=Mn.alternate;r=r!==null?r.memoizedState:null}else r=Fn.next;var i=ir===null?Mn.memoizedState:ir.next;if(i!==null)ir=i,Fn=r;else{if(r===null)throw Error(n(310));Fn=r,r={memoizedState:Fn.memoizedState,baseState:Fn.baseState,baseQueue:Fn.baseQueue,queue:Fn.queue,next:null},ir===null?Mn.memoizedState=ir=r:ir=ir.next=r}return ir}function Nl(r,i){return typeof i=="function"?i(r):i}function Ku(r){var i=xs(),c=i.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=r;var f=Fn,p=f.baseQueue,x=c.pending;if(x!==null){if(p!==null){var M=p.next;p.next=x.next,x.next=M}f.baseQueue=p=x,c.pending=null}if(p!==null){x=p.next,f=f.baseState;var X=M=null,re=null,_e=x;do{var Me=_e.lane;if((Oo&Me)===Me)re!==null&&(re=re.next={lane:0,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null}),f=_e.hasEagerState?_e.eagerState:r(f,_e.action);else{var Re={lane:Me,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null};re===null?(X=re=Re,M=f):re=re.next=Re,Mn.lanes|=Me,zi|=Me}_e=_e.next}while(_e!==null&&_e!==x);re===null?M=f:re.next=X,Xr(f,i.memoizedState)||(On=!0),i.memoizedState=f,i.baseState=M,i.baseQueue=re,c.lastRenderedState=f}if(r=c.interleaved,r!==null){p=r;do x=p.lane,Mn.lanes|=x,zi|=x,p=p.next;while(p!==r)}else p===null&&(c.lanes=0);return[i.memoizedState,c.dispatch]}function Cl(r){var i=xs(),c=i.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=r;var f=c.dispatch,p=c.pending,x=i.memoizedState;if(p!==null){c.pending=null;var M=p=p.next;do x=r(x,M.action),M=M.next;while(M!==p);Xr(x,i.memoizedState)||(On=!0),i.memoizedState=x,i.baseQueue===null&&(i.baseState=x),c.lastRenderedState=x}return[x,f]}function Lc(){}function bf(r,i){var c=Mn,f=xs(),p=i(),x=!Xr(f.memoizedState,p);if(x&&(f.memoizedState=p,On=!0),f=f.queue,Ic(bs.bind(null,c,f,r),[r]),f.getSnapshot!==i||x||ir!==null&&ir.memoizedState.tag&1){if(c.flags|=2048,Ma(9,Sf.bind(null,c,f,p,i),void 0,null),Zn===null)throw Error(n(349));(Oo&30)!==0||Pc(c,i,p)}return p}function Pc(r,i,c){r.flags|=16384,r={getSnapshot:i,value:c},i=Mn.updateQueue,i===null?(i={lastEffect:null,stores:null},Mn.updateQueue=i,i.stores=[r]):(c=i.stores,c===null?i.stores=[r]:c.push(r))}function Sf(r,i,c,f){i.value=c,i.getSnapshot=f,Fo(i)&&Bn(r)}function bs(r,i,c){return c(function(){Fo(i)&&Bn(r)})}function Fo(r){var i=r.getSnapshot;r=r.value;try{var c=i();return!Xr(r,c)}catch{return!0}}function Bn(r){var i=ci(r,1);i!==null&&ks(i,r,1,-1)}function Yu(r){var i=ws();return typeof r=="function"&&(r=r()),i.memoizedState=i.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Nl,lastRenderedState:r},i.queue=r,r=r.dispatch=Aa.bind(null,Mn,r),[i.memoizedState,r]}function Ma(r,i,c,f){return r={tag:r,create:i,destroy:c,deps:f,next:null},i=Mn.updateQueue,i===null?(i={lastEffect:null,stores:null},Mn.updateQueue=i,i.lastEffect=r.next=r):(c=i.lastEffect,c===null?i.lastEffect=r.next=r:(f=c.next,c.next=r,r.next=f,i.lastEffect=r)),r}function jf(){return xs().memoizedState}function Oc(r,i,c,f){var p=ws();Mn.flags|=r,p.memoizedState=Ma(1|i,c,void 0,f===void 0?null:f)}function zc(r,i,c,f){var p=xs();f=f===void 0?null:f;var x=void 0;if(Fn!==null){var M=Fn.memoizedState;if(x=M.destroy,f!==null&&Io(f,M.deps)){p.memoizedState=Ma(i,c,x,f);return}}Mn.flags|=r,p.memoizedState=Ma(1|i,c,x,f)}function Xu(r,i){return Oc(8390656,8,r,i)}function Ic(r,i){return zc(2048,8,r,i)}function kf(r,i){return zc(4,2,r,i)}function Nf(r,i){return zc(4,4,r,i)}function Xt(r,i){if(typeof i=="function")return r=r(),i(r),function(){i(null)};if(i!=null)return r=r(),i.current=r,function(){i.current=null}}function An(r,i,c){return c=c!=null?c.concat([r]):null,zc(4,4,Xt.bind(null,i,r),c)}function Rr(){}function Dc(r,i){var c=xs();i=i===void 0?null:i;var f=c.memoizedState;return f!==null&&i!==null&&Io(i,f[1])?f[0]:(c.memoizedState=[r,i],r)}function El(r,i){var c=xs();i=i===void 0?null:i;var f=c.memoizedState;return f!==null&&i!==null&&Io(i,f[1])?f[0]:(r=r(),c.memoizedState=[r,i],r)}function Ju(r,i,c){return(Oo&21)===0?(r.baseState&&(r.baseState=!1,On=!0),r.memoizedState=c):(Xr(c,i)||(c=Xn(),Mn.lanes|=c,zi|=c,r.baseState=!0),i)}function hh(r,i){var c=Kt;Kt=c!==0&&4>c?c:4,r(!0);var f=Gu.transition;Gu.transition={};try{r(!1),i()}finally{Kt=c,Gu.transition=f}}function Cf(){return xs().memoizedState}function Ef(r,i,c){var f=Fi(r);if(c={lane:f,action:c,hasEagerState:!1,eagerState:null,next:null},$f(r))Mf(i,c);else if(c=Hu(r,i,c,f),c!==null){var p=Sr();ks(c,r,f,p),Af(c,i,f)}}function Aa(r,i,c){var f=Fi(r),p={lane:f,action:c,hasEagerState:!1,eagerState:null,next:null};if($f(r))Mf(i,p);else{var x=r.alternate;if(r.lanes===0&&(x===null||x.lanes===0)&&(x=i.lastRenderedReducer,x!==null))try{var M=i.lastRenderedState,X=x(M,c);if(p.hasEagerState=!0,p.eagerState=X,Xr(X,M)){var re=i.interleaved;re===null?(p.next=p,Uu(i)):(p.next=re.next,re.next=p),i.interleaved=p;return}}catch{}finally{}c=Hu(r,i,p,f),c!==null&&(p=Sr(),ks(c,r,f,p),Af(c,i,f))}}function $f(r){var i=r.alternate;return r===Mn||i!==null&&i===Mn}function Mf(r,i){$a=xn=!0;var c=r.pending;c===null?i.next=i:(i.next=c.next,c.next=i),r.pending=i}function Af(r,i,c){if((c&4194240)!==0){var f=i.lanes;f&=r.pendingLanes,c|=f,i.lanes=c,Js(r,c)}}var Pi={readContext:Le,useCallback:fr,useContext:fr,useEffect:fr,useImperativeHandle:fr,useInsertionEffect:fr,useLayoutEffect:fr,useMemo:fr,useReducer:fr,useRef:fr,useState:fr,useDebugValue:fr,useDeferredValue:fr,useTransition:fr,useMutableSource:fr,useSyncExternalStore:fr,useId:fr,unstable_isNewReconciler:!1},Tf={readContext:Le,useCallback:function(r,i){return ws().memoizedState=[r,i===void 0?null:i],r},useContext:Le,useEffect:Xu,useImperativeHandle:function(r,i,c){return c=c!=null?c.concat([r]):null,Oc(4194308,4,Xt.bind(null,i,r),c)},useLayoutEffect:function(r,i){return Oc(4194308,4,r,i)},useInsertionEffect:function(r,i){return Oc(4,2,r,i)},useMemo:function(r,i){var c=ws();return i=i===void 0?null:i,r=r(),c.memoizedState=[r,i],r},useReducer:function(r,i,c){var f=ws();return i=c!==void 0?c(i):i,f.memoizedState=f.baseState=i,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:i},f.queue=r,r=r.dispatch=Ef.bind(null,Mn,r),[f.memoizedState,r]},useRef:function(r){var i=ws();return r={current:r},i.memoizedState=r},useState:Yu,useDebugValue:Rr,useDeferredValue:function(r){return ws().memoizedState=r},useTransition:function(){var r=Yu(!1),i=r[0];return r=hh.bind(null,r[1]),ws().memoizedState=r,[i,r]},useMutableSource:function(){},useSyncExternalStore:function(r,i,c){var f=Mn,p=ws();if($n){if(c===void 0)throw Error(n(407));c=c()}else{if(c=i(),Zn===null)throw Error(n(349));(Oo&30)!==0||Pc(f,i,c)}p.memoizedState=c;var x={value:c,getSnapshot:i};return p.queue=x,Xu(bs.bind(null,f,x,r),[r]),f.flags|=2048,Ma(9,Sf.bind(null,f,x,c,i),void 0,null),c},useId:function(){var r=ws(),i=Zn.identifierPrefix;if($n){var c=Ri,f=li;c=(f&~(1<<32-yr(f)-1)).toString(32)+c,i=":"+i+"R"+c,c=zo++,0<c&&(i+="H"+c.toString(32)),i+=":"}else c=Tr++,i=":"+i+"r"+c.toString(32)+":";return r.memoizedState=i},unstable_isNewReconciler:!1},Rf={readContext:Le,useCallback:Dc,useContext:Le,useEffect:Ic,useImperativeHandle:An,useInsertionEffect:kf,useLayoutEffect:Nf,useMemo:El,useReducer:Ku,useRef:jf,useState:function(){return Ku(Nl)},useDebugValue:Rr,useDeferredValue:function(r){var i=xs();return Ju(i,Fn.memoizedState,r)},useTransition:function(){var r=Ku(Nl)[0],i=xs().memoizedState;return[r,i]},useMutableSource:Lc,useSyncExternalStore:bf,useId:Cf,unstable_isNewReconciler:!1},Lf={readContext:Le,useCallback:Dc,useContext:Le,useEffect:Ic,useImperativeHandle:An,useInsertionEffect:kf,useLayoutEffect:Nf,useMemo:El,useReducer:Cl,useRef:jf,useState:function(){return Cl(Nl)},useDebugValue:Rr,useDeferredValue:function(r){var i=xs();return Fn===null?i.memoizedState=r:Ju(i,Fn.memoizedState,r)},useTransition:function(){var r=Cl(Nl)[0],i=xs().memoizedState;return[r,i]},useMutableSource:Lc,useSyncExternalStore:bf,useId:Cf,unstable_isNewReconciler:!1};function Ss(r,i){if(r&&r.defaultProps){i=G({},i),r=r.defaultProps;for(var c in r)i[c]===void 0&&(i[c]=r[c]);return i}return i}function Zu(r,i,c,f){i=r.memoizedState,c=c(f,i),c=c==null?i:G({},i,c),r.memoizedState=c,r.lanes===0&&(r.updateQueue.baseState=c)}var Fc={isMounted:function(r){return(r=r._reactInternals)?pn(r)===r:!1},enqueueSetState:function(r,i,c){r=r._reactInternals;var f=Sr(),p=Fi(r),x=Tt(f,p);x.payload=i,c!=null&&(x.callback=c),i=Pn(r,x,p),i!==null&&(ks(i,r,p,f),Ca(i,r,p))},enqueueReplaceState:function(r,i,c){r=r._reactInternals;var f=Sr(),p=Fi(r),x=Tt(f,p);x.tag=1,x.payload=i,c!=null&&(x.callback=c),i=Pn(r,x,p),i!==null&&(ks(i,r,p,f),Ca(i,r,p))},enqueueForceUpdate:function(r,i){r=r._reactInternals;var c=Sr(),f=Fi(r),p=Tt(c,f);p.tag=2,i!=null&&(p.callback=i),i=Pn(r,p,f),i!==null&&(ks(i,r,f,c),Ca(i,r,f))}};function Pf(r,i,c,f,p,x,M){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(f,x,M):i.prototype&&i.prototype.isPureReactComponent?!cl(c,f)||!cl(p,x):!0}function Of(r,i,c){var f=!1,p=ys,x=i.contextType;return typeof x=="object"&&x!==null?x=Le(x):(p=Ur(i)?Qi:sr.current,f=i.contextTypes,x=(f=f!=null)?zs(r,p):ys),i=new i(c,x),r.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=Fc,r.stateNode=i,i._reactInternals=r,f&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=p,r.__reactInternalMemoizedMaskedChildContext=x),i}function zf(r,i,c,f){r=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(c,f),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(c,f),i.state!==r&&Fc.enqueueReplaceState(i,i.state,null)}function Qu(r,i,c,f){var p=r.stateNode;p.props=c,p.state=r.memoizedState,p.refs={},Na(r);var x=i.contextType;typeof x=="object"&&x!==null?p.context=Le(x):(x=Ur(i)?Qi:sr.current,p.context=zs(r,x)),p.state=r.memoizedState,x=i.getDerivedStateFromProps,typeof x=="function"&&(Zu(r,i,x,c),p.state=r.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&&Fc.enqueueReplaceState(p,p.state,null),Li(r,c,p,f),p.state=r.memoizedState),typeof p.componentDidMount=="function"&&(r.flags|=4194308)}function Ta(r,i){try{var c="",f=i;do c+=he(f),f=f.return;while(f);var p=c}catch(x){p=`
|
|
39
|
+
Error generating stack: `+x.message+`
|
|
40
|
+
`+x.stack}return{value:r,source:i,stack:p,digest:null}}function Bc(r,i,c){return{value:r,source:null,stack:c??null,digest:i??null}}function $l(r,i){try{console.error(i.value)}catch(c){setTimeout(function(){throw c})}}var _h=typeof WeakMap=="function"?WeakMap:Map;function If(r,i,c){c=Tt(-1,c),c.tag=3,c.payload={element:null};var f=i.value;return c.callback=function(){Gc||(Gc=!0,hd=f),$l(r,i)},c}function Ml(r,i,c){c=Tt(-1,c),c.tag=3;var f=r.type.getDerivedStateFromError;if(typeof f=="function"){var p=i.value;c.payload=function(){return f(p)},c.callback=function(){$l(r,i)}}var x=r.stateNode;return x!==null&&typeof x.componentDidCatch=="function"&&(c.callback=function(){$l(r,i),typeof f!="function"&&(ao===null?ao=new Set([this]):ao.add(this));var M=i.stack;this.componentDidCatch(i.value,{componentStack:M!==null?M:""})}),c}function Df(r,i,c){var f=r.pingCache;if(f===null){f=r.pingCache=new _h;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(c)||(p.add(c),r=Rt.bind(null,r,i,c),i.then(r,r))}function so(r){do{var i;if((i=r.tag===13)&&(i=r.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return r;r=r.return}while(r!==null);return null}function br(r,i,c,f,p){return(r.mode&1)===0?(r===i?r.flags|=65536:(r.flags|=128,c.flags|=131072,c.flags&=-52805,c.tag===1&&(c.alternate===null?c.tag=17:(i=Tt(-1,1),i.tag=2,Pn(c,i,1))),c.lanes|=1),r):(r.flags|=65536,r.lanes=p,r)}var mr=P.ReactCurrentOwner,On=!1;function In(r,i,c,f){i.child=r===null?wf(i,null,c,f):Sa(i,r.child,c,f)}function Oi(r,i,c,f,p){c=c.render;var x=i.ref;return no(i,p),f=kl(r,i,c,f,x,p),c=Do(),r!==null&&!On?(i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~p,Fs(r,i,p)):($n&&c&&dr(i),i.flags|=1,In(r,i,f,p),i.child)}function Ds(r,i,c,f,p){if(r===null){var x=c.type;return typeof x=="function"&&!yh(x)&&x.defaultProps===void 0&&c.compare===null&&c.defaultProps===void 0?(i.tag=15,i.type=x,Ff(r,i,x,f,p)):(r=Yf(c.type,null,f,i,i.mode,p),r.ref=i.ref,r.return=i,i.child=r)}if(x=r.child,(r.lanes&p)===0){var M=x.memoizedProps;if(c=c.compare,c=c!==null?c:cl,c(M,f)&&r.ref===i.ref)return Fs(r,i,p)}return i.flags|=1,r=Fa(x,f),r.ref=i.ref,r.return=i,i.child=r}function Ff(r,i,c,f,p){if(r!==null){var x=r.memoizedProps;if(cl(x,f)&&r.ref===i.ref)if(On=!1,i.pendingProps=f=x,(r.lanes&p)!==0)(r.flags&131072)!==0&&(On=!0);else return i.lanes=r.lanes,Fs(r,i,p)}return Tl(r,i,c,f,p)}function Al(r,i,c){var f=i.pendingProps,p=f.children,x=r!==null?r.memoizedState:null;if(f.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},wn(Oa,ts),ts|=c;else{if((c&1073741824)===0)return r=x!==null?x.baseLanes|c:c,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:r,cachePool:null,transitions:null},i.updateQueue=null,wn(Oa,ts),ts|=r,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},f=x!==null?x.baseLanes:c,wn(Oa,ts),ts|=f}else x!==null?(f=x.baseLanes|c,i.memoizedState=null):f=c,wn(Oa,ts),ts|=f;return In(r,i,p,c),i.child}function Bf(r,i){var c=i.ref;(r===null&&c!==null||r!==null&&r.ref!==c)&&(i.flags|=512,i.flags|=2097152)}function Tl(r,i,c,f,p){var x=Ur(c)?Qi:sr.current;return x=zs(i,x),no(i,p),c=kl(r,i,c,f,x,p),f=Do(),r!==null&&!On?(i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~p,Fs(r,i,p)):($n&&f&&dr(i),i.flags|=1,In(r,i,c,p),i.child)}function Uf(r,i,c,f,p){if(Ur(c)){var x=!0;kc(i)}else x=!1;if(no(i,p),i.stateNode===null)Hc(r,i),Of(i,c,f),Qu(i,c,f,p),f=!0;else if(r===null){var M=i.stateNode,X=i.memoizedProps;M.props=X;var re=M.context,_e=c.contextType;typeof _e=="object"&&_e!==null?_e=Le(_e):(_e=Ur(c)?Qi:sr.current,_e=zs(i,_e));var Me=c.getDerivedStateFromProps,Re=typeof Me=="function"||typeof M.getSnapshotBeforeUpdate=="function";Re||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(X!==f||re!==_e)&&zf(i,M,f,_e),ro=!1;var $e=i.memoizedState;M.state=$e,Li(i,f,M,p),re=i.memoizedState,X!==f||$e!==re||ur.current||ro?(typeof Me=="function"&&(Zu(i,c,Me,f),re=i.memoizedState),(X=ro||Pf(i,c,X,f,$e,re,_e))?(Re||typeof M.UNSAFE_componentWillMount!="function"&&typeof M.componentWillMount!="function"||(typeof M.componentWillMount=="function"&&M.componentWillMount(),typeof M.UNSAFE_componentWillMount=="function"&&M.UNSAFE_componentWillMount()),typeof M.componentDidMount=="function"&&(i.flags|=4194308)):(typeof M.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=f,i.memoizedState=re),M.props=f,M.state=re,M.context=_e,f=X):(typeof M.componentDidMount=="function"&&(i.flags|=4194308),f=!1)}else{M=i.stateNode,xr(r,i),X=i.memoizedProps,_e=i.type===i.elementType?X:Ss(i.type,X),M.props=_e,Re=i.pendingProps,$e=M.context,re=c.contextType,typeof re=="object"&&re!==null?re=Le(re):(re=Ur(c)?Qi:sr.current,re=zs(i,re));var Xe=c.getDerivedStateFromProps;(Me=typeof Xe=="function"||typeof M.getSnapshotBeforeUpdate=="function")||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(X!==Re||$e!==re)&&zf(i,M,f,re),ro=!1,$e=i.memoizedState,M.state=$e,Li(i,f,M,p);var Qe=i.memoizedState;X!==Re||$e!==Qe||ur.current||ro?(typeof Xe=="function"&&(Zu(i,c,Xe,f),Qe=i.memoizedState),(_e=ro||Pf(i,c,_e,f,$e,Qe,re)||!1)?(Me||typeof M.UNSAFE_componentWillUpdate!="function"&&typeof M.componentWillUpdate!="function"||(typeof M.componentWillUpdate=="function"&&M.componentWillUpdate(f,Qe,re),typeof M.UNSAFE_componentWillUpdate=="function"&&M.UNSAFE_componentWillUpdate(f,Qe,re)),typeof M.componentDidUpdate=="function"&&(i.flags|=4),typeof M.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof M.componentDidUpdate!="function"||X===r.memoizedProps&&$e===r.memoizedState||(i.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||X===r.memoizedProps&&$e===r.memoizedState||(i.flags|=1024),i.memoizedProps=f,i.memoizedState=Qe),M.props=f,M.state=Qe,M.context=re,f=_e):(typeof M.componentDidUpdate!="function"||X===r.memoizedProps&&$e===r.memoizedState||(i.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||X===r.memoizedProps&&$e===r.memoizedState||(i.flags|=1024),f=!1)}return ed(r,i,c,f,x,p)}function ed(r,i,c,f,p,x){Bf(r,i);var M=(i.flags&128)!==0;if(!f&&!M)return p&&pl(i,c,!1),Fs(r,i,x);f=i.stateNode,mr.current=i;var X=M&&typeof c.getDerivedStateFromError!="function"?null:f.render();return i.flags|=1,r!==null&&M?(i.child=Sa(i,r.child,null,x),i.child=Sa(i,null,X,x)):In(r,i,X,x),i.memoizedState=f.state,p&&pl(i,c,!0),i.child}function td(r){var i=r.stateNode;i.pendingContext?_f(r,i.pendingContext,i.pendingContext!==i.context):i.context&&_f(r,i.context,!1),Ac(r,i.containerInfo)}function io(r,i,c,f,p){return To(),Ec(p),i.flags|=256,In(r,i,c,f),i.child}var Bo={dehydrated:null,treeContext:null,retryLane:0};function Uc(r){return{baseLanes:r,cachePool:null,transitions:null}}function nd(r,i,c){var f=i.pendingProps,p=Sn.current,x=!1,M=(i.flags&128)!==0,X;if((X=M)||(X=r!==null&&r.memoizedState===null?!1:(p&2)!==0),X?(x=!0,i.flags&=-129):(r===null||r.memoizedState!==null)&&(p|=1),wn(Sn,p&1),r===null)return Ao(i),r=i.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((i.mode&1)===0?i.lanes=1:r.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(M=f.children,r=f.fallback,x?(f=i.mode,x=i.child,M={mode:"hidden",children:M},(f&1)===0&&x!==null?(x.childLanes=0,x.pendingProps=M):x=Xf(M,f,0,null),r=ql(r,f,c,null),x.return=i,r.return=i,x.sibling=r,i.child=x,i.child.memoizedState=Uc(c),i.memoizedState=Bo,r):rd(i,M));if(p=r.memoizedState,p!==null&&(X=p.dehydrated,X!==null))return Ra(r,i,M,f,X,p,c);if(x){x=f.fallback,M=i.mode,p=r.child,X=p.sibling;var re={mode:"hidden",children:f.children};return(M&1)===0&&i.child!==p?(f=i.child,f.childLanes=0,f.pendingProps=re,i.deletions=null):(f=Fa(p,re),f.subtreeFlags=p.subtreeFlags&14680064),X!==null?x=Fa(X,x):(x=ql(x,M,c,null),x.flags|=2),x.return=i,f.return=i,f.sibling=x,i.child=f,f=x,x=i.child,M=r.child.memoizedState,M=M===null?Uc(c):{baseLanes:M.baseLanes|c,cachePool:null,transitions:M.transitions},x.memoizedState=M,x.childLanes=r.childLanes&~c,i.memoizedState=Bo,f}return x=r.child,r=x.sibling,f=Fa(x,{mode:"visible",children:f.children}),(i.mode&1)===0&&(f.lanes=c),f.return=i,f.sibling=null,r!==null&&(c=i.deletions,c===null?(i.deletions=[r],i.flags|=16):c.push(r)),i.child=f,i.memoizedState=null,f}function rd(r,i){return i=Xf({mode:"visible",children:i},r.mode,0,null),i.return=r,r.child=i}function Rl(r,i,c,f){return f!==null&&Ec(f),Sa(i,r.child,null,c),r=rd(i,i.pendingProps.children),r.flags|=2,i.memoizedState=null,r}function Ra(r,i,c,f,p,x,M){if(c)return i.flags&256?(i.flags&=-257,f=Bc(Error(n(422))),Rl(r,i,M,f)):i.memoizedState!==null?(i.child=r.child,i.flags|=128,null):(x=f.fallback,p=i.mode,f=Xf({mode:"visible",children:f.children},p,0,null),x=ql(x,p,M,null),x.flags|=2,f.return=i,x.return=i,f.sibling=x,i.child=f,(i.mode&1)!==0&&Sa(i,r.child,null,M),i.child.memoizedState=Uc(M),i.memoizedState=Bo,x);if((i.mode&1)===0)return Rl(r,i,M,null);if(p.data==="$!"){if(f=p.nextSibling&&p.nextSibling.dataset,f)var X=f.dgst;return f=X,x=Error(n(419)),f=Bc(x,f,void 0),Rl(r,i,M,f)}if(X=(M&r.childLanes)!==0,On||X){if(f=Zn,f!==null){switch(M&-M){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|M))!==0?0:p,p!==0&&p!==x.retryLane&&(x.retryLane=p,ci(r,p),ks(f,r,p,-1))}return W(),f=Bc(Error(n(421))),Rl(r,i,M,f)}return p.data==="$?"?(i.flags|=128,i.child=r.child,i=Un.bind(null,r),p._reactRetry=i,null):(r=x.treeContext,Qr=gs(p.nextSibling),Ar=i,$n=!0,Wr=null,r!==null&&(Hr[vs++]=li,Hr[vs++]=Ri,Hr[vs++]=ai,li=r.id,Ri=r.overflow,ai=i),i=rd(i,f.children),i.flags|=4096,i)}function Hf(r,i,c){r.lanes|=i;var f=r.alternate;f!==null&&(f.lanes|=i),Bu(r.return,i,c)}function La(r,i,c,f,p){var x=r.memoizedState;x===null?r.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:f,tail:c,tailMode:p}:(x.isBackwards=i,x.rendering=null,x.renderingStartTime=0,x.last=f,x.tail=c,x.tailMode=p)}function sd(r,i,c){var f=i.pendingProps,p=f.revealOrder,x=f.tail;if(In(r,i,f.children,c),f=Sn.current,(f&2)!==0)f=f&1|2,i.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=i.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Hf(r,c,i);else if(r.tag===19)Hf(r,c,i);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}f&=1}if(wn(Sn,f),(i.mode&1)===0)i.memoizedState=null;else switch(p){case"forwards":for(c=i.child,p=null;c!==null;)r=c.alternate,r!==null&&Tc(r)===null&&(p=c),c=c.sibling;c=p,c===null?(p=i.child,i.child=null):(p=c.sibling,c.sibling=null),La(i,!1,p,c,x);break;case"backwards":for(c=null,p=i.child,i.child=null;p!==null;){if(r=p.alternate,r!==null&&Tc(r)===null){i.child=p;break}r=p.sibling,p.sibling=c,c=p,p=r}La(i,!0,c,null,x);break;case"together":La(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function Hc(r,i){(i.mode&1)===0&&r!==null&&(r.alternate=null,i.alternate=null,i.flags|=2)}function Fs(r,i,c){if(r!==null&&(i.dependencies=r.dependencies),zi|=i.lanes,(c&i.childLanes)===0)return null;if(r!==null&&i.child!==r.child)throw Error(n(153));if(i.child!==null){for(r=i.child,c=Fa(r,r.pendingProps),i.child=c,c.return=i;r.sibling!==null;)r=r.sibling,c=c.sibling=Fa(r,r.pendingProps),c.return=i;c.sibling=null}return i.child}function ph(r,i,c){switch(i.tag){case 3:td(i),To();break;case 5:xf(i);break;case 1:Ur(i.type)&&kc(i);break;case 4:Ac(i,i.stateNode.containerInfo);break;case 10:var f=i.type._context,p=i.memoizedProps.value;wn($c,f._currentValue),f._currentValue=p;break;case 13:if(f=i.memoizedState,f!==null)return f.dehydrated!==null?(wn(Sn,Sn.current&1),i.flags|=128,null):(c&i.child.childLanes)!==0?nd(r,i,c):(wn(Sn,Sn.current&1),r=Fs(r,i,c),r!==null?r.sibling:null);wn(Sn,Sn.current&1);break;case 19:if(f=(c&i.childLanes)!==0,(r.flags&128)!==0){if(f)return sd(r,i,c);i.flags|=128}if(p=i.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),wn(Sn,Sn.current),f)break;return null;case 22:case 23:return i.lanes=0,Al(r,i,c)}return Fs(r,i,c)}var Wf,id,Vr,Uo;Wf=function(r,i){for(var c=i.child;c!==null;){if(c.tag===5||c.tag===6)r.appendChild(c.stateNode);else if(c.tag!==4&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===i)break;for(;c.sibling===null;){if(c.return===null||c.return===i)return;c=c.return}c.sibling.return=c.return,c=c.sibling}},id=function(){},Vr=function(r,i,c,f){var p=r.memoizedProps;if(p!==f){r=i.stateNode,Po(ui.current);var x=null;switch(c){case"input":p=lt(r,p),f=lt(r,f),x=[];break;case"select":p=G({},p,{value:void 0}),f=G({},f,{value:void 0}),x=[];break;case"textarea":p=Ge(r,p),f=Ge(r,f),x=[];break;default:typeof p.onClick!="function"&&typeof f.onClick=="function"&&(r.onclick=_a)}Jt(c,f);var M;c=null;for(_e in p)if(!f.hasOwnProperty(_e)&&p.hasOwnProperty(_e)&&p[_e]!=null)if(_e==="style"){var X=p[_e];for(M in X)X.hasOwnProperty(M)&&(c||(c={}),c[M]="")}else _e!=="dangerouslySetInnerHTML"&&_e!=="children"&&_e!=="suppressContentEditableWarning"&&_e!=="suppressHydrationWarning"&&_e!=="autoFocus"&&(a.hasOwnProperty(_e)?x||(x=[]):(x=x||[]).push(_e,null));for(_e in f){var re=f[_e];if(X=p!=null?p[_e]:void 0,f.hasOwnProperty(_e)&&re!==X&&(re!=null||X!=null))if(_e==="style")if(X){for(M in X)!X.hasOwnProperty(M)||re&&re.hasOwnProperty(M)||(c||(c={}),c[M]="");for(M in re)re.hasOwnProperty(M)&&X[M]!==re[M]&&(c||(c={}),c[M]=re[M])}else c||(x||(x=[]),x.push(_e,c)),c=re;else _e==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,X=X?X.__html:void 0,re!=null&&X!==re&&(x=x||[]).push(_e,re)):_e==="children"?typeof re!="string"&&typeof re!="number"||(x=x||[]).push(_e,""+re):_e!=="suppressContentEditableWarning"&&_e!=="suppressHydrationWarning"&&(a.hasOwnProperty(_e)?(re!=null&&_e==="onScroll"&&un("scroll",r),x||X===re||(x=[])):(x=x||[]).push(_e,re))}c&&(x=x||[]).push("style",c);var _e=x;(i.updateQueue=_e)&&(i.flags|=4)}},Uo=function(r,i,c,f){c!==f&&(i.flags|=4)};function Ll(r,i){if(!$n)switch(r.tailMode){case"hidden":i=r.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?r.tail=null:c.sibling=null;break;case"collapsed":c=r.tail;for(var f=null;c!==null;)c.alternate!==null&&(f=c),c=c.sibling;f===null?i||r.tail===null?r.tail=null:r.tail.sibling=null:f.sibling=null}}function hr(r){var i=r.alternate!==null&&r.alternate.child===r.child,c=0,f=0;if(i)for(var p=r.child;p!==null;)c|=p.lanes|p.childLanes,f|=p.subtreeFlags&14680064,f|=p.flags&14680064,p.return=r,p=p.sibling;else for(p=r.child;p!==null;)c|=p.lanes|p.childLanes,f|=p.subtreeFlags,f|=p.flags,p.return=r,p=p.sibling;return r.subtreeFlags|=f,r.childLanes=c,i}function Bs(r,i,c){var f=i.pendingProps;switch(xa(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return hr(i),null;case 1:return Ur(i.type)&&Eo(),hr(i),null;case 3:return f=i.stateNode,Ea(),on(ur),on(sr),jl(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(r===null||r.child===null)&&(yl(i)?i.flags|=4:r===null||r.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Wr!==null&&(_(Wr),Wr=null))),id(r,i),hr(i),null;case 5:Vu(i);var p=Po(Sl.current);if(c=i.type,r!==null&&i.stateNode!=null)Vr(r,i,c,f,p),r.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!f){if(i.stateNode===null)throw Error(n(166));return hr(i),null}if(r=Po(ui.current),yl(i)){f=i.stateNode,c=i.type;var x=i.memoizedProps;switch(f[Os]=i,f[ga]=x,r=(i.mode&1)!==0,c){case"dialog":un("cancel",f),un("close",f);break;case"iframe":case"object":case"embed":un("load",f);break;case"video":case"audio":for(p=0;p<ko.length;p++)un(ko[p],f);break;case"source":un("error",f);break;case"img":case"image":case"link":un("error",f),un("load",f);break;case"details":un("toggle",f);break;case"input":yt(f,x),un("invalid",f);break;case"select":f._wrapperState={wasMultiple:!!x.multiple},un("invalid",f);break;case"textarea":Mt(f,x),un("invalid",f)}Jt(c,x),p=null;for(var M in x)if(x.hasOwnProperty(M)){var X=x[M];M==="children"?typeof X=="string"?f.textContent!==X&&(x.suppressHydrationWarning!==!0&&ri(f.textContent,X,r),p=["children",X]):typeof X=="number"&&f.textContent!==""+X&&(x.suppressHydrationWarning!==!0&&ri(f.textContent,X,r),p=["children",""+X]):a.hasOwnProperty(M)&&X!=null&&M==="onScroll"&&un("scroll",f)}switch(c){case"input":Ye(f),Oe(f,x,!0);break;case"textarea":Ye(f),dn(f);break;case"select":case"option":break;default:typeof x.onClick=="function"&&(f.onclick=_a)}f=p,i.updateQueue=f,f!==null&&(i.flags|=4)}else{M=p.nodeType===9?p:p.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=Ft(c)),r==="http://www.w3.org/1999/xhtml"?c==="script"?(r=M.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof f.is=="string"?r=M.createElement(c,{is:f.is}):(r=M.createElement(c),c==="select"&&(M=r,f.multiple?M.multiple=!0:f.size&&(M.size=f.size))):r=M.createElementNS(r,c),r[Os]=i,r[ga]=f,Wf(r,i,!1,!1),i.stateNode=r;e:{switch(M=cr(c,f),c){case"dialog":un("cancel",r),un("close",r),p=f;break;case"iframe":case"object":case"embed":un("load",r),p=f;break;case"video":case"audio":for(p=0;p<ko.length;p++)un(ko[p],r);p=f;break;case"source":un("error",r),p=f;break;case"img":case"image":case"link":un("error",r),un("load",r),p=f;break;case"details":un("toggle",r),p=f;break;case"input":yt(r,f),p=lt(r,f),un("invalid",r);break;case"option":p=f;break;case"select":r._wrapperState={wasMultiple:!!f.multiple},p=G({},f,{value:void 0}),un("invalid",r);break;case"textarea":Mt(r,f),p=Ge(r,f),un("invalid",r);break;default:p=f}Jt(c,p),X=p;for(x in X)if(X.hasOwnProperty(x)){var re=X[x];x==="style"?yn(r,re):x==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,re!=null&&Kn(r,re)):x==="children"?typeof re=="string"?(c!=="textarea"||re!=="")&&jt(r,re):typeof re=="number"&&jt(r,""+re):x!=="suppressContentEditableWarning"&&x!=="suppressHydrationWarning"&&x!=="autoFocus"&&(a.hasOwnProperty(x)?re!=null&&x==="onScroll"&&un("scroll",r):re!=null&&q(r,x,re,M))}switch(c){case"input":Ye(r),Oe(r,f,!1);break;case"textarea":Ye(r),dn(r);break;case"option":f.value!=null&&r.setAttribute("value",""+Ce(f.value));break;case"select":r.multiple=!!f.multiple,x=f.value,x!=null?Ie(r,!!f.multiple,x,!1):f.defaultValue!=null&&Ie(r,!!f.multiple,f.defaultValue,!0);break;default:typeof p.onClick=="function"&&(r.onclick=_a)}switch(c){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 hr(i),null;case 6:if(r&&i.stateNode!=null)Uo(r,i,r.memoizedProps,f);else{if(typeof f!="string"&&i.stateNode===null)throw Error(n(166));if(c=Po(Sl.current),Po(ui.current),yl(i)){if(f=i.stateNode,c=i.memoizedProps,f[Os]=i,(x=f.nodeValue!==c)&&(r=Ar,r!==null))switch(r.tag){case 3:ri(f.nodeValue,c,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&ri(f.nodeValue,c,(r.mode&1)!==0)}x&&(i.flags|=4)}else f=(c.nodeType===9?c:c.ownerDocument).createTextNode(f),f[Os]=i,i.stateNode=f}return hr(i),null;case 13:if(on(Sn),f=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if($n&&Qr!==null&&(i.mode&1)!==0&&(i.flags&128)===0)gf(),To(),i.flags|=98560,x=!1;else if(x=yl(i),f!==null&&f.dehydrated!==null){if(r===null){if(!x)throw Error(n(318));if(x=i.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(n(317));x[Os]=i}else To(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;hr(i),x=!1}else Wr!==null&&(_(Wr),Wr=null),x=!0;if(!x)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=c,i):(f=f!==null,f!==(r!==null&&r.memoizedState!==null)&&f&&(i.child.flags|=8192,(i.mode&1)!==0&&(r===null||(Sn.current&1)!==0?jn===0&&(jn=3):W())),i.updateQueue!==null&&(i.flags|=4),hr(i),null);case 4:return Ea(),id(r,i),r===null&&Ni(i.stateNode.containerInfo),hr(i),null;case 10:return Mc(i.type._context),hr(i),null;case 17:return Ur(i.type)&&Eo(),hr(i),null;case 19:if(on(Sn),x=i.memoizedState,x===null)return hr(i),null;if(f=(i.flags&128)!==0,M=x.rendering,M===null)if(f)Ll(x,!1);else{if(jn!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(M=Tc(r),M!==null){for(i.flags|=128,Ll(x,!1),f=M.updateQueue,f!==null&&(i.updateQueue=f,i.flags|=4),i.subtreeFlags=0,f=c,c=i.child;c!==null;)x=c,r=f,x.flags&=14680066,M=x.alternate,M===null?(x.childLanes=0,x.lanes=r,x.child=null,x.subtreeFlags=0,x.memoizedProps=null,x.memoizedState=null,x.updateQueue=null,x.dependencies=null,x.stateNode=null):(x.childLanes=M.childLanes,x.lanes=M.lanes,x.child=M.child,x.subtreeFlags=0,x.deletions=null,x.memoizedProps=M.memoizedProps,x.memoizedState=M.memoizedState,x.updateQueue=M.updateQueue,x.type=M.type,r=M.dependencies,x.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),c=c.sibling;return wn(Sn,Sn.current&1|2),i.child}r=r.sibling}x.tail!==null&&sn()>za&&(i.flags|=128,f=!0,Ll(x,!1),i.lanes=4194304)}else{if(!f)if(r=Tc(M),r!==null){if(i.flags|=128,f=!0,c=r.updateQueue,c!==null&&(i.updateQueue=c,i.flags|=4),Ll(x,!0),x.tail===null&&x.tailMode==="hidden"&&!M.alternate&&!$n)return hr(i),null}else 2*sn()-x.renderingStartTime>za&&c!==1073741824&&(i.flags|=128,f=!0,Ll(x,!1),i.lanes=4194304);x.isBackwards?(M.sibling=i.child,i.child=M):(c=x.last,c!==null?c.sibling=M:i.child=M,x.last=M)}return x.tail!==null?(i=x.tail,x.rendering=i,x.tail=i.sibling,x.renderingStartTime=sn(),i.sibling=null,c=Sn.current,wn(Sn,f?c&1|2:c&1),i):(hr(i),null);case 22:case 23:return V(),f=i.memoizedState!==null,r!==null&&r.memoizedState!==null!==f&&(i.flags|=8192),f&&(i.mode&1)!==0?(ts&1073741824)!==0&&(hr(i),i.subtreeFlags&6&&(i.flags|=8192)):hr(i),null;case 24:return null;case 25:return null}throw Error(n(156,i.tag))}function od(r,i){switch(xa(i),i.tag){case 1:return Ur(i.type)&&Eo(),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return Ea(),on(ur),on(sr),jl(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 5:return Vu(i),null;case 13:if(on(Sn),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(n(340));To()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return on(Sn),null;case 4:return Ea(),null;case 10:return Mc(i.type._context),null;case 22:case 23:return V(),null;case 24:return null;default:return null}}var Pl=!1,_r=!1,gh=typeof WeakSet=="function"?WeakSet:Set,Ze=null;function or(r,i){var c=r.ref;if(c!==null)if(typeof c=="function")try{c(null)}catch(f){Je(r,i,f)}else c.current=null}function Ho(r,i,c){try{c()}catch(f){Je(r,i,f)}}var ad=!1;function qf(r,i){if(pa=vr,r=Ru(),ua(r)){if("selectionStart"in r)var c={start:r.selectionStart,end:r.selectionEnd};else e:{c=(c=r.ownerDocument)&&c.defaultView||window;var f=c.getSelection&&c.getSelection();if(f&&f.rangeCount!==0){c=f.anchorNode;var p=f.anchorOffset,x=f.focusNode;f=f.focusOffset;try{c.nodeType,x.nodeType}catch{c=null;break e}var M=0,X=-1,re=-1,_e=0,Me=0,Re=r,$e=null;t:for(;;){for(var Xe;Re!==c||p!==0&&Re.nodeType!==3||(X=M+p),Re!==x||f!==0&&Re.nodeType!==3||(re=M+f),Re.nodeType===3&&(M+=Re.nodeValue.length),(Xe=Re.firstChild)!==null;)$e=Re,Re=Xe;for(;;){if(Re===r)break t;if($e===c&&++_e===p&&(X=M),$e===x&&++Me===f&&(re=M),(Xe=Re.nextSibling)!==null)break;Re=$e,$e=Re.parentNode}Re=Xe}c=X===-1||re===-1?null:{start:X,end:re}}else c=null}c=c||{start:0,end:0}}else c=null;for(_s={focusedElem:r,selectionRange:c},vr=!1,Ze=i;Ze!==null;)if(i=Ze,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,Ze=r;else for(;Ze!==null;){i=Ze;try{var Qe=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(Qe!==null){var et=Qe.memoizedProps,Qn=Qe.memoizedState,fe=i.stateNode,oe=fe.getSnapshotBeforeUpdate(i.elementType===i.type?et:Ss(i.type,et),Qn);fe.__reactInternalSnapshotBeforeUpdate=oe}break;case 3:var me=i.stateNode.containerInfo;me.nodeType===1?me.textContent="":me.nodeType===9&&me.documentElement&&me.removeChild(me.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(De){Je(i,i.return,De)}if(r=i.sibling,r!==null){r.return=i.return,Ze=r;break}Ze=i.return}return Qe=ad,ad=!1,Qe}function Ol(r,i,c){var f=i.updateQueue;if(f=f!==null?f.lastEffect:null,f!==null){var p=f=f.next;do{if((p.tag&r)===r){var x=p.destroy;p.destroy=void 0,x!==void 0&&Ho(i,c,x)}p=p.next}while(p!==f)}}function zl(r,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var c=i=i.next;do{if((c.tag&r)===r){var f=c.create;c.destroy=f()}c=c.next}while(c!==i)}}function Us(r){var i=r.ref;if(i!==null){var c=r.stateNode;switch(r.tag){case 5:r=c;break;default:r=c}typeof i=="function"?i(r):i.current=r}}function Vf(r){var i=r.alternate;i!==null&&(r.alternate=null,Vf(i)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(i=r.stateNode,i!==null&&(delete i[Os],delete i[ga],delete i[Iu],delete i[hf],delete i[mh])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Gf(r){return r.tag===5||r.tag===3||r.tag===4}function ld(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Gf(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Il(r,i,c){var f=r.tag;if(f===5||f===6)r=r.stateNode,i?c.nodeType===8?c.parentNode.insertBefore(r,i):c.insertBefore(r,i):(c.nodeType===8?(i=c.parentNode,i.insertBefore(r,c)):(i=c,i.appendChild(r)),c=c._reactRootContainer,c!=null||i.onclick!==null||(i.onclick=_a));else if(f!==4&&(r=r.child,r!==null))for(Il(r,i,c),r=r.sibling;r!==null;)Il(r,i,c),r=r.sibling}function js(r,i,c){var f=r.tag;if(f===5||f===6)r=r.stateNode,i?c.insertBefore(r,i):c.appendChild(r);else if(f!==4&&(r=r.child,r!==null))for(js(r,i,c),r=r.sibling;r!==null;)js(r,i,c),r=r.sibling}var Vn=null,Hs=!1;function Lr(r,i,c){for(c=c.child;c!==null;)Wc(r,i,c),c=c.sibling}function Wc(r,i,c){if(Er&&typeof Er.onCommitFiberUnmount=="function")try{Er.onCommitFiberUnmount(tn,c)}catch{}switch(c.tag){case 5:_r||or(c,i);case 6:var f=Vn,p=Hs;Vn=null,Lr(r,i,c),Vn=f,Hs=p,Vn!==null&&(Hs?(r=Vn,c=c.stateNode,r.nodeType===8?r.parentNode.removeChild(c):r.removeChild(c)):Vn.removeChild(c.stateNode));break;case 18:Vn!==null&&(Hs?(r=Vn,c=c.stateNode,r.nodeType===8?bc(r.parentNode,c):r.nodeType===1&&bc(r,c),mo(r)):bc(Vn,c.stateNode));break;case 4:f=Vn,p=Hs,Vn=c.stateNode.containerInfo,Hs=!0,Lr(r,i,c),Vn=f,Hs=p;break;case 0:case 11:case 14:case 15:if(!_r&&(f=c.updateQueue,f!==null&&(f=f.lastEffect,f!==null))){p=f=f.next;do{var x=p,M=x.destroy;x=x.tag,M!==void 0&&((x&2)!==0||(x&4)!==0)&&Ho(c,i,M),p=p.next}while(p!==f)}Lr(r,i,c);break;case 1:if(!_r&&(or(c,i),f=c.stateNode,typeof f.componentWillUnmount=="function"))try{f.props=c.memoizedProps,f.state=c.memoizedState,f.componentWillUnmount()}catch(X){Je(c,i,X)}Lr(r,i,c);break;case 21:Lr(r,i,c);break;case 22:c.mode&1?(_r=(f=_r)||c.memoizedState!==null,Lr(r,i,c),_r=f):Lr(r,i,c);break;default:Lr(r,i,c)}}function qc(r){var i=r.updateQueue;if(i!==null){r.updateQueue=null;var c=r.stateNode;c===null&&(c=r.stateNode=new gh),i.forEach(function(f){var p=Ws.bind(null,r,f);c.has(f)||(c.add(f),f.then(p,p))})}}function an(r,i){var c=i.deletions;if(c!==null)for(var f=0;f<c.length;f++){var p=c[f];try{var x=r,M=i,X=M;e:for(;X!==null;){switch(X.tag){case 5:Vn=X.stateNode,Hs=!1;break e;case 3:Vn=X.stateNode.containerInfo,Hs=!0;break e;case 4:Vn=X.stateNode.containerInfo,Hs=!0;break e}X=X.return}if(Vn===null)throw Error(n(160));Wc(x,M,p),Vn=null,Hs=!1;var re=p.alternate;re!==null&&(re.return=null),p.return=null}catch(_e){Je(p,i,_e)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)Wo(i,r),i=i.sibling}function Wo(r,i){var c=r.alternate,f=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(an(i,r),di(r),f&4){try{Ol(3,r,r.return),zl(3,r)}catch(et){Je(r,r.return,et)}try{Ol(5,r,r.return)}catch(et){Je(r,r.return,et)}}break;case 1:an(i,r),di(r),f&512&&c!==null&&or(c,c.return);break;case 5:if(an(i,r),di(r),f&512&&c!==null&&or(c,c.return),r.flags&32){var p=r.stateNode;try{jt(p,"")}catch(et){Je(r,r.return,et)}}if(f&4&&(p=r.stateNode,p!=null)){var x=r.memoizedProps,M=c!==null?c.memoizedProps:x,X=r.type,re=r.updateQueue;if(r.updateQueue=null,re!==null)try{X==="input"&&x.type==="radio"&&x.name!=null&&rt(p,x),cr(X,M);var _e=cr(X,x);for(M=0;M<re.length;M+=2){var Me=re[M],Re=re[M+1];Me==="style"?yn(p,Re):Me==="dangerouslySetInnerHTML"?Kn(p,Re):Me==="children"?jt(p,Re):q(p,Me,Re,_e)}switch(X){case"input":Ne(p,x);break;case"textarea":Bt(p,x);break;case"select":var $e=p._wrapperState.wasMultiple;p._wrapperState.wasMultiple=!!x.multiple;var Xe=x.value;Xe!=null?Ie(p,!!x.multiple,Xe,!1):$e!==!!x.multiple&&(x.defaultValue!=null?Ie(p,!!x.multiple,x.defaultValue,!0):Ie(p,!!x.multiple,x.multiple?[]:"",!1))}p[ga]=x}catch(et){Je(r,r.return,et)}}break;case 6:if(an(i,r),di(r),f&4){if(r.stateNode===null)throw Error(n(162));p=r.stateNode,x=r.memoizedProps;try{p.nodeValue=x}catch(et){Je(r,r.return,et)}}break;case 3:if(an(i,r),di(r),f&4&&c!==null&&c.memoizedState.isDehydrated)try{mo(i.containerInfo)}catch(et){Je(r,r.return,et)}break;case 4:an(i,r),di(r);break;case 13:an(i,r),di(r),p=r.child,p.flags&8192&&(x=p.memoizedState!==null,p.stateNode.isHidden=x,!x||p.alternate!==null&&p.alternate.memoizedState!==null||(Ii=sn())),f&4&&qc(r);break;case 22:if(Me=c!==null&&c.memoizedState!==null,r.mode&1?(_r=(_e=_r)||Me,an(i,r),_r=_e):an(i,r),di(r),f&8192){if(_e=r.memoizedState!==null,(r.stateNode.isHidden=_e)&&!Me&&(r.mode&1)!==0)for(Ze=r,Me=r.child;Me!==null;){for(Re=Ze=Me;Ze!==null;){switch($e=Ze,Xe=$e.child,$e.tag){case 0:case 11:case 14:case 15:Ol(4,$e,$e.return);break;case 1:or($e,$e.return);var Qe=$e.stateNode;if(typeof Qe.componentWillUnmount=="function"){f=$e,c=$e.return;try{i=f,Qe.props=i.memoizedProps,Qe.state=i.memoizedState,Qe.componentWillUnmount()}catch(et){Je(f,c,et)}}break;case 5:or($e,$e.return);break;case 22:if($e.memoizedState!==null){dd(Re);continue}}Xe!==null?(Xe.return=$e,Ze=Xe):dd(Re)}Me=Me.sibling}e:for(Me=null,Re=r;;){if(Re.tag===5){if(Me===null){Me=Re;try{p=Re.stateNode,_e?(x=p.style,typeof x.setProperty=="function"?x.setProperty("display","none","important"):x.display="none"):(X=Re.stateNode,re=Re.memoizedProps.style,M=re!=null&&re.hasOwnProperty("display")?re.display:null,X.style.display=Nn("display",M))}catch(et){Je(r,r.return,et)}}}else if(Re.tag===6){if(Me===null)try{Re.stateNode.nodeValue=_e?"":Re.memoizedProps}catch(et){Je(r,r.return,et)}}else if((Re.tag!==22&&Re.tag!==23||Re.memoizedState===null||Re===r)&&Re.child!==null){Re.child.return=Re,Re=Re.child;continue}if(Re===r)break e;for(;Re.sibling===null;){if(Re.return===null||Re.return===r)break e;Me===Re&&(Me=null),Re=Re.return}Me===Re&&(Me=null),Re.sibling.return=Re.return,Re=Re.sibling}}break;case 19:an(i,r),di(r),f&4&&qc(r);break;case 21:break;default:an(i,r),di(r)}}function di(r){var i=r.flags;if(i&2){try{e:{for(var c=r.return;c!==null;){if(Gf(c)){var f=c;break e}c=c.return}throw Error(n(160))}switch(f.tag){case 5:var p=f.stateNode;f.flags&32&&(jt(p,""),f.flags&=-33);var x=ld(r);js(r,x,p);break;case 3:case 4:var M=f.stateNode.containerInfo,X=ld(r);Il(r,X,M);break;default:throw Error(n(161))}}catch(re){Je(r,r.return,re)}r.flags&=-3}i&4096&&(r.flags&=-4097)}function Kf(r,i,c){Ze=r,cd(r)}function cd(r,i,c){for(var f=(r.mode&1)!==0;Ze!==null;){var p=Ze,x=p.child;if(p.tag===22&&f){var M=p.memoizedState!==null||Pl;if(!M){var X=p.alternate,re=X!==null&&X.memoizedState!==null||_r;X=Pl;var _e=_r;if(Pl=M,(_r=re)&&!_e)for(Ze=p;Ze!==null;)M=Ze,re=M.child,M.tag===22&&M.memoizedState!==null?fd(p):re!==null?(re.return=M,Ze=re):fd(p);for(;x!==null;)Ze=x,cd(x),x=x.sibling;Ze=p,Pl=X,_r=_e}ud(r)}else(p.subtreeFlags&8772)!==0&&x!==null?(x.return=p,Ze=x):ud(r)}}function ud(r){for(;Ze!==null;){var i=Ze;if((i.flags&8772)!==0){var c=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:_r||zl(5,i);break;case 1:var f=i.stateNode;if(i.flags&4&&!_r)if(c===null)f.componentDidMount();else{var p=i.elementType===i.type?c.memoizedProps:Ss(i.type,c.memoizedProps);f.componentDidUpdate(p,c.memoizedState,f.__reactInternalSnapshotBeforeUpdate)}var x=i.updateQueue;x!==null&&qu(i,x,f);break;case 3:var M=i.updateQueue;if(M!==null){if(c=null,i.child!==null)switch(i.child.tag){case 5:c=i.child.stateNode;break;case 1:c=i.child.stateNode}qu(i,M,c)}break;case 5:var X=i.stateNode;if(c===null&&i.flags&4){c=X;var re=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":re.autoFocus&&c.focus();break;case"img":re.src&&(c.src=re.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var _e=i.alternate;if(_e!==null){var Me=_e.memoizedState;if(Me!==null){var Re=Me.dehydrated;Re!==null&&mo(Re)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}_r||i.flags&512&&Us(i)}catch($e){Je(i,i.return,$e)}}if(i===r){Ze=null;break}if(c=i.sibling,c!==null){c.return=i.return,Ze=c;break}Ze=i.return}}function dd(r){for(;Ze!==null;){var i=Ze;if(i===r){Ze=null;break}var c=i.sibling;if(c!==null){c.return=i.return,Ze=c;break}Ze=i.return}}function fd(r){for(;Ze!==null;){var i=Ze;try{switch(i.tag){case 0:case 11:case 15:var c=i.return;try{zl(4,i)}catch(re){Je(i,c,re)}break;case 1:var f=i.stateNode;if(typeof f.componentDidMount=="function"){var p=i.return;try{f.componentDidMount()}catch(re){Je(i,p,re)}}var x=i.return;try{Us(i)}catch(re){Je(i,x,re)}break;case 5:var M=i.return;try{Us(i)}catch(re){Je(i,M,re)}}}catch(re){Je(i,i.return,re)}if(i===r){Ze=null;break}var X=i.sibling;if(X!==null){X.return=i.return,Ze=X;break}Ze=i.return}}var md=Math.ceil,oo=P.ReactCurrentDispatcher,Pa=P.ReactCurrentOwner,es=P.ReactCurrentBatchConfig,Gt=0,Zn=null,gn=null,pr=0,ts=0,Oa=$i(0),jn=0,qo=null,zi=0,Dl=0,Vc=0,Fl=null,ar=null,Ii=0,za=1/0,ns=null,Gc=!1,hd=null,ao=null,Bl=!1,Di=null,Ul=0,Ia=0,Kc=null,Hl=-1,Wl=0;function Sr(){return(Gt&6)!==0?sn():Hl!==-1?Hl:Hl=sn()}function Fi(r){return(r.mode&1)===0?1:(Gt&2)!==0&&pr!==0?pr&-pr:yf.transition!==null?(Wl===0&&(Wl=Xn()),Wl):(r=Kt,r!==0||(r=window.event,r=r===void 0?16:xe(r.type)),r)}function ks(r,i,c,f){if(50<Ia)throw Ia=0,Kc=null,Error(n(185));Dn(r,c,f),((Gt&2)===0||r!==Zn)&&(r===Zn&&((Gt&2)===0&&(Dl|=c),jn===4&&N(r,pr)),Pr(r,f),c===1&&Gt===0&&(i.mode&1)===0&&(za=sn()+500,Is&&Ai()))}function Pr(r,i){var c=r.callbackNode;zn(r,i);var f=Xs(r,r===Zn?pr:0);if(f===0)c!==null&&gi(c),r.callbackNode=null,r.callbackPriority=0;else if(i=f&-f,r.callbackPriority!==i){if(c!=null&&gi(c),i===1)r.tag===0?gl(A.bind(null,r)):va(A.bind(null,r)),fh(function(){(Gt&6)===0&&Ai()}),c=null;else{switch(uo(f)){case 1:c=Yr;break;case 4:c=Ms;break;case 16:c=As;break;case 536870912:c=st;break;default:c=As}c=Sp(c,_d.bind(null,r))}r.callbackPriority=i,r.callbackNode=c}}function _d(r,i){if(Hl=-1,Wl=0,(Gt&6)!==0)throw Error(n(327));var c=r.callbackNode;if(Be()&&r.callbackNode!==c)return null;var f=Xs(r,r===Zn?pr:0);if(f===0)return null;if((f&30)!==0||(f&r.expiredLanes)!==0||i)i=we(r,f);else{i=f;var p=Gt;Gt|=2;var x=ie();(Zn!==r||pr!==i)&&(ns=null,za=sn()+500,J(r,i));do try{Pe();break}catch(X){Se(r,X)}while(!0);Fu(),oo.current=x,Gt=p,gn!==null?i=0:(Zn=null,pr=0,i=jn)}if(i!==0){if(i===2&&(p=ls(r),p!==0&&(f=p,i=Yc(r,p))),i===1)throw c=qo,J(r,0),N(r,f),Pr(r,sn()),c;if(i===6)N(r,f);else{if(p=r.current.alternate,(f&30)===0&&!k(p)&&(i=we(r,f),i===2&&(x=ls(r),x!==0&&(f=x,i=Yc(r,x))),i===1))throw c=qo,J(r,0),N(r,f),Pr(r,sn()),c;switch(r.finishedWork=p,r.finishedLanes=f,i){case 0:case 1:throw Error(n(345));case 2:St(r,ar,ns);break;case 3:if(N(r,f),(f&130023424)===f&&(i=Ii+500-sn(),10<i)){if(Xs(r,0)!==0)break;if(p=r.suspendedLanes,(p&f)!==f){Sr(),r.pingedLanes|=r.suspendedLanes&p;break}r.timeoutHandle=ps(St.bind(null,r,ar,ns),i);break}St(r,ar,ns);break;case 4:if(N(r,f),(f&4194240)===f)break;for(i=r.eventTimes,p=-1;0<f;){var M=31-yr(f);x=1<<M,M=i[M],M>p&&(p=M),f&=~x}if(f=p,f=sn()-f,f=(120>f?120:480>f?480:1080>f?1080:1920>f?1920:3e3>f?3e3:4320>f?4320:1960*md(f/1960))-f,10<f){r.timeoutHandle=ps(St.bind(null,r,ar,ns),f);break}St(r,ar,ns);break;case 5:St(r,ar,ns);break;default:throw Error(n(329))}}}return Pr(r,sn()),r.callbackNode===c?_d.bind(null,r):null}function Yc(r,i){var c=Fl;return r.current.memoizedState.isDehydrated&&(J(r,i).flags|=256),r=we(r,i),r!==2&&(i=ar,ar=c,i!==null&&_(i)),r}function _(r){ar===null?ar=r:ar.push.apply(ar,r)}function k(r){for(var i=r;;){if(i.flags&16384){var c=i.updateQueue;if(c!==null&&(c=c.stores,c!==null))for(var f=0;f<c.length;f++){var p=c[f],x=p.getSnapshot;p=p.value;try{if(!Xr(x(),p))return!1}catch{return!1}}}if(c=i.child,i.subtreeFlags&16384&&c!==null)c.return=i,i=c;else{if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function N(r,i){for(i&=~Vc,i&=~Dl,r.suspendedLanes|=i,r.pingedLanes&=~i,r=r.expirationTimes;0<i;){var c=31-yr(i),f=1<<c;r[c]=-1,i&=~f}}function A(r){if((Gt&6)!==0)throw Error(n(327));Be();var i=Xs(r,0);if((i&1)===0)return Pr(r,sn()),null;var c=we(r,i);if(r.tag!==0&&c===2){var f=ls(r);f!==0&&(i=f,c=Yc(r,f))}if(c===1)throw c=qo,J(r,0),N(r,i),Pr(r,sn()),c;if(c===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=i,St(r,ar,ns),Pr(r,sn()),null}function U(r,i){var c=Gt;Gt|=1;try{return r(i)}finally{Gt=c,Gt===0&&(za=sn()+500,Is&&Ai())}}function H(r){Di!==null&&Di.tag===0&&(Gt&6)===0&&Be();var i=Gt;Gt|=1;var c=es.transition,f=Kt;try{if(es.transition=null,Kt=1,r)return r()}finally{Kt=f,es.transition=c,Gt=i,(Gt&6)===0&&Ai()}}function V(){ts=Oa.current,on(Oa)}function J(r,i){r.finishedWork=null,r.finishedLanes=0;var c=r.timeoutHandle;if(c!==-1&&(r.timeoutHandle=-1,mf(c)),gn!==null)for(c=gn.return;c!==null;){var f=c;switch(xa(f),f.tag){case 1:f=f.type.childContextTypes,f!=null&&Eo();break;case 3:Ea(),on(ur),on(sr),jl();break;case 5:Vu(f);break;case 4:Ea();break;case 13:on(Sn);break;case 19:on(Sn);break;case 10:Mc(f.type._context);break;case 22:case 23:V()}c=c.return}if(Zn=r,gn=r=Fa(r.current,null),pr=ts=i,jn=0,qo=null,Vc=Dl=zi=0,ar=Fl=null,Ro!==null){for(i=0;i<Ro.length;i++)if(c=Ro[i],f=c.interleaved,f!==null){c.interleaved=null;var p=f.next,x=c.pending;if(x!==null){var M=x.next;x.next=p,f.next=M}c.pending=f}Ro=null}return r}function Se(r,i){do{var c=gn;try{if(Fu(),Rc.current=Pi,xn){for(var f=Mn.memoizedState;f!==null;){var p=f.queue;p!==null&&(p.pending=null),f=f.next}xn=!1}if(Oo=0,ir=Fn=Mn=null,$a=!1,zo=0,Pa.current=null,c===null||c.return===null){jn=1,qo=i,gn=null;break}e:{var x=r,M=c.return,X=c,re=i;if(i=pr,X.flags|=32768,re!==null&&typeof re=="object"&&typeof re.then=="function"){var _e=re,Me=X,Re=Me.tag;if((Me.mode&1)===0&&(Re===0||Re===11||Re===15)){var $e=Me.alternate;$e?(Me.updateQueue=$e.updateQueue,Me.memoizedState=$e.memoizedState,Me.lanes=$e.lanes):(Me.updateQueue=null,Me.memoizedState=null)}var Xe=so(M);if(Xe!==null){Xe.flags&=-257,br(Xe,M,X,x,i),Xe.mode&1&&Df(x,_e,i),i=Xe,re=_e;var Qe=i.updateQueue;if(Qe===null){var et=new Set;et.add(re),i.updateQueue=et}else Qe.add(re);break e}else{if((i&1)===0){Df(x,_e,i),W();break e}re=Error(n(426))}}else if($n&&X.mode&1){var Qn=so(M);if(Qn!==null){(Qn.flags&65536)===0&&(Qn.flags|=256),br(Qn,M,X,x,i),Ec(Ta(re,X));break e}}x=re=Ta(re,X),jn!==4&&(jn=2),Fl===null?Fl=[x]:Fl.push(x),x=M;do{switch(x.tag){case 3:x.flags|=65536,i&=-i,x.lanes|=i;var fe=If(x,re,i);Wu(x,fe);break e;case 1:X=re;var oe=x.type,me=x.stateNode;if((x.flags&128)===0&&(typeof oe.getDerivedStateFromError=="function"||me!==null&&typeof me.componentDidCatch=="function"&&(ao===null||!ao.has(me)))){x.flags|=65536,i&=-i,x.lanes|=i;var De=Ml(x,X,i);Wu(x,De);break e}}x=x.return}while(x!==null)}Ue(c)}catch(tt){i=tt,gn===c&&c!==null&&(gn=c=c.return);continue}break}while(!0)}function ie(){var r=oo.current;return oo.current=Pi,r===null?Pi:r}function W(){(jn===0||jn===3||jn===2)&&(jn=4),Zn===null||(zi&268435455)===0&&(Dl&268435455)===0||N(Zn,pr)}function we(r,i){var c=Gt;Gt|=2;var f=ie();(Zn!==r||pr!==i)&&(ns=null,J(r,i));do try{Ae();break}catch(p){Se(r,p)}while(!0);if(Fu(),Gt=c,oo.current=f,gn!==null)throw Error(n(261));return Zn=null,pr=0,jn}function Ae(){for(;gn!==null;)ze(gn)}function Pe(){for(;gn!==null&&!Ks();)ze(gn)}function ze(r){var i=Da(r.alternate,r,ts);r.memoizedProps=r.pendingProps,i===null?Ue(r):gn=i,Pa.current=null}function Ue(r){var i=r;do{var c=i.alternate;if(r=i.return,(i.flags&32768)===0){if(c=Bs(c,i,ts),c!==null){gn=c;return}}else{if(c=od(c,i),c!==null){c.flags&=32767,gn=c;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{jn=6,gn=null;return}}if(i=i.sibling,i!==null){gn=i;return}gn=i=r}while(i!==null);jn===0&&(jn=5)}function St(r,i,c){var f=Kt,p=es.transition;try{es.transition=null,Kt=1,xt(r,i,c,f)}finally{es.transition=p,Kt=f}return null}function xt(r,i,c,f){do Be();while(Di!==null);if((Gt&6)!==0)throw Error(n(327));c=r.finishedWork;var p=r.finishedLanes;if(c===null)return null;if(r.finishedWork=null,r.finishedLanes=0,c===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var x=c.lanes|c.childLanes;if(us(r,x),r===Zn&&(gn=Zn=null,pr=0),(c.subtreeFlags&2064)===0&&(c.flags&2064)===0||Bl||(Bl=!0,Sp(As,function(){return Be(),null})),x=(c.flags&15990)!==0,(c.subtreeFlags&15990)!==0||x){x=es.transition,es.transition=null;var M=Kt;Kt=1;var X=Gt;Gt|=4,Pa.current=null,qf(r,c),Wo(c,r),uh(_s),vr=!!pa,_s=pa=null,r.current=c,Kf(c),Ir(),Gt=X,Kt=M,es.transition=x}else r.current=c;if(Bl&&(Bl=!1,Di=r,Ul=p),x=r.pendingLanes,x===0&&(ao=null),yi(c.stateNode),Pr(r,sn()),i!==null)for(f=r.onRecoverableError,c=0;c<i.length;c++)p=i[c],f(p.value,{componentStack:p.stack,digest:p.digest});if(Gc)throw Gc=!1,r=hd,hd=null,r;return(Ul&1)!==0&&r.tag!==0&&Be(),x=r.pendingLanes,(x&1)!==0?r===Kc?Ia++:(Ia=0,Kc=r):Ia=0,Ai(),null}function Be(){if(Di!==null){var r=uo(Ul),i=es.transition,c=Kt;try{if(es.transition=null,Kt=16>r?16:r,Di===null)var f=!1;else{if(r=Di,Di=null,Ul=0,(Gt&6)!==0)throw Error(n(331));var p=Gt;for(Gt|=4,Ze=r.current;Ze!==null;){var x=Ze,M=x.child;if((Ze.flags&16)!==0){var X=x.deletions;if(X!==null){for(var re=0;re<X.length;re++){var _e=X[re];for(Ze=_e;Ze!==null;){var Me=Ze;switch(Me.tag){case 0:case 11:case 15:Ol(8,Me,x)}var Re=Me.child;if(Re!==null)Re.return=Me,Ze=Re;else for(;Ze!==null;){Me=Ze;var $e=Me.sibling,Xe=Me.return;if(Vf(Me),Me===_e){Ze=null;break}if($e!==null){$e.return=Xe,Ze=$e;break}Ze=Xe}}}var Qe=x.alternate;if(Qe!==null){var et=Qe.child;if(et!==null){Qe.child=null;do{var Qn=et.sibling;et.sibling=null,et=Qn}while(et!==null)}}Ze=x}}if((x.subtreeFlags&2064)!==0&&M!==null)M.return=x,Ze=M;else e:for(;Ze!==null;){if(x=Ze,(x.flags&2048)!==0)switch(x.tag){case 0:case 11:case 15:Ol(9,x,x.return)}var fe=x.sibling;if(fe!==null){fe.return=x.return,Ze=fe;break e}Ze=x.return}}var oe=r.current;for(Ze=oe;Ze!==null;){M=Ze;var me=M.child;if((M.subtreeFlags&2064)!==0&&me!==null)me.return=M,Ze=me;else e:for(M=oe;Ze!==null;){if(X=Ze,(X.flags&2048)!==0)try{switch(X.tag){case 0:case 11:case 15:zl(9,X)}}catch(tt){Je(X,X.return,tt)}if(X===M){Ze=null;break e}var De=X.sibling;if(De!==null){De.return=X.return,Ze=De;break e}Ze=X.return}}if(Gt=p,Ai(),Er&&typeof Er.onPostCommitFiberRoot=="function")try{Er.onPostCommitFiberRoot(tn,r)}catch{}f=!0}return f}finally{Kt=c,es.transition=i}}return!1}function at(r,i,c){i=Ta(c,i),i=If(r,i,1),r=Pn(r,i,1),i=Sr(),r!==null&&(Dn(r,1,i),Pr(r,i))}function Je(r,i,c){if(r.tag===3)at(r,r,c);else for(;i!==null;){if(i.tag===3){at(i,r,c);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(ao===null||!ao.has(f))){r=Ta(c,r),r=Ml(i,r,1),i=Pn(i,r,1),r=Sr(),i!==null&&(Dn(i,1,r),Pr(i,r));break}}i=i.return}}function Rt(r,i,c){var f=r.pingCache;f!==null&&f.delete(i),i=Sr(),r.pingedLanes|=r.suspendedLanes&c,Zn===r&&(pr&c)===c&&(jn===4||jn===3&&(pr&130023424)===pr&&500>sn()-Ii?J(r,0):Vc|=c),Pr(r,i)}function kn(r,i){i===0&&((r.mode&1)===0?i=1:(i=as,as<<=1,(as&130023424)===0&&(as=4194304)));var c=Sr();r=ci(r,i),r!==null&&(Dn(r,i,c),Pr(r,c))}function Un(r){var i=r.memoizedState,c=0;i!==null&&(c=i.retryLane),kn(r,c)}function Ws(r,i){var c=0;switch(r.tag){case 13:var f=r.stateNode,p=r.memoizedState;p!==null&&(c=p.retryLane);break;case 19:f=r.stateNode;break;default:throw Error(n(314))}f!==null&&f.delete(i),kn(r,c)}var Da;Da=function(r,i,c){if(r!==null)if(r.memoizedProps!==i.pendingProps||ur.current)On=!0;else{if((r.lanes&c)===0&&(i.flags&128)===0)return On=!1,ph(r,i,c);On=(r.flags&131072)!==0}else On=!1,$n&&(i.flags&1048576)!==0&&to(i,Ti,i.index);switch(i.lanes=0,i.tag){case 2:var f=i.type;Hc(r,i),r=i.pendingProps;var p=zs(i,sr.current);no(i,c),p=kl(null,i,f,r,p,c);var x=Do();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,Ur(f)?(x=!0,kc(i)):x=!1,i.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,Na(i),p.updater=Fc,i.stateNode=p,p._reactInternals=i,Qu(i,f,r,c),i=ed(null,i,f,!0,x,c)):(i.tag=0,$n&&x&&dr(i),In(null,i,p,c),i=i.child),i;case 16:f=i.elementType;e:{switch(Hc(r,i),r=i.pendingProps,p=f._init,f=p(f._payload),i.type=f,p=i.tag=Kw(f),r=Ss(f,r),p){case 0:i=Tl(null,i,f,r,c);break e;case 1:i=Uf(null,i,f,r,c);break e;case 11:i=Oi(null,i,f,r,c);break e;case 14:i=Ds(null,i,f,Ss(f.type,r),c);break e}throw Error(n(306,f,""))}return i;case 0:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Ss(f,p),Tl(r,i,f,p,c);case 1:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Ss(f,p),Uf(r,i,f,p,c);case 3:e:{if(td(i),r===null)throw Error(n(387));f=i.pendingProps,x=i.memoizedState,p=x.element,xr(r,i),Li(i,f,null,c);var M=i.memoizedState;if(f=M.element,x.isDehydrated)if(x={element:f,isDehydrated:!1,cache:M.cache,pendingSuspenseBoundaries:M.pendingSuspenseBoundaries,transitions:M.transitions},i.updateQueue.baseState=x,i.memoizedState=x,i.flags&256){p=Ta(Error(n(423)),i),i=io(r,i,f,c,p);break e}else if(f!==p){p=Ta(Error(n(424)),i),i=io(r,i,f,c,p);break e}else for(Qr=gs(i.stateNode.containerInfo.firstChild),Ar=i,$n=!0,Wr=null,c=wf(i,null,f,c),i.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{if(To(),f===p){i=Fs(r,i,c);break e}In(r,i,f,c)}i=i.child}return i;case 5:return xf(i),r===null&&Ao(i),f=i.type,p=i.pendingProps,x=r!==null?r.memoizedProps:null,M=p.children,si(f,p)?M=null:x!==null&&si(f,x)&&(i.flags|=32),Bf(r,i),In(r,i,M,c),i.child;case 6:return r===null&&Ao(i),null;case 13:return nd(r,i,c);case 4:return Ac(i,i.stateNode.containerInfo),f=i.pendingProps,r===null?i.child=Sa(i,null,f,c):In(r,i,f,c),i.child;case 11:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Ss(f,p),Oi(r,i,f,p,c);case 7:return In(r,i,i.pendingProps,c),i.child;case 8:return In(r,i,i.pendingProps.children,c),i.child;case 12:return In(r,i,i.pendingProps.children,c),i.child;case 10:e:{if(f=i.type._context,p=i.pendingProps,x=i.memoizedProps,M=p.value,wn($c,f._currentValue),f._currentValue=M,x!==null)if(Xr(x.value,M)){if(x.children===p.children&&!ur.current){i=Fs(r,i,c);break e}}else for(x=i.child,x!==null&&(x.return=i);x!==null;){var X=x.dependencies;if(X!==null){M=x.child;for(var re=X.firstContext;re!==null;){if(re.context===f){if(x.tag===1){re=Tt(-1,c&-c),re.tag=2;var _e=x.updateQueue;if(_e!==null){_e=_e.shared;var Me=_e.pending;Me===null?re.next=re:(re.next=Me.next,Me.next=re),_e.pending=re}}x.lanes|=c,re=x.alternate,re!==null&&(re.lanes|=c),Bu(x.return,c,i),X.lanes|=c;break}re=re.next}}else if(x.tag===10)M=x.type===i.type?null:x.child;else if(x.tag===18){if(M=x.return,M===null)throw Error(n(341));M.lanes|=c,X=M.alternate,X!==null&&(X.lanes|=c),Bu(M,c,i),M=x.sibling}else M=x.child;if(M!==null)M.return=x;else for(M=x;M!==null;){if(M===i){M=null;break}if(x=M.sibling,x!==null){x.return=M.return,M=x;break}M=M.return}x=M}In(r,i,p.children,c),i=i.child}return i;case 9:return p=i.type,f=i.pendingProps.children,no(i,c),p=Le(p),f=f(p),i.flags|=1,In(r,i,f,c),i.child;case 14:return f=i.type,p=Ss(f,i.pendingProps),p=Ss(f.type,p),Ds(r,i,f,p,c);case 15:return Ff(r,i,i.type,i.pendingProps,c);case 17:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Ss(f,p),Hc(r,i),i.tag=1,Ur(f)?(r=!0,kc(i)):r=!1,no(i,c),Of(i,f,p),Qu(i,f,p,c),ed(null,i,f,!0,r,c);case 19:return sd(r,i,c);case 22:return Al(r,i,c)}throw Error(n(156,i.tag))};function Sp(r,i){return $s(r,i)}function Gw(r,i,c,f){this.tag=r,this.key=c,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 fi(r,i,c,f){return new Gw(r,i,c,f)}function yh(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Kw(r){if(typeof r=="function")return yh(r)?1:0;if(r!=null){if(r=r.$$typeof,r===F)return 11;if(r===L)return 14}return 2}function Fa(r,i){var c=r.alternate;return c===null?(c=fi(r.tag,i,r.key,r.mode),c.elementType=r.elementType,c.type=r.type,c.stateNode=r.stateNode,c.alternate=r,r.alternate=c):(c.pendingProps=i,c.type=r.type,c.flags=0,c.subtreeFlags=0,c.deletions=null),c.flags=r.flags&14680064,c.childLanes=r.childLanes,c.lanes=r.lanes,c.child=r.child,c.memoizedProps=r.memoizedProps,c.memoizedState=r.memoizedState,c.updateQueue=r.updateQueue,i=r.dependencies,c.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},c.sibling=r.sibling,c.index=r.index,c.ref=r.ref,c}function Yf(r,i,c,f,p,x){var M=2;if(f=r,typeof r=="function")yh(r)&&(M=1);else if(typeof r=="string")M=5;else e:switch(r){case Z:return ql(c.children,p,x,i);case ee:M=8,p|=8;break;case ue:return r=fi(12,c,i,p|2),r.elementType=ue,r.lanes=x,r;case E:return r=fi(13,c,i,p),r.elementType=E,r.lanes=x,r;case j:return r=fi(19,c,i,p),r.elementType=j,r.lanes=x,r;case te:return Xf(c,p,x,i);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case de:M=10;break e;case pe:M=9;break e;case F:M=11;break e;case L:M=14;break e;case z:M=16,f=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return i=fi(M,c,i,p),i.elementType=r,i.type=f,i.lanes=x,i}function ql(r,i,c,f){return r=fi(7,r,f,i),r.lanes=c,r}function Xf(r,i,c,f){return r=fi(22,r,f,i),r.elementType=te,r.lanes=c,r.stateNode={isHidden:!1},r}function vh(r,i,c){return r=fi(6,r,null,i),r.lanes=c,r}function wh(r,i,c){return i=fi(4,r.children!==null?r.children:[],r.key,i),i.lanes=c,i.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},i}function Yw(r,i,c,f,p){this.tag=i,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=cs(0),this.expirationTimes=cs(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=cs(0),this.identifierPrefix=f,this.onRecoverableError=p,this.mutableSourceEagerHydrationData=null}function xh(r,i,c,f,p,x,M,X,re){return r=new Yw(r,i,c,X,re),i===1?(i=1,x===!0&&(i|=8)):i=0,x=fi(3,null,null,i),r.current=x,x.stateNode=r,x.memoizedState={element:f,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null},Na(x),r}function Xw(r,i,c){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Q,key:f==null?null:""+f,children:r,containerInfo:i,implementation:c}}function jp(r){if(!r)return ys;r=r._reactInternals;e:{if(pn(r)!==r||r.tag!==1)throw Error(n(170));var i=r;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(Ur(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(n(171))}if(r.tag===1){var c=r.type;if(Ur(c))return $o(r,c,i)}return i}function kp(r,i,c,f,p,x,M,X,re){return r=xh(c,f,!0,r,p,x,M,X,re),r.context=jp(null),c=r.current,f=Sr(),p=Fi(c),x=Tt(f,p),x.callback=i??null,Pn(c,x,p),r.current.lanes=p,Dn(r,p,f),Pr(r,f),r}function Jf(r,i,c,f){var p=i.current,x=Sr(),M=Fi(p);return c=jp(c),i.context===null?i.context=c:i.pendingContext=c,i=Tt(x,M),i.payload={element:r},f=f===void 0?null:f,f!==null&&(i.callback=f),r=Pn(p,i,M),r!==null&&(ks(r,p,M,x),Ca(r,p,M)),M}function Zf(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function Np(r,i){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var c=r.retryLane;r.retryLane=c!==0&&c<i?c:i}}function bh(r,i){Np(r,i),(r=r.alternate)&&Np(r,i)}function Jw(){return null}var Cp=typeof reportError=="function"?reportError:function(r){console.error(r)};function Sh(r){this._internalRoot=r}Qf.prototype.render=Sh.prototype.render=function(r){var i=this._internalRoot;if(i===null)throw Error(n(409));Jf(r,i,null,null)},Qf.prototype.unmount=Sh.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var i=r.containerInfo;H(function(){Jf(null,r,null,null)}),i[ii]=null}};function Qf(r){this._internalRoot=r}Qf.prototype.unstable_scheduleHydration=function(r){if(r){var i=nl();r={blockedOn:null,target:r,priority:i};for(var c=0;c<Fr.length&&i!==0&&i<Fr[c].priority;c++);Fr.splice(c,0,r),c===0&&Qs(r)}};function jh(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function em(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function Ep(){}function Zw(r,i,c,f,p){if(p){if(typeof f=="function"){var x=f;f=function(){var _e=Zf(M);x.call(_e)}}var M=kp(i,f,r,0,null,!1,!1,"",Ep);return r._reactRootContainer=M,r[ii]=M.current,Ni(r.nodeType===8?r.parentNode:r),H(),M}for(;p=r.lastChild;)r.removeChild(p);if(typeof f=="function"){var X=f;f=function(){var _e=Zf(re);X.call(_e)}}var re=xh(r,0,!1,null,null,!1,!1,"",Ep);return r._reactRootContainer=re,r[ii]=re.current,Ni(r.nodeType===8?r.parentNode:r),H(function(){Jf(i,re,c,f)}),re}function tm(r,i,c,f,p){var x=c._reactRootContainer;if(x){var M=x;if(typeof p=="function"){var X=p;p=function(){var re=Zf(M);X.call(re)}}Jf(i,M,r,p)}else M=Zw(c,i,r,p,f);return Zf(M)}ra=function(r){switch(r.tag){case 3:var i=r.stateNode;if(i.current.memoizedState.isDehydrated){var c=Yn(i.pendingLanes);c!==0&&(Js(i,c|1),Pr(i,sn()),(Gt&6)===0&&(za=sn()+500,Ai()))}break;case 13:H(function(){var f=ci(r,1);if(f!==null){var p=Sr();ks(f,r,1,p)}}),bh(r,1)}},sa=function(r){if(r.tag===13){var i=ci(r,134217728);if(i!==null){var c=Sr();ks(i,r,134217728,c)}bh(r,134217728)}},Dr=function(r){if(r.tag===13){var i=Fi(r),c=ci(r,i);if(c!==null){var f=Sr();ks(c,r,i,f)}bh(r,i)}},nl=function(){return Kt},Zs=function(r,i){var c=Kt;try{return Kt=r,i()}finally{Kt=c}},vn=function(r,i,c){switch(i){case"input":if(Ne(r,c),i=c.name,c.type==="radio"&&i!=null){for(c=r;c.parentNode;)c=c.parentNode;for(c=c.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<c.length;i++){var f=c[i];if(f!==r&&f.form===r.form){var p=Sc(f);if(!p)throw Error(n(90));Ct(f),Ne(f,p)}}}break;case"textarea":Bt(r,c);break;case"select":i=c.value,i!=null&&Ie(r,!!c.multiple,i,!1)}},He=U,ot=H;var Qw={usingClientEntryPoint:!1,Events:[_l,Co,Sc,Te,qe,U]},pd={findFiberByHostInstance:Zi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ex={bundleType:pd.bundleType,version:pd.version,rendererPackageName:pd.rendererPackageName,rendererConfig:pd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:P.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=Kr(r),r===null?null:r.stateNode},findFiberByHostInstance:pd.findFiberByHostInstance||Jw,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 nm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nm.isDisabled&&nm.supportsFiber)try{tn=nm.inject(ex),Er=nm}catch{}}return Ns.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Qw,Ns.createPortal=function(r,i){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!jh(i))throw Error(n(200));return Xw(r,i,null,c)},Ns.createRoot=function(r,i){if(!jh(r))throw Error(n(299));var c=!1,f="",p=Cp;return i!=null&&(i.unstable_strictMode===!0&&(c=!0),i.identifierPrefix!==void 0&&(f=i.identifierPrefix),i.onRecoverableError!==void 0&&(p=i.onRecoverableError)),i=xh(r,1,!1,null,null,c,!1,f,p),r[ii]=i.current,Ni(r.nodeType===8?r.parentNode:r),new Sh(i)},Ns.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var i=r._reactInternals;if(i===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=Kr(i),r=r===null?null:r.stateNode,r},Ns.flushSync=function(r){return H(r)},Ns.hydrate=function(r,i,c){if(!em(i))throw Error(n(200));return tm(null,r,i,!0,c)},Ns.hydrateRoot=function(r,i,c){if(!jh(r))throw Error(n(405));var f=c!=null&&c.hydratedSources||null,p=!1,x="",M=Cp;if(c!=null&&(c.unstable_strictMode===!0&&(p=!0),c.identifierPrefix!==void 0&&(x=c.identifierPrefix),c.onRecoverableError!==void 0&&(M=c.onRecoverableError)),i=kp(i,null,r,1,c??null,p,!1,x,M),r[ii]=i.current,Ni(r),f)for(r=0;r<f.length;r++)c=f[r],p=c._getVersion,p=p(c._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[c,p]:i.mutableSourceEagerHydrationData.push(c,p);return new Qf(i)},Ns.render=function(r,i,c){if(!em(i))throw Error(n(200));return tm(null,r,i,!1,c)},Ns.unmountComponentAtNode=function(r){if(!em(r))throw Error(n(40));return r._reactRootContainer?(H(function(){tm(null,null,r,!1,function(){r._reactRootContainer=null,r[ii]=null})}),!0):!1},Ns.unstable_batchedUpdates=U,Ns.unstable_renderSubtreeIntoContainer=function(r,i,c,f){if(!em(c))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return tm(r,i,c,!1,f)},Ns.version="18.3.1-next-f1338f8080-20240426",Ns}var Op;function Sy(){if(Op)return Ch.exports;Op=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(),Ch.exports=cx(),Ch.exports}var zp;function ux(){if(zp)return rm;zp=1;var e=Sy();return rm.createRoot=e.createRoot,rm.hydrateRoot=e.hydrateRoot,rm}var dx=ux();const fx=Y_(dx);async function jy(e){const t=String(e||"");if(!t)return!1;try{return await navigator.clipboard.writeText(t),!0}catch{try{const n=document.createElement("textarea");return n.value=t,n.style.position="fixed",n.style.left="-9999px",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),!0}catch{return!1}}}const mx=3,hx=Number.MAX_SAFE_INTEGER;function ky(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ny(e){return Array.isArray(e)}function _x(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 px(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function ru({kind:e,children:t}){return s.jsx("span",{className:`json-token ${e}`,children:t})}function gx(e){const t=JSON.stringify(e.value),n=t.length>96||t.includes("\\n")||t.includes("\\r")||t.includes("\\t"),[o,a]=h.useState(!n||e.expansion_mode==="unfolded");return h.useEffect(()=>{n&&a(e.expansion_mode==="unfolded")},[n,e.expansion_mode,e.expansion_version]),n?s.jsxs("span",{className:`json-string ${o?"open":"collapsed"}`,children:[s.jsx("button",{type:"button",className:"json-string__toggle",onClick:()=>a(l=>!l),"aria-label":o?"Collapse string value":"Expand string value","aria-expanded":o,children:o?"▾":"▸"}),o?s.jsx("span",{className:"json-token string json-string__value",children:t}):s.jsxs("button",{type:"button",className:"json-string__preview",onClick:()=>a(!0),"aria-label":"Expand string value",children:[s.jsx("span",{className:"json-token string json-string__preview_text",children:t}),s.jsx("span",{className:"json-string__suffix",children:"(...)"})]})]}):s.jsx(ru,{kind:"string",children:t})}function yx(e,t,n){return e===null?s.jsx(ru,{kind:"null",children:"null"}):typeof e=="string"?s.jsx(gx,{value:e,expansion_mode:t,expansion_version:n}):typeof e=="number"?s.jsx(ru,{kind:"number",children:String(e)}):typeof e=="boolean"?s.jsx(ru,{kind:"boolean",children:e?"true":"false"}):s.jsx(ru,{kind:"string",children:JSON.stringify(String(e))})}function vx(e){return Ny(e)?e.length===1?"1 item":`${e.length} items`:ky(e)?Object.keys(e).length===1?"1 key":`${Object.keys(e).length} keys`:""}function Cy(e){const{label:t,value:n,depth:o,collapse_after_depth:a,expansion_mode:l,expansion_version:d,trailing_comma:u}=e,m=o*14,y=ky(n),g=Ny(n),v=y||g,w=o<a,[b,C]=h.useState(w);h.useEffect(()=>{C(w)},[w,d]);const S=t?s.jsxs(s.Fragment,{children:[s.jsx(ru,{kind:"key",children:JSON.stringify(t)}),": "]}):null;if(!v)return s.jsxs("div",{className:"json-viewer__line",style:{paddingLeft:m},children:[S,yx(n,l,d),u?",":""]});const R=g?"[":"{",T=g?"]":"}",D=vx(n),q=b?`${R}`:`${R}…${T}${D?` (${D})`:""}`,P=g?n.map((K,Q)=>({key:String(Q),label:void 0,value:K})):Object.entries(n).map(([K,Q])=>({key:K,label:K,value:Q}));return s.jsxs("details",{className:"json-viewer__details",open:b,onToggle:K=>C(K.currentTarget.open),children:[s.jsxs("summary",{className:"json-viewer__summary",style:{paddingLeft:m},children:[S,s.jsx("span",{className:"json-viewer__caret","aria-hidden":"true",children:b?"▾":"▸"}),s.jsx("span",{className:"json-viewer__punct",children:q}),!b&&u?s.jsx("span",{className:"json-viewer__punct",children:","}):null]}),b?s.jsx("div",{className:"json-viewer__children",children:P.length===0?s.jsxs("div",{className:"json-viewer__line",style:{paddingLeft:m},children:[s.jsx("span",{className:"json-viewer__punct",children:T}),u?",":""]}):s.jsxs(s.Fragment,{children:[P.map((K,Q)=>{const Z=Q===P.length-1;return s.jsx(Cy,{label:K.label,value:K.value,depth:o+1,collapse_after_depth:a,expansion_mode:l,expansion_version:d,trailing_comma:!Z},`${o}:${t||"root"}:${K.key}`)}),s.jsxs("div",{className:"json-viewer__line",style:{paddingLeft:m},children:[s.jsx("span",{className:"json-viewer__punct",children:T}),u?",":""]})]})}):null]})}function Ey(e){const{value:t,className:n,showCopy:o=!0}=e,[a,l]=h.useState({mode:"folded",version:0}),d=typeof e.collapseAfterDepth=="number"&&(Number.isFinite(e.collapseAfterDepth)||e.collapseAfterDepth===1/0)&&e.collapseAfterDepth>=0?e.collapseAfterDepth===1/0?Number.MAX_SAFE_INTEGER:Math.trunc(e.collapseAfterDepth):mx,u=a.mode==="unfolded"?hx:d,m=h.useMemo(()=>typeof t=="string"?_x(t):t,[t]),y=h.useMemo(()=>px(t),[t]),g=["json-viewer",n].filter(Boolean).join(" ");h.useEffect(()=>{l(w=>({mode:"folded",version:w.version+1}))},[m]);const v=()=>{l(w=>({mode:w.mode==="unfolded"?"folded":"unfolded",version:w.version+1}))};return s.jsxs("div",{className:g,children:[s.jsxs("div",{className:"json-viewer__toolbar",children:[s.jsx("button",{type:"button",className:"json-viewer__btn json-viewer__toggle-all",onClick:v,"aria-expanded":a.mode==="unfolded",children:a.mode==="unfolded"?"Fold all":"Unfold all"}),o?s.jsx("button",{type:"button",className:"json-viewer__btn json-viewer__copy",onClick:()=>void jy(y),children:"Copy"}):null]}),s.jsx("div",{className:"json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:s.jsx(Cy,{value:m,depth:0,collapse_after_depth:u,expansion_mode:a.mode,expansion_version:a.version,trailing_comma:!1})})]})}function Mh(e){const t=[],n=String(e??"");let o=0,a="";const l=()=>{a&&(t.push(a),a="")};for(;o<n.length;){const d=n[o];if(d==="`"){const u=n.indexOf("`",o+1);if(u!==-1){l(),t.push(s.jsx("code",{children:n.slice(o+1,u)},`code:${o}`)),o=u+1;continue}}if(d==="*"&&n[o+1]==="*"){const u=n.indexOf("**",o+2);if(u!==-1){l(),t.push(s.jsx("strong",{children:n.slice(o+2,u)},`bold:${o}`)),o=u+2;continue}}a+=d,o+=1}return l(),t}function wx(e){return String(e??"").replace(/\r\n/g,`
|
|
41
|
+
`).replace(/\r/g,`
|
|
42
|
+
`).split(`
|
|
43
|
+
`)}function xx({text:e,className:t}){const n=wx(e),o=[];let a=0;for(;a<n.length;){const d=n[a],u=String(d??"");if(!u.trim()){a+=1;continue}if(u.trim().startsWith("```")){const w=u.trim().replace(/```/g,"").trim(),b=[];for(a+=1;a<n.length&&!String(n[a]??"").trim().startsWith("```");)b.push(String(n[a]??"")),a+=1;a<n.length&&(a+=1);const C=b.join(`
|
|
44
|
+
`);o.push(s.jsx("pre",{className:"mf-md_pre",children:s.jsx("code",{className:w?`language-${w}`:void 0,children:C})},`pre:${a}`));continue}const m=u.match(/^(#{1,3})\s+(.*)$/);if(m){const v=m[1].length,w=m[2]||"",b=Mh(w);v===1?o.push(s.jsx("h1",{children:b},`h1:${a}`)):v===2?o.push(s.jsx("h2",{children:b},`h2:${a}`)):o.push(s.jsx("h3",{children:b},`h3:${a}`)),a+=1;continue}const y=v=>{const w=v.trimStart();return w.startsWith("- ")||w.startsWith("* ")};if(y(u)){const v=[];for(;a<n.length&&y(String(n[a]??""));){const w=String(n[a]??"").trimStart();v.push(w.slice(2)),a+=1}o.push(s.jsx("ul",{className:"mf-md_ul",children:v.map((w,b)=>s.jsx("li",{children:Mh(w)},`li:${a}:${b}`))},`ul:${a}`));continue}const g=[];for(;a<n.length&&String(n[a]??"").trim();)g.push(String(n[a]??"")),a+=1;o.push(s.jsx("p",{className:"mf-md_p",children:g.map((v,w)=>s.jsxs(ye.Fragment,{children:[Mh(v),w<g.length-1?s.jsx("br",{}):null]},`pl:${a}:${w}`))},`p:${a}`))}const l=["mf-md",t].filter(Boolean).join(" ");return s.jsx("div",{className:l,children:o})}const Ip="observe";function is(e){return!e||typeof e!="object"?null:e}function p_(e,t){const n=String(e||"").replace(/\s+/g," ").trim();return n?n.length<=t?n:`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`:""}function Dp(e){const t=is(e);if(!t)return null;const n=typeof t.role=="string"?String(t.role).trim():"",o=typeof t.content=="string"?String(t.content):"";if(!n||o==="")return null;const a=typeof t.name=="string"?String(t.name).trim():"";return{role:n,content:o,name:a||void 0}}function bx(e){if(Array.isArray(e)){if(e.length===0)return null;const n=[];for(const o of e){const a=Dp(o);if(!a)return null;n.push(a)}return n}const t=Dp(e);return t?[t]:null}function Sx(e){const t=String(e||"").trim();if(!t)return null;const n=t[0],o=t[t.length-1];if(!(n==="{"&&o==="}"||n==="["&&o==="]"))return null;try{const l=JSON.parse(t);return l&&typeof l=="object"||Array.isArray(l)?l:null}catch{return null}}function jx(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 Fp({text:e}){const t=String(e||""),n=Sx(t);if(n!==null)return s.jsx(Ey,{value:n});const o=t.trim();return o.startsWith("{")||o.startsWith("[")?s.jsx("pre",{className:"run-details-output",children:t||"(none)"}):t.includes(`
|
|
45
|
+
`)||jx(t)?s.jsx("div",{className:"run-details-output",children:s.jsx(xx,{text:t})}):s.jsx("pre",{className:"run-details-output",children:t||"(none)"})}function $y({value:e}){if(e==null)return s.jsx("pre",{className:"run-details-output",children:"(none)"});const t=bx(e);return t?s.jsx("div",{className:"mf-msg-list",children:t.map((n,o)=>s.jsxs("div",{className:"mf-msg",children:[s.jsxs("div",{className:"mf-msg-meta",children:[s.jsx("span",{className:`mf-msg-role ${n.role}`,children:n.role}),n.name?s.jsx("span",{className:"mf-msg-name",children:n.name}):null]}),s.jsx("div",{className:"mf-msg-content",children:s.jsx(Fp,{text:n.content})})]},`${n.role}:${o}`))}):typeof e=="string"?s.jsx(Fp,{text:e}):s.jsx(Ey,{value:e})}function My(e){const t=e.effect;return!t||typeof t!="object"?null:t}function Ja(e){const t=My(e);return(t&&typeof t.type=="string"?t.type:"")||"effect"}function Vm(e){const t=My(e),n=t==null?void 0:t.payload;return!n||typeof n!="object"?null:n}function X_(e){const t=e.result;return!t||typeof t!="object"?null:t}function Ay(e){if(Ja(e)!=="tool_calls")return[];const n=X_(e),o=n&&Array.isArray(n.results)?n.results:null;if(!o)return[];const a=[];for(const l of o){const d=is(l);if(!d)continue;const u=typeof d.name=="string"?d.name.trim():"";u&&a.push({call_id:typeof d.call_id=="string"?d.call_id:void 0,name:u,success:!!d.success,output:d.output,error:d.error})}return a}function Ty(e){if(Ja(e)!=="tool_calls")return[];const n=Vm(e),o=n&&Array.isArray(n.tool_calls)?n.tool_calls:null;if(!o)return[];const a=[];for(const l of o){const d=is(l);if(!d)continue;const u=typeof d.name=="string"?d.name.trim():"";if(!u)continue;const m=is(d.args)||is(d.arguments)||{};a.push({call_id:typeof d.call_id=="string"?d.call_id:void 0,name:u,args:m})}return a}function Gm(e){const t=e.error;if(typeof t=="string")return t.trim();const n=is(t);if(n){const o=typeof n.message=="string"?n.message.trim():"",a=typeof n.stack=="string"?n.stack.trim():"";return o||a||""}return""}function Ry(e){if(!e)return"";const t=e.reasoning;if(typeof t=="string")return t.trim();const n=is(t);return n&&typeof n.text=="string"?n.text.trim():""}function Ly(e){const t=Ja(e),n=Vm(e),o=X_(e),a=(l,d)=>{const u=String(l||"").replace(/\s+/g," ").trim();return u?u.length<=d?u:`${u.slice(0,Math.max(0,d-1)).trimEnd()}…`:""};if(t==="llm_call"){const l=o==null?void 0:o.content,d=typeof l=="string"?l.replace(/\s+/g," ").trim():"",u=Ry(o),m=Array.isArray(o==null?void 0:o.tool_calls)?o.tool_calls:null,g=!!(m&&m.length>0)?u||d:d||u;return a(g,220)}if(t==="tool_calls"){const l=o&&Array.isArray(o.results)?o.results:null;if(!l)return"";const d=l.filter(u=>{var m;return((m=is(u))==null?void 0:m.success)===!1});return d.length>0?`${d.length} tool call(s) failed`:`${l.length} tool call(s) executed`}return t==="ask_user"&&n&&typeof n.prompt=="string"?String(n.prompt).trim():""}function Em(e){const t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||Gm(e.step)?"failed":t}function kx(e){const t=e.map(n=>Em(n));return t.some(n=>n==="failed")?"failed":t.some(n=>n==="waiting")?"waiting":t.some(n=>n==="running")?"running":"completed"}function Ah(e){return e.filter(t=>!t.hidden)}function Nx(e){const t=Ja(e),n=Gm(e);return Ah(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:!n},{id:"raw",label:"Raw"}]:t==="tool_calls"?[{id:"tools",label:"Tools"},{id:"errors",label:"Errors",hidden:!n},{id:"raw",label:"Raw"}]:[{id:"errors",label:"Errors",hidden:!n},{id:"raw",label:"Raw"}])}function Cx(e){const t=Ja(e);return t==="llm_call"?"user":t==="tool_calls"?"tools":Gm(e)?"errors":"raw"}function Ex(e){const t=new Map,n=Vm(e),o=n&&Array.isArray(n.tools)?n.tools:null;if(!o)return t;for(const a of o){const l=is(a);if(!l)continue;const d=typeof l.name=="string"?l.name.trim():"";if(!d)continue;const m=(Array.isArray(l.parameters)?l.parameters:[]).map(y=>{const g=is(y);return(g&&typeof g.id=="string"?g.id.trim():"")||""}).filter(Boolean);t.set(d,m)}return t}function Py(e,t,n){const o=Object.keys(t||{}),a=n&&n.length?n.filter(m=>o.includes(m)):[],l=o.filter(m=>!a.includes(m)).sort(),d=[...a,...l],u=d.slice(0,5).map(m=>{const y=t[m];return typeof y=="string"?`${m}=${JSON.stringify(p_(y,42))}`:typeof y=="number"||typeof y=="boolean"?`${m}=${String(y)}`:y==null?`${m}=null`:`${m}=${p_(JSON.stringify(y),42)}`});return`${e}(${u.join(", ")}${d.length>5?", …":""})`}function $x(e){const t=e.ts?String(e.ts):"";if(!t)return"";try{const n=new Date(t);return Number.isFinite(n.getTime())?n.toLocaleTimeString():""}catch{return""}}function Th({item:e,label:t,toolDefs:n,defaultOpen:o=!1}){const a=e.step,l=Ja(a),d=Nx(a),u=Cx(a),[m,y]=h.useState(u),[g,v]=h.useState(!!o),w=Vm(a),b=X_(a),C=Gm(a),S=$x(e),R=e.nodeId?String(e.nodeId):"",T=e.runId?String(e.runId):"",D=l==="tool_calls"?Ty(a):[],q=l==="tool_calls"?Ay(a):[],P=D.map(de=>Py(de.name,de.args,n.get(de.name)||null)),Q=(()=>{if(m==="raw")return a;if(m==="errors")return C||null;if(l==="llm_call"){const de=w||{},pe=typeof de.system_prompt=="string"?String(de.system_prompt):"",F=typeof de.prompt=="string"?String(de.prompt):"",E=is(b==null?void 0:b.metadata),j=E?is(E._runtime_observability):null,L=j?is(j.llm_generate_kwargs):null,z=L&&Array.isArray(L.messages)?L.messages:null,te=E?is(E._provider_request):null,I=te?is(te.payload):null,O=I&&Array.isArray(I.messages)?I.messages:null,G=Array.isArray(de.messages)?de.messages:[],$=z||O||G,Y=$.filter(le=>String((le==null?void 0:le.role)||"").trim()==="system"),se=$.filter(le=>String((le==null?void 0:le.role)||"").trim()==="user");if(m==="system"){const le=[],he=pe.trim(),be=!!he&&Y.some(je=>typeof(je==null?void 0:je.content)=="string"&&String(je.content).trim()===he);return he&&!be&&le.push({role:"system",name:"system_prompt",content:pe}),le.push(...Y),le}if(m==="user"){const le=[],he=F.trim(),be=!!he&&se.some(je=>typeof(je==null?void 0:je.content)=="string"&&String(je.content).trim()===he);return he&&!be&&le.push({role:"user",name:"prompt",content:F}),le.push(...se),le}if(m==="tools")return de.tools||[];if(m==="response"){const le=b==null?void 0:b.content;if(typeof le=="string"&&le.trim())return le;const he=b==null?void 0:b.output;if(he!==void 0)return he;const be=Array.isArray(b==null?void 0:b.tool_calls)?b.tool_calls:null;return be&&be.length?{tool_calls:be}:b}if(m==="reasoning")return Ry(b)||null}return l==="tool_calls"&&m==="tools"?{tool_calls:D,tool_signatures:P,results:q}:a})(),Z=Ly(a),ee=Em(e),ue=ee==="completed"?"OK":ee==="failed"?"ERROR":ee==="waiting"?"WAITING":ee.toUpperCase();return s.jsxs("details",{className:`agent-trace-entry ${ee}`,open:g,onToggle:de=>v(de.currentTarget.open),children:[s.jsxs("summary",{className:"agent-trace-summary",children:[s.jsx("span",{className:`agent-trace-status ${ee}`,children:ue}),s.jsx("span",{className:"agent-cycle-stage","data-stage":t,children:t}),s.jsx("span",{className:"agent-trace-kind",children:l}),S?s.jsx("span",{className:"agent-trace-node",children:S}):null,R?s.jsx("span",{className:"agent-trace-node",children:R}):null,T?s.jsx("span",{className:"agent-trace-run",children:T}):null]}),Z?s.jsx("div",{className:"agent-trace-preview",children:Z}):null,s.jsxs("div",{className:"agent-trace-body",children:[s.jsx("div",{className:"agent-trace-tabs",children:d.map(de=>s.jsx("button",{type:"button",className:`agent-trace-tab ${de.id===m?"active":""}`,onClick:()=>y(de.id),children:de.label},de.id))}),s.jsx($y,{value:Q})]})]})}function Mx({acts:e}){const t=e.flatMap(l=>Ay(l.step)),n=t.filter(l=>l.success===!1),o=n.length?`${n.length} error(s)`:t.length?`${t.length} tool result(s)`:"(none)",a=n.length?"failed":"completed";return s.jsxs("details",{className:`agent-trace-entry ${a}`,open:!1,children:[s.jsxs("summary",{className:"agent-trace-summary",children:[s.jsx("span",{className:`agent-trace-status ${a}`,children:n.length?"ERROR":"OK"}),s.jsx("span",{className:"agent-cycle-stage","data-stage":Ip,children:Ip}),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((l,d)=>{const u=l.success?"completed":"failed",m=l.success?"OK":"ERROR",y=l.success?l.output:l.error??l.output;return s.jsxs("details",{className:`agent-observe-result ${u}`,open:!1,children:[s.jsxs("summary",{className:"agent-observe-summary",children:[s.jsx("span",{className:`agent-trace-status ${u}`,children:m}),s.jsx("span",{className:"agent-observe-name",children:l.name}),l.call_id?s.jsx("span",{className:"agent-observe-callid",children:l.call_id}):null]}),s.jsx($y,{value:y})]},`${l.name}:${l.call_id||""}:${d}`)})})})]})}function Ax({items:e,subRunId:t,title:n,subtitle:o,onOpenSubRun:a,defaultOpenLatest:l=!0}){const d=h.useMemo(()=>{const v=Array.isArray(e)?e.slice():[];return v.sort((w,b)=>{const C=w.ts?new Date(w.ts).getTime():NaN,S=b.ts?new Date(b.ts).getTime():NaN;return Number.isFinite(C)&&Number.isFinite(S)?C-S:0}),v},[e]),u=h.useMemo(()=>{const v=[];let w=null,b=0;for(const C of d){const S=Ja(C.step);if(S==="llm_call"){b+=1,w={id:`cycle:${C.runId}:${b}:${C.ts||""}`,index:b,items:[C],think:C,acts:[],others:[],status:Em(C),ts:C.ts},v.push(w);continue}w||(b+=1,w={id:`cycle:${C.runId}:${b}:${C.ts||""}`,index:b,items:[],think:null,acts:[],others:[],status:Em(C),ts:C.ts},v.push(w)),w.items.push(C),S==="tool_calls"?w.acts.push(C):w.others.push(C),w.status=kx(w.items)}return v},[d]),m=typeof n=="string"&&n.trim()?n.trim():"Agent calls",y=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:m}),s.jsxs("div",{className:"agent-trace-subtitle",children:[y,g?s.jsxs("span",{className:"agent-trace-subrun",children:[" ","sub_run_id: ",g,s.jsx("button",{type:"button",className:"agent-trace-copy",onClick:v=>{v.stopPropagation(),jy(g)},title:`Copy sub_run_id: ${g}`,"aria-label":"Copy sub run id",children:"⧉"}),a?s.jsx("button",{type:"button",className:"agent-trace-open",onClick:v=>{v.stopPropagation(),a()},title:"Open sub-run",children:"Open"}):null]}):null]})]}),d.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:[u.length," cycle(s)"]}),u.map(v=>{const w=v.status,b=w==="completed"?"OK":w==="failed"?"ERROR":w==="waiting"?"WAITING":w.toUpperCase(),C=w==="completed"?"✓":w==="failed"?"✗":"",S=C?`${C} ${b}`:b,R=v.think?Ly(v.think.step):"",T=v.think?Ex(v.think.step):new Map,q=v.acts.flatMap(K=>Ty(K.step)).map(K=>Py(K.name,K.args,T.get(K.name)||null)),P=l&&v.index===u.length;return s.jsxs("details",{className:`agent-cycle ${w}`,open:P,children:[s.jsxs("summary",{className:"agent-cycle-summary",children:[s.jsx("span",{className:`agent-trace-status ${w}`,children:S}),s.jsx("span",{className:"agent-cycle-label",children:"cycle"}),s.jsxs("span",{className:"agent-cycle-index",children:["#",v.index]}),q.length?s.jsxs("span",{className:"agent-trace-badges",children:[q.slice(0,3).map(K=>s.jsx("span",{className:"run-metric-badge metric-tool",title:K,children:p_(K,62)},K)),q.length>3?s.jsxs("span",{className:"run-metric-badge metric-tool",children:["+",q.length-3]}):null]}):null,s.jsx("span",{className:"agent-cycle-spacer"}),R?s.jsx("span",{className:"agent-cycle-preview",children:R}):null]}),s.jsxs("div",{className:"agent-cycle-body",children:[v.think?s.jsx(Th,{item:v.think,label:"think",toolDefs:T,defaultOpen:P}):null,v.acts.map(K=>s.jsx(Th,{item:K,label:"act",toolDefs:T},K.id)),s.jsx(Mx,{acts:v.acts}),v.others.length?s.jsxs("div",{className:"agent-cycle-others",children:[s.jsx("div",{className:"agent-cycle-others-title",children:"other"}),v.others.map(K=>{const Q=P&&Ja(K.step)==="answer_user";return s.jsx(Th,{item:K,label:"other",toolDefs:T,defaultOpen:Q},K.id)})]}):null]})]},v.id)})]})]})}function Vi(e){return typeof e=="string"?e.trim():""}function Tx(e){var t;return Vi(e.run_id)||Vi((t=e.record)==null?void 0:t.run_id)}function g_(e){return Vi(e==null?void 0:e.node_id)}const Rx=new Set(["reason","act","observe","thought","think"]);function y_(e){const t=Vi(e);if(!t.includes("::"))return t;const n=t.split("::");if(n.length<2)return t;const o=String(n[n.length-1]||"").trim().toLowerCase();return Rx.has(o)?n.slice(0,-1).join("::"):t}function Oy(e){var t;return Vi((t=e==null?void 0:e.effect)==null?void 0:t.type)}function Lx(e){return Vi(e==null?void 0:e.status)||"unknown"}function Bp(e){return Vi(e==null?void 0:e.step_id)}function Px(e){return Vi(e==null?void 0:e.ended_at)||Vi(e==null?void 0:e.started_at)}function Ox(e){const t=new Map,n=new Map;for(const a of e){const l=y_(g_(a));if(!l)continue;const d=Oy(a);d==="llm_call"?t.set(l,(t.get(l)||0)+1):d==="tool_calls"&&n.set(l,(n.get(l)||0)+1)}const o=a=>{let l="",d=-1;for(const[u,m]of a)m>d&&(l=u,d=m);return l};return o(t)||o(n)||""}function zx(e,t){const n=Vi(t.run_id);if(!n)return{run_id:"",node_id:"",items:[]};const o=(Array.isArray(e)?e:[]).filter(b=>b&&b.record&&Tx(b)===n).map(b=>({cursor:b.cursor,record:b.record})).sort((b,C)=>(b.cursor||0)-(C.cursor||0)),a=o.map(b=>b.record),l=y_(Vi(t.node_id)),d=l||Ox(a),u=new Set(["llm_call","tool_calls","ask_user","answer_user"]);let m=o.filter(b=>u.has(Oy(b.record)));l&&(m=m.filter(b=>y_(g_(b.record))===l));const y=new Map,g=[];for(const b of m){const C=Bp(b.record);if(!C){g.push(b);continue}const S=y.get(C);(!S||(b.cursor||0)>(S.cursor||0))&&y.set(C,b)}const w=[...g,...Array.from(y.values())].sort((b,C)=>(b.cursor||0)-(C.cursor||0)).map(b=>{const C=b.record,S=g_(C)||"(node?)",R=Px(C),T=Bp(C);return{id:`ledger:${n}:${b.cursor}:${T||""}`,runId:n,nodeId:S,ts:R||void 0,status:Lx(C),step:C}});return{run_id:n,node_id:d,items:w}}function Km(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 Ix(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Dx(e){const t=String(e.role||"message").trim()||"message",n=String(e.title||"").trim(),o=String(e.ts||"").trim(),a=[t];return n&&a.push(n),o&&a.push(o),a.join(" · ")}function Fx(e){return e.endsWith(`
|
|
46
|
+
`)?e:`${e}
|
|
47
|
+
`}function Bx(e){return String(e||"").trimStart().startsWith("```")}function Ux(e,t){const o=[`# ${String((t==null?void 0:t.heading)||"Chat").trim()||"Chat"}`,""];for(const a of e){const l=Dx(a);o.push(`## ${l}`,"");const d=String(a.content||""),u=Km(d);u!==null&&!Bx(d)?o.push("```json",Ix(u).trimEnd(),"```",""):o.push(Fx(d).trimEnd(),""),o.push("---","")}for(;o.length&&!o[o.length-1].trim();)o.pop();return o.length&&o[o.length-1]==="---"&&o.pop(),`${o.join(`
|
|
48
|
+
`).trimEnd()}
|
|
49
|
+
`}async function nc(e){const t=String(e||"");if(!t)return!1;try{return await navigator.clipboard.writeText(t),!0}catch{try{const n=document.createElement("textarea");return n.value=t,n.style.position="fixed",n.style.left="-9999px",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),!0}catch{return!1}}}function Hx(e){const t=String(e.filename||"").trim()||"export.txt",n=String(e.text||""),o=String(e.mime),a=new Blob([n],{type:o}),l=URL.createObjectURL(a),d=document.createElement("a");d.href=l,d.download=t,document.body.appendChild(d),d.click(),d.remove(),window.setTimeout(()=>URL.revokeObjectURL(l),1e3)}const Wx=3,qx=Number.MAX_SAFE_INTEGER;function zy(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Iy(e){return Array.isArray(e)}function Vx(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function su({kind:e,children:t}){return s.jsx("span",{className:`pc-json-token ${e}`,children:t})}function Gx(e){const t=JSON.stringify(e.value),n=t.length>96||t.includes("\\n")||t.includes("\\r")||t.includes("\\t"),[o,a]=h.useState(!n||e.expansionMode==="unfolded");return h.useEffect(()=>{n&&a(e.expansionMode==="unfolded")},[n,e.expansionMode,e.expansionVersion]),n?s.jsxs("span",{className:`pc-json-string ${o?"open":"collapsed"}`,children:[s.jsx("button",{type:"button",className:"pc-json-string__toggle",onClick:()=>a(l=>!l),"aria-label":o?"Collapse string value":"Expand string value","aria-expanded":o,children:o?"▾":"▸"}),o?s.jsx("span",{className:"pc-json-token string pc-json-string__value",children:t}):s.jsxs("button",{type:"button",className:"pc-json-string__preview",onClick:()=>a(!0),"aria-label":"Expand string value",children:[s.jsx("span",{className:"pc-json-token string pc-json-string__preview_text",children:t}),s.jsx("span",{className:"pc-json-string__suffix",children:"(...)"})]})]}):s.jsx(su,{kind:"string",children:t})}function Kx(e,t,n){return e===null?s.jsx(su,{kind:"null",children:"null"}):typeof e=="string"?s.jsx(Gx,{value:e,expansionMode:t,expansionVersion:n}):typeof e=="number"?s.jsx(su,{kind:"number",children:String(e)}):typeof e=="boolean"?s.jsx(su,{kind:"boolean",children:e?"true":"false"}):s.jsx(su,{kind:"string",children:JSON.stringify(String(e))})}function Yx(e){return Iy(e)?e.length===1?"1 item":`${e.length} items`:zy(e)?Object.keys(e).length===1?"1 key":`${Object.keys(e).length} keys`:""}function Dy(e){const{label:t,value:n,depth:o,collapseAfterDepth:a,expansionMode:l,expansionVersion:d,trailingComma:u}=e,m=o*14,y=zy(n),g=Iy(n),v=y||g,w=o<a,[b,C]=h.useState(w);h.useEffect(()=>{C(w)},[w,d]);const S=t?s.jsxs(s.Fragment,{children:[s.jsx(su,{kind:"key",children:JSON.stringify(t)}),": "]}):null;if(!v)return s.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:m},children:[S,Kx(n,l,d),u?",":""]});const R=g?"[":"{",T=g?"]":"}",D=Yx(n),q=b?`${R}`:`${R}…${T}${D?` (${D})`:""}`,P=g?n.map((K,Q)=>({key:String(Q),label:void 0,value:K})):Object.entries(n).map(([K,Q])=>({key:K,label:K,value:Q}));return s.jsxs("details",{className:"pc-json-viewer__details",open:b,onToggle:K=>C(K.currentTarget.open),children:[s.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:m},children:[S,s.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:b?"▾":"▸"}),s.jsx("span",{className:"pc-json-viewer__punct",children:q}),!b&&u?s.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),b?s.jsx("div",{className:"pc-json-viewer__children",children:P.length===0?s.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:m},children:[s.jsx("span",{className:"pc-json-viewer__punct",children:T}),u?",":""]}):s.jsxs(s.Fragment,{children:[P.map((K,Q)=>{const Z=Q===P.length-1;return s.jsx(Dy,{label:K.label,value:K.value,depth:o+1,collapseAfterDepth:a,expansionMode:l,expansionVersion:d,trailingComma:!Z},`${o}:${t||"root"}:${K.key}`)}),s.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:m},children:[s.jsx("span",{className:"pc-json-viewer__punct",children:T}),u?",":""]})]})}):null]})}function Xx(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 os(e){const{value:t,className:n,showCopy:o=!0}=e,[a,l]=h.useState({mode:"folded",version:0}),d=typeof e.collapseAfterDepth=="number"&&(Number.isFinite(e.collapseAfterDepth)||e.collapseAfterDepth===1/0)&&e.collapseAfterDepth>=0?e.collapseAfterDepth===1/0?Number.MAX_SAFE_INTEGER:Math.trunc(e.collapseAfterDepth):Wx,u=a.mode==="unfolded"?qx:d,m=h.useMemo(()=>typeof t=="string"?Xx(t):t,[t]),y=h.useMemo(()=>Vx(t),[t]),g=["pc-json-viewer",n].filter(Boolean).join(" ");h.useEffect(()=>{l(w=>({mode:"folded",version:w.version+1}))},[m]);const v=()=>{l(w=>({mode:w.mode==="unfolded"?"folded":"unfolded",version:w.version+1}))};return s.jsxs("div",{className:g,children:[s.jsxs("div",{className:"pc-json-viewer__toolbar",children:[s.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__toggle-all",onClick:v,"aria-expanded":a.mode==="unfolded",children:a.mode==="unfolded"?"Fold all":"Unfold all"}),o?s.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__copy",onClick:()=>void nc(y),children:"Copy JSON"}):null]}),s.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:s.jsx(Dy,{value:m,depth:0,collapseAfterDepth:u,expansionMode:a.mode,expansionVersion:a.version,trailingComma:!1})})]})}function yd(e,t){const n=String(e??"");if(!t||!t.needles.length)return[n];const o=[],a=n.toLowerCase();let l=0;for(;l<n.length;){let d=-1,u="";for(let g=0;g<t.needlesLower.length;g++){const v=t.needlesLower[g];if(!v)continue;const w=a.indexOf(v,l);if(w===-1)continue;const b=t.needles[g]||"";b&&(d===-1||w<d||w===d&&b.length>u.length)&&(d=w,u=b)}if(d===-1||!u){o.push(n.slice(l));break}d>l&&o.push(n.slice(l,d));const m=t.hits===0&&t.id?t.id:void 0,y=n.slice(d,d+u.length);o.push(s.jsx("span",{id:m,className:t.className,children:y},`hl:${t.hits}`)),t.hits+=1,l=d+u.length}return o}function v_(e){const t=String(e||"").trim();if(t&&/^(https?:|mailto:|tel:|#|\/)/i.test(t))return t}let Zl=null;function Jx(e){var o;const t=String(e||"").trim();if(t.startsWith("/")&&!t.startsWith("//")&&!t.startsWith("/\\"))return!0;if(!/^https?:\/\//i.test(t))return!1;const n=typeof window<"u"?(o=window.location)==null?void 0:o.origin:void 0;if(!n||n==="null")return!1;try{return new URL(t).origin===n}catch{return!1}}function Fy(e,t,n){return s.jsx("a",{className:"pc-md_link pc-md_image_link",href:t,target:"_blank",rel:"noopener noreferrer",children:`image: ${n||t}`},e)}function qa(e,t){const n=[],o=String(e??"");let a=0,l="";const d=()=>{if(l){for(const u of yd(l,t))n.push(u);l=""}};for(;a<o.length;){const u=o[a];if(u==="!"&&o[a+1]==="["){const m=o.indexOf("]",a+2);if(m!==-1&&o[m+1]==="("){const y=o.indexOf(")",m+2);if(y!==-1){const g=o.slice(a+2,m),v=v_(o.slice(m+2,y));if(v&&Zl&&!Zl(v)){d(),n.push(Fy(`img:${a}`,v,g)),a=y+1;continue}if(v){d(),n.push(s.jsxs("span",{className:"pc-md_image_inline",children:[s.jsx("img",{className:"pc-md_img",src:v,alt:g,loading:"lazy"}),g?s.jsx("span",{className:"pc-md_img_caption",children:t?yd(g,t):g}):null]},`img:${a}`)),a=y+1;continue}}}}if(u==="["){const m=o.indexOf("]",a+1);if(m!==-1&&o[m+1]==="("){const y=o.indexOf(")",m+2);if(y!==-1){const g=o.slice(a+1,m),v=v_(o.slice(m+2,y));if(v){d(),n.push(s.jsx("a",{className:"pc-md_link",href:v,target:v.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:qa(g,t)},`link:${a}`)),a=y+1;continue}}}}if(u==="`"){const m=o.indexOf("`",a+1);if(m!==-1){d();const y=o.slice(a+1,m);n.push(s.jsx("code",{children:t?yd(y,t):y},`code:${a}`)),a=m+1;continue}}if(u==="*"&&o[a+1]==="*"){const m=o.indexOf("**",a+2);if(m!==-1){d();const y=o.slice(a+2,m);n.push(s.jsx("strong",{children:t?yd(y,t):y},`bold:${a}`)),a=m+2;continue}}if(u==="*"&&o[a+1]!=="*"){const m=o.indexOf("*",a+1);if(m!==-1){d();const y=o.slice(a+1,m);n.push(s.jsx("em",{children:t?yd(y,t):y},`em:${a}`)),a=m+1;continue}}l+=u,a+=1}return d(),n}function Zx(e){return String(e??"").replace(/\r\n/g,`
|
|
50
|
+
`).replace(/\r/g,`
|
|
51
|
+
`).split(`
|
|
52
|
+
`)}function wm(e){const n=String(e??"").match(/^([ \t]*)(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/);return n?{indent:n[1].replace(/\t/g," ").length,ordered:!!n[3],start:n[3]?Math.max(1,parseInt(n[3],10)||1):1,content:n[4]??""}:null}function Qx(e){const t=[];for(const a of e){const l=wm(a);l?t.push(l):t.length>0&&a.trim()&&(t[t.length-1].content+=` ${a.trim()}`)}const n=[],o=[];for(const a of t){for(;o.length>0&&a.indent<o[o.length-1].indent;)o.pop();let l=o.length>0?o[o.length-1]:null;if(l&&a.indent>l.indent){const d=l.node.items,u=d[d.length-1];if(u){const m={ordered:a.ordered,start:a.start,items:[]};u.children.push(m),o.push({indent:a.indent,node:m}),l=o[o.length-1]}}else if(l&&l.node.ordered!==a.ordered){o.pop();const d=o.length>0?o[o.length-1]:null,u={ordered:a.ordered,start:a.start,items:[]};if(d){const m=d.node.items,y=m[m.length-1];y?y.children.push(u):d.node.items.push({content:"",children:[u]})}else n.push(u);o.push({indent:a.indent,node:u}),l=o[o.length-1]}if(!l){const d={ordered:a.ordered,start:a.start,items:[]};n.push(d),o.push({indent:a.indent,node:d}),l=o[o.length-1]}l.node.items.push({content:a.content,children:[]})}return n}function By(e,t,n){const o=e.items.map((a,l)=>s.jsxs("li",{children:[qa(a.content,t),a.children.map((d,u)=>By(d,t,`${n}:${l}:${u}`))]},`${n}:li:${l}`));return e.ordered?s.jsx("ol",{className:"pc-md_ol",start:e.start!==1?e.start:void 0,children:o},n):s.jsx("ul",{className:"pc-md_ul",children:o},n)}function eb(e,t,n){return Qx(e).map((o,a)=>By(o,t,`${n}:${a}`))}function Up(e){let t=String(e??"").trim();return t?(t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>String(n??"").trim())):[]}function Hp(e){let t=String(e??"").trim();if(!t)return!1;t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1));const n=t.split("|").map(o=>String(o??"").trim());return n.length<2?!1:n.every(o=>/^:?-{3,}:?$/.test(o))}function _i(e){const t=Zl;Zl=e.images==="link"?e.inlineImage||Jx:null;try{return tb(e)}finally{Zl=t}}function tb({text:e,className:t,highlight:n,highlights:o,highlightClassName:a,highlightId:l}){const d=Zx(e),u=[],m=[];Array.isArray(o)&&m.push(...o),typeof n=="string"&&n.trim()&&m.push(n);const y=Array.from(new Set(m.map(b=>String(b??"").trim()).filter(Boolean))).filter(b=>b.length>=4),g=y.length?{needles:y,needlesLower:y.map(b=>b.toLowerCase()),className:a||"pc-md_hl",id:l,hits:0}:null;let v=0;for(;v<d.length;){const b=String(d[v]??"");if(!b.trim()){v+=1;continue}const C=b.trim();if(/^([-_*])(\s*\1){2,}$/.test(C)){u.push(s.jsx("hr",{className:"pc-md_hr"},`hr:${v}`)),v+=1;continue}const S=b.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(S){const D=v_(S[2]||"");if(D&&Zl&&!Zl(D)){u.push(s.jsx("p",{className:"pc-md_p",children:Fy(`img:${v}`,D,S[1]||"")},`p:${v}`)),v+=1;continue}if(D){const q=S[1]||"";u.push(s.jsxs("figure",{className:"pc-md_figure",children:[s.jsx("img",{className:"pc-md_img",src:D,alt:q,loading:"lazy"}),q?s.jsx("figcaption",{children:qa(q,g)}):null]},`figure:${v}`)),v+=1;continue}}if(b.trim().startsWith("```")){const q=b.trim().replace(/```/g,"").trim(),P=[];for(v+=1;v<d.length&&!String(d[v]??"").trim().startsWith("```");)P.push(String(d[v]??"")),v+=1;v<d.length&&(v+=1);const K=P.join(`
|
|
53
|
+
`);u.push(s.jsx("pre",{className:"pc-md_pre",children:s.jsx("code",{className:q?`language-${q}`:void 0,children:K})},`pre:${v}`));continue}const R=b.match(/^(#{1,5})\s+(.*)$/);if(R){const D=R[1].length,q=R[2]||"",P=qa(q,g);D===1?u.push(s.jsx("h1",{children:P},`h1:${v}`)):D===2?u.push(s.jsx("h2",{children:P},`h2:${v}`)):D===3?u.push(s.jsx("h3",{children:P},`h3:${v}`)):D===4?u.push(s.jsx("h4",{children:P},`h4:${v}`)):u.push(s.jsx("h5",{children:P},`h5:${v}`)),v+=1;continue}if(b.trimStart().startsWith(">")){const D=[];for(;v<d.length&&String(d[v]??"").trimStart().startsWith(">");){const P=String(d[v]??"").trimStart();D.push(P.replace(/^>\s?/,"")),v+=1}u.push(s.jsx("blockquote",{className:"pc-md_quote",children:D.map((q,P)=>s.jsxs(ye.Fragment,{children:[qa(q,g),P<D.length-1?s.jsx("br",{}):null]},`q:${v}:${P}`))},`quote:${v}`));continue}if(b.includes("|")&&v+1<d.length&&Hp(String(d[v+1]??""))){const D=Up(b),q=Math.max(1,D.length),P=[];for(v+=2;v<d.length;){const K=String(d[v]??"");if(!K.trim()||!K.includes("|"))break;const Q=Up(K),Z=[];for(let ee=0;ee<q;ee++)Z.push(Q[ee]??"");P.push(Z),v+=1}u.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:D.slice(0,q).map((K,Q)=>s.jsx("th",{children:qa(K,g)},`th:${v}:${Q}`))})}),s.jsx("tbody",{children:P.map((K,Q)=>s.jsx("tr",{children:K.map((Z,ee)=>s.jsx("td",{children:qa(Z,g)},`td:${v}:${Q}:${ee}`))},`tr:${v}:${Q}`))})]})},`table:${v}`));continue}if(wm(b)){const D=[];for(;v<d.length;){const q=String(d[v]??"");if(!q.trim()||q.trimStart().startsWith("```"))break;if(wm(q)||/^\s{2,}\S/.test(q)){D.push(q),v+=1;continue}break}u.push(s.jsx(ye.Fragment,{children:eb(D,g,`list:${v}`)},`list:${v}`));continue}const T=[];for(;v<d.length&&String(d[v]??"").trim()&&!(T.length>0&&wm(String(d[v]??"")));){const D=String(d[v]??"");if(T.length>0&&D.includes("|")&&v+1<d.length&&Hp(String(d[v+1]??"")))break;T.push(D),v+=1}u.push(s.jsx("p",{className:"pc-md_p",children:T.map((D,q)=>s.jsxs(ye.Fragment,{children:[qa(D,g),q<T.length-1?s.jsx("br",{}):null]},`pl:${v}:${q}`))},`p:${v}`))}const w=["pc-md",t].filter(Boolean).join(" ");return s.jsx("div",{className:w,children:u})}function nb(e){const t=String(e.text??""),n=h.useMemo(()=>Km(t),[t]),o=["pc-chat-content",e.className].filter(Boolean).join(" ");return n!==null?s.jsx("div",{className:o,children:s.jsx(os,{value:n,collapseAfterDepth:e.jsonCollapseAfterDepth})}):e.renderMarkdown?s.jsx("div",{className:o,children:e.renderMarkdown(t)}):s.jsx("div",{className:o,children:s.jsx(_i,{text:t,images:e.images,inlineImage:e.inlineImage})})}const Uy=[{id:"dark",label:"Dark (Abstract)",group:"dark",swatches:["#1a1a2e","#16213e","#0f3460","#e94560","#60a5fa","#27ae60"]},{id:"observer-night",label:"Observer Night",group:"dark",swatches:["#0b0f14","#10161e","#161e28","#e8a54a","#6ea8d8","#7bc98c"]},{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"]}];Uy.map(e=>({id:e.id,label:e.label}));function rb(e){return`theme-${String(e||"").trim()||"dark"}`}function Wp(e){try{const t=document.documentElement,n=Array.from(t.classList).filter(o=>o.startsWith("theme-"));for(const o of n)t.classList.remove(o);t.classList.add(rb(e))}catch{}}const w_=[{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}],x_=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function sb(e){const t=String(e).trim();return w_.find(n=>n.id===t)||w_[1]}function ib(e){const t=String(e).trim();return x_.find(n=>n.id===t)||x_[1]}function qp(e){try{const t=document.documentElement,n=sb(e.font_scale||"md"),o=ib(e.header_density||"standard");t.style.setProperty("--font-scale",String(n.scale)),t.style.setProperty("--header-density",String(o.density))}catch{}}var Hy=Sy();function Xc(...e){return e.filter(Boolean).join(" ")}function mu({value:e,options:t,placeholder:n="Select…",disabled:o=!1,loading:a=!1,searchable:l=!0,searchPlaceholder:d="Search…",allowCustom:u=!1,clearable:m=!1,minPopoverWidth:y=240,variant:g="panel",className:v,triggerClassName:w,ariaLabel:b,id:C,includeValueOption:S=!1,onOpen:R,customOptionLabel:T,validateCustomValue:D,onChange:q,renderOption:P,renderValue:K}){const Q=h.useRef(null),Z=h.useRef(null),ee=h.useRef(null),ue=h.useRef(R),de=h.useId(),pe=C||`af-select-${de.replace(/[^a-zA-Z0-9_-]/g,"")}`,F=`${pe}-listbox`,[E,j]=h.useState(!1),[L,z]=h.useState(""),[te,I]=h.useState(0),[O,G]=h.useState("bottom"),[$,Y]=h.useState({left:0,top:0,width:0});h.useEffect(()=>{ue.current=R},[R]);const se=h.useMemo(()=>{if(!S)return t;const ve=String(e??"").trim();return!ve||t.some(Ie=>Ie.value===ve)?t:[...t,{value:ve,label:ve}]},[S,t,e]),le=h.useMemo(()=>{const ve=String(e??"");return se.find(Ie=>Ie.value===ve)||null},[se,e]),he=h.useMemo(()=>(le==null?void 0:le.label)||String(e||"").trim()||"",[le,e]),be=h.useMemo(()=>{const ve=L.trim().toLowerCase();return ve?se.filter(Ie=>Ie.label.toLowerCase().includes(ve)||Ie.value.toLowerCase().includes(ve)):se},[se,L]),je=h.useMemo(()=>{if(!u)return null;const ve=L.trim();if(!ve||se.some(Mt=>Mt.value===ve))return null;const Ge=(D==null?void 0:D(ve,{options:se}))||"";return{value:ve,label:T?T(ve):`Use "${ve}"`,disabled:!!Ge,reason:Ge}},[u,T,se,L,D]),Ce=h.useMemo(()=>{const ve=je?[je,...be]:be;if(ve.length>0)return ve;const Ie=String(e??"").trim();return a&&Ie?[{value:Ie,label:he||Ie}]:ve},[je,be,a,he,e]),Fe=h.useCallback(()=>{const ve=Q.current;if(!ve)return;const Ie=ve.getBoundingClientRect(),Ge=Math.max(Ie.width,y),Mt=Math.max(8,Math.min(Ie.left,window.innerWidth-Ge-8)),Bt=window.innerHeight-Ie.bottom,dn=Ie.top,Ft=Bt>=220||Bt>=dn?"bottom":"top";G(Ft);const At=Ft==="bottom"?Ie.bottom+6:Ie.top-6;Y({left:Mt,top:At,width:Ge})},[y]),Ke=h.useCallback(()=>{j(!1),z("")},[]);h.useEffect(()=>{var ve;E&&((ve=ue.current)==null||ve.call(ue))},[E]),h.useEffect(()=>{if(!E)return;Fe();const ve=()=>Fe();return window.addEventListener("resize",ve),window.addEventListener("scroll",ve,!0),()=>{window.removeEventListener("resize",ve),window.removeEventListener("scroll",ve,!0)}},[E,Fe]),h.useEffect(()=>{if(!E)return;const ve=Ie=>{var Mt,Bt;const Ge=Ie.target;Ge&&((Mt=Q.current)!=null&&Mt.contains(Ge)||(Bt=Z.current)!=null&&Bt.contains(Ge)||Ke())};return document.addEventListener("mousedown",ve,!0),()=>document.removeEventListener("mousedown",ve,!0)},[E,Ke]),h.useEffect(()=>{if(!E)return;const ve=Math.max(0,Ce.findIndex(Ie=>Ie.value===e));I(ve===-1?0:ve),l&&setTimeout(()=>{var Ie;return(Ie=ee.current)==null?void 0:Ie.focus()},0)},[E,l,e,Ce]);const Ye=ve=>{var Ge;const Ie=Ce.find(Mt=>Mt.value===ve);Ie!=null&&Ie.disabled||(q(ve),Ke(),(Ge=Q.current)==null||Ge.focus())},Ct=ve=>{var Ie,Ge;if(ve.key==="Escape")return ve.preventDefault(),Ke(),(Ie=Q.current)==null||Ie.focus(),!0;if(ve.key==="Tab")return Ke(),(Ge=Q.current)==null||Ge.focus(),!1;if(ve.key==="ArrowDown")return ve.preventDefault(),I(Mt=>Math.min(Mt+1,Math.max(0,Ce.length-1))),!0;if(ve.key==="ArrowUp")return ve.preventDefault(),I(Mt=>Math.max(Mt-1,0)),!0;if(ve.key==="Home")return ve.preventDefault(),I(0),!0;if(ve.key==="End")return ve.preventDefault(),I(Math.max(0,Ce.length-1)),!0;if(ve.key==="Enter"){ve.preventDefault();const Mt=Ce[te];return Mt&&Ye(Mt.value),!0}return!1},wt=ve=>{if(!o){if(E){if(Ct(ve))return;if(ve.key===" "&&!l){ve.preventDefault();const Ie=Ce[te];Ie&&Ye(Ie.value)}return}(ve.key==="Enter"||ve.key===" "||ve.key==="ArrowDown"||ve.key==="ArrowUp")&&(ve.preventDefault(),j(!0))}},lt=!!String(e||"").trim(),yt=lt?he:n,rt=je!=null&&je.disabled?je.reason||"Unavailable":"",Ne=E&&Ce.length>0?`${pe}-opt-${te}`:void 0,Oe=s.jsx("span",{className:Xc("af-select-value",!lt&&"af-select-value--placeholder"),children:a&&!lt?"Loading…":yt}),it=K?K(le,String(e||"")):Oe;return s.jsxs("span",{className:Xc("af-select",g==="pin"?"af-select--pin":"af-select--panel",v),children:[s.jsxs("button",{ref:Q,id:pe,type:"button",className:Xc("af-select-trigger",m&<&&"af-select-trigger--clearable",w),disabled:o,onMouseDown:ve=>ve.stopPropagation(),onClick:ve=>{ve.stopPropagation(),!o&&j(Ie=>!Ie)},onKeyDown:wt,role:l?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":E,"aria-controls":E?F:void 0,"aria-activedescendant":l?void 0:Ne,"aria-label":b,children:[it,s.jsx("span",{className:Xc("af-select-caret",E&&"af-select-caret--open"),children:"▾"})]}),m&<?s.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:o,onMouseDown:ve=>{ve.preventDefault(),ve.stopPropagation()},onClick:ve=>{var Ie;ve.preventDefault(),ve.stopPropagation(),q(""),Ke(),(Ie=Q.current)==null||Ie.focus()},title:"Clear",children:"×"}):null,E?Hy.createPortal(s.jsxs("div",{ref:Z,className:Xc("af-select-popover",O==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${$.left}px`,top:`${$.top}px`,width:`${$.width}px`},onMouseDown:ve=>ve.stopPropagation(),onClick:ve=>ve.stopPropagation(),onWheel:ve=>ve.stopPropagation(),onKeyDown:Ct,tabIndex:-1,children:[l?s.jsxs("div",{className:"af-select-search",children:[s.jsx("input",{ref:ee,className:"af-select-search-input",value:L,onChange:ve=>z(ve.target.value),placeholder:d,onKeyDown:Ct,role:"combobox","aria-expanded":!0,"aria-controls":F,"aria-activedescendant":Ne,"aria-invalid":!!rt,"aria-describedby":rt?`${pe}-custom-error`:void 0}),rt?s.jsx("div",{id:`${pe}-custom-error`,className:"af-select-custom-error",role:"alert",children:rt}):null]}):null,s.jsx("div",{className:"af-select-options",role:"listbox",id:F,"aria-label":b,children:a&&Ce.length===0?s.jsx("div",{className:"af-select-empty",children:"Loading…"}):Ce.length===0?s.jsx("div",{className:"af-select-empty",children:"No results"}):Ce.map((ve,Ie)=>{var At;const Ge=ve.value===e,Mt=Ie===te,Bt=String(ve.group||"").trim(),dn=Ie>0?String(((At=Ce[Ie-1])==null?void 0:At.group)||"").trim():"",Ft=!!Bt&&Bt!==dn;return s.jsxs(ye.Fragment,{children:[Ft?s.jsx("div",{className:"af-select-group",role:"presentation",children:Bt}):null,s.jsx("div",{id:`${pe}-opt-${Ie}`,role:"option","aria-selected":Ge,className:Xc("af-select-option",Ge&&"af-select-option--selected",Mt&&"af-select-option--highlighted",ve.disabled&&"af-select-option--disabled"),title:ve.disabled?ve.reason||"Unavailable":void 0,onMouseEnter:()=>I(Ie),onMouseDown:fn=>{fn.preventDefault(),fn.stopPropagation()},onClick:()=>Ye(ve.value),"aria-disabled":ve.disabled?!0:void 0,children:P?P(ve,{selected:Ge,highlighted:Mt}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"af-select-option-label",children:[s.jsx("span",{children:ve.label}),ve.reason?s.jsx("small",{className:"af-select-option-reason",children:ve.reason}):null]}),Ge?s.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},ve.value)})})]}),document.body):null]})}function ob(e){const t=new Set,n=[];for(const o of e||[]){if(!o||typeof o!="object")continue;const a=String(o.name||"").trim();!a||t.has(a)||(t.add(a),n.push({name:a,display_name:typeof o.display_name=="string"?o.display_name:void 0}))}return n.sort((o,a)=>o.name.localeCompare(a.name)),n}function ab(e){const t=new Set,n=[];for(const o of e||[]){const a=String(o||"").trim();!a||t.has(a)||(t.add(a),n.push(a))}return n.sort(),n}function lb(e){const t=e.disabled===!0,n=e.layout||"stack",o=e.allowGatewayDefault!==!1,a=String(e.gatewayDefaultLabel||"(gateway default)"),l=String(e.providerLabel||"Provider"),d=String(e.modelLabel||"Model"),u=String(e.providerPlaceholder||"(select)"),m=String(e.modelPlaceholder||"(select)"),y=String(e.provider||"").trim(),g=String(e.model||"").trim(),v=ob(e.providers),w=ab(e.models),b=t||!!e.loadingProviders,C=t||!!e.loadingModels,S=[...o?[{value:"",label:a}]:[],...v.map(T=>({value:T.name,label:T.display_name?`${T.display_name} (${T.name})`:T.name}))],R=[...o?[{value:"",label:a}]:[],...w.map(T=>({value:T,label:T}))];return s.jsxs("div",{className:e.className,style:n==="row"?{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"flex-start"}:{display:"flex",flexDirection:"column",gap:"10px"},children:[s.jsxs("div",{style:n==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[s.jsx("label",{children:l}),s.jsx(mu,{value:y,options:S,placeholder:o?a:u,disabled:b,loading:!!e.loadingProviders,searchable:!0,allowCustom:e.allowCustomProvider===!0,clearable:o,variant:"panel",triggerClassName:e.selectClassName,ariaLabel:l,onChange:T=>e.onChange({provider:String(T||"").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:"var(--error)",fontSize:"12px",marginTop:"6px"},children:e.providerError}):null]}),s.jsxs("div",{style:n==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[s.jsx("label",{children:d}),s.jsx(mu,{value:g,options:R,placeholder:o?a:m,disabled:C,loading:!!e.loadingModels,searchable:!0,allowCustom:e.allowCustomModel===!0,clearable:o,variant:"panel",triggerClassName:e.selectClassName,ariaLabel:d,onChange:T=>e.onChange({provider:y,model:String(T||"").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:"var(--error)",fontSize:"12px",marginTop:"6px"},children:e.modelError}):null]})]})}function Vp(...e){return e.filter(Boolean).join(" ")}function cb({kicker:e="AbstractGateway connection",title:t="Connect to AbstractGateway",description:n="Sign in with the Gateway user token assigned by the Gateway admin.",statusLabel:o="Gateway token missing",statusTone:a="warn",tokenSourceLabel:l="token: missing",showGatewayUrl:d=!1,gatewayUrl:u="",gatewayUrlPlaceholder:m="http://127.0.0.1:8080",onGatewayUrlChange:y,userId:g,userPlaceholder:v="admin",onUserIdChange:w,token:b,tokenPlaceholder:C="Paste Gateway user token",showToken:S=!1,onTokenChange:R,onShowTokenChange:T,remember:D=!1,rememberLabel:q="Remember this browser",onRememberChange:P,loading:K=!1,submitting:Q=!1,submitDisabled:Z=!1,submitLabel:ee="Sign in",submittingLabel:ue="Signing in...",closeLabel:de="Close",signOutLabel:pe="Sign out",showClose:F=!1,showSignOut:E=!1,error:j,message:L,className:z,onSubmit:te,onClose:I,onSignOut:O}){const G=K||Q,$=G||Z||!String(g||"").trim()||!String(b||"").trim(),Y=se=>{se.preventDefault(),!$&&te()};return s.jsxs("form",{className:Vp("af-gateway-signin",z),onSubmit:Y,children:[s.jsxs("div",{className:"af-gateway-signin__hero",children:[s.jsxs("div",{children:[s.jsx("div",{className:"af-gateway-signin__kicker",children:e}),s.jsx("h2",{children:t}),n?s.jsx("p",{children:n}):null]}),s.jsx("div",{className:"af-gateway-signin__mark","aria-hidden":"true",children:"↔"})]}),s.jsxs("div",{className:"af-gateway-signin__status-row",children:[s.jsx("span",{className:Vp("af-gateway-signin__status",`af-gateway-signin__status--${a}`),children:o}),l?s.jsx("span",{className:"af-gateway-signin__source",children:l}):null]}),s.jsxs("div",{className:"af-gateway-signin__form",children:[d?s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-url",children:"Gateway URL"}),s.jsx("input",{id:"gateway-session-url",value:u,onChange:se=>y==null?void 0:y(se.target.value),placeholder:m,autoComplete:"url",disabled:G})]}):null,s.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-user",children:"Gateway user"}),s.jsx("input",{id:"gateway-session-user",value:g,onChange:se=>w(se.target.value),placeholder:v,autoComplete:"username",disabled:G}),s.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-token",children:"Gateway token"}),s.jsxs("div",{className:"af-gateway-signin__token-input",children:[s.jsx("input",{id:"gateway-session-token",type:S?"text":"password",value:b,onChange:se=>R(se.target.value),placeholder:C,autoComplete:"current-password",disabled:G}),s.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>T==null?void 0:T(!S),disabled:G,children:S?"Hide":"Show"})]}),s.jsx("label",{className:"af-gateway-signin__label",children:"Browser session"}),s.jsxs("label",{className:"af-gateway-signin__checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!D,onChange:se=>P==null?void 0:P(se.target.checked),disabled:G}),q]})]}),j?s.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:j}):null,!j&&L?s.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--ok",children:L}):null,s.jsxs("div",{className:"af-gateway-signin__actions",children:[F?s.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:I,disabled:G,children:de}):null,E?s.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(O==null?void 0:O()),disabled:G,children:pe}):null,s.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:$,children:Q?ue:ee})]})]})}function ub(e){return e==="light"?"Light":"Dark"}function db(e){const t=e.themes&&e.themes.length?e.themes:Uy,n=e.showSwatches!==!1,o=e.variant||"panel",a=h.useMemo(()=>{const d={};for(const u of t)d[u.id]=u;return d},[t]),l=h.useMemo(()=>t.map(d=>({value:d.id,label:d.label,group:ub(d.group)})),[t]);return s.jsx(mu,{value:e.value,options:l,placeholder:e.placeholder||"Select theme…",disabled:e.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:o,className:e.className,triggerClassName:e.triggerClassName,onChange:d=>e.onChange(String(d||"").trim()),renderValue:(d,u)=>{const m=String(u||"").trim(),y=a[m],g=(y==null?void 0:y.label)||m||e.placeholder||"Select theme…",v=(y==null?void 0:y.swatches)||null,w=!m;return s.jsxs("span",{className:"af-theme-value",children:[s.jsx("span",{className:`af-theme-label ${w?"af-theme-label--placeholder":""}`.trim(),children:g}),n&&v?s.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:v.map((b,C)=>s.jsx("span",{className:"af-theme-swatch",style:{background:b}},`${m}:${C}`))}):null]})},renderOption:(d,u)=>{const m=String(d.value||"").trim(),y=a[m],g=(y==null?void 0:y.swatches)||null;return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"af-theme-option-label",children:d.label}),s.jsxs("span",{className:"af-theme-option-right",children:[n&&g?s.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:g.map((v,w)=>s.jsx("span",{className:"af-theme-swatch",style:{background:v}},`${m}:${w}`))}):null,u.selected?s.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function fb(e){const t=e.scales&&e.scales.length?e.scales:w_,n=e.variant||"panel",o=h.useMemo(()=>t.map(a=>({value:a.id,label:a.label})),[t]);return s.jsx(mu,{value:e.value,options:o,placeholder:e.placeholder||"Font size…",disabled:e.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:n,className:e.className,triggerClassName:e.triggerClassName,onChange:a=>e.onChange(String(a||"").trim())})}function mb(e){const t=e.densities&&e.densities.length?e.densities:x_,n=e.variant||"panel",o=h.useMemo(()=>t.map(a=>({value:a.id,label:a.label})),[t]);return s.jsx(mu,{value:e.value,options:o,placeholder:e.placeholder||"Header size…",disabled:e.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:n,className:e.className,triggerClassName:e.triggerClassName,onChange:a=>e.onChange(String(a||"").trim())})}const hb=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function _b(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"})]});case"thumbsUp":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7 10v11"}),s.jsx("path",{d:"M7 10l4.5-8a2 2 0 0 1 3.6 1.5L14 8h5.2a2 2 0 0 1 2 2.4l-1.6 8a2 2 0 0 1-2 1.6H7"})]});case"thumbsDown":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M17 14V3"}),s.jsx("path",{d:"M17 14l-4.5 8a2 2 0 0 1-3.6-1.5L10 16H4.8a2 2 0 0 1-2-2.4l1.6-8a2 2 0 0 1 2-1.6H17"})]});case"thumbsUpFilled":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7 10v11"}),s.jsx("path",{d:"M7 10l4.5-8a2 2 0 0 1 3.6 1.5L14 8h5.2a2 2 0 0 1 2 2.4l-1.6 8a2 2 0 0 1-2 1.6H7z",fill:"currentColor",stroke:"none"})]});case"thumbsDownFilled":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M17 14V3"}),s.jsx("path",{d:"M17 14l-4.5 8a2 2 0 0 1-3.6-1.5L10 16H4.8a2 2 0 0 1-2-2.4l1.6-8a2 2 0 0 1 2-1.6H17z",fill:"currentColor",stroke:"none"})]});case"board":return s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"1.5",y:"2",width:"3.6",height:"12",rx:"1"}),s.jsx("rect",{x:"6.2",y:"2",width:"3.6",height:"8.5",rx:"1"}),s.jsx("rect",{x:"10.9",y:"2",width:"3.6",height:"5.5",rx:"1"})]});case"inbox":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2 9.5 L4 3.5 h8 l2 6"}),s.jsx("path",{d:"M2 9.5 v3 h12 v-3"}),s.jsx("path",{d:"M2 9.5 h3.4 l1 1.6 h3.2 l1-1.6 H14"})]});case"server":return s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2",y:"2.5",width:"12",height:"4.6",rx:"1.2"}),s.jsx("rect",{x:"2",y:"8.9",width:"12",height:"4.6",rx:"1.2"}),s.jsx("circle",{cx:"4.6",cy:"4.8",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"4.6",cy:"11.2",r:"0.8",fill:"currentColor",stroke:"none"})]});case"agent":return s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4.5",width:"10",height:"8",rx:"2"}),s.jsx("path",{d:"M8 4.5V2.2"}),s.jsx("circle",{cx:"8",cy:"1.8",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"5.8",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"10.2",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"})]});case"playCircle":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),s.jsx("path",{d:"M6.5 5.6 L11 8 L6.5 10.4 Z",fill:"currentColor",stroke:"none"})]});case"list":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.5 4h11"}),s.jsx("path",{d:"M2.5 8h11"}),s.jsx("path",{d:"M2.5 12h7"})]});case"gear":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"8",cy:"8",r:"2.2"}),s.jsx("path",{d:"M8 1.6v2"}),s.jsx("path",{d:"M8 12.4v2"}),s.jsx("path",{d:"M1.6 8h2"}),s.jsx("path",{d:"M12.4 8h2"}),s.jsx("path",{d:"M3.5 3.5l1.4 1.4"}),s.jsx("path",{d:"M11.1 11.1l1.4 1.4"}),s.jsx("path",{d:"M12.5 3.5l-1.4 1.4"}),s.jsx("path",{d:"M4.9 11.1l-1.4 1.4"})]});case"sparkle":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z"}),s.jsx("path",{d:"M18.5 15.5l.8 2.2 2.2.8-2.2.8-.8 2.2-.8-2.2-2.2-.8 2.2-.8z"})]});case"contrast":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]});case"logout":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),s.jsx("path",{d:"M16 17l5-5-5-5"}),s.jsx("path",{d:"M21 12H9"})]});default:return null}}function Tn({name:e,size:t=16,className:n,title:o,...a}){const l=o?void 0:!0,d=hb.has(e);return s.jsxs("svg",{width:t,height:t,viewBox:d?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:d?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":l,role:o?"img":"presentation",...a,children:[o?s.jsx("title",{children:o}):null,_b(e)]})}async function b_(e="/api/connection/gateway"){const t=await fetch(e),n=await t.json().catch(()=>null);if(!t.ok){const o=n&&typeof n=="object"&&n.detail?String(n.detail):`HTTP ${t.status}`;throw new Error(o)}return n}async function pb(e,t="/api/connection/gateway"){const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),o=await n.json().catch(()=>null);if(!n.ok){const a=o&&typeof o=="object"&&o.detail?String(o.detail):`HTTP ${n.status}`;throw new Error(a)}return o}async function Wy(e="/api/connection/gateway"){const t=await fetch(e,{method:"DELETE"});if(!t.ok){const n=await t.json().catch(()=>({})),o=n&&typeof n=="object"&&n.detail?String(n.detail):`HTTP ${t.status}`;throw new Error(o)}}function Rh(e){let t=String(e||"").trim();for(let n=0;n<2&&t;n+=1){try{const l=JSON.parse(t);if(typeof l=="string"&&l!==t){t=l.trim();continue}}catch{}const o=t[0],a=t[t.length-1];if(o==='"'&&a==='"'||o==="'"&&a==="'"){t=t.slice(1,-1).trim();continue}break}return t.replace(/\/+$/,"")}function qy(e){var l,d;if(!e)return{label:"Signed out",tone:"warn"};if(!e.has_session)return{label:"Signed out",tone:"warn"};const t=e.gateway||{},n=(l=t.principal)==null?void 0:l.user_id,o=(d=t.principal)==null?void 0:d.runtime_id;if(t.ok&&n)return{label:`Signed in as ${n}${o?` · runtime ${o}`:""}`,tone:"ok"};if(t.ok)return{label:"Signed in",tone:"ok"};const a=t.error||t.detail;return typeof a=="string"&&a.trim()?{label:"Session rejected — sign in again",tone:"err"}:{label:"Sign in required",tone:"err"}}function gb(e){const t=e.connectionPath||"/api/connection/gateway",[n,o]=h.useState(!1),[a,l]=h.useState(!1),[d,u]=h.useState(null),[m,y]=h.useState(!1);h.useEffect(()=>{e.isOpen||y(!1)},[e.isOpen]);const[g,v]=h.useState(e.defaultGatewayUrl||"http://127.0.0.1:8080"),[w,b]=h.useState("admin"),[C,S]=h.useState(""),[R,T]=h.useState(!1),[D,q]=h.useState(!0),[P,K]=h.useState(""),[Q,Z]=h.useState(""),ee=h.useMemo(()=>qy(d),[d]),ue=E=>{var j;u(E),(j=e.onStatusChange)==null||j.call(e,E)},de=h.useRef(!1);if(h.useEffect(()=>{var j;if(!e.isOpen)return;const E=!de.current;if(de.current=!0,E&&e.initialStatus!==void 0&&e.initialStatus!==null){const L=e.initialStatus;ue(L),typeof L.gateway_url=="string"&&L.gateway_url.trim()&&v(Rh(L.gateway_url));const z=(j=L.gateway)==null?void 0:j.principal;z!=null&&z.user_id&&b(z.user_id);return}o(!0),K(""),b_(t).then(L=>{var te;ue(L),typeof L.gateway_url=="string"&&L.gateway_url.trim()&&v(Rh(L.gateway_url));const z=(te=L.gateway)==null?void 0:te.principal;z!=null&&z.user_id&&b(z.user_id)}).catch(L=>K(`Failed to load connection status: ${String((L==null?void 0:L.message)||L)}`)).finally(()=>o(!1))},[e.isOpen]),h.useEffect(()=>{if(!e.isOpen)return;const E=j=>{j.key==="Escape"&&!j.defaultPrevented&&!e.blocking&&(j.preventDefault(),e.onClose())};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e.isOpen,e.blocking,e.onClose]),!e.isOpen||m)return null;const pe=async()=>{l(!0),K(""),Z("");try{const E=Rh(g);v(E);const j=await pb({gateway_url:E,gateway_user_id:w,gateway_token:C,persist:D},t);ue(j),S(""),y(!0),e.onClose()}catch(E){K(String((E==null?void 0:E.message)||E))}finally{l(!1)}},F=async()=>{l(!0),K(""),Z("");try{await Wy(t),S("");const E=await b_(t).catch(()=>null);ue(E),Z("Signed out. This browser no longer holds a gateway session.")}catch(E){K(String((E==null?void 0:E.message)||E))}finally{l(!1)}};return s.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:E=>{!e.blocking&&E.target===E.currentTarget&&e.onClose()},children:s.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:s.jsx(cb,{kicker:`${e.appName||"AbstractFramework"} connection`,title:"Connect this browser to AbstractGateway",description:"Sign in with a Gateway user token. The app exchanges it for an HTTP-only browser session and never stores the raw token.",statusLabel:ee.label,statusTone:ee.tone,tokenSourceLabel:d!=null&&d.has_session?"token: browser session":"token: missing",showGatewayUrl:!0,gatewayUrl:g,onGatewayUrlChange:E=>v(E),userId:w,onUserIdChange:b,token:C,tokenPlaceholder:d!=null&&d.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:R,onTokenChange:S,onShowTokenChange:T,remember:D,rememberLabel:"Keep this browser signed in",onRememberChange:q,loading:n,submitting:a,submittingLabel:"Signing in...",showClose:!e.blocking,onClose:e.onClose,showSignOut:!e.blocking&&!!(d!=null&&d.has_session),onSignOut:F,error:P,message:Q,onSubmit:pe})})})}function yb(e){return!!(e&&e.ok===!0&&e.has_session===!0)}function vb(e){const t=e||{},n=t.connectionPath||"/api/connection/gateway",o=t.variant||"dismissable",a=h.useRef(t.onStatusChange);a.current=t.onStatusChange;const l=h.useRef(o);l.current=o;const d=h.useRef(!!t.autoOpenMidSession);d.current=!!t.autoOpenMidSession;const[u,m]=h.useState(null),[y,g]=h.useState("loading"),[v,w]=h.useState(!1),b=h.useRef(!1),C=h.useRef(!1),S=h.useRef("loading"),R=h.useRef("none"),T=h.useRef(!1),D=h.useRef(0),q=h.useCallback(j=>{var z;D.current+=1,m(j),(z=a.current)==null||z.call(a,j);const L=yb(j);if(L)g("connected"),S.current="connected",b.current=!1,R.current="none",C.current||w(!1);else if(j!==null){const te=S.current;g("disconnected"),S.current="disconnected",te!=="disconnected"&&(R.current=T.current?"signout":te==="connected"?"mid":"boot");const I=l.current==="blocking"||R.current!=="mid"||d.current;!b.current&&I&&w(!0)}j!==null&&(C.current=L)},[]),P=h.useCallback(async()=>{const j=D.current;try{const L=await b_(n);if(D.current!==j)return;q(L)}catch{if(D.current!==j)return;q(null)}},[n,q]),[K,Q]=h.useState(!1),[Z,ee]=h.useState(null),ue=h.useCallback(async()=>{Q(!0),ee(null),D.current+=1;let j=null;try{await Wy(n)}catch(L){j=String((L==null?void 0:L.message)||L||"Sign-out request failed")}T.current=!0;try{await P()}finally{T.current=!1}ee(j),Q(!1)},[n,P]),de=h.useRef(!1);h.useEffect(()=>{de.current||(de.current=!0,P())},[P]);const pe=h.useCallback(()=>{w(!0)},[]),F=h.useCallback(()=>{const j=S.current;o==="blocking"&&j==="disconnected"||(j==="disconnected"&&(b.current=!0),w(!1))},[o]),E=h.useMemo(()=>({isOpen:v,onClose:F,blocking:o==="blocking"&&y!=="connected",appName:t.appName,connectionPath:n,defaultGatewayUrl:t.defaultGatewayUrl,initialStatus:u,onStatusChange:q}),[v,F,o,y,t.appName,n,t.defaultGatewayUrl,u,q]);return{status:u,phase:y,connected:y==="connected",modalOpen:v,signingOut:K,signOutError:Z,openModal:pe,refresh:P,signOut:ue,modalProps:E}}function wb(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`steer-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function xb(){const e=[];try{if(typeof document>"u")return e;for(const t of String(document.cookie||"").split(";")){const n=t.indexOf("=");if(n<0||!t.slice(0,n).trim().endsWith("_gateway_csrf"))continue;const a=t.slice(n+1).trim();let l=a;try{l=decodeURIComponent(a)}catch{}l&&!e.includes(l)&&e.push(l)}}catch{}return e}async function bb(e){const t=e.commandsPath||"/api/gateway/commands",n=wb(),o=JSON.stringify({command_id:n,run_id:e.runId,type:"inject_guidance",payload:{guidance:e.guidance}}),a=e.csrfToken!==void 0?[e.csrfToken]:xb();a.length===0&&a.push("");let l=null;for(const d of a){const u=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",...d?{"x-abstract-csrf":d}:{}},body:o}),m=await u.json().catch(()=>null);if(!u.ok){const y=m&&typeof m=="object"&&m.detail?String(m.detail):`HTTP ${u.status}`;if(l=new Error(y),u.status===403&&m&&typeof m=="object"&&m.reason_code==="csrf_required")continue;throw l}return{accepted:!!(m!=null&&m.accepted),duplicate:!!(m!=null&&m.duplicate),seq:Number((m==null?void 0:m.seq)??0)}}throw l||new Error("Steer submit failed")}function Sb(e){const[t,n]=h.useState(""),[o,a]=h.useState({kind:"idle"}),l=h.useRef(!1),d=h.useRef(0);h.useEffect(()=>{d.current+=1,a({kind:"idle"})},[e.runId]);const u=!e.disabled&&t.trim().length>0&&o.kind!=="sending",m=h.useMemo(()=>e.parked?"Run is waiting — your guidance delivers at its next wake (steers do not wake runs).":"Delivers at the run's next loop boundary.",[e.parked]),y=async()=>{var b;const v=t.trim();if(!v||l.current||e.disabled)return;l.current=!0;const w=d.current;a({kind:"sending"});try{const C=e.submit?await e.submit(e.runId,v):await bb({runId:e.runId,guidance:v,commandsPath:e.commandsPath});if(d.current!==w)return;if(!C.accepted&&!C.duplicate){a({kind:"error",detail:"The gateway did not accept this steer (accepted=false)."});return}a({kind:"queued",seq:C.seq,duplicate:C.duplicate}),n(""),(b=e.onSent)==null||b.call(e,{...C,guidance:v})}catch(C){d.current===w&&a({kind:"error",detail:String((C==null?void 0:C.message)||C)})}finally{l.current=!1}},g=v=>{v.key==="Enter"&&(v.metaKey||v.ctrlKey)&&(v.preventDefault(),y())};return s.jsxs("div",{className:`af-steer${e.className?` ${e.className}`:""}`,children:[s.jsxs("div",{className:"af-steer__row",children:[s.jsx("textarea",{className:"af-steer__input",value:t,rows:2,placeholder:e.placeholder||"Steer this run…","aria-label":e.ariaLabel||"Steer message",disabled:e.disabled||o.kind==="sending",onChange:v=>{n(v.target.value),(o.kind==="error"||o.kind==="queued")&&a({kind:"idle"})},onKeyDown:g}),s.jsx("button",{type:"button",className:"af-steer__send",disabled:!u,onClick:()=>void y(),title:"Send guidance (Cmd/Ctrl+Enter)",children:o.kind==="sending"?"Sending…":"Steer"})]}),s.jsx("div",{className:"af-steer__status",role:"status","aria-live":"polite",children:o.kind==="queued"?s.jsxs("span",{className:"af-steer__ok",children:[o.duplicate?`Already queued (seq ${o.seq}).`:`Queued (seq ${o.seq}).`," ",m," ","Watch for the steer_seen ack in the run ledger."]}):o.kind==="error"?s.jsx("span",{className:"af-steer__err",children:o.detail}):s.jsx("span",{className:"af-steer__hint",children:m})})]})}function jb(e){const t=e.closeOnEscape!==!1,n=h.useRef(null);return h.useEffect(()=>{if(!e.open||!t)return;const o=a=>{a.key!=="Escape"||a.defaultPrevented||(a.preventDefault(),e.onClose())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e.open,t,e.onClose]),h.useEffect(()=>{const o=n.current;o&&(e.open?o.removeAttribute("inert"):o.setAttribute("inert",""))},[e.open]),s.jsxs("div",{ref:n,className:`af-drawer${e.open?" af-drawer--open":""}${e.className?` ${e.className}`:""}`,style:{width:e.width||420,top:e.topOffset||0,display:e.open?void 0:"none"},role:"complementary","aria-label":e.label,"aria-hidden":e.open?void 0:!0,children:[e.title!==void 0?s.jsxs("div",{className:"af-drawer__header",children:[s.jsx("div",{className:"af-drawer__title",children:e.title}),s.jsxs("div",{className:"af-drawer__header-actions",children:[e.headerActions,s.jsx("button",{type:"button",className:"af-drawer__close","aria-label":"Close panel",onClick:e.onClose,children:"×"})]})]}):null,s.jsx("div",{className:"af-drawer__body",children:e.children})]})}const kb={name:"AbstractFramework",website:"https://abstractframework.ai",author:"Laurent-Philippe Albou, PhD",years:"2023-2026",copyright:"© 2023-2026 Laurent-Philippe Albou, PhD. Released under the MIT License.",contact_email:"contact@abstractframework.ai"},Nb={abstractframework:{name:"AbstractFramework",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractFramework",docs:"https://github.com/lpalbou/AbstractFramework/tree/main/docs",issues:"https://github.com/lpalbou/AbstractFramework/issues",feedback:"https://github.com/lpalbou/AbstractFramework/issues/new?labels=feedback"},abstractgateway:{name:"AbstractGateway",website:"https://abstractframework.ai/gateway",repo:"https://github.com/lpalbou/AbstractGateway",docs:"https://www.lpalbou.info/AbstractGateway/",issues:"https://github.com/lpalbou/AbstractGateway/issues",feedback:"https://github.com/lpalbou/AbstractGateway/issues/new?labels=feedback"},abstractcode:{name:"AbstractCode",website:"https://abstractframework.ai/code",repo:"https://github.com/lpalbou/AbstractCode",docs:"https://github.com/lpalbou/AbstractCode/tree/main/docs",issues:"https://github.com/lpalbou/AbstractCode/issues",feedback:"https://github.com/lpalbou/AbstractCode/issues/new?labels=feedback"},abstractassistant:{name:"AbstractAssistant",website:"https://abstractframework.ai/assistant",repo:"https://github.com/lpalbou/AbstractAssistant",docs:"https://github.com/lpalbou/AbstractAssistant/blob/main/docs/README.md",issues:"https://github.com/lpalbou/AbstractAssistant/issues",feedback:"https://github.com/lpalbou/AbstractAssistant/issues/new?labels=feedback"},abstractflow:{name:"AbstractFlow",website:"https://abstractframework.ai/flow",repo:"https://github.com/lpalbou/AbstractFlow",docs:"https://github.com/lpalbou/AbstractFlow#readme",issues:"https://github.com/lpalbou/AbstractFlow/issues",feedback:"https://github.com/lpalbou/AbstractFlow/issues/new?labels=feedback"},abstractcontinuum:{name:"AbstractContinuum",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractContinuum",docs:"https://github.com/lpalbou/AbstractContinuum/tree/main/docs",issues:"https://github.com/lpalbou/AbstractContinuum/issues",feedback:"https://github.com/lpalbou/AbstractContinuum/issues/new?labels=feedback"},abstractentity:{name:"AbstractEntity",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractEntity",docs:"https://github.com/lpalbou/AbstractEntity/tree/main/docs",issues:"https://github.com/lpalbou/AbstractEntity/issues",feedback:"https://github.com/lpalbou/AbstractEntity/issues/new?labels=feedback"},abstractobserver:{name:"AbstractObserver",website:"https://abstractframework.ai/observer",repo:"https://github.com/lpalbou/AbstractObserver",docs:"https://github.com/lpalbou/AbstractObserver#readme",issues:"https://github.com/lpalbou/AbstractObserver/issues",feedback:"https://github.com/lpalbou/AbstractObserver/issues/new?labels=feedback"},abstractcore:{name:"AbstractCore",website:"https://www.abstractcore.ai",repo:"https://github.com/lpalbou/AbstractCore",docs:"https://github.com/lpalbou/AbstractCore/tree/main/docs",issues:"https://github.com/lpalbou/AbstractCore/issues",feedback:"https://github.com/lpalbou/AbstractCore/issues/new?labels=feedback"},abstractuic:{name:"AbstractUIC",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractUIC",docs:"https://github.com/lpalbou/AbstractUIC/tree/main/docs",issues:"https://github.com/lpalbou/AbstractUIC/issues",feedback:"https://github.com/lpalbou/AbstractUIC/issues/new?labels=feedback"}},Cb={framework:kb,apps:Nb},$m=Cb;function Eb(){return Object.keys($m.apps).sort()}function $b(e,t){const n=Object.prototype.hasOwnProperty.call($m.apps,e)?$m.apps[e]:void 0;if(!n)throw new Error(`appIdentity: unknown application id "${e}" (known: ${Eb().join(", ")})`);return{id:e,name:n.name,version:t,website:n.website,repo:n.repo,docs:n.docs,issues:n.issues,feedback:n.feedback}}function Mb(e,t){const n=$m.framework,o=[["Application",`${e.name} ${e.version}`],["Part of",`${n.name} — ${n.website}`],["Author",`${n.author} (${n.years})`],["Copyright",n.copyright],["Website",e.website],["Source",e.repo],["Documentation",e.docs],["Report an issue",e.issues],["Give feedback",e.feedback],["Contact",n.contact_email]];for(const[a,l]of t||[])o.push([String(a),String(l)]);return o}function Lh(e){return typeof e=="string"?e.trim():""}function Gp(e,t){if(t!=null)return[["Gateway",`unavailable (${String(t).trim()||"unknown error"})`]];const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},o=Lh(n.abstractgateway);if(!o)return[["Gateway","unavailable (the gateway did not report its version)"]];const a=Lh(n.abstractframework),l=[["Gateway",`AbstractGateway ${o}`],["Gateway framework",a?`AbstractFramework ${a}`:"not installed on the gateway host"]],d=n.packages&&typeof n.packages=="object"&&!Array.isArray(n.packages)?n.packages:{},u=Object.keys(d).filter(m=>m!=="abstractgateway"&&m!=="abstractframework").sort((m,y)=>m<y?-1:m>y?1:0);for(const m of u){const y=Lh(d[m]);y&&l.push([`Gateway package ${m}`,y])}return l}const Ab='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function Tb(e,t,n){if(e.key!=="Tab"||!t)return;const o=Array.from(t.querySelectorAll(Ab));if(o.length===0){e.preventDefault();return}const a=o[0],l=o[o.length-1],d=!!n&&t.contains(n);e.shiftKey?(n===a||!d)&&(e.preventDefault(),l.focus()):(n===l||!d)&&(e.preventDefault(),a.focus())}const Rb=/https?:\/\/[^\s<>"]+/g;function Lb(e,t){if(e==="Contact")return[{text:t,href:`mailto:${t}`}];const n=[];let o=0;for(const a of t.matchAll(Rb)){const l=a.index??0;l>o&&n.push({text:t.slice(o,l)}),n.push({text:a[0],href:a[0]}),o=l+a[0].length}return(o<t.length||n.length===0)&&n.push({text:t.slice(o)}),n}function Pb({label:e,value:t}){return s.jsx("span",{children:Lb(e,t).map((n,o)=>n.href===void 0?s.jsx(ye.Fragment,{children:n.text},o):n.href.startsWith("mailto:")?s.jsx("a",{className:"af-about__link",href:n.href,children:n.text},o):s.jsx("a",{className:"af-about__link",href:n.href,target:"_blank",rel:"noopener noreferrer",children:n.text},o))})}function Ob(e){const t=h.useRef(null),n=h.useRef(null),o=h.useId(),a=h.useRef(e.onClose);if(a.current=e.onClose,h.useEffect(()=>{var y;if(!e.open)return;const u=document.activeElement;(y=t.current)==null||y.focus();const m=g=>{if(!g.defaultPrevented){if(g.key==="Escape"){g.preventDefault(),a.current();return}Tb(g,n.current,document.activeElement)}};return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m),u&&typeof u.focus=="function"&&u.focus()}},[e.open]),!e.open)return null;const l=e.title||`About ${e.identity.name}`,d=Mb(e.identity,e.extraRows);return s.jsx("div",{className:"af-appearance-overlay af-about-overlay",onClick:e.onClose,role:"presentation",children:s.jsxs("div",{ref:n,className:"af-appearance af-about",role:"dialog","aria-modal":"true","aria-labelledby":o,onClick:u=>u.stopPropagation(),children:[s.jsx("div",{className:"af-appearance__title",id:o,children:l}),s.jsx("dl",{className:"af-about__rows",children:d.map(([u,m],y)=>s.jsxs("div",{className:"af-about__row",children:[s.jsx("dt",{className:"af-about__label",children:u}),s.jsx("dd",{className:"af-about__value",children:s.jsx(Pb,{label:u,value:m})})]},`${y}:${u}`))}),s.jsx("div",{className:"af-appearance__actions",children:s.jsx("button",{ref:t,type:"button",className:"af-appearance__close",onClick:e.onClose,children:"Close"})})]})})}function zb(e){const{connection:t}=e,n=t.phase,o=t.signingOut===!0,[a,l]=h.useState(!1),d=e.about,u=o?"Signing out…":n==="connected"?"Disconnect":n==="loading"?"Connecting…":"Connect",m=n==="connected"?"Disconnect from gateway":n==="loading"?"Checking gateway session…":"Connect to gateway";return s.jsxs("div",{className:`af-topbar${e.className?` ${e.className}`:""}`,role:"group","aria-label":"App actions",children:[e.assistant?s.jsx("button",{type:"button",className:`af-topbar__btn${e.assistant.open?" is-active":""}`,"aria-pressed":e.assistant.open,"aria-label":e.assistant.label||"Open assistant",title:e.assistant.label||"Assistant",onClick:e.assistant.onToggle,children:s.jsx(Tn,{name:"sparkle",size:16})}):null,e.appearance?s.jsx("button",{type:"button",className:"af-topbar__btn","aria-label":e.appearance.label||"Appearance (theme and typography)",title:e.appearance.label||"Appearance",onClick:e.appearance.onOpen,children:s.jsx(Tn,{name:"contrast",size:16})}):null,d?s.jsx("button",{type:"button",className:"af-topbar__btn af-topbar__btn--about","aria-label":d.label||`About ${d.identity.name}`,title:d.label||"About","aria-haspopup":"dialog",onClick:()=>{var y;l(!0),(y=d.onOpen)==null||y.call(d)},children:s.jsx(Tn,{name:"info",size:16})}):null,e.extraActions,s.jsxs("button",{type:"button",className:`af-topbar__pill af-topbar__pill--${n}`,onClick:n==="connected"?t.onDisconnect:t.onConnect,disabled:o,title:m,"aria-label":m,children:[s.jsx("span",{className:`af-topbar__dot af-topbar__dot--${n}`,"aria-hidden":"true"}),s.jsx("span",{className:"af-topbar__pill-label",children:u})]}),d?s.jsx(Ob,{open:a,onClose:()=>l(!1),identity:d.identity,extraRows:d.extraRows}):null]})}const xm={theme:"dark",font_scale:"md",header_density:"standard"};function Ib(e){const t=e&&typeof e=="object"?e:{};return{theme:typeof t.theme=="string"&&t.theme?t.theme:xm.theme,font_scale:typeof t.font_scale=="string"&&t.font_scale?t.font_scale:xm.font_scale,header_density:typeof t.header_density=="string"&&t.header_density?t.header_density:xm.header_density}}function Db(e){return`af_appearance_${e}_v1`}function Fb(e,t){const n=Db(e),o=h.useMemo(()=>({...xm,...(t==null?void 0:t.defaults)||{}}),[JSON.stringify((t==null?void 0:t.defaults)||{})]),[a,l]=h.useState(()=>{let d=o;try{const u=localStorage.getItem(n)??(t!=null&&t.legacyKey?localStorage.getItem(t.legacyKey):null);u&&(d=Ib({...o,...JSON.parse(u)}))}catch{}try{Wp(d.theme),qp({font_scale:d.font_scale,header_density:d.header_density})}catch{}return d});return h.useEffect(()=>{Wp(a.theme),qp({font_scale:a.font_scale,header_density:a.header_density});try{localStorage.setItem(n,JSON.stringify(a))}catch{}},[n,a]),[a,l]}function Bb(e){return h.useEffect(()=>{if(!e.open)return;const t=n=>{n.key!=="Escape"||n.defaultPrevented||(n.preventDefault(),e.onClose())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e.open,e.onClose]),e.open?s.jsx("div",{className:"af-appearance-overlay",onClick:e.onClose,role:"presentation",children:s.jsxs("div",{className:"af-appearance",role:"dialog","aria-modal":"true","aria-label":e.title||"Appearance",onClick:t=>t.stopPropagation(),children:[s.jsx("div",{className:"af-appearance__title",children:e.title||"Appearance"}),s.jsx("div",{className:"af-appearance__note",children:e.note||"Stored locally in this browser, per app."}),s.jsxs("div",{className:"af-appearance__grid",children:[s.jsx("label",{className:"af-appearance__label",children:"Theme"}),s.jsx(db,{value:e.value.theme,onChange:t=>e.onChange({...e.value,theme:t})}),s.jsx("label",{className:"af-appearance__label",children:"Font size"}),s.jsx(fb,{value:e.value.font_scale,onChange:t=>e.onChange({...e.value,font_scale:t})}),s.jsx("label",{className:"af-appearance__label",children:"Header size"}),s.jsx(mb,{value:e.value.header_density,onChange:t=>e.onChange({...e.value,header_density:t})})]}),s.jsx("div",{className:"af-appearance__actions",children:s.jsx("button",{type:"button",className:"af-appearance__close",onClick:e.onClose,children:"Close"})})]})}):null}const Ub={diary:"var(--accent)",question:"#e7b45a",dream:"#c084dd",interest:"#7bd88a",lesson:"#6ea8d8",world_model:"#5eead4"};function Kp(e){const t=String(e||"");return t.length>14?`${t.slice(0,10)}…${t.slice(-4)}`:t}function Ph(e){const[t,n]=h.useState(!1),[o,a]=h.useState(null),l=h.useRef(!1),d=typeof e.entryId=="string"&&e.entryId.trim()?e.entryId.trim():null,u=e.kind&&Ub[e.kind]||"var(--text-muted)",m=h.useCallback(async()=>{if(!(!d||!e.onOpen||l.current)){l.current=!0,n(!0),a(null);try{await e.onOpen(d)}catch(y){a(String((y==null?void 0:y.message)||y||"could not open"))}finally{l.current=!1,n(!1)}}},[d,e.onOpen]);return!d||!e.onOpen?s.jsxs("span",{className:["af-memory-hint","af-memory-hint--text",e.className||""].filter(Boolean).join(" "),title:e.title,children:[s.jsx("span",{className:"af-memory-hint__dot",style:{background:u},"aria-hidden":"true"}),s.jsx("span",{className:"af-memory-hint__label",children:e.label}),d&&e.showId!==!1?s.jsx("code",{className:"af-memory-hint__id",children:Kp(d)}):null]}):s.jsxs("span",{className:["af-memory-hint",e.className||""].filter(Boolean).join(" "),children:[s.jsxs("button",{type:"button",className:"af-memory-hint__btn",onClick:()=>void m(),disabled:t,title:e.title||(e.command?e.command:`open ${d}`),"aria-label":`Open ${e.kind||"memory"} entry: ${e.label}`,children:[s.jsx("span",{className:"af-memory-hint__dot",style:{background:u},"aria-hidden":"true"}),s.jsx("span",{className:"af-memory-hint__label",children:e.label}),e.showId!==!1?s.jsx("code",{className:"af-memory-hint__id",children:Kp(d)}):null,s.jsx("span",{className:"af-memory-hint__act","aria-hidden":"true",children:t?"…":"↗"})]}),e.command?s.jsx("code",{className:"af-memory-hint__cmd",children:e.command}):null,o?s.jsx("span",{className:"af-memory-hint__err",role:"alert",children:o}):null]})}function Vy(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function Hb(e){const t=Vy(e);if(!t||typeof t!="object"||Array.isArray(t))return{label:"input",value:t==null?"":String(t)};const n=Object.entries(t),a=["command","query","url","file_path","path","pattern","name"].map(l=>n.find(([d])=>d===l)).find(Boolean)||n[0];return a?{label:a[0].replace(/_/g," "),value:typeof a[1]=="string"?a[1]:JSON.stringify(a[1])??""}:{label:"",value:""}}function Gy({tool:e,showCopy:t=!0}){const[n,o]=h.useState(!1),a=Vy(e.arguments),l=Hb(e.arguments),d=["file path","path"].includes(l.label)&&l.value.length>60?`${l.value.split(/[\\/]/).pop()} · ${l.value.slice(0,24)}…`:l.value,u=e.error&&/^File ['"].+['"] does not exist\.?$/.test(e.error)?"File not found. Expand for the exact path.":e.error&&e.error.length>180?`${e.error.slice(0,100)}…${e.error.slice(-70)}`:e.error,m={running:"Running",waiting:"Approval needed",completed:"Done",failed:"Failed"},y=e.startedAt&&e.endedAt?Date.parse(e.endedAt)-Date.parse(e.startedAt):NaN,g=a&&typeof a=="object"&&!Array.isArray(a)?Object.entries(a):null;return s.jsxs("details",{className:`pc-tool-activity pc-tool-activity--${e.status}`,children:[s.jsxs("summary",{className:"pc-tool-activity__summary",children:[s.jsx("span",{className:"pc-tool-activity__state-icon","aria-hidden":"true",children:s.jsx(Tn,{name:e.status==="completed"?"check":e.status==="failed"?"x":e.status==="waiting"?"warning":"loader",size:15})}),s.jsx("strong",{children:e.name}),s.jsx("span",{className:"pc-tool-activity__preview",title:l.value,children:l.value?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"pc-tool-activity__key",children:l.label}),d]}):"No parameters"}),s.jsx("span",{className:"pc-tool-activity__status",children:m[e.status]}),Number.isFinite(y)&&y>=0?s.jsxs("span",{className:"pc-tool-activity__duration",children:[(y/1e3).toFixed(1),"s"]}):null,s.jsx("span",{className:"pc-tool-activity__chevron","aria-hidden":"true",children:s.jsx(Tn,{name:"chevronRight",size:13})}),e.error?s.jsx("span",{className:"pc-tool-activity__error",title:e.error,children:u}):null]}),s.jsxs("div",{className:"pc-tool-activity__detail",children:[e.error?s.jsxs(s.Fragment,{children:[s.jsx("h4",{children:"Error"}),s.jsx("pre",{className:"pc-tool-activity__output",children:e.error})]}):null,s.jsxs("div",{className:"pc-tool-activity__detail-heading",children:[s.jsx("h4",{children:"Parameters"}),t?s.jsxs("button",{type:"button",onClick:async()=>o(await nc(JSON.stringify(e,null,2))),children:[s.jsx(Tn,{name:"copy",size:13}),n?"Copied":"Copy details"]}):null]}),g?s.jsx("dl",{className:"pc-tool-activity__parameters",children:g.map(([v,w])=>s.jsxs(ye.Fragment,{children:[s.jsx("dt",{children:v}),s.jsx("dd",{children:w&&typeof w=="object"?s.jsx(os,{value:w}):s.jsx("code",{children:typeof w=="string"?w:JSON.stringify(w)})})]},v))}):e.arguments===void 0?s.jsx("p",{children:"Arguments are unavailable in this ledger."}):s.jsx(os,{value:a}),e.output!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("h4",{children:"Result"}),typeof e.output=="string"?s.jsx("pre",{className:"pc-tool-activity__output",children:e.output}):s.jsx("div",{className:"pc-tool-activity__output",children:s.jsx(os,{value:e.output})})]}):null]})]})}function Wb({tools:e,showCopy:t}){const n=o=>e.filter(a=>a.status===o).length;return s.jsxs("section",{className:"pc-tool-group","aria-label":"Tool activity",children:[s.jsxs("div",{className:"pc-tool-group__heading",children:[s.jsx(Tn,{name:"terminal",size:14}),s.jsx("strong",{children:"Tools"}),s.jsxs("span",{children:[e.length," ",e.length===1?"call":"calls"]}),s.jsx("div",{}),n("running")?s.jsxs("span",{className:"pc-tool-group__running",children:[n("running")," running"]}):null,n("waiting")?s.jsxs("span",{className:"pc-tool-group__waiting",children:[n("waiting")," need approval"]}):null,n("failed")?s.jsxs("span",{className:"pc-tool-group__failed",children:[n("failed")," failed"]}):null,n("completed")?s.jsxs("span",{className:"pc-tool-group__completed",children:[n("completed")," done"]}):null]}),e.map(o=>s.jsx(Gy,{tool:o,showCopy:t},o.id))]})}const Or="not reported",rs=e=>e===void 0?Or:Math.round(e).toLocaleString(),Cs=e=>{if(e===void 0)return Or;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const t=Math.round(e/1e3);return`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`},Ky=e=>e===void 0?Or:`${Math.round(e).toLocaleString()} tok/s`,qb=(e,t)=>t>0?`${Math.round(e/t*100)}%`:"",Ql=(e,t,n=`${t}s`)=>`${e.toLocaleString()} ${e===1?t:n}`,Vb=e=>{const t=e.split("#")[0].replace(/\/+$/,"");return t.slice(t.lastIndexOf("/")+1)||e};function Gb(e){const t=new Map;for(const n of e)n&&t.set(n,(t.get(n)||0)+1);return[...t].map(([n,o])=>o>1?`${n} ×${o}`:n).join(" · ")}function Mm(e){const t=[],n=(e.models||[]).map(Vb),o=e.providers||[];return(n.length||o.length)&&t.push([n.join(", ")||"model not reported",o.join(", ")].filter(Boolean).join(" · ")),t.push("From the run ledger; summed across this turn and its child runs."),t}function Kb(e){const t=e.modelCalls||[],n=[],o=[{label:"Input",value:rs(e.inputTokens)},{label:"Output",value:rs(e.outputTokens)}];if(e.reasoningTokens!==void 0&&o.push({label:"Reasoning",value:rs(e.reasoningTokens),hint:"part of output"}),o.push({label:"Total",value:rs(e.totalTokens)}),n.push({heading:`Usage · ${Ql(e.llmCalls,"model call")}`,rows:o}),e.measuredCacheCalls){const l=e.cachedTokens||0,d=e.fedTokens||0,u=[{label:"Reused from cache",value:`${rs(l)}${l+d?` (${qb(l,l+d)})`:""}`},{label:"Newly processed",value:rs(e.fedTokens)},{label:"Outcome",value:Gb(t.map(m=>m.cacheOutcome))||(e.cacheOutcomes||[]).join(" · ")||Or},{label:"Backend",value:(e.cacheBackends||[]).join(", ")||Or}];e.measuredCacheCalls!==e.llmCalls&&u.push({label:"Measured on",value:`${e.measuredCacheCalls} of ${e.llmCalls} calls`}),n.push({heading:"Prompt cache",rows:u})}else e.llmCalls&&n.push({heading:"Prompt cache",rows:[{label:"Cache reuse",value:Or}]});const a=t.filter(l=>l.inputTokens!==void 0);return a.length===1&&t.length===1?n.push({heading:"Context",rows:[{label:"Prompt size",value:`${rs(a[0].inputTokens)} tokens`}]}):a.length>1&&n.push({heading:"Context",rows:[{label:"First → last call",value:`${rs(a[0].inputTokens)} → ${rs(a[a.length-1].inputTokens)} tokens`}],note:"Each call re-sends the conversation, so the input total counts the context once per call."}),t.length>1&&n.push({heading:"Per call",table:{columns:["#","Input","Cached","New","Output","Cache"],rows:t.map((l,d)=>[String(d+1),rs(l.inputTokens),l.cachedTokens===void 0?"—":rs(l.cachedTokens),l.fedTokens===void 0?"—":rs(l.fedTokens),rs(l.outputTokens),l.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:e.totalTokens===void 0?Or:`${e.totalTokens.toLocaleString()} total`,sections:n,footer:Mm(e)}}function sm(e,t,n,o){if(e===void 0)return Or;const a=[Cs(e)];return t!==void 0&&a.push(`${t.toLocaleString()} ${o}${n!==void 0?` at ${Ky(n)}`:""}`),a.join(" · ")}function Yb(e){var y,g,v;const t=e.modelCalls||[],n=[],o=e.durationMs,a=[{label:"Wall clock",value:Cs(o)}];if(a.push({label:"Model",value:e.genTimeMs===void 0?Or:`${Cs(e.genTimeMs)} · ${Ql(e.timedCalls||0,"call")}${e.timedCalls!==e.llmCalls?` (of ${e.llmCalls})`:""}`}),a.push({label:"Tools",value:e.toolTimeMs!==void 0?`${Cs(e.toolTimeMs)} · ${Ql(e.toolBatches||0,"batch","batches")}`:e.toolCalls?Or:"none",hint:e.toolTimeIncludesApproval?"includes approval wait":void 0}),o!==void 0&&e.genTimeMs!==void 0){const w=o-e.genTimeMs-(e.toolTimeMs||0);a.push({label:"Orchestration",value:w>=0?Cs(w):"overlaps (parallel runs)",hint:"wall − model − tools: routing, hand-offs, model load"})}n.push({heading:"Turn",rows:a});const l=[],d=e.ttftCalls||0,u=e.promptPhaseCalls||0;e.promptPhaseMs!==void 0?l.push({label:d&&d===u?"Prefill (TTFT)":"Prefill",value:sm(e.promptPhaseMs,e.promptPhaseNewTokens,e.promptPhaseTokensPerSecond,"new tok"),hint:d===u?"measured time to first token":d?`TTFT measured on ${d} of ${u}; rest from provider rate`:"derived: prompt ÷ provider rate"}):e.prefillMs!==void 0&&e.prefillNewTokensPerSecond!==void 0?l.push({label:"Prefill",value:sm(e.prefillMs,e.prefillNewTokens,e.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):e.prefillMs!==void 0?l.push({label:"Prefill",value:`${Cs(e.prefillMs)}${e.promptTokensPerSecond!==void 0?` at ${Ky(e.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):l.push({label:"Prefill",value:Or}),e.cachedTokens&&(e.promptPhaseMs??e.prefillMs)!==void 0&&l.push({label:"Restored",value:`${e.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),l.push({label:"Generation",value:e.generationPhaseMs!==void 0?sm(e.generationPhaseMs,e.generationPhaseTokens,e.generationPhaseTokensPerSecond,"tok"):sm(e.decodeMs,e.outputTokens,e.generationTokensPerSecond,"tok")}),e.measuredSpeedCalls&&e.measuredSpeedCalls!==e.llmCalls&&l.push({label:"Speeds from",value:`${e.measuredSpeedCalls} of ${e.llmCalls} calls`}),n.push({heading:"Model",rows:l});const m=e.speculation;if(m){const w=(m.draftKinds||[]).map(C=>C.toUpperCase()).join(", "),b=[{label:"Mode",value:`${m.used?"on":"off"}${w?` · ${w}`:""}${(y=m.modes)!=null&&y.length?` (${m.modes.join(", ")})`:""}`,hint:m.calls!==e.llmCalls||m.used!==m.calls?`used on ${m.used} of ${e.llmCalls} calls`:void 0},{label:"Acceptance",value:m.acceptanceRate===void 0?Or:`${Math.round(m.acceptanceRate*100)}% · ${rs(m.acceptedTokens)} of ${rs(m.draftedTokens)} drafted`}];((g=m.draftLengths)!=null&&g.length||m.rounds!==void 0)&&b.push({label:"Draft length",value:`${(v=m.draftLengths)!=null&&v.length?`${m.draftLengths.join("/")} tok/round`:Or}${m.rounds!==void 0?` · ${m.rounds.toLocaleString()} rounds`:""}`}),n.push({heading:"Speculation",rows:b})}return e.slowestToolBatch&&n.push({heading:"Tools",rows:[{label:"Total",value:`${Cs(e.toolTimeMs)} · ${Ql(e.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${Cs(e.slowestToolBatch.ms)} · ${Yy(e.slowestToolBatch)}`}],note:e.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),t.length>1&&n.push({heading:"Per call",table:{columns:["#","Prefill","New tok/s","Gen","Gen tok/s","Cache"],rows:t.map((w,b)=>[String(b+1),w.promptMs===void 0?"—":`${Cs(w.promptMs)}${w.promptSource==="rate"?"*":""}`,w.promptNewTokensPerSecond===void 0?"—":Math.round(w.promptNewTokensPerSecond).toLocaleString(),w.generationMs===void 0?"—":Cs(w.generationMs),w.generationTokensPerSecond===void 0?"—":Math.round(w.generationTokensPerSecond).toLocaleString(),w.cacheOutcome||"—"])},note:t.some(w=>w.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:o===void 0?Or:`${Cs(o)} wall clock`,sections:n,footer:Mm(e)}}function Yy(e){return e.tools.length===1?`${e.tools[0]} ×${e.calls}`:`${Ql(e.calls,"call")} (${e.tools.join(", ")})`}function Xb(e){const t=[],n=(e.toolsWaiting||0)+(e.toolsRunning||0);if(!e.toolCalls&&!n)return t.push({heading:"Outcome",rows:[{label:"Tools called",value:"none"}]}),{kind:"tools",title:"Tools",headline:"none",sections:t,footer:Mm(e)};const o=[{label:"Succeeded",value:(e.toolCalls-(e.toolsFailed||0)).toLocaleString()},{label:"Failed",value:(e.toolsFailed||0).toLocaleString()}];e.toolsRunning&&o.push({label:"Running",value:e.toolsRunning.toLocaleString()}),e.toolsWaiting&&o.push({label:"Awaiting approval",value:e.toolsWaiting.toLocaleString(),hint:"not run yet — not a failure"}),t.push({heading:"Outcome",rows:o});const a=Object.entries(e.toolBreakdown||{}).sort((u,m)=>m[1].calls-u[1].calls||u[0].localeCompare(m[0]));a.length&&t.push({heading:"By tool",table:{columns:["Tool","Calls","Failed","Time"],rows:a.map(([u,m])=>[u,m.calls.toLocaleString(),m.failed.toLocaleString(),m.ms!==void 0?`${Cs(m.ms)}${m.sharedBatches?" +shared":""}`:m.sharedBatches?"shared":Or])},note:a.some(([,u])=>u.sharedBatches)?"A batch that mixed tools ran them together; its time is not split between them.":void 0});const l=a.filter(([,u])=>u.errors&&Object.keys(u.errors).length);l.length&&t.push({heading:"Failures",rows:l.map(([u,m])=>({label:u,value:Object.entries(m.errors).sort((y,g)=>g[1]-y[1]).map(([y,g])=>g>1?`${y} ×${g}`:y).join(" · ")}))});const d=[{label:"Tool time",value:e.toolTimeMs===void 0?Or:`${Cs(e.toolTimeMs)} · ${Ql(e.toolBatches||0,"batch","batches")}`}];return e.slowestToolBatch&&d.push({label:"Slowest batch",value:`${Cs(e.slowestToolBatch.ms)} · ${Yy(e.slowestToolBatch)}`}),t.push({heading:"Timing",rows:d,note:e.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),{kind:"tools",title:"Tools",headline:`${Ql(e.toolCalls,"call")}${e.toolsFailed?` · ${e.toolsFailed} failed`:""}`,sections:t,footer:Mm(e)}}function Oh(e,t){return e==="tokens"?Kb(t):e==="time"?Yb(t):Xb(t)}function Jb(e){const t=e.detail;return s.jsxs("div",{ref:e.panelRef,id:e.id,role:"tooltip",className:`pc-stat-detail pc-stat-detail--${t.kind}`,style:e.style,onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,children:[s.jsxs("div",{className:"pc-stat-detail-head",children:[s.jsx("span",{className:"pc-stat-detail-title",children:t.title}),s.jsx("span",{className:"pc-stat-detail-headline",children:t.headline})]}),t.sections.map(n=>{var o;return s.jsxs("div",{className:"pc-stat-detail-section",children:[s.jsx("div",{className:"pc-stat-detail-heading",children:n.heading}),(o=n.rows)!=null&&o.length?s.jsx("dl",{className:"pc-stat-detail-rows",children:n.rows.map(a=>s.jsxs(ye.Fragment,{children:[s.jsx("dt",{children:a.label}),s.jsxs("dd",{children:[s.jsx("span",{className:a.value===Or?"pc-stat-detail-value pc-stat-detail-value--absent":"pc-stat-detail-value",children:a.value}),a.hint?s.jsx("span",{className:"pc-stat-detail-hint",children:a.hint}):null]})]},a.label))}):null,n.table?s.jsxs("table",{className:"pc-stat-detail-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:n.table.columns.map(a=>s.jsx("th",{scope:"col",children:a},a))})}),s.jsx("tbody",{children:n.table.rows.map((a,l)=>s.jsx("tr",{children:a.map((d,u)=>s.jsx("td",{children:d},u))},l))})]}):null,n.note?s.jsx("p",{className:"pc-stat-detail-note",children:n.note}):null]},n.heading)}),s.jsx("div",{className:"pc-stat-detail-foot",children:t.footer.map(n=>s.jsx("div",{children:n},n))})]})}const Vo=8;function Zb(e){const[t,n]=h.useState(!!e.defaultOpen),[o,a]=h.useState(null),l=h.useRef(null),d=h.useRef(null),u=h.useRef(null),m=`pc-stat-${h.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,y=h.useCallback(()=>{u.current!==null&&window.clearTimeout(u.current),u.current=null},[]),g=h.useCallback(()=>{y(),n(!0)},[y]),v=h.useCallback(()=>{y(),u.current=window.setTimeout(()=>n(!1),120)},[y]);h.useEffect(()=>y,[y]),h.useLayoutEffect(()=>{if(!t){a(null);return}const S=()=>{const R=l.current,T=d.current;if(!R||!T)return;const D=R.getBoundingClientRect(),q=T.offsetWidth,P=T.offsetHeight,K=window.innerWidth,Q=window.innerHeight,Z=D.top-Vo-P,ee=D.bottom+Vo,ue=Z>=Vo?Z:ee+P<=Q-Vo?ee:Math.max(Vo,Q-Vo-P),de=Math.min(Math.max(Vo,D.left),Math.max(Vo,K-Vo-q));a({top:ue,left:de})};return S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[t]),h.useEffect(()=>{if(!t)return;const S=R=>{R.key==="Escape"&&n(!1)};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t]);const w=typeof e.onClick=="function",b=w?"button":"span",C=t?s.jsx(Jb,{detail:e.detail,id:m,panelRef:d,onMouseEnter:y,onMouseLeave:v,style:{position:"fixed",top:(o==null?void 0:o.top)??0,left:(o==null?void 0:o.left)??0,visibility:o?"visible":"hidden"}}):null;return s.jsxs(s.Fragment,{children:[s.jsxs(b,{ref:l,...w?{type:"button"}:{tabIndex:0},className:["pc-chat-stat","pc-chat-stat--detail",w?"pc-chat-stat--clickable":"",e.className].filter(Boolean).join(" "),"aria-label":`${e.label} — ${e.detail.title.toLowerCase()} details`,"aria-describedby":t?m:void 0,"data-stat-kind":e.detail.kind,onMouseEnter:g,onMouseLeave:v,onFocus:g,onBlur:()=>n(!1),onKeyDown:S=>{S.key==="Escape"&&n(!1)},onClick:w?()=>{var S;return(S=e.onClick)==null?void 0:S.call(e)}:void 0,children:[e.icon?s.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:e.icon}):null,s.jsx("span",{className:"pc-chat-stat-label",children:e.label})]}),C&&typeof document<"u"?Hy.createPortal(C,document.body):C]})}function Qb(e){const t=e.totalTokens!==void 0?Oh("tokens",e):null,n=Oh("tools",e),o=e.durationMs!==void 0?Oh("time",e):null;return[...t?[{label:`${e.totalTokens.toLocaleString()} tokens`,detail:t}]:[],{label:`${e.toolCalls} ${e.toolCalls===1?"tool":"tools"}`,detail:n},...e.changedFiles.length?[{label:`${e.changedFiles.length} ${e.changedFiles.length===1?"file":"files"} changed`,title:e.changedFiles.join(`
|
|
54
|
+
`)}]:[],...o?[{label:`${(e.durationMs/1e3).toFixed(e.durationMs<1e4?1:0)}s`,detail:o}]:[]]}function e0(e){const t=String(e.role||"").trim().toLowerCase()||"system",n=String(e.kind||"").trim().toLowerCase(),o=String(e.level||"").trim().toLowerCase();return t==="system"&&n==="report_bug"?{label:String(e.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:t==="system"&&n==="report_feature"?{label:String(e.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:t==="user"?{label:String(e.title||"").trim()||"You",icon:"user",variant:"user"}:t==="assistant"?{label:String(e.title||"").trim()||"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 t0(e){var T;const t=e.message,n=h.useMemo(()=>e0(t),[t.kind,t.level,t.role,t.title]),o=String(t.ts||"").trim(),a=h.useMemo(()=>{if(!o)return"";const D=new Date(o);return Number.isFinite(D.getTime())?D.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[o]),[l,d]=h.useState("idle"),u=h.useRef(null);h.useEffect(()=>()=>{u.current!==null&&window.clearTimeout(u.current)},[]);const m=t.live,y=!m&&typeof e.onSpeakToggle=="function"&&n.variant==="assistant"&&!!String(t.content||"").trim(),g=y&&((T=e.getSpeakState)==null?void 0:T.call(e,t))||"idle",v=g==="loading"?"loader":g==="playing"?"pause":"speaker",w=g==="loading"?"Generating audio…":g==="playing"?"Pause":g==="paused"?"Resume":"Speak (TTS)",b=e.showCopy!==!1,C=Array.isArray(e.attachments)?e.attachments:[],S=t.statistics,R=h.useMemo(()=>Array.isArray(e.stats)?e.stats:S?Qb(S):[],[e.stats,S]);return t.toolActivity?s.jsx(Gy,{tool:t.toolActivity,showCopy:e.showCopy}):s.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${n.variant}`,m?"pc-chat-item--live":"",e.className].filter(Boolean).join(" "),...m?{"aria-busy":!0}:{},children:[s.jsxs("div",{className:"pc-chat-header",children:[s.jsx("div",{className:"pc-chat-avatar","aria-hidden":"true",children:s.jsx(Tn,{name:n.icon,size:14})}),s.jsx("span",{className:"pc-chat-role",children:n.label}),m?s.jsxs("span",{className:"pc-chat-live-indicator",title:"The reply is still being written",children:[s.jsx("span",{className:"pc-chat-live-dot","aria-hidden":"true"}),"streaming"]}):null,m!=null&&m.caption?s.jsx("span",{className:"pc-chat-live-caption",children:m.caption}):null,s.jsx("span",{className:"pc-chat-header-spacer"}),a?s.jsx("span",{className:"pc-chat-time",children:a}):null,s.jsxs("div",{className:"pc-chat-header-actions",children:[y?s.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":w,title:w,onClick:()=>{var D;return(D=e.onSpeakToggle)==null?void 0:D.call(e,t)},children:s.jsx(Tn,{name:v,size:22})}):null,b?s.jsx("button",{className:`pc-chat-icon-btn ${l!=="idle"?`pc-chat-icon-btn--${l}`:""}`.trim(),type:"button","aria-label":"Copy message",title:l==="idle"?"Copy":l==="copied"?"Copied":"Copy failed",onClick:async()=>{const D=await nc(String(t.content||""));d(D?"copied":"failed"),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>d("idle"),900)},children:s.jsx(Tn,{name:"copy",size:22})}):null]})]}),m!=null&&m.reasoning?s.jsxs("details",{className:"pc-chat-thinking",children:[s.jsx("summary",{children:"Thinking"}),s.jsx("div",{className:"pc-chat-thinking-body",children:m.reasoning})]}):null,!m||String(t.content||"").trim()?s.jsx("div",{className:"pc-chat-body",children:s.jsx(nb,{text:String(t.content||""),renderMarkdown:e.renderMarkdown,jsonCollapseAfterDepth:e.jsonCollapseAfterDepth,images:e.images||(n.variant==="user"?"inline":"link"),inlineImage:e.inlineImage})}):null,C.length?s.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:C.slice(0,24).map((D,q)=>{const P=String(D.label||"").trim()||"attachment",K=String(D.target||"").trim(),Q=String(D.title||"").trim(),Z=!!D.disabled||typeof D.onClick!="function";return s.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:Q||P,onClick:Z?void 0:D.onClick,disabled:Z,children:[s.jsx(Tn,{name:"paperclip",size:14}),K?s.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${K}`,children:K}):null,s.jsx("span",{className:"pc-chat-attachment-name",children:P})]},D.id||`${P}:${q}`)})}):null,R.length?s.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:R.slice(0,12).map((D,q)=>{const P=String(D.label||"").trim();if(!P)return null;if(D.detail)return s.jsx(Zb,{label:P,detail:D.detail,icon:D.icon,onClick:D.onClick},D.id||`${P}:${q}`);const K=String(D.title||"").trim(),Q=typeof D.onClick=="function",Z=Q?"button":"span";return s.jsxs(Z,{...Q?{type:"button"}:{},className:["pc-chat-stat",Q?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:K||void 0,onClick:Q?()=>{var ee;return(ee=D.onClick)==null?void 0:ee.call(D)}:void 0,children:[D.icon?s.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:D.icon}):null,s.jsx("span",{className:"pc-chat-stat-label",children:P})]},D.id||`${P}:${q}`)})}):null]})}function n0(e,t){const n=Math.max(0,Math.trunc(t));return e.scrollHeight-e.scrollTop-e.clientHeight<=n}function Xy(e){const t=typeof e.autoScrollThresholdPx=="number"&&Number.isFinite(e.autoScrollThresholdPx)?e.autoScrollThresholdPx:120,n=e.autoScroll!==!1,o=h.useRef(null),a=h.useRef(null),[l,d]=h.useState(!0),u=h.useMemo(()=>Array.isArray(e.messages)?e.messages:[],[e.messages]),m=h.useMemo(()=>{var v;const g=[];for(const w of u){const b=g[g.length-1];w.toolActivity&&((v=b==null?void 0:b[0])!=null&&v.toolActivity)&&b[0].runId===w.runId?b.push(w):g.push([w])}return g},[u]);h.useEffect(()=>{if(!n)return;const g=o.current;if(!g)return;const v=()=>{d(n0(g,t))};return g.addEventListener("scroll",v,{passive:!0}),v(),()=>g.removeEventListener("scroll",v)},[n,t]);const y=h.useMemo(()=>{let g=0;for(const v of u)g+=String(v.content??"").length;return`${u.length}:${g}:${String(e.afterKey??"")}`},[u,e.afterKey]);return h.useEffect(()=>{if(!n||!l)return;const g=o.current;g&&(g.scrollTop=g.scrollHeight)},[n,l,y]),s.jsxs("div",{ref:o,className:["pc-chat-thread",e.className].filter(Boolean).join(" "),children:[u.length?null:e.empty||null,m.map((g,v)=>{var C;const w=g[0],b=String(w.id||"")||String(w.ts||"")+":"+String(w.role||"")+":"+v;return w.toolActivity?s.jsx(Wb,{tools:g.map(S=>S.toolActivity),showCopy:(C=e.messageProps)==null?void 0:C.showCopy},b):s.jsx(t0,{message:w,...e.messageProps||{}},b)}),e.after,s.jsx("div",{ref:a})]})}const Jy=ye.forwardRef(function(t,n){const o=typeof t.rows=="number"&&Number.isFinite(t.rows)?Math.max(1,Math.trunc(t.rows)):3,a=!!t.disabled,l=!!t.busy,d=!a&&!l&&!!String(t.value||"").trim();return s.jsxs("div",{className:["pc-composer",t.className].filter(Boolean).join(" "),children:[t.leading,s.jsx("textarea",{ref:n,className:["pc-composer__textarea",t.textareaClassName].filter(Boolean).join(" "),value:t.value,onChange:u=>t.onChange(u.target.value),rows:o,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off",placeholder:t.placeholder||"","aria-label":t.ariaLabel||t.placeholder||"Message",disabled:a,autoFocus:!!t.autoFocus,onPaste:t.onPaste,onKeyDown:u=>{u.key!=="Enter"||u.shiftKey||u.nativeEvent.isComposing||u.keyCode===229||(u.preventDefault(),d&&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:!d,onClick:()=>t.onSubmit(),children:l?t.busyLabel||"Thinking…":t.sendLabel||"Send"})]}),t.overlay]})});function r0(e){return!!(e&&typeof e[Symbol.asyncIterator]=="function")}function s0(e){const[t,n]=h.useState([]),o=e.messages??t,a=S=>{e.onMessagesChange&&e.onMessagesChange(S),e.messages===void 0&&n(S)},l=h.useRef(o);l.current=o;const[d,u]=h.useState(""),[m,y]=h.useState(!1),g=h.useRef(null),v=e.assistantName||"Assistant",w=!!e.blockedNotice,b=async S=>{const R=String(S||"").trim();if(!R||m||w)return;u("");const T=l.current,D=[...T,{role:"user",content:R,ts:new Date().toISOString()}];a(D),y(!0);const q=new AbortController;g.current=q;try{const P=e.ask(R,{signal:q.signal,history:T});if(r0(P)){let K="";const Q=[...D,{role:"assistant",title:v,content:"",ts:new Date().toISOString()}];a(Q);for await(const Z of P){if(q.signal.aborted)break;K+=String(Z??""),a([...D,{role:"assistant",title:v,content:K,ts:new Date().toISOString()}])}!K.trim()&&!q.signal.aborted&&a([...D,{role:"assistant",title:v,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}else{const K=String(await P??"").trim();a([...D,K?{role:"assistant",title:v,content:K,ts:new Date().toISOString()}:{role:"assistant",title:v,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}}catch(P){q.signal.aborted||a([...l.current,{role:"assistant",title:v,content:`#FALLBACK assistant request failed: ${String((P==null?void 0:P.message)||P||"unknown error")}`,level:"error",ts:new Date().toISOString()}])}finally{g.current===q&&(g.current=null),y(!1)}},C=h.useMemo(()=>o.length>0?null:s.jsxs("div",{className:"pc-assistant__empty",children:[s.jsx("div",{className:"pc-assistant__empty-text",children:e.emptyState||"Ask about this app — answers are grounded in its documentation."}),e.suggestions&&e.suggestions.length>0?s.jsx("div",{className:"pc-assistant__suggestions",children:e.suggestions.map(S=>s.jsx("button",{type:"button",className:"pc-assistant__suggestion",onClick:()=>void b(S),disabled:m||w,children:S},S))}):null]}),[o.length,e.emptyState,e.suggestions,m,w]);return s.jsxs("div",{className:`pc-assistant${e.className?` ${e.className}`:""}`,children:[s.jsxs("div",{className:"pc-assistant__thread",children:[C,s.jsx(Xy,{messages:o,autoScroll:!0}),w?s.jsx("div",{className:"pc-assistant__blocked",children:e.blockedNotice}):null]}),s.jsx("div",{className:"pc-assistant__composer",children:s.jsx(Jy,{value:d,onChange:u,onSubmit:()=>void b(d),placeholder:e.placeholder||"Ask about this app…",disabled:w,busy:m,rows:2,actions:m?s.jsx("button",{type:"button",className:"pc-btn",onClick:()=>{var S;(S=g.current)==null||S.abort()},children:"Stop"}):null})})]})}const i0="# AbstractObserver\n\n> Gateway-only observability UI (Web/PWA) for AbstractFramework runs: a browser SPA + tiny Node.js CLI that connects to an AbstractGateway HTTP API (HTTP fetch + SSE ledger streaming) and submits durable commands.\n\nThis repository is UI-only:\n- The packaged CLI (`bin/cli.js`) serves static assets from `dist/` (SPA fallback) and proxies `/api` to Gateway after hosted browser-session sign-in, using the shared session proxy from the `@abstractframework/app-server` runtime dependency.\n- The browser talks to same-origin `/api` in hosted mode; direct Gateway URLs remain available for local development via `src/lib/gateway_client.ts` (treat this file as the source of truth for HTTP endpoints and request shapes).\n- Hosted sign-in uses Gateway URL + user + token only to create an app-scoped browser session. Settings persistence strips Gateway bearer tokens. With `@abstractframework/app-server` 0.1.10 or newer the proxy sends the browser's connection address as `X-Forwarded-For` and `X-AbstractFramework-App-Proxy: abstractobserver` to the Gateway.\n- On non-local hosted UI hostnames, the server-configured Gateway URL is authoritative; browser-supplied Gateway URL changes are rejected unless `ABSTRACTOBSERVER_ALLOW_REMOTE_BROWSER_GATEWAY_CONFIG=1` is enabled behind access control. Forwarded host headers are trusted only when `ABSTRACTOBSERVER_TRUST_PROXY_HEADERS=1` or `ABSTRACTGATEWAY_TRUST_PROXY_HEADERS=1`.\n\n## Quickstart\n- Run packaged UI server (no build step): `npx --yes --package @abstractframework/observer -- abstractobserver`\n- Dev server (Vite; proxies `/api` in dev): `npm install && npm run dev`\n- Unit tests (Vitest): `npm test`\n- Production build (writes `dist/`): `npm run build`\n- Regenerate `llms-full.txt`: `npm run llms:full`\n\nNotes:\n- Build output lives in `dist/` and is served by `bin/cli.js` (don’t edit `dist/` manually).\n- Dev/build uses Vite aliases to sibling workspace packages under `../abstractuic/*/src` (see `vite.config.ts` and `docs/development.md`).\n- `llms.txt` format reference: https://llmstxt.org/\n\n## Documentation (start here)\n- [README](README.md): Install and quickstart\n- [Getting started](docs/getting-started.md): Run the UI and connect to a gateway\n- [FAQ](docs/faq.md): Common questions (grounded in code), including the CLI `/api` session proxy and the About dialog\n- [Docs index](docs/README.md): What to read next\n- [Architecture](docs/architecture.md): Components, data flow, diagrams\n- [Configuration](docs/configuration.md): CLI env vars, UI settings, deployment patterns\n- [API](docs/api.md): Gateway endpoints used by the UI, including Runtime Activity run pages and canonical artifact envelope search/stats for Runtime Artifact Explorer\n- [Development](docs/development.md): Local dev, workspace deps, tests, build\n- [Security](docs/security.md): Trust boundaries and operational guidance\n- [Troubleshooting](docs/troubleshooting.md): Common issues and fixes (CORS, mixed content, 401 under `/api`, About shows the gateway unavailable, stale service worker)\n\n## Key entrypoints (code)\n- [CLI server](bin/cli.js): static server (`PORT`, `HOST`, `ABSTRACTOBSERVER_GATEWAY_URL`), SPA fallback, `@abstractframework/app-server` session proxy, optional GPU widget config injection\n- [App shell + pages](src/ui/app.tsx): settings, page routing, observe/launch flows, durable commands\n- [Gateway client](src/lib/gateway_client.ts): HTTP client + SSE ledger streaming (API source of truth)\n- [Vite config](vite.config.ts): workspace aliases + dev session proxy and `/api` fallback proxy\n- [Package metadata](package.json): npm name/version, scripts, Node engine\n- [llms-full generator](scripts/generate-llms-full.mjs): defines which files are embedded into `llms-full.txt`\n\n## Ecosystem context\n- [AbstractFramework](https://github.com/lpalbou/AbstractFramework): ecosystem entrypoint and component map\n- [AbstractRuntime](https://github.com/lpalbou/abstractruntime): durable workflow runtime behind the gateway ledger\n- [AbstractCore](https://github.com/lpalbou/abstractcore): unified LLM + tools layer commonly used by workflows\n\n## Common tasks\n- Add/change a gateway capability: update `src/lib/gateway_client.ts` (source of truth) → update `docs/api.md` → run `npm test` + `npm run build`.\n- Change CLI behavior/config: update `bin/cli.js` → update `docs/configuration.md` → run `npm run build`.\n- Update docs for agents: edit docs → regenerate `llms-full.txt` with `npm run llms:full`.\n\n## Optional (project meta)\n- [Changelog](CHANGELOG.md): Release notes\n- [Contributing](CONTRIBUTING.md): How to develop and submit changes\n- [Security policy](SECURITY.md): Responsible vulnerability reporting\n- [Acknowledgments](ACKNOWLEDGMENTS.md): Credits\n- [Code of conduct](CODE_OF_CONDUCT.md): Conduct expectations and reporting\n- [License](LICENSE): MIT license\n",o0="observer-docs-assistant",a0=1500,l0=12e4;function c0(e,t){return new Promise((n,o)=>{const a=setTimeout(n,e);t.addEventListener("abort",()=>{clearTimeout(a),o(new DOMException("aborted","AbortError"))},{once:!0})})}const zh=1200;function u0(e,t){const n=t.slice(-6),o=t.length-n.length,a=n.map(d=>{const u=d.role==="assistant"?"Assistant":"User",m=String(d.content||""),y=m.length>zh?`${m.slice(0,zh)}… [#TRUNCATION: ${zh} of ${m.length} chars of this turn]`:m;return`${u}: ${y}`}).join(`
|
|
55
|
+
`),l=o>0?`[#TRUNCATION: showing the last ${n.length} turns; ${o} earlier turn(s) omitted]
|
|
56
|
+
`:"";return["You are the AbstractObserver in-app assistant. Answer questions about","using and understanding the AbstractObserver web app (pages: Board,","Observe/run page with Story/Ledger/Flow/Ask tabs, System with","Activity/Artifacts/Memory/Logs, Launch, Settings). Ground every answer","in the documentation index below; when the docs don't cover something,","say so plainly instead of guessing. Be concise and concrete.","","=== DOCUMENTATION INDEX (llms.txt) ===",i0,"=== END DOCUMENTATION ===",a?`
|
|
57
|
+
Conversation so far:
|
|
58
|
+
`+l+a:"",`
|
|
59
|
+
User question: ${e}`].join(`
|
|
60
|
+
`)}function d0(e){var t,n;for(let o=e.length-1;o>=0;o--){const a=e[o],l=a!=null&&a.result&&typeof a.result=="object"?a.result:null,d=[(t=l==null?void 0:l.response)==null?void 0:t.content,(n=l==null?void 0:l.response)==null?void 0:n.text,l==null?void 0:l.output,l==null?void 0:l.content,l==null?void 0:l.text];for(const u of d){const m=typeof u=="string"?u.trim():"";if(m)return m}}return""}function f0(e){return async(t,n)=>{var u;const o=e(),a=n.history.map(m=>({role:m.role,content:String(m.content??"")})),l=await o.start_run(null,{prompt:u0(t,a)},{bundle_id:"basic-agent",session_id:o0}),d=Date.now();for(;;){if(await c0(a0,n.signal),Date.now()-d>l0)throw new Error("The assistant run timed out (120s). The run is still visible on the Observe page.");const m=await o.get_run(l),y=String((m==null?void 0:m.status)||"").trim().toLowerCase();if(y==="failed"||y==="cancelled"){const g=String(((u=m==null?void 0:m.error)==null?void 0:u.message)||(m==null?void 0:m.error)||"run "+y).slice(0,400);throw new Error(`The assistant run ${y}: ${g}`)}if(y==="completed"){const g=await o.get_ledger(l,{after:0,limit:500,signal:n.signal});return d0(g.items)||"(the run completed but produced no readable answer — inspect it on the Observe page)"}}}}function m0(e){const t=h.useRef(e.gateway);t.current=e.gateway;const n=h.useMemo(()=>f0(()=>t.current),[]),[o]=h.useState(void 0);return s.jsx(jb,{open:e.open,onClose:e.onClose,label:"Observer assistant",title:"Assistant",width:420,topOffset:e.topOffset,children:s.jsx(s0,{ask:n,assistantName:"Observer",placeholder:"Ask about the observer…",blockedNotice:e.connected?o:"Connect to the gateway to use the assistant.",suggestions:["How do I see why a run failed?","Where do I find the artifacts a run produced?","What does the Board's Review column mean?","How do I launch a workflow on a schedule?"],emptyState:s.jsx("div",{children:"Answers are grounded in this app's documentation. Each question runs once through the connected gateway's basic agent."})})})}function h0(){const e="0.1.13".trim();if(!e)throw new Error("AbstractObserver: __APP_VERSION__ is not defined; the vite/vitest config must inject it from package.json");return e}function _0(){return $b("abstractobserver",h0())}async function p0(e){let t;try{t=await e.gateway_about()}catch(n){return Gp(null,n instanceof Error?n.message||n.name:String(n))}return Gp(t)}class Am{constructor(t){this._maxSize=Am._normalizeMaxSize(t),this._values=[]}get maxSize(){return this._maxSize}get size(){return this._values.length}static _normalizeMaxSize(t){const n=Number(t);return!Number.isFinite(n)||n<=0?1:Math.min(1e3,Math.floor(n))}setMaxSize(t){const n=Am._normalizeMaxSize(t);this._maxSize=n,this._values.length>n&&(this._values=this._values.slice(this._values.length-n))}clear(){this._values=[]}push(t){const n=Number(t),o=Number.isFinite(n)?n: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 g0(e){try{return new URL(String(e)),!0}catch{return!1}}function y0({baseUrl:e,endpoint:t}){const n=String(t||"/api/gateway/host/metrics/gpu");return g0(n)?n:e&&String(e).trim()?new URL(n,String(e)).toString():n}async function v0({token:e,getToken:t}){if(typeof t=="function"){const n=await t();return n==null?"":String(n)}return e==null?"":String(e)}function w0({token:e}){const t=String(e||"").trim();return t?{Authorization:`Bearer ${t}`}:{}}function x0(e){if(!e||typeof e!="object")return null;const t=Number(e.utilization_gpu_pct);if(Number.isFinite(t))return t;const n=e.gpus;if(Array.isArray(n)&&n.length){const o=n.map(l=>Number(l&&l.utilization_gpu_pct)).filter(l=>Number.isFinite(l));return o.length?o.reduce((l,d)=>l+d,0)/o.length:null}return null}async function b0({baseUrl:e,endpoint:t,token:n,getToken:o,signal:a,fetchImpl:l}={}){const d=y0({baseUrl:e,endpoint:t}),u=await v0({token:n,getToken:o}),m=l||globalThis.fetch;if(typeof m!="function")return{ok:!1,status:0,error:"fetch_unavailable",payload:null};let y;try{y=await m(d,{method:"GET",headers:{Accept:"application/json",...w0({token:u})},signal:a})}catch(v){return{ok:!1,status:0,error:"network_error",detail:v instanceof Error?v.message:String(v),payload:null}}let g=null;try{g=await y.json()}catch{g=null}return{ok:y.ok,status:y.status,error:y.ok?null:"http_error",payload:g}}const vd=Object.freeze({tickMs:1500,historySize:20,endpoint:"/api/gateway/host/metrics/gpu",baseUrl:"",mode:"full"});function S0(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Yp(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,e)):t}function Xp(e,t){const n=Number(e);return Number.isFinite(n)?Math.floor(n):t}function Ih(e,t=1){const n=Yp(Number(e)/100,0,1),o=Math.round(140-140*n),a=Yp(Number(t),0,1);return a>=1?`hsl(${o} 85% 55%)`:`hsl(${o} 85% 55% / ${a})`}function Jp(e){const t={...vd,...e||{}};return t.tickMs=Math.max(250,Xp(t.tickMs,vd.tickMs)),t.historySize=Math.max(1,Math.min(200,Xp(t.historySize,vd.historySize))),t.endpoint=String(t.endpoint||vd.endpoint),t.baseUrl=String(t.baseUrl||""),t.mode=String(t.mode||vd.mode).trim().toLowerCase(),t.mode!=="icon"&&(t.mode="full"),t}function j0(){return`
|
|
61
|
+
: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}
|
|
62
|
+
.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)}
|
|
63
|
+
.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))}
|
|
64
|
+
.wrap.icon .top{display:none}
|
|
65
|
+
.wrap.icon .bars{height:var(--monitor-gpu-bars-height,18px)}
|
|
66
|
+
.top{display:flex;align-items:baseline;justify-content:space-between;gap:10px}
|
|
67
|
+
.label{font-size:var(--monitor-gpu-font-size,var(--font-size-sm,12px));opacity:.9}
|
|
68
|
+
.value{font-variant-numeric:tabular-nums;font-size:var(--monitor-gpu-font-size,var(--font-size-sm,12px));opacity:.95}
|
|
69
|
+
.bars{display:flex;align-items:flex-end;gap:2px;height:var(--monitor-gpu-bars-height,34px);overflow:hidden}
|
|
70
|
+
.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}
|
|
71
|
+
.bar.missing{background:var(--monitor-gpu-bar-missing,#62708a);opacity:.35}
|
|
72
|
+
.bar.error{background:var(--monitor-gpu-bar-error,#ff6b6b);opacity:.7}
|
|
73
|
+
.muted{opacity:.6}
|
|
74
|
+
`}class k0{constructor(t,n={}){if(!t||typeof t!="object")throw new TypeError("target element is required");this._target=t,this._opts=Jp(n),this._buffer=new Am(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=n.token,this._getToken=n.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 n=document.createElement("style");n.textContent=j0();const o=document.createElement("div");o.className=this._opts.mode==="icon"?"wrap icon":"wrap";const a=document.createElement("div");a.className="top";const l=document.createElement("div");l.className="label",l.textContent="GPU";const d=document.createElement("div");d.className="value muted",d.textContent="—",a.appendChild(l),a.appendChild(d);const u=document.createElement("div");u.className="bars",o.appendChild(a),o.appendChild(u),t.appendChild(n),t.appendChild(o),this._els={wrap:o,value:d,bars:u},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 n=Jp({...this._opts,...t||{}}),o=n.historySize!==this._opts.historySize,a=n.tickMs!==this._opts.tickMs,l=n.mode!==this._opts.mode;this._opts=n,l&&this._mounted&&this._els&&this._els.wrap&&(this._els.wrap.className=n.mode==="icon"?"wrap icon":"wrap"),o&&(this._buffer.setMaxSize(n.historySize),this._mounted&&this._rebuildBars()),a&&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 n=0;n<this._opts.historySize;n+=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:n,value:o,bars:a}=this._els,l=this._buffer.values(),d=this._buffer.last(),u=Number.isFinite(d)?Math.max(0,Math.min(100,d)):null;u==null?(o.textContent=t?"N/A":"—",o.classList.add("muted")):(o.textContent=`${u.toFixed(0)}%`,o.classList.remove("muted")),n&&(n.title=u==null?"GPU —":`GPU ${u.toFixed(0)}%`,u==null?(n.style.removeProperty("--monitor-gpu-accent"),n.style.removeProperty("--monitor-gpu-accent-glow")):(n.style.setProperty("--monitor-gpu-accent",Ih(u,.95)),n.style.setProperty("--monitor-gpu-accent-glow",Ih(u,.35))));const m=Array.from(a.children),y=Math.max(0,m.length-l.length),g=Math.max(2,a&&typeof a.clientHeight=="number"&&a.clientHeight>0?a.clientHeight:34);for(let v=0;v<m.length;v+=1){const w=m[v],b=v-y,C=b>=0?l[b]:null,S=Number.isFinite(C)?C:null,R=S==null?0:S0(S/100),T=Math.max(2,Math.min(g,Math.round(R*g)));w.style.height=`${T}px`,w.style.background=S==null?"":Ih(S),w.className="bar",S==null&&w.classList.add("missing"),t&&w.classList.add("error")}}async _tick(){const t=String(this._token||"").trim(),n=this._getToken,o=!!t||typeof n=="function";this._abort&&this._abort.abort(),this._abort=new AbortController;const a=await b0({baseUrl:this._opts.baseUrl,endpoint:this._opts.endpoint,token:t,getToken:n,signal:this._abort.signal}),l=a&&a.payload,d=l&&typeof l=="object"?l.supported!==!1:!0,u=x0(l);if(!a.ok){if(this._buffer.push(null),this._render({error:!0}),a.status===401||a.status===403){const m=String(this._token||"").trim(),y=typeof this._getToken=="function";if(!o&&(!!m||y))return;this._stoppedForAuth=!0,this.stop()}else a.status===429&&(this.stop(),this._resumeTimer=setTimeout(()=>{this._resumeTimer=null,this._mounted&&this.start()},3e4));return}if(!d||u==null){this._buffer.push(null),this._render();return}this._buffer.push(u),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 N0(e="monitor-gpu"){if(typeof globalThis>"u"||typeof globalThis.customElements>"u"||globalThis.customElements.get(e))return;const t=globalThis.HTMLElement||class{};class n 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 a=this._shadow||this;this._controller=new k0(a,{}),this._upgradeProperty("token"),this._upgradeProperty("getToken"),this._upgradeProperty("mode")}_upgradeProperty(a){if(!Object.prototype.hasOwnProperty.call(this,a))return;const l=this[a];try{delete this[a]}catch{}this[a]=l}connectedCallback(){this._controller.setOptions(this._readAttrs());const a=()=>{this.isConnected&&this._controller.start()};typeof queueMicrotask=="function"?queueMicrotask(a):Promise.resolve().then(a)}disconnectedCallback(){this._controller.destroy()}attributeChangedCallback(){this._controller.setOptions(this._readAttrs())}_readAttrs(){const a=this.getAttribute("tick-ms"),l=this.getAttribute("history-size"),d=this.getAttribute("endpoint"),u=this.getAttribute("base-url"),m=this.getAttribute("mode");return{...a!=null?{tickMs:a}:{},...l!=null?{historySize:l}:{},...d!=null?{endpoint:d}:{},...u!=null?{baseUrl:u}:{},...m!=null?{mode:m}:{}}}set token(a){this._controller.token=a}get token(){return this._controller.token}set getToken(a){this._controller.getToken=a}get getToken(){return this._controller.getToken}set tickMs(a){this._controller.setOptions({tickMs:a})}get tickMs(){return this._controller.options.tickMs}set historySize(a){this._controller.setOptions({historySize:a})}get historySize(){return this._controller.options.historySize}set endpoint(a){this._controller.setOptions({endpoint:a})}get endpoint(){return this._controller.options.endpoint}set baseUrl(a){this._controller.setOptions({baseUrl:a})}get baseUrl(){return this._controller.options.baseUrl}set mode(a){this._controller.setOptions({mode:a})}get mode(){return this._controller.options.mode}}globalThis.customElements.define(e,n)}function Nt(){return new Date().toISOString()}function C0(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function kr(e,t){try{const n=JSON.stringify(e);return typeof n!="string"?String(e):n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`}catch{const n=String(e);return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`}}function _t(e,t){const n=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,l=String(e||"").replace(/\r\n/g,`
|
|
75
|
+
`).replace(/\r/g,`
|
|
76
|
+
`).split(`
|
|
77
|
+
`),d=l.slice(0,Math.max(1,o)).join(`
|
|
78
|
+
`),u=l.length>o,m=d.length>n?`${d.slice(0,Math.max(0,n-1))}…`:d;return u&&m===d?`${d}…`:m}function $t(e,t){const n=String(e||"");return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`}function Dh(e){const t=String(e||"").trim();return t&&t.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"untitled"}function bn(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const n=t.replace(/(\.\d{3})\d+/,"$1"),o=Date.parse(n);return Number.isFinite(o)?o:null}function E0(e){const t=Date.now()-e,n=Math.floor(t/1e3),o=Math.floor(n/60),a=Math.floor(o/60),l=Math.floor(a/24);return n<60?"just now":o<60?`${o}m ago`:a<24?`${a}h ago`:l<=3?`${l}d ago`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Yo(e){const t=bn(e);return t===null?"—":E0(t)}function Zp(e){if(!Number.isFinite(e))return"";const t=Math.floor(e/1e3);if(t<=0)return"now";const n=Math.floor(t/60),o=Math.floor(n/60),a=Math.floor(o/24),l=t%60,d=n%60,u=o%24;return a>0?`${a}d ${u}h`:o>0?`${o}h ${d}m`:n>0?`${n}m ${l}s`:`${t}s`}function J_(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return"—";const t=Math.floor(e/1e3),n=t%60,o=Math.floor(t/60),a=o%60,l=Math.floor(o/60),d=l%24,u=Math.floor(l/24);return u>0?`${u}d ${d}h`:l>0?`${l}h ${a}m`:o>0?`${o}m ${n}s`:`${Math.max(0,t)}s`}function Jo(e){const t=bn(e);return t===null?"—":new Date(t).toLocaleString()}function rn(...e){for(const t of e){const n=String(t??"").trim();if(n)return n}return""}function $0(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return null}function pi(e){const t=String(e||"").trim().toLowerCase();return t==="completed"||t==="failed"||t==="cancelled"}function au(e){const t=String(e||"").trim().toLowerCase();return t==="running"||t==="waiting"}function Kl(e){return String((e==null?void 0:e.started_at)||(e==null?void 0:e.created_at)||"").trim()}function Zy(e){const t=String((e==null?void 0:e.status)||"").trim();return pi(t)?String((e==null?void 0:e.finished_at)||(e==null?void 0:e.updated_at)||"").trim():""}function Z_(e,t=Date.now()){const n=bn(Kl(e));if(n===null)return-1;const o=bn(Zy(e));return Math.max(0,(o!==null?o:t)-n)}function rc(e,t=Date.now()){return J_(Z_(e,t))}function hu(e){return String(e||"").trim().toLowerCase()}function Ym(e){return`${(e==null?void 0:e.filename)||""} ${(e==null?void 0:e.source_path)||""}`.trim().toLowerCase()}function Rd(e,t){return t.some(n=>e.endsWith(n))}function M0(e){const t=(e==null?void 0:e.tags)||{};return[e==null?void 0:e.content_type,e==null?void 0:e.filename,e==null?void 0:e.source_path,e==null?void 0:e.modality,t.kind,t.type,t.source,t.format,t.content_format,t.name].map(n=>String(n||"").trim()).filter(Boolean).join(" ").toLowerCase()}function A0(e){const t=(e==null?void 0:e.tags)||{};return[e==null?void 0:e.content_type,e==null?void 0:e.filename,e==null?void 0:e.source_path,e==null?void 0:e.modality,e==null?void 0:e.semantic_kind,e==null?void 0:e.render_kind,e==null?void 0:e.task,t.semantic_kind,t.render_kind,t.kind,t.type,t.task,t.provider_task,t.source,t.format,t.content_format,t.name].map(n=>String(n||"").trim()).filter(Boolean).join(" ").toLowerCase()}function T0(e){const t=String(e||"").trimStart().slice(0,4096).toLowerCase();return t?!!(/^<!doctype\s+html\b/.test(t)||/^<html[\s>]/.test(t)||/<head[\s>][\s\S]*<\/head>/.test(t)||/<body[\s>][\s\S]*<\/body>/.test(t)||/<(?:article|main|section|div|p|h[1-6]|meta|title|script|style)\b[\s\S]*>/.test(t)&&/<\/(?:article|main|section|div|p|h[1-6]|title|script|style)>/.test(t)):!1}function Qy(e,t){var d,u,m,y,g;const n=hu(e==null?void 0:e.content_type),o=Ym(e),a=[e==null?void 0:e.semantic_kind,e==null?void 0:e.render_kind,e==null?void 0:e.task,(d=e==null?void 0:e.tags)==null?void 0:d.semantic_kind,(u=e==null?void 0:e.tags)==null?void 0:u.render_kind,(m=e==null?void 0:e.tags)==null?void 0:m.task,(y=e==null?void 0:e.tags)==null?void 0:y.kind,(g=e==null?void 0:e.tags)==null?void 0:g.type].map(v=>String(v||"").trim().toLowerCase()).filter(Boolean).join(" ");if(/(^|[^a-z0-9])(code|source_code|script|program|executable)([^a-z0-9]|$)/i.test(a)||n.includes("javascript")||n.includes("typescript")||n.includes("x-python")||n.includes("x-shellscript")||n.includes("x-rust")||n.includes("x-go")||n.includes("x-java")||n.includes("x-csrc")||n.includes("x-c++src")||Rd(o,[".py",".js",".jsx",".ts",".tsx",".mjs",".cjs",".sh",".bash",".zsh",".go",".rs",".java",".c",".cc",".cpp",".h",".hpp",".cs",".php",".rb",".swift",".kt",".sql"]))return!0;const l=String(t||"").replace(/\r\n/g,`
|
|
79
|
+
`).replace(/\r/g,`
|
|
80
|
+
`).split(`
|
|
81
|
+
`);return ev(l)}function R0(e){const n=String(e||"").replace(/\r\n/g,`
|
|
82
|
+
`).replace(/\r/g,`
|
|
83
|
+
`).split(`
|
|
84
|
+
`),o=n.findIndex(d=>/^Markdown Content:\s*$/i.test(d.trim()));if(o===-1)return null;const a=[];for(const d of n.slice(0,o)){const u=d.match(/^\s*([A-Za-z][A-Za-z0-9 /_-]{1,40}):\s*(.+?)\s*$/);u&&a.push({label:u[1].trim(),value:u[2].trim()})}const l=n.slice(o+1).join(`
|
|
85
|
+
`).trim();return!a.length&&!l?null:{metadata:a,body:l}}function L0(e){const t=e.map(n=>n.trim()).filter(Boolean).slice(0,8);if(t.length<2)return!1;for(const n of[","," ",";"]){const o=t.map(a=>a.split(n).length);if(o[0]>=3&&o.every(a=>Math.abs(a-o[0])<=1))return!0}return!1}function P0(e){const t=e.map(o=>o.trimEnd()).filter(Boolean).slice(0,20);if(!t.length)return!1;const n=t.filter(o=>/^(\[[^\]]+\]|\d{4}-\d{2}-\d{2}[t\s]|\w+:\s|traceback\b|error\b|warn\b|info\b)/i.test(o.trim())).length;return t.length>=4&&n/t.length>=.55?!0:ev(e)}function ev(e){const t=e.map(o=>o.trimEnd()).filter(Boolean).slice(0,20);if(!t.length)return!1;const n=t.filter(o=>/[{};]\s*$/.test(o)||/^\s*(import|export|const|let|var|function|class|def|if|for|while|return)\b/.test(o)).length;return t.length>=4&&n/t.length>=.55}function O0(e){const t=String(e||"");if(!t.trim())return!1;const n=t.match(/\\[A-Za-z]{2,}\b/g)||[];if(n.length>=1&&/\\(?:setcctype|sectctype|documentclass|begin|end|maketitle|geq|leq|cite|ref|label)\b/.test(t)||n.length>=4)return!0;const a=t.replace(/\r\n/g,`
|
|
86
|
+
`).replace(/\r/g,`
|
|
87
|
+
`).split(`
|
|
88
|
+
`).map(m=>m.trim()).filter(Boolean).slice(0,80);if(a.length<12)return!1;const l=a.filter(m=>m.length<=28).length,d=a.filter(m=>/^[,.;:()†]+$/.test(m)).length;return a.filter(m=>/^(abstract\.?|introduction|references|appendix|figure\s+\d+|table\s+\d+)\b/i.test(m)).length>=2&&(l/a.length>=.45||d>=2)}function z0(e,t){var y;const n=String(t||""),o=M0(e);if(/(^|[^a-z0-9])(markdown|mdown)([^a-z0-9]|$)/i.test(o))return!0;if(!n.trim())return!1;if(/(^|\n)\s*Markdown Content:\s*(\n|$)/i.test(n)||n.includes("```")||/(^|\n)\s*#{1,6}\s+\S/.test(n)||/(^|\n)[ \t]*[-*][ \t]+\S/.test(n)||/(^|\n)[ \t]*\d+[\.)][ \t]+\S/.test(n)||/\*\*[^*\n][\s\S]*?\*\*/.test(n)||/\[[^\]\n]+\]\([^)]+\)/.test(n)||/(^|\n)\s*\|.+\|\s*(\n|$)/.test(n)&&/(^|\n)\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*(\n|$)/.test(n))return!0;const a=n.replace(/\r\n/g,`
|
|
89
|
+
`).replace(/\r/g,`
|
|
90
|
+
`).split(`
|
|
91
|
+
`),l=a.map(g=>g.trim()).filter(Boolean);if(l.length<2||O0(n)||L0(a)||P0(a))return!1;const d=((y=n.match(/[A-Za-z][A-Za-z'-]+/g))==null?void 0:y.length)||0,u=a.filter(g=>!g.trim()).length,m=l.filter(g=>/[A-Za-z]{3,}/.test(g)&&g.length>=12).length;return d>=24&&m>=2&&(u>=1||l[0].length<=140)}function Ld(e){const t=hu(e==null?void 0:e.modality),n=hu(e==null?void 0:e.content_type),o=Ym(e),a=A0(e);return t==="image"||n.startsWith("image/")||Rd(o,[".png",".jpg",".jpeg",".gif",".webp",".bmp",".svg",".tif",".tiff",".heic"])?"image":t==="audio"||t==="voice"||t==="music"||t==="sound"||n.startsWith("audio/")||/(tts|stt|voice|music|sound|speech|audio)/i.test(a)||Rd(o,[".wav",".mp3",".m4a",".aac",".flac",".ogg",".opus",".aiff",".mid",".midi"])?"audio":t==="video"||n.startsWith("video/")||Rd(o,[".mp4",".mov",".webm",".mkv",".avi",".m4v"])?"video":!n||t==="text"||n.startsWith("text/")||n.includes("json")||n.includes("yaml")||n.includes("toml")||n.includes("xml")||n.includes("html")||n.includes("markdown")||n.includes("csv")||Qy(e,"")?"text":"binary"}function Pd(e,t){const n=hu(e==null?void 0:e.content_type),o=Ym(e),a=String(t||"").trim();return n.includes("html")||o.endsWith(".html")||o.endsWith(".htm")||T0(t)?"html":Qy(e,t)?"code":n.includes("markdown")||o.endsWith(".md")||o.endsWith(".markdown")?"markdown":n.includes("json")||o.endsWith(".json")||o.endsWith(".jsonl")||(a.startsWith("{")||a.startsWith("["))&&Km(a)!==null?"json":z0(e,t)?"markdown":"text"}function Q_(e,t=""){const n=Ld(e);if(n==="image"||n==="video")return n;if(n==="audio"){const o=(e==null?void 0:e.tags)||{},a=[e==null?void 0:e.semantic_kind,e==null?void 0:e.modality,e==null?void 0:e.task,o.semantic_kind,o.modality,o.kind,o.task,o.source,e==null?void 0:e.filename,e==null?void 0:e.source_path].map(l=>String(l||"").trim().toLowerCase()).filter(Boolean).join(" ");return/(^|[^a-z0-9])(voice|tts|speech)([^a-z0-9]|$)/i.test(a)?"voice":/(^|[^a-z0-9])(music|song|instrumental|t2m)([^a-z0-9]|$)/i.test(a)?"music":/(^|[^a-z0-9])(sound|sfx|recording)([^a-z0-9]|$)/i.test(a)?"sound":"audio"}if(n==="binary"){const o=hu(e==null?void 0:e.modality),a=hu(e==null?void 0:e.content_type),l=Ym(e);return o==="document"||a.includes("pdf")||Rd(l,[".pdf",".doc",".docx",".ppt",".pptx",".xls",".xlsx"])?"document":"other"}return Pd(e,t)}function Fh(e){var y,g;const t=String(e||"").replace(/\r\n/g,`
|
|
92
|
+
`).replace(/\r/g,`
|
|
93
|
+
`).trim();if(!t)return"";const n=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=t.match(/<!--[\s\S]*?-->|<!doctype\b[^>]*>|<!\[CDATA\[[\s\S]*?\]\]>|<\/?[A-Za-z][^>]*>|[^<]+/gi)||[t],a=[];let l=0,d="";const u=v=>" ".repeat(Math.max(0,v)),m=(v,w)=>{const b=v.match(/^(<\/?|<!)([^\s/>]+)([\s\S]*?)(\/?>)$/);if(!b||v.length<=120||v.startsWith("</")||v.startsWith("<!"))return[`${u(w)}${v.trim()}`];const C=(b[3]||"").trim();if(!C)return[`${u(w)}${v.trim()}`];const S=C.match(/[^\s="'<>`]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'<>`]+))?/g)||[C];return[`${u(w)}${b[1]}${b[2]}`,...S.map(R=>`${u(w+1)}${R.trim()}`),`${u(w)}${b[4]}`]};for(const v of o){const w=String(v||"");if(!w.trim())continue;const b=w.trim().toLowerCase();if(b.startsWith("</")){const S=((y=b.match(/^<\/\s*([a-z0-9:-]+)/))==null?void 0:y[1])||"";d&&S===d&&(d=""),l=Math.max(0,l-1),a.push(`${u(l)}${w.trim()}`);continue}if(w.trimStart().startsWith("<")){a.push(...m(w,l));const S=((g=b.match(/^<\s*([a-z0-9:-]+)/))==null?void 0:g[1])||"";/\/>\s*$/.test(w)||b.startsWith("<!")||n.has(S)||(l+=1,(S==="script"||S==="style")&&(d=S));continue}if(d){const S=w.trim();S&&a.push(...S.split(`
|
|
94
|
+
`).map(R=>`${u(l)}${R.trimEnd()}`));continue}const C=w.replace(/\s+/g," ").trim();C&&a.push(`${u(l)}${C}`)}return a.join(`
|
|
95
|
+
`)}function I0(e){var n;const t=((n=e==null?void 0:e.output)==null?void 0:n.stop_reason)??(e==null?void 0:e.stop_reason)??null;return t&&typeof t=="object"?t:null}function Tm(e){const t=String((e==null?void 0:e.status)??"").trim().toLowerCase(),n=t==="completed"||t==="failed"||t==="cancelled";return e!=null&&e.paused&&!n?"paused":t==="completed"&&(e!=null&&e.stop_reason)&&e.stop_reason.finished===!1?"stopped":t||"unknown"}function Za(e,t){const n=String(e??"").trim().toLowerCase();return n==="stopped"?"warn":n==="completed"?t&&t.finished===!1?"warn":"ok":n==="failed"||n==="cancelled"?"danger":n==="waiting"||n==="paused"||n==="suspended"?"warn":n==="running"||n==="scheduled"?"info":"muted"}const D0=/^\s*<runtime_metadata>\s*([\s\S]*?)\s*<\/runtime_metadata>\s*/i;function ep(e){const t=typeof e=="string"?e:String(e??""),n=D0.exec(t);if(!n)return{text:t.trim(),metadata:null,stripped:!1};let o=null;try{const a=JSON.parse(String(n[1]||"").trim());a&&typeof a=="object"&&!Array.isArray(a)&&(o=a)}catch{o=null}return{text:t.slice(n[0].length).trim(),metadata:o,stripped:!0}}function tv(...e){const t={};for(const n of e)if(!(!n||typeof n!="object"||Array.isArray(n)))for(const[o,a]of Object.entries(n))a==null||String(a).trim()===""||(t[o]=a);return Object.keys(t).length?t:null}function S_(e){if(e==null)return"";if(typeof e=="string")return e.trim();if(Array.isArray(e))return e.map(t=>S_(t)).filter(Boolean).join(`
|
|
96
|
+
`).trim();if(typeof e=="object"){const t=e.text??e.content??e.message??e.value;if(t!==e){const n=S_(t);if(n)return n}}return""}function nv(e){const t=ep(S_(e));return{text:t.text,runtime_metadata:t.metadata}}function F0(e){var o,a;if(!e)return{text:"",runtime_metadata:null};const t=typeof e.prompt=="string"?String(e.prompt).trim():"";if(t){const l=ep(t);return{text:l.text,runtime_metadata:l.metadata}}const n=[(o=e.context)==null?void 0:o.messages,e.messages,e.conversation,e.history].filter(Array.isArray);for(const l of n)for(let d=l.length-1;d>=0;d-=1){const u=l[d],m=String((u==null?void 0:u.role)||(u==null?void 0:u.speaker)||"").trim().toLowerCase();if(m&&m!=="user"&&m!=="human")continue;const y=nv((u==null?void 0:u.content)??(u==null?void 0:u.text)??u);if(y.text)return{text:y.text,runtime_metadata:tv(y.runtime_metadata,u!=null&&u.runtime_metadata&&typeof u.runtime_metadata=="object"?u.runtime_metadata:null,(a=u==null?void 0:u.metadata)!=null&&a.runtime_metadata&&typeof u.metadata.runtime_metadata=="object"?u.metadata.runtime_metadata:null)}}return{text:"",runtime_metadata:null}}function B0(e,t=6){var l,d;if(!e)return[];const o=[(l=e.context)==null?void 0:l.messages,e.messages,e.conversation,e.history].filter(Array.isArray).find(u=>u.length)||[],a=[];for(const u of o){const m=String((u==null?void 0:u.role)||(u==null?void 0:u.speaker)||(u==null?void 0:u.author)||"").trim().toLowerCase()||"message",y=nv((u==null?void 0:u.content)??(u==null?void 0:u.text)??(u==null?void 0:u.message)??u),g=y.text;if(!g)continue;const v=String((u==null?void 0:u.ts)||(u==null?void 0:u.timestamp)||(u==null?void 0:u.created_at)||(u==null?void 0:u.time)||"").trim(),w=tv(y.runtime_metadata,u!=null&&u.runtime_metadata&&typeof u.runtime_metadata=="object"?u.runtime_metadata:null,(d=u==null?void 0:u.metadata)!=null&&d.runtime_metadata&&typeof u.metadata.runtime_metadata=="object"?u.metadata.runtime_metadata:null);a.push({role:m,text:g,ts:v,runtime_metadata:w})}return a.slice(Math.max(0,a.length-Math.max(1,t)))}function rv(e){const t=String(e||"").trim().toLowerCase().replace(/\s+/g," ");return t==="please respond:"||t==="please respond"||t==="type response..."||t==="type response"}function U0(e){const t=e.map(n=>String((n==null?void 0:n.name)||"tool").trim()).filter(Boolean);return t.length?`${t.slice(0,3).join(", ")}${t.length>3?` +${t.length-3}`:""}`:""}const sv="inferred from the call's arguments (regex heuristic) — not a declared risk tier; declared tiers replace this when the grant API ships";function iv(e){const t=String((e==null?void 0:e.name)||"").trim().toLowerCase(),n=e!=null&&e.arguments&&typeof e.arguments=="object"?e.arguments:{},o=String((n==null?void 0:n.command)||(n==null?void 0:n.cmd)||(n==null?void 0:n.shell)||"").trim().toLowerCase(),a=[];return(t.includes("execute_command")||t.includes("terminal")||o)&&a.push("Shell"),/[;&|]?\s*(rm|rmdir|mv|chmod|chown|sudo)\b/.test(o)&&a.push("Destructive risk"),/(^|\s)(curl|wget|scp|ssh|nc|ncat|ftp)\b/.test(o)&&a.push("Network"),/(^|\s)(cat|sed|rg|grep|ls|find|pwd)\b/.test(o)&&!/[>|]\s*\S/.test(o)&&a.push("Read path"),/[>|]\s*\S|(^|\s)(tee|touch|mkdir|cp)\b/.test(o)&&a.push("Filesystem write"),a.length||a.push("Tool call"),Array.from(new Set(a)).slice(0,4)}function tp(e,t){const n=String((e==null?void 0:e.reason)||"").trim().toLowerCase(),o=U0(t);return t.length?`Approval required: ${o||"tool call"}`:n==="user"?"Waiting for your answer":n==="event"?"Waiting for a user response event":n==="subworkflow"?"Waiting for a subworkflow":n==="until"?"Scheduled wait":n?`Waiting: ${n}`:"Waiting for input"}function ov(e,t){return t.length?"Review the requested tool call, then approve and execute it, approve without local execution, reject it, or cancel the whole run.":(Array.isArray(e==null?void 0:e.choices)?(e==null?void 0:e.choices)||[]:[]).length?"Select one of the allowed responses, then submit it to resume this run.":(e==null?void 0:e.allow_free_text)===!1?"This wait does not allow free text. Use the available response control or inspect the ledger.":String((e==null?void 0:e.prompt)||"").trim()?"Answer the workflow question below. Submitting resumes only this wait.":"No explicit question was emitted. Inspect the original request and recent ledger context before responding."}function av(e,t){const n=String((e==null?void 0:e.prompt)||"").trim(),o=ep(n),a=F0(t);return o.text&&!rv(o.text)?{text:o.text,runtime_metadata:o.metadata}:a.text?a:{text:o.text||n,runtime_metadata:o.metadata}}function H0(e,t){return av(e,t).text}function W0(e,t){return e||String(t||"").trim()||{}}function qs(e,t){const n=String((e==null?void 0:e.schedule_target_workflow_id)||(e==null?void 0:e.workflow_id)||"").trim();return n?t[n]||n:"(workflow unknown)"}function Qa(e){const t=String(e.status||"unknown").trim()||"unknown";return s.jsx("span",{className:`run_status_pill ${Za(t)}`,children:t})}function q0(e){var l;const t=String((e==null?void 0:e.status)||"").trim().toLowerCase();if(pi(t))return"";const n=e!=null&&e.waiting&&typeof e.waiting=="object"?e.waiting:null,o=String((n==null?void 0:n.reason)||(e==null?void 0:e.waiting_reason)||"").trim().toLowerCase(),a=Array.isArray((l=n==null?void 0:n.details)==null?void 0:l.tool_calls)?n.details.tool_calls:[];return a.length?tp(n,a):o==="user"?"Waiting for your answer":o==="event"?"Waiting for a response event":o==="subworkflow"?"Waiting for subworkflow":o==="until"?"Scheduled wait":o?`Waiting: ${o}`:t==="waiting"?"Waiting, reason unknown":""}function Rm(e){const t=e==null?void 0:e.error;return t?typeof t=="string"?_t(t,{max_chars:220,max_lines:2}):_t(kr(t,400),{max_chars:220,max_lines:2}):""}function V0(e){const t=q0(e);if(t)return t;const n=Rm(e);if(n)return n;const o=String((e==null?void 0:e.current_node)||"").trim();if(o)return`Current node: ${o}`;const a=String((e==null?void 0:e.status)||"").trim().toLowerCase();return a==="running"?"Running":pi(a)?"Terminal":"No current activity reported"}function lv(e){return e!=null&&e.ref&&typeof e.ref=="object"?e.ref:e!=null&&e.artifact_ref&&typeof e.artifact_ref=="object"?e.artifact_ref:e!=null&&e.artifact&&typeof e.artifact=="object"?e.artifact:{}}function Qp(e){const t=lv(e),n=e!=null&&e.metadata&&typeof e.metadata=="object"?e.metadata:e!=null&&e.meta&&typeof e.meta=="object"?e.meta:{},o=e!=null&&e.tags&&typeof e.tags=="object"?e.tags:{},a=rn(e==null?void 0:e.modality,t==null?void 0:t.modality,n==null?void 0:n.modality,o.modality).toLowerCase();if(a)return a;const l=rn(e==null?void 0:e.content_type,e==null?void 0:e.mime_type,e==null?void 0:e.mime,t==null?void 0:t.content_type,t==null?void 0:t.mime_type,t==null?void 0:t.mime,n==null?void 0:n.content_type,o.content_type).toLowerCase();return l.startsWith("image/")?"image":l.startsWith("audio/")?"audio":l.startsWith("video/")?"video":l.includes("pdf")?"document":l.startsWith("text/")||l.includes("json")||l.includes("markdown")||l.includes("csv")?"text":"artifact"}function G0(e){return!e||typeof e!="object"?{}:e.artifact_envelope_v1&&typeof e.artifact_envelope_v1=="object"?e.artifact_envelope_v1:e.envelope&&typeof e.envelope=="object"?e.envelope:e}function K0(e,t){if(!e||typeof e!="object")return null;const n=G0(e),o=lv(e),a=e!=null&&e.metadata&&typeof e.metadata=="object"?e.metadata:e!=null&&e.meta&&typeof e.meta=="object"?e.meta:{},l=n!=null&&n.descriptor&&typeof n.descriptor=="object"?n.descriptor:e!=null&&e.descriptor&&typeof e.descriptor=="object"?e.descriptor:{},d=rn(n.artifact_id,e.artifact_id,e.$artifact,e.id,o.artifact_id,o.$artifact,o.id,a.artifact_id,a.$artifact);if(!d)return null;const u={...o.tags&&typeof o.tags=="object"?o.tags:{},...a.tags&&typeof a.tags=="object"?a.tags:{},...n.tags&&typeof n.tags=="object"?n.tags:{},...e.tags&&typeof e.tags=="object"?e.tags:{}},m={};for(const[P,K]of Object.entries(u)){const Q=String(P||"").trim();Q&&(m[Q]=String(K??""))}const y=rn(n.filename,e.filename,o.filename,a.filename,m.filename,m.name,e.name,o.name),g=rn(n.source_path,e.source_path,o.source_path,a.source_path,e.path,o.path,m.path,m.source_path,m.file_path),v=rn(n.content_type,e.content_type,e.mime_type,e.mime,o.content_type,o.mime_type,o.mime,a.content_type,m.content_type),w=rn(n.render_kind,l.render_kind,e.render_kind,m.render_kind),b=rn(n.semantic_kind,l.semantic_kind,e.semantic_kind,m.semantic_kind,m.artifact_type),C=n.access&&typeof n.access=="object"?n.access:e.access&&typeof e.access=="object"?e.access:{},S=n.producer&&typeof n.producer=="object"?n.producer:e.producer&&typeof e.producer=="object"?e.producer:l.producer&&typeof l.producer=="object"?l.producer:{},R=n.provenance&&typeof n.provenance=="object"?n.provenance:e.provenance&&typeof e.provenance=="object"?e.provenance:l.provenance&&typeof l.provenance=="object"?l.provenance:{},T=n.generation&&typeof n.generation=="object"?n.generation:e.generation&&typeof e.generation=="object"?e.generation:l.generation&&typeof l.generation=="object"?l.generation:{},D=n.media&&typeof n.media=="object"?n.media:e.media&&typeof e.media=="object"?e.media:l.media&&typeof l.media=="object"?l.media:{},q=n.links&&typeof n.links=="object"?n.links:e.links&&typeof e.links=="object"?e.links:l.links&&typeof l.links=="object"?l.links:{};return{artifact_id:d,run_id:rn(n.run_id,e.run_id,o.run_id,a.run_id,m.run_id,R.run_id),content_type:v,modality:rn(n.modality,e.modality,l.modality,m.modality)||Qp({...e,ref:o,metadata:a,tags:m}),semantic_kind:b||Qp({...e,ref:o,metadata:a,tags:m}),render_kind:w||Q_({content_type:v,filename:y,source_path:g,modality:rn(n.modality,e.modality,m.modality),tags:m}),task:rn(n.task,l.task,e.task,m.task,m.provider_task),classification_source:rn(n.classification_source,l.classification_source,e.classification_source),session_id:rn(n.session_id,l.session_id,e.session_id,m.session_id),workflow_id:rn(n.workflow_id,l.workflow_id,e.workflow_id,m.workflow_id,m.workflow),node_id:rn(n.node_id,l.node_id,e.node_id,m.node_id,m.node),step_id:rn(n.step_id,l.step_id,e.step_id,m.step_id),effect_id:rn(n.effect_id,l.effect_id,e.effect_id,m.effect_id,m.effect_idempotency_key),turn_id:rn(n.turn_id,l.turn_id,e.turn_id,m.turn_id,m.turn),ledger_cursor:rn(n.ledger_cursor,l.ledger_cursor,e.ledger_cursor,m.ledger_cursor,m.step_cursor),parent_run_id:rn(n.parent_run_id,l.parent_run_id,e.parent_run_id,m.parent_run_id),actor_id:rn(n.actor_id,l.actor_id,e.actor_id,m.actor_id),title:rn(n.title,e.title,m.title,m.label,m.name),created_at:rn(n.created_at,e.created_at,o.created_at,a.created_at,m.created_at),size_bytes:$0(n.size_bytes,e.size_bytes,o.size_bytes,a.size_bytes,m.size_bytes),filename:y,source_path:g,sha256:rn(n.sha256,e.sha256,o.sha256,a.sha256,m.sha256),tags:m,producer:S,provenance:R,generation:T,media:D,source_refs:Array.isArray(n.source_refs)?n.source_refs:Array.isArray(e.source_refs)?e.source_refs:[],access:C,links:q,available_actions:Array.isArray(n.available_actions)?n.available_actions.map(String):Array.isArray(e.available_actions)?e.available_actions.map(String):[],provider_trace_available:!!(n.provider_trace_available??e.provider_trace_available),audit_available:!!(n.audit_available??e.audit_available),legacy_inferred:!!((n.legacy_inferred??e.legacy_inferred)||/(?:legacy|inferred|runtime_tags|runtime_mime)/i.test(rn(n.classification_source,l.classification_source,e.classification_source))),descriptor:l,source:t,raw:e}}function j_(e){return e.filename||e.title||(e.source_path?e.source_path.split("/").filter(Boolean).slice(-1)[0]:"")||$t(e.artifact_id,16)}function Y0(e,t){if(t==="type")return cu(e);if(t==="run")return e.run_id||"(no run)";if(t==="turn")return k_(e);if(t==="node")return lu(e)||"(node unknown)";if(t==="workflow")return np(e)||"(workflow unknown)";if(t==="location"){const a=(e.source_path||e.filename||"").split("/").filter(Boolean);return a.length>1?a.slice(0,-1).join("/"):"(root)"}if(t==="source")return Od(e)||e.source||"artifact";const n=bn(e.created_at);return n===null?"(unknown time)":new Date(n).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function np(e){const t=(e==null?void 0:e.tags)||{};return String((e==null?void 0:e.workflow_id)||t.workflow_id||t.workflow||"").trim()}function lu(e){const t=(e==null?void 0:e.tags)||{},n=String((e==null?void 0:e.node_id)||t.node_id||t.node||(e==null?void 0:e.step_id)||t.step_id||"").trim();if(n)return n;const a=String((e==null?void 0:e.source_path)||t.path||"").trim().match(/(?:^|[._:/-])(node-[A-Za-z0-9_-]+)/);return a!=null&&a[1]?String(a[1]):""}function k_(e){const t=(e==null?void 0:e.tags)||{},n=String((e==null?void 0:e.turn_id)||t.turn_id||t.turn||t.cycle||(e==null?void 0:e.ledger_cursor)||t.ledger_cursor||t.step_cursor||"").trim();if(n)return`turn ${n}`;const o=lu(e),a=bn(e==null?void 0:e.created_at),l=a===null?"unknown time":new Date(a).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),d=e!=null&&e.run_id?$t(String(e.run_id),10):"unknown run";return o?`${d} · ${o} · ${l}`:`${d} · ${l}`}function eg(e){if(!e)return"provenance unavailable";const t=[],n=np(e),o=lu(e),a=Od(e),l=cv(e);return n&&t.push(n),o&&t.push(o),a&&t.push(a),l&&t.push(l),t.length?t.join(" · "):"provenance unavailable"}function Yl(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return"—";const t=["B","KB","MB","GB","TB"];let n=e,o=0;for(;n>=1024&&o<t.length-1;)n/=1024,o+=1;const a=o===0?0:n>=10?1:2;return`${n.toFixed(a)} ${t[o]}`}function cu(e){const t=String((e==null?void 0:e.semantic_kind)||(e==null?void 0:e.modality)||"").trim().toLowerCase(),n=String((e==null?void 0:e.render_kind)||"").trim().toLowerCase(),o=t||n||"artifact";return{voice:"Voice",music:"Music",sound:"Sound",recording:"Recording",audio:"Unclassified audio",image:"Image",video:"Video",markdown:"Markdown",html:"HTML",json:"JSON",document:"Document",code:"Code",text:"Text",binary:"Other",artifact:"Other"}[o]||o.replace(/[_-]+/g," ").replace(/\b\w/g,l=>l.toUpperCase())}function X0(e){return e==="html"?"HTML":e==="json"?"JSON":e==="audio"?"Unclassified audio":e==="code"?"Code":e.slice(0,1).toUpperCase()+e.slice(1)}function J0(e){const t=Date.now();if(e==="hour")return new Date(t-3600*1e3).toISOString();if(e==="week")return new Date(t-10080*60*1e3).toISOString();if(e==="month")return new Date(t-720*60*60*1e3).toISOString();if(e==="today"){const n=new Date(t);return new Date(n.getFullYear(),n.getMonth(),n.getDate()).toISOString()}return""}function Z0(e){return e==="oldest"?{order_by:"created_at",order:"asc"}:e==="size_desc"?{order_by:"size_bytes",order:"desc"}:e==="size_asc"?{order_by:"size_bytes",order:"asc"}:e==="last_access"?{order_by:"last_accessed_at",order:"desc"}:e==="turn"?{order_by:"turn",order:"asc"}:e==="type"?{order_by:"semantic_kind",order:"asc"}:{order_by:"created_at",order:"desc"}}function tg(e){const t=e!=null&&e.stats&&typeof e.stats=="object"?e.stats:{},n=t!=null&&t.facets&&typeof t.facets=="object"?t.facets:e!=null&&e.facets&&typeof e.facets=="object"?e.facets:{};return n&&typeof n=="object"?n:{}}function Q0(e){const t=Jo(e.created_at),n=Yo(e.created_at);return t==="—"?"Created —":`${t}${n&&n!=="—"?` (${n})`:""}`}function ng(e){var a;const t=e.tags||{},n=String(((a=e.access)==null?void 0:a.last_accessed_at)||t.last_accessed_at||t.accessed_at||t.updated_at||e.created_at||"").trim(),o=Jo(n);return o==="—"?"—":o}function rg(e){const t=e.tags||{},n=String(e.title||t.title||t.name||t.label||e.filename||"").trim();if(n)return n;const o=String(e.source_path||t.path||"").trim();if(o)return o.split("/").filter(Boolean).slice(-1)[0]||o;const a=Od(e),l=cu(e);return a?`${l} ${a}`:`${l} artifact`}function Od(e){var n;const t=e.tags||{};return String(e.task||((n=e.provenance)==null?void 0:n.source)||t.task||t.kind||t.source||e.source||"").trim()}function cv(e){var o,a,l,d,u,m,y,g;if(!e)return"";const t=rn((o=e.producer)==null?void 0:o.provider,(a=e.producer)==null?void 0:a.provider_id,(l=e.provenance)==null?void 0:l.provider,(d=e.generation)==null?void 0:d.provider),n=rn((u=e.producer)==null?void 0:u.model,(m=e.producer)==null?void 0:m.model_id,(y=e.provenance)==null?void 0:y.model,(g=e.generation)==null?void 0:g.model);return t&&n?`${t} / ${n}`:t||n}function eS(e){var t,n,o,a;return e?rn((t=e.generation)==null?void 0:t.prompt,(n=e.generation)==null?void 0:n.input,(o=e.generation)==null?void 0:o.text,(a=e.provenance)==null?void 0:a.prompt):""}function sg(e){if(!e)return"";const t=e.media||{},n=Number(t.duration_s??t.duration_seconds??t.duration),o=Number(t.width??t.image_width??t.video_width),a=Number(t.height??t.image_height??t.video_height),l=Number(t.sample_rate??t.sample_rate_hz),d=Number(t.channels);if(Number.isFinite(n)&&n>0){const m=[`${n>=60?`${Math.floor(n/60)}m ${Math.round(n%60)}s`:`${n.toFixed(n>=10?1:2)}s`}`];return Number.isFinite(l)&&l>0&&m.push(`${Math.round(l/1e3)} kHz`),Number.isFinite(d)&&d>0&&m.push(`${d} ch`),m.join(" · ")}if(Number.isFinite(o)&&Number.isFinite(a)&&o>0&&a>0)return`${Math.round(o)} x ${Math.round(a)}`;const u=Number(t.page_count??t.pages);return Number.isFinite(u)&&u>0?`${Math.round(u)} pages`:""}function ig(e){return e.source_path||e.filename||""}function Lm(e,t,n){const o=e.run_id&&t[e.run_id]||null;if(!o)return e;const a=qs(o,n),l={...e.tags||{}};return a&&!l.workflow&&(l.workflow=a),a&&!l.workflow_id&&(l.workflow_id=a),{...e,workflow_id:e.workflow_id||a,tags:l}}function N_(e,t,n,o=""){const a=Lm(e,t,n),l=Q_(a,o);return{json:"JSON",html:"HTML",markdown:"Markdown",code:"Code",voice:"Voice",music:"Music",sound:"Sound",audio:"Unclassified audio",image:"Image",video:"Video",document:"Document",text:"Text",other:"Other"}[l]||cu(a)}function Ui(e){var o;const t=e,n=(o=t==null?void 0:t.result)==null?void 0:o.wait;return!n||typeof n!="object"?null:n}function im(e){var l,d,u;const t=e,n=t==null?void 0:t.effect;if(!n||typeof n!="object"||String(n.type||"")!=="emit_event")return null;const o=String(((l=n==null?void 0:n.payload)==null?void 0:l.name)||((d=n==null?void 0:n.payload)==null?void 0:d.event_name)||"").trim();if(!o)return null;const a=(u=n==null?void 0:n.payload)==null?void 0:u.payload;return{name:o,payload:a}}function yu(e){const t=e,n=t==null?void 0:t.details;if(!n||typeof n!="object")return[];const o=n==null?void 0:n.tool_calls;return Array.isArray(o)?o:[]}function tS(e){var a,l;const t=String((e==null?void 0:e.status)||"").trim(),n=String(((a=e==null?void 0:e.effect)==null?void 0:a.type)||"").trim(),o=(l=e==null?void 0:e.effect)!=null&&l.payload&&typeof e.effect.payload=="object"?String(e.effect.payload.name||"").trim():"";return n==="emit_event"&&o?o:n||t||"record"}function uv(e){if(!e||typeof e!="object")return"Ledger record";const t=String(e.node_id||"").trim(),n=String(e.status||"").trim(),o=tS(e),a=Ui(e);if(a){const l=String(a.reason||"").trim();if(String(a.prompt||"").trim())return`${t||"node"} is waiting for a response`;if(l)return`${t||"node"} is waiting (${l})`}return e.error?`${t||"node"} failed`:n==="completed"?`${t||"node"} completed ${o}`:n==="running"?`${t||"node"} started ${o}`:n==="waiting"?`${t||"node"} is waiting`:[t,n,o].filter(Boolean).join(" · ")||"Ledger record"}function Jc(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):kr(e,320),n=typeof e.duration=="number"?Number(e.duration):-1;return{text:t,duration:n}}return{text:kr(e,320),duration:-1}}function Yd(e){var d,u,m,y,g,v,w,b,C;if(!e||typeof e!="object")return"";const t=String(((d=e==null?void 0:e.effect)==null?void 0:d.type)||"").trim(),n=e==null?void 0:e.result,o=S=>typeof S=="string"?S.trim():S==null?"":typeof S=="number"||typeof S=="boolean"?String(S):"",a=S=>{if(!S||typeof S!="object")return"";const R=S,T=[R.response,R.answer,R.message,R.text,R.content];for(const D of T){const q=o(D);if(q)return q}return""};if(t==="answer_user"){const S=o(n==null?void 0:n.message)||o((u=n==null?void 0:n.output)==null?void 0:u.message)||o((m=n==null?void 0:n.output)==null?void 0:m.response)||o((g=(y=e==null?void 0:e.effect)==null?void 0:y.payload)==null?void 0:g.message)||o((w=(v=e==null?void 0:e.effect)==null?void 0:v.payload)==null?void 0:w.text)||o((C=(b=e==null?void 0:e.effect)==null?void 0:b.payload)==null?void 0:C.content);if(S)return S}if(t==="llm_call"){const S=a(n)||o(n==null?void 0:n.output)||a(n==null?void 0:n.output)||o(n==null?void 0:n.response);if(S)return S}return o(n==null?void 0:n.output)||a(n==null?void 0:n.output)||a(n)||o(n==null?void 0:n.response)}function bm(e){var a;const t=String((e==null?void 0:e.node_id)||""),n=String((e==null?void 0:e.status)||""),o=String(((a=e==null?void 0:e.effect)==null?void 0:a.type)||"");return`${t||"(node?)"} • ${n||"(status?)"} • ${o||"(effect?)"}`}function nS(e){return!!(e&&String(e.status||"")==="waiting")}function dv(e){var n,o;const t=[];for(const a of e||[]){const l=a.record;if(String(((n=l==null?void 0:l.effect)==null?void 0:n.type)||"").trim()!=="llm_call")continue;const u=(o=l==null?void 0:l.effect)!=null&&o.payload&&typeof l.effect.payload=="object"?l.effect.payload:{},m=l!=null&&l.result&&typeof l.result=="object"?l.result:{},y=(m==null?void 0:m.usage)||(m==null?void 0:m.token_usage)||{},g=typeof u.prompt=="string"?u.prompt:Array.isArray(u.messages)?kr(u.messages,1800):"",v=typeof m.content=="string"?m.content:typeof m.response=="string"?m.response:typeof l.result=="string"?String(l.result):"",w=bn(l.started_at),b=bn(l.ended_at),C=Number(y.prompt_tokens??y.input_tokens??0)||0,S=Number(y.completion_tokens??y.output_tokens??0)||0;t.push({id:`${String(a.run_id||l.run_id||"")}:${a.cursor}`,cursor:Number(a.cursor||0),ts:String(l.ended_at||l.started_at||""),run_id:String(a.run_id||l.run_id||"").trim(),node_id:String(l.node_id||"").trim(),provider:String(u.provider||m.provider||m.runtime_provider||"").trim(),model:String(u.model||m.model||m.runtime_model||"").trim(),prompt_preview:_t(g,{max_chars:1200,max_lines:10}),response_preview:_t(v,{max_chars:1200,max_lines:10}),missing_response:!String(v||"").trim(),tokens:{prompt:C,completion:S,total:Number(y.total_tokens??C+S)||0},duration_ms:w!==null&&b!==null?Math.max(0,b-w):typeof m.gen_time=="number"?Number(m.gen_time)*1e3:null,status:String(l.status||"").trim(),error:l.error?kr(l.error,500):"",raw:l})}return t.sort((a,l)=>(bn(l.ts)??0)-(bn(a.ts)??0))}function og(e){const t=e.size||18,n=Ld(e.artifact),o=Q_(e.artifact,""),a=`artifact_glyph ${o==="code"?"code":n}`,l={width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"};return n==="image"?s.jsx("span",{className:a,children:s.jsxs("svg",{...l,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("path",{d:"M7 15l3-3 3 3 2-2 4 4"}),s.jsx("circle",{cx:"8",cy:"9",r:"1.4"})]})}):n==="audio"?s.jsx("span",{className:a,children:s.jsxs("svg",{...l,children:[s.jsx("path",{d:"M4 12h2"}),s.jsx("path",{d:"M8 8v8"}),s.jsx("path",{d:"M12 5v14"}),s.jsx("path",{d:"M16 8v8"}),s.jsx("path",{d:"M20 12h-2"})]})}):n==="video"?s.jsx("span",{className:a,children:s.jsxs("svg",{...l,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("path",{d:"M9 9l6 3-6 3V9z",fill:"currentColor",stroke:"none"})]})}):o==="code"?s.jsx("span",{className:a,children:s.jsxs("svg",{...l,children:[s.jsx("path",{d:"M8 8l-4 4 4 4"}),s.jsx("path",{d:"M16 8l4 4-4 4"}),s.jsx("path",{d:"M14 4l-4 16"})]})}):n==="text"?s.jsx("span",{className:a,children:s.jsxs("svg",{...l,children:[s.jsx("path",{d:"M7 3h7l5 5v13H7z"}),s.jsx("path",{d:"M14 3v6h6"}),s.jsx("path",{d:"M10 13h7"}),s.jsx("path",{d:"M10 17h5"})]})}):s.jsx("span",{className:a,children:s.jsxs("svg",{...l,children:[s.jsx("path",{d:"M7 3h7l5 5v13H7z"}),s.jsx("path",{d:"M14 3v6h6"}),s.jsx("path",{d:"M9 14h8"})]})})}const rS=2,sS=Number.MAX_SAFE_INTEGER;function iS(e,t=120){const n=String(e||"").replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`}function oS(e){const t=String(e||"");if(typeof DOMParser>"u")return[{kind:"text",text:Fh(t)||t}];try{const n=new DOMParser().parseFromString(t,"text/html"),o=[];n.doctype&&o.push({kind:"doctype",name:n.doctype.name||"html"});const a=l=>{if(l.nodeType===Node.TEXT_NODE){const d=String(l.textContent||"").trim();return d?{kind:"text",text:d}:null}if(l.nodeType===Node.COMMENT_NODE)return{kind:"comment",text:String(l.textContent||"")};if(l.nodeType===Node.ELEMENT_NODE){const d=l,u=Array.from(d.attributes||[]).map(y=>({name:y.name,value:y.value})),m=Array.from(d.childNodes||[]).map(a).filter(Boolean);return{kind:"element",tag:d.tagName.toLowerCase(),attrs:u,children:m}}return null};if(n.documentElement){const l=a(n.documentElement);l&&o.push(l)}return o.length?o:[{kind:"text",text:Fh(t)||t}]}catch{return[{kind:"text",text:Fh(t)||t}]}}function Bh(e){return e.closing?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"runtime_html_punct",children:"</"}),s.jsx("span",{className:"runtime_html_tag",children:e.tag}),s.jsx("span",{className:"runtime_html_punct",children:">"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"runtime_html_punct",children:"<"}),s.jsx("span",{className:"runtime_html_tag",children:e.tag}),e.attrs.map(t=>s.jsxs(ye.Fragment,{children:[" ",s.jsx("span",{className:"runtime_html_attr",children:t.name}),s.jsx("span",{className:"runtime_html_punct",children:"="}),s.jsxs("span",{className:"runtime_html_value",children:['"',t.value,'"']})]},`${e.tag}:${t.name}:${t.value}`)),s.jsx("span",{className:"runtime_html_punct",children:e.selfClosing?" />":">"})]})}function fv(e){const t=e.node,n=e.depth*14,o=e.depth<e.collapseAfterDepth,[a,l]=h.useState(o);if(h.useEffect(()=>{l(o)},[o,e.expansionVersion]),t.kind==="doctype")return s.jsxs("div",{className:"html-tree__line",style:{paddingLeft:n},children:[s.jsx("span",{className:"runtime_html_punct",children:"<!DOCTYPE "}),s.jsx("span",{className:"runtime_html_tag",children:t.name}),s.jsx("span",{className:"runtime_html_punct",children:">"})]});if(t.kind==="comment")return s.jsx("div",{className:"html-tree__line",style:{paddingLeft:n},children:s.jsx("span",{className:"runtime_html_comment",children:`<!-- ${t.text.trim()} -->`})});if(t.kind==="text")return s.jsx("div",{className:"html-tree__line html-tree__text",style:{paddingLeft:n},children:t.text});if(!t.children.length)return s.jsx("div",{className:"html-tree__line",style:{paddingLeft:n},children:s.jsx(Bh,{tag:t.tag,attrs:t.attrs,selfClosing:!0})});const d=t.children.find(u=>u.kind==="text");return s.jsxs("details",{className:"html-tree__details",open:a,onToggle:u=>l(u.currentTarget.open),children:[s.jsxs("summary",{className:"html-tree__summary",style:{paddingLeft:n},children:[s.jsx("span",{className:"html-tree__caret","aria-hidden":"true",children:a?"▾":"▸"}),s.jsx(Bh,{tag:t.tag,attrs:t.attrs}),!a&&d?s.jsxs("span",{className:"html-tree__summary_text",children:[" ",iS(d.text)]}):null]}),a?s.jsxs("div",{className:"html-tree__children",children:[t.children.map((u,m)=>s.jsx(fv,{node:u,depth:e.depth+1,collapseAfterDepth:e.collapseAfterDepth,expansionMode:e.expansionMode,expansionVersion:e.expansionVersion},`${e.depth}:${t.kind}:${t.tag}:${m}`)),s.jsx("div",{className:"html-tree__line",style:{paddingLeft:n},children:s.jsx(Bh,{tag:t.tag,attrs:[],closing:!0})})]}):null]})}function aS(e){const t=h.useMemo(()=>oS(e.text),[e.text]),[n,o]=h.useState({mode:"folded",version:0}),a=n.mode==="unfolded"?sS:rS;h.useEffect(()=>{o(d=>({mode:"folded",version:d.version+1}))},[e.text]);const l=()=>{o(d=>({mode:d.mode==="unfolded"?"folded":"unfolded",version:d.version+1}))};return s.jsxs("div",{className:`${e.className} structured html_source_preview`,children:[s.jsx("div",{className:"html-tree__toolbar",children:s.jsx("button",{type:"button",className:"btn html-tree__toggle",onClick:l,"aria-expanded":n.mode==="unfolded",children:n.mode==="unfolded"?"Fold all":"Unfold all"})}),s.jsx("div",{className:"html-tree__tree",role:"tree","aria-label":"HTML source tree",children:t.map((d,u)=>s.jsx(fv,{node:d,depth:0,collapseAfterDepth:a,expansionMode:n.mode,expansionVersion:n.version},`root:${u}`))})]})}function lS(e){var o;const t=R0(e.text);if(!t)return s.jsx("div",{className:`${e.className} structured markdown_preview`,children:s.jsx(_i,{text:e.text})});const n=((o=t.metadata.find(a=>a.label.toLowerCase()==="title"))==null?void 0:o.value)||"";return s.jsxs("div",{className:`${e.className} structured markdown_preview artifact_markdown_report`,children:[n?s.jsx("h1",{className:"artifact_markdown_title",children:n}):null,t.metadata.length?s.jsx("dl",{className:"artifact_markdown_meta",children:t.metadata.map(a=>{const l=/^https?:\/\//i.test(a.value);return s.jsxs("div",{children:[s.jsx("dt",{children:a.label}),s.jsx("dd",{children:l?s.jsx("a",{href:a.value,target:"_blank",rel:"noreferrer",children:a.value}):a.value})]},`${a.label}:${a.value}`)})}):null,s.jsx(_i,{text:t.body||e.text})]})}function mv(e){const t=String(e.text||""),n=Pd(e.artifact,t);if(n==="json"){const o=Km(t);if(o!==null)return s.jsx("div",{className:`${e.className} structured`,children:s.jsx(os,{value:o,collapseAfterDepth:4,showCopy:!1})})}return n==="markdown"?s.jsx(lS,{text:t,className:e.className}):n==="html"?s.jsx(aS,{text:t,className:e.className}):s.jsx("pre",{className:`mono ${e.className}`,children:t})}function cS(e){const t=e.preview,n=e.artifact;return n?t.loading?s.jsx("div",{className:"runtime_inline_preview empty",children:"Loading preview…"}):t.error?s.jsx("div",{className:"runtime_inline_preview empty danger",children:t.error}):t.kind==="image"&&t.url?s.jsx("img",{className:"runtime_inline_preview media",src:t.url,alt:j_(n)}):t.kind==="audio"&&t.url?s.jsx("audio",{className:"runtime_inline_preview audio",src:t.url,controls:!0}):t.kind==="video"&&t.url?s.jsx("video",{className:"runtime_inline_preview media",src:t.url,controls:!0}):s.jsx(mv,{artifact:n,text:t.text||"Preview unavailable. Use Preview or Download.",className:"runtime_inline_preview text"}):s.jsx("div",{className:"runtime_inline_preview empty",children:"Select an artifact to preview it here."})}function rp(e){const t=e==null?void 0:e.waiting;return t&&typeof t=="object"?t:null}function hv(e){const t=rp(e);return String((t==null?void 0:t.reason)||(e==null?void 0:e.waiting_reason)||"").trim().toLowerCase()}function ag(e){return e?String(e.prompt||"").trim()||Array.isArray(e.choices)&&e.choices.length>0?!0:e.allow_free_text!==!1&&String(e.reason||"").trim().toLowerCase()==="user":!1}function uS(e){const t=e.map(n=>String((n==null?void 0:n.name)||"tool").trim()).filter(Boolean);return t.length?`${t.slice(0,3).join(", ")}${t.length>3?` +${t.length-3}`:""}`:""}function vu(e){const t=String((e==null?void 0:e.status)||"").trim().toLowerCase();if(pi(t)||t!=="waiting")return"none";const n=rp(e),o=hv(e);return yu(n).length?"tool_approval":o==="until"?"scheduled":o==="subworkflow"?"subworkflow":o==="event"?ag(n)?"user_response":"external_event":o==="user"||ag(n)?"user_response":"unknown_wait"}function _v(e){const t=rp(e),n=yu(t),o=vu(e);return o==="tool_approval"?`Tool approval: ${uS(n)||"tool call"}`:o==="user_response"?Array.isArray(t==null?void 0:t.choices)&&t.choices.length>0?"Choice required":"User response needed":o==="scheduled"?"Scheduled wait":o==="subworkflow"?"Waiting for subworkflow":o==="external_event"?"Waiting for external event":o==="unknown_wait"?"Waiting, context unclear":""}function dS(e){const t=vu(e);if(t==="tool_approval")return"Review the tool request, then approve, reject, or cancel the whole run.";if(t==="user_response")return"Answer the workflow request. Submit resumes only this wait.";if(t==="scheduled")return"No response is needed. The run resumes when the scheduled time arrives or it is manually resumed.";if(t==="subworkflow")return"No direct response is needed. Inspect the child workflow or cancel the parent run.";if(t==="external_event")return"No direct response is available here. Inspect the ledger or the event source.";if(t==="unknown_wait")return"No clear prompt was provided. Review the input and recent ledger before taking action.";const n=String((e==null?void 0:e.status)||"").trim().toLowerCase();return n==="failed"?"Open the ledger, artifacts, or logs to inspect the failure.":n==="running"?"Watch the ledger/provider traces or cancel the workflow if it should stop.":pi(n)?"Open the ledger and artifacts for the final outcome.":"Open the run to inspect current activity."}function lg(e){const t=e==null?void 0:e.error;if(!t)return"";if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}function fS(e,t={}){const n=t.now_ms??Date.now(),o=t.workflow_label??"",a=String(e.status||"unknown").trim().toLowerCase()||"unknown",l=vu(e),d=pi(a),u=Z_(e,n),m=bn(e.updated_at||e.created_at)??0,y=a==="running"&&u>=14400*1e3,g=_v(e)||lg(e)||(e.current_node?`Current node: ${e.current_node}`:a==="running"?"Running":d?"Terminal":"No current activity reported");let v="all";l==="tool_approval"?v="tool_approval":l==="user_response"?v="user_wait":l==="scheduled"||l==="subworkflow"||l==="external_event"?v="scheduled":a==="failed"?v="failed":a==="running"?v="running":d&&(v="finished");const w=l==="tool_approval"?0:l==="user_response"?1:l==="unknown_wait"?2:a==="failed"?3:y?4:a==="running"?5:l!=="none"?6:d?8:7,b=l==="tool_approval"||l==="user_response",C=l==="tool_approval"?"Open approval":l==="user_response"?"Open wait":"Open Observe",S=[e.run_id,e.workflow_id,o,e.session_id,e.parent_run_id,e.status,e.current_node,hv(e),g,lg(e)].join(" ").toLowerCase();return{run:e,run_id:String(e.run_id||"").trim(),status:a,wait_kind:l,queue:v,attention_rank:w,reason:g,expected_action:dS(e),action_label:C,search_text:S,is_terminal:d,needs_user_action:b,is_stale:y,duration_ms:u,updated_ms:m}}function mS(e,t={}){const n=t.now_ms??Date.now(),o=t.workflow_label_by_id??{};return e.map(a=>fS(a,{now_ms:n,workflow_label:o[String(a.workflow_id||"")]||String(a.workflow_id||"")}))}function hS(e){const t={attention:0,user_wait:0,tool_approval:0,running:0,failed:0,scheduled:0,finished:0,all:e.length};for(const n of e)t[n.queue]+=1,n.queue!=="finished"&&(n.needs_user_action||n.status==="failed"||n.is_stale||n.wait_kind==="unknown_wait")&&(t.attention+=1);return t}function _S(e,t){const n=t.queue,a=(t.query??"").trim().toLowerCase();return e.filter(l=>{if(n==="attention"){if(!(l.needs_user_action||l.status==="failed"||l.is_stale||l.wait_kind==="unknown_wait"))return!1}else if(n!=="all"&&l.queue!==n)return!1;return!a||l.search_text.includes(a)})}function pS(e,t){const n=[...e];return n.sort((o,a)=>{if(t==="recent")return a.updated_ms-o.updated_ms;if(t==="oldest")return o.updated_ms-a.updated_ms;if(t==="duration")return a.duration_ms-o.duration_ms;if(t==="tokens")return(Number(a.run.tokens_total||0)||0)-(Number(o.run.tokens_total||0)||0);if(t==="workflow")return String(o.run.workflow_id||"").localeCompare(String(a.run.workflow_id||""));const l=o.attention_rank-a.attention_rank;return l!==0?l:a.updated_ms-o.updated_ms}),n}function gS(e){const[t,n]=h.useState("attention"),[o,a]=h.useState(""),[l,d]=h.useState("attention"),[u,m]=h.useState(""),y=h.useMemo(()=>{const F={};for(const E of e.artifacts){const j=String(E.run_id||"").trim();j&&(F[j]=(F[j]||0)+1)}return F},[e.artifacts]),g=h.useMemo(()=>mS(e.runs,{workflow_label_by_id:e.workflow_label_by_id}),[e.runs,e.workflow_label_by_id]),v=h.useMemo(()=>hS(g),[g]),w=h.useMemo(()=>{const F=_S(g,{queue:t,query:o});return pS(F,l)},[g,t,o,l]),b=w.find(F=>String(F.run_id||"")===u)||w.find(F=>String(F.run_id||"")===e.selected_run_id)||w[0]||null,C=(b==null?void 0:b.run)||null,S=String((C==null?void 0:C.run_id)||"").trim(),R=String((C==null?void 0:C.session_id)||"").trim(),T=h.useMemo(()=>R?new Set(e.runs.filter(F=>String(F.session_id||"").trim()===R).map(F=>String(F.run_id||"").trim()).filter(Boolean)):new Set,[e.runs,R]),D=R?T.size:0,q=h.useMemo(()=>R?e.artifacts.filter(F=>String(F.session_id||"").trim()===R||T.has(String(F.run_id||"").trim())).length:0,[e.artifacts,R,T]),P=C!=null&&C.waiting&&typeof C.waiting=="object"?C.waiting:null,K=P?yu(P):[],Q=(b==null?void 0:b.reason)||(P?tp(P,K):""),Z=(b==null?void 0:b.expected_action)||(P?ov(P,K):""),ee=P?H0(P,null):"",ue=S&&y[S]||0,de=pi(C==null?void 0:C.status),pe=[{key:"attention",label:"Needs attention",count:v.attention},{key:"user_wait",label:"Needs my response",count:v.user_wait},{key:"tool_approval",label:"Tool approvals",count:v.tool_approval},{key:"running",label:"Running",count:v.running},{key:"failed",label:"Failed",count:v.failed},{key:"scheduled",label:"Scheduled/subflows",count:v.scheduled},{key:"finished",label:"Finished",count:v.finished},{key:"all",label:"All loaded",count:v.all}];return s.jsxs("div",{className:"runtime_ops_layout",children:[s.jsxs("aside",{className:"pane runtime_ops_filters",children:[s.jsxs("div",{className:"pane_header runtime_ops_filter_header",children:[s.jsx("span",{className:"pane_title",children:"Queues"}),s.jsx("div",{className:"pane_spacer"}),s.jsxs("button",{className:"btn btn_icon",onClick:e.gateway_connected?e.on_refresh_runs:e.on_reconnect,children:[s.jsx(Tn,{name:"refresh",size:14}),e.gateway_connected?"Refresh":"Reconnect"]})]}),s.jsxs("div",{className:"pane_body scroll runtime_ops_queue_list",children:[pe.map(F=>s.jsxs("button",{className:`runtime_ops_filter ${t===F.key?"selected":""}`,"aria-pressed":t===F.key,onClick:()=>n(F.key),children:[s.jsx("span",{children:F.label}),s.jsx("strong",{children:F.count.toLocaleString()})]},F.key)),s.jsx("div",{className:"runtime_ops_hint",children:"Counts are for the loaded runtime page. Refine search or refresh when supervising large runtimes."})]})]}),s.jsxs("section",{className:"pane runtime_ops_table_panel",children:[s.jsxs("div",{className:"pane_header runtime_ops_list_header",children:[s.jsx("span",{className:"pane_title",children:"Runs"}),s.jsx("span",{className:"pane_count",children:w.length.toLocaleString()}),s.jsx("div",{className:"pane_spacer"}),s.jsx("input",{value:o,onChange:F=>a(F.target.value),placeholder:"Search workflow, run, node, status, error"}),s.jsxs("select",{className:"seg_select",value:l,onChange:F=>d(F.target.value),children:[s.jsx("option",{value:"attention",children:"Attention order"}),s.jsx("option",{value:"recent",children:"Latest event"}),s.jsx("option",{value:"oldest",children:"Oldest event"}),s.jsx("option",{value:"duration",children:"Longest duration"}),s.jsx("option",{value:"tokens",children:"Most tokens"}),s.jsx("option",{value:"workflow",children:"Workflow"})]})]}),s.jsxs("div",{className:"pane_body scroll runtime_ops_rows",children:[w.length?null:s.jsx("div",{className:"runtime_ops_empty",children:e.gateway_connected?"No runs match this queue.":"Gateway offline. Runtime activity cannot be loaded until the connection is restored."}),w.map(F=>{const E=F.run,j=String(E.run_id||"").trim(),L=y[j]||0;return s.jsxs("div",{className:`raised runtime_ops_row ${j===S?"selected":""}`,"aria-current":j===S?"true":void 0,tabIndex:0,onClick:()=>{m(j),e.on_select_run(j)},onKeyDown:z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),m(j),e.on_select_run(j))},children:[s.jsxs("div",{className:"runtime_ops_row_top",children:[s.jsx("strong",{className:"runtime_ops_row_name",children:qs(E,e.workflow_label_by_id)}),F.is_stale?s.jsx("span",{className:"chip warn",children:"stale"}):null,s.jsx(Qa,{status:E.status})]}),s.jsxs("div",{className:"runtime_ops_row_sub",children:[s.jsx("span",{className:"mono",children:$t(j,18)}),s.jsx("span",{children:Yo(E.updated_at||E.created_at)}),s.jsx("span",{children:rc(E)}),s.jsx("span",{className:"runtime_ops_row_reason",title:F.reason,children:F.reason})]}),s.jsxs("div",{className:"runtime_ops_row_foot",children:[s.jsxs("span",{className:"runtime_ops_row_facts",children:[s.jsxs("span",{children:[Number(E.llm_calls||0).toLocaleString()," llm"]}),s.jsxs("span",{children:[Number(E.tool_calls||0).toLocaleString()," tools"]}),s.jsxs("span",{children:[Number(E.tokens_total||0).toLocaleString()," tok"]}),s.jsxs("span",{children:[L.toLocaleString()," artifacts"]})]}),s.jsxs("div",{className:"runtime_ops_actions",children:[F.needs_user_action?s.jsx("button",{className:"btn primary",onClick:z=>{z.stopPropagation(),e.on_open_run(j)},children:F.action_label}):s.jsx("button",{className:"btn",onClick:z=>{z.stopPropagation(),e.on_open_run(j)},children:"Open"}),s.jsx("button",{className:"btn",onClick:z=>{z.stopPropagation(),e.on_open_ledger(j)},children:"Ledger"}),s.jsx("button",{className:"btn",onClick:z=>{z.stopPropagation(),e.on_select_run(j),e.on_open_logs()},children:"Logs"}),s.jsx("button",{className:"btn",onClick:z=>{z.stopPropagation(),e.on_filter_artifacts(j)},children:"Artifacts"})]})]})]},j)})]})]}),s.jsxs("aside",{className:"pane runtime_ops_inspector",children:[s.jsxs("div",{className:"pane_header",children:[s.jsx("span",{className:"pane_title",children:"Run inspector"}),C?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pane_spacer"}),s.jsx(Qa,{status:C.status})]}):null]}),s.jsx("div",{className:"pane_body scroll runtime_ops_inspector_body",children:C?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"runtime_ops_inspector_head",children:[s.jsx("h3",{children:qs(C,e.workflow_label_by_id)}),s.jsx("span",{className:"mono",children:$t(S,28)})]}),s.jsxs("div",{className:"runtime_ops_decision",children:[s.jsx("strong",{children:(b==null?void 0:b.reason)||V0(C)}),s.jsx("span",{children:(b==null?void 0:b.expected_action)||(String(C.status||"").toLowerCase()==="waiting"?"This run is paused until the pending wait is resolved or the run is cancelled.":de?"This run is terminal. Open the ledger for the narrative and final error/output.":"This run is active or recently updated. Use ledger/provider logs to inspect live work.")})]}),s.jsxs("div",{className:"artifact_detail_grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Started"}),s.jsx("strong",{children:Jo(Kl(C))})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Elapsed"}),s.jsx("strong",{children:rc(C)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Last event"}),s.jsx("strong",{children:Jo(C.updated_at||C.created_at)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Session"}),s.jsx("strong",{className:"mono",children:C.session_id?$t(String(C.session_id),18):"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Node"}),s.jsx("strong",{className:"mono",children:C.current_node||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Visible artifacts"}),s.jsx("strong",{children:ue.toLocaleString()})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Provider calls"}),s.jsx("strong",{children:Number(C.llm_calls||0).toLocaleString()})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Tokens"}),s.jsx("strong",{children:Number(C.tokens_total||0).toLocaleString()})]})]}),R?s.jsxs("section",{className:"runtime_ops_session_context",children:[s.jsxs("div",{children:[s.jsx("span",{className:"run_hero_eyebrow",children:"Session context"}),s.jsx("strong",{className:"mono",children:$t(R,30)})]}),s.jsxs("div",{className:"runtime_ops_session_facts",children:[s.jsxs("span",{children:[D.toLocaleString()," loaded run",D===1?"":"s"]}),s.jsxs("span",{children:[q.toLocaleString()," visible artifact",q===1?"":"s"]})]}),s.jsxs("div",{className:"runtime_detail_actions compact",children:[s.jsx("button",{className:"btn",onClick:()=>e.on_filter_session_artifacts(R),children:"Open session artifacts"}),s.jsx("button",{className:"btn",onClick:()=>void nc(R),children:"Copy session id"})]})]}):null,P?s.jsxs("div",{className:"runtime_ops_wait_summary",children:[s.jsxs("div",{className:"runtime_ops_wait_header",children:[s.jsx("span",{className:"run_hero_eyebrow",children:"Blocked on"}),s.jsx("strong",{children:Q})]}),s.jsx("p",{children:Z}),ee?s.jsxs("div",{className:"runtime_ops_wait_request",children:[s.jsx("span",{children:"Request"}),s.jsx(_i,{text:ee})]}):s.jsx("div",{className:"runtime_ops_wait_request muted",children:"No explicit prompt is attached to this wait. Open Observe or the ledger for full run context before responding."}),K.length?s.jsx("div",{className:"runtime_ops_wait_tools",children:K.map((F,E)=>s.jsxs(ye.Fragment,{children:[s.jsx("span",{className:"chip mono warn",children:String((F==null?void 0:F.name)||"tool")}),iv(F).map(j=>s.jsxs("span",{className:"chip muted",title:sv,children:[j,"~"]},`${E}:${j}`))]},`${String((F==null?void 0:F.name)||"tool")}:${E}`))}):null,s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"muted",children:"Raw wait payload"}),s.jsx(os,{value:P,collapseAfterDepth:3,showCopy:!0})]})]}):null,Rm(C)?s.jsx("div",{className:"warn_callout",children:Rm(C)}):null,s.jsxs("div",{className:"runtime_detail_actions",children:[s.jsx("button",{className:"btn primary",onClick:()=>e.on_open_run(S),children:"Open Observe"}),s.jsx("button",{className:"btn",onClick:()=>e.on_open_ledger(S),children:"Open ledger"}),s.jsx("button",{className:"btn",onClick:()=>e.on_filter_artifacts(S),children:"Open artifacts"}),s.jsx("button",{className:"btn",onClick:e.on_open_logs,children:"Open logs"}),s.jsx("button",{className:"btn",onClick:()=>void nc(S),children:"Copy run id"})]})]}):s.jsx("div",{className:"empty_state_inline",children:"Select a run to inspect why it is active or blocked."})})]})]})}function yS(e){const t=e.selected_artifact,n=["voice","music","sound","recording","audio","image","video","markdown","html","json","document","code","text","other"],o=[{value:"all",label:"Any time"},{value:"hour",label:"Last hour"},{value:"today",label:"Today"},{value:"week",label:"7 days"},{value:"month",label:"30 days"}],a=h.useMemo(()=>new Set(e.type_filters),[e.type_filters]),l=Math.max(0,Number(e.artifact_total_count||0)),d=!!e.query.trim()||e.type_filters.length>0||e.date_filter!=="all"||e.scope!=="all"||!!e.artifact_run_filter.trim(),u=Math.max(1,Number(e.artifact_page_size||500)),m=Math.max(1,Math.ceil(l/u)),y=Math.min(Math.max(0,Number(e.artifact_page||0)),m-1),g=l?y*u+1:0,v=Math.min(l,y*u+e.artifacts.length),w=h.useMemo(()=>{const E={},j=e.artifact_type_facets&&Object.keys(e.artifact_type_facets).length?e.artifact_type_facets:e.artifact_facets,L=(j==null?void 0:j.semantic_kind)||{},z=(j==null?void 0:j.render_kind)||{};for(const te of n)E[te]=Number(L[te]||z[te]||0);return E.audio=Number(L.audio||0),E.other=Number(L.other||0)+Number(L.artifact||0)+Number(L.binary||0)+Number(L["(none)"]||0),E},[e.artifact_facets,e.artifact_type_facets]),b=E=>{const j=new Set(a);j.has(E)?j.delete(E):j.add(E),e.on_type_filters_change(Array.from(j.values()))},C=h.useMemo(()=>{const E={waiting:[],running:[],failed:[],cancelled:[],completed:[],other:[]};for(const j of e.runs){const L=String(j.status||"").trim().toLowerCase();L==="waiting"?E.waiting.push(j):L==="running"?E.running.push(j):L==="failed"?E.failed.push(j):L==="cancelled"?E.cancelled.push(j):L==="completed"?E.completed.push(j):E.other.push(j)}return E},[e.runs]),S=t!=null&&t.run_id&&e.run_by_id[t.run_id]||null,R=e.artifact_run_filter?qs(e.run_by_id[e.artifact_run_filter],e.workflow_label_by_id):"",T=h.useMemo(()=>{var L;const E=new Set,j=((L=e.artifact_facets)==null?void 0:L.run_id)||{};for(const z of Object.keys(j))z&&z!=="(none)"&&E.add(z);for(const z of e.artifacts)z.run_id&&E.add(z.run_id);for(const z of e.active_runs)z.run_id&&E.add(String(z.run_id));return Array.from(E).map(z=>e.run_by_id[z]||{run_id:z,workflow_id:null,status:"",created_at:null,updated_at:null}).sort((z,te)=>{const I=au(z.status)?0:1,O=au(te.status)?0:1;if(I!==O)return I-O;const G=bn(z.updated_at||z.created_at)??0;return(bn(te.updated_at||te.created_at)??0)-G}).slice(0,160)},[e.artifacts,e.active_runs,e.run_by_id,e.artifact_facets]),D=E=>{e.on_artifact_run_filter_change(E),e.on_session_filter_change(""),e.on_scope_change(E?"run":"all")},q=E=>e.gateway_connected?Math.max(0,Number(E||0)).toLocaleString():"—",P=e.selected_run_id&&e.run_by_id[e.selected_run_id]||null,K=h.useMemo(()=>{const E=e.runtime_log_query.trim().toLowerCase(),j=e.runtime_ledger_log_items||[];return E?j.filter(L=>{var I,O;const z=L.record||{};return[L.cursor,z.run_id,z.node_id,z.status,(I=z.effect)==null?void 0:I.type,z.started_at,z.ended_at,kr(((O=z.effect)==null?void 0:O.payload)??{},900),kr(z.result??{},900)].join(" ").toLowerCase().includes(E)}):j},[e.runtime_ledger_log_items,e.runtime_log_query]),Q=h.useMemo(()=>{const E=e.runtime_log_query.trim().toLowerCase(),j=dv(e.runtime_ledger_log_items);return E?j.filter(L=>[L.provider,L.model,L.run_id,L.node_id,L.status,L.error,L.prompt_preview,L.response_preview,L.tokens.prompt,L.tokens.completion,L.tokens.total].join(" ").toLowerCase().includes(E)):j},[e.runtime_ledger_log_items,e.runtime_log_query]),Z=Q.reduce((E,j)=>E+(Number(j.tokens.total)||0),0),ee=Q.filter(E=>E.missing_response||E.error).length,ue=h.useMemo(()=>{const E=e.runtime_log_query.trim().toLowerCase(),j=String(e.audit_log_text||"").replace(/\r\n/g,`
|
|
97
|
+
`).replace(/\r/g,`
|
|
98
|
+
`).split(`
|
|
99
|
+
`).filter(Boolean);return E?j.filter(L=>L.toLowerCase().includes(E)):j},[e.audit_log_text,e.runtime_log_query]),de=e.runtime_log_source==="run_ledger"||e.runtime_log_source==="provider_calls",pe=e.runtime_log_source==="run_ledger"?"Selected Run Ledger":e.runtime_log_source==="provider_calls"?"Provider Calls":"Gateway HTTP Audit",F=e.runtime_log_source==="run_ledger"?"Runtime execution records for the selected workflow run.":e.runtime_log_source==="provider_calls"?"Model/provider call records extracted from the selected run ledger.":"Global Gateway HTTP/audit tail. This is system activity, not artifact provenance.";return s.jsxs("div",{className:"page runtime_page",children:[s.jsxs("section",{className:"runtime_header",children:[s.jsxs("div",{children:[s.jsx("div",{className:"run_hero_eyebrow",children:"System"}),s.jsx("h2",{children:e.tab==="activity"?"Activity monitor":e.tab==="artifacts"?"Artifact explorer":e.tab==="memory"?"Active memory":"Logs"}),s.jsxs("div",{className:"run_hero_meta",children:[s.jsx("span",{className:`status_pill ${e.gateway_connected?"ok":"warn"}`,children:e.gateway_connected?"gateway connected":"gateway offline"}),e.tab==="artifacts"&&e.artifact_run_filter?s.jsxs("span",{className:"chip muted",children:["filtered run ",s.jsx("span",{className:"mono",children:$t(e.artifact_run_filter,18)})]}):null,e.session_id?s.jsxs("span",{className:"chip muted",children:["session ",s.jsx("span",{className:"mono",children:$t(e.session_id,18)})]}):null]})]}),s.jsxs("div",{className:"metric_grid compact runtime_header_metrics",children:[s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Waiting"}),s.jsx("strong",{children:q(C.waiting.length)})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Running"}),s.jsx("strong",{children:q(C.running.length)})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Failed"}),s.jsx("strong",{children:q(C.failed.length)})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsxs("span",{children:["Artifacts",d?" (filtered)":""]}),s.jsx("strong",{children:q(l)})]})]})]}),s.jsx("nav",{className:"runtime_mode_tabs",role:"tablist","aria-label":"System sections",children:["activity","artifacts","memory","logs"].map(E=>s.jsxs("button",{role:"tab","aria-selected":e.tab===E,className:`runtime_mode_tab ${e.tab===E?"active":""}`,onClick:()=>e.on_tab_change(E),children:[s.jsx(Tn,{name:E==="activity"?"history":E==="artifacts"?"download":E==="memory"?"agent":"terminal",size:14}),s.jsx("span",{children:E==="activity"?"Activity":E==="artifacts"?"Artifacts":E==="memory"?"Memory":"Logs"})]},E))}),e.gateway_connected?null:s.jsxs("div",{className:"runtime_offline_banner",role:"status",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Gateway offline"}),s.jsx("span",{children:"Activity, artifacts, memory, and logs are unavailable until the gateway reconnects."})]}),s.jsxs("div",{children:[s.jsx("button",{className:"btn primary",onClick:e.on_reconnect,children:"Reconnect"}),s.jsx("button",{className:"btn",onClick:e.on_open_settings,children:"Settings"})]})]}),e.error?s.jsx("div",{className:"warn_callout",children:e.error}):null,e.tab==="activity"?s.jsx(gS,{gateway_connected:e.gateway_connected,runs:e.runs,artifacts:e.artifacts,selected_run_id:e.selected_run_id,workflow_label_by_id:e.workflow_label_by_id,on_select_run:e.on_select_run,on_open_run:e.on_open_run,on_open_ledger:e.on_open_ledger,on_refresh_runs:e.on_refresh_runs,on_reconnect:e.on_reconnect,on_open_logs:()=>e.on_tab_change("logs"),on_filter_artifacts:E=>{D(E),e.on_select_run(E),e.on_tab_change("artifacts")},on_filter_session_artifacts:E=>{E&&(e.on_artifact_run_filter_change(""),e.on_session_filter_change(E),e.on_scope_change("session"),e.on_tab_change("artifacts"))}}):null,e.tab==="memory"?e.memory_panel?s.jsx("div",{className:"runtime_memory_panel",children:e.memory_panel}):s.jsx("div",{className:"empty_state_inline",children:"The memory explorer needs a gateway connection — sign in to browse knowledge-graph assertions."}):null,e.tab==="artifacts"?s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"pane runtime_artifact_toolbar","aria-label":"Find artifacts",children:[s.jsxs("div",{className:"runtime_artifact_toolbar_top",children:[s.jsxs("label",{className:"artifact_filter_field artifact_filter_search",children:[s.jsx("span",{children:"Search"}),s.jsx("input",{value:e.query,onChange:E=>e.on_query_change(E.target.value),placeholder:"title, path, hash, run, workflow, tag"})]}),s.jsxs("label",{className:"artifact_filter_field",children:[s.jsx("span",{children:"Scope"}),s.jsxs("select",{className:"seg_select",value:e.scope,onChange:E=>{const j=E.target.value;j!=="run"&&e.on_artifact_run_filter_change(""),j==="session"?e.on_session_filter_change(e.session_id):e.on_session_filter_change(""),e.on_scope_change(j)},children:[s.jsx("option",{value:"all",children:"All runtime"}),s.jsx("option",{value:"session",children:"This session"}),s.jsx("option",{value:"run",children:"Selected run"})]})]}),s.jsxs("label",{className:"artifact_filter_field",children:[s.jsx("span",{children:"Group"}),s.jsxs("select",{className:"seg_select",value:e.group_by,onChange:E=>e.on_group_by_change(E.target.value),children:[s.jsx("option",{value:"type",children:"Type"}),s.jsx("option",{value:"time",children:"Date"}),s.jsx("option",{value:"turn",children:"Turn"}),s.jsx("option",{value:"node",children:"Node"}),s.jsx("option",{value:"workflow",children:"Workflow"}),s.jsx("option",{value:"run",children:"Run"}),s.jsx("option",{value:"location",children:"Location"}),s.jsx("option",{value:"source",children:"Source"})]})]}),s.jsxs("label",{className:"artifact_filter_field",children:[s.jsx("span",{children:"Sort"}),s.jsxs("select",{className:"seg_select",value:e.sort_by,onChange:E=>e.on_sort_by_change(E.target.value),children:[s.jsx("option",{value:"newest",children:"Newest"}),s.jsx("option",{value:"oldest",children:"Oldest"}),s.jsx("option",{value:"last_access",children:"Last accessed"}),s.jsx("option",{value:"turn",children:"Turn order"}),s.jsx("option",{value:"type",children:"Type"}),s.jsx("option",{value:"size_desc",children:"Largest"}),s.jsx("option",{value:"size_asc",children:"Smallest"})]})]}),s.jsxs("button",{className:"btn btn_icon",onClick:e.on_refresh_artifacts,disabled:!e.gateway_connected||e.loading,children:[s.jsx(Tn,{name:"refresh",size:14}),e.loading?"Loading…":"Refresh"]})]}),s.jsxs("div",{className:"artifact_filter_section",children:[s.jsxs("div",{className:"artifact_filter_label",children:["Type ",s.jsx("span",{className:"muted",children:"OR"})]}),s.jsxs("div",{className:"artifact_filter_chips",role:"group","aria-label":"Artifact type filters combine with OR",children:[n.map(E=>{const j=a.has(E),L=w[E]||0,z=X0(E);return s.jsxs("button",{type:"button","aria-pressed":j,"aria-label":`${j?"Remove":"Add"} ${z} artifact type filter. Type filters combine with OR.`,title:`${j?"Remove":"Add"} ${z}. Type filters combine with OR.`,className:`artifact_filter_chip ${j?"active":""}`,onClick:()=>b(E),children:[s.jsx("span",{children:z}),s.jsx("span",{className:"artifact_chip_count",children:e.gateway_connected?L.toLocaleString():"—"})]},E)}),e.type_filters.length?s.jsx("button",{type:"button",className:"artifact_filter_chip clear",onClick:()=>e.on_type_filters_change([]),children:"Clear types"}):null]})]}),s.jsxs("div",{className:"artifact_filter_section",children:[s.jsx("div",{className:"artifact_filter_label",children:"Date"}),s.jsx("div",{className:"artifact_filter_chips",role:"group","aria-label":"Artifact date filters",children:o.map(E=>s.jsx("button",{type:"button","aria-pressed":e.date_filter===E.value,className:`artifact_filter_chip ${e.date_filter===E.value?"active":""}`,onClick:()=>e.on_date_filter_change(E.value),children:E.label},E.value))})]})]}),s.jsx("div",{className:"artifact_scope_banner",children:e.artifact_run_filter?s.jsxs(s.Fragment,{children:["Showing artifacts for ",s.jsx("strong",{children:R||$t(e.artifact_run_filter,18)}),".",s.jsx("button",{className:"btn",onClick:()=>D(""),children:"Show all"})]}):s.jsxs(s.Fragment,{children:["Showing artifacts across the selected runtime scope. Select a run to filter the inventory. ",e.artifact_total_bytes?s.jsxs("span",{className:"mono muted",children:["Total size ",Yl(e.artifact_total_bytes)]}):null]})}),s.jsxs("div",{className:"runtime_artifacts_layout",children:[s.jsxs("aside",{className:"pane artifact_filter_rail",children:[s.jsxs("div",{className:"pane_header",children:[s.jsx("span",{className:"pane_title",children:"Runs"}),s.jsx("span",{className:"pane_count",children:T.length.toLocaleString()})]}),s.jsxs("div",{className:"pane_body scroll artifact_filter_rail_list",children:[s.jsxs("button",{className:`artifact_filter_run ${e.artifact_run_filter?"":"selected"}`,onClick:()=>D(""),children:[s.jsx("strong",{children:"All artifacts"}),s.jsx("span",{children:e.gateway_connected?`${l.toLocaleString()} match${l===1?"":"es"}`:"counts unavailable"})]}),T.map(E=>{const j=String(E.run_id||"").trim(),L=j===e.artifact_run_filter||j===(t==null?void 0:t.run_id);return s.jsxs("button",{className:`artifact_filter_run ${L?"selected":""}`,onClick:()=>D(j),title:j,children:[s.jsx("strong",{children:qs(E,e.workflow_label_by_id)}),s.jsx("span",{className:"mono",children:$t(j,15)}),s.jsx("span",{children:rc(E)})]},j)})]})]}),s.jsxs("section",{className:"pane runtime_artifact_browser",children:[s.jsxs("div",{className:"pane_header artifact_browser_header",children:[s.jsx("span",{className:"pane_title",children:"Artifacts"}),s.jsx("span",{className:"pane_count",children:l?`${g.toLocaleString()}-${v.toLocaleString()} of ${l.toLocaleString()}`:"0 items"}),s.jsx("div",{className:"pane_spacer"}),m>1?s.jsxs("div",{className:"artifact_pagination","aria-label":"Artifact pages",children:[s.jsx("button",{className:"btn",onClick:()=>e.on_artifact_page_change(0),disabled:y<=0,children:"First"}),s.jsx("button",{className:"btn",onClick:()=>e.on_artifact_page_change(y-1),disabled:y<=0,children:"Prev"}),s.jsxs("span",{className:"muted artifact_page_label",children:["Page ",(y+1).toLocaleString()," / ",m.toLocaleString()]}),s.jsx("button",{className:"btn",onClick:()=>e.on_artifact_page_change(y+1),disabled:y>=m-1,children:"Next"}),s.jsx("button",{className:"btn",onClick:()=>e.on_artifact_page_change(m-1),disabled:y>=m-1,children:"Last"})]}):null]}),s.jsxs("div",{className:"pane_body scroll artifact_browser_body",children:[e.artifact_groups.length?null:s.jsx("div",{className:"empty_state_inline",children:e.gateway_connected?"No artifacts match the current filters.":"Gateway offline. Artifact inventory cannot be loaded until the connection is restored."}),s.jsx("div",{className:"artifact_group_list",children:e.artifact_groups.map(E=>s.jsxs("section",{className:"artifact_group",children:[s.jsxs("div",{className:"artifact_group_header",children:[s.jsx("span",{children:E.key}),s.jsx("span",{className:"artifact_group_count",children:E.items.length})]}),E.items.map(j=>{var O;const L=j.run_id&&e.run_by_id[j.run_id]||null,z=L?qs(L,e.workflow_label_by_id):np(j),te=sg(j),I=Number(((O=j.access)==null?void 0:O.access_count)||0)||0;return s.jsxs("button",{className:`artifact_row ${(t==null?void 0:t.artifact_id)===j.artifact_id?"selected":""}`,onClick:()=>{e.on_select_artifact(j.artifact_id),j.run_id&&e.on_select_run(j.run_id)},title:j.artifact_id,children:[s.jsx(og,{artifact:j,size:18}),s.jsxs("div",{className:"artifact_row_main",children:[s.jsxs("div",{className:"artifact_row_title",children:[s.jsx("strong",{children:rg(Lm(j,e.run_by_id,e.workflow_label_by_id))}),s.jsx("span",{className:"artifact_type_badge",children:cu(j)}),j.render_kind&&j.render_kind!==j.semantic_kind?s.jsx("span",{className:"artifact_type_badge muted",children:j.render_kind}):null,j.legacy_inferred?s.jsx("span",{className:"artifact_type_badge inferred",children:"legacy inferred"}):null]}),s.jsxs("div",{className:"artifact_row_facts",children:[s.jsxs("span",{children:[s.jsx("b",{children:"Created"})," ",Q0(j)]}),s.jsxs("span",{children:[s.jsx("b",{children:"Size"})," ",Yl(j.size_bytes)]}),s.jsxs("span",{children:[s.jsx("b",{children:"Last seen"})," ",ng(j)]}),I?s.jsxs("span",{children:[s.jsx("b",{children:"Accesses"})," ",I.toLocaleString()]}):null,te?s.jsxs("span",{children:[s.jsx("b",{children:"Media"})," ",te]}):null,j.content_type?s.jsxs("span",{children:[s.jsx("b",{children:"MIME"})," ",j.content_type]}):null]}),s.jsxs("div",{className:"artifact_row_facts secondary",children:[z?s.jsxs("span",{children:[s.jsx("b",{children:"Workflow"})," ",z]}):null,j.run_id?s.jsxs("span",{className:"mono",children:[s.jsx("b",{children:"Run"})," ",$t(j.run_id,13)]}):null,s.jsxs("span",{children:[s.jsx("b",{children:"Turn"})," ",k_(j)]}),lu(j)?s.jsxs("span",{className:"mono",children:[s.jsx("b",{children:"Node"})," ",lu(j)]}):null,Od(j)?s.jsxs("span",{children:[s.jsx("b",{children:"Source"})," ",Od(j)]}):null]}),s.jsxs("div",{className:"artifact_row_facts tertiary",children:[s.jsxs("span",{className:"mono",children:[s.jsx("b",{children:"ID"})," ",$t(j.artifact_id,22)]}),s.jsxs("span",{children:[s.jsx("b",{children:"Provenance"})," ",eg(j)]})]}),ig(j)?s.jsx("div",{className:"artifact_row_path mono",children:ig(j)}):null]})]},j.artifact_id)})]},E.key))})]})]}),s.jsx("aside",{className:"runtime_detail",children:s.jsxs("section",{className:"overview_panel runtime_artifact_detail",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Artifact Detail"}),t?s.jsx("span",{className:"chip mono muted",children:e.embedded_preview.render_kind?N_(t,e.run_by_id,e.workflow_label_by_id,e.embedded_preview.text):N_(t,e.run_by_id,e.workflow_label_by_id)}):null]}),t?s.jsxs(s.Fragment,{children:[(()=>{var O,G,$,Y,se,le,he;const E=eS(t),j=cv(t),L=sg(t),z=Number(((O=t.access)==null?void 0:O.access_count)||0)||0,te=rn((G=t.links)==null?void 0:G.provider_trace,($=t.links)==null?void 0:$.provider_trace_url,(Y=t.links)==null?void 0:Y.provider_trace_id),I=rn((se=t.links)==null?void 0:se.audit,(le=t.links)==null?void 0:le.audit_tail,(he=t.links)==null?void 0:he.audit_url);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"artifact_detail_header",children:[s.jsx(og,{artifact:t,size:22}),s.jsxs("div",{children:[s.jsx("div",{className:"artifact_detail_title",children:rg(Lm(t,e.run_by_id,e.workflow_label_by_id))}),s.jsxs("div",{className:"artifact_detail_subtitle",children:[cu(t)," • ",t.render_kind||e.embedded_preview.render_kind||t.modality||"artifact"," • ",t.content_type||"unknown MIME"," • ",Yl(t.size_bytes),t.legacy_inferred?" • legacy inferred":""]})]})]}),s.jsx(cS,{artifact:t,preview:e.embedded_preview}),s.jsxs("div",{className:"artifact_detail_grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Semantic type"}),s.jsx("strong",{children:cu(t)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Render kind"}),s.jsx("strong",{children:t.render_kind||e.embedded_preview.render_kind||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Created"}),s.jsx("strong",{children:Jo(t.created_at)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Size"}),s.jsx("strong",{children:Yl(t.size_bytes)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Last seen"}),s.jsx("strong",{children:ng(t)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Accesses"}),s.jsx("strong",{children:z?z.toLocaleString():"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Run"}),s.jsx("strong",{className:"mono",children:t.run_id?$t(t.run_id,24):"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Workflow"}),s.jsx("strong",{children:S?qs(S,e.workflow_label_by_id):"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Turn"}),s.jsx("strong",{children:k_(t)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Node"}),s.jsx("strong",{className:"mono",children:lu(t)||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Provider/model"}),s.jsx("strong",{children:j||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Media facts"}),s.jsx("strong",{children:L||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Trace"}),s.jsx("strong",{children:t.provider_trace_available?"available":"not recorded"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Provenance"}),s.jsx("strong",{children:eg(t)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Artifact id"}),s.jsx("strong",{className:"mono",children:$t(t.artifact_id,30)})]}),t.sha256?s.jsxs("div",{children:[s.jsx("span",{children:"sha256"}),s.jsx("strong",{className:"mono",children:$t(t.sha256,30)})]}):null]}),E?s.jsxs("div",{className:"artifact_provenance_panel",children:[s.jsx("div",{className:"artifact_filter_label",children:"Generation prompt / input"}),s.jsx("div",{className:"artifact_prompt_text",children:E})]}):s.jsxs("div",{className:"artifact_provenance_panel muted",children:[s.jsx("div",{className:"artifact_filter_label",children:"Generation prompt / input"}),s.jsx("div",{className:"artifact_prompt_text",children:"Generation prompt not recorded by the runtime artifact descriptor."})]}),Object.keys(t.generation||{}).length||Object.keys(t.producer||{}).length?s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Generation and producer metadata"}),s.jsx(os,{value:{generation:t.generation,producer:t.producer,source_refs:t.source_refs},collapseAfterDepth:3,showCopy:!0})]}):null,t.source_path?s.jsx("div",{className:"artifact_detail_path mono",children:t.source_path}):null,s.jsxs("div",{className:"runtime_detail_actions",children:[s.jsx("button",{className:"btn primary",onClick:()=>e.on_preview_artifact(t),disabled:!t.run_id,children:e.embedded_preview.render_kind==="html"?"Open as web page":"Open full preview"}),s.jsx("button",{className:"btn",onClick:()=>e.on_download_artifact(t),disabled:!t.run_id,children:"Download"}),s.jsx("button",{className:"btn",onClick:()=>D(t.run_id),disabled:!t.run_id,children:"Show run artifacts"}),s.jsx("button",{className:"btn",onClick:()=>e.on_open_run(t.run_id),disabled:!t.run_id,children:"Open in Observe"}),s.jsx("button",{className:"btn",onClick:()=>e.on_open_ledger(t.run_id),disabled:!t.run_id,children:"Open run ledger"}),s.jsx("button",{className:"btn",onClick:()=>{te&&window.open(te,"_blank","noopener,noreferrer")},disabled:!te,children:"Open provider trace"}),s.jsx("button",{className:"btn",onClick:()=>{I?window.open(I,"_blank","noopener,noreferrer"):e.on_tab_change("logs")},disabled:!I&&!t.audit_available,children:"Open audit trail"}),s.jsx("button",{className:"btn",onClick:()=>void nc(t.artifact_id),disabled:!t.artifact_id,children:"Copy artifact id"})]})]})})(),s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Raw metadata"}),s.jsx(os,{value:t.raw,collapseAfterDepth:3,showCopy:!0})]})]}):s.jsx("div",{className:"empty_state_inline",children:"Select an artifact to inspect metadata, preview, or download content."})]})})]})]}):null,e.tab==="logs"?s.jsxs("section",{className:"overview_panel runtime_logs_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:pe}),s.jsx("div",{className:"mono muted",children:F})]}),s.jsxs("div",{className:"actions",style:{marginTop:0},children:[de&&e.runtime_ledger_log_meta?s.jsx("span",{className:"mono muted",children:e.runtime_ledger_log_meta}):null,e.runtime_log_source==="gateway_audit"&&e.audit_log_meta?s.jsx("span",{className:"mono muted",children:e.audit_log_meta}):null,s.jsxs("button",{className:"btn btn_icon",onClick:()=>{de?e.on_refresh_runtime_ledger(e.selected_run_id):e.on_refresh_audit()},disabled:de?e.runtime_ledger_log_loading:e.audit_log_loading,children:[s.jsx(Tn,{name:"refresh",size:14}),de?e.runtime_ledger_log_loading?"Loading…":"Refresh":e.audit_log_loading?"Loading…":"Refresh"]})]})]}),s.jsxs("div",{className:"runtime_log_toolbar",children:[s.jsxs("div",{className:"seg_toggle mono",children:[s.jsx("button",{className:`seg_btn ${e.runtime_log_source==="run_ledger"?"active":""}`,onClick:()=>e.on_runtime_log_source_change("run_ledger"),children:"Run ledger"}),s.jsx("button",{className:`seg_btn ${e.runtime_log_source==="provider_calls"?"active":""}`,onClick:()=>e.on_runtime_log_source_change("provider_calls"),children:"Provider calls"}),s.jsx("button",{className:`seg_btn ${e.runtime_log_source==="gateway_audit"?"active":""}`,onClick:()=>e.on_runtime_log_source_change("gateway_audit"),children:"Gateway audit"})]}),s.jsx("input",{className:"mono",value:e.runtime_log_query,onChange:E=>e.on_runtime_log_query_change(E.target.value),placeholder:"Search node, status, effect, payload, error"})]}),e.runtime_log_source==="run_ledger"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"runtime_log_context",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Selected run"}),s.jsx("strong",{children:P?qs(P,e.workflow_label_by_id):e.selected_run_id?$t(e.selected_run_id,24):"No run selected"}),e.selected_run_id?s.jsx("em",{className:"mono",children:$t(e.selected_run_id,34)}):null]}),s.jsxs("div",{children:[s.jsx("span",{children:"Session"}),s.jsx("strong",{className:"mono",children:P!=null&&P.session_id?$t(String(P.session_id),28):e.session_id?$t(e.session_id,28):"—"})]}),s.jsxs("div",{className:"runtime_log_context_actions",children:[s.jsx("button",{className:"btn",onClick:()=>e.on_open_run(e.selected_run_id),disabled:!e.selected_run_id,children:"Open Observe"}),s.jsx("button",{className:"btn",onClick:()=>D(e.selected_run_id),disabled:!e.selected_run_id,children:"Run artifacts"})]})]}),e.runtime_ledger_log_error?s.jsx("div",{className:"warn_callout",children:e.runtime_ledger_log_error}):null,e.selected_run_id?null:s.jsx("div",{className:"empty_state_inline",children:"Select a run in Activity or Artifact Explorer to inspect its runtime ledger."}),e.selected_run_id&&!K.length&&!e.runtime_ledger_log_loading?s.jsx("div",{className:"empty_state_inline",children:"No ledger records match the current search."}):null,s.jsx("div",{className:"runtime_log_event_list","aria-label":"Selected run ledger records",children:K.map(E=>{var se,le;const j=E.record||{},L=String(((se=j==null?void 0:j.effect)==null?void 0:se.type)||"").trim(),z=String((j==null?void 0:j.status)||"").trim(),te=String((j==null?void 0:j.node_id)||"").trim(),I=rn(j==null?void 0:j.ended_at,j==null?void 0:j.started_at,j==null?void 0:j.ts),O=Ui(j),G=uv(j),$=L?_t(kr(((le=j==null?void 0:j.effect)==null?void 0:le.payload)??{},1200),{max_chars:1200,max_lines:6}):"",Y=Yd(j)||(O?`Waiting for ${String(O.reason||"input")}`:"")||((j==null?void 0:j.result)!==void 0?kr(j.result,700):"");return s.jsxs("article",{className:`runtime_log_event ${Za(z)}`,children:[s.jsxs("div",{className:"runtime_log_event_header",children:[s.jsxs("span",{className:"mono",children:["#",E.cursor]}),s.jsx(Qa,{status:z||"record"}),L?s.jsx("span",{className:"chip mono muted",children:L}):null,te?s.jsx("strong",{className:"mono",children:te}):null,I?s.jsx("span",{className:"mono muted",children:Jo(I)}):null]}),s.jsxs("div",{className:"runtime_log_event_body",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Request / activity"}),s.jsx("p",{children:[G||bm(j),$&&$!=="{}"?$:""].filter(Boolean).join(`
|
|
100
|
+
`)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Outcome"}),s.jsx("p",{children:_t(Y||"—",{max_chars:1200,max_lines:6})})]})]}),s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Raw ledger record"}),s.jsx(os,{value:j,collapseAfterDepth:3,showCopy:!0})]})]},`${e.selected_run_id}:${E.cursor}`)})})]}):e.runtime_log_source==="provider_calls"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"runtime_log_context",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Selected run"}),s.jsx("strong",{children:P?qs(P,e.workflow_label_by_id):e.selected_run_id?$t(e.selected_run_id,24):"No run selected"}),e.selected_run_id?s.jsx("em",{className:"mono",children:$t(e.selected_run_id,34)}):null]}),s.jsxs("div",{children:[s.jsx("span",{children:"Provider calls"}),s.jsx("strong",{children:Q.length.toLocaleString()}),s.jsx("em",{className:"mono",children:Z?`${Z.toLocaleString()} tokens`:"tokens not recorded"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Issues"}),s.jsx("strong",{children:ee.toLocaleString()})]}),s.jsxs("div",{className:"runtime_log_context_actions",children:[s.jsx("button",{className:"btn",onClick:()=>e.on_open_run(e.selected_run_id),disabled:!e.selected_run_id,children:"Open Observe"}),s.jsx("button",{className:"btn",onClick:()=>e.on_runtime_log_source_change("run_ledger"),disabled:!e.selected_run_id,children:"Run ledger"})]})]}),e.runtime_ledger_log_error?s.jsx("div",{className:"warn_callout",children:e.runtime_ledger_log_error}):null,e.selected_run_id?null:s.jsx("div",{className:"empty_state_inline",children:"Select a run in Activity or Artifact Explorer to inspect provider calls."}),e.selected_run_id&&!Q.length&&!e.runtime_ledger_log_loading?s.jsx("div",{className:"empty_state_inline",children:"No provider calls are present in the selected run ledger, or none match the current search."}):null,s.jsx("div",{className:"provider_activity_list runtime_provider_log_list",children:Q.map(E=>s.jsxs("article",{className:`provider_activity ${E.error||E.missing_response?"danger":""}`,children:[s.jsxs("div",{className:"provider_activity_header",children:[s.jsxs("div",{children:[s.jsx("h4",{children:[E.provider||"provider unknown",E.model||"model unknown"].join(" / ")}),s.jsxs("div",{className:"timeline_subtitle",children:[E.node_id?s.jsx("span",{className:"mono",children:E.node_id}):null,E.run_id?s.jsx("span",{className:"mono",children:$t(E.run_id,16)}):null,s.jsx("span",{children:J_(E.duration_ms)}),E.status?s.jsx(Qa,{status:E.status}):null]})]}),s.jsxs("div",{className:"provider_tokens mono",children:[E.tokens.total?E.tokens.total.toLocaleString():"—"," tokens"]})]}),s.jsxs("div",{className:"provider_preview_grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Prompt / messages"}),s.jsx("p",{children:E.prompt_preview||"No prompt payload captured"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Response / error"}),s.jsx("p",{children:E.response_preview||E.error||"No response captured"})]})]}),s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Raw provider ledger record"}),s.jsx(os,{value:E.raw,collapseAfterDepth:3,showCopy:!0})]})]},E.id))})]}):s.jsxs(s.Fragment,{children:[e.audit_log_error?s.jsx("div",{className:"warn_callout",children:e.audit_log_error}):null,s.jsx("pre",{className:"mono audit_log_tail",children:ue.length?ue.join(`
|
|
101
|
+
`):"(audit tail not loaded or no lines match search)"})]})]}):null]})}const om=30;function vS(e){const[t,n]=h.useState(""),o=Array.isArray(e.wait.choices)?e.wait.choices:[],a=e.wait.allow_free_text!==!1,l=e.disabled===!0,d=String(e.wait.prompt||"").trim();return s.jsxs(s.Fragment,{children:[o.length?s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Expected response"}),s.jsxs("select",{className:"mono",value:t,onChange:u=>n(u.target.value),children:[s.jsx("option",{value:"",children:"(select)"}),o.map((u,m)=>s.jsx("option",{value:String(u),children:String(u)},m))]})]}):null,a?s.jsxs("div",{className:"field",children:[s.jsx("label",{children:o.length?"Or type a response":d?"Your answer":"Response to resume this wait"}),s.jsx("textarea",{className:"mono wait_response_input",value:t,onChange:u=>n(u.target.value),placeholder:d?"Type your answer to the request above…":"Type the response the workflow is waiting for…",rows:4})]}):null,s.jsx("div",{className:"actions",children:s.jsx("button",{className:"btn primary",disabled:l||!t.trim(),onClick:()=>e.on_submit(t.trim()),children:"Submit response"})})]})}function wS(e){const t=e.selected_run_id.trim(),n=e.root_run_id.trim()||t,o=e.sections.reduce((a,l)=>a+l.rows.reduce((d,u)=>{const m=[u.run,...u.children];return d+m.filter(y=>au(y.status)).length},0),0);return s.jsxs("aside",{className:"observatory_sidebar pane",children:[s.jsxs("div",{className:"run_nav_header pane_header",children:[s.jsx("span",{className:"pane_title",children:"Runs"}),s.jsxs("span",{className:"pane_count",children:[e.total_runs.toLocaleString()," runs • ",o.toLocaleString()," active"]}),s.jsx("span",{className:"pane_spacer"}),s.jsxs("button",{className:"btn btn_icon",onClick:e.on_refresh,disabled:e.loading,title:"Refresh workflow runs",children:[s.jsx(Tn,{name:"refresh",size:14}),e.loading?"…":""]})]}),s.jsxs("div",{className:"run_nav_controls",children:[s.jsx("input",{value:e.search,onChange:a=>e.on_search(a.target.value),placeholder:"Search runs, sessions, workflows"}),s.jsxs("div",{className:"run_nav_filter_row",children:[s.jsx("div",{className:"seg_toggle run_nav_segments",children:["active","waiting","terminal","failed","all"].map(a=>s.jsx("button",{className:`seg_btn ${e.filter===a?"active":""}`,onClick:()=>e.on_filter(a),children:a},a))}),s.jsxs("select",{className:"seg_select",value:e.group_by,onChange:a=>e.on_group_by(a.target.value),title:"Group workflow runs",children:[s.jsx("option",{value:"status",children:"Group by status"}),s.jsx("option",{value:"workflow",children:"Group by workflow"}),s.jsx("option",{value:"session",children:"Group by session"})]})]})]}),s.jsxs("div",{className:"run_tree",children:[e.sections.length?null:e.connected?s.jsx("div",{className:"run_tree_empty",children:"No runs match the current filters."}):s.jsxs("div",{className:"run_tree_empty",children:["Gateway offline — runs are unavailable."," ",s.jsx("button",{className:"btn btn_sm",onClick:e.on_sign_in,children:"Sign in"})]}),e.sections.map(a=>s.jsxs("section",{className:"run_tree_section",children:[s.jsxs("div",{className:"run_tree_section_header",children:[s.jsx("span",{children:a.label}),s.jsx("span",{className:"mono",children:a.rows.length})]}),a.rows.map(l=>{const d=l.run,u=String(d.run_id||"").trim(),m=u===t;return s.jsxs("div",{className:"run_tree_group",children:[s.jsxs("button",{className:`run_tree_item ${m?"selected":""} ${u===n?"root_context":""}`,onClick:()=>e.on_select(u,u),title:u,children:[s.jsxs("div",{className:"run_tree_item_top",children:[s.jsx("span",{className:"run_tree_label",children:qs(d,e.workflow_label_by_id)}),s.jsx(Qa,{status:Tm(d)})]}),s.jsxs("div",{className:"run_tree_meta",children:[s.jsx("span",{className:"mono",children:$t(u,13)}),s.jsx("span",{children:Kl(d)?Yo(Kl(d)):"no start"}),s.jsx("span",{children:rc(d)})]})]}),l.children.length?s.jsx("div",{className:"run_tree_children",children:l.children.map(y=>{const g=String(y.run_id||"").trim();return s.jsxs("button",{className:`run_tree_item run_tree_child ${g===t?"selected":""}`,onClick:()=>e.on_select(g,u),title:g,children:[s.jsxs("div",{className:"run_tree_item_top",children:[s.jsx("span",{className:"run_tree_label",children:qs(y,e.workflow_label_by_id)}),s.jsx(Qa,{status:Tm(y)})]}),s.jsxs("div",{className:"run_tree_meta",children:[s.jsx("span",{className:"mono",children:$t(g,13)}),s.jsx("span",{children:Kl(y)?Yo(Kl(y)):"child"}),s.jsx("span",{children:rc(y)})]})]},g)})}):null]},u)})]},a.key))]})]})}function cg(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.7-.9L9.2 3.9A2 2 0 0 0 7.5 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})})}function xS(e){var R,T,D,q,P,K,Q;const t=e.run_id.trim(),[n,o]=h.useState(!1);if(!t)return s.jsx("div",{className:"run_overview",children:s.jsx("div",{className:"empty_state_inline",style:{padding:"48px 24px",textAlign:"center"},children:"Select a run on the left to inspect it — or start one from Launch."})});const a=qs(e.run,e.workflow_label_by_id),l=Kl(e.run)||String(((R=e.run_state)==null?void 0:R.started_at)||((T=e.run_state)==null?void 0:T.created_at)||"").trim(),d=Zy(e.run)||(pi(e.status_label)?String(((D=e.run_state)==null?void 0:D.updated_at)||"").trim():""),u=e.run?rc(e.run):l?J_((bn(d)??Date.now())-(bn(l)??Date.now())):"—",m=e.provider_activities.length,y=e.provider_activities.reduce((Z,ee)=>Z+(Number(ee.tokens.total)||0),0),g=e.provider_activities.filter(Z=>Z.missing_response||Z.error).length,v=String(((q=e.latest_summary)==null?void 0:q.text)||"").trim(),w=e.wait_state,b=pi(e.status_label),C=Rm(e.run)||String(((P=e.run_state)==null?void 0:P.error)||"").trim();let S="";for(let Z=e.records.length-1;Z>=0;Z--){const ee=Yd((K=e.records[Z])==null?void 0:K.record);if(ee){S=ee;break}}return s.jsxs("div",{className:"run_overview",children:[s.jsxs("section",{className:"run_hero run_hero_line",children:[s.jsx("h2",{className:"run_hero_title",title:a,children:a}),s.jsx(Qa,{status:e.status_label}),t?s.jsx("span",{className:"chip mono muted",title:t,children:$t(t,18)}):null,e.root_run_id&&e.root_run_id!==t?s.jsxs("span",{className:"chip mono muted",title:e.root_run_id,children:["root ",$t(e.root_run_id,12)]}):null,s.jsx("span",{className:"run_hero_spacer"}),e.workspace_root?s.jsxs("button",{className:"btn btn_icon",onClick:e.on_reveal_workspace,title:`Open the run's workspace folder
|
|
102
|
+
${e.workspace_root}`,children:[s.jsx(cg,{}),"Folder"]}):null,s.jsx("button",{className:"btn",onClick:e.on_generate_summary,disabled:!t||e.summary_generating,children:e.summary_generating?"Summarizing…":v?"Refresh summary":"Summarize"}),s.jsx("button",{className:"btn",onClick:e.on_open_runtime,title:"Open this run's artifacts in the System explorer",children:"Run artifacts"})]}),b?s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Outcome"}),s.jsx("span",{className:`chip mono ${Za(e.status_label)}`,children:e.status_label||(C?"failed":"completed")})]}),C?s.jsx("div",{className:"error_callout",children:C}):null,S?s.jsx(_i,{text:_t(S,{max_chars:4e3,max_lines:60})}):null,!C&&!S?s.jsx("div",{className:"empty_state_inline",children:"No final text output was recorded for this run — produced files, if any, live under Run artifacts (above)."}):null]}):null,(()=>{const Z=Array.isArray(e.run_artifacts)?e.run_artifacts:[],ee=E=>{const j=String((E!=null&&E.tags&&typeof E.tags=="object"?E.tags.source:"")||"").trim();return j==="run_store_offload"||j==="node_trace_offload"},ue=E=>{const j=E!=null&&E.tags&&typeof E.tags=="object"?E.tags:{},L=String((E==null?void 0:E.filename)||j.filename||"").trim();if(L)return L;const z=String(j.path||(E==null?void 0:E.source_path)||"").trim();return z?z.split("/").pop()||z:String((E==null?void 0:E.title)||"").trim()||String((E==null?void 0:E.artifact_id)||"").slice(0,14)},de=E=>{var j;return s.jsxs("div",{className:"run_artifact_row",children:[s.jsx("span",{className:"run_artifact_name",title:String(((j=E==null?void 0:E.tags)==null?void 0:j.path)||(E==null?void 0:E.source_path)||(E==null?void 0:E.artifact_id)||""),children:ue(E)}),s.jsx("span",{className:"chip mono muted",children:String((E==null?void 0:E.content_type)||"?").replace(/^application\//,"").replace(/^text\//,"")}),s.jsx("span",{className:"run_artifact_size",children:typeof(E==null?void 0:E.size_bytes)=="number"?`${(E.size_bytes/1024).toFixed(E.size_bytes>1e5?0:1)} kB`:""}),s.jsxs("span",{className:"run_artifact_actions",children:[s.jsx("button",{className:"btn",onClick:()=>e.on_preview_run_artifact(E),children:"Preview"}),s.jsx("button",{className:"btn",onClick:()=>e.on_download_run_artifact(E),children:"Download"})]})]},String((E==null?void 0:E.artifact_id)||Math.random()))},pe=Z.filter(E=>!ee(E)),F=Z.filter(ee);return s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Artifacts"}),s.jsx("span",{className:"mono muted",children:Z.length?Z.length.toLocaleString():""}),e.workspace_root?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"pane_spacer"}),s.jsxs("button",{className:"btn btn_icon",onClick:e.on_reveal_workspace,title:`Open the run's workspace folder
|
|
103
|
+
${e.workspace_root}`,children:[s.jsx(cg,{}),"Workspace"]})]}):null]}),e.run_artifacts_error?s.jsx("div",{className:"warn_callout",children:e.run_artifacts_error}):null,e.run_artifacts_loading&&!Z.length?s.jsx("div",{className:"empty_state_inline",children:"Loading artifacts…"}):null,!e.run_artifacts_loading&&!Z.length&&!e.run_artifacts_error?s.jsxs("div",{className:"empty_state_inline",children:["The runtime recorded no durable artifacts for this run.",e.workspace_root?" Files written to the workspace folder (if any) are reachable via the Folder button.":""]}):null,pe.length?s.jsx("div",{className:"run_artifact_list",children:pe.map(de)}):null,!pe.length&&Z.length?s.jsxs("div",{className:"empty_state_inline",children:["No file products — this run's durable artifacts are internal state offloads (below).",e.workspace_root?" Report files written to the workspace are reachable via the Folder button.":""]}):null,F.length?s.jsxs("details",{className:"runtime_raw_details",children:[s.jsxs("summary",{className:"muted",children:["Internal state offloads (",F.length,")"]}),s.jsx("div",{className:"run_artifact_list",children:F.map(de)})]}):null]})})(),s.jsxs("div",{className:"metric_grid",children:[s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Started"}),s.jsx("strong",{children:Jo(l)})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:d?"Finished":"Running for"}),s.jsx("strong",{children:d?Jo(d):u})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Total duration"}),s.jsx("strong",{children:u})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Ledger"}),s.jsx("strong",{children:(e.records_count+e.child_records_count).toLocaleString()})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Subworkflows"}),s.jsx("strong",{children:e.subrun_ids.length.toLocaleString()})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Provider calls"}),s.jsx("strong",{children:m.toLocaleString()})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Tokens"}),s.jsx("strong",{children:y?y.toLocaleString():"—"})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Assets"}),s.jsx("strong",{children:e.attachments_count.toLocaleString()})]})]}),s.jsxs("div",{className:"overview_columns",children:[s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:b?"What happened":"What is happening"}),w?s.jsx("span",{className:"chip mono info",children:"waiting"}):null]}),w?s.jsxs("div",{className:"overview_fact_list",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Reason"}),s.jsx("strong",{children:String(w.reason||"unknown")})]}),w.wait_key?s.jsxs("div",{children:[s.jsx("span",{children:"Wait key"}),s.jsx("strong",{className:"mono",children:$t(String(w.wait_key),34)})]}):null,(Q=w==null?void 0:w.details)!=null&&Q.sub_run_id?s.jsxs("div",{children:[s.jsx("span",{children:"Subworkflow"}),s.jsx("strong",{className:"mono",children:$t(String(w.details.sub_run_id),24)})]}):null,w.prompt?s.jsxs("div",{children:[s.jsx("span",{children:"Prompt"}),s.jsx("strong",{children:_t(String(w.prompt),{max_chars:260,max_lines:3})})]}):null,e.on_answer_wait&&w.wait_key&&String(w.reason||"")==="user"?s.jsx("div",{className:"overview_fact_actions",children:s.jsx("button",{className:"btn primary",onClick:e.on_answer_wait,children:"Review & answer…"})}):null]}):(()=>{var E;const Z=e.timeline_items.length?e.timeline_items[e.timeline_items.length-1]:null,ee=(Z==null?void 0:Z.record)||null,ue=String((ee==null?void 0:ee.node_id)||"").trim(),de=ue&&e.node_index?e.node_index[ue]:null,pe=String((de==null?void 0:de.label)||ue||"").trim(),F=String(((E=ee==null?void 0:ee.effect)==null?void 0:E.type)||"").trim();return pe||F?s.jsxs("div",{className:"overview_fact_list",children:[pe?s.jsxs("div",{children:[s.jsx("span",{children:b?"Ended at":"Last step"}),s.jsx("strong",{children:pe})]}):null,F?s.jsxs("div",{children:[s.jsx("span",{children:"Effect"}),s.jsx("strong",{className:"mono",children:F})]}):null]}):s.jsx("div",{className:"empty_state_inline",children:b?"Nothing in flight — the run is finished.":"No active wait is reported for this run."})})(),g?s.jsxs("div",{className:"warn_callout",children:[g," provider call(s) have missing responses or errors."]}):null]}),s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Summary"}),e.latest_summary?s.jsx("span",{className:"chip mono ok",children:"saved"}):s.jsx("span",{className:"chip mono muted",children:"none"})]}),e.summary_error?s.jsx("div",{className:"warn_callout",children:e.summary_error}):null,v?s.jsx(_i,{text:v}):s.jsx("div",{className:"empty_state_inline",children:"Generate a grounded summary from the root run and its subflows."})]})]}),e.subrun_ids.length?s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Subworkflows"}),s.jsx("span",{className:"mono muted",children:e.subrun_ids.length})]}),s.jsx("div",{className:"subrun_chip_list",children:e.subrun_ids.map(Z=>s.jsx("button",{className:"subrun_chip mono",onClick:()=>e.on_open_subrun(Z),title:Z,children:$t(Z,22)},Z))})]}):null,e.attachments.length||e.session_id?s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Session files"}),s.jsx("span",{className:"mono muted",children:e.attachments.length?`${e.attachments.length} file${e.attachments.length===1?"":"s"}`:""}),s.jsx("button",{className:"btn btn_sm",onClick:e.on_refresh_attachments,disabled:e.attachments_loading||!e.session_id,children:e.attachments_loading?"Refreshing…":"Refresh"})]}),e.attachments_error?s.jsx("div",{className:"warn_callout",children:e.attachments_error}):null,e.attachments.length?s.jsx("div",{className:"produced_list",children:e.attachments.map(Z=>{const ee=String((Z==null?void 0:Z.artifact_id)||"").trim();if(!ee)return null;const ue=Z!=null&&Z.tags&&typeof Z.tags=="object"?Z.tags:{},de=String((ue==null?void 0:ue.path)||"").trim()?`@${String(ue.path).trim()}`:String((ue==null?void 0:ue.filename)||"").trim()||ee,pe=typeof(Z==null?void 0:Z.size_bytes)=="number"?Number(Z.size_bytes):null,F=e.attachments_loading||!e.attachments_ready;return s.jsxs("div",{className:"produced_row",children:[s.jsx("span",{className:"produced_name mono",title:ee,children:de}),s.jsx("span",{className:"mono muted",children:pe!==null?`${pe.toLocaleString()} B`:""}),s.jsxs("span",{className:"produced_actions",children:[s.jsx("button",{className:"btn btn_sm",onClick:()=>e.on_preview_attachment(Z),disabled:F,children:"Preview"}),s.jsx("button",{className:"btn btn_sm",onClick:()=>e.on_download_attachment(Z),disabled:F,children:"Download"})]})]},ee)})}):s.jsx("div",{className:"empty_state_inline",children:b?"No files were attached to this run's session.":"No files in this run's session yet."})]}):null,e.timeline_items.length?s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Chronology"}),s.jsx("span",{className:"mono muted",children:n||e.timeline_items.length<=om?`${e.timeline_items.length} steps`:`last ${om} of ${e.timeline_items.length} steps`}),e.timeline_items.length>om?s.jsx("button",{className:"btn btn_sm",onClick:()=>o(Z=>!Z),children:n?"Show fewer":"Show all"}):null]}),s.jsx(bS,{items:n?e.timeline_items:e.timeline_items.slice(-om),node_index:e.node_index,workflow_label_by_id:e.workflow_label_by_id,on_copy:e.on_copy})]}):null]})}function bS(e){const t=n=>{var T,D;const o=n,a=n.record||{},l=String(((T=a==null?void 0:a.effect)==null?void 0:T.type)||o.effect_type||"").trim(),d=String((a==null?void 0:a.status)||o.status||"").trim(),u=String((a==null?void 0:a.node_id)||o.node_id||"").trim(),m=u&&e.node_index?e.node_index[u]:null,y=String((m==null?void 0:m.label)||u||o.title||"Step").trim(),g=Ui(a),v=(D=a==null?void 0:a.effect)==null?void 0:D.payload,w=a==null?void 0:a.result,b=Yd(a),C=l?kr(v??{},900):_t(String(o.preview||""),{max_chars:900,max_lines:8}),S=b||(g?`Waiting for ${String(g.reason||"input")}${g.wait_key?` (${$t(String(g.wait_key),18)})`:""}`:"")||(w!==void 0?kr(w,900):"");return{title:l==="llm_call"?"Model call":l==="tool_calls"?"Tool execution":l==="answer_user"?"User-facing response":l==="start_subworkflow"?"Subworkflow launched":l==="ask_user"?"User input requested":l||o.title||"Ledger event",subtitle:y,request:_t(C,{max_chars:900,max_lines:7}),outcome:_t(S,{max_chars:1100,max_lines:9}),cls:Za(d)}};return s.jsxs("div",{className:"human_timeline",children:[e.items.length?null:s.jsx("div",{className:"empty_state_inline",children:"No ledger records yet."}),e.items.map(n=>{const o=n.record||{},a=t(n),l=String(o.ended_at||o.started_at||n.ts||"").trim();return s.jsxs("article",{className:`timeline_event ${a.cls}`,children:[s.jsx("div",{className:"timeline_marker"}),s.jsxs("div",{className:"timeline_event_body",children:[s.jsxs("div",{className:"timeline_event_header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:a.title}),s.jsxs("div",{className:"timeline_subtitle",children:[s.jsx("span",{children:a.subtitle}),n.run_id?s.jsx("span",{className:"mono",children:$t(String(n.run_id),13)}):null]})]}),s.jsxs("div",{className:"timeline_time",children:[s.jsx("span",{children:Yo(l)}),s.jsx("span",{className:"mono",title:l,children:Jo(l)})]})]}),s.jsxs("div",{className:"timeline_payload_grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Requested"}),s.jsx("p",{className:"mono",children:a.request||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Outcome"}),s.jsx("p",{children:a.outcome||"—"})]})]}),s.jsx("div",{className:"timeline_actions",children:s.jsxs("button",{className:"btn btn_icon",onClick:()=>e.on_copy(JSON.stringify(o,null,2)),children:[s.jsx(Tn,{name:"copy",size:14}),"JSON"]})})]})]},`${String(n.run_id||o.run_id||"")}:${n.cursor}`)})]})}function SS(e){const t=e.item,n=String(t.node_id||"").trim(),o=n&&e.node_index&&typeof e.node_index=="object"?e.node_index[n]:null,a=typeof(o==null?void 0:o.label)=="string"&&o.label.trim()?o.label.trim():n||t.title,l=typeof(o==null?void 0:o.type)=="string"&&o.type.trim()?o.type.trim():"",d=typeof(o==null?void 0:o.headerColor)=="string"&&o.headerColor.trim()?o.headerColor.trim():"",u=t.kind==="step"?a:t.title,m=d||(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)"),y=String(t.status||"").trim(),g=y.toLowerCase(),v=Za(g),w=Yd(t.data),b=!!(w&&w.trim()),C=Yo(t.ts);return s.jsxs("div",{className:`lc ${v}`,style:{"--lc-accent":m},children:[s.jsxs("div",{className:"lc_header",children:[s.jsx("span",{className:"lc_title",children:u}),s.jsxs("div",{className:"lc_header_right",children:[y?s.jsx("span",{className:`lc_status ${v}`,children:y}):null,s.jsx("span",{className:"lc_time",title:t.ts,children:C})]})]}),s.jsxs("div",{className:"lc_meta",children:[l?s.jsx("span",{className:"lc_chip",children:l}):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:$t(String(t.run_id),10)}):null,t.kind!=="step"&&n?s.jsx("span",{className:"lc_chip",children:n}):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(w||"")),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(_i,{text:String(w||"")})}):null,e.open&&t.data?s.jsx("div",{className:"lc_body lc_body_json mono",children:s.jsx(os,{value:t.data,collapseAfterDepth:3,showCopy:!1})}):null]})}class jS{constructor(){Ua(this,"_buffer","");Ua(this,"_current",{data_lines:[]})}push(t,n){for(this._buffer+=t;;){const o=this._buffer.indexOf(`
|
|
104
|
+
`);if(o===-1)return;const a=this._buffer.slice(0,o);this._buffer=this._buffer.slice(o+1);const l=a.endsWith("\r")?a.slice(0,-1):a;if(l.startsWith(":"))continue;if(l===""){if(this._current.data_lines.length>0||this._current.event||this._current.id){const y={id:this._current.id,event:this._current.event,data:this._current.data_lines.join(`
|
|
105
|
+
`)};n(y)}this._current={data_lines:[]};continue}const d=l.indexOf(":"),u=d===-1?l:l.slice(0,d),m=d===-1?"":l.slice(d+1).trimStart();if(u==="id"){this._current.id=m;continue}if(u==="event"){this._current.event=m;continue}if(u==="data"){this._current.data_lines.push(m);continue}}}}function Pt(e,t){const n=(e||"").trim().replace(/\/+$/,"");return n?`${n}${t}`:t}function Bi(e,t=3e4){const n=AbortSignal.timeout(t);if(!e)return n;const o=AbortSignal.any;return typeof o=="function"?o([e,n]):e}function Ot(e){var o;const t=(e||"").trim(),n={};t&&(n.Authorization=`Bearer ${t}`);try{const a=(o=document.cookie.split(";").map(l=>l.trim()).find(l=>l.startsWith("abstractobserver_gateway_csrf=")))==null?void 0:o.slice(30);a&&(n["X-AbstractObserver-CSRF"]=decodeURIComponent(a))}catch{}return n}async function Gn(e){try{const t=await e.text();return t!=null&&t.trim()?t.trim():`${e.status}`}catch{return`${e.status}`}}class Uh{constructor(t){Ua(this,"_cfg");this._cfg={...t,base_url:(t.base_url||"").trim()}}async start_run(t,n,o){const a=String((o==null?void 0:o.bundle_id)||"").trim(),l=(o==null?void 0:o.session_id)===null||(o==null?void 0:o.session_id)===void 0?"":String(o.session_id||"").trim(),d=String(t||"").trim(),u={input_data:n||{}};a&&(u.bundle_id=a),d&&(u.flow_id=d),l&&(u.session_id=l);const m=await fetch(Pt(this._cfg.base_url,"/api/gateway/runs/start"),{method:"POST",headers:{"Content-Type":"application/json",...Ot(this._cfg.auth_token)},body:JSON.stringify(u)});if(!m.ok)throw new Error(`start_run failed: ${m.status}`);const y=await m.json(),g=y==null?void 0:y.run_id;if(typeof g!="string"||!g)throw new Error("start_run: missing run_id");return g}async schedule_run(t){const n=String((t==null?void 0:t.bundle_id)||"").trim(),o=String((t==null?void 0:t.flow_id)||"").trim();if(!n)throw new Error("schedule_run: bundle_id is required");if(!o)throw new Error("schedule_run: flow_id is required");const a={bundle_id:n,flow_id:o,input_data:(t==null?void 0:t.input_data)||{}},l=(t==null?void 0:t.start_at)===null||(t==null?void 0:t.start_at)===void 0?"":String(t.start_at||"").trim();l&&(a.start_at=l);const d=(t==null?void 0:t.interval)===null||(t==null?void 0:t.interval)===void 0?"":String(t.interval||"").trim();d&&(a.interval=d),typeof(t==null?void 0:t.repeat_count)=="number"&&Number.isFinite(t.repeat_count)&&(a.repeat_count=Number(t.repeat_count));const u=(t==null?void 0:t.repeat_until)===null||(t==null?void 0:t.repeat_until)===void 0?"":String(t.repeat_until||"").trim();u&&(a.repeat_until=u),typeof(t==null?void 0:t.share_context)=="boolean"&&(a.share_context=!!t.share_context);const m=(t==null?void 0:t.session_id)===null||(t==null?void 0:t.session_id)===void 0?"":String(t.session_id||"").trim();m&&(a.session_id=m);const y=await fetch(Pt(this._cfg.base_url,"/api/gateway/runs/schedule"),{method:"POST",headers:{"Content-Type":"application/json",...Ot(this._cfg.auth_token)},body:JSON.stringify(a)});if(!y.ok)throw new Error(`schedule_run failed: ${y.status}`);const g=await y.json(),v=g==null?void 0:g.run_id;if(typeof v!="string"||!v)throw new Error("schedule_run: missing run_id");return v}async list_mcp_servers(){for(const t of["/api/gateway/mcp/servers","/api/gateway/mcp","/api/gateway/discovery/mcp"])try{const n=await fetch(Pt(this._cfg.base_url,t),{headers:{...Ot(this._cfg.auth_token)},signal:Bi()});if(n.status===404||!n.ok)continue;const o=await n.json(),a=Array.isArray(o)?o:Array.isArray(o==null?void 0:o.servers)?o.servers:Array.isArray(o==null?void 0:o.items)?o.items:null;if(!a)continue;return a.map(l=>({name:String((l==null?void 0:l.name)||(l==null?void 0:l.id)||"").trim(),url:typeof(l==null?void 0:l.url)=="string"?l.url:void 0,description:typeof(l==null?void 0:l.description)=="string"?l.description:void 0,auth_required:typeof(l==null?void 0:l.auth_required)=="boolean"?l.auth_required:void 0})).filter(l=>l.name)}catch{return null}return null}async list_skills(){for(const t of["/api/gateway/skills","/api/gateway/skills/registry"])try{const n=await fetch(Pt(this._cfg.base_url,t),{headers:{...Ot(this._cfg.auth_token)},signal:Bi()});if(n.status===404||!n.ok)continue;const o=await n.json(),a=Array.isArray(o)?o:Array.isArray(o==null?void 0:o.skills)?o.skills:Array.isArray(o==null?void 0:o.items)?o.items:null;if(!a)continue;return a.map(l=>({name:String((l==null?void 0:l.name)||(l==null?void 0:l.id)||"").trim(),description:typeof(l==null?void 0:l.description)=="string"?l.description:void 0,version:typeof(l==null?void 0:l.version)=="string"?l.version:void 0,trust_level:typeof(l==null?void 0:l.trust_level)=="string"?l.trust_level:void 0,blocked:typeof(l==null?void 0:l.blocked)=="boolean"?l.blocked:void 0,requires_review:typeof(l==null?void 0:l.requires_review)=="boolean"?l.requires_review:void 0,tree_hash:typeof(l==null?void 0:l.tree_hash)=="string"?l.tree_hash:void 0,reasons:Array.isArray(l==null?void 0:l.reasons)?l.reasons.map(d=>String(d||"")).filter(Boolean):void 0})).filter(l=>l.name)}catch{return null}return null}async get_run(t){const n=await fetch(Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(t)}`),{headers:{...Ot(this._cfg.auth_token)}});if(!n.ok)throw new Error(`get_run failed: ${await Gn(n)}`);return await n.json()}async get_run_history_bundle(t,n){const o=String(t||"").trim();if(!o)throw new Error("get_run_history_bundle: run_id is required");const a=new URLSearchParams;(n==null?void 0:n.include_subruns)===!1&&a.set("include_subruns","false"),(n==null?void 0:n.include_session)===!0&&a.set("include_session","true"),typeof(n==null?void 0:n.session_turn_limit)=="number"&&Number.isFinite(n.session_turn_limit)&&a.set("session_turn_limit",String(Math.max(1,Math.trunc(n.session_turn_limit)))),n!=null&&n.ledger_mode&&a.set("ledger_mode",String(n.ledger_mode)),typeof(n==null?void 0:n.ledger_max_items)=="number"&&Number.isFinite(n.ledger_max_items)&&a.set("ledger_max_items",String(Math.max(0,Math.trunc(n.ledger_max_items))));const l=Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/history_bundle?${a.toString()}`),d=await fetch(l,{headers:{...Ot(this._cfg.auth_token)}});if(!d.ok)throw new Error(`get_run_history_bundle failed: ${await Gn(d)}`);return await d.json()}async list_runs(t){const n=typeof(t==null?void 0:t.limit)=="number"?t.limit:50,o=String((t==null?void 0:t.status)||"").trim(),a=String((t==null?void 0:t.workflow_id)||"").trim(),l=String((t==null?void 0:t.session_id)||"").trim(),d=(t==null?void 0:t.root_only)===!0,u=new URLSearchParams;u.set("limit",String(n)),o&&u.set("status",o),a&&u.set("workflow_id",a),l&&u.set("session_id",l),d&&u.set("root_only","true"),typeof(t==null?void 0:t.include_ledger_len)=="boolean"&&u.set("include_ledger_len",String(t.include_ledger_len)),typeof(t==null?void 0:t.include_metrics)=="boolean"&&u.set("include_metrics",String(t.include_metrics)),typeof(t==null?void 0:t.include_drafts)=="boolean"&&u.set("include_drafts",String(t.include_drafts));const m=Pt(this._cfg.base_url,`/api/gateway/runs?${u.toString()}`),y=await fetch(m,{headers:{...Ot(this._cfg.auth_token)},signal:AbortSignal.timeout(3e4)});if(!y.ok)throw new Error(`list_runs failed: ${await Gn(y)}`);return await y.json()}async audit_log_tail(t){const n=typeof(t==null?void 0:t.max_bytes)=="number"?Math.max(1024,Math.min(4e5,Math.floor(t.max_bytes))):8e4,o=Pt(this._cfg.base_url,`/api/gateway/audit/tail?max_bytes=${encodeURIComponent(String(n))}`),a=await fetch(o,{headers:{...Ot(this._cfg.auth_token)}});if(!a.ok)throw new Error(`audit_log_tail failed: ${await Gn(a)}`);return await a.json()}async gateway_about(){const t=await fetch(Pt(this._cfg.base_url,"/api/gateway/about"),{headers:{...Ot(this._cfg.auth_token)},signal:Bi(void 0,1e4)});if(!t.ok)throw new Error(`HTTP ${t.status}`);return await t.json()}async get_run_input_data(t){const n=String(t||"").trim();if(!n)throw new Error("get_run_input_data: run_id is required");const o=await fetch(Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(n)}/input_data`),{headers:{...Ot(this._cfg.auth_token)}});if(!o.ok)throw new Error(`get_run_input_data failed: ${await Gn(o)}`);return await o.json()}async list_run_artifacts(t,n){const o=String(t||"").trim();if(!o)throw new Error("list_run_artifacts: run_id is required");const a=typeof(n==null?void 0:n.limit)=="number"?n.limit:200,l=typeof(n==null?void 0:n.offset)=="number"?Math.max(0,Math.floor(n.offset)):0,d=Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/artifacts?limit=${encodeURIComponent(String(a))}&offset=${encodeURIComponent(String(l))}`),u=await fetch(d,{headers:{...Ot(this._cfg.auth_token)}});if(!u.ok)throw new Error(`list_run_artifacts failed: ${await Gn(u)}`);return await u.json()}async list_session_artifacts(t,n){const o=String(t||"").trim();if(!o)throw new Error("list_session_artifacts: session_id is required");const a=typeof(n==null?void 0:n.limit)=="number"?n.limit:200,l=typeof(n==null?void 0:n.offset)=="number"?Math.max(0,Math.floor(n.offset)):0,d=Pt(this._cfg.base_url,`/api/gateway/sessions/${encodeURIComponent(o)}/artifacts?limit=${encodeURIComponent(String(a))}&offset=${encodeURIComponent(String(l))}`),u=await fetch(d,{headers:{...Ot(this._cfg.auth_token)}});if(!u.ok)throw new Error(`list_session_artifacts failed: ${await Gn(u)}`);return await u.json()}async search_artifacts(t){const n=new URLSearchParams;n.set("scope",String((t==null?void 0:t.scope)||"all").trim()||"all");const o=String((t==null?void 0:t.session_id)||"").trim(),a=String((t==null?void 0:t.run_id)||"").trim(),l=String((t==null?void 0:t.modality)||"").trim(),d=String((t==null?void 0:t.artifact_kind)||"").trim(),u=String((t==null?void 0:t.semantic_kind)||"").trim(),m=String((t==null?void 0:t.render_kind)||"").trim(),y=String((t==null?void 0:t.workflow_id)||"").trim(),g=String((t==null?void 0:t.node_id)||"").trim(),v=String((t==null?void 0:t.content_type)||"").trim(),w=String((t==null?void 0:t.query)||"").trim(),b=String((t==null?void 0:t.tags)||"").trim(),C=String((t==null?void 0:t.cursor)||"").trim(),S=String((t==null?void 0:t.order_by)||"").trim(),R=String((t==null?void 0:t.order)||"").trim(),T=String((t==null?void 0:t.created_after)||"").trim(),D=String((t==null?void 0:t.created_before)||"").trim(),q=typeof(t==null?void 0:t.limit)=="number"?t.limit:500,P=typeof(t==null?void 0:t.offset)=="number"?Math.max(0,Math.floor(t.offset)):0;o&&n.set("session_id",o),a&&n.set("run_id",a),l&&n.set("modality",l),d&&n.set("artifact_kind",d),u&&n.set("semantic_kind",u),m&&n.set("render_kind",m),y&&n.set("workflow_id",y),g&&n.set("node_id",g),v&&n.set("content_type",v),w&&n.set("query",w),b&&n.set("tags",b),C&&n.set("cursor",C),S&&n.set("order_by",S),R&&n.set("order",R),T&&n.set("created_after",T),D&&n.set("created_before",D),t!=null&&t.include_stats&&n.set("include_stats","true"),n.set("limit",String(q)),n.set("offset",String(P));const K=await fetch(Pt(this._cfg.base_url,`/api/gateway/artifacts/search?${n.toString()}`),{headers:{...Ot(this._cfg.auth_token)}});if(!K.ok)throw new Error(`search_artifacts failed: ${await Gn(K)}`);return await K.json()}async artifact_stats(t){const n=new URLSearchParams;n.set("scope",String((t==null?void 0:t.scope)||"all").trim()||"all");for(const a of["session_id","run_id","modality","semantic_kind","render_kind","workflow_id","node_id","content_type","query","tags","created_after","created_before"]){const l=String((t==null?void 0:t[a])||"").trim();l&&n.set(a,l)}const o=await fetch(Pt(this._cfg.base_url,`/api/gateway/artifacts/stats?${n.toString()}`),{headers:{...Ot(this._cfg.auth_token)}});if(!o.ok)throw new Error(`artifact_stats failed: ${await Gn(o)}`);return await o.json()}async download_run_artifact_content(t,n,o){const a=String(t||"").trim(),l=String(n||"").trim();if(!a)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 d=String((o==null?void 0:o.access)||"").trim(),u=d?`?access=${encodeURIComponent(d)}`:"",m=Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(a)}/artifacts/${encodeURIComponent(l)}/content${u}`),y=await fetch(m,{headers:{...Ot(this._cfg.auth_token)}});if(!y.ok)throw new Error(`download_run_artifact_content failed: ${await Gn(y)}`);return await y.blob()}async list_entities(){const t=await fetch(Pt(this._cfg.base_url,"/api/gateway/entities"),{headers:{...Ot(this._cfg.auth_token)},signal:Bi()});if(!t.ok)throw new Error(`list_entities failed: ${await Gn(t)}`);const n=await t.json();return{entities:Array.isArray(n==null?void 0:n.entities)?n.entities:[]}}async get_entity_phases_spec(){const t=await fetch(Pt(this._cfg.base_url,"/api/gateway/entities/spec/phases"),{headers:{...Ot(this._cfg.auth_token)},signal:Bi()});if(!t.ok)throw new Error(`get_entity_phases_spec failed: ${await Gn(t)}`);return await t.json()}async get_entity_cognition(t){const n=await fetch(Pt(this._cfg.base_url,`/api/gateway/entities/${encodeURIComponent(t)}/cognition`),{headers:{...Ot(this._cfg.auth_token)},signal:Bi()});if(!n.ok)throw new Error(`get_entity_cognition failed: ${await Gn(n)}`);return await n.json()}async get_entity_card(t){const n=String(t||"").trim();if(!n)throw new Error("get_entity_card: name is required");const o=await fetch(Pt(this._cfg.base_url,`/api/gateway/entities/${encodeURIComponent(n)}/card`),{headers:{...Ot(this._cfg.auth_token)},signal:Bi()});if(!o.ok)throw new Error(`get_entity_card failed: ${await Gn(o)}`);return await o.json()}async read_entity_diary_entry(t,n){const o=String(t||"").trim(),a=String(n||"").trim();if(!o||!a)throw new Error("read_entity_diary_entry: name and entry_id are required");const l=Pt(this._cfg.base_url,`/api/gateway/entities/${encodeURIComponent(o)}/diary/${encodeURIComponent(a)}?reason=${encodeURIComponent("observer board hint chip")}`),d=await fetch(l,{headers:{...Ot(this._cfg.auth_token)},signal:Bi()});if(!d.ok)throw new Error(`read_entity_diary_entry failed: ${await Gn(d)}`);return await d.json()}async get_ledger(t,n){const o=Number((n==null?void 0:n.after)||0),a=Number((n==null?void 0:n.limit)||0),l=Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(t)}/ledger?after=${encodeURIComponent(String(o))}&limit=${encodeURIComponent(String(a))}`),d=await fetch(l,{headers:{...Ot(this._cfg.auth_token)},signal:Bi(n==null?void 0:n.signal)});if(!d.ok)throw new Error(`get_ledger failed: ${d.status}`);const u=await d.json(),m=Array.isArray(u==null?void 0:u.items)?u.items:[],y=typeof(u==null?void 0:u.next_after)=="number"?u.next_after:o;return{items:m,next_after:y}}async get_ledger_batch(t){const n=Array.isArray(t==null?void 0:t.runs)?t.runs:[],o=Number((t==null?void 0:t.limit)||0),a=await fetch(Pt(this._cfg.base_url,"/api/gateway/runs/ledger/batch"),{method:"POST",headers:{"Content-Type":"application/json",...Ot(this._cfg.auth_token)},body:JSON.stringify({runs:n,limit:o}),signal:Bi()});if(!a.ok)throw new Error(`get_ledger_batch failed: ${a.status}`);const l=await a.json(),u=(l&&typeof l=="object"?l:{}).runs;return{runs:u&&typeof u=="object"?u:{}}}async generate_run_summary(t,n){const o=String(t||"").trim();if(!o)throw new Error("generate_run_summary: run_id is required");const a={include_subruns:(n==null?void 0:n.include_subruns)!==!1},l=typeof(n==null?void 0:n.provider)=="string"?String(n.provider).trim():"";l&&(a.provider=l);const d=typeof(n==null?void 0:n.model)=="string"?String(n.model).trim():"";d&&(a.model=d);const u=await fetch(Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/summary`),{method:"POST",headers:{"Content-Type":"application/json",...Ot(this._cfg.auth_token)},body:JSON.stringify(a)});if(!u.ok)throw new Error(`generate_run_summary failed: ${u.status}`);return await u.json()}async run_chat(t,n){const o=String(t||"").trim();if(!o)throw new Error("run_chat: run_id is required");const a={include_subruns:(n==null?void 0:n.include_subruns)!==!1,messages:Array.isArray(n==null?void 0:n.messages)?n.messages:[],persist:!!(n!=null&&n.persist)},l=typeof(n==null?void 0:n.provider)=="string"?String(n.provider).trim():"";l&&(a.provider=l);const d=typeof(n==null?void 0:n.model)=="string"?String(n.model).trim():"";d&&(a.model=d);const u=await fetch(Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/chat`),{method:"POST",headers:{"Content-Type":"application/json",...Ot(this._cfg.auth_token)},body:JSON.stringify(a)});if(!u.ok)throw new Error(`run_chat failed: ${u.status}`);return await u.json()}async audio_transcribe(t,n){const o=String(t||"").trim();if(!o)throw new Error("audio_transcribe: run_id is required");const a=n==null?void 0:n.audio_artifact;if(!a||typeof a!="object")throw new Error("audio_transcribe: audio_artifact is required");if(!String(a.$artifact||"").trim())throw new Error("audio_transcribe: audio_artifact.$artifact is required");const d={audio_artifact:a},u=String((n==null?void 0:n.language)||"").trim();u&&(d.language=u);const m=String((n==null?void 0:n.request_id)||"").trim();m&&(d.request_id=m);const y=await fetch(Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/audio/transcribe`),{method:"POST",headers:{"Content-Type":"application/json",...Ot(this._cfg.auth_token)},body:JSON.stringify(d)});if(!y.ok)throw new Error(`audio_transcribe failed: ${await Gn(y)}`);const g=await y.json(),v=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:v,transcript_artifact:g==null?void 0:g.transcript_artifact}}async voice_tts(t,n){const o=String(t||"").trim();if(!o)throw new Error("voice_tts: run_id is required");const a=String((n==null?void 0:n.text)||"").trim();if(!a)throw new Error("voice_tts: text is required");const l={text:a},d=String((n==null?void 0:n.voice)||"").trim();d&&(l.voice=d);const u=String((n==null?void 0:n.format)||"").trim();u&&(l.format=u);const m=String((n==null?void 0:n.request_id)||"").trim();m&&(l.request_id=m);const y=await fetch(Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/voice/tts`),{method:"POST",headers:{"Content-Type":"application/json",...Ot(this._cfg.auth_token)},body:JSON.stringify(l)});if(!y.ok)throw new Error(`voice_tts failed: ${await Gn(y)}`);const g=await y.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,n){const o=String(t||"").trim();if(!o)throw new Error("save_chat_thread: run_id is required");const a={include_subruns:(n==null?void 0:n.include_subruns)!==!1,messages:Array.isArray(n==null?void 0:n.messages)?n.messages:[]},l=typeof(n==null?void 0:n.provider)=="string"?String(n.provider).trim():"";l&&(a.provider=l);const d=typeof(n==null?void 0:n.model)=="string"?String(n.model).trim():"";d&&(a.model=d);const u=typeof(n==null?void 0:n.title)=="string"?String(n.title).trim():"";u&&(a.title=u);const m=await fetch(Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/chat_threads`),{method:"POST",headers:{"Content-Type":"application/json",...Ot(this._cfg.auth_token)},body:JSON.stringify(a)});if(!m.ok)throw new Error(`save_chat_thread failed: ${await Gn(m)}`);return await m.json()}async list_bundles(){const t=await fetch(Pt(this._cfg.base_url,"/api/gateway/bundles"),{headers:{...Ot(this._cfg.auth_token)},signal:Bi()});if(!t.ok)throw new Error(`list_bundles failed: ${t.status}`);return await t.json()}async reload_bundles(){const t=await fetch(Pt(this._cfg.base_url,"/api/gateway/bundles/reload"),{method:"POST",headers:{...Ot(this._cfg.auth_token)}});if(!t.ok)throw new Error(`reload_bundles failed: ${t.status}`);return await t.json()}async upload_bundle(t,n){const o=(n==null?void 0:n.overwrite)===!0,a=(n==null?void 0:n.reload)!==!1,l=new FormData;l.set("overwrite",o?"true":"false"),l.set("reload",a?"true":"false"),l.set("file",t,t.name||"upload.flow");const d=await fetch(Pt(this._cfg.base_url,"/api/gateway/bundles/upload"),{method:"POST",headers:{...Ot(this._cfg.auth_token)},body:l});if(!d.ok)throw new Error(`upload_bundle failed: ${await Gn(d)}`);return await d.json()}async attachments_upload(t,n,o){const a=String(t||"").trim();if(!a)throw new Error("attachments_upload: session_id is required");if(!n)throw new Error("attachments_upload: file is required");const l=String((o==null?void 0:o.filename)||"").trim()||String((n==null?void 0:n.name)||"").trim()||"upload.bin",d=String((o==null?void 0:o.content_type)||"").trim()||String((n==null?void 0:n.type)||"").trim(),u=new FormData;u.append("session_id",a),u.append("file",n,l),u.append("filename",l),d&&u.append("content_type",d);const m=await fetch(Pt(this._cfg.base_url,"/api/gateway/attachments/upload"),{method:"POST",headers:{...Ot(this._cfg.auth_token)},body:u});if(!m.ok)throw new Error(`attachments_upload failed: ${await Gn(m)}`);const y=await m.json(),g=y==null?void 0:y.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,n){const o=String(t||"").trim();if(!o)throw new Error("remove_bundle: bundle_id is required");const a=new URLSearchParams,l=String((n==null?void 0:n.bundle_version)||"").trim();l&&a.set("bundle_version",l),a.set("reload",(n==null?void 0:n.reload)===!1?"false":"true");const d=Pt(this._cfg.base_url,`/api/gateway/bundles/${encodeURIComponent(o)}?${a.toString()}`),u=await fetch(d,{method:"DELETE",headers:{...Ot(this._cfg.auth_token)}});if(!u.ok)throw new Error(`remove_bundle failed: ${await Gn(u)}`);return await u.json()}async discovery_tools(){const t=await fetch(Pt(this._cfg.base_url,"/api/gateway/discovery/tools"),{headers:{...Ot(this._cfg.auth_token)}});if(!t.ok)throw new Error(`discovery_tools failed: ${t.status}`);return await t.json()}async discovery_providers(t){const n=(t==null?void 0:t.include_models)===!0,o=Pt(this._cfg.base_url,`/api/gateway/discovery/providers?include_models=${encodeURIComponent(String(n))}`),a=await fetch(o,{headers:{...Ot(this._cfg.auth_token)}});if(!a.ok)throw new Error(`discovery_providers failed: ${a.status}`);return await a.json()}async discovery_provider_models(t){const n=String(t||"").trim();if(!n)throw new Error("discovery_provider_models: provider_name is required");const o=await fetch(Pt(this._cfg.base_url,`/api/gateway/discovery/providers/${encodeURIComponent(n)}/models`),{headers:{...Ot(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 n=String(t||"").trim();if(!n)throw new Error("get_bundle: bundle_id is required");const o=await fetch(Pt(this._cfg.base_url,`/api/gateway/bundles/${encodeURIComponent(n)}`),{headers:{...Ot(this._cfg.auth_token)}});if(!o.ok)throw new Error(`get_bundle failed: ${o.status}`);return await o.json()}async get_bundle_flow(t,n){const o=String(t||"").trim(),a=String(n||"").trim();if(!o)throw new Error("get_bundle_flow: bundle_id is required");if(!a)throw new Error("get_bundle_flow: flow_id is required");const l=await fetch(Pt(this._cfg.base_url,`/api/gateway/bundles/${encodeURIComponent(o)}/flows/${encodeURIComponent(a)}`),{headers:{...Ot(this._cfg.auth_token)}});if(!l.ok)throw new Error(`get_bundle_flow failed: ${l.status}`);return await l.json()}async get_workflow_flow(t){const n=String(t||"").trim();if(!n)throw new Error("get_workflow_flow: workflow_id is required");const o=await fetch(Pt(this._cfg.base_url,`/api/gateway/workflows/${encodeURIComponent(n)}/flow`),{headers:{...Ot(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 n=await fetch(Pt(this._cfg.base_url,"/api/gateway/commands"),{method:"POST",headers:{"Content-Type":"application/json",...Ot(this._cfg.auth_token)},body:JSON.stringify(t)});if(!n.ok)throw new Error(`submit_command failed: ${n.status}`);return await n.json()}async kg_query(t){const n=String((t==null?void 0:t.scope)||"session").trim().toLowerCase(),o=String((t==null?void 0:t.order)||"desc").trim().toLowerCase(),a=typeof(t==null?void 0:t.limit)=="number"&&Number.isFinite(t.limit)?Number(t.limit):500,l={scope:n,order:o,limit:a},d=String((t==null?void 0:t.run_id)||"").trim();d&&(l.run_id=d);const u=String((t==null?void 0:t.session_id)||"").trim();u&&(l.session_id=u);const m=String((t==null?void 0:t.owner_id)||"").trim();m&&(l.owner_id=m),t!=null&&t.all_owners&&(l.all_owners=!0);const y=String((t==null?void 0:t.subject)||"").trim();y&&(l.subject=y);const g=String((t==null?void 0:t.predicate)||"").trim();g&&(l.predicate=g);const v=String((t==null?void 0:t.object)||"").trim();v&&(l.object=v);const w=String((t==null?void 0:t.since)||"").trim();w&&(l.since=w);const b=String((t==null?void 0:t.until)||"").trim();b&&(l.until=b);const C=String((t==null?void 0:t.active_at)||"").trim();C&&(l.active_at=C);const S=String((t==null?void 0:t.query_text)||"").trim();S&&(l.query_text=S),typeof(t==null?void 0:t.min_score)=="number"&&Number.isFinite(t.min_score)&&(l.min_score=Number(t.min_score));const R=await fetch(Pt(this._cfg.base_url,"/api/gateway/kg/query"),{method:"POST",headers:{"Content-Type":"application/json",...Ot(this._cfg.auth_token)},body:JSON.stringify(l)});if(!R.ok)throw new Error(`kg_query failed: ${await Gn(R)}`);return await R.json()}async stream_ledger(t,n){const o=Number((n==null?void 0:n.after)||0),a=n.on_step,l=n.signal,d=Pt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(t)}/ledger/stream?after=${encodeURIComponent(String(o))}`),u=await fetch(d,{headers:{Accept:"text/event-stream",...Ot(this._cfg.auth_token)},signal:l});if(!u.ok)throw new Error(`stream_ledger failed: ${u.status}`);if(!u.body)throw new Error("stream_ledger: response body is missing");const m=u.body.getReader(),y=new TextDecoder("utf-8"),g=new jS;for(;;){const{value:v,done:w}=await m.read();if(w)return;const b=y.decode(v,{stream:!0});g.push(b,C=>{if(!(C.event!=="step"||!C.data))try{const S=JSON.parse(C.data);S&&typeof S.cursor=="number"&&S.record&&a(S)}catch{}})}}}function ss(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id_${Date.now()}_${Math.random().toString(16).slice(2)}`}function kS(e){const t=(e||"").trim();return t?{Authorization:`Bearer ${t}`}:{}}class NS{constructor(t){Ua(this,"_cfg");this._cfg={...t,url:(t.url||"").trim()}}async call_tool(t){const n=String((t==null?void 0:t.name)||"").trim(),o=String((t==null?void 0:t.call_id)||(t==null?void 0:t.id)||ss()),a=t!=null&&t.arguments&&typeof t.arguments=="object"?t.arguments:{};if(!n)return{call_id:o,name:"",success:!1,output:null,error:"Missing tool name"};const l={jsonrpc:"2.0",id:ss(),method:"tools/call",params:{name:n,arguments:a}},d=await fetch(this._cfg.url,{method:"POST",headers:{"Content-Type":"application/json",...kS(this._cfg.auth_token)},body:JSON.stringify(l)});if(!d.ok)return{call_id:o,name:n,success:!1,output:null,error:`Worker HTTP ${d.status}`};const u=await d.json().catch(()=>null),m=u==null?void 0:u.result,y=!!(m!=null&&m.isError),v=(Array.isArray(m==null?void 0:m.content)?m.content:[]).find(b=>b&&b.type==="text"&&typeof b.text=="string"),w=(v==null?void 0:v.text)??"";return y?{call_id:o,name:n,success:!1,output:null,error:w||"Tool failed"}:{call_id:o,name:n,success:!0,output:w,error:null}}}class ug{constructor(t,n){Ua(this,"pending",[]);Ua(this,"scheduled",!1);Ua(this,"generation",0);this.schedule=t,this.on_flush=n}push(t){if(this.pending.push(t),this.scheduled)return;this.scheduled=!0;const n=this.generation;this.schedule(()=>{if(n!==this.generation)return;this.scheduled=!1;const o=this.pending;this.pending=[],o.length&&this.on_flush(o)})}reset(){this.generation+=1,this.pending=[],this.scheduled=!1}pending_count(){return this.pending.length}}const CS={execution:"#FFFFFF",string:"#FF00FF",number:"#00FF00",boolean:"#FF0000",object:"#00FFFF",array:"#FF8800",tools:"#FF8800",provider:"#00D2FF",model:"#9D4EDD",provider_text:"#00D2FF",model_text:"#9D4EDD",provider_image:"#19D3B8",model_image:"#8B5CF6",provider_voice:"#22D3EE",model_voice:"#A855F7",agent:"#4488FF",any:"#888888"},ES=[{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_text",label:"Text Provider",shape:"●",description:"Text/LLM provider id/name"},{type:"provider_image",label:"Image Provider",shape:"●",description:"Image-generation provider id"},{type:"provider_voice",label:"Voice Provider",shape:"●",description:"Voice/TTS/STT provider id"},{type:"provider",label:"Provider (legacy)",shape:"●",description:"Legacy unscoped provider id/name"},{type:"model",label:"Model",shape:"●",description:"Model id/name scoped by the selected provider"},{type:"agent",label:"Agent",shape:"⬢",description:"Agent reference"},{type:"any",label:"Any",shape:"●",description:"Accepts any type"}];function $S(){const[e,t]=h.useState(!0);return s.jsxs("div",{className:"pin-legend",children:[s.jsxs("button",{className:"pin-legend-toggle mono",type:"button",onClick:()=>t(n=>!n),title:"Pin Type Legend",children:[e?"?":"×"," Pin Types"]}),e?null:s.jsxs("div",{className:"pin-legend-content",children:[ES.map(n=>s.jsxs("div",{className:"pin-legend-row",children:[s.jsx("span",{className:"pin-legend-shape",style:{color:CS[n.type]},children:n.shape}),s.jsx("span",{className:"pin-legend-label mono",children:n.label}),s.jsx("span",{className:"pin-legend-desc mono",children:n.description})]},n.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 Qt(e){return typeof e=="string"?e:e==null?"":String(e)}function dg(e,t){const n=Qt(e).trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`}function pv(e){const t=Qt(e==null?void 0:e.targetHandle),n=Qt(e==null?void 0:e.sourceHandle);return!!(t==="exec-in"||n==="exec-out"||t.includes("exec")||n.includes("exec"))}function gv(e){if(!e||typeof e!="object")return"";const t=e!=null&&e.data&&typeof e.data=="object"?e.data:{};return Qt((t==null?void 0:t.nodeType)||(e==null?void 0:e.type)||"").trim()}function yv(e){if(!e||typeof e!="object")return"";const t=e!=null&&e.data&&typeof e.data=="object"?e.data:{},n=(t==null?void 0:t.subflowId)||(t==null?void 0:t.flowId),o=Qt(n).trim();if(!o)return"";if(o.includes(":")){const a=o.split(":",2);if(a.length===2&&a[1])return a[1].trim()}return o}function MS(e){const t=Qt(e==null?void 0:e.entryNode).trim();if(t)return t;const n=Array.isArray(e==null?void 0:e.nodes)?e.nodes:[];for(const o of n)if(gv(o)==="on_flow_start"){const a=Qt(o==null?void 0:o.id).trim();if(a)return a}return""}function Hh(e){const t=e!=null&&e.position&&typeof e.position=="object"?e.position:{},n=typeof t.x=="number"?t.x:0,o=typeof t.y=="number"?t.y:0;return{x:n,y:o}}function wd(e,t){const n=Qt(e).trim(),o=Qt(t).trim();return o?n?`${n}::${o}`:o:""}function AS(e){const t=e.root&&typeof e.root=="object"?e.root:{};if(!e.expand_subflows)return t;const n=[],o=[],a=new Set,l=(d,u,m,y)=>{if(!d||typeof d!="object"||n.length>=e.max_nodes||o.length>=e.max_edges)return;const g=Array.isArray(d.nodes)?d.nodes:[],v=Array.isArray(d.edges)?d.edges:[];for(const w of g){const b=Qt(w==null?void 0:w.id).trim();if(!b)continue;const C=wd(u,b);if(!C||a.has(C))continue;const S=Hh(w),R={...w,id:C,position:{x:S.x+m.x,y:S.y+m.y}};if(n.push(R),a.add(C),n.length>=e.max_nodes)break}for(const w of v){if(!pv(w))continue;const b=Qt(w==null?void 0:w.source).trim(),C=Qt(w==null?void 0:w.target).trim();if(!b||!C)continue;const S=wd(u,b),R=wd(u,C);if(!S||!R)continue;const T=Qt(w==null?void 0:w.id).trim(),D=T?`${S}->${R}::${T}`:`${S}->${R}`;if(o.push({...w,id:D,source:S,target:R}),o.length>=e.max_edges)break}if(!(y>=e.max_depth))for(const w of g){if(n.length>=e.max_nodes||o.length>=e.max_edges)return;if(gv(w)!=="subflow")continue;const b=yv(w);if(!b)continue;const C=e.flow_by_id[b];if(!C||typeof C!="object")continue;const S=wd(u,Qt(w==null?void 0:w.id));if(!S)continue;const R=MS(C);if(!R)continue;const D=(Array.isArray(C.nodes)?C.nodes:[]).find(ue=>Qt(ue==null?void 0:ue.id).trim()===R)||null;if(!D)continue;const q=Hh(w),P=Hh(D),Z={x:q.x+m.x+240-P.x,y:q.y+m.y+0-P.y},ee=wd(S,R);o.push({id:`${S}=>${ee}`,source:S,target:ee,sourceHandle:"exec-out",targetHandle:"exec-in"}),l(C,S,Z,y+1)}};return l(t,"",{x:0,y:0},0),{...t,id:Qt(t.id),nodes:n,edges:o}}function TS(e){const t=Qt(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 RS(e){const t=e.nodes.filter(l=>e.keep_id(l.id)),n=new Set(t.map(l=>l.id)),o={};for(const l of e.edges)o[l.source]||(o[l.source]=[]),o[l.source].push(l.target);const a=new Map;for(const l of t){const d=new Set,u=(o[l.id]||[]).slice();for(;u.length;){const m=u.pop();if(!m||d.has(m))continue;if(d.add(m),n.has(m)){const g=`${l.id}->${m}`;a.has(g)||a.set(g,{id:g,source:l.id,target:m});continue}const y=o[m]||[];for(const g of y)d.has(g)||u.push(g);if(a.size>=e.max_edges)break}if(a.size>=e.max_edges)break}return{nodes:t,edges:Array.from(a.values())}}function fg(e,t){const a=Math.max(t.w*8,160),l=Math.max(t.h*8,120),d=Math.max(160,Math.min(a,e.w)),u=Math.max(120,Math.min(l,e.h));return{x:e.x,y:e.y,w:d,h:u}}function LS(e){const t=typeof e.now_ms=="number"?e.now_ms:Date.now(),n=e.flow,o=Qt(e.active_node_id),a=e.recent_nodes||{},l=e.visited_nodes||{},d=e.highlight_path===!0,u=typeof e.vertical_compact=="number"?Math.max(.4,Math.min(1,e.vertical_compact)):.78,{nodes:m,edges:y,bounds:g}=h.useMemo(()=>{const I=AS({root:n||{},flow_by_id:e.flow_by_id||{},expand_subflows:e.expand_subflows===!0,max_depth:3,max_nodes:700,max_edges:900}),O=Array.isArray(I.nodes)?I.nodes:[],G=Array.isArray(I.edges)?I.edges:[];let $=[];for(const Ne of O){const Oe=Qt(Ne==null?void 0:Ne.id).trim();if(!Oe)continue;const it=Ne!=null&&Ne.position&&typeof Ne.position=="object"?Ne.position:{},ve=typeof it.x=="number"?it.x:0,Ie=typeof it.y=="number"?it.y:0,Ge=Ne!=null&&Ne.data&&typeof Ne.data=="object"?Ne.data:{},Mt=Qt((Ge==null?void 0:Ge.label)||(Ne==null?void 0:Ne.label)||Oe)||Oe,Bt=Qt((Ge==null?void 0:Ge.nodeType)||(Ne==null?void 0:Ne.type)||"unknown")||"unknown",dn=Qt((Ge==null?void 0:Ge.headerColor)||(Ne==null?void 0:Ne.headerColor)||"")||"",Ft=Ge!=null&&Ge.eventConfig&&typeof Ge.eventConfig=="object"?Ge.eventConfig:null,At=Ft&&typeof Ft.schedule=="string"?Qt(Ft.schedule).trim():"",fn=Ft&&typeof Ft.recurrent=="boolean"?!!Ft.recurrent:void 0,Kn=Bt==="subflow"?yv(Ne):"",jt=At||fn!==void 0||Kn?{schedule:At||void 0,recurrent:fn,subflow_id:Kn||void 0}:void 0;$.push({id:Oe,x:ve,y:Ie,label:Mt,type:Bt,color:dn,meta:jt})}const Y={};for(const Ne of $)Y[Ne.id]=Ne;let se=[];for(const Ne of G){if(!pv(Ne))continue;const Oe=Qt(Ne==null?void 0:Ne.source).trim(),it=Qt(Ne==null?void 0:Ne.target).trim();!Oe||!it||se.push({id:Qt((Ne==null?void 0:Ne.id)||`${Oe}->${it}`),source:Oe,target:it})}const le=new Set($.map(Ne=>Ne.id));if(se=se.filter(Ne=>le.has(Ne.source)&&le.has(Ne.target)),e.simplify===!0){const Oe=RS({nodes:$,edges:se,keep_id:it=>{if(o&&it===o)return!0;const ve=Y[it];if(!ve)return!1;const Ie=Qt(ve.type).trim().toLowerCase();return Ie==="on_flow_start"||Ie==="on_flow_end"||Ie==="subflow"?!0:!TS(Ie)},max_edges:900});$=Oe.nodes,se=Oe.edges}if(e.prefer_vertical===!0&&$.length>=2){const Ne=$.map(Ge=>Ge.x),Oe=$.map(Ge=>Ge.y),it=Math.max(...Ne)-Math.min(...Ne),ve=Math.max(...Oe)-Math.min(...Oe);it>=ve&&($=$.map(Ge=>({...Ge,x:Ge.y,y:Ge.x})));const Ie=Math.min(...$.map(Ge=>Ge.y));$=$.map(Ge=>({...Ge,y:Ie+(Ge.y-Ie)*u}))}const he={};for(const Ne of $)he[Ne.id]=Ne;const be=160,je=56,Ce=be/2,Fe=je/2;let Ke=0,Ye=0,Ct=0,wt=0;$.length&&(Ke=Math.min(...$.map(Ne=>Ne.x)),Ye=Math.min(...$.map(Ne=>Ne.y)),Ct=Math.max(...$.map(Ne=>Ne.x+be)),wt=Math.max(...$.map(Ne=>Ne.y+je)));let lt=0;if(se.length){const Ne=new Set(se.map(Oe=>`${Oe.source}->${Oe.target}`));for(const Oe of se){if(!Ne.has(`${Oe.target}->${Oe.source}`))continue;const it=he[Oe.source],ve=he[Oe.target];if(!it||!ve)continue;const Ie=it.x+Ce,Ge=it.y+Fe,Mt=ve.x+Ce,Bt=ve.y+Fe,dn=Math.max(1,Math.hypot(Mt-Ie,Bt-Ge)),Ft=Math.max(28,Math.min(72,dn*.14)),At=Math.min(200,Ft*3.5);At>lt&&(lt=At)}}const yt=60+lt,rt={x:Ke-yt,y:Ye-yt,w:Ct-Ke+yt*2,h:wt-Ye+yt*2,node_w:be,node_h:je};return{nodes:$,edges:se,bounds:rt}},[n,e.flow_by_id,e.expand_subflows,e.simplify,e.prefer_vertical,o,u]);if(!n)return s.jsx("div",{className:"graph_empty mono",children:"(no graph loaded)"});const v=h.useRef(null),[w,b]=h.useState(()=>({x:g.x,y:g.y,w:g.w,h:g.h})),C=h.useRef(w);C.current=w,h.useEffect(()=>{b({x:g.x,y:g.y,w:g.w,h:g.h})},[g.x,g.y,g.w,g.h]);const S=h.useRef(new Map),R=h.useRef(null),T=`${w.x} ${w.y} ${w.w} ${w.h}`,D={};for(const I of m)D[I.id]=I;const q=I=>{let O=Qt(I).trim();if(!O)return"";if(D[O])return O;for(;O.includes("::");)if(O=O.slice(0,Math.max(0,O.lastIndexOf("::"))),D[O])return O;return""},P=q(o),K={};for(const[I,O]of Object.entries(a)){if(typeof O!="number")continue;const G=q(I);G&&(K[G]=Math.max(K[G]||0,O))}const Q={};if(d)for(const[I,O]of Object.entries(l)){if(typeof O!="number")continue;const G=q(I);G&&(Q[G]=typeof Q[G]=="number"?Math.min(Q[G],O):O)}const Z=Qt(e.schedule_next_in).trim(),ee=Qt(e.schedule_interval).trim(),ue=e.node_last_ms&&typeof e.node_last_ms=="object"?e.node_last_ms:{},de=I=>{try{const O=new Date(I),G=String(O.getHours()).padStart(2,"0"),$=String(O.getMinutes()).padStart(2,"0");return`${G}:${$}`}catch{return""}},pe=(I,O)=>{var se,le;const G=Qt((se=I.meta)==null?void 0:se.schedule).trim();if(!(((le=I.meta)==null?void 0:le.recurrent)===!0))return O&&Z?`next ${Z}`:G&&G.length<=12&&!G.includes("T")?`in ${G}`:"scheduled";const Y=G||ee;return Y?O&&Z?`${Y} • next ${Z}`:`every ${Y}`:O&&Z?`next ${Z}`:"scheduled"},F=I=>{var be;const O=Qt((be=I.meta)==null?void 0:be.subflow_id).trim(),G=O&&e.flow_by_id?e.flow_by_id[O]:null,Y=Qt(G==null?void 0:G.name).trim()||O||I.label||I.id,se=typeof ue[I.id]=="number"?Number(ue[I.id]):null,le=se!==null?de(se):"",he=le?`last ${le}`:"subflow";return{label:Y,sub:he}},E=(I,O,G)=>{const $=G||C.current,Y=v.current;if(!Y)return{x:I,y:O};const se=Y.getBoundingClientRect(),le=se.width>0?(I-se.left)/se.width:0,he=se.height>0?(O-se.top)/se.height:0;return{x:$.x+le*$.w,y:$.y+he*$.h}},j=(I,O,G)=>{const $=G||C.current,Y=Math.max(.12,Math.min(8,O)),se=$.w*Y,le=$.h*Y,he=$.w>0?(I.x-$.x)/$.w:.5,be=$.h>0?(I.y-$.y)/$.h:.5,je=I.x-he*se,Ce=I.y-be*le;b(fg({x:je,y:Ce,w:se,h:le},g))},L=(I,O,G)=>{const $=G||C.current,Y=v.current;if(!Y)return;const se=Y.getBoundingClientRect(),le=.88,he=se.width>0?I/se.width*$.w*le:0,be=se.height>0?O/se.height*$.h*le:0;b(je=>fg({x:(G||je).x-he,y:(G||je).y-be,w:(G||je).w,h:(G||je).h},g))},z=h.useMemo(()=>{const I=new Set;for(const O of y)I.add(`${O.source}->${O.target}`);return I},[y]),te=(I,O,G,$)=>{const Y=g.node_w,se=g.node_h,le=Math.abs(G),he=Math.abs($);if(le<1e-6&&he<1e-6)return{x:I,y:O};const be=le>1e-6?Y/2/le:Number.POSITIVE_INFINITY,je=he>1e-6?se/2/he:Number.POSITIVE_INFINITY,Ce=Math.min(be,je);return{x:I+G*Ce,y:O+$*Ce}};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 I=v.current;if(!I)return;const O=I.getBoundingClientRect(),G=E(O.left+O.width/2,O.top+O.height/2);j(G,.84)},title:"Zoom in",children:"+"}),s.jsx("button",{className:"btn graph_corner_btn",type:"button",onClick:()=>{const I=v.current;if(!I)return;const O=I.getBoundingClientRect(),G=E(O.left+O.width/2,O.top+O.height/2);j(G,1.18)},title:"Zoom out",children:"−"})]}),s.jsx($S,{})]}),s.jsxs("svg",{ref:v,className:"graph_svg",viewBox:T,role:"img","aria-label":"Workflow execution graph",onWheel:I=>{I.preventDefault();const O=E(I.clientX,I.clientY),G=typeof I.deltaY=="number"?I.deltaY:0,$=typeof I.deltaMode=="number"?Number(I.deltaMode):0,Y=$===1?G*24:$===2?G*800:G,se=45e-5*1.15*1.1;let le=Math.exp(Y*se);le=Math.max(.86,Math.min(1.16,le)),j(O,le)},onPointerDown:I=>{var G,$;($=(G=I.currentTarget).setPointerCapture)==null||$.call(G,I.pointerId),S.current.set(I.pointerId,{x:I.clientX,y:I.clientY});const O=Array.from(S.current.values());if(O.length===1)R.current={mode:"pan",start_view:C.current,start_client:{x:I.clientX,y:I.clientY},start_dist:0,anchor_svg:{x:0,y:0}};else if(O.length>=2){const Y=O[0],se=O[1],le=Y.x-se.x,he=Y.y-se.y,be=Math.max(1,Math.hypot(le,he)),je={x:(Y.x+se.x)/2,y:(Y.y+se.y)/2},Ce=C.current;R.current={mode:"pinch",start_view:Ce,start_client:je,start_dist:be,anchor_svg:E(je.x,je.y,Ce)}}},onPointerMove:I=>{if(!S.current.has(I.pointerId))return;S.current.set(I.pointerId,{x:I.clientX,y:I.clientY});const O=R.current;if(!O)return;const G=Array.from(S.current.values());if(O.mode==="pan"&&G.length===1){const $=I.clientX-O.start_client.x,Y=I.clientY-O.start_client.y;L($,Y,O.start_view)}else if(O.mode==="pinch"&&G.length>=2){const $=G[0],Y=G[1],se=$.x-Y.x,le=$.y-Y.y,he=Math.max(1,Math.hypot(se,le)),be=O.start_dist/he;j(O.anchor_svg,be,O.start_view)}},onPointerUp:I=>{S.current.delete(I.pointerId),S.current.size===0&&(R.current=null)},onPointerCancel:I=>{S.current.delete(I.pointerId),S.current.size===0&&(R.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"})]})]})]}),y.map(I=>{const O=D[I.source],G=D[I.target];if(!O||!G)return null;const $=O.x+g.node_w/2,Y=O.y+g.node_h/2,se=G.x+g.node_w/2,le=G.y+g.node_h/2,he=se-$,be=le-Y,je=te($,Y,he,be),Ce=te(se,le,-he,-be),Fe=I.source!==I.target&&z.has(`${I.target}->${I.source}`),Ke=Math.max(1,Math.hypot(he,be)),Ye=-be/Ke,Ct=he/Ke,wt=String(I.source)<String(I.target)?1:-1,yt=Math.abs(he)>=Math.abs(be)?he>=0:be>=0,rt=!Fe||yt,Ne=Math.max(28,Math.min(72,Ke*.14)),Oe=Math.min(200,Ne*3.5),it=Fe&&!rt?Oe*wt:0,ve=(je.x+Ce.x)/2+Ye*it,Ie=(je.y+Ce.y)/2+Ct*it,Ge=Fe&&!rt?`M ${je.x} ${je.y} Q ${ve} ${Ie} ${Ce.x} ${Ce.y}`:`M ${je.x} ${je.y} L ${Ce.x} ${Ce.y}`,Mt=d&&Q&&Q[I.source]!==void 0&&Q[I.target]!==void 0;return s.jsx("path",{d:Ge,className:`graph_edge ${Mt?"visited":""}`,markerEnd:"url(#arrow)",fill:"none"},I.id)}),m.map(I=>{const G=(typeof K[I.id]=="number"?K[I.id]:0)>t,$=P&&I.id===P,Y=d&&Q&&Q[I.id]!==void 0,se=`graph_node ${$?"active":G?"recent":""} ${Y?"visited":""}`,le=I.color||"rgba(255,255,255,0.16)";let he=I.label||I.id,be=I.type;if(I.type==="on_schedule")be=pe(I,!!$);else if(I.type==="subflow"){const Fe=F(I);he=Fe.label,be=Fe.sub}const je=dg(he,22),Ce=dg(be,22);return s.jsxs("g",{className:se,transform:`translate(${I.x}, ${I.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:le}),s.jsx("text",{className:"graph_node_label",x:12,y:28,children:je}),s.jsx("text",{className:"graph_node_type",x:12,y:46,children:Ce}),I.type==="on_schedule"?s.jsx("text",{className:"graph_node_icon",x:g.node_w-18,y:18,children:"⏰"}):null]},I.id)})]})]})}function zr(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=zr(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Wh={exports:{}},qh={},Vh={exports:{}},Gh={};/**
|
|
106
|
+
* @license React
|
|
107
|
+
* use-sync-external-store-shim.production.js
|
|
108
|
+
*
|
|
109
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
110
|
+
*
|
|
111
|
+
* This source code is licensed under the MIT license found in the
|
|
112
|
+
* LICENSE file in the root directory of this source tree.
|
|
113
|
+
*/var mg;function PS(){if(mg)return Gh;mg=1;var e=Kd();function t(v,w){return v===w&&(v!==0||1/v===1/w)||v!==v&&w!==w}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,a=e.useEffect,l=e.useLayoutEffect,d=e.useDebugValue;function u(v,w){var b=w(),C=o({inst:{value:b,getSnapshot:w}}),S=C[0].inst,R=C[1];return l(function(){S.value=b,S.getSnapshot=w,m(S)&&R({inst:S})},[v,b,w]),a(function(){return m(S)&&R({inst:S}),v(function(){m(S)&&R({inst:S})})},[v]),d(b),b}function m(v){var w=v.getSnapshot;v=v.value;try{var b=w();return!n(v,b)}catch{return!0}}function y(v,w){return w()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:u;return Gh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,Gh}var hg;function OS(){return hg||(hg=1,Vh.exports=PS()),Vh.exports}/**
|
|
114
|
+
* @license React
|
|
115
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
116
|
+
*
|
|
117
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the MIT license found in the
|
|
120
|
+
* LICENSE file in the root directory of this source tree.
|
|
121
|
+
*/var _g;function zS(){if(_g)return qh;_g=1;var e=Kd(),t=OS();function n(y,g){return y===g&&(y!==0||1/y===1/g)||y!==y&&g!==g}var o=typeof Object.is=="function"?Object.is:n,a=t.useSyncExternalStore,l=e.useRef,d=e.useEffect,u=e.useMemo,m=e.useDebugValue;return qh.useSyncExternalStoreWithSelector=function(y,g,v,w,b){var C=l(null);if(C.current===null){var S={hasValue:!1,value:null};C.current=S}else S=C.current;C=u(function(){function T(Q){if(!D){if(D=!0,q=Q,Q=w(Q),b!==void 0&&S.hasValue){var Z=S.value;if(b(Z,Q))return P=Z}return P=Q}if(Z=P,o(q,Q))return Z;var ee=w(Q);return b!==void 0&&b(Z,ee)?(q=Q,Z):(q=Q,P=ee)}var D=!1,q,P,K=v===void 0?null:v;return[function(){return T(g())},K===null?void 0:function(){return T(K())}]},[g,v,w,b]);var R=a(y,C[0],C[1]);return d(function(){S.hasValue=!0,S.value=R},[R]),m(R),R},qh}var pg;function IS(){return pg||(pg=1,Wh.exports=zS()),Wh.exports}var DS=IS();const FS=Y_(DS),BS={},gg=e=>{let t;const n=new Set,o=(g,v)=>{const w=typeof g=="function"?g(t):g;if(!Object.is(w,t)){const b=t;t=v??(typeof w!="object"||w===null)?w:Object.assign({},t,w),n.forEach(C=>C(t,b))}},a=()=>t,m={setState:o,getState:a,getInitialState:()=>y,subscribe:g=>(n.add(g),()=>n.delete(g)),destroy:()=>{(BS?"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."),n.clear()}},y=t=e(o,a,m);return m},US=e=>e?gg(e):gg,{useDebugValue:HS}=ye,{useSyncExternalStoreWithSelector:WS}=FS,qS=e=>e;function vv(e,t=qS,n){const o=WS(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return HS(o),o}const yg=(e,t)=>{const n=US(e),o=(a,l=t)=>vv(n,a,l);return Object.assign(o,n),o},VS=(e,t)=>e?yg(e,t):yg;function Nr(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,a]of e)if(!Object.is(a,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 n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}var GS={value:()=>{}};function Xm(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Sm(n)}function Sm(e){this._=e}function KS(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",a=n.indexOf(".");if(a>=0&&(o=n.slice(a+1),n=n.slice(0,a)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Sm.prototype=Xm.prototype={constructor:Sm,on:function(e,t){var n=this._,o=KS(e+"",n),a,l=-1,d=o.length;if(arguments.length<2){for(;++l<d;)if((a=(e=o[l]).type)&&(a=YS(n[a],e.name)))return a;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++l<d;)if(a=(e=o[l]).type)n[a]=vg(n[a],e.name,t);else if(t==null)for(a in n)n[a]=vg(n[a],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Sm(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var n=new Array(a),o=0,a,l;o<a;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],o=0,a=l.length;o<a;++o)l[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],a=0,l=o.length;a<l;++a)o[a].value.apply(t,n)}};function YS(e,t){for(var n=0,o=e.length,a;n<o;++n)if((a=e[n]).name===t)return a.value}function vg(e,t,n){for(var o=0,a=e.length;o<a;++o)if(e[o].name===t){e[o]=GS,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var C_="http://www.w3.org/1999/xhtml";const wg={svg:"http://www.w3.org/2000/svg",xhtml:C_,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Jm(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),wg.hasOwnProperty(t)?{space:wg[t],local:e}:e}function XS(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===C_&&t.documentElement.namespaceURI===C_?t.createElement(e):t.createElementNS(n,e)}}function JS(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function wv(e){var t=Jm(e);return(t.local?JS:XS)(t)}function ZS(){}function sp(e){return e==null?ZS:function(){return this.querySelector(e)}}function QS(e){typeof e!="function"&&(e=sp(e));for(var t=this._groups,n=t.length,o=new Array(n),a=0;a<n;++a)for(var l=t[a],d=l.length,u=o[a]=new Array(d),m,y,g=0;g<d;++g)(m=l[g])&&(y=e.call(m,m.__data__,g,l))&&("__data__"in m&&(y.__data__=m.__data__),u[g]=y);return new Vs(o,this._parents)}function ej(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function tj(){return[]}function xv(e){return e==null?tj:function(){return this.querySelectorAll(e)}}function nj(e){return function(){return ej(e.apply(this,arguments))}}function rj(e){typeof e=="function"?e=nj(e):e=xv(e);for(var t=this._groups,n=t.length,o=[],a=[],l=0;l<n;++l)for(var d=t[l],u=d.length,m,y=0;y<u;++y)(m=d[y])&&(o.push(e.call(m,m.__data__,y,d)),a.push(m));return new Vs(o,a)}function bv(e){return function(){return this.matches(e)}}function Sv(e){return function(t){return t.matches(e)}}var sj=Array.prototype.find;function ij(e){return function(){return sj.call(this.children,e)}}function oj(){return this.firstElementChild}function aj(e){return this.select(e==null?oj:ij(typeof e=="function"?e:Sv(e)))}var lj=Array.prototype.filter;function cj(){return Array.from(this.children)}function uj(e){return function(){return lj.call(this.children,e)}}function dj(e){return this.selectAll(e==null?cj:uj(typeof e=="function"?e:Sv(e)))}function fj(e){typeof e!="function"&&(e=bv(e));for(var t=this._groups,n=t.length,o=new Array(n),a=0;a<n;++a)for(var l=t[a],d=l.length,u=o[a]=[],m,y=0;y<d;++y)(m=l[y])&&e.call(m,m.__data__,y,l)&&u.push(m);return new Vs(o,this._parents)}function jv(e){return new Array(e.length)}function mj(){return new Vs(this._enter||this._groups.map(jv),this._parents)}function Pm(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Pm.prototype={constructor:Pm,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 hj(e){return function(){return e}}function _j(e,t,n,o,a,l){for(var d=0,u,m=t.length,y=l.length;d<y;++d)(u=t[d])?(u.__data__=l[d],o[d]=u):n[d]=new Pm(e,l[d]);for(;d<m;++d)(u=t[d])&&(a[d]=u)}function pj(e,t,n,o,a,l,d){var u,m,y=new Map,g=t.length,v=l.length,w=new Array(g),b;for(u=0;u<g;++u)(m=t[u])&&(w[u]=b=d.call(m,m.__data__,u,t)+"",y.has(b)?a[u]=m:y.set(b,m));for(u=0;u<v;++u)b=d.call(e,l[u],u,l)+"",(m=y.get(b))?(o[u]=m,m.__data__=l[u],y.delete(b)):n[u]=new Pm(e,l[u]);for(u=0;u<g;++u)(m=t[u])&&y.get(w[u])===m&&(a[u]=m)}function gj(e){return e.__data__}function yj(e,t){if(!arguments.length)return Array.from(this,gj);var n=t?pj:_j,o=this._parents,a=this._groups;typeof e!="function"&&(e=hj(e));for(var l=a.length,d=new Array(l),u=new Array(l),m=new Array(l),y=0;y<l;++y){var g=o[y],v=a[y],w=v.length,b=vj(e.call(g,g&&g.__data__,y,o)),C=b.length,S=u[y]=new Array(C),R=d[y]=new Array(C),T=m[y]=new Array(w);n(g,v,S,R,T,b,t);for(var D=0,q=0,P,K;D<C;++D)if(P=S[D]){for(D>=q&&(q=D+1);!(K=R[q])&&++q<C;);P._next=K||null}}return d=new Vs(d,o),d._enter=u,d._exit=m,d}function vj(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function wj(){return new Vs(this._exit||this._groups.map(jv),this._parents)}function xj(e,t,n){var o=this.enter(),a=this,l=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(a=t(a),a&&(a=a.selection())),n==null?l.remove():n(l),o&&a?o.merge(a).order():a}function bj(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,a=n.length,l=o.length,d=Math.min(a,l),u=new Array(a),m=0;m<d;++m)for(var y=n[m],g=o[m],v=y.length,w=u[m]=new Array(v),b,C=0;C<v;++C)(b=y[C]||g[C])&&(w[C]=b);for(;m<a;++m)u[m]=n[m];return new Vs(u,this._parents)}function Sj(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],a=o.length-1,l=o[a],d;--a>=0;)(d=o[a])&&(l&&d.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(d,l),l=d);return this}function jj(e){e||(e=kj);function t(v,w){return v&&w?e(v.__data__,w.__data__):!v-!w}for(var n=this._groups,o=n.length,a=new Array(o),l=0;l<o;++l){for(var d=n[l],u=d.length,m=a[l]=new Array(u),y,g=0;g<u;++g)(y=d[g])&&(m[g]=y);m.sort(t)}return new Vs(a,this._parents).order()}function kj(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Nj(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Cj(){return Array.from(this)}function Ej(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],a=0,l=o.length;a<l;++a){var d=o[a];if(d)return d}return null}function $j(){let e=0;for(const t of this)++e;return e}function Mj(){return!this.node()}function Aj(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var a=t[n],l=0,d=a.length,u;l<d;++l)(u=a[l])&&e.call(u,u.__data__,l,a);return this}function Tj(e){return function(){this.removeAttribute(e)}}function Rj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Lj(e,t){return function(){this.setAttribute(e,t)}}function Pj(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Oj(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function zj(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Ij(e,t){var n=Jm(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?Rj:Tj:typeof t=="function"?n.local?zj:Oj:n.local?Pj:Lj)(n,t))}function kv(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Dj(e){return function(){this.style.removeProperty(e)}}function Fj(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Bj(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function Uj(e,t,n){return arguments.length>1?this.each((t==null?Dj:typeof t=="function"?Bj:Fj)(e,t,n??"")):_u(this.node(),e)}function _u(e,t){return e.style.getPropertyValue(t)||kv(e).getComputedStyle(e,null).getPropertyValue(t)}function Hj(e){return function(){delete this[e]}}function Wj(e,t){return function(){this[e]=t}}function qj(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Vj(e,t){return arguments.length>1?this.each((t==null?Hj:typeof t=="function"?qj:Wj)(e,t)):this.node()[e]}function Nv(e){return e.trim().split(/^|\s+/)}function ip(e){return e.classList||new Cv(e)}function Cv(e){this._node=e,this._names=Nv(e.getAttribute("class")||"")}Cv.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 Ev(e,t){for(var n=ip(e),o=-1,a=t.length;++o<a;)n.add(t[o])}function $v(e,t){for(var n=ip(e),o=-1,a=t.length;++o<a;)n.remove(t[o])}function Gj(e){return function(){Ev(this,e)}}function Kj(e){return function(){$v(this,e)}}function Yj(e,t){return function(){(t.apply(this,arguments)?Ev:$v)(this,e)}}function Xj(e,t){var n=Nv(e+"");if(arguments.length<2){for(var o=ip(this.node()),a=-1,l=n.length;++a<l;)if(!o.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?Yj:t?Gj:Kj)(n,t))}function Jj(){this.textContent=""}function Zj(e){return function(){this.textContent=e}}function Qj(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function ek(e){return arguments.length?this.each(e==null?Jj:(typeof e=="function"?Qj:Zj)(e)):this.node().textContent}function tk(){this.innerHTML=""}function nk(e){return function(){this.innerHTML=e}}function rk(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function sk(e){return arguments.length?this.each(e==null?tk:(typeof e=="function"?rk:nk)(e)):this.node().innerHTML}function ik(){this.nextSibling&&this.parentNode.appendChild(this)}function ok(){return this.each(ik)}function ak(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function lk(){return this.each(ak)}function ck(e){var t=typeof e=="function"?e:wv(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function uk(){return null}function dk(e,t){var n=typeof e=="function"?e:wv(e),o=t==null?uk:typeof t=="function"?t:sp(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function fk(){var e=this.parentNode;e&&e.removeChild(this)}function mk(){return this.each(fk)}function hk(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _k(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function pk(e){return this.select(e?_k:hk)}function gk(e){return arguments.length?this.property("__data__",e):this.node().__data__}function yk(e){return function(t){e.call(this,t,this.__data__)}}function vk(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function wk(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,a=t.length,l;n<a;++n)l=t[n],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):t[++o]=l;++o?t.length=o:delete this.__on}}}function xk(e,t,n){return function(){var o=this.__on,a,l=yk(t);if(o){for(var d=0,u=o.length;d<u;++d)if((a=o[d]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=l,a.options=n),a.value=t;return}}this.addEventListener(e.type,l,n),a={type:e.type,name:e.name,value:t,listener:l,options:n},o?o.push(a):this.__on=[a]}}function bk(e,t,n){var o=vk(e+""),a,l=o.length,d;if(arguments.length<2){var u=this.node().__on;if(u){for(var m=0,y=u.length,g;m<y;++m)for(a=0,g=u[m];a<l;++a)if((d=o[a]).type===g.type&&d.name===g.name)return g.value}return}for(u=t?xk:wk,a=0;a<l;++a)this.each(u(o[a],t,n));return this}function Mv(e,t,n){var o=kv(e),a=o.CustomEvent;typeof a=="function"?a=new a(t,n):(a=o.document.createEvent("Event"),n?(a.initEvent(t,n.bubbles,n.cancelable),a.detail=n.detail):a.initEvent(t,!1,!1)),e.dispatchEvent(a)}function Sk(e,t){return function(){return Mv(this,e,t)}}function jk(e,t){return function(){return Mv(this,e,t.apply(this,arguments))}}function kk(e,t){return this.each((typeof t=="function"?jk:Sk)(e,t))}function*Nk(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],a=0,l=o.length,d;a<l;++a)(d=o[a])&&(yield d)}var Av=[null];function Vs(e,t){this._groups=e,this._parents=t}function Xd(){return new Vs([[document.documentElement]],Av)}function Ck(){return this}Vs.prototype=Xd.prototype={constructor:Vs,select:QS,selectAll:rj,selectChild:aj,selectChildren:dj,filter:fj,data:yj,enter:mj,exit:wj,join:xj,merge:bj,selection:Ck,order:Sj,sort:jj,call:Nj,nodes:Cj,node:Ej,size:$j,empty:Mj,each:Aj,attr:Ij,style:Uj,property:Vj,classed:Xj,text:ek,html:sk,raise:ok,lower:lk,append:ck,insert:dk,remove:mk,clone:pk,datum:gk,on:bk,dispatch:kk,[Symbol.iterator]:Nk};function mi(e){return typeof e=="string"?new Vs([[document.querySelector(e)]],[document.documentElement]):new Vs([[e]],Av)}function Ek(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Hi(e,t){if(e=Ek(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}}return[e.pageX,e.pageY]}const $k={passive:!1},zd={capture:!0,passive:!1};function Kh(e){e.stopImmediatePropagation()}function uu(e){e.preventDefault(),e.stopImmediatePropagation()}function Tv(e){var t=e.document.documentElement,n=mi(e).on("dragstart.drag",uu,zd);"onselectstart"in t?n.on("selectstart.drag",uu,zd):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Rv(e,t){var n=e.document.documentElement,o=mi(e).on("dragstart.drag",null);t&&(o.on("click.drag",uu,zd),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const am=e=>()=>e;function E_(e,{sourceEvent:t,subject:n,target:o,identifier:a,active:l,x:d,y:u,dx:m,dy:y,dispatch:g}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:d,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:m,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:g}})}E_.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Mk(e){return!e.ctrlKey&&!e.button}function Ak(){return this.parentNode}function Tk(e,t){return t??{x:e.x,y:e.y}}function Rk(){return navigator.maxTouchPoints||"ontouchstart"in this}function Lk(){var e=Mk,t=Ak,n=Tk,o=Rk,a={},l=Xm("start","drag","end"),d=0,u,m,y,g,v=0;function w(P){P.on("mousedown.drag",b).filter(o).on("touchstart.drag",R).on("touchmove.drag",T,$k).on("touchend.drag touchcancel.drag",D).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(P,K){if(!(g||!e.call(this,P,K))){var Q=q(this,t.call(this,P,K),P,K,"mouse");Q&&(mi(P.view).on("mousemove.drag",C,zd).on("mouseup.drag",S,zd),Tv(P.view),Kh(P),y=!1,u=P.clientX,m=P.clientY,Q("start",P))}}function C(P){if(uu(P),!y){var K=P.clientX-u,Q=P.clientY-m;y=K*K+Q*Q>v}a.mouse("drag",P)}function S(P){mi(P.view).on("mousemove.drag mouseup.drag",null),Rv(P.view,y),uu(P),a.mouse("end",P)}function R(P,K){if(e.call(this,P,K)){var Q=P.changedTouches,Z=t.call(this,P,K),ee=Q.length,ue,de;for(ue=0;ue<ee;++ue)(de=q(this,Z,P,K,Q[ue].identifier,Q[ue]))&&(Kh(P),de("start",P,Q[ue]))}}function T(P){var K=P.changedTouches,Q=K.length,Z,ee;for(Z=0;Z<Q;++Z)(ee=a[K[Z].identifier])&&(uu(P),ee("drag",P,K[Z]))}function D(P){var K=P.changedTouches,Q=K.length,Z,ee;for(g&&clearTimeout(g),g=setTimeout(function(){g=null},500),Z=0;Z<Q;++Z)(ee=a[K[Z].identifier])&&(Kh(P),ee("end",P,K[Z]))}function q(P,K,Q,Z,ee,ue){var de=l.copy(),pe=Hi(ue||Q,K),F,E,j;if((j=n.call(P,new E_("beforestart",{sourceEvent:Q,target:w,identifier:ee,active:d,x:pe[0],y:pe[1],dx:0,dy:0,dispatch:de}),Z))!=null)return F=j.x-pe[0]||0,E=j.y-pe[1]||0,function L(z,te,I){var O=pe,G;switch(z){case"start":a[ee]=L,G=d++;break;case"end":delete a[ee],--d;case"drag":pe=Hi(I||te,K),G=d;break}de.call(z,P,new E_(z,{sourceEvent:te,subject:j,target:w,identifier:ee,active:G,x:pe[0]+F,y:pe[1]+E,dx:pe[0]-O[0],dy:pe[1]-O[1],dispatch:de}),Z)}}return w.filter=function(P){return arguments.length?(e=typeof P=="function"?P:am(!!P),w):e},w.container=function(P){return arguments.length?(t=typeof P=="function"?P:am(P),w):t},w.subject=function(P){return arguments.length?(n=typeof P=="function"?P:am(P),w):n},w.touchable=function(P){return arguments.length?(o=typeof P=="function"?P:am(!!P),w):o},w.on=function(){var P=l.on.apply(l,arguments);return P===l?w:P},w.clickDistance=function(P){return arguments.length?(v=(P=+P)*P,w):Math.sqrt(v)},w}function op(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Lv(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function Jd(){}var Id=.7,Om=1/Id,du="\\s*([+-]?\\d+)\\s*",Dd="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",lo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Pk=/^#([0-9a-f]{3,8})$/,Ok=new RegExp(`^rgb\\(${du},${du},${du}\\)$`),zk=new RegExp(`^rgb\\(${lo},${lo},${lo}\\)$`),Ik=new RegExp(`^rgba\\(${du},${du},${du},${Dd}\\)$`),Dk=new RegExp(`^rgba\\(${lo},${lo},${lo},${Dd}\\)$`),Fk=new RegExp(`^hsl\\(${Dd},${lo},${lo}\\)$`),Bk=new RegExp(`^hsla\\(${Dd},${lo},${lo},${Dd}\\)$`),xg={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};op(Jd,Fd,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:bg,formatHex:bg,formatHex8:Uk,formatHsl:Hk,formatRgb:Sg,toString:Sg});function bg(){return this.rgb().formatHex()}function Uk(){return this.rgb().formatHex8()}function Hk(){return Pv(this).formatHsl()}function Sg(){return this.rgb().formatRgb()}function Fd(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Pk.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?jg(t):n===3?new Es(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?lm(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?lm(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=Ok.exec(e))?new Es(t[1],t[2],t[3],1):(t=zk.exec(e))?new Es(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Ik.exec(e))?lm(t[1],t[2],t[3],t[4]):(t=Dk.exec(e))?lm(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Fk.exec(e))?Cg(t[1],t[2]/100,t[3]/100,1):(t=Bk.exec(e))?Cg(t[1],t[2]/100,t[3]/100,t[4]):xg.hasOwnProperty(e)?jg(xg[e]):e==="transparent"?new Es(NaN,NaN,NaN,0):null}function jg(e){return new Es(e>>16&255,e>>8&255,e&255,1)}function lm(e,t,n,o){return o<=0&&(e=t=n=NaN),new Es(e,t,n,o)}function Wk(e){return e instanceof Jd||(e=Fd(e)),e?(e=e.rgb(),new Es(e.r,e.g,e.b,e.opacity)):new Es}function $_(e,t,n,o){return arguments.length===1?Wk(e):new Es(e,t,n,o??1)}function Es(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}op(Es,$_,Lv(Jd,{brighter(e){return e=e==null?Om:Math.pow(Om,e),new Es(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Id:Math.pow(Id,e),new Es(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Es(ec(this.r),ec(this.g),ec(this.b),zm(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:kg,formatHex:kg,formatHex8:qk,formatRgb:Ng,toString:Ng}));function kg(){return`#${Xl(this.r)}${Xl(this.g)}${Xl(this.b)}`}function qk(){return`#${Xl(this.r)}${Xl(this.g)}${Xl(this.b)}${Xl((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ng(){const e=zm(this.opacity);return`${e===1?"rgb(":"rgba("}${ec(this.r)}, ${ec(this.g)}, ${ec(this.b)}${e===1?")":`, ${e})`}`}function zm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ec(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Xl(e){return e=ec(e),(e<16?"0":"")+e.toString(16)}function Cg(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Wi(e,t,n,o)}function Pv(e){if(e instanceof Wi)return new Wi(e.h,e.s,e.l,e.opacity);if(e instanceof Jd||(e=Fd(e)),!e)return new Wi;if(e instanceof Wi)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,a=Math.min(t,n,o),l=Math.max(t,n,o),d=NaN,u=l-a,m=(l+a)/2;return u?(t===l?d=(n-o)/u+(n<o)*6:n===l?d=(o-t)/u+2:d=(t-n)/u+4,u/=m<.5?l+a:2-l-a,d*=60):u=m>0&&m<1?0:d,new Wi(d,u,m,e.opacity)}function Vk(e,t,n,o){return arguments.length===1?Pv(e):new Wi(e,t,n,o??1)}function Wi(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}op(Wi,Vk,Lv(Jd,{brighter(e){return e=e==null?Om:Math.pow(Om,e),new Wi(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Id:Math.pow(Id,e),new Wi(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,n=this.l,o=n+(n<.5?n:1-n)*t,a=2*n-o;return new Es(Yh(e>=240?e-240:e+120,a,o),Yh(e,a,o),Yh(e<120?e+240:e-120,a,o),this.opacity)},clamp(){return new Wi(Eg(this.h),cm(this.s),cm(this.l),zm(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=zm(this.opacity);return`${e===1?"hsl(":"hsla("}${Eg(this.h)}, ${cm(this.s)*100}%, ${cm(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Eg(e){return e=(e||0)%360,e<0?e+360:e}function cm(e){return Math.max(0,Math.min(1,e||0))}function Yh(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Ov=e=>()=>e;function Gk(e,t){return function(n){return e+n*t}}function Kk(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function Yk(e){return(e=+e)==1?zv:function(t,n){return n-t?Kk(t,n,e):Ov(isNaN(t)?n:t)}}function zv(e,t){var n=t-e;return n?Gk(e,n):Ov(isNaN(e)?t:e)}const $g=(function e(t){var n=Yk(t);function o(a,l){var d=n((a=$_(a)).r,(l=$_(l)).r),u=n(a.g,l.g),m=n(a.b,l.b),y=zv(a.opacity,l.opacity);return function(g){return a.r=d(g),a.g=u(g),a.b=m(g),a.opacity=y(g),a+""}}return o.gamma=e,o})(1);function Va(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var M_=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Xh=new RegExp(M_.source,"g");function Xk(e){return function(){return e}}function Jk(e){return function(t){return e(t)+""}}function Zk(e,t){var n=M_.lastIndex=Xh.lastIndex=0,o,a,l,d=-1,u=[],m=[];for(e=e+"",t=t+"";(o=M_.exec(e))&&(a=Xh.exec(t));)(l=a.index)>n&&(l=t.slice(n,l),u[d]?u[d]+=l:u[++d]=l),(o=o[0])===(a=a[0])?u[d]?u[d]+=a:u[++d]=a:(u[++d]=null,m.push({i:d,x:Va(o,a)})),n=Xh.lastIndex;return n<t.length&&(l=t.slice(n),u[d]?u[d]+=l:u[++d]=l),u.length<2?m[0]?Jk(m[0].x):Xk(t):(t=m.length,function(y){for(var g=0,v;g<t;++g)u[(v=m[g]).i]=v.x(y);return u.join("")})}var Mg=180/Math.PI,A_={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Iv(e,t,n,o,a,l){var d,u,m;return(d=Math.sqrt(e*e+t*t))&&(e/=d,t/=d),(m=e*n+t*o)&&(n-=e*m,o-=t*m),(u=Math.sqrt(n*n+o*o))&&(n/=u,o/=u,m/=u),e*o<t*n&&(e=-e,t=-t,m=-m,d=-d),{translateX:a,translateY:l,rotate:Math.atan2(t,e)*Mg,skewX:Math.atan(m)*Mg,scaleX:d,scaleY:u}}var um;function Qk(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?A_:Iv(t.a,t.b,t.c,t.d,t.e,t.f)}function eN(e){return e==null||(um||(um=document.createElementNS("http://www.w3.org/2000/svg","g")),um.setAttribute("transform",e),!(e=um.transform.baseVal.consolidate()))?A_:(e=e.matrix,Iv(e.a,e.b,e.c,e.d,e.e,e.f))}function Dv(e,t,n,o){function a(y){return y.length?y.pop()+" ":""}function l(y,g,v,w,b,C){if(y!==v||g!==w){var S=b.push("translate(",null,t,null,n);C.push({i:S-4,x:Va(y,v)},{i:S-2,x:Va(g,w)})}else(v||w)&&b.push("translate("+v+t+w+n)}function d(y,g,v,w){y!==g?(y-g>180?g+=360:g-y>180&&(y+=360),w.push({i:v.push(a(v)+"rotate(",null,o)-2,x:Va(y,g)})):g&&v.push(a(v)+"rotate("+g+o)}function u(y,g,v,w){y!==g?w.push({i:v.push(a(v)+"skewX(",null,o)-2,x:Va(y,g)}):g&&v.push(a(v)+"skewX("+g+o)}function m(y,g,v,w,b,C){if(y!==v||g!==w){var S=b.push(a(b)+"scale(",null,",",null,")");C.push({i:S-4,x:Va(y,v)},{i:S-2,x:Va(g,w)})}else(v!==1||w!==1)&&b.push(a(b)+"scale("+v+","+w+")")}return function(y,g){var v=[],w=[];return y=e(y),g=e(g),l(y.translateX,y.translateY,g.translateX,g.translateY,v,w),d(y.rotate,g.rotate,v,w),u(y.skewX,g.skewX,v,w),m(y.scaleX,y.scaleY,g.scaleX,g.scaleY,v,w),y=g=null,function(b){for(var C=-1,S=w.length,R;++C<S;)v[(R=w[C]).i]=R.x(b);return v.join("")}}}var tN=Dv(Qk,"px, ","px)","deg)"),nN=Dv(eN,", ",")",")"),rN=1e-12;function Ag(e){return((e=Math.exp(e))+1/e)/2}function sN(e){return((e=Math.exp(e))-1/e)/2}function iN(e){return((e=Math.exp(2*e))-1)/(e+1)}const oN=(function e(t,n,o){function a(l,d){var u=l[0],m=l[1],y=l[2],g=d[0],v=d[1],w=d[2],b=g-u,C=v-m,S=b*b+C*C,R,T;if(S<rN)T=Math.log(w/y)/t,R=function(Z){return[u+Z*b,m+Z*C,y*Math.exp(t*Z*T)]};else{var D=Math.sqrt(S),q=(w*w-y*y+o*S)/(2*y*n*D),P=(w*w-y*y-o*S)/(2*w*n*D),K=Math.log(Math.sqrt(q*q+1)-q),Q=Math.log(Math.sqrt(P*P+1)-P);T=(Q-K)/t,R=function(Z){var ee=Z*T,ue=Ag(K),de=y/(n*D)*(ue*iN(t*ee+K)-sN(K));return[u+de*b,m+de*C,y*ue/Ag(t*ee+K)]}}return R.duration=T*1e3*t/Math.SQRT2,R}return a.rho=function(l){var d=Math.max(.001,+l),u=d*d,m=u*u;return e(d,u,m)},a})(Math.SQRT2,2,4);var pu=0,Ad=0,xd=0,Fv=1e3,Im,Td,Dm=0,sc=0,Zm=0,Bd=typeof performance=="object"&&performance.now?performance:Date,Bv=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ap(){return sc||(Bv(aN),sc=Bd.now()+Zm)}function aN(){sc=0}function Fm(){this._call=this._time=this._next=null}Fm.prototype=Uv.prototype={constructor:Fm,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ap():+n)+(t==null?0:+t),!this._next&&Td!==this&&(Td?Td._next=this:Im=this,Td=this),this._call=e,this._time=n,T_()},stop:function(){this._call&&(this._call=null,this._time=1/0,T_())}};function Uv(e,t,n){var o=new Fm;return o.restart(e,t,n),o}function lN(){ap(),++pu;for(var e=Im,t;e;)(t=sc-e._time)>=0&&e._call.call(void 0,t),e=e._next;--pu}function Tg(){sc=(Dm=Bd.now())+Zm,pu=Ad=0;try{lN()}finally{pu=0,uN(),sc=0}}function cN(){var e=Bd.now(),t=e-Dm;t>Fv&&(Zm-=t,Dm=e)}function uN(){for(var e,t=Im,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Im=n);Td=e,T_(o)}function T_(e){if(!pu){Ad&&(Ad=clearTimeout(Ad));var t=e-sc;t>24?(e<1/0&&(Ad=setTimeout(Tg,e-Bd.now()-Zm)),xd&&(xd=clearInterval(xd))):(xd||(Dm=Bd.now(),xd=setInterval(cN,Fv)),pu=1,Bv(Tg))}}function Rg(e,t,n){var o=new Fm;return t=t==null?0:+t,o.restart(a=>{o.stop(),e(a+t)},t,n),o}var dN=Xm("start","end","cancel","interrupt"),fN=[],Hv=0,Lg=1,R_=2,jm=3,Pg=4,L_=5,km=6;function Qm(e,t,n,o,a,l){var d=e.__transition;if(!d)e.__transition={};else if(n in d)return;mN(e,n,{name:t,index:o,group:a,on:dN,tween:fN,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:Hv})}function lp(e,t){var n=Gi(e,t);if(n.state>Hv)throw new Error("too late; already scheduled");return n}function co(e,t){var n=Gi(e,t);if(n.state>jm)throw new Error("too late; already running");return n}function Gi(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function mN(e,t,n){var o=e.__transition,a;o[t]=n,n.timer=Uv(l,0,n.time);function l(y){n.state=Lg,n.timer.restart(d,n.delay,n.time),n.delay<=y&&d(y-n.delay)}function d(y){var g,v,w,b;if(n.state!==Lg)return m();for(g in o)if(b=o[g],b.name===n.name){if(b.state===jm)return Rg(d);b.state===Pg?(b.state=km,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete o[g]):+g<t&&(b.state=km,b.timer.stop(),b.on.call("cancel",e,e.__data__,b.index,b.group),delete o[g])}if(Rg(function(){n.state===jm&&(n.state=Pg,n.timer.restart(u,n.delay,n.time),u(y))}),n.state=R_,n.on.call("start",e,e.__data__,n.index,n.group),n.state===R_){for(n.state=jm,a=new Array(w=n.tween.length),g=0,v=-1;g<w;++g)(b=n.tween[g].value.call(e,e.__data__,n.index,n.group))&&(a[++v]=b);a.length=v+1}}function u(y){for(var g=y<n.duration?n.ease.call(null,y/n.duration):(n.timer.restart(m),n.state=L_,1),v=-1,w=a.length;++v<w;)a[v].call(e,g);n.state===L_&&(n.on.call("end",e,e.__data__,n.index,n.group),m())}function m(){n.state=km,n.timer.stop(),delete o[t];for(var y in o)return;delete e.__transition}}function Nm(e,t){var n=e.__transition,o,a,l=!0,d;if(n){t=t==null?null:t+"";for(d in n){if((o=n[d]).name!==t){l=!1;continue}a=o.state>R_&&o.state<L_,o.state=km,o.timer.stop(),o.on.call(a?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[d]}l&&delete e.__transition}}function hN(e){return this.each(function(){Nm(this,e)})}function _N(e,t){var n,o;return function(){var a=co(this,e),l=a.tween;if(l!==n){o=n=l;for(var d=0,u=o.length;d<u;++d)if(o[d].name===t){o=o.slice(),o.splice(d,1);break}}a.tween=o}}function pN(e,t,n){var o,a;if(typeof n!="function")throw new Error;return function(){var l=co(this,e),d=l.tween;if(d!==o){a=(o=d).slice();for(var u={name:t,value:n},m=0,y=a.length;m<y;++m)if(a[m].name===t){a[m]=u;break}m===y&&a.push(u)}l.tween=a}}function gN(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Gi(this.node(),n).tween,a=0,l=o.length,d;a<l;++a)if((d=o[a]).name===e)return d.value;return null}return this.each((t==null?_N:pN)(n,e,t))}function cp(e,t,n){var o=e._id;return e.each(function(){var a=co(this,o);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return Gi(a,o).value[t]}}function Wv(e,t){var n;return(typeof t=="number"?Va:t instanceof Fd?$g:(n=Fd(t))?(t=n,$g):Zk)(e,t)}function yN(e){return function(){this.removeAttribute(e)}}function vN(e){return function(){this.removeAttributeNS(e.space,e.local)}}function wN(e,t,n){var o,a=n+"",l;return function(){var d=this.getAttribute(e);return d===a?null:d===o?l:l=t(o=d,n)}}function xN(e,t,n){var o,a=n+"",l;return function(){var d=this.getAttributeNS(e.space,e.local);return d===a?null:d===o?l:l=t(o=d,n)}}function bN(e,t,n){var o,a,l;return function(){var d,u=n(this),m;return u==null?void this.removeAttribute(e):(d=this.getAttribute(e),m=u+"",d===m?null:d===o&&m===a?l:(a=m,l=t(o=d,u)))}}function SN(e,t,n){var o,a,l;return function(){var d,u=n(this),m;return u==null?void this.removeAttributeNS(e.space,e.local):(d=this.getAttributeNS(e.space,e.local),m=u+"",d===m?null:d===o&&m===a?l:(a=m,l=t(o=d,u)))}}function jN(e,t){var n=Jm(e),o=n==="transform"?nN:Wv;return this.attrTween(e,typeof t=="function"?(n.local?SN:bN)(n,o,cp(this,"attr."+e,t)):t==null?(n.local?vN:yN)(n):(n.local?xN:wN)(n,o,t))}function kN(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function NN(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function CN(e,t){var n,o;function a(){var l=t.apply(this,arguments);return l!==o&&(n=(o=l)&&NN(e,l)),n}return a._value=t,a}function EN(e,t){var n,o;function a(){var l=t.apply(this,arguments);return l!==o&&(n=(o=l)&&kN(e,l)),n}return a._value=t,a}function $N(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Jm(e);return this.tween(n,(o.local?CN:EN)(o,t))}function MN(e,t){return function(){lp(this,e).delay=+t.apply(this,arguments)}}function AN(e,t){return t=+t,function(){lp(this,e).delay=t}}function TN(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?MN:AN)(t,e)):Gi(this.node(),t).delay}function RN(e,t){return function(){co(this,e).duration=+t.apply(this,arguments)}}function LN(e,t){return t=+t,function(){co(this,e).duration=t}}function PN(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?RN:LN)(t,e)):Gi(this.node(),t).duration}function ON(e,t){if(typeof t!="function")throw new Error;return function(){co(this,e).ease=t}}function zN(e){var t=this._id;return arguments.length?this.each(ON(t,e)):Gi(this.node(),t).ease}function IN(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;co(this,e).ease=n}}function DN(e){if(typeof e!="function")throw new Error;return this.each(IN(this._id,e))}function FN(e){typeof e!="function"&&(e=bv(e));for(var t=this._groups,n=t.length,o=new Array(n),a=0;a<n;++a)for(var l=t[a],d=l.length,u=o[a]=[],m,y=0;y<d;++y)(m=l[y])&&e.call(m,m.__data__,y,l)&&u.push(m);return new Zo(o,this._parents,this._name,this._id)}function BN(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,a=n.length,l=Math.min(o,a),d=new Array(o),u=0;u<l;++u)for(var m=t[u],y=n[u],g=m.length,v=d[u]=new Array(g),w,b=0;b<g;++b)(w=m[b]||y[b])&&(v[b]=w);for(;u<o;++u)d[u]=t[u];return new Zo(d,this._parents,this._name,this._id)}function UN(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function HN(e,t,n){var o,a,l=UN(t)?lp:co;return function(){var d=l(this,e),u=d.on;u!==o&&(a=(o=u).copy()).on(t,n),d.on=a}}function WN(e,t){var n=this._id;return arguments.length<2?Gi(this.node(),n).on.on(e):this.each(HN(n,e,t))}function qN(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function VN(){return this.on("end.remove",qN(this._id))}function GN(e){var t=this._name,n=this._id;typeof e!="function"&&(e=sp(e));for(var o=this._groups,a=o.length,l=new Array(a),d=0;d<a;++d)for(var u=o[d],m=u.length,y=l[d]=new Array(m),g,v,w=0;w<m;++w)(g=u[w])&&(v=e.call(g,g.__data__,w,u))&&("__data__"in g&&(v.__data__=g.__data__),y[w]=v,Qm(y[w],t,n,w,y,Gi(g,n)));return new Zo(l,this._parents,t,n)}function KN(e){var t=this._name,n=this._id;typeof e!="function"&&(e=xv(e));for(var o=this._groups,a=o.length,l=[],d=[],u=0;u<a;++u)for(var m=o[u],y=m.length,g,v=0;v<y;++v)if(g=m[v]){for(var w=e.call(g,g.__data__,v,m),b,C=Gi(g,n),S=0,R=w.length;S<R;++S)(b=w[S])&&Qm(b,t,n,S,w,C);l.push(w),d.push(g)}return new Zo(l,d,t,n)}var YN=Xd.prototype.constructor;function XN(){return new YN(this._groups,this._parents)}function JN(e,t){var n,o,a;return function(){var l=_u(this,e),d=(this.style.removeProperty(e),_u(this,e));return l===d?null:l===n&&d===o?a:a=t(n=l,o=d)}}function qv(e){return function(){this.style.removeProperty(e)}}function ZN(e,t,n){var o,a=n+"",l;return function(){var d=_u(this,e);return d===a?null:d===o?l:l=t(o=d,n)}}function QN(e,t,n){var o,a,l;return function(){var d=_u(this,e),u=n(this),m=u+"";return u==null&&(m=u=(this.style.removeProperty(e),_u(this,e))),d===m?null:d===o&&m===a?l:(a=m,l=t(o=d,u))}}function e1(e,t){var n,o,a,l="style."+t,d="end."+l,u;return function(){var m=co(this,e),y=m.on,g=m.value[l]==null?u||(u=qv(t)):void 0;(y!==n||a!==g)&&(o=(n=y).copy()).on(d,a=g),m.on=o}}function t1(e,t,n){var o=(e+="")=="transform"?tN:Wv;return t==null?this.styleTween(e,JN(e,o)).on("end.style."+e,qv(e)):typeof t=="function"?this.styleTween(e,QN(e,o,cp(this,"style."+e,t))).each(e1(this._id,e)):this.styleTween(e,ZN(e,o,t),n).on("end.style."+e,null)}function n1(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function r1(e,t,n){var o,a;function l(){var d=t.apply(this,arguments);return d!==a&&(o=(a=d)&&n1(e,d,n)),o}return l._value=t,l}function s1(e,t,n){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,r1(e,t,n??""))}function i1(e){return function(){this.textContent=e}}function o1(e){return function(){var t=e(this);this.textContent=t??""}}function a1(e){return this.tween("text",typeof e=="function"?o1(cp(this,"text",e)):i1(e==null?"":e+""))}function l1(e){return function(t){this.textContent=e.call(this,t)}}function c1(e){var t,n;function o(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&l1(a)),t}return o._value=e,o}function u1(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,c1(e))}function d1(){for(var e=this._name,t=this._id,n=Vv(),o=this._groups,a=o.length,l=0;l<a;++l)for(var d=o[l],u=d.length,m,y=0;y<u;++y)if(m=d[y]){var g=Gi(m,t);Qm(m,e,n,y,d,{time:g.time+g.delay+g.duration,delay:0,duration:g.duration,ease:g.ease})}return new Zo(o,this._parents,e,n)}function f1(){var e,t,n=this,o=n._id,a=n.size();return new Promise(function(l,d){var u={value:d},m={value:function(){--a===0&&l()}};n.each(function(){var y=co(this,o),g=y.on;g!==e&&(t=(e=g).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(m)),y.on=t}),a===0&&l()})}var m1=0;function Zo(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Vv(){return++m1}var Go=Xd.prototype;Zo.prototype={constructor:Zo,select:GN,selectAll:KN,selectChild:Go.selectChild,selectChildren:Go.selectChildren,filter:FN,merge:BN,selection:XN,transition:d1,call:Go.call,nodes:Go.nodes,node:Go.node,size:Go.size,empty:Go.empty,each:Go.each,on:WN,attr:jN,attrTween:$N,style:t1,styleTween:s1,text:a1,textTween:u1,remove:VN,tween:gN,delay:TN,duration:PN,ease:zN,easeVarying:DN,end:f1,[Symbol.iterator]:Go[Symbol.iterator]};function h1(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var _1={time:null,delay:0,duration:250,ease:h1};function p1(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function g1(e){var t,n;e instanceof Zo?(t=e._id,e=e._name):(t=Vv(),(n=_1).time=ap(),e=e==null?null:e+"");for(var o=this._groups,a=o.length,l=0;l<a;++l)for(var d=o[l],u=d.length,m,y=0;y<u;++y)(m=d[y])&&Qm(m,e,t,y,d,n||p1(m,t));return new Zo(o,this._parents,e,t)}Xd.prototype.interrupt=hN;Xd.prototype.transition=g1;const dm=e=>()=>e;function y1(e,{sourceEvent:t,target:n,transform:o,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:a}})}function Ko(e,t,n){this.k=e,this.x=t,this.y=n}Ko.prototype={constructor:Ko,scale:function(e){return e===1?this:new Ko(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ko(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 Xo=new Ko(1,0,0);Ko.prototype;function Jh(e){e.stopImmediatePropagation()}function bd(e){e.preventDefault(),e.stopImmediatePropagation()}function v1(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function w1(){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 Og(){return this.__zoom||Xo}function x1(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function b1(){return navigator.maxTouchPoints||"ontouchstart"in this}function S1(e,t,n){var o=e.invertX(t[0][0])-n[0][0],a=e.invertX(t[1][0])-n[1][0],l=e.invertY(t[0][1])-n[0][1],d=e.invertY(t[1][1])-n[1][1];return e.translate(a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a),d>l?(l+d)/2:Math.min(0,l)||Math.max(0,d))}function Gv(){var e=v1,t=w1,n=S1,o=x1,a=b1,l=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],u=250,m=oN,y=Xm("start","zoom","end"),g,v,w,b=500,C=150,S=0,R=10;function T(j){j.property("__zoom",Og).on("wheel.zoom",ee,{passive:!1}).on("mousedown.zoom",ue).on("dblclick.zoom",de).filter(a).on("touchstart.zoom",pe).on("touchmove.zoom",F).on("touchend.zoom touchcancel.zoom",E).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}T.transform=function(j,L,z,te){var I=j.selection?j.selection():j;I.property("__zoom",Og),j!==I?K(j,L,z,te):I.interrupt().each(function(){Q(this,arguments).event(te).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},T.scaleBy=function(j,L,z,te){T.scaleTo(j,function(){var I=this.__zoom.k,O=typeof L=="function"?L.apply(this,arguments):L;return I*O},z,te)},T.scaleTo=function(j,L,z,te){T.transform(j,function(){var I=t.apply(this,arguments),O=this.__zoom,G=z==null?P(I):typeof z=="function"?z.apply(this,arguments):z,$=O.invert(G),Y=typeof L=="function"?L.apply(this,arguments):L;return n(q(D(O,Y),G,$),I,d)},z,te)},T.translateBy=function(j,L,z,te){T.transform(j,function(){return n(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),d)},null,te)},T.translateTo=function(j,L,z,te,I){T.transform(j,function(){var O=t.apply(this,arguments),G=this.__zoom,$=te==null?P(O):typeof te=="function"?te.apply(this,arguments):te;return n(Xo.translate($[0],$[1]).scale(G.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof z=="function"?-z.apply(this,arguments):-z),O,d)},te,I)};function D(j,L){return L=Math.max(l[0],Math.min(l[1],L)),L===j.k?j:new Ko(L,j.x,j.y)}function q(j,L,z){var te=L[0]-z[0]*j.k,I=L[1]-z[1]*j.k;return te===j.x&&I===j.y?j:new Ko(j.k,te,I)}function P(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function K(j,L,z,te){j.on("start.zoom",function(){Q(this,arguments).event(te).start()}).on("interrupt.zoom end.zoom",function(){Q(this,arguments).event(te).end()}).tween("zoom",function(){var I=this,O=arguments,G=Q(I,O).event(te),$=t.apply(I,O),Y=z==null?P($):typeof z=="function"?z.apply(I,O):z,se=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),le=I.__zoom,he=typeof L=="function"?L.apply(I,O):L,be=m(le.invert(Y).concat(se/le.k),he.invert(Y).concat(se/he.k));return function(je){if(je===1)je=he;else{var Ce=be(je),Fe=se/Ce[2];je=new Ko(Fe,Y[0]-Ce[0]*Fe,Y[1]-Ce[1]*Fe)}G.zoom(null,je)}})}function Q(j,L,z){return!z&&j.__zooming||new Z(j,L)}function Z(j,L){this.that=j,this.args=L,this.active=0,this.sourceEvent=null,this.extent=t.apply(j,L),this.taps=0}Z.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,L){return this.mouse&&j!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var L=mi(this.that).datum();y.call(j,this.that,new y1(j,{sourceEvent:this.sourceEvent,target:T,transform:this.that.__zoom,dispatch:y}),L)}};function ee(j,...L){if(!e.apply(this,arguments))return;var z=Q(this,L).event(j),te=this.__zoom,I=Math.max(l[0],Math.min(l[1],te.k*Math.pow(2,o.apply(this,arguments)))),O=Hi(j);if(z.wheel)(z.mouse[0][0]!==O[0]||z.mouse[0][1]!==O[1])&&(z.mouse[1]=te.invert(z.mouse[0]=O)),clearTimeout(z.wheel);else{if(te.k===I)return;z.mouse=[O,te.invert(O)],Nm(this),z.start()}bd(j),z.wheel=setTimeout(G,C),z.zoom("mouse",n(q(D(te,I),z.mouse[0],z.mouse[1]),z.extent,d));function G(){z.wheel=null,z.end()}}function ue(j,...L){if(w||!e.apply(this,arguments))return;var z=j.currentTarget,te=Q(this,L,!0).event(j),I=mi(j.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",se,!0),O=Hi(j,z),G=j.clientX,$=j.clientY;Tv(j.view),Jh(j),te.mouse=[O,this.__zoom.invert(O)],Nm(this),te.start();function Y(le){if(bd(le),!te.moved){var he=le.clientX-G,be=le.clientY-$;te.moved=he*he+be*be>S}te.event(le).zoom("mouse",n(q(te.that.__zoom,te.mouse[0]=Hi(le,z),te.mouse[1]),te.extent,d))}function se(le){I.on("mousemove.zoom mouseup.zoom",null),Rv(le.view,te.moved),bd(le),te.event(le).end()}}function de(j,...L){if(e.apply(this,arguments)){var z=this.__zoom,te=Hi(j.changedTouches?j.changedTouches[0]:j,this),I=z.invert(te),O=z.k*(j.shiftKey?.5:2),G=n(q(D(z,O),te,I),t.apply(this,L),d);bd(j),u>0?mi(this).transition().duration(u).call(K,G,te,j):mi(this).call(T.transform,G,te,j)}}function pe(j,...L){if(e.apply(this,arguments)){var z=j.touches,te=z.length,I=Q(this,L,j.changedTouches.length===te).event(j),O,G,$,Y;for(Jh(j),G=0;G<te;++G)$=z[G],Y=Hi($,this),Y=[Y,this.__zoom.invert(Y),$.identifier],I.touch0?!I.touch1&&I.touch0[2]!==Y[2]&&(I.touch1=Y,I.taps=0):(I.touch0=Y,O=!0,I.taps=1+!!g);g&&(g=clearTimeout(g)),O&&(I.taps<2&&(v=Y[0],g=setTimeout(function(){g=null},b)),Nm(this),I.start())}}function F(j,...L){if(this.__zooming){var z=Q(this,L).event(j),te=j.changedTouches,I=te.length,O,G,$,Y;for(bd(j),O=0;O<I;++O)G=te[O],$=Hi(G,this),z.touch0&&z.touch0[2]===G.identifier?z.touch0[0]=$:z.touch1&&z.touch1[2]===G.identifier&&(z.touch1[0]=$);if(G=z.that.__zoom,z.touch1){var se=z.touch0[0],le=z.touch0[1],he=z.touch1[0],be=z.touch1[1],je=(je=he[0]-se[0])*je+(je=he[1]-se[1])*je,Ce=(Ce=be[0]-le[0])*Ce+(Ce=be[1]-le[1])*Ce;G=D(G,Math.sqrt(je/Ce)),$=[(se[0]+he[0])/2,(se[1]+he[1])/2],Y=[(le[0]+be[0])/2,(le[1]+be[1])/2]}else if(z.touch0)$=z.touch0[0],Y=z.touch0[1];else return;z.zoom("touch",n(q(G,$,Y),z.extent,d))}}function E(j,...L){if(this.__zooming){var z=Q(this,L).event(j),te=j.changedTouches,I=te.length,O,G;for(Jh(j),w&&clearTimeout(w),w=setTimeout(function(){w=null},b),O=0;O<I;++O)G=te[O],z.touch0&&z.touch0[2]===G.identifier?delete z.touch0:z.touch1&&z.touch1[2]===G.identifier&&delete z.touch1;if(z.touch1&&!z.touch0&&(z.touch0=z.touch1,delete z.touch1),z.touch0)z.touch0[1]=this.__zoom.invert(z.touch0[0]);else if(z.end(),z.taps===2&&(G=Hi(G,this),Math.hypot(v[0]-G[0],v[1]-G[1])<R)){var $=mi(this).on("dblclick.zoom");$&&$.apply(this,arguments)}}}return T.wheelDelta=function(j){return arguments.length?(o=typeof j=="function"?j:dm(+j),T):o},T.filter=function(j){return arguments.length?(e=typeof j=="function"?j:dm(!!j),T):e},T.touchable=function(j){return arguments.length?(a=typeof j=="function"?j:dm(!!j),T):a},T.extent=function(j){return arguments.length?(t=typeof j=="function"?j:dm([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),T):t},T.scaleExtent=function(j){return arguments.length?(l[0]=+j[0],l[1]=+j[1],T):[l[0],l[1]]},T.translateExtent=function(j){return arguments.length?(d[0][0]=+j[0][0],d[1][0]=+j[1][0],d[0][1]=+j[0][1],d[1][1]=+j[1][1],T):[[d[0][0],d[0][1]],[d[1][0],d[1][1]]]},T.constrain=function(j){return arguments.length?(n=j,T):n},T.duration=function(j){return arguments.length?(u=+j,T):u},T.interpolate=function(j){return arguments.length?(m=j,T):m},T.on=function(){var j=y.on.apply(y,arguments);return j===y?T:j},T.clickDistance=function(j){return arguments.length?(S=(j=+j)*j,T):Math.sqrt(S)},T.tapDistance=function(j){return arguments.length?(R=+j,T):R},T}const eh=h.createContext(null),j1=eh.Provider,Qo={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.`},Kv=Qo.error001();function Rn(e,t){const n=h.useContext(eh);if(n===null)throw new Error(Kv);return vv(n,e,t)}const gr=()=>{const e=h.useContext(eh);if(e===null)throw new Error(Kv);return h.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},k1=e=>e.userSelectionActive?"none":"all";function Ud({position:e,children:t,className:n,style:o,...a}){const l=Rn(k1),d=`${e}`.split("-");return ye.createElement("div",{className:zr(["react-flow__panel",n,...d]),style:{...o,pointerEvents:l},...a},t)}function N1({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:ye.createElement(Ud,{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"},ye.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const C1=({x:e,y:t,label:n,labelStyle:o={},labelShowBg:a=!0,labelBgStyle:l={},labelBgPadding:d=[2,4],labelBgBorderRadius:u=2,children:m,className:y,...g})=>{const v=h.useRef(null),[w,b]=h.useState({x:0,y:0,width:0,height:0}),C=zr(["react-flow__edge-textwrapper",y]);return h.useEffect(()=>{if(v.current){const S=v.current.getBBox();b({x:S.x,y:S.y,width:S.width,height:S.height})}},[n]),typeof n>"u"||!n?null:ye.createElement("g",{transform:`translate(${e-w.width/2} ${t-w.height/2})`,className:C,visibility:w.width?"visible":"hidden",...g},a&&ye.createElement("rect",{width:w.width+2*d[0],x:-d[0],y:-d[1],height:w.height+2*d[1],className:"react-flow__edge-textbg",style:l,rx:u,ry:u}),ye.createElement("text",{className:"react-flow__edge-text",y:w.height/2,dy:"0.3em",ref:v,style:o},n),m)};var E1=h.memo(C1);const up=e=>({width:e.offsetWidth,height:e.offsetHeight}),gu=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),dp=(e={x:0,y:0},t)=>({x:gu(e.x,t[0][0],t[1][0]),y:gu(e.y,t[0][1],t[1][1])}),zg=(e,t,n)=>e<t?gu(Math.abs(e-t),1,50)/50:e>n?-gu(Math.abs(e-n),1,50)/50:0,Yv=(e,t)=>{const n=zg(e.x,35,t.width-35)*20,o=zg(e.y,35,t.height-35)*20;return[n,o]},Xv=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Jv=(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)}),Hd=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Zv=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Ig=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),$1=(e,t)=>Zv(Jv(Hd(e),Hd(t))),P_=(e,t)=>{const n=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(n*o)},M1=e=>hi(e.width)&&hi(e.height)&&hi(e.x)&&hi(e.y),hi=e=>!isNaN(e)&&isFinite(e),lr=Symbol.for("internals"),Qv=["Enter"," ","Escape"],A1=(e,t)=>{},T1=e=>"nativeEvent"in e;function O_(e){var a,l;const t=T1(e)?e.nativeEvent:e,n=((l=(a=t.composedPath)==null?void 0:a.call(t))==null?void 0:l[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const ew=e=>"clientX"in e,Xa=(e,t)=>{var l,d;const n=ew(e),o=n?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,a=n?e.clientY:(d=e.touches)==null?void 0:d[0].clientY;return{x:o-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},Bm=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Zd=({id:e,path:t,labelX:n,labelY:o,label:a,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y,style:g,markerEnd:v,markerStart:w,interactionWidth:b=20})=>ye.createElement(ye.Fragment,null,ye.createElement("path",{id:e,style:g,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:v,markerStart:w}),b&&ye.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:b,className:"react-flow__edge-interaction"}),a&&hi(n)&&hi(o)?ye.createElement(E1,{x:n,y:o,label:a,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y}):null);Zd.displayName="BaseEdge";function Sd(e,t,n){return n===void 0?n:o=>{const a=t().edges.find(l=>l.id===e);a&&n(o,{...a})}}function tw({sourceX:e,sourceY:t,targetX:n,targetY:o}){const a=Math.abs(n-e)/2,l=n<e?n+a:n-a,d=Math.abs(o-t)/2,u=o<t?o+d:o-d;return[l,u,a,d]}function nw({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:a,sourceControlY:l,targetControlX:d,targetControlY:u}){const m=e*.125+a*.375+d*.375+n*.125,y=t*.125+l*.375+u*.375+o*.125,g=Math.abs(m-e),v=Math.abs(y-t);return[m,y,g,v]}var ic;(function(e){e.Strict="strict",e.Loose="loose"})(ic||(ic={}));var Jl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Jl||(Jl={}));var Wd;(function(e){e.Partial="partial",e.Full="full"})(Wd||(Wd={}));var Ya;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ya||(Ya={}));var qd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qd||(qd={}));var dt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(dt||(dt={}));function Dg({pos:e,x1:t,y1:n,x2:o,y2:a}){return e===dt.Left||e===dt.Right?[.5*(t+o),n]:[t,.5*(n+a)]}function rw({sourceX:e,sourceY:t,sourcePosition:n=dt.Bottom,targetX:o,targetY:a,targetPosition:l=dt.Top}){const[d,u]=Dg({pos:n,x1:e,y1:t,x2:o,y2:a}),[m,y]=Dg({pos:l,x1:o,y1:a,x2:e,y2:t}),[g,v,w,b]=nw({sourceX:e,sourceY:t,targetX:o,targetY:a,sourceControlX:d,sourceControlY:u,targetControlX:m,targetControlY:y});return[`M${e},${t} C${d},${u} ${m},${y} ${o},${a}`,g,v,w,b]}const fp=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:a=dt.Bottom,targetPosition:l=dt.Top,label:d,labelStyle:u,labelShowBg:m,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:w,markerEnd:b,markerStart:C,interactionWidth:S})=>{const[R,T,D]=rw({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:o,targetPosition:l});return ye.createElement(Zd,{path:R,labelX:T,labelY:D,label:d,labelStyle:u,labelShowBg:m,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:w,markerEnd:b,markerStart:C,interactionWidth:S})});fp.displayName="SimpleBezierEdge";const Fg={[dt.Left]:{x:-1,y:0},[dt.Right]:{x:1,y:0},[dt.Top]:{x:0,y:-1},[dt.Bottom]:{x:0,y:1}},R1=({source:e,sourcePosition:t=dt.Bottom,target:n})=>t===dt.Left||t===dt.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Bg=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function L1({source:e,sourcePosition:t=dt.Bottom,target:n,targetPosition:o=dt.Top,center:a,offset:l}){const d=Fg[t],u=Fg[o],m={x:e.x+d.x*l,y:e.y+d.y*l},y={x:n.x+u.x*l,y:n.y+u.y*l},g=R1({source:m,sourcePosition:t,target:y}),v=g.x!==0?"x":"y",w=g[v];let b=[],C,S;const R={x:0,y:0},T={x:0,y:0},[D,q,P,K]=tw({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(d[v]*u[v]===-1){C=a.x||D,S=a.y||q;const Z=[{x:C,y:m.y},{x:C,y:y.y}],ee=[{x:m.x,y:S},{x:y.x,y:S}];d[v]===w?b=v==="x"?Z:ee:b=v==="x"?ee:Z}else{const Z=[{x:m.x,y:y.y}],ee=[{x:y.x,y:m.y}];if(v==="x"?b=d.x===w?ee:Z:b=d.y===w?Z:ee,t===o){const E=Math.abs(e[v]-n[v]);if(E<=l){const j=Math.min(l-1,l-E);d[v]===w?R[v]=(m[v]>e[v]?-1:1)*j:T[v]=(y[v]>n[v]?-1:1)*j}}if(t!==o){const E=v==="x"?"y":"x",j=d[v]===u[E],L=m[E]>y[E],z=m[E]<y[E];(d[v]===1&&(!j&&L||j&&z)||d[v]!==1&&(!j&&z||j&&L))&&(b=v==="x"?Z:ee)}const ue={x:m.x+R.x,y:m.y+R.y},de={x:y.x+T.x,y:y.y+T.y},pe=Math.max(Math.abs(ue.x-b[0].x),Math.abs(de.x-b[0].x)),F=Math.max(Math.abs(ue.y-b[0].y),Math.abs(de.y-b[0].y));pe>=F?(C=(ue.x+de.x)/2,S=b[0].y):(C=b[0].x,S=(ue.y+de.y)/2)}return[[e,{x:m.x+R.x,y:m.y+R.y},...b,{x:y.x+T.x,y:y.y+T.y},n],C,S,P,K]}function P1(e,t,n,o){const a=Math.min(Bg(e,t)/2,Bg(t,n)/2,o),{x:l,y:d}=t;if(e.x===l&&l===n.x||e.y===d&&d===n.y)return`L${l} ${d}`;if(e.y===d){const y=e.x<n.x?-1:1,g=e.y<n.y?1:-1;return`L ${l+a*y},${d}Q ${l},${d} ${l},${d+a*g}`}const u=e.x<n.x?1:-1,m=e.y<n.y?-1:1;return`L ${l},${d+a*m}Q ${l},${d} ${l+a*u},${d}`}function z_({sourceX:e,sourceY:t,sourcePosition:n=dt.Bottom,targetX:o,targetY:a,targetPosition:l=dt.Top,borderRadius:d=5,centerX:u,centerY:m,offset:y=20}){const[g,v,w,b,C]=L1({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:a},targetPosition:l,center:{x:u,y:m},offset:y});return[g.reduce((R,T,D)=>{let q="";return D>0&&D<g.length-1?q=P1(g[D-1],T,g[D+1],d):q=`${D===0?"M":"L"}${T.x} ${T.y}`,R+=q,R},""),v,w,b,C]}const th=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,label:a,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y,style:g,sourcePosition:v=dt.Bottom,targetPosition:w=dt.Top,markerEnd:b,markerStart:C,pathOptions:S,interactionWidth:R})=>{const[T,D,q]=z_({sourceX:e,sourceY:t,sourcePosition:v,targetX:n,targetY:o,targetPosition:w,borderRadius:S==null?void 0:S.borderRadius,offset:S==null?void 0:S.offset});return ye.createElement(Zd,{path:T,labelX:D,labelY:q,label:a,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y,style:g,markerEnd:b,markerStart:C,interactionWidth:R})});th.displayName="SmoothStepEdge";const mp=h.memo(e=>{var t;return ye.createElement(th,{...e,pathOptions:h.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});mp.displayName="StepEdge";function O1({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[a,l,d,u]=tw({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,a,l,d,u]}const hp=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,label:a,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y,style:g,markerEnd:v,markerStart:w,interactionWidth:b})=>{const[C,S,R]=O1({sourceX:e,sourceY:t,targetX:n,targetY:o});return ye.createElement(Zd,{path:C,labelX:S,labelY:R,label:a,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y,style:g,markerEnd:v,markerStart:w,interactionWidth:b})});hp.displayName="StraightEdge";function fm(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Ug({pos:e,x1:t,y1:n,x2:o,y2:a,c:l}){switch(e){case dt.Left:return[t-fm(t-o,l),n];case dt.Right:return[t+fm(o-t,l),n];case dt.Top:return[t,n-fm(n-a,l)];case dt.Bottom:return[t,n+fm(a-n,l)]}}function sw({sourceX:e,sourceY:t,sourcePosition:n=dt.Bottom,targetX:o,targetY:a,targetPosition:l=dt.Top,curvature:d=.25}){const[u,m]=Ug({pos:n,x1:e,y1:t,x2:o,y2:a,c:d}),[y,g]=Ug({pos:l,x1:o,y1:a,x2:e,y2:t,c:d}),[v,w,b,C]=nw({sourceX:e,sourceY:t,targetX:o,targetY:a,sourceControlX:u,sourceControlY:m,targetControlX:y,targetControlY:g});return[`M${e},${t} C${u},${m} ${y},${g} ${o},${a}`,v,w,b,C]}const Um=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:a=dt.Bottom,targetPosition:l=dt.Top,label:d,labelStyle:u,labelShowBg:m,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:w,markerEnd:b,markerStart:C,pathOptions:S,interactionWidth:R})=>{const[T,D,q]=sw({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:o,targetPosition:l,curvature:S==null?void 0:S.curvature});return ye.createElement(Zd,{path:T,labelX:D,labelY:q,label:d,labelStyle:u,labelShowBg:m,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:w,markerEnd:b,markerStart:C,interactionWidth:R})});Um.displayName="BezierEdge";const _p=h.createContext(null),z1=_p.Provider;_p.Consumer;const I1=()=>h.useContext(_p),D1=e=>"id"in e&&"source"in e&&"target"in e,F1=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`reactflow__edge-${e}${t||""}-${n}${o||""}`,I_=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`,B1=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),U1=(e,t)=>{if(!e.source||!e.target)return t;let n;return D1(e)?n={...e}:n={...e,id:F1(e)},B1(n,t)?t:t.concat(n)},D_=({x:e,y:t},[n,o,a],l,[d,u])=>{const m={x:(e-n)/a,y:(t-o)/a};return l?{x:d*Math.round(m.x/d),y:u*Math.round(m.y/u)}:m},iw=({x:e,y:t},[n,o,a])=>({x:e*a+n,y:t*a+o}),tc=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],o=(e.height??0)*t[1],a={x:e.position.x-n,y:e.position.y-o};return{...a,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-o}:a}},nh=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,a)=>{const{x:l,y:d}=tc(a,t).positionAbsolute;return Jv(o,Hd({x:l,y:d,width:a.width||0,height:a.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Zv(n)},ow=(e,t,[n,o,a]=[0,0,1],l=!1,d=!1,u=[0,0])=>{const m={x:(t.x-n)/a,y:(t.y-o)/a,width:t.width/a,height:t.height/a},y=[];return e.forEach(g=>{const{width:v,height:w,selectable:b=!0,hidden:C=!1}=g;if(d&&!b||C)return!1;const{positionAbsolute:S}=tc(g,u),R={x:S.x,y:S.y,width:v||0,height:w||0},T=P_(m,R),D=typeof v>"u"||typeof w>"u"||v===null||w===null,q=l&&T>0,P=(v||0)*(w||0);(D||q||T>=P||g.dragging)&&y.push(g)}),y},aw=(e,t)=>{const n=e.map(o=>o.id);return t.filter(o=>n.includes(o.source)||n.includes(o.target))},lw=(e,t,n,o,a,l=.1)=>{const d=t/(e.width*(1+l)),u=n/(e.height*(1+l)),m=Math.min(d,u),y=gu(m,o,a),g=e.x+e.width/2,v=e.y+e.height/2,w=t/2-g*y,b=n/2-v*y;return{x:w,y:b,zoom:y}},Vl=(e,t=0)=>e.transition().duration(t);function Hg(e,t,n,o){return(t[n]||[]).reduce((a,l)=>{var d,u;return`${e.id}-${l.id}-${n}`!==o&&a.push({id:l.id||null,type:n,nodeId:e.id,x:(((d=e.positionAbsolute)==null?void 0:d.x)??0)+l.x+l.width/2,y:(((u=e.positionAbsolute)==null?void 0:u.y)??0)+l.y+l.height/2}),a},[])}function H1(e,t,n,o,a,l){const{x:d,y:u}=Xa(e),y=t.elementsFromPoint(d,u).find(C=>C.classList.contains("react-flow__handle"));if(y){const C=y.getAttribute("data-nodeid");if(C){const S=pp(void 0,y),R=y.getAttribute("data-handleid"),T=l({nodeId:C,id:R,type:S});if(T){const D=a.find(q=>q.nodeId===C&&q.type===S&&q.id===R);return{handle:{id:R,type:S,nodeId:C,x:(D==null?void 0:D.x)||n.x,y:(D==null?void 0:D.y)||n.y},validHandleResult:T}}}}let g=[],v=1/0;if(a.forEach(C=>{const S=Math.sqrt((C.x-n.x)**2+(C.y-n.y)**2);if(S<=o){const R=l(C);S<=v&&(S<v?g=[{handle:C,validHandleResult:R}]:S===v&&g.push({handle:C,validHandleResult:R}),v=S)}}),!g.length)return{handle:null,validHandleResult:cw()};if(g.length===1)return g[0];const w=g.some(({validHandleResult:C})=>C.isValid),b=g.some(({handle:C})=>C.type==="target");return g.find(({handle:C,validHandleResult:S})=>b?C.type==="target":w?S.isValid:!0)||g[0]}const W1={source:null,target:null,sourceHandle:null,targetHandle:null},cw=()=>({handleDomNode:null,isValid:!1,connection:W1,endHandle:null});function uw(e,t,n,o,a,l,d){const u=a==="target",m=d.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),y={...cw(),handleDomNode:m};if(m){const g=pp(void 0,m),v=m.getAttribute("data-nodeid"),w=m.getAttribute("data-handleid"),b=m.classList.contains("connectable"),C=m.classList.contains("connectableend"),S={source:u?v:n,sourceHandle:u?w:o,target:u?n:v,targetHandle:u?o:w};y.connection=S,b&&C&&(t===ic.Strict?u&&g==="source"||!u&&g==="target":v!==n||w!==o)&&(y.endHandle={nodeId:v,handleId:w,type:g},y.isValid=l(S))}return y}function q1({nodes:e,nodeId:t,handleId:n,handleType:o}){return e.reduce((a,l)=>{if(l[lr]){const{handleBounds:d}=l[lr];let u=[],m=[];d&&(u=Hg(l,d,"source",`${t}-${n}-${o}`),m=Hg(l,d,"target",`${t}-${n}-${o}`)),a.push(...u,...m)}return a},[])}function pp(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Zh(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function V1(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function dw({event:e,handleId:t,nodeId:n,onConnect:o,isTarget:a,getState:l,setState:d,isValidConnection:u,edgeUpdaterType:m,onEdgeUpdateEnd:y}){const g=Xv(e.target),{connectionMode:v,domNode:w,autoPanOnConnect:b,connectionRadius:C,onConnectStart:S,panBy:R,getNodes:T,cancelConnection:D}=l();let q=0,P;const{x:K,y:Q}=Xa(e),Z=g==null?void 0:g.elementFromPoint(K,Q),ee=pp(m,Z),ue=w==null?void 0:w.getBoundingClientRect();if(!ue||!ee)return;let de,pe=Xa(e,ue),F=!1,E=null,j=!1,L=null;const z=q1({nodes:T(),nodeId:n,handleId:t,handleType:ee}),te=()=>{if(!b)return;const[G,$]=Yv(pe,ue);R({x:G,y:$}),q=requestAnimationFrame(te)};d({connectionPosition:pe,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:ee,connectionStartHandle:{nodeId:n,handleId:t,type:ee},connectionEndHandle:null}),S==null||S(e,{nodeId:n,handleId:t,handleType:ee});function I(G){const{transform:$}=l();pe=Xa(G,ue);const{handle:Y,validHandleResult:se}=H1(G,g,D_(pe,$,!1,[1,1]),C,z,le=>uw(le,v,n,t,a?"target":"source",u,g));if(P=Y,F||(te(),F=!0),L=se.handleDomNode,E=se.connection,j=se.isValid,d({connectionPosition:P&&j?iw({x:P.x,y:P.y},$):pe,connectionStatus:V1(!!P,j),connectionEndHandle:se.endHandle}),!P&&!j&&!L)return Zh(de);E.source!==E.target&&L&&(Zh(de),de=L,L.classList.add("connecting","react-flow__handle-connecting"),L.classList.toggle("valid",j),L.classList.toggle("react-flow__handle-valid",j))}function O(G){var $,Y;(P||L)&&E&&j&&(o==null||o(E)),(Y=($=l()).onConnectEnd)==null||Y.call($,G),m&&(y==null||y(G)),Zh(de),D(),cancelAnimationFrame(q),F=!1,j=!1,E=null,L=null,g.removeEventListener("mousemove",I),g.removeEventListener("mouseup",O),g.removeEventListener("touchmove",I),g.removeEventListener("touchend",O)}g.addEventListener("mousemove",I),g.addEventListener("mouseup",O),g.addEventListener("touchmove",I),g.addEventListener("touchend",O)}const Wg=()=>!0,G1=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),K1=(e,t,n)=>o=>{const{connectionStartHandle:a,connectionEndHandle:l,connectionClickStartHandle:d}=o;return{connecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.handleId)===t&&(a==null?void 0:a.type)===n||(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===t&&(l==null?void 0:l.type)===n,clickConnecting:(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.handleId)===t&&(d==null?void 0:d.type)===n}},fw=h.forwardRef(({type:e="source",position:t=dt.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:a=!0,isConnectableEnd:l=!0,id:d,onConnect:u,children:m,className:y,onMouseDown:g,onTouchStart:v,...w},b)=>{var ue,de;const C=d||null,S=e==="target",R=gr(),T=I1(),{connectOnClick:D,noPanClassName:q}=Rn(G1,Nr),{connecting:P,clickConnecting:K}=Rn(K1(T,C,e),Nr);T||(de=(ue=R.getState()).onError)==null||de.call(ue,"010",Qo.error010());const Q=pe=>{const{defaultEdgeOptions:F,onConnect:E,hasDefaultEdges:j}=R.getState(),L={...F,...pe};if(j){const{edges:z,setEdges:te}=R.getState();te(U1(L,z))}E==null||E(L),u==null||u(L)},Z=pe=>{if(!T)return;const F=ew(pe);a&&(F&&pe.button===0||!F)&&dw({event:pe,handleId:C,nodeId:T,onConnect:Q,isTarget:S,getState:R.getState,setState:R.setState,isValidConnection:n||R.getState().isValidConnection||Wg}),F?g==null||g(pe):v==null||v(pe)},ee=pe=>{const{onClickConnectStart:F,onClickConnectEnd:E,connectionClickStartHandle:j,connectionMode:L,isValidConnection:z}=R.getState();if(!T||!j&&!a)return;if(!j){F==null||F(pe,{nodeId:T,handleId:C,handleType:e}),R.setState({connectionClickStartHandle:{nodeId:T,type:e,handleId:C}});return}const te=Xv(pe.target),I=n||z||Wg,{connection:O,isValid:G}=uw({nodeId:T,id:C,type:e},L,j.nodeId,j.handleId||null,j.type,I,te);G&&Q(O),E==null||E(pe),R.setState({connectionClickStartHandle:null})};return ye.createElement("div",{"data-handleid":C,"data-nodeid":T,"data-handlepos":t,"data-id":`${T}-${C}-${e}`,className:zr(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",q,y,{source:!S,target:S,connectable:o,connectablestart:a,connectableend:l,connecting:K,connectionindicator:o&&(a&&!P||l&&P)}]),onMouseDown:Z,onTouchStart:Z,onClick:D?ee:void 0,ref:b,...w},m)});fw.displayName="Handle";var Hm=h.memo(fw);const mw=({data:e,isConnectable:t,targetPosition:n=dt.Top,sourcePosition:o=dt.Bottom})=>ye.createElement(ye.Fragment,null,ye.createElement(Hm,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,ye.createElement(Hm,{type:"source",position:o,isConnectable:t}));mw.displayName="DefaultNode";var F_=h.memo(mw);const hw=({data:e,isConnectable:t,sourcePosition:n=dt.Bottom})=>ye.createElement(ye.Fragment,null,e==null?void 0:e.label,ye.createElement(Hm,{type:"source",position:n,isConnectable:t}));hw.displayName="InputNode";var _w=h.memo(hw);const pw=({data:e,isConnectable:t,targetPosition:n=dt.Top})=>ye.createElement(ye.Fragment,null,ye.createElement(Hm,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);pw.displayName="OutputNode";var gw=h.memo(pw);const gp=()=>null;gp.displayName="GroupNode";const Y1=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected)}),mm=e=>e.id;function X1(e,t){return Nr(e.selectedNodes.map(mm),t.selectedNodes.map(mm))&&Nr(e.selectedEdges.map(mm),t.selectedEdges.map(mm))}const yw=h.memo(({onSelectionChange:e})=>{const t=gr(),{selectedNodes:n,selectedEdges:o}=Rn(Y1,X1);return h.useEffect(()=>{const a={nodes:n,edges:o};e==null||e(a),t.getState().onSelectionChange.forEach(l=>l(a))},[n,o,e]),null});yw.displayName="SelectionListener";const J1=e=>!!e.onSelectionChange;function Z1({onSelectionChange:e}){const t=Rn(J1);return e||t?ye.createElement(yw,{onSelectionChange:e}):null}const Q1=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 Zc(e,t){h.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Ht(e,t,n){h.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const e2=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:a,onConnectStart:l,onConnectEnd:d,onClickConnectStart:u,onClickConnectEnd:m,nodesDraggable:y,nodesConnectable:g,nodesFocusable:v,edgesFocusable:w,edgesUpdatable:b,elevateNodesOnSelect:C,minZoom:S,maxZoom:R,nodeExtent:T,onNodesChange:D,onEdgesChange:q,elementsSelectable:P,connectionMode:K,snapGrid:Q,snapToGrid:Z,translateExtent:ee,connectOnClick:ue,defaultEdgeOptions:de,fitView:pe,fitViewOptions:F,onNodesDelete:E,onEdgesDelete:j,onNodeDrag:L,onNodeDragStart:z,onNodeDragStop:te,onSelectionDrag:I,onSelectionDragStart:O,onSelectionDragStop:G,noPanClassName:$,nodeOrigin:Y,rfId:se,autoPanOnConnect:le,autoPanOnNodeDrag:he,onError:be,connectionRadius:je,isValidConnection:Ce,nodeDragThreshold:Fe})=>{const{setNodes:Ke,setEdges:Ye,setDefaultNodesAndEdges:Ct,setMinZoom:wt,setMaxZoom:lt,setTranslateExtent:yt,setNodeExtent:rt,reset:Ne}=Rn(Q1,Nr),Oe=gr();return h.useEffect(()=>{const it=o==null?void 0:o.map(ve=>({...ve,...de}));return Ct(n,it),()=>{Ne()}},[]),Ht("defaultEdgeOptions",de,Oe.setState),Ht("connectionMode",K,Oe.setState),Ht("onConnect",a,Oe.setState),Ht("onConnectStart",l,Oe.setState),Ht("onConnectEnd",d,Oe.setState),Ht("onClickConnectStart",u,Oe.setState),Ht("onClickConnectEnd",m,Oe.setState),Ht("nodesDraggable",y,Oe.setState),Ht("nodesConnectable",g,Oe.setState),Ht("nodesFocusable",v,Oe.setState),Ht("edgesFocusable",w,Oe.setState),Ht("edgesUpdatable",b,Oe.setState),Ht("elementsSelectable",P,Oe.setState),Ht("elevateNodesOnSelect",C,Oe.setState),Ht("snapToGrid",Z,Oe.setState),Ht("snapGrid",Q,Oe.setState),Ht("onNodesChange",D,Oe.setState),Ht("onEdgesChange",q,Oe.setState),Ht("connectOnClick",ue,Oe.setState),Ht("fitViewOnInit",pe,Oe.setState),Ht("fitViewOnInitOptions",F,Oe.setState),Ht("onNodesDelete",E,Oe.setState),Ht("onEdgesDelete",j,Oe.setState),Ht("onNodeDrag",L,Oe.setState),Ht("onNodeDragStart",z,Oe.setState),Ht("onNodeDragStop",te,Oe.setState),Ht("onSelectionDrag",I,Oe.setState),Ht("onSelectionDragStart",O,Oe.setState),Ht("onSelectionDragStop",G,Oe.setState),Ht("noPanClassName",$,Oe.setState),Ht("nodeOrigin",Y,Oe.setState),Ht("rfId",se,Oe.setState),Ht("autoPanOnConnect",le,Oe.setState),Ht("autoPanOnNodeDrag",he,Oe.setState),Ht("onError",be,Oe.setState),Ht("connectionRadius",je,Oe.setState),Ht("isValidConnection",Ce,Oe.setState),Ht("nodeDragThreshold",Fe,Oe.setState),Zc(e,Ke),Zc(t,Ye),Zc(S,wt),Zc(R,lt),Zc(ee,yt),Zc(T,rt),null},qg={display:"none"},t2={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},vw="react-flow__node-desc",ww="react-flow__edge-desc",n2="react-flow__aria-live",r2=e=>e.ariaLiveMessage;function s2({rfId:e}){const t=Rn(r2);return ye.createElement("div",{id:`${n2}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:t2},t)}function i2({rfId:e,disableKeyboardA11y:t}){return ye.createElement(ye.Fragment,null,ye.createElement("div",{id:`${vw}-${e}`,style:qg},"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."," "),ye.createElement("div",{id:`${ww}-${e}`,style:qg},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&ye.createElement(s2,{rfId:e}))}var Vd=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,o]=h.useState(!1),a=h.useRef(!1),l=h.useRef(new Set([])),[d,u]=h.useMemo(()=>{if(e!==null){const y=(Array.isArray(e)?e:[e]).filter(v=>typeof v=="string").map(v=>v.split("+")),g=y.reduce((v,w)=>v.concat(...w),[]);return[y,g]}return[[],[]]},[e]);return h.useEffect(()=>{const m=typeof document<"u"?document:null,y=(t==null?void 0:t.target)||m;if(e!==null){const g=b=>{if(a.current=b.ctrlKey||b.metaKey||b.shiftKey,(!a.current||a.current&&!t.actInsideInputWithModifier)&&O_(b))return!1;const S=Gg(b.code,u);l.current.add(b[S]),Vg(d,l.current,!1)&&(b.preventDefault(),o(!0))},v=b=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&O_(b))return!1;const S=Gg(b.code,u);Vg(d,l.current,!0)?(o(!1),l.current.clear()):l.current.delete(b[S]),b.key==="Meta"&&l.current.clear(),a.current=!1},w=()=>{l.current.clear(),o(!1)};return y==null||y.addEventListener("keydown",g),y==null||y.addEventListener("keyup",v),window.addEventListener("blur",w),()=>{y==null||y.removeEventListener("keydown",g),y==null||y.removeEventListener("keyup",v),window.removeEventListener("blur",w)}}},[e,o]),n};function Vg(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(a=>t.has(a)))}function Gg(e,t){return t.includes(e)?"code":"key"}function xw(e,t,n,o){var d,u;if(!e.parentNode)return n;const a=t.get(e.parentNode),l=tc(a,o);return xw(a,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:(((d=a[lr])==null?void 0:d.z)??0)>(n.z??0)?((u=a[lr])==null?void 0:u.z)??0:n.z??0},o)}function bw(e,t,n){e.forEach(o=>{var a;if(o.parentNode&&!e.has(o.parentNode))throw new Error(`Parent node ${o.parentNode} not found`);if(o.parentNode||n!=null&&n[o.id]){const{x:l,y:d,z:u}=xw(o,e,{...o.position,z:((a=o[lr])==null?void 0:a.z)??0},t);o.positionAbsolute={x:l,y:d},o[lr].z=u,n!=null&&n[o.id]&&(o[lr].isParent=!0)}})}function Qh(e,t,n,o){const a=new Map,l={},d=o?1e3:0;return e.forEach(u=>{var w;const m=(hi(u.zIndex)?u.zIndex:0)+(u.selected?d:0),y=t.get(u.id),g={...u,positionAbsolute:{x:u.position.x,y:u.position.y}};u.parentNode&&(l[u.parentNode]=!0);const v=(y==null?void 0:y.type)&&(y==null?void 0:y.type)!==u.type;Object.defineProperty(g,lr,{enumerable:!1,value:{handleBounds:v||(w=y==null?void 0:y[lr])==null?void 0:w.handleBounds,z:m}}),a.set(u.id,g)}),bw(a,n,l),a}function Sw(e,t={}){const{getNodes:n,width:o,height:a,minZoom:l,maxZoom:d,d3Zoom:u,d3Selection:m,fitViewOnInitDone:y,fitViewOnInit:g,nodeOrigin:v}=e(),w=t.initial&&!y&&g;if(u&&m&&(w||!t.initial)){const C=n().filter(R=>{var D;const T=t.includeHiddenNodes?R.width&&R.height:!R.hidden;return(D=t.nodes)!=null&&D.length?T&&t.nodes.some(q=>q.id===R.id):T}),S=C.every(R=>R.width&&R.height);if(C.length>0&&S){const R=nh(C,v),{x:T,y:D,zoom:q}=lw(R,o,a,t.minZoom??l,t.maxZoom??d,t.padding??.1),P=Xo.translate(T,D).scale(q);return typeof t.duration=="number"&&t.duration>0?u.transform(Vl(m,t.duration),P):u.transform(m,P),!0}}return!1}function o2(e,t){return e.forEach(n=>{const o=t.get(n.id);o&&t.set(o.id,{...o,[lr]:o[lr],selected:n.selected})}),new Map(t)}function a2(e,t){return t.map(n=>{const o=e.find(a=>a.id===n.id);return o&&(n.selected=o.selected),n})}function hm({changedNodes:e,changedEdges:t,get:n,set:o}){const{nodeInternals:a,edges:l,onNodesChange:d,onEdgesChange:u,hasDefaultNodes:m,hasDefaultEdges:y}=n();e!=null&&e.length&&(m&&o({nodeInternals:o2(e,a)}),d==null||d(e)),t!=null&&t.length&&(y&&o({edges:a2(t,l)}),u==null||u(t))}const Qc=()=>{},l2={zoomIn:Qc,zoomOut:Qc,zoomTo:Qc,getZoom:()=>1,setViewport:Qc,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Qc,fitBounds:Qc,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},c2=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),u2=()=>{const e=gr(),{d3Zoom:t,d3Selection:n}=Rn(c2,Nr);return h.useMemo(()=>n&&t?{zoomIn:a=>t.scaleBy(Vl(n,a==null?void 0:a.duration),1.2),zoomOut:a=>t.scaleBy(Vl(n,a==null?void 0:a.duration),1/1.2),zoomTo:(a,l)=>t.scaleTo(Vl(n,l==null?void 0:l.duration),a),getZoom:()=>e.getState().transform[2],setViewport:(a,l)=>{const[d,u,m]=e.getState().transform,y=Xo.translate(a.x??d,a.y??u).scale(a.zoom??m);t.transform(Vl(n,l==null?void 0:l.duration),y)},getViewport:()=>{const[a,l,d]=e.getState().transform;return{x:a,y:l,zoom:d}},fitView:a=>Sw(e.getState,a),setCenter:(a,l,d)=>{const{width:u,height:m,maxZoom:y}=e.getState(),g=typeof(d==null?void 0:d.zoom)<"u"?d.zoom:y,v=u/2-a*g,w=m/2-l*g,b=Xo.translate(v,w).scale(g);t.transform(Vl(n,d==null?void 0:d.duration),b)},fitBounds:(a,l)=>{const{width:d,height:u,minZoom:m,maxZoom:y}=e.getState(),{x:g,y:v,zoom:w}=lw(a,d,u,m,y,(l==null?void 0:l.padding)??.1),b=Xo.translate(g,v).scale(w);t.transform(Vl(n,l==null?void 0:l.duration),b)},project:a=>{const{transform:l,snapToGrid:d,snapGrid:u}=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"),D_(a,l,d,u)},screenToFlowPosition:a=>{const{transform:l,snapToGrid:d,snapGrid:u,domNode:m}=e.getState();if(!m)return a;const{x:y,y:g}=m.getBoundingClientRect(),v={x:a.x-y,y:a.y-g};return D_(v,l,d,u)},flowToScreenPosition:a=>{const{transform:l,domNode:d}=e.getState();if(!d)return a;const{x:u,y:m}=d.getBoundingClientRect(),y=iw(a,l);return{x:y.x+u,y:y.y+m}},viewportInitialized:!0}:l2,[t,n])};function yp(){const e=u2(),t=gr(),n=h.useCallback(()=>t.getState().getNodes().map(S=>({...S})),[]),o=h.useCallback(S=>t.getState().nodeInternals.get(S),[]),a=h.useCallback(()=>{const{edges:S=[]}=t.getState();return S.map(R=>({...R}))},[]),l=h.useCallback(S=>{const{edges:R=[]}=t.getState();return R.find(T=>T.id===S)},[]),d=h.useCallback(S=>{const{getNodes:R,setNodes:T,hasDefaultNodes:D,onNodesChange:q}=t.getState(),P=R(),K=typeof S=="function"?S(P):S;if(D)T(K);else if(q){const Q=K.length===0?P.map(Z=>({type:"remove",id:Z.id})):K.map(Z=>({item:Z,type:"reset"}));q(Q)}},[]),u=h.useCallback(S=>{const{edges:R=[],setEdges:T,hasDefaultEdges:D,onEdgesChange:q}=t.getState(),P=typeof S=="function"?S(R):S;if(D)T(P);else if(q){const K=P.length===0?R.map(Q=>({type:"remove",id:Q.id})):P.map(Q=>({item:Q,type:"reset"}));q(K)}},[]),m=h.useCallback(S=>{const R=Array.isArray(S)?S:[S],{getNodes:T,setNodes:D,hasDefaultNodes:q,onNodesChange:P}=t.getState();if(q){const Q=[...T(),...R];D(Q)}else if(P){const K=R.map(Q=>({item:Q,type:"add"}));P(K)}},[]),y=h.useCallback(S=>{const R=Array.isArray(S)?S:[S],{edges:T=[],setEdges:D,hasDefaultEdges:q,onEdgesChange:P}=t.getState();if(q)D([...T,...R]);else if(P){const K=R.map(Q=>({item:Q,type:"add"}));P(K)}},[]),g=h.useCallback(()=>{const{getNodes:S,edges:R=[],transform:T}=t.getState(),[D,q,P]=T;return{nodes:S().map(K=>({...K})),edges:R.map(K=>({...K})),viewport:{x:D,y:q,zoom:P}}},[]),v=h.useCallback(({nodes:S,edges:R})=>{const{nodeInternals:T,getNodes:D,edges:q,hasDefaultNodes:P,hasDefaultEdges:K,onNodesDelete:Q,onEdgesDelete:Z,onNodesChange:ee,onEdgesChange:ue}=t.getState(),de=(S||[]).map(L=>L.id),pe=(R||[]).map(L=>L.id),F=D().reduce((L,z)=>{const te=!de.includes(z.id)&&z.parentNode&&L.find(O=>O.id===z.parentNode);return(typeof z.deletable=="boolean"?z.deletable:!0)&&(de.includes(z.id)||te)&&L.push(z),L},[]),E=q.filter(L=>typeof L.deletable=="boolean"?L.deletable:!0),j=E.filter(L=>pe.includes(L.id));if(F||j){const L=aw(F,E),z=[...j,...L],te=z.reduce((I,O)=>(I.includes(O.id)||I.push(O.id),I),[]);if((K||P)&&(K&&t.setState({edges:q.filter(I=>!te.includes(I.id))}),P&&(F.forEach(I=>{T.delete(I.id)}),t.setState({nodeInternals:new Map(T)}))),te.length>0&&(Z==null||Z(z),ue&&ue(te.map(I=>({id:I,type:"remove"})))),F.length>0&&(Q==null||Q(F),ee)){const I=F.map(O=>({id:O.id,type:"remove"}));ee(I)}}},[]),w=h.useCallback(S=>{const R=M1(S),T=R?null:t.getState().nodeInternals.get(S.id);return!R&&!T?[null,null,R]:[R?S:Ig(T),T,R]},[]),b=h.useCallback((S,R=!0,T)=>{const[D,q,P]=w(S);return D?(T||t.getState().getNodes()).filter(K=>{if(!P&&(K.id===q.id||!K.positionAbsolute))return!1;const Q=Ig(K),Z=P_(Q,D);return R&&Z>0||Z>=D.width*D.height}):[]},[]),C=h.useCallback((S,R,T=!0)=>{const[D]=w(S);if(!D)return!1;const q=P_(D,R);return T&&q>0||q>=D.width*D.height},[]);return h.useMemo(()=>({...e,getNodes:n,getNode:o,getEdges:a,getEdge:l,setNodes:d,setEdges:u,addNodes:m,addEdges:y,toObject:g,deleteElements:v,getIntersectingNodes:b,isNodeIntersecting:C}),[e,n,o,a,l,d,u,m,y,g,v,b,C])}const d2={actInsideInputWithModifier:!1};var f2=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=gr(),{deleteElements:o}=yp(),a=Vd(e,d2),l=Vd(t);h.useEffect(()=>{if(a){const{edges:d,getNodes:u}=n.getState(),m=u().filter(g=>g.selected),y=d.filter(g=>g.selected);o({nodes:m,edges:y}),n.setState({nodesSelectionActive:!1})}},[a]),h.useEffect(()=>{n.setState({multiSelectionActive:l})},[l])};function m2(e){const t=gr();h.useEffect(()=>{let n;const o=()=>{var l,d;if(!e.current)return;const a=up(e.current);(a.height===0||a.width===0)&&((d=(l=t.getState()).onError)==null||d.call(l,"004",Qo.error004())),t.setState({width:a.width||500,height:a.height||500})};return o(),window.addEventListener("resize",o),e.current&&(n=new ResizeObserver(()=>o()),n.observe(e.current)),()=>{window.removeEventListener("resize",o),n&&e.current&&n.unobserve(e.current)}},[])}const vp={position:"absolute",width:"100%",height:"100%",top:0,left:0},h2=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,_m=e=>({x:e.x,y:e.y,zoom:e.k}),eu=(e,t)=>e.target.closest(`.${t}`),Kg=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Yg=e=>{const t=e.ctrlKey&&Bm()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},_2=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),p2=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:o,zoomOnScroll:a=!0,zoomOnPinch:l=!0,panOnScroll:d=!1,panOnScrollSpeed:u=.5,panOnScrollMode:m=Jl.Free,zoomOnDoubleClick:y=!0,elementsSelectable:g,panOnDrag:v=!0,defaultViewport:w,translateExtent:b,minZoom:C,maxZoom:S,zoomActivationKeyCode:R,preventScrolling:T=!0,children:D,noWheelClassName:q,noPanClassName:P})=>{const K=h.useRef(),Q=gr(),Z=h.useRef(!1),ee=h.useRef(!1),ue=h.useRef(null),de=h.useRef({x:0,y:0,zoom:0}),{d3Zoom:pe,d3Selection:F,d3ZoomHandler:E,userSelectionActive:j}=Rn(_2,Nr),L=Vd(R),z=h.useRef(0),te=h.useRef(!1),I=h.useRef();return m2(ue),h.useEffect(()=>{if(ue.current){const O=ue.current.getBoundingClientRect(),G=Gv().scaleExtent([C,S]).translateExtent(b),$=mi(ue.current).call(G),Y=Xo.translate(w.x,w.y).scale(gu(w.zoom,C,S)),se=[[0,0],[O.width,O.height]],le=G.constrain()(Y,se,b);G.transform($,le),G.wheelDelta(Yg),Q.setState({d3Zoom:G,d3Selection:$,d3ZoomHandler:$.on("wheel.zoom"),transform:[le.x,le.y,le.k],domNode:ue.current.closest(".react-flow")})}},[]),h.useEffect(()=>{F&&pe&&(d&&!L&&!j?F.on("wheel.zoom",O=>{if(eu(O,q))return!1;O.preventDefault(),O.stopImmediatePropagation();const G=F.property("__zoom").k||1,$=Bm();if(O.ctrlKey&&l&&$){const Fe=Hi(O),Ke=Yg(O),Ye=G*Math.pow(2,Ke);pe.scaleTo(F,Ye,Fe,O);return}const Y=O.deltaMode===1?20:1;let se=m===Jl.Vertical?0:O.deltaX*Y,le=m===Jl.Horizontal?0:O.deltaY*Y;!$&&O.shiftKey&&m!==Jl.Vertical&&(se=O.deltaY*Y,le=0),pe.translateBy(F,-(se/G)*u,-(le/G)*u,{internal:!0});const he=_m(F.property("__zoom")),{onViewportChangeStart:be,onViewportChange:je,onViewportChangeEnd:Ce}=Q.getState();clearTimeout(I.current),te.current||(te.current=!0,t==null||t(O,he),be==null||be(he)),te.current&&(e==null||e(O,he),je==null||je(he),I.current=setTimeout(()=>{n==null||n(O,he),Ce==null||Ce(he),te.current=!1},150))},{passive:!1}):typeof E<"u"&&F.on("wheel.zoom",function(O,G){if(!T||eu(O,q))return null;O.preventDefault(),E.call(this,O,G)},{passive:!1}))},[j,d,m,F,pe,E,L,l,T,q,t,e,n]),h.useEffect(()=>{pe&&pe.on("start",O=>{var Y,se;if(!O.sourceEvent||O.sourceEvent.internal)return null;z.current=(Y=O.sourceEvent)==null?void 0:Y.button;const{onViewportChangeStart:G}=Q.getState(),$=_m(O.transform);Z.current=!0,de.current=$,((se=O.sourceEvent)==null?void 0:se.type)==="mousedown"&&Q.setState({paneDragging:!0}),G==null||G($),t==null||t(O.sourceEvent,$)})},[pe,t]),h.useEffect(()=>{pe&&(j&&!Z.current?pe.on("zoom",null):j||pe.on("zoom",O=>{var $;const{onViewportChange:G}=Q.getState();if(Q.setState({transform:[O.transform.x,O.transform.y,O.transform.k]}),ee.current=!!(o&&Kg(v,z.current??0)),(e||G)&&!(($=O.sourceEvent)!=null&&$.internal)){const Y=_m(O.transform);G==null||G(Y),e==null||e(O.sourceEvent,Y)}}))},[j,pe,e,v,o]),h.useEffect(()=>{pe&&pe.on("end",O=>{if(!O.sourceEvent||O.sourceEvent.internal)return null;const{onViewportChangeEnd:G}=Q.getState();if(Z.current=!1,Q.setState({paneDragging:!1}),o&&Kg(v,z.current??0)&&!ee.current&&o(O.sourceEvent),ee.current=!1,(n||G)&&h2(de.current,O.transform)){const $=_m(O.transform);de.current=$,clearTimeout(K.current),K.current=setTimeout(()=>{G==null||G($),n==null||n(O.sourceEvent,$)},d?150:0)}})},[pe,d,v,n,o]),h.useEffect(()=>{pe&&pe.filter(O=>{const G=L||a,$=l&&O.ctrlKey;if((v===!0||Array.isArray(v)&&v.includes(1))&&O.button===1&&O.type==="mousedown"&&(eu(O,"react-flow__node")||eu(O,"react-flow__edge")))return!0;if(!v&&!G&&!d&&!y&&!l||j||!y&&O.type==="dblclick"||eu(O,q)&&O.type==="wheel"||eu(O,P)&&(O.type!=="wheel"||d&&O.type==="wheel"&&!L)||!l&&O.ctrlKey&&O.type==="wheel"||!G&&!d&&!$&&O.type==="wheel"||!v&&(O.type==="mousedown"||O.type==="touchstart")||Array.isArray(v)&&!v.includes(O.button)&&(O.type==="mousedown"||O.type==="touchstart"))return!1;const Y=Array.isArray(v)&&v.includes(O.button)||!O.button||O.button<=1;return(!O.ctrlKey||O.type==="wheel")&&Y})},[j,pe,a,l,d,y,v,g,L]),ye.createElement("div",{className:"react-flow__renderer",ref:ue,style:vp},D)},g2=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function y2(){const{userSelectionActive:e,userSelectionRect:t}=Rn(g2,Nr);return e&&t?ye.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 Xg(e,t){const n=e.find(o=>o.id===t.parentNode);if(n){const o=t.position.x+t.width-n.width,a=t.position.y+t.height-n.height;if(o>0||a>0||t.position.x<0||t.position.y<0){if(n.style={...n.style},n.style.width=n.style.width??n.width,n.style.height=n.style.height??n.height,o>0&&(n.style.width+=o),a>0&&(n.style.height+=a),t.position.x<0){const l=Math.abs(t.position.x);n.position.x=n.position.x-l,n.style.width+=l,t.position.x=0}if(t.position.y<0){const l=Math.abs(t.position.y);n.position.y=n.position.y-l,n.style.height+=l,t.position.y=0}n.width=n.style.width,n.height=n.style.height}}}function v2(e,t){if(e.some(o=>o.type==="reset"))return e.filter(o=>o.type==="reset").map(o=>o.item);const n=e.filter(o=>o.type==="add").map(o=>o.item);return t.reduce((o,a)=>{const l=e.filter(u=>u.id===a.id);if(l.length===0)return o.push(a),o;const d={...a};for(const u of l)if(u)switch(u.type){case"select":{d.selected=u.selected;break}case"position":{typeof u.position<"u"&&(d.position=u.position),typeof u.positionAbsolute<"u"&&(d.positionAbsolute=u.positionAbsolute),typeof u.dragging<"u"&&(d.dragging=u.dragging),d.expandParent&&Xg(o,d);break}case"dimensions":{typeof u.dimensions<"u"&&(d.width=u.dimensions.width,d.height=u.dimensions.height),typeof u.updateStyle<"u"&&(d.style={...d.style||{},...u.dimensions}),typeof u.resizing=="boolean"&&(d.resizing=u.resizing),d.expandParent&&Xg(o,d);break}case"remove":return o}return o.push(d),o},n)}function w2(e,t){return v2(e,t)}const Ga=(e,t)=>({id:e,type:"select",selected:t});function iu(e,t){return e.reduce((n,o)=>{const a=t.includes(o.id);return!o.selected&&a?(o.selected=!0,n.push(Ga(o.id,!0))):o.selected&&!a&&(o.selected=!1,n.push(Ga(o.id,!1))),n},[])}const e_=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},x2=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),jw=h.memo(({isSelecting:e,selectionMode:t=Wd.Full,panOnDrag:n,onSelectionStart:o,onSelectionEnd:a,onPaneClick:l,onPaneContextMenu:d,onPaneScroll:u,onPaneMouseEnter:m,onPaneMouseMove:y,onPaneMouseLeave:g,children:v})=>{const w=h.useRef(null),b=gr(),C=h.useRef(0),S=h.useRef(0),R=h.useRef(),{userSelectionActive:T,elementsSelectable:D,dragging:q}=Rn(x2,Nr),P=()=>{b.setState({userSelectionActive:!1,userSelectionRect:null}),C.current=0,S.current=0},K=E=>{l==null||l(E),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},Q=E=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){E.preventDefault();return}d==null||d(E)},Z=u?E=>u(E):void 0,ee=E=>{const{resetSelectedElements:j,domNode:L}=b.getState();if(R.current=L==null?void 0:L.getBoundingClientRect(),!D||!e||E.button!==0||E.target!==w.current||!R.current)return;const{x:z,y:te}=Xa(E,R.current);j(),b.setState({userSelectionRect:{width:0,height:0,startX:z,startY:te,x:z,y:te}}),o==null||o(E)},ue=E=>{const{userSelectionRect:j,nodeInternals:L,edges:z,transform:te,onNodesChange:I,onEdgesChange:O,nodeOrigin:G,getNodes:$}=b.getState();if(!e||!R.current||!j)return;b.setState({userSelectionActive:!0,nodesSelectionActive:!1});const Y=Xa(E,R.current),se=j.startX??0,le=j.startY??0,he={...j,x:Y.x<se?Y.x:se,y:Y.y<le?Y.y:le,width:Math.abs(Y.x-se),height:Math.abs(Y.y-le)},be=$(),je=ow(L,he,te,t===Wd.Partial,!0,G),Ce=aw(je,z).map(Ke=>Ke.id),Fe=je.map(Ke=>Ke.id);if(C.current!==Fe.length){C.current=Fe.length;const Ke=iu(be,Fe);Ke.length&&(I==null||I(Ke))}if(S.current!==Ce.length){S.current=Ce.length;const Ke=iu(z,Ce);Ke.length&&(O==null||O(Ke))}b.setState({userSelectionRect:he})},de=E=>{if(E.button!==0)return;const{userSelectionRect:j}=b.getState();!T&&j&&E.target===w.current&&(K==null||K(E)),b.setState({nodesSelectionActive:C.current>0}),P(),a==null||a(E)},pe=E=>{T&&(b.setState({nodesSelectionActive:C.current>0}),a==null||a(E)),P()},F=D&&(e||T);return ye.createElement("div",{className:zr(["react-flow__pane",{dragging:q,selection:e}]),onClick:F?void 0:e_(K,w),onContextMenu:e_(Q,w),onWheel:e_(Z,w),onMouseEnter:F?void 0:m,onMouseDown:F?ee:void 0,onMouseMove:F?ue:y,onMouseUp:F?de:void 0,onMouseLeave:F?pe:g,ref:w,style:vp},v,ye.createElement(y2,null))});jw.displayName="Pane";function kw(e,t){if(!e.parentNode)return!1;const n=t.get(e.parentNode);return n?n.selected?!0:kw(n,t):!1}function Jg(e,t,n){let o=e;do{if(o!=null&&o.matches(t))return!0;if(o===n.current)return!1;o=o.parentElement}while(o);return!1}function b2(e,t,n,o){return Array.from(e.values()).filter(a=>(a.selected||a.id===o)&&(!a.parentNode||!kw(a,e))&&(a.draggable||t&&typeof a.draggable>"u")).map(a=>{var l,d;return{id:a.id,position:a.position||{x:0,y:0},positionAbsolute:a.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((l=a.positionAbsolute)==null?void 0:l.x)??0),y:n.y-(((d=a.positionAbsolute)==null?void 0:d.y)??0)},delta:{x:0,y:0},extent:a.extent,parentNode:a.parentNode,width:a.width,height:a.height,expandParent:a.expandParent}})}function S2(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function Nw(e,t,n,o,a=[0,0],l){const d=S2(e,e.extent||o);let u=d;if(e.extent==="parent"&&!e.expandParent)if(e.parentNode&&e.width&&e.height){const g=n.get(e.parentNode),{x:v,y:w}=tc(g,a).positionAbsolute;u=g&&hi(v)&&hi(w)&&hi(g.width)&&hi(g.height)?[[v+e.width*a[0],w+e.height*a[1]],[v+g.width-e.width+e.width*a[0],w+g.height-e.height+e.height*a[1]]]:u}else l==null||l("005",Qo.error005()),u=d;else if(e.extent&&e.parentNode&&e.extent!=="parent"){const g=n.get(e.parentNode),{x:v,y:w}=tc(g,a).positionAbsolute;u=[[e.extent[0][0]+v,e.extent[0][1]+w],[e.extent[1][0]+v,e.extent[1][1]+w]]}let m={x:0,y:0};if(e.parentNode){const g=n.get(e.parentNode);m=tc(g,a).positionAbsolute}const y=u&&u!=="parent"?dp(t,u):t;return{position:{x:y.x-m.x,y:y.y-m.y},positionAbsolute:y}}function t_({nodeId:e,dragItems:t,nodeInternals:n}){const o=t.map(a=>({...n.get(a.id),position:a.position,positionAbsolute:a.positionAbsolute}));return[e?o.find(a=>a.id===e):o[0],o]}const Zg=(e,t,n,o)=>{const a=t.querySelectorAll(e);if(!a||!a.length)return null;const l=Array.from(a),d=t.getBoundingClientRect(),u={x:d.width*o[0],y:d.height*o[1]};return l.map(m=>{const y=m.getBoundingClientRect();return{id:m.getAttribute("data-handleid"),position:m.getAttribute("data-handlepos"),x:(y.left-d.left-u.x)/n,y:(y.top-d.top-u.y)/n,...up(m)}})};function jd(e,t,n){return n===void 0?n:o=>{const a=t().nodeInternals.get(e);a&&n(o,{...a})}}function B_({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:a,unselectNodesAndEdges:l,multiSelectionActive:d,nodeInternals:u,onError:m}=t.getState(),y=u.get(e);if(!y){m==null||m("012",Qo.error012(e));return}t.setState({nodesSelectionActive:!1}),y.selected?(n||y.selected&&d)&&(l({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var g;return(g=o==null?void 0:o.current)==null?void 0:g.blur()})):a([e])}function j2(){const e=gr();return h.useCallback(({sourceEvent:n})=>{const{transform:o,snapGrid:a,snapToGrid:l}=e.getState(),d=n.touches?n.touches[0].clientX:n.clientX,u=n.touches?n.touches[0].clientY:n.clientY,m={x:(d-o[0])/o[2],y:(u-o[1])/o[2]};return{xSnapped:l?a[0]*Math.round(m.x/a[0]):m.x,ySnapped:l?a[1]*Math.round(m.y/a[1]):m.y,...m}},[])}function n_(e){return(t,n,o)=>e==null?void 0:e(t,o)}function Cw({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:a,isSelectable:l,selectNodesOnDrag:d}){const u=gr(),[m,y]=h.useState(!1),g=h.useRef([]),v=h.useRef({x:null,y:null}),w=h.useRef(0),b=h.useRef(null),C=h.useRef({x:0,y:0}),S=h.useRef(null),R=h.useRef(!1),T=h.useRef(!1),D=j2();return h.useEffect(()=>{if(e!=null&&e.current){const q=mi(e.current),P=({x:Z,y:ee})=>{const{nodeInternals:ue,onNodeDrag:de,onSelectionDrag:pe,updateNodePositions:F,nodeExtent:E,snapGrid:j,snapToGrid:L,nodeOrigin:z,onError:te}=u.getState();v.current={x:Z,y:ee};let I=!1,O={x:0,y:0,x2:0,y2:0};if(g.current.length>1&&E){const $=nh(g.current,z);O=Hd($)}if(g.current=g.current.map($=>{const Y={x:Z-$.distance.x,y:ee-$.distance.y};L&&(Y.x=j[0]*Math.round(Y.x/j[0]),Y.y=j[1]*Math.round(Y.y/j[1]));const se=[[E[0][0],E[0][1]],[E[1][0],E[1][1]]];g.current.length>1&&E&&!$.extent&&(se[0][0]=$.positionAbsolute.x-O.x+E[0][0],se[1][0]=$.positionAbsolute.x+($.width??0)-O.x2+E[1][0],se[0][1]=$.positionAbsolute.y-O.y+E[0][1],se[1][1]=$.positionAbsolute.y+($.height??0)-O.y2+E[1][1]);const le=Nw($,Y,ue,se,z,te);return I=I||$.position.x!==le.position.x||$.position.y!==le.position.y,$.position=le.position,$.positionAbsolute=le.positionAbsolute,$}),!I)return;F(g.current,!0,!0),y(!0);const G=a?de:n_(pe);if(G&&S.current){const[$,Y]=t_({nodeId:a,dragItems:g.current,nodeInternals:ue});G(S.current,$,Y)}},K=()=>{if(!b.current)return;const[Z,ee]=Yv(C.current,b.current);if(Z!==0||ee!==0){const{transform:ue,panBy:de}=u.getState();v.current.x=(v.current.x??0)-Z/ue[2],v.current.y=(v.current.y??0)-ee/ue[2],de({x:Z,y:ee})&&P(v.current)}w.current=requestAnimationFrame(K)},Q=Z=>{var z;const{nodeInternals:ee,multiSelectionActive:ue,nodesDraggable:de,unselectNodesAndEdges:pe,onNodeDragStart:F,onSelectionDragStart:E}=u.getState();T.current=!0;const j=a?F:n_(E);(!d||!l)&&!ue&&a&&((z=ee.get(a))!=null&&z.selected||pe()),a&&l&&d&&B_({id:a,store:u,nodeRef:e});const L=D(Z);if(v.current=L,g.current=b2(ee,de,L,a),j&&g.current){const[te,I]=t_({nodeId:a,dragItems:g.current,nodeInternals:ee});j(Z.sourceEvent,te,I)}};if(t)q.on(".drag",null);else{const Z=Lk().on("start",ee=>{const{domNode:ue,nodeDragThreshold:de}=u.getState();de===0&&Q(ee);const pe=D(ee);v.current=pe,b.current=(ue==null?void 0:ue.getBoundingClientRect())||null,C.current=Xa(ee.sourceEvent,b.current)}).on("drag",ee=>{var F,E;const ue=D(ee),{autoPanOnNodeDrag:de,nodeDragThreshold:pe}=u.getState();if(!R.current&&T.current&&de&&(R.current=!0,K()),!T.current){const j=ue.xSnapped-(((F=v==null?void 0:v.current)==null?void 0:F.x)??0),L=ue.ySnapped-(((E=v==null?void 0:v.current)==null?void 0:E.y)??0);Math.sqrt(j*j+L*L)>pe&&Q(ee)}(v.current.x!==ue.xSnapped||v.current.y!==ue.ySnapped)&&g.current&&T.current&&(S.current=ee.sourceEvent,C.current=Xa(ee.sourceEvent,b.current),P(ue))}).on("end",ee=>{if(T.current&&(y(!1),R.current=!1,T.current=!1,cancelAnimationFrame(w.current),g.current)){const{updateNodePositions:ue,nodeInternals:de,onNodeDragStop:pe,onSelectionDragStop:F}=u.getState(),E=a?pe:n_(F);if(ue(g.current,!1,!1),E){const[j,L]=t_({nodeId:a,dragItems:g.current,nodeInternals:de});E(ee.sourceEvent,j,L)}}}).filter(ee=>{const ue=ee.target;return!ee.button&&(!n||!Jg(ue,`.${n}`,e))&&(!o||Jg(ue,o,e))});return q.call(Z),()=>{q.on(".drag",null)}}}},[e,t,n,o,l,u,a,d,D]),m}function Ew(){const e=gr();return h.useCallback(n=>{const{nodeInternals:o,nodeExtent:a,updateNodePositions:l,getNodes:d,snapToGrid:u,snapGrid:m,onError:y,nodesDraggable:g}=e.getState(),v=d().filter(D=>D.selected&&(D.draggable||g&&typeof D.draggable>"u")),w=u?m[0]:5,b=u?m[1]:5,C=n.isShiftPressed?4:1,S=n.x*w*C,R=n.y*b*C,T=v.map(D=>{if(D.positionAbsolute){const q={x:D.positionAbsolute.x+S,y:D.positionAbsolute.y+R};u&&(q.x=m[0]*Math.round(q.x/m[0]),q.y=m[1]*Math.round(q.y/m[1]));const{positionAbsolute:P,position:K}=Nw(D,q,o,a,void 0,y);D.position=K,D.positionAbsolute=P}return D});l(T,!0,!1)},[])}const fu={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var kd=e=>{const t=({id:n,type:o,data:a,xPos:l,yPos:d,xPosOrigin:u,yPosOrigin:m,selected:y,onClick:g,onMouseEnter:v,onMouseMove:w,onMouseLeave:b,onContextMenu:C,onDoubleClick:S,style:R,className:T,isDraggable:D,isSelectable:q,isConnectable:P,isFocusable:K,selectNodesOnDrag:Q,sourcePosition:Z,targetPosition:ee,hidden:ue,resizeObserver:de,dragHandle:pe,zIndex:F,isParent:E,noDragClassName:j,noPanClassName:L,initialized:z,disableKeyboardA11y:te,ariaLabel:I,rfId:O,hasHandleBounds:G})=>{const $=gr(),Y=h.useRef(null),se=h.useRef(Z),le=h.useRef(ee),he=h.useRef(o),be=q||D||g||v||w||b,je=Ew(),Ce=jd(n,$.getState,v),Fe=jd(n,$.getState,w),Ke=jd(n,$.getState,b),Ye=jd(n,$.getState,C),Ct=jd(n,$.getState,S),wt=rt=>{const{nodeDragThreshold:Ne}=$.getState();if(q&&(!Q||!D||Ne>0)&&B_({id:n,store:$,nodeRef:Y}),g){const Oe=$.getState().nodeInternals.get(n);Oe&&g(rt,{...Oe})}},lt=rt=>{if(!O_(rt))if(Qv.includes(rt.key)&&q){const Ne=rt.key==="Escape";B_({id:n,store:$,unselect:Ne,nodeRef:Y})}else!te&&D&&y&&Object.prototype.hasOwnProperty.call(fu,rt.key)&&($.setState({ariaLiveMessage:`Moved selected node ${rt.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~d}`}),je({x:fu[rt.key].x,y:fu[rt.key].y,isShiftPressed:rt.shiftKey}))};h.useEffect(()=>()=>{Y.current&&(de==null||de.unobserve(Y.current))},[]),h.useEffect(()=>{if(Y.current&&!ue){const rt=Y.current;(!z||!G)&&(de==null||de.unobserve(rt),de==null||de.observe(rt))}},[ue,z,G]),h.useEffect(()=>{const rt=he.current!==o,Ne=se.current!==Z,Oe=le.current!==ee;Y.current&&(rt||Ne||Oe)&&(rt&&(he.current=o),Ne&&(se.current=Z),Oe&&(le.current=ee),$.getState().updateNodeDimensions([{id:n,nodeElement:Y.current,forceUpdate:!0}]))},[n,o,Z,ee]);const yt=Cw({nodeRef:Y,disabled:ue||!D,noDragClassName:j,handleSelector:pe,nodeId:n,isSelectable:q,selectNodesOnDrag:Q});return ue?null:ye.createElement("div",{className:zr(["react-flow__node",`react-flow__node-${o}`,{[L]:D},T,{selected:y,selectable:q,parent:E,dragging:yt}]),ref:Y,style:{zIndex:F,transform:`translate(${u}px,${m}px)`,pointerEvents:be?"all":"none",visibility:z?"visible":"hidden",...R},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:Ce,onMouseMove:Fe,onMouseLeave:Ke,onContextMenu:Ye,onClick:wt,onDoubleClick:Ct,onKeyDown:K?lt:void 0,tabIndex:K?0:void 0,role:K?"button":void 0,"aria-describedby":te?void 0:`${vw}-${O}`,"aria-label":I},ye.createElement(z1,{value:n},ye.createElement(e,{id:n,data:a,type:o,xPos:l,yPos:d,selected:y,isConnectable:P,sourcePosition:Z,targetPosition:ee,dragging:yt,dragHandle:pe,zIndex:F})))};return t.displayName="NodeWrapper",h.memo(t)};const k2=e=>{const t=e.getNodes().filter(n=>n.selected);return{...nh(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function N2({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=gr(),{width:a,height:l,x:d,y:u,transformString:m,userSelectionActive:y}=Rn(k2,Nr),g=Ew(),v=h.useRef(null);if(h.useEffect(()=>{var C;n||(C=v.current)==null||C.focus({preventScroll:!0})},[n]),Cw({nodeRef:v}),y||!a||!l)return null;const w=e?C=>{const S=o.getState().getNodes().filter(R=>R.selected);e(C,S)}:void 0,b=C=>{Object.prototype.hasOwnProperty.call(fu,C.key)&&g({x:fu[C.key].x,y:fu[C.key].y,isShiftPressed:C.shiftKey})};return ye.createElement("div",{className:zr(["react-flow__nodesselection","react-flow__container",t]),style:{transform:m}},ye.createElement("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:w,tabIndex:n?void 0:-1,onKeyDown:n?void 0:b,style:{width:a,height:l,top:u,left:d}}))}var C2=h.memo(N2);const E2=e=>e.nodesSelectionActive,$w=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:l,onPaneScroll:d,deleteKeyCode:u,onMove:m,onMoveStart:y,onMoveEnd:g,selectionKeyCode:v,selectionOnDrag:w,selectionMode:b,onSelectionStart:C,onSelectionEnd:S,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:D,elementsSelectable:q,zoomOnScroll:P,zoomOnPinch:K,panOnScroll:Q,panOnScrollSpeed:Z,panOnScrollMode:ee,zoomOnDoubleClick:ue,panOnDrag:de,defaultViewport:pe,translateExtent:F,minZoom:E,maxZoom:j,preventScrolling:L,onSelectionContextMenu:z,noWheelClassName:te,noPanClassName:I,disableKeyboardA11y:O})=>{const G=Rn(E2),$=Vd(v),Y=Vd(T),se=Y||de,le=Y||Q,he=$||w&&se!==!0;return f2({deleteKeyCode:u,multiSelectionKeyCode:R}),ye.createElement(p2,{onMove:m,onMoveStart:y,onMoveEnd:g,onPaneContextMenu:l,elementsSelectable:q,zoomOnScroll:P,zoomOnPinch:K,panOnScroll:le,panOnScrollSpeed:Z,panOnScrollMode:ee,zoomOnDoubleClick:ue,panOnDrag:!$&&se,defaultViewport:pe,translateExtent:F,minZoom:E,maxZoom:j,zoomActivationKeyCode:D,preventScrolling:L,noWheelClassName:te,noPanClassName:I},ye.createElement(jw,{onSelectionStart:C,onSelectionEnd:S,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:l,onPaneScroll:d,panOnDrag:se,isSelecting:!!he,selectionMode:b},e,G&&ye.createElement(C2,{onSelectionContextMenu:z,noPanClassName:I,disableKeyboardA11y:O})))};$w.displayName="FlowRenderer";var $2=h.memo($w);function M2(e){return Rn(h.useCallback(n=>e?ow(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function A2(e){const t={input:kd(e.input||_w),default:kd(e.default||F_),output:kd(e.output||gw),group:kd(e.group||gp)},n={},o=Object.keys(e).filter(a=>!["input","default","output","group"].includes(a)).reduce((a,l)=>(a[l]=kd(e[l]||F_),a),n);return{...t,...o}}const T2=({x:e,y:t,width:n,height:o,origin:a})=>!n||!o?{x:e,y:t}:a[0]<0||a[1]<0||a[0]>1||a[1]>1?{x:e,y:t}:{x:e-n*a[0],y:t-o*a[1]},R2=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),Mw=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:a,updateNodeDimensions:l,onError:d}=Rn(R2,Nr),u=M2(e.onlyRenderVisibleElements),m=h.useRef(),y=h.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const g=new ResizeObserver(v=>{const w=v.map(b=>({id:b.target.getAttribute("data-id"),nodeElement:b.target,forceUpdate:!0}));l(w)});return m.current=g,g},[]);return h.useEffect(()=>()=>{var g;(g=m==null?void 0:m.current)==null||g.disconnect()},[]),ye.createElement("div",{className:"react-flow__nodes",style:vp},u.map(g=>{var K,Q,Z;let v=g.type||"default";e.nodeTypes[v]||(d==null||d("003",Qo.error003(v)),v="default");const w=e.nodeTypes[v]||e.nodeTypes.default,b=!!(g.draggable||t&&typeof g.draggable>"u"),C=!!(g.selectable||a&&typeof g.selectable>"u"),S=!!(g.connectable||n&&typeof g.connectable>"u"),R=!!(g.focusable||o&&typeof g.focusable>"u"),T=e.nodeExtent?dp(g.positionAbsolute,e.nodeExtent):g.positionAbsolute,D=(T==null?void 0:T.x)??0,q=(T==null?void 0:T.y)??0,P=T2({x:D,y:q,width:g.width??0,height:g.height??0,origin:e.nodeOrigin});return ye.createElement(w,{key:g.id,id:g.id,className:g.className,style:g.style,type:v,data:g.data,sourcePosition:g.sourcePosition||dt.Bottom,targetPosition:g.targetPosition||dt.Top,hidden:g.hidden,xPos:D,yPos:q,xPosOrigin:P.x,yPosOrigin:P.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:C,isConnectable:S,isFocusable:R,resizeObserver:y,dragHandle:g.dragHandle,zIndex:((K=g[lr])==null?void 0:K.z)??0,isParent:!!((Q=g[lr])!=null&&Q.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!g.width&&!!g.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:g.ariaLabel,hasHandleBounds:!!((Z=g[lr])!=null&&Z.handleBounds)})}))};Mw.displayName="NodeRenderer";var L2=h.memo(Mw);const P2=(e,t,n)=>n===dt.Left?e-t:n===dt.Right?e+t:e,O2=(e,t,n)=>n===dt.Top?e-t:n===dt.Bottom?e+t:e,Qg="react-flow__edgeupdater",ey=({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:a,onMouseEnter:l,onMouseOut:d,type:u})=>ye.createElement("circle",{onMouseDown:a,onMouseEnter:l,onMouseOut:d,className:zr([Qg,`${Qg}-${u}`]),cx:P2(t,o,e),cy:O2(n,o,e),r:o,stroke:"transparent",fill:"transparent"}),z2=()=>!0;var tu=e=>{const t=({id:n,className:o,type:a,data:l,onClick:d,onEdgeDoubleClick:u,selected:m,animated:y,label:g,labelStyle:v,labelShowBg:w,labelBgStyle:b,labelBgPadding:C,labelBgBorderRadius:S,style:R,source:T,target:D,sourceX:q,sourceY:P,targetX:K,targetY:Q,sourcePosition:Z,targetPosition:ee,elementsSelectable:ue,hidden:de,sourceHandleId:pe,targetHandleId:F,onContextMenu:E,onMouseEnter:j,onMouseMove:L,onMouseLeave:z,edgeUpdaterRadius:te,onEdgeUpdate:I,onEdgeUpdateStart:O,onEdgeUpdateEnd:G,markerEnd:$,markerStart:Y,rfId:se,ariaLabel:le,isFocusable:he,isUpdatable:be,pathOptions:je,interactionWidth:Ce})=>{const Fe=h.useRef(null),[Ke,Ye]=h.useState(!1),[Ct,wt]=h.useState(!1),lt=gr(),yt=h.useMemo(()=>`url('#${I_(Y,se)}')`,[Y,se]),rt=h.useMemo(()=>`url('#${I_($,se)}')`,[$,se]);if(de)return null;const Ne=jt=>{var Jt;const{edges:mn,addSelectedEdges:Hn,unselectNodesAndEdges:Nn,multiSelectionActive:yn}=lt.getState(),Cn=mn.find(cr=>cr.id===n);Cn&&(ue&&(lt.setState({nodesSelectionActive:!1}),Cn.selected&&yn?(Nn({nodes:[],edges:[Cn]}),(Jt=Fe.current)==null||Jt.blur()):Hn([n])),d&&d(jt,Cn))},Oe=Sd(n,lt.getState,u),it=Sd(n,lt.getState,E),ve=Sd(n,lt.getState,j),Ie=Sd(n,lt.getState,L),Ge=Sd(n,lt.getState,z),Mt=(jt,mn)=>{if(jt.button!==0)return;const{edges:Hn,isValidConnection:Nn}=lt.getState(),yn=mn?D:T,Cn=(mn?F:pe)||null,Jt=mn?"target":"source",cr=Nn||z2,hn=mn,Wn=Hn.find(ne=>ne.id===n);wt(!0),O==null||O(jt,Wn,Jt);const vn=ne=>{wt(!1),G==null||G(ne,Wn,Jt)};dw({event:jt,handleId:Cn,nodeId:yn,onConnect:ne=>I==null?void 0:I(Wn,ne),isTarget:hn,getState:lt.getState,setState:lt.setState,isValidConnection:cr,edgeUpdaterType:Jt,onEdgeUpdateEnd:vn})},Bt=jt=>Mt(jt,!0),dn=jt=>Mt(jt,!1),Ft=()=>Ye(!0),At=()=>Ye(!1),fn=!ue&&!d,Kn=jt=>{var mn;if(Qv.includes(jt.key)&&ue){const{unselectNodesAndEdges:Hn,addSelectedEdges:Nn,edges:yn}=lt.getState();jt.key==="Escape"?((mn=Fe.current)==null||mn.blur(),Hn({edges:[yn.find(Jt=>Jt.id===n)]})):Nn([n])}};return ye.createElement("g",{className:zr(["react-flow__edge",`react-flow__edge-${a}`,o,{selected:m,animated:y,inactive:fn,updating:Ke}]),onClick:Ne,onDoubleClick:Oe,onContextMenu:it,onMouseEnter:ve,onMouseMove:Ie,onMouseLeave:Ge,onKeyDown:he?Kn:void 0,tabIndex:he?0:void 0,role:he?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":le===null?void 0:le||`Edge from ${T} to ${D}`,"aria-describedby":he?`${ww}-${se}`:void 0,ref:Fe},!Ct&&ye.createElement(e,{id:n,source:T,target:D,selected:m,animated:y,label:g,labelStyle:v,labelShowBg:w,labelBgStyle:b,labelBgPadding:C,labelBgBorderRadius:S,data:l,style:R,sourceX:q,sourceY:P,targetX:K,targetY:Q,sourcePosition:Z,targetPosition:ee,sourceHandleId:pe,targetHandleId:F,markerStart:yt,markerEnd:rt,pathOptions:je,interactionWidth:Ce}),be&&ye.createElement(ye.Fragment,null,(be==="source"||be===!0)&&ye.createElement(ey,{position:Z,centerX:q,centerY:P,radius:te,onMouseDown:Bt,onMouseEnter:Ft,onMouseOut:At,type:"source"}),(be==="target"||be===!0)&&ye.createElement(ey,{position:ee,centerX:K,centerY:Q,radius:te,onMouseDown:dn,onMouseEnter:Ft,onMouseOut:At,type:"target"})))};return t.displayName="EdgeWrapper",h.memo(t)};function I2(e){const t={default:tu(e.default||Um),straight:tu(e.bezier||hp),step:tu(e.step||mp),smoothstep:tu(e.step||th),simplebezier:tu(e.simplebezier||fp)},n={},o=Object.keys(e).filter(a=>!["default","bezier"].includes(a)).reduce((a,l)=>(a[l]=tu(e[l]||Um),a),n);return{...t,...o}}function ty(e,t,n=null){const o=((n==null?void 0:n.x)||0)+t.x,a=((n==null?void 0:n.y)||0)+t.y,l=(n==null?void 0:n.width)||t.width,d=(n==null?void 0:n.height)||t.height;switch(e){case dt.Top:return{x:o+l/2,y:a};case dt.Right:return{x:o+l,y:a+d/2};case dt.Bottom:return{x:o+l/2,y:a+d};case dt.Left:return{x:o,y:a+d/2}}}function ny(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const D2=(e,t,n,o,a,l)=>{const d=ty(n,e,t),u=ty(l,o,a);return{sourceX:d.x,sourceY:d.y,targetX:u.x,targetY:u.y}};function F2({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:o,targetWidth:a,targetHeight:l,width:d,height:u,transform:m}){const y={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+a),y2:Math.max(e.y+o,t.y+l)};y.x===y.x2&&(y.x2+=1),y.y===y.y2&&(y.y2+=1);const g=Hd({x:(0-m[0])/m[2],y:(0-m[1])/m[2],width:d/m[2],height:u/m[2]}),v=Math.max(0,Math.min(g.x2,y.x2)-Math.max(g.x,y.x)),w=Math.max(0,Math.min(g.y2,y.y2)-Math.max(g.y,y.y));return Math.ceil(v*w)>0}function ry(e){var o,a,l,d,u;const t=((o=e==null?void 0:e[lr])==null?void 0:o.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((a=e==null?void 0:e.positionAbsolute)==null?void 0:a.x)<"u"&&typeof((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)<"u";return[{x:((d=e==null?void 0:e.positionAbsolute)==null?void 0:d.x)||0,y:((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const B2=[{level:0,isMaxLevel:!0,edges:[]}];function U2(e,t,n=!1){let o=-1;const a=e.reduce((d,u)=>{var g,v;const m=hi(u.zIndex);let y=m?u.zIndex:0;if(n){const w=t.get(u.target),b=t.get(u.source),C=u.selected||(w==null?void 0:w.selected)||(b==null?void 0:b.selected),S=Math.max(((g=b==null?void 0:b[lr])==null?void 0:g.z)||0,((v=w==null?void 0:w[lr])==null?void 0:v.z)||0,1e3);y=(m?u.zIndex:0)+(C?S:0)}return d[y]?d[y].push(u):d[y]=[u],o=y>o?y:o,d},{}),l=Object.entries(a).map(([d,u])=>{const m=+d;return{edges:u,level:m,isMaxLevel:m===o}});return l.length===0?B2:l}function H2(e,t,n){const o=Rn(h.useCallback(a=>e?a.edges.filter(l=>{const d=t.get(l.source),u=t.get(l.target);return(d==null?void 0:d.width)&&(d==null?void 0:d.height)&&(u==null?void 0:u.width)&&(u==null?void 0:u.height)&&F2({sourcePos:d.positionAbsolute||{x:0,y:0},targetPos:u.positionAbsolute||{x:0,y:0},sourceWidth:d.width,sourceHeight:d.height,targetWidth:u.width,targetHeight:u.height,width:a.width,height:a.height,transform:a.transform})}):a.edges,[e,t]));return U2(o,t,n)}const W2=({color:e="none",strokeWidth:t=1})=>ye.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),q2=({color:e="none",strokeWidth:t=1})=>ye.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),sy={[qd.Arrow]:W2,[qd.ArrowClosed]:q2};function V2(e){const t=gr();return h.useMemo(()=>{var a,l;return Object.prototype.hasOwnProperty.call(sy,e)?sy[e]:((l=(a=t.getState()).onError)==null||l.call(a,"009",Qo.error009(e)),null)},[e])}const G2=({id:e,type:t,color:n,width:o=12.5,height:a=12.5,markerUnits:l="strokeWidth",strokeWidth:d,orient:u="auto-start-reverse"})=>{const m=V2(t);return m?ye.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:u,refX:"0",refY:"0"},ye.createElement(m,{color:n,strokeWidth:d})):null},K2=({defaultColor:e,rfId:t})=>n=>{const o=[];return n.edges.reduce((a,l)=>([l.markerStart,l.markerEnd].forEach(d=>{if(d&&typeof d=="object"){const u=I_(d,t);o.includes(u)||(a.push({id:u,color:d.color||e,...d}),o.push(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))},Aw=({defaultColor:e,rfId:t})=>{const n=Rn(h.useCallback(K2({defaultColor:e,rfId:t}),[e,t]),(o,a)=>!(o.length!==a.length||o.some((l,d)=>l.id!==a[d].id)));return ye.createElement("defs",null,n.map(o=>ye.createElement(G2,{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})))};Aw.displayName="MarkerDefinitions";var Y2=h.memo(Aw);const X2=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}),Tw=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:o,edgeTypes:a,noPanClassName:l,onEdgeUpdate:d,onEdgeContextMenu:u,onEdgeMouseEnter:m,onEdgeMouseMove:y,onEdgeMouseLeave:g,onEdgeClick:v,edgeUpdaterRadius:w,onEdgeDoubleClick:b,onEdgeUpdateStart:C,onEdgeUpdateEnd:S,children:R})=>{const{edgesFocusable:T,edgesUpdatable:D,elementsSelectable:q,width:P,height:K,connectionMode:Q,nodeInternals:Z,onError:ee}=Rn(X2,Nr),ue=H2(t,Z,n);return P?ye.createElement(ye.Fragment,null,ue.map(({level:de,edges:pe,isMaxLevel:F})=>ye.createElement("svg",{key:de,style:{zIndex:de},width:P,height:K,className:"react-flow__edges react-flow__container"},F&&ye.createElement(Y2,{defaultColor:e,rfId:o}),ye.createElement("g",null,pe.map(E=>{const[j,L,z]=ry(Z.get(E.source)),[te,I,O]=ry(Z.get(E.target));if(!z||!O)return null;let G=E.type||"default";a[G]||(ee==null||ee("011",Qo.error011(G)),G="default");const $=a[G]||a.default,Y=Q===ic.Strict?I.target:(I.target??[]).concat(I.source??[]),se=ny(L.source,E.sourceHandle),le=ny(Y,E.targetHandle),he=(se==null?void 0:se.position)||dt.Bottom,be=(le==null?void 0:le.position)||dt.Top,je=!!(E.focusable||T&&typeof E.focusable>"u"),Ce=typeof d<"u"&&(E.updatable||D&&typeof E.updatable>"u");if(!se||!le)return ee==null||ee("008",Qo.error008(se,E)),null;const{sourceX:Fe,sourceY:Ke,targetX:Ye,targetY:Ct}=D2(j,se,he,te,le,be);return ye.createElement($,{key:E.id,id:E.id,className:zr([E.className,l]),type:G,data:E.data,selected:!!E.selected,animated:!!E.animated,hidden:!!E.hidden,label:E.label,labelStyle:E.labelStyle,labelShowBg:E.labelShowBg,labelBgStyle:E.labelBgStyle,labelBgPadding:E.labelBgPadding,labelBgBorderRadius:E.labelBgBorderRadius,style:E.style,source:E.source,target:E.target,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle,markerEnd:E.markerEnd,markerStart:E.markerStart,sourceX:Fe,sourceY:Ke,targetX:Ye,targetY:Ct,sourcePosition:he,targetPosition:be,elementsSelectable:q,onEdgeUpdate:d,onContextMenu:u,onMouseEnter:m,onMouseMove:y,onMouseLeave:g,onClick:v,edgeUpdaterRadius:w,onEdgeDoubleClick:b,onEdgeUpdateStart:C,onEdgeUpdateEnd:S,rfId:o,ariaLabel:E.ariaLabel,isFocusable:je,isUpdatable:Ce,pathOptions:"pathOptions"in E?E.pathOptions:void 0,interactionWidth:E.interactionWidth})})))),R):null};Tw.displayName="EdgeRenderer";var J2=h.memo(Tw);const Z2=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Q2({children:e}){const t=Rn(Z2);return ye.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function eC(e){const t=yp(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const tC={[dt.Left]:dt.Right,[dt.Right]:dt.Left,[dt.Top]:dt.Bottom,[dt.Bottom]:dt.Top},Rw=({nodeId:e,handleType:t,style:n,type:o=Ya.Bezier,CustomComponent:a,connectionStatus:l})=>{var Q,Z,ee;const{fromNode:d,handleId:u,toX:m,toY:y,connectionMode:g}=Rn(h.useCallback(ue=>({fromNode:ue.nodeInternals.get(e),handleId:ue.connectionHandleId,toX:(ue.connectionPosition.x-ue.transform[0])/ue.transform[2],toY:(ue.connectionPosition.y-ue.transform[1])/ue.transform[2],connectionMode:ue.connectionMode}),[e]),Nr),v=(Q=d==null?void 0:d[lr])==null?void 0:Q.handleBounds;let w=v==null?void 0:v[t];if(g===ic.Loose&&(w=w||(v==null?void 0:v[t==="source"?"target":"source"])),!d||!w)return null;const b=u?w.find(ue=>ue.id===u):w[0],C=b?b.x+b.width/2:(d.width??0)/2,S=b?b.y+b.height/2:d.height??0,R=(((Z=d.positionAbsolute)==null?void 0:Z.x)??0)+C,T=(((ee=d.positionAbsolute)==null?void 0:ee.y)??0)+S,D=b==null?void 0:b.position,q=D?tC[D]:null;if(!D||!q)return null;if(a)return ye.createElement(a,{connectionLineType:o,connectionLineStyle:n,fromNode:d,fromHandle:b,fromX:R,fromY:T,toX:m,toY:y,fromPosition:D,toPosition:q,connectionStatus:l});let P="";const K={sourceX:R,sourceY:T,sourcePosition:D,targetX:m,targetY:y,targetPosition:q};return o===Ya.Bezier?[P]=sw(K):o===Ya.Step?[P]=z_({...K,borderRadius:0}):o===Ya.SmoothStep?[P]=z_(K):o===Ya.SimpleBezier?[P]=rw(K):P=`M${R},${T} ${m},${y}`,ye.createElement("path",{d:P,fill:"none",className:"react-flow__connection-path",style:n})};Rw.displayName="ConnectionLine";const nC=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function rC({containerStyle:e,style:t,type:n,component:o}){const{nodeId:a,handleType:l,nodesConnectable:d,width:u,height:m,connectionStatus:y}=Rn(nC,Nr);return!(a&&l&&u&&d)?null:ye.createElement("svg",{style:e,width:u,height:m,className:"react-flow__edges react-flow__connectionline react-flow__container"},ye.createElement("g",{className:zr(["react-flow__connection",y])},ye.createElement(Rw,{nodeId:a,handleType:l,style:t,type:n,CustomComponent:o,connectionStatus:y})))}function iy(e,t){return h.useRef(null),gr(),h.useMemo(()=>t(e),[e])}const Lw=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:o,onMoveEnd:a,onInit:l,onNodeClick:d,onEdgeClick:u,onNodeDoubleClick:m,onEdgeDoubleClick:y,onNodeMouseEnter:g,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:b,onSelectionContextMenu:C,onSelectionStart:S,onSelectionEnd:R,connectionLineType:T,connectionLineStyle:D,connectionLineComponent:q,connectionLineContainerStyle:P,selectionKeyCode:K,selectionOnDrag:Q,selectionMode:Z,multiSelectionKeyCode:ee,panActivationKeyCode:ue,zoomActivationKeyCode:de,deleteKeyCode:pe,onlyRenderVisibleElements:F,elementsSelectable:E,selectNodesOnDrag:j,defaultViewport:L,translateExtent:z,minZoom:te,maxZoom:I,preventScrolling:O,defaultMarkerColor:G,zoomOnScroll:$,zoomOnPinch:Y,panOnScroll:se,panOnScrollSpeed:le,panOnScrollMode:he,zoomOnDoubleClick:be,panOnDrag:je,onPaneClick:Ce,onPaneMouseEnter:Fe,onPaneMouseMove:Ke,onPaneMouseLeave:Ye,onPaneScroll:Ct,onPaneContextMenu:wt,onEdgeUpdate:lt,onEdgeContextMenu:yt,onEdgeMouseEnter:rt,onEdgeMouseMove:Ne,onEdgeMouseLeave:Oe,edgeUpdaterRadius:it,onEdgeUpdateStart:ve,onEdgeUpdateEnd:Ie,noDragClassName:Ge,noWheelClassName:Mt,noPanClassName:Bt,elevateEdgesOnSelect:dn,disableKeyboardA11y:Ft,nodeOrigin:At,nodeExtent:fn,rfId:Kn})=>{const jt=iy(e,A2),mn=iy(t,I2);return eC(l),ye.createElement($2,{onPaneClick:Ce,onPaneMouseEnter:Fe,onPaneMouseMove:Ke,onPaneMouseLeave:Ye,onPaneContextMenu:wt,onPaneScroll:Ct,deleteKeyCode:pe,selectionKeyCode:K,selectionOnDrag:Q,selectionMode:Z,onSelectionStart:S,onSelectionEnd:R,multiSelectionKeyCode:ee,panActivationKeyCode:ue,zoomActivationKeyCode:de,elementsSelectable:E,onMove:n,onMoveStart:o,onMoveEnd:a,zoomOnScroll:$,zoomOnPinch:Y,zoomOnDoubleClick:be,panOnScroll:se,panOnScrollSpeed:le,panOnScrollMode:he,panOnDrag:je,defaultViewport:L,translateExtent:z,minZoom:te,maxZoom:I,onSelectionContextMenu:C,preventScrolling:O,noDragClassName:Ge,noWheelClassName:Mt,noPanClassName:Bt,disableKeyboardA11y:Ft},ye.createElement(Q2,null,ye.createElement(J2,{edgeTypes:mn,onEdgeClick:u,onEdgeDoubleClick:y,onEdgeUpdate:lt,onlyRenderVisibleElements:F,onEdgeContextMenu:yt,onEdgeMouseEnter:rt,onEdgeMouseMove:Ne,onEdgeMouseLeave:Oe,onEdgeUpdateStart:ve,onEdgeUpdateEnd:Ie,edgeUpdaterRadius:it,defaultMarkerColor:G,noPanClassName:Bt,elevateEdgesOnSelect:!!dn,disableKeyboardA11y:Ft,rfId:Kn},ye.createElement(rC,{style:D,type:T,component:q,containerStyle:P})),ye.createElement("div",{className:"react-flow__edgelabel-renderer"}),ye.createElement(L2,{nodeTypes:jt,onNodeClick:d,onNodeDoubleClick:m,onNodeMouseEnter:g,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:b,selectNodesOnDrag:j,onlyRenderVisibleElements:F,noPanClassName:Bt,noDragClassName:Ge,disableKeyboardA11y:Ft,nodeOrigin:At,nodeExtent:fn,rfId:Kn})))};Lw.displayName="GraphView";var sC=h.memo(Lw);const U_=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ha={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:U_,nodeExtent:U_,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:ic.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:A1,isValidConnection:void 0},iC=()=>VS((e,t)=>({...Ha,setNodes:n=>{const{nodeInternals:o,nodeOrigin:a,elevateNodesOnSelect:l}=t();e({nodeInternals:Qh(n,o,a,l)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=t();e({edges:n.map(a=>({...o,...a}))})},setDefaultNodesAndEdges:(n,o)=>{const a=typeof n<"u",l=typeof o<"u",d=a?Qh(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:d,edges:l?o:[],hasDefaultNodes:a,hasDefaultEdges:l})},updateNodeDimensions:n=>{const{onNodesChange:o,nodeInternals:a,fitViewOnInit:l,fitViewOnInitDone:d,fitViewOnInitOptions:u,domNode:m,nodeOrigin:y}=t(),g=m==null?void 0:m.querySelector(".react-flow__viewport");if(!g)return;const v=window.getComputedStyle(g),{m22:w}=new window.DOMMatrixReadOnly(v.transform),b=n.reduce((S,R)=>{const T=a.get(R.id);if(T){const D=up(R.nodeElement);!!(D.width&&D.height&&(T.width!==D.width||T.height!==D.height||R.forceUpdate))&&(a.set(T.id,{...T,[lr]:{...T[lr],handleBounds:{source:Zg(".source",R.nodeElement,w,y),target:Zg(".target",R.nodeElement,w,y)}},...D}),S.push({id:T.id,type:"dimensions",dimensions:D}))}return S},[]);bw(a,y);const C=d||l&&!d&&Sw(t,{initial:!0,...u});e({nodeInternals:new Map(a),fitViewOnInitDone:C}),(b==null?void 0:b.length)>0&&(o==null||o(b))},updateNodePositions:(n,o=!0,a=!1)=>{const{triggerNodeChanges:l}=t(),d=n.map(u=>{const m={id:u.id,type:"position",dragging:a};return o&&(m.positionAbsolute=u.positionAbsolute,m.position=u.position),m});l(d)},triggerNodeChanges:n=>{const{onNodesChange:o,nodeInternals:a,hasDefaultNodes:l,nodeOrigin:d,getNodes:u,elevateNodesOnSelect:m}=t();if(n!=null&&n.length){if(l){const y=w2(n,u()),g=Qh(y,a,d,m);e({nodeInternals:g})}o==null||o(n)}},addSelectedNodes:n=>{const{multiSelectionActive:o,edges:a,getNodes:l}=t();let d,u=null;o?d=n.map(m=>Ga(m,!0)):(d=iu(l(),n),u=iu(a,[])),hm({changedNodes:d,changedEdges:u,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:o,edges:a,getNodes:l}=t();let d,u=null;o?d=n.map(m=>Ga(m,!0)):(d=iu(a,n),u=iu(l(),[])),hm({changedNodes:u,changedEdges:d,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:o}={})=>{const{edges:a,getNodes:l}=t(),d=n||l(),u=o||a,m=d.map(g=>(g.selected=!1,Ga(g.id,!1))),y=u.map(g=>Ga(g.id,!1));hm({changedNodes:m,changedEdges:y,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:a}=t();o==null||o.scaleExtent([n,a]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:a}=t();o==null||o.scaleExtent([a,n]),e({maxZoom:n})},setTranslateExtent:n=>{var o;(o=t().d3Zoom)==null||o.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:o}=t(),l=o().filter(u=>u.selected).map(u=>Ga(u.id,!1)),d=n.filter(u=>u.selected).map(u=>Ga(u.id,!1));hm({changedNodes:l,changedEdges:d,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:o}=t();o.forEach(a=>{a.positionAbsolute=dp(a.position,n)}),e({nodeExtent:n,nodeInternals:new Map(o)})},panBy:n=>{const{transform:o,width:a,height:l,d3Zoom:d,d3Selection:u,translateExtent:m}=t();if(!d||!u||!n.x&&!n.y)return!1;const y=Xo.translate(o[0]+n.x,o[1]+n.y).scale(o[2]),g=[[0,0],[a,l]],v=d==null?void 0:d.constrain()(y,g,m);return d.transform(u,v),o[0]!==v.x||o[1]!==v.y||o[2]!==v.k},cancelConnection:()=>e({connectionNodeId:Ha.connectionNodeId,connectionHandleId:Ha.connectionHandleId,connectionHandleType:Ha.connectionHandleType,connectionStatus:Ha.connectionStatus,connectionStartHandle:Ha.connectionStartHandle,connectionEndHandle:Ha.connectionEndHandle}),reset:()=>e({...Ha})}),Object.is),wp=({children:e})=>{const t=h.useRef(null);return t.current||(t.current=iC()),ye.createElement(j1,{value:t.current},e)};wp.displayName="ReactFlowProvider";const Pw=({children:e})=>h.useContext(eh)?ye.createElement(ye.Fragment,null,e):ye.createElement(wp,null,e);Pw.displayName="ReactFlowWrapper";const oC={input:_w,default:F_,output:gw,group:gp},aC={default:Um,straight:hp,step:mp,smoothstep:th,simplebezier:fp},lC=[0,0],cC=[15,15],uC={x:0,y:0,zoom:1},dC={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Ow=h.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:a,nodeTypes:l=oC,edgeTypes:d=aC,onNodeClick:u,onEdgeClick:m,onInit:y,onMove:g,onMoveStart:v,onMoveEnd:w,onConnect:b,onConnectStart:C,onConnectEnd:S,onClickConnectStart:R,onClickConnectEnd:T,onNodeMouseEnter:D,onNodeMouseMove:q,onNodeMouseLeave:P,onNodeContextMenu:K,onNodeDoubleClick:Q,onNodeDragStart:Z,onNodeDrag:ee,onNodeDragStop:ue,onNodesDelete:de,onEdgesDelete:pe,onSelectionChange:F,onSelectionDragStart:E,onSelectionDrag:j,onSelectionDragStop:L,onSelectionContextMenu:z,onSelectionStart:te,onSelectionEnd:I,connectionMode:O=ic.Strict,connectionLineType:G=Ya.Bezier,connectionLineStyle:$,connectionLineComponent:Y,connectionLineContainerStyle:se,deleteKeyCode:le="Backspace",selectionKeyCode:he="Shift",selectionOnDrag:be=!1,selectionMode:je=Wd.Full,panActivationKeyCode:Ce="Space",multiSelectionKeyCode:Fe=Bm()?"Meta":"Control",zoomActivationKeyCode:Ke=Bm()?"Meta":"Control",snapToGrid:Ye=!1,snapGrid:Ct=cC,onlyRenderVisibleElements:wt=!1,selectNodesOnDrag:lt=!0,nodesDraggable:yt,nodesConnectable:rt,nodesFocusable:Ne,nodeOrigin:Oe=lC,edgesFocusable:it,edgesUpdatable:ve,elementsSelectable:Ie,defaultViewport:Ge=uC,minZoom:Mt=.5,maxZoom:Bt=2,translateExtent:dn=U_,preventScrolling:Ft=!0,nodeExtent:At,defaultMarkerColor:fn="#b1b1b7",zoomOnScroll:Kn=!0,zoomOnPinch:jt=!0,panOnScroll:mn=!1,panOnScrollSpeed:Hn=.5,panOnScrollMode:Nn=Jl.Free,zoomOnDoubleClick:yn=!0,panOnDrag:Cn=!0,onPaneClick:Jt,onPaneMouseEnter:cr,onPaneMouseMove:hn,onPaneMouseLeave:Wn,onPaneScroll:vn,onPaneContextMenu:Ln,children:ne,onEdgeUpdate:ge,onEdgeContextMenu:Te,onEdgeDoubleClick:qe,onEdgeMouseEnter:He,onEdgeMouseMove:ot,onEdgeMouseLeave:pt,onEdgeUpdateStart:vt,onEdgeUpdateEnd:zt,edgeUpdaterRadius:ct=10,onNodesChange:It,onEdgesChange:qt,noDragClassName:ce="nodrag",noWheelClassName:kt="nowheel",noPanClassName:Lt="nopan",fitView:Ve=!1,fitViewOptions:en,connectOnClick:_n=!0,attributionPosition:ln,proOptions:pn,defaultEdgeOptions:er,elevateNodesOnSelect:Gr=!0,elevateEdgesOnSelect:Cr=!1,disableKeyboardA11y:Kr=!1,autoPanOnConnect:Gs=!0,autoPanOnNodeDrag:$s=!0,connectionRadius:gi=20,isValidConnection:Ks,onError:Ir,style:sn,id:ea,nodeDragThreshold:Yr,...Ms},As)=>{const Ys=ea||"1";return ye.createElement("div",{...Ms,style:{...sn,...dC},ref:As,className:zr(["react-flow",a]),"data-testid":"rf__wrapper",id:ea},ye.createElement(Pw,null,ye.createElement(sC,{onInit:y,onMove:g,onMoveStart:v,onMoveEnd:w,onNodeClick:u,onEdgeClick:m,onNodeMouseEnter:D,onNodeMouseMove:q,onNodeMouseLeave:P,onNodeContextMenu:K,onNodeDoubleClick:Q,nodeTypes:l,edgeTypes:d,connectionLineType:G,connectionLineStyle:$,connectionLineComponent:Y,connectionLineContainerStyle:se,selectionKeyCode:he,selectionOnDrag:be,selectionMode:je,deleteKeyCode:le,multiSelectionKeyCode:Fe,panActivationKeyCode:Ce,zoomActivationKeyCode:Ke,onlyRenderVisibleElements:wt,selectNodesOnDrag:lt,defaultViewport:Ge,translateExtent:dn,minZoom:Mt,maxZoom:Bt,preventScrolling:Ft,zoomOnScroll:Kn,zoomOnPinch:jt,zoomOnDoubleClick:yn,panOnScroll:mn,panOnScrollSpeed:Hn,panOnScrollMode:Nn,panOnDrag:Cn,onPaneClick:Jt,onPaneMouseEnter:cr,onPaneMouseMove:hn,onPaneMouseLeave:Wn,onPaneScroll:vn,onPaneContextMenu:Ln,onSelectionContextMenu:z,onSelectionStart:te,onSelectionEnd:I,onEdgeUpdate:ge,onEdgeContextMenu:Te,onEdgeDoubleClick:qe,onEdgeMouseEnter:He,onEdgeMouseMove:ot,onEdgeMouseLeave:pt,onEdgeUpdateStart:vt,onEdgeUpdateEnd:zt,edgeUpdaterRadius:ct,defaultMarkerColor:fn,noDragClassName:ce,noWheelClassName:kt,noPanClassName:Lt,elevateEdgesOnSelect:Cr,rfId:Ys,disableKeyboardA11y:Kr,nodeOrigin:Oe,nodeExtent:At}),ye.createElement(e2,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:b,onConnectStart:C,onConnectEnd:S,onClickConnectStart:R,onClickConnectEnd:T,nodesDraggable:yt,nodesConnectable:rt,nodesFocusable:Ne,edgesFocusable:it,edgesUpdatable:ve,elementsSelectable:Ie,elevateNodesOnSelect:Gr,minZoom:Mt,maxZoom:Bt,nodeExtent:At,onNodesChange:It,onEdgesChange:qt,snapToGrid:Ye,snapGrid:Ct,connectionMode:O,translateExtent:dn,connectOnClick:_n,defaultEdgeOptions:er,fitView:Ve,fitViewOptions:en,onNodesDelete:de,onEdgesDelete:pe,onNodeDragStart:Z,onNodeDrag:ee,onNodeDragStop:ue,onSelectionDrag:j,onSelectionDragStart:E,onSelectionDragStop:L,noPanClassName:Lt,nodeOrigin:Oe,rfId:Ys,autoPanOnConnect:Gs,autoPanOnNodeDrag:$s,onError:Ir,connectionRadius:gi,isValidConnection:Ks,nodeDragThreshold:Yr}),ye.createElement(Z1,{onSelectionChange:F}),ne,ye.createElement(N1,{proOptions:pn,position:ln}),ye.createElement(i2,{rfId:Ys,disableKeyboardA11y:Kr})))});Ow.displayName="ReactFlow";const zw=({id:e,x:t,y:n,width:o,height:a,style:l,color:d,strokeColor:u,strokeWidth:m,className:y,borderRadius:g,shapeRendering:v,onClick:w,selected:b})=>{const{background:C,backgroundColor:S}=l||{},R=d||C||S;return ye.createElement("rect",{className:zr(["react-flow__minimap-node",{selected:b},y]),x:t,y:n,rx:g,ry:g,width:o,height:a,fill:R,stroke:u,strokeWidth:m,shapeRendering:v,onClick:w?T=>w(T,e):void 0})};zw.displayName="MiniMapNode";var fC=h.memo(zw);const mC=e=>e.nodeOrigin,hC=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),r_=e=>e instanceof Function?e:()=>e;function _C({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:a=2,nodeComponent:l=fC,onClick:d}){const u=Rn(hC,Nr),m=Rn(mC),y=r_(t),g=r_(e),v=r_(n),w=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return ye.createElement(ye.Fragment,null,u.map(b=>{const{x:C,y:S}=tc(b,m).positionAbsolute;return ye.createElement(l,{key:b.id,x:C,y:S,width:b.width,height:b.height,style:b.style,selected:b.selected,className:v(b),color:y(b),borderRadius:o,strokeColor:g(b),strokeWidth:a,shapeRendering:w,onClick:d,id:b.id})}))}var pC=h.memo(_C);const gC=200,yC=150,vC=e=>{const t=e.getNodes(),n={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:n,boundingRect:t.length>0?$1(nh(t,e.nodeOrigin),n):n,rfId:e.rfId}},wC="react-flow__minimap-desc";function Iw({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:o="#e2e2e2",nodeClassName:a="",nodeBorderRadius:l=5,nodeStrokeWidth:d=2,nodeComponent:u,maskColor:m="rgb(240, 240, 240, 0.6)",maskStrokeColor:y="none",maskStrokeWidth:g=1,position:v="bottom-right",onClick:w,onNodeClick:b,pannable:C=!1,zoomable:S=!1,ariaLabel:R="React Flow mini map",inversePan:T=!1,zoomStep:D=10,offsetScale:q=5}){const P=gr(),K=h.useRef(null),{boundingRect:Q,viewBB:Z,rfId:ee}=Rn(vC,Nr),ue=(e==null?void 0:e.width)??gC,de=(e==null?void 0:e.height)??yC,pe=Q.width/ue,F=Q.height/de,E=Math.max(pe,F),j=E*ue,L=E*de,z=q*E,te=Q.x-(j-Q.width)/2-z,I=Q.y-(L-Q.height)/2-z,O=j+z*2,G=L+z*2,$=`${wC}-${ee}`,Y=h.useRef(0);Y.current=E,h.useEffect(()=>{if(K.current){const he=mi(K.current),be=Fe=>{const{transform:Ke,d3Selection:Ye,d3Zoom:Ct}=P.getState();if(Fe.sourceEvent.type!=="wheel"||!Ye||!Ct)return;const wt=-Fe.sourceEvent.deltaY*(Fe.sourceEvent.deltaMode===1?.05:Fe.sourceEvent.deltaMode?1:.002)*D,lt=Ke[2]*Math.pow(2,wt);Ct.scaleTo(Ye,lt)},je=Fe=>{const{transform:Ke,d3Selection:Ye,d3Zoom:Ct,translateExtent:wt,width:lt,height:yt}=P.getState();if(Fe.sourceEvent.type!=="mousemove"||!Ye||!Ct)return;const rt=Y.current*Math.max(1,Ke[2])*(T?-1:1),Ne={x:Ke[0]-Fe.sourceEvent.movementX*rt,y:Ke[1]-Fe.sourceEvent.movementY*rt},Oe=[[0,0],[lt,yt]],it=Xo.translate(Ne.x,Ne.y).scale(Ke[2]),ve=Ct.constrain()(it,Oe,wt);Ct.transform(Ye,ve)},Ce=Gv().on("zoom",C?je:null).on("zoom.wheel",S?be:null);return he.call(Ce),()=>{he.on("zoom",null)}}},[C,S,T,D]);const se=w?he=>{const be=Hi(he);w(he,{x:be[0],y:be[1]})}:void 0,le=b?(he,be)=>{const je=P.getState().nodeInternals.get(be);b(he,je)}:void 0;return ye.createElement(Ud,{position:v,style:e,className:zr(["react-flow__minimap",t]),"data-testid":"rf__minimap"},ye.createElement("svg",{width:ue,height:de,viewBox:`${te} ${I} ${O} ${G}`,role:"img","aria-labelledby":$,ref:K,onClick:se},R&&ye.createElement("title",{id:$},R),ye.createElement(pC,{onClick:le,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:l,nodeClassName:a,nodeStrokeWidth:d,nodeComponent:u}),ye.createElement("path",{className:"react-flow__minimap-mask",d:`M${te-z},${I-z}h${O+z*2}v${G+z*2}h${-O-z*2}z
|
|
122
|
+
M${Z.x},${Z.y}h${Z.width}v${Z.height}h${-Z.width}z`,fill:m,fillRule:"evenodd",stroke:y,strokeWidth:g,pointerEvents:"none"})))}Iw.displayName="MiniMap";var xC=h.memo(Iw);function bC(){return ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ye.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function SC(){return ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ye.createElement("path",{d:"M0 0h32v4.2H0z"}))}function jC(){return ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ye.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 kC(){return ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ye.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 NC(){return ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ye.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 ou=({children:e,className:t,...n})=>ye.createElement("button",{type:"button",className:zr(["react-flow__controls-button",t]),...n},e);ou.displayName="ControlButton";const CC=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Dw=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:a,onZoomIn:l,onZoomOut:d,onFitView:u,onInteractiveChange:m,className:y,children:g,position:v="bottom-left"})=>{const w=gr(),[b,C]=h.useState(!1),{isInteractive:S,minZoomReached:R,maxZoomReached:T}=Rn(CC,Nr),{zoomIn:D,zoomOut:q,fitView:P}=yp();if(h.useEffect(()=>{C(!0)},[]),!b)return null;const K=()=>{D(),l==null||l()},Q=()=>{q(),d==null||d()},Z=()=>{P(a),u==null||u()},ee=()=>{w.setState({nodesDraggable:!S,nodesConnectable:!S,elementsSelectable:!S}),m==null||m(!S)};return ye.createElement(Ud,{className:zr(["react-flow__controls",y]),position:v,style:e,"data-testid":"rf__controls"},t&&ye.createElement(ye.Fragment,null,ye.createElement(ou,{onClick:K,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:T},ye.createElement(bC,null)),ye.createElement(ou,{onClick:Q,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:R},ye.createElement(SC,null))),n&&ye.createElement(ou,{className:"react-flow__controls-fitview",onClick:Z,title:"fit view","aria-label":"fit view"},ye.createElement(jC,null)),o&&ye.createElement(ou,{className:"react-flow__controls-interactive",onClick:ee,title:"toggle interactivity","aria-label":"toggle interactivity"},S?ye.createElement(NC,null):ye.createElement(kC,null)),g)};Dw.displayName="Controls";var EC=h.memo(Dw),qi;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(qi||(qi={}));function $C({color:e,dimensions:t,lineWidth:n}){return ye.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function MC({color:e,radius:t}){return ye.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const AC={[qi.Dots]:"#91919a",[qi.Lines]:"#eee",[qi.Cross]:"#e2e2e2"},TC={[qi.Dots]:1,[qi.Lines]:1,[qi.Cross]:6},RC=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Fw({id:e,variant:t=qi.Dots,gap:n=20,size:o,lineWidth:a=1,offset:l=2,color:d,style:u,className:m}){const y=h.useRef(null),{transform:g,patternId:v}=Rn(RC,Nr),w=d||AC[t],b=o||TC[t],C=t===qi.Dots,S=t===qi.Cross,R=Array.isArray(n)?n:[n,n],T=[R[0]*g[2]||1,R[1]*g[2]||1],D=b*g[2],q=S?[D,D]:T,P=C?[D/l,D/l]:[q[0]/l,q[1]/l];return ye.createElement("svg",{className:zr(["react-flow__background",m]),style:{...u,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:y,"data-testid":"rf__background"},ye.createElement("pattern",{id:v+e,x:g[0]%T[0],y:g[1]%T[1],width:T[0],height:T[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${P[0]},-${P[1]})`},C?ye.createElement(MC,{color:w,radius:D/l}):ye.createElement($C,{dimensions:q,color:w,lineWidth:a})),ye.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${v+e})`}))}Fw.displayName="Background";var LC=h.memo(Fw);function Bw(e,t={}){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:null;if(!n)return null;const o=typeof n.x=="number"&&Number.isFinite(n.x)?n.x:null,a=typeof n.y=="number"&&Number.isFinite(n.y)?n.y:null,l=typeof n.zoom=="number"&&Number.isFinite(n.zoom)?n.zoom:null;if(o===null||a===null||l===null)return null;const d=typeof t.maxAbsTranslate=="number"&&Number.isFinite(t.maxAbsTranslate)?Math.abs(t.maxAbsTranslate):1e6;if(Math.abs(o)>d||Math.abs(a)>d)return null;const u=typeof t.minZoom=="number"&&Number.isFinite(t.minZoom)?t.minZoom:.025,m=typeof t.maxZoom=="number"&&Number.isFinite(t.maxZoom)?t.maxZoom:6,y=Math.min(u,m),g=Math.max(u,m);return{x:o,y:a,zoom:Math.min(g,Math.max(y,l))}}function Wm(e){const t=String(e||"").trim();if(!t)return"";const n=t.indexOf(":");return n!==-1&&n<t.length-1?t.slice(n+1):t}function PC(e){const t=String(e||"").trim();if(!t)return"entity";const n=t.indexOf(":");if(n<=0||n>=t.length-1)return"entity";const o=t.slice(0,n).toLowerCase(),a=t.slice(n+1).toLowerCase();if(o==="ex"){const l=a.indexOf("-"),d=l>0?a.slice(0,l):a;return d==="person"?"person":d==="org"?"org":d==="concept"?"concept":d==="claim"?"claim":d==="event"?"event":d==="doc"?"doc":d==="thing"?"thing":"entity"}return o==="schema"||o==="skos"||o==="dcterms"||o==="rdf"||o==="cito"?"vocab":"entity"}function OC(e){const t=String(e||"").trim();if(!t)return"";const n=t.indexOf(":");if(n<=0||n>=t.length-1)return Wm(t);const o=t.slice(0,n).toLowerCase(),a=t.slice(n+1);if(o==="ex"){const l=a.indexOf("-");if(l>0&&l<a.length-1)return a.slice(l+1)}return Wm(t)}function H_(e){const o=Math.max(1,Math.ceil(Math.sqrt(e.length))),a={};for(let l=0;l<e.length;l++){const d=Math.floor(l/o),u=l%o;a[e[l]]={x:u*240,y:d*120}}return a}function W_(e){const t=String(e??"");let n=2166136261;for(let o=0;o<t.length;o++)n^=t.charCodeAt(o),n=Math.imul(n,16777619);return n>>>0}function Uw(e){let t=e>>>0;return()=>{t+=1831565813;let n=Math.imul(t^t>>>15,1|t);return n^=n+Math.imul(n^n>>>7,61|n),((n^n>>>14)>>>0)/4294967296}}function zC(e,t){const n={},o=e.length;if(!o)return n;const a=Math.max(260,Math.sqrt(o)*150),l=t%360*Math.PI/180;for(let d=0;d<o;d++){const u=l+2*Math.PI*d/o;n[e[d]]={x:a*Math.cos(u),y:a*Math.sin(u)}}return n}function oy(e,t,n){var C;const o={};if(!e.length)return o;const a=new Map;for(const S of e)a.set(S,new Set);for(const S of t){const R=String((S==null?void 0:S.source)||"").trim(),T=String((S==null?void 0:S.target)||"").trim();if(!R||!T||R===T)continue;const D=a.get(R),q=a.get(T);D&&D.add(T),q&&q.add(R)}let l=e[0],d=-1;for(const S of e){const R=((C=a.get(S))==null?void 0:C.size)??0;(R>d||R===d&&S.localeCompare(l)<0)&&(l=S,d=R)}const u=new Map,m=[];for(u.set(l,0),m.push(l);m.length;){const S=m.shift(),R=u.get(S)??0,T=Array.from(a.get(S)??[]);T.sort((D,q)=>D.localeCompare(q));for(const D of T)u.has(D)||(u.set(D,R+1),m.push(D))}let y=0;for(const S of u.values())y=Math.max(y,S);for(const S of e)u.has(S)||u.set(S,y+1);const g=new Map;for(const S of e){const R=u.get(S)??0,T=g.get(R);T?T.push(S):g.set(R,[S])}const v=Array.from(g.keys()).sort((S,R)=>S-R),w=260,b=n%360*Math.PI/180;for(const S of v){const R=g.get(S)||[];if(R.sort((P,K)=>P.localeCompare(K)),S===0){if(R.length===1)o[R[0]]={x:0,y:0};else for(let K=0;K<R.length;K++){const Q=b+2*Math.PI*K/R.length;o[R[K]]={x:80*Math.cos(Q),y:80*Math.sin(Q)}}continue}const T=w*S,D=R.length;if(D===1){o[R[0]]={x:T,y:0};continue}const q=b+S*.35;for(let P=0;P<D;P++){const K=q+2*Math.PI*P/D;o[R[P]]={x:T*Math.cos(K),y:T*Math.sin(K)}}}return o}function nu(e,t={}){const n=t.kind??"grid",o=typeof t.seed=="number"&&Number.isFinite(t.seed)?Math.trunc(t.seed):0,a=e.nodes.map(l=>l.id);if(n==="grid")return H_(a);if(n==="circle")return zC(a,o);if(n==="radial")return oy(a,e.edges,o);if(n==="force"){const l=oy(a,e.edges,o),d=Uw(o||1),u=Math.max(10,Math.min(42,Math.sqrt(a.length)*2.75)),m={};for(const y of a){const g=l[y]||{x:0,y:0};m[y]={x:g.x+(d()-.5)*u,y:g.y+(d()-.5)*u}}return m}return H_(a)}function IC(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 DC(e,t={}){const n=!!(t.groupEdges??!0),o=Math.max(1,t.maxEdgeLabelPredicates??3),a=IC(e),l=new Set;for(const w of a){const b=String(w.subject||"").trim(),C=String(w.object||"").trim();b&&l.add(b),C&&l.add(C)}const d=Array.from(l);d.sort((w,b)=>w.localeCompare(b));const u=H_(d),m=d.map(w=>({id:w,type:"default",data:{label:OC(w),kind:PC(w)},position:u[w]||{x:0,y:0}})),y=new Map,g=(w,b)=>{const C=String(w.subject||"").trim(),S=String(w.object||"").trim(),R=String(w.predicate||"").trim();return n?`edge:${C}:${S}`:`edge:${b}:${C}:${R}:${S}`};for(let w=0;w<a.length;w++){const b=a[w],C=g(b,w),S=y.get(C);S?S.push(b):y.set(C,[b])}const v=[];for(const[w,b]of y.entries()){const C=b[0],S=String(C.subject||"").trim(),R=String(C.object||"").trim();if(!S||!R)continue;const T=new Map;for(const Z of b){const ee=String(Z.predicate||"").trim();ee&&T.set(ee,(T.get(ee)||0)+1)}const D=Array.from(T.entries());D.sort((Z,ee)=>ee[1]-Z[1]||Z[0].localeCompare(ee[0]));const P=D.slice(0,o).map(([Z,ee])=>ee>1?`${Wm(Z)}×${ee}`:Wm(Z)).join(" | "),K=D.length>o?` +${D.length-o}`:"",Q=`${P}${K}`.trim();v.push({id:w,source:S,target:R,label:Q,animated:!1,data:{assertions:b,predicateSummary:Q}})}return{nodes:m,edges:v}}function FC(e,t,n,o={}){const a=o.directed!==!1,l=String(t||"").trim(),d=String(n||"").trim();if(!l||!d)return null;if(l===d)return{nodeIds:[l],edgeIds:[]};const u=new Map,m=(S,R,T)=>{const D=u.get(S);D?D.push({to:R,edgeId:T}):u.set(S,[{to:R,edgeId:T}])};for(const S of e.edges)m(S.source,S.target,S.id),a||m(S.target,S.source,S.id);const y=[l],g=new Map,v=new Map;for(g.set(l,null),v.set(l,null);y.length;){const S=y.shift(),R=u.get(S)||[];for(const T of R)if(!g.has(T.to)){if(g.set(T.to,S),v.set(T.to,T.edgeId),T.to===d){y.length=0;break}y.push(T.to)}}if(!g.has(d))return null;const w=[],b=[];let C=d;for(;C;){w.push(C);const S=v.get(C);S&&b.push(S),C=g.get(C)||null}return w.reverse(),b.reverse(),{nodeIds:w,edgeIds:b}}const ay={seed:1,dt:1,springLength:240,springStrength:.03,repulsionStrength:9e3,centeringStrength:.003,damping:.85,maxSpeed:90,maxRepulsionNodes:320};function pm(e,t={}){const n={...ay,...t,seed:typeof t.seed=="number"&&Number.isFinite(t.seed)?Math.trunc(t.seed):ay.seed},o=e.nodes.map(b=>b.id),a=o.length,l=new Float64Array(2*a),d=new Float64Array(2*a),u=new Float64Array(2*a),m=new Map;for(let b=0;b<a;b++)m.set(o[b],b);const y=t.positions??nu(e,{kind:"force",seed:n.seed}),g=Uw(n.seed||1),v=Math.max(8,Math.min(38,Math.sqrt(a)*2.25));for(let b=0;b<a;b++){const C=o[b],S=y[C],R=typeof(S==null?void 0:S.x)=="number"&&Number.isFinite(S.x)?S.x:(g()-.5)*500,T=typeof(S==null?void 0:S.y)=="number"&&Number.isFinite(S.y)?S.y:(g()-.5)*500;l[2*b]=R+(g()-.5)*v,l[2*b+1]=T+(g()-.5)*v,d[2*b]=0,d[2*b+1]=0}const w=[];for(const b of e.edges){const C=m.get(String((b==null?void 0:b.source)||"").trim()),S=m.get(String((b==null?void 0:b.target)||"").trim());typeof C!="number"||typeof S!="number"||C===S||w.push(C,S)}return{nodeIds:o,pos:l,vel:d,acc:u,edges:new Uint32Array(w),options:n,tick:0}}function BC(e,t=1){const n=e.nodeIds.length;if(!n)return;const o=e.options,a=o.dt;for(let l=0;l<Math.max(1,Math.trunc(t));l++){if(e.acc.fill(0),n<=o.maxRepulsionNodes){const b=o.repulsionStrength;for(let C=0;C<n;C++){const S=e.pos[2*C],R=e.pos[2*C+1];for(let T=C+1;T<n;T++){const D=e.pos[2*T]-S,q=e.pos[2*T+1]-R,P=D*D+q*q+1e-6,K=1/Math.sqrt(P),Q=b/P,Z=Q*D*K,ee=Q*q*K;e.acc[2*C]-=Z,e.acc[2*C+1]-=ee,e.acc[2*T]+=Z,e.acc[2*T+1]+=ee}}}const u=o.springLength,m=o.springStrength,y=e.edges;for(let b=0;b<y.length;b+=2){const C=y[b],S=y[b+1],R=e.pos[2*C],T=e.pos[2*C+1],D=e.pos[2*S],q=e.pos[2*S+1],P=D-R,K=q-T,Q=P*P+K*K+1e-6,Z=Math.sqrt(Q),ee=m*(Z-u),ue=ee*P/Z,de=ee*K/Z;e.acc[2*C]+=ue,e.acc[2*C+1]+=de,e.acc[2*S]-=ue,e.acc[2*S+1]-=de}const g=o.centeringStrength;for(let b=0;b<n;b++)e.acc[2*b]+=-g*e.pos[2*b],e.acc[2*b+1]+=-g*e.pos[2*b+1];const v=o.damping,w=o.maxSpeed;for(let b=0;b<n;b++){let C=(e.vel[2*b]+e.acc[2*b]*a)*v,S=(e.vel[2*b+1]+e.acc[2*b+1]*a)*v;const R=Math.sqrt(C*C+S*S);if(R>w){const T=w/R;C*=T,S*=T}e.vel[2*b]=C,e.vel[2*b+1]=S,e.pos[2*b]+=C*a,e.pos[2*b+1]+=S*a}e.tick+=1}}function UC(e){const t=e.nodeIds.length;if(!t)return 0;let n=0;for(let o=0;o<t;o++){const a=e.vel[2*o],l=e.vel[2*o+1];n+=Math.sqrt(a*a+l*l)}return n/t}function HC(e){const t={},n=e.nodeIds.length;for(let o=0;o<n;o++)t[e.nodeIds[o]]={x:e.pos[2*o],y:e.pos[2*o+1]};return t}function ly(e,t="session"){const n=String(e??"").trim().toLowerCase();return n==="run"||n==="session"||n==="global"||n==="all"?n:t}function WC(){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 qC(){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 Hw(e,t,n,o){const a=typeof e=="number"&&Number.isFinite(e)?e:o;return Math.min(n,Math.max(t,a))}function Nd(e){const t=Hw(e,.6,2.4,1),n=240*t,o=9e3*t*t;return{springLength:n,repulsionStrength:o}}const Gd="abstractuic_amx_saved_layouts_v1",q_=.025,V_=6,Ww=1e6;function xp(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function G_(e,t="grid"){const n=String(e??"").trim().toLowerCase();return n==="grid"||n==="circle"||n==="radial"||n==="force"?n:t}function VC(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:null;if(!t)return null;const n=typeof t.x=="number"&&Number.isFinite(t.x)?t.x:null,o=typeof t.y=="number"&&Number.isFinite(t.y)?t.y:null;return n===null||o===null?null:{x:n,y:o}}function cy(e){const t=xp();if(!t)return null;const n=String(e??"").trim();if(!n)return null;try{const o=t.getItem(Gd);if(!o)return null;const a=JSON.parse(o),l=a&&typeof a=="object"&&!Array.isArray(a)?a:null;if(!l)return null;const d=l[n],u=d&&typeof d=="object"&&!Array.isArray(d)?d:null;if(!u)return null;const m=u.version===1?1:null;if(m===null)return null;const y=G_(u.kind,"grid"),g=typeof u.seed=="number"&&Number.isFinite(u.seed)?Math.trunc(u.seed):W_(n),v=u.positions&&typeof u.positions=="object"&&!Array.isArray(u.positions)?u.positions:null,w={};if(v)for(const[S,R]of Object.entries(v)){const T=VC(R);T&&(w[String(S)]=T)}const b=Bw(u.viewport,{minZoom:q_,maxZoom:V_,maxAbsTranslate:Ww})??void 0,C=typeof u.saved_at=="string"&&u.saved_at.trim()?u.saved_at.trim():"";return{version:m,kind:y,seed:g,positions:w,viewport:b,saved_at:C}}catch{return null}}function GC(e,t){const n=xp();if(!n)return;const o=String(e??"").trim();if(o)try{const a=n.getItem(Gd),l=a?JSON.parse(a):null,d=l&&typeof l=="object"&&!Array.isArray(l)?{...l}:{};d[o]=t,n.setItem(Gd,JSON.stringify(d))}catch{}}function KC(e){const t=xp();if(!t)return;const n=String(e??"").trim();if(n)try{const o=t.getItem(Gd);if(!o)return;const a=JSON.parse(o),l=a&&typeof a=="object"&&!Array.isArray(a)?{...a}:null;if(!l||!(n in l))return;delete l[n],t.setItem(Gd,JSON.stringify(l))}catch{}}function YC(e){const t=String(e??"").trim();if(!t)return;const n=Number(t);if(Number.isFinite(n))return n}function s_(e,t){const n=!!(t!=null&&t.allowZero),o=!!(t!=null&&t.allowNegativeOne),a=String(e??"").trim();if(!a)return;const l=Number(a);if(!Number.isFinite(l))return;const d=Math.trunc(l);if(o&&d===-1)return-1;if(!(!n&&d<=0)&&!(n&&d<0))return d}function XC(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e,n=typeof t.recall_level=="string"?t.recall_level:"",o=t.applied&&typeof t.applied=="object"&&!Array.isArray(t.applied)?t.applied:null,a=[];return n&&a.push(`recall_level=${n}`),o&&(typeof o.limit=="number"&&a.push(`limit=${o.limit}`),typeof o.min_score=="number"&&a.push(`min_score=${o.min_score}`),typeof o.max_input_tokens=="number"&&a.push(`max_input_tokens=${o.max_input_tokens}`)),a.length?a.join(" · "):null}function JC(e){if(!e||typeof e!="object")return null;const t=[],n=typeof e.scope=="string"?e.scope.trim():"",o=typeof e.owner_id=="string"?e.owner_id.trim():"";n&&t.push(`scope=${n}`),o&&t.push(`owner_id=${o}`);const a=typeof e.confidence=="number"&&Number.isFinite(e.confidence)?e.confidence:null;a!==null&&t.push(`confidence=${a.toFixed(3)}`);const l=e.provenance&&typeof e.provenance=="object"&&!Array.isArray(e.provenance)?e.provenance:null;if(l){const y=typeof l.writer_run_id=="string"?l.writer_run_id.trim():"",g=typeof l.writer_workflow_id=="string"?l.writer_workflow_id.trim():"";y&&t.push(`writer_run_id=${y}`),g&&t.push(`writer_workflow_id=${g}`)}const d=e.attributes&&typeof e.attributes=="object"&&!Array.isArray(e.attributes)?e.attributes:null,u=d&&d._retrieval&&typeof d._retrieval=="object"&&!Array.isArray(d._retrieval)?d._retrieval:null,m=u&&typeof u.score=="number"&&Number.isFinite(u.score)?u.score:null;return m!==null&&t.push(`score=${m.toFixed(3)}`),t.length?t.join(" · "):null}function ZC(e,t){const n=String(e??""),o=String(t??"").trim();if(!o)return n;const a=n.toLowerCase().indexOf(o.toLowerCase());if(a<0)return n;const l=n.slice(0,a),d=n.slice(a,a+o.length),u=n.slice(a+o.length);return s.jsxs(s.Fragment,{children:[l,s.jsx("span",{className:"amx-hl",children:d}),u]})}function Cd(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 QC(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const n=t.replace(/(\.\d{3})\d+/,"$1"),o=Date.parse(n);return Number.isFinite(o)?o:null}function Ed(e){const t=QC(e);if(t===null)return"";const n=new Date(t),o=n.getUTCFullYear(),a=String(n.getUTCMonth()+1).padStart(2,"0"),l=String(n.getUTCDate()).padStart(2,"0"),d=String(n.getUTCHours()).padStart(2,"0"),u=String(n.getUTCMinutes()).padStart(2,"0");return`${o}/${a}/${l} ${d}:${u}`}function qw(e){const t=String(e??"").trim();if(!t)return"";const n=t.indexOf(":");return n!==-1&&n<t.length-1?t.slice(n+1):t}function i_(e,t){const n=String(e??"").trim().toLowerCase();return!!(n&&t.has(n))}function eE(e,t={}){const n=Math.max(1,t.maxPredicates??3),o=new Map;for(const m of e){const y=String((m==null?void 0:m.predicate)||"").trim();y&&o.set(y,(o.get(y)||0)+1)}const a=Array.from(o.entries());a.sort((m,y)=>y[1]-m[1]||m[0].localeCompare(y[0]));const d=a.slice(0,n).map(([m,y])=>{const g=qw(m);return y>1?`${g}×${y}`:g}).join(" | "),u=a.length>n?` +${a.length-n}`:"";return`${d}${u}`.trim()}function tE({resetKey:e,queryMode:t,items:n,activeMemoryText:o,packets:a,packetsVersion:l,packedCount:d,dropped:u,estimatedTokens:m,effort:y,warnings:g,onQuery:v,onItemsReplace:w,onOpenSpan:b,onOpenTranscript:C}){var ho;const S=h.useRef(null),R=h.useMemo(()=>{const B=n==null?void 0:n[0],ae=n==null?void 0:n[n.length-1],xe=B?`${B.subject}|${B.predicate}|${B.object}`:"",ke=ae?`${ae.subject}|${ae.predicate}|${ae.object}`:"";return`${(n==null?void 0:n.length)||0}:${xe}:${ke}`},[n]),T=String(e??R),D=t==="replace"?"replace":"override",[q,P]=h.useState(null),[K,Q]=h.useState(null),[Z,ee]=h.useState(!1),[ue,de]=h.useState(""),[pe,F]=h.useState(!1),[E,j]=h.useState("");h.useEffect(()=>{P(null),Q(null),de(""),ee(!1),j(""),F(!1)},[T]);const[L,z]=h.useState(""),[te,I]=h.useState(!0),[O,G]=h.useState(!1),[$,Y]=h.useState(!0),[se]=h.useState(()=>({compact:WC(),show:!1})),le=se.compact,[he,be]=h.useState(se.show),[je,Ce]=h.useState(!1),Fe=T,Ke=h.useMemo(()=>W_(Fe),[Fe]),[Ye,Ct]=h.useState("grid"),[wt,lt]=h.useState(Ke),[yt,rt]=h.useState(!1),[Ne,Oe]=h.useState(1),it=h.useRef(null),ve=h.useRef(null),Ie=h.useRef(!1),[Ge,Mt]=h.useState(0),Bt=h.useRef(null),dn=h.useRef(0),Ft=h.useRef(0),At=h.useRef(0),fn=h.useRef(0),[Kn,jt]=h.useState(!1),[mn,Hn]=h.useState(""),[Nn,yn]=h.useState({}),Cn=h.useRef({});h.useEffect(()=>{Cn.current=Nn},[Nn]);const[Jt,cr]=h.useState(""),[hn,Wn]=h.useState(""),vn=h.useMemo(()=>{var ae;const B=(ae=n==null?void 0:n[0])==null?void 0:ae.scope;return ly(B,"session")},[n]),[Ln,ne]=h.useState(vn),[ge,Te]=h.useState("standard"),[qe,He]=h.useState(""),[ot,pt]=h.useState(""),[vt,zt]=h.useState(""),[ct,It]=h.useState(""),[qt,ce]=h.useState(""),[kt,Lt]=h.useState(""),[Ve,en]=h.useState(""),[_n,ln]=h.useState("qwen/qwen3-next-80b");h.useEffect(()=>{ne(vn)},[T]);const pn=Array.isArray(n)?n:[],er=typeof o=="string"?o:"",Gr=Array.isArray(a)?a:[],Cr=typeof l=="number"?l:void 0,Kr=typeof d=="number"?d:void 0,Gs=typeof u=="number"?u:void 0,$s=typeof m=="number"?m:void 0,gi=y,Ks=g,Ir=D==="override"&&(q!=null&&q.items)&&Array.isArray(q.items)?q.items:pn,sn=typeof(q==null?void 0:q.active_memory_text)=="string"&&q.active_memory_text.trim()?q.active_memory_text:er,ea=(q==null?void 0:q.effort)??gi,Yr=(q==null?void 0:q.warnings)??Ks,Ms=h.useMemo(()=>new Set(["rdf:type","schema:name","skos:preflabel","skos:altlabel","dcterms:title","dcterms:identifier"]),[]),As=h.useMemo(()=>$?Ir:(Ir||[]).filter(B=>!i_(B==null?void 0:B.predicate,Ms)),[Ir,$,Ms]),Ys=h.useMemo(()=>DC(Ir,{groupEdges:te}),[Ir,te]),st=h.useMemo(()=>{if($)return Ys;const B=[];for(const ae of Ys.edges){const ke=(ae&&ae.data&&Array.isArray(ae.data.assertions)?ae.data.assertions:[]).filter(We=>!i_(We==null?void 0:We.predicate,Ms));if(!ke.length)continue;const Ee=eE(ke);B.push({...ae,label:Ee,data:{...ae.data,assertions:ke,predicateSummary:Ee}})}return{nodes:Ys.nodes,edges:B}},[Ys,$,Ms]),tn=h.useMemo(()=>st.nodes.map(B=>B.id),[st.nodes]),Er=h.useMemo(()=>{const B=tn[0]||"",ae=tn[tn.length-1]||"";return`${tn.length}:${B}:${ae}`},[tn]),yi=h.useMemo(()=>{var ae;const B=new Map;for(const xe of st.nodes)B.set(xe.id,String(((ae=xe.data)==null?void 0:ae.label)||xe.id));return B},[st.nodes]),yr=h.useMemo(()=>{var ae;const B=new Map;for(const xe of st.nodes)B.set(xe.id,String(((ae=xe.data)==null?void 0:ae.kind)||""));return B},[st.nodes]),ta=L.trim().toLowerCase(),el=h.useMemo(()=>{var ae;if(!ta)return new Set;const B=new Set;for(const xe of st.nodes){const ke=String(xe.id||"").toLowerCase(),Ee=String(((ae=xe.data)==null?void 0:ae.label)||"").toLowerCase();(ke.includes(ta)||Ee.includes(ta))&&B.add(xe.id)}return B},[st.nodes,ta]),tl=h.useCallback((B,ae)=>{const xe={};for(const ke of tn){const Ee=B[ke]||ae[ke];xe[ke]=Ee?{x:Ee.x,y:Ee.y}:{x:0,y:0}}return xe},[tn]);h.useEffect(()=>{yn(B=>{const ae=nu(st,{kind:Ye,seed:wt}),xe={};for(const ke of tn){const Ee=B[ke]||ae[ke];xe[ke]=Ee?{x:Ee.x,y:Ee.y}:{x:0,y:0}}return xe})},[st,Ye,wt,tn,Er]),h.useEffect(()=>{if(!Ie.current)return;const B=S.current;if(!(!B||typeof B.fitView!="function")&&tn.length){Ie.current=!1;try{B.fitView({padding:.2,duration:0})}catch{try{B.fitView({padding:.2})}catch{}}}},[tn.length,Er,Nn]),h.useEffect(()=>{rt(!1),it.current=null,ve.current=null,Ie.current=!1,dn.current=0,Ft.current=0,At.current=0;const B=cy(Fe);if(B&&Object.keys(B.positions||{}).length){if(Ct(B.kind),lt(B.seed),jt(!0),Hn(B.saved_at||""),B.viewport){ve.current=B.viewport;const Ee=S.current;if(Ee&&typeof Ee.setViewport=="function"){try{Ee.setViewport(B.viewport,{duration:0})}catch{try{Ee.setViewport(B.viewport)}catch{}}ve.current=null}}else Ie.current=!0;const ke=nu(st,{kind:B.kind,seed:B.seed});yn(tl(B.positions,ke));return}jt(!1),Hn("");const ae=W_(Fe);lt(ae);const xe=nu(st,{kind:Ye,seed:ae});yn(xe),Ye==="force"&&st.nodes.length>0&&st.nodes.length<=320&&(it.current=pm(st,{seed:ae,positions:xe,...Nd(Ne)}),rt(!0))},[Fe]);const qn=h.useMemo(()=>{const B=String(Jt||"").trim(),ae=String(hn||"").trim();return!B||!ae?null:FC(st,B,ae,{directed:O})},[st,Jt,hn,O]),as=!!(qn&&String(Jt||"").trim()&&String(hn||"").trim()),Yn=h.useMemo(()=>{const B=String(Jt||"").trim(),ae=String(hn||"").trim();if(!B||!ae)return null;const xe=O,ke=new Map,Ee=(nt,ut)=>{const Dt=ke.get(nt);Dt?Dt.push(ut):ke.set(nt,[ut])};for(const nt of st.edges)Ee(nt.source,nt.target),xe||Ee(nt.target,nt.source);const We=new Set,ft=[];for(We.add(B),ft.push(B);ft.length;){const nt=ft.shift(),ut=ke.get(nt)||[];for(const Dt of ut)We.has(Dt)||(We.add(Dt),ft.push(Dt))}return{reachableFromStart:We.size,endReachable:We.has(ae),nodes:st.nodes.length,edges:st.edges.length,assertions:As.length}},[O,st.edges,st.nodes.length,hn,Jt,As.length]),Xs=h.useMemo(()=>new Set((qn==null?void 0:qn.nodeIds)||[]),[qn]),na=h.useMemo(()=>new Set((qn==null?void 0:qn.edgeIds)||[]),[qn]),[zn,ls]=h.useState(""),[Xn,cs]=h.useState(""),Dn=!!(String(zn||"").trim()||String(Xn||"").trim()),us=h.useMemo(()=>{const B=new Set,ae=new Set,xe=String(zn||"").trim(),ke=String(Xn||"").trim();if(xe){B.add(xe);for(const Ee of st.edges)(Ee.source===xe||Ee.target===xe)&&(ae.add(Ee.id),B.add(Ee.source),B.add(Ee.target));return{nodes:B,edges:ae}}if(ke){const Ee=st.edges.find(We=>We.id===ke);Ee&&(ae.add(Ee.id),B.add(Ee.source),B.add(Ee.target))}return{nodes:B,edges:ae}},[st.edges,Xn,zn]);h.useEffect(()=>{ls(""),cs(""),cr(""),Wn("")},[T]);const[Js,Kt]=h.useState(!1);h.useEffect(()=>{Kt(!1)},[T]),h.useEffect(()=>{yt||(it.current=null)},[yt]),h.useEffect(()=>{if(Ye!=="force")return;const B=it.current;if(!B)return;const ae=Nd(Ne);B.options.springLength=ae.springLength,B.options.repulsionStrength=ae.repulsionStrength},[Ye,Ne]),h.useEffect(()=>{Ye!=="force"&&yt&&rt(!1)},[Ye,yt]),h.useEffect(()=>{if(!yt||Ye!=="force"||st.nodes.length===0||typeof window>"u"||typeof window.requestAnimationFrame!="function")return;it.current||(it.current=pm(st,{seed:wt,positions:Cn.current,...Nd(Ne)}));let B=0,ae=0,xe=0;const ke=st.nodes.length<=140?2:1,Ee=1600,We=.08,ft=nt=>{if(B=window.requestAnimationFrame(ft),nt-ae<33)return;ae=nt;const ut=it.current;if(!ut){rt(!1);return}BC(ut,ke),xe+=ke,yn(HC(ut)),(UC(ut)<=We||xe>=Ee)&&rt(!1)};return B=window.requestAnimationFrame(ft),()=>{window.cancelAnimationFrame(B)}},[st,Ye,yt,wt]);const uo=h.useMemo(()=>st.nodes.map(B=>{var Zt;const ae=Xs.has(B.id),xe=el.has(B.id),ke=zn===B.id,Ee=Dn&&us.nodes.has(B.id),We=Cd((Zt=B.data)==null?void 0:Zt.kind),ft="rgba(34, 211, 238, 0.88)",nt=xe?"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)":"",ut=ae?"rgba(168, 85, 247, 0.9)":xe?ft:We.stroke,Dt=ke?"0 0 0 2px rgba(255,255,255,0.20), 0 18px 46px rgba(0,0,0,0.55)":Ee?"0 0 0 1px rgba(96, 165, 250, 0.28), 0 12px 34px rgba(0,0,0,0.45)":void 0,Vt=nt&&Dt?`${nt}, ${Dt}`:Dt||nt||void 0,Yt=ae?"rgba(168, 85, 247, 0.10)":xe?"rgba(34, 211, 238, 0.08)":We.bg,Et=as?ae||ke?1:.16:Dn?Ee||ke?1:.1:1;return{...B,position:Nn[B.id]?{x:Nn[B.id].x,y:Nn[B.id].y}:B.position,style:{...B.style||{},border:`1px solid ${ut}`,borderRadius:10,background:Yt,color:"rgba(255,255,255,0.92)",opacity:Et,padding:8,fontSize:12,boxShadow:Vt,width:180,cursor:"pointer"}}}),[st.nodes,as,el,Nn,zn,Xs,Dn,us.nodes]),ra=h.useMemo(()=>st.edges.map(B=>{const ae=na.has(B.id),xe=Xn===B.id,ke=Dn&&us.edges.has(B.id),Ee=ae?"rgba(168, 85, 247, 0.9)":Dn?ke||xe?"rgba(96, 165, 250, 0.55)":"rgba(255,255,255,0.14)":"rgba(255,255,255,0.18)",We=ae?2.75:Dn?ke||xe?2.25:1.25:1.5,ft=xe?"drop-shadow(0 0 10px rgba(168, 85, 247, 0.25))":void 0,nt=ae?"rgba(168, 85, 247, 0.9)":as?"rgba(255,255,255,0.10)":"rgba(255,255,255,0.28)",ut=as?ae||xe?1:.1:Dn?ke||xe?1:.08:1,Dt=as?ae||xe?1:0:Dn?ke||xe?1:0:1,Vt=as?ae||xe?String(B.label||""):"":String(B.label||"");return{...B,label:Vt,style:{...B.style||{},stroke:Ee,strokeWidth:We,filter:ft,opacity:ut},animated:!1,markerEnd:{type:qd.ArrowClosed,color:nt,width:20,height:20},labelShowBg:!0,labelBgPadding:[6,3],labelBgBorderRadius:10,labelBgStyle:{fill:`rgba(0, 0, 0, ${.38*Dt})`,stroke:`rgba(255, 255, 255, ${.14*Dt})`,strokeWidth:1},labelStyle:{fill:`rgba(255, 255, 255, ${.92*Dt})`,fontSize:10,fontWeight:600,letterSpacing:.2,textTransform:"lowercase"}}}),[st.edges,as,Xn,na,Dn,us.edges]),sa=h.useMemo(()=>{if(!Xn)return[];const B=st.edges.find(xe=>xe.id===Xn),ae=B&&B.data&&Array.isArray(B.data.assertions)?B.data.assertions:[];return Array.isArray(ae)?ae:[]},[st.edges,Xn]),Dr=h.useMemo(()=>Xn&&st.edges.find(B=>B.id===Xn)||null,[st.edges,Xn]),nl=h.useMemo(()=>{const B=String(zn||"").trim();return B?Ir.filter(ae=>!ae||typeof ae!="object"||!(ae.subject===B||ae.object===B)?!1:$?!0:!i_(ae.predicate,Ms)):[]},[Ir,zn,$,Ms]),Zs=h.useMemo(()=>Xn?sa:nl,[sa,Xn,nl]),fo=h.useMemo(()=>{const B=new Map;for(const ae of Zs){if(!ae||typeof ae!="object")continue;const xe=ae.provenance&&typeof ae.provenance=="object"&&!Array.isArray(ae.provenance)?ae.provenance:null,ke=xe&&typeof xe.span_id=="string"?xe.span_id.trim():"",Ee=xe&&typeof xe.writer_run_id=="string"?xe.writer_run_id.trim():"",We=typeof ae.owner_id=="string"?ae.owner_id.trim():"",ft=Ee||We;if(!ft||!ke)continue;const nt=`${ft}|${ke}`,ut=B.get(nt),Dt=typeof ae.observed_at=="string"?ae.observed_at.trim():"";ut?(ut.count+=1,Dt&&(!ut.last_observed_at||Dt>ut.last_observed_at)&&(ut.last_observed_at=Dt,ut.last_observed_at_fmt=Ed(Dt),ut.assertion=ae)):B.set(nt,{span_run_id:ft,span_id:ke,writer_run_id:Ee,count:1,last_observed_at:Dt,last_observed_at_fmt:Ed(Dt),assertion:ae})}return Array.from(B.values()).sort((ae,xe)=>String(xe.last_observed_at||"").localeCompare(String(ae.last_observed_at||"")))},[Zs]),vi=h.useMemo(()=>{const B=new Map;for(const ae of Zs){if(!ae||typeof ae!="object")continue;const xe=ae.provenance&&typeof ae.provenance=="object"&&!Array.isArray(ae.provenance)?ae.provenance:null,ke=xe&&typeof xe.span_id=="string"?xe.span_id.trim():"",Ee=xe&&typeof xe.writer_run_id=="string"?xe.writer_run_id.trim():"";if(!Ee||ke)continue;const We=B.get(Ee),ft=typeof ae.observed_at=="string"?ae.observed_at.trim():"";We?(We.count+=1,ft&&(!We.last_observed_at||ft>We.last_observed_at)&&(We.last_observed_at=ft,We.last_observed_at_fmt=Ed(ft),We.assertion=ae)):B.set(Ee,{run_id:Ee,count:1,last_observed_at:ft,last_observed_at_fmt:Ed(ft),assertion:ae})}return Array.from(B.values()).sort((ae,xe)=>String(xe.last_observed_at||"").localeCompare(String(ae.last_observed_at||"")))},[Zs]),tr=h.useCallback(B=>{const ae=String(B.run_id||"").trim(),xe=typeof B.span_id=="string"?String(B.span_id).trim():"";if(ae){if(C){try{C({run_id:ae,span_id:xe||void 0,assertion:B.assertion})}catch{}return}if(b&&xe)try{b({run_id:ae,span_id:xe,assertion:B.assertion})}catch{}}},[b,C]),nr=h.useCallback(async B=>{const ae=String(B??"");if(ae)try{await navigator.clipboard.writeText(ae)}catch{}},[]),$r=h.useCallback(()=>{const B=S.current;if(!(!B||typeof B.fitView!="function")){if(zn&&typeof B.getNode=="function"){const ae=B.getNode(zn);if(ae){B.fitView({nodes:[ae],padding:.55,duration:350});return}}B.fitView({padding:.2,duration:350})}},[zn]),wi=h.useCallback(B=>{const ae=B.kind,xe=Math.trunc(B.seed);rt(!1),it.current=null,ve.current=null,Ct(ae),lt(xe);const ke=nu(st,{kind:ae,seed:xe});yn(ke),ae==="force"&&(B.autoPlay??!0)&&st.nodes.length>0&&st.nodes.length<=320&&(it.current=pm(st,{seed:xe,positions:ke,...Nd(Ne)}),rt(!0))},[st,Ne]),ds=h.useCallback(()=>{if(Ye==="force"){if(yt){rt(!1);return}it.current=pm(st,{seed:wt,positions:Cn.current,...Nd(Ne)}),rt(!0)}},[st,Ye,yt,wt,Ne]);h.useEffect(()=>()=>{typeof window>"u"||typeof window.cancelAnimationFrame=="function"&&fn.current&&window.cancelAnimationFrame(fn.current)},[]);const Fr=h.useCallback(()=>{const B=S.current;if(!B||typeof B.getViewport!="function"||!tn.length)return null;const ae=Bt.current;if(!ae)return null;const xe=ae.getBoundingClientRect();if(!Number.isFinite(xe.width)||!Number.isFinite(xe.height)||xe.width<64||xe.height<64)return null;const ke=B.getViewport(),Ee=typeof(ke==null?void 0:ke.zoom)=="number"&&Number.isFinite(ke.zoom)?ke.zoom:null,We=typeof(ke==null?void 0:ke.x)=="number"&&Number.isFinite(ke.x)?ke.x:null,ft=typeof(ke==null?void 0:ke.y)=="number"&&Number.isFinite(ke.y)?ke.y:null;if(Ee===null||We===null||ft===null||Ee<=0)return null;const nt=140,ut=Math.min(tn.length,180),Dt=Cn.current;let Vt=0,Yt=0;for(const Et of tn){const Zt=Dt[Et];if(!Zt||!Number.isFinite(Zt.x)||!Number.isFinite(Zt.y))continue;Yt+=1;const En=[{x:Zt.x,y:Zt.y},{x:Zt.x+90,y:Zt.y+24}];for(const cn of En){const Br=cn.x*Ee+We,Jn=cn.y*Ee+ft;if(Br>-nt&&Br<xe.width+nt&&Jn>-nt&&Jn<xe.height+nt)return!1}if(Vt++,Vt>=ut)break}return Yt?!0:null},[tn]),fs=h.useCallback(B=>{typeof window>"u"||typeof window.requestAnimationFrame!="function"||fn.current||(fn.current=window.requestAnimationFrame(()=>{fn.current=0;const ae=Fr();if(ae===null){if(At.current>=12)return;At.current+=1,window.setTimeout(()=>fs(`${B}:probe`),120);return}if(ae!==!0){At.current=0,Ft.current=0;return}At.current=0;const xe=S.current;if(xe&&typeof xe.fitView=="function")try{xe.fitView({padding:.2,duration:0})}catch{try{xe.fitView({padding:.2})}catch{}}if(Ft.current+=1,Ft.current>=4&&dn.current<1){Ft.current=0,dn.current+=1,Mt(ke=>ke+1);return}Ft.current<8&&window.setTimeout(()=>fs(`${B}:retry`),220)}))},[Fr]);h.useEffect(()=>{Ft.current=0,dn.current=0,At.current=0,fs("mount")},[T,fs]),h.useEffect(()=>{fs("graph change")},[Er,fs]),h.useEffect(()=>{const B=Bt.current;if(!B||typeof window>"u"||typeof ResizeObserver!="function")return;const ae=new ResizeObserver(()=>fs("resize"));return ae.observe(B),()=>ae.disconnect()},[fs]);const rl=h.useCallback(()=>{const B=new Date().toISOString(),ae={};for(const ft of tn){const nt=Cn.current[ft];nt&&typeof nt.x=="number"&&typeof nt.y=="number"&&(ae[ft]={x:nt.x,y:nt.y})}const xe=S.current,ke=xe&&typeof xe.toObject=="function"?xe.toObject():null,Ee=ke&&ke.viewport?ke.viewport:xe&&typeof xe.getViewport=="function"?xe.getViewport():null,We=Bw(Ee,{minZoom:q_,maxZoom:V_,maxAbsTranslate:Ww})??void 0;GC(Fe,{version:1,kind:Ye,seed:wt,positions:ae,viewport:We,saved_at:B}),jt(!0),Hn(B),rt(!1)},[Fe,Ye,wt,tn]),ms=h.useCallback(()=>{const B=cy(Fe);if(!B)return;rt(!1),it.current=null,Ct(B.kind),lt(B.seed),jt(!0),Hn(B.saved_at||""),ve.current=B.viewport||null,Ie.current=!B.viewport;const ae=nu(st,{kind:B.kind,seed:B.seed});if(yn(tl(B.positions,ae)),B.viewport){const xe=S.current;if(xe&&typeof xe.setViewport=="function"){try{xe.setViewport(B.viewport,{duration:0})}catch{try{xe.setViewport(B.viewport)}catch{}}ve.current=null}}},[tl,st,Fe]),oc=h.useCallback(()=>{KC(Fe),jt(!1),Hn("")},[Fe]),Qs=h.useCallback(B=>{if(!Array.isArray(B)||B.length===0)return;let ae=!1;yn(xe=>{let ke=xe,Ee=!1;for(const We of B){const ft=We&&typeof We=="object"&&"id"in We&&typeof We.id=="string"?String(We.id):"",nt=(We==null?void 0:We.type)==="position"?We==null?void 0:We.position:null;ft&&nt&&typeof nt.x=="number"&&typeof nt.y=="number"&&(Ee||(ke={...xe},Ee=!0),ke[ft]={x:nt.x,y:nt.y},We!=null&&We.dragging&&(ae=!0))}return Ee?ke:xe}),ae&&yt&&rt(!1)},[yt]),Ki=h.useMemo(()=>{const B=new Map;for(const ae of st.edges)B.set(ae.id,ae);return B},[st.edges]),ia=h.useMemo(()=>{var ke;if(!qn)return[];const B=qn.nodeIds||[],ae=qn.edgeIds||[],xe=[];for(let Ee=0;Ee<Math.min(B.length-1,ae.length);Ee++){const We=B[Ee],ft=B[Ee+1],nt=ae[Ee],ut=Ki.get(nt),Dt=String(((ke=ut==null?void 0:ut.data)==null?void 0:ke.predicateSummary)||(ut==null?void 0:ut.label)||"").trim(),Vt=ut&&ut.source===We&&ut.target===ft?"forward":ut&&ut.source===ft&&ut.target===We?"reverse":"unknown";xe.push({from:We,to:ft,edgeId:nt,predicate:Dt,dir:Vt})}return xe},[Ki,qn]),xi=h.useCallback(async()=>{if(v){de(""),j(""),ee(!0);try{const B=YC(qt),ae=s_(kt,{allowZero:!0,allowNegativeOne:!0}),xe=s_(Ve,{allowZero:!0}),ke=await v({scope:Ln,owner_id:void 0,recall_level:ge,query_text:qe||void 0,subject:ot||void 0,predicate:vt||void 0,object:ct||void 0,min_score:B,limit:ae,max_input_tokens:xe,model:_n||void 0});P(ke),Q("live query"),D==="replace"&&w&&ke&&Array.isArray(ke.items)&&w(ke.items,{kind:"live query",result:ke})}catch(B){const ae=B instanceof Error?B.message:String(B);de(ae||"Query failed")}finally{ee(!1)}}},[kt,Ve,qt,_n,ct,w,v,vt,D,qe,ge,Ln,ot]),hs=h.useCallback(async()=>{if(!v)return;const B=String(Jt||"").trim(),ae=String(hn||"").trim();if(!B||!ae)return;const xe=Math.max(200,s_(kt)??80),ke=60;j(""),de(""),F(!0);try{const Ee=[],We=new Set,ft=Et=>{if(!Et||typeof Et!="object"||typeof Et.subject!="string"||typeof Et.predicate!="string"||typeof Et.object!="string")return;const Zt=`${Et.subject}|${Et.predicate}|${Et.object}|${String(Et.observed_at||"")}|${String(Et.scope||"")}|${String(Et.owner_id||"")}`;We.has(Zt)||(We.add(Zt),Ee.push(Et))};for(const Et of Ir)ft(Et);const nt=O,ut=new Set,Dt=[B],Vt=new Set([B]),Yt=async Et=>{const Zt=await v({scope:Ln,recall_level:ge,min_score:0,limit:xe,subject:Et,query_text:void 0,max_input_tokens:0,model:void 0});if(Zt&&Array.isArray(Zt.items)){for(const En of Zt.items)if(ft(En),typeof En.subject=="string"&&En.subject.trim()===Et&&typeof En.object=="string"){const cn=En.object.trim();cn&&!Vt.has(cn)&&(Vt.add(cn),Dt.push(cn))}}if(!nt){const En=await v({scope:Ln,recall_level:ge,min_score:0,limit:xe,object:Et,query_text:void 0,max_input_tokens:0,model:void 0});if(En&&Array.isArray(En.items)){for(const cn of En.items)if(ft(cn),typeof cn.object=="string"&&cn.object.trim()===Et&&typeof cn.subject=="string"){const Br=cn.subject.trim();Br&&!Vt.has(Br)&&(Vt.add(Br),Dt.push(Br))}}}};for(;Dt.length&&ut.size<ke&&!Vt.has(ae);){const Et=Dt.shift();!Et||ut.has(Et)||(ut.add(Et),await Yt(Et))}P({ok:!0,count:Ee.length,items:Ee,active_memory_text:sn,raw:{expanded_for_path:!0,expanded_nodes:ut.size,discovered_nodes:Vt.size,merged:Ee.length,directed:nt}}),Q("expanded neighborhood"),D==="replace"&&w&&w(Ee,{kind:"expanded neighborhood",result:{ok:!0,count:Ee.length,items:Ee,active_memory_text:sn,raw:{expanded_for_path:!0,expanded_nodes:ut.size,discovered_nodes:Vt.size,merged:Ee.length,directed:nt}}})}catch(Ee){const We=Ee instanceof Error?Ee.message:String(Ee);j(We||"Expand neighborhood failed")}finally{F(!1)}},[O,sn,Ir,kt,w,v,hn,Jt,D,ge,Ln]),mo=h.useCallback(()=>{P(null),Q(null),de(""),ee(!1),j(""),F(!1),cr(""),Wn(""),ls(""),cs("")},[]),ei="Search KG",vr=st.nodes.length,wu=st.edges.length,Ts=As.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:Ye,onChange:B=>Ct(G_(B.target.value,Ye)),disabled:!tn.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)"})]}),Ye==="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:Ne,onChange:B=>Oe(Hw(Number(B.target.value),.7,2.2,1))}),s.jsxs("span",{className:"amx-small",children:[Ne.toFixed(1),"×"]})]}):null,s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>wi({kind:Ye,seed:wt}),disabled:!tn.length,children:"Apply"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:ds,disabled:!tn.length||Ye!=="force",children:yt?"Pause simulation":"Play simulation"})]})}),s.jsxs("div",{className:"amx-graph","aria-label":"Knowledge graph",ref:Bt,children:[s.jsx(wp,{children:s.jsxs(Ow,{nodes:uo,edges:ra,defaultViewport:{x:0,y:0,zoom:1},minZoom:q_,maxZoom:V_,onInit:B=>{S.current=B;const ae=ve.current;if(ae&&typeof B.setViewport=="function")try{B.setViewport(ae,{duration:0})}catch{try{B.setViewport(ae)}catch{}}if(Ie.current&&typeof B.fitView=="function")try{B.fitView({padding:.2,duration:0})}catch{try{B.fitView({padding:.2})}catch{}}ve.current=null,Ie.current=!1,fs("init")},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,onNodesChange:Qs,onNodeClick:(B,ae)=>{cs(""),ls(ae.id)},onEdgeClick:(B,ae)=>{ls(""),cs(ae.id)},onPaneClick:()=>{ls(""),cs("")},children:[s.jsx(EC,{className:"amx-flow-controls",children:s.jsx(ou,{type:"button",className:`amx-control-legend ${je?"amx-control-legend-active":""}`,onClick:()=>Ce(B=>!B),title:je?"Hide node color legend":"Show node color legend","aria-label":je?"Hide node color legend":"Show node color legend",children:s.jsx(qC,{})})}),s.jsx(Ud,{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:()=>be(B=>!B),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(xC,{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:le?120:160,height:le?80:110,marginBottom:56},nodeColor:B=>{var ae;return Cd((ae=B.data)==null?void 0:ae.kind).minimap}}):null,je?s.jsxs(Ud,{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:B,label:ae})=>s.jsx("span",{className:"amx-legend-item",style:{borderColor:Cd(B).stroke},children:ae},B))})]}):null,s.jsx(LC,{gap:20,size:1,color:"rgba(255,255,255,0.06)"})]})},Ge),s.jsxs("details",{className:"amx-panel amx-controls",children:[s.jsxs("summary",{children:[s.jsx("span",{className:"amx-controls-title",children:ei}),s.jsxs("span",{className:"amx-small",children:[Ts," assertions · ",vr," nodes · ",wu," 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:L,onChange:B=>z(B.target.value),placeholder:"filter nodes by id/label"})]}),s.jsxs("label",{children:["group edges",s.jsxs("select",{value:String(te),onChange:B=>I(B.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($),onChange:B=>Y(B.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(O),onChange:B=>G(B.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:Ye,onChange:B=>Ct(G_(B.target.value,Ye)),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:wt,onChange:B=>lt(Math.trunc(Number(B.target.value||0)||0))})]})]}),s.jsxs("div",{className:"amx-actions",style:{marginTop:10},children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>wi({kind:Ye,seed:wt}),disabled:!tn.length,children:"Apply layout"}),Ye==="force"?s.jsx("button",{type:"button",className:"amx-btn",onClick:ds,disabled:!tn.length,children:yt?"Pause simulation":"Play simulation"}):null,s.jsx("button",{type:"button",className:"amx-btn",onClick:rl,disabled:!tn.length,children:"Save layout"}),Kn?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:ms,children:"Load saved"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:oc,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.",Kn?s.jsxs("span",{children:[" ","(saved",mn?`: ${mn}`:"",")"]}):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:Jt,onChange:B=>cr(B.target.value),children:[s.jsx("option",{value:"",children:"(none)"}),tn.map(B=>s.jsx("option",{value:B,children:(()=>{const ae=yi.get(B)||B;return ae===B?ae:`${ae} (${B})`})()},B))]})]}),s.jsxs("label",{children:["path end",s.jsxs("select",{value:hn,onChange:B=>Wn(B.target.value),children:[s.jsx("option",{value:"",children:"(none)"}),tn.map(B=>s.jsx("option",{value:B,children:(()=>{const ae=yi.get(B)||B;return ae===B?ae:`${ae} (${B})`})()},B))]})]})]}),qn?s.jsx("div",{className:"amx-small",style:{marginTop:10},children:ia.map((B,ae)=>{const xe=yi.get(B.from)||B.from,ke=yi.get(B.to)||B.to,Ee=B.dir==="reverse"?" ← ":" → ",We=B.predicate?` (${B.predicate})`:"";return s.jsxs("div",{children:[ae===0?s.jsx("span",{children:xe}):null,Ee,s.jsxs("span",{children:[ke,We]})]},`${B.edgeId}:${ae}`)})}):Jt&&hn?s.jsxs("div",{className:"amx-small",style:{marginTop:10,opacity:.9},children:["No path found in the current subgraph (",(Yn==null?void 0:Yn.assertions)??Ts," assertions · ",(Yn==null?void 0:Yn.nodes)??st.nodes.length," nodes ·"," ",(Yn==null?void 0:Yn.edges)??st.edges.length," edges). Start reaches ",(Yn==null?void 0:Yn.reachableFromStart)??0," nodes.",v?s.jsx("div",{style:{marginTop:10},children:s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void hs(),disabled:pe,children:pe?"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:qe,onChange:B=>He(B.target.value),placeholder:"e.g. emotion chip"})]}),s.jsxs("label",{children:["subject (exact)",s.jsx("input",{value:ot,onChange:B=>pt(B.target.value),placeholder:"e.g. ex:person-data"})]}),s.jsxs("label",{children:["predicate (exact)",s.jsx("input",{value:vt,onChange:B=>zt(B.target.value),placeholder:"e.g. schema:about"})]}),s.jsxs("label",{children:["object (exact)",s.jsx("input",{value:ct,onChange:B=>It(B.target.value),placeholder:"e.g. ex:concept-emotion-chip"})]}),s.jsxs("label",{children:["min_score",s.jsx("input",{type:"number",step:"any",value:qt,onChange:B=>ce(B.target.value),placeholder:"(auto)"})]}),s.jsxs("label",{children:["limit",s.jsx("input",{type:"number",min:"-1",step:"1",value:kt,onChange:B=>Lt(B.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:Ln,onChange:B=>ne(ly(B.target.value,Ln)),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:ge,onChange:B=>Te(B.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:Ve,onChange:B=>en(B.target.value),placeholder:"(auto)"})]}),s.jsxs("label",{children:["model (budgeting)",s.jsx("input",{value:_n,onChange:B=>ln(B.target.value),placeholder:"qwen/qwen3-next-80b"})]})]})]}),s.jsxs("div",{className:"amx-actions",children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void xi(),disabled:!v||Z,children:Z?"Querying…":"Query store"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:mo,disabled:!q&&!ue&&!Z,children:"Reset to step output"}),q?s.jsxs("span",{className:"amx-small",children:["showing: ",K||"live query"]}):s.jsx("span",{className:"amx-small",children:"showing: step output"}),ue?s.jsx("span",{className:"amx-small",style:{color:"var(--error, rgba(255, 80, 80, 0.95))"},children:ue}):null,E?s.jsx("span",{className:"amx-small",style:{color:"var(--error, rgba(255, 80, 80, 0.95))"},children:E}):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 B=XC(ea);return B?s.jsx("div",{className:"amx-small",style:{marginBottom:8,opacity:.9},children:B}):null})(),(()=>{const B=Yr;if(!B)return null;const ae=typeof B=="string"?B:Array.isArray(B)?B.map(xe=>String(xe)).join(" · "):JSON.stringify(B);return!ae||!ae.trim()?null:s.jsx("div",{className:"amx-small",style:{marginBottom:8,color:"var(--warning, rgba(255, 180, 90, 0.95))"},children:ae})})(),s.jsx("div",{className:"amx-small",style:{marginBottom:8,opacity:.9},children:(()=>{const B=(q==null?void 0:q.packets_version)??Cr,ae=(q==null?void 0:q.packed_count)??Kr,xe=(q==null?void 0:q.dropped)??Gs,ke=(q==null?void 0:q.estimated_tokens)??$s,Ee=[];return typeof B=="number"&&Ee.push(`packets_v${B}`),typeof ae=="number"&&Ee.push(`packed=${ae}`),typeof xe=="number"&&Ee.push(`dropped=${xe}`),typeof ke=="number"&&Ee.push(`est_tokens=${ke}`),Ee.length?Ee.join(" · "):"No packetization stats (set max_input_tokens > 0)."})()}),s.jsx("div",{className:"amx-active-memory",children:ZC(sn||"(empty)",L)}),(()=>{const B=q!=null&&q.packets&&Array.isArray(q.packets)?q.packets:Gr;return!Array.isArray(B)||B.length===0?null:s.jsxs("div",{style:{marginTop:10},children:[s.jsxs("button",{type:"button",className:"amx-btn",onClick:()=>Kt(ae=>!ae),children:[Js?"Hide":"Show"," packets (",B.length,")"]}),Js?s.jsx("div",{className:"amx-list",style:{marginTop:10},children:B.slice(0,120).map((ae,xe)=>{const ke=ae&&typeof ae=="object"&&!Array.isArray(ae)?ae:null,Ee=ke&&typeof ke.statement=="string"?ke.statement:typeof ae=="string"?ae:"",We=ke&&(typeof ke.retrieval_score=="number"||typeof ke.retrieval_score=="string")?ke.retrieval_score:null,ft=ke&&typeof ke.observed_at=="string"?ke.observed_at:null;return s.jsxs("div",{className:"amx-item",children:[s.jsx("div",{className:"amx-mono",children:Ee||"(packet)"}),ft||We!==null?s.jsxs("div",{className:"amx-small",children:[ft?`[${ft}]`:null,ft&&We!==null?" ":null,We!==null?`score:${We}`:null]}):null]},xe)})}):null]})})(),s.jsx("div",{style:{marginTop:14,marginBottom:12,borderTop:"1px solid var(--ui-border-1, 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."}),zn?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:yi.get(zn)||zn}),s.jsxs("div",{className:"amx-small",children:["kind=",yr.get(zn)||"entity"," · id=",zn]})]}),s.jsxs("div",{className:"amx-actions",children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void nr(zn),children:"Copy id"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:$r,children:"Focus"})]})]}):Dr&&Dr.source&&Dr.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:[Dr.source," —",String(Dr.label||((ho=Dr.data)==null?void 0:ho.predicateSummary)||"").trim()||"?","→ ",Dr.target]}),s.jsxs("div",{className:"amx-small",children:["edge_id=",Dr.id]})]}),s.jsxs("div",{className:"amx-actions",children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void nr(Dr.id),children:"Copy id"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:$r,children:"Fit"})]})]}):s.jsx("div",{className:"amx-small",style:{marginBottom:10,opacity:.9},children:"(no selection)"}),s.jsx("div",{className:"amx-list",children:Zs.slice(0,80).map((B,ae)=>{const xe=String(B.subject||"").trim(),ke=String(B.predicate||"").trim(),Ee=String(B.object||"").trim(),We=yi.get(xe)||xe,ft=yi.get(Ee)||Ee,nt=yr.get(xe)||"entity",ut=yr.get(Ee)||"entity",Dt=Cd(nt),Vt=Cd(ut),Yt=Ed(B.observed_at),Et=JC(B),Zt=B.provenance&&typeof B.provenance=="object"&&!Array.isArray(B.provenance)?B.provenance:null,En=Zt&&typeof Zt.span_id=="string"?Zt.span_id.trim():"",cn=Zt&&typeof Zt.writer_run_id=="string"?Zt.writer_run_id.trim():"",Br=typeof B.owner_id=="string"?B.owner_id.trim():"",Jn=cn||Br,bi=!!((C||b)&&En&&Jn),Si=!!(C&&cn&&!En),_o=bi||Si;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:Dt.stroke,background:Dt.bg},title:xe,onClick:()=>{xe&&(cs(""),ls(xe))},children:We||xe||"(subject)"}),s.jsx("span",{className:"amx-arrow",children:"—"}),s.jsx("span",{className:"amx-predicate",title:ke,children:qw(ke)||"(predicate)"}),s.jsx("span",{className:"amx-arrow",children:"→"}),s.jsx("button",{type:"button",className:"amx-term",style:{borderColor:Vt.stroke,background:Vt.bg},title:Ee,onClick:()=>{Ee&&(cs(""),ls(Ee))},children:ft||Ee||"(object)"})]}),s.jsxs("div",{className:"amx-triple-meta",children:[Yt?s.jsxs("span",{className:"amx-small",title:String(B.observed_at||""),children:["[",Yt,"]"]}):null,Et?s.jsx("span",{className:"amx-small",children:Et}):null]}),En||cn?s.jsxs("div",{className:"amx-triple-actions",children:[En?s.jsxs("span",{className:"amx-small",children:["span:",En]}):null,cn?s.jsxs("span",{className:"amx-small",children:["run:",cn]}):null,_o?s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>{if(bi&&En&&Jn){tr({run_id:Jn,span_id:En,assertion:B});return}Si&&cn&&tr({run_id:cn,assertion:B})},children:"Open transcript"}):null]}):null]},ae)})})]}),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)."}),fo.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:fo.slice(0,60).map(B=>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:",B.span_id]}),s.jsxs("div",{className:"amx-small",children:["run_id=",B.span_run_id," · assertions=",B.count,B.last_observed_at_fmt?` · last=[${B.last_observed_at_fmt}]`:""]})]}),b||C?s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>tr({run_id:B.span_run_id,span_id:B.span_id,assertion:B.assertion}),children:"Open transcript"}):null]},`${B.span_run_id}|${B.span_id}`))})]}):null,C&&vi.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:vi.slice(0,40).map(B=>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:",B.run_id]}),s.jsxs("div",{className:"amx-small",children:["assertions=",B.count,B.last_observed_at_fmt?` · last=[${B.last_observed_at_fmt}]`:""]})]}),s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>tr({run_id:B.run_id,assertion:B.assertion}),children:"Open transcript"})]},B.run_id))})]}):null,!fo.length&&!(C&&vi.length)?s.jsx("div",{className:"amx-small",children:"(no provenance)"}):null]})]})]})}function Ka({open:e,title:t,children:n,actions:o,variant:a="default",onClose:l}){if(h.useEffect(()=>{if(!e)return;const u=m=>{m.key==="Escape"&&l()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,l]),!e)return null;const d=a==="fullscreen";return s.jsx("div",{className:`modal_backdrop${d?" fullscreen":""}`,onMouseDown:u=>{u.target===u.currentTarget&&l()},children:s.jsxs("div",{className:`modal_panel${d?" fullscreen":""}`,children:[s.jsxs("div",{className:"modal_header",children:[s.jsx("div",{className:"modal_title",children:t}),s.jsx("button",{className:"btn",onClick:l,children:"Close"})]}),s.jsx("div",{className:"modal_body",children:n}),o?s.jsx("div",{className:"modal_footer",children:o}):null]})})}function o_(e,t="session"){const n=String(e||"").trim().toLowerCase();return n==="run"||n==="session"||n==="global"||n==="all"?n:t}function Wa(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const n=t.replace(/(\.\d{3})\d+/,"$1"),o=Date.parse(n);return Number.isFinite(o)?o:null}function Gl(e){if(typeof e!="number"||!Number.isFinite(e))return"—";const t=new Date(e),n=t.getUTCFullYear(),o=String(t.getUTCMonth()+1).padStart(2,"0"),a=String(t.getUTCDate()).padStart(2,"0"),l=String(t.getUTCHours()).padStart(2,"0"),d=String(t.getUTCMinutes()).padStart(2,"0");return`${n}/${o}/${a} ${l}:${d}`}function nE(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 n=Wa(t);return n!==null?Gl(n):t}function bp(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,`
|
|
123
|
+
`).replace(/\\n/g,`
|
|
124
|
+
`).replace(/\\t/g," "):""}function Vw(e){return String(e??"").replace(/[*_`~]/g,"")}function gm(e,t){const n=!!(t!=null&&t.strip_punct),o=bp(e);let a=Vw(o).replace(/\s+/g," ").trim().toLowerCase();return n&&(a=a.replace(/[^\p{L}\p{N}\s]+/gu,"").replace(/\s+/g," ").trim()),a}function ym(e,t){const n=String(t??"").trim();if(!n)return!1;const o=gm(n,{strip_punct:!1});if(!o)return!1;if(gm(String(e??""),{strip_punct:!1}).includes(o))return!0;const l=gm(n,{strip_punct:!0});return l?gm(String(e??""),{strip_punct:!0}).includes(l):!1}function uy(e){const t=bp(e).trim();if(!t)return[];const n=[],o=d=>{const u=String(d??"").replace(/\s+/g," ").trim();u&&(u.length<6||n.includes(u)||n.push(u))},a=t.search(/[`*_~]/);if(a>0){const d=t.slice(0,a);d.replace(/\s+/g," ").trim().length>=10&&o(d)}const l=[/`([^`]+)`/g,/\*\*([^*]+)\*\*/g,/__([^_]+)__/g,/\*([^*]+)\*/g,/_([^_]+)_/g];for(const d of l){let u;for(;(u=d.exec(t))!==null;){const m=String(u[1]??"").trim();m&&o(m)}}return o(Vw(t)),n}function rE(e){const t=String(e??"").replace(/\r\n/g,`
|
|
125
|
+
`).replace(/\r/g,`
|
|
126
|
+
`);if(!t)return null;const n=t.split(`
|
|
127
|
+
`);let o;const a=[],l=[];let d=null,u=[],m=!1;const y=()=>{if(!d)return;const w=u.join(`
|
|
128
|
+
`).trim();w&&l.push({role:d,lines:[w]}),d=null,u=[]};for(const w of n){const b=o?null:w.match(/^\s*created_at\s*=\s*(.+)\s*$/i);if(b&&b[1]){o=b[1].trim();continue}const C=w.match(/^\s*(USER|ASSISTANT|SYSTEM)\s*:\s*(.*)$/i);if(C){m=!0,y();const S=String(C[1]||"").trim().toLowerCase();d=S==="user"?"user":S==="assistant"?"assistant":"system";const R=String(C[2]??"");u=R?[R]:[];continue}d?u.push(w):a.push(w)}if(y(),!m||!l.length)return null;const g=a.join(`
|
|
129
|
+
`).trim(),v={messages:[]};o&&(v.created_at=o),g&&v.messages.push({role:"system",content:g});for(const w of l)v.messages.push({role:w.role,content:w.lines.join(`
|
|
130
|
+
`)});return v.messages.length?v:null}function dy(e,t){const n=String(e||""),o=String(t||"");return o>n?o:n}function fy(e){const t=String((e==null?void 0:e.subject)||"").trim(),n=String((e==null?void 0:e.predicate)||"").trim(),o=String((e==null?void 0:e.object)||"").trim(),a=String((e==null?void 0:e.observed_at)||"").trim(),l=String((e==null?void 0:e.scope)||"").trim(),d=String((e==null?void 0:e.owner_id)||"").trim();return`${t}|${n}|${o}|${a}|${l}|${d}`}function sE(e){const t=String((e==null?void 0:e.observed_at)||"").trim(),n=String((e==null?void 0:e.subject)||"").trim(),o=String((e==null?void 0:e.predicate)||"").trim(),a=String((e==null?void 0:e.object)||"").trim(),l=String((e==null?void 0:e.scope)||"").trim(),d=String((e==null?void 0:e.owner_id)||"").trim(),u=[];l&&u.push(`scope=${l}`),d&&u.push(`owner=${d}`);const m=u.length?` (${u.join(", ")})`:"";return`${t?`[${t}] `:""}${n} --${o}--> ${a}${m}`}function iE({gateway:e,selected_run_id:t,selected_session_id:n}){const[o,a]=h.useState(String(t||"").trim()),[l,d]=h.useState(String(n||"").trim()),[u,m]=h.useState("all"),y=u==="all",[g,v]=h.useState(!0),[w,b]=h.useState(750),[C,S]=h.useState(5e3),[R,T]=h.useState([]),[D,q]=h.useState(void 0),[P,K]=h.useState(""),[Q,Z]=h.useState(!1),[ee,ue]=h.useState([]),[de,pe]=h.useState(!1),[F,E]=h.useState(!1),[j,L]=h.useState(""),[z,te]=h.useState(""),[I,O]=h.useState(""),[G,$]=h.useState(""),[Y,se]=h.useState("artifact"),[le,he]=h.useState(null),[be,je]=h.useState(""),[Ce,Fe]=h.useState(null),Ke=h.useRef(!1),Ye=h.useMemo(()=>{const ne=Ce,ge=ne!=null&&ne.attributes&&typeof ne.attributes=="object"&&!Array.isArray(ne.attributes)?ne.attributes:null;return(ge&&typeof ge.evidence_quote=="string"?String(ge.evidence_quote):"").trim()},[Ce]),Ct=h.useMemo(()=>{const ne=le,ge=ne&&typeof ne=="object"&&!Array.isArray(ne)?ne:null,Te=ge&&typeof ge.note=="string"?String(ge.note):"";return bp(Te).trim()},[le]),wt=h.useMemo(()=>{const ne=le&&typeof le=="object"&&!Array.isArray(le)?le:null,ge=ne&&Array.isArray(ne.messages)?ne.messages:null;return Array.isArray(ge)?ge:null},[le]),lt=h.useMemo(()=>{const ne=Ct,ge=Ye;return!ne||!ge?!1:ym(ne,ge)},[Ye,Ct]),yt=h.useMemo(()=>{const ne=wt,ge=Ye;if(!ne||!ge)return[];const Te=[];for(let qe=0;qe<Math.min(ne.length,500);qe++){const He=ne[qe],ot=(He==null?void 0:He.content)==null?"":String(He.content);ym(ot,ge)&&Te.push(qe)}return Te},[Ye,wt]),rt=h.useMemo(()=>new Set(yt),[yt]),Ne=yt.length?yt[0]:null,Oe=h.useCallback(ne=>{const ge=document.getElementById(`source_msg_${ne}`);ge&&typeof ge.scrollIntoView=="function"&&ge.scrollIntoView({block:"center",behavior:"smooth"})},[]),it=h.useCallback(()=>{const ne=document.getElementById("source_note_hit_0")||document.getElementById("source_note_msg_hit_0");ne&&typeof ne.scrollIntoView=="function"&&ne.scrollIntoView({block:"center",behavior:"smooth"})},[]);h.useEffect(()=>{if(de&&!(F||j)&&!Ke.current){if(Ne!==null){Ke.current=!0,window.setTimeout(()=>Oe(Ne),0);return}if(lt){Ke.current=!0,window.setTimeout(()=>it(),0);return}}},[Oe,it,j,Ne,F,lt,de]);const ve=h.useRef(new Set),Ie=h.useRef(""),Ge=h.useRef(null),Mt=h.useRef(null);h.useEffect(()=>{a(String(t||"").trim())},[t]),h.useEffect(()=>{d(String(n||"").trim())},[n]);const Bt=h.useMemo(()=>{const ne=String(o||"").trim(),ge=String(l||"").trim();return`mindmap:${u}:${ne}:${ge}`},[o,l,u]),dn=h.useMemo(()=>{let ne=null,ge=null;for(const Te of R){const qe=Wa(Te==null?void 0:Te.observed_at);qe!==null&&(ne=ne===null?qe:Math.min(ne,qe),ge=ge===null?qe:Math.max(ge,qe))}return{min_ms:ne,max_ms:ge}},[R]),Ft=1e3,At=h.useMemo(()=>{const ne=dn.min_ms,ge=dn.max_ms;if(typeof ne!="number"||typeof ge!="number"||!Number.isFinite(ne)||!Number.isFinite(ge))return null;if(ge<=ne)return{min_ms:ne,max_ms:ne,real_max_ms:ge};const Te=ne+Math.ceil((ge-ne)/Ft)*Ft;return{min_ms:ne,max_ms:Te,real_max_ms:ge}},[dn.max_ms,dn.min_ms]),[fn,Kn]=h.useState(!0),[jt,mn]=h.useState(null);h.useEffect(()=>{fn&&At&&mn(At.max_ms)},[fn,At]);const Hn=h.useMemo(()=>{const ne=typeof jt=="number"?jt:null;return ne===null?R:R.filter(ge=>{const Te=Wa(ge==null?void 0:ge.observed_at);return Te===null?!0:Te<=ne})},[R,jt]),Nn=h.useCallback((ne,ge)=>{const Te=Array.isArray(ne)?ne:[],qe=String(Ie.current||"").trim(),He=new Set,ot=[];let pt="";for(const vt of Te){if(!vt||typeof vt!="object"||typeof vt.subject!="string"||typeof vt.predicate!="string"||typeof vt.object!="string")continue;const zt=fy(vt);if(He.has(zt))continue;He.add(zt),ot.push(vt);const ct=String(vt.observed_at||"").trim();ct&&(pt=dy(pt,ct))}T(ot),q(ge==null?void 0:ge.warnings),ve.current=He,Ie.current=pt||qe},[]),yn=h.useCallback(async ne=>{const ge=o_(ne.scope,"session"),Te=String(ne.subject||"").trim(),qe=String(ne.predicate||"").trim(),He=String(ne.object||"").trim(),ot=String(ne.since||"").trim(),pt=String(ne.until||"").trim(),vt=String(ne.active_at||"").trim(),zt=String(ne.query_text||"").trim(),ct=typeof ne.min_score=="number"&&Number.isFinite(ne.min_score)?Number(ne.min_score):void 0,It=ne.order==="asc"?"asc":"desc",qt=typeof ne.limit=="number"&&Number.isFinite(ne.limit)?Number(ne.limit):0,ce=String(o||"").trim(),kt=String(l||"").trim(),Lt={scope:ge,all_owners:y,limit:qt,order:It};Te&&(Lt.subject=Te),qe&&(Lt.predicate=qe),He&&(Lt.object=He),ot&&(Lt.since=ot),pt&&(Lt.until=pt),vt&&(Lt.active_at=vt),zt&&(Lt.query_text=zt),typeof ct=="number"&&(Lt.min_score=ct),y||(ge==="run"?ce&&(Lt.run_id=ce):ge==="session"?kt?Lt.session_id=kt:ce&&(Lt.run_id=ce):ge==="all"&&(ce?Lt.run_id=ce:kt&&(Lt.session_id=kt)));try{const Ve=await e.kg_query(Lt),en=Array.isArray(Ve==null?void 0:Ve.items)?Ve.items:[],_n=Ve==null?void 0:Ve.warnings;return{ok:(Ve==null?void 0:Ve.ok)!==!1,count:Number((Ve==null?void 0:Ve.count)||en.length),items:en,warnings:_n,raw:Ve}}catch(Ve){const en=Ve instanceof Error?Ve.message:String(Ve);if(en.includes("Run '")&&en.includes("not found")&&!kt&&(ge==="session"||ge==="all")&&ce){const ln=await e.kg_query({...Lt,run_id:void 0,session_id:ce}),pn=Array.isArray(ln==null?void 0:ln.items)?ln.items:[],er=ln==null?void 0:ln.warnings;return{ok:(ln==null?void 0:ln.ok)!==!1,count:Number((ln==null?void 0:ln.count)||pn.length),items:pn,warnings:er,raw:ln}}throw new Error(en||"KG query failed")}},[y,e,o,l]),Cn=h.useCallback(async ne=>{var qe;const ge=String(ne.run_id||"").trim(),Te=String(ne.span_id||"").trim();if(!(!ge||!Te)){pe(!0),E(!0),L(""),O(ge),$(Te),se("artifact"),te(`source span:${Te}`),he(null),je(""),Fe(ne.assertion&&typeof ne.assertion=="object"?ne.assertion:null),Ke.current=!1;try{const He=[ge],ot=typeof((qe=ne.assertion)==null?void 0:qe.owner_id)=="string"?String(ne.assertion.owner_id).trim():"";ot&&ot!==ge&&He.push(ot);let pt=null,vt=null;for(const zt of He)try{vt=await(await e.download_run_artifact_content(zt,Te)).text(),zt!==ge&&O(zt);break}catch(ct){pt=ct instanceof Error?ct.message:String(ct)}if(vt==null)throw new Error(pt||"Failed to load source span");je(vt);try{const zt=JSON.parse(vt);he(zt)}catch{he(null)}}catch(He){const ot=He instanceof Error?He.message:String(He);L(ot||"Failed to load source span")}finally{E(!1)}}},[e]),Jt=h.useCallback(async ne=>{const ge=String(ne.run_id||"").trim();if(!ge)return null;try{const Te=await e.list_run_artifacts(ge,{limit:200}),He=(Array.isArray(Te==null?void 0:Te.items)?Te.items:[]).map(ct=>{const It=typeof(ct==null?void 0:ct.artifact_id)=="string"?String(ct.artifact_id).trim():"",qt=ct!=null&&ct.tags&&typeof ct.tags=="object"&&!Array.isArray(ct.tags)?ct.tags:null,ce=qt&&typeof qt.kind=="string"?String(qt.kind).trim():"";return{artifact_id:It,kind:ce}}).filter(ct=>!!(ct.artifact_id&&(ct.kind==="conversation_span"||ct.kind==="memory_note")));if(!He.length)return null;if(He.length===1)return He[0].artifact_id;const ot=ne.assertion,pt=ot!=null&&ot.attributes&&typeof ot.attributes=="object"&&!Array.isArray(ot.attributes)?ot.attributes:null,zt=(pt&&typeof pt.evidence_quote=="string"?String(pt.evidence_quote):"").trim();if(!zt)return null;for(const ct of He.slice(0,10))try{const qt=await(await e.download_run_artifact_content(ge,ct.artifact_id)).text(),ce=JSON.parse(qt);if(ce&&typeof ce=="object"){const kt=typeof ce.note=="string"?String(ce.note):"";if(kt&&kt.includes(zt))return ct.artifact_id;const Lt=Array.isArray(ce.messages)?ce.messages:null;if(Lt){for(const Ve of Lt.slice(0,200))if(((Ve==null?void 0:Ve.content)==null?"":String(Ve.content)).includes(zt))return ct.artifact_id}}}catch{}}catch{}return null},[e]),cr=h.useCallback(async ne=>{const ge=String(ne.run_id||"").trim();if(ge){pe(!0),E(!0),L(""),O(ge),$(""),se("run_input"),te(`transcript run:${ge}`),he(null),je(""),Fe(ne.assertion&&typeof ne.assertion=="object"?ne.assertion:null),Ke.current=!1;try{const Te=await Jt({run_id:ge,assertion:ne.assertion});if(Te){await Cn({run_id:ge,span_id:Te,assertion:ne.assertion});return}const qe=await e.get_run_input_data(ge),He=qe&&typeof qe=="object"&&!Array.isArray(qe)?qe.input_data:null,ot={kind:"run_input_data",run_id:ge};if(qe&&typeof(qe==null?void 0:qe.workflow_id)=="string"&&(ot.workflow_id=String(qe.workflow_id)),He&&typeof He=="object"&&!Array.isArray(He)){const pt=He.context,zt=(pt&&typeof pt=="object"&&Array.isArray(pt.messages)?pt.messages:null)||(Array.isArray(He.messages)?He.messages:null);Array.isArray(zt)&&(ot.messages=zt);const ct=["text","prompt","task","message"];for(const It of ct){const qt=He[It];if(typeof qt=="string"&&qt.trim()){ot.note=qt.trim();break}}ot.input_data=He}!ot.messages&&!ot.note&&(ot.note=JSON.stringify(He??qe??{},null,2));try{const pt=await e.get_run(ge),vt=pt&&typeof(pt==null?void 0:pt.created_at)=="string"?String(pt.created_at):"";vt&&(ot.created_at=vt)}catch{}he(ot),je(JSON.stringify(qe,null,2))}catch(Te){const qe=Te instanceof Error?Te.message:String(Te);L(qe||"Failed to load run input transcript")}finally{E(!1)}}},[e,Cn,Jt]),hn=h.useCallback(async()=>{K(""),Z(!0);try{const ne=u==="all"?"all":u,ge=await yn({scope:ne,limit:0,order:"desc"});Nn(ge.items||[],{warnings:ge.warnings}),Ge.current={scope:ne}}catch(ne){const ge=ne instanceof Error?ne.message:String(ne);K(ge||"Load failed")}finally{Z(!1)}},[yn,Nn,u]);h.useEffect(()=>{R.length||hn()},[]);const Wn=h.useCallback(async ne=>{const ge=o_(ne.scope,"session");return Mt.current=ne,await yn({scope:ge,subject:ne.subject,predicate:ne.predicate,object:ne.object,query_text:ne.query_text,min_score:ne.min_score,since:ne.since,until:ne.until,active_at:ne.active_at,limit:typeof ne.limit=="number"?ne.limit:0,order:"desc"})},[yn]),vn=h.useCallback((ne,ge)=>{var Te;if((ge==null?void 0:ge.kind)==="live query"){const qe=Mt.current;qe&&(Ge.current={scope:o_(qe.scope,"session"),subject:typeof qe.subject=="string"?qe.subject:void 0,predicate:typeof qe.predicate=="string"?qe.predicate:void 0,object:typeof qe.object=="string"?qe.object:void 0})}Nn(ne,{warnings:(Te=ge==null?void 0:ge.result)==null?void 0:Te.warnings})},[Nn]),Ln=h.useCallback(async()=>{const ne=Ge.current;if(!ne)return;const ge=String(Ie.current||"").trim(),Te=await yn({scope:ne.scope,subject:ne.subject,predicate:ne.predicate,object:ne.object,since:ge||void 0,order:"asc",limit:0}),qe=Array.isArray(Te.items)?Te.items:[];if(!qe.length)return;const ot=Date.now()+Math.max(250,Math.min(2e4,C)),pt=ve.current,vt=[],zt=[];let ct=String(Ie.current||"").trim();for(const It of qe){if(!It||typeof It!="object"||typeof It.subject!="string"||typeof It.predicate!="string"||typeof It.object!="string")continue;const qt=fy(It);if(pt.has(qt))continue;pt.add(qt),vt.push(It),zt.push({id:qt,assertion:It,expires_at_ms:ot});const ce=String(It.observed_at||"").trim();ce&&(ct=dy(ct,ce))}vt.length&&(Ie.current=ct,T(It=>{const qt=It.concat(vt);return qt.sort((ce,kt)=>String((kt==null?void 0:kt.observed_at)||"").localeCompare(String((ce==null?void 0:ce.observed_at)||""))),qt}),ue(It=>{const qt=It.concat(zt);return qt.sort((ce,kt)=>kt.expires_at_ms-ce.expires_at_ms),qt.slice(0,30)}))},[C,yn]);return h.useEffect(()=>{if(!g)return;let ne=!1,ge=null;const Te=async()=>{if(!ne){try{await Ln()}catch{}ne||(ge=window.setTimeout(()=>void Te(),Math.max(250,Math.min(6e4,w))))}};return Te(),()=>{ne=!0,ge!==null&&window.clearTimeout(ge)}},[g,w,Ln]),h.useEffect(()=>{if(!ee.length)return;const ne=window.setInterval(()=>{const ge=Date.now();ue(Te=>Te.filter(qe=>qe.expires_at_ms>ge))},250);return()=>window.clearInterval(ne)},[ee.length]),s.jsxs("div",{className:"mindmap_root",children:[s.jsxs("div",{className:"mindmap_bar",children:[s.jsx("button",{className:"btn",onClick:()=>void hn(),disabled:Q,children:Q?"Loading…":"Load snapshot"}),s.jsxs("label",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",children:"source"}),s.jsxs("select",{value:u,onChange:ne=>{const ge=String(ne.target.value||"").trim();(ge==="all"||ge==="global"||ge==="session"||ge==="run")&&m(ge)},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:ne=>v(!!ne.target.checked)})]}),u==="session"?s.jsxs("label",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",children:"session_id"}),s.jsx("input",{className:"mono",value:l,onChange:ne=>d(String(ne.target.value||"")),placeholder:"(required)"})]}):null,u==="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:ne=>a(String(ne.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:w,onChange:ne=>b(Math.max(250,Number(ne.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:C,onChange:ne=>S(Math.max(250,Number(ne.target.value||0)||5e3))})]})})]})]}),P?s.jsx("div",{className:"mindmap_error mono",children:P}):null,s.jsxs("div",{className:"mindmap_explorer",children:[s.jsx(tE,{title:"mindmap",resetKey:Bt,queryMode:"replace",items:Hn,warnings:D,onQuery:Wn,onItemsReplace:vn,onOpenSpan:({run_id:ne,span_id:ge,assertion:Te})=>{Cn({run_id:ne,span_id:ge,assertion:Te})},onOpenTranscript:({run_id:ne,span_id:ge,assertion:Te})=>{const qe=String(ne||"").trim(),He=typeof ge=="string"?String(ge).trim():"";qe&&(He?Cn({run_id:qe,span_id:He,assertion:Te}):cr({run_id:qe,assertion:Te}))}},Bt),ee.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:ee.slice().sort((ne,ge)=>ge.expires_at_ms-ne.expires_at_ms).slice(0,12).map(ne=>s.jsx("div",{className:"mindmap_recent_item mono",children:sE(ne.assertion)},ne.id))})]}):null,At?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 jt=="number"?jt:At.max_ms,At.real_max_ms))}),s.jsx("input",{className:"mindmap_slider",type:"range",min:At.min_ms,max:At.max_ms,step:Ft,value:typeof jt=="number"?jt:At.max_ms,onChange:ne=>{const ge=Number(ne.target.value||0);mn(ge),Kn(ge>=At.max_ms)}}),s.jsxs("div",{className:"mindmap_timeline_counts mono muted",children:[Hn.length.toLocaleString(),"/",R.length.toLocaleString()]})]})}):null]}),s.jsxs(Ka,{open:de,title:z||"source",onClose:()=>{pe(!1)},children:[F?s.jsx("div",{className:"mono muted",children:"Loading…"}):null,j?s.jsx("div",{className:"mindmap_error mono",children:j}):null,!F&&!j?s.jsxs("div",{className:"source_span",children:[(()=>{const ne=Ce;if(!ne)return null;const ge=String(ne.subject||"").trim(),Te=String(ne.predicate||"").trim(),qe=String(ne.object||"").trim(),He=Gl(Wa(ne.observed_at)),ot=ne.attributes&&typeof ne.attributes=="object"&&!Array.isArray(ne.attributes)?ne.attributes:null,pt=ot&&typeof ot.evidence_quote=="string"?String(ot.evidence_quote):"",vt=ot&&typeof ot.original_context=="string"?String(ot.original_context):"";return s.jsxs("div",{className:"source_header",children:[s.jsxs("div",{className:"mono source_triple",title:`${ge} --${Te}--> ${qe}`,children:[ge," ",s.jsxs("span",{className:"muted",children:["—",Te,"→"]})," ",qe," ",He?s.jsxs("span",{className:"muted",children:["[",He,"]"]}):null]}),pt?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:pt}),vt?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:vt})]}):null]}):null]})})(),s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:["run_id=",I," · ",Y==="artifact"?`span_id=${G}`:"source=input_data"]}),s.jsxs("div",{className:"source_actions",children:[Ne!==null?s.jsx("button",{className:"btn",onClick:()=>Oe(Ne),children:"Jump to evidence"}):null,Ne===null&<?s.jsx("button",{className:"btn",onClick:()=>it(),children:"Jump to evidence"}):null]}),(()=>{const ne=le,ge=ne&&typeof ne=="object"&&!Array.isArray(ne)?ne:null,Te=wt,qe=Ct,He=ge&&typeof ge.created_at=="string"?String(ge.created_at):"",ot=He?Wa(He):null,pt=ot!==null?Gl(ot):He,vt=ge&&ge.span&&typeof ge.span=="object"&&!Array.isArray(ge.span)?ge.span:null,zt=vt&&typeof vt.from_timestamp=="string"?String(vt.from_timestamp):"",ct=vt&&typeof vt.to_timestamp=="string"?String(vt.to_timestamp):"",It=zt?Wa(zt):null,qt=ct?Wa(ct):null,ce=It!==null&&qt!==null?`${Gl(It)} → ${Gl(qt)}`:"";if(qe){const kt=rE(qe);if(kt){const Lt=Ye,Ve=Lt?kt.messages.findIndex(pn=>ym(pn.content,Lt)):-1,en=Lt?uy(Lt):[],_n=kt.created_at||He,ln=_n?nE(_n):He?pt:"";return s.jsx("div",{className:"source_chat",children:kt.messages.map((pn,er)=>{const Gr=pn.role,Cr=!!(Lt&&ym(pn.content,Lt)),Kr=Gr==="user"?"USER":Gr==="assistant"?"ASSISTANT":"SYSTEM";return s.jsxs("div",{id:er===Ve?"source_note_msg_hit_0":void 0,className:`source_msg source_${Gr} ${Cr?"source_match":""}`,children:[s.jsxs("div",{className:"source_msg_meta mono muted",children:[s.jsxs("span",{children:["#",er+1," · ",Kr,Cr?s.jsx("span",{className:"source_match_badge",children:"evidence"}):null]}),ln?s.jsx("span",{title:_n||"",children:ln}):null]}),s.jsx("div",{className:"source_msg_body",children:s.jsx(_i,{text:pn.content,highlights:Cr&&en.length?en:void 0,highlightClassName:"source_note_hit",highlightId:er===Ve?"source_note_hit_0":void 0})})]},`note_msg:${er}`)})})}return s.jsxs("div",{className:"source_note",children:[He?s.jsx("div",{className:"mono muted",style:{marginBottom:10},children:s.jsxs("span",{title:He,children:["created_at=",pt]})}):null,s.jsx(_i,{text:qe,highlights:Ye?uy(Ye):void 0,highlightClassName:"source_note_hit",highlightId:"source_note_hit_0"})]})}if(Te){const kt=new Map;for(const Ve of Te){const en=typeof(Ve==null?void 0:Ve.role)=="string"?String(Ve.role):"unknown";kt.set(en,(kt.get(en)||0)+1)}const Lt=Array.from(kt.entries()).sort((Ve,en)=>en[1]-Ve[1]||Ve[0].localeCompare(en[0])).map(([Ve,en])=>`${Ve}×${en}`).join(" · ");return s.jsxs("div",{className:"source_chat",children:[He?s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:[s.jsxs("span",{title:He,children:["created_at=",pt]})," · messages=",Te.length]}):null,ce?s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:["span=",ce]}):null,Lt?s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:["participants: ",Lt]}):null,Te.slice(0,200).map((Ve,en)=>{var Gs,$s;const _n=typeof(Ve==null?void 0:Ve.role)=="string"?String(Ve.role):"unknown",ln=(Ve==null?void 0:Ve.content)==null?"":String(Ve.content),pn=typeof(Ve==null?void 0:Ve.timestamp)=="string"?String(Ve.timestamp):"",er=pn?Wa(pn):null,Gr=er!==null?Gl(er):pn,Cr=typeof(Ve==null?void 0:Ve.message_id)=="string"?String(Ve.message_id):typeof((Gs=Ve==null?void 0:Ve.metadata)==null?void 0:Gs.message_id)=="string"?String(Ve.metadata.message_id):typeof(($s=Ve==null?void 0:Ve.metadata)==null?void 0:$s.id)=="string"?String(Ve.metadata.id):"",Kr=rt.has(en);return s.jsxs("div",{id:`source_msg_${en}`,className:`source_msg source_${_n} ${Kr?"source_match":""}`,children:[s.jsxs("div",{className:"source_msg_meta mono muted",children:[s.jsxs("span",{children:["#",en+1," · ",_n,Kr?s.jsx("span",{className:"source_match_badge",children:"evidence"}):null,Cr?s.jsx("span",{className:"source_msg_id",children:Cr}):null]}),pn?s.jsx("span",{title:pn,children:Gr}):null]}),s.jsx("div",{className:"source_msg_body",children:s.jsx(_i,{text:ln})})]},en)})]})}return s.jsx("pre",{className:"mono source_raw",style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:(typeof ne=="string"?ne:be)||"(empty)"})})()]}):null]})]})}const a_=4;function oE(e){var l;const t=(l=e==null?void 0:e.discoveries)==null?void 0:l.dreams_signals_brief;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=typeof t.count=="number"&&Number.isInteger(t.count)&&t.count>0?t.count:0;if(!n)return null;const o=d=>Array.isArray(d)?d.filter(u=>typeof u=="string").map(u=>u.trim()).filter(Boolean):[],a=typeof t.dreams=="number"&&Number.isInteger(t.dreams)&&t.dreams>0?t.dreams:null;return{count:n,kinds:o(t.kinds),felt_tones:o(t.felt_tones),dreams:a}}function my(e){if(!e||typeof e!="object")return null;const t=String(e.title||"").trim(),n=String(e.statement||"").trim();if(!t&&!n)return null;const o=typeof e.entry_id=="string"&&e.entry_id.trim()?e.entry_id.trim():null;return{record_id:String(e.record_id||"").trim(),title:t,statement:n,entry_id:o}}function aE(e){var u,m;const t=y=>{var v;const g=(v=e==null?void 0:e[y])==null?void 0:v.open;return Array.isArray(g)?g.map(my).filter(w=>w!==null):[]},n=t("questions"),o=t("problems"),a=(u=e==null?void 0:e.lessons)==null?void 0:u.lessons,l=Array.isArray(a)?a.map(my).filter(y=>y!==null):[],d=typeof((m=e==null?void 0:e.lessons)==null?void 0:m.total)=="number"?e.lessons.total:l.length;return{questions:n.slice(0,a_),questions_total:n.length,problems:o.slice(0,a_),problems_total:o.length,lessons:l.slice(0,a_),lessons_total:d}}function l_(e){return e===null||!Number.isFinite(e)||e<0?"":e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(e<1e4?1:0)}k`:`${(e/1e6).toFixed(1)}M`}const hy={review:"Review",working:"Working",pending:"Pending",done:"Done"},lE={review:"nothing needs you",working:"idle",pending:"nothing scheduled",done:"no recent runs"},cE={pending:"scheduled or queued — will run without you",working:"running or parked listening — no action needed",review:"needs a human decision — act here",done:"terminal — read the outcome"};function uE(e){const t=String((e==null?void 0:e.status)||"").trim().toLowerCase();if(pi(t))return"done";const n=vu(e);return n==="tool_approval"||n==="user_response"?"review":n==="scheduled"||t==="pending"||t==="queued"||t==="created"?"pending":"working"}function dE(e){const t=vu(e);return t==="tool_approval"||t==="user_response"}function _y(e,t=Date.now()){const n=uE(e),o=e!=null&&e.waiting&&typeof e.waiting=="object"?e.waiting:null,a=yu(o),l=bn((o==null?void 0:o.since)||(e==null?void 0:e.updated_at)||(e==null?void 0:e.created_at)||"");return{run_id:String((e==null?void 0:e.run_id)||""),column:n,workflow:String((e==null?void 0:e.workflow_id)||"").trim()||"(workflow?)",status:String((e==null?void 0:e.status)||"").trim().toLowerCase(),wait_kind:vu(e),reason:_v(e),tool_names:a.map(d=>String((d==null?void 0:d.name)||"tool")).filter(Boolean),wait_key:String((o==null?void 0:o.wait_key)||"").trim(),allow_free_text:(o==null?void 0:o.allow_free_text)!==!1,prompt:String((o==null?void 0:o.prompt)||"").trim(),since_ms:l,duration_ms:Z_(e,t),tokens_total:typeof(e==null?void 0:e.tokens_total)=="number"?e.tokens_total:null,llm_calls:typeof(e==null?void 0:e.llm_calls)=="number"?e.llm_calls:null,tool_calls:typeof(e==null?void 0:e.tool_calls)=="number"?e.tool_calls:null,is_scheduled:!!(e!=null&&e.is_scheduled),schedule_interval:String((e==null?void 0:e.schedule_interval)||"").trim(),failed:String((e==null?void 0:e.status)||"").trim().toLowerCase()==="failed",error:String((e==null?void 0:e.error)||"").trim(),paused:!!(e!=null&&e.paused),is_subrun:!!String((e==null?void 0:e.parent_run_id)||"").trim()}}function fE(e,t,n=Date.now()){const o={pending:[],working:[],review:[],done:[]},a=t&&t.length?t:e,l=new Set;for(const d of a||[]){const u=String((d==null?void 0:d.run_id)||"").trim();!d||!u||l.has(u)||dE(d)&&(l.add(u),o.review.push(_y(d,n)))}for(const d of e||[]){const u=String((d==null?void 0:d.run_id)||"").trim();if(!d||!u||l.has(u))continue;const m=_y(d,n);o[m.column].push(m)}return o.review.sort((d,u)=>(d.since_ms??0)-(u.since_ms??0)),o.working.sort((d,u)=>(u.since_ms??0)-(d.since_ms??0)),o.pending.sort((d,u)=>(u.since_ms??0)-(d.since_ms??0)),o.done.sort((d,u)=>Number(u.failed)-Number(d.failed)||(u.since_ms??0)-(d.since_ms??0)),o}const K_={"12h":12*36e5,"24h":24*36e5,"48h":48*36e5,"72h":72*36e5,"7d":7*864e5,"14d":14*864e5,"1m":30*864e5,all:null},c_={"12h":"last 12h","24h":"last 24h","48h":"last 48h","72h":"last 72h","7d":"last 7 days","14d":"last 14 days","1m":"last month",all:"all loaded"},py="48h";function mE(e,t,n=Date.now()){const o=K_[t]??null;if(o===null)return{visible:e,hidden_count:0};const a=n-o,l=[];let d=0;for(const u of e)u.since_ms===null||u.since_ms>=a?l.push(u):d+=1;return{visible:l,hidden_count:d}}function hE(e,t=Date.now()){const n=String(e||"").trim();if(!n)return null;const o=Date.parse(n);return Number.isFinite(o)?Math.max(0,t-o):null}const _E=6e4;function $d(e,t=Date.now()){if(e===null||!Number.isFinite(e))return"";const n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s`:n<36e5?`${Math.round(n/6e4)}m`:n<864e5?`${(n/36e5).toFixed(1)}h`:`${(n/864e5).toFixed(1)}d`}function pE(e){return!Number.isFinite(e)||e<0?"":e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.floor(e/6e4)}m${Math.round(e%6e4/1e3)}s`:`${(e/36e5).toFixed(1)}h`}function gE(e){const t=String(e||"");return t.length>14?`${t.slice(0,6)}…${t.slice(-6)}`:t}function u_(e){const t=String(e||"").trim();return t.length>72?`${t.slice(0,70)}…`:t}function yE(e){const t=String(e||"");let n=t.includes(":")?t.slice(t.lastIndexOf(":")+1):t;if(t.includes(":")&&/^[0-9a-f]{6,}$/i.test(n.trim())){const o=t.slice(0,t.lastIndexOf(":"));/[a-z]/i.test(o)&&!/^[0-9a-f]+$/i.test(o.replace(/[@.\-_]/g,""))&&(n=o)}return n.length>34?`${n.slice(0,32)}…`:n}function Cm(e){return e.toLowerCase().replace(/[_-]+/g," ")}function vE(e){var y,g;const t=e!=null&&e.spec&&typeof e.spec=="object"?e.spec:null,n=t!=null&&t.phases&&typeof t.phases=="object"&&!Array.isArray(t.phases)?t.phases:null;if(!n)return null;const o=Object.keys(n).filter(v=>v&&typeof v=="string");if(!o.length)return null;const a=[];for(const v of o){a.push({needle:Cm(v),phase:v});const w=(y=n[v])==null?void 0:y.spoken_synonyms;if(Array.isArray(w))for(const b of w){const C=Cm(String(b||"").trim());C&&a.push({needle:C,phase:v})}}const d=(typeof t.initial_phase=="string"&&o.includes(t.initial_phase)?t.initial_phase:null)??(o.includes("sleep")?"sleep":null);if(!d)return null;const u=[],m=(g=t==null?void 0:t.state_mode_axis)==null?void 0:g.words;if(m&&typeof m=="object"&&!Array.isArray(m))for(const[v,w]of Object.entries(m)){const b=String((w==null?void 0:w.phase)||"").trim(),C=Cm(String(v||"").trim());C&&o.includes(b)&&u.push({needle:C,phase:b})}return{phases:o,synonyms:a,modes:u,initial:d,version:typeof t.version=="number"?t.version:null,sha256:String((e==null?void 0:e.sha256)||"").trim()}}const wE=["asleep","sleep","dream"],xE=["rest"],bE=["awake","idle"];function SE(e,t){const n=String(e||"").trim().toLowerCase();if(!n)return"unknown";if(t){const o=Cm(n),a=t.synonyms.filter(d=>o.includes(d.needle)).sort((d,u)=>u.needle.length-d.needle.length);if(a.length)return a[0].phase;const l=t.modes.filter(d=>o.includes(d.needle)).sort((d,u)=>u.needle.length-d.needle.length);return l.length?l[0].phase:n.includes("task")&&!n.includes("no_task")&&t.phases.includes("work")?"work":wE.some(d=>n.includes(d))?t.initial:xE.some(d=>n.includes(d))&&t.phases.includes("personal")?"personal":bE.some(d=>n.includes(d))?t.initial:n.includes("stop")?"stopped":n.includes("pause")?"paused":n}return n.includes("visit")?"visit":n.includes("sleep")||n.includes("dream")?"sleep":n.includes("personal")||n.includes("own_time")||n.includes("own time")?"personal":n.includes("task")&&!n.includes("no_task")||n.includes("work")?"work":n.includes("awake")||n.includes("idle")?"sleep":n.includes("stop")?"stopped":n.includes("pause")?"paused":n.includes("rest")?"resting":n}const jE=new Set(["visit","work","personal","sleep","paused","resting","stopped","unknown"]),kE=new Set(["visit","work","personal","sleep","paused","resting","stopped","unknown"]);function NE(e){if(!e)return jE;const t=e.phases.filter(n=>kE.has(n));return new Set([...t,"paused","stopped","unknown"])}function CE(e){var Q,Z,ee,ue,de,pe;const t=Date.now(),n=h.useMemo(()=>fE(e.runs,e.all_runs,Date.now()),[e.runs,e.all_runs]),[o,a]=h.useState(""),[l,d]=h.useState(""),[u,m]=h.useState(!1),[y,g]=h.useState(()=>{try{const F=localStorage.getItem("abstractobserver_done_window_v1");return F&&F in K_?F:py}catch{return py}}),v=h.useMemo(()=>mE(n.done,y,t),[n.done,y]),w=$d(e.runs_refreshed_at,t),b=n.review.length,C=v.visible.filter(F=>F.failed).length,[S,R]=h.useState(""),[T,D]=h.useState(null),q=F=>`${F.run_id}:${F.wait_key}:${F.since_ms??""}`;h.useEffect(()=>{o&&(n.review.some(F=>q(F)===o)||a(""))},[n,o]);async function P(F,E){a(q(F)),d("");try{await e.on_resume_wait(F.run_id,F.wait_key,E)}catch(j){d(`${F.run_id}: ${String((j==null?void 0:j.message)||j||"resume failed")}`),a("")}}function K(F){const E=o===q(F),j=F.column==="review",L=j&&!F.wait_key;return s.jsxs("div",{className:`mc_card ${j?"mc_card_review":""} ${F.failed?"mc_card_failed":""}`,onClick:()=>e.on_open_run(F.run_id),role:"button",tabIndex:0,onKeyDown:z=>{z.key==="Enter"&&z.target===z.currentTarget&&e.on_open_run(F.run_id)},children:[s.jsxs("div",{className:"mc_card_head",children:[s.jsx("span",{className:"mc_card_title",title:F.workflow,children:yE(F.workflow)}),(()=>{const z=F.failed?"failed":Tm({status:F.status,paused:F.paused});return s.jsx("span",{className:`mc_status ${Za(z)}`,children:z==="unknown"?"?":z})})()]}),s.jsxs("div",{className:"mc_card_meta",children:[s.jsx("span",{className:"mono",title:F.run_id,children:gE(F.run_id)}),F.is_subrun?s.jsx("span",{title:"This wait lives in a child run of an agent workflow",children:"subrun"}):null,F.duration_ms>=0?s.jsx("span",{children:pE(F.duration_ms)}):null,F.tokens_total!==null?s.jsxs("span",{children:[F.tokens_total.toLocaleString()," tk"]}):null,F.tool_calls!==null&&F.tool_calls>0?s.jsxs("span",{children:[F.tool_calls," tools"]}):null]}),F.is_scheduled&&F.schedule_interval?s.jsxs("div",{className:"mc_card_line",children:["every ",F.schedule_interval]}):null,F.failed&&F.error?s.jsx("div",{className:"mc_card_error",title:F.error,children:F.error.length>120?`${F.error.slice(0,118)}…`:F.error}):null,j?s.jsxs("div",{className:"mc_card_review_body",onClick:z=>z.stopPropagation(),onKeyDown:z=>z.stopPropagation(),children:[s.jsx("div",{className:"mc_card_reason",children:F.reason||"Needs a decision"}),F.prompt?s.jsx("div",{className:"mc_card_prompt",title:F.prompt,children:F.prompt.length>240?`${F.prompt.slice(0,238)}…`:F.prompt}):null,F.tool_names.length?s.jsxs("div",{className:"mc_card_tools",title:"Tool calls awaiting your approval",children:[F.tool_names.slice(0,4).map((z,te)=>s.jsx("span",{className:"mc_tool_chip mono",children:z},`${z}_${te}`)),F.tool_names.length>4?s.jsxs("span",{className:"mc_tool_chip",children:["+",F.tool_names.length-4," more"]}):null]}):null,F.since_ms!==null?s.jsxs("div",{className:"mc_card_waiting",children:["waiting ",$d(F.since_ms,t)]}):null,L?s.jsx("div",{className:"mc_card_line",title:"The wait has not registered a wait_key yet — open the run to inspect.",children:"wait key not published yet — open the run"}):null,L?s.jsx("div",{className:"mc_card_actions",children:s.jsx("button",{className:"btn",onClick:()=>e.on_open_run(F.run_id),children:"Open the run →"})}):F.wait_kind==="tool_approval"?s.jsxs("div",{className:"mc_card_actions",children:[s.jsx("button",{className:"btn success",disabled:E,onClick:()=>void P(F,{approved:!0}),children:E?"Resuming…":"Approve"}),s.jsx("button",{className:"btn danger",disabled:E,onClick:()=>void P(F,{approved:!1}),children:"Reject"})]}):s.jsx("div",{className:"mc_card_actions",children:s.jsx("button",{className:"btn primary",onClick:()=>e.on_open_run(F.run_id),children:"Review & answer →"})})]}):null]},F.run_id)}return s.jsxs("div",{className:"page page_scroll mc_page",children:[s.jsxs("div",{className:"mc_health",children:[s.jsx("span",{className:`mc_led ${e.gateway_connected?"ok":"bad"}`,title:e.gateway_connected?"Gateway connected":"Gateway unreachable"}),e.gateway_connected?null:s.jsx("span",{className:"mc_health_text",children:"gateway unreachable"}),e.runs_refreshed_at===null?s.jsx("span",{className:"mc_health_text muted mc_loading",children:"loading runs…"}):s.jsxs("div",{className:"mc_stats",children:[s.jsxs("div",{className:`mc_stat ${b?"is_hot":""}`,title:"runs blocked on a human decision (Review column)",children:[s.jsx("span",{className:"mc_stat_value",children:b}),s.jsx("span",{className:"mc_stat_label",children:"need you"})]}),s.jsxs("div",{className:`mc_stat ${C?"is_bad":""}`,title:"failed runs in the Done column",children:[s.jsx("span",{className:"mc_stat_value",children:C}),s.jsx("span",{className:"mc_stat_label",children:"failed"})]}),s.jsxs("div",{className:"mc_stat",title:"runs executing or parked listening",children:[s.jsx("span",{className:"mc_stat_value",children:n.working.length}),s.jsx("span",{className:"mc_stat_label",children:"working"})]})]}),s.jsx("span",{className:"mc_spacer"}),s.jsxs("div",{className:"mc_health_side",children:[w?s.jsxs("span",{className:"mc_health_text muted",title:"age of the last runs poll — the board is only as live as this",children:["data ",w," old"]}):null,s.jsx("button",{className:"btn",onClick:e.on_refresh,disabled:e.refreshing,children:e.refreshing?"Refreshing…":"Refresh"})]})]}),l?s.jsx("div",{className:"mc_error",children:l}):null,e.entities.length||e.entities_error?s.jsxs("div",{className:"mc_entities",children:[s.jsxs("div",{className:"mc_entities_head",children:[s.jsxs("span",{children:["Entities",e.entities_total>e.entities.length?` (${e.entities.length} of ${e.entities_total} — open the entity app for all)`:""]}),s.jsx("a",{className:"mc_entity_link",href:e.entity_app_href,target:"_blank",rel:"noreferrer",children:"open the entity app →"})]}),e.entities_error?s.jsx("div",{className:"muted",children:e.entities_error}):null,s.jsx("div",{className:"mc_entities_row",children:e.entities.map(F=>s.jsxs("div",{className:"mc_entity_cell",children:[s.jsxs("a",{className:"mc_entity",href:`${e.entity_app_href}${e.entity_app_href.includes("?")?"&":"?"}entity=${encodeURIComponent(F.name)}&live=1`,target:"_blank",rel:"noreferrer",title:[F.error,F.age_days!==null?`${F.age_days.toFixed(0)} days old`:"",F.last_moment].filter(Boolean).join(" — ")||F.name,children:[s.jsx("span",{className:"mc_entity_name",children:F.name}),(()=>{var O;const E=String(F.live_phase||F.state||"").trim(),j=SE(E,e.phase_graph),L=NE(e.phase_graph).has(j)?j:"other",z=((O=e.phase_graph)==null?void 0:O.initial)??"sleep",te=/awake|idle/i.test(E)&&j===z,I=E&&E.toLowerCase()!==j?` — wire word: ${E}${te?" (settling)":""}`:"";return s.jsx("span",{className:`mc_entity_phase mc_phase_${L}`,title:(F.live_phase?"phase (cognition wire)":"phase from card state — cognition wire unavailable")+I,children:j})})(),F.last_moment?s.jsx("span",{className:"mc_entity_moment",title:F.last_moment,children:F.last_moment.replace(/_/g," ")}):null,(()=>{if(F.working===!0)return s.jsx("span",{className:"mc_entity_live",title:"busy now (loop mid-day or live visit — store-read, never fabricated)",children:"● busy"});const E=hE(F.last_moment_at,t);return F.working===!1?s.jsxs("span",{className:"mc_entity_live muted",title:"idle (cognition wire)",children:["idle",E!==null?` · ${$d(t-E,t)} ago`:""]}):E===null?null:E<=_E?s.jsx("span",{className:"mc_entity_live",title:`last moment ${$d(t-E,t)} ago`,children:"● active"}):s.jsxs("span",{className:"mc_entity_live muted",title:"time since the last recorded moment",children:[$d(t-E,t)," ago"]})})(),F.tokens_total!==null?s.jsxs("span",{className:"muted mc_entity_spend",title:`lifetime billed tokens (home run ledger)${F.live_visit_tokens!==null?`; open visit: ${l_(F.live_visit_tokens)} tk`:""}${F.spend_warning?`; ${F.spend_warning}`:""}`,children:[l_(F.tokens_total)," tk",F.live_visit_tokens!==null?` (+${l_(F.live_visit_tokens)})`:"",F.spend_warning?"*":""]}):null]}),F.open_questions_total||F.open_problems_total||F.lessons_total||F.dreams_brief?s.jsx("button",{type:"button",className:"mc_entity_hints_btn","aria-expanded":S===F.name,title:"open questions / problems + distilled lessons + night signals from the entity card — click to expand",onClick:()=>R(S===F.name?"":F.name),children:[F.open_questions_total?`${F.open_questions_total} question${F.open_questions_total>1?"s":""}`:"",F.open_problems_total?`${F.open_problems_total} problem${F.open_problems_total>1?"s":""}`:"",F.lessons_total?`${F.lessons_total} lesson${F.lessons_total>1?"s":""}`:"",F.dreams_brief?`night: ${F.dreams_brief.count} signal${F.dreams_brief.count>1?"s":""}`:""].filter(Boolean).join(" · ")}):null]},F.name))}),(()=>{if(!S)return null;const F=e.entities.find(L=>L.name===S);if(!F||!F.open_questions.length&&!F.open_problems.length&&!F.lessons.length&&!F.dreams_brief)return null;const E=e.on_read_diary?async L=>{const z=await e.on_read_diary(F.name,L);D({entity:F.name,entry:(z==null?void 0:z.entry)??z,seq:typeof(z==null?void 0:z.read_recorded_at_seq)=="number"?z.read_recorded_at_seq:null})}:void 0,j=F.open_questions_total-F.open_questions.length+(F.open_problems_total-F.open_problems.length)+(F.lessons_total-F.lessons.length);return s.jsxs("div",{className:"mc_entity_hints_panel",children:[F.open_questions.map((L,z)=>s.jsx(Ph,{kind:"question",label:L.title||u_(L.statement),entryId:L.entry_id,onOpen:E,title:L.statement||L.title},`q_${L.record_id||z}`)),F.open_problems.map((L,z)=>s.jsx(Ph,{kind:"problem",label:L.title||u_(L.statement),entryId:L.entry_id,onOpen:E,title:L.statement||L.title},`p_${L.record_id||z}`)),F.lessons.map((L,z)=>s.jsx(Ph,{kind:"lesson",label:L.title||u_(L.statement),entryId:L.entry_id,onOpen:E,title:L.statement||L.title},`l_${L.record_id||z}`)),F.dreams_brief?s.jsxs("span",{className:"mc_entity_dreams muted",title:"night signals carried by STANDING dreams (the sleep pass's maintenance stream; count = signals, not dreams); felt tones color the content, they never rank it — the entity app renders the full stream",children:["night signals: ",F.dreams_brief.count,F.dreams_brief.dreams?` across ${F.dreams_brief.dreams} dream${F.dreams_brief.dreams>1?"s":""}`:"",F.dreams_brief.kinds.length?` — ${F.dreams_brief.kinds.slice(0,6).join(", ")}${F.dreams_brief.kinds.length>6?` +${F.dreams_brief.kinds.length-6} more`:""}`:"",F.dreams_brief.felt_tones.length?` · felt: ${F.dreams_brief.felt_tones.slice(0,6).join(", ")}`:""]}):null,j>0?s.jsxs("span",{className:"muted mc_entity_hints_more",children:["+",j," more — open the entity app"]}):null]})})()]}):null,T?s.jsx(Ka,{open:!0,title:`${T.entity} — diary entry`,onClose:()=>D(null),children:s.jsxs("div",{className:"mc_diary_entry",children:[s.jsx("div",{className:"mc_diary_meta muted",children:[(Q=T.entry)!=null&&Q.kind?`kind: ${T.entry.kind}`:"",(Z=T.entry)!=null&&Z.visibility?`visibility: ${T.entry.visibility}`:"",(ee=T.entry)!=null&&ee.written_at?`written: ${T.entry.written_at}`:"",(ue=T.entry)!=null&&ue.entry_id?`id: ${T.entry.entry_id}`:""].filter(Boolean).join(" · ")}),s.jsxs("div",{className:"mc_diary_recorded muted",children:["this read was recorded in ",T.entity,"’s stream",T.seq!==null?` (seq ${T.seq})`:""]}),(de=T.entry)!=null&&de.gist?s.jsx("div",{className:"mc_diary_gist",children:String(T.entry.gist)}):null,s.jsx("pre",{className:"mc_diary_text",children:String(((pe=T.entry)==null?void 0:pe.text)||"(entry carries no text)")})]})}):null,s.jsx("div",{className:"mc_board",children:Object.keys(hy).map(F=>{const E=F==="done"?v.visible:n[F],j=F==="done"&&!u?E.slice(0,8):E;return s.jsxs("div",{className:`mc_column mc_column_${F}`,children:[s.jsxs("div",{className:"mc_column_head",children:[s.jsx("span",{className:"mc_column_title",children:hy[F]}),F==="done"?s.jsx("select",{className:"mc_window_select",value:y,title:"Show terminal runs from this time window",onClick:L=>L.stopPropagation(),onChange:L=>{const z=L.target.value;g(z),m(!1);try{localStorage.setItem("abstractobserver_done_window_v1",z)}catch{}},children:Object.keys(K_).map(L=>s.jsx("option",{value:L,children:c_[L]},L))}):null,s.jsx("span",{className:"mc_column_count",title:F==="done"&&v.hidden_count?`${v.hidden_count} older run(s) outside this window`:void 0,children:E.length})]}),s.jsx("div",{className:"mc_column_hint muted",children:cE[F]}),s.jsxs("div",{className:"mc_column_cards",children:[j.map(L=>K(L)),E.length?null:s.jsx("div",{className:"mc_empty muted",children:e.runs_refreshed_at===null?"loading…":F==="done"&&v.hidden_count?`none in the ${c_[y]} — ${v.hidden_count} older`:lE[F]}),F==="done"&&E.length>8&&!u?s.jsxs("button",{className:"btn mc_more",onClick:()=>m(!0),children:["show all ",E.length]}):null,F==="done"&&v.hidden_count&&E.length?s.jsxs("div",{className:"mc_window_note muted",title:"Widen the window above to see older terminal runs",children:["+",v.hidden_count," older outside ",c_[y]]}):null]})]},F)})})]})}function gy(e){const t=Array.from(new Set(e.map(n=>String(n||"").trim()).filter(Boolean)));return t.sort((n,o)=>n.localeCompare(o)),t}function d_(e){const t=e.disabled===!0,n=h.useMemo(()=>gy(e.options||[]),[e.options]),o=h.useMemo(()=>gy(e.value||[]),[e.value]),[a,l]=h.useState(!1),[d,u]=h.useState(""),m=h.useMemo(()=>{const v=d.trim().toLowerCase();return v?n.filter(w=>w.toLowerCase().includes(v)):n},[n,d]),y=h.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:()=>l(v=>!v),disabled:t||!n.length,"aria-expanded":a,children:[a?"Hide":"Select"," • ",o.length>0?`${o.length} of ${n.length}`:e.placeholder||"(none)"]}),s.jsx("button",{className:"btn",type:"button",onClick:()=>e.onChange(n.slice()),disabled:t||!n.length||o.length===n.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(v=>s.jsxs("span",{className:"multi_select_chip",title:v,onClick:()=>{if(t)return;const w=new Set(y);w.delete(v),e.onChange(Array.from(w.values()))},children:[v,t?null:s.jsx("span",{className:"multi_select_chip_x",children:"×"})]},v))}):null,a?s.jsxs("div",{className:"multi_select_panel",children:[s.jsx("input",{className:"mono",value:d,onChange:v=>u(String(v.target.value||"")),placeholder:"filter…",disabled:t}),s.jsxs("div",{className:"multi_select_list",style:{maxHeight:`${g}px`},children:[m.map(v=>{const w=y.has(v);return s.jsxs("label",{className:`multi_select_item mono ${w?"checked":""}`,children:[s.jsx("input",{type:"checkbox",checked:w,disabled:t,onChange:b=>{const C=new Set(y);b.target.checked?C.add(v):C.delete(v),e.onChange(Array.from(C.values()))}}),s.jsx("span",{children:v})]},v)}),m.length?null:s.jsx("div",{className:"mono muted",children:"(no matches)"})]})]}):null]})}function EE(){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 $E(){if(typeof window>"u")return!1;const e=window;return!!(e!=null&&e.AudioContext||e!=null&&e.webkitAudioContext)}function ME(){const e=window.MediaRecorder,t=o=>{var a;try{return!!((a=e==null?void 0:e.isTypeSupported)!=null&&a.call(e,o))}catch{return!1}},n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];for(const o of n)if(t(o))return o;return""}async function AE(e,t){var a;const n=t.slice(0),o=(a=e.decodeAudioData)==null?void 0:a.bind(e);if(typeof o!="function")throw new Error("decodeAudioData not available");try{const l=o(n);if(l&&typeof l.then=="function")return await l}catch{}return await new Promise((l,d)=>{try{o(n,l,d)}catch(u){d(u)}})}function TE(e){const t=L=>{var z;return(z=e.on_error)==null?void 0:z.call(e,L)},n=h.useMemo(()=>$E(),[]),o=h.useMemo(()=>EE(),[]),[a,l]=h.useState({key:"",status:"idle"}),d=h.useRef(""),u=h.useRef(""),m=h.useRef(null),y=h.useRef(null),g=h.useRef(null),v=h.useRef(null),w=h.useRef(0),b=h.useRef(0),C=()=>{try{const L=globalThis,z=(L==null?void 0:L.AudioContext)||(L==null?void 0:L.webkitAudioContext);if(!z)return null;if(!m.current){const O=new z,G=O.createGain();G.gain.value=1,G.connect(O.destination),m.current=O,y.current=G}const te=m.current,I=y.current;if(!te||!I)return null;try{te.state==="suspended"&&te.resume()}catch{}return{ctx:te,gain:I}}catch{return null}},S=()=>{const L=g.current;if(g.current=null,!!L){try{L.onended=null}catch{}try{L.stop()}catch{}try{L.disconnect()}catch{}}},R=()=>{S(),u.current="",d.current="",v.current=null,w.current=0,b.current=0,l({key:"",status:"idle"})};h.useEffect(()=>()=>{var L,z;R();try{(L=y.current)==null||L.disconnect()}catch{}try{(z=m.current)==null||z.close()}catch{}m.current=null,y.current=null,v.current=null},[]);const T=async(L,z,te)=>{const I=C();if(!I)throw new Error("TTS playback is not supported in this browser");const{ctx:O,gain:G}=I;try{O.state==="suspended"&&await O.resume()}catch{}S();const $=O.createBufferSource();$.buffer=z,$.connect(G);const Y=Number.isFinite(Number(z.duration))?Number(z.duration):0,se=Math.max(0,Math.min(Number(te||0),Y>0?Math.max(0,Y-.01):0));b.current=O.currentTime-se,w.current=se,g.current=$,d.current=L,$.onended=()=>{g.current===$&&(g.current=null,w.current=0,b.current=0,d.current="",l({key:"",status:"idle"}))},$.start(0,se),l({key:L,status:"playing"})},D=async(L,z)=>{const te=String(L||"").trim(),I=String(z||"").trim();if(!te||!I)return;const O=e.gateway,G=String(e.run_id||"").trim();if(!O){t==null||t("Connect to the gateway first.");return}if(!G){t==null||t("Voice store not available (missing run_id).");return}const $=C();if(!$){t==null||t("TTS playback is not supported in this browser.");return}const Y=a.key===te;if(Y&&a.status==="playing"){const se=Math.max(0,$.ctx.currentTime-Number(b.current||0));w.current=se,S(),l({key:te,status:"paused"});return}if(Y&&a.status==="paused"){const se=v.current;if(se){t==null||t("");try{await T(te,se,w.current)}catch(le){t==null||t(String((le==null?void 0:le.message)||le||"TTS play failed")),l({key:"",status:"idle"})}return}}if(!(Y&&a.status==="loading")){S(),v.current=null,w.current=0,b.current=0,d.current=te,u.current=te,l({key:te,status:"loading"}),t==null||t("");try{const se=await O.voice_tts(G,{text:I,request_id:ss()}),le=se==null?void 0:se.audio_artifact,he=le&&typeof le=="object"&&!Array.isArray(le)?String(le.$artifact||"").trim():"";if(!he)throw new Error("TTS failed: missing audio artifact");const je=await(await O.download_run_artifact_content(G,he)).arrayBuffer();if(u.current!==te)return;const Ce=await AE($.ctx,je);if(u.current!==te)return;v.current=Ce,w.current=0,await T(te,Ce,0)}catch(se){u.current===te&&(u.current="",d.current="",l({key:"",status:"idle"})),t==null||t(String((se==null?void 0:se.message)||se||"TTS failed"))}}},[q,P]=h.useState(!1),[K,Q]=h.useState(!1),Z=h.useRef(null),ee=h.useRef(null),ue=h.useRef([]),de=h.useRef("");function pe(){var L,z;try{(z=(L=Z.current)==null?void 0:L.getTracks)==null||z.call(L).forEach(te=>{try{te.stop()}catch{}})}catch{}Z.current=null}h.useEffect(()=>()=>{var L,z;try{(z=(L=ee.current)==null?void 0:L.stop)==null||z.call(L)}catch{}ee.current=null,pe()},[]);async function F(L,z){var G;if(t==null||t(""),!L||!L.size||K)return;const te=e.gateway,I=String(e.session_id||"").trim(),O=String(e.run_id||"").trim();if(!te){t==null||t("Connect to the gateway first.");return}if(!I){t==null||t("Voice input unavailable (missing session_id).");return}if(!O){t==null||t("Voice input unavailable (missing run_id).");return}Q(!0);try{const $=String(z||L.type||"").toLowerCase(),Y=$.includes("mp4")?"m4a":$.includes("ogg")?"ogg":$.includes("wav")?"wav":"webm",se=new File([L],`recording.${Y}`,{type:$||"audio/webm"}),le=await te.attachments_upload(I,se,{filename:se.name,content_type:se.type}),he=await te.audio_transcribe(O,{audio_artifact:le,request_id:ss()}),be=String((he==null?void 0:he.text)||"").trim();be&&((G=e.on_transcript)==null||G.call(e,be))}catch($){t==null||t(String(($==null?void 0:$.message)||$||"Transcription failed"))}finally{Q(!1)}}async function E(){if(t==null||t(""),!o){t==null||t("Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(!K&&!(q||ee.current)){ue.current=[];try{const L=await navigator.mediaDevices.getUserMedia({audio:!0});Z.current=L;const z=ME();de.current=z;const te=z?new MediaRecorder(L,{mimeType:z}):new MediaRecorder(L);ee.current=te,te.ondataavailable=I=>{try{I!=null&&I.data&&ue.current.push(I.data)}catch{}},te.onerror=()=>{t==null||t("Recording failed.")},te.onstop=()=>{P(!1),pe(),ee.current=null;try{const I=new Blob(ue.current,{type:de.current||""});F(I,de.current)}catch(I){t==null||t(String((I==null?void 0:I.message)||I||"Failed to build recording"))}},te.start(),P(!0)}catch(L){pe(),ee.current=null,P(!1);const z=String((L==null?void 0:L.message)||L||"Failed to access microphone");t==null||t(z.toLowerCase().includes("permission")?`Microphone permission denied: ${z}`:z)}}}function j(){const L=ee.current;if(!(!q||!L)){ee.current=null,P(!1);try{L.stop()}catch(z){t==null||t(String((z==null?void 0:z.message)||z||"Failed to stop recording"))}}}return h.useEffect(()=>{if(!q)return;const L=()=>j();return window.addEventListener("pointerup",L),window.addEventListener("pointercancel",L),()=>{window.removeEventListener("pointerup",L),window.removeEventListener("pointercancel",L)}},[q]),{tts_supported:n,tts_playback:a,toggle_tts:D,stop_tts:R,voice_ptt_supported:o,voice_ptt_recording:q,voice_ptt_busy:K,start_voice_ptt_recording:E,stop_voice_ptt_recording:j}}const vm=500,qm="http://127.0.0.1:8080";function f_(e){const t=String(e||"").trim(),n=t.indexOf(":");return n<=0||n>=t.length-1?null:{bundle_id:t.slice(0,n),flow_id:t.slice(n+1)}}function Md(e){const t=String(e||"").trim();return t.startsWith("abstractcode.")?`abstract.${t.slice(13)}`:t}function m_(e){const t=e&&typeof e=="object"?e:{},n=typeof(t==null?void 0:t.count)=="number"&&Number.isFinite(t.count)?Number(t.count):null,o=typeof(t==null?void 0:t.node_id)=="string"&&t.node_id.trim()?` before ${t.node_id.trim()}`:"";return`${n===null?"steering":`${n} steer message${n===1?"":"s"}`} folded into the run${o} — the loop sees it at this boundary`}function h_(e){const t=String(e||"").trim();return t.startsWith("abstract.")||t.startsWith("abstractcode.")}function RE(e){const t=String(e||"").trim();if(t.startsWith("evt:")){const n=t.split(":",4);if(n.length===4&&n[3])return String(n[3]).trim()}return t}function LE(e){if(!e||typeof e!="object")return[];const t=Array.isArray(e.nodes)?e.nodes:[];if(!t.length)return[];let n=null;for(const u of t){if(!u||typeof u!="object")continue;const m=u.data&&typeof u.data=="object"?u.data:{};if(String(m.nodeType||u.type||"").trim()==="on_flow_start"){n=u;break}}if(!n)return[];const o=n.data&&typeof n.data=="object"?n.data:{},a=Array.isArray(o.outputs)?o.outputs:[],l=o.pinDefaults&&typeof o.pinDefaults=="object"?o.pinDefaults:{},d=[];for(const u of a){if(!u||typeof u!="object")continue;const m=String(u.id||"").trim();if(!m)continue;const y=String(u.type||"").trim();if(y==="execution"||m==="exec-out"||m==="exec")continue;const g=String(u.label||m).trim()||m,v={id:m,label:g,type:y||"unknown"};l&&Object.prototype.hasOwnProperty.call(l,m)&&(v.default=l[m]),d.push(v)}return d}function __(e,t){const n=String((e==null?void 0:e.message)||e||"Discovery failed");if(/\b401\b/.test(n)){const o=String(t.gateway_user||"").trim();return o?`Gateway authentication failed for user '${o}'. Sign in again through the connection dialog. (${n})`:`Gateway authentication failed. Sign in through the connection dialog (or check the dev bearer token under Settings → Advanced). (${n})`}return n}const PE=/^[a-zA-Z0-9_-]+$/;function yy(e){return PE.test(String(e||"").trim())}async function OE(e){const t=String(e||""),n=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 a=await o.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(a)).map(l=>l.toString(16).padStart(2,"0")).join("")}async function vy(e){const t=String(e||"").trim();if(!t)throw new Error("session_id is required");if(yy(t)){const o=`session_memory_${t}`;if(yy(o))return o}return`session_memory_sha_${(await OE(t)).slice(0,32)}`}const wy=new Set(["abstract.status","abstract.summary","abstract.chat"]);function zE(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!wy.has(t);const n=String(e.effect_type||"").trim();if(n){if(n==="tool_calls"||n==="llm_call"||n==="ask_user"||n==="answer_user"||n==="memory_compact"||n==="start_subworkflow")return!0;if(n==="emit_event")return!(t&&wy.has(t))}if(String(e.status||"").trim()==="waiting"){const l=Ui(e.data),d=String((l==null?void 0:l.reason)||"").trim();return!!(d==="user"||d==="event"||yu(l).length)}return!!Yd(e.data)}function IE(){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)||qm),auth_token:"",gateway_user:String((t==null?void 0:t.gateway_user)||""),gateway_auth_mode:(t==null?void 0:t.gateway_auth_mode)==="direct"?"direct":"session",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)||""),assistant_skill_names:Array.isArray(t==null?void 0:t.assistant_skill_names)?t.assistant_skill_names.map(n=>String(n||"").trim()).filter(Boolean):[],maintenance_ai_model:String((t==null?void 0:t.maintenance_ai_model)||"")}}catch{return{gateway_url:qm,auth_token:"",gateway_user:"",gateway_auth_mode:"session",worker_url:"",worker_token:"",theme:"dark",font_scale:"md",header_density:"standard",auto_connect_gateway:!0,maintenance_ai_provider:"",assistant_skill_names:[],maintenance_ai_model:""}}}function DE(e){localStorage.setItem("abstractobserver_settings",JSON.stringify({...e,auth_token:""}))}function FE(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=[],n=(a,l)=>{const d=String(l??"").trim();d&&(t.some(u=>u.label===a&&u.value===d)||t.push({label:a,value:d}))},o=String(e.display??"").trim().replace(/^\[/,"").replace(/\]$/,"");return n("time",o||e.local_datetime),n("tz",e.timezone),n("country",e.country),n("user",e.user),t}function xy(e){const t=FE(e.metadata);return t.length?s.jsx("div",{className:"runtime_metadata_chips","aria-label":"Runtime metadata",children:t.map(n=>s.jsxs("span",{className:"chip mono muted",children:[n.label,": ",n.value]},`${n.label}:${n.value}`))}):null}function by(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 BE(){try{const t=String(window.location.hash||"").replace(/^#/,"").split("/").filter(Boolean),n=t.length?String(t[t.length-1]||"").trim():"";if(by(n))return n;const a=String(window.location.pathname||"").split("/").filter(Boolean),l=a.length?String(a[a.length-1]||"").trim():"";if(by(l))return l}catch{}return""}function UE(){try{const e="abstractobserver_session_id_v1",t=window.sessionStorage.getItem(e);if(t&&t.trim())return t.trim();const n=globalThis.crypto,a=`obs_${n&&typeof n.randomUUID=="function"?n.randomUUID():`${Math.random().toString(16).slice(2)}_${Date.now().toString(16)}`}`;return window.sessionStorage.setItem(e,a),a}catch{return""}}function HE(){var Bl,Di,Ul,Ia,Kc,Hl,Wl,Sr,Fi,ks,Pr,_d,Yc;const[e,t]=h.useState("board"),[n,o]=h.useState(()=>IE()),a=typeof window<"u"&&((Bl=window.__ABSTRACT_UI_CONFIG__)==null?void 0:Bl.monitor_gpu)===!0,l=typeof window<"u"&&(((Di=window.__ABSTRACT_UI_CONFIG__)==null?void 0:Di.entity_app_url)||"").trim().replace(/\/+$/,"")||"http://127.0.0.1:3007",d=h.useRef(null),[u,m]=h.useState(""),[y,g]=h.useState(""),[v,w]=h.useState(()=>BE()),[b,C]=h.useState(""),[S,R]=h.useState(""),[T,D]=h.useState("{}"),[q]=h.useState(()=>UE()),[P,K]=h.useState(null),[Q,Z]=h.useState(!1),[ee,ue]=h.useState(""),[de,pe]=h.useState(!1),[F,E]=h.useState(""),[j,L]=h.useState(!1),z=vb({appName:"AbstractObserver",variant:"dismissable",defaultGatewayUrl:typeof window<"u"&&((Ul=window.__ABSTRACT_UI_CONFIG__)==null?void 0:Ul.gateway_url)||qm,onStatusChange:_=>xs(_)}),[te,I]=h.useState(null),[O,G]=h.useState(null),[$,Y]=h.useState(!1),[se,le]=h.useState(null),[he,be]=h.useState([]),[je,Ce]=Fb("abstractobserver",{legacyKey:"abstractobserver_settings"}),[Fe,Ke]=h.useState(!1),[Ye,Ct]=h.useState(!1),[wt,lt]=h.useState([]),[yt,rt]=h.useState([]),[Ne,Oe]=h.useState([]),[it,ve]=h.useState(!1),[Ie,Ge]=h.useState(null),[Mt,Bt]=h.useState([]),[dn,Ft]=h.useState(0),[At,fn]=h.useState(""),Kn=h.useRef(!1),jt=h.useRef(0),mn=h.useRef(0),[Hn,Nn]=h.useState(!1),[yn,Cn]=h.useState([]),[Jt,cr]=h.useState([]),[hn,Wn]=h.useState({}),[vn,Ln]=h.useState(!1),[ne,ge]=h.useState(!1),[Te,qe]=h.useState(!1),[He,ot]=h.useState([]),[pt,vt]=h.useState([]),zt=h.useRef(0),ct=h.useRef(null);ct.current||(ct.current=new ug(_=>window.setTimeout(_,40),_=>ot(k=>k.concat(_))));const It=h.useRef(null);It.current||(It.current=new ug(_=>window.setTimeout(_,40),_=>vt(k=>k.concat(_))));const qt=h.useRef({scanned:0,found:null}),[ce,kt]=h.useState(null),[Lt,Ve]=h.useState(""),[en,_n]=h.useState(""),[ln,pn]=h.useState(!1),[er,Gr]=h.useState(!1),Cr=h.useRef(null),[Kr,Gs]=h.useState({}),[$s,gi]=h.useState({}),[Ks,Ir]=h.useState("now"),[sn,ea]=h.useState(""),[Yr,Ms]=h.useState("once"),[As,Ys]=h.useState(1),[st,tn]=h.useState("days"),[Er,yi]=h.useState(2),[yr,ta]=h.useState(""),[el,tl]=h.useState("23:59"),[qn,as]=h.useState(!0),[Yn,Xs]=h.useState(!1),[na,zn]=h.useState(""),[ls,Xn]=h.useState(!0),[cs,Dn]=h.useState(""),[us,Js]=h.useState(!1),[Kt,uo]=h.useState(!1),[ra,sa]=h.useState(6),[Dr,nl]=h.useState("standard"),[Zs,fo]=h.useState(""),[vi,tr]=h.useState(""),[nr,$r]=h.useState(!1),[wi,ds]=h.useState(!1),[Fr,fs]=h.useState("pause"),[rl,ms]=h.useState(""),[oc,Qs]=h.useState(""),[Ki,ia]=h.useState(""),xi=h.useRef(null),hs=h.useRef(null),[mo,ei]=h.useState(!1),vr=h.useRef(null),[wu,Ts]=h.useState(""),[ho,B]=h.useState(""),[ae,xe]=h.useState(""),[ke,Ee]=h.useState(""),[We,ft]=h.useState(""),[nt,ut]=h.useState(!1),[Dt,Vt]=h.useState("idle"),[Yt,Et]=h.useState([]),Zt=h.useRef(null),[En,cn]=h.useState(!1),[Br,Jn]=h.useState(""),[bi,Si]=h.useState(""),[_o,po]=h.useState(""),[xu,go]=h.useState([]),[sl,ac]=h.useState(!1),[Qd,lc]=h.useState(""),[bu,il]=h.useState(""),[cc,uc]=h.useState(!1),[ef,yo]=h.useState(""),dc=h.useMemo(()=>{if(!Yt.length)return"";try{return JSON.stringify(Yt.map(_=>({role:_.role,content:_.content,ts:_.ts})))}catch{return"1"}},[Yt]),Su=h.useMemo(()=>Yt.length?_o?dc!==_o:!0:!1,[dc,Yt.length,_o]),ju=h.useMemo(()=>xu.map(_=>{const k=String(_.title||"").trim()||`Chat ${String(_.thread_id||"").slice(0,8)}`,N=String(_.created_at||"").trim(),A=N?N.replace("T"," ").slice(0,19):"",U=String(_.run_id||"").trim()?String(_.run_id).slice(0,8):"",H=[k,A&&`(${A})`,U&&`run ${U}`].filter(Boolean).join(" • ");return{value:String(_.thread_id||""),label:H}}),[xu]);h.useEffect(()=>{a&&N0()},[a]),h.useEffect(()=>{if(!a)return;const _=d.current;_&&(_.token=n.gateway_auth_mode==="direct"&&n.auth_token||"")},[a,n.auth_token,n.gateway_auth_mode]);const[ku,fc]=h.useState([]),[rh,Nu]=h.useState({}),[sh,tf]=h.useState({}),[Cu,Wt]=h.useState(""),[Eu,$u]=h.useState(""),[Rs,ih]=h.useState("all"),[ol,nf]=h.useState("status"),[rr,Ls]=h.useState("overview"),[oa,aa]=h.useState(!0),[al,Mu]=h.useState("steps"),[oh,Au]=h.useState(""),[mc,vo]=h.useState(""),[la,hc]=h.useState([]),[ll,rf]=h.useState(!1),[sf,ca]=h.useState(""),[_c,pc]=h.useState(""),[of,gc]=h.useState([]),[ah,af]=h.useState(!1),[lh,Tu]=h.useState(""),[ch,Xr]=h.useState(!1),[cl,lf]=h.useState(""),[cf,wo]=h.useState(""),[Ru,ua]=h.useState(""),[uh,yc]=h.useState(!1),[Ps,xo]=h.useState(""),[ti,bo]=h.useState(null),[ul,da]=h.useState({}),[So,jo]=h.useState(!1),[Lu,Yi]=h.useState(""),[dl,uf]=h.useState(!1),[Pu,df]=h.useState(!1),[ff,fl]=h.useState(()=>Date.now()),[wr,Xi]=h.useState(""),[Ou,vc]=h.useState({}),[dh,ko]=h.useState({}),ml=h.useRef([]),Jr=h.useRef(null),ji=h.useRef(""),un=h.useRef({}),ki=h.useRef({}),fa=h.useRef({}),Ni=h.useRef(new Set),[ni,ma]=h.useState([]),Ci=h.useRef(""),Ei=h.useRef({}),Zr=h.useRef(null),Mr=h.useRef(null),No=h.useRef(0),ha=h.useRef({}),hl=h.useRef(!1),ri=h.useRef(new Set),[_a,pa]=h.useState(""),[_s,si]=h.useState(""),ps=h.useRef(""),[mf,wc]=h.useState(!1),[fh,xc]=h.useState(""),bc=()=>({artifact_id:"",kind:"binary",render_kind:"",text:"",url:"",loading:!1,error:""}),[gs,zu]=h.useState("activity"),[Ji,Os]=h.useState([]),[ga,ii]=h.useState(0),[Iu,hf]=h.useState(0),[mh,Zi]=h.useState({}),[_l,Co]=h.useState({}),[Sc,jc]=h.useState(!1),[ya,$i]=h.useState(""),[on,wn]=h.useState(""),[ys,sr]=h.useState("all"),[ur,Qi]=h.useState(""),[zs,Ur]=h.useState([]),[Eo,_f]=h.useState("all"),[$o,kc]=h.useState("type"),[pl,Mi]=h.useState("newest"),[Is,Nc]=h.useState(""),[va,gl]=h.useState(""),[Ai,eo]=h.useState(""),[oi,wa]=h.useState(0),[Ti,Hr]=h.useState(()=>bc()),[vs,ai]=h.useState(!1),[li,Ri]=h.useState(""),[Mo,to]=h.useState(""),[dr,xa]=h.useState(""),[Ar,Qr]=h.useState("text"),[$n,Wr]=h.useState(null),[pf,ba]=h.useState(!1),[Cc,Ao]=h.useState(""),[Du,yl]=h.useState(""),[gf,To]=h.useState(""),[Ec,yf]=h.useState(!1),[vl,wl]=h.useState(""),[xl,vf]=h.useState("run_ledger"),[Sa,wf]=h.useState(""),[$c,ja]=h.useState([]),[ka,bl]=h.useState(""),[Fu,Mc]=h.useState(!1),[Bu,no]=h.useState(""),Le=h.useMemo(()=>new Uh({base_url:n.gateway_auth_mode==="session"?"":n.gateway_url,auth_token:n.gateway_auth_mode==="session"?"":n.auth_token}),[n.gateway_auth_mode,n.gateway_url,n.auth_token]),Ro=h.useMemo(()=>_0(),[]),[Uu,Hu]=h.useState([]),ci=h.useRef(0);function ro(){const _=++ci.current;Hu([["Gateway","checking…"]]),p0(Le).then(k=>{_===ci.current&&Hu(k)})}const Na=h.useMemo(()=>n.worker_url.trim()?new NS({url:n.worker_url.trim(),auth_token:n.worker_token}):null,[n.worker_url,n.worker_token]),xr=He.length?He[He.length-1].record:null,Tt=h.useMemo(()=>Ui(xr),[xr]),Pn=h.useMemo(()=>{const _=S.trim();if(!P||!_||String(P.bundle_id||"").trim()&&String(P.bundle_id||"").trim()!==_)return null;const k=Array.isArray(P.entrypoints)?P.entrypoints:[];if(!k.length)return null;const N=b.trim();if(N)return k.find(U=>String(U.flow_id||"").trim()===N)||null;if(k.length===1)return k[0];const A=String(P.default_entrypoint||"").trim();return A&&k.find(U=>String(U.flow_id||"").trim()===A)||null},[P,S,b]),Ca=h.useMemo(()=>{const _=Pn==null?void 0:Pn.inputs;return Array.isArray(_)?_:[]},[Pn]),Wu=h.useMemo(()=>LE(ti),[ti]),Li=h.useMemo(()=>Ca.length?Ca:Wu,[Ca,Wu]),qu=h.useMemo(()=>{const _=typeof(ce==null?void 0:ce.workflow_id)=="string"?String(ce.workflow_id):"",k=f_(_);if(k&&P&&String(P.bundle_id||"").trim()===k.bundle_id){const U=(Array.isArray(P.entrypoints)?P.entrypoints:[]).find(H=>String((H==null?void 0:H.flow_id)||"").trim()===k.flow_id);if(U&&U.node_index&&typeof U.node_index=="object")return U.node_index}const N=Pn==null?void 0:Pn.node_index;return N&&typeof N=="object"?N:{}},[ce,P,Pn]);h.useEffect(()=>{DE(n)},[n]),h.useEffect(()=>()=>{Zr.current&&Zr.current.abort(),Mr.current&&Mr.current.abort(),xi.current&&window.clearTimeout(xi.current),hs.current&&window.clearTimeout(hs.current),Jr.current&&window.clearTimeout(Jr.current),vr.current&&window.clearTimeout(vr.current)},[]);const gt=h.useMemo(()=>{const _=T.trim();if(!_)return{};try{const k=JSON.parse(_);return typeof k!="object"||k===null||Array.isArray(k)?null:k}catch{return null}},[T]),ui=typeof(gt==null?void 0:gt.prompt)=="string"?String(gt.prompt):"",Lo=typeof(gt==null?void 0:gt.provider)=="string"?String(gt.provider):"",Sl=typeof(gt==null?void 0:gt.model)=="string"?String(gt.model):"",Po=typeof(gt==null?void 0:gt.workspace_root)=="string"?String(gt.workspace_root):"",Ac=typeof(gt==null?void 0:gt.workspace_access_mode)=="string"?String(gt.workspace_access_mode):"",Ea=h.useMemo(()=>{const _=gt==null?void 0:gt.workspace_allowed_paths;return Array.isArray(_)?_.map(k=>String(k||"").trim()).filter(Boolean).join(`
|
|
131
|
+
`):typeof _=="string"?String(_):""},[gt]),xf=h.useMemo(()=>{const _=gt==null?void 0:gt.workspace_ignored_paths;return Array.isArray(_)?_.map(k=>String(k||"").trim()).filter(Boolean).join(`
|
|
132
|
+
`):typeof _=="string"?String(_):""},[gt]),Vu=Li.length>0&&!!S.trim(),Sn=_=>{const k=String(_||"").trim().toLowerCase();return k==="object"||k==="memory"||k==="assertion"||k==="assertions"||k==="any"};h.useEffect(()=>{gi({})},[S,b]),h.useEffect(()=>{gt!==null&&Gs(_=>{const k={};for(const N of Li){if(!N||typeof N!="object")continue;const A=String(N.id||"").trim();if(!A)continue;const U=String(N.type||"").trim();if(!Sn(U))continue;if(String($s[A]||"").trim()){k[A]=typeof _[A]=="string"?_[A]:"";continue}const V=gt==null?void 0:gt[A];V===void 0?k[A]="":k[A]=C0(V)}return k})},[Li,gt,$s]);const Tc=S.trim()&&b.trim()?`${S.trim()}:${b.trim()}`:"",qr=h.useMemo(()=>{const _={};for(const k of wt){const N=String(k.workflow_id||"").trim(),A=String(k.label||"").trim();N&&A&&(_[N]=A)}return _},[wt]),jl=h.useMemo(()=>wt.filter(_=>_.has_interface),[wt]),Rc=h.useMemo(()=>{const _=new Set;for(const k of Array.isArray(Jt)?Jt:[]){const N=String((k==null?void 0:k.name)||"").trim();N&&_.add(N)}return Array.from(_).sort()},[Jt]),Gu=h.useMemo(()=>{const _=[];for(const k of Array.isArray(Jt)?Jt:[]){const N=String((k==null?void 0:k.name)||"").trim();if(!N)continue;const A=String((k==null?void 0:k.display_name)||"").trim();_.push({name:N,display_name:A||void 0})}return _},[Jt]),Oo=h.useMemo(()=>{const _=new Set;for(const k of yn||[]){if(!k||typeof k!="object")continue;const N=String(k.name||"").trim();N&&_.add(N)}return Array.from(_).sort()},[yn]),Mn=h.useMemo(()=>{const _=n.maintenance_ai_provider.trim();if(!_)return{models:[],error:""};const k=hn[_];return k?{models:(Array.isArray(k.models)?k.models:[]).map(A=>String(A||"").trim()).filter(Boolean),error:String(k.error||"")}:{models:[],error:""}},[hn,n.maintenance_ai_provider]),Fn=n.maintenance_ai_provider.trim(),ir=!!(Fn&&j&&!Object.prototype.hasOwnProperty.call(hn,Fn));h.useEffect(()=>{const _=Lo.trim();if(!_||hn[_]||Ei.current[_])return;Ei.current[_]=!0;let k=!1;return(async()=>{try{const A=await Le.discovery_provider_models(_);if(k)return;const U=Array.isArray(A==null?void 0:A.models)?A.models:[],H=typeof(A==null?void 0:A.error)=="string"?String(A.error):"";Wn(V=>({...V,[_]:{models:U,error:H||void 0}}))}catch(A){if(k)return;Wn(U=>({...U,[_]:{models:[],error:String((A==null?void 0:A.message)||A||"Failed to load models")}}))}finally{delete Ei.current[_]}})(),()=>{k=!0}},[Lo,hn,Le]),h.useEffect(()=>{const _=n.maintenance_ai_provider.trim();if(!_||!j||hn[_]||Ei.current[_])return;Ei.current[_]=!0;let k=!1;return(async()=>{try{const A=await Le.discovery_provider_models(_);if(k)return;const U=Array.isArray(A==null?void 0:A.models)?A.models:[],H=typeof(A==null?void 0:A.error)=="string"?String(A.error):"";Wn(V=>({...V,[_]:{models:U,error:H||void 0}}))}catch(A){if(k)return;Wn(U=>({...U,[_]:{models:[],error:String((A==null?void 0:A.message)||A||"Failed to load models")}}))}finally{delete Ei.current[_]}})(),()=>{k=!0}},[n.maintenance_ai_provider,hn,Le,j]);function xn(_,k){const N=String(_||"").trim();if(!N)return;let A={};try{const U=JSON.parse(T||"{}");typeof U=="object"&&U!==null&&!Array.isArray(U)&&(A=U)}catch{A={}}if(k==null){delete A[N],D(JSON.stringify(A,null,2));return}if(typeof k=="string")k?A[N]=k:delete A[N];else if(Array.isArray(k)){const U=k.map(H=>H).filter(H=>H!=null);U.length?A[N]=U:delete A[N]}else A[N]=k;D(JSON.stringify(A,null,2))}async function $a(_){const k=String(_||"").trim();if(!k)return ue("Missing bundle_id"),null;ue(""),Z(!0);try{const N=await Le.get_bundle(k);return K(N),Xt({ts:Nt(),kind:"info",title:`Loaded bundle ${k}`}),N}catch(N){return K(null),ue(String((N==null?void 0:N.message)||N||"Failed to load bundle")),null}finally{Z(!1)}}function zo(_){const k=[],N=Array.isArray(_==null?void 0:_.items)?_.items:[];for(const A of N){const U=String((A==null?void 0:A.bundle_id)||"").trim();if(!U)continue;const H=Array.isArray(A==null?void 0:A.entrypoints)?A.entrypoints:[];if(H.length)for(const V of H){const J=String((V==null?void 0:V.flow_id)||"").trim();if(!J||(V==null?void 0:V.deprecated)===!0)continue;const Se=`${U}:${J}`,ie=String((V==null?void 0:V.name)||"").trim(),W=ie?`${U} · ${ie}`:`${U} · ${J}`,we=String((V==null?void 0:V.description)||"").trim(),Pe=(Array.isArray(V==null?void 0:V.interfaces)?V.interfaces:[]).some(ze=>String(ze||"").trim().length>0);k.push({workflow_id:Se,bundle_id:U,flow_id:J,label:W,description:we||void 0,has_interface:Pe})}}return k.sort((A,U)=>A.label.localeCompare(U.label)),k}async function Tr(_=Le,k){if(Kn.current&&!(k!=null&&k.force))return;Kn.current=!0;const N=Do.current;ve(!0);try{const A=ie=>ie.map(W=>{var we,Ae,Pe,ze,Ue,St;return{run_id:String((W==null?void 0:W.run_id)||"").trim(),workflow_id:typeof(W==null?void 0:W.workflow_id)=="string"?String(W.workflow_id):(W==null?void 0:W.workflow_id)??null,status:typeof(W==null?void 0:W.status)=="string"?String(W.status):"",created_at:typeof(W==null?void 0:W.created_at)=="string"?String(W.created_at):(W==null?void 0:W.created_at)??null,updated_at:typeof(W==null?void 0:W.updated_at)=="string"?String(W.updated_at):(W==null?void 0:W.updated_at)??null,ledger_len:typeof(W==null?void 0:W.ledger_len)=="number"?Number(W.ledger_len):(W==null?void 0:W.ledger_len)??null,parent_run_id:typeof(W==null?void 0:W.parent_run_id)=="string"?String(W.parent_run_id):(W==null?void 0:W.parent_run_id)??null,session_id:typeof(W==null?void 0:W.session_id)=="string"?String(W.session_id):(W==null?void 0:W.session_id)??null,is_scheduled:typeof(W==null?void 0:W.is_scheduled)=="boolean"?!!W.is_scheduled:(W==null?void 0:W.is_scheduled)??null,paused:typeof(W==null?void 0:W.paused)=="boolean"?!!W.paused:(W==null?void 0:W.paused)??null,waiting_reason:typeof((we=W==null?void 0:W.waiting)==null?void 0:we.reason)=="string"?String(W.waiting.reason):((Ae=W==null?void 0:W.waiting)==null?void 0:Ae.reason)??null,schedule_interval:typeof((Pe=W==null?void 0:W.schedule)==null?void 0:Pe.interval)=="string"?String(W.schedule.interval).trim():((ze=W==null?void 0:W.schedule)==null?void 0:ze.interval)??null,schedule_target_workflow_id:typeof((Ue=W==null?void 0:W.schedule)==null?void 0:Ue.target_workflow_id)=="string"?String(W.schedule.target_workflow_id).trim():((St=W==null?void 0:W.schedule)==null?void 0:St.target_workflow_id)??null,current_node:typeof(W==null?void 0:W.current_node)=="string"?String(W.current_node).trim():(W==null?void 0:W.current_node)??null,llm_calls:typeof(W==null?void 0:W.llm_calls)=="number"?Number(W.llm_calls):(W==null?void 0:W.llm_calls)??null,tool_calls:typeof(W==null?void 0:W.tool_calls)=="number"?Number(W.tool_calls):(W==null?void 0:W.tool_calls)??null,tokens_total:typeof(W==null?void 0:W.tokens_total)=="number"?Number(W.tokens_total):(W==null?void 0:W.tokens_total)??null,error:(W==null?void 0:W.error)??null,waiting:(W==null?void 0:W.waiting)??null}}).filter(W=>!!W.run_id),[U,H]=await Promise.all([_.list_runs({limit:200,root_only:!0,include_metrics:!0}),_.list_runs({limit:500,root_only:!1,include_metrics:!0})]);if(N!==Do.current)return;const V=Array.isArray(U==null?void 0:U.items)?U.items:[],J=Array.isArray(H==null?void 0:H.items)?H.items:[],Se=A(V).filter(ie=>!String(ie.parent_run_id||"").trim());rt(Se),Oe(A(J).filter(ie=>!!ie.run_id)),Ge(Date.now()),mn.current=0,jt.current=0}catch(A){const U=String((A==null?void 0:A.message)||A||"");if(Xt({ts:Nt(),kind:"error",title:"Refresh runs failed",preview:_t(U)}),(/\b40[13]\b/.test(U)||/unauthorized|forbidden/i.test(U))&&z.refresh().catch(()=>{}),/\b429\b/.test(U)||/too many requests/i.test(U)){const H=Math.min(12e4,Math.max(15e3,mn.current*2||15e3));mn.current=H,jt.current=Date.now()+H,Xt({ts:Nt(),kind:"info",title:`Gateway rate-limited — pausing polls ${Math.round(H/1e3)}s`})}}finally{Kn.current=!1,ve(!1)}}async function fr(_){var V,J;const k=Do.current;L(!0),Wn({});const[N,,A,U]=await Promise.allSettled([_.list_bundles(),Tr(_),_.discovery_tools(),_.discovery_providers({include_models:!1})]);if(k!==Do.current)return;if(N.status==="rejected"&&A.status==="rejected"&&U.status==="rejected"){L(!1),E(__(N.reason,n)),Xt({ts:Nt(),kind:"error",title:"Discovery failed",preview:_t(String(N.reason||""))});return}let H=0;if(N.status==="fulfilled"){const Se=zo(N.value);H=Se.length,lt(Se)}else lt([]),Xt({ts:Nt(),kind:"error",title:"Discovery bundles failed",preview:_t(String(N.reason||""))});if(A.status==="fulfilled"){const Se=Array.isArray((V=A.value)==null?void 0:V.items)?A.value.items:[];Cn(Se)}else Cn([]),Xt({ts:Nt(),kind:"error",title:"Discovery tools failed",preview:_t(String(A.reason||""))});if(U.status==="fulfilled"){const Se=Array.isArray((J=U.value)==null?void 0:J.items)?U.value.items:[];cr(Se)}else cr([]),Xt({ts:Nt(),kind:"error",title:"Discovery providers failed",preview:_t(String(U.reason||""))});Xt({ts:Nt(),kind:"info",title:"Gateway discovery loaded",preview:_t(`workflows: ${H}`)})}async function Io(_){var k,N;E(""),L(!1),pe(!0);try{if(!(_!=null&&_.prefer_direct)&&(await z.refresh(),kl.current))return;const A=String(n.auth_token||"").trim();if(!A){_!=null&&_.open_modal_if_needed&&z.openModal();return}const U=String(n.gateway_url||"").trim();if(U){const V=U.toLowerCase();if(!V.startsWith("http://")&&!V.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(((k=window==null?void 0:window.location)==null?void 0:k.protocol)||"")==="https:"&&V.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 Se=new URL(U),ie=String(((N=window==null?void 0:window.location)==null?void 0:N.hostname)||"").trim().toLowerCase(),W=String(Se.hostname||"").trim().toLowerCase(),we=Ae=>Ae==="localhost"||Ae==="127.0.0.1"||Ae==="::1";if(we(W)&&ie&&!we(ie))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(J){throw new Error(String((J==null?void 0:J.message)||J||"Invalid Gateway URL"))}}const H=new Uh({base_url:U,auth_token:A});await H.list_bundles(),o(V=>({...V,gateway_auth_mode:"direct"})),await fr(H)}catch(A){E(__(A,n))}finally{pe(!1)}}const kl=h.useRef(!1),Do=h.useRef(0),ws=h.useRef(!1);function xs(_){var N,A,U;I(_);const k=!!(_&&_.has_session&&((N=_.gateway)!=null&&N.ok));if(kl.current=k,k){if(ws.current=!1,j&&n.gateway_auth_mode==="direct")return;const H=String(((U=(A=_==null?void 0:_.gateway)==null?void 0:A.principal)==null?void 0:U.user_id)||"").trim();if(o(V=>({...V,gateway_auth_mode:"session",auth_token:"",gateway_user:H||V.gateway_user})),j&&n.gateway_auth_mode==="session")return;E(""),pe(!0),fr(new Uh({base_url:"",auth_token:""})).catch(V=>E(__(V,n))).finally(()=>pe(!1));return}_&&!_.has_session&&(n.gateway_auth_mode==="session"&&Cl({keep_session:!0}),String(n.auth_token||"").trim()&&!j&&!ws.current&&(ws.current=!0,Io({prefer_direct:!0})))}async function Nl(){if(!(Hn||de)){Nn(!0);try{await Le.reload_bundles();const _=await Le.list_bundles(),k=zo(_);lt(k),Xt({ts:Nt(),kind:"info",title:"Bundles reloaded",preview:_t(`workflows: ${k.length}`)})}catch(_){const k=String((_==null?void 0:_.message)||_||"Bundle reload failed");Xt({ts:Nt(),kind:"error",title:"Bundle reload failed",preview:_t(k),data:{error:k}})}finally{Nn(!1)}}}async function Ku(_){if(er||de||!j)return;const k=_;if(k){Gr(!0),Wt("");try{const N=await Le.upload_bundle(k,{overwrite:!1,reload:!0});Xt({ts:Nt(),kind:"info",title:"Bundle uploaded",preview:_t(String((N==null?void 0:N.bundle_ref)||""))});const A=await Le.list_bundles(),U=zo(A);lt(U)}catch(N){const A=String((N==null?void 0:N.message)||N||"Upload failed");Wt(A),Xt({ts:Nt(),kind:"error",title:"Upload .flow failed",preview:_t(A),data:{error:A}})}finally{Gr(!1);try{Cr.current&&(Cr.current.value="")}catch{}}}}function Cl(_){Do.current+=1,_!=null&&_.keep_session||(z.signOut().catch(()=>{}),kl.current=!1),Tf(),R(""),C(""),xo(""),K(null),ue(""),Z(!1),lt([]),rt([]),Oe([]),Ge(null),Bt([]),Cn([]),cr([]),Wn({}),E(""),L(!1),I(null),o(k=>({...k,auth_token:""})),Xt({ts:Nt(),kind:"info",title:"Gateway disconnected"})}async function Lc(_){const k=String(_??"");if(k){try{await navigator.clipboard.writeText(k),An("Copied to clipboard",2);return}catch{}try{const N=document.createElement("textarea");N.value=k,N.style.position="fixed",N.style.left="-9999px",N.style.top="0",N.style.opacity="0",document.body.appendChild(N),N.focus(),N.select(),document.execCommand("copy"),document.body.removeChild(N),An("Copied to clipboard",2)}catch{An("Copy failed",2)}}}h.useEffect(()=>{const _=u.trim();if(!vn||!_)return;let k=!1;const N=async()=>{if(!(jt.current>Date.now()))try{const U=await Le.get_run(_);k||kt(U)}catch{}};N();const A=window.setInterval(N,2e3);return()=>{k=!0,window.clearInterval(A)}},[vn,u,Le]),h.useEffect(()=>{if(!j)return;let _=null,k=!1,N=!1;const A=V=>{k||(_!==null&&window.clearTimeout(_),_=window.setTimeout(()=>void U(),V))},U=async()=>{if(N)return;const V=jt.current-Date.now();if(V>0){A(V+500);return}N=!0;const J=Date.now();try{await Tr(Le)}finally{N=!1;const Se=Date.now()-J,ie=document.visibilityState==="hidden"?3e4:5e3;A(Math.max(ie,Se*3))}},H=()=>{document.visibilityState==="visible"&&U()};return U(),document.addEventListener("visibilitychange",H),()=>{k=!0,_!==null&&window.clearTimeout(_),document.removeEventListener("visibilitychange",H)}},[j,Le]);const[bf,Pc]=h.useState(null);h.useEffect(()=>{if(!j){Pc(null);return}let _=!1;return(async()=>{try{const k=await Le.get_entity_phases_spec();if(_)return;const N=vE(k);if(Pc(N),N)try{const A=localStorage.getItem("abstractobserver_phase_graph_id_v1"),U=A?JSON.parse(A):null;U&&U.sha256&&N.sha256&&U.sha256!==N.sha256&&U.version===N.version&&Xt({ts:Nt(),kind:"error",title:"Phase-graph drift: served bytes changed without a version bump",preview:_t(`v${N.version}: ${String(U.sha256).slice(0,12)}… -> ${String(N.sha256).slice(0,12)}…`),data:{prev:U,now:{sha256:N.sha256,version:N.version}}}),localStorage.setItem("abstractobserver_phase_graph_id_v1",JSON.stringify({sha256:N.sha256,version:N.version}))}catch{}}catch(k){if(!_){Pc(null);const N=String((k==null?void 0:k.message)||k||"");/404|not found/i.test(N)||Xt({ts:Nt(),kind:"info",title:"Phase-graph fetch failed — pre-wire fallback vocabulary in use (#FALLBACK)",preview:_t(N),data:{error:N}})}}})(),()=>{_=!0}},[j]),h.useEffect(()=>{if(!j){Bt([]),fn("");return}let _=!1,k=null;const N=async()=>{if(!(jt.current>Date.now())){try{const A=await Le.list_entities(),U=A.entities.map(V=>String((V==null?void 0:V.name)||(V==null?void 0:V.slug)||"").trim()).filter(Boolean).slice(0,12),H=await Promise.all(U.map(async V=>{var J,Se;try{const[ie,W]=await Promise.all([Le.get_entity_card(V),Le.get_entity_cognition(V).catch(()=>null)]),we=ie!=null&&ie.state&&typeof ie.state=="object"?ie.state:null,Ae=Array.isArray(ie==null?void 0:ie.moments)?ie.moments:[],Pe=Ae.length?Ae[Ae.length-1]:null,ze=(J=W==null?void 0:W.spend)==null?void 0:J.lifetime,Ue=(Se=W==null?void 0:W.spend)==null?void 0:Se.live_visit,St=Array.isArray(W==null?void 0:W.warnings)?W.warnings.map(Be=>String(Be||"")).filter(Boolean):[],xt=aE(ie);return{name:V,state:String((we==null?void 0:we.state)??(typeof(ie==null?void 0:ie.state)=="string"?ie.state:"")).trim(),age_days:typeof(ie==null?void 0:ie.age_days)=="number"?ie.age_days:null,last_moment:String((Pe==null?void 0:Pe.kind)||"").trim(),last_moment_at:String((Pe==null?void 0:Pe.at)||"").trim(),working:typeof(W==null?void 0:W.working)=="boolean"?W.working:null,tokens_total:typeof(ze==null?void 0:ze.tokens_total)=="number"?ze.tokens_total:null,live_visit_tokens:typeof(Ue==null?void 0:Ue.tokens_total)=="number"?Ue.tokens_total:null,spend_warning:St.join(" | "),live_phase:typeof(W==null?void 0:W.phase)=="string"?W.phase:"",open_questions:xt.questions,open_questions_total:xt.questions_total,open_problems:xt.problems,open_problems_total:xt.problems_total,lessons:xt.lessons,lessons_total:xt.lessons_total,dreams_brief:oE(ie),error:""}}catch(ie){return{name:V,state:"",age_days:null,last_moment:"",last_moment_at:"",working:null,tokens_total:null,live_visit_tokens:null,spend_warning:"",live_phase:"",open_questions:[],open_questions_total:0,open_problems:[],open_problems_total:0,lessons:[],lessons_total:0,dreams_brief:null,error:String((ie==null?void 0:ie.message)||ie||"card failed")}}}));_||(Bt(H),Ft(A.entities.length),fn(""))}catch(A){if(!_){Bt([]);const U=String((A==null?void 0:A.message)||A||"");fn(/404|not found/i.test(U)?"":U)}}_||(k=window.setTimeout(()=>void N(),3e4))}};return N(),()=>{_=!0,k!==null&&window.clearTimeout(k)}},[j,Le]);async function Sf(_,k,N){const A=String(k||"").trim();if(!_||!A)throw new Error("This wait has no wait_key yet — open the run to inspect.");await Le.submit_command({command_id:ss(),run_id:_,type:"resume",payload:{wait_key:A,payload:N||{}},client_id:"web_pwa"}),Xt({ts:Nt(),kind:"info",title:"Board resume submitted",preview:_t(`run ${_} · wait ${A}`),data:{run_id:_,wait_key:A}}),Tr(Le,{force:!0}),window.setTimeout(()=>void Tr(Le,{force:!0}),1200)}const bs=h.useMemo(()=>{const _=ce==null?void 0:ce.session_id;return typeof _=="string"?_.trim():_==null?"":String(_||"").trim()},[ce]),Fo=h.useMemo(()=>{const _=String(bs||"").trim();return _||String(q||"").trim()},[bs,q]);h.useEffect(()=>{if(!j||!Fo){ft(""),Ee("");return}(async()=>{try{const _=await vy(Fo);ft(_)}catch{ft("")}})()},[j,Fo]);const Bn=TE({gateway:j?Le:null,session_id:Fo,run_id:We,on_error:Ee,on_transcript:_=>{const k=String(_||"").trim();k&&(B(N=>{const A=String(N||"");return A.trim()?`${A.trimEnd()}
|
|
133
|
+
${k}`:k}),window.setTimeout(()=>{var N;return(N=Zt.current)==null?void 0:N.focus()},0))}});function Yu(_,k){try{const N=URL.createObjectURL(_),A=document.createElement("a");A.href=N,A.download=k||"download",A.rel="noreferrer",document.body.appendChild(A),A.click(),document.body.removeChild(A),window.setTimeout(()=>URL.revokeObjectURL(N),5e3)}catch{}}async function Ma(){if(!ll){if(!j||!bs){vo(""),hc([]),ca("");return}rf(!0),ca("");try{const _=await vy(bs);vo(_);const k=await Le.list_run_artifacts(_,{limit:800}),A=(Array.isArray(k==null?void 0:k.items)?k.items:[]).filter(U=>{const H=U==null?void 0:U.tags;return H&&typeof H=="object"&&String(H.kind||"").trim()==="attachment"});hc(A)}catch(_){const k=String((_==null?void 0:_.message)||_||"Failed to load session attachments"),N=k.toLowerCase();k.includes("404")||N.includes("session_memory_")&&N.includes("not found")||N.includes('"detail"')&&N.includes("not found")&&N.includes("session_memory_")?(hc([]),ca("")):(hc([]),ca(k)),vo("")}finally{rf(!1)}}}async function jf(){const _=_c.trim();if(!_){An("This run recorded no workspace folder",2);return}try{const k=await fetch("/api/local/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:_})}),N=await k.json().catch(()=>({}));k.ok&&(N!=null&&N.ok)?An(`Opened ${String(N.path||_)}`,2):An(String((N==null?void 0:N.error)||`Folder reveal failed (${k.status})`),3)}catch(k){An(String((k==null?void 0:k.message)||k||"Folder reveal failed"),3)}}async function Oc(_){const k=String(mc||"").trim();if(!k){An("No session attachment store yet",2);return}const N=String((_==null?void 0:_.artifact_id)||"").trim();if(!N)return;const A=_!=null&&_.tags&&typeof _.tags=="object"?_.tags:{},U=String(A.filename||"").trim(),H=String(A.path||"").trim(),V=U||(H?H.split("/").pop():"")||N,J=Dh(V);try{const Se=await Le.download_run_artifact_content(k,N,{access:"download"});Yu(Se,J),An("Downloaded attachment",2)}catch(Se){An(String((Se==null?void 0:Se.message)||Se||"Download failed"),3)}}async function zc(_){const k=String(mc||"").trim(),N=String((_==null?void 0:_.artifact_id)||"").trim();if(!k||!N)return;const A=_!=null&&_.tags&&typeof _.tags=="object"?_.tags:{},U=String(A.filename||"").trim(),H=String(A.path||"").trim(),V=H?`@${H}`:U||N,J=typeof(_==null?void 0:_.size_bytes)=="number"?Number(_.size_bytes):null,Se=String((_==null?void 0:_.content_type)||A.content_type||"").trim().toLowerCase();if(lf(V),wo(""),ua(""),Xr(!0),typeof J=="number"&&J>1e6){wo(`(Attachment is ${J.toLocaleString()} bytes; download to view.)`);return}if(!(!Se||Se.startsWith("text/")||Se.includes("json")||Se.includes("yaml")||Se.includes("toml")||Se.includes("xml"))){wo(`(Binary attachment: ${Se||"unknown"}; download to view.)`);return}yc(!0);try{const we=await(await Le.download_run_artifact_content(k,N,{access:"download"})).text(),Ae=14e3,Pe=we.length>Ae?`${we.slice(0,Math.max(0,Ae-1))}…`:we;wo(Pe)}catch(W){ua(String((W==null?void 0:W.message)||W||"Preview failed"))}finally{yc(!1)}}async function Xu(_){const k=String((_==null?void 0:_.run_id)||"").trim(),N=String((_==null?void 0:_.artifact_id)||"").trim();if(!k||!N){An("Artifact download needs a run id",3);return}const A=j_(_)||N;try{const U=await Le.download_run_artifact_content(k,N,{access:"preview"});Yu(U,Dh(A)),An("Downloaded artifact",2)}catch(U){An(String((U==null?void 0:U.message)||U||"Download failed"),3)}}async function Ic(_){const k=String((_==null?void 0:_.run_id)||"").trim(),N=String((_==null?void 0:_.artifact_id)||"").trim();if(!k||!N){An("Artifact preview needs a run id",3);return}const A=j_(_),U=String((_==null?void 0:_.content_type)||"").trim().toLowerCase(),H=Ld(_),J=H==="text"&&Pd(_,"")==="html"?window.open("about:blank","_blank"):null;if(J&&(J.document.write('<!doctype html><title>Loading artifact preview...</title><body style="font:14px system-ui;padding:24px">Loading artifact preview...</body>'),J.document.close()),Ri(A||N),to(""),Ao(""),Qr(H),Wr(_),ai(!0),dr&&(URL.revokeObjectURL(dr),xa("")),H==="binary"){to(`(Binary artifact: ${U||"unknown"}; download to view.)`);return}if(H==="text"&&typeof _.size_bytes=="number"&&_.size_bytes>15e5){to(`(Text artifact is ${_.size_bytes.toLocaleString()} bytes; download to view.)`);return}ba(!0);try{const Se=await Le.download_run_artifact_content(k,N,{access:"preview"});if(H==="text"){const ie=await Se.text(),W=Pd(_,ie);if(W==="html"){const Ae=new Blob([ie],{type:U.includes("html")?String(_.content_type||"text/html"):"text/html;charset=utf-8"}),Pe=URL.createObjectURL(Ae),ze=J||window.open("about:blank","_blank");if(ze){ze.location.href=Pe,ai(!1),Wr(null),to(""),ba(!1),setTimeout(()=>URL.revokeObjectURL(Pe),300*1e3),An("Opened HTML preview",2);return}URL.revokeObjectURL(Pe),Ao("Browser blocked opening the HTML page. Showing highlighted source instead.")}else J&&J.close();const we=W==="json"?15e5:W==="markdown"?25e4:W==="html"?3e5:22e3;to(ie.length>we&&W!=="text"?`${Yl(_.size_bytes??ie.length)} ${W.toUpperCase()} artifact. Download to inspect it.`:ie.length>we?`${ie.slice(0,Math.max(0,we-1))}…`:ie)}else J&&J.close(),xa(URL.createObjectURL(Se))}catch(Se){J&&J.close(),Ao(String((Se==null?void 0:Se.message)||Se||"Preview failed"))}finally{ba(!1)}}h.useEffect(()=>()=>{dr&&URL.revokeObjectURL(dr)},[dr]);async function kf(_){const k=String(_.artifact_id||"").trim(),N=String(_.run_id||"").trim(),A=Ld(_);if(!N||!k)return{artifact_id:k,kind:A,render_kind:"",text:"Preview needs artifact run metadata.",url:"",loading:!1,error:""};if(A==="binary")return{artifact_id:k,kind:A,render_kind:"",text:`Preview unavailable for ${_.content_type||_.modality||"this artifact"}. Download to inspect it.`,url:"",loading:!1,error:""};if(A==="text"&&typeof _.size_bytes=="number"&&_.size_bytes>5e5)return{artifact_id:k,kind:A,render_kind:"",text:`${Yl(_.size_bytes)} text artifact. Use Preview for a larger view or Download to inspect locally.`,url:"",loading:!1,error:""};try{const U=await Le.download_run_artifact_content(N,k,{access:"preview"});if(A==="text"){const H=await U.text(),V=Pd(_,H),J=V==="json"?5e5:V==="markdown"?12e4:V==="html"?3e5:8e3;return{artifact_id:k,kind:A,render_kind:V,text:H.length>J&&V!=="text"?`${Yl(_.size_bytes??H.length)} ${V.toUpperCase()} artifact. Use Larger preview or Download to inspect it.`:H.length>J?`${H.slice(0,Math.max(0,J-1))}…`:H,url:"",loading:!1,error:""}}return{artifact_id:k,kind:A,render_kind:"",text:"",url:URL.createObjectURL(U),loading:!1,error:""}}catch(U){return{artifact_id:k,kind:A,render_kind:"",text:"",url:"",loading:!1,error:String((U==null?void 0:U.message)||U||"Preview failed")}}}async function Nf(_){if(Ti.url&&URL.revokeObjectURL(Ti.url),!_){Hr(bc());return}const k=String(_.artifact_id||"").trim(),N=Ld(_);Hr({artifact_id:k,kind:N,render_kind:"",text:"",url:"",loading:!0,error:""}),Hr(await kf(_))}h.useEffect(()=>{Ma()},[Le,j,bs]);function Xt(_){const k=String(_.id||"").trim()||ss();fc(N=>[{..._,id:k},...N].slice(0,800))}function An(_,k){ia(_),hs.current&&window.clearTimeout(hs.current),ei(!1),window.requestAnimationFrame(()=>ei(!0)),hs.current=window.setTimeout(()=>{ei(!1),hs.current=null},1500),xi.current&&(window.clearTimeout(xi.current),xi.current=null),k>0&&(xi.current=window.setTimeout(()=>{ia(""),xi.current=null},Math.max(1,k)*1e3))}function Rr(_,k){const N=String(_||"").trim(),A=String(k||"").trim();if(!A)return"";const U=N?String(un.current[N]||"").trim():"";return U?`${U}::${A}`:A}function Dc(_,k,N){const A=String(_||"").trim(),U=String(k||"").trim(),H=String(N||"").trim();if(!A||!U||!H)return;const V=Rr(A,U);V&&(un.current[H]=V,ki.current[H]=A,fa.current[H]={parent_run_id:A,parent_node_id:U},Ni.current.has(H)||(Ni.current.add(H),ma(J=>J.includes(H)?J:[...J,H])))}function El(_){const k=String(_||"").trim();if(!k)return;const N=Date.now(),A=ji.current;ji.current=k,fl(N),vc(U=>{const H={};for(const[ie,W]of Object.entries(U))typeof W=="number"&&W>N&&(H[ie]=W);H[k]=Math.max(H[k]||0,N+2e3),A&&A!==k&&(H[A]=Math.max(H[A]||0,N+2e3));const V=Object.keys(H);if(V.length<=200)return H;const J=V.sort((ie,W)=>(H[W]||0)-(H[ie]||0)).slice(0,200),Se={};for(const ie of J)Se[ie]=H[ie]||0;return Se}),ko(U=>{if(typeof U[k]=="number")return U;const H={...U,[k]:N};if(ml.current.push(k),ml.current.length>8e3){const V=ml.current.splice(0,1500);for(const J of V)delete H[J]}return H}),Jr.current&&window.clearTimeout(Jr.current),Jr.current=window.setTimeout(()=>{const U=Date.now();vc(H=>{const V={};for(const[J,Se]of Object.entries(H))typeof Se=="number"&&Se>U&&(V[J]=Se);return V}),fl(U),Jr.current=null},2200)}function Ju(_,k){var Ue,St,xt;const N=String(k||"").trim()||u.trim();zt.current=_.cursor,(Ue=ct.current)==null||Ue.push({cursor:_.cursor,record:_.record}),N&&ri.current.add(`${N}:${_.cursor}`);const A=im(_.record),U=A&&A.name?Md(A.name):"",H=_.record,V=typeof(H==null?void 0:H.node_id)=="string"?H.node_id:"",J=typeof(H==null?void 0:H.status)=="string"?H.status:"",Se=typeof((St=H==null?void 0:H.effect)==null?void 0:St.type)=="string"?H.effect.type:"",ie=typeof(H==null?void 0:H.run_id)=="string"?H.run_id:"",W=ie||N;if(U==="abstract.status"&&W===N){const{text:Be,duration:at}=Jc(A==null?void 0:A.payload);An(Be,at)}const we=V?Rr(W,V):"";if(J==="waiting"){const Be=Ui(H);if(String((Be==null?void 0:Be.reason)||"").trim()==="subworkflow"){const Je=typeof((xt=Be==null?void 0:Be.details)==null?void 0:xt.sub_run_id)=="string"?String(Be.details.sub_run_id):"";Je&&V&&Dc(W,V,Je)}}if(V&&(El(Rr(W,V)),J==="waiting"||J==="running")){const Be=Rr(W,V);Be&&(ji.current=Be,Xi(Be))}let Ae="step",Pe=we||V||"(node?)",ze="";if(A&&A.name&&h_(A.name))Ae=U==="abstract.message"?"message":"event",Pe=U||A.name,ze=_t(U==="abstract.steer_seen"?m_(A==null?void 0:A.payload):Jc(A==null?void 0:A.payload).text);else if(H!=null&&H.error)Ae="error",Pe="error",ze=_t(kr(H.error,360));else if(J==="waiting"){const Be=Ui(H),at=String((Be==null?void 0:Be.reason)||"").trim();ze=_t(at?`waiting • ${at}`:"waiting")}else H!=null&&H.result?ze=_t(kr(H.result,360)):Se?ze=_t(Se):ze=_t(bm(H));Xt({id:`step:${ie||N||"?"}:${_.cursor}`,ts:String((H==null?void 0:H.ended_at)||(H==null?void 0:H.started_at)||Nt()),kind:Ae,title:Pe,preview:ze,data:H,cursor:_.cursor,run_id:ie||N||void 0,node_id:we||V,status:J,effect_type:Se,emit_name:U||(A==null?void 0:A.name)||void 0})}function hh(_,k){var ze,Ue,St;No.current=Math.max(No.current,k.cursor);const N=`${_}:${k.cursor}`;if(!!ri.current.has(N))return;ri.current.add(N),(ze=It.current)==null||ze.push({run_id:_,cursor:k.cursor,record:k.record});const U=im(k.record),H=U&&U.name?Md(U.name):"",V=k.record,J=typeof(V==null?void 0:V.node_id)=="string"?V.node_id:"",Se=J?Rr(_,J):"",ie=typeof(V==null?void 0:V.status)=="string"?V.status:"",W=typeof((Ue=V==null?void 0:V.effect)==null?void 0:Ue.type)=="string"?V.effect.type:"";if(ie==="waiting"){const xt=Ui(V);if(String((xt==null?void 0:xt.reason)||"").trim()==="subworkflow"){const at=typeof((St=xt==null?void 0:xt.details)==null?void 0:St.sub_run_id)=="string"?String(xt.details.sub_run_id):"";at&&J&&Dc(_,J,at),at&&ps.current.trim()===String(_||"").trim()&&(ps.current=at,si(at))}}if(J&&(El(Rr(_,J)),ie==="waiting"||ie==="running")){const xt=Rr(_,J);xt&&(ji.current=xt,Xi(xt))}if((ie==="completed"||ie==="failed")&&ps.current.trim()===String(_||"").trim()){const xt=String(ki.current[String(_||"").trim()]||"").trim();xt&&xt!==u.trim()?(ps.current=xt,si(xt)):(ps.current="",si(""))}if(H==="abstract.status"&&_===u.trim()){const{text:xt,duration:Be}=Jc(U==null?void 0:U.payload);An(xt,Be)}let we="step",Ae=Se||J||"(node?)",Pe="";if(U&&U.name&&h_(U.name))we=H==="abstract.message"?"message":"event",Ae=`subrun • ${H||U.name}`,Pe=_t(H==="abstract.steer_seen"?m_(U==null?void 0:U.payload):Jc(U==null?void 0:U.payload).text);else if(V!=null&&V.error)we="error",Ae="error",Pe=_t(kr(V.error,360));else if(ie==="waiting"){const xt=Ui(V),Be=String((xt==null?void 0:xt.reason)||"").trim();Pe=_t(Be?`waiting • ${Be}`:"waiting")}else V!=null&&V.result?Pe=_t(kr(V.result,360)):W?Pe=_t(W):Pe=_t(bm(V));Xt({id:`step:${_}:${k.cursor}`,ts:String((V==null?void 0:V.ended_at)||(V==null?void 0:V.started_at)||Nt()),kind:we,title:Ae,preview:Pe,data:V,cursor:k.cursor,run_id:_,node_id:Se||J,status:ie,effect_type:W,emit_name:H||(U==null?void 0:U.name)||""})}function Cf(_,k){var Ue,St,xt;const N=String(_||"").trim();if(!N)return;const A=`${N}:${k.cursor}`;if(!!ri.current.has(A))return;ri.current.add(A),(Ue=It.current)==null||Ue.push({run_id:N,cursor:k.cursor,record:k.record});const H=im(k.record),V=H&&H.name?Md(H.name):"",J=k.record,Se=typeof(J==null?void 0:J.node_id)=="string"?J.node_id:"",ie=Se?Rr(N,Se):"",W=typeof(J==null?void 0:J.status)=="string"?J.status:"",we=typeof((St=J==null?void 0:J.effect)==null?void 0:St.type)=="string"?J.effect.type:"";if(W==="waiting"){const Be=Ui(J);if(String((Be==null?void 0:Be.reason)||"").trim()==="subworkflow"){const Je=typeof((xt=Be==null?void 0:Be.details)==null?void 0:xt.sub_run_id)=="string"?String(Be.details.sub_run_id):"";Je&&Se&&Dc(N,Se,Je)}}if(Se&&(El(Rr(N,Se)),W==="waiting"||W==="running")){const Be=Rr(N,Se);Be&&(ji.current=Be,Xi(Be))}if(V==="abstract.status"&&N===u.trim()){const{text:Be,duration:at}=Jc(H==null?void 0:H.payload);An(Be,at)}let Ae="step",Pe=ie||Se||"(node?)",ze="";if(H&&H.name&&h_(H.name))Ae=V==="abstract.message"?"message":"event",Pe=`subrun • ${V||H.name}`,ze=_t(V==="abstract.steer_seen"?m_(H==null?void 0:H.payload):Jc(H==null?void 0:H.payload).text);else if(J!=null&&J.error)Ae="error",Pe="error",ze=_t(kr(J.error,360));else if(W==="waiting"){const Be=Ui(J),at=String((Be==null?void 0:Be.reason)||"").trim();ze=_t(at?`waiting • ${at}`:"waiting")}else J!=null&&J.result?ze=_t(kr(J.result,360)):we?ze=_t(we):ze=_t(bm(J));Xt({id:`step:${N}:${k.cursor}`,ts:String((J==null?void 0:J.ended_at)||(J==null?void 0:J.started_at)||Nt()),kind:Ae,title:Pe,preview:ze,data:J,cursor:k.cursor,run_id:N,node_id:ie||Se,status:W,effect_type:we,emit_name:V||(H==null?void 0:H.name)||""})}async function Ef(_,k){var A,U;let N=k.after;for(;;){if((A=k.signal)!=null&&A.aborted)return N;const H=await Le.get_ledger(_,{after:N,limit:200,signal:k.signal});if((U=k.signal)!=null&&U.aborted)return N;const V=Array.isArray(H.items)?H.items:[];if(!V.length)return zt.current=N,N;const J=N;for(let Se=0;Se<V.length;Se++){const ie=V[Se];Ju({cursor:J+Se+1,record:ie},_)}N=typeof H.next_after=="number"?H.next_after:N}}async function Aa(_){var H,V,J,Se;const k=String(_||"").trim();Wt(""),ge(!0),Ln(!1),(H=ct.current)==null||H.reset(),(V=It.current)==null||V.reset(),qt.current={scanned:0,found:null},ot([]),zt.current=0,vt([]),ri.current=new Set,fc([]),Nu({}),tf({}),Mu("steps"),Au(""),ia(""),kt(null),Ts(""),pc(""),gc([]),Tu(""),Xi(""),ji.current="",vc({}),ko({}),ml.current=[],fl(Date.now()),un.current=k?{[k]:""}:{},ki.current={},fa.current={},Ni.current=new Set,ma([]),Ci.current="",ps.current="",si(""),ha.current={},Jr.current&&window.clearTimeout(Jr.current),Jr.current=null,vr.current&&window.clearTimeout(vr.current),vr.current=null,Zr.current&&Zr.current.abort(),Mr.current&&Mr.current.abort(),Mr.current=null,No.current=0,pa("");const N=new AbortController;Zr.current=N;let A=!1;try{let ie="",W="";try{const we=await Le.get_run(k);kt(we);const Ae=typeof(we==null?void 0:we.workflow_id)=="string"?String(we.workflow_id):"",Pe=f_(Ae);Pe&&(ie=Pe.bundle_id,W=Pe.flow_id)}catch{}try{const we=await Le.get_run_input_data(k);typeof(we==null?void 0:we.bundle_id)=="string"&&(ie=String(we.bundle_id||"").trim()||ie),typeof(we==null?void 0:we.flow_id)=="string"&&(W=String(we.flow_id||"").trim()||W);const Ae=we&&typeof we.input_data=="object"&&we.input_data&&!Array.isArray(we.input_data)?we.input_data:null;Ae&&D(JSON.stringify(Ae,null,2));const Pe=we==null?void 0:we.workspace,ze=typeof(Pe==null?void 0:Pe.workspace_root)=="string"?String(Pe.workspace_root).trim():"";pc(ze)}catch{pc("")}(async()=>{af(!0),Tu("");try{const we=await Le.list_run_artifacts(k,{limit:200}),Ae=Array.isArray(we==null?void 0:we.items)?we.items:[];N.signal.aborted||gc(Ae)}catch(we){N.signal.aborted||(gc([]),Tu(String((we==null?void 0:we.message)||we||"artifact listing failed")))}finally{N.signal.aborted||af(!1)}})(),ie&&W&&(R(ie),C(W),xo(W),await $a(ie)),await Ef(k,{after:0,signal:N.signal});try{const we=await Le.get_run_history_bundle(k,{include_subruns:!0,include_session:!1,ledger_mode:"tail",ledger_max_items:1}),Ae=we&&typeof we=="object"?we.ledgers:null,ze=(Ae&&typeof Ae=="object"?Object.keys(Ae):[]).map(Ue=>String(Ue||"").trim()).filter(Boolean).filter(Ue=>Ue!==k);if(ze.length){for(const Ue of ze)Ni.current.add(Ue);ma(Ue=>Array.from(new Set([...Ue,...ze])));try{const Ue=typeof((J=Ae==null?void 0:Ae[k])==null?void 0:J.total)=="number"?Number(Ae[k].total):0;let St="",xt=-1;for(const Be of ze){const at=typeof((Se=Ae==null?void 0:Ae[Be])==null?void 0:Se.total)=="number"?Number(Ae[Be].total):0;at>xt&&(St=Be,xt=at)}St&&xt>Math.max(Ue*3,Ue+20)&&(ps.current=St,si(St))}catch{}}}catch{}Ln(!0),Xt({ts:Nt(),kind:"info",title:`Attached to run ${k}`,data:{run_id:k}}),A=!0}catch(ie){const W=String((ie==null?void 0:ie.message)||ie||"unknown error");Wt(W),Xt({ts:Nt(),kind:"error",title:"Connection error",preview:_t(W),data:{error:W}}),Ln(!1)}finally{ge(!1)}if(!A||N.signal.aborted)return;(async()=>{let ie=250;for(;!N.signal.aborted;){try{const W=await Ef(k,{after:zt.current,signal:N.signal});await Le.stream_ledger(k,{after:W,on_step:we=>Ju(we,k),signal:N.signal})}catch(W){if(N.signal.aborted)break;const we=String((W==null?void 0:W.message)||W||"stream error");Xt({ts:Nt(),kind:"error",title:"Ledger stream error (will retry)",preview:_t(we),data:{error:we}})}if(N.signal.aborted)break;await new Promise(W=>setTimeout(W,ie)),ie=Math.min(5e3,Math.floor(ie*1.6))}})()}async function $f(){const _=b.trim(),k=S.trim();if(!_||!k){const N="Select a workflow first (Launch → pick a workflow).";return Wt(N),N}Wt(""),ge(!0);try{let N={};const A=T.trim();if(A)try{if(N=JSON.parse(A),typeof N!="object"||N===null||Array.isArray(N))throw new Error("input_data must be a JSON object")}catch(ie){const W=`Invalid input_data JSON: ${String((ie==null?void 0:ie.message)||ie)}`;return Wt(W),W}for(const[ie,W]of Object.entries(N)){if(typeof W!="string")continue;const we=W.trim();we?N[ie]=we:delete N[ie]}const U=(Li||[]).find(ie=>ie&&typeof ie=="object"&&ie.id==="prompt"),H=U&&typeof U=="object"&&Object.prototype.hasOwnProperty.call(U,"default"),V=N==null?void 0:N.prompt,J=typeof V=="string"?V.trim():"";if(U&&!H&&!J){const ie="Missing required input_data.prompt";return Wt(ie),ie}const Se=await Le.start_run(_,N,{bundle_id:k,session_id:String(q||"").trim()||null});return g(Se),m(Se),Ve(""),await Aa(Se),Tr(),null}catch(N){const A=String((N==null?void 0:N.message)||N||"start failed");return Wt(A),A}finally{ge(!1)}}async function Mf(_){const k=b.trim(),N=S.trim();if(!k||!N){const A="Select a workflow first (Launch → pick a workflow).";return Wt(A),A}if(ln)return"Schedule already in progress";_n(""),Wt(""),pn(!0),ge(!0);try{let A={};const U=T.trim();if(U)try{if(A=JSON.parse(U),typeof A!="object"||A===null||Array.isArray(A))throw new Error("input_data must be a JSON object")}catch(Je){const Rt=`Invalid input_data JSON: ${String((Je==null?void 0:Je.message)||Je)}`;return _n(Rt),Rt}const H=(Li||[]).find(Je=>Je&&typeof Je=="object"&&Je.id==="prompt"),V=H&&typeof H=="object"&&Object.prototype.hasOwnProperty.call(H,"default"),J=A==null?void 0:A.prompt,Se=typeof J=="string"?J.trim():"";if(H&&!V&&!Se){const Je="Missing required input_data.prompt";return _n(Je),Je}let ie=null,W=null;if(_.start_mode==="now")ie="now",W=new Date;else{const Je=String(_.start_at_local||"").trim();if(!Je){const kn="Pick a start date/time (or choose 'now').";return _n(kn),kn}const Rt=new Date(Je);if(!Number.isFinite(Rt.getTime())){const kn="Invalid start date/time";return _n(kn),kn}ie=Rt.toISOString(),W=new Date(ie)}const we=Number.isFinite(_.every_n)?_.every_n:1,Ae=Math.max(1,Math.min(1e4,Math.floor(we))),Pe=String(_.every_unit||"").trim();let ze="1d";Pe==="minutes"?ze=`${Ae}m`:Pe==="hours"?ze=`${Ae}h`:Pe==="days"?ze=`${Ae}d`:Pe==="weeks"?ze=`${Ae*7}d`:Pe==="months"&&(ze=`${Ae*30}d`);const Ue=_.repeat_mode,St=Ue==="once"?null:ze,xt=Ue==="count"?Math.max(1,Math.floor(Number.isFinite(_.repeat_count)?_.repeat_count:1)):null;let Be=null;if(Ue==="until"){const Je=String(_.repeat_until_date_local||"").trim(),Rt=String(_.repeat_until_time_local||"").trim()||"23:59";if(!Je){const Un="Pick an end date (Until).";return _n(Un),Un}const kn=new Date(`${Je}T${Rt}`);if(!Number.isFinite(kn.getTime())){const Un="Invalid end date/time";return _n(Un),Un}if(Be=kn.toISOString(),W&&Number.isFinite(W.getTime())&&kn.getTime()<W.getTime()){const Un="End date must be after the start date.";return _n(Un),Un}}const at=await Le.schedule_run({bundle_id:N,flow_id:k,input_data:A,start_at:ie,interval:St,repeat_count:xt,repeat_until:Be,share_context:!!_.share_context,session_id:String(q||"").trim()||null});return g(at),m(at),_n(""),await Aa(at),Tr(),null}catch(A){const U=String((A==null?void 0:A.message)||A||"schedule failed");return _n(U),Wt(U),U}finally{ge(!1),pn(!1)}}async function Af(){Ve(""),_n("");const k=Ks!=="now"||Yr!=="once"?await Mf({start_mode:Ks,start_at_local:sn,repeat_mode:Yr,every_n:As,every_unit:st,repeat_count:Er,repeat_until_date_local:yr,repeat_until_time_local:el,share_context:qn}):await $f();if(k){Ve(k);return}Ls("overview"),t("observe")}async function Pi(_,k){const N=String(_||"").trim();if(!N)return;if(ne){An(`Still attaching — retry in a moment (${$t(N,14)})`,2500);return}Wt("");const A=String((k==null?void 0:k.root_run_id)||N).trim()||N;g(A),m(N),await Aa(N)}h.useEffect(()=>{const _=String(v||"").trim();if(!_)return;let k=!1;return(async()=>{try{if(j||await Io({open_modal_if_needed:!0}),k)return;Ls("overview"),t("observe"),await Pi(_)}catch(N){k||Wt(String((N==null?void 0:N.message)||N||"Failed to attach run from URL"))}finally{k||w("")}})(),()=>{k=!0}},[v]);function Tf(){var _,k;Zr.current&&Zr.current.abort(),Zr.current=null,Mr.current&&Mr.current.abort(),Mr.current=null,No.current=0,pa(""),m(""),g(""),un.current={},ki.current={},fa.current={},Ni.current=new Set,ma([]),Ci.current="",ps.current="",si(""),ha.current={},Ts(""),Jr.current&&window.clearTimeout(Jr.current),Jr.current=null,vr.current&&window.clearTimeout(vr.current),vr.current=null,Ln(!1),ge(!1),qe(!1),zt.current=0,(_=ct.current)==null||_.reset(),(k=It.current)==null||k.reset(),qt.current={scanned:0,found:null},ot([]),vt([]),ri.current=new Set,kt(null),fc([]),Nu({}),Xi(""),ji.current="",vc({}),ko({}),ml.current=[],fl(Date.now()),An("",-1),Wt(""),wc(!1),xc(""),Et([]),B(""),xe(""),ut(!1),cn(!1),Jn(""),Si(""),po(""),go([]),ac(!1),lc(""),il(""),uc(!1),yo("")}h.useEffect(()=>{Et([]),B(""),xe(""),ut(!1),cn(!1),Jn(""),Si(""),po(""),go([]),ac(!1),lc(""),il(""),uc(!1),yo("")},[u]),h.useEffect(()=>{rr==="chat"&&u.trim()&&j&&$l()},[rr,u,j,ce==null?void 0:ce.workflow_id]);async function Rf(_,k,N){const A=String(_||"").trim();if(!A)return Wt("Missing run_id"),"Missing run_id";Wt("");try{const U={},H=String((N==null?void 0:N.reason)||"").trim();H&&(U.reason=H),await Le.submit_command({command_id:ss(),run_id:A,type:k,payload:U,client_id:"web_pwa"}),Xt({ts:Nt(),kind:"info",title:`${k} submitted`,preview:H?`reason: ${H}`:"",data:{run_id:A,type:k,reason:H}});try{if(A===u.trim()){const V=await Le.get_run(A);kt(V)}}catch{}return Tr(Le,{force:!0}),window.setTimeout(()=>void Tr(Le,{force:!0}),900),window.setTimeout(()=>void Tr(Le,{force:!0}),2400),null}catch(U){const H=String((U==null?void 0:U.message)||U||`${k} failed`);return Wt(H),H}}async function Lf(_,k){return Rf(u.trim(),_,k)}async function Ss(_,k="Stopped from AbstractObserver"){const N=String(_||"").trim();if(!N||!window.confirm(`Cancel run ${$t(N,24)}?`))return;await Rf(N,"cancel",{reason:k})||An("Cancel submitted",2)}async function Zu(){var N;const _=u.trim();if(!_){Wt("Select a run first.");return}if(!j){Wt("Connect to the gateway first.");return}if(Te)return;const k=String(((N=ce==null?void 0:ce.waiting)==null?void 0:N.reason)||"").trim().toLowerCase()||String(mr||"").trim().toLowerCase();if(!Bs||Ds||Oi||In.toLowerCase()!=="waiting"||k!=="until"){Wt("This run is not a scheduled wait that can be triggered now.");return}Wt(""),qe(!0);try{const A={payload:{mode:"run_now",requested_at:Nt()}},U=String(br||"").trim();U&&(A.wait_key=U),await Le.submit_command({command_id:ss(),run_id:_,type:"resume",payload:A,client_id:"web_pwa"}),Xt({ts:Nt(),kind:"info",title:"Scheduled run triggered",preview:_t(`run ${_}`),data:{run_id:_,until:On||null}});try{const H=await Le.get_run(_);kt(H)}catch{}}catch(A){Wt(String((A==null?void 0:A.message)||A||"Failed to trigger scheduled run"))}finally{qe(!1)}}async function Fc(_){const k=u.trim();if(!k)return Wt("Missing run_id"),"Missing run_id";if(us)return"Schedule update already in progress";const N=String(_.interval||"").trim();if(!/^\s*(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)\s*$/i.test(N)){const U="Invalid interval (expected like '20m', '1h', '0.5s', '250ms')";return Dn(U),U}Dn(""),Wt(""),Js(!0),ge(!0);try{await Le.submit_command({command_id:ss(),run_id:k,type:"update_schedule",payload:{interval:N,apply_immediately:_.apply_immediately!==!1},client_id:"web_pwa"}),Xt({ts:Nt(),kind:"info",title:"Schedule updated",preview:_t(`interval: ${N}`),data:{interval:N},run_id:k});try{const U=await Le.get_run(k);kt(U)}catch{}return null}catch(U){const H=String((U==null?void 0:U.message)||U||"update_schedule failed");return Dn(H),Wt(H),H}finally{ge(!1),Js(!1)}}async function Pf(_){const k=u.trim();if(!k)return Wt("Missing run_id"),"Missing run_id";if(nr)return"Compaction already in progress";const N=typeof(_==null?void 0:_.preserve_recent)=="number"?_.preserve_recent:ra,A=Math.max(0,Math.min(500,Math.floor(Number.isFinite(N)?N:6))),U=(_==null?void 0:_.compression_mode)||Dr,H=String((_==null?void 0:_.focus)??Zs??"").trim();tr(""),Wt(""),$r(!0),ge(!0);try{const V={preserve_recent:A,compression_mode:U};return H&&(V.focus=H),await Le.submit_command({command_id:ss(),run_id:k,type:"compact_memory",payload:V,client_id:"web_pwa"}),Xt({ts:Nt(),kind:"info",title:"Compaction requested",preview:_t(`mode: ${U} • preserve_recent: ${A}`),data:V,run_id:k}),null}catch(V){const J=String((V==null?void 0:V.message)||V||"compact_memory failed");return tr(J),Wt(J),J}finally{ge(!1),$r(!1)}}async function Of(){const _=u.trim();if(!_){xc("Missing run_id");return}if(!mf){xc(""),wc(!0);try{const k=n.maintenance_ai_provider.trim(),N=n.maintenance_ai_model.trim();await Le.generate_run_summary(_,{provider:k||void 0,model:N||void 0,include_subruns:!0}),Xt({ts:Nt(),kind:"info",title:"Summary generation requested",preview:_t(`run ${_}`)})}catch(k){xc(String((k==null?void 0:k.message)||k||"Failed to generate summary"))}finally{wc(!1)}}}async function zf(){const _=u.trim();if(!_){xe("Select a run first.");return}if(!j){xe("Connect to the gateway first.");return}const k=ho.trim();if(!k||nt)return;if(Bn.voice_ptt_busy){Ee("Wait for transcription to finish.");return}xe(""),Ee(""),ut(!0);const A={id:`local:${ss()}`,role:"user",content:k,ts:Nt()};Et(U=>[...U,A]),B("");try{const U=[...Yt,A].slice(-20).map(W=>({role:W.role,content:W.content})),H=n.maintenance_ai_provider.trim(),V=n.maintenance_ai_model.trim(),J=await Le.run_chat(_,{provider:H||void 0,model:V||void 0,include_subruns:!0,messages:U}),Se=String((J==null?void 0:J.answer)||"").trim()||"(empty response)",ie=String((J==null?void 0:J.generated_at)||"").trim()||Nt();Et(W=>[...W,{id:`local:${ss()}`,role:"assistant",content:Se,ts:ie}])}catch(U){xe(String((U==null?void 0:U.message)||U||"Chat failed")),Et(H=>[...H,{id:`local:${ss()}`,role:"assistant",content:"(error: failed to generate answer)",ts:Nt()}])}finally{ut(!1)}}function Qu(_){const k=String(_.id||_.ts||"").trim(),N=String(_.content||"").trim();!k||!N||(Ee(""),Bn.toggle_tts(k,N))}function Ta(_){const k=String(_.id||_.ts||"").trim(),N=Bn.tts_playback;return!k||!N.key||N.key!==k?"idle":N.status}function Bc(_){if(!Yt.length)return;const k=u.trim(),N=k?`Run ${k}`:"Chat",A=Ux(Yt.map(U=>({role:U.role,content:U.content,ts:U.ts})),{heading:N});if(_==="download"){const U=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-"),H=`abstractobserver-chat-${Dh(k||"run")}-${U}.md`;Hx({filename:H,text:A,mime:"text/markdown;charset=utf-8"});return}(async()=>{const U=await nc(A);Vt(U?"copied":"failed"),window.setTimeout(()=>Vt("idle"),900)})()}async function $l(){const _=typeof(ce==null?void 0:ce.workflow_id)=="string"?String(ce.workflow_id).trim():"";if(!_){go([]);return}if(j&&!sl){lc(""),ac(!0);try{const k=await Le.list_runs({limit:200,workflow_id:_,root_only:!0}),N=Array.isArray(k==null?void 0:k.items)?k.items:[],A=[];for(const ie of N){const W=typeof(ie==null?void 0:ie.run_id)=="string"?String(ie.run_id).trim():"";if(!W)continue;const we=typeof(ie==null?void 0:ie.ledger_len)=="number"?Number(ie.ledger_len):0;A.push({run_id:W,ledger_len:Number.isFinite(we)?we:0})}if(!A.length){go([]);return}const U=400,H=A.map(ie=>({run_id:ie.run_id,after:Math.max(0,(ie.ledger_len||0)-U)})),V=await Le.get_ledger_batch({runs:H,limit:U}),J=[],Se=new Set;for(const ie of A){const W=V!=null&&V.runs&&typeof V.runs=="object"?V.runs[ie.run_id]:null,we=Array.isArray(W==null?void 0:W.items)?W.items:[];for(const Ae of we){const Pe=Ae==null?void 0:Ae.effect;if(!Pe||typeof Pe!="object"||String(Pe.type||"")!=="emit_event")continue;const ze=Pe.payload;if(!ze||typeof ze!="object"||String(ze.name||"")!=="abstract.chat.thread")continue;const Ue=ze.payload;if(!Ue||typeof Ue!="object")continue;const St=typeof Ue.thread_id=="string"?String(Ue.thread_id).trim():"";if(!St||Se.has(St))continue;Se.add(St);const xt=typeof Ue.created_at=="string"?String(Ue.created_at):"",Be=typeof Ue.title=="string"?String(Ue.title):"",at=typeof Ue.workflow_id=="string"?String(Ue.workflow_id):_,Je=typeof Ue.run_id=="string"?String(Ue.run_id):ie.run_id,Rt=typeof Ue.provider=="string"?String(Ue.provider):"",kn=typeof Ue.model=="string"?String(Ue.model):"",Un=typeof Ue.message_count=="number"?Number(Ue.message_count):null,Ws=Ue.chat_artifact,Da=Ws&&typeof Ws=="object"&&typeof Ws.$artifact=="string"?String(Ws.$artifact):"";Da&&J.push({thread_id:St,created_at:xt,title:Be||`Chat ${St.slice(0,8)}`,run_id:Je,workflow_id:at,message_count:Un,provider:Rt,model:kn,artifact_id:Da})}}J.sort((ie,W)=>String(W.created_at||"").localeCompare(String(ie.created_at||""))),go(J)}catch(k){lc(String((k==null?void 0:k.message)||k||"Failed to load saved discussions"))}finally{ac(!1)}}}async function _h(){const _=u.trim();if(!_){Jn("Select a run first.");return}if(!j){Jn("Connect to the gateway first.");return}if(Yt.length&&!En){Jn(""),cn(!0);try{const k=n.maintenance_ai_provider.trim(),N=n.maintenance_ai_model.trim(),A=await Le.save_chat_thread(_,{provider:k||void 0,model:N||void 0,include_subruns:!0,messages:Yt.map(V=>({role:V.role,content:V.content,ts:V.ts}))}),U=typeof(A==null?void 0:A.created_at)=="string"?String(A.created_at):Nt();Si(U);try{const V=JSON.stringify(Yt.map(J=>({role:J.role,content:J.content,ts:J.ts})));po(V)}catch{po("1")}typeof(A==null?void 0:A.thread_id)=="string"&&String(A.thread_id).trim()&&il(String(A.thread_id).trim());const H=!!(A!=null&&A.duplicate);An(H?"Already saved":"Saved discussion",2),await $l()}catch(k){Jn(String((k==null?void 0:k.message)||k||"Failed to save discussion"))}finally{cn(!1)}}}async function If(){const _=String(bu||"").trim();if(!_)return;const k=xu.find(U=>String(U.thread_id||"").trim()===_)||null;if(!k){yo("Saved discussion not found (refresh list).");return}if(!j){yo("Connect to the gateway first.");return}if(cc)return;const N=Yt.length>0,A=(()=>{if(!N)return!1;if(!_o)return!0;try{return JSON.stringify(Yt.map(H=>({role:H.role,content:H.content,ts:H.ts})))!==_o}catch{return!0}})();if(!(N&&A&&!window.confirm("Replace the current chat with the selected saved discussion? Unsaved changes will be lost."))){yo(""),uc(!0);try{const H=await(await Le.download_run_artifact_content(k.run_id,k.artifact_id)).text(),V=JSON.parse(H),J=Array.isArray(V==null?void 0:V.messages)?V.messages:[],Se=typeof(V==null?void 0:V.created_at)=="string"?String(V.created_at):String(k.created_at||""),ie=[];for(let W=0;W<J.length;W++){const we=J[W];if(!we||typeof we!="object")continue;const Ae=String(we.role||"").trim()==="assistant"?"assistant":"user",Pe=typeof we.content=="string"?String(we.content):"";if(!Pe.trim())continue;const ze=typeof we.ts=="string"?String(we.ts):Se||Nt();ie.push({id:`thread:${_}:${W}`,role:Ae,content:Pe.trim(),ts:ze})}Et(ie),B(""),xe(""),Jn(""),Si(Se||"");try{const W=JSON.stringify(ie.map(we=>({role:we.role,content:we.content,ts:we.ts})));po(W)}catch{po("1")}An("Loaded discussion",2)}catch(U){yo(String((U==null?void 0:U.message)||U||"Failed to load saved discussion"))}finally{uc(!1)}}}async function Ml(_){const k=u.trim(),N=String((Tt==null?void 0:Tt.wait_key)||"").trim();if(!k||!N){Wt("No active wait to resume");return}if(String((Tt==null?void 0:Tt.reason)||"").trim()==="subworkflow"){Wt("This run is waiting on a subworkflow; attach to the child run instead of resuming manually.");return}Wt(""),qe(!0);try{await Le.submit_command({command_id:ss(),run_id:k,type:"resume",payload:{wait_key:N,payload:_||{}},client_id:"web_pwa"}),Xt({ts:Nt(),kind:"info",title:"Resume submitted",preview:_t(`wait_key: ${N}`),data:{wait_key:N,payload:_||{}}}),Ts(N);try{const A=await Le.get_run(k);kt(A)}catch{}Tr(Le,{force:!0}),window.setTimeout(()=>void Tr(Le,{force:!0}),900),window.setTimeout(()=>void Tr(Le,{force:!0}),2400),vr.current&&window.clearTimeout(vr.current),vr.current=window.setTimeout(()=>{Ts(A=>A===N?"":A)},2e3)}catch(A){Wt(String((A==null?void 0:A.message)||A||"resume failed"))}finally{qe(!1)}}async function Df(_){if(!Na){Wt("No worker configured");return}if(!Te){Wt(""),qe(!0);try{const k=[];for(const N of _){const A=await Na.call_tool(N);k.push(A)}await Ml({mode:"executed",results:k})}finally{qe(!1)}}}const so=h.useMemo(()=>yu(Tt),[Tt]),br=String((Tt==null?void 0:Tt.wait_key)||"").trim(),mr=String((Tt==null?void 0:Tt.reason)||"").trim(),On=typeof(Tt==null?void 0:Tt.until)=="string"?String(Tt.until):"",In=typeof(ce==null?void 0:ce.status)=="string"?String(ce.status):"",Oi=!!(ce!=null&&ce.paused),Ds=In==="completed"||In==="failed"||In==="cancelled",Ff=mr==="until"&&!!On,Al=!Ds&&nS(xr)&&(!!br||Ff),Bf=mr==="user",Tl=mr==="event"?Md(RE(br)):"",Uf=mr==="event"&&Tl==="abstract.ask",ed=so.length>0,td=Al&&br&&(Bf||Uf||ed)&&wu!==br&&e!=="board",io=typeof((Ia=Tt==null?void 0:Tt.details)==null?void 0:Ia.sub_run_id)=="string"?String(Tt.details.sub_run_id):"",Bo={run_id:u.trim(),workflow_id:typeof(ce==null?void 0:ce.workflow_id)=="string"?String(ce.workflow_id):null,status:In,created_at:typeof(ce==null?void 0:ce.created_at)=="string"?String(ce.created_at):null,updated_at:typeof(ce==null?void 0:ce.updated_at)=="string"?String(ce.updated_at):null,session_id:typeof(ce==null?void 0:ce.session_id)=="string"?String(ce.session_id):null,current_node:typeof(ce==null?void 0:ce.current_node)=="string"?String(ce.current_node):null},Uc=He.slice(-10).map(_=>{var k,N,A,U,H,V;return{cursor:_.cursor,node_id:String(((k=_.record)==null?void 0:k.node_id)||"").trim(),status:String(((N=_.record)==null?void 0:N.status)||"").trim(),effect_type:String(((U=(A=_.record)==null?void 0:A.effect)==null?void 0:U.type)||"").trim(),ts:String(((H=_.record)==null?void 0:H.ended_at)||((V=_.record)==null?void 0:V.started_at)||"").trim(),summary:uv(_.record)}}),nd=tp(Tt,so),rd=ov(Tt,so),Rl=av(Tt,gt),Ra=Rl.text,Hf=Rl.runtime_metadata,La=String((Tt==null?void 0:Tt.prompt)||"").trim(),sd=B0(gt,6),Hc=!!(La&&rv(La)),Fs=!!(La&&!Hc),ph=Fs?"Question from workflow":Ra&&Ra!==La?"Closest prior user request":"Request context",Wf=W0(gt,T),id=!!T.trim(),Vr=ce!=null&&ce.schedule&&typeof ce.schedule=="object"?ce.schedule:null,Uo=typeof(Vr==null?void 0:Vr.interval)=="string"?String(Vr.interval).trim():"",Ll=typeof(Vr==null?void 0:Vr.share_context)=="boolean"?!!Vr.share_context:null,hr=typeof(Vr==null?void 0:Vr.repeat_count)=="number"?Number(Vr.repeat_count):null,Bs=!!(ce!=null&&ce.is_scheduled)||!!Vr||typeof(ce==null?void 0:ce.workflow_id)=="string"&&String(ce.workflow_id).startsWith("scheduled:"),od=Bs&&!!Uo,Pl=Bs?Oi?"Resume schedule":"Suspend schedule":In==="running"&&!Oi?"Pause":"Resume",_r=Bs?Oi?"resume":"pause":Pl==="Pause"?"pause":"resume",gh=Bs?!u.trim()||ne||Te||Ds:!u.trim()||ne||Te||Ds||_r==="resume"&&!Oi,Ze=Bs&&!Oi&&!Ds&&!ne&&!Te&&In.toLowerCase()==="waiting"&&(String(((Kc=ce==null?void 0:ce.waiting)==null?void 0:Kc.reason)||"").trim().toLowerCase()==="until"||mr==="until")&&!!String(On||"").trim(),or=(Hl=ce==null?void 0:ce.limits)==null?void 0:Hl.tokens,Ho=typeof(or==null?void 0:or.pct)=="number"?Number(or.pct):null,ad=or==null?void 0:or.estimated_used,qf=(or==null?void 0:or.max_input_tokens)??(or==null?void 0:or.max_tokens),Ol=h.useMemo(()=>{const _=qt.current;He.length<_.scanned&&(_.scanned=0,_.found=null);for(let k=_.scanned;k<He.length;k++){const N=He[k],A=N==null?void 0:N.record;if(!A)continue;const U=im(A);if((U&&U.name?Md(U.name):"")!=="abstract.summary")continue;const V=U!=null&&U.payload&&typeof U.payload=="object"?U.payload:{},J=typeof(V==null?void 0:V.text)=="string"?String(V.text):"";J.trim()&&(_.found={cursor:N.cursor,ts:String((A==null?void 0:A.ended_at)||(A==null?void 0:A.started_at)||""),text:J,provider:typeof(V==null?void 0:V.provider)=="string"?String(V.provider):void 0,model:typeof(V==null?void 0:V.model)=="string"?String(V.model):void 0,generated_at:typeof(V==null?void 0:V.generated_at)=="string"?String(V.generated_at):void 0,source:V==null?void 0:V.source})}return _.scanned=He.length,_.found},[He]);h.useEffect(()=>{ps.current=_s.trim()},[_s]),h.useEffect(()=>{const _=u.trim(),k=io.trim();if(!(vn&&mr==="subworkflow"&&!!k&&k!==_)){Ci.current="",_s.trim()&&si("");return}Ci.current!==k&&(Ci.current=k,ps.current=k,si(k))},[vn,u,mr,io,_s]),h.useEffect(()=>{da({})},[S]);const zl=h.useMemo(()=>((Array.isArray(P==null?void 0:P.entrypoints)?P==null?void 0:P.entrypoints:[])||[]).map(k=>String((k==null?void 0:k.flow_id)||"").trim()).filter(Boolean),[P]),Us=h.useMemo(()=>{const _=String((ce==null?void 0:ce.workflow_id)||"").trim();return vn&&_.startsWith("scheduled:")?_:""},[vn,ce==null?void 0:ce.workflow_id]),Vf=h.useMemo(()=>{var V;if(!vn||!u.trim()||!Us.trim())return wr;const _=String((ce==null?void 0:ce.status)||"").trim().toLowerCase(),k=String((ce==null?void 0:ce.current_node)||"").trim();if(_!=="waiting"&&_!=="running"||!k)return wr;const N=Rr(u.trim(),k);if(!N)return wr;const A=String(mr||((V=ce==null?void 0:ce.waiting)==null?void 0:V.reason)||"").trim().toLowerCase(),U=typeof(xr==null?void 0:xr.node_id)=="string"?String(xr.node_id).trim():"",H=typeof(xr==null?void 0:xr.status)=="string"?String(xr.status).trim().toLowerCase():"";return _==="waiting"&&A==="until"||!wr.trim()||(H==="waiting"||H==="running")&&!U?N:wr},[vn,u,Us,ce==null?void 0:ce.status,ce==null?void 0:ce.current_node,(Wl=ce==null?void 0:ce.waiting)==null?void 0:Wl.reason,mr,wr,xr]),Gf=h.useMemo(()=>{const _={},k=u.trim(),N=(A,U)=>{if(!U)return;const H=typeof(U==null?void 0:U.node_id)=="string"?String(U.node_id).trim():"";if(!H)return;const V=Rr(A,H);if(!V)return;const J=String((U==null?void 0:U.ended_at)||(U==null?void 0:U.started_at)||"").trim(),Se=bn(J);Se!==null&&(_[V]=Math.max(_[V]||0,Se))};for(const A of He)A&&A.record&&N(k,A.record);for(const A of pt)A&&A.record&&N(String(A.run_id||"").trim(),A.record);return _},[He,pt,u,ni]);h.useEffect(()=>{var N;if(!vn||!u.trim()||!Us.trim())return;const _=String((ce==null?void 0:ce.current_node)||"").trim();!_||String(((N=ce==null?void 0:ce.waiting)==null?void 0:N.reason)||"").trim()==="subworkflow"||El(Rr(u.trim(),_))},[vn,u,Us,ce==null?void 0:ce.current_node,(Sr=ce==null?void 0:ce.waiting)==null?void 0:Sr.reason]),h.useEffect(()=>{const _=String((Pn==null?void 0:Pn.flow_id)||"").trim();_&&(Ps.trim()||xo(_))},[Pn,Ps]),h.useEffect(()=>{const _=Us.trim(),k=S.trim(),N=Ps.trim();if(_){let U=!1;return jo(!0),Yi(""),Le.get_workflow_flow(_).then(H=>{if(U)return;const V=H==null?void 0:H.flow;bo(V&&typeof V=="object"?V:null)}).catch(H=>{U||(bo(null),Yi(String((H==null?void 0:H.message)||H||"Failed to load workflow flow")))}).finally(()=>{U||jo(!1)}),()=>{U=!0}}if(!k||!N){bo(null),Yi(""),jo(!1);return}let A=!1;return jo(!0),Yi(""),Le.get_bundle_flow(k,N).then(U=>{if(A)return;const H=U==null?void 0:U.flow,V=H&&typeof H=="object"?H:null;bo(V),V&&da(J=>({...J,[N]:V}))}).catch(U=>{A||(bo(null),Yi(String((U==null?void 0:U.message)||U||"Failed to load flow")))}).finally(()=>{A||jo(!1)}),()=>{A=!0}},[Us,S,Ps,Le]),h.useEffect(()=>{const _=S.trim();if(!dl||!_||!ti)return;let k=!1;const N=3,A=ie=>{const W=Array.isArray(ie==null?void 0:ie.nodes)?ie.nodes:[],we=[];for(const Ae of W){const Pe=Ae!=null&&Ae.data&&typeof Ae.data=="object"?Ae.data:{};if(String((Pe==null?void 0:Pe.nodeType)||(Ae==null?void 0:Ae.type)||"").trim()!=="subflow")continue;const Ue=(Pe==null?void 0:Pe.subflowId)||(Pe==null?void 0:Pe.flowId),St=typeof Ue=="string"?Ue.trim():"";St&&we.push(St.includes(":")?St.split(":",2)[1]:St)}return we},U=new Set,H=new Set,V=(ie,W)=>{if(!(!ie||W>=N))for(const we of A(ie)){const Ae=String(we||"").trim();if(!Ae||U.has(Ae))continue;U.add(Ae),H.add(Ae);const Pe=ul[Ae];Pe&&V(Pe,W+1)}};V(ti,0);const J=Array.from(H).filter(ie=>!ul[ie]).slice(0,20);return J.length?((async()=>{for(const ie of J){if(k)return;try{const W=await Le.get_bundle_flow(_,ie),we=W==null?void 0:W.flow,Ae=we&&typeof we=="object"?we:null;if(!Ae)continue;da(Pe=>Pe[ie]?Pe:{...Pe,[ie]:Ae})}catch{}}})(),()=>{k=!0}):void 0},[dl,S,ti,ul,Le]);const ld=h.useMemo(()=>{const k=(Array.isArray(P==null?void 0:P.flows)?P==null?void 0:P.flows:[]).map(N=>String(N||"").trim()).filter(Boolean);return k.length?Array.from(new Set(k)).sort():Array.from(new Set(zl)).sort()},[P,zl]);h.useEffect(()=>{Ds&&wr.trim()&&(Xi(""),ji.current="")},[Ds,u,wr]),h.useEffect(()=>{const _=_s.trim(),k=u.trim();if(!(vn&&!!_&&_!==k)){Mr.current&&Mr.current.abort(),Mr.current=null,No.current=0,_a&&pa("");return}if(_a===_)return;Mr.current&&Mr.current.abort();const A=new AbortController;Mr.current=A,No.current=0,pa(_),Xt({ts:Nt(),kind:"info",title:`Following run ${_} (status/events)`});let U=250;return(async()=>{for(;!A.signal.aborted;){try{await Le.stream_ledger(_,{after:No.current,on_step:V=>hh(_,V),signal:A.signal});return}catch(V){if(A.signal.aborted)break;const J=String((V==null?void 0:V.message)||V||"stream error");Xt({ts:Nt(),kind:"error",title:"Child ledger stream error (will retry)",preview:_t(J),data:{child_run_id:_,error:J}})}if(A.signal.aborted)break;await new Promise(V=>setTimeout(V,U)),U=Math.min(5e3,Math.floor(U*1.6))}})(),()=>{A.abort()}},[vn,_s,u,Le,_a]),h.useEffect(()=>{if(!vn||!u.trim())return;let _=!1;const k=async()=>{if(!_&&!hl.current&&ni.length&&!(jt.current>Date.now())){hl.current=!0;try{const A=ni.map(J=>String(J||"").trim()).filter(Boolean);if(!A.length)return;const U=A.map(J=>({run_id:J,after:Number(ha.current[J]||0)})),H=await Le.get_ledger_batch({runs:U,limit:200}),V=H&&typeof H=="object"?H.runs:{};for(const J of A){if(_)return;const Se=V&&typeof V=="object"?V[J]:null,ie=Array.isArray(Se==null?void 0:Se.items)?Se.items:[],W=typeof(Se==null?void 0:Se.next_after)=="number"?Se.next_after:Number(ha.current[J]||0),we=Number(ha.current[J]||0);for(let Ae=0;Ae<ie.length;Ae++){const Pe=ie[Ae];Cf(J,{cursor:we+Ae+1,record:Pe})}ha.current[J]=W}}catch(A){if(_)return;Xt({ts:Nt(),kind:"error",title:"Subrun digest poll failed",preview:_t(String((A==null?void 0:A.message)||A||""))})}finally{hl.current=!1}}};k();const N=window.setInterval(()=>void k(),2e3);return()=>{_=!0,window.clearInterval(N),hl.current=!1}},[vn,u,ni,Le]);const Il=h.useMemo(()=>oa?ku.filter(zE):ku,[oa,ku]),js=h.useMemo(()=>{const _=u.trim(),k=[];for(const N of He)!N||!N.record||k.push({run_id:_,cursor:N.cursor,record:N.record});for(const N of pt)!N||!N.record||k.push({run_id:String(N.run_id||"").trim(),cursor:N.cursor,record:N.record});return k},[He,pt,u]),Vn=h.useMemo(()=>{var k,N,A;const _={};for(const U of js){const H=String(U.run_id||((k=U.record)==null?void 0:k.run_id)||"").trim();!H||String(((A=(N=U.record)==null?void 0:N.effect)==null?void 0:A.type)||"").trim()!=="llm_call"||(_[H]=(_[H]||0)+1)}return _},[js]),Hs=h.useMemo(()=>{const _=_s.trim();if(_)return _;let k="",N=-1;for(const[A,U]of Object.entries(Vn))U>N&&(k=A,N=U);return k||u.trim()},[Vn,_s,u]),Lr=(oh.trim()||Hs).trim(),Wc=h.useMemo(()=>{var U;const _=new Set,k=u.trim(),N=_s.trim();k&&_.add(k),N&&_.add(N);for(const H of ni){const V=String(H||"").trim();V&&_.add(V)}for(const H of js){const V=String(H.run_id||((U=H.record)==null?void 0:U.run_id)||"").trim();V&&_.add(V)}const A=Array.from(_);return A.sort((H,V)=>k&&H===k&&V!==k?-1:k&&V===k&&H!==k?1:N&&H===N&&V!==N?-1:N&&V===N&&H!==N?1:H<V?-1:H>V?1:0),A},[u,_s,ni,js]),qc=h.useMemo(()=>zx(js,{run_id:Lr}),[js,Lr]),an=h.useMemo(()=>{const _=u.trim();return _&&(Ne.find(k=>String(k.run_id||"").trim()===_)||yt.find(k=>String(k.run_id||"").trim()===_))||null},[Ne,yt,u]),Wo=String((ce==null?void 0:ce.status)||(an==null?void 0:an.status)||"").trim(),di=String(mr||((Fi=ce==null?void 0:ce.waiting)==null?void 0:Fi.reason)||(an==null?void 0:an.waiting_reason)||"").trim().toLowerCase(),Kf=!!(ce!=null&&ce.is_scheduled||an!=null&&an.is_scheduled),cd=!!(ce!=null&&ce.paused||an!=null&&an.paused),ud=Kf&&Wo.toLowerCase()==="waiting",dd=ud&&di==="until",fd=bn(On),md=dd&&fd!==null?Zp(fd-Date.now()):"",oo=I0(ce),Pa=Kf&&cd?"Suspended":ud?"Scheduled":Tm({status:Wo,paused:cd,stop_reason:oo});async function es(){if(j){jc(!0),$i("");try{const _=ys,k=_==="session"?String(ur||bs||q||"").trim():"",N=_==="run"?String(Is||u||"").trim():"",A=J0(Eo),U=zs.length?zs.join(","):"",H=Z0(pl),V=Math.max(0,oi)*vm,J=await Le.search_artifacts({scope:_,session_id:k||void 0,run_id:N||void 0,query:on||void 0,artifact_kind:U||void 0,created_after:A||void 0,include_stats:!0,limit:vm,offset:V,order_by:H.order_by,order:H.order}),Se=[],ie=new Set;for(const ze of Array.isArray(J==null?void 0:J.items)?J.items:[]){const Ue=K0(ze,"search");!Ue||ie.has(Ue.artifact_id)||(ie.add(Ue.artifact_id),Se.push(Ue))}const W=J!=null&&J.stats&&typeof J.stats=="object"?J.stats:{},we=Number((W==null?void 0:W.total)??(J==null?void 0:J.total)??Se.length),Ae=tg(J);let Pe=Ae;if(zs.length)try{const ze=await Le.search_artifacts({scope:_,session_id:k||void 0,run_id:N||void 0,query:on||void 0,created_after:A||void 0,include_stats:!0,limit:1,offset:0,order_by:H.order_by,order:H.order});Pe=tg(ze)}catch{Pe=Ae}ii(Number.isFinite(we)?Math.max(0,we):Se.length),hf(Number((W==null?void 0:W.total_bytes)??(W==null?void 0:W.byte_total)??0)||0),Zi(Ae),Co(Pe),Os(Se),eo(ze=>{var Ue;return ze&&Se.some(St=>St.artifact_id===ze)?ze:((Ue=Se[0])==null?void 0:Ue.artifact_id)||""})}catch(_){$i(String((_==null?void 0:_.message)||_||"Failed to load artifacts")),Os([]),ii(0),hf(0),Zi({}),Co({}),eo("")}finally{jc(!1)}}}async function Gt(){if(j){yf(!0),wl("");try{const _=await Le.audit_log_tail({max_bytes:16e4}),k=typeof(_==null?void 0:_.bytes)=="number"?Number(_.bytes):0,N=!!(_!=null&&_.truncated);yl(String((_==null?void 0:_.content)||"")),To(`${k.toLocaleString()} bytes${N?" (tail)":""}`)}catch(_){wl(String((_==null?void 0:_.message)||_||"Failed to load audit log")),yl(""),To("")}finally{yf(!1)}}}async function Zn(_){if(!j)return;const k=String(_||va||Is||u||"").trim();if(!k){ja([]),bl(""),no("Select a run in Activity or Artifacts to load its runtime ledger.");return}Mc(!0),no("");try{const N=await Le.get_ledger(k,{after:0,limit:2e3}),A=Array.isArray(N.items)?N.items:[];ja(A.map((H,V)=>({cursor:V+1,record:H})));const U=typeof N.next_after=="number"?Number(N.next_after):A.length;bl(`${A.length.toLocaleString()} record${A.length===1?"":"s"}${U>=2e3?" (first 2,000)":""}`)}catch(N){no(String((N==null?void 0:N.message)||N||"Failed to load run ledger")),ja([]),bl("")}finally{Mc(!1)}}h.useEffect(()=>{j&&e==="runtime"&&es()},[j,e,ys,ur,Is,on,zs,Eo,pl,oi]),h.useEffect(()=>{j&&(Ec||Du||e==="runtime"&&Gt())},[j,e,rr]),h.useEffect(()=>{if(!j||e!=="runtime"||gs!=="logs"||xl!=="run_ledger"&&xl!=="provider_calls")return;const _=String(va||Is||u||"").trim();_&&Zn(_)},[j,e,gs,xl,va,Is,u]);const gn=h.useMemo(()=>{const _=new Map;for(const k of[...yt,...Ne]){const N=String(k.run_id||"").trim();N&&_.set(N,k)}for(const k of ni){const N=String(k||"").trim();!N||_.has(N)||_.set(N,{run_id:N,workflow_id:null,status:"",created_at:null,updated_at:null,ledger_len:null,parent_run_id:ki.current[N]||null,session_id:bs||null})}return u.trim()&&!_.has(u.trim())&&_.set(u.trim(),{run_id:u.trim(),workflow_id:typeof(ce==null?void 0:ce.workflow_id)=="string"?String(ce.workflow_id):null,status:typeof(ce==null?void 0:ce.status)=="string"?String(ce.status):"",created_at:typeof(ce==null?void 0:ce.created_at)=="string"?String(ce.created_at):null,updated_at:typeof(ce==null?void 0:ce.updated_at)=="string"?String(ce.updated_at):null,ledger_len:He.length||null,parent_run_id:typeof(ce==null?void 0:ce.parent_run_id)=="string"?String(ce.parent_run_id):null,session_id:typeof(ce==null?void 0:ce.session_id)=="string"?String(ce.session_id):bs||null}),Array.from(_.values()).sort((k,N)=>{const A=bn(k.updated_at||k.created_at)??0;return(bn(N.updated_at||N.created_at)??0)-A})},[Ne,yt,u,ce,He.length,ni,bs]),pr=h.useMemo(()=>{const _=Eu.trim().toLowerCase(),k=gn,N={},A={};for(const ie of k){const W=String(ie.run_id||"").trim();if(!W)continue;A[W]=ie;const we=String(ie.parent_run_id||ki.current[W]||"").trim();we&&(N[we]||(N[we]=[]),N[we].push(ie))}const U=ie=>{const W=String(ie.status||"").trim().toLowerCase();return Rs==="all"?!0:Rs==="active"?au(W):Rs==="waiting"?W==="waiting":Rs==="terminal"?pi(W):Rs==="failed"?W==="failed":!0},H=ie=>{if(!_)return!0;const W=String(ie.workflow_id||ie.schedule_target_workflow_id||"").trim(),we=W?qr[W]||W:"";return[ie.run_id,W,we,ie.session_id,ie.status].join(" ").toLowerCase().includes(_)},V=new Set;for(const ie of k){const W=String(ie.run_id||"").trim();if(!W)continue;const we=String(ie.parent_run_id||ki.current[W]||"").trim();(!we||!A[we])&&V.add(W)}const J={},Se=ie=>{if(ol==="workflow"){const we=String(ie.schedule_target_workflow_id||ie.workflow_id||"").trim()||"(unknown workflow)";return{key:we,label:qr[we]||we}}if(ol==="session"){const we=String(ie.session_id||"").trim()||"(no session)";return{key:we,label:we}}const W=String(ie.status||"").trim().toLowerCase()||"unknown";return au(W)?{key:"active",label:"Active"}:W==="failed"?{key:"failed",label:"Failed"}:pi(W)?{key:"finished",label:"Finished"}:{key:W,label:W}};for(const ie of V){const W=A[ie];if(!W)continue;const we=[...N[ie]||[]].sort((ze,Ue)=>{const St=bn(ze.updated_at||ze.created_at)??0;return(bn(Ue.updated_at||Ue.created_at)??0)-St}),Ae=we.some(ze=>U(ze)&&H(ze));if(!(U(W)&&H(W))&&!Ae)continue;const Pe=Se(W);J[Pe.key]||(J[Pe.key]={key:Pe.key,label:Pe.label,rows:[]}),J[Pe.key].rows.push({run:W,children:we})}return Object.values(J).sort((ie,W)=>{const we={active:0,waiting:1,failed:2,finished:3},Ae=we[ie.key]??10,Pe=we[W.key]??10;return Ae!==Pe?Ae-Pe:ie.label.localeCompare(W.label)})},[gn,Eu,Rs,ol,qr]),ts=h.useMemo(()=>dv(js),[js]),Oa=h.useMemo(()=>{const _=[...js];return _.sort((k,N)=>{var H,V,J,Se;const A=bn(((H=k.record)==null?void 0:H.ended_at)||((V=k.record)==null?void 0:V.started_at))??0,U=bn(((J=N.record)==null?void 0:J.ended_at)||((Se=N.record)==null?void 0:Se.started_at))??0;return A-U}),_.slice(-240)},[js]),jn=h.useMemo(()=>{const _={};for(const k of gn){const N=String(k.run_id||"").trim();N&&(_[N]=k)}return _},[gn]),qo=String(va||Is||u||"").trim(),zi=qo&&jn[qo]||null,Dl=String(ur||(zi==null?void 0:zi.session_id)||bs||q||"").trim(),Vc=h.useMemo(()=>Ji.map(_=>Lm(_,jn,qr)),[Ji,jn,qr]);h.useEffect(()=>{wa(0)},[on,zs,Eo,Is,pl,$o,ys,ur]);const Fl=Math.max(1,Math.ceil(ga/vm)),ar=Math.min(Math.max(0,oi),Fl-1);h.useEffect(()=>{oi!==ar&&wa(ar)},[oi,ar]);const Ii=h.useMemo(()=>Vc,[Vc,ar]),za=h.useMemo(()=>{const _={};for(const k of Ii){const N=$o==="type"?N_(k,jn,qr):Y0(k,$o);_[N]||(_[N]=[]),_[N].push(k)}return Object.entries(_).map(([k,N])=>({key:k,items:N})).sort((k,N)=>{var A,U;if($o==="time"){const H=bn((A=k.items[0])==null?void 0:A.created_at)??0,V=bn((U=N.items[0])==null?void 0:U.created_at)??0;if(H!==V)return V-H}return k.key.localeCompare(N.key)})},[Ii,$o,jn,qr]),ns=h.useMemo(()=>{const _=Ai.trim();return _?Ii.find(k=>k.artifact_id===_)||Ii[0]||null:Ii[0]||null},[Ii,Ai]);h.useEffect(()=>{e!=="runtime"||gs!=="artifacts"||Nf(ns)},[e,gs,ns==null?void 0:ns.artifact_id]),h.useEffect(()=>()=>{Ti.url&&URL.revokeObjectURL(Ti.url)},[Ti.url]);const Gc=h.useMemo(()=>gn.filter(_=>au(_.status)),[gn]);h.useEffect(()=>{if(e!=="settings"&&e!=="launch"||!j||$)return;let _=!1;return(async()=>{const[k,N]=await Promise.all([Le.list_skills(),Le.list_mcp_servers()]);_||(G(k),le(N),Y(!0))})(),()=>{_=!0}},[e,j,$]);const hd=[{id:"board",label:"Board",icon:s.jsx(Tn,{name:"board",size:16})},{id:"observe",label:"Observe",icon:s.jsx(Tn,{name:"history",size:16})},{id:"runtime",label:"System",icon:s.jsx(Tn,{name:"server",size:16})},{id:"launch",label:"Launch",icon:s.jsx(Tn,{name:"send",size:16})}],ao={board:"Board",observe:"Observe",runtime:"System",launch:"Launch",settings:"Settings"};return s.jsxs("div",{className:"app-shell shell",children:[s.jsxs("aside",{className:"shell_sidebar",children:[s.jsxs("div",{className:"shell_brand",title:"AbstractObserver (Web/PWA)",children:[s.jsx("span",{className:"logo-icon shell_brand_mark","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 24 24",width:"20",height:"20",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:"shell_brand_name",children:"Observer"})]}),s.jsxs("nav",{className:"shell_nav",children:[hd.map(_=>s.jsxs("button",{className:`shell_nav_item ${e===_.id?"active":""}`,onClick:()=>t(_.id),type:"button",children:[s.jsx("span",{className:"shell_nav_icon",children:_.icon}),s.jsx("span",{className:"shell_nav_label",children:_.label})]},_.id)),s.jsxs("a",{className:"shell_nav_item",href:l,target:"_blank",rel:"noreferrer",title:"Open the entity app (memory graph + visits)",children:[s.jsx("span",{className:"shell_nav_icon",children:s.jsx(Tn,{name:"bot",size:16})}),s.jsx("span",{className:"shell_nav_label",children:"Entities ↗"})]}),s.jsxs("button",{className:`shell_nav_item ${e==="settings"?"active":""}`,onClick:()=>t("settings"),type:"button",children:[s.jsx("span",{className:"shell_nav_icon",children:s.jsx(Tn,{name:"settings",size:16})}),s.jsx("span",{className:"shell_nav_label",children:"Settings"})]})]}),s.jsx("div",{className:"shell_sidebar_footer",children:s.jsxs("div",{className:"shell_connection shell_connection_passive",title:j?"Gateway connected":de?"Gateway: connecting…":"Gateway: signed out",children:[s.jsx("span",{className:`gateway_led ${j?"ok":de?"warn":"err"}`,"aria-hidden":"true"}),s.jsx("span",{className:`shell_connection_label ${j&&((Pr=(ks=te==null?void 0:te.gateway)==null?void 0:ks.principal)!=null&&Pr.user_id)?"mono":""}`,children:j?((Yc=(_d=te==null?void 0:te.gateway)==null?void 0:_d.principal)==null?void 0:Yc.user_id)||(n.gateway_auth_mode==="direct"?"direct dev":"connected"):de?"connecting…":"signed out"})]})})]}),s.jsxs("div",{className:"shell_main",children:[s.jsxs("header",{className:"shell_header",children:[s.jsx("div",{className:"shell_header_title",children:ao[e]||"Observer"}),s.jsxs("div",{className:"shell_header_actions",children:[a?s.jsx("monitor-gpu",{ref:d,mode:"icon","history-size":"5","tick-ms":"1500","base-url":n.gateway_auth_mode==="session"?"":n.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,s.jsx(zb,{assistant:{open:Ye,onToggle:()=>Ct(_=>!_),label:"Observer assistant (docs-grounded)"},appearance:{onOpen:()=>Ke(!0)},about:{identity:Ro,extraRows:Uu,onOpen:ro},connection:{phase:z.phase,signingOut:z.signingOut,onConnect:()=>z.openModal(),onDisconnect:()=>Cl()}})]})]}),s.jsx(gb,{...z.modalProps}),s.jsx(Bb,{open:Fe,onClose:()=>Ke(!1),value:je,onChange:Ce}),s.jsx(m0,{open:Ye,onClose:()=>Ct(!1),connected:j,topOffset:44,gateway:Le}),s.jsxs("div",{className:"app-body shell_content",children:[e==="board"?j?s.jsx(CE,{gateway_connected:j,runs:yt,all_runs:Ne,runs_refreshed_at:Ie,entities:Mt,entities_total:dn,entities_error:At,refreshing:it,on_refresh:()=>void Tr(Le,{force:!0}),on_open_run:_=>{t("observe"),Ls("overview"),Pi(_)},on_resume_wait:Sf,entity_app_href:l,on_read_diary:(_,k)=>Le.read_entity_diary_entry(_,k),phase_graph:bf}):s.jsx("div",{className:"page page_scroll",children:s.jsx("div",{className:"page_inner constrained",children:s.jsxs("div",{className:"card mc_hero",children:[s.jsx("div",{className:"title",children:s.jsx("h1",{children:"Connect to your gateway"})}),s.jsxs("p",{className:"muted",children:["Mission Control shows every run and entity on one board — but nothing is connected yet.",F?` Last attempt: ${F}`:""]}),s.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center"},children:[s.jsx("button",{className:"btn primary",onClick:()=>z.openModal(),disabled:de,children:de?"Connecting…":"Sign in"}),s.jsx("button",{className:"btn",onClick:()=>void Io({open_modal_if_needed:!0}),disabled:de,title:"Retry with an existing browser session or a direct dev token",children:"Retry connection"})]})]})})}):null,e==="settings"?s.jsx("div",{className:"page page_scroll",children:s.jsxs("div",{className:"page_inner settings_col",children:[s.jsxs("section",{className:"pane",children:[s.jsxs("div",{className:"pane_header",children:[s.jsx("span",{className:"pane_title",children:"Gateway"}),s.jsx("span",{className:"pane_spacer"}),s.jsx("span",{className:`chip ${j?"ok":"warn"}`,children:qy(te).label})]}),s.jsxs("div",{className:"pane_body settings_body",children:[s.jsxs("div",{className:"settings_row",children:[s.jsxs("div",{className:"settings_row_main",children:[s.jsx("div",{className:"settings_row_title",children:"Connection"}),s.jsx("div",{className:"settings_row_help",children:"The shared AbstractFramework sign-in: a gateway user token exchanges for an HTTP-only browser session. Raw tokens are never stored."})]}),s.jsxs("div",{className:"settings_row_actions",children:[s.jsx("button",{className:"btn",onClick:()=>z.openModal(),children:"Manage connection…"}),j?s.jsx("button",{className:"btn",onClick:()=>Cl(),title:"Sign this browser out of the gateway (this app's session only)",children:"Sign out"}):null]})]}),F?s.jsx("div",{className:"warn_callout",children:F}):null,s.jsxs("div",{className:"settings_row",children:[s.jsxs("div",{className:"settings_row_main",children:[s.jsx("div",{className:"settings_row_title",children:"Auto-connect on load"}),s.jsx("div",{className:"settings_row_help",children:"Reuse the browser session automatically when the app opens."})]}),s.jsx("div",{className:"settings_row_actions",children:s.jsxs("select",{value:n.auto_connect_gateway?"on":"off",onChange:_=>o(k=>({...k,auto_connect_gateway:_.target.value==="on"})),children:[s.jsx("option",{value:"on",children:"On"}),s.jsx("option",{value:"off",children:"Off"})]})})]}),s.jsxs("details",{className:"settings_advanced",children:[s.jsx("summary",{children:"Advanced: direct dev connection (bearer token, cross-origin)"}),s.jsxs("div",{className:"field",style:{marginTop:"8px"},children:[s.jsx("label",{children:"Gateway URL"}),s.jsx("input",{value:n.gateway_url,onChange:_=>o(k=>({...k,gateway_url:_.target.value})),placeholder:qm})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Dev bearer token"}),s.jsx("input",{type:"password",value:n.auth_token,onChange:_=>o(k=>({...k,auth_token:_.target.value,gateway_auth_mode:"direct"})),placeholder:"development only — prefer the sign-in dialog"})]}),s.jsx("button",{className:"btn",onClick:()=>void Io({prefer_direct:!0}),disabled:de,children:de?"Connecting…":"Connect directly"})]})]})]}),s.jsxs("section",{className:"pane",children:[s.jsxs("div",{className:"pane_header",children:[s.jsx("span",{className:"pane_title",children:"Assistant"}),s.jsx("span",{className:"pane_spacer"}),s.jsx("span",{className:"chip muted",children:"docs Q&A + run Ask"})]}),s.jsxs("div",{className:"pane_body settings_body",children:[s.jsx("div",{className:"settings_row_help",style:{marginTop:0},children:"The model answering the header assistant and the run page's Ask tab. Blank fields follow the gateway defaults."}),s.jsx(lb,{className:"field",providerLabel:"Provider",modelLabel:"Model",providerPlaceholder:"(gateway default)",modelPlaceholder:"(gateway default)",provider:n.maintenance_ai_provider,model:n.maintenance_ai_model,providers:Gu,models:Mn.models,loadingProviders:de,loadingModels:ir,modelError:Fn?Mn.error:"",allowCustomProvider:!0,allowCustomModel:!0,allowGatewayDefault:!0,gatewayDefaultLabel:"(gateway default)",onChange:_=>o(k=>({...k,maintenance_ai_provider:_.provider,maintenance_ai_model:_.model}))}),s.jsx("div",{className:"settings_subhead",children:"Skills"}),O===null?s.jsx("div",{className:"settings_row_help",children:j?$?"The gateway does not serve a skills inventory yet — the abstractskill shelf list lights up here the day it ships.":"Probing the gateway for the skills inventory…":"Connect to the gateway to list installable skills (abstractskill shelf)."}):O.length?s.jsx("div",{className:"settings_choice_list",children:O.map(_=>{const k=n.assistant_skill_names.includes(_.name);return s.jsxs("label",{className:`settings_choice ${k?"on":""}`,title:_.description||_.name,children:[s.jsx("input",{type:"checkbox",checked:k,onChange:N=>o(A=>({...A,assistant_skill_names:N.target.checked?Array.from(new Set([...A.assistant_skill_names,_.name])):A.assistant_skill_names.filter(U=>U!==_.name)}))}),s.jsxs("span",{className:"settings_choice_name",children:[_.name,_.version?s.jsxs("em",{children:[" v",_.version]}):null]}),_.description?s.jsx("span",{className:"settings_choice_desc",children:_.description}):null]},_.name)})}):s.jsx("div",{className:"settings_row_help",children:"The gateway serves an empty skills inventory."}),s.jsx("div",{className:"settings_row_help",children:"Selected skills ride the assistant's runs once the gateway's skills-attachment lane serves them; the selection persists here meanwhile."}),s.jsx("div",{className:"settings_subhead",children:"MCP servers"}),s.jsx("div",{className:"settings_row_help",style:{marginTop:0},children:"Remote tool endpoints the assistant may call. The gateway does not serve an MCP inventory yet — one manual endpoint is supported (advanced / potentially dangerous: it executes tool waits from this browser)."}),s.jsxs("div",{className:"settings_mcp_row",children:[s.jsx("input",{className:"mono",value:n.worker_url,onChange:_=>o(k=>({...k,worker_url:_.target.value})),placeholder:"https://your-mcp-worker-endpoint"}),s.jsx("input",{className:"mono",type:"password",value:n.worker_token,onChange:_=>o(k=>({...k,worker_token:_.target.value})),placeholder:"Bearer token (optional)"}),s.jsx("span",{className:`chip ${n.worker_url.trim()?"ok":"muted"}`,children:n.worker_url.trim()?"configured":"none"})]})]})]})]})}):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:"help_text muted",children:"Pick a workflow, fill its inputs, and start a run on the connected gateway."}),j?null:s.jsxs("div",{className:"warn_callout",children:["Not connected."," ",s.jsx("button",{className:"btn primary",onClick:()=>z.openModal(),children:"Sign in"})," ","to launch workflows on this gateway."]}),s.jsxs("div",{className:"launch_workflow_bar",children:[s.jsxs("select",{className:"launch_workflow_select",value:Tc,onChange:async _=>{const k=String(_.target.value||"").trim();if(!k)return;const N=f_(k);N&&(R(N.bundle_id),C(N.flow_id),xo(N.flow_id),be([]),await $a(N.bundle_id))},disabled:de||!jl.length,children:[s.jsx("option",{value:"",children:jl.length?"(select workflow)":vn?de?"(loading workflows…)":"(no executable workflows published on this gateway)":"(sign in to load workflows)"}),jl.map(_=>s.jsx("option",{value:_.workflow_id,children:_.label},_.workflow_id))]}),s.jsx("input",{ref:Cr,type:"file",accept:".flow",style:{display:"none"},onChange:_=>{const k=_.target.files&&_.target.files.length?_.target.files[0]:null;k&&Ku(k)}}),s.jsx("button",{type:"button",className:"btn launch_btn_upload",onClick:()=>{var _;return(_=Cr.current)==null?void 0:_.click()},disabled:!j||de||er||ne||Te,title:"Upload a .flow bundle",children:er?"…":"Upload"}),s.jsxs("button",{type:"button",className:"btn launch_btn_reload",onClick:()=>void Nl(),disabled:!j||de||Hn||ne||Te,title:"Reload picks up server-side edits",children:[s.jsx(Tn,{name:"refresh",size:14}),Hn?"…":"Reload"]})]}),s.jsxs("div",{className:"field",children:[Pn!=null&&Pn.description?s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:String(Pn.description)}):null,Q?s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading workflow…"}):null,ee?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:ee}):null]}),s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Inputs"}),!S.trim()||!b.trim()?s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Select a workflow above to configure inputs."}):gt===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:Nt()})]}),s.jsx("div",{className:"body mono",children:"Invalid input JSON — reselect the workflow to reset its inputs."})]}):Vu?s.jsx("div",{className:"launch_inputs",children:(()=>{const _=ne||Te,k=[],N=[];for(const H of Li){if(!H||typeof H!="object")continue;const V=String(H.id||"").trim();if(!V)continue;const J=String(H.type||"").trim().toLowerCase();J==="tools"||J==="skills"||J==="mcp"||J==="mcp_servers"||V==="skills"||V==="mcp"||V==="mcp_servers"||J==="array"||Sn(J)||V==="prompt"||V==="system"?k.push(H):N.push(H)}const A=H=>String(H||"").trim().replace(/_/g," ").replace(/\b\w/g,V=>V.toUpperCase()),U=(H,V)=>{const J=String(H.id||"").trim();if(!J)return null;const Se=String(H.label||J).trim()||J,ie=Se===J?A(J):Se,W=String(H.type||"").trim().toLowerCase(),we=Object.prototype.hasOwnProperty.call(H,"default"),Ae=we?H.default:void 0,Pe=we?typeof Ae=="string"?Ae:kr(Ae,80):"",ze=gt==null?void 0:gt[J],Ue=we?`${Pe}`:"";if(W==="tools"){const Be=Array.isArray(ze)?ze.map(Rt=>String(Rt||"").trim()).filter(Boolean):[],at=Array.isArray(Ae)?Ae.map(Rt=>String(Rt||"").trim()).filter(Boolean):[],Je=Array.from(new Set([...Oo,...Be,...at])).sort();return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx(d_,{options:Je,value:Be,disabled:_,placeholder:"(no tools selected)",onChange:Rt=>xn(J,Rt)})]},J)}if(W==="skills"||J==="skills"){const Be=Array.isArray(ze)?ze.map(Rt=>String(Rt||"").trim()).filter(Boolean):[];if(O===null&&!Be.length)return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("div",{className:"help_text muted",children:"This gateway does not serve a skills inventory yet — skill selection lights up here when it ships (abstractskill shelf via abstractgateway)."})]},J);const at=(O||[]).filter(Rt=>Rt.blocked!==!0).map(Rt=>Rt.name),Je=Array.from(new Set([...at,...Be])).sort();return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx(d_,{options:Je,value:Be,disabled:_,placeholder:"(no skills selected)",onChange:Rt=>xn(J,Rt)})]},J)}if(W==="mcp"||W==="mcp_servers"||J==="mcp"||J==="mcp_servers"){const Be=Array.isArray(ze)?ze.map(Rt=>String(Rt||"").trim()).filter(Boolean):[];if(se===null&&!Be.length)return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("div",{className:"help_text muted",children:"This gateway does not serve an MCP server inventory yet — MCP selection lights up here when it ships."})]},J);const at=(se||[]).map(Rt=>Rt.name),Je=Array.from(new Set([...at,...Be])).sort();return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx(d_,{options:Je,value:Be,disabled:_,placeholder:"(no MCP servers selected)",onChange:Rt=>xn(J,Rt)})]},J)}if(W==="provider"||W==="provider_text"){const Be=typeof ze=="string"?String(ze):"";return s.jsxs("div",{className:V||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsxs("select",{value:Be,onChange:at=>xn(J,at.target.value),disabled:_,children:[s.jsx("option",{value:"",children:Ue||"(select)"}),Rc.map(at=>s.jsx("option",{value:at,children:at},at))]})]},J)}if(W==="model"||W==="model_text"){const Be=typeof ze=="string"?String(ze):"",at=String((gt==null?void 0:gt.provider)||"").trim(),Je=at?hn[at]:void 0,Rt=Je&&Array.isArray(Je.models)?Je.models.map(kn=>String(kn||"").trim()).filter(Boolean):[];return s.jsxs("div",{className:V||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ie}),Rt.length?s.jsxs("select",{value:Be,onChange:kn=>xn(J,kn.target.value),disabled:_,children:[s.jsx("option",{value:"",children:Ue||"(select)"}),Rt.map(kn=>s.jsx("option",{value:kn,children:kn},kn))]}):s.jsx("input",{value:Be,onChange:kn=>xn(J,kn.target.value),placeholder:Ue||"model id",disabled:_})]},J)}if(W==="boolean"){const Be=typeof ze=="boolean"?ze?"true":"false":"";return s.jsxs("div",{className:V||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsxs("select",{value:Be,onChange:at=>{const Je=String(at.target.value||"").trim();Je?xn(J,Je==="true"):xn(J,void 0)},disabled:_,children:[s.jsx("option",{value:"",children:Ue||"(default)"}),s.jsx("option",{value:"true",children:"Yes"}),s.jsx("option",{value:"false",children:"No"})]})]},J)}if(W==="number"){const Be=typeof ze=="number"&&Number.isFinite(ze)?String(ze):"";return s.jsxs("div",{className:V||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("input",{type:"number",value:Be,onChange:at=>{const Je=String(at.target.value||"").trim();if(!Je){xn(J,void 0);return}const Rt=Number(Je);Number.isFinite(Rt)&&xn(J,Rt)},placeholder:Ue,disabled:_})]},J)}if(W==="array"){const Be=Array.isArray(ze)?ze.map(at=>String(at||"").trim()).filter(Boolean).join(`
|
|
134
|
+
`):"";return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("textarea",{className:"mono",value:Be,onChange:at=>{const Je=String(at.target.value||"").split(/\r?\n/g).map(Rt=>String(Rt||"").trim()).filter(Boolean);xn(J,Je.length?Je:void 0)},placeholder:Ue||"(one item per line)",rows:2,disabled:_})]},J)}if(Sn(W)){const Be=typeof Kr[J]=="string"?Kr[J]:"",at=String($s[J]||"").trim();return s.jsxs("div",{className:"launch_field_wide",children:[s.jsxs("label",{className:"launch_label",children:[ie," ",s.jsx("span",{className:"launch_label_type",children:W})]}),s.jsx("textarea",{className:"mono",value:Be,onChange:Je=>{const Rt=String(Je.target.value??"");Gs(Un=>({...Un,[J]:Rt}));const kn=Rt.trim();if(!kn){gi(Un=>{const Ws={...Un};return delete Ws[J],Ws}),xn(J,void 0);return}try{const Un=JSON.parse(kn);gi(Ws=>{const Da={...Ws};return delete Da[J],Da}),xn(J,Un)}catch(Un){gi(Ws=>({...Ws,[J]:String((Un==null?void 0:Un.message)||Un||"Invalid JSON")}))}},placeholder:Ue||"{...}",rows:3,disabled:_}),at?s.jsx("div",{className:"launch_field_error",children:at}):null]},J)}const St=typeof ze=="string"?String(ze):"";return J==="prompt"||J==="system"?s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("textarea",{value:St,onChange:Be=>xn(J,Be.target.value),placeholder:Ue||(J==="prompt"?"What should the agent do?":"System instructions (optional)"),rows:3,disabled:_})]},J):s.jsxs("div",{className:V||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("input",{value:St,onChange:Be=>xn(J,Be.target.value),placeholder:Ue,disabled:_})]},J)};return k.sort((H,V)=>{const J={system:0,prompt:1,tools:2};return(J[String(H.id||"")]??10)-(J[String(V.id||"")]??10)}),s.jsxs(s.Fragment,{children:[k.map(H=>U(H)),N.length>0?s.jsx("div",{className:"launch_grid",children:N.map(H=>U(H,"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",{value:ui,onChange:_=>xn("prompt",_.target.value),placeholder:"What do you want the workflow/agent to do?",rows:3,disabled:ne||Te})]}),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",{value:Lo,onChange:_=>xn("provider",_.target.value),placeholder:"lmstudio / ollama / openai / ...",disabled:ne||Te})]})}),s.jsx("div",{className:"col",children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Model (common)"}),s.jsx("input",{value:Sl,onChange:_=>xn("model",_.target.value),placeholder:"qwen/qwen3-next-80b / gpt-4.1 / ...",disabled:ne||Te})]})})]})]}),S.trim()&&b.trim()?s.jsxs("details",{className:"launch_capabilities",style:{marginTop:"10px"},children:[s.jsxs("summary",{className:"help_text muted",style:{cursor:"pointer"},children:["Capabilities",he.length?` · ${he.length} skill${he.length===1?"":"s"}`:""]}),s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Skills attach knowledge procedures to this run. The gateway resolves selections through the trust gate at start: validated skills activate, unverified ones are held for review, blocked ones never ride."}),O===null?s.jsx("div",{className:"help_text muted",style:{marginTop:"8px"},children:"This gateway does not serve a skills inventory yet — the shelf lights up here when it ships."}):O.length?s.jsx("div",{className:"launch_skill_list",children:O.map(_=>{var U;const k=he.includes(_.name),N=_.blocked===!0,A=_.requires_review===!0&&!N;return s.jsxs("label",{className:`launch_skill_row ${N?"is_blocked":""} ${k?"is_on":""}`,title:[_.description||"",_.tree_hash?`tree ${_.tree_hash.slice(0,16)}…`:"",N&&((U=_.reasons)!=null&&U.length)?`blocked: ${_.reasons.join("; ")}`:""].filter(Boolean).join(`
|
|
135
|
+
`),children:[s.jsx("input",{type:"checkbox",checked:k,disabled:N||ne||Te,onChange:H=>{const V=H.target.checked?Array.from(new Set([...he,_.name])):he.filter(J=>J!==_.name);be(V),xn("skills",V.length?V:void 0)}}),s.jsx("span",{className:"launch_skill_name",children:_.name}),_.trust_level?s.jsx("span",{className:`chip ${N?"danger":A?"warn":"muted"}`,children:N?"blocked":A?"review":_.trust_level}):null,_.description?s.jsx("span",{className:"launch_skill_desc",children:_.description}):null]},_.name)})}):s.jsx("div",{className:"help_text muted",style:{marginTop:"8px"},children:"The gateway's skills shelf is empty."}),he.length?s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-xxs)",marginTop:"6px"},children:"Selected skills ride the run as input_data.skills; the resolved verdicts land in the run's record."}):null]}):null,s.jsxs("details",{style:{marginTop:"10px"},children:[s.jsx("summary",{className:"help_text muted",style:{cursor:"pointer"},children:"Workspace"}),s.jsx("div",{className:"help_text 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:Po,onChange:_=>xn("workspace_root",_.target.value),placeholder:"/path/to/workspace",disabled:ne||Te}),s.jsx("div",{className:"help_text 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:(Ac||"workspace_only").trim()||"workspace_only",onChange:_=>xn("workspace_access_mode",_.target.value),disabled:ne||Te,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:"help_text muted",style:{fontSize:"var(--font-size-xxs)"},children:"workspace_only: absolute paths must stay under root. workspace_or_allowed: allow additional roots."})]})]}),(Ac||"").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:Ea,onChange:_=>xn("workspace_allowed_paths",_.target.value),placeholder:`/path/to/project
|
|
136
|
+
/path/to/workspace`,disabled:ne||Te,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off"}),s.jsx("div",{className:"help_text 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:xf,onChange:_=>xn("workspace_ignored_paths",_.target.value),placeholder:`node_modules
|
|
137
|
+
runtime
|
|
138
|
+
secret`,disabled:ne||Te,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off"}),s.jsx("div",{className:"help_text 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"}),en?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:en})]}):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:Ks==="now",onChange:()=>Ir("now")}),s.jsx("span",{children:"Now"})]}),s.jsxs("label",{className:"sched_radio",children:[s.jsx("input",{type:"radio",name:"schedule_start",checked:Ks==="at",onChange:()=>Ir("at")}),s.jsx("span",{children:"Scheduled"})]})]}),Ks==="at"?s.jsx("input",{type:"datetime-local",value:sn,onChange:_=>ea(_.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:Yr,onChange:_=>Ms(_.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"})]})]}),Yr!=="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(As),onChange:_=>Ys(Math.max(1,parseInt(_.target.value||"1",10)||1)),style:{width:"70px"}}),s.jsxs("select",{value:st,onChange:_=>tn(_.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,Yr==="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(Er),onChange:_=>yi(Math.max(1,parseInt(_.target.value||"1",10)||1)),style:{width:"100px"}})]}):null,Yr==="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:yr,onChange:_=>ta(_.target.value)}),s.jsx("input",{type:"time",value:el,onChange:_=>tl(_.target.value)})]})]}):null]}),s.jsxs("label",{className:"launch_checkbox",style:{marginTop:"8px"},children:[s.jsx("input",{type:"checkbox",checked:qn,onChange:_=>as(!!_.target.checked)}),s.jsxs("span",{children:["Share context across executions ",s.jsx("span",{className:"help_text 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"}),Lt?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:Lt})]}):null,s.jsx("div",{className:"launch_actions_bar launch_actions_stack",children:(()=>{const _=j?!S.trim()||!b.trim()?"Select a workflow":gt===null?"Inputs contain invalid JSON":ne||Te?"Attaching to a run…":de||Q?"Loading…":ln?"Submitting…":"":"Sign in first";return s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"launch_submit_btn",onClick:()=>void Af(),disabled:!!_,title:_,children:ln||ne?"Launching…":Ks!=="now"||Yr!=="once"?"Launch (scheduled)":"Launch now"}),_&&!ln&&!ne?s.jsx("span",{className:"mono muted launch_disabled_reason",children:_}):null]})})()})]})})}):null,e==="runtime"?s.jsx(yS,{gateway_connected:j,tab:gs,runs:gn,active_runs:Gc,all_artifacts:Ji,artifacts:Ii,artifact_total_count:ga,artifact_total_bytes:Iu,artifact_facets:mh,artifact_type_facets:_l,artifact_page:ar,artifact_page_size:vm,artifact_groups:za,selected_artifact:ns,embedded_preview:Ti,loading:Sc,error:ya,query:on,scope:ys,type_filters:zs,date_filter:Eo,group_by:$o,sort_by:pl,artifact_run_filter:Is,audit_log_text:Du,audit_log_meta:gf,audit_log_loading:Ec,audit_log_error:vl,workflow_label_by_id:qr,run_by_id:jn,selected_run_id:qo,session_id:Dl,runtime_log_source:xl,runtime_log_query:Sa,runtime_ledger_log_items:$c,runtime_ledger_log_meta:ka,runtime_ledger_log_loading:Fu,runtime_ledger_log_error:Bu,on_tab_change:zu,on_query_change:wn,on_scope_change:sr,on_session_filter_change:Qi,on_type_filters_change:Ur,on_date_filter_change:_f,on_group_by_change:kc,on_sort_by_change:Mi,on_artifact_page_change:wa,on_artifact_run_filter_change:_=>{const k=String(_||"").trim();Nc(k),k&&gl(k),k&&ys!=="run"&&sr("run")},on_refresh_artifacts:()=>void es(),on_refresh_audit:()=>void Gt(),on_refresh_runtime_ledger:_=>void Zn(_),on_runtime_log_source_change:vf,on_runtime_log_query_change:wf,on_select_run:_=>{const k=String(_||"").trim();gl(k);const N=k&&jn[k]||null,A=String((N==null?void 0:N.session_id)||"").trim();A&&Qi(A)},on_select_artifact:eo,on_preview_artifact:_=>void Ic(_),on_download_artifact:_=>void Xu(_),on_open_run:_=>{gl(String(_||"").trim()),t("observe"),Ls("overview"),Pi(_)},on_open_ledger:_=>{gl(String(_||"").trim()),t("observe"),Ls("ledger"),Pi(_)},on_refresh_runs:()=>void Tr(Le,{force:!0}),on_reconnect:()=>void Io({open_modal_if_needed:!0}),on_open_settings:()=>t("settings"),memory_panel:j?s.jsx(iE,{gateway:Le,selected_run_id:va,selected_session_id:Dl}):null}):null,e==="observe"?s.jsx("div",{className:"page observe_page",children:s.jsxs("div",{className:"observatory_layout",children:[s.jsx(wS,{sections:pr,selected_run_id:u,root_run_id:y,search:Eu,filter:Rs,group_by:ol,loading:it,connected:j,on_sign_in:()=>z.openModal(),total_runs:gn.length,workflow_label_by_id:qr,on_search:$u,on_filter:ih,on_group_by:nf,on_refresh:()=>void Tr(),on_select:(_,k)=>void Pi(_,{root_run_id:k||_})}),s.jsxs("div",{className:"observatory_main",children:[s.jsxs("div",{className:"observe_toolbar",children:[s.jsxs("div",{className:"observe_toolbar_row",children:[u.trim()?s.jsxs("div",{className:"observe_run_identity",title:u.trim(),children:[s.jsx("span",{className:"observe_run_name",children:qr[String((an==null?void 0:an.workflow_id)||"")]||String((an==null?void 0:an.workflow_id)||"").trim()||$t(u.trim(),22)}),s.jsx("span",{className:"chip mono muted",children:$t(u.trim(),14)}),s.jsx("span",{className:`chip ${Za(Pa||Wo,oo)}`,title:String((oo==null?void 0:oo.headline)||""),children:Pa||Wo||"unknown"})]}):s.jsx("span",{className:"observe_run_identity_empty",children:"No run selected"}),s.jsx("span",{className:"observe_toolbar_spacer"}),u.trim()?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{if(_r==="pause"){fs("pause"),ms(""),Qs(""),ds(!0);return}Lf("resume")},disabled:gh,children:Pl}),Ze?s.jsx("button",{className:"btn primary",onClick:()=>void Zu(),disabled:ne||Te||Ds||Oi,children:"Run now"}):null,s.jsx("button",{className:"btn danger",onClick:()=>{fs("cancel"),ms(""),Qs(""),ds(!0)},disabled:ne||Te||Ds,children:"Cancel"}),s.jsx("button",{className:"btn btn_icon",onClick:Tf,title:"Clear the run view",children:s.jsx(Tn,{name:"x",size:14})})]}):null]}),u.trim()&&!Ds?s.jsx("div",{className:"observe_steer_row",children:s.jsx(Sb,{runId:u.trim(),parked:Al,submit:(_,k)=>Le.submit_command({command_id:`steer-${ss()}`,run_id:_,type:"inject_guidance",payload:{guidance:k},client_id:"web_pwa"}).then(N=>({accepted:!!(N!=null&&N.accepted),duplicate:!!(N!=null&&N.duplicate),seq:Number((N==null?void 0:N.seq)??0)})),onSent:()=>Xt({ts:Nt(),kind:"info",title:"Steer queued",preview:"inject_guidance submitted — delivery shows as abstract.steer_seen in the ledger"})})}):null,Al||Bs||Cu?s.jsxs("div",{className:"observe_toolbar_context",children:[Al?s.jsxs("div",{className:"observe_context_card info",children:[s.jsxs("div",{className:"observe_context_label",children:[(()=>{const _=Bs?Oi?"suspended":"scheduled":"waiting";return s.jsx("span",{className:`chip ${Za(_)}`,children:_})})(),s.jsx("span",{className:"muted",children:mr||"unknown"})]}),s.jsxs("div",{className:"observe_context_body",children:[br?s.jsxs("span",{className:"mono",title:br,children:[s.jsx("span",{className:"muted",children:"wait_key"}),": ",$t(br,46)]}):null,mr==="event"&&Tl?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"event"}),": ",Tl]}):null,mr==="subworkflow"&&io?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"child"}),": ",$t(io,18)]}):null,mr==="until"&&On?s.jsxs("span",{className:"mono",title:On,children:[s.jsx("span",{className:"muted",children:"until"}),": ",$t(On,46)]}):null,mr==="until"&&On?s.jsx("span",{className:"mono muted",children:(()=>{const _=bn(On),k=_!==null?new Date(_).toLocaleString():On,N=_!==null?Zp(_-Date.now()):"";return`Next at ${k}${N?` (in ${N})`:""}`})()}):null]}),mr==="subworkflow"&&io?s.jsxs("div",{className:"observe_context_actions",children:[s.jsx("button",{className:"btn primary",onClick:async()=>{m(io),await Aa(io)},disabled:ne,children:"Attach to child"}),y.trim()&&y.trim()!==u.trim()?s.jsx("button",{className:"btn",onClick:async()=>{m(y.trim()),await Aa(y.trim())},disabled:ne,children:"Back to root"}):null]}):null]}):null,Bs?s.jsxs("div",{className:"observe_context_card muted",children:[s.jsxs("div",{className:"observe_context_label",children:[s.jsx("span",{className:"chip muted",children:"schedule"}),s.jsx("span",{className:"muted",children:od?`every ${Uo}`:"once"})]}),s.jsxs("div",{className:"observe_context_body",children:[Uo?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"interval"}),": ",Uo]}):null,s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"share ctx"}),": ",Ll?"yes":"no"]}),typeof hr=="number"?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"repeats"}),": ",hr]}):null]}),Ho!==null?s.jsxs("div",{className:"observe_context_budget",children:[s.jsxs("span",{className:"mono muted",children:[typeof ad=="number"&&typeof qf=="number"?`${ad.toLocaleString()} / ${qf.toLocaleString()}`:"",` • ${Math.round(Math.max(0,Math.min(1,Ho))*100)}%`]}),s.jsx("div",{className:"observe_budget_bar",children:s.jsx("div",{className:`observe_budget_fill ${Ho>=.9?"danger":Ho>=.75?"warn":"ok"}`,style:{width:`${Math.round(Math.max(0,Math.min(1,Ho))*100)}%`}})})]}):null,s.jsxs("div",{className:"observe_context_actions",children:[od?s.jsx("button",{className:"btn",onClick:()=>{zn(Uo||""),Xn(!0),Dn(""),Xs(!0)},disabled:ne||us,children:"Edit schedule"}):null,od?s.jsx("button",{className:"btn",onClick:()=>{tr(""),uo(!0)},disabled:ne||nr,children:"Compact context"}):null]})]}):null,Cu?s.jsxs("div",{className:"observe_context_card error",children:[s.jsx("span",{className:"chip danger",children:"error"}),s.jsx("span",{className:"mono",children:Cu})]}):null]}):null]}),s.jsxs("div",{className:"card panel_card card_scroll observe_viewer observe_viewer_full",children:[s.jsxs("div",{className:"tab_bar",children:[s.jsxs("div",{role:"tablist","aria-label":"Run views",className:"observe_tablist",children:[s.jsx("button",{role:"tab","aria-selected":rr==="overview",className:`tab ${rr==="overview"?"active":""}`,onClick:()=>Ls("overview"),children:"Story"}),s.jsx("button",{role:"tab","aria-selected":rr==="ledger",className:`tab ${rr==="ledger"?"active":""}`,onClick:()=>Ls("ledger"),children:"Ledger"}),s.jsx("button",{role:"tab","aria-selected":rr==="graph",className:`tab ${rr==="graph"?"active":""}`,onClick:()=>Ls("graph"),children:"Flow"}),s.jsx("button",{role:"tab","aria-selected":rr==="chat",className:`tab ${rr==="chat"?"active":""}`,onClick:()=>Ls("chat"),children:"Ask"})]}),rr==="ledger"&&(Il.length>0||al==="cycles")?s.jsxs("div",{className:"tab_bar_controls",children:[s.jsxs("div",{className:"seg_toggle",children:[s.jsx("button",{className:`seg_btn ${al==="steps"?"active":""}`,onClick:()=>Mu("steps"),children:"Steps"}),s.jsx("button",{className:`seg_btn ${al==="cycles"?"active":""}`,onClick:()=>Mu("cycles"),children:"Cycles"})]}),al==="steps"?s.jsx("button",{className:`seg_action ${oa?"active":""}`,onClick:()=>aa(_=>!_),title:oa?"Showing condensed view":"Showing all steps",children:oa?"Condensed":"All"}):s.jsxs("select",{className:"mono seg_select",value:Lr,onChange:_=>Au(String(_.target.value||"")),disabled:!Wc.length,title:"Select run for cycles view",children:[Wc.length?null:s.jsx("option",{value:"",children:"(no runs)"}),Wc.map(_=>{const k=typeof Vn[_]=="number"?Number(Vn[_]):0,N=`${$t(_,18)}${k?` • ${k} llm`:""}`;return s.jsx("option",{value:_,children:N},_)})]}),s.jsx("button",{className:"seg_action",disabled:!He.length&&!pt.length,title:"Copy full ledger as JSONL",onClick:()=>{const N=[...He.map(H=>({run_id:u.trim()||H.record.run_id||"",cursor:H.cursor,record:H.record})),...pt.map(H=>({run_id:H.run_id,cursor:H.cursor,record:H.record}))].map(H=>{var Se,ie;const V=String(((Se=H.record)==null?void 0:Se.ended_at)||((ie=H.record)==null?void 0:ie.started_at)||"").trim(),J=bn(V);return{...H,_ms:J??0}});N.sort((H,V)=>(H._ms||0)-(V._ms||0));const U=(N.length>5e3?N.slice(N.length-5e3):N).map(({_ms:H,...V})=>JSON.stringify(V)).join(`
|
|
139
|
+
`);Lc(U)},children:"Copy JSONL"})]}):null,rr==="graph"?s.jsxs("div",{className:"tab_bar_controls",children:[s.jsx("button",{className:`seg_action ${dl?"active":""}`,onClick:()=>uf(_=>!_),children:"Subflows"}),s.jsx("button",{className:`seg_action ${Pu?"active":""}`,onClick:()=>df(_=>!_),children:"Path"}),ld.length?s.jsx("select",{className:"mono seg_select",value:Ps,onChange:_=>xo(String(_.target.value||"")),disabled:!!Us.trim()||!S.trim()||So,children:ld.map(_=>s.jsx("option",{value:_,children:_},_))}):null]}):null]}),rr==="overview"?s.jsx(xS,{run_id:u,run:an,run_state:ce,status_label:Pa||Wo||"unknown",workflow_label_by_id:qr,root_run_id:y,subrun_ids:ni,session_id:bs,records_count:He.length,records:He,child_records_count:pt.length,provider_activities:ts,attachments_count:la.length,latest_summary:Ol,wait_state:Tt,summary_generating:mf,summary_error:fh,on_generate_summary:()=>void Of(),on_open_runtime:()=>{const _=String(u||"").trim();_&&(gl(_),Nc(_),sr("run")),zu("artifacts"),t("runtime")},on_open_subrun:_=>void Pi(_,{root_run_id:y||u||_}),on_answer_wait:()=>Ts(""),workspace_root:_c,on_reveal_workspace:()=>void jf(),run_artifacts:of,run_artifacts_loading:ah,run_artifacts_error:lh,on_preview_run_artifact:_=>void Ic(_),on_download_run_artifact:_=>void Xu(_),timeline_items:Oa,node_index:qu,attachments:la,attachments_loading:ll,attachments_error:sf,attachments_ready:!!mc.trim(),on_refresh_attachments:()=>void Ma(),on_preview_attachment:_=>void zc(_),on_download_attachment:_=>void Oc(_),on_copy:_=>void Lc(_)}):null,rr==="ledger"?s.jsx(s.Fragment,{children:al==="steps"?s.jsxs("div",{className:"log log_scroll",children:[Il.map(_=>s.jsx(SS,{item:_,open:rh[_.id]===!0,on_toggle:()=>Nu(k=>({...k,[_.id]:!k[_.id]})),response_open:sh[_.id]===!0,on_toggle_response:()=>tf(k=>({...k,[_.id]:!k[_.id]})),node_index:qu,on_copy:k=>void Lc(k)},_.id)),Il.length?null:s.jsx("div",{className:"empty_state_inline",children:"(no ledger items)"})]}):s.jsx("div",{className:"log log_scroll",children:s.jsx(Ax,{items:qc.items,title:"Agent",subtitle:qc.node_id?`node_id: ${qc.node_id}`:"Live per-effect trace (LLM/tool calls).",subRunId:Lr,onOpenSubRun:Lr&&Lr!==u.trim()?()=>{m(Lr),Aa(Lr)}:void 0})})}):null,rr==="graph"?s.jsxs(s.Fragment,{children:[Lu?s.jsxs("div",{className:"log_item log_item_danger",children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{children:"graph error"}),s.jsx("span",{className:"mono",children:Nt()})]}),s.jsx("div",{className:"body mono",children:Lu})]}):null,So?s.jsxs("div",{className:"log_item log_item_info",children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{children:"loading"}),s.jsx("span",{className:"mono",children:Us.trim()?Us.trim():Ps})]}),s.jsx("div",{className:"body mono",children:"Loading graph…"})]}):null,s.jsx("div",{className:"graph_panel",children:s.jsx(LS,{flow:ti,flow_by_id:ul,expand_subflows:dl,simplify:!0,prefer_vertical:!0,vertical_compact:.78,schedule_next_in:md,schedule_interval:Uo,node_last_ms:Gf,active_node_id:Vf,recent_nodes:Ou,visited_nodes:dh,highlight_path:Pu,now_ms:ff})})]}):null,s.jsxs(Ka,{open:ch,title:cl||"Attachment",onClose:()=>{Xr(!1),wo(""),ua(""),yc(!1)},actions:s.jsx(s.Fragment,{children:s.jsx("button",{className:"btn",onClick:()=>{Xr(!1),wo(""),ua(""),yc(!1)},children:"Close"})}),children:[uh?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:"Loading…"}):null,Ru?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:Ru}):null,s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",maxHeight:"62vh",overflow:"auto",margin:0},children:cf||"(empty)"})]}),rr==="chat"?s.jsxs("div",{className:"ask_tab log_scroll",style:{marginTop:"6px"},children:[s.jsxs("div",{className:"ask_header",children:[s.jsx("span",{className:"ask_title",children:"Ask about this run"}),s.jsx("span",{className:"chip muted",title:"Model comes from Settings → Assistant (blank = gateway default)",children:(n.maintenance_ai_provider.trim()||"gateway")+" / "+(n.maintenance_ai_model.trim()||"default")}),s.jsx("span",{className:"pane_spacer"}),s.jsx("span",{className:"ask_hint",children:"Read-only · grounded in this run + subflows"})]}),s.jsxs("details",{className:"ask_manage",children:[s.jsx("summary",{children:"History & export"}),s.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[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(mu,{value:bu,options:ju,placeholder:sl?"Loading…":ju.length?"Select a saved discussion…":"(none saved)",disabled:!u.trim()||!j||!ju.length,loading:sl,searchable:!0,clearable:!0,onChange:_=>{il(_),yo("")}})}),s.jsxs("div",{className:"actions",style:{justifyContent:"flex-end",marginTop:0},children:[s.jsx("button",{className:"btn",type:"button",disabled:!bu.trim()||!j||cc,onClick:()=>void If(),children:cc?"Loading…":"Load"}),s.jsx("button",{className:"btn",type:"button",disabled:!Yt.length||nt||En||cc,onClick:()=>{Et([]),B(""),xe(""),Jn(""),Si(""),po("")},children:"Clear"}),s.jsx("button",{className:"btn",type:"button",onClick:()=>void $l(),disabled:!u.trim()||!j||sl,children:sl?"Refreshing…":"Refresh"})]})]}),s.jsxs("div",{className:"actions",style:{justifyContent:"flex-end",marginTop:"8px",flexWrap:"wrap"},children:[s.jsx("button",{className:"btn",type:"button",disabled:!Yt.length||!u.trim()||!j||En||!Su,onClick:()=>void _h(),title:Su?"":"No changes since last save",children:En?"Saving…":!Su&&bi?"Saved":"Save discussion"}),s.jsx("button",{className:"btn",type:"button",disabled:!Yt.length,onClick:()=>Bc("download"),children:"Export Markdown"}),s.jsx("button",{className:"btn",type:"button",disabled:!Yt.length,onClick:()=>Bc("copy"),children:Dt==="copied"?"Copied":Dt==="failed"?"Copy failed":"Copy Markdown"})]}),bi?s.jsxs("div",{className:"chat_hint",children:["Last saved: ",Yo(bi)]}):null,Br?s.jsx("div",{className:"chat_hint chat_hint_danger",children:Br}):null,ef?s.jsx("div",{className:"chat_hint chat_hint_danger",children:ef}):null,Qd?s.jsx("div",{className:"chat_hint chat_hint_danger",children:Qd}):null]})]}),ae?s.jsxs("div",{className:"log_item log_item_danger",children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{children:"error"}),s.jsx("span",{className:"mono",children:Nt()})]}),s.jsx("div",{className:"body mono",children:ae})]}):null,ke?s.jsxs("div",{className:"log_item log_item_danger",children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{children:"voice"}),s.jsx("span",{className:"mono",children:Nt()})]}),s.jsx("div",{className:"body mono",children:ke})]}):null,s.jsx("div",{className:"chat_messages",style:{marginTop:"10px"},children:s.jsx(Xy,{messages:Yt,className:"log_scroll",messageProps:Bn.tts_supported&&j&&We.trim()?{onSpeakToggle:Qu,getSpeakState:Ta,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(Jy,{ref:Zt,value:ho,onChange:B,onSubmit:()=>void zf(),placeholder:"Ask about this run…",disabled:!u.trim()||!j||nt,busy:nt||Bn.voice_ptt_busy,busyLabel:Bn.voice_ptt_busy?"Transcribing…":"Thinking…",rows:3,sendButtonClassName:"btn primary",actions:s.jsxs("button",{className:`btn btn_icon voice_btn${Bn.voice_ptt_recording?" danger":""}`,type:"button",disabled:!j||!Fo.trim()||!We.trim()||nt||Bn.voice_ptt_busy||!Bn.voice_ptt_supported,title:Bn.voice_ptt_supported?Bn.voice_ptt_busy?"Transcribing…":Bn.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:_=>{var k,N;if(!(!j||!Fo.trim()||!We.trim()||nt||Bn.voice_ptt_busy||!Bn.voice_ptt_supported)){_.preventDefault();try{(N=(k=_.currentTarget)==null?void 0:k.setPointerCapture)==null||N.call(k,_.pointerId)}catch{}Bn.start_voice_ptt_recording()}},onPointerUp:_=>{_.preventDefault(),Bn.stop_voice_ptt_recording()},onPointerCancel:_=>{_.preventDefault(),Bn.stop_voice_ptt_recording()},children:[s.jsx(Tn,{name:Bn.voice_ptt_recording?"x":"mic",size:16}),Bn.voice_ptt_busy?"Transcribing…":Bn.voice_ptt_recording?"Recording…":"Voice"]})})})]}):null,u.trim()?s.jsxs("div",{className:`status_bar ${mo?"pulse":""}`,children:[s.jsx("strong",{children:"Run"}),":"," ",s.jsx("span",{className:"mono",children:Pa||Wo||"unknown"}),dd&&md?s.jsxs("span",{className:"mono muted",children:[" • next in ",md]}):null,Ki?s.jsxs("span",{className:"mono muted",children:[" • ",Ki]}):null]}):null]})]})]})}):null,s.jsxs(Ka,{open:vs,title:li||"Artifact",onClose:()=>{ai(!1),to(""),Ao(""),ba(!1),Wr(null),dr&&(URL.revokeObjectURL(dr),xa(""))},actions:s.jsx("button",{className:"btn",onClick:()=>{ai(!1),to(""),Ao(""),ba(!1),Wr(null),dr&&(URL.revokeObjectURL(dr),xa(""))},children:"Close"}),children:[pf?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:"Loading…"}):null,Cc?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:Cc}):null,Ar==="image"&&dr?s.jsx("img",{className:"runtime_preview_media",src:dr,alt:li||"Artifact preview"}):Ar==="audio"&&dr?s.jsx("audio",{className:"runtime_preview_media",controls:!0,src:dr}):Ar==="video"&&dr?s.jsx("video",{className:"runtime_preview_media",controls:!0,src:dr}):s.jsx(mv,{artifact:$n,text:Mo||"(empty)",className:"runtime_preview_text"})]}),Yn?s.jsxs(Ka,{open:Yn,title:"Edit schedule",onClose:()=>{Xs(!1),zn(""),Xn(!0),Dn(""),Js(!1)},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{Xs(!1),zn(""),Xn(!0),Dn(""),Js(!1)},disabled:ne||us,children:"Back"}),s.jsx("button",{className:"btn primary",onClick:async()=>{await Fc({interval:na,apply_immediately:ls})||(Xs(!1),Dn(""),Js(!1))},disabled:ne||us||!na.trim(),children:"Save"})]}),children:[cs?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:Nt()})]}),s.jsx("div",{className:"body mono",children:cs})]}):null,s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Interval"}),s.jsx("input",{className:"mono",value:na,onChange:_=>zn(String(_.target.value||"")),placeholder:"20m / 1h / 0.5s / 250ms",disabled:ne||us}),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(_=>s.jsx("button",{className:"btn",onClick:()=>zn(_),disabled:ne||us,children:_},_))})]}),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:ls,onChange:_=>Xn(!!_.target.checked),disabled:ne||us}),"Apply immediately (recompute next run from now if waiting)"]})]})]}):null,Kt?s.jsxs(Ka,{open:Kt,title:"Compact scheduled context",onClose:()=>{uo(!1),tr(""),$r(!1)},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{uo(!1),tr(""),$r(!1)},disabled:ne||nr,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:async()=>{await Pf({preserve_recent:ra,compression_mode:Dr,focus:Zs})||(uo(!1),tr(""),$r(!1))},disabled:ne||nr,children:nr?"Compacting…":"Compact"})]}),children:[vi?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:Nt()})]}),s.jsx("div",{className:"body mono",children:vi})]}):null,s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Preserve recent turns"}),s.jsx("input",{type:"number",min:1,value:String(ra),onChange:_=>sa(Math.max(1,parseInt(_.target.value||"6",10)||6)),disabled:ne||nr})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Mode"}),s.jsxs("select",{value:Dr,onChange:_=>nl(_.target.value),disabled:ne||nr,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:Zs,onChange:_=>fo(String(_.target.value||"")),placeholder:"e.g. important decisions, next steps…",disabled:ne||nr})]})]}):null,wi?s.jsxs(Ka,{open:wi,title:Fr==="cancel"?"Cancel run":Bs?"Suspend schedule":"Pause run",onClose:()=>{ds(!1),ms(""),Qs("")},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{ds(!1),ms(""),Qs("")},disabled:ne||Te,children:"Back"}),s.jsx("button",{className:`btn ${Fr==="cancel"?"danger":"primary"}`,onClick:async()=>{Qs("");const _=await Lf(Fr,{reason:rl});if(_){Qs(_);return}ds(!1),ms(""),Qs("")},disabled:ne||Te,children:Fr==="pause"?Bs?"Suspend":"Pause":"Cancel"})]}),children:[oc?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:Nt()})]}),s.jsx("div",{className:"body mono",children:oc})]}):null,s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Reason (optional)"}),s.jsx("input",{className:"mono",value:rl,onChange:_=>ms(_.target.value),placeholder:"reason…"})]})]}):null,td?s.jsxs(Ka,{open:td,title:nd,onClose:()=>{br&&Ts(br)},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{Ls("ledger"),t("observe"),br&&Ts(br)},disabled:!u.trim(),children:"Open ledger"}),s.jsx("button",{className:"btn",onClick:()=>br&&Ts(br),disabled:Te,children:"Dismiss"}),so.length?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn danger",disabled:Te,onClick:()=>Ml({approved:!1}),children:"Reject"}),s.jsx("button",{className:"btn",disabled:Te,onClick:()=>Ml({approved:!0}),children:"Approve only"}),s.jsx("button",{className:"btn primary",disabled:!Na||Te,onClick:()=>Df(so),children:"Approve and execute"})]}):null]}),children:[s.jsxs("div",{className:"wait_context_panel",children:[s.jsxs("div",{className:"wait_context_header",children:[s.jsxs("div",{children:[s.jsx("div",{className:"run_hero_eyebrow",children:"What you need to do"}),s.jsx("strong",{children:nd}),s.jsx("p",{children:rd})]}),s.jsx(Qa,{status:In||"waiting"})]}),Ra?s.jsxs("div",{className:`wait_request_card ${Fs?"":"inferred"}`,children:[s.jsx("span",{children:ph}),s.jsx(xy,{metadata:Hf}),s.jsx(_i,{text:Ra}),Fs?null:s.jsx("p",{className:"wait_context_note",children:"The runtime did not attach a specific question to this wait. This is inferred from the run input; verify the session turns and workflow steps before answering."})]}):s.jsx("div",{className:"warn_callout",children:"This wait did not provide a clear prompt or recoverable prior user request. Review the full run input and recent workflow steps before submitting a response."}),sd.length?s.jsxs("section",{className:"wait_context_block wait_conversation_context",children:[s.jsx("span",{children:"Recent session turns"}),s.jsx("div",{className:"wait_turn_list",children:sd.map((_,k)=>s.jsxs("div",{className:`wait_turn_row role_${_.role.replace(/[^a-z0-9_-]+/g,"_")}`,children:[s.jsxs("div",{className:"wait_turn_meta",children:[s.jsx("strong",{children:_.role==="assistant"?"Assistant":_.role==="user"||_.role==="human"?"User":_.role}),_.ts?s.jsx("span",{className:"mono muted",children:Yo(_.ts)}):null]}),s.jsx(xy,{metadata:_.runtime_metadata}),s.jsx(_i,{text:_t(_.text,{max_chars:1200,max_lines:10})})]},`${_.role}:${k}`))})]}):null,s.jsxs("div",{className:"artifact_detail_grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Workflow"}),s.jsx("strong",{children:qs(Bo,qr)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Run"}),s.jsx("strong",{className:"mono",children:$t(u.trim(),24)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Node"}),s.jsx("strong",{className:"mono",children:Bo.current_node||String((xr==null?void 0:xr.node_id)||"—")})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Elapsed"}),s.jsx("strong",{children:rc(Bo)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Session"}),s.jsx("strong",{className:"mono",children:Bo.session_id?$t(String(Bo.session_id),18):"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Wait key"}),s.jsx("strong",{className:"mono",children:$t(br,28)})]})]}),id?s.jsxs("details",{className:"runtime_raw_details wait_full_input_details",open:!Ra,children:[s.jsx("summary",{className:"mono muted",children:"Full run input JSON"}),s.jsx("div",{className:"wait_shared_json",children:s.jsx(os,{value:Wf,collapseAfterDepth:4,showCopy:!0})})]}):null,s.jsxs("section",{className:"wait_context_block",children:[s.jsx("span",{children:"Recent workflow steps leading to this wait"}),s.jsxs("div",{className:"wait_event_list",children:[Uc.map(_=>s.jsxs("div",{className:"wait_event_row",children:[s.jsxs("span",{className:"mono",children:["#",_.cursor]}),s.jsx("strong",{children:_.summary||_.effect_type||_.status||"event"}),s.jsx("span",{className:"mono muted",children:[_.node_id,_.status,Yo(_.ts)].filter(Boolean).join(" · ")})]},`${_.cursor}:${_.node_id}:${_.status}`)),Uc.length?null:s.jsx("div",{className:"empty_state_inline",children:"No ledger context is loaded. Open the ledger before deciding."})]})]})]}),so.length?s.jsxs("div",{className:"wait_action_panel",children:[s.jsx("div",{className:"wait_action_intro",children:"Approve and execute runs the listed tool request through your configured worker. Approve only sends approval without local execution. Reject returns a denial. Cancel run stops the whole workflow run."}),s.jsx("div",{className:"wait_tool_list",children:so.map((_,k)=>s.jsxs("div",{className:"wait_tool_card",children:[s.jsxs("div",{className:"wait_tool_header",children:[s.jsx("strong",{children:String((_==null?void 0:_.name)||"tool")}),s.jsxs("div",{className:"wait_tool_badges",children:[s.jsx("span",{className:"chip mono warn",children:"approval"}),iv(_).map(N=>s.jsxs("span",{className:"chip mono muted",title:sv,children:[N,"~"]},N))]})]}),s.jsx("div",{className:"wait_tool_args",children:s.jsx(os,{value:(_==null?void 0:_.arguments)||{},collapseAfterDepth:3,showCopy:!0})})]},`${String((_==null?void 0:_.name)||"tool")}:${k}`))}),Na?null:s.jsx("div",{className:"warn_callout",children:"No tool worker is configured, so Observer cannot execute these calls directly."}),s.jsx("div",{className:"actions",children:s.jsx("button",{className:"btn danger",onClick:()=>void Ss(u.trim(),"Cancelled from wait prompt"),disabled:!u.trim()||Te,children:"Cancel whole run"})}),s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Diagnostics"}),s.jsx("div",{className:"wait_shared_json",children:s.jsx(os,{value:Tt||{},collapseAfterDepth:3,showCopy:!0})})]})]}):s.jsxs("div",{className:"wait_action_panel",children:[s.jsx("div",{className:"wait_action_intro",children:"Submit only when the request above is clear. The response resumes this wait only; Cancel run attempts to stop the whole workflow and prevent further work."}),s.jsx("div",{className:"wait_prompt_text",children:Ra||"No explicit prompt was provided. Open the ledger for context before responding."}),s.jsx(vS,{wait:Tt,disabled:Te,on_submit:_=>Ml({response:_})}),s.jsx("div",{className:"actions",children:s.jsx("button",{className:"btn danger",onClick:()=>void Ss(u.trim(),"Cancelled from wait prompt"),disabled:!u.trim()||Te,children:"Cancel whole run"})}),s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Diagnostics"}),s.jsx("div",{className:"wait_shared_json",children:s.jsx(os,{value:Tt||{},collapseAfterDepth:3,showCopy:!0})})]})]})]}):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())})}fx.createRoot(document.getElementById("root")).render(s.jsx(ye.StrictMode,{children:s.jsx(HE,{})}));
|
|
140
|
+
//# sourceMappingURL=index-BNRMqyx3.js.map
|