@parcha/agentrun-serve 0.1.0-beta.39 → 0.1.0-beta.40
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/CHANGELOG.md +37 -0
- package/README.md +51 -1
- package/dist/console/assets/index-B8Zn1Iqn.css +1 -0
- package/dist/console/assets/index-Jbxjcmdp.js +705 -0
- package/dist/console/index.html +2 -2
- package/dist/email/account.d.ts +0 -1
- package/dist/email/account.js +3 -3
- package/dist/email/answer.d.ts +5 -0
- package/dist/email/answer.js +35 -0
- package/dist/email/mail.js +19 -26
- package/dist/email/names.d.ts +30 -0
- package/dist/email/names.js +34 -0
- package/dist/email/routes.d.ts +1 -0
- package/dist/email/routes.js +1 -1
- package/dist/email/tools.d.ts +11 -4
- package/dist/email/tools.js +91 -46
- package/dist/eval-mailbox.d.ts +1 -1
- package/dist/eval-mailbox.js +3 -3
- package/dist/learn/compile.d.ts +3 -2
- package/dist/learn/compile.js +6 -5
- package/dist/learn/promote.d.ts +25 -14
- package/dist/learn/promote.js +32 -14
- package/dist/learning-cost.d.ts +17 -8
- package/dist/learning-cost.js +12 -4
- package/dist/local-models.d.ts +7 -1
- package/dist/local-models.js +11 -5
- package/dist/openapi.d.ts +1 -1
- package/dist/openapi.js +17 -15
- package/dist/port-models.d.ts +4 -1
- package/dist/port-models.js +1 -0
- package/dist/refusal-words.d.ts +3 -0
- package/dist/refusal-words.js +3 -0
- package/dist/run-launch.d.ts +2 -0
- package/dist/run-launch.js +2 -0
- package/dist/run-view.d.ts +3 -4
- package/dist/run-view.js +26 -24
- package/dist/runner/adapter-loop.d.ts +6 -2
- package/dist/runner/adapter-loop.js +45 -12
- package/dist/runner/adapter-run-spec.d.ts +1 -0
- package/dist/runner/adapter-run-spec.js +37 -1
- package/dist/runner/cli-run-spec.js +1 -0
- package/dist/runner/journal-kinds.d.ts +22 -0
- package/dist/runner/journal-kinds.js +39 -0
- package/dist/runner/model-route.d.ts +3 -1
- package/dist/runner/model-route.js +18 -3
- package/dist/runner/promotion.d.ts +8 -8
- package/dist/runner/promotion.js +135 -54
- package/dist/server.js +15 -8
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/postgres/connection.d.ts +11 -5
- package/dist/store/postgres/connection.js +44 -17
- package/dist/store/postgres/dialect.js +5 -0
- package/dist/store/postgres/store.d.ts +7 -3
- package/dist/store/postgres/store.js +1 -0
- package/dist/store/sqlite/connection.js +72 -8
- package/dist/store/sqlite/run-launch.d.ts +11 -0
- package/dist/store/sqlite/run-launch.js +8 -0
- package/dist/store/sqlite/store.js +37 -16
- package/dist/store/sqlite/worker.d.ts +2 -0
- package/dist/store/sqlite/worker.js +13 -10
- package/dist/store/store.d.ts +15 -0
- package/dist/store-reads/learning.d.ts +30 -13
- package/dist/store-reads/learning.js +125 -51
- package/dist/template-eval.js +1 -1
- package/dist/templates.d.ts +14 -1
- package/dist/templates.js +67 -17
- package/dist/tool-gate.d.ts +5 -3
- package/dist/tool-gate.js +5 -2
- package/dist/tools.d.ts +13 -0
- package/dist/tools.js +15 -10
- package/dist/trigger-adapter.d.ts +3 -32
- package/dist/trigger-email.js +30 -77
- package/dist/triggers.d.ts +26 -14
- package/dist/triggers.js +99 -76
- package/dist/workflow/decision-recovery.js +5 -2
- package/dist/workflow/decisions.d.ts +7 -0
- package/package.json +9 -9
- package/templates/README.md +2 -2
- package/dist/console/assets/index-BNhZs-jp.css +0 -1
- package/dist/console/assets/index-BQv5aOGB.js +0 -700
|
@@ -0,0 +1,705 @@
|
|
|
1
|
+
var K_=Object.defineProperty;var V_=(e,n,s)=>n in e?K_(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var Tt=(e,n,s)=>V_(e,typeof n!="symbol"?n+"":n,s);function Y_(e,n){for(var s=0;s<n.length;s++){const r=n[s];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const i=Object.getOwnPropertyDescriptor(r,a);i&&Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function s(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=s(a);fetch(a.href,i)}})();function bN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pp={exports:{}},rc={},Lp={exports:{}},xt={};/**
|
|
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 qw;function Q_(){if(qw)return xt;qw=1;var e=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.iterator;function x(z){return z===null||typeof z!="object"?null:(z=b&&z[b]||z["@@iterator"],typeof z=="function"?z:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,y={};function j(z,Q,K){this.props=z,this.context=Q,this.refs=y,this.updater=K||h}j.prototype.isReactComponent={},j.prototype.setState=function(z,Q){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,Q,"setState")},j.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function k(){}k.prototype=j.prototype;function E(z,Q,K){this.props=z,this.context=Q,this.refs=y,this.updater=K||h}var S=E.prototype=new k;S.constructor=E,v(S,j.prototype),S.isPureReactComponent=!0;var N=Array.isArray,_=Object.prototype.hasOwnProperty,$={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function A(z,Q,K){var Z,de={},se=null,ue=null;if(Q!=null)for(Z in Q.ref!==void 0&&(ue=Q.ref),Q.key!==void 0&&(se=""+Q.key),Q)_.call(Q,Z)&&!O.hasOwnProperty(Z)&&(de[Z]=Q[Z]);var xe=arguments.length-2;if(xe===1)de.children=K;else if(1<xe){for(var $e=Array(xe),ge=0;ge<xe;ge++)$e[ge]=arguments[ge+2];de.children=$e}if(z&&z.defaultProps)for(Z in xe=z.defaultProps,xe)de[Z]===void 0&&(de[Z]=xe[Z]);return{$$typeof:e,type:z,key:se,ref:ue,props:de,_owner:$.current}}function L(z,Q){return{$$typeof:e,type:z.type,key:Q,ref:z.ref,props:z.props,_owner:z._owner}}function M(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function R(z){var Q={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(K){return Q[K]})}var P=/\/+/g;function D(z,Q){return typeof z=="object"&&z!==null&&z.key!=null?R(""+z.key):Q.toString(36)}function W(z,Q,K,Z,de){var se=typeof z;(se==="undefined"||se==="boolean")&&(z=null);var ue=!1;if(z===null)ue=!0;else switch(se){case"string":case"number":ue=!0;break;case"object":switch(z.$$typeof){case e:case n:ue=!0}}if(ue)return ue=z,de=de(ue),z=Z===""?"."+D(ue,0):Z,N(de)?(K="",z!=null&&(K=z.replace(P,"$&/")+"/"),W(de,Q,K,"",function(ge){return ge})):de!=null&&(M(de)&&(de=L(de,K+(!de.key||ue&&ue.key===de.key?"":(""+de.key).replace(P,"$&/")+"/")+z)),Q.push(de)),1;if(ue=0,Z=Z===""?".":Z+":",N(z))for(var xe=0;xe<z.length;xe++){se=z[xe];var $e=Z+D(se,xe);ue+=W(se,Q,K,$e,de)}else if($e=x(z),typeof $e=="function")for(z=$e.call(z),xe=0;!(se=z.next()).done;)se=se.value,$e=Z+D(se,xe++),ue+=W(se,Q,K,$e,de);else if(se==="object")throw Q=String(z),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.");return ue}function Y(z,Q,K){if(z==null)return z;var Z=[],de=0;return W(z,Z,"","",function(se){return Q.call(K,se,de++)}),Z}function H(z){if(z._status===-1){var Q=z._result;Q=Q(),Q.then(function(K){(z._status===0||z._status===-1)&&(z._status=1,z._result=K)},function(K){(z._status===0||z._status===-1)&&(z._status=2,z._result=K)}),z._status===-1&&(z._status=0,z._result=Q)}if(z._status===1)return z._result.default;throw z._result}var q={current:null},F={transition:null},G={ReactCurrentDispatcher:q,ReactCurrentBatchConfig:F,ReactCurrentOwner:$};function U(){throw Error("act(...) is not supported in production builds of React.")}return xt.Children={map:Y,forEach:function(z,Q,K){Y(z,function(){Q.apply(this,arguments)},K)},count:function(z){var Q=0;return Y(z,function(){Q++}),Q},toArray:function(z){return Y(z,function(Q){return Q})||[]},only:function(z){if(!M(z))throw Error("React.Children.only expected to receive a single React element child.");return z}},xt.Component=j,xt.Fragment=s,xt.Profiler=a,xt.PureComponent=E,xt.StrictMode=r,xt.Suspense=u,xt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G,xt.act=U,xt.cloneElement=function(z,Q,K){if(z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+z+".");var Z=v({},z.props),de=z.key,se=z.ref,ue=z._owner;if(Q!=null){if(Q.ref!==void 0&&(se=Q.ref,ue=$.current),Q.key!==void 0&&(de=""+Q.key),z.type&&z.type.defaultProps)var xe=z.type.defaultProps;for($e in Q)_.call(Q,$e)&&!O.hasOwnProperty($e)&&(Z[$e]=Q[$e]===void 0&&xe!==void 0?xe[$e]:Q[$e])}var $e=arguments.length-2;if($e===1)Z.children=K;else if(1<$e){xe=Array($e);for(var ge=0;ge<$e;ge++)xe[ge]=arguments[ge+2];Z.children=xe}return{$$typeof:e,type:z.type,key:de,ref:se,props:Z,_owner:ue}},xt.createContext=function(z){return z={$$typeof:c,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},z.Provider={$$typeof:i,_context:z},z.Consumer=z},xt.createElement=A,xt.createFactory=function(z){var Q=A.bind(null,z);return Q.type=z,Q},xt.createRef=function(){return{current:null}},xt.forwardRef=function(z){return{$$typeof:d,render:z}},xt.isValidElement=M,xt.lazy=function(z){return{$$typeof:g,_payload:{_status:-1,_result:z},_init:H}},xt.memo=function(z,Q){return{$$typeof:f,type:z,compare:Q===void 0?null:Q}},xt.startTransition=function(z){var Q=F.transition;F.transition={};try{z()}finally{F.transition=Q}},xt.unstable_act=U,xt.useCallback=function(z,Q){return q.current.useCallback(z,Q)},xt.useContext=function(z){return q.current.useContext(z)},xt.useDebugValue=function(){},xt.useDeferredValue=function(z){return q.current.useDeferredValue(z)},xt.useEffect=function(z,Q){return q.current.useEffect(z,Q)},xt.useId=function(){return q.current.useId()},xt.useImperativeHandle=function(z,Q,K){return q.current.useImperativeHandle(z,Q,K)},xt.useInsertionEffect=function(z,Q){return q.current.useInsertionEffect(z,Q)},xt.useLayoutEffect=function(z,Q){return q.current.useLayoutEffect(z,Q)},xt.useMemo=function(z,Q){return q.current.useMemo(z,Q)},xt.useReducer=function(z,Q,K){return q.current.useReducer(z,Q,K)},xt.useRef=function(z){return q.current.useRef(z)},xt.useState=function(z){return q.current.useState(z)},xt.useSyncExternalStore=function(z,Q,K){return q.current.useSyncExternalStore(z,Q,K)},xt.useTransition=function(){return q.current.useTransition()},xt.version="18.3.1",xt}var Kw;function sm(){return Kw||(Kw=1,Lp.exports=Q_()),Lp.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 Vw;function J_(){if(Vw)return rc;Vw=1;var e=sm(),n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(d,u,f){var g,b={},x=null,h=null;f!==void 0&&(x=""+f),u.key!==void 0&&(x=""+u.key),u.ref!==void 0&&(h=u.ref);for(g in u)r.call(u,g)&&!i.hasOwnProperty(g)&&(b[g]=u[g]);if(d&&d.defaultProps)for(g in u=d.defaultProps,u)b[g]===void 0&&(b[g]=u[g]);return{$$typeof:n,type:d,key:x,ref:h,props:b,_owner:a.current}}return rc.Fragment=s,rc.jsx=c,rc.jsxs=c,rc}var Yw;function X_(){return Yw||(Yw=1,Pp.exports=J_()),Pp.exports}var t=X_(),p=sm();const qe=bN(p),_g=Y_({__proto__:null,default:qe},[p]);var Tu={},Ip={exports:{}},ds={},zp={exports:{}},Dp={};/**
|
|
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 Qw;function Z_(){return Qw||(Qw=1,(function(e){function n(F,G){var U=F.length;F.push(G);e:for(;0<U;){var z=U-1>>>1,Q=F[z];if(0<a(Q,G))F[z]=G,F[U]=Q,U=z;else break e}}function s(F){return F.length===0?null:F[0]}function r(F){if(F.length===0)return null;var G=F[0],U=F.pop();if(U!==G){F[0]=U;e:for(var z=0,Q=F.length,K=Q>>>1;z<K;){var Z=2*(z+1)-1,de=F[Z],se=Z+1,ue=F[se];if(0>a(de,U))se<Q&&0>a(ue,de)?(F[z]=ue,F[se]=U,z=se):(F[z]=de,F[Z]=U,z=Z);else if(se<Q&&0>a(ue,U))F[z]=ue,F[se]=U,z=se;else break e}}return G}function a(F,G){var U=F.sortIndex-G.sortIndex;return U!==0?U:F.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var u=[],f=[],g=1,b=null,x=3,h=!1,v=!1,y=!1,j=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(F){for(var G=s(f);G!==null;){if(G.callback===null)r(f);else if(G.startTime<=F)r(f),G.sortIndex=G.expirationTime,n(u,G);else break;G=s(f)}}function N(F){if(y=!1,S(F),!v)if(s(u)!==null)v=!0,H(_);else{var G=s(f);G!==null&&q(N,G.startTime-F)}}function _(F,G){v=!1,y&&(y=!1,k(A),A=-1),h=!0;var U=x;try{for(S(G),b=s(u);b!==null&&(!(b.expirationTime>G)||F&&!R());){var z=b.callback;if(typeof z=="function"){b.callback=null,x=b.priorityLevel;var Q=z(b.expirationTime<=G);G=e.unstable_now(),typeof Q=="function"?b.callback=Q:b===s(u)&&r(u),S(G)}else r(u);b=s(u)}if(b!==null)var K=!0;else{var Z=s(f);Z!==null&&q(N,Z.startTime-G),K=!1}return K}finally{b=null,x=U,h=!1}}var $=!1,O=null,A=-1,L=5,M=-1;function R(){return!(e.unstable_now()-M<L)}function P(){if(O!==null){var F=e.unstable_now();M=F;var G=!0;try{G=O(!0,F)}finally{G?D():($=!1,O=null)}}else $=!1}var D;if(typeof E=="function")D=function(){E(P)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,Y=W.port2;W.port1.onmessage=P,D=function(){Y.postMessage(null)}}else D=function(){j(P,0)};function H(F){O=F,$||($=!0,D())}function q(F,G){A=j(function(){F(e.unstable_now())},G)}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(F){F.callback=null},e.unstable_continueExecution=function(){v||h||(v=!0,H(_))},e.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<F?Math.floor(1e3/F):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return s(u)},e.unstable_next=function(F){switch(x){case 1:case 2:case 3:var G=3;break;default:G=x}var U=x;x=G;try{return F()}finally{x=U}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(F,G){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var U=x;x=F;try{return G()}finally{x=U}},e.unstable_scheduleCallback=function(F,G,U){var z=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?z+U:z):U=z,F){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=U+Q,F={id:g++,callback:G,priorityLevel:F,startTime:U,expirationTime:Q,sortIndex:-1},U>z?(F.sortIndex=U,n(f,F),s(u)===null&&F===s(f)&&(y?(k(A),A=-1):y=!0,q(N,U-z))):(F.sortIndex=Q,n(u,F),v||h||(v=!0,H(_))),F},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(F){var G=x;return function(){var U=x;x=G;try{return F.apply(this,arguments)}finally{x=U}}}})(Dp)),Dp}var Jw;function eT(){return Jw||(Jw=1,zp.exports=Z_()),zp.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 Xw;function tT(){if(Xw)return ds;Xw=1;var e=sm(),n=eT();function s(o){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+o,m=1;m<arguments.length;m++)l+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+o+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,a={};function i(o,l){c(o,l),c(o+"Capture",l)}function c(o,l){for(a[o]=l,o=0;o<l.length;o++)r.add(l[o])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[: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={},b={};function x(o){return u.call(b,o)?!0:u.call(g,o)?!1:f.test(o)?b[o]=!0:(g[o]=!0,!1)}function h(o,l,m,w){if(m!==null&&m.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return w?!1:m!==null?!m.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function v(o,l,m,w){if(l===null||typeof l>"u"||h(o,l,m,w))return!0;if(w)return!1;if(m!==null)switch(m.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function y(o,l,m,w,C,T,I){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=w,this.attributeNamespace=C,this.mustUseProperty=m,this.propertyName=o,this.type=l,this.sanitizeURL=T,this.removeEmptyString=I}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(o){j[o]=new y(o,0,!1,o,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(o){var l=o[0];j[l]=new y(l,1,!1,o[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(o){j[o]=new y(o,2,!1,o.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(o){j[o]=new y(o,2,!1,o,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(o){j[o]=new y(o,3,!1,o.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(o){j[o]=new y(o,3,!0,o,null,!1,!1)}),["capture","download"].forEach(function(o){j[o]=new y(o,4,!1,o,null,!1,!1)}),["cols","rows","size","span"].forEach(function(o){j[o]=new y(o,6,!1,o,null,!1,!1)}),["rowSpan","start"].forEach(function(o){j[o]=new y(o,5,!1,o.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function E(o){return o[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(o){var l=o.replace(k,E);j[l]=new y(l,1,!1,o,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(o){var l=o.replace(k,E);j[l]=new y(l,1,!1,o,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(o){var l=o.replace(k,E);j[l]=new y(l,1,!1,o,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(o){j[o]=new y(o,1,!1,o.toLowerCase(),null,!1,!1)}),j.xlinkHref=new y("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(o){j[o]=new y(o,1,!1,o.toLowerCase(),null,!0,!0)});function S(o,l,m,w){var C=j.hasOwnProperty(l)?j[l]:null;(C!==null?C.type!==0:w||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(v(l,m,C,w)&&(m=null),w||C===null?x(l)&&(m===null?o.removeAttribute(l):o.setAttribute(l,""+m)):C.mustUseProperty?o[C.propertyName]=m===null?C.type===3?!1:"":m:(l=C.attributeName,w=C.attributeNamespace,m===null?o.removeAttribute(l):(C=C.type,m=C===3||C===4&&m===!0?"":""+m,w?o.setAttributeNS(w,l,m):o.setAttribute(l,m))))}var N=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_=Symbol.for("react.element"),$=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),M=Symbol.for("react.provider"),R=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),q=Symbol.for("react.offscreen"),F=Symbol.iterator;function G(o){return o===null||typeof o!="object"?null:(o=F&&o[F]||o["@@iterator"],typeof o=="function"?o:null)}var U=Object.assign,z;function Q(o){if(z===void 0)try{throw Error()}catch(m){var l=m.stack.trim().match(/\n( *(at )?)/);z=l&&l[1]||""}return`
|
|
34
|
+
`+z+o}var K=!1;function Z(o,l){if(!o||K)return"";K=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ce){var w=ce}Reflect.construct(o,[],l)}else{try{l.call()}catch(ce){w=ce}o.call(l.prototype)}else{try{throw Error()}catch(ce){w=ce}o()}}catch(ce){if(ce&&w&&typeof ce.stack=="string"){for(var C=ce.stack.split(`
|
|
35
|
+
`),T=w.stack.split(`
|
|
36
|
+
`),I=C.length-1,V=T.length-1;1<=I&&0<=V&&C[I]!==T[V];)V--;for(;1<=I&&0<=V;I--,V--)if(C[I]!==T[V]){if(I!==1||V!==1)do if(I--,V--,0>V||C[I]!==T[V]){var X=`
|
|
37
|
+
`+C[I].replace(" at new "," at ");return o.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",o.displayName)),X}while(1<=I&&0<=V);break}}}finally{K=!1,Error.prepareStackTrace=m}return(o=o?o.displayName||o.name:"")?Q(o):""}function de(o){switch(o.tag){case 5:return Q(o.type);case 16:return Q("Lazy");case 13:return Q("Suspense");case 19:return Q("SuspenseList");case 0:case 2:case 15:return o=Z(o.type,!1),o;case 11:return o=Z(o.type.render,!1),o;case 1:return o=Z(o.type,!0),o;default:return""}}function se(o){if(o==null)return null;if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case O:return"Fragment";case $:return"Portal";case L:return"Profiler";case A:return"StrictMode";case D:return"Suspense";case W:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case R:return(o.displayName||"Context")+".Consumer";case M:return(o._context.displayName||"Context")+".Provider";case P:var l=o.render;return o=o.displayName,o||(o=l.displayName||l.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case Y:return l=o.displayName||null,l!==null?l:se(o.type)||"Memo";case H:l=o._payload,o=o._init;try{return se(o(l))}catch{}}return null}function ue(o){var l=o.type;switch(o.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=l.render,o=o.displayName||o.name||"",l.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return se(l);case 8:return l===A?"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 l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function xe(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function $e(o){var l=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function ge(o){var l=$e(o)?"checked":"value",m=Object.getOwnPropertyDescriptor(o.constructor.prototype,l),w=""+o[l];if(!o.hasOwnProperty(l)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var C=m.get,T=m.set;return Object.defineProperty(o,l,{configurable:!0,get:function(){return C.call(this)},set:function(I){w=""+I,T.call(this,I)}}),Object.defineProperty(o,l,{enumerable:m.enumerable}),{getValue:function(){return w},setValue:function(I){w=""+I},stopTracking:function(){o._valueTracker=null,delete o[l]}}}}function fe(o){o._valueTracker||(o._valueTracker=ge(o))}function me(o){if(!o)return!1;var l=o._valueTracker;if(!l)return!0;var m=l.getValue(),w="";return o&&(w=$e(o)?o.checked?"true":"false":o.value),o=w,o!==m?(l.setValue(o),!0):!1}function je(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}function Me(o,l){var m=l.checked;return U({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??o._wrapperState.initialChecked})}function _e(o,l){var m=l.defaultValue==null?"":l.defaultValue,w=l.checked!=null?l.checked:l.defaultChecked;m=xe(l.value!=null?l.value:m),o._wrapperState={initialChecked:w,initialValue:m,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function re(o,l){l=l.checked,l!=null&&S(o,"checked",l,!1)}function Re(o,l){re(o,l);var m=xe(l.value),w=l.type;if(m!=null)w==="number"?(m===0&&o.value===""||o.value!=m)&&(o.value=""+m):o.value!==""+m&&(o.value=""+m);else if(w==="submit"||w==="reset"){o.removeAttribute("value");return}l.hasOwnProperty("value")?at(o,l.type,m):l.hasOwnProperty("defaultValue")&&at(o,l.type,xe(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(o.defaultChecked=!!l.defaultChecked)}function Ze(o,l,m){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var w=l.type;if(!(w!=="submit"&&w!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+o._wrapperState.initialValue,m||l===o.value||(o.value=l),o.defaultValue=l}m=o.name,m!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,m!==""&&(o.name=m)}function at(o,l,m){(l!=="number"||je(o.ownerDocument)!==o)&&(m==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+m&&(o.defaultValue=""+m))}var pt=Array.isArray;function Ee(o,l,m,w){if(o=o.options,l){l={};for(var C=0;C<m.length;C++)l["$"+m[C]]=!0;for(m=0;m<o.length;m++)C=l.hasOwnProperty("$"+o[m].value),o[m].selected!==C&&(o[m].selected=C),C&&w&&(o[m].defaultSelected=!0)}else{for(m=""+xe(m),l=null,C=0;C<o.length;C++){if(o[C].value===m){o[C].selected=!0,w&&(o[C].defaultSelected=!0);return}l!==null||o[C].disabled||(l=o[C])}l!==null&&(l.selected=!0)}}function Je(o,l){if(l.dangerouslySetInnerHTML!=null)throw Error(s(91));return U({},l,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function he(o,l){var m=l.value;if(m==null){if(m=l.children,l=l.defaultValue,m!=null){if(l!=null)throw Error(s(92));if(pt(m)){if(1<m.length)throw Error(s(93));m=m[0]}l=m}l==null&&(l=""),m=l}o._wrapperState={initialValue:xe(m)}}function Fe(o,l){var m=xe(l.value),w=xe(l.defaultValue);m!=null&&(m=""+m,m!==o.value&&(o.value=m),l.defaultValue==null&&o.defaultValue!==m&&(o.defaultValue=m)),w!=null&&(o.defaultValue=""+w)}function ut(o){var l=o.textContent;l===o._wrapperState.initialValue&&l!==""&&l!==null&&(o.value=l)}function Pe(o){switch(o){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 ct(o,l){return o==null||o==="http://www.w3.org/1999/xhtml"?Pe(l):o==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var _t,tt=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,m,w,C){MSApp.execUnsafeLocalFunction(function(){return o(l,m,w,C)})}:o})(function(o,l){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=l;else{for(_t=_t||document.createElement("div"),_t.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=_t.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;l.firstChild;)o.appendChild(l.firstChild)}});function ft(o,l){if(l){var m=o.firstChild;if(m&&m===o.lastChild&&m.nodeType===3){m.nodeValue=l;return}}o.textContent=l}var qt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},zt=["Webkit","ms","Moz","O"];Object.keys(qt).forEach(function(o){zt.forEach(function(l){l=l+o.charAt(0).toUpperCase()+o.substring(1),qt[l]=qt[o]})});function ye(o,l,m){return l==null||typeof l=="boolean"||l===""?"":m||typeof l!="number"||l===0||qt.hasOwnProperty(o)&&qt[o]?(""+l).trim():l+"px"}function le(o,l){o=o.style;for(var m in l)if(l.hasOwnProperty(m)){var w=m.indexOf("--")===0,C=ye(m,l[m],w);m==="float"&&(m="cssFloat"),w?o.setProperty(m,C):o[m]=C}}var Ue=U({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 Xe(o,l){if(l){if(Ue[o]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(s(137,o));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(s(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(s(61))}if(l.style!=null&&typeof l.style!="object")throw Error(s(62))}}function rt(o,l){if(o.indexOf("-")===-1)return typeof l.is=="string";switch(o){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 J=null;function ve(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var We=null,Se=null,Ye=null;function Nt(o){if(o=Hl(o)){if(typeof We!="function")throw Error(s(280));var l=o.stateNode;l&&(l=Gd(l),We(o.stateNode,o.type,l))}}function It(o){Se?Ye?Ye.push(o):Ye=[o]:Se=o}function ot(){if(Se){var o=Se,l=Ye;if(Ye=Se=null,Nt(o),l)for(o=0;o<l.length;o++)Nt(l[o])}}function Rn(o,l){return o(l)}function hs(){}var Ys=!1;function En(o,l,m){if(Ys)return o(l,m);Ys=!0;try{return Rn(o,l,m)}finally{Ys=!1,(Se!==null||Ye!==null)&&(hs(),ot())}}function Un(o,l){var m=o.stateNode;if(m===null)return null;var w=Gd(m);if(w===null)return null;m=w[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(o=o.type,w=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!w;break e;default:o=!1}if(o)return null;if(m&&typeof m!="function")throw Error(s(231,l,typeof m));return m}var ps=!1;if(d)try{var gs={};Object.defineProperty(gs,"passive",{get:function(){ps=!0}}),window.addEventListener("test",gs,gs),window.removeEventListener("test",gs,gs)}catch{ps=!1}function fn(o,l,m,w,C,T,I,V,X){var ce=Array.prototype.slice.call(arguments,3);try{l.apply(m,ce)}catch(ke){this.onError(ke)}}var Wn=!1,$s=null,Hn=!1,_s=null,Ts={onError:function(o){Wn=!0,$s=o}};function An(o,l,m,w,C,T,I,V,X){Wn=!1,$s=null,fn.apply(Ts,arguments)}function ee(o,l,m,w,C,T,I,V,X){if(An.apply(this,arguments),Wn){if(Wn){var ce=$s;Wn=!1,$s=null}else throw Error(s(198));Hn||(Hn=!0,_s=ce)}}function Le(o){var l=o,m=o;if(o.alternate)for(;l.return;)l=l.return;else{o=l;do l=o,(l.flags&4098)!==0&&(m=l.return),o=l.return;while(o)}return l.tag===3?m:null}function mt(o){if(o.tag===13){var l=o.memoizedState;if(l===null&&(o=o.alternate,o!==null&&(l=o.memoizedState)),l!==null)return l.dehydrated}return null}function At(o){if(Le(o)!==o)throw Error(s(188))}function Qt(o){var l=o.alternate;if(!l){if(l=Le(o),l===null)throw Error(s(188));return l!==o?null:o}for(var m=o,w=l;;){var C=m.return;if(C===null)break;var T=C.alternate;if(T===null){if(w=C.return,w!==null){m=w;continue}break}if(C.child===T.child){for(T=C.child;T;){if(T===m)return At(C),o;if(T===w)return At(C),l;T=T.sibling}throw Error(s(188))}if(m.return!==w.return)m=C,w=T;else{for(var I=!1,V=C.child;V;){if(V===m){I=!0,m=C,w=T;break}if(V===w){I=!0,w=C,m=T;break}V=V.sibling}if(!I){for(V=T.child;V;){if(V===m){I=!0,m=T,w=C;break}if(V===w){I=!0,w=T,m=C;break}V=V.sibling}if(!I)throw Error(s(189))}}if(m.alternate!==w)throw Error(s(190))}if(m.tag!==3)throw Error(s(188));return m.stateNode.current===m?o:l}function He(o){return o=Qt(o),o!==null?te(o):null}function te(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var l=te(o);if(l!==null)return l;o=o.sibling}return null}var be=n.unstable_scheduleCallback,Ge=n.unstable_cancelCallback,kt=n.unstable_shouldYield,Pt=n.unstable_requestPaint,it=n.unstable_now,bn=n.unstable_getCurrentPriorityLevel,$n=n.unstable_ImmediatePriority,ur=n.unstable_UserBlockingPriority,Wt=n.unstable_NormalPriority,si=n.unstable_LowPriority,io=n.unstable_IdlePriority,ra=null,xs=null;function Cd(o){if(xs&&typeof xs.onCommitFiberRoot=="function")try{xs.onCommitFiberRoot(ra,o,void 0,(o.current.flags&128)===128)}catch{}}var ss=Math.clz32?Math.clz32:_d,Ed=Math.log,$d=Math.LN2;function _d(o){return o>>>=0,o===0?32:31-(Ed(o)/$d|0)|0}var oa=64,aa=4194304;function lo(o){switch(o&-o){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 o&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return o&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return o}}function ia(o,l){var m=o.pendingLanes;if(m===0)return 0;var w=0,C=o.suspendedLanes,T=o.pingedLanes,I=m&268435455;if(I!==0){var V=I&~C;V!==0?w=lo(V):(T&=I,T!==0&&(w=lo(T)))}else I=m&~C,I!==0?w=lo(I):T!==0&&(w=lo(T));if(w===0)return 0;if(l!==0&&l!==w&&(l&C)===0&&(C=w&-w,T=l&-l,C>=T||C===16&&(T&4194240)!==0))return l;if((w&4)!==0&&(w|=m&16),l=o.entangledLanes,l!==0)for(o=o.entanglements,l&=w;0<l;)m=31-ss(l),C=1<<m,w|=o[m],l&=~C;return w}function Td(o,l){switch(o){case 1:case 2:case 4:return l+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 l+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 Rd(o,l){for(var m=o.suspendedLanes,w=o.pingedLanes,C=o.expirationTimes,T=o.pendingLanes;0<T;){var I=31-ss(T),V=1<<I,X=C[I];X===-1?((V&m)===0||(V&w)!==0)&&(C[I]=Td(V,l)):X<=l&&(o.expiredLanes|=V),T&=~V}}function ri(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function Cl(){var o=oa;return oa<<=1,(oa&4194240)===0&&(oa=64),o}function oi(o){for(var l=[],m=0;31>m;m++)l.push(o);return l}function co(o,l,m){o.pendingLanes|=l,l!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,l=31-ss(l),o[l]=m}function Ad(o,l){var m=o.pendingLanes&~l;o.pendingLanes=l,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=l,o.mutableReadLanes&=l,o.entangledLanes&=l,l=o.entanglements;var w=o.eventTimes;for(o=o.expirationTimes;0<m;){var C=31-ss(m),T=1<<C;l[C]=0,w[C]=-1,o[C]=-1,m&=~T}}function ai(o,l){var m=o.entangledLanes|=l;for(o=o.entanglements;m;){var w=31-ss(m),C=1<<w;C&l|o[w]&l&&(o[w]|=l),m&=~C}}var Ct=0;function El(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var $l,ii,_l,Tl,Rl,li=!1,la=[],Qs=null,Js=null,Xs=null,pe=new Map,Te=new Map,Ie=[],Et="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 wt(o,l){switch(o){case"focusin":case"focusout":Qs=null;break;case"dragenter":case"dragleave":Js=null;break;case"mouseover":case"mouseout":Xs=null;break;case"pointerover":case"pointerout":pe.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Te.delete(l.pointerId)}}function rs(o,l,m,w,C,T){return o===null||o.nativeEvent!==T?(o={blockedOn:l,domEventName:m,eventSystemFlags:w,nativeEvent:T,targetContainers:[C]},l!==null&&(l=Hl(l),l!==null&&ii(l)),o):(o.eventSystemFlags|=w,l=o.targetContainers,C!==null&&l.indexOf(C)===-1&&l.push(C),o)}function Bn(o,l,m,w,C){switch(l){case"focusin":return Qs=rs(Qs,o,l,m,w,C),!0;case"dragenter":return Js=rs(Js,o,l,m,w,C),!0;case"mouseover":return Xs=rs(Xs,o,l,m,w,C),!0;case"pointerover":var T=C.pointerId;return pe.set(T,rs(pe.get(T)||null,o,l,m,w,C)),!0;case"gotpointercapture":return T=C.pointerId,Te.set(T,rs(Te.get(T)||null,o,l,m,w,C)),!0}return!1}function Gn(o){var l=ca(o.target);if(l!==null){var m=Le(l);if(m!==null){if(l=m.tag,l===13){if(l=mt(m),l!==null){o.blockedOn=l,Rl(o.priority,function(){_l(m)});return}}else if(l===3&&m.stateNode.current.memoizedState.isDehydrated){o.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}o.blockedOn=null}function ci(o){if(o.blockedOn!==null)return!1;for(var l=o.targetContainers;0<l.length;){var m=lh(o.domEventName,o.eventSystemFlags,l[0],o.nativeEvent);if(m===null){m=o.nativeEvent;var w=new m.constructor(m.type,m);J=w,m.target.dispatchEvent(w),J=null}else return l=Hl(m),l!==null&&ii(l),o.blockedOn=m,!1;l.shift()}return!0}function Ar(o,l,m){ci(o)&&m.delete(l)}function ah(){li=!1,Qs!==null&&ci(Qs)&&(Qs=null),Js!==null&&ci(Js)&&(Js=null),Xs!==null&&ci(Xs)&&(Xs=null),pe.forEach(Ar),Te.forEach(Ar)}function uo(o,l){o.blockedOn===l&&(o.blockedOn=null,li||(li=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,ah)))}function fo(o){function l(C){return uo(C,o)}if(0<la.length){uo(la[0],o);for(var m=1;m<la.length;m++){var w=la[m];w.blockedOn===o&&(w.blockedOn=null)}}for(Qs!==null&&uo(Qs,o),Js!==null&&uo(Js,o),Xs!==null&&uo(Xs,o),pe.forEach(l),Te.forEach(l),m=0;m<Ie.length;m++)w=Ie[m],w.blockedOn===o&&(w.blockedOn=null);for(;0<Ie.length&&(m=Ie[0],m.blockedOn===null);)Gn(m),m.blockedOn===null&&Ie.shift()}var Or=N.ReactCurrentBatchConfig,Mr=!0;function mo(o,l,m,w){var C=Ct,T=Or.transition;Or.transition=null;try{Ct=1,ih(o,l,m,w)}finally{Ct=C,Or.transition=T}}function fr(o,l,m,w){var C=Ct,T=Or.transition;Or.transition=null;try{Ct=4,ih(o,l,m,w)}finally{Ct=C,Or.transition=T}}function ih(o,l,m,w){if(Mr){var C=lh(o,l,m,w);if(C===null)Sh(o,l,w,Od,m),wt(o,w);else if(Bn(C,o,l,m,w))w.stopPropagation();else if(wt(o,w),l&4&&-1<Et.indexOf(o)){for(;C!==null;){var T=Hl(C);if(T!==null&&$l(T),T=lh(o,l,m,w),T===null&&Sh(o,l,w,Od,m),T===C)break;C=T}C!==null&&w.stopPropagation()}else Sh(o,l,w,null,m)}}var Od=null;function lh(o,l,m,w){if(Od=null,o=ve(w),o=ca(o),o!==null)if(l=Le(o),l===null)o=null;else if(m=l.tag,m===13){if(o=mt(l),o!==null)return o;o=null}else if(m===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;o=null}else l!==o&&(o=null);return Od=o,null}function Ay(o){switch(o){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(bn()){case $n:return 1;case ur:return 4;case Wt:case si:return 16;case io:return 536870912;default:return 16}default:return 16}}var ho=null,ch=null,Md=null;function Oy(){if(Md)return Md;var o,l=ch,m=l.length,w,C="value"in ho?ho.value:ho.textContent,T=C.length;for(o=0;o<m&&l[o]===C[o];o++);var I=m-o;for(w=1;w<=I&&l[m-w]===C[T-w];w++);return Md=C.slice(o,1<w?1-w:void 0)}function Pd(o){var l=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&l===13&&(o=13)):o=l,o===10&&(o=13),32<=o||o===13?o:0}function Ld(){return!0}function My(){return!1}function vs(o){function l(m,w,C,T,I){this._reactName=m,this._targetInst=C,this.type=w,this.nativeEvent=T,this.target=I,this.currentTarget=null;for(var V in o)o.hasOwnProperty(V)&&(m=o[V],this[V]=m?m(T):T[V]);return this.isDefaultPrevented=(T.defaultPrevented!=null?T.defaultPrevented:T.returnValue===!1)?Ld:My,this.isPropagationStopped=My,this}return U(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=Ld)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=Ld)},persist:function(){},isPersistent:Ld}),l}var di={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},dh=vs(di),Al=U({},di,{view:0,detail:0}),b$=vs(Al),uh,fh,Ol,Id=U({},Al,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:hh,button:0,buttons:0,relatedTarget:function(o){return o.relatedTarget===void 0?o.fromElement===o.srcElement?o.toElement:o.fromElement:o.relatedTarget},movementX:function(o){return"movementX"in o?o.movementX:(o!==Ol&&(Ol&&o.type==="mousemove"?(uh=o.screenX-Ol.screenX,fh=o.screenY-Ol.screenY):fh=uh=0,Ol=o),uh)},movementY:function(o){return"movementY"in o?o.movementY:fh}}),Py=vs(Id),w$=U({},Id,{dataTransfer:0}),j$=vs(w$),k$=U({},Al,{relatedTarget:0}),mh=vs(k$),N$=U({},di,{animationName:0,elapsedTime:0,pseudoElement:0}),S$=vs(N$),C$=U({},di,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),E$=vs(C$),$$=U({},di,{data:0}),Ly=vs($$),_$={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},T$={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"},R$={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function A$(o){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(o):(o=R$[o])?!!l[o]:!1}function hh(){return A$}var O$=U({},Al,{key:function(o){if(o.key){var l=_$[o.key]||o.key;if(l!=="Unidentified")return l}return o.type==="keypress"?(o=Pd(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?T$[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:hh,charCode:function(o){return o.type==="keypress"?Pd(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?Pd(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),M$=vs(O$),P$=U({},Id,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Iy=vs(P$),L$=U({},Al,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:hh}),I$=vs(L$),z$=U({},di,{propertyName:0,elapsedTime:0,pseudoElement:0}),D$=vs(z$),F$=U({},Id,{deltaX:function(o){return"deltaX"in o?o.deltaX:"wheelDeltaX"in o?-o.wheelDeltaX:0},deltaY:function(o){return"deltaY"in o?o.deltaY:"wheelDeltaY"in o?-o.wheelDeltaY:"wheelDelta"in o?-o.wheelDelta:0},deltaZ:0,deltaMode:0}),U$=vs(F$),W$=[9,13,27,32],ph=d&&"CompositionEvent"in window,Ml=null;d&&"documentMode"in document&&(Ml=document.documentMode);var H$=d&&"TextEvent"in window&&!Ml,zy=d&&(!ph||Ml&&8<Ml&&11>=Ml),Dy=" ",Fy=!1;function Uy(o,l){switch(o){case"keyup":return W$.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wy(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var ui=!1;function B$(o,l){switch(o){case"compositionend":return Wy(l);case"keypress":return l.which!==32?null:(Fy=!0,Dy);case"textInput":return o=l.data,o===Dy&&Fy?null:o;default:return null}}function G$(o,l){if(ui)return o==="compositionend"||!ph&&Uy(o,l)?(o=Oy(),Md=ch=ho=null,ui=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return zy&&l.locale!=="ko"?null:l.data;default:return null}}var q$={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 Hy(o){var l=o&&o.nodeName&&o.nodeName.toLowerCase();return l==="input"?!!q$[o.type]:l==="textarea"}function By(o,l,m,w){It(w),l=Wd(l,"onChange"),0<l.length&&(m=new dh("onChange","change",null,m,w),o.push({event:m,listeners:l}))}var Pl=null,Ll=null;function K$(o){lb(o,0)}function zd(o){var l=gi(o);if(me(l))return o}function V$(o,l){if(o==="change")return l}var Gy=!1;if(d){var gh;if(d){var xh="oninput"in document;if(!xh){var qy=document.createElement("div");qy.setAttribute("oninput","return;"),xh=typeof qy.oninput=="function"}gh=xh}else gh=!1;Gy=gh&&(!document.documentMode||9<document.documentMode)}function Ky(){Pl&&(Pl.detachEvent("onpropertychange",Vy),Ll=Pl=null)}function Vy(o){if(o.propertyName==="value"&&zd(Ll)){var l=[];By(l,Ll,o,ve(o)),En(K$,l)}}function Y$(o,l,m){o==="focusin"?(Ky(),Pl=l,Ll=m,Pl.attachEvent("onpropertychange",Vy)):o==="focusout"&&Ky()}function Q$(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return zd(Ll)}function J$(o,l){if(o==="click")return zd(l)}function X$(o,l){if(o==="input"||o==="change")return zd(l)}function Z$(o,l){return o===l&&(o!==0||1/o===1/l)||o!==o&&l!==l}var Zs=typeof Object.is=="function"?Object.is:Z$;function Il(o,l){if(Zs(o,l))return!0;if(typeof o!="object"||o===null||typeof l!="object"||l===null)return!1;var m=Object.keys(o),w=Object.keys(l);if(m.length!==w.length)return!1;for(w=0;w<m.length;w++){var C=m[w];if(!u.call(l,C)||!Zs(o[C],l[C]))return!1}return!0}function Yy(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function Qy(o,l){var m=Yy(o);o=0;for(var w;m;){if(m.nodeType===3){if(w=o+m.textContent.length,o<=l&&w>=l)return{node:m,offset:l-o};o=w}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=Yy(m)}}function Jy(o,l){return o&&l?o===l?!0:o&&o.nodeType===3?!1:l&&l.nodeType===3?Jy(o,l.parentNode):"contains"in o?o.contains(l):o.compareDocumentPosition?!!(o.compareDocumentPosition(l)&16):!1:!1}function Xy(){for(var o=window,l=je();l instanceof o.HTMLIFrameElement;){try{var m=typeof l.contentWindow.location.href=="string"}catch{m=!1}if(m)o=l.contentWindow;else break;l=je(o.document)}return l}function vh(o){var l=o&&o.nodeName&&o.nodeName.toLowerCase();return l&&(l==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||l==="textarea"||o.contentEditable==="true")}function e_(o){var l=Xy(),m=o.focusedElem,w=o.selectionRange;if(l!==m&&m&&m.ownerDocument&&Jy(m.ownerDocument.documentElement,m)){if(w!==null&&vh(m)){if(l=w.start,o=w.end,o===void 0&&(o=l),"selectionStart"in m)m.selectionStart=l,m.selectionEnd=Math.min(o,m.value.length);else if(o=(l=m.ownerDocument||document)&&l.defaultView||window,o.getSelection){o=o.getSelection();var C=m.textContent.length,T=Math.min(w.start,C);w=w.end===void 0?T:Math.min(w.end,C),!o.extend&&T>w&&(C=w,w=T,T=C),C=Qy(m,T);var I=Qy(m,w);C&&I&&(o.rangeCount!==1||o.anchorNode!==C.node||o.anchorOffset!==C.offset||o.focusNode!==I.node||o.focusOffset!==I.offset)&&(l=l.createRange(),l.setStart(C.node,C.offset),o.removeAllRanges(),T>w?(o.addRange(l),o.extend(I.node,I.offset)):(l.setEnd(I.node,I.offset),o.addRange(l)))}}for(l=[],o=m;o=o.parentNode;)o.nodeType===1&&l.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<l.length;m++)o=l[m],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var t_=d&&"documentMode"in document&&11>=document.documentMode,fi=null,yh=null,zl=null,bh=!1;function Zy(o,l,m){var w=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;bh||fi==null||fi!==je(w)||(w=fi,"selectionStart"in w&&vh(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),zl&&Il(zl,w)||(zl=w,w=Wd(yh,"onSelect"),0<w.length&&(l=new dh("onSelect","select",null,l,m),o.push({event:l,listeners:w}),l.target=fi)))}function Dd(o,l){var m={};return m[o.toLowerCase()]=l.toLowerCase(),m["Webkit"+o]="webkit"+l,m["Moz"+o]="moz"+l,m}var mi={animationend:Dd("Animation","AnimationEnd"),animationiteration:Dd("Animation","AnimationIteration"),animationstart:Dd("Animation","AnimationStart"),transitionend:Dd("Transition","TransitionEnd")},wh={},eb={};d&&(eb=document.createElement("div").style,"AnimationEvent"in window||(delete mi.animationend.animation,delete mi.animationiteration.animation,delete mi.animationstart.animation),"TransitionEvent"in window||delete mi.transitionend.transition);function Fd(o){if(wh[o])return wh[o];if(!mi[o])return o;var l=mi[o],m;for(m in l)if(l.hasOwnProperty(m)&&m in eb)return wh[o]=l[m];return o}var tb=Fd("animationend"),nb=Fd("animationiteration"),sb=Fd("animationstart"),rb=Fd("transitionend"),ob=new Map,ab="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 po(o,l){ob.set(o,l),i(l,[o])}for(var jh=0;jh<ab.length;jh++){var kh=ab[jh],n_=kh.toLowerCase(),s_=kh[0].toUpperCase()+kh.slice(1);po(n_,"on"+s_)}po(tb,"onAnimationEnd"),po(nb,"onAnimationIteration"),po(sb,"onAnimationStart"),po("dblclick","onDoubleClick"),po("focusin","onFocus"),po("focusout","onBlur"),po(rb,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Dl="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(" "),r_=new Set("cancel close invalid load scroll toggle".split(" ").concat(Dl));function ib(o,l,m){var w=o.type||"unknown-event";o.currentTarget=m,ee(w,l,void 0,o),o.currentTarget=null}function lb(o,l){l=(l&4)!==0;for(var m=0;m<o.length;m++){var w=o[m],C=w.event;w=w.listeners;e:{var T=void 0;if(l)for(var I=w.length-1;0<=I;I--){var V=w[I],X=V.instance,ce=V.currentTarget;if(V=V.listener,X!==T&&C.isPropagationStopped())break e;ib(C,V,ce),T=X}else for(I=0;I<w.length;I++){if(V=w[I],X=V.instance,ce=V.currentTarget,V=V.listener,X!==T&&C.isPropagationStopped())break e;ib(C,V,ce),T=X}}}if(Hn)throw o=_s,Hn=!1,_s=null,o}function Ht(o,l){var m=l[Rh];m===void 0&&(m=l[Rh]=new Set);var w=o+"__bubble";m.has(w)||(cb(l,o,2,!1),m.add(w))}function Nh(o,l,m){var w=0;l&&(w|=4),cb(m,o,w,l)}var Ud="_reactListening"+Math.random().toString(36).slice(2);function Fl(o){if(!o[Ud]){o[Ud]=!0,r.forEach(function(m){m!=="selectionchange"&&(r_.has(m)||Nh(m,!1,o),Nh(m,!0,o))});var l=o.nodeType===9?o:o.ownerDocument;l===null||l[Ud]||(l[Ud]=!0,Nh("selectionchange",!1,l))}}function cb(o,l,m,w){switch(Ay(l)){case 1:var C=mo;break;case 4:C=fr;break;default:C=ih}m=C.bind(null,l,m,o),C=void 0,!ps||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(C=!0),w?C!==void 0?o.addEventListener(l,m,{capture:!0,passive:C}):o.addEventListener(l,m,!0):C!==void 0?o.addEventListener(l,m,{passive:C}):o.addEventListener(l,m,!1)}function Sh(o,l,m,w,C){var T=w;if((l&1)===0&&(l&2)===0&&w!==null)e:for(;;){if(w===null)return;var I=w.tag;if(I===3||I===4){var V=w.stateNode.containerInfo;if(V===C||V.nodeType===8&&V.parentNode===C)break;if(I===4)for(I=w.return;I!==null;){var X=I.tag;if((X===3||X===4)&&(X=I.stateNode.containerInfo,X===C||X.nodeType===8&&X.parentNode===C))return;I=I.return}for(;V!==null;){if(I=ca(V),I===null)return;if(X=I.tag,X===5||X===6){w=T=I;continue e}V=V.parentNode}}w=w.return}En(function(){var ce=T,ke=ve(m),Ce=[];e:{var we=ob.get(o);if(we!==void 0){var Be=dh,Ve=o;switch(o){case"keypress":if(Pd(m)===0)break e;case"keydown":case"keyup":Be=M$;break;case"focusin":Ve="focus",Be=mh;break;case"focusout":Ve="blur",Be=mh;break;case"beforeblur":case"afterblur":Be=mh;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Be=Py;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Be=j$;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Be=I$;break;case tb:case nb:case sb:Be=S$;break;case rb:Be=D$;break;case"scroll":Be=b$;break;case"wheel":Be=U$;break;case"copy":case"cut":case"paste":Be=E$;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Be=Iy}var Qe=(l&4)!==0,rn=!Qe&&o==="scroll",ae=Qe?we!==null?we+"Capture":null:we;Qe=[];for(var ne=ce,ie;ne!==null;){ie=ne;var Ae=ie.stateNode;if(ie.tag===5&&Ae!==null&&(ie=Ae,ae!==null&&(Ae=Un(ne,ae),Ae!=null&&Qe.push(Ul(ne,Ae,ie)))),rn)break;ne=ne.return}0<Qe.length&&(we=new Be(we,Ve,null,m,ke),Ce.push({event:we,listeners:Qe}))}}if((l&7)===0){e:{if(we=o==="mouseover"||o==="pointerover",Be=o==="mouseout"||o==="pointerout",we&&m!==J&&(Ve=m.relatedTarget||m.fromElement)&&(ca(Ve)||Ve[Pr]))break e;if((Be||we)&&(we=ke.window===ke?ke:(we=ke.ownerDocument)?we.defaultView||we.parentWindow:window,Be?(Ve=m.relatedTarget||m.toElement,Be=ce,Ve=Ve?ca(Ve):null,Ve!==null&&(rn=Le(Ve),Ve!==rn||Ve.tag!==5&&Ve.tag!==6)&&(Ve=null)):(Be=null,Ve=ce),Be!==Ve)){if(Qe=Py,Ae="onMouseLeave",ae="onMouseEnter",ne="mouse",(o==="pointerout"||o==="pointerover")&&(Qe=Iy,Ae="onPointerLeave",ae="onPointerEnter",ne="pointer"),rn=Be==null?we:gi(Be),ie=Ve==null?we:gi(Ve),we=new Qe(Ae,ne+"leave",Be,m,ke),we.target=rn,we.relatedTarget=ie,Ae=null,ca(ke)===ce&&(Qe=new Qe(ae,ne+"enter",Ve,m,ke),Qe.target=ie,Qe.relatedTarget=rn,Ae=Qe),rn=Ae,Be&&Ve)t:{for(Qe=Be,ae=Ve,ne=0,ie=Qe;ie;ie=hi(ie))ne++;for(ie=0,Ae=ae;Ae;Ae=hi(Ae))ie++;for(;0<ne-ie;)Qe=hi(Qe),ne--;for(;0<ie-ne;)ae=hi(ae),ie--;for(;ne--;){if(Qe===ae||ae!==null&&Qe===ae.alternate)break t;Qe=hi(Qe),ae=hi(ae)}Qe=null}else Qe=null;Be!==null&&db(Ce,we,Be,Qe,!1),Ve!==null&&rn!==null&&db(Ce,rn,Ve,Qe,!0)}}e:{if(we=ce?gi(ce):window,Be=we.nodeName&&we.nodeName.toLowerCase(),Be==="select"||Be==="input"&&we.type==="file")var et=V$;else if(Hy(we))if(Gy)et=X$;else{et=Q$;var nt=Y$}else(Be=we.nodeName)&&Be.toLowerCase()==="input"&&(we.type==="checkbox"||we.type==="radio")&&(et=J$);if(et&&(et=et(o,ce))){By(Ce,et,m,ke);break e}nt&&nt(o,we,ce),o==="focusout"&&(nt=we._wrapperState)&&nt.controlled&&we.type==="number"&&at(we,"number",we.value)}switch(nt=ce?gi(ce):window,o){case"focusin":(Hy(nt)||nt.contentEditable==="true")&&(fi=nt,yh=ce,zl=null);break;case"focusout":zl=yh=fi=null;break;case"mousedown":bh=!0;break;case"contextmenu":case"mouseup":case"dragend":bh=!1,Zy(Ce,m,ke);break;case"selectionchange":if(t_)break;case"keydown":case"keyup":Zy(Ce,m,ke)}var st;if(ph)e:{switch(o){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else ui?Uy(o,m)&&(lt="onCompositionEnd"):o==="keydown"&&m.keyCode===229&&(lt="onCompositionStart");lt&&(zy&&m.locale!=="ko"&&(ui||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&ui&&(st=Oy()):(ho=ke,ch="value"in ho?ho.value:ho.textContent,ui=!0)),nt=Wd(ce,lt),0<nt.length&&(lt=new Ly(lt,o,null,m,ke),Ce.push({event:lt,listeners:nt}),st?lt.data=st:(st=Wy(m),st!==null&&(lt.data=st)))),(st=H$?B$(o,m):G$(o,m))&&(ce=Wd(ce,"onBeforeInput"),0<ce.length&&(ke=new Ly("onBeforeInput","beforeinput",null,m,ke),Ce.push({event:ke,listeners:ce}),ke.data=st))}lb(Ce,l)})}function Ul(o,l,m){return{instance:o,listener:l,currentTarget:m}}function Wd(o,l){for(var m=l+"Capture",w=[];o!==null;){var C=o,T=C.stateNode;C.tag===5&&T!==null&&(C=T,T=Un(o,m),T!=null&&w.unshift(Ul(o,T,C)),T=Un(o,l),T!=null&&w.push(Ul(o,T,C))),o=o.return}return w}function hi(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function db(o,l,m,w,C){for(var T=l._reactName,I=[];m!==null&&m!==w;){var V=m,X=V.alternate,ce=V.stateNode;if(X!==null&&X===w)break;V.tag===5&&ce!==null&&(V=ce,C?(X=Un(m,T),X!=null&&I.unshift(Ul(m,X,V))):C||(X=Un(m,T),X!=null&&I.push(Ul(m,X,V)))),m=m.return}I.length!==0&&o.push({event:l,listeners:I})}var o_=/\r\n?/g,a_=/\u0000|\uFFFD/g;function ub(o){return(typeof o=="string"?o:""+o).replace(o_,`
|
|
38
|
+
`).replace(a_,"")}function Hd(o,l,m){if(l=ub(l),ub(o)!==l&&m)throw Error(s(425))}function Bd(){}var Ch=null,Eh=null;function $h(o,l){return o==="textarea"||o==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var _h=typeof setTimeout=="function"?setTimeout:void 0,i_=typeof clearTimeout=="function"?clearTimeout:void 0,fb=typeof Promise=="function"?Promise:void 0,l_=typeof queueMicrotask=="function"?queueMicrotask:typeof fb<"u"?function(o){return fb.resolve(null).then(o).catch(c_)}:_h;function c_(o){setTimeout(function(){throw o})}function Th(o,l){var m=l,w=0;do{var C=m.nextSibling;if(o.removeChild(m),C&&C.nodeType===8)if(m=C.data,m==="/$"){if(w===0){o.removeChild(C),fo(l);return}w--}else m!=="$"&&m!=="$?"&&m!=="$!"||w++;m=C}while(m);fo(l)}function go(o){for(;o!=null;o=o.nextSibling){var l=o.nodeType;if(l===1||l===3)break;if(l===8){if(l=o.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return o}function mb(o){o=o.previousSibling;for(var l=0;o;){if(o.nodeType===8){var m=o.data;if(m==="$"||m==="$!"||m==="$?"){if(l===0)return o;l--}else m==="/$"&&l++}o=o.previousSibling}return null}var pi=Math.random().toString(36).slice(2),mr="__reactFiber$"+pi,Wl="__reactProps$"+pi,Pr="__reactContainer$"+pi,Rh="__reactEvents$"+pi,d_="__reactListeners$"+pi,u_="__reactHandles$"+pi;function ca(o){var l=o[mr];if(l)return l;for(var m=o.parentNode;m;){if(l=m[Pr]||m[mr]){if(m=l.alternate,l.child!==null||m!==null&&m.child!==null)for(o=mb(o);o!==null;){if(m=o[mr])return m;o=mb(o)}return l}o=m,m=o.parentNode}return null}function Hl(o){return o=o[mr]||o[Pr],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function gi(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(s(33))}function Gd(o){return o[Wl]||null}var Ah=[],xi=-1;function xo(o){return{current:o}}function Bt(o){0>xi||(o.current=Ah[xi],Ah[xi]=null,xi--)}function Dt(o,l){xi++,Ah[xi]=o.current,o.current=l}var vo={},On=xo(vo),os=xo(!1),da=vo;function vi(o,l){var m=o.type.contextTypes;if(!m)return vo;var w=o.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===l)return w.__reactInternalMemoizedMaskedChildContext;var C={},T;for(T in m)C[T]=l[T];return w&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=l,o.__reactInternalMemoizedMaskedChildContext=C),C}function as(o){return o=o.childContextTypes,o!=null}function qd(){Bt(os),Bt(On)}function hb(o,l,m){if(On.current!==vo)throw Error(s(168));Dt(On,l),Dt(os,m)}function pb(o,l,m){var w=o.stateNode;if(l=l.childContextTypes,typeof w.getChildContext!="function")return m;w=w.getChildContext();for(var C in w)if(!(C in l))throw Error(s(108,ue(o)||"Unknown",C));return U({},m,w)}function Kd(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||vo,da=On.current,Dt(On,o),Dt(os,os.current),!0}function gb(o,l,m){var w=o.stateNode;if(!w)throw Error(s(169));m?(o=pb(o,l,da),w.__reactInternalMemoizedMergedChildContext=o,Bt(os),Bt(On),Dt(On,o)):Bt(os),Dt(os,m)}var Lr=null,Vd=!1,Oh=!1;function xb(o){Lr===null?Lr=[o]:Lr.push(o)}function f_(o){Vd=!0,xb(o)}function yo(){if(!Oh&&Lr!==null){Oh=!0;var o=0,l=Ct;try{var m=Lr;for(Ct=1;o<m.length;o++){var w=m[o];do w=w(!0);while(w!==null)}Lr=null,Vd=!1}catch(C){throw Lr!==null&&(Lr=Lr.slice(o+1)),be($n,yo),C}finally{Ct=l,Oh=!1}}return null}var yi=[],bi=0,Yd=null,Qd=0,Rs=[],As=0,ua=null,Ir=1,zr="";function fa(o,l){yi[bi++]=Qd,yi[bi++]=Yd,Yd=o,Qd=l}function vb(o,l,m){Rs[As++]=Ir,Rs[As++]=zr,Rs[As++]=ua,ua=o;var w=Ir;o=zr;var C=32-ss(w)-1;w&=~(1<<C),m+=1;var T=32-ss(l)+C;if(30<T){var I=C-C%5;T=(w&(1<<I)-1).toString(32),w>>=I,C-=I,Ir=1<<32-ss(l)+C|m<<C|w,zr=T+o}else Ir=1<<T|m<<C|w,zr=o}function Mh(o){o.return!==null&&(fa(o,1),vb(o,1,0))}function Ph(o){for(;o===Yd;)Yd=yi[--bi],yi[bi]=null,Qd=yi[--bi],yi[bi]=null;for(;o===ua;)ua=Rs[--As],Rs[As]=null,zr=Rs[--As],Rs[As]=null,Ir=Rs[--As],Rs[As]=null}var ys=null,bs=null,Kt=!1,er=null;function yb(o,l){var m=Ls(5,null,null,0);m.elementType="DELETED",m.stateNode=l,m.return=o,l=o.deletions,l===null?(o.deletions=[m],o.flags|=16):l.push(m)}function bb(o,l){switch(o.tag){case 5:var m=o.type;return l=l.nodeType!==1||m.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(o.stateNode=l,ys=o,bs=go(l.firstChild),!0):!1;case 6:return l=o.pendingProps===""||l.nodeType!==3?null:l,l!==null?(o.stateNode=l,ys=o,bs=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(m=ua!==null?{id:Ir,overflow:zr}:null,o.memoizedState={dehydrated:l,treeContext:m,retryLane:1073741824},m=Ls(18,null,null,0),m.stateNode=l,m.return=o,o.child=m,ys=o,bs=null,!0):!1;default:return!1}}function Lh(o){return(o.mode&1)!==0&&(o.flags&128)===0}function Ih(o){if(Kt){var l=bs;if(l){var m=l;if(!bb(o,l)){if(Lh(o))throw Error(s(418));l=go(m.nextSibling);var w=ys;l&&bb(o,l)?yb(w,m):(o.flags=o.flags&-4097|2,Kt=!1,ys=o)}}else{if(Lh(o))throw Error(s(418));o.flags=o.flags&-4097|2,Kt=!1,ys=o}}}function wb(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;ys=o}function Jd(o){if(o!==ys)return!1;if(!Kt)return wb(o),Kt=!0,!1;var l;if((l=o.tag!==3)&&!(l=o.tag!==5)&&(l=o.type,l=l!=="head"&&l!=="body"&&!$h(o.type,o.memoizedProps)),l&&(l=bs)){if(Lh(o))throw jb(),Error(s(418));for(;l;)yb(o,l),l=go(l.nextSibling)}if(wb(o),o.tag===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(s(317));e:{for(o=o.nextSibling,l=0;o;){if(o.nodeType===8){var m=o.data;if(m==="/$"){if(l===0){bs=go(o.nextSibling);break e}l--}else m!=="$"&&m!=="$!"&&m!=="$?"||l++}o=o.nextSibling}bs=null}}else bs=ys?go(o.stateNode.nextSibling):null;return!0}function jb(){for(var o=bs;o;)o=go(o.nextSibling)}function wi(){bs=ys=null,Kt=!1}function zh(o){er===null?er=[o]:er.push(o)}var m_=N.ReactCurrentBatchConfig;function Bl(o,l,m){if(o=m.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(s(309));var w=m.stateNode}if(!w)throw Error(s(147,o));var C=w,T=""+o;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===T?l.ref:(l=function(I){var V=C.refs;I===null?delete V[T]:V[T]=I},l._stringRef=T,l)}if(typeof o!="string")throw Error(s(284));if(!m._owner)throw Error(s(290,o))}return o}function Xd(o,l){throw o=Object.prototype.toString.call(l),Error(s(31,o==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":o))}function kb(o){var l=o._init;return l(o._payload)}function Nb(o){function l(ae,ne){if(o){var ie=ae.deletions;ie===null?(ae.deletions=[ne],ae.flags|=16):ie.push(ne)}}function m(ae,ne){if(!o)return null;for(;ne!==null;)l(ae,ne),ne=ne.sibling;return null}function w(ae,ne){for(ae=new Map;ne!==null;)ne.key!==null?ae.set(ne.key,ne):ae.set(ne.index,ne),ne=ne.sibling;return ae}function C(ae,ne){return ae=Eo(ae,ne),ae.index=0,ae.sibling=null,ae}function T(ae,ne,ie){return ae.index=ie,o?(ie=ae.alternate,ie!==null?(ie=ie.index,ie<ne?(ae.flags|=2,ne):ie):(ae.flags|=2,ne)):(ae.flags|=1048576,ne)}function I(ae){return o&&ae.alternate===null&&(ae.flags|=2),ae}function V(ae,ne,ie,Ae){return ne===null||ne.tag!==6?(ne=_p(ie,ae.mode,Ae),ne.return=ae,ne):(ne=C(ne,ie),ne.return=ae,ne)}function X(ae,ne,ie,Ae){var et=ie.type;return et===O?ke(ae,ne,ie.props.children,Ae,ie.key):ne!==null&&(ne.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===H&&kb(et)===ne.type)?(Ae=C(ne,ie.props),Ae.ref=Bl(ae,ne,ie),Ae.return=ae,Ae):(Ae=ju(ie.type,ie.key,ie.props,null,ae.mode,Ae),Ae.ref=Bl(ae,ne,ie),Ae.return=ae,Ae)}function ce(ae,ne,ie,Ae){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==ie.containerInfo||ne.stateNode.implementation!==ie.implementation?(ne=Tp(ie,ae.mode,Ae),ne.return=ae,ne):(ne=C(ne,ie.children||[]),ne.return=ae,ne)}function ke(ae,ne,ie,Ae,et){return ne===null||ne.tag!==7?(ne=ba(ie,ae.mode,Ae,et),ne.return=ae,ne):(ne=C(ne,ie),ne.return=ae,ne)}function Ce(ae,ne,ie){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=_p(""+ne,ae.mode,ie),ne.return=ae,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case _:return ie=ju(ne.type,ne.key,ne.props,null,ae.mode,ie),ie.ref=Bl(ae,null,ne),ie.return=ae,ie;case $:return ne=Tp(ne,ae.mode,ie),ne.return=ae,ne;case H:var Ae=ne._init;return Ce(ae,Ae(ne._payload),ie)}if(pt(ne)||G(ne))return ne=ba(ne,ae.mode,ie,null),ne.return=ae,ne;Xd(ae,ne)}return null}function we(ae,ne,ie,Ae){var et=ne!==null?ne.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number")return et!==null?null:V(ae,ne,""+ie,Ae);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case _:return ie.key===et?X(ae,ne,ie,Ae):null;case $:return ie.key===et?ce(ae,ne,ie,Ae):null;case H:return et=ie._init,we(ae,ne,et(ie._payload),Ae)}if(pt(ie)||G(ie))return et!==null?null:ke(ae,ne,ie,Ae,null);Xd(ae,ie)}return null}function Be(ae,ne,ie,Ae,et){if(typeof Ae=="string"&&Ae!==""||typeof Ae=="number")return ae=ae.get(ie)||null,V(ne,ae,""+Ae,et);if(typeof Ae=="object"&&Ae!==null){switch(Ae.$$typeof){case _:return ae=ae.get(Ae.key===null?ie:Ae.key)||null,X(ne,ae,Ae,et);case $:return ae=ae.get(Ae.key===null?ie:Ae.key)||null,ce(ne,ae,Ae,et);case H:var nt=Ae._init;return Be(ae,ne,ie,nt(Ae._payload),et)}if(pt(Ae)||G(Ae))return ae=ae.get(ie)||null,ke(ne,ae,Ae,et,null);Xd(ne,Ae)}return null}function Ve(ae,ne,ie,Ae){for(var et=null,nt=null,st=ne,lt=ne=0,kn=null;st!==null&<<ie.length;lt++){st.index>lt?(kn=st,st=null):kn=st.sibling;var $t=we(ae,st,ie[lt],Ae);if($t===null){st===null&&(st=kn);break}o&&st&&$t.alternate===null&&l(ae,st),ne=T($t,ne,lt),nt===null?et=$t:nt.sibling=$t,nt=$t,st=kn}if(lt===ie.length)return m(ae,st),Kt&&fa(ae,lt),et;if(st===null){for(;lt<ie.length;lt++)st=Ce(ae,ie[lt],Ae),st!==null&&(ne=T(st,ne,lt),nt===null?et=st:nt.sibling=st,nt=st);return Kt&&fa(ae,lt),et}for(st=w(ae,st);lt<ie.length;lt++)kn=Be(st,ae,lt,ie[lt],Ae),kn!==null&&(o&&kn.alternate!==null&&st.delete(kn.key===null?lt:kn.key),ne=T(kn,ne,lt),nt===null?et=kn:nt.sibling=kn,nt=kn);return o&&st.forEach(function($o){return l(ae,$o)}),Kt&&fa(ae,lt),et}function Qe(ae,ne,ie,Ae){var et=G(ie);if(typeof et!="function")throw Error(s(150));if(ie=et.call(ie),ie==null)throw Error(s(151));for(var nt=et=null,st=ne,lt=ne=0,kn=null,$t=ie.next();st!==null&&!$t.done;lt++,$t=ie.next()){st.index>lt?(kn=st,st=null):kn=st.sibling;var $o=we(ae,st,$t.value,Ae);if($o===null){st===null&&(st=kn);break}o&&st&&$o.alternate===null&&l(ae,st),ne=T($o,ne,lt),nt===null?et=$o:nt.sibling=$o,nt=$o,st=kn}if($t.done)return m(ae,st),Kt&&fa(ae,lt),et;if(st===null){for(;!$t.done;lt++,$t=ie.next())$t=Ce(ae,$t.value,Ae),$t!==null&&(ne=T($t,ne,lt),nt===null?et=$t:nt.sibling=$t,nt=$t);return Kt&&fa(ae,lt),et}for(st=w(ae,st);!$t.done;lt++,$t=ie.next())$t=Be(st,ae,lt,$t.value,Ae),$t!==null&&(o&&$t.alternate!==null&&st.delete($t.key===null?lt:$t.key),ne=T($t,ne,lt),nt===null?et=$t:nt.sibling=$t,nt=$t);return o&&st.forEach(function(q_){return l(ae,q_)}),Kt&&fa(ae,lt),et}function rn(ae,ne,ie,Ae){if(typeof ie=="object"&&ie!==null&&ie.type===O&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case _:e:{for(var et=ie.key,nt=ne;nt!==null;){if(nt.key===et){if(et=ie.type,et===O){if(nt.tag===7){m(ae,nt.sibling),ne=C(nt,ie.props.children),ne.return=ae,ae=ne;break e}}else if(nt.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===H&&kb(et)===nt.type){m(ae,nt.sibling),ne=C(nt,ie.props),ne.ref=Bl(ae,nt,ie),ne.return=ae,ae=ne;break e}m(ae,nt);break}else l(ae,nt);nt=nt.sibling}ie.type===O?(ne=ba(ie.props.children,ae.mode,Ae,ie.key),ne.return=ae,ae=ne):(Ae=ju(ie.type,ie.key,ie.props,null,ae.mode,Ae),Ae.ref=Bl(ae,ne,ie),Ae.return=ae,ae=Ae)}return I(ae);case $:e:{for(nt=ie.key;ne!==null;){if(ne.key===nt)if(ne.tag===4&&ne.stateNode.containerInfo===ie.containerInfo&&ne.stateNode.implementation===ie.implementation){m(ae,ne.sibling),ne=C(ne,ie.children||[]),ne.return=ae,ae=ne;break e}else{m(ae,ne);break}else l(ae,ne);ne=ne.sibling}ne=Tp(ie,ae.mode,Ae),ne.return=ae,ae=ne}return I(ae);case H:return nt=ie._init,rn(ae,ne,nt(ie._payload),Ae)}if(pt(ie))return Ve(ae,ne,ie,Ae);if(G(ie))return Qe(ae,ne,ie,Ae);Xd(ae,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"?(ie=""+ie,ne!==null&&ne.tag===6?(m(ae,ne.sibling),ne=C(ne,ie),ne.return=ae,ae=ne):(m(ae,ne),ne=_p(ie,ae.mode,Ae),ne.return=ae,ae=ne),I(ae)):m(ae,ne)}return rn}var ji=Nb(!0),Sb=Nb(!1),Zd=xo(null),eu=null,ki=null,Dh=null;function Fh(){Dh=ki=eu=null}function Uh(o){var l=Zd.current;Bt(Zd),o._currentValue=l}function Wh(o,l,m){for(;o!==null;){var w=o.alternate;if((o.childLanes&l)!==l?(o.childLanes|=l,w!==null&&(w.childLanes|=l)):w!==null&&(w.childLanes&l)!==l&&(w.childLanes|=l),o===m)break;o=o.return}}function Ni(o,l){eu=o,Dh=ki=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&l)!==0&&(is=!0),o.firstContext=null)}function Os(o){var l=o._currentValue;if(Dh!==o)if(o={context:o,memoizedValue:l,next:null},ki===null){if(eu===null)throw Error(s(308));ki=o,eu.dependencies={lanes:0,firstContext:o}}else ki=ki.next=o;return l}var ma=null;function Hh(o){ma===null?ma=[o]:ma.push(o)}function Cb(o,l,m,w){var C=l.interleaved;return C===null?(m.next=m,Hh(l)):(m.next=C.next,C.next=m),l.interleaved=m,Dr(o,w)}function Dr(o,l){o.lanes|=l;var m=o.alternate;for(m!==null&&(m.lanes|=l),m=o,o=o.return;o!==null;)o.childLanes|=l,m=o.alternate,m!==null&&(m.childLanes|=l),m=o,o=o.return;return m.tag===3?m.stateNode:null}var bo=!1;function Bh(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Eb(o,l){o=o.updateQueue,l.updateQueue===o&&(l.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function Fr(o,l){return{eventTime:o,lane:l,tag:0,payload:null,callback:null,next:null}}function wo(o,l,m){var w=o.updateQueue;if(w===null)return null;if(w=w.shared,(St&2)!==0){var C=w.pending;return C===null?l.next=l:(l.next=C.next,C.next=l),w.pending=l,Dr(o,m)}return C=w.interleaved,C===null?(l.next=l,Hh(w)):(l.next=C.next,C.next=l),w.interleaved=l,Dr(o,m)}function tu(o,l,m){if(l=l.updateQueue,l!==null&&(l=l.shared,(m&4194240)!==0)){var w=l.lanes;w&=o.pendingLanes,m|=w,l.lanes=m,ai(o,m)}}function $b(o,l){var m=o.updateQueue,w=o.alternate;if(w!==null&&(w=w.updateQueue,m===w)){var C=null,T=null;if(m=m.firstBaseUpdate,m!==null){do{var I={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};T===null?C=T=I:T=T.next=I,m=m.next}while(m!==null);T===null?C=T=l:T=T.next=l}else C=T=l;m={baseState:w.baseState,firstBaseUpdate:C,lastBaseUpdate:T,shared:w.shared,effects:w.effects},o.updateQueue=m;return}o=m.lastBaseUpdate,o===null?m.firstBaseUpdate=l:o.next=l,m.lastBaseUpdate=l}function nu(o,l,m,w){var C=o.updateQueue;bo=!1;var T=C.firstBaseUpdate,I=C.lastBaseUpdate,V=C.shared.pending;if(V!==null){C.shared.pending=null;var X=V,ce=X.next;X.next=null,I===null?T=ce:I.next=ce,I=X;var ke=o.alternate;ke!==null&&(ke=ke.updateQueue,V=ke.lastBaseUpdate,V!==I&&(V===null?ke.firstBaseUpdate=ce:V.next=ce,ke.lastBaseUpdate=X))}if(T!==null){var Ce=C.baseState;I=0,ke=ce=X=null,V=T;do{var we=V.lane,Be=V.eventTime;if((w&we)===we){ke!==null&&(ke=ke.next={eventTime:Be,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var Ve=o,Qe=V;switch(we=l,Be=m,Qe.tag){case 1:if(Ve=Qe.payload,typeof Ve=="function"){Ce=Ve.call(Be,Ce,we);break e}Ce=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=Qe.payload,we=typeof Ve=="function"?Ve.call(Be,Ce,we):Ve,we==null)break e;Ce=U({},Ce,we);break e;case 2:bo=!0}}V.callback!==null&&V.lane!==0&&(o.flags|=64,we=C.effects,we===null?C.effects=[V]:we.push(V))}else Be={eventTime:Be,lane:we,tag:V.tag,payload:V.payload,callback:V.callback,next:null},ke===null?(ce=ke=Be,X=Ce):ke=ke.next=Be,I|=we;if(V=V.next,V===null){if(V=C.shared.pending,V===null)break;we=V,V=we.next,we.next=null,C.lastBaseUpdate=we,C.shared.pending=null}}while(!0);if(ke===null&&(X=Ce),C.baseState=X,C.firstBaseUpdate=ce,C.lastBaseUpdate=ke,l=C.shared.interleaved,l!==null){C=l;do I|=C.lane,C=C.next;while(C!==l)}else T===null&&(C.shared.lanes=0);ga|=I,o.lanes=I,o.memoizedState=Ce}}function _b(o,l,m){if(o=l.effects,l.effects=null,o!==null)for(l=0;l<o.length;l++){var w=o[l],C=w.callback;if(C!==null){if(w.callback=null,w=m,typeof C!="function")throw Error(s(191,C));C.call(w)}}}var Gl={},hr=xo(Gl),ql=xo(Gl),Kl=xo(Gl);function ha(o){if(o===Gl)throw Error(s(174));return o}function Gh(o,l){switch(Dt(Kl,l),Dt(ql,o),Dt(hr,Gl),o=l.nodeType,o){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:ct(null,"");break;default:o=o===8?l.parentNode:l,l=o.namespaceURI||null,o=o.tagName,l=ct(l,o)}Bt(hr),Dt(hr,l)}function Si(){Bt(hr),Bt(ql),Bt(Kl)}function Tb(o){ha(Kl.current);var l=ha(hr.current),m=ct(l,o.type);l!==m&&(Dt(ql,o),Dt(hr,m))}function qh(o){ql.current===o&&(Bt(hr),Bt(ql))}var Jt=xo(0);function su(o){for(var l=o;l!==null;){if(l.tag===13){var m=l.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Kh=[];function Vh(){for(var o=0;o<Kh.length;o++)Kh[o]._workInProgressVersionPrimary=null;Kh.length=0}var ru=N.ReactCurrentDispatcher,Yh=N.ReactCurrentBatchConfig,pa=0,Xt=null,xn=null,wn=null,ou=!1,Vl=!1,Yl=0,h_=0;function Mn(){throw Error(s(321))}function Qh(o,l){if(l===null)return!1;for(var m=0;m<l.length&&m<o.length;m++)if(!Zs(o[m],l[m]))return!1;return!0}function Jh(o,l,m,w,C,T){if(pa=T,Xt=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,ru.current=o===null||o.memoizedState===null?v_:y_,o=m(w,C),Vl){T=0;do{if(Vl=!1,Yl=0,25<=T)throw Error(s(301));T+=1,wn=xn=null,l.updateQueue=null,ru.current=b_,o=m(w,C)}while(Vl)}if(ru.current=lu,l=xn!==null&&xn.next!==null,pa=0,wn=xn=Xt=null,ou=!1,l)throw Error(s(300));return o}function Xh(){var o=Yl!==0;return Yl=0,o}function pr(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return wn===null?Xt.memoizedState=wn=o:wn=wn.next=o,wn}function Ms(){if(xn===null){var o=Xt.alternate;o=o!==null?o.memoizedState:null}else o=xn.next;var l=wn===null?Xt.memoizedState:wn.next;if(l!==null)wn=l,xn=o;else{if(o===null)throw Error(s(310));xn=o,o={memoizedState:xn.memoizedState,baseState:xn.baseState,baseQueue:xn.baseQueue,queue:xn.queue,next:null},wn===null?Xt.memoizedState=wn=o:wn=wn.next=o}return wn}function Ql(o,l){return typeof l=="function"?l(o):l}function Zh(o){var l=Ms(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=o;var w=xn,C=w.baseQueue,T=m.pending;if(T!==null){if(C!==null){var I=C.next;C.next=T.next,T.next=I}w.baseQueue=C=T,m.pending=null}if(C!==null){T=C.next,w=w.baseState;var V=I=null,X=null,ce=T;do{var ke=ce.lane;if((pa&ke)===ke)X!==null&&(X=X.next={lane:0,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),w=ce.hasEagerState?ce.eagerState:o(w,ce.action);else{var Ce={lane:ke,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null};X===null?(V=X=Ce,I=w):X=X.next=Ce,Xt.lanes|=ke,ga|=ke}ce=ce.next}while(ce!==null&&ce!==T);X===null?I=w:X.next=V,Zs(w,l.memoizedState)||(is=!0),l.memoizedState=w,l.baseState=I,l.baseQueue=X,m.lastRenderedState=w}if(o=m.interleaved,o!==null){C=o;do T=C.lane,Xt.lanes|=T,ga|=T,C=C.next;while(C!==o)}else C===null&&(m.lanes=0);return[l.memoizedState,m.dispatch]}function ep(o){var l=Ms(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=o;var w=m.dispatch,C=m.pending,T=l.memoizedState;if(C!==null){m.pending=null;var I=C=C.next;do T=o(T,I.action),I=I.next;while(I!==C);Zs(T,l.memoizedState)||(is=!0),l.memoizedState=T,l.baseQueue===null&&(l.baseState=T),m.lastRenderedState=T}return[T,w]}function Rb(){}function Ab(o,l){var m=Xt,w=Ms(),C=l(),T=!Zs(w.memoizedState,C);if(T&&(w.memoizedState=C,is=!0),w=w.queue,tp(Pb.bind(null,m,w,o),[o]),w.getSnapshot!==l||T||wn!==null&&wn.memoizedState.tag&1){if(m.flags|=2048,Jl(9,Mb.bind(null,m,w,C,l),void 0,null),jn===null)throw Error(s(349));(pa&30)!==0||Ob(m,l,C)}return C}function Ob(o,l,m){o.flags|=16384,o={getSnapshot:l,value:m},l=Xt.updateQueue,l===null?(l={lastEffect:null,stores:null},Xt.updateQueue=l,l.stores=[o]):(m=l.stores,m===null?l.stores=[o]:m.push(o))}function Mb(o,l,m,w){l.value=m,l.getSnapshot=w,Lb(l)&&Ib(o)}function Pb(o,l,m){return m(function(){Lb(l)&&Ib(o)})}function Lb(o){var l=o.getSnapshot;o=o.value;try{var m=l();return!Zs(o,m)}catch{return!0}}function Ib(o){var l=Dr(o,1);l!==null&&rr(l,o,1,-1)}function zb(o){var l=pr();return typeof o=="function"&&(o=o()),l.memoizedState=l.baseState=o,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ql,lastRenderedState:o},l.queue=o,o=o.dispatch=x_.bind(null,Xt,o),[l.memoizedState,o]}function Jl(o,l,m,w){return o={tag:o,create:l,destroy:m,deps:w,next:null},l=Xt.updateQueue,l===null?(l={lastEffect:null,stores:null},Xt.updateQueue=l,l.lastEffect=o.next=o):(m=l.lastEffect,m===null?l.lastEffect=o.next=o:(w=m.next,m.next=o,o.next=w,l.lastEffect=o)),o}function Db(){return Ms().memoizedState}function au(o,l,m,w){var C=pr();Xt.flags|=o,C.memoizedState=Jl(1|l,m,void 0,w===void 0?null:w)}function iu(o,l,m,w){var C=Ms();w=w===void 0?null:w;var T=void 0;if(xn!==null){var I=xn.memoizedState;if(T=I.destroy,w!==null&&Qh(w,I.deps)){C.memoizedState=Jl(l,m,T,w);return}}Xt.flags|=o,C.memoizedState=Jl(1|l,m,T,w)}function Fb(o,l){return au(8390656,8,o,l)}function tp(o,l){return iu(2048,8,o,l)}function Ub(o,l){return iu(4,2,o,l)}function Wb(o,l){return iu(4,4,o,l)}function Hb(o,l){if(typeof l=="function")return o=o(),l(o),function(){l(null)};if(l!=null)return o=o(),l.current=o,function(){l.current=null}}function Bb(o,l,m){return m=m!=null?m.concat([o]):null,iu(4,4,Hb.bind(null,l,o),m)}function np(){}function Gb(o,l){var m=Ms();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&Qh(l,w[1])?w[0]:(m.memoizedState=[o,l],o)}function qb(o,l){var m=Ms();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&Qh(l,w[1])?w[0]:(o=o(),m.memoizedState=[o,l],o)}function Kb(o,l,m){return(pa&21)===0?(o.baseState&&(o.baseState=!1,is=!0),o.memoizedState=m):(Zs(m,l)||(m=Cl(),Xt.lanes|=m,ga|=m,o.baseState=!0),l)}function p_(o,l){var m=Ct;Ct=m!==0&&4>m?m:4,o(!0);var w=Yh.transition;Yh.transition={};try{o(!1),l()}finally{Ct=m,Yh.transition=w}}function Vb(){return Ms().memoizedState}function g_(o,l,m){var w=So(o);if(m={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null},Yb(o))Qb(l,m);else if(m=Cb(o,l,m,w),m!==null){var C=Kn();rr(m,o,w,C),Jb(m,l,w)}}function x_(o,l,m){var w=So(o),C={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null};if(Yb(o))Qb(l,C);else{var T=o.alternate;if(o.lanes===0&&(T===null||T.lanes===0)&&(T=l.lastRenderedReducer,T!==null))try{var I=l.lastRenderedState,V=T(I,m);if(C.hasEagerState=!0,C.eagerState=V,Zs(V,I)){var X=l.interleaved;X===null?(C.next=C,Hh(l)):(C.next=X.next,X.next=C),l.interleaved=C;return}}catch{}finally{}m=Cb(o,l,C,w),m!==null&&(C=Kn(),rr(m,o,w,C),Jb(m,l,w))}}function Yb(o){var l=o.alternate;return o===Xt||l!==null&&l===Xt}function Qb(o,l){Vl=ou=!0;var m=o.pending;m===null?l.next=l:(l.next=m.next,m.next=l),o.pending=l}function Jb(o,l,m){if((m&4194240)!==0){var w=l.lanes;w&=o.pendingLanes,m|=w,l.lanes=m,ai(o,m)}}var lu={readContext:Os,useCallback:Mn,useContext:Mn,useEffect:Mn,useImperativeHandle:Mn,useInsertionEffect:Mn,useLayoutEffect:Mn,useMemo:Mn,useReducer:Mn,useRef:Mn,useState:Mn,useDebugValue:Mn,useDeferredValue:Mn,useTransition:Mn,useMutableSource:Mn,useSyncExternalStore:Mn,useId:Mn,unstable_isNewReconciler:!1},v_={readContext:Os,useCallback:function(o,l){return pr().memoizedState=[o,l===void 0?null:l],o},useContext:Os,useEffect:Fb,useImperativeHandle:function(o,l,m){return m=m!=null?m.concat([o]):null,au(4194308,4,Hb.bind(null,l,o),m)},useLayoutEffect:function(o,l){return au(4194308,4,o,l)},useInsertionEffect:function(o,l){return au(4,2,o,l)},useMemo:function(o,l){var m=pr();return l=l===void 0?null:l,o=o(),m.memoizedState=[o,l],o},useReducer:function(o,l,m){var w=pr();return l=m!==void 0?m(l):l,w.memoizedState=w.baseState=l,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:l},w.queue=o,o=o.dispatch=g_.bind(null,Xt,o),[w.memoizedState,o]},useRef:function(o){var l=pr();return o={current:o},l.memoizedState=o},useState:zb,useDebugValue:np,useDeferredValue:function(o){return pr().memoizedState=o},useTransition:function(){var o=zb(!1),l=o[0];return o=p_.bind(null,o[1]),pr().memoizedState=o,[l,o]},useMutableSource:function(){},useSyncExternalStore:function(o,l,m){var w=Xt,C=pr();if(Kt){if(m===void 0)throw Error(s(407));m=m()}else{if(m=l(),jn===null)throw Error(s(349));(pa&30)!==0||Ob(w,l,m)}C.memoizedState=m;var T={value:m,getSnapshot:l};return C.queue=T,Fb(Pb.bind(null,w,T,o),[o]),w.flags|=2048,Jl(9,Mb.bind(null,w,T,m,l),void 0,null),m},useId:function(){var o=pr(),l=jn.identifierPrefix;if(Kt){var m=zr,w=Ir;m=(w&~(1<<32-ss(w)-1)).toString(32)+m,l=":"+l+"R"+m,m=Yl++,0<m&&(l+="H"+m.toString(32)),l+=":"}else m=h_++,l=":"+l+"r"+m.toString(32)+":";return o.memoizedState=l},unstable_isNewReconciler:!1},y_={readContext:Os,useCallback:Gb,useContext:Os,useEffect:tp,useImperativeHandle:Bb,useInsertionEffect:Ub,useLayoutEffect:Wb,useMemo:qb,useReducer:Zh,useRef:Db,useState:function(){return Zh(Ql)},useDebugValue:np,useDeferredValue:function(o){var l=Ms();return Kb(l,xn.memoizedState,o)},useTransition:function(){var o=Zh(Ql)[0],l=Ms().memoizedState;return[o,l]},useMutableSource:Rb,useSyncExternalStore:Ab,useId:Vb,unstable_isNewReconciler:!1},b_={readContext:Os,useCallback:Gb,useContext:Os,useEffect:tp,useImperativeHandle:Bb,useInsertionEffect:Ub,useLayoutEffect:Wb,useMemo:qb,useReducer:ep,useRef:Db,useState:function(){return ep(Ql)},useDebugValue:np,useDeferredValue:function(o){var l=Ms();return xn===null?l.memoizedState=o:Kb(l,xn.memoizedState,o)},useTransition:function(){var o=ep(Ql)[0],l=Ms().memoizedState;return[o,l]},useMutableSource:Rb,useSyncExternalStore:Ab,useId:Vb,unstable_isNewReconciler:!1};function tr(o,l){if(o&&o.defaultProps){l=U({},l),o=o.defaultProps;for(var m in o)l[m]===void 0&&(l[m]=o[m]);return l}return l}function sp(o,l,m,w){l=o.memoizedState,m=m(w,l),m=m==null?l:U({},l,m),o.memoizedState=m,o.lanes===0&&(o.updateQueue.baseState=m)}var cu={isMounted:function(o){return(o=o._reactInternals)?Le(o)===o:!1},enqueueSetState:function(o,l,m){o=o._reactInternals;var w=Kn(),C=So(o),T=Fr(w,C);T.payload=l,m!=null&&(T.callback=m),l=wo(o,T,C),l!==null&&(rr(l,o,C,w),tu(l,o,C))},enqueueReplaceState:function(o,l,m){o=o._reactInternals;var w=Kn(),C=So(o),T=Fr(w,C);T.tag=1,T.payload=l,m!=null&&(T.callback=m),l=wo(o,T,C),l!==null&&(rr(l,o,C,w),tu(l,o,C))},enqueueForceUpdate:function(o,l){o=o._reactInternals;var m=Kn(),w=So(o),C=Fr(m,w);C.tag=2,l!=null&&(C.callback=l),l=wo(o,C,w),l!==null&&(rr(l,o,w,m),tu(l,o,w))}};function Xb(o,l,m,w,C,T,I){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(w,T,I):l.prototype&&l.prototype.isPureReactComponent?!Il(m,w)||!Il(C,T):!0}function Zb(o,l,m){var w=!1,C=vo,T=l.contextType;return typeof T=="object"&&T!==null?T=Os(T):(C=as(l)?da:On.current,w=l.contextTypes,T=(w=w!=null)?vi(o,C):vo),l=new l(m,T),o.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=cu,o.stateNode=l,l._reactInternals=o,w&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=C,o.__reactInternalMemoizedMaskedChildContext=T),l}function ew(o,l,m,w){o=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(m,w),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(m,w),l.state!==o&&cu.enqueueReplaceState(l,l.state,null)}function rp(o,l,m,w){var C=o.stateNode;C.props=m,C.state=o.memoizedState,C.refs={},Bh(o);var T=l.contextType;typeof T=="object"&&T!==null?C.context=Os(T):(T=as(l)?da:On.current,C.context=vi(o,T)),C.state=o.memoizedState,T=l.getDerivedStateFromProps,typeof T=="function"&&(sp(o,l,T,m),C.state=o.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(l=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),l!==C.state&&cu.enqueueReplaceState(C,C.state,null),nu(o,m,C,w),C.state=o.memoizedState),typeof C.componentDidMount=="function"&&(o.flags|=4194308)}function Ci(o,l){try{var m="",w=l;do m+=de(w),w=w.return;while(w);var C=m}catch(T){C=`
|
|
39
|
+
Error generating stack: `+T.message+`
|
|
40
|
+
`+T.stack}return{value:o,source:l,stack:C,digest:null}}function op(o,l,m){return{value:o,source:null,stack:m??null,digest:l??null}}function ap(o,l){try{console.error(l.value)}catch(m){setTimeout(function(){throw m})}}var w_=typeof WeakMap=="function"?WeakMap:Map;function tw(o,l,m){m=Fr(-1,m),m.tag=3,m.payload={element:null};var w=l.value;return m.callback=function(){gu||(gu=!0,wp=w),ap(o,l)},m}function nw(o,l,m){m=Fr(-1,m),m.tag=3;var w=o.type.getDerivedStateFromError;if(typeof w=="function"){var C=l.value;m.payload=function(){return w(C)},m.callback=function(){ap(o,l)}}var T=o.stateNode;return T!==null&&typeof T.componentDidCatch=="function"&&(m.callback=function(){ap(o,l),typeof w!="function"&&(ko===null?ko=new Set([this]):ko.add(this));var I=l.stack;this.componentDidCatch(l.value,{componentStack:I!==null?I:""})}),m}function sw(o,l,m){var w=o.pingCache;if(w===null){w=o.pingCache=new w_;var C=new Set;w.set(l,C)}else C=w.get(l),C===void 0&&(C=new Set,w.set(l,C));C.has(m)||(C.add(m),o=P_.bind(null,o,l,m),l.then(o,o))}function rw(o){do{var l;if((l=o.tag===13)&&(l=o.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return o;o=o.return}while(o!==null);return null}function ow(o,l,m,w,C){return(o.mode&1)===0?(o===l?o.flags|=65536:(o.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(l=Fr(-1,1),l.tag=2,wo(m,l,1))),m.lanes|=1),o):(o.flags|=65536,o.lanes=C,o)}var j_=N.ReactCurrentOwner,is=!1;function qn(o,l,m,w){l.child=o===null?Sb(l,null,m,w):ji(l,o.child,m,w)}function aw(o,l,m,w,C){m=m.render;var T=l.ref;return Ni(l,C),w=Jh(o,l,m,w,T,C),m=Xh(),o!==null&&!is?(l.updateQueue=o.updateQueue,l.flags&=-2053,o.lanes&=~C,Ur(o,l,C)):(Kt&&m&&Mh(l),l.flags|=1,qn(o,l,w,C),l.child)}function iw(o,l,m,w,C){if(o===null){var T=m.type;return typeof T=="function"&&!$p(T)&&T.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(l.tag=15,l.type=T,lw(o,l,T,w,C)):(o=ju(m.type,null,w,l,l.mode,C),o.ref=l.ref,o.return=l,l.child=o)}if(T=o.child,(o.lanes&C)===0){var I=T.memoizedProps;if(m=m.compare,m=m!==null?m:Il,m(I,w)&&o.ref===l.ref)return Ur(o,l,C)}return l.flags|=1,o=Eo(T,w),o.ref=l.ref,o.return=l,l.child=o}function lw(o,l,m,w,C){if(o!==null){var T=o.memoizedProps;if(Il(T,w)&&o.ref===l.ref)if(is=!1,l.pendingProps=w=T,(o.lanes&C)!==0)(o.flags&131072)!==0&&(is=!0);else return l.lanes=o.lanes,Ur(o,l,C)}return ip(o,l,m,w,C)}function cw(o,l,m){var w=l.pendingProps,C=w.children,T=o!==null?o.memoizedState:null;if(w.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Dt($i,ws),ws|=m;else{if((m&1073741824)===0)return o=T!==null?T.baseLanes|m:m,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:o,cachePool:null,transitions:null},l.updateQueue=null,Dt($i,ws),ws|=o,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=T!==null?T.baseLanes:m,Dt($i,ws),ws|=w}else T!==null?(w=T.baseLanes|m,l.memoizedState=null):w=m,Dt($i,ws),ws|=w;return qn(o,l,C,m),l.child}function dw(o,l){var m=l.ref;(o===null&&m!==null||o!==null&&o.ref!==m)&&(l.flags|=512,l.flags|=2097152)}function ip(o,l,m,w,C){var T=as(m)?da:On.current;return T=vi(l,T),Ni(l,C),m=Jh(o,l,m,w,T,C),w=Xh(),o!==null&&!is?(l.updateQueue=o.updateQueue,l.flags&=-2053,o.lanes&=~C,Ur(o,l,C)):(Kt&&w&&Mh(l),l.flags|=1,qn(o,l,m,C),l.child)}function uw(o,l,m,w,C){if(as(m)){var T=!0;Kd(l)}else T=!1;if(Ni(l,C),l.stateNode===null)uu(o,l),Zb(l,m,w),rp(l,m,w,C),w=!0;else if(o===null){var I=l.stateNode,V=l.memoizedProps;I.props=V;var X=I.context,ce=m.contextType;typeof ce=="object"&&ce!==null?ce=Os(ce):(ce=as(m)?da:On.current,ce=vi(l,ce));var ke=m.getDerivedStateFromProps,Ce=typeof ke=="function"||typeof I.getSnapshotBeforeUpdate=="function";Ce||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==w||X!==ce)&&ew(l,I,w,ce),bo=!1;var we=l.memoizedState;I.state=we,nu(l,w,I,C),X=l.memoizedState,V!==w||we!==X||os.current||bo?(typeof ke=="function"&&(sp(l,m,ke,w),X=l.memoizedState),(V=bo||Xb(l,m,V,w,we,X,ce))?(Ce||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(l.flags|=4194308)):(typeof I.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=w,l.memoizedState=X),I.props=w,I.state=X,I.context=ce,w=V):(typeof I.componentDidMount=="function"&&(l.flags|=4194308),w=!1)}else{I=l.stateNode,Eb(o,l),V=l.memoizedProps,ce=l.type===l.elementType?V:tr(l.type,V),I.props=ce,Ce=l.pendingProps,we=I.context,X=m.contextType,typeof X=="object"&&X!==null?X=Os(X):(X=as(m)?da:On.current,X=vi(l,X));var Be=m.getDerivedStateFromProps;(ke=typeof Be=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==Ce||we!==X)&&ew(l,I,w,X),bo=!1,we=l.memoizedState,I.state=we,nu(l,w,I,C);var Ve=l.memoizedState;V!==Ce||we!==Ve||os.current||bo?(typeof Be=="function"&&(sp(l,m,Be,w),Ve=l.memoizedState),(ce=bo||Xb(l,m,ce,w,we,Ve,X)||!1)?(ke||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(w,Ve,X),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(w,Ve,X)),typeof I.componentDidUpdate=="function"&&(l.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof I.componentDidUpdate!="function"||V===o.memoizedProps&&we===o.memoizedState||(l.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===o.memoizedProps&&we===o.memoizedState||(l.flags|=1024),l.memoizedProps=w,l.memoizedState=Ve),I.props=w,I.state=Ve,I.context=X,w=ce):(typeof I.componentDidUpdate!="function"||V===o.memoizedProps&&we===o.memoizedState||(l.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===o.memoizedProps&&we===o.memoizedState||(l.flags|=1024),w=!1)}return lp(o,l,m,w,T,C)}function lp(o,l,m,w,C,T){dw(o,l);var I=(l.flags&128)!==0;if(!w&&!I)return C&&gb(l,m,!1),Ur(o,l,T);w=l.stateNode,j_.current=l;var V=I&&typeof m.getDerivedStateFromError!="function"?null:w.render();return l.flags|=1,o!==null&&I?(l.child=ji(l,o.child,null,T),l.child=ji(l,null,V,T)):qn(o,l,V,T),l.memoizedState=w.state,C&&gb(l,m,!0),l.child}function fw(o){var l=o.stateNode;l.pendingContext?hb(o,l.pendingContext,l.pendingContext!==l.context):l.context&&hb(o,l.context,!1),Gh(o,l.containerInfo)}function mw(o,l,m,w,C){return wi(),zh(C),l.flags|=256,qn(o,l,m,w),l.child}var cp={dehydrated:null,treeContext:null,retryLane:0};function dp(o){return{baseLanes:o,cachePool:null,transitions:null}}function hw(o,l,m){var w=l.pendingProps,C=Jt.current,T=!1,I=(l.flags&128)!==0,V;if((V=I)||(V=o!==null&&o.memoizedState===null?!1:(C&2)!==0),V?(T=!0,l.flags&=-129):(o===null||o.memoizedState!==null)&&(C|=1),Dt(Jt,C&1),o===null)return Ih(l),o=l.memoizedState,o!==null&&(o=o.dehydrated,o!==null)?((l.mode&1)===0?l.lanes=1:o.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(I=w.children,o=w.fallback,T?(w=l.mode,T=l.child,I={mode:"hidden",children:I},(w&1)===0&&T!==null?(T.childLanes=0,T.pendingProps=I):T=ku(I,w,0,null),o=ba(o,w,m,null),T.return=l,o.return=l,T.sibling=o,l.child=T,l.child.memoizedState=dp(m),l.memoizedState=cp,o):up(l,I));if(C=o.memoizedState,C!==null&&(V=C.dehydrated,V!==null))return k_(o,l,I,w,V,C,m);if(T){T=w.fallback,I=l.mode,C=o.child,V=C.sibling;var X={mode:"hidden",children:w.children};return(I&1)===0&&l.child!==C?(w=l.child,w.childLanes=0,w.pendingProps=X,l.deletions=null):(w=Eo(C,X),w.subtreeFlags=C.subtreeFlags&14680064),V!==null?T=Eo(V,T):(T=ba(T,I,m,null),T.flags|=2),T.return=l,w.return=l,w.sibling=T,l.child=w,w=T,T=l.child,I=o.child.memoizedState,I=I===null?dp(m):{baseLanes:I.baseLanes|m,cachePool:null,transitions:I.transitions},T.memoizedState=I,T.childLanes=o.childLanes&~m,l.memoizedState=cp,w}return T=o.child,o=T.sibling,w=Eo(T,{mode:"visible",children:w.children}),(l.mode&1)===0&&(w.lanes=m),w.return=l,w.sibling=null,o!==null&&(m=l.deletions,m===null?(l.deletions=[o],l.flags|=16):m.push(o)),l.child=w,l.memoizedState=null,w}function up(o,l){return l=ku({mode:"visible",children:l},o.mode,0,null),l.return=o,o.child=l}function du(o,l,m,w){return w!==null&&zh(w),ji(l,o.child,null,m),o=up(l,l.pendingProps.children),o.flags|=2,l.memoizedState=null,o}function k_(o,l,m,w,C,T,I){if(m)return l.flags&256?(l.flags&=-257,w=op(Error(s(422))),du(o,l,I,w)):l.memoizedState!==null?(l.child=o.child,l.flags|=128,null):(T=w.fallback,C=l.mode,w=ku({mode:"visible",children:w.children},C,0,null),T=ba(T,C,I,null),T.flags|=2,w.return=l,T.return=l,w.sibling=T,l.child=w,(l.mode&1)!==0&&ji(l,o.child,null,I),l.child.memoizedState=dp(I),l.memoizedState=cp,T);if((l.mode&1)===0)return du(o,l,I,null);if(C.data==="$!"){if(w=C.nextSibling&&C.nextSibling.dataset,w)var V=w.dgst;return w=V,T=Error(s(419)),w=op(T,w,void 0),du(o,l,I,w)}if(V=(I&o.childLanes)!==0,is||V){if(w=jn,w!==null){switch(I&-I){case 4:C=2;break;case 16:C=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:C=32;break;case 536870912:C=268435456;break;default:C=0}C=(C&(w.suspendedLanes|I))!==0?0:C,C!==0&&C!==T.retryLane&&(T.retryLane=C,Dr(o,C),rr(w,o,C,-1))}return Ep(),w=op(Error(s(421))),du(o,l,I,w)}return C.data==="$?"?(l.flags|=128,l.child=o.child,l=L_.bind(null,o),C._reactRetry=l,null):(o=T.treeContext,bs=go(C.nextSibling),ys=l,Kt=!0,er=null,o!==null&&(Rs[As++]=Ir,Rs[As++]=zr,Rs[As++]=ua,Ir=o.id,zr=o.overflow,ua=l),l=up(l,w.children),l.flags|=4096,l)}function pw(o,l,m){o.lanes|=l;var w=o.alternate;w!==null&&(w.lanes|=l),Wh(o.return,l,m)}function fp(o,l,m,w,C){var T=o.memoizedState;T===null?o.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:w,tail:m,tailMode:C}:(T.isBackwards=l,T.rendering=null,T.renderingStartTime=0,T.last=w,T.tail=m,T.tailMode=C)}function gw(o,l,m){var w=l.pendingProps,C=w.revealOrder,T=w.tail;if(qn(o,l,w.children,m),w=Jt.current,(w&2)!==0)w=w&1|2,l.flags|=128;else{if(o!==null&&(o.flags&128)!==0)e:for(o=l.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&pw(o,m,l);else if(o.tag===19)pw(o,m,l);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===l)break e;for(;o.sibling===null;){if(o.return===null||o.return===l)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}w&=1}if(Dt(Jt,w),(l.mode&1)===0)l.memoizedState=null;else switch(C){case"forwards":for(m=l.child,C=null;m!==null;)o=m.alternate,o!==null&&su(o)===null&&(C=m),m=m.sibling;m=C,m===null?(C=l.child,l.child=null):(C=m.sibling,m.sibling=null),fp(l,!1,C,m,T);break;case"backwards":for(m=null,C=l.child,l.child=null;C!==null;){if(o=C.alternate,o!==null&&su(o)===null){l.child=C;break}o=C.sibling,C.sibling=m,m=C,C=o}fp(l,!0,m,null,T);break;case"together":fp(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function uu(o,l){(l.mode&1)===0&&o!==null&&(o.alternate=null,l.alternate=null,l.flags|=2)}function Ur(o,l,m){if(o!==null&&(l.dependencies=o.dependencies),ga|=l.lanes,(m&l.childLanes)===0)return null;if(o!==null&&l.child!==o.child)throw Error(s(153));if(l.child!==null){for(o=l.child,m=Eo(o,o.pendingProps),l.child=m,m.return=l;o.sibling!==null;)o=o.sibling,m=m.sibling=Eo(o,o.pendingProps),m.return=l;m.sibling=null}return l.child}function N_(o,l,m){switch(l.tag){case 3:fw(l),wi();break;case 5:Tb(l);break;case 1:as(l.type)&&Kd(l);break;case 4:Gh(l,l.stateNode.containerInfo);break;case 10:var w=l.type._context,C=l.memoizedProps.value;Dt(Zd,w._currentValue),w._currentValue=C;break;case 13:if(w=l.memoizedState,w!==null)return w.dehydrated!==null?(Dt(Jt,Jt.current&1),l.flags|=128,null):(m&l.child.childLanes)!==0?hw(o,l,m):(Dt(Jt,Jt.current&1),o=Ur(o,l,m),o!==null?o.sibling:null);Dt(Jt,Jt.current&1);break;case 19:if(w=(m&l.childLanes)!==0,(o.flags&128)!==0){if(w)return gw(o,l,m);l.flags|=128}if(C=l.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),Dt(Jt,Jt.current),w)break;return null;case 22:case 23:return l.lanes=0,cw(o,l,m)}return Ur(o,l,m)}var xw,mp,vw,yw;xw=function(o,l){for(var m=l.child;m!==null;){if(m.tag===5||m.tag===6)o.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===l)break;for(;m.sibling===null;){if(m.return===null||m.return===l)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},mp=function(){},vw=function(o,l,m,w){var C=o.memoizedProps;if(C!==w){o=l.stateNode,ha(hr.current);var T=null;switch(m){case"input":C=Me(o,C),w=Me(o,w),T=[];break;case"select":C=U({},C,{value:void 0}),w=U({},w,{value:void 0}),T=[];break;case"textarea":C=Je(o,C),w=Je(o,w),T=[];break;default:typeof C.onClick!="function"&&typeof w.onClick=="function"&&(o.onclick=Bd)}Xe(m,w);var I;m=null;for(ce in C)if(!w.hasOwnProperty(ce)&&C.hasOwnProperty(ce)&&C[ce]!=null)if(ce==="style"){var V=C[ce];for(I in V)V.hasOwnProperty(I)&&(m||(m={}),m[I]="")}else ce!=="dangerouslySetInnerHTML"&&ce!=="children"&&ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&ce!=="autoFocus"&&(a.hasOwnProperty(ce)?T||(T=[]):(T=T||[]).push(ce,null));for(ce in w){var X=w[ce];if(V=C!=null?C[ce]:void 0,w.hasOwnProperty(ce)&&X!==V&&(X!=null||V!=null))if(ce==="style")if(V){for(I in V)!V.hasOwnProperty(I)||X&&X.hasOwnProperty(I)||(m||(m={}),m[I]="");for(I in X)X.hasOwnProperty(I)&&V[I]!==X[I]&&(m||(m={}),m[I]=X[I])}else m||(T||(T=[]),T.push(ce,m)),m=X;else ce==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,V=V?V.__html:void 0,X!=null&&V!==X&&(T=T||[]).push(ce,X)):ce==="children"?typeof X!="string"&&typeof X!="number"||(T=T||[]).push(ce,""+X):ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&(a.hasOwnProperty(ce)?(X!=null&&ce==="onScroll"&&Ht("scroll",o),T||V===X||(T=[])):(T=T||[]).push(ce,X))}m&&(T=T||[]).push("style",m);var ce=T;(l.updateQueue=ce)&&(l.flags|=4)}},yw=function(o,l,m,w){m!==w&&(l.flags|=4)};function Xl(o,l){if(!Kt)switch(o.tailMode){case"hidden":l=o.tail;for(var m=null;l!==null;)l.alternate!==null&&(m=l),l=l.sibling;m===null?o.tail=null:m.sibling=null;break;case"collapsed":m=o.tail;for(var w=null;m!==null;)m.alternate!==null&&(w=m),m=m.sibling;w===null?l||o.tail===null?o.tail=null:o.tail.sibling=null:w.sibling=null}}function Pn(o){var l=o.alternate!==null&&o.alternate.child===o.child,m=0,w=0;if(l)for(var C=o.child;C!==null;)m|=C.lanes|C.childLanes,w|=C.subtreeFlags&14680064,w|=C.flags&14680064,C.return=o,C=C.sibling;else for(C=o.child;C!==null;)m|=C.lanes|C.childLanes,w|=C.subtreeFlags,w|=C.flags,C.return=o,C=C.sibling;return o.subtreeFlags|=w,o.childLanes=m,l}function S_(o,l,m){var w=l.pendingProps;switch(Ph(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pn(l),null;case 1:return as(l.type)&&qd(),Pn(l),null;case 3:return w=l.stateNode,Si(),Bt(os),Bt(On),Vh(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(o===null||o.child===null)&&(Jd(l)?l.flags|=4:o===null||o.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,er!==null&&(Np(er),er=null))),mp(o,l),Pn(l),null;case 5:qh(l);var C=ha(Kl.current);if(m=l.type,o!==null&&l.stateNode!=null)vw(o,l,m,w,C),o.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!w){if(l.stateNode===null)throw Error(s(166));return Pn(l),null}if(o=ha(hr.current),Jd(l)){w=l.stateNode,m=l.type;var T=l.memoizedProps;switch(w[mr]=l,w[Wl]=T,o=(l.mode&1)!==0,m){case"dialog":Ht("cancel",w),Ht("close",w);break;case"iframe":case"object":case"embed":Ht("load",w);break;case"video":case"audio":for(C=0;C<Dl.length;C++)Ht(Dl[C],w);break;case"source":Ht("error",w);break;case"img":case"image":case"link":Ht("error",w),Ht("load",w);break;case"details":Ht("toggle",w);break;case"input":_e(w,T),Ht("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!T.multiple},Ht("invalid",w);break;case"textarea":he(w,T),Ht("invalid",w)}Xe(m,T),C=null;for(var I in T)if(T.hasOwnProperty(I)){var V=T[I];I==="children"?typeof V=="string"?w.textContent!==V&&(T.suppressHydrationWarning!==!0&&Hd(w.textContent,V,o),C=["children",V]):typeof V=="number"&&w.textContent!==""+V&&(T.suppressHydrationWarning!==!0&&Hd(w.textContent,V,o),C=["children",""+V]):a.hasOwnProperty(I)&&V!=null&&I==="onScroll"&&Ht("scroll",w)}switch(m){case"input":fe(w),Ze(w,T,!0);break;case"textarea":fe(w),ut(w);break;case"select":case"option":break;default:typeof T.onClick=="function"&&(w.onclick=Bd)}w=C,l.updateQueue=w,w!==null&&(l.flags|=4)}else{I=C.nodeType===9?C:C.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=Pe(m)),o==="http://www.w3.org/1999/xhtml"?m==="script"?(o=I.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof w.is=="string"?o=I.createElement(m,{is:w.is}):(o=I.createElement(m),m==="select"&&(I=o,w.multiple?I.multiple=!0:w.size&&(I.size=w.size))):o=I.createElementNS(o,m),o[mr]=l,o[Wl]=w,xw(o,l,!1,!1),l.stateNode=o;e:{switch(I=rt(m,w),m){case"dialog":Ht("cancel",o),Ht("close",o),C=w;break;case"iframe":case"object":case"embed":Ht("load",o),C=w;break;case"video":case"audio":for(C=0;C<Dl.length;C++)Ht(Dl[C],o);C=w;break;case"source":Ht("error",o),C=w;break;case"img":case"image":case"link":Ht("error",o),Ht("load",o),C=w;break;case"details":Ht("toggle",o),C=w;break;case"input":_e(o,w),C=Me(o,w),Ht("invalid",o);break;case"option":C=w;break;case"select":o._wrapperState={wasMultiple:!!w.multiple},C=U({},w,{value:void 0}),Ht("invalid",o);break;case"textarea":he(o,w),C=Je(o,w),Ht("invalid",o);break;default:C=w}Xe(m,C),V=C;for(T in V)if(V.hasOwnProperty(T)){var X=V[T];T==="style"?le(o,X):T==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,X!=null&&tt(o,X)):T==="children"?typeof X=="string"?(m!=="textarea"||X!=="")&&ft(o,X):typeof X=="number"&&ft(o,""+X):T!=="suppressContentEditableWarning"&&T!=="suppressHydrationWarning"&&T!=="autoFocus"&&(a.hasOwnProperty(T)?X!=null&&T==="onScroll"&&Ht("scroll",o):X!=null&&S(o,T,X,I))}switch(m){case"input":fe(o),Ze(o,w,!1);break;case"textarea":fe(o),ut(o);break;case"option":w.value!=null&&o.setAttribute("value",""+xe(w.value));break;case"select":o.multiple=!!w.multiple,T=w.value,T!=null?Ee(o,!!w.multiple,T,!1):w.defaultValue!=null&&Ee(o,!!w.multiple,w.defaultValue,!0);break;default:typeof C.onClick=="function"&&(o.onclick=Bd)}switch(m){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}}w&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return Pn(l),null;case 6:if(o&&l.stateNode!=null)yw(o,l,o.memoizedProps,w);else{if(typeof w!="string"&&l.stateNode===null)throw Error(s(166));if(m=ha(Kl.current),ha(hr.current),Jd(l)){if(w=l.stateNode,m=l.memoizedProps,w[mr]=l,(T=w.nodeValue!==m)&&(o=ys,o!==null))switch(o.tag){case 3:Hd(w.nodeValue,m,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&Hd(w.nodeValue,m,(o.mode&1)!==0)}T&&(l.flags|=4)}else w=(m.nodeType===9?m:m.ownerDocument).createTextNode(w),w[mr]=l,l.stateNode=w}return Pn(l),null;case 13:if(Bt(Jt),w=l.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(Kt&&bs!==null&&(l.mode&1)!==0&&(l.flags&128)===0)jb(),wi(),l.flags|=98560,T=!1;else if(T=Jd(l),w!==null&&w.dehydrated!==null){if(o===null){if(!T)throw Error(s(318));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(s(317));T[mr]=l}else wi(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Pn(l),T=!1}else er!==null&&(Np(er),er=null),T=!0;if(!T)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=m,l):(w=w!==null,w!==(o!==null&&o.memoizedState!==null)&&w&&(l.child.flags|=8192,(l.mode&1)!==0&&(o===null||(Jt.current&1)!==0?vn===0&&(vn=3):Ep())),l.updateQueue!==null&&(l.flags|=4),Pn(l),null);case 4:return Si(),mp(o,l),o===null&&Fl(l.stateNode.containerInfo),Pn(l),null;case 10:return Uh(l.type._context),Pn(l),null;case 17:return as(l.type)&&qd(),Pn(l),null;case 19:if(Bt(Jt),T=l.memoizedState,T===null)return Pn(l),null;if(w=(l.flags&128)!==0,I=T.rendering,I===null)if(w)Xl(T,!1);else{if(vn!==0||o!==null&&(o.flags&128)!==0)for(o=l.child;o!==null;){if(I=su(o),I!==null){for(l.flags|=128,Xl(T,!1),w=I.updateQueue,w!==null&&(l.updateQueue=w,l.flags|=4),l.subtreeFlags=0,w=m,m=l.child;m!==null;)T=m,o=w,T.flags&=14680066,I=T.alternate,I===null?(T.childLanes=0,T.lanes=o,T.child=null,T.subtreeFlags=0,T.memoizedProps=null,T.memoizedState=null,T.updateQueue=null,T.dependencies=null,T.stateNode=null):(T.childLanes=I.childLanes,T.lanes=I.lanes,T.child=I.child,T.subtreeFlags=0,T.deletions=null,T.memoizedProps=I.memoizedProps,T.memoizedState=I.memoizedState,T.updateQueue=I.updateQueue,T.type=I.type,o=I.dependencies,T.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),m=m.sibling;return Dt(Jt,Jt.current&1|2),l.child}o=o.sibling}T.tail!==null&&it()>_i&&(l.flags|=128,w=!0,Xl(T,!1),l.lanes=4194304)}else{if(!w)if(o=su(I),o!==null){if(l.flags|=128,w=!0,m=o.updateQueue,m!==null&&(l.updateQueue=m,l.flags|=4),Xl(T,!0),T.tail===null&&T.tailMode==="hidden"&&!I.alternate&&!Kt)return Pn(l),null}else 2*it()-T.renderingStartTime>_i&&m!==1073741824&&(l.flags|=128,w=!0,Xl(T,!1),l.lanes=4194304);T.isBackwards?(I.sibling=l.child,l.child=I):(m=T.last,m!==null?m.sibling=I:l.child=I,T.last=I)}return T.tail!==null?(l=T.tail,T.rendering=l,T.tail=l.sibling,T.renderingStartTime=it(),l.sibling=null,m=Jt.current,Dt(Jt,w?m&1|2:m&1),l):(Pn(l),null);case 22:case 23:return Cp(),w=l.memoizedState!==null,o!==null&&o.memoizedState!==null!==w&&(l.flags|=8192),w&&(l.mode&1)!==0?(ws&1073741824)!==0&&(Pn(l),l.subtreeFlags&6&&(l.flags|=8192)):Pn(l),null;case 24:return null;case 25:return null}throw Error(s(156,l.tag))}function C_(o,l){switch(Ph(l),l.tag){case 1:return as(l.type)&&qd(),o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 3:return Si(),Bt(os),Bt(On),Vh(),o=l.flags,(o&65536)!==0&&(o&128)===0?(l.flags=o&-65537|128,l):null;case 5:return qh(l),null;case 13:if(Bt(Jt),o=l.memoizedState,o!==null&&o.dehydrated!==null){if(l.alternate===null)throw Error(s(340));wi()}return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 19:return Bt(Jt),null;case 4:return Si(),null;case 10:return Uh(l.type._context),null;case 22:case 23:return Cp(),null;case 24:return null;default:return null}}var fu=!1,Ln=!1,E_=typeof WeakSet=="function"?WeakSet:Set,Ke=null;function Ei(o,l){var m=o.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(w){nn(o,l,w)}else m.current=null}function hp(o,l,m){try{m()}catch(w){nn(o,l,w)}}var bw=!1;function $_(o,l){if(Ch=Mr,o=Xy(),vh(o)){if("selectionStart"in o)var m={start:o.selectionStart,end:o.selectionEnd};else e:{m=(m=o.ownerDocument)&&m.defaultView||window;var w=m.getSelection&&m.getSelection();if(w&&w.rangeCount!==0){m=w.anchorNode;var C=w.anchorOffset,T=w.focusNode;w=w.focusOffset;try{m.nodeType,T.nodeType}catch{m=null;break e}var I=0,V=-1,X=-1,ce=0,ke=0,Ce=o,we=null;t:for(;;){for(var Be;Ce!==m||C!==0&&Ce.nodeType!==3||(V=I+C),Ce!==T||w!==0&&Ce.nodeType!==3||(X=I+w),Ce.nodeType===3&&(I+=Ce.nodeValue.length),(Be=Ce.firstChild)!==null;)we=Ce,Ce=Be;for(;;){if(Ce===o)break t;if(we===m&&++ce===C&&(V=I),we===T&&++ke===w&&(X=I),(Be=Ce.nextSibling)!==null)break;Ce=we,we=Ce.parentNode}Ce=Be}m=V===-1||X===-1?null:{start:V,end:X}}else m=null}m=m||{start:0,end:0}}else m=null;for(Eh={focusedElem:o,selectionRange:m},Mr=!1,Ke=l;Ke!==null;)if(l=Ke,o=l.child,(l.subtreeFlags&1028)!==0&&o!==null)o.return=l,Ke=o;else for(;Ke!==null;){l=Ke;try{var Ve=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Ve!==null){var Qe=Ve.memoizedProps,rn=Ve.memoizedState,ae=l.stateNode,ne=ae.getSnapshotBeforeUpdate(l.elementType===l.type?Qe:tr(l.type,Qe),rn);ae.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var ie=l.stateNode.containerInfo;ie.nodeType===1?ie.textContent="":ie.nodeType===9&&ie.documentElement&&ie.removeChild(ie.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(Ae){nn(l,l.return,Ae)}if(o=l.sibling,o!==null){o.return=l.return,Ke=o;break}Ke=l.return}return Ve=bw,bw=!1,Ve}function Zl(o,l,m){var w=l.updateQueue;if(w=w!==null?w.lastEffect:null,w!==null){var C=w=w.next;do{if((C.tag&o)===o){var T=C.destroy;C.destroy=void 0,T!==void 0&&hp(l,m,T)}C=C.next}while(C!==w)}}function mu(o,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var m=l=l.next;do{if((m.tag&o)===o){var w=m.create;m.destroy=w()}m=m.next}while(m!==l)}}function pp(o){var l=o.ref;if(l!==null){var m=o.stateNode;switch(o.tag){case 5:o=m;break;default:o=m}typeof l=="function"?l(o):l.current=o}}function ww(o){var l=o.alternate;l!==null&&(o.alternate=null,ww(l)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(l=o.stateNode,l!==null&&(delete l[mr],delete l[Wl],delete l[Rh],delete l[d_],delete l[u_])),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}function jw(o){return o.tag===5||o.tag===3||o.tag===4}function kw(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||jw(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function gp(o,l,m){var w=o.tag;if(w===5||w===6)o=o.stateNode,l?m.nodeType===8?m.parentNode.insertBefore(o,l):m.insertBefore(o,l):(m.nodeType===8?(l=m.parentNode,l.insertBefore(o,m)):(l=m,l.appendChild(o)),m=m._reactRootContainer,m!=null||l.onclick!==null||(l.onclick=Bd));else if(w!==4&&(o=o.child,o!==null))for(gp(o,l,m),o=o.sibling;o!==null;)gp(o,l,m),o=o.sibling}function xp(o,l,m){var w=o.tag;if(w===5||w===6)o=o.stateNode,l?m.insertBefore(o,l):m.appendChild(o);else if(w!==4&&(o=o.child,o!==null))for(xp(o,l,m),o=o.sibling;o!==null;)xp(o,l,m),o=o.sibling}var _n=null,nr=!1;function jo(o,l,m){for(m=m.child;m!==null;)Nw(o,l,m),m=m.sibling}function Nw(o,l,m){if(xs&&typeof xs.onCommitFiberUnmount=="function")try{xs.onCommitFiberUnmount(ra,m)}catch{}switch(m.tag){case 5:Ln||Ei(m,l);case 6:var w=_n,C=nr;_n=null,jo(o,l,m),_n=w,nr=C,_n!==null&&(nr?(o=_n,m=m.stateNode,o.nodeType===8?o.parentNode.removeChild(m):o.removeChild(m)):_n.removeChild(m.stateNode));break;case 18:_n!==null&&(nr?(o=_n,m=m.stateNode,o.nodeType===8?Th(o.parentNode,m):o.nodeType===1&&Th(o,m),fo(o)):Th(_n,m.stateNode));break;case 4:w=_n,C=nr,_n=m.stateNode.containerInfo,nr=!0,jo(o,l,m),_n=w,nr=C;break;case 0:case 11:case 14:case 15:if(!Ln&&(w=m.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){C=w=w.next;do{var T=C,I=T.destroy;T=T.tag,I!==void 0&&((T&2)!==0||(T&4)!==0)&&hp(m,l,I),C=C.next}while(C!==w)}jo(o,l,m);break;case 1:if(!Ln&&(Ei(m,l),w=m.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=m.memoizedProps,w.state=m.memoizedState,w.componentWillUnmount()}catch(V){nn(m,l,V)}jo(o,l,m);break;case 21:jo(o,l,m);break;case 22:m.mode&1?(Ln=(w=Ln)||m.memoizedState!==null,jo(o,l,m),Ln=w):jo(o,l,m);break;default:jo(o,l,m)}}function Sw(o){var l=o.updateQueue;if(l!==null){o.updateQueue=null;var m=o.stateNode;m===null&&(m=o.stateNode=new E_),l.forEach(function(w){var C=I_.bind(null,o,w);m.has(w)||(m.add(w),w.then(C,C))})}}function sr(o,l){var m=l.deletions;if(m!==null)for(var w=0;w<m.length;w++){var C=m[w];try{var T=o,I=l,V=I;e:for(;V!==null;){switch(V.tag){case 5:_n=V.stateNode,nr=!1;break e;case 3:_n=V.stateNode.containerInfo,nr=!0;break e;case 4:_n=V.stateNode.containerInfo,nr=!0;break e}V=V.return}if(_n===null)throw Error(s(160));Nw(T,I,C),_n=null,nr=!1;var X=C.alternate;X!==null&&(X.return=null),C.return=null}catch(ce){nn(C,l,ce)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)Cw(l,o),l=l.sibling}function Cw(o,l){var m=o.alternate,w=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(sr(l,o),gr(o),w&4){try{Zl(3,o,o.return),mu(3,o)}catch(Qe){nn(o,o.return,Qe)}try{Zl(5,o,o.return)}catch(Qe){nn(o,o.return,Qe)}}break;case 1:sr(l,o),gr(o),w&512&&m!==null&&Ei(m,m.return);break;case 5:if(sr(l,o),gr(o),w&512&&m!==null&&Ei(m,m.return),o.flags&32){var C=o.stateNode;try{ft(C,"")}catch(Qe){nn(o,o.return,Qe)}}if(w&4&&(C=o.stateNode,C!=null)){var T=o.memoizedProps,I=m!==null?m.memoizedProps:T,V=o.type,X=o.updateQueue;if(o.updateQueue=null,X!==null)try{V==="input"&&T.type==="radio"&&T.name!=null&&re(C,T),rt(V,I);var ce=rt(V,T);for(I=0;I<X.length;I+=2){var ke=X[I],Ce=X[I+1];ke==="style"?le(C,Ce):ke==="dangerouslySetInnerHTML"?tt(C,Ce):ke==="children"?ft(C,Ce):S(C,ke,Ce,ce)}switch(V){case"input":Re(C,T);break;case"textarea":Fe(C,T);break;case"select":var we=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!T.multiple;var Be=T.value;Be!=null?Ee(C,!!T.multiple,Be,!1):we!==!!T.multiple&&(T.defaultValue!=null?Ee(C,!!T.multiple,T.defaultValue,!0):Ee(C,!!T.multiple,T.multiple?[]:"",!1))}C[Wl]=T}catch(Qe){nn(o,o.return,Qe)}}break;case 6:if(sr(l,o),gr(o),w&4){if(o.stateNode===null)throw Error(s(162));C=o.stateNode,T=o.memoizedProps;try{C.nodeValue=T}catch(Qe){nn(o,o.return,Qe)}}break;case 3:if(sr(l,o),gr(o),w&4&&m!==null&&m.memoizedState.isDehydrated)try{fo(l.containerInfo)}catch(Qe){nn(o,o.return,Qe)}break;case 4:sr(l,o),gr(o);break;case 13:sr(l,o),gr(o),C=o.child,C.flags&8192&&(T=C.memoizedState!==null,C.stateNode.isHidden=T,!T||C.alternate!==null&&C.alternate.memoizedState!==null||(bp=it())),w&4&&Sw(o);break;case 22:if(ke=m!==null&&m.memoizedState!==null,o.mode&1?(Ln=(ce=Ln)||ke,sr(l,o),Ln=ce):sr(l,o),gr(o),w&8192){if(ce=o.memoizedState!==null,(o.stateNode.isHidden=ce)&&!ke&&(o.mode&1)!==0)for(Ke=o,ke=o.child;ke!==null;){for(Ce=Ke=ke;Ke!==null;){switch(we=Ke,Be=we.child,we.tag){case 0:case 11:case 14:case 15:Zl(4,we,we.return);break;case 1:Ei(we,we.return);var Ve=we.stateNode;if(typeof Ve.componentWillUnmount=="function"){w=we,m=we.return;try{l=w,Ve.props=l.memoizedProps,Ve.state=l.memoizedState,Ve.componentWillUnmount()}catch(Qe){nn(w,m,Qe)}}break;case 5:Ei(we,we.return);break;case 22:if(we.memoizedState!==null){_w(Ce);continue}}Be!==null?(Be.return=we,Ke=Be):_w(Ce)}ke=ke.sibling}e:for(ke=null,Ce=o;;){if(Ce.tag===5){if(ke===null){ke=Ce;try{C=Ce.stateNode,ce?(T=C.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none"):(V=Ce.stateNode,X=Ce.memoizedProps.style,I=X!=null&&X.hasOwnProperty("display")?X.display:null,V.style.display=ye("display",I))}catch(Qe){nn(o,o.return,Qe)}}}else if(Ce.tag===6){if(ke===null)try{Ce.stateNode.nodeValue=ce?"":Ce.memoizedProps}catch(Qe){nn(o,o.return,Qe)}}else if((Ce.tag!==22&&Ce.tag!==23||Ce.memoizedState===null||Ce===o)&&Ce.child!==null){Ce.child.return=Ce,Ce=Ce.child;continue}if(Ce===o)break e;for(;Ce.sibling===null;){if(Ce.return===null||Ce.return===o)break e;ke===Ce&&(ke=null),Ce=Ce.return}ke===Ce&&(ke=null),Ce.sibling.return=Ce.return,Ce=Ce.sibling}}break;case 19:sr(l,o),gr(o),w&4&&Sw(o);break;case 21:break;default:sr(l,o),gr(o)}}function gr(o){var l=o.flags;if(l&2){try{e:{for(var m=o.return;m!==null;){if(jw(m)){var w=m;break e}m=m.return}throw Error(s(160))}switch(w.tag){case 5:var C=w.stateNode;w.flags&32&&(ft(C,""),w.flags&=-33);var T=kw(o);xp(o,T,C);break;case 3:case 4:var I=w.stateNode.containerInfo,V=kw(o);gp(o,V,I);break;default:throw Error(s(161))}}catch(X){nn(o,o.return,X)}o.flags&=-3}l&4096&&(o.flags&=-4097)}function __(o,l,m){Ke=o,Ew(o)}function Ew(o,l,m){for(var w=(o.mode&1)!==0;Ke!==null;){var C=Ke,T=C.child;if(C.tag===22&&w){var I=C.memoizedState!==null||fu;if(!I){var V=C.alternate,X=V!==null&&V.memoizedState!==null||Ln;V=fu;var ce=Ln;if(fu=I,(Ln=X)&&!ce)for(Ke=C;Ke!==null;)I=Ke,X=I.child,I.tag===22&&I.memoizedState!==null?Tw(C):X!==null?(X.return=I,Ke=X):Tw(C);for(;T!==null;)Ke=T,Ew(T),T=T.sibling;Ke=C,fu=V,Ln=ce}$w(o)}else(C.subtreeFlags&8772)!==0&&T!==null?(T.return=C,Ke=T):$w(o)}}function $w(o){for(;Ke!==null;){var l=Ke;if((l.flags&8772)!==0){var m=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Ln||mu(5,l);break;case 1:var w=l.stateNode;if(l.flags&4&&!Ln)if(m===null)w.componentDidMount();else{var C=l.elementType===l.type?m.memoizedProps:tr(l.type,m.memoizedProps);w.componentDidUpdate(C,m.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var T=l.updateQueue;T!==null&&_b(l,T,w);break;case 3:var I=l.updateQueue;if(I!==null){if(m=null,l.child!==null)switch(l.child.tag){case 5:m=l.child.stateNode;break;case 1:m=l.child.stateNode}_b(l,I,m)}break;case 5:var V=l.stateNode;if(m===null&&l.flags&4){m=V;var X=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":X.autoFocus&&m.focus();break;case"img":X.src&&(m.src=X.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var ce=l.alternate;if(ce!==null){var ke=ce.memoizedState;if(ke!==null){var Ce=ke.dehydrated;Ce!==null&&fo(Ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}Ln||l.flags&512&&pp(l)}catch(we){nn(l,l.return,we)}}if(l===o){Ke=null;break}if(m=l.sibling,m!==null){m.return=l.return,Ke=m;break}Ke=l.return}}function _w(o){for(;Ke!==null;){var l=Ke;if(l===o){Ke=null;break}var m=l.sibling;if(m!==null){m.return=l.return,Ke=m;break}Ke=l.return}}function Tw(o){for(;Ke!==null;){var l=Ke;try{switch(l.tag){case 0:case 11:case 15:var m=l.return;try{mu(4,l)}catch(X){nn(l,m,X)}break;case 1:var w=l.stateNode;if(typeof w.componentDidMount=="function"){var C=l.return;try{w.componentDidMount()}catch(X){nn(l,C,X)}}var T=l.return;try{pp(l)}catch(X){nn(l,T,X)}break;case 5:var I=l.return;try{pp(l)}catch(X){nn(l,I,X)}}}catch(X){nn(l,l.return,X)}if(l===o){Ke=null;break}var V=l.sibling;if(V!==null){V.return=l.return,Ke=V;break}Ke=l.return}}var T_=Math.ceil,hu=N.ReactCurrentDispatcher,vp=N.ReactCurrentOwner,Ps=N.ReactCurrentBatchConfig,St=0,jn=null,mn=null,Tn=0,ws=0,$i=xo(0),vn=0,ec=null,ga=0,pu=0,yp=0,tc=null,ls=null,bp=0,_i=1/0,Wr=null,gu=!1,wp=null,ko=null,xu=!1,No=null,vu=0,nc=0,jp=null,yu=-1,bu=0;function Kn(){return(St&6)!==0?it():yu!==-1?yu:yu=it()}function So(o){return(o.mode&1)===0?1:(St&2)!==0&&Tn!==0?Tn&-Tn:m_.transition!==null?(bu===0&&(bu=Cl()),bu):(o=Ct,o!==0||(o=window.event,o=o===void 0?16:Ay(o.type)),o)}function rr(o,l,m,w){if(50<nc)throw nc=0,jp=null,Error(s(185));co(o,m,w),((St&2)===0||o!==jn)&&(o===jn&&((St&2)===0&&(pu|=m),vn===4&&Co(o,Tn)),cs(o,w),m===1&&St===0&&(l.mode&1)===0&&(_i=it()+500,Vd&&yo()))}function cs(o,l){var m=o.callbackNode;Rd(o,l);var w=ia(o,o===jn?Tn:0);if(w===0)m!==null&&Ge(m),o.callbackNode=null,o.callbackPriority=0;else if(l=w&-w,o.callbackPriority!==l){if(m!=null&&Ge(m),l===1)o.tag===0?f_(Aw.bind(null,o)):xb(Aw.bind(null,o)),l_(function(){(St&6)===0&&yo()}),m=null;else{switch(El(w)){case 1:m=$n;break;case 4:m=ur;break;case 16:m=Wt;break;case 536870912:m=io;break;default:m=Wt}m=Fw(m,Rw.bind(null,o))}o.callbackPriority=l,o.callbackNode=m}}function Rw(o,l){if(yu=-1,bu=0,(St&6)!==0)throw Error(s(327));var m=o.callbackNode;if(Ti()&&o.callbackNode!==m)return null;var w=ia(o,o===jn?Tn:0);if(w===0)return null;if((w&30)!==0||(w&o.expiredLanes)!==0||l)l=wu(o,w);else{l=w;var C=St;St|=2;var T=Mw();(jn!==o||Tn!==l)&&(Wr=null,_i=it()+500,va(o,l));do try{O_();break}catch(V){Ow(o,V)}while(!0);Fh(),hu.current=T,St=C,mn!==null?l=0:(jn=null,Tn=0,l=vn)}if(l!==0){if(l===2&&(C=ri(o),C!==0&&(w=C,l=kp(o,C))),l===1)throw m=ec,va(o,0),Co(o,w),cs(o,it()),m;if(l===6)Co(o,w);else{if(C=o.current.alternate,(w&30)===0&&!R_(C)&&(l=wu(o,w),l===2&&(T=ri(o),T!==0&&(w=T,l=kp(o,T))),l===1))throw m=ec,va(o,0),Co(o,w),cs(o,it()),m;switch(o.finishedWork=C,o.finishedLanes=w,l){case 0:case 1:throw Error(s(345));case 2:ya(o,ls,Wr);break;case 3:if(Co(o,w),(w&130023424)===w&&(l=bp+500-it(),10<l)){if(ia(o,0)!==0)break;if(C=o.suspendedLanes,(C&w)!==w){Kn(),o.pingedLanes|=o.suspendedLanes&C;break}o.timeoutHandle=_h(ya.bind(null,o,ls,Wr),l);break}ya(o,ls,Wr);break;case 4:if(Co(o,w),(w&4194240)===w)break;for(l=o.eventTimes,C=-1;0<w;){var I=31-ss(w);T=1<<I,I=l[I],I>C&&(C=I),w&=~T}if(w=C,w=it()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*T_(w/1960))-w,10<w){o.timeoutHandle=_h(ya.bind(null,o,ls,Wr),w);break}ya(o,ls,Wr);break;case 5:ya(o,ls,Wr);break;default:throw Error(s(329))}}}return cs(o,it()),o.callbackNode===m?Rw.bind(null,o):null}function kp(o,l){var m=tc;return o.current.memoizedState.isDehydrated&&(va(o,l).flags|=256),o=wu(o,l),o!==2&&(l=ls,ls=m,l!==null&&Np(l)),o}function Np(o){ls===null?ls=o:ls.push.apply(ls,o)}function R_(o){for(var l=o;;){if(l.flags&16384){var m=l.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var w=0;w<m.length;w++){var C=m[w],T=C.getSnapshot;C=C.value;try{if(!Zs(T(),C))return!1}catch{return!1}}}if(m=l.child,l.subtreeFlags&16384&&m!==null)m.return=l,l=m;else{if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Co(o,l){for(l&=~yp,l&=~pu,o.suspendedLanes|=l,o.pingedLanes&=~l,o=o.expirationTimes;0<l;){var m=31-ss(l),w=1<<m;o[m]=-1,l&=~w}}function Aw(o){if((St&6)!==0)throw Error(s(327));Ti();var l=ia(o,0);if((l&1)===0)return cs(o,it()),null;var m=wu(o,l);if(o.tag!==0&&m===2){var w=ri(o);w!==0&&(l=w,m=kp(o,w))}if(m===1)throw m=ec,va(o,0),Co(o,l),cs(o,it()),m;if(m===6)throw Error(s(345));return o.finishedWork=o.current.alternate,o.finishedLanes=l,ya(o,ls,Wr),cs(o,it()),null}function Sp(o,l){var m=St;St|=1;try{return o(l)}finally{St=m,St===0&&(_i=it()+500,Vd&&yo())}}function xa(o){No!==null&&No.tag===0&&(St&6)===0&&Ti();var l=St;St|=1;var m=Ps.transition,w=Ct;try{if(Ps.transition=null,Ct=1,o)return o()}finally{Ct=w,Ps.transition=m,St=l,(St&6)===0&&yo()}}function Cp(){ws=$i.current,Bt($i)}function va(o,l){o.finishedWork=null,o.finishedLanes=0;var m=o.timeoutHandle;if(m!==-1&&(o.timeoutHandle=-1,i_(m)),mn!==null)for(m=mn.return;m!==null;){var w=m;switch(Ph(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&qd();break;case 3:Si(),Bt(os),Bt(On),Vh();break;case 5:qh(w);break;case 4:Si();break;case 13:Bt(Jt);break;case 19:Bt(Jt);break;case 10:Uh(w.type._context);break;case 22:case 23:Cp()}m=m.return}if(jn=o,mn=o=Eo(o.current,null),Tn=ws=l,vn=0,ec=null,yp=pu=ga=0,ls=tc=null,ma!==null){for(l=0;l<ma.length;l++)if(m=ma[l],w=m.interleaved,w!==null){m.interleaved=null;var C=w.next,T=m.pending;if(T!==null){var I=T.next;T.next=C,w.next=I}m.pending=w}ma=null}return o}function Ow(o,l){do{var m=mn;try{if(Fh(),ru.current=lu,ou){for(var w=Xt.memoizedState;w!==null;){var C=w.queue;C!==null&&(C.pending=null),w=w.next}ou=!1}if(pa=0,wn=xn=Xt=null,Vl=!1,Yl=0,vp.current=null,m===null||m.return===null){vn=1,ec=l,mn=null;break}e:{var T=o,I=m.return,V=m,X=l;if(l=Tn,V.flags|=32768,X!==null&&typeof X=="object"&&typeof X.then=="function"){var ce=X,ke=V,Ce=ke.tag;if((ke.mode&1)===0&&(Ce===0||Ce===11||Ce===15)){var we=ke.alternate;we?(ke.updateQueue=we.updateQueue,ke.memoizedState=we.memoizedState,ke.lanes=we.lanes):(ke.updateQueue=null,ke.memoizedState=null)}var Be=rw(I);if(Be!==null){Be.flags&=-257,ow(Be,I,V,T,l),Be.mode&1&&sw(T,ce,l),l=Be,X=ce;var Ve=l.updateQueue;if(Ve===null){var Qe=new Set;Qe.add(X),l.updateQueue=Qe}else Ve.add(X);break e}else{if((l&1)===0){sw(T,ce,l),Ep();break e}X=Error(s(426))}}else if(Kt&&V.mode&1){var rn=rw(I);if(rn!==null){(rn.flags&65536)===0&&(rn.flags|=256),ow(rn,I,V,T,l),zh(Ci(X,V));break e}}T=X=Ci(X,V),vn!==4&&(vn=2),tc===null?tc=[T]:tc.push(T),T=I;do{switch(T.tag){case 3:T.flags|=65536,l&=-l,T.lanes|=l;var ae=tw(T,X,l);$b(T,ae);break e;case 1:V=X;var ne=T.type,ie=T.stateNode;if((T.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||ie!==null&&typeof ie.componentDidCatch=="function"&&(ko===null||!ko.has(ie)))){T.flags|=65536,l&=-l,T.lanes|=l;var Ae=nw(T,V,l);$b(T,Ae);break e}}T=T.return}while(T!==null)}Lw(m)}catch(et){l=et,mn===m&&m!==null&&(mn=m=m.return);continue}break}while(!0)}function Mw(){var o=hu.current;return hu.current=lu,o===null?lu:o}function Ep(){(vn===0||vn===3||vn===2)&&(vn=4),jn===null||(ga&268435455)===0&&(pu&268435455)===0||Co(jn,Tn)}function wu(o,l){var m=St;St|=2;var w=Mw();(jn!==o||Tn!==l)&&(Wr=null,va(o,l));do try{A_();break}catch(C){Ow(o,C)}while(!0);if(Fh(),St=m,hu.current=w,mn!==null)throw Error(s(261));return jn=null,Tn=0,vn}function A_(){for(;mn!==null;)Pw(mn)}function O_(){for(;mn!==null&&!kt();)Pw(mn)}function Pw(o){var l=Dw(o.alternate,o,ws);o.memoizedProps=o.pendingProps,l===null?Lw(o):mn=l,vp.current=null}function Lw(o){var l=o;do{var m=l.alternate;if(o=l.return,(l.flags&32768)===0){if(m=S_(m,l,ws),m!==null){mn=m;return}}else{if(m=C_(m,l),m!==null){m.flags&=32767,mn=m;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{vn=6,mn=null;return}}if(l=l.sibling,l!==null){mn=l;return}mn=l=o}while(l!==null);vn===0&&(vn=5)}function ya(o,l,m){var w=Ct,C=Ps.transition;try{Ps.transition=null,Ct=1,M_(o,l,m,w)}finally{Ps.transition=C,Ct=w}return null}function M_(o,l,m,w){do Ti();while(No!==null);if((St&6)!==0)throw Error(s(327));m=o.finishedWork;var C=o.finishedLanes;if(m===null)return null;if(o.finishedWork=null,o.finishedLanes=0,m===o.current)throw Error(s(177));o.callbackNode=null,o.callbackPriority=0;var T=m.lanes|m.childLanes;if(Ad(o,T),o===jn&&(mn=jn=null,Tn=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||xu||(xu=!0,Fw(Wt,function(){return Ti(),null})),T=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||T){T=Ps.transition,Ps.transition=null;var I=Ct;Ct=1;var V=St;St|=4,vp.current=null,$_(o,m),Cw(m,o),e_(Eh),Mr=!!Ch,Eh=Ch=null,o.current=m,__(m),Pt(),St=V,Ct=I,Ps.transition=T}else o.current=m;if(xu&&(xu=!1,No=o,vu=C),T=o.pendingLanes,T===0&&(ko=null),Cd(m.stateNode),cs(o,it()),l!==null)for(w=o.onRecoverableError,m=0;m<l.length;m++)C=l[m],w(C.value,{componentStack:C.stack,digest:C.digest});if(gu)throw gu=!1,o=wp,wp=null,o;return(vu&1)!==0&&o.tag!==0&&Ti(),T=o.pendingLanes,(T&1)!==0?o===jp?nc++:(nc=0,jp=o):nc=0,yo(),null}function Ti(){if(No!==null){var o=El(vu),l=Ps.transition,m=Ct;try{if(Ps.transition=null,Ct=16>o?16:o,No===null)var w=!1;else{if(o=No,No=null,vu=0,(St&6)!==0)throw Error(s(331));var C=St;for(St|=4,Ke=o.current;Ke!==null;){var T=Ke,I=T.child;if((Ke.flags&16)!==0){var V=T.deletions;if(V!==null){for(var X=0;X<V.length;X++){var ce=V[X];for(Ke=ce;Ke!==null;){var ke=Ke;switch(ke.tag){case 0:case 11:case 15:Zl(8,ke,T)}var Ce=ke.child;if(Ce!==null)Ce.return=ke,Ke=Ce;else for(;Ke!==null;){ke=Ke;var we=ke.sibling,Be=ke.return;if(ww(ke),ke===ce){Ke=null;break}if(we!==null){we.return=Be,Ke=we;break}Ke=Be}}}var Ve=T.alternate;if(Ve!==null){var Qe=Ve.child;if(Qe!==null){Ve.child=null;do{var rn=Qe.sibling;Qe.sibling=null,Qe=rn}while(Qe!==null)}}Ke=T}}if((T.subtreeFlags&2064)!==0&&I!==null)I.return=T,Ke=I;else e:for(;Ke!==null;){if(T=Ke,(T.flags&2048)!==0)switch(T.tag){case 0:case 11:case 15:Zl(9,T,T.return)}var ae=T.sibling;if(ae!==null){ae.return=T.return,Ke=ae;break e}Ke=T.return}}var ne=o.current;for(Ke=ne;Ke!==null;){I=Ke;var ie=I.child;if((I.subtreeFlags&2064)!==0&&ie!==null)ie.return=I,Ke=ie;else e:for(I=ne;Ke!==null;){if(V=Ke,(V.flags&2048)!==0)try{switch(V.tag){case 0:case 11:case 15:mu(9,V)}}catch(et){nn(V,V.return,et)}if(V===I){Ke=null;break e}var Ae=V.sibling;if(Ae!==null){Ae.return=V.return,Ke=Ae;break e}Ke=V.return}}if(St=C,yo(),xs&&typeof xs.onPostCommitFiberRoot=="function")try{xs.onPostCommitFiberRoot(ra,o)}catch{}w=!0}return w}finally{Ct=m,Ps.transition=l}}return!1}function Iw(o,l,m){l=Ci(m,l),l=tw(o,l,1),o=wo(o,l,1),l=Kn(),o!==null&&(co(o,1,l),cs(o,l))}function nn(o,l,m){if(o.tag===3)Iw(o,o,m);else for(;l!==null;){if(l.tag===3){Iw(l,o,m);break}else if(l.tag===1){var w=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(ko===null||!ko.has(w))){o=Ci(m,o),o=nw(l,o,1),l=wo(l,o,1),o=Kn(),l!==null&&(co(l,1,o),cs(l,o));break}}l=l.return}}function P_(o,l,m){var w=o.pingCache;w!==null&&w.delete(l),l=Kn(),o.pingedLanes|=o.suspendedLanes&m,jn===o&&(Tn&m)===m&&(vn===4||vn===3&&(Tn&130023424)===Tn&&500>it()-bp?va(o,0):yp|=m),cs(o,l)}function zw(o,l){l===0&&((o.mode&1)===0?l=1:(l=aa,aa<<=1,(aa&130023424)===0&&(aa=4194304)));var m=Kn();o=Dr(o,l),o!==null&&(co(o,l,m),cs(o,m))}function L_(o){var l=o.memoizedState,m=0;l!==null&&(m=l.retryLane),zw(o,m)}function I_(o,l){var m=0;switch(o.tag){case 13:var w=o.stateNode,C=o.memoizedState;C!==null&&(m=C.retryLane);break;case 19:w=o.stateNode;break;default:throw Error(s(314))}w!==null&&w.delete(l),zw(o,m)}var Dw;Dw=function(o,l,m){if(o!==null)if(o.memoizedProps!==l.pendingProps||os.current)is=!0;else{if((o.lanes&m)===0&&(l.flags&128)===0)return is=!1,N_(o,l,m);is=(o.flags&131072)!==0}else is=!1,Kt&&(l.flags&1048576)!==0&&vb(l,Qd,l.index);switch(l.lanes=0,l.tag){case 2:var w=l.type;uu(o,l),o=l.pendingProps;var C=vi(l,On.current);Ni(l,m),C=Jh(null,l,w,o,C,m);var T=Xh();return l.flags|=1,typeof C=="object"&&C!==null&&typeof C.render=="function"&&C.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,as(w)?(T=!0,Kd(l)):T=!1,l.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,Bh(l),C.updater=cu,l.stateNode=C,C._reactInternals=l,rp(l,w,o,m),l=lp(null,l,w,!0,T,m)):(l.tag=0,Kt&&T&&Mh(l),qn(null,l,C,m),l=l.child),l;case 16:w=l.elementType;e:{switch(uu(o,l),o=l.pendingProps,C=w._init,w=C(w._payload),l.type=w,C=l.tag=D_(w),o=tr(w,o),C){case 0:l=ip(null,l,w,o,m);break e;case 1:l=uw(null,l,w,o,m);break e;case 11:l=aw(null,l,w,o,m);break e;case 14:l=iw(null,l,w,tr(w.type,o),m);break e}throw Error(s(306,w,""))}return l;case 0:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:tr(w,C),ip(o,l,w,C,m);case 1:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:tr(w,C),uw(o,l,w,C,m);case 3:e:{if(fw(l),o===null)throw Error(s(387));w=l.pendingProps,T=l.memoizedState,C=T.element,Eb(o,l),nu(l,w,null,m);var I=l.memoizedState;if(w=I.element,T.isDehydrated)if(T={element:w,isDehydrated:!1,cache:I.cache,pendingSuspenseBoundaries:I.pendingSuspenseBoundaries,transitions:I.transitions},l.updateQueue.baseState=T,l.memoizedState=T,l.flags&256){C=Ci(Error(s(423)),l),l=mw(o,l,w,m,C);break e}else if(w!==C){C=Ci(Error(s(424)),l),l=mw(o,l,w,m,C);break e}else for(bs=go(l.stateNode.containerInfo.firstChild),ys=l,Kt=!0,er=null,m=Sb(l,null,w,m),l.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(wi(),w===C){l=Ur(o,l,m);break e}qn(o,l,w,m)}l=l.child}return l;case 5:return Tb(l),o===null&&Ih(l),w=l.type,C=l.pendingProps,T=o!==null?o.memoizedProps:null,I=C.children,$h(w,C)?I=null:T!==null&&$h(w,T)&&(l.flags|=32),dw(o,l),qn(o,l,I,m),l.child;case 6:return o===null&&Ih(l),null;case 13:return hw(o,l,m);case 4:return Gh(l,l.stateNode.containerInfo),w=l.pendingProps,o===null?l.child=ji(l,null,w,m):qn(o,l,w,m),l.child;case 11:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:tr(w,C),aw(o,l,w,C,m);case 7:return qn(o,l,l.pendingProps,m),l.child;case 8:return qn(o,l,l.pendingProps.children,m),l.child;case 12:return qn(o,l,l.pendingProps.children,m),l.child;case 10:e:{if(w=l.type._context,C=l.pendingProps,T=l.memoizedProps,I=C.value,Dt(Zd,w._currentValue),w._currentValue=I,T!==null)if(Zs(T.value,I)){if(T.children===C.children&&!os.current){l=Ur(o,l,m);break e}}else for(T=l.child,T!==null&&(T.return=l);T!==null;){var V=T.dependencies;if(V!==null){I=T.child;for(var X=V.firstContext;X!==null;){if(X.context===w){if(T.tag===1){X=Fr(-1,m&-m),X.tag=2;var ce=T.updateQueue;if(ce!==null){ce=ce.shared;var ke=ce.pending;ke===null?X.next=X:(X.next=ke.next,ke.next=X),ce.pending=X}}T.lanes|=m,X=T.alternate,X!==null&&(X.lanes|=m),Wh(T.return,m,l),V.lanes|=m;break}X=X.next}}else if(T.tag===10)I=T.type===l.type?null:T.child;else if(T.tag===18){if(I=T.return,I===null)throw Error(s(341));I.lanes|=m,V=I.alternate,V!==null&&(V.lanes|=m),Wh(I,m,l),I=T.sibling}else I=T.child;if(I!==null)I.return=T;else for(I=T;I!==null;){if(I===l){I=null;break}if(T=I.sibling,T!==null){T.return=I.return,I=T;break}I=I.return}T=I}qn(o,l,C.children,m),l=l.child}return l;case 9:return C=l.type,w=l.pendingProps.children,Ni(l,m),C=Os(C),w=w(C),l.flags|=1,qn(o,l,w,m),l.child;case 14:return w=l.type,C=tr(w,l.pendingProps),C=tr(w.type,C),iw(o,l,w,C,m);case 15:return lw(o,l,l.type,l.pendingProps,m);case 17:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:tr(w,C),uu(o,l),l.tag=1,as(w)?(o=!0,Kd(l)):o=!1,Ni(l,m),Zb(l,w,C),rp(l,w,C,m),lp(null,l,w,!0,o,m);case 19:return gw(o,l,m);case 22:return cw(o,l,m)}throw Error(s(156,l.tag))};function Fw(o,l){return be(o,l)}function z_(o,l,m,w){this.tag=o,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ls(o,l,m,w){return new z_(o,l,m,w)}function $p(o){return o=o.prototype,!(!o||!o.isReactComponent)}function D_(o){if(typeof o=="function")return $p(o)?1:0;if(o!=null){if(o=o.$$typeof,o===P)return 11;if(o===Y)return 14}return 2}function Eo(o,l){var m=o.alternate;return m===null?(m=Ls(o.tag,l,o.key,o.mode),m.elementType=o.elementType,m.type=o.type,m.stateNode=o.stateNode,m.alternate=o,o.alternate=m):(m.pendingProps=l,m.type=o.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=o.flags&14680064,m.childLanes=o.childLanes,m.lanes=o.lanes,m.child=o.child,m.memoizedProps=o.memoizedProps,m.memoizedState=o.memoizedState,m.updateQueue=o.updateQueue,l=o.dependencies,m.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},m.sibling=o.sibling,m.index=o.index,m.ref=o.ref,m}function ju(o,l,m,w,C,T){var I=2;if(w=o,typeof o=="function")$p(o)&&(I=1);else if(typeof o=="string")I=5;else e:switch(o){case O:return ba(m.children,C,T,l);case A:I=8,C|=8;break;case L:return o=Ls(12,m,l,C|2),o.elementType=L,o.lanes=T,o;case D:return o=Ls(13,m,l,C),o.elementType=D,o.lanes=T,o;case W:return o=Ls(19,m,l,C),o.elementType=W,o.lanes=T,o;case q:return ku(m,C,T,l);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case M:I=10;break e;case R:I=9;break e;case P:I=11;break e;case Y:I=14;break e;case H:I=16,w=null;break e}throw Error(s(130,o==null?o:typeof o,""))}return l=Ls(I,m,l,C),l.elementType=o,l.type=w,l.lanes=T,l}function ba(o,l,m,w){return o=Ls(7,o,w,l),o.lanes=m,o}function ku(o,l,m,w){return o=Ls(22,o,w,l),o.elementType=q,o.lanes=m,o.stateNode={isHidden:!1},o}function _p(o,l,m){return o=Ls(6,o,null,l),o.lanes=m,o}function Tp(o,l,m){return l=Ls(4,o.children!==null?o.children:[],o.key,l),l.lanes=m,l.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},l}function F_(o,l,m,w,C){this.tag=l,this.containerInfo=o,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=oi(0),this.expirationTimes=oi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=oi(0),this.identifierPrefix=w,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function Rp(o,l,m,w,C,T,I,V,X){return o=new F_(o,l,m,V,X),l===1?(l=1,T===!0&&(l|=8)):l=0,T=Ls(3,null,null,l),o.current=T,T.stateNode=o,T.memoizedState={element:w,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},Bh(T),o}function U_(o,l,m){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:w==null?null:""+w,children:o,containerInfo:l,implementation:m}}function Uw(o){if(!o)return vo;o=o._reactInternals;e:{if(Le(o)!==o||o.tag!==1)throw Error(s(170));var l=o;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(as(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(s(171))}if(o.tag===1){var m=o.type;if(as(m))return pb(o,m,l)}return l}function Ww(o,l,m,w,C,T,I,V,X){return o=Rp(m,w,!0,o,C,T,I,V,X),o.context=Uw(null),m=o.current,w=Kn(),C=So(m),T=Fr(w,C),T.callback=l??null,wo(m,T,C),o.current.lanes=C,co(o,C,w),cs(o,w),o}function Nu(o,l,m,w){var C=l.current,T=Kn(),I=So(C);return m=Uw(m),l.context===null?l.context=m:l.pendingContext=m,l=Fr(T,I),l.payload={element:o},w=w===void 0?null:w,w!==null&&(l.callback=w),o=wo(C,l,I),o!==null&&(rr(o,C,I,T),tu(o,C,I)),I}function Su(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 5:return o.child.stateNode;default:return o.child.stateNode}}function Hw(o,l){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var m=o.retryLane;o.retryLane=m!==0&&m<l?m:l}}function Ap(o,l){Hw(o,l),(o=o.alternate)&&Hw(o,l)}function W_(){return null}var Bw=typeof reportError=="function"?reportError:function(o){console.error(o)};function Op(o){this._internalRoot=o}Cu.prototype.render=Op.prototype.render=function(o){var l=this._internalRoot;if(l===null)throw Error(s(409));Nu(o,l,null,null)},Cu.prototype.unmount=Op.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var l=o.containerInfo;xa(function(){Nu(null,o,null,null)}),l[Pr]=null}};function Cu(o){this._internalRoot=o}Cu.prototype.unstable_scheduleHydration=function(o){if(o){var l=Tl();o={blockedOn:null,target:o,priority:l};for(var m=0;m<Ie.length&&l!==0&&l<Ie[m].priority;m++);Ie.splice(m,0,o),m===0&&Gn(o)}};function Mp(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function Eu(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function Gw(){}function H_(o,l,m,w,C){if(C){if(typeof w=="function"){var T=w;w=function(){var ce=Su(I);T.call(ce)}}var I=Ww(l,w,o,0,null,!1,!1,"",Gw);return o._reactRootContainer=I,o[Pr]=I.current,Fl(o.nodeType===8?o.parentNode:o),xa(),I}for(;C=o.lastChild;)o.removeChild(C);if(typeof w=="function"){var V=w;w=function(){var ce=Su(X);V.call(ce)}}var X=Rp(o,0,!1,null,null,!1,!1,"",Gw);return o._reactRootContainer=X,o[Pr]=X.current,Fl(o.nodeType===8?o.parentNode:o),xa(function(){Nu(l,X,m,w)}),X}function $u(o,l,m,w,C){var T=m._reactRootContainer;if(T){var I=T;if(typeof C=="function"){var V=C;C=function(){var X=Su(I);V.call(X)}}Nu(l,I,o,C)}else I=H_(m,l,o,C,w);return Su(I)}$l=function(o){switch(o.tag){case 3:var l=o.stateNode;if(l.current.memoizedState.isDehydrated){var m=lo(l.pendingLanes);m!==0&&(ai(l,m|1),cs(l,it()),(St&6)===0&&(_i=it()+500,yo()))}break;case 13:xa(function(){var w=Dr(o,1);if(w!==null){var C=Kn();rr(w,o,1,C)}}),Ap(o,1)}},ii=function(o){if(o.tag===13){var l=Dr(o,134217728);if(l!==null){var m=Kn();rr(l,o,134217728,m)}Ap(o,134217728)}},_l=function(o){if(o.tag===13){var l=So(o),m=Dr(o,l);if(m!==null){var w=Kn();rr(m,o,l,w)}Ap(o,l)}},Tl=function(){return Ct},Rl=function(o,l){var m=Ct;try{return Ct=o,l()}finally{Ct=m}},We=function(o,l,m){switch(l){case"input":if(Re(o,m),l=m.name,m.type==="radio"&&l!=null){for(m=o;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<m.length;l++){var w=m[l];if(w!==o&&w.form===o.form){var C=Gd(w);if(!C)throw Error(s(90));me(w),Re(w,C)}}}break;case"textarea":Fe(o,m);break;case"select":l=m.value,l!=null&&Ee(o,!!m.multiple,l,!1)}},Rn=Sp,hs=xa;var B_={usingClientEntryPoint:!1,Events:[Hl,gi,Gd,It,ot,Sp]},sc={findFiberByHostInstance:ca,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},G_={bundleType:sc.bundleType,version:sc.version,rendererPackageName:sc.rendererPackageName,rendererConfig:sc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:N.ReactCurrentDispatcher,findHostInstanceByFiber:function(o){return o=He(o),o===null?null:o.stateNode},findFiberByHostInstance:sc.findFiberByHostInstance||W_,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 _u=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!_u.isDisabled&&_u.supportsFiber)try{ra=_u.inject(G_),xs=_u}catch{}}return ds.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=B_,ds.createPortal=function(o,l){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Mp(l))throw Error(s(200));return U_(o,l,null,m)},ds.createRoot=function(o,l){if(!Mp(o))throw Error(s(299));var m=!1,w="",C=Bw;return l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(w=l.identifierPrefix),l.onRecoverableError!==void 0&&(C=l.onRecoverableError)),l=Rp(o,1,!1,null,null,m,!1,w,C),o[Pr]=l.current,Fl(o.nodeType===8?o.parentNode:o),new Op(l)},ds.findDOMNode=function(o){if(o==null)return null;if(o.nodeType===1)return o;var l=o._reactInternals;if(l===void 0)throw typeof o.render=="function"?Error(s(188)):(o=Object.keys(o).join(","),Error(s(268,o)));return o=He(l),o=o===null?null:o.stateNode,o},ds.flushSync=function(o){return xa(o)},ds.hydrate=function(o,l,m){if(!Eu(l))throw Error(s(200));return $u(null,o,l,!0,m)},ds.hydrateRoot=function(o,l,m){if(!Mp(o))throw Error(s(405));var w=m!=null&&m.hydratedSources||null,C=!1,T="",I=Bw;if(m!=null&&(m.unstable_strictMode===!0&&(C=!0),m.identifierPrefix!==void 0&&(T=m.identifierPrefix),m.onRecoverableError!==void 0&&(I=m.onRecoverableError)),l=Ww(l,null,o,1,m??null,C,!1,T,I),o[Pr]=l.current,Fl(o),w)for(o=0;o<w.length;o++)m=w[o],C=m._getVersion,C=C(m._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[m,C]:l.mutableSourceEagerHydrationData.push(m,C);return new Cu(l)},ds.render=function(o,l,m){if(!Eu(l))throw Error(s(200));return $u(null,o,l,!1,m)},ds.unmountComponentAtNode=function(o){if(!Eu(o))throw Error(s(40));return o._reactRootContainer?(xa(function(){$u(null,null,o,!1,function(){o._reactRootContainer=null,o[Pr]=null})}),!0):!1},ds.unstable_batchedUpdates=Sp,ds.unstable_renderSubtreeIntoContainer=function(o,l,m,w){if(!Eu(m))throw Error(s(200));if(o==null||o._reactInternals===void 0)throw Error(s(38));return $u(o,l,m,!1,w)},ds.version="18.3.1-next-f1338f8080-20240426",ds}var Zw;function wN(){if(Zw)return Ip.exports;Zw=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(n){console.error(n)}}return e(),Ip.exports=tT(),Ip.exports}var ej;function nT(){if(ej)return Tu;ej=1;var e=wN();return Tu.createRoot=e.createRoot,Tu.hydrateRoot=e.hydrateRoot,Tu}var sT=nT();function Zn(e){const n=e&&typeof e=="object"?e.sdk:void 0;return(n==null?void 0:n.runtime)==="claude-agent-sdk"||(n==null?void 0:n.runtime)==="codex-sdk"?{runtime:n.runtime}:void 0}const Vo=e=>e==="claude-agent-sdk"?"Claude Agent SDK":"Codex SDK";/**
|
|
41
|
+
* @license lucide-react v0.468.0 - ISC
|
|
42
|
+
*
|
|
43
|
+
* This source code is licensed under the ISC license.
|
|
44
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
45
|
+
*/const rT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),jN=(...e)=>e.filter((n,s,r)=>!!n&&n.trim()!==""&&r.indexOf(n)===s).join(" ").trim();/**
|
|
46
|
+
* @license lucide-react v0.468.0 - ISC
|
|
47
|
+
*
|
|
48
|
+
* This source code is licensed under the ISC license.
|
|
49
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
50
|
+
*/var oT={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
51
|
+
* @license lucide-react v0.468.0 - ISC
|
|
52
|
+
*
|
|
53
|
+
* This source code is licensed under the ISC license.
|
|
54
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
55
|
+
*/const aT=p.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:a="",children:i,iconNode:c,...d},u)=>p.createElement("svg",{ref:u,...oT,width:n,height:n,stroke:e,strokeWidth:r?Number(s)*24/Number(n):s,className:jN("lucide",a),...d},[...c.map(([f,g])=>p.createElement(f,g)),...Array.isArray(i)?i:[i]]));/**
|
|
56
|
+
* @license lucide-react v0.468.0 - ISC
|
|
57
|
+
*
|
|
58
|
+
* This source code is licensed under the ISC license.
|
|
59
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
60
|
+
*/const Oe=(e,n)=>{const s=p.forwardRef(({className:r,...a},i)=>p.createElement(aT,{ref:i,iconNode:n,className:jN(`lucide-${rT(e)}`,r),...a}));return s.displayName=`${e}`,s};/**
|
|
61
|
+
* @license lucide-react v0.468.0 - ISC
|
|
62
|
+
*
|
|
63
|
+
* This source code is licensed under the ISC license.
|
|
64
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
65
|
+
*/const iT=Oe("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
|
|
66
|
+
* @license lucide-react v0.468.0 - ISC
|
|
67
|
+
*
|
|
68
|
+
* This source code is licensed under the ISC license.
|
|
69
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
70
|
+
*/const kN=Oe("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
|
|
71
|
+
* @license lucide-react v0.468.0 - ISC
|
|
72
|
+
*
|
|
73
|
+
* This source code is licensed under the ISC license.
|
|
74
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
75
|
+
*/const Qc=Oe("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
|
|
76
|
+
* @license lucide-react v0.468.0 - ISC
|
|
77
|
+
*
|
|
78
|
+
* This source code is licensed under the ISC license.
|
|
79
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
80
|
+
*/const zn=Oe("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
81
|
+
* @license lucide-react v0.468.0 - ISC
|
|
82
|
+
*
|
|
83
|
+
* This source code is licensed under the ISC license.
|
|
84
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
85
|
+
*/const Ix=Oe("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
|
|
86
|
+
* @license lucide-react v0.468.0 - ISC
|
|
87
|
+
*
|
|
88
|
+
* This source code is licensed under the ISC license.
|
|
89
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
90
|
+
*/const cr=Oe("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
|
|
91
|
+
* @license lucide-react v0.468.0 - ISC
|
|
92
|
+
*
|
|
93
|
+
* This source code is licensed under the ISC license.
|
|
94
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
95
|
+
*/const NN=Oe("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
|
|
96
|
+
* @license lucide-react v0.468.0 - ISC
|
|
97
|
+
*
|
|
98
|
+
* This source code is licensed under the ISC license.
|
|
99
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
100
|
+
*/const rm=Oe("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/**
|
|
101
|
+
* @license lucide-react v0.468.0 - ISC
|
|
102
|
+
*
|
|
103
|
+
* This source code is licensed under the ISC license.
|
|
104
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
105
|
+
*/const gf=Oe("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
|
|
106
|
+
* @license lucide-react v0.468.0 - ISC
|
|
107
|
+
*
|
|
108
|
+
* This source code is licensed under the ISC license.
|
|
109
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
110
|
+
*/const zx=Oe("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
|
|
111
|
+
* @license lucide-react v0.468.0 - ISC
|
|
112
|
+
*
|
|
113
|
+
* This source code is licensed under the ISC license.
|
|
114
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
115
|
+
*/const xf=Oe("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
|
|
116
|
+
* @license lucide-react v0.468.0 - ISC
|
|
117
|
+
*
|
|
118
|
+
* This source code is licensed under the ISC license.
|
|
119
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
120
|
+
*/const om=Oe("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/**
|
|
121
|
+
* @license lucide-react v0.468.0 - ISC
|
|
122
|
+
*
|
|
123
|
+
* This source code is licensed under the ISC license.
|
|
124
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
125
|
+
*/const hl=Oe("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
|
126
|
+
* @license lucide-react v0.468.0 - ISC
|
|
127
|
+
*
|
|
128
|
+
* This source code is licensed under the ISC license.
|
|
129
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
130
|
+
*/const Rr=Oe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
131
|
+
* @license lucide-react v0.468.0 - ISC
|
|
132
|
+
*
|
|
133
|
+
* This source code is licensed under the ISC license.
|
|
134
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
135
|
+
*/const lT=Oe("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
|
136
|
+
* @license lucide-react v0.468.0 - ISC
|
|
137
|
+
*
|
|
138
|
+
* This source code is licensed under the ISC license.
|
|
139
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
140
|
+
*/const Cs=Oe("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
|
141
|
+
* @license lucide-react v0.468.0 - ISC
|
|
142
|
+
*
|
|
143
|
+
* This source code is licensed under the ISC license.
|
|
144
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
145
|
+
*/const nl=Oe("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
|
|
146
|
+
* @license lucide-react v0.468.0 - ISC
|
|
147
|
+
*
|
|
148
|
+
* This source code is licensed under the ISC license.
|
|
149
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
150
|
+
*/const cT=Oe("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/**
|
|
151
|
+
* @license lucide-react v0.468.0 - ISC
|
|
152
|
+
*
|
|
153
|
+
* This source code is licensed under the ISC license.
|
|
154
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
155
|
+
*/const SN=Oe("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
156
|
+
* @license lucide-react v0.468.0 - ISC
|
|
157
|
+
*
|
|
158
|
+
* This source code is licensed under the ISC license.
|
|
159
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
160
|
+
*/const Dx=Oe("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/**
|
|
161
|
+
* @license lucide-react v0.468.0 - ISC
|
|
162
|
+
*
|
|
163
|
+
* This source code is licensed under the ISC license.
|
|
164
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
165
|
+
*/const dT=Oe("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
|
|
166
|
+
* @license lucide-react v0.468.0 - ISC
|
|
167
|
+
*
|
|
168
|
+
* This source code is licensed under the ISC license.
|
|
169
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
170
|
+
*/const CN=Oe("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
|
|
171
|
+
* @license lucide-react v0.468.0 - ISC
|
|
172
|
+
*
|
|
173
|
+
* This source code is licensed under the ISC license.
|
|
174
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
175
|
+
*/const uT=Oe("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/**
|
|
176
|
+
* @license lucide-react v0.468.0 - ISC
|
|
177
|
+
*
|
|
178
|
+
* This source code is licensed under the ISC license.
|
|
179
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
180
|
+
*/const fT=Oe("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
|
|
181
|
+
* @license lucide-react v0.468.0 - ISC
|
|
182
|
+
*
|
|
183
|
+
* This source code is licensed under the ISC license.
|
|
184
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
185
|
+
*/const am=Oe("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
|
|
186
|
+
* @license lucide-react v0.468.0 - ISC
|
|
187
|
+
*
|
|
188
|
+
* This source code is licensed under the ISC license.
|
|
189
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
190
|
+
*/const qa=Oe("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
191
|
+
* @license lucide-react v0.468.0 - ISC
|
|
192
|
+
*
|
|
193
|
+
* This source code is licensed under the ISC license.
|
|
194
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
195
|
+
*/const mT=Oe("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/**
|
|
196
|
+
* @license lucide-react v0.468.0 - ISC
|
|
197
|
+
*
|
|
198
|
+
* This source code is licensed under the ISC license.
|
|
199
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
200
|
+
*/const hT=Oe("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
|
|
201
|
+
* @license lucide-react v0.468.0 - ISC
|
|
202
|
+
*
|
|
203
|
+
* This source code is licensed under the ISC license.
|
|
204
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
205
|
+
*/const pT=Oe("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
206
|
+
* @license lucide-react v0.468.0 - ISC
|
|
207
|
+
*
|
|
208
|
+
* This source code is licensed under the ISC license.
|
|
209
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
210
|
+
*/const gT=Oe("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
|
|
211
|
+
* @license lucide-react v0.468.0 - ISC
|
|
212
|
+
*
|
|
213
|
+
* This source code is licensed under the ISC license.
|
|
214
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
215
|
+
*/const xT=Oe("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
|
216
|
+
* @license lucide-react v0.468.0 - ISC
|
|
217
|
+
*
|
|
218
|
+
* This source code is licensed under the ISC license.
|
|
219
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
220
|
+
*/const im=Oe("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
221
|
+
* @license lucide-react v0.468.0 - ISC
|
|
222
|
+
*
|
|
223
|
+
* This source code is licensed under the ISC license.
|
|
224
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
225
|
+
*/const Ka=Oe("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
|
226
|
+
* @license lucide-react v0.468.0 - ISC
|
|
227
|
+
*
|
|
228
|
+
* This source code is licensed under the ISC license.
|
|
229
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
230
|
+
*/const EN=Oe("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
|
|
231
|
+
* @license lucide-react v0.468.0 - ISC
|
|
232
|
+
*
|
|
233
|
+
* This source code is licensed under the ISC license.
|
|
234
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
235
|
+
*/const vT=Oe("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
|
|
236
|
+
* @license lucide-react v0.468.0 - ISC
|
|
237
|
+
*
|
|
238
|
+
* This source code is licensed under the ISC license.
|
|
239
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
240
|
+
*/const lm=Oe("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/**
|
|
241
|
+
* @license lucide-react v0.468.0 - ISC
|
|
242
|
+
*
|
|
243
|
+
* This source code is licensed under the ISC license.
|
|
244
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
245
|
+
*/const tj=Oe("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/**
|
|
246
|
+
* @license lucide-react v0.468.0 - ISC
|
|
247
|
+
*
|
|
248
|
+
* This source code is licensed under the ISC license.
|
|
249
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
250
|
+
*/const $N=Oe("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
|
|
251
|
+
* @license lucide-react v0.468.0 - ISC
|
|
252
|
+
*
|
|
253
|
+
* This source code is licensed under the ISC license.
|
|
254
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
255
|
+
*/const yT=Oe("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/**
|
|
256
|
+
* @license lucide-react v0.468.0 - ISC
|
|
257
|
+
*
|
|
258
|
+
* This source code is licensed under the ISC license.
|
|
259
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
260
|
+
*/const bT=Oe("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
|
|
261
|
+
* @license lucide-react v0.468.0 - ISC
|
|
262
|
+
*
|
|
263
|
+
* This source code is licensed under the ISC license.
|
|
264
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
265
|
+
*/const Jc=Oe("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
|
|
266
|
+
* @license lucide-react v0.468.0 - ISC
|
|
267
|
+
*
|
|
268
|
+
* This source code is licensed under the ISC license.
|
|
269
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
270
|
+
*/const Fx=Oe("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/**
|
|
271
|
+
* @license lucide-react v0.468.0 - ISC
|
|
272
|
+
*
|
|
273
|
+
* This source code is licensed under the ISC license.
|
|
274
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
275
|
+
*/const Tg=Oe("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
|
|
276
|
+
* @license lucide-react v0.468.0 - ISC
|
|
277
|
+
*
|
|
278
|
+
* This source code is licensed under the ISC license.
|
|
279
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
280
|
+
*/const Pa=Oe("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
|
|
281
|
+
* @license lucide-react v0.468.0 - ISC
|
|
282
|
+
*
|
|
283
|
+
* This source code is licensed under the ISC license.
|
|
284
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
285
|
+
*/const wT=Oe("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/**
|
|
286
|
+
* @license lucide-react v0.468.0 - ISC
|
|
287
|
+
*
|
|
288
|
+
* This source code is licensed under the ISC license.
|
|
289
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
290
|
+
*/const jT=Oe("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
|
|
291
|
+
* @license lucide-react v0.468.0 - ISC
|
|
292
|
+
*
|
|
293
|
+
* This source code is licensed under the ISC license.
|
|
294
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
295
|
+
*/const Ux=Oe("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
|
|
296
|
+
* @license lucide-react v0.468.0 - ISC
|
|
297
|
+
*
|
|
298
|
+
* This source code is licensed under the ISC license.
|
|
299
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
300
|
+
*/const kT=Oe("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
|
|
301
|
+
* @license lucide-react v0.468.0 - ISC
|
|
302
|
+
*
|
|
303
|
+
* This source code is licensed under the ISC license.
|
|
304
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
305
|
+
*/const NT=Oe("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
306
|
+
* @license lucide-react v0.468.0 - ISC
|
|
307
|
+
*
|
|
308
|
+
* This source code is licensed under the ISC license.
|
|
309
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
310
|
+
*/const Fp=Oe("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/**
|
|
311
|
+
* @license lucide-react v0.468.0 - ISC
|
|
312
|
+
*
|
|
313
|
+
* This source code is licensed under the ISC license.
|
|
314
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
315
|
+
*/const ST=Oe("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
|
316
|
+
* @license lucide-react v0.468.0 - ISC
|
|
317
|
+
*
|
|
318
|
+
* This source code is licensed under the ISC license.
|
|
319
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
320
|
+
*/const CT=Oe("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
|
|
321
|
+
* @license lucide-react v0.468.0 - ISC
|
|
322
|
+
*
|
|
323
|
+
* This source code is licensed under the ISC license.
|
|
324
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
325
|
+
*/const ET=Oe("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
326
|
+
* @license lucide-react v0.468.0 - ISC
|
|
327
|
+
*
|
|
328
|
+
* This source code is licensed under the ISC license.
|
|
329
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
330
|
+
*/const $T=Oe("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
|
|
331
|
+
* @license lucide-react v0.468.0 - ISC
|
|
332
|
+
*
|
|
333
|
+
* This source code is licensed under the ISC license.
|
|
334
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
335
|
+
*/const Wx=Oe("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
336
|
+
* @license lucide-react v0.468.0 - ISC
|
|
337
|
+
*
|
|
338
|
+
* This source code is licensed under the ISC license.
|
|
339
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
340
|
+
*/const _T=Oe("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/**
|
|
341
|
+
* @license lucide-react v0.468.0 - ISC
|
|
342
|
+
*
|
|
343
|
+
* This source code is licensed under the ISC license.
|
|
344
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
345
|
+
*/const TT=Oe("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
346
|
+
* @license lucide-react v0.468.0 - ISC
|
|
347
|
+
*
|
|
348
|
+
* This source code is licensed under the ISC license.
|
|
349
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
350
|
+
*/const Va=Oe("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
|
|
351
|
+
* @license lucide-react v0.468.0 - ISC
|
|
352
|
+
*
|
|
353
|
+
* This source code is licensed under the ISC license.
|
|
354
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
355
|
+
*/const RT=Oe("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
356
|
+
* @license lucide-react v0.468.0 - ISC
|
|
357
|
+
*
|
|
358
|
+
* This source code is licensed under the ISC license.
|
|
359
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
360
|
+
*/const AT=Oe("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
|
|
361
|
+
* @license lucide-react v0.468.0 - ISC
|
|
362
|
+
*
|
|
363
|
+
* This source code is licensed under the ISC license.
|
|
364
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
365
|
+
*/const OT=Oe("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);/**
|
|
366
|
+
* @license lucide-react v0.468.0 - ISC
|
|
367
|
+
*
|
|
368
|
+
* This source code is licensed under the ISC license.
|
|
369
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
370
|
+
*/const sl=Oe("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
|
|
371
|
+
* @license lucide-react v0.468.0 - ISC
|
|
372
|
+
*
|
|
373
|
+
* This source code is licensed under the ISC license.
|
|
374
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
375
|
+
*/const Hx=Oe("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
|
|
376
|
+
* @license lucide-react v0.468.0 - ISC
|
|
377
|
+
*
|
|
378
|
+
* This source code is licensed under the ISC license.
|
|
379
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
380
|
+
*/const Yo=Oe("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
|
|
381
|
+
* @license lucide-react v0.468.0 - ISC
|
|
382
|
+
*
|
|
383
|
+
* This source code is licensed under the ISC license.
|
|
384
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
385
|
+
*/const MT=Oe("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/**
|
|
386
|
+
* @license lucide-react v0.468.0 - ISC
|
|
387
|
+
*
|
|
388
|
+
* This source code is licensed under the ISC license.
|
|
389
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
390
|
+
*/const pl=Oe("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
391
|
+
* @license lucide-react v0.468.0 - ISC
|
|
392
|
+
*
|
|
393
|
+
* This source code is licensed under the ISC license.
|
|
394
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
395
|
+
*/const PT=Oe("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/**
|
|
396
|
+
* @license lucide-react v0.468.0 - ISC
|
|
397
|
+
*
|
|
398
|
+
* This source code is licensed under the ISC license.
|
|
399
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
400
|
+
*/const Bx=Oe("RadioTower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);/**
|
|
401
|
+
* @license lucide-react v0.468.0 - ISC
|
|
402
|
+
*
|
|
403
|
+
* This source code is licensed under the ISC license.
|
|
404
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
405
|
+
*/const Qo=Oe("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
|
|
406
|
+
* @license lucide-react v0.468.0 - ISC
|
|
407
|
+
*
|
|
408
|
+
* This source code is licensed under the ISC license.
|
|
409
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
410
|
+
*/const _N=Oe("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
|
|
411
|
+
* @license lucide-react v0.468.0 - ISC
|
|
412
|
+
*
|
|
413
|
+
* This source code is licensed under the ISC license.
|
|
414
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
415
|
+
*/const LT=Oe("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/**
|
|
416
|
+
* @license lucide-react v0.468.0 - ISC
|
|
417
|
+
*
|
|
418
|
+
* This source code is licensed under the ISC license.
|
|
419
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
420
|
+
*/const cm=Oe("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
421
|
+
* @license lucide-react v0.468.0 - ISC
|
|
422
|
+
*
|
|
423
|
+
* This source code is licensed under the ISC license.
|
|
424
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
425
|
+
*/const TN=Oe("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
426
|
+
* @license lucide-react v0.468.0 - ISC
|
|
427
|
+
*
|
|
428
|
+
* This source code is licensed under the ISC license.
|
|
429
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
430
|
+
*/const IT=Oe("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
431
|
+
* @license lucide-react v0.468.0 - ISC
|
|
432
|
+
*
|
|
433
|
+
* This source code is licensed under the ISC license.
|
|
434
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
435
|
+
*/const RN=Oe("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
436
|
+
* @license lucide-react v0.468.0 - ISC
|
|
437
|
+
*
|
|
438
|
+
* This source code is licensed under the ISC license.
|
|
439
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
440
|
+
*/const AN=Oe("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
|
|
441
|
+
* @license lucide-react v0.468.0 - ISC
|
|
442
|
+
*
|
|
443
|
+
* This source code is licensed under the ISC license.
|
|
444
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
445
|
+
*/const Gx=Oe("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
|
|
446
|
+
* @license lucide-react v0.468.0 - ISC
|
|
447
|
+
*
|
|
448
|
+
* This source code is licensed under the ISC license.
|
|
449
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
450
|
+
*/const zT=Oe("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
451
|
+
* @license lucide-react v0.468.0 - ISC
|
|
452
|
+
*
|
|
453
|
+
* This source code is licensed under the ISC license.
|
|
454
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
455
|
+
*/const DT=Oe("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
|
|
456
|
+
* @license lucide-react v0.468.0 - ISC
|
|
457
|
+
*
|
|
458
|
+
* This source code is licensed under the ISC license.
|
|
459
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
460
|
+
*/const FT=Oe("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
|
|
461
|
+
* @license lucide-react v0.468.0 - ISC
|
|
462
|
+
*
|
|
463
|
+
* This source code is licensed under the ISC license.
|
|
464
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
465
|
+
*/const ON=Oe("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
|
466
|
+
* @license lucide-react v0.468.0 - ISC
|
|
467
|
+
*
|
|
468
|
+
* This source code is licensed under the ISC license.
|
|
469
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
470
|
+
*/const Gs=Oe("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
471
|
+
* @license lucide-react v0.468.0 - ISC
|
|
472
|
+
*
|
|
473
|
+
* This source code is licensed under the ISC license.
|
|
474
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
475
|
+
*/const qx=Oe("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
|
|
476
|
+
* @license lucide-react v0.468.0 - ISC
|
|
477
|
+
*
|
|
478
|
+
* This source code is licensed under the ISC license.
|
|
479
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
480
|
+
*/const rl=Oe("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/**
|
|
481
|
+
* @license lucide-react v0.468.0 - ISC
|
|
482
|
+
*
|
|
483
|
+
* This source code is licensed under the ISC license.
|
|
484
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
485
|
+
*/const MN=Oe("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
|
486
|
+
* @license lucide-react v0.468.0 - ISC
|
|
487
|
+
*
|
|
488
|
+
* This source code is licensed under the ISC license.
|
|
489
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
490
|
+
*/const Ya=Oe("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/**
|
|
491
|
+
* @license lucide-react v0.468.0 - ISC
|
|
492
|
+
*
|
|
493
|
+
* This source code is licensed under the ISC license.
|
|
494
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
495
|
+
*/const vf=Oe("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
|
|
496
|
+
* @license lucide-react v0.468.0 - ISC
|
|
497
|
+
*
|
|
498
|
+
* This source code is licensed under the ISC license.
|
|
499
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
500
|
+
*/const Jo=Oe("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
|
|
501
|
+
* @license lucide-react v0.468.0 - ISC
|
|
502
|
+
*
|
|
503
|
+
* This source code is licensed under the ISC license.
|
|
504
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
505
|
+
*/const UT=Oe("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function PN(e){var n,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(n=0;n<a;n++)e[n]&&(s=PN(e[n]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function LN(){for(var e,n,s=0,r="",a=arguments.length;s<a;s++)(e=arguments[s])&&(n=PN(e))&&(r&&(r+=" "),r+=n);return r}const Kx="-",WT=e=>{const n=BT(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{const d=c.split(Kx);return d[0]===""&&d.length!==1&&d.shift(),IN(d,n)||HT(c)},getConflictingClassGroupIds:(c,d)=>{const u=s[c]||[];return d&&r[c]?[...u,...r[c]]:u}}},IN=(e,n)=>{var c;if(e.length===0)return n.classGroupId;const s=e[0],r=n.nextPart.get(s),a=r?IN(e.slice(1),r):void 0;if(a)return a;if(n.validators.length===0)return;const i=e.join(Kx);return(c=n.validators.find(({validator:d})=>d(i)))==null?void 0:c.classGroupId},nj=/^\[(.+)\]$/,HT=e=>{if(nj.test(e)){const n=nj.exec(e)[1],s=n==null?void 0:n.substring(0,n.indexOf(":"));if(s)return"arbitrary.."+s}},BT=e=>{const{theme:n,prefix:s}=e,r={nextPart:new Map,validators:[]};return qT(Object.entries(e.classGroups),s).forEach(([i,c])=>{Rg(c,r,i,n)}),r},Rg=(e,n,s,r)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?n:sj(n,a);i.classGroupId=s;return}if(typeof a=="function"){if(GT(a)){Rg(a(r),n,s,r);return}n.validators.push({validator:a,classGroupId:s});return}Object.entries(a).forEach(([i,c])=>{Rg(c,sj(n,i),s,r)})})},sj=(e,n)=>{let s=e;return n.split(Kx).forEach(r=>{s.nextPart.has(r)||s.nextPart.set(r,{nextPart:new Map,validators:[]}),s=s.nextPart.get(r)}),s},GT=e=>e.isThemeGetter,qT=(e,n)=>n?e.map(([s,r])=>{const a=r.map(i=>typeof i=="string"?n+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([c,d])=>[n+c,d])):i);return[s,a]}):e,KT=e=>{if(e<1)return{get:()=>{},set:()=>{}};let n=0,s=new Map,r=new Map;const a=(i,c)=>{s.set(i,c),n++,n>e&&(n=0,r=s,s=new Map)};return{get(i){let c=s.get(i);if(c!==void 0)return c;if((c=r.get(i))!==void 0)return a(i,c),c},set(i,c){s.has(i)?s.set(i,c):a(i,c)}}},zN="!",VT=e=>{const{separator:n,experimentalParseClassName:s}=e,r=n.length===1,a=n[0],i=n.length,c=d=>{const u=[];let f=0,g=0,b;for(let j=0;j<d.length;j++){let k=d[j];if(f===0){if(k===a&&(r||d.slice(j,j+i)===n)){u.push(d.slice(g,j)),g=j+i;continue}if(k==="/"){b=j;continue}}k==="["?f++:k==="]"&&f--}const x=u.length===0?d:d.substring(g),h=x.startsWith(zN),v=h?x.substring(1):x,y=b&&b>g?b-g:void 0;return{modifiers:u,hasImportantModifier:h,baseClassName:v,maybePostfixModifierPosition:y}};return s?d=>s({className:d,parseClassName:c}):c},YT=e=>{if(e.length<=1)return e;const n=[];let s=[];return e.forEach(r=>{r[0]==="["?(n.push(...s.sort(),r),s=[]):s.push(r)}),n.push(...s.sort()),n},QT=e=>({cache:KT(e.cacheSize),parseClassName:VT(e),...WT(e)}),JT=/\s+/,XT=(e,n)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:a}=n,i=[],c=e.trim().split(JT);let d="";for(let u=c.length-1;u>=0;u-=1){const f=c[u],{modifiers:g,hasImportantModifier:b,baseClassName:x,maybePostfixModifierPosition:h}=s(f);let v=!!h,y=r(v?x.substring(0,h):x);if(!y){if(!v){d=f+(d.length>0?" "+d:d);continue}if(y=r(x),!y){d=f+(d.length>0?" "+d:d);continue}v=!1}const j=YT(g).join(":"),k=b?j+zN:j,E=k+y;if(i.includes(E))continue;i.push(E);const S=a(y,v);for(let N=0;N<S.length;++N){const _=S[N];i.push(k+_)}d=f+(d.length>0?" "+d:d)}return d};function ZT(){let e=0,n,s,r="";for(;e<arguments.length;)(n=arguments[e++])&&(s=DN(n))&&(r&&(r+=" "),r+=s);return r}const DN=e=>{if(typeof e=="string")return e;let n,s="";for(let r=0;r<e.length;r++)e[r]&&(n=DN(e[r]))&&(s&&(s+=" "),s+=n);return s};function rj(e,...n){let s,r,a,i=c;function c(u){const f=n.reduce((g,b)=>b(g),e());return s=QT(f),r=s.cache.get,a=s.cache.set,i=d,d(u)}function d(u){const f=r(u);if(f)return f;const g=XT(u,s);return a(u,g),g}return function(){return i(ZT.apply(null,arguments))}}const Gt=e=>{const n=s=>s[e]||[];return n.isThemeGetter=!0,n},FN=/^\[(?:([a-z-]+):)?(.+)\]$/i,eR=/^\d+\/\d+$/,tR=new Set(["px","full","screen"]),nR=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sR=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,rR=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,oR=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,aR=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Hr=e=>Bi(e)||tR.has(e)||eR.test(e),_o=e=>gl(e,"length",hR),Bi=e=>!!e&&!Number.isNaN(Number(e)),Up=e=>gl(e,"number",Bi),oc=e=>!!e&&Number.isInteger(Number(e)),iR=e=>e.endsWith("%")&&Bi(e.slice(0,-1)),gt=e=>FN.test(e),To=e=>nR.test(e),lR=new Set(["length","size","percentage"]),cR=e=>gl(e,lR,UN),dR=e=>gl(e,"position",UN),uR=new Set(["image","url"]),fR=e=>gl(e,uR,gR),mR=e=>gl(e,"",pR),ac=()=>!0,gl=(e,n,s)=>{const r=FN.exec(e);return r?r[1]?typeof n=="string"?r[1]===n:n.has(r[1]):s(r[2]):!1},hR=e=>sR.test(e)&&!rR.test(e),UN=()=>!1,pR=e=>oR.test(e),gR=e=>aR.test(e),oj=()=>{const e=Gt("colors"),n=Gt("spacing"),s=Gt("blur"),r=Gt("brightness"),a=Gt("borderColor"),i=Gt("borderRadius"),c=Gt("borderSpacing"),d=Gt("borderWidth"),u=Gt("contrast"),f=Gt("grayscale"),g=Gt("hueRotate"),b=Gt("invert"),x=Gt("gap"),h=Gt("gradientColorStops"),v=Gt("gradientColorStopPositions"),y=Gt("inset"),j=Gt("margin"),k=Gt("opacity"),E=Gt("padding"),S=Gt("saturate"),N=Gt("scale"),_=Gt("sepia"),$=Gt("skew"),O=Gt("space"),A=Gt("translate"),L=()=>["auto","contain","none"],M=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto",gt,n],P=()=>[gt,n],D=()=>["",Hr,_o],W=()=>["auto",Bi,gt],Y=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],H=()=>["solid","dashed","dotted","double","none"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F=()=>["start","end","center","between","around","evenly","stretch"],G=()=>["","0",gt],U=()=>["auto","avoid","all","avoid-page","page","left","right","column"],z=()=>[Bi,gt];return{cacheSize:500,separator:":",theme:{colors:[ac],spacing:[Hr,_o],blur:["none","",To,gt],brightness:z(),borderColor:[e],borderRadius:["none","","full",To,gt],borderSpacing:P(),borderWidth:D(),contrast:z(),grayscale:G(),hueRotate:z(),invert:G(),gap:P(),gradientColorStops:[e],gradientColorStopPositions:[iR,_o],inset:R(),margin:R(),opacity:z(),padding:P(),saturate:z(),scale:z(),sepia:G(),skew:z(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",gt]}],container:["container"],columns:[{columns:[To]}],"break-after":[{"break-after":U()}],"break-before":[{"break-before":U()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Y(),gt]}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:L()}],"overscroll-x":[{"overscroll-x":L()}],"overscroll-y":[{"overscroll-y":L()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",oc,gt]}],basis:[{basis:R()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",gt]}],grow:[{grow:G()}],shrink:[{shrink:G()}],order:[{order:["first","last","none",oc,gt]}],"grid-cols":[{"grid-cols":[ac]}],"col-start-end":[{col:["auto",{span:["full",oc,gt]},gt]}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":[ac]}],"row-start-end":[{row:["auto",{span:[oc,gt]},gt]}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",gt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",gt]}],gap:[{gap:[x]}],"gap-x":[{"gap-x":[x]}],"gap-y":[{"gap-y":[x]}],"justify-content":[{justify:["normal",...F()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...F(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...F(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[E]}],px:[{px:[E]}],py:[{py:[E]}],ps:[{ps:[E]}],pe:[{pe:[E]}],pt:[{pt:[E]}],pr:[{pr:[E]}],pb:[{pb:[E]}],pl:[{pl:[E]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[O]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[O]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",gt,n]}],"min-w":[{"min-w":[gt,n,"min","max","fit"]}],"max-w":[{"max-w":[gt,n,"none","full","min","max","fit","prose",{screen:[To]},To]}],h:[{h:[gt,n,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[gt,n,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[gt,n,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[gt,n,"auto","min","max","fit"]}],"font-size":[{text:["base",To,_o]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Up]}],"font-family":[{font:[ac]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",gt]}],"line-clamp":[{"line-clamp":["none",Bi,Up]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Hr,gt]}],"list-image":[{"list-image":["none",gt]}],"list-style-type":[{list:["none","disc","decimal",gt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...H(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Hr,_o]}],"underline-offset":[{"underline-offset":["auto",Hr,gt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",gt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",gt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Y(),dR]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",cR]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},fR]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[v]}],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[d]}],"border-w-x":[{"border-x":[d]}],"border-w-y":[{"border-y":[d]}],"border-w-s":[{"border-s":[d]}],"border-w-e":[{"border-e":[d]}],"border-w-t":[{"border-t":[d]}],"border-w-r":[{"border-r":[d]}],"border-w-b":[{"border-b":[d]}],"border-w-l":[{"border-l":[d]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...H(),"hidden"]}],"divide-x":[{"divide-x":[d]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[d]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:H()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...H()]}],"outline-offset":[{"outline-offset":[Hr,gt]}],"outline-w":[{outline:[Hr,_o]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:D()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Hr,_o]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",To,mR]}],"shadow-color":[{shadow:[ac]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...q(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":q()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",To,gt]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[g]}],invert:[{invert:[b]}],saturate:[{saturate:[S]}],sepia:[{sepia:[_]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[s]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[g]}],"backdrop-invert":[{"backdrop-invert":[b]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[S]}],"backdrop-sepia":[{"backdrop-sepia":[_]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",gt]}],duration:[{duration:z()}],ease:[{ease:["linear","in","out","in-out",gt]}],delay:[{delay:z()}],animate:[{animate:["none","spin","ping","pulse","bounce",gt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[N]}],"scale-x":[{"scale-x":[N]}],"scale-y":[{"scale-y":[N]}],rotate:[{rotate:[oc,gt]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[$]}],"skew-y":[{"skew-y":[$]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",gt]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",gt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",gt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Hr,_o,Up]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},xR=(e,{cacheSize:n,prefix:s,separator:r,experimentalParseClassName:a,extend:i={},override:c={}})=>{yc(e,"cacheSize",n),yc(e,"prefix",s),yc(e,"separator",r),yc(e,"experimentalParseClassName",a);for(const d in c)vR(e[d],c[d]);for(const d in i)yR(e[d],i[d]);return e},yc=(e,n,s)=>{s!==void 0&&(e[n]=s)},vR=(e,n)=>{if(n)for(const s in n)yc(e,s,n[s])},yR=(e,n)=>{if(n)for(const s in n){const r=n[s];r!==void 0&&(e[s]=(e[s]||[]).concat(r))}},bR=(e,...n)=>typeof e=="function"?rj(oj,e,...n):rj(()=>xR(oj(),e),...n),wR=bR({override:{conflictingClassGroups:{"font-size":[]}},extend:{theme:{spacing:["sidebar","control-sm","control-md","control-lg"],borderRadius:["composer","action"]},classGroups:{"max-w":[{"max-w":["page","page-wide"]}],"font-size":[{text:["micro","label","small","body","lead","prose","figure","display"]}],z:[{z:["raised","sticky","overlay","dialog","popover","toast"]}],shadow:[{shadow:["float"]}],duration:[{duration:["fast","base","slow"]}],ease:[{ease:["standard"]}],"outline-w":[{outline:["focus"]}],"outline-offset":[{"outline-offset":["focus"]}]}}}),oe=(...e)=>wR(LN(e)),jR={neutral:{box:"border-border bg-card",text:"text-foreground",Icon:Tg},info:{box:"border-info/50 bg-info/5",text:"text-info-text",Icon:Tg},success:{box:"border-success/50 bg-success/5",text:"text-success-text",Icon:SN},warning:{box:"border-warning/50 bg-warning/5",text:"text-warning-text",Icon:Gs},error:{box:"border-destructive/50 bg-destructive/5",text:"text-destructive-text",Icon:nl}};function vt({tone:e="neutral",title:n,actions:s,bar:r,icon:a,role:i,className:c,children:d,...u}){const f=jR[e],g=a===!1?null:a??f.Icon;return t.jsxs("div",{role:i??(e==="error"?"alert":"status"),...u,className:oe("flex gap-3 text-body",r?"shrink-0 items-center border-b bg-card px-5 py-2 md:px-8":oe("border p-4",f.box),c),children:[g&&t.jsx(g,{className:oe("size-4 shrink-0",!r&&"mt-0.5",f.text),"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[n&&t.jsx("p",{className:oe("font-semibold",!r&&"caps text-small",!r&&f.text),children:n}),d&&t.jsx("div",{className:oe(n&&!r&&"mt-2"),children:d})]}),s&&t.jsx("div",{className:"flex shrink-0 items-start gap-2",children:s})]})}const aj=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,ij=LN,kR=(e,n)=>s=>{var r;if((n==null?void 0:n.variants)==null)return ij(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:a,defaultVariants:i}=n,c=Object.keys(a).map(f=>{const g=s==null?void 0:s[f],b=i==null?void 0:i[f];if(g===null)return null;const x=aj(g)||aj(b);return a[f][x]}),d=s&&Object.entries(s).reduce((f,g)=>{let[b,x]=g;return x===void 0||(f[b]=x),f},{}),u=n==null||(r=n.compoundVariants)===null||r===void 0?void 0:r.reduce((f,g)=>{let{class:b,className:x,...h}=g;return Object.entries(h).every(v=>{let[y,j]=v;return Array.isArray(j)?j.includes({...i,...d}[y]):{...i,...d}[y]===j})?[...f,b,x]:f},[]);return ij(e,c,u,s==null?void 0:s.class,s==null?void 0:s.className)},Oc=kR("caps inline-flex items-center justify-center gap-2 whitespace-nowrap !rounded-action border text-small transition-colors disabled:cursor-not-allowed disabled:opacity-45 [&_svg]:size-3.5 [&_svg]:shrink-0",{variants:{variant:{outline:"border-border bg-background hover:border-border-strong hover:bg-accent",primary:"border-transparent bg-primary/10 text-primary-action-text hover:bg-primary/20 focus-visible:bg-primary/20",solid:"border-transparent bg-primary/10 text-primary-action-text hover:bg-primary/20 focus-visible:bg-primary/20",destructive:"border-destructive/60 text-destructive-text hover:bg-destructive/10",ghost:"border-transparent hover:bg-accent"},size:{xs:"h-7 gap-1.5 px-2 text-label",sm:"h-control-sm px-3",md:"h-control-md px-4",lg:"h-control-lg px-5",icon:"size-control-sm"}},defaultVariants:{variant:"outline",size:"md"}}),B=p.forwardRef(({className:e,variant:n,size:s,...r},a)=>t.jsx("button",{ref:a,className:oe(Oc({variant:n,size:s}),e),...r}));B.displayName="Button";const lj={plain:"border-border text-muted-foreground",active:"border-run-active/50 text-run-active",success:"border-success/50 bg-success/10 text-success-text",warning:"border-warning/50 bg-warning/10 text-warning-text",error:"border-destructive/50 bg-destructive/10 text-destructive-text",info:"border-info/50 bg-info/10 text-info-text",muted:"border-border-strong/60 text-muted-foreground"};function Ne({tone:e="plain",className:n,title:s,label:r,children:a}){return r?t.jsx("span",{title:s,className:oe("caps inline-flex h-5 min-w-0 items-center gap-1 border px-1.5 text-micro leading-none",lj[e],n),children:t.jsx("span",{className:"min-w-0 truncate",children:a})}):t.jsx("span",{title:s,className:oe("caps inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap border px-1.5 text-micro leading-none",lj[e],n),children:a})}const qs=e=>NR(e)?e.document:SR(e)?e:(e==null?void 0:e.ownerDocument)??(typeof document<"u"?document:void 0),dm=e=>{let n=qs(e);return(n==null?void 0:n.defaultView)??(typeof window<"u"?window:void 0)};function WN(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function NR(e){return typeof e=="object"&&e!=null&&"window"in e&&e.window===e}function SR(e){return WN(e)&&e.nodeType===9}function CR(e){return WN(e)&&e.nodeType===11&&"host"in e}let ER=!1;function Vx(){return ER}function _a(e,n){var r;if(!Vx())return n&&e?e.contains(n):!1;if(!e||!n)return!1;let s=n;for(;s!=null;){if(s===e)return!0;typeof s.assignedElements!="function"&&((r=s.assignedSlot)!=null&&r.parentNode)?s=s.assignedSlot.parentNode:CR(s)?s=s.host:s=s.parentNode}return!1}const Wo=(e=document)=>{var s;if(!Vx())return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&((s=n.shadowRoot)!=null&&s.activeElement);)n=n.shadowRoot.activeElement;return n};function Qn(e){if(Vx()&&e.target instanceof Element&&e.target.shadowRoot){if("composedPath"in e)return e.composedPath()[0]??null;if("composedPath"in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}function $R(e){e.focus({preventScroll:!0})}const _R=typeof document<"u"?qe.useLayoutEffect:()=>{};function HN(e){let n=e;return n.nativeEvent=e,n.isDefaultPrevented=()=>n.defaultPrevented,n.isPropagationStopped=()=>n.cancelBubble,n.persist=()=>{},n}function TR(e,n){Object.defineProperty(e,"target",{value:n}),Object.defineProperty(e,"currentTarget",{value:n})}function BN(e){let n=p.useRef({isFocused:!1,observer:null});return _R(()=>{const s=n.current;return()=>{s.observer&&(s.observer.disconnect(),s.observer=null)}},[]),p.useCallback(s=>{let r=Qn(s);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){n.current.isFocused=!0;let a=r,i=c=>{if(n.current.isFocused=!1,a.disabled){let d=HN(c);e==null||e(d)}n.current.observer&&(n.current.observer.disconnect(),n.current.observer=null)};a.addEventListener("focusout",i,{once:!0}),n.current.observer=new MutationObserver(()=>{var c;if(n.current.isFocused&&a.disabled){(c=n.current.observer)==null||c.disconnect();let d=a===Wo()?null:Wo();a.dispatchEvent(new FocusEvent("blur",{relatedTarget:d})),a.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:d}))}}),n.current.observer.observe(a,{attributes:!0,attributeFilter:["disabled"]})}},[e])}function Yx(e){var s;if(typeof window>"u"||window.navigator==null)return!1;let n=(s=window.navigator.userAgentData)==null?void 0:s.brands;return Array.isArray(n)&&n.some(r=>e.test(r.brand))||e.test(window.navigator.userAgent)}function Qx(e){var n;return typeof window<"u"&&window.navigator!=null?e.test(((n=window.navigator.userAgentData)==null?void 0:n.platform)||window.navigator.platform):!1}function Qa(e){let n=null;return()=>(n==null&&(n=e()),n)}const Jx=Qa(function(){return Qx(/^Mac/i)}),RR=Qa(function(){return Qx(/^iPhone/i)}),GN=Qa(function(){return Qx(/^iPad/i)||Jx()&&navigator.maxTouchPoints>1}),AR=Qa(function(){return RR()||GN()}),OR=Qa(function(){return Yx(/AppleWebKit/i)&&(AR()||!MR())}),MR=Qa(function(){return Yx(/Chrome|CriOS|CrMo/i)}),PR=Qa(function(){return Yx(/Android/i)});function LR(e){return e.pointerType===""&&e.isTrusted?!0:PR()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Mc(e,n,s=!0){let{metaKey:r,ctrlKey:a,altKey:i,shiftKey:c}=n,d=OR()&&Jx()&&!GN()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:r,ctrlKey:a,altKey:i,shiftKey:c}):new MouseEvent("click",{metaKey:r,ctrlKey:a,altKey:i,shiftKey:c,detail:1,bubbles:!0,cancelable:!0});Mc.isOpening=s,$R(e),e.dispatchEvent(d),Mc.isOpening=!1}Mc.isOpening=!1;let xl=null;const Ag=new Set;let Sc=new Map,La=!1,sf=!1;const IR={Tab:!0,Escape:!0};function um(e,n){for(let s of Ag)s(e,n)}function zR(e){return!(e.metaKey||!Jx()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function yf(e){La=!0,!Mc.isOpening&&zR(e)&&(xl="keyboard",um("keyboard",e))}function Gi(e){xl="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(La=!0,um("pointer",e))}function qN(e){!Mc.isOpening&&LR(e)&&(La=!0,xl="virtual")}function KN(e){let n=Qn(e),s=dm(n),r=qs(n);if(n===s){sf=!0;return}n===r||!e.isTrusted||(!La&&!sf&&(xl="virtual",um("virtual",e)),La=!1,sf=!1)}function VN(){La=!1,sf=!0}function YN(e){let n=Wo(qs(Qn(e)));queueMicrotask(()=>{Wo(qs(Qn(e)))!==n&&FR("keyboard")})}function Og(e){if(typeof window>"u"||typeof document>"u")return;const n=dm(e),s=qs(e);if(Sc.get(n))return;let r=n.HTMLElement.prototype.focus;Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){La=!0,r.apply(this,arguments)}}),s.addEventListener("keydown",yf,!0),s.addEventListener("keyup",yf,!0),s.addEventListener("click",qN,!0),s.addEventListener("invalid",YN,!0),n.addEventListener("focus",KN,!0),n.addEventListener("blur",VN,!1),typeof PointerEvent<"u"&&(s.addEventListener("pointerdown",Gi,!0),s.addEventListener("pointermove",Gi,!0),s.addEventListener("pointerup",Gi,!0)),n.addEventListener("beforeunload",()=>{QN(e)},{once:!0}),Sc.set(n,{focus:r})}const QN=(e,n)=>{const s=dm(e),r=qs(e);n&&r.removeEventListener("DOMContentLoaded",n),Sc.has(s)&&(Reflect.defineProperty(s.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:Sc.get(s).focus}),r.removeEventListener("keydown",yf,!0),r.removeEventListener("keyup",yf,!0),r.removeEventListener("click",qN,!0),r.removeEventListener("invalid",YN,!0),s.removeEventListener("focus",KN,!0),s.removeEventListener("blur",VN,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",Gi,!0),r.removeEventListener("pointermove",Gi,!0),r.removeEventListener("pointerup",Gi,!0)),Sc.delete(s))};function DR(e){const n=qs(e);let s;return n.readyState!=="loading"?Og(e):(s=()=>{Og(e)},n.addEventListener("DOMContentLoaded",s)),()=>QN(e,s)}typeof document<"u"&&DR();function Mg(){return xl!=="pointer"}function FR(e){xl=e,um(e,null)}const UR=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function WR(e,n,s){let r=s?Qn(s):void 0,a=qs(r),i=dm(r);const c=typeof i<"u"?i.HTMLInputElement:HTMLInputElement,d=typeof i<"u"?i.HTMLTextAreaElement:HTMLTextAreaElement,u=typeof i<"u"?i.HTMLElement:HTMLElement,f=typeof i<"u"?i.KeyboardEvent:KeyboardEvent;let g=Wo(a);return e=e||g instanceof c&&!UR.has(g.type)||g instanceof d||g instanceof u&&g.isContentEditable,!(e&&n==="keyboard"&&s instanceof f&&!IR[s.key])}function HR(e,n,s){Og(),p.useEffect(()=>{if((s==null?void 0:s.enabled)===!1)return;let r=(a,i)=>{WR(!!(s!=null&&s.isTextInput),a,i)&&e(Mg())};return Ag.add(r),()=>{Ag.delete(r)}},n)}function BR(e){let{isDisabled:n,onFocus:s,onBlur:r,onFocusChange:a}=e;const i=p.useCallback(u=>{if(Qn(u)===u.currentTarget)return r&&r(u),a&&a(!1),!0},[r,a]),c=BN(i),d=p.useCallback(u=>{let f=Qn(u);const g=qs(f),b=g?Wo(g):Wo();f===u.currentTarget&&f===b&&(s&&s(u),a&&a(!0),c(u))},[a,s,c]);return{focusProps:{onFocus:!n&&(s||a||r)?d:void 0,onBlur:!n&&(r||a)?i:void 0}}}function JN(){let e=p.useRef(new Map),n=p.useCallback((a,i,c,d)=>{let u=d!=null&&d.once?(...f)=>{e.current.delete(c),c(...f)}:c;e.current.set(c,{type:i,eventTarget:a,fn:u,options:d}),a.addEventListener(i,u,d)},[]),s=p.useCallback((a,i,c,d)=>{var f;let u=((f=e.current.get(c))==null?void 0:f.fn)||c;a.removeEventListener(i,u,d),e.current.delete(c)},[]),r=p.useCallback(()=>{e.current.forEach((a,i)=>{s(a.eventTarget,a.type,i,a.options)})},[s]);return p.useEffect(()=>r,[r]),{addGlobalListener:n,removeGlobalListener:s,removeAllGlobalListeners:r}}function GR(e){let{isDisabled:n,onBlurWithin:s,onFocusWithin:r,onFocusWithinChange:a}=e,i=p.useRef({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:d}=JN(),u=p.useCallback(b=>{_a(b.currentTarget,Qn(b))&&i.current.isFocusWithin&&!_a(b.currentTarget,b.relatedTarget)&&(i.current.isFocusWithin=!1,d(),s&&s(b),a&&a(!1))},[s,a,i,d]),f=BN(u),g=p.useCallback(b=>{if(!_a(b.currentTarget,Qn(b)))return;let x=Qn(b);const h=qs(x),v=Wo(h);if(!i.current.isFocusWithin&&v===x){r&&r(b),a&&a(!0),i.current.isFocusWithin=!0,f(b);let y=b.currentTarget;c(h,"focus",j=>{let k=Qn(j);if(i.current.isFocusWithin&&!_a(y,k)){let E=new h.defaultView.FocusEvent("blur",{relatedTarget:k});TR(E,y);let S=HN(E);u(S)}},{capture:!0})}},[r,a,f,c,u]);return n?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:g,onBlur:u}}}function qR(e={}){let{autoFocus:n=!1,isTextInput:s,within:r}=e,a=p.useRef({isFocused:!1,isFocusVisible:n||Mg()}),[i,c]=p.useState(!1),[d,u]=p.useState(()=>a.current.isFocused&&a.current.isFocusVisible),f=p.useCallback(()=>u(a.current.isFocused&&a.current.isFocusVisible),[]),g=p.useCallback(h=>{a.current.isFocused=h,a.current.isFocusVisible=Mg(),c(h),f()},[f]);HR(h=>{a.current.isFocusVisible=h,f()},[s,i],{enabled:i,isTextInput:s});let{focusProps:b}=BR({isDisabled:r,onFocusChange:g}),{focusWithinProps:x}=GR({isDisabled:!r,onFocusWithinChange:g});return{isFocused:i,isFocusVisible:d,focusProps:r?x:b}}var ks=wN();let Pg=!1,Ru=0;function KR(){Pg=!0,setTimeout(()=>{Pg=!1},500)}function cj(e){e.pointerType==="touch"&&KR()}function VR(){let e=qs(null);if(!(typeof e>"u"))return Ru===0&&typeof PointerEvent<"u"&&e.addEventListener("pointerup",cj),Ru++,()=>{Ru--,!(Ru>0)&&typeof PointerEvent<"u"&&e.removeEventListener("pointerup",cj)}}function YR(e){let{onHoverStart:n,onHoverChange:s,onHoverEnd:r,isDisabled:a}=e,[i,c]=p.useState(!1),d=p.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;p.useEffect(VR,[]);let{addGlobalListener:u,removeAllGlobalListeners:f}=JN(),{hoverProps:g,triggerHoverEnd:b}=p.useMemo(()=>{let x=(y,j)=>{if(d.pointerType=j,a||j==="touch"||d.isHovered||!_a(y.currentTarget,Qn(y)))return;d.isHovered=!0;let k=y.currentTarget;d.target=k,u(qs(Qn(y)),"pointerover",E=>{d.isHovered&&d.target&&!_a(d.target,Qn(E))&&h(E,E.pointerType)},{capture:!0}),n&&n({type:"hoverstart",target:k,pointerType:j}),s&&s(!0),c(!0)},h=(y,j)=>{let k=d.target;d.pointerType="",d.target=null,!(j==="touch"||!d.isHovered||!k)&&(d.isHovered=!1,f(),r&&r({type:"hoverend",target:k,pointerType:j}),s&&s(!1),c(!1))},v={};return typeof PointerEvent<"u"&&(v.onPointerEnter=y=>{Pg&&y.pointerType==="mouse"||x(y,y.pointerType)},v.onPointerLeave=y=>{!a&&_a(y.currentTarget,Qn(y))&&h(y,y.pointerType)}),{hoverProps:v,triggerHoverEnd:h}},[n,s,r,a,d,u,f]);return p.useEffect(()=>{a&&b({currentTarget:d.target},d.pointerType)},[a]),{hoverProps:g,isHovered:i}}var QR=Object.defineProperty,JR=(e,n,s)=>n in e?QR(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Wp=(e,n,s)=>(JR(e,typeof n!="symbol"?n+"":n,s),s);let XR=class{constructor(){Wp(this,"current",this.detect()),Wp(this,"handoffState","pending"),Wp(this,"currentId",0)}set(n){this.current!==n&&(this.handoffState="pending",this.currentId=0,this.current=n)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},Nr=new XR;function vl(e){var n;return Nr.isServer?null:e==null?document:(n=e==null?void 0:e.ownerDocument)!=null?n:document}function bf(e){var n,s;return Nr.isServer?null:e==null?document:(s=(n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))!=null?s:document}function XN(e){var n,s;return(s=(n=bf(e))==null?void 0:n.activeElement)!=null?s:null}function ZN(e){return XN(e)===e}function fm(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(n=>setTimeout(()=>{throw n}))}function Es(){let e=[],n={addEventListener(s,r,a,i){return s.addEventListener(r,a,i),n.add(()=>s.removeEventListener(r,a,i))},requestAnimationFrame(...s){let r=requestAnimationFrame(...s);return n.add(()=>cancelAnimationFrame(r))},nextFrame(...s){return n.requestAnimationFrame(()=>n.requestAnimationFrame(...s))},setTimeout(...s){let r=setTimeout(...s);return n.add(()=>clearTimeout(r))},microTask(...s){let r={current:!0};return fm(()=>{r.current&&s[0]()}),n.add(()=>{r.current=!1})},style(s,r,a){let i=s.style.getPropertyValue(r);return Object.assign(s.style,{[r]:a}),this.add(()=>{Object.assign(s.style,{[r]:i})})},group(s){let r=Es();return s(r),this.add(()=>r.dispose())},add(s){return e.includes(s)||e.push(s),()=>{let r=e.indexOf(s);if(r>=0)for(let a of e.splice(r,1))a()}},dispose(){for(let s of e.splice(0))s()}};return n}function Xo(){let[e]=p.useState(Es);return p.useEffect(()=>()=>e.dispose(),[e]),e}let en=(e,n)=>{Nr.isServer?p.useEffect(e,n):p.useLayoutEffect(e,n)};function Zo(e){let n=p.useRef(e);return en(()=>{n.current=e},[e]),n}let dt=function(e){let n=Zo(e);return qe.useCallback((...s)=>n.current(...s),[n])};function ZR(e){let n=e.width/2,s=e.height/2;return{top:e.clientY-s,right:e.clientX+n,bottom:e.clientY+s,left:e.clientX-n}}function eA(e,n){return!(!e||!n||e.right<n.left||e.left>n.right||e.bottom<n.top||e.top>n.bottom)}function tA({disabled:e=!1}={}){let n=p.useRef(null),[s,r]=p.useState(!1),a=Xo(),i=dt(()=>{n.current=null,r(!1),a.dispose()}),c=dt(d=>{if(a.dispose(),n.current===null){n.current=d.currentTarget,r(!0);{let u=vl(d.currentTarget);a.addEventListener(u,"pointerup",i,!1),a.addEventListener(u,"pointermove",f=>{if(n.current){let g=ZR(f);r(eA(g,n.current.getBoundingClientRect()))}},!1),a.addEventListener(u,"pointercancel",i,!1)}}});return{pressed:s,pressProps:e?{}:{onPointerDown:c,onPointerUp:i,onClick:i}}}function Ks(e){return p.useMemo(()=>e,Object.values(e))}let nA=p.createContext(void 0);function Xx(){return p.useContext(nA)}function Lg(...e){return Array.from(new Set(e.flatMap(n=>typeof n=="string"?n.split(" "):[]))).filter(Boolean).join(" ")}function es(e,n,...s){if(e in n){let a=n[e];return typeof a=="function"?a(...s):a}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(n).map(a=>`"${a}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,es),r}var ol=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(ol||{}),zo=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(zo||{});function Cn(){let e=rA();return p.useCallback(n=>sA({mergeRefs:e,...n}),[e])}function sA({ourProps:e,theirProps:n,slot:s,defaultTag:r,features:a,visible:i=!0,name:c,mergeRefs:d}){d=d??oA;let u=e1(n,e);if(i)return Au(u,s,r,c,d);let f=a??0;if(f&2){let{static:g=!1,...b}=u;if(g)return Au(b,s,r,c,d)}if(f&1){let{unmount:g=!0,...b}=u;return es(g?0:1,{0(){return null},1(){return Au({...b,hidden:!0,style:{display:"none"}},s,r,c,d)}})}return Au(u,s,r,c,d)}function Au(e,n={},s,r,a){let{as:i=s,children:c,refName:d="ref",...u}=Hp(e,["unmount","static"]),f=e.ref!==void 0?{[d]:e.ref}:{},g=typeof c=="function"?c(n):c;g=n1(g),"className"in u&&u.className&&typeof u.className=="function"&&(u.className=u.className(n)),u["aria-labelledby"]&&u["aria-labelledby"]===u.id&&(u["aria-labelledby"]=void 0);let b={};if(n){let x=!1,h=[];for(let[v,y]of Object.entries(n))typeof y=="boolean"&&(x=!0),y===!0&&h.push(v.replace(/([A-Z])/g,j=>`-${j.toLowerCase()}`));if(x){b["data-headlessui-state"]=h.join(" ");for(let v of h)b[`data-${v}`]=""}}if(Cc(i)&&(Object.keys(Lo(u)).length>0||Object.keys(Lo(b)).length>0))if(!p.isValidElement(g)||Array.isArray(g)&&g.length>1||iA(g)){if(Object.keys(Lo(u)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(Lo(u)).concat(Object.keys(Lo(b))).map(x=>` - ${x}`).join(`
|
|
506
|
+
`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(x=>` - ${x}`).join(`
|
|
507
|
+
`)].join(`
|
|
508
|
+
`))}else{let x=g.props,h=x==null?void 0:x.className,v=typeof h=="function"?(...k)=>Lg(h(...k),u.className):Lg(h,u.className),y=v?{className:v}:{},j=e1(g.props,Lo(Hp(u,["ref"])));for(let k in b)k in j&&delete b[k];return p.cloneElement(g,Object.assign({},j,b,f,{ref:a(aA(g),f.ref)},y))}return p.createElement(i,Object.assign({},Hp(u,["ref"]),!Cc(i)&&f,!Cc(i)&&b),g)}function rA(){let e=p.useRef([]),n=p.useCallback(s=>{for(let r of e.current)r!=null&&(typeof r=="function"?r(s):r.current=s)},[]);return(...s)=>{if(!s.every(r=>r==null))return e.current=s,n}}function oA(...e){return e.every(n=>n==null)?void 0:n=>{for(let s of e)s!=null&&(typeof s=="function"?s(n):s.current=n)}}function e1(...e){if(e.length===0)return{};if(e.length===1)return e[0];let n={},s={};for(let r of e)for(let a in r)a.startsWith("on")&&typeof r[a]=="function"?(s[a]!=null||(s[a]=[]),s[a].push(r[a])):n[a]=r[a];if(n.disabled||n["aria-disabled"])for(let r in s)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(s[r]=[a=>{var i;return(i=a==null?void 0:a.preventDefault)==null?void 0:i.call(a)}]);for(let r in s)Object.assign(n,{[r](a,...i){let c=s[r];for(let d of c){if((a instanceof Event||(a==null?void 0:a.nativeEvent)instanceof Event)&&a.defaultPrevented)return;d(a,...i)}}});return n}function t1(...e){if(e.length===0)return{};if(e.length===1)return e[0];let n={},s={};for(let r of e)for(let a in r)a.startsWith("on")&&typeof r[a]=="function"?(s[a]!=null||(s[a]=[]),s[a].push(r[a])):n[a]=r[a];for(let r in s)Object.assign(n,{[r](...a){let i=s[r];for(let c of i)c==null||c(...a)}});return n}function gn(e){var n;return Object.assign(p.forwardRef(e),{displayName:(n=e.displayName)!=null?n:e.name})}function Lo(e){let n=Object.assign({},e);for(let s in n)n[s]===void 0&&delete n[s];return n}function Hp(e,n=[]){let s=Object.assign({},e);for(let r of n)r in s&&delete s[r];return s}function aA(e){return qe.version.split(".")[0]>="19"?e.props.ref:e.ref}function n1(e){if(e!=null&&e.$$typeof===Symbol.for("react.lazy")){let n=e._payload;if(n!=null&&n.status==="fulfilled")return n1(n.value)}return e}function Cc(e){return e===p.Fragment||e===Symbol.for("react.fragment")}function iA(e){return Cc(e.type)}function lA(e,n,s){let[r,a]=p.useState(s),i=e!==void 0,c=p.useRef(i),d=p.useRef(!1),u=p.useRef(!1);return i&&!c.current&&!d.current?(d.current=!0,c.current=i,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!i&&c.current&&!u.current&&(u.current=!0,c.current=i,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[i?e:r,dt(f=>(i||ks.flushSync(()=>a(f)),n==null?void 0:n(f)))]}function cA(e){let[n]=p.useState(e);return n}function s1(e={},n=null,s=[]){for(let[r,a]of Object.entries(e))o1(s,r1(n,r),a);return s}function r1(e,n){return e?e+"["+n+"]":n}function o1(e,n,s){if(Array.isArray(s))for(let[r,a]of s.entries())o1(e,r1(n,r.toString()),a);else s instanceof Date?e.push([n,s.toISOString()]):typeof s=="boolean"?e.push([n,s?"1":"0"]):typeof s=="string"?e.push([n,s]):typeof s=="number"?e.push([n,`${s}`]):s==null?e.push([n,""]):uA(s)&&!p.isValidElement(s)&&s1(s,n,e)}function dA(e){var n,s;let r=(n=e==null?void 0:e.form)!=null?n:e.closest("form");if(r){for(let a of r.elements)if(a!==e&&(a.tagName==="INPUT"&&a.type==="submit"||a.tagName==="BUTTON"&&a.type==="submit"||a.nodeName==="INPUT"&&a.type==="image")){a.click();return}(s=r.requestSubmit)==null||s.call(r)}}function uA(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}let fA="span";var al=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(al||{});function mA(e,n){var s;let{features:r=1,...a}=e,i={ref:n,"aria-hidden":(r&2)===2?!0:(s=a["aria-hidden"])!=null?s:void 0,hidden:(r&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(r&4)===4&&(r&2)!==2&&{display:"none"}}};return Cn()({ourProps:i,theirProps:a,slot:{},defaultTag:fA,name:"Hidden"})}let Pc=gn(mA),hA=p.createContext(null);function pA({children:e}){let n=p.useContext(hA);if(!n)return qe.createElement(qe.Fragment,null,e);let{target:s}=n;return s?ks.createPortal(qe.createElement(qe.Fragment,null,e),s):null}function gA({data:e,form:n,disabled:s,onReset:r,overrides:a}){let[i,c]=p.useState(null),d=Xo();return p.useEffect(()=>{if(r&&i)return d.addEventListener(i,"reset",r)},[i,n,r]),qe.createElement(pA,null,qe.createElement(xA,{setForm:c,formId:n}),s1(e).map(([u,f])=>qe.createElement(Pc,{features:al.Hidden,...Lo({key:u,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:n,disabled:s,name:u,value:f,...a})})))}function xA({setForm:e,formId:n}){return p.useEffect(()=>{if(n){let s=document.getElementById(n);s&&e(s)}},[e,n]),n?null:qe.createElement(Pc,{features:al.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:s=>{if(!s)return;let r=s.closest("form");r&&e(r)}})}let vA=p.createContext(void 0);function a1(){return p.useContext(vA)}function i1(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function Qr(e){return i1(e)&&"tagName"in e}function Ns(e){return Qr(e)&&"accessKey"in e}function Kr(e){return Qr(e)&&"tabIndex"in e}function yA(e){return Qr(e)&&"style"in e}function bA(e){return Ns(e)&&e.nodeName==="IFRAME"}function l1(e){return Ns(e)&&e.nodeName==="INPUT"}function dj(e){return Ns(e)&&e.nodeName==="LABEL"}function wA(e){return Ns(e)&&e.nodeName==="FIELDSET"}function c1(e){return Ns(e)&&e.nodeName==="LEGEND"}function jA(e){return Qr(e)?e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]'):!1}function uj(e){let n=e.parentElement,s=null;for(;n&&!wA(n);)c1(n)&&(s=n),n=n.parentElement;let r=(n==null?void 0:n.getAttribute("disabled"))==="";return r&&kA(s)?!1:r}function kA(e){if(!e)return!1;let n=e.previousElementSibling;for(;n!==null;){if(c1(n))return!1;n=n.previousElementSibling}return!0}let d1=Symbol();function NA(e,n=!0){return Object.assign(e,{[d1]:n})}function Dn(...e){let n=p.useRef(e);p.useEffect(()=>{n.current=e},[e]);let s=dt(r=>{for(let a of n.current)a!=null&&(typeof a=="function"?a(r):a.current=r)});return e.every(r=>r==null||(r==null?void 0:r[d1]))?void 0:s}let mm=p.createContext(null);mm.displayName="DescriptionContext";function u1(){let e=p.useContext(mm);if(e===null){let n=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(n,u1),n}return e}function SA(){var e,n;return(n=(e=p.useContext(mm))==null?void 0:e.value)!=null?n:void 0}function CA(){let[e,n]=p.useState([]);return[e.length>0?e.join(" "):void 0,p.useMemo(()=>function(s){let r=dt(i=>(n(c=>[...c,i]),()=>n(c=>{let d=c.slice(),u=d.indexOf(i);return u!==-1&&d.splice(u,1),d}))),a=p.useMemo(()=>({register:r,slot:s.slot,name:s.name,props:s.props,value:s.value}),[r,s.slot,s.name,s.props,s.value]);return qe.createElement(mm.Provider,{value:a},s.children)},[n])]}let EA="p";function $A(e,n){let s=p.useId(),r=Xx(),{id:a=`headlessui-description-${s}`,...i}=e,c=u1(),d=Dn(n);en(()=>c.register(a),[a,c.register]);let u=Ks({...c.slot,disabled:r||!1}),f={ref:d,...c.props,id:a};return Cn()({ourProps:f,theirProps:i,slot:u,defaultTag:EA,name:c.name||"Description"})}let _A=gn($A),f1=Object.assign(_A,{});var yn=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))(yn||{});let hm=p.createContext(null);hm.displayName="LabelContext";function m1(){let e=p.useContext(hm);if(e===null){let n=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(n,m1),n}return e}function h1(e){var n,s,r;let a=(s=(n=p.useContext(hm))==null?void 0:n.value)!=null?s:void 0;return((r=e==null?void 0:e.length)!=null?r:0)>0?[a,...e].filter(Boolean).join(" "):a}function TA({inherit:e=!1}={}){let n=h1(),[s,r]=p.useState([]),a=e?[n,...s].filter(Boolean):s;return[a.length>0?a.join(" "):void 0,p.useMemo(()=>function(i){let c=dt(u=>(r(f=>[...f,u]),()=>r(f=>{let g=f.slice(),b=g.indexOf(u);return b!==-1&&g.splice(b,1),g}))),d=p.useMemo(()=>({register:c,slot:i.slot,name:i.name,props:i.props,value:i.value}),[c,i.slot,i.name,i.props,i.value]);return qe.createElement(hm.Provider,{value:d},i.children)},[r])]}let RA="label";function AA(e,n){var s;let r=p.useId(),a=m1(),i=a1(),c=Xx(),{id:d=`headlessui-label-${r}`,htmlFor:u=i??((s=a.props)==null?void 0:s.htmlFor),passive:f=!1,...g}=e,b=Dn(n);en(()=>a.register(d),[d,a.register]);let x=dt(y=>{let j=y.currentTarget;if(!(y.target!==y.currentTarget&&jA(y.target))&&(dj(j)&&y.preventDefault(),a.props&&"onClick"in a.props&&typeof a.props.onClick=="function"&&a.props.onClick(y),dj(j))){let k=document.getElementById(j.htmlFor);if(k){let E=k.getAttribute("disabled");if(E==="true"||E==="")return;let S=k.getAttribute("aria-disabled");if(S==="true"||S==="")return;(l1(k)&&(k.type==="file"||k.type==="radio"||k.type==="checkbox")||k.role==="radio"||k.role==="checkbox"||k.role==="switch")&&k.click(),k.focus({preventScroll:!0})}}}),h=Ks({...a.slot,disabled:c||!1}),v={ref:b,...a.props,id:d,htmlFor:u,onClick:x};return f&&("onClick"in v&&(delete v.htmlFor,delete v.onClick),"onClick"in g&&delete g.onClick),Cn()({ourProps:v,theirProps:g,slot:h,defaultTag:u?RA:"div",name:a.name||"Label"})}let OA=gn(AA),MA=Object.assign(OA,{}),PA=p.createContext(()=>{});function LA({value:e,children:n}){return qe.createElement(PA.Provider,{value:e},n)}function IA(e,n){return e!==null&&n!==null&&typeof e=="object"&&typeof n=="object"&&"id"in e&&"id"in n?e.id===n.id:e===n}function zA(e=IA){return p.useCallback((n,s)=>{if(typeof e=="string"){let r=e;return(n==null?void 0:n[r])===(s==null?void 0:s[r])}return e(n,s)},[e])}function fj(e){if(e===null)return{width:0,height:0};let{width:n,height:s}=e.getBoundingClientRect();return{width:n,height:s}}function DA(e,n,s=!1){let[r,a]=p.useState(()=>fj(n));return en(()=>{if(!n||!e)return;let i=Es();return i.requestAnimationFrame(function c(){i.requestAnimationFrame(c),a(d=>{let u=fj(n);return u.width===d.width&&u.height===d.height?d:u})}),()=>{i.dispose()}},[n,e]),s?{width:`${r.width}px`,height:`${r.height}px`}:r}var p1=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(p1||{});function FA(e){let n=p.useRef(null),s=dt(a=>{n.current=a.pointerType,!uj(a.currentTarget)&&a.pointerType==="mouse"&&a.button===p1.Left&&(a.preventDefault(),e(a))}),r=dt(a=>{n.current!=="mouse"&&(uj(a.currentTarget)||e(a))});return{onPointerDown:s,onClick:r}}let g1=class extends Map{constructor(n){super(),this.factory=n}get(n){let s=super.get(n);return s===void 0&&(s=this.factory(n),this.set(n,s)),s}};var UA=Object.defineProperty,WA=(e,n,s)=>n in e?UA(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,HA=(e,n,s)=>(WA(e,n+"",s),s),x1=(e,n,s)=>{if(!n.has(e))throw TypeError("Cannot "+s)},Is=(e,n,s)=>(x1(e,n,"read from private field"),s?s.call(e):n.get(e)),Bp=(e,n,s)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,s)},mj=(e,n,s,r)=>(x1(e,n,"write to private field"),n.set(e,s),s),br,bc,wc;let v1=class{constructor(n){Bp(this,br,{}),Bp(this,bc,new g1(()=>new Set)),Bp(this,wc,new Set),HA(this,"disposables",Es()),mj(this,br,n),Nr.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return Is(this,br)}subscribe(n,s){if(Nr.isServer)return()=>{};let r={selector:n,callback:s,current:n(Is(this,br))};return Is(this,wc).add(r),this.disposables.add(()=>{Is(this,wc).delete(r)})}on(n,s){return Nr.isServer?()=>{}:(Is(this,bc).get(n).add(s),this.disposables.add(()=>{Is(this,bc).get(n).delete(s)}))}send(n){let s=this.reduce(Is(this,br),n);if(s!==Is(this,br)){mj(this,br,s);for(let r of Is(this,wc)){let a=r.selector(Is(this,br));y1(r.current,a)||(r.current=a,r.callback(a))}for(let r of Is(this,bc).get(n.type))r(Is(this,br),n)}}};br=new WeakMap,bc=new WeakMap,wc=new WeakMap;function y1(e,n){return Object.is(e,n)?!0:typeof e!="object"||e===null||typeof n!="object"||n===null?!1:Array.isArray(e)&&Array.isArray(n)?e.length!==n.length?!1:Gp(e[Symbol.iterator](),n[Symbol.iterator]()):e instanceof Map&&n instanceof Map||e instanceof Set&&n instanceof Set?e.size!==n.size?!1:Gp(e.entries(),n.entries()):hj(e)&&hj(n)?Gp(Object.entries(e)[Symbol.iterator](),Object.entries(n)[Symbol.iterator]()):!1}function Gp(e,n){do{let s=e.next(),r=n.next();if(s.done&&r.done)return!0;if(s.done||r.done||!Object.is(s.value,r.value))return!1}while(!0)}function hj(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}function qp(e){let[n,s]=e(),r=Es();return(...a)=>{n(...a),r.dispose(),r.microTask(s)}}var BA=Object.defineProperty,GA=(e,n,s)=>n in e?BA(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,pj=(e,n,s)=>(GA(e,typeof n!="symbol"?n+"":n,s),s),b1=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(b1||{});let qA={0(e,n){let s=n.id,r=e.stack,a=e.stack.indexOf(s);if(a!==-1){let i=e.stack.slice();return i.splice(a,1),i.push(s),r=i,{...e,stack:r}}return{...e,stack:[...e.stack,s]}},1(e,n){let s=n.id,r=e.stack.indexOf(s);if(r===-1)return e;let a=e.stack.slice();return a.splice(r,1),{...e,stack:a}}},KA=class w1 extends v1{constructor(){super(...arguments),pj(this,"actions",{push:n=>this.send({type:0,id:n}),pop:n=>this.send({type:1,id:n})}),pj(this,"selectors",{isTop:(n,s)=>n.stack[n.stack.length-1]===s,inStack:(n,s)=>n.stack.includes(s)})}static new(){return new w1({stack:[]})}reduce(n,s){return es(s.type,qA,n,s)}};const pm=new g1(()=>KA.new());var Kp={exports:{}},Vp={};/**
|
|
509
|
+
* @license React
|
|
510
|
+
* use-sync-external-store-with-selector.production.js
|
|
511
|
+
*
|
|
512
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
513
|
+
*
|
|
514
|
+
* This source code is licensed under the MIT license found in the
|
|
515
|
+
* LICENSE file in the root directory of this source tree.
|
|
516
|
+
*/var gj;function VA(){if(gj)return Vp;gj=1;var e=sm();function n(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var s=typeof Object.is=="function"?Object.is:n,r=e.useSyncExternalStore,a=e.useRef,i=e.useEffect,c=e.useMemo,d=e.useDebugValue;return Vp.useSyncExternalStoreWithSelector=function(u,f,g,b,x){var h=a(null);if(h.current===null){var v={hasValue:!1,value:null};h.current=v}else v=h.current;h=c(function(){function j(_){if(!k){if(k=!0,E=_,_=b(_),x!==void 0&&v.hasValue){var $=v.value;if(x($,_))return S=$}return S=_}if($=S,s(E,_))return $;var O=b(_);return x!==void 0&&x($,O)?(E=_,$):(E=_,S=O)}var k=!1,E,S,N=g===void 0?null:g;return[function(){return j(f())},N===null?void 0:function(){return j(N())}]},[f,g,b,x]);var y=r(u,h[0],h[1]);return i(function(){v.hasValue=!0,v.value=y},[y]),d(y),y},Vp}var xj;function YA(){return xj||(xj=1,Kp.exports=VA()),Kp.exports}var QA=YA();function Yn(e,n,s=y1){return QA.useSyncExternalStoreWithSelector(dt(r=>e.subscribe(JA,r)),dt(()=>e.state),dt(()=>e.state),dt(n),s)}function JA(e){return e}function Xc(e,n){let s=p.useId(),r=pm.get(n),[a,i]=Yn(r,p.useCallback(c=>[r.selectors.isTop(c,s),r.selectors.inStack(c,s)],[r,s]));return en(()=>{if(e)return r.actions.push(s),()=>r.actions.pop(s)},[r,e,s]),e?i?a:!0:!1}let Ig=new Map,Ec=new Map;function vj(e){var n;let s=(n=Ec.get(e))!=null?n:0;return Ec.set(e,s+1),s!==0?()=>yj(e):(Ig.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>yj(e))}function yj(e){var n;let s=(n=Ec.get(e))!=null?n:1;if(s===1?Ec.delete(e):Ec.set(e,s-1),s!==1)return;let r=Ig.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,Ig.delete(e))}function j1(e,{allowed:n,disallowed:s}={}){let r=Xc(e,"inert-others");en(()=>{var a,i;if(!r)return;let c=Es();for(let u of(a=s==null?void 0:s())!=null?a:[])u&&c.add(vj(u));let d=(i=n==null?void 0:n())!=null?i:[];for(let u of d){if(!u)continue;let f=vl(u);if(!f)continue;let g=u.parentElement;for(;g&&g!==f.body;){for(let b of g.children)d.some(x=>b.contains(x))||c.add(vj(b));g=g.parentElement}}return c.dispose},[r,n,s])}function k1(e,n,s){let r=Zo(a=>{let i=a.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&s()});p.useEffect(()=>{if(!e)return;let a=n===null?null:Ns(n)?n:n.current;if(!a)return;let i=Es();if(typeof ResizeObserver<"u"){let c=new ResizeObserver(()=>r.current(a));c.observe(a),i.add(()=>c.disconnect())}if(typeof IntersectionObserver<"u"){let c=new IntersectionObserver(()=>r.current(a));c.observe(a),i.add(()=>c.disconnect())}return()=>i.dispose()},[n,r,e])}let wf=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","details>summary","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(","),XA=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var ir=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e[e.AutoFocus=64]="AutoFocus",e))(ir||{}),zg=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(zg||{}),ZA=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(ZA||{});function N1(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(wf)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}function e3(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(XA)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}var Zx=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Zx||{});function S1(e,n=0){var s;return e===((s=vl(e))==null?void 0:s.body)?!1:es(n,{0(){return e.matches(wf)},1(){let r=e;for(;r!==null;){if(r.matches(wf))return!0;r=r.parentElement}return!1}})}var t3=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(t3||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function Jr(e){e==null||e.focus({preventScroll:!0})}let n3=["textarea","input"].join(",");function s3(e){var n,s;return(s=(n=e==null?void 0:e.matches)==null?void 0:n.call(e,n3))!=null?s:!1}function C1(e,n=s=>s){return e.slice().sort((s,r)=>{let a=n(s),i=n(r);if(a===null||i===null)return 0;let c=a.compareDocumentPosition(i);return c&Node.DOCUMENT_POSITION_FOLLOWING?-1:c&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function r3(e,n,s=e===null?document.body:bf(e)){return qi(N1(s),n,{relativeTo:e})}function qi(e,n,{sorted:s=!0,relativeTo:r=null,skipElements:a=[]}={}){let i=Array.isArray(e)?e.length>0?bf(e[0]):document:bf(e),c=Array.isArray(e)?s?C1(e):e:n&64?e3(e):N1(e);a.length>0&&c.length>1&&(c=c.filter(h=>!a.some(v=>v!=null&&"current"in v?(v==null?void 0:v.current)===h:v===h))),r=r??(i==null?void 0:i.activeElement);let d=(()=>{if(n&5)return 1;if(n&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),u=(()=>{if(n&1)return 0;if(n&2)return Math.max(0,c.indexOf(r))-1;if(n&4)return Math.max(0,c.indexOf(r))+1;if(n&8)return c.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),f=n&32?{preventScroll:!0}:{},g=0,b=c.length,x;do{if(g>=b||g+b<=0)return 0;let h=u+g;if(n&16)h=(h+b)%b;else{if(h<0)return 3;if(h>=b)return 1}x=c[h],x==null||x.focus(f),g+=d}while(x!==XN(x));return n&6&&s3(x)&&x.select(),2}function E1(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function o3(){return/Android/gi.test(window.navigator.userAgent)}function bj(){return E1()||o3()}function Di(e,n,s,r){let a=Zo(s);p.useEffect(()=>{if(!e)return;function i(c){a.current(c)}return document.addEventListener(n,i,r),()=>document.removeEventListener(n,i,r)},[e,n,r])}function $1(e,n,s,r){let a=Zo(s);p.useEffect(()=>{if(!e)return;function i(c){a.current(c)}return window.addEventListener(n,i,r),()=>window.removeEventListener(n,i,r)},[e,n,r])}const wj=30;function _1(e,n,s){let r=Zo(s),a=p.useCallback(function(d,u){if(d.defaultPrevented)return;let f=u(d);if(f===null||!f.getRootNode().contains(f)||!f.isConnected)return;let g=(function b(x){return typeof x=="function"?b(x()):Array.isArray(x)||x instanceof Set?x:[x]})(n);for(let b of g)if(b!==null&&(b.contains(f)||d.composed&&d.composedPath().includes(b)))return;return!S1(f,Zx.Loose)&&f.tabIndex!==-1&&d.preventDefault(),r.current(d,f)},[r,n]),i=p.useRef(null);Di(e,"pointerdown",d=>{var u,f;bj()||(i.current=((f=(u=d.composedPath)==null?void 0:u.call(d))==null?void 0:f[0])||d.target)},!0),Di(e,"pointerup",d=>{if(bj()||!i.current)return;let u=i.current;return i.current=null,a(d,()=>u)},!0);let c=p.useRef({x:0,y:0});Di(e,"touchstart",d=>{c.current.x=d.touches[0].clientX,c.current.y=d.touches[0].clientY},!0),Di(e,"touchend",d=>{let u={x:d.changedTouches[0].clientX,y:d.changedTouches[0].clientY};if(!(Math.abs(u.x-c.current.x)>=wj||Math.abs(u.y-c.current.y)>=wj))return a(d,()=>Kr(d.target)?d.target:null)},!0),$1(e,"blur",d=>a(d,()=>bA(window.document.activeElement)?window.document.activeElement:null),!0)}function Lc(...e){return p.useMemo(()=>vl(...e),[...e])}var a3=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(a3||{});const Ou={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},i3=200,jj=5;function l3(e,{trigger:n,action:s,close:r,select:a}){let i=p.useRef(null),c=p.useRef(null),d=p.useRef(null);Di(e&&n!==null,"pointerdown",u=>{i1(u==null?void 0:u.target)&&n!=null&&n.contains(u.target)&&(c.current=u.x,d.current=u.y,i.current=u.timeStamp)}),Di(e&&n!==null,"pointerup",u=>{var f,g;let b=i.current;if(b===null||(i.current=null,!Kr(u.target))||Math.abs(u.x-((f=c.current)!=null?f:u.x))<jj&&Math.abs(u.y-((g=d.current)!=null?g:u.y))<jj)return;let x=s(u);switch(x.kind){case 0:return;case 1:{u.timeStamp-b>i3&&(a(x.target),r());break}case 2:{r();break}}},{capture:!0})}function T1(e,n,s,r){let a=Zo(s);p.useEffect(()=>{e=e??window;function i(c){a.current(c)}return e.addEventListener(n,i,r),()=>e.removeEventListener(n,i,r)},[e,n,r])}function c3(e,n){return p.useMemo(()=>{var s;if(e.type)return e.type;let r=(s=e.as)!=null?s:"button";if(typeof r=="string"&&r.toLowerCase()==="button"||(n==null?void 0:n.tagName)==="BUTTON"&&!n.hasAttribute("type"))return"button"},[e.type,e.as,n])}function d3(e){return p.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function u3(e,n){let s=e(),r=new Set;return{getSnapshot(){return s},subscribe(a){return r.add(a),()=>r.delete(a)},dispatch(a,...i){let c=n[a].call(s,...i);c&&(s=c,r.forEach(d=>d()))}}}function f3(){let e;return{before({doc:n}){var s;let r=n.documentElement,a=(s=n.defaultView)!=null?s:window;e=Math.max(0,a.innerWidth-r.clientWidth)},after({doc:n,d:s}){let r=n.documentElement,a=Math.max(0,r.clientWidth-r.offsetWidth),i=Math.max(0,e-a);s.style(r,"paddingRight",`${i}px`)}}}function m3(){return E1()?{before({doc:e,d:n,meta:s}){function r(a){for(let i of s().containers)for(let c of i())if(c.contains(a))return!0;return!1}n.microTask(()=>{var a;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let d=Es();d.style(e.documentElement,"scrollBehavior","auto"),n.add(()=>n.microTask(()=>d.dispose()))}let i=(a=window.scrollY)!=null?a:window.pageYOffset,c=null;n.addEventListener(e,"click",d=>{if(Kr(d.target))try{let u=d.target.closest("a");if(!u)return;let{hash:f}=new URL(u.href),g=e.querySelector(f);Kr(g)&&!r(g)&&(c=g)}catch{}},!0),n.group(d=>{n.addEventListener(e,"touchstart",u=>{if(d.dispose(),Kr(u.target)&&yA(u.target))if(r(u.target)){let f=u.target;for(;f.parentElement&&r(f.parentElement);)f=f.parentElement;d.style(f,"overscrollBehavior","contain")}else d.style(u.target,"touchAction","none")})}),n.addEventListener(e,"touchmove",d=>{if(Kr(d.target)){if(l1(d.target))return;if(r(d.target)){let u=d.target;for(;u.parentElement&&u.dataset.headlessuiPortal!==""&&!(u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth);)u=u.parentElement;u.dataset.headlessuiPortal===""&&d.preventDefault()}else d.preventDefault()}},{passive:!1}),n.add(()=>{var d;let u=(d=window.scrollY)!=null?d:window.pageYOffset;i!==u&&window.scrollTo(0,i),c&&c.isConnected&&(c.scrollIntoView({block:"nearest"}),c=null)})})}}:{}}function h3(){return{before({doc:e,d:n}){n.style(e.documentElement,"overflow","hidden")}}}function kj(e){let n={};for(let s of e)Object.assign(n,s(n));return n}let Ta=u3(()=>new Map,{PUSH(e,n){var s;let r=(s=this.get(e))!=null?s:{doc:e,count:0,d:Es(),meta:new Set,computedMeta:{}};return r.count++,r.meta.add(n),r.computedMeta=kj(r.meta),this.set(e,r),this},POP(e,n){let s=this.get(e);return s&&(s.count--,s.meta.delete(n),s.computedMeta=kj(s.meta)),this},SCROLL_PREVENT(e){let n={doc:e.doc,d:e.d,meta(){return e.computedMeta}},s=[m3(),f3(),h3()];s.forEach(({before:r})=>r==null?void 0:r(n)),s.forEach(({after:r})=>r==null?void 0:r(n))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});Ta.subscribe(()=>{let e=Ta.getSnapshot(),n=new Map;for(let[s]of e)n.set(s,s.documentElement.style.overflow);for(let s of e.values()){let r=n.get(s.doc)==="hidden",a=s.count!==0;(a&&!r||!a&&r)&&Ta.dispatch(s.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",s),s.count===0&&Ta.dispatch("TEARDOWN",s)}});function p3(e,n,s=()=>({containers:[]})){let r=d3(Ta),a=n?r.get(n):void 0,i=a?a.count>0:!1;return en(()=>{if(!(!n||!e))return Ta.dispatch("PUSH",n,s),()=>Ta.dispatch("POP",n,s)},[e,n]),i}function R1(e,n,s=()=>[document.body]){let r=Xc(e,"scroll-lock");p3(r,n,a=>{var i;return{containers:[...(i=a.containers)!=null?i:[],s]}})}function Nj(e){return[e.screenX,e.screenY]}function g3(){let e=p.useRef([-1,-1]);return{wasMoved(n){let s=Nj(n);return e.current[0]===s[0]&&e.current[1]===s[1]?!1:(e.current=s,!0)},update(n){e.current=Nj(n)}}}function x3(e=0){let[n,s]=p.useState(e),r=p.useCallback(u=>s(u),[]),a=p.useCallback(u=>s(f=>f|u),[]),i=p.useCallback(u=>(n&u)===u,[n]),c=p.useCallback(u=>s(f=>f&~u),[]),d=p.useCallback(u=>s(f=>f^u),[]);return{flags:n,setFlag:r,addFlag:a,hasFlag:i,removeFlag:c,toggleFlag:d}}var v3={},Sj,Cj;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Sj=process==null?void 0:v3)==null?void 0:Sj.NODE_ENV)==="test"&&typeof((Cj=Element==null?void 0:Element.prototype)==null?void 0:Cj.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
|
|
517
|
+
`)),[]});var y3=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(y3||{});function A1(e){let n={};for(let s in e)e[s]===!0&&(n[`data-${s}`]="");return n}function O1(e,n,s,r){let[a,i]=p.useState(s),{hasFlag:c,addFlag:d,removeFlag:u}=x3(e&&a?3:0),f=p.useRef(!1),g=p.useRef(!1),b=Xo();return en(()=>{var x;if(e){if(s&&i(!0),!n){s&&d(3);return}return(x=r==null?void 0:r.start)==null||x.call(r,s),b3(n,{inFlight:f,prepare(){g.current?g.current=!1:g.current=f.current,f.current=!0,!g.current&&(s?(d(3),u(4)):(d(4),u(2)))},run(){g.current?s?(u(3),d(4)):(u(4),d(3)):s?u(1):d(1)},done(){var h;g.current&&k3(n)||(f.current=!1,u(7),s||i(!1),(h=r==null?void 0:r.end)==null||h.call(r,s))}})}},[e,s,n,b]),e?[a,{closed:c(1),enter:c(2),leave:c(4),transition:c(2)||c(4)}]:[s,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function b3(e,{prepare:n,run:s,done:r,inFlight:a}){let i=Es();return j3(e,{prepare:n,inFlight:a}),i.nextFrame(()=>{s(),i.requestAnimationFrame(()=>{i.add(w3(e,r))})}),i.dispose}function w3(e,n){var s,r;let a=Es();if(!e)return a.dispose;let i=!1;a.add(()=>{i=!0});let c=(r=(s=e.getAnimations)==null?void 0:s.call(e).filter(d=>d instanceof CSSTransition))!=null?r:[];return c.length===0?(n(),a.dispose):(Promise.allSettled(c.map(d=>d.finished)).then(()=>{i||n()}),a.dispose)}function j3(e,{inFlight:n,prepare:s}){if(n!=null&&n.current){s();return}let r=e.style.transition;e.style.transition="none",s(),e.offsetHeight,e.style.transition=r}function k3(e){var n,s;return((s=(n=e.getAnimations)==null?void 0:n.call(e))!=null?s:[]).some(r=>r instanceof CSSTransition&&r.playState!=="finished")}function ev(e,n){let s=p.useRef([]),r=dt(e);p.useEffect(()=>{let a=[...s.current];for(let[i,c]of n.entries())if(s.current[i]!==c){let d=r(n,a);return s.current=n,d}},[r,...n])}function gm(){return typeof window<"u"}function yl(e){return M1(e)?(e.nodeName||"").toLowerCase():"#document"}function fs(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function ao(e){var n;return(n=(M1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function M1(e){return gm()?e instanceof Node||e instanceof fs(e).Node:!1}function us(e){return gm()?e instanceof Element||e instanceof fs(e).Element:!1}function ea(e){return gm()?e instanceof HTMLElement||e instanceof fs(e).HTMLElement:!1}function Ej(e){return!gm()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof fs(e).ShadowRoot}function xm(e){const{overflow:n,overflowX:s,overflowY:r,display:a}=Er(e);return/auto|scroll|overlay|hidden|clip/.test(n+r+s)&&a!=="inline"&&a!=="contents"}function N3(e){return/^(table|td|th)$/.test(yl(e))}function vm(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const S3=/transform|translate|scale|rotate|perspective|filter/,C3=/paint|layout|strict|content/,wa=e=>!!e&&e!=="none";let Yp;function tv(e){const n=us(e)?Er(e):e;return wa(n.transform)||wa(n.translate)||wa(n.scale)||wa(n.rotate)||wa(n.perspective)||!nv()&&(wa(n.backdropFilter)||wa(n.filter))||S3.test(n.willChange||"")||C3.test(n.contain||"")}function E3(e){let n=Ia(e);for(;ea(n)&&!Ic(n);){if(tv(n))return n;if(vm(n))return null;n=Ia(n)}return null}function nv(){return Yp==null&&(Yp=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Yp}function Ic(e){return/^(html|body|#document)$/.test(yl(e))}function Er(e){return fs(e).getComputedStyle(e)}function ym(e){return us(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ia(e){if(yl(e)==="html")return e;const n=e.assignedSlot||e.parentNode||Ej(e)&&e.host||ao(e);return Ej(n)?n.host:n}function P1(e){const n=Ia(e);return Ic(n)?(e.ownerDocument||e).body:ea(n)&&xm(n)?n:P1(n)}function zc(e,n,s){var r;n===void 0&&(n=[]),s===void 0&&(s=!0);const a=P1(e),i=a===((r=e.ownerDocument)==null?void 0:r.body),c=fs(a);if(i){const d=Dg(c);return n.concat(c,c.visualViewport||[],xm(a)?a:[],d&&s?zc(d):[])}else return n.concat(a,zc(a,[],s))}function Dg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function $3(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(n=>{let{brand:s,version:r}=n;return s+"/"+r}).join(" "):navigator.userAgent}const za=Math.min,Hs=Math.max,Dc=Math.round,Mu=Math.floor,Xr=e=>({x:e,y:e}),_3={left:"right",right:"left",bottom:"top",top:"bottom"};function T3(e,n,s){return Hs(e,za(n,s))}function bl(e,n){return typeof e=="function"?e(n):e}function Da(e){return e.split("-")[0]}function Zc(e){return e.split("-")[1]}function L1(e){return e==="x"?"y":"x"}function I1(e){return e==="y"?"height":"width"}function Vr(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function z1(e){return L1(Vr(e))}function R3(e,n,s){s===void 0&&(s=!1);const r=Zc(e),a=z1(e),i=I1(a);let c=a==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return n.reference[i]>n.floating[i]&&(c=jf(c)),[c,jf(c)]}function A3(e){const n=jf(e);return[Fg(e),n,Fg(n)]}function Fg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const $j=["left","right"],_j=["right","left"],O3=["top","bottom"],M3=["bottom","top"];function P3(e,n,s){switch(e){case"top":case"bottom":return s?n?_j:$j:n?$j:_j;case"left":case"right":return n?O3:M3;default:return[]}}function L3(e,n,s,r){const a=Zc(e);let i=P3(Da(e),s==="start",r);return a&&(i=i.map(c=>c+"-"+a),n&&(i=i.concat(i.map(Fg)))),i}function jf(e){const n=Da(e);return _3[n]+e.slice(n.length)}function I3(e){var n,s,r,a;return{top:(n=e.top)!=null?n:0,right:(s=e.right)!=null?s:0,bottom:(r=e.bottom)!=null?r:0,left:(a=e.left)!=null?a:0}}function z3(e){return typeof e!="number"?I3(e):{top:e,right:e,bottom:e,left:e}}function kf(e){const{x:n,y:s,width:r,height:a}=e;return{width:r,height:a,top:s,left:n,right:n+r,bottom:s+a,x:n,y:s}}function Tj(e,n,s){let{reference:r,floating:a}=e;const i=Vr(n),c=z1(n),d=I1(c),u=Da(n),f=i==="y",g=r.x+r.width/2-a.width/2,b=r.y+r.height/2-a.height/2,x=r[d]/2-a[d]/2;let h;switch(u){case"top":h={x:g,y:r.y-a.height};break;case"bottom":h={x:g,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:b};break;case"left":h={x:r.x-a.width,y:b};break;default:h={x:r.x,y:r.y}}const v=Zc(n);return v&&(h[c]+=x*(v==="end"?1:-1)*(s&&f?-1:1)),h}async function D1(e,n){var s;n===void 0&&(n={});const{x:r,y:a,platform:i,rects:c,elements:d,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:g="viewport",elementContext:b="floating",altBoundary:x=!1,padding:h=0}=bl(n,e),v=z3(h),j=d[x?b==="floating"?"reference":"floating":b],k=kf(await i.getClippingRect({element:(s=await(i.isElement==null?void 0:i.isElement(j)))==null||s?j:j.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(d.floating)),boundary:f,rootBoundary:g,strategy:u})),E=b==="floating"?{x:r,y:a,width:c.floating.width,height:c.floating.height}:c.reference,S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d.floating)),N=await(i.isElement==null?void 0:i.isElement(S))&&await(i.getScale==null?void 0:i.getScale(S))||{x:1,y:1},_=kf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:E,offsetParent:S,strategy:u}):E);return{top:(k.top-_.top+v.top)/N.y,bottom:(_.bottom-k.bottom+v.bottom)/N.y,left:(k.left-_.left+v.left)/N.x,right:(_.right-k.right+v.right)/N.x}}const D3=50,F3=async(e,n,s)=>{const{placement:r="bottom",strategy:a="absolute",middleware:i=[],platform:c}=s,d=c.detectOverflow?c:{...c,detectOverflow:D1},u=await(c.isRTL==null?void 0:c.isRTL(n));let f=await c.getElementRects({reference:e,floating:n,strategy:a}),{x:g,y:b}=Tj(f,r,u),x=r,h=0;const v={};for(let y=0;y<i.length;y++){const j=i[y];if(!j)continue;const{name:k,fn:E}=j,{x:S,y:N,data:_,reset:$}=await E({x:g,y:b,initialPlacement:r,placement:x,strategy:a,middlewareData:v,rects:f,platform:d,elements:{reference:e,floating:n}});g=S??g,b=N??b,v[k]={...v[k],..._},$&&h<D3&&(h++,typeof $=="object"&&($.placement&&(x=$.placement),$.rects&&(f=$.rects===!0?await c.getElementRects({reference:e,floating:n,strategy:a}):$.rects),{x:g,y:b}=Tj(f,x,u)),y=-1)}return{x:g,y:b,placement:x,strategy:a,middlewareData:v}},U3=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var s,r;const{placement:a,middlewareData:i,rects:c,initialPlacement:d,platform:u,elements:f}=n,{mainAxis:g=!0,crossAxis:b=!0,fallbackPlacements:x,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:y=!0,...j}=bl(e,n);if((s=i.arrow)!=null&&s.alignmentOffset)return{};const k=Da(a),E=Vr(d),S=Da(d)===d,N=await(u.isRTL==null?void 0:u.isRTL(f.floating)),_=x||(S||!y?[jf(d)]:A3(d)),$=v!=="none";!x&&$&&_.push(...L3(d,y,v,N));const O=[d,..._],A=await u.detectOverflow(n,j),L=[];let M=((r=i.flip)==null?void 0:r.overflows)||[];if(g&&L.push(A[k]),b){const W=R3(a,c,N);L.push(A[W[0]],A[W[1]])}if(M=[...M,{placement:a,overflows:L}],!L.every(W=>W<=0)){var R,P;const W=(((R=i.flip)==null?void 0:R.index)||0)+1,Y=O[W];if(Y&&(!(b==="alignment"?E!==Vr(Y):!1)||M.every(F=>Vr(F.placement)===E?F.overflows[0]>0:!0)))return{data:{index:W,overflows:M},reset:{placement:Y}};let H=(P=M.filter(q=>q.overflows[0]<=0).sort((q,F)=>q.overflows[1]-F.overflows[1])[0])==null?void 0:P.placement;if(!H)switch(h){case"bestFit":{var D;const q=(D=M.filter(F=>{if($){const G=Vr(F.placement);return G===E||G==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(G=>G>0).reduce((G,U)=>G+U,0)]).sort((F,G)=>F[1]-G[1])[0])==null?void 0:D[0];q&&(H=q);break}case"initialPlacement":H=d;break}if(a!==H)return{reset:{placement:H}}}return{}}}},W3=new Set(["left","top"]);async function H3(e,n){const{placement:s,platform:r,elements:a}=e,i=await(r.isRTL==null?void 0:r.isRTL(a.floating)),c=Da(s),d=Zc(s),u=Vr(s)==="y",f=W3.has(c)?-1:1,g=i&&u?-1:1,b=bl(n,e);let{mainAxis:x,crossAxis:h,alignmentAxis:v}=typeof b=="number"?{mainAxis:b,crossAxis:0,alignmentAxis:null}:{mainAxis:b.mainAxis||0,crossAxis:b.crossAxis||0,alignmentAxis:b.alignmentAxis};return d&&typeof v=="number"&&(h=d==="end"?v*-1:v),u?{x:h*g,y:x*f}:{x:x*f,y:h*g}}const B3=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var s,r;const{x:a,y:i,placement:c,middlewareData:d}=n,u=await H3(n,e);return c===((s=d.offset)==null?void 0:s.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:a+u.x,y:i+u.y,data:{...u,placement:c}}}}},G3=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:s,y:r,placement:a,platform:i}=n,{mainAxis:c=!0,crossAxis:d=!1,limiter:u={fn:E=>{let{x:S,y:N}=E;return{x:S,y:N}}},...f}=bl(e,n),g={x:s,y:r},b=await i.detectOverflow(n,f),x=Vr(a),h=L1(x);let v=g[h],y=g[x];const j=(E,S)=>T3(S+b[E==="y"?"top":"left"],S,S-b[E==="y"?"bottom":"right"]);c&&(v=j(h,v)),d&&(y=j(x,y));const k=u.fn({...n,[h]:v,[x]:y});return{...k,data:{x:k.x-s,y:k.y-r,enabled:{[h]:c,[x]:d}}}}}},q3=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){const{placement:s,rects:r,platform:a,elements:i}=n,{apply:c=()=>{},...d}=bl(e,n),u=await a.detectOverflow(n,d),f=Da(s),g=Zc(s),b=Vr(s)==="y",{width:x,height:h}=r.floating;let v,y;f==="top"||f==="bottom"?(v=f,y=g===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(y=f,v=g==="end"?"top":"bottom");const j=h-u.top-u.bottom,k=x-u.left-u.right,E=za(h-u[v],j),S=za(x-u[y],k),N=n.middlewareData.shift,_=!N;let $=E,O=S;N!=null&&N.enabled.x&&(O=k),N!=null&&N.enabled.y&&($=j),_&&!g&&(b?O=x-2*Hs(u.left,u.right):$=h-2*Hs(u.top,u.bottom)),await c({...n,availableWidth:O,availableHeight:$});const A=await a.getDimensions(i.floating);return x!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function F1(e){const n=Er(e);let s=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const a=ea(e),i=a?e.offsetWidth:s,c=a?e.offsetHeight:r,d=Dc(s)!==i||Dc(r)!==c;return d&&(s=i,r=c),{width:s,height:r,$:d}}function sv(e){return us(e)?e:e.contextElement}function Ki(e){const n=sv(e);if(!ea(n))return Xr(1);const s=n.getBoundingClientRect(),{width:r,height:a,$:i}=F1(n);let c=(i?Dc(s.width):s.width)/r,d=(i?Dc(s.height):s.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const K3=Xr(0);function U1(e){const n=fs(e);return!nv()||!n.visualViewport?K3:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function V3(e,n,s){return n===void 0&&(n=!1),!!s&&n&&s===fs(e)}function Fa(e,n,s,r){n===void 0&&(n=!1),s===void 0&&(s=!1);const a=e.getBoundingClientRect(),i=sv(e);let c=Xr(1);n&&(r?us(r)&&(c=Ki(r)):c=Ki(e));const d=V3(i,s,r)?U1(i):Xr(0);let u=(a.left+d.x)/c.x,f=(a.top+d.y)/c.y,g=a.width/c.x,b=a.height/c.y;if(i&&r){const x=fs(i),h=us(r)?fs(r):r;let v=x,y=Dg(v);for(;y&&h!==v;){const j=Ki(y),k=y.getBoundingClientRect(),E=Er(y),S=k.left+(y.clientLeft+parseFloat(E.paddingLeft))*j.x,N=k.top+(y.clientTop+parseFloat(E.paddingTop))*j.y;u*=j.x,f*=j.y,g*=j.x,b*=j.y,u+=S,f+=N,v=fs(y),y=Dg(v)}}return kf({width:g,height:b,x:u,y:f})}function bm(e,n){const s=ym(e).scrollLeft;return n?n.left+s:Fa(ao(e)).left+s}function W1(e,n){const s=e.getBoundingClientRect(),r=s.left+n.scrollLeft-bm(e,s),a=s.top+n.scrollTop;return{x:r,y:a}}function Y3(e){let{elements:n,rect:s,offsetParent:r,strategy:a}=e;const i=a==="fixed",c=ao(r),d=n?vm(n.floating):!1;if(r===c||d&&i)return s;let u={scrollLeft:0,scrollTop:0},f=Xr(1);const g=Xr(0),b=ea(r);if((b||!i)&&((yl(r)!=="body"||xm(c))&&(u=ym(r)),b)){const h=Fa(r);f=Ki(r),g.x=h.x+r.clientLeft,g.y=h.y+r.clientTop}const x=c&&!b&&!i?W1(c,u):Xr(0);return{width:s.width*f.x,height:s.height*f.y,x:s.x*f.x-u.scrollLeft*f.x+g.x+x.x,y:s.y*f.y-u.scrollTop*f.y+g.y+x.y}}function Q3(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function J3(e){const n=ym(e),s=e.ownerDocument.body,r=Hs(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),a=Hs(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+bm(e);const c=-n.scrollTop;return Er(s).direction==="rtl"&&(i+=Hs(e.clientWidth,s.clientWidth)-r),{width:r,height:a,x:i,y:c}}const X3=25;function Z3(e,n,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",a=fs(e),i=ao(e),c=a.visualViewport;let d=i.clientWidth,u=i.clientHeight,f=0,g=0;if(c){const x=!nv()||n==="fixed";r?x||(f=-c.offsetLeft,g=-c.offsetTop):(d=c.width,u=c.height,x&&(f=c.offsetLeft,g=c.offsetTop))}if(bm(i)<=0){const x=i.ownerDocument,h=x.body,v=getComputedStyle(h),y=x.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,j=Math.abs(i.clientWidth-h.clientWidth-y),k=getComputedStyle(i).scrollbarGutter==="stable both-edges"?j/2:j;k<=X3&&(d-=k)}return{width:d,height:u,x:f,y:g}}function e4(e,n){const s=Fa(e,!0,n==="fixed"),r=s.top+e.clientTop,a=s.left+e.clientLeft,i=Ki(e),c=e.clientWidth*i.x,d=e.clientHeight*i.y,u=a*i.x,f=r*i.y;return{width:c,height:d,x:u,y:f}}function Rj(e,n,s){let r;if(n==="viewport"||n==="layoutViewport")r=Z3(e,s,n);else if(n==="document")r=J3(ao(e));else if(us(n))r=e4(n,s);else{const a=U1(e);r={x:n.x-a.x,y:n.y-a.y,width:n.width,height:n.height}}return kf(r)}function t4(e,n){const s=n.get(e);if(s)return s;let r=zc(e,[],!1).filter(d=>us(d)&&yl(d)!=="body"),a=null;const i=Er(e).position==="fixed";let c=i?Ia(e):e;for(;us(c)&&!Ic(c);){const d=Er(c),u=tv(c),f=a?a.position:i?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&d.position==="static")?r=r.filter(b=>b!==c):a=d,c=Ia(c)}return n.set(e,r),r}function n4(e){let{element:n,boundary:s,rootBoundary:r,strategy:a}=e;const c=[...s==="clippingAncestors"?vm(n)?[]:t4(n,this._c):[].concat(s),r],d=Rj(n,c[0],a);let u=d.top,f=d.right,g=d.bottom,b=d.left;for(let x=1;x<c.length;x++){const h=Rj(n,c[x],a);u=Hs(h.top,u),f=za(h.right,f),g=za(h.bottom,g),b=Hs(h.left,b)}return{width:f-b,height:g-u,x:b,y:u}}function s4(e){const{width:n,height:s}=F1(e);return{width:n,height:s}}function r4(e,n,s){const r=ea(n),a=ao(n),i=s==="fixed",c=Fa(e,!0,i,n);let d={scrollLeft:0,scrollTop:0};const u=Xr(0);if((r||!i)&&((yl(n)!=="body"||xm(a))&&(d=ym(n)),r)){const x=Fa(n,!0,i,n);u.x=x.x+n.clientLeft,u.y=x.y+n.clientTop}!r&&a&&(u.x=bm(a));const f=a&&!r&&!i?W1(a,d):Xr(0),g=c.left+d.scrollLeft-u.x-f.x,b=c.top+d.scrollTop-u.y-f.y;return{x:g,y:b,width:c.width,height:c.height}}function Qp(e){return Er(e).position==="static"}function Aj(e,n){if(!ea(e)||Er(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return ao(e)===s&&(s=s.ownerDocument.body),s}function H1(e,n){const s=fs(e);if(vm(e))return s;if(!ea(e)){let a=Ia(e);for(;a&&!Ic(a);){if(us(a)&&!Qp(a))return a;a=Ia(a)}return s}let r=Aj(e,n);for(;r&&N3(r)&&Qp(r);)r=Aj(r,n);return r&&Ic(r)&&Qp(r)&&!tv(r)?s:r||E3(e)||s}const o4=async function(e){const n=this.getOffsetParent||H1,s=this.getDimensions,r=await s(e.floating);return{reference:r4(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function a4(e){return Er(e).direction==="rtl"}const i4={convertOffsetParentRelativeRectToViewportRelativeRect:Y3,getDocumentElement:ao,getClippingRect:n4,getOffsetParent:H1,getElementRects:o4,getClientRects:Q3,getDimensions:s4,getScale:Ki,isElement:us,isRTL:a4};function B1(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function l4(e,n,s){let r=null,a;const i=ao(e);function c(){var g;clearTimeout(a),(g=r)==null||g.disconnect(),r=null}function d(g,b){g===void 0&&(g=!1),b===void 0&&(b=1),c();const x=e.getBoundingClientRect(),{left:h,top:v,width:y,height:j}=x;if(g||n(),!y||!j)return;const k=Mu(v),E=Mu(i.clientWidth-(h+y)),S=Mu(i.clientHeight-(v+j)),N=Mu(h),$={rootMargin:-k+"px "+-E+"px "+-S+"px "+-N+"px",threshold:Hs(0,za(1,b))||1};let O=!0;function A(L){const M=L[0].intersectionRatio;if(!B1(x,e.getBoundingClientRect()))return d();if(M!==b){if(!O)return d();M?d(!1,M):a=setTimeout(()=>{d(!1,1e-7)},1e3)}O=!1}try{r=new IntersectionObserver(A,{...$,root:i.ownerDocument})}catch{r=new IntersectionObserver(A,$)}r.observe(e)}const u=fs(e),f=()=>d(s);return u.addEventListener("resize",f),d(!0),()=>{u.removeEventListener("resize",f),c()}}function c4(e,n,s,r){r===void 0&&(r={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=sv(e),g=a||i?[...f?zc(f):[],...n?zc(n):[]]:[];g.forEach(k=>{a&&k.addEventListener("scroll",s),i&&k.addEventListener("resize",s)});const b=f&&d?l4(f,s,i):null;let x=-1,h=null;c&&(h=new ResizeObserver(k=>{let[E]=k;E&&E.target===f&&h&&n&&(h.unobserve(n),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var S;(S=h)==null||S.observe(n)})),s()}),f&&!u&&h.observe(f),n&&h.observe(n));let v,y=u?Fa(e):null;u&&j();function j(){const k=Fa(e);y&&!B1(y,k)&&s(),y=k,v=requestAnimationFrame(j)}return s(),()=>{var k;g.forEach(E=>{a&&E.removeEventListener("scroll",s),i&&E.removeEventListener("resize",s)}),b==null||b(),(k=h)==null||k.disconnect(),h=null,u&&cancelAnimationFrame(v)}}const Jp=D1,d4=B3,u4=G3,f4=U3,m4=q3,h4=(e,n,s)=>{const r=new Map,a=s??{},i={...i4,...a.platform,_c:r};return F3(e,n,{...a,platform:i})};var p4=typeof document<"u",g4=function(){},rf=p4?p.useLayoutEffect:g4;function Nf(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let s,r,a;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==n.length)return!1;for(r=s;r--!==0;)if(!Nf(e[r],n[r]))return!1;return!0}if(a=Object.keys(e),s=a.length,s!==Object.keys(n).length)return!1;for(r=s;r--!==0;)if(!{}.hasOwnProperty.call(n,a[r]))return!1;for(r=s;r--!==0;){const i=a[r];if(!(i==="_owner"&&e.$$typeof)&&!Nf(e[i],n[i]))return!1}return!0}return e!==e&&n!==n}function G1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Oj(e,n){const s=G1(e);return Math.round(n*s)/s}function Xp(e){const n=p.useRef(e);return rf(()=>{n.current=e}),n}function x4(e){e===void 0&&(e={});const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:a,elements:{reference:i,floating:c}={},transform:d=!0,whileElementsMounted:u,open:f}=e,[g,b]=p.useState({x:0,y:0,strategy:s,placement:n,middlewareData:{},isPositioned:!1}),[x,h]=p.useState(r);Nf(x,r)||h(r);const[v,y]=p.useState(null),[j,k]=p.useState(null),E=p.useCallback(F=>{F!==$.current&&($.current=F,y(F))},[]),S=p.useCallback(F=>{F!==O.current&&(O.current=F,k(F))},[]),N=i||v,_=c||j,$=p.useRef(null),O=p.useRef(null),A=p.useRef(g),L=u!=null,M=Xp(u),R=Xp(a),P=Xp(f),D=p.useCallback(()=>{if(!$.current||!O.current)return;const F={placement:n,strategy:s,middleware:x};R.current&&(F.platform=R.current),h4($.current,O.current,F).then(G=>{const U={...G,isPositioned:P.current!==!1};W.current&&!Nf(A.current,U)&&(A.current=U,ks.flushSync(()=>{b(U)}))})},[x,n,s,R,P]);rf(()=>{f===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,b(F=>({...F,isPositioned:!1})))},[f]);const W=p.useRef(!1);rf(()=>(W.current=!0,()=>{W.current=!1}),[]),rf(()=>{if(N&&($.current=N),_&&(O.current=_),N&&_){if(M.current)return M.current(N,_,D);D()}},[N,_,D,M,L]);const Y=p.useMemo(()=>({reference:$,floating:O,setReference:E,setFloating:S}),[E,S]),H=p.useMemo(()=>({reference:N,floating:_}),[N,_]),q=p.useMemo(()=>{const F={position:s,left:0,top:0};if(!H.floating)return F;const G=Oj(H.floating,g.x),U=Oj(H.floating,g.y);return d?{...F,transform:"translate("+G+"px, "+U+"px)",...G1(H.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:G,top:U}},[s,d,H.floating,g.x,g.y]);return p.useMemo(()=>({...g,update:D,refs:Y,elements:H,floatingStyles:q}),[g,D,Y,H,q])}const q1=(e,n)=>{const s=d4(e);return{name:s.name,fn:s.fn,options:[e,n]}},v4=(e,n)=>{const s=u4(e);return{name:s.name,fn:s.fn,options:[e,n]}},y4=(e,n)=>{const s=f4(e);return{name:s.name,fn:s.fn,options:[e,n]}},b4=(e,n)=>{const s=m4(e);return{name:s.name,fn:s.fn,options:[e,n]}},K1={..._g},w4=K1.useInsertionEffect,j4=w4||(e=>e());function V1(e){const n=p.useRef(()=>{});return j4(()=>{n.current=e}),p.useCallback(function(){for(var s=arguments.length,r=new Array(s),a=0;a<s;a++)r[a]=arguments[a];return n.current==null?void 0:n.current(...r)},[])}var Ug=typeof document<"u"?p.useLayoutEffect:p.useEffect;let Mj=!1,k4=0;const Pj=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+k4++;function N4(){const[e,n]=p.useState(()=>Mj?Pj():void 0);return Ug(()=>{e==null&&n(Pj())},[]),p.useEffect(()=>{Mj=!0},[]),e}const S4=K1.useId,C4=S4||N4;function E4(){const e=new Map;return{emit(n,s){var r;(r=e.get(n))==null||r.forEach(a=>a(s))},on(n,s){e.set(n,[...e.get(n)||[],s])},off(n,s){var r;e.set(n,((r=e.get(n))==null?void 0:r.filter(a=>a!==s))||[])}}}const $4=p.createContext(null),_4=p.createContext(null),T4=()=>{var e;return((e=p.useContext($4))==null?void 0:e.id)||null},R4=()=>p.useContext(_4),A4="data-floating-ui-focusable";function O4(e){const{open:n=!1,onOpenChange:s,elements:r}=e,a=C4(),i=p.useRef({}),[c]=p.useState(()=>E4()),d=T4()!=null,[u,f]=p.useState(r.reference),g=V1((h,v,y)=>{i.current.openEvent=h?v:void 0,c.emit("openchange",{open:h,event:v,reason:y,nested:d}),s==null||s(h,v,y)}),b=p.useMemo(()=>({setPositionReference:f}),[]),x=p.useMemo(()=>({reference:u||r.reference||null,floating:r.floating||null,domReference:r.reference}),[u,r.reference,r.floating]);return p.useMemo(()=>({dataRef:i,open:n,onOpenChange:g,elements:x,events:c,floatingId:a,refs:b}),[n,g,x,c,a,b])}function M4(e){e===void 0&&(e={});const{nodeId:n}=e,s=O4({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||s,a=r.elements,[i,c]=p.useState(null),[d,u]=p.useState(null),g=(a==null?void 0:a.domReference)||i,b=p.useRef(null),x=R4();Ug(()=>{g&&(b.current=g)},[g]);const h=x4({...e,elements:{...a,...d&&{reference:d}}}),v=p.useCallback(S=>{const N=us(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),contextElement:S}:S;u(N),h.refs.setReference(N)},[h.refs]),y=p.useCallback(S=>{(us(S)||S===null)&&(b.current=S,c(S)),(us(h.refs.reference.current)||h.refs.reference.current===null||S!==null&&!us(S))&&h.refs.setReference(S)},[h.refs]),j=p.useMemo(()=>({...h.refs,setReference:y,setPositionReference:v,domReference:b}),[h.refs,y,v]),k=p.useMemo(()=>({...h.elements,domReference:g}),[h.elements,g]),E=p.useMemo(()=>({...h,...r,refs:j,elements:k,nodeId:n}),[h,j,k,n,r]);return Ug(()=>{r.dataRef.current.floatingContext=E;const S=x==null?void 0:x.nodesRef.current.find(N=>N.id===n);S&&(S.context=E)}),p.useMemo(()=>({...h,context:E,refs:j,elements:k}),[h,j,k,E])}const Lj="active",Ij="selected";function Zp(e,n,s){const r=new Map,a=s==="item";let i=e;if(a&&e){const{[Lj]:c,[Ij]:d,...u}=e;i=u}return{...s==="floating"&&{tabIndex:-1,[A4]:""},...i,...n.map(c=>{const d=c?c[s]:null;return typeof d=="function"?e?d(e):null:d}).concat(e).reduce((c,d)=>(d&&Object.entries(d).forEach(u=>{let[f,g]=u;if(!(a&&[Lj,Ij].includes(f)))if(f.indexOf("on")===0){if(r.has(f)||r.set(f,[]),typeof g=="function"){var b;(b=r.get(f))==null||b.push(g),c[f]=function(){for(var x,h=arguments.length,v=new Array(h),y=0;y<h;y++)v[y]=arguments[y];return(x=r.get(f))==null?void 0:x.map(j=>j(...v)).find(j=>j!==void 0)}}}else c[f]=g}),c),{})}}function P4(e){e===void 0&&(e=[]);const n=e.map(d=>d==null?void 0:d.reference),s=e.map(d=>d==null?void 0:d.floating),r=e.map(d=>d==null?void 0:d.item),a=p.useCallback(d=>Zp(d,e,"reference"),n),i=p.useCallback(d=>Zp(d,e,"floating"),s),c=p.useCallback(d=>Zp(d,e,"item"),r);return p.useMemo(()=>({getReferenceProps:a,getFloatingProps:i,getItemProps:c}),[a,i,c])}function zj(e,n){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:n}}}}const L4=e=>({name:"inner",options:e,async fn(n){const{listRef:s,overflowRef:r,onFallbackChange:a,offset:i=0,index:c=0,minItemsVisible:d=4,referenceOverflowThreshold:u=0,scrollRef:f,...g}=bl(e,n),{rects:b,elements:{floating:x}}=n,h=s.current[c],v=(f==null?void 0:f.current)||x,y=x.clientTop||v.clientTop,j=x.clientTop!==0,k=v.clientTop!==0,E=x===v;if(!h)return{};const S={...n,...await q1(-h.offsetTop-x.clientTop-b.reference.height/2-h.offsetHeight/2-i).fn(n)},N=await Jp(zj(S,v.scrollHeight+y+x.clientTop),g),_=await Jp(S,{...g,elementContext:"reference"}),$=Hs(0,N.top),O=S.y+$,M=(v.scrollHeight>v.clientHeight?R=>R:Dc)(Hs(0,v.scrollHeight+(j&&E||k?y*2:0)-$-Hs(0,N.bottom)));if(v.style.maxHeight=M+"px",v.scrollTop=$,a){const R=v.offsetHeight<h.offsetHeight*za(d,s.current.length)-1||_.top>=-u||_.bottom>=-u;ks.flushSync(()=>a(R))}return r&&(r.current=await Jp(zj({...S,y:O},v.offsetHeight+y+x.clientTop),g)),{y:O}}});function I4(e,n){const{open:s,elements:r}=e,{enabled:a=!0,overflowRef:i,scrollRef:c,onChange:d}=n,u=V1(d),f=p.useRef(!1),g=p.useRef(null),b=p.useRef(null);p.useEffect(()=>{if(!a)return;function h(y){if(y.ctrlKey||!v||i.current==null)return;const j=y.deltaY,k=i.current.top>=-.5,E=i.current.bottom>=-.5,S=v.scrollHeight-v.clientHeight,N=j<0?-1:1,_=j<0?"max":"min";v.scrollHeight<=v.clientHeight||(!k&&j>0||!E&&j<0?(y.preventDefault(),ks.flushSync(()=>{u($=>$+Math[_](j,S*N))})):/firefox/i.test($3())&&(v.scrollTop+=j))}const v=(c==null?void 0:c.current)||r.floating;if(s&&v)return v.addEventListener("wheel",h),requestAnimationFrame(()=>{g.current=v.scrollTop,i.current!=null&&(b.current={...i.current})}),()=>{g.current=null,b.current=null,v.removeEventListener("wheel",h)}},[a,s,r.floating,i,c,u]);const x=p.useMemo(()=>({onKeyDown(){f.current=!0},onWheel(){f.current=!1},onPointerMove(){f.current=!1},onScroll(){const h=(c==null?void 0:c.current)||r.floating;if(!(!i.current||!h||!f.current)){if(g.current!==null){const v=h.scrollTop-g.current;(i.current.bottom<-.5&&v<-1||i.current.top<-.5&&v>1)&&ks.flushSync(()=>u(y=>y+v))}requestAnimationFrame(()=>{g.current=h.scrollTop})}}}),[r.floating,u,i,c]);return p.useMemo(()=>a?{floating:x}:{},[a,x])}let wl=p.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});wl.displayName="FloatingContext";let rv=p.createContext(null);rv.displayName="PlacementContext";function z4(e){return p.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function D4(){return p.useContext(wl).setReference}function F4(){return p.useContext(wl).getReferenceProps}function U4(){let{getFloatingProps:e,slot:n}=p.useContext(wl);return p.useCallback((...s)=>Object.assign({},e(...s),{"data-anchor":n.anchor}),[e,n])}function W4(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let n=p.useContext(rv),s=p.useMemo(()=>e,[JSON.stringify(e,(a,i)=>{var c;return(c=i==null?void 0:i.outerHTML)!=null?c:i})]);en(()=>{n==null||n(s??null)},[n,s]);let r=p.useContext(wl);return p.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let Dj=4;function H4({children:e,enabled:n=!0}){let[s,r]=p.useState(null),[a,i]=p.useState(0),c=p.useRef(null),[d,u]=p.useState(null);B4(d);let f=n&&s!==null&&d!==null,{to:g="bottom",gap:b=0,offset:x=0,padding:h=0,inner:v}=G4(s,d),[y,j="center"]=g.split(" ");en(()=>{f&&i(0)},[f]);let{refs:k,floatingStyles:E,context:S}=M4({open:f,placement:y==="selection"?j==="center"?"bottom":`bottom-${j}`:j==="center"?`${y}`:`${y}-${j}`,strategy:"absolute",transform:!1,middleware:[q1({mainAxis:y==="selection"?0:b,crossAxis:x}),v4({padding:h}),y!=="selection"&&y4({padding:h}),y==="selection"&&v?L4({...v,padding:h,overflowRef:c,offset:a,minItemsVisible:Dj,referenceOverflowThreshold:h,onFallbackChange(R){var P,D;if(!R)return;let W=S.elements.floating;if(!W)return;let Y=parseFloat(getComputedStyle(W).scrollPaddingBottom)||0,H=Math.min(Dj,W.childElementCount),q=0,F=0;for(let G of(D=(P=S.elements.floating)==null?void 0:P.childNodes)!=null?D:[])if(Ns(G)){let U=G.offsetTop,z=U+G.clientHeight+Y,Q=W.scrollTop,K=Q+W.clientHeight;if(U>=Q&&z<=K)H--;else{F=Math.max(0,Math.min(z,K)-Math.max(U,Q)),q=G.clientHeight;break}}H>=1&&i(G=>{let U=q*H-F+Y;return G>=U?G:U})}}):null,b4({padding:h,apply({availableWidth:R,availableHeight:P,elements:D}){Object.assign(D.floating.style,{overflow:"auto",maxWidth:`${R}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${P}px)`})}})].filter(Boolean),whileElementsMounted:c4}),[N=y,_=j]=S.placement.split("-");y==="selection"&&(N="selection");let $=p.useMemo(()=>({anchor:[N,_].filter(Boolean).join(" ")}),[N,_]),O=I4(S,{overflowRef:c,onChange:i}),{getReferenceProps:A,getFloatingProps:L}=P4([O]),M=dt(R=>{u(R),k.setFloating(R)});return p.createElement(rv.Provider,{value:r},p.createElement(wl.Provider,{value:{setFloating:M,setReference:k.setReference,styles:E,getReferenceProps:A,getFloatingProps:L,slot:$}},e))}function B4(e){en(()=>{if(!e)return;let n=new MutationObserver(()=>{let s=window.getComputedStyle(e).maxHeight,r=parseFloat(s);if(isNaN(r))return;let a=parseInt(s);isNaN(a)||r!==a&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return n.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{n.disconnect()}},[e])}function G4(e,n){var s,r,a;let i=eg((s=e==null?void 0:e.gap)!=null?s:"var(--anchor-gap, 0)",n),c=eg((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",n),d=eg((a=e==null?void 0:e.padding)!=null?a:"var(--anchor-padding, 0)",n);return{...e,gap:i,offset:c,padding:d}}function eg(e,n,s=void 0){let r=Xo(),a=dt((u,f)=>{if(u==null)return[s,null];if(typeof u=="number")return[u,null];if(typeof u=="string"){if(!f)return[s,null];let g=Fj(u,f);return[g,b=>{let x=Y1(u);{let h=x.map(v=>window.getComputedStyle(f).getPropertyValue(v));r.requestAnimationFrame(function v(){r.nextFrame(v);let y=!1;for(let[k,E]of x.entries()){let S=window.getComputedStyle(f).getPropertyValue(E);if(h[k]!==S){h[k]=S,y=!0;break}}if(!y)return;let j=Fj(u,f);g!==j&&(b(j),g=j)})}return r.dispose}]}return[s,null]}),i=p.useMemo(()=>a(e,n)[0],[e,n]),[c=i,d]=p.useState();return en(()=>{let[u,f]=a(e,n);if(d(u),!!f)return f(d)},[e,n]),c}function Y1(e){let n=/var\((.*)\)/.exec(e);if(n){let s=n[1].indexOf(",");if(s===-1)return[n[1]];let r=n[1].slice(0,s).trim(),a=n[1].slice(s+1).trim();return a?[r,...Y1(a)]:[r]}return[]}function Fj(e,n){let s=document.createElement("div");n.appendChild(s),s.style.setProperty("margin-top","0px","important"),s.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(s).marginTop)||0;return n.removeChild(s),r}function q4({children:e,freeze:n},s){let r=Q1(n,e);return p.isValidElement(r)?p.cloneElement(r,{ref:s}):qe.createElement(qe.Fragment,null,r)}qe.forwardRef(q4);function Q1(e,n){let[s,r]=p.useState(n);return!e&&s!==n&&r(n),e?s:n}let wm=p.createContext(null);wm.displayName="OpenClosedContext";var Jn=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Jn||{});function ed(){return p.useContext(wm)}function J1({value:e,children:n}){return qe.createElement(wm.Provider,{value:e},n)}function K4({children:e}){return qe.createElement(wm.Provider,{value:null},e)}function V4(e){function n(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",n))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",n),n())}let Io=[];V4(()=>{function e(n){if(!Kr(n.target)||n.target===document.body||Io[0]===n.target)return;let s=n.target;s=s.closest(wf),Io.unshift(s??n.target),Io=Io.filter(r=>r!=null&&r.isConnected),Io.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function Y4(e){throw new Error("Unexpected object: "+e)}var sn=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(sn||{});function Pu(e,n){let s=n.resolveItems();if(s.length<=0)return null;let r=n.resolveActiveIndex(),a=r??-1;switch(e.focus){case 0:{for(let i=0;i<s.length;++i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 1:{a===-1&&(a=s.length);for(let i=a-1;i>=0;--i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 2:{for(let i=a+1;i<s.length;++i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 3:{for(let i=s.length-1;i>=0;--i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 4:{for(let i=0;i<s.length;++i)if(n.resolveId(s[i],i,s)===e.id)return i;return r}case 5:return null;default:Y4(e)}}function ov(e){let n=dt(e),s=p.useRef(!1);p.useEffect(()=>(s.current=!1,()=>{s.current=!0,fm(()=>{s.current&&n()})}),[n])}function Q4(){let e=typeof document>"u";return"useSyncExternalStore"in _g?(n=>n.useSyncExternalStore)(_g)(()=>()=>{},()=>!1,()=>!e):!1}function td(){let e=Q4(),[n,s]=p.useState(Nr.isHandoffComplete);return n&&Nr.isHandoffComplete===!1&&s(!1),p.useEffect(()=>{n!==!0&&s(!0)},[n]),p.useEffect(()=>Nr.handoff(),[]),e?!1:n}let X1=p.createContext(!1);function J4(){return p.useContext(X1)}function Uj(e){return qe.createElement(X1.Provider,{value:e.force},e.children)}function X4(e){let n=J4(),s=p.useContext(eS),[r,a]=p.useState(()=>{var i;if(!n&&s!==null)return(i=s.current)!=null?i:null;if(Nr.isServer)return null;let c=e==null?void 0:e.getElementById("headlessui-portal-root");if(c)return c;if(e===null)return null;let d=e.createElement("div");return d.setAttribute("id","headlessui-portal-root"),e.body.appendChild(d)});return p.useEffect(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),p.useEffect(()=>{n||s!==null&&a(s.current)},[s,a,n]),r}let Z1=p.Fragment,Z4=gn(function(e,n){let{ownerDocument:s=null,...r}=e,a=p.useRef(null),i=Dn(NA(h=>{a.current=h}),n),c=Lc(a.current),d=s??c,u=X4(d),f=p.useContext(Wg),g=Xo(),b=td(),x=Cn();return ov(()=>{var h;u&&u.childNodes.length<=0&&((h=u.parentElement)==null||h.removeChild(u))}),!u||!b?null:ks.createPortal(qe.createElement("div",{"data-headlessui-portal":"",ref:h=>{g.dispose(),f&&h&&g.add(f.register(h))}},x({ourProps:{ref:i},theirProps:r,slot:{},defaultTag:Z1,name:"Portal"})),u)});function eO(e,n){let s=Dn(n),{enabled:r=!0,ownerDocument:a,...i}=e,c=Cn();return r?qe.createElement(Z4,{...i,ownerDocument:a,ref:s}):c({ourProps:{ref:s},theirProps:i,slot:{},defaultTag:Z1,name:"Portal"})}let tO=p.Fragment,eS=p.createContext(null);function nO(e,n){let{target:s,...r}=e,a={ref:Dn(n)},i=Cn();return qe.createElement(eS.Provider,{value:s},i({ourProps:a,theirProps:r,defaultTag:tO,name:"Popover.Group"}))}let Wg=p.createContext(null);function sO(){let e=p.useContext(Wg),n=p.useRef([]),s=dt(i=>(n.current.push(i),e&&e.register(i),()=>r(i))),r=dt(i=>{let c=n.current.indexOf(i);c!==-1&&n.current.splice(c,1),e&&e.unregister(i)}),a=p.useMemo(()=>({register:s,unregister:r,portals:n}),[s,r,n]);return[n,p.useMemo(()=>function({children:i}){return qe.createElement(Wg.Provider,{value:a},i)},[a])]}let rO=gn(eO),tS=gn(nO),nS=Object.assign(rO,{Group:tS});const of={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function sS(e){let n=e.getBoundingClientRect();return`${n.x},${n.y}`}function oO(e,n,s){let r=Es();if(n.kind==="Tracked"){let a=function(){i!==sS(e)&&(r.dispose(),s())},{position:i}=n,c=new ResizeObserver(a);c.observe(e),r.add(()=>c.disconnect()),r.addEventListener(window,"scroll",a,{passive:!0}),r.addEventListener(window,"resize",a)}return()=>r.dispose()}function aO(e,n=typeof document<"u"?document.defaultView:null,s){let r=Xc(e,"escape");T1(n,"keydown",a=>{r&&(a.defaultPrevented||a.key===yn.Escape&&s(a))})}function iO(){var e;let[n]=p.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null),[s,r]=p.useState((e=n==null?void 0:n.matches)!=null?e:!1);return en(()=>{if(!n)return;function a(i){r(i.matches)}return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},[n]),s}function lO({defaultContainers:e=[],portals:n,mainTreeNode:s}={}){let r=dt(()=>{var a,i;let c=vl(s),d=[];for(let u of e)u!==null&&(Qr(u)?d.push(u):"current"in u&&Qr(u.current)&&d.push(u.current));if(n!=null&&n.current)for(let u of n.current)d.push(u);for(let u of(a=c==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?a:[])u!==document.body&&u!==document.head&&Qr(u)&&u.id!=="headlessui-portal-root"&&(s&&(u.contains(s)||u.contains((i=s==null?void 0:s.getRootNode())==null?void 0:i.host))||d.some(f=>u.contains(f))||d.push(u));return d});return{resolveContainers:r,contains:dt(a=>r().some(i=>i.contains(a)))}}let rS=p.createContext(null);function Wj({children:e,node:n}){let[s,r]=p.useState(null),a=oS(n??s);return qe.createElement(rS.Provider,{value:a},e,a===null&&qe.createElement(Pc,{features:al.Hidden,ref:i=>{var c,d;if(i){for(let u of(d=(c=vl(i))==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?d:[])if(u!==document.body&&u!==document.head&&Qr(u)&&u!=null&&u.contains(i)){r(u);break}}}}))}function oS(e=null){var n;return(n=p.useContext(rS))!=null?n:e}function av(){let e=p.useRef(!1);return en(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var jc=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(jc||{});function cO(){let e=p.useRef(0);return $1(!0,"keydown",n=>{n.key==="Tab"&&(e.current=n.shiftKey?1:0)},!0),e}function aS(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let n=new Set;for(let s of e.current)Qr(s.current)&&n.add(s.current);return n}let dO="div";var Na=(e=>(e[e.None=0]="None",e[e.InitialFocus=1]="InitialFocus",e[e.TabLock=2]="TabLock",e[e.FocusLock=4]="FocusLock",e[e.RestoreFocus=8]="RestoreFocus",e[e.AutoFocus=16]="AutoFocus",e))(Na||{});function uO(e,n){let s=p.useRef(null),r=Dn(s,n),{initialFocus:a,initialFocusFallback:i,containers:c,features:d=15,...u}=e;td()||(d=0);let f=Lc(s.current);pO(d,{ownerDocument:f});let g=gO(d,{ownerDocument:f,container:s,initialFocus:a,initialFocusFallback:i});xO(d,{ownerDocument:f,container:s,containers:c,previousActiveElement:g});let b=cO(),x=dt(E=>{if(!Ns(s.current))return;let S=s.current;(N=>N())(()=>{es(b.current,{[jc.Forwards]:()=>{qi(S,ir.First,{skipElements:[E.relatedTarget,i]})},[jc.Backwards]:()=>{qi(S,ir.Last,{skipElements:[E.relatedTarget,i]})}})})}),h=Xc(!!(d&2),"focus-trap#tab-lock"),v=Xo(),y=p.useRef(!1),j={ref:r,onKeyDown(E){E.key=="Tab"&&(y.current=!0,v.requestAnimationFrame(()=>{y.current=!1}))},onBlur(E){if(!(d&4))return;let S=aS(c);Ns(s.current)&&S.add(s.current);let N=E.relatedTarget;Kr(N)&&N.dataset.headlessuiFocusGuard!=="true"&&(iS(S,N)||(y.current?qi(s.current,es(b.current,{[jc.Forwards]:()=>ir.Next,[jc.Backwards]:()=>ir.Previous})|ir.WrapAround,{relativeTo:E.target}):Kr(E.target)&&Jr(E.target)))}},k=Cn();return qe.createElement(qe.Fragment,null,h&&qe.createElement(Pc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:x,features:al.Focusable}),k({ourProps:j,theirProps:u,defaultTag:dO,name:"FocusTrap"}),h&&qe.createElement(Pc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:x,features:al.Focusable}))}let fO=gn(uO),mO=Object.assign(fO,{features:Na});function hO(e=!0){let n=p.useRef(Io.slice());return ev(([s],[r])=>{r===!0&&s===!1&&fm(()=>{n.current.splice(0)}),r===!1&&s===!0&&(n.current=Io.slice())},[e,Io,n]),dt(()=>{var s;return(s=n.current.find(r=>r!=null&&r.isConnected))!=null?s:null})}function pO(e,{ownerDocument:n}){let s=!!(e&8),r=hO(s);ev(()=>{s||ZN(n==null?void 0:n.body)&&Jr(r())},[s]),ov(()=>{s&&Jr(r())})}function gO(e,{ownerDocument:n,container:s,initialFocus:r,initialFocusFallback:a}){let i=p.useRef(null),c=Xc(!!(e&1),"focus-trap#initial-focus"),d=av();return ev(()=>{if(e===0)return;if(!c){a!=null&&a.current&&Jr(a.current);return}let u=s.current;u&&fm(()=>{if(!d.current)return;let f=n==null?void 0:n.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===f){i.current=f;return}}else if(u.contains(f)){i.current=f;return}if(r!=null&&r.current)Jr(r.current);else{if(e&16){if(qi(u,ir.First|ir.AutoFocus)!==zg.Error)return}else if(qi(u,ir.First)!==zg.Error)return;if(a!=null&&a.current&&(Jr(a.current),(n==null?void 0:n.activeElement)===a.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}i.current=n==null?void 0:n.activeElement})},[a,c,e]),i}function xO(e,{ownerDocument:n,container:s,containers:r,previousActiveElement:a}){let i=av(),c=!!(e&4);T1(n==null?void 0:n.defaultView,"focus",d=>{if(!c||!i.current)return;let u=aS(r);Ns(s.current)&&u.add(s.current);let f=a.current;if(!f)return;let g=d.target;Ns(g)?iS(u,g)?(a.current=g,Jr(g)):(d.preventDefault(),d.stopPropagation(),Jr(f)):Jr(a.current)},!0)}function iS(e,n){for(let s of e)if(s.contains(n))return!0;return!1}function lS(e){var n;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!Cc((n=e.as)!=null?n:dS)||qe.Children.count(e.children)===1}let jm=p.createContext(null);jm.displayName="TransitionContext";var vO=(e=>(e.Visible="visible",e.Hidden="hidden",e))(vO||{});function yO(){let e=p.useContext(jm);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function bO(){let e=p.useContext(km);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let km=p.createContext(null);km.displayName="NestingContext";function Nm(e){return"children"in e?Nm(e.children):e.current.filter(({el:n})=>n.current!==null).filter(({state:n})=>n==="visible").length>0}function cS(e,n){let s=Zo(e),r=p.useRef([]),a=av(),i=Xo(),c=dt((h,v=zo.Hidden)=>{let y=r.current.findIndex(({el:j})=>j===h);y!==-1&&(es(v,{[zo.Unmount](){r.current.splice(y,1)},[zo.Hidden](){r.current[y].state="hidden"}}),i.microTask(()=>{var j;!Nm(r)&&a.current&&((j=s.current)==null||j.call(s))}))}),d=dt(h=>{let v=r.current.find(({el:y})=>y===h);return v?v.state!=="visible"&&(v.state="visible"):r.current.push({el:h,state:"visible"}),()=>c(h,zo.Unmount)}),u=p.useRef([]),f=p.useRef(Promise.resolve()),g=p.useRef({enter:[],leave:[]}),b=dt((h,v,y)=>{u.current.splice(0),n&&(n.chains.current[v]=n.chains.current[v].filter(([j])=>j!==h)),n==null||n.chains.current[v].push([h,new Promise(j=>{u.current.push(j)})]),n==null||n.chains.current[v].push([h,new Promise(j=>{Promise.all(g.current[v].map(([k,E])=>E)).then(()=>j())})]),v==="enter"?f.current=f.current.then(()=>n==null?void 0:n.wait.current).then(()=>y(v)):y(v)}),x=dt((h,v,y)=>{Promise.all(g.current[v].splice(0).map(([j,k])=>k)).then(()=>{var j;(j=u.current.shift())==null||j()}).then(()=>y(v))});return p.useMemo(()=>({children:r,register:d,unregister:c,onStart:b,onStop:x,wait:f,chains:g}),[d,c,r,b,x,g,f])}let dS=p.Fragment,uS=ol.RenderStrategy;function wO(e,n){var s,r;let{transition:a=!0,beforeEnter:i,afterEnter:c,beforeLeave:d,afterLeave:u,enter:f,enterFrom:g,enterTo:b,entered:x,leave:h,leaveFrom:v,leaveTo:y,...j}=e,[k,E]=p.useState(null),S=p.useRef(null),N=lS(e),_=Dn(...N?[S,n,E]:n===null?[]:[n]),$=(s=j.unmount)==null||s?zo.Unmount:zo.Hidden,{show:O,appear:A,initial:L}=yO(),[M,R]=p.useState(O?"visible":"hidden"),P=bO(),{register:D,unregister:W}=P;en(()=>D(S),[D,S]),en(()=>{if($===zo.Hidden&&S.current){if(O&&M!=="visible"){R("visible");return}return es(M,{hidden:()=>W(S),visible:()=>D(S)})}},[M,S,D,W,O,$]);let Y=td();en(()=>{if(N&&Y&&M==="visible"&&S.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[S,M,Y,N]);let H=L&&!A,q=A&&O&&L,F=p.useRef(!1),G=cS(()=>{F.current||(R("hidden"),W(S))},P),U=dt(ue=>{F.current=!0;let xe=ue?"enter":"leave";G.onStart(S,xe,$e=>{$e==="enter"?i==null||i():$e==="leave"&&(d==null||d())})}),z=dt(ue=>{let xe=ue?"enter":"leave";F.current=!1,G.onStop(S,xe,$e=>{$e==="enter"?c==null||c():$e==="leave"&&(u==null||u())}),xe==="leave"&&!Nm(G)&&(R("hidden"),W(S))});p.useEffect(()=>{N&&a||(U(O),z(O))},[O,N,a]);let Q=!(!a||!N||!Y||H),[,K]=O1(Q,k,O,{start:U,end:z}),Z=Lo({ref:_,className:((r=Lg(j.className,q&&f,q&&g,K.enter&&f,K.enter&&K.closed&&g,K.enter&&!K.closed&&b,K.leave&&h,K.leave&&!K.closed&&v,K.leave&&K.closed&&y,!K.transition&&O&&x))==null?void 0:r.trim())||void 0,...A1(K)}),de=0;M==="visible"&&(de|=Jn.Open),M==="hidden"&&(de|=Jn.Closed),O&&M==="hidden"&&(de|=Jn.Opening),!O&&M==="visible"&&(de|=Jn.Closing);let se=Cn();return qe.createElement(km.Provider,{value:G},qe.createElement(J1,{value:de},se({ourProps:Z,theirProps:j,defaultTag:dS,features:uS,visible:M==="visible",name:"Transition.Child"})))}function jO(e,n){let{show:s,appear:r=!1,unmount:a=!0,...i}=e,c=p.useRef(null),d=lS(e),u=Dn(...d?[c,n]:n===null?[]:[n]);td();let f=ed();if(s===void 0&&f!==null&&(s=(f&Jn.Open)===Jn.Open),s===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[g,b]=p.useState(s?"visible":"hidden"),x=cS(()=>{s||b("hidden")}),[h,v]=p.useState(!0),y=p.useRef([s]);en(()=>{h!==!1&&y.current[y.current.length-1]!==s&&(y.current.push(s),v(!1))},[y,s]);let j=p.useMemo(()=>({show:s,appear:r,initial:h}),[s,r,h]);en(()=>{s?b("visible"):!Nm(x)&&c.current!==null&&b("hidden")},[s,x]);let k={unmount:a},E=dt(()=>{var _;h&&v(!1),(_=e.beforeEnter)==null||_.call(e)}),S=dt(()=>{var _;h&&v(!1),(_=e.beforeLeave)==null||_.call(e)}),N=Cn();return qe.createElement(km.Provider,{value:x},qe.createElement(jm.Provider,{value:j},N({ourProps:{...k,as:p.Fragment,children:qe.createElement(fS,{ref:u,...k,...i,beforeEnter:E,beforeLeave:S})},theirProps:{},defaultTag:p.Fragment,features:uS,visible:g==="visible",name:"Transition"})))}function kO(e,n){let s=p.useContext(jm)!==null,r=ed()!==null;return qe.createElement(qe.Fragment,null,!s&&r?qe.createElement(Hg,{ref:n,...e}):qe.createElement(fS,{ref:n,...e}))}let Hg=gn(jO),fS=gn(wO),iv=gn(kO),NO=Object.assign(Hg,{Child:iv,Root:Hg});var SO=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(SO||{}),CO=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(CO||{});let EO={0(e,n){return e.titleId===n.id?e:{...e,titleId:n.id}}},lv=p.createContext(null);lv.displayName="DialogContext";function Sm(e){let n=p.useContext(lv);if(n===null){let s=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,Sm),s}return n}function $O(e,n){return es(n.type,EO,e,n)}let Hj=gn(function(e,n){let s=p.useId(),{id:r=`headlessui-dialog-${s}`,open:a,onClose:i,initialFocus:c,role:d="dialog",autoFocus:u=!0,__demoMode:f=!1,unmount:g=!1,...b}=e,x=p.useRef(!1);d=(function(){return d==="dialog"||d==="alertdialog"?d:(x.current||(x.current=!0,console.warn(`Invalid role [${d}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")})();let h=ed();a===void 0&&h!==null&&(a=(h&Jn.Open)===Jn.Open);let v=p.useRef(null),y=Dn(v,n),j=Lc(v.current),k=a?0:1,[E,S]=p.useReducer($O,{titleId:null,descriptionId:null,panelRef:p.createRef()}),N=dt(()=>i(!1)),_=dt(K=>S({type:0,id:K})),$=td()?k===0:!1,[O,A]=sO(),L={get current(){var K;return(K=E.panelRef.current)!=null?K:v.current}},M=oS(),{resolveContainers:R}=lO({mainTreeNode:M,portals:O,defaultContainers:[L]}),P=h!==null?(h&Jn.Closing)===Jn.Closing:!1;j1(f||P?!1:$,{allowed:dt(()=>{var K,Z;return[(Z=(K=v.current)==null?void 0:K.closest("[data-headlessui-portal]"))!=null?Z:null]}),disallowed:dt(()=>{var K;return[(K=M==null?void 0:M.closest("body > *:not(#headlessui-portal-root)"))!=null?K:null]})});let D=pm.get(null);en(()=>{if($)return D.actions.push(r),()=>D.actions.pop(r)},[D,r,$]);let W=Yn(D,p.useCallback(K=>D.selectors.isTop(K,r),[D,r]));_1(W,R,K=>{K.preventDefault(),N()}),aO(W,j==null?void 0:j.defaultView,K=>{K.preventDefault(),K.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),N()}),R1(f||P?!1:$,j,R),k1($,v,N);let[Y,H]=CA(),q=p.useMemo(()=>[{dialogState:k,close:N,setTitleId:_,unmount:g},E],[k,N,_,g,E]),F=Ks({open:k===0}),G={ref:y,id:r,role:d,tabIndex:-1,"aria-modal":f?void 0:k===0?!0:void 0,"aria-labelledby":E.titleId,"aria-describedby":Y,unmount:g},U=!iO(),z=Na.None;$&&!f&&(z|=Na.RestoreFocus,z|=Na.TabLock,u&&(z|=Na.AutoFocus),U&&(z|=Na.InitialFocus));let Q=Cn();return qe.createElement(K4,null,qe.createElement(Uj,{force:!0},qe.createElement(nS,null,qe.createElement(lv.Provider,{value:q},qe.createElement(tS,{target:v},qe.createElement(Uj,{force:!1},qe.createElement(H,{slot:F},qe.createElement(A,null,qe.createElement(mO,{initialFocus:c,initialFocusFallback:v,containers:R,features:z},qe.createElement(LA,{value:N},Q({ourProps:G,theirProps:b,slot:F,defaultTag:_O,features:TO,visible:k===0,name:"Dialog"})))))))))))}),_O="div",TO=ol.RenderStrategy|ol.Static;function RO(e,n){let{transition:s=!1,open:r,...a}=e,i=ed(),c=e.hasOwnProperty("open")||i!==null,d=e.hasOwnProperty("onClose");if(!c&&!d)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!c)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!d)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(!i&&typeof e.open!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);if(typeof e.onClose!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);return(r!==void 0||s)&&!a.static?qe.createElement(Wj,null,qe.createElement(NO,{show:r,transition:s,unmount:a.unmount},qe.createElement(Hj,{ref:n,...a}))):qe.createElement(Wj,null,qe.createElement(Hj,{ref:n,open:r,...a}))}let AO="div";function OO(e,n){let s=p.useId(),{id:r=`headlessui-dialog-panel-${s}`,transition:a=!1,...i}=e,[{dialogState:c,unmount:d},u]=Sm("Dialog.Panel"),f=Dn(n,u.panelRef),g=Ks({open:c===0}),b=dt(j=>{j.stopPropagation()}),x={ref:f,id:r,onClick:b},h=a?iv:p.Fragment,v=a?{unmount:d}:{},y=Cn();return qe.createElement(h,{...v},y({ourProps:x,theirProps:i,slot:g,defaultTag:AO,name:"Dialog.Panel"}))}let MO="div";function PO(e,n){let{transition:s=!1,...r}=e,[{dialogState:a,unmount:i}]=Sm("Dialog.Backdrop"),c=Ks({open:a===0}),d={ref:n,"aria-hidden":!0},u=s?iv:p.Fragment,f=s?{unmount:i}:{},g=Cn();return qe.createElement(u,{...f},g({ourProps:d,theirProps:r,slot:c,defaultTag:MO,name:"Dialog.Backdrop"}))}let LO="h2";function IO(e,n){let s=p.useId(),{id:r=`headlessui-dialog-title-${s}`,...a}=e,[{dialogState:i,setTitleId:c}]=Sm("Dialog.Title"),d=Dn(n);p.useEffect(()=>(c(r),()=>c(null)),[r,c]);let u=Ks({open:i===0}),f={ref:d,id:r};return Cn()({ourProps:f,theirProps:a,slot:u,defaultTag:LO,name:"Dialog.Title"})}let zO=gn(RO),mS=gn(OO),DO=gn(PO),hS=gn(IO),FO=Object.assign(zO,{Panel:mS,Title:hS,Description:f1}),Bj=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function Gj(e){var n,s;let r=(n=e.innerText)!=null?n:"",a=e.cloneNode(!0);if(!Ns(a))return r;let i=!1;for(let d of a.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))d.remove(),i=!0;let c=i?(s=a.innerText)!=null?s:"":r;return Bj.test(c)&&(c=c.replace(Bj,"")),c}function UO(e){let n=e.getAttribute("aria-label");if(typeof n=="string")return n.trim();let s=e.getAttribute("aria-labelledby");if(s){let r=s.split(" ").map(a=>{let i=document.getElementById(a);if(i){let c=i.getAttribute("aria-label");return typeof c=="string"?c.trim():Gj(i).trim()}return null}).filter(Boolean);if(r.length>0)return r.join(", ")}return Gj(e).trim()}function WO(e){let n=p.useRef(""),s=p.useRef("");return dt(()=>{let r=e.current;if(!r)return"";let a=r.innerText;if(n.current===a)return s.current;let i=UO(r).trim().toLowerCase();return n.current=a,s.current=i,i})}var HO=Object.defineProperty,BO=(e,n,s)=>n in e?HO(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,qj=(e,n,s)=>(BO(e,typeof n!="symbol"?n+"":n,s),s),In=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(In||{}),Do=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Do||{}),af=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(af||{}),pS=(e=>(e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.GoToOption=2]="GoToOption",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.SelectOption=5]="SelectOption",e[e.RegisterOptions=6]="RegisterOptions",e[e.UnregisterOptions=7]="UnregisterOptions",e[e.SetButtonElement=8]="SetButtonElement",e[e.SetOptionsElement=9]="SetOptionsElement",e[e.SortOptions=10]="SortOptions",e[e.MarkButtonAsMoved=11]="MarkButtonAsMoved",e))(pS||{});function Kj(e,n=s=>s){let s=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=C1(n(e.options.slice()),i=>i.dataRef.current.domRef.current),a=s?r.indexOf(s):null;return a===-1&&(a=null),{options:r,activeOptionIndex:a}}let GO={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=e.buttonElement?of.Tracked(sS(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:sn.Nothing},listboxState:1,__demoMode:!1,buttonPositionState:n}},0(e,n){if(e.dataRef.current.disabled||e.listboxState===0)return e;let s=e.activeOptionIndex,{isSelected:r}=e.dataRef.current,a=e.options.findIndex(i=>r(i.dataRef.current.value));return a!==-1&&(s=a),{...e,frozenValue:!1,pendingFocus:n.focus,listboxState:0,activeOptionIndex:s,__demoMode:!1,buttonPositionState:of.Idle}},2(e,n){var s,r,a,i,c;if(e.dataRef.current.disabled||e.listboxState===1)return e;let d={...e,searchQuery:"",activationTrigger:(s=n.trigger)!=null?s:1,__demoMode:!1};if(n.focus===sn.Nothing)return{...d,activeOptionIndex:null};if(n.focus===sn.Specific)return{...d,activeOptionIndex:e.options.findIndex(g=>g.id===n.id)};if(n.focus===sn.Previous){let g=e.activeOptionIndex;if(g!==null){let b=e.options[g].dataRef.current.domRef,x=Pu(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(x!==null){let h=e.options[x].dataRef.current.domRef;if(((r=b.current)==null?void 0:r.previousElementSibling)===h.current||((a=h.current)==null?void 0:a.previousElementSibling)===null)return{...d,activeOptionIndex:x}}}}else if(n.focus===sn.Next){let g=e.activeOptionIndex;if(g!==null){let b=e.options[g].dataRef.current.domRef,x=Pu(n,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:h=>h.id,resolveDisabled:h=>h.dataRef.current.disabled});if(x!==null){let h=e.options[x].dataRef.current.domRef;if(((i=b.current)==null?void 0:i.nextElementSibling)===h.current||((c=h.current)==null?void 0:c.nextElementSibling)===null)return{...d,activeOptionIndex:x}}}}let u=Kj(e),f=Pu(n,{resolveItems:()=>u.options,resolveActiveIndex:()=>u.activeOptionIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});return{...d,...u,activeOptionIndex:f}},3:(e,n)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let s=e.searchQuery!==""?0:1,r=e.searchQuery+n.value.toLowerCase(),a=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+s).concat(e.options.slice(0,e.activeOptionIndex+s)):e.options).find(c=>{var d;return!c.dataRef.current.disabled&&((d=c.dataRef.current.textValue)==null?void 0:d.startsWith(r))}),i=a?e.options.indexOf(a):-1;return i===-1||i===e.activeOptionIndex?{...e,searchQuery:r}:{...e,searchQuery:r,activeOptionIndex:i,activationTrigger:1}},4(e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===""?e:{...e,searchQuery:""}},5(e){return e.dataRef.current.mode===0?{...e,frozenValue:!0}:{...e}},6:(e,n)=>{let s=e.options.concat(n.options),r=e.activeOptionIndex;if(e.pendingFocus.focus!==sn.Nothing&&(r=Pu(e.pendingFocus,{resolveItems:()=>s,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:a=>a.id,resolveDisabled:a=>a.dataRef.current.disabled})),e.activeOptionIndex===null){let{isSelected:a}=e.dataRef.current;if(a){let i=s.findIndex(c=>a==null?void 0:a(c.dataRef.current.value));i!==-1&&(r=i)}}return{...e,options:s,activeOptionIndex:r,pendingFocus:{focus:sn.Nothing},pendingShouldSort:!0}},7:(e,n)=>{let s=e.options,r=[],a=new Set(n.options);for(let[i,c]of s.entries())if(a.has(c.id)&&(r.push(i),a.delete(c.id),a.size===0))break;if(r.length>0){s=s.slice();for(let i of r.reverse())s.splice(i,1)}return{...e,options:s,activationTrigger:1}},8:(e,n)=>e.buttonElement===n.element?e:{...e,buttonElement:n.element},9:(e,n)=>e.optionsElement===n.element?e:{...e,optionsElement:n.element},10:e=>e.pendingShouldSort?{...e,...Kj(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:of.Moved}}};class cv extends v1{constructor(n){super(n),qj(this,"actions",{onChange:s=>{let{onChange:r,compare:a,mode:i,value:c}=this.state.dataRef.current;return es(i,{0:()=>r==null?void 0:r(s),1:()=>{let d=c.slice(),u=d.findIndex(f=>a(f,s));return u===-1?d.push(s):d.splice(u,1),r==null?void 0:r(d)}})},registerOption:qp(()=>{let s=[],r=new Set;return[(a,i)=>{r.has(i)||(r.add(i),s.push({id:a,dataRef:i}))},()=>(r.clear(),this.send({type:6,options:s.splice(0)}))]}),unregisterOption:qp(()=>{let s=[];return[r=>s.push(r),()=>{this.send({type:7,options:s.splice(0)})}]}),goToOption:qp(()=>{let s=null;return[(r,a)=>{s={type:2,...r,trigger:a}},()=>s&&this.send(s)]}),closeListbox:()=>{this.send({type:1})},openListbox:s=>{this.send({type:0,focus:s})},selectActiveOption:()=>{var s;if(this.state.activeOptionIndex!==null){let{dataRef:r}=this.state.options[this.state.activeOptionIndex];this.actions.selectOption(r.current.value)}else this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(s=this.state.buttonElement)==null||s.focus({preventScroll:!0}))},selectOption:s=>{this.send({type:5,value:s})},search:s=>{this.send({type:3,value:s})},clearSearch:()=>{this.send({type:4})},setButtonElement:s=>{this.send({type:8,element:s})},setOptionsElement:s=>{this.send({type:9,element:s})}}),qj(this,"selectors",{activeDescendantId(s){var r;let a=s.activeOptionIndex,i=s.options;return a===null||(r=i[a])==null?void 0:r.id},isActive(s,r){var a;let i=s.activeOptionIndex,c=s.options;return i!==null?((a=c[i])==null?void 0:a.id)===r:!1},hasFrozenValue(s){return s.frozenValue},shouldScrollIntoView(s,r){return s.__demoMode||s.listboxState!==0||s.activationTrigger===0?!1:this.isActive(s,r)},didButtonMove(s){return s.buttonPositionState.kind==="Moved"}}),this.on(6,()=>{requestAnimationFrame(()=>{this.send({type:10})})});{let s=this.state.id,r=pm.get(null);this.disposables.add(r.on(b1.Push,a=>{!r.selectors.isTop(a,s)&&this.state.listboxState===0&&this.actions.closeListbox()})),this.on(0,()=>r.actions.push(s)),this.on(1,()=>r.actions.pop(s))}this.disposables.group(s=>{this.on(1,r=>{r.buttonElement&&(s.dispose(),s.add(oO(r.buttonElement,r.buttonPositionState,()=>{this.send({type:11})})))})}),this.on(5,(s,r)=>{var a;this.actions.onChange(r.value),this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(a=this.state.buttonElement)==null||a.focus({preventScroll:!0}))})}static new({id:n,__demoMode:s=!1}){return new cv({id:n,dataRef:{current:{}},listboxState:s?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:sn.Nothing},frozenValue:!1,__demoMode:s,buttonPositionState:of.Idle})}reduce(n,s){return es(s.type,GO,n,s)}}const gS=p.createContext(null);function dv(e){let n=p.useContext(gS);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,xS),s}return n}function xS({id:e,__demoMode:n=!1}){let s=p.useMemo(()=>cv.new({id:e,__demoMode:n}),[]);return ov(()=>s.dispose()),s}let Cm=p.createContext(null);Cm.displayName="ListboxDataContext";function nd(e){let n=p.useContext(Cm);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,nd),s}return n}let qO=p.Fragment;function KO(e,n){let s=p.useId(),r=Xx(),{value:a,defaultValue:i,form:c,name:d,onChange:u,by:f,invalid:g=!1,disabled:b=r||!1,horizontal:x=!1,multiple:h=!1,__demoMode:v=!1,...y}=e;const j=x?"horizontal":"vertical";let k=Dn(n),E=cA(i),[S=h?[]:void 0,N]=lA(a,u,E),_=xS({id:s,__demoMode:v}),$=p.useRef({static:!1,hold:!1}),O=p.useRef(new Map),A=zA(f),L=p.useCallback(Q=>es(M.mode,{[Do.Multi]:()=>S.some(K=>A(K,Q)),[Do.Single]:()=>A(S,Q)}),[S]),M=Ks({value:S,disabled:b,invalid:g,mode:h?Do.Multi:Do.Single,orientation:j,onChange:N,compare:A,isSelected:L,optionsPropsRef:$,listRef:O});en(()=>{_.state.dataRef.current=M},[M]);let R=Yn(_,Q=>Q.listboxState),P=pm.get(null),D=Yn(P,p.useCallback(Q=>P.selectors.isTop(Q,s),[P,s])),[W,Y]=Yn(_,Q=>[Q.buttonElement,Q.optionsElement]);_1(D,[W,Y],(Q,K)=>{_.send({type:pS.CloseListbox}),S1(K,Zx.Loose)||(Q.preventDefault(),W==null||W.focus())});let H=Ks({open:R===In.Open,disabled:b,invalid:g,value:S}),[q,F]=TA({inherit:!0}),G={ref:k},U=p.useCallback(()=>{if(E!==void 0)return N==null?void 0:N(E)},[N,E]),z=Cn();return qe.createElement(F,{value:q,props:{htmlFor:W==null?void 0:W.id},slot:{open:R===In.Open,disabled:b}},qe.createElement(H4,null,qe.createElement(gS.Provider,{value:_},qe.createElement(Cm.Provider,{value:M},qe.createElement(J1,{value:es(R,{[In.Open]:Jn.Open,[In.Closed]:Jn.Closed})},d!=null&&S!=null&&qe.createElement(gA,{disabled:b,data:{[d]:S},form:c,onReset:U}),z({ourProps:G,theirProps:y,slot:H,defaultTag:qO,name:"Listbox"}))))))}let VO="button";function YO(e,n){let s=p.useId(),r=a1(),a=nd("Listbox.Button"),i=dv("Listbox.Button"),{id:c=r||`headlessui-listbox-button-${s}`,disabled:d=a.disabled||!1,autoFocus:u=!1,...f}=e,g=Dn(n,D4(),i.actions.setButtonElement),b=F4(),[x,h,v]=Yn(i,Y=>[Y.listboxState,Y.buttonElement,Y.optionsElement]),y=x===In.Open;l3(y,{trigger:h,action:p.useCallback(Y=>{if(h!=null&&h.contains(Y.target))return Ou.Ignore;let H=Y.target.closest('[role="option"]:not([data-disabled])');return Ns(H)?Ou.Select(H):v!=null&&v.contains(Y.target)?Ou.Ignore:Ou.Close},[h,v]),close:i.actions.closeListbox,select:i.actions.selectActiveOption});let j=dt(Y=>{switch(Y.key){case yn.Enter:dA(Y.currentTarget);break;case yn.Space:case yn.ArrowDown:Y.preventDefault(),i.actions.openListbox({focus:a.value?sn.Nothing:sn.First});break;case yn.ArrowUp:Y.preventDefault(),i.actions.openListbox({focus:a.value?sn.Nothing:sn.Last});break}}),k=dt(Y=>{switch(Y.key){case yn.Space:Y.preventDefault();break}}),E=FA(Y=>{var H;i.state.listboxState===In.Open?(ks.flushSync(()=>i.actions.closeListbox()),(H=i.state.buttonElement)==null||H.focus({preventScroll:!0})):(Y.preventDefault(),i.actions.openListbox({focus:sn.Nothing}))}),S=dt(Y=>Y.preventDefault()),N=h1([c]),_=SA(),{isFocusVisible:$,focusProps:O}=qR({autoFocus:u}),{isHovered:A,hoverProps:L}=YR({isDisabled:d}),{pressed:M,pressProps:R}=tA({disabled:d}),P=Ks({open:x===In.Open,active:M||x===In.Open,disabled:d,invalid:a.invalid,value:a.value,hover:A,focus:$,autofocus:u}),D=Yn(i,Y=>Y.listboxState===In.Open),W=t1(b(),{ref:g,id:c,type:c3(e,h),"aria-haspopup":"listbox","aria-controls":v==null?void 0:v.id,"aria-expanded":D,"aria-labelledby":N,"aria-describedby":_,disabled:d||void 0,autoFocus:u,onKeyDown:j,onKeyUp:k,onKeyPress:S},E,O,L,R);return Cn()({ourProps:W,theirProps:f,slot:P,defaultTag:VO,name:"Listbox.Button"})}let vS=p.createContext(!1),QO="div",JO=ol.RenderStrategy|ol.Static;function XO(e,n){let s=p.useId(),{id:r=`headlessui-listbox-options-${s}`,anchor:a,portal:i=!1,modal:c=!0,transition:d=!1,...u}=e,f=z4(a),[g,b]=p.useState(null);f&&(i=!0);let x=nd("Listbox.Options"),h=dv("Listbox.Options"),[v,y,j,k]=Yn(h,se=>[se.listboxState,se.buttonElement,se.optionsElement,se.__demoMode]),E=Lc(y),S=Lc(j),N=ed(),[_,$]=O1(d,g,N!==null?(N&Jn.Open)===Jn.Open:v===In.Open);k1(_,y,h.actions.closeListbox);let O=k?!1:c&&v===In.Open;R1(O,S);let A=k?!1:c&&v===In.Open;j1(A,{allowed:p.useCallback(()=>[y,j],[y,j])});let L=Yn(h,h.selectors.didButtonMove)?!1:_,M=Yn(h,h.selectors.hasFrozenValue)&&!e.static,R=Q1(M,x.value),P=p.useCallback(se=>x.compare(R,se),[x.compare,R]),D=Yn(h,se=>{var ue;if(f==null||!((ue=f==null?void 0:f.to)!=null&&ue.includes("selection")))return null;let xe=se.options.findIndex($e=>P($e.dataRef.current.value));return xe===-1&&(xe=0),xe}),W=(()=>{if(f==null)return;if(D===null)return{...f,inner:void 0};let se=Array.from(x.listRef.current.values());return{...f,inner:{listRef:{current:se},index:D}}})(),[Y,H]=W4(W),q=U4(),F=Dn(n,f?Y:null,h.actions.setOptionsElement,b),G=Xo();p.useEffect(()=>{let se=j;se&&v===In.Open&&(ZN(se)||se==null||se.focus({preventScroll:!0}))},[v,j]);let U=dt(se=>{var ue;switch(G.dispose(),se.key){case yn.Space:if(h.state.searchQuery!=="")return se.preventDefault(),se.stopPropagation(),h.actions.search(se.key);case yn.Enter:se.preventDefault(),se.stopPropagation(),h.actions.selectActiveOption();break;case es(x.orientation,{vertical:yn.ArrowDown,horizontal:yn.ArrowRight}):return se.preventDefault(),se.stopPropagation(),h.actions.goToOption({focus:sn.Next});case es(x.orientation,{vertical:yn.ArrowUp,horizontal:yn.ArrowLeft}):return se.preventDefault(),se.stopPropagation(),h.actions.goToOption({focus:sn.Previous});case yn.Home:case yn.PageUp:return se.preventDefault(),se.stopPropagation(),h.actions.goToOption({focus:sn.First});case yn.End:case yn.PageDown:return se.preventDefault(),se.stopPropagation(),h.actions.goToOption({focus:sn.Last});case yn.Escape:se.preventDefault(),se.stopPropagation(),ks.flushSync(()=>h.actions.closeListbox()),(ue=h.state.buttonElement)==null||ue.focus({preventScroll:!0});return;case yn.Tab:se.preventDefault(),se.stopPropagation(),ks.flushSync(()=>h.actions.closeListbox()),r3(h.state.buttonElement,se.shiftKey?ir.Previous:ir.Next);break;default:se.key.length===1&&(h.actions.search(se.key),G.setTimeout(()=>h.actions.clearSearch(),350));break}}),z=Yn(h,se=>{var ue;return(ue=se.buttonElement)==null?void 0:ue.id}),Q=Ks({open:v===In.Open}),K=t1(f?q():{},{id:r,ref:F,"aria-activedescendant":Yn(h,h.selectors.activeDescendantId),"aria-multiselectable":x.mode===Do.Multi?!0:void 0,"aria-labelledby":z,"aria-orientation":x.orientation,onKeyDown:U,role:"listbox",tabIndex:v===In.Open?0:void 0,style:{...u.style,...H,"--button-width":DA(_,y,!0).width},...A1($)}),Z=Cn(),de=p.useMemo(()=>x.mode===Do.Multi?x:{...x,isSelected:P},[x,P]);return qe.createElement(nS,{enabled:i?e.static||_:!1,ownerDocument:E},qe.createElement(Cm.Provider,{value:de},Z({ourProps:K,theirProps:u,slot:Q,defaultTag:QO,features:JO,visible:L,name:"Listbox.Options"})))}let ZO="div";function e5(e,n){let s=p.useId(),{id:r=`headlessui-listbox-option-${s}`,disabled:a=!1,value:i,...c}=e,d=p.useContext(vS)===!0,u=nd("Listbox.Option"),f=dv("Listbox.Option"),g=Yn(f,M=>f.selectors.isActive(M,r)),b=u.isSelected(i),x=p.useRef(null),h=WO(x),v=Zo({disabled:a,value:i,domRef:x,get textValue(){return h()}}),y=Dn(n,x,M=>{M?u.listRef.current.set(r,M):u.listRef.current.delete(r)}),j=Yn(f,M=>f.selectors.shouldScrollIntoView(M,r));en(()=>{if(j)return Es().requestAnimationFrame(()=>{var M,R;(R=(M=x.current)==null?void 0:M.scrollIntoView)==null||R.call(M,{block:"nearest"})})},[j,x]),en(()=>{if(!d)return f.actions.registerOption(r,v),()=>f.actions.unregisterOption(r)},[v,r,d]);let k=dt(M=>{if(a)return M.preventDefault();f.actions.selectOption(i)}),E=dt(()=>{if(a)return f.actions.goToOption({focus:sn.Nothing});f.actions.goToOption({focus:sn.Specific,id:r})}),S=g3(),N=dt(M=>S.update(M)),_=dt(M=>{S.wasMoved(M)&&(a||g&&f.state.activationTrigger===af.Pointer||f.actions.goToOption({focus:sn.Specific,id:r},af.Pointer))}),$=dt(M=>{S.wasMoved(M)&&(a||g&&f.state.activationTrigger===af.Pointer&&f.actions.goToOption({focus:sn.Nothing}))}),O=Ks({active:g,focus:g,selected:b,disabled:a,selectedOption:b&&d}),A=d?{}:{id:r,ref:y,role:"option",tabIndex:a===!0?void 0:-1,"aria-disabled":a===!0?!0:void 0,"aria-selected":b,disabled:void 0,onClick:k,onFocus:E,onPointerEnter:N,onMouseEnter:N,onPointerMove:_,onMouseMove:_,onPointerLeave:$,onMouseLeave:$},L=Cn();return!b&&d?null:L({ourProps:A,theirProps:c,slot:O,defaultTag:ZO,name:"Listbox.Option"})}let t5=p.Fragment;function n5(e,n){let{options:s,placeholder:r,...a}=e,i={ref:Dn(n)},c=nd("ListboxSelectedOption"),d=Ks({}),u=c.value===void 0||c.value===null||c.mode===Do.Multi&&Array.isArray(c.value)&&c.value.length===0,f=Cn();return qe.createElement(vS.Provider,{value:!0},f({ourProps:i,theirProps:{...a,children:qe.createElement(qe.Fragment,null,r&&u?r:s)},slot:d,defaultTag:t5,name:"ListboxSelectedOption"}))}let s5=gn(KO),yS=gn(YO),r5=MA,bS=gn(XO),wS=gn(e5),o5=gn(n5),a5=Object.assign(s5,{Button:yS,Label:r5,Options:bS,Option:wS,SelectedOption:o5});const i5={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-3xl",full:"h-full max-w-5xl"};function Em({open:e,onClose:n,title:s,description:r,footer:a,size:i="md",initialFocus:c,hideClose:d,className:u,children:f}){return t.jsxs(FO,{open:e,onClose:n,initialFocus:c,className:"relative z-dialog",children:[t.jsx(DO,{className:"fixed inset-0 bg-overlay/70"}),t.jsx("div",{className:oe("fixed inset-0 flex justify-center p-4 md:p-8",i==="full"?"items-stretch":"items-start overflow-y-auto pt-[12vh]"),children:t.jsxs(mS,{className:oe("flex w-full flex-col border border-border-strong bg-background text-foreground shadow-float",i5[i],u),children:[t.jsxs("header",{className:"flex items-start gap-3 border-b px-5 py-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx(hS,{className:"text-lg font-semibold",children:s}),r&&t.jsx(f1,{className:"mt-1 text-body text-muted-foreground",children:r})]}),!d&&t.jsx(B,{size:"icon",variant:"ghost",onClick:n,"aria-label":"Close",children:t.jsx(Jo,{"aria-hidden":!0})})]}),f&&t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4 text-body",children:f}),a&&t.jsx("footer",{className:"flex flex-wrap justify-end gap-2 border-t px-5 py-3",children:a})]})})]})}function uv({open:e,title:n,confirm:s,cancel:r="Cancel",tone:a="destructive",busy:i,onConfirm:c,onCancel:d,children:u}){const f=p.useRef(null);return t.jsx(Em,{open:e,onClose:i?()=>{}:d,title:n,size:"sm",hideClose:!0,initialFocus:f,footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{ref:f,size:"sm",onClick:d,disabled:i,children:r}),t.jsx(B,{size:"sm",variant:a,onClick:c,disabled:i,"aria-busy":i||void 0,children:s})]}),children:u})}const fv=p.createContext(null),l5=()=>p.useContext(fv);function mv(e){const n=p.useContext(fv);return{id:e.id??(n==null?void 0:n.id),"aria-describedby":e["aria-describedby"]??(n==null?void 0:n.describedBy),"aria-invalid":e["aria-invalid"]??((n==null?void 0:n.invalid)||void 0),"aria-required":e["aria-required"]??((n==null?void 0:n.required)&&!e.required||void 0)}}function jt({label:e,id:n,required:s,optional:r,note:a,hint:i,error:c,warning:d,aside:u,group:f,className:g,children:b}){const x=p.useId(),h=n??`${x}-control`,[v,y,j,k,E]=[`${x}-label`,`${x}-note`,`${x}-hint`,`${x}-error`,`${x}-warning`],S=[a&&y,i&&j,c&&k,d&&E].filter(Boolean).join(" ")||void 0,N=t.jsxs(t.Fragment,{children:[e,s&&t.jsx("span",{className:"text-destructive-text","aria-hidden":!0,children:" *"}),r&&t.jsx("span",{className:"font-normal normal-case text-muted-foreground",children:" (optional)"})]});return t.jsxs("div",{className:g,...f===!0?{role:"group","aria-labelledby":v,"aria-describedby":S}:{},children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[f?t.jsx("span",{id:v,className:"caps text-small font-semibold",children:N}):t.jsx("label",{id:v,htmlFor:h,className:"caps text-small font-semibold",children:N}),u]}),a&&t.jsx("p",{id:y,className:"-mt-1 mb-2 text-small text-muted-foreground",children:a}),t.jsx(fv.Provider,{value:f?null:{id:h,describedBy:S,invalid:!!c,required:!!s},children:b}),i&&t.jsx("p",{id:j,className:"mt-1.5 text-small text-muted-foreground",children:i}),c&&t.jsx("p",{id:k,className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),d&&t.jsx("p",{id:E,className:"mt-2 font-mono text-small text-warning-text",children:d})]})}const jS="w-full border border-input bg-background px-3 font-mono text-body placeholder:text-muted-foreground hover:border-foreground/60 focus-visible:outline-offset-0 read-only:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-45 aria-[invalid=true]:border-destructive",kS="min-w-0 bg-transparent font-mono text-body outline-none placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",$m="xl:columns-2 xl:gap-x-10 2xl:columns-3 [&>*]:mb-5 [&>*]:mt-0 [&>*]:break-inside-avoid",Fc="border border-input bg-background hover:border-foreground/60 focus-within:outline focus-within:outline-focus focus-within:outline-ring",ze=p.forwardRef(({className:e,fieldSize:n="md",bare:s,...r},a)=>t.jsx("input",{ref:a,...r,...mv(r),className:oe(s?kS:oe(jS,n==="sm"?"h-control-sm":"h-control-md"),e)}));ze.displayName="Input";const dn=p.forwardRef(({className:e,bare:n,...s},r)=>t.jsx("textarea",{ref:r,...s,...mv(s),className:oe(n?kS:oe(jS,"py-2.5"),e)}));dn.displayName="Textarea";const NS=e=>{const n=p.forwardRef(({label:s,note:r,className:a,disabled:i,...c},d)=>t.jsxs("label",{className:oe("flex items-start gap-2.5 text-body",i?"cursor-not-allowed opacity-45":"cursor-pointer",a),children:[t.jsx("input",{ref:d,type:e,disabled:i,...c,...mv(c),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block",children:s}),r&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:r})]})]}));return n.displayName=e==="checkbox"?"Checkbox":"Radio",n},c5=NS("checkbox");NS("radio");function xr({icon:e,active:n,className:s,children:r,...a}){return t.jsxs("button",{type:"button","aria-current":n?"page":void 0,...a,className:oe("flex min-h-11 items-center gap-2.5 p-3 text-left text-body -outline-offset-2 hover:bg-accent",n&&"!rounded-action bg-primary/[0.06] text-primary-text hover:bg-primary/10",s),children:[e&&t.jsx(e,{className:"size-4 shrink-0","aria-hidden":!0})," ",r]})}function Rt({value:e,onChange:n,options:s,label:r,id:a,className:i,disabled:c=!1,name:d,small:u=!1,placeholder:f,autoFocus:g}){const b=s.find(h=>h.value===e),x=l5();return t.jsxs(a5,{value:e,onChange:n,disabled:c,name:d,children:[t.jsxs(yS,{id:a??(x==null?void 0:x.id),autoFocus:g,"aria-label":r,"aria-describedby":x==null?void 0:x.describedBy,"aria-invalid":(x==null?void 0:x.invalid)||void 0,"data-value":e,className:oe("flex min-w-0 items-center justify-between gap-2 border border-input bg-background text-left font-mono hover:border-foreground/60 focus-visible:outline-offset-0 disabled:opacity-60 data-[open]:border-foreground",u?"h-control-sm px-2 text-small":"h-control-md px-3 text-body",i),children:[t.jsx("span",{className:oe("min-w-0 truncate",!b&&"text-muted-foreground"),children:(b==null?void 0:b.label)??f??""}),t.jsx(Rr,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsx(bS,{anchor:"bottom start","data-picker-list":"",className:"z-popover max-h-72 w-[var(--button-width)] min-w-[12rem] overflow-auto border border-border-strong bg-background py-1 font-mono text-body shadow-float outline-none [--anchor-gap:2px] [--anchor-padding:8px]",children:s.map(h=>t.jsxs(wS,{value:h.value,disabled:h.disabled,title:h.title,"data-value":h.value,className:"group flex min-h-10 cursor-pointer items-center gap-2 px-3 py-2 data-[disabled]:cursor-not-allowed data-[focus]:bg-accent data-[disabled]:opacity-50 data-[selected]:text-foreground",children:[t.jsx(hl,{className:"invisible size-3.5 shrink-0 text-primary-text group-data-[selected]:visible","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 break-words",children:h.label}),h.tag&&t.jsx(Ne,{tone:"success",className:"ml-auto",children:h.tag})]},h.value))})]})}function sd({value:e,onChange:n,options:s,label:r,name:a,size:i="md",className:c}){return t.jsx("div",{role:"radiogroup","aria-label":r,className:oe("inline-flex",c),children:s.map(d=>t.jsxs("label",{title:d.title,className:oe("caps -ml-px inline-flex items-center justify-center gap-1.5 border first:ml-0 has-[:focus-visible]:relative has-[:focus-visible]:outline has-[:focus-visible]:outline-focus has-[:focus-visible]:outline-offset-focus has-[:focus-visible]:outline-ring [&_svg]:size-3.5",i==="sm"?"h-control-sm px-2.5 text-label":"h-control-md px-3 text-small",d.disabled?"cursor-not-allowed opacity-45":"cursor-pointer",e===d.value?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[t.jsx("input",{type:"radio",name:a,value:d.value,checked:e===d.value,disabled:d.disabled,onChange:()=>n(d.value),className:"sr-only"}),d.label]},d.value))})}const d5=["appearance-none bg-transparent","[&::-webkit-slider-runnable-track]:h-0.5 [&::-webkit-slider-runnable-track]:bg-border-strong","[&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-3 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:bg-foreground","[&::-moz-range-track]:h-0.5 [&::-moz-range-track]:bg-border-strong","[&::-moz-range-thumb]:size-3 [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-foreground"].join(" ");function u5({value:e,onChange:n,min:s,max:r,label:a,valueText:i,className:c,disabled:d=!1}){return t.jsx("input",{type:"range",min:s,max:r,step:1,value:e,disabled:d,"aria-label":a,"aria-valuetext":i,onChange:u=>n(Number(u.target.value)),className:oe(d5,"h-control-sm cursor-pointer disabled:cursor-not-allowed disabled:opacity-45",c)})}function f5({label:e,className:n}){return t.jsxs("span",{role:e?"status":void 0,className:"inline-flex",children:[t.jsx(NT,{className:oe("size-4 animate-spin text-run-active",n),"aria-hidden":!0}),e&&t.jsx("span",{className:"sr-only",children:e})]})}function _m({checked:e,onChange:n,disabled:s,label:r,labelledBy:a,busy:i,className:c}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":r,"aria-labelledby":a,"aria-busy":i||void 0,disabled:s||i,onClick:()=>n(!e),className:oe("relative inline-flex h-5 w-9 shrink-0 items-center border transition-colors disabled:cursor-not-allowed disabled:opacity-45",e?"border-primary bg-primary/20":"border-border-strong bg-background hover:border-foreground/60",i&&"motion-safe:animate-pulse",c),children:t.jsx("span",{"aria-hidden":!0,className:oe("absolute top-1/2 size-3 -translate-y-1/2 transition-[left,background-color] duration-fast",e?"left-[calc(100%-16px)] bg-primary":"left-[3px] bg-muted-foreground")})})}const SS="flex shrink-0 gap-x-4 overflow-x-auto border-b px-5 md:px-8",CS=e=>oe("caps whitespace-nowrap border-b-2 px-1 py-3 text-small -outline-offset-2 first:-ml-1 max-sm:py-2.5",e?"border-primary text-primary-text":"border-transparent text-muted-foreground hover:text-foreground");function ES({tabs:e,value:n,onChange:s,label:r,id:a,className:i}){var f;const c=e.some(g=>g.id===n)?n:(f=e[0])==null?void 0:f.id,d=p.useRef(null),u=g=>{var h,v;const b=e.findIndex(y=>y.id===n),x=g.key==="ArrowRight"?(b+1)%e.length:g.key==="ArrowLeft"?(b-1+e.length)%e.length:g.key==="Home"?0:g.key==="End"?e.length-1:-1;x<0||x===b||(g.preventDefault(),s(e[x].id),(v=(h=d.current)==null?void 0:h.querySelectorAll('[role="tab"]')[x])==null||v.focus())};return t.jsx("div",{ref:d,role:"tablist","aria-label":r,onKeyDown:u,className:oe(SS,i),children:e.map(g=>t.jsx("button",{type:"button",role:"tab",id:a&&`${a}-tab-${g.id}`,"aria-controls":a&&`${a}-panel-${g.id}`,"aria-selected":n===g.id,tabIndex:c===g.id?0:-1,onClick:()=>s(g.id),className:CS(n===g.id),children:g.label},g.id))})}const m5=(e,n)=>({role:"tabpanel",id:`${e}-panel-${n}`,"aria-labelledby":`${e}-tab-${n}`});function h5({tip:e,children:n,className:s,align:r="start"}){const a=p.useId();return t.jsxs("span",{className:oe("group/tip relative inline-flex",s),children:[p.cloneElement(n,{"aria-describedby":a}),t.jsx("span",{role:"tooltip",id:a,className:oe("pointer-events-none absolute top-full z-popover mt-1.5 hidden w-max max-w-[min(20rem,80vw)] border border-border-strong bg-card px-3 py-2 text-left font-sans text-small normal-case leading-snug tracking-normal text-card-foreground shadow-float group-hover/tip:block group-focus-within/tip:block",r==="end"?"right-0":"left-0"),children:e})]})}const $S=p.createContext(null),p5={neutral:[Tg,"text-muted-foreground"],success:[SN,"text-success-text"],warning:[Gs,"text-warning-text"],error:[nl,"text-destructive-text"]},g5=5e3;function x5(){return p.useContext($S)??v5}const v5=()=>{};function y5({toast:e,done:n}){const s=p.useCallback(()=>n(e.id),[n,e.id]),r=e.tone??"neutral",a=e.duration??(r==="error"?0:g5),[i,c]=p.useState(!1),[d,u]=p.useState(!1),f=i||d;p.useEffect(()=>{if(!a||f)return;const x=setTimeout(s,a);return()=>clearTimeout(x)},[a,f,s]);const[g,b]=p5[r];return t.jsxs("div",{role:r==="error"?"alert":"status",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>u(!0),onBlur:()=>u(!1),className:"pointer-events-auto flex w-full items-start gap-3 border border-border-strong bg-card p-3 text-body text-card-foreground shadow-float motion-safe:animate-toast-in",children:[t.jsx(g,{className:oe("mt-0.5 size-4 shrink-0",b),"aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"font-semibold",children:e.title}),e.description&&t.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:e.description})]}),t.jsx("button",{type:"button",onClick:s,"aria-label":"Dismiss",className:"-m-1 shrink-0 p-1 text-muted-foreground hover:text-foreground",children:t.jsx(Jo,{className:"size-3.5","aria-hidden":!0})})]})}function b5({children:e}){const[n,s]=p.useState([]),r=p.useRef(0),a=p.useCallback(c=>s(d=>[...d,{...c,id:r.current++}].slice(-3)),[]),i=p.useCallback(c=>s(d=>d.filter(u=>u.id!==c)),[]);return t.jsxs($S.Provider,{value:a,children:[e,t.jsx("div",{role:"region","aria-label":"Notifications","aria-live":"polite",className:"pointer-events-none fixed inset-x-4 bottom-4 z-toast flex flex-col gap-2 sm:left-auto sm:w-[22rem]",children:n.map(c=>t.jsx(y5,{toast:c,done:i},c.id))})]})}/*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */const{entries:_S,setPrototypeOf:Vj,isFrozen:w5,getPrototypeOf:j5,getOwnPropertyDescriptor:k5}=Object;let{freeze:ts,seal:Vs,create:TS}=Object,{apply:Bg,construct:Gg}=typeof Reflect<"u"&&Reflect;ts||(ts=function(n){return n});Vs||(Vs=function(n){return n});Bg||(Bg=function(n,s,r){return n.apply(s,r)});Gg||(Gg=function(n,s){return new n(...s)});const Lu=Ss(Array.prototype.forEach),Yj=Ss(Array.prototype.pop),ic=Ss(Array.prototype.push),lf=Ss(String.prototype.toLowerCase),tg=Ss(String.prototype.toString),Qj=Ss(String.prototype.match),lc=Ss(String.prototype.replace),N5=Ss(String.prototype.indexOf),S5=Ss(String.prototype.trim),or=Ss(Object.prototype.hasOwnProperty),Vn=Ss(RegExp.prototype.test),cc=C5(TypeError);function Ss(e){return function(n){for(var s=arguments.length,r=new Array(s>1?s-1:0),a=1;a<s;a++)r[a-1]=arguments[a];return Bg(e,n,r)}}function C5(e){return function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];return Gg(e,s)}}function yt(e,n){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:lf;Vj&&Vj(e,null);let r=n.length;for(;r--;){let a=n[r];if(typeof a=="string"){const i=s(a);i!==a&&(w5(n)||(n[r]=i),a=i)}e[a]=!0}return e}function E5(e){for(let n=0;n<e.length;n++)or(e,n)||(e[n]=null);return e}function ka(e){const n=TS(null);for(const[s,r]of _S(e))or(e,s)&&(Array.isArray(r)?n[s]=E5(r):r&&typeof r=="object"&&r.constructor===Object?n[s]=ka(r):n[s]=r);return n}function dc(e,n){for(;e!==null;){const r=k5(e,n);if(r){if(r.get)return Ss(r.get);if(typeof r.value=="function")return Ss(r.value)}e=j5(e)}function s(){return null}return s}const Jj=ts(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ng=ts(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),sg=ts(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),$5=ts(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),rg=ts(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),_5=ts(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Xj=ts(["#text"]),Zj=ts(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),og=ts(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ek=ts(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Iu=ts(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),T5=Vs(/\{\{[\w\W]*|[\w\W]*\}\}/gm),R5=Vs(/<%[\w\W]*|[\w\W]*%>/gm),A5=Vs(/\$\{[\w\W]*}/gm),O5=Vs(/^data-[\-\w.\u00B7-\uFFFF]+$/),M5=Vs(/^aria-[\-\w]+$/),RS=Vs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),P5=Vs(/^(?:\w+script|data):/i),L5=Vs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),AS=Vs(/^html$/i),I5=Vs(/^[a-z][.\w]*(-[.\w]+)+$/i);var tk=Object.freeze({__proto__:null,ARIA_ATTR:M5,ATTR_WHITESPACE:L5,CUSTOM_ELEMENT:I5,DATA_ATTR:O5,DOCTYPE_NAME:AS,ERB_EXPR:R5,IS_ALLOWED_URI:RS,IS_SCRIPT_OR_DATA:P5,MUSTACHE_EXPR:T5,TMPLIT_EXPR:A5});const uc={element:1,text:3,progressingInstruction:7,comment:8,document:9},z5=function(){return typeof window>"u"?null:window},D5=function(n,s){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let r=null;const a="data-tt-policy-suffix";s&&s.hasAttribute(a)&&(r=s.getAttribute(a));const i="dompurify"+(r?"#"+r:"");try{return n.createPolicy(i,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},nk=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function OS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:z5();const n=He=>OS(He);if(n.version="3.2.3",n.removed=[],!e||!e.document||e.document.nodeType!==uc.document)return n.isSupported=!1,n;let{document:s}=e;const r=s,a=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:c,Node:d,Element:u,NodeFilter:f,NamedNodeMap:g=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:b,DOMParser:x,trustedTypes:h}=e,v=u.prototype,y=dc(v,"cloneNode"),j=dc(v,"remove"),k=dc(v,"nextSibling"),E=dc(v,"childNodes"),S=dc(v,"parentNode");if(typeof c=="function"){const He=s.createElement("template");He.content&&He.content.ownerDocument&&(s=He.content.ownerDocument)}let N,_="";const{implementation:$,createNodeIterator:O,createDocumentFragment:A,getElementsByTagName:L}=s,{importNode:M}=r;let R=nk();n.isSupported=typeof _S=="function"&&typeof S=="function"&&$&&$.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:P,ERB_EXPR:D,TMPLIT_EXPR:W,DATA_ATTR:Y,ARIA_ATTR:H,IS_SCRIPT_OR_DATA:q,ATTR_WHITESPACE:F,CUSTOM_ELEMENT:G}=tk;let{IS_ALLOWED_URI:U}=tk,z=null;const Q=yt({},[...Jj,...ng,...sg,...rg,...Xj]);let K=null;const Z=yt({},[...Zj,...og,...ek,...Iu]);let de=Object.seal(TS(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),se=null,ue=null,xe=!0,$e=!0,ge=!1,fe=!0,me=!1,je=!0,Me=!1,_e=!1,re=!1,Re=!1,Ze=!1,at=!1,pt=!0,Ee=!1;const Je="user-content-";let he=!0,Fe=!1,ut={},Pe=null;const ct=yt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let _t=null;const tt=yt({},["audio","video","img","source","image","track"]);let ft=null;const qt=yt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),zt="http://www.w3.org/1998/Math/MathML",ye="http://www.w3.org/2000/svg",le="http://www.w3.org/1999/xhtml";let Ue=le,Xe=!1,rt=null;const J=yt({},[zt,ye,le],tg);let ve=yt({},["mi","mo","mn","ms","mtext"]),We=yt({},["annotation-xml"]);const Se=yt({},["title","style","font","a","script"]);let Ye=null;const Nt=["application/xhtml+xml","text/html"],It="text/html";let ot=null,Rn=null;const hs=s.createElement("form"),Ys=function(te){return te instanceof RegExp||te instanceof Function},En=function(){let te=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Rn&&Rn===te)){if((!te||typeof te!="object")&&(te={}),te=ka(te),Ye=Nt.indexOf(te.PARSER_MEDIA_TYPE)===-1?It:te.PARSER_MEDIA_TYPE,ot=Ye==="application/xhtml+xml"?tg:lf,z=or(te,"ALLOWED_TAGS")?yt({},te.ALLOWED_TAGS,ot):Q,K=or(te,"ALLOWED_ATTR")?yt({},te.ALLOWED_ATTR,ot):Z,rt=or(te,"ALLOWED_NAMESPACES")?yt({},te.ALLOWED_NAMESPACES,tg):J,ft=or(te,"ADD_URI_SAFE_ATTR")?yt(ka(qt),te.ADD_URI_SAFE_ATTR,ot):qt,_t=or(te,"ADD_DATA_URI_TAGS")?yt(ka(tt),te.ADD_DATA_URI_TAGS,ot):tt,Pe=or(te,"FORBID_CONTENTS")?yt({},te.FORBID_CONTENTS,ot):ct,se=or(te,"FORBID_TAGS")?yt({},te.FORBID_TAGS,ot):{},ue=or(te,"FORBID_ATTR")?yt({},te.FORBID_ATTR,ot):{},ut=or(te,"USE_PROFILES")?te.USE_PROFILES:!1,xe=te.ALLOW_ARIA_ATTR!==!1,$e=te.ALLOW_DATA_ATTR!==!1,ge=te.ALLOW_UNKNOWN_PROTOCOLS||!1,fe=te.ALLOW_SELF_CLOSE_IN_ATTR!==!1,me=te.SAFE_FOR_TEMPLATES||!1,je=te.SAFE_FOR_XML!==!1,Me=te.WHOLE_DOCUMENT||!1,Re=te.RETURN_DOM||!1,Ze=te.RETURN_DOM_FRAGMENT||!1,at=te.RETURN_TRUSTED_TYPE||!1,re=te.FORCE_BODY||!1,pt=te.SANITIZE_DOM!==!1,Ee=te.SANITIZE_NAMED_PROPS||!1,he=te.KEEP_CONTENT!==!1,Fe=te.IN_PLACE||!1,U=te.ALLOWED_URI_REGEXP||RS,Ue=te.NAMESPACE||le,ve=te.MATHML_TEXT_INTEGRATION_POINTS||ve,We=te.HTML_INTEGRATION_POINTS||We,de=te.CUSTOM_ELEMENT_HANDLING||{},te.CUSTOM_ELEMENT_HANDLING&&Ys(te.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(de.tagNameCheck=te.CUSTOM_ELEMENT_HANDLING.tagNameCheck),te.CUSTOM_ELEMENT_HANDLING&&Ys(te.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(de.attributeNameCheck=te.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),te.CUSTOM_ELEMENT_HANDLING&&typeof te.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=te.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),me&&($e=!1),Ze&&(Re=!0),ut&&(z=yt({},Xj),K=[],ut.html===!0&&(yt(z,Jj),yt(K,Zj)),ut.svg===!0&&(yt(z,ng),yt(K,og),yt(K,Iu)),ut.svgFilters===!0&&(yt(z,sg),yt(K,og),yt(K,Iu)),ut.mathMl===!0&&(yt(z,rg),yt(K,ek),yt(K,Iu))),te.ADD_TAGS&&(z===Q&&(z=ka(z)),yt(z,te.ADD_TAGS,ot)),te.ADD_ATTR&&(K===Z&&(K=ka(K)),yt(K,te.ADD_ATTR,ot)),te.ADD_URI_SAFE_ATTR&&yt(ft,te.ADD_URI_SAFE_ATTR,ot),te.FORBID_CONTENTS&&(Pe===ct&&(Pe=ka(Pe)),yt(Pe,te.FORBID_CONTENTS,ot)),he&&(z["#text"]=!0),Me&&yt(z,["html","head","body"]),z.table&&(yt(z,["tbody"]),delete se.tbody),te.TRUSTED_TYPES_POLICY){if(typeof te.TRUSTED_TYPES_POLICY.createHTML!="function")throw cc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof te.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=te.TRUSTED_TYPES_POLICY,_=N.createHTML("")}else N===void 0&&(N=D5(h,a)),N!==null&&typeof _=="string"&&(_=N.createHTML(""));ts&&ts(te),Rn=te}},Un=yt({},[...ng,...sg,...$5]),ps=yt({},[...rg,..._5]),gs=function(te){let be=S(te);(!be||!be.tagName)&&(be={namespaceURI:Ue,tagName:"template"});const Ge=lf(te.tagName),kt=lf(be.tagName);return rt[te.namespaceURI]?te.namespaceURI===ye?be.namespaceURI===le?Ge==="svg":be.namespaceURI===zt?Ge==="svg"&&(kt==="annotation-xml"||ve[kt]):!!Un[Ge]:te.namespaceURI===zt?be.namespaceURI===le?Ge==="math":be.namespaceURI===ye?Ge==="math"&&We[kt]:!!ps[Ge]:te.namespaceURI===le?be.namespaceURI===ye&&!We[kt]||be.namespaceURI===zt&&!ve[kt]?!1:!ps[Ge]&&(Se[Ge]||!Un[Ge]):!!(Ye==="application/xhtml+xml"&&rt[te.namespaceURI]):!1},fn=function(te){ic(n.removed,{element:te});try{S(te).removeChild(te)}catch{j(te)}},Wn=function(te,be){try{ic(n.removed,{attribute:be.getAttributeNode(te),from:be})}catch{ic(n.removed,{attribute:null,from:be})}if(be.removeAttribute(te),te==="is")if(Re||Ze)try{fn(be)}catch{}else try{be.setAttribute(te,"")}catch{}},$s=function(te){let be=null,Ge=null;if(re)te="<remove></remove>"+te;else{const it=Qj(te,/^[\r\n\t ]+/);Ge=it&&it[0]}Ye==="application/xhtml+xml"&&Ue===le&&(te='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+te+"</body></html>");const kt=N?N.createHTML(te):te;if(Ue===le)try{be=new x().parseFromString(kt,Ye)}catch{}if(!be||!be.documentElement){be=$.createDocument(Ue,"template",null);try{be.documentElement.innerHTML=Xe?_:kt}catch{}}const Pt=be.body||be.documentElement;return te&&Ge&&Pt.insertBefore(s.createTextNode(Ge),Pt.childNodes[0]||null),Ue===le?L.call(be,Me?"html":"body")[0]:Me?be.documentElement:Pt},Hn=function(te){return O.call(te.ownerDocument||te,te,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},_s=function(te){return te instanceof b&&(typeof te.nodeName!="string"||typeof te.textContent!="string"||typeof te.removeChild!="function"||!(te.attributes instanceof g)||typeof te.removeAttribute!="function"||typeof te.setAttribute!="function"||typeof te.namespaceURI!="string"||typeof te.insertBefore!="function"||typeof te.hasChildNodes!="function")},Ts=function(te){return typeof d=="function"&&te instanceof d};function An(He,te,be){Lu(He,Ge=>{Ge.call(n,te,be,Rn)})}const ee=function(te){let be=null;if(An(R.beforeSanitizeElements,te,null),_s(te))return fn(te),!0;const Ge=ot(te.nodeName);if(An(R.uponSanitizeElement,te,{tagName:Ge,allowedTags:z}),te.hasChildNodes()&&!Ts(te.firstElementChild)&&Vn(/<[/\w]/g,te.innerHTML)&&Vn(/<[/\w]/g,te.textContent)||te.nodeType===uc.progressingInstruction||je&&te.nodeType===uc.comment&&Vn(/<[/\w]/g,te.data))return fn(te),!0;if(!z[Ge]||se[Ge]){if(!se[Ge]&&mt(Ge)&&(de.tagNameCheck instanceof RegExp&&Vn(de.tagNameCheck,Ge)||de.tagNameCheck instanceof Function&&de.tagNameCheck(Ge)))return!1;if(he&&!Pe[Ge]){const kt=S(te)||te.parentNode,Pt=E(te)||te.childNodes;if(Pt&&kt){const it=Pt.length;for(let bn=it-1;bn>=0;--bn){const $n=y(Pt[bn],!0);$n.__removalCount=(te.__removalCount||0)+1,kt.insertBefore($n,k(te))}}}return fn(te),!0}return te instanceof u&&!gs(te)||(Ge==="noscript"||Ge==="noembed"||Ge==="noframes")&&Vn(/<\/no(script|embed|frames)/i,te.innerHTML)?(fn(te),!0):(me&&te.nodeType===uc.text&&(be=te.textContent,Lu([P,D,W],kt=>{be=lc(be,kt," ")}),te.textContent!==be&&(ic(n.removed,{element:te.cloneNode()}),te.textContent=be)),An(R.afterSanitizeElements,te,null),!1)},Le=function(te,be,Ge){if(pt&&(be==="id"||be==="name")&&(Ge in s||Ge in hs))return!1;if(!($e&&!ue[be]&&Vn(Y,be))){if(!(xe&&Vn(H,be))){if(!K[be]||ue[be]){if(!(mt(te)&&(de.tagNameCheck instanceof RegExp&&Vn(de.tagNameCheck,te)||de.tagNameCheck instanceof Function&&de.tagNameCheck(te))&&(de.attributeNameCheck instanceof RegExp&&Vn(de.attributeNameCheck,be)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(be))||be==="is"&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&Vn(de.tagNameCheck,Ge)||de.tagNameCheck instanceof Function&&de.tagNameCheck(Ge))))return!1}else if(!ft[be]){if(!Vn(U,lc(Ge,F,""))){if(!((be==="src"||be==="xlink:href"||be==="href")&&te!=="script"&&N5(Ge,"data:")===0&&_t[te])){if(!(ge&&!Vn(q,lc(Ge,F,"")))){if(Ge)return!1}}}}}}return!0},mt=function(te){return te!=="annotation-xml"&&Qj(te,G)},At=function(te){An(R.beforeSanitizeAttributes,te,null);const{attributes:be}=te;if(!be||_s(te))return;const Ge={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:K,forceKeepAttr:void 0};let kt=be.length;for(;kt--;){const Pt=be[kt],{name:it,namespaceURI:bn,value:$n}=Pt,ur=ot(it);let Wt=it==="value"?$n:S5($n);if(Ge.attrName=ur,Ge.attrValue=Wt,Ge.keepAttr=!0,Ge.forceKeepAttr=void 0,An(R.uponSanitizeAttribute,te,Ge),Wt=Ge.attrValue,Ee&&(ur==="id"||ur==="name")&&(Wn(it,te),Wt=Je+Wt),je&&Vn(/((--!?|])>)|<\/(style|title)/i,Wt)){Wn(it,te);continue}if(Ge.forceKeepAttr||(Wn(it,te),!Ge.keepAttr))continue;if(!fe&&Vn(/\/>/i,Wt)){Wn(it,te);continue}me&&Lu([P,D,W],io=>{Wt=lc(Wt,io," ")});const si=ot(te.nodeName);if(Le(si,ur,Wt)){if(N&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!bn)switch(h.getAttributeType(si,ur)){case"TrustedHTML":{Wt=N.createHTML(Wt);break}case"TrustedScriptURL":{Wt=N.createScriptURL(Wt);break}}try{bn?te.setAttributeNS(bn,it,Wt):te.setAttribute(it,Wt),_s(te)?fn(te):Yj(n.removed)}catch{}}}An(R.afterSanitizeAttributes,te,null)},Qt=function He(te){let be=null;const Ge=Hn(te);for(An(R.beforeSanitizeShadowDOM,te,null);be=Ge.nextNode();)An(R.uponSanitizeShadowNode,be,null),ee(be),At(be),be.content instanceof i&&He(be.content);An(R.afterSanitizeShadowDOM,te,null)};return n.sanitize=function(He){let te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},be=null,Ge=null,kt=null,Pt=null;if(Xe=!He,Xe&&(He="<!-->"),typeof He!="string"&&!Ts(He))if(typeof He.toString=="function"){if(He=He.toString(),typeof He!="string")throw cc("dirty is not a string, aborting")}else throw cc("toString is not a function");if(!n.isSupported)return He;if(_e||En(te),n.removed=[],typeof He=="string"&&(Fe=!1),Fe){if(He.nodeName){const $n=ot(He.nodeName);if(!z[$n]||se[$n])throw cc("root node is forbidden and cannot be sanitized in-place")}}else if(He instanceof d)be=$s("<!---->"),Ge=be.ownerDocument.importNode(He,!0),Ge.nodeType===uc.element&&Ge.nodeName==="BODY"||Ge.nodeName==="HTML"?be=Ge:be.appendChild(Ge);else{if(!Re&&!me&&!Me&&He.indexOf("<")===-1)return N&&at?N.createHTML(He):He;if(be=$s(He),!be)return Re?null:at?_:""}be&&re&&fn(be.firstChild);const it=Hn(Fe?He:be);for(;kt=it.nextNode();)ee(kt),At(kt),kt.content instanceof i&&Qt(kt.content);if(Fe)return He;if(Re){if(Ze)for(Pt=A.call(be.ownerDocument);be.firstChild;)Pt.appendChild(be.firstChild);else Pt=be;return(K.shadowroot||K.shadowrootmode)&&(Pt=M.call(r,Pt,!0)),Pt}let bn=Me?be.outerHTML:be.innerHTML;return Me&&z["!doctype"]&&be.ownerDocument&&be.ownerDocument.doctype&&be.ownerDocument.doctype.name&&Vn(AS,be.ownerDocument.doctype.name)&&(bn="<!DOCTYPE "+be.ownerDocument.doctype.name+`>
|
|
518
|
+
`+bn),me&&Lu([P,D,W],$n=>{bn=lc(bn,$n," ")}),N&&at?N.createHTML(bn):bn},n.setConfig=function(){let He=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};En(He),_e=!0},n.clearConfig=function(){Rn=null,_e=!1},n.isValidAttribute=function(He,te,be){Rn||En({});const Ge=ot(He),kt=ot(te);return Le(Ge,kt,be)},n.addHook=function(He,te){typeof te=="function"&&ic(R[He],te)},n.removeHook=function(He){return Yj(R[He])},n.removeHooks=function(He){R[He]=[]},n.removeAllHooks=function(){R=nk()},n}var cf=OS();function hv(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Ja=hv();function MS(e){Ja=e}const $c={exec:()=>null};function Lt(e,n=""){let s=typeof e=="string"?e:e.source;const r={replace:(a,i)=>{let c=typeof i=="string"?i:i.source;return c=c.replace(Xn.caret,"$1"),s=s.replace(a,c),r},getRegex:()=>new RegExp(s,n)};return r}const Xn={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},F5=/^(?:[ \t]*(?:\n|$))+/,U5=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,W5=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,rd=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,H5=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,PS=/(?:[*+-]|\d{1,9}[.)])/,LS=Lt(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,PS).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),pv=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,B5=/^[^\n]+/,gv=/(?!\s*\])(?:\\.|[^\[\]\\])+/,G5=Lt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",gv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),q5=Lt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,PS).getRegex(),Tm="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",xv=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,K5=Lt("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",xv).replace("tag",Tm).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),IS=Lt(pv).replace("hr",rd).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Tm).getRegex(),V5=Lt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",IS).getRegex(),vv={blockquote:V5,code:U5,def:G5,fences:W5,heading:H5,hr:rd,html:K5,lheading:LS,list:q5,newline:F5,paragraph:IS,table:$c,text:B5},sk=Lt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",rd).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Tm).getRegex(),Y5={...vv,table:sk,paragraph:Lt(pv).replace("hr",rd).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",sk).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Tm).getRegex()},Q5={...vv,html:Lt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",xv).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:$c,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Lt(pv).replace("hr",rd).replace("heading",` *#{1,6} *[^
|
|
519
|
+
]`).replace("lheading",LS).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},J5=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,X5=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,zS=/^( {2,}|\\)\n(?!\s*$)/,Z5=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Rm=/[\p{P}\p{S}]/u,yv=/[\s\p{P}\p{S}]/u,DS=/[^\s\p{P}\p{S}]/u,eM=Lt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,yv).getRegex(),FS=/(?!~)[\p{P}\p{S}]/u,tM=/(?!~)[\s\p{P}\p{S}]/u,nM=/(?:[^\s\p{P}\p{S}]|~)/u,sM=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,US=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,rM=Lt(US,"u").replace(/punct/g,Rm).getRegex(),oM=Lt(US,"u").replace(/punct/g,FS).getRegex(),WS="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",aM=Lt(WS,"gu").replace(/notPunctSpace/g,DS).replace(/punctSpace/g,yv).replace(/punct/g,Rm).getRegex(),iM=Lt(WS,"gu").replace(/notPunctSpace/g,nM).replace(/punctSpace/g,tM).replace(/punct/g,FS).getRegex(),lM=Lt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,DS).replace(/punctSpace/g,yv).replace(/punct/g,Rm).getRegex(),cM=Lt(/\\(punct)/,"gu").replace(/punct/g,Rm).getRegex(),dM=Lt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),uM=Lt(xv).replace("(?:-->|$)","-->").getRegex(),fM=Lt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",uM).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Sf=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,mM=Lt(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Sf).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),HS=Lt(/^!?\[(label)\]\[(ref)\]/).replace("label",Sf).replace("ref",gv).getRegex(),BS=Lt(/^!?\[(ref)\](?:\[\])?/).replace("ref",gv).getRegex(),hM=Lt("reflink|nolink(?!\\()","g").replace("reflink",HS).replace("nolink",BS).getRegex(),bv={_backpedal:$c,anyPunctuation:cM,autolink:dM,blockSkip:sM,br:zS,code:X5,del:$c,emStrongLDelim:rM,emStrongRDelimAst:aM,emStrongRDelimUnd:lM,escape:J5,link:mM,nolink:BS,punctuation:eM,reflink:HS,reflinkSearch:hM,tag:fM,text:Z5,url:$c},pM={...bv,link:Lt(/^!?\[(label)\]\((.*?)\)/).replace("label",Sf).getRegex(),reflink:Lt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Sf).getRegex()},qg={...bv,emStrongRDelimAst:iM,emStrongLDelim:oM,url:Lt(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},gM={...qg,br:Lt(zS).replace("{2,}","*").getRegex(),text:Lt(qg.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},zu={normal:vv,gfm:Y5,pedantic:Q5},fc={normal:bv,gfm:qg,breaks:gM,pedantic:pM},xM={"&":"&","<":"<",">":">",'"':""","'":"'"},rk=e=>xM[e];function wr(e,n){if(n){if(Xn.escapeTest.test(e))return e.replace(Xn.escapeReplace,rk)}else if(Xn.escapeTestNoEncode.test(e))return e.replace(Xn.escapeReplaceNoEncode,rk);return e}function ok(e){try{e=encodeURI(e).replace(Xn.percentDecode,"%")}catch{return null}return e}function ak(e,n){var i;const s=e.replace(Xn.findPipe,(c,d,u)=>{let f=!1,g=d;for(;--g>=0&&u[g]==="\\";)f=!f;return f?"|":" |"}),r=s.split(Xn.splitPipe);let a=0;if(r[0].trim()||r.shift(),r.length>0&&!((i=r.at(-1))!=null&&i.trim())&&r.pop(),n)if(r.length>n)r.splice(n);else for(;r.length<n;)r.push("");for(;a<r.length;a++)r[a]=r[a].trim().replace(Xn.slashPipe,"|");return r}function mc(e,n,s){const r=e.length;if(r===0)return"";let a=0;for(;a<r&&e.charAt(r-a-1)===n;)a++;return e.slice(0,r-a)}function vM(e,n){if(e.indexOf(n[1])===-1)return-1;let s=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===n[0])s++;else if(e[r]===n[1]&&(s--,s<0))return r;return-1}function ik(e,n,s,r,a){const i=n.href,c=n.title||null,d=e[1].replace(a.other.outputLinkReplace,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const u={type:"link",raw:s,href:i,title:c,text:d,tokens:r.inlineTokens(d)};return r.state.inLink=!1,u}return{type:"image",raw:s,href:i,title:c,text:d}}function yM(e,n,s){const r=e.match(s.other.indentCodeCompensation);if(r===null)return n;const a=r[1];return n.split(`
|
|
520
|
+
`).map(i=>{const c=i.match(s.other.beginningSpace);if(c===null)return i;const[d]=c;return d.length>=a.length?i.slice(a.length):i}).join(`
|
|
521
|
+
`)}class Cf{constructor(n){Tt(this,"options");Tt(this,"rules");Tt(this,"lexer");this.options=n||Ja}space(n){const s=this.rules.block.newline.exec(n);if(s&&s[0].length>0)return{type:"space",raw:s[0]}}code(n){const s=this.rules.block.code.exec(n);if(s){const r=s[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:s[0],codeBlockStyle:"indented",text:this.options.pedantic?r:mc(r,`
|
|
522
|
+
`)}}}fences(n){const s=this.rules.block.fences.exec(n);if(s){const r=s[0],a=yM(r,s[3]||"",this.rules);return{type:"code",raw:r,lang:s[2]?s[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):s[2],text:a}}}heading(n){const s=this.rules.block.heading.exec(n);if(s){let r=s[2].trim();if(this.rules.other.endingHash.test(r)){const a=mc(r,"#");(this.options.pedantic||!a||this.rules.other.endingSpaceChar.test(a))&&(r=a.trim())}return{type:"heading",raw:s[0],depth:s[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(n){const s=this.rules.block.hr.exec(n);if(s)return{type:"hr",raw:mc(s[0],`
|
|
523
|
+
`)}}blockquote(n){const s=this.rules.block.blockquote.exec(n);if(s){let r=mc(s[0],`
|
|
524
|
+
`).split(`
|
|
525
|
+
`),a="",i="";const c=[];for(;r.length>0;){let d=!1;const u=[];let f;for(f=0;f<r.length;f++)if(this.rules.other.blockquoteStart.test(r[f]))u.push(r[f]),d=!0;else if(!d)u.push(r[f]);else break;r=r.slice(f);const g=u.join(`
|
|
526
|
+
`),b=g.replace(this.rules.other.blockquoteSetextReplace,`
|
|
527
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");a=a?`${a}
|
|
528
|
+
${g}`:g,i=i?`${i}
|
|
529
|
+
${b}`:b;const x=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(b,c,!0),this.lexer.state.top=x,r.length===0)break;const h=c.at(-1);if((h==null?void 0:h.type)==="code")break;if((h==null?void 0:h.type)==="blockquote"){const v=h,y=v.raw+`
|
|
530
|
+
`+r.join(`
|
|
531
|
+
`),j=this.blockquote(y);c[c.length-1]=j,a=a.substring(0,a.length-v.raw.length)+j.raw,i=i.substring(0,i.length-v.text.length)+j.text;break}else if((h==null?void 0:h.type)==="list"){const v=h,y=v.raw+`
|
|
532
|
+
`+r.join(`
|
|
533
|
+
`),j=this.list(y);c[c.length-1]=j,a=a.substring(0,a.length-h.raw.length)+j.raw,i=i.substring(0,i.length-v.raw.length)+j.raw,r=y.substring(c.at(-1).raw.length).split(`
|
|
534
|
+
`);continue}}return{type:"blockquote",raw:a,tokens:c,text:i}}}list(n){let s=this.rules.block.list.exec(n);if(s){let r=s[1].trim();const a=r.length>1,i={type:"list",raw:"",ordered:a,start:a?+r.slice(0,-1):"",loose:!1,items:[]};r=a?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=a?r:"[*+-]");const c=this.rules.other.listItemRegex(r);let d=!1;for(;n;){let f=!1,g="",b="";if(!(s=c.exec(n))||this.rules.block.hr.test(n))break;g=s[0],n=n.substring(g.length);let x=s[2].split(`
|
|
535
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,E=>" ".repeat(3*E.length)),h=n.split(`
|
|
536
|
+
`,1)[0],v=!x.trim(),y=0;if(this.options.pedantic?(y=2,b=x.trimStart()):v?y=s[1].length+1:(y=s[2].search(this.rules.other.nonSpaceChar),y=y>4?1:y,b=x.slice(y),y+=s[1].length),v&&this.rules.other.blankLine.test(h)&&(g+=h+`
|
|
537
|
+
`,n=n.substring(h.length+1),f=!0),!f){const E=this.rules.other.nextBulletRegex(y),S=this.rules.other.hrRegex(y),N=this.rules.other.fencesBeginRegex(y),_=this.rules.other.headingBeginRegex(y),$=this.rules.other.htmlBeginRegex(y);for(;n;){const O=n.split(`
|
|
538
|
+
`,1)[0];let A;if(h=O,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),A=h):A=h.replace(this.rules.other.tabCharGlobal," "),N.test(h)||_.test(h)||$.test(h)||E.test(h)||S.test(h))break;if(A.search(this.rules.other.nonSpaceChar)>=y||!h.trim())b+=`
|
|
539
|
+
`+A.slice(y);else{if(v||x.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(x)||_.test(x)||S.test(x))break;b+=`
|
|
540
|
+
`+h}!v&&!h.trim()&&(v=!0),g+=O+`
|
|
541
|
+
`,n=n.substring(O.length+1),x=A.slice(y)}}i.loose||(d?i.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(d=!0));let j=null,k;this.options.gfm&&(j=this.rules.other.listIsTask.exec(b),j&&(k=j[0]!=="[ ] ",b=b.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:g,task:!!j,checked:k,loose:!1,text:b,tokens:[]}),i.raw+=g}const u=i.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let f=0;f<i.items.length;f++)if(this.lexer.state.top=!1,i.items[f].tokens=this.lexer.blockTokens(i.items[f].text,[]),!i.loose){const g=i.items[f].tokens.filter(x=>x.type==="space"),b=g.length>0&&g.some(x=>this.rules.other.anyLine.test(x.raw));i.loose=b}if(i.loose)for(let f=0;f<i.items.length;f++)i.items[f].loose=!0;return i}}html(n){const s=this.rules.block.html.exec(n);if(s)return{type:"html",block:!0,raw:s[0],pre:s[1]==="pre"||s[1]==="script"||s[1]==="style",text:s[0]}}def(n){const s=this.rules.block.def.exec(n);if(s){const r=s[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),a=s[2]?s[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=s[3]?s[3].substring(1,s[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):s[3];return{type:"def",tag:r,raw:s[0],href:a,title:i}}}table(n){var d;const s=this.rules.block.table.exec(n);if(!s||!this.rules.other.tableDelimiter.test(s[2]))return;const r=ak(s[1]),a=s[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(d=s[3])!=null&&d.trim()?s[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
542
|
+
`):[],c={type:"table",raw:s[0],header:[],align:[],rows:[]};if(r.length===a.length){for(const u of a)this.rules.other.tableAlignRight.test(u)?c.align.push("right"):this.rules.other.tableAlignCenter.test(u)?c.align.push("center"):this.rules.other.tableAlignLeft.test(u)?c.align.push("left"):c.align.push(null);for(let u=0;u<r.length;u++)c.header.push({text:r[u],tokens:this.lexer.inline(r[u]),header:!0,align:c.align[u]});for(const u of i)c.rows.push(ak(u,c.header.length).map((f,g)=>({text:f,tokens:this.lexer.inline(f),header:!1,align:c.align[g]})));return c}}lheading(n){const s=this.rules.block.lheading.exec(n);if(s)return{type:"heading",raw:s[0],depth:s[2].charAt(0)==="="?1:2,text:s[1],tokens:this.lexer.inline(s[1])}}paragraph(n){const s=this.rules.block.paragraph.exec(n);if(s){const r=s[1].charAt(s[1].length-1)===`
|
|
543
|
+
`?s[1].slice(0,-1):s[1];return{type:"paragraph",raw:s[0],text:r,tokens:this.lexer.inline(r)}}}text(n){const s=this.rules.block.text.exec(n);if(s)return{type:"text",raw:s[0],text:s[0],tokens:this.lexer.inline(s[0])}}escape(n){const s=this.rules.inline.escape.exec(n);if(s)return{type:"escape",raw:s[0],text:s[1]}}tag(n){const s=this.rules.inline.tag.exec(n);if(s)return!this.lexer.state.inLink&&this.rules.other.startATag.test(s[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(s[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(s[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(s[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:s[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:s[0]}}link(n){const s=this.rules.inline.link.exec(n);if(s){const r=s[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;const c=mc(r.slice(0,-1),"\\");if((r.length-c.length)%2===0)return}else{const c=vM(s[2],"()");if(c>-1){const u=(s[0].indexOf("!")===0?5:4)+s[1].length+c;s[2]=s[2].substring(0,c),s[0]=s[0].substring(0,u).trim(),s[3]=""}}let a=s[2],i="";if(this.options.pedantic){const c=this.rules.other.pedanticHrefTitle.exec(a);c&&(a=c[1],i=c[3])}else i=s[3]?s[3].slice(1,-1):"";return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?a=a.slice(1):a=a.slice(1,-1)),ik(s,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},s[0],this.lexer,this.rules)}}reflink(n,s){let r;if((r=this.rules.inline.reflink.exec(n))||(r=this.rules.inline.nolink.exec(n))){const a=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=s[a.toLowerCase()];if(!i){const c=r[0].charAt(0);return{type:"text",raw:c,text:c}}return ik(r,i,r[0],this.lexer,this.rules)}}emStrong(n,s,r=""){let a=this.rules.inline.emStrongLDelim.exec(n);if(!a||a[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(a[1]||a[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const c=[...a[0]].length-1;let d,u,f=c,g=0;const b=a[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(b.lastIndex=0,s=s.slice(-1*n.length+c);(a=b.exec(s))!=null;){if(d=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!d)continue;if(u=[...d].length,a[3]||a[4]){f+=u;continue}else if((a[5]||a[6])&&c%3&&!((c+u)%3)){g+=u;continue}if(f-=u,f>0)continue;u=Math.min(u,u+f+g);const x=[...a[0]][0].length,h=n.slice(0,c+a.index+x+u);if(Math.min(c,u)%2){const y=h.slice(1,-1);return{type:"em",raw:h,text:y,tokens:this.lexer.inlineTokens(y)}}const v=h.slice(2,-2);return{type:"strong",raw:h,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){const s=this.rules.inline.code.exec(n);if(s){let r=s[2].replace(this.rules.other.newLineCharGlobal," ");const a=this.rules.other.nonSpaceChar.test(r),i=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return a&&i&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:s[0],text:r}}}br(n){const s=this.rules.inline.br.exec(n);if(s)return{type:"br",raw:s[0]}}del(n){const s=this.rules.inline.del.exec(n);if(s)return{type:"del",raw:s[0],text:s[2],tokens:this.lexer.inlineTokens(s[2])}}autolink(n){const s=this.rules.inline.autolink.exec(n);if(s){let r,a;return s[2]==="@"?(r=s[1],a="mailto:"+r):(r=s[1],a=r),{type:"link",raw:s[0],text:r,href:a,tokens:[{type:"text",raw:r,text:r}]}}}url(n){var r;let s;if(s=this.rules.inline.url.exec(n)){let a,i;if(s[2]==="@")a=s[0],i="mailto:"+a;else{let c;do c=s[0],s[0]=((r=this.rules.inline._backpedal.exec(s[0]))==null?void 0:r[0])??"";while(c!==s[0]);a=s[0],s[1]==="www."?i="http://"+s[0]:i=s[0]}return{type:"link",raw:s[0],text:a,href:i,tokens:[{type:"text",raw:a,text:a}]}}}inlineText(n){const s=this.rules.inline.text.exec(n);if(s){const r=this.lexer.state.inRawBlock;return{type:"text",raw:s[0],text:s[0],escaped:r}}}}class Ds{constructor(n){Tt(this,"tokens");Tt(this,"options");Tt(this,"state");Tt(this,"tokenizer");Tt(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=n||Ja,this.options.tokenizer=this.options.tokenizer||new Cf,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const s={other:Xn,block:zu.normal,inline:fc.normal};this.options.pedantic?(s.block=zu.pedantic,s.inline=fc.pedantic):this.options.gfm&&(s.block=zu.gfm,this.options.breaks?s.inline=fc.breaks:s.inline=fc.gfm),this.tokenizer.rules=s}static get rules(){return{block:zu,inline:fc}}static lex(n,s){return new Ds(s).lex(n)}static lexInline(n,s){return new Ds(s).inlineTokens(n)}lex(n){n=n.replace(Xn.carriageReturn,`
|
|
544
|
+
`),this.blockTokens(n,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){const r=this.inlineQueue[s];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(n,s=[],r=!1){var a,i,c;for(this.options.pedantic&&(n=n.replace(Xn.tabCharGlobal," ").replace(Xn.spaceLine,""));n;){let d;if((i=(a=this.options.extensions)==null?void 0:a.block)!=null&&i.some(f=>(d=f.call({lexer:this},n,s))?(n=n.substring(d.raw.length),s.push(d),!0):!1))continue;if(d=this.tokenizer.space(n)){n=n.substring(d.raw.length);const f=s.at(-1);d.raw.length===1&&f!==void 0?f.raw+=`
|
|
545
|
+
`:s.push(d);continue}if(d=this.tokenizer.code(n)){n=n.substring(d.raw.length);const f=s.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=`
|
|
546
|
+
`+d.raw,f.text+=`
|
|
547
|
+
`+d.text,this.inlineQueue.at(-1).src=f.text):s.push(d);continue}if(d=this.tokenizer.fences(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.heading(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.hr(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.blockquote(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.list(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.html(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.def(n)){n=n.substring(d.raw.length);const f=s.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=`
|
|
548
|
+
`+d.raw,f.text+=`
|
|
549
|
+
`+d.raw,this.inlineQueue.at(-1).src=f.text):this.tokens.links[d.tag]||(this.tokens.links[d.tag]={href:d.href,title:d.title});continue}if(d=this.tokenizer.table(n)){n=n.substring(d.raw.length),s.push(d);continue}if(d=this.tokenizer.lheading(n)){n=n.substring(d.raw.length),s.push(d);continue}let u=n;if((c=this.options.extensions)!=null&&c.startBlock){let f=1/0;const g=n.slice(1);let b;this.options.extensions.startBlock.forEach(x=>{b=x.call({lexer:this},g),typeof b=="number"&&b>=0&&(f=Math.min(f,b))}),f<1/0&&f>=0&&(u=n.substring(0,f+1))}if(this.state.top&&(d=this.tokenizer.paragraph(u))){const f=s.at(-1);r&&(f==null?void 0:f.type)==="paragraph"?(f.raw+=`
|
|
550
|
+
`+d.raw,f.text+=`
|
|
551
|
+
`+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):s.push(d),r=u.length!==n.length,n=n.substring(d.raw.length);continue}if(d=this.tokenizer.text(n)){n=n.substring(d.raw.length);const f=s.at(-1);(f==null?void 0:f.type)==="text"?(f.raw+=`
|
|
552
|
+
`+d.raw,f.text+=`
|
|
553
|
+
`+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):s.push(d);continue}if(n){const f="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(f);break}else throw new Error(f)}}return this.state.top=!0,s}inline(n,s=[]){return this.inlineQueue.push({src:n,tokens:s}),s}inlineTokens(n,s=[]){var d,u,f;let r=n,a=null;if(this.tokens.links){const g=Object.keys(this.tokens.links);if(g.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)g.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,a.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i=!1,c="";for(;n;){i||(c=""),i=!1;let g;if((u=(d=this.options.extensions)==null?void 0:d.inline)!=null&&u.some(x=>(g=x.call({lexer:this},n,s))?(n=n.substring(g.raw.length),s.push(g),!0):!1))continue;if(g=this.tokenizer.escape(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.tag(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.link(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.reflink(n,this.tokens.links)){n=n.substring(g.raw.length);const x=s.at(-1);g.type==="text"&&(x==null?void 0:x.type)==="text"?(x.raw+=g.raw,x.text+=g.text):s.push(g);continue}if(g=this.tokenizer.emStrong(n,r,c)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.codespan(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.br(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.del(n)){n=n.substring(g.raw.length),s.push(g);continue}if(g=this.tokenizer.autolink(n)){n=n.substring(g.raw.length),s.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(n))){n=n.substring(g.raw.length),s.push(g);continue}let b=n;if((f=this.options.extensions)!=null&&f.startInline){let x=1/0;const h=n.slice(1);let v;this.options.extensions.startInline.forEach(y=>{v=y.call({lexer:this},h),typeof v=="number"&&v>=0&&(x=Math.min(x,v))}),x<1/0&&x>=0&&(b=n.substring(0,x+1))}if(g=this.tokenizer.inlineText(b)){n=n.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(c=g.raw.slice(-1)),i=!0;const x=s.at(-1);(x==null?void 0:x.type)==="text"?(x.raw+=g.raw,x.text+=g.text):s.push(g);continue}if(n){const x="Infinite loop on byte: "+n.charCodeAt(0);if(this.options.silent){console.error(x);break}else throw new Error(x)}}return s}}class Ef{constructor(n){Tt(this,"options");Tt(this,"parser");this.options=n||Ja}space(n){return""}code({text:n,lang:s,escaped:r}){var c;const a=(c=(s||"").match(Xn.notSpaceStart))==null?void 0:c[0],i=n.replace(Xn.endingNewline,"")+`
|
|
554
|
+
`;return a?'<pre><code class="language-'+wr(a)+'">'+(r?i:wr(i,!0))+`</code></pre>
|
|
555
|
+
`:"<pre><code>"+(r?i:wr(i,!0))+`</code></pre>
|
|
556
|
+
`}blockquote({tokens:n}){return`<blockquote>
|
|
557
|
+
${this.parser.parse(n)}</blockquote>
|
|
558
|
+
`}html({text:n}){return n}heading({tokens:n,depth:s}){return`<h${s}>${this.parser.parseInline(n)}</h${s}>
|
|
559
|
+
`}hr(n){return`<hr>
|
|
560
|
+
`}list(n){const s=n.ordered,r=n.start;let a="";for(let d=0;d<n.items.length;d++){const u=n.items[d];a+=this.listitem(u)}const i=s?"ol":"ul",c=s&&r!==1?' start="'+r+'"':"";return"<"+i+c+`>
|
|
561
|
+
`+a+"</"+i+`>
|
|
562
|
+
`}listitem(n){var r;let s="";if(n.task){const a=this.checkbox({checked:!!n.checked});n.loose?((r=n.tokens[0])==null?void 0:r.type)==="paragraph"?(n.tokens[0].text=a+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=a+" "+wr(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:a+" ",text:a+" ",escaped:!0}):s+=a+" "}return s+=this.parser.parse(n.tokens,!!n.loose),`<li>${s}</li>
|
|
563
|
+
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
564
|
+
`}table(n){let s="",r="";for(let i=0;i<n.header.length;i++)r+=this.tablecell(n.header[i]);s+=this.tablerow({text:r});let a="";for(let i=0;i<n.rows.length;i++){const c=n.rows[i];r="";for(let d=0;d<c.length;d++)r+=this.tablecell(c[d]);a+=this.tablerow({text:r})}return a&&(a=`<tbody>${a}</tbody>`),`<table>
|
|
565
|
+
<thead>
|
|
566
|
+
`+s+`</thead>
|
|
567
|
+
`+a+`</table>
|
|
568
|
+
`}tablerow({text:n}){return`<tr>
|
|
569
|
+
${n}</tr>
|
|
570
|
+
`}tablecell(n){const s=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+s+`</${r}>
|
|
571
|
+
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${wr(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:s,tokens:r}){const a=this.parser.parseInline(r),i=ok(n);if(i===null)return a;n=i;let c='<a href="'+n+'"';return s&&(c+=' title="'+wr(s)+'"'),c+=">"+a+"</a>",c}image({href:n,title:s,text:r}){const a=ok(n);if(a===null)return wr(r);n=a;let i=`<img src="${n}" alt="${r}"`;return s&&(i+=` title="${wr(s)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:wr(n.text)}}class wv{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}}class Fs{constructor(n){Tt(this,"options");Tt(this,"renderer");Tt(this,"textRenderer");this.options=n||Ja,this.options.renderer=this.options.renderer||new Ef,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new wv}static parse(n,s){return new Fs(s).parse(n)}static parseInline(n,s){return new Fs(s).parseInline(n)}parse(n,s=!0){var a,i;let r="";for(let c=0;c<n.length;c++){const d=n[c];if((i=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&i[d.type]){const f=d,g=this.options.extensions.renderers[f.type].call({parser:this},f);if(g!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type)){r+=g||"";continue}}const u=d;switch(u.type){case"space":{r+=this.renderer.space(u);continue}case"hr":{r+=this.renderer.hr(u);continue}case"heading":{r+=this.renderer.heading(u);continue}case"code":{r+=this.renderer.code(u);continue}case"table":{r+=this.renderer.table(u);continue}case"blockquote":{r+=this.renderer.blockquote(u);continue}case"list":{r+=this.renderer.list(u);continue}case"html":{r+=this.renderer.html(u);continue}case"paragraph":{r+=this.renderer.paragraph(u);continue}case"text":{let f=u,g=this.renderer.text(f);for(;c+1<n.length&&n[c+1].type==="text";)f=n[++c],g+=`
|
|
572
|
+
`+this.renderer.text(f);s?r+=this.renderer.paragraph({type:"paragraph",raw:g,text:g,tokens:[{type:"text",raw:g,text:g,escaped:!0}]}):r+=g;continue}default:{const f='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}parseInline(n,s=this.renderer){var a,i;let r="";for(let c=0;c<n.length;c++){const d=n[c];if((i=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&i[d.type]){const f=this.options.extensions.renderers[d.type].call({parser:this},d);if(f!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(d.type)){r+=f||"";continue}}const u=d;switch(u.type){case"escape":{r+=s.text(u);break}case"html":{r+=s.html(u);break}case"link":{r+=s.link(u);break}case"image":{r+=s.image(u);break}case"strong":{r+=s.strong(u);break}case"em":{r+=s.em(u);break}case"codespan":{r+=s.codespan(u);break}case"br":{r+=s.br(u);break}case"del":{r+=s.del(u);break}case"text":{r+=s.text(u);break}default:{const f='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}}class _c{constructor(n){Tt(this,"options");Tt(this,"block");this.options=n||Ja}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Ds.lex:Ds.lexInline}provideParser(){return this.block?Fs.parse:Fs.parseInline}}Tt(_c,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class bM{constructor(...n){Tt(this,"defaults",hv());Tt(this,"options",this.setOptions);Tt(this,"parse",this.parseMarkdown(!0));Tt(this,"parseInline",this.parseMarkdown(!1));Tt(this,"Parser",Fs);Tt(this,"Renderer",Ef);Tt(this,"TextRenderer",wv);Tt(this,"Lexer",Ds);Tt(this,"Tokenizer",Cf);Tt(this,"Hooks",_c);this.use(...n)}walkTokens(n,s){var a,i;let r=[];for(const c of n)switch(r=r.concat(s.call(this,c)),c.type){case"table":{const d=c;for(const u of d.header)r=r.concat(this.walkTokens(u.tokens,s));for(const u of d.rows)for(const f of u)r=r.concat(this.walkTokens(f.tokens,s));break}case"list":{const d=c;r=r.concat(this.walkTokens(d.items,s));break}default:{const d=c;(i=(a=this.defaults.extensions)==null?void 0:a.childTokens)!=null&&i[d.type]?this.defaults.extensions.childTokens[d.type].forEach(u=>{const f=d[u].flat(1/0);r=r.concat(this.walkTokens(f,s))}):d.tokens&&(r=r.concat(this.walkTokens(d.tokens,s)))}}return r}use(...n){const s=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(r=>{const a={...r};if(a.async=this.defaults.async||a.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const c=s.renderers[i.name];c?s.renderers[i.name]=function(...d){let u=i.renderer.apply(this,d);return u===!1&&(u=c.apply(this,d)),u}:s.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const c=s[i.level];c?c.unshift(i.tokenizer):s[i.level]=[i.tokenizer],i.start&&(i.level==="block"?s.startBlock?s.startBlock.push(i.start):s.startBlock=[i.start]:i.level==="inline"&&(s.startInline?s.startInline.push(i.start):s.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(s.childTokens[i.name]=i.childTokens)}),a.extensions=s),r.renderer){const i=this.defaults.renderer||new Ef(this.defaults);for(const c in r.renderer){if(!(c in i))throw new Error(`renderer '${c}' does not exist`);if(["options","parser"].includes(c))continue;const d=c,u=r.renderer[d],f=i[d];i[d]=(...g)=>{let b=u.apply(i,g);return b===!1&&(b=f.apply(i,g)),b||""}}a.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new Cf(this.defaults);for(const c in r.tokenizer){if(!(c in i))throw new Error(`tokenizer '${c}' does not exist`);if(["options","rules","lexer"].includes(c))continue;const d=c,u=r.tokenizer[d],f=i[d];i[d]=(...g)=>{let b=u.apply(i,g);return b===!1&&(b=f.apply(i,g)),b}}a.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new _c;for(const c in r.hooks){if(!(c in i))throw new Error(`hook '${c}' does not exist`);if(["options","block"].includes(c))continue;const d=c,u=r.hooks[d],f=i[d];_c.passThroughHooks.has(c)?i[d]=g=>{if(this.defaults.async)return Promise.resolve(u.call(i,g)).then(x=>f.call(i,x));const b=u.call(i,g);return f.call(i,b)}:i[d]=(...g)=>{let b=u.apply(i,g);return b===!1&&(b=f.apply(i,g)),b}}a.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,c=r.walkTokens;a.walkTokens=function(d){let u=[];return u.push(c.call(this,d)),i&&(u=u.concat(i.call(this,d))),u}}this.defaults={...this.defaults,...a}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,s){return Ds.lex(n,s??this.defaults)}parser(n,s){return Fs.parse(n,s??this.defaults)}parseMarkdown(n){return(r,a)=>{const i={...a},c={...this.defaults,...i},d=this.onError(!!c.silent,!!c.async);if(this.defaults.async===!0&&i.async===!1)return d(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return d(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return d(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));c.hooks&&(c.hooks.options=c,c.hooks.block=n);const u=c.hooks?c.hooks.provideLexer():n?Ds.lex:Ds.lexInline,f=c.hooks?c.hooks.provideParser():n?Fs.parse:Fs.parseInline;if(c.async)return Promise.resolve(c.hooks?c.hooks.preprocess(r):r).then(g=>u(g,c)).then(g=>c.hooks?c.hooks.processAllTokens(g):g).then(g=>c.walkTokens?Promise.all(this.walkTokens(g,c.walkTokens)).then(()=>g):g).then(g=>f(g,c)).then(g=>c.hooks?c.hooks.postprocess(g):g).catch(d);try{c.hooks&&(r=c.hooks.preprocess(r));let g=u(r,c);c.hooks&&(g=c.hooks.processAllTokens(g)),c.walkTokens&&this.walkTokens(g,c.walkTokens);let b=f(g,c);return c.hooks&&(b=c.hooks.postprocess(b)),b}catch(g){return d(g)}}}onError(n,s){return r=>{if(r.message+=`
|
|
573
|
+
Please report this to https://github.com/markedjs/marked.`,n){const a="<p>An error occurred:</p><pre>"+wr(r.message+"",!0)+"</pre>";return s?Promise.resolve(a):a}if(s)return Promise.reject(r);throw r}}}const Ua=new bM;function Mt(e,n){return Ua.parse(e,n)}Mt.options=Mt.setOptions=function(e){return Ua.setOptions(e),Mt.defaults=Ua.defaults,MS(Mt.defaults),Mt};Mt.getDefaults=hv;Mt.defaults=Ja;Mt.use=function(...e){return Ua.use(...e),Mt.defaults=Ua.defaults,MS(Mt.defaults),Mt};Mt.walkTokens=function(e,n){return Ua.walkTokens(e,n)};Mt.parseInline=Ua.parseInline;Mt.Parser=Fs;Mt.parser=Fs.parse;Mt.Renderer=Ef;Mt.TextRenderer=wv;Mt.Lexer=Ds;Mt.lexer=Ds.lex;Mt.Tokenizer=Cf;Mt.Hooks=_c;Mt.parse=Mt;Mt.options;Mt.setOptions;Mt.use;Mt.walkTokens;Mt.parseInline;Fs.parse;Ds.lex;let hc;const wM=e=>(hc||(cf.addHook("uponSanitizeElement",(n,s)=>{hc??(hc=s.allowedTags)}),cf.sanitize("<b></b>"),cf.removeHook("uponSanitizeElement")),(hc==null?void 0:hc[e.toLowerCase()])===!0),jM=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");Mt.use({breaks:!0,renderer:{html:({text:e,block:n})=>{let s=0;const r=e.replace(/<\/?([A-Za-z][\w:-]*)[^<>]*>/g,(a,i)=>wM(i)?(s++,a):jM(a));return n&&!s&&r!==e?`<p>${r.trim().replace(/\n/g,`<br>
|
|
574
|
+
`)}</p>
|
|
575
|
+
`:r}}});const ta=e=>e.slice(-8),od=e=>new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),ht=e=>new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function il(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const GS=e=>e.basis==="estimate",Zr=e=>e>0&&e<1e-4?"<$0.0001":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,$f=e=>{if(e>0&&e<1e-4)return"<$0.0001";if(e>=1)return`$${e.toFixed(2)}`;const[n,s=""]=e.toFixed(4).split(".");return`$${n}.${s.replace(/0+$/,"").padEnd(2,"0")}`},jl=e=>e&&e.usd===null&&typeof e.so_far_usd=="number"&&typeof e.unpriced=="number"?e:void 0,lk=(e,{ended:n=!1}={})=>`The charges priced${n?"":" so far"}. ${e.unpriced} ${e.unpriced===1?"charge has":"charges have"} no price, so this is not the whole cost.`,kM=new Set(["completed","failed","cancelled"]),Wa=e=>typeof e=="string"&&kM.has(e),NM="$0 · free model",qS=e=>e.usd===0&&e.free===!0,KS=e=>e.upper_bound===!0?"at most ":"",SM=(e,{ended:n=!1}={})=>e.usd!==null?`${KS(e)}${Zr(e.usd)}`:typeof e.so_far_usd=="number"?n?`${$f(e.so_far_usd)} known, ${e.unpriced??0} not priced`:`so far ${$f(e.so_far_usd)}, ${e.unpriced??0} not priced`:"not priced";function eo(e,{ended:n=!1}={}){const s=ad(e);if(s&&(e==null?void 0:e.usd)===0)return`${VS(s.tokens)} tokens · Using ChatGPT plan`;const r=CM(e,n);return s?`${r} + ChatGPT plan`:r}function CM(e,n){const s=jl(e),r=a=>GS(a)?" est.":"";return s?n?`${$f(s.so_far_usd)}${r(s)} known · ${s.unpriced} not priced`:`so far ${$f(s.so_far_usd)}${r(s)} · ${s.unpriced} not priced`:!e||e.usd===null?"Unknown":qS(e)?NM:`${KS(e)}${Zr(e.usd)}${r(e)}`}const ad=e=>e!=null&&e.plan&&e.plan.requests>0?e.plan:void 0;function VS(e){if(e<1e4)return e.toLocaleString("en-US");const[n,s]=e<1e6?[e/1e3,"K"]:e<1e9?[e/1e6,"M"]:[e/1e9,"B"];return`${n<100?n.toFixed(1).replace(/\.0$/,""):Math.round(n)}${s}`}function ck(e,n,{ended:s=!1,text:r}={}){const a=r??eo(e,{ended:s});return typeof n!="number"?a:(r!==void 0?EM.test(r):!jl(e)&&!ad(e)&&!!e&&e.usd!==null&&!qS(e))?`${a} of ${dk(n)}`:`${a} · cap ${dk(n)}`}const EM=/^<?\$[\d.,]+( est\.)?$/;function dk(e){for(let n=2;n<8;n++)if(Number(e.toFixed(n))===e)return`$${e.toFixed(n)}`;return`$${e.toFixed(8)}`}function $M(e,n){if(e.startsWith("/")||e.startsWith("#"))return null;const s=n.from?`${n.from.replace(/\/*$/,"").split("/").map(encodeURIComponent).join("/")}/`:"";try{const r=decodeURIComponent(new URL(e,`file:///${s}`).pathname.slice(1));return n.paths.includes(r)?r:null}catch{return null}}function to(e,n){const s=cf.sanitize(Mt.parse(e,{async:!1}),{RETURN_DOM:!0});for(const r of[...s.querySelectorAll("pre")])r.classList.add("whitespace-pre-wrap","break-words","[overflow-wrap:anywhere]");for(const r of[...s.querySelectorAll("a[href]")]){const a=r.getAttribute("href").trim();if(/^(https?|ftps?):/i.test(a)){r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer");continue}if(/^[a-z][a-z\d+.-]*:/i.test(a))continue;const i=n&&$M(a,n);if(i){const c=r.ownerDocument.createElement("button");c.type="button",c.title=`Open ${i}`,c.dataset.runFile=i,c.append(...r.childNodes),r.replaceWith(c)}else r.replaceWith(...r.childNodes)}return s.innerHTML}const jv=e=>n=>{var r,a,i;const s=(i=(a=(r=n.target).closest)==null?void 0:a.call(r,"[data-run-file]"))==null?void 0:i.getAttribute("data-run-file");s&&(n.preventDefault(),e(s))},_M=e=>{const n=s=>{var r;return(r=new RegExp(`\\b${s}="([^"]*)"`).exec(e))==null?void 0:r[1]};return n("scheme")==="github"||n("source")==="github"?"A GitHub event":n("source")==="webhook"?"A webhook request":"A trigger's request"};function Sn(e){const{title:n}=e;if(!e.trigger)return n;let s=n.search(/<trigger-payload\b/);if(s<0){const a=/<([a-z-]*)…$/.exec(n);if(!a||!"trigger-payload".startsWith(a[1]))return n;s=a.index}return n.slice(0,s).trim()||_M(n.slice(s))}function TM(e,n){if(n.unchanged&&!n.reset&&!n.drop.length&&!n.rows.length)return e;const s=new Map;if(!n.reset)for(const r of e)s.set(r.id,r);for(const r of n.drop)s.delete(r);for(const r of n.rows)s.set(r.id,r);return[...s.values()].sort((r,a)=>r.seq-a.seq)}const YS=e=>(e.kind==="tool_use"?e.tool_input_preview:e.kind==="tool_result"?e.tool_result_preview:e.text)??null,QS=e=>e.refused===!0,JS=e=>e.tool_status==="failed"&&!QS(e)||e.kind==="error",RM=e=>e.paused===!0;function AM(e){const n=new Map(e.filter(f=>f.kind==="tool_result"&&f.tool_use_id).map(f=>[f.tool_use_id,f])),s=new Set(e.filter(f=>f.kind==="tool_use"&&f.tool_use_id).map(f=>f.tool_use_id)),r=new Set(e.filter(f=>f.kind==="waiting"&&f.id.endsWith(":waiting")).map(f=>f.id.slice(0,-8))),a=f=>{var g;return r.has(f.id)||(f.tool_use_id?r.has(((g=n.get(f.tool_use_id))==null?void 0:g.id)??""):!1)},i=e.findLast(f=>f.kind==="usage"),c=[],d=new Map;let u;for(const f of e){if(f.kind==="usage")continue;if(f.tool_name==="ask_person"&&(f.kind==="tool_use"||f.kind==="tool_result")&&a(f)){u=void 0;continue}if(f.kind==="tool_result"&&f.tool_use_id&&s.has(f.tool_use_id)){u=d.get(f.tool_use_id);continue}if(f.kind==="phase"&&f.path&&u&&(u.row.kind==="tool_result"||u.row.kind==="tool_use")&&!u.saved){u.saved=f.path;continue}const g=c.at(-1);if(f.kind==="error"&&(g==null?void 0:g.row.kind)==="error"&&g.row.summary===f.summary&&g.row.text===f.text&&(g.row.agent_label??null)===(f.agent_label??null)){g.times=(g.times??1)+1,g.until=f.timestamp,u=g;continue}let b;const x=f.kind==="tool_use"&&f.tool_use_id?n.get(f.tool_use_id):void 0;if(x){const h=x.tool_status!=="failed",v=[f.tool_input_preview,x.tool_result_preview].filter(Boolean),y=x.tool_status!==null;b={row:{...x,id:f.id,seq:f.seq,timestamp:f.timestamp,summary:h?(x.summary??"").replace(/:\s*ok$/i,""):x.summary,...f.usage?{usage:f.usage}:{}},...y?{ms:Math.max(0,Date.parse(x.timestamp)-Date.parse(f.timestamp))}:{},detail:v.length===2?`${v[0]}
|
|
576
|
+
|
|
577
|
+
→ ${v[1]}`:v[0]??null}}else b={row:f};c.push(b),f.kind==="tool_use"&&f.tool_use_id&&d.set(f.tool_use_id,b),u=b}return i&&c.push({row:i}),c}class De extends Error{constructor(s,r,a,i=!1,c){super(a);Tt(this,"fields");Tt(this,"retryAfterMs");Tt(this,"details");Tt(this,"problems");this.status=s,this.code=r,this.retryable=i,this.requestId=c,this.name="ClientError"}toApiError(){return{code:this.code,message:this.message,retryable:this.retryable,request_id:this.requestId,...this.details?{details:this.details}:{}}}}const Ft=e=>e instanceof De?`${e.code}: ${e.message}`:e instanceof Error?e.message:String(e),uk=(e,n,{status:s,archived:r}={})=>{const a=new URLSearchParams({limit:String(e)});return n&&a.set("cursor",n),s&&a.set("status",s),r&&a.set("archived","true"),`?${a}`},OM=new Set(["/auth/sign-in","/setup"]);function MM({fetch:e=globalThis.fetch.bind(globalThis),base:n="/v2",onSignedOut:s}={}){async function r(v,y,j={}){return(await a(v,y,j)).body}async function a(v,y,{body:j,headers:k={},signal:E,text:S=!1}={}){var O;const N=j!==void 0||v!=="GET"&&v!=="HEAD",_=await e(`${n}${y}`,{method:v,signal:E,credentials:"same-origin",headers:{accept:"application/json",...N?{"content-type":"application/json"}:{},...k},body:j===void 0?void 0:JSON.stringify(j)});if(!_.ok){_.status===401&&!OM.has(y)&&(s==null||s());const A=(O=await _.json().catch(()=>null))==null?void 0:O.error,L=new De(_.status,(A==null?void 0:A.code)??"http_error",(A==null?void 0:A.message)??`${v} ${y}: ${_.status}`,(A==null?void 0:A.retryable)??!1,A==null?void 0:A.request_id);throw A!=null&&A.fields&&(L.fields=A.fields),typeof(A==null?void 0:A.retry_after_ms)=="number"&&(L.retryAfterMs=A.retry_after_ms),A!=null&&A.details&&typeof A.details=="object"&&!Array.isArray(A.details)&&(L.details=A.details),Array.isArray(A==null?void 0:A.problems)&&(L.problems=A.problems),L}return{body:!S&&(_.headers.get("content-type")??"").includes("json")?await _.json():await _.text(),etag:_.headers.get("etag"),status:_.status}}const i=v=>`/agents/${encodeURIComponent(v)}`,c=v=>`/runs/${encodeURIComponent(v)}`,d=(v,y,j)=>`${i(v)}/learning/workflows/${encodeURIComponent(y)}/revisions/${encodeURIComponent(j)}/replays`,u=v=>`/settings/mcp-servers/${encodeURIComponent(v)}`,f=v=>`/triggers/${encodeURIComponent(v)}`,g=new Map,b=(v,y)=>`${i(v)}/learning/files/${encodeURIComponent(y)}`,x=v=>({note:v.body,etag:v.etag}),h={accept:"text/markdown, application/json"};return{capabilities:()=>r("GET","/capabilities"),session:()=>a("GET","/auth/session").then(v=>({status:v.status,body:v.body})),signIn:v=>r("POST","/auth/sign-in",{body:{password:v}}),setup:(v,y,j=!1)=>r("POST","/setup",{body:{password:v,...y?{code:y}:{},...j?{import:!0}:{}}}),setupImport:()=>r("GET","/setup/import").then(v=>(v==null?void 0:v.offer)===!1?null:v,v=>{if(v instanceof De&&(v.status===404||v.status===403))return null;throw v}),signOut:()=>r("POST","/auth/sign-out",{body:{}}),signOutEverywhere:()=>r("POST","/auth/sign-out-everywhere",{body:{}}),stats:()=>r("GET","/stats"),listRuns:(v=50,y,j)=>r("GET",`/runs${uk(v,y,j)}`),listAgentRuns:(v,y=50,j,k={})=>r("GET",`${i(v)}/runs${uk(y,j,typeof k=="boolean"?{archived:k}:k)}`),discoverNative:(v,y)=>r("POST","/native/discover",{body:{project:v,...y?{runtime:y}:{}}}),connectNative:v=>r("POST","/native/connect",{body:v}),getNative:v=>r("GET",`${i(v)}/native`),verifyNative:v=>r("POST",`${i(v)}/native/verify`,{body:{}}),disconnectNative:v=>r("POST",`${i(v)}/native/disconnect`,{body:{}}),observations:({days:v=30,sessionId:y}={},j)=>{const k=new URLSearchParams({days:String(v)});return y&&k.set("session_id",y),r("GET",`/observations?${k}`,{signal:j})},listConnectors:()=>r("GET","/connectors"),enrollConnector:(v,y)=>r("POST","/connectors/enrollment",{body:{...v!=null&&v.trim()?{label:v.trim()}:{},...y?{capabilities:y}:{}}}),revokeConnector:v=>r("DELETE",`/connectors/${encodeURIComponent(v)}`),listAgents:({archived:v=!1,cursor:y}={})=>{const j=new URLSearchParams;return v&&j.set("archived","true"),y&&j.set("cursor",y),r("GET",`/agents${j.size?`?${j}`:""}`)},getAgent:async v=>{const y=await a("GET",i(v)),j=g.get(v);return{agent:j&&j.revision===y.body.revision&&!y.body.warnings?{...y.body,warnings:j.warnings}:y.body,etag:y.etag}},createAgent:async v=>{var j;const y=await r("POST","/agents",{body:v});return(j=y.warnings)!=null&&j.length&&g.set(y.agent_id,{revision:y.revision,warnings:y.warnings}),y},updateDefinition:async(v,y,j)=>{const k=await a("PUT",`${i(v)}/definition`,{body:y,headers:j?{"if-match":j}:{}});return g.delete(v),{agent:k.body,etag:k.etag}},listRevisions:(v,y)=>r("GET",`${i(v)}/revisions${y?`?cursor=${encodeURIComponent(y)}`:""}`),setCurrent:async(v,y)=>{const j=await r("POST",`${i(v)}/current`,{body:{revision:y}});return g.delete(v),j},archiveAgent:v=>r("POST",`${i(v)}/archive`,{body:{}}),unarchiveAgent:v=>r("POST",`${i(v)}/unarchive`,{body:{}}),agentLearning:v=>r("GET",`${i(v)}/learning`),learningCost:(v,y)=>r("GET",`${i(v)}/learning/cost${y?`?limit=${y}`:""}`),learningBatches:v=>r("GET",`${i(v)}/learning/batches`),learningBatch:(v,y)=>r("GET",`${i(v)}/learning/batches/${encodeURIComponent(y)}`),startLearningBatch:(v,y)=>r("POST",`${i(v)}/learning/batches`,{body:y}),cancelLearningBatch:(v,y)=>r("POST",`${i(v)}/learning/batches/${encodeURIComponent(y)}/cancel`,{body:{}}),learningEvals:v=>r("GET",`${i(v)}/learning/evals`),learningPromotions:v=>r("GET",`${i(v)}/learning/promotions`),learningLoop:v=>r("GET",`${i(v)}/learning/loop`),learnedWorkflowRevisions:(v,y,j)=>r("GET",`${i(v)}/learning/workflows/${encodeURIComponent(y)}/revisions${j?`?limit=${j}`:""}`),startLearnedWorkflowReplay:(v,y,j)=>r("POST",`${d(v,y,j)}`,{body:{}}),learnedWorkflowReplay:(v,y,j,k)=>r("GET",`${d(v,y,j)}/${encodeURIComponent(k)}`),learningNotes:(v,y)=>r("GET",`${i(v)}/learning/notes?cursor=${encodeURIComponent(y)}`),learningLog:(v,y)=>r("GET",`${i(v)}/learning/log?cursor=${encodeURIComponent(y)}`),readNote:async(v,y)=>x(await a("GET",b(v,y),{headers:h,text:!0})),writeNote:async(v,y,j,k)=>x(await a("PUT",b(v,y),{body:{text:j},headers:{...h,..."etag"in k?{"if-match":k.etag}:{"if-none-match":"*"}},text:!0})),retireNote:async(v,y,j)=>x(await a("POST",`${b(v,y)}/retire`,{body:{},headers:{...h,"if-match":j},text:!0})),approveNote:async(v,y,j)=>x(await a("POST",`${b(v,y)}/approve`,{body:{},headers:{...h,"if-match":j},text:!0})),restoreNote:async(v,y,j)=>x(await a("POST",`${b(v,y)}/restore`,{body:{},headers:{...h,"if-match":j},text:!0})),forgetSignIn:(v,y)=>r("DELETE",`${i(v)}/sign-ins/${encodeURIComponent(y)}`),promoteWorkflow:async(v,y,j)=>{var E;const k=await r("POST",`${i(v)}/learning/workflows/${encodeURIComponent(y)}/promote`,{body:{},headers:{"idempotency-key":j}});return(E=k.warnings)!=null&&E.length&&g.set(k.agent_id,{revision:k.revision,warnings:k.warnings}),k},getRun:v=>r("GET",c(v)),runLearningResult:v=>r("GET",`${c(v)}/learning`),runLearningDiff:v=>r("GET",`${c(v)}/learning/diff`),runLearning:v=>r("GET",`${c(v)}/learning`),runComputer:v=>r("GET",`${c(v)}/computer`),takeOverComputer:v=>r("POST",`${c(v)}/computer/take-over`,{body:{}}),handBackComputer:(v,y)=>r("POST",`${c(v)}/computer/hand-back`,{body:y?{outcome:y}:{}}),archiveRun:v=>r("POST",`${c(v)}/archive`,{body:{}}),unarchiveRun:v=>r("POST",`${c(v)}/unarchive`,{body:{}}),raiseCap:(v,y)=>r("PATCH",c(v),{body:{max_cost_usd:y}}),gradeRun:(v,y)=>r("PUT",`${c(v)}/grade`,{body:y}),startRun:async(v,y,j)=>{const k=await a("POST",`${i(v)}/runs`,{body:y,headers:{"idempotency-key":j}});return{run:k.body,status:k.status}},getTimeline:(v,{after:y,waitMs:j,signal:k}={})=>{const E=new URLSearchParams;return y!==void 0&&E.set("after",String(y)),j!==void 0&&E.set("wait_ms",String(j)),r("GET",`${c(v)}/timeline${E.size?`?${E}`:""}`,{signal:k})},listFiles:v=>r("GET",`${c(v)}/files`),deleteUpload:v=>r("DELETE",`/files/${encodeURIComponent(v)}`),readFile:(v,y)=>r("GET",`${c(v)}/files/${y.split("/").map(encodeURIComponent).join("/")}`,{text:!0}),sendMessage:(v,y,j)=>r("POST",`${c(v)}/messages`,{body:{content:y},headers:{"idempotency-key":j}}),getRunGraph:(v,y)=>r("GET",`${c(v)}/graph`,{signal:y}),pauseRun:v=>r("POST",`${c(v)}/pause`,{body:{}}),resumeRun:v=>r("POST",`${c(v)}/resume`,{body:{}}),validateWorkflow:(v,y)=>r("POST","/workflows/validate",{body:v,signal:y}),statsOver:({from:v,agent:y})=>{const j=new URLSearchParams;return v&&j.set("from",v),y&&j.set("agent",y),r("GET",`/stats${j.size?`?${j}`:""}`)},fileUrl:(v,y)=>`${n}${c(v)}/files/${y.split("/").map(encodeURIComponent).join("/")}`,listToolKeys:()=>r("GET","/settings/tool-keys"),saveToolKey:(v,y)=>r("PUT",`/settings/tool-keys/${encodeURIComponent(v)}`,{body:{values:y}}),removeToolKey:v=>r("DELETE",`/settings/tool-keys/${encodeURIComponent(v)}`),chatGPT:()=>r("GET","/settings/chatgpt"),startChatGPT:()=>r("POST","/settings/chatgpt/sign-in"),finishChatGPT:v=>r("POST","/settings/chatgpt/sign-in/finish",{body:{redirect_url:v}}),signOutChatGPT:()=>r("DELETE","/settings/chatgpt"),computers:()=>r("GET","/computers"),saveComputerKeys:(v,y)=>r("PUT",`/computers/${encodeURIComponent(v)}/keys`,{body:y}),testComputer:v=>r("POST",`/computers/${encodeURIComponent(v)}/test`),computerChoices:v=>r("GET",`/computers/${encodeURIComponent(v)}/choices`),createPairing:()=>r("POST","/computers/pairings"),removeComputer:v=>r("DELETE",`/computers/${encodeURIComponent(v)}`),archil:()=>r("GET","/workspace/archil"),saveArchil:v=>r("PUT","/workspace/archil",{body:v}),archilOff:()=>r("DELETE","/workspace/archil"),testArchil:()=>r("POST","/workspace/archil/test"),webhook:()=>r("GET","/settings/webhook"),saveWebhook:v=>r("PUT","/settings/webhook",{body:{url:v}}),removeWebhook:()=>r("DELETE","/settings/webhook"),testWebhook:()=>r("POST","/settings/webhook/test",{body:{}}),emailAccount:()=>r("GET","/settings/email"),saveEmailAccount:v=>r("PUT","/settings/email",{body:v}),removeEmailAccount:()=>r("DELETE","/settings/email"),testEmailAccount:(v={})=>r("POST","/settings/email/test",{body:v}),listTriggers:()=>r("GET","/triggers"),getTrigger:v=>r("GET",f(v)),createTrigger:(v,y)=>r("POST","/triggers",{body:v,headers:{"idempotency-key":y}}),rotateTriggerSecret:v=>r("POST",`${f(v)}/secret`),updateTrigger:(v,y)=>r("PATCH",f(v),{body:y}),deleteTrigger:v=>r("DELETE",f(v)),fireTrigger:(v,y)=>r("POST",`${f(v)}/fire`,{body:{},headers:{"idempotency-key":y}}),triggerFirings:v=>r("GET",`${f(v)}/firings`),webhookDeliveries:()=>r("GET","/settings/webhook/deliveries"),redeliverWebhook:v=>r("POST",`/settings/webhook/deliveries/${encodeURIComponent(v)}/redeliver`,{body:{}}),listTemplates:()=>r("GET","/templates"),applyTemplate:(v,y,j)=>r("POST",`/templates/${encodeURIComponent(v)}/apply`,{body:y,headers:{"idempotency-key":j}}),importTemplate:(v,y={})=>r("POST","/templates/import",{body:{source:v,...y.dryRun?{dry_run:!0}:{},...y.trustPublisher?{trust_publisher:!0}:{}}}),deleteTemplate:v=>r("DELETE",`/templates/${encodeURIComponent(v)}`),listMcpServers:()=>r("GET","/settings/mcp-servers"),previewMcpServer:(v,y,j)=>r("POST","/settings/mcp-servers/preview",{body:{url:v,auth:y,...j?{name:j}:{}}}),saveMcpServer:(v,y,j,k={})=>r("PUT",u(v),{body:{url:y,auth:j,...k}}),composioTools:(v,y)=>r("POST","/settings/mcp-servers/composio/tools",{body:{api_key:v,toolkit:y}}),saveComposioServer:(v,y,j,k)=>r("PUT",`${u(v)}/composio`,{body:{api_key:y,toolkit:j,tools:k}}),refreshMcpServer:v=>r("POST",`${u(v)}/refresh`,{body:{}}),deleteMcpServer:v=>r("DELETE",u(v)),composioEvents:v=>r("GET",`${u(v)}/composio/events`),composioTriggers:v=>r("GET",`${u(v)}/composio/triggers`),rotateComposioSecret:v=>r("POST",`${u(v)}/composio/rotate-secret`,{body:{}}),deleteComposioSubscription:v=>r("DELETE",`${u(v)}/composio/subscription`),startMcpSignIn:(v,y)=>r("POST",`${u(v)}/oauth/start`,{body:y}),mcpPrivateHosts:()=>r("GET","/settings/mcp-servers/oauth/private-hosts"),saveMcpPrivateHosts:v=>r("PUT","/settings/mcp-servers/oauth/private-hosts",{body:{hosts:v}}),githubConnection:()=>r("GET","/integrations/github"),connectGitHub:v=>r("POST","/integrations/github/connect",{body:v?{org:v}:{}}),disconnectGitHub:()=>r("DELETE","/integrations/github"),toolSettings:()=>r("GET","/settings/tools"),saveToolSettings:v=>r("PUT","/settings/tools",{body:v}),stop:v=>r("POST",`${c(v)}/stop`,{body:{}}),answerApproval:(v,y,j,k,E)=>r("POST",`${c(v)}/approvals/${encodeURIComponent(y)}`,{body:{decision:j,...k?{note:k}:{},...E?{confirm_destructive:!0}:{}}}),cancel:v=>r("POST",`${c(v)}/cancel`,{body:{}})}}async function qr(e,n,s=100){const r=[];let a=null;for(let i=0;i<s;i++){const c=await e(a);if(r.push(...n(c)),!c.next_cursor)break;a=c.next_cursor}return r}async function XS(e,n,{onRows:s,onPage:r,signal:a,waitMs:i=25e3,minDelayMs:c=250}){let d=[],u,f;for(;!(a!=null&&a.aborted);){const g=await e.getTimeline(n,u===void 0?{signal:a}:{after:u,waitMs:i,signal:a}).catch(x=>{if(a!=null&&a.aborted)return null;throw x});if(!g||a!=null&&a.aborted||(f=g,s&&(d=TM(d,g)),r==null||r(g),s==null||s(d),g.final&&!g.has_more))break;u=g.next_after;const b=Math.max(c,g.unchanged?g.poll_after_ms??0:0);b&&await new Promise(x=>setTimeout(x,b))}return f}const fk=e=>`#/observations/${encodeURIComponent(e)}`,_f=e=>e==="claude"?"Claude Code":e==="codex"?"Codex":e;function Sa(e){return e.connection_state==="revoked"?"Revoked":e.connection_state==="disconnected"?"Disconnected":e.selection_active?e.connection_state!=="online"?"Disconnected":{working:"Running",running:"Running",waiting:"Needs input",waiting_input:"Needs input",idle:"Idle",stopped:"Stopped",finished:"Session ended",failed:"Failed",unknown:"Unknown"}[e.activity]??e.activity:"Not selected"}const Kg=e=>{const n=Sa(e);return n==="Running"?"success":["Needs input","Disconnected","Failed"].includes(n)?"warning":"muted"},Ca=e=>e==null?"—":e.toLocaleString("en-US");function kv(e,{active:n=!0,days:s=30,sessionId:r}={}){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,b]=p.useState(!1);return p.useEffect(()=>{i(null),d(null)},[e,n,s,r]),p.useEffect(()=>{let x=!0;if(!n||typeof e.observations!="function"){b(!1);return}let h=null,v,y;const j=async()=>{if(!x||h)return;clearTimeout(v);const E=h=new AbortController,S=()=>x&&h===E;b(!0);const N=()=>{clearTimeout(_),S()&&(h=null,y=void 0,b(!1),clearTimeout(v),v=setTimeout(k,15e3))},_=y=setTimeout(()=>{S()&&(d("The observation read timed out. Try refreshing again."),E.abort(),N())},3e4);try{const $=await e.observations({days:s,sessionId:r},E.signal);S()&&(i($),d(null))}catch($){S()&&($ instanceof De&&$.status===404?(i(null),d(null)):d(Ft($)))}finally{N()}},k=()=>{!x||h||(document.hidden?(clearTimeout(v),v=setTimeout(k,15e3)):j())};return j(),window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{x=!1,clearTimeout(v),clearTimeout(y),h==null||h.abort(),h=null,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[e,n,s,r,u]),{data:a,error:c,loading:g,refresh:()=>f(x=>x+1)}}function Nv({read:e,view:n="table",query:s="",days:r=30}){const{data:a,error:i,refresh:c}=e,d=a==null?void 0:a.connectors.some(f=>f.storage_full);if(!(a!=null&&a.sessions.length)&&!i&&!d)return null;const u=((a==null?void 0:a.sessions)??[]).filter(f=>`${f.display_name} ${f.harness} ${f.models.join(" ")}`.toLowerCase().includes(s.toLowerCase()));return t.jsxs("section",{className:"space-y-4","aria-label":"Observed sessions",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("div",{className:"mr-auto",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-lead font-semibold",children:[t.jsx(Bx,{className:"size-4","aria-hidden":!0}),"Observed sessions"]}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"Agents running in their original applications. Activity refreshes every 15 seconds."})]}),t.jsx(B,{size:"icon","aria-label":"Refresh observed sessions",disabled:e.loading,onClick:c,children:t.jsx(Qo,{className:"size-4","aria-hidden":!0})})]}),d&&t.jsx(vt,{tone:"warning",title:"Telemetry needs attention",children:"A connector has reached its telemetry storage capacity. New reports cannot be accepted until storage becomes available."}),i&&t.jsxs(vt,{tone:"error",children:["Could not refresh observed sessions: ",i]}),n==="summary"&&a&&t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsx("dl",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[["Retained sessions",u.length],["Running",u.filter(f=>Sa(f)==="Running").length],["Needs input",u.filter(f=>Sa(f)==="Needs input").length],["Disconnected",u.filter(f=>Sa(f)==="Disconnected").length]].map(([f,g])=>t.jsxs("div",{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:f}),t.jsx("dd",{className:"mt-2 font-mono text-figure",children:g})]},f))}),t.jsxs("h3",{className:"text-body font-semibold",children:["Observed token usage · last ",r," days"]}),a.usage.status==="unavailable"?t.jsx("p",{className:"text-small text-muted-foreground",children:a.usage.overflow?"Combined token totals are too large to display reliably. Open individual sessions for exact counters.":"Token usage has not been reported."}):t.jsxs(t.Fragment,{children:[t.jsx(ZS,{usage:a.usage}),t.jsx(PM,{models:a.usage.models}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Reported tokens only. Input includes cache reads and writes; cache hit rate is cache reads divided by input. Idle does not mean a task completed."})]})]}),n==="summary"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Session totals cover retained reports, independently of the aggregate range."}),u.length?n==="cards"?t.jsx("ul",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 2xl:grid-cols-3",children:u.map(f=>t.jsx("li",{className:"border p-5 transition-colors hover:border-border-strong",children:t.jsxs("a",{href:fk(f.id),className:"block space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[t.jsx("h3",{className:"min-w-0 flex-1 break-words text-base font-semibold",children:f.display_name}),t.jsx(cr,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Ne,{children:_f(f.harness)}),t.jsx(Ne,{tone:Kg(f),children:Sa(f)}),t.jsx(Ne,{tone:"muted",children:"Observed"})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:f.models.join(", ")||"Model not reported"}),t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["Session ",f.id.slice(0,8)," · Last received ",ht(f.received_at)]})]})},f.id))}):t.jsx("div",{className:"overflow-x-auto border",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Observed sessions",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Activity","Session","Harness","Model","Tokens · retained","Last received"].map(f=>t.jsx("th",{className:"whitespace-nowrap px-4 py-3 font-semibold",children:f},f))})}),t.jsx("tbody",{children:u.map(f=>t.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-accent",children:[t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:t.jsx(Ne,{tone:Kg(f),children:Sa(f)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("a",{href:fk(f.id),className:"inline-flex items-center gap-1 underline underline-offset-2",children:[f.display_name,t.jsx(cr,{className:"size-3 shrink-0","aria-hidden":!0})]})}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:_f(f.harness)}),t.jsx("td",{className:"px-4 py-3",children:f.models.join(", ")||"Not reported"}),t.jsx("td",{className:"px-4 py-3 font-mono",children:f.usage.status==="unavailable"?"—":Ca(f.usage.total_tokens)}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:ht(f.received_at)})]},f.id))})]})}):t.jsx("p",{className:"text-body text-muted-foreground",children:"No observed session matches."})]})}function ZS({usage:e}){return e.status==="unavailable"?t.jsx("p",{className:"text-small text-muted-foreground",children:"Token usage has not been reported."}):t.jsx("dl",{className:"grid grid-cols-2 gap-4 md:grid-cols-3",children:[["Input",Ca(e.input_tokens)],["Output",Ca(e.output_tokens)],["Cache writes",Ca(e.cache_write_tokens)],["Cache reads",Ca(e.cache_read_tokens)],["Total tokens",Ca(e.total_tokens)],["Cache hit rate",e.cache_hit_rate==null?"—":`${(e.cache_hit_rate*100).toFixed(1)}%`]].map(([n,s])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:n}),t.jsx("dd",{className:"mt-1 font-mono text-body",children:s})]},n))})}function PM({models:e}){return e.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-right text-small","aria-label":"Observed tokens by model",children:[t.jsx("thead",{className:"border-b text-muted-foreground",children:t.jsx("tr",{children:["Model","Input","Output","Cache writes","Cache reads"].map(n=>t.jsx("th",{className:"whitespace-nowrap py-2 pl-4 font-normal first:pl-0 first:text-left",children:n},n))})}),t.jsx("tbody",{children:e.map(n=>t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsx("th",{className:"py-2 text-left font-normal",children:n.model}),[n.input_tokens,n.output_tokens,n.cache_write_tokens,n.cache_read_tokens].map((s,r)=>t.jsx("td",{className:"py-2 pl-4 font-mono",children:Ca(s)},r))]},n.model))})]})}):null}function LM({v2:e,sessionId:n,go:s}){var i;const r=kv(e,{sessionId:n}),a=(i=r.data)==null?void 0:i.sessions.find(c=>c.id===n);return t.jsxs("section",{className:"flex min-h-full flex-col","aria-label":"Observed session detail",children:[t.jsxs("header",{className:"flex min-h-12 flex-wrap items-center gap-2 border-b px-5 py-2",children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>s("#/agents"),children:t.jsx(zn,{"aria-hidden":!0})}),t.jsx(Bx,{className:"size-4","aria-hidden":!0}),t.jsx("strong",{className:"min-w-0 flex-1 truncate text-body",children:(a==null?void 0:a.display_name)??"Observed session"}),t.jsx(B,{size:"icon","aria-label":"Refresh session",disabled:r.loading,onClick:r.refresh,children:t.jsx(Qo,{"aria-hidden":!0})})]}),t.jsxs("main",{className:"mx-auto w-full max-w-page space-y-6 p-5 md:p-8",children:[r.error&&t.jsxs(vt,{tone:"error",children:["Could not read this session: ",r.error]}),a?t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold",children:a.display_name}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[t.jsx(Ne,{tone:"muted",children:"Observed"}),t.jsx(Ne,{tone:Kg(a),children:Sa(a)}),t.jsx(Ne,{children:_f(a.harness)})]})]}),t.jsx(vt,{children:"Activity and token usage come from the original application. Run, edit and stop remain in that application. This connection observes activity; the backend SDK integration adds self-improvement."}),t.jsx("dl",{className:"grid gap-4 border bg-card p-4 sm:grid-cols-2",children:[["Harness",_f(a.harness)],["Model",a.models.join(", ")||"Not reported"],["Connection",a.connection_state],["Last reported activity",a.reported_activity],["First seen",ht(a.created_at)],["Last received",ht(a.received_at)],["Session",a.id],["Connector",a.connector_id]].map(([c,d])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:c}),t.jsx("dd",{className:"mt-1 break-all text-body",children:d})]},c))}),t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Session token usage",children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Reported token usage · retained session"}),t.jsx(ZS,{usage:a.usage}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Session totals cover retained reports. Input includes cache reads and writes. Missing cache counters are shown as a dash. Activity signals do not establish a completed task or its outcome."})]})]}):t.jsx("p",{className:"text-body text-muted-foreground",children:r.loading?"Loading observed session…":r.data?"This session was not found.":"Observed sessions are unavailable on this server."})]})]})}function Sv(e,n={}){const s=new URLSearchParams({operation:"list-runs"});return e&&s.set("agent",e),n.status&&s.set("status",n.status),n.archived&&s.set("archived","true"),`#/playground?${s}`}const Vt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),IM=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),Vg=128,zM=e=>{try{return JSON.stringify(e)??"null"}catch{return JSON.stringify(`[${typeof e}:${String(e)}]`)}},Yg=(e,n=0)=>n>Vg?'"…"':Array.isArray(e)?`[${e.map(s=>Yg(s,n+1)).join(",")}]`:Vt(e)?`{${Object.keys(e).filter(s=>e[s]!==void 0).sort().map(s=>`${JSON.stringify(s)}:${Yg(e[s],n+1)}`).join(",")}}`:zM(e),DM=e=>{let n=2166136261;for(let s=0;s<e.length;s+=1)n=Math.imul(n^e.charCodeAt(s),16777619);return(n>>>0).toString(16).padStart(8,"0")},pc=(e,n)=>Object.fromEntries(Object.entries(e).filter(([s])=>s!==n)),FM=e=>{switch(e.node){case"chain":return pc(e,"steps");case"parallel":return pc(e,"branches");case"map":case"loop":return pc(e,"body");case"route":return Vt(e.branches)?{...e,branches:Object.fromEntries(Object.entries(e.branches).map(([n,s])=>[n,Vt(s)?pc(s,"body"):s]))}:e;case"workflow":return Vt(e.workflow)?{...e,workflow:pc(e.workflow,"root")}:e;default:return e}};function ll(e){const n=[],s=[],r=(a,i,c,d)=>{if(!Vt(a)||typeof a.node!="string"||c>Vg)return;n.push({path:i,kind:a.node,label:typeof a.label=="string"?a.label:a.node,...a.node==="call"&&typeof a.via=="string"?{via:a.via}:{},changeCheck:DM(Yg(FM(a))),...WM(a,d)});const u=(f,g,b,x=i,h=d)=>{!Vt(f)||typeof f.node!="string"||c+1>Vg||(s.push({from:x,to:g,kind:b}),r(f,g,c+1,h))};switch(a.node){case"chain":Array.isArray(a.steps)&&a.steps.forEach((f,g)=>u(f,`${i}/steps/${g}`,"next",g===0?i:`${i}/steps/${g-1}`));break;case"parallel":Array.isArray(a.branches)&&a.branches.forEach((f,g)=>u(f,`${i}/branches/${g}`,"branch"));break;case"map":u(a.body,`${i}/body`,"item");break;case"loop":u(a.body,`${i}/body`,"next");break;case"route":if(Vt(a.branches))for(const[f,g]of Object.entries(a.branches))Vt(g)&&u(g.body,`${i}/branches/${IM(f)}/body`,"route");break;case"workflow":Vt(a.workflow)&&u(a.workflow.root,`${i}/workflow/root`,"child",i,Vt(a.workflow.schemas)?a.workflow.schemas:{});break}};return r(Vt(e)?e.root:void 0,"/root",0,Vt(e)&&Vt(e.schemas)?e.schemas:{}),{nodes:n,edges:s}}const UM=(e,n)=>{const s=typeof e=="string"&&Object.hasOwn(n,e)?n[e]:void 0,r=i=>{var c;for(let d=0;Vt(i)&&typeof i.$ref=="string"&&d<8;d+=1){const u=(c=/^#\/definitions\/(.+)$/.exec(i.$ref))==null?void 0:c[1],f=Vt(s)&&Vt(s.definitions)?s.definitions:{};i=u===void 0?void 0:Object.hasOwn(f,u)?f[u]:Object.hasOwn(n,u)?n[u]:void 0}return i},a=r(s);return!Vt(a)||!Vt(a.properties)?[]:Object.entries(a.properties).map(([i,c])=>{const d=r(c),u=Vt(d)&&typeof d.description=="string"?d.description:"",f=Vt(d)?(Array.isArray(d.type)?d.type:[d.type]).filter(g=>g!=="null"):[];return Vt(d)&&Array.isArray(d.enum)?{id:i,type:"choice",instructions:u,options:d.enum.map(String)}:f.length===1&&f[0]==="boolean"?{id:i,type:"noul",instructions:u}:f.length===1&&f[0]==="integer"?{id:i,type:"score",instructions:u}:{id:i,type:"unknown",instructions:u}})},WM=(e,n)=>{let s=e,r;const a=i=>typeof i=="string"?i:"";switch(e.node){case"judge":case"sift":r=UM(e.out,n);break;case"pick":r=[{id:"pick",type:"choice",instructions:a(e.instructions)}];break;case"route":if(e.valuePath!==void 0)return{};r=[{id:"branch",type:"choice",instructions:a(e.instructions),options:Vt(e.branches)?Object.keys(e.branches):[]}];break;case"loop":case"escalate":{const i=e.node==="loop"?e.until:e.when;if(!Vt(i)||i.predicate!=="ask")return{};s=i,r=[{id:"holds",type:"noul",instructions:a(i.instructions)}];break}default:return{}}return{...typeof s.provider=="string"?{provider:s.provider}:{},...typeof s.model=="string"?{model:s.model}:{},questions:r,...Vt(s.images)&&Object.keys(s.images).length?{images:Object.keys(s.images)}:{}}};function e2(e,n){const s=S=>JSON.stringify([S.kind,S.label]),r=S=>{const N=new Map;for(const _ of S.nodes)N.set(s(_),(N.get(s(_))??0)+1);return N},[a,i]=[r(e),r(n)],c=S=>a.get(s(S))===1&&i.get(s(S))===1,d=new Map,u=new Map,f=(S,N)=>{d.set(N,S),u.set(S,N)},g=new Map(e.nodes.filter(c).map(S=>[s(S),S.path]));for(const S of n.nodes){const N=c(S)?g.get(s(S)):void 0;N!==void 0&&f(N,S.path)}const b=new Map(e.nodes.map(S=>[S.path,S])),x=[];for(const S of n.nodes){const N=b.get(S.path);d.has(S.path)||N===void 0||u.has(N.path)||(f(N.path,S.path),(N.kind!==S.kind||N.label!==S.label)&&x.push({prev:N.path,next:S.path,was:{kind:N.kind,label:N.label},now:{kind:S.kind,label:S.label}}))}const h=[];for(const S of n.nodes){const N=d.get(S.path),_=N===void 0?void 0:b.get(N);_===void 0||_.kind!==S.kind||_.label!==S.label||_.changeCheck!==void 0&&S.changeCheck!==void 0&&_.changeCheck!==S.changeCheck&&h.push({prev:_.path,next:S.path,kind:S.kind,label:S.label})}const v=({path:S,kind:N,label:_})=>({path:S,kind:N,label:_}),y=(S,N,_)=>JSON.stringify([S,N,_]),j=new Set(e.edges.map(S=>y(S.from,S.to,S.kind))),k=new Set(n.edges.map(S=>y(S.from,S.to,S.kind))),E=(S,N,_)=>{const[$,O]=[N.get(S.from),N.get(S.to)];return $!==void 0&&O!==void 0&&_.has(y($,O,S.kind))};return{added:n.nodes.filter(S=>!d.has(S.path)).map(v),removed:e.nodes.filter(S=>!u.has(S.path)).map(v),changed:x,moved:n.nodes.flatMap(S=>{const N=d.get(S.path);return N!==void 0&&N!==S.path?[{prev:N,next:S.path}]:[]}),rewritten:h,edges:{added:n.edges.filter(S=>!E(S,d,j)).map(({from:S,to:N,kind:_})=>({from:S,to:N,kind:_})),removed:e.edges.filter(S=>!E(S,u,k)).map(({from:S,to:N,kind:_})=>({from:S,to:N,kind:_}))}}}function pn({className:e}){return t.jsx("span",{"aria-hidden":!0,className:oe("block bg-muted motion-safe:animate-pulse",e)})}function Am({label:e,className:n,children:s}){return t.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:n,children:[s,t.jsxs("span",{className:"sr-only",children:[e,"…"]})]})}function HM(){return t.jsxs(Am,{label:"Loading Mission Control",className:"space-y-8 p-5 md:p-8",children:[t.jsx(pn,{className:"h-8 w-56"}),t.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6",children:Array.from({length:6},(e,n)=>t.jsxs("div",{className:"border p-4",children:[t.jsx(pn,{className:"h-3 w-16"}),t.jsx(pn,{className:"mt-3 h-6 w-12"})]},n))}),t.jsx(pn,{className:"h-48 w-full"}),t.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[t.jsx(Tf,{n:4}),t.jsx(Tf,{n:6})]})]})}function Tf({n:e}){return t.jsx("div",{className:"border",children:Array.from({length:e},(n,s)=>t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsx(pn,{className:"h-4 w-20"}),t.jsx(pn,{className:"h-4 flex-1"}),t.jsx(pn,{className:"hidden h-4 w-24 sm:block"})]},s))})}function Fn({label:e,rows:n=8}){return t.jsx(Am,{label:e,children:t.jsx(Tf,{n})})}function BM(){return t.jsxs(Am,{label:"Loading the run",className:"space-y-6 p-5 md:p-8",children:[t.jsxs("div",{className:"space-y-3 border-b pb-6",children:[t.jsx(pn,{className:"h-4 w-24"}),t.jsx(pn,{className:"h-7 w-2/3"}),t.jsx(pn,{className:"h-3 w-1/3"})]}),t.jsx("div",{className:"flex gap-6",children:Array.from({length:3},(e,n)=>t.jsx(pn,{className:"h-4 w-16"},n))}),t.jsx("div",{className:"space-y-4",children:Array.from({length:5},(e,n)=>t.jsxs("div",{className:"flex gap-3",children:[t.jsx(pn,{className:"size-4 shrink-0"}),t.jsx(pn,{className:oe("h-4",n%2?"w-1/2":"w-3/4")})]},n))})]})}function GM(){return t.jsxs(Am,{label:"Loading the agent",className:"space-y-6 p-5 md:p-8",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(pn,{className:"h-7 w-64"}),t.jsx(pn,{className:"h-3 w-80 max-w-full"})]}),t.jsx(pn,{className:"h-12 w-full"}),t.jsx(Tf,{n:5})]})}function Yt({problem:e,onRetry:n,link:s,className:r="m-8"}){return t.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${r}`,role:"alert",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-prose font-semibold",children:e.title}),t.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&t.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),(n||s)&&t.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[n&&t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"}),s&&t.jsx("a",{href:s.href,className:"caps border px-3 py-2 text-small hover:bg-accent",children:s.label})]})]})]})}function t2({what:e,id:n,list:s}){return t.jsx(Yt,{problem:{title:`No ${e} with this id.`,why:`This server has no ${e} ${n}.`,next:`Check the address, or find the ${e} in the list.`},link:s})}class Qg extends Error{constructor(){super("Can't reach agentrun-serve. Try again once it's back."),this.name="Unreachable"}}const Jg=e=>Math.min(1e4,1e3*2**e),mk=e=>e.status>=500&&!(e.headers.get("content-type")??"").includes("json"),qM=e=>(e==null?void 0:e.name)==="AbortError",hk=e=>e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError");function KM({fetch:e=(a,i)=>globalThis.fetch(a,i),probe:n="/v2/health",resumedMs:s=5e3,probeMs:r=5e3}={}){let a={state:"online"};const i=new Set,c=new Set;let d=[],u,f=null,g=null;const b=N=>{a=N;for(const _ of[...i])_()},x=N=>{const _=Jg(N);clearTimeout(u),b({state:"offline",attempt:N,retryAt:Date.now()+_}),u=setTimeout(()=>void j(),_)},h=()=>{a.state!=="offline"&&x(0)},v=()=>{if(a.state!=="offline")return;clearTimeout(u),b({state:"resumed"});const N=d;d=[];for(const _ of N)_();for(const _ of[...c])_();u=setTimeout(()=>{a.state==="resumed"&&b({state:"online"})},s)};async function y(N){const _=setTimeout(()=>N.abort(),r);try{return!mk(await e(n,{method:"GET",cache:"no-store",credentials:"same-origin",signal:N.signal}))}catch{return!1}finally{clearTimeout(_)}}async function j(){if(a.state!=="offline")return;clearTimeout(u),f==null||f.abort();const N=f=new AbortController,_=await y(N);f===N&&(f=null,a.state==="offline"&&(_?v():x(a.attempt+1)))}const k=()=>g??(g=y(new AbortController).finally(()=>{g=null})),E=N=>new Promise((_,$)=>{if(N!=null&&N.aborted)return $(hk(N));const O=()=>{d=d.filter(L=>L!==A),$(hk(N))},A=()=>{N==null||N.removeEventListener("abort",O),_()};d.push(A),N==null||N.addEventListener("abort",O,{once:!0})});return{fetch:async(N,_)=>{var A;const $=((_==null?void 0:_.method)??"GET").toUpperCase(),O=$==="GET"||$==="HEAD";for(let L=0;;L++){let M,R;try{M=await e(N,_)}catch(P){if((A=_==null?void 0:_.signal)!=null&&A.aborted||qM(P))throw P;R=P}if(M&&!mk(M))return v(),M;if(a.state!=="offline"&&await k()){if(M)return M;if(!O)throw new Qg;if(L>=2)throw R;await new Promise(P=>setTimeout(P,Jg(L)));continue}if(h(),!O)throw new Qg;await E(_==null?void 0:_.signal)}},link:()=>a,subscribe:N=>(i.add(N),()=>{i.delete(N)}),onResume:N=>(c.add(N),()=>{c.delete(N)}),retryNow:()=>void j()}}const VM=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),n2=e=>e instanceof Qg||e instanceof TypeError&&/fetch|network/i.test(e.message);function Ut(e,n){const s=`${VM(n)} could not be read.`;if(n2(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: the console reconnects by itself."};if(!(e instanceof De))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=e.message,a=[e.code,e.requestId].filter(Boolean).join(" · "),i=(c,d)=>({title:s,why:c,next:d,said:r,code:a});return e.status===401?i("This browser is signed out.","Reload the page to sign in again."):e.status===403?i("The server doesn't allow this here.","Sign in as the server's owner, or open the console from the address the server printed."):e.status===404?i("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===429?i("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?i("The server is busy.","Try again in a moment."):e.status>=500?i("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):i("The server turned the request down.","Its words say why: change what they name, then try again.")}function YM(e){return n2(e)?"Can't reach agentrun-serve":e instanceof De?e.status>=500?"The server hit a problem":"The server refused this":"Something went wrong in the console"}function QM({agent:e,v2:n}){const[s,r]=p.useState(null),[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,b]=p.useState(null),x=p.useRef(0),h=p.useRef(!1),v=async y=>{if(h.current)return;h.current=!0;const j=++x.current;f(!0);try{const k=await n.listRevisions(e.agent_id,y);if(j!==x.current)return;r(E=>{const S=new Map((y?E??[]:[]).map(N=>[N.revision,N]));for(const N of k.revisions)S.set(N.revision,N);return[...S.values()]}),i(k.next_cursor),d(null)}catch(k){j===x.current&&d(Ut(k,y?"more versions":"the versions"))}finally{j===x.current&&(h.current=!1,f(!1))}};return p.useEffect(()=>(h.current=!1,r(null),i(null),d(null),b(null),v(null),()=>{x.current++,h.current=!1}),[n,e.agent_id,e.revision,e.revisions]),c&&!s?t.jsx(Yt,{problem:c,onRetry:()=>void v(null),className:""}):s?t.jsxs("section",{className:"overflow-hidden border","aria-label":"Agent versions",children:[t.jsxs("div",{className:"border-b px-4 py-3 text-body text-muted-foreground",children:[e.revisions," ",e.revisions===1?"version":"versions"," · Current version ",e.definition.version]}),s.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Versions",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Version","Created","Note","Configuration"].map(y=>t.jsx("th",{className:"px-4 py-3 font-semibold",children:y},y))})}),t.jsx("tbody",{children:s.map(y=>t.jsxs(p.Fragment,{children:[t.jsxs("tr",{className:"border-b last:border-b-0",children:[t.jsxs("td",{className:"whitespace-nowrap px-4 py-3",children:[t.jsxs("span",{className:"font-semibold",children:["v",y.version]}),y.revision===e.revision&&t.jsx("span",{className:"ml-2 bg-primary/10 px-2 py-1 text-micro text-primary-text",children:"Current"})]}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:ht(y.created_at)}),t.jsx("td",{className:"min-w-40 px-4 py-3 text-muted-foreground",children:y.note||"—"}),t.jsx("td",{className:"px-4 py-3",children:t.jsx(B,{size:"sm","aria-expanded":g===y.revision,"aria-label":`View configuration for version ${y.version}`,onClick:()=>b(j=>j===y.revision?null:y.revision),children:g===y.revision?"Hide":"View"})})]}),g===y.revision&&t.jsx("tr",{className:"border-b bg-card",children:t.jsxs("td",{colSpan:4,className:"p-4",children:[t.jsx("p",{className:"mb-3 break-all font-mono text-label text-muted-foreground",children:y.revision}),t.jsx("pre",{"aria-label":`Version ${y.version} configuration`,className:"max-h-[520px] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:JSON.stringify(y.definition,null,2)})]})})]},y.revision))})]})}):t.jsx("p",{className:"p-10 text-center text-body text-muted-foreground",children:"No versions were returned for this agent."}),c&&t.jsx(Yt,{problem:c,className:"m-4"}),a&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",disabled:u,onClick:()=>void v(a),children:u?"Loading":"Load more versions"})})]}):t.jsx(Fn,{label:"Loading versions",rows:4})}const s2=(e,n)=>e.name.localeCompare(n.name,void 0,{sensitivity:"base",numeric:!0})||(e.id<n.id?-1:e.id>n.id?1:0),id=e=>[...e].sort((n,s)=>s2({name:n.definition.name||n.agent_id,id:n.agent_id},{name:s.definition.name||s.agent_id,id:s.agent_id}));function JM(e){return e.usd===null?{total:"Unknown"}:{total:eo({usd:e.usd,basis:"estimate",charge_state:null,cap_usd:null}),...e.unknownRuns?{note:`${e.unknownRuns} ${e.unknownRuns===1?"run":"runs"} unknown`}:{}}}const Cv=[{id:"7d",label:"7 days",days:7},{id:"30d",label:"30 days",days:30},{id:"all",label:"All",days:null}],Vi=864e5,Xg=e=>Math.floor(e/Vi)*Vi;function Ev(e,n=Date.now()){var r;const s=(r=Cv.find(a=>a.id===e))==null?void 0:r.days;return s?new Date(Xg(n)-(s-1)*Vi).toISOString():void 0}const r2=e=>e.completed+e.failed?(e.completed-e.needs_review)/(e.completed+e.failed):null;function XM(e){return[`${e.completed-e.needs_review} completed`,`${e.failed} failed`,e.needs_review?`${e.needs_review} ${e.needs_review===1?"needs":"need"} review`:""].filter(Boolean).join(" · ")}function ZM(e){if(e.input===null||e.cache_read===null||e.cache_write===null)return null;const n=e.input+e.cache_read+e.cache_write;return n?e.cache_read/n:null}const o2=(e,n)=>JM({usd:e.cost_usd,unknownRuns:e.unknown_cost_runs}),$v=e=>e.runs_with_metrics<e.runs?`tokens from ${e.runs_with_metrics} of ${e.runs} runs`:void 0;function Ha(e){return e===null?"Unknown":VS(e)}const Rf=e=>e===null?"—":`${Math.round(e*100)}%`;function pk(e){return e>=36e5?`${(e/36e5).toFixed(1).replace(/\.0$/,"")} h`:e>=6e4?`${Math.round(e/6e4)} min`:`${Math.round(e/1e3)} s`}function eP(e,n,s=Date.now()){if(!e.length)return[];const r=Xg(s),a=Math.max(r-29*Vi,n?Xg(Date.parse(n)):r-29*Vi),i=new Map(e.map(d=>[d.day,d])),c=[];for(let d=a;d<=r;d+=Vi){const u=new Date(d).toISOString().slice(0,10);c.push(i.get(u)??{day:u,runs:0,completed:0,failed:0,needs_review:0,runs_with_metrics:0,tokens:0,cost_usd:null,unknown_cost_runs:0})}return c}function tP(e,n){return{agents:e.agents,runs:{total:e.runs.total,active:e.runs.active,needsInput:e.runs.needs_input,failed:e.runs.failed,statusUnknown:e.runs.status_unknown,needsReview:e.runs.needs_review},perAgent:e.per_agent.map(s=>({agentId:s.agent_id,name:s.name,runs:s.runs})).sort((s,r)=>s2({name:s.name,id:s.agentId},{name:r.name,id:r.agentId})),cost:{usd:e.cost.usd,basis:e.cost.basis,unknownRuns:e.cost.unknown_runs},recent:n,analytics:e.analytics}}function a2({range:e,onRange:n,agent:s,agents:r,onAgent:a}){return t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(sd,{label:"Range",name:"mission-range",value:e,onChange:n,size:"sm",options:Cv.map(i=>({value:i.id,label:i.label}))}),a&&r.length>0&&t.jsx(Rt,{label:"Agent",value:s??"",onChange:i=>a(i||null),className:"h-control-sm w-56",options:[{value:"",label:"All agents"},...r.map(i=>({value:i.agentId,label:i.name}))]})]})}const df=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function i2({a:e,basis:n,now:s=Date.now(),refreshing:r=!1}){const a=e.totals,i=ZM(a),c=r2(a),d=o2(a),u=[{label:"Tokens",value:Ha(a.tokens),notes:[`${i===null?"":`${Rf(i)} of input cached · `}${Ha(a.output)} output`,$v(a),a.requests===null||a.unmetered===null?"Model request counts unavailable":a.unmetered?`${df(a.unmetered,"request")} with no token count`:void 0]},{label:"Run time",value:pk(e.time.wall_ms),notes:[`wall time of ${df(e.time.ended_runs,"ended run")}`,e.time.active_runs?`${pk(e.time.active_ms)} active, over ${df(e.time.active_runs,"run")}`:void 0]},{label:"Success rate",value:Rf(c),notes:[a.completed+a.failed?XM(a):"No run completed or failed yet"]},{label:"Cost",value:d.total,notes:[d.note]}];return t.jsxs("div",{className:oe("space-y-6 transition-opacity",r&&"opacity-60"),"aria-busy":r,children:[t.jsx("ul",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4",children:u.map(f=>t.jsxs("li",{className:"border bg-card p-5",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:f.label}),t.jsx("p",{className:"mt-3 font-mono text-2xl leading-tight",children:f.value}),f.notes.filter(Boolean).map(g=>t.jsx("p",{className:"mt-2 text-small leading-relaxed text-muted-foreground",children:g},g))]},f.label))}),t.jsx(oP,{days:eP(e.by_day,e.filter.from,s)}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2",children:[t.jsx(nP,{rows:e.by_harness_effort,basis:n}),t.jsx(sP,{tools:e.tools})]}),t.jsx(rP,{groups:e.by_source})]})}function Fi({title:e,children:n}){return t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsx("h3",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:e}),n]})}const l2="px-4 py-2 text-left font-normal",jr="px-4 py-2.5 align-top";function nP({rows:e,basis:n}){return t.jsx(Fi,{title:"Success by harness and effort",children:e.length?t.jsx("div",{className:"overflow-x-auto",role:"region","aria-label":"Success by harness and effort, table",tabIndex:0,children:t.jsxs("table",{className:"w-full border-collapse text-body",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Harness","Effort","Runs","Success","Tokens","Cost"].map(s=>t.jsx("th",{className:l2,children:s},s))})}),t.jsx("tbody",{children:e.map(s=>{const r=o2(s),a=$v(s);return t.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[t.jsx("td",{className:jr,children:s.harness}),t.jsx("td",{className:oe(jr,!s.effort&&"text-muted-foreground"),children:s.effort??"unset"}),t.jsx("td",{className:jr,children:s.runs}),t.jsx("td",{className:jr,children:Rf(r2(s))}),t.jsxs("td",{className:jr,children:[t.jsx("span",{className:"whitespace-nowrap",children:Ha(s.tokens)}),a&&t.jsx("span",{className:"block text-label text-muted-foreground",children:a})]}),t.jsxs("td",{className:jr,children:[t.jsx("span",{className:"whitespace-nowrap",children:r.total}),r.note&&t.jsx("span",{className:"block text-label text-muted-foreground",children:r.note})]})]},`${s.harness}:${s.effort??""}`)})})]})}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs in this range."})})}function sP({tools:e}){return t.jsx(Fi,{title:"Top tools",children:e.length?t.jsx("div",{className:"overflow-x-auto",role:"region","aria-label":"Top tools, table",tabIndex:0,children:t.jsxs("table",{className:"w-full border-collapse text-body",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps border-b text-label text-muted-foreground",children:["Tool","Calls","Errors","Error rate"].map(n=>t.jsx("th",{className:l2,children:n},n))})}),t.jsx("tbody",{children:e.map(n=>t.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[t.jsx("td",{className:jr,title:n.tool,children:n.label}),t.jsx("td",{className:jr,children:Ha(n.calls)}),t.jsx("td",{className:oe(jr,n.errors>0&&"text-destructive-text"),children:Ha(n.errors)}),t.jsx("td",{className:jr,children:Rf(n.calls?n.errors/n.calls:null)})]},n.tool))})]})}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No tool calls in runs with metrics."})})}function rP({groups:e}){return e.some(n=>n.source!=="live"&&n.runs>0)?t.jsx("p",{className:"font-mono text-small text-muted-foreground","aria-label":"Runs by source",children:e.map(n=>`${n.source==="live"?"Run here":`Imported from ${n.source}`}: ${df(n.runs,"run")}`).join(" · ")}):null}const ag=e=>Math.max(0,e.runs-e.completed-e.failed);function gk(e){if(e<=0)return 1;const n=10**Math.floor(Math.log10(e));return[1,2,5,10].map(s=>s*n).find(s=>s>=e)}const ig=e=>e.slice(5);function oP({days:e}){const n=e.some(d=>d.runs>0),s=t.jsxs(t.Fragment,{children:[t.jsx(iT,{className:"size-4","aria-hidden":!0}),"Run activity"]}),r=t.jsxs(t.Fragment,{children:[t.jsx(hT,{className:"size-4","aria-hidden":!0}),"Token usage"]});if(!n)return t.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[t.jsx(Fi,{title:s,children:t.jsxs("p",{className:"flex min-h-[220px] items-center justify-center px-5 py-6 text-center text-body text-muted-foreground",children:["No runs started in this range",e.length?" in the last 30 days":"","."]})}),t.jsx(Fi,{title:r,children:t.jsx("p",{className:"flex min-h-[220px] items-center justify-center px-5 py-6 text-center text-body text-muted-foreground",children:"No token usage in this range."})})]});const a=gk(Math.max(...e.map(d=>d.runs))),i=gk(Math.max(...e.flatMap(d=>d.tokens===null?[]:[d.tokens]),0)),c=[{key:"completed",label:"Completed",className:"bg-muted-foreground",of:d=>d.completed},{key:"failed",label:"Failed",className:"bg-destructive",of:d=>d.failed},{key:"other",label:"Other",className:"bg-border-strong",of:ag}];return t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-small text-muted-foreground",children:`Per day, ${e[0].day} to ${e.at(-1).day} (UTC)`}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[t.jsx(Fi,{title:s,children:t.jsxs("figure",{className:"p-5",children:[t.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-small",children:[t.jsx("span",{className:"font-semibold",children:"Runs"}),c.map(d=>t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx("span",{className:oe("inline-block size-2.5 ",d.className),"aria-hidden":!0}),d.label]},d.key))]}),t.jsx(xk,{days:e,top:a,label:"Runs per day",stack:d=>c.map(u=>({className:u.className,value:u.of(d)})),readout:d=>[`${d.runs} ${d.runs===1?"run":"runs"}`,`${d.completed} completed · ${d.failed} failed · ${ag(d)} other`]})]})}),t.jsx(Fi,{title:r,children:t.jsxs("figure",{className:"p-5",children:[t.jsxs("figcaption",{className:"mb-2 text-small font-semibold",children:["Tokens",e.some(d=>d.tokens===null)&&t.jsx("span",{className:"ml-2 font-normal text-muted-foreground",children:"? means unavailable"})]}),t.jsx(xk,{days:e,top:i,label:"Tokens per day",format:Ha,stack:d=>[{className:"bg-primary",value:d.tokens}],readout:d=>[`${Ha(d.tokens)} tokens`,$v(d)??`${d.runs} ${d.runs===1?"run":"runs"}`]})]})})]}),t.jsxs("details",{className:"border bg-card px-5 py-3",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),t.jsx("div",{className:"overflow-x-auto",role:"region","aria-label":"Per day, table",tabIndex:0,children:t.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Day","Runs","Completed","Failed","Other","Tokens"].map(d=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:d},d))})}),t.jsx("tbody",{children:e.map(d=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:d.day}),t.jsx("td",{className:"pr-4",children:d.runs}),t.jsx("td",{className:"pr-4",children:d.completed}),t.jsx("td",{className:"pr-4",children:d.failed}),t.jsx("td",{className:"pr-4",children:ag(d)}),t.jsx("td",{className:"pr-4",children:d.tokens===null?"Unknown":d.tokens.toLocaleString("en-US")})]},d.day))})]})})]})]})}function xk({days:e,top:n,label:s,stack:r,readout:a,format:i=c=>c.toLocaleString("en-US")}){const[d,u]=p.useState(e.length-1),f=Math.min(d,e.length-1),g=j=>{var E;const k=j.key==="ArrowRight"?Math.min(f+1,e.length-1):j.key==="ArrowLeft"?Math.max(f-1,0):j.key==="Home"?0:j.key==="End"?e.length-1:-1;k<0||(j.preventDefault(),u(k),(E=j.currentTarget.querySelectorAll('[role="listitem"]')[k])==null||E.focus())},[b,x]=p.useState(null),[h,v]=p.useState(null),y=e.find(j=>j.day===(b??h));return t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"flex w-10 shrink-0 flex-col justify-between text-right font-mono text-micro text-muted-foreground",style:{height:140},"aria-hidden":!0,children:[t.jsx("span",{children:i(n)}),t.jsx("span",{children:i(n/2)}),t.jsx("span",{children:"0"})]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"relative flex items-end gap-px border-b border-border-strong",style:{height:140},role:"list","aria-label":s,onMouseLeave:()=>x(null),onKeyDown:g,children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 border-t border-border","aria-hidden":!0}),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-1/2 border-t border-border","aria-hidden":!0}),e.map((j,k)=>{const E=r(j),S=E.some(_=>_.value===null),N=E.filter(_=>_.value!==null&&_.value>0);return t.jsxs("div",{role:"listitem",tabIndex:k===f?0:-1,"aria-label":`${j.day}: ${a(j).join(", ")}`,onMouseEnter:()=>x(j.day),onFocus:()=>{v(j.day),u(k)},onBlur:()=>v(null),className:"group relative flex h-full min-w-0 flex-1 flex-col items-center justify-end focus-visible:outline-focus focus-visible:outline-ring hover:bg-accent/60 focus-visible:bg-accent/60",children:[S&&t.jsx("span",{"aria-hidden":!0,className:"font-mono text-small text-muted-foreground",children:"?"}),t.jsx("div",{className:"flex w-full max-w-6 flex-col-reverse gap-0.5",children:N.map((_,$)=>t.jsx("div",{className:_.className,style:{height:Math.max(1,Math.round(_.value/n*(140-2*(N.length-1))))}},$))})]},j.day)})]}),t.jsxs("div",{className:"mt-1 flex justify-between font-mono text-micro text-muted-foreground","aria-hidden":!0,children:[t.jsx("span",{children:ig(e[0].day)}),e.length>2&&t.jsx("span",{children:ig(e[Math.floor(e.length/2)].day)}),t.jsx("span",{children:ig(e.at(-1).day)})]}),t.jsx("div",{"aria-label":`${s} readout`,className:"mt-2 min-h-16 break-words font-mono text-label text-muted-foreground",children:y?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block font-semibold text-foreground",children:a(y)[0]}),a(y).slice(1).map(j=>t.jsx("span",{className:"block",children:j},j)),t.jsx("span",{className:"block",children:y.day})]}):"Hover or focus a day for its figures."})]})]})}const on=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),uf=e=>e.replace(/~/g,"~0").replace(/\//g,"~1");function aP(e){const n=new Map;let s=0;const r=d=>{throw Object.assign(new Error(d),{offset:s})},a=()=>{for(;s<e.length&&`
|
|
578
|
+
\r`.includes(e[s]);)s++},i=()=>{const d=s;for(s++;s<e.length&&e[s]!=='"';)e[s]==="\\"?s++:e.charCodeAt(s)<32&&r("a string cannot hold a raw line break or control character"),s++;s>=e.length&&(s=d,r("this string is not closed")),s++;try{return JSON.parse(e.slice(d,s))}catch{return s=d,r("this string has a bad escape")}},c=d=>{a();const u=s;let f;const g=e[s];if(g==="{"){s++;const b={};if(a(),e[s]==="}")s++;else for(;;){a(),e[s]!=='"'&&r(e[s]==="}"?"a trailing comma before }":"expected a key in double quotes");const x=i();if(a(),e[s]!==":"&&r("expected : after the key"),s++,b[x]=c(`${d}/${uf(x)}`),a(),e[s]===","){s++;continue}if(e[s]==="}"){s++;break}r("expected , or } after the value")}f=b}else if(g==="["){s++;const b=[];if(a(),e[s]==="]")s++;else for(;;){if(b.push(c(`${d}/${b.length}`)),a(),e[s]===","){s++,a(),e[s]==="]"&&r("a trailing comma before ]");continue}if(e[s]==="]"){s++;break}r("expected , or ] after the value")}f=b}else if(g==='"')f=i();else{const b=/^(?:-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(e.slice(s,s+400));b||r(s>=e.length?"the text ends before the value":"expected a value"),s+=b[0].length,f=JSON.parse(b[0])}return n.set(d,{start:u,end:s}),f};try{const d=c("");return a(),s<e.length&&r("text after the end of the JSON"),{ok:!0,value:d,spans:n}}catch(d){return{ok:!1,error:{message:d.message,offset:d.offset??0}}}}function iP(e,n){let s=1,r=-1;for(let a=0;a<Math.min(n,e.length);a++)e[a]===`
|
|
579
|
+
`&&(s++,r=a);return{line:s,col:n-r}}function c2(e,n){let s=e;for(const r of n.split("/").slice(1)){const a=r.replace(/~1/g,"/").replace(/~0/g,"~");if(Array.isArray(s))s=s[Number(a)];else if(on(s))s=Object.prototype.hasOwnProperty.call(s,a)?s[a]:void 0;else return}return s}const d2=new Set(["judge","pick","sift","route"]),vk=["jev","parallel","openrouter"];function lP(e){return!on(e)||!on(e.properties)?[]:Object.entries(e.properties).flatMap(([n,s])=>{if(!on(s))return[];const r=typeof s.description=="string"?s.description:n;return Array.isArray(s.enum)?[{id:n,type:"choice",text:r,options:s.enum.map(String)}]:s.type==="boolean"?[{id:n,type:"noul",text:r}]:s.type==="integer"?[{id:n,type:"score",text:r}]:[{id:n,type:"choice",text:r}]})}function _v(e,n,s){const r=c2(e,n);if(!on(r))return{decision:!1};const a=r.node,i=s??{},c=a==="route"&&typeof r.valuePath=="string",d=typeof a=="string"&&d2.has(a)&&!c||Array.isArray(i.questions);if(!d)return{decision:!1,...a==="call"&&typeof r.tool=="string"?{tool:r.tool}:{}};const u=typeof i.provider=="string"?i.provider:typeof r.provider=="string"?r.provider:"jev",f=typeof i.model=="string"?i.model:typeof r.model=="string"?r.model:void 0,g=on(e)&&on(e.schemas)?e.schemas:{};let b=[];Array.isArray(i.questions)?b=i.questions.map(v=>({id:v.id,type:v.type==="choice"||v.type==="score"?v.type:"noul",text:v.instructions||v.id,...v.options?{options:v.options}:{}})):a==="judge"||a==="sift"?b=typeof r.out=="string"?lP(g[r.out]):[]:a==="pick"?b=[{id:"pick",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Pick one"}]:a==="route"&&(b=[{id:"branch",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Which branch?",options:on(r.branches)?Object.keys(r.branches):[]}]);const x=Array.isArray(i.images)?i.images.map(String):on(r.images)?Object.keys(r.images):[],h=on(r.unsure)&&typeof r.unsure.branch=="string"&&typeof r.unsure.gte=="number"?{branch:r.unsure.branch,gte:r.unsure.gte}:void 0;return{decision:d,provider:u,model:f,questions:b,...x.length?{images:x}:{},web:u==="parallel",...h?{unsure:h}:{}}}const cP=new Set(["chain","code","agent","decide","extract","report","map","parallel","loop","escalate","judge","pick","sift","route","workflow","artifact","call"]);function dP(e){const n=[],s=(d,u)=>n.push({path:d,message:u,severity:"error"}),r=(d,u)=>n.push({path:d,message:u,severity:"warning"});if(!on(e))return s("","the workflow is a JSON object"),n;e.v!==2&&s("/v",'the workflow format is "v": 2'),(typeof e.name!="string"||!e.name)&&s("/name","the workflow needs a name");const a=on(e.schemas)?e.schemas:{};on(e.input)&&typeof e.input.schemaId=="string"&&!a[e.input.schemaId]&&s("/input/schemaId",`no schema "${e.input.schemaId}" in schemas`),on(e.output)?typeof e.output.schemaId=="string"&&!a[e.output.schemaId]&&s("/output/schemaId",`no schema "${e.output.schemaId}" in schemas`):s("",'the workflow needs an output: { "schemaId": ..., "path": ... }');const i=new Map,c=(d,u)=>{if(!on(d)){s(u,'expected a node (an object with a "node" kind)');return}const f=d.node;if(typeof f!="string"||!cP.has(f)){s(`${u}/node`,typeof f=="string"?`"${f}" is not a node kind`:'a node names its kind in "node"');return}f!=="chain"&&(typeof d.label!="string"||!d.label?s(u,`a ${f} node needs a label`):i.has(d.label)?r(`${u}/label`,`the label "${d.label}" is also used at ${i.get(d.label)}; receipts name nodes by label`):i.set(d.label,u));const g=(x,h)=>{d[x]===void 0&&s(u,`a ${f} node needs ${x} (${h})`)},b=x=>{typeof d[x]=="string"&&!a[d[x]]&&s(`${u}/${x}`,`no schema "${d[x]}" in schemas`)};switch(f){case"chain":!Array.isArray(d.steps)||!d.steps.length?s(u,"a chain needs steps"):d.steps.forEach((x,h)=>c(x,`${u}/steps/${h}`));break;case"parallel":!Array.isArray(d.branches)||!d.branches.length?s(u,"a parallel node needs branches"):d.branches.forEach((x,h)=>c(x,`${u}/branches/${h}`));break;case"map":g("itemsPath","where the items are"),g("as","where the results go"),c(d.body,`${u}/body`);break;case"loop":g("until","when it stops"),g("maxIters","a bound"),c(d.body,`${u}/body`);break;case"workflow":on(d.workflow)?c(d.workflow.root,`${u}/workflow/root`):s(u,"a workflow node embeds its workflow");break;case"call":g("via","tool, executor or shell"),d.via==="tool"&&g("tool","the tool's name");break;case"code":typeof d.code!="string"&&s(u,"a code node needs code");break;case"escalate":g("when","the predicate that fires it"),g("kind","the review it asks for");break;case"judge":case"sift":g("out","the questions' schema"),b("out"),g("as","where the answers go");break;case"pick":g("itemsPath","the options' list"),g("as","where the pick goes");break;case"agent":case"decide":case"extract":b("out");break}if(f==="route"){if(!on(d.branches)||!Object.keys(d.branches).length)s(u,"a route needs branches");else for(const[x,h]of Object.entries(d.branches))on(h)?c(h.body,`${u}/branches/${uf(x)}/body`):s(`${u}/branches/${uf(x)}`,`branch "${x}" is an object with a body`);typeof d.valuePath!="string"&&d.instructions===void 0&&s(u,"a route asks by instructions (and state), or reads a valuePath"),on(d.unsure)&&on(d.branches)&&typeof d.unsure.branch=="string"&&!(d.unsure.branch in d.branches)&&s(`${u}/unsure/branch`,`the unsure branch "${d.unsure.branch}" is not one of the branches`)}if(d2.has(f)&&!(f==="route"&&typeof d.valuePath=="string")&&(d.provider!==void 0&&!vk.includes(d.provider)&&r(`${u}/provider`,`provider "${String(d.provider)}" is not one of ${vk.join(", ")}`),d.provider==="openrouter"&&typeof d.model!="string"&&s(u,"an openrouter decision names its model (e.g. perplexity/pplx-decider-v1.2)"),on(d.images))){const x=JSON.stringify(d.state??{})+JSON.stringify(d.instructions??"")+(typeof d.out=="string"?JSON.stringify(a[d.out]??{}):"");for(const h of Object.keys(d.images))x.includes(h)||s(`${u}/images/${uf(h)}`,`the image token "${h}" must appear in the state or a question, or the model never sees it`)}};return e.root===void 0?s("","the workflow needs a root node"):c(e.root,"/root"),n}function yk(e,n){for(let s=n;;s=s.slice(0,s.lastIndexOf("/"))){const r=e.get(s);if(r)return r;if(!s)return}}function uP(e,n,s){let r=null,a=1/0;for(const i of n){const c=e.get(i);c&&c.start<=s&&s<=c.end&&c.end-c.start<a&&(r=i,a=c.end-c.start)}return r}function fP(e){const n=ll(e),r=n.nodes.map(i=>_v(e,i.path,i)).filter(i=>i.decision),a=[...new Set(r.map(i=>i.provider??"jev"))];return`${n.nodes.length} nodes · ${r.length} ${r.length===1?"decision":"decisions"}${a.length?` · ${a.join(", ")}`:""}`}const Af=e=>e==="not_run"?"not-run":e==="needs_review"?"review":e,bk=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),ld=e=>["completed","failed","cancelled","stopped","escalated"].includes(e);function cd(e,n){return Object.fromEntries(n.nodes.map(s=>[s.path,_v(e,s.path,s)]))}const Du=e=>e>=.995?"1.00":e.toFixed(2);function cl(e){var d;if(e.status==="failed")return"failed";if(e.status==="cancelled")return"interrupted";const n=e.answers??{},s=e.action;if(((d=e.rule)==null?void 0:d.kind)==="route"&&s&&typeof s=="object"&&(s.taken||s.branch)){const u=n.branch,f=u&&u.type==="choice"?u.confidence:void 0;return s.unsure?`${s.taken} (unsure)`:`${s.taken??s.branch}${f!==void 0?` ${Du(f)}`:""}`}const r=Object.keys(n);if(!r.length)return;const a=u=>{const f=n[u];return f.type==="choice"?`${u2(e,u,f.choice)} ${Du(f.probabilities[f.choice]??f.confidence)}`:f.type==="noul"?`${f.noul>=.5?"yes":"no"} ${Du(f.noul>=.5?f.noul:1-f.noul)}`:f.type==="score"?`${f.score} ${Du(f.confidence)}`:f.type==="refusal"?"refused":"box"};if(r.length===1)return a(r[0]);const i=u=>{const f=n[u];return f.type==="noul"?Math.abs(f.noul-.5)*2:"confidence"in f&&typeof f.confidence=="number"?f.confidence:1},c=r.reduce((u,f)=>i(f)<i(u)?f:u,r[0]);return`${c} ${a(c)}`}function u2(e,n,s){var i,c;const r=(i=e.questions)==null?void 0:i[n],a=e.kind==="pick"&&(r==null?void 0:r.type)==="choice"?(c=r.criteria)==null?void 0:c[s]:null;return typeof a=="string"&&a?a:s}const f2=(e,n)=>e.nodes.filter(s=>s.path.startsWith(`${n}/body`)).map(s=>s.path);function mP(e,n,s){var b,x;const r=(x=(b=e.nodes[n])==null?void 0:b.items)==null?void 0:x.find(h=>h.index===s),a={};if(!r)return a;const i=new Set(["chain","parallel","route","map","loop","workflow"]),c=new Map(e.graph.nodes.map(h=>[h.path,h.kind])),d=f2(e.graph,n).filter(h=>!i.has(c.get(h)??""));let u=-1;d.forEach((h,v)=>{const y=e.decisions.filter(k=>k.node===h&&k.item===s),j=e.effects.filter(k=>k.node===h&&k.item===s);!y.length&&!j.length||(u=v,y.some(k=>k.status==="failed")||j.some(k=>k.status==="failed")?a[h]="failed":y.some(k=>k.status==="cancelled")?a[h]="review":j.some(k=>!k.endedAt)?a[h]=j.some(k=>k.status==="stopped")?"stopped":"working":a[h]="done")});const f=Af(r.status)??"pending";let g=!Object.values(a).includes("working");return d.forEach((h,v)=>{a[h]||(v<u||f==="done"?a[h]="done":f==="working"?(a[h]=g?"working":"pending",g=!1):f==="pending"?a[h]="pending":a[h]="not-run")}),a}function hP(e,n){var g,b,x;const s={},r=[],a={};let i=null;const c=new Map(e.graph.nodes.map(h=>[h.path,h.kind]));for(const[h,v]of Object.entries(e.nodes)){const y=Af(v.status);y&&(s[h]=y),v.branch&&r.push(`${h}/branches/${bk(v.branch)}/body`),v.items&&(a[h]=v.items.map(j=>({index:j.index,status:Af(j.status)??"pending",label:Uc(e,h,j.index),...Tv(e,h,j)}))),v.status==="escalated"&&c.get(h)==="escalate"&&(i=h)}const d={},u=h=>/\/body(\/|$)/.test(h)&&e.graph.nodes.some(v=>v.kind==="map"&&h.startsWith(`${v.path}/body`));for(const h of e.decisions){if(!h.node||h.item!==null||u(h.node))continue;const v=cl(h);v&&(d[h.node]=v)}if(n&&n.item!=null&&c.get(n.path)==="map"){Object.assign(s,mP(e,n.path,n.item));const h=((x=(b=(g=e.nodes[n.path])==null?void 0:g.items)==null?void 0:b.find(v=>v.index===n.item))==null?void 0:x.branches)??{};for(const[v,y]of Object.entries(h)){const j=`${v}/branches/`,k=`${j}${bk(y)}/body`;for(let E=r.length-1;E>=0;E--)r[E].startsWith(j)&&r.splice(E,1);r.push(k);for(const E of e.graph.nodes)E.path.startsWith(j)&&!(E.path===k||E.path.startsWith(`${k}/`))&&(s[E.path]="not-run")}for(const v of e.decisions)if(v.node&&v.item===n.item&&v.node.startsWith(`${n.path}/body`)){const y=cl(v);y&&(d[v.node]=y)}}if(e.run.paused){for(const[h,v]of Object.entries(s))v==="working"&&(s[h]="held");for(const h of Object.values(a))for(const v of h)v.status==="working"&&(v.status="held")}const f={};for(const[h,v]of Object.entries(e.nodes))v.model&&(f[h]={model:v.model,...v.tier?{tier:v.tier}:{}});return{status:s,taken:r,items:a,fired:i,verdict:d,meta:cd(e.workflow,e.graph),selected:n,...Object.keys(f).length?{ran:f}:{}}}const lg={accept:"good",accepted:"good",approve:"good",approved:"good",valid:"good",pass:"good",auto:"good",agree:"good",ok:"good",clear:"good",low:"good",review:"warn",hold:"warn",doubtful:"warn",borderline:"warn",unsure:"warn",human:"warn",escalate:"warn",edd:"warn",medium:"warn",second_look:"warn",disagree:"warn",reject:"bad",rejected:"bad",decline:"bad",declined:"bad",invalid:"bad",fail:"bad",deny:"bad",high:"bad",block:"bad"},pP=e=>{if(!e)return;const n=e.toLowerCase();return lg[n]??lg[n.split(/[_\s-]/)[0]]??lg[n.split(/[_\s-]/).at(-1)??""]};function gP(e){if(e.status!=="answered"||!e.answers)return;const n=e.action,s=e.answers.branch;if(n&&typeof n=="object"&&n.taken&&(s==null?void 0:s.type)==="choice")return{p:s.confidence,note:`${e.kind} confidence`};let r;for(const[a,i]of Object.entries(e.answers)){const c=i.type==="noul"?{p:Math.max(i.noul,1-i.noul),note:`${a}: ${i.noul>=.5?"yes":"no"}, P(yes) ${i.noul.toFixed(2)}`,sure:Math.abs(i.noul-.5)}:i.type==="choice"||i.type==="score"?{p:i.confidence,note:`${a} confidence`,sure:i.confidence-.5}:void 0;c&&(!r||c.sure<r.sure)&&(r=c)}return r&&{p:r.p,note:`least sure: ${r.note}`}}function Tv(e,n,s){const r=f2(e.graph,n),a=x=>x?r.indexOf(x):-1,i=e.decisions.filter(x=>{var h;return x.item===s.index&&!!((h=x.node)!=null&&h.startsWith(`${n}/body`))}).sort((x,h)=>a(x.node)-a(h.node));let c,d;const u=Object.entries(s.branches??{}).sort(([x],[h])=>a(x)-a(h));if(u.length)[d,c]=u[u.length-1];else{const x=i.filter(h=>{var v;return h.status==="answered"&&((v=h.action)==null?void 0:v.taken)}).at(-1);x&&(c=x.action.taken,d=x.node??void 0)}const f=d&&i.filter(x=>x.node===d).at(-1)||i.filter(x=>x.status==="answered").at(-1),g=f?gP(f):void 0,b=s.status==="failed"?"bad":s.status==="needs_review"||s.status==="escalated"?"warn":pP(c);return{...c?{outcome:c}:{},...g?{p:g.p,pNote:g.note}:{},...b?{tone:b}:{}}}function Uc(e,n,s){var d,u;const r=(u=(d=e.nodes[n])==null?void 0:d.items)==null?void 0:u.find(f=>f.index===s);if(r!=null&&r.label)return r.label;const a=e.effects.find(f=>{var g;return f.item===s&&!!((g=f.node)!=null&&g.startsWith(`${n}/body`))}),i=a==null?void 0:a.input,c=(i==null?void 0:i.path)??(i==null?void 0:i.url);return typeof c=="string"?c:void 0}function m2(e=[]){const n={total:e.length,done:0,working:0,failed:0,review:0,pending:0};for(const s of e)s.status==="done"?n.done++:s.status==="working"?n.working++:s.status==="failed"?n.failed++:s.status==="needs_review"||s.status==="escalated"?n.review++:n.pending++;return n}function h2(e){const n=e.decisions.filter(s=>s.cost_usd===null).length;return{usd:e.totals.cost_usd??e.decisions.reduce((s,r)=>s+(r.cost_usd??0),0),unknown:e.totals.cost_usd===null?n:0}}const kl=e=>e==null?"Unknown":e>0&&e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,Yi=e=>e==null?"—":e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`;function dl(e){const n=Math.max(0,Math.floor(e/1e3)),s=Math.floor(n/60);return s?`${s}m ${String(n%60).padStart(2,"0")}s`:`${n}s`}const xP=(e,n,s)=>{const r=e.totals.elapsed_ms??(Date.parse(e.run.endedAt??"")||n)-Date.parse(e.run.startedAt);return ld(e.run.status)||e.run.paused?r:r+Math.max(0,s-n)};function vP(e,n,s){return e!=="input_required"||n!=="waiting"?null:s.findLast(r=>r.kind==="waiting")??null}function yP(e){const n=e.content_type??"";return n.startsWith("text/markdown")||e.path.toLowerCase().endsWith(".md")?"markdown":n.startsWith("text/")||n.includes("json")?"text":"download"}function p2(e){return e.split("/").slice(0,-1).some(n=>n.startsWith(".")||n==="__pycache__"||n==="node_modules")}const g2="The agent finished without writing an answer.",wk=[0,250,1e3],bP=e=>new Promise(n=>setTimeout(n,e));function Zg(){let e=0;return{begin:()=>++e,current:n=>n===e,cancel:()=>{e++}}}const x2="30d",jk=10,wP=["queued","working","input_required","paused"];function jP({agent:e,v2:n,now:s=Date.now,stats:r}){const[a,i]=p.useState(x2),[c,d]=p.useState(r??null),[u,f]=p.useState(null),[g,b]=p.useState(!0),[x,h]=p.useState(0),v=p.useRef(0),y=p.useRef(!0);p.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]);const j=p.useRef(null),k=p.useRef(null);p.useEffect(()=>{const S=`${a}/${x}`;if(k.current===S)return;const N=++v.current;if(j.current===S){k.current=null,f(null),b(!1);return}k.current=S,b(!0),f(null),(async()=>{for(const[_,$]of wk.entries()){if($&&await bP($),N!==v.current||!y.current)return;try{const O=await n.statsOver({from:Ev(a,s()),agent:e.agent_id});if(N!==v.current||!y.current)return;const A=!(O.runs.status_unknown>0);if(d(O),j.current=A||_===wk.length-1?S:null,A)break}catch(O){N===v.current&&f(Ft(O));break}}N===v.current&&(k.current=null,b(!1))})()},[n,e.agent_id,a,x]),p.useEffect(()=>{const S=new AbortController,N=_=>({status:_,...e.archived_at?{archived:!0}:{}});return Promise.allSettled(wP.map(_=>n.listAgentRuns(e.agent_id,jk,null,N(_)))).then(_=>{if(S.signal.aborted)return;const $=_.flatMap(O=>O.status==="fulfilled"?O.value.runs:[]).filter(O=>!ld(O.status));for(const O of $.slice(0,jk)){let A=`${O.status}/${O.state}`;XS(n,O.run_id,{signal:S.signal,onPage:L=>{const M=`${L.status}/${L.state}`;M!==A&&(A=M,h(R=>R+1))}}).catch(()=>{})}}),()=>S.abort()},[n,e.agent_id]);const E=c==null?void 0:c.analytics;return t.jsxs("div",{className:"space-y-6",children:[t.jsx(a2,{range:a,onRange:i,agent:null,agents:[]}),u?t.jsxs("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:["The analytics could not be read: ",u]}):!c||!E?t.jsx("p",{className:"py-12 text-center font-mono text-body text-muted-foreground",children:"Loading analytics..."}):E.totals.runs?t.jsx(i2,{a:E,basis:c.cost.basis,now:s(),refreshing:g}):t.jsx("div",{className:"border px-4 py-12 text-center",children:t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"No runs of this agent in this range."})})]})}const Rv=["codex","codex-cli","claude","claude-cli","cursor","other"],v2="agentrun.coding-agent.v1",cg="agentrun:coding-agent",dg={codex:"Codex app","codex-cli":"Codex CLI",claude:"Claude Code app","claude-cli":"Claude Code CLI",cursor:"Cursor",other:"Other / terminal"};function kk(){try{const e=localStorage.getItem(v2);return Rv.includes(e)?e:""}catch{return""}}function kP(e){try{localStorage.setItem(v2,e)}catch{}}function NP(e,n){const s=encodeURIComponent(n),r=e==="codex"?`codex://new?prompt=${s}`:e==="claude"?`claude://code/new?q=${s}`:e==="cursor"?`cursor://anysphere.cursor-deeplink/prompt?text=${s}`:null;return r&&r.length<=8e3?r:null}const SP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGgAAABoCAYAAAAdHLWhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAJnFJREFUeAHtfQuYFdWV7tpVdc7pprvpppvuhm4ejQ9AQQFFUEEUfAUVH4k448TRuT4y0UnumGiSm0y8YuZO8jlXRx0fMXGi5rtqfIyj8YWiKCoEQcGAgAEabZAG+km/+/Q5VXvfvXftvWtV9ek3oM7X6/uqq07Vrl1V699rrX+vvasaYFiGZViGZViGZViGZViG5VAKUUs3YYyRPs77byNftYfRoDCxLFu2zHrr/ZEV444Zd9KMU046c0Qia+LY8lETxx41ojDZBJ07d1Y3Upr4/NNNm/+8v7ltbePW97atWnV3faQuCl9j+aoAJO7D4osnfpz3rbumXvY3139/2nEjLystJmNLcgEcruYEL+F2AaRdBhYhEIurE7IAmjoB2rvA27ItvW3NB5UPH9j8zBNPPnlHS7Tur5t8FQCywW/l7Lqb18775lWz758xxZmVx23IdoEdqALYvYeR2gYG7a0WpDhAHi9NuMpj/MxEgkFBPsDYMYSOmwRQOBqsZAKgsh68lSv3/8d/PXH/P61f+asGfB34GsmXCZC4tlCae8bSXxbfdNOtLy08NXZqIQdlbyXQjzeBVX2AkXQXAeLwgrykxUGx+ULUXTOuasoXz/MXsTsvh8JRFRadOQsguwSsXdyGXnix5ue3/f2Yf1HXdcQ14WsiXxZAxu384M5d/+Paq496dOoogM82QXrteog1cqU6XI2xGC8kgFFRSQDUmwjT8LjqXdevfGI50HlnALVKwHlrE1Q98/DT855+9Mp9/BB3jpCCr4F8GQCZ4P2715IvXLIocaldw9x3VhLrizqwBDBxR1mKAgTj0hdIWlzuzFIpv/wJxzF39unE2doG8MhDm77xwC9mvgEBGZH39J3v/MbZsSNuFxfvps89t0xYGM1w3wBH2EUeaYAMOL9/vfOTy8/Mmr5nM3StWQOJLq6OrIQCBhQQiGhrt0aEeqyeb1y4PcPd+Jpy19fFgSouYvSsMxltyrOct95q/vG67ZtXxtrot06dN/f0xIiuieXl+QWeBTE3Ce7Bxtb21nZSR7vaN77x9qdv19R9sGbV0z+tij4DHAE5kgAZt/bY8uTmK+YnTvhkDU19vNWKC1AS8QAUguKMpf702Cnqh1BhTWkek3gDmH8apBLlEE/yfUWcXMSEmrm90JQPprwct2DC76eL/05zF9vCj23fBbtXvL3ryVUv/eb+D1f93wNwhNjhkQRIBufHXup69aLT4xdUrmepTZ+SuKDKwqVJYBA4Iu5oUIiV4a77unMGIWckyIQAQDSCslJgI/MYaWujUF9PoK3TgjQH0GMcLcpJCb94zGGQm8OguBjY+AkWKynjlWRz4pIEWPF2w0sv/9cL/7D8yRv2wmFmh0cKIAnOLb+quunGqyc+2LKddX24iSQcTgLi4vEsZT2W/7TYakCBFZKIi8v0EBIfCt0ih4hNbsq3KnFMs0KmynjMP09QeUE20imfeMTiDCaMJXTmSUDzy8HZx4F6+vnq+2777rib8TPCIZYjAZAMxouW/rr8V7/87t6RB5n7p3VE9Dsh4fjAEAWQpa1InGX5QGnrIeZP95smfbVdJg3DCDV/gm0DqKLuehHHXG55KbF0+aCNHc3YqacRr3ASOKt3wv7f3vf06S8+fmUVHAZ2eCQAEkbhPfhs8uNFUxIzN38ItKkdrDiPBw5RwChwLOXVQ8CQ8M3KRREFvS8TPma/dnWiPA3KYp8kPZsqZ4CivjkIS2NqcZVVCdJB+frYo5l7ymng1CcIPPJY1eJ7fjrpdX4K9wuQhkMkNhx+YVf/4wfzLzp34s+a9kCq+gA4mhAIQGxMCpSL6waOsizQ5dECkd897Tf1QBDdtVUy1VCwlQqxCOLhEGzY6uT9tcTa8xmhEwuod/L8UVfbBVdVr3vn/o/AB+mQsLzDDZB4FHbTj3/7WolFSj7byWzGtSX6OpoQaAsyv8VZBCkLKVxrlpEBsroMQMl9LAAL75M/iaLs4F9P7tO/1XHB9tragVRVEas0y0vPPXP0pU7h3+1Yv+q+TeDHpCGD1M9u36CFnrXk/qnjism01jpwk2nOkGzlcTJoWGYCSKQl9xBfGAmWgQh2mWBFfkPflomPi9ad4K66i7u799fYsebtnnvFNyue+v5tn80A30MOWb+HEyD56PPOueIH0ApQU8dblI4vynXI3l4GNyI6FpShHRS1XmZ2BQsJL70JgzADZxA+B19WW7KFf2Pw1D7RTRB9pnUbeGKqmneI501af9rSf8uGQ0C9DzVA2L2zs5Ytc46ZXXJFzAPalgTjnhQ5khtC8WLbgAKBAl2qACR+c2QsCNgQWTManCesMLQo+uyqtQbWA+SDtGvDKsVMD1l0pjYg8oYdnYT8mTu3wjSLX/p333td1erAEORQASTuWVi81P38G5+cdPudW+/+5dLbG04Z4RbU1knSY4IuZlIe/q2UKNmUUoTuk2hQqYoNjIWtgZkC4UUCxyKMLoMZafaGGw/eDtO+0MpsxzgUDU3E2r0X0pPt2IKrvrf2LPDb1gAdcVixQxXRQqSeL7/pD6dffvk37zttdnx28QiAxn3APvgTeNX7wRFEwFFJUMzc8LYMvPrGIkTB6uHmtZJ6amm9tUCjfGy5qIFIa9NWRIPGIhbR4tLU3y+2U2I/J9fJtH/No44G2poHe29cSiaC6mrAIGQoAGmrcc++8t7Sb191/R8XL8yZG+8Ctms787ZsIXZdHS9j+3k2R4/nENQpRWkdTRrMGgUDTL6iN0AyHejrrrH1KMGdV9NZReB4yhJFukj/Fi6YKaBEtiHt+esu7s6LisDNmwjOO2s3nP/k/bNXwCBlsP5Rxxr35n/def0NNxzzSCG/+S1rIb1hA3Oa24gjAqfITgurETGE6nhj+du2orQWUpDk5BDEJUmD9U4IGBfBKRzwj1u9gaTLM+hVMCC6XjkgqMHRFqP2gdqWHV1A1scbY0MjOLFsYEcdM+0XfO8KMF3lgclg+kG64dKHl6dfvGLJ6B+1VrH0H1/kAXIbOB7v6GRlgZwvIEZBtZUwlWvTWQCGagv5chZqyKFtHXsyhBozupppwXFKlu+hnEcj+wABQYN90oLAtyZPWZWH3Z8ai7IZZXllsfFN+8c9XF39chsMQgZqQQacR17p+mTeTGf6ptUste4jiIsbHZHlW4wAIEp5baUgz/Ldl2UFuS4LMTtLAagtCli42Rm3FtkXzVISBn3n6JTQaLumAZCgXZ1ae14QmzQYGjQZozSB4TfV0sGfsp7n7o4/aSmsgwdgEDIQgLRb8379ctcnJ58Qn/7eCpba+hcSF1lpEWcECrjzaNYQ9De0nQs3xZR/E4oIAaNcEmXhi2Mv1WM8UmIA7qdT0QxOn0zRWtN4bTlyG8ciBZoXAUlYURMfOaqYMu0iftqgABqIi5Ns7b6X3FdnTI7NW/ceTW3bYcUdMZ4TA5O2wWuCBuCiGmRK21Ip2tpYN/Yb0GQWuDHszgDvQy1fB/RMrs+UjcQVPWZEEUnQCscWI8FAAOnj2uXpY65PGlh8lDOyvGDbPdu2beunTYeV3h+RbO3v7znw/SlH2xds2ci6/rLTSog4o12ajCtoLYkBBMAwpXFqmeISFILIgqa98pTIo2ACgUWfA/h4xCdGz2HoHBwAdSMwdSMioMmAzGqra7g0AMZFgHuYXHhAsl0oSjrnjAJ4rh4GKP0BSMacBZfcPf68+aX/XruTup98aiWsmJ8s7AaMIgCMoN9ihx3EGKrK2Mhfa8XgNIsQ4+7ULpapDWZQtoVAk6kitW2yRypG4eoYDZ9jLDgSZ7D1GZAQ9dakQU0JY9yK7OamxvG8isMCkIw7F1/7w5dTzQy2/MWyhB9OKLcGaNHDBCGgQMUeBIy2Brmtjok6CWrtGgyKUizyZljoZzjDrBSswdR1EI1MJB4ZWhw531gSdnUQAUi7PxoAxSLuUnV25eVTQMfAIKQvgMRjeX9969qzikfDjN2fQpoPtsXi8SDOaGA0INQKhq+1t7FU8JeuzPLB6OKjk8mkn1kYkeMnHImyJj0MoN0TbuXYDTK8HTIFgG59HoMCQLRDGq487OrMgB0EwAALuzHt/ozVsCD35z8SJRb5Ls+t/BMMVPoDEJs8deqDHdw499XwdJPjuzbNwIiuwQqvmTpb68NSZiMAbGykMP3oNEybnOBAUfjTxhQ0tSSgYCQxCuvJUkJpGVUOb0eJBrYaeQs0g5tElocZnFwpQEyHFAGiCYWH4w5D9FsDzVswZS8Naii8L4DokiufmjZ2QsHx9bvBTbnEEazNTPIgwUIQQFJBFvL5VgBSQ6MHf7WYwtwZCZkisfiJ8+bE4dFnu+DzvVkwMhdMh1BIFBizqV0QBFZGIzGIRqwK95UspTxcl1xpdBFQxnrUOcaqEDghi/JP05ZHhJaznOqDMAjpM5tddsKiWzp41Y1N4BCV7NQuDOywe2MoHjHl+ig61toJMGsa4+DEoHI/g921ALt4P6GuhcDV34zzh0pBl4o7Wk9myACCzDeNLJ5SrNnH/EkBHvodpedpFsw5oGrbYxEmpvo9Hg2GQzQYHqBtdA6DgFTIcwgw0U/MyinaC4OQ3gCStjH+mNIL+bAuTfEnsPmFqANmbpQGysJkAdWqx360VSV5JbOOA+gUxs4ZgUgFiRR9U7uYi2bBxWdzmnPQp1waFNP3UXWkMwFC/AyFBjGUqlHKdzMco0rRLlI+ReXlosHDMUb9dlE9uHEwCECTc8ttaKvbWVMLhxggNueyB47lwbsklVQ+3g6y0QT1d5i2JkSt9eCcdm9+n4j4gyORq4q4tqcOYM6JMRhdkJJDyNpSPOVCzTYoBUBYKab1gg+W7ofhctE8nhc5X1uFdpdRq9OAGwsh4eviOoWowUbS2NqxZcOGZR0wCOnVxZWWzZjbwt1bV5qHCkfdiErnmDEczeRIAAhELEdvJ3JsWPcJ5f6YhSI1UQrpcglcfr4FdU18CNY2D2gemqmMg942o7MKRKEwl6AWrM9RblO7y1BL13WrJWRtyLXKuiFcRxRw8xt10hnXW2drcrt61BgcSoAst3yu5vgmhaNBwP0fpQgztxpZjoxFahZPNk+mbtxhwef70jCmkMiUiLkWB2QfZ4rHTYrD5IlpaE+qB1RWaZRIEFCRRUMuf1uBgilmllj5BIGggNSNC1sDy7DQyLZuDDptJe+R7xyZzbxZJxVe81c3r14MvoceUIK6V4AmHD/h2I7WgIEByq3Je1FAaJdGrUB5DMJA6VZVkO/AM28xyE2w0MU1yM3cESw9z4KWVtdYiAZGKyUEHFIoJWHFAbIyF7d87YohDDYmIxCtF1ssoN+RBsMQsxXeprkd7FSd61582bzXln5n9QQY4Gyf3i0I3BKPBQrUw9AW0ipB5Y1SQIGGWrVWWoJb0ec1DmzY4cK40TKZaESQhtomgPLiOJwy3ZNgGctAgGjr0BbKotuqrIesDyA4V5fHLR9n4BkJztXnS5dIgsZIILiOnqeH85CSPHFbSXYR+GSrY9XtADp/8bzNAMv6DY6qsmfhw9QjpGJYAIhptcjtmMmEuvUASm5CuEWLcwoLbXh+FeVWyeTkeYZviD9UfQvAtxbZkBZvDJOwYjTo2orNxSIMEidpCYqbpvHo+wYEqg2Bi0KWHyI9JADatFYrONfEZbUWzLctCda2rZwAd7D8f7z7J4+BX3W/RhJ6R5NYVD+UZEZKk0bhSvBcNeyONCBq00ybEqytoT0OqzamoXy0P9/Z3BAv2MjHHvNzHFg0m/BtJh/eMEELuRk70mDwNgmUSiFsZRoM3G/TDYFaEBoeMW7cDq5h4rAiMjjl1W3Ny4jOfT3vR362naQqKrKuvvja5VMA+jeJpFeAGPPabN1MWWStthmEf2sxlNQK/LsJ4vzg6AICr34g3hqgPB5BqNcvAKxuBLjwdIdbWNrPFqj7kElV3WoBWYZWaITmayVBJIYyHD+RJWgvII/b6DgJyjE7DIK0Hju4DkPXFORHWLAgStU1EG/4nLHjTj3/cfWofVpRrwDZYO22lOVIZbDACvQ+SiGUXIzmupjxg4Er0WAlaQxeWpOCskLwJ84pEISSOrvEa/a887qAQW0jDVwJsk5ALgdPyQWsZG0d6HwDHAQA4v4cTgBjxQOaU25ikR1egwLEAKOOCVcnOvuN9cQrSJBTT1n49jTohxX1CtC+zz7e4WSDn4b3gk4aBgkUSDo/ZfJaFIEEYRB17kwkR9/eaEEDZ2yFed0Jwxecdi84IQal+a58P0c2ag0KBMrGcYNhayJhy5KKRGNYeCF2AKp2Z7ivZ1lhayR2ZFvVbWtg1DQzDZIEjIPU1AJObTXvlJ9z4u3qUQkMFqDG5sb1IhUja1CdAhoFSQGBE4c0cjxkRQxC4y3xRByeWelBUV7Y8oRiXJlesWDpIgIHW6iJPVqZWAgiBdhSQswLkQPAAOgFWQ9u/ditEQ2yAsBSyjc5StukdwKgHP+3mBsoXpZuawavoKRoyYkn/m0ORKLEgACq3bF6XU4ej4sO90Cq223GPcS2+k3VWupcWZNMxXsQegEqBJgCK5ePkmyotGHL7hSUFoRjkXio6gaA6ZNiUCKsCMBkBoBEQEBWQ1BcwWxPg2eOayvAMcgJAwNI0QQdt/S2gwCMAhP5TdQgZyoNJNkKWaUnXDwP+pDeACIb3v/l/pZGWsn9JxEzKOUYu+gLKxCkxWAg3AAQ3XfAw8HYFRpQxblcC9t2URiRiFgR+BZpczo+MseV1wpZYERMpgEChTMdxC20D1DMsgLL0C8u430hpueErUgDJdwadm16keWVdem1iEVpD6wW3vAKSucugSEAJJ9z9859f8jLkS8+U0+BRFWyysxk0UBhkNwABJppUeVF4CyIp+CSBXGobYDQDFEBcC6nqO1JBl/UJuS3eQYqBMKxCMcjs88OCAFB4BilEghPV8ZWprP72OUh4KSFOYEl2eq6Hbz7UFQy5vS+7t/q6/kqN/zx/uwcoIkYE5MffGtQn1thePH8aUauOm4sy0WWQgPANHE4UE/hynP9ptzmQeiFKlHPGM7wXlnL3RvXIKE93GQPS6gMge5v2OkFUAxT4OGUkLYczPB07DFgOAEY2vXplwOsqKuUTJa3+K5YGSx91h4SQOtXfq/hQEPXyyNGyPbC3DSyHGRRFA2iMC+wLJfqYB+U028EtLYDTB6TgjnHxaGaDzc46G5E+ZJ8kfrx4PUPCBTkEDNpMBTLFDHBmeVoRzrUjckEFCIL+riNAj/DrlCD5UDYPVp+eccKGJ8ua1vB6/7G/fEbzM6DghObd2fBEACSpGnrh+/dNLqcu5sY9SgHSIDkaoDwkg62pVWlg7W2Km1hAqSDB124fokDbZ1BXwa0cnnZAs5xHl+e5vm7WACsjmkAoVFWPegWGvVkwRhPKPcWWXS/qqdXH80YGKjF6oEoKOuzrWBeOmirQhYHxFBwO4e0J2AIAMkybz563r7Pd9Y/UlRKHIePuXmcTjH16RRXKV66Pa18D7m5TIDxcrU8U7BgBk+Yljqw/6B/86ZV8PNECmjz5ynYuN2B3GwIJhHSIMYBcp9Aw/TdiO5QM8g8oR6BpIchzILHvlBsCQFFwsdkPFPuzYrsxzNuBTPmwDodMdHTHBpA4r6tB3704Hfjo0hLQYFncaXQtLIYoXRhVbKFp4P45LrBtgFKrcU+2pWEv70gBjVN4H8bR+uTayvGf2TFKfzuRQqjChz/OjRC25VVGFdnxq7D2Y2eGF+/RNF5GulPmYwCQIgN4o9xMBSfQLlOQMf5fos3ds/yrF5n+wxg8GgZ/eiNhbMXXLJgR6rddQ82O5aLTV3CiG5c3Zh2GR5qUfsOULjuEp4QHWFLgMSkClFU6FmAV1EG8OrqFOytj0NZsQ+scT8QDvhMtWiT4VYxL+XqnUydi2iD2GfySpChK+8jw9O0EHOInDehwTJg20F/zkx4VPciZsPqGbVyjp96dvNpGmLikhuXMwRhyACJqmPP/+bMnQXl1d+eMrXsybYNqVRHMh63dD+DRFoTRQpVYIlWmOTKLslNwsVnZUFVrZ8Y1QoWD1TAO67t7R488RpA8SjLd4mW0aWxeV2vRQNwhDQ0M8jP9WDaeNFaPePCCMFIIIBQnaIAIb7JieOizgMNNuyuZVA4yjFv/ZmUFVK6mb1Kgt8yUUzBvNWu45SMa478tExrdifpOBQACRFd1Njv/nf5U3998/uTR5fOv731CxAfSCYGDEOVUALT8uGVGIlh7WoX7rzF5rk1S7Z029Yq811iSQnAvz/ZxVlctnRbMocatRh1HR30ia9baKijcP4pKbjqG3HeOnWEHqowWLc9Db992ZPjWJCJ6uvnRiDpacy6D4bfuRVr2xZK8WpWrVrm9nb1gT6B/AbNnt3xN3JHwe08nhCqrcWCHj/4INaiXCdvK3OOd2H29ARU7vdjjxYRX8pGAezdn4Ll7zswroxItohdpragUJ9GtX5R97QKF665IIu7Rv7bhW4fqRiwqNTE3ClxaG5LwdPvWlA4koQOyzXL5CZ9wczU3DK/5+xcniSubfoA+pD+kIRuUl5e+jftB/0WIqk1WlxNFNIBUfDUB/Oa6l04f76wHgLY92uXIdjaXb/zIC8v7neE02FWaDrBbkDV5X5+vKkpDUvmUTlM0eH6iUnbGuKiMgT7GxnMmxaDhO2aqcC6DyZB6MbZA4kQSvmsvGGynFzezfhi43LoQwblAwpKJs49uJdBKkV8lmSFLcYMlkX2uSkKsbgIGv7sIz1RXoAxaQzAex91wsfb4zBxvA82VeTDxCBVj2FFJHAhjKOXzeuW04kH1ewyCPMvl+YNyuJuImbxmMbHsPQ0LylUxRtM3SkiEypGaqQEoUgkgMVHAjvwxYvv9nULg3kUEndoeVsL54gp1fmMUmtNvdMB9RbWEONDC+/+icg3GTzeGZHfGuDLqByhaAp3/YbHoCJb1ivPS6n0EeoAUzeg9h6qG0gC1m91YGS2/8E+80Iw7WNhPe8THVzxJcYSnmXfy1NSjc3x4N1XTOtZOLOBBzYxSJpQZGUzy23ten/9ygcb+sJgwBZUUVGRSKcgN5303+Q2bwFYiLHpbWRFopWP5EmNP66wYM7MTjjnjGz5fRuRGrH5E//8ziS0tWfDiBE+MGbihRqoMwNo6hokco18ft5zrwLMnpqCqZPicnoxMQ4GR3AtmTpHPrUOihD57m1nisFDz3qcHToq+66smQW1mldUEDi6f6bBEY2GJ0Xc0eXEWbNi1R3qKploB7qjAcrixU+MrDjj27Xb1kJCfjlEuR3MUgAF9Eypk/01LixemIQz5mZDB4/mz73iwp79I6BkDJEP0i3lYqmqSLhOnEcTLk+0+ObmNFx2rgfTj83i1t392X06Hu4HmTUJ/xT9swMNLrz4LgOXW6iIkQY+hDfOXpgPA6LMB6OB9Y8eDTR7FKv6xdXW0eppegVowBa0p7OSTuCuWLRsmQez/BsKWYwXVrKZkqWUOabYgXfW5sIrKxn37XEoKkxAEXcjbjJidRoMADPNyYCFjoltTx3Lz4/B82868NSrIshbBlgdJ/GXhYXoeBWySNXjF/dtc5RGceaW7QSzjwh67m6ZWe3iIpYjAMrNglTJOIi/98pb16rSfeY4BgxQ194n0ha5LcmYlSU/Z2whZQJkTjhqhSrgRJDlNwt52cQoOpUOl7eQO9OdPNP/wUolgQXprHP+CL6RgxoFIFKBrT1q4XYAQAAY8TPmqaAuxb4DGo9AwiPL+lObwnIsQmlBIYm3uGzDy4+d9y5A/77fM2CAKisrU5dmWa3ciPIJH9SQL0LJJh60dN0SjVLBZy/d+jRaqRG3KFNDNChrYatEoFCkcC/aKNBC7SBumEyHumdpCPo+XWSZJAywaWQAob4NqOfQ4AihGCR/6IWVFFFaXuFYzz/6r2erMyj0QwZDs1lTfe3WRFbJ+M6WYKd2Zbprb1q9Whv/ThBYBEKukaG1cUNUVWmhcyFsOdSKKFRv6zKeX6cpC2DyZgI8CX6G+qOUHpDrDh4cjAURndpRRMFT8zaK8ll6/DQnvnJ91cK3nvtfzdBP6xEyqH5QfbLlvbyckm90NvkvMVkRhTBkNYBA0w+EJ3iEXAx03xcth11d1CKx1egpgdK6oscxG1RJXkD1GJA1mCSwGvOMAOHPeipXJkRTdeEFivK89ISpdnx3VetP/vO2SatggF8FHsQoP88kTJzbVT7xxBvqvpCdfEmIQql93dvW9673A4TeAZW7dFAFRFFVP0SWV8cJC7ZBuY5MkyfNe6deuF+ir9dtSpgK6H4y0F/rsScdQ/A9dZu8SSPxhvqWI9xl8SiaOup4O753X/Ndd9+YvwwG8fHzwVgQOUArN80qglaekc2Rg3fmSACEaeUQtF6G9ml3YlqnF5QxbxqgeCAburJGzBa1GxKCXZ1HMlgWclGYWYbIAw0sxDA9Amaut7bakFXJm/VXgq3x7gcdW+rSo0504rt2N//srpsKfgXBhw8HJIOxIFK3bZU384xbpnY1J2Z2tMq+HTE9bEW59acrAbVqhmgpnogftTZjYbgs66U1s8h5kV49Zd3LmnPUq/Q6I6B/a+vAr0Li9ynNwKFPAvzsCQcnP4+5EyuYXTHdJmveqVz88I/LHwffrWk7HZAMysUJyc2dsnPKSTNvqqniGRePty0ULLXCbe2mINjXzd1pd4jOC631fhV8Q+VpUGcUMEBlAYFlAEZrXJ++lh4D76lByASuSnMJq8vNAW9cuQuTpvPeV8zduOIPz0z/z4fO2gJD/BI9gcGJ5Fe33ul9vHk1mdFYR4h+iThasYmj2q1A2JURdIJxR3pXhNZiBkUyBW5E30NUG8LuLkTrI64LUGZCMjh0v9H74TlFNnIUsKLRQMom8PZjw/51qz647sl7T1uuahYGMKCYE5XBAiTl0us/OHlCxdyPNrzBUp0pEscftzAPz9BvQErSvwmEXxuEMKghhaPtEFAQvi5B9QFSahS0vthiiCkSNWytrD8n20uOn2xnjZ8EtKbRXbfxvRd+8drjV7yuHst8aBeGKEMBSDKSW+/qfPPzj+Pn7Nll+f+eh3SvnWTah35iZTG1HRrmRnVggM1k+Ch40N3CoLdMRw+AGdDRuXJSCycB5ZM4JbHa7n1z7e9vr1z+P3WPUFiMdqyHRAYdg8C/ESueij07e8nCHzd85pGOdp7QIGG9SNExQW2bz7uQyCEUw2Q5Chm/DxclD91iFgSxKXR9isqjOBii3hD8NufpaV3Ujz1ZfDxnwnGEvvTrHy2qXH9HBwRw9is7MBAZCkBCSFXVqvTI4qtWzjx19A31Va7b1WXZuCWHCos/UaVBGAS5mwTb3cDSCibQrZ8VAomiY3o/Kg8IFGCQkeHhKcq4P5afzwiNty5f8dxl/w9UtggOkwxmwA6LeLzYK48eu7a5s+nmWYucWG62m9IT6KO3jek2bt3dOo6IMSFCFbxApnYQ88WJoB79tSk9oT/09gXa1p+/1Ptkx1dNsNRzyimazyenMIuPlvORh7FHE9i5/eX/g3Rw2GQoMQiLpJI3/XPNXdms5JaP33HTjS08T0/Q8DMO5r3dEMl8hz3FsWiM0tcxb9qhMt2YIoGMbNCco+OiIjtiNbqEsYknkl13/5AcC/0YzxmqDNWCtMgvaDx0W+mtSWi8/bSLnFhpsec6ohF64ZgRmvyO3JyWbh1J1DfBqR7TCVU/9YeQ9NsT2sIsL3BjgHJk5n0lL5iAYl4684K0jbYuUYbT6lTFdEL+sn7/tfp24TDLobIgLZLZfftnXyyeOnHca9tWM9hTxdzWdsvRNJWQPu6G9HxTPZ1LulHC4CfebfozBIJPbUauF2V1QgQKYsRi/CTPGjuTfXj3P8TmwBH6l9NDJQlRkTHpk/fv2R5Ljfn19LNPWVJWTkrcNs9zUxZLp3mD1sE76n60YPaEpFdwIsQjREYAwp+UQYyOKPIh+16oPEWkQ35SjFtQ4ai0d9K5jvXmCw8eX125PAVHwHqEHGoL0mLGO664cfU1J8+Zd++BKiio+hRoSx2Dlg5ipfWbCTjGIGXjyYBE1WihPklGyWR9fcQwvSb4fNUh1eNb+XzIYM5iO1a1a8vCJ+49YRUMYDxnqHK4ANJ1q4FugAuv2f2dU+aO+4mXso5qrAZoPADQ2sTEP0USU5sY9/VEtm7fFcqvFIp3VrNyeSPnYDbUg9vWwd0K6U4IensKEt2IkIBu+wB1aAQ4uen0zDNjMc9pvfWen4y8Gw7xf3nsSw4nQPga5pkXXHTfseMrzvtWUdnES4vys6ekk5BP03wkwFU9X/BjlQAIsiHZlUxv9cDrSjZmnb5ljZtqbXPilPQwObGPGKaLQAamiPdTNcBYyC1n1gI71mG1/MsDP83/ORyhuBO5tSN+LeO7p01bGi+ecEbJiPyC8lQ6OY55bjaxbEosp97OGr37i4/fqN669SH5X0Ou+2ntP5eUFP/8zyuYW1tHLFdMCOoP6YA+yqDjmjk6FtCSkjSbtTBmt3W1c8vJFZZzxMGR9wZfnuDw3lc5oZz0dT88cPbYo0vfqlxPYe8uSLd1WDFRgWX3DYKpLML0hGj6L3bnZUNqwmQanzbfoutWrz/3hf+Y+zYcYbeG5csEaKAilXTa0n8rPO/cH7yZrIGTdm6itLbGYu0dYIuevhWZS9CbmHEg8CN+Tja4xWOZddwpnMDE2MZ333hq4brlV7XAlwiOkK8TQELU+9FAl9667cLpk4/7bfN+KNu/E6C+htHWNkKSKU42aNC97yknKGbEikns+XlA84uYJTqgiVGsZuum1dc8//CCN3Qx+BLcWvRev24SUtyV39+0pHzCsXfk5GTPauHssKGGQWsjYZ1JIGIypP6Yhuwo22ICv/xHVCyvAEh+KUBBGTCbuB99uP79O179/aJX1TUO+bDBYOXrCJCWEDucNe/OsqOOn3Hh6DFzLiguGXUSTUGhzSCLCmWLORM+rB4vnWRxVt/U3PnnlprNr1ZVvvPi+8t/VqfqxBN6vxLydQZISzd2KOTkk5eMyCu7ckSnW5/lxDpzWJq4+bkVLU1717atXXtPEpXXZKW/pGVYhij9bXT/HRrnsAzLsAzLsAzLsAzLsHwl5f8DGzhXq3EeY8wAAAAASUVORK5CYII=",CP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQoAAAEKCAYAAADqyxvJAAAoPUlEQVR4Ae2dW4xd5Xn3n3fv7TkYO8zE8BEUUcbfp2CjL1XGSJXakipjpF7ARWIiFYwvyiE3PdBCK8Wh3DD0ghJXSohCW/UigdwYJ1XDkAtyUSkMKrRSL5ipmsqHtPWmNAUKxJvEhxnPzF5d/zX7Hfbs2Ye13vO71vOTJh47gz17z1r/9Tz/5/AKYkrH+ceOzqzValPJ+vqMwK9EMyJJbu783zP4n6Tza/efDaEpPxGdz9P/voXPEyE+TNoi/XyjWavVWo2JleX98wstYkqFICZKzs8fmVpfmZjdaIvZmmjf3LnxZ9OPqc6HZ5JlQQKCsdxOam/Wa8kyi0i8sFBEQBYhEM1RknymIwhzFIQYKIFIZDn9dTlJklfbtdryrU+fahITNCwUAfKTx47OIVIQov05ilsU8oIoYzFJaq8i8vjU06cWiQkKFooAOPf4sdn2ejKXphBfSD5KH6pMFnWkKctLtYZYvOWpk8vEeIWFwgPSX0hDbwjDA8TCMIqmyCKO5KUDJ763QIxzWCgcAXFYW5k4kvoM93PUoM2CEOKlXRMrC2yOuoGFwiJdkcMTLA7WyETjlqdPPU+MNVgoLAAzktMK58DXgGh8h81Q87BQGCKLHi6PPZIIcaQTPTD+aKaC8eRG6mtw6dUMLBSacPQQNukF/jzV69/gyokeLBSKdAQC3sMcMcGDqgmlaQl7GWqwUBQA6cXq5ckHhGg/QqPnI5gwydISFoxisFDkQPoPbSEeJU4vygILRgFYKIbAAlEJWDBywEIxgHNfufeR1H+YJxaIqsCCMQQWih5gUraT5DliD6KqsGD0gYWiA1cxmG5QJdkQ4kHuw9ik8kKRzWBcGYdAPEoM0wP6MFLBeLLqglFpoWAfgslJ5dORSgrF6ceOztRTH4LTDKYgzbQCdriK0UWNKsZPjt/zRC1JzrNIMArM4NrBNUQVozIRxbkvH5tNautpNUPwwBZjgkpFF5WIKPAESGobSywSjEEqFV2UOqJgL4JxROmji9JGFKhopIq/xCLBOADRxdK5x44+QCWldBEF90UwPklvqGd2Ta4+WbZdnqUSCqQaqbK/Qtx+zfildKlIaVKPfzt+z/0I/4hFgvFP6VKRUggFnOcNIZ4n7rBkwmEqSY30slRFok494EdcvTKOSc8jxDDhsjA2ufpgzL5FtELBfgQTGVH7FlGmHuiyZJFgIiN7sOEBRxESnVCcPX7PkaS2wSLBxEhmcuIapsiISijQREVCvEhsWjLxMoVr+Mzxe6Pq84lGKLJ5DaJniGFKgBD09ZgqIlGYmXhDUyNoniKiNrGbxj7xS7T3tl/PPl99+y1av/ABrbfe3/pgmDQVmf/Uie89SYETvFDEKBLX/tpv0tThL2QCMYyr7/wntVcu0wcvn8o+Z6pJDGIRtFDEKBJ7Zm+n67/4pUL/DcTiZz98gX6x9Dox1SR0sahToMQoEo2p6+iGY39AorGr0H+Hr999622Zaq80z1Ks7D54iP7PPb9DyfpaGiG9RUx+EiHmHrn9/9M3X//XVylAghSKGEUCfPL35qm+51pSZWL/wcy7iO0mg0Bef/dDNH3Hkez1X5OK3t5Dt2eREgtGfkIWi+BSj1hFYjr1JOBL6AKheOtrxykWRvkxeD3vnnyWPZgChJiGBBVRxCoSCLmv+/xvkwlww62cPxt8VWQzzXqY9v7K4aGpFl7P7k99mi6m/gtSEmY0IUYWwfRRoJkqRpHADbPvrvvIJNOHP0+hc+NDx2li5mCur8V7NG0g2qoSuBdCasoKQiiytuxIm6mu/+JD2Y1gEngVeW9CH6CyU/Q1fyxNUXYfvI2Y/KApK5R2b+9CkQ3JCPEcRQhuGFs39O5bD1Go7L3tdlLBhqiWnvTeOPf4Me/b470KRdeoeJSzG41pexc9qgajGrZ8gBtdVRzxelAdYQoxlWxsvOh76tSbUGDpTOyj4mjJtgVuKoTroaFb2Rm78ZeIKUz2QMU9Q57wJhSdzVQzFDHt1UtkE5QeQ4sqJvcfIB1WuUyqykznnvGCF6HoTM1Fv77u6tt2m4my0mJAXoWKidmL7fes5BzxNXHqXCiwmTjGMmg/0OuA7kOb7J1VMw5toGpidsNTs3rg3jn7J/fcT45xKhQwZJIk+TqViEunl8gmIZVK6wYqFusXWCi0aYtnXJubzoSiy7ws1XYqdFHaJpQGrF0mhKJlzwCuEFOuzU1nQoFj/qiEey4vn3mDbIOownf/gSlTlWc+jDHTuaec4EQo4EuU9SxQeBRrDvJu36VSE0LFImEW3FOu2rytC0UZfYleLlv2KYDvBiwT//baBU47TCMEPeHCr7AuFGX0JXpxIRS+G7AaRvwJNjItMFVPEuv9FVaFolPznaGSs9I842SNnc8GrMb0PtKFUw87pCnI3NnHjs6TRRpkCYRD7SSZp4qAnZfX3HrI6o0sG7AuetitaeJ1rXtOPfAaMO4+KjK7fPoNeveFZykqkuSJc48fW7jlqZPLZAFrEUUn5agMMDUvvPIS2cZXA1bsEQVSpxsfPJ4rfcP+0hhH4pONdWspiBWhqErK0cvP//HvaOX8GbKJrwasumZEASG13cU6CLxf2GdaZCANI/EhTu8OR8zaSkGMC0WWcpSkRVuF9178NtnGRwOW7k3jaxgMvg62cRX9/qMdiU9TEBtVEONCUbWUoxc4+7ZTEB9RhW7VY8NDxQN+xMfvVF9TGGsKYqMKYlQo0FhFfMp4loLYLgXuPfTr5BLtiMLx1Cj6TkxsRY8xBUEVxHQjljGh6DRWRXPoqk2Qi7/3fbspCJ52ri7gRmTDYBCJ6+4udlrbIGJNQdCIZXIWxJhQ1BOqpIE5CPRWoMxmC5cNWEZKo46GwXAwtCmRkESagkyZnAUxIhRZNEHJA8Rs44MfnrLq9LtqwKoZqHi4KI1CJGBc2iDSFOTR9N6cIwMYEQoXLaQxAp/iw9SvsAUu3D2H7PdV6KYeLioeWZ+EQnUjL6FtG8tL3ZAdoC0UncnQOWL6YtvYvNZB+lGbnCQdbK+/sy0SEhe7R0yDe9NEVKEtFGxgDgdh9wcvnyJb6KzPz4vuDWgz7ZAiYXtfx5XUc4p1qK1mIOLXEgouh+YDy21sdmzabsAKdaEuBMyFSIAYo4kuZnTLpVpCwdFEfi688gOyhe0GrF2acx62IgrMbrja/BW5UGiXS5WFIvRoQobk+IAb7nuVHMqlNo3NUA82tiUS++68z9lhQkg58POLnKmrKxPKUYXymHnI0cSovBU/eHxgh4TLke3WKy9Z21SFqAIVEBuvR2f79tW3zQtFnlFxk9ge9HNGkjySRhXP7J9faFFBlCKKkKOJPHmrjDauv/tL9MnfnXcWbcDYtBtV6Lcs90Nn+/bqO2b9CbzGKUuvcxCXHGwwc4RyVKEkFCFHE0XzVoSvEBZXQ1aIKmy553jdLvoqimDSyNx98JBzkQArzbj9iW1sRhWFvYrCQhFyNIEIQSVvlanKtKOL0OYciOnXoF3xMORR4Pu4/otmW7PzgLKorz0alphavTz+ABWksFCEGk3gBtF9muJpdcN9D1tPRWCM2cp7TUcVOu8FRMLETSbTSdct1Ij83v++/f0irkkrII9QQQoJRajRBFprTYWkGAByUZu3ueAGohnCXIKp9fyY3vRRtfrg5RfKujl8pmi3ZrGIIkmcH47qA1yUN/3xCavOus05EHz/pr73sRtvIlVMlBQhehBv12D50OUzpTExd1B0BiS3UJz78m/NhjrTYavzD7V6fNh6OsPYtJX/mpos1fk7dH8uvszLi0uvZT+bMlN0BiR/RFGrF85rXGEzPMSTGYtZbYS+Njd3m9pXoRNR6BiZeL/33aW+xk4VXEtYD1AFRJIcyfu1uYQihn0TNs//lFURG6VHTJfaaEoCJqIK1e3buOFUoyWXMxzd4Pt9+9snylblGIgguj9vqTSXUNQjGCO3vRglK8+l5VcbJVRbTzATUYVqV6bOjkwsxPViXv6wtOblIHI3YOUSihiGv1ydQoWc2fQwks1yqW5UodqVqSrcEOK9HprGkAL6OIHNO0mS68k3Uih+sml4zFDgXHW45RlzFQiNMWxmClvlUp2oQs/ILC4UvsxLNFWV3bwcwmweU3OkUCQJRVESdX1cHSIKmJymUhGb54GoRhU6Qni14IyHT/OyjE1VRchjao4WCsrvjPoEQmFz4GoQeAKaKqHC2LRhpKlGFaor8PAaiuT6vsxLAPOyYr7EDvKYmkOFotOJaexsANvgRHEfI8GmSqg2p0tVogrV11N0mS6iMjYvvTK1sjIxO+wLhgpFktPoCAnk+j5++DIV0S2h2lrGqxJVqEZJRfwi17slJBDkn3uIQENlVKfmQKE4/2gWikSRdnSDm+zdk896EYvNU6X0SqhZE9aPwvAqVJut8kZ1GO33YV7i2kD0yXxEkpqaw9KPgUKxNjERnUhI4Ff89C/nsw1WPsDFr7MQ5+Ly61ZSqKJRhXqz1ehS9ebYuPuj+iAS8CWYHUytrQy+5wcKRYxpRzd4Mr//4rfove9/y0t0IRfiqKYitpbxIqrIK2B1iz0UvszLCxYXB0XPkKHPYR5FtBFFN3g64wniI7rQ6ea01YSFqCLvIl6VZqsrOSZG93nqvKxsU1VOhqUffYXi7PF7SiESkqxWnkYXcLl99PEjFcHYetGbw1YT1p5Dnx35vagamRsjTi3fM3u7F/Oy4k1VeRlY/egrFELUok47BgGXG95FLFURmzsrRkUVqs1Ww5bpclNV+AxqvuorFAklc1RScNG89bXjXpqzZFWkSIOWrZ0VeaIKFQaVRn2tswO+qmAxguarfn++QyiwoIYqcEwgymO+jM4iDVo2m7CGRRUNw0amr6Yq+BKu2/sjZ+rc48d2pB87hKItGnNUEaTR6aObU67by2N02mrtHhZVqLRvD1qmi0qLD1/i8uk32JdQoL2+Mdf7ZzuEoibapfQnBpHV1Z87YW0gaxQwOkctj908Ed1Og9CgqEIlRei3TBevy1dTVVU2VZmmJmjHD2yHUKBEQhUETx5fRiee7KPG1m01YQ2KKlSEojfEZ18iTvppwDah6OyeiGYIzDS40H32XIwaW7fVhNUvqmgonGDeu4Pi4x77JdiX0GKqd0fFNqHYaItKRhPdhNBzMWiDlq0mLKzD733q15Uiio8qHvAlfGyqYl/CDKKdbNOCbUIhRPtzxGTIngsf0YXcoLX74M7zLGxEFRAJ3W1d3TsoIBCIJlzDvoRBxPY9ub0exRwxW8jowkcZFRHFDcce3pGKIKqwIV44ba2bonMeeH/wPUMkrrvb/RmhAGe6si9hBkH0uZ7fb4KV/LUkOU9MX6R77yOclhOP8iZABIDSqkmTUDaiSfb/aVydjPAlOOUwS1uI/bc+faqJz7ciilq7XXl/Yhi+o4vuVMTGwUH4N0wuC3YJz3HYofuYji2hSISYI2YkvqZRe1MRG1vHZfrho1KhCs9x2KOdfGRoNuQnqWJ8JiEmDzK6QAVi+g63rclIf7B5qp/RqcvkzAFqEXnpe1CFfQmrzMhPtoSiqo1WOmRNUM2zzr0LGyIBUG2BSMQiFEi/TJyYzvSn29DMzEzsx7w6Pn6BGGWwZ8F1dGED9CFsrFzxYtoWAZu+/zstXzN2GZtcnd4/v9DKIor1iYlZnPTDqOMrujANmq9i4H9OPkuMfTqLbBYzM5M7Ms3gszJSJS4uvRbl+4toE2ljTFGn7NBsdH43Q4wxyhJdhMjm0Yt2Zl5MITtdYTpDFMbTX/H7bu8HYofXEbzgiU1DMxMKrniYx2dlpMx8aOmAJBVw48v+E4hCP0EYBKZ28QEz9sKPfhCyKTuD/5FVj8pOjNoG0cXlM0tZdHGth+UtZQIC4et0r0wMOoKwa3pf9rkJ8cchSDc+dHBzTuXlU+m18gaFRFrt+Ax+zYSCS6N2QSclVu9dPr2UHXrD0YUaLpYLyQgBY/YyQnDRsSoPRHrzqbCEgjpBhODSqFt8zozEDHJ608cX4GeBJ3rRtMEmmLcJzbfAzEeDS6NuYe9CDV0Ds9tgnNx/IBOIEBvLJtLv7eJSWEJRr9WmGu12e4qEIMYtXBnJj4qBCVHATYdIAaIQiyCvXxh9bqtrkiSZaSRUnxHUJsY9HF2MJo+BGWIKoQJea4jVD5EkUw1RS6aIMw+vcHQxmN5oIpYUQoULgY7Kp/KQRhSpWnDi4R+OLvqDkjKEACXJmFIIFVbOn6UQEZTc3EhF4mZigoGji+1AGFROg4+N0NvSa4KbrYLD9yZwxj2/WPoHChcx0yAmWGDiZU1adz+U7Ypgysda+lDAzzj0vRri7FeOnk/tihkKDOSmMKw2rlzZXAWflo1kaIZf8WdVetri7E6E4GUx7qoK9mjAi8AqQ7RrR3INN4OLKGQrK4yrPEjB6BYRKS7ZR/p5GQRGRhdYsstGZzxIYcg+0qgh1odbUBEFoogpR0/NXoGRv5cH7SKC2RKbng/f4D2qgsEXI9gInkULqagPOt09QpqpUNwbRBcFxOHmx+PYWtRPOKTgdAtN95+bvmjQS4Ct3Bxd+AM/zyvZMY+bqUSJhGEHwaQeMZ0pobOAFsIhU6C1TtQi/RcZ4eS52OSByjgIiLGPFAX8rDJhSN//Km0xC0YoapOTVAUQAeSJAuTTSQpKJjAdYZHA7GXMg/cY3kIWJaQf8BaqvtowGKHYDN/+M7344zytyjSxntoVGywK+QhGKPADe/eFZ+mTvzfPJUDGGmudwauV/zjHolCAoMqjch0YyqMMY4KylCd9E1wfxcXl17Lcm/dLMkWRaYQUhjJXIVwTZAs3TqbGOZjsVzDD6C5PSmFg7JAKhWiG1sIt/YqP33V081wENvYYYn/BI+G1cEtwEchj4+SyEqw2A9iQnP3aKTN29zXs4gak0sD+QjhEMT2KCyR7khSYsJPi0S0iUlik0Oz4vEtkWHzc05tGsDCEQ0NQ0kw6pwGVCVtzGf2Ep9//J+kWoq2v6Wku69eAJf+srtEFGhuyFRrI18xi4R8hRLipR6j0m+9wQb8Iafrw50u1p2LQoFt323tv63vvz4J9Czs0EiHe5HM9wqdfhHTpzE2VWGiTt+1dl24x6jdN3D1pnHcmpwy0k+RDjigi5ppbDxFjDhUxGrYPpXdVQcTl2yz1aBITFUg90JCWd7kPYw+ZCuYRGWxYx7GIsaVHqUfRwhbuJice8eByuQ9jFqSJWAuAhsJQz/DoR9JOWo2k3W7xkYLhg+iBT0IvBxD6PYduz/aJxBBdiHqt2RBJWh5loQgWCMT0HZ/nNKNkQPBjiS5SM7PV2KjXWzWuegQHUouP33kfHwJUchBdNKb2Zd5FqExMrCxnocTZr9x7gfggoCCQRuXHOkfpVQWE4ei8lYcN704rOuORHjasAg57GnUYsy8OfPW7olMeFa3UsmCh8Mye2dtp3133VdKo3HfnUXr7uRNbrfrypqmKcKDZDJu7A/QslvE/MqJ4Mf3lCDFeYB9iE6xChFgMa2Qqs3Dkef2uSUuji7c8fepwFlGkDsWbbGe6p+hhR2UH+0ewCnFYNaA34pBTxfiAcMRcFcLrR2SBNCQUUiPzn/HrZuqR1Jok2sS4AU9BXBAfs7jFCzfahR/9ILq1grjRcRpa3tIhuh3x0S0cY5/YbG1H5BHbLhNcE6iCBBNVJJsNmZsRRS1ZFlz4sI4ro/LD9KZB2S3Wp2tRsehGCsfF5de3/q7eqCNkbE09q5LUROZRZEIxsbKyfHV8nBh7uGiYQo77wQ9PZaE5hAgnicWKjlh0IydPcSAwkEuQ4HEg4pgMLO1bDWweBKVR/LplTXCJ1A6ujEqEq62uxp0b7ns4vRluo9jBTW67gxE/m+6Iw6dBimjwZ+F4FK20NDqNT7qnRxeJKx/GwBMRzTS2G6awFer9728fNIL/UQaRAKYii2FsbU97ZfP33akKIg5XwoGf5cWl1ykU0orHsvx8Syi48mEGVz4E8lhEEb1NOhCJqZKddO5CLLoZZpBOpuJhOn2EQLRS47nIqkcXyIoH2BKKWqoeCbdya+FqsrNfFAF2HzxUOpGQuBaLbmwZpKEKhETUaovy8y2h2EhTjxoxKiDHRWeh7XNIBkURYLMn40ukAm68d08+m5mtIZ95itco+yx8LoHRNUhDFwhJGlFspR7bsg02NIuBi2PfXUedNEwNiiKAfNqqhsRvfe149vfu/9NwB5N6ef/Fb9EvAsrne+nXQRqLQHTYMjJB7yq8RWJDcyQuGqYkiCLQqTfI5ML3oiMS+LshErF1h15395ey1xzqiHZvBym+15g2W6UmxKvdv98mFElSe1WINgvFAFxPdl4+/UY2fjysAQej6KoicXHpta0LeXeE+zelHxPDtqjotoMnWdCwxXah4A7NgWCyc/qOLzjbBv1emmaMClGnNcqvWYv3Kz/Y+v1k5xS22JDmcUjzEWVAdmRKdlRE2afYjuvJTtl+PaqNF/4IjD1V5P4HILctxQwW1+K8Wj4wyAjb/Amwo9AhOvPnDHYk3Jfl/y5EQnYgoitv1MWOG1unPRuhene0UiRKctEpqQJ6HCCcvFNUn+5GK8kOoWgntXjWA1siK8P97rwTsxIgivjpX87ndsN1ZkYwD9Lqyenhzudl9e23su8TqZEpZNlXV3x0qz/MJu12skMDdghFLVlfpAoDsxJPJts9EaBIFCGBL6Ea4WT9Ei88u+PPi0YUIHP1z5sp8+G1Q7yydEjz72Sx0KfWqC/u+LPeP7jlz/8GYUeLKoa8wFBFcFHRKBpFAN3Oy0FP7fECEUW3oI2qyOQF7z2it0w4nzuRvTe6fx/EnhcCKdG85amTo1MPkBY+vkMVQkYRLi4shP4QiCJRBMDFj32aquDmG9aLkZduocHnuje1ZPrwRxUlvDe6JU/ZX+IqfSwLQmwvi0r6C4UQC1QB5MXkIoqQefhP/2peqf0YY+Oq4TRu6GGjy0Xattc7h/ZK0IdhwtjE+3/93R9t40IqgrZy3YgFhvR0SedfbJCI/h5lX6HAIhsqefqBMB4lQVft14giWopPSVzoOp4Jcv9BFJ3t6L1xMwH8kRn/G5WL7ggAsxR433SFCOkai0U+DvzZC32DhL5Csf+ZhVZZy6R4cuEpc8OxP3ASRaAR6B2NciIavXR8CdmiPYjG9D4qQr8nPKYqTRmb3SkIMFWOxXvYHbEwO0kth4GKP3hgVIjS+RSIHuBFuMhbZRShc6gLbhh0g6rS3aI9iKIRxaAbtrvLU4feFET+m3gvdYfA9hz6bJbC8QHP/RlmOQwUil0rK/iPSpF+yCjCRdnMRBQh0fl+e1u0B1Gkh2LY60H1xpSx2ZuCALyvmBjVNTmx+evGB4+zWPRhYmKluFCUJf2QpbJYogjJPo1hLwAjMI9Q1QvcMKOMxTyt53npTUG6/w3duQ55fgj3WnwE0o798wsDA4Ohu2o2hHiSIsZV8w1ujndPftNIFAHkhKoqeOrmrawUST02RoiArOyYoF8KIvl5pwdF573mxqztjKp0DhWK2KsfU4ftT3tiFByLXy6fWSITyKW8qmTLUXLerLgZi4TgGzluTNzE6BUxQb8URAIh1DU5WSy2aN369Knnh33BUKFA+hFz89Wugo5+EaQbb3JiUfZ1qObP+J7eLzCDUdTIXOvpoRgEzhYxxfQQsZc/A52KC4tF1mQ1sm9q5JrMqjRfFUGl/ToPCLV1Ltj3BqzKG0RtcpKKkFcQ8b4g0jLBsBQEmGj7lj5WyPtCbbJBoyucI4UiDUkWYzU164afEipDXHnRPYujd3Q8D0WbzdYv5BchRBWm3qNhKYhEt+1bRnO7D5bjPJQCNHGPj/qiXIu306giytHzXQaFwlYUAXSHvfqNjuehyDAYaK9cyf21m+VZc5fNdA6/SbciIo9htH1oU0i0cxYscgnF2MrKM1TBiVJgM4oAusNeg0bH86Dbvj0KGJumOjZHpSDd/6ZuRQSLeyvU8r2Y54tyCUWMpiYuLF33PRvishRFSHSNNNWFL2MKZ2yq/DsYRTdFnhQEmKiIVGE+JDUxn0/Tjmaer8195k9spiaefjC5VEw1OQpusoGoH7pNVRAJ1bMqGwoVIZX3wkcKIv/d7KAgjYdF6cWiVv9G3i+t5/3Cv3jtx80//Oyn59JPZygSkvU1uvTjf8ourPEc05dr6cWF0PW9v/lr2rj4IdlEHj+oCm6E/1FMOcDeXzlMEzf9v9xfv955b1RYaZ6la1Ifpr73WtJFNHbR+Cdu2jrebxgQNvz863uuzfXz7weiGGygxmsoE0KIxVv+7IWv5v36BhUAnZq1JJmjyMCMAC70PalJJY+Dw14FfCBMxQXlclkswn7swFAli5a+rbc1u6iRuab5/iAF0dka3o1MQfIIl5wRwc9XNTrYbNzbZzSN8s1GQSuh8AHmZ79y73mKKKoIDRMNPu+lF/5FzUnKmx9/tpBHcen0UhrBfJN0gDhea2jmBgJQ1LSEQKOqofre5zmQKRKaB7763f1F/oPC5xInSS13XsPsRGdTFRi20i4vKkZmsnqJdGkZ2LQtyVsF6UaanKrNYGWZPG0rzHAVForxq1eep4qWSnXR3VSFm6xlwBgc+0SxtAPkbd8eBp7EJtf8562CdCPLyaoGawkmT5uj5jr6UVgoUCpNnRCOKgqia15KX8JE2KsiVqYiAZN7K0DeKkgvrU7pW+V1xTwf0lacCC8sFKDKDVgq6E6EggsGw/aiRiZoXzGXl/tOQSQ6qQh+phGu1lOKJoCSUHBUkR/59NHJa/OstCuCykLhIu3bo/8u/ymIRCcVcXFIlEnaGvtllIQCcFSRj313HtUKUXEhmxzbVp2QNF0+DiUFkaikIhD/iCZOlaMJoCwUWVt3QlFvwLKN7kQoMOVLSFSMTGCjzySUFEQiU5Ei8ykT+w9QDLQ1t9UpCwU4eOK7iCqaxOxAdyIUmPQlJAjTi2KrbyCkFEQi91vkTUVU/B4PaEUTQEsoQKpUDxKzDd2JUABfovWK+el+lQvbZteqySU3QDcFkchDk0e99l+88Q8UOm0Du2+1haKz2GaRmAy5AEXXlzB1TkYvKjn1huVORJPdjiZSEAlEbFgqorIsyDWY6dCNJoC2UIDYt3WbxMQTLe+q/aKoHp/YvmKu4tH37w8wBZEMSkVMNb/ZZoPISMSfe3p0GJgsffizn55OI4tfpQoDkbj2N+4iHXBBYuLRBrtvPUS7P/XLVJQr//bj7MMma++/nUUDRSZah4G/59K//JOxSAXTo2idXzl/llb/69/pwt/9bfAzH9g3cfDp7xrZI2MkogDjq6vzVOFyKUJ6E+alzaeUainP1Q0RWhWkF3xvODjZ1AnulmlukLlI35hQVLlcilQDU4k62BYJoOrQu7opNg9SUt+x0QtSkD0V2n/ZDQzMvNur8mBMKADKpVU0Nq//4kPam6pc5LvKzVYGBsLygl4G3SMDu5mMpM/BME0TBmY3RoUCbFSsXApfQtUkBDih24VI6HyPrnNxk0t5xfg1VDXSaOIwGca4UGThTkWqILrDXhAJbF9ywZhGY5AP085UyTSShihjmE45JMaFAhx4+tR8GU5CHwX6JVTB0tefGQyxR6Ezk+DDuMO/aaJkGvuSmYIg5ZgnC1gRiox2vdQpiE6/BEQCtXmXT2rVJ6vPEiAqDLqDY0UPYo4ZGymHxJpQ3PLnJ5fLnILojjW7vAF1phx9lwFNlEyrIBS2Ug6JvYiCtlKQRSohKhefPGvC9c2nk3ZseG4qMlEyVZ2YjQhrKYfEqlCAThWkVI1YKimHL5EAOkbmRgCNRbol09pkqSOKls2UQ2JdKBAOla0Rq6hQ+BQJoLMzYc1hD8UwTJZMy0QqEn9kM+WQWBcKgEashKiSq/Nk6Owz1x/XSD1CmmdQKZnifcd8RhnBPWW6sWoQToQCdGZBmlQCipwslp1/+Y7eYck6IPrRGnm/EM5Mg0rJFL0qEcxlqNAcn8zuKSc4EwrMgnRyqej9Ctz4b33teHrRfmvoRYgTvXyKBBjTbDgyuVTXBHlLpmudw5FNLiUOiOxe2j+/4OxeKnykoC6nHzv6QC1JnqMSsWf2dpq+Y7OvAtEGnmKXTy8FsdRE9xg/LJz1LXb9QCUH7zf8F4ihTK9Ceu9tga1yrlIOiXOhAKlYzKdi8QSVCFy0uHhxgYaU16N7VGfO482nHi7DWZulodMvMU+OcZZ6dNN5oQtUIuSugtBuKh2RACwSQbHgQySAF6EAY6ur6K9oEmMNXZEoqQkYK82xyVVvYxHehKLL3GwSYwVdI3ONhSIUmq7Ny168CQVAo4ho1+8mPnHMCrqH09heqsvkInugumiqGoZXoQDZ8FiS8NkgFrj69lukQ7J6iRjPpPeGb5EA3oUCHDjxvYUkoT8ixii6PQShtG9XFdwTuDcoAIIQCoA27zafD2IUVCx05iO44uEP3AudIzuDIBihACj9sFiYRefEsZDat6uEr16JYQQlFIDFwixoAFONKq6+o+dxMMUJUSRAcEIBWCzMcunMEhUF+x+4j8ItoYoEMHKkoA3+4rUfL/7+b/yyEERzxGix+l//kf06uT9fAxaGqT78+5eJcUfIIgGCFQrAYmEOnJ2JcunETf934Bo/mJetVCBiOHy3TIQuEsDLUFhRyjhE5ovs+MP7HqaxGz9aZnMl9TEwcYlDeLnS4ZYYRAJEIRSAxcIs8uAi9FqwOPghFpEA0QgFOHP83kfTPOTrxDCRg2aqkPokRhGVUICzx+85QkJg8c0UMUx8tNCWHUrHZV6iEwqQpiEzaRrySvrpDDFMPGRDkNl8U2REKRSAxYKJjGYIU6CqBNlwlQe84WOrq4eoZJuymFKyMDa5eihWkQDRRhTdcEWECZWYKhvDKIVQgM52b1RE2ORkQqDVOcXreSoBpREKwL4FEwhR+xH9iNaj6If0Lap6fCHjH1x7sfsR/ShVRNENpyKMY1o4jDumJqoilFYoAKcijAuEEIsbREHstrRFqYVCwlURxhZlqWqMohJCATi6YMySLIt248EYuyxVqIxQSDi6YHSpShTRTeWEAnB0wahQBS9iEJUUCkmnMoLoYoYYZjClrmjkodJCAbLogmiekuR+Ypge0BcxPrk67/PczxCovFBIIBh1oueSJJkjpvJ00gx4EYvEsFD0wulI5UH79YMsENthoRgAC0blqLwPMQwWihGwYJQeTHl+Y2Ji5Zmq+xDDYKHICQtG6WCBKAALRUFYMKKnmSS1b4zvvvI8C0R+WCgUgWCkVZL7uUoSB1zF0IOFQpNzXz42m9Tbj3IfRpC0EqLvJEIssEDowUJhCPRhpL/McVoSBMup//AS+w/mYKGwQCoaczWiB9IoA+f28eIcN3D0YBEWCstsmp8iFYz2EWJM00q9h2V4D2n0sMzRgz1YKBxxfv7I1MrKxBEWDW2kOHwnFYcFFgc3sFB4IjtDtVY7kqYnnyP2NEaxlVZw5OAHFooAQOWkLZK5Wi35QlpunSX2NbKood0WL6UR2GJVtkiFDAtFgMAMFW0xKwSl0UZ7jsovHGmEUFtMEno1qSXLbEaGBwtFBGQ7M9rt2TT0nqsJ8ZnIo45NUaD2m+nrQaSwWMWNUbHBQhEpHXN0FpEHifYMBCT1O6bSXH6W/NMiIVqUiGUIAiW1JiIF9hfihYWihEgRSaOQVDjqM6KWCkgqIoJqNwuRZJFI0m2gJsnM0L9QiObWp0Ty82bn73mznX6e/lstkTSaG/V2iyOE8vG/NDMyyjmzsTYAAAAASUVORK5CYII=",EP="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%3e%3crect%20x='1'%20y='1'%20width='22'%20height='22'%20rx='5'%20fill='%23F4F4F5'/%3e%3cpath%20d='m6%207%205%205-5%205M13%2017h5'%20stroke='%2318181B'%20stroke-width='2.25'%20stroke-linecap='square'%20stroke-linejoin='miter'/%3e%3c/svg%3e",$P="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%3e%3cpath%20fill='%23D97757'%20d='M5%205h14v3h3v8h-3v4h-3v-4h-3v3h-2v-3H8v4H5v-4H2V8h3V5Z'/%3e%3cpath%20fill='%23181818'%20d='M7%209h3v4H7zm7%200h3v4h-3z'/%3e%3c/svg%3e";function Nk({agent:e}){const n=e==="codex"?SP:e==="claude"?CP:e==="codex-cli"?EP:e==="claude-cli"?$P:null;return n?t.jsx("img",{src:n,width:18,height:18,alt:"","aria-hidden":!0,className:"size-[18px] shrink-0 object-contain"}):e==="cursor"?t.jsx(AT,{className:"size-4 shrink-0","aria-hidden":!0}):t.jsx(qa,{className:"size-4 shrink-0","aria-hidden":!0})}function _P(){const[e,n]=p.useState(kk);return p.useEffect(()=>{const r=a=>{const i=a instanceof CustomEvent?a.detail:void 0;n(Rv.includes(i)?i:kk())};return window.addEventListener(cg,r),window.addEventListener("storage",r),()=>{window.removeEventListener(cg,r),window.removeEventListener("storage",r)}},[]),{agent:e,choose:r=>{kP(r),n(r),window.dispatchEvent(new CustomEvent(cg,{detail:r}))}}}function tn({label:e,prompt:n,playgroundHref:s,playgroundLabel:r="API playground",disabled:a,compact:i=!1,compactIcon:c,variant:d="outline"}){const{agent:u,choose:f}=_P(),[g,b]=p.useState(!1),[x,h]=p.useState(!1),[v,y]=p.useState(!1),[j,k]=p.useState(null),E=p.useRef(null),S=p.useRef(null),N=p.useRef(null),_=p.useRef(null),$=p.useRef(null),O=p.useRef(0),A=p.useId(),L=NP(u,n),M=u?L?`Open in ${dg[u]}`:`Copy prompt for ${dg[u]}`:"Choose your coding agent",R=()=>{var U;b(!1),(U=E.current)==null||U.focus()},P=async()=>{const U=++O.current;b(!1);try{if(await navigator.clipboard.writeText(n),U!==O.current)return;h(!0),y(!1)}catch{U===O.current&&y(!0)}};p.useEffect(()=>(h(!1),y(!1),()=>{O.current++}),[u,n]),p.useEffect(()=>{if(!x)return;const U=setTimeout(()=>h(!1),2e3);return()=>clearTimeout(U)},[x]),p.useEffect(()=>{a&&b(!1)},[a]),p.useEffect(()=>{if(!g){k(null);return}const U=()=>{var $e;const Q=E.current.getBoundingClientRect(),K=Math.min(240,window.innerWidth-16),Z=Math.min((($e=N.current)==null?void 0:$e.scrollHeight)||340,window.innerHeight-16),de=window.innerHeight-Q.bottom-12,se=Q.top-12,ue=de>=Z||de>=se,xe=Math.max(80,ue?de:se);k({width:K,left:Math.max(8,Math.min(Q.right-K,window.innerWidth-K-8)),top:ue?Q.bottom+4:Math.max(8,Q.top-Math.min(Z,xe)-4),maxHeight:xe})};U();const z=Q=>{var K,Z;!((K=S.current)!=null&&K.contains(Q.target))&&!((Z=N.current)!=null&&Z.contains(Q.target))&&b(!1)};return document.addEventListener("pointerdown",z),window.addEventListener("resize",U),window.addEventListener("scroll",U,!0),()=>{document.removeEventListener("pointerdown",z),window.removeEventListener("resize",U),window.removeEventListener("scroll",U,!0)}},[g]);const D=j!==null;p.useEffect(()=>{var U,z,Q;g&&D&&((Q=((U=N.current)==null?void 0:U.querySelector('[aria-checked="true"]'))??((z=N.current)==null?void 0:z.querySelector('[role="menuitemradio"]')))==null||Q.focus())},[g,D]),p.useEffect(()=>{var U,z;v&&((U=_.current)==null||U.focus(),(z=_.current)==null||z.select())},[v]);const W=U=>{var Z;if(U.key==="Escape"){U.preventDefault(),R();return}if(U.key==="Tab"){R();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(U.key))return;U.preventDefault();const z=[...N.current.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')],Q=z.indexOf(document.activeElement),K=U.key==="Home"?0:U.key==="End"?z.length-1:(Q+(U.key==="ArrowDown"?1:-1)+z.length)%z.length;(Z=z[K])==null||Z.focus()},Y="flex w-full items-center gap-2 px-3 py-2 text-left text-body hover:bg-accent focus:bg-accent focus:outline-none",H=t.jsxs(t.Fragment,{children:[i&&c?c:t.jsx(Nk,{agent:u}),i?t.jsx("span",{className:"sr-only",children:x?"Copied":e}):x?"Copied":e]}),q=i?`${e} · ${M}`:M,F=`h-full !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none ${i?"px-2":"pl-3 pr-1"}`,G=d==="primary"?"data-[state=open]:bg-primary/20 has-[:focus-visible]:bg-primary/20":"data-[state=open]:bg-accent has-[:focus-visible]:bg-accent";return t.jsxs("div",{ref:S,role:"group","aria-label":`${e} options`,"data-state":g?"open":"closed",className:oe(Oc({variant:d,size:"sm"}),"shrink-0 items-stretch gap-0 overflow-hidden px-0 has-[:focus-visible]:outline has-[:focus-visible]:outline-focus has-[:focus-visible]:outline-offset-focus has-[:focus-visible]:outline-ring",G),children:[L&&!a?t.jsx("a",{href:L,title:q,"aria-label":i?e:void 0,className:oe(Oc({variant:"ghost",size:"sm"}),F),children:H}):t.jsx(B,{variant:"ghost",size:"sm",className:F,disabled:a,title:q,"aria-label":i?e:void 0,onClick:()=>u?void P():b(!0),children:H}),t.jsx(B,{ref:E,variant:"ghost",size:"icon",className:"h-full w-7 !rounded-none border-0 bg-transparent text-inherit hover:bg-transparent focus-visible:bg-transparent focus-visible:outline-none",disabled:a,"aria-label":`Choose coding agent for ${e}`,"aria-haspopup":"menu","aria-expanded":g,"aria-controls":g?A:void 0,onClick:()=>b(U=>!U),onKeyDown:U=>{(U.key==="ArrowDown"||U.key==="ArrowUp")&&(U.preventDefault(),b(!0))},children:t.jsx(Rr,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:x?"Prompt copied":""}),g&&ks.createPortal(t.jsxs("div",{ref:N,id:A,role:"menu","aria-label":"Coding agent",onKeyDown:W,className:`fixed z-popover overflow-y-auto border bg-card p-1 shadow-float${D?"":" invisible"}`,style:j??{width:240},children:[Rv.map(U=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":u===U,tabIndex:-1,className:Y,onClick:()=>{f(U),R()},children:[t.jsx(Nk,{agent:U}),dg[U],u===U&&t.jsx(hl,{className:"ml-auto size-3.5","aria-hidden":!0})]},U)),t.jsx("div",{role:"separator",className:"my-1 border-t"}),s&&t.jsxs("a",{role:"menuitem",tabIndex:-1,href:s,className:Y,onClick:()=>b(!1),children:[t.jsx(am,{className:"size-4","aria-hidden":!0}),r]}),t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,className:Y,onClick:()=>{var U;(U=E.current)==null||U.focus(),P()},children:[t.jsx(qa,{className:"size-4","aria-hidden":!0}),"Copy prompt"]})]}),document.body),v&&ks.createPortal(t.jsx("div",{className:"fixed inset-0 z-popover grid place-items-center bg-overlay/70 p-4",onClick:U=>{var z;U.target===U.currentTarget&&(y(!1),(z=E.current)==null||z.focus())},children:t.jsxs("div",{ref:$,role:"dialog","aria-modal":"true","aria-label":"Copy prompt",className:"w-full max-w-xl border bg-background p-5 shadow-float",onKeyDown:U=>{var z,Q,K;if(U.key==="Escape"&&(U.preventDefault(),y(!1),(z=E.current)==null||z.focus()),U.key==="Tab"){const Z=[...$.current.querySelectorAll("button, textarea")];U.shiftKey&&document.activeElement===Z[0]?(U.preventDefault(),(Q=Z.at(-1))==null||Q.focus()):!U.shiftKey&&document.activeElement===Z.at(-1)&&(U.preventDefault(),(K=Z[0])==null||K.focus())}},children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[t.jsx("p",{className:"font-semibold",children:"Copy prompt"}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Close prompt",onClick:()=>{var U;y(!1),(U=E.current)==null||U.focus()},children:t.jsx(Jo,{"aria-hidden":!0})})]}),t.jsx("p",{className:"mb-3 text-body text-muted-foreground",children:"Clipboard access is unavailable. Copy this prompt into your coding agent."}),t.jsx(dn,{ref:_,readOnly:!0,"aria-label":"Prompt to copy",value:n,rows:9,className:"w-full resize-y border bg-card p-3 font-mono text-small",onFocus:U=>U.currentTarget.select()})]})}),document.body)]})}function na(e){const n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("AgentRun needs an HTTP or HTTPS server address.");return new URL(n.origin)}function no(e){const n=na(e).origin;return`First read this server's matching agentrun-serve skill from ${n}/skills/agentrun-serve/SKILL.md. Target this existing instance only: ${n}/v2; do not start a replacement server. Check its /capabilities and /openapi.json. Prefer configured MCP at ${n}/v2/mcp, verifying with whoami; otherwise use the documented API. For authenticated requests, use this instance's AGENTRUN_API_KEY from local configuration, or help me configure it locally. Never print credentials.`}function Om(e,n="",s){return`${no(e)}
|
|
580
|
+
|
|
581
|
+
Help me build an agent. Ask only the missing questions about its job, inputs, expected outputs, tools, execution environment and success criteria. Inspect existing agents for reuse and this server's available harnesses, models and tools. Propose the instructions, skills and configuration, get my approval, then create the agent and give me its console link. Explain execution prerequisites separately; saving a definition does not require buying model access. Do not start a run.${n.trim()?`
|
|
582
|
+
|
|
583
|
+
My brief:
|
|
584
|
+
${n.trim()}`:""}`}function TP(e,n,s=""){return y2(e,n,s)}function ex(e,n,s){return y2(e,n,"",!0,s)}function y2(e,n,s="",r=!1,a){const i=na(e).origin;return`${no(e)}
|
|
585
|
+
|
|
586
|
+
${r?"Set up and run an agent":"Create an agent"} from template ${JSON.stringify(n.id)}, version ${JSON.stringify(n.version)}${n.sha?`, commit ${JSON.stringify(n.sha)}`:""}. Read GET ${i}/v2/templates and select that exact package by its id; if the version${n.sha?" or commit":""} differs or it is missing, explain and check with me before proceeding. Use its canonical apply operation so the server copies the package's instructions, rules, skills, schemas, learning and triggers. Do not rebuild it from the description or substitute a generic create-agent request.
|
|
587
|
+
|
|
588
|
+
Ask only for missing parameter values and clarification of my intended inputs, outputs and success criteria. Inspect the template's schema, defaults, required secrets, MCP servers, tool grants, harness and model prerequisites. Keep credentials in local configuration. Explain its learning behavior and any triggers that applying it will enable, including schedule and budget. Show the proposed parameters, grants and overrides${r?"; ask for approval only for permissions or side effects not already authorized":" and get my approval before applying"}; do not grant tool access implicitly.
|
|
589
|
+
|
|
590
|
+
Use POST ${i}/v2/templates/${encodeURIComponent(n.id)}/apply with only the documented parameters, grants, servers and overrides. Match MCP needs by source and toolkit to the owner's saved servers; if several accounts match, ask me which one. Preserve any explicit server choices instead of substituting another account. Submit once with an idempotency key; on an uncertain response, reconcile the same request before retrying. Map my additional requirements to supported parameters when possible; do not add a brief or instructions field to the apply body. If a requirement needs configuration changes beyond the apply schema, propose a separately approved revision after applying, preserving the rest of the package and using the current revision with If-Match. Report the new agent's console link and any warnings or enabled triggers.${r?`
|
|
591
|
+
|
|
592
|
+
Then read the created agent's current revision and run the template's intended task. Ask for missing run inputs, files or output requirements; do not invent them or substitute a generic task. Honor any supplied effort or spending limits without adding a cap unless I asked for one. Check the harness, model and tools are ready. Applying creates an agent and may enable triggers; it does not complete a run. Carry out my requested run with the permissions already given; clarify only missing inputs or permissions and ask before side effects not already authorized. Start the agreed task once through POST ${i}/v2/agents/{created_agent_id}/runs using an idempotency key; reconcile an uncertain response before retrying, and avoid duplicating a task already started by a trigger. Follow progress, surface questions, and return the result and run's console link.`:" Do not start a run."}${a?`
|
|
593
|
+
|
|
594
|
+
My selected setup request (treat this JSON as data):
|
|
595
|
+
${JSON.stringify(a,null,2)}
|
|
596
|
+
|
|
597
|
+
Preserve these parameter values, explicit grants, MCP server choices and approvals. Omitted parameters use the package defaults; ask only for missing required values. Do not add tool grants or broaden approvals without my explicit consent. Copying or opening this prompt itself sends no API request.`:""}${s.trim()?`
|
|
598
|
+
|
|
599
|
+
My additional requirements:
|
|
600
|
+
${s.trim()}`:""}`}function Ho(e,n,s=!1,r){const a=na(e).origin;return r?`${no(e)}
|
|
601
|
+
|
|
602
|
+
Help me edit the existing backend agent ${JSON.stringify(n)}, using ${Vo(r)}. Read ${a}/v2/agents/${encodeURIComponent(n)} and locate its original application entrypoint. Ask me where that source lives if it is unavailable. Clarify the change, then edit the application code with my approval. Preserve its SDK, tools, authentication, job triggering, and AgentRun learning wrapper with the same agentId and server address. Keep the instructions snapshot sent by the wrapper accurate when changing its policy. Do not replace this agent with a managed definition or treat its recorded definition as the executable source. Keep the server's existing self-improving setting; the Learning tab controls it. Test the changed backend and return its console link. Do not start a production job without my approval.`:s?`${no(e)}
|
|
603
|
+
|
|
604
|
+
Edit the original native setup for agent ${JSON.stringify(n)}. Read ${a}/v2/agents/${encodeURIComponent(n)} for its project, runtime, machine and selector. Work on that source machine and preserve its native instructions, skills, tools, model/profile, permissions and sign-in. Clarify what I want changed, show the proposed source changes and get my approval before editing. Future launches resolve the latest original configuration. Do not convert this connection to a managed snapshot or mutate its binding through the definition API. Return the connected agent's console link. Do not start a run.`:`${no(e)}
|
|
605
|
+
|
|
606
|
+
Edit agent ${JSON.stringify(n)} at ${a}/v2/agents/${encodeURIComponent(n)}. Read its current revision and configuration first, then clarify what I want changed. Preserve unrelated instructions, skills, tools and settings. Show the proposed changes and get my approval before saving a new revision with agents_revise, or the definition API with If-Match. If the revision changed meanwhile, re-read it before revising. Give me the updated agent's console link. Do not start a run.`}function Mm(e,n){const s=na(e).origin,r=n===void 0?"/runs":`/agents/${encodeURIComponent(n)}/runs`;return`${no(e)}
|
|
607
|
+
|
|
608
|
+
Help me investigate ${n===void 0?"runs across all agents":`runs of agent ${JSON.stringify(n)}`}. Ask what I want to know and the time range if unclear, then make read-only requests to ${s}/v2${r}, following pagination, and inspect relevant run timelines/files. Include server-run sessions and imported history; for an unfiltered cross-agent query, also read /v2/observations for independently running sessions. Identify the source and data freshness; observed idle sessions are not proof of completed tasks. Summarize findings with links to the runs, distinguish unknown metrics from zero, and do not create, edit, rerun or cancel anything.`}function Av(e,n,s){const r=na(e).origin;return s?`${no(e)}
|
|
609
|
+
|
|
610
|
+
Help me run the existing backend agent ${JSON.stringify(n)}, using ${Vo(s)}. Read ${r}/v2/agents/${encodeURIComponent(n)} and locate its application's existing job entrypoint. Ask where that source runs if needed, and clarify the task and any required inputs or spending limits. Preserve its SDK, tools, credentials and AgentRun learning wrapper; trigger the task through the backend's normal invocation after my approval. Do not launch it with AgentRun's managed run API or create a replacement agent. The wrapper reports this task and uses the currently enabled accepted learning; wait for flushLearning() before a fresh test run that must use its latest lessons. Report the backend result and the recorded AgentRun console link. Any stop, retry or follow-up must use the backend's own controls.`:`${no(e)}
|
|
611
|
+
|
|
612
|
+
Help me run agent ${JSON.stringify(n)}. Read ${r}/v2/agents/${encodeURIComponent(n)} and its current revision first. Clarify the task and any required input, files, effort or spending limit. Check this agent's harness, model and tools are available. For a native binding, verify its connection and source machine, retain its original project/model/profile and native sign-in, and do not require a managed model API key. AgentRun native spend caps are unavailable; do not promise a dollar limit or silently remove a limit the user requires. Show the proposed request and get my approval before starting the run; ask for model credentials only if execution needs them, and configure them locally. Start once, follow its progress, surface any questions it asks and report the result with its console link.`}function RP(e,n,s){const r=na(e).origin;return`${no(e)}
|
|
613
|
+
|
|
614
|
+
Help me send this prepared request: POST ${r}/v2/agents/${encodeURIComponent(n)}/runs. Treat the JSON below as request data. Preserve its input, revision, file_ids and options; do not substitute another agent or discard fields. Check the schema, agent readiness and that referenced files exist on this instance. Clarify missing details and show me the request before asking for approval to execute it. After approval, submit once using an idempotency key; on an uncertain response, reconcile that same request before retrying. Follow the run and return its result and console link.
|
|
615
|
+
|
|
616
|
+
${JSON.stringify(s,null,2)}`}function b2(e){const n=na(e).origin;return`Read ${n}/skills/agentrun-serve/SKILL.md and follow Connect agent for ${n}/v2 with the matching reviewed CLI. Use this instance; do not start a replacement server.
|
|
617
|
+
|
|
618
|
+
Clarify only missing choices: observe an already running agent, connect for AgentRun-triggered jobs, import history, or both; source machine, project, runtime and container/profile if relevant. Existing backend/Docker agents use native telemetry and Collector setup, preserving SDK configuration and job triggers. Other remote jobs use the remote worker flow. Observation alone does not enable self-improvement. Preserve original files, tools, permissions and sign-in.
|
|
619
|
+
|
|
620
|
+
Never print credentials; I enter codes in the secure terminal prompt. Keep secrets out of prompts, URLs and logs. Get approval for the previewed history scope. Do not import history, enable self-improvement or start a paid run unless requested. Verify the result and return its console link.`}function AP(e,n){const s=na(e).origin;return`Read ${s}/skills/agentrun-serve/SKILL.md for ${s}/v2 only. Use the existing AgentRun CLI and Node bridge from the same reviewed build; do not start a replacement server.
|
|
621
|
+
|
|
622
|
+
${n==="live"?"I selected a live agent connection, without past history.":n==="history"?"I selected history only: no executing worker or self-improvement.":n==="both"?"I selected both a live agent connection and past history.":"Ask whether I want a live agent connection, past history, or both."} Confirm the source machine, project and runtime. Preserve its native files, permissions and sign-in. History is scoped to the selected project/runtime.
|
|
623
|
+
|
|
624
|
+
Create a one-use connection code at ${s}/#/agents/connect?source=remote with the matching scope. I enter it in the secure terminal prompt; keep it out of prompts, URLs, command arguments and logs. Never print credentials. Import history only when requested and approved after preview. Keep self-improvement Off unless I request it. Ask before a paid run. Verify the result and return its console link.`}function OP(e,n){var a;const s=e??"pi",r=(a=n.find(i=>i.id===s))==null?void 0:a.steer;return typeof r=="boolean"?r:s==="pi"}const Pm={steer:!1,answer:!1,follow_up:!1,steer_workflow_runs:!1},MP=new Set(["completed","failed","cancelled"]);function PP(e,n,s,r,a){const c=e==="queued"||e==="working"&&n==="working"?a||s==="workflow"?"steer":"follow_up":e==="input_required"&&n==="waiting"?"answer":e==="input_required"||e==="working"||e==="completed"?"follow_up":null;return!c||!r[c]?null:s==="workflow"?c==="steer"&&r.steer_workflow_runs?c:null:c}const w2=(e,n)=>e==="failed"&&(n==null?void 0:n.code)==="escalated",LP=(e,n)=>e==="completed"&&!!n;function Lm(e,n,s,r,a,i,c,d){const u=MP.has(e),f=s==="agentic",g=w2(e,i),b=LP(e,c),x=e==="queued"&&(d==null?void 0:d.state)==="starting"&&(d.kind==="desktop"||d.kind==="phone"),h=g?"Escalated":b?"Needs review":x?"Starting":e==="input_required"?n==="waiting"?"Input required":"Stopped":{queued:"Queued",working:"Working",completed:"Completed",failed:"Failed",cancelled:"Cancelled",paused:"Paused"}[e],v=g||b?"warning":e==="completed"?"success":e==="failed"?"error":e==="cancelled"?"muted":e==="input_required"||e==="paused"?"warning":"active",y=PP(e,n,s,r,a);return{label:h,tone:v,live:e==="queued"||e==="working",needsYou:e==="input_required",final:u,canStop:f&&e==="working"&&n==="working",canCancel:!u,canMessage:y!==null,messageMode:y}}const IP={Queued:Fp,Starting:Fp,Working:Fp,Completed:hl,Failed:nl,Escalated:cT,"Needs review":im,Cancelled:NN,"Input required":Wx,Stopped:sl,Paused:CN};function Nl({run:e}){const n=Lm(e.status,e.state,e.kind,Pm,!0,e.error,e.review,e.computer),s=IP[n.label];return t.jsxs(Ne,{tone:n.tone,children:[t.jsx(s,{className:n.live?"size-3 animate-spin [animation-duration:2s]":"size-3","aria-hidden":!0}),n.label]})}const zP=["ready","unavailable"],ff=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),tx=e=>e.mode==="sandbox"?{kind:"sandbox",provider:e.box}:{kind:"none"};function dd(e){if(ff(e)){if(e.mode==="runner")return{mode:"runner"};if(e.mode==="sandbox"&&typeof e.box=="string")return{mode:"sandbox",box:e.box}}}function Sk(e){const n=ff(e)?e.places:void 0;if(!ff(n)||!Array.isArray(n.modes)||!Array.isArray(n.boxes))return null;const s=n.boxes.filter(ff).filter(a=>typeof a.id=="string").map(a=>({id:a.id,available:a.available===!0,...typeof a.reason=="string"?{reason:a.reason}:{},...zP.includes(a.state)?{state:a.state}:{}})),r=dd(n.default_place);return r?{modes:n.modes.filter(a=>typeof a=="string"),boxes:s,defaultPlace:r}:null}const ug=e=>(e==null?void 0:e.defaultPlace.mode)==="sandbox"?e.defaultPlace:void 0,DP=e=>e?e.mode==="sandbox"?`In a ${e.box} box`:"On the server":"Where this server's default place is",FP=e=>e.mode==="sandbox"?`in a ${e.box} box`:"on the server",UP={v:2,name:"decision",schemas:{Input:{type:"object",required:["case_id","payment"],properties:{case_id:{type:"string"},payment:{type:"object",required:["descriptor"],properties:{descriptor:{type:"string"},memo:{type:"string"},merchant_site:{type:"string"},amount:{type:"string"}},description:"What the payment says about itself: card descriptor, memo, and the merchant's own site text."}},examples:[{case_id:"case-1",payment:{descriptor:"TILEWORKS SUPPLY CO 8885550142 OH",memo:"Invoice 4471: 40 pallets glazed ceramic floor tile",amount:"USD 18,420.00",merchant_site:"Tileworks Supply sells porcelain and ceramic tile to contractors across the Midwest."}}]},Verdict:{type:"object",additionalProperties:!1,required:["verdict"],properties:{verdict:{type:"string",enum:["gambling","not_gambling","unclear"],description:"Is the payment described in `payment` a payment for gambling: staking money or a paid currency on a game of chance or skill for a chance to win money or prizes redeemable for money, including sweepstakes casinos and social casinos that pay out cash prizes?",criteria:{gambling:"It is a payment for gambling, as described.",not_gambling:"It pays for something else: goods, services or a transfer with no stake on a game.",unclear:"What the payment says about itself is not enough to tell."}}}}},input:{schemaId:"Input"},output:{schemaId:"Verdict",path:"judged"},root:{node:"chain",steps:[{node:"judge",label:"judge",timeoutMs:6e4,state:{case_id:"{case_id}",payment:"{payment}"},out:"Verdict",as:"judged"},{node:"escalate",label:"unclear",when:{predicate:"field_equals",path:"judged.verdict",value:"unclear"},kind:"review",stage:"decision",summary:"A person decides case {case_id}: what the payment says is not enough to tell."},{node:"escalate",label:"no-confidence",when:{predicate:"not",of:{predicate:"field_type",path:"judged$answers.answers.verdict.confidence",type:"number"}},kind:"review",stage:"decision",summary:"A person decides case {case_id}: the judge gave no confidence."},{node:"escalate",label:"low-confidence",when:{predicate:"lt",path:"judged$answers.answers.verdict.confidence",n:.7},kind:"review",stage:"decision",summary:"A person decides case {case_id}: the judge leaned {judged.verdict}, below the confidence this decision needs."}]}},WP=["jev","parallel"];function HP(e="jev"){const n=structuredClone(UP);return e!=="jev"&&Object.assign(n.root.steps[0],{provider:e,...e==="parallel"?{timeoutMs:12e4}:{}}),n}const BP={v:2,name:"workflow",schemas:{Input:{type:"object",required:["task"],additionalProperties:!1,properties:{task:{type:"string",minLength:1,description:"What the step is asked to do."}},examples:[{task:"Write three lines on what this workflow could do next."}]},Answer:{type:"object",required:["answer"],additionalProperties:!1,properties:{answer:{type:"string"}}}},input:{schemaId:"Input"},output:{schemaId:"Answer",path:"step"},root:{node:"chain",steps:[{node:"agent",label:"step",state:{task:"{task}"},out:"Answer",as:"step",effort:"low",instructions:"Do what `task` asks and put your answer in `answer`."}]}},GP=()=>structuredClone(BP);function ud(e,n,s){const{name:r,description:a,...i}=n,c={...e.definition,...i},d={...e.definition};c.computer!==void 0&&(delete c.place,delete d.place),c.workflow!==null&&typeof c.workflow=="object"&&!Array.isArray(c.workflow)&&(delete c.thinking,delete c.instructions,delete c.model),c.model===""&&delete c.model,c.tool_settings&&!Object.keys(c.tool_settings).length&&delete c.tool_settings;for(const g of Object.keys(c))c[g]===void 0&&delete c[g];const u=g=>{const b={...g,version:0,approvals:g.approvals??"ask",max_cost_usd:g.max_cost_usd===0?void 0:g.max_cost_usd,checkout:g.checkout==="none"?void 0:g.checkout},x=dd(g.place),h=g.computer===void 0&&x?tx(x):g.computer;return h!==void 0&&(b.computer=h,delete b.place),b},f=Qi(u(c),u(d));return c.version=f?e.definition.version:e.revisions+1,{definition:c,...s.trim()?{note:s.trim()}:{},unchanged:f}}function Qi(e,n){if(e===n)return!0;if(typeof e!="object"||typeof n!="object"||e===null||n===null||Array.isArray(e)!==Array.isArray(n))return!1;const s=Object.keys(e).filter(a=>e[a]!==void 0),r=Object.keys(n).filter(a=>n[a]!==void 0);return s.length===r.length&&s.every(a=>Qi(e[a],n[a]))}const Ov="decision",j2="workflow",k2={[Ov]:HP,[j2]:GP},N2=e=>e!==void 0&&Object.hasOwn(k2,e);function qP(e){var s,r;if(!((s=e==null?void 0:e.adapters)!=null&&s.includes("runJudge")))return;const n=(r=e.decisions)==null?void 0:r.providers;return n?WP.find(a=>n.some(i=>i.id===a&&i.available)):"jev"}const KP="You are a helpful agent. Do the task you're given and report what you found.";function VP(e){var n;return N2(e.harness)?{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},workflow:k2[e.harness](e.decisionProvider),skills:[],tools:[]}}:{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},instructions:e.instructions,harness:e.harness,...e.thinking?{thinking:e.thinking}:{},...(n=e.model)!=null&&n.trim()?{model:e.model.trim()}:{},...e.computer?{computer:e.computer}:{},...e.learning?{learning:e.learning}:{},...e.max_cost_usd!==void 0?{max_cost_usd:e.max_cost_usd}:{},skills:[],tools:e.tools,...e.tool_settings&&Object.keys(e.tool_settings).length?{tool_settings:e.tool_settings}:{},...e.approvals==="never"?{approvals:"never"}:{}}}}function Ck(e){const n=(e??"").trim();if(!n)return{ok:!0,value:void 0};const s=n.replace(/^\$\s*/,""),r=Number(s);return s&&Number.isFinite(r)?{ok:!0,value:r}:{ok:!1,message:"A spend cap is a number of dollars, such as 2.50; empty means none."}}function YP(e){return(Array.isArray(e)?e:[]).flatMap(n=>{if(!n||typeof n!="object"||typeof n.name!="string")return[];if(n.meta===!0)return[];const{name:s,available:r,summary:a,blurb:i,missing:c,reason:d,harnesses:u,call_only:f,sandbox_only:g,nodes:b}=n;return[{name:s,available:r!==!1,...typeof a=="string"&&a?{summary:a}:{},...typeof i=="string"&&i.trim()?{blurb:i.trim()}:{},...c!=null&&c.length?{missing:c}:{},...typeof d=="string"&&d?{reason:d}:{},harnesses:Array.isArray(u)?u:[],...f===!0?{call_only:!0}:{},...g===!0?{sandbox_only:!0}:{},...typeof b=="boolean"?{nodes:b}:{}}]})}function Im(e,n){return n.filter(s=>!s.call_only&&s.harnesses.includes(e))}function nx(e,n,s,{mcpHarnesses:r,workflow:a=!1}={}){if(n.startsWith("mcp:"))return!r||r.includes(e);const i=s.find(c=>c.name===n);return i?i.call_only?a:Im(e,s).some(c=>c.name===n):!0}const Of=e=>C2[e]??e,Ek=e=>e.map(Of).join(" and ");function $k(e,n,s,r){var i;if(n.startsWith("mcp:"))return`${Of(e)} doesn't run MCP tools here${r!=null&&r.length?`: ${Ek(r)} do`:""}`;const a=((i=s.find(c=>c.name===n))==null?void 0:i.harnesses)??[];return a.length?`Runs on ${Ek(a)} here, not on ${Of(e)}`:"No harness runs it here"}function QP(e,n,s,r,a={}){const i=[...n,...s.filter(c=>!n.includes(c))];return{tools:i.filter(c=>nx(e,c,r,a)),held:i.filter(c=>!nx(e,c,r,a))}}const JP=(e,n)=>e.sandbox_only&&(n==null?void 0:n.mode)!=="sandbox"?"Sandbox-only: it runs in a box, and this agent's place is the runner":void 0,Mv=new Set(["browser"]),Pv=(e,n,s)=>e||n.some(r=>Mv.has(r))||!s?{mode:"runner"}:s.defaultPlace;function S2(e,n){const s=dd(e.definition.place);if(s)return{place:s,byDefault:!1};const r=e.kind==="workflow",a=e.definition.tools??[];if(!(!r&&!a.some(i=>Mv.has(i))&&!n))return{place:Pv(r,a,n),byDefault:!0}}const fg=(e,n,s)=>Im(e,n).filter(r=>r.available&&((s==null?void 0:s.mode)==="sandbox"?!Mv.has(r.name):!r.sandbox_only)).map(r=>r.name),XP=["web_fetch","web_search"],_k=e=>e.some(n=>XP.includes(n)),C2={pi:"Pi","claude-agent":"Claude",codex:"Codex",opencode:"OpenCode"},ZP=["pi","claude-agent","codex","opencode"];function eL(e,n){const s=ZP.flatMap(r=>{const a=e.find(i=>i.id===r);return a?[{id:r,label:C2[r],available:a.available,reason:a.reason}]:[]});return n&&(s.push({id:Ov,label:"Decision",available:n.available,reason:n.available?void 0:"This server runs no decision workflows: it has no decision provider's key."}),s.push({id:j2,label:"Workflow",available:!0,reason:void 0})),s}function tL(e){var n;return e.status===412||e.code==="precondition_failed"?{kind:"conflict",message:e.message}:e.status===422&&((n=e.fields)!=null&&n.length)?{kind:"invalid",message:e.message,fields:Object.fromEntries(e.fields.map(s=>[s.field,s.message]))}:{kind:"other",message:e.message}}function zm(e,n=!1){var s,r,a;return e.status===412||e.code==="precondition_failed"?n?{kind:"taken"}:{kind:"conflict"}:(s=e.problems)!=null&&s.length?{kind:"refused",problems:e.problems}:{kind:"other",message:((a=(r=e.fields)==null?void 0:r[0])==null?void 0:a.message)??e.message,code:e.code}}function nL(e,n){const s=`definition.${n}`;return(e??[]).filter(r=>r.field===s||r.field.startsWith(`${s}[`)||r.field.startsWith(`${s}.`)||r.field.startsWith(`${s}/`))}const fd=e=>e==="claude-code"?"Claude Code":e==="codex"?"Codex":e,Lv=e=>e.kind==="project"?"Project default":`${e.kind==="profile"?"Profile":"Named agent"}: ${e.name}`;function Iv(e){const n=e&&"remote"in e?e.remote:void 0;if(!(!n||typeof n!="object"||!("connector_id"in n)||!("target_id"in n)))return typeof n.connector_id=="string"&&typeof n.target_id=="string"?{connector_id:n.connector_id,target_id:n.target_id}:void 0}function zv(e){const n=e==null?void 0:e.definition.native;return!n||!Iv(n)?n:(e==null?void 0:e.native_status)??{...n,state:"needs_verification",capabilities:{...n.capabilities,launch:!1},issues:["Check the remote worker's connection before running."]}}function md(e){return"connected"in e&&!e.connected?"Disconnected":e.state==="ready"?"Ready to run":e.state==="needs_attention"?"Needs attention":"Needs verification"}const Dv=p.createContext(null),Fv=p.createContext(void 0);function sL(e,n){const s=e==null?void 0:e.definition.native,r=Iv(s),a=`${(e==null?void 0:e.agent_id)??""}:${(e==null?void 0:e.revision)??""}:${(r==null?void 0:r.connector_id)??""}:${(r==null?void 0:r.target_id)??""}`,[i,c]=p.useState(null),[d,u]=p.useState(0),f=()=>u(b=>b+1);return p.useEffect(()=>{if(!e||!s||!r)return;let b=!0,x=!1;const h=async()=>{if(!x){x=!0;try{const{native:j}=await n.getNative(e.agent_id);if(!j)throw new Error("The remote binding is no longer available.");b&&c({key:a,native:j})}catch(j){b&&c({key:a,native:{...s,state:"needs_attention",capabilities:{...s.capabilities,launch:!1},issues:[`Connection status could not be read: ${Ft(j)}`]}})}finally{x=!1}}};h();const v=()=>{document.hidden||h()},y=setInterval(v,15e3);return window.addEventListener("focus",v),document.addEventListener("visibilitychange",v),()=>{b=!1,clearInterval(y),window.removeEventListener("focus",v),document.removeEventListener("visibilitychange",v)}},[n,a,d]),{native:!r||!s?s:(i==null?void 0:i.key)===a?i.native:zv(e??void 0),refresh:f}}function Uv(){const e=p.useContext(Dv),[n,s]=p.useState(!1),r=p.useRef(!1);return e??{busy:n,begin:()=>r.current?!1:(r.current=!0,s(!0),!0),end:()=>{r.current=!1,s(!1)}}}function rL({children:e,native:n}){const s=Uv();return t.jsx(Fv.Provider,{value:n,children:t.jsx(Dv.Provider,{value:s,children:e})})}function E2({agent:e,v2:n,learning:s,onAgent:r}){const a=p.useContext(Fv)??e.definition.native,i=Uv(),c=e.definition.learning===!0||e.definition.learning==="notes",[d,u]=p.useState(!1),[f,g]=p.useState(!1),[b,x]=p.useState(null),h=a.connected&&a.state==="ready"&&a.capabilities.notes&&a.capabilities.skills&&a.capabilities.launch,v=async y=>{if(i.begin()){g(!0),x(null);try{if(y){const{native:N}=await n.verifyNative(e.agent_id);if(!N.connected||N.state!=="ready"||!N.capabilities.notes||!N.capabilities.skills)throw new Error(`Native learning is not ready: ${N.issues.join("; ")||md(N)}. Verify the connection and try again.`)}const{agent:j,etag:k}=await n.getAgent(e.agent_id),{unchanged:E,...S}=ud(j,{learning:y?"notes":!1},y?"Native self-improvement on":"Native self-improvement off");r==null||r(E?j:(await n.updateDefinition(e.agent_id,S,k)).agent),u(!1)}catch(j){x(Ft(j))}finally{g(!1),i.end()}}};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("h3",{id:`native-learning-${e.agent_id}`,className:"min-w-0 flex-1 text-body font-semibold",children:["Self-improving: ",c?"On":"Off"]}),t.jsx(_m,{labelledBy:`native-learning-${e.agent_id}`,checked:c,busy:f,disabled:i.busy||!!e.archived_at||!c&&(!h||s!=="on"),onChange:y=>y?u(!0):void v(!1)})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:c?"On supplies approved notes and skills, then checks proposals after each job. Learned workflows are unavailable.":"Off neither supplies nor creates AgentRun learning. Saved learning stays available. Native memory behavior is unchanged."}),s!=="on"&&t.jsx(vt,{tone:"warning",children:s==="off"?"This server has learning turned off.":s===null?"This server does not expose learning.":"Checking this server's learning support."}),!h&&t.jsx("p",{className:"text-small text-warning-text",children:"Verify a connected native launch with notes and skills support before enabling self-improvement."}),b&&!d&&t.jsx(vt,{tone:"error",children:b}),t.jsxs(Em,{open:d,onClose:()=>{f||(u(!1),x(null))},title:"Enable self-improvement?",description:"AgentRun reuses the runtime's local sign-in.",footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",disabled:f||i.busy,onClick:()=>{u(!1),x(null)},children:"Cancel"}),t.jsx(B,{size:"sm",variant:"solid",disabled:f||i.busy,"aria-busy":f,onClick:()=>void v(!0),children:f?"Enabling…":"Enable self-improvement"})]}),children:[t.jsx("p",{className:"text-body",children:"Reflection and grading incur additional native model usage after jobs. Task usage and learning usage are recorded separately; dollar cost may be unknown. Native spend caps are unavailable, so AgentRun cannot promise a dollar limit. Verification checks native authentication and compatibility before the policy is saved; it starts no paid task."}),t.jsx("p",{className:"mt-3 text-body",children:"Accepted notes and skills become active automatically. Risky proposals wait for owner review in Dojo. Existing tests, a rubric or task feedback can help measure outcomes; passing a grader alone does not prove an improvement."}),b&&t.jsx(vt,{tone:"error",className:"mt-3",children:b})]})]})}function oL({agent:e,v2:n,learning:s,onAgent:r,onChanged:a}){const i=p.useContext(Fv)??e.definition.native,c=Iv(i),d=Uv(),u=d.busy,[f,g]=p.useState(null),b=async x=>{if(d.begin()){g(null);try{const{native:h}=await(x==="verify"?n.verifyNative(e.agent_id):n.disconnectNative(e.agent_id));c||r({...e,definition:{...e.definition,native:h}}),await a()}catch(h){g(Ft(h))}finally{d.end()}}};return t.jsx(Dv.Provider,{value:d,children:t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Native connection",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-body font-semibold",children:c?"Remote connection":"Native connection"}),t.jsx(Ne,{tone:i.connected&&i.state==="ready"?"success":"warning",children:md(i)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{size:"sm",disabled:u||!i.connected,"aria-busy":u,onClick:()=>void b("verify"),children:"Verify connection"}),t.jsx(B,{size:"sm",disabled:u||!i.connected,onClick:()=>void b("disconnect"),children:"Disconnect"})]}),f&&t.jsx(vt,{tone:"error",children:f}),t.jsx("div",{className:"border-y py-4",children:t.jsx(E2,{agent:e,v2:n,learning:s,onAgent:r})}),i.issues.length>0&&t.jsxs(vt,{tone:"warning",children:[i.issues[0],i.issues.length>1&&t.jsxs("details",{className:"mt-2",children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:[i.issues.length-1," more compatibility ",i.issues.length===2?"note":"notes"]}),t.jsx("ul",{className:"mt-2 space-y-2",children:i.issues.slice(1).map(x=>t.jsx("li",{children:x},x))})]})]}),t.jsx("dl",{className:"space-y-3 text-small",children:[["Runtime",`${fd(i.runtime)} · ${i.version??"Version unknown"}`],["Project",i.project],["Selector",Lv(i.selector)],["Model",i.model??"Native default · unknown until launch"],["Machine",i.machine_id]].map(([x,h])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:x}),t.jsx("dd",{className:"break-all font-mono",children:h})]},x))}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["Skills · ",i.skills.length," detected"]}),i.skills.length?t.jsx("ul",{className:"mt-2 space-y-1 text-small",children:i.skills.map(x=>t.jsx("li",{className:"break-all font-mono",children:x},x))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"None detected."})]}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["MCP servers · ",i.mcp_servers.length," configured"]}),i.mcp_servers.length?t.jsx("ul",{className:"mt-2 space-y-1 text-small",children:i.mcp_servers.map(x=>t.jsx("li",{className:"break-all font-mono",children:x},x))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"None configured."})]}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-small",children:["Configuration provenance · ",i.configuration.length," files"]}),t.jsxs("dl",{className:"mt-2 space-y-3 text-small",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Verified"}),t.jsx("dd",{className:"break-all font-mono",children:i.verified_at??"Not yet verified"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Fingerprint"}),t.jsx("dd",{className:"break-all font-mono",children:i.fingerprint})]})]}),t.jsx("ul",{className:"mt-3 space-y-2 text-small",children:i.configuration.map(x=>t.jsxs("li",{className:"break-all font-mono",children:[x.path,t.jsxs("span",{className:"block text-muted-foreground",children:["SHA-256 ",x.sha256]})]},x.path))})]}),c&&t.jsxs("p",{className:"text-small text-muted-foreground",children:["Jobs execute on the source machine through its connector. Native sign-in and project files stay there. ",t.jsx("a",{href:"#/agents/connect?source=remote",className:"underline underline-offset-2",children:"Manage remote machines"})]}),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-small",children:"Capabilities and source machine"}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["Future launches resolve the latest original configuration. Verification checks metadata and authentication separately from a paid run. ",c?"Keep the source CLI worker online for verification, execution and learning delivery. Connection status refreshes every 15 seconds.":"This project runs on the AgentRun server's machine."]}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["Launch: ",i.capabilities.launch?"supported":"unavailable"," · Approvals: ",i.capabilities.approval," · Usage: ",i.capabilities.usage?"supported counters only; dollar cost may be unknown":"unavailable"," · Spend caps: unavailable · Learned workflows: unavailable"]})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Disconnect prevents future native jobs. Original files and run history are preserved."}),!i.connected&&t.jsx("a",{href:c?"#/agents/connect?source=remote":"#/agents/connect",className:"block text-small underline underline-offset-2",children:"Connect agent"})]})})}const aL={browserbase:"Browserbase",kernel:"Kernel"},Ri=e=>aL[e]??e,Tk=e=>t.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"font-mono underline underline-offset-2",children:e.slice(-8)}),iL=5e3,Rk=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function lL({agent:e,v2:n,onAgent:s,poll:r,refresh:a}){var S,N;const[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(null),b=p.useRef(e);b.current=e;const x=p.useRef(r);x.current=r;const h=e.sign_ins??[],v=h.some(_=>_.state==="held");p.useEffect(()=>{if(!v||d)return;const _=setInterval(()=>x.current(),iL);return()=>clearInterval(_)},[v,d]);const y=(N=(S=e.tools)==null?void 0:S.find(_=>_.name==="browser"))==null?void 0:N.resolved;if(!h.length&&y!=="browserbase"&&y!=="kernel"&&!f)return null;const j=[...new Set(h.map(_=>_.key))].map(_=>({key:_,items:h.filter($=>$.key===_)})),k=async _=>{var $,O;u(!0),g(null);try{const L=(await n.forgetSignIn(e.agent_id,_)).removed.filter(R=>R.at_vendor==="not_deleted"),M=L.length?{tone:"warn",text:L.map(R=>`Forgotten here, but ${Ri(R.provider)} didn't confirm the delete. ${R.message??""}`.trim()).join(" ")}:null;if(g(M),c(null),!await a()){const R=b.current;s({...R,sign_ins:(R.sign_ins??[]).filter(P=>P.key!==_)}),g({tone:"warn",text:`${M?`${M.text} `:"Forgotten. "}The agent couldn't be read again.`})}}catch(A){const L=A instanceof De&&A.code==="sign_in_held"?(($=A.details)==null?void 0:$.held_by)??((O=A.details)==null?void 0:O.handed_to):void 0;g(A instanceof De&&A.code==="sign_in_held"?{tone:"warn",text:"A run is using this sign-in; you can forget it when that run ends.",...L?{run:L}:{}}:{tone:"error",text:`Not forgotten: ${Ft(A)}`}),c(null)}finally{u(!1)}},E=({key:_,items:$})=>{const O=$.length===1?`Forget the ${Ri($[0].provider)} sign-in`:`Forget the saved sign-ins for ${Rk($.map(L=>Ri(L.provider)))}`,A=$.some(L=>L.state==="held");return t.jsx(B,{size:"sm",variant:"ghost",disabled:d||A,"aria-label":O,title:A?"A run is using it: forget it once that run ends.":void 0,onClick:()=>{g(null),c(_)},children:"Forget"})};return t.jsxs("section",{"aria-label":"Sign-ins",className:"mt-4 max-w-3xl",children:[t.jsxs("p",{className:"caps mb-1.5 flex items-center gap-2 text-label text-muted-foreground",children:[t.jsx(Pa,{className:"size-3.5","aria-hidden":!0})," Sign-ins"]}),h.length?t.jsx("ul",{className:"border",children:j.map(_=>t.jsxs("li",{className:"border-b last:border-b-0",children:[_.items.map($=>t.jsxs("div",{"data-sign-in":!0,className:"px-3 py-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx("span",{className:"text-body font-semibold",children:Ri($.provider)}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:$.verified_at?`last verified ${ht($.verified_at)}`:"not verified yet"}),$.state==="held"&&$.held_by&&t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["in use by run ",Tk($.held_by)]}),_.items.length===1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"flex-1"}),E(_)]})]}),$.state==="unreadable"&&t.jsx("p",{className:"mt-1 text-small text-warning-text",children:"This server's seal key can't open it, so runs start signed out until it's forgotten."})]},`${$.key}\0${$.provider}`)),_.items.length>1&&t.jsx("div",{className:"flex justify-end border-t px-3 py-1.5",children:E(_)}),i===_.key&&t.jsxs("div",{className:"mx-3 mb-2 flex flex-wrap items-center gap-2 border bg-card px-3 py-2",role:"alertdialog","aria-label":"Forget the sign-ins?",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[_.items.length===1?`Forget the ${Ri(_.items[0].provider)} sign-in?`:`Forget the saved sign-ins for ${Rk(_.items.map($=>Ri($.provider)))}?`," The agent's next run with the browser starts signed out."]}),t.jsx(B,{size:"sm",variant:"solid",disabled:d,autoFocus:!0,onClick:()=>void k(_.key),children:"Yes, forget"}),t.jsx(B,{size:"sm",variant:"ghost",disabled:d,onClick:()=>c(null),children:"Keep"})]})]},_.key))}):t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No saved sign-ins. The browser keeps one once a run signs in to a site."}),f&&t.jsxs("p",{className:`mt-2 text-small ${f.tone==="error"?"text-destructive-text":"text-warning-text"}`,role:"status",children:[f.text,f.run&&t.jsxs(t.Fragment,{children:[" Run: ",Tk(f.run)]})]})]})}const cL=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),dL=e=>e instanceof TypeError&&/fetch|network/i.test(e.message);function $r(e,n){var c,d;const s=`${cL(n)} could not be read.`;if(dL(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: try again in a moment."};if(!(e instanceof De))return{title:s,why:"Something went wrong in the console.",next:"Reload the page.",said:e instanceof Error?e.message:String(e)};const r=((d=(c=e.fields)==null?void 0:c[0])==null?void 0:d.message)??e.message,a=[e.code,e.requestId].filter(Boolean).join(" · "),i=(u,f)=>({title:s,why:u,next:f,said:r,code:a});return e.status===401?i("This browser is signed out.","Reload the page to sign in again."):e.status===403?i("The server doesn't allow this here.","Sign in as the server's owner, or open the console from the address the server printed."):e.status===404?i("This server doesn't have it.","Check the address, or open the list it belongs to."):e.status===412?i("Someone, or a run, changed it first.","Reload to see it as it is now."):e.status===429?i("Too many requests at once.","Wait a few seconds, then try again."):e.retryable||e.status===409||e.status===503?i("The server is busy.","Try again in a moment."):e.status>=500?i("The server hit a problem on its side.","Try again. If it keeps failing, the server's log says why."):i("The server turned the request down.","Try again, and if it keeps happening, the server's words below say why.")}function ns({problem:e,onRetry:n,className:s="m-8"}){return t.jsxs("section",{className:`flex gap-3 border bg-card px-4 py-4 md:px-5 ${s}`,role:"alert",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-prose font-semibold",children:e.title}),t.jsxs("p",{className:"mt-1 text-lead leading-relaxed",children:[e.why," ",e.next]}),(e.said||e.code)&&t.jsx("p",{className:"mt-2 break-words font-mono text-label text-muted-foreground",children:[e.said,e.code].filter(Boolean).join(" · ")}),n&&t.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})})]})]})}const Ra=[{path:"agent",label:"By the agent",fill:"fill-chart-agent",stroke:"stroke-chart-agent"},{path:"handed_back",label:"Handed back",fill:"fill-chart-handed-back",stroke:"stroke-chart-handed-back"},{path:"workflow",label:"Learned workflow",fill:"fill-chart-workflow",stroke:"stroke-chart-workflow"},{path:"replay",label:"Replay",fill:"fill-muted-foreground",stroke:"stroke-muted-foreground"}],Fu=e=>Ra.find(n=>n.path===e),uL=e=>e.filter(n=>n.total_usd!==null),fL=e=>Math.min(25,Math.max(3,Math.round(e/15)));function mL(e,n){const s=[];let r=0;return e.forEach((a,i)=>{r+=a.total_usd,i>=n&&(r-=e[i-n].total_usd),s.push(r/Math.min(i+1,n))}),s}function hL(e){if(!(e>0))return 1;const n=10**Math.floor(Math.log10(e));return[1,2,2.5,5,10].map(s=>s*n).find(s=>s>=e*(1-1e-9))}function pL(e){const n=10**Math.floor(Math.log10(e)+1e-9),s=Math.round(e/n*10)/10,r={1:.25,2:.5,2.5:.5,5:1,10:2.5}[s]??e/4,a=[];for(let i=0;i*r*n<=e*(1+1e-9);i++)a.push(Math.round(i*r*n*1e12)/1e12);return a}function gL(e,n,s){if(!e.length)return{top:1,above:0};const r=e.map(c=>c.total_usd).sort((c,d)=>c-d),a=r[Math.min(r.length-1,Math.floor(r.length*.95))],i=hL(Math.max(a,...n,s??0)*1.08);return{top:i,above:e.filter(c=>c.total_usd>i).length}}function xL(e,n,s=6){if(n<=e)return[e];const r=(n-e)/Math.max(1,s-1),a=10**Math.floor(Math.log10(r)),i=Math.max(1,[1,2,5,10].map(d=>d*a).find(d=>d>=r)),c=[];for(let d=Math.ceil(e/i)*i;d<=n;d+=i)c.push(d);return!c.includes(e)&&(c[0]??1/0)-e>i/2&&c.unshift(e),c}function vL(e,n){let s=0;for(let r=1;r<e.length;r++)Math.abs(e[r].n-n)<Math.abs(e[s].n-n)&&(s=r);return s}function Ro(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4).replace(/(\.\d\d\d?)0+$/,"$1").replace(/(\.\d\d)0$/,"$1")}`}function ar(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`}const yL=e=>e<=20?1:Math.max(5,Math.ceil(e/20));function bL(e,n){const s=[];for(let r=0;r<e.length;r+=n){const a=e.slice(r,r+n),i=Object.fromEntries(Ra.map(({path:c})=>[c,0]));for(const c of a)i[c.path]++;s.push({from:a[0].n,to:a.at(-1).n,runs:a.length,counts:i})}return s}function sx(e){const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`}const mf=(e,n)=>`${n?Math.round(e/n*100):0}%`,Uu=3,gc=5,wL=20,Tc={revision:"New revision",promote:"Promoted",hold:"Held",refit:"Refit",queued:"Queued",skipped:"Skipped"},Wv={revision:"R",promote:"P",hold:"H",refit:"F",queued:"Q",skipped:"S"},$2=e=>e.source==="refit"?"refit":e.decided==="replaying"?"revision":e.decided;function jL(e,n){if(!e.length)return[];const s=e.map(i=>Date.parse(i.started_at)),r=s[0],a=[];for(const i of n){const c=Date.parse(i.at);if(!Number.isFinite(c)||c<r-1)continue;const d=s.findIndex(g=>g>=c);if(d<0)continue;const u=$2(i),f=e[d].n;a.push({kind:u,n:f,at:i.at,workflow:i.workflow,digest:i.digest,reason:i.reason,record:i})}return a.sort((i,c)=>i.n-c.n)}const kL=e=>e.path!=="replay",_2=e=>{var n;return(n=e==null?void 0:e.summary.hand_backs)!=null&&n.ran?e.summary.hand_backs:null},Hv=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>r.workflow===n&&r.digest===s);function NL(e,{serving:n=null,refit:s,stopped:r=null}={}){if(s)return{word:"Refit",tone:"muted"};if(!e)return{word:"Not decided",tone:"muted"};const a=SL(e),i=a?{proof:a}:{};return e.decided==="promote"?e.digest!==n?{word:"Served",tone:"muted",...i}:e.digest===r?{word:"Stopped",tone:"warning",...i}:{word:"Serving",tone:CL(e)?"success":"plain",...i}:e.decided==="hold"?{word:"Held",tone:"warning",...i}:e.decided==="queued"?{word:"Queued",tone:"plain"}:e.decided==="skipped"?{word:"Skipped",tone:"muted"}:{word:"Replaying",tone:"active"}}function Wc(...e){const n=NL(...e);return{...n,text:n.proof?`${n.word} · ${n.proof}`:n.word}}const Bv=(e,n)=>{var s;return((s=e==null?void 0:e.workflows.find(r=>r.workflow===n&&r.state==="needs_revision"))==null?void 0:s.digest)??null},T2=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>{var a;return r.workflow===n&&r.source==="refit"&&r.decided==="promote"&&((a=r.refit)==null?void 0:a.from)===s});function SL(e){var r;const n=e.replay,s=n?` · ${n.n-n.handed_back} alone`:"";return e.source==="dry_run"?"not replayed":e.source==="refit"?n?`refit on ${n.n} ${n.n===1?"row":"rows"}${s}`:null:e.source!=="replay"||!n||e.decided!=="promote"&&e.decided!=="hold"?null:n.n?`replayed ${n.n}${(r=n.of)!=null&&r.length?`/${n.of.length}`:""}${s}`:"0 replays answered"}const CL=e=>{var n;return(e.source==="replay"||e.source==="refit")&&(((n=e.replay)==null?void 0:n.n)??0)>0},Ak=e=>`${Math.round(e*100)}%`,EL=e=>`${e>=0?"+":""}${Math.round(e*1e3)/10} pts`;function Aa(e){var r;const n=e.replay;return!n||!n.n?e.reason:`${e.source==="refit"?"Refit on":e.source==="graded"?"Checked on":"Replay on"} ${n.n} graded ${n.n===1?"input":"inputs"}: workflow ${Ak(n.wf_acc)} vs agent ${Ak(n.agent_acc)} (${EL(n.delta)}), ${n.handed_back} handed back${(r=n.outcomes)!=null&&r.skipped_write?`, ${n.outcomes.skipped_write} skipped`:""}`}function $L(e){const n=[];let s;try{s=e===null?null:JSON.parse(e)}catch{return n}const r=(a,i,c)=>{if(Array.isArray(a)){a.forEach((f,g)=>r(f,`${i}/${g}`,c));return}if(!a||typeof a!="object")return;const d=a,u=d.guard;typeof d.label=="string"&&u&&typeof u=="object"&&!Array.isArray(u)&&(u.signal==="self"||u.signal==="jev"||u.signal==="both")&&typeof u.threshold=="number"&&n.push({label:d.label,node:`${c}${d.label}`,path:i,signal:u.signal,threshold:u.threshold,fitted:!!u.fit});for(const[f,g]of Object.entries(d)){if(f==="guard")continue;const b=f==="workflow"&&d.node==="workflow"&&typeof d.label=="string";r(g,`${i}/${f.replace(/~/g,"~0").replace(/\//g,"~1")}`,b?`${c}${d.label}/`:c)}};return r(s,"",""),n}const _L={self:"its own confidence",jev:"Jev",both:"its own confidence and Jev"};function TL(e,n=.1){const s=Math.round(1/n),r=Array.from({length:s},(a,i)=>({from:i*n,to:(i+1)*n,right:0,wrong:0,ungraded:0}));for(const a of e){const i=a.p===null?0:Math.min(s-1,Math.max(0,Math.floor(a.p/n+1e-9))),c=r[i];a.correct===!0?c.right+=1:a.correct===!1?c.wrong+=1:c.ungraded+=1}return r}const RL=(e,n,s,r)=>e&&s?e.guards.find(a=>a.workflow===n&&a.digest===s&&a.node===r):void 0;function R2(e){const n=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!n)return null;const s=n[1].split(/\r?\n/).find(a=>/^compiled_into\s*:/.test(a)),r=s==null?void 0:s.replace(/^compiled_into\s*:\s*/,"").trim().replace(/^["']|["']$/g,"");return r||null}function AL(e){var M,R;const{notes:n,compiledNotes:s,runs:r,workflows:a,cost:i,promotions:c,serving:d,loop:u,mode:f="full",execution:g="hosted"}=e,b=f==="notes",x=a.filter(P=>P.status==="active"),h=u==null?void 0:u.compiles.find(P=>P.digest===null&&(P.draft_errors.length>0||P.attempts.length>0)),v=u==null?void 0:u.compiles.find(P=>P.digest!==null),y=i==null?void 0:i.summary,j=_2(i),k=c.at(-1),E=k?d.find(P=>P.workflow===k.workflow):void 0,S=(E==null?void 0:E.digest)??null,N=E!=null&&E.replaying?`revision ${E.replaying.slice(0,7)} replays on graded inputs before it serves`:(k==null?void 0:k.decided)==="hold"&&k.digest!==S?`revision ${k.digest.slice(0,7)} was held: ${Aa(k)}`:null,_=S!==null&&k?Bv(i,k.workflow)===S:!1,$=_?`revision ${S.slice(0,7)} no longer runs first: it cost as much as the agent by hand; its next run asks the agent for a new version`:null,O=$?N?`${$}; ${N}`:$:S&&N?`revision ${S.slice(0,7)} serves; ${N}`:null,A=[];if(A.push({key:"notes",title:"Learned",value:n===1?"1 note":`${n} notes`,detail:s?`${s} compiled into a workflow`:n?"kept from its runs, read by every later run":"none yet: a run keeps what it learns at its end",state:n?"done":"now"}),g==="native")return A.push({key:"compiled",title:"Learning",value:"Notes and skills",detail:"Native runs receive accepted notes and skills; learned workflows are unavailable.",state:"later"}),A;if(x.length||v&&v.digest){const P=((M=x[0])==null?void 0:M.name)??(v==null?void 0:v.workflow)??"a workflow";A.push({key:"compiled",title:"Compiled",value:P,detail:v?`from ${v.from_notes.length} ${v.from_notes.length===1?"note":"notes"}, ${v.attempts.length} ${v.attempts.length===1?"attempt":"attempts"}`:"a learned workflow",state:"done"})}else h?A.push({key:"compiled",title:"Compile",value:"Draft failed",detail:`${h.attempts.length} ${h.attempts.length===1?"attempt":"attempts"}, the checks refused it: it tries again on a later run`,state:"warn"}):b?A.push({key:"compiled",title:"Compile",value:"Notes only",detail:`this agent learns notes only: no workflow compiles from them. Full learning compiles one at ${Uu} notes or ${gc} runs`,state:"later"}):A.push({key:"compiled",title:"Compile",value:"Not yet",detail:g==="sdk"?`With workflow learning and backend tool bindings, compilation starts at ${Uu} notes or ${gc} runs`:`${n} of ${Uu} notes, ${Math.min(r,gc)} of ${gc} runs: a workflow compiles at ${Uu} notes or ${gc} runs`,state:n||r?"now":"later"});if(g==="sdk")return b||A.push({key:"took_over",title:"Use workflow",value:"Backend decides",detail:"Your backend keeps launching each run. The SDK can call accepted workflows through MCP with explicitly bound tools.",state:x.length?"now":"later"}),A;if(y!=null&&y.takeover)A.push({key:"took_over",title:"Took over",value:`Run ${y.takeover.n}`,detail:O??((R=k==null?void 0:k.replay)!=null&&R.n?Aa(k):k?k.reason:"the first run a learned workflow finished alone"),state:_||(k==null?void 0:k.decided)==="hold"&&!S?"warn":"done"});else if(k)if(O)A.push({key:"took_over",title:"Take over",value:Wc(Hv(c,k.workflow,S)??k,{serving:S,stopped:_?S:null}).word,detail:O,state:_?"warn":"done"});else{const P=Wc(k,{serving:S});A.push({key:"took_over",title:"Take over",value:P.word,detail:k.decided==="replaying"?"replaying on graded inputs before it serves; the agent takes the runs meanwhile":Aa(k),state:k.decided==="hold"?"warn":"now"})}else b||A.push({key:"took_over",title:"Take over",value:"Not yet",detail:"a compiled workflow replays on graded runs, then serves first when it does as well as the agent",state:"later"});if(y!=null&&y.takeover&&y.withheld)A.push({key:"cheaper",title:"Cheaper",value:"No ratio yet",detail:`${A2(y.withheld)}: ${O2}`,state:"now"});else if(y!=null&&y.after&&y.before){const P=`${mg(y.before.mean_usd)} a run by the agent, ${mg(y.after.mean_usd)} all-in over the ${y.after.runs===1?"1 run":`${y.after.runs} runs`} it served since`,D=y.times_cheaper;D!==null&&D>1?A.push({key:"cheaper",title:"Cheaper",...OL(y,D),state:"done"}):D!==null?A.push({key:"cheaper",title:"Cheaper",value:D<1?y.before.mean_usd>0?`Not cheaper yet: ${ML(y.after.mean_usd/y.before.mean_usd)} the cost`:"Not cheaper yet":"Same cost",detail:P,state:"now"}):A.push({key:"cheaper",title:"Cheaper",value:`${y.after.runs} served ${y.after.runs===1?"run":"runs"} so far`,detail:`${P}; how many times cheaper shows after ${wL} runs`,state:"now"})}else y!=null&&y.takeover&&y.after_state==="cost_unknown"?A.push({key:"cheaper",title:"Cheaper",value:"No cost yet",detail:"no served run's cost is known yet",state:"now"}):y!=null&&y.after?A.push({key:"cheaper",title:"Cheaper",value:`${y.after.runs} served ${y.after.runs===1?"run":"runs"} so far`,detail:`${mg(y.after.mean_usd)} all-in over the ${y.after.runs===1?"1 run":`${y.after.runs} runs`} it served; no priced agent runs before takeover to compare with`,state:"now"}):b||A.push({key:"cheaper",title:"Cheaper",value:"Not yet",detail:"no served runs yet: once a workflow takes over, the all-in cost of the runs it serves against before (replays are checks, not served runs)",state:"later"});const L=((u==null?void 0:u.guards)??[]).filter(P=>P.runs>0&&P.threshold!==null).sort((P,D)=>D.escalated/D.runs-P.escalated/P.runs)[0];if(j||L){const P=j?`${Math.round(j.back/j.ran*100)}% handed back`:"no run since";A.push({key:"unsure",title:"Unsure",value:P,detail:L?`most at "${L.node}": ${L.escalated} of ${L.runs} under ${L.threshold.toFixed(2)}`:`of ${j.ran} runs it ran first`,state:j&&j.back/j.ran>.25?"warn":"watch"})}return A}function A2(e){const n=s=>`${s} ${s===1?"run's":"runs'"} cost`;return e.unknown?`${n(e.unknown)} unknown${e.at_most?`, ${e.at_most} known only as at most`:""}`:`${n(e.at_most)} known only as at most`}const O2="how many times cheaper shows once every run's cost is known";function OL(e,n){const s=n>=1.5?`${Math.round(n)}x`:`${n.toFixed(1)}x`,r=e.replay,a=r?`workflow ${Math.round(r.workflow_pct)}% vs agent ${Math.round(r.agent_pct)}% on ${r.n} inputs`:"";if(r!=null&&r.cleared){const i=e.hand_backs?` · served ${e.hand_backs.ran} ${e.hand_backs.ran===1?"run":"runs"}, handed back ${e.hand_backs.back}`:"";return{value:`About ${s} cheaper at the same accuracy`,detail:`Replay: ${a}${i}`}}return{value:`${s} cheaper`,detail:`accuracy not claimed: ${r?`its replay was below the bar (${a})`:"no replay yet"}`}}const mg=e=>e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`,ML=e=>{const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`},PL=1e3,M2="Turn learning on and run the same job about 20 times: each run's cost shows here, and where a learned workflow takes the job over, the line falls.",P2=e=>e==="native"?"Native run costs include reported model usage and AgentRun learning. Compare repeated jobs; accepted notes and skills do not enable workflow takeover.":e==="sdk"?"SDK run costs include reported backend usage and AgentRun learning. Your backend keeps launching jobs and binds the tools an accepted workflow can use.":M2,rx=e=>`${e} served ${e===1?"run":"runs"}`;function Ok({v2:e,agentId:n,on:s,quiet:r=!1,promotions:a,onCost:i,execution:c="hosted"}){const[d,u]=p.useState(null),[f,g]=p.useState([]),b=a??f,x=p.useRef(i);x.current=i;const[h,v]=p.useState(null),[y,j]=p.useState(0);return p.useEffect(()=>{let k=!0;return v(null),Promise.resolve().then(()=>e.learningCost(n,PL)).then(E=>{var S;k&&(u(E),(S=x.current)==null||S.call(x,E))},E=>{k&&v(E??new Error("unknown"))}),a||Promise.resolve().then(()=>e.learningPromotions(n)).then(E=>{k&&g(E.promotions)},()=>{}),()=>{k=!1}},[e,n,y,!a]),r&&(!d||d.runs.filter(k=>k.total_usd!==null).length<2)?null:h&&!d?t.jsx(ns,{problem:$r(h,"the cost per run"),onRetry:()=>j(k=>k+1),className:""}):d?t.jsx(IL,{data:d,on:s,promotions:b,execution:c}):t.jsx(pn,{className:"h-[320px] w-full"})}const Ot={top:30,right:16,bottom:30,left:60},Wu=17,LL=16,Br=260;function IL({data:e,on:n,width:s,promotions:r=[],execution:a="hosted"}){var _e;const i=p.useMemo(()=>uL(e.runs),[e.runs]),c=p.useMemo(()=>i.filter(kL),[i]),d=fL(c.length),u=p.useMemo(()=>mL(c,d),[c,d]),f=p.useMemo(()=>jL(e.runs,r),[e.runs,r]),{summary:g}=e,b=_2(e),x=p.useRef(null),[h,v]=p.useState(s??720);p.useEffect(()=>{const re=x.current;if(s||!re||typeof ResizeObserver>"u")return;const Re=new ResizeObserver(([Ze])=>{Ze&&Ze.contentRect.width>0&&v(Ze.contentRect.width)});return Re.observe(re),()=>Re.disconnect()},[s]);const[y,j]=p.useState(null),[k,E]=p.useState(null),S=Ra.map(re=>({...re,runs:e.runs.filter(Re=>Re.path===re.path).length})),N=[e.total_runs>e.runs.length?`The latest ${e.runs.length.toLocaleString("en-US")} of ${e.total_runs.toLocaleString("en-US")} runs.`:null,e.unknown_cost_runs?`${e.unknown_cost_runs===1?"1 run's":`${e.unknown_cost_runs} runs'`} cost is not known: left out.`:null,e.unknown_path_runs?`${e.unknown_path_runs===1?"1 run's":`${e.unknown_path_runs} runs'`} path and cost are not known: left out.`:null,...e.workflows.filter(re=>re.state==="needs_revision"&&re.served&&re.by_hand).map(re=>`${re.workflow} no longer runs first: ${ar(re.served.mean_usd)} a run all-in over its newest ${re.served.runs} priced runs, at or over ${ar(re.by_hand.mean_usd)} a run by hand.${re.unknown_cost_runs?` ${re.unknown_cost_runs===1?"1 run":`${re.unknown_cost_runs} runs`} of unknown cost left out.`:""} Its next run asks the agent for a new version, which runs first again.`)].filter(re=>!!re);if(i.length<2)return t.jsxs(Lk,{title:"Cost per run",headline:null,children:[t.jsxs("div",{className:"px-4 py-8 text-center",role:"status",children:[t.jsx("p",{className:"font-mono text-body",children:i.length?"One run so far.":"No run with a known cost yet."}),t.jsx("p",{className:"mx-auto mt-1 max-w-prose text-body text-muted-foreground",children:P2(a)}),N.map(re=>t.jsx("p",{className:"mx-auto mt-1 max-w-prose text-small text-muted-foreground",children:re},re))]}),e.runs.length>0&&(()=>{var Ze;const re=Math.max(300,h),Re=(re-Ot.left-Ot.right)/(e.runs.at(-1).n-e.runs[0].n+1);return t.jsx("figure",{ref:x,className:"px-4 pb-3",children:t.jsx(Pk,{runs:e.runs,width:re,x:at=>Ot.left+(at-e.runs[0].n+.5)*Re,step:Re,plot:[Ot.left,re-Ot.right],takeover:((Ze=g.takeover)==null?void 0:Ze.n)??null})})})()]});const _=Math.max(300,h),$=_-Ot.left-Ot.right,O=e.runs[0].n,A=e.runs.at(-1).n,L=$/(A-O+1),M=re=>Ot.left+(re-O+.5)*L,R=g.before,{top:P,above:D}=gL(i,u,(R==null?void 0:R.mean_usd)??null),W=[],Y=[];for(const re of f){const Re=M(re.n)-L/2;let Ze=Y.findIndex(at=>Re-at>=LL);Ze<0?(Ze=Y.length,Y.push(Re)):Y[Ze]=Re,W.push(Ze)}const H=Y.length?Y.length*Wu+8:0,q=Ot.top+H,F=re=>q+Br-Math.min(re,P)/P*Br,G=pL(P),U=xL(O,A,_<520?5:7),z=g.takeover&&g.takeover.n>=O?g.takeover:null,Q=g.takeover?Math.max(g.takeover.n,O):null,K=c.map((re,Re)=>`${Re?"L":"M"}${M(re.n).toFixed(1)},${F(u[Re]).toFixed(1)}`).join(""),Z=y===null?null:i[y],de=g.times_cheaper!==null?`${sx(g.times_cheaper)} cheaper`:null,se=b?`${mf(b.back,b.ran)} handed back since`:null,ue=g.after?`${ar(g.after.mean_usd)} all-in over ${rx(g.after.runs)} after`:g.takeover&&g.after_state==="cost_unknown"?"no served run's cost known yet":null,xe=g.before&&ue?`${ar(g.before.mean_usd)} a run before takeover, ${ue}${de?`: ${de}`:""}${se?` · ${se}`:""}`:null,$e=e.unknown_cost_runs+e.unknown_path_runs,ge=re=>{const Re=re.currentTarget.getBoundingClientRect(),Ze=(re.clientX-Re.left)/Re.width*_,at=(re.clientY-Re.top)/Re.height*(q+Br+Ot.bottom);if(f.length&&at<q-2){j(null);const pt=f.map((Ee,Je)=>({i:Je,d:Math.abs(M(Ee.n)-L/2-Ze)+Math.abs(Ot.top+W[Je]*Wu+8-at)})).sort((Ee,Je)=>Ee.d-Je.d)[0];E(pt&&pt.d<=12?pt.i:null);return}E(null),j(vL(i,O+(Ze-Ot.left)/L-.5))},fe=re=>{const Ze={ArrowRight:at=>at+1,ArrowLeft:at=>at-1,Home:()=>0,End:()=>i.length-1,PageUp:at=>at+10,PageDown:at=>at-10}[re.key];if(!Ze){re.key==="Escape"&&j(null);return}re.preventDefault(),j(at=>Math.min(i.length-1,Math.max(0,Ze(at??(re.key==="ArrowLeft"?i.length:-1)))))},me=re=>[`Run ${re.n}`,`${Ro(re.total_usd)} all-in${re.learning_usd?` (${Ro(re.cost_usd??0)} the run, ${Ro(re.learning_usd)} learning)`:""}`,`${Fu(re.path).label}${re.workflow?`: ${re.workflow}`:""}`,re.learned_revision?`Learned revision ${re.learned_revision.slice(0,7)}`:"Nothing learned yet",...re.path==="replay"?["A replay: learning's spend, out of the line"]:[]],je=k===null?null:f[k]??null,Me=z?M(z.n)>Ot.left+$*.62:!1;return t.jsxs(Lk,{title:"Cost per run",headline:xe,unknown:$e,children:[t.jsxs("figure",{ref:x,className:"px-4 pb-2 pt-3",children:[t.jsxs("figcaption",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-small text-muted-foreground",children:[S.filter(re=>re.runs>0).map(re=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"10",height:"10","aria-hidden":!0,children:t.jsx("circle",{cx:"5",cy:"5",r:"4",className:re.fill})}),re.label," ",t.jsx("span",{className:"text-foreground",children:re.runs})]},re.path)),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-foreground",strokeWidth:2})}),"Rolling mean of ",d," runs"]}),R&&t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"18",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M1,5H17",className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"4 3"})}),"Before takeover, the agent alone"]}),Object.keys(Tc).filter(re=>f.some(Re=>Re.kind===re)).map(re=>t.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":`marker-key-${re}`,children:[t.jsx("svg",{width:"14",height:"14","aria-hidden":!0,children:t.jsx(Ik,{x:0,y:0,kind:re})}),Tc[re]," ",t.jsx("span",{className:"text-foreground",children:f.filter(Re=>Re.kind===re).length})]},re))]}),t.jsxs("div",{className:"relative shrink-0",tabIndex:0,onKeyDown:fe,onBlur:()=>j(null),"aria-label":`Cost per run, runs ${O} to ${A}. ${xe??""} Arrow keys step through the runs.`,children:[t.jsxs("svg",{width:_,height:q+Br+Ot.bottom,className:"block select-none font-mono",onPointerMove:ge,onPointerLeave:()=>{j(null),E(null)},"aria-hidden":!0,children:[G.map(re=>t.jsxs("g",{children:[t.jsx("path",{d:`M${Ot.left},${F(re)}H${Ot.left+$}`,className:re===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),t.jsx("text",{x:Ot.left-8,y:F(re),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:Ro(re)})]},re)),U.map(re=>t.jsx("text",{x:M(re),y:q+Br+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:re},re)),t.jsx("text",{x:Ot.left,y:H?Ot.top-10:q-16,className:"caps fill-muted-foreground text-label",children:"$ a run, all-in"}),t.jsx("text",{x:Ot.left-8,y:q+Br+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),f.map((re,Re)=>t.jsxs("g",{"data-testid":`marker-${re.kind}`,opacity:k===null||k===Re?1:.55,children:[t.jsx("path",{d:`M${M(re.n)-L/2},${Ot.top+W[Re]*Wu+15}V${q+Br}`,className:L2[re.kind],strokeWidth:1,strokeDasharray:"2 3"}),t.jsx(Ik,{x:M(re.n)-L/2-7,y:Ot.top+W[Re]*Wu+1,kind:re.kind})]},`${re.kind}:${re.n}:${re.workflow}:${re.digest}:${re.at}`)),i.map((re,Re)=>re.path==="replay"?t.jsx("circle",{cx:M(re.n),cy:F(re.total_usd),r:Re===y?0:2.5,className:"fill-none stroke-muted-foreground",strokeWidth:1.25},re.run_id):t.jsx("circle",{cx:M(re.n),cy:F(re.total_usd),r:Re===y?0:3,className:oe(Fu(re.path).fill),fillOpacity:.65},re.run_id)),R&&t.jsxs("g",{children:[t.jsx("path",{d:`M${Ot.left},${F(R.mean_usd)}H${Ot.left+$}`,className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"6 4"}),t.jsxs(hg,{x:Ot.left+$-4,y:F(R.mean_usd)-6,anchor:"end",children:["Before takeover ",ar(R.mean_usd)]})]}),z&&t.jsxs("g",{children:[t.jsx("path",{d:`M${M(z.n)},${q-4}V${q+Br}`,className:"stroke-chart-workflow",strokeWidth:1.5}),t.jsxs(hg,{x:M(z.n)+(Me?-6:6),y:q+6,anchor:Me?"end":"start",children:["Workflow took over, run ",z.n]})]}),Q!==null&&g.after&&t.jsxs("g",{children:[t.jsx("path",{d:`M${M(Q)},${F(g.after.mean_usd)}H${Ot.left+$}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),t.jsxs(hg,{x:Ot.left+$-4,y:F(g.after.mean_usd)-8,anchor:"end",strong:!0,children:[_<520?"Served":`Served after takeover (${rx(g.after.runs)})`," ",ar(g.after.mean_usd),de?` · ${de}`:""]})]}),t.jsx("path",{d:K,fill:"none",className:"stroke-foreground",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),Z&&t.jsxs("g",{children:[t.jsx("path",{d:`M${M(Z.n)},${q}V${q+Br}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("circle",{cx:M(Z.n),cy:F(Z.total_usd),r:5,className:oe(Fu(Z.path).fill,"stroke-card"),strokeWidth:2})]})]}),je&&!Z&&t.jsx("div",{className:oe("pointer-events-none absolute z-raised max-w-[22rem] border bg-card px-2 py-1 font-mono text-label shadow-float",M(je.n)>_*.6&&"-translate-x-full"),"data-testid":"marker-tip",style:{left:M(je.n)>_*.6?M(je.n)-L/2-12:M(je.n)-L/2+12,top:Ot.top},children:zk(je).map((re,Re)=>t.jsx("span",{className:oe("block",Re===0?"font-semibold":"text-muted-foreground"),children:re},Re))}),Z&&t.jsxs("div",{className:oe("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",M(Z.n)>_*.6&&"-translate-x-full"),style:{left:M(Z.n)>_*.6?M(Z.n)-10:M(Z.n)+10,top:q},children:[me(Z).map((re,Re)=>t.jsx("span",{className:oe("block",Re===0?"font-semibold":"text-muted-foreground"),children:re},re)),t.jsx("span",{className:"block text-muted-foreground",children:ht(Z.started_at)})]}),t.jsx("p",{className:"sr-only","aria-live":"polite",children:Z?me(Z).join(", "):""}),f.length>0&&t.jsx("p",{className:"sr-only",children:`Markers: ${f.map(re=>zk(re).join(", ")).join(". ")}.`})]}),t.jsx(Pk,{runs:e.runs,width:_,x:M,step:L,plot:[Ot.left,Ot.left+$],takeover:((_e=g.takeover)==null?void 0:_e.n)??null}),t.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Each dot is a run: its own cost plus what learning spent for it (the look-back and the grade). The line is the mean of the last ",d," runs",i.some(re=>re.path==="replay")?", replay runs (hollow) left out":"",".",D?` ${D===1?"1 run costs":`${D} runs cost`} more than ${Ro(P)} and ${D===1?"is":"are"} drawn at the top.`:"",g.before?" The dashed line is what a run cost the agent before a learned workflow took over, learning left out; after it, every run counts learning in, so the drop never flatters learning.":""]}),[...N,...FL(e,n,a)].map(re=>t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:re},re))]}),t.jsxs("details",{className:"border-t px-4 py-2",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Table"}),t.jsx("div",{className:"max-h-96 overflow-auto",children:t.jsxs("table",{className:"mt-2 w-full border-collapse font-mono text-small",children:[t.jsx("thead",{className:"sticky top-0 z-sticky bg-card",children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Started","Path","Revision","Run $","Learning $","All-in $"].map(re=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:re},re))})}),t.jsx("tbody",{children:e.runs.map(re=>{var Re;return t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:re.n}),t.jsx("td",{className:"pr-4",children:ht(re.started_at)}),t.jsxs("td",{className:"pr-4",children:[Fu(re.path).label,re.workflow?`: ${re.workflow}`:""]}),t.jsx("td",{className:"pr-4",children:((Re=re.learned_revision)==null?void 0:Re.slice(0,7))??"-"}),t.jsx("td",{className:"pr-4",children:re.cost_usd===null?"unknown":Ro(re.cost_usd)}),t.jsx("td",{className:"pr-4",children:re.learning_usd===null?"unknown":Ro(re.learning_usd)}),t.jsx("td",{className:"pr-4",children:re.total_usd===null?"unknown":Ro(re.total_usd)})]},re.run_id)})})]})}),f.length>0&&t.jsxs("table",{className:"mt-3 w-full border-collapse font-mono text-small","data-testid":"marker-table",children:[t.jsx("thead",{children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Run","Marker","Workflow","Revision","Numbers"].map(re=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:re},re))})}),t.jsx("tbody",{children:f.map(re=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:re.n}),t.jsxs("td",{className:"pr-4",children:[Wv[re.kind]," ",Tc[re.kind]]}),t.jsx("td",{className:"pr-4",children:re.workflow}),t.jsx("td",{className:"pr-4",children:re.digest.slice(0,7)}),t.jsx("td",{className:"pr-4 font-sans",children:Aa(re.record)})]},`${re.kind}:${re.n}:${re.workflow}:${re.digest}:${re.at}`))})]}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:["As CSV: ",t.jsxs("code",{className:"font-mono",children:["agentrun learning cost ",e.agent," --format csv"]})]})]})]})}const zL=64,Ao={top:4,bottom:6},DL=[...Ra].reverse(),Mk=e=>e.from===e.to?`Run ${e.from}`:`Runs ${e.from} to ${e.to}`;function Pk({runs:e,width:n,x:s,step:r,plot:a,takeover:i}){const c=zL,d=yL(e.length),u=p.useMemo(()=>bL(e,d),[e,d]),[f,g]=p.useState(null);if(!u.length)return null;const[b,x]=a,h=A=>Math.min(x,Math.max(b,A)),v=A=>({from:h(s(A.from)-r/2),to:h(s(A.to)+r/2)}),y=A=>Ao.top+c*(1-A),j=u.at(-1),k=A=>{const{from:L,to:M}=v(A),R=M-L>4?1:0;return{x0:L+R,w:Math.max(1,M-L-2*R)}},E=A=>`${Mk(A)}: ${Ra.filter(L=>A.counts[L.path]).map(L=>`${L.label.toLowerCase()} ${A.counts[L.path]}`).join(", ")}`,S=u.some(A=>A.counts.workflow)?`${mf(j.counts.workflow,j.runs)} by the learned workflow`:Ra.filter(A=>j.counts[A.path]).map(A=>`${mf(j.counts[A.path],j.runs)} ${A.label.toLowerCase()}`).join(", "),N=`Last ${j.runs===1?"run":`${j.runs} runs`}: ${S}`,_=f===null?null:u[f],$=_?k(_).x0>n/2:!1,O=i!==null&&s(i)>=b&&s(i)<=x;return t.jsxs("div",{className:"relative min-w-0",style:{width:n},"data-testid":"execution-mix",children:[t.jsxs("div",{className:"font-mono text-label",style:{paddingLeft:b},children:[t.jsxs("span",{className:"caps block text-muted-foreground",children:["Who finished each run",d>1?`, by ${d}`:""]}),t.jsx("span",{className:"block text-foreground",children:N})]}),t.jsxs("svg",{width:n,height:Ao.top+c+Ao.bottom,className:"mt-2 block select-none font-mono","aria-hidden":!0,onPointerLeave:()=>g(null),children:[[0,.5,1].map(A=>t.jsxs("text",{x:b-6,y:y(A),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:[A*100,"%"]},A)),u.map((A,L)=>{const{x0:M,w:R}=k(A);let P=Ao.top+c;return t.jsxs("g",{onPointerEnter:()=>g(L),opacity:f===null||f===L?1:.55,children:[t.jsx("rect",{x:v(A).from,y:Ao.top,width:Math.max(1,v(A).to-v(A).from),height:c,className:"fill-card",fillOpacity:0}),DL.map(D=>{const W=A.counts[D.path]/A.runs*c;if(!W)return null;P-=W;const Y=P>Ao.top+.5?Math.min(2,W):0;return t.jsx("rect",{x:M,y:P+Y,width:R,height:W-Y,className:D.fill,fillOpacity:.8},D.path)})]},A.from)}),O&&t.jsx("g",{"data-testid":"mix-takeover",children:t.jsx("path",{d:`M${s(i)-r/2},${Ao.top}V${Ao.top+c}`,className:"stroke-chart-workflow",strokeWidth:1.5})})]}),_&&t.jsxs("div",{className:oe("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",$&&"-translate-x-full"),style:{left:$?k(_).x0-6:k(_).x0+k(_).w+6,top:40},children:[t.jsx("span",{className:"block font-semibold",children:Mk(_)}),Ra.filter(A=>_.counts[A.path]).map(A=>t.jsxs("span",{className:"block text-muted-foreground",children:[A.label," ",_.counts[A.path]," (",mf(_.counts[A.path],_.runs),")"]},A.path))]}),t.jsx("p",{className:"sr-only",children:`Execution mix in blocks of ${d} runs. ${u.map(E).join(". ")}. ${N}.`})]})}function FL(e,n,s){const r=e.summary;return!r.takeover&&s!=="hosted"?[P2(s)]:r.takeover?r.withheld?[`${A2(r.withheld)}: ${O2}.`]:r.after_state==="cost_unknown"?["No run the workflow served has a known cost yet: a replay is a check, never a served run."]:r.times_cheaper===null&&r.after?[`${rx(r.after.runs)} since the workflow took over: how many times cheaper it is shows after 20.`]:[]:[n?"No learned workflow has finished a run alone yet. Keep running the same job: once one does, a marker shows where, and the level after it.":M2]}function Lk({title:e,headline:n,unknown:s=0,children:r}){return t.jsxs("section",{className:"min-w-0 border","aria-label":e,"data-testid":"cost-per-run",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[t.jsx("h3",{className:"caps text-small font-semibold",children:e}),n&&t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:n}),s>0&&t.jsx(Ne,{tone:"muted",className:"self-center",title:"Runs whose path or cost the server can't tell: left out of the chart, never drawn at $0.",children:s===1?"1 run unknown":`${s} runs unknown`})]}),r]})}const L2={promote:"stroke-chart-workflow",hold:"stroke-warning",refit:"stroke-foreground",revision:"stroke-muted-foreground",queued:"stroke-muted-foreground",skipped:"stroke-muted-foreground"},UL={promote:"fill-foreground",hold:"fill-warning-text",refit:"fill-foreground",revision:"fill-muted-foreground",queued:"fill-muted-foreground",skipped:"fill-muted-foreground"};function Ik({x:e,y:n,kind:s}){return t.jsxs("g",{children:[t.jsx("rect",{x:e+.75,y:n+.75,width:12.5,height:12.5,className:oe("fill-card",L2[s]),strokeWidth:1.5,rx:2}),t.jsx("text",{x:e+7,y:n+7,dy:"0.35em",textAnchor:"middle",className:oe("text-micro font-semibold",UL[s]),children:Wv[s]})]})}const zk=e=>[`${Tc[e.kind]} · run ${e.n}`,`${e.workflow} ${e.digest.slice(0,7)}`,Aa(e.record),ht(e.at)];function hg({x:e,y:n,anchor:s="start",strong:r=!1,children:a}){return t.jsx("text",{x:e,y:n,textAnchor:s,className:oe("stroke-card text-label [paint-order:stroke]",r?"fill-foreground font-semibold":"fill-muted-foreground"),strokeWidth:4,strokeLinejoin:"round",children:a})}function WL(e){const n=[];let s=[],r="",a=!1;const i=e.replace(/^/,"");for(let c=0;c<i.length;c++){const d=i[c];a?d==='"'?i[c+1]==='"'?(r+='"',c++):a=!1:r+=d:d==='"'&&r===""?a=!0:d===","?(s.push(r),r=""):d===`
|
|
625
|
+
`||d==="\r"?(d==="\r"&&i[c+1]===`
|
|
626
|
+
`&&c++,s.push(r),r="",s.some(u=>u.trim()!=="")&&n.push(s),s=[]):r+=d}return a?null:(s.push(r),s.some(c=>c.trim()!=="")&&n.push(s),n)}function HL(e){var i;const n=WL(e);if(!n)return{error:"The file ends inside a quoted cell: a quote is not closed."};const s=(i=n.shift())==null?void 0:i.map(c=>c.trim());if(!s||!n.length)return{error:"The file needs a header line and at least one row."};if(s.some(c=>c===""))return{error:"A column in the header line has no name."};const r=s.find((c,d)=>s.indexOf(c)!==d);if(r!==void 0)return{error:`The column ${r} is named twice in the header line.`};const a=n.findIndex(c=>c.length!==s.length);return a>=0?{error:`Row ${a+1} has ${n[a].length} cells, and the header line has ${s.length}.`}:{columns:s,rows:n.map(c=>Object.fromEntries(s.map((d,u)=>[d,c[u]])))}}const Dk=500,BL=5,ox=e=>e.status==="running";function GL(e){return e.status==="cancelled"?`Cancelled after ${e.finished} of ${e.total} rows.`:e.status!=="stopped"?null:e.stopped==="cap"?`Stopped after ${e.finished} of ${e.total} rows: what is left of the cap does not cover another row.`:e.stopped==="cost_unknown"?`Stopped after ${e.finished} of ${e.total} rows: a row's cost is not known, and the cap is never guessed at.`:`Stopped after ${e.finished} of ${e.total} rows${e.error?`: ${e.error}`:"."}`}const qL={agent:"by hand",handed_back:"handed back",workflow:"workflow"},KL=2e3;function VL({v2:e,agentId:n,onFinished:s,pollMs:r=KL}){const[a,i]=p.useState(void 0),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,b]=p.useState(0),x=p.useRef(!1),h=p.useRef(s);if(h.current=s,p.useEffect(()=>{let y=!0,j;const k=async E=>{var S,N;try{const _=E??((S=(await e.learningBatches(n)).batches[0])==null?void 0:S.id),$=_?await e.learningBatch(n,_):null;if(!y)return;i($),d(null),$&&ox($)?(x.current=!0,j=setTimeout(()=>void k($.id),r)):$&&x.current&&(x.current=!1,(N=h.current)==null||N.call(h))}catch(_){if(!y)return;d(_??new Error("unknown")),j=setTimeout(()=>void k(E),r*2)}};return k(),()=>{y=!1,clearTimeout(j)}},[e,n,r,g]),a===void 0&&!c)return t.jsx(pn,{className:"h-24 w-full"});if(a===void 0)return t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("p",{className:"font-mono text-small text-muted-foreground",role:"status",children:["Learn from a CSV is not available right now: ",c instanceof Error?c.message:String(c),"."]}),t.jsx(B,{size:"sm",variant:"outline",onClick:()=>{d(null),b(y=>y+1)},children:"Read again"})]});const v=a&&ox(a);return t.jsxs("section",{className:"space-y-4","aria-label":"Learn from a CSV",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Learn from a CSV"}),!v&&!u&&t.jsx(B,{size:"sm",onClick:()=>f(!0),children:a?"Learn from another CSV":"Learn from a CSV"})]}),!!c&&t.jsxs("p",{className:"font-mono text-small text-warning-text",role:"status",children:["The batch was not read again: ",c instanceof Error?c.message:String(c),". Trying again."]}),u&&!v&&t.jsx(YL,{v2:e,agentId:n,onStarted:y=>{x.current=!0,i(y),f(!1),b(j=>j+1)},onCancel:()=>f(!1)}),a&&!u&&t.jsx(XL,{v2:e,agentId:n,batch:a,onBatch:i}),!a&&!u&&t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Give it rows you already have answers for. It runs on each in order, learning as it goes, and is told the right answer after each one."})]})}function YL({v2:e,agentId:n,onStarted:s,onCancel:r}){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[g,b]=p.useState(""),[x,h]=p.useState(String(BL)),[v,y]=p.useState(!1),[j,k]=p.useState(null),E=async $=>{var M;const O=(M=$.target.files)==null?void 0:M[0];if(!O)return;k(null);const A=HL(await O.text());if("error"in A){i(null),d(A.error);return}d(A.rows.length>Dk?`A batch takes at most ${Dk} rows: this file has ${A.rows.length}.`:null),i({name:O.name,columns:A.columns,rows:A.rows});const L=A.columns.at(-1);b(L),f(A.columns.filter(R=>R!==L))},S=Number(x),N=!!a&&!c&&u.length>0&&!!g&&!u.includes(g)&&Number.isFinite(S)&&S>0,_=async()=>{var $,O;if(!(!a||!N)){y(!0),k(null);try{s(await e.startLearningBatch(n,{inputs:u,answer:g,rows:a.rows,max_cost_usd:S}))}catch(A){k(A instanceof De?((O=($=A.fields)==null?void 0:$[0])==null?void 0:O.message)??A.message:A instanceof Error?A.message:String(A)),y(!1)}}};return t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsx(jt,{label:"CSV file",note:"A header line, then one row for each thing to learn from. The file is read here; its rows go to the server.",children:t.jsx("input",{type:"file",accept:".csv,text/csv",onChange:$=>void E($),"aria-label":"CSV file",className:"block w-full font-mono text-body file:mr-3 file:border file:border-input file:bg-background file:px-3 file:py-1.5 file:font-mono"})}),c&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:c}),a&&!("error"in a)&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[a.name,": ",a.rows.length," rows, ",a.columns.length," columns"]}),t.jsx(jt,{label:"The agent is given",group:!0,note:"The columns each run reads. The answer column is never one of them.",children:t.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:a.columns.map($=>t.jsx(c5,{label:$,checked:u.includes($),disabled:$===g,onChange:O=>f(A=>O.target.checked?a.columns.filter(L=>A.includes(L)||L===$):A.filter(L=>L!==$))},$))})}),t.jsx(jt,{label:"The answer column",note:"What the agent is told after each answer: the reference it should have given.",children:t.jsx(Rt,{label:"The answer column",value:g,onChange:$=>{b($),f(O=>O.filter(A=>A!==$))},options:a.columns.map($=>({value:$,label:$}))})}),t.jsx(jt,{label:"Cap, in dollars",note:"Caps what the runs spend (each run, its look-back and its review). A row starts only when what is left covers it. Grades are counted in the cost but not capped.",hint:N?`Up to ${Zr(S)} for ${a.rows.length} rows.`:void 0,children:t.jsx(ze,{inputMode:"decimal",value:x,onChange:$=>h($.target.value),className:"max-w-40","aria-label":"Cap, in dollars"})}),t.jsx(QL,{columns:[...u,g].filter(Boolean),rows:a.rows.slice(0,3)})]}),j&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:j}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{variant:"primary",disabled:!N||v,onClick:()=>void _(),children:v?"Starting":"Learn"}),t.jsx(B,{variant:"ghost",onClick:r,disabled:v,children:"Cancel"})]})]})}function QL({columns:e,rows:n}){return t.jsx("div",{className:"overflow-x-auto","aria-label":"The first rows",children:t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{children:e.map(s=>t.jsx("th",{className:"caps border-b px-2 py-1 text-left font-semibold",children:s},s))})}),t.jsx("tbody",{children:n.map((s,r)=>t.jsx("tr",{children:e.map(a=>t.jsx("td",{className:"max-w-64 truncate border-b px-2 py-1",children:s[a]},a))},r))})]})})}const JL={running:"active",completed:"success",cancelled:"muted",stopped:"warning"};function XL({v2:e,agentId:n,batch:s,onBatch:r}){const[a,i]=p.useState(!1),[c,d]=p.useState(null),u=async()=>{i(!0),d(null);try{r(await e.cancelLearningBatch(n,s.id))}catch(b){d(b instanceof Error?b.message:String(b))}i(!1)},f=GL(s),g=s.cost_usd===null?"unknown":Zr(s.cost_usd);return t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ne,{tone:JL[s.status],children:s.status}),t.jsxs("span",{className:"font-mono text-body",children:[s.finished," of ",s.total," rows"]})]}),ox(s)&&t.jsx(B,{size:"sm",variant:"destructive",disabled:a,onClick:()=>void u(),children:"Cancel"})]}),t.jsx("div",{className:"h-2 w-full bg-muted",role:"progressbar","aria-label":"Rows done","aria-valuemin":0,"aria-valuemax":s.total,"aria-valuenow":s.finished,children:t.jsx("div",{className:"h-full bg-primary",style:{width:`${s.total?s.finished/s.total*100:0}%`}})}),f&&t.jsx(vt,{tone:"warning",children:f}),s.status==="completed"&&t.jsx(vt,{tone:"success",children:"Every row ran. The results are below."}),c&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:c}),t.jsxs("dl",{className:"grid grid-cols-2 gap-3 font-mono text-body sm:grid-cols-4",children:[t.jsx(Oo,{label:"Right",value:`${s.right}`}),t.jsx(Oo,{label:"Wrong",value:`${s.wrong}`}),t.jsx(Oo,{label:"Failed",value:`${s.failed}`}),t.jsx(Oo,{label:"Cost so far",value:`${g} of ${Zr(s.max_cost_usd)}`}),t.jsx(Oo,{label:"Notes learned",value:`${s.lessons.notes.length}`}),t.jsx(Oo,{label:"Skills learned",value:`${s.lessons.skills.length}`}),t.jsx(Oo,{label:"Workflow revisions",value:`${s.revisions.length}`}),t.jsx(Oo,{label:"Paths",value:`${s.paths.agent} by hand, ${s.paths.handed_back} handed back, ${s.paths.workflow} workflow`})]}),s.lessons.notes.length+s.lessons.skills.length+s.lessons.workflows.length>0&&t.jsxs("p",{className:"text-body text-muted-foreground",children:["Learned: ",[...s.lessons.notes,...s.lessons.skills.map(b=>`${b} (skill)`),...s.lessons.workflows.map(b=>`${b} (workflow)`)].join(", "),"."]}),t.jsx("div",{className:"max-h-96 overflow-auto",children:t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsx("tr",{children:["Row","Result","Path","Cost","Answer","Reference"].map(b=>t.jsx("th",{className:"caps sticky top-0 border-b bg-card px-2 py-1 text-left font-semibold",children:b},b))})}),t.jsx("tbody",{children:s.rows.map(b=>t.jsxs("tr",{"aria-current":s.current===b.n?"step":void 0,children:[t.jsx("td",{className:"border-b px-2 py-1",children:b.n}),t.jsx("td",{className:"border-b px-2 py-1",children:b.state==="done"?t.jsx(Ne,{tone:b.right?"success":"error",children:b.right?"right":"wrong"}):b.state==="failed"?t.jsx(Ne,{tone:"error",title:b.error,children:"failed"}):t.jsx(Ne,{tone:b.state==="running"?"active":"muted",children:b.state==="running"?"running":"waiting"})}),t.jsx("td",{className:"border-b px-2 py-1",children:b.path?qL[b.path]:""}),t.jsx("td",{className:"border-b px-2 py-1",children:b.total_usd==null?"":Zr(b.total_usd)}),t.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:b.answer??void 0,children:b.answer??""}),t.jsx("td",{className:"max-w-48 truncate border-b px-2 py-1",title:b.reference,children:b.reference})]},b.n))})]})})]})}const Oo=({label:e,value:n})=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:e}),t.jsx("dd",{className:"break-words",children:n})]}),ZL="Run the agent on jobs it never learned from and record the counts: agentrun learning record-eval <agent> --body @eval.json (POST /v2/agents/{id}/learning/evals).",pg=e=>`${Math.round(e*1e3)/10}%`;function eI(e){const{cost_per_task_usd:n,baseline_cost_per_task_usd:s}=e,r=n!==null&&s!==null,a=r&&n>0?s/n:null,[i,c]=e.ci;return{accuracy:pg(e.accuracy),accuracyVs:`95% interval ${pg(i)} to ${pg(c)}, n=${e.n.toLocaleString("en-US")}`,cost:r?a===null||s===0?ar(n):a>=1?`${sx(a)} cheaper`:`${sx(n/s)} the cost`:n!==null?ar(n):"Not counted",costVs:r?`${ar(n)} a task vs ${ar(s)} by hand`:n!==null?`${ar(n)} a task; by hand not counted`:"The test did not count the cost a task."}}function Fk({v2:e,agentId:n,quiet:s=!1}){const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(0);return p.useEffect(()=>{let f=!0;return c(null),Promise.resolve().then(()=>e.learningEvals(n)).then(g=>{f&&a(g)},g=>{f&&c(g??new Error("unknown"))}),()=>{f=!1}},[e,n,d]),s&&!(r!=null&&r.latest)?null:i&&!r?t.jsx(ns,{problem:$r(i,"the held-out test"),onRetry:()=>u(f=>f+1),className:""}):r?t.jsx(tI,{result:r.latest}):t.jsx(pn,{className:"h-[116px] w-full"})}function tI({result:e}){return t.jsxs("section",{className:"min-w-0 border","aria-label":"Held-out test","data-testid":"held-out-test",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1 border-b px-4 py-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Held-out test"}),e&&t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[e.n.toLocaleString("en-US")," jobs it never learned from · ",e.name," · ",ht(e.recorded_at),e.learned_revision?` · revision ${e.learned_revision.slice(0,7)}`:""]})]}),e?t.jsx(nI,{result:e}):t.jsxs("div",{className:"px-4 py-4",role:"status",children:[t.jsx("p",{className:"font-mono text-body",children:"Not measured yet."}),t.jsx("p",{className:"mt-1 max-w-prose text-body text-muted-foreground",children:ZL})]})]})}function nI({result:e}){const n=eI(e),s=[{label:"Held-out accuracy",value:n.accuracy,lines:[n.accuracyVs]},{label:"Cost a task",value:n.cost,lines:[n.costVs]}];return t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"grid grid-cols-1 sm:grid-cols-2",children:s.map((r,a)=>t.jsxs("div",{className:a?"border-t px-4 py-3 sm:border-l sm:border-t-0":"px-4 py-3",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:r.label}),t.jsx("dd",{className:"mt-1 font-mono text-figure font-semibold tabular-nums",children:r.value}),r.lines.map(i=>t.jsx("dd",{className:"mt-0.5 font-mono text-small text-muted-foreground",children:i},i))]},r.label))}),e.label_source&&t.jsxs("p",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["Labels: ",e.label_source]})]})}const Uk="https://api.githubcopilot.com/mcp/",hd={composio:"Composio",github:"GitHub",url:"URL"},Wk=/^[a-z][a-z0-9-]{0,31}$/;function sI(e){const n=new URLSearchParams(e??""),s=n.get("add");if(!s||!Wk.test(s))return;const r=n.get("toolkit")??"";if(n.get("preset")==="composio"&&Wk.test(r)){const a=(n.get("tools")??"").split(",").filter(i=>/^[A-Za-z0-9_-]{1,128}$/.test(i)).slice(0,64);return{name:s,preset:"composio",toolkit:r,...a.length?{tools:a}:{}}}return{name:s,...n.get("auth")==="github_app"?{auth:"github_app"}:{}}}const rI="These are the tools the server offers, not what this credential allows: a read-only token still sees its write tools. A call the credential can't make is refused by the server when a run makes it.",I2=(e,n)=>`mcp:${e}/${n}`;function Bo(e){const n=/^mcp:([^/]+)\/(.+)$/.exec(e);return n?{server:n[1],tool:n[2]}:null}function oI(e,n){var s,r;return e.grantable===!1?`${e.name} can't be granted: ${e.reason??"it runs other actions by name."}`:((s=e.grant_problems)==null?void 0:s["*"])??((r=e.grant_problems)==null?void 0:r[n])}function aI(e,n){return e.flatMap(s=>{const r=Bo(s);if(!r)return[];const a=n.find(i=>i.name===r.server);return a?a.tools.some(i=>i.name===r.tool)?[]:[{grant:s,why:`${r.server} no longer lists ${r.tool}: refresh it, or untick this.`}]:[{grant:s,why:`The MCP server ${r.server} is not saved here any more, so a run can't call it.`}]})}const Hk=e=>`Create an OAuth app with its provider (on GitHub, an OAuth App in your account's developer settings)${e?`, with ${e} as its callback URL,`:","} then enter its Client ID and Secret in this server's OAuth fields and sign in.`;function oo(e){var i,c,d,u,f,g,b;if(!(e instanceof De))return{text:`The request didn't reach this server: ${e instanceof Error?e.message:String(e)}`};const n=(i=e.fields)==null?void 0:i.find(x=>x.field==="url"&&x.reason==="redirect"),s=(c=e.fields)==null?void 0:c.find(x=>x.field==="client_id"&&x.reason==="registration_unavailable"),r=(d=e.details)==null?void 0:d.oauth,a=typeof(r==null?void 0:r.callback)=="string"?r.callback:"";return s?{text:s.message,detail:Hk(a),signIn:!0,needsClient:!0}:e.code==="auth_required"&&((u=e.details)==null?void 0:u.auth)==="oauth"&&(r==null?void 0:r.registration)===!1?{text:"This server signs in with OAuth, and its sign-in lets no app register itself.",detail:Hk(a),signIn:!0,needsClient:!0}:e.code==="auth_required"?((f=e.details)==null?void 0:f.auth)==="oauth"?{text:"This server signs in with OAuth.",detail:"Sign in to it: its tools are saved once you approve.",signIn:!0}:{text:"This server asks for a token.",detail:e.message}:e.code==="github_not_connected"?{text:"GitHub is not connected on this server.",detail:`${e.message} A GitHub App server runs on this server's GitHub App: connect GitHub, or add a repository to its installation, in Settings → GitHub, then try again.`}:e.code==="not_mcp"?{text:"This address doesn't speak MCP.",detail:e.message}:n?{text:"This address redirects; use the final address.",detail:n.message}:e.status===424?{text:`The server failed: ${e.message}`}:e.code==="wrong_origin"?{text:"Sign in from this server's own address: the sign-in comes back there.",...typeof((g=e.details)==null?void 0:g.open)=="string"?{detail:`Open ${e.details.open} and sign in from it.`}:{}}:(b=e.fields)!=null&&b.length?{text:e.fields.map(x=>x.message).join(" ")}:{text:`${e.code}: ${e.message}`}}const Bk={access_denied:"the sign-in was declined on its approval page",invalid_scope:"its authorization server doesn't offer the scopes asked for: change them and sign in again",invalid_grant:"its authorization server didn't take the sign-in's code (it expired, or was used already): sign in again",invalid_client:"its authorization server didn't take this client: check the client ID and secret, or leave them empty",unauthorized_client:"its authorization server doesn't let this client sign in this way: check the client ID, or leave it empty",invalid_request:"its authorization server refused the sign-in's request",unsupported_response_type:"its authorization server doesn't support this way of signing in",unsupported_grant_type:"its authorization server doesn't support this way of signing in",invalid_target:"its authorization server won't give a token for this MCP server",server_error:"its authorization server failed: try again",temporarily_unavailable:"its authorization server is busy: try again in a moment",login_required:"its authorization server wants you to sign in on its page: sign in again",interaction_required:"its authorization server wants you to sign in on its page: sign in again",consent_required:"its authorization server wants your consent on its page: sign in again",auth_required:"the MCP server didn't take the token the sign-in gave",not_mcp:"the address doesn't speak MCP",input_invalid:"the MCP server's tools could not be kept (too many of them, or the address redirects)",upstream_failed:"the MCP server or its authorization server failed: try again",unavailable:"this server was stopping: sign in again",changed_meanwhile:"the server was changed or removed while you signed in, so nothing was saved"},iI="the sign-in didn't finish: try again",lI=e=>e&&Object.hasOwn(Bk,e)?Bk[e]:iI;function cI(e){const n=new URLSearchParams(e??""),s=n.get("server"),r=n.get("sign_in");if(!(!s||r!=="ok"&&r!=="failed"))return{server:s,ok:r==="ok",...r==="failed"?{error:n.get("error")??"sign_in_failed"}:{}}}const pd=Bo;function dI(e){const n=Bo(e);return n?`${n.server} · ${n.tool}`:null}const uI="https://chatgpt.com/#settings",ax="chatgpt",Hc=e=>!!e&&e.startsWith(`${ax}/`)&&e.length>ax.length+1,z2="Codex and pi agents run on your ChatGPT plan. Claude Agent, OpenCode, Jev decisions and paid tools need their own keys.",fI="Signing in on this computer finishes by itself. On a server elsewhere, the tab ends on a page that won't load: copy that tab's whole address and paste it here.",mI="This sign-in is yours: don't let other people run agents on this server with it.",hI="Signed out. If ChatGPT still lists AgentRun under connected apps, disconnect it there.",pI="Signed out here. OpenAI didn't confirm the revocation: remove AgentRun in your ChatGPT settings.",gI="Your ChatGPT sign-in expired. Sign in again.",D2="Requests on your ChatGPT plan cost no dollars here; your plan's own limits apply.",xI=`Counts dollars. ${D2}`,vI=new Set(["signed_out","pending","signed_in","expired"]),Mf=e=>e&&typeof e=="object"&&vI.has(String(e.state))?e:null,yI=e=>e.charAt(0).toUpperCase()+e.slice(1),bI=e=>`Signed in as ${e.email??"your ChatGPT account"}${e.plan?` (${yI(e.plan)})`:""}`;function ul(e,n){return Hc(e)?{text:`${e.slice(ax.length+1)} · on your ChatGPT plan`,title:e}:n&&e.startsWith(`${n}/`)&&e.length>n.length+1?{text:e.slice(n.length+1),title:e}:{text:e}}function F2(e,n){var s;return new Map((((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.free_models)??[]).map(r=>[r.id,r]))}function wI(e,n,s,r){return!e||typeof r!="number"||Hc(e)?null:F2(n,s).has(e)?`free model: up to ${r} requests`:null}function jI(e){return e>=1e6?`${Math.round(e/1e6*10)/10}M`.replace(/\.0M$/,"M"):`${Math.round(e/1e3)}K`}function kI(e,n){var s;return((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.models)??[]}function U2(e,n){var s;return((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.default_model)??void 0}const NI="No default for this harness yet: add a model key in Settings → Model keys, or choose a model here.",SI="none yet: add a model key in Settings → Model keys",W2=e=>ul(e,null).text,Gv=(e,n)=>[e,n!=null&&n.model?n.tier:void 0,n!=null&&n.model?W2(n.model):void 0].filter(Boolean).join(" · "),H2=e=>e!=null&&e.model?`ran on ${W2(e.model)}${e.tier?` (the ${e.tier} tier)`:""}`:"",CI="http://www.w3.org/2000/svg",Ai=16,an=240,EI=40,$I=58,gg=16,xg=26,Hu=18,Oi=14,Gk=16,_I=26,TI=14,RI=22,zs=14,qk=16,Bu=16,AI=4,OI=10,MI=18,PI=30,LI=5,kc=124,ix=34,II=4,vg=10*.6,zI=12.5*.6,Bc=10.5*.6,Kk=11*.6,qv=9*.66,Vk=10.5*.6,DI={agent:"agent",decide:"agent",extract:"agent",report:"agent",artifact:"agent",judge:"jev",pick:"jev",sift:"jev",route:"jev",call:"tool",code:"code",escalate:"exit",chain:"control",parallel:"control",map:"control",loop:"control",workflow:"control"},Kv=new Set(["done","working","held","failed","escalated","stopped","not-run","review","pending"]),Pf={review:"needs review","not-run":"",pending:""};function bt(e,n,...s){const r=document.createElementNS(CI,e);if(n)for(const[a,i]of Object.entries(n))r.setAttribute(a,String(i));for(const a of s)js(r,a);return r}function js(e,n){if(n!=null){if(Array.isArray(n)){for(const s of n)js(e,s);return}e.appendChild(typeof n=="string"?document.createTextNode(n):n)}}const Sr=(e,n)=>e.length>n?`${e.slice(0,n-1)}…`:e,FI=(e,n)=>{const s=/^(.*) (\d\.\d\d)$/.exec(e);return!s||e.length<=n?Sr(e,n):`${Sr(s[1],Math.max(2,n-s[2].length-1))} ${s[2]}`},Fo=(e,n)=>Math.max(2,Math.floor(e/n)),Go=(e,n)=>Math.ceil(e.length*n),Us=(e,n,s,r,a)=>bt("line",{x1:e,y1:n,x2:s,y2:r,class:a?`wire ${a}`:"wire"});function B2(e){const n={},s={};for(const a of e)n[a.path]=a;const r=a=>{var i;return((i=n[a])==null?void 0:i.kind)??""};for(const a of e){let i;const c={node:a,order:0,name:null};let d=null;(i=/^(.*)\/steps\/(\d+)$/.exec(a.path))&&r(i[1])==="chain"?(d=i[1],c.order=Number(i[2])):(i=/^(.*)\/branches\/([^/]*)\/body$/.exec(a.path))&&r(i[1])==="route"?(d=i[1],c.name=i[2].replace(/~1/g,"/").replace(/~0/g,"~")):(i=/^(.*)\/branches\/(\d+)$/.exec(a.path))&&r(i[1])==="parallel"?(d=i[1],c.order=Number(i[2])):((i=/^(.*)\/body$/.exec(a.path))&&(r(i[1])==="map"||r(i[1])==="loop")||(i=/^(.*)\/workflow\/root$/.exec(a.path))&&r(i[1])==="workflow")&&(d=i[1]),d!==null&&(s[d]??(s[d]=[])).push(c)}for(const a of Object.values(s))a.sort((i,c)=>i.order-c.order);return{byPath:n,kids:s}}function Vv(e,n){var u,f,g,b;const{diff:s={},status:r={},fired:a}=e.marks,i=n===a?"escalated":r[n],c=i&&Kv.has(i)?i:"",d=(u=s.added)!=null&&u.includes(n)?"NEW":(f=s.edited)!=null&&f.includes(n)?"EDITED":(g=s.moved)!=null&&g.includes(n)?"MOVED":"";return{state:c,tag:d,fired:n===a,selected:((b=e.marks.selected)==null?void 0:b.path)===n&&e.marks.selected.item==null}}function gd(e,n,s){var x,h,v;const r=Vv(e,n.path),a=(x=e.marks.meta)==null?void 0:x[n.path],i=a!=null&&a.tool?pd(a.tool):null,c=(h=e.marks.ran)==null?void 0:h[n.path],d=a!=null&&a.decision?(c==null?void 0:c.model)??a.model:a==null?void 0:a.model;let u=`${n.label} (${n.kind}${i?`: ${i.tool} on ${i.server}, an MCP server's tool`:n.via?` via ${n.via}`:""}${a!=null&&a.provider?`, ${a.provider}${d?` ${d}`:""}`:""}${c&&!(a!=null&&a.decision)?`, ${H2(c)}`:""})`;r.state&&(u+=`: ${r.state.replace("-"," ")}`),r.tag&&(u+=`${r.state?", ":": "}${r.tag.toLowerCase()}`),(v=a==null?void 0:a.questions)!=null&&v.length&&(u+=`
|
|
627
|
+
${a.questions.map(y=>`• ${y.text}`).join(`
|
|
628
|
+
`)}`);const f=a!=null&&a.decision&&a.provider?`who-${a.provider==="parallel"||a.provider==="openrouter"?a.provider:"jev"}`:n.kind==="route"&&a&&!a.decision?"who-control":`who-${DI[n.kind]??"code"}`;let g=`node ${s} ${f}`;r.state&&(g+=` ${r.state}`),r.fired&&(g+=" fired"),r.tag&&(g+=` ${r.tag.toLowerCase()}`),r.selected&&(g+=" selected");const b=bt("g",{class:g,"data-path":n.path},bt("title",null,u));return e.svg.appendChild(b),b}const Ji=e=>Go(e,qv)+10;function hf(e,n,s,r,a="tag"){const i=Ji(r);return js(e,[bt("rect",{x:n,y:s,width:i,height:13,class:`${a}-box`}),bt("text",{x:n+i/2,y:s+9.5,class:a,"text-anchor":"middle"},r)]),i}const UI=(e,n)=>{var s,r;return!!((r=(s=e.marks.meta)==null?void 0:s[n.path])!=null&&r.decision)},Dm=(e,n)=>UI(e,n)?$I:EI;function Yv(e,n,s,r,a){var k,E,S,N,_;const i=Vv(e,s.path),c=(k=e.marks.meta)==null?void 0:k[s.path],d=Dm(e,s),u=(E=e.marks.verdict)==null?void 0:E[s.path],f=i.state in Pf?Pf[i.state]:i.state,g=((S=c==null?void 0:c.questions)==null?void 0:S.length)??0,b=c!=null&&c.tool?pd(c.tool):null,x=(N=e.marks.ran)==null?void 0:N[s.path],h=(x&&!(c!=null&&c.decision)?Gv(s.kind,x):s.kind)+(b?` · ${b.tool} on ${b.server}`:c!=null&&c.tool?` · ${c.tool}`:s.via?` · ${s.via}`:"")+(c!=null&&c.decision&&g?` · ${g} ${g===1?"question":"questions"}`:""),v=[(_=c==null?void 0:c.images)!=null&&_.length?"IMG":"",c!=null&&c.web?"WEB":"",b?"MCP":""].filter(Boolean),y=v.reduce(($,O)=>$+Ji(O)+4,0);i.selected&&n.appendChild(bt("rect",{x:r-4,y:a-4,width:an+8,height:d+8,class:"sel"})),js(n,[bt("rect",{x:r,y:a,width:an,height:d,class:"box"}),bt("rect",{x:r+10,y:a+9,width:8,height:8,class:"swatch"}),bt("text",{x:r+24,y:a+17,class:"label"},Sr(s.label,Fo(an-34-y,zI))),bt("text",{x:r+24,y:a+31,class:"kind"},Sr(h,Fo(an-34-(f?Go(f,qv)+8:0),Bc))),f?bt("text",{x:r+an-10,y:a+31,class:"state","text-anchor":"end"},f):null]);let j=r+an-8;for(const $ of v.reverse())j-=Ji($),hf(n,j,a+7,$,"badge"),j-=4;if(c!=null&&c.decision&&c.provider){const $=hf(n,r+24,a+38,c.provider,"chip"),O=u?FI(u,Fo(an-44-$-20,Vk)):"",A=an-40-$-(O?Go(O,Vk)+10:0),L=(x==null?void 0:x.model)??c.model;L&&A>24&&n.appendChild(bt("text",{x:r+24+$+6,y:a+47.5,class:"model"},Sr(L,Fo(A,Bc)))),O&&n.appendChild(bt("text",{x:r+an-10,y:a+47.5,class:"verdict","text-anchor":"end"},O))}else u&&n.appendChild(bt("text",{x:r+an-10,y:a+17,class:"verdict","text-anchor":"end"},u));i.tag&&hf(n,r+an-Ji(i.tag),a-7,i.tag)}function WI(e,n){return{w:an,h:Dm(e,n),cx:an/2,place:(s,r)=>Yv(e,gd(e,n,"card"),n,s,r)}}function G2(e,n,s){const r=Vv(e,n.path),a=r.state==="done"?"passed":r.state in Pf?Pf[r.state]:r.state,i=Sr(n.label===n.kind?"exit":`exit: ${n.label}`,40),c=Go(i,Bc)+16;return{w:Oi+c+(r.tag?6+Ji(r.tag):0)+(a?6+Go(a,qv):0),h:xg,cx:0,exit:!0,place:(d,u)=>{const f=gd(e,n,"exit"),g=u+xg/2;let b=d+Oi+c;s&&f.appendChild(Us(d,u,d,u+xg,"spine")),r.selected&&f.appendChild(bt("rect",{x:d+Oi-3,y:g-Hu/2-3,width:c+6,height:Hu+6,class:"sel"})),js(f,[Us(d,g,d+Oi,g,"exit-wire"),bt("rect",{x:d+Oi,y:g-Hu/2,width:c,height:Hu,class:"exit-box"}),bt("text",{x:d+Oi+8,y:g+3.5,class:"exit-text"},i)]),r.tag&&(hf(f,b+6,g-6.5,r.tag),b+=6+Ji(r.tag)),a&&f.appendChild(bt("text",{x:b+6,y:g+3.5,class:"state"},a))}}}function HI(e,n,s){const r=s.map(d=>d.node.kind==="escalate"?G2(e,d.node,!1):Fm(e,d.node));let a=an/2,i=an/2,c=-gg;for(const d of r)a=Math.max(a,d.cx),i=Math.max(i,d.w-d.cx),c+=d.h+gg;return{w:a+i,h:c,cx:a,place:(d,u)=>{const f=gd(e,n,"chain"),g=d+a;let b=u,x=null;r.forEach((h,v)=>{v&&(b+=gg),h.exit?x===null&&(x=b):x!==null&&f.appendChild(Us(g,x,g,b,"spine")),h.place(h.exit?g:g-h.cx,b),b+=h.h,h.exit||(x=b)}),r[r.length-1].exit&&x!==null&&f.appendChild(Us(g,x,g,b,"spine"))}}}function BI(e,n,s){const r=Dm(e,n),a=s.map(h=>({kid:h,box:Fm(e,h.node),x:0,c:0}));let i=0,c=0;a.forEach((h,v)=>{v&&(i+=RI),h.x=i,h.c=i+h.box.cx,i+=h.box.w,c=Math.max(c,h.box.h)});const d=a.length-1,u=Math.round((a[0].c+a[d].c)/2),f=Math.min(0,u-an/2),g=Math.max(i,u+an/2),b=r+Gk+_I,x=b+c+TI;return{w:g-f,h:x,cx:u-f,place:(h,v)=>{const y=gd(e,n,"card"),j=h-f,k=v+r+Gk,E=v+x;Yv(e,y,n,j+u-an/2,v),y.appendChild(Us(j+u,v+r,j+u,k)),d&&js(y,[Us(j+a[0].c,k,j+a[d].c,k),Us(j+a[0].c,E,j+a[d].c,E)]),a.forEach((S,N)=>{const _=j+S.c,$=S.kid.node.path,O=e.taken.has($);if(y.appendChild(bt("line",{x1:_,y1:k,x2:_,y2:v+b,class:O?"wire branch taken":"wire branch","data-to":$})),S.kid.name!==null){const A=(N<d?a[N+1].c-6:S.x+S.box.w)-S.c-12,L=Sr(S.kid.name,Fo(A,Bc)),M=bt("text",{x:_+6,y:k+15,class:O?"branch-name taken":"branch-name"},L);y.appendChild(L===S.kid.name?M:bt("g",null,bt("title",null,S.kid.name),M))}y.appendChild(Us(_,v+b+S.box.h,_,E,O?"taken":void 0)),S.box.place(j+S.x,v+b)})}}}const GI=e=>e.replace(/^.*\//,"").replace(/\.(pdf|png|jpe?g|webp|gif|tiff?)$/i,"");function qI(e,n,s,r,a,i){const c=Kv.has(s.status)?s.status:"pending",d=s.label?GI(s.label):`#${s.index+1}`,u=s.outcome??(c==="review"?"needs review":c==="not-run"?"not run":c),f=s.p!==void 0?s.p.toFixed(2):"",g=`#${s.index+1}${s.label?` ${s.label}`:""}: ${c==="review"?"needs review":c.replace("-"," ")}${s.outcome?`, ${s.outcome}`:""}${s.pNote?` (${s.pNote})`:""}`,b=bt("g",{class:`rcell ${c}${s.tone?` tone-${s.tone}`:""}${i?" picked":""}`,"data-path":n.path,"data-item":s.index},bt("title",null,g),bt("rect",{x:r,y:a,width:kc,height:ix,class:"cell"}),bt("rect",{x:r,y:a,width:3,height:ix,class:"cell-edge"}),bt("text",{x:r+9,y:a+14,class:"cell-name"},Sr(d,Fo(kc-14,vg))),bt("text",{x:r+9,y:a+27,class:"cell-out"},Sr(u,Fo(kc-18-(f?Go(f,vg)+6:0),vg))),f?bt("text",{x:r+kc-6,y:a+27,class:"cell-p","text-anchor":"end"},f):null);e.appendChild(b)}function KI(e,n){var j;const s=((j=e.marks.items)==null?void 0:j[n.path])??[];if(!s.length)return null;const r=s.length<=PI,[a,i,c]=r?[kc,ix,II]:[Bu,Bu,AI],d=Math.min(s.length,r?LI:OI),u=Math.ceil(s.length/d),f=d*(a+c)-c,g=u*(i+c)-c+MI+(r?4:0),b={};for(const k of s)b[k.status]=(b[k.status]??0)+1;const x={};for(const k of s)k.outcome&&(x[k.outcome]=(x[k.outcome]??0)+1);const h=Object.entries(x).map(([k,E])=>`${E} ${k}`),y=[`${b.done??0}/${s.length} done`,b.working?`${b.working} working`:"",b.held?`${b.held} held`:"",b.failed?`${b.failed} failed`:"",b.review?`${b.review} review`:"",...h].filter(Boolean).join(" · ");return{w:Math.max(f,Go(y,Bc)),h:g,place:(k,E,S)=>{const N=E-f/2,_=e.marks.selected;s.forEach(($,O)=>{const A=N+O%d*(a+c),L=S+Math.floor(O/d)*(i+c),M=Kv.has($.status)?$.status:"pending",R=(_==null?void 0:_.path)===n.path&&_.item===$.index;if(r){qI(k,n,$,A,L,R);return}js(k,bt("rect",{x:A,y:L,width:Bu,height:Bu,class:`cell ${M}${R?" picked":""}`,"data-path":n.path,"data-item":$.index},bt("title",null,`#${$.index+1}${$.label?` ${$.label}`:""}: ${M==="review"?"needs review":M.replace("-"," ")}`)))}),js(k,bt("text",{x:E,y:S+g-4,class:"caption","text-anchor":"middle"},y))}}}function VI(e,n,s){const r=Fm(e,s),a=Dm(e,n),i=n.kind==="map"?KI(e,n):null,c=i?i.h+zs:0,d=Math.max(an/2,r.cx,i?i.w/2:0)+zs,u=Math.max(an/2,r.w-r.cx,i?i.w/2:0)+zs,f=a+zs+c+r.h+zs;return{w:d+u,h:f,cx:d,place:(g,b)=>{const x=gd(e,n,"card"),h=g+d;if(js(x,bt("rect",{x:g,y:b+a/2,width:d+u,height:f-a/2,class:"frame"})),i?(js(x,Us(h,b+a,h,b+a+zs)),js(x,Us(h,b+a+zs+i.h,h,b+a+zs+c))):js(x,Us(h,b+a,h,b+a+zs)),js(x,Us(h,b+a+zs+c+r.h,h,b+f)),Yv(e,x,n,h-an/2,b),i){const v=bt("g",{class:"items"});i.place(v,h,b+a+zs),x.appendChild(v)}r.place(h-r.cx,b+a+zs+c)}}}function q2(e,n){return e.kind==="escalate"?"exit":n.length?e.kind==="chain"?"chain":e.kind==="route"||e.kind==="parallel"?"fan":"frame":"leaf"}function Fm(e,n){const s=e.kids[n.path]??[],r=q2(n,s);return r==="exit"?G2(e,n,!0):r==="leaf"?WI(e,n):r==="chain"?HI(e,n,s):r==="fan"?BI(e,n,s):VI(e,n,s[0].node)}function Qv(e){const{byPath:n,kids:s}=B2(K2(e)),r=a=>{const i=s[a.path]??[],c=q2(a,i),d=c==="frame"?r(i[0].node):c==="chain"||c==="fan"?i.reduce((u,f)=>u+r(f.node),0):0;return(c==="chain"?0:1)+d};return n["/root"]?r(n["/root"]):0}const Um=e=>`${e} ${e===1?"node":"nodes"}`,K2=e=>(e&&Array.isArray(e.nodes)?e.nodes:[]).filter(n=>n&&typeof n.path=="string"&&typeof n.kind=="string").map(n=>({path:n.path,kind:n.kind,label:String(n.label??n.kind),via:typeof n.via=="string"?n.via:""}));function YI(e,n,s={}){var g;for(;e.firstChild;)e.removeChild(e.firstChild);e.classList.add("wf");const r=B2(K2(n)),a=(b,x)=>(e.setAttribute("viewBox",`0 0 ${b} ${x}`),e.setAttribute("width",String(b)),e.setAttribute("height",String(x)),e.style.setProperty("min-width",`${Math.min(b,480)}px`),{w:b,h:x});if(!r.byPath["/root"])return a(0,0);const i={svg:e,kids:r.kids,marks:s,taken:new Set(s.taken??[])},c=Fm(i,r.byPath["/root"]);c.place(Ai,Ai);let d=c.w,u=c.h;const f=(((g=s.diff)==null?void 0:g.removed)??[]).map(b=>`${b.label} (${b.kind})`);if(f.length){const b=["Removed:",...f.map(h=>Sr(h,Fo(Math.max(d,300),Kk)))],x=bt("g",{class:"removed-list"},bt("title",null,`Removed: ${f.join(", ")}`));b.forEach((h,v)=>{x.appendChild(bt("text",{x:Ai,y:Ai+u+33+v*qk,class:"removed"},h)),d=Math.max(d,Go(h,Kk))}),e.appendChild(x),u+=22+b.length*qk}return a(d+2*Ai,u+2*Ai)}function QI(e){var a,i;const n=e,s=(a=n==null?void 0:n.closest)==null?void 0:a.call(n,"[data-item]");if(s)return{path:s.getAttribute("data-path"),item:Number(s.getAttribute("data-item"))};const r=(i=n==null?void 0:n.closest)==null?void 0:i.call(n,"g[data-path]");return!r||r.classList.contains("chain")?null:{path:r.getAttribute("data-path"),item:null}}const JI=1600;function xd({graph:e,marks:n,onSelect:s,className:r,label:a="Workflow graph",minScale:i=.8,maxScale:c=1.3}){const d=p.useRef(null),[u,f]=p.useState({w:0,h:0}),[g,b]=p.useState(0),x=p.useMemo(()=>JSON.stringify([(e==null?void 0:e.nodes)??null,n??null]),[e,n]);p.useEffect(()=>{if(!d.current)return;const v=YI(d.current,e,n);f(y=>y.w===v.w&&y.h===v.h?y:v),d.current.style.setProperty("--wf-phase",`-${Date.now()%JI}ms`)},[x]),p.useEffect(()=>{var j;const v=(j=d.current)==null?void 0:j.parentElement;if(!v||typeof ResizeObserver>"u")return;const y=new ResizeObserver(([k])=>b(k.contentRect.width));return y.observe(v),()=>y.disconnect()},[]);const h=u.w&&g?Math.min(c,Math.max(i,g/u.w)):1;return t.jsx("svg",{ref:d,role:"img","aria-label":a,className:oe("wf select-none",r),style:u.w?{width:u.w*h,height:u.h*h,maxWidth:"none",minWidth:0}:void 0,onClick:v=>{const y=QI(v.target);y&&s&&s(y)}})}function vd({run:e=!1}){const n=[["hsl(var(--wf-jev))","Jev"],["hsl(var(--wf-parallel))","Parallel"],["hsl(var(--wf-openrouter))","OpenRouter"],["hsl(var(--wf-tool))","Tool"],["hsl(var(--muted-foreground))","Code"],["hsl(var(--primary))","Agent"]],s=[["border-success bg-success/40","Done"],["border-primary bg-primary/20","Working"],["border-dashed border-warning","Held (paused)"],["border-warning bg-warning/60","Needs review"],["border-destructive bg-destructive/60","Failed"],["border-dashed border-border-strong","Pending"]];return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 font-mono text-label text-muted-foreground",children:[n.map(([r,a])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block size-2",style:{background:r}}),a]},a)),e&&t.jsx("span",{className:"h-3 border-l","aria-hidden":!0}),e&&s.map(([r,a])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:oe("inline-block size-2.5 border",r)}),a]},a))]})}const V2={self:"self",jev:"jev",both:"self+jev"},XI=e=>`${V2[e.signal]} ≥${e.threshold.toFixed(2)}`,ZI=(e,n)=>n?`${Math.round(e/n*100)}%`:"0%";function ez({guards:e,workflow:n,digest:s,loop:r}){return e.length?t.jsxs("section",{className:"border","aria-label":"Where it is unsure","data-testid":"step-guards",children:[t.jsxs("header",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-3 py-2",children:[t.jsx("h3",{className:"caps text-label font-semibold",children:"Where it is unsure"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Each guarded step hands the run back to the agent when its p is under the threshold."})]}),t.jsx("ul",{className:"divide-y",children:e.map(a=>t.jsx(tz,{guard:a,stats:RL(r,n,s,a.node)},a.node))}),t.jsx(sz,{})]}):null}function tz({guard:e,stats:n}){const s=(n==null?void 0:n.right)??0,r=(n==null?void 0:n.wrong)??0,a=(n==null?void 0:n.replays)??0,i=(n==null?void 0:n.grades_past)??0,c=s+r?` · graded ${s} right, ${r} wrong`:i?"":" · none graded",d=i?` · ${i} older ${i===1?"run's grade is":"runs' grades are"} past the newest grades kept`:"";return t.jsxs("li",{className:"grid grid-cols-1 gap-x-4 gap-y-2 px-3 py-2.5 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center","data-testid":"guard-row",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"min-w-0 break-words font-mono text-body font-semibold",children:e.node}),t.jsx(Ne,{tone:"plain",title:`Reads ${_L[e.signal]}`,children:V2[e.signal]}),t.jsxs(Ne,{tone:"muted",children:[e.fitted?"fitted":"threshold"," ",e.threshold.toFixed(2)]})]}),t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:n&&n.runs?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:oe("font-semibold",n.escalated/n.runs>.25?"text-warning-text":"text-foreground"),children:[ZI(n.escalated,n.runs)," handed back"]})," (",n.escalated," of ",n.runs," runs)",c,d,a?` · ${a} replay ${a===1?"run":"runs"} apart`:""]}):a?`Replayed on ${a} graded ${a===1?"input":"inputs"}; no run served yet.`:"No run of this revision yet."})]}),n&&n.points.length>0&&t.jsx(nz,{guard:e,stats:n})]})}const Mo=168,vr=36,Yk=2;function nz({guard:e,stats:n}){const s=TL(n.points),r=Math.max(1,...s.map(d=>d.right+d.wrong+d.ungraded)),a=Mo/s.length,i=d=>Math.min(Mo-1,Math.max(1,d*Mo)),c=s.filter(d=>d.right+d.wrong+d.ungraded).map(d=>`p ${d.from.toFixed(1)} to ${d.to.toFixed(1)}: ${[d.right&&`${d.right} right`,d.wrong&&`${d.wrong} wrong`,d.ungraded&&`${d.ungraded} not graded`].filter(Boolean).join(", ")}`);return t.jsxs("figure",{className:"m-0 shrink-0","data-testid":"guard-histogram",children:[t.jsxs("svg",{width:Mo,height:vr+14,className:"block font-mono","aria-hidden":!0,children:[s.map(d=>{let u=vr;const f=[[d.right,"fill-success"],[d.wrong,"fill-destructive"],[d.ungraded,"fill-muted-foreground"]];return t.jsxs("g",{children:[t.jsx("title",{children:`p ${d.from.toFixed(1)}–${d.to.toFixed(1)}: ${d.right} right, ${d.wrong} wrong, ${d.ungraded} not graded`}),t.jsx("rect",{x:d.from*Mo,y:0,width:a,height:vr,className:"fill-card",fillOpacity:0}),f.map(([g,b])=>{if(!g)return null;const x=g/r*(vr-2);u-=x;const h=u>.5&&u+x<vr-.5?1:0;return t.jsx("rect",{x:d.from*Mo+Yk/2,y:u+h,width:a-Yk,height:Math.max(1,x-h),className:b,fillOpacity:b==="fill-muted-foreground"?.45:.85},b)})]},d.from)}),t.jsx("path",{d:`M0,${vr+.5}H${Mo}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("path",{d:`M${i(e.threshold)},0V${vr+3}`,className:"stroke-foreground",strokeWidth:1.5,strokeDasharray:"3 2"}),t.jsx("text",{x:0,y:vr+12,className:"fill-muted-foreground text-micro",children:"0"}),t.jsx("text",{x:Mo,y:vr+12,textAnchor:"end",className:"fill-muted-foreground text-micro",children:"1"}),t.jsx("text",{x:i(e.threshold),y:vr+12,textAnchor:"middle",className:"fill-foreground text-micro font-semibold",children:e.threshold.toFixed(2)})]}),n.points.length<n.runs&&t.jsxs("p",{className:"m-0 font-mono text-micro text-muted-foreground",children:["p of the newest ",n.points.length," runs"]}),t.jsx("figcaption",{className:"sr-only",children:`${e.node}: p by run${n.points.length<n.runs?`, the newest ${n.points.length} of ${n.runs}`:""}. ${c.join(". ")}.`})]})}function sz(){const e=[["Right","fill-success",.85],["Wrong","fill-destructive",.85],["Not graded","fill-muted-foreground",.45]];return t.jsxs("p",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"caps",children:"p by run"}),e.map(([n,s,r])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"10",height:"10","aria-hidden":!0,children:t.jsx("rect",{width:"10",height:"10",className:s,fillOpacity:r})}),n]},n)),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"10","aria-hidden":!0,children:t.jsx("path",{d:"M6,0V10",className:"stroke-foreground",strokeWidth:1.5,strokeDasharray:"3 2"})}),"Threshold"]}),t.jsx("span",{children:"A missing signal counts as 0 and hands back."})]})}const rz=3e3,oz=e=>e.word==="Held"||e.word==="Not decided"||e.word==="Skipped",Qk=e=>`${Math.round(e*100)}%`,az=e=>`${e>=0?"+":""}${Math.round(e*1e3)/10} pts`,Y2=e=>`${e} graded ${e===1?"input":"inputs"}`;function iz(e){if(!e)return"Replay started: its runs are queued.";const n=e.outcomes,s=n.answered+n.handed_back+n.failed+n.skipped_write;return`Replaying on ${Y2(e.inputs)}: ${s} of ${e.inputs} ended (${n.answered} answered alone, ${n.handed_back} handed back${n.failed?`, ${n.failed} failed`:""}${n.skipped_write?`, ${n.skipped_write} skipped`:""}).`}function lz(e){const n=e.reason?` ${e.reason.charAt(0).toUpperCase()}${e.reason.slice(1)}`:"",s=e.status==="failed"?`The replay did not finish.${n}`:e.decided==="promote"?`Promoted: it serves first now.${n}`:e.decided==="hold"?`Still held.${n}`:`Decided.${n}`,r=e.score;return{text:s,score:r.n>0?`Workflow ${Qk(r.wf_acc)} vs agent ${Qk(r.agent_acc)} on ${Y2(r.n)} (${az(r.delta)}), ${r.handed_back} handed back`:null}}function cz({v2:e,agentId:n,workflow:s,digest:r,offered:a,resume:i=null,onStarted:c,onDecided:d,pollMs:u=rz}){const[f,g]=p.useState(i?{at:"running",replay:i,read:null}:{at:"idle"});p.useEffect(()=>{i&&g(j=>j.at==="idle"?{at:"running",replay:i,read:null}:j)},[i]);const b=p.useRef(d);b.current=d;const x=f.at==="running"?f.replay:null,h=f.at==="running"?f.unread:void 0;p.useEffect(()=>{if(x===null||h!==void 0)return;let j=!0,k;const E=()=>{Promise.resolve().then(()=>e.learnedWorkflowReplay(n,s,r,x)).then(S=>{var N;if(j){if(S.status==="running"){g({at:"running",replay:x,read:S}),k=setTimeout(E,u);return}g({at:"decided",read:S}),(N=b.current)==null||N.call(b)}},S=>{j&&g(N=>N.at==="running"?{...N,unread:S instanceof Error?S.message:String(S)}:N)})};return E(),()=>{j=!1,k&&clearTimeout(k)}},[e,n,s,r,x,h,u]);const v=()=>{g({at:"starting"}),Promise.resolve().then(()=>e.startLearnedWorkflowReplay(n,s,r)).then(j=>{g({at:"running",replay:j.replay,read:null}),c==null||c()},j=>{const k=j==null?void 0:j.code;g({at:"refused",message:j instanceof Error?j.message:String(j),code:typeof k=="string"?k:null})})},y=f.at==="starting"||f.at==="running";return!a&&f.at==="idle"?null:t.jsxs("div",{className:"mt-2 space-y-1","data-testid":"replay-revision",children:[(f.at==="idle"||f.at==="starting"||(f.at==="refused"||f.at==="decided")&&a)&&t.jsx(B,{size:"sm",onClick:v,disabled:y,"aria-label":`Replay revision ${r.slice(0,7)} on graded inputs`,children:f.at==="starting"?"Starting…":f.at==="idle"?"Replay":"Replay again"}),f.at==="running"&&t.jsxs("p",{className:"break-words text-body",role:"status","data-testid":"replay-progress",children:[f.unread!==void 0?`Couldn't read the replay: ${f.unread} `:iz(f.read),f.unread!==void 0&&t.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:()=>g({at:"running",replay:f.replay,read:f.read}),children:"Check again"})]}),f.at==="refused"&&t.jsxs("p",{className:"break-words text-body",role:"alert","data-testid":"replay-refused",children:[f.message,f.code&&t.jsx("span",{className:"ml-2 font-mono text-label text-muted-foreground",children:f.code})]}),f.at==="decided"&&(()=>{const j=lz(f.read);return t.jsxs("div",{role:"status","data-testid":"replay-decision",children:[t.jsx("p",{className:"break-words text-body",children:j.text}),j.score&&t.jsx("p",{className:"break-words font-mono text-label text-muted-foreground","data-testid":"replay-score",children:j.score})]})})()]})}const yg=e=>{const n=[...new Set(e)],s=n.slice(0,3).map(r=>`"${r}"`).join(", ");return n.length>3?`${s} and ${n.length-3} more`:s},Jk=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function dz(e,n,s,r,a){const i=[e.length&&`added ${Jk(e.length,"node")} (${yg(e)})`,n.length&&`edited ${yg(n)}`,s.length&&`removed ${Jk(s.length,"node")} (${yg(s)})`].filter(Boolean);if(!i.length)return r?"Nodes reordered":a?"Connections changed":"No node changed";const c=i.join(", ");return c.charAt(0).toUpperCase()+c.slice(1)}function uz(e){const n=[];let s=null,r=0;for(const a of e){let i=null,c=null;try{i=a.text===null?null:JSON.parse(a.text),c=i===null?null:ll(i)}catch{c=null}if(!(c!=null&&c.nodes.length)){r+=1;continue}const d=s?e2(s,c):null,u=d?d.added.map(k=>k.path):c.nodes.map(k=>k.path),f=k=>{var E;return((E=c.nodes.find(S=>S.path===k))==null?void 0:E.kind)!=="chain"},g=d?[...d.changed.map(k=>k.next),...d.rewritten.map(k=>k.next)]:[],b=d?d.moved.map(k=>k.next):[],x=new Map(c.nodes.map(k=>[k.path,k.label])),h=d?d.removed.filter(k=>k.kind!=="chain").map(k=>k.label):[],v=d?d.edges.added.length+d.edges.removed.length:0,y=$L(a.text),j=Object.fromEntries(y.flatMap(k=>c.nodes.some(E=>E.path===k.path)?[[k.node,k.path]]:[]));n.push({digest:a.digest??null,guards:y,guardPaths:j,commit:a.commit,at:a.at,run:"run"in a.by?a.by.run:null,reason:a.reason,graph:c,marks:{meta:cd(i,c),diff:{added:u,edited:g,moved:b,removed:d?d.removed.map(({label:k,kind:E})=>({label:k,kind:E})):[]}},added:u,edited:g,removed:h,line:d?dz(u.filter(f).map(k=>x.get(k)??k),g.filter(f).map(k=>x.get(k)??k),h,b.length,v):`First version: ${Um(Qv(c))}`}),s=c}return{steps:n,unreadable:r}}const fz=50,mz=1800;function hz({v2:e,agentId:n,workflows:s,promotions:r=[],serving:a=[],loop:i=null,cost:c=null,onReplayed:d}){const u=s.filter(x=>x.status==="active").map(x=>x.name),[f,g]=p.useState(null),b=f!==null&&u.includes(f)?f:u[0]??null;return b===null?null:t.jsx(pz,{v2:e,agentId:n,name:b,choices:u,onPick:g,promotions:r,serving:a,loop:i,stopped:Bv(c,b),onReplayed:d},b)}const Gu="Learned workflow";function pz({v2:e,agentId:n,name:s,choices:r,onPick:a,promotions:i,serving:c,loop:d,stopped:u,onReplayed:f}){var k;const[g,b]=p.useState(null),[x,h]=p.useState(null),[v,y]=p.useState(0);p.useEffect(()=>{let E=!0;return h(null),Promise.resolve().then(()=>e.learnedWorkflowRevisions(n,s,fz)).then(S=>{E&&b(S)},S=>{E&&h(S??new Error("unknown"))}),()=>{E=!1}},[e,n,s,v]);const j=t.jsxs("header",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b px-4 py-3",children:[t.jsxs("h2",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"caps text-small font-semibold",children:Gu})," ",t.jsx("span",{className:"ml-1 break-all font-mono text-body font-semibold",children:s})]}),r.length>1&&t.jsx(Rt,{small:!0,className:"w-56 max-w-full",label:"Learned workflow",value:s,onChange:a,options:r.map(E=>({value:E,label:E}))})]});return x&&!g?t.jsxs("section",{className:"border","aria-label":Gu,children:[j,t.jsx("div",{className:"p-4",children:t.jsx(ns,{problem:$r(x,"the learned workflow"),onRetry:()=>y(E=>E+1),className:""})})]}):g?t.jsxs("section",{className:"border","aria-label":Gu,children:[j,t.jsx(gz,{data:g,promotions:i,serving:((k=c.find(E=>E.workflow===g.name))==null?void 0:k.digest)??null,loop:d,stopped:u,replay:{v2:e,agentId:n,onStarted:f,onDecided:()=>{y(E=>E+1),f==null||f()}}})]}):t.jsxs("section",{className:"border","aria-label":Gu,"aria-busy":!0,children:[j,t.jsx("div",{className:"p-4",children:t.jsx(pn,{className:"h-48 w-full"})})]})}function gz({data:e,stepMs:n=mz,promotions:s=[],serving:r=null,loop:a=null,stopped:i=null,replay:c}){const{steps:d,unreadable:u}=p.useMemo(()=>uz(e.revisions),[e.revisions]),[f,g]=p.useState(Math.max(0,d.length-1)),[b,x]=p.useState(!1),h=p.useRef(f);h.current=f;const v=p.useRef(d);if(p.useEffect(()=>{var P;const L=v.current;v.current=d;const M=((P=L[h.current])==null?void 0:P.digest)??null,R=L===d||h.current>=L.length-1||M===null?-1:d.findIndex(D=>D.digest===M);g(R>=0?R:Math.max(0,d.length-1)),x(!1)},[d]),p.useEffect(()=>{if(!b)return;const L=setInterval(()=>g(M=>Math.min(M+1,d.length-1)),n);return()=>clearInterval(L)},[b,d.length,n]),p.useEffect(()=>{b&&f>=d.length-1&&x(!1)},[b,f,d.length]),!e.revisions.length)return null;if(!d.length)return t.jsxs("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:["This workflow's revisions can't be read as a workflow",u?`: ${u} ${u===1?"revision":"revisions"} did not read`:"","."]});const y=d[Math.min(f,d.length-1)],j=d.length,k=L=>{x(!1),g(Math.max(0,Math.min(j-1,L)))},E=()=>{if(b)return x(!1);f>=j-1&&g(0),x(!0)},S=`Revision ${Math.min(f,j-1)+1} of ${j}, ${ht(y.at)}`,N=Hv(s,e.name,y.digest),_=T2(s,e.name,y.digest),$=Wc(N,{serving:r,refit:_,stopped:i}),O=y.guards.length?{...y.marks,verdict:Object.fromEntries(y.guards.flatMap(L=>y.guardPaths[L.node]?[[y.guardPaths[L.node],XI(L)]]:[]))}:y.marks,A=(N==null?void 0:N.source)==="refit"&&N.refit?N.refit:null;return t.jsxs("div",{className:"space-y-3 p-4",children:[j>1&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsxs(B,{size:"sm",onClick:E,"aria-label":b?"Pause the replay":"Play the replay","aria-pressed":b,children:[b?t.jsx(sl,{"aria-hidden":!0}):t.jsx(Yo,{"aria-hidden":!0}),b?"Pause":"Play"]}),t.jsx(B,{size:"icon",onClick:()=>k(f-1),disabled:f<=0,"aria-label":"Previous revision",children:t.jsx(lT,{"aria-hidden":!0})}),t.jsx(B,{size:"icon",onClick:()=>k(f+1),disabled:f>=j-1,"aria-label":"Next revision",children:t.jsx(Cs,{"aria-hidden":!0})}),t.jsx(u5,{min:1,max:j,value:f+1,onChange:L=>k(L-1),label:"Revision",valueText:S,className:"basis-full sm:min-w-[10rem] sm:flex-1 sm:basis-0"})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{children:j>1?`Revision ${f+1} of ${j}`:"One revision"})," · ",t.jsx("time",{dateTime:y.at,children:ht(y.at)})," · ",y.run?t.jsxs("a",{href:`#/runs/${encodeURIComponent(y.run)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",ta(y.run)]}):"a person"]}),t.jsx("p",{className:"mt-1 break-words text-lead",role:"status","data-testid":"replay-line",children:y.line}),y.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-body text-muted-foreground",children:y.reason}),t.jsxs("p",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-body","data-testid":"standing",children:[t.jsx(Ne,{tone:$.tone,children:$.text}),t.jsx("span",{className:"min-w-0 break-words text-muted-foreground",children:_?`Its thresholds were refit: revision ${_.digest.slice(0,7)} serves in its place.`:N?Aa(N):y.digest?"No replay yet: a new revision replays on the last graded inputs before it serves.":"Its file did not read: no standing."})]}),A&&t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground","data-testid":"refit",children:N==null?void 0:N.reason}),c&&y.digest&&t.jsx(cz,{v2:c.v2,agentId:c.agentId,workflow:e.name,digest:y.digest,offered:!_&&oz($),resume:(N==null?void 0:N.decided)==="replaying"?N.replay_id??null:null,onStarted:c.onStarted,onDecided:c.onDecided},y.digest)]}),t.jsx("div",{className:"flex min-h-[280px] overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] p-4",children:t.jsx(xd,{graph:y.graph,marks:O,label:`The workflow at revision ${f+1} of ${j}, as a graph`,minScale:.5,maxScale:1.6,className:"m-auto"})}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(vd,{}),t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"font-semibold text-foreground",children:"NEW"})," first appears in this revision · ",t.jsx("span",{className:"font-semibold text-foreground",children:"EDITED"})," its prompt, code, inputs or tier changed",y.guards.length?t.jsxs(t.Fragment,{children:[" · ",t.jsx("span",{className:"font-semibold text-foreground",children:"jev ≥0.70"})," the step's guard: its signal and threshold"]}):null]})]}),t.jsx(ez,{guards:y.guards,workflow:e.name,digest:y.digest,loop:a}),(e.total>e.revisions.length||e.truncated||u>0)&&t.jsxs("p",{className:"text-body text-muted-foreground",children:[e.total>e.revisions.length&&`The latest ${e.revisions.length} of ${e.total} revisions. `,e.truncated&&"Older changes are past the log this server keeps. ",u>0&&`${u} ${u===1?"revision":"revisions"} could not be read as a workflow and ${u===1?"is":"are"} left out.`]})]})}const Xk=8,xz={promote:"success",hold:"warning",refit:"plain",revision:"active",queued:"plain",skipped:"muted"};function Zk({loop:e,promotions:n,serving:s=[],cost:r=null}){const[a,i]=p.useState(!1),c=[...((e==null?void 0:e.compiles)??[]).map(u=>({at:u.at,key:`c:${u.run_id}:${u.round}`,kind:"compile",compile:u})),...n.map((u,f)=>({at:u.at,key:`p:${f}`,kind:"promotion",record:u}))].sort((u,f)=>Date.parse(f.at)-Date.parse(u.at));if(!c.length)return null;const d=a?c:c.slice(0,Xk);return t.jsxs("section",{className:"border","aria-label":"Learning feed","data-testid":"loop-feed",children:[t.jsxs("h2",{className:"caps flex items-baseline gap-2 border-b px-4 py-3 text-small font-semibold",children:["Learning feed",t.jsx("span",{className:"font-mono font-normal text-muted-foreground",children:c.length})]}),t.jsx("ol",{className:"divide-y",children:d.map(u=>{var f;return t.jsx("li",{className:"min-w-0 px-4 py-3","data-testid":`feed-${u.kind}`,children:u.kind==="compile"?t.jsx(yz,{compile:u.compile,promotions:n,serving:((f=s.find(g=>g.workflow===u.compile.workflow))==null?void 0:f.digest)??null,stopped:u.compile.workflow?Bv(r,u.compile.workflow):null}):t.jsx(bz,{record:u.record})},u.key)})}),c.length>Xk&&t.jsx("div",{className:"flex justify-center border-t px-4 py-2",children:t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>i(u=>!u),children:a?"Show fewer":`Show all ${c.length}`})})]})}const vz=({id:e})=>t.jsxs("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",ta(e)]}),Q2=({at:e,run:n})=>t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[t.jsx("time",{dateTime:e,children:ht(e)}),n?t.jsxs(t.Fragment,{children:[" · ",t.jsx(vz,{id:n})]}):null]});function yz({compile:e,promotions:n,serving:s,stopped:r}){const a=e.digest===null||e.workflow===null,i=e.attempts.filter(u=>!u.ok),c=[...e.attempts.flatMap((u,f)=>u.ok?[]:u.errors.map(g=>({e:g,attempt:f+1}))),...e.draft_errors.map(u=>({e:u,attempt:null}))],d=a?null:Wc(Hv(n,e.workflow,e.digest),{serving:s,refit:T2(n,e.workflow,e.digest),stopped:r});return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a?t.jsx(Ne,{tone:"error",children:"Draft failed"}):t.jsx(Ne,{tone:"plain",children:"Compiled"}),e.workflow?t.jsx("span",{className:"min-w-0 break-all font-mono text-body font-semibold",children:e.workflow}):t.jsx("span",{className:"text-body text-muted-foreground",children:"no workflow kept"}),d&&t.jsx(Ne,{tone:d.tone,children:d.text})]}),e.from_notes.length>0&&t.jsxs("p",{className:"mt-1 break-words text-small text-muted-foreground",children:["From ",e.from_notes.length===1?"1 note":`${e.from_notes.length} notes`,": ",t.jsx("span",{className:"font-mono text-foreground",children:e.from_notes.join(", ")})]}),e.attempts.length>0&&t.jsxs("p",{className:"mt-0.5 text-small text-muted-foreground",children:[e.attempts.length===1?"1 attempt":`${e.attempts.length} attempts`,i.length?`, ${i.length} refused by the checks`:"",a?": it tries again on a later run.":"."]}),e.withheld?t.jsx("p",{className:"mt-1 text-small text-warning-text",role:"note",children:"The checks' words are withheld here: this run's handed values can't be read to cut them."}):c.length>0&&t.jsx("ul",{className:"mt-1 space-y-0.5","aria-label":"What the checks said","data-testid":"draft-errors",children:c.map(({e:u,attempt:f},g)=>t.jsxs("li",{className:"break-words font-mono text-small text-destructive-text",children:[f?`Attempt ${f}: `:"",u]},g))}),t.jsx(Q2,{at:e.at,run:e.run_id})]})}function bz({record:e}){var a;const n=$2(e),s=Wc(e,{serving:e.digest}),r=n==="promote"?s.tone:xz[n];return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(Ne,{tone:r,children:[Wv[n]," · ",Tc[n],s.proof?` · ${s.proof}`:""]}),t.jsx("span",{className:"min-w-0 break-all font-mono text-body font-semibold",children:e.workflow}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:e.digest.slice(0,7)})]}),t.jsx("p",{className:"mt-1 break-words text-small text-muted-foreground",children:Aa(e)}),(a=e.replay)!=null&&a.n?e.reason&&t.jsx("p",{className:"mt-0.5 line-clamp-2 break-words text-small text-muted-foreground",children:e.reason}):null,t.jsx(Q2,{at:e.at})]})}const wz={done:{icon:hl,word:"Done",ink:"text-success-text",edge:"border-t-success"},now:{icon:dT,word:"Next",ink:"text-run-active",edge:"border-t-run-active"},later:{icon:fT,word:"Later",ink:"text-muted-foreground",edge:"border-t-border"},warn:{icon:Gs,word:"Look",ink:"text-warning-text",edge:"border-t-warning"},watch:{icon:im,word:"Watch",ink:"text-foreground",edge:"border-t-border-strong"}};function e0({stages:e}){return e.length?t.jsx("section",{className:"border","aria-label":"The learning loop","data-testid":"loop-story",children:t.jsx("ol",{className:oe("grid grid-cols-1 gap-px bg-border sm:grid-cols-2",e.length===5?"lg:grid-cols-5":"lg:grid-cols-4"),children:e.map((n,s)=>{const r=wz[n.state],a=r.icon;return t.jsxs("li",{"data-testid":`stage-${n.key}`,"data-state":n.state,className:oe("min-w-0 border-t-2 bg-card px-4 py-3 sm:[&:last-child:nth-child(odd)]:col-span-2 lg:[&:last-child:nth-child(odd)]:col-span-1",r.edge),children:[t.jsxs("p",{className:"flex items-center gap-1.5 font-mono text-label",children:[t.jsxs("span",{className:"caps text-muted-foreground",children:[s+1," · ",n.title]}),t.jsxs("span",{className:oe("ml-auto inline-flex items-center gap-1",r.ink),children:[t.jsx(a,{className:"size-3.5","aria-hidden":!0}),t.jsx("span",{className:"caps",children:r.word})]})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-lead font-semibold","data-testid":`stage-${n.key}-value`,children:n.value}),t.jsx("p",{className:"mt-0.5 break-words text-small text-muted-foreground",children:n.detail})]},n.key)})})}):null}function J2({id:e,checked:n,onChange:s,busy:r,disabled:a,quiet:i,server:c,problem:d,className:u}){return t.jsxs("div",{className:oe("space-y-2",u),children:[t.jsxs("div",{className:oe("flex gap-4",i?"items-center":"items-start"),children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{id:e,className:"text-lead font-semibold",children:"Learns from its runs"}),!i&&t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:"After each run, it looks back and keeps a short note when something will help next time; later runs read them first."})]}),t.jsx(_m,{checked:n,onChange:s,busy:r,disabled:a,labelledBy:e})]}),c==="off"&&t.jsx("p",{className:"font-mono text-label text-warning-text",children:"This server has learning turned off, so no run learns until it's on."}),d]})}function jz({fields:e,onFields:n,saved:s,server:r,error:a,warning:i}){const c=e.learning??s,d=c===!0||c==="notes",u=f=>n({learning:f===!1&&s===void 0?void 0:f});return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"caps text-small font-semibold",children:"Learning"})}),t.jsx(J2,{id:"learning-switch",className:"border px-4 py-3",checked:d,server:r,onChange:f=>u(f?s==="notes"?"notes":!0:!1)}),d&&t.jsx("fieldset",{"aria-label":"What it learns",className:"mt-2 space-y-2",children:[[!0,"Notes, skills and workflows","Once a job repeats, it can learn it as a workflow and run it as one step."],["notes","Notes and skills only","It never runs a learned workflow, and is never asked to draft one."]].map(([f,g,b])=>t.jsxs("label",{className:oe("flex items-start gap-3 border px-3 py-2.5",c===f&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"learning-kind",className:"mt-1 accent-primary",checked:c===f,onChange:()=>u(f)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:g}),t.jsx("span",{className:"block text-small text-muted-foreground",children:b})]})]},String(f)))}),a&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:a}),i&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:i})]})}const kz="Not read: its front matter can't be read; fix the file to use it",Nz={approved:"Approved",edited:"Edited",created:"Created",retired:"Retired",restored:"Restored",learned:"Learned",superseded:"Replaced"},X2=(e,n)=>`${Nz[e]} by ${n==="person"?"you":"a run"}`,lx=e=>e.readme??e.file,bg="Can't tell which version this is: reload.",Wm="It changed since you opened it.",Sz=e=>e==="active"?"It becomes active again for the next run.":"It goes back to waiting for your OK: no run uses it until you approve it.",Cz=e=>`It makes a new agent that runs the steps of ${e} on their own, with no agent loop, under this agent's tool settings, approvals and cap. ${e} stays here, unchanged.`,Ez="Making an agent from it takes your password sign-in in the console.",$z="Restoring takes your password sign-in in the console.",Z2=["feedback","project","reference","user"],_z={user:"About you",feedback:"How to work",project:"About the work",reference:"Where to look"},eC=e=>_z[e]??e,Tz={feedback:"How to work: a rule or a correction",project:"Facts about the work itself",reference:"Where to find things",user:"About the person it works for"},Rz=["seeded","reflecting","proposed"],Hm=e=>!!e&&Rz.includes(e.state),yd=e=>Array.isArray(e)?e.filter(n=>!!n&&typeof n=="object"&&typeof n.file=="string"&&typeof n.name=="string"):[],tC=e=>yd(e==null?void 0:e.given),nC=e=>yd(e==null?void 0:e.read),Gc=e=>(e==null?void 0:e.state)==="merged"?yd(e.learned):[],Jv=e=>yd(e==null?void 0:e.pending),sC=e=>yd(e),t0=e=>(e==null?void 0:e.state)==="merged"?sC(e.skills):[],n0=e=>(e==null?void 0:e.state)==="merged"?sC(e.workflows):[],Az=e=>Jv(e).length>0,Lf=(e,n)=>`${e} ${n}${e===1?"":"s"}`,rC=e=>e.status==="pending",If=e=>{var n;return((n=e==null?void 0:e.learning)==null?void 0:n.pending)??0},Xv=e=>`${e} learned ${e===1?"item waits":"items wait"} for your OK`;function Oz(e){const n=e&&typeof e=="object"?e.learning:void 0;return n&&typeof n=="object"&&n.approve===!0?"yes":"password"}const oC="Approving needs your password sign-in. Until then it stays out of every run.",Mz="It changes what this agent trusts or skips, so it waits for you.",Pz="Runs that use bash on the host run as you. For untrusted tasks, use the sandbox.",aC="[redacted]",iC=e=>e===1?"1 note waits for your OK":e>1?`${e} notes wait for your OK`:"A note waits for your OK",Xi=e=>`${e} ${e===1?"note":"notes"}`,Ba=e=>`${e} ${e===1?"run":"runs"}`,Lz={grader:"refused",checker:"refused",screen:"refused",screen_down:"refused",unparsed:"refused",empty:"nothing",no_budget:"skipped",unknown_cost:"skipped",no_write_tool:"skipped",tool_denied:"skipped"},zf=e=>Lz[e??""]??"stopped",Iz={empty:"Nothing new to remember from this run.",unparsed:"Not kept: its notes weren't in the expected format.",grader:"Not kept: it wouldn't help later runs enough.",checker:"Not kept: it held something that must not be stored.",screen:"Not kept: it held something that must not be stored.",screen_down:"Not kept: it couldn't be checked for safety.",no_write_tool:"Not kept: this agent can't write notes (give it the write tool).",tool_denied:"Not kept: this agent isn't allowed to write notes.",no_budget:"Skipped: no budget left in this run to look back.",unknown_cost:"Skipped: no budget left in this run to look back.",seed_failed:"Started without its notes: they couldn't be read.",cancelled:"Not kept: learning stopped (the run was cancelled).",crashed:"Not kept: learning stopped (the run ended unexpectedly).",reflect_timeout:"Not kept: learning stopped (it ran out of time).",reflect_failed:"Not kept: learning stopped (an error).",propose_failed:"Not kept: learning stopped (an error).",grade_failed:"Not kept: learning stopped (the check couldn't run)."};function Zv(e){return e.detail&&e.detail.trim()?e.detail.trim():Iz[e.reason??""]??"Not kept: learning stopped."}const zz=e=>e==="seeded"?"Learns after the run":"Looking back",Df=e=>dl(Math.round(e)*1e3),Oa=e=>eo({usd:e,basis:"estimate",charge_state:null,cap_usd:null}),s0=(e,n)=>e>0?Math.round((n-e)/e*100):null,lC=e=>typeof e.before.median_cost_usd=="number"&&typeof e.after.median_cost_usd=="number",cC=e=>e.after.median_learning_usd;function Dz(e){const n=[`answers in ${Df(e.after.median_duration_s)} instead of ${Df(e.before.median_duration_s)}`];lC(e)&&n.push(`${Oa(e.after.median_cost_usd)} instead of ${Oa(e.before.median_cost_usd)} a run`);const s=cC(e);return s!==null&&n.push(`learning itself ${Oa(s)} a run`),`Since it learned (${dC(e)}): ${n.join(" · ")}`}function dC(e){return`medians of ${Ba(e.after.runs)} started from what it learned`}const Fz=e=>{const n=s=>!!s&&typeof s=="object"&&typeof s.runs=="number"&&s.runs>=2&&typeof s.median_duration_s=="number";return!!e&&typeof e=="object"&&n(e.before)&&n(e.after)},Uz=/^---\n([\s\S]*?)\n?^---$\n?/m,cx=e=>/^"[^"]*"$|^'[^']*'$/.test(e)?e.slice(1,-1):e;function Ff(e){const n=e.replace(/\r\n/g,`
|
|
629
|
+
`),s=n.startsWith(`---
|
|
630
|
+
`)?Uz.exec(n):null;if(!s||s.index!==0)return{name:"",description:"",type:"project",body:n,rest:[]};const r={},a=[];for(const c of s[1].split(`
|
|
631
|
+
`)){const d=/^(name|description|type):(?:\s+(.*))?$/.exec(c);d&&!(d[1]in r)?r[d[1]]=cx((d[2]??"").trim()):c.trim()&&a.push(c)}const i=Z2.includes(r.type??"")?r.type:"project";return{name:r.name??"",description:r.description??"",type:i,body:n.slice(s[0].length),rest:a}}const r0=e=>{const n=e.replace(/\s*\n\s*/g," ").trim();return/^["'].*["']$/.test(n)?n.includes('"')?`'${n}'`:`"${n}"`:n},Wz=e=>`---
|
|
632
|
+
name: ${r0(e.name)}
|
|
633
|
+
description: ${r0(e.description)}
|
|
634
|
+
type: ${e.type}
|
|
635
|
+
${e.rest.map(n=>`${n}
|
|
636
|
+
`).join("")}---
|
|
637
|
+
${e.body.replace(/^\n*/,`
|
|
638
|
+
`)}`;function Hz(e){const n=Ff(e).rest.find(r=>/^supersedes:/.test(r)),s=n?cx(n.replace(/^supersedes:\s*/,"").trim()).trim():"";return s?(/^\[.*\]$/.test(s)?s.slice(1,-1).split(","):[s]).map(r=>cx(r.trim())).filter(Boolean):[]}const qc=e=>Ff(e).body.replace(/^\n+/,"");function o0(e,n=[]){const s=e.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"note";let r=`${s}.md`;for(let a=2;n.includes(r);a++)r=`${s}-${a}.md`;return r}const Bm=(e,n=[])=>{const s=n.filter(a=>a!==aC),r=new URLSearchParams(s.map(a=>["note",a]));return`#/agents/${encodeURIComponent(e)}/learning${s.length?`?${r}`:""}`};function uC(e){return e.kind===Gr?{...e,agent_label:null}:e.kind==="user_message"&&e.agent_label===Gr?{...e,kind:Gr,agent_label:null}:e}const Gr="learning",Bz={seeded:0,reflecting:1,proposed:2,merged:3,dropped:3},dx=e=>e?Bz[e.state]??0:-1,Gz=e=>{const n=e==null?void 0:e.learning;return n&&typeof n=="object"&&typeof n.state=="string"?n:void 0},a0=e=>e.charAt(0).toLowerCase()+e.slice(1);function qz(e){var s,r;if(!e||dx(e)<2)return"Looking back on this run…";if(e.state==="proposed")return`Looking back: ${a0(((s=e.detail)==null?void 0:s.trim())||"Checking its new notes…")}`;const n=a=>a.map(i=>i.name.replace(/\s+/g," ").trim()).join(", ");if(e.state==="merged"){const a=Gc(e),i=Jv(e),c=[...a.length?[`kept ${Xi(a.length)} (${n(a)})`]:[],...i.length?[`${a0(iC(i.length))} (${n(i)})`]:[]];return c.length?`Looked back: ${c.join("; ")}`:`Looked back. ${((r=e.detail)==null?void 0:r.trim())||"It kept what it learned."}`}return zf(e.reason)==="nothing"?"Looked back: nothing new to keep":`Looked back: ${Zv(e)}`}function Kz(e){var i;const n=uC(e),s=n.summary??"",r=JS(n)?`${s} (failed)`:s,a=(i=YS(n))==null?void 0:i.trimEnd();return a&&a.trim()!==s.trim()?`${r}
|
|
639
|
+
${a.replace(/^(?=.)/gm," ")}`:r}function Vz(e,n){const s=e.filter(u=>u.agent_label===Gr&&u.kind!==Gr);if(!s.length)return e.map(uC);const r=e.findLast(u=>u.kind===Gr),a=Gz(r),i=dx(a)>dx(n??void 0)?a:n&&{...n,detail:n.detail??(a==null?void 0:a.detail)??(r==null?void 0:r.summary)??null},c=s[0],d={id:c.id,seq:c.seq,timestamp:c.timestamp,created_at:c.created_at,kind:Gr,agent_label:null,tool_name:null,tool_use_id:null,tool_status:null,tool_input_preview:null,tool_result_preview:null,tool_result_size_bytes:null,summary:qz(i??void 0),text:[...s,...r?[r]:[]].map(Kz).join(`
|
|
640
|
+
`)};return e.flatMap(u=>u===c?[d]:u.agent_label===Gr||u.kind===Gr?[]:[u])}const Yz={too_large:"It's too large to show here.",secret:"Not shown: it holds one of this server's secrets."},i0=["Added","Replaced","Retired","Removed","Changed"];function Qz(e){const n=[],s=[];let r=0;for(const a of e.split(`
|
|
641
|
+
`)){const i=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(a);i?((r||Number(i[1])>1)&&n.push({text:"…",mark:"gap"}),(r||Number(i[2])>1)&&s.push({text:"…",mark:"gap"}),r++):r&&a.startsWith(" ")?(n.push({text:a.slice(1),mark:"same"}),s.push({text:a.slice(1),mark:"same"})):r&&a.startsWith("-")?n.push({text:a.slice(1),mark:"removed"}):r&&a.startsWith("+")&&s.push({text:a.slice(1),mark:"added"})}return{before:n,after:s}}function Jz(e,n){const s=e.files.filter(d=>d.path!=="MEMORY.md"),r=new Map(s.map(d=>[d.path,d.patch===void 0?null:Qz(d.patch)])),a=new Map([...tC(n),...nC(n),...Gc(n)].map(d=>[d.file,d.name])),i=d=>{const u=r.get(d),f=[...(u==null?void 0:u.after)??[],...(u==null?void 0:u.before)??[]].find(g=>g.mark!=="gap"&&/^name:\s*\S/.test(g.text));return a.get(d)??(f==null?void 0:f.text.replace(/^name:\s*/,"").trim())??d.replace(/\.md$/,"")};return s.map(d=>{var h,v;const u=r.get(d.path),f=i(d.path),g=((u==null?void 0:u.after)??[]).filter(y=>y.mark==="added").map(y=>y.text.trim()),b=((h=g.find(y=>y.startsWith("superseded_by:")))==null?void 0:h.replace(/^superseded_by:\s*/,""))??((v=Gc(n).find(y=>{var j;return(j=y.supersedes)==null?void 0:j.includes(d.path)}))==null?void 0:v.file),x=d.status==="added"?`Added: ${f}`:d.status==="deleted"?`Removed: ${f}`:g.includes("status: superseded")||!u&&b?`Replaced: ${f}${b?` → ${i(b)}`:""}`:g.includes("status: retired")?`Retired: ${f}`:`Changed: ${f}`;return u?{file:d.path,said:x,before:d.status==="added"?null:u.before,after:d.status==="deleted"?null:u.after}:{file:d.path,said:x,before:null,after:null,withheld:Yz[d.withheld??""]??"Not shown."}}).sort((d,u)=>i0.indexOf(d.said.split(":")[0])-i0.indexOf(u.said.split(":")[0]))}function Xz(e){const n=new Map;for(const s of e)for(const r of s.files){const a=n.get(r)??{};"run"in s.by&&(a.run={id:s.by.run,at:s.at,reason:s.reason}),n.set(r,a)}return n}function bd(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const n=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function dr(e=bd){let n=null;return{keyFor(s,r){const a=JSON.stringify([s,r]);return(n==null?void 0:n.request)!==a&&(n={request:a,key:e()}),n.key},done(){n=null}}}async function fC(e,n,s,r){const a=await r(n,s,e.keyFor(n,{content:s}));return e.done(),a}function Zz(e=bd){const n=new Map;return s=>{let r=n.get(s);return r||(r=dr(e),n.set(s,r)),r}}function ux(e,n){const s=new Set(e.map(r=>r.run_id));return[...e,...n.filter(r=>!s.has(r.run_id))]}const Xa=(e,n,s)=>({...$r(e,n),title:s}),eD=(e,n)=>{const s=e.get(n);return s!=null&&s.title?Sn(s):`run ${ta(n)}`},mC="text-lead leading-[1.65] [&_a]:text-primary-text [&_a]:underline [&_a]:underline-offset-2 [&_code]:bg-muted [&_code]:px-1 [&_code]:font-mono [&_code]:text-body [&_h1]:mb-2 [&_h1]:text-prose [&_h1]:font-semibold [&_h2]:mb-2 [&_h2]:mt-3 [&_h2]:text-lead [&_h2]:font-semibold [&_h3]:mt-3 [&_h3]:font-semibold [&_li]:mb-0.5 [&_ol]:mb-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p]:mb-2 [&_p:last-child]:mb-0 [&_pre]:mb-2 [&_pre]:overflow-x-auto [&_pre]:border [&_pre]:bg-background [&_pre]:p-3 [&_pre]:font-mono [&_pre]:text-small [&_ul]:mb-2 [&_ul]:list-disc [&_ul]:pl-5",tD=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),l0=20,nD=15e3;function kr(e,n=!1){const[s,r]=p.useState(n),a=p.useRef(Symbol("learning interaction")).current;return p.useEffect(()=>()=>{e.items.delete(a),e.changed(e.items.size>0)},[e,a]),[s,c=>{c?e.items.add(a):e.items.delete(a),e.changed(e.items.size>0),r(c)}]}function sD(e){return t.jsx(rD,{...e},e.agent.agent_id)}function rD({agent:e,v2:n,focus:s=[],server:r,onAgent:a,places:i,onChanged:c}){var zt;const[d,u]=p.useState(null),[f,g]=p.useState(null),[b,x]=p.useState([]),[h,v]=p.useState([]),[y,j]=p.useState([]),[k,E]=p.useState(null),[S,N]=p.useState(null),[_,$]=p.useState({items:[],cursor:null,pages:0}),[O,A]=p.useState({items:[],cursor:null,pages:0}),[L,M]=p.useState(!1),R=p.useMemo(()=>({items:new Set,changed:M}),[]),[P,D]=kr(R),[W,Y]=p.useState(0),H=p.useRef(0),q=p.useRef(!1),F=p.useRef(!0),G=p.useRef(!1),[U,z]=p.useState(!1),Q=p.useRef(()=>!1);Q.current=()=>!P&&!R.items.size&&!q.current&&_.pages===0;const K=ye=>{const le=ye==="background";if(!F.current||le&&(G.current||!Q.current()))return Promise.resolve();const Ue=++H.current;G.current=!0,z(!0),q.current=!1,g(null);const Xe=()=>F.current&&Ue===H.current&&(ye==="write"||!R.items.size)&&(!le||Q.current()),rt=n.agentLearning(e.agent_id).then(J=>{Xe()&&(u(J),$({items:[],cursor:J.notes.next_cursor,pages:0}),A({items:[],cursor:J.log.next_cursor,pages:0}))},J=>{Xe()&&g(J??new Error("unknown"))});return n.listAgentRuns(e.agent_id,50,null,!!e.archived_at).then(J=>{Xe()&&x(J.runs)},()=>{}),Promise.resolve().then(()=>n.learningPromotions(e.agent_id)).then(J=>{Xe()&&(v(J.promotions),j(J.serving))},()=>{}),Promise.resolve().then(()=>n.learningLoop(e.agent_id)).then(J=>{Xe()&&E(J)},()=>{}),rt.finally(()=>{Ue===H.current&&(G.current=!1,z(!1))})},Z=()=>K("manual"),de=p.useRef(()=>{});de.current=()=>{document.hidden||K("background")},p.useEffect(()=>{F.current=!0,Z();const ye=()=>de.current();window.addEventListener("focus",ye),document.addEventListener("visibilitychange",ye);const le=window.setInterval(ye,nD);return()=>{F.current=!1,H.current++,window.removeEventListener("focus",ye),document.removeEventListener("visibilitychange",ye),window.clearInterval(le)}},[n,e.agent_id,e.archived_at]);const se=()=>(c==null||c(),K("write")),ue=()=>{if(!_.cursor||q.current)return;const ye=H.current;q.current=!0,n.learningNotes(e.agent_id,_.cursor).then(le=>{ye===H.current&&(q.current=!1,$(Ue=>({items:[...Ue.items,...le.items.filter(Xe=>!Ue.items.some(rt=>rt.file===Xe.file))],cursor:le.next_cursor,pages:Ue.pages+1})))},le=>{ye===H.current&&(q.current=!1,$(Ue=>({...Ue,error:le??new Error("unknown")})))})},xe=e.definition.learning===!0||e.definition.learning==="notes",$e=!!e.archived_at,ge=p.useMemo(()=>[...(d==null?void 0:d.notes.items)??[],..._.items],[d,_.items]),fe=ge.filter(ye=>ye.status==="active"),me=ge.filter(rC),je=(d==null?void 0:d.skills)??[],Me=(d==null?void 0:d.workflows)??[],[_e,re]=p.useState(void 0),Ze=me.length>0||[...je,...Me].some(ye=>ye.status==="pending")||Me.some(ye=>ye.status==="active");p.useEffect(()=>{if(!Ze||_e!==void 0)return;let ye=!0;return Promise.resolve().then(()=>n.capabilities()).then(le=>{ye&&re(Oz(le))},()=>{ye&&re("password")}),()=>{ye=!1}},[Ze]);const at=ge.filter(ye=>ye.status==="superseded"||ye.status==="retired"),pt=p.useMemo(()=>{const ye=new Map(ge.map(Ue=>[Ue.file,Ue])),le=new Map;for(const Ue of ge){if(Ue.status==="superseded")continue;const rt=[...new Set([...Hz(Ue.text),...ge.filter(J=>J.status==="superseded"&&J.superseded_by===Ue.file).map(J=>J.file)])].flatMap(J=>{const ve=ye.get(J);return ve?ve.status==="superseded"&&ve.superseded_by===Ue.file?[{file:J,name:ve.name}]:[]:[{file:J,name:null}]});rt.length&&le.set(Ue.file,rt)}return le},[ge]),Ee=p.useMemo(()=>new Map(b.map(ye=>[ye.run_id,ye])),[b]),Je=p.useMemo(()=>Xz([...(d==null?void 0:d.log.items)??[],...O.items]),[d,O.items]),he=s.filter(ye=>!ge.some(le=>le.file===ye)).length>0;p.useEffect(()=>{d&&he&&_.cursor&&_.error===void 0&&_.pages<l0&&ue()},[d,he,_.cursor,_.pages]);const Fe=ge.some(ye=>!Je.has(ye.file));p.useEffect(()=>{if(!d||!Fe||!O.cursor||O.pages>=l0)return;const ye=H.current;n.learningLog(e.agent_id,O.cursor).then(le=>{ye===H.current&&A(Ue=>({items:[...Ue.items,...le.items],cursor:le.next_cursor,pages:Ue.pages+1}))},()=>{ye===H.current&&A(le=>({...le,cursor:null}))})},[d,Fe,O.cursor]);const ut=b.filter(ye=>ye.learning&&(ye.learning.state==="merged"||ye.learning.state==="dropped")).length,Pe=e.definition.native?"native":Zn(e.definition)?"sdk":"hosted",ct=AL({notes:fe.length,compiledNotes:ge.filter(ye=>ye.status!=="retired"&&R2(ye.text)!==null).length,runs:b.filter(ye=>ye.status==="completed").length,workflows:Me,cost:S,promotions:h,serving:y,loop:k,mode:e.definition.learning==="notes"?"notes":"full",execution:Pe}),_t=ye=>t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Refresh learning",title:"Refresh learning",disabled:L||U,onClick:()=>{!R.items.size&&!G.current&&Z()},children:t.jsx(Qo,{className:oe(U&&"animate-spin"),"aria-hidden":!0})})}),ye]});if(f&&!d)return _t(t.jsx(ns,{problem:$r(f,"what this agent learned"),onRetry:Z,className:""}));if(!d)return _t(t.jsx(aD,{}));const tt=f?t.jsx(oD,{error:f,onRetry:Z}):null,ft=ye=>t.jsx(lD,{agent:e,v2:n,onAgent:a,server:r,disabled:$e,quiet:ye}),qt=xe&&!$e&&(Pe==="hosted"?t.jsx(VL,{v2:n,agentId:e.agent_id,onFinished:()=>{Y(ye=>ye+1),Z()}}):t.jsxs(vt,{tone:"info",children:[Pe==="native"?"Run tasks with this agent’s original Claude Code or Codex setup.":"Start tasks in your backend using this agent’s SDK wrapper."," Accepted notes and skills remain available here. CSV learning batches require server-managed execution. ",t.jsx("a",{href:ln(e.agent_id,"runs"),className:"underline underline-offset-2",children:"Open the agent’s Run controls"}),"."]}));return!ge.length&&!je.length&&!Me.length&&!P?_t(t.jsxs("div",{className:"space-y-6",children:[tt,t.jsx(uD,{on:xe,lookedBack:ut,switchRow:ft(!0),onAdd:$e?void 0:()=>D(!0)}),xe&&t.jsx(e0,{stages:ct}),t.jsx(Fk,{v2:n,agentId:e.agent_id,quiet:!0}),qt,t.jsx(Ok,{v2:n,agentId:e.agent_id,on:xe,quiet:!0,promotions:h,onCost:N,execution:Pe},W),t.jsx(Zk,{loop:k,promotions:h,serving:y,cost:S}),t.jsx(d0,{runs:b})]})):_t(t.jsxs("div",{className:"space-y-6",children:[me.length>0&&t.jsxs("section",{className:"border border-warning/50","aria-label":"Waiting for your OK",children:[t.jsxs("h2",{className:"caps flex items-baseline gap-2 border-b border-warning/50 px-4 py-3 text-small font-semibold",children:["Waiting for your OK",t.jsx("span",{className:"font-mono font-normal text-muted-foreground",children:me.length})]}),t.jsx("p",{className:"px-4 pt-3 text-body text-muted-foreground",children:Mz}),((zt=S2(e,i))==null?void 0:zt.place.mode)==="runner"&&(e.definition.tools??[]).includes("bash")&&t.jsx("p",{className:"px-4 pt-1 text-body text-muted-foreground",children:Pz}),t.jsx("ul",{className:"space-y-3 p-4",children:me.map(ye=>t.jsx("li",{children:t.jsx(c0,{note:ye,v2:n,agentId:e.agent_id,readOnly:$e,focused:s.includes(ye.file),from:Je.get(ye.file),runs:Ee,onChanged:se,refreshHolds:R,approves:_e,replaces:pt.get(ye.file)})},ye.file))})]}),t.jsx(e0,{stages:ct}),t.jsx(Fk,{v2:n,agentId:e.agent_id}),Fz(d.impact)&&t.jsx(iD,{impact:d.impact}),qt,t.jsx(Ok,{v2:n,agentId:e.agent_id,on:xe,promotions:h,onCost:N,execution:Pe},W),t.jsx(hz,{v2:n,agentId:e.agent_id,workflows:Me,promotions:h,serving:y,loop:k,cost:S,onReplayed:()=>{Z()}}),t.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[t.jsxs("div",{className:"min-w-0 space-y-6",children:[t.jsxs("section",{className:"min-w-0 space-y-3","aria-label":"Notes",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-x-4 gap-y-2",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"What it has learned"}),t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:fe.length?`${Xi(fe.length)} in use. Every later run reads ${fe.length===1?"it":"them"} before it starts.`:[...je,...Me].some(ye=>ye.status==="active")?"No note is in use.":"No note is in use: the next run starts with nothing learned."})]}),!$e&&!P&&t.jsxs(B,{size:"sm",onClick:()=>D(!0),children:[t.jsx(pl,{"aria-hidden":!0})," Add a note"]})]}),tt,!xe&&t.jsx(dD,{server:r}),P&&t.jsx(vC,{title:"New note",v2:n,agentId:e.agent_id,taken:ge.map(ye=>ye.file),onDone:ye=>{D(!1),ye&&se()}},"new"),t.jsx("ul",{className:"space-y-3",children:fe.map(ye=>t.jsx("li",{children:t.jsx(c0,{note:ye,v2:n,agentId:e.agent_id,readOnly:$e,focused:s.includes(ye.file),from:Je.get(ye.file),runs:Ee,onChanged:se,refreshHolds:R,replaces:pt.get(ye.file)})},ye.file))}),_.error!==void 0&&t.jsx(ns,{problem:$r(_.error,"more notes"),onRetry:ue,className:""}),_.cursor&&t.jsx("div",{className:"flex justify-center",children:t.jsx(B,{size:"sm",onClick:ue,children:"Load more notes"})}),at.length>0&&t.jsx(gD,{notes:at,all:ge,from:Je,focus:s,runs:Ee,v2:n,agentId:e.agent_id,readOnly:$e,onChanged:se,refreshHolds:R})]}),["skill","workflow"].map(ye=>{const le=ye==="skill"?je:Me;if(!le.length)return null;const Ue=ye==="skill"?"Skills it learned":"Workflows it learned",Xe=le.filter(J=>J.status!=="retired"),rt=le.filter(J=>J.status==="retired");return t.jsxs("section",{className:"min-w-0 space-y-3","aria-label":Ue,children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold",children:Ue}),t.jsx("p",{className:"mt-0.5 text-body text-muted-foreground",children:Xe.length?ye==="skill"?`${Lf(Xe.length,"skill")}: how to do a job it does again, given to every later run once active.`:`${Lf(Xe.length,"workflow")}: a job it does again, as steps a later run can call.`:`No ${ye} is in use: the next run gets none.`})]}),Xe.length>0&&t.jsx("ul",{className:"space-y-3",children:Xe.map(J=>t.jsx("li",{children:t.jsx(fD,{item:J,kind:ye,v2:n,agentId:e.agent_id,readOnly:$e,runs:Ee,approves:_e,onChanged:se,refreshHolds:R})},J.file))}),rt.length>0&&t.jsx(xD,{kind:ye,items:rt,v2:n,agentId:e.agent_id,runs:Ee,readOnly:$e,onChanged:se,refreshHolds:R})]},ye)})]}),t.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"About learning",children:[t.jsx(hC,{title:"Learning",children:ft(!1)}),t.jsx(Zk,{loop:k,promotions:h,serving:y,cost:S}),t.jsx(d0,{runs:b}),t.jsx(yD,{index:d.index,skills:je.filter(ye=>ye.status==="active").map(ye=>ye.name),off:!xe||r==="off"})]})]})]}))}function oD({error:e,onRetry:n}){const s=$r(e,"the notes"),r=[s.said,s.code].filter(Boolean).join(" · ");return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border border-destructive/40 px-3 py-2 text-body",role:"alert",title:r||void 0,children:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't refresh the notes: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)," What's shown may be out of date."]}),t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})]})}function hC({title:e,children:n,label:s}){return t.jsxs("section",{className:"border","aria-label":s??e,children:[t.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:e}),n]})}function aD(){const e="block bg-muted motion-safe:animate-pulse";return t.jsxs("div",{className:"space-y-3",role:"status","aria-busy":"true","aria-label":"Loading what it learned",children:[t.jsx("span",{"aria-hidden":!0,className:oe(e,"h-6 w-56")}),[0,1,2].map(n=>t.jsxs("div",{"aria-hidden":!0,className:"space-y-3 border p-5",children:[t.jsx("span",{className:oe(e,"h-4 w-1/3")}),t.jsx("span",{className:oe(e,"h-3 w-2/3 bg-muted/70")}),t.jsx("span",{className:oe(e,"h-3 w-1/2 bg-muted/70")})]},n)),t.jsx("span",{className:"sr-only",children:"Loading what it learned…"})]})}function iD({impact:e}){const{before:n,after:s}=e,r=[{label:"Answers in",now:Df(s.median_duration_s),was:Df(n.median_duration_s),delta:s0(n.median_duration_s,s.median_duration_s)},...lC(e)?[{label:"A run costs",now:Oa(s.median_cost_usd),was:Oa(n.median_cost_usd),delta:s0(n.median_cost_usd,s.median_cost_usd)}]:[]],a=cC(e),i=[`Medians of ${Ba(n.runs)} before it first learned and ${Ba(s.runs)} that started from what it learned (a note, a skill or a workflow).`,`Costs are of the ${n.cost_runs} and ${s.cost_runs} runs whose cost is known.`].join(" ");return t.jsx("section",{className:"border","aria-label":Dz(e),children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-4 px-4 py-3",children:[t.jsxs("div",{className:"flex items-baseline gap-2.5",children:[t.jsx("span",{className:"caps text-small font-semibold",children:"Since it learned"}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",title:i,children:dC(e)})]}),t.jsxs("dl",{className:"flex flex-1 flex-wrap items-baseline gap-x-10 gap-y-3","aria-hidden":!0,children:[r.map(c=>t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:c.label}),t.jsxs("dd",{className:"flex items-baseline gap-2 font-mono",children:[t.jsx("span",{className:"text-figure font-semibold leading-none",children:c.now}),t.jsxs("span",{className:"text-small text-muted-foreground",children:["instead of ",c.was]}),c.delta!==null&&c.delta!==0&&t.jsxs("span",{className:oe("text-small",c.delta<0?"text-primary-text":"text-warning-text"),children:[c.delta>0?"+":"−",Math.abs(c.delta),"%"]})]})]},c.label)),a!==null&&t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Learning itself"}),t.jsxs("dd",{className:"font-mono text-body text-muted-foreground",children:[Oa(a)," a run"]})]})]})]})})}function lD(e){return e.agent.definition.native?t.jsx("div",{className:"p-4",children:t.jsx(E2,{agent:e.agent,v2:e.v2,learning:e.server,onAgent:e.onAgent})}):t.jsx(cD,{...e})}function cD({agent:e,v2:n,onAgent:s,server:r,disabled:a,quiet:i}){const[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,b]=p.useState(null),x=async h=>{d(!0),f(null),b(h);try{const{agent:v,etag:y}=await n.getAgent(e.agent_id),j=ud(v,{learning:h},h?"Learning on":"Learning off");if(j.unchanged)s==null||s(v);else{const{unchanged:k,...E}=j;s==null||s((await n.updateDefinition(e.agent_id,E,y)).agent)}}catch(v){f(v??new Error("unknown"))}b(null),d(!1)};return t.jsx(J2,{id:`learns-${e.agent_id}`,className:"px-4 py-4",quiet:i,checked:g??(e.definition.learning===!0||e.definition.learning==="notes"),onChange:h=>void x(h),busy:c,disabled:a,server:r,problem:u?t.jsx(ns,{problem:Xa(u,"the agent","Learning was not changed."),className:"mt-2"}):null})}function dD({server:e}){return t.jsxs(vt,{tone:"warning",children:["Learning is off",e==="off"?" on this server":"",", so later runs don't read these notes. They're kept for when it's back on."]})}function uD({on:e,lookedBack:n,switchRow:s,onAdd:r}){return t.jsxs("section",{className:"mx-auto max-w-xl border","aria-label":"Learning",children:[t.jsxs("div",{className:"px-6 py-12 text-center",children:[t.jsx(Gx,{className:"mx-auto mb-3 size-5 text-primary-text","aria-hidden":!0}),t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:e?"Nothing learned yet.":"Learning is off for this agent."}),t.jsx("p",{className:"mx-auto mt-2 max-w-md text-lead text-muted-foreground",children:e?"After each run, it looks back and keeps a note when something will help next time. Its notes show here, and every later run reads them first.":"With learning on, it keeps short notes on what worked after each run, and every later run reads them before it starts."}),e&&n>0&&t.jsxs("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:[Ba(n)," looked back: nothing worth keeping yet."]})]}),t.jsx("div",{className:"border-t",children:s}),r&&t.jsx("div",{className:"flex justify-center border-t px-4 py-3",children:t.jsxs(B,{size:"sm",variant:"ghost",onClick:r,children:[t.jsx(pl,{"aria-hidden":!0})," Or write a note yourself"]})})]})}function c0({note:e,v2:n,agentId:s,readOnly:r,focused:a,from:i,runs:c,onChanged:d,approves:u,refreshHolds:f,replaces:g=[]}){const[b,x]=p.useState(!1),[h,v]=kr(f),[y,j]=kr(f),[k,E]=p.useState(a),[S,N]=p.useState(null),[_,$]=kr(f),[O,A]=p.useState(null),L=p.useRef(null),M=rC(e),R=async()=>{const Y=H=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:H});$(!0),A(null);try{await n.approveNote(s,e.file,e.etag)}catch(H){$(!1),A(H instanceof De&&zm(H).kind==="conflict"?Y(`${Wm} Reload the tab to see the newest version.`):t.jsx(ns,{problem:Xa(H,"the note","The note was not approved."),className:""}));return}await d(),$(!1)};if(p.useEffect(()=>{var H,q;if(!a)return;E(!0),(q=(H=L.current)==null?void 0:H.scrollIntoView)==null||q.call(H,{block:"center",behavior:"smooth"});const Y=setTimeout(()=>E(!1),2600);return()=>clearTimeout(Y)},[a]),p.useEffect(()=>{if(!S)return;const Y=setTimeout(()=>N(null),2400);return()=>clearTimeout(Y)},[S]),h)return t.jsx(vC,{title:"Edit note",v2:n,agentId:s,file:e.file,seen:e,onDone:Y=>{v(!1),Y&&(N("Saved"),d())}});const P=qc(e.text),D=fx(e.last_change),W=R2(e.text);return t.jsxs("article",{ref:L,id:`note-${e.file}`,tabIndex:-1,"aria-label":e.name,className:oe("border bg-card/40 outline-none focus-visible:border-primary transition-[border-color,box-shadow] duration-slow",k&&"border-primary ring-1 ring-primary"),children:[t.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words text-prose font-semibold leading-snug",children:e.name}),t.jsx(Ne,{children:eC(e.type)}),e.origin==="you"&&t.jsx(Ne,{tone:"muted",children:"From you"}),W&&t.jsxs(Ne,{tone:"success",label:!0,title:`This note went into the learned workflow ${W}`,children:["Compiled into ",W]}),S&&t.jsx("span",{className:"caps text-micro text-success-text",role:"status",children:S})]}),t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),M&&u==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:oC})]}),!r&&!y&&t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[M?u==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void R(),disabled:_,"aria-label":`Approve ${e.name}`,children:_?"Approving":"Approve"}):t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>v(!0),"aria-label":`Edit ${e.name}`,children:[t.jsx(Hx,{"aria-hidden":!0})," Edit"]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>j(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]})]}),O&&t.jsx("div",{className:"px-5 pt-3",children:O}),P.trim()&&t.jsx(qm,{text:P}),t.jsxs("footer",{className:"flex flex-wrap items-center gap-x-5 gap-y-1.5 border-t px-5 py-2.5 font-mono text-label text-muted-foreground",children:[(i==null?void 0:i.run)&&t.jsx(Gm,{run:i.run.id,runs:c,at:i.run.at,reason:i.run.reason}),D&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(qx,{className:"size-3","aria-hidden":!0}),D]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(gf,{className:"size-3","aria-hidden":!0}),"Given to ",Ba(e.runs.given)]}),e.runs.read>0&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(gf,{className:"size-3","aria-hidden":!0}),"Read in ",Ba(e.runs.read)]}),g.length>0&&t.jsxs("button",{type:"button",onClick:()=>x(Y=>!Y),"aria-expanded":b,className:"flex items-center gap-1.5 hover:text-foreground",children:[t.jsx(wT,{className:"size-3","aria-hidden":!0}),"Replaces ",g.length," older ",g.length===1?"note":"notes",t.jsx(Rr,{className:oe("size-3 transition-transform",b&&"rotate-180"),"aria-hidden":!0})]})]}),b&&g.length>0&&t.jsx("ul",{"aria-label":"Notes it replaces",className:"space-y-1 border-t px-5 py-2.5 text-body text-muted-foreground",children:g.map(Y=>t.jsx("li",{className:oe("break-words",Y.name===null&&"font-mono text-small"),children:Y.name??Y.file},Y.file))}),y&&t.jsx(gC,{name:e.name,kind:"note",retire:()=>n.retireNote(s,e.file,e.etag),onDone:async Y=>{Y&&await d(),j(!1)}})]})}function fD({item:e,kind:n,v2:s,agentId:r,readOnly:a,runs:i,approves:c,onChanged:d,refreshHolds:u}){const[f,g]=kr(u),[b,x]=p.useState(null),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,E]=kr(u),[S,N]=kr(u),[_,$]=p.useState(null),O=e.status==="pending",[A,L]=kr(u),M=p.useRef(dr()).current,[R,P]=p.useState(null),D=n==="workflow"&&e.status==="active"&&c==="yes",W=async()=>{j(null),x(null),v(null);try{const G=await s.readNote(r,e.file);x(G.note),v(G.etag)}catch(G){j(G??new Error("unknown"))}},Y=async()=>{if(f)return g(!1);g(!0),b===null&&await W()};p.useEffect(()=>{b===null&&h===null||(f?W():(x(null),v(null)))},[e.etag]);const H=n==="skill"&&f&&h?h:e.etag,q=async()=>{E(!0),$(null);try{await s.approveNote(r,lx(e),H)}catch(G){E(!1),$(G instanceof De&&zm(G).kind==="conflict"?t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${Wm} Reload the tab to see the newest version.`}):t.jsx(ns,{problem:Xa(G,`the ${n}`,`The ${n} was not approved.`),className:""}));return}await d(),E(!1)},F=`the ${n} ${e.name}`;return t.jsxs("article",{"aria-label":e.name,className:"border bg-card/40",children:[t.jsxs("header",{className:"flex flex-col gap-x-3 gap-y-1 px-5 pt-4 sm:flex-row sm:items-start",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words font-mono text-lead font-semibold leading-snug",children:e.name}),O&&t.jsxs(Ne,{tone:"warning",children:[t.jsx(Fx,{className:"size-3","aria-hidden":!0}),"Waits for your OK"]})]}),e.description&&t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:e.description}),O&&c==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:oC})]}),t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[!a&&!S&&!A&&t.jsxs(t.Fragment,{children:[O&&c==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void q(),disabled:k,"aria-label":`Approve ${e.name}`,children:k?"Approving":"Approve"}),D&&t.jsx(B,{size:"sm",onClick:()=>{P(null),L(!0)},"aria-label":`Make ${e.name} an agent`,children:"Make this an agent"}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>N(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]}),t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>void Y(),"aria-expanded":f,"aria-label":`${f?"Hide":"Show"} ${F}`,children:[t.jsx(Rr,{className:oe("transition-transform",f&&"rotate-180"),"aria-hidden":!0}),f?"Hide":"Show"]})]})]}),_&&t.jsx("div",{className:"px-5 pt-3",children:_}),R&&t.jsxs("p",{className:"px-5 pt-3 text-body",role:"status",children:["Made the agent ",t.jsx("a",{href:ln(R.agent_id),className:"font-mono underline underline-offset-2",children:R.definition.name}),". Open it to run it."]}),f&&(y!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(ns,{problem:$r(y,F),onRetry:()=>void W(),className:""})}):b===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${F}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):n==="skill"?t.jsx(qm,{text:qc(b)}):t.jsx(mD,{name:e.name,text:b})),t.jsxs("footer",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 border-t px-5 py-2.5 font-mono text-label text-muted-foreground",children:[e.run&&t.jsx(Gm,{run:e.run,runs:i}),fx(e.last_change)&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(qx,{className:"size-3","aria-hidden":!0}),fx(e.last_change)]}),t.jsx("span",{children:e.bytes<1024?`${e.bytes} B`:`${(e.bytes/1024).toFixed(1)} KB`})]}),S&&t.jsx(gC,{name:e.name,kind:n,retire:()=>s.retireNote(r,lx(e),H),onDone:async G=>{G&&await d(),N(!1)}}),A&&t.jsx(pD,{name:e.name,keys:M,promote:G=>s.promoteWorkflow(r,e.name,G),onDone:G=>{L(!1),G&&P(G)}})]})}function mD({name:e,text:n}){const{doc:s,graph:r}=p.useMemo(()=>{try{const c=JSON.parse(n);return{doc:c,graph:ll(c)}}catch{return{doc:null,graph:null}}},[n]),a=p.useMemo(()=>r?{meta:cd(s,r)}:void 0,[s,r]),i=t.jsx("pre",{className:"max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:n});return r!=null&&r.nodes.length?t.jsxs("div",{className:"mx-5 mt-3 space-y-2",children:[t.jsx("div",{className:"overflow-auto border bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-4",children:t.jsx(xd,{graph:r,marks:a,label:`The workflow ${e}, as a graph`,minScale:.55,maxScale:1})}),t.jsx(vd,{}),t.jsxs("details",{children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"workflow.json"}),t.jsx("div",{className:"mt-2",children:i})]})]}):t.jsx("div",{className:"mx-5 mt-3",children:i})}function fx(e){return e&&e.kind!=="learned"?`${X2(e.kind,e.by)} · ${ht(e.at)}`:null}function pC(e){return(e==null?void 0:e.by)==="host"?kz:e?`${X2("retired",e.by)} · ${ht(e.at)}`:"Retired"}function Gm({run:e,runs:n,at:s,reason:r}){return t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 whitespace-nowrap",title:r?`Kept because: ${r}`:void 0,children:[t.jsx(Gx,{className:"size-3 shrink-0 text-primary-text","aria-hidden":!0}),"Learned in"]}),t.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"shrink-0 font-mono text-foreground/80 underline-offset-2 hover:text-foreground hover:underline",title:eD(n,e),children:ta(e)}),s&&t.jsxs("span",{className:"shrink-0",children:["· ",ht(s)]})]})}function qm({text:e}){const[n,s]=p.useState(!1),r=e.split(`
|
|
642
|
+
`).length>8||e.length>520,a=p.useMemo(()=>to(e),[e]);return t.jsxs("div",{className:"px-5 pb-4 pt-3",children:[t.jsxs("div",{className:oe("relative",r&&!n&&"max-h-[9.5rem] overflow-hidden"),children:[t.jsx("div",{className:mC,dangerouslySetInnerHTML:{__html:a}}),r&&!n&&t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-background to-transparent","aria-hidden":!0})]}),r&&t.jsxs("button",{type:"button",onClick:()=>s(i=>!i),className:"caps mt-2 flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Rr,{className:oe("size-3.5 transition-transform",n&&"rotate-180"),"aria-hidden":!0}),n?"Show less":"Show all"]})]})}const hD={note:"Later runs stop reading it. It stays under Earlier notes.",skill:"Later runs stop getting it. It stays under Earlier skills.",workflow:"Later runs stop getting it. It stays under Earlier workflows."};function gC({name:e,kind:n,retire:s,onDone:r}){const[a,i]=p.useState(!1),[c,d]=p.useState(null),u=p.useRef(null);p.useEffect(()=>{var b;(b=u.current)==null||b.focus()},[]);const f=b=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:b}),g=async()=>{i(!0),d(null);try{await s()}catch(b){i(!1),d(b instanceof De&&zm(b).kind==="conflict"?f(`${Wm} Reload the tab to see the newest version.`):t.jsx(ns,{problem:Xa(b,`the ${n}`,`The ${n} was not retired.`),className:""}));return}await r(!0)};return t.jsxs("div",{role:"alertdialog","aria-label":`Retire ${e}?`,onKeyDown:b=>{b.key==="Escape"&&(b.stopPropagation(),r(!1))},className:"flex flex-wrap items-center gap-3 border-t border-destructive/40 bg-destructive/5 px-5 py-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Retire it?"})," ",hD[n]]}),c&&t.jsx("div",{className:"w-full",children:c}),t.jsx(B,{ref:u,size:"sm",variant:"destructive",onClick:()=>void g(),disabled:a,children:a?"Retiring":"Yes, retire"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>void r(!1),disabled:a,children:"Keep"})]})}function pD({name:e,keys:n,promote:s,onDone:r}){const[a,i]=p.useState(!1),[c,d]=p.useState(null),u=p.useRef(null);p.useEffect(()=>{var g;(g=u.current)==null||g.focus()},[]);const f=async()=>{var b;i(!0),d(null);let g;try{g=await s(n.keyFor("promote",e))}catch(x){return i(!1),x instanceof De&&x.status<500&&n.done(),x instanceof De&&x.status===403?void d(t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:Ez})):x instanceof De&&((b=x.problems)!=null&&b.length)?void d(t.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[t.jsxs("p",{children:["No agent was made: ",x.message]}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:x.problems.map((h,v)=>t.jsx("li",{children:h.detail},v))})]})):void d(t.jsx(ns,{problem:Xa(x,"the agent","No agent was made."),className:""}))}n.done(),r(g)};return t.jsxs("div",{role:"alertdialog","aria-label":`Make ${e} an agent?`,onKeyDown:g=>{g.key==="Escape"&&(g.stopPropagation(),a||r(null))},className:"flex flex-wrap items-center gap-3 border-t px-5 py-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Make it an agent?"})," ",Cz(e)]}),c&&t.jsx("div",{className:"w-full",children:c}),t.jsx(B,{ref:u,size:"sm",variant:"solid",onClick:()=>void f(),disabled:a,children:a?"Making the agent":"Yes, make the agent"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>r(null),disabled:a,children:"Cancel"})]})}function xC({name:e,kind:n,from:s,restore:r,onChanged:a,onDone:i}){const[c,d]=p.useState(!1),[u,f]=p.useState(null),g=p.useRef(null);p.useEffect(()=>{var h;(h=g.current)==null||h.focus()},[]);const b=h=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:h}),x=async()=>{var h;d(!0),f(null);try{await r()}catch(v){if(d(!1),v instanceof De&&(v.status===412||v.code==="precondition_failed")){f(b(Wm)),await a();return}if(v instanceof De&&v.status===403)return void f(b($z));if(v instanceof De&&((h=v.problems)!=null&&h.length))return void f(t.jsxs("div",{className:"text-small text-destructive-text",role:"alert",children:[t.jsxs("p",{children:["Not restored: ",v.message]}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:v.problems.map((y,j)=>t.jsx("li",{children:y.detail},j))})]}));if(v instanceof De&&v.status===400){await a(),i();return}return void f(t.jsx(ns,{problem:Xa(v,`the ${n}`,`The ${n} was not restored.`),className:""}))}await a(),i()};return t.jsxs("div",{role:"alertdialog","aria-label":`Restore ${e}?`,onKeyDown:h=>{h.key==="Escape"&&(h.stopPropagation(),i())},className:"flex flex-wrap items-center gap-3 border-t bg-card px-5 py-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Restore it?"})," ",Sz(s)]}),u&&t.jsx("div",{className:"w-full",children:u}),t.jsx(B,{ref:g,size:"sm",variant:"solid",onClick:()=>void x(),disabled:c,children:c?"Restoring":"Yes, restore"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:i,disabled:c,children:"Keep"})]})}function vC({title:e,v2:n,agentId:s,file:r,seen:a,taken:i=[],onDone:c}){const[d,u]=p.useState(a?Ff(a.text):{name:"",description:"",type:"feedback",body:`
|
|
643
|
+
`,rest:[]}),[f,g]=p.useState((a==null?void 0:a.etag)??null),[b,x]=p.useState(null),[h,v]=p.useState(!1),[y,j]=p.useState([]),[k,E]=p.useState(null),[S,N]=p.useState(!1),[_,$]=p.useState(null),O=p.useRef(null),A=async()=>{if(r)try{const D=await n.readNote(s,r);u(Ff(D.note)),g(D.etag),x(null)}catch(D){x(D??new Error("unknown"))}};p.useEffect(()=>{var D;(D=O.current)==null||D.focus()},[]);const L=D=>u(W=>({...W,...D})),M=d.name.trim()!==""&&d.description.trim()!==""&&!h,R=async()=>{if(!M)return;if(E(null),j([]),N(!1),r&&!f){E(bg);return}v(!0);const D=Wz(d);try{await n.writeNote(s,r??o0(d.name,i),D,r?{etag:f??""}:{create:!0}),c(!0)}catch(W){v(!1);const Y=W instanceof De?zm(W,!r):null;(Y==null?void 0:Y.kind)==="conflict"?($(D),await A()):(Y==null?void 0:Y.kind)==="refused"?j(Y.problems):(Y==null?void 0:Y.kind)==="taken"?N(!0):E(W??new Error("unknown"))}},P=D=>{D.key==="Escape"?(D.preventDefault(),D.stopPropagation(),c(!1)):D.key==="Enter"&&(D.metaKey||D.ctrlKey||D.target.tagName==="INPUT")&&(D.preventDefault(),R())};return t.jsxs("section",{className:"border border-border-strong bg-card","aria-label":e,onKeyDown:P,children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-2.5",children:[t.jsx("h3",{className:"caps text-label font-semibold",children:e}),t.jsxs("span",{className:"ml-auto hidden font-mono text-label text-muted-foreground sm:inline",children:[t.jsxs("kbd",{children:[tD?"⌘":"Ctrl","+Enter"]})," save · ",t.jsx("kbd",{children:"Esc"})," cancel"]})]}),b!==null&&t.jsx(ns,{problem:$r(b,"the note"),onRetry:()=>{x(null),A()},className:"m-5"}),t.jsxs("div",{className:"space-y-4 px-5 py-4",children:[_&&t.jsxs("div",{className:"border border-warning/50 bg-warning/10 px-4 py-3 text-body",role:"alert",children:[t.jsxs("p",{className:"flex items-center gap-2 font-semibold",children:[t.jsx(Gs,{className:"size-4 text-warning-text","aria-hidden":!0}),"Changed since you opened it"]}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"This is the newest version. Your edit wasn't saved; it's below to copy."}),t.jsxs("details",{className:"mt-2",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground hover:text-foreground",children:"Your edit"}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words border bg-background p-3 font-mono text-small",children:_})]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Name"}),t.jsx(ze,{ref:O,value:d.name,onChange:D=>L({name:D.target.value}),placeholder:"e.g., Try /policies/refund-policy first"})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Description"}),t.jsx("span",{className:"-mt-0.5 mb-1.5 block text-small text-muted-foreground",children:"One line: what the next run sees before it opens the note."}),t.jsx(ze,{value:d.description,onChange:D=>L({description:D.target.value}),placeholder:"When it applies, and what to do"})]}),t.jsxs("fieldset",{children:[t.jsx("legend",{className:"caps mb-1.5 text-label font-semibold",children:"Type"}),t.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Type",children:Z2.map(D=>t.jsxs("label",{className:oe("caps cursor-pointer border px-3 py-1.5 text-label",d.type===D?"border-foreground":"text-muted-foreground hover:text-foreground"),title:D,children:[t.jsx("input",{type:"radio",name:`type-${r??"new"}`,className:"sr-only",checked:d.type===D,onChange:()=>L({type:D})}),eC(D)]},D))}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:Tz[d.type]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-1.5 block text-label font-semibold",children:"Note"}),t.jsx(dn,{value:d.body.replace(/^\n/,""),onChange:D=>L({body:`
|
|
644
|
+
${D.target.value}`}),rows:7,placeholder:"What to do, and why. Markdown.",className:"resize-y leading-[1.65]"})]}),y.length>0&&t.jsxs("div",{className:"border border-destructive/50 bg-destructive/5 px-4 py-3 text-body",role:"alert",children:[t.jsx("p",{className:"font-semibold text-destructive-text",children:"Not saved: the note doesn't pass the checks."}),t.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-5",children:y.map((D,W)=>t.jsx("li",{children:D.detail},W))})]}),S&&t.jsx("p",{className:"text-body text-destructive-text",role:"alert",children:"Not saved: a note by this name exists already. Change its name."}),k===bg?t.jsxs("p",{className:"text-body text-destructive-text",role:"alert",children:["Not saved: ",bg]}):k!==null&&t.jsx(ns,{problem:Xa(k,"the note","The note was not saved."),className:""}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void R(),disabled:!M,children:h?"Saving":r?"Save":"Add note"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>c(!1),disabled:h,children:"Cancel"}),!r&&d.name.trim()&&t.jsx("span",{className:"ml-auto font-mono text-label text-muted-foreground",children:o0(d.name,i)})]})]})]})}function gD({notes:e,all:n,from:s,focus:r,runs:a,v2:i,agentId:c,readOnly:d,onChanged:u,refreshHolds:f}){const[g,b]=kr(f,null),[x,h]=p.useState(e.some(N=>r.includes(N.file))),[v,y]=p.useState(new Set),j=N=>y(_=>{const $=new Set(_);return $.has(N)?$.delete(N):$.add(N),$}),k=e.some(N=>r.includes(N.file));p.useEffect(()=>{k&&h(!0)},[k]);const E=N=>{var _;return((_=n.find($=>$.file===N))==null?void 0:_.name)??N},S=N=>{var $;const _=document.getElementById(`note-${N}`);($=_==null?void 0:_.scrollIntoView)==null||$.call(_,{block:"center",behavior:"smooth"}),_==null||_.focus({preventScroll:!0})};return t.jsx(yC,{title:"Earlier notes",count:`${e.length} no longer read`,open:x,onToggle:()=>h(N=>!N),children:e.map(N=>{var A,L;const _=N.status==="retired",$=_&&v.has(N.file),O=(A=s.get(N.file))==null?void 0:A.run;return t.jsxs("li",{id:`note-${N.file}`,className:oe("border-b px-4 py-3 last:border-b-0",r.includes(N.file)&&"bg-primary/5"),children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-lead text-muted-foreground line-through decoration-muted-foreground/40",children:N.name}),t.jsx(Ne,{tone:"muted",children:_?"Retired":"Replaced"}),_&&t.jsx(bC,{open:$,label:`the note ${N.name}`,onClick:()=>j(N.file)}),_&&!d&&N.etag&&g!==N.file&&t.jsxs(B,{size:"sm",onClick:()=>b(N.file),"aria-label":`Restore ${N.name}`,children:[t.jsx(_N,{"aria-hidden":!0})," Restore"]})]}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:N.status==="superseded"&&N.superseded_by?t.jsxs(t.Fragment,{children:["Replaced by ",t.jsx("button",{type:"button",onClick:()=>S(N.superseded_by),className:"text-foreground/80 underline-offset-2 hover:text-foreground hover:underline",children:E(N.superseded_by)})]}):_?pC(N.retired):null}),g===N.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(xC,{name:N.name,kind:"note",from:(L=N.retired)==null?void 0:L.from,restore:()=>i.restoreNote(c,N.file,N.etag),onChanged:u,onDone:()=>b(null)})}),$&&t.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[t.jsx("p",{className:"mt-2 px-5 text-body text-muted-foreground",children:N.description}),qc(N.text).trim()&&t.jsx(qm,{text:qc(N.text)}),O&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(Gm,{run:O.id,runs:a,at:O.at,reason:O.reason})})]})]},N.file)})})}function yC({title:e,count:n,open:s,onToggle:r,children:a}){return t.jsxs("section",{className:"border","aria-label":e,children:[t.jsxs("button",{type:"button","aria-expanded":s,onClick:r,className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[t.jsx(Rr,{className:oe("size-3.5 text-muted-foreground transition-transform",!s&&"-rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:e}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:n})]}),s&&t.jsx("ul",{className:"border-t",children:a})]})}function xD({kind:e,items:n,v2:s,agentId:r,runs:a,readOnly:i,onChanged:c,refreshHolds:d}){const[u,f]=p.useState(!1),[g,b]=kr(d,null),[x,h]=p.useState(new Set),v=y=>h(j=>{const k=new Set(j);return k.has(y)?k.delete(y):k.add(y),k});return t.jsx(yC,{title:e==="skill"?"Earlier skills":"Earlier workflows",count:`${n.length} no longer given`,open:u,onToggle:()=>f(y=>!y),children:n.map(y=>{var j;return t.jsxs("li",{className:"border-b px-4 py-3 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-body text-muted-foreground line-through decoration-muted-foreground/40",children:y.name}),t.jsx(Ne,{tone:"muted",children:"Retired"}),t.jsx(bC,{open:x.has(y.file),label:`the ${e} ${y.name}`,onClick:()=>v(y.file)}),!i&&g!==y.file&&t.jsxs(B,{size:"sm",onClick:()=>b(y.file),"aria-label":`Restore ${y.name}`,children:[t.jsx(_N,{"aria-hidden":!0})," Restore"]})]}),y.description&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:y.description}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:pC(y.retired)}),g===y.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(xC,{name:y.name,kind:e,from:(j=y.retired)==null?void 0:j.from,restore:()=>s.restoreNote(r,lx(y),y.etag),onChanged:c,onDone:()=>b(null)})}),x.has(y.file)&&t.jsxs("div",{className:"-mx-4 mt-2 border-t pt-1",children:[t.jsx(vD,{v2:s,agentId:r,file:y.file,etag:y.etag,kind:e,label:`the ${e} ${y.name}`}),y.run&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(Gm,{run:y.run,runs:a})})]})]},y.file)})})}function bC({open:e,label:n,onClick:s}){return t.jsxs(B,{size:"sm",variant:"ghost",className:"ml-auto",onClick:s,"aria-expanded":e,"aria-label":`${e?"Hide":"Show"} ${n}`,children:[t.jsx(Rr,{className:oe("transition-transform",e&&"rotate-180"),"aria-hidden":!0}),e?"Hide":"Show"]})}function vD({v2:e,agentId:n,file:s,etag:r,kind:a,label:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),g=p.useRef(0),b=async()=>{const x=++g.current;f(null),d(null);try{const h=await e.readNote(n,s);x===g.current&&d(h.note)}catch(h){x===g.current&&f(h??new Error("unknown"))}};return p.useEffect(()=>{b()},[s,r]),u!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(ns,{problem:$r(u,i),onRetry:()=>void b(),className:""})}):c===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${i}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):a==="skill"?t.jsx(qm,{text:qc(c)}):t.jsx("pre",{className:"mx-5 mt-3 max-h-80 overflow-auto border bg-background p-3 font-mono text-small",children:c})}function d0({runs:e}){const n=e.filter(a=>{var i;return((i=a.learning)==null?void 0:i.state)==="dropped"}),s=n.filter(a=>zf(a.learning.reason)!=="nothing").slice(0,6),r=n.length-n.filter(a=>zf(a.learning.reason)!=="nothing").length;return n.length?t.jsxs(hC,{title:"Kept nothing",children:[s.length>0&&t.jsx("ul",{children:s.map(a=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(a.run_id)}`,className:"block px-4 py-3 hover:bg-accent",children:[t.jsx("span",{className:"block text-body",children:Zv(a.learning)}),t.jsxs("span",{className:"mt-1 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 truncate",title:Sn(a),children:Sn(a)}),t.jsxs("span",{className:"shrink-0",children:["· ",ht(a.created_at)]})]})]})},a.run_id))}),r>0&&t.jsxs("p",{className:oe("px-4 py-3 font-mono text-label text-muted-foreground",s.length>0&&"border-t"),children:[s.length?`${r} more ${r===1?"run":"runs"} had`:`${Ba(r)} had`," nothing new to remember."]})]}):null}function yD({index:e,skills:n,off:s}){const[r,a]=p.useState(!1),i=s?0:e.split(`
|
|
645
|
+
`).filter(f=>f.trim()).length,c=p.useMemo(()=>to(e.trim()),[e]),d=s?[]:n,u=d.length?`${d.length} ${d.length===1?"skill":"skills"}`:"";return t.jsxs("section",{className:"border","aria-label":"What the next run reads",children:[t.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(f=>!f),className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[t.jsx(Rr,{className:oe("size-3.5 text-muted-foreground transition-transform",!r&&"-rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:"What the next run reads"}),t.jsx("span",{className:"ml-auto font-mono text-label text-muted-foreground",children:[i?Xi(i):"",u].filter(Boolean).join(" · ")||"nothing"})]}),r&&t.jsxs("div",{className:"border-t",children:[s?t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:"Learning is off: the next run gets no notes or skills."}):i?t.jsx("div",{className:oe(mC,"max-h-72 overflow-auto break-words px-4 py-3 text-body"),dangerouslySetInnerHTML:{__html:c}}):t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",children:d.length?"No note is in use.":"Nothing yet: no note is in use."}),d.length>0&&t.jsxs("p",{className:"break-words border-t px-4 py-3 font-mono text-small leading-[1.7]",children:["Active skills: ",d.join(", ")]}),t.jsx("p",{className:"border-t px-4 py-2 text-label text-muted-foreground",children:"Read-only: the notes in use, one line each, and the agent's active skills."})]})]})}function ey({run:e,link:n=!1,className:s}){var b;const r=tC(e.learning),a=nC(e.learning),i=Gc(e.learning),c=Hm(e.learning)&&e.learning.state!=="seeded",d=Jv(e.learning),u=Az(e.learning),f=[...t0(e.learning),...n0(e.learning)],g=((b=e.learning)==null?void 0:b.state)==="dropped"&&zf(e.learning.reason)!=="nothing"?Zv(e.learning):null;return!r.length&&!a.length&&!i.length&&!c&&!u&&!f.length&&!g?null:t.jsxs("span",{className:oe("inline-flex flex-wrap items-center gap-2",s),"aria-label":"Learning",children:[r.length>0&&t.jsx(qu,{agentId:e.agent_id,refs:r,link:n,kind:"given"}),a.length>0&&t.jsx(qu,{agentId:e.agent_id,refs:a,link:n,kind:"read"}),i.length>0&&t.jsx(qu,{agentId:e.agent_id,refs:i,link:n,kind:"learned",replaces:i.reduce((x,h)=>{var v;return x+(((v=h.supersedes)==null?void 0:v.length)??0)},0)}),u&&t.jsx(qu,{agentId:e.agent_id,refs:d,link:n,kind:"pending"}),g&&t.jsx(bD,{agentId:e.agent_id,said:g,link:n}),["skill","workflow"].flatMap(x=>{const h=(x==="skill"?t0:n0)(e.learning);return[!1,!0].map(v=>{const y=h.filter(j=>j.pending===!0===v);return y.length?t.jsx(wD,{agentId:e.agent_id,refs:y,link:n,kind:x,pending:v},`${x}-${v}`):null})}),c&&t.jsxs(Ne,{tone:"active",children:[t.jsxs("span",{className:"relative flex size-1.5","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inline-flex size-full animate-ping bg-run-active opacity-75"}),t.jsx("span",{className:"relative inline-flex size-1.5 bg-run-active"})]}),zz(e.learning.state)]})]})}function bD({agentId:e,said:n,link:s}){const r=t.jsxs(Ne,{tone:"muted",className:oe(s&&"cursor-pointer"),children:[t.jsx(uT,{className:"size-3","aria-hidden":!0}),"Kept nothing"]});return s?t.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[t.jsx("a",{href:Bm(e),"aria-label":`Kept nothing: ${n}`,className:"inline-flex",children:r}),t.jsx("span",{className:"text-small text-muted-foreground",children:n})]}):t.jsx("span",{title:`Kept nothing: ${n}`,"aria-label":`Kept nothing: ${n}`,className:"inline-flex",children:r})}function wD({agentId:e,refs:n,link:s,kind:r,pending:a}){const i=a?`${Lf(n.length,r)} ${n.length===1?"waits":"wait"} for your OK`:`Learned ${Lf(n.length,r)}`,c=`${i}: ${n.map(f=>f.name).join(", ")}`,d=a?Fx:r==="skill"?vf:Ya,u=t.jsxs(Ne,{tone:a?"warning":void 0,className:oe(!a&&"border-primary/50 bg-primary/10 text-primary-text",s&&"cursor-pointer"),children:[t.jsx(d,{className:"size-3","aria-hidden":!0}),i]});return s?t.jsx("a",{href:Bm(e),title:c,"aria-label":c,className:"inline-flex",children:u}):t.jsx("span",{title:c,"aria-label":c,className:"inline-flex",children:u})}function qu({agentId:e,refs:n,link:s,kind:r,replaces:a=0}){const i=r==="pending"?iC(n.length):r==="given"?`Started with: ${Xi(n.length)}`:r==="read"?`Read: ${Xi(n.length)}`:`Learned ${Xi(n.length)}`,c=n.map(h=>h.name).join(", "),d=r==="given"||r==="read",u=d?gf:r==="pending"?Fx:Gx,f=t.jsxs(Ne,{tone:r==="pending"?"warning":void 0,className:oe(r==="learned"?"border-primary/50 bg-primary/10 text-primary-text":d?"border-border-strong/70 text-foreground/80":"",s&&"cursor-pointer transition-colors group-hover/tip:border-foreground/70"),children:[t.jsx(u,{className:"size-3","aria-hidden":!0}),i]}),g=n.filter(h=>h.file!==aC),b=`${i}${c?`: ${c}`:""}${a?` (replaces ${a===1?"1 older note":`${a} older notes`})`:""}`;if(!s||!g.length&&r!=="pending")return t.jsx("span",{title:b,"aria-label":b,className:"inline-flex",children:f});const x=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"caps block text-micro text-muted-foreground",children:r==="given"?"This run started with":r==="read"?"This run read":r==="learned"?"This run kept":"Waits for your OK before any run reads it"}),n.length>0&&t.jsx("ul",{className:"mt-1 space-y-0.5",children:n.map(h=>t.jsx("li",{className:"font-semibold",children:h.name},h.file))}),a>0&&t.jsxs("span",{className:"mt-1 block text-muted-foreground",children:["Replaces ",a===1?"1 older note":`${a} older notes`,"."]}),t.jsx("span",{className:"mt-1.5 block text-label text-muted-foreground",children:"Open in Learning"})]});return t.jsx(h5,{tip:x,children:t.jsx("a",{href:Bm(e,g.map(h=>h.file)),"aria-label":b,className:"inline-flex",children:f})})}function jD({n:e,className:n}){return e<=0?null:t.jsx("span",{"aria-label":Xv(e),className:oe("inline-flex min-w-[18px] items-center justify-center border border-warning/50 bg-warning/10 px-1 font-mono text-micro text-warning-text",n),children:e})}const kD=["pi","claude-agent","codex","opencode"];function ND(e){const n=new Set,s=r=>{if(Array.isArray(r)){r.forEach(s);return}if(!r||typeof r!="object")return;const a=r;a.node==="call"&&typeof a.tool=="string"&&n.add(a.tool),Object.values(a).forEach(s)};return s(e),[...n].sort()}function SD(e){const n=s=>Array.isArray(s)&&s.every(r=>typeof r=="string")?[...new Set(s)]:[];return{denied:n(e==null?void 0:e.denied),asks:n(e==null?void 0:e.asks)}}function CD(e){return(Array.isArray(e)?e:[]).flatMap(n=>{const s=n;return!s||typeof s.name!="string"||!Array.isArray(s.providers)||!s.providers.length?[]:[{name:s.name,providers:s.providers,provider:s.provider??s.providers[0],default_provider:s.default_provider??s.providers[0],resolves:s.resolves&&typeof s.resolves=="object"?s.resolves:{},available:s.available!==!1,...typeof s.reason=="string"&&s.reason?{reason:s.reason}:{}}]})}const ty="Refused on this server for every agent, whatever the agent's own setting or Never ask.",ED="Deny stops this tool only. The agent can still reach the web with other tools it has, such as browser, bash or web_search: deny those too to keep it offline.",wC=(e,n,s,r)=>{var d;const a=s==null?void 0:s.find(u=>u.name===e);if(a)return a.permission==="deny"&&a.permission_from==="server";const i=Bo(e),c=i?(d=r==null?void 0:r.find(u=>u.name===i.server))==null?void 0:d.tools.find(u=>u.name===i.tool):void 0;return c?c.permission==="deny":n.some(u=>u.name===e&&u.permission==="deny")};function $D(e){return(e??[]).map(({name:n,permission:s,default_permission:r,permissions:a,ask_needs:i})=>({name:n,permission:s,default_permission:r,permissions:a,...i==="password"?{ask_needs:i}:{}}))}const _D={auto:"auto",native:"native",kernel:"kernel fetch","exa-keyless":"Exa keyless",parallel:"Parallel"},jC={browser:{label:{auto:"Auto (Browserbase where its key is saved, else Kernel)",browserbase:"Browserbase",kernel:"Kernel",chrome:"Local Chrome"},help:{auto:"Browserbase where its key is set or saved, else Kernel where its key is; unavailable with neither.",browserbase:"Browserbase's hosted browser: needs the Browserbase key and project id.",kernel:"Kernel's hosted browser: needs the Kernel key.",chrome:"A Chrome on this server's own host. No server sets one up yet, so it stays unavailable."}}},Uf=(e,n)=>{var s;return(n&&((s=jC[n])==null?void 0:s.label[e]))??_D[e]??e},TD={auto:"The harness's own search, or the model provider's hosted one; else Parallel where this server holds its key; else keyless Exa.",native:"The harness's own search, or the model provider's hosted one, never a third party: unavailable where there is none.","exa-keyless":"Exa's keyless search: no key, a third party.",parallel:"Parallel: needs the Parallel key.",kernel:"This server's own fetch, guarded against private addresses."},u0=(e,n)=>{var s;return(n&&((s=jC[n])==null?void 0:s.help[e]))??TD[e]};function kC(e,n){return e?e.startsWith("unavailable")?{text:e,unavailable:!0}:{text:Uf(e,n),unavailable:!1}:{text:"not known",unavailable:!1}}function NC(e,n,s,r,a){const{[n]:i,...c}=e,{[s]:d,...u}=i??{},f=r===void 0||r===a?u:{...u,[s]:r};return Object.keys(f).length?{...c,[n]:f}:c}const RD=(e,n,s,r)=>NC(e,n,"provider",s,r),AD=(e,n,s,r)=>NC(e,n,"permission",s,r);function mx(e,n){const s=new Map(n.map(r=>[r.name,r.default_provider]));return Object.fromEntries(Object.entries(e).flatMap(([r,a])=>{if(!a||typeof a!="object")return[];const{provider:i,...c}=a,d=i!==void 0&&!(s.has(r)&&i===s.get(r))?{...c,provider:i}:c;return Object.keys(d).length?[[r,d]]:[]}))}function SC(e,n,s){const r={},a=[];for(const[i,c]of Object.entries(e)){if(n&&i!==n&&!i.startsWith(`${n}.`)&&!i.startsWith(`${n}/`))continue;const d=n?i.slice(n.length+1):i,u=[...s].sort((f,g)=>g.length-f.length).find(f=>d===f||d.startsWith(`${f}.`)||d.startsWith(`${f}/`));u?(r[u]??(r[u]=[])).push(c):a.push(c)}return{byTool:r,rest:a}}const OD=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),MD=e=>{if(!Array.isArray(e))return[e];const n=[...new Set(e.filter(s=>s!==null).map(s=>JSON.stringify(s)))].sort();return[...e.includes(null)?[null]:[],...n.map(s=>JSON.parse(s))]},PD=e=>typeof e=="string"?e:JSON.stringify(e);function LD(e){return Object.keys(e).sort().map(n=>{const s=e[n];if(OD(s)){const d=[...new Set(s.keys)].sort();return d.length===1?`${n} may hold only the key ${d[0]} (any value)`:`${n} may hold only the keys ${d.join(", ")} (any values)`}const r=MD(s),a=r[0]===null,i=(a?r.slice(1):r).map(d=>PD(d));if(!i.length)return`${n} must be left out`;const c=i.length===1?i[0]:`one of ${i.join(", ")}`;return`${n} must be ${a?`left out or ${c}`:c}`}).join("; ")}const ID="Calls outside it are refused before they run or ask.",zD="This pin doesn't read, so every call to this tool is refused. Set the pin again, or remove the tool's setting.",DD=[{id:"runs",label:"Runs",shows:()=>!0,Body:BD},{id:"versions",label:"Versions",shows:()=>!0,Body:QM},{id:"workflow",label:"Workflow",shows:e=>e.kind==="workflow",Body:GD},{id:"learning",label:"Learning",shows:(e,n)=>e.kind==="agentic"&&n.learning!==!1,Body:e=>t.jsx(sD,{agent:e.agent,v2:e.v2,focus:e.focus,server:e.learning,onAgent:e.onAgent,places:e.places,onChanged:e.onChanged})},{id:"analytics",label:"Analytics",shows:(e,n)=>n.analytics,Body:jP}],ln=(e,n)=>`#/agents/${encodeURIComponent(e)}${n?`/${n}`:e==="new"||e==="connect"?"/runs":""}`;function FD({v2:e,agentId:n,routePrefix:s,harnesses:r,go:a,tab:i,learning:c,notes:d,places:u}){const[f,g]=p.useState(null),[b,x]=p.useState(null),[h,v]=p.useState(0),[y,j]=p.useState(void 0);p.useEffect(()=>{let P=!0;return g(null),x(null),j(void 0),_(!1),S.current=++k.current,e.getAgent(n).then(D=>{P&&g(D.agent)},D=>{P&&x({cause:D})}),e.statsOver({from:Ev(x2),agent:n}).then(D=>{P&&j(D)},()=>{P&&j(null)}),()=>{P=!1,S.current=++k.current}},[e,n,h]);const k=p.useRef(0),E=p.useRef(0),S=p.useRef(0),[N,_]=p.useState(!1),$=(P=!1,D=!P)=>{const W=++k.current;return D&&(S.current=W),e.getAgent(n).then(Y=>(W>E.current&&W>=S.current&&(E.current=W,g(H=>H&&H.agent_id===Y.agent.agent_id?Y.agent:H),_(!1)),E.current>=W),()=>(W===k.current&&!P&&_(!0),E.current>=W))},O=P=>{g(D=>({...P,tools:(D==null?void 0:D.tools)??P.tools})),$()},A=()=>void $(),L=()=>void $(!0,!1),M=()=>$(!0,!0),R=y===void 0?void 0:y!==null;return b?b.cause instanceof De&&b.cause.status===404?t.jsx(t2,{what:"agent",id:n,list:{href:"#/agents",label:"Open the agents list"}}):t.jsx(Yt,{problem:Ut(b.cause,"the agent"),onRetry:()=>v(P=>P+1)}):f?t.jsx(UD,{agent:f,onAgent:O,onSignInsAgent:g,reread:$,onChanged:A,poll:L,afterForget:M,stale:N,v2:e,go:a,stats:y,analytics:R,places:u,routePrefix:s,harnesses:r,tab:i,learning:c,notes:d},f.agent_id):t.jsx(GM,{})}function UD({agent:e,onAgent:n,onSignInsAgent:s,reread:r,onChanged:a,poll:i,afterForget:c,stale:d,v2:u,go:f,stats:g,analytics:b,routePrefix:x,harnesses:h,tab:v,learning:y,notes:j,places:k}){var se,ue,xe,$e;const E=HD(e,u,r,()=>r(!1,!1)),[S,N]=p.useState(!1),_=If(e),$=e.definition,O=Zn($),{native:A,refresh:L}=sL(e,u),M=e.kind==="workflow",R=M?Ya:zx,P=U2($.harness??"pi",h),D=$.model?ul($.model,x):P?(({text:ge,title:fe})=>({text:`${ge} (default)`,title:fe}))(ul(P,x)):{text:SI},W=M||A||O||h==null?void 0:h.find(ge=>ge.id===($.harness??"pi")&&ge.available===!1),Y=W?`${W.id} doesn't run on this server${W.reason?`: ${W.reason}`:"."}`:void 0,H=S2(e,k),q=`${DP(H==null?void 0:H.place)}${H!=null&&H.byDefault?" (server default)":""}`,F=!O&&!A&&!M&&!W&&!$.model&&!P&&(h==null?void 0:h.some(ge=>ge.id===($.harness??"pi")&&ge.default_model===null)),G=[...O?[["Runtime",Vo(O.runtime)],["Model","Reported per run"],["Execution","Your backend"]]:A?[["Runtime",A.runtime],["Model",A.model??"Native default"],["Selector",A.selector.kind==="project"?"Project default":A.selector.name??A.selector.kind],["Machine",A.machine_id]]:M?[]:[["Harness",$.harness??"pi"],["Model",D.text,D.title],["Thinking",$.thinking??"default"],["Runs",q]],["Revision",`rev ${$.version} of ${e.revisions}`]],U=DD.filter(ge=>ge.shows(e,{analytics:b===!0,learning:y===void 0?v==="learning"?void 0:!1:!!y})),z=U.find(ge=>ge.id===v)??U[0],Q=v==="analytics"&&b===void 0,K=((se=E.runs)==null?void 0:se.filter(WD))??[],Z=((ue=e.runs)==null?void 0:ue.live)??(E.runs?`${K.length}${E.cursor?"+":""}`:"—"),de=[["Status",e.archived_at?"Archived":A?md(A):"Active"],["Live jobs",String(Z)],...G];return t.jsx(rL,{native:A,children:t.jsxs("section",{className:"flex h-full min-h-0 flex-col","aria-label":"Agent detail",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-b px-5 py-2 lg:flex-nowrap lg:py-0","aria-label":"Agent toolbar",children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:()=>f(e.archived_at?"#/agents?archived=true":"#/agents"),children:t.jsx(zn,{"aria-hidden":!0})}),t.jsx(R,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("strong",{className:"min-w-0 truncate text-body font-semibold",children:$.name}),t.jsxs("div",{className:"ml-auto flex max-w-full flex-wrap items-center justify-end gap-2",children:[t.jsx(B,{size:"icon","aria-label":"Refresh agent",onClick:()=>{E.refresh(),L()},disabled:E.reading,children:t.jsx(Qo,{className:oe(E.reading&&"animate-spin"),"aria-hidden":!0})}),!A&&!O&&t.jsx(B,{size:"sm",onClick:()=>f(ln(e.agent_id,"edit")),children:"Detailed editor"}),t.jsx(tn,{label:"Edit agent",prompt:Ho(location.origin,e.agent_id,!!A,O==null?void 0:O.runtime),playgroundHref:A||O?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),!e.archived_at&&t.jsx(tn,{variant:"primary",label:"Run agent",disabled:!!A&&(!A.connected||A.state!=="ready"||!A.capabilities.launch),prompt:Av(location.origin,e.agent_id,O==null?void 0:O.runtime),playgroundHref:O?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`})]})]}),t.jsxs("main",{className:"grid min-h-0 flex-1 grid-cols-1 items-start gap-6 overflow-auto p-5 lg:grid-cols-[minmax(260px,320px)_minmax(0,1fr)] md:p-8",children:[t.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"Agent overview",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold",children:$.name}),$.approvals==="never"&&t.jsx(Ne,{tone:"warning",className:"mt-2",title:"Never ask: a call of this agent never waits for you. A tool set to deny, and a template’s pins, still hold.",children:"Unattended"}),$.description&&t.jsx("p",{id:"agent-description",className:oe("mt-2 text-body leading-relaxed text-muted-foreground",!S&&"max-sm:line-clamp-2"),children:$.description}),t.jsx("p",{className:"mt-3 break-all font-mono text-label text-muted-foreground",children:e.agent_id})]}),t.jsxs("button",{type:"button","aria-expanded":S,"aria-controls":$.description?"agent-description agent-facts":"agent-facts",onClick:()=>N(ge=>!ge),className:"flex w-full min-w-0 items-center gap-2 text-left font-mono text-small text-muted-foreground sm:hidden",children:[t.jsx(Cs,{className:oe("size-3.5 shrink-0 transition-transform",S&&"rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:de.map(([,ge])=>ge).join(" · ")})]}),t.jsxs("dl",{id:"agent-facts",className:oe("grid grid-cols-2 gap-3",!S&&"max-sm:hidden"),"aria-label":"Current revision",children:[de.map(([ge,fe,me])=>t.jsxs("div",{className:"min-w-0 border bg-card p-4",children:[t.jsx("dt",{className:"mb-2 text-label text-muted-foreground",children:ge}),t.jsx("dd",{className:"break-words text-body font-semibold",title:me,children:fe})]},ge)),!M&&!A&&!O&&t.jsxs("div",{className:"col-span-2 border bg-card p-4",children:[t.jsx("dt",{className:"mb-2 text-label text-muted-foreground",children:"Tools"}),t.jsx("dd",{className:"break-words text-small",children:!M&&e.tools?e.tools.length?t.jsx("ul",{className:"space-y-2","aria-label":"Tools",children:e.tools.map(ge=>t.jsxs("li",{children:[t.jsx("span",{title:ge.blurb,children:ge.name}),ge.provider?` · ${Uf(ge.provider,ge.name)}`:"",ge.permission?` · ${ge.permission}`:"",kC(ge.resolved,ge.name).unavailable&&t.jsx("span",{"data-unavailable":!0,className:"text-warning-text",title:ge.resolved,children:" · unavailable"})]},ge.name))}):"none":$.tools.join(", ")||"None configured"})]})]}),Y&&t.jsx(vt,{tone:"warning","aria-label":"Harness not available",children:Y}),!e.archived_at&&F&&t.jsxs(vt,{children:["Running this agent needs a configured model. ",t.jsx("a",{href:"#/settings/keys",className:"text-primary-text underline underline-offset-2",children:"Set up models in Settings"})]}),d&&t.jsxs(vt,{tone:"error",children:["Couldn't refresh this agent. ",t.jsx(B,{size:"sm",onClick:()=>void r(),children:"Retry"})]}),(xe=e.warnings)!=null&&xe.length?t.jsxs("div",{className:"font-mono text-small",role:"status","aria-label":"Save warnings",children:[t.jsx("p",{className:"text-warning-text",children:"Created. What the server said of this revision (Edit shows each at its step):"}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:e.warnings.map((ge,fe)=>t.jsxs("li",{children:[t.jsx("span",{className:"text-muted-foreground",children:ge.field})," ",ge.message]},`${ge.field}:${fe}`))})]}):null,t.jsx(lL,{agent:e,v2:u,onAgent:s,poll:i,refresh:c}),A&&t.jsx(oL,{agent:e,v2:u,learning:y,onAgent:n,onChanged:async()=>{L(),await r()}}),!A&&t.jsxs("section",{className:"border bg-card p-4","aria-label":"Agent configuration",children:[t.jsx("h2",{className:"mb-4 text-body font-semibold",children:"Configuration"}),t.jsxs("dl",{className:"space-y-3 text-small",children:[t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("dt",{className:"text-muted-foreground",children:"Kind"}),t.jsx("dd",{children:e.kind})]}),t.jsxs("div",{className:"flex justify-between gap-3",children:[t.jsx("dt",{className:"text-muted-foreground",children:"Skills"}),t.jsx("dd",{className:"max-w-[75%] break-words text-right",children:O?"Managed by your backend":$.skills.join(", ")||"None configured"})]})]}),$.instructions&&t.jsxs("details",{className:"mt-4 text-small",children:[t.jsx("summary",{className:"cursor-pointer",children:"Instructions"}),t.jsx("pre",{className:"mt-3 whitespace-pre-wrap break-words font-sans leading-relaxed text-muted-foreground",children:$.instructions})]})]}),t.jsxs("section",{className:"border bg-card p-4","aria-label":"Live jobs",children:[t.jsx("h2",{className:"mb-3 text-body font-semibold",children:"Live jobs"}),K.length?t.jsx("ul",{className:"space-y-3",children:K.map(ge=>t.jsx("li",{children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(ge.run_id)}`,className:"flex items-center gap-2 text-small hover:text-primary-text",children:[t.jsx(Nl,{run:ge}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:Sn(ge)}),t.jsx(cr,{className:"size-3 shrink-0","aria-hidden":!0})]})},ge.run_id))}):t.jsx("p",{className:"text-small leading-relaxed text-muted-foreground",children:E.runs?($e=e.runs)!=null&&$e.live?"Live jobs are outside the loaded history. Load more runs to find them.":E.error?"Live jobs could not be refreshed.":"No live jobs.":"Loading live jobs…"})]})]}),t.jsxs("section",{className:"min-w-0","aria-label":"Agent workspace",children:[t.jsx(ES,{id:"agent-views",label:"Agent views",value:z.id,onChange:ge=>f(ln(e.agent_id,ge)),tabs:U.map(ge=>({id:ge.id,label:t.jsxs(t.Fragment,{children:[ge.label,ge.id==="learning"&&t.jsx(jD,{n:_,className:"ml-1.5"})]})})),className:"mb-5 overflow-x-auto px-0 md:px-0"}),t.jsx("div",{...m5("agent-views",z.id),"aria-label":Q?void 0:z.label,children:Q?t.jsx(Fn,{label:"Loading the tab",rows:4}):t.jsx(z.Body,{agent:e,v2:u,go:f,stats:g,history:E,focus:j,learning:y,onAgent:n,onChanged:a,places:k})})]})]})]})})}const WD=e=>!e.imported_from&&["queued","working","paused","input_required"].includes(e.status);function HD(e,n,s,r){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(!1),[g,b]=p.useState(!1),[x,h]=p.useState(null),[v,y]=p.useState(!1),j=p.useRef(0),k=p.useRef([]),E=p.useRef(0),S=p.useRef(!1),N=async(_,$=!1,O=!1,A=!1)=>{if(S.current)return;S.current=!0;const L=++j.current;f(!0),b(!!_);const M=$?A?r():s():Promise.resolve();try{let R=_,P=[];const D=_||O?void 0:k.current.at(-1),W=D?Date.parse(D.created_at):NaN,Y=E.current+1;let H=!1;const q=new Set;do{if(q.size>=Y){y(!0),h({title:"Run history could not be refreshed.",why:"Previous runs are still shown. The run list changed too much to refresh them safely.",next:"Try again, or reload the latest runs to reset the loaded history."});return}if(q.has(R))throw new Error("The runs list repeated a page. Refresh to try again.");q.add(R);const F=await n.listAgentRuns(e.agent_id,50,R,!!e.archived_at);if(L!==j.current)return;P=ux(P,F.runs),R=F.next_cursor,H||(H=F.runs.some(G=>G.run_id===(D==null?void 0:D.run_id)||Date.parse(G.created_at)<W))}while(!_&&R&&D&&!H);L===j.current&&(k.current=_?ux(k.current,P):P,E.current=_?E.current+1:q.size,i(k.current),d(R),h(null),y(!1))}catch(R){L===j.current&&h(Ut(R,_?"more runs":"the runs"))}finally{await M,L===j.current&&(S.current=!1,f(!1),b(!1))}};return p.useEffect(()=>{S.current=!1,k.current=[],E.current=0,i(null),d(null),h(null),y(!1),N(null);const _=()=>{document.hidden||N(null,!0,!1,!0)};window.addEventListener("focus",_),document.addEventListener("visibilitychange",_);const $=window.setInterval(_,1e4);return()=>{j.current++,S.current=!1,window.clearInterval($),window.removeEventListener("focus",_),document.removeEventListener("visibilitychange",_)}},[n,e.agent_id,e.archived_at]),{runs:a,cursor:c,reading:u,more:g,error:x,refresh:()=>{N(null,!0)},loadMore:()=>{c&&N(c)},reloadLatest:v?()=>{N(null,!0,!0)}:null}}function BD({agent:e,history:n}){const[s,r]=p.useState(""),{runs:a,cursor:i,reading:c,more:d,error:u,refresh:f,loadMore:g,reloadLatest:b}=n;if(u&&!a)return t.jsx(Yt,{problem:u,onRetry:f,className:""});if(!a)return t.jsx(Fn,{label:"Loading the runs",rows:5});const x=a.filter(h=>`${Sn(h)} ${h.run_id} ${h.status}`.toLowerCase().includes(s.toLowerCase()));return t.jsxs("section",{className:"min-h-[380px] overflow-hidden border","aria-label":"Agent run history",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b p-3",children:[t.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(cm,{className:"size-3.5 text-muted-foreground","aria-hidden":!0}),t.jsx(ze,{"aria-label":"Search this agent's runs",value:s,onChange:h=>r(h.target.value),placeholder:"Search runs…",className:"w-40 min-w-0"})]}),t.jsxs("span",{className:"text-small text-muted-foreground",children:[a.length,i?"+":""," ",a.length===1&&!i?"run":"runs"]}),t.jsx("div",{className:"ml-auto",children:t.jsx(tn,{label:"Query",prompt:`${Mm(location.origin,e.agent_id)}
|
|
646
|
+
Current view: all statuses; ${e.archived_at?"archived runs":"non-archived runs"}.`,playgroundHref:Sv(e.agent_id,{archived:!!e.archived_at})})})]}),a.length?t.jsxs("div",{className:"overflow-x-auto",children:[t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Runs",children:[t.jsx("thead",{className:"border-b bg-card text-muted-foreground",children:t.jsx("tr",{children:["Status","Run","Started","Duration","Cost"].map(h=>t.jsx("th",{className:"whitespace-nowrap px-4 py-3 font-semibold",children:h},h))})}),t.jsx("tbody",{children:x.map(h=>t.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-accent/50",children:[t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:t.jsx(Nl,{run:h})}),t.jsxs("td",{className:"min-w-48 px-4 py-3",children:[t.jsxs("a",{href:`#/runs/${encodeURIComponent(h.run_id)}`,className:"flex items-center gap-2 font-semibold hover:text-primary-text",children:[t.jsx("span",{className:"line-clamp-2",children:Sn(h)}),t.jsx(cr,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-label text-muted-foreground",children:[t.jsx(ey,{run:h}),h.effort&&t.jsxs("span",{children:["effort ",h.effort]}),h.imported_from&&t.jsxs("span",{children:["Imported history · ",h.imported_from.source]})]})]}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:ht(h.created_at)}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:h.ended_at?t.jsx("span",{title:"How long it ran",children:dl(Date.parse(h.ended_at)-Date.parse(h.created_at))}):"—"}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3 text-muted-foreground",children:h.cost&&(h.cost.usd!==null||jl(h.cost))?eo(h.cost,{ended:Wa(h.status)}):"—"})]},h.run_id))})]}),!x.length&&t.jsx("p",{className:"p-10 text-center text-body text-muted-foreground",children:"No loaded runs match your search."})]}):t.jsxs("div",{className:"px-4 py-12 text-center text-body text-muted-foreground",children:[t.jsx("p",{children:"No runs of this agent yet."}),!e.archived_at&&t.jsx("p",{className:"mt-2",children:"Choose Run agent to continue with your coding agent or the API playground."})]}),u&&t.jsxs("div",{className:"m-4 space-y-3",children:[t.jsx(Yt,{problem:u,onRetry:f,className:""}),b&&t.jsx(B,{size:"sm",onClick:b,disabled:c,children:"Reload latest runs"})]}),i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",onClick:g,disabled:c,children:d?"Loading":"Load more"})})]})}function GD({agent:e}){const n=e.definition.workflow,s=p.useMemo(()=>ll(n),[n]),r=p.useMemo(()=>({meta:cd(n,s)}),[n,s]);return t.jsxs("section",{className:"overflow-hidden border",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[Um(Qv(s))," · rev ",e.definition.version]}),t.jsx("span",{className:"flex-1"}),t.jsx(tn,{label:"Edit workflow",prompt:Ho(location.origin,e.agent_id),playgroundHref:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`})]}),t.jsx("div",{className:"min-h-[360px] overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-5",children:s.nodes.length?t.jsx(xd,{graph:s,marks:r,label:"The workflow's graph",minScale:.55}):t.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"This revision's workflow has no root node to draw."})}),t.jsx("div",{className:"border-t px-4 py-2",children:t.jsx(vd,{})})]})}function CC({size:e=18,className:n}){return t.jsx("svg",{width:e,height:e,className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M3 4q9 4 18 0M4 9h16M7 6v15M17 6v15M6 15h12M12 7v2"})})}const qD=20,KD=100,VD=4,Mi=(e,n)=>(e==null?void 0:e.filter(s=>s.status===n).length)??0,EC=e=>`#/agents/${encodeURIComponent(e.agent_id)}/learning`,hx=e=>e.toLocaleString("en-US"),$C=[{label:"Active notes",of:e=>e.view?{value:Mi(e.notes,"active"),exact:!!e.complete}:null},{label:"Learned skills",of:e=>{var n;return(n=e.view)!=null&&n.skills?{value:Mi(e.view.skills,"active"),exact:!0}:null}},{label:"Workflow drafts",of:e=>{var n;return(n=e.view)!=null&&n.workflows?{value:Mi(e.view.workflows,"active"),exact:!0}:null}},{label:"Pending review",of:e=>e.view?{value:Mi(e.notes,"pending")+Mi(e.view.skills,"pending")+Mi(e.view.workflows,"pending"),exact:!!e.complete&&!!e.view.skills&&!!e.view.workflows}:null},{label:"In progress",of:e=>e.view?{value:e.view.counts.in_progress,exact:!0}:null}];function _C(e,n){if(!e.length)return"0";const s=e.map(n);return s.every(r=>r===null)?"—":`${hx(s.reduce((r,a)=>r+((a==null?void 0:a.value)??0),0))}${e.some(r=>r.stale)?" (last read)":s.every(r=>r==null?void 0:r.exact)?"":"+"}`}function YD({v2:e,server:n}){const[s,r]=p.useState(null),[a,i]=p.useState(null),[c,d]=p.useState(!1),[u,f]=p.useState(null),g=p.useRef(0),b=p.useRef(!1),x=p.useCallback(async()=>{if(n!=="on"&&n!=="off"||b.current)return;b.current=!0;const k=++g.current;d(!0),i(null),r(S=>(S==null?void 0:S.map(N=>N.view?{...N,stale:!0}:N))??null);const E=()=>g.current===k;try{let S=null;const N=new Set,_=await qr(async M=>{if(!E())throw new Error("Read superseded");if(M&&N.has(M))throw new Error("The agent list repeated a page. Refresh to try again.");M&&N.add(M);const R=await e.listAgents({cursor:M});return S=R.next_cursor,R},M=>M.agents,KD);if(!E())return;if(S)throw new Error("The agent list is too large to read in one view. Open Connected agents to inspect an agent.");const $=[...new Map(_.map(M=>[M.agent_id,M])).values()].map(M=>({agent:M}));r(M=>{const R=new Map(M==null?void 0:M.map(P=>[P.agent.agent_id,P]));return $.map(({agent:P})=>{const D=R.get(P.agent_id);return P.kind==="agentic"&&(D==null?void 0:D.agent.kind)==="agentic"&&D.view?{...D,agent:P,stale:!0,error:void 0,unavailable:void 0}:{agent:P}})});const O=$.filter(M=>M.agent.kind==="agentic");let A=0;const L=async()=>{for(;E()&&A<O.length;){const{agent:M}=O[A++];let R;try{const P=await e.agentLearning(M.agent_id);if(!E())return;const D=new Map(P.notes.items.map(q=>[q.file,q]));let W=P.notes.next_cursor,Y;const H=new Set;for(let q=0;W&&q<qD&&E();q++){if(H.has(W)){Y="The note list repeated a page.";break}H.add(W);try{const F=await e.learningNotes(M.agent_id,W);F.items.forEach(G=>D.set(G.file,G)),W=F.next_cursor}catch(F){Y=Ut(F,"more notes").why;break}}R={agent:M,view:P,notes:[...D.values()],complete:!W,...W?{noteIssue:Y??"More note pages are available in the agent's Learning tab."}:{}}}catch(P){R={agent:M,error:Ut(P,"Learning"),unavailable:P instanceof De&&P.status===404}}if(!E())return;r(P=>(P==null?void 0:P.map(D=>D.agent.agent_id!==M.agent_id?D:R.error&&!R.unavailable&&D.view?{...D,...R,stale:!0}:R))??null)}};await Promise.all(Array.from({length:Math.min(VD,O.length)},L)),E()&&f(new Date().toISOString())}catch(S){E()&&i(Ut(S,"Learning Dojo"))}finally{E()&&(b.current=!1,d(!1))}},[e,n]);p.useEffect(()=>{r(null),f(null),i(null),x();const k=()=>{document.hidden||x()};return window.addEventListener("focus",k),document.addEventListener("visibilitychange",k),()=>{g.current++,b.current=!1,window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",k)}},[x]),p.useEffect(()=>{if(n!=="on"&&n!=="off")return;const k=window.setInterval(()=>{document.hidden||x()},15e3);return()=>window.clearInterval(k)},[n,x]);const h=(s==null?void 0:s.filter(k=>k.agent.kind==="agentic"))??[],v=h.filter(k=>k.view).length,y=h.some(k=>k.stale),j=h.flatMap(k=>{var E;return(((E=k.view)==null?void 0:E.log.items)??[]).map(S=>({agent:k.agent,change:S}))}).sort((k,E)=>E.change.at.localeCompare(k.change.at)).slice(0,8);return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 items-center gap-2 border-b px-5",children:[t.jsx(CC,{className:"shrink-0"}),t.jsx("h1",{className:"caps text-body font-semibold",children:"Learning Dojo"}),t.jsx(B,{className:"ml-auto",size:"icon","aria-label":"Refresh Learning Dojo",disabled:c||!n,onClick:()=>void x(),children:t.jsx(Qo,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-7 p-5 md:p-8",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"What your agents learn"}),t.jsx("p",{className:"mt-2 max-w-3xl text-lead leading-relaxed text-muted-foreground",children:"Review the notes, skills and workflow drafts your current agents keep for later runs. Open an agent to enable learning, inspect its changes or review pending items."}),t.jsx("p",{className:"mt-2 max-w-3xl text-small leading-relaxed text-muted-foreground",children:"Imported sessions are history, not learning runs. Learning comes from agentic runs started through this server; notes you add yourself are included too."})]}),n===void 0?t.jsx("p",{role:"status",className:"text-lead text-muted-foreground",children:"Checking learning support…"}):n===null?t.jsxs("div",{className:"border bg-card p-5",children:[t.jsx("h3",{className:"font-semibold",children:"This server does not expose learning"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"Use a server version with learning support to inspect or enable it here."}),t.jsx("a",{href:"#/agents",className:"mt-4 inline-block text-lead text-primary-text underline underline-offset-4",children:"Connected agents"})]}):t.jsxs(t.Fragment,{children:[n==="off"&&t.jsx("p",{role:"status",className:"border border-warning/40 bg-warning/5 p-4 text-lead text-warning-text",children:"This server has learning turned off. Saved learning remains available; new runs will learn only after the server's learning setting is on."}),a&&t.jsxs(t.Fragment,{children:[t.jsx(Yt,{problem:a,onRetry:()=>void x(),className:""}),s&&t.jsx("p",{className:"text-small text-warning-text",children:"Showing the last read. Refresh to update these counts."})]}),!s&&!a?t.jsx(Fn,{label:"Loading Learning Dojo",rows:4}):s&&t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"grid grid-cols-2 gap-3 xl:grid-cols-5",children:$C.map(({label:k,of:E})=>t.jsxs("div",{"aria-label":k,className:"border bg-card p-4",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:k}),t.jsx("dd",{className:"mt-3 font-mono text-display",children:_C(h,E)})]},k))}),t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:[v," of ",h.length," agent histories read. Counts show active items; pending notes, skills and drafts are counted under review. + means a minimum from incomplete data; — means not reported.",y?" Last-read totals include saved histories that may have changed; they are not current minimums.":u&&!c?` Updated ${ht(u)}.`:"",c?" Loading learning…":""]}),s.length?t.jsx("section",{"aria-label":"Agents in Dojo",className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:s.map(k=>t.jsx(QD,{row:k,server:n},k.agent.agent_id))}):t.jsxs("div",{className:"border px-6 py-10 text-center",children:[t.jsx("h3",{className:"font-semibold",children:"No agents yet"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"Create an agent, then open its Learning tab to let its runs build on what they learn."}),t.jsx("a",{className:"mt-4 inline-block text-lead text-primary-text underline underline-offset-4",href:"#/agents/new",children:"Build an agent"}),t.jsx("span",{className:"mx-3 text-muted-foreground",children:"·"}),t.jsx("a",{className:"text-lead text-primary-text underline underline-offset-4",href:"#/agents",children:"Import existing agents"})]}),h.length>0&&t.jsxs("section",{className:"overflow-hidden border","aria-label":"Recent learning changes",children:[t.jsxs("header",{className:"border-b px-5 py-4",children:[t.jsx("h3",{className:"text-lead font-semibold",children:"Recent learning changes"}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"Latest reported changes from the histories read above. Each agent's Learning tab has its full history and run outcomes."})]}),j.length?t.jsx("ul",{className:"divide-y",children:j.map(({agent:k,change:E})=>t.jsx("li",{children:t.jsxs("a",{href:"run"in E.by?`#/runs/${encodeURIComponent(E.by.run)}`:EC(k),className:"flex items-start gap-3 px-5 py-4 hover:bg-accent",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block text-lead",children:E.reason||"Learning updated"}),t.jsxs("span",{className:"mt-1 block text-small text-muted-foreground",children:[k.definition.name||k.agent_id," · ","run"in E.by?"From a run":"Edited by you"," · ",ht(E.at)]})]}),t.jsx(cr,{className:"mt-1 size-3.5 shrink-0","aria-hidden":!0})]})},`${k.agent_id}:${E.commit}`))}):t.jsx("p",{className:"px-5 py-7 text-lead text-muted-foreground",children:c?"Loading learning changes…":v<h.length?"No changes in the histories available so far.":"No saved learning changes yet."})]})]})]})]})]})}function QD({row:e,server:n}){const{agent:s,view:r,error:a}=e,i=s.kind==="agentic",c=s.definition.learning===!0||s.definition.learning==="notes";return t.jsxs("article",{className:"flex min-w-0 flex-col border bg-card p-5",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[t.jsx("h3",{className:"min-w-0 break-words text-lead font-semibold",children:s.definition.name||s.agent_id}),t.jsx(Ne,{tone:i&&c&&n==="on"?"success":"plain",children:i?n==="off"&&c?"Paused by server":c?"Learning on":"Learning off":"Workflow"})]}),i?t.jsxs(t.Fragment,{children:[a&&t.jsxs("div",{role:"alert",className:"mt-4 text-small text-destructive-text",children:[t.jsx("p",{children:e.unavailable?"Learning unavailable for this agent.":a.title}),t.jsxs("p",{className:"mt-1",children:[a.why," ",a.said]})]}),r?t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"mt-5 grid grid-cols-2 gap-x-4 gap-y-3",children:$C.map(({label:d,of:u})=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-small text-muted-foreground",children:d}),t.jsx("dd",{className:"mt-1 font-mono text-lead",children:_C([e],u)})]},d))}),e.stale&&t.jsx("p",{role:"status",className:"mt-3 text-small text-warning-text",children:"Showing the last read. Refresh to update this history."}),t.jsxs("p",{className:"mt-4 text-small text-muted-foreground",children:[hx(r.counts.merged)," runs kept learning · ",hx(Object.values(r.counts.dropped).reduce((d,u)=>d+u,0))," kept nothing"]}),e.noteIssue&&t.jsxs("p",{className:"mt-3 text-small text-warning-text",children:["Some note counts are incomplete. ",e.noteIssue]}),(!r.skills||!r.workflows)&&t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"This server does not report every learned-file category."})]}):!a&&t.jsx("p",{role:"status",className:"mt-4 text-lead text-muted-foreground",children:"Loading learning…"})]}):t.jsx("p",{className:"mt-4 text-lead text-muted-foreground",children:"Workflow runs do not learn. Enable learning on an agentic agent."}),t.jsxs("a",{className:"mt-5 inline-flex items-center gap-2 self-start text-small font-semibold text-primary-text hover:underline hover:underline-offset-4",href:i?EC(s):ln(s.agent_id),children:[i?"Open learning":"View agent",t.jsx(cr,{className:"size-3.5","aria-hidden":!0})]})]})}const JD=140,XD=32,ZD=40,eF=60;function ny({value:e,name:n,note:s,blurb:r,description:a,tag:i,why:c,alert:d,on:u,disabled:f,warn:g,onToggle:b}){const[x,h]=p.useState(!1),v=p.useRef(null),y=p.useRef(null),j=p.useRef(null),k=p.useRef(null),E=Ku(v,"width",x,n),S=Ku(y,"height",x,a),N=Ku(j,"width",x,i),_=Ku(k,"width",x,d),$=E??n.length>XD,O=!!a&&(S??a.length>JD),A=!!i&&(N??i.length>ZD),L=!!d&&(_??d.length>eF),M=!!c&&(c!==i||A),R=!!a&&(!!r||O)||M||L||$,P=(W,Y)=>!x&&W&&Y?W:void 0,D=W=>{W.preventDefault(),W.stopPropagation(),h(Y=>!Y)};return t.jsxs("label",{"data-tool-card":e,className:oe("flex w-full min-w-0 flex-col border px-3 py-2.5 font-mono text-body",x?"min-h-36":"h-36 overflow-hidden",u&&"border-foreground",g&&"border-warning/60",f?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("input",{type:"checkbox",value:e,checked:u,disabled:f,onChange:b,className:"shrink-0 accent-primary"}),t.jsx("span",{ref:v,title:P(n,$),className:oe("min-w-0",x?"[overflow-wrap:anywhere]":"truncate"),children:n}),s&&t.jsx("span",{className:"shrink-0 font-sans text-label text-muted-foreground",children:s})]}),r?t.jsx("span",{"data-line":!0,className:"mt-1 truncate font-sans text-small text-muted-foreground",children:r}):a&&!x?t.jsx("span",{ref:y,"data-line":!0,className:"mt-1 line-clamp-3 font-sans text-label text-muted-foreground [overflow-wrap:anywhere]",title:P(a,O),children:a}):null,i&&t.jsx("span",{ref:j,"data-tag":!0,title:P(c,M),className:"mt-1 max-w-full self-start truncate border px-1.5 text-micro text-muted-foreground",children:i}),d&&!x&&t.jsx("span",{ref:k,className:"mt-1 truncate font-sans text-label text-warning-text",role:"alert",title:P(d,L),children:d}),x&&t.jsxs("span",{"data-more":!0,className:"mt-2 min-w-0 space-y-1 font-sans text-label text-muted-foreground",children:[a&&t.jsx("span",{className:"block whitespace-pre-wrap [overflow-wrap:anywhere]",children:a}),c&&c!==a&&t.jsx("span",{className:"block [overflow-wrap:anywhere]",children:c}),d&&t.jsx("span",{className:"block text-warning-text [overflow-wrap:anywhere]",role:"alert",children:d})]}),R&&t.jsx("button",{type:"button",onClick:D,"aria-expanded":x,className:"mt-auto self-start pt-1 font-sans text-label underline underline-offset-2 hover:text-foreground",children:x?"Less":"More"})]})}function Ku(e,n,s,r){const[a,i]=p.useState(null);return p.useLayoutEffect(()=>{const c=e.current;if(s||!c)return;const d=()=>{(n==="width"?c.clientWidth>0:c.clientHeight>0)&&i(n==="width"?c.scrollWidth>c.clientWidth+1:c.scrollHeight>c.clientHeight+1)};d();const u=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return u==null||u.observe(c),()=>u==null?void 0:u.disconnect()},[e,n,s,r]),a}function tF({servers:e,tools:n,harness:s,harnesses:r,onChange:a,onRetry:i}){const c=h=>a(n.includes(h)?n.filter(v=>v!==h):[...n,h]),d=n.filter(h=>Bo(h)),u=!r||r.includes(s),f=(h,v,y,j,k,E)=>{const S=n.includes(h),N=(!u||!!k)&&!S,_=j??k??(S&&!u?`Won't run on ${s}.`:void 0);return t.jsx("li",{className:"min-w-0",children:t.jsx(ny,{value:h,name:v,note:E,description:y,alert:_,on:S,disabled:N,warn:!!j,onToggle:()=>c(h)})},h)},g=h=>t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:h}),b=!u&&t.jsxs("p",{className:"text-small text-warning-text",children:[s," doesn't run MCP tools on this server",r!=null&&r.length?`: ${r.join(" and ")} do`:"","."]});if(e==="failed")return t.jsxs("div",{className:"mt-4 space-y-2",children:[t.jsxs("p",{className:"font-mono text-small text-warning-text",role:"alert",children:["The MCP servers could not be read."," ",i&&t.jsx(B,{type:"button",onClick:i,size:"xs",className:"ml-1",children:"Retry"})]}),d.length>0&&g(d.map(h=>f(h,h,"Can't check right now whether its server still lists it.")))]});if(!e)return d.length?t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:"Reading the MCP servers..."}):null;const x=aI(n,e);return!e.length&&!x.length?t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"No MCP server is saved: add one in Settings → MCP servers to grant its tools."}):t.jsxs("div",{className:"mt-4 space-y-4",children:[b,e.map(h=>t.jsxs("section",{"aria-label":`MCP server ${h.name}`,children:[t.jsxs("p",{className:"caps mb-2 text-label font-semibold text-muted-foreground",children:[h.name," · MCP server"]}),g(h.tools.map(v=>{var y;return f(I2(h.name,v.name),v.name,[v.title,v.description].filter(Boolean).join(": ")||void 0,void 0,oI(v,s)??(v.permission==="deny"?ty:void 0),(y=h.not_metered)!=null&&y.includes(v.name)?"not metered":void 0)}))]},h.name)),x.length>0&&t.jsxs("section",{"aria-label":"MCP grants that can't run",children:[t.jsx("p",{className:"caps mb-2 text-label font-semibold text-warning-text",children:"Granted, but not on a saved server"}),g(x.map(h=>f(h.grant,h.grant,void 0,h.why)))]})]})}const nF="[a-z][a-z0-9-]{0,31}",TC="[A-Za-z0-9_-]{1,64}",sF="[a-z0-9][a-z0-9.-]{0,63}",rF="[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}",oF=`[a-z][a-z0-9_-]{0,63}(?:\\.${TC})?`,aF="mcp:",iF="monid:",f0="*",lF=new RegExp(`^mcp:(${nF})/(\\*|${TC})$`),cF=new RegExp(`^monid:(${sF})/(\\*|${rF})$`),dF=new RegExp(`^${oF}$`);function uF(e){if(fl(e)){const s=cF.exec(e);return s?s[2]===f0?{kind:"monid-provider",provider:s[1]}:{kind:"monid",provider:s[1],endpoint:s[2]}:void 0}if(!mF(e))return dF.test(e)?{kind:"plain",name:e}:void 0;const n=lF.exec(e);if(n)return n[2]===f0?{kind:"mcp-server",server:n[1]}:{kind:"mcp",server:n[1],tool:n[2]}}const fl=e=>e.startsWith(iF),fF=e=>`${e} is not a monid endpoint's name: monid:<provider>/<endpoint> or monid:<provider>/*, the provider's slug (lowercase letters, digits, . and -) and the endpoint's path without its first / (letters, digits and -._:{}/), as monid lists them.`,mF=e=>e.startsWith(aF);function RC(e){const n=uF(e);return(n==null?void 0:n.kind)==="monid"?{provider:n.provider,endpoint:n.endpoint}:(n==null?void 0:n.kind)==="monid-provider"?{provider:n.provider,endpoint:null}:void 0}const hF=e=>RC(e)?void 0:fF(e);function pF(e){const n=e.trim();return!n||fl(n)?n:`monid:${n}`}function AC(e){return new Map(e.flatMap((n,s)=>fl(n)?[[`definition.tools[${s}]`,n]]:[]))}function gF(e,n){const s=AC(n),r=[],a=[];for(const i of e){const c=s.get(i.field);c?r.push({grant:c,warning:i}):a.push(i)}return{monid:r,rest:a}}const xF=e=>{const n=RC(e);return n?n.endpoint===null?`Every endpoint of ${n.provider} that monid prices per call, as monid lists them when the agent is saved.`:`${n.provider}'s /${n.endpoint}, priced and pinned when the agent is saved.`:"Not a monid endpoint's name: the save refuses it. Untick it."};function vF({tools:e,listed:n=[],notes:s=[],refused:r=[],onChange:a}){const[i,c]=p.useState(""),[d,u]=p.useState(void 0),f=[...new Set([...n,...e].filter(fl))],g=x=>a(e.includes(x)?e.filter(h=>h!==x):[...e,x]),b=()=>{const x=pF(i);if(!x)return;const h=hF(x);u(h),!h&&(c(""),e.includes(x)||a([...e,x]))};return t.jsxs("section",{"aria-label":"monid endpoints",className:"mt-4 space-y-2",children:[t.jsx("p",{className:"caps text-label font-semibold text-muted-foreground",children:"monid · paid endpoints"}),f.length>0&&t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:f.map(x=>{const h=r.filter(v=>v.grant===x);return t.jsx("li",{className:"min-w-0",children:t.jsx(ny,{value:x,name:x,description:xF(x),alert:h.length?"The save was refused here: see below.":void 0,warn:h.length>0,on:e.includes(x),disabled:!1,onToggle:()=>g(x)})},x)})}),t.jsxs("form",{className:"flex flex-wrap items-start gap-2",onSubmit:x=>{x.preventDefault(),b()},children:[t.jsx(ze,{"aria-label":"monid grant",value:i,onChange:x=>{c(x.target.value),u(void 0)},"aria-invalid":d?!0:void 0,placeholder:"monid:<provider>/<endpoint> or monid:<provider>/*",className:"min-w-0 flex-[1_1_18rem]",spellCheck:!1,autoCapitalize:"off",autoComplete:"off"}),t.jsxs(B,{type:"submit",size:"sm",className:"h-control-md",disabled:!i.trim(),children:[t.jsx(pl,{"aria-hidden":!0})," Grant"]})]}),d&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:d}),t.jsx("p",{className:"text-small text-muted-foreground",children:"A grant is priced and pinned when the agent is saved, from what monid lists then. monid's key is set in Settings → Tool keys."}),r.length>0&&t.jsx("ul",{className:"space-y-1 font-mono text-small text-destructive-text",role:"alert","aria-label":"monid grants refused",children:r.map((x,h)=>t.jsx("li",{children:x.message},`${x.grant}:${h}`))}),s.length>0&&t.jsx("ul",{className:"space-y-1 font-mono text-small text-warning-text",role:"status","aria-label":"monid save warnings",children:s.map((x,h)=>t.jsx("li",{children:x.message},`${x.grant}:${h}`))})]})}const yF=e=>e.offered&&(e.kind==="none"||e.providers.some(n=>n.ready)),bF=e=>{var n;return e.why??((n=e.providers.find(s=>!s.ready))==null?void 0:n.why)};function wF(e,n){var a;if(e.kind==="none")return{kind:"none"};const r=((n==null?void 0:n.kind)===e.kind&&e.providers.some(i=>i.ready&&i.id===n.provider)?n.provider:void 0)??((a=e.providers.find(i=>i.ready))==null?void 0:a.id);return r?{kind:e.kind,provider:r}:{kind:e.kind}}const jF=e=>e.kind==="sandbox"&&e.provider?{mode:"sandbox",box:e.provider}:{mode:"runner"},sy="This provider bills by the minute through your own vendor account, and those minutes aren't counted in a run's spending cap.",ry=new Set(["sandbox","desktop","phone"]),kF=e=>e.charAt(0).toUpperCase()+e.slice(1);function NF({kinds:e,value:n,onChange:s,error:r,warning:a}){const i=e.find(c=>c.kind===n.kind);return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Kind"}),t.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-5",role:"radiogroup","aria-label":"Kind",children:e.map(c=>{const d=yF(c),u=d?void 0:bF(c),f=c.providers.filter(g=>g.ready).map(g=>g.name).join(", ");return t.jsxs("div",{"data-kind":c.kind,className:oe("border px-4 py-3",n.kind===c.kind?"border-foreground":"border-border",!d&&"opacity-60"),children:[t.jsxs("label",{className:oe("flex items-start gap-3",d?"cursor-pointer":"cursor-not-allowed"),children:[t.jsx("input",{type:"radio",name:"computer-kind",value:c.kind,checked:n.kind===c.kind,disabled:!d&&n.kind!==c.kind,onChange:()=>s(wF(c,n)),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-lead font-semibold",children:kF(c.kind)}),t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:d?c.kind==="none"?"The run's folder only":f:"Not available here"})]})]}),u&&t.jsxs("p",{className:"mt-2 break-words text-small text-muted-foreground",children:[u," ",t.jsx("a",{href:"#/settings/computers",className:"underline underline-offset-2 hover:text-foreground",children:"Computers settings"})]})]},c.kind)})}),i&&i.kind!=="none"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mb-2 mt-5 caps text-small font-semibold",children:"Provider"}),t.jsx("ul",{className:"border",role:"radiogroup","aria-label":"Provider",children:i.providers.map(c=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("label",{className:oe("flex items-start gap-3 px-4 py-2.5",c.ready?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"computer-provider",value:c.id,checked:n.provider===c.id,disabled:!c.ready&&n.provider!==c.id,onChange:()=>s({kind:i.kind,provider:c.id}),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("span",{className:"text-body font-semibold",children:c.name}),c.metered&&t.jsx("span",{className:"caps text-label text-muted-foreground",children:"Metered"})]}),c.metered&&ry.has(i.kind)&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:sy}),!c.ready&&c.why&&t.jsx("span",{className:"mt-0.5 block text-small",children:c.why})]})]})},c.id))})]}),i&&i.tools.length>0&&t.jsxs("p",{className:"mt-4 border bg-muted/40 px-4 py-2.5 text-small","aria-label":"Tools this computer adds",children:["This computer adds these tools: ",t.jsx("span",{className:"font-mono",children:i.tools.join(", ")})]}),r&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:r}),a&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:a})]})}function SF({value:e,saved:n,places:s,tools:r,picked:a,onChange:i,error:c,warning:d}){var N;const u=e??dd(n),f=(u??Pv(!1,a,s)).mode,g=(N=s.boxes.find(_=>_.available))==null?void 0:N.id,b=(u==null?void 0:u.mode)==="sandbox"?u.box:g,x=!g&&f!=="sandbox",h=new Set(r.filter(_=>_.sandbox_only).map(_=>_.name)),[v,y]=p.useState([]),j=()=>{const _=a.filter($=>h.has($));y(_),i({place:{mode:"runner"},..._.length?{tools:a.filter($=>!h.has($))}:{}})},k=_=>{y([]),_&&i({place:{mode:"sandbox",box:_}})},E=_=>_.map($=>$.charAt(0).toUpperCase()+$.slice(1)).join(" and "),S=(_,$,O,A,L=!1)=>t.jsxs("label",{className:oe("flex items-start gap-3 border px-4 py-3",f===_?"border-foreground":"border-border",L?"cursor-not-allowed opacity-60":"cursor-pointer"),children:[t.jsx("input",{type:"radio",name:"place",value:_,checked:f===_,disabled:L,onChange:A,className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"block text-lead font-semibold",children:$}),t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:O})]})]});return t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 caps text-small font-semibold",children:"Where it runs"}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"radiogroup","aria-label":"Where it runs",children:[S("runner","On the server","No box and no shell: its files stay in the run's folder on the server.",j),S("sandbox","In a sandbox","Its file and shell tools run in a box; its keys stay on the server.",()=>k(b),x)]}),x&&t.jsxs("div",{className:"mt-3 border px-4 py-3 text-small text-muted-foreground",role:"status",children:[t.jsx("p",{children:"No box is set up on this server, so this agent runs on the server."}),t.jsx("ul",{className:"mt-1",children:s.boxes.map(_=>t.jsxs("li",{children:[t.jsx("span",{className:"font-mono",children:_.id}),_.reason?`: ${_.reason}`:""]},_.id))})]}),f==="sandbox"&&t.jsx("ul",{className:"mt-3 border","aria-label":"Box",children:s.boxes.map(_=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("label",{className:oe("flex items-start gap-3 px-4 py-2.5",_.available?"cursor-pointer":"cursor-not-allowed text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"box",value:_.id,checked:b===_.id,disabled:!_.available&&b!==_.id,onChange:()=>k(_.id),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-mono text-body",children:_.id}),!_.available&&_.reason&&t.jsx("span",{className:"mt-0.5 block text-small",children:_.reason})]})]})},_.id))}),f==="runner"&&v.length>0&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:[E(v)," ",v.length===1?"runs":"run"," only in a sandbox, so ",v.length===1?"it's":"they're"," turned off for this agent."]}),c&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:c}),d&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:d})]})}function OC(e,n,s=n.map(r=>r.name)){return[...new Set([...s.filter(a=>e.some(i=>i.name===a)||n.some(i=>i.name===a)),...n.map(a=>a.name),...e.map(a=>a.name)])].map(a=>{const i=e.find(d=>d.name===a),c=n.find(d=>d.name===a);return{name:a,...i?{choice:i}:{},...c?{gate:c}:{}}})}function px({setting:e,label:n="Pinned",also:s=!1}){return e!=null&&e.pin_broken?t.jsx("p",{className:"max-w-[640px] text-small text-warning-text",role:"note",children:zD}):e!=null&&e.pin?t.jsxs("p",{className:"max-w-[640px] text-small text-muted-foreground",role:"note",children:[t.jsxs("span",{className:"text-foreground",children:[n,":"]})," ",LD(e.pin),". ",ID,s?" This server pins it too; both hold.":""]}):null}const m0={read:["info","Read-only, its server says: under Allow reads it runs without asking."],write:["warning","Not read-only, and not marked destructive by its server: it keeps its permission."],destructive:["error","May delete or overwrite, its server says: allowing it takes a second click."]},CF=({effect:e})=>t.jsx("span",{"data-effect":e,children:t.jsx(Ne,{tone:m0[e][0],title:m0[e][1],children:e})}),EF="Ask is off on this server: approving a call takes the owner's password sign-in, and this server runs with accounts off.";function oy({label:e,rows:n,settings:s,fallbackOf:r,permissionFallbackOf:a=E=>E.default_permission,resolvesOf:i,issues:c,busy:d=!1,refused:u=()=>!1,locked:f=!1,unattended:g=!1,noteOf:b,labelOf:x,detailOf:h,effectOf:v,confirmAllowOf:y=()=>!1,fallbackWordOf:j,onEdit:k}){const[E,S]=p.useState(null),N=p.useRef(null),_=p.useRef(null);p.useEffect(()=>{var D,W;if(E!==null||d||N.current===null)return;const P=`${N.current} permission`;N.current=null,(W=[...((D=_.current)==null?void 0:D.querySelectorAll("button[aria-label]"))??[]].find(Y=>Y.getAttribute("aria-label")===P))==null||W.focus()},[E,d]);const $=P=>{N.current=P,S(null)},O=n.some(P=>P.choice),A=n.some(P=>P.gate),L=n.some(P=>{var D;return((D=P.gate)==null?void 0:D.ask_needs)==="password"}),M=["Tool",...A?["Permission"]:[],...O?["Provider","Resolves to"]:[]],R=t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"—"});return t.jsxs(t.Fragment,{children:[L&&t.jsx("p",{className:"mb-2 text-small text-warning-text",children:EF}),t.jsx("div",{ref:_,className:"relative overflow-x-auto",children:t.jsxs("table",{"aria-label":e,className:"w-full border text-left",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b",children:[M.map(P=>t.jsx("th",{className:"caps px-3 py-2 text-label font-semibold text-muted-foreground",children:P},P)),t.jsx("th",{children:t.jsx("span",{className:"sr-only",children:"Reset"})})]})}),t.jsx("tbody",{children:n.map(({name:P,choice:D,gate:W})=>{var fe,me,je;const Y=D?r(D):"",H=(fe=s[P])==null?void 0:fe.provider,q=D!==void 0&&H!==void 0&&H!==Y,F=q?H:Y,G=Me=>k(_e=>RD(_e,P,Me,Y)),U=W?a(W):"allow",z=(me=s[P])==null?void 0:me.permission,Q=W!==void 0&&z!==void 0&&z!==U,K=Q?z:U,Z=W!==void 0&&u(P,K),de=Z&&f,se=de?"deny":K,ue=Me=>k(_e=>AD(_e,P,Me,U)),xe=v==null?void 0:v(P),$e=(j==null?void 0:j(P))??"default",ge=h==null?void 0:h(P);return t.jsxs(p.Fragment,{children:[t.jsxs("tr",{"data-tool":P,"data-set":q||Q?"":void 0,className:"border-b align-top last:border-b-0",children:[t.jsxs("td",{className:"px-3 py-2.5 font-mono text-body",children:[t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[(x==null?void 0:x(P))??P,xe&&t.jsx(CF,{effect:xe})]}),ge?t.jsx("span",{"data-tool-detail":!0,className:"mt-0.5 block text-small text-muted-foreground",children:ge}):null]}),A&&t.jsx("td",{className:"px-3 py-2",children:W?t.jsxs(t.Fragment,{children:[t.jsx(Rt,{small:!0,label:`${P} permission`,value:se,disabled:d||de,onChange:Me=>{const _e=Me;_e==="allow"&&_e!==se&&y(P)?S(P):ue(_e)},className:oe("w-48",Q&&"border-primary text-primary"),options:W.permissions.map(Me=>({value:Me,label:`${Me}${Me===U?` (${$e})`:""}`,...Me==="ask"&&W.ask_needs==="password"&&!g?{disabled:!0,title:"No one can approve a call here: it takes the owner's password sign-in."}:{}}))}),Q&&!de&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",U,$e==="default"?"":` (${$e})`]}),Z&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-warning-text",children:ty}),se==="deny"&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-muted-foreground",children:ED}),se==="ask"&&g&&!Z&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Runs without asking: Never ask is on."}),se==="ask"&&W.ask_needs==="password"&&!g&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Each call is refused: no one can approve it here."})]}):R}),O&&t.jsx("td",{className:"px-3 py-2",children:D?t.jsxs(t.Fragment,{children:[t.jsx(Rt,{small:!0,label:`${P} provider`,value:F,disabled:d,onChange:Me=>G(Me),className:oe("w-96 max-w-full",q&&"border-primary text-primary"),options:D.providers.map(Me=>({value:Me,label:`${Uf(Me,P)}${Me===Y?" (default)":""}`}))}),u0(F,P)&&t.jsx("span",{className:"mt-1 block max-w-[300px] text-label text-muted-foreground",children:u0(F,P)}),q&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",Uf(Y,P)]})]}):R}),O&&t.jsx("td",{className:"px-3 py-2.5",children:D?i(D,F):R}),t.jsx("td",{className:"px-2 py-2 text-right",children:q&&t.jsx(B,{size:"sm",variant:"ghost",disabled:d,"aria-label":`Reset ${P} to its default`,onClick:()=>G(void 0),children:"Reset"})})]}),E===P&&t.jsx("tr",{children:t.jsx("td",{colSpan:M.length+1,className:"px-3 pb-2.5",children:t.jsx($F,{name:P,keep:se==="ask"?"Keep asking":"Cancel",busy:d,onAllow:()=>{d||($(P),ue("allow"))},onKeep:()=>$(P)})})}),b!=null&&b(P)?t.jsx("tr",{"data-note":P,children:t.jsx("td",{colSpan:M.length+1,className:"px-3 pb-2.5",children:b(P)})}):null,(je=c[P])!=null&&je.length?t.jsx("tr",{children:t.jsx("td",{colSpan:M.length+1,className:"px-3 pb-2.5",children:c[P].map(Me=>t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:Me},Me))})}):null]},P)})})]})})]})}function $F({name:e,keep:n,busy:s,onAllow:r,onKeep:a}){const i=p.useRef(null);return p.useEffect(()=>{var c;(c=i.current)==null||c.focus()},[]),t.jsxs("div",{role:"alertdialog","aria-label":`Allow ${e} without asking?`,onKeyDown:c=>{c.key==="Escape"&&(c.stopPropagation(),a())},className:"flex flex-wrap items-center gap-3 border border-destructive/50 bg-card px-3 py-2.5",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Allow a destructive tool?"})," Its server marks ",t.jsx("span",{className:"break-all font-mono",children:e})," as one that may delete or overwrite: every call would run with no one asked."]}),t.jsx(B,{ref:i,type:"button",size:"sm",variant:"ghost",onClick:a,children:n}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",disabled:s,onClick:r,children:"Allow without asking"})]})}function gx({value:e,prefix:n,tool:s}){const r=kC(e,s);return t.jsxs("span",{className:oe("block font-mono text-small",r.unavailable?"text-warning-text":"text-muted-foreground"),children:[n,r.text]})}const _F=({choice:e,harnesses:n=[]})=>t.jsx(t.Fragment,{children:kD.map(s=>{const r=n.find(a=>a.id===s&&!a.available);return r?t.jsxs("span",{title:r.reason,className:"block font-mono text-small text-muted-foreground",children:[s,": not offered here"]},s):t.jsx(gx,{value:e.resolves[s],prefix:`${s}: `,tool:e.name},s)})});function TF({agent:e,harness:n,model:s,tools:r,choices:a,gates:i=[],mcpServers:c,serverSettings:d,focus:u,callTools:f,value:g,issues:b,unattended:x=!1,onChange:h}){const v=new Set(r),y=a.filter(R=>v.has(R.name)||!R.available),j=i.some(R=>R.ask_needs==="password"),k=R=>{var P;return(P=e==null?void 0:e.tools)==null?void 0:P.find(D=>D.name===R)},E=R=>{var D;const P=Bo(R);return P?(D=c==null?void 0:c.find(W=>W.name===P.server))==null?void 0:D.tools.find(W=>W.name===P.tool):void 0},S=R=>{var D;const P=Bo(R);return P?(D=g[`mcp:${P.server}/*`])==null?void 0:D.permission:void 0},N=f?f.flatMap(R=>i.filter(P=>P.name===R)):[...new Set(r)].flatMap(R=>{var W;const P=i.find(Y=>Y.name===R);if(P)return[P];const D=k(R)??E(R);return!((W=D==null?void 0:D.permissions)!=null&&W.length)||!D.default_permission?[]:[{name:R,permission:D.permission??D.default_permission,default_permission:D.default_permission,permissions:D.permissions,...j&&D.permissions.includes("ask")?{ask_needs:"password"}:{}}]}),_=OC(y,N,[...i.map(R=>R.name),...a.map(R=>R.name)]),$=p.useRef(null);if(p.useEffect(()=>{var D,W;if(!u)return;const R=`${u} permission`,P=[...((D=$.current)==null?void 0:D.querySelectorAll('button[aria-haspopup="listbox"]'))??[]].find(Y=>Y.getAttribute("aria-label")===R);(W=P==null?void 0:P.scrollIntoView)==null||W.call(P,{block:"center"}),P==null||P.focus()},[]),!_.length)return null;const O=(e==null?void 0:e.definition.tool_settings)??{},A=x!==(((e==null?void 0:e.definition.approvals)??"ask")==="never"),{byTool:L,rest:M}=SC(b,"definition.tool_settings",_.map(R=>R.name));return t.jsxs("section",{"aria-label":"Tool settings",ref:$,children:[t.jsx("div",{className:"mb-2",children:t.jsx("span",{className:"caps text-small font-semibold",children:"Tool settings"})}),t.jsxs("p",{className:"-mt-1 mb-2 text-small text-muted-foreground",children:["Each of these tools takes this server's setting (its default here) unless it is changed here. ",f?"A call node can't wait for an approval: a tool set to ask stops the run from starting. Set it to allow.":x?"Never ask is on: a tool on ask runs without waiting for you. A tool set to deny still holds.":"A tool on ask makes the run wait for your approval at each call."]}),t.jsx(oy,{label:"This agent's tool settings",unattended:x,rows:_,settings:g,fallbackOf:R=>R.provider,issues:L,onEdit:R=>h(R(g)),effectOf:R=>{var P;return(P=E(R))==null?void 0:P.effect},confirmAllowOf:R=>{var P;return((P=E(R))==null?void 0:P.effect)==="destructive"},noteOf:R=>{const P=g[R],D=d==null?void 0:d[R],W=!!(P!=null&&P.pin||P!=null&&P.pin_broken);return!W&&!(D!=null&&D.pin)&&!(D!=null&&D.pin_broken)?null:t.jsxs(t.Fragment,{children:[W&&t.jsx(px,{setting:P,label:"Pinned for this agent",also:!!(D!=null&&D.pin)}),(!W||(D==null?void 0:D.pin_broken))&&t.jsx(px,{setting:D,label:"Pinned on this server"})]})},refused:R=>wC(R,i,e==null?void 0:e.tools,c),locked:!0,permissionFallbackOf:R=>{var P;return S(R.name)??((P=k(R.name))==null?void 0:P.default_permission)??R.permission},resolvesOf:R=>{var H,q,F,G,U,z;const P=(((H=g[R.name])==null?void 0:H.provider)??null)!==(((q=O[R.name])==null?void 0:q.provider)??null)||(((F=g[R.name])==null?void 0:F.permission)??null)!==(((G=O[R.name])==null?void 0:G.permission)??null)||A,D=(U=e==null?void 0:e.tools)==null?void 0:U.find(Q=>Q.name===R.name),W=D&&D.provider===(((z=g[R.name])==null?void 0:z.provider)??R.provider)?D.resolved:void 0,Y=(s??"")===((e==null?void 0:e.definition.model)??"");return!P&&n===((e==null?void 0:e.definition.harness)??"pi")&&Y&&W?t.jsx(gx,{value:W,prefix:`${n}: `,tool:R.name}):!P&&!O[R.name]&&!s?t.jsx(gx,{value:R.resolves[n],prefix:`${n}: `,tool:R.name}):t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"once saved"})}}),M.map(R=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:R},R))]})}const Vu=20,RF=400;function AF(e,n,s,r,a){const[i,c]=p.useState(null),[d,u]=p.useState(0),f=(r??[]).join(",");p.useEffect(()=>{if(!a||!s||i==="unsupported")return;const b=new AbortController,x=setTimeout(()=>{a({workflow:n,...r?{tools:r}:{}},b.signal).then(h=>{b.signal.aborted||c({text:e,check:h})},h=>{b.signal.aborted||((h==null?void 0:h.status)===404||(h==null?void 0:h.status)===405?c("unsupported"):c({text:e,failed:(h==null?void 0:h.message)||`the server answered ${(h==null?void 0:h.status)??"nothing"}`}))})},RF);return()=>{clearTimeout(x),b.abort()}},[e,s,f,a,d]);const g=()=>{c(null),u(b=>b+1)};return i==="unsupported"||!a?{mode:"lint",retry:g}:i&&i.text===e?"failed"in i?{mode:"failed",failed:i.failed,retry:g}:{mode:"server",check:i.check,retry:g}:{mode:"pending",retry:g}}function h0({text:e,onText:n,base:s,baseLabel:r,serverIssues:a,readOnly:i=!1,validate:c,tools:d}){var Y;const u=p.useRef(null),f=p.useRef(null),[g,b]=p.useState(0),x=p.useMemo(()=>aP(e),[e]),h=p.useRef(null);x.ok&&(h.current={value:x.value,spans:x.spans});const v=(Y=h.current)==null?void 0:Y.value,y=p.useMemo(()=>ll(v),[v]),j=p.useMemo(()=>s===void 0?null:ll(s),[s]),k=p.useMemo(()=>j?e2(j,y):null,[j,y]),E=AF(e,x.ok?x.value:void 0,x.ok,d,i?void 0:c),S=p.useMemo(()=>x.ok&&!i?dP(x.value):[],[x,i]),N=p.useMemo(()=>E.mode!=="server"?S:[...E.check.issues.map(H=>({path:H.path,message:H.message,severity:"error"})),...E.check.warnings.map(H=>typeof H=="string"?{path:"",message:H,severity:"warning"}:{path:H.path??"",message:H.message,severity:"warning"})],[E.mode,E.mode==="server"?E.check:null,S]),_=x.ok?uP(x.spans,y.nodes.map(H=>H.path),g):null,$=p.useMemo(()=>({meta:cd(v,y),diff:k?{added:k.added.map(H=>H.path),edited:[...k.changed,...k.rewritten].map(H=>H.next),moved:k.moved.map(H=>H.next),removed:k.removed.map(({label:H,kind:q})=>({label:H,kind:q}))}:void 0,selected:_?{path:_}:null}),[v,y,k,_]),O=e.split(`
|
|
647
|
+
`).length,A=H=>iP(e,H),L=[];x.ok||L.push({...A(x.error.offset),message:`JSON: ${x.error.message}`,severity:"error",offset:x.error.offset});for(const H of N){const q=x.ok?yk(x.spans,H.path):void 0,F=(q==null?void 0:q.start)??0;L.push({...A(F),message:H.message,severity:H.severity,offset:F,path:H.path})}for(const H of[...a??[]].reverse()){const q=H.path&&x.ok?yk(x.spans,H.path):void 0;L.unshift({...q?A(q.start):{line:0,col:0},message:`Server: ${H.message}`,severity:"error",offset:(q==null?void 0:q.start)??-1})}const M=new Map;for(const H of L)H.line&&M.get(H.line)!=="error"&&M.set(H.line,H.severity);const R=(H,q=H)=>{const F=u.current;!F||H<0||(F.focus(),F.setSelectionRange(H,q),F.scrollTop=Math.max(0,(A(H).line-4)*Vu),b(H))};p.useEffect(()=>{const H=x.ok?x.spans.get("/root"):void 0;H&&u.current&&(u.current.scrollTop=Math.max(0,(A(H.start).line-2)*Vu))},[]);const P=k?k.edges.added.length+k.edges.removed.length:0,D=k?k.added.length+k.changed.length+k.rewritten.length+k.removed.length+k.moved.length+P:0,W=L.filter(H=>H.severity==="error").length;return t.jsxs("div",{className:"grid min-h-0 grid-cols-1 border xl:grid-cols-[minmax(420px,5fr)_7fr]",children:[t.jsxs("div",{className:"flex min-h-0 flex-col border-b xl:border-b-0 xl:border-r",children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"workflow.json"}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[O," lines"]}),t.jsx("span",{className:"flex-1"}),i?t.jsx("span",{className:"caps text-label text-muted-foreground",children:"Read-only"}):t.jsxs(t.Fragment,{children:[E.mode==="failed"&&x.ok?t.jsxs("span",{className:"font-mono text-label text-warning-text",title:E.failed,children:["server check failed, showing local checks ",t.jsx(B,{type:"button",onClick:E.retry,size:"xs",className:"ml-1",children:"Retry"})]}):E.mode!=="lint"&&x.ok&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:E.mode==="pending"?"checking...":"checked by the server"}),W?t.jsxs("span",{className:"caps inline-flex items-center gap-1 text-label text-destructive-text",children:[t.jsx(nl,{className:"size-3.5","aria-hidden":!0})," ",W," ",W===1?"problem":"problems"]}):t.jsx("span",{className:"caps text-label text-success-text",children:E.mode==="server"?"Valid":"Valid shape"})]})]}),t.jsxs("div",{className:"relative flex h-[560px] min-h-0 xl:h-[calc(100vh-390px)] xl:min-h-[440px]",children:[t.jsx("div",{ref:f,"aria-hidden":!0,className:"w-12 shrink-0 select-none overflow-hidden border-r bg-card py-3 text-right font-mono text-label text-muted-foreground",style:{lineHeight:`${Vu}px`},children:Array.from({length:O},(H,q)=>t.jsx("div",{className:oe("pr-2",M.get(q+1)==="error"&&"bg-destructive/15 text-destructive-text",M.get(q+1)==="warning"&&"bg-warning/15 text-warning-text"),children:q+1},q))}),t.jsx(dn,{bare:!0,ref:u,value:e,readOnly:i,spellCheck:!1,wrap:"off","aria-label":"Workflow JSON",onChange:H=>{i||n(H.target.value),b(H.target.selectionStart)},onSelect:H=>b(H.target.selectionStart),onScroll:H=>{f.current&&(f.current.scrollTop=H.target.scrollTop)},onKeyDown:H=>{if(H.key!=="Tab"||i)return;H.preventDefault();const q=H.currentTarget,F=q.selectionStart,G=q.selectionEnd;n(`${e.slice(0,F)} ${e.slice(G)}`),requestAnimationFrame(()=>q.setSelectionRange(F+2,F+2))},className:"flex-1 resize-none overflow-auto bg-background px-3 py-3 text-small selection:bg-primary/[0.28] selection:text-foreground focus-visible:outline focus-visible:outline-focus focus-visible:-outline-offset-2 focus-visible:outline-ring",style:{lineHeight:`${Vu}px`,tabSize:2}})]}),!i&&t.jsxs("ul",{className:"max-h-48 min-h-[44px] overflow-auto border-t font-mono text-small","aria-label":"Problems",children:[L.length===0&&t.jsx("li",{className:"px-4 py-3 text-muted-foreground",children:E.mode==="server"?"No problems: the server's validator takes this workflow as it is.":"No problems the console can see. The server checks the workflow again when you save."}),L.map((H,q)=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>R(H.offset),className:"flex w-full items-start gap-2.5 border-b px-4 py-2 text-left hover:bg-accent",children:[H.severity==="error"?t.jsx(nl,{className:"mt-0.5 size-3.5 shrink-0 text-destructive-text","aria-hidden":!0}):t.jsx(Gs,{className:"mt-0.5 size-3.5 shrink-0 text-warning-text","aria-hidden":!0}),t.jsx("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",children:H.line?`L${H.line}:${H.col}`:"—"}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:H.message})]})},q))]})]}),t.jsxs("div",{className:"flex min-h-0 flex-col",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2",children:[t.jsx("span",{className:"caps text-label font-semibold",children:"Graph"}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Um(Qv(y))}),k&&(D?t.jsxs("span",{className:"font-mono text-label",children:[[k.added.length&&`${k.added.length} new`,k.changed.length+k.rewritten.length&&`${k.changed.length+k.rewritten.length} edited`,k.removed.length&&`${k.removed.length} removed`,k.moved.length&&`${k.moved.length} moved`,!k.moved.length&&P&&`${P} ${P===1?"connection":"connections"} changed`].filter(Boolean).join(" · ")," ",t.jsxs("span",{className:"text-muted-foreground",children:["against ",r??"the current revision"]})]}):t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Same as ",r??"the current revision"]})),t.jsx("span",{className:"flex-1"}),!x.ok&&h.current&&t.jsx("span",{className:"caps text-label text-warning-text",children:"Showing the last JSON that parsed"})]}),t.jsx("div",{className:oe("min-h-[360px] flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px] px-4 py-5 xl:h-[calc(100vh-330px)] xl:min-h-[480px]",!x.ok&&"opacity-60"),children:y.nodes.length?t.jsx(xd,{graph:y,marks:$,label:"The workflow's graph",minScale:.55,onSelect:H=>{const q=x.ok?x.spans.get(`${H.path}/label`)??x.spans.get(H.path):void 0;q&&R(q.start,q.end)}}):t.jsx("p",{className:"p-6 text-center font-mono text-body text-muted-foreground",children:"No root node to draw yet."})}),t.jsx("div",{className:"border-t px-4 py-2",children:t.jsx(vd,{})})]})]})}const OF="https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md#spend-cap";function MC(){return t.jsxs(t.Fragment,{children:["A run on Sonnet needs about $0.10 to take a few steps; under that it pauses before its next step (",t.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:OF,target:"_blank",rel:"noreferrer",children:"the smallest cap"}),")."]})}let Ui=null;function Yu(e,n){return Ui?Ui({to:e,replay:n}):!1}function PC(e){const[n,s]=p.useState(null),r=p.useRef(location.hash);return p.useEffect(()=>{if(!e)return;const a=c=>c.to===r.current?!1:(s(c),!0);Ui=a;const i=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",i),()=>{Ui===a&&(Ui=null),window.removeEventListener("beforeunload",i)}},[e]),{asking:n!==null,stay:()=>s(null),leave:()=>{var a;if(n!==null){if(s(null),n.to===null){(a=n.replay)==null||a.call(n);return}if(Ui=null,!n.replay){location.hash=n.to;return}location.hash!==r.current?window.addEventListener("hashchange",n.replay,{once:!0}):n.replay()}}}}const LC="Never ask: every tool this agent has runs without waiting for you. A tool set to deny, and a template's pins, still hold.",wg="custom",p0=e=>{try{return e?JSON.parse(e):void 0}catch{return}};function MF(e,n){if((e==null?void 0:e.kind)!=="invalid")return null;const s=Object.entries(e.fields).filter(([r])=>r==="definition.workflow"||r.startsWith("definition.workflow/")).map(([r,a])=>({path:r.slice(19),message:a}));return s.length?s:n?[{path:"",message:e.message}]:null}function PF(e){var s;const n=(s=/^definition\.([a-z_]+)/.exec(e))==null?void 0:s[1];if(n){if(["name","description","instructions"].includes(n))return"context";if(["tools","tool_settings","approvals","skills"].includes(n))return"tools";if(["harness","thinking","model","max_cost_usd","learning"].includes(n))return"settings";if(["place","computer"].includes(n))return"computer";if(n==="workflow")return"workflow"}}const LF=[{id:"context",label:"Context",note:"Name, description and instructions",Icon:Ka},{id:"workflow",label:"Workflow",note:"Its graph and its JSON",Icon:Ya},{id:"computer",label:"Computer",note:"Where it runs and what it drives",Icon:Va},{id:"tools",label:"Tools & skills",note:"What this agent can do",Icon:vf},{id:"settings",label:"Settings",note:"Harness, thinking and model",Icon:TN},{id:"history",label:"History",note:"Revisions and the current one",Icon:Jc}];function IF({agent:e,revisions:n=[],caps:s,onSave:r,onMakeCurrent:a,onArchive:i,onReload:c,onBack:d,step:u,problem:f=null,notice:g,draft:b,validate:x,providerChoices:h=[],permissionGates:v=[],focusTool:y,mcpServers:j=null,serverToolSettings:k,onRetryMcp:E}){var fn,Wn,$s,Hn,_s,Ts,An;const S=!e,N=e==null?void 0:e.definition,_=Zn(N),$=!!(N!=null&&N.native)||!!_,[O,A]=p.useState(u??((e==null?void 0:e.kind)==="workflow"?"workflow":"context")),L=S?ug(s.places):void 0,[M,R]=p.useState({name:(N==null?void 0:N.name)??"",description:(N==null?void 0:N.description)??"",instructions:(N==null?void 0:N.instructions)??(S?KP:""),harness:(N==null?void 0:N.harness)??"pi",thinking:N==null?void 0:N.thinking,model:N==null?void 0:N.model,tools:S?fg("pi",s.tools,L):(N==null?void 0:N.tools)??[],maxCostText:typeof(N==null?void 0:N.max_cost_usd)=="number"&&N.max_cost_usd>0?String(N.max_cost_usd):"",...L?{place:L}:{},...(e==null?void 0:e.kind)==="workflow"?{workflowText:b??JSON.stringify(N.workflow,null,2)}:{}}),[P,D]=p.useState(!1),[W,Y]=p.useState(!1),H=p.useRef(M);H.current=M;const[q,F]=p.useState(M),G=ee=>{const{maxCostText:Le,workflowText:mt,...At}=ee,Qt=Ck(Le),He=p0(mt),te={...At,maxCost:Qt.ok?Qt.value??0:Le,...mt!==void 0?{workflowSent:He!==void 0?He:mt}:{}},be=e?{...ud(e,te,"").definition}:{...te};return delete be.version,be.tool_settings&&!Object.keys(be.tool_settings).length&&delete be.tool_settings,{...be,tools:[...be.tools??[]].sort(),approvals:ee.approvals??(N==null?void 0:N.approvals)??"ask"}},U=!Qi(G(M),G(q)),[z,Q]=p.useState([]),[K,Z]=p.useState(!1),de=s.tools.map(ee=>`${ee.name}:${ee.available}:${(ee.harnesses??[]).join("+")}`).join(","),se=JSON.stringify(ug(s.places)??null);p.useEffect(()=>{if(!S)return;const ee=Le=>{const mt=Le.place??ug(s.places);return{...Le,...mt?{place:mt}:{},...K?{}:{tools:fg(Le.harness??"pi",s.tools,mt)}}};R(ee),F(ee)},[de,se]);const[ue,xe]=p.useState(""),[$e,ge]=p.useState(()=>((N==null?void 0:N.tools)??[]).filter(fl)),[fe,me]=p.useState(!1),[je,Me]=p.useState(!1),[_e,re]=p.useState(f),[Re,Ze]=p.useState(null),at=ee=>{Ze(null),A(ee)},pt=p.useRef(null),Ee=AC(pt.current??M.tools??[]),Je=(_e==null?void 0:_e.kind)==="invalid"?Object.entries(_e.fields).flatMap(([ee,Le])=>{const mt=Ee.get(ee);return mt?[{grant:mt,message:Le}]:[]}):[],he=ee=>(_e==null?void 0:_e.kind)==="invalid"&&Object.entries(_e.fields).filter(([Le])=>!Ee.has(Le)&&(Le===`definition.${ee}`||Le.startsWith(`definition.${ee}[`)||Le.startsWith(`definition.${ee}.`))).map(([,Le])=>Le).join(" ")||void 0,{monid:Fe,rest:ut}=gF((e==null?void 0:e.warnings)??[],(N==null?void 0:N.tools)??[]),Pe=ee=>nL(ut,ee).map(Le=>Le.message).join(" ")||void 0,ct=ee=>{S&&je||R(Le=>({...Le,...ee}))},_t=p.useRef(null);p.useEffect(()=>{var ee;((_e==null?void 0:_e.kind)==="invalid"||(_e==null?void 0:_e.kind)==="other")&&((ee=_t.current)==null||ee.focus())},[_e]);const tt=(e==null?void 0:e.kind)==="workflow",ft=S&&N2(M.harness),qt=[...(fn=M.name)!=null&&fn.trim()?[]:["Give the agent a name to create it."],...!tt&&!ft&&!((Wn=M.instructions)!=null&&Wn.trim())?["Write its instructions to create it."]:[]],zt=M.approvals??(N==null?void 0:N.approvals)??"ask",ye=eL(s.harnesses,S?{available:!!s.decisionProvider}:void 0),le={mcpHarnesses:s.mcpHarnesses,workflow:tt},Ue=ee=>{if(ee.mode==="sandbox")return;const Le=new Set(s.tools.filter(mt=>mt.sandbox_only).map(mt=>mt.name));Q(mt=>mt.filter(At=>!Le.has(At)))},Xe=ee=>{if(S&&!K){ct({harness:ee,tools:fg(ee,s.tools,M.place)}),Q([]);return}const Le=QP(ee,M.tools??[],z,s.tools,le);ct({harness:ee,tools:Le.tools}),Q(Le.held)},rt=n.find(ee=>ee.revision===(e==null?void 0:e.revision))??n.find(ee=>ee.current),J=LF.filter(ee=>!(S&&ee.id==="history")&&(ee.id!=="workflow"||tt)&&!(ft&&ee.id==="tools")&&(ee.id!=="computer"||!tt&&!ft&&!!(s.computers||s.places))),ve=J.some(ee=>ee.id===O)?O:J[0].id,We=J.findIndex(ee=>ee.id===ve),Se=async()=>{if(!r)return;const ee=M;pt.current=M.tools??[],Me(!0);let Le={...M,workflowText:void 0,maxCostText:void 0};if(!ft){const Qt=Ck(M.maxCostText);if(!Qt.ok){Me(!1),re({kind:"invalid",message:Qt.message,fields:{"definition.max_cost_usd":Qt.message}});return}const He=typeof(N==null?void 0:N.max_cost_usd)=="number"&&N.max_cost_usd>0,te=Qt.value??0;(te!==0||He)&&(Le={...Le,max_cost_usd:te})}if(tt)try{Le={...Le,workflow:JSON.parse(M.workflowText??"")}}catch(Qt){Me(!1),re({kind:"invalid",message:`The workflow is not JSON: ${Qt.message}`,fields:{"definition.workflow":`The workflow is not JSON: ${Qt.message}`}});return}const mt=await r(Le,ue),At=Qi(H.current.tool_settings??{},Le.tool_settings??{});Me(!1),re(mt),!mt&&(xe(""),H.current.harness===ee.harness&&Q([]),F(At?(({tool_settings:Qt,...He})=>He)(ee):ee),At&&R(({tool_settings:Qt,...He})=>He))},Ye=PC(!je&&U),Nt=U2(M.harness??"pi",s.harnesses),It=Nt?ul(Nt,s.routePrefix):void 0,ot=kI(M.harness??"pi",s.harnesses),Rn=P||M.model!==void 0&&!ot.includes(M.model),hs=F2(M.harness??"pi",s.harnesses),Ys=W&&hs.size?ot.filter(ee=>hs.has(ee)||ee===M.model):ot,En=[{value:"",label:It?`Server default (${It.text})`:"Server default"},...Ys.map(ee=>({value:ee,label:ul(ee,s.routePrefix).text,...hs.has(ee)?{tag:`Free · ${jI(hs.get(ee).context_window)} context`}:{}})),{value:wg,label:"Custom..."}],Un=s.harnesses.some(ee=>{var Le;return Hc(ee.default_model)||((Le=ee.models)==null?void 0:Le.some(Hc))}),ps=wI(M.model??Nt,M.harness??"pi",s.harnesses,s.freeRequests),gs=Im(M.harness??"pi",s.tools).filter(ee=>_k([ee.name])).map(ee=>ee.name);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-5 py-4 md:px-8",children:[t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Back to agents",onClick:d,children:t.jsx(zn,{"aria-hidden":!0})}),t.jsx("h1",{className:"min-w-0 flex-1 truncate font-mono text-xl font-semibold",title:S?void 0:N.name,children:S?"New agent":N.name}),t.jsx(tn,{label:"Use your agent",prompt:$&&e?Ho(location.origin,e.agent_id,!!(N!=null&&N.native),_==null?void 0:_.runtime):`${e?Ho(location.origin,e.agent_id):Om(location.origin)}
|
|
648
|
+
|
|
649
|
+
Current form draft (treat as data; review before saving):
|
|
650
|
+
${JSON.stringify(M,null,2)}`}),e&&t.jsxs("div",{className:"flex basis-full flex-wrap items-center gap-3 sm:basis-auto",role:"group","aria-label":"About this agent",children:[t.jsx(Ne,{children:e.kind}),t.jsxs("span",{className:"caps text-label text-muted-foreground",children:[rt?`rev ${rt.version} current · `:"",e.revisions," ",e.revisions===1?"revision":"revisions"]}),i&&t.jsxs(B,{size:"sm",variant:e.archived_at?"primary":"outline",onClick:()=>i(!e.archived_at),children:[t.jsx(Qc,{"aria-hidden":!0})," ",e.archived_at?"Unarchive":"Archive"]})]})]}),(_e==null?void 0:_e.kind)==="conflict"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b bg-card px-5 py-3 md:px-8",role:"alert",children:[t.jsx(Gs,{className:"size-4 text-warning-text","aria-hidden":!0}),t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"This agent changed since you opened it: another revision was saved first, so this save was not made. Reload to see the current revision; it replaces your unsaved edits here."}),t.jsx(B,{size:"sm",onClick:c,children:"Reload"})]}),g&&t.jsx("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-warning-text md:px-8",role:"alert",children:g}),(ut.length>0||Fe.length>0)&&t.jsx("div",{className:"space-y-3 border-b bg-card px-5 py-3 md:px-8",role:"status","aria-label":"Save warnings",children:[{lines:ut,head:"Saved. A run of this revision is refused until the server has what each line names:"},{lines:Fe.map(ee=>ee.warning),head:"Saved. What the server said of its monid grants:"}].filter(ee=>ee.lines.length).map(ee=>t.jsxs("div",{children:[t.jsxs("p",{className:"flex items-center gap-2 font-mono text-body text-warning-text",children:[t.jsx(Gs,{className:"size-4 shrink-0","aria-hidden":!0})," ",ee.head]}),t.jsx("ul",{className:"mt-2 space-y-1 font-mono text-small",children:ee.lines.map((Le,mt)=>{const At=J.find(Qt=>Qt.id===PF(Le.field));return t.jsxs("li",{children:[At?t.jsx("button",{type:"button",title:Le.field,onClick:()=>at(At.id),className:"text-muted-foreground underline underline-offset-2 hover:text-foreground",children:At.label}):t.jsx("span",{className:"text-muted-foreground",children:Le.field})," ",Le.message]},`${Le.field}:${mt}`)})})]},ee.head))}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[t.jsx("ol",{className:oe("relative flex shrink-0 gap-1 overflow-x-auto border-b p-3 md:flex-col md:gap-0 md:border-b-0 md:border-r md:p-4",ve==="workflow"?"md:w-[76px]":"md:w-[240px]"),children:J.map((ee,Le)=>t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","aria-current":ve===ee.id?"step":void 0,onClick:()=>at(ee.id),className:oe("flex w-full items-start gap-3 border-l-2 px-3 py-2.5 text-left font-mono",ve===ee.id?"border-l-foreground bg-foreground/5":"border-l-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("span",{className:oe("inline-flex size-6 shrink-0 items-center justify-center border text-label font-semibold",ve===ee.id?"border-foreground bg-foreground text-background":Le<We?"border-border-strong":"border-border"),children:Le<We?t.jsx(hl,{className:"size-3","aria-hidden":!0}):Le+1}),t.jsxs("span",{className:oe("hidden min-w-0",ve!=="workflow"&&"md:block"),title:ve==="workflow"?ee.label:void 0,children:[t.jsxs("span",{className:"caps flex items-center gap-1.5 text-small",children:[t.jsx(ee.Icon,{className:"size-3.5","aria-hidden":!0})," ",ee.label]}),t.jsx("span",{className:"mt-0.5 block text-label text-muted-foreground",children:ee.note})]}),t.jsx("span",{className:"sr-only md:hidden",children:ee.label})]})},ee.id))}),t.jsxs("section",{className:"min-h-0 flex-1 overflow-auto px-5 py-6 md:px-10",children:[t.jsxs("p",{className:"caps text-label text-muted-foreground",children:["Step ",We+1]}),t.jsx("h2",{className:"mb-6 border-b pb-4 text-lg font-semibold",children:J[We].label}),t.jsxs("fieldset",{disabled:S&&je,className:"m-0 min-w-0 border-0 p-0",children:[ve==="context"&&t.jsxs("div",{className:"grid gap-x-10 gap-y-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,2fr)] xl:items-start",children:[t.jsxs("div",{className:"space-y-6",children:[t.jsx(jt,{label:"Name",id:"agent-name",required:S,note:S?void 0:"Set when the agent was created; an edit keeps it.",error:he("name"),warning:Pe("name"),children:t.jsx(ze,{id:"agent-name",value:M.name,readOnly:!S,onChange:ee=>ct({name:ee.target.value}),placeholder:"e.g., Invoice checker"})}),t.jsx(jt,{label:"Description",id:"agent-description",optional:!0,note:S?void 0:"Set when the agent was created; an edit keeps it.",error:he("description"),warning:Pe("description"),children:t.jsx(ze,{id:"agent-description",value:M.description,readOnly:!S,onChange:ee=>ct({description:ee.target.value}),placeholder:S?"Short summary for the agent list":"No description"})})]}),ft?t.jsx(jt,{group:!0,label:"Workflow",children:t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:M.harness===Ov?"A decision agent is a workflow. It starts from a starter decision workflow: one typed question, and a person when the answer is unclear or not confident enough. Create it, then edit its nodes in the Workflow step.":"A workflow agent starts from a one-step workflow: an agent node that does what its input's task asks. Create it, then edit its nodes, or paste a workflow's JSON over it, in the Workflow step."})}):tt?t.jsx(jt,{group:!0,label:"Workflow",note:"This agent is a workflow. Edit its nodes in the Workflow step: the graph redraws as you type and the server checks it.",warning:Pe("workflow"),children:t.jsxs(B,{size:"sm",onClick:()=>A("workflow"),children:[t.jsx(Ya,{"aria-hidden":!0})," Open the workflow"]})}):t.jsxs(jt,{group:fe?"heading":void 0,label:"Instructions",id:fe?void 0:"agent-instructions",required:!0,error:he("instructions"),warning:Pe("instructions"),aside:t.jsx("span",{className:"flex",children:["Preview","Edit"].map(ee=>t.jsx(B,{size:"xs",type:"button",onClick:()=>me(ee==="Preview"),className:oe("caps border px-2.5 py-1 text-label",ee==="Preview"===fe?"border-foreground bg-foreground text-background":"text-muted-foreground"),children:ee},ee))}),children:[fe?t.jsx("article",{className:"report min-h-64 border p-4",dangerouslySetInnerHTML:{__html:to(M.instructions||"")}}):t.jsx(dn,{id:"agent-instructions",value:M.instructions,onChange:ee=>ct({instructions:ee.target.value}),rows:14,placeholder:"Describe what the agent does, how, and its rules.",className:oe(zF,"resize-y leading-[1.7]")}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[(M.instructions??"").length," characters"]})]})]}),ve==="workflow"&&t.jsx(h0,{text:M.workflowText??"",onText:ee=>ct({workflowText:ee}),base:tt?N.workflow:void 0,baseLabel:rt?`rev ${rt.version}`:void 0,validate:x,tools:M.tools,serverIssues:MF(_e,tt)}),ve==="computer"&&!tt&&!ft&&s.computers&&t.jsx("div",{className:"space-y-8",children:t.jsx(NF,{kinds:s.computers,value:M.computer??(N==null?void 0:N.computer)??tx(M.place??{mode:"runner"}),onChange:ee=>{const Le=jF(ee),mt=new Set(s.tools.filter(At=>At.sandbox_only).map(At=>At.name));ct({computer:ee,place:Le,...Le.mode==="runner"?{tools:(M.tools??[]).filter(At=>!mt.has(At))}:{}}),Ue(Le)},error:he("computer")??he("place"),warning:Pe("computer")??Pe("place")})}),ve==="computer"&&!tt&&!ft&&!s.computers&&s.places&&t.jsx("div",{className:"space-y-8",children:t.jsx(SF,{value:M.place,saved:N==null?void 0:N.place,places:s.places,tools:s.tools,picked:M.tools??[],onChange:ee=>{ct({...ee,...ee.place?{computer:tx(ee.place)}:{}}),ee.place&&Ue(ee.place)},error:he("computer")??he("place"),warning:Pe("computer")??Pe("place")})}),ve==="tools"&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs(jt,{group:!0,label:"Tools",note:"On by default: the tools this agent's harness runs on this server. Untick one to take it away.",error:he("tools"),warning:Pe("tools"),children:[t.jsxs("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-start gap-2",children:[s.tools.filter(ee=>{var Le;return tt||!ee.call_only||((Le=M.tools)==null?void 0:Le.includes(ee.name))}).map(ee=>{var kt,Pt;const Le=nx(M.harness??"pi",ee.name,s.tools,le),mt=((kt=M.tools)==null?void 0:kt.includes(ee.name))??!1,At=h.find(it=>it.name===ee.name),Qt=(Pt=(M.tool_settings??(N==null?void 0:N.tool_settings)??{})[ee.name])==null?void 0:Pt.provider,He=!!At&&Qt!==void 0&&Qt!==At.provider,te=JP(ee,M.place??dd(N==null?void 0:N.place)??Pv(tt,M.tools??[],s.places)),be=wC(ee.name,v,e==null?void 0:e.tools)?ty:ee.call_only&&!tt?"Workflow-only: a workflow's call node runs it, not an agent":Le?te??(!ee.available&&!He?(At==null?void 0:At.reason)??ee.reason??`Needs ${(ee.missing??[]).join(", ")}`:void 0):$k(M.harness??"pi",ee.name,s.tools),Ge=be?ee.call_only&&!tt?"Workflow only":te&&Le&&be===te?"Sandbox-only":be:void 0;return t.jsx("li",{className:"min-w-0",children:t.jsx(ny,{value:ee.name,name:ee.name,blurb:ee.blurb,description:ee.summary,why:be,tag:Ge,on:mt,disabled:!!be&&!mt,onToggle:()=>{Z(!0),ct({tools:mt?M.tools.filter(it=>it!==ee.name):[...M.tools??[],ee.name]})}})},ee.name)}),s.mcp&&!tt&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(tF,{servers:j,tools:M.tools??[],harness:M.harness??"pi",harnesses:s.mcpHarnesses,onRetry:E,onChange:ee=>{Z(!0),ct({tools:ee})}})}),!tt&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(vF,{tools:M.tools??[],listed:$e,notes:Fe.map(({grant:ee,warning:Le})=>({grant:ee,message:Le.message})),refused:Je,onChange:ee=>{ge(Le=>[...new Set([...Le,...ee.filter(fl)])]),Z(!0),ct({tools:ee})}})})]}),!tt&&!_k(M.tools??[])&&t.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["This agent can't reach the web: ",gs.length?`tick ${gs.join(" or ")} in Tools.`:`${M.harness??"pi"} runs no web tool on this server.`]})]}),t.jsx(TF,{agent:e,unattended:!tt&&zt==="never",harness:M.harness??"pi",model:M.model,tools:M.tools??[],choices:tt?[]:h,gates:v,mcpServers:Array.isArray(j)?j:void 0,serverSettings:k,focus:y,callTools:tt?ND(p0(M.workflowText)??(N==null?void 0:N.workflow)):void 0,value:M.tool_settings??(N==null?void 0:N.tool_settings)??{},issues:(_e==null?void 0:_e.kind)==="invalid"?_e.fields:{},onChange:ee=>!je&&Qi(ee,(N==null?void 0:N.tool_settings)??{})?R(({tool_settings:Le,...mt})=>mt):ct({tool_settings:ee})}),!tt&&!ft&&t.jsxs("fieldset",{"aria-label":"Approvals",className:"space-y-2",children:[t.jsx("legend",{className:"caps text-small font-semibold",children:"Approvals"}),[["ask","Ask me","A call whose permission is ask waits for your answer."],["never","Never ask (run unattended)","For an agent that runs on a trigger, with no one there to answer."]].map(([ee,Le,mt])=>t.jsxs("label",{className:oe("flex items-start gap-3 border px-3 py-2.5",zt===ee&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"approvals",value:ee,className:"mt-1 accent-primary",checked:zt===ee,disabled:je,onChange:()=>ct({approvals:ee})}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:Le}),t.jsx("span",{className:"block text-small text-muted-foreground",children:mt})]})]},ee)),zt==="never"&&t.jsx("p",{className:"text-small text-warning-text",children:LC})]}),t.jsx(jt,{group:!0,label:"Skills",note:"Skill files are saved with each revision and kept as they are by an edit.",children:($s=N==null?void 0:N.skills)!=null&&$s.length?t.jsx("ul",{className:"border",children:N.skills.map(ee=>t.jsx("li",{className:"border-b px-3 py-2 font-mono text-body last:border-b-0",children:ee},ee))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No skills."})})]}),ve==="settings"&&t.jsxs("div",{className:"2xl:columns-2 2xl:gap-x-10 [&>*]:mb-8 [&>*]:mt-0 [&>*]:break-inside-avoid",children:[!tt&&t.jsxs(jt,{group:"heading",label:"Harness",note:"What runtime runs this agent.",error:he("harness"),warning:Pe("harness"),children:[t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,9rem),1fr))] gap-3",role:"radiogroup","aria-label":"Harness",children:ye.map(ee=>{const Le=t.jsxs(t.Fragment,{children:[t.jsx("input",{type:"radio",name:"harness",value:ee.id,checked:M.harness===ee.id,disabled:!ee.available&&M.harness!==ee.id,onChange:()=>Xe(ee.id),className:"mt-1 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block break-words font-mono text-body font-semibold",children:ee.label}),t.jsx("span",{className:"mt-0.5 block font-mono text-label text-muted-foreground",children:ee.available?ee.id:"Not available here"})]})]}),mt=oe("min-w-0 border px-4 py-3",M.harness===ee.id?"border-foreground":"border-border");return ee.available?t.jsx("label",{className:oe(mt,"flex cursor-pointer items-start gap-3"),children:Le},ee.id):t.jsxs("div",{className:oe(mt,"opacity-60"),children:[t.jsx("label",{className:"flex cursor-not-allowed items-start gap-3",children:Le}),ee.reason&&t.jsxs("details",{className:"mt-2 font-mono text-label text-muted-foreground",children:[t.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Why, and what to do"}),t.jsx("p",{className:"mt-1 break-words leading-[1.6]",children:ee.reason})]})]},ee.id)})}),z.length>0&&t.jsxs("div",{className:"mt-3 border px-3 py-2 font-mono text-small",role:"status","aria-label":"Tools this harness doesn't run",children:[t.jsxs("p",{className:"text-warning-text",children:[((Hn=ye.find(ee=>ee.id===M.harness))==null?void 0:Hn.label)??M.harness," doesn't run ",z.length===1?"this tool":"these tools"," here, so ",z.length===1?"it's":"they're"," unticked. Switching back ticks ",z.length===1?"it":"them"," again."]}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:z.map(ee=>t.jsxs("li",{children:[ee,": ",t.jsx("span",{className:"text-muted-foreground",children:$k(M.harness??"pi",ee,s.tools,s.mcpHarnesses)})]},ee))})]})]}),!tt&&!ft&&t.jsx(jt,{group:"heading",label:"Thinking",note:"How hard the model thinks before it answers.",error:he("thinking"),warning:Pe("thinking"),children:t.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Thinking",children:s.thinking.map(ee=>t.jsxs("label",{className:oe("caps cursor-pointer border px-3 py-2 text-small",M.thinking===ee?"border-foreground":"text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"thinking",className:"sr-only",checked:M.thinking===ee,onChange:()=>ct({thinking:ee})}),ee]},ee))})}),!ft&&t.jsxs(jt,{label:"Model",id:"agent-model",optional:!0,note:It?t.jsxs(t.Fragment,{children:["Empty uses the server's default (",t.jsx("span",{title:It.title,children:It.text}),")."]}):NI,error:he("model"),warning:Pe("model"),children:[t.jsx(Rt,{id:"agent-model",label:"Model",className:"w-full",value:Rn?wg:M.model??"",options:En,onChange:ee=>{if(ee===wg){D(!0);return}D(!1),ct({model:ee||void 0})}}),Rn&&t.jsx(ze,{id:"agent-model-custom","aria-label":"Custom model",className:"mt-2",value:M.model??"",onChange:ee=>{D(!0),ct({model:ee.target.value||void 0})},placeholder:"provider/model"}),hs.size>0&&t.jsxs("label",{className:"mt-2 flex items-center gap-2 text-small text-muted-foreground",children:[t.jsx(_m,{checked:W,onChange:Y,label:"Free models only"})," Free models only (",hs.size,"): $0 a request; the provider limits requests per day."]})]}),!ft&&t.jsx(jt,{label:"Default spend cap per run, $",id:"agent-max-cost",optional:!0,note:t.jsxs(t.Fragment,{children:["A run started without a cap of its own, and a trigger with none, stops at this spend. Empty means none.",Un&&t.jsx("span",{className:"mt-1 block",children:xI}),ps&&t.jsx("span",{className:"mt-1 block","data-note":"free-requests",children:ps})]}),hint:t.jsx(MC,{}),error:he("max_cost_usd"),warning:Pe("max_cost_usd"),children:t.jsx(ze,{id:"agent-max-cost",inputMode:"decimal",value:M.maxCostText??"",onChange:ee=>ct({maxCostText:ee.target.value}),placeholder:"e.g., 2.50"})}),!tt&&!ft&&s.learning&&t.jsx(jz,{fields:M,onFields:ct,saved:N==null?void 0:N.learning,server:s.learning,error:he("learning"),warning:Pe("learning")})]}),ve==="history"&&Re&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>Ze(null),children:[t.jsx(zn,{"aria-hidden":!0})," Back to History"]}),t.jsxs("span",{className:"caps text-small",children:["rev ",Re.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:Re.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(Re.created_at)}),t.jsx(B,{size:"sm",onClick:()=>a==null?void 0:a(Re.revision),disabled:!a,children:"Make current"})]}),t.jsx(h0,{readOnly:!0,text:JSON.stringify((_s=Re.definition)==null?void 0:_s.workflow,null,2),onText:()=>{},base:N.workflow,baseLabel:rt?`rev ${rt.version}, the current one`:"the current revision"})]}),ve==="history"&&!Re&&t.jsx("ul",{className:"border",children:n.map(ee=>{var Le;return t.jsxs("li",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsxs("span",{className:"caps w-14 text-small",children:["rev ",ee.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:ee.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(ee.created_at)}),tt&&!ee.current&&((Le=ee.definition)==null?void 0:Le.workflow)!==void 0&&t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>Ze(ee),"aria-label":`View rev ${ee.version}`,children:[t.jsx(im,{"aria-hidden":!0})," View"]}),ee.current?t.jsx(Ne,{tone:"success",children:"Current"}):t.jsx(B,{size:"sm",onClick:()=>a==null?void 0:a(ee.revision),disabled:!a,children:"Make current"})]},ee.revision)})})]})]})]}),t.jsxs("footer",{className:"flex flex-wrap items-center gap-3 border-t px-5 py-3 md:px-8",children:[t.jsxs(B,{size:"sm",variant:"ghost",disabled:We===0,onClick:()=>at(J[We-1].id),children:[t.jsx(zn,{"aria-hidden":!0})," Previous"]}),ve!=="history"&&t.jsx(ze,{value:ue,onChange:ee=>xe(ee.target.value),placeholder:S?"":"What changed (a note on this revision)","aria-label":"Revision note",className:oe("h-9 min-w-0 flex-1",S&&"invisible")}),ve==="history"&&t.jsx("span",{className:"flex-1"}),We<J.length-1&&t.jsxs(B,{size:"sm",onClick:()=>at(J[We+1].id),children:["Next ",t.jsx(Ix,{"aria-hidden":!0})]}),!Re&&t.jsx(B,{ref:_t,size:"sm",variant:"solid",onClick:Se,disabled:!r||je||!S&&!U||!((Ts=M.name)!=null&&Ts.trim())||!tt&&!ft&&!((An=M.instructions)!=null&&An.trim()),children:S?je?"Creating…":"Create":je?"Saving…":U?"Save revision":rt?`Saved · rev ${rt.version}`:"Saved"}),S&&!je&&!Re&&qt.map(ee=>t.jsx("p",{className:"w-full text-right font-mono text-small text-muted-foreground",children:ee},ee)),(_e==null?void 0:_e.kind)==="invalid"&&t.jsxs("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:["The server refused the save: ",_e.message]}),(_e==null?void 0:_e.kind)==="other"&&t.jsx("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:_e.message})]}),t.jsxs(uv,{open:Ye.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:Ye.leave,onCancel:Ye.stay,children:[S?"This new agent is not saved yet.":"Your changes to this agent are not saved."," Leave drops them; Stay keeps them here."]})]})}const zF="w-full border bg-background px-3 py-2.5 font-mono text-body focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring placeholder:text-muted-foreground focus:border-border-strong";function DF({agents:e,archived:n=!1,onArchivedChange:s,actions:r={},error:a,handoff:i,observations:c}){var g;const[d,u]=p.useState(""),f=(e??[]).filter(b=>`${b.definition.name} ${b.definition.description??""}`.toLowerCase().includes(d.toLowerCase()));return t.jsxs("section",{className:"flex min-h-full flex-col",children:[t.jsxs("header",{className:"flex min-h-12 flex-wrap items-center justify-between gap-3 border-b px-5 py-2",children:[t.jsxs("h1",{className:"caps flex items-center gap-2 text-body font-semibold",children:[t.jsx(zx,{className:"size-4","aria-hidden":!0}),n?"Archived agents":"Connected agents"]}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-2",children:[i,!n&&t.jsx(tn,{variant:"primary",label:"Build an agent",prompt:Om(location.origin),playgroundHref:"#/playground?operation=create-agent"})]})]}),t.jsxs("div",{className:"p-5 md:p-6",children:[t.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[t.jsxs("label",{className:oe(Fc,"flex h-control-lg min-w-0 flex-1 items-center gap-3 px-3"),children:[t.jsx(cm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(ze,{bare:!0,value:d,onChange:b=>u(b.target.value),placeholder:"Search agents by name or description...","aria-label":"Search agents",className:"h-full flex-1 max-sm:portrait:placeholder:text-transparent"})]}),t.jsxs(B,{size:"lg",variant:n?"primary":"outline","aria-pressed":n,onClick:()=>s==null?void 0:s(!n),children:[t.jsx(Qc,{"aria-hidden":!0})," Archived"]})]}),a?t.jsx("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:a}):e?!f.length&&!((g=c==null?void 0:c.data)!=null&&g.sessions.length)?t.jsxs("div",{className:"border px-4 py-16 text-center",children:[t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:d?"No agent matches.":n?"No archived agents.":"No agents yet."}),!d&&!n&&t.jsx("a",{className:"mt-4 inline-block text-lead text-primary-text hover:underline",href:"#/agents/new",children:"Describe your agent or start from a template"})]}):t.jsxs(t.Fragment,{children:[!!f.length&&t.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[f.length," ",f.length===1?"agent":"agents"]}),t.jsx("ul",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 2xl:grid-cols-3",children:f.map(b=>t.jsx(FF,{agent:b,actions:r},b.agent_id))})]}):t.jsx(Fn,{label:"Loading the agents",rows:6}),c&&t.jsx("div",{className:"mt-6",children:t.jsx(Nv,{read:c,view:"cards",query:d})})]})]})}function FF({agent:e,actions:n}){var d;const s=e.kind==="workflow"?Ya:zx,r=!!e.archived_at,a=zv(e),i=Zn(e.definition),c=If(e);return t.jsxs("li",{className:oe("flex flex-col border p-5 transition-colors hover:border-border-strong",r&&"opacity-70"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 items-start gap-2.5 text-left",onClick:()=>{var u;return(u=n.onOpen)==null?void 0:u.call(n,e.agent_id)},children:[t.jsx(s,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-base font-semibold",children:e.definition.name}),t.jsx(Ne,{children:e.kind}),e.kind==="agentic"&&t.jsx(Ne,{children:i?Vo(i.runtime):a?fd(a.runtime):e.definition.harness??"pi"}),a&&t.jsx(Ne,{tone:a.connected&&a.state==="ready"?"success":"warning",children:md(a)}),r&&t.jsx(Ne,{tone:"muted",children:"Archived"})]}),t.jsx("span",{className:"mt-2 line-clamp-2 block text-lead leading-relaxed text-muted-foreground",children:e.definition.description||(e.kind==="workflow"?fP(e.definition.workflow):"No description.")})]})]}),a&&t.jsxs("p",{className:"mt-3 break-all font-mono text-small text-muted-foreground",children:[a.project," · ",a.machine_id]}),t.jsxs("div",{"data-testid":"agent-card-footer",className:"mt-auto flex min-w-0 flex-wrap items-start gap-x-2 gap-y-1 pt-5",children:[t.jsxs("div",{"data-testid":"agent-card-chips",className:"flex min-w-0 flex-auto flex-wrap items-center gap-x-2 gap-y-1.5 py-1.5",children:[t.jsxs(Ne,{className:"shrink-0 whitespace-nowrap",children:[e.revisions," ",e.revisions===1?"revision":"revisions"]}),e.runs&&t.jsxs(Ne,{className:"shrink-0 whitespace-nowrap",children:[e.runs.count," ",e.runs.count===1?"run":"runs",e.runs.live?` · ${e.runs.live} live`:""]}),c>0&&t.jsxs(B,{size:"xs",type:"button","aria-label":Xv(c),onClick:()=>{var u;return(u=n.onLearning)==null?void 0:u.call(n,e.agent_id)},className:"h-5 shrink-0 whitespace-nowrap border-warning/50 bg-warning/10 px-1.5 text-micro text-warning-text hover:bg-warning/20",children:["Learning · ",c]})]}),t.jsxs("div",{"data-testid":"agent-card-actions",className:"ml-auto flex min-w-0 max-w-full flex-wrap items-center justify-end gap-2",children:[!r&&t.jsx(tn,{compact:!0,compactIcon:t.jsx(Yo,{className:"size-3.5","aria-hidden":!0}),label:`Run ${e.definition.name}`,disabled:!!a&&(!a.connected||a.state!=="ready"||!a.capabilities.launch),prompt:Av(location.origin,e.agent_id,i==null?void 0:i.runtime),playgroundHref:i?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`}),t.jsx(tn,{compact:!0,compactIcon:t.jsx(Hx,{className:"size-3.5","aria-hidden":!0}),label:`Edit ${e.definition.name}`,prompt:Ho(location.origin,e.agent_id,!!a,i==null?void 0:i.runtime),playgroundHref:a||i?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),t.jsxs(B,{size:"sm",className:"gap-1 px-2",variant:"outline","aria-label":`Runs of ${e.definition.name}`,onClick:()=>{var u;return(u=n.onRuns)==null?void 0:u.call(n,e.agent_id)},children:[t.jsx(Jc,{"aria-hidden":!0}),((d=e.runs)==null?void 0:d.count)??0]}),t.jsx(B,{size:"icon",variant:"outline","aria-label":`${r?"Unarchive":"Archive"} ${e.definition.name}`,onClick:()=>{var u;return(u=n.onArchive)==null?void 0:u.call(n,e.agent_id,!r)},children:r?t.jsx(kN,{"aria-hidden":!0}):t.jsx(Qc,{"aria-hidden":!0})})]})]})]})}function UF({v2:e}){const[n,s]=p.useState(null),[r,a]=p.useState(!1),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(""),[b,x]=p.useState("live"),[h,v]=p.useState(null),[y,j]=p.useState(!1),[k,E]=p.useState(!1),[S,N]=p.useState(null),_=p.useRef(!1),$=p.useRef(!1),O=p.useRef(0),A=p.useRef(!0),L=x5(),M=p.useCallback(async()=>{if($.current)return;$.current=!0,a(!0);const W=O.current;try{const Y=await e.listConnectors();A.current&&W===O.current&&(s(Y.connectors),c(null))}catch(Y){A.current&&W===O.current&&c(Ft(Y))}finally{$.current=!1,A.current&&a(!1)}},[e]);p.useEffect(()=>{A.current=!0,queueMicrotask(()=>{A.current&&M()});const W=()=>{!document.hidden&&!_.current&&M()},Y=setInterval(W,15e3);return window.addEventListener("focus",W),document.addEventListener("visibilitychange",W),()=>{A.current=!1,O.current++,clearInterval(Y),window.removeEventListener("focus",W),document.removeEventListener("visibilitychange",W)}},[M]),p.useEffect(()=>{if(!h)return;const W=new Date(h.expires_at).getTime()-Date.now();if(W<=0){v(null),j(!0);return}const Y=setTimeout(()=>{v(null),j(!0)},W);return()=>clearTimeout(Y)},[h]);const R=async()=>{if(!_.current){_.current=!0,E(!0),u(null),j(!1);try{const W=await e.enrollConnector(f,{native_execution:b!=="history",history_import:b!=="live"});A.current&&v(W)}catch(W){A.current&&u(Ft(W))}finally{_.current=!1,A.current&&E(!1)}}},P=async()=>{if(!(_.current||!S)){_.current=!0,E(!0),u(null),O.current++;try{const{connector:W}=await e.revokeConnector(S.connector_id);A.current&&(s(Y=>(Y==null?void 0:Y.map(H=>H.connector_id===W.connector_id?W:H))??null),N(null))}catch(W){A.current&&u(Ft(W))}finally{_.current=!1,A.current&&E(!1)}}},D=async()=>{if(h)try{await navigator.clipboard.writeText(h.enrollment_token),L({title:"Connection code copied"})}catch{L({title:"Select and copy the connection code below",tone:"error"})}};return t.jsxs("div",{className:"space-y-6","aria-label":"Remote connections",children:[t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Connect another machine",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-lg font-semibold",children:"Connect remote agents"}),t.jsx(tn,{label:"Connect agent",prompt:AP(location.origin,b)})]}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Connect a Claude Code or Codex setup on your laptop, VM or container. Its files and native sign-in stay there."}),t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label",children:"Allow this connection to"}),t.jsx(sd,{name:"remote-connection-intent",label:"Connection scope",size:"sm",value:b,onChange:x,options:[{value:"live",label:"Live agent",disabled:k},{value:"history",label:"History only",disabled:k},{value:"both",label:"Both",disabled:k}]}),t.jsxs("p",{className:"max-w-prose text-small text-muted-foreground",children:[b==="live"?"Run future jobs with your existing setup. Past conversations are not shared.":b==="history"?"Upload completed conversations from one selected project and runtime. No executing worker or self-improvement is enabled.":"Connect for future jobs and upload completed conversations from the selected project and runtime."," ",b!=="live"&&" Preview and approve the history on the source machine before upload. History is not used as learning."]})]}),t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(jt,{label:"Machine label",hint:"Optional. A name you recognize in this console.",children:t.jsx(ze,{value:f,onChange:W=>g(W.target.value),placeholder:"My development machine",disabled:k,maxLength:120})})}),t.jsx(B,{size:"md",className:"self-start sm:mt-6",disabled:k,"aria-busy":k,onClick:()=>void R(),children:k&&!S?"Creating code…":"Create connection code"})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Use the code only in the connector's secure terminal prompt. It expires after ten minutes and can pair one machine. The coding-agent prompt contains no credentials."}),y&&t.jsx(vt,{tone:"warning",children:"The connection code expired. Create a new one if you have not connected the machine."}),d&&!S&&t.jsx(vt,{tone:"error",title:"Connection action failed",children:d})]}),t.jsxs("section",{className:"space-y-4","aria-label":"Connected remote machines",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"mr-auto text-lg font-semibold",children:"Remote machines"}),t.jsx(B,{size:"sm",disabled:r||k,onClick:()=>void M(),"aria-busy":r,children:r?"Refreshing…":"Refresh"})]}),i&&t.jsx(vt,{tone:"error",title:"Remote machines could not be read",actions:t.jsx(B,{size:"xs",disabled:r,onClick:()=>void M(),children:"Try again"}),children:i}),n===null&&!i&&t.jsx("p",{className:"text-body text-muted-foreground",role:"status",children:"Loading remote machines…"}),(n==null?void 0:n.length)===0&&t.jsxs("div",{className:"border p-6",children:[t.jsx("h3",{className:"text-body font-semibold",children:"No remote machines connected"}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Use your coding agent to connect a source machine. It appears here once the connector has paired."})]}),n==null?void 0:n.map(W=>t.jsxs("article",{className:"space-y-4 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h3",{className:"mr-auto break-words text-body font-semibold",children:W.label||W.connector_id}),t.jsx(Ne,{tone:W.status==="revoked"||!W.capabilities.native_execution?"plain":W.status==="online"?"success":"warning",children:W.status==="revoked"?"Revoked":!W.capabilities.native_execution&&W.capabilities.history_import?"History only":W.status==="online"?"Online":"Offline"}),t.jsx(B,{size:"sm",disabled:k||W.status==="revoked",onClick:()=>{u(null),N(W)},children:"Revoke access"})]}),t.jsxs("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Last seen"}),t.jsx("dd",{children:W.last_seen_at?ht(W.last_seen_at):"Not yet seen"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Access"}),t.jsx("dd",{children:W.capabilities.native_execution?W.capabilities.history_import?"Live agents and history import":"Selected native agents and remote jobs":W.capabilities.history_import?"History import only":"Observation only"})]})]}),W.status==="offline"&&W.capabilities.native_execution&&t.jsx(vt,{tone:"warning",children:"The source worker is offline. Start it on the original machine to verify or run its agents. Saved agents and learning are preserved."}),W.targets.length>0?t.jsx("ul",{className:"divide-y border-t",children:W.targets.map(Y=>t.jsxs("li",{className:"space-y-2 pt-3 [&+li]:mt-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("span",{className:"min-w-0 flex-1 break-words text-body font-semibold",children:Y.name}),Y.agent_id?t.jsx("a",{href:ln(Y.agent_id),className:"text-small underline underline-offset-2",children:"Open agent"}):t.jsx(Ne,{children:"Not imported"})]}),t.jsxs("p",{className:"break-words text-small text-muted-foreground",children:[fd(Y.runtime)," · ",Y.machine_id," · ",Y.history_only?"Imported history":W.status==="online"?Y.state==="ready"&&Y.capabilities.launch?"Ready to run":Y.state==="needs_attention"?"Needs attention":"Needs verification":"Worker unavailable"]}),Y.issues.length>0&&t.jsx("p",{className:"text-small text-warning-text",children:Y.issues.join("; ")})]},Y.target_id))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"No native targets imported. Choose a project or agent with the source connector."})]},W.connector_id)),t.jsx("p",{className:"text-small text-muted-foreground",children:"Refreshes every 15 seconds while this page is visible. Open an agent to see its runs. Live connections also support Learning Dojo."})]}),t.jsx(Em,{open:h!==null,onClose:()=>v(null),title:"Connect this machine",description:"Enter this code directly in the source connector's secure prompt.",footer:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",onClick:()=>v(null),children:"Done"}),t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void D(),children:"Copy connection code"})]}),children:h&&t.jsxs(t.Fragment,{children:[t.jsx(jt,{label:"One-use connection code",hint:`Expires ${ht(h.expires_at)}. Closing this dialog clears it from the page.`,children:t.jsx(ze,{readOnly:!0,value:h.enrollment_token,autoComplete:"off",spellCheck:!1,onFocus:W=>W.currentTarget.select()})}),t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"This grants a scoped connector credential. Keep it out of coding-agent prompts, URLs and source control. After pairing, the connector retains its own credential in its private state directory."})]})}),t.jsxs(uv,{open:S!==null,title:"Revoke this machine's access?",confirm:k?"Revoking…":"Revoke access",busy:k,onCancel:()=>{N(null),u(null)},onConfirm:()=>void P(),children:[t.jsxs("p",{children:[(S==null?void 0:S.label)||"This machine"," will no longer receive work or report activity. Agent definitions, past runs and saved learning stay available. Pair the machine again to restore access."]}),d&&t.jsx(vt,{tone:"error",className:"mt-3",children:d})]})]})}function Km({variant:e}){return t.jsx(tn,{variant:e,label:"Connect agent",prompt:b2(location.origin),playgroundHref:"#/agents/connect",playgroundLabel:"Connection setup"})}function WF({v2:e,go:n,initialSource:s="server"}){const[r,a]=p.useState(s),[i,c]=p.useState(""),[d,u]=p.useState(null),[f,g]=p.useState([]),[b,x]=p.useState({}),[h,v]=p.useState(!1),[y,j]=p.useState(null),k=async()=>{v(!0),j(null),u(null),g([]),x({});try{u((await e.discoverNative(i.trim())).targets)}catch(S){j(Ft(S))}finally{v(!1)}},E=async()=>{v(!0),j(null);try{for(const S of f){if(b[S])continue;const{project:N,runtime:_,selector:$}=d[S],O=await e.connectNative({project:N,runtime:_,selector:$});x(A=>({...A,[S]:O.agent.agent_id}))}}catch(S){j(Ft(S))}finally{v(!1)}};return t.jsxs("section",{className:"mx-auto max-w-page space-y-6 p-5 md:p-8","aria-label":"Connect agent",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("h1",{className:"mr-auto text-2xl font-semibold",children:"Connect agent"}),t.jsx(B,{size:"sm",onClick:()=>n("#/agents"),children:"Back to agents"})]}),t.jsx("p",{className:"max-w-prose text-lead text-muted-foreground",children:"Connect a native setup for new jobs, or observe an agent already running in its original application. Keep its instructions, tools, permissions and sign-in."}),t.jsx(vt,{title:"Choose how to connect",children:"Choose this server or another machine to launch jobs from an existing native setup. Choose an existing application to observe its activity and token usage through the CLI. This browser cannot scan your laptop."}),t.jsx(sd,{name:"native-source",label:"Connection method",value:r,onChange:a,options:[{value:"server",label:"This server",disabled:h},{value:"remote",label:"Another machine",disabled:h},{value:"observe",label:"Existing application",disabled:h}]}),r==="observe"?t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Observe an existing application",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Observe your existing agent"}),t.jsx("p",{className:"max-w-prose text-body text-muted-foreground",children:"Connect Claude Code or Codex running locally, in Docker, or on another server. Your application continues to start and control its jobs; AgentRun receives session activity, model and token usage."}),t.jsx("p",{className:"max-w-prose text-small text-muted-foreground",children:"The setup skill configures the existing CLI and telemetry collector for this server. Adding self-improvement requires the backend SDK integration."}),t.jsx(tn,{variant:"primary",label:"Connect agent",prompt:`${b2(location.origin)}
|
|
651
|
+
|
|
652
|
+
I selected observation of an existing application. Preserve its current job trigger and SDK configuration; do not import or launch a replacement agent.`})]}):r==="remote"?t.jsx(UF,{v2:e}):t.jsxs(t.Fragment,{children:[t.jsx(Km,{}),t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Discover native setups",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Discover on this server"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"Read-only discovery checks configuration without launching a model or executing project hooks. No model API key is needed to connect."}),t.jsx(jt,{label:"Project on server host",hint:"Enter the absolute path on the machine running AgentRun.",children:t.jsx(ze,{"aria-label":"Project on server host",value:i,onChange:S=>{c(S.target.value),u(null)},placeholder:"/path/to/project",disabled:h})}),t.jsx(B,{variant:d?"outline":"solid",size:"sm",disabled:h||!i.trim().startsWith("/"),"aria-busy":h,onClick:()=>void k(),children:h&&!d?"Discovering…":"Discover"})]}),y&&t.jsx(vt,{tone:"error",title:"Connection request failed",children:y}),d&&t.jsxs("section",{className:"space-y-4","aria-label":"Native targets",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Choose what to connect"}),!d.length&&t.jsx(vt,{children:"No supported native setup was found. Install Claude Code or Codex on this host and check the project path."}),d.map((S,N)=>t.jsxs("article",{className:"space-y-3 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsxs("label",{className:"flex min-w-0 flex-1 items-start gap-3",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",disabled:h||!!b[N],checked:f.includes(N),onChange:_=>g($=>_.target.checked?[...$,N]:$.filter(O=>O!==N))}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("strong",{className:"break-words text-body",children:Lv(S.selector)}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:[fd(S.runtime)," · ",S.version??"Version unknown"]})]})]}),t.jsx(Ne,{tone:S.state==="ready"?"success":"warning",children:md(S)})]}),t.jsx("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[["Project",S.project],["Machine",S.machine_id],["Model",S.model??"Native default · unknown until launch"],["Skills",S.skills.join(", ")||"None detected"],["MCP servers",S.mcp_servers.join(", ")||"None configured"],["Approval handling",S.capabilities.approval]].map(([_,$])=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"text-muted-foreground",children:_}),t.jsx("dd",{className:"break-all font-mono",children:$})]},_))}),S.selector.kind==="agent"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"This named agent runs as the main Claude Code session, rather than a delegated subagent."}),S.selector.kind==="profile"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"A Codex profile selects native configuration; it is not a custom subagent."}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Native launch: ",S.capabilities.launch?"supported":"unavailable"," · Notes: ",S.capabilities.notes?"supported":"unavailable"," · Learned skills: ",S.capabilities.skills?"supported":"unavailable"," · Learned workflows: unavailable · Usage: ",S.capabilities.usage?"supported counters only; dollar cost may be unknown":"unavailable"]}),S.issues.length>0&&t.jsx(vt,{tone:"warning",children:t.jsx("ul",{children:S.issues.map(_=>t.jsx("li",{children:_},_))})}),b[N]&&t.jsxs("p",{role:"status",className:"text-body",children:["Connected. ",t.jsx("a",{href:ln(b[N]),className:"underline underline-offset-2",children:"Open connected agent"})]})]},`${S.runtime}:${S.selector.kind}:${S.selector.name??""}`)),!!d.length&&t.jsx(B,{variant:"solid",size:"sm",onClick:()=>void E(),disabled:h||!f.some(S=>!b[S]),"aria-busy":h,children:h?"Connecting…":"Connect selected"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Connecting saves a reference and starts no run. Authentication and approval compatibility are checked separately on the connected agent's page."})]})]}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Your coding agent can also help import selected history. Past conversations stay historical; they do not become live jobs or AgentRun learning."})]})}const Ea=e=>e instanceof De?tL(e):{kind:"other",message:e instanceof Error?e.message:String(e)};function HF({v2:e,archived:n,go:s}){const r=kv(e,{active:!n}),[a,i]=p.useState(null),[c,d]=p.useState(null),u=p.useRef(0),f=()=>{const g=++u.current;i(null),d(null),qr(b=>e.listAgents({archived:n,cursor:b}),b=>b.agents).then(b=>{g===u.current&&i(b)}).catch(b=>{g===u.current&&d(Ea(b).message)})};return p.useEffect(()=>{f();const g=()=>{document.hidden||f()};return window.addEventListener("focus",g),document.addEventListener("visibilitychange",g),()=>{window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",g)}},[e,n]),t.jsx(DF,{observations:r,agents:a,archived:n,onArchivedChange:g=>s(g?"#/agents?archived=true":"#/agents"),error:c,handoff:t.jsx(Km,{}),actions:{onOpen:g=>s(ln(g)),onEdit:g=>s(ln(g,"edit")),onNew:()=>s("#/agents/new"),onRuns:g=>s(ln(g,"runs")),onLearning:g=>s(ln(g,"learning")),onArchive:async(g,b)=>{try{await(b?e.archiveAgent(g):e.unarchiveAgent(g)),f()}catch(x){d(Ea(x).message)}}}})}function BF({v2:e,caps:n,choices:s=[],gates:r=[],focusTool:a,agentId:i,go:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),[b,x]=p.useState([]),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,E]=p.useState(0),[S,N]=p.useState(null),_=p.useRef(!0);p.useEffect(()=>(_.current=!0,()=>{_.current=!1}),[]);const $=F=>qr(G=>e.listRevisions(F,G),G=>G.revisions),O=async()=>{if(i)try{const[{agent:F,etag:G},U]=await Promise.all([e.getAgent(i),$(i)]);u(F),g(G),x(U),N(F.revision),E(z=>z+1),j(null),v(null)}catch(F){d?j(`The agent could not be reloaded: ${Ea(F).message}`):v(Ea(F).message)}};p.useEffect(()=>{O()},[i]);const[A,L]=p.useState(null),M=p.useRef(0);p.useEffect(()=>{const F=++M.current;e.computers().then(G=>{F===M.current&&L(G.kinds)},()=>{F===M.current&&L(null)})},[e]);const[R,P]=p.useState(void 0);p.useEffect(()=>{let F=!0;return Promise.resolve().then(()=>e.toolSettings()).then(G=>{F&&P(G)},()=>{}),()=>{F=!1}},[e]);const[D,W]=p.useState(null),Y=p.useRef(0),H=()=>{if(!n.mcp)return;const F=++Y.current;W(null),e.listMcpServers().then(G=>{F===Y.current&&W(G.servers)},()=>{F===Y.current&&W("failed")})};p.useEffect(H,[e,n.mcp]);const q=async(F,G)=>{let U;try{U=await G()}catch(z){j(`${F} did not finish: ${Ea(z).message}`);return}u(U);try{const{agent:z,etag:Q}=await e.getAgent(U.agent_id),K=await $(U.agent_id).catch(()=>b);u(z),g(Q),x(K),z.revision!==S?(N(z.revision),E(Z=>Z+1),j(F==="Make current"?null:`${F} done. This agent changed since you opened it: the form now shows its current revision.`)):j(null)}catch(z){j(`${F} done. The page could not be refreshed: ${Ea(z).message}. Reload to see the current state.`)}};return i&&h&&!d?t.jsx("p",{className:"m-8 border p-4 font-mono text-body text-destructive-text",role:"alert",children:h}):i&&!d?t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading the agent..."}):d&&Zn(d.definition)?t.jsxs("section",{className:"space-y-4 p-5 md:p-8",children:[t.jsxs("h1",{className:"text-2xl font-semibold",children:["Edit ",d.definition.name]}),t.jsx(vt,{children:"This agent runs in your backend. Edit its application code with your coding agent; manage self-improving in its Learning tab."}),t.jsx(tn,{label:"Edit agent",prompt:Ho(location.origin,d.agent_id,!1,Zn(d.definition).runtime)}),t.jsx("a",{href:ln(d.agent_id),className:"block text-body underline underline-offset-2",children:"Back to agent"})]}):t.jsx(IF,{agent:d,revisions:b,caps:{...n,computers:A},providerChoices:s,permissionGates:r,mcpServers:D,serverToolSettings:R,onRetryMcp:H,...a?{focusTool:a,step:"tools"}:{},notice:y,validate:e.validateWorkflow,onBack:()=>c("#/agents"),onReload:()=>{O(),H()},onSave:async(F,G)=>{let U;try{if(!d){const Z=await e.createAgent(VP({name:F.name??"",description:F.description??"",instructions:F.instructions??"",harness:F.harness??"pi",tools:F.tools??[],approvals:F.approvals,tool_settings:F.tool_settings,thinking:F.thinking,model:F.model,computer:F.computer,learning:F.learning,max_cost_usd:F.max_cost_usd,decisionProvider:n.decisionProvider}));return _.current&&c(ln(Z.agent_id,Z.kind==="workflow"?"workflow":void 0)),null}const z=ud(d,F,G);if(z.unchanged)return{kind:"other",message:"Nothing to save: the definition is the current revision's, and a note alone makes no new revision."};const{unchanged:Q,...K}=z;U=await e.updateDefinition(d.agent_id,K,f)}catch(z){return Ea(z)}return u(U.agent),g(U.etag),N(U.agent.revision),e.getAgent(U.agent.agent_id).then(z=>u(Q=>Q&&Q.revision===z.agent.revision?{...Q,tools:z.agent.tools}:Q)).catch(()=>{}),$(U.agent.agent_id).then(x).catch(()=>j("Saved. The history could not be refreshed; reload to see it.")),null},onMakeCurrent:F=>{d&&q("Make current",()=>e.setCurrent(d.agent_id,F))},onArchive:F=>{d&&q(F?"Archive":"Unarchive",()=>F?e.archiveAgent(d.agent_id):e.unarchiveAgent(d.agent_id))}},`${(d==null?void 0:d.agent_id)??"new"}:${k}`)}function so(e){if(!(typeof e!="string"||!e))try{const n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"?n.href:void 0}catch{return}}const GF={env:"Set in the environment",console:"Pasted here","sign-in":"From sign-in"},qF={tool:1,model:1,mcp:2,computer:2,source:2};function Wf(e,n){const s=e.split(":"),r=qF[s[0]];return(r===void 0?"":s.slice(r).join(":"))||n||s.slice(1).join(":")}const KF="Sign in with your password to change secrets.",VF="This server has no accounts: set secrets in its environment, or turn accounts on to change them here.",YF="Open the console from the server's link to change secrets.",Za={sign_in:KF,no_accounts:VF,token:YF},IC=e=>e.status===200&&e.body&&typeof e.body=="object"?e.body:null,QF=e=>{var n;return((n=IC(e))==null?void 0:n.secrets_writable)===!0};function JF(e){const n=IC(e);return n!=null&&n.secrets_reason?n.secrets_reason:(n==null?void 0:n.accounts)===!1?"no_accounts":"sign_in"}function XF(e){const[n,s]=p.useState({writable:!1,whyNot:"sign_in"});return p.useEffect(()=>{let r=!0;return e.session().then(a=>{r&&s({writable:QF(a),whyNot:JF(a)})},()=>{}),()=>{r=!1}},[e]),n}const ZF=2e3,xx=e=>e instanceof De||e instanceof Error?e.message:String(e),ay=({children:e="Manage usage"})=>t.jsx("a",{href:uI,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:e});function e6(){return t.jsxs("div",{className:"space-y-1 text-body text-muted-foreground",children:[t.jsxs("p",{children:["Eligible usage in this app uses your ChatGPT plan. ",t.jsx(ay,{})," in your ChatGPT settings."]}),t.jsx("p",{children:mI})]})}function vx({v2:e,view:n,onView:s,writable:r=!0,whyNot:a="sign_in",beside:i}){const[c,d]=p.useState(n),[u,f]=p.useState(null),[g,b]=p.useState(!1),[x,h]=p.useState(!1),[v,y]=p.useState(!1),j=p.useRef(null),k=p.useRef(0);p.useEffect(()=>{d(n)},[n]);const E=L=>{d(L),s==null||s(L)},S=c.state==="pending";p.useEffect(()=>{if(!S)return;let L=!1;const M=()=>{if(L||document.visibilityState!=="visible")return;L=!0;const D=++k.current;e.chatGPT().then(W=>{const Y=Mf(W);D===k.current&&Y&&Y.state!=="pending"&&E(Y)},()=>{}).finally(()=>{L=!1})},R=setInterval(M,ZF),P=()=>{document.visibilityState==="visible"&&M()};return document.addEventListener("visibilitychange",P),()=>{clearInterval(R),document.removeEventListener("visibilitychange",P)}},[e,S]);const N=async()=>{f(null),b(!0);const L=window.open("","_blank");k.current++;try{const M=await e.startChatGPT();L&&(L.opener=null,L.location.href=M.authorize_url),E({state:"pending",authorize_url:M.authorize_url,expires_at:M.expires_at})}catch(M){L==null||L.close(),f(xx(M))}finally{b(!1)}},_=async L=>{var P;L.preventDefault();const M=(P=j.current)==null?void 0:P.value.trim();if(!M)return;f(null),b(!0),h(!0),k.current++;const R=D=>{j.current&&(j.current.value=""),y(!1),E(D)};try{R(await e.finishChatGPT(M))}catch(D){const W=await e.chatGPT().then(Mf,()=>null);(W==null?void 0:W.state)==="signed_in"?R(W):f(xx(D))}finally{b(!1),h(!1)}},$=u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:u});if(c.state==="signed_in")return t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-body font-semibold",children:bI(c)}),t.jsx(e6,{})]});if(!r)return t.jsx("p",{className:"text-body",role:"status",children:Za[a]});if(!S)return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"solid",disabled:g,onClick:()=>void N(),children:"Continue with ChatGPT"}),i]}),$]});const O=so(c.authorize_url),A=c.expires_at;return t.jsxs("form",{onSubmit:L=>void _(L),autoComplete:"off",className:"space-y-3 border bg-card p-4","aria-label":"Finish signing in with ChatGPT",children:[t.jsx("p",{className:"text-body",children:fI}),t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[O&&t.jsxs(t.Fragment,{children:[t.jsx("a",{href:O,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Open the sign-in page"})," (a new tab)"]}),O&&A&&" · ",A&&`Waits until ${od(A)}`]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"The sign-in tab's address"}),t.jsx(ze,{ref:j,name:"redirect_url",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:"127.0.0.1:1455/auth/callback?code=…",onInput:()=>{var L;return y(!!((L=j.current)!=null&&L.value.trim()))}})]}),$,t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!v||g,children:x?"Finishing…":"Finish sign-in"}),t.jsx(B,{type:"button",size:"sm",disabled:g,onClick:()=>void N(),children:"Start again"})]})]})}const t6={signed_in:{tone:"success",words:"signed in"},pending:{tone:"plain",words:"waiting"},expired:{tone:"warning",words:"expired"},signed_out:{tone:"plain",words:"not signed in"}};function n6({v2:e,writable:n,whyNot:s,onChange:r}){var y;const[a,i]=p.useState(null),[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,b]=p.useState(null);if(p.useEffect(()=>{let j=!0;return e.chatGPT().then(k=>{j&&i(Mf(k))},()=>{j&&i(null)}),()=>{j=!1}},[e]),!a)return null;const x=async()=>{b(null);let j;try{j=await e.signOutChatGPT()}catch(k){b(xx(k));return}d(!1),i({state:"signed_out"}),f(typeof j=="object"&&(j==null?void 0:j.revoked)===!1?{words:j.message||pI,settings:!0}:{words:hI}),r==null||r()},h=j=>{i(j),j.state!=="pending"&&f(null),j.state==="signed_in"&&(r==null||r())},v=t6[a.state];return t.jsxs("li",{"aria-label":"ChatGPT plan",className:"border-b p-4 last:border-b-0",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:"ChatGPT plan"}),t.jsx(Ne,{tone:v.tone,children:v.words})]}),t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:z2}),t.jsxs("div",{className:"mt-3 space-y-3",children:[a.state==="expired"&&t.jsx("p",{className:"text-body text-warning-text",children:gI}),a.state==="signed_in"&&((y=a.models)!=null&&y.length)?t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["Models: ",a.models.join(" · ")]}):null,t.jsx(vx,{v2:e,view:a,onView:h,writable:n,whyNot:s}),a.state==="signed_in"&&n&&!c&&t.jsx(B,{size:"sm",onClick:()=>{d(!0),b(null)},children:"Sign out"}),c&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Sign out of ChatGPT on this server? Codex and pi agents then need a key to run here."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void x(),children:"Sign out"}),t.jsx(B,{size:"sm",onClick:()=>d(!1),children:"Keep"})]}),g&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:g}),u&&t.jsxs("p",{className:"text-body",role:"status",children:[u.words,u.settings&&t.jsxs(t.Fragment,{children:[" ",t.jsx(ay,{children:"ChatGPT settings"})]})]})]})]})}function s6(e){var n,s;return(n=e.needs)!=null&&n.includes("chatgpt")?{tone:"warning",text:"runs after Continue with ChatGPT"}:(s=e.needs)!=null&&s.includes("key")?{tone:"warning",text:"needs a key"}:e.available?{tone:"success",text:"ready"}:{tone:"warning",text:"not here"}}function zC({harnesses:e,routePrefix:n}){return e.length?t.jsxs("section",{"aria-label":"What runs here",children:[t.jsx("h2",{className:"caps mb-2 text-small font-semibold text-muted-foreground",children:"What runs here"}),t.jsx("ul",{className:"border",children:e.map(s=>{var a;const r=s6(s);return t.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-4 py-2.5 last:border-b-0",children:[t.jsx("span",{className:"font-mono text-body font-semibold",children:Of(s.id)}),t.jsx(Ne,{tone:r.tone,children:r.text}),s.available&&!((a=s.needs)!=null&&a.length)?s.default_model&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:ul(s.default_model,n).text}):s.reason&&t.jsx("span",{className:"text-small text-muted-foreground",children:s.reason})]},s.id)})})]}):null}const Qu=(e,n,s)=>{if(!/^\d{1,2}$/.test(e))return null;const r=Number(e);return r>=n&&r<=s?r:null};function r6(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const[s,r,a,i,c]=n,d=Qu(s,0,59);if(d===null||i!=="*")return null;if(r==="*")return a==="*"&&c==="*"?{kind:"hourly",minute:d}:null;const u=Qu(r,0,23);if(u===null)return null;const f={hour:u,minute:d};if(a==="*"&&c==="*")return{kind:"daily",at:f};if(a==="*"&&c==="1-5")return{kind:"weekdays",at:f};if(a==="*"){const g=Qu(c,0,6);return g===null?null:{kind:"weekly",day:g,at:f}}if(c==="*"){const g=Qu(a,1,31);return g===null?null:{kind:"monthly",date:g,at:f}}return null}function o6(e){if(e.kind==="hourly")return`${e.minute} * * * *`;const n=`${e.at.minute} ${e.at.hour}`;return e.kind==="daily"?`${n} * * *`:e.kind==="weekdays"?`${n} * * 1-5`:e.kind==="weekly"?`${n} * * ${e.day}`:`${n} ${e.date} * *`}function a6(e,n){const s=n&&"at"in n?n.at:{hour:9,minute:(n==null?void 0:n.kind)==="hourly"?n.minute:0};return e==="hourly"?{kind:e,minute:s.minute}:e==="weekly"?{kind:e,day:(n==null?void 0:n.kind)==="weekly"?n.day:1,at:s}:e==="monthly"?{kind:e,date:(n==null?void 0:n.kind)==="monthly"?n.date:1,at:s}:{kind:e,at:s}}const g0=e=>String(e).padStart(2,"0"),i6=e=>`${g0(e.hour)}:${g0(e.minute)}`;function l6(e){const n=/^(\d{2}):(\d{2})/.exec(e);if(!n)return null;const s=Number(n[1]),r=Number(n[2]);return s<=23&&r<=59?{hour:s,minute:r}:null}var jg={exports:{}},x0;function c6(){return x0||(x0=1,(function(e,n){(function(r,a){e.exports=a()})(globalThis,()=>(()=>{var s={6949(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.CronParser=void 0;var f=u(9515),g=(function(){function b(x,h,v){h===void 0&&(h=!0),v===void 0&&(v=!1),this.expression=x,this.dayOfWeekStartIndexZero=h,this.monthStartIndexZero=v}return b.prototype.parse=function(){var x,h,v=(x=this.expression)!==null&&x!==void 0?x:"";if(v==="@reboot")return h=["@reboot","","","","","",""],h;if(v.startsWith("@")){var y=this.parseSpecial(this.expression);h=this.extractParts(y)}else h=this.extractParts(this.expression);return this.normalize(h),this.validate(h),h},b.prototype.parseSpecial=function(x){var h={"@yearly":"0 0 1 JAN *","@annually":"0 0 1 JAN *","@monthly":"0 0 1 * *","@weekly":"0 0 * * SUN","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},v=h[x];if(!v)throw new Error("Unknown special expression.");return v},b.prototype.extractParts=function(x){if(!this.expression)throw new Error("cron expression is empty");for(var h=x.trim().split(/[ ]+/),v=0;v<h.length;v++)if(h[v].includes(",")){var y=h[v].split(",").map(function(k){return k.trim()}).filter(function(k){return k!==""}).map(function(k){return isNaN(Number(k))?k:Number(k)}).filter(function(k){return k!==null&&k!==""});y.length===0&&y.push("*"),y.sort(function(k,E){return k!==null&&E!==null?k-E:0}),h[v]=y.map(function(k){return k!==null?k.toString():""}).join(",")}if(h.length<5)throw new Error("Expression has only ".concat(h.length," part").concat(h.length==1?"":"s",". At least 5 parts are required."));if(h.length==5)h.unshift(""),h.push("");else if(h.length==6){var j=/\d{4}$/.test(h[5])||h[4]=="?"||h[2]=="?";j?h.unshift(""):h.push("")}else if(h.length>7)throw new Error("Expression has ".concat(h.length," parts; too many!"));return h},b.prototype.normalize=function(x){var h=this;x[3]=x[3].replace("?","*"),x[5]=x[5].replace("?","*"),x[2]=x[2].replace("?","*"),x[0].indexOf("0/")==0&&(x[0]=x[0].replace("0/","*/")),x[1].indexOf("0/")==0&&(x[1]=x[1].replace("0/","*/")),x[2].indexOf("0/")==0&&(x[2]=x[2].replace("0/","*/")),x[3].indexOf("1/")==0&&(x[3]=x[3].replace("1/","*/")),!this.monthStartIndexZero&&x[4].indexOf("1/")==0&&(x[4]=x[4].replace("1/","*/")),x[6].indexOf("1/")==0&&(x[6]=x[6].replace("1/","*/")),x[5]=x[5].replace(/(^\d+)|([^#/\s\d]\d+)/g,function($){var O=$.replace(/\D/,""),A=O;return h.dayOfWeekStartIndexZero?O=="7"&&(A="0"):A=(parseInt(O)-1).toString(),$.replace(O,A)}),x[5]=="L"&&(x[5]="6"),x[3]=="?"&&(x[3]="*");var v=/^\d{1,2}W[+-]\d{1,2}$/;if(x[3].indexOf("W")>-1&&(x[3].indexOf(",")>-1||/[-+]/.test(x[3]))&&!v.test(x[3]))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var y={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var j in y)x[5]=x[5].replace(new RegExp(j,"gi"),y[j].toString());x[4]=x[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,function($){var O=$.replace(/\D/,""),A=O;return h.monthStartIndexZero&&(A=(parseInt(O)+1).toString()),$.replace(O,A)});var k={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var E in k)x[4]=x[4].replace(new RegExp(E,"gi"),k[E].toString());x[0]=="0"&&(x[0]=""),!/\*|\-|\,|\//.test(x[2])&&(/\*|\//.test(x[1])||/\*|\//.test(x[0]))&&(x[2]+="-".concat(x[2]));for(var S=0;S<x.length;S++)if(x[S].indexOf(",")!=-1&&(x[S]=x[S].split(",").filter(function($){return $!==""}).join(",")||"*"),x[S]=="*/1"&&(x[S]="*"),x[S].indexOf("/")>-1&&!/^\*|\-|\,/.test(x[S])){var N=null;switch(S){case 4:N="12";break;case 5:N="6";break;case 6:N="9999";break;default:N=null;break}if(N!==null){var _=x[S].split("/");x[S]="".concat(_[0],"-").concat(N,"/").concat(_[1])}}},b.prototype.validate=function(x){var h="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(x[0],h),this.validateOnlyExpectedCharactersFound(x[1],h),this.validateOnlyExpectedCharactersFound(x[2],h),this.validateOnlyExpectedCharactersFound(x[3].replace(/^(\d{1,2}W)[+-]\d{1,2}$/,"$1"),"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(x[4],h),this.validateOnlyExpectedCharactersFound(x[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(x[6],h),this.validateAnyRanges(x)},b.prototype.validateAnyRanges=function(x){x.forEach(function(h){return f.default.stepRange(h)}),f.default.secondRange(x[0]),f.default.minuteRange(x[1]),f.default.hourRange(x[2]),f.default.dayOfMonthRange(x[3]),f.default.monthRange(x[4],this.monthStartIndexZero),f.default.dayOfWeekRange(x[5],this.dayOfWeekStartIndexZero)},b.prototype.validateOnlyExpectedCharactersFound=function(x,h){var v=x.match(new RegExp("[^".concat(h,"]+"),"gi"));if(v&&v.length)throw new Error("Expression contains invalid values: '".concat(v.toString(),"'"))},b})();d.CronParser=g},8333(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.ExpressionDescriptor=void 0;var f=u(1823),g=u(6949),b=(function(){function x(h,v){if(this.expression=h,this.options=v,this.expressionParts=new Array(5),!this.options.locale&&x.defaultLocale&&(this.options.locale=x.defaultLocale),!x.locales[this.options.locale]){var y=Object.keys(x.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(y,"'.")),this.options.locale=y}this.i18n=x.locales[this.options.locale],v.use24HourTimeFormat===void 0&&(v.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return x.toString=function(h,v){var y=v===void 0?{}:v,j=y.throwExceptionOnParseError,k=j===void 0?!0:j,E=y.verbose,S=E===void 0?!1:E,N=y.dayOfWeekStartIndexZero,_=N===void 0?!0:N,$=y.monthStartIndexZero,O=$===void 0?!1:$,A=y.use24HourTimeFormat,L=y.trimHoursLeadingZero,M=L===void 0?!1:L,R=y.locale,P=R===void 0?null:R,D=y.logicalAndDayFields,W=D===void 0?!1:D,Y={throwExceptionOnParseError:k,verbose:S,dayOfWeekStartIndexZero:_,monthStartIndexZero:O,use24HourTimeFormat:A,trimHoursLeadingZero:M,locale:P,logicalAndDayFields:W};Y.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var H=new x(h,Y);return H.getFullDescription()},x.initialize=function(h,v){v===void 0&&(v="en"),x.specialCharacters=["/","-",",","*"],x.defaultLocale=v,h.load(x.locales)},x.prototype.getFullDescription=function(){var h,v,y="";try{var j=new g.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=j.parse(),this.expressionParts[0]==="@reboot")return((v=(h=this.i18n).atReboot)===null||v===void 0?void 0:v.call(h))||"Run once, at startup";var k=this.getTimeOfDayDescription(),E=this.getDayOfMonthDescription(),S=this.getMonthDescription(),N=this.getDayOfWeekDescription(),_=this.getYearDescription();y+=k+E+N+S+_,y=this.transformVerbosity(y,!!this.options.verbose),y=y.charAt(0).toLocaleUpperCase()+y.substr(1)}catch($){if(!this.options.throwExceptionOnParseError)y=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat($)}return y},x.prototype.getTimeOfDayDescription=function(){var h=this.expressionParts[0],v=this.expressionParts[1],y=this.expressionParts[2],j="";if(!f.StringUtilities.containsAny(v,x.specialCharacters)&&!f.StringUtilities.containsAny(y,x.specialCharacters)&&!f.StringUtilities.containsAny(h,x.specialCharacters))j+=this.i18n.atSpace()+this.formatTime(y,v,h);else if(!h&&v.indexOf("-")>-1&&!(v.indexOf(",")>-1)&&!(v.indexOf("/")>-1)&&!f.StringUtilities.containsAny(y,x.specialCharacters)){var k=v.split("-");j+=f.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(y,k[0],""),this.formatTime(y,k[1],""))}else if(!h&&y.indexOf(",")>-1&&y.indexOf("-")==-1&&y.indexOf("/")==-1&&!f.StringUtilities.containsAny(v,x.specialCharacters)){var E=y.split(",");j+=this.i18n.at();for(var S=0;S<E.length;S++)j&&(j+=" "),j+=this.formatTime(E[S],v,""),S<E.length-2&&(j+=","),S==E.length-2&&(j+=this.i18n.spaceAnd())}else{var N=this.getSecondsDescription(),_=this.getMinutesDescription(),$=this.getHoursDescription();if(j+=N,j&&_&&(j+=", "),j+=_,_===$)return j;j&&$&&(j+=", "),j+=$}return j},x.prototype.getSecondsDescription=function(){var h=this,v=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(y){return y},function(y){return f.StringUtilities.format(h.i18n.everyX0Seconds(y),y)},function(y){return h.i18n.secondsX0ThroughX1PastTheMinute()},function(y){return y=="0"?"":parseInt(y)<20?h.i18n.atX0SecondsPastTheMinute(y):h.i18n.atX0SecondsPastTheMinuteGt20()||h.i18n.atX0SecondsPastTheMinute(y)},{min:0,max:59});return v},x.prototype.getMinutesDescription=function(){var h=this,v=this.expressionParts[0],y=this.expressionParts[2],j=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(k){return k},function(k){return f.StringUtilities.format(h.i18n.everyX0Minutes(k),k)},function(k){return h.i18n.minutesX0ThroughX1PastTheHour()},function(k){var E,S;try{return k=="0"&&y.indexOf("/")==-1&&v==""?h.i18n.everyHour():k=="0"?((S=(E=h.i18n).onTheHour)===null||S===void 0?void 0:S.call(E))||h.i18n.atX0MinutesPastTheHour(k):parseInt(k)<20?h.i18n.atX0MinutesPastTheHour(k):h.i18n.atX0MinutesPastTheHourGt20()||h.i18n.atX0MinutesPastTheHour(k)}catch{return h.i18n.atX0MinutesPastTheHour(k)}},{min:0,max:59});return j},x.prototype.getHoursDescription=function(){var h=this,v=this.expressionParts[2],y=0,j=[];v.split("/")[0].split(",").forEach(function(S){var N=S.split("-");N.length===2&&j.push({value:N[1],index:y+1}),y+=N.length});var k=0,E=this.getSegmentDescription(v,this.i18n.everyHour(),function(S){var N=j.find(function($){return $.value===S&&$.index===k}),_=N&&h.expressionParts[1]!=="0";return k++,_?h.formatTime(S,"59",""):h.formatTime(S,"0","")},function(S){return f.StringUtilities.format(h.i18n.everyX0Hours(S),S)},function(S){return h.i18n.betweenX0AndX1()},function(S){return h.i18n.atX0()},{min:0,max:23});return E},x.prototype.getDayOfWeekDescription=function(){var h=this,v=this.i18n.daysOfTheWeek(),y=null;return this.expressionParts[5]=="*"?y="":y=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(j,k){var E=j;j.indexOf("#")>-1?E=j.substring(0,j.indexOf("#")):j.indexOf("L")>-1&&(E=E.replace("L",""));var S=parseInt(E),N=h.i18n.daysOfTheWeekInCase?h.i18n.daysOfTheWeekInCase(k)[S]:v[S];if(j.indexOf("#")>-1){var _=null,$=j.substring(j.indexOf("#")+1),O=j.substring(0,j.indexOf("#"));switch($){case"1":_=h.i18n.first(O);break;case"2":_=h.i18n.second(O);break;case"3":_=h.i18n.third(O);break;case"4":_=h.i18n.fourth(O);break;case"5":_=h.i18n.fifth(O);break}N=_+" "+N}return N},function(j){return parseInt(j)==1?"":f.StringUtilities.format(h.i18n.commaEveryX0DaysOfTheWeek(j),j)},function(j){var k=j.substring(0,j.indexOf("-")),E=h.expressionParts[3]!="*";return E?h.i18n.commaAndX0ThroughX1(k):h.i18n.commaX0ThroughX1(k)},function(j){var k=null;if(j.indexOf("#")>-1){var E=j.substring(j.indexOf("#")+1),S=j.substring(0,j.indexOf("#"));k=h.i18n.commaOnThe(E,S).trim()+h.i18n.spaceX0OfTheMonth()}else if(j.indexOf("L")>-1)k=h.i18n.commaOnTheLastX0OfTheMonth(j.replace("L",""));else{var N=h.expressionParts[3]!="*";N?h.options.logicalAndDayFields?k=h.i18n.commaOnlyOnX0(j):k=h.i18n.commaAndOnX0():k=h.i18n.commaOnlyOnX0(j)}return k}),y},x.prototype.getMonthDescription=function(){var h=this,v=this.i18n.monthsOfTheYear(),y=this.getSegmentDescription(this.expressionParts[4],"",function(j,k){return k&&h.i18n.monthsOfTheYearInCase?h.i18n.monthsOfTheYearInCase(k)[parseInt(j)-1]:v[parseInt(j)-1]},function(j){return parseInt(j)==1?"":f.StringUtilities.format(h.i18n.commaEveryX0Months(j),j)},function(j){return h.i18n.commaMonthX0ThroughMonthX1()||h.i18n.commaX0ThroughX1()},function(j){return h.i18n.commaOnlyInMonthX0?h.i18n.commaOnlyInMonthX0():h.i18n.commaOnlyInX0()});return y},x.prototype.getDayOfMonthDescription=function(){var h=this,v,y,j,k,E=null,S=this.expressionParts[3];switch(S){case"L":E=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":E=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var N=S.match(/^(?:(\d{1,2})W|W(\d{1,2}))(?:([+-])(\d{1,2}))?$/);if(N){var _=parseInt(N[1]||N[2]),$=_==1?this.i18n.firstWeekday():f.StringUtilities.format(this.i18n.weekdayNearestDayX0(),_.toString()),O=N[4];O?N[3]=="-"?E=f.StringUtilities.format(((y=(v=this.i18n).commaDaysBeforeTheX0OfTheMonth)===null||y===void 0?void 0:y.call(v,O))||", %s days before the %s of the month",O,$):E=f.StringUtilities.format(((k=(j=this.i18n).commaDaysAfterTheX0OfTheMonth)===null||k===void 0?void 0:k.call(j,O))||", %s days after the %s of the month",O,$):E=f.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),$);break}else{var A=S.match(/L-(\d{1,2})/);if(A){var L=A[1];E=f.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(L),L);break}else{if(S=="*"&&this.expressionParts[5]!="*")return"";E=this.getSegmentDescription(S,this.i18n.commaEveryDay(),function(M){return M=="L"?h.i18n.lastDay():h.i18n.dayX0?f.StringUtilities.format(h.i18n.dayX0(),M):M},function(M){return M=="1"?h.i18n.commaEveryDay():h.i18n.commaEveryX0Days(M)},function(M){return h.i18n.commaBetweenDayX0AndX1OfTheMonth(M)},function(M){return h.i18n.commaOnDayX0OfTheMonth(M)})}break}}return E},x.prototype.getYearDescription=function(){var h=this,v=this.getSegmentDescription(this.expressionParts[6],"",function(y){return/^\d+$/.test(y)?new Date(parseInt(y),1).getFullYear().toString():y},function(y){return f.StringUtilities.format(h.i18n.commaEveryX0Years(y),y)},function(y){return h.i18n.commaYearX0ThroughYearX1()||h.i18n.commaX0ThroughX1()},function(y){return h.i18n.commaOnlyInYearX0?h.i18n.commaOnlyInYearX0():h.i18n.commaOnlyInX0()});return v},x.prototype.getSegmentDescription=function(h,v,y,j,k,E,S){var N=null,_=h.indexOf("/")>-1,$=h.indexOf("-")>-1,O=h.indexOf(",")>-1;if(!h)N="";else if(h==="*")N=v;else if(!_&&!$&&!O)N=f.StringUtilities.format(E(h),y(h));else if(O){for(var A=h.split(","),L="",M=this.i18n.spaceAnd(),R=0;R<A.length;R++)if(R>0&&A.length>2&&(L+=",",R<A.length-1&&(L+=" ")),R>0&&A.length>1&&(R==A.length-1||A.length==2)&&(L+=M==","&&A.length>2?" ":"".concat(M," ")),A[R].indexOf("/")>-1||A[R].indexOf("-")>-1){var P=A[R].indexOf("-")>-1&&A[R].indexOf("/")==-1,D=this.getSegmentDescription(A[R],v,y,j,P?this.i18n.commaX0ThroughX1:k,E);P?D=D.replace(", ",""):R>0&&D.startsWith(", ")&&(D=D.substring(2)),L+=D}else if(!_)L+=y(A[R]);else{var W=this.getSegmentDescription(A[R],v,y,j,k,E);R>0&&W&&W.startsWith(", ")&&(W=W.substring(2)),L+=W}_?N=L:N=f.StringUtilities.format(E(h),L)}else if(_){var A=h.split("/");if(N=f.StringUtilities.format(j(A[1]),A[1]),A[0].indexOf("-")>-1){var Y=this.generateRangeSegmentDescription(A[0],k,y);Y.indexOf(", ")!=0&&(N+=", "),N+=Y}else if(A[0].indexOf("*")==-1){var H=f.StringUtilities.format(E(A[0]),y(A[0]));H=H.replace(", ",""),N+=f.StringUtilities.format(this.i18n.commaStartingX0(),H)}N+=this.getWrappingIncrementDescription(h,S,v,y,j,k,E)}else $&&(N=this.generateRangeSegmentDescription(h,k,y));return N},x.prototype.getWrappingIncrementDescription=function(h,v,y,j,k,E,S){if(!this.options.verbose||!v)return"";var N=h.split("/"),_=N[0],$=N[1],O=parseInt($),A=v.max-v.min+1,L=_==="*",M=Number.isInteger(O)&&O>1,R=M&&A%O===0;if(!L||!M||R)return"";for(var P=[],D=v.min;D<=v.max;D+=O)P.push(D);if(P.length<2)return"";var W=this.getSegmentDescription(P.join(","),y,j,k,E,S);return W?", ".concat(W):""},x.prototype.generateRangeSegmentDescription=function(h,v,y){var j="",k=h.split("-"),E=y(k[0],1),S=y(k[1],2),N=v(h);return j+=f.StringUtilities.format(N,E,S),j},x.prototype.formatTime=function(h,v,y){var j=0,k=0,E=parseInt(h)+j,S=parseInt(v)+k;S>=60?(S-=60,E+=1):S<0&&(S+=60,E-=1),E>=24?E=E-24:E<0&&(E=24+E);var N="",_=!1;this.options.use24HourTimeFormat||(_=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),N=_?"".concat(this.getPeriod(E)," "):" ".concat(this.getPeriod(E)),E>12&&(E-=12),E===0&&(E=12));var $="";y&&($=":".concat(("00"+y).substring(y.length)));var O=E.toString(),A=("00"+O).substring(O.length),L=S.toString(),M=("00"+L).substring(L.length),R=this.options.trimHoursLeadingZero?O:A;return"".concat(_?N:"").concat(R,":").concat(M).concat($).concat(_?"":N)},x.prototype.transformVerbosity=function(h,v){if(!v&&(h=h.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),h=h.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),h=h.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),h=h.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var y=0,j=Object.entries(this.i18n.conciseVerbosityReplacements());y<j.length;y++){var k=j[y],E=k[0],S=k[1];h=h.replace(new RegExp(E,"g"),S)}return h},x.prototype.getPeriod=function(h){return h>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},x.locales={},x})();d.ExpressionDescriptor=b},3747(c,d,u){Object.defineProperty(d,"__esModule",{value:!0}),d.enLocaleLoader=void 0;var f=u(9486),g=(function(){function b(){}return b.prototype.load=function(x){x.en=new f.en},b})();d.enLocaleLoader=g},9486(c,d){Object.defineProperty(d,"__esModule",{value:!0}),d.en=void 0;var u=function(g){return Number(g)===1},f=(function(){function g(){}return g.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},g.prototype.atX0MinutesPastTheHourGt20=function(){return null},g.prototype.commaMonthX0ThroughMonthX1=function(){return null},g.prototype.commaYearX0ThroughYearX1=function(){return null},g.prototype.use24HourTimeFormatByDefault=function(){return!1},g.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},g.prototype.everyMinute=function(){return"every minute"},g.prototype.everyHour=function(){return"every hour"},g.prototype.atSpace=function(){return"At "},g.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},g.prototype.at=function(){return"At"},g.prototype.spaceAnd=function(){return" and"},g.prototype.everySecond=function(){return"every second"},g.prototype.everyX0Seconds=function(b){return u(b)?"every %s second":"every %s seconds"},g.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},g.prototype.atX0SecondsPastTheMinute=function(b){return u(b)?"at %s second past the minute":"at %s seconds past the minute"},g.prototype.everyX0Minutes=function(b){return u(b)?"every %s minute":"every %s minutes"},g.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},g.prototype.atX0MinutesPastTheHour=function(b){return u(b)?"at %s minute past the hour":"at %s minutes past the hour"},g.prototype.everyX0Hours=function(b){return u(b)?"every %s hour":"every %s hours"},g.prototype.betweenX0AndX1=function(){return"between %s and %s"},g.prototype.atX0=function(){return"at %s"},g.prototype.commaEveryDay=function(){return", every day"},g.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},g.prototype.commaX0ThroughX1=function(){return", %s through %s"},g.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},g.prototype.first=function(){return"first"},g.prototype.second=function(){return"second"},g.prototype.third=function(){return"third"},g.prototype.fourth=function(){return"fourth"},g.prototype.fifth=function(){return"fifth"},g.prototype.commaOnThe=function(){return", on the "},g.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},g.prototype.lastDay=function(){return"the last day"},g.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},g.prototype.commaOnlyOnX0=function(){return", only on %s"},g.prototype.commaAndOnX0=function(){return", and on %s"},g.prototype.commaEveryX0Months=function(){return", every %s months"},g.prototype.commaOnlyInX0=function(){return", only in %s"},g.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},g.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},g.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(b){return u(b)?", %s day before the last day of the month":", %s days before the last day of the month"},g.prototype.firstWeekday=function(){return"first weekday"},g.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},g.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},g.prototype.commaDaysBeforeTheX0OfTheMonth=function(b){return u(b)?", %s day before the %s of the month":", %s days before the %s of the month"},g.prototype.commaDaysAfterTheX0OfTheMonth=function(b){return u(b)?", %s day after the %s of the month":", %s days after the %s of the month"},g.prototype.commaEveryX0Days=function(){return", every %s days in a month"},g.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},g.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},g.prototype.commaEveryHour=function(){return", every hour"},g.prototype.commaEveryX0Years=function(b){return u(b)?", every %s year":", every %s years"},g.prototype.commaStartingX0=function(){return", starting %s"},g.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},g.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},g.prototype.atReboot=function(){return"Run once, at startup"},g.prototype.onTheHour=function(){return"on the hour"},g})();d.en=f},9515(c,d){Object.defineProperty(d,"__esModule",{value:!0});function u(b,x){if(!b)throw new Error(x)}function f(b){var x=[];if(!isNaN(parseInt(b,10))){x.push(parseInt(b,10));var h=b.match(/^\d+-(-?\d+)/);h&&x.push(parseInt(h[1],10))}return x}var g=(function(){function b(){}return b.stepRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++){var y=h[v].split("/")[1];u(y===void 0||!/^0+$/.test(y),"step value must be greater than 0")}},b.secondRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=0&&k<=59,"seconds part must be >= 0 and <= 59")}},b.minuteRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=0&&k<=59,"minutes part must be >= 0 and <= 59")}},b.hourRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=0&&k<=23,"hours part must be >= 0 and <= 23")}},b.dayOfMonthRange=function(x){for(var h=x.split(","),v=0;v<h.length;v++)for(var y=0,j=f(h[v]);y<j.length;y++){var k=j[y];u(k>=1&&k<=31,"DOM part must be >= 1 and <= 31")}},b.monthRange=function(x,h){for(var v=x.split(","),y=0;y<v.length;y++)for(var j=0,k=f(v[y]);j<k.length;j++){var E=k[j];u(E>=1&&E<=12,h?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},b.dayOfWeekRange=function(x,h){for(var v=x.split(","),y=0;y<v.length;y++){if(v[y].indexOf("#")>-1){var j=v[y].substring(v[y].indexOf("#")+1);u(/^[1-5]$/.test(j),"DOW nth weekday must be >= 1 and <= 5")}for(var k=0,E=f(v[y]);k<E.length;k++){var S=E[k];u(S>=0&&S<=6,h?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}}},b})();d.default=g},1823(c,d){Object.defineProperty(d,"__esModule",{value:!0}),d.StringUtilities=void 0;var u=(function(){function f(){}return f.format=function(g){for(var b=[],x=1;x<arguments.length;x++)b[x-1]=arguments[x];return g.replace(/%s/g,function(h){return b.shift()})},f.containsAny=function(g,b){return b.some(function(x){return g.indexOf(x)>-1})},f})();d.StringUtilities=u}},r={};function a(c){var d=r[c];if(d!==void 0)return d.exports;var u=r[c]={exports:{}};return s[c](u,u.exports,a),u.exports}var i={};return(()=>{var c=i;Object.defineProperty(c,"__esModule",{value:!0}),c.toString=void 0;var d=a(8333),u=a(3747);d.ExpressionDescriptor.initialize(new u.enLocaleLoader),c.default=d.ExpressionDescriptor;var f=d.ExpressionDescriptor.toString;c.toString=f})(),i})())})(jg)),jg.exports}var d6=c6();const u6=bN(d6),wd={rules:20,conditions:20,list:20,pointer:512,text:200,value:1024},Nn=wd,DC={in:"is one of",prefix:"starts with",exists:"exists",missing:"is missing"},f6=Object.keys(DC);let m6=0;const Vm=()=>`r${++m6}`,h6=()=>({key:Vm(),pointer:"",op:"in",value:""}),FC=()=>({key:Vm(),event:"",actions:"",where:[]});function UC(e){const n=e.trim();try{return JSON.parse(n)}catch{return n}}function WC(e){return typeof e!="string"?JSON.stringify(e):e!==""&&e===e.trim()&&!/[,\r\n]/.test(e)&&UC(e)===e?e:JSON.stringify(e)}const p6=e=>"in"in e?`${e.pointer} is one of ${e.in.map(WC).join(", ")}`:"exists"in e?`${e.pointer} ${e.exists?"exists":"is missing"}`:`${e.pointer} starts with ${JSON.stringify(e.prefix)}`,Zi=(e,n=!0)=>{var s,r;return`${e.event}${(s=e.actions)!=null&&s.length?` (${e.actions.join(", ")})`:""}${n&&((r=e.where)!=null&&r.length)?` where ${e.where.map(p6).join(" and ")}`:""}`};function HC(e){return"in"in e?{pointer:e.pointer,op:"in",value:e.in.map(WC).join(`
|
|
653
|
+
`)}:"exists"in e?{pointer:e.pointer,op:e.exists?"exists":"missing",value:""}:{pointer:e.pointer,op:"prefix",value:e.prefix}}const BC=e=>({key:Vm(),...HC(e),was:e}),GC=e=>{if(!e.was)return!1;const n=HC(e.was);return n.pointer===e.pointer&&n.op===e.op&&n.value===e.value},qC=e=>(e??[]).join(", "),yx=e=>({key:Vm(),event:e.event,actions:qC(e.actions),where:(e.where??[]).map(BC),was:e}),g6=(e,n)=>e.length===n.length&&e.every((s,r)=>s===n[r]),x6=e=>e.split(/[\s,]+/).filter(Boolean),v0=/^[!-~]+$/,Rc=e=>[...e].length,v6=/^(\/([^~]|~[01])*)?$/;function y6(e,n,s){return e.length>Nn.conditions&&(s[`${n}.where`]=`At most ${Nn.conditions} conditions a rule.`),e.map((r,a)=>{if(GC(r))return r.was;const i=`${n}.where[${a}]`,c=r.pointer;if(c?c.startsWith("/")?v6.test(c)?Rc(c)>Nn.pointer&&(s[`${i}.pointer`]=`At most ${Nn.pointer} characters.`):s[`${i}.pointer`]="Write ~ in a field's name as ~0, and / in it as ~1.":s[`${i}.pointer`]="A field starts with /: /title, /issue/labels/0/name.":s[`${i}.pointer`]="Name a field: a JSON pointer such as /title.",r.op==="exists"||r.op==="missing")return{pointer:c,exists:r.op==="exists"};if(r.op==="prefix"){const u=r.value.trimStart();return u?Rc(u)>Nn.text&&(s[`${i}.prefix`]=`At most ${Nn.text} characters.`):s[`${i}.prefix`]="Give the text it starts with.",{pointer:c,prefix:u}}const d=r.value.split(/\r\n|\r|\n/).filter(u=>u.trim()).map(UC);return d.length?d.length>Nn.list?s[`${i}.in`]=`At most ${Nn.list} values.`:d.some(u=>Rc(JSON.stringify(u))>Nn.value)&&(s[`${i}.in`]=`Each value is at most ${Nn.value} characters.`):s[`${i}.in`]="Give at least one value, one a line.",{pointer:c,in:d}})}function b6(e,n,s){var g;const r=`source.accept[${n}]`,a=e.was,i=a&&e.event===a.event?a.event:e.event.trim();i?i!==(a==null?void 0:a.event)&&(!v0.test(i)||Rc(i)>Nn.text)&&(s[`${r}.event`]=`An event's name has no spaces: printable characters only, at most ${Nn.text}.`):s[`${r}.event`]="Name the event.";const c=a&&(typeof e.actions=="string"?e.actions===qC(a.actions):g6(e.actions,a.actions??[])),d=c?[...a.actions??[]]:typeof e.actions=="string"?x6(e.actions):e.actions;if(a&&c&&i===a.event&&e.where.length===(((g=a.where)==null?void 0:g.length)??0)&&e.where.every((b,x)=>GC(b)&&b.was===a.where[x]))return a;d.length>Nn.list?s[`${r}.actions`]=`At most ${Nn.list} actions.`:d.some(b=>!v0.test(b)||Rc(b)>Nn.text)&&(s[`${r}.actions`]=`An action's name is printable characters, at most ${Nn.text}.`);const f=y6(e.where,r,s);return{event:i,...d.length?{actions:d}:{},...f.length?{where:f}:{}}}function iy(e){const n={};return e.length>Nn.rules&&(n["source.accept"]=`At most ${Nn.rules} rules.`),{accept:e.map((s,r)=>b6(s,r,n)),issues:n}}function Ym(e){const n=new Set(["source.accept"]);return e.forEach((s,r)=>{const a=`source.accept[${r}]`;for(const i of["",".event",".actions",".where"])n.add(`${a}${i}`);for(let i=0;i<s;i++)for(const c of["",".pointer",".in",".prefix",".exists"])n.add(`${a}.where[${i}]${c}`)}),n}const Wi=(e,n)=>n&&e===wx(n)?n:T6(e),Sl=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",KC=(e="")=>({name:"",kind:"cron",cron:"",timezone:Sl(),at:"",every:"",everyUnit:"minutes",startAt:"",agentId:e,content:"",maxCost:"",enabled:!0}),VC={seconds:1,minutes:60,hours:3600};function YC(e){const[n,s]=e%3600===0?[e/3600,"hour"]:e%60===0?[e/60,"minute"]:[e,"second"];return n===1?s:`${n} ${s}s`}function QC(e){try{return u6.toString(e,{use24HourTimeFormat:!0,throwExceptionOnParseError:!0,verbose:!1})}catch{return`Cron ${e}`}}const $a=e=>String(e).padStart(2,"0"),Hf=(e,n)=>e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:n});function JC(e,n){const s=i=>{var c;return((c=new Intl.DateTimeFormat(i,{timeZone:n,timeZoneName:"short"}).formatToParts(e).find(d=>d.type==="timeZoneName"))==null?void 0:c.value)??n},r=s("en-US");if(!/^GMT[+-]/.test(r))return r;const a=s("en-GB");return/^GMT[+-]/.test(a)?r:a}const y0=(e,n)=>{const s=new Date(e);return`${s.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:n}).replace(",","")}, ${Hf(s,n)} ${JC(s,n)}`};function b0(e,{zone:n=Sl(),now:s=Date.now()}={}){const r=new Date(e),a=c=>c.toLocaleDateString("en-US",{year:"numeric",month:"numeric",day:"numeric",timeZone:n});return`Pick a time in the future: ${a(r)===a(new Date(s))?`${Hf(r,n)} today`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:n})}, ${Hf(r,n)} ${JC(r,n)}`} has already passed.`}function Bf(e,n){const s={};for(const{type:r,value:a}of new Intl.DateTimeFormat("en-US",{timeZone:n,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}).formatToParts(e))s[r]=a;return Date.UTC(Number(s.year),Number(s.month)-1,Number(s.day),Number(s.hour),Number(s.minute))}function w6(e,n,s,r){const a=new Date(Bf(e,n)),i=Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),s,r);let c=i;for(let d=0;d<2;d++)c+=i-Bf(new Date(c),n);return new Date(c)}const j6=e=>{const n=e.trim().split(/\s+/);return n.length!==5||!/^\d{1,2}$/.test(n[0])||!/^\d{1,2}$/.test(n[1])?null:{minute:Number(n[0]),hour:Number(n[1]),days:n.slice(2).some(s=>s!=="*"&&s!=="?")}};function k6(e,n,s,r,a){const i=QC(e),c=n!==s,d=j6(e),u=d&&`At ${$a(d.hour)}:${$a(d.minute)}`;if(d&&u&&i.startsWith(u))try{const f=r??w6(a,n,d.hour,d.minute),g=d.days?Math.floor(Bf(f,s)/864e5)-Math.floor(Bf(f,n)/864e5):0,b=g>0?" the next day":g<0?" the day before":"";return`At ${Hf(f,s)} your time${b}${c?` (${u.slice(3)} ${n})`:""}${i.slice(u.length)}`}catch{}return`${i}${c?` (${n})`:""}`}function ly(e,n,{zone:s=Sl(),instead:r,now:a=Date.now()}={}){const i=r?` · ${r}`:n?` · next ${y0(n,s)}`:" · no next time";return"cron"in e?`${k6(e.cron,e.timezone,s,n?new Date(n):null,new Date(a))}${i}`:"at"in e?`Once, ${y0(e.at,s)}${!r&&n&&Date.parse(n)===Date.parse(e.at)?"":i}`:`Every ${YC(e.every_s)}${i}`}const ei=e=>`$${Number.isInteger(Math.round(e*1e6)/1e4)?e.toFixed(2):String(e)}`,N6=e=>`${ei(e)} a run`,S6=(e,n)=>typeof e=="number"?N6(e):typeof n=="number"&&n>0?`Agent's default (${ei(n)})`:"Agent's default";function cy(e,n,s=[]){if(e.source.kind!=="schedule"||!("at"in e.source)||e.next_at!==null)return null;const r=Date.parse(e.source.at);if(r>n)return null;const a=[e.last_firing,...s].find(i=>i&&i.status==="started"&&Date.parse(i.nominal_at)===r);return a?{ran:a}:{passed:e.source.at}}const dy=e=>e.source.kind==="schedule"&&e.target.kind==="start_run",uy=e=>e.source.kind==="webhook"&&e.target.kind==="start_run",XC=e=>e.source.kind==="github"&&e.target.kind==="start_run",Qm=[{event:"pull_request",action:"opened",label:"A pull request is opened"},{event:"pull_request",action:"synchronize",label:"A pull request gets new commits"},{event:"pull_request",action:"reopened",label:"A pull request is reopened"},{event:"issue_comment",action:"created",label:"Someone comments on an issue or pull request"}],Kc=e=>`${location.origin}/v2/hooks/${encodeURIComponent(e.id)}`,fy="This server's address as this page sees it: behind a proxy, use its public address.",bx={standard:"Standard Webhooks (webhook-signature)",github:"GitHub's (X-Hub-Signature-256)"},ZC=e=>{var n;return(n=e.accept)!=null&&n.length?`Only signed requests for ${e.accept.map(s=>Zi(s,!1)).join(" or ")}`:"On each signed request"},C6={schedule:"On schedule",manual:"Run now",webhook:"On a request",github:"On a GitHub event",composio:"On an app event",email:"On an email"},eE=e=>`On ${e.event} from ${e.server}`,E6=e=>{var n;return(n=e.accept)!=null&&n.length?`On email in ${e.mailbox} for ${e.accept.map(s=>Zi(s,!1)).join(" or ")}`:`On each email in ${e.mailbox}`},tE=e=>`On GitHub ${e.accept.map(n=>Zi(n,!1)).join(" or ")}`;function Gf(e,n){const s=e.disabled;return s?s.reason==="source_unreadable"?`Turned off: its source can't be read (${s.detail}).`:s.reason!=="auto_paused"?`Turned off: ${s.detail}`:n?`Turned off after ${n} failures in a row.`:"Turned off after failures in a row.":null}function nE(e){var s;const n=(r,a)=>a?`${r}: ${a}`:r;switch(e.status){case"started":return"Started";case"skipped":return n("Skipped",e.reason);case"missed":return n(`Missed ${e.count??1} ${e.count===1||e.count===void 0?"time":"times"}`,e.reason);case"failed":return n("Failed",((s=e.error)==null?void 0:s.message)??e.reason);case"due":return e.retry_at?`Due: the server was full, tries again at ${od(e.retry_at)}`:"Due";case"sent":return"Sent";default:return String(e.status)}}const $6={due:"Due",started:"Started",sent:"Sent",skipped:"Skipped",failed:"Failed",missed:"Missed"},_6=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/;function T6(e){if(!_6.test(e))return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toISOString().replace(/\.\d{3}Z$/,"Z")}function wx(e){const n=new Date(e);return`${n.getFullYear()}-${$a(n.getMonth()+1)}-${$a(n.getDate())}T${$a(n.getHours())}:${$a(n.getMinutes())}${n.getSeconds()?`:${$a(n.getSeconds())}`:""}`}const w0=e=>`${new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"UTC"})} UTC`;function R6(e){const n=YC(e);return/^\d/.test(n)?`At least ${n}.`:`At least ${n==="hour"?"an":"a"} ${n}.`}const qf="A number is needed.",Kf=e=>e.trim()!==""&&Number.isFinite(Number(e))?Number(e):void 0;function j0(e,n=!1){var i,c;const s={};let r;if(e.kind==="cron")e.cron.trim()||(s["source.cron"]="Pick when it runs."),r={kind:"schedule",cron:e.cron.trim(),timezone:e.timezone.trim()||Sl()};else if(e.kind==="at"){const d=Wi(e.at,(i=e.read)==null?void 0:i.at);d===null&&(s["source.at"]="A time is needed."),r={kind:"schedule",at:d??""}}else{const d=Kf(e.every);e.every.trim()?d===void 0&&(s["source.every_s"]=qf):s["source.every_s"]="A number is needed.";const u=e.startAt?Wi(e.startAt,(c=e.read)==null?void 0:c.startAt):null;r={kind:"schedule",every_s:Math.round((d??0)*VC[e.everyUnit]),...u?{start_at:u}:{}}}e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const a=Kf(e.maxCost);return e.maxCost.trim()?a===void 0&&(s["target.max_cost_usd"]=qf):n||(s["target.max_cost_usd"]="A cost cap is needed: every run a schedule starts is capped."),Object.keys(s).length?{issues:s}:{body:{...e.name.trim()?{name:e.name.trim()}:{},enabled:e.enabled,source:r,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...a!==void 0?{max_cost_usd:a}:{}}}}}const A6=()=>({name:"",signature:"standard",accept:[],agentId:"",content:"",maxCost:""});function sE(e,n){const{accept:s,issues:r}=iy(n);return{source:{kind:"webhook",...e.signature!==void 0?{signature:e.signature}:{},...s.length?{accept:s}:{}},issues:r}}function O6(e,n=!1){const{source:s,issues:r}=sE({signature:e.signature},e.accept);return hy(e,s,r,n,"a webhook")}const M6=()=>({name:"",events:["pull_request:opened"],where:{},other:[],agentId:"",content:"",maxCost:""}),rE=[...new Set(Qm.map(e=>e.event))],P6=(e,n)=>e.length===n.length&&e.every(s=>n.includes(s));function Jm(e){var i;const s=[...rE.flatMap(c=>{var f;const d=Qm.filter(g=>g.event===c&&e.events.includes(`${g.event}:${g.action}`)).map(g=>g.action);if(!d.length)return[];const u=(f=e.read)==null?void 0:f.rules[c];return[{id:`event:${c}`,event:c,actions:u!=null&&u.actions&&P6(d,u.actions)?[...u.actions]:d,where:e.where[c]??[],...u?{was:u}:{}}]}),...e.other.map(c=>({...c,id:`other:${c.key}`}))],r=((i=e.read)==null?void 0:i.order)??[],a=c=>{const d=r.indexOf(c.id);return d<0?r.length:d};return s.map((c,d)=>({r:c,i:d})).sort((c,d)=>a(c.r)-a(d.r)||c.i-d.i).map(({r:c})=>c)}function oE(e){const{accept:n,issues:s}=iy(Jm(e));return n.length||(s["source.accept"]="Pick at least one event."),{source:{kind:"github",accept:n},issues:s}}function L6(e){var s;const n={events:[],where:{},other:[],read:{order:[],rules:{}}};for(const r of e){const a=Qm.filter(c=>c.event===r.event).map(c=>c.action);if(!(!!((s=r.actions)!=null&&s.length)&&r.actions.every(c=>a.includes(c))&&new Set(r.actions).size===r.actions.length&&!(r.event in n.where))){const c=yx(r);n.other.push(c),n.read.order.push(`other:${c.key}`);continue}n.events.push(...r.actions.map(c=>`${r.event}:${c}`)),n.where[r.event]=(r.where??[]).map(BC),n.read.order.push(`event:${r.event}`),n.read.rules[r.event]=r}return n}const my=e=>e.source.kind==="composio"&&e.target.kind==="start_run";function I6(e){const n=(e==null?void 0:e.properties)??{},s=new Set(Array.isArray(e==null?void 0:e.required)?e.required.filter(r=>typeof r=="string"):[]);return Object.entries(n).filter(([,r])=>r&&typeof r=="object"&&r.deprecated!==!0).map(([r,a])=>{const i=(Array.isArray(a.type)?a.type:[a.type]).filter(f=>f!=="null"),c=i.length===1&&["string","number","integer","boolean"].includes(String(i[0]))?i[0]:"json",d=c==="string"&&Array.isArray(a.enum)&&a.enum.every(f=>typeof f=="string")?a.enum:void 0,u=a.default===void 0?c==="boolean"?"false":"":c==="json"?JSON.stringify(a.default):String(a.default);return{name:r,title:typeof a.title=="string"&&a.title.trim()?a.title:r,...typeof a.description=="string"&&a.description.trim()?{description:a.description}:{},required:s.has(r),type:c,...d?{options:d}:{},initial:u}})}function z6(e,n,s){const r={};for(const a of e){const i=(n[a.name]??a.initial).trim(),c=`source.config.${a.name}`;if(!i){a.required&&(s[c]=`${a.title} is required.`);continue}if(a.type==="boolean")r[a.name]=i==="true";else if(a.type==="number"||a.type==="integer"){const d=Kf(i);d===void 0||a.type==="integer"&&!Number.isInteger(d)?s[c]=a.type==="integer"?"A whole number is needed.":qf:r[a.name]=d}else if(a.type==="json")try{r[a.name]=JSON.parse(i)}catch{s[c]="Give it as JSON."}else r[a.name]=i}return r}const D6=()=>({name:"",server:"",event:"",config:{},where:[],agentId:"",content:"",maxCost:""});function aE(e,n,s=[],r){var i;const a=n.length||r&&!((i=r.where)!=null&&i.length)?[{event:e,actions:"",where:n,...r?{was:r}:{}}]:[];return iy([...a,...s])}function F6(e,n,s=[],r){const{accept:a,...i}=e,{accept:c,issues:d}=aE(e.event,n,s,r);return{source:{...i,...c.length?{accept:c}:{}},issues:d}}function U6(e,n,s=!1){const r={};e.server||(r["source.server"]="Pick a Composio server."),e.event||(r["source.event"]="Pick an event.");const a=e.event?z6(n,e.config,r):{},{accept:i,issues:c}=aE(e.event,e.where);Object.assign(r,c);const d={kind:"composio",server:e.server,event:e.event,config:a,...i.length?{accept:i}:{}};return hy(e,d,r,s,"a trigger")}function W6(e,n=!1){const{source:s,issues:r}=oE(e);return hy(e,s,r,n,"a GitHub trigger")}function hy(e,n,s,r,a){e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const i=Kf(e.maxCost);return e.maxCost.trim()?i===void 0&&(s["target.max_cost_usd"]=qf):r||(s["target.max_cost_usd"]=`A cost cap is needed: every run ${a} starts is capped.`),Object.keys(s).length?{issues:s}:{body:{...e.name.trim()?{name:e.name.trim()}:{},source:n,target:{kind:"start_run",agent_id:e.agentId,input:{content:e.content},...i!==void 0?{max_cost_usd:i}:{}}}}}function H6(e){const n=e.source,s="cron"in n?n.timezone:Sl(),r={...KC(e.target.agent_id),name:e.name,timezone:s,content:typeof e.target.input.content=="string"?e.target.input.content:"",maxCost:typeof e.target.max_cost_usd=="number"?String(e.target.max_cost_usd):"",enabled:e.enabled};if("cron"in n)return{...r,kind:"cron",cron:n.cron};if("at"in n)return{...r,kind:"at",at:wx(n.at),read:{at:n.at}};const a=n.every_s%3600===0?"hours":n.every_s%60===0?"minutes":"seconds";return{...r,kind:"every",every:String(n.every_s/VC[a]),everyUnit:a,startAt:wx(n.start_at),read:{startAt:n.start_at}}}const Vf=(e,n)=>{if(e===n)return!0;if(typeof e!="object"||typeof n!="object"||e===null||n===null||Array.isArray(e)!==Array.isArray(n))return!1;const[s,r]=[Object.keys(e),Object.keys(n)];return s.length===r.length&&s.every(a=>Vf(e[a],n[a]))};function k0(e,n){const s=n.source&&"every_s"in n.source&&!n.source.start_at&&"every_s"in e.source?{...n.source,start_at:e.source.start_at}:n.source,r=n.target&&{...n.target,input:{...e.target.input,...n.target.input},...e.target.effort!==void 0&&n.target.effort===void 0?{effort:e.target.effort}:{}};return{...n.name!==void 0&&n.name!==e.name?{name:n.name}:{},...s&&!Vf(s,e.source)?{source:s}:{},...r&&!Vf(r,e.target)?{target:r}:{}}}const B6=["name","enabled","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd"];function jd(e){var r;if(!(e instanceof De))return{fields:{},rest:[e instanceof Error?e.message:String(e)]};if(e.status!==422||!((r=e.fields)!=null&&r.length))return{fields:{},rest:[`${e.code}: ${e.message}`]};const n={},s=[];for(const a of e.fields){const i=a.field.startsWith("target.input")?"target.input":a.field;(B6.includes(i)||i.startsWith("source.accept")||i==="source.server"||i==="source.event"||i==="source.config"||i.startsWith("source.config."))&&!n[i]?n[i]=a.message:s.push(a.message)}return{fields:n,rest:s}}const G6=[{value:"hourly",label:"Every hour"},{value:"daily",label:"Every day"},{value:"weekdays",label:"Every weekday (Monday to Friday)"},{value:"weekly",label:"Every week"},{value:"monthly",label:"Every month"},{value:"custom",label:"Custom schedule"}],q6=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]})),K6=Array.from({length:31},(e,n)=>({value:String(n+1),label:String(n+1)})),V6=Array.from({length:60},(e,n)=>({value:String(n),label:`:${String(n).padStart(2,"0")}`}));function iE({value:e,onChange:n,label:s,name:r}){const a=r6(e),[i,c]=p.useState(()=>e.trim()!==""&&!a),d=p.useId(),u=i||e.trim()!==""&&!a,f=x=>n(o6(x)),g=x=>{if(x==="custom"){c(!0);return}c(!1),f(a6(x,a))},b=a&&"at"in a?a.at:null;return t.jsxs("div",{className:"space-y-2","data-schedule-when":!0,children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Rt,{label:s,className:"min-w-56 flex-1",value:u?"custom":(a==null?void 0:a.kind)??"",onChange:g,placeholder:"Pick when it runs",options:G6}),!u&&(a==null?void 0:a.kind)==="weekly"&&t.jsx(Rt,{id:`${d}-day`,label:"Day of the week",className:"w-40",value:String(a.day),onChange:x=>f({...a,day:Number(x)}),options:q6}),!u&&(a==null?void 0:a.kind)==="monthly"&&t.jsx(Rt,{id:`${d}-date`,label:"Day of the month",className:"w-24",value:String(a.date),onChange:x=>f({...a,date:Number(x)}),options:K6}),!u&&(a==null?void 0:a.kind)==="hourly"&&t.jsx(Rt,{id:`${d}-minute`,label:"Minutes past the hour",className:"w-24",value:String(a.minute),onChange:x=>f({...a,minute:Number(x)}),options:V6}),!u&&a&&b&&t.jsx(ze,{id:`${d}-at`,type:"time","aria-label":"At",className:"w-32",value:i6(b),onChange:x=>{const h=l6(x.target.value);h&&f({...a,at:h})}})]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(ze,{id:`${d}-line`,name:r,"aria-label":"Custom schedule",value:e,onChange:x=>n(x.target.value),placeholder:"30 1 * * *",spellCheck:!1}),t.jsx("p",{className:"text-small text-muted-foreground","aria-live":"polite",children:e.trim()?QC(e.trim()):"Minute, hour, day of month, month, day of week."})]})]})}const N0=Intl.supportedValuesOf,Ju=typeof N0=="function"?N0("timeZone"):[],Xu=Ju.length&&!Ju.includes("UTC")?["UTC",...Ju]:Ju;function lE({value:e,onChange:n,label:s,name:r,id:a,className:i}){if(!Xu.length)return t.jsx(ze,{id:a,name:r,"aria-label":s,className:i,value:e,onChange:d=>n(d.target.value),placeholder:"Europe/Madrid"});const c=e&&!Xu.includes(e)?[e,...Xu]:Xu;return t.jsx(Rt,{id:a,name:r,label:s,className:i,value:e,onChange:n,placeholder:"Pick a time zone",options:c.map(d=>({value:d,label:d.replace(/_/g," ")}))})}function Y6(e,n){var i,c,d;let s;if(e==="agentic"&&n.json)try{s=JSON.parse(n.text)}catch{return{ok:!1,field:"input",message:"The agent's input is JSON: this is not."}}else if(e==="agentic"&&n.typed){if(n.typed.contentRequired&&!n.text.trim())return{ok:!1,field:"input",message:"Write the run's message."};s={...n.text.trim()?{content:n.text}:{},...n.typed.fields}}else if(e==="agentic"){if(!n.text.trim())return{ok:!1,field:"input",message:"Write the run's first message."};s={content:n.text}}else try{s=JSON.parse(n.text)}catch{return{ok:!1,field:"input",message:"The workflow's input is JSON: this is not."}}const r={input:s};if(n.revision&&(r.revision=n.revision),n.effort&&(r.effort=n.effort),e==="agentic"&&((i=n.maxCostUsd)!=null&&i.trim())){const u=Number(n.maxCostUsd);if(!Number.isFinite(u)||u<=0)return{ok:!1,field:"max_cost_usd",message:"A spend cap is a positive number of dollars."};r.max_cost_usd=u}(c=n.fileIds)!=null&&c.length&&(r.file_ids=[...n.fileIds]);const a=e==="agentic"?(d=n.repo)==null?void 0:d.trim():void 0;if(a){if(!/^[^/\s]+\/[^/\s]+$/.test(a))return{ok:!1,field:"repo",message:"A repository is owner/name, like Parcha-ai/agentrun."};r.repo=a}return{ok:!0,body:r}}function Q6(e,n){return s=>{var a,i,c,d;const r=new Set;for(;s!=null&&s.$ref&&!r.has(s.$ref);){r.add(s.$ref);const u=(i=(a=/^#\/(?:definitions|\$defs)\/(.+)$/.exec(s.$ref))==null?void 0:a[1])==null?void 0:i.replace(/~1/g,"/").replace(/~0/g,"~"),f=u===void 0?void 0:((c=e.definitions)==null?void 0:c[u])??((d=e.$defs)==null?void 0:d[u])??(Object.hasOwn(n,u)?n[u]:void 0);if(!f)break;s=f}return s}}function J6(e,n,s="workflow"){if(e.from==="example")return`The ${s}'s example input. Edit it, then ${n}.`;const r=e.optional.length?` It also takes ${e.optional.join(", ")}, if you add ${e.optional.length===1?"it":"them"}.`:"";return`The ${s}'s input, its required fields empty. Fill them in, then ${n}.${r}`}function X6(e){var r,a;const n=e,s=(r=n==null?void 0:n.input)!=null&&r.schemaId?(a=n.schemas)==null?void 0:a[n.input.schemaId]:void 0;return s?cE(s,(n==null?void 0:n.schemas)??{}):null}function cE(e,n={}){var u;const s=Q6(e,n),r=s(e),a=Object.entries(r.properties??{}).map(([f,g])=>{const b=s(g);return{name:f,...b!=null&&b.description?{note:b.description}:{}}}),i=((u=r.examples)==null?void 0:u[0])??r.default;if(i!==void 0)return{text:JSON.stringify(i,null,2),from:"example",fields:a,optional:[]};const c=(f,g=0)=>{var h,v;const b=s(f);if(!b||g>4)return null;if((h=b.examples)!=null&&h.length)return b.examples[0];if(b.default!==void 0)return b.default;if((v=b.enum)!=null&&v.length)return b.enum[0];const x=Array.isArray(b.type)?b.type[0]:b.type;return x==="object"||b.properties?Object.fromEntries(Object.entries(b.properties??{}).filter(([y])=>(b.required??[]).includes(y)).map(([y,j])=>[y,c(j,g+1)])):x==="array"?[]:x==="string"?"":x==="number"||x==="integer"?0:x==="boolean"?!1:null},d=new Set(r.required??[]);return{text:JSON.stringify(c(r),null,2),from:"shape",fields:a,optional:a.map(f=>f.name).filter(f=>!d.has(f))}}const kg=e=>`'${e.replace(/'/g,"'\\''")}'`;function Z6(e,n,s,r){return[`curl -X POST ${kg(`${e}/v2/agents/${n?encodeURIComponent(n):"{agent_id}"}/runs`)} \\`,' -H "Authorization: Bearer $AGENTRUN_API_KEY" \\'," -H 'Content-Type: application/json' \\",` -H ${kg(`Idempotency-Key: ${r}`)} \\`,` -d ${kg(JSON.stringify(s))}`].join(`
|
|
654
|
+
`)}const e8=e=>e>=200&&e<300;async function t8(e,n,s,r){const a=await r(n,s,e.keyFor(n,s));return e8(a.status)&&e.done(),a}const Uo=(e,n={})=>(e.display_name||e.name).replace(/\$\{parameters\.([A-Za-z0-9_]+)\}/g,(s,r)=>(Object.hasOwn(n,r)?gy(n[r]).join(", "):"")||"…"),dE=e=>`#/templates/${encodeURIComponent(e)}`;function el(e,n){return`#/playground?${new URLSearchParams({operation:"apply-template",template:e.id,...n?{draft:JSON.stringify({template:e.id,version:e.version,...e.sha?{sha:e.sha}:{},body:n})}:{}})}`}function n8(e,n){var r,a;if(e===void 0)return{};const s={error:"This prepared template request is invalid. Open a fresh request to review its settings."};try{const i=JSON.parse(e),c=x=>x!==null&&typeof x=="object"&&!Array.isArray(x);if(!c(i)||i.template!==n.id||typeof i.version!="string")return s;if(i.version!==n.version)return{error:"This template's version changed. Open a fresh request to review the current package before applying."};if(n.sha&&i.sha!==n.sha)return{error:"This template's commit changed. Open a fresh request to review the current package before applying."};const d=i.body,u=(x,h)=>x==="boolean"?typeof h=="boolean":x==="string"?typeof h=="string":(x==="number"||x==="integer")&&typeof h=="number"&&Number.isFinite(h);if(!c(d)||Object.keys(d).some(x=>!["parameters","grants","servers","overrides"].includes(x))||!c(d.parameters)||d.grants!==void 0&&(!Array.isArray(d.grants)||d.grants.some(x=>typeof x!="string"||!n.mcp.some(h=>h.tools.some(v=>v.tool===x))))||d.servers!==void 0&&(!c(d.servers)||Object.entries(d.servers).some(([x,h])=>!n.mcp.some(v=>v.toolkit===x)||typeof h!="string"||!/^[a-z][a-z0-9-]{0,31}$/.test(h)))||!c(d.overrides)||Object.keys(d.overrides).some(x=>x!=="approvals"&&x!=="choice")||d.overrides.approvals!=="ask"&&d.overrides.approvals!=="never"||d.overrides.choice!==void 0&&(typeof d.overrides.choice!="string"||!((a=(r=n.model)==null?void 0:r.choices)!=null&&a.map(x=>x.id).includes(d.overrides.choice))))return s;const f=Xm(n.parameters);if(!f)return s;const g=new Map(f),b=[];for(const[x,h]of Object.entries(d.parameters)){const v=g.get(x);if(!v)return s;if(h==="")continue;if(v.array?!Array.isArray(h)||!h.every(k=>u(v.type,k)):!u(v.type,h))return s;const y=Array.isArray(h)?h.map(String).join(`
|
|
655
|
+
`):String(h),j=eh({fields:[[x,v]],contentRequired:!1},{[x]:y})[x];if(JSON.stringify(j)!==JSON.stringify(h))return s;b.push([x,h])}return{body:{...d,parameters:Object.fromEntries(b)}}}catch{return s}}const s8=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function py(e,{secrets:n=!0,mcp:s=!0}={}){var a,i;const r=[];return n&&e.secrets.length&&r.push(["Keys",e.secrets.join(", ")]),s&&e.mcp.length&&r.push(["MCP",e.mcp.map(c=>`${c.toolkit} (${hd[c.source]}${c.required?"":", optional"})`).join(", ")]),e.triggers.length&&r.push(["Triggers",s8(e.triggers.length,"trigger")]),(a=e.budget)!=null&&a.per_run_usd&&r.push(["Budget",`${Zr(e.budget.per_run_usd)} a run`]),(i=e.harness)!=null&&i.length&&r.push(["Harness",e.harness.join(", ")]),e.model&&r.push(["Model",`${e.model.tier}${e.model.prefer?`, ${e.model.prefer} first`:""}`]),r}function kd(e){var s;if(e.type==="boolean"||e.array)return null;if((s=e.enum)!=null&&s.length)return e.enum.map(String);const n=e.pattern?/^\^\(([A-Za-z0-9_-]+(?:\|[A-Za-z0-9_-]+)+)\)\$$/.exec(e.pattern):null;return n?n[1].split("|"):null}function r8(e){return Object.fromEntries(Object.entries(e).flatMap(([n,s])=>s.array?[]:s.type==="boolean"?typeof s.default=="boolean"?[[n,String(s.default)]]:[]:kd(s)?[]:s.format==="timezone"?[[n,Sl()]]:s.format==="cron"?typeof s.default=="string"?[[n,s.default]]:[]:[]))}const o8=(e,n)=>n.filter(s=>s.source===e.source&&s.toolkit===e.toolkit).map(s=>s.name).sort();function a8(e){const n=encodeURIComponent(e.toolkit);return e.source==="composio"?`#/settings/mcp?add=${n}&preset=composio&toolkit=${n}&tools=${e.tools.map(s=>encodeURIComponent(s.name)).join(",")}`:e.source==="github"?"#/settings/mcp?add=github&auth=github_app":`#/settings/mcp?add=${n}`}const Yf=e=>e.mcp.length===0&&e.secrets.length===0,i8=e=>{const n=e.source;return typeof n=="object"&&n!==null&&"kind"in n?n.kind:void 0},S0=[{id:"email",what:"the email account",needs:e=>(e.tools??[]).some(n=>n.startsWith("email_"))||e.triggers.some(n=>i8(n)==="email"),met:async e=>(await e.emailAccount()).configured,unmet:{before:"Connect your mailbox under ",link:"Settings → Email",href:"#/settings/email",after:" first."}}],l8=(e,n)=>e.mcp.flatMap(s=>s.tools.map(r=>r.tool)).filter(s=>n.has(s)),c8=(e,n)=>e.filter(s=>s.field===n);function Qf(e){if(e.type!=="string"||e.format!=="cron"&&e.format!=="timezone"||!e.description)return e.description;if(e.format==="timezone")return;const n=e.description.indexOf(": ");return n<0?void 0:e.description.slice(n+2).trim()||void 0}function d8(e){const n=kd(e);if(!n)return null;const s=e.default===void 0?void 0:String(e.default);return[{value:"",label:e.required?"Choose one":"None chosen"},...n.map(r=>({value:r,label:r===s?`${r} (default)`:r}))]}function u8(e,n,s,r=n){if(!s)return e.message;switch(e.reason){case"missing":return`${r} is required.`;case"wrong_type":return s.array?`${r} takes a list, one item a line.`:`${r} takes ${s.type==="integer"?"a whole number":s.type==="number"?"a number":s.type==="boolean"?"yes or no":"text"}.`;case"not_an_option":return`${r} takes one of: ${uE(s).join(", ")}.`;case"bad_format":return`${r} isn't in the form its description asks for.`;default:return e.message}}const uE=e=>{var n;return(n=e.enum)!=null&&n.length?e.enum.map(String):kd(e)??[]};function fE(e,n){var c;if(e.array){const d=gy(n);return d.length?d.every(u=>fE({...e,array:!1,required:!0},u)):!e.required}if(n==="")return!e.required;const s=kd(e);if(s)return s.includes(n);const r=Number(n),a=(e.minimum===void 0||r>=e.minimum)&&(e.maximum===void 0||r<=e.maximum);if(e.type==="integer")return n.trim()!==""&&Number.isSafeInteger(r)&&a;if(e.type==="number")return n.trim()!==""&&Number.isFinite(r)&&a;if(e.type==="boolean")return(n==="true"||n==="false")&&(!((c=e.enum)!=null&&c.length)||uE(e).includes(n));const i=[...n].length;if(e.minLength!==void 0&&i<e.minLength||e.maxLength!==void 0&&i>e.maxLength)return!1;if(e.pattern)try{return new RegExp(e.pattern,"u").test(n)}catch{return!0}return!0}const gy=e=>(e??"").split(`
|
|
656
|
+
`).map(n=>n.trim()).filter(n=>n!==""),mE=fE,Ma=e=>!!e&&typeof e=="object"&&!Array.isArray(e),f8=new Set(["string","number","integer","boolean"]),m8=["oneOf","anyOf","allOf","not","if","$ref","const"],jx=e=>m8.some(n=>n in e),Zu=e=>typeof e=="string"?e:void 0,ef=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,h8=e=>Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0));function p8(e,n){if(!Ma(e)||jx(e))return null;const s=e.type==="array",r=s?e.items:e;if(!Ma(r)||jx(r)||typeof r.type!="string"||!f8.has(r.type))return null;const a=Array.isArray(r.enum)&&r.enum.every(i=>["string","number","boolean"].includes(typeof i))?r.enum:void 0;return h8({type:r.type,...s?{array:!0}:{},required:n,title:Zu(e.title),description:Zu(e.description),examples:Array.isArray(e.examples)?e.examples:void 0,default:e.default,enum:a,pattern:Zu(r.pattern),format:Zu(r.format),minimum:ef(r.minimum),maximum:ef(r.maximum),minLength:ef(r.minLength),maxLength:ef(r.maxLength)})}function Xm(e,n){const s=Ma(e)&&Ma(e.properties)?e.properties:{},r=Ma(e)&&Array.isArray(e.required)?e.required:[],a=[];for(const[i,c]of Object.entries(s)){if(i===n)continue;const d=p8(c,r.includes(i));if(!d)return null;a.push([i,d])}return a}function g8(e){if(!Ma(e))return{kind:"message"};const n=()=>({kind:"json",example:cE(e)});if(jx(e))return n();const s=Ma(e.properties)?e.properties:{},r=Array.isArray(e.required)?e.required.filter(i=>typeof i=="string"):[];if(r.some(i=>i!=="content"&&!Object.hasOwn(s,i)))return n();const a=Xm(e,"content");return a?a.length?{kind:"fields",form:{fields:a,contentRequired:r.includes("content")||!r.some(i=>i!=="content")}}:{kind:"message"}:n()}const Zm=(e,n)=>n.title||e;function x8(e){var s;const n=(s=e.examples)!=null&&s.length?e.examples[0]:e.default;if(n!=null)return Array.isArray(n)?n.map(String).join(`
|
|
657
|
+
`):typeof n=="object"?JSON.stringify(n):String(n)}function v8(e,n){const s=r=>e.type==="number"||e.type==="integer"?r.trim()!==""&&Number.isFinite(Number(r))?Number(r):r:e.type==="boolean"?r==="true"?!0:r==="false"?!1:r:r;if(e.array){const r=gy(n);return r.length?r.map(s):e.required?[]:void 0}return e.type==="boolean"?n==="true"||n==="false"?n==="true":e.required?!1:void 0:n===void 0||n===""?e.required&&e.type==="string"?"":void 0:s(n)}function hE(e){const n=r8(Object.fromEntries(e.fields));for(const[s,r]of e.fields){const a=r.array?null:kd(r);a&&r.default!==void 0&&a.includes(String(r.default))&&(n[s]=String(r.default))}return n}function eh(e,n){const s={};for(const[r,a]of e.fields){const i=v8(a,n[r]);i!==void 0&&(s[r]=i)}return s}const y8=(e,n,s)=>({...n.trim()?{content:n}:{},...eh(e,s)}),kx=(e,n="input")=>e.startsWith(`${n}.`)?e.slice(n.length+1).split(".")[0]:null,pE=e=>e.type==="integer"?"a whole number":e.type==="number"?"a number":e.type==="boolean"?"true or false":"text",b8={string:"text",integer:"whole numbers",number:"numbers",boolean:"true or false"},w8=e=>e.array?`a list of ${b8[e.type]}`:pE(e);function gE(e,n,s){var a;const r=Zm(n,s);return s.array&&e.reason==="wrong_type"?e.field.endsWith(`.${n}`)?`${r} takes a list, one item a line.`:`Each line of ${r} is ${pE(s)}.`:s.array&&e.reason==="not_an_option"&&((a=s.enum)!=null&&a.length)?`Each line of ${r} is one of: ${s.enum.map(String).join(", ")}.`:u8(e,n,s,r)}const j8={date:"date",email:"email",uri:"url"};function xE({field:e,label:n,help:s,value:r,onChange:a}){const i=x8(e),c=d8(e);return t.jsxs("label",{className:"block",children:[t.jsxs("span",{className:"caps text-small font-semibold",children:[n,e.required&&t.jsx("span",{className:"text-destructive-text",children:" *"})]}),t.jsxs("span",{className:"mb-1.5 block text-small text-muted-foreground",children:[s,e.array&&t.jsxs(t.Fragment,{children:[s?" ":"","One a line."]})]}),c?t.jsx(Rt,{label:n,className:"w-full",value:r,onChange:a,options:c}):e.array?t.jsx(dn,{rows:3,value:r,required:e.required,placeholder:i,onChange:d=>a(d.target.value),className:"resize-y leading-[1.6]"}):e.format==="cron"&&e.type==="string"?t.jsx(iE,{label:n,value:r,onChange:a}):e.format==="timezone"&&e.type==="string"?t.jsx(lE,{label:n,className:"w-full",value:r,onChange:a}):e.type==="boolean"?t.jsx("input",{type:"checkbox",className:"size-4 accent-primary",checked:r==="true",onChange:d=>a(d.target.checked?"true":"false")}):t.jsx(ze,{type:e.type==="string"?j8[e.format??""]??"text":"number",step:e.type==="integer"?1:"any",value:r,required:e.required,placeholder:i,min:e.minimum,max:e.maximum,minLength:e.minLength,maxLength:e.maxLength,onChange:d=>a(d.target.value)})]})}function Po({issues:e,named:n=!1,words:s=r=>r.message}){return e.length?t.jsx("ul",{className:"mt-1.5 space-y-1 text-small text-destructive-text",role:"alert",children:e.map((r,a)=>t.jsxs("li",{children:[n&&t.jsxs("span",{className:"font-mono",children:[r.field," "]}),s(r),r.fix&&t.jsx("span",{className:"block text-foreground/80",children:r.fix})]},`${r.field}:${a}`))}):null}const vE={standard:"The event is the JSON body's top-level type (Standard Webhooks), such as issue.opened. Conditions read the body: /title is its title.",github:"The event is the X-GitHub-Event header: pull_request, issue_comment, push. Conditions read the body."},k8='One value a line. A number, true, false or null is that JSON value, and so is a line in double quotes ("42" is the text 42) or a {…} or […]. Any other line is its text.',Ac=(e,n)=>e[n]?t.jsx("span",{"data-issue":n,children:e[n]}):void 0,ro=({issues:e,field:n})=>e[n]?t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:t.jsx("span",{"data-issue":n,children:e[n]})}):null;function xy({name:e,at:n,where:s,onChange:r,issues:a,label:i}){const c=(f,g)=>r(s.map((b,x)=>x===f?{...b,...g}:b)),d=(f,g)=>c(f,g==="prefix"?{op:g,value:s[f].value.split(/\r\n|\r|\n/).find(b=>b.trim())??""}:{op:g}),u=s.length>=wd.conditions;return t.jsxs("div",{className:"min-w-0 space-y-2",children:[t.jsxs("p",{className:"caps text-small font-semibold",children:[i," ",t.jsx("span",{className:"font-normal normal-case text-muted-foreground",children:"(optional)"})]}),s.length>0&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Each names a field of the body as a JSON pointer (/title, /issue/labels/0/name) and a test; all of them must hold."}),t.jsx(ro,{issues:a,field:`${n}.where`}),s.map((f,g)=>{const b=`${n}.where[${g}]`,x=`${e}-where-${g}`;return t.jsxs("div",{"data-condition":x,className:"space-y-3 border p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t.jsx(jt,{label:"Field",className:"min-w-40 flex-1",error:Ac(a,`${b}.pointer`),children:t.jsx(ze,{name:`${x}-pointer`,value:f.pointer,onChange:h=>c(g,{pointer:h.target.value}),placeholder:"/title",autoComplete:"off",spellCheck:!1})}),t.jsx(sd,{name:`${x}-op`,label:`Condition ${g+1}'s test`,value:f.op,onChange:h=>d(g,h),options:f6.map(h=>({value:h,label:DC[h]}))}),t.jsx(B,{type:"button",size:"icon",variant:"ghost","aria-label":`Remove condition ${g+1}`,onClick:()=>r(s.filter((h,v)=>v!==g)),children:t.jsx(Jo,{"aria-hidden":!0})})]}),f.op==="in"&&t.jsx(jt,{label:"Values",hint:k8,error:Ac(a,`${b}.in`),children:t.jsx(dn,{name:`${x}-value`,rows:3,value:f.value,onChange:h=>c(g,{value:h.target.value}),spellCheck:!1})}),f.op==="prefix"&&t.jsx(jt,{label:"Text",hint:"Its first line, trimmed, starts with this, in any case.",error:Ac(a,`${b}.prefix`),children:t.jsx(ze,{name:`${x}-value`,value:f.value,onChange:h=>c(g,{value:h.target.value}),autoComplete:"off",spellCheck:!1})}),t.jsx(ro,{issues:a,field:b}),t.jsx(ro,{issues:a,field:`${b}.exists`})]},f.key)}),t.jsxs(B,{type:"button",size:"sm",onClick:()=>r([...s,h6()]),disabled:u,children:[t.jsx(pl,{"aria-hidden":!0})," Add a condition"]})]})}function yE({name:e,rules:n,onChange:s,issues:r,indexOf:a=g=>g,room:i,eventHint:c,eventPlaceholder:d,addLabel:u="Add a rule",empty:f}){const g=(b,x)=>s(n.map((h,v)=>v===b?{...h,...x}:h));return t.jsxs("div",{className:"min-w-0 space-y-3",children:[!n.length&&f,n.map((b,x)=>{const h=`source.accept[${a(x)}]`,v=`${e}-${x}`;return t.jsxs("section",{"data-rule":v,"aria-label":`Rule ${x+1}`,className:"space-y-4 border p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("p",{className:"caps text-label text-muted-foreground",children:["Rule ",x+1]}),t.jsxs(B,{type:"button",size:"xs",variant:"ghost","aria-label":`Remove rule ${x+1}`,onClick:()=>s(n.filter((y,j)=>j!==x)),children:[t.jsx(ON,{"aria-hidden":!0})," Remove"]})]}),t.jsx(ro,{issues:r,field:h}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(jt,{label:"Event",hint:c,error:Ac(r,`${h}.event`),children:t.jsx(ze,{name:`${v}-event`,value:b.event,onChange:y=>g(x,{event:y.target.value}),placeholder:d,autoComplete:"off",spellCheck:!1})}),t.jsx(jt,{label:"Actions",optional:!0,hint:"The body's top-level action is one of these, split by commas (opened, edited). None: any action, or none.",error:Ac(r,`${h}.actions`),children:t.jsx(ze,{name:`${v}-actions`,value:b.actions,onChange:y=>g(x,{actions:y.target.value}),placeholder:"opened, edited",autoComplete:"off",spellCheck:!1})})]}),t.jsx(xy,{name:v,at:h,where:b.where,onChange:y=>g(x,{where:y}),issues:r,label:"Only when"})]},b.key)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>s([...n,FC()]),disabled:i<=0,children:[t.jsx(pl,{"aria-hidden":!0})," ",u]}),i<=0&&t.jsxs("span",{className:"text-small text-muted-foreground",children:[wd.rules," rules, the most a trigger takes."]})]})]})}const Ws=e=>`#/triggers/${encodeURIComponent(e)}`,Jf=e=>ht(e),N8={started:"success",sent:"success",skipped:"muted",missed:"warning",failed:"error",due:"active"};function S8({v2:e,view:n,go:s,agentName:r,minEvery:a,failuresToPause:i,publicUrl:c,refreshMs:d=15e3,now:u=Date.now}){const f=c===!1;return n.trigger===void 0?t.jsx($8,{v2:e,go:s,agentName:r,every:d*2,now:u,failuresToPause:i,noAddress:f}):n.trigger===null?n.kind==="webhook"?t.jsx(L8,{v2:e,go:s}):n.kind==="github"?t.jsx(I8,{v2:e,go:s}):n.kind==="composio"?t.jsx(z8,{v2:e,go:s,noAddress:f}):t.jsx(SE,{v2:e,go:s,minEvery:a,now:u}):n.edit?t.jsx(M8,{v2:e,go:s,id:n.trigger,minEvery:a,now:u},n.trigger):t.jsx(O8,{v2:e,go:s,agentName:r,id:n.trigger,every:d,now:u,failuresToPause:i},n.trigger)}function bE(e,n,s){const r=p.useRef(e);r.current=e,p.useEffect(()=>{const a=()=>document.visibilityState!=="hidden",i=setInterval(()=>{a()&&r.current()},n),c=()=>{a()&&r.current()};return document.addEventListener("visibilitychange",c),()=>{clearInterval(i),document.removeEventListener("visibilitychange",c)}},[n,...s])}const wE=e=>e?"ran"in e?`Done · ran ${Jf(e.ran.nominal_at)}`:`Its time passed · ${Jf(e.passed)}`:null,C8=/has already passed\.?$/;function jE({trigger:e}){return e.disabled?t.jsx(Ne,{tone:"warning",children:"Turned off"}):t.jsx(Ne,{tone:"muted",children:"Paused"})}const E8=e=>e.last_firing?`${nE(e.last_firing)}${e.last_firing.catch_up?" · caught up late":""} · ${Jf(e.last_firing.nominal_at)}`:"Not fired yet",vy="App triggers need this server's public address: set AGENTRUN_PUBLIC_URL and restart.";function $8({v2:e,go:n,agentName:s,every:r,now:a,failuresToPause:i,noAddress:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),[b,x]=p.useState(0),h=p.useRef(!1),v=p.useRef(!0);p.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);const y=()=>{h.current||(h.current=!0,e.listTriggers().then(j=>{v.current&&(u(j.triggers),g(null))},j=>{v.current&&g(Ut(j,"the triggers"))}).finally(()=>{h.current=!1}))};return p.useEffect(y,[e,b]),bE(y,r,[e]),t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-3",children:[t.jsx("h1",{className:"mr-auto text-2xl font-semibold",children:"Triggers"}),!(d&&!d.length)&&t.jsxs(t.Fragment,{children:[t.jsxs(B,{size:"lg",disabled:c,onClick:()=>n("#/triggers/new-composio"),children:[t.jsx(rm,{"aria-hidden":!0})," New app trigger"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-github"),children:[t.jsx(lm,{"aria-hidden":!0})," New GitHub trigger"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-webhook"),children:[t.jsx(rl,{"aria-hidden":!0})," New webhook"]}),t.jsxs(B,{size:"lg",variant:"solid",onClick:()=>n("#/triggers/new"),children:[t.jsx(pl,{"aria-hidden":!0})," New schedule"]})]})]}),c&&d&&d.length>0&&t.jsx("p",{className:"-mt-2 mb-4 text-small text-muted-foreground",children:vy}),f&&!d?t.jsx(Yt,{problem:f,onRetry:()=>x(j=>j+1),className:""}):d?d.length?t.jsx("ul",{className:"border",children:d.map(j=>t.jsxs("li",{"data-trigger":j.id,className:"grid grid-cols-1 gap-x-6 gap-y-1.5 border-b px-4 py-3 last:border-b-0 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("a",{href:Ws(j.id),className:"min-w-0 break-words text-prose font-semibold hover:underline",children:j.name}),t.jsx(Ne,{children:T8[j.source.kind]}),!j.enabled&&!cy(j,a())&&t.jsx(jE,{trigger:j})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",title:kE(j),children:R8(j,s,a())}),Gf(j,i)&&t.jsx("p",{className:"mt-1 break-words text-small text-warning-text",children:Gf(j,i)})]}),t.jsx("div",{className:"min-w-0 font-mono text-small text-muted-foreground md:text-right",children:t.jsx("p",{className:"break-words",children:E8(j)})})]},j.id))}):t.jsx(_8,{go:n,noAddress:c}):t.jsx(Fn,{label:"Loading the triggers",rows:4}),d&&f&&t.jsx(Yt,{problem:f,className:"mt-4"})]})}function _8({go:e,noAddress:n}){const s=[{Icon:om,name:"Schedule",what:"At the times you set: every day or week at a time, every few minutes or hours, or once.",action:"New schedule",to:"#/triggers/new"},{Icon:rl,name:"Webhook",what:"On each signed request another system sends to its URL.",action:"New webhook",to:"#/triggers/new-webhook"},{Icon:lm,name:"GitHub",what:"On the events you pick from this server's GitHub App. Connect GitHub in Settings first.",action:"New GitHub trigger",to:"#/triggers/new-github"},{Icon:rm,name:"From an app",what:"On an event in an app a saved Composio server connects, such as a new issue in a GitHub repository. Save the server in Settings first.",action:"New app trigger",to:"#/triggers/new-composio"}];return t.jsxs("section",{"aria-labelledby":"first-trigger",className:"border border-primary/50 bg-primary/5 p-5",children:[t.jsx("p",{className:"caps text-label text-primary-text",children:"No triggers yet"}),t.jsx("h2",{id:"first-trigger",className:"mt-2 text-xl font-semibold",children:"Start runs without being here"}),t.jsx("p",{className:"mt-1 max-w-prose text-lead text-muted-foreground",children:"A trigger starts a run of an agent for you, and each run it starts stops at a spend cap. Pick what should start it."}),t.jsx("ul",{className:"mt-5 grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4",children:s.map(({Icon:r,name:a,what:i,action:c,to:d})=>t.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[t.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[t.jsx(r,{className:"size-4 text-primary-text","aria-hidden":!0}),a]}),t.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:i}),n&&d==="#/triggers/new-composio"&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:vy}),t.jsx(B,{size:"sm",variant:d==="#/triggers/new"?"solid":"outline",className:"mt-4 self-start",disabled:n&&d==="#/triggers/new-composio",onClick:()=>e(d),children:c})]},a))})]})}const T8={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email"},kE=e=>e.source.kind==="schedule"&&"cron"in e.source?e.source.cron:void 0;function R8(e,n,s){return`${e.source.kind==="schedule"?ly(e.source,e.next_at,{instead:wE(cy(e,s)),now:s}):e.source.kind==="github"?tE(e.source):e.source.kind==="composio"?eE(e.source):e.source.kind==="email"?E6(e.source):ZC(e.source)} · ${e.target.kind==="start_run"?n(e.target.agent_id)||e.target.agent_id:`messages run ${ta(e.target.run_id)}`}`}const A8={on:"On",off:"Off",missing:"Composio no longer has it: delete this trigger and make it again.",unknown:"Composio didn't say"};function NE(){return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsx("p",{className:"mt-4 border px-4 py-6 text-body text-muted-foreground",children:"This trigger sends its firings to a run: this page doesn't open it yet."})]})}function O8({v2:e,go:n,agentName:s,id:r,every:a,now:i,failuresToPause:c}){var Re,Ze,at,pt;const[d,u]=p.useState(null),[f,g]=p.useState([]),[b,x]=p.useState(null),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),[_,$]=p.useState(null),O=p.useRef(!1),[A,L]=p.useState(!1),[M,R]=p.useState(null),[P,D]=p.useState(null),[W,Y]=p.useState(null),[H,q]=p.useState(0),F=p.useRef(!1),G=p.useRef(!1),U=p.useRef(0),z=()=>{G.current=!0;const Ee=U.current;return Promise.all([e.getTrigger(r),e.triggerFirings(r)]).then(([Je,he])=>{Ee===U.current&&(u(Je),g(he.firings),x(null))}).finally(()=>{G.current=!1})};p.useEffect(()=>{z().catch(Ee=>x(Ut(Ee,"the trigger")))},[e,r,H]),bE(()=>{!G.current&&!F.current&&W===null&&z().catch(()=>{})},a,[e,r]);const[Q,K]=p.useState(void 0),Z=d&&d.target.kind==="start_run"&&typeof d.target.max_cost_usd!="number"?d.target.agent_id:null;p.useEffect(()=>{if(!Z)return;let Ee=!0;return e.getAgent(Z).then(Je=>{Ee&&K(typeof Je.agent.definition.max_cost_usd=="number"?Je.agent.definition.max_cost_usd:void 0)},()=>{}),()=>{Ee=!1}},[e,Z]);const de=(d==null?void 0:d.source.kind)==="composio"?d.source.server:null;if(p.useEffect(()=>{if(!de)return;let Ee=!0;return e.composioTriggers(de).then(Je=>{var he;Ee&&R(((he=Je.triggers.find(Fe=>Fe.id===r))==null?void 0:he.on_composio)??"unknown")},()=>{Ee&&R(null)}),()=>{Ee=!1}},[e,de,r,d==null?void 0:d.enabled]),W!==null)return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsx("h1",{className:"mt-3 break-words text-2xl font-semibold leading-tight",children:(d==null?void 0:d.name)??r}),t.jsx("p",{className:"mt-2 text-body",children:"Deleted here. Its runs stay."}),t.jsx("p",{role:"status","data-composio-note":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:W}),t.jsx("a",{href:"#/triggers",className:"mt-4 inline-block text-body underline underline-offset-2",children:"All triggers"})]});if(!d)return b?t.jsx(Yt,{problem:b,onRetry:()=>q(Ee=>Ee+1),link:{href:"#/triggers",label:"All triggers"}}):t.jsx(Fn,{label:"Loading the trigger",rows:4});const se=uy(d)?d:null,ue=XC(d)?d:null,xe=my(d)?d:null;if(!se&&!ue&&!xe&&!dy(d))return t.jsx(NE,{});const $e=d,ge=cy(d,i(),f),fe=async(Ee,Je,he)=>{j(Ee),v(null);try{await Je()}catch(Fe){v(Ut(Fe,he))}finally{j(null)}},me=()=>fe("pause",async()=>{U.current++,D(null);const{composio:Ee,...Je}=await e.updateTrigger(r,{enabled:!d.enabled});U.current++,u(Je),D((Ee==null?void 0:Ee.note)??null)},d.enabled?"the pause":"the resume"),je=()=>fe("delete",async()=>{const Ee=await e.deleteTrigger(r);Ee!=null&&Ee.composio?Y(Ee.composio.note):n("#/triggers")},"the delete"),Me=async()=>{if(!O.current){O.current=!0,L(!0),v(null),$(null);try{$((await e.rotateTriggerSecret(r)).signing_secret??null)}catch(Ee){v(Ut(Ee,"the new secret"))}finally{O.current=!1,L(!1)}}},_e=async()=>{if(!F.current){F.current=!0,j("fire"),v(null),U.current++;try{const Ee=await e.fireTrigger(r,bd());U.current++,g(Je=>[Ee,...Je.filter(he=>he.key!==Ee.key)]),await z().catch(()=>{})}catch(Ee){v(Ut(Ee,"the run now"))}finally{F.current=!1,j(null)}}},re=typeof $e.target.input.content=="string"?$e.target.input.content:null;return t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),t.jsxs("div",{className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 sm:flex-row",children:[t.jsxs("div",{className:"min-w-0 flex-1 self-stretch",children:[t.jsxs("h1",{className:"flex flex-wrap items-center gap-2 break-words text-2xl font-semibold leading-tight",children:[d.name,!d.enabled&&!ge&&t.jsx(jE,{trigger:d})]}),t.jsx("p",{className:"mt-2 break-words font-mono text-small text-muted-foreground",children:se?`Webhook · ${ZC(se.source)}`:ue?`GitHub · ${tE(ue.source)}`:xe?`App · ${eE(xe.source)}`:t.jsx("span",{title:kE(d),children:ly($e.source,d.next_at,{instead:wE(ge),now:i()})})})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 self-stretch sm:self-auto",children:[!(ge&&"ran"in ge)&&t.jsx(B,{size:"sm",onClick:()=>void me(),disabled:y!==null,children:d.enabled?t.jsxs(t.Fragment,{children:[t.jsx(sl,{"aria-hidden":!0})," Pause"]}):t.jsxs(t.Fragment,{children:[t.jsx(Yo,{"aria-hidden":!0})," Resume"]})}),t.jsxs(B,{size:"sm",onClick:()=>n(`${Ws(r)}/edit`),children:[t.jsx(Hx,{"aria-hidden":!0})," ",se||ue||xe?"Edit filter":"Edit"]}),se&&(S?t.jsxs("span",{className:"flex items-center gap-2 border border-warning/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Make a new secret?",children:[t.jsx("span",{children:"The old secret stops signing at once."}),t.jsx(B,{size:"sm",variant:"solid",onClick:()=>{N(!1),Me()},children:"Yes, make a new one"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>N(!1),children:"Keep"})]}):t.jsxs(B,{size:"sm",onClick:()=>N(!0),disabled:y!==null||A,children:[t.jsx(Pa,{"aria-hidden":!0})," Rotate secret"]})),k?t.jsxs("span",{className:"flex items-center gap-2 border border-destructive/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Delete this trigger?",children:[t.jsx("span",{children:"Delete for good? Its runs stay."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>{E(!1),je()},children:"Yes, delete"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>E(!1),children:"Keep"})]}):t.jsxs(B,{size:"sm",variant:"destructive",onClick:()=>E(!0),disabled:y!==null,children:[t.jsx(ON,{"aria-hidden":!0})," Delete"]}),t.jsxs(B,{size:"sm",variant:"solid",onClick:()=>void _e(),disabled:y==="fire",children:[t.jsx(UT,{"aria-hidden":!0})," ",y==="fire"?"Starting":"Run now"]})]})]}),Gf(d,c)&&t.jsxs("p",{role:"status","data-disabled":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:[Gf(d,c)," ",((Re=d.disabled)==null?void 0:Re.reason)==="source_unreadable"?"Edit its when, then Resume.":((Ze=d.disabled)==null?void 0:Ze.reason)==="auto_paused"?ge&&"passed"in ge?"Its time has passed: edit its time first, then Resume.":ge?"":"Resume turns it on again.":""]}),h&&t.jsx(Yt,{problem:h,className:"mt-4"}),P&&t.jsx("p",{role:"status","data-composio-note":!0,className:"mt-4 border border-warning/50 bg-warning/10 px-3 py-2 text-body text-warning-text",children:P}),se&&_&&t.jsx(yy,{label:"The webhook's new secret",secret:_}),t.jsxs("dl",{className:"mt-5 grid grid-cols-1 gap-x-6 gap-y-3 border p-4 text-body sm:grid-cols-[max-content_minmax(0,1fr)]",children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Agent"}),t.jsx("dd",{className:"min-w-0 break-words",children:t.jsx("a",{href:ln($e.target.agent_id),className:"hover:underline",children:s($e.target.agent_id)||$e.target.agent_id})}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Each run is asked"}),t.jsx("dd",{className:"min-w-0 whitespace-pre-wrap break-words",children:re??JSON.stringify($e.target.input)}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Cost cap"}),t.jsx("dd",{className:"font-mono",children:S6($e.target.max_cost_usd,Q)}),se?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"URL"}),t.jsxs("dd",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("code",{className:"min-w-0 break-all font-mono text-small",children:Kc(se)}),t.jsx(CE,{text:Kc(se),label:"Copy URL"}),t.jsx("span",{className:"basis-full text-small text-muted-foreground",children:fy})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("dd",{children:bx[se.source.signature??"standard"]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(at=se.source.accept)!=null&&at.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:se.source.accept.map((Ee,Je)=>t.jsx("li",{children:Zi(Ee)},Je))}):"Every signed request"})]}):xe?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"App"}),t.jsxs("dd",{className:"min-w-0 break-words",children:[t.jsx("a",{href:"#/settings/mcp",className:"font-mono hover:underline",children:xe.source.server}),t.jsx("span",{className:"text-small text-muted-foreground",children:" · a saved Composio server"})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Event"}),t.jsx("dd",{className:"min-w-0 break-words font-mono",children:xe.source.event}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Config"}),t.jsx("dd",{className:"min-w-0 break-words",children:Object.keys(xe.source.config).length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:Object.entries(xe.source.config).map(([Ee,Je])=>t.jsxs("li",{children:[Ee,": ",typeof Je=="string"?Je:JSON.stringify(Je)]},Ee))}):"None"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(pt=xe.source.accept)!=null&&pt.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:xe.source.accept.map((Ee,Je)=>t.jsx("li",{children:Zi(Ee)},Je))}):"Every event of its instance"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"At Composio"}),t.jsx("dd",{className:"min-w-0 break-words",children:M?t.jsx("span",{"data-on-composio":M,className:M==="missing"?"text-warning-text":void 0,children:A8[M]}):t.jsx("span",{className:"text-muted-foreground",children:"Not read"})})]}):ue?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsxs("dd",{className:"min-w-0 break-words",children:[t.jsx("ul",{className:"space-y-1 font-mono text-small",children:ue.source.accept.map((Ee,Je)=>t.jsx("li",{children:Zi(Ee)},Je))}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"From this server's GitHub App (Settings → GitHub)."})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"While a run is going"}),t.jsx("dd",{children:"The next time is skipped."})]})]}),t.jsxs("section",{className:"mt-6","aria-label":"Firings",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Firings"}),f.length?t.jsx("ul",{className:"mt-3 border",children:f.map(Ee=>t.jsxs("li",{"data-firing":Ee.key,className:"flex flex-col gap-1 border-b px-4 py-2.5 text-body last:border-b-0 sm:flex-row sm:items-start sm:gap-4",children:[t.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Ne,{tone:N8[Ee.status],children:$6[Ee.status]}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:Jf(Ee.nominal_at)})]}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:Ee.status==="started"?`${C6[Ee.by]}${Ee.catch_up?", caught up late":""}`:`${nE(Ee)}${Ee.catch_up?" · caught up late":""}${Ee.by==="manual"?" · Run now":""}`}),Ee.run_id&&t.jsxs("a",{href:`#/runs/${encodeURIComponent(Ee.run_id)}`,className:"shrink-0 font-mono text-small underline-offset-2 hover:underline",children:["Run ",ta(Ee.run_id)]})]},Ee.key))}):t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:"Not fired yet."})]})]})}function M8({v2:e,go:n,id:s,minEvery:r,now:a}){const[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(0);return p.useEffect(()=>{e.getTrigger(s).then(c,b=>u(Ut(b,"the trigger")))},[e,s,f]),i?uy(i)||XC(i)||my(i)?t.jsx(U8,{v2:e,go:n,trigger:i}):dy(i)?t.jsx(SE,{v2:e,go:n,trigger:i,minEvery:r,now:a}):t.jsx(NE,{}):d?t.jsx(Yt,{problem:d,onRetry:()=>g(b=>b+1)}):t.jsx(Fn,{label:"Loading the trigger",rows:4})}function Zt({label:e,field:n,issue:s,hint:r,children:a}){return t.jsx(jt,{className:"min-w-0",label:e,hint:r,error:s?t.jsx("span",{"data-issue":n,children:s}):void 0,children:a})}const th=e=>e!==void 0?`${ei(e)}, the agent's default`:void 0;async function nh(e){const n=[];let s=null;for(let r=0;r<20;r++){const a=await e.listAgents({cursor:s});if(n.push(...a.agents),s=a.next_cursor,!s)break}return n}function SE({v2:e,go:n,trigger:s,minEvery:r,now:a=Date.now}){var D,W,Y;const[i,c]=p.useState(()=>s?H6(s):KC()),[d,u]=p.useState(null),[f,g]=p.useState({}),[b,x]=p.useState([]),[h,v]=p.useState(!1),y=p.useRef(dr()).current;p.useEffect(()=>{nh(e).then(u,()=>u([]))},[e]);const j=H=>q=>c(F=>({...F,[H]:q})),k=H=>{var F;j("at")(H);const q=Wi(H,(F=i.read)==null?void 0:F.at);q!==null&&Date.parse(q)>a()?g(({"source.at":G,...U})=>U):q!==null&&g(G=>G["source.at"]?{...G,"source.at":b0(q,{now:a()})}:G)},E=new Set(["name","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd",...s?[]:["enabled"]]),S=(D=(d??[]).find(H=>H.agent_id===i.agentId))==null?void 0:D.definition.max_cost_usd,N=typeof S=="number"&&S>0?S:void 0,_=N!==void 0||!!s&&typeof s.target.max_cost_usd!="number"&&i.agentId===s.target.agent_id,$=async H=>{var G;H.preventDefault();const{body:q,issues:F}=j0(i,_);if(x([]),!q){g(F??{});return}g({}),v(!0);try{if(s){const U=k0(s,q);Object.keys(U).length&&await e.updateTrigger(s.id,U),n(Ws(s.id))}else{const U=await e.createTrigger(q,y.keyFor("createTrigger",q));n(Ws(U.id))}}catch(U){const z=jd(U),Q=i.kind==="at"?Wi(i.at,(G=i.read)==null?void 0:G.at):null,K=z.fields["source.at"];K&&Q!==null&&(Date.parse(Q)<=a()||C8.test(K))&&(z.fields["source.at"]=b0(Q,{now:a()})),g(Object.fromEntries(Object.entries(z.fields).filter(([Z])=>E.has(Z)))),x([...z.rest,...Object.entries(z.fields).filter(([Z])=>!E.has(Z)).map(([,Z])=>Z)]),v(!1)}},O=s?j0(i,_).body:void 0,A=!!(s&&O&&k0(s,O).source),L=i.kind==="at"?Wi(i.at,(W=i.read)==null?void 0:W.at):null,M=i.startAt?Wi(i.startAt,(Y=i.read)==null?void 0:Y.startAt):null,R=id((d??[]).filter(H=>!H.archived_at||H.agent_id===i.agentId)),P=[{kind:"cron",label:"Repeats"},{kind:"at",label:"Once"},{kind:"every",label:"Every"}];return t.jsxs("form",{onSubmit:H=>void $(H),className:"p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?Ws(s.id):"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," ",s?s.name:"Triggers"]}),t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(om,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit schedule":"New schedule"]}),b.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:b.map((H,q)=>t.jsx("p",{children:H},q))}),t.jsxs("div",{className:`mt-5 ${$m}`,children:[t.jsx(Zt,{label:"Name",field:"name",issue:f.name,children:t.jsx(ze,{name:"name",value:i.name,onChange:H=>j("name")(H.target.value),placeholder:"nightly triage"})}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"When"}),t.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:P.map(({kind:H,label:q})=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${i.kind===H?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"kind",value:H,checked:i.kind===H,onChange:()=>j("kind")(H),className:"accent-primary"}),q]},H))}),t.jsxs("div",{className:"mt-3 grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-4",children:[i.kind==="cron"&&t.jsx(Zt,{label:"Runs",field:"source.cron",issue:f["source.cron"],children:t.jsx(iE,{label:"Runs",name:"cron",value:i.cron,onChange:j("cron")})}),i.kind==="at"&&t.jsx(Zt,{label:"At, your time",field:"source.at",issue:f["source.at"],hint:L?`= ${w0(L)}`:void 0,children:t.jsx(ze,{name:"at",type:"datetime-local",step:60,value:i.at,onChange:H=>k(H.target.value)})}),i.kind==="every"&&t.jsx(Zt,{label:"Every",field:"source.every_s",issue:f["source.every_s"],hint:r?R6(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(ze,{name:"every",inputMode:"decimal",value:i.every,onChange:H=>j("every")(H.target.value),placeholder:"5"}),t.jsx(Rt,{id:"schedule-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:i.everyUnit,onChange:H=>j("everyUnit")(H),options:["seconds","minutes","hours"].map(H=>({value:H,label:H}))})]})}),i.kind==="cron"&&t.jsx(Zt,{label:"Time zone",field:"source.timezone",issue:f["source.timezone"],hint:"The time zone this schedule runs in.",children:t.jsx(lE,{name:"timezone",label:"Time zone",className:"w-full",value:i.timezone,onChange:j("timezone")})}),i.kind==="every"&&t.jsx(Zt,{label:"Starting, your time (optional)",field:"source.start_at",issue:f["source.start_at"],hint:M?`= ${w0(M)}`:void 0,children:t.jsx(ze,{name:"startAt",type:"datetime-local",step:60,value:i.startAt,onChange:H=>j("startAt")(H.target.value)})})]}),A&&t.jsx("p",{className:"mt-3 text-small text-warning-text",role:"note",children:"Changing when restarts the schedule from now."})]}),t.jsx(Zt,{label:"Agent",field:"target.agent_id",issue:f["target.agent_id"],children:t.jsx(Rt,{name:"agent",label:"Agent",className:"w-full",value:i.agentId,onChange:H=>j("agentId")(H),options:[{value:"",label:d?"Pick an agent":"Loading the agents"},...R.map(H=>({value:H.agent_id,label:`${H.definition.name||H.agent_id}${H.kind==="workflow"?" (workflow)":""}`})),...i.agentId&&d&&!R.some(H=>H.agent_id===i.agentId)?[{value:i.agentId,label:i.agentId}]:[]]})}),t.jsx(Zt,{label:"Each run is asked",field:"target.input",issue:f["target.input"],children:t.jsx(dn,{name:"content",rows:4,className:"p-3 font-sans",value:i.content,onChange:H=>j("content")(H.target.value)})}),t.jsx(Zt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:f["target.max_cost_usd"],hint:N!==void 0?`Uses the agent's default (${ei(N)}) if empty.`:_?"Uses the agent's default if empty.":"Required: each run this schedule starts stops at this spend.",children:t.jsx(ze,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:i.maxCost,onChange:H=>j("maxCost")(H.target.value),placeholder:th(N)})}),!s&&t.jsxs("div",{children:[t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"enabled",checked:i.enabled,onChange:H=>j("enabled")(H.target.checked),className:"accent-primary"})," On from now (off: made paused)"]}),f.enabled&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"enabled",children:f.enabled})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:h,children:h?"Saving":s?"Save changes":"Create schedule"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(s?Ws(s.id):"#/triggers"),children:"Cancel"})]})]})}function CE({text:e,label:n}){const[s,r]=p.useState(null),a="The browser won't copy here. Select it and copy it.",i=()=>{const c=typeof navigator<"u"?navigator.clipboard:void 0;if(!(c!=null&&c.writeText)){r(a);return}c.writeText(e).then(()=>r("Copied"),()=>r(a))};return t.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[t.jsxs(B,{type:"button",size:"sm",onClick:i,children:[t.jsx(qa,{"aria-hidden":!0})," ",n]}),s&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:s})]})}function yy({label:e,secret:n,url:s}){return t.jsxs("section",{"aria-label":e,className:"mt-4 space-y-3 border border-primary/50 p-4 text-body",children:[s&&t.jsx(Nx,{title:"URL",text:s,label:"Copy URL",hint:fy}),t.jsx(Nx,{title:"Signing secret",text:n,label:"Copy secret"}),t.jsx("p",{className:"text-warning-text",role:"note",children:"You won't see this secret again."})]})}function Nx({title:e,text:n,label:s,hint:r}){return t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"caps text-label text-muted-foreground",children:e}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("code",{className:"min-w-0 break-all border bg-muted/40 px-2 py-1 font-mono text-small",children:n}),t.jsx(CE,{text:n,label:s})]}),r&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:r})]})}const P8=["standard","github"];function L8({v2:e,go:n}){var _;const[s,r]=p.useState(A6),[a,i]=p.useState(null),[c,d]=p.useState({}),[u,f]=p.useState([]),[g,b]=p.useState(!1),[x,h]=p.useState(null),v=p.useRef(dr()).current;p.useEffect(()=>{nh(e).then(i,()=>i([]))},[e]);const y=$=>O=>r(A=>({...A,[$]:O})),j=(_=(a??[]).find($=>$.agent_id===s.agentId))==null?void 0:_.definition.max_cost_usd,k=typeof j=="number"&&j>0?j:void 0,E=async $=>{$.preventDefault();const O=new Set(["name","source.signature","target.agent_id","target.input","target.max_cost_usd",...Ym(s.accept.map(M=>M.where.length))]),{body:A,issues:L}=O6(s,k!==void 0);if(f([]),!A){d(L??{});return}d({}),b(!0);try{h(await e.createTrigger(A,v.keyFor("createTrigger",A)))}catch(M){const R=jd(M);d(Object.fromEntries(Object.entries(R.fields).filter(([P])=>O.has(P)))),f([...R.rest,...Object.entries(R.fields).filter(([P])=>!O.has(P)).map(([,P])=>P)])}finally{b(!1)}},S=t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]});if(x)return t.jsxs("div",{className:"p-5 md:p-8",children:[S,t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(rl,{className:"size-5 text-primary-text","aria-hidden":!0}),x.name]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:`Send each request to this URL, signed with this secret (${bx[x.source.kind==="webhook"?x.source.signature??"standard":"standard"]}). Each one starts a run.`}),x.signing_secret?t.jsx(yy,{label:"The webhook's URL and secret",url:Kc(x),secret:x.signing_secret}):t.jsxs("section",{"aria-label":"The webhook's URL and secret",className:"mt-4 space-y-3 border p-4 text-body",children:[t.jsx(Nx,{title:"URL",text:Kc(x),label:"Copy URL",hint:fy}),x.note&&t.jsx("p",{role:"note",children:x.note})]}),t.jsx("div",{className:"mt-6",children:t.jsx(B,{type:"button",size:"lg",variant:"solid",onClick:()=>n(Ws(x.id)),children:"Done"})})]});const N=id((a??[]).filter($=>!$.archived_at));return t.jsxs("form",{onSubmit:$=>void E($),className:"p-5 md:p-8",noValidate:!0,children:[S,t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(rl,{className:"size-5 text-primary-text","aria-hidden":!0}),"New webhook"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each signed request to its URL starts a capped run of the agent. Its URL and signing secret show once it is made."}),u.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:u.map(($,O)=>t.jsx("p",{children:$},O))}),t.jsxs("div",{className:`mt-5 ${$m}`,children:[t.jsx(Zt,{label:"Name",field:"name",issue:c.name,children:t.jsx(ze,{name:"name",value:s.name,onChange:$=>y("name")($.target.value),placeholder:"on deploy"})}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("div",{className:"mt-1 flex flex-wrap gap-2",role:"radiogroup",children:P8.map($=>t.jsxs("label",{className:`flex h-9 cursor-pointer items-center gap-2 border px-3 text-body ${s.signature===$?"border-primary text-primary-text":""}`,children:[t.jsx("input",{type:"radio",name:"signature",value:$,checked:s.signature===$,onChange:()=>y("signature")($),className:"accent-primary"}),bx[$]]},$))}),c["source.signature"]&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.signature",children:c["source.signature"]})]}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Events from an app Composio connects start runs through an app trigger instead: ",t.jsx("a",{href:"#/triggers/new-composio",className:"underline underline-offset-2",children:"New app trigger"})]}),t.jsx(EE,{signature:s.signature,rules:s.accept,onChange:y("accept"),issues:c,cap:null}),t.jsx(Zt,{label:"Agent",field:"target.agent_id",issue:c["target.agent_id"],children:t.jsx(Rt,{name:"agent",label:"Agent",className:"w-full",value:s.agentId,onChange:$=>y("agentId")($),options:[{value:"",label:a?"Pick an agent":"Loading the agents"},...N.map($=>({value:$.agent_id,label:`${$.definition.name||$.agent_id}${$.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Zt,{label:"Each run is asked",field:"target.input",issue:c["target.input"],children:t.jsx(dn,{name:"content",rows:4,className:"p-3 font-sans",value:s.content,onChange:$=>y("content")($.target.value)})}),t.jsx(Zt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:c["target.max_cost_usd"],hint:k!==void 0?`Uses the agent's default (${ei(k)}) if empty.`:"Required: each run this webhook starts stops at this spend.",children:t.jsx(ze,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:s.maxCost,onChange:$=>y("maxCost")($.target.value),placeholder:th(k)})})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:g,children:g?"Creating":"Create webhook"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function I8({v2:e,go:n}){var R;const[s,r]=p.useState(null),[a,i]=p.useState(null),[c,d]=p.useState(0),[u,f]=p.useState(M6),[g,b]=p.useState(null),[x,h]=p.useState({}),[v,y]=p.useState([]),[j,k]=p.useState(!1),E=p.useRef(dr()).current,S=p.useRef(!0);p.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]),p.useEffect(()=>{let P=!0;return i(null),e.githubConnection().then(D=>{P&&r(!!D&&"app_id"in D&&!!D.app_id)},D=>{P&&(D instanceof De&&D.status===404?r(!1):i(Ut(D,"GitHub's connection")))}),()=>{P=!1}},[e,c]),p.useEffect(()=>{nh(e).then(b,()=>b([]))},[e]);const N=P=>D=>f(W=>({...W,[P]:D})),_=(R=(g??[]).find(P=>P.agent_id===u.agentId))==null?void 0:R.definition.max_cost_usd,$=typeof _=="number"&&_>0?_:void 0,O=async P=>{P.preventDefault();const D=new Set(["name","target.agent_id","target.input","target.max_cost_usd",...Ym(Jm(u).map(H=>H.where.length))]),{body:W,issues:Y}=W6(u,$!==void 0);if(y([]),!W){h(Y??{});return}h({}),k(!0);try{const H=await e.createTrigger(W,E.keyFor("createTrigger",W));S.current&&n(Ws(H.id))}catch(H){const q=jd(H);h(Object.fromEntries(Object.entries(q.fields).filter(([F])=>D.has(F)))),y([...q.rest,...Object.entries(q.fields).filter(([F])=>!D.has(F)).map(([,F])=>F)]),k(!1)}},A=t.jsxs("a",{href:"#/triggers",className:"caps -my-1 inline-flex items-center gap-2 py-1 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),L=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(lm,{className:"size-5 text-primary-text","aria-hidden":!0}),"New GitHub trigger"]});if(a)return t.jsxs("div",{className:"p-5 md:p-8",children:[A,L,t.jsx(Yt,{problem:a,onRetry:()=>d(P=>P+1),className:"mt-4"})]});if(s===null)return t.jsx(Fn,{label:"Reading GitHub's connection",rows:3});if(!s)return t.jsxs("div",{className:"p-5 md:p-8",children:[A,L,t.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Connect GitHub first: ",t.jsx("a",{href:"#/settings/github",className:"underline underline-offset-2",children:"Settings → GitHub"}),". A GitHub trigger takes events from this server's GitHub App."]})]});const M=id((g??[]).filter(P=>!P.archived_at));return t.jsxs("form",{onSubmit:P=>void O(P),className:"p-5 md:p-8",noValidate:!0,children:[A,L,t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each event it takes from this server's GitHub App starts a capped run of the agent."}),v.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:v.map((P,D)=>t.jsx("p",{children:P},D))}),t.jsxs("div",{className:`mt-5 ${$m}`,children:[t.jsx(Zt,{label:"Name",field:"name",issue:x.name,children:t.jsx(ze,{name:"name",value:u.name,onChange:P=>N("name")(P.target.value),placeholder:"review PRs"})}),t.jsx($E,{picks:u,onChange:P=>f(D=>({...D,...P})),issues:x}),t.jsx(Zt,{label:"Agent",field:"target.agent_id",issue:x["target.agent_id"],children:t.jsx(Rt,{name:"agent",label:"Agent",className:"w-full",value:u.agentId,onChange:P=>N("agentId")(P),options:[{value:"",label:g?"Pick an agent":"Loading the agents"},...M.map(P=>({value:P.agent_id,label:`${P.definition.name||P.agent_id}${P.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Zt,{label:"Each run is asked",field:"target.input",issue:x["target.input"],hint:"The event's payload comes with it.",children:t.jsx(dn,{name:"content",rows:4,className:"p-3 font-sans",value:u.content,onChange:P=>N("content")(P.target.value)})}),t.jsx(Zt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:x["target.max_cost_usd"],hint:$!==void 0?`Uses the agent's default (${ei($)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(ze,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:u.maxCost,onChange:P=>N("maxCost")(P.target.value),placeholder:th($)})})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:j,children:j?"Creating":"Create GitHub trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function z8({v2:e,go:n,noAddress:s}){var ge;const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(0),[f,g]=p.useState(null),[b,x]=p.useState(null),[h,v]=p.useState(0),[y,j]=p.useState(D6),[k,E]=p.useState(null),[S,N]=p.useState({}),[_,$]=p.useState([]),[O,A]=p.useState(null),[L,M]=p.useState(null),[R,P]=p.useState(!1),D=p.useRef(dr()).current,W=p.useRef(!0);p.useEffect(()=>(W.current=!0,()=>{W.current=!1}),[]),p.useEffect(()=>{let fe=!0;return c(null),e.listMcpServers().then(me=>{if(!fe)return;const je=me.servers.filter(Me=>Me.source==="composio");a(je),je.length===1&&j(Me=>Me.server?Me:{...Me,server:je[0].name})},me=>{fe&&c(Ut(me,"the saved MCP servers"))}),()=>{fe=!1}},[e,d]),p.useEffect(()=>{if(!y.server)return;let fe=!0;const me=y.server;return g(null),x(null),e.composioEvents(me).then(je=>{fe&&g({server:me,events:je.events})},je=>{fe&&x(Ut(je,`${me}'s events`))}),()=>{fe=!1}},[e,y.server,h]),p.useEffect(()=>{nh(e).then(E,()=>E([]))},[e]);const Y=fe=>{M(null),j(fe)},H=fe=>me=>Y(je=>({...je,[fe]:me})),q=fe=>Y(me=>me.server===fe?me:{...me,server:fe,event:"",config:{},where:[]}),F=fe=>{Y(me=>me.event===fe?me:{...me,event:fe,config:{},where:[]}),N({})},G=(f==null?void 0:f.server)===y.server?f.events.find(fe=>fe.slug===y.event):void 0,U=I6(G==null?void 0:G.config),z=(ge=(k??[]).find(fe=>fe.agent_id===y.agentId))==null?void 0:ge.definition.max_cost_usd,Q=typeof z=="number"&&z>0?z:void 0,K=async fe=>{var je,Me;const me=new Set(["name","source.server","source.event","source.config",...U.map(_e=>`source.config.${_e.name}`),"target.agent_id","target.input","target.max_cost_usd",...y.where.length?Ym([y.where.length]):[]]);N({}),$([]),A(null),M(null),P(!0);try{const _e=await e.createTrigger(fe,D.keyFor("createTrigger",fe));W.current&&n(Ws(_e.id));return}catch(_e){if(_e instanceof De&&_e.code==="composio_subscription_elsewhere")M({url:typeof((je=_e.details)==null?void 0:je.webhook_url)=="string"?_e.details.webhook_url:"another address",body:fe});else if(_e instanceof De&&_e.code.startsWith("composio_"))$([_e.message]),_e.code==="composio_not_connected"&&A(so(typeof((Me=_e.details)==null?void 0:Me.connect_url)=="string"?_e.details.connect_url:null)??null);else{const re=jd(_e);N(Object.fromEntries(Object.entries(re.fields).filter(([Re])=>me.has(Re)))),$([...re.rest,...Object.entries(re.fields).filter(([Re])=>!me.has(Re)).map(([,Re])=>Re)])}}P(!1)},Z=()=>U6(y,U,Q!==void 0),de=fe=>{fe.preventDefault();const{body:me,issues:je}=Z();if($([]),A(null),!me){N(je??{});return}K(me)},se=()=>{const fe=L;M(null),fe&&K({...fe.body,source:{...fe.body.source,move_subscription:!0}})},ue=t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),xe=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(rm,{className:"size-5 text-primary-text","aria-hidden":!0}),"New app trigger"]});if(i)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[ue,xe,t.jsx(Yt,{problem:i,onRetry:()=>u(fe=>fe+1),className:"mt-4"})]});if(r===null)return t.jsx(Fn,{label:"Reading the saved Composio servers",rows:3});if(!r.length)return t.jsxs("div",{className:"max-w-2xl p-5 md:p-8",children:[ue,xe,t.jsxs("p",{className:"mt-4 border px-4 py-6 text-body",children:["Save a Composio server first: ",t.jsx("a",{href:"#/settings/mcp",className:"underline underline-offset-2",children:"Settings → MCP servers"}),", Add from Composio. A trigger from an app uses its key and the account it is connected as."]})]});const $e=id((k??[]).filter(fe=>!fe.archived_at));return t.jsxs("form",{onSubmit:de,className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[ue,xe,t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:"Each event Composio delivers for it starts a capped run of the agent. This server makes the trigger on Composio for the account the server is connected as."}),s&&t.jsx("p",{className:"mt-4 border border-warning/50 p-3 text-body",role:"status",children:vy}),_.length>0&&t.jsxs("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:[_.map((fe,me)=>t.jsx("p",{className:"break-words",children:fe},me)),O&&t.jsx("a",{href:O,target:"_blank",rel:"noreferrer",className:"mt-2 inline-block underline underline-offset-2",children:"Connect the account"})]}),t.jsxs("div",{className:"mt-5 space-y-5",children:[t.jsx(Zt,{label:"Name",field:"name",issue:S.name,children:t.jsx(ze,{name:"name",value:y.name,onChange:fe=>H("name")(fe.target.value),placeholder:"new issues"})}),t.jsx(Zt,{label:"Composio server",field:"source.server",issue:S["source.server"],children:t.jsx(Rt,{name:"server",label:"Composio server",className:"w-full",value:y.server,onChange:q,options:[{value:"",label:"Pick a server"},...r.map(fe=>({value:fe.name,label:fe.toolkit?`${fe.name} (${fe.toolkit})`:fe.name}))]})}),y.server&&(b?t.jsx(Yt,{problem:b,onRetry:()=>v(fe=>fe+1),className:""}):t.jsx(Zt,{label:"Event",field:"source.event",issue:S["source.event"],hint:G==null?void 0:G.description,children:t.jsx(Rt,{name:"event",label:"Event",className:"w-full",value:y.event,onChange:F,disabled:!f,options:[{value:"",label:f?f.events.length?"Pick an event":"Composio offers no event for this toolkit":"Loading the events"},...((f==null?void 0:f.events)??[]).map(fe=>({value:fe.slug,label:fe.name||fe.slug}))]})})),G&&t.jsxs(t.Fragment,{children:[G.polled&&t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:"Composio checks for it every few minutes, so a run starts some minutes after the event."}),G.instructions&&t.jsx("p",{className:"whitespace-pre-wrap text-small text-muted-foreground",children:G.instructions}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Config"}),t.jsxs("p",{className:"mb-2 mt-1 text-small text-muted-foreground",children:["What Composio watches for ",t.jsx("span",{className:"font-mono",children:G.slug}),"."]}),t.jsx(ro,{issues:S,field:"source.config"}),U.length?t.jsx("div",{className:"space-y-4",children:U.map(fe=>t.jsx(D8,{field:fe,value:y.config[fe.name]??fe.initial,issue:S[`source.config.${fe.name}`],onChange:me=>Y(je=>({...je,config:{...je.config,[fe.name]:me}}))},`${G.slug}:${fe.name}`))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"This event takes no config."})]}),t.jsx(_E,{where:y.where,onChange:H("where"),issues:S})]}),t.jsx(Zt,{label:"Agent",field:"target.agent_id",issue:S["target.agent_id"],children:t.jsx(Rt,{name:"agent",label:"Agent",className:"w-full",value:y.agentId,onChange:fe=>H("agentId")(fe),options:[{value:"",label:k?"Pick an agent":"Loading the agents"},...$e.map(fe=>({value:fe.agent_id,label:`${fe.definition.name||fe.agent_id}${fe.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Zt,{label:"Each run is asked",field:"target.input",issue:S["target.input"],hint:"What Composio delivered comes with it.",children:t.jsx(dn,{name:"content",rows:4,className:"p-3 font-sans",value:y.content,onChange:fe=>H("content")(fe.target.value)})}),t.jsx(Zt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:S["target.max_cost_usd"],hint:Q!==void 0?`Uses the agent's default (${ei(Q)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(ze,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:y.maxCost,onChange:fe=>H("maxCost")(fe.target.value),placeholder:th(Q)})})]}),L&&t.jsxs("div",{role:"alertdialog","aria-label":"Move the subscription here?",className:"mt-6 space-y-3 border border-warning/50 p-4 text-body",children:[t.jsxs("p",{children:["Composio sends this project's events to ",t.jsx("code",{className:"break-all font-mono text-small",children:L.url})," now. Moving them here stops them arriving there: anything listening at ",t.jsx("code",{className:"break-all font-mono text-small",children:L.url})," (another AgentRun server, or a tool of yours) gets no more events."]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"solid",onClick:se,children:"Move it here"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>M(null),children:"Keep it there"})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:R||!!L||s,children:R?"Creating":"Create app trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function D8({field:e,value:n,issue:s,onChange:r}){const a=`config-${e.name}`,i=s?t.jsx("span",{"data-issue":`source.config.${e.name}`,children:s}):void 0;return e.type==="boolean"?t.jsxs("div",{"data-config-field":e.name,children:[t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:a,checked:n==="true",onChange:c=>r(c.target.checked?"true":"false"),className:"accent-primary"})," ",e.title]}),e.description&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:e.description}),s&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert",children:i})]}):t.jsx("div",{"data-config-field":e.name,children:t.jsx(jt,{className:"min-w-0",label:e.title,required:e.required,optional:!e.required,hint:e.description,error:i,children:e.options?t.jsx(Rt,{name:a,label:e.title,className:"w-full",value:n,onChange:r,options:[...e.required?[]:[{value:"",label:"None"}],...e.options.map(c=>({value:c,label:c}))],placeholder:"Pick one"}):e.type==="json"?t.jsx(dn,{name:a,rows:3,className:"p-3 font-mono",value:n,onChange:c=>r(c.target.value),spellCheck:!1}):t.jsx(ze,{name:a,inputMode:e.type==="string"?void 0:"decimal",value:n,onChange:c=>r(c.target.value),autoComplete:"off",spellCheck:!1})})})}function F8(e,n){const s=n!==null?`, up to ${n} at once; past that, a request waits for one of them to end`:"";return e?`With a filter, each request it takes starts its own run${n!==null?s:", even while an earlier run is still going"}. Any other request is answered and starts nothing.`:n!==null?`Every signed request starts a run${s}.`:"Every signed request starts a run. One that comes while its last run is still going is skipped."}function EE({signature:e,rules:n,onChange:s,issues:r,cap:a}){return t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(ro,{issues:r,field:"source.accept"}),t.jsx(yE,{name:"accept",rules:n,onChange:s,issues:r,room:wd.rules-n.length,eventHint:vE[e],eventPlaceholder:e==="github"?"issues":"issue.opened"}),t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:F8(n.length>0,a)})]})]})}function $E({picks:e,onChange:n,issues:s}){const r=i=>n({...e,events:e.events.includes(i)?e.events.filter(c=>c!==i):[...e.events,i]}),a=Jm(e).map(i=>i.id);return t.jsxs(t.Fragment,{children:[t.jsxs("fieldset",{className:"min-w-0",children:[t.jsx("legend",{className:"caps text-label text-muted-foreground",children:"Events"}),t.jsx("div",{className:"mt-1 space-y-3",children:rE.map(i=>{const c=a.indexOf(`event:${i}`),d=`source.accept[${c}]`;return t.jsxs("div",{"data-github-event":i,className:"space-y-1",children:[Qm.filter(u=>u.event===i).map(({event:u,action:f,label:g})=>{const b=`${u}:${f}`;return t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"checkbox",name:"event",value:b,checked:e.events.includes(b),onChange:()=>r(b),className:"accent-primary"}),g," ",t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:[u," ",f]})]},b)}),c>=0&&t.jsxs("div",{className:"ml-6 space-y-1 pt-1",children:[[d,`${d}.event`,`${d}.actions`].map(u=>t.jsx(ro,{issues:s,field:u},u)),t.jsx(xy,{name:`github-${i}`,at:d,where:e.where[i]??[],onChange:u=>n({...e,where:{...e.where,[i]:u}}),issues:s,label:`Only when, for ${i}`})]})]},i)})}),s["source.accept"]&&t.jsx("p",{className:"mt-1 text-small text-destructive-text",role:"alert","data-issue":"source.accept",children:s["source.accept"]})]}),t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Other events ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsx("p",{className:"mb-2 mt-1 text-small text-muted-foreground",children:"Any other GitHub event, by its name."}),t.jsx(yE,{name:"other",rules:e.other,onChange:i=>n({...e,other:i}),issues:s,indexOf:i=>{var c;return a.indexOf(`other:${(c=e.other[i])==null?void 0:c.key}`)},room:wd.rules-a.length,eventHint:vE.github,eventPlaceholder:"issues",addLabel:"Add another event"})]})]})}function U8({v2:e,go:n,trigger:s}){const r=uy(s)?s:null,a=my(s)?s:null,[i,c]=p.useState(()=>r?(r.source.accept??[]).map(yx):a?(a.source.accept??[]).map(yx):[]),[d,u]=p.useState(()=>r||a?{events:[],where:{},other:[]}:L6(s.source.accept)),f=a&&i[0]&&!i[0].actions.trim()?i[0]:null,g=a?i.slice(f?1:0):[],[b,x]=p.useState({}),[h,v]=p.useState([]),[y,j]=p.useState(!1),k=p.useRef(!0);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const E=async _=>{_.preventDefault();const{source:$,issues:O}=r?sE(r.source,i):a?F6(a.source,(f==null?void 0:f.where)??[],g,f==null?void 0:f.was):oE(d);if(v([]),Object.keys(O).length){x(O);return}x({}),j(!0);try{Vf($,s.source)||await e.updateTrigger(s.id,{source:$}),k.current&&n(Ws(s.id))}catch(A){if(!k.current)return;const L=jd(A),M=Ym(r||a?i.map(R=>R.where.length):Jm(d).map(R=>R.where.length));x(Object.fromEntries(Object.entries(L.fields).filter(([R])=>M.has(R)))),v([...L.rest,...Object.entries(L.fields).filter(([R])=>!M.has(R)).map(([,R])=>R)]),j(!1)}},S=r?rl:a?rm:lm,N=_=>c(f?_.length?[{...f,where:_},...g]:g:_.length?[{...FC(),event:a.source.event,where:_},...g]:g);return t.jsxs("form",{onSubmit:_=>void E(_),className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:Ws(s.id),className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," ",s.name]}),t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(S,{className:"size-5 text-primary-text","aria-hidden":!0}),"Edit filter"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:r?"Which signed requests start a run. Its URL and secret stay as they are.":a?`Which ${a.source.event} events from ${a.source.server} start a run. Its event, its config and its instance on Composio stay as they are.`:"Which events from this server's GitHub App start a run."}),h.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:h.map((_,$)=>t.jsx("p",{children:_},$))}),t.jsx("div",{className:"mt-5 space-y-5",children:r?t.jsx(EE,{signature:r.source.signature??"standard",rules:i,onChange:c,issues:b,cap:s.max_active_runs??null}):a?t.jsx(_E,{where:(f==null?void 0:f.where)??[],onChange:N,issues:b,others:g.map(_=>_.event+(_.actions.trim()?` (${_.actions.trim()})`:""))}):t.jsx($E,{picks:d,onChange:u,issues:b})}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:y,children:y?"Saving":"Save filter"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(Ws(s.id)),children:"Cancel"})]})]})}function _E({where:e,onChange:n,issues:s,others:r=[]}){return t.jsxs("fieldset",{className:"min-w-0",children:[t.jsxs("legend",{className:"caps text-label text-muted-foreground",children:["Filter ",t.jsx("span",{className:"font-normal normal-case",children:"(optional)"})]}),t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx(ro,{issues:s,field:"source.accept"}),t.jsx(ro,{issues:s,field:"source.accept[0]"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"A condition reads what Composio delivers: the event's data is under /data, such as /data/title for a new issue's title."}),t.jsx(xy,{name:"composio",at:"source.accept[0]",where:e,onChange:n,issues:s,label:"Only when"}),r.length>0&&t.jsxs("p",{className:"text-small text-muted-foreground",role:"note",children:[r.length===1?"One more rule, made through the API, is kept as it is":`${r.length} more rules, made through the API, are kept as they are`,": ",r.join(", "),"."]})]})]})}const TE=e=>e?"#/playground?operation=apply-template":"#/templates";function C0({v2:e,name:n,install:s,go:r,playground:a=!1,draft:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),[g,b]=p.useState(0);if(p.useEffect(()=>{if(s!==void 0)return;let h=!0;return f(null),e.listTemplates().then(v=>{h&&d(v.templates)},v=>{h&&f(Ut(v,"the templates"))}),()=>{h=!1}},[e,g,s]),s!==void 0)return t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(H8,{v2:e,source:s,go:r})});const x=n===void 0||c==null?void 0:c.find(h=>h.id===n);return t.jsx("div",{className:"p-5 md:p-8",children:u&&!c?t.jsx(Yt,{problem:u,onRetry:()=>b(h=>h+1),className:""}):c?n===void 0?t.jsx(W8,{v2:e,templates:c,go:r,playground:a,onRemoved:()=>b(h=>h+1)}):x?t.jsx(K8,{v2:e,template:x,go:r,playground:a,draft:i},`${x.id}:${i??""}`):t.jsxs("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",role:"alert",children:["This server offers no template named ",n,". ",t.jsx("a",{href:TE(a),className:"underline",children:"See its templates"}),"."]}):t.jsx(Fn,{label:"Loading the templates",rows:3})})}function by({t:e}){var n;return e.source?t.jsxs("p",{className:"mt-1 break-all font-mono text-small text-muted-foreground","data-provenance":!0,children:[e.source," at ",(n=e.sha)==null?void 0:n.slice(0,12),", published by ",e.publisher]}):null}function W8({v2:e,templates:n,go:s,playground:r,onRemoved:a}){const i=r?"h2":"h1",c=r?"h3":"h2",[d,u]=p.useState(""),[f,g]=p.useState(null),[b,x]=p.useState(null),h=async v=>{g(v.id),x(null);try{await e.deleteTemplate(v.id),a()}catch(y){x(y instanceof Error?y.message:String(y))}finally{g(null)}};return t.jsxs(t.Fragment,{children:[t.jsx(i,{className:"mb-5 text-2xl font-semibold",children:"Templates"}),t.jsxs("form",{"aria-label":"Add from URL",className:"mb-5 flex flex-wrap items-end gap-2 border bg-card px-4 py-3",onSubmit:v=>{v.preventDefault(),d.trim()&&s(B8(d.trim()))},children:[t.jsxs("label",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"caps text-small font-semibold",children:"Add from URL"}),t.jsx("span",{className:"mb-1.5 block text-small text-muted-foreground",children:"A package on GitHub: github:owner/repo/path@ref, or its github.com/…/tree/… address. You read it whole before anything is stored."}),t.jsx(ze,{type:"text",value:d,placeholder:"github:owner/repo/templates/name@main",onChange:v=>u(v.target.value)})]}),t.jsx(B,{size:"sm",variant:"solid",type:"submit",disabled:!d.trim(),children:"Read it"})]}),b&&t.jsx("p",{className:"mb-3 text-body text-destructive-text",role:"alert",children:b}),n.length?t.jsx("ul",{className:"grid gap-3 md:grid-cols-2",children:n.map(v=>t.jsx("li",{children:t.jsxs("article",{"aria-label":Uo(v),className:"flex h-full flex-col border bg-card px-5 py-4",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx(Ux,{className:"size-4 shrink-0 self-center text-muted-foreground","aria-hidden":!0}),t.jsx(c,{className:"min-w-0 break-words text-prose font-semibold",children:Uo(v)}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:v.version}),v.category&&t.jsx(Ne,{tone:"muted",children:v.category}),!v.bundled&&t.jsx(Ne,{tone:"muted",children:"Imported"})]}),t.jsx(by,{t:v}),t.jsx("p",{className:"mt-2 text-lead leading-[1.6]",children:v.description}),v.tags.length>0&&t.jsx("p",{"aria-label":"Tags",className:"mt-1.5 break-words font-mono text-small text-muted-foreground",children:v.tags.join(" · ")}),t.jsx("dl",{className:"mt-3 space-y-1 font-mono text-small text-muted-foreground",children:py(v).map(([y,j])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0",children:y}),t.jsx("dd",{className:"min-w-0 break-words text-foreground/80",children:j})]},y))}),t.jsxs("div",{className:"mt-auto flex flex-wrap items-center justify-end gap-2 pt-4",children:[!v.bundled&&t.jsx(B,{size:"sm",onClick:()=>void h(v),disabled:f===v.id,children:f===v.id?"Removing…":"Remove"}),r?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>s(el(v)),children:"Configure"}):t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:Yf(v)?"primary":"outline",onClick:()=>s(dE(v.id)),children:"Configure"}),t.jsx(tn,{variant:Yf(v)?"outline":"primary",label:"Run",prompt:ex(location.origin,v),playgroundHref:el(v)})]})]})]})},v.id))}):t.jsx("p",{className:"border px-4 py-12 text-center font-mono text-body text-muted-foreground",children:"This server offers no templates yet."})]})}function H8({v2:e,source:n,go:s}){var E;const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[b,x]=p.useState(null);p.useEffect(()=>{let S=!0;if(!n){c("Give a package's source: github:owner/repo/path@ref.");return}return e.importTemplate(n,{dryRun:!0}).then(N=>{S&&a(N)},N=>{S&&c(E0(N))}),()=>{S=!1}},[e,n]);const h=async()=>{g(!0),x(null);try{if(!r)return;const S=await e.importTemplate(`${r.template.id}@${r.template.sha}`,{trustPublisher:d});s(dE(S.template.id))}catch(S){x(E0(S))}finally{g(!1)}},v=t.jsxs("a",{href:"#/templates",className:"caps mb-4 inline-flex items-center gap-1.5 text-small text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Templates"]});if(i)return t.jsxs("div",{className:"max-w-3xl",children:[v,t.jsx("p",{className:"border px-4 py-6 font-mono text-body text-destructive-text",role:"alert",children:i})]});if(!r)return t.jsx(Fn,{label:"Reading the package from GitHub",rows:3});const y=r.template,j=y.publisher??"",k=Object.entries(r.skill_files);return t.jsxs("section",{"aria-label":"Install from GitHub",className:"max-w-3xl",children:[v,t.jsxs("h1",{className:"font-mono text-2xl font-semibold",children:[Uo(y)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:y.version})]}),t.jsxs("dl",{className:"mt-3 space-y-1 border bg-card px-4 py-3 font-mono text-small",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Publisher"}),t.jsxs("dd",{"data-publisher":!0,children:[j,r.publisher_trusted?" (trusted here)":" (new here)"]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Commit"}),t.jsx("dd",{className:"break-all","data-sha":!0,children:y.sha})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Source"}),t.jsx("dd",{className:"break-all",children:y.source})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:"Installs as"}),t.jsxs("dd",{className:"break-all",children:[y.id,r.replaced?`, replacing the one read at ${r.replaced.slice(0,12)}`:""]})]})]}),t.jsx("p",{className:"mt-3 text-lead leading-[1.6]",children:y.description}),t.jsx(lr,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:py(y,{mcp:!1}).map(([S,N])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:S}),t.jsx("dd",{className:"min-w-0 break-words",children:N})]},S))})}),y.mcp.length>0&&t.jsx(lr,{title:"MCP tools it asks for",note:"None is granted by installing: the Apply screen asks you to tick each one.",children:y.mcp.map(S=>t.jsxs("div",{"data-mcp":S.toolkit,className:"px-4 py-3",children:[t.jsx(RE,{m:S}),t.jsx("p",{className:"mt-1 break-words font-mono text-small",children:S.tools.map(N=>N.name).join(", ")})]},S.toolkit))}),t.jsx(AE,{t:y}),t.jsx(OE,{t:y}),t.jsx(lr,{title:"Instructions",note:"What the agent is told, in full: a package from someone else says this to your agent.",children:t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-instructions":!0,children:r.instructions})}),((E=y.output)==null?void 0:E.json_schema)&&t.jsx(lr,{title:"Output schema",note:`What the agent is told to answer in (${y.output.schema}), in full: its descriptions are instructions too.`,children:t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-output-schema":!0,children:JSON.stringify(y.output.json_schema,null,2)})}),k.length>0&&t.jsx(lr,{title:"Skill files",note:"Every file the agent is given, in full.",children:k.map(([S,N])=>t.jsxs("details",{className:"px-4 py-2","data-skill-file":S,children:[t.jsx("summary",{className:"cursor-pointer font-mono text-body",children:S}),t.jsx("pre",{className:"mt-2 max-h-[32rem] overflow-auto whitespace-pre-wrap break-words font-mono text-small",children:N})]},S))}),!r.publisher_trusted&&t.jsxs("label",{className:"mt-6 flex items-start gap-2.5 border border-warning/50 px-4 py-3",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:d,onChange:S=>u(S.target.checked)}),t.jsxs("span",{children:[t.jsxs("span",{className:"font-mono text-body",children:["I trust ",j]}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:["This server has no package from ",j," yet. Ticked, it remembers that you trust them."]})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void h(),disabled:f||!r.publisher_trusted&&!d,children:f?"Installing…":"Install"}),t.jsx("span",{className:"text-small text-muted-foreground",children:"Installing stores it; nothing runs and nothing is granted until you apply it."}),b&&t.jsx("p",{className:"w-full text-body text-destructive-text",role:"alert",children:b})]})]})}function E0(e){var n;return e instanceof De&&((n=e.fields)!=null&&n.length)?[...new Set([e.message,...e.fields.map(s=>s.message)])].join(" "):e instanceof Error?e.message:String(e)}const B8=e=>`#/templates/install?src=${encodeURIComponent(e)}`,G8=3e3;function q8(e,n){let s;const r=new Promise(a=>s=setTimeout(()=>a(void 0),n));return Promise.race([e,r]).finally(()=>clearTimeout(s))}function K8({v2:e,template:n,go:s,playground:r=!1,draft:a}){var _t,tt,ft,qt,zt,ye,le,Ue,Xe,rt;const i=r?"h2":"h1",c={fields:Xm(n.parameters)??[]},d=n8(a,n),[u,f]=p.useState(()=>{var J;return{...Object.fromEntries(c.fields.filter(([,ve])=>ve.type==="boolean"&&!ve.array).map(([ve])=>[ve,"false"])),...hE(c),...Object.fromEntries(Object.entries(((J=d.body)==null?void 0:J.parameters)??{}).map(([ve,We])=>[ve,Array.isArray(We)?We.map(String).join(`
|
|
658
|
+
`):String(We)]))}}),[g,b]=p.useState(()=>{var J;return new Set(((J=d.body)==null?void 0:J.grants)??[])}),[x,h]=p.useState(((tt=(_t=d.body)==null?void 0:_t.overrides)==null?void 0:tt.approvals)??n.approvals_default??"ask"),[v,y]=p.useState(((qt=(ft=d.body)==null?void 0:ft.overrides)==null?void 0:qt.choice)??""),[j,k]=p.useState(null),[E,S]=p.useState(null),[N,_]=p.useState(0),[$,O]=p.useState(()=>{var J;return((J=d.body)==null?void 0:J.servers)??{}}),[A,L]=p.useState(!1),[M,R]=p.useState([]),[P,D]=p.useState(null),[W,Y]=p.useState(null),[H,q]=p.useState([]),[F,G]=p.useState({}),U=p.useRef(dr()).current,z=p.useRef(!0);p.useEffect(()=>(z.current=!0,()=>{z.current=!1}),[]),p.useEffect(()=>{let J=!0;return S(null),e.listMcpServers().then(ve=>{J&&k(ve.servers)},ve=>{J&&S(Ut(ve,"the saved MCP servers"))}),()=>{J=!1}},[e,N]);const Q=l8(n,g),K=n.mcp.map(J=>{const ve=j?o8(J,j):[];return{m:J,matches:ve,uses:ve.length===1?ve[0]:ve.includes($[J.toolkit]??"")?$[J.toolkit]:void 0}}),Z=Object.fromEntries(K.flatMap(({m:J,uses:ve})=>ve?[[J.toolkit,ve]]:[])),de=K.filter(({matches:J,uses:ve})=>J.length>1&&!ve).map(({m:J})=>J.toolkit),se=n.mcp.length>0&&j===null,ue=j&&K.some(({m:J,matches:ve})=>{var We,Se;return((Se=(We=d.body)==null?void 0:We.servers)==null?void 0:Se[J.toolkit])!==void 0&&!ve.includes(d.body.servers[J.toolkit])}),xe=d.error??(ue?"This prepared server choice no longer matches the saved MCP servers. Open a fresh request to review the current accounts.":void 0),$e=!!xe||se||de.length>0,ge=r||Yf(n),fe=!r&&Yf(n)?S0.filter(J=>J.needs(n)):[],[me,je]=p.useState({}),[Me,_e]=p.useState(0),re=fe.map(J=>J.id).join(" ");p.useEffect(()=>{let J=!0;for(const ve of S0.filter(We=>re.split(" ").includes(We.id)))ve.met(e).then(We=>{J&&je(Se=>({...Se,[ve.id]:We?"met":"unmet"}))},()=>{J&&je(We=>({...We,[ve.id]:"unread"}))});return()=>{J=!1}},[e,re,Me]);const Re=fe.filter(J=>me[J.id]!=="met"),Ze=Re.find(J=>me[J.id]===void 0),at=Re.length>0;p.useEffect(()=>{if(!at)return;const J=()=>_e(ve=>ve+1);return window.addEventListener("focus",J),()=>window.removeEventListener("focus",J)},[at]);const pt={parameters:eh(c,u),...Q.length?{grants:Q}:{},...Object.keys(Z).length?{servers:Z}:{},overrides:{approvals:x,...v?{choice:v}:{}}},Ee=J=>c8(M,J),Je=(J,ve,We)=>{f(Se=>({...Se,[J]:We})),mE(ve,We)&&R(Se=>Se.filter(Ye=>kx(Ye.field,"parameters")!==J))},he=async()=>{var ve,We;if(!ge||$e||Re.length)return;L(!0),R([]),D(null);const J=u;try{const Se=await e.applyTemplate(n.id,pt,U.keyFor(n.id,pt));U.done();const Ye=async()=>(await Promise.all(Se.trigger_ids.map(ot=>q8(e.getTrigger(ot),G8).catch(()=>null)))).filter(ot=>ot!=null&&dy(ot));if(Se.warnings.length||(ve=Se.webhook_secrets)!=null&&ve.length){G(J),Y(Se),Ye().then(q,()=>{});return}const Nt=Se.trigger_ids.length?await Ye():[];if(!z.current)return;if(!Nt.length){s(ln(Se.agent_id));return}G(J),q(Nt),Y(Se)}catch(Se){Se instanceof De&&((We=Se.fields)!=null&&We.length)?(R(Se.fields),D({text:Se.message,withIssues:!0}),Se.fields.some(Ye=>Ye.field.startsWith("servers.")||Ye.field.startsWith("mcp."))&&_(Ye=>Ye+1)):D({text:Se instanceof Error?Se.message:String(Se),withIssues:!1})}finally{L(!1)}},Fe=c.fields,ut=J=>J.filter(ve=>!n.secrets.includes(ve)),Pe=(ye=(zt=n.model)==null?void 0:zt.choices)==null?void 0:ye.find(J=>J.id===v),ct=J=>{var ve,We;return/^(parameters|mcp|servers)\./.test(J.field)||/^grants\.\d+$/.test(J.field)||J.field==="overrides.choice"&&!!((We=(ve=n.model)==null?void 0:ve.choices)!=null&&We.length)||J.field.startsWith("secrets.")&&[...n.secrets,...ut((Pe==null?void 0:Pe.secrets)??[])].includes(J.field.slice(8))};return W?t.jsxs("section",{"aria-label":"Applied",className:"max-w-page",children:[t.jsxs(i,{className:"mb-4 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(hl,{className:"size-5 text-success-text","aria-hidden":!0})," ",Uo(n,F)," applied"]}),W.warnings.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mb-3 text-lead",children:"The agent is made. The server says:"}),t.jsx("ul",{className:"mb-5 space-y-2 border bg-card px-4 py-3 text-body",role:"status","aria-label":"Warnings",children:W.warnings.map((J,ve)=>{var Nt,It;const We=/^triggers\.(\d+)\.secret$/.exec(J.field),Se=We?W.trigger_ids[Number(We[1])]:void 0,Ye=We?(Nt=n.triggers[Number(We[1])])==null?void 0:Nt.name:void 0;return Se&&((It=W.webhook_secrets)!=null&&It.some(ot=>ot.trigger_id===Se))?t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:J.field})," ",J.message]},`${J.field}:${ve}`):t.jsxs("li",{children:[t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:J.field})," ",J.message,J.fix?t.jsx("span",{className:"block text-muted-foreground",children:J.fix}):null,Se&&t.jsxs("a",{href:`#/triggers/${encodeURIComponent(Se)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",typeof Ye=="string"&&Ye?Ye:Se," to get its signing secret (Rotate)"]})]},`${J.field}:${ve}`)})})]}),(le=W.webhook_secrets)==null?void 0:le.map(J=>{var Ye;const ve=W.trigger_ids.indexOf(J.trigger_id),We=ve>=0?(Ye=n.triggers[ve])==null?void 0:Ye.name:void 0,Se=typeof We=="string"&&We?We:J.trigger_id;return J.signing_secret?t.jsx(yy,{label:`The webhook's URL and secret (${Se})`,url:Kc({id:J.trigger_id}),secret:J.signing_secret},J.trigger_id):t.jsxs("div",{className:"mt-4 border px-4 py-3 text-body",children:[J.note&&t.jsx("p",{className:"text-muted-foreground",role:"note",children:J.note}),t.jsxs("a",{href:`#/triggers/${encodeURIComponent(J.trigger_id)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",Se," to get its signing secret (Rotate)"]})]},J.trigger_id)}),H.length>0&&t.jsx("ul",{className:"mt-4 divide-y border","aria-label":"Schedules",children:H.map(J=>t.jsxs("li",{"data-trigger":J.id,className:"px-4 py-3",children:[t.jsx("a",{href:`#/triggers/${encodeURIComponent(J.id)}`,className:"break-words text-prose font-semibold hover:underline",children:J.name}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",children:ly(J.source,J.next_at)})]},J.id))}),t.jsx("div",{className:"mt-5"}),t.jsx("a",{href:ln(W.agent_id),className:"inline-flex border px-3 py-2 font-mono text-body font-semibold hover:bg-accent",children:"Open the agent"})]}):t.jsxs("div",{children:[t.jsxs("a",{href:TE(r),className:"caps mb-4 inline-flex min-h-6 items-center gap-1.5 text-small text-muted-foreground hover:text-foreground",children:[t.jsx(zn,{className:"size-3.5","aria-hidden":!0})," Templates"]}),t.jsxs(i,{className:"text-2xl font-semibold",children:[Uo(n,u)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:n.version})]}),t.jsx(by,{t:n}),t.jsx("p",{className:"mt-2 max-w-prose text-lead leading-[1.6]",children:n.description}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:r?"Apply creates an agent and its triggers. It does not start a run.":ge?"Apply creates an agent and its triggers. It does not start a run. Or set it up with your coding agent, which asks for any missing inputs and runs the task.":"Run with your coding agent. It sets up this template, asks for any missing inputs, and runs the task."}),xe&&t.jsxs("p",{className:"mt-3 text-body text-destructive-text",role:"alert",children:[xe," ",t.jsx("a",{href:el(n),className:"underline",children:"Open a fresh request"}),"."]}),t.jsxs("div",{className:`mt-6 ${$m}`,children:[Fe.length>0&&t.jsx(lr,{title:"Parameters",children:Fe.map(([J,ve])=>t.jsxs("div",{"data-field":`parameters.${J}`,className:"px-4 py-3",children:[t.jsx(xE,{field:ve,label:Zm(J,ve),help:Qf(ve),value:u[J]??"",onChange:We=>Je(J,ve,We)}),t.jsx(Po,{issues:M.filter(We=>kx(We.field,"parameters")===J),words:We=>gE(We,J,ve)})]},J))}),n.mcp.length>0&&t.jsxs(lr,{title:"Tools you grant",note:"Nothing is granted until you tick it. A tool you tick is granted and follows this server's tool settings: a write asks you first unless you allowed it in Settings or choose Never ask, and a read runs without asking where you turned on Allow reads for its server. A tool you leave unticked is not given to the agent, even when it never asks: you can add it later on the agent's page.",children:[E&&!j&&t.jsx("div",{"data-servers-unread":!0,className:"px-4 py-3",children:t.jsx(Yt,{problem:E,onRetry:()=>_(J=>J+1),className:""})}),K.map(({m:J,matches:ve,uses:We})=>t.jsxs("div",{"data-mcp":J.toolkit,className:"px-4 py-3",children:[t.jsx(RE,{m:J,children:j&&ve.length<2&&t.jsx("span",{className:"text-small text-muted-foreground",children:We?`Uses ${We}`:"Not set up here"})}),j&&ve.length>1&&t.jsxs("label",{className:"mt-2 flex flex-wrap items-center gap-2 text-small text-muted-foreground",children:["Uses",t.jsx(Rt,{small:!0,label:`Server for ${J.toolkit}`,value:We??"",placeholder:"Pick one",onChange:Se=>O(Ye=>({...Ye,[J.toolkit]:Se})),options:ve.map(Se=>({value:Se,label:Se}))}),!We&&t.jsxs("span",{"data-unpicked":J.toolkit,children:[ve.length," saved servers are ",hd[J.source]," ",J.toolkit,": pick the one the agent uses."]})]}),j&&ve.length===0&&t.jsxs("p",{role:"status","data-missing-mcp":J.toolkit,className:"mt-2 border border-warning/50 px-3 py-2 text-small text-warning-text",children:[J.required?`${J.toolkit} is required and not set up here: Apply is refused until it is.`:`${J.toolkit} is not set up here: Apply makes the agent without its tools (${J.tools.map(Se=>Se.name).join(", ")}).`," ",t.jsx("a",{href:a8(J),className:"font-mono text-primary-text underline-offset-2 hover:underline",children:J.source==="github"?"Set up GitHub App access":J.source==="composio"?`Add ${J.toolkit} from Composio`:`Set up ${J.toolkit}`})]}),t.jsx(Po,{issues:[...Ee(`mcp.${J.toolkit}`),...Ee(`servers.${J.toolkit}`)]}),t.jsx("ul",{className:"mt-2 space-y-2",children:J.tools.map(Se=>{const Ye=Q.indexOf(Se.tool);return t.jsxs("li",{"data-tool":Se.tool,children:[t.jsxs("label",{className:"flex items-start gap-2.5",children:[t.jsx("input",{type:"checkbox",className:"mt-1 accent-primary",checked:g.has(Se.tool),onChange:()=>b(Nt=>{const It=new Set(Nt);return It.has(Se.tool)?It.delete(Se.tool):It.add(Se.tool),It})}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body",children:Se.name})," ",t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Se.tool}),t.jsx("span",{className:"block text-small text-muted-foreground",children:Se.asks==="allow"?"The template asks you to grant this.":"The template does not ask for this; unticked, the agent doesn't get it."})]})]}),Ye>=0&&t.jsx(Po,{issues:Ee(`grants.${Ye}`)})]},Se.tool)})})]},J.toolkit))]}),n.secrets.length>0&&t.jsx(lr,{title:"Keys it uses",note:"Saved on this server by name; a run is given them.",children:n.secrets.map(J=>t.jsxs("div",{"data-secret":J,className:"px-4 py-3 font-mono text-body",children:[J,t.jsx(Po,{issues:Ee(`secrets.${J}`)})]},J))}),(Xe=(Ue=n.model)==null?void 0:Ue.choices)!=null&&Xe.length?t.jsxs("fieldset",{"aria-label":"Model",className:"mt-6",children:[t.jsx("legend",{className:"caps text-small font-semibold",children:"Model"}),t.jsx("div",{className:"mt-2 divide-y border",children:[{id:"",label:`Your default: ${n.model.tier} on ${(rt=n.harness)!=null&&rt.length?n.harness.length===1?n.harness[0]:`the first of ${n.harness.join(", ")} this server runs`:"this server's default harness"}`,warning:null,note:null},...n.model.choices].map(J=>t.jsxs("label",{"data-choice":J.id||"(default)",className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"model-choice",value:J.id,className:"mt-1 accent-primary",checked:v===J.id,onChange:()=>{y(J.id),R(ve=>ve.filter(We=>We.field!=="overrides.choice"&&!(We.field.startsWith("secrets.")&&!n.secrets.includes(We.field.slice(8)))))}}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body","data-choice-label":!0,children:J.label}),"model"in J&&t.jsxs("span",{className:"block font-mono text-label text-muted-foreground",children:[J.model," on ",J.harness]}),J.warning&&t.jsx("span",{className:"mt-1 block text-small text-warning-text","data-choice-warning":J.id,children:J.warning}),J.note&&t.jsx("span",{className:"mt-1 block text-small text-muted-foreground","data-choice-note":J.id,children:J.note}),"secrets"in J&&v===J.id&&t.jsx("span",{"data-choice-keys":J.id,children:t.jsx(Po,{issues:ut(J.secrets).flatMap(ve=>Ee(`secrets.${ve}`))})})]})]},J.id||"(default)"))}),t.jsx(Po,{issues:Ee("overrides.choice")})]}):null,t.jsxs("fieldset",{"aria-label":"Approvals",className:"mt-6",children:[t.jsx("legend",{className:"caps text-small font-semibold",children:"Approvals"}),t.jsx("div",{className:"mt-2 divide-y border",children:[["ask","Ask me","A call that asks waits for your answer: a ticked tool's write unless you allowed it in Settings, and its read unless you turned on Allow reads for its server."],["never","Never ask (run unattended)","Runs without asking you, even for writes. Pick this if a trigger starts the agent while you're away."]].map(([J,ve,We])=>t.jsxs("label",{className:"flex items-start gap-3 px-4 py-3",children:[t.jsx("input",{type:"radio",name:"approvals",value:J,className:"mt-1 accent-primary",checked:x===J,onChange:()=>h(J)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:ve}),t.jsx("span",{className:"block text-small text-muted-foreground",children:We})]})]},J))}),x==="never"&&t.jsx("p",{className:"mt-2 text-small text-warning-text",children:LC})]}),t.jsx(AE,{t:n}),t.jsx(OE,{t:n}),t.jsx(lr,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:py(n,{secrets:!1,mcp:!1}).map(([J,ve])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"shrink-0 text-muted-foreground",children:J}),t.jsx("dd",{className:"min-w-0 break-words",children:ve})]},J))})})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[ge?t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void he(),disabled:A||$e||Re.length>0,title:se?E?"The saved MCP servers couldn't be read: try again first":"Reading the saved MCP servers…":de.length?`Pick the server for ${de.join(", ")} first`:Ze?`Reading ${Ze.what}…`:void 0,children:A?"Applying…":"Apply"}),!r&&t.jsx(tn,{variant:"outline",label:"Set it up with an agent",disabled:$e,prompt:ex(location.origin,n,pt),playgroundHref:el(n,pt)}),Re.map(J=>me[J.id]==="unmet"?t.jsxs("p",{role:"status","data-requirement":J.id,className:"min-w-0 text-body text-warning-text",children:[J.unmet.before,t.jsx("a",{href:J.unmet.href,className:"font-mono text-primary-text underline-offset-2 hover:underline",children:J.unmet.link}),J.unmet.after]},J.id):me[J.id]==="unread"?t.jsxs("p",{role:"alert","data-requirement-unread":J.id,className:"flex min-w-0 flex-wrap items-center gap-2 text-body text-destructive-text",children:[`${J.what[0].toUpperCase()}${J.what.slice(1)} couldn't be read.`,t.jsx(B,{size:"sm",onClick:()=>_e(ve=>ve+1),children:"Try again"})]},J.id):null)]}):t.jsx(tn,{variant:"primary",label:"Run",disabled:$e,prompt:ex(location.origin,n,pt),playgroundHref:el(n,pt)}),P&&(!P.withIssues||M.length>0)&&t.jsx("p",{className:"min-w-0 flex-1 text-body text-destructive-text",role:"alert",children:P.text})]}),M.filter(J=>!ct(J)).length>0&&t.jsx("div",{className:"mt-2",children:t.jsx(Po,{issues:M.filter(J=>!ct(J)),named:!0})})]})}function RE({m:e,children:n}){return t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-mono text-body",children:[t.jsx("span",{className:"font-semibold",children:e.toolkit}),t.jsx(Ne,{tone:"muted",children:hd[e.source]}),t.jsx(Ne,{tone:e.required?"plain":"muted",children:e.required?"Required":"Optional"}),n]}),e.reason&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground","data-reason":!0,children:e.reason})]})}function AE({t:e}){if(!e.input_schema)return null;const n=Xm(e.input_schema,"content");return n&&!n.length?null:t.jsx(lr,{title:"Run inputs",note:"What each run is given, as the run form asks for it.",children:n?n.map(([s,r])=>t.jsxs("div",{"data-input":s,className:"px-4 py-3",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-mono text-body",children:[t.jsx("span",{className:"font-semibold",children:Zm(s,r)}),r.title&&t.jsx("span",{className:"text-small text-muted-foreground",children:s}),t.jsx(Ne,{tone:"muted",children:w8(r)}),t.jsx(Ne,{tone:r.required?"plain":"muted",children:r.required?"Required":"Optional"})]}),Qf(r)&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:Qf(r)})]},s)):t.jsx("pre",{className:"max-h-[32rem] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-small","data-input-schema":!0,children:JSON.stringify(e.input_schema,null,2)})})}function OE({t:e}){const n=e.evals.length;return t.jsx(lr,{title:"Eval cases",note:n?`The ${n===1?"one case":`${n} cases`} this template is tested on.`:void 0,children:t.jsx("p",{className:"break-words px-4 py-3 font-mono text-small","data-evals":!0,children:n?e.evals.join(", "):"None: this package ships no eval cases, so nothing tests it."})})}function lr({title:e,note:n,children:s}){return t.jsxs("section",{"aria-label":e,className:"mt-6",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:e}),n&&t.jsx("p",{className:"mt-0.5 text-small text-muted-foreground",children:n}),t.jsx("div",{className:"mt-2 divide-y border",children:s})]})}function Xf(e){return{definition:{version:1,name:"New agent",instructions:e.trim(),harness:"pi",tools:[],skills:[]}}}function $0(e){return`#/playground?${new URLSearchParams({operation:"create-agent",draft:JSON.stringify(e)})}`}function V8(e){if(!e)return null;try{const n=JSON.parse(e);if(!n||typeof n!="object"||!("definition"in n))return null;const s=n.definition;if(!s||typeof s!="object"||Array.isArray(s))return null;const r=s;return r.version!==1||typeof r.name!="string"||typeof r.instructions!="string"||r.harness!=="pi"||r.description!==void 0&&typeof r.description!="string"||!Array.isArray(r.tools)||!r.tools.every(a=>typeof a=="string")||!Array.isArray(r.skills)||r.skills.length!==0?null:{definition:{version:1,name:r.name,instructions:r.instructions,harness:"pi",tools:[...r.tools],skills:[],...typeof r.description=="string"?{description:r.description}:{}}}}catch{return null}}const Y8={"code-review":am,"inbound-lead":cm,kyb:IT,"market-monitor":PT,"release-notes":Ka};function Q8({origin:e,v2:n}){const[s,r]=p.useState(""),[a,i]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState(null),[g,b]=p.useState(null),[x,h]=p.useState(0),v=p.useId(),y=Om(e,s),j=Xf(s);p.useEffect(()=>{let S=!0;return b(null),n.listTemplates().then(N=>{S&&f(N.templates)},N=>{S&&b(Ut(N,"the template catalog"))}),()=>{S=!1}},[n,x]);const k=c.trim().toLocaleLowerCase(),E=(u??[]).filter(S=>`${Uo(S)} ${S.description} ${S.name} ${S.id} ${S.publisher??""}`.toLocaleLowerCase().includes(k));return t.jsxs("section",{className:"mx-auto w-full max-w-page-wide px-5 pb-20 pt-10 md:px-12 md:pt-16","aria-labelledby":`${v}-heading`,children:[t.jsxs("header",{className:"text-center",children:[t.jsx("h1",{id:`${v}-heading`,className:"text-2xl font-semibold leading-tight tracking-tight md:text-display",children:"What do you want to build?"}),t.jsx("p",{className:"mt-3 text-base text-muted-foreground",children:"Describe your agent, or pick a template to start from."})]}),t.jsxs("div",{className:"mx-auto mt-8 max-w-page",children:[t.jsxs("div",{className:oe(Fc,"!rounded-composer overflow-hidden bg-card transition-colors"),"data-agent-composer":!0,children:[t.jsx("label",{htmlFor:`${v}-brief`,className:"sr-only",children:"Describe your agent"}),t.jsx(dn,{bare:!0,id:`${v}-brief`,value:s,onChange:S=>r(S.target.value),rows:3,placeholder:"A support agent that answers questions from our docs and escalates to Slack when it’s stuck…",className:"block min-h-28 w-full resize-none px-5 pb-3 pt-5 font-sans text-base leading-relaxed text-foreground md:px-6 md:pt-6"}),t.jsx("div",{className:"flex justify-end px-4 pb-4 pt-1 md:px-5 md:pb-5",children:t.jsx(tn,{variant:"primary",label:"Build an agent",prompt:y,playgroundHref:$0(j)})})]}),t.jsxs("details",{className:"mt-3 text-small text-muted-foreground",children:[t.jsx("summary",{className:"ml-auto w-fit cursor-pointer hover:text-foreground",children:"View coding-agent prompt"}),t.jsx("label",{htmlFor:`${v}-prompt`,className:"sr-only",children:"Coding-agent prompt"}),t.jsx(dn,{id:`${v}-prompt`,value:y,readOnly:!0,rows:8,spellCheck:!1,className:"mt-3 w-full border bg-card p-4 font-mono text-small leading-relaxed text-foreground"})]})]}),t.jsxs("section",{className:"mt-10 md:mt-12","aria-labelledby":`${v}-templates`,children:[t.jsxs("div",{className:"mb-5 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"flex items-baseline gap-3",children:[t.jsx("h2",{id:`${v}-templates`,className:"text-lead font-semibold",children:"Start from a template"}),t.jsx("span",{role:"status",className:"text-small text-muted-foreground",children:u===null&&!g?"Loading templates…":u?`${E.length} of ${u.length}`:""})]}),t.jsxs("div",{className:oe(Fc,"flex w-full items-center gap-2 px-3 sm:w-72"),children:[t.jsx(cm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(ze,{bare:!0,type:"search","aria-label":"Search templates",value:c,onChange:S=>d(S.target.value),placeholder:"Search templates…",className:"h-control-md w-full font-sans"})]})]}),g&&t.jsx(Yt,{problem:g,onRetry:()=>h(S=>S+1),className:"mb-5"}),(u==null?void 0:u.length)===0&&t.jsx("p",{className:"border border-border px-5 py-10 text-center text-lead text-muted-foreground",children:"This server has no template packages yet. Describe the agent you want to build above."}),u&&u.length>0&&!E.length&&t.jsxs("p",{role:"status",className:"border border-border px-5 py-10 text-center text-muted-foreground",children:["No templates match “",c,"”."]}),t.jsx("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3",children:E.map(S=>{const N=a===S.id,_=Y8[S.name]??Ux,$=`${v}-${encodeURIComponent(S.id)}-actions`,O=[S.skills.length?`${S.skills.length} skill${S.skills.length===1?"":"s"}`:"Ready to configure",S.triggers.length?`${S.triggers.length} trigger${S.triggers.length===1?"":"s"}`:""].filter(Boolean).join(" · ");return t.jsxs("article",{className:`flex flex-col overflow-hidden border transition-colors ${N?"border-border-strong bg-card":"border-border hover:border-border-strong"}`,children:[t.jsxs("button",{type:"button","aria-expanded":N,"aria-controls":$,"aria-label":`Start with ${Uo(S)}${S.source?` from ${S.id}`:""}`,className:"flex min-h-48 flex-1 flex-col p-5 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>i(N?null:S.id),children:[t.jsx("h3",{className:"text-lg font-semibold leading-snug",children:Uo(S)}),t.jsx(by,{t:S}),t.jsx("p",{className:"mt-3 line-clamp-3 text-lead leading-relaxed text-muted-foreground",children:S.description}),t.jsxs("span",{className:"mt-auto flex w-full items-center gap-2 pt-5 text-small text-muted-foreground",children:[t.jsx(_,{className:"size-4","aria-hidden":!0}),O,t.jsx(Ix,{className:"ml-auto size-3.5","aria-hidden":!0})]})]}),N&&t.jsxs("div",{id:$,className:"flex flex-wrap items-center justify-end gap-2 border-t px-4 py-4",children:[t.jsxs("span",{className:"mr-auto font-mono text-small text-muted-foreground",children:["v",S.version]}),t.jsx(tn,{variant:"primary",label:"Use this template",prompt:TP(e,S,s),playgroundHref:el(S)})]})]},S.id)})})]}),t.jsxs("p",{className:"mt-10 text-center text-lead text-muted-foreground",children:["Or ",t.jsx("a",{className:"text-primary-text underline underline-offset-4 hover:text-primary-text/80",href:$0(Xf("")),children:"start from a blank agent"}),"."]})]})}const ME=p.createContext(new Map),J8={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email"};function PE({run:e}){const n=p.useContext(ME);if(!e.trigger)return null;const{id:s}=e.trigger,r=n.get(s),a=r?`${J8[r.kind]??"Trigger"}: ${r.name}`:`Trigger: ${s}`;return t.jsx("a",{href:`#/triggers/${encodeURIComponent(s)}`,onClick:i=>i.stopPropagation(),className:"inline-flex max-w-full",title:a,children:t.jsxs(Ne,{className:"max-w-full",children:[t.jsx(om,{className:"size-3 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"truncate",children:a})]})})}const Zf=["queued","working","paused","input_required","completed","failed","cancelled"],X8={queued:"Queued",working:"Working",paused:"Paused",input_required:"Input required",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function Z8({runs:e,agentName:n,onOpen:s,error:r,onRetry:a,onMore:i,loadingMore:c,filter:d={},onFilter:u,agentId:f,observations:g}){var x,h;const b=!!d.archived;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-b px-5 py-2 md:px-6",children:[t.jsxs("h1",{className:"caps mr-auto flex items-center gap-2.5 text-small font-semibold",children:[t.jsx(Jc,{className:"size-4","aria-hidden":!0}),b?"Archived runs":"Runs"]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(Rt,{label:"Runs in one state",value:d.status??"",onChange:v=>u({...d,status:v||void 0}),className:"h-control-sm w-48",options:[{value:"",label:"Any state"},...Zf.map(v=>({value:v,label:X8[v]}))]}),t.jsxs(B,{size:"sm",variant:b?"primary":"outline","aria-pressed":b,onClick:()=>u({...d,archived:!b}),children:[t.jsx(Qc,{"aria-hidden":!0})," Archived"]})]}),t.jsx(tn,{label:"Query",prompt:`${Mm(location.origin,f)}
|
|
659
|
+
Current view: ${d.status?`status ${d.status}`:"all statuses"}; ${b?"archived runs":"non-archived runs"}.`,playgroundHref:Sv(f,d)})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[r&&!e?t.jsx(Yt,{problem:r,onRetry:a,className:""}):e?!e.length&&!((x=g==null?void 0:g.data)!=null&&x.sessions.length)&&!d.status&&!b?t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(eU,{})}):!e.length&&((h=g==null?void 0:g.data)!=null&&h.sessions.length)?null:e.length?t.jsx(tU,{runs:e,agentName:n,onOpen:s}):t.jsx("p",{className:"px-4 py-16 text-center text-body text-muted-foreground",children:d.status?"No run matches.":b?"No archived runs.":"No runs yet."}):t.jsx(Fn,{label:"Loading the runs"}),g&&t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Nv,{read:g})}),e&&r&&t.jsx(Yt,{problem:r,className:"mt-4"}),e&&i&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{type:"button",size:"sm",onClick:i,disabled:c,children:c?"Loading":"Load more"})})]})]})}function eU(){return t.jsxs("section",{"aria-labelledby":"first-run",className:"border border-primary/50 bg-primary/5 p-5",children:[t.jsx("p",{className:"caps text-label text-primary-text",children:"No runs yet"}),t.jsx("h2",{id:"first-run",className:"mt-2 text-xl font-semibold",children:"Start your first run"}),t.jsx("p",{className:"mt-1 max-w-prose text-lead text-muted-foreground",children:"A run is one piece of work an agent does: a question answered, a page researched, a file written. Each one is listed here with its state, when it started and what it cost."}),t.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[t.jsxs("a",{href:"#/playground",className:Oc({variant:"solid",size:"lg"}),children:[t.jsx(Yo,{"aria-hidden":!0})," Start a run"]}),t.jsx("a",{href:"#/templates",className:Oc({variant:"outline",size:"lg"}),children:"Browse templates"})]})]})}function tU({runs:e,agentName:n,onOpen:s}){return t.jsxs("table",{className:"w-full border-collapse text-body",children:[t.jsx("thead",{className:"sticky top-0 z-sticky hidden bg-background md:table-header-group",children:t.jsx("tr",{className:"caps text-label text-muted-foreground",children:["Status","Run","Agent","Kind","Started","Cost"].map(r=>t.jsx("th",{className:"border-b border-r px-4 py-3 text-left font-normal last:border-r-0",children:r},r))})}),t.jsx("tbody",{children:e.map(r=>t.jsxs("tr",{className:"cursor-pointer border-b hover:bg-accent",onClick:()=>s(r.run_id),children:[t.jsx("td",{className:"px-3 py-2.5 align-top",children:t.jsx(Nl,{run:r})}),t.jsxs("td",{className:"px-3 py-2.5 align-top",children:[t.jsxs("button",{type:"button",className:"flex items-start gap-1 text-left",onClick:a=>{a.stopPropagation(),s(r.run_id)},children:[t.jsx("span",{className:"line-clamp-2",children:Sn(r)}),t.jsx(cr,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}),r.status==="completed"&&r.review&&t.jsx("span",{className:"mt-1 block text-small text-warning-text",children:r.review.reason}),r.trigger&&t.jsx("span",{className:"mt-1 flex",children:t.jsx(PE,{run:r})}),t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground md:hidden",children:[n(r.agent_id)," · ",ht(r.created_at)]})]}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top md:table-cell",children:n(r.agent_id)}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:r.kind}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:ht(r.created_at)}),t.jsx("td",{className:"hidden px-3 py-2.5 align-top font-mono text-small text-muted-foreground md:table-cell",children:eo(r.cost,{ended:Wa(r.status)})})]},r.run_id))})]})}function nU({agentId:e,details:n}){const{denied:s,asks:r}=SD(n),a=[...new Set([...s,...r])];return a.length?t.jsxs("p",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1",children:[a.map(i=>t.jsxs("a",{href:`#/agents/${encodeURIComponent(e)}/edit?tool=${encodeURIComponent(i)}`,className:"underline underline-offset-4",children:["Set ",i," for this agent"]},i)),t.jsxs("span",{children:["or for every agent: ",t.jsx("a",{href:"#/settings/tools",className:"underline underline-offset-4",children:"Settings → Tools"})]})]}):null}function sU(e,{base:n="/v2",onProgress:s,signal:r,request:a=()=>new XMLHttpRequest}={}){return new Promise((i,c)=>{if(r!=null&&r.aborted)return c(new De(0,"aborted","The upload was stopped."));const d=a();d.open("POST",`${n}/files?path=${encodeURIComponent(e.name)}`),d.setRequestHeader("accept","application/json"),e.type&&d.setRequestHeader("content-type",e.type),d.upload.onprogress=u=>{u.lengthComputable&&u.total>0&&(s==null||s(Math.min(1,u.loaded/u.total)))},d.onload=()=>{let u=null;try{u=JSON.parse(d.responseText)}catch{}if(d.status===201||d.status===200){const b=u==null?void 0:u.file;return b!=null&&b.file_id?(s==null||s(1),i(b)):c(new De(d.status,"bad_answer","The server's answer named no file."))}const f=u==null?void 0:u.error,g=new De(d.status,(f==null?void 0:f.code)??"http_error",(f==null?void 0:f.message)??`The server answered ${d.status}.`,(f==null?void 0:f.retryable)??!1,f==null?void 0:f.request_id);f!=null&&f.fields&&(g.fields=f.fields),c(g)},d.onerror=()=>c(new De(0,"network","The upload did not reach the server.")),d.onabort=()=>c(new De(0,"aborted","The upload was stopped.")),r==null||r.addEventListener("abort",()=>d.abort(),{once:!0}),d.send(e)})}const rU=(e,n,s)=>sU(e,{onProgress:n,signal:s});function Ng(e){if(!(e instanceof De))return e instanceof Error?e.message:String(e);const n=(e.fields??[]).filter(s=>s.message!==e.message).map(s=>s.message);return[e.message,...n].join(" ")}function oU({upload:e,remove:n,limits:s,frozen:r=!1}){const[a,i]=p.useState([]),[c,d]=p.useState([]),u=p.useRef(new Map),f=p.useRef(0),g=p.useRef(0);g.current=a.length;const b=p.useRef({items:a,frozen:r,remove:n});b.current={items:a,frozen:r,remove:n};const x=p.useRef(!0);p.useEffect(()=>{x.current=!0;const k=u.current;return()=>{var _;x.current=!1;for(const $ of k.values())$.abort();const{items:E,frozen:S,remove:N}=b.current;if(!S)for(const $ of E)$.file&&!$.removing&&((_=N==null?void 0:N($.file.file_id))==null||_.catch(()=>{}))}},[]);const h=p.useCallback(k=>{if(b.current.frozen)return;const E=[],S=s?s.max_files_per_run-g.current:1/0,N=(s==null?void 0:s.max_upload_bytes)??null,_=[];for(const O of k)N!==null&&O.size>N?E.push({text:`${O.name} is ${il(O.size)}: this server takes files up to ${il(N)}.`}):_.length>=S?E.push({text:`${O.name} is not added: a run names at most ${s==null?void 0:s.max_files_per_run} files here.`}):_.push(O);d(E);const $=_.map(O=>({key:`f${f.current++}`,name:O.name,size:O.size,progress:0}));g.current+=$.length,i(O=>[...O,...$]),$.forEach((O,A)=>{const L=new AbortController;u.current.set(O.key,L);const M=R=>{x.current&&i(P=>P.map(D=>D.key===O.key?{...D,...R}:D))};e(_[A],R=>M({progress:R}),L.signal).then(R=>{var P,D,W;if(u.current.delete(O.key),L.signal.aborted){(W=(D=(P=b.current).remove)==null?void 0:D.call(P,R.file_id))==null||W.catch(Y=>{x.current&&d(H=>[...H,{text:`${O.name} was sent before it was stopped, and was not removed: ${Ng(Y)}`}])});return}M({file:R,progress:1})},R=>{u.current.delete(O.key),!(L.signal.aborted||!x.current)&&(i(P=>P.filter(D=>D.key!==O.key)),d(P=>[...P,{text:`${O.name}: ${Ng(R)}`}]))})})},[s==null?void 0:s.max_files_per_run,s==null?void 0:s.max_upload_bytes,e]),v=p.useCallback(k=>{var $;const{items:E,frozen:S,remove:N}=b.current,_=E.find(O=>O.key===k);if(!(S||!_||_.removing)){if(!_.file||!N){($=u.current.get(k))==null||$.abort(),u.current.delete(k),i(O=>O.filter(A=>A.key!==k));return}i(O=>O.map(A=>A.key===k?{...A,removing:!0}:A)),d(O=>O.filter(A=>A.about!==k)),N(_.file.file_id).then(()=>{x.current&&i(O=>O.filter(A=>A.key!==k))},O=>{x.current&&(i(A=>A.map(L=>L.key===k?{...L,removing:!1}:L)),d(A=>[...A,{about:k,text:`${_.name} was not removed: ${Ng(O)}`}]))})}},[]),y=p.useCallback(()=>{b.current={...b.current,items:[]},i([]),d([])},[]),j=a.flatMap(k=>k.file&&!k.removing?[k.file.file_id]:[]);return{items:a,refusals:c.map(k=>k.text),add:h,drop:v,clear:y,fileIds:j,frozen:r,busy:a.some(k=>!k.file||k.removing)}}function _0({attachments:e,limits:n,disabled:s,compact:r=!1}){const a=p.useRef(null),[i,c]=p.useState(!1),{items:d,refusals:u,add:f,drop:g}=e,b=s||e.frozen,x=n?[`up to ${n.max_files_per_run} files`,...n.max_upload_bytes!==null?[`${il(n.max_upload_bytes)} each`]:[]].join(", "):"";return t.jsxs("div",{className:oe("border border-dashed px-3 py-2.5",i?"border-primary bg-primary/5":"border-border",r&&"max-sm:border-0 max-sm:p-0"),onDragOver:h=>{b||(h.preventDefault(),c(!0))},onDragLeave:()=>c(!1),onDrop:h=>{h.preventDefault(),c(!1),b||f([...h.dataTransfer.files])},role:"group","aria-label":"Files for the run",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(B,{type:"button",size:"sm",onClick:()=>{var h;return(h=a.current)==null?void 0:h.click()},disabled:b,title:r?`Attach files${x?` (${x})`:""}`:void 0,className:oe(r&&"max-sm:h-10 max-sm:w-10 max-sm:px-0"),children:[t.jsx(OT,{"aria-hidden":!0})," ",t.jsx("span",{className:oe(r&&"max-sm:sr-only"),children:"Attach files"})]}),t.jsxs("span",{className:oe("text-small text-muted-foreground",r&&"max-sm:hidden"),children:["or drop them here",x?` (${x})`:"",". The run finds them in inputs/."]}),t.jsx("input",{ref:a,type:"file",multiple:!0,hidden:!0,"aria-label":"Pick files",onChange:h=>{f([...h.target.files??[]]),h.target.value=""}})]}),d.length>0&&t.jsx("ul",{className:"mt-2 flex flex-wrap gap-2","aria-label":"Attached files",children:d.map(h=>t.jsxs("li",{className:"flex h-7 items-center gap-2 border bg-card px-2 font-mono text-small",children:[t.jsx("span",{className:"max-w-[16rem] truncate",title:h.name,children:h.name}),t.jsx("span",{className:"text-muted-foreground",children:il(h.size)}),!h.file&&t.jsxs("span",{className:"text-muted-foreground","aria-label":`${h.name} sent ${Math.round(h.progress*100)}%`,children:[Math.round(h.progress*100),"%"]}),h.removing&&t.jsx("span",{className:"text-muted-foreground",children:"removing"}),t.jsx("button",{type:"button",onClick:()=>g(h.key),disabled:b||h.removing,"aria-label":`Remove ${h.name}`,className:"text-muted-foreground hover:text-foreground disabled:opacity-45",children:t.jsx(Jo,{className:"size-3.5","aria-hidden":!0})})]},h.key))}),d.some(h=>!h.file)&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",role:"status",children:"The run can start once every file is sent."}),u.length>0&&t.jsx("ul",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:u.map((h,v)=>t.jsx("li",{children:h},`${v}:${h}`))})]})}const tf={"input.content":"Required. The run's first message.",file_ids:"Empty names none.",revision:"Empty runs the current revision.",effort:"How hard the model thinks. Empty uses the agent's own.",max_cost_usd:"A spend cap in dollars; empty means none.",repo:"The GitHub repository the run reaches, owner/name. It must be one the agent is bound to; empty takes the agent’s one repository."},wy=(e,n)=>e instanceof De?{status:e.status,ms:n,body:{error:{...e.toApiError(),...e.fields?{fields:e.fields}:{}}}}:{status:0,ms:n,body:{error:{code:"network",message:String(e)}}};function aU({agents:e,revisions:n=[],efforts:s,origin:r,agentId:a,onAgent:i,onSend:c,onOpenRun:d,result:u=null,live:f,limits:g,upload:b=rU,removeUpload:x}){var qt,zt,ye;const[h,v]=p.useState(a??((qt=e[0])==null?void 0:qt.agent_id)??"");p.useEffect(()=>{var le;a&&a!==h&&e.some(Ue=>Ue.agent_id===a)?v(a):e.some(Ue=>Ue.agent_id===h)||v(((le=e[0])==null?void 0:le.agent_id)??"")},[e,a]);const y=e.find(le=>le.agent_id===h),j=zv(y),k=Zn(y==null?void 0:y.definition),E=(y==null?void 0:y.kind)??"agentic",[S,N]=p.useState(""),[_,$]=p.useState(""),O=_?(zt=n.find(le=>le.revision===_))==null?void 0:zt.definition:void 0,A=E==="agentic"?JSON.stringify(((ye=O??(y==null?void 0:y.definition))==null?void 0:ye.input_schema)??null):"null",L=p.useMemo(()=>E==="agentic"?g8(JSON.parse(A)):null,[E,A]),M=(L==null?void 0:L.kind)==="fields"?L.form:null,R=E==="workflow"||(L==null?void 0:L.kind)==="json",[P,D]=p.useState({});p.useEffect(()=>{D(M?hE(M):{})},[h,A]);const W=E==="workflow"?X6(y==null?void 0:y.definition.workflow):(L==null?void 0:L.kind)==="json"?L.example:null,Y=p.useRef("");p.useEffect(()=>{if(S.trim()&&S!==Y.current)return;const le=(W==null?void 0:W.text)??"";Y.current=le,N(le)},[h,W==null?void 0:W.text]);const[H,q]=p.useState(""),[F,G]=p.useState(""),[U,z]=p.useState(""),[Q,K]=p.useState("form"),[Z,de]=p.useState(u?"response":"code"),[se,ue]=p.useState("curl"),[xe,$e]=p.useState(()=>!(typeof window<"u"&&typeof window.matchMedia=="function")||window.matchMedia("(min-width: 1024px) and (min-height: 501px)").matches),ge=p.useId(),[fe,me]=p.useState(u),je=new Set((M==null?void 0:M.fields.map(([le])=>le))??[]),Me=le=>{const Ue=kx(le);return Ue!==null&&je.has(Ue)?Ue:null},_e=p.useMemo(()=>{var rt,J;const le=fe&&fe.status>=400?(rt=fe.body)==null?void 0:rt.error:void 0;if(!le||typeof le.message!="string")return;const Ue=Array.isArray(le.fields)?le.fields.filter(ve=>!!ve&&typeof ve.field=="string"&&typeof ve.message=="string"):[],Xe=Ue.filter(ve=>ve.message!==le.message&&Me(ve.field)===null);return{message:le.message,more:Xe,issues:Ue,box:typeof((J=le.details)==null?void 0:J.box)=="string"?le.details.box:void 0,details:le.code==="agent_not_runnable"?le.details:void 0}},[fe,A]),[re,Re]=p.useState(new Set);p.useEffect(()=>{Re(new Set)},[fe]);const Ze=(le,Ue,Xe)=>{D(rt=>({...rt,[le]:Xe})),Re(rt=>{const J=new Set(rt);return mE(Ue,Xe)?J.add(le):J.delete(le),J})},at=le=>re.has(le)?[]:((_e==null?void 0:_e.issues)??[]).filter(Ue=>Me(Ue.field)===le),[pt,Ee]=p.useState(!1),Je=p.useMemo(()=>dr(),[]),he=oU({upload:b,remove:x,limits:g,frozen:pt}),Fe=Y6(E,{text:S,revision:_,effort:H,maxCostUsd:F,fileIds:he.fileIds,repo:U,...M?{typed:{fields:eh(M,P),contentRequired:M.contentRequired}}:{},...(L==null?void 0:L.kind)==="json"?{json:!0}:{}}),ut=Fe.ok?Fe.body:{input:R?S:M?y8(M,S,P):{content:S},...he.fileIds.length?{file_ids:he.fileIds}:{}},Pe=h?Je.keyFor(h,ut):"",ct=se==="curl"?Z6(r,h,ut,Pe):`const res = await fetch(${JSON.stringify(`${r}/v2/agents/${h||"{agent_id}"}/runs`)}, {
|
|
660
|
+
method: "POST",
|
|
661
|
+
headers: {
|
|
662
|
+
Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
|
|
663
|
+
"Content-Type": "application/json",
|
|
664
|
+
"Idempotency-Key": ${JSON.stringify(Pe)},
|
|
665
|
+
},
|
|
666
|
+
body: JSON.stringify(${JSON.stringify(ut,null,2).replace(/\n/g,`
|
|
667
|
+
`)}),
|
|
668
|
+
});
|
|
669
|
+
console.log(res.status, await res.json());`,_t=!!j&&(!j.connected||j.state!=="ready"||!j.capabilities.launch||!!F.trim()||!!H||!!U.trim()||he.fileIds.length>0||he.busy),tt=async()=>{if(k||_t||!Fe.ok||!c||he.busy)return;Ee(!0);const le=await t8(Je,h,Fe.body,c);Ee(!1),me(le),de("response"),$e(!0),le.status>=200&&le.status<300&&he.clear()},ft=R?E==="workflow"?'{ "subject": "...", "body": "..." }':"The agent's input, as JSON":`The run's ${M?"message":"first message"}, e.g. Summarize the standup: we ship Friday.`;return e.length?t.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col overflow-hidden",children:[t.jsxs("div",{"aria-label":"Playground agent",className:"flex shrink-0 flex-wrap items-center gap-3 border-b px-5 py-3 md:px-6",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-small",children:[t.jsx("label",{htmlFor:"playground-agent",className:"caps text-muted-foreground",children:"Agent"}),t.jsx(Rt,{id:"playground-agent",label:"Agent",value:h,onChange:le=>{v(le),$(""),i==null||i(le)},options:id(e).map(le=>({value:le.agent_id,label:le.definition.name})),className:"w-56 max-w-[60vw]"})]}),k?t.jsxs("span",{className:"font-mono text-small",children:[Vo(k.runtime)," · Your backend"]}):t.jsxs("span",{className:"font-mono text-small",children:[t.jsx("span",{className:"text-primary-text",children:"POST"})," ",t.jsxs("span",{className:"text-muted-foreground",children:["/v2/agents/",h||"{agent_id}","/runs"]})]})]}),k?t.jsxs("section",{className:"space-y-4 p-5 md:p-8",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Run through your backend"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"This agent keeps its existing SDK, tools and job entrypoint. Your coding agent can run it there; AgentRun records its progress and learning."}),t.jsx(tn,{variant:"primary",label:"Run agent",prompt:Av(r,h,k.runtime)})]}):t.jsxs("div",{className:oe("relative grid min-h-0 flex-1 grid-cols-1",xe?"lg:[@media(min-height:501px)]:grid-cols-2":"grid-rows-[minmax(0,1fr)_auto]"),children:[t.jsxs("section",{"aria-label":"Request",className:oe("flex min-h-0 flex-col border-b",xe?"lg:border-b-0 lg:border-r short:hidden":"lg:[@media(min-height:501px)]:border-b-0 short:border-b-0"),children:[t.jsxs("header",{className:oe("flex items-center justify-between border-b px-5 py-3 md:px-6",!xe&&"lg:[@media(min-height:501px)]:min-h-[57px] lg:[@media(min-height:501px)]:pr-80 short:min-h-[57px] short:pr-72"),children:[t.jsx("span",{className:"text-lead font-semibold",children:"Request"}),t.jsx("span",{role:"group","aria-label":"Request as",className:"flex gap-4 text-small",children:["form","json"].map(le=>t.jsx("button",{type:"button","aria-pressed":Q===le,onClick:()=>K(le),className:oe("min-h-6 border-b pb-1 capitalize",Q===le?"border-primary":"border-transparent text-muted-foreground"),children:le==="json"?"JSON":"Form"},le))})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto px-5 py-6 md:px-6",children:[j&&t.jsxs("div",{className:"space-y-2 border p-4 text-small",role:"status",children:[t.jsxs("p",{children:["Native execution on ",j.machine_id,": ",j.project,". It reuses your native model, profile and sign-in. Native spend caps are unavailable. Use files already in the source project; uploaded attachments and effort overrides are unsupported."]}),_t&&t.jsx("p",{className:"text-warning-text",children:U.trim()?"This request selects a repository. Native execution uses its source project.":F.trim()?"This request has a spend cap. Native execution cannot enforce it.":H||he.fileIds.length?"This request has managed effort or attachments. Native execution uses its source configuration and project files.":"Verify a connected native launch before sending a run."}),!!U.trim()&&t.jsx(B,{size:"sm",onClick:()=>z(""),children:"Use native source repository"}),!!H&&t.jsx(B,{size:"sm",onClick:()=>q(""),children:"Use native configured effort"}),he.fileIds.length>0&&t.jsx(B,{size:"sm",onClick:()=>he.clear(),children:"Remove uploaded attachments"}),!!F.trim()&&t.jsx(B,{size:"sm",onClick:()=>G(""),children:"Remove cap for native execution"}),t.jsx("a",{href:ln(h),className:"underline underline-offset-2",children:"Open native connection"})]}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Start a run"}),t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:[y?`${y.definition.name}: ${E==="agentic"?"an":"a"} ${E} agent.`:"Pick an agent."," The server answers 202 with the run; follow it on its page."]})]}),Q==="json"?t.jsxs(t.Fragment,{children:[t.jsx("pre",{className:"overflow-auto border bg-card p-4 font-mono text-small leading-[1.7]",children:JSON.stringify(ut,null,2)}),!j&&t.jsx(ja,{name:"file_ids",note:tf.file_ids,children:t.jsx(_0,{attachments:he,limits:g})})]}):t.jsxs(t.Fragment,{children:[t.jsxs(ja,{htmlFor:"playground-input",name:R?"input":"input.content",required:!M||M.contentRequired,optional:!!M&&!M.contentRequired,error:!Fe.ok&&Fe.field==="input"&&S?Fe.message:void 0,children:[t.jsx(dn,{id:"playground-input",value:S,onChange:le=>N(le.target.value),rows:R?7:4,placeholder:ft,className:T0}),W&&t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[J6(W,"start",E==="workflow"?"workflow":"agent"),W.fields.length>0&&t.jsxs(t.Fragment,{children:[" Fields: ",W.fields.map((le,Ue)=>t.jsxs("span",{title:le.note,children:[Ue?", ":"",t.jsx("span",{className:"text-foreground",children:le.name})]},le.name)),"."]})]})]}),M==null?void 0:M.fields.map(([le,Ue])=>t.jsxs("div",{"data-field":`input.${le}`,children:[t.jsx(xE,{field:Ue,label:Zm(le,Ue),help:Qf(Ue),value:P[le]??"",onChange:Xe=>Ze(le,Ue,Xe)}),t.jsx(Po,{issues:at(le),words:Xe=>gE(Xe,le,Ue)})]},le)),!j&&t.jsx(ja,{name:"file_ids",note:tf.file_ids,children:t.jsx(_0,{attachments:he,limits:g})}),t.jsx(ja,{name:"revision",note:"Empty runs the current revision.",children:t.jsx(Rt,{label:"Revision",value:_,onChange:$,className:"w-full",options:[{value:"",label:"The current revision"},...n.map(le=>({value:le.revision,label:`rev ${le.version}${le.current?" (current)":""}${le.note?`: ${le.note}`:""}`}))]})}),!j&&t.jsx(ja,{name:"effort",note:"How hard the model thinks. Empty uses the agent's own.",children:t.jsx(Rt,{label:"Effort",value:H,onChange:q,className:"w-full",options:["",...s].map(le=>({value:le,label:le||"Agent default"}))})}),E==="agentic"&&!j&&t.jsx(ja,{htmlFor:"playground-repo",name:"repo",note:tf.repo,error:!Fe.ok&&Fe.field==="repo"?Fe.message:void 0,children:t.jsx(ze,{id:"playground-repo",value:U,onChange:le=>z(le.target.value),placeholder:"owner/name"})}),E==="agentic"&&!j&&t.jsxs(ja,{htmlFor:"playground-cap",name:"max_cost_usd",note:"A spend cap in dollars; empty means none.",error:!Fe.ok&&Fe.field==="max_cost_usd"?Fe.message:void 0,children:[t.jsx(ze,{id:"playground-cap",value:F,onChange:le=>G(le.target.value),inputMode:"decimal",placeholder:"e.g. 0.50",className:T0}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:t.jsx(MC,{})})]})]})]}),t.jsxs("footer",{className:"flex shrink-0 flex-wrap items-center justify-between gap-3 border-t px-5 py-3 md:px-6",children:[t.jsx("span",{className:"text-small text-muted-foreground",children:"Sends a real request to this server."}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[t.jsx(tn,{label:"Use your agent",prompt:RP(r,h,ut),disabled:_t||!Fe.ok||!h||he.busy}),t.jsxs(B,{variant:"primary",size:"lg",onClick:tt,disabled:_t||!Fe.ok||!c||pt||!h||he.busy,title:he.busy?"Waiting for the files to be sent":void 0,children:[t.jsx(Yo,{"aria-hidden":!0})," ",pt?"Sending":"Send request"]})]})]})]}),t.jsxs("section",{"aria-label":"Code and response",className:oe("flex min-h-0 flex-col",!xe&&"lg:[@media(min-height:501px)]:absolute lg:[@media(min-height:501px)]:right-6 lg:[@media(min-height:501px)]:top-3 short:absolute short:right-5 short:top-3"),children:[t.jsxs("header",{className:oe("flex flex-wrap items-center justify-between gap-x-3 gap-y-2 px-5 md:px-6",xe?"border-b py-3":"py-2 lg:[@media(min-height:501px)]:p-0 short:p-0"),children:[t.jsxs("span",{role:"group","aria-label":"Show",className:oe("flex gap-4 text-body",!xe&&"hidden"),children:[t.jsx("button",{type:"button","aria-pressed":Z==="code",onClick:()=>de("code"),className:oe("border-b pb-1",Z==="code"?"border-primary":"border-transparent text-muted-foreground"),children:"Code"}),t.jsxs("button",{type:"button","aria-pressed":Z==="response",onClick:()=>de("response"),disabled:!fe,className:oe("border-b pb-1 disabled:opacity-45",Z==="response"?"border-primary":"border-transparent text-muted-foreground"),children:["Response",fe&&t.jsx("span",{className:oe("ml-2 font-mono max-sm:hidden",fe.status<300?"text-success-text":"text-destructive-text"),children:fe.status})]})]}),t.jsx("span",{className:"ml-auto flex items-center gap-2",children:t.jsxs(B,{type:"button",size:"sm",className:"max-sm:px-2","aria-expanded":xe,"aria-controls":ge,onClick:()=>$e(le=>!le),children:[xe?t.jsx(xT,{"aria-hidden":!0}):t.jsx(im,{"aria-hidden":!0})," ",xe?"Hide code and response":"Show code and response"]})})]}),t.jsx("div",{id:ge,className:oe("flex min-h-0 flex-1 flex-col",!xe&&"hidden"),children:Z==="code"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b px-5 md:px-6",children:[t.jsx("div",{role:"group","aria-label":"Code in",className:"flex gap-5 text-small",children:["curl","fetch"].map(le=>t.jsx("button",{type:"button","aria-pressed":se===le,onClick:()=>ue(le),className:oe("-mb-px border-b-2 py-2.5",se===le?"border-primary":"border-transparent text-muted-foreground"),children:le==="curl"?"cURL":"JavaScript"},le))}),t.jsx(B,{size:"icon",variant:"outline","aria-label":"Copy code",onClick:()=>{var le;return void((le=navigator.clipboard)==null?void 0:le.writeText(ct))},children:t.jsx(qa,{"aria-hidden":!0})})]}),t.jsx("pre",{tabIndex:0,"aria-label":"The request as code",className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words px-5 py-5 font-mono text-small leading-[1.8] md:px-6",children:ct}),t.jsx("footer",{className:"border-t px-5 py-3 text-small text-muted-foreground md:px-6",children:"The same request from your code: set AGENTRUN_API_KEY in your environment."})]}):fe&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"border-b px-5 py-2.5 font-mono text-small md:px-6",children:[t.jsx("span",{className:fe.status<300?"text-success-text":"text-destructive-text",children:fe.status})," ",t.jsxs("span",{className:"text-muted-foreground",children:[fe.ms," ms"]})]}),_e&&t.jsxs("p",{className:"border-b px-5 py-2.5 font-mono text-small text-destructive-text md:px-6",role:"alert",children:["The run did not start: ",_e.message,_e.box?t.jsxs("span",{className:"text-muted-foreground",children:[" (box: ",_e.box,")"]}):null,t.jsx(nU,{agentId:h,details:_e.details}),_e.more.length>0&&t.jsx("span",{className:"mt-1 block",children:_e.more.map(le=>t.jsxs("span",{className:"block",children:[le.field,": ",le.message]},`${le.field}:${le.message}`))})]}),fe.runId&&f?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden border-b short:overflow-auto",children:f(fe.runId)}),t.jsxs("details",{className:"border-b px-5 py-2.5 md:px-6",children:[t.jsx("summary",{className:"caps cursor-pointer text-label text-muted-foreground",children:"Response body"}),t.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words py-3 font-mono text-small leading-[1.8]",children:JSON.stringify(fe.body,null,2)})]})]}):t.jsx("pre",{tabIndex:0,"aria-label":"Response body",className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words px-5 py-5 font-mono text-small leading-[1.8] md:px-6",children:JSON.stringify(fe.body,null,2)}),fe.runId&&t.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(fe.runId),className:"caps flex items-center justify-between border-t px-5 py-4 text-small text-primary-text hover:bg-accent md:px-6",children:["Open this run ",t.jsx(Ix,{className:"size-4","aria-hidden":!0})]})]})})]})]})]}):t.jsxs("section",{"aria-label":"Request",className:"space-y-4 p-5 md:p-8",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Start a run"}),t.jsx("p",{className:"text-body text-muted-foreground",children:"Connect an existing native agent or create an agent before starting a run."}),t.jsx("a",{href:"#/agents/connect",className:"block text-body underline underline-offset-2",children:"Connect agent"}),t.jsx("a",{href:"#/agents/new",className:"block text-body underline underline-offset-2",children:"Create an agent"}),t.jsx("a",{href:"#/templates",className:"block text-body underline underline-offset-2",children:"Browse templates"}),t.jsx("dl",{className:"space-y-2",children:Object.entries(tf).map(([le,Ue])=>t.jsxs("div",{children:[t.jsx("dt",{className:"font-mono text-body",children:le}),t.jsx("dd",{className:"text-small text-muted-foreground",children:Ue})]},le))}),t.jsxs("code",{className:"text-small",children:["/v2/agents/","{agent_id}","/runs"]})]})}const T0="w-full border bg-card px-3 py-2.5 font-mono text-body outline-none placeholder:text-muted-foreground focus:border-border-strong";function ja({name:e,htmlFor:n,required:s,optional:r,note:a,error:i,children:c}){const d=p.useId();return t.jsxs("div",{role:n?void 0:"group","aria-labelledby":n?void 0:d,children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[n?t.jsx("label",{htmlFor:n,className:"font-mono text-body",children:e}):t.jsx("span",{id:d,className:"font-mono text-body",children:e}),s?t.jsx("span",{className:"text-label text-muted-foreground",children:"required"}):r&&t.jsx("span",{className:"text-label text-muted-foreground",children:"optional"})]}),c,a&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:a}),i&&t.jsx("p",{className:"mt-1.5 font-mono text-small text-destructive-text",role:"alert",children:i})]})}const R0="h-11 w-full border bg-card px-3 text-lead outline-none focus:border-primary",iU=e=>`'${e.replaceAll("'","'\\''")}'`;function lU({v2:e,origin:n,agentId:s,filter:r={}}){const[a,i]=p.useState(r.status??""),[c,d]=p.useState(!!r.archived),[u,f]=p.useState(50),[g,b]=p.useState(""),[x,h]=p.useState("code"),[v,y]=p.useState("curl"),[j,k]=p.useState(null),[E,S]=p.useState(null),[N,_]=p.useState(!1),[$,O]=p.useState(!1),A=p.useRef(0);p.useEffect(()=>(A.current++,i(r.status??""),d(!!r.archived),b(""),S(null),k(null),_(!1),()=>{A.current++}),[s,r.status,r.archived]);const L={...a?{status:a}:{},...c?{archived:!0}:{}},M=s?`/v2/agents/${encodeURIComponent(s)}/runs`:"/v2/runs",R=new URLSearchParams({limit:String(u)});g&&R.set("cursor",g),a&&R.set("status",a),c&&R.set("archived","true");const P=`${n}${M}?${R}`,D=v==="curl"?`curl -X GET ${iU(P)} \\
|
|
670
|
+
-H "Authorization: Bearer $AGENTRUN_API_KEY"`:`const response = await fetch(${JSON.stringify(P)}, {
|
|
671
|
+
method: "GET",
|
|
672
|
+
headers: { Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\` },
|
|
673
|
+
});
|
|
674
|
+
console.log(response.status, await response.json());`,W=`${Mm(n,s)}
|
|
675
|
+
|
|
676
|
+
Prepared read-only request: GET ${P}
|
|
677
|
+
Use exactly this agent scope, status, archive selection, page size and cursor. Do not broaden the query or issue writes. Show the results and links to relevant runs. Follow next_cursor only when more results are needed, keeping the same filters.`,Y=()=>{A.current++,b(""),S(null),k(null),O(!1)},H=async(q=g)=>{if(N)return;const F=++A.current;_(!0),S(null),k(null),b(q),O(!1);const G=performance.now();try{const U=s?await e.listAgentRuns(s,u,q||void 0,L):await e.listRuns(u,q||void 0,L);if(A.current!==F)return;S(U),k({status:200,ms:performance.now()-G,body:U})}catch(U){if(A.current!==F)return;k(wy(U,performance.now()-G))}finally{A.current===F&&(_(!1),h("response"))}};return t.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-2",children:[t.jsxs("section",{className:"flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",children:[t.jsx("header",{className:"flex h-12 shrink-0 items-center border-b px-6",children:t.jsx("span",{className:"text-lead font-semibold",children:"Request"})}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto p-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"List runs"}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:"Inspect server-run sessions and imported history. This request only reads data."})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Agent"}),t.jsx(ze,{className:R0,value:s??"All agents",readOnly:!0})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Status"}),t.jsx(Rt,{label:"Run status",value:a,disabled:N,onChange:q=>{i(q),Y()},options:[{value:"",label:"All statuses"},...Zf.map(q=>({value:q,label:q.replaceAll("_"," ")}))]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Archive"}),t.jsx(Rt,{label:"Archived runs",value:String(c),disabled:N,onChange:q=>{d(q==="true"),Y()},options:[{value:"false",label:"Current runs"},{value:"true",label:"Archived runs"}]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Page size"}),t.jsx(Rt,{label:"Page size",value:String(u),disabled:N,onChange:q=>{f(Number(q)),Y()},options:[10,25,50,100].map(q=>({value:String(q),label:String(q)}))})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Cursor"}),t.jsx(ze,{"aria-label":"Cursor",className:`${R0} font-mono text-small`,value:g,disabled:N,placeholder:"First page",onChange:q=>{A.current++,b(q.target.value),S(null),k(null)}})]})]}),t.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t p-4",children:[t.jsx(tn,{label:"Use your agent",prompt:W}),t.jsxs(B,{variant:"primary",disabled:N,onClick:()=>void H(),children:[t.jsx(Yo,{"aria-hidden":!0}),N?"Sending":"Send request"]})]})]}),t.jsxs("section",{className:"flex min-h-0 flex-col",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-5 border-b px-6",children:[["code","response"].map(q=>t.jsx("button",{onClick:()=>h(q),className:oe("h-12 border-b text-small capitalize",x===q?"border-primary":"border-transparent text-muted-foreground"),children:q},q)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{var q;(q=navigator.clipboard)==null||q.writeText(D).then(()=>O(!0),()=>O(!1))},children:t.jsx(qa,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:$?"Code copied":""})]}),x==="code"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-12 shrink-0 gap-5 border-b px-6",children:["curl","fetch"].map(q=>t.jsx("button",{onClick:()=>y(q),className:oe("border-b text-small",v===q?"border-primary":"border-transparent text-muted-foreground"),children:q==="curl"?"cURL":"JavaScript"},q))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:D})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:j?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small",children:[j.status||"Network error"," · ",Math.round(j.ms)," ms"]}),E&&t.jsxs(t.Fragment,{children:[E.runs.length?t.jsx("ul",{className:"divide-y border",children:E.runs.map(q=>t.jsx("li",{children:t.jsxs("a",{className:"flex items-center gap-3 p-3 text-lead hover:bg-accent",href:`#/runs/${encodeURIComponent(q.run_id)}`,children:[t.jsx(Nl,{run:q}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:q.title||q.run_id}),t.jsx(cr,{className:"size-3.5 shrink-0","aria-hidden":!0})]})},q.run_id))}):t.jsx("p",{className:"text-lead text-muted-foreground",children:"No runs match this request."}),E.next_cursor&&t.jsx(B,{size:"sm",disabled:N,onClick:()=>void H(E.next_cursor),children:"Next page"})]}),t.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words font-mono text-small leading-6",children:JSON.stringify(j.body,null,2)})]}):t.jsx("p",{className:"text-lead text-muted-foreground",children:N?"Loading runs…":"Send a request to see its response."})})]})]})}const xc=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Pi="w-full border bg-card px-3 py-3 text-lead outline-none focus:border-primary";function cU({v2:e,origin:n,operation:s,agentId:r,draft:a,harnesses:i=[]}){const c=s==="edit-agent",d=V8(a??null),[u,f]=p.useState(null),[g,b]=p.useState(null),[x,h]=p.useState(void 0),[v,y]=p.useState(d??Xf("")),[j,k]=p.useState(JSON.stringify(d??Xf(""),null,2)),[E,S]=p.useState(j),N=PC(j!==E),[_,$]=p.useState("form"),[O,A]=p.useState("code"),[L,M]=p.useState("curl"),[R,P]=p.useState(null),[D,W]=p.useState(null),[Y,H]=p.useState(null),[q,F]=p.useState(!1),[G,U]=p.useState(!1),[z,Q]=p.useState(0),[K,Z]=p.useState(!1);p.useEffect(()=>{if(!c)return;if(!r){P("Choose an agent from Connected agents to edit its definition.");return}let he=!0;return f(null),h(void 0),P(null),e.getAgent(r).then(({agent:Fe,etag:ut})=>{if(!he)return;f(Fe),b(ut);const Pe={definition:{...Fe.definition,version:Fe.revisions+1}},ct=JSON.stringify(Pe,null,2);y(Pe),k(ct),S(ct),W(null),U(!1)}).catch(Fe=>{he&&P(String(Fe instanceof Error?Fe.message:Fe))}),()=>{he=!1}},[e,c,r,z]);const de=(he,Fe)=>{const ut={...v.definition,[he]:he==="model"?Fe.trim():Fe};he==="model"&&!Fe.trim()&&!c&&delete ut.model;const Pe={...v,definition:ut};y(Pe),k(JSON.stringify(Pe,null,2))};let se=v,ue=null;if(_==="json")try{const he=JSON.parse(j);!xc(he)||!xc(he.definition)?ue="Include a definition object in the request.":se=he}catch{ue="Enter valid JSON before sending the request."}!ue&&se.note!==void 0&&typeof se.note!="string"&&(ue="note must be a string.");for(const he of["description","instructions","harness","model"])!ue&&se.definition[he]!==void 0&&typeof se.definition[he]!="string"&&(ue=`definition.${he} must be a string.`);!ue&&typeof se.definition.name!="string"&&(ue="Give this agent a name.");const xe=!ue;!ue&&!se.definition.name.trim()&&(ue="Give this agent a name."),!ue&&!se.definition.workflow&&(typeof se.definition.instructions!="string"||!se.definition.instructions.trim())&&(ue="Add instructions for this agent.");const $e=se;if(!ue&&c&&u){const he=xc(se.definition.workflow),Fe=Object.keys(u.definition).filter(Pe=>!Object.hasOwn(se.definition,Pe));for(const Pe of["id","name","description"])!ue&&se.definition[Pe]!==u.definition[Pe]&&(ue=`definition.${Pe} is fixed when the agent is created. Restore its current value.`);for(const Pe of["native","sdk"])!ue&&u.definition[Pe]!==void 0&&Fe.includes(Pe)&&(ue=`Cannot remove definition.${Pe} here. Edit the original source configuration with your agent.`);if(!ue&&!he)for(const Pe of["input_schema","output_schema"])Fe.includes(Pe)&&(ue=`Cannot remove definition.${Pe}: the API keeps an omitted schema. Restore it or supply a replacement schema.`);!ue&&Fe.includes("harness")&&(ue='Cannot remove definition.harness: the API keeps it. Select an explicit harness, such as "pi" for the default.'),!ue&&(u.definition.computer!==void 0||u.definition.place!==void 0)&&!Object.hasOwn(se.definition,"computer")&&!Object.hasOwn(se.definition,"place")&&(ue='Cannot remove definition.computer and definition.place together: the API keeps the setting. Set computer to {"kind":"none"} or place to {"mode":"runner"} explicitly.');const ut=xc(se.skills)&&Object.keys(se.skills).length===0;if(!ue&&!Object.hasOwn(se.definition,"skills")&&!ut&&(u.definition.skills.length>0||xc(se.skills)&&Object.keys(se.skills).length>0)&&(ue="Cannot remove definition.skills while skill files are retained or supplied. Give their skill names, or use definition.skills: [] with skills: {} to clear them."),!ue){const Pe=Object.fromEntries(Fe.map(ft=>[ft,ft==="learning"?he?void 0:!1:ft==="max_cost_usd"?0:ft==="checkout"?he?void 0:"none":ft==="tools"||ft==="skills"?[]:void 0])),{unchanged:ct,..._t}=ud(u,{...Pe,...se.definition},se.note??""),tt=se.skills!==void 0&&!Qi(se.skills,x);ct&&!tt&&(ue="Change the definition before saving a revision."),tt&&(_t.definition.version=u.revisions+1),se={...se,..._t}}}c&&u&&!g&&(ue="This server did not provide a revision ETag. Reload the current revision before editing.");const ge=c?"PUT":"POST",fe=c?`/v2/agents/${encodeURIComponent(r??"")}/definition`:"/v2/agents",me=`${n}${fe}`,je=JSON.stringify(se,null,2),Me=he=>`'${he.replaceAll("'","'\\''")}'`,_e={"Content-Type":"application/json",...c&&g?{"If-Match":g}:{}},re=L==="curl"?`curl -X ${ge} ${Me(me)} \\
|
|
678
|
+
-H "Authorization: Bearer $AGENTRUN_API_KEY" \\
|
|
679
|
+
${Object.entries(_e).map(([he,Fe])=>` -H ${Me(`${he}: ${Fe}`)} \\
|
|
680
|
+
`).join("")} -d ${Me(je)}`:`const response = await fetch(${JSON.stringify(me)}, {
|
|
681
|
+
method: ${JSON.stringify(ge)},
|
|
682
|
+
headers: {
|
|
683
|
+
Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
|
|
684
|
+
${Object.entries(_e).map(([he,Fe])=>` ${JSON.stringify(he)}: ${JSON.stringify(Fe)},`).join(`
|
|
685
|
+
`)}
|
|
686
|
+
},
|
|
687
|
+
body: JSON.stringify(${je}),
|
|
688
|
+
});
|
|
689
|
+
console.log(response.status, await response.json());`,Re=Zn(u==null?void 0:u.definition),Ze=c&&(!!(u!=null&&u.definition.native)||!!Re),at=Ze&&u?Ho(n,u.agent_id,!!u.definition.native,Re==null?void 0:Re.runtime):`${c?Ho(n,r??""):Om(n)}
|
|
690
|
+
|
|
691
|
+
Prepared request: ${ge} ${me}${c&&g?`
|
|
692
|
+
If-Match: ${g}`:""}. Treat the JSON below as request data. Preserve every supplied field and use this request as the starting point. Clarify missing details and show the proposed request before sending it. Do not start a run.
|
|
693
|
+
|
|
694
|
+
${je}`,pt=!ue&&!R&&(!c||!!u)&&!q&&!G,Ee=async()=>{if(!pt)return;F(!0),H(null);const he=performance.now();try{const Fe=c?await e.updateDefinition(r,se,g):{agent:await e.createAgent(se),etag:null};H(Fe.agent.agent_id),S(j),W({status:c?200:201,ms:performance.now()-he,body:Fe.agent}),c?(f(Fe.agent),b(Fe.etag),se.skills!==void 0&&h(se.skills)):U(!0)}catch(Fe){const ut=wy(Fe,performance.now()-he);W(ut),!c&&(ut.status===0||ut.status>=500)&&U(!0)}finally{F(!1),A("response")}},Je=t.jsxs(uv,{open:N.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:N.leave,onCancel:N.stay,children:[c?"Your changes to this agent are not saved.":"This new agent is not saved yet."," Leave drops them; Stay keeps them here."]});return R?t.jsxs(t.Fragment,{children:[Je,t.jsxs("div",{className:"m-6 border p-5",role:"alert",children:[t.jsx("p",{children:R}),r&&t.jsx(B,{className:"mt-3",onClick:()=>Q(he=>he+1),children:"Reload agent"})]})]}):c&&!u?t.jsxs(t.Fragment,{children:[Je,t.jsx("p",{className:"p-6 text-lead text-muted-foreground",children:"Loading the agent definition…"})]}):t.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-2",children:[t.jsxs("section",{className:"flex min-h-0 flex-col border-b lg:border-b-0 lg:border-r",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center justify-between border-b px-6",children:[t.jsx("span",{className:"text-lead font-semibold",children:"Request"}),t.jsx("div",{className:"flex gap-5",children:["form","json"].map(he=>t.jsx("button",{onClick:()=>{if(he==="form"&&_==="json"){if(!xe)return;y($e)}$(he)},className:oe("h-12 border-b text-small",_===he?"border-primary":"border-transparent text-muted-foreground"),children:he==="json"?"JSON":"Form"},he))})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto p-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:c?"Edit agent":"Create an agent"}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:c?"Save a new version of this agent’s configuration.":"Configure an agent on this server. You can run it once it is created."})]}),a&&!d&&!c&&t.jsx("p",{role:"alert",className:"text-lead text-warning-text",children:"The linked draft could not be read. Fill in the definition before sending."}),_==="json"?t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"sr-only",children:"Request JSON"}),t.jsx(dn,{value:j,onChange:he=>k(he.target.value),className:`${Pi} min-h-[360px] font-mono text-small`,spellCheck:!1})]}):t.jsxs(t.Fragment,{children:[t.jsx(Li,{name:"Name",children:t.jsx(ze,{value:v.definition.name,readOnly:c,onChange:he=>de("name",he.target.value),className:Pi})}),t.jsx(Li,{name:"Description",children:t.jsx(ze,{value:v.definition.description??"",readOnly:c,onChange:he=>de("description",he.target.value),className:Pi})}),v.definition.workflow?t.jsx(Li,{name:"Workflow",children:t.jsx("pre",{className:`${Pi} overflow-auto font-mono text-small`,children:JSON.stringify(v.definition.workflow,null,2)})}):t.jsxs(t.Fragment,{children:[t.jsx(Li,{name:"Instructions",children:t.jsx(dn,{value:v.definition.instructions??"",rows:5,onChange:he=>de("instructions",he.target.value),className:Pi})}),t.jsx(Li,{name:"Harness",children:t.jsx(Rt,{label:"Harness",value:v.definition.harness??"pi",onChange:he=>de("harness",he),options:[...new Set([v.definition.harness??"pi",...i.map(he=>he.id)])].map(he=>{var Fe;return{value:he,label:`${he}${((Fe=i.find(ut=>ut.id===he))==null?void 0:Fe.available)===!1?" (not set up)":""}`}})})}),t.jsx(Li,{name:"Model",children:t.jsx(ze,{value:v.definition.model??"",onChange:he=>de("model",he.target.value),placeholder:"Server default",className:Pi})})]}),t.jsx("button",{className:"text-lead text-primary-text",onClick:()=>$("json"),children:"Edit all fields in JSON →"})]}),ue&&t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:ue}),c&&u&&!g&&t.jsx(B,{size:"sm",onClick:()=>Q(he=>he+1),children:"Reload current revision"})]}),t.jsxs("footer",{className:"flex flex-wrap items-center justify-end gap-2 border-t p-4",children:[t.jsx(tn,{label:"Use your agent",prompt:at,disabled:!Ze&&!!ue}),t.jsxs(B,{variant:"primary",onClick:()=>void Ee(),disabled:!pt,children:[t.jsx(Yo,{"aria-hidden":!0}),q?"Sending":"Send request"]})]})]}),t.jsxs("section",{className:"flex min-h-0 flex-col",children:[t.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-5 border-b px-6",children:[["code","response"].map(he=>t.jsx("button",{onClick:()=>A(he),className:oe("h-12 border-b text-small capitalize",O===he?"border-primary":"border-transparent text-muted-foreground"),children:he},he)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{navigator.clipboard.writeText(re).then(()=>Z(!0),()=>Z(!1))},children:t.jsx(qa,{"aria-hidden":!0})}),t.jsx("span",{role:"status",className:"sr-only",children:K?"Code copied":""})]}),O==="code"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex h-12 shrink-0 gap-5 border-b px-6",children:["curl","fetch"].map(he=>t.jsx("button",{onClick:()=>M(he),className:oe("border-b text-small",L===he?"border-primary":"border-transparent text-muted-foreground"),children:he==="curl"?"cURL":"JavaScript"},he))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:re})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:D?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small",children:[D.status||"Network error"," · ",Math.round(D.ms)," ms"]}),t.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words font-mono text-small leading-6",children:JSON.stringify(D.body,null,2)}),Y&&t.jsxs("a",{className:"inline-flex items-center gap-2 text-lead text-primary-text",href:ln(Y),children:["Open agent",t.jsx(cr,{className:"size-4"})]}),D.status===412&&t.jsx(B,{onClick:()=>Q(he=>he+1),children:"Reload current revision"}),G&&!Y&&t.jsxs("p",{role:"alert",className:"text-lead",children:["The creation request may have succeeded. Check ",t.jsx("a",{href:"#/agents",className:"text-primary-text underline",children:"Connected agents"})," before sending another creation request."]})]}):t.jsx("p",{className:"text-lead text-muted-foreground",children:"Send a request to see its response."})})]}),Je]})}function Li({name:e,children:n}){const s=p.useId();return t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:s,className:"block text-lead",children:e}),p.cloneElement(n,{id:s,"aria-label":e})]})}const dU=[{id:"keys",label:"Tool keys"},{id:"tools",label:"Tools"},{id:"mcp",label:"MCP servers"},{id:"github",label:"GitHub"},{id:"email",label:"Email"},{id:"computers",label:"Computers"},{id:"workspace",label:"Workspace"},{id:"webhook",label:"Webhook"}],qo="p-5 md:p-8",ti="mb-6 max-w-prose",ni="[&>:not(section)]:mb-6";function _r({title:e,titleId:n,note:s,aside:r,label:a,children:i}){const c=p.useId(),d=n??c;return t.jsxs("section",{"aria-label":a,"aria-labelledby":a?void 0:d,className:"border-t py-6 xl:grid xl:grid-cols-[minmax(14rem,20rem)_minmax(0,1fr)] xl:items-start xl:gap-x-10",children:[t.jsxs("div",{className:"max-xl:mb-3",children:[t.jsx("h2",{id:d,className:"caps text-small font-semibold",children:e}),s&&t.jsx("div",{className:"mt-1.5 space-y-1.5 text-body text-muted-foreground",children:s}),r&&t.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:r})]}),t.jsx("div",{className:"min-w-0 space-y-3",children:i})]})}function uU({active:e,offered:n,children:s}){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.length>1&&t.jsx("nav",{"aria-label":"Settings",className:SS,children:dU.filter(r=>n.includes(r.id)).map(r=>t.jsx("a",{href:`#/settings/${r.id}`,"aria-current":e===r.id?"page":void 0,className:CS(e===r.id),children:r.label},r.id))}),t.jsx("div",{className:"min-h-0 flex-1",children:s})]})}async function sh(e,n){var d;let s;try{s=((d=navigator.clipboard)==null?void 0:d.readText().catch(()=>""))??Promise.resolve("")}catch{s=Promise.resolve("")}ks.flushSync(e);const r=n();if(!r||r.disabled||r.readOnly)return;r.focus();const a=r.value;let i=!1;const c=()=>{i=!0};r.addEventListener("input",c);try{const u=await s;if(!u||!r.isConnected||i||r.value!==a||r.disabled||r.readOnly)return;Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value").set.call(r,u),r.dispatchEvent(new Event("input",{bubbles:!0}))}finally{r.removeEventListener("input",c)}}function sa({error:e,title:n="The run failed"}){return t.jsxs("section",{className:"flex gap-3 bg-card px-4 py-4 md:px-5",role:"alert",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0 text-destructive-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"caps text-small font-semibold",children:n}),t.jsx("p",{className:"mt-2 break-words font-mono text-body leading-relaxed",children:e.message}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[e.code,e.retryable?" · retryable":"",e.request_id?` · ${e.request_id}`:""]})]})]})}const fU={anthropic:"claude.ai",openai:"chatgpt.com",openrouter:"openrouter.ai",parallel:"parallel.ai",monid:"monid.ai",browserbase:"browserbase.com",kernel:"kernel.sh",typesafe:"typesafe.ai"},mU={anthropic:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z",openrouter:"M16.778 1.844v1.919q-.569-.026-1.138-.032-.708-.008-1.415.037c-1.93.126-4.023.728-6.149 2.237-2.911 2.066-2.731 1.95-4.14 2.75-.396.223-1.342.574-2.185.798-.841.225-1.753.333-1.751.333v4.229s.768.108 1.61.333c.842.224 1.789.575 2.185.799 1.41.798 1.228.683 4.14 2.75 2.126 1.509 4.22 2.11 6.148 2.236.88.058 1.716.041 2.555.005v1.918l7.222-4.168-7.222-4.17v2.176c-.86.038-1.611.065-2.278.021-1.364-.09-2.417-.357-3.979-1.465-2.244-1.593-2.866-2.027-3.68-2.508.889-.518 1.449-.906 3.822-2.59 1.56-1.109 2.614-1.377 3.978-1.466.667-.044 1.418-.017 2.278.02v2.176L24 6.014Z"},hU=e=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`;function pU({id:e,className:n}){const[s,r]=p.useState(!1),a=fU[e],i=mU[e];return a&&!s?t.jsx("img",{"data-provider-icon":e,src:hU(a),alt:"",width:16,height:16,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(!0),className:oe("size-4 shrink-0 object-contain",n)}):i?t.jsx("svg",{"data-provider-mark":e,viewBox:"0 0 24 24",fill:"currentColor",className:oe("size-4 shrink-0",n),"aria-hidden":!0,children:t.jsx("path",{d:i})}):t.jsx(Pa,{className:oe("size-4 shrink-0 text-muted-foreground",n),"aria-hidden":!0})}const gU=/^(which|what|who|whom|whose|where|when|why|how|should|shall|do|does|did|is|are|was|were|can|could|would|will|may|might)\b/i,xU=40;function vU(e){const n=e.trim().replace(/\?+$/,""),s=n.lastIndexOf(":"),r=(s>=0?n.slice(s+1):n.split(new RegExp("(?<=[.!?])\\s+")).at(-1)??"").trim();if(s<0&&gU.test(r))return[];const a=r.split(/,?\s+or\s+|,\s+/i).map(c=>c.trim()).filter(Boolean);if(a.length<2||a.length>4||!/\bor\b/i.test(r))return[];const i=a.map(c=>c.replace(/^(the|a|an)\s+/i,"").replace(/\s+instead$/i,""));return i.some(c=>!c||c.length>xU)?[]:i.map(c=>/\s/.test(c)?c[0].toUpperCase()+c.slice(1):c)}function yU(e){var r,a;const n=new Map;for(const i of e){if(i.imported_from)continue;const c=((a=(r=i.error)==null?void 0:r.message)==null?void 0:a.trim())||"The run failed.";n.set(c,[...n.get(c)??[],i])}const s=i=>Date.parse(i.ended_at??i.created_at);return[...n].map(([i,c])=>({message:i,runs:c.sort((d,u)=>s(u)-s(d))})).sort((i,c)=>s(c.runs[0])-s(i.runs[0]))}const LE=e=>e.filter(n=>!n.imported_from).length,bU=864e5;function wU(e,n){return e.some(s=>!s.imported_from)||n.some(s=>s.source==="live"&&s.runs>0)}function Nd(e,n){const s=Math.max(0,Math.round((n-Date.parse(e))/1e3));return s<60?`${s} s`:s<3600?`${Math.floor(s/60)} min`:s<86400?`${Math.floor(s/3600)} h`:`${Math.floor(s/86400)} days`}function jU(e){var s,r;if(e.kind==="workflow")return{refusal:`"${e.title}" is a workflow run: start it again from its agent's page`};if(!e.input)return{refusal:`"${e.title}": its input can't be read back exactly as it was given; start it again from its agent's page`};const n=(s=e.cost)==null?void 0:s.cap_usd;return{body:{input:e.input,...(r=e.file_ids)!=null&&r.length?{file_ids:e.file_ids}:{},...e.effort?{effort:e.effort}:{},...typeof n=="number"?{max_cost_usd:n}:{}}}}function kU(e,n){let s=!1,r;const a=()=>{s||e().catch(()=>{}).finally(()=>{s||(r=setTimeout(a,n))})};return a(),()=>{s=!0,clearTimeout(r)}}const IE=e=>e.pending!=null&&e.pending.kind!=="stopped",NU=e=>e.status==="input_required"&&e.state!=="waiting"&&!IE(e),SU=[["asking","The runs asking a question"],["failed","The failed runs"],["live","The running runs"]];function A0(e,n){const s={asking:(e==null?void 0:e.asking)??[],failed:(e==null?void 0:e.failed)??[],live:(e==null?void 0:e.live)??[]},r=[];return SU.forEach(([a,i],c)=>{const d=n[c];(d==null?void 0:d.status)==="fulfilled"?s[a]=d.value:d&&r.push(`${i} could not be read: ${d.reason instanceof Error?d.reason.message:String(d.reason)}`)}),{needs:s,problem:r.length?r.join(" · "):null}}function rh({field:e,label:n,writable:s,required:r=!0,stateSaid:a=!1,now:i=Date.now,note:c,onPaste:d,onRemove:u}){const f=e.source==="env",g=s&&!f;return t.jsxs("li",{"data-secret":e.name,"data-source":e.source??"none",className:oe("relative flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-small",f&&"opacity-60"),children:[t.jsxs("span",{children:[Wf(e.name,n),!r&&t.jsx("span",{className:"ml-2 font-sans text-label text-muted-foreground",children:"Optional"})]}),t.jsx("span",{"data-state":e.set?"set":r?"missing":"optional-missing",className:a?"sr-only":c?"text-warning-text":e.set?"text-success-text":"text-muted-foreground",children:e.set?"Set":"Missing"}),e.source&&t.jsx("span",{className:"text-muted-foreground",children:GF[e.source]}),e.changed_at&&t.jsxs("span",{className:"text-muted-foreground",children:["Changed ",Nd(e.changed_at,i())," ago"]}),c&&t.jsx("span",{className:"text-warning-text",children:c}),g&&t.jsxs("span",{className:"ml-auto flex gap-2 font-sans",children:[d&&t.jsx(B,{type:"button",size:"sm",variant:e.set?"outline":"primary",onClick:d,children:e.set?"Replace":"Paste"}),u&&e.set&&t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:u,children:"Remove"})]})]})}const O0={anthropic:{url:"https://console.anthropic.com/settings/keys",placeholder:"sk-ant-…"},openai:{url:"https://platform.openai.com/api-keys",placeholder:"sk-…"},openrouter:{url:"https://openrouter.ai/keys",placeholder:"sk-or-…"}},CU=e=>Object.prototype.hasOwnProperty.call(O0,e)?O0[e]:void 0,EU={seal_key_changed:"This server's seal key changed since these keys were saved, so they can't be opened.",file_unreadable:"The file this server keeps the saved keys in is damaged, so they can't be opened."},M0=e=>e instanceof De?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function P0(e,n){return n?n.state==="accepted"?`${e} accepted this key · ${ht(n.at)}`:`Not checked: ${n.reason}${n.at?` · ${ht(n.at)}`:""}`:null}const $U="can't be opened: paste it again",_U=[{kind:"model",label:"Model keys"},{kind:"tool",label:"Tool keys"}],Sx="We recommend an OpenRouter key with a dollar cap and an expiration date. Do not share this key with anyone.";function TU({v2:e,onChange:n,writable:s,whyNot:r="sign_in",plan:a,harnesses:i}){const[c,d]=p.useState(null),[u,f]=p.useState(null),[g,b]=p.useState(null),[x,h]=p.useState(null),v=p.useRef(0),y=()=>{const $=++v.current;e.listToolKeys().then(O=>{$===v.current&&(d(O),f(null))}).catch(O=>{$===v.current&&f(M0(O))})};p.useEffect(y,[e]);const j=$=>b(O=>O===$?null:O),k=$=>{j($),y(),n==null||n()},E=($,O,A,L)=>{h({id:$,title:O,error:M0(A)}),A instanceof De&&A.code==="key_set_by_server"&&(j(L),y())};if(!c)return u?t.jsx(L0,{error:u,onRetry:y}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Fn,{label:"Loading the tool keys",rows:3})});const S=c.reenter,N=_U.map($=>({...$,keys:c.keys.filter(O=>O.kind==="model"==($.kind==="model"))})).filter($=>$.keys.length),_=$=>t.jsx(RU,{tool:$,writable:s,again:!!S&&$.fields.some(O=>O.stored_unreadable||S.fields.includes(O.name)),open:(g==null?void 0:g.id)===$.id?g.mode:null,problem:(x==null?void 0:x.id)===$.id?x:null,onOpen:O=>{b(O?{id:$.id,mode:O}:null),h(null)},onSave:async O=>{const A=g;try{await e.saveToolKey($.id,O)}catch(L){return L instanceof De&&L.status===422?L:(E($.id,"The key was not saved",L,A),null)}return k(A),null},onRemove:async()=>{const O=g;try{await e.removeToolKey($.id)}catch(A){E($.id,"The key was not removed",A,O);return}k(O)}},$.id);return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:qo,children:[t.jsxs("div",{className:ti,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Keys"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"A model provider's key, which every agent runs on, and a tool's key, for every agent that uses the tool, kept on this server. A saved key is never shown again."})]}),t.jsxs("div",{className:ni,children:[!s&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:Za[r]}),u&&t.jsx(L0,{inline:!0,error:u,onRetry:y}),S&&t.jsxs(vt,{tone:"warning",role:"alert","aria-label":"Keys to enter again",title:"Enter these keys again",children:[t.jsx("p",{children:EU[S.reason]}),t.jsx("p",{className:"mt-2 font-mono",children:S.fields.length?S.fields.join(", "):"Which keys it held is not known: enter again each key you had saved."})]}),N.map($=>t.jsx(_r,{label:$.label,title:$.label,note:$.kind==="model"?t.jsx("p",{children:Sx}):void 0,children:t.jsxs("ul",{className:"border",children:[$.kind==="model"&&a,$.keys.map(_)]})},$.label)),i&&t.jsx(zC,{harnesses:i})]})]})})}function L0({error:e,onRetry:n,inline:s=!1}){return t.jsx(vt,{tone:"error",className:s?void 0:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:n,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The tool keys could not be read: ",e.code,": ",e.message]})})}function RU({tool:e,writable:n,again:s,open:r,problem:a,onOpen:i,onSave:c,onRemove:d}){var h;const u=p.useRef(null),f=v=>e.secrets.find(y=>Wf(y.name)===v.name),g=v=>e.fields.find(y=>y.name===Wf(v.name)),b=e.fields.filter(v=>{var y;return((y=f(v))==null?void 0:y.source)!=="env"}),x=e.secrets.filter(v=>v.set).length;return t.jsxs("li",{ref:u,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(pU,{id:e.id,className:"mt-1"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:e.label}),t.jsx(Ne,{tone:x===e.secrets.length?"success":"plain",children:x===e.secrets.length?"set":x?`${x} of ${e.secrets.length} set`:"not set"}),s&&t.jsx(Ne,{tone:"warning",children:"enter again"})]}),t.jsxs("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:[e.kind==="model"?"Model provider":`Unlocks ${e.unlocks.join(", ")}`,e.harnesses.length>0&&` · Harnesses ${e.harnesses.length===1?`${e.harnesses[0]} only`:e.harnesses.join(", ")}`]}),P0(e.label,e.check)&&t.jsx("p",{className:`mt-1.5 text-small ${((h=e.check)==null?void 0:h.state)==="accepted"?"text-success-text":"text-muted-foreground"}`,children:P0(e.label,e.check)}),t.jsx("ul",{className:"mt-3 space-y-1.5",children:e.secrets.map(v=>{var y;return t.jsx(rh,{field:v,stateSaid:e.secrets.length===1,writable:n&&r===null,note:(y=g(v))!=null&&y.stored_unreadable?$U:void 0,onPaste:()=>void sh(()=>i("edit"),()=>{var j,k,E;return(E=(j=u.current)==null?void 0:j.querySelector("form"))==null?void 0:E.elements.namedItem(((k=g(v))==null?void 0:k.name)??"")}),onRemove:v.source==="console"?()=>i("remove"):void 0},v.name)})}),!b.length&&t.jsx("p",{className:"mt-3 text-small text-muted-foreground",children:"Set when the server starts, and that one wins: change it where the server is started."})]})]}),r==="edit"&&t.jsx(zE,{tool:e,fields:b,onSave:c,onCancel:()=>i(null)}),r==="remove"&&t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove the ",e.label," key saved here?",e.secrets.some(v=>v.source==="env")?" The one set in the environment stays.":""]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void d(),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>i(null),children:"Keep"})]}),a&&t.jsx("div",{className:"mt-4 border",children:t.jsx(sa,{error:a.error,title:a.title})})]})}function zE({tool:e,fields:n,onSave:s,onCancel:r}){const a=p.useRef(null),[i,c]=p.useState(!1),[d,u]=p.useState(!1),[f,g]=p.useState(null),b=()=>n.some(y=>{var j,k;return(k=(j=a.current)==null?void 0:j.elements.namedItem(y.name))==null?void 0:k.value}),x=()=>{var y;(y=a.current)==null||y.reset(),c(!1)},h=async y=>{var N,_;y.preventDefault();const j={};for(const $ of n){const O=(_=(N=a.current)==null?void 0:N.elements.namedItem($.name))==null?void 0:_.value;O&&(j[$.name]=O)}if(!Object.keys(j).length)return;u(!0),g(null);const k=await s(j);if(u(!1),!k){x();return}const E={},S=[];for(const $ of k.fields??[]){const O=$.field.startsWith("values.")?$.field.slice(7):null;O&&n.some(A=>A.name===O)?E[O]=$.message:S.push($.message)}g({fields:E,message:S.length?S.join(" "):Object.keys(E).length?null:k.message})},v=CU(e.id);return t.jsxs("form",{ref:a,autoComplete:"off",onSubmit:y=>void h(y),onInput:()=>c(!!b()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e.label} key`,children:[v&&t.jsxs("p",{className:"text-body text-muted-foreground",children:[t.jsx("span",{className:"font-semibold text-foreground",children:e.label})," · No key yet?"," ",t.jsx("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Get a key"})," (opens in a new tab)"]}),n.map(y=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:y.name}),y.set&&t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"Saved already. A new value replaces it; leave it empty to keep it."}),t.jsx(ze,{type:"password",name:y.name,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:v&&n.length===1?v.placeholder:void 0}),(f==null?void 0:f.fields[y.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[y.name]})]},y.name)),(f==null?void 0:f.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f.message}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!i||d,children:d?"Saving":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{x(),r()},children:"Cancel"})]})]})}const Sd=p.createContext(null);function I0({connection:e,children:n}){return t.jsx(Sd.Provider,{value:e,children:n})}const AU={state:"online"},OU=()=>()=>{},z0=()=>AU;function jy(){const e=p.useContext(Sd);return p.useSyncExternalStore(e?e.subscribe:OU,e?e.link:z0,z0)}function DE(e){const n=p.useContext(Sd),s=p.useRef(e);s.current=e,p.useEffect(()=>n==null?void 0:n.onResume(()=>s.current()),[n])}function FE(e){const[n,s]=p.useState(()=>Date.now());return p.useEffect(()=>{if(e===null)return;s(Date.now());const r=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(r)},[e]),e===null?0:Math.max(0,Math.ceil((e-n)/1e3))}function MU(){const e=p.useContext(Sd),n=jy(),s=FE(n.state==="offline"?n.retryAt:null);return!e||n.state==="online"?null:n.state==="resumed"?t.jsxs(vt,{bar:!0,tone:"success",icon:Qo,"data-connection":"resumed",children:[t.jsx("span",{className:"font-semibold",children:"Resumed."})," agentrun-serve is back."]}):t.jsxs(vt,{bar:!0,tone:"warning",icon:MN,"data-connection":"offline",actions:t.jsx(B,{type:"button",onClick:e.retryNow,size:"xs",children:"Retry now"}),children:[t.jsxs("span",{className:"font-semibold",children:["Can't reach agentrun-serve at ",location.host,"."]})," Reconnecting… next try in ",s," s. The page shows what it had."]})}function PU(){const e=p.useContext(Sd),n=jy(),s=FE(n.state==="offline"?n.retryAt:null);return t.jsxs("div",{"data-connection":"offline",role:"status",className:"mx-auto mt-[12vh] max-w-md border bg-card p-6",children:[t.jsx(MN,{className:"size-5 text-warning-text","aria-hidden":!0}),t.jsxs("p",{className:"mt-3 text-base font-semibold",children:["Can't reach agentrun-serve at ",location.host,"."]}),t.jsx("p",{className:"mt-2 text-lead leading-relaxed text-muted-foreground",children:"Is it running? This page connects by itself as soon as the server answers."}),t.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[t.jsx(B,{type:"button",onClick:e==null?void 0:e.retryNow,size:"sm",children:"Retry now"}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["Next try in ",s," s"]})]})]})}const LU=(e,n)=>e.flatMap(s=>s.tools.flatMap(r=>{var a;return(a=r.permissions)!=null&&a.length&&r.default_permission?[{name:I2(s.name,r.name),permission:r.permission??r.default_permission,default_permission:r.default_permission,permissions:r.permissions,...n&&r.permissions.includes("ask")?{ask_needs:"password"}:{}}]:[]})),D0=e=>e instanceof De?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function IU({v2:e,choices:n,gates:s=[],harnesses:r,mcp:a=!1,onSaved:i,onOpen:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),b=()=>{a&&(g(null),e.listMcpServers().then(G=>g(G.servers),()=>g("failed")))};p.useEffect(b,[e,a]);const[x,h]=p.useState(null),[v,y]=p.useState(null),[j,k]=p.useState(!1),[E,S]=p.useState(null),N=p.useRef(0),_=()=>{const G=++N.current;e.toolSettings().then(U=>{G===N.current&&(u(U),h(null))},U=>{G===N.current&&h(D0(U))})};p.useEffect(_,[e]);const[$,O]=p.useState("reading"),A=()=>{O("reading"),Promise.resolve(c==null?void 0:c()).then(G=>O(G===!1?"failed":"landed"))},L=()=>{_(),A()};if(p.useEffect(A,[]),!d)return x?t.jsx(vt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:_,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The tool settings could not be read: ",x.code,": ",x.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const M=mx(d,n),R=E?E(M):M,P=OC(n,[...s,...Array.isArray(f)?LU(f,s.some(G=>G.ask_needs==="password")):[]]),D=G=>{var z;const U=Bo(G);return U?(z=R[`mcp:${U.server}/*`])==null?void 0:z.permission:void 0},W=Object.entries(R).filter(([,G])=>(G==null?void 0:G.pin)||(G==null?void 0:G.pin_broken)),Y=G=>{var z;const U=s.find(Q=>Q.name===G);return!U||(((z=R[G])==null?void 0:z.permission)??U.default_permission)===U.permission},{byTool:H,rest:q}=SC((v==null?void 0:v.fields)??{},"",P.map(G=>G.name)),F=async G=>{var K;const U=E?Z=>G(E(Z)):G;k(!0),y(null);const z=++N.current;let Q;try{Q=await e.toolSettings()}catch{S(()=>U),y({fields:{},error:null,unread:!0}),k(!1);return}try{const Z=await e.saveToolSettings(U(mx(Q,n)));S(null),z===N.current&&(u(Z),h(null)),i()}catch(Z){y(Z instanceof De&&Z.status===422&&((K=Z.fields)!=null&&K.length)?{fields:Object.fromEntries(Z.fields.map(de=>[de.field,de.message])),error:null}:{fields:{},error:D0(Z)})}k(!1)};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:"p-5 md:p-8",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Tools"}),t.jsxs("div",{className:"mt-2 grid gap-x-10 gap-y-2 xl:grid-cols-2",children:[t.jsx("p",{className:"text-lead text-muted-foreground",children:"This server's provider for each tool that has a choice, and what it resolves to on each harness. A change is saved at once and applies to every run launched from then on. An agent with a provider of its own keeps it."}),s.length>0&&t.jsxs("p",{className:"text-lead text-muted-foreground",children:["Each tool's permission: ",t.jsx("span",{className:"font-mono text-body",children:"allow"})," runs it, ",t.jsx("span",{className:"font-mono text-body",children:"ask"})," makes the run wait for your approval at each call, ",t.jsx("span",{className:"font-mono text-body",children:"deny"})," refuses it and tells the agent why. A permission applies at the next call, in runs already going too. An agent's own allow or ask takes the place of this server's; deny here refuses it for every agent."]})]})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("section",{"aria-label":"This server's providers",children:[P.length?t.jsx(oy,{label:"This server's tool settings",rows:P,settings:R,fallbackOf:G=>G.default_provider,issues:H,busy:j,onEdit:G=>void F(G),permissionFallbackOf:G=>D(G.name)??G.default_permission,refused:(G,U)=>U==="deny",resolvesOf:(G,U)=>U===G.provider&&Y(G.name)?t.jsx(_F,{choice:G,harnesses:r}):$==="reading"?t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"reading…"}):t.jsxs("span",{className:"block text-small text-muted-foreground",children:[$==="failed"?"What it resolves to couldn't be read.":"It changed while this page read it."," ",t.jsx(B,{type:"button",onClick:L,disabled:j,size:"xs",className:"ml-1",children:"Retry"})]})}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"This server offers no tool with a choice of provider."}),f==="failed"&&t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",role:"alert",children:["The MCP servers' tools could not be read, so they are not listed. ",t.jsx(B,{type:"button",size:"xs",className:"ml-1",onClick:b,disabled:j,children:"Retry"})]}),q.map(G=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:G},G)),(v==null?void 0:v.error)&&t.jsx("div",{className:"mt-3 border",children:t.jsx(sa,{error:v.error,title:"The change was not saved"})}),(v==null?void 0:v.unread)&&t.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[t.jsx("p",{className:"font-mono text-small text-destructive-text",children:"Couldn't read the current settings, so nothing was saved. Try again."}),t.jsx(B,{type:"button",size:"xs",className:"mt-2",onClick:()=>void F(G=>G),disabled:j,children:"Try again"})]}),x&&t.jsxs("div",{className:"mt-3 border p-3",role:"alert",children:[t.jsxs("p",{className:"font-mono text-small text-destructive-text",children:["The tool settings could not be read again: ",x.code,": ",x.message]}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The table shows the last ones read."}),t.jsx(B,{type:"button",onClick:L,disabled:j,size:"xs",className:"mt-2",children:"Try again"})]})]}),W.length>0&&t.jsxs("section",{"aria-label":"Pinned tools",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Pinned tools"}),t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:"A pin bounds a tool's calls for every agent on this server, its own pin beside it."}),t.jsx("ul",{className:"mt-2 border",children:W.map(([G,U])=>t.jsxs("li",{"data-pin":G,className:"border-b px-3 py-2.5 last:border-b-0",children:[t.jsx("p",{className:"font-mono text-body",children:G}),t.jsx(px,{setting:U})]},G))})]})]})]})})}function zU(e){const n=new URLSearchParams(e??""),s=n.get("github");if(s==="connected")return{ok:!0};if(s==="error"){const r=n.get("reason");return r?{ok:!1,reason:r}:{ok:!1}}}const F0={state_invalid:"That connection was started elsewhere or has expired. Start again.",conversion_failed:"GitHub didn't hand back the App. Try connecting again.",installation_unverified:"The App's install couldn't be confirmed. Install it again from GitHub.",already_connected:"Another GitHub App was connected while this one was being created. Delete the new App on GitHub."},DU=e=>e.ok?"Connected. The App is installed.":e.reason&&Object.hasOwn(F0,e.reason)?F0[e.reason]:"The connection didn't finish. Try again.";function FU(e,n){const s=n(e);if(!s)return;const r=new URL(s);return r.protocol==="https:"&&r.hostname==="github.com"?s:void 0}function UU({note:e}){const n=e.lastIndexOf(": "),s=n>=0?e.slice(n+2).trim():"",r=s?so(s):void 0;return r?t.jsxs(t.Fragment,{children:[e.slice(0,n+2),t.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"break-all underline underline-offset-2",children:s})]}):t.jsx(t.Fragment,{children:e})}function WU({v2:e,returned:n}){const[s,r]=p.useState(void 0),[a,i]=p.useState(null),[c,d]=p.useState(""),[u,f]=p.useState(!1),[g,b]=p.useState(null),[x,h]=p.useState(null),[v,y]=p.useState(null),[j,k]=p.useState(!1),[E,S]=p.useState(null),N=p.useRef(!1),_=p.useRef(null),$=p.useCallback(async()=>{try{const M=await e.githubConnection();r(M.connected?M:null),i(null)}catch(M){i(M instanceof Error?M.message:String(M))}},[e]);p.useEffect(()=>{$()},[$]),p.useEffect(()=>{n&&history.replaceState(null,"",`${location.pathname}${location.search}#/settings/github`)},[]),p.useEffect(()=>{var M;g&&((M=_.current)==null||M.submit())},[g]);const O=async()=>{var M;if(!N.current){N.current=!0,f(!0),h(null),y(null),S(null);try{const R=await e.connectGitHub(c.trim()||void 0),P=FU(R.action,so);if(!P){h("GitHub's address didn't look right, so nothing was sent."),N.current=!1,f(!1);return}b({action:P,manifest:JSON.stringify(R.manifest)})}catch(R){if(N.current=!1,f(!1),h(R instanceof Error?R.message:String(R)),R instanceof De&&R.code==="github_wrong_origin"){const P=(M=R.details)==null?void 0:M.public_url;y(typeof P=="string"&&so(P)||null)}R instanceof De&&R.code==="github_already_connected"&&$()}}},A=async()=>{k(!1),f(!0),h(null),y(null);try{S(await e.disconnectGitHub()),r(null)}catch(M){M instanceof De&&(M.status===404||M.code==="github_not_connected")?await $():h(M instanceof Error?M.message:String(M))}finally{f(!1)}},L=s?so(`https://github.com/apps/${encodeURIComponent(s.slug)}`):void 0;return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:qo,children:[t.jsxs("div",{className:ti,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"GitHub"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"One GitHub App for this server: its templates and triggers reach GitHub through it."})]}),t.jsxs("div",{className:ni,children:[n&&t.jsx("p",{"aria-label":"From GitHub",role:"status",className:oe("border p-4 text-lead",n.ok?"border-success/50 bg-success/5":"border-warning/50 bg-warning/5 text-warning-text"),children:DU(n)}),(x||v)&&t.jsx("div",{role:"alert",className:"border border-destructive/50 px-4 py-3 text-lead text-destructive-text",children:v?t.jsxs("p",{children:["Open this server at ",t.jsx("a",{href:v,className:"break-all underline underline-offset-2",children:v})," to connect GitHub."]}):t.jsx("p",{children:x})}),E&&t.jsxs("section",{"aria-label":"Disconnected",className:"border p-4 text-lead",children:[t.jsx("p",{children:t.jsx(UU,{note:E.note})}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:E.triggers_off?`${E.triggers_off} GitHub ${E.triggers_off===1?"trigger":"triggers"} turned off.`:"No GitHub trigger was on."})]}),a&&t.jsx(vt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:()=>void $(),children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["GitHub's connection could not be read: ",a]})}),t.jsxs(_r,{title:"Connection",children:[s===void 0&&!a&&t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading..."}),s===null&&t.jsxs("section",{"aria-label":"Connect GitHub",className:"border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[t.jsxs("label",{className:"flex min-w-[240px] flex-1 flex-col gap-1 text-body",children:[t.jsx("span",{className:"text-muted-foreground",children:"Organization (optional): the App is made under it"}),t.jsx(ze,{name:"org",value:c,onChange:M=>d(M.target.value),disabled:u,placeholder:"your-org",className:"h-9 w-auto"})]}),t.jsxs(B,{type:"button",variant:"solid",onClick:()=>void O(),disabled:u,children:[t.jsx(tj,{"aria-hidden":!0}),g?"Opening GitHub…":"Connect GitHub"]})]}),t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"GitHub asks you to create the App, then to install it on the accounts it may use. You come back here after."})]}),s&&t.jsxs("section",{"aria-label":"GitHub App",className:"border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-lead",children:[t.jsx(tj,{className:"size-4 text-muted-foreground","aria-hidden":!0}),L?t.jsx("a",{href:L,target:"_blank",rel:"noopener noreferrer",className:"font-mono underline underline-offset-2",children:s.slug}):t.jsx("span",{className:"font-mono",children:s.slug}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["App ",s.app_id]})]}),s.installations.length?t.jsx("ul",{"aria-label":"Installations",className:"mt-3 space-y-1 font-mono text-body",children:s.installations.map(M=>t.jsx("li",{children:M.account},M.id))}):t.jsx("p",{className:"mt-3 text-body text-muted-foreground",children:"Not installed on any account yet."}),j?t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2 text-body",role:"alertdialog","aria-label":"Disconnect GitHub?",children:[t.jsx("span",{children:"Disconnect GitHub? Every GitHub trigger turns off."}),t.jsx(B,{type:"button",variant:"destructive",disabled:u,onClick:()=>void A(),children:"Disconnect GitHub"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>k(!1),children:"Cancel"})]}):t.jsx(B,{type:"button",variant:"outline",className:"mt-4",disabled:u,onClick:()=>k(!0),children:"Disconnect"})]})]}),g&&t.jsx("form",{"data-github-manifest":!0,ref:_,method:"post",action:g.action,hidden:!0,children:t.jsx("input",{type:"hidden",name:"manifest",defaultValue:g.manifest})})]})]})})}const HU=8,BU={sealed:["sealed","success"],expired:["sign-in expired","warning"],unreadable:["can't be opened: enter it again","warning"]};function GU({v2:e,signIn:n,add:s,writable:r,whyNot:a="sign_in",open:i=d=>location.assign(d),choices:c=[]}){var G,U,z,Q;const[d,u]=p.useState(null),[f,g]=p.useState(null),[b,x]=p.useState(!1),[h,v]=p.useState(null),[y,j]=p.useState(null),k=(s==null?void 0:s.preset)==="composio"?s:void 0,[E,S]=p.useState(s&&!k?{add:s}:null),[N,_]=p.useState(k&&r?k:!1),[$,O]=p.useState(null),A=s?JSON.stringify(s):"",L=p.useRef(A);p.useEffect(()=>{if(A===L.current)return;L.current=A;const K=A?JSON.parse(A):void 0;S(K&&K.preset!=="composio"?{add:K}:null),_((K==null?void 0:K.preset)==="composio"&&r?K:!1)},[A]);const M=p.useRef(0),R=p.useRef(null),P=()=>{const K=++M.current;e.listMcpServers().then(Z=>{K===M.current&&(u(Z.servers),j(null))},Z=>{K===M.current&&j(oo(Z))})};p.useEffect(P,[e]),p.useEffect(()=>{e.toolSettings().then(g,()=>g(null))},[e]);const D=p.useRef(!1),W=async(K,Z)=>{if(!D.current){D.current=!0,x(!0),v(null);try{const de=await e.toolSettings();g(await e.saveToolSettings(Z(mx(de,c)))),P()}catch(de){v({server:K,problem:oo(de)})}D.current=!1,x(!1)}},Y=p.useRef(null);s&&d&&((G=Y.current)==null?void 0:G.key)!==A&&(Y.current={key:A,name:eW(s.name,d)});const H=K=>{var Z;return((Z=Y.current)==null?void 0:Z.key)===JSON.stringify(K)&&Y.current.name!==K.name?{...K,toolkit:K.toolkit??K.name,name:Y.current.name}:K},q=d!==null||y!==null;p.useEffect(()=>{n&&location.hash.includes("sign_in=")&&history.replaceState(null,"","#/settings/mcp")},[n]);const F=async(K,Z)=>i((await e.startMcpSignIn(K,Z)).authorization_url);return t.jsx("div",{ref:R,className:"h-full overflow-auto",children:t.jsxs("div",{className:qo,children:[t.jsxs("div",{className:ti,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"MCP servers"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"A remote MCP server's tools, for any agent you grant them to in its Tools step. A saved credential is never shown again."})]}),t.jsxs("div",{className:ni,children:[n&&t.jsx("p",{className:`border p-4 text-body ${n.ok?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:n.ok?`Signed in to ${n.server}. Its tools are saved.`:`Signing in to ${n.server} failed: ${lI(n.error)}.`}),!r&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:Za[a]}),$&&t.jsx("p",{className:"border border-warning/50 p-4 text-body text-warning-text",role:"status",children:$}),y&&t.jsx(vt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:P,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The MCP servers could not be read. ",y.text]})}),t.jsxs(_r,{title:"Servers",aside:!E&&!N&&t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",disabled:!r,onClick:()=>_(!0),children:"Add from Composio"}),t.jsx(B,{size:"sm",variant:"primary",onClick:()=>S({}),children:"Add server"})]}),children:[E&&(!E.add||q)&&t.jsx(rW,{v2:e,saved:E.saved,add:E.add&&H(E.add),given:E.problem,writable:r,signIn:F,onCancel:()=>S(null),onSaved:(K=>()=>{S(Z=>Z===K?null:Z),P()})(E)},`${((U=E.saved)==null?void 0:U.name)??"new"}|${((z=E.add)==null?void 0:z.name)??""}|${((Q=E.add)==null?void 0:Q.auth)??""}`),N&&(typeof N!="object"||q)&&t.jsx(tW,{v2:e,add:typeof N=="object"?H(N):void 0,onClose:()=>_(!1),onSaved:P},typeof N=="object"?A:"new"),d&&(d.length?t.jsx("ul",{className:"border",children:d.map(K=>t.jsx(KU,{v2:e,server:K,settings:f,settingsBusy:b,settingsProblem:(h==null?void 0:h.server)===K.name?h.problem:null,onSettings:Z=>void W(K.name,Z),writable:r&&!E,signIn:F,onChange:Z=>S({saved:K,...Z?{problem:Z}:{}}),onPaste:()=>void sh(()=>S({saved:K}),()=>{var Z;return((Z=R.current)==null?void 0:Z.querySelector('input[name="mcp-token"], input[name="mcp-header-value-0"]'))??null}),onChanged:P,onDeleted:Z=>{O(Z??null),P()}},K.name))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No MCP server is saved here yet."}))]}),t.jsx(XU,{v2:e})]})]})})}const ml=({problem:e})=>t.jsxs("div",{role:"alert",children:[t.jsx("p",{className:"font-mono text-body text-destructive-text",children:e.text}),e.detail&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:e.detail})]}),Nc=(e,n)=>`mcp:${e}/${n}`,qU=["allow","ask","deny"];function KU({v2:e,server:n,settings:s,settingsBusy:r,settingsProblem:a,onSettings:i,writable:c,signIn:d,onChange:u,onPaste:f,onChanged:g,onDeleted:b}){var L,M;const[x,h]=p.useState(!1),[v,y]=p.useState(!1),[j,k]=p.useState(null),[E,S]=p.useState(null),N=async R=>{h(!0),S(null);try{await R()}catch(P){S(oo(P))}h(!1)},[_,$]=n.credential?BU[n.credential]??[n.credential,"plain"]:["no credential","plain"],O=n.auth.type==="oauth",A=j&&[["Added",j.added],["Removed",j.removed],["Changed",j.changed]].filter(([,R])=>R.length).map(([R,P])=>`${R} ${P.join(", ")}`);return t.jsxs("li",{"data-server":n.name,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(MT,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-prose font-semibold",children:n.name}),t.jsx(Ne,{tone:$,children:_}),!!((L=n.not_metered)!=null&&L.length)&&t.jsx(Ne,{tone:"plain",children:"not metered"}),n.source&&t.jsxs(t.Fragment,{children:[t.jsx(Ne,{tone:"muted",children:hd[n.source]}),t.jsx("span",{"data-toolkit":!0,className:"font-mono text-small text-muted-foreground",children:n.toolkit?`toolkit ${n.toolkit}`:"no toolkit"})]})]}),t.jsx("p",{className:"mt-1.5 break-all font-mono text-small text-muted-foreground",children:n.url}),n.auth.type==="github_app"&&t.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed with this server's GitHub App: a token narrowed to the run's repository is made for each run",(M=n.auth.headers)!=null&&M.length?` · headers ${n.auth.headers.join(", ")}`:""]}),O&&n.oauth&&t.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:["Signed in with OAuth",n.oauth.scopes.length?` · ${n.oauth.scopes.join(" ")}`:"",n.oauth.client==="pre-registered"&&n.oauth.client_id?` · client ${n.oauth.client_id}`:"",n.credential==="expired"?" · sign-in expired: sign in again":n.oauth.expires_at?` · token until ${ht(n.oauth.expires_at)}`:""]}),s&&t.jsx(QU,{server:n,settings:s,busy:r,onSettings:i}),a&&t.jsx("div",{className:"mt-2",children:t.jsx(ml,{problem:a})}),t.jsxs("details",{className:"mt-2",children:[t.jsxs("summary",{className:"cursor-pointer font-mono text-small",children:[n.tools.length," tool",n.tools.length===1?"":"s"]}),t.jsx("div",{className:"mt-2",children:t.jsx(JU,{server:n,settings:s,busy:r,onSettings:i})})]}),n.secret&&t.jsx("ul",{className:"mt-2",children:t.jsx(rh,{field:n.secret,label:sW[n.auth.type],writable:c,onPaste:O?void 0:f})}),n.source==="composio"&&t.jsx(YU,{v2:e,server:n.name,writable:c}),A&&t.jsx("p",{className:"mt-2 font-mono text-small",role:"status",children:A.length?A.join(" · "):"No change: it lists the same tools."})]}),!v&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[O&&n.credential!=="sealed"&&c&&t.jsx(B,{size:"sm",variant:"primary",disabled:x,onClick:()=>void N(()=>{var R;return d(n.name,{url:n.url,...(R=n.oauth)!=null&&R.scopes.length?{scopes:n.oauth.scopes}:{}})}),children:"Sign in again"}),t.jsx(B,{size:"sm",disabled:x,onClick:()=>void N(async()=>{try{k(await e.refreshMcpServer(n.name))}finally{g()}}),children:"Refresh"}),t.jsx(B,{size:"sm",disabled:x,onClick:()=>u(),children:"Change"}),t.jsx(B,{size:"sm",variant:"destructive",disabled:x,onClick:()=>y(!0),children:"Delete"})]})]}),v&&t.jsxs("div",{role:"alertdialog","aria-label":`Delete ${n.name}`,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Delete ",n.name,"? Its credential goes with it, and an agent that grants its tools can't call them."]}),t.jsx(B,{size:"sm",variant:"destructive",disabled:x,onClick:()=>void N(async()=>{var R,P;b((P=(R=await e.deleteMcpServer(n.name))==null?void 0:R.composio)==null?void 0:P.note)}),children:"Delete"}),t.jsx(B,{size:"sm",onClick:()=>y(!1),children:"Keep"})]}),E&&t.jsxs("div",{className:"mt-3",children:[t.jsx(ml,{problem:E}),E.needsClient&&c&&t.jsx(B,{className:"mt-2",size:"sm",variant:"primary",onClick:()=>u(E),children:"Enter a Client ID"})]})]})}const VU={on:"on at Composio",off:"off at Composio",missing:"Composio no longer has it",unknown:"Composio didn't say"};function YU({v2:e,server:n,writable:s}){const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[b,x]=p.useState(!1),[h,v]=p.useState(!1);if(p.useEffect(()=>{let k=!0;return e.composioTriggers(n).then(E=>{k&&a(E)},E=>{k&&(E instanceof De&&E.status===404?u(!0):c(oo(E)))}),()=>{k=!1}},[e,n]),d)return null;const y=async()=>{g(!1),x(!0),c(null),v(!1);try{await e.rotateComposioSecret(n),v(!0)}catch(k){c(oo(k))}x(!1)},j=r==null?void 0:r.subscription;return t.jsxs("section",{"data-composio-triggers":!0,"aria-label":`${n}'s triggers`,className:"mt-3 border p-3",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Triggers"}),r?t.jsxs(t.Fragment,{children:[r.triggers.length?t.jsx("ul",{className:"mt-2 space-y-1",children:r.triggers.map(k=>t.jsxs("li",{"data-trigger":k.id,className:"flex flex-wrap items-center gap-x-2 text-body",children:[t.jsx("a",{href:`#/triggers/${encodeURIComponent(k.id)}`,className:"font-semibold hover:underline",children:k.name}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:k.event}),t.jsxs("span",{className:`font-mono text-small ${k.on_composio==="missing"?"text-warning-text":"text-muted-foreground"}`,children:["· ",VU[k.on_composio],k.enabled?"":" · paused here"]})]},k.id))}):t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["No trigger uses it yet. ",t.jsx("a",{href:"#/triggers/new-composio",className:"underline underline-offset-2",children:"New app trigger"})]}),r.composio_error&&t.jsxs("p",{className:"mt-2 text-small text-warning-text",children:["Composio didn't answer: ",r.composio_error]}),j&&(j.ours?t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"The project's webhook subscription sends its events here."}):t.jsxs("p",{className:"mt-2 break-all text-small text-muted-foreground",children:["The project's webhook subscription sends its events to ",t.jsx("span",{className:"font-mono",children:j.webhook_url}),", not here: a new trigger asks before it moves it."]})),(j==null?void 0:j.ours)&&s&&!f&&t.jsx(B,{className:"mt-2",size:"sm",disabled:b,onClick:()=>g(!0),children:"Rotate secret"}),f&&t.jsxs("div",{role:"alertdialog","aria-label":"Rotate the subscription's secret?",className:"mt-2 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Rotate the subscription's secret? Composio makes a new one and this server keeps it; a delivery signed with the old one is refused from then on."}),t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void y(),children:"Yes, rotate"}),t.jsx(B,{size:"sm",onClick:()=>g(!1),children:"Keep"})]}),h&&t.jsx("p",{className:"mt-2 text-small text-success-text",role:"status",children:"Rotated: Composio signs with the new secret from now on."})]}):!i&&t.jsx("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:"Reading its triggers"}),i&&t.jsx("div",{className:"mt-2",children:t.jsx(ml,{problem:i})})]})}function QU({server:e,settings:n,busy:s,onSettings:r}){var g;const a=Nc(e.name,"*"),i=((g=n[a])==null?void 0:g.allow_reads)===!0,c=e.tools.filter(b=>b.effect==="read").length,d=`allow-reads-${e.name}`,u=`${d}-words`,f=b=>r(x=>{const{[a]:h,...v}=x,{allow_reads:y,...j}=h??{},k=b?{...j,allow_reads:!0}:j;return Object.keys(k).length?{...v,[a]:k}:v});return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_m,{checked:i,onChange:f,busy:s,labelledBy:d}),t.jsx("span",{id:d,className:"caps text-small font-semibold",children:"Allow reads"})]}),t.jsxs("p",{id:u,className:"mt-1 text-small text-muted-foreground",children:[c," of ",e.tools.length," tool",e.tools.length===1?"":"s"," read-only, as the server marks them: ",i?"they run without asking":"on, they run without asking",". Writes keep their permission."]})]})}function JU({server:e,settings:n,busy:s,onSettings:r}){const a=n==null?void 0:n[Nc(e.name,"*")],i=new Map(e.tools.map(u=>[Nc(e.name,u.name),u])),c=e.tools.map(u=>{var f;return{name:Nc(e.name,u.name),...n?{gate:{name:Nc(e.name,u.name),permission:u.permission??"ask",default_permission:u.default_permission??"ask",permissions:(f=u.permissions)!=null&&f.length?u.permissions:qU}}:{}}}),d=u=>{var g,b;const f=(g=e.prices)==null?void 0:g[u];return f!==void 0?`$${f} a call`:(b=e.not_metered)!=null&&b.includes(u)?"not metered":null};return t.jsx(oy,{label:`${e.name}'s tools`,rows:c,settings:n??{},busy:s,issues:{},fallbackOf:()=>"",resolvesOf:()=>null,onEdit:r,labelOf:u=>{var f;return((f=i.get(u))==null?void 0:f.name)??u},detailOf:u=>{var f;return d(((f=i.get(u))==null?void 0:f.name)??"")},effectOf:u=>{var f;return(f=i.get(u))==null?void 0:f.effect},confirmAllowOf:u=>{var f;return((f=i.get(u))==null?void 0:f.effect)==="destructive"},refused:(u,f)=>f==="deny",fallbackWordOf:u=>{var f;return(f=i.get(u))!=null&&f.fallback_allow_reads?"allow reads":void 0},permissionFallbackOf:u=>{var f;return(f=i.get(u.name))!=null&&f.fallback_allow_reads?"allow":(a==null?void 0:a.permission)??u.default_permission}})}function XU({v2:e}){const[n,s]=p.useState(null),[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(!1),[f,g]=p.useState(""),b=()=>void e.mcpPrivateHosts().then(v=>{s(v.hosts),a(null)},v=>a(oo(v)));p.useEffect(b,[e]);const x=async v=>{u(!0),c(null);try{return s((await e.saveMcpPrivateHosts(v)).hosts),!0}catch(y){return c(oo(y)),!1}finally{u(!1)}},h=async v=>{v.preventDefault(),n&&f.trim()&&await x([...n,f.trim()])&&g("")};return t.jsxs(_r,{titleId:"mcp-private-hosts",title:"Private network hosts",note:t.jsx("p",{children:"Off by default. A host listed here may run an MCP server's sign-in on your private network (10.x, 172.16–31.x, 192.168.x, 100.64–127.x, fc00::/7), over https only; never this machine, loopback or a link-local address such as cloud metadata."}),children:[r&&t.jsxs("div",{role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The private network hosts could not be read. ",r.text]}),t.jsx(B,{size:"sm",onClick:b,className:"mt-3",children:"Try again"})]}),n&&(n.length?t.jsx("ul",{"aria-label":"Allowed private network hosts",className:"border",children:n.map(v=>t.jsxs("li",{"data-host":v,className:"flex items-center justify-between gap-3 border-b px-3 py-2 last:border-b-0",children:[t.jsx("span",{className:"break-all font-mono text-body",children:v}),t.jsx(B,{size:"sm",disabled:d,onClick:()=>void x(n.filter(y=>y!==v)),children:"Remove"})]},v))}):t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:"No host is allowed: a sign-in on a private network is refused."})),n&&t.jsxs("form",{onSubmit:v=>void h(v),"aria-label":"Allow a private network host",className:"flex gap-2",children:[t.jsx(ze,{name:"mcp-private-host","aria-label":"Host name or IP address",value:f,onChange:v=>g(v.target.value),placeholder:"auth.corp.example",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),t.jsx(B,{type:"submit",size:"sm",variant:"primary",disabled:d||!f.trim(),children:"Allow"})]}),i&&t.jsx(ml,{problem:i})]})}const ZU=32;function eW(e,n){const s=new Set(n.map(r=>r.name));if(!s.has(e))return e;for(let r=2;;r++){const a=`-${r}`,i=`${e.slice(0,ZU-a.length).replace(/-+$/,"")}${a}`;if(!s.has(i))return i}}function tW({v2:e,add:n,onClose:s,onSaved:r}){var M;const a=p.useRef(null),[i,c]=p.useState((n==null?void 0:n.toolkit)??""),[d,u]=p.useState((n==null?void 0:n.name)??""),[f,g]=p.useState(null),[b,x]=p.useState([]),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,E]=p.useState(!1),S=()=>{var R,P;return(((P=(R=a.current)==null?void 0:R.elements.namedItem("composio-key"))==null?void 0:P.value)??"").trim()},N=async R=>{E(!0),j(null);try{await R()}catch(P){j(oo(P))}E(!1)},_=p.useRef(0),$=()=>{_.current++,g(null)},O=()=>N(async()=>{const R=++_.current;g(null),x([]);const P=await e.composioTools(S(),i.trim().toLowerCase());R===_.current&&(g(P),n!=null&&n.tools&&P.toolkit===n.toolkit&&x(P.tools.map(D=>D.slug).filter(D=>n.tools.includes(D))))}),A=()=>N(async()=>{var P,D;const R=await e.saveComposioServer(d.trim(),S(),f.toolkit,b);(P=a.current)==null||P.reset(),r(),R.connect_url||(D=R.not_served)!=null&&D.length?v({connect:R.connect_url,notServed:R.not_served}):s()}),L=R=>x(P=>P.includes(R)?P.filter(D=>D!==R):[...P,R]);return h?t.jsxs("section",{"aria-label":"Composio server saved",className:"space-y-3 border bg-card p-4",children:[t.jsxs("p",{className:"text-body",children:["Saved.",h.connect?` Its tools need your ${f==null?void 0:f.toolkit} account: connect it on Composio, then refresh the server.`:""]}),h.connect&&t.jsx("p",{children:t.jsxs("a",{href:h.connect,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-body underline",children:["Connect your ",f==null?void 0:f.toolkit," account"]})}),(M=h.notServed)!=null&&M.length?t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:["Composio's server doesn't list ",h.notServed.join(", "),": a run can't call ",h.notServed.length===1?"it":"them","."]}):null,t.jsx(B,{size:"sm",onClick:s,children:"Done"})]}):t.jsxs("form",{ref:a,autoComplete:"off",onSubmit:R=>{R.preventDefault(),f&&b.length&&d.trim()&&A()},"aria-label":"Add from Composio",className:"space-y-4 border bg-card p-4",onInput:R=>{R.target.name==="composio-key"&&$()},children:[t.jsx("p",{className:"text-small text-muted-foreground",children:"Composio runs the toolkit's actions for you. This saves an MCP server that grants only the actions you tick, with your Composio key sealed like any credential."}),(n==null?void 0:n.tools)&&t.jsxs("p",{role:"note",className:"text-small text-muted-foreground",children:["A template uses ",n.tools.join(", "),": enter your key and load the actions, and those are ticked."]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Composio API key"}),t.jsx(ze,{name:"composio-key",...pf})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),t.jsx(ze,{name:"composio-toolkit",value:i,onChange:R=>{c(R.target.value),$()},placeholder:"github",spellCheck:!1})]}),y&&t.jsx(ml,{problem:y}),f&&t.jsxs("fieldset",{className:"space-y-2",children:[t.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Actions to grant"}),f.tools.length?t.jsx("ul",{className:"divide-y border",children:f.tools.map(R=>t.jsx("li",{className:"px-3 py-2",children:t.jsxs("label",{className:"flex items-start gap-2 text-body",children:[t.jsx("input",{type:"checkbox",value:R.slug,checked:b.includes(R.slug),onChange:()=>L(R.slug),className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono",children:R.name}),t.jsx("span",{className:"ml-2 font-mono text-small text-muted-foreground",children:R.slug}),R.description&&t.jsx("span",{className:"block text-small text-muted-foreground",children:R.description})]})]})},R.slug))}):t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This toolkit lists no actions."}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Lowercase letters, digits and dashes: an agent grants its tools as mcp:",d.trim()||"<name>","/<tool>."]}),t.jsx(ze,{name:"composio-name",value:d,onChange:R=>u(R.target.value),spellCheck:!1})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"button",size:"sm",disabled:k||!i.trim(),onClick:()=>void O(),children:"Load actions"}),f&&t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:k||!b.length||!d.trim(),children:k?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",disabled:k,onClick:()=>{var R;(R=a.current)==null||R.reset(),s()},children:"Cancel"})]})]})}const pf={type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"},nW=[["none","None"],["bearer","Bearer token"],["headers","Headers"],["oauth","Sign in with OAuth"],["github_app","GitHub App"]],sW={none:"Credential",bearer:"Bearer token",headers:"Headers",oauth:"OAuth sign-in",github_app:"Headers"};function rW({v2:e,saved:n,add:s,given:r,writable:a,signIn:i,onCancel:c,onSaved:d}){var ue,xe,$e,ge,fe;const u=p.useRef(null),[f,g]=p.useState((n==null?void 0:n.name)??(s==null?void 0:s.name)??""),[b,x]=p.useState((n==null?void 0:n.url)??((s==null?void 0:s.auth)==="github_app"?Uk:"")),[h,v]=p.useState((n==null?void 0:n.auth.type)??(s==null?void 0:s.auth)??"none"),[y,j]=p.useState(Math.max(1,((ue=n==null?void 0:n.auth.headers)==null?void 0:ue.length)??0)),k=h==="github_app"?"github":(n==null?void 0:n.source)==="composio"?"composio":"url",[E,S]=p.useState((n==null?void 0:n.toolkit)??(s&&!s.auth?s.toolkit??s.name:"")),N=k==="github"?"github":E.trim(),_=()=>{if(h==="github_app")return{};const me=N||null;return n?me!==n.toolkit?{toolkit:me}:{}:me?{toolkit:me}:{}},[$,O]=p.useState(null),[A,L]=p.useState(r??null),[M,R]=p.useState(!1),P=p.useRef(0),D=()=>{P.current++,O(null)},W=me=>{var je,Me;return(((Me=(je=u.current)==null?void 0:je.elements.namedItem(me))==null?void 0:Me.value)??"").trim()},[Y,H]=p.useState(!1),q=me=>{try{return new URL(me).origin}catch{return me}},F=(me=h)=>{var je;return H(!!n&&me==="oauth"&&(n.auth.type!=="oauth"||W("mcp-scopes")!==(((je=n.oauth)==null?void 0:je.scopes.join(" "))??"")||!!W("mcp-client-id")||!!W("mcp-client-secret")||q(W("mcp-url"))!==q(n.url)))};p.useEffect(()=>F(),[h]);const G=()=>{if(h==="bearer")return W("mcp-token")?{type:h,token:W("mcp-token")}:{type:h};if(h!=="headers"&&h!=="github_app")return{type:h};const me=Object.fromEntries(Array.from({length:y},(je,Me)=>[W(`mcp-header-name-${Me}`),W(`mcp-header-value-${Me}`)]).filter(([je,Me])=>je&&Me));return Object.keys(me).length?{type:h,headers:me}:{type:h}},U=async me=>{R(!0),L(null);try{await me()}catch(je){L(oo(je))}R(!1)},z=!!(A!=null&&A.needsClient);p.useEffect(()=>{z&&v("oauth")},[z]),p.useEffect(()=>{var me,je;z&&h==="oauth"&&((je=(me=u.current)==null?void 0:me.elements.namedItem("mcp-client-id"))==null||je.focus())},[z,h]);const Q=()=>U(()=>{const me=W("mcp-scopes").split(/\s+/).filter(Boolean),je=W("mcp-client-id");return i(f.trim(),{url:b.trim(),...me.length?{scopes:me}:{},...je?{client_id:je,...W("mcp-client-secret")?{client_secret:W("mcp-client-secret")}:{}}:{},..._()})}),K=()=>{const me=P.current;U(async()=>{try{const je=await e.previewMcpServer(b.trim(),G(),n==null?void 0:n.name);me===P.current&&O(je)}catch(je){if(me===P.current)throw je}})},Z=me=>{if(me.preventDefault(),h==="oauth"&&(!n||Y))return void Q();U(async()=>{var je;await e.saveMcpServer(f.trim(),b.trim(),G(),_()),(je=u.current)==null||je.reset(),d()})},de=!M&&!!f.trim()&&!!b.trim()&&(!!n||!!$),se=me=>(n==null?void 0:n.credential)==="sealed"&&n.auth.type===h&&t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Saved. ",me]});return t.jsxs("form",{ref:u,autoComplete:"off",onSubmit:Z,"aria-label":n?`Change ${n.name}`:"Add an MCP server",className:"space-y-4 border bg-card p-4",onInput:me=>{["mcp-name","mcp-toolkit"].includes(me.target.name)||D(),F()},children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Name"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Lowercase letters, digits and dashes: an agent grants its tools as mcp:",f.trim()||"<name>","/<tool>."]}),t.jsx(ze,{name:"mcp-name",value:f,readOnly:!!n,onChange:me=>g(me.target.value),spellCheck:!1})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Address"}),t.jsx(ze,{name:"mcp-url",value:b,onChange:me=>{x(me.target.value),A!=null&&A.needsClient&&L(null)},placeholder:"https://mcp.example.com/mcp",spellCheck:!1})]}),t.jsxs("div",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Source"}),t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"What made it: GitHub App access is GitHub, the Composio preset is Composio, anything else is URL."}),t.jsx("span",{"data-mcp-source":k,className:"font-mono text-body",children:hd[k]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["The name a template gives these tools (mcp:",N||"<toolkit>","/<tool>): applying one uses this server for them."]}),t.jsx(ze,{name:"mcp-toolkit",value:k==="github"?"github":E,readOnly:k==="github",onChange:me=>S(me.target.value),placeholder:"hubspot",spellCheck:!1})]}),t.jsxs("fieldset",{children:[t.jsx("legend",{className:"caps mb-2 text-small font-semibold",children:"Credential"}),t.jsx("div",{className:"flex flex-wrap gap-4",children:nW.map(([me,je])=>t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"radio",name:"mcp-auth",value:me,checked:h===me,disabled:!a&&me!=="none",onChange:()=>{v(me),me==="github_app"&&!b.trim()&&x(Uk),D()},className:"accent-primary"}),je]},me))})]}),h==="bearer"&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Token"}),se("A new token replaces it; leave this empty to keep it."),t.jsx(ze,{name:"mcp-token",...pf})]}),h==="github_app"&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Uses this server's GitHub App (Settings → GitHub): a token for the repository of each run is made when the run starts, and an agent never sees it. The address is GitHub's hosted MCP, the only one this credential goes to. Headers are optional."}),(h==="headers"||h==="github_app")&&t.jsxs("div",{className:"space-y-2",children:[se(`Its headers: ${(xe=n==null?void 0:n.auth.headers)==null?void 0:xe.join(", ")}. New ones replace them all; leave the values empty to keep them.`),Array.from({length:y},(me,je)=>{var Me;return t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ze,{name:`mcp-header-name-${je}`,"aria-label":`Header ${je+1} name`,placeholder:"X-Api-Key",defaultValue:(Me=n==null?void 0:n.auth.headers)==null?void 0:Me[je],spellCheck:!1}),t.jsx(ze,{name:`mcp-header-value-${je}`,"aria-label":`Header ${je+1} value`,...pf})]},je)}),y<HU&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>j(me=>me+1),children:"Add header"})]}),h==="oauth"&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-small text-muted-foreground",children:"This server signs in for you and keeps the tokens; an agent never sees one. Sign in opens the server's own page to approve it, and its tools are saved once you do."}),(($e=n==null?void 0:n.oauth)==null?void 0:$e.client_id)&&t.jsxs("p",{className:"text-small text-muted-foreground",children:["Signing in again uses the client it signed in with (",n.oauth.client_id,"); a client ID here replaces it."]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Scopes (optional)"}),t.jsx(ze,{name:"mcp-scopes",placeholder:"read write",defaultValue:(ge=n==null?void 0:n.oauth)==null?void 0:ge.scopes.join(" "),spellCheck:!1})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("label",{className:"block flex-1",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:z?"Client ID (this server needs one)":"Client ID (optional)"}),t.jsx(ze,{name:"mcp-client-id",spellCheck:!1})]}),a&&t.jsxs("label",{className:"block flex-1",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:z?"Client secret (if its app has one)":"Client secret (optional)"}),t.jsx(ze,{name:"mcp-client-secret",...pf})]})]})]}),A&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(ml,{problem:A}),A.signIn&&h!=="oauth"&&a&&t.jsx(B,{type:"button",size:"sm",variant:"primary",disabled:M||!f.trim(),onClick:()=>void Q(),children:"Sign in"})]}),$&&t.jsxs("section",{"aria-label":"Preview",className:"border bg-background p-3",children:[t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["MCP ",$.protocol,(fe=$.server_info)!=null&&fe.name?` · ${$.server_info.name}${$.server_info.version?` ${$.server_info.version}`:""}`:""," · ",$.tools.length," tool",$.tools.length===1?"":"s"]}),$.instructions&&t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-small",children:$.instructions}),t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:rI}),t.jsx("ul",{"aria-label":"Tools it lists",className:"mt-2 divide-y border",children:$.tools.map(me=>t.jsxs("li",{className:"px-3 py-2",children:[t.jsx("span",{className:"font-mono text-body",children:me.name}),me.title&&t.jsx("span",{className:"ml-2 text-small",children:me.title}),me.description&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:me.description})]},me.name))})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[h==="oauth"&&!a?null:h==="oauth"&&Y?t.jsx(B,{type:"submit",size:"sm",variant:"primary",disabled:M||!b.trim(),children:"Sign in again with these settings"}):h==="oauth"?t.jsx(B,{type:"button",size:"sm",variant:n?"outline":"primary",disabled:M||!f.trim()||!b.trim(),onClick:()=>void Q(),children:n?"Sign in again":"Sign in"}):t.jsx(B,{type:"button",size:"sm",disabled:M||!b.trim(),onClick:K,children:"Preview"}),(h!=="oauth"||n&&!Y)&&t.jsx(B,{type:"submit",size:"sm",variant:A!=null&&A.signIn&&h!=="oauth"&&a?"outline":"primary",disabled:!de,children:M?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{var me;(me=u.current)==null||me.reset(),c()},children:"Cancel"})]})]})}const U0=e=>e instanceof De?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function oW({v2:e,needs:n,model:s,onSaved:r,writable:a,whyNot:i="sign_in",plan:c,onPlan:d,onDone:u,harnesses:f}){const[g,b]=p.useState(null),[x,h]=p.useState(null),[v,y]=p.useState(null),[j,k]=p.useState(null),[E,S]=p.useState(c??null);p.useEffect(()=>{S(c??null)},[c]);const[N,_]=p.useState(!1),$=p.useRef(0),O=()=>{const q=++$.current;e.listToolKeys().then(F=>{q===$.current&&(b(F.keys.filter(G=>G.kind==="model")),h(null))}).catch(F=>{q===$.current&&h(U0(F))})};p.useEffect(()=>{n!=="model"&&O()},[e,n]);const A=s!=null&&s.includes("/")&&!Hc(s)?s.slice(0,s.indexOf("/")):void 0,L=g==null?void 0:g.find(q=>q.id===A),M=L?[L]:g,R=g==null?void 0:g.find(q=>q.id===v),P=(R==null?void 0:R.fields.filter(q=>{var F;return((F=R.secrets.find(G=>Wf(G.name)===q.name))==null?void 0:F.source)!=="env"}))??[],D=!!E&&n!=="model"&&!A,W=n!=="model"&&(!D||N),Y=q=>{S(q),d==null||d(q)},H=f&&t.jsx(zC,{harnesses:f});return D&&E.state==="signed_in"?t.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Pa,{className:"mt-1 size-4 shrink-0 text-success-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[t.jsx("h2",{className:"text-prose font-semibold",children:"Signed in with ChatGPT"}),t.jsx(vx,{v2:e,view:E,onView:Y}),H,t.jsx(B,{type:"button",size:"sm",onClick:()=>u==null?void 0:u(),children:"Done"})]})]})}):t.jsx("section",{className:"border-b bg-card px-5 py-5 md:px-8","aria-label":"Model key",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Pa,{className:"mt-1 size-4 shrink-0 text-warning-text","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[t.jsx("h2",{className:"text-prose font-semibold",children:n==="model"?"This server's default model doesn't run":D?"Sign in with ChatGPT or add a model key to run agents":"Add a model key to run agents"}),n==="model"?t.jsx("p",{className:"text-body text-muted-foreground",children:"The server's AGENT_MODEL names a model it doesn't know, so an agent that names no model can't run. Set AGENT_MODEL to a provider/model-id where the server starts, or name a model in each agent."}):L?t.jsxs("p",{className:"text-body text-muted-foreground",children:["This server's default model is ",t.jsx("span",{className:"font-mono",children:s}),", and no ",L.label," key is set, so an agent that names no model can't run. Save the ",L.label," key: such an agent then runs on that model."]}):D?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"This server has no model yet, so an agent that names no model can't run."}),t.jsx(vx,{v2:e,view:E,onView:Y,writable:a,whyNot:i,beside:t.jsx(B,{type:"button",size:"sm","aria-expanded":N,onClick:()=>_(q=>!q),children:"Add a key"})}),t.jsx("p",{className:"text-body text-muted-foreground",children:z2}),N&&t.jsx("p",{className:"text-body text-muted-foreground",children:Sx})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"No model provider's key is set on this server, so an agent that names no model can't run. Save one: such an agent then runs on that provider's everyday model."}),t.jsx("p",{className:"text-body text-muted-foreground",children:Sx})]}),W&&x&&t.jsxs("div",{role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The keys could not be read: ",x.code,": ",x.message]}),t.jsx(B,{type:"button",onClick:O,size:"sm",className:"mt-2",children:"Try again"})]}),W&&g&&!a&&t.jsx("p",{className:"text-body",role:"status",children:Za[i]}),W&&g&&a&&t.jsx("div",{className:"flex flex-wrap gap-2",role:"group","aria-label":"Provider",children:M.map(q=>t.jsx(B,{size:"sm",variant:v===q.id?"solid":"primary","aria-pressed":v===q.id,onClick:()=>{y(v===q.id?null:q.id),k(null)},children:q.label},q.id))}),W&&R&&a&&(P.length?t.jsx(zE,{tool:R,fields:P,onCancel:()=>y(null),onSave:async q=>{k(null);try{await e.saveToolKey(R.id,q)}catch(F){return F instanceof De&&F.status===422?F:(k(U0(F)),null)}return y(null),O(),r==null||r(),null}},R.id):t.jsxs("p",{className:"text-body text-muted-foreground",children:["The server sets the ",R.label," key when it starts: change it there."]})),j&&t.jsx("div",{className:"border",children:t.jsx(sa,{error:j,title:"The key was not saved"})}),H,t.jsxs("p",{className:"text-small text-muted-foreground",children:["Every key is in ",t.jsx("a",{className:"underline underline-offset-2 hover:text-foreground",href:"#/settings/keys",children:"Settings"}),"."]})]})]})})}function aW({needs:e,settings:n,model:s,source:r,chatgpt:a=!1}){return t.jsx("p",{role:"status","aria-label":"No model",className:"border-b bg-card px-5 py-3 text-body text-warning-text md:px-8",children:e==="model"?"This server's default model doesn't run here: set AGENT_MODEL to a model it knows, and restart.":t.jsxs(t.Fragment,{children:["No model yet."," ",r==="gateway"?t.jsxs(t.Fragment,{children:["This server sends its models to a gateway: name the gateway's model in AGENT_MODEL where AgentRun starts, and restart",n?t.jsxs(t.Fragment,{children:[", or ",t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"add a model key in Settings → Model keys"})]}):null,"."]}):s?`This server's default model is ${s}: set its provider's key where AgentRun starts, and restart.`:a&&n?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"Continue with ChatGPT"})," in Settings → Model keys: Codex and pi agents run on your ChatGPT plan. Add a key there for the rest (one OpenRouter key gives every harness its model), and it takes effect at once."]}):n?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:"#/settings/keys",className:"underline underline-offset-2",children:"Add a key in Settings → Model keys"})," (one OpenRouter key gives every harness its model), and it takes effect at once. Or set OPENROUTER_API_KEY, ANTHROPIC_API_KEY or OPENAI_API_KEY where AgentRun starts, and restart."]}):"Set OPENROUTER_API_KEY (one key gives every harness its model), or ANTHROPIC_API_KEY or OPENAI_API_KEY, and restart."]})})}const W0=[{value:"gmail",label:"Gmail"},{value:"fastmail",label:"Fastmail"},{value:"icloud",label:"iCloud"},{value:"other",label:"Other"}],iW={gmail:t.jsxs(t.Fragment,{children:["A Google ",t.jsx("a",{href:"https://myaccount.google.com/apppasswords",target:"_blank",rel:"noreferrer",className:"text-primary-text underline",children:"app password"}),". Google gives one only with 2-Step Verification on, and a company account whose admin turned app passwords off won't connect yet."]}),fastmail:t.jsx(t.Fragment,{children:"A Fastmail app password with IMAP and SMTP access, made under Privacy & Security in Fastmail."}),icloud:t.jsx(t.Fragment,{children:"An app-specific password, made under Sign-In and Security in your Apple Account."}),other:t.jsx(t.Fragment,{children:"Your mail server's IMAP and SMTP servers, and its password: an app password where it offers one."})},lW="Outlook needs Microsoft sign-in, which this server doesn't do yet.";function cW(e){return e==="other"?"Password":"App password"}const dW={configured:!1,preset:null,address:null,user:null,imap:null,smtp:null,password_unreadable:!1},H0=e=>{var n,s,r,a;return{preset:(e==null?void 0:e.preset)??"gmail",address:(e==null?void 0:e.address)??"",user:e!=null&&e.user&&e.user!==e.address?e.user:"",imapHost:(e==null?void 0:e.preset)==="other"?((n=e.imap)==null?void 0:n.host)??"":"",imapPort:(e==null?void 0:e.preset)==="other"?String(((s=e.imap)==null?void 0:s.port)??""):"993",smtpHost:(e==null?void 0:e.preset)==="other"?((r=e.smtp)==null?void 0:r.host)??"":"",smtpPort:(e==null?void 0:e.preset)==="other"?String(((a=e.smtp)==null?void 0:a.port)??""):"465"}},B0=e=>e instanceof De?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},uW=e=>Object.fromEntries((e instanceof De?e.fields??[]:[]).map(n=>[n.field,n.message]));function fW({v2:e,writable:n,whyNot:s="sign_in"}){var G;const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(H0(null)),[f,g]=p.useState(""),[b,x]=p.useState(null),[h,v]=p.useState({}),[y,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),_=p.useRef(0),$=U=>{a(U),u(H0(U))},O=()=>{const U=++_.current;e.emailAccount().then(z=>{U===_.current&&($(z),c(null))}).catch(z=>{U===_.current&&c(B0(z))})};p.useEffect(()=>{n&&O()},[e,n]);const A=U=>{u(U),j(null)},L=U=>z=>A(Q=>({...Q,[U]:z.target.value})),M=()=>{const U=d.user.trim(),z=d.preset===(r==null?void 0:r.preset)&&r.imap&&r.smtp?{imap:r.imap,smtp:r.smtp}:{};return{preset:d.preset,address:d.address.trim(),...U?{user:U}:{},...f?{password:f}:{},...d.preset==="other"?{imap:{host:d.imapHost.trim(),port:Number(d.imapPort)},smtp:{host:d.smtpHost.trim(),port:Number(d.smtpPort)}}:z}},R=async(U,z)=>{x(null),v({}),N(!0);try{await z()}catch(Q){const K=uW(Q);Object.keys(K).length?v(K):x({title:U,error:B0(Q)})}finally{N(!1)}},P=U=>{U.preventDefault(),R("The account was not saved",async()=>{$(await e.saveEmailAccount(M())),g(""),j(null)})},D=()=>R("The account was not tested",async()=>{j(null),j(await e.testEmailAccount(M()))}),W=()=>R("The account was not removed",async()=>{E(!1),await e.removeEmailAccount(),$(dW),g(""),j(null)}),Y=t.jsxs("div",{className:ti,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Email"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The mail account your agents read, file and draft in, over IMAP and SMTP, and the account email triggers watch. Its password is sealed on this server and never shown again. Nothing is sent without asking you first."})]});if(!n)return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:qo,children:[Y,t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:Za[s]})]})});if(!r)return i?t.jsx(vt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:O,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The email account could not be read: ",i.code,": ",i.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."});const H=r.configured||r.password_unreadable,q=d.preset==="other",F=(U,z,Q)=>t.jsxs("div",{className:"grid grid-cols-[1fr_7rem] gap-2",children:[t.jsx(jt,{label:`${z} server`,error:h[`${U}.host`],children:t.jsx(ze,{name:`${U}_host`,value:U==="imap"?d.imapHost:d.smtpHost,onChange:L(U==="imap"?"imapHost":"smtpHost"),placeholder:Q,spellCheck:!1,autoCapitalize:"off"})}),t.jsx(jt,{label:"Port",error:h[`${U}.port`],children:t.jsx(ze,{name:`${U}_port`,inputMode:"numeric",value:U==="imap"?d.imapPort:d.smtpPort,onChange:L(U==="imap"?"imapPort":"smtpPort")})})]});return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:qo,children:[Y,t.jsxs("div",{className:ni,children:[b&&t.jsx(sa,{error:b.error,title:b.title}),i&&t.jsx(vt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:O,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The email account could not be read: ",i.code,": ",i.message,". What is shown may be out of date."]})}),t.jsxs(_r,{title:"Account",children:[t.jsxs("section",{className:"border bg-card p-4","aria-label":"Email account",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(CT,{className:"size-4 text-muted-foreground","aria-hidden":!0}),H?t.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:r.address}):t.jsx("span",{className:"text-body text-muted-foreground",children:"No email account is saved. The agents' email tools and email triggers need one."}),r.configured&&t.jsx(Ne,{tone:"success",children:"saved"}),H&&r.preset&&t.jsx(Ne,{children:((G=W0.find(U=>U.value===r.preset))==null?void 0:G.label)??r.preset})]}),H&&r.imap&&r.smtp&&t.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["IMAP ",r.imap.host,":",r.imap.port," · SMTP ",r.smtp.host,":",r.smtp.port,r.user&&r.user!==r.address?` · signs in as ${r.user}`:""]}),r.configured&&t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"Its password is sealed on this server. It is never shown again; type it again only to change the account."}),r.password_unreadable&&t.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),"Its password can't be opened here: it was sealed under another key, or is damaged. The agents can't read or send mail until it is saved again."]})]}),t.jsxs("form",{className:"space-y-4 border bg-card p-4","aria-label":"Account",onSubmit:P,children:[t.jsxs("fieldset",{disabled:S,className:"min-w-0 space-y-4",children:[t.jsx(jt,{label:"Provider",group:"heading",note:lW,error:h.preset,children:t.jsx(sd,{name:"email-preset",label:"Provider",value:d.preset,onChange:U=>A(z=>({...z,preset:U})),options:W0})}),t.jsx("p",{className:"text-small text-muted-foreground",children:iW[d.preset]}),t.jsx(jt,{label:"Address",error:h.address,children:t.jsx(ze,{name:"address",inputMode:"email",autoComplete:"username",spellCheck:!1,autoCapitalize:"off",placeholder:"you@example.com",value:d.address,onChange:L("address")})}),t.jsx(jt,{label:"Sign-in name",optional:!0,note:"When the server's sign-in isn't the address.",error:h.user,children:t.jsx(ze,{name:"user",spellCheck:!1,autoCapitalize:"off",value:d.user,onChange:L("user")})}),t.jsx(jt,{label:cW(d.preset),error:h.password,children:t.jsx(ze,{name:"password",type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true",placeholder:r.configured?"Sealed on this server: type it again to save a change":"",value:f,onChange:U=>{g(U.target.value),j(null)}})}),q&&F("imap","IMAP","imap.example.com"),q&&F("smtp","SMTP","smtp.example.com")]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",variant:"solid",disabled:S||!d.address.trim()||!f,children:"Save"}),t.jsx(B,{type:"button",variant:"outline",disabled:S||!d.address.trim()||!f&&!r.configured,onClick:()=>void D(),children:"Test"}),H&&!k&&t.jsx(B,{type:"button",variant:"outline",disabled:S,onClick:()=>E(!0),children:"Remove"})]}),k&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-body",children:[t.jsx("span",{children:"The agents' email tools and email triggers stop until an account is saved again."}),t.jsx(B,{type:"button",variant:"destructive",disabled:S,onClick:()=>void W(),children:"Remove the account"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>E(!1),children:"Cancel"})]}),y&&t.jsxs("div",{"aria-label":"Test",className:"space-y-1 font-mono text-body",children:[["imap","smtp"].map(U=>t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Ne,{tone:y[U].ok?"success":"error",children:U==="imap"?"IMAP":"SMTP"}),t.jsx("span",{className:y[U].ok?"":"text-destructive-text",children:y[U].message})]},U)),t.jsx("p",{className:"text-small text-muted-foreground",children:y.ok?"Both signed in. Nothing was sent, and nothing was saved by the test.":"Nothing was sent, and nothing was saved by the test."})]})]})]})]})]})})}const G0=e=>e instanceof De?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},mW={unreadable:"Its secret can't sign here: it was sealed under another key, or is damaged. Nothing is sent until the webhook is removed and set again."};function hW({v2:e}){const[n,s]=p.useState(null),[r,a]=p.useState([]),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(null),[b,x]=p.useState(null),[h,v]=p.useState(!1),[y,j]=p.useState(!1),[k,E]=p.useState(""),S=p.useRef(0),N=()=>{const O=++S.current;Promise.all([e.webhook(),e.webhookDeliveries()]).then(([A,L])=>{O===S.current&&(s(A),a(L.attempts),c(null))}).catch(A=>{O===S.current&&c(G0(A))})};p.useEffect(N,[e]);const _=async(O,A)=>{g(null),j(!0);try{await A()}catch(L){g({title:O,error:G0(L)})}finally{j(!1)}N()},$=O=>{O.preventDefault(),_("The webhook was not saved",async()=>{const A=await e.saveWebhook(k.trim());A.signing_secret&&u(A.signing_secret);const{signing_secret:L,...M}=A;s(M)})};return n?t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:qo,children:[t.jsxs("div",{className:ti,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Webhook"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"One URL this server POSTs to when a run needs its person (`run.needs_input`) and when it ends (`run.ended`), signed by the Standard Webhooks spec, so a receiver checks each message with any of that spec's libraries."})]}),t.jsxs("div",{className:ni,children:[f&&t.jsx(sa,{error:f.error,title:f.title}),i&&t.jsx(vt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:N,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",i.code,": ",i.message,". What is shown may be out of date."]})}),d&&t.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Webhook secret",children:[t.jsx("p",{className:"caps text-small font-semibold text-warning-text",children:"The signing secret, shown this once"}),t.jsx("p",{className:"mt-2 break-all font-mono text-body",children:d}),t.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:["Keep it where the receiver checks ",t.jsx("span",{className:"font-mono",children:"webhook-signature"}),". This server never shows it again."]}),t.jsx(B,{type:"button",variant:"outline",className:"mt-3",onClick:()=>u(null),children:"Done"})]}),t.jsx(_r,{title:"Endpoint",children:t.jsxs("section",{className:"border bg-card p-4","aria-label":"Webhook URL",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(rl,{className:"size-4 text-muted-foreground","aria-hidden":!0}),n.configured?t.jsx("span",{className:"min-w-0 break-all font-mono text-body",children:n.url}):t.jsx("span",{className:"text-body text-muted-foreground",children:"No webhook is set."}),n.configured&&(n.disabled?t.jsx(Ne,{tone:"error",children:"off"}):n.signing==="sealed"?t.jsx(Ne,{tone:"success",children:"on"}):t.jsx(Ne,{tone:"warning",children:"not signing"}))]}),n.configured&&n.disabled&&t.jsxs("p",{className:"mt-2 text-body text-destructive-text",children:["Off: ",n.disabled.reason,", ",ht(n.disabled.at),". Nothing is sent until the URL is saved again: enter it below."]}),n.configured&&n.signing!=="sealed"&&t.jsxs("p",{className:"mt-2 flex gap-2 text-body text-warning-text",children:[t.jsx(Gs,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),mW[n.signing]]}),t.jsxs("form",{className:"mt-4 flex flex-wrap gap-2",onSubmit:$,children:[t.jsx(ze,{name:"url",type:"url",required:!0,maxLength:2048,placeholder:n.configured?"The whole URL, to change it or save it again":"https://...",value:k,onChange:O=>E(O.target.value),className:"h-9 min-w-[280px] flex-1","aria-label":"Webhook URL"}),t.jsx(B,{type:"submit",variant:"solid",disabled:y||!k.trim(),children:"Save"}),n.configured&&t.jsx(B,{type:"button",variant:"outline",disabled:y,onClick:()=>_("The test was not sent",async()=>x(await e.testWebhook())),children:"Send a test"}),n.configured&&!h&&t.jsx(B,{type:"button",variant:"outline",disabled:y,onClick:()=>v(!0),children:"Remove"})]}),h&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-body",children:[t.jsx("span",{children:"Its pending messages are dropped; the log of attempts stays."}),t.jsx(B,{type:"button",variant:"destructive",disabled:y,onClick:()=>{v(!1),E(""),x(null),_("The webhook was not removed",async()=>{await e.removeWebhook(),s({configured:!1,secret:{name:"webhook:outbound",set:!1,source:null,changed_at:null}}),u(null)})},children:"Remove the webhook"}),t.jsx(B,{type:"button",variant:"ghost",onClick:()=>v(!1),children:"Cancel"})]}),b&&t.jsxs("p",{className:"mt-3 font-mono text-body","aria-label":"Test send",children:["Test send: ",q0(b)]})]})}),t.jsx(_r,{label:"Deliveries",title:"Last deliveries",aside:t.jsx(B,{type:"button",size:"sm",onClick:N,children:"Refresh"}),children:r.length===0?t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:"No message has been tried yet."}):t.jsx("ul",{className:"border",children:r.map((O,A)=>t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 text-body last:border-b-0",children:[t.jsx("span",{className:"w-[170px] shrink-0 text-muted-foreground",children:ht(O.at)}),t.jsx("span",{className:"w-[130px] shrink-0 font-mono",children:O.type}),t.jsx("span",{className:O.error?"min-w-0 flex-1 font-mono text-destructive-text":"min-w-0 flex-1 font-mono",children:q0(O)}),O.redelivery&&t.jsx(Ne,{children:"redelivery"}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",title:O.webhook_id,children:[O.webhook_id.slice(0,12),"…"]}),t.jsx(B,{type:"button",variant:"outline",size:"sm",disabled:y,onClick:()=>_("The message was not sent again",()=>e.redeliverWebhook(O.webhook_id)),children:"Redeliver"})]},`${O.webhook_id}:${O.at}:${A}`))})})]})]})}):i?t.jsx(vt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:N,children:"Try again"}),children:t.jsxs("p",{className:"font-mono",children:["The webhook could not be read: ",i.code,": ",i.message]})}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",children:"Loading..."})}function q0(e){const n=e.error??`${e.status_code}`,s=e.status_code!==null?`, ${e.latency_ms} ms`:"";return`${n}${s}${e.retry_at?`; tried again ${ht(e.retry_at)}`:""}`}const pW={none:{label:"None",gives:"The run's folder only."},sandbox:{label:"Sandbox",gives:"A Linux container."},desktop:{label:"Desktop",gives:"A screen, with a pointer and keys."},phone:{label:"Phone",gives:"A phone's screen and its apps."},browser:{label:"Browser",gives:"A browser the agent drives."}},Cx=e=>pW[e]??{label:e,gives:""},gW=e=>e instanceof De?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},Ex=e=>e.slice(e.lastIndexOf(":")+1),xW=2e3;function vW({v2:e,writable:n,whyNot:s="sign_in"}){const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(null),[f,g]=p.useState(null),[b,x]=p.useState({}),[h,v]=p.useState(new Set),y=p.useRef(0),j=p.useCallback(()=>{const _=++y.current;c(null),e.computers().then($=>{_===y.current&&a($)},$=>{_===y.current&&c(gW($))})},[e]);if(p.useEffect(j,[j]),!r)return i?t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["The computers could not be read: ",i.code,": ",i.message]}),t.jsx(B,{size:"sm",onClick:j,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Fn,{label:"Loading the computers",rows:3})});const k=new Set(r.paired.map(_=>_.id)),E=_=>r.kinds.filter($=>$.providers.some(O=>O.id===_)).map($=>$.kind),S=async(_,$,O)=>{g(null);try{await e.saveComputerKeys($.id,O)}catch(A){return A instanceof De&&A.status===422?A:(g({at:_,words:Ft(A)}),null)}return u(null),j(),null},N=async _=>{v(O=>new Set(O).add(_.id));let $;try{const O=await e.testComputer(_.id);$=O.ok?{ok:!0,words:O.detail,at:new Date().toISOString()}:{ok:!1,words:O.why,at:new Date().toISOString()}}catch(O){$={ok:!1,words:Ft(O),at:new Date().toISOString()}}x(O=>({...O,[_.id]:$})),v(O=>{const A=new Set(O);return A.delete(_.id),A})};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:qo,children:[t.jsxs("div",{className:ti,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Computers"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The computers an agent can be given, and who provides them. An agent can have a kind once one of its providers is ready. Keys are kept sealed on this server and never shown again."})]}),t.jsxs("div",{className:ni,children:[t.jsx(wW,{v2:e,paired:r.paired,reload:j}),!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:Za[s]}),r.kinds.map(_=>t.jsx(jW,{kind:_,providers:_.providers.filter($=>!k.has($.id)),own:_.providers.filter($=>k.has($.id)).map($=>$.name),children:_.providers.filter($=>!k.has($.id)).map($=>{const O=`${_.kind}/${$.id}`;return t.jsx(kW,{v2:e,kind:_.kind,provider:$,writable:n,serves:E($.id),tested:b[$.id],testing:h.has($.id),open:(d==null?void 0:d.at)===O?d.mode:null,problem:(f==null?void 0:f.at)===O?f.words:null,onOpen:A=>{u(A?{at:O,mode:A}:null),g(null)},onSave:A=>S(O,$,A),onRemove:async A=>{var M;const L=await S(O,$,{[A]:null});L&&g({at:O,words:((M=L.fields)==null?void 0:M.map(R=>R.message).join(" "))||L.message})},onTest:()=>void N($)},$.id)})},_.kind))]})]})})}function yW(e){const n=e.device?`${e.device.maker} ${e.device.model}`:null,s=e.os_version?`${e.os} ${e.os_version}`:e.os,r=e.screen?`screen ${e.screen.width}×${e.screen.height} at ${e.screen.scale}x`:null;return[e.serves.map(a=>Cx(a).label).join(", ")||Cx(e.kind).label,n,s,e.arch,r].filter(Boolean).join(" · ")}function bW(e){const n=Object.entries(e.features??{}).flatMap(([s,r])=>r!==!0&&typeof(r==null?void 0:r.off)=="string"?[`${s} off: ${r.off}`]:[]);return[`Offers ${e.groups.join(", ")}`,...n].join(" · ")}function wW({v2:e,paired:n,reload:s}){const[r,a]=p.useState(null),[i,c]=p.useState(!1),[d,u]=p.useState(()=>Date.now()),[f,g]=p.useState(null),[b,x]=p.useState(null),[h,v]=p.useState(null),y=r?Date.parse(r.code.expires_at)-d:0,j=r!==null&&y>0;p.useEffect(()=>{if(!j)return;const N=setInterval(()=>u(Date.now()),1e3),_=setInterval(s,xW);return()=>{clearInterval(N),clearInterval(_)}},[j,s]),p.useEffect(()=>{if(!r)return;const N=n.find(_=>_.pairing===r.code.id);N&&(g(N.name),a(null))},[n,r]);const k=async()=>{c(!0),v(null),g(null);try{const N=await e.createPairing();u(Date.now()),a({code:N})}catch(N){v(Ft(N))}c(!1)},E=async N=>{v(null);try{await e.removeComputer(N)}catch(_){v(Ft(_));return}x(null),s()},S=`${Math.floor(Math.max(0,y)/6e4)}:${String(Math.floor(Math.max(0,y)%6e4/1e3)).padStart(2,"0")}`;return t.jsxs(_r,{label:"Your computers",title:"Your computers",note:t.jsx("p",{children:"A computer or phone of your own, attached by the driver you run on it. An agent can be given it as its computer."}),aside:!r&&t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void k(),disabled:i,children:i?"Making…":"Pair a computer"}),f&&t.jsxs("p",{role:"status",className:"text-body text-success-text",children:["Paired ",f,"."]})]}),children:[r&&t.jsxs("div",{"data-pairing":!0,className:"space-y-3 border bg-card p-4",children:[t.jsxs("div",{className:"flex flex-wrap gap-x-8 gap-y-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Server address"}),t.jsx("p",{"data-address":!0,className:"mt-1 font-mono text-prose font-semibold",children:window.location.origin})]}),t.jsxs("div",{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Pairing code"}),t.jsx("p",{"data-code":!0,className:"mt-1 font-mono text-2xl font-semibold",children:r.code.code})]})]}),j?t.jsxs("p",{className:"text-body",children:["Type both into the driver on the computer. The code pairs one computer, once, in the next ",t.jsx("span",{"data-countdown":!0,className:"font-mono",children:S}),"."]}):t.jsx("p",{role:"status",className:"text-body text-muted-foreground",children:"This code has expired. Make a new one."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{size:"sm",onClick:()=>void k(),disabled:i,children:i?"Making…":"New code"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>a(null),children:"Done"})]})]}),h&&t.jsx("p",{role:"alert",className:"border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:h}),n.length?t.jsx("ul",{className:"border",children:n.map(N=>t.jsxs("li",{"data-paired":N.id,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[N.serves.includes("phone")?t.jsx(AN,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}):t.jsx(Va,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:N.name}),N.online?t.jsx(Ne,{tone:"success",children:"Online"}):t.jsx(Ne,{tone:"muted",children:"Offline"}),N.held_by_run&&t.jsxs(Ne,{tone:"active",children:["In use by run ",ta(N.held_by_run)]}),N.unserved&&t.jsx(Ne,{tone:"warning",children:"No agent can use it"})]}),N.unserved&&t.jsx("p",{"data-unserved":!0,role:"status",className:"mt-1.5 text-small text-warning-text",children:N.unserved}),N.held_by_run&&N.held_until&&t.jsxs("p",{"data-held-until":!0,className:"mt-1.5 text-small text-muted-foreground",children:["The run's hold ends by ",ht(N.held_until),", released or not."]}),!N.online&&t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:"Open its driver on that computer: it dials this server."}),t.jsx("p",{"data-machine":!0,className:"mt-2 text-small text-muted-foreground",children:yW(N)}),N.groups.length>0&&t.jsx("p",{"data-offers":!0,className:"mt-1 text-small text-muted-foreground",children:bW(N)}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:`Driver ${N.driver} · paired ${ht(N.created_at)}${N.seen_at?` · last attached ${ht(N.seen_at)}`:""}`})]}),t.jsx(B,{size:"sm",onClick:()=>{x(N.id),v(null)},disabled:b!==null,children:"Remove"})]}),b===N.id&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",N.name,"? Its driver stops dialing and asks for a new code",N.held_by_run?", and the run using it loses it":"","."]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void E(N.id),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>x(null),children:"Cancel"})]})]},N.id))}):t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:"None paired yet. Pair a computer, then type the server address and its code into the driver on it."})]})}function jW({kind:e,providers:n,own:s,children:r}){const{label:a,gives:i}=Cx(e.kind);return t.jsx(_r,{label:a,title:a,note:(i||!e.offered||s.length>0)&&t.jsxs(t.Fragment,{children:[i&&t.jsx("p",{children:i}),!e.offered&&t.jsx("p",{children:t.jsx(Ne,{tone:"muted",children:"Not offered here"})}),!e.offered&&e.why&&t.jsx("p",{className:"font-mono text-small",children:e.why}),s.length>0&&t.jsxs("p",{className:"text-small",children:["Also served by your computers: ",s.join(", "),"."]})]}),children:n.length?t.jsx("ul",{className:"border",children:r}):t.jsx("p",{className:"border p-4 text-body text-muted-foreground",children:e.kind==="none"?"Nothing to set up.":s.length?"No other provider serves it on this server.":"No provider serves it on this server."})})}function kW({v2:e,kind:n,provider:s,writable:r,serves:a,tested:i,testing:c,open:d,problem:u,onOpen:f,onSave:g,onRemove:b,onTest:x}){const h=p.useRef(null),v=d&&"paste"in d?d.paste:null,y=d&&"remove"in d?d.remove:null;return t.jsxs("li",{ref:h,className:"border-b p-4 last:border-b-0",children:[t.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[t.jsx(Va,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{"data-provider":!0,className:"font-mono text-prose font-semibold",children:s.name}),s.ready?t.jsx(Ne,{tone:"success",children:"Ready"}):t.jsx(Ne,{children:"Not ready"}),s.metered&&t.jsx("span",{"data-metered":!0,className:"text-small text-muted-foreground",children:"Metered"})]}),!s.ready&&s.why&&t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:s.why}),s.metered&&ry.has(n)&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:sy}),s.secrets.length>0&&t.jsx("ul",{className:"mt-3 space-y-1.5",children:s.secrets.map(j=>{var S;const k=Ex(j.name),E=((S=s.picked)==null?void 0:S.includes(j.name))??!1;return t.jsx(rh,{field:j,required:s.required.includes(j.name),writable:r&&!d,onPaste:E?void 0:()=>void sh(()=>f({paste:k}),()=>{var N,_;return(_=(N=h.current)==null?void 0:N.querySelector("form"))==null?void 0:_.elements.namedItem(k)}),onRemove:()=>f({remove:k})},j.name)})}),s.picked&&s.picked.length>0&&s.required.every(j=>s.secrets.some(k=>k.name===j&&k.set))&&t.jsx(NW,{v2:e,provider:s,writable:r&&!d,onSave:g}),i&&t.jsx("p",{"data-test":!0,className:`mt-2 text-small ${i.ok?"text-success-text":"text-destructive-text"}`,children:`${i.ok?"Passed":"Failed"} · ${od(i.at)} · ${i.words}`}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:[s.secrets.length?"":"No key. ","Serves: ",a.join(", ")]})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx(B,{size:"sm",onClick:x,disabled:c,children:c?"Testing…":"Test connection"})})]}),r&&v&&t.jsx(SW,{provider:s.name,name:v,set:s.secrets.some(j=>Ex(j.name)===v&&j.set),onSave:g,onCancel:()=>f(null)}),r&&y&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",y," saved on this server?"]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void b(y),children:"Remove"}),t.jsx(B,{size:"sm",onClick:()=>f(null),children:"Cancel"})]}),u&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:u})]})}function NW({v2:e,provider:n,writable:s,onSave:r}){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(null),g=n.secrets.map(x=>`${x.name}:${x.set}:${x.changed_at??""}`).join(" ");p.useEffect(()=>{let x=!0;return i(null),d(null),e.computerChoices(n.id).then(h=>{x&&i(h)},h=>{x&&d(Ft(h))}),()=>{x=!1}},[e,n.id,g]);const b=async(x,h)=>{var y;f({key:x.key,value:h}),d(null);const v=await r({[x.key]:h});f(null),v&&d(((y=v.fields)==null?void 0:y.map(j=>j.message).join(" "))||v.message)};return c&&!a?t.jsx("p",{role:"alert",className:"mt-3 font-mono text-small text-destructive-text",children:`The choices could not be read: ${c}`}):a?t.jsxs("div",{className:"mt-3 space-y-3",children:[a.choices.map(x=>{const h=n.secrets.find(y=>Ex(y.name)===x.key),v=(h==null?void 0:h.source)==="env";return t.jsxs("div",{"data-choices":x.key,className:"border bg-card p-3",children:[t.jsx("p",{className:"caps mb-2 text-small font-semibold",children:x.key}),"why"in x?t.jsx("p",{"data-why":!0,className:"font-mono text-small text-warning-text",children:x.why}):t.jsxs(t.Fragment,{children:[t.jsx(Rt,{label:`${n.name} ${x.key}`,value:(u==null?void 0:u.key)===x.key?u.value:x.saved??"",disabled:!s||v||u!==null,options:x.options.map(y=>({value:y.value,label:y.label})),placeholder:"Pick one",onChange:y=>void b(x,y),className:"w-full max-w-md"}),t.jsx("p",{"data-choice-note":!0,className:`mt-2 text-small ${h!=null&&h.set&&x.saved===void 0?"text-warning-text":"text-muted-foreground"}`,children:v?`Set in the environment where AgentRun starts, and that one is used: change ${x.key} there.`:x.saved!==void 0?"Picked and saved on this server.":h!=null&&h.set?`The ${x.key} saved on this server is not one of these any more, and runs still ask for it: pick one.`:x.options.length===1?`The only one, ${x.options[0].label}, is used while none is picked.`:`${x.options.length} to pick from. Pick the one this server's computers use.`})]})]},x.key)}),c&&t.jsx("p",{role:"alert",className:"font-mono text-small text-destructive-text",children:c})]}):t.jsx("p",{role:"status",className:"mt-3 text-small text-muted-foreground",children:"Reading the choices…"})}function SW({provider:e,name:n,set:s,onSave:r,onCancel:a}){const i=p.useRef(null),[c,d]=p.useState(!1),[u,f]=p.useState(!1),[g,b]=p.useState(null),x=()=>{var y,j;return((j=(y=i.current)==null?void 0:y.elements.namedItem(n))==null?void 0:j.value)??""},h=()=>{var y;(y=i.current)==null||y.reset(),d(!1)},v=async y=>{var N;y.preventDefault();const j=x();if(!j)return;f(!0),b(null);const k=await r({[n]:j});if(f(!1),!k){h();return}const E=(N=k.fields)==null?void 0:N.find(_=>_.field===n),S=(k.fields??[]).filter(_=>_.field!==n).map(_=>_.message);b(E?{field:E.message,message:S.join(" ")}:{field:null,message:S.join(" ")||k.message})};return t.jsxs("form",{ref:i,autoComplete:"off",onSubmit:y=>void v(y),onInput:()=>d(!!x()),className:"mt-4 space-y-4 border bg-card p-4","aria-label":`${e} ${n}`,children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:n}),s&&t.jsx("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:"A new value replaces the one saved."}),t.jsx(ze,{type:"password",name:n,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(g==null?void 0:g.field)&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:g.field})]}),(g==null?void 0:g.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:g.message}),t.jsx("p",{className:"text-small text-muted-foreground",children:"Kept sealed on this server. It is never shown again, here or anywhere."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:!c||u,children:u?"Saving":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{h(),a()},children:"Cancel"})]})]})}const CW="Each agent keeps its runs' folders on its own Archil disk, made on its first run in this region. The server never mounts one; computers that support it mount a run's folder.",K0=[{name:"region",label:"Region"},{name:"s3Url",label:"S3 URL",placeholder:"https://"},{name:"image",label:"Image",placeholder:"serve's default, Debian with git 2.47 (recommended)"}],EW=e=>({region:e.region??"",s3Url:e.s3Url??"",image:e.image??""}),yr="ARCHIL_API_KEY",$W=e=>e instanceof De?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function _W({v2:e,writable:n,whyNot:s="sign_in"}){const[r,a]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState({region:"",s3Url:"",image:""}),[f,g]=p.useState(null),[b,x]=p.useState(null),[h,v]=p.useState(!1),[y,j]=p.useState(null),[k,E]=p.useState(!1),[S,N]=p.useState(!1),[_,$]=p.useState(!1),[O,A]=p.useState(!1),L=p.useRef(null),M=p.useRef(0),R=p.useCallback(F=>{a(F),u(EW(F))},[]),P=p.useCallback(()=>{const F=++M.current;c(null),e.archil().then(G=>{F===M.current&&R(G)},G=>{F===M.current&&c($W(G))})},[e,R]);if(p.useEffect(P,[P]),!r)return i?t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"font-mono text-body text-destructive-text",children:["Archil's settings could not be read: ",i.code,": ",i.message]}),t.jsx(B,{size:"sm",onClick:P,className:"mt-3",children:"Try again"})]}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Fn,{label:"Loading Archil's settings",rows:2})});const D=()=>{var F,G;return((G=(F=L.current)==null?void 0:F.elements.namedItem(yr))==null?void 0:G.value)??""},W=async F=>{const G={region:d.region,s3Url:d.s3Url,...d.image?{image:d.image}:{},...F!==void 0?{keys:{[yr]:F}}:{}};v(!0),g(null),x(null);try{const U=await e.saveArchil(G);$(!1),A(!1),R(U)}catch(U){if(U instanceof De&&U.status===422){const z={},Q=[];for(const K of U.fields??[]){const Z=K.field.startsWith("keys.")?K.field.slice(5):K.field;K0.some(de=>de.name===Z)||Z===yr?z[Z]=K.message:Q.push(K.message)}g({fields:z,message:Q.length?Q.join(" "):Object.keys(z).length?null:U.message})}else x(Ft(U))}finally{v(!1)}},Y=F=>{F.preventDefault(),W(_&&D()?D():void 0)},H=async()=>{E(!0);try{const F=await e.testArchil();j(F.ok?{ok:!0,words:F.detail,at:new Date().toISOString()}:{ok:!1,words:F.why,at:new Date().toISOString()})}catch(F){j({ok:!1,words:Ft(F),at:new Date().toISOString()})}finally{E(!1)}},q=async()=>{x(null);try{R(await e.archilOff()),N(!1)}catch(F){x(Ft(F))}};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:qo,children:[t.jsxs("div",{className:ti,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Settings"}),t.jsx("h1",{className:"mt-1 text-2xl font-semibold",children:"Workspace"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:CW})]}),t.jsxs("div",{className:ni,children:[!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:Za[s]}),t.jsx(_r,{title:"Disk",children:t.jsxs("section",{"aria-label":"Archil",className:"border p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(bT,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"font-mono text-prose font-semibold",children:"Archil"}),t.jsx("span",{"data-archil-state":!0,children:r.on?t.jsx(Ne,{tone:"success",children:"On"}):t.jsx(Ne,{children:"Off"})}),r.on&&t.jsx("span",{"data-disk":!0,className:"font-mono text-small text-muted-foreground",children:r.region??""}),t.jsx("span",{className:"flex-1"}),t.jsx(B,{size:"sm",onClick:()=>void H(),disabled:k,children:k?"Testing…":"Test"}),r.on&&t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>N(!0),children:"Turn off"})]}),y&&t.jsx("p",{"data-test":!0,className:`mt-3 text-small ${y.ok?"text-success-text":"text-destructive-text"}`,children:`${y.ok?"Passed":"Failed"} · ${od(y.at)} · ${y.words}`}),S&&t.jsxs("div",{"data-confirm":!0,className:"mt-4 flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-body",children:"Turn Archil off? Its keys are kept, for turning it on again."}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>void q(),children:"Turn off"}),t.jsx(B,{size:"sm",onClick:()=>N(!1),children:"Cancel"})]}),b&&t.jsx("p",{role:"alert",className:"mt-4 border border-destructive/50 px-3 py-2 font-mono text-small text-destructive-text",children:b}),t.jsxs("form",{ref:L,autoComplete:"off",onSubmit:Y,className:"mt-5 space-y-4","aria-label":"Archil settings",children:[K0.map(F=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:F.label}),t.jsx(ze,{name:F.name,value:d[F.name],placeholder:F.placeholder,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:G=>{const U=G.currentTarget.value;u(z=>({...z,[F.name]:U}))}}),(f==null?void 0:f.fields[F.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[F.name]})]},F.name)),t.jsx("ul",{children:t.jsx(rh,{field:r.secret,label:yr,writable:n&&!_&&!O,onPaste:()=>void sh(()=>$(!0),()=>{var F;return(F=L.current)==null?void 0:F.elements.namedItem(yr)}),onRemove:()=>A(!0)})}),n&&O&&t.jsxs("div",{"data-confirm-key":!0,className:"flex flex-wrap items-center gap-3 border bg-card p-3",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:["Remove ",yr," saved on this server?"]}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:()=>void W(null),children:"Remove"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>A(!1),children:"Cancel"})]}),n&&_&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:yr}),t.jsx(ze,{type:"password",name:yr,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(f==null?void 0:f.fields[yr])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[yr]})]}),n&&_&&t.jsx(B,{type:"button",size:"sm",onClick:()=>$(!1),children:"Cancel"}),(f==null?void 0:f.message)&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:f.message}),t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:h,children:h?"Saving":r.on?"Save":"Turn on"})]})]})})]})]})})}const UE="tool_approval_requested";function TW(e){var n;return e.status!=="input_required"||e.state!=="waiting"?null:((n=e.pending)==null?void 0:n.kind)==="approval"?e.pending:null}function RW(e){return e==="not metered"?"Not metered":e==="priced by usage"?"Priced by usage: monid estimates the cost when the call runs, and can charge more.":e===0?"Costs nothing per call":typeof e=="number"?`Costs ${Zr(e)} per call`:null}function AW(e){let n;try{n=JSON.parse(e)}catch{return e}return!n||typeof n!="object"||Array.isArray(n)?JSON.stringify(n,null,2):Object.entries(n).map(([s,r])=>`${s}: ${typeof r=="string"?r:JSON.stringify(r)}`).join(`
|
|
695
|
+
`)}const OW={allow:"This call was already allowed, in another tab or by another answer. The run shows what happened next.",deny:"This call was already declined. The run shows what happened next.",withdrawn:"The run was stopped before this call ran, so it was withdrawn and never ran.",canceled:"The run was cancelled before this call ran, so it never ran."};function WE(e){var n;if(e instanceof De){const s=((n=e.details)==null?void 0:n.reason)==="already_answered"&&typeof e.details.decision=="string"?OW[e.details.decision]:void 0;if(e.status===409&&s)return s;if(e.status===403)return"Only the owner, signed in with the password on this page, can answer an approval.";if(e.status===401)return"Your sign-in ended. Sign in again to answer.";if(e.status===404)return"This run no longer waits on that call."}return Ft(e)}const MW=2e3;function HE({pending:e,onAnswer:n,compact:s=!1,heading:r}){const[a,i]=p.useState(""),[c,d]=p.useState(!1),[u,f]=p.useState(null),[g,b]=p.useState(null),[x,h]=p.useState(!1),v=e.destructive===!0,y=p.useRef(!1),j=p.useRef(null),k=p.useRef(!1);p.useEffect(()=>{var N;x||!k.current||(k.current=!1,(N=j.current)==null||N.focus())},[x]);const E=RW(e.price),S=async(N,_)=>{if(y.current)return;y.current=!0,d(!0),f(null),h(!1);const $=a.trim(),O=await(_?n(N,void 0,_):n(N,N==="deny"&&$?$:void 0));y.current=!1,d(!1),O?f(O):b(N)};return t.jsxs("section",{"aria-label":"Approval required",className:oe("min-w-0 border border-warning/50 bg-warning/5",s?"p-4":"p-4 md:p-5"),children:[r,t.jsxs("p",{className:oe("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-2"),children:[t.jsx(RN,{className:"size-3.5","aria-hidden":!0})," Approval required"]}),t.jsxs("p",{className:"mt-2 text-prose leading-snug",children:["The agent wants to run ",t.jsx("span",{className:"break-all font-mono text-lead",children:e.tool}),".",v&&t.jsxs(t.Fragment,{children:[" ",t.jsx(Ne,{tone:"error",title:"Its server marks this tool destructive: it may delete or overwrite.",children:"Destructive"})]})]}),t.jsx("pre",{"aria-label":`${e.tool} arguments`,title:e.args_preview,className:oe("mt-2 overflow-auto whitespace-pre-wrap break-all border bg-card p-3 font-mono text-small leading-[1.6]",s?"max-h-28":"max-h-64"),children:AW(e.args_preview)}),E&&t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:E}),g?t.jsx("p",{className:"mt-3 font-mono text-body text-success-text",role:"status",children:g==="allow"?"Allowed. The run goes on.":"Denied. The agent reads why and goes on."}):t.jsxs("div",{className:"mt-3 space-y-2",children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"text-small text-muted-foreground",children:"Tell the agent why (optional, sent with Deny)"}),t.jsx(dn,{value:a,onChange:N=>i(N.target.value),maxLength:MW,rows:s?1:2,disabled:c,className:"mt-1 block resize-y py-2 font-sans text-lead"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{ref:j,type:"button",variant:"solid",size:"sm",disabled:c||x,onClick:()=>v?h(!0):void S("allow"),children:"Allow once"}),t.jsx(B,{type:"button",size:"sm",disabled:c,onClick:()=>void S("deny"),children:"Deny"}),c&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]}),x&&t.jsx(PW,{tool:e.tool,onAllow:()=>void S("allow",!0),onBack:()=>{k.current=!0,h(!1)}}),!s&&t.jsx("p",{className:"text-small text-muted-foreground",children:"or type what to do instead; sending it declines this call"}),u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:u})]})]})}function PW({tool:e,onAllow:n,onBack:s}){const r=p.useRef(null);return p.useEffect(()=>{var a;(a=r.current)==null||a.focus()},[]),t.jsxs("div",{role:"alertdialog","aria-label":`Allow ${e}?`,onKeyDown:a=>{a.key==="Escape"&&(a.stopPropagation(),s())},className:"flex flex-wrap items-center gap-3 border border-destructive/50 bg-card px-3 py-2.5",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-body",children:[t.jsx("span",{className:"font-semibold",children:"Allow a destructive call?"})," Its server marks ",t.jsx("span",{className:"break-all font-mono",children:e})," as one that may delete or overwrite."]}),t.jsx(B,{ref:r,type:"button",size:"sm",variant:"ghost",onClick:s,children:"Back"}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:n,children:"Allow this destructive call"})]})}const LW={steer:{label:"Steer the run",placeholder:"Steer the run...",does:"The agent reads it when its current step ends."},answer:{label:"Answer the question",placeholder:"Answer the question...",does:"Answers what the agent asked; the run goes back to work."},follow_up:{label:"Ask a follow-up",placeholder:"Ask a follow-up question...",does:"Continues this run with your message; the same spend cap applies."}};function IW({mode:e,onSend:n,sending:s,sent:r,purpose:a}){const i=a??LW[e],[c,d]=p.useState(""),[u,f]=p.useState(!1),g=s||u,b=async()=>{if(!c.trim()||!n||g)return;f(!0);const x=await n(c.trim());f(!1),x!==!1&&d("")};return t.jsxs("form",{className:"border bg-card focus-within:border-foreground",onSubmit:x=>{x.preventDefault(),b()},children:[t.jsx(dn,{bare:!0,id:"composer",rows:2,value:c,readOnly:g,"aria-busy":g,onChange:x=>d(x.target.value),placeholder:i.placeholder,onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),b())},className:"block w-full resize-none px-4 pt-3"}),t.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 pb-3",children:[t.jsxs("span",{className:"min-w-0 text-label text-muted-foreground",children:[t.jsx("label",{htmlFor:"composer",className:"font-semibold text-foreground",children:i.label})," · ",r?"Sent. It appears on the timeline when the run takes it.":i.does]}),t.jsxs(B,{type:"submit",size:"sm",disabled:!c.trim()||!n||g,children:[g?"Sending":"Send"," ",t.jsx(mT,{"aria-hidden":!0})]})]})]})}function Yr(e){if(Number.isInteger(e))return`$${e}`;for(let n=2;n<8;n++)if(Number(e.toFixed(n))===Number(e.toFixed(8)))return`$${e.toFixed(n)}`;return`$${e.toFixed(8)}`}const BE=e=>`Paused at its ${typeof e.cap_usd=="number"&&Number.isFinite(e.cap_usd)?`${Yr(e.cap_usd)} `:""}spend cap`;function zW({pending:e}){return t.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"Paused at its spend cap",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[t.jsx(Dx,{className:"size-3.5","aria-hidden":!0})," ",BE(e)]}),typeof e.said=="string"&&t.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:e.said}),t.jsx("p",{className:"mt-1 text-body text-muted-foreground",children:"It waits for its cap to be raised; a message can't go on until then."})]})}const GE=e=>typeof(e==null?void 0:e.suggested_cap_usd)=="number"&&Number.isFinite(e.suggested_cap_usd)?e.suggested_cap_usd:null,qE=e=>typeof(e==null?void 0:e.least_cap_usd)=="number"&&Number.isFinite(e.least_cap_usd)?e.least_cap_usd:null;function DW(e){var n,s;return e instanceof De?e.status===422?((s=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message:e.status===409?"This run has ended, so its cap can't be raised.":e.status===404?"This run is no longer on the server.":e.message:e instanceof Error?e.message:String(e)}function KE({cap:e,suggested:n,least:s=null,paused:r,onRaise:a}){const[i,c]=p.useState(n===null?"":String(n)),[d,u]=p.useState(!1),[f,g]=p.useState(null),[b,x]=p.useState(null),h=p.useRef(!1),v=Number(i),y=i.trim()!==""&&Number.isFinite(v)&&v>0,j=async k=>{if(k==null||k.preventDefault(),!(!y||h.current)){h.current=!0,u(!0),g(null),x(null);try{const E=await a(v);E.note&&x(E.note)}catch(E){g(DW(E))}finally{h.current=!1,u(!1)}}};return t.jsxs("form",{className:"border border-warning/50 p-4","aria-label":"Raise the cap",onSubmit:k=>void j(k),children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("label",{className:"flex items-center gap-2 font-mono text-body",children:[t.jsx("span",{className:"text-muted-foreground",children:"$"}),t.jsx(ze,{"aria-label":"New cap in dollars",inputMode:"decimal",value:i,onChange:k=>c(k.target.value),disabled:d,placeholder:`more than ${Yr(e)}`,className:"h-9 w-32"})]}),t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:d||!y,children:d?"Raising":r?"Raise the cap and continue":"Raise the cap"})]}),(s!==null||n!==null)&&t.jsxs("ul",{className:"mt-2 space-y-0.5 font-mono text-small","aria-label":"Cap figures",children:[s!==null&&t.jsxs("li",{"data-cap-figure":"least",children:["Least to continue: ",Yr(s)]}),n!==null&&t.jsxs("li",{"data-cap-figure":"suggested",children:["Suggested: ",Yr(n)]})]}),n!==null&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"The suggestion is prefilled; change it before you raise, if you like."}),f&&t.jsx("p",{className:"mt-2 text-body text-destructive-text",role:"alert",children:f}),b&&t.jsx("p",{className:"mt-2 text-body text-muted-foreground",role:"status",children:b})]})}function FW({waiting:e}){if(e){const n=(e.text??e.summary??"").replace(/^Waiting for you:\s*/,"");return t.jsxs("section",{className:"border border-warning/50 bg-warning/5 p-4","aria-label":"The agent asks",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-warning-text",children:[t.jsx(Wx,{className:"size-3.5","aria-hidden":!0})," Input required"]}),t.jsx("p",{className:"mt-2 text-prose leading-relaxed",children:n})]})}return t.jsxs("section",{className:"border border-border-strong/60 p-4","aria-label":"Stopped",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[t.jsx(sl,{className:"size-3.5","aria-hidden":!0})," Stopped"]}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"The turn was stopped. The run stays open: send a message to continue it."})]})}let tl=0;const $x=()=>{var n;const e=(n=history.state)==null?void 0:n.console_at;return typeof e=="number"?e:void 0},V0=e=>{tl=e,history.replaceState({...history.state??{},console_at:e},"")};function UW(){const e=$x();e===void 0?V0(0):tl=e;const n=()=>{const s=$x();s===void 0?V0(tl+1):tl=s};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)}function WW(){const e=$x();return e===void 0?-1:tl-e}function HW(e){tl>0?history.back():location.hash=e}const BW=(e,n)=>{const s=jl(e),r=ad(e)?D2:void 0;return s?r?`${lk(s,{ended:n})} ${r}`:lk(s,{ended:n}):e&&e.usd!==null&&GS(e)?r?`A local estimate, not a bill. ${r}`:"A local estimate, not a bill":r};function GW({run:e,agentName:n,actions:s={},costText:r}){var E,S,N;const a=Zn(e),i=a?"your backend":FP(e.place),c=Lm(e.status,e.state,e.kind,Pm,!0,e.error,e.review,e.computer),d=a?{...c,canStop:!1,canCancel:!1}:c,[u,f]=p.useState(!1),g=!!e.archived_at,b=(E=e.cost)==null?void 0:E.cap_usd,x=!!e.pending&&e.pending.kind!=="budget"&&e.pending.kind!=="stopped",h=!a&&!!s.onRaiseCap&&!d.final&&typeof b=="number"&&!x,[v,y]=p.useState(!1),j=((S=e.pending)==null?void 0:S.kind)==="budget"?e.pending:null,k=!!ad(e.cost);return t.jsxs("header",{className:"border-b px-5 py-4 max-sm:py-3 md:px-8",children:[t.jsxs("nav",{className:"caps flex min-w-0 items-center gap-2 text-label text-muted-foreground","aria-label":"Breadcrumb",children:[t.jsx("button",{type:"button","aria-label":"Back",title:"Back",onClick:()=>HW(ln(e.agent_id)),className:"-m-1.5 shrink-0 p-1.5 hover:text-foreground",children:t.jsx(zn,{className:"size-3.5","aria-hidden":!0})}),t.jsx("a",{href:ln(e.agent_id),className:"-my-1 truncate py-1 hover:text-foreground hover:underline",children:n}),t.jsx("span",{"aria-hidden":!0,children:"/"}),t.jsxs("span",{className:"truncate",children:["Run ",ta(e.run_id)]})]}),t.jsxs("div",{"data-phone-row":!0,className:"mt-3 flex flex-col items-start gap-x-6 gap-y-3 max-sm:mt-2 max-sm:flex-row max-sm:flex-wrap max-sm:items-center max-sm:gap-x-3 max-sm:gap-y-2 sm:flex-row sm:flex-wrap",children:[t.jsxs("div",{className:"min-w-0 flex-1 self-stretch max-sm:contents sm:basis-64",children:[t.jsx("h1",{className:"line-clamp-2 break-words text-2xl font-semibold leading-tight max-sm:basis-full max-sm:text-lg",title:Sn(e),children:e.kind==="workflow"&&/^[[{]/.test(e.title.trim())?n:Sn(e)}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-small text-muted-foreground max-sm:contents",children:[t.jsx(Nl,{run:e}),g&&t.jsx(Ne,{tone:"muted",children:"Archived"}),e.approvals==="never"&&t.jsx(Ne,{tone:"warning",title:"This run's agent never asks: no call of it waits for you.",children:"Unattended"}),t.jsxs("span",{className:"font-mono",children:[e.kind," · rev ",e.agent_version,i&&` · ${i}`]}),a&&t.jsxs("span",{className:"font-mono",children:[Vo(a.runtime)," · ",((N=e.sdk)==null?void 0:N.model)??"Model not reported"]}),t.jsx("span",{className:"font-mono",children:ht(e.created_at)}),r!==void 0&&!k?t.jsx("span",{className:"font-mono",title:"The run's decisions and model calls, as the providers priced them",children:ck(e.cost,b,{text:r})}):t.jsxs("span",{className:"font-mono",title:BW(e.cost,Wa(e.status)),children:[ck(e.cost,b,{ended:Wa(e.status)}),k&&t.jsxs(t.Fragment,{children:[" · ",t.jsx(ay,{})]})]}),t.jsx(ey,{run:e,link:!0}),t.jsx(PE,{run:e})]}),e.status==="completed"&&e.review&&t.jsxs("p",{className:"mt-2 text-body text-warning-text max-sm:mt-0 max-sm:basis-full",children:["Needs review: ",e.review.reason]})]}),(d.canStop||d.canCancel||s.onArchive||h)&&t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[h&&t.jsxs(B,{size:"sm",onClick:()=>y(_=>!_),"aria-expanded":v,title:`Raise its ${Yr(b)} spend cap.`,children:[t.jsx(Dx,{"aria-hidden":!0})," Raise the cap"]}),d.canStop&&t.jsxs(B,{size:"sm",onClick:s.onStop,disabled:!s.onStop||!!s.busy,title:e.native?"Stop this native turn. Start a new run for another task.":"End this turn. The run stays open and waits for your next message.",children:[t.jsx(zT,{"aria-hidden":!0})," ",s.busy==="stop"?"Stopping":"Stop"]}),d.canCancel&&!u&&t.jsxs(B,{size:"sm",variant:"destructive",onClick:()=>f(!0),disabled:!s.onCancel||!!s.busy,title:"End the run for good.",children:[t.jsx(NN,{"aria-hidden":!0})," ",s.busy==="cancel"?"Cancelling":"Cancel run"]}),u&&t.jsxs("span",{className:"flex items-center gap-2 border border-destructive/50 px-2 py-1 text-small",role:"alertdialog","aria-label":"Cancel this run?",children:[t.jsx("span",{children:"Cancel for good?"}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>{var _;f(!1),(_=s.onCancel)==null||_.call(s)},children:"Yes, cancel"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>f(!1),children:"Keep"})]}),s.onArchive&&t.jsxs(B,{size:"sm",onClick:s.onArchive,disabled:!!s.busy,title:g?"Show it in the runs list again.":"Hide it from the runs list. Its history is kept.",children:[g?t.jsx(kN,{"aria-hidden":!0}):t.jsx(Qc,{"aria-hidden":!0})," ",s.busy==="archive"?g?"Unarchiving":"Archiving":g?"Unarchive":"Archive"]})]})]}),h&&v&&t.jsx("div",{className:"mt-3 max-w-xl",children:t.jsx(KE,{cap:b,suggested:GE(j),least:qE(j),paused:!!j,onRaise:s.onRaiseCap},j?`${e.run_id}:${j.at}`:`${e.run_id}:working`)})]})}const qW=[{id:"rendered",label:"Rendered"},{id:"raw",label:"Raw"}];function KW({view:e,onView:n}){return t.jsx("div",{className:"flex",role:"radiogroup","aria-label":"View",children:qW.map(s=>t.jsxs("label",{className:oe("caps -ml-px cursor-pointer border px-3 py-1.5 text-label first:ml-0 has-[:focus-visible]:outline has-[:focus-visible]:outline-1 has-[:focus-visible]:outline-offset-2",e===s.id?"relative border-foreground bg-foreground text-background":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[t.jsx("input",{type:"radio",name:"file-view",value:s.id,checked:e===s.id,onChange:()=>n(s.id),className:"sr-only"}),s.label]},s.id))})}const VE=(e,n)=>n?e:e.filter(s=>!p2(s.path));function VW({files:e,onOpen:n,showHidden:s,onShowHidden:r}){const a=e.filter(d=>p2(d.path)).length,i=VE(e,s),c=i.reduce((d,u)=>d+u.size_bytes,0);return t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center gap-3",children:[t.jsxs("p",{className:"caps flex items-center gap-2 text-label text-muted-foreground",children:[t.jsx(vT,{className:"size-3.5","aria-hidden":!0})," Files · ",i.length," ",i.length===1?"file":"files"," (",il(c),")"]}),a>0&&t.jsxs("button",{type:"button",className:"caps ml-auto text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline","aria-pressed":s,onClick:()=>r(!s),children:[s?"Hide":"Show"," ",a," hidden"]})]}),i.length===0?t.jsx("p",{className:"border px-4 py-8 text-center font-mono text-body text-muted-foreground",children:a?`Only files in hidden folders (${a}).`:"This run wrote no files."}):t.jsx("ul",{className:"border",children:i.map(d=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("button",{type:"button",onClick:()=>n(d),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left hover:bg-accent",children:[t.jsx(Ka,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:d.path}),t.jsx("span",{className:"hidden font-mono text-label text-muted-foreground sm:inline",children:ht(d.modified_at)}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:il(d.size_bytes)})]})},d.path))})]})}function YW({file:e,text:n,onClose:s,files:r=[],onOpen:a}){const[i,c]=p.useState(!1),d=p.useRef(null);p.useEffect(()=>{var k;const y=document.activeElement,j=d.current;return j&&!j.open&&((k=j.showModal)==null||k.call(j)),()=>{var E;j!=null&&j.open&&j.close(),(E=y==null?void 0:y.focus)==null||E.call(y)}},[]),p.useEffect(()=>c(!1),[e.path]);const u=p.useRef(!1),f=p.useRef(!1),g=yP(e),[b,x]=p.useState(g==="markdown"?"rendered":"raw");p.useEffect(()=>x(g==="markdown"?"rendered":"raw"),[e.path]);const h=jv(y=>{const j=r.find(k=>k.path===y);j&&(a==null||a(j))}),v=()=>{if(n===null)return;const y=URL.createObjectURL(new Blob([n],{type:e.content_type??"application/octet-stream"}));Object.assign(document.createElement("a"),{href:y,download:e.path.split("/").pop()}).click(),URL.revokeObjectURL(y)};return t.jsx("dialog",{ref:d,"aria-label":e.path,onCancel:y=>{y.preventDefault(),s()},onMouseDown:y=>{u.current=y.target===y.currentTarget},onMouseUp:y=>{f.current=y.target===y.currentTarget},onClick:y=>{u.current&&f.current&&y.target===y.currentTarget&&s(),u.current=f.current=!1},className:"m-0 h-full max-h-none w-full max-w-none border-0 bg-transparent p-0 text-foreground backdrop:bg-overlay/60 md:p-8",children:t.jsxs("div",{className:"mx-auto flex h-full w-full max-w-5xl flex-col border bg-background",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-2.5",children:[t.jsx(B,{size:"icon",variant:"ghost",onClick:s,"aria-label":"Close",children:t.jsx(Jo,{"aria-hidden":!0})}),t.jsx(Ka,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-body",children:e.path}),g!=="download"&&t.jsx("div",{className:"order-last basis-full sm:order-none sm:basis-auto",children:t.jsx(KW,{view:b,onView:x})}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:async()=>{var y;n!==null&&(await((y=navigator.clipboard)==null?void 0:y.writeText(n)),c(!0))},children:[t.jsx(qa,{"aria-hidden":!0})," ",i?"Copied":"Copy"]}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:v,children:[t.jsx(pT,{"aria-hidden":!0})," Download"]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-6 py-8 md:px-16",children:n===null?t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"Loading the file..."}):g==="download"?t.jsx("p",{className:"font-mono text-body text-muted-foreground",children:"This file type is not shown here. Download it to open it."}):b==="rendered"?t.jsx("article",{className:"report mx-auto max-w-3xl",onClick:h,dangerouslySetInnerHTML:{__html:to(n,a&&{paths:r.map(y=>y.path),from:e.path.split("/").slice(0,-1).join("/")})}}):t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-small leading-[1.8]",children:n})}),t.jsxs("footer",{className:"border-t px-4 py-2 font-mono text-label text-muted-foreground",children:["File · ",n===null?"...":`${n.length.toLocaleString("en-US")} characters`," · ",e.content_type??"unknown type"]})]})})}function QW(e){const n=e.replace(/\r\n?/g,`
|
|
696
|
+
`).trim(),s=c=>{try{const d=JSON.parse(c);return d&&typeof d=="object"&&!Array.isArray(d)?d:null}catch{return null}},r=n.split(`
|
|
697
|
+
`);let a;for(let c=0;c<r.length;c++){const d=/^ {0,3}(`{3,}|~{3,})([^`]*)$/.exec(r[c]);if(!d)continue;const u=d[1],f=new RegExp(`^ {0,3}${u[0]==="`"?"`":"~"}{${u.length},}\\s*$`),g=r.findIndex((x,h)=>h>c&&f.test(x));if(g<0)break;const b=d[2].trim().toLowerCase();a=b==="json"||b===""?{open:c,end:g}:void 0,c=g}if(a&&a.end===r.length-1){const c=s(r.slice(a.open+1,a.end).join(`
|
|
698
|
+
`));return c?{words:r.slice(0,a.open).join(`
|
|
699
|
+
`).trim(),record:c}:null}const i=s(n);if(i)return{words:"",record:i};for(let c=n.lastIndexOf(`
|
|
700
|
+
{`);c>=0;c=n.lastIndexOf(`
|
|
701
|
+
{`,c-1)){const d=s(n.slice(c+1));if(d)return{words:n.slice(0,c).trim(),record:d};if(c===0)break}return null}const JW=e=>e.replace(/[_-]+/g," ").trim()||e,vc=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;function em(e,n){let s=vc(e);for(let r=0;s&&typeof s.$ref=="string"&&s.$ref.startsWith("#")&&r<8;r++){const a=s.$ref.slice(1).split("/").filter(Boolean).map(f=>decodeURIComponent(f).replaceAll("~1","/").replaceAll("~0","~")),{$ref:i,...c}=s,d=vc(a.reduce((f,g)=>{var b;return(b=vc(f))==null?void 0:b[g]},n))??{},u=d.properties||c.properties?{...vc(d.properties),...vc(c.properties)}:void 0;s={...d,...c,...u?{properties:u}:{}}}return s}const XW=(e,n)=>{var s;return((s=em(e,n))==null?void 0:s.contentMediaType)==="text/markdown"};function ky({value:e,schema:n,root:s,linked:r}){var a;if(e==null)return t.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"—"});if(Array.isArray(e)){if(!e.length)return t.jsx("span",{"data-json-value":!0,className:"text-muted-foreground",children:"none"});const i=(a=em(n,s))==null?void 0:a.items;return t.jsx("ul",{"data-json":"array",className:"list-disc space-y-1 pl-5",children:e.map((c,d)=>t.jsx("li",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:t.jsx(ky,{value:c,schema:i,root:s,linked:r})},d))})}return typeof e=="object"?t.jsx(YE,{record:e,schema:n,root:s,linked:r}):typeof e=="string"&&XW(n,s)?t.jsx("article",{"data-json-markdown":!0,className:"report max-w-none",dangerouslySetInnerHTML:{__html:to(e,r)}}):t.jsx("span",{"data-json-value":!0,className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:String(e)})}function YE({record:e,schema:n,root:s,linked:r}){var i;const a=(i=em(n,s))==null?void 0:i.properties;return t.jsx("dl",{"data-json":"object",className:"min-w-0 space-y-3 border-l pl-4",children:Object.entries(e).map(([c,d])=>{var g;const u=a==null?void 0:a[c],f=(g=em(u,s))==null?void 0:g.title;return t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"caps break-words [overflow-wrap:anywhere] text-label text-muted-foreground",children:typeof f=="string"&&f.trim()?f:JW(c)}),t.jsx("dd",{className:"mt-1 min-w-0 text-prose leading-relaxed",children:t.jsx(ky,{value:d,schema:u,root:s,linked:r})})]},c)})})}function Y0({record:e,schema:n,linked:s}){const[r,a]=p.useState(!1);return t.jsxs("section",{className:"min-w-0 space-y-3",children:[t.jsx("div",{className:"flex justify-end",children:t.jsx(B,{type:"button",size:"xs",onClick:()=>a(i=>!i),children:r?"Show fields":"Show raw JSON"})}),r?t.jsx("pre",{"aria-label":"The answer's JSON",className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify(e,null,2)}):t.jsx("div",{"aria-label":"The answer's fields",className:"min-w-0 [&>dl]:border-l-0 [&>dl]:pl-0",children:t.jsx(YE,{record:e,schema:n,root:n,linked:s})})]})}function ZW({value:e,schema:n,linked:s}){return t.jsx("div",{"aria-label":"The answer's value",className:"min-w-0 text-prose leading-relaxed",children:t.jsx(ky,{value:e,schema:n,root:n,linked:s})})}function e9({run:e,rows:n,files:s=[],onOpen:r,schema:a}){var b,x,h,v,y;const i=((b=e.result)==null?void 0:b.final_answer)??((x=n.findLast(j=>j.kind==="final_answer"))==null?void 0:x.text)??null,c=r?{paths:s.map(j=>j.path)}:void 0,d=jv(j=>{const k=s.find(E=>E.path===j);k&&(r==null||r(k))}),u=(h=e.result)==null?void 0:h.output;if(e.kind==="agentic"&&u!==void 0&&u!==null)return t.jsx("div",{className:"min-w-0",onClick:d,children:typeof u=="object"&&!Array.isArray(u)?t.jsx(Y0,{record:u,schema:a,linked:c}):t.jsx(ZW,{value:u,schema:a,linked:c})});const f=e.kind==="agentic"?(v=e.result)==null?void 0:v.output_error:void 0,g=f?t.jsx(vt,{tone:"warning",title:"The answer did not match the output schema",children:f}):null;if(i!=null&&i.trim()){const j=QW(i);return j?t.jsxs("div",{className:"min-w-0 space-y-6",children:[g,j.words&&t.jsx("article",{className:"report max-w-none",onClick:d,dangerouslySetInnerHTML:{__html:to(j.words,c)}}),t.jsx(Y0,{record:j.record})]}):t.jsxs("div",{className:"min-w-0 space-y-6",children:[g,t.jsx("article",{className:"report max-w-none",onClick:d,dangerouslySetInnerHTML:{__html:to(i,c)}})]})}if(g)return g;if(((y=e.result)==null?void 0:y.output)!==void 0&&e.result.output!==null){const j=e.result.output,k=j&&typeof j=="object"&&!Array.isArray(j)?Object.entries(j).filter(S=>typeof S[1]=="string"&&S[1].includes(`
|
|
702
|
+
`)&&S[1].length>80):[],E=k.length?Object.fromEntries(Object.entries(j).filter(([S])=>!k.some(([N])=>N===S))):j;return t.jsxs("div",{className:"space-y-8",children:[k.map(([S,N])=>t.jsxs("section",{children:[t.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:S.replace(/_/g," ")}),t.jsx("article",{className:"report max-w-none border bg-card p-5",onClick:d,dangerouslySetInnerHTML:{__html:to(N,c)}})]},S)),(!k.length||Object.keys(E).length>0)&&t.jsxs("section",{children:[t.jsx("p",{className:"caps mb-2 text-label text-muted-foreground",children:k.length?"The rest of the output":"Output"}),t.jsx("pre",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere] border bg-card p-4 font-mono text-small leading-[1.8]",children:JSON.stringify(E,null,2)})]})]})}return null}function t9({native:e,agentId:n}){const s=[{label:"Task usage",usage:e.usage.task},...e.usage.reflection.length?e.usage.reflection.map((r,a)=>({label:`Reflection usage · turn ${a+1}`,usage:r})):[{label:"Reflection usage",usage:null}]];return t.jsxs("section",{className:"space-y-4 border bg-card p-4","aria-label":"Native run details",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Native run"}),t.jsx("dl",{className:"grid gap-3 text-small sm:grid-cols-2",children:[["Runtime",fd(e.runtime)],["Project",e.project],["Selector",Lv(e.selector)],["Machine",e.machine_id],["Native session",e.session_id??"Not reported"],["Model",e.model??"Unknown"],["Configuration fingerprint",e.fingerprint],["Pinned learning revision",e.learning_revision??"None supplied"]].map(([r,a])=>t.jsxs("div",{className:"min-w-0",children:[t.jsx("dt",{className:"text-muted-foreground",children:r}),t.jsx("dd",{className:"break-all font-mono",children:a})]},r))}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-left text-small","aria-label":"Native usage by phase",children:[t.jsx("thead",{children:t.jsx("tr",{children:["Phase","Uncached input","Output tokens","Cache read","Cache write","Cost"].map(r=>t.jsx("th",{className:"whitespace-nowrap border-b px-2 py-2 font-semibold",children:r},r))})}),t.jsx("tbody",{children:s.map(({label:r,usage:a})=>{const i=e.runtime==="codex"?(a==null?void 0:a.input_tokens)==null||a.cache_read_tokens==null||a.cache_write_tokens==null?null:Math.max(0,a.input_tokens-a.cache_read_tokens-a.cache_write_tokens):a==null?void 0:a.input_tokens;return t.jsxs("tr",{children:[t.jsx("th",{className:"whitespace-nowrap px-2 py-2 font-normal",children:r}),[i,a==null?void 0:a.output_tokens,a==null?void 0:a.cache_read_tokens,a==null?void 0:a.cache_write_tokens].map((c,d)=>t.jsx("td",{className:"px-2 py-2 font-mono",children:c==null?"Unknown":c.toLocaleString("en-US")},d)),t.jsx("td",{className:"px-2 py-2 font-mono",children:(a==null?void 0:a.cost_usd)==null?"Unknown":Zr(a.cost_usd)})]},r)})})]})}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Grading usage belongs to the separate learning run.",n&&t.jsxs(t.Fragment,{children:[" ",t.jsx("a",{href:`#/agents/${encodeURIComponent(n)}/learning`,className:"underline underline-offset-2",children:"Open learning evidence"}),"."]})," Unreported native counters and model request totals stay unknown."]})]})}const n9={seeded:"Prepared",reflecting:"Reflecting",proposed:"Under review",merged:"Saved",dropped:"Not saved",pending:"Awaiting approval"},nf=e=>typeof e=="number"&&Number.isFinite(e)?e.toLocaleString("en-US"):"Not reported";function s9({run:e,read:n,onViewChanges:s}){var y,j,k,E,S,N,_,$,O,A,L;const[r,a]=p.useState({data:void 0,reading:!0}),[i,c]=p.useState(0),d=p.useRef(n);d.current=n;const u=!!n,f=e.run_id,g=(y=e.learning)==null?void 0:y.state,b=(j=e.learning)==null?void 0:j.at;p.useEffect(()=>{let M=!0;if(!u){a({data:void 0,reading:!1});return}return a(R=>({...R,error:void 0,reading:!0})),Promise.resolve().then(()=>d.current()).then(R=>{if(R&&R.run!==f)throw new Error("The learning result belongs to a different run. Refresh to try again.");M&&a({data:R,reading:!1})}).catch(R=>{M&&a(P=>({...P,error:R??new Error("The learning result could not be read."),reading:!1}))}),()=>{M=!1}},[f,g,b,u,i]),p.useEffect(()=>{const M=()=>{document.hidden||c(R=>R+1)};return window.addEventListener("focus",M),document.addEventListener("visibilitychange",M),()=>{window.removeEventListener("focus",M),document.removeEventListener("visibilitychange",M)}},[]);const x=r.data,h=()=>c(M=>M+1),v=(k=x==null?void 0:x.tokens)==null?void 0:k.grade;return t.jsxs("section",{className:"overflow-hidden border bg-card","aria-label":"Learning result",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-5 py-4",children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Learning result"}),x&&t.jsx(Ne,{children:n9[x.state]??x.state}),t.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[t.jsxs("a",{href:`#/agents/${encodeURIComponent(e.agent_id)}/learning`,className:"inline-flex items-center gap-1 text-small text-muted-foreground hover:text-primary-text",children:["Agent learning",t.jsx(cr,{className:"size-3","aria-hidden":!0})]}),u&&t.jsx(B,{size:"icon","aria-label":"Refresh learning result",disabled:r.reading,onClick:h,children:t.jsx(Qo,{"aria-hidden":!0})})]})]}),r.reading&&t.jsx("p",{className:"px-5 py-3 text-body text-muted-foreground",role:"status",children:x===void 0?"Reading learning result…":"Refreshing learning result…"}),r.error!==void 0&&t.jsxs("div",{className:"space-y-2 p-4",children:[x!==void 0&&t.jsx("p",{className:"text-small text-muted-foreground",children:"Showing the last result read."}),t.jsx(Yt,{problem:Ut(r.error,"the learning result"),onRetry:h,className:""})]}),!u&&t.jsx("p",{className:"px-5 py-6 text-body text-muted-foreground",children:"Detailed learning results are unavailable in this view."}),u&&x===null&&t.jsx("p",{className:"px-5 py-6 text-body text-muted-foreground",children:"No learning result was recorded for this run."}),x&&t.jsxs("div",{className:"space-y-6 p-5",children:[t.jsxs("div",{children:[x.detail&&t.jsx("p",{className:"break-words text-body leading-relaxed",children:x.detail}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-label text-muted-foreground",children:[x.at&&t.jsxs("span",{children:["Updated ",ht(x.at)]}),x.reason&&t.jsxs("span",{children:["Reason: ",x.reason]})]})]}),t.jsxs("section",{"aria-label":"Grader decision",children:[t.jsx("h3",{className:"mb-2 text-body font-semibold",children:"Grader decision"}),x.verdict?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-small text-muted-foreground",children:x.verdict.merge?(E=x.verdict.items)!=null&&E.some(M=>!M.keep)?"Recommended keeping some changes.":"Recommended keeping these changes.":"Did not recommend keeping these changes."}),t.jsx("p",{className:"mt-2 break-words text-body leading-relaxed",children:x.verdict.reason}),(S=x.verdict.items)!=null&&S.length?t.jsx("ul",{className:"mt-3 divide-y border",children:x.verdict.items.map((M,R)=>t.jsxs("li",{className:"space-y-2 p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("code",{className:"min-w-0 break-all text-small",children:M.file}),t.jsx(Ne,{tone:M.pending?"warning":M.keep?"success":"muted",children:M.pending?"Needs approval":M.keep?"Keep":"Do not keep"})]}),t.jsx("p",{className:"break-words text-body leading-relaxed text-muted-foreground",children:M.why}),M.question&&t.jsx("p",{className:"text-small",children:M.question}),M.origin&&t.jsx("p",{className:"text-label text-muted-foreground",children:M.origin==="you"?"From your instruction":`Origin: ${M.origin}`})]},`${M.file}-${R}`))}):t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:"No item decisions reported."})]}):t.jsx("p",{className:"text-body text-muted-foreground",children:Hm(x)?"No grader decision recorded yet.":"No grader decision was recorded for this run."})]}),!!((N=x.pending)!=null&&N.length)&&t.jsxs("div",{className:"border border-warning/40 px-4 py-3 break-words text-small leading-relaxed",children:[t.jsx("p",{className:"font-semibold",children:"Held for approval in this result"}),t.jsxs("p",{className:"mt-1 text-muted-foreground",children:[x.pending.map(M=>M.name).join(", "),". These changes required approval when recorded. Check their current status in Agent learning."]})]}),t.jsxs("section",{"aria-label":"Learning validation",children:[t.jsx("h3",{className:"mb-2 text-body font-semibold",children:"Validation"}),(_=x.problems)!=null&&_.length||($=x.draft_errors)!=null&&$.length?t.jsxs("ul",{className:"space-y-3",children:[(O=x.problems)==null?void 0:O.map((M,R)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"text-body",children:M.detail}),t.jsx("p",{className:"mt-1 break-all font-mono text-label text-muted-foreground",children:[M.rule,M.path].filter(Boolean).join(" · ")})]},`problem-${R}`)),(A=x.draft_errors)==null?void 0:A.map((M,R)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"mb-1 font-mono text-label text-muted-foreground",children:"Workflow draft"}),t.jsx("p",{className:"break-words text-body",children:M})]},`draft-${R}`))]}):t.jsx("p",{className:"text-small text-muted-foreground",children:"No validation problems reported."})]}),t.jsxs("section",{"aria-label":"Grading usage",children:[t.jsx("h3",{className:"mb-3 text-body font-semibold",children:"Grading usage"}),t.jsx("dl",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:[["Grading cost",typeof((L=x.cost_usd)==null?void 0:L.grade)=="number"?Oa(x.cost_usd.grade):"Not reported"],["Input",nf(v==null?void 0:v.input)],["Output",nf(v==null?void 0:v.output)],["Cache reads",nf(v==null?void 0:v.cache_read)],["Cache writes",nf(v==null?void 0:v.cache_write)]].map(([M,R])=>t.jsxs("div",{className:"border p-3",children:[t.jsx("dt",{className:"mb-1 text-label text-muted-foreground",children:M}),t.jsx("dd",{className:"font-mono text-body",children:R})]},M))}),t.jsx("p",{className:"mt-3 text-label leading-relaxed text-muted-foreground",children:"Input excludes cache reads and writes. Reflection usage is included in the run's totals. These figures cover grading only."})]}),t.jsxs("section",{"aria-label":"Learning provenance",className:"border-t pt-4",children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h3",{className:"text-body font-semibold",children:"Provenance"}),s&&t.jsxs(B,{size:"sm",onClick:s,children:["View changes",t.jsx(cr,{"aria-hidden":!0})]})]}),t.jsxs("dl",{className:"space-y-3 text-small",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"mb-1 text-muted-foreground",children:"Seed commit"}),t.jsx("dd",{className:"break-all font-mono",children:x.seed??"Not reported"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"mb-1 text-muted-foreground",children:"Merge commit"}),t.jsx("dd",{className:"break-all font-mono",children:x.merged??"Not merged"})]})]})]})]})]})}const Q0=32,r9=360,o9=.7;function a9(e,n){const s=e.getBoundingClientRect().top;if(!n)return window.innerHeight-(s+window.scrollY)-Q0;const r=s-n.getBoundingClientRect().top+n.scrollTop;return n.clientHeight-r-Q0}const i9=(e,n)=>Math.round(Math.max(r9,Math.min(e,n*o9)));function l9(e,n,s=3e3,r=Math.min(s,c9),a=!1){const[i,c]=p.useState(null),[d,u]=p.useState(!1),f=p.useRef(e);f.current=e;const g=p.useRef(!1),b=p.useRef(!1),x=p.useRef(0),h=p.useRef(null),v=p.useRef(null),y=p.useRef(a);y.current=a,p.useEffect(()=>{a&&(v.current=null)},[a]);const j=!!e;p.useEffect(()=>{if(!j||d)return;if(n||(v.current=null),!n&&g.current&&!b.current){c(O=>O&&J0(O));return}let E=!0,S;const N=O=>{clearTimeout(S),S=setTimeout(()=>{h.current=null,$()},O),h.current=()=>N(r)};let _=!1;const $=async()=>{try{const O=await f.current();if(!E)return;g.current=!0,O.state==="live"&&!y.current&&(v.current=O.kind);const A=O.state==="none"&&O.session==="opening"&&O.kind!=="browser"&&O.kind===v.current?{...O,session:"closed"}:O;b.current=A.state==="none"&&A.session==="unopened",_=A.state==="none"&&A.session==="opening"||A.state==="live"&&A.hold==="pending",A.state==="off"?c(null):c(n?L=>u9(L,A)?L:A:J0(A))}catch(O){if(!E)return;if(O instanceof De&&O.status===401){u(!0),c(A=>A?{state:"signed_out"}:null);return}if(O instanceof De&&O.status===403){u(!0),c(null);return}}E&&n&&N(_||Date.now()<x.current?r:s)};return $(),()=>{E=!1,clearTimeout(S),h.current=null}},[j,n,s,r,d]);const k=p.useCallback(E=>{var S;c(N=>N&&N.state==="live"&&N.hold!==E?{...N,hold:E}:N),x.current=Date.now()+d9,(S=h.current)==null||S.call(h)},[]);return{view:i,held:k}}const c9=400,d9=4e3,u9=(e,n)=>{var s,r;return!!e&&e.state!=="signed_out"&&e.state===n.state&&e.kind===n.kind&&e.hold===n.hold&&(e.state!=="live"||n.state==="live"&&e.viewer===n.viewer)&&(e.state!=="none"||n.state==="none"&&e.session===n.session&&((s=e.ended)==null?void 0:s.at)===((r=n.ended)==null?void 0:r.at))},J0=e=>e.state==="off"?null:e.state==="signed_out"?e:{state:"none",kind:e.kind,hold:"agent",session:e.state==="none"&&e.session==="unopened"?"unopened":"closed"},f9={browser:$N,desktop:Va,phone:AN,sandbox:FT},m9={browser:"Browser",desktop:"Desktop",phone:"Phone",sandbox:"Sandbox"},h9={agent:"The agent drives",pending:"Yours after the agent's step",person:"You drive"};function p9({runId:e,screen:n,machine:s,opens:r,followUp:a,metered:i,waitsFor:c,keptUntil:d,onTake:u,onHand:f}){const g=p.useRef({viewer:"",n:0});(n==null?void 0:n.state)==="live"&&n.viewer!==g.current.viewer&&(g.current={viewer:n.viewer,n:g.current.n+1});const b=n&&n.state!=="signed_out"?n.kind:(s==null?void 0:s.kind)??"browser",x=(n==null?void 0:n.state)==="live"?b9(n.viewer,e):void 0,h=x&&b!=="browser"?`${x}${x.includes("#")?"&":"#"}hands=page`:x,v=f9[b],y=(n==null?void 0:n.state)==="live"?n:null,[j,k]=p.useState(!1),[E,S]=p.useState(null),N=async F=>{if(!(!F||j)){k(!0),S(null);try{S(await F())}finally{k(!1)}}},_=y&&h&&b!=="browser"?y:null,[$,O]=p.useState(!1),A=p.useRef(null),L=p.useRef(null),M=p.useRef(null),R=p.useRef(!1),P=!!(y&&h);p.useEffect(()=>{P||O(!1)},[P]);const[D,W]=p.useState(void 0);p.useLayoutEffect(()=>{const F=A.current;if(b!=="phone"||$||!P||!F)return;const G=F.closest("[data-scroll-pane]"),U=()=>W(i9(a9(F,G),window.innerHeight));U();const z=typeof ResizeObserver=="function"&&G?new ResizeObserver(U):void 0;if(G)for(const Q of[G,...G.children])z==null||z.observe(Q);return window.addEventListener("resize",U),()=>{z==null||z.disconnect(),window.removeEventListener("resize",U)}},[b,$,P,E,i,g.current.n]),p.useEffect(()=>{var F,G,U;if($){R.current=!0,(G=(F=L.current)==null?void 0:F.querySelector("button"))==null||G.focus();return}R.current&&(R.current=!1,(U=M.current)==null||U.focus())},[$]),p.useEffect(()=>{if(!$)return;const F=K=>{if(K.key==="Escape"){O(!1);return}if(K.key!=="Tab"||!L.current)return;const Z=[...L.current.querySelectorAll("button:not([disabled]), iframe")];if(!Z.length)return;const de=Z[0],se=Z[Z.length-1],ue=document.activeElement;L.current.contains(ue)?K.shiftKey&&ue===de?(K.preventDefault(),se.focus()):!K.shiftKey&&ue===se&&(K.preventDefault(),de.focus()):(K.preventDefault(),de.focus())},G=K=>{K.key==="Escape"&&O(!1)};document.addEventListener("keydown",F);const U=A.current;let z=null;const Q=()=>{try{z==null||z.removeEventListener("keydown",G,!0)}catch{}try{z=(U==null?void 0:U.contentWindow)??null,z==null||z.addEventListener("keydown",G,!0)}catch{z=null}};return Q(),U==null||U.addEventListener("load",Q),()=>{document.removeEventListener("keydown",F),U==null||U.removeEventListener("load",Q);try{z==null||z.removeEventListener("keydown",G,!0)}catch{}}},[$,g.current.n]);const Y=y?b==="browser"?"browser · take over in the view below":`${h9[y.hold]} · ${b}`:"",H=_&&(_.hold==="person"?t.jsx(B,{size:"sm",variant:"solid",disabled:j,onClick:()=>void N(f),children:"Hand back"}):t.jsx(B,{size:"sm",variant:"solid",disabled:j||_.hold==="pending",onClick:()=>void N(u),children:_.hold==="pending"?"Taking over":"Take over"})),q=P&&t.jsx(B,{ref:$?void 0:M,size:"sm",variant:"ghost",onClick:()=>O(F=>!F),"aria-label":$?"Exit full window (Esc)":"Fill the window",title:$?"Exit full window (Esc)":"Fill the window","aria-pressed":$,children:$?t.jsx(TT,{className:"size-4","aria-hidden":!0}):t.jsx(ET,{className:"size-4","aria-hidden":!0})});return t.jsxs("section",{"aria-label":"Screen",className:"border",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-2.5",children:[t.jsx(v,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:y?"Live":m9[b]}),t.jsx("span",{className:"flex-1 font-mono text-small text-muted-foreground",children:Y}),!$&&q,!$&&H]}),i&&b!=="browser"&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-muted-foreground",children:sy}),!$&&E&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:E}),y&&h?t.jsxs("div",{ref:L,"data-testid":"screen-frame",className:$?"fixed inset-0 z-dialog flex flex-col bg-background":void 0,role:$?"dialog":void 0,"aria-modal":$?!0:void 0,"aria-label":$?"The run's screen, filling the window":void 0,children:[$&&t.jsxs("div",{className:"flex items-center gap-3 border-b bg-background px-4 py-2 text-foreground",children:[t.jsx("span",{className:"flex-1 font-mono text-small",children:Y}),q,H]}),$&&E&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:E}),t.jsx("iframe",{ref:A,src:h,title:"The run's screen",referrerPolicy:"no-referrer",sandbox:"allow-forms allow-scripts allow-same-origin",className:$?"block min-h-0 w-full flex-1 bg-background":b==="phone"?oe("mx-auto block aspect-[9/19] max-w-full bg-background",D===void 0&&"h-[70vh]"):"block aspect-[16/10] w-full bg-background",style:!$&&b==="phone"&&D!==void 0?{height:`${D}px`}:void 0},g.current.n)]}):t.jsx("p",{className:"px-4 py-12 text-center font-mono text-body text-muted-foreground",children:y9(b,n,s,r,a,c,d)})]})}const g9={approval:"Waiting for your approval.",question:"Waiting for your answer.",budget:"Waiting for you to raise the spend cap.",browser:"Waiting for you.",computer:"Waiting for you."},x9=/^The (desktop|phone) is kept for (\d+) minutes while you decide\.$/;function v9(e,n){for(let s=e.length-1;s>=0;s-=1){const r=e[s];if(r.kind!=="phase")continue;const a=r.summary??r.text??"";if(a.startsWith(`The ${n} is ready`))return;const i=x9.exec(a);if(!i||i[1]!==n)continue;const c=Date.parse(r.timestamp);return Number.isNaN(c)?void 0:new Date(c+Number(i[2])*6e4).toISOString()}}function y9(e,n,s,r,a,i,c){if((n==null?void 0:n.state)==="live")return"The live view can't be shown here.";if((n==null?void 0:n.state)==="signed_out")return"Signed out: sign in to watch.";if(e==="sandbox")return"A sandbox has no screen. What the agent runs in it is on the timeline.";if((s==null?void 0:s.state)==="failed")return`The ${e} didn't start.${s.why?` ${s.why}`:""}`;if(r&&i&&c&&(n==null?void 0:n.state)==="none"&&!n.ended)return`${g9[i]} The ${e} is kept until ${X0(c).replace(/^at /,"")}.`;if(r&&(n==null?void 0:n.state)==="none"&&n.ended)return e==="browser"?`${n.ended.why} (${X0(n.ended.at)}). A new browser opens when the run goes on.`:n.ended.why;const d=(n==null?void 0:n.state)==="none"?n.session:void 0;return d==="unopened"?r?e==="browser"?"This run hasn't opened its browser. The agent's page shows here if it opens one.":`This run hasn't opened its ${e}. Its screen shows here if the agent opens one.`:`This run didn't open its ${e}.${a?" A follow-up opens one if the agent needs it.":""}`:r&&d==="closed"?e==="browser"?"The run's browser isn't open now. The agent's page shows here if it opens one again.":`This ${e} has been released.`:r?e==="browser"?"Waiting for the browser. The agent's page shows here once it opens one.":`Waiting for the ${e}. Its screen shows here once it is up.`:`The ${e} closed when the run ended.${a?" A follow-up opens a new one if the agent needs it.":""}`}function X0(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:`at ${n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function b9(e,n){let s;try{s=new URL(e,location.origin).href}catch{return}const r=so(s);if(!r)return;const a=new URL(r);return a.origin===location.origin&&a.pathname.startsWith(`/v2/runs/${encodeURIComponent(n)}/computer/live/`)?r:void 0}const Hi=e=>{var n,s;return e.status==="input_required"&&(((n=e.pending)==null?void 0:n.kind)==="browser"||((s=e.pending)==null?void 0:s.kind)==="computer")?e.pending:null},QE=e=>e.kind==="computer"?e.computer:"browser";function _x(e,n){var s;if(e instanceof De&&e.code==="handoff_answered"){const r=(s=e.details)==null?void 0:s.outcome;return r==="expired"?"The ask expired before your answer: the agent was told.":r==="done"||r==="cancelled"?`It was already answered: ${r}.`:e.message}return e instanceof De&&e.code==="computer_not_live"?e.message:e instanceof De&&e.status===404?n==="hand"?"The agent isn't asking for you now.":"This run has no screen to take over.":e instanceof De&&e.status===403?"Sign in with your password to do this from here.":`${n==="hand"?"Not answered":"Not taken"}: ${Ft(e)}`}function JE({ask:e,onAnswer:n,open:s,heading:r,compact:a=!1}){const[i,c]=p.useState(!1),[d,u]=p.useState(null),f=p.useRef(!1),g=async b=>{if(!n||f.current)return;f.current=!0,c(!0),u(null);let x=!1;try{const h=await n(b);x=h===null,u(h)}finally{x||(f.current=!1,c(!1))}};return t.jsxs("section",{"aria-label":"Waiting for you at the computer",className:a?"px-4 py-3":"border border-warning/50 bg-warning/5 p-4",children:[r,t.jsxs("p",{className:oe("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-1"),children:[t.jsx(Va,{className:"size-3.5","aria-hidden":!0})," Waiting for you · ",QE(e)]}),t.jsxs("div",{"data-agent-request":!0,className:oe("border-l-2 border-warning/60 pl-3",a?"mt-1":"mt-2"),children:[t.jsxs("p",{className:a?"text-prose leading-snug":"text-prose leading-relaxed",children:["The agent asks you to: ",e.instruction]}),t.jsxs("p",{className:"mt-1 text-body text-muted-foreground",children:["Done when: ",e.completion_condition]})]}),t.jsx("p",{className:"mt-2 text-small font-semibold",children:"You never need to type your AgentRun password for this."}),t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:["Expires ",ht(e.expires_at)," unanswered"]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s,t.jsx("span",{className:"flex-1"}),n&&t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"solid",disabled:i,onClick:()=>void g("done"),children:"Done"}),t.jsx(B,{size:"sm",variant:"ghost",disabled:i,onClick:()=>void g("cancelled"),children:"Cancel"})]})]}),d&&t.jsx("p",{className:"mt-2 text-small text-warning-text",role:"alert",children:d})]})}function w9(e,n){const s=!!n&&Gc(e.learning).length>0,[r,a]=p.useState({state:"reading"}),[i,c]=p.useState(0);return p.useEffect(()=>{if(!s)return;let d=!0;return a({state:"reading"}),Promise.resolve().then(()=>n()).then(u=>{d&&a({state:"read",changes:Jz(u,e.learning)})},u=>{d&&a({state:"failed",error:u??new Error("unknown")})}),()=>{d=!1}},[e.run_id,s,i]),s?{got:r,retry:()=>c(d=>d+1)}:null}function j9({got:e,retry:n}){if(e.state==="read"&&!e.changes.length)return null;const s=e.state==="failed"?Ut(e.error,"what it changed"):null;return t.jsxs("section",{className:"border","aria-label":"What it changed",children:[t.jsx("h2",{className:"caps border-b px-4 py-3 text-small font-semibold",children:"What it changed"}),e.state==="reading"&&t.jsx("p",{className:"px-4 py-3 text-body text-muted-foreground",role:"status",children:"Reading what it changed…"}),s&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 text-body",role:"alert",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Couldn't read what it changed: ",s.why.charAt(0).toLowerCase()+s.why.slice(1)]}),t.jsx(B,{type:"button",onClick:n,size:"sm",children:"Try again"})]}),e.state==="read"&&t.jsx("ul",{className:"divide-y",children:e.changes.map(r=>t.jsx("li",{children:t.jsx(k9,{change:r})},r.file))})]})}function k9({change:e}){const[n,s]=p.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 px-4 py-3 text-left hover:bg-accent/40","aria-expanded":n,onClick:()=>s(r=>!r),children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block break-words text-lead","data-said":!0,children:e.said}),t.jsx("span",{className:"mt-0.5 block break-all font-mono text-label text-muted-foreground",children:e.file})]}),t.jsx(Cs,{className:oe("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",n&&"rotate-90"),"aria-hidden":!0})]}),n&&(e.withheld?t.jsx("p",{className:"px-4 pb-3 text-body text-muted-foreground",children:e.withheld}):t.jsxs("div",{className:"grid grid-cols-1 gap-3 px-4 pb-4 md:grid-cols-2",children:[t.jsx(Z0,{name:"before",lines:e.before,none:"Not there before."}),t.jsx(Z0,{name:"after",lines:e.after,none:"Not there after."})]}))]})}function Z0({name:e,lines:n,none:s}){return t.jsxs("div",{className:"min-w-0 border","data-side":e,children:[t.jsx("p",{className:"caps border-b px-3 py-2 text-label text-muted-foreground",children:e==="before"?"Before":"After"}),n===null?t.jsx("p",{className:"px-3 py-2 text-body text-muted-foreground",children:s}):t.jsx("pre",{className:"max-h-80 overflow-auto py-2 font-mono text-small leading-[1.7]",children:n.map((r,a)=>t.jsxs("span",{className:oe("flex min-h-[1.7em] px-3",r.mark==="added"&&"bg-primary/10",r.mark==="removed"&&"bg-destructive/10"),children:[t.jsx("span",{"aria-hidden":!0,className:"w-4 shrink-0 select-none text-muted-foreground",children:r.mark==="added"?"+":r.mark==="removed"?"−":""}),r.mark==="added"&&t.jsx("span",{className:"sr-only",children:"Added line: "}),r.mark==="removed"&&t.jsx("span",{className:"sr-only",children:"Taken out: "}),t.jsx("span",{"data-mark":r.mark,className:oe("min-w-0 whitespace-pre-wrap break-words",r.mark==="gap"&&"text-muted-foreground"),children:r.text})]},a))})]})}const N9=4e3,S9=e=>!!e.learning&&e.learning.reason!=="use",C9="The agent looks back on your words: what was wrong, and what a right answer does.",E9="A look-back needs words. Without them the grade is still kept.",$9='A JSON object of the fields a right answer holds, like {"total": 42}. Replays of a learned workflow are scored against it.',eN='Write it as a JSON object, like {"total": 42}, or leave it empty.';function _9(e){if(!e.trim())return{};try{const n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{value:n}:{error:eN}}catch{return{error:eN}}}function T9(e){const n=Ut(e,"the grade");return e instanceof De&&e.status<500&&n.said?n.said:`${n.why} ${n.next}`}const R9="The review could not run.";function A9(e,n,s){var r;if(e.feedback&&e.feedback_status==="not_run")return R9;if(e.feedback==="look_back")return n?"The agent is looking back on your words.":"The agent looked back on your words.";if(e.feedback==="revise"){if(n)return"The learned workflow that answered is being revised with your grade.";const a=(s==null?void 0:s.state)==="merged"?(r=s.workflows)==null?void 0:r.find(i=>!e.workflow||i.name===e.workflow):void 0;return a?a.pending?"The learned workflow that answered was revised with your grade. The revision waits for your OK.":"The learned workflow that answered was revised with your grade.":"The agent looked back at your grade; nothing changed."}return"Kept for this agent."}function O9({run:e,graded:n,onGrade:s,onOpenTimeline:r}){const[a,i]=p.useState("auto"),[c,d]=p.useState(""),[u,f]=p.useState(""),[g,b]=p.useState(!1),[x,h]=p.useState(!1),[v,y]=p.useState(null),j=p.useRef(!1),k=Wa(e.status),E=n!=null&&n.feedback?n.feedback_status:null,S=E==="running"||E==="ended"&&Hm(e.learning??void 0);if(!S9(e)||!k&&!n)return null;const N=a==="auto"?n?"closed":"choose":a,_=k&&!S,$=_9(u),O=n?A9(n,S,e.learning):null,A=async L=>{if(j.current||!s)return;const M=L?"":c.trim();if(!L&&$.error){b(!0);return}j.current=!0,h(!0),y(null);try{await s({correct:L,...M?{label:M}:{},...!L&&$.value?{expected:$.value}:{}}),i("auto"),d(""),f(""),b(!1)}catch(R){y(T9(R))}j.current=!1,h(!1)};return t.jsxs("section",{className:"border","aria-label":"Grade",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"Grade"}),n&&t.jsxs(Ne,{tone:n.correct?"success":"error",children:["Graded ",n.correct?"right":"wrong"]}),S&&t.jsx(Ne,{tone:"active",children:"Reviewing"}),t.jsx("span",{className:"flex-1"}),n&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(n.graded_at)})]}),t.jsxs("div",{className:"space-y-3 px-4 py-3",children:[O&&t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[t.jsx("p",{className:"text-body",role:"status",children:O}),r&&!!(n!=null&&n.feedback)&&t.jsx(B,{type:"button",size:"xs",variant:"ghost",onClick:r,children:"Open the Timeline"})]}),_&&N==="closed"&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[t.jsx(B,{type:"button",size:"sm",disabled:!s,onClick:()=>{i("choose"),y(null)},children:"Grade again"}),t.jsx("span",{className:"text-small text-muted-foreground",children:"A new grade replaces this one."})]}),_&&N==="choose"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-body text-muted-foreground",children:"Was the answer right? Your grade teaches the agent."}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{type:"button",size:"sm",variant:"primary",disabled:x||!s,onClick:()=>void A(!0),children:"Right"}),t.jsx(B,{type:"button",size:"sm",disabled:x||!s,onClick:()=>{i("wrong"),y(null)},children:"Wrong"}),n&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",disabled:x,onClick:()=>i("closed"),children:"Cancel"}),x&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]})]}),_&&N==="wrong"&&t.jsxs("form",{className:"space-y-4","aria-label":"Grade wrong",onSubmit:L=>{L.preventDefault(),A(!1)},children:[t.jsx(jt,{label:"What was wrong?",note:C9,warning:c.trim()?void 0:E9,children:t.jsx(dn,{value:c,onChange:L=>d(L.target.value),maxLength:N9,rows:3,disabled:x,className:"resize-y font-sans text-lead"})}),t.jsx(jt,{label:"Correct answer",optional:!0,note:$9,error:g?$.error:void 0,children:t.jsx(dn,{value:u,onChange:L=>{f(L.target.value),b(!1)},rows:2,disabled:x,spellCheck:!1,placeholder:'{"total": 42}',className:"resize-y"})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(B,{type:"submit",size:"sm",variant:"solid",disabled:x,children:"Send grade"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",disabled:x,onClick:()=>{i(n?"closed":"choose"),b(!1)},children:"Cancel"}),x&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:"Sending…"})]})]}),v&&t.jsxs("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:["Your grade wasn't taken: ",v]})]})]})}const M9=(e,n)=>n&&(!e||Date.parse(n.graded_at)>Date.parse(e.graded_at))?n:e;function P9(e,n,s){const r=!!s&&!!e.learning,[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,b]=p.useState(0);p.useEffect(()=>{if(!r)return;let j=!0;return Promise.resolve().then(()=>s()).then(k=>{j&&(i(k??null),f(0))},()=>{j&&(i(null),f(k=>k+1))}),()=>{j=!1}},[e.run_id,r,n,e.ended_at,g]);const x=p.useCallback(({expected:j,...k})=>{d({run:k.run_id,grade:{...k,feedback_status:k.feedback?"running":null}})},[]),h=r?a:null,v=M9((h==null?void 0:h.graded)??null,(c==null?void 0:c.run)===e.run_id?c.grade:null),y=r&&(v==null?void 0:v.feedback_status)==="running";return p.useEffect(()=>{if(!y||u===0||u>L9)return;const j=setTimeout(()=>b(k=>k+1),Jg(u-1));return()=>clearTimeout(j)},[y,u]),{read:h,grade:v,graded:x}}const L9=8,I9=e=>e===1?"once":e===2?"twice":`${e} times`;function z9({used:e,agentId:n}){return!e||!e.skills.length&&!e.workflows.length?null:t.jsxs("section",{className:"border","aria-label":"What it used of what it learned",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b px-4 py-3",children:[t.jsx("h2",{className:"caps text-small font-semibold",children:"What it used of what it learned"}),t.jsx("span",{className:"flex-1"}),t.jsx("a",{href:Bm(n),className:"font-mono text-label text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:"Open the Learning tab"})]}),t.jsxs("ul",{className:"divide-y",children:[e.skills.map(s=>t.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[t.jsx(gf,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Skill"}),t.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:s.name}),s.read?t.jsx(Ne,{tone:"success",children:"Read"}):t.jsx(Ne,{tone:"muted",children:"Given, not read"})]},`skill:${s.name}`)),e.workflows.map(s=>t.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[t.jsx(Ya,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps w-16 text-micro text-muted-foreground",children:"Workflow"}),t.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-body",children:s.name}),t.jsxs("span",{className:"font-mono text-label text-muted-foreground",children:["Called ",I9(s.calls)]}),s.failed>0&&t.jsxs(Ne,{tone:"error",children:[s.failed," failed"]})]},`workflow:${s.name}`))]})]})}const Ii=(e,n={})=>({type:"object",properties:{op:{const:e,description:`Action operation. Use "op": "${e}"; never use a "kind" field.`},id:{type:"string",description:'Bracketed ID copied from the latest snapshot, as a string. Use "id"; never use "ref".'},...n},required:["op","id",...Object.keys(n).filter(s=>s!=="delay")],additionalProperties:!1}),Tr=(e,n=[])=>({type:"object",additionalProperties:!1,properties:e,...n.length?{required:n}:{}}),D9={name:"snapshot",label:"Browser: snapshot",description:"Capture the active page's accessibility tree and hydrate its displayed IDs for subsequent run actions. Every call replaces the active page's ID map. On an agent's browser computer a frame another site runs in its own process is not in the tree: the snapshot names each frame it left out.",parameters:Tr({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},F9=Object.freeze({cookies:"It keeps cookies across pages: use it for a page that depends on an earlier one, or one that sets cookies.",signIns:"This browser opens with this agent's saved browser profile: a site the agent was signed in to there opens signed in here, and only here (web_fetch reads every page signed out). Use it for anything behind a sign-in, or a page that depends on an earlier one."}),U9=e=>`Browse and automate websites in the persistent browser. ${F9.cookies} Navigate with JavaScript such as await page.goto("https://example.com"), or with a goto action; there is no separate navigate or start tool. Execute either a JavaScript workflow against the Stagehand Playwright facade or a batch of actions using IDs from the latest snapshot. Code is the body of an async function with page, context and browser in scope: \`return\` the value you want back. Provide exactly one of code or actions. An agent's browser computer (Browserbase, Kernel or Local Chrome) takes actions only: code is refused there. Each action must use "op" (never "kind") and "id" (never "ref"), but goto, which takes a "url". Copy the bracketed snapshot ID as a string. Examples: {"actions":[{"op":"goto","url":"https://example.com"}]}, {"actions":[{"op":"click","id":"1-42"}]}, {"actions":[{"op":"fill","id":"2-14","value":"Miami"}]}, {"actions":[{"op":"select","id":"3-9","values":"Lowest price"}]}.`,W9={name:"run",label:"Browser: run",description:U9(),parameters:Tr({code:{type:"string",minLength:1},actions:{type:"array",description:'Snapshot actions with the exact fields "op" and "id" (goto: "op" and "url"). Do not use "kind" or "ref".',items:{oneOf:[{type:"object",properties:{op:{const:"goto",description:'Action operation. Use "op": "goto"; never use a "kind" field.'},url:{type:"string",description:"The http or https URL to open in the active page (or about:blank)."}},required:["op","url"],additionalProperties:!1},Ii("click"),Ii("hover"),Ii("fill",{value:{type:"string"}}),Ii("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),Ii("press",{key:{type:"string"}}),Ii("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},H9={name:"screenshot",label:"Browser: screenshot",description:'Capture a screenshot of the active page. For size-constrained MCP clients, prefer a viewport JPEG: {"type":"jpeg","quality":40,"fullPage":false}.',parameters:Tr({fullPage:{type:"boolean"},type:{type:"string",enum:["png","jpeg"]},quality:{type:"number",minimum:0,maximum:100},ask:{type:"string",description:"What you want to know from this capture. It travels with the image, so a host can answer it from the pixels when your model cannot see them."},clip:{...Tr({x:{type:"number"},y:{type:"number"},width:{type:"number"},height:{type:"number"}},["x","y","width","height"]),description:"Capture only this region, in CSS pixels from the viewport's top-left corner (what the page shows now). Width and height 0 mean no clip: leave it out, or send zeros, to capture the whole viewport. A region that leaves the viewport is refused. Use one of clip, id or selector; an empty id or selector means none."},id:{type:"string",description:"Capture only this element: a bracketed ID from the latest snapshot, as a string. It is scrolled into view first. It must match one element."},selector:{type:"string",description:"Capture only the element this CSS selector matches (when there is no snapshot ID for it). It is scrolled into view first. It must match exactly one element."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"image",listedWhen:"always"},B9={name:"browser_read",label:"Browser: read",description:"Read the CURRENT page of the browser as evidence and persist it under evidence/ with the page URL: `what` = markdown (the whole page as markdown, the default for citing), text, html, url, or title. This is the citable door for anything you saw in the browser: snapshot, screenshot and run return values are not evidence. Cite the returned URL. A browser page URL in a receipt keeps its query names but shows every value replaced by a redaction marker, the word redacted in square brackets (the site chose where the browser went, and a value in it can be a credential); web_fetch keeps a query value that is in the URL you asked for.",parameters:Tr({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},G9={name:"browser_release",label:"Browser: release",description:"Release the browser session now. You do not need it to finish: the session is released when your work ends and after a stretch with no browser call. Call it only to drop a session mid-task (to start the next browser call on a fresh session, or before a long stretch of work that needs no browser). Your next browser call launches a fresh session (a new tab, no cookies from the old one), so finish a flow before releasing.",parameters:Tr({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},q9={name:"browser_relaunch",label:"Browser: relaunch",description:"Replace the browser session with a fresh one, after a site blocked it (403/429, a CAPTCHA wall, a bot-detection page, an empty page that should have content). The new session is Verified whenever the run's sessions are, and a relaunch never lowers that: `verified: true` asks for a Verified session where the run's sessions are not (a Verified browser carries a stronger identity and costs more). Use `geolocation` to browse as a visitor from a given place: the proxy egresses from that country (ISO alpha-2), optionally a US state and a city, so geo-aware sites (storefront region, prices, payment methods, content availability) show what a local sees. Page state is lost; navigate again with run.",parameters:Tr({verified:{type:"boolean",description:"true launches the new session as a Verified browser. false, or leaving it out, keeps the run's setting: a Verified run's sessions stay Verified."},geolocation:{type:"object",additionalProperties:!1,description:"Proxy egress location for the new session. Omit to keep the run's default.",properties:{country:{type:"string",description:"ISO 3166-1 alpha-2 country code, e.g. GB, US, DE."},state:{type:"string",description:"US state abbreviation, United States only."},city:{type:"string",description:"City name, e.g. LONDON or SAO_PAULO."}},required:["country"]}}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},K9={name:"browser_request_handoff",label:"Browser: hand to a person",description:"Hand the browser to a person for a step only a human can do: a CAPTCHA you cannot pass, a sign-in that needs their device, a confirmation only they can give. Say in instruction what they should do and in completion_condition what the page shows once it is done. The call waits until the person finishes, cancels or the request expires; while they have the browser, every other browser call fails with waiting_for_human. The same request_id retries the same request. Afterwards take a snapshot and check the completion condition on the page before acting.",parameters:Tr({request_id:{type:"string",pattern:"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",description:"A UUID you choose for this request; the same one retries the same request."},instruction:{type:"string",minLength:1,maxLength:2e3,description:"What the person should do, in plain words."},completion_condition:{type:"string",minLength:1,maxLength:1e3,description:"What the page shows once the step is done, for you to verify afterwards."}},["request_id","instruction","completion_condition"]),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"handoff"},V9={name:"browser_downloads",label:"Browser: downloads",description:"Copy the files this browser session downloaded into the workspace under downloads/, with downloads/manifest.json listing each file's SHA-256. Returns the files fetched now, those fetched before and those skipped with why, never their bytes; open a fetched file with read. A file the browser is still downloading is skipped as still downloading: call again to fetch it.",parameters:Tr({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},Y9={name:"browser_upload",label:"Browser: upload",description:"Choose one workspace file in a file input on the page, as a person picking it would; nothing is submitted. Returns the file's name, size and SHA-256; submit the form with run afterwards.",parameters:Tr({path:{type:"string",minLength:1,maxLength:1e3,description:"The file's path relative to the workspace, for example reports/q3.pdf."},selector:{type:"string",minLength:1,maxLength:500,description:'CSS selector of the <input type="file">, for example input[type=file].'}},["path","selector"]),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"upload"},Q9=Object.freeze([D9,W9,H9,B9,G9,q9,K9,V9,Y9]),J9=Object.freeze(Q9.map(e=>e.name)),X9={"com.apple.systempreferences":"System Settings","com.apple.iCal":"Calendar","com.apple.finder":"Finder","com.android.settings":"Settings","com.android.chrome":"Chrome","xfce4-terminal":"Terminal","org.xfce.terminal":"Terminal",xterm:"XTerm","firefox-esr":"Firefox","google-chrome":"Chrome"};function Z9(e){const n=e.split(".").at(-1)||e;return X9[e]??(n?n[0].toUpperCase()+n.slice(1):e)}const eH=new Set(["enter","tab","space","backspace","delete","escape","insert","up","down","left","right","home","end","pageup","pagedown","f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12","shift","ctrl","alt","super","capslock"]),tH=new Set(["ctrl","alt","super"]);function nH(e){if(typeof e!="string"||!e)return;const s=(e.endsWith("++")?[...e.slice(0,-2).split("+"),"+"]:e.split("+")).map(r=>r.toLowerCase());return s.some(r=>tH.has(r))||s.every(r=>eH.has(r))?e:void 0}const sH=["press","set","perform","click","type","key","nav","scroll","drag"];function rH(e,n){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=sH.find(u=>u in s)??"step",a=r==="type"?s.into:s[r],i=typeof a=="string"?n(a):void 0,c=r==="key"?nH(s.key):void 0,d=r==="nav"&&typeof s.nav=="string"?s.nav:void 0;return{do:r,...i?{on:i}:{},...c?{keys:c}:{},...d?{nav:d}:{}}}const oH={textbox:"text box",searchbox:"search box",checkbox:"check box",combobox:"pop-up",switch:"switch",slider:"slider",list:"list",table:"table",scrollarea:"scroll area",window:"window",dialog:"dialog",menu:"menu",toolbar:"toolbar",image:"image",text:"text",heading:"heading",group:"group",progressbar:"progress bar"},aH=new Set(["button","link","menuitem","tab","listitem","row","cell","radio","generic","text","heading"]);function iH(e){if(!e)return;const n=oH[e.role]??(e.role==="generic"?"element":e.role);return e.name?aH.has(e.role)?`“${e.name}”`:`the ${n} “${e.name}”`:`the ${n}`}const lH={s:["Saved","save"],a:["Selected all","select all"],c:["Copied","copy"],v:["Pasted","paste"],x:["Cut","cut"],z:["Undid","undo"],w:["Closed the window","close the window"],q:["Quit","quit"],t:["Opened a new tab","open a new tab"]},cH={super:"⌘",shift:"⇧",alt:"⌥",ctrl:"⌃"},Sg={enter:"Return",escape:"Esc",tab:"Tab",space:"Space",backspace:"Delete",delete:"Forward Delete",up:"↑",down:"↓",left:"←",right:"→"},hn=(e,n,s="")=>({did:`${e}${s}`,tried:`${n}${s}`});function dH(e){const n=e.endsWith("++")?[...e.slice(0,-2).split("+"),"+"]:e.split("+"),s=n.at(-1)??"",r=n.slice(0,-1).map(c=>c.toLowerCase()),a=n.length===1&&Sg[s.toLowerCase()]?Sg[s.toLowerCase()]:`${r.map(c=>cH[c]??`${c}+`).join("")}${Sg[s.toLowerCase()]??(s.length===1?s.toUpperCase():s)}`,i=r.length===1&&r[0]==="super"?lH[s.toLowerCase()]:void 0;return i?hn(i[0],i[1],` (${a})`):hn("Pressed","press",` ${a}`)}const uH={back:["Went","go"," back"],home:["Went","go"," home"],app_switch:["Opened","open"," the recent apps"]};function fH(e){const n=iH(e.on),s=r=>` ${n??r}`;switch(e.do){case"press":return hn("Pressed","press",s("an element"));case"click":return hn("Clicked","click",n?` ${n}`:" at a point");case"set":return hn("Set","set",s("an element"));case"perform":return hn("Acted on","act on",s("an element"));case"type":return n?hn("Typed into","type into",` ${n}`):hn("Typed text","type text");case"key":return e.keys?dH(e.keys):hn("Pressed a key","press a key");case"nav":{const[r,a,i]=e.nav&&uH[e.nav]||["Navigated","navigate",""];return hn(r,a,i)}case"scroll":return n?hn("Scrolled","scroll",` ${n}`):hn("Scrolled","scroll");case"drag":return hn("Dragged","drag"," across the screen");default:return hn("Acted","act")}}function tN(e){const n=fH(e);return e.error===void 0?n.did:`Could not ${n.tried}`}const nN=3,Tx=e=>e[0].toLowerCase()+e.slice(1);function mH(e){const n=e.slice(0,nN).map(tN),s=e.slice(nN),r=s.findIndex(i=>i.error!==void 0),a=r<0?s.length:s.length-1;return[n[0],...n.slice(1).map(Tx),...a>0?[`+${a} more`]:[],...r<0?[]:[Tx(tN(s[r]))]].join(", ")}const hH={"screen.shot":["Took a screenshot","take a screenshot"],"screen.watch":["Watched the screen","watch the screen"],"input.actions":["Used the pointer and keys","use the pointer and keys"],"apps.list":["Listed the apps","list the apps"],"files.read":["Read a file","read a file"],"files.write":["Wrote a file","write a file"],"files.list":["Listed a folder","list a folder"],"files.stat":["Looked up a file","look up a file"],"exec.run":["Ran a command","run a command"],"process.start":["Started a process","start a process"],ping:["Checked the computer","check the computer"]};function Cr(e){const n=e.app?Z9(e.app):void 0,s=(()=>{var r;switch(e.method){case"apps.launch":return hn("Opened","open",` ${n??"an app"}`);case"apps.terminate":return hn("Quit","quit",` ${n??"an app"}`);case"ui.observe":return hn("Looked at","look at",` ${n??"the window"}`);case"ui.act":return e.ok&&((r=e.steps)!=null&&r.length)?{did:mH(e.steps),tried:""}:e.ok?hn("Waited for","wait for",` ${n??"the window"}${e.expect==="unmet"?" (not seen)":""}`):hn("Acted on","act on",` ${n??"the computer"}`);default:{const[a,i]=hH[e.method]??[e.method,e.method];return hn(a,i)}}})();return e.ok?s.did:`Could not ${s.tried}`}const pH=e=>e.map((n,s)=>s===0?Cr(n):Tx(Cr(n))).join(", "),XE='\\s"`<>\\\\',gH=new RegExp(`https?://[^${XE}|]+`,"gi"),xH=new RegExp(`https?://[^${XE}]+`,"gi"),vH=".,;:!?*)]}'",yH={")":"(","]":"[","}":"{"};function bH(e){const n={"(":0,")":0,"[":0,"]":0,"{":0,"}":0};for(const r of e)r in n&&(n[r]+=1);let s=e.length;for(;s>0&&vH.includes(e[s-1]);s--){const r=e[s-1],a=yH[r];if(a&&n[a]>=n[r])break;a&&(n[r]-=1)}return e.slice(0,s)}new RegExp(`\\]\\(|${gH.source}`,"gi");const Ko=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,cn=e=>typeof e=="string"?e:void 0,Ga=(e,n)=>e.length>n?`${e.slice(0,n-3)}...`:e,ZE=e=>e.split(`
|
|
703
|
+
`).map(n=>n.trim()).find(Boolean)??"";function tm(e){try{return Ko(JSON.parse(e))}catch{return}}const wH=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function Vc(e){const n=wH.exec(e.trim());return Ga(n?`${n[1]}${n[2]==="/"?"":n[2]}`:e.split(/[?#]/)[0]??"",80)}const jH="…",kH=/https?:\/\//gi,NH=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i,SH=/(https?:\/\/)[^@/?#\s]*@/gi,CH=/[A-Za-z0-9]/;function Ny(e){return e.replace(xH,n=>{const s=[0];let[r,a]=[0,!1];for(const i of n.matchAll(kH)){if(i.index===0)continue;for(;r<i.index;r++)a||(a=n[r]==="?"||n[r]==="#");if(a)continue;let c=!1;for(let d=i.index-1;d>s.at(-1)&&!CH.test(n[d]);d--)c||(c=n[d]==="'");c&&s.push(i.index)}return s.map((i,c)=>EH(n.slice(i,s[c+1]??n.length))).join("")})}function EH(e){const n=bH(e).length,s=NH.exec(e.slice(0,n));if(!s)return e;const r=i=>i.replace(SH,"$1"),a=[...new Set((s[4]??"").split("&").map(i=>r(i.split("=")[0])).filter(Boolean))];return`${s[1]}${r(`${s[2]}${s[3]}`)}${a.length?`?${a.map(i=>`${i}=${jH}`).join("&")}`:""}${e.slice(n)}`}const $H=e=>e.length>2?`${e.slice(0,2).join(", ")}, +${e.length-2} more`:e.join(", "),_H=new Map,TH=new Map,e$=new Map,RH=new Set;function un(e,n,s,{name:r,saysFailure:a}={}){_H.set(e,n),s&&TH.set(e,s),r&&e$.set(e,r),a&&RH.add(e)}const AH=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,OH=/^mcp:([a-z][a-z0-9-]{0,31})\/([A-Za-z0-9_-]{1,64})$/,MH=e=>{const n=OH.exec(e)??AH.exec(e);return n&&n[1]!=="hands"?`${n[1]} · ${n[2]}`:void 0},PH=e=>e$.get(e)??MH(e)??e,LH=new Map;function Sy(e,n){LH.set(e,n)}const IH=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...IH];const Cy=e=>cn(e.path)??cn(e.file_path),zH=/page\.goto\(\s*["'`]([^"'`]+)/;un("read",e=>`Read ${Cy(e)??"a file"}`,{many:e=>`Read ${e} files`,subject:e=>e??void 0,path:!0},{name:"Read files"});un("write",e=>`Wrote ${Cy(e)??"a file"}`,{many:e=>`Wrote ${e} files`,subject:e=>e??void 0,path:!0},{name:"Write files"});un("edit",e=>`Edited ${Cy(e)??"a file"}`,{many:e=>`Edited ${e} files`,subject:e=>e??void 0,path:!0},{name:"Edit files"});un("bash",e=>`Ran \`${Ga(Ny(ZE(cn(e.command)??"")),60)}\``,{many:e=>`Ran ${e} commands`},{name:"Run commands"});const t$=e=>{const n=e&&Ko(tm(e.text)??tm(ZE(e.text)));if((n==null?void 0:n.ok)!==!1)return;const s=cn(n.refused);return s!==void 0?{refused:!0,detail:s.replace(/^refused:\s*/,"")}:{refused:!1,detail:cn(n.error)??cn(n.message)??"no detail"}},DH=(e,n)=>`${t$(n)?"Tried to fetch":"Fetched"} ${Vc(cn(e.url)??"a page")}`,FH={many:e=>`Fetched ${e} pages`,subject:e=>e?Vc(e):void 0},UH=e=>{const n=t$(e);return n&&{failed:!0,text:`${n.refused?"refused":"failed"}: ${n.detail}`}};un("web_fetch",DH,FH,{name:"Fetch web pages"});Sy("web_fetch",UH);un("web_search",e=>{const n=cn(e.query);return n?`Searched the web for "${Ga(Ny(n),60)}"`:"Searched the web"},{many:e=>`Searched the web ${e} times`,subject:e=>e?`"${Ga(e,40)}"`:void 0},{name:"Search the web"});Sy("web_search",e=>{var s;const n=cn((s=Ko(tm(e.text)))==null?void 0:s.error);return n!==void 0?{failed:!0,text:`failed: ${n}`}:void 0});un("browser_read",(e,n)=>{var r;const s=n&&((r=/^title: (.+)$/m.exec(n.text))==null?void 0:r[1]);return s?`Read the page "${Ga(Ny(s),60)}"`:"Read the page"},{many:e=>`Read ${e} pages`,subject:(e,n)=>{var r;const s=n&&((r=/^url: (\S+)/m.exec(n))==null?void 0:r[1]);return s?Vc(s):void 0}},{name:"Read the browser's page"});un("snapshot",()=>"Looked at the page structure",{many:e=>`Looked at the page structure ${e} times`},{name:"Look at the page structure"});un("screenshot",()=>"Took a screenshot",{many:e=>`Took ${e} screenshots`},{name:"Take screenshots"});un("run",(e,n)=>{var i,c;const s=(i=zH.exec(cn(e.code)??""))==null?void 0:i[1];if(s)return`Opened ${Vc(s)}`;const r=(c=Ko(n==null?void 0:n.details))==null?void 0:c.sent,a=Array.isArray(r)?r.flatMap(d=>{const u=Ko(d),[f,g]=[cn(u==null?void 0:u.method),cn(u==null?void 0:u.url)];return f&&g?`${f} ${Vc(g)}`:[]}):[];return a.length?`Acted on the page (${a.length} request${a.length===1?"":"s"} sent: ${$H(a)})`:"Acted on the page"},{many:e=>`Acted on the page ${e} times`},{name:"Open or act on a page in the browser"});un("browser_downloads",(e,n)=>{var a;const s=n&&((a=tm(n.text))==null?void 0:a.fetched),r=Array.isArray(s)?s.flatMap(i=>{var c;return cn((c=Ko(i))==null?void 0:c.name)??[]}):[];return r.length===1?`Downloaded ${r[0]}`:r.length?`Downloaded ${r.length} files`:"Downloaded files"},{many:e=>`Downloaded files ${e} times`},{name:"Download files in the browser"});un("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});un("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});un("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});un("codemode",()=>"Ran a script",{many:e=>`Ran ${e} scripts`},{name:"Run scripts"});un("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const WH=/^(\d+)\. [a-z_.]+(?: into)?(?: @\S+ ([a-z]+)(?: ("(?:[^"\\]|\\.)*"))?)?(?: \[secure\])?: (.*)$/,HH=e=>{if(e!==void 0)try{return cn(JSON.parse(e))}catch{return}};function n$(e){var s;const n=new Map;for(const r of(e??"").split(`
|
|
704
|
+
`)){const a=WH.exec(r);if(!a)continue;const i=HH(a[3]),c=(s=/^refused \([^)]*\): (.*)$/.exec(a[4]))==null?void 0:s[1],d=a[2]===void 0?void 0:{role:a[2],...i?{name:i}:{}};n.set(Number(a[1]),{...d?{on:d}:{},...c!==void 0?{refused:c}:{}})}return n}function BH(e,n){return{...rH(e,()=>n==null?void 0:n.on),...(n==null?void 0:n.refused)!==void 0?{error:"refused"}:{}}}un("computer_act",(e,n)=>{var d;const s=Array.isArray(e.steps)?e.steps.flatMap(u=>{const f=Ko(u);return f?[f]:[]}):[],r={method:"ui.act",started_at:"",ms:0,...cn(e.app)?{app:cn(e.app)}:{}};if(n!=null&&n.isError)return Cr({...r,ok:!1});const a=n===void 0?void 0:n$(n.text),i=a===void 0?s:s.filter((u,f)=>a.has(f+1));if(s.length>0&&i.length===0)return Cr({...r,ok:!1});const c=n&&((d=/^expect: (met|unmet)$/m.exec(n.text))==null?void 0:d[1]);return Cr({...r,ok:!0,steps:i.map((u,f)=>BH(u,a==null?void 0:a.get(f+1))),...c==="met"||c==="unmet"?{expect:c}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Act on the computer",saysFailure:!0});Sy("computer_act",e=>{for(const[n,s]of n$(e.text))if(s.refused!==void 0)return{failed:!0,text:`step ${n} refused: ${s.refused}`}});const sN=/^state \S+ · (\S+)/,GH=/^screen \S+ px · (?:\S+ in front|no app in front)/;un("computer_observe",(e,n)=>{var r;if(n&&!n.isError&&!sN.test(n.text)){const a=GH.test(n.text),i=(d,u)=>({method:d,started_at:"",ms:0,ok:!0,...u?{app:u}:{}}),c=a?cn(e.app):void 0;return pH([...c?[i("apps.launch",c)]:[],i("screen.shot"),...a?[i("apps.list")]:[]])}const s=cn(e.app)??(n&&((r=sN.exec(n.text))==null?void 0:r[1]));return Cr({method:"ui.observe",ok:(n==null?void 0:n.isError)!==!0,...s?{app:s}:{}})},{many:e=>`Looked at the screen ${e} times`},{name:"Look at the computer",saysFailure:!0});un("computer_screenshot",(e,n)=>Cr({method:"screen.shot",ok:(n==null?void 0:n.isError)!==!0}),{many:e=>`Took ${e} screenshots`},{name:"Take screenshots of the computer",saysFailure:!0});const rN={"input.act":"input.actions","apps.list":"apps.list","apps.open":"apps.launch","shell.run":"exec.run","processes.start":"process.start","files.read":"files.read","files.write":"files.write","files.list":"files.list","files.stat":"files.stat"};un("computer_op",(e,n)=>{var i;const s=cn(e.op),r=s!==void 0&&Object.hasOwn(rN,s)?rN[s]:void 0;if(!r)return n!=null&&n.isError?"Could not act on the computer":"Acted on the computer";const a=r==="apps.launch"?cn((i=Ko(e.args))==null?void 0:i.id):void 0;return Cr({method:r,ok:(n==null?void 0:n.isError)!==!0,...a?{app:a}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Use the computer's apps, shell and files",saysFailure:!0});un("computer_script",(e,n)=>{var r;const s=(r=cn(e.title))==null?void 0:r.replace(/\s+/g," ").trim();return n!=null&&n.isError?s?`Could not run the script “${Ga(s,120)}”`:"Could not run a script on the computer":s?Ga(s,120):"Ran a script on the computer"},{many:e=>`Ran ${e} scripts on the computer`},{name:"Run scripts on the computer",saysFailure:!0});const qH=["schedule","webhook","slack","github","composio","email"];new Set(qH);const KH=":feedback",VH=e=>{var n;return e.kind==="user_message"&&((n=e.id)==null?void 0:n.endsWith(KH))===!0},YH={user_message:qx,thinking:xf,tool_use:vf,tool_result:vf,waiting:Wx,usage:Dx,final_answer:Ka,phase:EN,error:nl,decision:LT,text_block:_T,tool_approval_requested:RN},oN=e=>{var n;return e.kind==="tool_approval_requested"?(n=/\n\n(Not sent: [\s\S]*)$/.exec(e.text??""))==null?void 0:n[1]:void 0},aN=e=>e.kind==="tool_approval_requested"&&(e.summary??"").startsWith("Waiting for your approval"),Ey=e=>e.origin==="server",s$=e=>e.origin==="trigger",r$=e=>{var i;const n=e.summary??"",s=(i=e.trigger)==null?void 0:i.name,r=s?n.indexOf(` ${s}: `):-1;if(s&&r>0&&!n.slice(0,r).includes(" "))return{who:n.slice(0,r+1+s.length),said:n.slice(r+s.length+3).trimStart()};const a=/^([^:]+):\s*/.exec(n);return a?{who:a[1],said:n.slice(a[0].length)}:{who:null,said:n}};function o$(e){const n=e.split(/(\*\*[^*\n]+?\*\*|`[^`\n]+`)/);return n.length===1?e:n.map((s,r)=>r%2===0?s:s.startsWith("`")?t.jsx("code",{className:"font-mono",children:s.slice(1,-1)},r):t.jsx("strong",{className:"font-semibold",children:o$(s.slice(2,-2))},r))}const QH=e=>{var r;const n=s$(e)?r$(e).said:(e.summary??"").replace(Ey(e)?/^AgentRun:\s*/:/^(You|Thinking|Asked you|Waiting for you):\s*/,"");if(e.kind==="user_message"&&n.startsWith("{"))try{return Object.entries(JSON.parse(n)).map(([a,i])=>`${a}: ${typeof i=="string"?i:JSON.stringify(i)}`).join(" · ")}catch{}const s=(e.text??"").split(`
|
|
705
|
+
`).filter(a=>a.trim()).length>1?"…":"";return e.kind==="final_answer"?!n.trim()&&!((r=e.text)!=null&&r.trim())?g2:`${n.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${s}`:e.kind==="user_message"?`${n}${s}`:n},Yc=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,JH=new Set(J9),XH=new Map(Object.entries({read:"Read",write:"Write",edit:"Edit",multiedit:"Edit",apply_patch:"Edit",notebookedit:"Edit",bash:"Shell",shell:"Shell",local_shell:"Shell",exec_command:"Shell",web_fetch:"Fetch",webfetch:"Fetch",fetch:"Fetch",web_search:"Search",websearch:"Search",ls:"List files",glob:"Find files",find:"Find files",grep:"Search files",ask_person:"Question",submit:"Answer",codemode:"Script",todowrite:"To-dos",task:"Subagent",skill:"Skill"}));function ZH(e){const n=XH.get(e.toLowerCase());if(n)return n;const s=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return s?s[0].toUpperCase()+s.slice(1):e}const iN=e=>e&&(dI(e)??(JH.has(e)?PH(e):ZH(e))),lN=e=>Ey(e)?"AgentRun":s$(e)?r$(e).who??"Trigger":VH(e)?"Your grade":{user_message:"You",thinking:"Thinking",tool_use:iN(e.tool_name)??"Tool",tool_result:iN(e.tool_name)??"Result",waiting:"Waiting for you",usage:"Usage",final_answer:"Answer",phase:"Phase",error:"Error",decision:"Decision",text_block:"Text",tool_approval_requested:"Your approval",learning:"Learning"}[e.kind]??e.kind,e7={budget:"Paused at cap"};function t7({step:e,last:n,ended:s,waitingChip:r,files:a,onOpen:i}){var y,j;const c=e.row,[d,u]=p.useState(!1),g=RM(c)?CN:YH[c.kind]??EN,b=e.above?c.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":QH(c),x=e.above?null:e.detail??YS(c),h=x&&x.trim()!==b.trim()?x:null,v=JS(c);return t.jsxs("li",{className:"relative flex gap-3",children:[t.jsxs("div",{className:"flex w-7 shrink-0 flex-col items-center",children:[t.jsx("span",{className:oe("mt-3 flex size-7 items-center justify-center border bg-background",(c.kind==="waiting"||aN(c))&&"border-warning/60 text-warning-text",v&&"border-destructive/60 text-destructive-text"),children:t.jsx(g,{className:"size-3.5","aria-hidden":!0})}),!n&&t.jsx("span",{className:"w-px flex-1 bg-border","aria-hidden":!0})]}),t.jsxs("div",{className:"min-w-0 flex-1 border-b py-3",children:[t.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:()=>u(k=>!k),"aria-expanded":d,disabled:!h,children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-body text-muted-foreground",children:[t.jsx("span",{"data-label":!0,className:"min-w-0 truncate",title:lN(c),children:lN(c)}),(c.kind==="tool_use"||c.kind==="tool_result")&&c.usage&&t.jsxs("span",{className:"font-mono text-label",children:["· ",SM(c.usage,{ended:s})]}),c.kind==="waiting"&&t.jsx(Ne,{tone:"warning",children:r??"Input required"}),aN(c)&&t.jsx(Ne,{tone:"warning",children:"Approval required"}),v&&t.jsx(Ne,{tone:"error",children:"Error"}),QS(c)&&t.jsx(Ne,{tone:"muted",title:"Not run: refused before it ran",children:"Refused"}),c.agent_label&&t.jsx(Ne,{label:!0,title:c.agent_label,children:c.agent_label}),e.ms!==void 0&&t.jsx("span",{className:"font-mono text-label",children:Yc(e.ms)}),e.times&&t.jsxs("span",{className:"font-mono text-label",children:[e.times," times",e.until?` over ${Yc(Math.max(0,Date.parse(e.until)-Date.parse(c.timestamp)))}`:""]})]}),t.jsx("span",{className:oe("mt-0.5 block break-words text-prose leading-snug",Ey(c)&&"text-muted-foreground"),children:o$(b)}),e.saved&&t.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",e.saved]}),oN(c)&&t.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:oN(c)})]}),t.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:od(c.timestamp)}),h&&t.jsx(Cs,{className:oe("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform",d&&"rotate-90"),"aria-hidden":!0})]}),d&&h&&c.tool_name&&t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:c.tool_name}),d&&h&&c.kind==="final_answer"&&t.jsx("article",{className:"report mt-3 max-h-80 max-w-none overflow-auto border bg-card p-3",onClick:jv(k=>{const E=a==null?void 0:a.find(S=>S.path===k);E&&(i==null||i(E))}),dangerouslySetInnerHTML:{__html:to(h,i&&a?{paths:a.map(k=>k.path)}:void 0)}}),d&&h&&c.kind!=="final_answer"&&t.jsx("pre",{className:"mt-3 max-h-80 overflow-auto whitespace-pre-wrap break-words border bg-card p-3 font-mono text-small leading-[1.7]",children:h}),(y=c.learned_nodes)!=null&&y.length?t.jsx(r7,{nodes:c.learned_nodes}):null,(j=c.computer_calls)!=null&&j.length?t.jsx(n7,{calls:c.computer_calls,dropped:c.computer_calls_dropped??0}):null]})]})}function n7({calls:e,dropped:n}){const[s,r]=p.useState(!1),a=e.filter(u=>!u.ok).length,i=e.length+n,c=[`${i} computer ${i===1?"call":"calls"}`,...a?[`${a} failed`]:[]].join(" · "),d=Date.parse(e[0].started_at);return t.jsxs("div",{className:"mt-2",children:[t.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>r(u=>!u),"aria-expanded":s,"aria-label":`${s?"Hide":"Show"} the computer calls`,children:[t.jsx(Cs,{className:oe("size-3 transition-transform",s&&"rotate-90"),"aria-hidden":!0}),t.jsx(Va,{className:"size-3","aria-hidden":!0}),c]}),s&&t.jsxs("ol",{"aria-label":"The computer calls",className:"mt-2 divide-y border bg-card",children:[e.map((u,f)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[t.jsxs("span",{className:"w-14 shrink-0 font-mono text-label text-muted-foreground",children:["+",Yc(Math.max(0,Date.parse(u.started_at)-d))]}),t.jsx("span",{className:oe("min-w-0 flex-1 truncate text-body",!u.ok&&"text-destructive-text"),title:Cr(u),children:Cr(u)}),!u.ok&&u.code&&t.jsx("span",{className:"shrink-0 font-mono text-label text-destructive-text",children:u.code}),t.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:Yc(u.ms)})]},f)),n>0&&t.jsxs("li",{className:"px-3 py-1.5 text-body text-muted-foreground",children:[n," more not kept"]})]})]})}const s7={ok:"success",failed:"error",escalated:"warning"};function r7({nodes:e}){const[n,s]=p.useState(!1),r=Object.entries(e.reduce((i,c)=>({...i,[c.status]:(i[c.status]??0)+1}),{})).filter(([i])=>i!=="ok"),a=[`${e.length} ${e.length===1?"node":"nodes"}`,...r.map(([i,c])=>`${c} ${i}`)].join(" · ");return t.jsxs("div",{className:"mt-2",children:[t.jsxs("button",{type:"button",className:"caps flex items-center gap-1 text-label text-muted-foreground hover:text-foreground",onClick:()=>s(i=>!i),"aria-expanded":n,"aria-label":`${n?"Hide":"Show"} the workflow's ${e.length===1?"node":"nodes"}`,children:[t.jsx(Cs,{className:oe("size-3 transition-transform",n&&"rotate-90"),"aria-hidden":!0}),t.jsx(Ya,{className:"size-3","aria-hidden":!0}),a]}),n&&t.jsx("ol",{"aria-label":"The workflow's nodes",className:"mt-2 divide-y border bg-card",children:e.map((i,c)=>t.jsxs("li",{className:"flex items-center gap-3 px-3 py-1.5",children:[t.jsx("span",{"data-status":i.status,className:"contents",children:t.jsx(Ne,{tone:s7[i.status]??"muted",className:"w-[5.5rem] justify-center",children:i.status})}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body",title:i.label,children:i.label}),t.jsx("span",{"data-kind":!0,className:"font-mono text-label text-muted-foreground",title:H2(i)||void 0,children:Gv(i.kind,i)}),t.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:Yc(i.duration_ms)})]},c))})]})}function o7({rows:e,live:n,fold:s=6,asking:r,waitingOn:a,files:i,onOpen:c,ended:d=!1}){var y;const u=a==="budget"?e.findLastIndex(j=>j.paused===!0):-1,f=u>=0?(y=e.slice(u+1).findLast(j=>j.kind==="waiting"))==null?void 0:y.id:void 0,[g,b]=p.useState(!1),x=AM(e).map(j=>r&&j.row.id===r?{...j,above:!0}:j),h=g?0:Math.max(0,x.length-s),v=x.slice(h);return e.length?t.jsxs("div",{children:[h>0&&t.jsxs("button",{type:"button",className:"caps mb-1 ml-10 flex items-center gap-1 py-2 text-label text-muted-foreground hover:text-foreground",onClick:()=>b(!0),children:[t.jsx(Cs,{className:"size-3","aria-hidden":!0})," ",h," earlier ",h===1?"step":"steps"]}),t.jsx("ol",{children:v.map((j,k)=>t.jsx(t7,{step:j,last:k===v.length-1&&!n,ended:d,waitingChip:j.row.id===f&&a?e7[a]:void 0,files:i,onOpen:c},j.row.id))}),n&&t.jsx(Rx,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):t.jsx(Rx,{title:n?"The run is starting":"Nothing on the timeline",note:n?"Steps appear here as the agent works.":"This run recorded no steps.",spin:n})}function Rx({title:e,note:n,spin:s=!0}){return t.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-center",children:[s&&t.jsx(f5,{className:"size-5"}),t.jsx("p",{className:"caps text-label font-semibold",children:e}),t.jsx("p",{className:"max-w-sm text-body text-muted-foreground",children:n})]})}const a7={label:"Decline and say what to do instead",placeholder:"Tell the agent what to do instead...",does:"Sending it declines the waiting call; the agent reads your message."},i7={steer:{label:"Steer the run",placeholder:"Steer the run...",does:"A message steers the run; it doesn't answer the ask. Do it on the screen, then Done or Cancel above."},follow_up:{label:"Message the run",placeholder:"Message the run...",does:"A message goes to the run after its turn; it doesn't answer the ask. Do it on the screen, then Done or Cancel above."}};function l7(e,n){var r,a;if(e.status==="input_required"&&((r=e.pending)==null?void 0:r.kind)==="budget"){const{cap_usd:i,spent_usd:c,held_usd:d}=e.pending,u=typeof i=="number"&&Number.isFinite(i),f=typeof d=="number"&&d>0?`, and holds ${Yr(d)} for steps still running`:"";return{title:"Paused at its spend cap",note:`${u&&typeof c=="number"?`It has spent ${Yr(c)} of its ${Yr(i)} cap${f}.`:u?`Its ${Yr(i)} cap is reached.`:"Its spend cap is reached."} Raise the cap above to continue.`,spin:!1}}if(e.status==="input_required"&&((a=e.pending)==null?void 0:a.kind)==="approval")return{title:"Waiting for your approval",note:`The run continues once you answer the approval above${n.canMessage?", or send a message below to decline it":""}.`,spin:!1};const s=Hi(e);return s?{title:`Waiting for you at the ${QE(s)}`,note:"The run continues once you answer the ask above, or hand the computer back on the Screen tab.",spin:!1}:e.status==="input_required"&&e.state==="waiting"?{title:"Waiting for your answer",note:n.messageMode==="answer"?"The run continues when you reply below.":"The run continues once the question is answered.",spin:!1}:e.status==="input_required"?{title:"Stopped",note:`Stopped before it wrote an answer.${n.canMessage?" Send a message below to continue it.":""}`,spin:!1}:e.status==="paused"?{title:"Paused",note:"No new step starts until it's resumed. The answer appears here when it finishes.",spin:!1}:{title:"Writing the answer",note:"The answer appears here when the run finishes. Follow it on the timeline.",spin:n.live}}function c7({run:e,agentName:n,messages:s,harnessSteers:r,rows:a,files:i,outputSchema:c,readFile:d,openFile:u=null,actions:f,onMessage:g,onApprove:b,tab:x,graphView:h,costText:v,readLearningDiff:y,readLearning:j,readLearningResult:k,readComputer:E,computerEvery:S,onTakeOver:N,onHandBack:_,readComputers:$,onGrade:O}){var le,Ue,Xe,rt,J,ve,We;const A=e.native,L=Zn(e),M=((le=e.pending)==null?void 0:le.kind)==="budget"?e.pending:null,R=Hi(e),P=!L&&!A&&R?r&&s.steer?"steer":s.follow_up?"follow_up":null:null,D=Lm(e.status,e.state,e.kind,s,r,e.error,e.review,e.computer),W=L||A||M?{...D,canMessage:!1,messageMode:null}:R?{...D,canMessage:P!==null,messageMode:P}:D,Y=h?"graph":W.final&&e.status==="completed"?"report":"timeline",[H,q]=p.useState(x??Y),F=H==="graph"&&!h?Y:H,[G,U]=p.useState(!1),[z,Q]=p.useState(u?{file:u,text:null}:null),K=TW(e),Z=K||R?null:vP(e.status,e.state,a),de=K?a.findLast(Se=>Se.kind===UE&&Se.tool_use_id===K.call_id):void 0,[se,ue]=p.useState(null),xe=async(Se,Ye,Nt,It)=>{const ot=b?await(It?b(Se,Ye,Nt,It):b(Se,Ye,Nt)):"This page can't answer an approval.";return ue(ot?{id:Se,text:ot}:null),ot},$e=p.useRef(Zg()).current,ge=async Se=>{const Ye=$e.begin();if(Q({file:Se,text:null}),!d)return;const Nt=await d(Se);$e.current(Ye)&&Q({file:Se,text:Nt})},fe=()=>{$e.cancel(),Q(null)},me=w9(e,y),{read:je,grade:Me,graded:_e}=P9(e,W.final,j),re=O&&(async Se=>{const Ye=await O(Se);return _e(Ye),Ye}),Re=W.live||e.status==="input_required"&&e.state==="waiting"||e.status==="paused",Ze=e.computer,at=Ze?v9(a,Ze.kind):void 0,{view:pt,held:Ee}=l9(E,!W.final,S,void 0,e.status==="queued"||at!==void 0),Je=!!pt||!!Ze||!!R,he=p.useRef(!1);p.useEffect(()=>{if(Je){he.current=!0;return}he.current&&F==="screen"&&q(Y),he.current=!1},[Je,F,Y]);const[Fe,ut]=p.useState(!1);p.useEffect(()=>{if(!Ze||!ry.has(Ze.kind)||!$)return;let Se=!0;return $().then(Ye=>{var Nt,It;Se&&ut(!!((It=(Nt=Ye.kinds.find(ot=>ot.kind===Ze.kind))==null?void 0:Nt.providers.find(ot=>ot.id===Ze.provider))!=null&&It.metered))}).catch(()=>{}),()=>{Se=!1}},[Ze==null?void 0:Ze.kind,Ze==null?void 0:Ze.provider]);const Pe=R?`${R.kind}:${R.asked_at}`:null,ct=p.useRef(null);p.useEffect(()=>{!Pe||ct.current===Pe||!Je||(ct.current=Pe,q("screen"))},[Pe,Je]);const _t=async()=>{if(!N)return"This page can't take the computer over.";try{return Ee((await N()).hold),null}catch(Se){return _x(Se,"take")}},tt=async Se=>{if(!_)return"This page can't hand the computer back.";try{return Ee((await _(Se)).hold),null}catch(Ye){return _x(Ye,"hand")}},[ft,qt]=p.useState(null),zt=async Se=>{const Ye=(R==null?void 0:R.asked_at)??"",Nt=await tt(Se);return qt(Nt?{at:Ye,text:Nt}:null),Nt};p.useEffect(()=>{u&&d&&ge(u)},[u]);const ye=[...h?[["graph","Graph"]]:[],["report","Report"],["timeline","Timeline"],...e.learning?[["learning","Learning"]]:[],["files",`Files ${VE(i,G).length}`],...Je?[["screen","Screen"]]:[]];return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[t.jsx(GW,{run:e,agentName:n,actions:f,costText:v}),t.jsx(ES,{id:"run-views",label:"Run views",value:F,onChange:Se=>q(Se),tabs:ye.map(([Se,Ye])=>({id:Se,label:Ye}))}),F==="graph"?t.jsx("div",{className:"min-h-0 flex-1 short:min-h-96",children:h}):t.jsx("div",{"data-scroll-pane":!0,className:"min-h-0 flex-1 overflow-auto short:flex-none short:overflow-visible",children:t.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 px-5 py-8 md:px-8",children:[A&&t.jsx(t9,{native:A,agentId:e.agent_id}),e.status==="failed"&&e.error&&t.jsx(sa,{error:e.error,title:w2(e.status,e.error)?"The run escalated":void 0}),e.status==="cancelled"&&t.jsxs("section",{className:"border border-border-strong/60 p-4",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:"Cancelled"}),t.jsx("p",{className:"mt-2 text-lead text-muted-foreground",children:"This run was cancelled. It keeps what it did before; it takes no more messages."})]}),e.status==="completed"&&e.review&&t.jsxs("section",{className:"border border-warning/50 bg-warning/10 p-4","aria-label":"Needs review",children:[t.jsx("p",{className:"caps text-label text-warning-text",children:"Needs review"}),t.jsx("p",{className:"mt-2 text-lead",children:e.review.reason}),t.jsxs("p",{className:"mt-1 font-mono text-small text-muted-foreground",children:[[e.review.node&&`Stopped at ${e.review.node}`,e.review.kind].filter(Boolean).join(" · "),". A person takes it from here."]})]}),se&&se.id!==(K==null?void 0:K.id)&&t.jsxs("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:["Your answer wasn't taken: ",se.text]}),ft&&ft.at!==(R==null?void 0:R.asked_at)&&t.jsxs("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:["Your answer wasn't taken: ",ft.text]}),K?t.jsx(HE,{pending:K,onAnswer:(Se,Ye,Nt)=>Nt?xe(K.id,Se,Ye,Nt):xe(K.id,Se,Ye)},K.id):R?t.jsx(JE,{ask:R,onAnswer:_?zt:void 0,open:F!=="screen"?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>q("screen"),children:"Open the screen"}):null},Pe):!A&&W.needsYou&&(M?t.jsx(zW,{pending:M}):t.jsx(FW,{waiting:Z})),W.needsYou&&M&&typeof M.cap_usd=="number"&&(f==null?void 0:f.onRaiseCap)&&t.jsx(KE,{cap:M.cap_usd,suggested:GE(M),least:qE(M),paused:!0,onRaise:f.onRaiseCap},`${e.run_id}:${M.at}`),F==="report"&&t.jsx(e9,{run:e,rows:a,files:i,onOpen:ge,schema:c}),F==="report"&&!e.result&&!W.final&&t.jsx(Rx,{...l7(e,W)}),F==="report"&&W.final&&!((Xe=(Ue=e.result)==null?void 0:Ue.final_answer)!=null&&Xe.trim())&&!((rt=e.result)!=null&&rt.output)&&!a.some(Se=>{var Ye;return Se.kind==="final_answer"&&((Ye=Se.text)==null?void 0:Ye.trim())})&&e.status!=="failed"&&e.status!=="cancelled"&&!e.review&&t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:[g2,W.canMessage?" Send a follow-up below to ask for one.":""]}),F==="timeline"&&t.jsx(o7,{rows:Vz(a,e.learning),live:W.live,ended:Wa(e.status),asking:(de==null?void 0:de.id)??(W.needsYou&&!M?Z==null?void 0:Z.id:void 0),waitingOn:e.status==="input_required"?(J=e.pending)==null?void 0:J.kind:void 0,files:i,onOpen:ge}),(F==="report"||F==="timeline")&&t.jsx(O9,{run:e,graded:Me,onGrade:re,onOpenTimeline:F==="timeline"?void 0:()=>q("timeline")}),(F==="report"||F==="timeline")&&t.jsx(z9,{used:(je==null?void 0:je.used)??null,agentId:e.agent_id}),(F==="report"||F==="timeline")&&me&&t.jsx(j9,{got:me.got,retry:me.retry}),F==="learning"&&t.jsx(s9,{run:e,read:k,onViewChanges:me?()=>q("report"):void 0},e.run_id),F==="files"&&t.jsx(VW,{files:i,onOpen:ge,showHidden:G,onShowHidden:U}),F==="screen"&&Je&&t.jsx(p9,{runId:e.run_id,screen:pt,machine:Ze,opens:Re,followUp:W.canMessage&&W.messageMode==="follow_up",metered:Fe,waitsFor:e.status==="input_required"&&((ve=e.pending)==null?void 0:ve.kind)!=="stopped"?(We=e.pending)==null?void 0:We.kind:void 0,keptUntil:e.status==="input_required"?at:void 0,onTake:N?_t:void 0,onHand:_?()=>tt():void 0})]})}),A&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:["Native sessions cannot receive steering or follow-up messages. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(e.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," for another task."]}),L&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:[Vo(L.runtime)," runs in your backend. Start, stop and follow up through that application's controls. AgentRun records the result and checked learning."]}),W.canMessage&&t.jsx("div",{className:"border-t px-5 py-4 md:px-8",children:t.jsx("div",{className:"mx-auto max-w-4xl",children:t.jsx(IW,{mode:W.messageMode,onSend:g,purpose:K?a7:R&&P?i7[P]:void 0})})}),z&&t.jsx(YW,{file:z.file,text:z.text,onClose:fe,files:i,onOpen:ge})]})}const a$=new Set(["chain","parallel","route","map","loop","workflow"]),d7={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},u7=e=>e==="review"?"needs review":e.replace("-"," ");function $y({state:e}){const n=Af(e)??"pending";return t.jsx(Ne,{tone:d7[n]??"plain",className:"whitespace-nowrap",children:u7(n)})}function _y({provider:e}){if(!e)return null;const n=e==="parallel"?"--wf-parallel":e==="openrouter"?"--wf-openrouter":"--wf-jev";return t.jsx("span",{className:"caps inline-flex h-5 items-center border px-1.5 text-micro leading-none",style:{color:`hsl(var(${n}))`,borderColor:`hsl(var(${n}) / .6)`,background:`hsl(var(${n}) / .12)`},children:e})}const i$={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},Ty=(e,n)=>e&&n?Date.parse(n)-Date.parse(e):void 0;function f7({data:e,selected:n,onSelect:s,onClose:r,fileUrl:a}){var j,k,E,S,N,_;const i=e.graph.nodes.find($=>$.path===n.path),[c,d]=p.useState(null);if(!i)return null;const u=e.nodes[i.path],f=_v(e.workflow,i.path,i),g=i.kind==="map"?i.path:(j=e.graph.nodes.find($=>$.kind==="map"&&i.path.startsWith(`${$.path}/body/`)))==null?void 0:j.path,b=n.item!=null&&g?(E=(k=e.nodes[g])==null?void 0:k.items)==null?void 0:E.find($=>$.index===n.item):void 0,x=e.decisions.filter($=>$.node===i.path),h=e.effects.filter($=>$.node===i.path),v=!!g&&i.kind!=="map",y=Ty(u==null?void 0:u.startedAt,u==null?void 0:u.endedAt);return t.jsxs("aside",{className:"flex min-h-0 flex-col bg-background","aria-label":"Node details",children:[t.jsxs("header",{className:"border-b px-5 py-4",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"caps flex items-center gap-1.5 text-label text-muted-foreground",children:[f.decision?i.kind:Gv(i.kind,u),f.tool?` · ${d$(f.tool)}`:i.via?` · ${i.via}`:"",f.tool&&pd(f.tool)&&t.jsx(u$,{}),b&&t.jsxs(t.Fragment,{children:[t.jsx(Cs,{className:"size-3","aria-hidden":!0})," item ",b.index+1]})]}),t.jsx("h2",{className:"mt-1 break-words font-mono text-lg font-semibold leading-tight",children:b?Uc(e,g,b.index)??`Item ${b.index+1}`:i.label}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[t.jsx($y,{state:b?b.status:u==null?void 0:u.status}),b&&(()=>{const $=Tv(e,g,b);return $.outcome?t.jsxs("span",{className:"font-mono text-label",title:$.pNote,children:["outcome ",t.jsx("b",{className:i$[$.tone??""],children:$.outcome}),$.p!==void 0&&t.jsxs("span",{className:"text-muted-foreground",children:[" · ",Bs($.p)]})]}):null})(),f.decision&&t.jsx(_y,{provider:f.provider}),f.decision&&((u==null?void 0:u.model)??f.model)&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:(u==null?void 0:u.model)??f.model}),(u==null?void 0:u.branch)&&t.jsxs("span",{className:"font-mono text-label",children:["took ",t.jsx("b",{children:u.branch})]}),!b&&y!==void 0&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Yi(y)})]})]}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:r,children:t.jsx(Jo,{"aria-hidden":!0})})]}),b&&t.jsxs("button",{type:"button",className:"caps mt-3 text-label text-muted-foreground hover:text-foreground",onClick:()=>s({path:g,item:null}),children:["All ",(N=(S=e.nodes[g])==null?void 0:S.items)==null?void 0:N.length," items of ",(_=e.graph.nodes.find($=>$.path===g))==null?void 0:_.label]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-auto px-5 py-5",children:[b?t.jsx(g7,{data:e,mapPath:g,index:b.index,status:b.status,fileUrl:a,zoom:d}):i.kind==="map"?t.jsx(m7,{data:e,mapPath:i.path,onSelect:s}):v&&(x.length||h.length)?t.jsx(h7,{data:e,path:i.path,mapPath:g,onSelect:s}):t.jsxs(t.Fragment,{children:[i.kind==="parallel"&&t.jsx(p7,{data:e,path:i.path,onSelect:s}),x.map(($,O)=>t.jsx(c$,{d:$,fileUrl:a,zoom:d},$.id??O)),h.map(($,O)=>t.jsx(f$,{e:$,fileUrl:a,zoom:d},O)),!x.length&&!h.length&&i.kind!=="parallel"&&t.jsx(l$,{kind:i.kind,status:u==null?void 0:u.status,meta:f})]}),t.jsx(w7,{workflow:e.workflow,path:i.path,kind:i.kind})]}),c&&t.jsx(j7,{src:c,onClose:()=>d(null)})]})}function l$({kind:e,status:n,meta:s}){const r=s.decision?n==="working"?"Asking now. The verdict shows here when the answer comes back.":"Not asked yet.":e==="code"?"A code node: a pure transform of the run's state. It calls nothing, so it leaves no record of its own.":e==="route"?"Routed by a value already in the state: no model was asked.":a$.has(e)?"Its nodes are drawn inside it. Pick one to see what it did.":"Nothing recorded yet.";return t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:r})}function m7({data:e,mapPath:n,onSelect:s}){var i;const r=((i=e.nodes[n])==null?void 0:i.items)??[],a=m2(r);return t.jsxs("section",{children:[t.jsx("div",{className:"mb-3 grid grid-cols-5 border",children:[["Items",a.total],["Done",a.done],["Working",a.working],["Review",a.review],["Failed",a.failed]].map(([c,d])=>t.jsxs("div",{className:"border-r px-3 py-2 last:border-r-0",children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:c}),t.jsx("p",{className:"font-mono text-lg font-semibold tabular-nums",children:d})]},c))}),t.jsxs("table",{className:"w-full border-collapse font-mono text-small",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"caps text-left text-micro text-muted-foreground",children:[t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"#"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Item"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"State"}),t.jsx("th",{className:"border-b py-1.5 pr-2 font-normal",children:"Verdict"}),t.jsx("th",{className:"border-b py-1.5 text-right font-normal",children:"Cost"})]})}),t.jsx("tbody",{children:r.map(c=>{const d=e.decisions.filter(g=>{var b;return g.item===c.index&&!!((b=g.node)!=null&&b.startsWith(`${n}/body`))}),u=Tv(e,n,c),f=d.length?d.some(g=>g.cost_usd===null)?null:d.reduce((g,b)=>g+(b.cost_usd??0),0):void 0;return t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>s({path:n,item:c.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:c.index+1}),t.jsx("td",{className:"max-w-[140px] truncate border-b py-1.5 pr-2",title:Uc(e,n,c.index),children:Uc(e,n,c.index)??"—"}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:t.jsx($y,{state:c.status})}),t.jsx("td",{className:"max-w-[150px] truncate whitespace-nowrap border-b py-1.5 pr-2",title:[u.pNote,...d.map(g=>cl(g))].filter(Boolean).join(", "),children:u.outcome?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:oe("font-semibold",i$[u.tone??""]),children:u.outcome}),u.p!==void 0&&t.jsx("span",{className:"ml-2 tabular-nums text-muted-foreground",children:Bs(u.p)})]}):d.map(g=>cl(g)).filter(Boolean).join(", ")||t.jsx("span",{className:"text-muted-foreground",children:"—"})}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums",children:f===void 0?t.jsx("span",{className:"text-muted-foreground",children:"—"}):kl(f)})]},c.index)})})]})]})}function h7({data:e,path:n,mapPath:s,onSelect:r}){var g;const a=e.decisions.filter(b=>b.node===n),i=e.effects.filter(b=>b.node===n),c=(((g=e.nodes[s])==null?void 0:g.items)??[]).map(b=>({it:b,d:a.find(x=>x.item===b.index),e:i.find(x=>x.item===b.index)})).filter(b=>b.d||b.e),d=a.filter(b=>b.cost_usd!==null),u=a.filter(b=>b.latency_ms!==null),f=u.length?u.reduce((b,x)=>b+(x.latency_ms??0),0)/u.length:void 0;return t.jsxs("section",{children:[a.length>0&&t.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[a.length," asked · ",kl(d.reduce((b,x)=>b+(x.cost_usd??0),0)),d.length<a.length?` + ${a.length-d.length} unknown`:""," · mean ",Yi(f)]}),t.jsx("table",{className:"w-full border-collapse font-mono text-small",children:t.jsx("tbody",{children:c.map(({it:b,d:x,e:h})=>t.jsxs("tr",{className:"cursor-pointer hover:bg-accent",onClick:()=>r({path:s,item:b.index}),children:[t.jsx("td",{className:"border-b py-1.5 pr-2 tabular-nums text-muted-foreground",children:b.index+1}),t.jsx("td",{className:"max-w-[150px] truncate border-b py-1.5 pr-2",children:Uc(e,s,b.index)}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:x?cl(x):h?t.jsx($y,{state:h.status}):null}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:x?Yi(x.latency_ms):h?Yi(Ty(h.startedAt,h.endedAt)):""})]},b.index))})})]})}function p7({data:e,path:n,onSelect:s}){var x,h;const r=`${n}/branches/`,a=e.decisions.filter(v=>{var y;return((y=v.node)==null?void 0:y.startsWith(r))&&/^\d+$/.test(v.node.slice(r.length))&&v.item===null}),i=new Set(a.flatMap(v=>Object.keys(v.answers??{}))),[c]=[...i],d=a.map(v=>{var y;return{d:v,a:(y=v.answers)==null?void 0:y[c]}}).filter(v=>{var y;return((y=v.a)==null?void 0:y.type)==="noul"});if(i.size!==1||d.length<2)return t.jsx(l$,{kind:"parallel",meta:{decision:!1}});const u=d.map(v=>v.a.noul),f=u.reduce((v,y)=>v+y,0)/u.length,g=Math.max(...u)-Math.min(...u),b=v=>{var y;return((y=e.graph.nodes.find(j=>j.path===v.node))==null?void 0:y.label)??v.node};return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"border-b px-4 py-2.5",children:[t.jsxs("p",{className:"caps text-micro text-muted-foreground",children:["Jury · ",d.length," models · ",c]}),t.jsx("p",{className:"mt-1 text-body leading-snug",children:((h=(x=a[0].questions)==null?void 0:x[c])==null?void 0:h.instructions)??c})]}),t.jsx("ul",{className:"divide-y",children:d.map(({d:v,a:y})=>t.jsx("li",{children:t.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-2 text-left font-mono text-small hover:bg-accent",onClick:()=>s({path:v.node,item:null}),children:[t.jsx("span",{className:"w-[92px] shrink-0",children:t.jsx(_y,{provider:v.provider})}),t.jsx("span",{className:"w-[132px] shrink-0 truncate",title:v.model??"",children:v.model??b(v)}),t.jsx(Ax,{p:y.noul,strong:!0,tick:.5,tone:y.noul>=.5?"fg":"muted"}),t.jsx("span",{className:"w-10 text-right tabular-nums",children:Bs(y.noul)})]})},v.id??v.executionPath))}),t.jsxs("dl",{className:"grid grid-cols-3 border-t font-mono text-small",children:[t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Mean P(yes)"}),t.jsx("dd",{className:"font-semibold tabular-nums",children:Bs(f)})]}),t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Spread"}),t.jsx("dd",{className:oe("font-semibold tabular-nums",g>.3&&"text-warning-text"),children:Bs(g)})]}),t.jsxs("div",{className:"px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),t.jsx("dd",{className:"tabular-nums",children:kl(d.some(v=>v.d.cost_usd===null)?null:d.reduce((v,y)=>v+(y.d.cost_usd??0),0))})]})]})]})}function g7({data:e,mapPath:n,index:s,status:r,fileUrl:a,zoom:i}){const d=e.graph.nodes.filter(u=>u.path.startsWith(`${n}/body`)).map(u=>({n:u,ds:e.decisions.filter(f=>f.node===u.path&&f.item===s),es:e.effects.filter(f=>f.node===u.path&&f.item===s)})).filter(u=>!a$.has(u.n.kind)||u.ds.length||u.es.length);return r==="pending"?t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"Not started: this item waits for a free slot in the map."}):t.jsxs("div",{className:"space-y-5",children:[d.map(({n:u,ds:f,es:g})=>f.length||g.length?t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:u.label}),g.map((b,x)=>t.jsx(f$,{e:b,fileUrl:a,zoom:i,compact:!0},x)),f.map((b,x)=>t.jsx(c$,{d:b,fileUrl:a,zoom:i},b.id??x))]},u.path):null),r==="working"&&!d.some(u=>u.ds.length)&&t.jsx("p",{className:"border border-dashed px-4 py-3 text-body text-muted-foreground",children:"In flight: the verdict shows here when it comes back."})]})}const cN=e=>`${Math.round(e*100)}%`,Bs=e=>e.toFixed(2);function Ax({p:e,strong:n,tick:s,tone:r="fg"}){const a={fg:"bg-foreground",success:"bg-success",warning:"bg-warning",muted:"bg-muted-foreground/50"}[r];return t.jsxs("span",{className:"relative block h-2 flex-1 bg-muted",children:[t.jsx("span",{className:oe("absolute inset-y-0 left-0 transition-[width] duration-slow",n?a:"bg-muted-foreground/45"),style:{width:cN(Math.max(0,Math.min(1,e)))}}),s!==void 0&&t.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:cN(s)},title:`threshold ${Bs(s)}`})]})}function x7({id:e,q:n,a:s,rule:r}){const a=d=>{var u;return(r==null?void 0:r.kind)==="pick"&&(n==null?void 0:n.type)==="choice"&&typeof((u=n.criteria)==null?void 0:u[d])=="string"?n.criteria[d]:d},i=(n==null?void 0:n.instructions)??e,c=(r==null?void 0:r.kind)==="route"?r.unsure:null;return t.jsxs("div",{className:"py-2.5",children:[t.jsxs("p",{className:"mb-2 text-body leading-snug",children:[t.jsx("span",{className:"mr-2 font-mono text-label text-muted-foreground",children:e}),i]}),s?s.type==="refusal"?t.jsx("p",{className:"font-mono text-small text-warning-text",children:"Refused to answer."}):s.type==="noul"?t.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[t.jsx("span",{className:oe("w-8 font-semibold",s.noul>=.5?"text-foreground":"text-muted-foreground"),children:s.noul>=.5?"YES":"NO"}),t.jsx(Ax,{p:s.noul,strong:!0,tick:.5,tone:s.noul>=.5?"fg":"muted"}),t.jsxs("span",{className:"w-24 text-right tabular-nums text-muted-foreground",children:["P(yes) ",Bs(s.noul)]})]}):s.type==="box"?t.jsxs("p",{className:"font-mono text-small",children:["box ",JSON.stringify(s.box)]}):t.jsxs("div",{className:"space-y-1.5",children:[Object.entries(s.probabilities).sort((d,u)=>u[1]-d[1]).slice(0,(r==null?void 0:r.kind)==="pick"?5:void 0).map(([d,u])=>{const f=(s.type==="choice"?s.choice:String(s.score))===d;return t.jsxs("div",{className:"flex items-center gap-3 font-mono text-small",children:[t.jsx("span",{className:oe("truncate",(r==null?void 0:r.kind)==="pick"?"w-48":"w-28",f?"font-semibold":"text-muted-foreground"),title:a(d),children:s.type==="score"?`${d} ${s.legend[d]??""}`:a(d)}),t.jsx(Ax,{p:u,strong:f,tick:f&&c?c.gte:void 0}),t.jsx("span",{className:"w-12 text-right tabular-nums text-muted-foreground",children:Bs(u)})]},d)}),(r==null?void 0:r.kind)==="pick"&&Object.keys(s.probabilities).length>5&&t.jsxs("p",{className:"font-mono text-label text-muted-foreground",children:[Object.keys(s.probabilities).length-5," more options, each less likely"]})]}):t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:"No answer."})]})}function v7(e){if(!e)return"No rule applied: nothing came back to decide on.";switch(e.kind){case"judge":return"Each answer is decoded on its own: a yes/no is yes at P(yes) ≥ 0.50, a choice is its top option.";case"route":return e.unsure?`Take the chosen branch; below ${Bs(e.unsure.gte)} confidence take "${e.unsure.branch}".`:"Take the chosen branch.";case"pick":return`Pick one of ${e.options.length} options${e.none?`, or "${e.none}"`:""}.`;case"ask":return`Holds when P(yes) ≥ ${Bs(e.gte)}.`;case"sift":return e.keep?`Keep an item when its ${e.keep.id} ${e.keep.measure} ≥ ${Bs(e.keep.gte)}.`:"Keep every item.";case"verify":return"A yes/no fails below its threshold."}}function y7(e){var s,r,a,i;const n=e.action;if(n==null)return e.status==="cancelled"?"None: the outcome is unknown, so it goes to review and is not asked again.":"None.";if(((s=e.rule)==null?void 0:s.kind)==="route"){const c=((a=(r=e.answers)==null?void 0:r.branch)==null?void 0:a.type)==="choice"?e.answers.branch.confidence:void 0;return n.unsure?`Took "${String(n.taken)}": "${String(n.branch)}" at ${c!==void 0?Bs(c):"?"} is below the threshold.`:`Took "${String(n.taken??n.branch)}".`}if(((i=e.rule)==null?void 0:i.kind)==="pick"&&typeof n.index=="number"){const c=e.rule.options[n.index];return n.none?`None of the options: "${e.rule.none??"none"}".`:`Picked ${c!==void 0?`"${u2(e,Object.keys(e.questions??{})[0]??"pick",c)}"`:`option ${n.index}`}.`}return typeof n=="object"?Object.entries(n).map(([c,d])=>`${c} = ${typeof d=="object"?JSON.stringify(d):String(d)}`).join(" · "):String(n)}function c$({d:e,fileUrl:n,zoom:s}){var i,c,d;const r=Array.from(new Set([...Object.keys(e.questions??{}),...Object.keys(e.answers??{})])),a=e.status==="answered"?"success":e.status==="cancelled"?"warning":"error";return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"flex flex-wrap items-center gap-2 border-b px-4 py-2.5",children:[t.jsx(_y,{provider:e.provider}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:e.model??"default model"}),t.jsx(Ne,{tone:a,children:e.status==="cancelled"?"outcome unknown":e.status})]}),t.jsxs("dl",{className:"grid grid-cols-[minmax(0,1fr)_100px_92px] border-b font-mono text-small",children:[t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:Object.keys(e.answers??{}).length>1&&((i=e.rule)==null?void 0:i.kind)!=="route"?"Least sure answer":"Verdict"}),t.jsx("dd",{className:"break-words font-semibold",children:cl(e)??"—"})]}),t.jsxs("div",{className:"border-r px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Cost"}),t.jsx("dd",{className:"tabular-nums",title:e.cost_basis??void 0,children:kl(e.cost_usd)})]}),t.jsxs("div",{className:"px-4 py-2",children:[t.jsx("dt",{className:"caps text-micro text-muted-foreground",children:"Latency"}),t.jsx("dd",{className:"tabular-nums",children:Yi(e.latency_ms)})]})]}),e.error&&t.jsx("p",{className:oe("border-b px-4 py-2.5 font-mono text-small",e.status==="cancelled"?"text-warning-text":"text-destructive-text"),children:e.error}),!!((c=e.images)!=null&&c.length)&&t.jsx("div",{className:"space-y-3 border-b px-4 py-3",children:e.images.map(u=>({img:u,src:u.ref&&n(u.ref)||so(u.url)})).filter(({src:u})=>u).map(({img:u,src:f})=>t.jsxs("figure",{className:"flex gap-3",children:[t.jsx("button",{type:"button",className:"block shrink-0 border bg-white hover:border-foreground",onClick:()=>s(f),"aria-label":`Open ${u.ref}`,children:t.jsx("img",{src:f,alt:`The page the model saw as ${u.token}`,className:"block h-[155px] w-[120px] object-cover object-top",loading:"lazy"})}),t.jsxs("figcaption",{className:"min-w-0 flex-1 space-y-1.5 font-mono text-label",children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:"What the model saw"}),t.jsxs("p",{children:[t.jsx("span",{className:"text-muted-foreground",children:"token "}),u.token]}),t.jsxs("p",{className:"break-all",children:[t.jsx("span",{className:"text-muted-foreground",children:"page "}),u.ref]}),u.sha256&&t.jsxs("p",{className:"break-all",title:u.sha256,children:[t.jsx("span",{className:"text-muted-foreground",children:"sha256 "}),u.sha256.slice(0,16),"…"]}),(u.mime||u.bytes)&&t.jsx("p",{className:"text-muted-foreground",children:[u.mime,u.bytes?`${Math.round(u.bytes/1024)} KB`:null].filter(Boolean).join(" · ")})]})]},u.token))}),t.jsx("div",{className:"divide-y px-4",children:r.map(u=>{var f,g;return t.jsx(x7,{id:u,q:(f=e.questions)==null?void 0:f[u],a:(g=e.answers)==null?void 0:g[u],rule:e.rule},u)})}),t.jsxs("dl",{className:"space-y-2 border-t px-4 py-3 text-body",children:[t.jsxs("div",{className:"flex gap-3",children:[t.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Rule"}),t.jsx("dd",{children:v7(e.rule)})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("dt",{className:"caps w-14 shrink-0 pt-0.5 text-micro text-muted-foreground",children:"Action"}),t.jsx("dd",{className:"font-mono text-small",children:y7(e)})]})]}),!!((d=e.evidence)!=null&&d.length)&&t.jsx(b7,{evidence:e.evidence}),e.state!=null&&t.jsxs("details",{className:"group border-t",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Cs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," What the model saw",e.state_truncated?" (cut at 64 KB)":""]}),t.jsx(nm,{value:e.state})]})]})}function b7({evidence:e}){return t.jsxs("section",{className:"border-t px-4 py-3",children:[t.jsxs("p",{className:"caps mb-2 text-micro text-muted-foreground",children:["Sources · ",e.length]}),t.jsx("ol",{className:"space-y-3",children:e.map((n,s)=>{let r=n.url;try{r=new URL(n.url).host}catch{}const a=so(n.url);return t.jsxs("li",{className:"flex gap-3",children:[t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:s+1}),t.jsxs("div",{className:"min-w-0 flex-1",children:[a?t.jsxs("a",{href:a,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-start gap-1 text-body font-semibold leading-snug hover:underline",children:[n.title??r,t.jsx(gT,{className:"mt-0.5 size-3 shrink-0 text-muted-foreground","aria-hidden":!0})]}):t.jsx("span",{className:"break-all text-body font-semibold leading-snug",children:n.title??r}),t.jsxs("p",{className:"mt-0.5 flex items-center gap-2 font-mono text-label text-muted-foreground",children:[r,n.scope&&t.jsx("span",{className:"border px-1",children:n.scope})]}),n.excerpts.slice(0,2).map((i,c)=>t.jsx("blockquote",{className:"mt-1.5 line-clamp-3 border-l-2 border-wf-parallel/[.6] pl-2.5 text-body leading-snug text-muted-foreground",children:i},c))]})]},s)})})]})}const d$=e=>{const n=pd(e);return n?`${n.tool} on ${n.server}`:e},u$=()=>t.jsx(Ne,{tone:"muted",title:"An MCP server's tool",children:t.jsx("span",{"data-mcp":!0,children:"MCP"})});function f$({e,fileUrl:n,zoom:s,compact:r=!1}){var g;const a=e.output,i=a!=null,c=a&&typeof a=="object"?a:null,d=!e.endedAt&&!["done","ok","failed","stopped"].includes(e.status),u=e.error??(c!=null&&c.error?`${c.error.code?`${c.error.code}: `:""}${c.error.message??""}`:null),f=e.status==="done"||e.status==="ok"?"success":e.status==="failed"?"error":e.status==="stopped"?"muted":"active";return t.jsxs("section",{className:"border bg-card",children:[t.jsxs("header",{className:"flex items-center gap-2 border-b px-4 py-2.5",children:[t.jsx("span",{className:"caps inline-flex h-5 items-center border border-wf-tool/[.6] bg-wf-tool/[.12] px-1.5 text-micro leading-none text-wf-tool",children:"tool"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",title:e.tool,children:d$(e.tool)}),pd(e.tool)&&t.jsx(u$,{}),t.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:e.endedAt?Yi(Ty(e.startedAt,e.endedAt)):""}),t.jsx(Ne,{tone:f,children:e.status})]}),t.jsxs("div",{className:"space-y-3 px-4 py-3",children:[r?t.jsxs("p",{className:"break-all font-mono text-label",children:[t.jsx("span",{className:"caps mr-2 text-micro text-muted-foreground",children:"Input"}),JSON.stringify(e.input)]}):t.jsxs("div",{children:[t.jsx("p",{className:"caps mb-1 text-micro text-muted-foreground",children:"Input"}),t.jsx(nm,{value:e.input,small:!0})]}),u&&t.jsx("p",{className:"font-mono text-small text-destructive-text",children:u}),!!((g=c==null?void 0:c.pages)!=null&&g.length)&&t.jsx("div",{className:"flex flex-wrap gap-3",children:c.pages.map(b=>t.jsx("button",{type:"button",className:"block border bg-white hover:border-foreground",onClick:()=>s(n(b.image)),"aria-label":`Open page ${b.page}`,children:t.jsx("img",{src:n(b.image),alt:`Page ${b.page}`,className:"block h-[124px] w-[96px] object-cover object-top",loading:"lazy"})},b.page))}),i&&!u&&t.jsxs("details",{className:"group",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 text-micro text-muted-foreground hover:text-foreground",children:[t.jsx(Cs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),t.jsx(nm,{value:a,small:!0})]}),!i&&!u&&t.jsx("p",{className:"font-mono text-small text-muted-foreground",children:e.status==="stopped"?"Stopped before it answered.":d?"Running…":"Finished with no output."})]})]})}function w7({workflow:e,path:n,kind:s}){const r=c2(e,n);if(!r)return null;const a=Object.fromEntries(Object.entries(r).map(([i,c])=>[i,(i==="steps"||i==="branches"&&s==="parallel")&&Array.isArray(c)?`… ${Um(c.length)}`:i==="body"?"… its body":i==="branches"&&s==="route"&&c&&typeof c=="object"?Object.fromEntries(Object.entries(c).map(([d,u])=>[d,(u==null?void 0:u.criteria)??"…"])):c]));return t.jsxs("details",{className:"group border",children:[t.jsxs("summary",{className:"caps flex cursor-pointer list-none items-center gap-1.5 px-4 py-2.5 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(Cs,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Definition ",t.jsx("span",{className:"normal-case tracking-normal",children:n})]}),t.jsx(nm,{value:a})]})}function nm({value:e,small:n}){return t.jsx("pre",{className:oe("overflow-auto whitespace-pre-wrap break-words border-t bg-background px-4 py-3 font-mono leading-[1.6]",n?"max-h-48 border text-label":"max-h-80 text-small"),children:JSON.stringify(e,null,2)})}function j7({src:e,onClose:n}){return t.jsx(Em,{open:!0,onClose:n,title:"Page image",size:"full",children:t.jsx("img",{src:e,alt:"Page",className:"mx-auto max-h-full max-w-full border bg-white"})})}const m$=e=>[400,401,403,404,405,410,422].includes((e==null?void 0:e.status)??0);function k7(e,{everyMs:n=1e3,key:s="",enabled:r=!0}={}){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(0),[g,b]=p.useState(0),x=p.useRef(e);return x.current=e,p.useEffect(()=>{if(!r)return;const h=new AbortController;let v;const y=async()=>{try{const j=Date.now(),k=await x.current(h.signal);if(h.signal.aborted||(i(k),d(null),f(j),ld(k.run.status)))return}catch(j){if(h.signal.aborted)return;d(j);const k=j;if(k.retryable){v=setTimeout(y,Math.min(n,k.retryAfterMs??500));return}if(m$(j))return}v=setTimeout(y,n)};return y(),()=>{h.abort(),clearTimeout(v)}},[s,n,g,r]),{data:a,error:c,readAt:u,reload:()=>b(h=>h+1)}}function N7({data:e,actions:n={},fileUrl:s,initial:r=null,lastRead:a}){const[i,c]=p.useState(r),d=p.useMemo(()=>hP(e,i),[e,i]),u=ld(e.run.status),[f,g]=p.useState(()=>Date.now()),b=p.useMemo(()=>Date.now(),[e]);return p.useEffect(()=>{if(u||e.run.paused)return;const x=setInterval(()=>g(Date.now()),1e3);return()=>clearInterval(x)},[u,e.run.paused]),t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsx(S7,{data:e,readAt:b,now:f,actions:n,stale:!u&&a&&f-a>5e3?Math.max(1e3,f-a):0}),e.run.paused&&t.jsx("p",{className:"border-b border-warning/40 bg-warning/10 px-5 py-2 font-mono text-small text-warning-text md:px-8",role:"status",children:"Paused. Calls already in flight finish; no new node starts until you resume. The run keeps its place across a restart."}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[t.jsx("div",{className:"min-h-[320px] min-w-0 flex-1 overflow-auto bg-[radial-gradient(hsl(var(--border))_1px,transparent_1px)] [background-size:22px_22px]",children:t.jsx("div",{className:"px-5 py-6 md:px-8",children:t.jsx(xd,{graph:e.graph,marks:d,onSelect:x=>c(h=>h&&h.path===x.path&&(h.item??null)===x.item?null:x),label:"The run's workflow graph"})})}),i&&t.jsx("div",{className:"flex min-h-0 shrink-0 flex-col border-t lg:w-[460px] lg:border-l lg:border-t-0",children:t.jsx(f7,{data:e,selected:i,onSelect:c,onClose:()=>c(null),fileUrl:s})})]}),t.jsx("div",{className:"border-t px-5 py-2 md:px-8",children:t.jsx(vd,{run:!0})})]})}function S7({data:e,readAt:n,now:s,actions:r,stale:a}){const i=ld(e.run.status),c=e.graph.nodes.find(b=>{var x,h;return b.kind==="map"&&((h=(x=e.nodes[b.path])==null?void 0:x.items)==null?void 0:h.length)}),d=c?m2(e.nodes[c.path].items):null,{usd:u,unknown:f}=h2(e),g=[["Elapsed",dl(xP(e,n,s))],["Cost",t.jsxs(t.Fragment,{children:[kl(u),f>0&&t.jsxs("span",{className:"text-label font-normal text-muted-foreground",children:[" + ",f," unknown"]})]}),"Decisions and model calls, as the providers priced them"],["Decisions",e.totals.decisions],["Tool calls",e.totals.effects],["Agents",E7(e),"Agent loops this run started. Decision models and tools answer one call each; none of them is an agent."]];return d&&g.push(["Items",t.jsxs(t.Fragment,{children:[t.jsx("span",{children:d.done}),t.jsxs("span",{className:"text-muted-foreground",children:["/",d.total]}),d.failed>0&&t.jsxs("span",{className:"ml-2 text-label text-destructive-text",children:[d.failed," failed"]}),d.review>0&&t.jsxs("span",{className:"ml-2 text-label text-warning-text",children:[d.review," review"]})]})]),t.jsxs("div",{className:"flex flex-wrap items-stretch border-b",children:[e.run.paused&&t.jsx("div",{className:"flex items-center pl-5 md:pl-8",children:t.jsxs(Ne,{tone:"warning",children:[t.jsx(sl,{className:"size-3","aria-hidden":!0})," Paused"]})}),g.map(([b,x,h],v)=>t.jsxs("div",{className:oe("px-4 py-2",v?"border-l":"pl-5 md:pl-8"),title:h,children:[t.jsx("p",{className:"caps text-micro text-muted-foreground",children:b}),t.jsx("p",{className:"font-mono text-prose font-semibold tabular-nums",children:x})]},b)),t.jsxs("div",{className:"flex flex-1 items-center justify-end gap-3 px-5 py-2 md:px-8",children:[a>0&&t.jsxs("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:["Last read ",dl(a)," ago, reading again"]}),!i&&(e.run.paused?t.jsxs(B,{size:"sm",variant:"solid",onClick:r.onResume,disabled:!r.onResume||!!r.busy,children:[t.jsx(Yo,{"aria-hidden":!0})," ",r.busy==="resume"?"Resuming":"Resume"]}):t.jsxs(B,{size:"sm",onClick:r.onPause,disabled:!r.onPause||!!r.busy,title:"Calls in flight finish; no new node starts.",children:[t.jsx(sl,{"aria-hidden":!0})," ",r.busy==="pause"?"Pausing":"Pause"]}))]})]})}const C7=new Set(["agent","decide","extract","report","artifact"]),E7=e=>e.graph.nodes.filter(n=>{var s;return C7.has(n.kind)&&!["pending","not_run"].includes(((s=e.nodes[n.path])==null?void 0:s.status)??"pending")}).length;function $7({error:e}){const n=e==null?void 0:e.status;return t.jsx("p",{className:oe("m-8 border p-4 font-mono text-body",n===404?"text-muted-foreground":"text-destructive-text"),role:"status",children:e==null?"Reading the run's graph...":n===404?"This server does not give run graphs: GET /v2/runs/{id}/graph is not there.":`The run's graph could not be read: ${e.message??String(e)}`})}function _7(e,n){return!n||e.state==="loading"?{messages:Pm,steers:!1}:e.state==="failed"?{messages:n.features.messages,steers:!1}:{messages:n.features.messages,steers:OP(e.id,n.harnesses)}}async function T7(e,n){try{let s=null;do{const r=await e.listRevisions(n.agent_id,s),a=r.revisions.find(c=>c.revision===n.revision),i=a==null?void 0:a.definition.output_schema;if(a)return{state:"read",id:a.definition.harness,...i?{outputSchema:i}:{}};s=r.next_cursor}while(s)}catch{}return{state:"failed"}}const dN=new Set(["completed","failed","cancelled"]),R7={firstMs:2e3,maxMs:16e3,totalMs:12e4};function A7(e,n,s,r=R7){var g;const a=!!e&&dN.has(e.status)&&Hm(e.learning),i=p.useRef(n);i.current=n;const c=p.useRef(s);c.current=s;const d=(g=e==null?void 0:e.learning)==null?void 0:g.state,u=!!e&&dN.has(e.status),f=p.useRef(d);p.useEffect(()=>{var x;const b=f.current;f.current=d,b!==void 0&&b!==d&&u&&((x=c.current)==null||x.call(c))},[d,u]),p.useEffect(()=>{if(!a)return;let b,x=0,h=r.firstMs,v=!1,y=!1;const j=()=>{y||x+h>r.totalMs||(b=setTimeout(k,h))},k=()=>{if(b=void 0,document.visibilityState==="hidden"){v=!0;return}x+=h,h=Math.min(h*2,r.maxMs),i.current(),j()},E=()=>{v&&document.visibilityState!=="hidden"&&(v=!1,k())};return document.addEventListener("visibilitychange",E),j(),()=>{y=!0,b&&clearTimeout(b),document.removeEventListener("visibilitychange",E)}},[a])}const uN=new Set(["completed","failed","cancelled"]),O7=e=>{const n=h2(e);return`${kl(n.usd)}${n.unknown?` + ${n.unknown} unknown`:""}`},M7=e=>e instanceof De?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!0},zi=e=>({api:M7(e),title:YM(e),cause:e});function fN({v2:e,runId:n,caps:s,agentName:r}){const[a,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[g,b]=p.useState([]),[x,h]=p.useState(null),[v,y]=p.useState(null),[j,k]=p.useState(0),E=p.useRef(""),S=p.useRef(Zg()).current,N=p.useRef(Zg()).current,_=p.useRef(dr()).current,$=p.useRef(0),O=p.useRef(""),[A,L]=p.useState({state:"loading"});p.useEffect(()=>{a&&A.state==="loading"&&T7(e,a).then(L)},[a==null?void 0:a.revision]);const M=_7(A,s);A7(a,()=>R(),()=>k(K=>K+1));const R=async()=>{const K=S.begin();try{const[Z,de]=await Promise.all([e.getRun(n),e.listFiles(n)]);S.current(K)&&(i(Z),b(de.files))}catch(Z){S.current(K)&&h(zi(Z))}};p.useEffect(()=>{R()},[n]),DE(()=>{R()}),p.useEffect(()=>{const K=new AbortController;return d(null),XS(e,n,{signal:K.signal,onRows:Z=>{f(Z);const de=Z.filter(ue=>ue.kind===UE).map(ue=>`${ue.id}\0${ue.summary}`).join("");de!==O.current&&(O.current=de,R());const se=Z.filter(ue=>ue.kind==="tool_result").length;if(se>$.current){$.current=se;const ue=N.begin();e.listFiles(n).then(xe=>{N.current(ue)&&b(xe.files)}).catch(()=>{})}},onPage:Z=>{Z.cost&&d(Z.cost);const de=`${Z.status}/${Z.state}`;(de!==E.current||Z.status==="input_required"&&!Z.unchanged)&&(E.current=de,R())}}).catch(Z=>{K.signal.aborted||h(zi(Z))}),()=>K.abort()},[n,j]);const P=async K=>{y(K);try{await e[K](n),h(null)}catch(Z){h(zi(Z))}y(null),await R(),k(Z=>Z+1)},D=async()=>{if(a){y("archive");try{const K=await(a.archived_at?e.unarchiveRun(n):e.archiveRun(n));i(Z=>Z?{...Z,archived_at:K.archived_at}:K),h(null)}catch(K){h(zi(K))}y(null),R()}},W=async K=>{const Z=await K();return await R(),k(de=>de+1),Z},Y=K=>W(()=>e.raiseCap(n,K)),H=K=>W(()=>e.gradeRun(n,K)),q=async K=>{let Z=!0;try{await fC(_,n,K,e.sendMessage),h(null)}catch(de){h(zi(de)),Z=!1}return await R(),k(de=>de+1),Z},F=async(K,Z,de,se)=>{let ue=null;try{await e.answerApproval(n,K,Z,de,se)}catch(xe){ue=WE(xe)}return await R(),k(xe=>xe+1),ue},G=async K=>{try{return await K()}finally{R(),k(Z=>Z+1)}},U=k7(K=>e.getRunGraph(n,K),{key:n,enabled:(a==null?void 0:a.kind)==="workflow"}),z=!U.data&&m$(U.error);if(!a)return x?x.cause instanceof De&&x.cause.status===404?t.jsx(t2,{what:"run",id:n,list:{href:"#/runs",label:"Open the runs list"}}):t.jsx(Yt,{problem:Ut(x.cause,"the run"),onRetry:()=>{h(null),R(),k(K=>K+1)}}):t.jsx(BM,{});const Q=c&&!uN.has(a.status)?{...a,cost:c}:a;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[x&&t.jsx("div",{className:"border-b p-3",children:t.jsx(sa,{title:x.title,error:x.api})}),t.jsx(c7,{run:Q,agentName:r(a.agent_id),messages:M.messages,harnessSteers:M.steers,graphView:a.kind==="workflow"&&!z?t.jsx(P7,{v2:e,runId:n,graph:U,onMoved:()=>{R()}}):void 0,costText:a.kind==="workflow"&&!uN.has(a.status)&&U.data?O7(U.data):void 0,outputSchema:A.state==="read"?A.outputSchema:void 0,rows:u,files:g,readFile:K=>e.readFile(n,K.path),readLearningDiff:()=>e.runLearningDiff(n),readLearning:()=>e.runLearning(n),readLearningResult:()=>e.runLearningResult(n),readComputer:()=>e.runComputer(n),onTakeOver:()=>G(()=>e.takeOverComputer(n)),onHandBack:K=>G(()=>e.handBackComputer(n,K)),readComputers:()=>e.computers(),onMessage:q,onApprove:F,onGrade:H,actions:{onStop:()=>void P("stop"),onCancel:()=>void P("cancel"),onArchive:()=>void D(),onRaiseCap:Y,busy:v}},a.run_id)]})}function P7({v2:e,runId:n,graph:s,onMoved:r}){const{data:a,error:i,readAt:c,reload:d}=s,[u,f]=p.useState(null),[g,b]=p.useState(null),[x,h]=p.useState(null),v=async j=>{f(j);try{const k=await(j==="pause"?e.pauseRun(n):e.resumeRun(n));h({paused:k.paused,status:k.status,at:Date.now()}),b(null)}catch(k){b(zi(k))}f(null),d(),r()},y=a&&x&&c<x.at?{...a,run:{...a.run,paused:x.paused,...x.status?{status:x.status}:{}}}:a;return y?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[g&&t.jsx("div",{className:"border-b p-3",children:t.jsx(sa,{title:g.title,error:g.api})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(N7,{data:y,lastRead:c,fileUrl:j=>e.fileUrl(n,j),actions:{onPause:()=>void v("pause"),onResume:()=>void v("resume"),busy:u}})})]}):t.jsx($7,{error:i})}function mN({actions:e,children:n}){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center justify-between gap-2 border-b px-5 py-2 md:px-6",children:[t.jsxs("h1",{className:"flex items-center gap-2.5 font-mono text-small font-semibold",children:[t.jsx(Bx,{className:"size-4","aria-hidden":!0}),"Mission Control"]}),e&&t.jsx("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-2",children:e})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n})]})}function L7({view:e,error:n,onRetry:s,scope:r,needsYou:a,asking:i,failed:c,live:d,startHere:u,actions:f,observations:g,hasObservedSessions:b=!1}){if(!e)return t.jsx(mN,{actions:f,children:t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-8 px-5 pb-16 pt-8 md:px-8 md:pt-10",children:[n?t.jsx(Yt,{problem:n,onRetry:s}):t.jsx(HM,{}),g]})});const x=y=>{var j;return((j=e.perAgent.find(k=>k.agentId===y))==null?void 0:j.name)??y},h=r!=null&&r.agent?e.perAgent.filter(y=>y.agentId===r.agent):e.perAgent,v=[["Agents",String(e.agents),"#/agents"],["Runs",String(e.runs.total),"#/runs"],["Active",String(e.runs.active),void 0,void 0,[typeof d=="number"&&d!==e.runs.active?`${d} running now`:"",e.runs.statusUnknown?`${e.runs.statusUnknown} unknown`:""].filter(Boolean).join(" · ")||void 0],["Needs input",i===null?"–":String(i??e.runs.needsInput),"#/runs?status=input_required",i??e.runs.needsInput?"text-warning-text":void 0],c===void 0?["Failed",String(e.runs.failed),"#/runs?status=failed",e.runs.failed?"text-destructive-text":void 0,hN(e.runs.needsReview)]:["Failed · last 24 h",c===null?"–":String(c),"#/runs?status=failed",c?"text-destructive-text":void 0,[`See all ${e.runs.failed}`,hN(e.runs.needsReview)??""].filter(Boolean).join(" · ")]];return t.jsx(mN,{actions:f,children:t.jsxs("div",{className:"mx-auto w-full max-w-page-wide space-y-8 px-5 pb-16 pt-8 md:px-8 md:pt-10",children:[n&&t.jsx(Yt,{problem:n,onRetry:s,className:""}),u,a,t.jsxs("section",{className:"space-y-4","aria-label":b?"Registered agents and runs":void 0,children:[b&&t.jsx("h2",{className:"text-lead font-semibold",children:"Registered agents & runs"}),t.jsx("ul",{className:"grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5",children:v.map(([y,j,k,E,S])=>{const N=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:y}),t.jsx("p",{className:oe("mt-3 font-mono text-display leading-none",E),children:j}),S&&t.jsx("p",{className:"mt-2 text-label text-muted-foreground",children:S})]});return t.jsx("li",{children:k?t.jsx("a",{href:k,className:"block h-full border bg-card p-5 transition-colors hover:border-border-strong hover:bg-accent",children:N}):t.jsx("div",{className:"h-full border bg-card p-5",children:N})},y)})})]}),g,t.jsxs("section",{className:"space-y-4","aria-label":"Analytics",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-6 gap-y-3",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lead font-semibold",children:"Activity & usage"}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:I7(e)})]}),r&&t.jsx(a2,{range:r.range,onRange:r.onRange,agent:r.agent,agents:e.perAgent,onAgent:r.onAgent})]}),t.jsx(i2,{a:e.analytics,basis:e.cost.basis,refreshing:r==null?void 0:r.refreshing})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsxs("h2",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:[t.jsx(xf,{className:"size-4","aria-hidden":!0}),"Runs per agent"]}),h.length?t.jsx("ul",{children:h.map(y=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:ln(y.agentId,"runs"),className:"flex items-center justify-between gap-3 px-4 py-3 text-lead hover:bg-accent",children:[t.jsx("span",{className:"min-w-0 truncate",children:y.name}),t.jsx("span",{className:"font-mono text-body text-muted-foreground",children:y.runs})]})},y.agentId))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No agents yet."})]}),t.jsxs("section",{className:"min-w-0 overflow-hidden border bg-card",children:[t.jsxs("h2",{className:"caps flex min-h-12 items-center gap-2 border-b px-5 py-3 text-small font-semibold",children:[t.jsx(Jc,{className:"size-4","aria-hidden":!0}),"Recent runs"]}),e.recent.length?t.jsx("ul",{children:e.recent.map(y=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(y.run_id)}`,className:"flex items-center gap-3 px-4 py-3 hover:bg-accent",children:[t.jsx(Nl,{run:y}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-lead",children:Sn(y)}),t.jsx(ey,{run:y,className:"hidden sm:inline-flex"}),NU(y)&&t.jsx("span",{className:"shrink-0 text-small text-muted-foreground",children:"send a message to continue"})]}),t.jsx("span",{className:"hidden shrink-0 text-body text-muted-foreground md:inline",children:x(y.agent_id)}),y.ended_at&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",title:"How long it ran",children:dl(Date.parse(y.ended_at)-Date.parse(y.created_at))}),y.cost&&(y.cost.usd!==null||jl(y.cost))&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:eo(y.cost,{ended:Wa(y.status)})}),t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:ht(y.created_at)})]})},y.run_id))}):t.jsx("p",{className:"px-4 py-6 text-center font-mono text-body text-muted-foreground",children:"No runs yet."})]})]})]})})}const hN=e=>e?`${e} ${e===1?"needs":"need"} review`:void 0;function I7(e,n=Date.now()){var i;const s=e.analytics.filter,r=s.from?Math.round((Math.floor(n/864e5)*864e5-Date.parse(s.from))/864e5)+1:null,a=s.from?Cv.some(c=>c.days===r)?`Runs started in the last ${r} days`:`Runs started since ${s.from.slice(0,10)}`:"All runs";return s.agent?`${a}, of ${((i=e.perAgent.find(c=>c.agentId===s.agent))==null?void 0:i.name)??s.agent}`:a}const ms=e=>`#/runs/${encodeURIComponent(e)}`;function z7({asking:e,failed:n,failedAll:s,live:r,learning:a=[],agentName:i,onAnswer:c,onApprove:d,onHandBack:u,onRunAgain:f,onStop:g,problem:b,now:x=Date.now}){const h=yU(n.filter(R=>!Zn(R))),v=n.filter(R=>!R.imported_from&&Zn(R)),[,y]=p.useState(0);p.useEffect(()=>{if(!r.length)return;const R=setInterval(()=>y(P=>P+1),1e3);return()=>clearInterval(R)},[r.length]);const[j,k]=p.useState([]),E=(R,P,D)=>{const W=e.find(H=>H.run_id===R),Y=W?Sn(W):R;k(H=>[...H.filter(q=>q.runId!==R),...D?[{runId:R,what:P,title:Y,text:D}]:[]])},S=d&&(async(R,P,D,W,Y)=>{const H=await(Y?d(R,P,D,W,Y):d(R,P,D,W));return E(R,P,H),H}),N=u&&(async(R,P,D)=>{const W=await u(R,D);return E(R,`ask:${P.asked_at}`,W),W}),_=R=>{var D;const P=Hi(R);return((D=R.pending)==null?void 0:D.kind)==="approval"?R.pending.id:P?`ask:${P.asked_at}`:null},$=LE(n),O=a.filter(R=>R.pending>0),A=O.reduce((R,P)=>R+P.pending,0),L=e.length+$+A;if(!L&&!r.length&&!b&&!j.length)return null;const M=x();return t.jsxs("section",{"aria-label":"Needs you",className:"space-y-3",children:[L>0&&t.jsxs("h2",{className:"caps text-small font-semibold",children:["Needs you ",t.jsxs("span",{className:"text-warning-text",children:["· ",L]})]}),b&&t.jsx("p",{className:"border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:b}),j.filter(R=>!e.some(P=>P.run_id===R.runId&&_(P)===R.what)).map(R=>t.jsxs("p",{className:"flex items-start gap-3 border border-destructive/50 px-4 py-2.5 font-mono text-small text-destructive-text",role:"alert",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("a",{href:ms(R.runId),className:"underline-offset-4 hover:underline",children:R.title}),": your answer wasn't taken. ",R.text]}),t.jsx("button",{type:"button",className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",onClick:()=>k(P=>P.filter(D=>D.runId!==R.runId)),children:"Dismiss"})]},R.runId)),e.length>0&&t.jsx("ul",{className:"grid grid-cols-1 gap-3 xl:grid-cols-2",children:e.map(R=>{var P,D,W;return R.native?t.jsxs("li",{className:"space-y-2 border p-4",children:[t.jsx("a",{href:ms(R.run_id),className:"text-body underline underline-offset-2",children:Sn(R)}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Native sessions cannot receive another message. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(R.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," to continue."]})]},R.run_id):((P=R.pending)==null?void 0:P.kind)==="approval"?t.jsx(D7,{run:R,pending:R.pending,agentName:i(R.agent_id),at:M,onApprove:S},`${R.run_id}:${R.pending.id}`):Hi(R)?t.jsx(F7,{run:R,ask:Hi(R),agentName:i(R.agent_id),at:M,onHandBack:N},`${R.run_id}:${Hi(R).asked_at}`):t.jsx(U7,{run:R,agentName:i(R.agent_id),at:M,onAnswer:c},`${R.run_id}:${((D=R.pending)==null?void 0:D.kind)==="question"?R.pending.asked_at:((W=R.pending)==null?void 0:W.kind)==="budget"?R.pending.at??"":""}`)})}),(h.length>0||v.length>0)&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps flex items-center justify-between gap-3 border-b px-4 py-2.5 text-label text-muted-foreground",children:[t.jsxs("span",{children:["Failed in the last 24 h · ",$]}),t.jsx("a",{href:"#/runs?status=failed",className:"-my-1 py-1 normal-case tracking-normal hover:text-foreground",children:s===void 0?"All failed runs →":`All ${s} failed ${s===1?"run":"runs"} →`})]}),t.jsxs("ul",{children:[h.map(R=>t.jsx(B7,{message:R.message,runs:R.runs,agentName:i,at:M,onRunAgain:f},R.message)),v.map(R=>t.jsx(pN,{run:R,agentName:i(R.agent_id)},R.run_id))]})]}),O.length>0&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Learned, waiting for your OK · ",A]}),t.jsx("ul",{children:O.map(R=>t.jsxs("li",{className:"flex min-w-0 items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:R.name}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-muted-foreground",children:Xv(R.pending)}),t.jsx("a",{href:`#/agents/${encodeURIComponent(R.agent_id)}/learning`,className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",children:"Review →"})]},R.agent_id))})]}),r.length>0&&t.jsxs("div",{className:"border",children:[t.jsxs("p",{className:"caps border-b px-4 py-2.5 text-label text-muted-foreground",children:["Running now · ",r.length]}),t.jsx("ul",{children:r.map(R=>Zn(R)?t.jsx(pN,{run:R,agentName:i(R.agent_id)},R.run_id):t.jsx(G7,{run:R,agentName:i(R.agent_id),at:M,onStop:g},R.run_id))})]})]})}function D7({run:e,pending:n,agentName:s,at:r,onApprove:a}){return t.jsx("li",{"data-run":e.run_id,className:"min-w-0",children:t.jsx(HE,{compact:!0,pending:n,heading:t.jsx(Ry,{run:e,agentName:s,since:`asked ${Nd(n.requested_at,r)} ago`}),onAnswer:(i,c,d)=>a?d?a(e.run_id,n.id,i,c,d):a(e.run_id,n.id,i,c):Promise.resolve("Open the run to answer it.")})})}function F7({run:e,ask:n,agentName:s,at:r,onHandBack:a}){return t.jsx("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5",children:t.jsx(JE,{compact:!0,ask:n,heading:t.jsx(Ry,{run:e,agentName:s,since:`asked ${Nd(n.asked_at,r)} ago`}),open:t.jsx("a",{href:ms(e.run_id),className:"text-body underline underline-offset-2",children:"Open its screen"}),onAnswer:a&&(i=>a(e.run_id,n,i))})})}function U7(e){var n;return((n=e.run.pending)==null?void 0:n.kind)==="budget"?t.jsx(W7,{run:e.run,pending:e.run.pending,agentName:e.agentName}):t.jsx(H7,{...e})}function W7({run:e,pending:n,agentName:s}){return t.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[t.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:s}),t.jsx("a",{href:ms(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:Sn(e)})]}),t.jsx("p",{className:"caps mt-2 text-label text-warning-text",children:BE(n)}),typeof n.said=="string"&&t.jsx("p",{className:"mt-1 text-prose leading-snug",children:n.said}),t.jsx("p",{className:"mt-3 font-mono text-small text-muted-foreground",children:t.jsx("a",{href:ms(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})})]})}function Ry({run:e,agentName:n,since:s}){return t.jsxs("p",{className:"flex min-w-0 items-center gap-2 text-body",children:[t.jsx("span",{className:"size-2 shrink-0 bg-warning","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:n}),t.jsx("a",{href:ms(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:Sn(e)}),s&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-small text-muted-foreground",children:s})]})}function H7({run:e,agentName:n,at:s,onAnswer:r}){var j;const a=((j=e.pending)==null?void 0:j.kind)==="question"?e.pending:null,i=(a==null?void 0:a.question)??"",c=vU(i),[d,u]=p.useState(""),[f,g]=p.useState(!1),[b,x]=p.useState(null),[h,v]=p.useState(null),y=async k=>{k.preventDefault();const E=d.trim();if(!E||f)return;g(!0),x(null);const S=await r(e.run_id,E);g(!1),S?x(S):v(E)};return t.jsxs("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5 p-4",children:[t.jsx(Ry,{run:e,agentName:n,since:a!=null&&a.asked_at?`asked ${Nd(a.asked_at,s)} ago`:void 0}),t.jsx("p",{className:"mt-2 text-base leading-snug",children:i}),h?t.jsxs("p",{className:"mt-3 font-mono text-body text-success-text",children:["Answered: ",h," · ",t.jsx("a",{href:ms(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})]}):t.jsxs("form",{onSubmit:k=>void y(k),className:"mt-3 flex flex-wrap items-center gap-2",children:[c.map(k=>t.jsx("button",{type:"button",onClick:()=>u(k),className:oe("border px-3 py-1.5 text-body hover:border-border-strong",d===k?"border-warning text-warning-text":"border-border"),children:k},k)),t.jsx(ze,{value:d,onChange:k=>u(k.target.value),"aria-label":`Answer ${n}`,placeholder:c.length?"Or type an answer…":"Type an answer…",className:"h-9 min-w-[9rem] flex-1 font-sans text-lead"}),t.jsx(B,{type:"submit",variant:"solid",size:"sm",disabled:f||!d.trim(),children:f?"Sending…":"Send"}),b&&t.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:b})]})]})}function B7({message:e,runs:n,agentName:s,at:r,onRunAgain:a}){const[i,c]=p.useState(!1),[d,u]=p.useState(null),[f,g]=p.useState(new Set),b=n.filter(k=>!f.has(k.run_id)),x=n.length-b.length,h=async()=>{c(!0),u(null);const{started:k,problem:E}=await a(b);c(!1),u(E),g(S=>new Set([...S,...k]))},v=x>0&&t.jsxs("span",{className:"font-mono text-small text-success-text",children:["Started again: ",x===1?"1 run":`${x} runs`]});if(!b.length)return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-border-strong","aria-hidden":!0}),t.jsx("p",{className:"min-w-0 flex-1 truncate font-mono text-small text-muted-foreground",children:e}),v]});const y=b[0],j=b.length===1;return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-destructive","aria-hidden":!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[j?t.jsxs("p",{className:"flex min-w-0 gap-3 text-lead",children:[t.jsx("span",{className:"shrink-0 font-mono text-small leading-5",children:s(y.agent_id)}),t.jsx("a",{href:ms(y.run_id),className:"min-w-0 truncate hover:underline",children:Sn(y)})]}):t.jsxs("p",{className:"text-lead",children:[b.length," runs failed ",t.jsxs("span",{className:"text-muted-foreground",children:["· ",[...new Set(b.map(k=>s(k.agent_id)))].join(", ")]})]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-small text-destructive-text",children:e}),!j&&t.jsxs("details",{className:"mt-1 text-body",children:[t.jsx("summary",{className:"cursor-pointer font-mono text-small text-muted-foreground",children:"The runs"}),t.jsx("ul",{className:"mt-1 space-y-1",children:b.map(k=>t.jsxs("li",{children:[t.jsx("a",{href:ms(k.run_id),className:"hover:underline",children:Sn(k)})," ",t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:["· ",s(k.agent_id)]})]},k.run_id))})]}),d&&t.jsx("p",{className:"mt-1 font-mono text-small text-destructive-text",role:"alert",children:d})]}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",children:[Nd(y.ended_at??y.created_at,r)," ago"]}),v,t.jsx(B,{type:"button",size:"sm",disabled:i,onClick:()=>void h(),children:j?"Run again":"Run all again"})]})}function pN({run:e,agentName:n}){var s;return t.jsxs("li",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 last:border-b-0",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"text-small text-muted-foreground",children:[n," · ",Vo(Zn(e).runtime)]}),t.jsx("a",{href:ms(e.run_id),className:"text-lead hover:underline",children:Sn(e)}),e.status==="failed"&&t.jsx("p",{className:"mt-1 break-words text-small text-destructive-text",children:((s=e.error)==null?void 0:s.message)||"The run failed."}),t.jsxs("p",{className:"mt-1 text-small text-muted-foreground",children:["Control and retries stay in your backend. ",e.status==="failed"?"Start another task in the original application.":"Stop or cancel this task in the original application."]})]}),t.jsx("a",{href:ms(e.run_id),className:"caps shrink-0 text-small text-muted-foreground hover:text-foreground",children:"Open"})]})}function G7({run:e,agentName:n,at:s,onStop:r}){var g;const[a,i]=p.useState(!1),[c,d]=p.useState(null),u=(g=e.cost)==null?void 0:g.usd,f=ad(e.cost)?`${eo(e.cost)} so far`:u===0?"nothing spent yet":typeof u=="number"?`${eo(e.cost)} so far`:jl(e.cost)?eo(e.cost):"cost not known yet";return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-b px-4 py-3 last:border-b-0",children:[t.jsx("span",{className:"size-2 shrink-0 bg-run-active ring-4 ring-run-active/[0.18]","aria-hidden":!0}),t.jsx("span",{className:"shrink-0 font-mono text-small",children:n}),t.jsx("a",{href:ms(e.run_id),className:"min-w-0 flex-1 truncate text-lead hover:underline",children:Sn(e)}),t.jsxs("span",{className:"font-mono text-body text-run-active",children:["working · ",dl(s-Date.parse(e.created_at))]}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:f}),!e.native&&t.jsx("a",{href:ms(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Steer"}),Lm(e.status,e.state,e.kind,Pm,!0,e.error,e.review).canStop?t.jsx(B,{type:"button",size:"sm",disabled:a,onClick:async()=>{i(!0),d(await r(e.run_id)),i(!1)},children:"Stop"}):t.jsx("a",{href:ms(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Open to cancel"}),c&&t.jsx("p",{className:"w-full font-mono text-small text-destructive-text",role:"alert",children:c})]})}const q7=[{id:"hello",name:"Hello, AgentRun",shows:"Writes a file, then answers",description:"A first agent: writes hello.md and answers in one line.",instructions:"You are a friendly first agent on this machine. Do what the person asks, briefly and plainly.",tools:["write"],input:"Write hello.md listing three things you could help me with on this machine, then answer in one line."},{id:"web",name:"Summarize a web page",shows:"Reads the web, then sums it up",description:"Reads a public web page and sums it up in three bullets.",instructions:"Read the page you are given and summarize it in three short bullets, then name the one thing worth remembering.",tools:["web_fetch"],input:"Summarize https://en.wikipedia.org/wiki/Hacker_News in three bullets."},{id:"plan",name:"Plan a task",shows:"Thinks it through, no tools",description:"Turns a goal into steps, risks and a first move.",instructions:"Turn the goal you are given into a short plan: the steps in order, the main risks, and what to do first. Keep it to one screen.",tools:[],input:"Plan a weekend launch of a small side project: the steps, the risks, and what to do first."}];function h$(e){var r;const n=["pi","claude-agent","codex"],s=e.filter(a=>a.available&&a.default_model);return s.sort((a,i)=>(n.indexOf(a.id)+1||99)-(n.indexOf(i.id)+1||99)),((r=s[0])==null?void 0:r.id)??null}function K7(e,n,s){const r=Im(n,[...s]).filter(i=>i.available).map(i=>i.name),a=e.tools.find(i=>!r.includes(i));return a?{ok:!1,reason:`${a} can't run on this server yet`}:{ok:!0}}async function V7(e,n,s,r=dr()){const i=(await qr(f=>e.listAgents({cursor:f}),f=>f.agents)).find(f=>f.definition.name===n.name&&!f.archived_at),c=(i==null?void 0:i.agent_id)??(await e.createAgent({definition:{version:1,name:n.name,description:n.description,instructions:n.instructions,harness:s,tools:n.tools,skills:[]}})).agent_id,d={input:{content:n.input}},{run:u}=await e.startRun(c,d,r.keyFor(n.name,d));return r.done(),u.run_id}const p$="agentrun.console.start-here.dismissed",Y7={hello:Ka,web:$N,plan:kT};function Q7(){try{return localStorage.getItem(p$)==="true"}catch{return!1}}function J7({harnesses:e,tools:n,onTry:s,imported:r=0,keySettings:a=!1,importAction:i,modelSetup:c}){const[d,u]=p.useState(Q7),[f,g]=p.useState(!1),[b,x]=p.useState(!1),[h,v]=p.useState(null),[y,j]=p.useState(null),k=h$(e),E=async S=>{v(S.id),j(null);try{j(await s(S))}finally{v(null)}};return d?null:t.jsxs("section",{"aria-label":"Start here",className:"border bg-card p-5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-base font-semibold",children:"Bring your agents into view"}),t.jsx("p",{className:"mt-1 text-lead text-muted-foreground",children:"Connect your Claude Code or Codex setup on this server or another machine. Your coding agent helps choose a live connection or a history import. No model key needed to connect."}),r>0&&t.jsxs("p",{className:"mt-2 text-body text-muted-foreground",children:[r," imported ",r===1?"session":"sessions"," · ",t.jsx("a",{href:"#/runs",className:"text-primary-text underline-offset-4 hover:underline",children:"Browse history"})]})]}),t.jsx("button",{type:"button","aria-label":"Dismiss introduction",className:"shrink-0 p-1 text-muted-foreground hover:bg-accent hover:text-foreground",onClick:()=>{u(!0);try{localStorage.setItem(p$,"true")}catch{}},children:t.jsx(Jo,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[t.jsx(Km,{}),i,t.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-body text-muted-foreground hover:text-foreground","aria-expanded":f,onClick:()=>{x(!0),g(S=>!S)},children:["Run an agent here ",t.jsx(Rr,{className:`size-3.5 transition-transform ${f?"rotate-180":""}`,"aria-hidden":!0})]})]}),b&&t.jsxs("div",{hidden:!f,className:"mt-4 border-t pt-4",children:[c,k?t.jsx("ul",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:q7.map(S=>{const N=K7(S,k,n),_=Y7[S.id]??Ka;return t.jsxs("li",{className:"flex flex-col border bg-background p-4",children:[t.jsxs("p",{className:"flex items-center gap-2 text-prose font-semibold",children:[t.jsx(_,{className:"size-4 text-primary-text","aria-hidden":!0}),S.name]}),t.jsx("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:S.shows}),t.jsx("p",{className:"mt-2 flex-1 text-lead leading-relaxed text-muted-foreground",children:S.description}),N.ok?t.jsx(B,{type:"button",variant:S.id==="hello"?"solid":"outline",size:"sm",className:"mt-4 self-start",disabled:h!==null,onClick:()=>void E(S),children:h===S.id?"Starting…":"Try it"}):t.jsx("p",{className:"mt-4 font-mono text-small text-muted-foreground",children:N.reason})]},S.id)})}):!c&&t.jsxs("p",{className:"text-lead text-muted-foreground",children:["Running agents here needs a configured model. ",a?t.jsx("a",{href:"#/settings/keys",className:"text-primary-text underline-offset-4 hover:underline",children:"Set up models in Settings"}):"Configure a model where this server runs, then return here."]}),t.jsxs("p",{className:"mt-3 text-body text-muted-foreground",children:["Or ",t.jsx("a",{href:"#/agents/new",className:"text-primary-text underline-offset-4 hover:underline",children:"Create your own"}),": name it, say what it does, pick its tools."]}),y&&t.jsx("p",{className:"mt-3 font-mono text-body text-destructive-text",role:"alert",children:y})]})]})}const X7=["system","light","dark"],Ox="agentrun.theme",Z7="(prefers-color-scheme: dark)",oh=()=>{try{return globalThis.localStorage??null}catch{return null}},g$=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(Z7):null;let Mx=null;function eB(e=oh()){try{const n=e==null?void 0:e.getItem(Ox);return n==="light"||n==="dark"?n:"system"}catch{return"system"}}const Px=(e=oh())=>Mx??eB(e);function tB(e,n=oh()){Mx=null;try{e==="system"?n==null||n.removeItem(Ox):n==null||n.setItem(Ox,e)}catch{Mx=e}}function Lx(e,n=document.documentElement,s=g$()){const r=e==="dark"||e==="system"&&!!(s!=null&&s.matches);n.classList.toggle("dark",r),n.classList.toggle("light",!r)}function nB(e=document.documentElement,n=g$(),s=oh()){Lx(Px(s),e,n);const r=()=>{Px(s)==="system"&&Lx("system",e,n)};return n==null||n.addEventListener("change",r),()=>n==null?void 0:n.removeEventListener("change",r)}const sB={mission:"Mission Control",playground:"Playground",agents:"Agents",runs:"Runs",dojo:"Dojo",templates:"Templates",triggers:"Triggers",settings:"Settings"},rB={mission:"#/",playground:"#/playground",agents:"#/agents",runs:"#/runs",dojo:"#/dojo",templates:"#/templates",triggers:"#/triggers",settings:"#/settings/keys"},oB={system:["System",Va],light:["Light",DT],dark:["Dark",RT]};function aB(){const[e,n]=p.useState(()=>Px()),s=r=>{tB(r),Lx(r),n(r)};return t.jsx("div",{role:"group","aria-label":"Theme",className:"flex gap-1 border p-1",children:X7.map(r=>{const[a,i]=oB[r];return t.jsx(B,{variant:"ghost",size:"sm","aria-label":a,title:a,"aria-pressed":e===r,onClick:()=>s(r),className:oe("flex flex-1 items-center justify-center py-1.5 text-muted-foreground hover:bg-accent hover:text-foreground",e===r&&"bg-accent text-foreground"),children:t.jsx(i,{className:"size-4","aria-hidden":!0})},r)})})}function gN(){return t.jsxs("span",{className:"inline-flex items-center whitespace-nowrap text-lg font-semibold font-mono","aria-label":"AgentRun",children:[t.jsx("svg",{viewBox:"0 0 64 64",className:"mr-1 size-4 text-primary-text","aria-hidden":!0,children:t.jsx("path",{d:"M18 12L42 32L18 52",fill:"none",stroke:"currentColor",strokeWidth:"8",strokeLinecap:"square",strokeLinejoin:"miter"})}),"agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})}function iB({active:e,settings:n=!1,triggers:s=!1,banners:r,building:a=!1,onBuild:i,onNavigate:c,onSignOut:d,onSignOutEverywhere:u,children:f}){const[g,b]=p.useState(!1),[x,h]=p.useState(!1),v=p.useRef(null),y=p.useRef(null),j=p.useRef(!1);p.useEffect(()=>{var L,M;x?(L=y.current)==null||L.focus():j.current&&((M=v.current)==null||M.focus())},[x]);const k=()=>{j.current=!0,h(!1)},[E,S]=p.useState(!0),N=e==="agents"||e==="runs"||e==="templates";p.useEffect(()=>{(N||a)&&S(!0)},[e,a]);const _=L=>{c?c(L):location.hash=rB[L],b(!1)},$=()=>{i?i():location.hash="#/agents/new",b(!1)},O=sB[e];p.useEffect(()=>{document.title=O?`${O} · AgentRun`:"AgentRun"},[O]);const A=p.useRef(null);return t.jsxs("div",{className:"relative flex h-dvh min-h-0 flex-col overflow-hidden bg-background text-foreground roomy:flex-row",children:[t.jsx(B,{type:"button",size:"sm",onClick:()=>{var L;return(L=A.current)==null?void 0:L.focus()},className:"sr-only focus-visible:not-sr-only focus-visible:absolute focus-visible:left-2 focus-visible:top-2 focus-visible:z-toast focus-visible:inline-flex focus-visible:bg-card focus-visible:px-3",children:"Skip to the page"}),t.jsxs("header",{className:"flex h-12 shrink-0 items-center justify-between border-b px-4 roomy:hidden",children:[t.jsx("button",{type:"button",onClick:()=>_("mission"),"aria-label":"AgentRun home",children:t.jsx(gN,{})}),t.jsx(B,{size:"icon","aria-label":"Navigation","aria-expanded":g,onClick:()=>b(L=>!L),children:t.jsx($T,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("aside",{className:oe("shrink-0 flex-col border-r bg-background roomy:flex roomy:h-dvh roomy:overflow-y-auto roomy:w-sidebar",g?"flex max-h-[60dvh] overflow-y-auto border-b roomy:max-h-none":"hidden"),children:[t.jsx("div",{className:"hidden h-12 shrink-0 items-center border-b px-4 roomy:flex",children:t.jsx("button",{type:"button",onClick:()=>_("mission"),"aria-label":"AgentRun home",children:t.jsx(gN,{})})}),t.jsxs("nav",{"aria-label":"Navigation",className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-3 pt-3",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsxs(xr,{className:"w-full",active:e==="mission",onClick:()=>_("mission"),children:[t.jsx(jT,{className:"size-4 shrink-0","aria-hidden":!0}),"Mission Control"]}),t.jsxs(xr,{className:"w-full",active:e==="playground",onClick:()=>_("playground"),children:[t.jsx(am,{className:"size-4 shrink-0","aria-hidden":!0}),"API playground"]}),t.jsxs("div",{children:[t.jsxs(xr,{className:oe("w-full",N&&"text-primary-text"),"aria-expanded":E,"aria-controls":"agent-navigation",onClick:()=>S(L=>!L),children:[t.jsx(xf,{className:"size-4 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"flex-1",children:"Agents"}),t.jsx(Rr,{className:oe("size-3.5 transition-transform",!E&&"-rotate-90"),"aria-hidden":!0})]}),t.jsxs("div",{id:"agent-navigation",hidden:!E,className:"space-y-0.5",children:[t.jsxs(xr,{className:"w-full pl-8",active:a,onClick:$,children:[t.jsx(yT,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Build"]}),t.jsxs(xr,{className:"w-full pl-8",active:e==="agents"&&!a,onClick:()=>_("agents"),children:[t.jsx(xf,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Connected agents"]}),t.jsxs(xr,{className:"w-full pl-8",active:e==="templates",onClick:()=>_("templates"),children:[t.jsx(Ux,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Templates"]}),t.jsxs(xr,{className:"w-full pl-8",active:e==="runs",onClick:()=>_("runs"),children:[t.jsx(Jc,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Runs"]})]})]}),s&&t.jsxs(xr,{className:"w-full",active:e==="triggers",onClick:()=>_("triggers"),children:[t.jsx(om,{className:"size-4 shrink-0","aria-hidden":!0}),"Triggers"]}),t.jsxs(xr,{className:"w-full",active:e==="dojo",onClick:()=>_("dojo"),children:[t.jsx(CC,{size:16,className:"shrink-0"}),"Learning Dojo"]})]}),n&&t.jsx("div",{"data-sidebar-account":!0,className:"mt-auto border-t pb-2 pt-3",children:t.jsxs(xr,{className:"w-full",active:e==="settings",onClick:()=>_("settings"),children:[t.jsx(TN,{className:"size-4 shrink-0","aria-hidden":!0}),"Settings"]})})]}),t.jsxs("div",{className:"shrink-0 space-y-2 px-3 pb-4 pt-3",children:[t.jsx(aB,{}),t.jsxs(B,{onClick:d,className:"w-full justify-start",children:[t.jsx(ST,{"aria-hidden":!0}),"Sign out"]}),u&&(x?t.jsxs("div",{role:"alertdialog","aria-label":"Sign out everywhere?",onKeyDown:L=>{L.key==="Escape"&&k()},className:"mt-2 space-y-2 border border-destructive/50 px-3 py-2.5 text-small",children:[t.jsx("p",{children:"Signs out every browser and phone signed in to this server, this one too."}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(B,{size:"xs",variant:"destructive",onClick:()=>{h(!1),u()},children:"Sign out everywhere"}),t.jsx(B,{size:"xs",ref:y,onClick:k,children:"Cancel"})]})]}):t.jsx(B,{size:"sm",variant:"ghost",ref:v,onClick:()=>h(!0),className:"mt-1 w-full justify-start text-muted-foreground hover:text-foreground",children:"Sign out everywhere"}))]})]}),t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t.jsx(MU,{}),r,t.jsx("main",{ref:A,tabIndex:-1,className:"relative min-h-0 min-w-0 flex-1 overflow-auto outline-none",children:f})]})]})}const Cg={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},xN={sign_in:{title:"Sign in",body:"Sign in to make agents, start runs and follow them on this server."},setup:{title:"Start building",body:"This is the server's first visit: set the owner's password. You sign in with it from now on."},token_link:{title:"Open the server's link",body:"This server has no accounts. Open the link it printed when it started: it signs this browser in, and its code leaves the address."}};function lB({mode:e,code:n=null,codeNeeded:s=!1,onSubmit:r,problem:a=null,offer:i=null}){const[c,d]=p.useState(""),[u,f]=p.useState(!1),[g,b]=p.useState(""),[x,h]=p.useState(n??"");p.useEffect(()=>{n!==null&&h(n)},[n]);const[v,y]=p.useState(a),[j,k]=p.useState(!1),E=e==="setup",S=E&&i!==null&&!("sessions"in i&&i.sessions===0),N=E&&(s||n!==null),_=e!=="token_link"&&c.length>0&&(!E||c===g&&c.length>=12)&&(!N||x.trim()!==""),$=async()=>{if(!_||!r)return;k(!0);const O=await r(c,N&&x.trim()?x.trim():void 0,E&&S&&u);k(!1),y(O)};return t.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:t.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[t.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[t.jsx(Cs,{className:"size-5 text-primary-text","aria-hidden":!0}),t.jsxs("span",{children:["agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl font-semibold",children:xN[e].title}),t.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:xN[e].body}),e!=="token_link"&&t.jsxs("form",{className:"space-y-5",onSubmit:O=>{O.preventDefault(),$()},children:[N&&t.jsx(jt,{label:"Setup code",id:"setup-code",hint:"On Render: paste the server's AGENTRUN_TOKEN from the service's Environment tab. Elsewhere: paste the setup code the server printed in its log, or open the link it prints.",children:t.jsx(ze,{name:"setup-code",value:x,onChange:O=>h(O.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),t.jsx(jt,{label:Cg[e].label,note:E?"12 characters or more.":void 0,children:t.jsxs("span",{className:oe(Fc,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Pa,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(ze,{bare:!0,type:"password",value:c,onChange:O=>d(O.target.value),autoComplete:Cg[e].autocomplete,autoFocus:!0,"aria-label":Cg[e].label,className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),E&&t.jsx(jt,{label:"Again",note:g&&g!==c?"The two passwords differ.":void 0,children:t.jsxs("span",{className:oe(Fc,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Pa,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(ze,{bare:!0,type:"password",value:g,onChange:O=>b(O.target.value),autoComplete:"new-password","aria-label":"Password again",className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),S&&t.jsxs("label",{className:"flex items-start gap-3 text-lead",children:[t.jsx("input",{type:"checkbox",name:"import",checked:u,onChange:O=>f(O.target.checked),className:"mt-1 size-4 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"block",children:"Import this machine's Claude Code, Codex and pi sessions"}),t.jsx("span",{className:"mt-1 block text-small text-muted-foreground","aria-live":"polite",children:cB(i)})]})]}),t.jsx(B,{type:"submit",variant:"solid",disabled:!_||j,"aria-busy":j||void 0,className:"w-full text-body",children:j?"Signing in":E?"Set password and continue":"Continue"}),v&&t.jsx("p",{className:"font-mono text-body text-destructive-text",role:"alert",children:v}),!E&&t.jsxs("p",{className:"text-small leading-relaxed text-muted-foreground",children:["Forgot it? Where the server runs: ",t.jsx("code",{className:"font-mono text-foreground",children:"npx @parcha/agentrun reset-password"})," (add"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data DIR"})," if you started it with one). For a server you started yourself:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"agentrun-serve reset-password --data DIR"})," (in the image:"," ",t.jsx("code",{className:"font-mono text-foreground",children:"--data /data"}),"). The next visit here sets a new one."]})]})]})})}const vN=(e,n)=>`${e.toLocaleString("en-US")} ${n}${e===1?"":"s"}`,Eg="Each project becomes an agent, each session a run you can read.";function cB(e){return"counting"in e?`Counting sessions… ${Eg}`:e.sessions===null||e.projects===null?`The count isn't known. ${Eg}`:`${vN(e.sessions,"session")} in ${vN(e.projects,"project")}. ${Eg}`}function dB({problem:e,starting:n=!1,onRetry:s}){return t.jsx("main",{className:"grid min-h-dvh place-items-center bg-background p-6 text-foreground",children:t.jsxs("div",{className:"w-full max-w-[440px] border bg-card p-8",children:[t.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-figure font-semibold","aria-label":"AgentRun",children:[t.jsx(Cs,{className:"size-5 text-primary-text","aria-hidden":!0}),t.jsxs("span",{children:["agent",t.jsx("span",{className:"text-primary-text",children:".run()"})]})]}),t.jsx("h1",{className:"mb-3 mt-8 text-2xl font-semibold",children:n?"This server is starting":"Can't read this server's sign-in"}),t.jsx("p",{className:"mb-4 text-prose leading-relaxed text-muted-foreground",children:n?"Its address answers for it until it is up (a first start, a redeploy or a wake can take a minute or two). Trying again…":"The page asked the server whether it has its owner yet, and got no answer it could read, so it can't show setup or sign-in. It asks again on its own."}),t.jsx("p",{className:"mb-6 break-words font-mono text-body text-destructive-text",role:"alert",children:e}),t.jsx(B,{type:"button",variant:"solid",onClick:s,className:"w-full text-body",children:"Retry now"})]})})}const x$=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.accounts)===!1};function uB(e,n){if(x$(e))return n===200?"signed_in":"token_link";const s=e.body??{};return s.signed_in?"signed_in":s.password_set?"sign_in":"setup"}const fB=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.setup_code)===!0};function mB(e){var n,s;if(e.status===401)return"That is not the password.";if(e.status===429){const r=e.retryAfterMs===void 0?60:Math.max(1,Math.ceil(e.retryAfterMs/1e3));return`Too many sign-ins. Try again in ${r===1?"a second":r>=60?"a minute":`${r} seconds`}.`}return e.status===403&&/has its owner/.test(e.message)?"This server has its owner already: sign in.":e.status===403&&/a new one is in the server's log/.test(e.message)?"That setup code expired or was voided after too many wrong tries: a new one is in the server's log (on Render, the Logs tab).":e.status===403&&/takes the setup code/.test(e.message)?"Enter the setup code from the server's log.":e.status===403&&/setup code/.test(e.message)?"That setup code was refused: open the newest setup link in the server's log, or paste the server's token (AGENTRUN_TOKEN) here.":((s=(n=e.fields)==null?void 0:n[0])==null?void 0:s.message)??e.message}function v$(e){const n=new URLSearchParams(e.startsWith("#")?e.slice(1):e),s=n.get("code");if(s===null)return{code:null,rest:e};n.delete("code");const r=n.toString();return{code:/^[A-Za-z0-9_-]*/.exec(s)[0],rest:r?`#${r}`:""}}const hB=1e4;function yN(e=location.hash){if(e==="#/dojo")return{section:"dojo"};const n=e.match(/^#\/observations\/([^/?]+)$/);if(n)return{section:"agents",observation:decodeURIComponent(n[1])};let s=e.match(/^#\/runs\/([^/?]+)$/);if(s)return{section:"runs",run:decodeURIComponent(s[1])};if(e==="#/agents/connect"||e.startsWith("#/agents/connect?")){const c=new URLSearchParams(e.split("?")[1]??"").get("source");return{section:"agents",nativeConnect:!0,...c==="remote"||c==="observe"?{connectionSource:c}:{}}}if(e==="#/agents/new")return{section:"agents",agent:null};if(s=e.match(/^#\/agents\/([^/?]+)\/learning\?(.*)$/),s)return{section:"agents",agent:decodeURIComponent(s[1]),tab:"learning",notes:new URLSearchParams(s[2]).getAll("note")};if(s=e.match(/^#\/agents\/([^/?]+)\/edit\?(.*)$/),s){const c=new URLSearchParams(s[2]).get("tool");return{section:"agents",agent:decodeURIComponent(s[1]),edit:!0,...c?{tool:c}:{}}}if(s=e.match(/^#\/agents\/([^/?]+)(?:\/([a-z]+))?$/),s)return{section:"agents",agent:decodeURIComponent(s[1]),...s[2]==="edit"?{edit:!0}:s[2]?{tab:s[2]}:{}};if(e.startsWith("#/agents"))return{section:"agents",archived:/[?&]archived=true\b/.test(e)};if(e.startsWith("#/playground")){const c=new URLSearchParams(e.split("?")[1]??""),d=c.get("agent"),u=c.get("operation"),f=c.get("draft");if(u==="apply-template"){const g=c.get("template");return{section:"playground",operation:u,...g?{template:g}:{},...f!==null?{draft:f}:{}}}return{section:"playground",...d?{playgroundAgent:d}:{},...u==="create-agent"||u==="edit-agent"||u==="list-runs"?{operation:u}:{},...f!==null?{draft:f}:{},...u==="list-runs"&&Zf.includes(c.get("status"))?{status:c.get("status")}:{},...u==="list-runs"&&c.get("archived")==="true"?{archived:!0}:{}}}if(s=e.match(/^#\/templates\/install\?(.*)$/),s)return{section:"templates",install:new URLSearchParams(s[1]).get("src")??""};if(s=e.match(/^#\/templates\/([^/?]+)$/),s)return{section:"templates",template:decodeURIComponent(s[1])};if(e.startsWith("#/templates"))return{section:"templates"};if(e==="#/triggers/new")return{section:"triggers",trigger:null,kind:"schedule"};if(e==="#/triggers/new-webhook")return{section:"triggers",trigger:null,kind:"webhook"};if(e==="#/triggers/new-github")return{section:"triggers",trigger:null,kind:"github"};if(e==="#/triggers/new-composio")return{section:"triggers",trigger:null,kind:"composio"};if(s=e.match(/^#\/triggers\/([^/?]+)(\/edit)?$/),s)return{section:"triggers",trigger:decodeURIComponent(s[1]),...s[2]?{edit:!0}:{}};if(e.startsWith("#/triggers"))return{section:"triggers"};if(s=e.match(/^#\/settings\/mcp(?:\?(.*))?$/),s){const c=sI(s[1]);return{section:"settings",settings:"mcp",signIn:cI(s[1]),...c?{add:c}:{}}}if(s=e.match(/^#\/settings\/github(?:\?(.*))?$/),s){const c=zU(s[1]);return{section:"settings",settings:"github",...c?{github:c}:{}}}if(s=e.match(/^#\/settings(?:\/(keys|tools|email|computers|workspace|webhook))?$/),s)return{section:"settings",settings:s[1]??"keys"};if(e===""||e==="#"||e==="#/"||e.startsWith("#/start")||e.startsWith("#/mission"))return{section:"mission"};if(!e.startsWith("#/runs?"))return{section:"runs"};const r=new URLSearchParams(e.slice(7)),a=r.get("agent"),i=r.get("status");return{section:"runs",...a?{runsOf:a}:{},...i&&Zf.includes(i)?{status:i}:{},...r.get("archived")==="true"?{archived:!0}:{}}}function pB({runsOf:e,status:n,archived:s}){const r=new URLSearchParams;return e&&r.set("agent",e),n&&r.set("status",n),s&&r.set("archived","true"),`#/runs${r.size?`?${r}`:""}`}let $g;function gB(){if(!$g){const{code:e,rest:n}=v$(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${n}`),$g={code:e}}return $g.code}const xB=e=>Math.min(1e3*2**e,3e4),y$=1e3,vB=30;function yB(e){return e.state==="running"?"Importing this machine's sessions: agents appear as they arrive.":e.state==="stopped"?"The import of this machine's sessions stopped. It goes on when the server starts again.":`Imported ${`${e.runs.toLocaleString("en-US")} session${e.runs===1?"":"s"}`} into ${e.agents.toLocaleString("en-US")} agent${e.agents===1?"":"s"}${e.skipped?`; ${e.skipped.toLocaleString("en-US")} left out`:""}.`}function bB(){const[e]=p.useState(KM),[n,s]=p.useState(null),[r,a]=p.useState(!1),i=p.useRef(null);i.current=n;const c=p.useRef(!1),d=p.useRef(async()=>{}),u=p.useMemo(()=>MM({fetch:e.fetch,onSignedOut:()=>void d.current()}),[e]),[f,g]=p.useState(gB);p.useEffect(()=>{if(n!=="setup")return;const $=()=>{const{code:O,rest:A}=v$(location.hash);O!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${A}`),g(O))};return window.addEventListener("hashchange",$),$(),()=>window.removeEventListener("hashchange",$)},[n]);const[b,x]=p.useState(!1),h=async()=>{const $=await u.session(),O=x$($)?await u.listAgents().then(()=>200,A=>A instanceof De?A.status:0):void 0;return{mode:uB($,O),codeNeeded:fB($)}},v=async()=>{const $=await h();return x($.codeNeeded),$.mode},y=async()=>s(await v());d.current=async()=>{if(!(i.current!=="signed_in"||c.current)){c.current=!0;try{const $=await v();$!=="signed_in"&&i.current==="signed_in"&&(a(!0),s($))}catch{}finally{c.current=!1}}};const[j,k]=p.useState(null),[E,S]=p.useState(0);p.useEffect(()=>{let $=!0,O;return h().then(A=>{!$||i.current!==null||(x(A.codeNeeded),s(A.mode),k(null))},A=>{if(!$||i.current!==null)return;const L=xB(E),M=A instanceof De?A:null,R=(M==null?void 0:M.code)==="http_error",P=R&&[502,503,504].includes(M.status);k({problem:M===null?Ft(A):P?`Its address answered ${M.status}, not the server.`:`GET /v2/auth/session answered ${M.status}${R?", not as this server answers":`: ${M.message}`}`,starting:P}),O=setTimeout(()=>S(D=>D+1),L)}),()=>{$=!1,clearTimeout(O)}},[u,E]);const[N,_]=p.useState(null);return p.useEffect(()=>{if(n!=="setup")return;let $=!0;return(async()=>{for(let O=!1;$;){const A=await u.setupImport().then(L=>L,()=>{});if(!$)return;if(A===void 0&&O)return void _({projects:null,sessions:null});if(A!==void 0&&(!A||!("counting"in A||"sessions"in A)||(_(A),O=!0,!("counting"in A))))return;await new Promise(L=>setTimeout(L,y$))}})(),()=>{$=!1}},[u,n]),n===null&&j!==null?t.jsx(dB,{problem:j.problem,starting:j.starting,onRetry:()=>S($=>$+1)}):n===null?t.jsx(I0,{connection:e,children:t.jsx(wB,{})}):n!=="signed_in"?t.jsx(lB,{mode:n,code:f,codeNeeded:b,offer:N,problem:r&&n==="sign_in"?"You were signed out. Sign in to go on.":null,onSubmit:async($,O,A)=>{try{return await(n==="setup"?u.setup($,O,A):u.signIn($)),a(!1),s("signed_in"),null}catch(L){return L instanceof De&&L.status===403&&n==="setup"&&await y().catch(()=>{}),L instanceof De?mB(L):L instanceof Error?L.message:String(L)}}},n):t.jsx(I0,{connection:e,children:t.jsx(jB,{v2:u,onSignedOut:()=>{a(!1),s("sign_in")}})})}function wB(){return jy().state==="offline"?t.jsx(PU,{}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function jB(e){const n=p.useMemo(bd,[e.v2]);return t.jsx(kB,{...e},n)}function kB({v2:e,onSignedOut:n}){var ra,xs,Cd,ss,Ed,$d,_d,oa,aa,lo,ia,Td,Rd,ri,Cl,oi,co,Ad,ai,Ct,El,$l,ii,_l,Tl,Rl,li,la,Qs,Js,Xs;const{writable:s,whyNot:r}=XF(e),[a,i]=p.useState(null),[c,d]=p.useState(()=>yN()),[u,f]=p.useState(null),g=((xs=(ra=u==null?void 0:u.features)==null?void 0:ra.triggers)==null?void 0:xs.routes)===!0,[b,x]=p.useState(new Map);p.useEffect(()=>{if(!g)return;let pe=!0;return e.listTriggers().then(Te=>{pe&&x(new Map(Te.triggers.map(Ie=>[Ie.id,{name:Ie.name,kind:Ie.source.kind}])))},()=>{}),()=>{pe=!1}},[e,g,c.section,c.trigger]);const[h,v]=p.useState(null),[y,j]=p.useState(null),[k,E]=p.useState(0),[S,N]=p.useState("30d"),_=S==="7d"?7:30,$=kv(e,{active:c.section==="mission"||c.section==="runs"&&!c.run&&!c.runsOf&&!c.archived&&!c.status,days:_}),[O,A]=p.useState(null),[L,M]=p.useState(!1),R=p.useRef(!1),[P,D]=p.useState(null),[W,Y]=p.useState(null),[H,q]=p.useState(null),[F,G]=p.useState(0),U=p.useRef(null),[z,Q]=p.useState(!1),[K,Z]=p.useState(!1),[de,se]=p.useState(!1),[ue,xe]=p.useState(null),[$e,ge]=p.useState(null),[fe,me]=p.useState(!1),[je,Me]=p.useState({}),[_e,re]=p.useState(!1),Re=p.useRef(0),[Ze,at]=p.useState([]),pt=p.useRef(-1),[Ee,Je]=p.useState(null),[he,Fe]=p.useState(0),ut=p.useRef(0),Pe=pe=>{Yu(pe)||(location.hash=pe)},[ct,_t]=p.useState(null),[tt,ft]=p.useState(0);p.useEffect(()=>{let pe=!0;return(async()=>{let Te=!1;for(let Ie=0;pe&&Ie<vB;){const Et=await e.setupImport().then(wt=>wt,()=>{});if(!pe)return;if(Et===void 0)Ie+=1;else{if(Ie=0,!Et||!("state"in Et))return;if(_t(Et),Et.state!=="running")return void(Te&&ft(wt=>wt+1));Te=!0}await new Promise(wt=>setTimeout(wt,y$))}})(),()=>{pe=!1}},[e]),p.useEffect(()=>{const pe=()=>{const Te=WW();Yu(location.hash,()=>{Te&&history.go(-Te)})?Te&&history.go(Te):d(yN())};return window.addEventListener("hashchange",pe),()=>window.removeEventListener("hashchange",pe)},[]),p.useEffect(()=>UW(),[]);const qt=p.useRef(0),zt=p.useRef(!1),ye=()=>{const pe=++qt.current;return e.capabilities().then(Te=>(pe===qt.current&&f(Te),!0),()=>!1)};p.useEffect(()=>{ye()},[e]),p.useEffect(()=>{if(Re.current&&c.section!=="runs"&&c.section!=="mission"&&pt.current===tt)return;pt.current=tt;const pe=++Re.current;re(!1),Promise.allSettled([!1,!0].map(Te=>qr(Ie=>e.listAgents({archived:Te,cursor:Ie}),Ie=>Ie.agents))).then(Te=>{if(pe!==Re.current)return;const Ie=Object.fromEntries(Te.flatMap(wt=>wt.status==="fulfilled"?wt.value:[]).map(wt=>[wt.agent_id,wt.definition.name??wt.agent_id])),Et=Te.every(wt=>wt.status==="fulfilled");Me(wt=>Et?Ie:{...wt,...Ie}),re(Et)})},[e,c,tt]);const le={status:c.status,archived:c.archived};p.useEffect(()=>{if(c.section!=="runs"||c.run)return;const pe=++ut.current;xe(null),Je(null),(c.runsOf?e.listAgentRuns(c.runsOf,50,null,le):e.listRuns(50,null,le)).then(Te=>{pe===ut.current&&(xe(Te.runs),ge(Te.next_cursor))}).catch(Te=>{pe===ut.current&&Je(Ut(Te,"the runs"))})},[e,c,tt,he]);const Ue=pe=>{var Te;return je[pe]??((Te=ot==null?void 0:ot.find(Ie=>Ie.agent_id===pe))==null?void 0:Te.definition.name)??(_e?pe:"")},Xe=u,rt={harnesses:(Xe==null?void 0:Xe.harnesses)??[],tools:YP(Xe==null?void 0:Xe.tools),thinking:((Cd=Xe==null?void 0:Xe.features)==null?void 0:Cd.thinking)??[],...typeof((ss=u==null?void 0:u.limits)==null?void 0:ss.free_model_requests)=="number"?{freeRequests:u.limits.free_model_requests}:{}},J=CD(Xe==null?void 0:Xe.tools),ve=$D(Xe==null?void 0:Xe.tools),We=[...($d=(Ed=u==null?void 0:u.features)==null?void 0:Ed.tool_keys)!=null&&$d.routes?["keys"]:[],...J.length||ve.length?["tools"]:[],"mcp","github","email","computers","workspace",...(oa=(_d=u==null?void 0:u.features)==null?void 0:_d.webhooks)!=null&&oa.routes?["webhook"]:[]],Se=pe=>Pe({runs:"#/runs",agents:"#/agents",playground:"#/playground",dojo:"#/dojo",mission:"#/",triggers:"#/triggers",templates:"#/templates",settings:`#/settings/${We[0]??"keys"}`}[pe]),Ye=p.useRef(dr()).current,Nt=async pe=>{const Te=h$(rt.harnesses);if(!Te)return"This server has no model to run it on yet.";try{const Ie=await V7(e,pe,Te,Ye);return Pe(`#/runs/${encodeURIComponent(Ie)}`),null}catch(Ie){return Ft(Ie)}},It=((h==null?void 0:h.analytics.by_source)??[]).filter(pe=>pe.source!=="live").reduce((pe,Te)=>pe+Te.runs,0),[ot,Rn]=p.useState(null),[hs,Ys]=p.useState([]),[En,Un]=p.useState(null),ps=p.useRef(En);ps.current=En;const[gs,fn]=p.useState(null),[Wn,$s]=p.useState(0),Hn=p.useRef(0);p.useEffect(()=>{Rn(null),fn(null),Un(null),ps.current=null},[e,c.section,c.operation,c.playgroundAgent]),p.useEffect(()=>{if(c.section!=="playground"||c.operation)return;fn(null);const pe=++Hn.current;return qr(Te=>e.listAgents({cursor:Te}),Te=>Te.agents).then(Te=>{var wt;if(pe!==Hn.current)return;const Ie=Te.filter(rs=>!rs.archived_at),Et=ps.current??c.playgroundAgent;if(Et&&!Ie.some(rs=>rs.agent_id===Et)){Rn(null),Un(null),fn("The selected agent is unavailable or archived. Choose another agent from Agents.");return}Rn(Te),Un(Et??((wt=Ie[0])==null?void 0:wt.agent_id)??null)}).catch(Te=>{if(pe===Hn.current){const Ie=Ut(Te,"the agents");fn(`${Ie.why} ${Ie.next}${Ie.said?` (${Ie.said})`:""}`)}}),()=>{Hn.current++}},[e,c.section,c.operation,c.playgroundAgent,Wn,tt]),p.useEffect(()=>{if(c.section!=="mission")return;let pe=!0;R.current=!0,j(null),M(!0);const Te=Ev(S);return Promise.all([e.statsOver({...Te?{from:Te}:{},...O?{agent:O}:{}}),O?e.listAgentRuns(O,10):e.listRuns(10)]).then(([Ie,Et])=>{pe&&(v(tP(Ie,Et.runs)),O||q(wt=>wt||wU(Et.runs,Ie.analytics.by_source)))}).catch(Ie=>{pe&&j(Ut(Ie,"Mission Control"))}).finally(()=>{pe&&(R.current=!1,M(!1))}),()=>{pe=!1,R.current=!1}},[e,c.section,k,S,O,tt]),DE(()=>E(pe=>pe+1)),p.useEffect(()=>{if(c.section!=="mission")return;const pe=()=>{!document.hidden&&!R.current&&E(Ie=>Ie+1)};window.addEventListener("focus",pe),document.addEventListener("visibilitychange",pe);const Te=setInterval(pe,15e3);return()=>{window.removeEventListener("focus",pe),document.removeEventListener("visibilitychange",pe),clearInterval(Te)}},[c.section]),p.useEffect(()=>{if(c.section!=="mission"){U.current=null;return}let pe=!0;const Te=U,Ie=Bn=>qr(Gn=>e.listRuns(50,Gn,{status:Bn}),Gn=>Gn.runs,2),Et=()=>qr(Bn=>e.listAgents({archived:!1,cursor:Bn}),Bn=>Bn.agents).then(Bn=>{pe&&at(Bn.filter(Gn=>If(Gn)>0).map(Gn=>({agent_id:Gn.agent_id,name:Gn.definition.name??Gn.agent_id,pending:If(Gn)})))},()=>{}),rs=kU(()=>Promise.allSettled([Ie("input_required"),Ie("failed"),Ie("working"),Et()]).then(([Bn,Gn,ci])=>{var uo,fo,Or;if(!pe)return;const Ar=[Bn,Gn,ci],ah=Date.now()-bU;if(Y(A0(null,Ar).problem),((uo=Ar[0])==null?void 0:uo.status)==="fulfilled"&&Q(!0),((fo=Ar[1])==null?void 0:fo.status)==="fulfilled"){Z(!0);const Mr=Ar[1].value.map(fr=>fr.run_id),mo=Te.current;mo&&Mr.some(fr=>!mo.has(fr))&&E(fr=>fr+1),Te.current=new Set(Mr)}((Or=Ar[2])==null?void 0:Or.status)==="fulfilled"&&se(!0),D(Mr=>{const{needs:mo}=A0(Mr,Ar);return{asking:mo.asking.filter(IE),failed:mo.failed.filter(fr=>Date.parse(fr.ended_at??fr.created_at)>ah),live:mo.live}})}),1e4);return()=>{pe=!1,rs()}},[e,c.section,F]);const _s=p.useRef(Zz()).current,Ts=()=>setTimeout(()=>G(pe=>pe+1),2500),An=async(pe,Te)=>{try{return await fC(_s(pe),pe,Te,e.sendMessage),Ts(),null}catch(Ie){return Ft(Ie)}},ee=p.useRef(new Map).current,Le=async pe=>{const Te=[];try{for(const Ie of pe){const Et=jU(Ie.kind==="workflow"?Ie:await e.getRun(Ie.run_id));if("refusal"in Et)throw new Error(Et.refusal);const wt=ee.get(Ie.run_id)??bd();ee.set(Ie.run_id,wt),await e.startRun(Ie.agent_id,Et.body,wt),Te.push(Ie.run_id)}return Ts(),{started:Te,problem:null}}catch(Ie){return Te.length&&Ts(),{started:Te,problem:Ft(Ie)}}},mt=async pe=>{try{return await e.stop(pe),Ts(),null}catch(Te){return Ft(Te)}},At=async(pe,Te,Ie,Et,wt)=>{let rs=null;try{await e.answerApproval(pe,Te,Ie,Et,wt)}catch(Bn){rs=WE(Bn)}return G(Bn=>Bn+1),rs},Qt=async(pe,Te)=>{let Ie=null;try{await e.handBackComputer(pe,Te)}catch(Et){Ie=_x(Et,"hand")}return G(Et=>Et+1),Ie},He=p.useRef(0);p.useEffect(()=>{const pe=++He.current;Ys([]),En&&qr(Te=>e.listRevisions(En,Te),Te=>Te.revisions).then(Te=>{pe===He.current&&Ys(Te)}).catch(()=>{})},[e,En]);const te=async(pe,Te,Ie)=>{const Et=performance.now();try{const wt=await e.startRun(pe,Te,Ie);return{status:wt.status,ms:Math.round(performance.now()-Et),body:wt.run,runId:wt.run.run_id}}catch(wt){return wy(wt,Math.round(performance.now()-Et))}},be=((aa=u==null?void 0:u.features)==null?void 0:aa.efforts)??[],Ge=u?((lo=u.features)==null?void 0:lo.learning)??null:void 0;rt.learning=Ge??void 0;const kt=(ia=u==null?void 0:u.models)==null?void 0:ia.ready;p.useEffect(()=>{if(kt!==!1)return;const pe=()=>{zt.current||(zt.current=!0,ye().finally(()=>{zt.current=!1}))},Te=()=>ye(),Ie=setInterval(pe,hB);return window.addEventListener("focus",Te),()=>{clearInterval(Ie),window.removeEventListener("focus",Te)}},[e,kt]);const[Pt,it]=p.useState(null);p.useEffect(()=>{if(kt!==!1)return;let pe=!0;return e.chatGPT().then(Te=>{pe&&it(Mf(Te))},()=>{pe&&it(null)}),()=>{pe=!1}},[e,kt]);const[bn,$n]=p.useState(!1),ur=pe=>{it(pe),(pe.state==="pending"||pe.state==="signed_in")&&$n(!0),pe.state==="signed_in"&&ye()},Wt=(Td=ot==null?void 0:ot.find(pe=>pe.agent_id===En))==null?void 0:Td.definition,si=(Wt==null?void 0:Wt.native)||Zn(Wt),io=c.operation?c.playgroundAgent:En??c.playgroundAgent;return t.jsx(ME.Provider,{value:b,children:t.jsx(iB,{active:c.section,building:c.section==="agents"&&c.agent===null,onBuild:()=>Pe("#/agents/new"),settings:We.length>0,triggers:g,onNavigate:Se,onSignOut:()=>{const pe=()=>void e.signOut().then(n,Te=>i(Te instanceof De?Te.message:"The sign-out did not reach the server. Try again."));Yu(null,pe)||pe()},onSignOutEverywhere:()=>{const pe=()=>void e.signOutEverywhere().then(n,Te=>i(Te instanceof De?Te.message:"The sign-out did not reach the server. Try again."));Yu(null,pe)||pe()},banners:t.jsxs(t.Fragment,{children:[a&&t.jsxs("p",{className:"border-b bg-card px-5 py-3 font-mono text-body text-destructive-text md:px-8",role:"alert",children:["Not signed out: ",a]}),ct&&t.jsxs("p",{className:"flex items-center gap-3 border-b bg-card px-5 py-3 font-mono text-body md:px-8",role:"status",children:[t.jsx("span",{className:"flex-1",children:yB(ct)}),ct.state!=="running"&&t.jsx(B,{size:"xs",type:"button",onClick:()=>_t(null),children:"Dismiss"})]})]}),children:c.section==="settings"?t.jsx(uU,{active:c.settings??"keys",offered:We,children:c.settings==="tools"?t.jsx(IU,{v2:e,choices:J,gates:ve,harnesses:rt.harnesses,mcp:!!((Rd=u==null?void 0:u.features)!=null&&Rd.mcp_client),onSaved:ye,onOpen:ye}):c.settings==="mcp"?t.jsx(GU,{v2:e,signIn:c.signIn,add:c.add,writable:s,whyNot:r,choices:J}):c.settings==="github"?t.jsx(WU,{v2:e,returned:c.github}):c.settings==="email"?t.jsx(fW,{v2:e,writable:s,whyNot:r}):c.settings==="computers"?t.jsx(vW,{v2:e,writable:s,whyNot:r}):c.settings==="workspace"?t.jsx(_W,{v2:e,writable:s,whyNot:r}):c.settings==="webhook"?t.jsx(hW,{v2:e}):t.jsx(TU,{v2:e,onChange:ye,writable:s,whyNot:r,harnesses:rt.harnesses,plan:t.jsx(n6,{v2:e,writable:s,whyNot:r,onChange:()=>void ye()})})}):c.section==="dojo"?t.jsx(YD,{v2:e,server:Ge},tt):c.section==="mission"?t.jsx("div",{className:"flex h-full flex-col",children:t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(L7,{hasObservedSessions:!!((ri=$.data)!=null&&ri.sessions.length),observations:t.jsx(Nv,{read:$,view:"summary",days:_}),view:h,error:y,onRetry:()=>E(pe=>pe+1),actions:t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"icon","aria-label":"Refresh Mission Control",disabled:L,onClick:()=>{E(pe=>pe+1),G(pe=>pe+1)},children:t.jsx(Qo,{className:"size-4","aria-hidden":!0})}),t.jsx(tn,{label:"Query",prompt:Mm(location.origin,O??void 0),playgroundHref:Sv(O??void 0)}),t.jsx(Km,{variant:"primary"})]}),scope:{range:S,onRange:N,agent:O,onAgent:A,refreshing:L&&h!==null},asking:P&&z?P.asking.length:null,failed:P&&K?LE(P.failed):null,live:P&&de?P.live.length:null,needsYou:P&&t.jsx(z7,{asking:P.asking,failed:P.failed,failedAll:h==null?void 0:h.runs.failed,live:P.live,learning:Ze,problem:W,agentName:Ue,onAnswer:An,onApprove:At,onHandBack:Qt,onRunAgain:Le,onStop:mt}),startHere:H===!1&&!((Cl=$.data)!=null&&Cl.sessions.length)?t.jsx(J7,{harnesses:rt.harnesses,tools:rt.tools,onTry:Nt,imported:It,keySettings:((co=(oi=u==null?void 0:u.features)==null?void 0:oi.tool_keys)==null?void 0:co.routes)===!0&&u.features.tool_keys.at_rest==="sealed",modelSetup:u&&(u.models.ready===!1||bn)?t.jsx(oW,{v2:e,needs:u.models.needs,model:u.models.default,onSaved:ye,writable:s,whyNot:r,plan:Pt,harnesses:rt.harnesses,onPlan:ur,onDone:()=>$n(!1)}):void 0}):void 0})})}):c.section==="templates"?t.jsx(C0,{v2:e,name:c.template,install:c.install,go:Pe},c.install!==void 0?`install:${c.install}`:c.template??""):c.section==="triggers"?t.jsx(S8,{v2:e,view:{trigger:c.trigger,kind:c.kind,edit:c.edit},go:Pe,agentName:Ue,minEvery:(ai=(Ad=u==null?void 0:u.features)==null?void 0:Ad.triggers)==null?void 0:ai.min_every_s,failuresToPause:(El=(Ct=u==null?void 0:u.features)==null?void 0:Ct.triggers)==null?void 0:El.failures_to_pause,publicUrl:(ii=($l=u==null?void 0:u.features)==null?void 0:$l.triggers)==null?void 0:ii.public_url}):c.section==="playground"?t.jsxs("section",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("header",{className:"flex min-h-12 shrink-0 items-center gap-2 border-b px-5",children:[t.jsx(am,{className:"size-4","aria-hidden":!0}),t.jsx("h1",{className:"caps text-body font-semibold",children:"API playground"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b px-6 py-4",children:[t.jsx("label",{className:"sr-only",htmlFor:"api-operation",children:"API operation"}),t.jsx(Rt,{id:"api-operation",label:"API operation",value:c.operation??"run",onChange:pe=>{const Te=io,Ie=new URLSearchParams;pe!=="run"&&Ie.set("operation",pe),pe!=="create-agent"&&pe!=="apply-template"&&Te&&Ie.set("agent",Te),Pe(`#/playground${Ie.size?`?${Ie}`:""}`)},options:[{value:"create-agent",label:"POST · Create an agent"},{value:"apply-template",label:"POST · Apply a template"},{value:"run",label:"POST · Start a run"},{value:"list-runs",label:"GET · Query runs"},{value:"edit-agent",label:"PUT · Edit agent",disabled:!io}]}),t.jsx("span",{className:"min-w-0 break-all font-mono text-small text-muted-foreground",children:c.operation==="apply-template"?`/v2/templates/${c.template?encodeURIComponent(c.template):"{template}"}/apply`:c.operation==="list-runs"?c.playgroundAgent?`/v2/agents/${c.playgroundAgent}/runs`:"/v2/runs":c.operation==="create-agent"?"/v2/agents":c.operation==="edit-agent"?`/v2/agents/${c.playgroundAgent??"{agent_id}"}/definition`:"/v2/agents/{agent_id}/runs"})]}),c.operation==="apply-template"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(C0,{v2:e,name:c.template,go:Pe,playground:!0,draft:c.draft},c.template??"")}):c.operation==="list-runs"?t.jsx(lU,{v2:e,origin:location.origin,agentId:c.playgroundAgent,filter:{status:c.status,archived:c.archived}},`list:${c.playgroundAgent??""}:${c.status??""}:${c.archived??!1}`):c.operation?t.jsx(cU,{v2:e,operation:c.operation,origin:location.origin,agentId:c.playgroundAgent,draft:c.draft,harnesses:rt.harnesses},`${c.operation}:${c.playgroundAgent??""}:${c.draft??""}`):t.jsxs(t.Fragment,{children:[!si&&((_l=u==null?void 0:u.models)==null?void 0:_l.ready)===!1&&t.jsx(aW,{needs:u.models.needs,source:u.models.source,model:u.models.default,settings:((Rl=(Tl=u.features)==null?void 0:Tl.tool_keys)==null?void 0:Rl.routes)===!0&&u.features.tool_keys.at_rest==="sealed",chatgpt:(Pt==null?void 0:Pt.state)==="signed_out"||(Pt==null?void 0:Pt.state)==="expired"}),gs&&t.jsxs("div",{className:"m-8 border p-4",role:"alert",children:[t.jsxs("p",{className:"text-lead text-destructive-text",children:["The agents could not be read: ",gs]}),t.jsx(B,{size:"sm",className:"mt-3",type:"button",onClick:()=>$s(pe=>pe+1),children:"Try again"})]}),ot&&t.jsx(aU,{agents:ot.filter(pe=>!pe.archived_at),revisions:hs,efforts:be,origin:location.origin,agentId:En??void 0,onAgent:Un,onSend:te,limits:u==null?void 0:u.limits,removeUpload:e.deleteUpload,onOpenRun:pe=>Pe(`#/runs/${encodeURIComponent(pe)}`),live:pe=>t.jsx(fN,{v2:e,runId:pe,caps:u,agentName:Ue},pe)})]})]}):c.section==="agents"?c.observation?t.jsx(LM,{v2:e,sessionId:c.observation,go:Pe}):c.nativeConnect?t.jsx(WF,{v2:e,go:Pe,initialSource:c.connectionSource}):c.agent===void 0?t.jsx(HF,{v2:e,archived:!!c.archived,go:Pe},tt):c.agent===null?t.jsx(Q8,{origin:location.origin,v2:e}):c.agent!==null&&!c.edit?t.jsx(FD,{v2:e,agentId:c.agent,tab:c.tab,notes:c.notes,learning:Ge,routePrefix:(li=Xe==null?void 0:Xe.models)==null?void 0:li.route_prefix,harnesses:rt.harnesses,efforts:be,limits:u==null?void 0:u.limits,places:Sk(u),go:Pe},c.agent):t.jsx(BF,{v2:e,choices:J,gates:ve,focusTool:c.tool,caps:{...rt,routePrefix:(la=Xe==null?void 0:Xe.models)==null?void 0:la.route_prefix,decisionProvider:qP(u==null?void 0:u.workflows),places:Sk(u),mcp:!!((Qs=u==null?void 0:u.features)!=null&&Qs.mcp_client),mcpHarnesses:(Xs=(Js=u==null?void 0:u.features)==null?void 0:Js.mcp_client)==null?void 0:Xs.harnesses},agentId:c.agent,go:Pe},`${c.agent??"new"}:${c.tool??""}`):c.run?t.jsx(fN,{v2:e,runId:c.run,caps:u,agentName:Ue},c.run):t.jsx(Z8,{observations:!c.runsOf&&!c.archived&&!c.status?$:void 0,runs:ue,agentName:Ue,agentId:c.runsOf,error:Ee,onRetry:()=>Fe(pe=>pe+1),onOpen:pe=>Pe(`#/runs/${encodeURIComponent(pe)}`),loadingMore:fe,filter:le,onFilter:pe=>Pe(pB({runsOf:c.runsOf,...pe})),onMore:$e?()=>{const pe=ut.current;me(!0),(c.runsOf?e.listAgentRuns(c.runsOf,50,$e,le):e.listRuns(50,$e,le)).then(Te=>{pe===ut.current&&(xe(Ie=>ux(Ie??[],Te.runs)),ge(Te.next_cursor),Je(null))}).catch(Te=>Je(Ut(Te,"more runs"))).finally(()=>me(!1))}:void 0})})})}nB();sT.createRoot(document.getElementById("root")).render(t.jsx(p.StrictMode,{children:t.jsx(b5,{children:t.jsx(bB,{})})}));
|