@parcha/agentrun-serve 0.1.0-beta.41 → 0.1.0-beta.42
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 +53 -0
- package/NOTICE +2 -0
- package/README.md +77 -12
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.js +3 -1
- package/dist/calendar/address.d.ts +49 -0
- package/dist/calendar/address.js +153 -0
- package/dist/calendar/fetch.d.ts +24 -0
- package/dist/calendar/fetch.js +146 -0
- package/dist/calendar/ics-faux.d.ts +39 -0
- package/dist/calendar/ics-faux.js +236 -0
- package/dist/calendar/labels.d.ts +3 -0
- package/dist/calendar/labels.js +61 -0
- package/dist/calendar/names.d.ts +52 -0
- package/dist/calendar/names.js +54 -0
- package/dist/calendar/parse.d.ts +108 -0
- package/dist/calendar/parse.js +625 -0
- package/dist/calendar/routes.d.ts +17 -0
- package/dist/calendar/routes.js +81 -0
- package/dist/calendar/tools.d.ts +23 -0
- package/dist/calendar/tools.js +124 -0
- package/dist/cli.js +3 -1
- package/dist/computer-record.d.ts +55 -0
- package/dist/computer-record.js +315 -0
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +15 -2
- package/dist/computers.js +2 -14
- package/dist/console/assets/index-DYJ_wj27.js +711 -0
- package/dist/console/index.html +1 -1
- package/dist/eval-feed.d.ts +2 -2
- package/dist/eval-feed.js +9 -5
- package/dist/feed/parse.d.ts +3 -2
- package/dist/feed/parse.js +9 -18
- package/dist/feed/pointer.d.ts +2 -0
- package/dist/feed/pointer.js +17 -0
- package/dist/file-types.js +1 -0
- package/dist/host-command.d.ts +3 -0
- package/dist/host-command.js +18 -0
- package/dist/host.d.ts +3 -0
- package/dist/host.js +3 -0
- package/dist/learn/check.d.ts +14 -0
- package/dist/learn/check.js +194 -14
- package/dist/learn/compile.d.ts +48 -27
- package/dist/learn/compile.js +134 -101
- package/dist/learn/promote.d.ts +61 -5
- package/dist/learn/promote.js +12 -2
- package/dist/learning-setting.d.ts +23 -0
- package/dist/learning-setting.js +51 -0
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +3 -0
- package/dist/learning.d.ts +3 -2
- package/dist/learning.js +5 -3
- package/dist/mcp-oauth.d.ts +8 -0
- package/dist/mcp-oauth.js +7 -0
- package/dist/mcp-private-hosts.d.ts +13 -0
- package/dist/mcp-private-hosts.js +16 -0
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +105 -9
- package/dist/run-files.d.ts +6 -2
- package/dist/run-files.js +29 -7
- package/dist/run-learning-served.d.ts +1 -1
- package/dist/run-reads-over-store.d.ts +5 -1
- package/dist/run-reads-over-store.js +8 -4
- package/dist/run-recordings.d.ts +20 -0
- package/dist/run-recordings.js +133 -0
- package/dist/runner/adapter-loop.d.ts +1 -1
- package/dist/runner/adapter-loop.js +3 -6
- package/dist/runner/adapter-run-spec.d.ts +16 -1
- package/dist/runner/adapter-run-spec.js +20 -6
- package/dist/runner/beside.js +1 -1
- package/dist/runner/cli-run-spec.js +10 -7
- package/dist/runner/feedback-round.d.ts +9 -25
- package/dist/runner/feedback-round.js +22 -40
- package/dist/runner/learning-end.d.ts +17 -7
- package/dist/runner/learning-end.js +79 -53
- package/dist/runner/main.d.ts +11 -0
- package/dist/runner/main.js +29 -2
- package/dist/runner/mcp-run.d.ts +2 -2
- package/dist/runner/promotion.d.ts +36 -4
- package/dist/runner/promotion.js +280 -20
- package/dist/runner/reflect-hook.d.ts +5 -0
- package/dist/runner/reflect-hook.js +22 -14
- package/dist/runner/store-secrets.js +3 -1
- package/dist/runner/workflow-first.d.ts +0 -6
- package/dist/runner/workflow-first.js +7 -13
- package/dist/runs-over-store.d.ts +1 -1
- package/dist/sdk/runs.js +2 -1
- package/dist/secrets.js +2 -2
- package/dist/server.d.ts +4 -3
- package/dist/server.js +72 -11
- package/dist/store/agent-body.d.ts +5 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store-reads/learning.d.ts +1 -1
- package/dist/store-reads/loop.d.ts +1 -0
- package/dist/store-reads/loop.js +14 -4
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +4 -0
- package/dist/template-eval.d.ts +7 -0
- package/dist/template-eval.js +54 -6
- package/dist/templates.d.ts +3 -1
- package/dist/templates.js +14 -1
- package/dist/timeline/computer.js +2 -1
- package/dist/tool-list.js +1 -0
- package/dist/tools.d.ts +7 -0
- package/dist/tools.js +11 -0
- package/dist/trigger-feed.js +67 -18
- package/dist/validate.js +7 -2
- package/dist/workspace/computer-for-claim.d.ts +7 -0
- package/dist/workspace/computer-for-claim.js +12 -2
- package/dist/workspace/paths.d.ts +4 -0
- package/dist/workspace/paths.js +9 -0
- package/dist/workspace/resolve-computer.d.ts +3 -1
- package/launcher/agentrun-serve +31 -24
- package/package.json +10 -9
- package/templates/README.md +11 -2
- package/dist/console/assets/index-COGhx_2Z.js +0 -711
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
var iT=Object.defineProperty;var lT=(e,n,s)=>n in e?iT(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var At=(e,n,s)=>lT(e,typeof n!="symbol"?n+"":n,s);function cT(e,n){for(var s=0;s<n.length;s++){const r=n[s];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const i=Object.getOwnPropertyDescriptor(r,o);i&&Object.defineProperty(e,o,i.get?i:{enumerable:!0,get:()=>r[o]})}}}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 o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)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(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=s(o);fetch(o.href,i)}})();function SN(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Dp={exports:{}},cc={},Fp={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 Xw;function dT(){if(Xw)return xt;Xw=1;var e=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=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(D){return D===null||typeof D!="object"?null:(D=b&&D[b]||D["@@iterator"],typeof D=="function"?D:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,y={};function j(D,Y,se){this.props=D,this.context=Y,this.refs=y,this.updater=se||h}j.prototype.isReactComponent={},j.prototype.setState=function(D,Y){if(typeof D!="object"&&typeof D!="function"&&D!=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,D,Y,"setState")},j.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function k(){}k.prototype=j.prototype;function E(D,Y,se){this.props=D,this.context=Y,this.refs=y,this.updater=se||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},M={key:!0,ref:!0,__self:!0,__source:!0};function O(D,Y,se){var Q,re={},te=null,he=null;if(Y!=null)for(Q in Y.ref!==void 0&&(he=Y.ref),Y.key!==void 0&&(te=""+Y.key),Y)$.call(Y,Q)&&!M.hasOwnProperty(Q)&&(re[Q]=Y[Q]);var ge=arguments.length-2;if(ge===1)re.children=se;else if(1<ge){for(var be=Array(ge),xe=0;xe<ge;xe++)be[xe]=arguments[xe+2];re.children=be}if(D&&D.defaultProps)for(Q in ge=D.defaultProps,ge)re[Q]===void 0&&(re[Q]=ge[Q]);return{$$typeof:e,type:D,key:te,ref:he,props:re,_owner:_.current}}function L(D,Y){return{$$typeof:e,type:D.type,key:Y,ref:D.ref,props:D.props,_owner:D._owner}}function R(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function A(D){var Y={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(se){return Y[se]})}var P=/\/+/g;function z(D,Y){return typeof D=="object"&&D!==null&&D.key!=null?A(""+D.key):Y.toString(36)}function U(D,Y,se,Q,re){var te=typeof D;(te==="undefined"||te==="boolean")&&(D=null);var he=!1;if(D===null)he=!0;else switch(te){case"string":case"number":he=!0;break;case"object":switch(D.$$typeof){case e:case n:he=!0}}if(he)return he=D,re=re(he),D=Q===""?"."+z(he,0):Q,N(re)?(se="",D!=null&&(se=D.replace(P,"$&/")+"/"),U(re,Y,se,"",function(xe){return xe})):re!=null&&(R(re)&&(re=L(re,se+(!re.key||he&&he.key===re.key?"":(""+re.key).replace(P,"$&/")+"/")+D)),Y.push(re)),1;if(he=0,Q=Q===""?".":Q+":",N(D))for(var ge=0;ge<D.length;ge++){te=D[ge];var be=Q+z(te,ge);he+=U(te,Y,se,be,re)}else if(be=x(D),typeof be=="function")for(D=be.call(D),ge=0;!(te=D.next()).done;)te=te.value,be=Q+z(te,ge++),he+=U(te,Y,se,be,re);else if(te==="object")throw Y=String(D),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.");return he}function q(D,Y,se){if(D==null)return D;var Q=[],re=0;return U(D,Q,"","",function(te){return Y.call(se,te,re++)}),Q}function H(D){if(D._status===-1){var Y=D._result;Y=Y(),Y.then(function(se){(D._status===0||D._status===-1)&&(D._status=1,D._result=se)},function(se){(D._status===0||D._status===-1)&&(D._status=2,D._result=se)}),D._status===-1&&(D._status=0,D._result=Y)}if(D._status===1)return D._result.default;throw D._result}var K={current:null},W={transition:null},G={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:W,ReactCurrentOwner:_};function F(){throw Error("act(...) is not supported in production builds of React.")}return xt.Children={map:q,forEach:function(D,Y,se){q(D,function(){Y.apply(this,arguments)},se)},count:function(D){var Y=0;return q(D,function(){Y++}),Y},toArray:function(D){return q(D,function(Y){return Y})||[]},only:function(D){if(!R(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},xt.Component=j,xt.Fragment=s,xt.Profiler=o,xt.PureComponent=E,xt.StrictMode=r,xt.Suspense=u,xt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G,xt.act=F,xt.cloneElement=function(D,Y,se){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var Q=v({},D.props),re=D.key,te=D.ref,he=D._owner;if(Y!=null){if(Y.ref!==void 0&&(te=Y.ref,he=_.current),Y.key!==void 0&&(re=""+Y.key),D.type&&D.type.defaultProps)var ge=D.type.defaultProps;for(be in Y)$.call(Y,be)&&!M.hasOwnProperty(be)&&(Q[be]=Y[be]===void 0&&ge!==void 0?ge[be]:Y[be])}var be=arguments.length-2;if(be===1)Q.children=se;else if(1<be){ge=Array(be);for(var xe=0;xe<be;xe++)ge[xe]=arguments[xe+2];Q.children=ge}return{$$typeof:e,type:D.type,key:re,ref:te,props:Q,_owner:he}},xt.createContext=function(D){return D={$$typeof:c,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},D.Provider={$$typeof:i,_context:D},D.Consumer=D},xt.createElement=O,xt.createFactory=function(D){var Y=O.bind(null,D);return Y.type=D,Y},xt.createRef=function(){return{current:null}},xt.forwardRef=function(D){return{$$typeof:d,render:D}},xt.isValidElement=R,xt.lazy=function(D){return{$$typeof:g,_payload:{_status:-1,_result:D},_init:H}},xt.memo=function(D,Y){return{$$typeof:f,type:D,compare:Y===void 0?null:Y}},xt.startTransition=function(D){var Y=W.transition;W.transition={};try{D()}finally{W.transition=Y}},xt.unstable_act=F,xt.useCallback=function(D,Y){return K.current.useCallback(D,Y)},xt.useContext=function(D){return K.current.useContext(D)},xt.useDebugValue=function(){},xt.useDeferredValue=function(D){return K.current.useDeferredValue(D)},xt.useEffect=function(D,Y){return K.current.useEffect(D,Y)},xt.useId=function(){return K.current.useId()},xt.useImperativeHandle=function(D,Y,se){return K.current.useImperativeHandle(D,Y,se)},xt.useInsertionEffect=function(D,Y){return K.current.useInsertionEffect(D,Y)},xt.useLayoutEffect=function(D,Y){return K.current.useLayoutEffect(D,Y)},xt.useMemo=function(D,Y){return K.current.useMemo(D,Y)},xt.useReducer=function(D,Y,se){return K.current.useReducer(D,Y,se)},xt.useRef=function(D){return K.current.useRef(D)},xt.useState=function(D){return K.current.useState(D)},xt.useSyncExternalStore=function(D,Y,se){return K.current.useSyncExternalStore(D,Y,se)},xt.useTransition=function(){return K.current.useTransition()},xt.version="18.3.1",xt}var Zw;function cm(){return Zw||(Zw=1,Fp.exports=dT()),Fp.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 ej;function uT(){if(ej)return cc;ej=1;var e=cm(),n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=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:o.current}}return cc.Fragment=s,cc.jsx=c,cc.jsxs=c,cc}var tj;function fT(){return tj||(tj=1,Dp.exports=uT()),Dp.exports}var t=fT(),p=cm();const Ke=SN(p),Og=cT({__proto__:null,default:Ke},[p]);var Du={},Up={exports:{}},us={},Wp={exports:{}},Hp={};/**
|
|
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 nj;function mT(){return nj||(nj=1,(function(e){function n(W,G){var F=W.length;W.push(G);e:for(;0<F;){var D=F-1>>>1,Y=W[D];if(0<o(Y,G))W[D]=G,W[F]=Y,F=D;else break e}}function s(W){return W.length===0?null:W[0]}function r(W){if(W.length===0)return null;var G=W[0],F=W.pop();if(F!==G){W[0]=F;e:for(var D=0,Y=W.length,se=Y>>>1;D<se;){var Q=2*(D+1)-1,re=W[Q],te=Q+1,he=W[te];if(0>o(re,F))te<Y&&0>o(he,re)?(W[D]=he,W[te]=F,D=te):(W[D]=re,W[Q]=F,D=Q);else if(te<Y&&0>o(he,F))W[D]=he,W[te]=F,D=te;else break e}}return G}function o(W,G){var F=W.sortIndex-G.sortIndex;return F!==0?F:W.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(W){for(var G=s(f);G!==null;){if(G.callback===null)r(f);else if(G.startTime<=W)r(f),G.sortIndex=G.expirationTime,n(u,G);else break;G=s(f)}}function N(W){if(y=!1,S(W),!v)if(s(u)!==null)v=!0,H($);else{var G=s(f);G!==null&&K(N,G.startTime-W)}}function $(W,G){v=!1,y&&(y=!1,k(O),O=-1),h=!0;var F=x;try{for(S(G),b=s(u);b!==null&&(!(b.expirationTime>G)||W&&!A());){var D=b.callback;if(typeof D=="function"){b.callback=null,x=b.priorityLevel;var Y=D(b.expirationTime<=G);G=e.unstable_now(),typeof Y=="function"?b.callback=Y:b===s(u)&&r(u),S(G)}else r(u);b=s(u)}if(b!==null)var se=!0;else{var Q=s(f);Q!==null&&K(N,Q.startTime-G),se=!1}return se}finally{b=null,x=F,h=!1}}var _=!1,M=null,O=-1,L=5,R=-1;function A(){return!(e.unstable_now()-R<L)}function P(){if(M!==null){var W=e.unstable_now();R=W;var G=!0;try{G=M(!0,W)}finally{G?z():(_=!1,M=null)}}else _=!1}var z;if(typeof E=="function")z=function(){E(P)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,q=U.port2;U.port1.onmessage=P,z=function(){q.postMessage(null)}}else z=function(){j(P,0)};function H(W){M=W,_||(_=!0,z())}function K(W,G){O=j(function(){W(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(W){W.callback=null},e.unstable_continueExecution=function(){v||h||(v=!0,H($))},e.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<W?Math.floor(1e3/W):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return s(u)},e.unstable_next=function(W){switch(x){case 1:case 2:case 3:var G=3;break;default:G=x}var F=x;x=G;try{return W()}finally{x=F}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(W,G){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var F=x;x=W;try{return G()}finally{x=F}},e.unstable_scheduleCallback=function(W,G,F){var D=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?D+F:D):F=D,W){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=F+Y,W={id:g++,callback:G,priorityLevel:W,startTime:F,expirationTime:Y,sortIndex:-1},F>D?(W.sortIndex=F,n(f,W),s(u)===null&&W===s(f)&&(y?(k(O),O=-1):y=!0,K(N,F-D))):(W.sortIndex=Y,n(u,W),v||h||(v=!0,H($))),W},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(W){var G=x;return function(){var F=x;x=G;try{return W.apply(this,arguments)}finally{x=F}}}})(Hp)),Hp}var sj;function hT(){return sj||(sj=1,Wp.exports=mT()),Wp.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 rj;function pT(){if(rj)return us;rj=1;var e=cm(),n=hT();function s(a){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+a,m=1;m<arguments.length;m++)l+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function i(a,l){c(a,l),c(a+"Capture",l)}function c(a,l){for(o[a]=l,a=0;a<l.length;a++)r.add(l[a])}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(a){return u.call(b,a)?!0:u.call(g,a)?!1:f.test(a)?b[a]=!0:(g[a]=!0,!1)}function h(a,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:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function v(a,l,m,w){if(l===null||typeof l>"u"||h(a,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(a,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=a,this.type=l,this.sanitizeURL=T,this.removeEmptyString=I}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){j[a]=new y(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var l=a[0];j[l]=new y(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){j[a]=new y(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){j[a]=new y(a,2,!1,a,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(a){j[a]=new y(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){j[a]=new y(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){j[a]=new y(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){j[a]=new y(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){j[a]=new y(a,5,!1,a.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function E(a){return a[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(a){var l=a.replace(k,E);j[l]=new y(l,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var l=a.replace(k,E);j[l]=new y(l,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var l=a.replace(k,E);j[l]=new y(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){j[a]=new y(a,1,!1,a.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(a){j[a]=new y(a,1,!1,a.toLowerCase(),null,!0,!0)});function S(a,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?a.removeAttribute(l):a.setAttribute(l,""+m)):C.mustUseProperty?a[C.propertyName]=m===null?C.type===3?!1:"":m:(l=C.attributeName,w=C.attributeNamespace,m===null?a.removeAttribute(l):(C=C.type,m=C===3||C===4&&m===!0?"":""+m,w?a.setAttributeNS(w,l,m):a.setAttribute(l,m))))}var N=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),_=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),R=Symbol.for("react.provider"),A=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),W=Symbol.iterator;function G(a){return a===null||typeof a!="object"?null:(a=W&&a[W]||a["@@iterator"],typeof a=="function"?a:null)}var F=Object.assign,D;function Y(a){if(D===void 0)try{throw Error()}catch(m){var l=m.stack.trim().match(/\n( *(at )?)/);D=l&&l[1]||""}return`
|
|
34
|
+
`+D+a}var se=!1;function Q(a,l){if(!a||se)return"";se=!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(ue){var w=ue}Reflect.construct(a,[],l)}else{try{l.call()}catch(ue){w=ue}a.call(l.prototype)}else{try{throw Error()}catch(ue){w=ue}a()}}catch(ue){if(ue&&w&&typeof ue.stack=="string"){for(var C=ue.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 a.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",a.displayName)),X}while(1<=I&&0<=V);break}}}finally{se=!1,Error.prepareStackTrace=m}return(a=a?a.displayName||a.name:"")?Y(a):""}function re(a){switch(a.tag){case 5:return Y(a.type);case 16:return Y("Lazy");case 13:return Y("Suspense");case 19:return Y("SuspenseList");case 0:case 2:case 15:return a=Q(a.type,!1),a;case 11:return a=Q(a.type.render,!1),a;case 1:return a=Q(a.type,!0),a;default:return""}}function te(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case M:return"Fragment";case _:return"Portal";case L:return"Profiler";case O:return"StrictMode";case z:return"Suspense";case U:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case A:return(a.displayName||"Context")+".Consumer";case R:return(a._context.displayName||"Context")+".Provider";case P:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case q:return l=a.displayName||null,l!==null?l:te(a.type)||"Memo";case H:l=a._payload,a=a._init;try{return te(a(l))}catch{}}return null}function he(a){var l=a.type;switch(a.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 a=l.render,a=a.displayName||a.name||"",l.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return te(l);case 8:return l===O?"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 ge(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function be(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function xe(a){var l=be(a)?"checked":"value",m=Object.getOwnPropertyDescriptor(a.constructor.prototype,l),w=""+a[l];if(!a.hasOwnProperty(l)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var C=m.get,T=m.set;return Object.defineProperty(a,l,{configurable:!0,get:function(){return C.call(this)},set:function(I){w=""+I,T.call(this,I)}}),Object.defineProperty(a,l,{enumerable:m.enumerable}),{getValue:function(){return w},setValue:function(I){w=""+I},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function fe(a){a._valueTracker||(a._valueTracker=xe(a))}function De(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var m=l.getValue(),w="";return a&&(w=be(a)?a.checked?"true":"false":a.value),a=w,a!==m?(l.setValue(a),!0):!1}function Fe(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}function Pe(a,l){var m=l.checked;return F({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??a._wrapperState.initialChecked})}function Ee(a,l){var m=l.defaultValue==null?"":l.defaultValue,w=l.checked!=null?l.checked:l.defaultChecked;m=ge(l.value!=null?l.value:m),a._wrapperState={initialChecked:w,initialValue:m,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function ae(a,l){l=l.checked,l!=null&&S(a,"checked",l,!1)}function $e(a,l){ae(a,l);var m=ge(l.value),w=l.type;if(m!=null)w==="number"?(m===0&&a.value===""||a.value!=m)&&(a.value=""+m):a.value!==""+m&&(a.value=""+m);else if(w==="submit"||w==="reset"){a.removeAttribute("value");return}l.hasOwnProperty("value")?me(a,l.type,m):l.hasOwnProperty("defaultValue")&&me(a,l.type,ge(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(a.defaultChecked=!!l.defaultChecked)}function ot(a,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=""+a._wrapperState.initialValue,m||l===a.value||(a.value=l),a.defaultValue=l}m=a.name,m!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,m!==""&&(a.name=m)}function me(a,l,m){(l!=="number"||Fe(a.ownerDocument)!==a)&&(m==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+m&&(a.defaultValue=""+m))}var Le=Array.isArray;function Ze(a,l,m,w){if(a=a.options,l){l={};for(var C=0;C<m.length;C++)l["$"+m[C]]=!0;for(m=0;m<a.length;m++)C=l.hasOwnProperty("$"+a[m].value),a[m].selected!==C&&(a[m].selected=C),C&&w&&(a[m].defaultSelected=!0)}else{for(m=""+ge(m),l=null,C=0;C<a.length;C++){if(a[C].value===m){a[C].selected=!0,w&&(a[C].defaultSelected=!0);return}l!==null||a[C].disabled||(l=a[C])}l!==null&&(l.selected=!0)}}function yt(a,l){if(l.dangerouslySetInnerHTML!=null)throw Error(s(91));return F({},l,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function oe(a,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(Le(m)){if(1<m.length)throw Error(s(93));m=m[0]}l=m}l==null&&(l=""),m=l}a._wrapperState={initialValue:ge(m)}}function Se(a,l){var m=ge(l.value),w=ge(l.defaultValue);m!=null&&(m=""+m,m!==a.value&&(a.value=m),l.defaultValue==null&&a.defaultValue!==m&&(a.defaultValue=m)),w!=null&&(a.defaultValue=""+w)}function tt(a){var l=a.textContent;l===a._wrapperState.initialValue&&l!==""&&l!==null&&(a.value=l)}function Ae(a){switch(a){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 it(a,l){return a==null||a==="http://www.w3.org/1999/xhtml"?Ae(l):a==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var $t,nt=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,m,w,C){MSApp.execUnsafeLocalFunction(function(){return a(l,m,w,C)})}:a})(function(a,l){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=l;else{for($t=$t||document.createElement("div"),$t.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=$t.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}});function ft(a,l){if(l){var m=a.firstChild;if(m&&m===a.lastChild&&m.nodeType===3){m.nodeValue=l;return}}a.textContent=l}var Dt={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},Ft=["Webkit","ms","Moz","O"];Object.keys(Dt).forEach(function(a){Ft.forEach(function(l){l=l+a.charAt(0).toUpperCase()+a.substring(1),Dt[l]=Dt[a]})});function ye(a,l,m){return l==null||typeof l=="boolean"||l===""?"":m||typeof l!="number"||l===0||Dt.hasOwnProperty(a)&&Dt[a]?(""+l).trim():l+"px"}function de(a,l){a=a.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?a.setProperty(m,C):a[m]=C}}var Ue=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Xe(a,l){if(l){if(Ue[a]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(s(137,a));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 at(a,l){if(a.indexOf("-")===-1)return typeof l.is=="string";switch(a){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(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var We=null,Ve=null,He=null;function gt(a){if(a=Vl(a)){if(typeof We!="function")throw Error(s(280));var l=a.stateNode;l&&(l=eu(l),We(a.stateNode,a.type,l))}}function kt(a){Ve?He?He.push(a):He=[a]:Ve=a}function lt(){if(Ve){var a=Ve,l=He;if(He=Ve=null,gt(a),l)for(a=0;a<l.length;a++)gt(l[a])}}function Vt(a,l){return a(l)}function ps(){}var Qs=!1;function $n(a,l,m){if(Qs)return a(l,m);Qs=!0;try{return Vt(a,l,m)}finally{Qs=!1,(Ve!==null||He!==null)&&(ps(),lt())}}function Wn(a,l){var m=a.stateNode;if(m===null)return null;var w=eu(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)||(a=a.type,w=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!w;break e;default:a=!1}if(a)return null;if(m&&typeof m!="function")throw Error(s(231,l,typeof m));return m}var gs=!1;if(d)try{var xs={};Object.defineProperty(xs,"passive",{get:function(){gs=!0}}),window.addEventListener("test",xs,xs),window.removeEventListener("test",xs,xs)}catch{gs=!1}function mn(a,l,m,w,C,T,I,V,X){var ue=Array.prototype.slice.call(arguments,3);try{l.apply(m,ue)}catch(Ne){this.onError(Ne)}}var Hn=!1,_s=null,Bn=!1,Ts=null,Rs={onError:function(a){Hn=!0,_s=a}};function On(a,l,m,w,C,T,I,V,X){Hn=!1,_s=null,mn.apply(Rs,arguments)}function Z(a,l,m,w,C,T,I,V,X){if(On.apply(this,arguments),Hn){if(Hn){var ue=_s;Hn=!1,_s=null}else throw Error(s(198));Bn||(Bn=!0,Ts=ue)}}function Oe(a){var l=a,m=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(m=l.return),a=l.return;while(a)}return l.tag===3?m:null}function mt(a){if(a.tag===13){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function Ot(a){if(Oe(a)!==a)throw Error(s(188))}function Xt(a){var l=a.alternate;if(!l){if(l=Oe(a),l===null)throw Error(s(188));return l!==a?null:a}for(var m=a,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 Ot(C),a;if(T===w)return Ot(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?a:l}function Be(a){return a=Xt(a),a!==null?ee(a):null}function ee(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var l=ee(a);if(l!==null)return l;a=a.sibling}return null}var we=n.unstable_scheduleCallback,qe=n.unstable_cancelCallback,St=n.unstable_shouldYield,It=n.unstable_requestPaint,ct=n.unstable_now,wn=n.unstable_getCurrentPriorityLevel,_n=n.unstable_ImmediatePriority,mr=n.unstable_UserBlockingPriority,Bt=n.unstable_NormalPriority,oi=n.unstable_LowPriority,io=n.unstable_IdlePriority,aa=null,vs=null;function Pd(a){if(vs&&typeof vs.onCommitFiberRoot=="function")try{vs.onCommitFiberRoot(aa,a,void 0,(a.current.flags&128)===128)}catch{}}var rs=Math.clz32?Math.clz32:zd,Ld=Math.log,Id=Math.LN2;function zd(a){return a>>>=0,a===0?32:31-(Ld(a)/Id|0)|0}var ia=64,la=4194304;function lo(a){switch(a&-a){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 a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function ca(a,l){var m=a.pendingLanes;if(m===0)return 0;var w=0,C=a.suspendedLanes,T=a.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=a.entangledLanes,l!==0)for(a=a.entanglements,l&=w;0<l;)m=31-rs(l),C=1<<m,w|=a[m],l&=~C;return w}function Dd(a,l){switch(a){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 Fd(a,l){for(var m=a.suspendedLanes,w=a.pingedLanes,C=a.expirationTimes,T=a.pendingLanes;0<T;){var I=31-rs(T),V=1<<I,X=C[I];X===-1?((V&m)===0||(V&w)!==0)&&(C[I]=Dd(V,l)):X<=l&&(a.expiredLanes|=V),T&=~V}}function ai(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function Rl(){var a=ia;return ia<<=1,(ia&4194240)===0&&(ia=64),a}function ii(a){for(var l=[],m=0;31>m;m++)l.push(a);return l}function co(a,l,m){a.pendingLanes|=l,l!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,l=31-rs(l),a[l]=m}function Ud(a,l){var m=a.pendingLanes&~l;a.pendingLanes=l,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=l,a.mutableReadLanes&=l,a.entangledLanes&=l,l=a.entanglements;var w=a.eventTimes;for(a=a.expirationTimes;0<m;){var C=31-rs(m),T=1<<C;l[C]=0,w[C]=-1,a[C]=-1,m&=~T}}function li(a,l){var m=a.entangledLanes|=l;for(a=a.entanglements;m;){var w=31-rs(m),C=1<<w;C&l|a[w]&l&&(a[w]|=l),m&=~C}}var _t=0;function Al(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var Ol,ci,Ml,Pl,Ll,di=!1,da=[],Js=null,Xs=null,Zs=null,pe=new Map,_e=new Map,Ie=[],Tt="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 Nt(a,l){switch(a){case"focusin":case"focusout":Js=null;break;case"dragenter":case"dragleave":Xs=null;break;case"mouseover":case"mouseout":Zs=null;break;case"pointerover":case"pointerout":pe.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":_e.delete(l.pointerId)}}function os(a,l,m,w,C,T){return a===null||a.nativeEvent!==T?(a={blockedOn:l,domEventName:m,eventSystemFlags:w,nativeEvent:T,targetContainers:[C]},l!==null&&(l=Vl(l),l!==null&&ci(l)),a):(a.eventSystemFlags|=w,l=a.targetContainers,C!==null&&l.indexOf(C)===-1&&l.push(C),a)}function Gn(a,l,m,w,C){switch(l){case"focusin":return Js=os(Js,a,l,m,w,C),!0;case"dragenter":return Xs=os(Xs,a,l,m,w,C),!0;case"mouseover":return Zs=os(Zs,a,l,m,w,C),!0;case"pointerover":var T=C.pointerId;return pe.set(T,os(pe.get(T)||null,a,l,m,w,C)),!0;case"gotpointercapture":return T=C.pointerId,_e.set(T,os(_e.get(T)||null,a,l,m,w,C)),!0}return!1}function qn(a){var l=ua(a.target);if(l!==null){var m=Oe(l);if(m!==null){if(l=m.tag,l===13){if(l=mt(m),l!==null){a.blockedOn=l,Ll(a.priority,function(){Ml(m)});return}}else if(l===3&&m.stateNode.current.memoizedState.isDehydrated){a.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}a.blockedOn=null}function ui(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var m=fh(a.domEventName,a.eventSystemFlags,l[0],a.nativeEvent);if(m===null){m=a.nativeEvent;var w=new m.constructor(m.type,m);J=w,m.target.dispatchEvent(w),J=null}else return l=Vl(m),l!==null&&ci(l),a.blockedOn=m,!1;l.shift()}return!0}function Mr(a,l,m){ui(a)&&m.delete(l)}function dh(){di=!1,Js!==null&&ui(Js)&&(Js=null),Xs!==null&&ui(Xs)&&(Xs=null),Zs!==null&&ui(Zs)&&(Zs=null),pe.forEach(Mr),_e.forEach(Mr)}function uo(a,l){a.blockedOn===l&&(a.blockedOn=null,di||(di=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,dh)))}function fo(a){function l(C){return uo(C,a)}if(0<da.length){uo(da[0],a);for(var m=1;m<da.length;m++){var w=da[m];w.blockedOn===a&&(w.blockedOn=null)}}for(Js!==null&&uo(Js,a),Xs!==null&&uo(Xs,a),Zs!==null&&uo(Zs,a),pe.forEach(l),_e.forEach(l),m=0;m<Ie.length;m++)w=Ie[m],w.blockedOn===a&&(w.blockedOn=null);for(;0<Ie.length&&(m=Ie[0],m.blockedOn===null);)qn(m),m.blockedOn===null&&Ie.shift()}var Pr=N.ReactCurrentBatchConfig,Lr=!0;function mo(a,l,m,w){var C=_t,T=Pr.transition;Pr.transition=null;try{_t=1,uh(a,l,m,w)}finally{_t=C,Pr.transition=T}}function hr(a,l,m,w){var C=_t,T=Pr.transition;Pr.transition=null;try{_t=4,uh(a,l,m,w)}finally{_t=C,Pr.transition=T}}function uh(a,l,m,w){if(Lr){var C=fh(a,l,m,w);if(C===null)_h(a,l,w,Wd,m),Nt(a,w);else if(Gn(C,a,l,m,w))w.stopPropagation();else if(Nt(a,w),l&4&&-1<Tt.indexOf(a)){for(;C!==null;){var T=Vl(C);if(T!==null&&Ol(T),T=fh(a,l,m,w),T===null&&_h(a,l,w,Wd,m),T===C)break;C=T}C!==null&&w.stopPropagation()}else _h(a,l,w,null,m)}}var Wd=null;function fh(a,l,m,w){if(Wd=null,a=ve(w),a=ua(a),a!==null)if(l=Oe(a),l===null)a=null;else if(m=l.tag,m===13){if(a=mt(l),a!==null)return a;a=null}else if(m===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;a=null}else l!==a&&(a=null);return Wd=a,null}function zy(a){switch(a){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(wn()){case _n:return 1;case mr:return 4;case Bt:case oi:return 16;case io:return 536870912;default:return 16}default:return 16}}var ho=null,mh=null,Hd=null;function Dy(){if(Hd)return Hd;var a,l=mh,m=l.length,w,C="value"in ho?ho.value:ho.textContent,T=C.length;for(a=0;a<m&&l[a]===C[a];a++);var I=m-a;for(w=1;w<=I&&l[m-w]===C[T-w];w++);return Hd=C.slice(a,1<w?1-w:void 0)}function Bd(a){var l=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&l===13&&(a=13)):a=l,a===10&&(a=13),32<=a||a===13?a:0}function Gd(){return!0}function Fy(){return!1}function ys(a){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 a)a.hasOwnProperty(V)&&(m=a[V],this[V]=m?m(T):T[V]);return this.isDefaultPrevented=(T.defaultPrevented!=null?T.defaultPrevented:T.returnValue===!1)?Gd:Fy,this.isPropagationStopped=Fy,this}return F(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=Gd)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=Gd)},persist:function(){},isPersistent:Gd}),l}var fi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},hh=ys(fi),Il=F({},fi,{view:0,detail:0}),M$=ys(Il),ph,gh,zl,qd=F({},Il,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:vh,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==zl&&(zl&&a.type==="mousemove"?(ph=a.screenX-zl.screenX,gh=a.screenY-zl.screenY):gh=ph=0,zl=a),ph)},movementY:function(a){return"movementY"in a?a.movementY:gh}}),Uy=ys(qd),P$=F({},qd,{dataTransfer:0}),L$=ys(P$),I$=F({},Il,{relatedTarget:0}),xh=ys(I$),z$=F({},fi,{animationName:0,elapsedTime:0,pseudoElement:0}),D$=ys(z$),F$=F({},fi,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),U$=ys(F$),W$=F({},fi,{data:0}),Wy=ys(W$),H$={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},B$={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"},G$={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function q$(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=G$[a])?!!l[a]:!1}function vh(){return q$}var K$=F({},Il,{key:function(a){if(a.key){var l=H$[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=Bd(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?B$[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:vh,charCode:function(a){return a.type==="keypress"?Bd(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Bd(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),V$=ys(K$),Y$=F({},qd,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Hy=ys(Y$),Q$=F({},Il,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:vh}),J$=ys(Q$),X$=F({},fi,{propertyName:0,elapsedTime:0,pseudoElement:0}),Z$=ys(X$),e_=F({},qd,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),t_=ys(e_),n_=[9,13,27,32],yh=d&&"CompositionEvent"in window,Dl=null;d&&"documentMode"in document&&(Dl=document.documentMode);var s_=d&&"TextEvent"in window&&!Dl,By=d&&(!yh||Dl&&8<Dl&&11>=Dl),Gy=" ",qy=!1;function Ky(a,l){switch(a){case"keyup":return n_.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vy(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var mi=!1;function r_(a,l){switch(a){case"compositionend":return Vy(l);case"keypress":return l.which!==32?null:(qy=!0,Gy);case"textInput":return a=l.data,a===Gy&&qy?null:a;default:return null}}function o_(a,l){if(mi)return a==="compositionend"||!yh&&Ky(a,l)?(a=Dy(),Hd=mh=ho=null,mi=!1,a):null;switch(a){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 By&&l.locale!=="ko"?null:l.data;default:return null}}var a_={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 Yy(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!a_[a.type]:l==="textarea"}function Qy(a,l,m,w){kt(w),l=Jd(l,"onChange"),0<l.length&&(m=new hh("onChange","change",null,m,w),a.push({event:m,listeners:l}))}var Fl=null,Ul=null;function i_(a){hb(a,0)}function Kd(a){var l=vi(a);if(De(l))return a}function l_(a,l){if(a==="change")return l}var Jy=!1;if(d){var bh;if(d){var wh="oninput"in document;if(!wh){var Xy=document.createElement("div");Xy.setAttribute("oninput","return;"),wh=typeof Xy.oninput=="function"}bh=wh}else bh=!1;Jy=bh&&(!document.documentMode||9<document.documentMode)}function Zy(){Fl&&(Fl.detachEvent("onpropertychange",eb),Ul=Fl=null)}function eb(a){if(a.propertyName==="value"&&Kd(Ul)){var l=[];Qy(l,Ul,a,ve(a)),$n(i_,l)}}function c_(a,l,m){a==="focusin"?(Zy(),Fl=l,Ul=m,Fl.attachEvent("onpropertychange",eb)):a==="focusout"&&Zy()}function d_(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Kd(Ul)}function u_(a,l){if(a==="click")return Kd(l)}function f_(a,l){if(a==="input"||a==="change")return Kd(l)}function m_(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var er=typeof Object.is=="function"?Object.is:m_;function Wl(a,l){if(er(a,l))return!0;if(typeof a!="object"||a===null||typeof l!="object"||l===null)return!1;var m=Object.keys(a),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)||!er(a[C],l[C]))return!1}return!0}function tb(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function nb(a,l){var m=tb(a);a=0;for(var w;m;){if(m.nodeType===3){if(w=a+m.textContent.length,a<=l&&w>=l)return{node:m,offset:l-a};a=w}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=tb(m)}}function sb(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?sb(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function rb(){for(var a=window,l=Fe();l instanceof a.HTMLIFrameElement;){try{var m=typeof l.contentWindow.location.href=="string"}catch{m=!1}if(m)a=l.contentWindow;else break;l=Fe(a.document)}return l}function jh(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l&&(l==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||l==="textarea"||a.contentEditable==="true")}function h_(a){var l=rb(),m=a.focusedElem,w=a.selectionRange;if(l!==m&&m&&m.ownerDocument&&sb(m.ownerDocument.documentElement,m)){if(w!==null&&jh(m)){if(l=w.start,a=w.end,a===void 0&&(a=l),"selectionStart"in m)m.selectionStart=l,m.selectionEnd=Math.min(a,m.value.length);else if(a=(l=m.ownerDocument||document)&&l.defaultView||window,a.getSelection){a=a.getSelection();var C=m.textContent.length,T=Math.min(w.start,C);w=w.end===void 0?T:Math.min(w.end,C),!a.extend&&T>w&&(C=w,w=T,T=C),C=nb(m,T);var I=nb(m,w);C&&I&&(a.rangeCount!==1||a.anchorNode!==C.node||a.anchorOffset!==C.offset||a.focusNode!==I.node||a.focusOffset!==I.offset)&&(l=l.createRange(),l.setStart(C.node,C.offset),a.removeAllRanges(),T>w?(a.addRange(l),a.extend(I.node,I.offset)):(l.setEnd(I.node,I.offset),a.addRange(l)))}}for(l=[],a=m;a=a.parentNode;)a.nodeType===1&&l.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<l.length;m++)a=l[m],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var p_=d&&"documentMode"in document&&11>=document.documentMode,hi=null,kh=null,Hl=null,Nh=!1;function ob(a,l,m){var w=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;Nh||hi==null||hi!==Fe(w)||(w=hi,"selectionStart"in w&&jh(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}),Hl&&Wl(Hl,w)||(Hl=w,w=Jd(kh,"onSelect"),0<w.length&&(l=new hh("onSelect","select",null,l,m),a.push({event:l,listeners:w}),l.target=hi)))}function Vd(a,l){var m={};return m[a.toLowerCase()]=l.toLowerCase(),m["Webkit"+a]="webkit"+l,m["Moz"+a]="moz"+l,m}var pi={animationend:Vd("Animation","AnimationEnd"),animationiteration:Vd("Animation","AnimationIteration"),animationstart:Vd("Animation","AnimationStart"),transitionend:Vd("Transition","TransitionEnd")},Sh={},ab={};d&&(ab=document.createElement("div").style,"AnimationEvent"in window||(delete pi.animationend.animation,delete pi.animationiteration.animation,delete pi.animationstart.animation),"TransitionEvent"in window||delete pi.transitionend.transition);function Yd(a){if(Sh[a])return Sh[a];if(!pi[a])return a;var l=pi[a],m;for(m in l)if(l.hasOwnProperty(m)&&m in ab)return Sh[a]=l[m];return a}var ib=Yd("animationend"),lb=Yd("animationiteration"),cb=Yd("animationstart"),db=Yd("transitionend"),ub=new Map,fb="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(a,l){ub.set(a,l),i(l,[a])}for(var Ch=0;Ch<fb.length;Ch++){var Eh=fb[Ch],g_=Eh.toLowerCase(),x_=Eh[0].toUpperCase()+Eh.slice(1);po(g_,"on"+x_)}po(ib,"onAnimationEnd"),po(lb,"onAnimationIteration"),po(cb,"onAnimationStart"),po("dblclick","onDoubleClick"),po("focusin","onFocus"),po("focusout","onBlur"),po(db,"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 Bl="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(" "),v_=new Set("cancel close invalid load scroll toggle".split(" ").concat(Bl));function mb(a,l,m){var w=a.type||"unknown-event";a.currentTarget=m,Z(w,l,void 0,a),a.currentTarget=null}function hb(a,l){l=(l&4)!==0;for(var m=0;m<a.length;m++){var w=a[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,ue=V.currentTarget;if(V=V.listener,X!==T&&C.isPropagationStopped())break e;mb(C,V,ue),T=X}else for(I=0;I<w.length;I++){if(V=w[I],X=V.instance,ue=V.currentTarget,V=V.listener,X!==T&&C.isPropagationStopped())break e;mb(C,V,ue),T=X}}}if(Bn)throw a=Ts,Bn=!1,Ts=null,a}function Gt(a,l){var m=l[Ph];m===void 0&&(m=l[Ph]=new Set);var w=a+"__bubble";m.has(w)||(pb(l,a,2,!1),m.add(w))}function $h(a,l,m){var w=0;l&&(w|=4),pb(m,a,w,l)}var Qd="_reactListening"+Math.random().toString(36).slice(2);function Gl(a){if(!a[Qd]){a[Qd]=!0,r.forEach(function(m){m!=="selectionchange"&&(v_.has(m)||$h(m,!1,a),$h(m,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[Qd]||(l[Qd]=!0,$h("selectionchange",!1,l))}}function pb(a,l,m,w){switch(zy(l)){case 1:var C=mo;break;case 4:C=hr;break;default:C=uh}m=C.bind(null,l,m,a),C=void 0,!gs||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(C=!0),w?C!==void 0?a.addEventListener(l,m,{capture:!0,passive:C}):a.addEventListener(l,m,!0):C!==void 0?a.addEventListener(l,m,{passive:C}):a.addEventListener(l,m,!1)}function _h(a,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=ua(V),I===null)return;if(X=I.tag,X===5||X===6){w=T=I;continue e}V=V.parentNode}}w=w.return}$n(function(){var ue=T,Ne=ve(m),Ce=[];e:{var je=ub.get(a);if(je!==void 0){var Ge=hh,Qe=a;switch(a){case"keypress":if(Bd(m)===0)break e;case"keydown":case"keyup":Ge=V$;break;case"focusin":Qe="focus",Ge=xh;break;case"focusout":Qe="blur",Ge=xh;break;case"beforeblur":case"afterblur":Ge=xh;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":Ge=Uy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ge=L$;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ge=J$;break;case ib:case lb:case cb:Ge=D$;break;case db:Ge=Z$;break;case"scroll":Ge=M$;break;case"wheel":Ge=t_;break;case"copy":case"cut":case"paste":Ge=U$;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ge=Hy}var Je=(l&4)!==0,an=!Je&&a==="scroll",le=Je?je!==null?je+"Capture":null:je;Je=[];for(var ne=ue,ce;ne!==null;){ce=ne;var Re=ce.stateNode;if(ce.tag===5&&Re!==null&&(ce=Re,le!==null&&(Re=Wn(ne,le),Re!=null&&Je.push(ql(ne,Re,ce)))),an)break;ne=ne.return}0<Je.length&&(je=new Ge(je,Qe,null,m,Ne),Ce.push({event:je,listeners:Je}))}}if((l&7)===0){e:{if(je=a==="mouseover"||a==="pointerover",Ge=a==="mouseout"||a==="pointerout",je&&m!==J&&(Qe=m.relatedTarget||m.fromElement)&&(ua(Qe)||Qe[Ir]))break e;if((Ge||je)&&(je=Ne.window===Ne?Ne:(je=Ne.ownerDocument)?je.defaultView||je.parentWindow:window,Ge?(Qe=m.relatedTarget||m.toElement,Ge=ue,Qe=Qe?ua(Qe):null,Qe!==null&&(an=Oe(Qe),Qe!==an||Qe.tag!==5&&Qe.tag!==6)&&(Qe=null)):(Ge=null,Qe=ue),Ge!==Qe)){if(Je=Uy,Re="onMouseLeave",le="onMouseEnter",ne="mouse",(a==="pointerout"||a==="pointerover")&&(Je=Hy,Re="onPointerLeave",le="onPointerEnter",ne="pointer"),an=Ge==null?je:vi(Ge),ce=Qe==null?je:vi(Qe),je=new Je(Re,ne+"leave",Ge,m,Ne),je.target=an,je.relatedTarget=ce,Re=null,ua(Ne)===ue&&(Je=new Je(le,ne+"enter",Qe,m,Ne),Je.target=ce,Je.relatedTarget=an,Re=Je),an=Re,Ge&&Qe)t:{for(Je=Ge,le=Qe,ne=0,ce=Je;ce;ce=gi(ce))ne++;for(ce=0,Re=le;Re;Re=gi(Re))ce++;for(;0<ne-ce;)Je=gi(Je),ne--;for(;0<ce-ne;)le=gi(le),ce--;for(;ne--;){if(Je===le||le!==null&&Je===le.alternate)break t;Je=gi(Je),le=gi(le)}Je=null}else Je=null;Ge!==null&&gb(Ce,je,Ge,Je,!1),Qe!==null&&an!==null&&gb(Ce,an,Qe,Je,!0)}}e:{if(je=ue?vi(ue):window,Ge=je.nodeName&&je.nodeName.toLowerCase(),Ge==="select"||Ge==="input"&&je.type==="file")var et=l_;else if(Yy(je))if(Jy)et=f_;else{et=d_;var st=c_}else(Ge=je.nodeName)&&Ge.toLowerCase()==="input"&&(je.type==="checkbox"||je.type==="radio")&&(et=u_);if(et&&(et=et(a,ue))){Qy(Ce,et,m,Ne);break e}st&&st(a,je,ue),a==="focusout"&&(st=je._wrapperState)&&st.controlled&&je.type==="number"&&me(je,"number",je.value)}switch(st=ue?vi(ue):window,a){case"focusin":(Yy(st)||st.contentEditable==="true")&&(hi=st,kh=ue,Hl=null);break;case"focusout":Hl=kh=hi=null;break;case"mousedown":Nh=!0;break;case"contextmenu":case"mouseup":case"dragend":Nh=!1,ob(Ce,m,Ne);break;case"selectionchange":if(p_)break;case"keydown":case"keyup":ob(Ce,m,Ne)}var rt;if(yh)e:{switch(a){case"compositionstart":var dt="onCompositionStart";break e;case"compositionend":dt="onCompositionEnd";break e;case"compositionupdate":dt="onCompositionUpdate";break e}dt=void 0}else mi?Ky(a,m)&&(dt="onCompositionEnd"):a==="keydown"&&m.keyCode===229&&(dt="onCompositionStart");dt&&(By&&m.locale!=="ko"&&(mi||dt!=="onCompositionStart"?dt==="onCompositionEnd"&&mi&&(rt=Dy()):(ho=Ne,mh="value"in ho?ho.value:ho.textContent,mi=!0)),st=Jd(ue,dt),0<st.length&&(dt=new Wy(dt,a,null,m,Ne),Ce.push({event:dt,listeners:st}),rt?dt.data=rt:(rt=Vy(m),rt!==null&&(dt.data=rt)))),(rt=s_?r_(a,m):o_(a,m))&&(ue=Jd(ue,"onBeforeInput"),0<ue.length&&(Ne=new Wy("onBeforeInput","beforeinput",null,m,Ne),Ce.push({event:Ne,listeners:ue}),Ne.data=rt))}hb(Ce,l)})}function ql(a,l,m){return{instance:a,listener:l,currentTarget:m}}function Jd(a,l){for(var m=l+"Capture",w=[];a!==null;){var C=a,T=C.stateNode;C.tag===5&&T!==null&&(C=T,T=Wn(a,m),T!=null&&w.unshift(ql(a,T,C)),T=Wn(a,l),T!=null&&w.push(ql(a,T,C))),a=a.return}return w}function gi(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function gb(a,l,m,w,C){for(var T=l._reactName,I=[];m!==null&&m!==w;){var V=m,X=V.alternate,ue=V.stateNode;if(X!==null&&X===w)break;V.tag===5&&ue!==null&&(V=ue,C?(X=Wn(m,T),X!=null&&I.unshift(ql(m,X,V))):C||(X=Wn(m,T),X!=null&&I.push(ql(m,X,V)))),m=m.return}I.length!==0&&a.push({event:l,listeners:I})}var y_=/\r\n?/g,b_=/\u0000|\uFFFD/g;function xb(a){return(typeof a=="string"?a:""+a).replace(y_,`
|
|
38
|
+
`).replace(b_,"")}function Xd(a,l,m){if(l=xb(l),xb(a)!==l&&m)throw Error(s(425))}function Zd(){}var Th=null,Rh=null;function Ah(a,l){return a==="textarea"||a==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var Oh=typeof setTimeout=="function"?setTimeout:void 0,w_=typeof clearTimeout=="function"?clearTimeout:void 0,vb=typeof Promise=="function"?Promise:void 0,j_=typeof queueMicrotask=="function"?queueMicrotask:typeof vb<"u"?function(a){return vb.resolve(null).then(a).catch(k_)}:Oh;function k_(a){setTimeout(function(){throw a})}function Mh(a,l){var m=l,w=0;do{var C=m.nextSibling;if(a.removeChild(m),C&&C.nodeType===8)if(m=C.data,m==="/$"){if(w===0){a.removeChild(C),fo(l);return}w--}else m!=="$"&&m!=="$?"&&m!=="$!"||w++;m=C}while(m);fo(l)}function go(a){for(;a!=null;a=a.nextSibling){var l=a.nodeType;if(l===1||l===3)break;if(l===8){if(l=a.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return a}function yb(a){a=a.previousSibling;for(var l=0;a;){if(a.nodeType===8){var m=a.data;if(m==="$"||m==="$!"||m==="$?"){if(l===0)return a;l--}else m==="/$"&&l++}a=a.previousSibling}return null}var xi=Math.random().toString(36).slice(2),pr="__reactFiber$"+xi,Kl="__reactProps$"+xi,Ir="__reactContainer$"+xi,Ph="__reactEvents$"+xi,N_="__reactListeners$"+xi,S_="__reactHandles$"+xi;function ua(a){var l=a[pr];if(l)return l;for(var m=a.parentNode;m;){if(l=m[Ir]||m[pr]){if(m=l.alternate,l.child!==null||m!==null&&m.child!==null)for(a=yb(a);a!==null;){if(m=a[pr])return m;a=yb(a)}return l}a=m,m=a.parentNode}return null}function Vl(a){return a=a[pr]||a[Ir],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function vi(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(s(33))}function eu(a){return a[Kl]||null}var Lh=[],yi=-1;function xo(a){return{current:a}}function qt(a){0>yi||(a.current=Lh[yi],Lh[yi]=null,yi--)}function Ut(a,l){yi++,Lh[yi]=a.current,a.current=l}var vo={},Mn=xo(vo),as=xo(!1),fa=vo;function bi(a,l){var m=a.type.contextTypes;if(!m)return vo;var w=a.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===l)return w.__reactInternalMemoizedMaskedChildContext;var C={},T;for(T in m)C[T]=l[T];return w&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=l,a.__reactInternalMemoizedMaskedChildContext=C),C}function is(a){return a=a.childContextTypes,a!=null}function tu(){qt(as),qt(Mn)}function bb(a,l,m){if(Mn.current!==vo)throw Error(s(168));Ut(Mn,l),Ut(as,m)}function wb(a,l,m){var w=a.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,he(a)||"Unknown",C));return F({},m,w)}function nu(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||vo,fa=Mn.current,Ut(Mn,a),Ut(as,as.current),!0}function jb(a,l,m){var w=a.stateNode;if(!w)throw Error(s(169));m?(a=wb(a,l,fa),w.__reactInternalMemoizedMergedChildContext=a,qt(as),qt(Mn),Ut(Mn,a)):qt(as),Ut(as,m)}var zr=null,su=!1,Ih=!1;function kb(a){zr===null?zr=[a]:zr.push(a)}function C_(a){su=!0,kb(a)}function yo(){if(!Ih&&zr!==null){Ih=!0;var a=0,l=_t;try{var m=zr;for(_t=1;a<m.length;a++){var w=m[a];do w=w(!0);while(w!==null)}zr=null,su=!1}catch(C){throw zr!==null&&(zr=zr.slice(a+1)),we(_n,yo),C}finally{_t=l,Ih=!1}}return null}var wi=[],ji=0,ru=null,ou=0,As=[],Os=0,ma=null,Dr=1,Fr="";function ha(a,l){wi[ji++]=ou,wi[ji++]=ru,ru=a,ou=l}function Nb(a,l,m){As[Os++]=Dr,As[Os++]=Fr,As[Os++]=ma,ma=a;var w=Dr;a=Fr;var C=32-rs(w)-1;w&=~(1<<C),m+=1;var T=32-rs(l)+C;if(30<T){var I=C-C%5;T=(w&(1<<I)-1).toString(32),w>>=I,C-=I,Dr=1<<32-rs(l)+C|m<<C|w,Fr=T+a}else Dr=1<<T|m<<C|w,Fr=a}function zh(a){a.return!==null&&(ha(a,1),Nb(a,1,0))}function Dh(a){for(;a===ru;)ru=wi[--ji],wi[ji]=null,ou=wi[--ji],wi[ji]=null;for(;a===ma;)ma=As[--Os],As[Os]=null,Fr=As[--Os],As[Os]=null,Dr=As[--Os],As[Os]=null}var bs=null,ws=null,Yt=!1,tr=null;function Sb(a,l){var m=Is(5,null,null,0);m.elementType="DELETED",m.stateNode=l,m.return=a,l=a.deletions,l===null?(a.deletions=[m],a.flags|=16):l.push(m)}function Cb(a,l){switch(a.tag){case 5:var m=a.type;return l=l.nodeType!==1||m.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(a.stateNode=l,bs=a,ws=go(l.firstChild),!0):!1;case 6:return l=a.pendingProps===""||l.nodeType!==3?null:l,l!==null?(a.stateNode=l,bs=a,ws=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(m=ma!==null?{id:Dr,overflow:Fr}:null,a.memoizedState={dehydrated:l,treeContext:m,retryLane:1073741824},m=Is(18,null,null,0),m.stateNode=l,m.return=a,a.child=m,bs=a,ws=null,!0):!1;default:return!1}}function Fh(a){return(a.mode&1)!==0&&(a.flags&128)===0}function Uh(a){if(Yt){var l=ws;if(l){var m=l;if(!Cb(a,l)){if(Fh(a))throw Error(s(418));l=go(m.nextSibling);var w=bs;l&&Cb(a,l)?Sb(w,m):(a.flags=a.flags&-4097|2,Yt=!1,bs=a)}}else{if(Fh(a))throw Error(s(418));a.flags=a.flags&-4097|2,Yt=!1,bs=a}}}function Eb(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;bs=a}function au(a){if(a!==bs)return!1;if(!Yt)return Eb(a),Yt=!0,!1;var l;if((l=a.tag!==3)&&!(l=a.tag!==5)&&(l=a.type,l=l!=="head"&&l!=="body"&&!Ah(a.type,a.memoizedProps)),l&&(l=ws)){if(Fh(a))throw $b(),Error(s(418));for(;l;)Sb(a,l),l=go(l.nextSibling)}if(Eb(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(s(317));e:{for(a=a.nextSibling,l=0;a;){if(a.nodeType===8){var m=a.data;if(m==="/$"){if(l===0){ws=go(a.nextSibling);break e}l--}else m!=="$"&&m!=="$!"&&m!=="$?"||l++}a=a.nextSibling}ws=null}}else ws=bs?go(a.stateNode.nextSibling):null;return!0}function $b(){for(var a=ws;a;)a=go(a.nextSibling)}function ki(){ws=bs=null,Yt=!1}function Wh(a){tr===null?tr=[a]:tr.push(a)}var E_=N.ReactCurrentBatchConfig;function Yl(a,l,m){if(a=m.ref,a!==null&&typeof a!="function"&&typeof a!="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,a));var C=w,T=""+a;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 a!="string")throw Error(s(284));if(!m._owner)throw Error(s(290,a))}return a}function iu(a,l){throw a=Object.prototype.toString.call(l),Error(s(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a))}function _b(a){var l=a._init;return l(a._payload)}function Tb(a){function l(le,ne){if(a){var ce=le.deletions;ce===null?(le.deletions=[ne],le.flags|=16):ce.push(ne)}}function m(le,ne){if(!a)return null;for(;ne!==null;)l(le,ne),ne=ne.sibling;return null}function w(le,ne){for(le=new Map;ne!==null;)ne.key!==null?le.set(ne.key,ne):le.set(ne.index,ne),ne=ne.sibling;return le}function C(le,ne){return le=Eo(le,ne),le.index=0,le.sibling=null,le}function T(le,ne,ce){return le.index=ce,a?(ce=le.alternate,ce!==null?(ce=ce.index,ce<ne?(le.flags|=2,ne):ce):(le.flags|=2,ne)):(le.flags|=1048576,ne)}function I(le){return a&&le.alternate===null&&(le.flags|=2),le}function V(le,ne,ce,Re){return ne===null||ne.tag!==6?(ne=Op(ce,le.mode,Re),ne.return=le,ne):(ne=C(ne,ce),ne.return=le,ne)}function X(le,ne,ce,Re){var et=ce.type;return et===M?Ne(le,ne,ce.props.children,Re,ce.key):ne!==null&&(ne.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===H&&_b(et)===ne.type)?(Re=C(ne,ce.props),Re.ref=Yl(le,ne,ce),Re.return=le,Re):(Re=Ru(ce.type,ce.key,ce.props,null,le.mode,Re),Re.ref=Yl(le,ne,ce),Re.return=le,Re)}function ue(le,ne,ce,Re){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==ce.containerInfo||ne.stateNode.implementation!==ce.implementation?(ne=Mp(ce,le.mode,Re),ne.return=le,ne):(ne=C(ne,ce.children||[]),ne.return=le,ne)}function Ne(le,ne,ce,Re,et){return ne===null||ne.tag!==7?(ne=ja(ce,le.mode,Re,et),ne.return=le,ne):(ne=C(ne,ce),ne.return=le,ne)}function Ce(le,ne,ce){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=Op(""+ne,le.mode,ce),ne.return=le,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case $:return ce=Ru(ne.type,ne.key,ne.props,null,le.mode,ce),ce.ref=Yl(le,null,ne),ce.return=le,ce;case _:return ne=Mp(ne,le.mode,ce),ne.return=le,ne;case H:var Re=ne._init;return Ce(le,Re(ne._payload),ce)}if(Le(ne)||G(ne))return ne=ja(ne,le.mode,ce,null),ne.return=le,ne;iu(le,ne)}return null}function je(le,ne,ce,Re){var et=ne!==null?ne.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return et!==null?null:V(le,ne,""+ce,Re);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:return ce.key===et?X(le,ne,ce,Re):null;case _:return ce.key===et?ue(le,ne,ce,Re):null;case H:return et=ce._init,je(le,ne,et(ce._payload),Re)}if(Le(ce)||G(ce))return et!==null?null:Ne(le,ne,ce,Re,null);iu(le,ce)}return null}function Ge(le,ne,ce,Re,et){if(typeof Re=="string"&&Re!==""||typeof Re=="number")return le=le.get(ce)||null,V(ne,le,""+Re,et);if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case $:return le=le.get(Re.key===null?ce:Re.key)||null,X(ne,le,Re,et);case _:return le=le.get(Re.key===null?ce:Re.key)||null,ue(ne,le,Re,et);case H:var st=Re._init;return Ge(le,ne,ce,st(Re._payload),et)}if(Le(Re)||G(Re))return le=le.get(ce)||null,Ne(ne,le,Re,et,null);iu(ne,Re)}return null}function Qe(le,ne,ce,Re){for(var et=null,st=null,rt=ne,dt=ne=0,Nn=null;rt!==null&&dt<ce.length;dt++){rt.index>dt?(Nn=rt,rt=null):Nn=rt.sibling;var Rt=je(le,rt,ce[dt],Re);if(Rt===null){rt===null&&(rt=Nn);break}a&&rt&&Rt.alternate===null&&l(le,rt),ne=T(Rt,ne,dt),st===null?et=Rt:st.sibling=Rt,st=Rt,rt=Nn}if(dt===ce.length)return m(le,rt),Yt&&ha(le,dt),et;if(rt===null){for(;dt<ce.length;dt++)rt=Ce(le,ce[dt],Re),rt!==null&&(ne=T(rt,ne,dt),st===null?et=rt:st.sibling=rt,st=rt);return Yt&&ha(le,dt),et}for(rt=w(le,rt);dt<ce.length;dt++)Nn=Ge(rt,le,dt,ce[dt],Re),Nn!==null&&(a&&Nn.alternate!==null&&rt.delete(Nn.key===null?dt:Nn.key),ne=T(Nn,ne,dt),st===null?et=Nn:st.sibling=Nn,st=Nn);return a&&rt.forEach(function($o){return l(le,$o)}),Yt&&ha(le,dt),et}function Je(le,ne,ce,Re){var et=G(ce);if(typeof et!="function")throw Error(s(150));if(ce=et.call(ce),ce==null)throw Error(s(151));for(var st=et=null,rt=ne,dt=ne=0,Nn=null,Rt=ce.next();rt!==null&&!Rt.done;dt++,Rt=ce.next()){rt.index>dt?(Nn=rt,rt=null):Nn=rt.sibling;var $o=je(le,rt,Rt.value,Re);if($o===null){rt===null&&(rt=Nn);break}a&&rt&&$o.alternate===null&&l(le,rt),ne=T($o,ne,dt),st===null?et=$o:st.sibling=$o,st=$o,rt=Nn}if(Rt.done)return m(le,rt),Yt&&ha(le,dt),et;if(rt===null){for(;!Rt.done;dt++,Rt=ce.next())Rt=Ce(le,Rt.value,Re),Rt!==null&&(ne=T(Rt,ne,dt),st===null?et=Rt:st.sibling=Rt,st=Rt);return Yt&&ha(le,dt),et}for(rt=w(le,rt);!Rt.done;dt++,Rt=ce.next())Rt=Ge(rt,le,dt,Rt.value,Re),Rt!==null&&(a&&Rt.alternate!==null&&rt.delete(Rt.key===null?dt:Rt.key),ne=T(Rt,ne,dt),st===null?et=Rt:st.sibling=Rt,st=Rt);return a&&rt.forEach(function(aT){return l(le,aT)}),Yt&&ha(le,dt),et}function an(le,ne,ce,Re){if(typeof ce=="object"&&ce!==null&&ce.type===M&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:e:{for(var et=ce.key,st=ne;st!==null;){if(st.key===et){if(et=ce.type,et===M){if(st.tag===7){m(le,st.sibling),ne=C(st,ce.props.children),ne.return=le,le=ne;break e}}else if(st.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===H&&_b(et)===st.type){m(le,st.sibling),ne=C(st,ce.props),ne.ref=Yl(le,st,ce),ne.return=le,le=ne;break e}m(le,st);break}else l(le,st);st=st.sibling}ce.type===M?(ne=ja(ce.props.children,le.mode,Re,ce.key),ne.return=le,le=ne):(Re=Ru(ce.type,ce.key,ce.props,null,le.mode,Re),Re.ref=Yl(le,ne,ce),Re.return=le,le=Re)}return I(le);case _:e:{for(st=ce.key;ne!==null;){if(ne.key===st)if(ne.tag===4&&ne.stateNode.containerInfo===ce.containerInfo&&ne.stateNode.implementation===ce.implementation){m(le,ne.sibling),ne=C(ne,ce.children||[]),ne.return=le,le=ne;break e}else{m(le,ne);break}else l(le,ne);ne=ne.sibling}ne=Mp(ce,le.mode,Re),ne.return=le,le=ne}return I(le);case H:return st=ce._init,an(le,ne,st(ce._payload),Re)}if(Le(ce))return Qe(le,ne,ce,Re);if(G(ce))return Je(le,ne,ce,Re);iu(le,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,ne!==null&&ne.tag===6?(m(le,ne.sibling),ne=C(ne,ce),ne.return=le,le=ne):(m(le,ne),ne=Op(ce,le.mode,Re),ne.return=le,le=ne),I(le)):m(le,ne)}return an}var Ni=Tb(!0),Rb=Tb(!1),lu=xo(null),cu=null,Si=null,Hh=null;function Bh(){Hh=Si=cu=null}function Gh(a){var l=lu.current;qt(lu),a._currentValue=l}function qh(a,l,m){for(;a!==null;){var w=a.alternate;if((a.childLanes&l)!==l?(a.childLanes|=l,w!==null&&(w.childLanes|=l)):w!==null&&(w.childLanes&l)!==l&&(w.childLanes|=l),a===m)break;a=a.return}}function Ci(a,l){cu=a,Hh=Si=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&l)!==0&&(ls=!0),a.firstContext=null)}function Ms(a){var l=a._currentValue;if(Hh!==a)if(a={context:a,memoizedValue:l,next:null},Si===null){if(cu===null)throw Error(s(308));Si=a,cu.dependencies={lanes:0,firstContext:a}}else Si=Si.next=a;return l}var pa=null;function Kh(a){pa===null?pa=[a]:pa.push(a)}function Ab(a,l,m,w){var C=l.interleaved;return C===null?(m.next=m,Kh(l)):(m.next=C.next,C.next=m),l.interleaved=m,Ur(a,w)}function Ur(a,l){a.lanes|=l;var m=a.alternate;for(m!==null&&(m.lanes|=l),m=a,a=a.return;a!==null;)a.childLanes|=l,m=a.alternate,m!==null&&(m.childLanes|=l),m=a,a=a.return;return m.tag===3?m.stateNode:null}var bo=!1;function Vh(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ob(a,l){a=a.updateQueue,l.updateQueue===a&&(l.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function Wr(a,l){return{eventTime:a,lane:l,tag:0,payload:null,callback:null,next:null}}function wo(a,l,m){var w=a.updateQueue;if(w===null)return null;if(w=w.shared,(Ct&2)!==0){var C=w.pending;return C===null?l.next=l:(l.next=C.next,C.next=l),w.pending=l,Ur(a,m)}return C=w.interleaved,C===null?(l.next=l,Kh(w)):(l.next=C.next,C.next=l),w.interleaved=l,Ur(a,m)}function du(a,l,m){if(l=l.updateQueue,l!==null&&(l=l.shared,(m&4194240)!==0)){var w=l.lanes;w&=a.pendingLanes,m|=w,l.lanes=m,li(a,m)}}function Mb(a,l){var m=a.updateQueue,w=a.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},a.updateQueue=m;return}a=m.lastBaseUpdate,a===null?m.firstBaseUpdate=l:a.next=l,m.lastBaseUpdate=l}function uu(a,l,m,w){var C=a.updateQueue;bo=!1;var T=C.firstBaseUpdate,I=C.lastBaseUpdate,V=C.shared.pending;if(V!==null){C.shared.pending=null;var X=V,ue=X.next;X.next=null,I===null?T=ue:I.next=ue,I=X;var Ne=a.alternate;Ne!==null&&(Ne=Ne.updateQueue,V=Ne.lastBaseUpdate,V!==I&&(V===null?Ne.firstBaseUpdate=ue:V.next=ue,Ne.lastBaseUpdate=X))}if(T!==null){var Ce=C.baseState;I=0,Ne=ue=X=null,V=T;do{var je=V.lane,Ge=V.eventTime;if((w&je)===je){Ne!==null&&(Ne=Ne.next={eventTime:Ge,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var Qe=a,Je=V;switch(je=l,Ge=m,Je.tag){case 1:if(Qe=Je.payload,typeof Qe=="function"){Ce=Qe.call(Ge,Ce,je);break e}Ce=Qe;break e;case 3:Qe.flags=Qe.flags&-65537|128;case 0:if(Qe=Je.payload,je=typeof Qe=="function"?Qe.call(Ge,Ce,je):Qe,je==null)break e;Ce=F({},Ce,je);break e;case 2:bo=!0}}V.callback!==null&&V.lane!==0&&(a.flags|=64,je=C.effects,je===null?C.effects=[V]:je.push(V))}else Ge={eventTime:Ge,lane:je,tag:V.tag,payload:V.payload,callback:V.callback,next:null},Ne===null?(ue=Ne=Ge,X=Ce):Ne=Ne.next=Ge,I|=je;if(V=V.next,V===null){if(V=C.shared.pending,V===null)break;je=V,V=je.next,je.next=null,C.lastBaseUpdate=je,C.shared.pending=null}}while(!0);if(Ne===null&&(X=Ce),C.baseState=X,C.firstBaseUpdate=ue,C.lastBaseUpdate=Ne,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);va|=I,a.lanes=I,a.memoizedState=Ce}}function Pb(a,l,m){if(a=l.effects,l.effects=null,a!==null)for(l=0;l<a.length;l++){var w=a[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 Ql={},gr=xo(Ql),Jl=xo(Ql),Xl=xo(Ql);function ga(a){if(a===Ql)throw Error(s(174));return a}function Yh(a,l){switch(Ut(Xl,l),Ut(Jl,a),Ut(gr,Ql),a=l.nodeType,a){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:it(null,"");break;default:a=a===8?l.parentNode:l,l=a.namespaceURI||null,a=a.tagName,l=it(l,a)}qt(gr),Ut(gr,l)}function Ei(){qt(gr),qt(Jl),qt(Xl)}function Lb(a){ga(Xl.current);var l=ga(gr.current),m=it(l,a.type);l!==m&&(Ut(Jl,a),Ut(gr,m))}function Qh(a){Jl.current===a&&(qt(gr),qt(Jl))}var Zt=xo(0);function fu(a){for(var l=a;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===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Jh=[];function Xh(){for(var a=0;a<Jh.length;a++)Jh[a]._workInProgressVersionPrimary=null;Jh.length=0}var mu=N.ReactCurrentDispatcher,Zh=N.ReactCurrentBatchConfig,xa=0,en=null,vn=null,jn=null,hu=!1,Zl=!1,ec=0,$_=0;function Pn(){throw Error(s(321))}function ep(a,l){if(l===null)return!1;for(var m=0;m<l.length&&m<a.length;m++)if(!er(a[m],l[m]))return!1;return!0}function tp(a,l,m,w,C,T){if(xa=T,en=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,mu.current=a===null||a.memoizedState===null?A_:O_,a=m(w,C),Zl){T=0;do{if(Zl=!1,ec=0,25<=T)throw Error(s(301));T+=1,jn=vn=null,l.updateQueue=null,mu.current=M_,a=m(w,C)}while(Zl)}if(mu.current=xu,l=vn!==null&&vn.next!==null,xa=0,jn=vn=en=null,hu=!1,l)throw Error(s(300));return a}function np(){var a=ec!==0;return ec=0,a}function xr(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jn===null?en.memoizedState=jn=a:jn=jn.next=a,jn}function Ps(){if(vn===null){var a=en.alternate;a=a!==null?a.memoizedState:null}else a=vn.next;var l=jn===null?en.memoizedState:jn.next;if(l!==null)jn=l,vn=a;else{if(a===null)throw Error(s(310));vn=a,a={memoizedState:vn.memoizedState,baseState:vn.baseState,baseQueue:vn.baseQueue,queue:vn.queue,next:null},jn===null?en.memoizedState=jn=a:jn=jn.next=a}return jn}function tc(a,l){return typeof l=="function"?l(a):l}function sp(a){var l=Ps(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=a;var w=vn,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,ue=T;do{var Ne=ue.lane;if((xa&Ne)===Ne)X!==null&&(X=X.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),w=ue.hasEagerState?ue.eagerState:a(w,ue.action);else{var Ce={lane:Ne,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};X===null?(V=X=Ce,I=w):X=X.next=Ce,en.lanes|=Ne,va|=Ne}ue=ue.next}while(ue!==null&&ue!==T);X===null?I=w:X.next=V,er(w,l.memoizedState)||(ls=!0),l.memoizedState=w,l.baseState=I,l.baseQueue=X,m.lastRenderedState=w}if(a=m.interleaved,a!==null){C=a;do T=C.lane,en.lanes|=T,va|=T,C=C.next;while(C!==a)}else C===null&&(m.lanes=0);return[l.memoizedState,m.dispatch]}function rp(a){var l=Ps(),m=l.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=a;var w=m.dispatch,C=m.pending,T=l.memoizedState;if(C!==null){m.pending=null;var I=C=C.next;do T=a(T,I.action),I=I.next;while(I!==C);er(T,l.memoizedState)||(ls=!0),l.memoizedState=T,l.baseQueue===null&&(l.baseState=T),m.lastRenderedState=T}return[T,w]}function Ib(){}function zb(a,l){var m=en,w=Ps(),C=l(),T=!er(w.memoizedState,C);if(T&&(w.memoizedState=C,ls=!0),w=w.queue,op(Ub.bind(null,m,w,a),[a]),w.getSnapshot!==l||T||jn!==null&&jn.memoizedState.tag&1){if(m.flags|=2048,nc(9,Fb.bind(null,m,w,C,l),void 0,null),kn===null)throw Error(s(349));(xa&30)!==0||Db(m,l,C)}return C}function Db(a,l,m){a.flags|=16384,a={getSnapshot:l,value:m},l=en.updateQueue,l===null?(l={lastEffect:null,stores:null},en.updateQueue=l,l.stores=[a]):(m=l.stores,m===null?l.stores=[a]:m.push(a))}function Fb(a,l,m,w){l.value=m,l.getSnapshot=w,Wb(l)&&Hb(a)}function Ub(a,l,m){return m(function(){Wb(l)&&Hb(a)})}function Wb(a){var l=a.getSnapshot;a=a.value;try{var m=l();return!er(a,m)}catch{return!0}}function Hb(a){var l=Ur(a,1);l!==null&&or(l,a,1,-1)}function Bb(a){var l=xr();return typeof a=="function"&&(a=a()),l.memoizedState=l.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:tc,lastRenderedState:a},l.queue=a,a=a.dispatch=R_.bind(null,en,a),[l.memoizedState,a]}function nc(a,l,m,w){return a={tag:a,create:l,destroy:m,deps:w,next:null},l=en.updateQueue,l===null?(l={lastEffect:null,stores:null},en.updateQueue=l,l.lastEffect=a.next=a):(m=l.lastEffect,m===null?l.lastEffect=a.next=a:(w=m.next,m.next=a,a.next=w,l.lastEffect=a)),a}function Gb(){return Ps().memoizedState}function pu(a,l,m,w){var C=xr();en.flags|=a,C.memoizedState=nc(1|l,m,void 0,w===void 0?null:w)}function gu(a,l,m,w){var C=Ps();w=w===void 0?null:w;var T=void 0;if(vn!==null){var I=vn.memoizedState;if(T=I.destroy,w!==null&&ep(w,I.deps)){C.memoizedState=nc(l,m,T,w);return}}en.flags|=a,C.memoizedState=nc(1|l,m,T,w)}function qb(a,l){return pu(8390656,8,a,l)}function op(a,l){return gu(2048,8,a,l)}function Kb(a,l){return gu(4,2,a,l)}function Vb(a,l){return gu(4,4,a,l)}function Yb(a,l){if(typeof l=="function")return a=a(),l(a),function(){l(null)};if(l!=null)return a=a(),l.current=a,function(){l.current=null}}function Qb(a,l,m){return m=m!=null?m.concat([a]):null,gu(4,4,Yb.bind(null,l,a),m)}function ap(){}function Jb(a,l){var m=Ps();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&ep(l,w[1])?w[0]:(m.memoizedState=[a,l],a)}function Xb(a,l){var m=Ps();l=l===void 0?null:l;var w=m.memoizedState;return w!==null&&l!==null&&ep(l,w[1])?w[0]:(a=a(),m.memoizedState=[a,l],a)}function Zb(a,l,m){return(xa&21)===0?(a.baseState&&(a.baseState=!1,ls=!0),a.memoizedState=m):(er(m,l)||(m=Rl(),en.lanes|=m,va|=m,a.baseState=!0),l)}function __(a,l){var m=_t;_t=m!==0&&4>m?m:4,a(!0);var w=Zh.transition;Zh.transition={};try{a(!1),l()}finally{_t=m,Zh.transition=w}}function ew(){return Ps().memoizedState}function T_(a,l,m){var w=So(a);if(m={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null},tw(a))nw(l,m);else if(m=Ab(a,l,m,w),m!==null){var C=Vn();or(m,a,w,C),sw(m,l,w)}}function R_(a,l,m){var w=So(a),C={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null};if(tw(a))nw(l,C);else{var T=a.alternate;if(a.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,er(V,I)){var X=l.interleaved;X===null?(C.next=C,Kh(l)):(C.next=X.next,X.next=C),l.interleaved=C;return}}catch{}finally{}m=Ab(a,l,C,w),m!==null&&(C=Vn(),or(m,a,w,C),sw(m,l,w))}}function tw(a){var l=a.alternate;return a===en||l!==null&&l===en}function nw(a,l){Zl=hu=!0;var m=a.pending;m===null?l.next=l:(l.next=m.next,m.next=l),a.pending=l}function sw(a,l,m){if((m&4194240)!==0){var w=l.lanes;w&=a.pendingLanes,m|=w,l.lanes=m,li(a,m)}}var xu={readContext:Ms,useCallback:Pn,useContext:Pn,useEffect:Pn,useImperativeHandle:Pn,useInsertionEffect:Pn,useLayoutEffect:Pn,useMemo:Pn,useReducer:Pn,useRef:Pn,useState:Pn,useDebugValue:Pn,useDeferredValue:Pn,useTransition:Pn,useMutableSource:Pn,useSyncExternalStore:Pn,useId:Pn,unstable_isNewReconciler:!1},A_={readContext:Ms,useCallback:function(a,l){return xr().memoizedState=[a,l===void 0?null:l],a},useContext:Ms,useEffect:qb,useImperativeHandle:function(a,l,m){return m=m!=null?m.concat([a]):null,pu(4194308,4,Yb.bind(null,l,a),m)},useLayoutEffect:function(a,l){return pu(4194308,4,a,l)},useInsertionEffect:function(a,l){return pu(4,2,a,l)},useMemo:function(a,l){var m=xr();return l=l===void 0?null:l,a=a(),m.memoizedState=[a,l],a},useReducer:function(a,l,m){var w=xr();return l=m!==void 0?m(l):l,w.memoizedState=w.baseState=l,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:l},w.queue=a,a=a.dispatch=T_.bind(null,en,a),[w.memoizedState,a]},useRef:function(a){var l=xr();return a={current:a},l.memoizedState=a},useState:Bb,useDebugValue:ap,useDeferredValue:function(a){return xr().memoizedState=a},useTransition:function(){var a=Bb(!1),l=a[0];return a=__.bind(null,a[1]),xr().memoizedState=a,[l,a]},useMutableSource:function(){},useSyncExternalStore:function(a,l,m){var w=en,C=xr();if(Yt){if(m===void 0)throw Error(s(407));m=m()}else{if(m=l(),kn===null)throw Error(s(349));(xa&30)!==0||Db(w,l,m)}C.memoizedState=m;var T={value:m,getSnapshot:l};return C.queue=T,qb(Ub.bind(null,w,T,a),[a]),w.flags|=2048,nc(9,Fb.bind(null,w,T,m,l),void 0,null),m},useId:function(){var a=xr(),l=kn.identifierPrefix;if(Yt){var m=Fr,w=Dr;m=(w&~(1<<32-rs(w)-1)).toString(32)+m,l=":"+l+"R"+m,m=ec++,0<m&&(l+="H"+m.toString(32)),l+=":"}else m=$_++,l=":"+l+"r"+m.toString(32)+":";return a.memoizedState=l},unstable_isNewReconciler:!1},O_={readContext:Ms,useCallback:Jb,useContext:Ms,useEffect:op,useImperativeHandle:Qb,useInsertionEffect:Kb,useLayoutEffect:Vb,useMemo:Xb,useReducer:sp,useRef:Gb,useState:function(){return sp(tc)},useDebugValue:ap,useDeferredValue:function(a){var l=Ps();return Zb(l,vn.memoizedState,a)},useTransition:function(){var a=sp(tc)[0],l=Ps().memoizedState;return[a,l]},useMutableSource:Ib,useSyncExternalStore:zb,useId:ew,unstable_isNewReconciler:!1},M_={readContext:Ms,useCallback:Jb,useContext:Ms,useEffect:op,useImperativeHandle:Qb,useInsertionEffect:Kb,useLayoutEffect:Vb,useMemo:Xb,useReducer:rp,useRef:Gb,useState:function(){return rp(tc)},useDebugValue:ap,useDeferredValue:function(a){var l=Ps();return vn===null?l.memoizedState=a:Zb(l,vn.memoizedState,a)},useTransition:function(){var a=rp(tc)[0],l=Ps().memoizedState;return[a,l]},useMutableSource:Ib,useSyncExternalStore:zb,useId:ew,unstable_isNewReconciler:!1};function nr(a,l){if(a&&a.defaultProps){l=F({},l),a=a.defaultProps;for(var m in a)l[m]===void 0&&(l[m]=a[m]);return l}return l}function ip(a,l,m,w){l=a.memoizedState,m=m(w,l),m=m==null?l:F({},l,m),a.memoizedState=m,a.lanes===0&&(a.updateQueue.baseState=m)}var vu={isMounted:function(a){return(a=a._reactInternals)?Oe(a)===a:!1},enqueueSetState:function(a,l,m){a=a._reactInternals;var w=Vn(),C=So(a),T=Wr(w,C);T.payload=l,m!=null&&(T.callback=m),l=wo(a,T,C),l!==null&&(or(l,a,C,w),du(l,a,C))},enqueueReplaceState:function(a,l,m){a=a._reactInternals;var w=Vn(),C=So(a),T=Wr(w,C);T.tag=1,T.payload=l,m!=null&&(T.callback=m),l=wo(a,T,C),l!==null&&(or(l,a,C,w),du(l,a,C))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var m=Vn(),w=So(a),C=Wr(m,w);C.tag=2,l!=null&&(C.callback=l),l=wo(a,C,w),l!==null&&(or(l,a,w,m),du(l,a,w))}};function rw(a,l,m,w,C,T,I){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(w,T,I):l.prototype&&l.prototype.isPureReactComponent?!Wl(m,w)||!Wl(C,T):!0}function ow(a,l,m){var w=!1,C=vo,T=l.contextType;return typeof T=="object"&&T!==null?T=Ms(T):(C=is(l)?fa:Mn.current,w=l.contextTypes,T=(w=w!=null)?bi(a,C):vo),l=new l(m,T),a.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=vu,a.stateNode=l,l._reactInternals=a,w&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=C,a.__reactInternalMemoizedMaskedChildContext=T),l}function aw(a,l,m,w){a=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(m,w),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(m,w),l.state!==a&&vu.enqueueReplaceState(l,l.state,null)}function lp(a,l,m,w){var C=a.stateNode;C.props=m,C.state=a.memoizedState,C.refs={},Vh(a);var T=l.contextType;typeof T=="object"&&T!==null?C.context=Ms(T):(T=is(l)?fa:Mn.current,C.context=bi(a,T)),C.state=a.memoizedState,T=l.getDerivedStateFromProps,typeof T=="function"&&(ip(a,l,T,m),C.state=a.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&&vu.enqueueReplaceState(C,C.state,null),uu(a,m,C,w),C.state=a.memoizedState),typeof C.componentDidMount=="function"&&(a.flags|=4194308)}function $i(a,l){try{var m="",w=l;do m+=re(w),w=w.return;while(w);var C=m}catch(T){C=`
|
|
39
|
+
Error generating stack: `+T.message+`
|
|
40
|
+
`+T.stack}return{value:a,source:l,stack:C,digest:null}}function cp(a,l,m){return{value:a,source:null,stack:m??null,digest:l??null}}function dp(a,l){try{console.error(l.value)}catch(m){setTimeout(function(){throw m})}}var P_=typeof WeakMap=="function"?WeakMap:Map;function iw(a,l,m){m=Wr(-1,m),m.tag=3,m.payload={element:null};var w=l.value;return m.callback=function(){Su||(Su=!0,Sp=w),dp(a,l)},m}function lw(a,l,m){m=Wr(-1,m),m.tag=3;var w=a.type.getDerivedStateFromError;if(typeof w=="function"){var C=l.value;m.payload=function(){return w(C)},m.callback=function(){dp(a,l)}}var T=a.stateNode;return T!==null&&typeof T.componentDidCatch=="function"&&(m.callback=function(){dp(a,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 cw(a,l,m){var w=a.pingCache;if(w===null){w=a.pingCache=new P_;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),a=Y_.bind(null,a,l,m),l.then(a,a))}function dw(a){do{var l;if((l=a.tag===13)&&(l=a.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return a;a=a.return}while(a!==null);return null}function uw(a,l,m,w,C){return(a.mode&1)===0?(a===l?a.flags|=65536:(a.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(l=Wr(-1,1),l.tag=2,wo(m,l,1))),m.lanes|=1),a):(a.flags|=65536,a.lanes=C,a)}var L_=N.ReactCurrentOwner,ls=!1;function Kn(a,l,m,w){l.child=a===null?Rb(l,null,m,w):Ni(l,a.child,m,w)}function fw(a,l,m,w,C){m=m.render;var T=l.ref;return Ci(l,C),w=tp(a,l,m,w,T,C),m=np(),a!==null&&!ls?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~C,Hr(a,l,C)):(Yt&&m&&zh(l),l.flags|=1,Kn(a,l,w,C),l.child)}function mw(a,l,m,w,C){if(a===null){var T=m.type;return typeof T=="function"&&!Ap(T)&&T.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(l.tag=15,l.type=T,hw(a,l,T,w,C)):(a=Ru(m.type,null,w,l,l.mode,C),a.ref=l.ref,a.return=l,l.child=a)}if(T=a.child,(a.lanes&C)===0){var I=T.memoizedProps;if(m=m.compare,m=m!==null?m:Wl,m(I,w)&&a.ref===l.ref)return Hr(a,l,C)}return l.flags|=1,a=Eo(T,w),a.ref=l.ref,a.return=l,l.child=a}function hw(a,l,m,w,C){if(a!==null){var T=a.memoizedProps;if(Wl(T,w)&&a.ref===l.ref)if(ls=!1,l.pendingProps=w=T,(a.lanes&C)!==0)(a.flags&131072)!==0&&(ls=!0);else return l.lanes=a.lanes,Hr(a,l,C)}return up(a,l,m,w,C)}function pw(a,l,m){var w=l.pendingProps,C=w.children,T=a!==null?a.memoizedState:null;if(w.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ut(Ti,js),js|=m;else{if((m&1073741824)===0)return a=T!==null?T.baseLanes|m:m,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:a,cachePool:null,transitions:null},l.updateQueue=null,Ut(Ti,js),js|=a,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=T!==null?T.baseLanes:m,Ut(Ti,js),js|=w}else T!==null?(w=T.baseLanes|m,l.memoizedState=null):w=m,Ut(Ti,js),js|=w;return Kn(a,l,C,m),l.child}function gw(a,l){var m=l.ref;(a===null&&m!==null||a!==null&&a.ref!==m)&&(l.flags|=512,l.flags|=2097152)}function up(a,l,m,w,C){var T=is(m)?fa:Mn.current;return T=bi(l,T),Ci(l,C),m=tp(a,l,m,w,T,C),w=np(),a!==null&&!ls?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~C,Hr(a,l,C)):(Yt&&w&&zh(l),l.flags|=1,Kn(a,l,m,C),l.child)}function xw(a,l,m,w,C){if(is(m)){var T=!0;nu(l)}else T=!1;if(Ci(l,C),l.stateNode===null)bu(a,l),ow(l,m,w),lp(l,m,w,C),w=!0;else if(a===null){var I=l.stateNode,V=l.memoizedProps;I.props=V;var X=I.context,ue=m.contextType;typeof ue=="object"&&ue!==null?ue=Ms(ue):(ue=is(m)?fa:Mn.current,ue=bi(l,ue));var Ne=m.getDerivedStateFromProps,Ce=typeof Ne=="function"||typeof I.getSnapshotBeforeUpdate=="function";Ce||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==w||X!==ue)&&aw(l,I,w,ue),bo=!1;var je=l.memoizedState;I.state=je,uu(l,w,I,C),X=l.memoizedState,V!==w||je!==X||as.current||bo?(typeof Ne=="function"&&(ip(l,m,Ne,w),X=l.memoizedState),(V=bo||rw(l,m,V,w,je,X,ue))?(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=ue,w=V):(typeof I.componentDidMount=="function"&&(l.flags|=4194308),w=!1)}else{I=l.stateNode,Ob(a,l),V=l.memoizedProps,ue=l.type===l.elementType?V:nr(l.type,V),I.props=ue,Ce=l.pendingProps,je=I.context,X=m.contextType,typeof X=="object"&&X!==null?X=Ms(X):(X=is(m)?fa:Mn.current,X=bi(l,X));var Ge=m.getDerivedStateFromProps;(Ne=typeof Ge=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(V!==Ce||je!==X)&&aw(l,I,w,X),bo=!1,je=l.memoizedState,I.state=je,uu(l,w,I,C);var Qe=l.memoizedState;V!==Ce||je!==Qe||as.current||bo?(typeof Ge=="function"&&(ip(l,m,Ge,w),Qe=l.memoizedState),(ue=bo||rw(l,m,ue,w,je,Qe,X)||!1)?(Ne||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(w,Qe,X),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(w,Qe,X)),typeof I.componentDidUpdate=="function"&&(l.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof I.componentDidUpdate!="function"||V===a.memoizedProps&&je===a.memoizedState||(l.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===a.memoizedProps&&je===a.memoizedState||(l.flags|=1024),l.memoizedProps=w,l.memoizedState=Qe),I.props=w,I.state=Qe,I.context=X,w=ue):(typeof I.componentDidUpdate!="function"||V===a.memoizedProps&&je===a.memoizedState||(l.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||V===a.memoizedProps&&je===a.memoizedState||(l.flags|=1024),w=!1)}return fp(a,l,m,w,T,C)}function fp(a,l,m,w,C,T){gw(a,l);var I=(l.flags&128)!==0;if(!w&&!I)return C&&jb(l,m,!1),Hr(a,l,T);w=l.stateNode,L_.current=l;var V=I&&typeof m.getDerivedStateFromError!="function"?null:w.render();return l.flags|=1,a!==null&&I?(l.child=Ni(l,a.child,null,T),l.child=Ni(l,null,V,T)):Kn(a,l,V,T),l.memoizedState=w.state,C&&jb(l,m,!0),l.child}function vw(a){var l=a.stateNode;l.pendingContext?bb(a,l.pendingContext,l.pendingContext!==l.context):l.context&&bb(a,l.context,!1),Yh(a,l.containerInfo)}function yw(a,l,m,w,C){return ki(),Wh(C),l.flags|=256,Kn(a,l,m,w),l.child}var mp={dehydrated:null,treeContext:null,retryLane:0};function hp(a){return{baseLanes:a,cachePool:null,transitions:null}}function bw(a,l,m){var w=l.pendingProps,C=Zt.current,T=!1,I=(l.flags&128)!==0,V;if((V=I)||(V=a!==null&&a.memoizedState===null?!1:(C&2)!==0),V?(T=!0,l.flags&=-129):(a===null||a.memoizedState!==null)&&(C|=1),Ut(Zt,C&1),a===null)return Uh(l),a=l.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((l.mode&1)===0?l.lanes=1:a.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(I=w.children,a=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=Au(I,w,0,null),a=ja(a,w,m,null),T.return=l,a.return=l,T.sibling=a,l.child=T,l.child.memoizedState=hp(m),l.memoizedState=mp,a):pp(l,I));if(C=a.memoizedState,C!==null&&(V=C.dehydrated,V!==null))return I_(a,l,I,w,V,C,m);if(T){T=w.fallback,I=l.mode,C=a.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=ja(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=a.child.memoizedState,I=I===null?hp(m):{baseLanes:I.baseLanes|m,cachePool:null,transitions:I.transitions},T.memoizedState=I,T.childLanes=a.childLanes&~m,l.memoizedState=mp,w}return T=a.child,a=T.sibling,w=Eo(T,{mode:"visible",children:w.children}),(l.mode&1)===0&&(w.lanes=m),w.return=l,w.sibling=null,a!==null&&(m=l.deletions,m===null?(l.deletions=[a],l.flags|=16):m.push(a)),l.child=w,l.memoizedState=null,w}function pp(a,l){return l=Au({mode:"visible",children:l},a.mode,0,null),l.return=a,a.child=l}function yu(a,l,m,w){return w!==null&&Wh(w),Ni(l,a.child,null,m),a=pp(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function I_(a,l,m,w,C,T,I){if(m)return l.flags&256?(l.flags&=-257,w=cp(Error(s(422))),yu(a,l,I,w)):l.memoizedState!==null?(l.child=a.child,l.flags|=128,null):(T=w.fallback,C=l.mode,w=Au({mode:"visible",children:w.children},C,0,null),T=ja(T,C,I,null),T.flags|=2,w.return=l,T.return=l,w.sibling=T,l.child=w,(l.mode&1)!==0&&Ni(l,a.child,null,I),l.child.memoizedState=hp(I),l.memoizedState=mp,T);if((l.mode&1)===0)return yu(a,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=cp(T,w,void 0),yu(a,l,I,w)}if(V=(I&a.childLanes)!==0,ls||V){if(w=kn,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,Ur(a,C),or(w,a,C,-1))}return Rp(),w=cp(Error(s(421))),yu(a,l,I,w)}return C.data==="$?"?(l.flags|=128,l.child=a.child,l=Q_.bind(null,a),C._reactRetry=l,null):(a=T.treeContext,ws=go(C.nextSibling),bs=l,Yt=!0,tr=null,a!==null&&(As[Os++]=Dr,As[Os++]=Fr,As[Os++]=ma,Dr=a.id,Fr=a.overflow,ma=l),l=pp(l,w.children),l.flags|=4096,l)}function ww(a,l,m){a.lanes|=l;var w=a.alternate;w!==null&&(w.lanes|=l),qh(a.return,l,m)}function gp(a,l,m,w,C){var T=a.memoizedState;T===null?a.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 jw(a,l,m){var w=l.pendingProps,C=w.revealOrder,T=w.tail;if(Kn(a,l,w.children,m),w=Zt.current,(w&2)!==0)w=w&1|2,l.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=l.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&ww(a,m,l);else if(a.tag===19)ww(a,m,l);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===l)break e;for(;a.sibling===null;){if(a.return===null||a.return===l)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}w&=1}if(Ut(Zt,w),(l.mode&1)===0)l.memoizedState=null;else switch(C){case"forwards":for(m=l.child,C=null;m!==null;)a=m.alternate,a!==null&&fu(a)===null&&(C=m),m=m.sibling;m=C,m===null?(C=l.child,l.child=null):(C=m.sibling,m.sibling=null),gp(l,!1,C,m,T);break;case"backwards":for(m=null,C=l.child,l.child=null;C!==null;){if(a=C.alternate,a!==null&&fu(a)===null){l.child=C;break}a=C.sibling,C.sibling=m,m=C,C=a}gp(l,!0,m,null,T);break;case"together":gp(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function bu(a,l){(l.mode&1)===0&&a!==null&&(a.alternate=null,l.alternate=null,l.flags|=2)}function Hr(a,l,m){if(a!==null&&(l.dependencies=a.dependencies),va|=l.lanes,(m&l.childLanes)===0)return null;if(a!==null&&l.child!==a.child)throw Error(s(153));if(l.child!==null){for(a=l.child,m=Eo(a,a.pendingProps),l.child=m,m.return=l;a.sibling!==null;)a=a.sibling,m=m.sibling=Eo(a,a.pendingProps),m.return=l;m.sibling=null}return l.child}function z_(a,l,m){switch(l.tag){case 3:vw(l),ki();break;case 5:Lb(l);break;case 1:is(l.type)&&nu(l);break;case 4:Yh(l,l.stateNode.containerInfo);break;case 10:var w=l.type._context,C=l.memoizedProps.value;Ut(lu,w._currentValue),w._currentValue=C;break;case 13:if(w=l.memoizedState,w!==null)return w.dehydrated!==null?(Ut(Zt,Zt.current&1),l.flags|=128,null):(m&l.child.childLanes)!==0?bw(a,l,m):(Ut(Zt,Zt.current&1),a=Hr(a,l,m),a!==null?a.sibling:null);Ut(Zt,Zt.current&1);break;case 19:if(w=(m&l.childLanes)!==0,(a.flags&128)!==0){if(w)return jw(a,l,m);l.flags|=128}if(C=l.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),Ut(Zt,Zt.current),w)break;return null;case 22:case 23:return l.lanes=0,pw(a,l,m)}return Hr(a,l,m)}var kw,xp,Nw,Sw;kw=function(a,l){for(var m=l.child;m!==null;){if(m.tag===5||m.tag===6)a.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}},xp=function(){},Nw=function(a,l,m,w){var C=a.memoizedProps;if(C!==w){a=l.stateNode,ga(gr.current);var T=null;switch(m){case"input":C=Pe(a,C),w=Pe(a,w),T=[];break;case"select":C=F({},C,{value:void 0}),w=F({},w,{value:void 0}),T=[];break;case"textarea":C=yt(a,C),w=yt(a,w),T=[];break;default:typeof C.onClick!="function"&&typeof w.onClick=="function"&&(a.onclick=Zd)}Xe(m,w);var I;m=null;for(ue in C)if(!w.hasOwnProperty(ue)&&C.hasOwnProperty(ue)&&C[ue]!=null)if(ue==="style"){var V=C[ue];for(I in V)V.hasOwnProperty(I)&&(m||(m={}),m[I]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(o.hasOwnProperty(ue)?T||(T=[]):(T=T||[]).push(ue,null));for(ue in w){var X=w[ue];if(V=C!=null?C[ue]:void 0,w.hasOwnProperty(ue)&&X!==V&&(X!=null||V!=null))if(ue==="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(ue,m)),m=X;else ue==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,V=V?V.__html:void 0,X!=null&&V!==X&&(T=T||[]).push(ue,X)):ue==="children"?typeof X!="string"&&typeof X!="number"||(T=T||[]).push(ue,""+X):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(o.hasOwnProperty(ue)?(X!=null&&ue==="onScroll"&&Gt("scroll",a),T||V===X||(T=[])):(T=T||[]).push(ue,X))}m&&(T=T||[]).push("style",m);var ue=T;(l.updateQueue=ue)&&(l.flags|=4)}},Sw=function(a,l,m,w){m!==w&&(l.flags|=4)};function sc(a,l){if(!Yt)switch(a.tailMode){case"hidden":l=a.tail;for(var m=null;l!==null;)l.alternate!==null&&(m=l),l=l.sibling;m===null?a.tail=null:m.sibling=null;break;case"collapsed":m=a.tail;for(var w=null;m!==null;)m.alternate!==null&&(w=m),m=m.sibling;w===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:w.sibling=null}}function Ln(a){var l=a.alternate!==null&&a.alternate.child===a.child,m=0,w=0;if(l)for(var C=a.child;C!==null;)m|=C.lanes|C.childLanes,w|=C.subtreeFlags&14680064,w|=C.flags&14680064,C.return=a,C=C.sibling;else for(C=a.child;C!==null;)m|=C.lanes|C.childLanes,w|=C.subtreeFlags,w|=C.flags,C.return=a,C=C.sibling;return a.subtreeFlags|=w,a.childLanes=m,l}function D_(a,l,m){var w=l.pendingProps;switch(Dh(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ln(l),null;case 1:return is(l.type)&&tu(),Ln(l),null;case 3:return w=l.stateNode,Ei(),qt(as),qt(Mn),Xh(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(a===null||a.child===null)&&(au(l)?l.flags|=4:a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,tr!==null&&($p(tr),tr=null))),xp(a,l),Ln(l),null;case 5:Qh(l);var C=ga(Xl.current);if(m=l.type,a!==null&&l.stateNode!=null)Nw(a,l,m,w,C),a.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!w){if(l.stateNode===null)throw Error(s(166));return Ln(l),null}if(a=ga(gr.current),au(l)){w=l.stateNode,m=l.type;var T=l.memoizedProps;switch(w[pr]=l,w[Kl]=T,a=(l.mode&1)!==0,m){case"dialog":Gt("cancel",w),Gt("close",w);break;case"iframe":case"object":case"embed":Gt("load",w);break;case"video":case"audio":for(C=0;C<Bl.length;C++)Gt(Bl[C],w);break;case"source":Gt("error",w);break;case"img":case"image":case"link":Gt("error",w),Gt("load",w);break;case"details":Gt("toggle",w);break;case"input":Ee(w,T),Gt("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!T.multiple},Gt("invalid",w);break;case"textarea":oe(w,T),Gt("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&&Xd(w.textContent,V,a),C=["children",V]):typeof V=="number"&&w.textContent!==""+V&&(T.suppressHydrationWarning!==!0&&Xd(w.textContent,V,a),C=["children",""+V]):o.hasOwnProperty(I)&&V!=null&&I==="onScroll"&&Gt("scroll",w)}switch(m){case"input":fe(w),ot(w,T,!0);break;case"textarea":fe(w),tt(w);break;case"select":case"option":break;default:typeof T.onClick=="function"&&(w.onclick=Zd)}w=C,l.updateQueue=w,w!==null&&(l.flags|=4)}else{I=C.nodeType===9?C:C.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=Ae(m)),a==="http://www.w3.org/1999/xhtml"?m==="script"?(a=I.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof w.is=="string"?a=I.createElement(m,{is:w.is}):(a=I.createElement(m),m==="select"&&(I=a,w.multiple?I.multiple=!0:w.size&&(I.size=w.size))):a=I.createElementNS(a,m),a[pr]=l,a[Kl]=w,kw(a,l,!1,!1),l.stateNode=a;e:{switch(I=at(m,w),m){case"dialog":Gt("cancel",a),Gt("close",a),C=w;break;case"iframe":case"object":case"embed":Gt("load",a),C=w;break;case"video":case"audio":for(C=0;C<Bl.length;C++)Gt(Bl[C],a);C=w;break;case"source":Gt("error",a),C=w;break;case"img":case"image":case"link":Gt("error",a),Gt("load",a),C=w;break;case"details":Gt("toggle",a),C=w;break;case"input":Ee(a,w),C=Pe(a,w),Gt("invalid",a);break;case"option":C=w;break;case"select":a._wrapperState={wasMultiple:!!w.multiple},C=F({},w,{value:void 0}),Gt("invalid",a);break;case"textarea":oe(a,w),C=yt(a,w),Gt("invalid",a);break;default:C=w}Xe(m,C),V=C;for(T in V)if(V.hasOwnProperty(T)){var X=V[T];T==="style"?de(a,X):T==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,X!=null&&nt(a,X)):T==="children"?typeof X=="string"?(m!=="textarea"||X!=="")&&ft(a,X):typeof X=="number"&&ft(a,""+X):T!=="suppressContentEditableWarning"&&T!=="suppressHydrationWarning"&&T!=="autoFocus"&&(o.hasOwnProperty(T)?X!=null&&T==="onScroll"&&Gt("scroll",a):X!=null&&S(a,T,X,I))}switch(m){case"input":fe(a),ot(a,w,!1);break;case"textarea":fe(a),tt(a);break;case"option":w.value!=null&&a.setAttribute("value",""+ge(w.value));break;case"select":a.multiple=!!w.multiple,T=w.value,T!=null?Ze(a,!!w.multiple,T,!1):w.defaultValue!=null&&Ze(a,!!w.multiple,w.defaultValue,!0);break;default:typeof C.onClick=="function"&&(a.onclick=Zd)}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 Ln(l),null;case 6:if(a&&l.stateNode!=null)Sw(a,l,a.memoizedProps,w);else{if(typeof w!="string"&&l.stateNode===null)throw Error(s(166));if(m=ga(Xl.current),ga(gr.current),au(l)){if(w=l.stateNode,m=l.memoizedProps,w[pr]=l,(T=w.nodeValue!==m)&&(a=bs,a!==null))switch(a.tag){case 3:Xd(w.nodeValue,m,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&Xd(w.nodeValue,m,(a.mode&1)!==0)}T&&(l.flags|=4)}else w=(m.nodeType===9?m:m.ownerDocument).createTextNode(w),w[pr]=l,l.stateNode=w}return Ln(l),null;case 13:if(qt(Zt),w=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(Yt&&ws!==null&&(l.mode&1)!==0&&(l.flags&128)===0)$b(),ki(),l.flags|=98560,T=!1;else if(T=au(l),w!==null&&w.dehydrated!==null){if(a===null){if(!T)throw Error(s(318));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(s(317));T[pr]=l}else ki(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Ln(l),T=!1}else tr!==null&&($p(tr),tr=null),T=!0;if(!T)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=m,l):(w=w!==null,w!==(a!==null&&a.memoizedState!==null)&&w&&(l.child.flags|=8192,(l.mode&1)!==0&&(a===null||(Zt.current&1)!==0?yn===0&&(yn=3):Rp())),l.updateQueue!==null&&(l.flags|=4),Ln(l),null);case 4:return Ei(),xp(a,l),a===null&&Gl(l.stateNode.containerInfo),Ln(l),null;case 10:return Gh(l.type._context),Ln(l),null;case 17:return is(l.type)&&tu(),Ln(l),null;case 19:if(qt(Zt),T=l.memoizedState,T===null)return Ln(l),null;if(w=(l.flags&128)!==0,I=T.rendering,I===null)if(w)sc(T,!1);else{if(yn!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(I=fu(a),I!==null){for(l.flags|=128,sc(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,a=w,T.flags&=14680066,I=T.alternate,I===null?(T.childLanes=0,T.lanes=a,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,a=I.dependencies,T.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),m=m.sibling;return Ut(Zt,Zt.current&1|2),l.child}a=a.sibling}T.tail!==null&&ct()>Ri&&(l.flags|=128,w=!0,sc(T,!1),l.lanes=4194304)}else{if(!w)if(a=fu(I),a!==null){if(l.flags|=128,w=!0,m=a.updateQueue,m!==null&&(l.updateQueue=m,l.flags|=4),sc(T,!0),T.tail===null&&T.tailMode==="hidden"&&!I.alternate&&!Yt)return Ln(l),null}else 2*ct()-T.renderingStartTime>Ri&&m!==1073741824&&(l.flags|=128,w=!0,sc(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=ct(),l.sibling=null,m=Zt.current,Ut(Zt,w?m&1|2:m&1),l):(Ln(l),null);case 22:case 23:return Tp(),w=l.memoizedState!==null,a!==null&&a.memoizedState!==null!==w&&(l.flags|=8192),w&&(l.mode&1)!==0?(js&1073741824)!==0&&(Ln(l),l.subtreeFlags&6&&(l.flags|=8192)):Ln(l),null;case 24:return null;case 25:return null}throw Error(s(156,l.tag))}function F_(a,l){switch(Dh(l),l.tag){case 1:return is(l.type)&&tu(),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return Ei(),qt(as),qt(Mn),Xh(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 5:return Qh(l),null;case 13:if(qt(Zt),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(s(340));ki()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return qt(Zt),null;case 4:return Ei(),null;case 10:return Gh(l.type._context),null;case 22:case 23:return Tp(),null;case 24:return null;default:return null}}var wu=!1,In=!1,U_=typeof WeakSet=="function"?WeakSet:Set,Ye=null;function _i(a,l){var m=a.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(w){rn(a,l,w)}else m.current=null}function vp(a,l,m){try{m()}catch(w){rn(a,l,w)}}var Cw=!1;function W_(a,l){if(Th=Lr,a=rb(),jh(a)){if("selectionStart"in a)var m={start:a.selectionStart,end:a.selectionEnd};else e:{m=(m=a.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,ue=0,Ne=0,Ce=a,je=null;t:for(;;){for(var Ge;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),(Ge=Ce.firstChild)!==null;)je=Ce,Ce=Ge;for(;;){if(Ce===a)break t;if(je===m&&++ue===C&&(V=I),je===T&&++Ne===w&&(X=I),(Ge=Ce.nextSibling)!==null)break;Ce=je,je=Ce.parentNode}Ce=Ge}m=V===-1||X===-1?null:{start:V,end:X}}else m=null}m=m||{start:0,end:0}}else m=null;for(Rh={focusedElem:a,selectionRange:m},Lr=!1,Ye=l;Ye!==null;)if(l=Ye,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,Ye=a;else for(;Ye!==null;){l=Ye;try{var Qe=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Qe!==null){var Je=Qe.memoizedProps,an=Qe.memoizedState,le=l.stateNode,ne=le.getSnapshotBeforeUpdate(l.elementType===l.type?Je:nr(l.type,Je),an);le.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var ce=l.stateNode.containerInfo;ce.nodeType===1?ce.textContent="":ce.nodeType===9&&ce.documentElement&&ce.removeChild(ce.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(Re){rn(l,l.return,Re)}if(a=l.sibling,a!==null){a.return=l.return,Ye=a;break}Ye=l.return}return Qe=Cw,Cw=!1,Qe}function rc(a,l,m){var w=l.updateQueue;if(w=w!==null?w.lastEffect:null,w!==null){var C=w=w.next;do{if((C.tag&a)===a){var T=C.destroy;C.destroy=void 0,T!==void 0&&vp(l,m,T)}C=C.next}while(C!==w)}}function ju(a,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var m=l=l.next;do{if((m.tag&a)===a){var w=m.create;m.destroy=w()}m=m.next}while(m!==l)}}function yp(a){var l=a.ref;if(l!==null){var m=a.stateNode;switch(a.tag){case 5:a=m;break;default:a=m}typeof l=="function"?l(a):l.current=a}}function Ew(a){var l=a.alternate;l!==null&&(a.alternate=null,Ew(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&(delete l[pr],delete l[Kl],delete l[Ph],delete l[N_],delete l[S_])),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}function $w(a){return a.tag===5||a.tag===3||a.tag===4}function _w(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||$w(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function bp(a,l,m){var w=a.tag;if(w===5||w===6)a=a.stateNode,l?m.nodeType===8?m.parentNode.insertBefore(a,l):m.insertBefore(a,l):(m.nodeType===8?(l=m.parentNode,l.insertBefore(a,m)):(l=m,l.appendChild(a)),m=m._reactRootContainer,m!=null||l.onclick!==null||(l.onclick=Zd));else if(w!==4&&(a=a.child,a!==null))for(bp(a,l,m),a=a.sibling;a!==null;)bp(a,l,m),a=a.sibling}function wp(a,l,m){var w=a.tag;if(w===5||w===6)a=a.stateNode,l?m.insertBefore(a,l):m.appendChild(a);else if(w!==4&&(a=a.child,a!==null))for(wp(a,l,m),a=a.sibling;a!==null;)wp(a,l,m),a=a.sibling}var Tn=null,sr=!1;function jo(a,l,m){for(m=m.child;m!==null;)Tw(a,l,m),m=m.sibling}function Tw(a,l,m){if(vs&&typeof vs.onCommitFiberUnmount=="function")try{vs.onCommitFiberUnmount(aa,m)}catch{}switch(m.tag){case 5:In||_i(m,l);case 6:var w=Tn,C=sr;Tn=null,jo(a,l,m),Tn=w,sr=C,Tn!==null&&(sr?(a=Tn,m=m.stateNode,a.nodeType===8?a.parentNode.removeChild(m):a.removeChild(m)):Tn.removeChild(m.stateNode));break;case 18:Tn!==null&&(sr?(a=Tn,m=m.stateNode,a.nodeType===8?Mh(a.parentNode,m):a.nodeType===1&&Mh(a,m),fo(a)):Mh(Tn,m.stateNode));break;case 4:w=Tn,C=sr,Tn=m.stateNode.containerInfo,sr=!0,jo(a,l,m),Tn=w,sr=C;break;case 0:case 11:case 14:case 15:if(!In&&(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)&&vp(m,l,I),C=C.next}while(C!==w)}jo(a,l,m);break;case 1:if(!In&&(_i(m,l),w=m.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=m.memoizedProps,w.state=m.memoizedState,w.componentWillUnmount()}catch(V){rn(m,l,V)}jo(a,l,m);break;case 21:jo(a,l,m);break;case 22:m.mode&1?(In=(w=In)||m.memoizedState!==null,jo(a,l,m),In=w):jo(a,l,m);break;default:jo(a,l,m)}}function Rw(a){var l=a.updateQueue;if(l!==null){a.updateQueue=null;var m=a.stateNode;m===null&&(m=a.stateNode=new U_),l.forEach(function(w){var C=J_.bind(null,a,w);m.has(w)||(m.add(w),w.then(C,C))})}}function rr(a,l){var m=l.deletions;if(m!==null)for(var w=0;w<m.length;w++){var C=m[w];try{var T=a,I=l,V=I;e:for(;V!==null;){switch(V.tag){case 5:Tn=V.stateNode,sr=!1;break e;case 3:Tn=V.stateNode.containerInfo,sr=!0;break e;case 4:Tn=V.stateNode.containerInfo,sr=!0;break e}V=V.return}if(Tn===null)throw Error(s(160));Tw(T,I,C),Tn=null,sr=!1;var X=C.alternate;X!==null&&(X.return=null),C.return=null}catch(ue){rn(C,l,ue)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)Aw(l,a),l=l.sibling}function Aw(a,l){var m=a.alternate,w=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(rr(l,a),vr(a),w&4){try{rc(3,a,a.return),ju(3,a)}catch(Je){rn(a,a.return,Je)}try{rc(5,a,a.return)}catch(Je){rn(a,a.return,Je)}}break;case 1:rr(l,a),vr(a),w&512&&m!==null&&_i(m,m.return);break;case 5:if(rr(l,a),vr(a),w&512&&m!==null&&_i(m,m.return),a.flags&32){var C=a.stateNode;try{ft(C,"")}catch(Je){rn(a,a.return,Je)}}if(w&4&&(C=a.stateNode,C!=null)){var T=a.memoizedProps,I=m!==null?m.memoizedProps:T,V=a.type,X=a.updateQueue;if(a.updateQueue=null,X!==null)try{V==="input"&&T.type==="radio"&&T.name!=null&&ae(C,T),at(V,I);var ue=at(V,T);for(I=0;I<X.length;I+=2){var Ne=X[I],Ce=X[I+1];Ne==="style"?de(C,Ce):Ne==="dangerouslySetInnerHTML"?nt(C,Ce):Ne==="children"?ft(C,Ce):S(C,Ne,Ce,ue)}switch(V){case"input":$e(C,T);break;case"textarea":Se(C,T);break;case"select":var je=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!T.multiple;var Ge=T.value;Ge!=null?Ze(C,!!T.multiple,Ge,!1):je!==!!T.multiple&&(T.defaultValue!=null?Ze(C,!!T.multiple,T.defaultValue,!0):Ze(C,!!T.multiple,T.multiple?[]:"",!1))}C[Kl]=T}catch(Je){rn(a,a.return,Je)}}break;case 6:if(rr(l,a),vr(a),w&4){if(a.stateNode===null)throw Error(s(162));C=a.stateNode,T=a.memoizedProps;try{C.nodeValue=T}catch(Je){rn(a,a.return,Je)}}break;case 3:if(rr(l,a),vr(a),w&4&&m!==null&&m.memoizedState.isDehydrated)try{fo(l.containerInfo)}catch(Je){rn(a,a.return,Je)}break;case 4:rr(l,a),vr(a);break;case 13:rr(l,a),vr(a),C=a.child,C.flags&8192&&(T=C.memoizedState!==null,C.stateNode.isHidden=T,!T||C.alternate!==null&&C.alternate.memoizedState!==null||(Np=ct())),w&4&&Rw(a);break;case 22:if(Ne=m!==null&&m.memoizedState!==null,a.mode&1?(In=(ue=In)||Ne,rr(l,a),In=ue):rr(l,a),vr(a),w&8192){if(ue=a.memoizedState!==null,(a.stateNode.isHidden=ue)&&!Ne&&(a.mode&1)!==0)for(Ye=a,Ne=a.child;Ne!==null;){for(Ce=Ye=Ne;Ye!==null;){switch(je=Ye,Ge=je.child,je.tag){case 0:case 11:case 14:case 15:rc(4,je,je.return);break;case 1:_i(je,je.return);var Qe=je.stateNode;if(typeof Qe.componentWillUnmount=="function"){w=je,m=je.return;try{l=w,Qe.props=l.memoizedProps,Qe.state=l.memoizedState,Qe.componentWillUnmount()}catch(Je){rn(w,m,Je)}}break;case 5:_i(je,je.return);break;case 22:if(je.memoizedState!==null){Pw(Ce);continue}}Ge!==null?(Ge.return=je,Ye=Ge):Pw(Ce)}Ne=Ne.sibling}e:for(Ne=null,Ce=a;;){if(Ce.tag===5){if(Ne===null){Ne=Ce;try{C=Ce.stateNode,ue?(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(Je){rn(a,a.return,Je)}}}else if(Ce.tag===6){if(Ne===null)try{Ce.stateNode.nodeValue=ue?"":Ce.memoizedProps}catch(Je){rn(a,a.return,Je)}}else if((Ce.tag!==22&&Ce.tag!==23||Ce.memoizedState===null||Ce===a)&&Ce.child!==null){Ce.child.return=Ce,Ce=Ce.child;continue}if(Ce===a)break e;for(;Ce.sibling===null;){if(Ce.return===null||Ce.return===a)break e;Ne===Ce&&(Ne=null),Ce=Ce.return}Ne===Ce&&(Ne=null),Ce.sibling.return=Ce.return,Ce=Ce.sibling}}break;case 19:rr(l,a),vr(a),w&4&&Rw(a);break;case 21:break;default:rr(l,a),vr(a)}}function vr(a){var l=a.flags;if(l&2){try{e:{for(var m=a.return;m!==null;){if($w(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=_w(a);wp(a,T,C);break;case 3:case 4:var I=w.stateNode.containerInfo,V=_w(a);bp(a,V,I);break;default:throw Error(s(161))}}catch(X){rn(a,a.return,X)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function H_(a,l,m){Ye=a,Ow(a)}function Ow(a,l,m){for(var w=(a.mode&1)!==0;Ye!==null;){var C=Ye,T=C.child;if(C.tag===22&&w){var I=C.memoizedState!==null||wu;if(!I){var V=C.alternate,X=V!==null&&V.memoizedState!==null||In;V=wu;var ue=In;if(wu=I,(In=X)&&!ue)for(Ye=C;Ye!==null;)I=Ye,X=I.child,I.tag===22&&I.memoizedState!==null?Lw(C):X!==null?(X.return=I,Ye=X):Lw(C);for(;T!==null;)Ye=T,Ow(T),T=T.sibling;Ye=C,wu=V,In=ue}Mw(a)}else(C.subtreeFlags&8772)!==0&&T!==null?(T.return=C,Ye=T):Mw(a)}}function Mw(a){for(;Ye!==null;){var l=Ye;if((l.flags&8772)!==0){var m=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:In||ju(5,l);break;case 1:var w=l.stateNode;if(l.flags&4&&!In)if(m===null)w.componentDidMount();else{var C=l.elementType===l.type?m.memoizedProps:nr(l.type,m.memoizedProps);w.componentDidUpdate(C,m.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var T=l.updateQueue;T!==null&&Pb(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}Pb(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 ue=l.alternate;if(ue!==null){var Ne=ue.memoizedState;if(Ne!==null){var Ce=Ne.dehydrated;Ce!==null&&fo(Ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}In||l.flags&512&&yp(l)}catch(je){rn(l,l.return,je)}}if(l===a){Ye=null;break}if(m=l.sibling,m!==null){m.return=l.return,Ye=m;break}Ye=l.return}}function Pw(a){for(;Ye!==null;){var l=Ye;if(l===a){Ye=null;break}var m=l.sibling;if(m!==null){m.return=l.return,Ye=m;break}Ye=l.return}}function Lw(a){for(;Ye!==null;){var l=Ye;try{switch(l.tag){case 0:case 11:case 15:var m=l.return;try{ju(4,l)}catch(X){rn(l,m,X)}break;case 1:var w=l.stateNode;if(typeof w.componentDidMount=="function"){var C=l.return;try{w.componentDidMount()}catch(X){rn(l,C,X)}}var T=l.return;try{yp(l)}catch(X){rn(l,T,X)}break;case 5:var I=l.return;try{yp(l)}catch(X){rn(l,I,X)}}}catch(X){rn(l,l.return,X)}if(l===a){Ye=null;break}var V=l.sibling;if(V!==null){V.return=l.return,Ye=V;break}Ye=l.return}}var B_=Math.ceil,ku=N.ReactCurrentDispatcher,jp=N.ReactCurrentOwner,Ls=N.ReactCurrentBatchConfig,Ct=0,kn=null,hn=null,Rn=0,js=0,Ti=xo(0),yn=0,oc=null,va=0,Nu=0,kp=0,ac=null,cs=null,Np=0,Ri=1/0,Br=null,Su=!1,Sp=null,ko=null,Cu=!1,No=null,Eu=0,ic=0,Cp=null,$u=-1,_u=0;function Vn(){return(Ct&6)!==0?ct():$u!==-1?$u:$u=ct()}function So(a){return(a.mode&1)===0?1:(Ct&2)!==0&&Rn!==0?Rn&-Rn:E_.transition!==null?(_u===0&&(_u=Rl()),_u):(a=_t,a!==0||(a=window.event,a=a===void 0?16:zy(a.type)),a)}function or(a,l,m,w){if(50<ic)throw ic=0,Cp=null,Error(s(185));co(a,m,w),((Ct&2)===0||a!==kn)&&(a===kn&&((Ct&2)===0&&(Nu|=m),yn===4&&Co(a,Rn)),ds(a,w),m===1&&Ct===0&&(l.mode&1)===0&&(Ri=ct()+500,su&&yo()))}function ds(a,l){var m=a.callbackNode;Fd(a,l);var w=ca(a,a===kn?Rn:0);if(w===0)m!==null&&qe(m),a.callbackNode=null,a.callbackPriority=0;else if(l=w&-w,a.callbackPriority!==l){if(m!=null&&qe(m),l===1)a.tag===0?C_(zw.bind(null,a)):kb(zw.bind(null,a)),j_(function(){(Ct&6)===0&&yo()}),m=null;else{switch(Al(w)){case 1:m=_n;break;case 4:m=mr;break;case 16:m=Bt;break;case 536870912:m=io;break;default:m=Bt}m=qw(m,Iw.bind(null,a))}a.callbackPriority=l,a.callbackNode=m}}function Iw(a,l){if($u=-1,_u=0,(Ct&6)!==0)throw Error(s(327));var m=a.callbackNode;if(Ai()&&a.callbackNode!==m)return null;var w=ca(a,a===kn?Rn:0);if(w===0)return null;if((w&30)!==0||(w&a.expiredLanes)!==0||l)l=Tu(a,w);else{l=w;var C=Ct;Ct|=2;var T=Fw();(kn!==a||Rn!==l)&&(Br=null,Ri=ct()+500,ba(a,l));do try{K_();break}catch(V){Dw(a,V)}while(!0);Bh(),ku.current=T,Ct=C,hn!==null?l=0:(kn=null,Rn=0,l=yn)}if(l!==0){if(l===2&&(C=ai(a),C!==0&&(w=C,l=Ep(a,C))),l===1)throw m=oc,ba(a,0),Co(a,w),ds(a,ct()),m;if(l===6)Co(a,w);else{if(C=a.current.alternate,(w&30)===0&&!G_(C)&&(l=Tu(a,w),l===2&&(T=ai(a),T!==0&&(w=T,l=Ep(a,T))),l===1))throw m=oc,ba(a,0),Co(a,w),ds(a,ct()),m;switch(a.finishedWork=C,a.finishedLanes=w,l){case 0:case 1:throw Error(s(345));case 2:wa(a,cs,Br);break;case 3:if(Co(a,w),(w&130023424)===w&&(l=Np+500-ct(),10<l)){if(ca(a,0)!==0)break;if(C=a.suspendedLanes,(C&w)!==w){Vn(),a.pingedLanes|=a.suspendedLanes&C;break}a.timeoutHandle=Oh(wa.bind(null,a,cs,Br),l);break}wa(a,cs,Br);break;case 4:if(Co(a,w),(w&4194240)===w)break;for(l=a.eventTimes,C=-1;0<w;){var I=31-rs(w);T=1<<I,I=l[I],I>C&&(C=I),w&=~T}if(w=C,w=ct()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*B_(w/1960))-w,10<w){a.timeoutHandle=Oh(wa.bind(null,a,cs,Br),w);break}wa(a,cs,Br);break;case 5:wa(a,cs,Br);break;default:throw Error(s(329))}}}return ds(a,ct()),a.callbackNode===m?Iw.bind(null,a):null}function Ep(a,l){var m=ac;return a.current.memoizedState.isDehydrated&&(ba(a,l).flags|=256),a=Tu(a,l),a!==2&&(l=cs,cs=m,l!==null&&$p(l)),a}function $p(a){cs===null?cs=a:cs.push.apply(cs,a)}function G_(a){for(var l=a;;){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(!er(T(),C))return!1}catch{return!1}}}if(m=l.child,l.subtreeFlags&16384&&m!==null)m.return=l,l=m;else{if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Co(a,l){for(l&=~kp,l&=~Nu,a.suspendedLanes|=l,a.pingedLanes&=~l,a=a.expirationTimes;0<l;){var m=31-rs(l),w=1<<m;a[m]=-1,l&=~w}}function zw(a){if((Ct&6)!==0)throw Error(s(327));Ai();var l=ca(a,0);if((l&1)===0)return ds(a,ct()),null;var m=Tu(a,l);if(a.tag!==0&&m===2){var w=ai(a);w!==0&&(l=w,m=Ep(a,w))}if(m===1)throw m=oc,ba(a,0),Co(a,l),ds(a,ct()),m;if(m===6)throw Error(s(345));return a.finishedWork=a.current.alternate,a.finishedLanes=l,wa(a,cs,Br),ds(a,ct()),null}function _p(a,l){var m=Ct;Ct|=1;try{return a(l)}finally{Ct=m,Ct===0&&(Ri=ct()+500,su&&yo())}}function ya(a){No!==null&&No.tag===0&&(Ct&6)===0&&Ai();var l=Ct;Ct|=1;var m=Ls.transition,w=_t;try{if(Ls.transition=null,_t=1,a)return a()}finally{_t=w,Ls.transition=m,Ct=l,(Ct&6)===0&&yo()}}function Tp(){js=Ti.current,qt(Ti)}function ba(a,l){a.finishedWork=null,a.finishedLanes=0;var m=a.timeoutHandle;if(m!==-1&&(a.timeoutHandle=-1,w_(m)),hn!==null)for(m=hn.return;m!==null;){var w=m;switch(Dh(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&tu();break;case 3:Ei(),qt(as),qt(Mn),Xh();break;case 5:Qh(w);break;case 4:Ei();break;case 13:qt(Zt);break;case 19:qt(Zt);break;case 10:Gh(w.type._context);break;case 22:case 23:Tp()}m=m.return}if(kn=a,hn=a=Eo(a.current,null),Rn=js=l,yn=0,oc=null,kp=Nu=va=0,cs=ac=null,pa!==null){for(l=0;l<pa.length;l++)if(m=pa[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}pa=null}return a}function Dw(a,l){do{var m=hn;try{if(Bh(),mu.current=xu,hu){for(var w=en.memoizedState;w!==null;){var C=w.queue;C!==null&&(C.pending=null),w=w.next}hu=!1}if(xa=0,jn=vn=en=null,Zl=!1,ec=0,jp.current=null,m===null||m.return===null){yn=1,oc=l,hn=null;break}e:{var T=a,I=m.return,V=m,X=l;if(l=Rn,V.flags|=32768,X!==null&&typeof X=="object"&&typeof X.then=="function"){var ue=X,Ne=V,Ce=Ne.tag;if((Ne.mode&1)===0&&(Ce===0||Ce===11||Ce===15)){var je=Ne.alternate;je?(Ne.updateQueue=je.updateQueue,Ne.memoizedState=je.memoizedState,Ne.lanes=je.lanes):(Ne.updateQueue=null,Ne.memoizedState=null)}var Ge=dw(I);if(Ge!==null){Ge.flags&=-257,uw(Ge,I,V,T,l),Ge.mode&1&&cw(T,ue,l),l=Ge,X=ue;var Qe=l.updateQueue;if(Qe===null){var Je=new Set;Je.add(X),l.updateQueue=Je}else Qe.add(X);break e}else{if((l&1)===0){cw(T,ue,l),Rp();break e}X=Error(s(426))}}else if(Yt&&V.mode&1){var an=dw(I);if(an!==null){(an.flags&65536)===0&&(an.flags|=256),uw(an,I,V,T,l),Wh($i(X,V));break e}}T=X=$i(X,V),yn!==4&&(yn=2),ac===null?ac=[T]:ac.push(T),T=I;do{switch(T.tag){case 3:T.flags|=65536,l&=-l,T.lanes|=l;var le=iw(T,X,l);Mb(T,le);break e;case 1:V=X;var ne=T.type,ce=T.stateNode;if((T.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(ko===null||!ko.has(ce)))){T.flags|=65536,l&=-l,T.lanes|=l;var Re=lw(T,V,l);Mb(T,Re);break e}}T=T.return}while(T!==null)}Ww(m)}catch(et){l=et,hn===m&&m!==null&&(hn=m=m.return);continue}break}while(!0)}function Fw(){var a=ku.current;return ku.current=xu,a===null?xu:a}function Rp(){(yn===0||yn===3||yn===2)&&(yn=4),kn===null||(va&268435455)===0&&(Nu&268435455)===0||Co(kn,Rn)}function Tu(a,l){var m=Ct;Ct|=2;var w=Fw();(kn!==a||Rn!==l)&&(Br=null,ba(a,l));do try{q_();break}catch(C){Dw(a,C)}while(!0);if(Bh(),Ct=m,ku.current=w,hn!==null)throw Error(s(261));return kn=null,Rn=0,yn}function q_(){for(;hn!==null;)Uw(hn)}function K_(){for(;hn!==null&&!St();)Uw(hn)}function Uw(a){var l=Gw(a.alternate,a,js);a.memoizedProps=a.pendingProps,l===null?Ww(a):hn=l,jp.current=null}function Ww(a){var l=a;do{var m=l.alternate;if(a=l.return,(l.flags&32768)===0){if(m=D_(m,l,js),m!==null){hn=m;return}}else{if(m=F_(m,l),m!==null){m.flags&=32767,hn=m;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{yn=6,hn=null;return}}if(l=l.sibling,l!==null){hn=l;return}hn=l=a}while(l!==null);yn===0&&(yn=5)}function wa(a,l,m){var w=_t,C=Ls.transition;try{Ls.transition=null,_t=1,V_(a,l,m,w)}finally{Ls.transition=C,_t=w}return null}function V_(a,l,m,w){do Ai();while(No!==null);if((Ct&6)!==0)throw Error(s(327));m=a.finishedWork;var C=a.finishedLanes;if(m===null)return null;if(a.finishedWork=null,a.finishedLanes=0,m===a.current)throw Error(s(177));a.callbackNode=null,a.callbackPriority=0;var T=m.lanes|m.childLanes;if(Ud(a,T),a===kn&&(hn=kn=null,Rn=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||Cu||(Cu=!0,qw(Bt,function(){return Ai(),null})),T=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||T){T=Ls.transition,Ls.transition=null;var I=_t;_t=1;var V=Ct;Ct|=4,jp.current=null,W_(a,m),Aw(m,a),h_(Rh),Lr=!!Th,Rh=Th=null,a.current=m,H_(m),It(),Ct=V,_t=I,Ls.transition=T}else a.current=m;if(Cu&&(Cu=!1,No=a,Eu=C),T=a.pendingLanes,T===0&&(ko=null),Pd(m.stateNode),ds(a,ct()),l!==null)for(w=a.onRecoverableError,m=0;m<l.length;m++)C=l[m],w(C.value,{componentStack:C.stack,digest:C.digest});if(Su)throw Su=!1,a=Sp,Sp=null,a;return(Eu&1)!==0&&a.tag!==0&&Ai(),T=a.pendingLanes,(T&1)!==0?a===Cp?ic++:(ic=0,Cp=a):ic=0,yo(),null}function Ai(){if(No!==null){var a=Al(Eu),l=Ls.transition,m=_t;try{if(Ls.transition=null,_t=16>a?16:a,No===null)var w=!1;else{if(a=No,No=null,Eu=0,(Ct&6)!==0)throw Error(s(331));var C=Ct;for(Ct|=4,Ye=a.current;Ye!==null;){var T=Ye,I=T.child;if((Ye.flags&16)!==0){var V=T.deletions;if(V!==null){for(var X=0;X<V.length;X++){var ue=V[X];for(Ye=ue;Ye!==null;){var Ne=Ye;switch(Ne.tag){case 0:case 11:case 15:rc(8,Ne,T)}var Ce=Ne.child;if(Ce!==null)Ce.return=Ne,Ye=Ce;else for(;Ye!==null;){Ne=Ye;var je=Ne.sibling,Ge=Ne.return;if(Ew(Ne),Ne===ue){Ye=null;break}if(je!==null){je.return=Ge,Ye=je;break}Ye=Ge}}}var Qe=T.alternate;if(Qe!==null){var Je=Qe.child;if(Je!==null){Qe.child=null;do{var an=Je.sibling;Je.sibling=null,Je=an}while(Je!==null)}}Ye=T}}if((T.subtreeFlags&2064)!==0&&I!==null)I.return=T,Ye=I;else e:for(;Ye!==null;){if(T=Ye,(T.flags&2048)!==0)switch(T.tag){case 0:case 11:case 15:rc(9,T,T.return)}var le=T.sibling;if(le!==null){le.return=T.return,Ye=le;break e}Ye=T.return}}var ne=a.current;for(Ye=ne;Ye!==null;){I=Ye;var ce=I.child;if((I.subtreeFlags&2064)!==0&&ce!==null)ce.return=I,Ye=ce;else e:for(I=ne;Ye!==null;){if(V=Ye,(V.flags&2048)!==0)try{switch(V.tag){case 0:case 11:case 15:ju(9,V)}}catch(et){rn(V,V.return,et)}if(V===I){Ye=null;break e}var Re=V.sibling;if(Re!==null){Re.return=V.return,Ye=Re;break e}Ye=V.return}}if(Ct=C,yo(),vs&&typeof vs.onPostCommitFiberRoot=="function")try{vs.onPostCommitFiberRoot(aa,a)}catch{}w=!0}return w}finally{_t=m,Ls.transition=l}}return!1}function Hw(a,l,m){l=$i(m,l),l=iw(a,l,1),a=wo(a,l,1),l=Vn(),a!==null&&(co(a,1,l),ds(a,l))}function rn(a,l,m){if(a.tag===3)Hw(a,a,m);else for(;l!==null;){if(l.tag===3){Hw(l,a,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))){a=$i(m,a),a=lw(l,a,1),l=wo(l,a,1),a=Vn(),l!==null&&(co(l,1,a),ds(l,a));break}}l=l.return}}function Y_(a,l,m){var w=a.pingCache;w!==null&&w.delete(l),l=Vn(),a.pingedLanes|=a.suspendedLanes&m,kn===a&&(Rn&m)===m&&(yn===4||yn===3&&(Rn&130023424)===Rn&&500>ct()-Np?ba(a,0):kp|=m),ds(a,l)}function Bw(a,l){l===0&&((a.mode&1)===0?l=1:(l=la,la<<=1,(la&130023424)===0&&(la=4194304)));var m=Vn();a=Ur(a,l),a!==null&&(co(a,l,m),ds(a,m))}function Q_(a){var l=a.memoizedState,m=0;l!==null&&(m=l.retryLane),Bw(a,m)}function J_(a,l){var m=0;switch(a.tag){case 13:var w=a.stateNode,C=a.memoizedState;C!==null&&(m=C.retryLane);break;case 19:w=a.stateNode;break;default:throw Error(s(314))}w!==null&&w.delete(l),Bw(a,m)}var Gw;Gw=function(a,l,m){if(a!==null)if(a.memoizedProps!==l.pendingProps||as.current)ls=!0;else{if((a.lanes&m)===0&&(l.flags&128)===0)return ls=!1,z_(a,l,m);ls=(a.flags&131072)!==0}else ls=!1,Yt&&(l.flags&1048576)!==0&&Nb(l,ou,l.index);switch(l.lanes=0,l.tag){case 2:var w=l.type;bu(a,l),a=l.pendingProps;var C=bi(l,Mn.current);Ci(l,m),C=tp(null,l,w,a,C,m);var T=np();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,is(w)?(T=!0,nu(l)):T=!1,l.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,Vh(l),C.updater=vu,l.stateNode=C,C._reactInternals=l,lp(l,w,a,m),l=fp(null,l,w,!0,T,m)):(l.tag=0,Yt&&T&&zh(l),Kn(null,l,C,m),l=l.child),l;case 16:w=l.elementType;e:{switch(bu(a,l),a=l.pendingProps,C=w._init,w=C(w._payload),l.type=w,C=l.tag=Z_(w),a=nr(w,a),C){case 0:l=up(null,l,w,a,m);break e;case 1:l=xw(null,l,w,a,m);break e;case 11:l=fw(null,l,w,a,m);break e;case 14:l=mw(null,l,w,nr(w.type,a),m);break e}throw Error(s(306,w,""))}return l;case 0:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:nr(w,C),up(a,l,w,C,m);case 1:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:nr(w,C),xw(a,l,w,C,m);case 3:e:{if(vw(l),a===null)throw Error(s(387));w=l.pendingProps,T=l.memoizedState,C=T.element,Ob(a,l),uu(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=$i(Error(s(423)),l),l=yw(a,l,w,m,C);break e}else if(w!==C){C=$i(Error(s(424)),l),l=yw(a,l,w,m,C);break e}else for(ws=go(l.stateNode.containerInfo.firstChild),bs=l,Yt=!0,tr=null,m=Rb(l,null,w,m),l.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(ki(),w===C){l=Hr(a,l,m);break e}Kn(a,l,w,m)}l=l.child}return l;case 5:return Lb(l),a===null&&Uh(l),w=l.type,C=l.pendingProps,T=a!==null?a.memoizedProps:null,I=C.children,Ah(w,C)?I=null:T!==null&&Ah(w,T)&&(l.flags|=32),gw(a,l),Kn(a,l,I,m),l.child;case 6:return a===null&&Uh(l),null;case 13:return bw(a,l,m);case 4:return Yh(l,l.stateNode.containerInfo),w=l.pendingProps,a===null?l.child=Ni(l,null,w,m):Kn(a,l,w,m),l.child;case 11:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:nr(w,C),fw(a,l,w,C,m);case 7:return Kn(a,l,l.pendingProps,m),l.child;case 8:return Kn(a,l,l.pendingProps.children,m),l.child;case 12:return Kn(a,l,l.pendingProps.children,m),l.child;case 10:e:{if(w=l.type._context,C=l.pendingProps,T=l.memoizedProps,I=C.value,Ut(lu,w._currentValue),w._currentValue=I,T!==null)if(er(T.value,I)){if(T.children===C.children&&!as.current){l=Hr(a,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=Wr(-1,m&-m),X.tag=2;var ue=T.updateQueue;if(ue!==null){ue=ue.shared;var Ne=ue.pending;Ne===null?X.next=X:(X.next=Ne.next,Ne.next=X),ue.pending=X}}T.lanes|=m,X=T.alternate,X!==null&&(X.lanes|=m),qh(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),qh(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}Kn(a,l,C.children,m),l=l.child}return l;case 9:return C=l.type,w=l.pendingProps.children,Ci(l,m),C=Ms(C),w=w(C),l.flags|=1,Kn(a,l,w,m),l.child;case 14:return w=l.type,C=nr(w,l.pendingProps),C=nr(w.type,C),mw(a,l,w,C,m);case 15:return hw(a,l,l.type,l.pendingProps,m);case 17:return w=l.type,C=l.pendingProps,C=l.elementType===w?C:nr(w,C),bu(a,l),l.tag=1,is(w)?(a=!0,nu(l)):a=!1,Ci(l,m),ow(l,w,C),lp(l,w,C,m),fp(null,l,w,!0,a,m);case 19:return jw(a,l,m);case 22:return pw(a,l,m)}throw Error(s(156,l.tag))};function qw(a,l){return we(a,l)}function X_(a,l,m,w){this.tag=a,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 Is(a,l,m,w){return new X_(a,l,m,w)}function Ap(a){return a=a.prototype,!(!a||!a.isReactComponent)}function Z_(a){if(typeof a=="function")return Ap(a)?1:0;if(a!=null){if(a=a.$$typeof,a===P)return 11;if(a===q)return 14}return 2}function Eo(a,l){var m=a.alternate;return m===null?(m=Is(a.tag,l,a.key,a.mode),m.elementType=a.elementType,m.type=a.type,m.stateNode=a.stateNode,m.alternate=a,a.alternate=m):(m.pendingProps=l,m.type=a.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=a.flags&14680064,m.childLanes=a.childLanes,m.lanes=a.lanes,m.child=a.child,m.memoizedProps=a.memoizedProps,m.memoizedState=a.memoizedState,m.updateQueue=a.updateQueue,l=a.dependencies,m.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},m.sibling=a.sibling,m.index=a.index,m.ref=a.ref,m}function Ru(a,l,m,w,C,T){var I=2;if(w=a,typeof a=="function")Ap(a)&&(I=1);else if(typeof a=="string")I=5;else e:switch(a){case M:return ja(m.children,C,T,l);case O:I=8,C|=8;break;case L:return a=Is(12,m,l,C|2),a.elementType=L,a.lanes=T,a;case z:return a=Is(13,m,l,C),a.elementType=z,a.lanes=T,a;case U:return a=Is(19,m,l,C),a.elementType=U,a.lanes=T,a;case K:return Au(m,C,T,l);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case R:I=10;break e;case A:I=9;break e;case P:I=11;break e;case q:I=14;break e;case H:I=16,w=null;break e}throw Error(s(130,a==null?a:typeof a,""))}return l=Is(I,m,l,C),l.elementType=a,l.type=w,l.lanes=T,l}function ja(a,l,m,w){return a=Is(7,a,w,l),a.lanes=m,a}function Au(a,l,m,w){return a=Is(22,a,w,l),a.elementType=K,a.lanes=m,a.stateNode={isHidden:!1},a}function Op(a,l,m){return a=Is(6,a,null,l),a.lanes=m,a}function Mp(a,l,m){return l=Is(4,a.children!==null?a.children:[],a.key,l),l.lanes=m,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}function eT(a,l,m,w,C){this.tag=l,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ii(0),this.expirationTimes=ii(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ii(0),this.identifierPrefix=w,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function Pp(a,l,m,w,C,T,I,V,X){return a=new eT(a,l,m,V,X),l===1?(l=1,T===!0&&(l|=8)):l=0,T=Is(3,null,null,l),a.current=T,T.stateNode=a,T.memoizedState={element:w,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},Vh(T),a}function tT(a,l,m){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:_,key:w==null?null:""+w,children:a,containerInfo:l,implementation:m}}function Kw(a){if(!a)return vo;a=a._reactInternals;e:{if(Oe(a)!==a||a.tag!==1)throw Error(s(170));var l=a;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(is(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(s(171))}if(a.tag===1){var m=a.type;if(is(m))return wb(a,m,l)}return l}function Vw(a,l,m,w,C,T,I,V,X){return a=Pp(m,w,!0,a,C,T,I,V,X),a.context=Kw(null),m=a.current,w=Vn(),C=So(m),T=Wr(w,C),T.callback=l??null,wo(m,T,C),a.current.lanes=C,co(a,C,w),ds(a,w),a}function Ou(a,l,m,w){var C=l.current,T=Vn(),I=So(C);return m=Kw(m),l.context===null?l.context=m:l.pendingContext=m,l=Wr(T,I),l.payload={element:a},w=w===void 0?null:w,w!==null&&(l.callback=w),a=wo(C,l,I),a!==null&&(or(a,C,I,T),du(a,C,I)),I}function Mu(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function Yw(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var m=a.retryLane;a.retryLane=m!==0&&m<l?m:l}}function Lp(a,l){Yw(a,l),(a=a.alternate)&&Yw(a,l)}function nT(){return null}var Qw=typeof reportError=="function"?reportError:function(a){console.error(a)};function Ip(a){this._internalRoot=a}Pu.prototype.render=Ip.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(s(409));Ou(a,l,null,null)},Pu.prototype.unmount=Ip.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;ya(function(){Ou(null,a,null,null)}),l[Ir]=null}};function Pu(a){this._internalRoot=a}Pu.prototype.unstable_scheduleHydration=function(a){if(a){var l=Pl();a={blockedOn:null,target:a,priority:l};for(var m=0;m<Ie.length&&l!==0&&l<Ie[m].priority;m++);Ie.splice(m,0,a),m===0&&qn(a)}};function zp(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Lu(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function Jw(){}function sT(a,l,m,w,C){if(C){if(typeof w=="function"){var T=w;w=function(){var ue=Mu(I);T.call(ue)}}var I=Vw(l,w,a,0,null,!1,!1,"",Jw);return a._reactRootContainer=I,a[Ir]=I.current,Gl(a.nodeType===8?a.parentNode:a),ya(),I}for(;C=a.lastChild;)a.removeChild(C);if(typeof w=="function"){var V=w;w=function(){var ue=Mu(X);V.call(ue)}}var X=Pp(a,0,!1,null,null,!1,!1,"",Jw);return a._reactRootContainer=X,a[Ir]=X.current,Gl(a.nodeType===8?a.parentNode:a),ya(function(){Ou(l,X,m,w)}),X}function Iu(a,l,m,w,C){var T=m._reactRootContainer;if(T){var I=T;if(typeof C=="function"){var V=C;C=function(){var X=Mu(I);V.call(X)}}Ou(l,I,a,C)}else I=sT(m,l,a,C,w);return Mu(I)}Ol=function(a){switch(a.tag){case 3:var l=a.stateNode;if(l.current.memoizedState.isDehydrated){var m=lo(l.pendingLanes);m!==0&&(li(l,m|1),ds(l,ct()),(Ct&6)===0&&(Ri=ct()+500,yo()))}break;case 13:ya(function(){var w=Ur(a,1);if(w!==null){var C=Vn();or(w,a,1,C)}}),Lp(a,1)}},ci=function(a){if(a.tag===13){var l=Ur(a,134217728);if(l!==null){var m=Vn();or(l,a,134217728,m)}Lp(a,134217728)}},Ml=function(a){if(a.tag===13){var l=So(a),m=Ur(a,l);if(m!==null){var w=Vn();or(m,a,l,w)}Lp(a,l)}},Pl=function(){return _t},Ll=function(a,l){var m=_t;try{return _t=a,l()}finally{_t=m}},We=function(a,l,m){switch(l){case"input":if($e(a,m),l=m.name,m.type==="radio"&&l!=null){for(m=a;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!==a&&w.form===a.form){var C=eu(w);if(!C)throw Error(s(90));De(w),$e(w,C)}}}break;case"textarea":Se(a,m);break;case"select":l=m.value,l!=null&&Ze(a,!!m.multiple,l,!1)}},Vt=_p,ps=ya;var rT={usingClientEntryPoint:!1,Events:[Vl,vi,eu,kt,lt,_p]},lc={findFiberByHostInstance:ua,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},oT={bundleType:lc.bundleType,version:lc.version,rendererPackageName:lc.rendererPackageName,rendererConfig:lc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:N.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=Be(a),a===null?null:a.stateNode},findFiberByHostInstance:lc.findFiberByHostInstance||nT,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 zu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zu.isDisabled&&zu.supportsFiber)try{aa=zu.inject(oT),vs=zu}catch{}}return us.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=rT,us.createPortal=function(a,l){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!zp(l))throw Error(s(200));return tT(a,l,null,m)},us.createRoot=function(a,l){if(!zp(a))throw Error(s(299));var m=!1,w="",C=Qw;return l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(w=l.identifierPrefix),l.onRecoverableError!==void 0&&(C=l.onRecoverableError)),l=Pp(a,1,!1,null,null,m,!1,w,C),a[Ir]=l.current,Gl(a.nodeType===8?a.parentNode:a),new Ip(l)},us.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var l=a._reactInternals;if(l===void 0)throw typeof a.render=="function"?Error(s(188)):(a=Object.keys(a).join(","),Error(s(268,a)));return a=Be(l),a=a===null?null:a.stateNode,a},us.flushSync=function(a){return ya(a)},us.hydrate=function(a,l,m){if(!Lu(l))throw Error(s(200));return Iu(null,a,l,!0,m)},us.hydrateRoot=function(a,l,m){if(!zp(a))throw Error(s(405));var w=m!=null&&m.hydratedSources||null,C=!1,T="",I=Qw;if(m!=null&&(m.unstable_strictMode===!0&&(C=!0),m.identifierPrefix!==void 0&&(T=m.identifierPrefix),m.onRecoverableError!==void 0&&(I=m.onRecoverableError)),l=Vw(l,null,a,1,m??null,C,!1,T,I),a[Ir]=l.current,Gl(a),w)for(a=0;a<w.length;a++)m=w[a],C=m._getVersion,C=C(m._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[m,C]:l.mutableSourceEagerHydrationData.push(m,C);return new Pu(l)},us.render=function(a,l,m){if(!Lu(l))throw Error(s(200));return Iu(null,a,l,!1,m)},us.unmountComponentAtNode=function(a){if(!Lu(a))throw Error(s(40));return a._reactRootContainer?(ya(function(){Iu(null,null,a,!1,function(){a._reactRootContainer=null,a[Ir]=null})}),!0):!1},us.unstable_batchedUpdates=_p,us.unstable_renderSubtreeIntoContainer=function(a,l,m,w){if(!Lu(m))throw Error(s(200));if(a==null||a._reactInternals===void 0)throw Error(s(38));return Iu(a,l,m,!1,w)},us.version="18.3.1-next-f1338f8080-20240426",us}var oj;function CN(){if(oj)return Up.exports;oj=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(),Up.exports=pT(),Up.exports}var aj;function gT(){if(aj)return Du;aj=1;var e=CN();return Du.createRoot=e.createRoot,Du.hydrateRoot=e.hydrateRoot,Du}var xT=gT();function es(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 Yo=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 vT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),EN=(...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 yT={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 bT=p.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:c,...d},u)=>p.createElement("svg",{ref:u,...yT,width:n,height:n,stroke:e,strokeWidth:r?Number(s)*24/Number(n):s,className:EN("lucide",o),...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 Te=(e,n)=>{const s=p.forwardRef(({className:r,...o},i)=>p.createElement(bT,{ref:i,iconNode:n,className:EN(`lucide-${vT(e)}`,r),...o}));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 wT=Te("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 $N=Te("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 nd=Te("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 An=Te("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 Fx=Te("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 fr=Te("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 _N=Te("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 dm=Te("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 Nf=Te("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 Ux=Te("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 Sf=Te("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 um=Te("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 xl=Te("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 Or=Te("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 jT=Te("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 Es=Te("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 sl=Te("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 kT=Te("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 TN=Te("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 Wx=Te("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 NT=Te("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 RN=Te("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 ST=Te("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 CT=Te("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 fm=Te("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 Ya=Te("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 ET=Te("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 $T=Te("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 AN=Te("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 _T=Te("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 TT=Te("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 mm=Te("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 Qa=Te("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 ON=Te("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 RT=Te("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 hm=Te("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 ij=Te("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 MN=Te("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 AT=Te("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 OT=Te("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 sd=Te("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 Hx=Te("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 Mg=Te("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 Ia=Te("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 MT=Te("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 PT=Te("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 Bx=Te("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 LT=Te("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 IT=Te("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 Bp=Te("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 zT=Te("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 DT=Te("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 FT=Te("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 UT=Te("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 Gx=Te("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 WT=Te("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 HT=Te("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 Ja=Te("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 BT=Te("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 GT=Te("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 qT=Te("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 rl=Te("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 qx=Te("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 Qo=Te("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 KT=Te("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 vl=Te("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 VT=Te("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 Kx=Te("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 Jo=Te("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 PN=Te("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 Vx=Te("Rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/**
|
|
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 YT=Te("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"}]]);/**
|
|
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 pm=Te("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
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 LN=Te("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"}]]);/**
|
|
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 QT=Te("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"}]]);/**
|
|
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 IN=Te("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"}]]);/**
|
|
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 zN=Te("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
|
|
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 Yx=Te("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"}]]);/**
|
|
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 JT=Te("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
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 XT=Te("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"}]]);/**
|
|
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 ZT=Te("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
|
|
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 DN=Te("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"}]]);/**
|
|
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 Gs=Te("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"}]]);/**
|
|
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 Qx=Te("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"}]]);/**
|
|
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 ol=Te("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"}]]);/**
|
|
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 FN=Te("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"}]]);/**
|
|
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 Xa=Te("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"}]]);/**
|
|
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 Cf=Te("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"}]]);/**
|
|
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 Xo=Te("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
|
|
506
|
+
* @license lucide-react v0.468.0 - ISC
|
|
507
|
+
*
|
|
508
|
+
* This source code is licensed under the ISC license.
|
|
509
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
510
|
+
*/const eR=Te("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 UN(e){var n,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(n=0;n<o;n++)e[n]&&(s=UN(e[n]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function WN(){for(var e,n,s=0,r="",o=arguments.length;s<o;s++)(e=arguments[s])&&(n=UN(e))&&(r&&(r+=" "),r+=n);return r}const Jx="-",tR=e=>{const n=sR(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{const d=c.split(Jx);return d[0]===""&&d.length!==1&&d.shift(),HN(d,n)||nR(c)},getConflictingClassGroupIds:(c,d)=>{const u=s[c]||[];return d&&r[c]?[...u,...r[c]]:u}}},HN=(e,n)=>{var c;if(e.length===0)return n.classGroupId;const s=e[0],r=n.nextPart.get(s),o=r?HN(e.slice(1),r):void 0;if(o)return o;if(n.validators.length===0)return;const i=e.join(Jx);return(c=n.validators.find(({validator:d})=>d(i)))==null?void 0:c.classGroupId},lj=/^\[(.+)\]$/,nR=e=>{if(lj.test(e)){const n=lj.exec(e)[1],s=n==null?void 0:n.substring(0,n.indexOf(":"));if(s)return"arbitrary.."+s}},sR=e=>{const{theme:n,prefix:s}=e,r={nextPart:new Map,validators:[]};return oR(Object.entries(e.classGroups),s).forEach(([i,c])=>{Pg(c,r,i,n)}),r},Pg=(e,n,s,r)=>{e.forEach(o=>{if(typeof o=="string"){const i=o===""?n:cj(n,o);i.classGroupId=s;return}if(typeof o=="function"){if(rR(o)){Pg(o(r),n,s,r);return}n.validators.push({validator:o,classGroupId:s});return}Object.entries(o).forEach(([i,c])=>{Pg(c,cj(n,i),s,r)})})},cj=(e,n)=>{let s=e;return n.split(Jx).forEach(r=>{s.nextPart.has(r)||s.nextPart.set(r,{nextPart:new Map,validators:[]}),s=s.nextPart.get(r)}),s},rR=e=>e.isThemeGetter,oR=(e,n)=>n?e.map(([s,r])=>{const o=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,o]}):e,aR=e=>{if(e<1)return{get:()=>{},set:()=>{}};let n=0,s=new Map,r=new Map;const o=(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 o(i,c),c},set(i,c){s.has(i)?s.set(i,c):o(i,c)}}},BN="!",iR=e=>{const{separator:n,experimentalParseClassName:s}=e,r=n.length===1,o=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===o&&(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(BN),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},lR=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},cR=e=>({cache:aR(e.cacheSize),parseClassName:iR(e),...tR(e)}),dR=/\s+/,uR=(e,n)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:o}=n,i=[],c=e.trim().split(dR);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=lR(g).join(":"),k=b?j+BN:j,E=k+y;if(i.includes(E))continue;i.push(E);const S=o(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 fR(){let e=0,n,s,r="";for(;e<arguments.length;)(n=arguments[e++])&&(s=GN(n))&&(r&&(r+=" "),r+=s);return r}const GN=e=>{if(typeof e=="string")return e;let n,s="";for(let r=0;r<e.length;r++)e[r]&&(n=GN(e[r]))&&(s&&(s+=" "),s+=n);return s};function dj(e,...n){let s,r,o,i=c;function c(u){const f=n.reduce((g,b)=>b(g),e());return s=cR(f),r=s.cache.get,o=s.cache.set,i=d,d(u)}function d(u){const f=r(u);if(f)return f;const g=uR(u,s);return o(u,g),g}return function(){return i(fR.apply(null,arguments))}}const Kt=e=>{const n=s=>s[e]||[];return n.isThemeGetter=!0,n},qN=/^\[(?:([a-z-]+):)?(.+)\]$/i,mR=/^\d+\/\d+$/,hR=new Set(["px","full","screen"]),pR=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,gR=/\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$/,xR=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,vR=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,yR=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Gr=e=>qi(e)||hR.has(e)||mR.test(e),_o=e=>yl(e,"length",ER),qi=e=>!!e&&!Number.isNaN(Number(e)),Gp=e=>yl(e,"number",qi),dc=e=>!!e&&Number.isInteger(Number(e)),bR=e=>e.endsWith("%")&&qi(e.slice(0,-1)),pt=e=>qN.test(e),To=e=>pR.test(e),wR=new Set(["length","size","percentage"]),jR=e=>yl(e,wR,KN),kR=e=>yl(e,"position",KN),NR=new Set(["image","url"]),SR=e=>yl(e,NR,_R),CR=e=>yl(e,"",$R),uc=()=>!0,yl=(e,n,s)=>{const r=qN.exec(e);return r?r[1]?typeof n=="string"?r[1]===n:n.has(r[1]):s(r[2]):!1},ER=e=>gR.test(e)&&!xR.test(e),KN=()=>!1,$R=e=>vR.test(e),_R=e=>yR.test(e),uj=()=>{const e=Kt("colors"),n=Kt("spacing"),s=Kt("blur"),r=Kt("brightness"),o=Kt("borderColor"),i=Kt("borderRadius"),c=Kt("borderSpacing"),d=Kt("borderWidth"),u=Kt("contrast"),f=Kt("grayscale"),g=Kt("hueRotate"),b=Kt("invert"),x=Kt("gap"),h=Kt("gradientColorStops"),v=Kt("gradientColorStopPositions"),y=Kt("inset"),j=Kt("margin"),k=Kt("opacity"),E=Kt("padding"),S=Kt("saturate"),N=Kt("scale"),$=Kt("sepia"),_=Kt("skew"),M=Kt("space"),O=Kt("translate"),L=()=>["auto","contain","none"],R=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto",pt,n],P=()=>[pt,n],z=()=>["",Gr,_o],U=()=>["auto",qi,pt],q=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],H=()=>["solid","dashed","dotted","double","none"],K=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],W=()=>["start","end","center","between","around","evenly","stretch"],G=()=>["","0",pt],F=()=>["auto","avoid","all","avoid-page","page","left","right","column"],D=()=>[qi,pt];return{cacheSize:500,separator:":",theme:{colors:[uc],spacing:[Gr,_o],blur:["none","",To,pt],brightness:D(),borderColor:[e],borderRadius:["none","","full",To,pt],borderSpacing:P(),borderWidth:z(),contrast:D(),grayscale:G(),hueRotate:D(),invert:G(),gap:P(),gradientColorStops:[e],gradientColorStopPositions:[bR,_o],inset:A(),margin:A(),opacity:D(),padding:P(),saturate:D(),scale:D(),sepia:G(),skew:D(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",pt]}],container:["container"],columns:[{columns:[To]}],"break-after":[{"break-after":F()}],"break-before":[{"break-before":F()}],"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:[...q(),pt]}],overflow:[{overflow:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],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",dc,pt]}],basis:[{basis:A()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",pt]}],grow:[{grow:G()}],shrink:[{shrink:G()}],order:[{order:["first","last","none",dc,pt]}],"grid-cols":[{"grid-cols":[uc]}],"col-start-end":[{col:["auto",{span:["full",dc,pt]},pt]}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":[uc]}],"row-start-end":[{row:["auto",{span:[dc,pt]},pt]}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",pt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",pt]}],gap:[{gap:[x]}],"gap-x":[{"gap-x":[x]}],"gap-y":[{"gap-y":[x]}],"justify-content":[{justify:["normal",...W()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...W(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...W(),"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":[M]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[M]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",pt,n]}],"min-w":[{"min-w":[pt,n,"min","max","fit"]}],"max-w":[{"max-w":[pt,n,"none","full","min","max","fit","prose",{screen:[To]},To]}],h:[{h:[pt,n,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[pt,n,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[pt,n,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[pt,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",Gp]}],"font-family":[{font:[uc]}],"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",pt]}],"line-clamp":[{"line-clamp":["none",qi,Gp]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Gr,pt]}],"list-image":[{"list-image":["none",pt]}],"list-style-type":[{list:["none","disc","decimal",pt]}],"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",Gr,_o]}],"underline-offset":[{"underline-offset":["auto",Gr,pt]}],"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",pt]}],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",pt]}],"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:[...q(),kR]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",jR]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},SR]}],"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:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...H()]}],"outline-offset":[{"outline-offset":[Gr,pt]}],"outline-w":[{outline:[Gr,_o]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Gr,_o]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",To,CR]}],"shadow-color":[{shadow:[uc]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...K(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":K()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",To,pt]}],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",pt]}],duration:[{duration:D()}],ease:[{ease:["linear","in","out","in-out",pt]}],delay:[{delay:D()}],animate:[{animate:["none","spin","ping","pulse","bounce",pt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[N]}],"scale-x":[{"scale-x":[N]}],"scale-y":[{"scale-y":[N]}],rotate:[{rotate:[dc,pt]}],"translate-x":[{"translate-x":[O]}],"translate-y":[{"translate-y":[O]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",pt]}],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",pt]}],"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",pt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Gr,_o,Gp]}],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"]}}},TR=(e,{cacheSize:n,prefix:s,separator:r,experimentalParseClassName:o,extend:i={},override:c={}})=>{kc(e,"cacheSize",n),kc(e,"prefix",s),kc(e,"separator",r),kc(e,"experimentalParseClassName",o);for(const d in c)RR(e[d],c[d]);for(const d in i)AR(e[d],i[d]);return e},kc=(e,n,s)=>{s!==void 0&&(e[n]=s)},RR=(e,n)=>{if(n)for(const s in n)kc(e,s,n[s])},AR=(e,n)=>{if(n)for(const s in n){const r=n[s];r!==void 0&&(e[s]=(e[s]||[]).concat(r))}},OR=(e,...n)=>typeof e=="function"?dj(uj,e,...n):dj(()=>TR(uj(),e),...n),MR=OR({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"]}]}}}),ie=(...e)=>MR(WN(e)),PR={neutral:{box:"border-border bg-card",text:"text-foreground",Icon:Mg},info:{box:"border-info/50 bg-info/5",text:"text-info-text",Icon:Mg},success:{box:"border-success/50 bg-success/5",text:"text-success-text",Icon:TN},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:sl}};function vt({tone:e="neutral",title:n,actions:s,bar:r,icon:o,role:i,className:c,children:d,...u}){const f=PR[e],g=o===!1?null:o??f.Icon;return t.jsxs("div",{role:i??(e==="error"?"alert":"status"),...u,className:ie("flex gap-3 text-body",r?"shrink-0 items-center border-b bg-card px-5 py-2 md:px-8":ie("border p-4",f.box),c),children:[g&&t.jsx(g,{className:ie("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:ie("font-semibold",!r&&"caps text-small",!r&&f.text),children:n}),d&&t.jsx("div",{className:ie(n&&!r&&"mt-2"),children:d})]}),s&&t.jsx("div",{className:"flex shrink-0 items-start gap-2",children:s})]})}const fj=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,mj=WN,LR=(e,n)=>s=>{var r;if((n==null?void 0:n.variants)==null)return mj(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:o,defaultVariants:i}=n,c=Object.keys(o).map(f=>{const g=s==null?void 0:s[f],b=i==null?void 0:i[f];if(g===null)return null;const x=fj(g)||fj(b);return o[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 mj(e,c,u,s==null?void 0:s.class,s==null?void 0:s.className)},al=LR("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},o)=>t.jsx("button",{ref:o,className:ie(al({variant:n,size:s}),e),...r}));B.displayName="Button";const hj={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 ke({tone:e="plain",className:n,title:s,label:r,children:o}){return r?t.jsx("span",{title:s,className:ie("caps inline-flex h-5 min-w-0 items-center gap-1 border px-1.5 text-micro leading-none",hj[e],n),children:t.jsx("span",{className:"min-w-0 truncate",children:o})}):t.jsx("span",{title:s,className:ie("caps inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap border px-1.5 text-micro leading-none",hj[e],n),children:o})}const qs=e=>IR(e)?e.document:zR(e)?e:(e==null?void 0:e.ownerDocument)??(typeof document<"u"?document:void 0),gm=e=>{let n=qs(e);return(n==null?void 0:n.defaultView)??(typeof window<"u"?window:void 0)};function VN(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function IR(e){return typeof e=="object"&&e!=null&&"window"in e&&e.window===e}function zR(e){return VN(e)&&e.nodeType===9}function DR(e){return VN(e)&&e.nodeType===11&&"host"in e}let FR=!1;function Xx(){return FR}function Ra(e,n){var r;if(!Xx())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:DR(s)?s=s.host:s=s.parentNode}return!1}const Ho=(e=document)=>{var s;if(!Xx())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 Jn(e){if(Xx()&&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 UR(e){e.focus({preventScroll:!0})}const WR=typeof document<"u"?Ke.useLayoutEffect:()=>{};function YN(e){let n=e;return n.nativeEvent=e,n.isDefaultPrevented=()=>n.defaultPrevented,n.isPropagationStopped=()=>n.cancelBubble,n.persist=()=>{},n}function HR(e,n){Object.defineProperty(e,"target",{value:n}),Object.defineProperty(e,"currentTarget",{value:n})}function QN(e){let n=p.useRef({isFocused:!1,observer:null});return WR(()=>{const s=n.current;return()=>{s.observer&&(s.observer.disconnect(),s.observer=null)}},[]),p.useCallback(s=>{let r=Jn(s);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){n.current.isFocused=!0;let o=r,i=c=>{if(n.current.isFocused=!1,o.disabled){let d=YN(c);e==null||e(d)}n.current.observer&&(n.current.observer.disconnect(),n.current.observer=null)};o.addEventListener("focusout",i,{once:!0}),n.current.observer=new MutationObserver(()=>{var c;if(n.current.isFocused&&o.disabled){(c=n.current.observer)==null||c.disconnect();let d=o===Ho()?null:Ho();o.dispatchEvent(new FocusEvent("blur",{relatedTarget:d})),o.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:d}))}}),n.current.observer.observe(o,{attributes:!0,attributeFilter:["disabled"]})}},[e])}function Zx(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 ev(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 Za(e){let n=null;return()=>(n==null&&(n=e()),n)}const tv=Za(function(){return ev(/^Mac/i)}),BR=Za(function(){return ev(/^iPhone/i)}),JN=Za(function(){return ev(/^iPad/i)||tv()&&navigator.maxTouchPoints>1}),GR=Za(function(){return BR()||JN()}),qR=Za(function(){return Zx(/AppleWebKit/i)&&(GR()||!KR())}),KR=Za(function(){return Zx(/Chrome|CriOS|CrMo/i)}),VR=Za(function(){return Zx(/Android/i)});function YR(e){return e.pointerType===""&&e.isTrusted?!0:VR()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Ic(e,n,s=!0){let{metaKey:r,ctrlKey:o,altKey:i,shiftKey:c}=n,d=qR()&&tv()&&!JN()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:r,ctrlKey:o,altKey:i,shiftKey:c}):new MouseEvent("click",{metaKey:r,ctrlKey:o,altKey:i,shiftKey:c,detail:1,bubbles:!0,cancelable:!0});Ic.isOpening=s,UR(e),e.dispatchEvent(d),Ic.isOpening=!1}Ic.isOpening=!1;let bl=null;const Lg=new Set;let _c=new Map,za=!1,ff=!1;const QR={Tab:!0,Escape:!0};function xm(e,n){for(let s of Lg)s(e,n)}function JR(e){return!(e.metaKey||!tv()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function Ef(e){za=!0,!Ic.isOpening&&JR(e)&&(bl="keyboard",xm("keyboard",e))}function Ki(e){bl="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(za=!0,xm("pointer",e))}function XN(e){!Ic.isOpening&&YR(e)&&(za=!0,bl="virtual")}function ZN(e){let n=Jn(e),s=gm(n),r=qs(n);if(n===s){ff=!0;return}n===r||!e.isTrusted||(!za&&!ff&&(bl="virtual",xm("virtual",e)),za=!1,ff=!1)}function e1(){za=!1,ff=!0}function t1(e){let n=Ho(qs(Jn(e)));queueMicrotask(()=>{Ho(qs(Jn(e)))!==n&&ZR("keyboard")})}function Ig(e){if(typeof window>"u"||typeof document>"u")return;const n=gm(e),s=qs(e);if(_c.get(n))return;let r=n.HTMLElement.prototype.focus;Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){za=!0,r.apply(this,arguments)}}),s.addEventListener("keydown",Ef,!0),s.addEventListener("keyup",Ef,!0),s.addEventListener("click",XN,!0),s.addEventListener("invalid",t1,!0),n.addEventListener("focus",ZN,!0),n.addEventListener("blur",e1,!1),typeof PointerEvent<"u"&&(s.addEventListener("pointerdown",Ki,!0),s.addEventListener("pointermove",Ki,!0),s.addEventListener("pointerup",Ki,!0)),n.addEventListener("beforeunload",()=>{n1(e)},{once:!0}),_c.set(n,{focus:r})}const n1=(e,n)=>{const s=gm(e),r=qs(e);n&&r.removeEventListener("DOMContentLoaded",n),_c.has(s)&&(Reflect.defineProperty(s.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:_c.get(s).focus}),r.removeEventListener("keydown",Ef,!0),r.removeEventListener("keyup",Ef,!0),r.removeEventListener("click",XN,!0),r.removeEventListener("invalid",t1,!0),s.removeEventListener("focus",ZN,!0),s.removeEventListener("blur",e1,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",Ki,!0),r.removeEventListener("pointermove",Ki,!0),r.removeEventListener("pointerup",Ki,!0)),_c.delete(s))};function XR(e){const n=qs(e);let s;return n.readyState!=="loading"?Ig(e):(s=()=>{Ig(e)},n.addEventListener("DOMContentLoaded",s)),()=>n1(e,s)}typeof document<"u"&&XR();function zg(){return bl!=="pointer"}function ZR(e){bl=e,xm(e,null)}const eA=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function tA(e,n,s){let r=s?Jn(s):void 0,o=qs(r),i=gm(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=Ho(o);return e=e||g instanceof c&&!eA.has(g.type)||g instanceof d||g instanceof u&&g.isContentEditable,!(e&&n==="keyboard"&&s instanceof f&&!QR[s.key])}function nA(e,n,s){Ig(),p.useEffect(()=>{if((s==null?void 0:s.enabled)===!1)return;let r=(o,i)=>{tA(!!(s!=null&&s.isTextInput),o,i)&&e(zg())};return Lg.add(r),()=>{Lg.delete(r)}},n)}function sA(e){let{isDisabled:n,onFocus:s,onBlur:r,onFocusChange:o}=e;const i=p.useCallback(u=>{if(Jn(u)===u.currentTarget)return r&&r(u),o&&o(!1),!0},[r,o]),c=QN(i),d=p.useCallback(u=>{let f=Jn(u);const g=qs(f),b=g?Ho(g):Ho();f===u.currentTarget&&f===b&&(s&&s(u),o&&o(!0),c(u))},[o,s,c]);return{focusProps:{onFocus:!n&&(s||o||r)?d:void 0,onBlur:!n&&(r||o)?i:void 0}}}function s1(){let e=p.useRef(new Map),n=p.useCallback((o,i,c,d)=>{let u=d!=null&&d.once?(...f)=>{e.current.delete(c),c(...f)}:c;e.current.set(c,{type:i,eventTarget:o,fn:u,options:d}),o.addEventListener(i,u,d)},[]),s=p.useCallback((o,i,c,d)=>{var f;let u=((f=e.current.get(c))==null?void 0:f.fn)||c;o.removeEventListener(i,u,d),e.current.delete(c)},[]),r=p.useCallback(()=>{e.current.forEach((o,i)=>{s(o.eventTarget,o.type,i,o.options)})},[s]);return p.useEffect(()=>r,[r]),{addGlobalListener:n,removeGlobalListener:s,removeAllGlobalListeners:r}}function rA(e){let{isDisabled:n,onBlurWithin:s,onFocusWithin:r,onFocusWithinChange:o}=e,i=p.useRef({isFocusWithin:!1}),{addGlobalListener:c,removeAllGlobalListeners:d}=s1(),u=p.useCallback(b=>{Ra(b.currentTarget,Jn(b))&&i.current.isFocusWithin&&!Ra(b.currentTarget,b.relatedTarget)&&(i.current.isFocusWithin=!1,d(),s&&s(b),o&&o(!1))},[s,o,i,d]),f=QN(u),g=p.useCallback(b=>{if(!Ra(b.currentTarget,Jn(b)))return;let x=Jn(b);const h=qs(x),v=Ho(h);if(!i.current.isFocusWithin&&v===x){r&&r(b),o&&o(!0),i.current.isFocusWithin=!0,f(b);let y=b.currentTarget;c(h,"focus",j=>{let k=Jn(j);if(i.current.isFocusWithin&&!Ra(y,k)){let E=new h.defaultView.FocusEvent("blur",{relatedTarget:k});HR(E,y);let S=YN(E);u(S)}},{capture:!0})}},[r,o,f,c,u]);return n?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:g,onBlur:u}}}function oA(e={}){let{autoFocus:n=!1,isTextInput:s,within:r}=e,o=p.useRef({isFocused:!1,isFocusVisible:n||zg()}),[i,c]=p.useState(!1),[d,u]=p.useState(()=>o.current.isFocused&&o.current.isFocusVisible),f=p.useCallback(()=>u(o.current.isFocused&&o.current.isFocusVisible),[]),g=p.useCallback(h=>{o.current.isFocused=h,o.current.isFocusVisible=zg(),c(h),f()},[f]);nA(h=>{o.current.isFocusVisible=h,f()},[s,i],{enabled:i,isTextInput:s});let{focusProps:b}=sA({isDisabled:r,onFocusChange:g}),{focusWithinProps:x}=rA({isDisabled:!r,onFocusWithinChange:g});return{isFocused:i,isFocusVisible:d,focusProps:r?x:b}}var Ns=CN();let Dg=!1,Fu=0;function aA(){Dg=!0,setTimeout(()=>{Dg=!1},500)}function pj(e){e.pointerType==="touch"&&aA()}function iA(){let e=qs(null);if(!(typeof e>"u"))return Fu===0&&typeof PointerEvent<"u"&&e.addEventListener("pointerup",pj),Fu++,()=>{Fu--,!(Fu>0)&&typeof PointerEvent<"u"&&e.removeEventListener("pointerup",pj)}}function lA(e){let{onHoverStart:n,onHoverChange:s,onHoverEnd:r,isDisabled:o}=e,[i,c]=p.useState(!1),d=p.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;p.useEffect(iA,[]);let{addGlobalListener:u,removeAllGlobalListeners:f}=s1(),{hoverProps:g,triggerHoverEnd:b}=p.useMemo(()=>{let x=(y,j)=>{if(d.pointerType=j,o||j==="touch"||d.isHovered||!Ra(y.currentTarget,Jn(y)))return;d.isHovered=!0;let k=y.currentTarget;d.target=k,u(qs(Jn(y)),"pointerover",E=>{d.isHovered&&d.target&&!Ra(d.target,Jn(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=>{Dg&&y.pointerType==="mouse"||x(y,y.pointerType)},v.onPointerLeave=y=>{!o&&Ra(y.currentTarget,Jn(y))&&h(y,y.pointerType)}),{hoverProps:v,triggerHoverEnd:h}},[n,s,r,o,d,u,f]);return p.useEffect(()=>{o&&b({currentTarget:d.target},d.pointerType)},[o]),{hoverProps:g,isHovered:i}}var cA=Object.defineProperty,dA=(e,n,s)=>n in e?cA(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,qp=(e,n,s)=>(dA(e,typeof n!="symbol"?n+"":n,s),s);let uA=class{constructor(){qp(this,"current",this.detect()),qp(this,"handoffState","pending"),qp(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"}},Cr=new uA;function wl(e){var n;return Cr.isServer?null:e==null?document:(n=e==null?void 0:e.ownerDocument)!=null?n:document}function $f(e){var n,s;return Cr.isServer?null:e==null?document:(s=(n=e==null?void 0:e.getRootNode)==null?void 0:n.call(e))!=null?s:document}function r1(e){var n,s;return(s=(n=$f(e))==null?void 0:n.activeElement)!=null?s:null}function o1(e){return r1(e)===e}function vm(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(n=>setTimeout(()=>{throw n}))}function $s(){let e=[],n={addEventListener(s,r,o,i){return s.addEventListener(r,o,i),n.add(()=>s.removeEventListener(r,o,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 vm(()=>{r.current&&s[0]()}),n.add(()=>{r.current=!1})},style(s,r,o){let i=s.style.getPropertyValue(r);return Object.assign(s.style,{[r]:o}),this.add(()=>{Object.assign(s.style,{[r]:i})})},group(s){let r=$s();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 o of e.splice(r,1))o()}},dispose(){for(let s of e.splice(0))s()}};return n}function Zo(){let[e]=p.useState($s);return p.useEffect(()=>()=>e.dispose(),[e]),e}let tn=(e,n)=>{Cr.isServer?p.useEffect(e,n):p.useLayoutEffect(e,n)};function ea(e){let n=p.useRef(e);return tn(()=>{n.current=e},[e]),n}let ut=function(e){let n=ea(e);return Ke.useCallback((...s)=>n.current(...s),[n])};function fA(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 mA(e,n){return!(!e||!n||e.right<n.left||e.left>n.right||e.bottom<n.top||e.top>n.bottom)}function hA({disabled:e=!1}={}){let n=p.useRef(null),[s,r]=p.useState(!1),o=Zo(),i=ut(()=>{n.current=null,r(!1),o.dispose()}),c=ut(d=>{if(o.dispose(),n.current===null){n.current=d.currentTarget,r(!0);{let u=wl(d.currentTarget);o.addEventListener(u,"pointerup",i,!1),o.addEventListener(u,"pointermove",f=>{if(n.current){let g=fA(f);r(mA(g,n.current.getBoundingClientRect()))}},!1),o.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 pA=p.createContext(void 0);function nv(){return p.useContext(pA)}function Fg(...e){return Array.from(new Set(e.flatMap(n=>typeof n=="string"?n.split(" "):[]))).filter(Boolean).join(" ")}function ts(e,n,...s){if(e in n){let o=n[e];return typeof o=="function"?o(...s):o}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(n).map(o=>`"${o}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,ts),r}var il=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(il||{}),zo=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(zo||{});function En(){let e=xA();return p.useCallback(n=>gA({mergeRefs:e,...n}),[e])}function gA({ourProps:e,theirProps:n,slot:s,defaultTag:r,features:o,visible:i=!0,name:c,mergeRefs:d}){d=d??vA;let u=a1(n,e);if(i)return Uu(u,s,r,c,d);let f=o??0;if(f&2){let{static:g=!1,...b}=u;if(g)return Uu(b,s,r,c,d)}if(f&1){let{unmount:g=!0,...b}=u;return ts(g?0:1,{0(){return null},1(){return Uu({...b,hidden:!0,style:{display:"none"}},s,r,c,d)}})}return Uu(u,s,r,c,d)}function Uu(e,n={},s,r,o){let{as:i=s,children:c,refName:d="ref",...u}=Kp(e,["unmount","static"]),f=e.ref!==void 0?{[d]:e.ref}:{},g=typeof c=="function"?c(n):c;g=l1(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(Tc(i)&&(Object.keys(Lo(u)).length>0||Object.keys(Lo(b)).length>0))if(!p.isValidElement(g)||Array.isArray(g)&&g.length>1||bA(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(`
|
|
511
|
+
`),"","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(`
|
|
512
|
+
`)].join(`
|
|
513
|
+
`))}else{let x=g.props,h=x==null?void 0:x.className,v=typeof h=="function"?(...k)=>Fg(h(...k),u.className):Fg(h,u.className),y=v?{className:v}:{},j=a1(g.props,Lo(Kp(u,["ref"])));for(let k in b)k in j&&delete b[k];return p.cloneElement(g,Object.assign({},j,b,f,{ref:o(yA(g),f.ref)},y))}return p.createElement(i,Object.assign({},Kp(u,["ref"]),!Tc(i)&&f,!Tc(i)&&b),g)}function xA(){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 vA(...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 a1(...e){if(e.length===0)return{};if(e.length===1)return e[0];let n={},s={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(s[o]!=null||(s[o]=[]),s[o].push(r[o])):n[o]=r[o];if(n.disabled||n["aria-disabled"])for(let r in s)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(s[r]=[o=>{var i;return(i=o==null?void 0:o.preventDefault)==null?void 0:i.call(o)}]);for(let r in s)Object.assign(n,{[r](o,...i){let c=s[r];for(let d of c){if((o instanceof Event||(o==null?void 0:o.nativeEvent)instanceof Event)&&o.defaultPrevented)return;d(o,...i)}}});return n}function i1(...e){if(e.length===0)return{};if(e.length===1)return e[0];let n={},s={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(s[o]!=null||(s[o]=[]),s[o].push(r[o])):n[o]=r[o];for(let r in s)Object.assign(n,{[r](...o){let i=s[r];for(let c of i)c==null||c(...o)}});return n}function xn(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 Kp(e,n=[]){let s=Object.assign({},e);for(let r of n)r in s&&delete s[r];return s}function yA(e){return Ke.version.split(".")[0]>="19"?e.props.ref:e.ref}function l1(e){if(e!=null&&e.$$typeof===Symbol.for("react.lazy")){let n=e._payload;if(n!=null&&n.status==="fulfilled")return l1(n.value)}return e}function Tc(e){return e===p.Fragment||e===Symbol.for("react.fragment")}function bA(e){return Tc(e.type)}function wA(e,n,s){let[r,o]=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,ut(f=>(i||Ns.flushSync(()=>o(f)),n==null?void 0:n(f)))]}function jA(e){let[n]=p.useState(e);return n}function c1(e={},n=null,s=[]){for(let[r,o]of Object.entries(e))u1(s,d1(n,r),o);return s}function d1(e,n){return e?e+"["+n+"]":n}function u1(e,n,s){if(Array.isArray(s))for(let[r,o]of s.entries())u1(e,d1(n,r.toString()),o);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,""]):NA(s)&&!p.isValidElement(s)&&c1(s,n,e)}function kA(e){var n,s;let r=(n=e==null?void 0:e.form)!=null?n:e.closest("form");if(r){for(let o of r.elements)if(o!==e&&(o.tagName==="INPUT"&&o.type==="submit"||o.tagName==="BUTTON"&&o.type==="submit"||o.nodeName==="INPUT"&&o.type==="image")){o.click();return}(s=r.requestSubmit)==null||s.call(r)}}function NA(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||Object.getPrototypeOf(n)===null}let SA="span";var ll=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(ll||{});function CA(e,n){var s;let{features:r=1,...o}=e,i={ref:n,"aria-hidden":(r&2)===2?!0:(s=o["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 En()({ourProps:i,theirProps:o,slot:{},defaultTag:SA,name:"Hidden"})}let zc=xn(CA),EA=p.createContext(null);function $A({children:e}){let n=p.useContext(EA);if(!n)return Ke.createElement(Ke.Fragment,null,e);let{target:s}=n;return s?Ns.createPortal(Ke.createElement(Ke.Fragment,null,e),s):null}function _A({data:e,form:n,disabled:s,onReset:r,overrides:o}){let[i,c]=p.useState(null),d=Zo();return p.useEffect(()=>{if(r&&i)return d.addEventListener(i,"reset",r)},[i,n,r]),Ke.createElement($A,null,Ke.createElement(TA,{setForm:c,formId:n}),c1(e).map(([u,f])=>Ke.createElement(zc,{features:ll.Hidden,...Lo({key:u,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:n,disabled:s,name:u,value:f,...o})})))}function TA({setForm:e,formId:n}){return p.useEffect(()=>{if(n){let s=document.getElementById(n);s&&e(s)}},[e,n]),n?null:Ke.createElement(zc,{features:ll.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:s=>{if(!s)return;let r=s.closest("form");r&&e(r)}})}let RA=p.createContext(void 0);function f1(){return p.useContext(RA)}function m1(e){return typeof e!="object"||e===null?!1:"nodeType"in e}function Xr(e){return m1(e)&&"tagName"in e}function Ss(e){return Xr(e)&&"accessKey"in e}function Yr(e){return Xr(e)&&"tabIndex"in e}function AA(e){return Xr(e)&&"style"in e}function OA(e){return Ss(e)&&e.nodeName==="IFRAME"}function h1(e){return Ss(e)&&e.nodeName==="INPUT"}function gj(e){return Ss(e)&&e.nodeName==="LABEL"}function MA(e){return Ss(e)&&e.nodeName==="FIELDSET"}function p1(e){return Ss(e)&&e.nodeName==="LEGEND"}function PA(e){return Xr(e)?e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]'):!1}function xj(e){let n=e.parentElement,s=null;for(;n&&!MA(n);)p1(n)&&(s=n),n=n.parentElement;let r=(n==null?void 0:n.getAttribute("disabled"))==="";return r&&LA(s)?!1:r}function LA(e){if(!e)return!1;let n=e.previousElementSibling;for(;n!==null;){if(p1(n))return!1;n=n.previousElementSibling}return!0}let g1=Symbol();function IA(e,n=!0){return Object.assign(e,{[g1]:n})}function Fn(...e){let n=p.useRef(e);p.useEffect(()=>{n.current=e},[e]);let s=ut(r=>{for(let o of n.current)o!=null&&(typeof o=="function"?o(r):o.current=r)});return e.every(r=>r==null||(r==null?void 0:r[g1]))?void 0:s}let ym=p.createContext(null);ym.displayName="DescriptionContext";function x1(){let e=p.useContext(ym);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,x1),n}return e}function zA(){var e,n;return(n=(e=p.useContext(ym))==null?void 0:e.value)!=null?n:void 0}function DA(){let[e,n]=p.useState([]);return[e.length>0?e.join(" "):void 0,p.useMemo(()=>function(s){let r=ut(i=>(n(c=>[...c,i]),()=>n(c=>{let d=c.slice(),u=d.indexOf(i);return u!==-1&&d.splice(u,1),d}))),o=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 Ke.createElement(ym.Provider,{value:o},s.children)},[n])]}let FA="p";function UA(e,n){let s=p.useId(),r=nv(),{id:o=`headlessui-description-${s}`,...i}=e,c=x1(),d=Fn(n);tn(()=>c.register(o),[o,c.register]);let u=Ks({...c.slot,disabled:r||!1}),f={ref:d,...c.props,id:o};return En()({ourProps:f,theirProps:i,slot:u,defaultTag:FA,name:c.name||"Description"})}let WA=xn(UA),v1=Object.assign(WA,{});var bn=(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))(bn||{});let bm=p.createContext(null);bm.displayName="LabelContext";function y1(){let e=p.useContext(bm);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,y1),n}return e}function b1(e){var n,s,r;let o=(s=(n=p.useContext(bm))==null?void 0:n.value)!=null?s:void 0;return((r=e==null?void 0:e.length)!=null?r:0)>0?[o,...e].filter(Boolean).join(" "):o}function HA({inherit:e=!1}={}){let n=b1(),[s,r]=p.useState([]),o=e?[n,...s].filter(Boolean):s;return[o.length>0?o.join(" "):void 0,p.useMemo(()=>function(i){let c=ut(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 Ke.createElement(bm.Provider,{value:d},i.children)},[r])]}let BA="label";function GA(e,n){var s;let r=p.useId(),o=y1(),i=f1(),c=nv(),{id:d=`headlessui-label-${r}`,htmlFor:u=i??((s=o.props)==null?void 0:s.htmlFor),passive:f=!1,...g}=e,b=Fn(n);tn(()=>o.register(d),[d,o.register]);let x=ut(y=>{let j=y.currentTarget;if(!(y.target!==y.currentTarget&&PA(y.target))&&(gj(j)&&y.preventDefault(),o.props&&"onClick"in o.props&&typeof o.props.onClick=="function"&&o.props.onClick(y),gj(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;(h1(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({...o.slot,disabled:c||!1}),v={ref:b,...o.props,id:d,htmlFor:u,onClick:x};return f&&("onClick"in v&&(delete v.htmlFor,delete v.onClick),"onClick"in g&&delete g.onClick),En()({ourProps:v,theirProps:g,slot:h,defaultTag:u?BA:"div",name:o.name||"Label"})}let qA=xn(GA),KA=Object.assign(qA,{}),VA=p.createContext(()=>{});function YA({value:e,children:n}){return Ke.createElement(VA.Provider,{value:e},n)}function QA(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 JA(e=QA){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 vj(e){if(e===null)return{width:0,height:0};let{width:n,height:s}=e.getBoundingClientRect();return{width:n,height:s}}function XA(e,n,s=!1){let[r,o]=p.useState(()=>vj(n));return tn(()=>{if(!n||!e)return;let i=$s();return i.requestAnimationFrame(function c(){i.requestAnimationFrame(c),o(d=>{let u=vj(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 w1=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(w1||{});function ZA(e){let n=p.useRef(null),s=ut(o=>{n.current=o.pointerType,!xj(o.currentTarget)&&o.pointerType==="mouse"&&o.button===w1.Left&&(o.preventDefault(),e(o))}),r=ut(o=>{n.current!=="mouse"&&(xj(o.currentTarget)||e(o))});return{onPointerDown:s,onClick:r}}let j1=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 e3=Object.defineProperty,t3=(e,n,s)=>n in e?e3(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,n3=(e,n,s)=>(t3(e,n+"",s),s),k1=(e,n,s)=>{if(!n.has(e))throw TypeError("Cannot "+s)},zs=(e,n,s)=>(k1(e,n,"read from private field"),s?s.call(e):n.get(e)),Vp=(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)},yj=(e,n,s,r)=>(k1(e,n,"write to private field"),n.set(e,s),s),jr,Nc,Sc;let N1=class{constructor(n){Vp(this,jr,{}),Vp(this,Nc,new j1(()=>new Set)),Vp(this,Sc,new Set),n3(this,"disposables",$s()),yj(this,jr,n),Cr.isServer&&this.disposables.microTask(()=>{this.dispose()})}dispose(){this.disposables.dispose()}get state(){return zs(this,jr)}subscribe(n,s){if(Cr.isServer)return()=>{};let r={selector:n,callback:s,current:n(zs(this,jr))};return zs(this,Sc).add(r),this.disposables.add(()=>{zs(this,Sc).delete(r)})}on(n,s){return Cr.isServer?()=>{}:(zs(this,Nc).get(n).add(s),this.disposables.add(()=>{zs(this,Nc).get(n).delete(s)}))}send(n){let s=this.reduce(zs(this,jr),n);if(s!==zs(this,jr)){yj(this,jr,s);for(let r of zs(this,Sc)){let o=r.selector(zs(this,jr));S1(r.current,o)||(r.current=o,r.callback(o))}for(let r of zs(this,Nc).get(n.type))r(zs(this,jr),n)}}};jr=new WeakMap,Nc=new WeakMap,Sc=new WeakMap;function S1(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:Yp(e[Symbol.iterator](),n[Symbol.iterator]()):e instanceof Map&&n instanceof Map||e instanceof Set&&n instanceof Set?e.size!==n.size?!1:Yp(e.entries(),n.entries()):bj(e)&&bj(n)?Yp(Object.entries(e)[Symbol.iterator](),Object.entries(n)[Symbol.iterator]()):!1}function Yp(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 bj(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=$s();return(...o)=>{n(...o),r.dispose(),r.microTask(s)}}var s3=Object.defineProperty,r3=(e,n,s)=>n in e?s3(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,wj=(e,n,s)=>(r3(e,typeof n!="symbol"?n+"":n,s),s),C1=(e=>(e[e.Push=0]="Push",e[e.Pop=1]="Pop",e))(C1||{});let o3={0(e,n){let s=n.id,r=e.stack,o=e.stack.indexOf(s);if(o!==-1){let i=e.stack.slice();return i.splice(o,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 o=e.stack.slice();return o.splice(r,1),{...e,stack:o}}},a3=class E1 extends N1{constructor(){super(...arguments),wj(this,"actions",{push:n=>this.send({type:0,id:n}),pop:n=>this.send({type:1,id:n})}),wj(this,"selectors",{isTop:(n,s)=>n.stack[n.stack.length-1]===s,inStack:(n,s)=>n.stack.includes(s)})}static new(){return new E1({stack:[]})}reduce(n,s){return ts(s.type,o3,n,s)}};const wm=new j1(()=>a3.new());var Jp={exports:{}},Xp={};/**
|
|
514
|
+
* @license React
|
|
515
|
+
* use-sync-external-store-with-selector.production.js
|
|
516
|
+
*
|
|
517
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
518
|
+
*
|
|
519
|
+
* This source code is licensed under the MIT license found in the
|
|
520
|
+
* LICENSE file in the root directory of this source tree.
|
|
521
|
+
*/var jj;function i3(){if(jj)return Xp;jj=1;var e=cm();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,o=e.useRef,i=e.useEffect,c=e.useMemo,d=e.useDebugValue;return Xp.useSyncExternalStoreWithSelector=function(u,f,g,b,x){var h=o(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 M=b($);return x!==void 0&&x(_,M)?(E=$,_):(E=$,S=M)}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},Xp}var kj;function l3(){return kj||(kj=1,Jp.exports=i3()),Jp.exports}var c3=l3();function Qn(e,n,s=S1){return c3.useSyncExternalStoreWithSelector(ut(r=>e.subscribe(d3,r)),ut(()=>e.state),ut(()=>e.state),ut(n),s)}function d3(e){return e}function rd(e,n){let s=p.useId(),r=wm.get(n),[o,i]=Qn(r,p.useCallback(c=>[r.selectors.isTop(c,s),r.selectors.inStack(c,s)],[r,s]));return tn(()=>{if(e)return r.actions.push(s),()=>r.actions.pop(s)},[r,e,s]),e?i?o:!0:!1}let Ug=new Map,Rc=new Map;function Nj(e){var n;let s=(n=Rc.get(e))!=null?n:0;return Rc.set(e,s+1),s!==0?()=>Sj(e):(Ug.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Sj(e))}function Sj(e){var n;let s=(n=Rc.get(e))!=null?n:1;if(s===1?Rc.delete(e):Rc.set(e,s-1),s!==1)return;let r=Ug.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,Ug.delete(e))}function $1(e,{allowed:n,disallowed:s}={}){let r=rd(e,"inert-others");tn(()=>{var o,i;if(!r)return;let c=$s();for(let u of(o=s==null?void 0:s())!=null?o:[])u&&c.add(Nj(u));let d=(i=n==null?void 0:n())!=null?i:[];for(let u of d){if(!u)continue;let f=wl(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(Nj(b));g=g.parentElement}}return c.dispose},[r,n,s])}function _1(e,n,s){let r=ea(o=>{let i=o.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&s()});p.useEffect(()=>{if(!e)return;let o=n===null?null:Ss(n)?n:n.current;if(!o)return;let i=$s();if(typeof ResizeObserver<"u"){let c=new ResizeObserver(()=>r.current(o));c.observe(o),i.add(()=>c.disconnect())}if(typeof IntersectionObserver<"u"){let c=new IntersectionObserver(()=>r.current(o));c.observe(o),i.add(()=>c.disconnect())}return()=>i.dispose()},[n,r,e])}let _f=["[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(","),u3=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var lr=(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))(lr||{}),Wg=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(Wg||{}),f3=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(f3||{});function T1(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(_f)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}function m3(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(u3)).sort((n,s)=>Math.sign((n.tabIndex||Number.MAX_SAFE_INTEGER)-(s.tabIndex||Number.MAX_SAFE_INTEGER)))}var sv=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(sv||{});function R1(e,n=0){var s;return e===((s=wl(e))==null?void 0:s.body)?!1:ts(n,{0(){return e.matches(_f)},1(){let r=e;for(;r!==null;){if(r.matches(_f))return!0;r=r.parentElement}return!1}})}var h3=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(h3||{});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 Zr(e){e==null||e.focus({preventScroll:!0})}let p3=["textarea","input"].join(",");function g3(e){var n,s;return(s=(n=e==null?void 0:e.matches)==null?void 0:n.call(e,p3))!=null?s:!1}function A1(e,n=s=>s){return e.slice().sort((s,r)=>{let o=n(s),i=n(r);if(o===null||i===null)return 0;let c=o.compareDocumentPosition(i);return c&Node.DOCUMENT_POSITION_FOLLOWING?-1:c&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function x3(e,n,s=e===null?document.body:$f(e)){return Vi(T1(s),n,{relativeTo:e})}function Vi(e,n,{sorted:s=!0,relativeTo:r=null,skipElements:o=[]}={}){let i=Array.isArray(e)?e.length>0?$f(e[0]):document:$f(e),c=Array.isArray(e)?s?A1(e):e:n&64?m3(e):T1(e);o.length>0&&c.length>1&&(c=c.filter(h=>!o.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!==r1(x));return n&6&&g3(x)&&x.select(),2}function O1(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function v3(){return/Android/gi.test(window.navigator.userAgent)}function Cj(){return O1()||v3()}function Ui(e,n,s,r){let o=ea(s);p.useEffect(()=>{if(!e)return;function i(c){o.current(c)}return document.addEventListener(n,i,r),()=>document.removeEventListener(n,i,r)},[e,n,r])}function M1(e,n,s,r){let o=ea(s);p.useEffect(()=>{if(!e)return;function i(c){o.current(c)}return window.addEventListener(n,i,r),()=>window.removeEventListener(n,i,r)},[e,n,r])}const Ej=30;function P1(e,n,s){let r=ea(s),o=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!R1(f,sv.Loose)&&f.tabIndex!==-1&&d.preventDefault(),r.current(d,f)},[r,n]),i=p.useRef(null);Ui(e,"pointerdown",d=>{var u,f;Cj()||(i.current=((f=(u=d.composedPath)==null?void 0:u.call(d))==null?void 0:f[0])||d.target)},!0),Ui(e,"pointerup",d=>{if(Cj()||!i.current)return;let u=i.current;return i.current=null,o(d,()=>u)},!0);let c=p.useRef({x:0,y:0});Ui(e,"touchstart",d=>{c.current.x=d.touches[0].clientX,c.current.y=d.touches[0].clientY},!0),Ui(e,"touchend",d=>{let u={x:d.changedTouches[0].clientX,y:d.changedTouches[0].clientY};if(!(Math.abs(u.x-c.current.x)>=Ej||Math.abs(u.y-c.current.y)>=Ej))return o(d,()=>Yr(d.target)?d.target:null)},!0),M1(e,"blur",d=>o(d,()=>OA(window.document.activeElement)?window.document.activeElement:null),!0)}function Dc(...e){return p.useMemo(()=>wl(...e),[...e])}var y3=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(y3||{});const Wu={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},b3=200,$j=5;function w3(e,{trigger:n,action:s,close:r,select:o}){let i=p.useRef(null),c=p.useRef(null),d=p.useRef(null);Ui(e&&n!==null,"pointerdown",u=>{m1(u==null?void 0:u.target)&&n!=null&&n.contains(u.target)&&(c.current=u.x,d.current=u.y,i.current=u.timeStamp)}),Ui(e&&n!==null,"pointerup",u=>{var f,g;let b=i.current;if(b===null||(i.current=null,!Yr(u.target))||Math.abs(u.x-((f=c.current)!=null?f:u.x))<$j&&Math.abs(u.y-((g=d.current)!=null?g:u.y))<$j)return;let x=s(u);switch(x.kind){case 0:return;case 1:{u.timeStamp-b>b3&&(o(x.target),r());break}case 2:{r();break}}},{capture:!0})}function L1(e,n,s,r){let o=ea(s);p.useEffect(()=>{e=e??window;function i(c){o.current(c)}return e.addEventListener(n,i,r),()=>e.removeEventListener(n,i,r)},[e,n,r])}function j3(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 k3(e){return p.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function N3(e,n){let s=e(),r=new Set;return{getSnapshot(){return s},subscribe(o){return r.add(o),()=>r.delete(o)},dispatch(o,...i){let c=n[o].call(s,...i);c&&(s=c,r.forEach(d=>d()))}}}function S3(){let e;return{before({doc:n}){var s;let r=n.documentElement,o=(s=n.defaultView)!=null?s:window;e=Math.max(0,o.innerWidth-r.clientWidth)},after({doc:n,d:s}){let r=n.documentElement,o=Math.max(0,r.clientWidth-r.offsetWidth),i=Math.max(0,e-o);s.style(r,"paddingRight",`${i}px`)}}}function C3(){return O1()?{before({doc:e,d:n,meta:s}){function r(o){for(let i of s().containers)for(let c of i())if(c.contains(o))return!0;return!1}n.microTask(()=>{var o;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let d=$s();d.style(e.documentElement,"scrollBehavior","auto"),n.add(()=>n.microTask(()=>d.dispose()))}let i=(o=window.scrollY)!=null?o:window.pageYOffset,c=null;n.addEventListener(e,"click",d=>{if(Yr(d.target))try{let u=d.target.closest("a");if(!u)return;let{hash:f}=new URL(u.href),g=e.querySelector(f);Yr(g)&&!r(g)&&(c=g)}catch{}},!0),n.group(d=>{n.addEventListener(e,"touchstart",u=>{if(d.dispose(),Yr(u.target)&&AA(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(Yr(d.target)){if(h1(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 E3(){return{before({doc:e,d:n}){n.style(e.documentElement,"overflow","hidden")}}}function _j(e){let n={};for(let s of e)Object.assign(n,s(n));return n}let Aa=N3(()=>new Map,{PUSH(e,n){var s;let r=(s=this.get(e))!=null?s:{doc:e,count:0,d:$s(),meta:new Set,computedMeta:{}};return r.count++,r.meta.add(n),r.computedMeta=_j(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=_j(s.meta)),this},SCROLL_PREVENT(e){let n={doc:e.doc,d:e.d,meta(){return e.computedMeta}},s=[C3(),S3(),E3()];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)}});Aa.subscribe(()=>{let e=Aa.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",o=s.count!==0;(o&&!r||!o&&r)&&Aa.dispatch(s.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",s),s.count===0&&Aa.dispatch("TEARDOWN",s)}});function $3(e,n,s=()=>({containers:[]})){let r=k3(Aa),o=n?r.get(n):void 0,i=o?o.count>0:!1;return tn(()=>{if(!(!n||!e))return Aa.dispatch("PUSH",n,s),()=>Aa.dispatch("POP",n,s)},[e,n]),i}function I1(e,n,s=()=>[document.body]){let r=rd(e,"scroll-lock");$3(r,n,o=>{var i;return{containers:[...(i=o.containers)!=null?i:[],s]}})}function Tj(e){return[e.screenX,e.screenY]}function _3(){let e=p.useRef([-1,-1]);return{wasMoved(n){let s=Tj(n);return e.current[0]===s[0]&&e.current[1]===s[1]?!1:(e.current=s,!0)},update(n){e.current=Tj(n)}}}function T3(e=0){let[n,s]=p.useState(e),r=p.useCallback(u=>s(u),[]),o=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:o,hasFlag:i,removeFlag:c,toggleFlag:d}}var R3={},Rj,Aj;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Rj=process==null?void 0:R3)==null?void 0:Rj.NODE_ENV)==="test"&&typeof((Aj=Element==null?void 0:Element.prototype)==null?void 0:Aj.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(`
|
|
522
|
+
`)),[]});var A3=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(A3||{});function z1(e){let n={};for(let s in e)e[s]===!0&&(n[`data-${s}`]="");return n}function D1(e,n,s,r){let[o,i]=p.useState(s),{hasFlag:c,addFlag:d,removeFlag:u}=T3(e&&o?3:0),f=p.useRef(!1),g=p.useRef(!1),b=Zo();return tn(()=>{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),O3(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&&L3(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?[o,{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 O3(e,{prepare:n,run:s,done:r,inFlight:o}){let i=$s();return P3(e,{prepare:n,inFlight:o}),i.nextFrame(()=>{s(),i.requestAnimationFrame(()=>{i.add(M3(e,r))})}),i.dispose}function M3(e,n){var s,r;let o=$s();if(!e)return o.dispose;let i=!1;o.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(),o.dispose):(Promise.allSettled(c.map(d=>d.finished)).then(()=>{i||n()}),o.dispose)}function P3(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 L3(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 rv(e,n){let s=p.useRef([]),r=ut(e);p.useEffect(()=>{let o=[...s.current];for(let[i,c]of n.entries())if(s.current[i]!==c){let d=r(n,o);return s.current=n,d}},[r,...n])}function jm(){return typeof window<"u"}function jl(e){return F1(e)?(e.nodeName||"").toLowerCase():"#document"}function ms(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function ao(e){var n;return(n=(F1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function F1(e){return jm()?e instanceof Node||e instanceof ms(e).Node:!1}function fs(e){return jm()?e instanceof Element||e instanceof ms(e).Element:!1}function ta(e){return jm()?e instanceof HTMLElement||e instanceof ms(e).HTMLElement:!1}function Oj(e){return!jm()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ms(e).ShadowRoot}function km(e){const{overflow:n,overflowX:s,overflowY:r,display:o}=_r(e);return/auto|scroll|overlay|hidden|clip/.test(n+r+s)&&o!=="inline"&&o!=="contents"}function I3(e){return/^(table|td|th)$/.test(jl(e))}function Nm(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const z3=/transform|translate|scale|rotate|perspective|filter/,D3=/paint|layout|strict|content/,ka=e=>!!e&&e!=="none";let Zp;function ov(e){const n=fs(e)?_r(e):e;return ka(n.transform)||ka(n.translate)||ka(n.scale)||ka(n.rotate)||ka(n.perspective)||!av()&&(ka(n.backdropFilter)||ka(n.filter))||z3.test(n.willChange||"")||D3.test(n.contain||"")}function F3(e){let n=Da(e);for(;ta(n)&&!Fc(n);){if(ov(n))return n;if(Nm(n))return null;n=Da(n)}return null}function av(){return Zp==null&&(Zp=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Zp}function Fc(e){return/^(html|body|#document)$/.test(jl(e))}function _r(e){return ms(e).getComputedStyle(e)}function Sm(e){return fs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Da(e){if(jl(e)==="html")return e;const n=e.assignedSlot||e.parentNode||Oj(e)&&e.host||ao(e);return Oj(n)?n.host:n}function U1(e){const n=Da(e);return Fc(n)?(e.ownerDocument||e).body:ta(n)&&km(n)?n:U1(n)}function Uc(e,n,s){var r;n===void 0&&(n=[]),s===void 0&&(s=!0);const o=U1(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),c=ms(o);if(i){const d=Hg(c);return n.concat(c,c.visualViewport||[],km(o)?o:[],d&&s?Uc(d):[])}else return n.concat(o,Uc(o,[],s))}function Hg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function U3(){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 Fa=Math.min,Hs=Math.max,Wc=Math.round,Hu=Math.floor,eo=e=>({x:e,y:e}),W3={left:"right",right:"left",bottom:"top",top:"bottom"};function H3(e,n,s){return Hs(e,Fa(n,s))}function kl(e,n){return typeof e=="function"?e(n):e}function Ua(e){return e.split("-")[0]}function od(e){return e.split("-")[1]}function W1(e){return e==="x"?"y":"x"}function H1(e){return e==="y"?"height":"width"}function Qr(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function B1(e){return W1(Qr(e))}function B3(e,n,s){s===void 0&&(s=!1);const r=od(e),o=B1(e),i=H1(o);let c=o==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return n.reference[i]>n.floating[i]&&(c=Tf(c)),[c,Tf(c)]}function G3(e){const n=Tf(e);return[Bg(e),n,Bg(n)]}function Bg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Mj=["left","right"],Pj=["right","left"],q3=["top","bottom"],K3=["bottom","top"];function V3(e,n,s){switch(e){case"top":case"bottom":return s?n?Pj:Mj:n?Mj:Pj;case"left":case"right":return n?q3:K3;default:return[]}}function Y3(e,n,s,r){const o=od(e);let i=V3(Ua(e),s==="start",r);return o&&(i=i.map(c=>c+"-"+o),n&&(i=i.concat(i.map(Bg)))),i}function Tf(e){const n=Ua(e);return W3[n]+e.slice(n.length)}function Q3(e){var n,s,r,o;return{top:(n=e.top)!=null?n:0,right:(s=e.right)!=null?s:0,bottom:(r=e.bottom)!=null?r:0,left:(o=e.left)!=null?o:0}}function J3(e){return typeof e!="number"?Q3(e):{top:e,right:e,bottom:e,left:e}}function Rf(e){const{x:n,y:s,width:r,height:o}=e;return{width:r,height:o,top:s,left:n,right:n+r,bottom:s+o,x:n,y:s}}function Lj(e,n,s){let{reference:r,floating:o}=e;const i=Qr(n),c=B1(n),d=H1(c),u=Ua(n),f=i==="y",g=r.x+r.width/2-o.width/2,b=r.y+r.height/2-o.height/2,x=r[d]/2-o[d]/2;let h;switch(u){case"top":h={x:g,y:r.y-o.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-o.width,y:b};break;default:h={x:r.x,y:r.y}}const v=od(n);return v&&(h[c]+=x*(v==="end"?1:-1)*(s&&f?-1:1)),h}async function G1(e,n){var s;n===void 0&&(n={});const{x:r,y:o,platform:i,rects:c,elements:d,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:g="viewport",elementContext:b="floating",altBoundary:x=!1,padding:h=0}=kl(n,e),v=J3(h),j=d[x?b==="floating"?"reference":"floating":b],k=Rf(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:o,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},$=Rf(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 X3=50,Z3=async(e,n,s)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:c}=s,d=c.detectOverflow?c:{...c,detectOverflow:G1},u=await(c.isRTL==null?void 0:c.isRTL(n));let f=await c.getElementRects({reference:e,floating:n,strategy:o}),{x:g,y:b}=Lj(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:o,middlewareData:v,rects:f,platform:d,elements:{reference:e,floating:n}});g=S??g,b=N??b,v[k]={...v[k],...$},_&&h<X3&&(h++,typeof _=="object"&&(_.placement&&(x=_.placement),_.rects&&(f=_.rects===!0?await c.getElementRects({reference:e,floating:n,strategy:o}):_.rects),{x:g,y:b}=Lj(f,x,u)),y=-1)}return{x:g,y:b,placement:x,strategy:o,middlewareData:v}},e4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var s,r;const{placement:o,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}=kl(e,n);if((s=i.arrow)!=null&&s.alignmentOffset)return{};const k=Ua(o),E=Qr(d),S=Ua(d)===d,N=await(u.isRTL==null?void 0:u.isRTL(f.floating)),$=x||(S||!y?[Tf(d)]:G3(d)),_=v!=="none";!x&&_&&$.push(...Y3(d,y,v,N));const M=[d,...$],O=await u.detectOverflow(n,j),L=[];let R=((r=i.flip)==null?void 0:r.overflows)||[];if(g&&L.push(O[k]),b){const U=B3(o,c,N);L.push(O[U[0]],O[U[1]])}if(R=[...R,{placement:o,overflows:L}],!L.every(U=>U<=0)){var A,P;const U=(((A=i.flip)==null?void 0:A.index)||0)+1,q=M[U];if(q&&(!(b==="alignment"?E!==Qr(q):!1)||R.every(W=>Qr(W.placement)===E?W.overflows[0]>0:!0)))return{data:{index:U,overflows:R},reset:{placement:q}};let H=(P=R.filter(K=>K.overflows[0]<=0).sort((K,W)=>K.overflows[1]-W.overflows[1])[0])==null?void 0:P.placement;if(!H)switch(h){case"bestFit":{var z;const K=(z=R.filter(W=>{if(_){const G=Qr(W.placement);return G===E||G==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(G=>G>0).reduce((G,F)=>G+F,0)]).sort((W,G)=>W[1]-G[1])[0])==null?void 0:z[0];K&&(H=K);break}case"initialPlacement":H=d;break}if(o!==H)return{reset:{placement:H}}}return{}}}},t4=new Set(["left","top"]);async function n4(e,n){const{placement:s,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),c=Ua(s),d=od(s),u=Qr(s)==="y",f=t4.has(c)?-1:1,g=i&&u?-1:1,b=kl(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 s4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var s,r;const{x:o,y:i,placement:c,middlewareData:d}=n,u=await n4(n,e);return c===((s=d.offset)==null?void 0:s.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:c}}}}},r4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:s,y:r,placement:o,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}=kl(e,n),g={x:s,y:r},b=await i.detectOverflow(n,f),x=Qr(o),h=W1(x);let v=g[h],y=g[x];const j=(E,S)=>H3(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}}}}}},o4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){const{placement:s,rects:r,platform:o,elements:i}=n,{apply:c=()=>{},...d}=kl(e,n),u=await o.detectOverflow(n,d),f=Ua(s),g=od(s),b=Qr(s)==="y",{width:x,height:h}=r.floating;let v,y;f==="top"||f==="bottom"?(v=f,y=g===(await(o.isRTL==null?void 0:o.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=Fa(h-u[v],j),S=Fa(x-u[y],k),N=n.middlewareData.shift,$=!N;let _=E,M=S;N!=null&&N.enabled.x&&(M=k),N!=null&&N.enabled.y&&(_=j),$&&!g&&(b?M=x-2*Hs(u.left,u.right):_=h-2*Hs(u.top,u.bottom)),await c({...n,availableWidth:M,availableHeight:_});const O=await o.getDimensions(i.floating);return x!==O.width||h!==O.height?{reset:{rects:!0}}:{}}}};function q1(e){const n=_r(e);let s=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const o=ta(e),i=o?e.offsetWidth:s,c=o?e.offsetHeight:r,d=Wc(s)!==i||Wc(r)!==c;return d&&(s=i,r=c),{width:s,height:r,$:d}}function iv(e){return fs(e)?e:e.contextElement}function Yi(e){const n=iv(e);if(!ta(n))return eo(1);const s=n.getBoundingClientRect(),{width:r,height:o,$:i}=q1(n);let c=(i?Wc(s.width):s.width)/r,d=(i?Wc(s.height):s.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const a4=eo(0);function K1(e){const n=ms(e);return!av()||!n.visualViewport?a4:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function i4(e,n,s){return n===void 0&&(n=!1),!!s&&n&&s===ms(e)}function Wa(e,n,s,r){n===void 0&&(n=!1),s===void 0&&(s=!1);const o=e.getBoundingClientRect(),i=iv(e);let c=eo(1);n&&(r?fs(r)&&(c=Yi(r)):c=Yi(e));const d=i4(i,s,r)?K1(i):eo(0);let u=(o.left+d.x)/c.x,f=(o.top+d.y)/c.y,g=o.width/c.x,b=o.height/c.y;if(i&&r){const x=ms(i),h=fs(r)?ms(r):r;let v=x,y=Hg(v);for(;y&&h!==v;){const j=Yi(y),k=y.getBoundingClientRect(),E=_r(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=ms(y),y=Hg(v)}}return Rf({width:g,height:b,x:u,y:f})}function Cm(e,n){const s=Sm(e).scrollLeft;return n?n.left+s:Wa(ao(e)).left+s}function V1(e,n){const s=e.getBoundingClientRect(),r=s.left+n.scrollLeft-Cm(e,s),o=s.top+n.scrollTop;return{x:r,y:o}}function l4(e){let{elements:n,rect:s,offsetParent:r,strategy:o}=e;const i=o==="fixed",c=ao(r),d=n?Nm(n.floating):!1;if(r===c||d&&i)return s;let u={scrollLeft:0,scrollTop:0},f=eo(1);const g=eo(0),b=ta(r);if((b||!i)&&((jl(r)!=="body"||km(c))&&(u=Sm(r)),b)){const h=Wa(r);f=Yi(r),g.x=h.x+r.clientLeft,g.y=h.y+r.clientTop}const x=c&&!b&&!i?V1(c,u):eo(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 c4(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function d4(e){const n=Sm(e),s=e.ownerDocument.body,r=Hs(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),o=Hs(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+Cm(e);const c=-n.scrollTop;return _r(s).direction==="rtl"&&(i+=Hs(e.clientWidth,s.clientWidth)-r),{width:r,height:o,x:i,y:c}}const u4=25;function f4(e,n,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",o=ms(e),i=ao(e),c=o.visualViewport;let d=i.clientWidth,u=i.clientHeight,f=0,g=0;if(c){const x=!av()||n==="fixed";r?x||(f=-c.offsetLeft,g=-c.offsetTop):(d=c.width,u=c.height,x&&(f=c.offsetLeft,g=c.offsetTop))}if(Cm(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<=u4&&(d-=k)}return{width:d,height:u,x:f,y:g}}function m4(e,n){const s=Wa(e,!0,n==="fixed"),r=s.top+e.clientTop,o=s.left+e.clientLeft,i=Yi(e),c=e.clientWidth*i.x,d=e.clientHeight*i.y,u=o*i.x,f=r*i.y;return{width:c,height:d,x:u,y:f}}function Ij(e,n,s){let r;if(n==="viewport"||n==="layoutViewport")r=f4(e,s,n);else if(n==="document")r=d4(ao(e));else if(fs(n))r=m4(n,s);else{const o=K1(e);r={x:n.x-o.x,y:n.y-o.y,width:n.width,height:n.height}}return Rf(r)}function h4(e,n){const s=n.get(e);if(s)return s;let r=Uc(e,[],!1).filter(d=>fs(d)&&jl(d)!=="body"),o=null;const i=_r(e).position==="fixed";let c=i?Da(e):e;for(;fs(c)&&!Fc(c);){const d=_r(c),u=ov(c),f=o?o.position:i?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&d.position==="static")?r=r.filter(b=>b!==c):o=d,c=Da(c)}return n.set(e,r),r}function p4(e){let{element:n,boundary:s,rootBoundary:r,strategy:o}=e;const c=[...s==="clippingAncestors"?Nm(n)?[]:h4(n,this._c):[].concat(s),r],d=Ij(n,c[0],o);let u=d.top,f=d.right,g=d.bottom,b=d.left;for(let x=1;x<c.length;x++){const h=Ij(n,c[x],o);u=Hs(h.top,u),f=Fa(h.right,f),g=Fa(h.bottom,g),b=Hs(h.left,b)}return{width:f-b,height:g-u,x:b,y:u}}function g4(e){const{width:n,height:s}=q1(e);return{width:n,height:s}}function x4(e,n,s){const r=ta(n),o=ao(n),i=s==="fixed",c=Wa(e,!0,i,n);let d={scrollLeft:0,scrollTop:0};const u=eo(0);if((r||!i)&&((jl(n)!=="body"||km(o))&&(d=Sm(n)),r)){const x=Wa(n,!0,i,n);u.x=x.x+n.clientLeft,u.y=x.y+n.clientTop}!r&&o&&(u.x=Cm(o));const f=o&&!r&&!i?V1(o,d):eo(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 eg(e){return _r(e).position==="static"}function zj(e,n){if(!ta(e)||_r(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return ao(e)===s&&(s=s.ownerDocument.body),s}function Y1(e,n){const s=ms(e);if(Nm(e))return s;if(!ta(e)){let o=Da(e);for(;o&&!Fc(o);){if(fs(o)&&!eg(o))return o;o=Da(o)}return s}let r=zj(e,n);for(;r&&I3(r)&&eg(r);)r=zj(r,n);return r&&Fc(r)&&eg(r)&&!ov(r)?s:r||F3(e)||s}const v4=async function(e){const n=this.getOffsetParent||Y1,s=this.getDimensions,r=await s(e.floating);return{reference:x4(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function y4(e){return _r(e).direction==="rtl"}const b4={convertOffsetParentRelativeRectToViewportRelativeRect:l4,getDocumentElement:ao,getClippingRect:p4,getOffsetParent:Y1,getElementRects:v4,getClientRects:c4,getDimensions:g4,getScale:Yi,isElement:fs,isRTL:y4};function Q1(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function w4(e,n,s){let r=null,o;const i=ao(e);function c(){var g;clearTimeout(o),(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=Hu(v),E=Hu(i.clientWidth-(h+y)),S=Hu(i.clientHeight-(v+j)),N=Hu(h),_={rootMargin:-k+"px "+-E+"px "+-S+"px "+-N+"px",threshold:Hs(0,Fa(1,b))||1};let M=!0;function O(L){const R=L[0].intersectionRatio;if(!Q1(x,e.getBoundingClientRect()))return d();if(R!==b){if(!M)return d();R?d(!1,R):o=setTimeout(()=>{d(!1,1e-7)},1e3)}M=!1}try{r=new IntersectionObserver(O,{..._,root:i.ownerDocument})}catch{r=new IntersectionObserver(O,_)}r.observe(e)}const u=ms(e),f=()=>d(s);return u.addEventListener("resize",f),d(!0),()=>{u.removeEventListener("resize",f),c()}}function j4(e,n,s,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=iv(e),g=o||i?[...f?Uc(f):[],...n?Uc(n):[]]:[];g.forEach(k=>{o&&k.addEventListener("scroll",s),i&&k.addEventListener("resize",s)});const b=f&&d?w4(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?Wa(e):null;u&&j();function j(){const k=Wa(e);y&&!Q1(y,k)&&s(),y=k,v=requestAnimationFrame(j)}return s(),()=>{var k;g.forEach(E=>{o&&E.removeEventListener("scroll",s),i&&E.removeEventListener("resize",s)}),b==null||b(),(k=h)==null||k.disconnect(),h=null,u&&cancelAnimationFrame(v)}}const tg=G1,k4=s4,N4=r4,S4=e4,C4=o4,E4=(e,n,s)=>{const r=new Map,o=s??{},i={...b4,...o.platform,_c:r};return Z3(e,n,{...o,platform:i})};var $4=typeof document<"u",_4=function(){},mf=$4?p.useLayoutEffect:_4;function Af(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,o;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(!Af(e[r],n[r]))return!1;return!0}if(o=Object.keys(e),s=o.length,s!==Object.keys(n).length)return!1;for(r=s;r--!==0;)if(!{}.hasOwnProperty.call(n,o[r]))return!1;for(r=s;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Af(e[i],n[i]))return!1}return!0}return e!==e&&n!==n}function J1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Dj(e,n){const s=J1(e);return Math.round(n*s)/s}function ng(e){const n=p.useRef(e);return mf(()=>{n.current=e}),n}function T4(e){e===void 0&&(e={});const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:o,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);Af(x,r)||h(r);const[v,y]=p.useState(null),[j,k]=p.useState(null),E=p.useCallback(W=>{W!==_.current&&(_.current=W,y(W))},[]),S=p.useCallback(W=>{W!==M.current&&(M.current=W,k(W))},[]),N=i||v,$=c||j,_=p.useRef(null),M=p.useRef(null),O=p.useRef(g),L=u!=null,R=ng(u),A=ng(o),P=ng(f),z=p.useCallback(()=>{if(!_.current||!M.current)return;const W={placement:n,strategy:s,middleware:x};A.current&&(W.platform=A.current),E4(_.current,M.current,W).then(G=>{const F={...G,isPositioned:P.current!==!1};U.current&&!Af(O.current,F)&&(O.current=F,Ns.flushSync(()=>{b(F)}))})},[x,n,s,A,P]);mf(()=>{f===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,b(W=>({...W,isPositioned:!1})))},[f]);const U=p.useRef(!1);mf(()=>(U.current=!0,()=>{U.current=!1}),[]),mf(()=>{if(N&&(_.current=N),$&&(M.current=$),N&&$){if(R.current)return R.current(N,$,z);z()}},[N,$,z,R,L]);const q=p.useMemo(()=>({reference:_,floating:M,setReference:E,setFloating:S}),[E,S]),H=p.useMemo(()=>({reference:N,floating:$}),[N,$]),K=p.useMemo(()=>{const W={position:s,left:0,top:0};if(!H.floating)return W;const G=Dj(H.floating,g.x),F=Dj(H.floating,g.y);return d?{...W,transform:"translate("+G+"px, "+F+"px)",...J1(H.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:G,top:F}},[s,d,H.floating,g.x,g.y]);return p.useMemo(()=>({...g,update:z,refs:q,elements:H,floatingStyles:K}),[g,z,q,H,K])}const X1=(e,n)=>{const s=k4(e);return{name:s.name,fn:s.fn,options:[e,n]}},R4=(e,n)=>{const s=N4(e);return{name:s.name,fn:s.fn,options:[e,n]}},A4=(e,n)=>{const s=S4(e);return{name:s.name,fn:s.fn,options:[e,n]}},O4=(e,n)=>{const s=C4(e);return{name:s.name,fn:s.fn,options:[e,n]}},Z1={...Og},M4=Z1.useInsertionEffect,P4=M4||(e=>e());function eS(e){const n=p.useRef(()=>{});return P4(()=>{n.current=e}),p.useCallback(function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return n.current==null?void 0:n.current(...r)},[])}var Gg=typeof document<"u"?p.useLayoutEffect:p.useEffect;let Fj=!1,L4=0;const Uj=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+L4++;function I4(){const[e,n]=p.useState(()=>Fj?Uj():void 0);return Gg(()=>{e==null&&n(Uj())},[]),p.useEffect(()=>{Fj=!0},[]),e}const z4=Z1.useId,D4=z4||I4;function F4(){const e=new Map;return{emit(n,s){var r;(r=e.get(n))==null||r.forEach(o=>o(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(o=>o!==s))||[])}}}const U4=p.createContext(null),W4=p.createContext(null),H4=()=>{var e;return((e=p.useContext(U4))==null?void 0:e.id)||null},B4=()=>p.useContext(W4),G4="data-floating-ui-focusable";function q4(e){const{open:n=!1,onOpenChange:s,elements:r}=e,o=D4(),i=p.useRef({}),[c]=p.useState(()=>F4()),d=H4()!=null,[u,f]=p.useState(r.reference),g=eS((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:o,refs:b}),[n,g,x,c,o,b])}function K4(e){e===void 0&&(e={});const{nodeId:n}=e,s=q4({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||s,o=r.elements,[i,c]=p.useState(null),[d,u]=p.useState(null),g=(o==null?void 0:o.domReference)||i,b=p.useRef(null),x=B4();Gg(()=>{g&&(b.current=g)},[g]);const h=T4({...e,elements:{...o,...d&&{reference:d}}}),v=p.useCallback(S=>{const N=fs(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),contextElement:S}:S;u(N),h.refs.setReference(N)},[h.refs]),y=p.useCallback(S=>{(fs(S)||S===null)&&(b.current=S,c(S)),(fs(h.refs.reference.current)||h.refs.reference.current===null||S!==null&&!fs(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 Gg(()=>{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 Wj="active",Hj="selected";function sg(e,n,s){const r=new Map,o=s==="item";let i=e;if(o&&e){const{[Wj]:c,[Hj]:d,...u}=e;i=u}return{...s==="floating"&&{tabIndex:-1,[G4]:""},...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(!(o&&[Wj,Hj].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 V4(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),o=p.useCallback(d=>sg(d,e,"reference"),n),i=p.useCallback(d=>sg(d,e,"floating"),s),c=p.useCallback(d=>sg(d,e,"item"),r);return p.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:c}),[o,i,c])}function Bj(e,n){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:n}}}}const Y4=e=>({name:"inner",options:e,async fn(n){const{listRef:s,overflowRef:r,onFallbackChange:o,offset:i=0,index:c=0,minItemsVisible:d=4,referenceOverflowThreshold:u=0,scrollRef:f,...g}=kl(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 X1(-h.offsetTop-x.clientTop-b.reference.height/2-h.offsetHeight/2-i).fn(n)},N=await tg(Bj(S,v.scrollHeight+y+x.clientTop),g),$=await tg(S,{...g,elementContext:"reference"}),_=Hs(0,N.top),M=S.y+_,R=(v.scrollHeight>v.clientHeight?A=>A:Wc)(Hs(0,v.scrollHeight+(j&&E||k?y*2:0)-_-Hs(0,N.bottom)));if(v.style.maxHeight=R+"px",v.scrollTop=_,o){const A=v.offsetHeight<h.offsetHeight*Fa(d,s.current.length)-1||$.top>=-u||$.bottom>=-u;Ns.flushSync(()=>o(A))}return r&&(r.current=await tg(Bj({...S,y:M},v.offsetHeight+y+x.clientTop),g)),{y:M}}});function Q4(e,n){const{open:s,elements:r}=e,{enabled:o=!0,overflowRef:i,scrollRef:c,onChange:d}=n,u=eS(d),f=p.useRef(!1),g=p.useRef(null),b=p.useRef(null);p.useEffect(()=>{if(!o)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(),Ns.flushSync(()=>{u(_=>_+Math[$](j,S*N))})):/firefox/i.test(U3())&&(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)}},[o,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)&&Ns.flushSync(()=>u(y=>y+v))}requestAnimationFrame(()=>{g.current=h.scrollTop})}}}),[r.floating,u,i,c]);return p.useMemo(()=>o?{floating:x}:{},[o,x])}let Nl=p.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});Nl.displayName="FloatingContext";let lv=p.createContext(null);lv.displayName="PlacementContext";function J4(e){return p.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function X4(){return p.useContext(Nl).setReference}function Z4(){return p.useContext(Nl).getReferenceProps}function eO(){let{getFloatingProps:e,slot:n}=p.useContext(Nl);return p.useCallback((...s)=>Object.assign({},e(...s),{"data-anchor":n.anchor}),[e,n])}function tO(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let n=p.useContext(lv),s=p.useMemo(()=>e,[JSON.stringify(e,(o,i)=>{var c;return(c=i==null?void 0:i.outerHTML)!=null?c:i})]);tn(()=>{n==null||n(s??null)},[n,s]);let r=p.useContext(Nl);return p.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let Gj=4;function nO({children:e,enabled:n=!0}){let[s,r]=p.useState(null),[o,i]=p.useState(0),c=p.useRef(null),[d,u]=p.useState(null);sO(d);let f=n&&s!==null&&d!==null,{to:g="bottom",gap:b=0,offset:x=0,padding:h=0,inner:v}=rO(s,d),[y,j="center"]=g.split(" ");tn(()=>{f&&i(0)},[f]);let{refs:k,floatingStyles:E,context:S}=K4({open:f,placement:y==="selection"?j==="center"?"bottom":`bottom-${j}`:j==="center"?`${y}`:`${y}-${j}`,strategy:"absolute",transform:!1,middleware:[X1({mainAxis:y==="selection"?0:b,crossAxis:x}),R4({padding:h}),y!=="selection"&&A4({padding:h}),y==="selection"&&v?Y4({...v,padding:h,overflowRef:c,offset:o,minItemsVisible:Gj,referenceOverflowThreshold:h,onFallbackChange(A){var P,z;if(!A)return;let U=S.elements.floating;if(!U)return;let q=parseFloat(getComputedStyle(U).scrollPaddingBottom)||0,H=Math.min(Gj,U.childElementCount),K=0,W=0;for(let G of(z=(P=S.elements.floating)==null?void 0:P.childNodes)!=null?z:[])if(Ss(G)){let F=G.offsetTop,D=F+G.clientHeight+q,Y=U.scrollTop,se=Y+U.clientHeight;if(F>=Y&&D<=se)H--;else{W=Math.max(0,Math.min(D,se)-Math.max(F,Y)),K=G.clientHeight;break}}H>=1&&i(G=>{let F=K*H-W+q;return G>=F?G:F})}}):null,O4({padding:h,apply({availableWidth:A,availableHeight:P,elements:z}){Object.assign(z.floating.style,{overflow:"auto",maxWidth:`${A}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${P}px)`})}})].filter(Boolean),whileElementsMounted:j4}),[N=y,$=j]=S.placement.split("-");y==="selection"&&(N="selection");let _=p.useMemo(()=>({anchor:[N,$].filter(Boolean).join(" ")}),[N,$]),M=Q4(S,{overflowRef:c,onChange:i}),{getReferenceProps:O,getFloatingProps:L}=V4([M]),R=ut(A=>{u(A),k.setFloating(A)});return p.createElement(lv.Provider,{value:r},p.createElement(Nl.Provider,{value:{setFloating:R,setReference:k.setReference,styles:E,getReferenceProps:O,getFloatingProps:L,slot:_}},e))}function sO(e){tn(()=>{if(!e)return;let n=new MutationObserver(()=>{let s=window.getComputedStyle(e).maxHeight,r=parseFloat(s);if(isNaN(r))return;let o=parseInt(s);isNaN(o)||r!==o&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return n.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{n.disconnect()}},[e])}function rO(e,n){var s,r,o;let i=rg((s=e==null?void 0:e.gap)!=null?s:"var(--anchor-gap, 0)",n),c=rg((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",n),d=rg((o=e==null?void 0:e.padding)!=null?o:"var(--anchor-padding, 0)",n);return{...e,gap:i,offset:c,padding:d}}function rg(e,n,s=void 0){let r=Zo(),o=ut((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=qj(u,f);return[g,b=>{let x=tS(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=qj(u,f);g!==j&&(b(j),g=j)})}return r.dispose}]}return[s,null]}),i=p.useMemo(()=>o(e,n)[0],[e,n]),[c=i,d]=p.useState();return tn(()=>{let[u,f]=o(e,n);if(d(u),!!f)return f(d)},[e,n]),c}function tS(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(),o=n[1].slice(s+1).trim();return o?[r,...tS(o)]:[r]}return[]}function qj(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 oO({children:e,freeze:n},s){let r=nS(n,e);return p.isValidElement(r)?p.cloneElement(r,{ref:s}):Ke.createElement(Ke.Fragment,null,r)}Ke.forwardRef(oO);function nS(e,n){let[s,r]=p.useState(n);return!e&&s!==n&&r(n),e?s:n}let Em=p.createContext(null);Em.displayName="OpenClosedContext";var Xn=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Xn||{});function ad(){return p.useContext(Em)}function sS({value:e,children:n}){return Ke.createElement(Em.Provider,{value:e},n)}function aO({children:e}){return Ke.createElement(Em.Provider,{value:null},e)}function iO(e){function n(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",n))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",n),n())}let Io=[];iO(()=>{function e(n){if(!Yr(n.target)||n.target===document.body||Io[0]===n.target)return;let s=n.target;s=s.closest(_f),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 lO(e){throw new Error("Unexpected object: "+e)}var on=(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))(on||{});function Bu(e,n){let s=n.resolveItems();if(s.length<=0)return null;let r=n.resolveActiveIndex(),o=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:{o===-1&&(o=s.length);for(let i=o-1;i>=0;--i)if(!n.resolveDisabled(s[i],i,s))return i;return r}case 2:{for(let i=o+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:lO(e)}}function cv(e){let n=ut(e),s=p.useRef(!1);p.useEffect(()=>(s.current=!1,()=>{s.current=!0,vm(()=>{s.current&&n()})}),[n])}function cO(){let e=typeof document>"u";return"useSyncExternalStore"in Og?(n=>n.useSyncExternalStore)(Og)(()=>()=>{},()=>!1,()=>!e):!1}function id(){let e=cO(),[n,s]=p.useState(Cr.isHandoffComplete);return n&&Cr.isHandoffComplete===!1&&s(!1),p.useEffect(()=>{n!==!0&&s(!0)},[n]),p.useEffect(()=>Cr.handoff(),[]),e?!1:n}let rS=p.createContext(!1);function dO(){return p.useContext(rS)}function Kj(e){return Ke.createElement(rS.Provider,{value:e.force},e.children)}function uO(e){let n=dO(),s=p.useContext(aS),[r,o]=p.useState(()=>{var i;if(!n&&s!==null)return(i=s.current)!=null?i:null;if(Cr.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&&o(s.current)},[s,o,n]),r}let oS=p.Fragment,fO=xn(function(e,n){let{ownerDocument:s=null,...r}=e,o=p.useRef(null),i=Fn(IA(h=>{o.current=h}),n),c=Dc(o.current),d=s??c,u=uO(d),f=p.useContext(qg),g=Zo(),b=id(),x=En();return cv(()=>{var h;u&&u.childNodes.length<=0&&((h=u.parentElement)==null||h.removeChild(u))}),!u||!b?null:Ns.createPortal(Ke.createElement("div",{"data-headlessui-portal":"",ref:h=>{g.dispose(),f&&h&&g.add(f.register(h))}},x({ourProps:{ref:i},theirProps:r,slot:{},defaultTag:oS,name:"Portal"})),u)});function mO(e,n){let s=Fn(n),{enabled:r=!0,ownerDocument:o,...i}=e,c=En();return r?Ke.createElement(fO,{...i,ownerDocument:o,ref:s}):c({ourProps:{ref:s},theirProps:i,slot:{},defaultTag:oS,name:"Portal"})}let hO=p.Fragment,aS=p.createContext(null);function pO(e,n){let{target:s,...r}=e,o={ref:Fn(n)},i=En();return Ke.createElement(aS.Provider,{value:s},i({ourProps:o,theirProps:r,defaultTag:hO,name:"Popover.Group"}))}let qg=p.createContext(null);function gO(){let e=p.useContext(qg),n=p.useRef([]),s=ut(i=>(n.current.push(i),e&&e.register(i),()=>r(i))),r=ut(i=>{let c=n.current.indexOf(i);c!==-1&&n.current.splice(c,1),e&&e.unregister(i)}),o=p.useMemo(()=>({register:s,unregister:r,portals:n}),[s,r,n]);return[n,p.useMemo(()=>function({children:i}){return Ke.createElement(qg.Provider,{value:o},i)},[o])]}let xO=xn(mO),iS=xn(pO),lS=Object.assign(xO,{Group:iS});const hf={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function cS(e){let n=e.getBoundingClientRect();return`${n.x},${n.y}`}function vO(e,n,s){let r=$s();if(n.kind==="Tracked"){let o=function(){i!==cS(e)&&(r.dispose(),s())},{position:i}=n,c=new ResizeObserver(o);c.observe(e),r.add(()=>c.disconnect()),r.addEventListener(window,"scroll",o,{passive:!0}),r.addEventListener(window,"resize",o)}return()=>r.dispose()}function yO(e,n=typeof document<"u"?document.defaultView:null,s){let r=rd(e,"escape");L1(n,"keydown",o=>{r&&(o.defaultPrevented||o.key===bn.Escape&&s(o))})}function bO(){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 tn(()=>{if(!n)return;function o(i){r(i.matches)}return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[n]),s}function wO({defaultContainers:e=[],portals:n,mainTreeNode:s}={}){let r=ut(()=>{var o,i;let c=wl(s),d=[];for(let u of e)u!==null&&(Xr(u)?d.push(u):"current"in u&&Xr(u.current)&&d.push(u.current));if(n!=null&&n.current)for(let u of n.current)d.push(u);for(let u of(o=c==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?o:[])u!==document.body&&u!==document.head&&Xr(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:ut(o=>r().some(i=>i.contains(o)))}}let dS=p.createContext(null);function Vj({children:e,node:n}){let[s,r]=p.useState(null),o=uS(n??s);return Ke.createElement(dS.Provider,{value:o},e,o===null&&Ke.createElement(zc,{features:ll.Hidden,ref:i=>{var c,d;if(i){for(let u of(d=(c=wl(i))==null?void 0:c.querySelectorAll("html > *, body > *"))!=null?d:[])if(u!==document.body&&u!==document.head&&Xr(u)&&u!=null&&u.contains(i)){r(u);break}}}}))}function uS(e=null){var n;return(n=p.useContext(dS))!=null?n:e}function dv(){let e=p.useRef(!1);return tn(()=>(e.current=!0,()=>{e.current=!1}),[]),e}var Cc=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(Cc||{});function jO(){let e=p.useRef(0);return M1(!0,"keydown",n=>{n.key==="Tab"&&(e.current=n.shiftKey?1:0)},!0),e}function fS(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let n=new Set;for(let s of e.current)Xr(s.current)&&n.add(s.current);return n}let kO="div";var Ca=(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))(Ca||{});function NO(e,n){let s=p.useRef(null),r=Fn(s,n),{initialFocus:o,initialFocusFallback:i,containers:c,features:d=15,...u}=e;id()||(d=0);let f=Dc(s.current);$O(d,{ownerDocument:f});let g=_O(d,{ownerDocument:f,container:s,initialFocus:o,initialFocusFallback:i});TO(d,{ownerDocument:f,container:s,containers:c,previousActiveElement:g});let b=jO(),x=ut(E=>{if(!Ss(s.current))return;let S=s.current;(N=>N())(()=>{ts(b.current,{[Cc.Forwards]:()=>{Vi(S,lr.First,{skipElements:[E.relatedTarget,i]})},[Cc.Backwards]:()=>{Vi(S,lr.Last,{skipElements:[E.relatedTarget,i]})}})})}),h=rd(!!(d&2),"focus-trap#tab-lock"),v=Zo(),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=fS(c);Ss(s.current)&&S.add(s.current);let N=E.relatedTarget;Yr(N)&&N.dataset.headlessuiFocusGuard!=="true"&&(mS(S,N)||(y.current?Vi(s.current,ts(b.current,{[Cc.Forwards]:()=>lr.Next,[Cc.Backwards]:()=>lr.Previous})|lr.WrapAround,{relativeTo:E.target}):Yr(E.target)&&Zr(E.target)))}},k=En();return Ke.createElement(Ke.Fragment,null,h&&Ke.createElement(zc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:x,features:ll.Focusable}),k({ourProps:j,theirProps:u,defaultTag:kO,name:"FocusTrap"}),h&&Ke.createElement(zc,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:x,features:ll.Focusable}))}let SO=xn(NO),CO=Object.assign(SO,{features:Ca});function EO(e=!0){let n=p.useRef(Io.slice());return rv(([s],[r])=>{r===!0&&s===!1&&vm(()=>{n.current.splice(0)}),r===!1&&s===!0&&(n.current=Io.slice())},[e,Io,n]),ut(()=>{var s;return(s=n.current.find(r=>r!=null&&r.isConnected))!=null?s:null})}function $O(e,{ownerDocument:n}){let s=!!(e&8),r=EO(s);rv(()=>{s||o1(n==null?void 0:n.body)&&Zr(r())},[s]),cv(()=>{s&&Zr(r())})}function _O(e,{ownerDocument:n,container:s,initialFocus:r,initialFocusFallback:o}){let i=p.useRef(null),c=rd(!!(e&1),"focus-trap#initial-focus"),d=dv();return rv(()=>{if(e===0)return;if(!c){o!=null&&o.current&&Zr(o.current);return}let u=s.current;u&&vm(()=>{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)Zr(r.current);else{if(e&16){if(Vi(u,lr.First|lr.AutoFocus)!==Wg.Error)return}else if(Vi(u,lr.First)!==Wg.Error)return;if(o!=null&&o.current&&(Zr(o.current),(n==null?void 0:n.activeElement)===o.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}i.current=n==null?void 0:n.activeElement})},[o,c,e]),i}function TO(e,{ownerDocument:n,container:s,containers:r,previousActiveElement:o}){let i=dv(),c=!!(e&4);L1(n==null?void 0:n.defaultView,"focus",d=>{if(!c||!i.current)return;let u=fS(r);Ss(s.current)&&u.add(s.current);let f=o.current;if(!f)return;let g=d.target;Ss(g)?mS(u,g)?(o.current=g,Zr(g)):(d.preventDefault(),d.stopPropagation(),Zr(f)):Zr(o.current)},!0)}function mS(e,n){for(let s of e)if(s.contains(n))return!0;return!1}function hS(e){var n;return!!(e.enter||e.enterFrom||e.enterTo||e.leave||e.leaveFrom||e.leaveTo)||!Tc((n=e.as)!=null?n:gS)||Ke.Children.count(e.children)===1}let $m=p.createContext(null);$m.displayName="TransitionContext";var RO=(e=>(e.Visible="visible",e.Hidden="hidden",e))(RO||{});function AO(){let e=p.useContext($m);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function OO(){let e=p.useContext(_m);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let _m=p.createContext(null);_m.displayName="NestingContext";function Tm(e){return"children"in e?Tm(e.children):e.current.filter(({el:n})=>n.current!==null).filter(({state:n})=>n==="visible").length>0}function pS(e,n){let s=ea(e),r=p.useRef([]),o=dv(),i=Zo(),c=ut((h,v=zo.Hidden)=>{let y=r.current.findIndex(({el:j})=>j===h);y!==-1&&(ts(v,{[zo.Unmount](){r.current.splice(y,1)},[zo.Hidden](){r.current[y].state="hidden"}}),i.microTask(()=>{var j;!Tm(r)&&o.current&&((j=s.current)==null||j.call(s))}))}),d=ut(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=ut((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=ut((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 gS=p.Fragment,xS=il.RenderStrategy;function MO(e,n){var s,r;let{transition:o=!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=hS(e),$=Fn(...N?[S,n,E]:n===null?[]:[n]),_=(s=j.unmount)==null||s?zo.Unmount:zo.Hidden,{show:M,appear:O,initial:L}=AO(),[R,A]=p.useState(M?"visible":"hidden"),P=OO(),{register:z,unregister:U}=P;tn(()=>z(S),[z,S]),tn(()=>{if(_===zo.Hidden&&S.current){if(M&&R!=="visible"){A("visible");return}return ts(R,{hidden:()=>U(S),visible:()=>z(S)})}},[R,S,z,U,M,_]);let q=id();tn(()=>{if(N&&q&&R==="visible"&&S.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[S,R,q,N]);let H=L&&!O,K=O&&M&&L,W=p.useRef(!1),G=pS(()=>{W.current||(A("hidden"),U(S))},P),F=ut(he=>{W.current=!0;let ge=he?"enter":"leave";G.onStart(S,ge,be=>{be==="enter"?i==null||i():be==="leave"&&(d==null||d())})}),D=ut(he=>{let ge=he?"enter":"leave";W.current=!1,G.onStop(S,ge,be=>{be==="enter"?c==null||c():be==="leave"&&(u==null||u())}),ge==="leave"&&!Tm(G)&&(A("hidden"),U(S))});p.useEffect(()=>{N&&o||(F(M),D(M))},[M,N,o]);let Y=!(!o||!N||!q||H),[,se]=D1(Y,k,M,{start:F,end:D}),Q=Lo({ref:$,className:((r=Fg(j.className,K&&f,K&&g,se.enter&&f,se.enter&&se.closed&&g,se.enter&&!se.closed&&b,se.leave&&h,se.leave&&!se.closed&&v,se.leave&&se.closed&&y,!se.transition&&M&&x))==null?void 0:r.trim())||void 0,...z1(se)}),re=0;R==="visible"&&(re|=Xn.Open),R==="hidden"&&(re|=Xn.Closed),M&&R==="hidden"&&(re|=Xn.Opening),!M&&R==="visible"&&(re|=Xn.Closing);let te=En();return Ke.createElement(_m.Provider,{value:G},Ke.createElement(sS,{value:re},te({ourProps:Q,theirProps:j,defaultTag:gS,features:xS,visible:R==="visible",name:"Transition.Child"})))}function PO(e,n){let{show:s,appear:r=!1,unmount:o=!0,...i}=e,c=p.useRef(null),d=hS(e),u=Fn(...d?[c,n]:n===null?[]:[n]);id();let f=ad();if(s===void 0&&f!==null&&(s=(f&Xn.Open)===Xn.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=pS(()=>{s||b("hidden")}),[h,v]=p.useState(!0),y=p.useRef([s]);tn(()=>{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]);tn(()=>{s?b("visible"):!Tm(x)&&c.current!==null&&b("hidden")},[s,x]);let k={unmount:o},E=ut(()=>{var $;h&&v(!1),($=e.beforeEnter)==null||$.call(e)}),S=ut(()=>{var $;h&&v(!1),($=e.beforeLeave)==null||$.call(e)}),N=En();return Ke.createElement(_m.Provider,{value:x},Ke.createElement($m.Provider,{value:j},N({ourProps:{...k,as:p.Fragment,children:Ke.createElement(vS,{ref:u,...k,...i,beforeEnter:E,beforeLeave:S})},theirProps:{},defaultTag:p.Fragment,features:xS,visible:g==="visible",name:"Transition"})))}function LO(e,n){let s=p.useContext($m)!==null,r=ad()!==null;return Ke.createElement(Ke.Fragment,null,!s&&r?Ke.createElement(Kg,{ref:n,...e}):Ke.createElement(vS,{ref:n,...e}))}let Kg=xn(PO),vS=xn(MO),uv=xn(LO),IO=Object.assign(Kg,{Child:uv,Root:Kg});var zO=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(zO||{}),DO=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(DO||{});let FO={0(e,n){return e.titleId===n.id?e:{...e,titleId:n.id}}},fv=p.createContext(null);fv.displayName="DialogContext";function Rm(e){let n=p.useContext(fv);if(n===null){let s=new Error(`<${e} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,Rm),s}return n}function UO(e,n){return ts(n.type,FO,e,n)}let Yj=xn(function(e,n){let s=p.useId(),{id:r=`headlessui-dialog-${s}`,open:o,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=ad();o===void 0&&h!==null&&(o=(h&Xn.Open)===Xn.Open);let v=p.useRef(null),y=Fn(v,n),j=Dc(v.current),k=o?0:1,[E,S]=p.useReducer(UO,{titleId:null,descriptionId:null,panelRef:p.createRef()}),N=ut(()=>i(!1)),$=ut(se=>S({type:0,id:se})),_=id()?k===0:!1,[M,O]=gO(),L={get current(){var se;return(se=E.panelRef.current)!=null?se:v.current}},R=uS(),{resolveContainers:A}=wO({mainTreeNode:R,portals:M,defaultContainers:[L]}),P=h!==null?(h&Xn.Closing)===Xn.Closing:!1;$1(f||P?!1:_,{allowed:ut(()=>{var se,Q;return[(Q=(se=v.current)==null?void 0:se.closest("[data-headlessui-portal]"))!=null?Q:null]}),disallowed:ut(()=>{var se;return[(se=R==null?void 0:R.closest("body > *:not(#headlessui-portal-root)"))!=null?se:null]})});let z=wm.get(null);tn(()=>{if(_)return z.actions.push(r),()=>z.actions.pop(r)},[z,r,_]);let U=Qn(z,p.useCallback(se=>z.selectors.isTop(se,r),[z,r]));P1(U,A,se=>{se.preventDefault(),N()}),yO(U,j==null?void 0:j.defaultView,se=>{se.preventDefault(),se.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),N()}),I1(f||P?!1:_,j,A),_1(_,v,N);let[q,H]=DA(),K=p.useMemo(()=>[{dialogState:k,close:N,setTitleId:$,unmount:g},E],[k,N,$,g,E]),W=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":q,unmount:g},F=!bO(),D=Ca.None;_&&!f&&(D|=Ca.RestoreFocus,D|=Ca.TabLock,u&&(D|=Ca.AutoFocus),F&&(D|=Ca.InitialFocus));let Y=En();return Ke.createElement(aO,null,Ke.createElement(Kj,{force:!0},Ke.createElement(lS,null,Ke.createElement(fv.Provider,{value:K},Ke.createElement(iS,{target:v},Ke.createElement(Kj,{force:!1},Ke.createElement(H,{slot:W},Ke.createElement(O,null,Ke.createElement(CO,{initialFocus:c,initialFocusFallback:v,containers:A,features:D},Ke.createElement(YA,{value:N},Y({ourProps:G,theirProps:b,slot:W,defaultTag:WO,features:HO,visible:k===0,name:"Dialog"})))))))))))}),WO="div",HO=il.RenderStrategy|il.Static;function BO(e,n){let{transition:s=!1,open:r,...o}=e,i=ad(),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)&&!o.static?Ke.createElement(Vj,null,Ke.createElement(IO,{show:r,transition:s,unmount:o.unmount},Ke.createElement(Yj,{ref:n,...o}))):Ke.createElement(Vj,null,Ke.createElement(Yj,{ref:n,open:r,...o}))}let GO="div";function qO(e,n){let s=p.useId(),{id:r=`headlessui-dialog-panel-${s}`,transition:o=!1,...i}=e,[{dialogState:c,unmount:d},u]=Rm("Dialog.Panel"),f=Fn(n,u.panelRef),g=Ks({open:c===0}),b=ut(j=>{j.stopPropagation()}),x={ref:f,id:r,onClick:b},h=o?uv:p.Fragment,v=o?{unmount:d}:{},y=En();return Ke.createElement(h,{...v},y({ourProps:x,theirProps:i,slot:g,defaultTag:GO,name:"Dialog.Panel"}))}let KO="div";function VO(e,n){let{transition:s=!1,...r}=e,[{dialogState:o,unmount:i}]=Rm("Dialog.Backdrop"),c=Ks({open:o===0}),d={ref:n,"aria-hidden":!0},u=s?uv:p.Fragment,f=s?{unmount:i}:{},g=En();return Ke.createElement(u,{...f},g({ourProps:d,theirProps:r,slot:c,defaultTag:KO,name:"Dialog.Backdrop"}))}let YO="h2";function QO(e,n){let s=p.useId(),{id:r=`headlessui-dialog-title-${s}`,...o}=e,[{dialogState:i,setTitleId:c}]=Rm("Dialog.Title"),d=Fn(n);p.useEffect(()=>(c(r),()=>c(null)),[r,c]);let u=Ks({open:i===0}),f={ref:d,id:r};return En()({ourProps:f,theirProps:o,slot:u,defaultTag:YO,name:"Dialog.Title"})}let JO=xn(BO),yS=xn(qO),XO=xn(VO),bS=xn(QO),ZO=Object.assign(JO,{Panel:yS,Title:bS,Description:v1}),Qj=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function Jj(e){var n,s;let r=(n=e.innerText)!=null?n:"",o=e.cloneNode(!0);if(!Ss(o))return r;let i=!1;for(let d of o.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))d.remove(),i=!0;let c=i?(s=o.innerText)!=null?s:"":r;return Qj.test(c)&&(c=c.replace(Qj,"")),c}function e5(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(o=>{let i=document.getElementById(o);if(i){let c=i.getAttribute("aria-label");return typeof c=="string"?c.trim():Jj(i).trim()}return null}).filter(Boolean);if(r.length>0)return r.join(", ")}return Jj(e).trim()}function t5(e){let n=p.useRef(""),s=p.useRef("");return ut(()=>{let r=e.current;if(!r)return"";let o=r.innerText;if(n.current===o)return s.current;let i=e5(r).trim().toLowerCase();return n.current=o,s.current=i,i})}var n5=Object.defineProperty,s5=(e,n,s)=>n in e?n5(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Xj=(e,n,s)=>(s5(e,typeof n!="symbol"?n+"":n,s),s),zn=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(zn||{}),Do=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Do||{}),pf=(e=>(e[e.Pointer=0]="Pointer",e[e.Other=1]="Other",e))(pf||{}),wS=(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))(wS||{});function Zj(e,n=s=>s){let s=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=A1(n(e.options.slice()),i=>i.dataRef.current.domRef.current),o=s?r.indexOf(s):null;return o===-1&&(o=null),{options:r,activeOptionIndex:o}}let r5={1(e){if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=e.buttonElement?hf.Tracked(cS(e.buttonElement)):e.buttonPositionState;return{...e,activeOptionIndex:null,pendingFocus:{focus:on.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,o=e.options.findIndex(i=>r(i.dataRef.current.value));return o!==-1&&(s=o),{...e,frozenValue:!1,pendingFocus:n.focus,listboxState:0,activeOptionIndex:s,__demoMode:!1,buttonPositionState:hf.Idle}},2(e,n){var s,r,o,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===on.Nothing)return{...d,activeOptionIndex:null};if(n.focus===on.Specific)return{...d,activeOptionIndex:e.options.findIndex(g=>g.id===n.id)};if(n.focus===on.Previous){let g=e.activeOptionIndex;if(g!==null){let b=e.options[g].dataRef.current.domRef,x=Bu(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||((o=h.current)==null?void 0:o.previousElementSibling)===null)return{...d,activeOptionIndex:x}}}}else if(n.focus===on.Next){let g=e.activeOptionIndex;if(g!==null){let b=e.options[g].dataRef.current.domRef,x=Bu(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=Zj(e),f=Bu(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(),o=(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=o?e.options.indexOf(o):-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!==on.Nothing&&(r=Bu(e.pendingFocus,{resolveItems:()=>s,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:o=>o.id,resolveDisabled:o=>o.dataRef.current.disabled})),e.activeOptionIndex===null){let{isSelected:o}=e.dataRef.current;if(o){let i=s.findIndex(c=>o==null?void 0:o(c.dataRef.current.value));i!==-1&&(r=i)}}return{...e,options:s,activeOptionIndex:r,pendingFocus:{focus:on.Nothing},pendingShouldSort:!0}},7:(e,n)=>{let s=e.options,r=[],o=new Set(n.options);for(let[i,c]of s.entries())if(o.has(c.id)&&(r.push(i),o.delete(c.id),o.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,...Zj(e),pendingShouldSort:!1}:e,11(e){return e.buttonPositionState.kind!=="Tracked"?e:{...e,buttonPositionState:hf.Moved}}};class mv extends N1{constructor(n){super(n),Xj(this,"actions",{onChange:s=>{let{onChange:r,compare:o,mode:i,value:c}=this.state.dataRef.current;return ts(i,{0:()=>r==null?void 0:r(s),1:()=>{let d=c.slice(),u=d.findIndex(f=>o(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[(o,i)=>{r.has(i)||(r.add(i),s.push({id:o,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,o)=>{s={type:2,...r,trigger:o}},()=>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})}}),Xj(this,"selectors",{activeDescendantId(s){var r;let o=s.activeOptionIndex,i=s.options;return o===null||(r=i[o])==null?void 0:r.id},isActive(s,r){var o;let i=s.activeOptionIndex,c=s.options;return i!==null?((o=c[i])==null?void 0:o.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=wm.get(null);this.disposables.add(r.on(C1.Push,o=>{!r.selectors.isTop(o,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(vO(r.buttonElement,r.buttonPositionState,()=>{this.send({type:11})})))})}),this.on(5,(s,r)=>{var o;this.actions.onChange(r.value),this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(o=this.state.buttonElement)==null||o.focus({preventScroll:!0}))})}static new({id:n,__demoMode:s=!1}){return new mv({id:n,dataRef:{current:{}},listboxState:s?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:on.Nothing},frozenValue:!1,__demoMode:s,buttonPositionState:hf.Idle})}reduce(n,s){return ts(s.type,r5,n,s)}}const jS=p.createContext(null);function hv(e){let n=p.useContext(jS);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,kS),s}return n}function kS({id:e,__demoMode:n=!1}){let s=p.useMemo(()=>mv.new({id:e,__demoMode:n}),[]);return cv(()=>s.dispose()),s}let Am=p.createContext(null);Am.displayName="ListboxDataContext";function ld(e){let n=p.useContext(Am);if(n===null){let s=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,ld),s}return n}let o5=p.Fragment;function a5(e,n){let s=p.useId(),r=nv(),{value:o,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=Fn(n),E=jA(i),[S=h?[]:void 0,N]=wA(o,u,E),$=kS({id:s,__demoMode:v}),_=p.useRef({static:!1,hold:!1}),M=p.useRef(new Map),O=JA(f),L=p.useCallback(Y=>ts(R.mode,{[Do.Multi]:()=>S.some(se=>O(se,Y)),[Do.Single]:()=>O(S,Y)}),[S]),R=Ks({value:S,disabled:b,invalid:g,mode:h?Do.Multi:Do.Single,orientation:j,onChange:N,compare:O,isSelected:L,optionsPropsRef:_,listRef:M});tn(()=>{$.state.dataRef.current=R},[R]);let A=Qn($,Y=>Y.listboxState),P=wm.get(null),z=Qn(P,p.useCallback(Y=>P.selectors.isTop(Y,s),[P,s])),[U,q]=Qn($,Y=>[Y.buttonElement,Y.optionsElement]);P1(z,[U,q],(Y,se)=>{$.send({type:wS.CloseListbox}),R1(se,sv.Loose)||(Y.preventDefault(),U==null||U.focus())});let H=Ks({open:A===zn.Open,disabled:b,invalid:g,value:S}),[K,W]=HA({inherit:!0}),G={ref:k},F=p.useCallback(()=>{if(E!==void 0)return N==null?void 0:N(E)},[N,E]),D=En();return Ke.createElement(W,{value:K,props:{htmlFor:U==null?void 0:U.id},slot:{open:A===zn.Open,disabled:b}},Ke.createElement(nO,null,Ke.createElement(jS.Provider,{value:$},Ke.createElement(Am.Provider,{value:R},Ke.createElement(sS,{value:ts(A,{[zn.Open]:Xn.Open,[zn.Closed]:Xn.Closed})},d!=null&&S!=null&&Ke.createElement(_A,{disabled:b,data:{[d]:S},form:c,onReset:F}),D({ourProps:G,theirProps:y,slot:H,defaultTag:o5,name:"Listbox"}))))))}let i5="button";function l5(e,n){let s=p.useId(),r=f1(),o=ld("Listbox.Button"),i=hv("Listbox.Button"),{id:c=r||`headlessui-listbox-button-${s}`,disabled:d=o.disabled||!1,autoFocus:u=!1,...f}=e,g=Fn(n,X4(),i.actions.setButtonElement),b=Z4(),[x,h,v]=Qn(i,q=>[q.listboxState,q.buttonElement,q.optionsElement]),y=x===zn.Open;w3(y,{trigger:h,action:p.useCallback(q=>{if(h!=null&&h.contains(q.target))return Wu.Ignore;let H=q.target.closest('[role="option"]:not([data-disabled])');return Ss(H)?Wu.Select(H):v!=null&&v.contains(q.target)?Wu.Ignore:Wu.Close},[h,v]),close:i.actions.closeListbox,select:i.actions.selectActiveOption});let j=ut(q=>{switch(q.key){case bn.Enter:kA(q.currentTarget);break;case bn.Space:case bn.ArrowDown:q.preventDefault(),i.actions.openListbox({focus:o.value?on.Nothing:on.First});break;case bn.ArrowUp:q.preventDefault(),i.actions.openListbox({focus:o.value?on.Nothing:on.Last});break}}),k=ut(q=>{switch(q.key){case bn.Space:q.preventDefault();break}}),E=ZA(q=>{var H;i.state.listboxState===zn.Open?(Ns.flushSync(()=>i.actions.closeListbox()),(H=i.state.buttonElement)==null||H.focus({preventScroll:!0})):(q.preventDefault(),i.actions.openListbox({focus:on.Nothing}))}),S=ut(q=>q.preventDefault()),N=b1([c]),$=zA(),{isFocusVisible:_,focusProps:M}=oA({autoFocus:u}),{isHovered:O,hoverProps:L}=lA({isDisabled:d}),{pressed:R,pressProps:A}=hA({disabled:d}),P=Ks({open:x===zn.Open,active:R||x===zn.Open,disabled:d,invalid:o.invalid,value:o.value,hover:O,focus:_,autofocus:u}),z=Qn(i,q=>q.listboxState===zn.Open),U=i1(b(),{ref:g,id:c,type:j3(e,h),"aria-haspopup":"listbox","aria-controls":v==null?void 0:v.id,"aria-expanded":z,"aria-labelledby":N,"aria-describedby":$,disabled:d||void 0,autoFocus:u,onKeyDown:j,onKeyUp:k,onKeyPress:S},E,M,L,A);return En()({ourProps:U,theirProps:f,slot:P,defaultTag:i5,name:"Listbox.Button"})}let NS=p.createContext(!1),c5="div",d5=il.RenderStrategy|il.Static;function u5(e,n){let s=p.useId(),{id:r=`headlessui-listbox-options-${s}`,anchor:o,portal:i=!1,modal:c=!0,transition:d=!1,...u}=e,f=J4(o),[g,b]=p.useState(null);f&&(i=!0);let x=ld("Listbox.Options"),h=hv("Listbox.Options"),[v,y,j,k]=Qn(h,te=>[te.listboxState,te.buttonElement,te.optionsElement,te.__demoMode]),E=Dc(y),S=Dc(j),N=ad(),[$,_]=D1(d,g,N!==null?(N&Xn.Open)===Xn.Open:v===zn.Open);_1($,y,h.actions.closeListbox);let M=k?!1:c&&v===zn.Open;I1(M,S);let O=k?!1:c&&v===zn.Open;$1(O,{allowed:p.useCallback(()=>[y,j],[y,j])});let L=Qn(h,h.selectors.didButtonMove)?!1:$,R=Qn(h,h.selectors.hasFrozenValue)&&!e.static,A=nS(R,x.value),P=p.useCallback(te=>x.compare(A,te),[x.compare,A]),z=Qn(h,te=>{var he;if(f==null||!((he=f==null?void 0:f.to)!=null&&he.includes("selection")))return null;let ge=te.options.findIndex(be=>P(be.dataRef.current.value));return ge===-1&&(ge=0),ge}),U=(()=>{if(f==null)return;if(z===null)return{...f,inner:void 0};let te=Array.from(x.listRef.current.values());return{...f,inner:{listRef:{current:te},index:z}}})(),[q,H]=tO(U),K=eO(),W=Fn(n,f?q:null,h.actions.setOptionsElement,b),G=Zo();p.useEffect(()=>{let te=j;te&&v===zn.Open&&(o1(te)||te==null||te.focus({preventScroll:!0}))},[v,j]);let F=ut(te=>{var he;switch(G.dispose(),te.key){case bn.Space:if(h.state.searchQuery!=="")return te.preventDefault(),te.stopPropagation(),h.actions.search(te.key);case bn.Enter:te.preventDefault(),te.stopPropagation(),h.actions.selectActiveOption();break;case ts(x.orientation,{vertical:bn.ArrowDown,horizontal:bn.ArrowRight}):return te.preventDefault(),te.stopPropagation(),h.actions.goToOption({focus:on.Next});case ts(x.orientation,{vertical:bn.ArrowUp,horizontal:bn.ArrowLeft}):return te.preventDefault(),te.stopPropagation(),h.actions.goToOption({focus:on.Previous});case bn.Home:case bn.PageUp:return te.preventDefault(),te.stopPropagation(),h.actions.goToOption({focus:on.First});case bn.End:case bn.PageDown:return te.preventDefault(),te.stopPropagation(),h.actions.goToOption({focus:on.Last});case bn.Escape:te.preventDefault(),te.stopPropagation(),Ns.flushSync(()=>h.actions.closeListbox()),(he=h.state.buttonElement)==null||he.focus({preventScroll:!0});return;case bn.Tab:te.preventDefault(),te.stopPropagation(),Ns.flushSync(()=>h.actions.closeListbox()),x3(h.state.buttonElement,te.shiftKey?lr.Previous:lr.Next);break;default:te.key.length===1&&(h.actions.search(te.key),G.setTimeout(()=>h.actions.clearSearch(),350));break}}),D=Qn(h,te=>{var he;return(he=te.buttonElement)==null?void 0:he.id}),Y=Ks({open:v===zn.Open}),se=i1(f?K():{},{id:r,ref:W,"aria-activedescendant":Qn(h,h.selectors.activeDescendantId),"aria-multiselectable":x.mode===Do.Multi?!0:void 0,"aria-labelledby":D,"aria-orientation":x.orientation,onKeyDown:F,role:"listbox",tabIndex:v===zn.Open?0:void 0,style:{...u.style,...H,"--button-width":XA($,y,!0).width},...z1(_)}),Q=En(),re=p.useMemo(()=>x.mode===Do.Multi?x:{...x,isSelected:P},[x,P]);return Ke.createElement(lS,{enabled:i?e.static||$:!1,ownerDocument:E},Ke.createElement(Am.Provider,{value:re},Q({ourProps:se,theirProps:u,slot:Y,defaultTag:c5,features:d5,visible:L,name:"Listbox.Options"})))}let f5="div";function m5(e,n){let s=p.useId(),{id:r=`headlessui-listbox-option-${s}`,disabled:o=!1,value:i,...c}=e,d=p.useContext(NS)===!0,u=ld("Listbox.Option"),f=hv("Listbox.Option"),g=Qn(f,R=>f.selectors.isActive(R,r)),b=u.isSelected(i),x=p.useRef(null),h=t5(x),v=ea({disabled:o,value:i,domRef:x,get textValue(){return h()}}),y=Fn(n,x,R=>{R?u.listRef.current.set(r,R):u.listRef.current.delete(r)}),j=Qn(f,R=>f.selectors.shouldScrollIntoView(R,r));tn(()=>{if(j)return $s().requestAnimationFrame(()=>{var R,A;(A=(R=x.current)==null?void 0:R.scrollIntoView)==null||A.call(R,{block:"nearest"})})},[j,x]),tn(()=>{if(!d)return f.actions.registerOption(r,v),()=>f.actions.unregisterOption(r)},[v,r,d]);let k=ut(R=>{if(o)return R.preventDefault();f.actions.selectOption(i)}),E=ut(()=>{if(o)return f.actions.goToOption({focus:on.Nothing});f.actions.goToOption({focus:on.Specific,id:r})}),S=_3(),N=ut(R=>S.update(R)),$=ut(R=>{S.wasMoved(R)&&(o||g&&f.state.activationTrigger===pf.Pointer||f.actions.goToOption({focus:on.Specific,id:r},pf.Pointer))}),_=ut(R=>{S.wasMoved(R)&&(o||g&&f.state.activationTrigger===pf.Pointer&&f.actions.goToOption({focus:on.Nothing}))}),M=Ks({active:g,focus:g,selected:b,disabled:o,selectedOption:b&&d}),O=d?{}:{id:r,ref:y,role:"option",tabIndex:o===!0?void 0:-1,"aria-disabled":o===!0?!0:void 0,"aria-selected":b,disabled:void 0,onClick:k,onFocus:E,onPointerEnter:N,onMouseEnter:N,onPointerMove:$,onMouseMove:$,onPointerLeave:_,onMouseLeave:_},L=En();return!b&&d?null:L({ourProps:O,theirProps:c,slot:M,defaultTag:f5,name:"Listbox.Option"})}let h5=p.Fragment;function p5(e,n){let{options:s,placeholder:r,...o}=e,i={ref:Fn(n)},c=ld("ListboxSelectedOption"),d=Ks({}),u=c.value===void 0||c.value===null||c.mode===Do.Multi&&Array.isArray(c.value)&&c.value.length===0,f=En();return Ke.createElement(NS.Provider,{value:!0},f({ourProps:i,theirProps:{...o,children:Ke.createElement(Ke.Fragment,null,r&&u?r:s)},slot:d,defaultTag:h5,name:"ListboxSelectedOption"}))}let g5=xn(a5),SS=xn(l5),x5=KA,CS=xn(u5),ES=xn(m5),v5=xn(p5),y5=Object.assign(g5,{Button:SS,Label:x5,Options:CS,Option:ES,SelectedOption:v5});const b5={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-3xl",full:"h-full max-w-5xl"};function Om({open:e,onClose:n,title:s,description:r,footer:o,size:i="md",initialFocus:c,hideClose:d,className:u,children:f}){return t.jsxs(ZO,{open:e,onClose:n,initialFocus:c,className:"relative z-dialog",children:[t.jsx(XO,{className:"fixed inset-0 bg-overlay/70"}),t.jsx("div",{className:ie("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(yS,{className:ie("flex w-full flex-col border border-border-strong bg-background text-foreground shadow-float",b5[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(bS,{className:"text-lg font-semibold",children:s}),r&&t.jsx(v1,{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(Xo,{"aria-hidden":!0})})]}),f&&t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4 text-body",children:f}),o&&t.jsx("footer",{className:"flex flex-wrap justify-end gap-2 border-t px-5 py-3",children:o})]})})]})}function pv({open:e,title:n,confirm:s,cancel:r="Cancel",tone:o="destructive",busy:i,onConfirm:c,onCancel:d,children:u}){const f=p.useRef(null);return t.jsx(Om,{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:o,onClick:c,disabled:i,"aria-busy":i||void 0,children:s})]}),children:u})}const gv=p.createContext(null),w5=()=>p.useContext(gv);function xv(e){const n=p.useContext(gv);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 wt({label:e,id:n,required:s,optional:r,note:o,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=[o&&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]}),o&&t.jsx("p",{id:y,className:"-mt-1 mb-2 text-small text-muted-foreground",children:o}),t.jsx(gv.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 $S="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",_S="min-w-0 bg-transparent font-mono text-body outline-none placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",cd="xl:columns-2 xl:gap-x-10 2xl:columns-3 [&>*]:mb-5 [&>*]:mt-0 [&>*]:break-inside-avoid",Hc="border border-input bg-background hover:border-foreground/60 focus-within:outline focus-within:outline-focus focus-within:outline-ring",Me=p.forwardRef(({className:e,fieldSize:n="md",bare:s,...r},o)=>t.jsx("input",{ref:o,...r,...xv(r),className:ie(s?_S:ie($S,n==="sm"?"h-control-sm":"h-control-md"),e)}));Me.displayName="Input";const nn=p.forwardRef(({className:e,bare:n,...s},r)=>t.jsx("textarea",{ref:r,...s,...xv(s),className:ie(n?_S:ie($S,"py-2.5"),e)}));nn.displayName="Textarea";const TS=e=>{const n=p.forwardRef(({label:s,note:r,className:o,disabled:i,...c},d)=>t.jsxs("label",{className:ie("flex items-start gap-2.5 text-body",i?"cursor-not-allowed opacity-45":"cursor-pointer",o),children:[t.jsx("input",{ref:d,type:e,disabled:i,...c,...xv(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},j5=TS("checkbox");TS("radio");function yr({icon:e,active:n,className:s,children:r,...o}){return t.jsxs("button",{type:"button","aria-current":n?"page":void 0,...o,className:ie("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 Et({value:e,onChange:n,options:s,label:r,id:o,className:i,disabled:c=!1,name:d,small:u=!1,placeholder:f,autoFocus:g}){const b=s.find(h=>h.value===e),x=w5();return t.jsxs(y5,{value:e,onChange:n,disabled:c,name:d,children:[t.jsxs(SS,{id:o??(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:ie("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:ie("min-w-0 truncate",!b&&"text-muted-foreground"),children:(b==null?void 0:b.label)??f??""}),t.jsx(Or,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsx(CS,{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(ES,{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(xl,{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(ke,{tone:"success",className:"ml-auto",children:h.tag})]},h.value))})]})}function dd({value:e,onChange:n,options:s,label:r,name:o,size:i="md",className:c}){return t.jsx("div",{role:"radiogroup","aria-label":r,className:ie("inline-flex",c),children:s.map(d=>t.jsxs("label",{title:d.title,className:ie("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:o,value:d.value,checked:e===d.value,disabled:d.disabled,onChange:()=>n(d.value),className:"sr-only"}),d.label]},d.value))})}const k5=["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 N5({value:e,onChange:n,min:s,max:r,label:o,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":o,"aria-valuetext":i,onChange:u=>n(Number(u.target.value)),className:ie(k5,"h-control-sm cursor-pointer disabled:cursor-not-allowed disabled:opacity-45",c)})}function S5({label:e,className:n}){return t.jsxs("span",{role:e?"status":void 0,className:"inline-flex",children:[t.jsx(IT,{className:ie("size-4 animate-spin text-run-active",n),"aria-hidden":!0}),e&&t.jsx("span",{className:"sr-only",children:e})]})}function ud({checked:e,onChange:n,disabled:s,label:r,labelledBy:o,busy:i,className:c}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":r,"aria-labelledby":o,"aria-busy":i||void 0,disabled:s||i,onClick:()=>n(!e),className:ie("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:ie("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 RS="flex shrink-0 gap-x-4 overflow-x-auto border-b px-5 md:px-8",AS=e=>ie("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 OS({tabs:e,value:n,onChange:s,label:r,id:o,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:ie(RS,i),children:e.map(g=>t.jsx("button",{type:"button",role:"tab",id:o&&`${o}-tab-${g.id}`,"aria-controls":o&&`${o}-panel-${g.id}`,"aria-selected":n===g.id,tabIndex:c===g.id?0:-1,onClick:()=>s(g.id),className:AS(n===g.id),children:g.label},g.id))})}const C5=(e,n)=>({role:"tabpanel",id:`${e}-panel-${n}`,"aria-labelledby":`${e}-tab-${n}`});function E5({tip:e,children:n,className:s,align:r="start"}){const o=p.useId();return t.jsxs("span",{className:ie("group/tip relative inline-flex",s),children:[p.cloneElement(n,{"aria-describedby":o}),t.jsx("span",{role:"tooltip",id:o,className:ie("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 MS=p.createContext(null),$5={neutral:[Mg,"text-muted-foreground"],success:[TN,"text-success-text"],warning:[Gs,"text-warning-text"],error:[sl,"text-destructive-text"]},_5=5e3;function T5(){return p.useContext(MS)??R5}const R5=()=>{};function A5({toast:e,done:n}){const s=p.useCallback(()=>n(e.id),[n,e.id]),r=e.tone??"neutral",o=e.duration??(r==="error"?0:_5),[i,c]=p.useState(!1),[d,u]=p.useState(!1),f=i||d;p.useEffect(()=>{if(!o||f)return;const x=setTimeout(s,o);return()=>clearTimeout(x)},[o,f,s]);const[g,b]=$5[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:ie("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(Xo,{className:"size-3.5","aria-hidden":!0})})]})}function O5({children:e}){const[n,s]=p.useState([]),r=p.useRef(0),o=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(MS.Provider,{value:o,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(A5,{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:PS,setPrototypeOf:ek,isFrozen:M5,getPrototypeOf:P5,getOwnPropertyDescriptor:L5}=Object;let{freeze:ns,seal:Vs,create:LS}=Object,{apply:Vg,construct:Yg}=typeof Reflect<"u"&&Reflect;ns||(ns=function(n){return n});Vs||(Vs=function(n){return n});Vg||(Vg=function(n,s,r){return n.apply(s,r)});Yg||(Yg=function(n,s){return new n(...s)});const Gu=Cs(Array.prototype.forEach),tk=Cs(Array.prototype.pop),fc=Cs(Array.prototype.push),gf=Cs(String.prototype.toLowerCase),og=Cs(String.prototype.toString),nk=Cs(String.prototype.match),mc=Cs(String.prototype.replace),I5=Cs(String.prototype.indexOf),z5=Cs(String.prototype.trim),ar=Cs(Object.prototype.hasOwnProperty),Yn=Cs(RegExp.prototype.test),hc=D5(TypeError);function Cs(e){return function(n){for(var s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];return Vg(e,n,r)}}function D5(e){return function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];return Yg(e,s)}}function bt(e,n){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:gf;ek&&ek(e,null);let r=n.length;for(;r--;){let o=n[r];if(typeof o=="string"){const i=s(o);i!==o&&(M5(n)||(n[r]=i),o=i)}e[o]=!0}return e}function F5(e){for(let n=0;n<e.length;n++)ar(e,n)||(e[n]=null);return e}function Sa(e){const n=LS(null);for(const[s,r]of PS(e))ar(e,s)&&(Array.isArray(r)?n[s]=F5(r):r&&typeof r=="object"&&r.constructor===Object?n[s]=Sa(r):n[s]=r);return n}function pc(e,n){for(;e!==null;){const r=L5(e,n);if(r){if(r.get)return Cs(r.get);if(typeof r.value=="function")return Cs(r.value)}e=P5(e)}function s(){return null}return s}const sk=ns(["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"]),ag=ns(["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"]),ig=ns(["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"]),U5=ns(["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"]),lg=ns(["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"]),W5=ns(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),rk=ns(["#text"]),ok=ns(["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"]),cg=ns(["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"]),ak=ns(["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"]),qu=ns(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),H5=Vs(/\{\{[\w\W]*|[\w\W]*\}\}/gm),B5=Vs(/<%[\w\W]*|[\w\W]*%>/gm),G5=Vs(/\$\{[\w\W]*}/gm),q5=Vs(/^data-[\-\w.\u00B7-\uFFFF]+$/),K5=Vs(/^aria-[\-\w]+$/),IS=Vs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),V5=Vs(/^(?:\w+script|data):/i),Y5=Vs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),zS=Vs(/^html$/i),Q5=Vs(/^[a-z][.\w]*(-[.\w]+)+$/i);var ik=Object.freeze({__proto__:null,ARIA_ATTR:K5,ATTR_WHITESPACE:Y5,CUSTOM_ELEMENT:Q5,DATA_ATTR:q5,DOCTYPE_NAME:zS,ERB_EXPR:B5,IS_ALLOWED_URI:IS,IS_SCRIPT_OR_DATA:V5,MUSTACHE_EXPR:H5,TMPLIT_EXPR:G5});const gc={element:1,text:3,progressingInstruction:7,comment:8,document:9},J5=function(){return typeof window>"u"?null:window},X5=function(n,s){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";s&&s.hasAttribute(o)&&(r=s.getAttribute(o));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}},lk=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function DS(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:J5();const n=Be=>DS(Be);if(n.version="3.2.3",n.removed=[],!e||!e.document||e.document.nodeType!==gc.document)return n.isSupported=!1,n;let{document:s}=e;const r=s,o=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=pc(v,"cloneNode"),j=pc(v,"remove"),k=pc(v,"nextSibling"),E=pc(v,"childNodes"),S=pc(v,"parentNode");if(typeof c=="function"){const Be=s.createElement("template");Be.content&&Be.content.ownerDocument&&(s=Be.content.ownerDocument)}let N,$="";const{implementation:_,createNodeIterator:M,createDocumentFragment:O,getElementsByTagName:L}=s,{importNode:R}=r;let A=lk();n.isSupported=typeof PS=="function"&&typeof S=="function"&&_&&_.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:P,ERB_EXPR:z,TMPLIT_EXPR:U,DATA_ATTR:q,ARIA_ATTR:H,IS_SCRIPT_OR_DATA:K,ATTR_WHITESPACE:W,CUSTOM_ELEMENT:G}=ik;let{IS_ALLOWED_URI:F}=ik,D=null;const Y=bt({},[...sk,...ag,...ig,...lg,...rk]);let se=null;const Q=bt({},[...ok,...cg,...ak,...qu]);let re=Object.seal(LS(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}})),te=null,he=null,ge=!0,be=!0,xe=!1,fe=!0,De=!1,Fe=!0,Pe=!1,Ee=!1,ae=!1,$e=!1,ot=!1,me=!1,Le=!0,Ze=!1;const yt="user-content-";let oe=!0,Se=!1,tt={},Ae=null;const it=bt({},["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 nt=bt({},["audio","video","img","source","image","track"]);let ft=null;const Dt=bt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ft="http://www.w3.org/1998/Math/MathML",ye="http://www.w3.org/2000/svg",de="http://www.w3.org/1999/xhtml";let Ue=de,Xe=!1,at=null;const J=bt({},[Ft,ye,de],og);let ve=bt({},["mi","mo","mn","ms","mtext"]),We=bt({},["annotation-xml"]);const Ve=bt({},["title","style","font","a","script"]);let He=null;const gt=["application/xhtml+xml","text/html"],kt="text/html";let lt=null,Vt=null;const ps=s.createElement("form"),Qs=function(ee){return ee instanceof RegExp||ee instanceof Function},$n=function(){let ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Vt&&Vt===ee)){if((!ee||typeof ee!="object")&&(ee={}),ee=Sa(ee),He=gt.indexOf(ee.PARSER_MEDIA_TYPE)===-1?kt:ee.PARSER_MEDIA_TYPE,lt=He==="application/xhtml+xml"?og:gf,D=ar(ee,"ALLOWED_TAGS")?bt({},ee.ALLOWED_TAGS,lt):Y,se=ar(ee,"ALLOWED_ATTR")?bt({},ee.ALLOWED_ATTR,lt):Q,at=ar(ee,"ALLOWED_NAMESPACES")?bt({},ee.ALLOWED_NAMESPACES,og):J,ft=ar(ee,"ADD_URI_SAFE_ATTR")?bt(Sa(Dt),ee.ADD_URI_SAFE_ATTR,lt):Dt,$t=ar(ee,"ADD_DATA_URI_TAGS")?bt(Sa(nt),ee.ADD_DATA_URI_TAGS,lt):nt,Ae=ar(ee,"FORBID_CONTENTS")?bt({},ee.FORBID_CONTENTS,lt):it,te=ar(ee,"FORBID_TAGS")?bt({},ee.FORBID_TAGS,lt):{},he=ar(ee,"FORBID_ATTR")?bt({},ee.FORBID_ATTR,lt):{},tt=ar(ee,"USE_PROFILES")?ee.USE_PROFILES:!1,ge=ee.ALLOW_ARIA_ATTR!==!1,be=ee.ALLOW_DATA_ATTR!==!1,xe=ee.ALLOW_UNKNOWN_PROTOCOLS||!1,fe=ee.ALLOW_SELF_CLOSE_IN_ATTR!==!1,De=ee.SAFE_FOR_TEMPLATES||!1,Fe=ee.SAFE_FOR_XML!==!1,Pe=ee.WHOLE_DOCUMENT||!1,$e=ee.RETURN_DOM||!1,ot=ee.RETURN_DOM_FRAGMENT||!1,me=ee.RETURN_TRUSTED_TYPE||!1,ae=ee.FORCE_BODY||!1,Le=ee.SANITIZE_DOM!==!1,Ze=ee.SANITIZE_NAMED_PROPS||!1,oe=ee.KEEP_CONTENT!==!1,Se=ee.IN_PLACE||!1,F=ee.ALLOWED_URI_REGEXP||IS,Ue=ee.NAMESPACE||de,ve=ee.MATHML_TEXT_INTEGRATION_POINTS||ve,We=ee.HTML_INTEGRATION_POINTS||We,re=ee.CUSTOM_ELEMENT_HANDLING||{},ee.CUSTOM_ELEMENT_HANDLING&&Qs(ee.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(re.tagNameCheck=ee.CUSTOM_ELEMENT_HANDLING.tagNameCheck),ee.CUSTOM_ELEMENT_HANDLING&&Qs(ee.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(re.attributeNameCheck=ee.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),ee.CUSTOM_ELEMENT_HANDLING&&typeof ee.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(re.allowCustomizedBuiltInElements=ee.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),De&&(be=!1),ot&&($e=!0),tt&&(D=bt({},rk),se=[],tt.html===!0&&(bt(D,sk),bt(se,ok)),tt.svg===!0&&(bt(D,ag),bt(se,cg),bt(se,qu)),tt.svgFilters===!0&&(bt(D,ig),bt(se,cg),bt(se,qu)),tt.mathMl===!0&&(bt(D,lg),bt(se,ak),bt(se,qu))),ee.ADD_TAGS&&(D===Y&&(D=Sa(D)),bt(D,ee.ADD_TAGS,lt)),ee.ADD_ATTR&&(se===Q&&(se=Sa(se)),bt(se,ee.ADD_ATTR,lt)),ee.ADD_URI_SAFE_ATTR&&bt(ft,ee.ADD_URI_SAFE_ATTR,lt),ee.FORBID_CONTENTS&&(Ae===it&&(Ae=Sa(Ae)),bt(Ae,ee.FORBID_CONTENTS,lt)),oe&&(D["#text"]=!0),Pe&&bt(D,["html","head","body"]),D.table&&(bt(D,["tbody"]),delete te.tbody),ee.TRUSTED_TYPES_POLICY){if(typeof ee.TRUSTED_TYPES_POLICY.createHTML!="function")throw hc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof ee.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw hc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=ee.TRUSTED_TYPES_POLICY,$=N.createHTML("")}else N===void 0&&(N=X5(h,o)),N!==null&&typeof $=="string"&&($=N.createHTML(""));ns&&ns(ee),Vt=ee}},Wn=bt({},[...ag,...ig,...U5]),gs=bt({},[...lg,...W5]),xs=function(ee){let we=S(ee);(!we||!we.tagName)&&(we={namespaceURI:Ue,tagName:"template"});const qe=gf(ee.tagName),St=gf(we.tagName);return at[ee.namespaceURI]?ee.namespaceURI===ye?we.namespaceURI===de?qe==="svg":we.namespaceURI===Ft?qe==="svg"&&(St==="annotation-xml"||ve[St]):!!Wn[qe]:ee.namespaceURI===Ft?we.namespaceURI===de?qe==="math":we.namespaceURI===ye?qe==="math"&&We[St]:!!gs[qe]:ee.namespaceURI===de?we.namespaceURI===ye&&!We[St]||we.namespaceURI===Ft&&!ve[St]?!1:!gs[qe]&&(Ve[qe]||!Wn[qe]):!!(He==="application/xhtml+xml"&&at[ee.namespaceURI]):!1},mn=function(ee){fc(n.removed,{element:ee});try{S(ee).removeChild(ee)}catch{j(ee)}},Hn=function(ee,we){try{fc(n.removed,{attribute:we.getAttributeNode(ee),from:we})}catch{fc(n.removed,{attribute:null,from:we})}if(we.removeAttribute(ee),ee==="is")if($e||ot)try{mn(we)}catch{}else try{we.setAttribute(ee,"")}catch{}},_s=function(ee){let we=null,qe=null;if(ae)ee="<remove></remove>"+ee;else{const ct=nk(ee,/^[\r\n\t ]+/);qe=ct&&ct[0]}He==="application/xhtml+xml"&&Ue===de&&(ee='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+ee+"</body></html>");const St=N?N.createHTML(ee):ee;if(Ue===de)try{we=new x().parseFromString(St,He)}catch{}if(!we||!we.documentElement){we=_.createDocument(Ue,"template",null);try{we.documentElement.innerHTML=Xe?$:St}catch{}}const It=we.body||we.documentElement;return ee&&qe&&It.insertBefore(s.createTextNode(qe),It.childNodes[0]||null),Ue===de?L.call(we,Pe?"html":"body")[0]:Pe?we.documentElement:It},Bn=function(ee){return M.call(ee.ownerDocument||ee,ee,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},Ts=function(ee){return ee instanceof b&&(typeof ee.nodeName!="string"||typeof ee.textContent!="string"||typeof ee.removeChild!="function"||!(ee.attributes instanceof g)||typeof ee.removeAttribute!="function"||typeof ee.setAttribute!="function"||typeof ee.namespaceURI!="string"||typeof ee.insertBefore!="function"||typeof ee.hasChildNodes!="function")},Rs=function(ee){return typeof d=="function"&&ee instanceof d};function On(Be,ee,we){Gu(Be,qe=>{qe.call(n,ee,we,Vt)})}const Z=function(ee){let we=null;if(On(A.beforeSanitizeElements,ee,null),Ts(ee))return mn(ee),!0;const qe=lt(ee.nodeName);if(On(A.uponSanitizeElement,ee,{tagName:qe,allowedTags:D}),ee.hasChildNodes()&&!Rs(ee.firstElementChild)&&Yn(/<[/\w]/g,ee.innerHTML)&&Yn(/<[/\w]/g,ee.textContent)||ee.nodeType===gc.progressingInstruction||Fe&&ee.nodeType===gc.comment&&Yn(/<[/\w]/g,ee.data))return mn(ee),!0;if(!D[qe]||te[qe]){if(!te[qe]&&mt(qe)&&(re.tagNameCheck instanceof RegExp&&Yn(re.tagNameCheck,qe)||re.tagNameCheck instanceof Function&&re.tagNameCheck(qe)))return!1;if(oe&&!Ae[qe]){const St=S(ee)||ee.parentNode,It=E(ee)||ee.childNodes;if(It&&St){const ct=It.length;for(let wn=ct-1;wn>=0;--wn){const _n=y(It[wn],!0);_n.__removalCount=(ee.__removalCount||0)+1,St.insertBefore(_n,k(ee))}}}return mn(ee),!0}return ee instanceof u&&!xs(ee)||(qe==="noscript"||qe==="noembed"||qe==="noframes")&&Yn(/<\/no(script|embed|frames)/i,ee.innerHTML)?(mn(ee),!0):(De&&ee.nodeType===gc.text&&(we=ee.textContent,Gu([P,z,U],St=>{we=mc(we,St," ")}),ee.textContent!==we&&(fc(n.removed,{element:ee.cloneNode()}),ee.textContent=we)),On(A.afterSanitizeElements,ee,null),!1)},Oe=function(ee,we,qe){if(Le&&(we==="id"||we==="name")&&(qe in s||qe in ps))return!1;if(!(be&&!he[we]&&Yn(q,we))){if(!(ge&&Yn(H,we))){if(!se[we]||he[we]){if(!(mt(ee)&&(re.tagNameCheck instanceof RegExp&&Yn(re.tagNameCheck,ee)||re.tagNameCheck instanceof Function&&re.tagNameCheck(ee))&&(re.attributeNameCheck instanceof RegExp&&Yn(re.attributeNameCheck,we)||re.attributeNameCheck instanceof Function&&re.attributeNameCheck(we))||we==="is"&&re.allowCustomizedBuiltInElements&&(re.tagNameCheck instanceof RegExp&&Yn(re.tagNameCheck,qe)||re.tagNameCheck instanceof Function&&re.tagNameCheck(qe))))return!1}else if(!ft[we]){if(!Yn(F,mc(qe,W,""))){if(!((we==="src"||we==="xlink:href"||we==="href")&&ee!=="script"&&I5(qe,"data:")===0&&$t[ee])){if(!(xe&&!Yn(K,mc(qe,W,"")))){if(qe)return!1}}}}}}return!0},mt=function(ee){return ee!=="annotation-xml"&&nk(ee,G)},Ot=function(ee){On(A.beforeSanitizeAttributes,ee,null);const{attributes:we}=ee;if(!we||Ts(ee))return;const qe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:se,forceKeepAttr:void 0};let St=we.length;for(;St--;){const It=we[St],{name:ct,namespaceURI:wn,value:_n}=It,mr=lt(ct);let Bt=ct==="value"?_n:z5(_n);if(qe.attrName=mr,qe.attrValue=Bt,qe.keepAttr=!0,qe.forceKeepAttr=void 0,On(A.uponSanitizeAttribute,ee,qe),Bt=qe.attrValue,Ze&&(mr==="id"||mr==="name")&&(Hn(ct,ee),Bt=yt+Bt),Fe&&Yn(/((--!?|])>)|<\/(style|title)/i,Bt)){Hn(ct,ee);continue}if(qe.forceKeepAttr||(Hn(ct,ee),!qe.keepAttr))continue;if(!fe&&Yn(/\/>/i,Bt)){Hn(ct,ee);continue}De&&Gu([P,z,U],io=>{Bt=mc(Bt,io," ")});const oi=lt(ee.nodeName);if(Oe(oi,mr,Bt)){if(N&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!wn)switch(h.getAttributeType(oi,mr)){case"TrustedHTML":{Bt=N.createHTML(Bt);break}case"TrustedScriptURL":{Bt=N.createScriptURL(Bt);break}}try{wn?ee.setAttributeNS(wn,ct,Bt):ee.setAttribute(ct,Bt),Ts(ee)?mn(ee):tk(n.removed)}catch{}}}On(A.afterSanitizeAttributes,ee,null)},Xt=function Be(ee){let we=null;const qe=Bn(ee);for(On(A.beforeSanitizeShadowDOM,ee,null);we=qe.nextNode();)On(A.uponSanitizeShadowNode,we,null),Z(we),Ot(we),we.content instanceof i&&Be(we.content);On(A.afterSanitizeShadowDOM,ee,null)};return n.sanitize=function(Be){let ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},we=null,qe=null,St=null,It=null;if(Xe=!Be,Xe&&(Be="<!-->"),typeof Be!="string"&&!Rs(Be))if(typeof Be.toString=="function"){if(Be=Be.toString(),typeof Be!="string")throw hc("dirty is not a string, aborting")}else throw hc("toString is not a function");if(!n.isSupported)return Be;if(Ee||$n(ee),n.removed=[],typeof Be=="string"&&(Se=!1),Se){if(Be.nodeName){const _n=lt(Be.nodeName);if(!D[_n]||te[_n])throw hc("root node is forbidden and cannot be sanitized in-place")}}else if(Be instanceof d)we=_s("<!---->"),qe=we.ownerDocument.importNode(Be,!0),qe.nodeType===gc.element&&qe.nodeName==="BODY"||qe.nodeName==="HTML"?we=qe:we.appendChild(qe);else{if(!$e&&!De&&!Pe&&Be.indexOf("<")===-1)return N&&me?N.createHTML(Be):Be;if(we=_s(Be),!we)return $e?null:me?$:""}we&&ae&&mn(we.firstChild);const ct=Bn(Se?Be:we);for(;St=ct.nextNode();)Z(St),Ot(St),St.content instanceof i&&Xt(St.content);if(Se)return Be;if($e){if(ot)for(It=O.call(we.ownerDocument);we.firstChild;)It.appendChild(we.firstChild);else It=we;return(se.shadowroot||se.shadowrootmode)&&(It=R.call(r,It,!0)),It}let wn=Pe?we.outerHTML:we.innerHTML;return Pe&&D["!doctype"]&&we.ownerDocument&&we.ownerDocument.doctype&&we.ownerDocument.doctype.name&&Yn(zS,we.ownerDocument.doctype.name)&&(wn="<!DOCTYPE "+we.ownerDocument.doctype.name+`>
|
|
523
|
+
`+wn),De&&Gu([P,z,U],_n=>{wn=mc(wn,_n," ")}),N&&me?N.createHTML(wn):wn},n.setConfig=function(){let Be=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};$n(Be),Ee=!0},n.clearConfig=function(){Vt=null,Ee=!1},n.isValidAttribute=function(Be,ee,we){Vt||$n({});const qe=lt(Be),St=lt(ee);return Oe(qe,St,we)},n.addHook=function(Be,ee){typeof ee=="function"&&fc(A[Be],ee)},n.removeHook=function(Be){return tk(A[Be])},n.removeHooks=function(Be){A[Be]=[]},n.removeAllHooks=function(){A=lk()},n}var xf=DS();function vv(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let ei=vv();function FS(e){ei=e}const Ac={exec:()=>null};function zt(e,n=""){let s=typeof e=="string"?e:e.source;const r={replace:(o,i)=>{let c=typeof i=="string"?i:i.source;return c=c.replace(Zn.caret,"$1"),s=s.replace(o,c),r},getRegex:()=>new RegExp(s,n)};return r}const Zn={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")},Z5=/^(?:[ \t]*(?:\n|$))+/,eM=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,tM=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,fd=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nM=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,US=/(?:[*+-]|\d{1,9}[.)])/,WS=zt(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,US).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(),yv=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,sM=/^[^\n]+/,bv=/(?!\s*\])(?:\\.|[^\[\]\\])+/,rM=zt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",bv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),oM=zt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,US).getRegex(),Mm="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",wv=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,aM=zt("^ {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",wv).replace("tag",Mm).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),HS=zt(yv).replace("hr",fd).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",Mm).getRegex(),iM=zt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",HS).getRegex(),jv={blockquote:iM,code:eM,def:rM,fences:tM,heading:nM,hr:fd,html:aM,lheading:WS,list:oM,newline:Z5,paragraph:HS,table:Ac,text:sM},ck=zt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",fd).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",Mm).getRegex(),lM={...jv,table:ck,paragraph:zt(yv).replace("hr",fd).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ck).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",Mm).getRegex()},cM={...jv,html:zt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",wv).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:Ac,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:zt(yv).replace("hr",fd).replace("heading",` *#{1,6} *[^
|
|
524
|
+
]`).replace("lheading",WS).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},dM=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,uM=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,BS=/^( {2,}|\\)\n(?!\s*$)/,fM=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Pm=/[\p{P}\p{S}]/u,kv=/[\s\p{P}\p{S}]/u,GS=/[^\s\p{P}\p{S}]/u,mM=zt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,kv).getRegex(),qS=/(?!~)[\p{P}\p{S}]/u,hM=/(?!~)[\s\p{P}\p{S}]/u,pM=/(?:[^\s\p{P}\p{S}]|~)/u,gM=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,KS=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,xM=zt(KS,"u").replace(/punct/g,Pm).getRegex(),vM=zt(KS,"u").replace(/punct/g,qS).getRegex(),VS="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",yM=zt(VS,"gu").replace(/notPunctSpace/g,GS).replace(/punctSpace/g,kv).replace(/punct/g,Pm).getRegex(),bM=zt(VS,"gu").replace(/notPunctSpace/g,pM).replace(/punctSpace/g,hM).replace(/punct/g,qS).getRegex(),wM=zt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,GS).replace(/punctSpace/g,kv).replace(/punct/g,Pm).getRegex(),jM=zt(/\\(punct)/,"gu").replace(/punct/g,Pm).getRegex(),kM=zt(/^<(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(),NM=zt(wv).replace("(?:-->|$)","-->").getRegex(),SM=zt("^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",NM).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Of=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,CM=zt(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Of).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),YS=zt(/^!?\[(label)\]\[(ref)\]/).replace("label",Of).replace("ref",bv).getRegex(),QS=zt(/^!?\[(ref)\](?:\[\])?/).replace("ref",bv).getRegex(),EM=zt("reflink|nolink(?!\\()","g").replace("reflink",YS).replace("nolink",QS).getRegex(),Nv={_backpedal:Ac,anyPunctuation:jM,autolink:kM,blockSkip:gM,br:BS,code:uM,del:Ac,emStrongLDelim:xM,emStrongRDelimAst:yM,emStrongRDelimUnd:wM,escape:dM,link:CM,nolink:QS,punctuation:mM,reflink:YS,reflinkSearch:EM,tag:SM,text:fM,url:Ac},$M={...Nv,link:zt(/^!?\[(label)\]\((.*?)\)/).replace("label",Of).getRegex(),reflink:zt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Of).getRegex()},Qg={...Nv,emStrongRDelimAst:bM,emStrongLDelim:vM,url:zt(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},_M={...Qg,br:zt(BS).replace("{2,}","*").getRegex(),text:zt(Qg.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ku={normal:jv,gfm:lM,pedantic:cM},xc={normal:Nv,gfm:Qg,breaks:_M,pedantic:$M},TM={"&":"&","<":"<",">":">",'"':""","'":"'"},dk=e=>TM[e];function kr(e,n){if(n){if(Zn.escapeTest.test(e))return e.replace(Zn.escapeReplace,dk)}else if(Zn.escapeTestNoEncode.test(e))return e.replace(Zn.escapeReplaceNoEncode,dk);return e}function uk(e){try{e=encodeURI(e).replace(Zn.percentDecode,"%")}catch{return null}return e}function fk(e,n){var i;const s=e.replace(Zn.findPipe,(c,d,u)=>{let f=!1,g=d;for(;--g>=0&&u[g]==="\\";)f=!f;return f?"|":" |"}),r=s.split(Zn.splitPipe);let o=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(;o<r.length;o++)r[o]=r[o].trim().replace(Zn.slashPipe,"|");return r}function vc(e,n,s){const r=e.length;if(r===0)return"";let o=0;for(;o<r&&e.charAt(r-o-1)===n;)o++;return e.slice(0,r-o)}function RM(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 mk(e,n,s,r,o){const i=n.href,c=n.title||null,d=e[1].replace(o.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 AM(e,n,s){const r=e.match(s.other.indentCodeCompensation);if(r===null)return n;const o=r[1];return n.split(`
|
|
525
|
+
`).map(i=>{const c=i.match(s.other.beginningSpace);if(c===null)return i;const[d]=c;return d.length>=o.length?i.slice(o.length):i}).join(`
|
|
526
|
+
`)}class Mf{constructor(n){At(this,"options");At(this,"rules");At(this,"lexer");this.options=n||ei}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:vc(r,`
|
|
527
|
+
`)}}}fences(n){const s=this.rules.block.fences.exec(n);if(s){const r=s[0],o=AM(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:o}}}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 o=vc(r,"#");(this.options.pedantic||!o||this.rules.other.endingSpaceChar.test(o))&&(r=o.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:vc(s[0],`
|
|
528
|
+
`)}}blockquote(n){const s=this.rules.block.blockquote.exec(n);if(s){let r=vc(s[0],`
|
|
529
|
+
`).split(`
|
|
530
|
+
`),o="",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(`
|
|
531
|
+
`),b=g.replace(this.rules.other.blockquoteSetextReplace,`
|
|
532
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
|
|
533
|
+
${g}`:g,i=i?`${i}
|
|
534
|
+
${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+`
|
|
535
|
+
`+r.join(`
|
|
536
|
+
`),j=this.blockquote(y);c[c.length-1]=j,o=o.substring(0,o.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+`
|
|
537
|
+
`+r.join(`
|
|
538
|
+
`),j=this.list(y);c[c.length-1]=j,o=o.substring(0,o.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(`
|
|
539
|
+
`);continue}}return{type:"blockquote",raw:o,tokens:c,text:i}}}list(n){let s=this.rules.block.list.exec(n);if(s){let r=s[1].trim();const o=r.length>1,i={type:"list",raw:"",ordered:o,start:o?+r.slice(0,-1):"",loose:!1,items:[]};r=o?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=o?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(`
|
|
540
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,E=>" ".repeat(3*E.length)),h=n.split(`
|
|
541
|
+
`,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+`
|
|
542
|
+
`,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 M=n.split(`
|
|
543
|
+
`,1)[0];let O;if(h=M,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),O=h):O=h.replace(this.rules.other.tabCharGlobal," "),N.test(h)||$.test(h)||_.test(h)||E.test(h)||S.test(h))break;if(O.search(this.rules.other.nonSpaceChar)>=y||!h.trim())b+=`
|
|
544
|
+
`+O.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+=`
|
|
545
|
+
`+h}!v&&!h.trim()&&(v=!0),g+=M+`
|
|
546
|
+
`,n=n.substring(M.length+1),x=O.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," "),o=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:o,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=fk(s[1]),o=s[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(d=s[3])!=null&&d.trim()?s[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
547
|
+
`):[],c={type:"table",raw:s[0],header:[],align:[],rows:[]};if(r.length===o.length){for(const u of o)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(fk(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)===`
|
|
548
|
+
`?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=vc(r.slice(0,-1),"\\");if((r.length-c.length)%2===0)return}else{const c=RM(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 o=s[2],i="";if(this.options.pedantic){const c=this.rules.other.pedanticHrefTitle.exec(o);c&&(o=c[1],i=c[3])}else i=s[3]?s[3].slice(1,-1):"";return o=o.trim(),this.rules.other.startAngleBracket.test(o)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?o=o.slice(1):o=o.slice(1,-1)),mk(s,{href:o&&o.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 o=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=s[o.toLowerCase()];if(!i){const c=r[0].charAt(0);return{type:"text",raw:c,text:c}}return mk(r,i,r[0],this.lexer,this.rules)}}emStrong(n,s,r=""){let o=this.rules.inline.emStrongLDelim.exec(n);if(!o||o[3]&&r.match(this.rules.other.unicodeAlphaNumeric))return;if(!(o[1]||o[2]||"")||!r||this.rules.inline.punctuation.exec(r)){const c=[...o[0]].length-1;let d,u,f=c,g=0;const b=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(b.lastIndex=0,s=s.slice(-1*n.length+c);(o=b.exec(s))!=null;){if(d=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!d)continue;if(u=[...d].length,o[3]||o[4]){f+=u;continue}else if((o[5]||o[6])&&c%3&&!((c+u)%3)){g+=u;continue}if(f-=u,f>0)continue;u=Math.min(u,u+f+g);const x=[...o[0]][0].length,h=n.slice(0,c+o.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 o=this.rules.other.nonSpaceChar.test(r),i=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return o&&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,o;return s[2]==="@"?(r=s[1],o="mailto:"+r):(r=s[1],o=r),{type:"link",raw:s[0],text:r,href:o,tokens:[{type:"text",raw:r,text:r}]}}}url(n){var r;let s;if(s=this.rules.inline.url.exec(n)){let o,i;if(s[2]==="@")o=s[0],i="mailto:"+o;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]);o=s[0],s[1]==="www."?i="http://"+s[0]:i=s[0]}return{type:"link",raw:s[0],text:o,href:i,tokens:[{type:"text",raw:o,text:o}]}}}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 Fs{constructor(n){At(this,"tokens");At(this,"options");At(this,"state");At(this,"tokenizer");At(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=n||ei,this.options.tokenizer=this.options.tokenizer||new Mf,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:Zn,block:Ku.normal,inline:xc.normal};this.options.pedantic?(s.block=Ku.pedantic,s.inline=xc.pedantic):this.options.gfm&&(s.block=Ku.gfm,this.options.breaks?s.inline=xc.breaks:s.inline=xc.gfm),this.tokenizer.rules=s}static get rules(){return{block:Ku,inline:xc}}static lex(n,s){return new Fs(s).lex(n)}static lexInline(n,s){return new Fs(s).inlineTokens(n)}lex(n){n=n.replace(Zn.carriageReturn,`
|
|
549
|
+
`),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 o,i,c;for(this.options.pedantic&&(n=n.replace(Zn.tabCharGlobal," ").replace(Zn.spaceLine,""));n;){let d;if((i=(o=this.options.extensions)==null?void 0:o.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+=`
|
|
550
|
+
`: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+=`
|
|
551
|
+
`+d.raw,f.text+=`
|
|
552
|
+
`+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+=`
|
|
553
|
+
`+d.raw,f.text+=`
|
|
554
|
+
`+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+=`
|
|
555
|
+
`+d.raw,f.text+=`
|
|
556
|
+
`+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+=`
|
|
557
|
+
`+d.raw,f.text+=`
|
|
558
|
+
`+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,o=null;if(this.tokens.links){const g=Object.keys(this.tokens.links);if(g.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)g.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,o.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 Pf{constructor(n){At(this,"options");At(this,"parser");this.options=n||ei}space(n){return""}code({text:n,lang:s,escaped:r}){var c;const o=(c=(s||"").match(Zn.notSpaceStart))==null?void 0:c[0],i=n.replace(Zn.endingNewline,"")+`
|
|
559
|
+
`;return o?'<pre><code class="language-'+kr(o)+'">'+(r?i:kr(i,!0))+`</code></pre>
|
|
560
|
+
`:"<pre><code>"+(r?i:kr(i,!0))+`</code></pre>
|
|
561
|
+
`}blockquote({tokens:n}){return`<blockquote>
|
|
562
|
+
${this.parser.parse(n)}</blockquote>
|
|
563
|
+
`}html({text:n}){return n}heading({tokens:n,depth:s}){return`<h${s}>${this.parser.parseInline(n)}</h${s}>
|
|
564
|
+
`}hr(n){return`<hr>
|
|
565
|
+
`}list(n){const s=n.ordered,r=n.start;let o="";for(let d=0;d<n.items.length;d++){const u=n.items[d];o+=this.listitem(u)}const i=s?"ol":"ul",c=s&&r!==1?' start="'+r+'"':"";return"<"+i+c+`>
|
|
566
|
+
`+o+"</"+i+`>
|
|
567
|
+
`}listitem(n){var r;let s="";if(n.task){const o=this.checkbox({checked:!!n.checked});n.loose?((r=n.tokens[0])==null?void 0:r.type)==="paragraph"?(n.tokens[0].text=o+" "+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=o+" "+kr(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:o+" ",text:o+" ",escaped:!0}):s+=o+" "}return s+=this.parser.parse(n.tokens,!!n.loose),`<li>${s}</li>
|
|
568
|
+
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
569
|
+
`}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 o="";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]);o+=this.tablerow({text:r})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
|
|
570
|
+
<thead>
|
|
571
|
+
`+s+`</thead>
|
|
572
|
+
`+o+`</table>
|
|
573
|
+
`}tablerow({text:n}){return`<tr>
|
|
574
|
+
${n}</tr>
|
|
575
|
+
`}tablecell(n){const s=this.parser.parseInline(n.tokens),r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+s+`</${r}>
|
|
576
|
+
`}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>${kr(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 o=this.parser.parseInline(r),i=uk(n);if(i===null)return o;n=i;let c='<a href="'+n+'"';return s&&(c+=' title="'+kr(s)+'"'),c+=">"+o+"</a>",c}image({href:n,title:s,text:r}){const o=uk(n);if(o===null)return kr(r);n=o;let i=`<img src="${n}" alt="${r}"`;return s&&(i+=` title="${kr(s)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:kr(n.text)}}class Sv{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 Us{constructor(n){At(this,"options");At(this,"renderer");At(this,"textRenderer");this.options=n||ei,this.options.renderer=this.options.renderer||new Pf,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Sv}static parse(n,s){return new Us(s).parse(n)}static parseInline(n,s){return new Us(s).parseInline(n)}parse(n,s=!0){var o,i;let r="";for(let c=0;c<n.length;c++){const d=n[c];if((i=(o=this.options.extensions)==null?void 0:o.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+=`
|
|
577
|
+
`+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 o,i;let r="";for(let c=0;c<n.length;c++){const d=n[c];if((i=(o=this.options.extensions)==null?void 0:o.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 Oc{constructor(n){At(this,"options");At(this,"block");this.options=n||ei}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?Fs.lex:Fs.lexInline}provideParser(){return this.block?Us.parse:Us.parseInline}}At(Oc,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class OM{constructor(...n){At(this,"defaults",vv());At(this,"options",this.setOptions);At(this,"parse",this.parseMarkdown(!0));At(this,"parseInline",this.parseMarkdown(!1));At(this,"Parser",Us);At(this,"Renderer",Pf);At(this,"TextRenderer",Sv);At(this,"Lexer",Fs);At(this,"Tokenizer",Mf);At(this,"Hooks",Oc);this.use(...n)}walkTokens(n,s){var o,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=(o=this.defaults.extensions)==null?void 0:o.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 o={...r};if(o.async=this.defaults.async||o.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)}),o.extensions=s),r.renderer){const i=this.defaults.renderer||new Pf(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||""}}o.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new Mf(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}}o.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new Oc;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];Oc.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}}o.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,c=r.walkTokens;o.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,...o}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,s){return Fs.lex(n,s??this.defaults)}parser(n,s){return Us.parse(n,s??this.defaults)}parseMarkdown(n){return(r,o)=>{const i={...o},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?Fs.lex:Fs.lexInline,f=c.hooks?c.hooks.provideParser():n?Us.parse:Us.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+=`
|
|
578
|
+
Please report this to https://github.com/markedjs/marked.`,n){const o="<p>An error occurred:</p><pre>"+kr(r.message+"",!0)+"</pre>";return s?Promise.resolve(o):o}if(s)return Promise.reject(r);throw r}}}const Ha=new OM;function Lt(e,n){return Ha.parse(e,n)}Lt.options=Lt.setOptions=function(e){return Ha.setOptions(e),Lt.defaults=Ha.defaults,FS(Lt.defaults),Lt};Lt.getDefaults=vv;Lt.defaults=ei;Lt.use=function(...e){return Ha.use(...e),Lt.defaults=Ha.defaults,FS(Lt.defaults),Lt};Lt.walkTokens=function(e,n){return Ha.walkTokens(e,n)};Lt.parseInline=Ha.parseInline;Lt.Parser=Us;Lt.parser=Us.parse;Lt.Renderer=Pf;Lt.TextRenderer=Sv;Lt.Lexer=Fs;Lt.lexer=Fs.lex;Lt.Tokenizer=Mf;Lt.Hooks=Oc;Lt.parse=Lt;Lt.options;Lt.setOptions;Lt.use;Lt.walkTokens;Lt.parseInline;Us.parse;Fs.lex;let yc;const MM=e=>(yc||(xf.addHook("uponSanitizeElement",(n,s)=>{yc??(yc=s.allowedTags)}),xf.sanitize("<b></b>"),xf.removeHook("uponSanitizeElement")),(yc==null?void 0:yc[e.toLowerCase()])===!0),PM=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");Lt.use({breaks:!0,renderer:{html:({text:e,block:n})=>{let s=0;const r=e.replace(/<\/?([A-Za-z][\w:-]*)[^<>]*>/g,(o,i)=>MM(i)?(s++,o):PM(o));return n&&!s&&r!==e?`<p>${r.trim().replace(/\n/g,`<br>
|
|
579
|
+
`)}</p>
|
|
580
|
+
`:r}}});const na=e=>e.slice(-8),md=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 Ba(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const JS=e=>e.basis==="estimate",to=e=>e>0&&e<1e-4?"<$0.0001":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,Lf=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")}`},Sl=e=>e&&e.usd===null&&typeof e.so_far_usd=="number"&&typeof e.unpriced=="number"?e:void 0,hk=(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.`,LM=new Set(["completed","failed","cancelled"]),Ga=e=>typeof e=="string"&&LM.has(e),IM="$0 · free model",XS=e=>e.usd===0&&e.free===!0,ZS=e=>e.upper_bound===!0?"at most ":"",zM=(e,{ended:n=!1}={})=>e.usd!==null?`${ZS(e)}${to(e.usd)}`:typeof e.so_far_usd=="number"?n?`${Lf(e.so_far_usd)} known, ${e.unpriced??0} not priced`:`so far ${Lf(e.so_far_usd)}, ${e.unpriced??0} not priced`:"not priced";function no(e,{ended:n=!1}={}){const s=hd(e);if(s&&(e==null?void 0:e.usd)===0)return`${e2(s.tokens)} tokens · Using ChatGPT plan`;const r=DM(e,n);return s?`${r} + ChatGPT plan`:r}function DM(e,n){const s=Sl(e),r=o=>JS(o)?" est.":"";return s?n?`${Lf(s.so_far_usd)}${r(s)} known · ${s.unpriced} not priced`:`so far ${Lf(s.so_far_usd)}${r(s)} · ${s.unpriced} not priced`:!e||e.usd===null?"Unknown":XS(e)?IM:`${ZS(e)}${to(e.usd)}${r(e)}`}const hd=e=>e!=null&&e.plan&&e.plan.requests>0?e.plan:void 0;function e2(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 pk(e,n,{ended:s=!1,text:r}={}){const o=r??no(e,{ended:s});return typeof n!="number"?o:(r!==void 0?FM.test(r):!Sl(e)&&!hd(e)&&!!e&&e.usd!==null&&!XS(e))?`${o} of ${gk(n)}`:`${o} · cap ${gk(n)}`}const FM=/^<?\$[\d.,]+( est\.)?$/;function gk(e){for(let n=2;n<8;n++)if(Number(e.toFixed(n))===e)return`$${e.toFixed(n)}`;return`$${e.toFixed(8)}`}function UM(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 so(e,n){const s=xf.sanitize(Lt.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 o=r.getAttribute("href").trim();if(/^(https?|ftps?):/i.test(o)){r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer");continue}if(/^[a-z][a-z\d+.-]*:/i.test(o))continue;const i=n&&UM(o,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 Cv=e=>n=>{var r,o,i;const s=(i=(o=(r=n.target).closest)==null?void 0:o.call(r,"[data-run-file]"))==null?void 0:i.getAttribute("data-run-file");s&&(n.preventDefault(),e(s))},WM=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 Cn(e){const{title:n}=e;if(!e.trigger)return n;let s=n.search(/<trigger-payload\b/);if(s<0){const o=/<([a-z-]*)…$/.exec(n);if(!o||!"trigger-payload".startsWith(o[1]))return n;s=o.index}return n.slice(0,s).trim()||WM(n.slice(s))}function HM(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,o)=>r.seq-o.seq)}const t2=e=>(e.kind==="tool_use"?e.tool_input_preview:e.kind==="tool_result"?e.tool_result_preview:e.text)??null,n2=e=>e.refused===!0,s2=e=>e.tool_status==="failed"&&!n2(e)||e.kind==="error",BM=e=>e.paused===!0;function GM(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))),o=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")&&o(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]}
|
|
581
|
+
|
|
582
|
+
→ ${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 ze extends Error{constructor(s,r,o,i=!1,c){super(o);At(this,"fields");At(this,"retryAfterMs");At(this,"details");At(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 Wt=e=>e instanceof ze?`${e.code}: ${e.message}`:e instanceof Error?e.message:String(e),xk=(e,n,{status:s,archived:r}={})=>{const o=new URLSearchParams({limit:String(e)});return n&&o.set("cursor",n),s&&o.set("status",s),r&&o.set("archived","true"),`?${o}`},qM=new Set(["/auth/sign-in","/setup"]);function KM({fetch:e=globalThis.fetch.bind(globalThis),base:n="/v2",onSignedOut:s}={}){async function r(v,y,j={}){return(await o(v,y,j)).body}async function o(v,y,{body:j,headers:k={},signal:E,text:S=!1}={}){var M;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&&!qM.has(y)&&(s==null||s());const O=(M=await $.json().catch(()=>null))==null?void 0:M.error,L=new ze($.status,(O==null?void 0:O.code)??"http_error",(O==null?void 0:O.message)??`${v} ${y}: ${$.status}`,(O==null?void 0:O.retryable)??!1,O==null?void 0:O.request_id);throw O!=null&&O.fields&&(L.fields=O.fields),typeof(O==null?void 0:O.retry_after_ms)=="number"&&(L.retryAfterMs=O.retry_after_ms),O!=null&&O.details&&typeof O.details=="object"&&!Array.isArray(O.details)&&(L.details=O.details),Array.isArray(O==null?void 0:O.problems)&&(L.problems=O.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:()=>o("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 ze&&(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${xk(v,y,j)}`),listAgentRuns:(v,y=50,j,k={})=>r("GET",`${i(v)}/runs${xk(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 o("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 o("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 o("GET",b(v,y),{headers:h,text:!0})),writeNote:async(v,y,j,k)=>x(await o("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 o("POST",`${b(v,y)}/retire`,{body:{},headers:{...h,"if-match":j},text:!0})),approveNote:async(v,y,j)=>x(await o("POST",`${b(v,y)}/approve`,{body:{},headers:{...h,"if-match":j},text:!0})),restoreNote:async(v,y,j)=>x(await o("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 o("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 Vr(e,n,s=100){const r=[];let o=null;for(let i=0;i<s;i++){const c=await e(o);if(r.push(...n(c)),!c.next_cursor)break;o=c.next_cursor}return r}async function r2(e,n,{onRows:s,onPage:r,signal:o,waitMs:i=25e3,minDelayMs:c=250}){let d=[],u,f;for(;!(o!=null&&o.aborted);){const g=await e.getTimeline(n,u===void 0?{signal:o}:{after:u,waitMs:i,signal:o}).catch(x=>{if(o!=null&&o.aborted)return null;throw x});if(!g||o!=null&&o.aborted||(f=g,s&&(d=HM(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 vk=e=>`#/observations/${encodeURIComponent(e)}`,If=e=>e==="claude"?"Claude Code":e==="codex"?"Codex":e;function Ea(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 Jg=e=>{const n=Ea(e);return n==="Running"?"success":["Needs input","Disconnected","Failed"].includes(n)?"warning":"muted"},$a=e=>e==null?"—":e.toLocaleString("en-US");function Ev(e,{active:n=!0,days:s=30,sessionId:r}={}){const[o,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 ze&&_.status===404?(i(null),d(null)):d(Wt(_)))}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:o,error:c,loading:g,refresh:()=>f(x=>x+1)}}function $v({read:e,view:n="table",query:s="",days:r=30}){const{data:o,error:i,refresh:c}=e,d=o==null?void 0:o.connectors.some(f=>f.storage_full);if(!(o!=null&&o.sessions.length)&&!i&&!d)return null;const u=((o==null?void 0:o.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(Kx,{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(Jo,{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"&&o&&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=>Ea(f)==="Running").length],["Needs input",u.filter(f=>Ea(f)==="Needs input").length],["Disconnected",u.filter(f=>Ea(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"]}),o.usage.status==="unavailable"?t.jsx("p",{className:"text-small text-muted-foreground",children:o.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(o2,{usage:o.usage}),t.jsx(VM,{models:o.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:vk(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(fr,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(ke,{children:If(f.harness)}),t.jsx(ke,{tone:Jg(f),children:Ea(f)}),t.jsx(ke,{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(ke,{tone:Jg(f),children:Ea(f)})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("a",{href:vk(f.id),className:"inline-flex items-center gap-1 underline underline-offset-2",children:[f.display_name,t.jsx(fr,{className:"size-3 shrink-0","aria-hidden":!0})]})}),t.jsx("td",{className:"whitespace-nowrap px-4 py-3",children:If(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"?"—":$a(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 o2({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",$a(e.input_tokens)],["Output",$a(e.output_tokens)],["Cache writes",$a(e.cache_write_tokens)],["Cache reads",$a(e.cache_read_tokens)],["Total tokens",$a(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 VM({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:$a(s)},r))]},n.model))})]})}):null}function YM({v2:e,sessionId:n,go:s}){var i;const r=Ev(e,{sessionId:n}),o=(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(An,{"aria-hidden":!0})}),t.jsx(Kx,{className:"size-4","aria-hidden":!0}),t.jsx("strong",{className:"min-w-0 flex-1 truncate text-body",children:(o==null?void 0:o.display_name)??"Observed session"}),t.jsx(B,{size:"icon","aria-label":"Refresh session",disabled:r.loading,onClick:r.refresh,children:t.jsx(Jo,{"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]}),o?t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold",children:o.display_name}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[t.jsx(ke,{tone:"muted",children:"Observed"}),t.jsx(ke,{tone:Jg(o),children:Ea(o)}),t.jsx(ke,{children:If(o.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",If(o.harness)],["Model",o.models.join(", ")||"Not reported"],["Connection",o.connection_state],["Last reported activity",o.reported_activity],["First seen",ht(o.created_at)],["Last received",ht(o.received_at)],["Session",o.id],["Connector",o.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(o2,{usage:o.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 _v(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 Qt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),QM=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),Xg=128,JM=e=>{try{return JSON.stringify(e)??"null"}catch{return JSON.stringify(`[${typeof e}:${String(e)}]`)}},Zg=(e,n=0)=>n>Xg?'"…"':Array.isArray(e)?`[${e.map(s=>Zg(s,n+1)).join(",")}]`:Qt(e)?`{${Object.keys(e).filter(s=>e[s]!==void 0).sort().map(s=>`${JSON.stringify(s)}:${Zg(e[s],n+1)}`).join(",")}}`:JM(e),XM=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")},bc=(e,n)=>Object.fromEntries(Object.entries(e).filter(([s])=>s!==n)),ZM=e=>{switch(e.node){case"chain":return bc(e,"steps");case"parallel":return bc(e,"branches");case"map":case"loop":return bc(e,"body");case"route":return Qt(e.branches)?{...e,branches:Object.fromEntries(Object.entries(e.branches).map(([n,s])=>[n,Qt(s)?bc(s,"body"):s]))}:e;case"workflow":return Qt(e.workflow)?{...e,workflow:bc(e.workflow,"root")}:e;default:return e}};function cl(e){const n=[],s=[],r=(o,i,c,d)=>{if(!Qt(o)||typeof o.node!="string"||c>Xg)return;n.push({path:i,kind:o.node,label:typeof o.label=="string"?o.label:o.node,...o.node==="call"&&typeof o.via=="string"?{via:o.via}:{},changeCheck:XM(Zg(ZM(o))),...tP(o,d)});const u=(f,g,b,x=i,h=d)=>{!Qt(f)||typeof f.node!="string"||c+1>Xg||(s.push({from:x,to:g,kind:b}),r(f,g,c+1,h))};switch(o.node){case"chain":Array.isArray(o.steps)&&o.steps.forEach((f,g)=>u(f,`${i}/steps/${g}`,"next",g===0?i:`${i}/steps/${g-1}`));break;case"parallel":Array.isArray(o.branches)&&o.branches.forEach((f,g)=>u(f,`${i}/branches/${g}`,"branch"));break;case"map":u(o.body,`${i}/body`,"item");break;case"loop":u(o.body,`${i}/body`,"next");break;case"route":if(Qt(o.branches))for(const[f,g]of Object.entries(o.branches))Qt(g)&&u(g.body,`${i}/branches/${QM(f)}/body`,"route");break;case"workflow":Qt(o.workflow)&&u(o.workflow.root,`${i}/workflow/root`,"child",i,Qt(o.workflow.schemas)?o.workflow.schemas:{});break}};return r(Qt(e)?e.root:void 0,"/root",0,Qt(e)&&Qt(e.schemas)?e.schemas:{}),{nodes:n,edges:s}}const eP=(e,n)=>{const s=typeof e=="string"&&Object.hasOwn(n,e)?n[e]:void 0,r=i=>{var c;for(let d=0;Qt(i)&&typeof i.$ref=="string"&&d<8;d+=1){const u=(c=/^#\/definitions\/(.+)$/.exec(i.$ref))==null?void 0:c[1],f=Qt(s)&&Qt(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},o=r(s);return!Qt(o)||!Qt(o.properties)?[]:Object.entries(o.properties).map(([i,c])=>{const d=r(c),u=Qt(d)&&typeof d.description=="string"?d.description:"",f=Qt(d)?(Array.isArray(d.type)?d.type:[d.type]).filter(g=>g!=="null"):[];return Qt(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}})},tP=(e,n)=>{let s=e,r;const o=i=>typeof i=="string"?i:"";switch(e.node){case"judge":case"sift":r=eP(e.out,n);break;case"pick":r=[{id:"pick",type:"choice",instructions:o(e.instructions)}];break;case"route":if(e.valuePath!==void 0)return{};r=[{id:"branch",type:"choice",instructions:o(e.instructions),options:Qt(e.branches)?Object.keys(e.branches):[]}];break;case"loop":case"escalate":{const i=e.node==="loop"?e.until:e.when;if(!Qt(i)||i.predicate!=="ask")return{};s=i,r=[{id:"holds",type:"noul",instructions:o(i.instructions)}];break}default:return{}}return{...typeof s.provider=="string"?{provider:s.provider}:{},...typeof s.model=="string"?{model:s.model}:{},questions:r,...Qt(s.images)&&Object.keys(s.images).length?{images:Object.keys(s.images)}:{}}};function a2(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},[o,i]=[r(e),r(n)],c=S=>o.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[_,M]=[N.get(S.from),N.get(S.to)];return _!==void 0&&M!==void 0&&$.has(y(_,M,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 gn({className:e}){return t.jsx("span",{"aria-hidden":!0,className:ie("block bg-muted motion-safe:animate-pulse",e)})}function Lm({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 nP(){return t.jsxs(Lm,{label:"Loading Mission Control",className:"space-y-8 p-5 md:p-8",children:[t.jsx(gn,{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(gn,{className:"h-3 w-16"}),t.jsx(gn,{className:"mt-3 h-6 w-12"})]},n))}),t.jsx(gn,{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(zf,{n:4}),t.jsx(zf,{n:6})]})]})}function zf({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(gn,{className:"h-4 w-20"}),t.jsx(gn,{className:"h-4 flex-1"}),t.jsx(gn,{className:"hidden h-4 w-24 sm:block"})]},s))})}function Un({label:e,rows:n=8}){return t.jsx(Lm,{label:e,children:t.jsx(zf,{n})})}function sP(){return t.jsxs(Lm,{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(gn,{className:"h-4 w-24"}),t.jsx(gn,{className:"h-7 w-2/3"}),t.jsx(gn,{className:"h-3 w-1/3"})]}),t.jsx("div",{className:"flex gap-6",children:Array.from({length:3},(e,n)=>t.jsx(gn,{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(gn,{className:"size-4 shrink-0"}),t.jsx(gn,{className:ie("h-4",n%2?"w-1/2":"w-3/4")})]},n))})]})}function rP(){return t.jsxs(Lm,{label:"Loading the agent",className:"space-y-6 p-5 md:p-8",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(gn,{className:"h-7 w-64"}),t.jsx(gn,{className:"h-3 w-80 max-w-full"})]}),t.jsx(gn,{className:"h-12 w-full"}),t.jsx(zf,{n:5})]})}function Jt({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 i2({what:e,id:n,list:s}){return t.jsx(Jt,{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 ex extends Error{constructor(){super("Can't reach agentrun-serve. Try again once it's back."),this.name="Unreachable"}}const tx=e=>Math.min(1e4,1e3*2**e),yk=e=>e.status>=500&&!(e.headers.get("content-type")??"").includes("json"),oP=e=>(e==null?void 0:e.name)==="AbortError",bk=e=>e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError");function aP({fetch:e=(o,i)=>globalThis.fetch(o,i),probe:n="/v2/health",resumedMs:s=5e3,probeMs:r=5e3}={}){let o={state:"online"};const i=new Set,c=new Set;let d=[],u,f=null,g=null;const b=N=>{o=N;for(const $ of[...i])$()},x=N=>{const $=tx(N);clearTimeout(u),b({state:"offline",attempt:N,retryAt:Date.now()+$}),u=setTimeout(()=>void j(),$)},h=()=>{o.state!=="offline"&&x(0)},v=()=>{if(o.state!=="offline")return;clearTimeout(u),b({state:"resumed"});const N=d;d=[];for(const $ of N)$();for(const $ of[...c])$();u=setTimeout(()=>{o.state==="resumed"&&b({state:"online"})},s)};async function y(N){const $=setTimeout(()=>N.abort(),r);try{return!yk(await e(n,{method:"GET",cache:"no-store",credentials:"same-origin",signal:N.signal}))}catch{return!1}finally{clearTimeout($)}}async function j(){if(o.state!=="offline")return;clearTimeout(u),f==null||f.abort();const N=f=new AbortController,$=await y(N);f===N&&(f=null,o.state==="offline"&&($?v():x(o.attempt+1)))}const k=()=>g??(g=y(new AbortController).finally(()=>{g=null})),E=N=>new Promise(($,_)=>{if(N!=null&&N.aborted)return _(bk(N));const M=()=>{d=d.filter(L=>L!==O),_(bk(N))},O=()=>{N==null||N.removeEventListener("abort",M),$()};d.push(O),N==null||N.addEventListener("abort",M,{once:!0})});return{fetch:async(N,$)=>{var O;const _=(($==null?void 0:$.method)??"GET").toUpperCase(),M=_==="GET"||_==="HEAD";for(let L=0;;L++){let R,A;try{R=await e(N,$)}catch(P){if((O=$==null?void 0:$.signal)!=null&&O.aborted||oP(P))throw P;A=P}if(R&&!yk(R))return v(),R;if(o.state!=="offline"&&await k()){if(R)return R;if(!M)throw new ex;if(L>=2)throw A;await new Promise(P=>setTimeout(P,tx(L)));continue}if(h(),!M)throw new ex;await E($==null?void 0:$.signal)}},link:()=>o,subscribe:N=>(i.add(N),()=>{i.delete(N)}),onResume:N=>(c.add(N),()=>{c.delete(N)}),retryNow:()=>void j()}}const iP=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),l2=e=>e instanceof ex||e instanceof TypeError&&/fetch|network/i.test(e.message);function Ht(e,n){const s=`${iP(n)} could not be read.`;if(l2(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: the console reconnects by itself."};if(!(e instanceof ze))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,o=[e.code,e.requestId].filter(Boolean).join(" · "),i=(c,d)=>({title:s,why:c,next:d,said:r,code:o});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 lP(e){return l2(e)?"Can't reach agentrun-serve":e instanceof ze?e.status>=500?"The server hit a problem":"The server refused this":"Something went wrong in the console"}function cP({agent:e,v2:n}){const[s,r]=p.useState(null),[o,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(Ht(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(Jt,{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(Jt,{problem:c,className:"m-4"}),o&&t.jsx("div",{className:"flex justify-center p-4",children:t.jsx(B,{size:"sm",disabled:u,onClick:()=>void v(o),children:u?"Loading":"Load more versions"})})]}):t.jsx(Un,{label:"Loading versions",rows:4})}const c2=(e,n)=>e.name.localeCompare(n.name,void 0,{sensitivity:"base",numeric:!0})||(e.id<n.id?-1:e.id>n.id?1:0),Cl=e=>[...e].sort((n,s)=>c2({name:n.definition.name||n.agent_id,id:n.agent_id},{name:s.definition.name||s.agent_id,id:s.agent_id}));function dP(e){return e.usd===null?{total:"Unknown"}:{total:no({usd:e.usd,basis:"estimate",charge_state:null,cap_usd:null}),...e.unknownRuns?{note:`${e.unknownRuns} ${e.unknownRuns===1?"run":"runs"} unknown`}:{}}}const Tv=[{id:"7d",label:"7 days",days:7},{id:"30d",label:"30 days",days:30},{id:"all",label:"All",days:null}],Qi=864e5,nx=e=>Math.floor(e/Qi)*Qi;function Rv(e,n=Date.now()){var r;const s=(r=Tv.find(o=>o.id===e))==null?void 0:r.days;return s?new Date(nx(n)-(s-1)*Qi).toISOString():void 0}const d2=e=>e.completed+e.failed?(e.completed-e.needs_review)/(e.completed+e.failed):null;function uP(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 fP(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 u2=(e,n)=>dP({usd:e.cost_usd,unknownRuns:e.unknown_cost_runs}),Av=e=>e.runs_with_metrics<e.runs?`tokens from ${e.runs_with_metrics} of ${e.runs} runs`:void 0;function qa(e){return e===null?"Unknown":e2(e)}const Df=e=>e===null?"—":`${Math.round(e*100)}%`;function wk(e){return e>=36e5?`${(e/36e5).toFixed(1).replace(/\.0$/,"")} h`:e>=6e4?`${Math.round(e/6e4)} min`:`${Math.round(e/1e3)} s`}function mP(e,n,s=Date.now()){if(!e.length)return[];const r=nx(s),o=Math.max(r-29*Qi,n?nx(Date.parse(n)):r-29*Qi),i=new Map(e.map(d=>[d.day,d])),c=[];for(let d=o;d<=r;d+=Qi){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 hP(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)=>c2({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 f2({range:e,onRange:n,agent:s,agents:r,onAgent:o}){return t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(dd,{label:"Range",name:"mission-range",value:e,onChange:n,size:"sm",options:Tv.map(i=>({value:i.id,label:i.label}))}),o&&r.length>0&&t.jsx(Et,{label:"Agent",value:s??"",onChange:i=>o(i||null),className:"h-control-sm w-56",options:[{value:"",label:"All agents"},...r.map(i=>({value:i.agentId,label:i.name}))]})]})}const vf=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function m2({a:e,basis:n,now:s=Date.now(),refreshing:r=!1}){const o=e.totals,i=fP(o),c=d2(o),d=u2(o),u=[{label:"Tokens",value:qa(o.tokens),notes:[`${i===null?"":`${Df(i)} of input cached · `}${qa(o.output)} output`,Av(o),o.requests===null||o.unmetered===null?"Model request counts unavailable":o.unmetered?`${vf(o.unmetered,"request")} with no token count`:void 0]},{label:"Run time",value:wk(e.time.wall_ms),notes:[`wall time of ${vf(e.time.ended_runs,"ended run")}`,e.time.active_runs?`${wk(e.time.active_ms)} active, over ${vf(e.time.active_runs,"run")}`:void 0]},{label:"Success rate",value:Df(c),notes:[o.completed+o.failed?uP(o):"No run completed or failed yet"]},{label:"Cost",value:d.total,notes:[d.note]}];return t.jsxs("div",{className:ie("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(vP,{days:mP(e.by_day,e.filter.from,s)}),t.jsxs("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2",children:[t.jsx(pP,{rows:e.by_harness_effort,basis:n}),t.jsx(gP,{tools:e.tools})]}),t.jsx(xP,{groups:e.by_source})]})}function Wi({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 h2="px-4 py-2 text-left font-normal",Nr="px-4 py-2.5 align-top";function pP({rows:e,basis:n}){return t.jsx(Wi,{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:h2,children:s},s))})}),t.jsx("tbody",{children:e.map(s=>{const r=u2(s),o=Av(s);return t.jsxs("tr",{className:"border-b font-mono last:border-b-0",children:[t.jsx("td",{className:Nr,children:s.harness}),t.jsx("td",{className:ie(Nr,!s.effort&&"text-muted-foreground"),children:s.effort??"unset"}),t.jsx("td",{className:Nr,children:s.runs}),t.jsx("td",{className:Nr,children:Df(d2(s))}),t.jsxs("td",{className:Nr,children:[t.jsx("span",{className:"whitespace-nowrap",children:qa(s.tokens)}),o&&t.jsx("span",{className:"block text-label text-muted-foreground",children:o})]}),t.jsxs("td",{className:Nr,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 gP({tools:e}){return t.jsx(Wi,{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:h2,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:Nr,title:n.tool,children:n.label}),t.jsx("td",{className:Nr,children:qa(n.calls)}),t.jsx("td",{className:ie(Nr,n.errors>0&&"text-destructive-text"),children:qa(n.errors)}),t.jsx("td",{className:Nr,children:Df(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 xP({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}`}: ${vf(n.runs,"run")}`).join(" · ")}):null}const dg=e=>Math.max(0,e.runs-e.completed-e.failed);function jk(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 ug=e=>e.slice(5);function vP({days:e}){const n=e.some(d=>d.runs>0),s=t.jsxs(t.Fragment,{children:[t.jsx(wT,{className:"size-4","aria-hidden":!0}),"Run activity"]}),r=t.jsxs(t.Fragment,{children:[t.jsx($T,{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(Wi,{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(Wi,{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 o=jk(Math.max(...e.map(d=>d.runs))),i=jk(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:dg}];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(Wi,{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:ie("inline-block size-2.5 ",d.className),"aria-hidden":!0}),d.label]},d.key))]}),t.jsx(kk,{days:e,top:o,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 · ${dg(d)} other`]})]})}),t.jsx(Wi,{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(kk,{days:e,top:i,label:"Tokens per day",format:qa,stack:d=>[{className:"bg-primary",value:d.tokens}],readout:d=>[`${qa(d.tokens)} tokens`,Av(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:dg(d)}),t.jsx("td",{className:"pr-4",children:d.tokens===null?"Unknown":d.tokens.toLocaleString("en-US")})]},d.day))})]})})]})]})}function kk({days:e,top:n,label:s,stack:r,readout:o,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}: ${o(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:ug(e[0].day)}),e.length>2&&t.jsx("span",{children:ug(e[Math.floor(e.length/2)].day)}),t.jsx("span",{children:ug(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:o(y)[0]}),o(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 ln=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),yf=e=>e.replace(/~/g,"~0").replace(/\//g,"~1");function yP(e){const n=new Map;let s=0;const r=d=>{throw Object.assign(new Error(d),{offset:s})},o=()=>{for(;s<e.length&&`
|
|
583
|
+
\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=>{o();const u=s;let f;const g=e[s];if(g==="{"){s++;const b={};if(o(),e[s]==="}")s++;else for(;;){o(),e[s]!=='"'&&r(e[s]==="}"?"a trailing comma before }":"expected a key in double quotes");const x=i();if(o(),e[s]!==":"&&r("expected : after the key"),s++,b[x]=c(`${d}/${yf(x)}`),o(),e[s]===","){s++;continue}if(e[s]==="}"){s++;break}r("expected , or } after the value")}f=b}else if(g==="["){s++;const b=[];if(o(),e[s]==="]")s++;else for(;;){if(b.push(c(`${d}/${b.length}`)),o(),e[s]===","){s++,o(),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 o(),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 bP(e,n){let s=1,r=-1;for(let o=0;o<Math.min(n,e.length);o++)e[o]===`
|
|
584
|
+
`&&(s++,r=o);return{line:s,col:n-r}}function p2(e,n){let s=e;for(const r of n.split("/").slice(1)){const o=r.replace(/~1/g,"/").replace(/~0/g,"~");if(Array.isArray(s))s=s[Number(o)];else if(ln(s))s=Object.prototype.hasOwnProperty.call(s,o)?s[o]:void 0;else return}return s}const g2=new Set(["judge","pick","sift","route"]),Nk=["jev","parallel","openrouter"];function wP(e){return!ln(e)||!ln(e.properties)?[]:Object.entries(e.properties).flatMap(([n,s])=>{if(!ln(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 Ov(e,n,s){const r=p2(e,n);if(!ln(r))return{decision:!1};const o=r.node,i=s??{},c=o==="route"&&typeof r.valuePath=="string",d=typeof o=="string"&&g2.has(o)&&!c||Array.isArray(i.questions);if(!d)return{decision:!1,...o==="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=ln(e)&&ln(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}:{}})):o==="judge"||o==="sift"?b=typeof r.out=="string"?wP(g[r.out]):[]:o==="pick"?b=[{id:"pick",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Pick one"}]:o==="route"&&(b=[{id:"branch",type:"choice",text:typeof r.instructions=="string"?r.instructions:"Which branch?",options:ln(r.branches)?Object.keys(r.branches):[]}]);const x=Array.isArray(i.images)?i.images.map(String):ln(r.images)?Object.keys(r.images):[],h=ln(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 jP=new Set(["chain","code","agent","decide","extract","report","map","parallel","loop","escalate","judge","pick","sift","route","workflow","artifact","call"]);function kP(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(!ln(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 o=ln(e.schemas)?e.schemas:{};ln(e.input)&&typeof e.input.schemaId=="string"&&!o[e.input.schemaId]&&s("/input/schemaId",`no schema "${e.input.schemaId}" in schemas`),ln(e.output)?typeof e.output.schemaId=="string"&&!o[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(!ln(d)){s(u,'expected a node (an object with a "node" kind)');return}const f=d.node;if(typeof f!="string"||!jP.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"&&!o[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":ln(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(!ln(d.branches)||!Object.keys(d.branches).length)s(u,"a route needs branches");else for(const[x,h]of Object.entries(d.branches))ln(h)?c(h.body,`${u}/branches/${yf(x)}/body`):s(`${u}/branches/${yf(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"),ln(d.unsure)&&ln(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(g2.has(f)&&!(f==="route"&&typeof d.valuePath=="string")&&(d.provider!==void 0&&!Nk.includes(d.provider)&&r(`${u}/provider`,`provider "${String(d.provider)}" is not one of ${Nk.join(", ")}`),d.provider==="openrouter"&&typeof d.model!="string"&&s(u,"an openrouter decision names its model (e.g. perplexity/pplx-decider-v1.2)"),ln(d.images))){const x=JSON.stringify(d.state??{})+JSON.stringify(d.instructions??"")+(typeof d.out=="string"?JSON.stringify(o[d.out]??{}):"");for(const h of Object.keys(d.images))x.includes(h)||s(`${u}/images/${yf(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 Sk(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 NP(e,n,s){let r=null,o=1/0;for(const i of n){const c=e.get(i);c&&c.start<=s&&s<=c.end&&c.end-c.start<o&&(r=i,o=c.end-c.start)}return r}function SP(e){const n=cl(e),r=n.nodes.map(i=>Ov(e,i.path,i)).filter(i=>i.decision),o=[...new Set(r.map(i=>i.provider??"jev"))];return`${n.nodes.length} nodes · ${r.length} ${r.length===1?"decision":"decisions"}${o.length?` · ${o.join(", ")}`:""}`}const Ff=e=>e==="not_run"?"not-run":e==="needs_review"?"review":e,Ck=e=>e.replace(/~/g,"~0").replace(/\//g,"~1"),pd=e=>["completed","failed","cancelled","stopped","escalated"].includes(e);function gd(e,n){return Object.fromEntries(n.nodes.map(s=>[s.path,Ov(e,s.path,s)]))}const Vu=e=>e>=.995?"1.00":e.toFixed(2);function dl(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?` ${Vu(f)}`:""}`}const r=Object.keys(n);if(!r.length)return;const o=u=>{const f=n[u];return f.type==="choice"?`${x2(e,u,f.choice)} ${Vu(f.probabilities[f.choice]??f.confidence)}`:f.type==="noul"?`${f.noul>=.5?"yes":"no"} ${Vu(f.noul>=.5?f.noul:1-f.noul)}`:f.type==="score"?`${f.score} ${Vu(f.confidence)}`:f.type==="refusal"?"refused":"box"};if(r.length===1)return o(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} ${o(c)}`}function x2(e,n,s){var i,c;const r=(i=e.questions)==null?void 0:i[n],o=e.kind==="pick"&&(r==null?void 0:r.type)==="choice"?(c=r.criteria)==null?void 0:c[s]:null;return typeof o=="string"&&o?o:s}const v2=(e,n)=>e.nodes.filter(s=>s.path.startsWith(`${n}/body`)).map(s=>s.path);function CP(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),o={};if(!r)return o;const i=new Set(["chain","parallel","route","map","loop","workflow"]),c=new Map(e.graph.nodes.map(h=>[h.path,h.kind])),d=v2(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")?o[h]="failed":y.some(k=>k.status==="cancelled")?o[h]="review":j.some(k=>!k.endedAt)?o[h]=j.some(k=>k.status==="stopped")?"stopped":"working":o[h]="done")});const f=Ff(r.status)??"pending";let g=!Object.values(o).includes("working");return d.forEach((h,v)=>{o[h]||(v<u||f==="done"?o[h]="done":f==="working"?(o[h]=g?"working":"pending",g=!1):f==="pending"?o[h]="pending":o[h]="not-run")}),o}function EP(e,n){var g,b,x;const s={},r=[],o={};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=Ff(v.status);y&&(s[h]=y),v.branch&&r.push(`${h}/branches/${Ck(v.branch)}/body`),v.items&&(o[h]=v.items.map(j=>({index:j.index,status:Ff(j.status)??"pending",label:Bc(e,h,j.index),...Mv(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=dl(h);v&&(d[h.node]=v)}if(n&&n.item!=null&&c.get(n.path)==="map"){Object.assign(s,CP(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}${Ck(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=dl(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(o))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:o,fired:i,verdict:d,meta:gd(e.workflow,e.graph),selected:n,...Object.keys(f).length?{ran:f}:{}}}const fg={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"},$P=e=>{if(!e)return;const n=e.toLowerCase();return fg[n]??fg[n.split(/[_\s-]/)[0]]??fg[n.split(/[_\s-]/).at(-1)??""]};function _P(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[o,i]of Object.entries(e.answers)){const c=i.type==="noul"?{p:Math.max(i.noul,1-i.noul),note:`${o}: ${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:`${o} 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 Mv(e,n,s){const r=v2(e.graph,n),o=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)=>o(x.node)-o(h.node));let c,d;const u=Object.entries(s.branches??{}).sort(([x],[h])=>o(x)-o(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?_P(f):void 0,b=s.status==="failed"?"bad":s.status==="needs_review"||s.status==="escalated"?"warn":$P(c);return{...c?{outcome:c}:{},...g?{p:g.p,pNote:g.note}:{},...b?{tone:b}:{}}}function Bc(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 o=e.effects.find(f=>{var g;return f.item===s&&!!((g=f.node)!=null&&g.startsWith(`${n}/body`))}),i=o==null?void 0:o.input,c=(i==null?void 0:i.path)??(i==null?void 0:i.url);return typeof c=="string"?c:void 0}function y2(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 b2(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 El=e=>e==null?"Unknown":e>0&&e<1e-4?"<$0.0001":e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,Ji=e=>e==null?"—":e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(e<1e4?2:1)} s`;function ul(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 TP=(e,n,s)=>{const r=e.totals.elapsed_ms??(Date.parse(e.run.endedAt??"")||n)-Date.parse(e.run.startedAt);return pd(e.run.status)||e.run.paused?r:r+Math.max(0,s-n)};function RP(e,n,s){return e!=="input_required"||n!=="waiting"?null:s.findLast(r=>r.kind==="waiting")??null}function AP(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 w2(e){return e.split("/").slice(0,-1).some(n=>n.startsWith(".")||n==="__pycache__"||n==="node_modules")}const j2="The agent finished without writing an answer.",Ek=[0,250,1e3],OP=e=>new Promise(n=>setTimeout(n,e));function k2(){let e=0;return{begin:()=>++e,current:n=>n===e,cancel:()=>{e++}}}const N2="30d",$k=10,MP=["queued","working","input_required","paused"];function PP({agent:e,v2:n,now:s=Date.now,stats:r}){const[o,i]=p.useState(N2),[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=`${o}/${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 Ek.entries()){if(_&&await OP(_),N!==v.current||!y.current)return;try{const M=await n.statsOver({from:Rv(o,s()),agent:e.agent_id});if(N!==v.current||!y.current)return;const O=!(M.runs.status_unknown>0);if(d(M),j.current=O||$===Ek.length-1?S:null,O)break}catch(M){N===v.current&&f(Wt(M));break}}N===v.current&&(k.current=null,b(!1))})()},[n,e.agent_id,o,x]),p.useEffect(()=>{const S=new AbortController,N=$=>({status:$,...e.archived_at?{archived:!0}:{}});return Promise.allSettled(MP.map($=>n.listAgentRuns(e.agent_id,$k,null,N($)))).then($=>{if(S.signal.aborted)return;const _=$.flatMap(M=>M.status==="fulfilled"?M.value.runs:[]).filter(M=>!pd(M.status));for(const M of _.slice(0,$k)){let O=`${M.status}/${M.state}`;r2(n,M.run_id,{signal:S.signal,onPage:L=>{const R=`${L.status}/${L.state}`;R!==O&&(O=R,h(A=>A+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(f2,{range:o,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(m2,{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 Pv=["codex","codex-cli","claude","claude-cli","cursor","other"],S2="agentrun.coding-agent.v1",mg="agentrun:coding-agent",hg={codex:"Codex app","codex-cli":"Codex CLI",claude:"Claude Code app","claude-cli":"Claude Code CLI",cursor:"Cursor",other:"Other / terminal"};function _k(){try{const e=localStorage.getItem(S2);return Pv.includes(e)?e:""}catch{return""}}function LP(e){try{localStorage.setItem(S2,e)}catch{}}function IP(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 zP="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=",DP="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=",FP="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",UP="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 Tk({agent:e}){const n=e==="codex"?zP:e==="claude"?DP:e==="codex-cli"?FP:e==="claude-cli"?UP: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(GT,{className:"size-4 shrink-0","aria-hidden":!0}):t.jsx(Ya,{className:"size-4 shrink-0","aria-hidden":!0})}function WP(){const[e,n]=p.useState(_k);return p.useEffect(()=>{const r=o=>{const i=o instanceof CustomEvent?o.detail:void 0;n(Pv.includes(i)?i:_k())};return window.addEventListener(mg,r),window.addEventListener("storage",r),()=>{window.removeEventListener(mg,r),window.removeEventListener("storage",r)}},[]),{agent:e,choose:r=>{LP(r),n(r),window.dispatchEvent(new CustomEvent(mg,{detail:r}))}}}function sn({label:e,prompt:n,playgroundHref:s,playgroundLabel:r="API playground",disabled:o,compact:i=!1,compactIcon:c,variant:d="outline"}){const{agent:u,choose:f}=WP(),[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),M=p.useRef(0),O=p.useId(),L=IP(u,n),R=u?L?`Open in ${hg[u]}`:`Copy prompt for ${hg[u]}`:"Choose your coding agent",A=()=>{var F;b(!1),(F=E.current)==null||F.focus()},P=async()=>{const F=++M.current;b(!1);try{if(await navigator.clipboard.writeText(n),F!==M.current)return;h(!0),y(!1)}catch{F===M.current&&y(!0)}};p.useEffect(()=>(h(!1),y(!1),()=>{M.current++}),[u,n]),p.useEffect(()=>{if(!x)return;const F=setTimeout(()=>h(!1),2e3);return()=>clearTimeout(F)},[x]),p.useEffect(()=>{o&&b(!1)},[o]),p.useEffect(()=>{if(!g){k(null);return}const F=()=>{var be;const Y=E.current.getBoundingClientRect(),se=Math.min(240,window.innerWidth-16),Q=Math.min(((be=N.current)==null?void 0:be.scrollHeight)||340,window.innerHeight-16),re=window.innerHeight-Y.bottom-12,te=Y.top-12,he=re>=Q||re>=te,ge=Math.max(80,he?re:te);k({width:se,left:Math.max(8,Math.min(Y.right-se,window.innerWidth-se-8)),top:he?Y.bottom+4:Math.max(8,Y.top-Math.min(Q,ge)-4),maxHeight:ge})};F();const D=Y=>{var se,Q;!((se=S.current)!=null&&se.contains(Y.target))&&!((Q=N.current)!=null&&Q.contains(Y.target))&&b(!1)};return document.addEventListener("pointerdown",D),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("pointerdown",D),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[g]);const z=j!==null;p.useEffect(()=>{var F,D,Y;g&&z&&((Y=((F=N.current)==null?void 0:F.querySelector('[aria-checked="true"]'))??((D=N.current)==null?void 0:D.querySelector('[role="menuitemradio"]')))==null||Y.focus())},[g,z]),p.useEffect(()=>{var F,D;v&&((F=$.current)==null||F.focus(),(D=$.current)==null||D.select())},[v]);const U=F=>{var Q;if(F.key==="Escape"){F.preventDefault(),A();return}if(F.key==="Tab"){A();return}if(!["ArrowDown","ArrowUp","Home","End"].includes(F.key))return;F.preventDefault();const D=[...N.current.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')],Y=D.indexOf(document.activeElement),se=F.key==="Home"?0:F.key==="End"?D.length-1:(Y+(F.key==="ArrowDown"?1:-1)+D.length)%D.length;(Q=D[se])==null||Q.focus()},q="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(Tk,{agent:u}),i?t.jsx("span",{className:"sr-only",children:x?"Copied":e}):x?"Copied":e]}),K=i?`${e} · ${R}`:R,W=`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:ie(al({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&&!o?t.jsx("a",{href:L,title:K,"aria-label":i?e:void 0,className:ie(al({variant:"ghost",size:"sm"}),W),children:H}):t.jsx(B,{variant:"ghost",size:"sm",className:W,disabled:o,title:K,"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:o,"aria-label":`Choose coding agent for ${e}`,"aria-haspopup":"menu","aria-expanded":g,"aria-controls":g?O:void 0,onClick:()=>b(F=>!F),onKeyDown:F=>{(F.key==="ArrowDown"||F.key==="ArrowUp")&&(F.preventDefault(),b(!0))},children:t.jsx(Or,{"aria-hidden":!0})}),t.jsx("span",{className:"sr-only",role:"status",children:x?"Prompt copied":""}),g&&Ns.createPortal(t.jsxs("div",{ref:N,id:O,role:"menu","aria-label":"Coding agent",onKeyDown:U,className:`fixed z-popover overflow-y-auto border bg-card p-1 shadow-float${z?"":" invisible"}`,style:j??{width:240},children:[Pv.map(F=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":u===F,tabIndex:-1,className:q,onClick:()=>{f(F),A()},children:[t.jsx(Tk,{agent:F}),hg[F],u===F&&t.jsx(xl,{className:"ml-auto size-3.5","aria-hidden":!0})]},F)),t.jsx("div",{role:"separator",className:"my-1 border-t"}),s&&t.jsxs("a",{role:"menuitem",tabIndex:-1,href:s,className:q,onClick:()=>b(!1),children:[t.jsx(fm,{className:"size-4","aria-hidden":!0}),r]}),t.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,className:q,onClick:()=>{var F;(F=E.current)==null||F.focus(),P()},children:[t.jsx(Ya,{className:"size-4","aria-hidden":!0}),"Copy prompt"]})]}),document.body),v&&Ns.createPortal(t.jsx("div",{className:"fixed inset-0 z-popover grid place-items-center bg-overlay/70 p-4",onClick:F=>{var D;F.target===F.currentTarget&&(y(!1),(D=E.current)==null||D.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:F=>{var D,Y,se;if(F.key==="Escape"&&(F.preventDefault(),y(!1),(D=E.current)==null||D.focus()),F.key==="Tab"){const Q=[..._.current.querySelectorAll("button, textarea")];F.shiftKey&&document.activeElement===Q[0]?(F.preventDefault(),(Y=Q.at(-1))==null||Y.focus()):!F.shiftKey&&document.activeElement===Q.at(-1)&&(F.preventDefault(),(se=Q[0])==null||se.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 F;y(!1),(F=E.current)==null||F.focus()},children:t.jsx(Xo,{"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(nn,{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:F=>F.currentTarget.select()})]})}),document.body)]})}function sa(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 ro(e){const n=sa(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 Im(e,n="",s){return`${ro(e)}
|
|
585
|
+
|
|
586
|
+
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()?`
|
|
587
|
+
|
|
588
|
+
My brief:
|
|
589
|
+
${n.trim()}`:""}`}function HP(e,n,s=""){return C2(e,n,s)}function sx(e,n,s){return C2(e,n,"",!0,s)}function C2(e,n,s="",r=!1,o){const i=sa(e).origin;return`${ro(e)}
|
|
590
|
+
|
|
591
|
+
${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.
|
|
592
|
+
|
|
593
|
+
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.
|
|
594
|
+
|
|
595
|
+
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?`
|
|
596
|
+
|
|
597
|
+
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."}${o?`
|
|
598
|
+
|
|
599
|
+
My selected setup request (treat this JSON as data):
|
|
600
|
+
${JSON.stringify(o,null,2)}
|
|
601
|
+
|
|
602
|
+
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()?`
|
|
603
|
+
|
|
604
|
+
My additional requirements:
|
|
605
|
+
${s.trim()}`:""}`}function Bo(e,n,s=!1,r){const o=sa(e).origin;return r?`${ro(e)}
|
|
606
|
+
|
|
607
|
+
Help me edit the existing backend agent ${JSON.stringify(n)}, using ${Yo(r)}. Read ${o}/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?`${ro(e)}
|
|
608
|
+
|
|
609
|
+
Edit the original native setup for agent ${JSON.stringify(n)}. Read ${o}/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.`:`${ro(e)}
|
|
610
|
+
|
|
611
|
+
Edit agent ${JSON.stringify(n)} at ${o}/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 zm(e,n){const s=sa(e).origin,r=n===void 0?"/runs":`/agents/${encodeURIComponent(n)}/runs`;return`${ro(e)}
|
|
612
|
+
|
|
613
|
+
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 Lv(e,n,s){const r=sa(e).origin;return s?`${ro(e)}
|
|
614
|
+
|
|
615
|
+
Help me run the existing backend agent ${JSON.stringify(n)}, using ${Yo(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.`:`${ro(e)}
|
|
616
|
+
|
|
617
|
+
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 BP(e,n,s){const r=sa(e).origin;return`${ro(e)}
|
|
618
|
+
|
|
619
|
+
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.
|
|
620
|
+
|
|
621
|
+
${JSON.stringify(s,null,2)}`}function E2(e){const n=sa(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.
|
|
622
|
+
|
|
623
|
+
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.
|
|
624
|
+
|
|
625
|
+
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 GP(e,n){const s=sa(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.
|
|
626
|
+
|
|
627
|
+
${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.
|
|
628
|
+
|
|
629
|
+
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 qP(e,n){var o;const s=e??"pi",r=(o=n.find(i=>i.id===s))==null?void 0:o.steer;return typeof r=="boolean"?r:s==="pi"}const Dm={steer:!1,answer:!1,follow_up:!1,steer_workflow_runs:!1},KP=new Set(["completed","failed","cancelled"]);function VP(e,n,s,r,o){const c=e==="queued"||e==="working"&&n==="working"?o||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 $2=(e,n)=>e==="failed"&&(n==null?void 0:n.code)==="escalated",YP=(e,n)=>e==="completed"&&!!n;function Fm(e,n,s,r,o,i,c,d){const u=KP.has(e),f=s==="agentic",g=$2(e,i),b=YP(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=VP(e,n,s,r,o);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 QP={Queued:Bp,Starting:Bp,Working:Bp,Completed:xl,Failed:sl,Escalated:kT,"Needs review":mm,Cancelled:_N,"Input required":Gx,Stopped:rl,Paused:RN};function $l({run:e}){const n=Fm(e.status,e.state,e.kind,Dm,!0,e.error,e.review,e.computer),s=QP[n.label];return t.jsxs(ke,{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 JP=["ready","unavailable"],bf=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),rx=e=>e.mode==="sandbox"?{kind:"sandbox",provider:e.box}:{kind:"none"};function xd(e){if(bf(e)){if(e.mode==="runner")return{mode:"runner"};if(e.mode==="sandbox"&&typeof e.box=="string")return{mode:"sandbox",box:e.box}}}function Rk(e){const n=bf(e)?e.places:void 0;if(!bf(n)||!Array.isArray(n.modes)||!Array.isArray(n.boxes))return null;const s=n.boxes.filter(bf).filter(o=>typeof o.id=="string").map(o=>({id:o.id,available:o.available===!0,...typeof o.reason=="string"?{reason:o.reason}:{},...JP.includes(o.state)?{state:o.state}:{}})),r=xd(n.default_place);return r?{modes:n.modes.filter(o=>typeof o=="string"),boxes:s,defaultPlace:r}:null}const pg=e=>(e==null?void 0:e.defaultPlace.mode)==="sandbox"?e.defaultPlace:void 0,XP=e=>e?e.mode==="sandbox"?`In a ${e.box} box`:"On the server":"Where this server's default place is",ZP=e=>e.mode==="sandbox"?`in a ${e.box} box`:"on the server",eL={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."}]}},tL=["jev","parallel"];function nL(e="jev"){const n=structuredClone(eL);return e!=="jev"&&Object.assign(n.root.steps[0],{provider:e,...e==="parallel"?{timeoutMs:12e4}:{}}),n}const sL={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`."}]}},rL=()=>structuredClone(sL),fl=e=>e===!0||e==="notes"||typeof e=="object"&&e!==null&&!Array.isArray(e);function vd(e,n,s){const{name:r,description:o,...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=xd(g.place),h=g.computer===void 0&&x?rx(x):g.computer;return h!==void 0&&(b.computer=h,delete b.place),b},f=Xi(u(c),u(d));return c.version=f?e.definition.version:e.revisions+1,{definition:c,...s.trim()?{note:s.trim()}:{},unchanged:f}}function Xi(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(o=>e[o]!==void 0),r=Object.keys(n).filter(o=>n[o]!==void 0);return s.length===r.length&&s.every(o=>Xi(e[o],n[o]))}const Iv="decision",_2="workflow",T2={[Iv]:nL,[_2]:rL},R2=e=>e!==void 0&&Object.hasOwn(T2,e);function oL(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?tL.find(o=>n.some(i=>i.id===o&&i.available)):"jev"}const aL="You are a helpful agent. Do the task you're given and report what you found.";function iL(e){var n;return R2(e.harness)?{definition:{version:1,name:e.name,...e.description.trim()?{description:e.description}:{},workflow:T2[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 Ak(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 lL(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:o,blurb:i,missing:c,reason:d,harnesses:u,call_only:f,sandbox_only:g,nodes:b}=n;return[{name:s,available:r!==!1,...typeof o=="string"&&o?{summary:o}:{},...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 Um(e,n){return n.filter(s=>!s.call_only&&s.harnesses.includes(e))}function ox(e,n,s,{mcpHarnesses:r,workflow:o=!1}={}){if(n.startsWith("mcp:"))return!r||r.includes(e);const i=s.find(c=>c.name===n);return i?i.call_only?o:Um(e,s).some(c=>c.name===n):!0}const Uf=e=>O2[e]??e,Ok=e=>e.map(Uf).join(" and ");function Mk(e,n,s,r){var i;if(n.startsWith("mcp:"))return`${Uf(e)} doesn't run MCP tools here${r!=null&&r.length?`: ${Ok(r)} do`:""}`;const o=((i=s.find(c=>c.name===n))==null?void 0:i.harnesses)??[];return o.length?`Runs on ${Ok(o)} here, not on ${Uf(e)}`:"No harness runs it here"}function cL(e,n,s,r,o={}){const i=[...n,...s.filter(c=>!n.includes(c))];return{tools:i.filter(c=>ox(e,c,r,o)),held:i.filter(c=>!ox(e,c,r,o))}}const dL=(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,zv=new Set(["browser"]),Dv=(e,n,s)=>e||n.some(r=>zv.has(r))||!s?{mode:"runner"}:s.defaultPlace;function A2(e,n){const s=xd(e.definition.place);if(s)return{place:s,byDefault:!1};const r=e.kind==="workflow",o=e.definition.tools??[];if(!(!r&&!o.some(i=>zv.has(i))&&!n))return{place:Dv(r,o,n),byDefault:!0}}const gg=(e,n,s)=>Um(e,n).filter(r=>r.available&&((s==null?void 0:s.mode)==="sandbox"?!zv.has(r.name):!r.sandbox_only)).map(r=>r.name),uL=["web_fetch","web_search"],Pk=e=>e.some(n=>uL.includes(n)),O2={pi:"Pi","claude-agent":"Claude",codex:"Codex",opencode:"OpenCode"},fL=["pi","claude-agent","codex","opencode"];function mL(e,n){const s=fL.flatMap(r=>{const o=e.find(i=>i.id===r);return o?[{id:r,label:O2[r],available:o.available,reason:o.reason}]:[]});return n&&(s.push({id:Iv,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:_2,label:"Workflow",available:!0,reason:void 0})),s}function hL(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 Wm(e,n=!1){var s,r,o;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:((o=(r=e.fields)==null?void 0:r[0])==null?void 0:o.message)??e.message,code:e.code}}function pL(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 yd=e=>e==="claude-code"?"Claude Code":e==="codex"?"Codex":e,Fv=e=>e.kind==="project"?"Project default":`${e.kind==="profile"?"Profile":"Named agent"}: ${e.name}`;function Uv(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 Wv(e){const n=e==null?void 0:e.definition.native;return!n||!Uv(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 bd(e){return"connected"in e&&!e.connected?"Disconnected":e.state==="ready"?"Ready to run":e.state==="needs_attention"?"Needs attention":"Needs verification"}const Hv=p.createContext(null),Bv=p.createContext(void 0);function gL(e,n){const s=e==null?void 0:e.definition.native,r=Uv(s),o=`${(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:o,native:j})}catch(j){b&&c({key:o,native:{...s,state:"needs_attention",capabilities:{...s.capabilities,launch:!1},issues:[`Connection status could not be read: ${Wt(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,o,d]),{native:!r||!s?s:(i==null?void 0:i.key)===o?i.native:Wv(e??void 0),refresh:f}}function Gv(){const e=p.useContext(Hv),[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 xL({children:e,native:n}){const s=Gv();return t.jsx(Bv.Provider,{value:n,children:t.jsx(Hv.Provider,{value:s,children:e})})}function M2({agent:e,v2:n,learning:s,onAgent:r}){const o=p.useContext(Bv)??e.definition.native,i=Gv(),c=fl(e.definition.learning),[d,u]=p.useState(!1),[f,g]=p.useState(!1),[b,x]=p.useState(null),h=o.connected&&o.state==="ready"&&o.capabilities.notes&&o.capabilities.skills&&o.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("; ")||bd(N)}. Verify the connection and try again.`)}const{agent:j,etag:k}=await n.getAgent(e.agent_id),{unchanged:E,...S}=vd(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(Wt(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(ud,{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(Om,{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 vL({agent:e,v2:n,learning:s,onAgent:r,onChanged:o}){const i=p.useContext(Bv)??e.definition.native,c=Uv(i),d=Gv(),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 o()}catch(h){g(Wt(h))}finally{d.end()}}};return t.jsx(Hv.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(ke,{tone:i.connected&&i.state==="ready"?"success":"warning",children:bd(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(M2,{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",`${yd(i.runtime)} · ${i.version??"Version unknown"}`],["Project",i.project],["Selector",Fv(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 yL={browserbase:"Browserbase",kernel:"Kernel"},Oi=e=>yL[e]??e,Lk=e=>t.jsx("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"font-mono underline underline-offset-2",children:e.slice(-8)}),bL=5e3,Ik=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function wL({agent:e,v2:n,onAgent:s,poll:r,refresh:o}){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(),bL);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 _,M;u(!0),g(null);try{const L=(await n.forgetSignIn(e.agent_id,$)).removed.filter(A=>A.at_vendor==="not_deleted"),R=L.length?{tone:"warn",text:L.map(A=>`Forgotten here, but ${Oi(A.provider)} didn't confirm the delete. ${A.message??""}`.trim()).join(" ")}:null;if(g(R),c(null),!await o()){const A=b.current;s({...A,sign_ins:(A.sign_ins??[]).filter(P=>P.key!==$)}),g({tone:"warn",text:`${R?`${R.text} `:"Forgotten. "}The agent couldn't be read again.`})}}catch(O){const L=O instanceof ze&&O.code==="sign_in_held"?((_=O.details)==null?void 0:_.held_by)??((M=O.details)==null?void 0:M.handed_to):void 0;g(O instanceof ze&&O.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: ${Wt(O)}`}),c(null)}finally{u(!1)}},E=({key:$,items:_})=>{const M=_.length===1?`Forget the ${Oi(_[0].provider)} sign-in`:`Forget the saved sign-ins for ${Ik(_.map(L=>Oi(L.provider)))}`,O=_.some(L=>L.state==="held");return t.jsx(B,{size:"sm",variant:"ghost",disabled:d||O,"aria-label":M,title:O?"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(Ia,{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:Oi(_.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 ",Lk(_.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 ${Oi($.items[0].provider)} sign-in?`:`Forget the saved sign-ins for ${Ik($.items.map(_=>Oi(_.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: ",Lk(f.run)]})]})]})}const jL=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),kL=e=>e instanceof TypeError&&/fetch|network/i.test(e.message);function Tr(e,n){var c,d;const s=`${jL(n)} could not be read.`;if(kL(e))return{title:s,why:"Can't reach agentrun-serve.",next:"It may be restarting: try again in a moment."};if(!(e instanceof ze))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,o=[e.code,e.requestId].filter(Boolean).join(" · "),i=(u,f)=>({title:s,why:u,next:f,said:r,code:o});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 ss({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 Oa=[{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"}],Yu=e=>Oa.find(n=>n.path===e),NL=e=>e.filter(n=>n.total_usd!==null),SL=e=>Math.min(25,Math.max(3,Math.round(e/15)));function CL(e,n){const s=[];let r=0;return e.forEach((o,i)=>{r+=o.total_usd,i>=n&&(r-=e[i-n].total_usd),s.push(r/Math.min(i+1,n))}),s}function EL(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 $L(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,o=[];for(let i=0;i*r*n<=e*(1+1e-9);i++)o.push(Math.round(i*r*n*1e12)/1e12);return o}function _L(e,n,s){if(!e.length)return{top:1,above:0};const r=e.map(c=>c.total_usd).sort((c,d)=>c-d),o=r[Math.min(r.length-1,Math.floor(r.length*.95))],i=EL(Math.max(o,...n,s??0)*1.08);return{top:i,above:e.filter(c=>c.total_usd>i).length}}function TL(e,n,s=6){if(n<=e)return[e];const r=(n-e)/Math.max(1,s-1),o=10**Math.floor(Math.log10(r)),i=Math.max(1,[1,2,5,10].map(d=>d*o).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 RL(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 ir(e){return e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`}const AL=e=>e<=20?1:Math.max(5,Math.ceil(e/20));function OL(e,n){const s=[];for(let r=0;r<e.length;r+=n){const o=e.slice(r,r+n),i=Object.fromEntries(Oa.map(({path:c})=>[c,0]));for(const c of o)i[c.path]++;s.push({from:o[0].n,to:o.at(-1).n,runs:o.length,counts:i})}return s}function ax(e){const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`}const wf=(e,n)=>`${n?Math.round(e/n*100):0}%`,P2=20,ML=e=>{const n=typeof e=="object"&&e!==null?e.compile_after:void 0;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:P2},PL=20,Mc={revision:"New revision",promote:"Promoted",hold:"Held",refit:"Refit",queued:"Queued",skipped:"Skipped"},qv={revision:"R",promote:"P",hold:"H",refit:"F",queued:"Q",skipped:"S"},L2=e=>e.source==="refit"?"refit":e.decided==="replaying"?"revision":e.decided;function LL(e,n){if(!e.length)return[];const s=e.map(i=>Date.parse(i.started_at)),r=s[0],o=[];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=L2(i),f=e[d].n;o.push({kind:u,n:f,at:i.at,workflow:i.workflow,digest:i.digest,reason:i.reason,record:i})}return o.sort((i,c)=>i.n-c.n)}const IL=e=>e.path!=="replay",I2=e=>{var n;return(n=e==null?void 0:e.summary.hand_backs)!=null&&n.ran?e.summary.hand_backs:null},Kv=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>r.workflow===n&&r.digest===s);function zL(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 o=DL(e),i=o?{proof:o}:{};return e.decided==="promote"?e.digest!==n?{word:"Served",tone:"muted",...i}:e.digest===r?{word:"Stopped",tone:"warning",...i}:{word:"Serving",tone:FL(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 Gc(...e){const n=zL(...e);return{...n,text:n.proof?`${n.word} · ${n.proof}`:n.word}}const Vv=(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},z2=(e,n,s)=>s===null?void 0:[...e].reverse().find(r=>{var o;return r.workflow===n&&r.source==="refit"&&r.decided==="promote"&&((o=r.refit)==null?void 0:o.from)===s});function DL(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 FL=e=>{var n;return(e.source==="replay"||e.source==="refit")&&(((n=e.replay)==null?void 0:n.n)??0)>0},zk=e=>`${Math.round(e*100)}%`,UL=e=>`${e>=0?"+":""}${Math.round(e*1e3)/10} pts`;function Ma(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 ${zk(n.wf_acc)} vs agent ${zk(n.agent_acc)} (${UL(n.delta)}), ${n.handed_back} handed back${(r=n.outcomes)!=null&&r.skipped_write?`, ${n.outcomes.skipped_write} skipped`:""}`}function WL(e){const n=[];let s;try{s=e===null?null:JSON.parse(e)}catch{return n}const r=(o,i,c)=>{if(Array.isArray(o)){o.forEach((f,g)=>r(f,`${i}/${g}`,c));return}if(!o||typeof o!="object")return;const d=o,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 HL={self:"its own confidence",jev:"Jev",both:"its own confidence and Jev"};function BL(e,n=.1){const s=Math.round(1/n),r=Array.from({length:s},(o,i)=>({from:i*n,to:(i+1)*n,right:0,wrong:0,ungraded:0}));for(const o of e){const i=o.p===null?0:Math.min(s-1,Math.max(0,Math.floor(o.p/n+1e-9))),c=r[i];o.correct===!0?c.right+=1:o.correct===!1?c.wrong+=1:c.ungraded+=1}return r}const GL=(e,n,s,r)=>e&&s?e.guards.find(o=>o.workflow===n&&o.digest===s&&o.node===r):void 0;function D2(e){const n=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!n)return null;const s=n[1].split(/\r?\n/).find(o=>/^compiled_into\s*:/.test(o)),r=s==null?void 0:s.replace(/^compiled_into\s*:\s*/,"").trim().replace(/^["']|["']$/g,"");return r||null}function qL(e){var A,P;const{notes:n,compiledNotes:s,runs:r,workflows:o,cost:i,promotions:c,serving:d,loop:u,mode:f="full",execution:g="hosted",compileAfter:b=P2}=e,x=f==="notes",h=o.filter(z=>z.status==="active"),v=u==null?void 0:u.compiles.find(z=>z.digest===null&&(z.draft_errors.length>0||z.attempts.length>0)),y=u==null?void 0:u.compiles.find(z=>z.digest!==null),j=i==null?void 0:i.summary,k=I2(i),E=c.at(-1),S=E?d.find(z=>z.workflow===E.workflow):void 0,N=(S==null?void 0:S.digest)??null,$=S!=null&&S.replaying?`revision ${S.replaying.slice(0,7)} replays on graded inputs before it serves`:(E==null?void 0:E.decided)==="hold"&&E.digest!==N?`revision ${E.digest.slice(0,7)} was held: ${Ma(E)}`:null,_=N!==null&&E?Vv(i,E.workflow)===N:!1,M=_?`revision ${N.slice(0,7)} no longer runs first: it cost as much as the agent by hand; the agent takes its runs`:null,O=M?$?`${M}; ${$}`:M:N&&$?`revision ${N.slice(0,7)} serves; ${$}`:null,L=[];if(L.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 L.push({key:"compiled",title:"Learning",value:"Notes and skills",detail:"Native runs receive accepted notes and skills; learned workflows are unavailable.",state:"later"}),L;if(h.length||y&&y.digest){const z=((A=h[0])==null?void 0:A.name)??(y==null?void 0:y.workflow)??"a workflow";L.push({key:"compiled",title:"Compiled",value:z,detail:y?`from ${y.from_notes.length} ${y.from_notes.length===1?"note":"notes"}, ${y.attempts.length} ${y.attempts.length===1?"attempt":"attempts"}`:"a learned workflow",state:"done"})}else v?L.push({key:"compiled",title:"Compile",value:"Draft failed",detail:`${v.attempts.length} ${v.attempts.length===1?"attempt":"attempts"}, the checks refused it: it tries again on a later run`,state:"warn"}):x?L.push({key:"compiled",title:"Compile",value:"Notes only",detail:`this agent learns notes only: no workflow compiles from them. Full learning compiles one at ${b} completed runs`,state:"later"}):L.push({key:"compiled",title:"Compile",value:"Not yet",detail:g==="sdk"?`With workflow learning and backend tool bindings, compilation starts at ${b} completed runs`:`${Math.min(r,b)} of ${b} completed runs: a workflow compiles at ${b}, then is checked once on those runs' inputs against the agent's own answers`,state:r?"now":"later"});if(g==="sdk")return x||L.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:h.length?"now":"later"}),L;if(j!=null&&j.takeover)L.push({key:"took_over",title:"Took over",value:`Run ${j.takeover.n}`,detail:O??((P=E==null?void 0:E.replay)!=null&&P.n?Ma(E):E?E.reason:"the first run a learned workflow finished alone"),state:_||(E==null?void 0:E.decided)==="hold"&&!N?"warn":"done"});else if(E)if(O)L.push({key:"took_over",title:"Take over",value:Gc(Kv(c,E.workflow,N)??E,{serving:N,stopped:_?N:null}).word,detail:O,state:_?"warn":"done"});else{const z=Gc(E,{serving:N});L.push({key:"took_over",title:"Take over",value:z.word,detail:E.decided==="replaying"?"replaying on graded inputs before it serves; the agent takes the runs meanwhile":Ma(E),state:E.decided==="hold"?"warn":"now"})}else x||L.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(j!=null&&j.takeover&&j.withheld)L.push({key:"cheaper",title:"Cheaper",value:"No ratio yet",detail:`${F2(j.withheld)}: ${U2}`,state:"now"});else if(j!=null&&j.after&&j.before){const z=`${xg(j.before.mean_usd)} a run by the agent, ${xg(j.after.mean_usd)} all-in over the ${j.after.runs===1?"1 run":`${j.after.runs} runs`} it served since`,U=j.times_cheaper;U!==null&&U>1?L.push({key:"cheaper",title:"Cheaper",...KL(j,U),state:"done"}):U!==null?L.push({key:"cheaper",title:"Cheaper",value:U<1?j.before.mean_usd>0?`Not cheaper yet: ${VL(j.after.mean_usd/j.before.mean_usd)} the cost`:"Not cheaper yet":"Same cost",detail:z,state:"now"}):L.push({key:"cheaper",title:"Cheaper",value:`${j.after.runs} served ${j.after.runs===1?"run":"runs"} so far`,detail:`${z}; how many times cheaper shows after ${PL} runs`,state:"now"})}else j!=null&&j.takeover&&j.after_state==="cost_unknown"?L.push({key:"cheaper",title:"Cheaper",value:"No cost yet",detail:"no served run's cost is known yet",state:"now"}):j!=null&&j.after?L.push({key:"cheaper",title:"Cheaper",value:`${j.after.runs} served ${j.after.runs===1?"run":"runs"} so far`,detail:`${xg(j.after.mean_usd)} all-in over the ${j.after.runs===1?"1 run":`${j.after.runs} runs`} it served; no priced agent runs before takeover to compare with`,state:"now"}):x||L.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 R=((u==null?void 0:u.guards)??[]).filter(z=>z.runs>0&&z.threshold!==null).sort((z,U)=>U.escalated/U.runs-z.escalated/z.runs)[0];if(k||R){const z=k?`${Math.round(k.back/k.ran*100)}% handed back`:"no run since";L.push({key:"unsure",title:"Unsure",value:z,detail:R?`most at "${R.node}": ${R.escalated} of ${R.runs} under ${R.threshold.toFixed(2)}`:`of ${k.ran} runs it ran first`,state:k&&k.back/k.ran>.25?"warn":"watch"})}return L}function F2(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 U2="how many times cheaper shows once every run's cost is known";function KL(e,n){const s=n>=1.5?`${Math.round(n)}x`:`${n.toFixed(1)}x`,r=e.replay,o=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: ${o}${i}`}}return{value:`${s} cheaper`,detail:`accuracy not claimed: ${r?`its replay was below the bar (${o})`:"no replay yet"}`}}const xg=e=>e===0?"$0":e<1e-4?"<$0.0001":e>=1?`$${e.toFixed(2)}`:`$${e.toPrecision(3)}`,VL=e=>{const n=Math.round(e*10)/10;return`${n>=10?Math.round(e):n.toFixed(1)}x`},YL=1e3,W2="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.",H2=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.":W2,ix=e=>`${e} served ${e===1?"run":"runs"}`;function Dk({v2:e,agentId:n,on:s,quiet:r=!1,promotions:o,onCost:i,execution:c="hosted"}){const[d,u]=p.useState(null),[f,g]=p.useState([]),b=o??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,YL)).then(E=>{var S;k&&(u(E),(S=x.current)==null||S.call(x,E))},E=>{k&&v(E??new Error("unknown"))}),o||Promise.resolve().then(()=>e.learningPromotions(n)).then(E=>{k&&g(E.promotions)},()=>{}),()=>{k=!1}},[e,n,y,!o]),r&&(!d||d.runs.filter(k=>k.total_usd!==null).length<2)?null:h&&!d?t.jsx(ss,{problem:Tr(h,"the cost per run"),onRetry:()=>j(k=>k+1),className:""}):d?t.jsx(JL,{data:d,on:s,promotions:b,execution:c}):t.jsx(gn,{className:"h-[320px] w-full"})}const Mt={top:30,right:16,bottom:30,left:60},Qu=17,QL=16,qr=260;function JL({data:e,on:n,width:s,promotions:r=[],execution:o="hosted"}){var Ee;const i=p.useMemo(()=>NL(e.runs),[e.runs]),c=p.useMemo(()=>i.filter(IL),[i]),d=SL(c.length),u=p.useMemo(()=>CL(c,d),[c,d]),f=p.useMemo(()=>LL(e.runs,r),[e.runs,r]),{summary:g}=e,b=I2(e),x=p.useRef(null),[h,v]=p.useState(s??720);p.useEffect(()=>{const ae=x.current;if(s||!ae||typeof ResizeObserver>"u")return;const $e=new ResizeObserver(([ot])=>{ot&&ot.contentRect.width>0&&v(ot.contentRect.width)});return $e.observe(ae),()=>$e.disconnect()},[s]);const[y,j]=p.useState(null),[k,E]=p.useState(null),S=Oa.map(ae=>({...ae,runs:e.runs.filter($e=>$e.path===ae.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(ae=>ae.state==="needs_revision"&&ae.served&&ae.by_hand).map(ae=>`${ae.workflow} no longer runs first: ${ir(ae.served.mean_usd)} a run all-in over its newest ${ae.served.runs} priced runs, at or over ${ir(ae.by_hand.mean_usd)} a run by hand.${ae.unknown_cost_runs?` ${ae.unknown_cost_runs===1?"1 run":`${ae.unknown_cost_runs} runs`} of unknown cost left out.`:""} The agent takes its runs; a new version runs first again.`)].filter(ae=>!!ae);if(i.length<2)return t.jsxs(Wk,{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:H2(o)}),N.map(ae=>t.jsx("p",{className:"mx-auto mt-1 max-w-prose text-small text-muted-foreground",children:ae},ae))]}),e.runs.length>0&&(()=>{var ot;const ae=Math.max(300,h),$e=(ae-Mt.left-Mt.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(Uk,{runs:e.runs,width:ae,x:me=>Mt.left+(me-e.runs[0].n+.5)*$e,step:$e,plot:[Mt.left,ae-Mt.right],takeover:((ot=g.takeover)==null?void 0:ot.n)??null})})})()]});const $=Math.max(300,h),_=$-Mt.left-Mt.right,M=e.runs[0].n,O=e.runs.at(-1).n,L=_/(O-M+1),R=ae=>Mt.left+(ae-M+.5)*L,A=g.before,{top:P,above:z}=_L(i,u,(A==null?void 0:A.mean_usd)??null),U=[],q=[];for(const ae of f){const $e=R(ae.n)-L/2;let ot=q.findIndex(me=>$e-me>=QL);ot<0?(ot=q.length,q.push($e)):q[ot]=$e,U.push(ot)}const H=q.length?q.length*Qu+8:0,K=Mt.top+H,W=ae=>K+qr-Math.min(ae,P)/P*qr,G=$L(P),F=TL(M,O,$<520?5:7),D=g.takeover&&g.takeover.n>=M?g.takeover:null,Y=g.takeover?Math.max(g.takeover.n,M):null,se=c.map((ae,$e)=>`${$e?"L":"M"}${R(ae.n).toFixed(1)},${W(u[$e]).toFixed(1)}`).join(""),Q=y===null?null:i[y],re=g.times_cheaper!==null?`${ax(g.times_cheaper)} cheaper`:null,te=b?`${wf(b.back,b.ran)} handed back since`:null,he=g.after?`${ir(g.after.mean_usd)} all-in over ${ix(g.after.runs)} after`:g.takeover&&g.after_state==="cost_unknown"?"no served run's cost known yet":null,ge=g.before&&he?`${ir(g.before.mean_usd)} a run before takeover, ${he}${re?`: ${re}`:""}${te?` · ${te}`:""}`:null,be=e.unknown_cost_runs+e.unknown_path_runs,xe=ae=>{const $e=ae.currentTarget.getBoundingClientRect(),ot=(ae.clientX-$e.left)/$e.width*$,me=(ae.clientY-$e.top)/$e.height*(K+qr+Mt.bottom);if(f.length&&me<K-2){j(null);const Le=f.map((Ze,yt)=>({i:yt,d:Math.abs(R(Ze.n)-L/2-ot)+Math.abs(Mt.top+U[yt]*Qu+8-me)})).sort((Ze,yt)=>Ze.d-yt.d)[0];E(Le&&Le.d<=12?Le.i:null);return}E(null),j(RL(i,M+(ot-Mt.left)/L-.5))},fe=ae=>{const ot={ArrowRight:me=>me+1,ArrowLeft:me=>me-1,Home:()=>0,End:()=>i.length-1,PageUp:me=>me+10,PageDown:me=>me-10}[ae.key];if(!ot){ae.key==="Escape"&&j(null);return}ae.preventDefault(),j(me=>Math.min(i.length-1,Math.max(0,ot(me??(ae.key==="ArrowLeft"?i.length:-1)))))},De=ae=>[`Run ${ae.n}`,`${Ro(ae.total_usd)} all-in${ae.learning_usd?` (${Ro(ae.cost_usd??0)} the run, ${Ro(ae.learning_usd)} learning)`:""}`,`${Yu(ae.path).label}${ae.workflow?`: ${ae.workflow}`:""}`,ae.learned_revision?`Learned revision ${ae.learned_revision.slice(0,7)}`:"Nothing learned yet",...ae.path==="replay"?["A replay: learning's spend, out of the line"]:[]],Fe=k===null?null:f[k]??null,Pe=D?R(D.n)>Mt.left+_*.62:!1;return t.jsxs(Wk,{title:"Cost per run",headline:ge,unknown:be,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(ae=>ae.runs>0).map(ae=>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:ae.fill})}),ae.label," ",t.jsx("span",{className:"text-foreground",children:ae.runs})]},ae.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"]}),A&&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(Mc).filter(ae=>f.some($e=>$e.kind===ae)).map(ae=>t.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":`marker-key-${ae}`,children:[t.jsx("svg",{width:"14",height:"14","aria-hidden":!0,children:t.jsx(Hk,{x:0,y:0,kind:ae})}),Mc[ae]," ",t.jsx("span",{className:"text-foreground",children:f.filter($e=>$e.kind===ae).length})]},ae))]}),t.jsxs("div",{className:"relative shrink-0",tabIndex:0,onKeyDown:fe,onBlur:()=>j(null),"aria-label":`Cost per run, runs ${M} to ${O}. ${ge??""} Arrow keys step through the runs.`,children:[t.jsxs("svg",{width:$,height:K+qr+Mt.bottom,className:"block select-none font-mono",onPointerMove:xe,onPointerLeave:()=>{j(null),E(null)},"aria-hidden":!0,children:[G.map(ae=>t.jsxs("g",{children:[t.jsx("path",{d:`M${Mt.left},${W(ae)}H${Mt.left+_}`,className:ae===0?"stroke-border-strong":"stroke-border",strokeWidth:1}),t.jsx("text",{x:Mt.left-8,y:W(ae),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:Ro(ae)})]},ae)),F.map(ae=>t.jsx("text",{x:R(ae),y:K+qr+18,textAnchor:"middle",className:"fill-muted-foreground text-label",children:ae},ae)),t.jsx("text",{x:Mt.left,y:H?Mt.top-10:K-16,className:"caps fill-muted-foreground text-label",children:"$ a run, all-in"}),t.jsx("text",{x:Mt.left-8,y:K+qr+18,textAnchor:"end",className:"caps fill-muted-foreground text-label",children:"Run"}),f.map((ae,$e)=>t.jsxs("g",{"data-testid":`marker-${ae.kind}`,opacity:k===null||k===$e?1:.55,children:[t.jsx("path",{d:`M${R(ae.n)-L/2},${Mt.top+U[$e]*Qu+15}V${K+qr}`,className:B2[ae.kind],strokeWidth:1,strokeDasharray:"2 3"}),t.jsx(Hk,{x:R(ae.n)-L/2-7,y:Mt.top+U[$e]*Qu+1,kind:ae.kind})]},`${ae.kind}:${ae.n}:${ae.workflow}:${ae.digest}:${ae.at}`)),i.map((ae,$e)=>ae.path==="replay"?t.jsx("circle",{cx:R(ae.n),cy:W(ae.total_usd),r:$e===y?0:2.5,className:"fill-none stroke-muted-foreground",strokeWidth:1.25},ae.run_id):t.jsx("circle",{cx:R(ae.n),cy:W(ae.total_usd),r:$e===y?0:3,className:ie(Yu(ae.path).fill),fillOpacity:.65},ae.run_id)),A&&t.jsxs("g",{children:[t.jsx("path",{d:`M${Mt.left},${W(A.mean_usd)}H${Mt.left+_}`,className:"stroke-muted-foreground",strokeWidth:1.5,strokeDasharray:"6 4"}),t.jsxs(vg,{x:Mt.left+_-4,y:W(A.mean_usd)-6,anchor:"end",children:["Before takeover ",ir(A.mean_usd)]})]}),D&&t.jsxs("g",{children:[t.jsx("path",{d:`M${R(D.n)},${K-4}V${K+qr}`,className:"stroke-chart-workflow",strokeWidth:1.5}),t.jsxs(vg,{x:R(D.n)+(Pe?-6:6),y:K+6,anchor:Pe?"end":"start",children:["Workflow took over, run ",D.n]})]}),Y!==null&&g.after&&t.jsxs("g",{children:[t.jsx("path",{d:`M${R(Y)},${W(g.after.mean_usd)}H${Mt.left+_}`,className:"stroke-foreground",strokeWidth:1,strokeDasharray:"2 3"}),t.jsxs(vg,{x:Mt.left+_-4,y:W(g.after.mean_usd)-8,anchor:"end",strong:!0,children:[$<520?"Served":`Served after takeover (${ix(g.after.runs)})`," ",ir(g.after.mean_usd),re?` · ${re}`:""]})]}),t.jsx("path",{d:se,fill:"none",className:"stroke-foreground",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),Q&&t.jsxs("g",{children:[t.jsx("path",{d:`M${R(Q.n)},${K}V${K+qr}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("circle",{cx:R(Q.n),cy:W(Q.total_usd),r:5,className:ie(Yu(Q.path).fill,"stroke-card"),strokeWidth:2})]})]}),Fe&&!Q&&t.jsx("div",{className:ie("pointer-events-none absolute z-raised max-w-[22rem] border bg-card px-2 py-1 font-mono text-label shadow-float",R(Fe.n)>$*.6&&"-translate-x-full"),"data-testid":"marker-tip",style:{left:R(Fe.n)>$*.6?R(Fe.n)-L/2-12:R(Fe.n)-L/2+12,top:Mt.top},children:Bk(Fe).map((ae,$e)=>t.jsx("span",{className:ie("block",$e===0?"font-semibold":"text-muted-foreground"),children:ae},$e))}),Q&&t.jsxs("div",{className:ie("pointer-events-none absolute z-raised whitespace-nowrap border bg-card px-2 py-1 font-mono text-label shadow-float",R(Q.n)>$*.6&&"-translate-x-full"),style:{left:R(Q.n)>$*.6?R(Q.n)-10:R(Q.n)+10,top:K},children:[De(Q).map((ae,$e)=>t.jsx("span",{className:ie("block",$e===0?"font-semibold":"text-muted-foreground"),children:ae},ae)),t.jsx("span",{className:"block text-muted-foreground",children:ht(Q.started_at)})]}),t.jsx("p",{className:"sr-only","aria-live":"polite",children:Q?De(Q).join(", "):""}),f.length>0&&t.jsx("p",{className:"sr-only",children:`Markers: ${f.map(ae=>Bk(ae).join(", ")).join(". ")}.`})]}),t.jsx(Uk,{runs:e.runs,width:$,x:R,step:L,plot:[Mt.left,Mt.left+_],takeover:((Ee=g.takeover)==null?void 0:Ee.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(ae=>ae.path==="replay")?", replay runs (hollow) left out":"",".",z?` ${z===1?"1 run costs":`${z} runs cost`} more than ${Ro(P)} and ${z===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,...eI(e,n,o)].map(ae=>t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:ae},ae))]}),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(ae=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:ae},ae))})}),t.jsx("tbody",{children:e.runs.map(ae=>{var $e;return t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:ae.n}),t.jsx("td",{className:"pr-4",children:ht(ae.started_at)}),t.jsxs("td",{className:"pr-4",children:[Yu(ae.path).label,ae.workflow?`: ${ae.workflow}`:""]}),t.jsx("td",{className:"pr-4",children:(($e=ae.learned_revision)==null?void 0:$e.slice(0,7))??"-"}),t.jsx("td",{className:"pr-4",children:ae.cost_usd===null?"unknown":Ro(ae.cost_usd)}),t.jsx("td",{className:"pr-4",children:ae.learning_usd===null?"unknown":Ro(ae.learning_usd)}),t.jsx("td",{className:"pr-4",children:ae.total_usd===null?"unknown":Ro(ae.total_usd)})]},ae.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(ae=>t.jsx("th",{className:"py-1 pr-4 text-left font-normal",children:ae},ae))})}),t.jsx("tbody",{children:f.map(ae=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-0.5 pr-4",children:ae.n}),t.jsxs("td",{className:"pr-4",children:[qv[ae.kind]," ",Mc[ae.kind]]}),t.jsx("td",{className:"pr-4",children:ae.workflow}),t.jsx("td",{className:"pr-4",children:ae.digest.slice(0,7)}),t.jsx("td",{className:"pr-4 font-sans",children:Ma(ae.record)})]},`${ae.kind}:${ae.n}:${ae.workflow}:${ae.digest}:${ae.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 XL=64,Ao={top:4,bottom:6},ZL=[...Oa].reverse(),Fk=e=>e.from===e.to?`Run ${e.from}`:`Runs ${e.from} to ${e.to}`;function Uk({runs:e,width:n,x:s,step:r,plot:o,takeover:i}){const c=XL,d=AL(e.length),u=p.useMemo(()=>OL(e,d),[e,d]),[f,g]=p.useState(null);if(!u.length)return null;const[b,x]=o,h=O=>Math.min(x,Math.max(b,O)),v=O=>({from:h(s(O.from)-r/2),to:h(s(O.to)+r/2)}),y=O=>Ao.top+c*(1-O),j=u.at(-1),k=O=>{const{from:L,to:R}=v(O),A=R-L>4?1:0;return{x0:L+A,w:Math.max(1,R-L-2*A)}},E=O=>`${Fk(O)}: ${Oa.filter(L=>O.counts[L.path]).map(L=>`${L.label.toLowerCase()} ${O.counts[L.path]}`).join(", ")}`,S=u.some(O=>O.counts.workflow)?`${wf(j.counts.workflow,j.runs)} by the learned workflow`:Oa.filter(O=>j.counts[O.path]).map(O=>`${wf(j.counts[O.path],j.runs)} ${O.label.toLowerCase()}`).join(", "),N=`Last ${j.runs===1?"run":`${j.runs} runs`}: ${S}`,$=f===null?null:u[f],_=$?k($).x0>n/2:!1,M=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(O=>t.jsxs("text",{x:b-6,y:y(O),dy:"0.32em",textAnchor:"end",className:"fill-muted-foreground text-label",children:[O*100,"%"]},O)),u.map((O,L)=>{const{x0:R,w:A}=k(O);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(O).from,y:Ao.top,width:Math.max(1,v(O).to-v(O).from),height:c,className:"fill-card",fillOpacity:0}),ZL.map(z=>{const U=O.counts[z.path]/O.runs*c;if(!U)return null;P-=U;const q=P>Ao.top+.5?Math.min(2,U):0;return t.jsx("rect",{x:R,y:P+q,width:A,height:U-q,className:z.fill,fillOpacity:.8},z.path)})]},O.from)}),M&&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:ie("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:Fk($)}),Oa.filter(O=>$.counts[O.path]).map(O=>t.jsxs("span",{className:"block text-muted-foreground",children:[O.label," ",$.counts[O.path]," (",wf($.counts[O.path],$.runs),")"]},O.path))]}),t.jsx("p",{className:"sr-only",children:`Execution mix in blocks of ${d} runs. ${u.map(E).join(". ")}. ${N}.`})]})}function eI(e,n,s){const r=e.summary;return!r.takeover&&s!=="hosted"?[H2(s)]:r.takeover?r.withheld?[`${F2(r.withheld)}: ${U2}.`]: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?[`${ix(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.":W2]}function Wk({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(ke,{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 B2={promote:"stroke-chart-workflow",hold:"stroke-warning",refit:"stroke-foreground",revision:"stroke-muted-foreground",queued:"stroke-muted-foreground",skipped:"stroke-muted-foreground"},tI={promote:"fill-foreground",hold:"fill-warning-text",refit:"fill-foreground",revision:"fill-muted-foreground",queued:"fill-muted-foreground",skipped:"fill-muted-foreground"};function Hk({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:ie("fill-card",B2[s]),strokeWidth:1.5,rx:2}),t.jsx("text",{x:e+7,y:n+7,dy:"0.35em",textAnchor:"middle",className:ie("text-micro font-semibold",tI[s]),children:qv[s]})]})}const Bk=e=>[`${Mc[e.kind]} · run ${e.n}`,`${e.workflow} ${e.digest.slice(0,7)}`,Ma(e.record),ht(e.at)];function vg({x:e,y:n,anchor:s="start",strong:r=!1,children:o}){return t.jsx("text",{x:e,y:n,textAnchor:s,className:ie("stroke-card text-label [paint-order:stroke]",r?"fill-foreground font-semibold":"fill-muted-foreground"),strokeWidth:4,strokeLinejoin:"round",children:o})}function nI(e){const n=[];let s=[],r="",o=!1;const i=e.replace(/^/,"");for(let c=0;c<i.length;c++){const d=i[c];o?d==='"'?i[c+1]==='"'?(r+='"',c++):o=!1:r+=d:d==='"'&&r===""?o=!0:d===","?(s.push(r),r=""):d===`
|
|
630
|
+
`||d==="\r"?(d==="\r"&&i[c+1]===`
|
|
631
|
+
`&&c++,s.push(r),r="",s.some(u=>u.trim()!=="")&&n.push(s),s=[]):r+=d}return o?null:(s.push(r),s.some(c=>c.trim()!=="")&&n.push(s),n)}function sI(e){var i;const n=nI(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 o=n.findIndex(c=>c.length!==s.length);return o>=0?{error:`Row ${o+1} has ${n[o].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 Gk=500,rI=5,lx=e=>e.status==="running";function oI(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 aI={agent:"by hand",handed_back:"handed back",workflow:"workflow"},iI=2e3;function lI({v2:e,agentId:n,onFinished:s,pollMs:r=iI}){const[o,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),_&&lx(_)?(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]),o===void 0&&!c)return t.jsx(gn,{className:"h-24 w-full"});if(o===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=o&&lx(o);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:o?"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(cI,{v2:e,agentId:n,onStarted:y=>{x.current=!0,i(y),f(!1),b(j=>j+1)},onCancel:()=>f(!1)}),o&&!u&&t.jsx(fI,{v2:e,agentId:n,batch:o,onBatch:i}),!o&&!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 cI({v2:e,agentId:n,onStarted:s,onCancel:r}){const[o,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState([]),[g,b]=p.useState(""),[x,h]=p.useState(String(rI)),[v,y]=p.useState(!1),[j,k]=p.useState(null),E=async _=>{var R;const M=(R=_.target.files)==null?void 0:R[0];if(!M)return;k(null);const O=sI(await M.text());if("error"in O){i(null),d(O.error);return}d(O.rows.length>Gk?`A batch takes at most ${Gk} rows: this file has ${O.rows.length}.`:null),i({name:M.name,columns:O.columns,rows:O.rows});const L=O.columns.at(-1);b(L),f(O.columns.filter(A=>A!==L))},S=Number(x),N=!!o&&!c&&u.length>0&&!!g&&!u.includes(g)&&Number.isFinite(S)&&S>0,$=async()=>{var _,M;if(!(!o||!N)){y(!0),k(null);try{s(await e.startLearningBatch(n,{inputs:u,answer:g,rows:o.rows,max_cost_usd:S}))}catch(O){k(O instanceof ze?((M=(_=O.fields)==null?void 0:_[0])==null?void 0:M.message)??O.message:O instanceof Error?O.message:String(O)),y(!1)}}};return t.jsxs("div",{className:"space-y-4 border bg-card p-4",children:[t.jsx(wt,{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}),o&&!("error"in o)&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[o.name,": ",o.rows.length," rows, ",o.columns.length," columns"]}),t.jsx(wt,{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:o.columns.map(_=>t.jsx(j5,{label:_,checked:u.includes(_),disabled:_===g,onChange:M=>f(O=>M.target.checked?o.columns.filter(L=>O.includes(L)||L===_):O.filter(L=>L!==_))},_))})}),t.jsx(wt,{label:"The answer column",note:"What the agent is told after each answer: the reference it should have given.",children:t.jsx(Et,{label:"The answer column",value:g,onChange:_=>{b(_),f(M=>M.filter(O=>O!==_))},options:o.columns.map(_=>({value:_,label:_}))})}),t.jsx(wt,{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 ${to(S)} for ${o.rows.length} rows.`:void 0,children:t.jsx(Me,{inputMode:"decimal",value:x,onChange:_=>h(_.target.value),className:"max-w-40","aria-label":"Cap, in dollars"})}),t.jsx(dI,{columns:[...u,g].filter(Boolean),rows:o.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 dI({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(o=>t.jsx("td",{className:"max-w-64 truncate border-b px-2 py-1",children:s[o]},o))},r))})]})})}const uI={running:"active",completed:"success",cancelled:"muted",stopped:"warning"};function fI({v2:e,agentId:n,batch:s,onBatch:r}){const[o,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=oI(s),g=s.cost_usd===null?"unknown":to(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(ke,{tone:uI[s.status],children:s.status}),t.jsxs("span",{className:"font-mono text-body",children:[s.finished," of ",s.total," rows"]})]}),lx(s)&&t.jsx(B,{size:"sm",variant:"destructive",disabled:o,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 ${to(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(ke,{tone:b.right?"success":"error",children:b.right?"right":"wrong"}):b.state==="failed"?t.jsx(ke,{tone:"error",title:b.error,children:"failed"}):t.jsx(ke,{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?aI[b.path]:""}),t.jsx("td",{className:"border-b px-2 py-1",children:b.total_usd==null?"":to(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})]}),mI="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).",yg=e=>`${Math.round(e*1e3)/10}%`;function hI(e){const{cost_per_task_usd:n,baseline_cost_per_task_usd:s}=e,r=n!==null&&s!==null,o=r&&n>0?s/n:null,[i,c]=e.ci;return{accuracy:yg(e.accuracy),accuracyVs:`95% interval ${yg(i)} to ${yg(c)}, n=${e.n.toLocaleString("en-US")}`,cost:r?o===null||s===0?ir(n):o>=1?`${ax(o)} cheaper`:`${ax(n/s)} the cost`:n!==null?ir(n):"Not counted",costVs:r?`${ir(n)} a task vs ${ir(s)} by hand`:n!==null?`${ir(n)} a task; by hand not counted`:"The test did not count the cost a task."}}function qk({v2:e,agentId:n,quiet:s=!1}){const[r,o]=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&&o(g)},g=>{f&&c(g??new Error("unknown"))}),()=>{f=!1}},[e,n,d]),s&&!(r!=null&&r.latest)?null:i&&!r?t.jsx(ss,{problem:Tr(i,"the held-out test"),onRetry:()=>u(f=>f+1),className:""}):r?t.jsx(pI,{result:r.latest}):t.jsx(gn,{className:"h-[116px] w-full"})}function pI({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(gI,{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:mI})]})]})}function gI({result:e}){const n=hI(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,o)=>t.jsxs("div",{className:o?"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 Wf="https://api.githubcopilot.com/mcp/",wd={composio:"Composio",github:"GitHub",url:"URL"},Kk=/^[a-z][a-z0-9-]{0,31}$/,Yv=[{id:"parallel",label:"Parallel Search",name:"parallel",url:"https://mcp.parallel.ai/mcp",auth:"none",note:"Web search, free for light use: no key, no account."},{id:"firecrawl",label:"Firecrawl",name:"firecrawl",url:"https://mcp.firecrawl.dev/v2/mcp",auth:"none",note:"Search, scrape and parse, free without a key and rate limited: add your Firecrawl key later as a bearer token for more."},{id:"github-token",label:"GitHub (token)",name:"github",url:Wf,readOnly:`${Wf}readonly`,auth:"bearer",note:"A fine-grained personal access token for the repositories it may use, with Contents, Issues and Pull requests (read-only, or read and write)."},{id:"linear",label:"Linear",name:"linear",url:"https://mcp.linear.app/mcp",auth:"oauth",note:"Sign in with your Linear account: this server keeps the tokens."},{id:"notion",label:"Notion",name:"notion",url:"https://mcp.notion.com/mcp",auth:"oauth",note:"Sign in with your Notion workspace: this server keeps the tokens."}],G2=e=>Yv.find(n=>n.id===e);function xI(e){const n=new URLSearchParams(e??""),s=n.get("add");if(!s||!Kk.test(s))return;const r=n.get("toolkit")??"",o=n.get("preset")??void 0;if(o==="composio"&&Kk.test(r)){const c=(n.get("tools")??"").split(",").filter(d=>/^[A-Za-z0-9_-]{1,128}$/.test(d)).slice(0,64);return{name:s,preset:"composio",toolkit:r,...c.length?{tools:c}:{}}}const i=G2(o);return i?{name:s,preset:i.id}:{name:s,...n.get("auth")==="github_app"?{auth:"github_app"}:{}}}const vI="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.",q2=(e,n)=>`mcp:${e}/${n}`;function Go(e){const n=/^mcp:([^/]+)\/(.+)$/.exec(e);return n?{server:n[1],tool:n[2]}:null}function yI(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 bI(e,n){return e.flatMap(s=>{const r=Go(s);if(!r)return[];const o=n.find(i=>i.name===r.server);return o?o.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 Vk=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,x;if(!(e instanceof ze))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(h=>h.field==="url"&&h.reason==="redirect"),s=(c=e.fields)==null?void 0:c.find(h=>h.field==="client_id"&&h.reason==="registration_unavailable"),r=(d=e.details)==null?void 0:d.oauth,o=typeof(r==null?void 0:r.callback)=="string"?r.callback:"";return s?{text:s.message,detail:Vk(o),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:Vk(o),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(h=>h.message).join(" "),...typeof((x=e.details)==null?void 0:x.composio)=="string"?{detail:e.details.composio}:{}}:{text:`${e.code}: ${e.message}`}}const Yk={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"},wI="the sign-in didn't finish: try again",jI=e=>e&&Object.hasOwn(Yk,e)?Yk[e]:wI;function kI(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 jd=Go;function NI(e){const n=Go(e);return n?`${n.server} · ${n.tool}`:null}const SI="https://chatgpt.com/#settings",cx="chatgpt",qc=e=>!!e&&e.startsWith(`${cx}/`)&&e.length>cx.length+1,K2="Codex and pi agents run on your ChatGPT plan. Claude Agent, OpenCode, Jev decisions and paid tools need their own keys.",CI="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.",EI="This sign-in is yours: don't let other people run agents on this server with it.",$I="Signed out. If ChatGPT still lists AgentRun under connected apps, disconnect it there.",_I="Signed out here. OpenAI didn't confirm the revocation: remove AgentRun in your ChatGPT settings.",TI="Your ChatGPT sign-in expired. Sign in again.",V2="Requests on your ChatGPT plan cost no dollars here; your plan's own limits apply.",RI=`Counts dollars. ${V2}`,AI=new Set(["signed_out","pending","signed_in","expired"]),Hf=e=>e&&typeof e=="object"&&AI.has(String(e.state))?e:null,OI=e=>e.charAt(0).toUpperCase()+e.slice(1),MI=e=>`Signed in as ${e.email??"your ChatGPT account"}${e.plan?` (${OI(e.plan)})`:""}`;function ml(e,n){return qc(e)?{text:`${e.slice(cx.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 Y2(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 PI(e,n,s,r){return!e||typeof r!="number"||qc(e)?null:Y2(n,s).has(e)?`free model: up to ${r} requests`:null}function LI(e){return e>=1e6?`${Math.round(e/1e6*10)/10}M`.replace(/\.0M$/,"M"):`${Math.round(e/1e3)}K`}function II(e,n){var s;return((s=n==null?void 0:n.find(r=>r.id===e))==null?void 0:s.models)??[]}function Q2(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 zI="No default for this harness yet: add a model key in Settings → Model keys, or choose a model here.",DI="none yet: add a model key in Settings → Model keys",J2=e=>ml(e,null).text,Qv=(e,n)=>[e,n!=null&&n.model?n.tier:void 0,n!=null&&n.model?J2(n.model):void 0].filter(Boolean).join(" · "),X2=e=>e!=null&&e.model?`ran on ${J2(e.model)}${e.tier?` (the ${e.tier} tier)`:""}`:"",FI="http://www.w3.org/2000/svg",Mi=16,cn=240,UI=40,WI=58,bg=16,wg=26,Ju=18,Pi=14,Qk=16,HI=26,BI=14,GI=22,Ds=14,Jk=16,Xu=16,qI=4,KI=10,VI=18,YI=30,QI=5,Ec=124,dx=34,JI=4,jg=10*.6,XI=12.5*.6,Kc=10.5*.6,Xk=11*.6,Jv=9*.66,Zk=10.5*.6,ZI={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"},Xv=new Set(["done","working","held","failed","escalated","stopped","not-run","review","pending"]),Bf={review:"needs review","not-run":"",pending:""};function jt(e,n,...s){const r=document.createElementNS(FI,e);if(n)for(const[o,i]of Object.entries(n))r.setAttribute(o,String(i));for(const o of s)ks(r,o);return r}function ks(e,n){if(n!=null){if(Array.isArray(n)){for(const s of n)ks(e,s);return}e.appendChild(typeof n=="string"?document.createTextNode(n):n)}}const Er=(e,n)=>e.length>n?`${e.slice(0,n-1)}…`:e,ez=(e,n)=>{const s=/^(.*) (\d\.\d\d)$/.exec(e);return!s||e.length<=n?Er(e,n):`${Er(s[1],Math.max(2,n-s[2].length-1))} ${s[2]}`},Fo=(e,n)=>Math.max(2,Math.floor(e/n)),qo=(e,n)=>Math.ceil(e.length*n),Ws=(e,n,s,r,o)=>jt("line",{x1:e,y1:n,x2:s,y2:r,class:o?`wire ${o}`:"wire"});function Z2(e){const n={},s={};for(const o of e)n[o.path]=o;const r=o=>{var i;return((i=n[o])==null?void 0:i.kind)??""};for(const o of e){let i;const c={node:o,order:0,name:null};let d=null;(i=/^(.*)\/steps\/(\d+)$/.exec(o.path))&&r(i[1])==="chain"?(d=i[1],c.order=Number(i[2])):(i=/^(.*)\/branches\/([^/]*)\/body$/.exec(o.path))&&r(i[1])==="route"?(d=i[1],c.name=i[2].replace(/~1/g,"/").replace(/~0/g,"~")):(i=/^(.*)\/branches\/(\d+)$/.exec(o.path))&&r(i[1])==="parallel"?(d=i[1],c.order=Number(i[2])):((i=/^(.*)\/body$/.exec(o.path))&&(r(i[1])==="map"||r(i[1])==="loop")||(i=/^(.*)\/workflow\/root$/.exec(o.path))&&r(i[1])==="workflow")&&(d=i[1]),d!==null&&(s[d]??(s[d]=[])).push(c)}for(const o of Object.values(s))o.sort((i,c)=>i.order-c.order);return{byPath:n,kids:s}}function Zv(e,n){var u,f,g,b;const{diff:s={},status:r={},fired:o}=e.marks,i=n===o?"escalated":r[n],c=i&&Xv.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===o,selected:((b=e.marks.selected)==null?void 0:b.path)===n&&e.marks.selected.item==null}}function kd(e,n,s){var x,h,v;const r=Zv(e,n.path),o=(x=e.marks.meta)==null?void 0:x[n.path],i=o!=null&&o.tool?jd(o.tool):null,c=(h=e.marks.ran)==null?void 0:h[n.path],d=o!=null&&o.decision?(c==null?void 0:c.model)??o.model:o==null?void 0:o.model;let u=`${n.label} (${n.kind}${i?`: ${i.tool} on ${i.server}, an MCP server's tool`:n.via?` via ${n.via}`:""}${o!=null&&o.provider?`, ${o.provider}${d?` ${d}`:""}`:""}${c&&!(o!=null&&o.decision)?`, ${X2(c)}`:""})`;r.state&&(u+=`: ${r.state.replace("-"," ")}`),r.tag&&(u+=`${r.state?", ":": "}${r.tag.toLowerCase()}`),(v=o==null?void 0:o.questions)!=null&&v.length&&(u+=`
|
|
632
|
+
${o.questions.map(y=>`• ${y.text}`).join(`
|
|
633
|
+
`)}`);const f=o!=null&&o.decision&&o.provider?`who-${o.provider==="parallel"||o.provider==="openrouter"?o.provider:"jev"}`:n.kind==="route"&&o&&!o.decision?"who-control":`who-${ZI[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=jt("g",{class:g,"data-path":n.path},jt("title",null,u));return e.svg.appendChild(b),b}const Zi=e=>qo(e,Jv)+10;function jf(e,n,s,r,o="tag"){const i=Zi(r);return ks(e,[jt("rect",{x:n,y:s,width:i,height:13,class:`${o}-box`}),jt("text",{x:n+i/2,y:s+9.5,class:o,"text-anchor":"middle"},r)]),i}const tz=(e,n)=>{var s,r;return!!((r=(s=e.marks.meta)==null?void 0:s[n.path])!=null&&r.decision)},Hm=(e,n)=>tz(e,n)?WI:UI;function ey(e,n,s,r,o){var k,E,S,N,$;const i=Zv(e,s.path),c=(k=e.marks.meta)==null?void 0:k[s.path],d=Hm(e,s),u=(E=e.marks.verdict)==null?void 0:E[s.path],f=i.state in Bf?Bf[i.state]:i.state,g=((S=c==null?void 0:c.questions)==null?void 0:S.length)??0,b=c!=null&&c.tool?jd(c.tool):null,x=(N=e.marks.ran)==null?void 0:N[s.path],h=(x&&!(c!=null&&c.decision)?Qv(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((_,M)=>_+Zi(M)+4,0);i.selected&&n.appendChild(jt("rect",{x:r-4,y:o-4,width:cn+8,height:d+8,class:"sel"})),ks(n,[jt("rect",{x:r,y:o,width:cn,height:d,class:"box"}),jt("rect",{x:r+10,y:o+9,width:8,height:8,class:"swatch"}),jt("text",{x:r+24,y:o+17,class:"label"},Er(s.label,Fo(cn-34-y,XI))),jt("text",{x:r+24,y:o+31,class:"kind"},Er(h,Fo(cn-34-(f?qo(f,Jv)+8:0),Kc))),f?jt("text",{x:r+cn-10,y:o+31,class:"state","text-anchor":"end"},f):null]);let j=r+cn-8;for(const _ of v.reverse())j-=Zi(_),jf(n,j,o+7,_,"badge"),j-=4;if(c!=null&&c.decision&&c.provider){const _=jf(n,r+24,o+38,c.provider,"chip"),M=u?ez(u,Fo(cn-44-_-20,Zk)):"",O=cn-40-_-(M?qo(M,Zk)+10:0),L=(x==null?void 0:x.model)??c.model;L&&O>24&&n.appendChild(jt("text",{x:r+24+_+6,y:o+47.5,class:"model"},Er(L,Fo(O,Kc)))),M&&n.appendChild(jt("text",{x:r+cn-10,y:o+47.5,class:"verdict","text-anchor":"end"},M))}else u&&n.appendChild(jt("text",{x:r+cn-10,y:o+17,class:"verdict","text-anchor":"end"},u));i.tag&&jf(n,r+cn-Zi(i.tag),o-7,i.tag)}function nz(e,n){return{w:cn,h:Hm(e,n),cx:cn/2,place:(s,r)=>ey(e,kd(e,n,"card"),n,s,r)}}function eC(e,n,s){const r=Zv(e,n.path),o=r.state==="done"?"passed":r.state in Bf?Bf[r.state]:r.state,i=Er(n.label===n.kind?"exit":`exit: ${n.label}`,40),c=qo(i,Kc)+16;return{w:Pi+c+(r.tag?6+Zi(r.tag):0)+(o?6+qo(o,Jv):0),h:wg,cx:0,exit:!0,place:(d,u)=>{const f=kd(e,n,"exit"),g=u+wg/2;let b=d+Pi+c;s&&f.appendChild(Ws(d,u,d,u+wg,"spine")),r.selected&&f.appendChild(jt("rect",{x:d+Pi-3,y:g-Ju/2-3,width:c+6,height:Ju+6,class:"sel"})),ks(f,[Ws(d,g,d+Pi,g,"exit-wire"),jt("rect",{x:d+Pi,y:g-Ju/2,width:c,height:Ju,class:"exit-box"}),jt("text",{x:d+Pi+8,y:g+3.5,class:"exit-text"},i)]),r.tag&&(jf(f,b+6,g-6.5,r.tag),b+=6+Zi(r.tag)),o&&f.appendChild(jt("text",{x:b+6,y:g+3.5,class:"state"},o))}}}function sz(e,n,s){const r=s.map(d=>d.node.kind==="escalate"?eC(e,d.node,!1):Bm(e,d.node));let o=cn/2,i=cn/2,c=-bg;for(const d of r)o=Math.max(o,d.cx),i=Math.max(i,d.w-d.cx),c+=d.h+bg;return{w:o+i,h:c,cx:o,place:(d,u)=>{const f=kd(e,n,"chain"),g=d+o;let b=u,x=null;r.forEach((h,v)=>{v&&(b+=bg),h.exit?x===null&&(x=b):x!==null&&f.appendChild(Ws(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(Ws(g,x,g,b,"spine"))}}}function rz(e,n,s){const r=Hm(e,n),o=s.map(h=>({kid:h,box:Bm(e,h.node),x:0,c:0}));let i=0,c=0;o.forEach((h,v)=>{v&&(i+=GI),h.x=i,h.c=i+h.box.cx,i+=h.box.w,c=Math.max(c,h.box.h)});const d=o.length-1,u=Math.round((o[0].c+o[d].c)/2),f=Math.min(0,u-cn/2),g=Math.max(i,u+cn/2),b=r+Qk+HI,x=b+c+BI;return{w:g-f,h:x,cx:u-f,place:(h,v)=>{const y=kd(e,n,"card"),j=h-f,k=v+r+Qk,E=v+x;ey(e,y,n,j+u-cn/2,v),y.appendChild(Ws(j+u,v+r,j+u,k)),d&&ks(y,[Ws(j+o[0].c,k,j+o[d].c,k),Ws(j+o[0].c,E,j+o[d].c,E)]),o.forEach((S,N)=>{const $=j+S.c,_=S.kid.node.path,M=e.taken.has(_);if(y.appendChild(jt("line",{x1:$,y1:k,x2:$,y2:v+b,class:M?"wire branch taken":"wire branch","data-to":_})),S.kid.name!==null){const O=(N<d?o[N+1].c-6:S.x+S.box.w)-S.c-12,L=Er(S.kid.name,Fo(O,Kc)),R=jt("text",{x:$+6,y:k+15,class:M?"branch-name taken":"branch-name"},L);y.appendChild(L===S.kid.name?R:jt("g",null,jt("title",null,S.kid.name),R))}y.appendChild(Ws($,v+b+S.box.h,$,E,M?"taken":void 0)),S.box.place(j+S.x,v+b)})}}}const oz=e=>e.replace(/^.*\//,"").replace(/\.(pdf|png|jpe?g|webp|gif|tiff?)$/i,"");function az(e,n,s,r,o,i){const c=Xv.has(s.status)?s.status:"pending",d=s.label?oz(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=jt("g",{class:`rcell ${c}${s.tone?` tone-${s.tone}`:""}${i?" picked":""}`,"data-path":n.path,"data-item":s.index},jt("title",null,g),jt("rect",{x:r,y:o,width:Ec,height:dx,class:"cell"}),jt("rect",{x:r,y:o,width:3,height:dx,class:"cell-edge"}),jt("text",{x:r+9,y:o+14,class:"cell-name"},Er(d,Fo(Ec-14,jg))),jt("text",{x:r+9,y:o+27,class:"cell-out"},Er(u,Fo(Ec-18-(f?qo(f,jg)+6:0),jg))),f?jt("text",{x:r+Ec-6,y:o+27,class:"cell-p","text-anchor":"end"},f):null);e.appendChild(b)}function iz(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<=YI,[o,i,c]=r?[Ec,dx,JI]:[Xu,Xu,qI],d=Math.min(s.length,r?QI:KI),u=Math.ceil(s.length/d),f=d*(o+c)-c,g=u*(i+c)-c+VI+(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,qo(y,Kc)),h:g,place:(k,E,S)=>{const N=E-f/2,$=e.marks.selected;s.forEach((_,M)=>{const O=N+M%d*(o+c),L=S+Math.floor(M/d)*(i+c),R=Xv.has(_.status)?_.status:"pending",A=($==null?void 0:$.path)===n.path&&$.item===_.index;if(r){az(k,n,_,O,L,A);return}ks(k,jt("rect",{x:O,y:L,width:Xu,height:Xu,class:`cell ${R}${A?" picked":""}`,"data-path":n.path,"data-item":_.index},jt("title",null,`#${_.index+1}${_.label?` ${_.label}`:""}: ${R==="review"?"needs review":R.replace("-"," ")}`)))}),ks(k,jt("text",{x:E,y:S+g-4,class:"caption","text-anchor":"middle"},y))}}}function lz(e,n,s){const r=Bm(e,s),o=Hm(e,n),i=n.kind==="map"?iz(e,n):null,c=i?i.h+Ds:0,d=Math.max(cn/2,r.cx,i?i.w/2:0)+Ds,u=Math.max(cn/2,r.w-r.cx,i?i.w/2:0)+Ds,f=o+Ds+c+r.h+Ds;return{w:d+u,h:f,cx:d,place:(g,b)=>{const x=kd(e,n,"card"),h=g+d;if(ks(x,jt("rect",{x:g,y:b+o/2,width:d+u,height:f-o/2,class:"frame"})),i?(ks(x,Ws(h,b+o,h,b+o+Ds)),ks(x,Ws(h,b+o+Ds+i.h,h,b+o+Ds+c))):ks(x,Ws(h,b+o,h,b+o+Ds)),ks(x,Ws(h,b+o+Ds+c+r.h,h,b+f)),ey(e,x,n,h-cn/2,b),i){const v=jt("g",{class:"items"});i.place(v,h,b+o+Ds),x.appendChild(v)}r.place(h-r.cx,b+o+Ds+c)}}}function tC(e,n){return e.kind==="escalate"?"exit":n.length?e.kind==="chain"?"chain":e.kind==="route"||e.kind==="parallel"?"fan":"frame":"leaf"}function Bm(e,n){const s=e.kids[n.path]??[],r=tC(n,s);return r==="exit"?eC(e,n,!0):r==="leaf"?nz(e,n):r==="chain"?sz(e,n,s):r==="fan"?rz(e,n,s):lz(e,n,s[0].node)}function ty(e){const{byPath:n,kids:s}=Z2(nC(e)),r=o=>{const i=s[o.path]??[],c=tC(o,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 Gm=e=>`${e} ${e===1?"node":"nodes"}`,nC=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 cz(e,n,s={}){var g;for(;e.firstChild;)e.removeChild(e.firstChild);e.classList.add("wf");const r=Z2(nC(n)),o=(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 o(0,0);const i={svg:e,kids:r.kids,marks:s,taken:new Set(s.taken??[])},c=Bm(i,r.byPath["/root"]);c.place(Mi,Mi);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=>Er(h,Fo(Math.max(d,300),Xk)))],x=jt("g",{class:"removed-list"},jt("title",null,`Removed: ${f.join(", ")}`));b.forEach((h,v)=>{x.appendChild(jt("text",{x:Mi,y:Mi+u+33+v*Jk,class:"removed"},h)),d=Math.max(d,qo(h,Xk))}),e.appendChild(x),u+=22+b.length*Jk}return o(d+2*Mi,u+2*Mi)}function dz(e){var o,i;const n=e,s=(o=n==null?void 0:n.closest)==null?void 0:o.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 uz=1600;function Nd({graph:e,marks:n,onSelect:s,className:r,label:o="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=cz(d.current,e,n);f(y=>y.w===v.w&&y.h===v.h?y:v),d.current.style.setProperty("--wf-phase",`-${Date.now()%uz}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":o,className:ie("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=dz(v.target);y&&s&&s(y)}})}function Sd({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,o])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block size-2",style:{background:r}}),o]},o)),e&&t.jsx("span",{className:"h-3 border-l","aria-hidden":!0}),e&&s.map(([r,o])=>t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:ie("inline-block size-2.5 border",r)}),o]},o))]})}const sC={self:"self",jev:"jev",both:"self+jev"},fz=e=>`${sC[e.signal]} ≥${e.threshold.toFixed(2)}`,mz=(e,n)=>n?`${Math.round(e/n*100)}%`:"0%";function hz({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(o=>t.jsx(pz,{guard:o,stats:GL(r,n,s,o.node)},o.node))}),t.jsx(xz,{})]}):null}function pz({guard:e,stats:n}){const s=(n==null?void 0:n.right)??0,r=(n==null?void 0:n.wrong)??0,o=(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(ke,{tone:"plain",title:`Reads ${HL[e.signal]}`,children:sC[e.signal]}),t.jsxs(ke,{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:ie("font-semibold",n.escalated/n.runs>.25?"text-warning-text":"text-foreground"),children:[mz(n.escalated,n.runs)," handed back"]})," (",n.escalated," of ",n.runs," runs)",c,d,o?` · ${o} replay ${o===1?"run":"runs"} apart`:""]}):o?`Replayed on ${o} graded ${o===1?"input":"inputs"}; no run served yet.`:"No run of this revision yet."})]}),n&&n.points.length>0&&t.jsx(gz,{guard:e,stats:n})]})}const Mo=168,br=36,e0=2;function gz({guard:e,stats:n}){const s=BL(n.points),r=Math.max(1,...s.map(d=>d.right+d.wrong+d.ungraded)),o=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:br+14,className:"block font-mono","aria-hidden":!0,children:[s.map(d=>{let u=br;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:o,height:br,className:"fill-card",fillOpacity:0}),f.map(([g,b])=>{if(!g)return null;const x=g/r*(br-2);u-=x;const h=u>.5&&u+x<br-.5?1:0;return t.jsx("rect",{x:d.from*Mo+e0/2,y:u+h,width:o-e0,height:Math.max(1,x-h),className:b,fillOpacity:b==="fill-muted-foreground"?.45:.85},b)})]},d.from)}),t.jsx("path",{d:`M0,${br+.5}H${Mo}`,className:"stroke-border-strong",strokeWidth:1}),t.jsx("path",{d:`M${i(e.threshold)},0V${br+3}`,className:"stroke-foreground",strokeWidth:1.5,strokeDasharray:"3 2"}),t.jsx("text",{x:0,y:br+12,className:"fill-muted-foreground text-micro",children:"0"}),t.jsx("text",{x:Mo,y:br+12,textAnchor:"end",className:"fill-muted-foreground text-micro",children:"1"}),t.jsx("text",{x:i(e.threshold),y:br+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 xz(){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 vz=3e3,yz=e=>e.word==="Held"||e.word==="Not decided"||e.word==="Skipped",t0=e=>`${Math.round(e*100)}%`,bz=e=>`${e>=0?"+":""}${Math.round(e*1e3)/10} pts`,rC=e=>`${e} graded ${e===1?"input":"inputs"}`;function wz(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 ${rC(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 jz(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 ${t0(r.wf_acc)} vs agent ${t0(r.agent_acc)} on ${rC(r.n)} (${bz(r.delta)}), ${r.handed_back} handed back`:null}}function kz({v2:e,agentId:n,workflow:s,digest:r,offered:o,resume:i=null,onStarted:c,onDecided:d,pollMs:u=vz}){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!o&&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")&&o)&&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} `:wz(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=jz(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 kg=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},n0=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`;function Nz(e,n,s,r,o){const i=[e.length&&`added ${n0(e.length,"node")} (${kg(e)})`,n.length&&`edited ${kg(n)}`,s.length&&`removed ${n0(s.length,"node")} (${kg(s)})`].filter(Boolean);if(!i.length)return r?"Nodes reordered":o?"Connections changed":"No node changed";const c=i.join(", ");return c.charAt(0).toUpperCase()+c.slice(1)}function Sz(e){const n=[];let s=null,r=0;for(const o of e){let i=null,c=null;try{i=o.text===null?null:JSON.parse(o.text),c=i===null?null:cl(i)}catch{c=null}if(!(c!=null&&c.nodes.length)){r+=1;continue}const d=s?a2(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=WL(o.text),j=Object.fromEntries(y.flatMap(k=>c.nodes.some(E=>E.path===k.path)?[[k.node,k.path]]:[]));n.push({digest:o.digest??null,guards:y,guardPaths:j,commit:o.commit,at:o.at,run:"run"in o.by?o.by.run:null,reason:o.reason,graph:c,marks:{meta:gd(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?Nz(u.filter(f).map(k=>x.get(k)??k),g.filter(f).map(k=>x.get(k)??k),h,b.length,v):`First version: ${Gm(ty(c))}`}),s=c}return{steps:n,unreadable:r}}const Cz=50,Ez=1800;function $z({v2:e,agentId:n,workflows:s,promotions:r=[],serving:o=[],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(_z,{v2:e,agentId:n,name:b,choices:u,onPick:g,promotions:r,serving:o,loop:i,stopped:Vv(c,b),onReplayed:d},b)}const Zu="Learned workflow";function _z({v2:e,agentId:n,name:s,choices:r,onPick:o,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,Cz)).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:Zu})," ",t.jsx("span",{className:"ml-1 break-all font-mono text-body font-semibold",children:s})]}),r.length>1&&t.jsx(Et,{small:!0,className:"w-56 max-w-full",label:"Learned workflow",value:s,onChange:o,options:r.map(E=>({value:E,label:E}))})]});return x&&!g?t.jsxs("section",{className:"border","aria-label":Zu,children:[j,t.jsx("div",{className:"p-4",children:t.jsx(ss,{problem:Tr(x,"the learned workflow"),onRetry:()=>y(E=>E+1),className:""})})]}):g?t.jsxs("section",{className:"border","aria-label":Zu,children:[j,t.jsx(Tz,{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":Zu,"aria-busy":!0,children:[j,t.jsx("div",{className:"p-4",children:t.jsx(gn,{className:"h-48 w-full"})})]})}function Tz({data:e,stepMs:n=Ez,promotions:s=[],serving:r=null,loop:o=null,stopped:i=null,replay:c}){const{steps:d,unreadable:u}=p.useMemo(()=>Sz(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 R=((P=L[h.current])==null?void 0:P.digest)??null,A=L===d||h.current>=L.length-1||R===null?-1:d.findIndex(z=>z.digest===R);g(A>=0?A:Math.max(0,d.length-1)),x(!1)},[d]),p.useEffect(()=>{if(!b)return;const L=setInterval(()=>g(R=>Math.min(R+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=Kv(s,e.name,y.digest),$=z2(s,e.name,y.digest),_=Gc(N,{serving:r,refit:$,stopped:i}),M=y.guards.length?{...y.marks,verdict:Object.fromEntries(y.guards.flatMap(L=>y.guardPaths[L.node]?[[y.guardPaths[L.node],fz(L)]]:[]))}:y.marks,O=(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(rl,{"aria-hidden":!0}):t.jsx(Qo,{"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(jT,{"aria-hidden":!0})}),t.jsx(B,{size:"icon",onClick:()=>k(f+1),disabled:f>=j-1,"aria-label":"Next revision",children:t.jsx(Es,{"aria-hidden":!0})}),t.jsx(N5,{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 ",na(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(ke,{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?Ma(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."})]}),O&&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(kz,{v2:c.v2,agentId:c.agentId,workflow:e.name,digest:y.digest,offered:!$&&yz(_),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(Nd,{graph:y.graph,marks:M,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(Sd,{}),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(hz,{guards:y.guards,workflow:e.name,digest:y.digest,loop:o}),(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 s0=8,Rz={promote:"success",hold:"warning",refit:"plain",revision:"active",queued:"plain",skipped:"muted"};function r0({loop:e,promotions:n,serving:s=[],cost:r=null}){const[o,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=o?c:c.slice(0,s0);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(Oz,{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?Vv(r,u.compile.workflow):null}):t.jsx(Mz,{record:u.record})},u.key)})}),c.length>s0&&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:o?"Show fewer":`Show all ${c.length}`})})]})}const Az=({id:e})=>t.jsxs("a",{href:`#/runs/${encodeURIComponent(e)}`,className:"underline underline-offset-2 hover:text-foreground",children:["run ",na(e)]}),oC=({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(Az,{id:n})]}):null]});function Oz({compile:e,promotions:n,serving:s,stopped:r}){const o=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=o?null:Gc(Kv(n,e.workflow,e.digest),{serving:s,refit:z2(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:[o?t.jsx(ke,{tone:"error",children:"Draft failed"}):t.jsx(ke,{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(ke,{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`:"",o?": 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(oC,{at:e.at,run:e.run_id})]})}function Mz({record:e}){var o;const n=L2(e),s=Gc(e,{serving:e.digest}),r=n==="promote"?s.tone:Rz[n];return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(ke,{tone:r,children:[qv[n]," · ",Mc[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:Ma(e)}),(o=e.replay)!=null&&o.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(oC,{at:e.at})]})}const Pz={done:{icon:xl,word:"Done",ink:"text-success-text",edge:"border-t-success"},now:{icon:NT,word:"Next",ink:"text-run-active",edge:"border-t-run-active"},later:{icon:CT,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:mm,word:"Watch",ink:"text-foreground",edge:"border-t-border-strong"}};function o0({stages:e}){return e.length?t.jsx("section",{className:"border","aria-label":"The learning loop","data-testid":"loop-story",children:t.jsx("ol",{className:ie("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=Pz[n.state],o=r.icon;return t.jsxs("li",{"data-testid":`stage-${n.key}`,"data-state":n.state,className:ie("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:ie("ml-auto inline-flex items-center gap-1",r.ink),children:[t.jsx(o,{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 aC({id:e,checked:n,onChange:s,busy:r,disabled:o,quiet:i,server:c,problem:d,className:u}){return t.jsxs("div",{className:ie("space-y-2",u),children:[t.jsxs("div",{className:ie("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(ud,{checked:n,onChange:s,busy:r,disabled:o,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 Lz({fields:e,onFields:n,saved:s,server:r,error:o,warning:i}){const c=e.learning??s,d=fl(c),u=typeof s=="object"?s:!0,f=b=>b==="notes"?"notes":fl(b)?"full":void 0,g=b=>n({learning:b===!1&&s===void 0?void 0:b});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(aC,{id:"learning-switch",className:"border px-4 py-3",checked:d,server:r,onChange:b=>g(b?s==="notes"?"notes":u:!1)}),d&&t.jsx("fieldset",{"aria-label":"What it learns",className:"mt-2 space-y-2",children:[["full","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(([b,x,h])=>t.jsxs("label",{className:ie("flex items-start gap-3 border px-3 py-2.5",f(c)===b&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"learning-kind",className:"mt-1 accent-primary",checked:f(c)===b,onChange:()=>g(b==="full"?u:"notes")}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:x}),t.jsx("span",{className:"block text-small text-muted-foreground",children:h})]})]},b))}),o&&t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:o}),i&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:i})]})}const Iz="Not read: its front matter can't be read; fix the file to use it",zz={approved:"Approved",edited:"Edited",created:"Created",retired:"Retired",restored:"Restored",learned:"Learned",superseded:"Replaced"},iC=(e,n)=>`${zz[e]} by ${n==="person"?"you":"a run"}`,ux=e=>e.readme??e.file,Ng="Can't tell which version this is: reload.",qm="It changed since you opened it.",Dz=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.",Fz=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.`,Uz="Making an agent from it takes your password sign-in in the console.",Wz="Restoring takes your password sign-in in the console.",lC=["feedback","project","reference","user"],Hz={user:"About you",feedback:"How to work",project:"About the work",reference:"Where to look"},cC=e=>Hz[e]??e,Bz={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"},Gz=["seeded","reflecting","proposed"],Km=e=>!!e&&Gz.includes(e.state),Cd=e=>Array.isArray(e)?e.filter(n=>!!n&&typeof n=="object"&&typeof n.file=="string"&&typeof n.name=="string"):[],dC=e=>Cd(e==null?void 0:e.given),uC=e=>Cd(e==null?void 0:e.read),Vc=e=>(e==null?void 0:e.state)==="merged"?Cd(e.learned):[],ny=e=>Cd(e==null?void 0:e.pending),fC=e=>Cd(e),a0=e=>(e==null?void 0:e.state)==="merged"?fC(e.skills):[],i0=e=>(e==null?void 0:e.state)==="merged"?fC(e.workflows):[],qz=e=>ny(e).length>0,Gf=(e,n)=>`${e} ${n}${e===1?"":"s"}`,mC=e=>e.status==="pending",qf=e=>{var n;return((n=e==null?void 0:e.learning)==null?void 0:n.pending)??0},sy=e=>`${e} learned ${e===1?"item waits":"items wait"} for your OK`;function Kz(e){const n=e&&typeof e=="object"?e.learning:void 0;return n&&typeof n=="object"&&n.approve===!0?"yes":"password"}const hC="Approving needs your password sign-in. Until then it stays out of every run.",Vz="It changes what this agent trusts or skips, so it waits for you.",Yz="Runs that use bash on the host run as you. For untrusted tasks, use the sandbox.",pC="[redacted]",gC=e=>e===1?"1 note waits for your OK":e>1?`${e} notes wait for your OK`:"A note waits for your OK",el=e=>`${e} ${e===1?"note":"notes"}`,Ka=e=>`${e} ${e===1?"run":"runs"}`,Qz={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"},Kf=e=>Qz[e??""]??"stopped",Jz={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 ry(e){return e.detail&&e.detail.trim()?e.detail.trim():Jz[e.reason??""]??"Not kept: learning stopped."}const Xz=e=>e==="seeded"?"Learns after the run":"Looking back",Vf=e=>ul(Math.round(e)*1e3),Pa=e=>no({usd:e,basis:"estimate",charge_state:null,cap_usd:null}),l0=(e,n)=>e>0?Math.round((n-e)/e*100):null,xC=e=>typeof e.before.median_cost_usd=="number"&&typeof e.after.median_cost_usd=="number",vC=e=>e.after.median_learning_usd;function Zz(e){const n=[`answers in ${Vf(e.after.median_duration_s)} instead of ${Vf(e.before.median_duration_s)}`];xC(e)&&n.push(`${Pa(e.after.median_cost_usd)} instead of ${Pa(e.before.median_cost_usd)} a run`);const s=vC(e);return s!==null&&n.push(`learning itself ${Pa(s)} a run`),`Since it learned (${yC(e)}): ${n.join(" · ")}`}function yC(e){return`medians of ${Ka(e.after.runs)} started from what it learned`}const eD=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)},tD=/^---\n([\s\S]*?)\n?^---$\n?/m,fx=e=>/^"[^"]*"$|^'[^']*'$/.test(e)?e.slice(1,-1):e;function Yf(e){const n=e.replace(/\r\n/g,`
|
|
634
|
+
`),s=n.startsWith(`---
|
|
635
|
+
`)?tD.exec(n):null;if(!s||s.index!==0)return{name:"",description:"",type:"project",body:n,rest:[]};const r={},o=[];for(const c of s[1].split(`
|
|
636
|
+
`)){const d=/^(name|description|type):(?:\s+(.*))?$/.exec(c);d&&!(d[1]in r)?r[d[1]]=fx((d[2]??"").trim()):c.trim()&&o.push(c)}const i=lC.includes(r.type??"")?r.type:"project";return{name:r.name??"",description:r.description??"",type:i,body:n.slice(s[0].length),rest:o}}const c0=e=>{const n=e.replace(/\s*\n\s*/g," ").trim();return/^["'].*["']$/.test(n)?n.includes('"')?`'${n}'`:`"${n}"`:n},nD=e=>`---
|
|
637
|
+
name: ${c0(e.name)}
|
|
638
|
+
description: ${c0(e.description)}
|
|
639
|
+
type: ${e.type}
|
|
640
|
+
${e.rest.map(n=>`${n}
|
|
641
|
+
`).join("")}---
|
|
642
|
+
${e.body.replace(/^\n*/,`
|
|
643
|
+
`)}`;function sD(e){const n=Yf(e).rest.find(r=>/^supersedes:/.test(r)),s=n?fx(n.replace(/^supersedes:\s*/,"").trim()).trim():"";return s?(/^\[.*\]$/.test(s)?s.slice(1,-1).split(","):[s]).map(r=>fx(r.trim())).filter(Boolean):[]}const Yc=e=>Yf(e).body.replace(/^\n+/,"");function d0(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 o=2;n.includes(r);o++)r=`${s}-${o}.md`;return r}const Vm=(e,n=[])=>{const s=n.filter(o=>o!==pC),r=new URLSearchParams(s.map(o=>["note",o]));return`#/agents/${encodeURIComponent(e)}/learning${s.length?`?${r}`:""}`};function bC(e){return e.kind===Kr?{...e,agent_label:null}:e.kind==="user_message"&&e.agent_label===Kr?{...e,kind:Kr,agent_label:null}:e}const Kr="learning",rD={seeded:0,reflecting:1,proposed:2,merged:3,dropped:3},mx=e=>e?rD[e.state]??0:-1,oD=e=>{const n=e==null?void 0:e.learning;return n&&typeof n=="object"&&typeof n.state=="string"?n:void 0},u0=e=>e.charAt(0).toLowerCase()+e.slice(1);function aD(e){var s,r;if(!e||mx(e)<2)return"Looking back on this run…";if(e.state==="proposed")return`Looking back: ${u0(((s=e.detail)==null?void 0:s.trim())||"Checking its new notes…")}`;const n=o=>o.map(i=>i.name.replace(/\s+/g," ").trim()).join(", ");if(e.state==="merged"){const o=Vc(e),i=ny(e),c=[...o.length?[`kept ${el(o.length)} (${n(o)})`]:[],...i.length?[`${u0(gC(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 Kf(e.reason)==="nothing"?"Looked back: nothing new to keep":`Looked back: ${ry(e)}`}function iD(e){var i;const n=bC(e),s=n.summary??"",r=s2(n)?`${s} (failed)`:s,o=(i=t2(n))==null?void 0:i.trimEnd();return o&&o.trim()!==s.trim()?`${r}
|
|
644
|
+
${o.replace(/^(?=.)/gm," ")}`:r}function lD(e,n){const s=e.filter(u=>u.agent_label===Kr&&u.kind!==Kr);if(!s.length)return e.map(bC);const r=e.findLast(u=>u.kind===Kr),o=oD(r),i=mx(o)>mx(n??void 0)?o:n&&{...n,detail:n.detail??(o==null?void 0:o.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:Kr,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:aD(i??void 0),text:[...s,...r?[r]:[]].map(iD).join(`
|
|
645
|
+
`)};return e.flatMap(u=>u===c?[d]:u.agent_label===Kr||u.kind===Kr?[]:[u])}const cD={too_large:"It's too large to show here.",secret:"Not shown: it holds one of this server's secrets."},f0=["Added","Replaced","Retired","Removed","Changed"];function dD(e){const n=[],s=[];let r=0;for(const o of e.split(`
|
|
646
|
+
`)){const i=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(o);i?((r||Number(i[1])>1)&&n.push({text:"…",mark:"gap"}),(r||Number(i[2])>1)&&s.push({text:"…",mark:"gap"}),r++):r&&o.startsWith(" ")?(n.push({text:o.slice(1),mark:"same"}),s.push({text:o.slice(1),mark:"same"})):r&&o.startsWith("-")?n.push({text:o.slice(1),mark:"removed"}):r&&o.startsWith("+")&&s.push({text:o.slice(1),mark:"added"})}return{before:n,after:s}}function uD(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:dD(d.patch)])),o=new Map([...dC(n),...uC(n),...Vc(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 o.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=Vc(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:cD[d.withheld??""]??"Not shown."}}).sort((d,u)=>f0.indexOf(d.said.split(":")[0])-f0.indexOf(u.said.split(":")[0]))}function fD(e){const n=new Map;for(const s of e)for(const r of s.files){const o=n.get(r)??{};"run"in s.by&&(o.run={id:s.by.run,at:s.at,reason:s.reason}),n.set(r,o)}return n}function Ed(){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 Ys(e=Ed){let n=null;return{keyFor(s,r){const o=JSON.stringify([s,r]);return(n==null?void 0:n.request)!==o&&(n={request:o,key:e()}),n.key},done(){n=null}}}async function wC(e,n,s,r){const o=await r(n,s,e.keyFor(n,{content:s}));return e.done(),o}function mD(e=Ed){const n=new Map;return s=>{let r=n.get(s);return r||(r=Ys(e),n.set(s,r)),r}}function hx(e,n){const s=new Set(e.map(r=>r.run_id));return[...e,...n.filter(r=>!s.has(r.run_id))]}const ti=(e,n,s)=>({...Tr(e,n),title:s}),hD=(e,n)=>{const s=e.get(n);return s!=null&&s.title?Cn(s):`run ${na(n)}`},jC="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",pD=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),m0=20,gD=15e3;function Sr(e,n=!1){const[s,r]=p.useState(n),o=p.useRef(Symbol("learning interaction")).current;return p.useEffect(()=>()=>{e.items.delete(o),e.changed(e.items.size>0)},[e,o]),[s,c=>{c?e.items.add(o):e.items.delete(o),e.changed(e.items.size>0),r(c)}]}function xD(e){return t.jsx(vD,{...e},e.agent.agent_id)}function vD({agent:e,v2:n,focus:s=[],server:r,onAgent:o,places:i,onChanged:c}){var Ft;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}),[M,O]=p.useState({items:[],cursor:null,pages:0}),[L,R]=p.useState(!1),A=p.useMemo(()=>({items:new Set,changed:R}),[]),[P,z]=Sr(A),[U,q]=p.useState(0),H=p.useRef(0),K=p.useRef(!1),W=p.useRef(!0),G=p.useRef(!1),[F,D]=p.useState(!1),Y=p.useRef(()=>!1);Y.current=()=>!P&&!A.items.size&&!K.current&&$.pages===0;const se=ye=>{const de=ye==="background";if(!W.current||de&&(G.current||!Y.current()))return Promise.resolve();const Ue=++H.current;G.current=!0,D(!0),K.current=!1,g(null);const Xe=()=>W.current&&Ue===H.current&&(ye==="write"||!A.items.size)&&(!de||Y.current()),at=n.agentLearning(e.agent_id).then(J=>{Xe()&&(u(J),_({items:[],cursor:J.notes.next_cursor,pages:0}),O({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)},()=>{}),at.finally(()=>{Ue===H.current&&(G.current=!1,D(!1))})},Q=()=>se("manual"),re=p.useRef(()=>{});re.current=()=>{document.hidden||se("background")},p.useEffect(()=>{W.current=!0,Q();const ye=()=>re.current();window.addEventListener("focus",ye),document.addEventListener("visibilitychange",ye);const de=window.setInterval(ye,gD);return()=>{W.current=!1,H.current++,window.removeEventListener("focus",ye),document.removeEventListener("visibilitychange",ye),window.clearInterval(de)}},[n,e.agent_id,e.archived_at]);const te=()=>(c==null||c(),se("write")),he=()=>{if(!$.cursor||K.current)return;const ye=H.current;K.current=!0,n.learningNotes(e.agent_id,$.cursor).then(de=>{ye===H.current&&(K.current=!1,_(Ue=>({items:[...Ue.items,...de.items.filter(Xe=>!Ue.items.some(at=>at.file===Xe.file))],cursor:de.next_cursor,pages:Ue.pages+1})))},de=>{ye===H.current&&(K.current=!1,_(Ue=>({...Ue,error:de??new Error("unknown")})))})},ge=fl(e.definition.learning),be=!!e.archived_at,xe=p.useMemo(()=>[...(d==null?void 0:d.notes.items)??[],...$.items],[d,$.items]),fe=xe.filter(ye=>ye.status==="active"),De=xe.filter(mC),Fe=(d==null?void 0:d.skills)??[],Pe=(d==null?void 0:d.workflows)??[],[Ee,ae]=p.useState(void 0),ot=De.length>0||[...Fe,...Pe].some(ye=>ye.status==="pending")||Pe.some(ye=>ye.status==="active");p.useEffect(()=>{if(!ot||Ee!==void 0)return;let ye=!0;return Promise.resolve().then(()=>n.capabilities()).then(de=>{ye&&ae(Kz(de))},()=>{ye&&ae("password")}),()=>{ye=!1}},[ot]);const me=xe.filter(ye=>ye.status==="superseded"||ye.status==="retired"),Le=p.useMemo(()=>{const ye=new Map(xe.map(Ue=>[Ue.file,Ue])),de=new Map;for(const Ue of xe){if(Ue.status==="superseded")continue;const at=[...new Set([...sD(Ue.text),...xe.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}]});at.length&&de.set(Ue.file,at)}return de},[xe]),Ze=p.useMemo(()=>new Map(b.map(ye=>[ye.run_id,ye])),[b]),yt=p.useMemo(()=>fD([...(d==null?void 0:d.log.items)??[],...M.items]),[d,M.items]),oe=s.filter(ye=>!xe.some(de=>de.file===ye)).length>0;p.useEffect(()=>{d&&oe&&$.cursor&&$.error===void 0&&$.pages<m0&&he()},[d,oe,$.cursor,$.pages]);const Se=xe.some(ye=>!yt.has(ye.file));p.useEffect(()=>{if(!d||!Se||!M.cursor||M.pages>=m0)return;const ye=H.current;n.learningLog(e.agent_id,M.cursor).then(de=>{ye===H.current&&O(Ue=>({items:[...Ue.items,...de.items],cursor:de.next_cursor,pages:Ue.pages+1}))},()=>{ye===H.current&&O(de=>({...de,cursor:null}))})},[d,Se,M.cursor]);const tt=b.filter(ye=>ye.learning&&(ye.learning.state==="merged"||ye.learning.state==="dropped")).length,Ae=e.definition.native?"native":es(e.definition)?"sdk":"hosted",it=qL({notes:fe.length,compiledNotes:xe.filter(ye=>ye.status!=="retired"&&D2(ye.text)!==null).length,runs:(k==null?void 0:k.completed_runs)??0,workflows:Pe,cost:S,promotions:h,serving:y,loop:k,mode:e.definition.learning==="notes"?"notes":"full",execution:Ae,compileAfter:ML(e.definition.learning)}),$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||F,onClick:()=>{!A.items.size&&!G.current&&Q()},children:t.jsx(Jo,{className:ie(F&&"animate-spin"),"aria-hidden":!0})})}),ye]});if(f&&!d)return $t(t.jsx(ss,{problem:Tr(f,"what this agent learned"),onRetry:Q,className:""}));if(!d)return $t(t.jsx(bD,{}));const nt=f?t.jsx(yD,{error:f,onRetry:Q}):null,ft=ye=>t.jsx(jD,{agent:e,v2:n,onAgent:o,server:r,disabled:be,quiet:ye}),Dt=ge&&!be&&(Ae==="hosted"?t.jsx(lI,{v2:n,agentId:e.agent_id,onFinished:()=>{q(ye=>ye+1),Q()}}):t.jsxs(vt,{tone:"info",children:[Ae==="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:dn(e.agent_id,"runs"),className:"underline underline-offset-2",children:"Open the agent’s Run controls"}),"."]}));return!xe.length&&!Fe.length&&!Pe.length&&!P?$t(t.jsxs("div",{className:"space-y-6",children:[nt,t.jsx(SD,{on:ge,lookedBack:tt,switchRow:ft(!0),onAdd:be?void 0:()=>z(!0)}),ge&&t.jsx(o0,{stages:it}),t.jsx(qk,{v2:n,agentId:e.agent_id,quiet:!0}),Dt,t.jsx(Dk,{v2:n,agentId:e.agent_id,on:ge,quiet:!0,promotions:h,onCost:N,execution:Ae},U),t.jsx(r0,{loop:k,promotions:h,serving:y,cost:S}),t.jsx(p0,{runs:b})]})):$t(t.jsxs("div",{className:"space-y-6",children:[De.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:De.length})]}),t.jsx("p",{className:"px-4 pt-3 text-body text-muted-foreground",children:Vz}),((Ft=A2(e,i))==null?void 0:Ft.place.mode)==="runner"&&(e.definition.tools??[]).includes("bash")&&t.jsx("p",{className:"px-4 pt-1 text-body text-muted-foreground",children:Yz}),t.jsx("ul",{className:"space-y-3 p-4",children:De.map(ye=>t.jsx("li",{children:t.jsx(h0,{note:ye,v2:n,agentId:e.agent_id,readOnly:be,focused:s.includes(ye.file),from:yt.get(ye.file),runs:Ze,onChanged:te,refreshHolds:A,approves:Ee,replaces:Le.get(ye.file)})},ye.file))})]}),t.jsx(o0,{stages:it}),t.jsx(qk,{v2:n,agentId:e.agent_id}),eD(d.impact)&&t.jsx(wD,{impact:d.impact}),Dt,t.jsx(Dk,{v2:n,agentId:e.agent_id,on:ge,promotions:h,onCost:N,execution:Ae},U),t.jsx($z,{v2:n,agentId:e.agent_id,workflows:Pe,promotions:h,serving:y,loop:k,cost:S,onReplayed:()=>{Q()}}),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?`${el(fe.length)} in use. Every later run reads ${fe.length===1?"it":"them"} before it starts.`:[...Fe,...Pe].some(ye=>ye.status==="active")?"No note is in use.":"No note is in use: the next run starts with nothing learned."})]}),!be&&!P&&t.jsxs(B,{size:"sm",onClick:()=>z(!0),children:[t.jsx(vl,{"aria-hidden":!0})," Add a note"]})]}),nt,!ge&&t.jsx(ND,{server:r}),P&&t.jsx(EC,{title:"New note",v2:n,agentId:e.agent_id,taken:xe.map(ye=>ye.file),onDone:ye=>{z(!1),ye&&te()}},"new"),t.jsx("ul",{className:"space-y-3",children:fe.map(ye=>t.jsx("li",{children:t.jsx(h0,{note:ye,v2:n,agentId:e.agent_id,readOnly:be,focused:s.includes(ye.file),from:yt.get(ye.file),runs:Ze,onChanged:te,refreshHolds:A,replaces:Le.get(ye.file)})},ye.file))}),$.error!==void 0&&t.jsx(ss,{problem:Tr($.error,"more notes"),onRetry:he,className:""}),$.cursor&&t.jsx("div",{className:"flex justify-center",children:t.jsx(B,{size:"sm",onClick:he,children:"Load more notes"})}),me.length>0&&t.jsx(TD,{notes:me,all:xe,from:yt,focus:s,runs:Ze,v2:n,agentId:e.agent_id,readOnly:be,onChanged:te,refreshHolds:A})]}),["skill","workflow"].map(ye=>{const de=ye==="skill"?Fe:Pe;if(!de.length)return null;const Ue=ye==="skill"?"Skills it learned":"Workflows it learned",Xe=de.filter(J=>J.status!=="retired"),at=de.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"?`${Gf(Xe.length,"skill")}: how to do a job it does again, given to every later run once active.`:`${Gf(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(CD,{item:J,kind:ye,v2:n,agentId:e.agent_id,readOnly:be,runs:Ze,approves:Ee,onChanged:te,refreshHolds:A})},J.file))}),at.length>0&&t.jsx(RD,{kind:ye,items:at,v2:n,agentId:e.agent_id,runs:Ze,readOnly:be,onChanged:te,refreshHolds:A})]},ye)})]}),t.jsxs("aside",{className:"min-w-0 space-y-6","aria-label":"About learning",children:[t.jsx(kC,{title:"Learning",children:ft(!1)}),t.jsx(r0,{loop:k,promotions:h,serving:y,cost:S}),t.jsx(p0,{runs:b}),t.jsx(OD,{index:d.index,skills:Fe.filter(ye=>ye.status==="active").map(ye=>ye.name),off:!ge||r==="off"})]})]})]}))}function yD({error:e,onRetry:n}){const s=Tr(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 kC({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 bD(){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:ie(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:ie(e,"h-4 w-1/3")}),t.jsx("span",{className:ie(e,"h-3 w-2/3 bg-muted/70")}),t.jsx("span",{className:ie(e,"h-3 w-1/2 bg-muted/70")})]},n)),t.jsx("span",{className:"sr-only",children:"Loading what it learned…"})]})}function wD({impact:e}){const{before:n,after:s}=e,r=[{label:"Answers in",now:Vf(s.median_duration_s),was:Vf(n.median_duration_s),delta:l0(n.median_duration_s,s.median_duration_s)},...xC(e)?[{label:"A run costs",now:Pa(s.median_cost_usd),was:Pa(n.median_cost_usd),delta:l0(n.median_cost_usd,s.median_cost_usd)}]:[]],o=vC(e),i=[`Medians of ${Ka(n.runs)} before it first learned and ${Ka(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":Zz(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:yC(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:ie("text-small",c.delta<0?"text-primary-text":"text-warning-text"),children:[c.delta>0?"+":"−",Math.abs(c.delta),"%"]})]})]},c.label)),o!==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:[Pa(o)," a run"]})]})]})]})})}function jD(e){return e.agent.definition.native?t.jsx("div",{className:"p-4",children:t.jsx(M2,{agent:e.agent,v2:e.v2,learning:e.server,onAgent:e.onAgent})}):t.jsx(kD,{...e})}function kD({agent:e,v2:n,onAgent:s,server:r,disabled:o,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=vd(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(aC,{id:`learns-${e.agent_id}`,className:"px-4 py-4",quiet:i,checked:g??fl(e.definition.learning),onChange:h=>void x(h),busy:c,disabled:o,server:r,problem:u?t.jsx(ss,{problem:ti(u,"the agent","Learning was not changed."),className:"mt-2"}):null})}function ND({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 SD({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(Yx,{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:[Ka(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(vl,{"aria-hidden":!0})," Or write a note yourself"]})})]})}function h0({note:e,v2:n,agentId:s,readOnly:r,focused:o,from:i,runs:c,onChanged:d,approves:u,refreshHolds:f,replaces:g=[]}){const[b,x]=p.useState(!1),[h,v]=Sr(f),[y,j]=Sr(f),[k,E]=p.useState(o),[S,N]=p.useState(null),[$,_]=Sr(f),[M,O]=p.useState(null),L=p.useRef(null),R=mC(e),A=async()=>{const q=H=>t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:H});_(!0),O(null);try{await n.approveNote(s,e.file,e.etag)}catch(H){_(!1),O(H instanceof ze&&Wm(H).kind==="conflict"?q(`${qm} Reload the tab to see the newest version.`):t.jsx(ss,{problem:ti(H,"the note","The note was not approved."),className:""}));return}await d(),_(!1)};if(p.useEffect(()=>{var H,K;if(!o)return;E(!0),(K=(H=L.current)==null?void 0:H.scrollIntoView)==null||K.call(H,{block:"center",behavior:"smooth"});const q=setTimeout(()=>E(!1),2600);return()=>clearTimeout(q)},[o]),p.useEffect(()=>{if(!S)return;const q=setTimeout(()=>N(null),2400);return()=>clearTimeout(q)},[S]),h)return t.jsx(EC,{title:"Edit note",v2:n,agentId:s,file:e.file,seen:e,onDone:q=>{v(!1),q&&(N("Saved"),d())}});const P=Yc(e.text),z=px(e.last_change),U=D2(e.text);return t.jsxs("article",{ref:L,id:`note-${e.file}`,tabIndex:-1,"aria-label":e.name,className:ie("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(ke,{children:cC(e.type)}),e.origin==="you"&&t.jsx(ke,{tone:"muted",children:"From you"}),U&&t.jsxs(ke,{tone:"success",label:!0,title:`This note went into the learned workflow ${U}`,children:["Compiled into ",U]}),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}),R&&u==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:hC})]}),!r&&!y&&t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[R?u==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void A(),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(qx,{"aria-hidden":!0})," Edit"]}),t.jsx(B,{size:"sm",variant:"destructive",onClick:()=>j(!0),"aria-label":`Retire ${e.name}`,children:"Retire"})]})]}),M&&t.jsx("div",{className:"px-5 pt-3",children:M}),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(Ym,{run:i.run.id,runs:c,at:i.run.at,reason:i.run.reason}),z&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Qx,{className:"size-3","aria-hidden":!0}),z]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Nf,{className:"size-3","aria-hidden":!0}),"Given to ",Ka(e.runs.given)]}),e.runs.read>0&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Nf,{className:"size-3","aria-hidden":!0}),"Read in ",Ka(e.runs.read)]}),g.length>0&&t.jsxs("button",{type:"button",onClick:()=>x(q=>!q),"aria-expanded":b,className:"flex items-center gap-1.5 hover:text-foreground",children:[t.jsx(MT,{className:"size-3","aria-hidden":!0}),"Replaces ",g.length," older ",g.length===1?"note":"notes",t.jsx(Or,{className:ie("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(q=>t.jsx("li",{className:ie("break-words",q.name===null&&"font-mono text-small"),children:q.name??q.file},q.file))}),y&&t.jsx(SC,{name:e.name,kind:"note",retire:()=>n.retireNote(s,e.file,e.etag),onDone:async q=>{q&&await d(),j(!1)}})]})}function CD({item:e,kind:n,v2:s,agentId:r,readOnly:o,runs:i,approves:c,onChanged:d,refreshHolds:u}){const[f,g]=Sr(u),[b,x]=p.useState(null),[h,v]=p.useState(null),[y,j]=p.useState(null),[k,E]=Sr(u),[S,N]=Sr(u),[$,_]=p.useState(null),M=e.status==="pending",[O,L]=Sr(u),R=p.useRef(Ys()).current,[A,P]=p.useState(null),z=n==="workflow"&&e.status==="active"&&c==="yes",U=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"))}},q=async()=>{if(f)return g(!1);g(!0),b===null&&await U()};p.useEffect(()=>{b===null&&h===null||(f?U():(x(null),v(null)))},[e.etag]);const H=n==="skill"&&f&&h?h:e.etag,K=async()=>{E(!0),_(null);try{await s.approveNote(r,ux(e),H)}catch(G){E(!1),_(G instanceof ze&&Wm(G).kind==="conflict"?t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:`${qm} Reload the tab to see the newest version.`}):t.jsx(ss,{problem:ti(G,`the ${n}`,`The ${n} was not approved.`),className:""}));return}await d(),E(!1)},W=`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}),M&&t.jsxs(ke,{tone:"warning",children:[t.jsx(Hx,{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}),M&&c==="password"&&t.jsx("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:hC})]}),t.jsxs("div",{className:"-ml-3 flex shrink-0 items-center gap-1 sm:ml-0",children:[!o&&!S&&!O&&t.jsxs(t.Fragment,{children:[M&&c==="yes"&&t.jsx(B,{size:"sm",variant:"solid",onClick:()=>void K(),disabled:k,"aria-label":`Approve ${e.name}`,children:k?"Approving":"Approve"}),z&&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 q(),"aria-expanded":f,"aria-label":`${f?"Hide":"Show"} ${W}`,children:[t.jsx(Or,{className:ie("transition-transform",f&&"rotate-180"),"aria-hidden":!0}),f?"Hide":"Show"]})]})]}),$&&t.jsx("div",{className:"px-5 pt-3",children:$}),A&&t.jsxs("p",{className:"px-5 pt-3 text-body",role:"status",children:["Made the agent ",t.jsx("a",{href:dn(A.agent_id),className:"font-mono underline underline-offset-2",children:A.definition.name}),". Open it to run it."]}),f&&(y!==null?t.jsx("div",{className:"px-5 pt-3",children:t.jsx(ss,{problem:Tr(y,W),onRetry:()=>void U(),className:""})}):b===null?t.jsx("div",{className:"px-5 pt-3",role:"status","aria-label":`Loading ${W}`,children:t.jsx("div",{"aria-hidden":!0,className:"h-16 bg-muted motion-safe:animate-pulse"})}):n==="skill"?t.jsx(Qm,{text:Yc(b)}):t.jsx(ED,{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(Ym,{run:e.run,runs:i}),px(e.last_change)&&t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Qx,{className:"size-3","aria-hidden":!0}),px(e.last_change)]}),t.jsx("span",{children:e.bytes<1024?`${e.bytes} B`:`${(e.bytes/1024).toFixed(1)} KB`})]}),S&&t.jsx(SC,{name:e.name,kind:n,retire:()=>s.retireNote(r,ux(e),H),onDone:async G=>{G&&await d(),N(!1)}}),O&&t.jsx(_D,{name:e.name,keys:R,promote:G=>s.promoteWorkflow(r,e.name,G),onDone:G=>{L(!1),G&&P(G)}})]})}function ED({name:e,text:n}){const{doc:s,graph:r}=p.useMemo(()=>{try{const c=JSON.parse(n);return{doc:c,graph:cl(c)}}catch{return{doc:null,graph:null}}},[n]),o=p.useMemo(()=>r?{meta:gd(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(Nd,{graph:r,marks:o,label:`The workflow ${e}, as a graph`,minScale:.55,maxScale:1})}),t.jsx(Sd,{}),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 px(e){return e&&e.kind!=="learned"?`${iC(e.kind,e.by)} · ${ht(e.at)}`:null}function NC(e){return(e==null?void 0:e.by)==="host"?Iz:e?`${iC("retired",e.by)} · ${ht(e.at)}`:"Retired"}function Ym({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(Yx,{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:hD(n,e),children:na(e)}),s&&t.jsxs("span",{className:"shrink-0",children:["· ",ht(s)]})]})}function Qm({text:e}){const[n,s]=p.useState(!1),r=e.split(`
|
|
647
|
+
`).length>8||e.length>520,o=p.useMemo(()=>so(e),[e]);return t.jsxs("div",{className:"px-5 pb-4 pt-3",children:[t.jsxs("div",{className:ie("relative",r&&!n&&"max-h-[9.5rem] overflow-hidden"),children:[t.jsx("div",{className:jC,dangerouslySetInnerHTML:{__html:o}}),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(Or,{className:ie("size-3.5 transition-transform",n&&"rotate-180"),"aria-hidden":!0}),n?"Show less":"Show all"]})]})}const $D={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 SC({name:e,kind:n,retire:s,onDone:r}){const[o,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 ze&&Wm(b).kind==="conflict"?f(`${qm} Reload the tab to see the newest version.`):t.jsx(ss,{problem:ti(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?"})," ",$D[n]]}),c&&t.jsx("div",{className:"w-full",children:c}),t.jsx(B,{ref:u,size:"sm",variant:"destructive",onClick:()=>void g(),disabled:o,children:o?"Retiring":"Yes, retire"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>void r(!1),disabled:o,children:"Keep"})]})}function _D({name:e,keys:n,promote:s,onDone:r}){const[o,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 ze&&x.status<500&&n.done(),x instanceof ze&&x.status===403?void d(t.jsx("p",{className:"text-small text-destructive-text",role:"alert",children:Uz})):x instanceof ze&&((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(ss,{problem:ti(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(),o||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?"})," ",Fz(e)]}),c&&t.jsx("div",{className:"w-full",children:c}),t.jsx(B,{ref:u,size:"sm",variant:"solid",onClick:()=>void f(),disabled:o,children:o?"Making the agent":"Yes, make the agent"}),t.jsx(B,{size:"sm",variant:"ghost",onClick:()=>r(null),disabled:o,children:"Cancel"})]})}function CC({name:e,kind:n,from:s,restore:r,onChanged:o,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 ze&&(v.status===412||v.code==="precondition_failed")){f(b(qm)),await o();return}if(v instanceof ze&&v.status===403)return void f(b(Wz));if(v instanceof ze&&((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 ze&&v.status===400){await o(),i();return}return void f(t.jsx(ss,{problem:ti(v,`the ${n}`,`The ${n} was not restored.`),className:""}))}await o(),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?"})," ",Dz(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 EC({title:e,v2:n,agentId:s,file:r,seen:o,taken:i=[],onDone:c}){const[d,u]=p.useState(o?Yf(o.text):{name:"",description:"",type:"feedback",body:`
|
|
648
|
+
`,rest:[]}),[f,g]=p.useState((o==null?void 0:o.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),M=p.useRef(null),O=async()=>{if(r)try{const z=await n.readNote(s,r);u(Yf(z.note)),g(z.etag),x(null)}catch(z){x(z??new Error("unknown"))}};p.useEffect(()=>{var z;(z=M.current)==null||z.focus()},[]);const L=z=>u(U=>({...U,...z})),R=d.name.trim()!==""&&d.description.trim()!==""&&!h,A=async()=>{if(!R)return;if(E(null),j([]),N(!1),r&&!f){E(Ng);return}v(!0);const z=nD(d);try{await n.writeNote(s,r??d0(d.name,i),z,r?{etag:f??""}:{create:!0}),c(!0)}catch(U){v(!1);const q=U instanceof ze?Wm(U,!r):null;(q==null?void 0:q.kind)==="conflict"?(_(z),await O()):(q==null?void 0:q.kind)==="refused"?j(q.problems):(q==null?void 0:q.kind)==="taken"?N(!0):E(U??new Error("unknown"))}},P=z=>{z.key==="Escape"?(z.preventDefault(),z.stopPropagation(),c(!1)):z.key==="Enter"&&(z.metaKey||z.ctrlKey||z.target.tagName==="INPUT")&&(z.preventDefault(),A())};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:[pD?"⌘":"Ctrl","+Enter"]})," save · ",t.jsx("kbd",{children:"Esc"})," cancel"]})]}),b!==null&&t.jsx(ss,{problem:Tr(b,"the note"),onRetry:()=>{x(null),O()},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(Me,{ref:M,value:d.name,onChange:z=>L({name:z.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(Me,{value:d.description,onChange:z=>L({description:z.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:lC.map(z=>t.jsxs("label",{className:ie("caps cursor-pointer border px-3 py-1.5 text-label",d.type===z?"border-foreground":"text-muted-foreground hover:text-foreground"),title:z,children:[t.jsx("input",{type:"radio",name:`type-${r??"new"}`,className:"sr-only",checked:d.type===z,onChange:()=>L({type:z})}),cC(z)]},z))}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:Bz[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(nn,{value:d.body.replace(/^\n/,""),onChange:z=>L({body:`
|
|
649
|
+
${z.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((z,U)=>t.jsx("li",{children:z.detail},U))})]}),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===Ng?t.jsxs("p",{className:"text-body text-destructive-text",role:"alert",children:["Not saved: ",Ng]}):k!==null&&t.jsx(ss,{problem:ti(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 A(),disabled:!R,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:d0(d.name,i)})]})]})]})}function TD({notes:e,all:n,from:s,focus:r,runs:o,v2:i,agentId:c,readOnly:d,onChanged:u,refreshHolds:f}){const[g,b]=Sr(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($C,{title:"Earlier notes",count:`${e.length} no longer read`,open:x,onToggle:()=>h(N=>!N),children:e.map(N=>{var O,L;const $=N.status==="retired",_=$&&v.has(N.file),M=(O=s.get(N.file))==null?void 0:O.run;return t.jsxs("li",{id:`note-${N.file}`,className:ie("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(ke,{tone:"muted",children:$?"Retired":"Replaced"}),$&&t.jsx(_C,{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(PN,{"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)})]}):$?NC(N.retired):null}),g===N.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(CC,{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}),Yc(N.text).trim()&&t.jsx(Qm,{text:Yc(N.text)}),M&&t.jsx("p",{className:"mt-3 flex px-5 font-mono text-label text-muted-foreground",children:t.jsx(Ym,{run:M.id,runs:o,at:M.at,reason:M.reason})})]})]},N.file)})})}function $C({title:e,count:n,open:s,onToggle:r,children:o}){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(Or,{className:ie("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:o})]})}function RD({kind:e,items:n,v2:s,agentId:r,runs:o,readOnly:i,onChanged:c,refreshHolds:d}){const[u,f]=p.useState(!1),[g,b]=Sr(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($C,{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(ke,{tone:"muted",children:"Retired"}),t.jsx(_C,{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(PN,{"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:NC(y.retired)}),g===y.file&&t.jsx("div",{className:"-mx-4 mt-2",children:t.jsx(CC,{name:y.name,kind:e,from:(j=y.retired)==null?void 0:j.from,restore:()=>s.restoreNote(r,ux(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(AD,{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(Ym,{run:y.run,runs:o})})]})]},y.file)})})}function _C({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(Or,{className:ie("transition-transform",e&&"rotate-180"),"aria-hidden":!0}),e?"Hide":"Show"]})}function AD({v2:e,agentId:n,file:s,etag:r,kind:o,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(ss,{problem:Tr(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"})}):o==="skill"?t.jsx(Qm,{text:Yc(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 p0({runs:e}){const n=e.filter(o=>{var i;return((i=o.learning)==null?void 0:i.state)==="dropped"}),s=n.filter(o=>Kf(o.learning.reason)!=="nothing").slice(0,6),r=n.length-n.filter(o=>Kf(o.learning.reason)!=="nothing").length;return n.length?t.jsxs(kC,{title:"Kept nothing",children:[s.length>0&&t.jsx("ul",{children:s.map(o=>t.jsx("li",{className:"border-b last:border-b-0",children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(o.run_id)}`,className:"block px-4 py-3 hover:bg-accent",children:[t.jsx("span",{className:"block text-body",children:ry(o.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:Cn(o),children:Cn(o)}),t.jsxs("span",{className:"shrink-0",children:["· ",ht(o.created_at)]})]})]})},o.run_id))}),r>0&&t.jsxs("p",{className:ie("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`:`${Ka(r)} had`," nothing new to remember."]})]}):null}function OD({index:e,skills:n,off:s}){const[r,o]=p.useState(!1),i=s?0:e.split(`
|
|
650
|
+
`).filter(f=>f.trim()).length,c=p.useMemo(()=>so(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:()=>o(f=>!f),className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent",children:[t.jsx(Or,{className:ie("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?el(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:ie(jC,"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 oy({run:e,link:n=!1,className:s}){var b;const r=dC(e.learning),o=uC(e.learning),i=Vc(e.learning),c=Km(e.learning)&&e.learning.state!=="seeded",d=ny(e.learning),u=qz(e.learning),f=[...a0(e.learning),...i0(e.learning)],g=((b=e.learning)==null?void 0:b.state)==="dropped"&&Kf(e.learning.reason)!=="nothing"?ry(e.learning):null;return!r.length&&!o.length&&!i.length&&!c&&!u&&!f.length&&!g?null:t.jsxs("span",{className:ie("inline-flex flex-wrap items-center gap-2",s),"aria-label":"Learning",children:[r.length>0&&t.jsx(ef,{agentId:e.agent_id,refs:r,link:n,kind:"given"}),o.length>0&&t.jsx(ef,{agentId:e.agent_id,refs:o,link:n,kind:"read"}),i.length>0&&t.jsx(ef,{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(ef,{agentId:e.agent_id,refs:d,link:n,kind:"pending"}),g&&t.jsx(MD,{agentId:e.agent_id,said:g,link:n}),["skill","workflow"].flatMap(x=>{const h=(x==="skill"?a0:i0)(e.learning);return[!1,!0].map(v=>{const y=h.filter(j=>j.pending===!0===v);return y.length?t.jsx(PD,{agentId:e.agent_id,refs:y,link:n,kind:x,pending:v},`${x}-${v}`):null})}),c&&t.jsxs(ke,{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"})]}),Xz(e.learning.state)]})]})}function MD({agentId:e,said:n,link:s}){const r=t.jsxs(ke,{tone:"muted",className:ie(s&&"cursor-pointer"),children:[t.jsx(ST,{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:Vm(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 PD({agentId:e,refs:n,link:s,kind:r,pending:o}){const i=o?`${Gf(n.length,r)} ${n.length===1?"waits":"wait"} for your OK`:`Learned ${Gf(n.length,r)}`,c=`${i}: ${n.map(f=>f.name).join(", ")}`,d=o?Hx:r==="skill"?Cf:Xa,u=t.jsxs(ke,{tone:o?"warning":void 0,className:ie(!o&&"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:Vm(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 ef({agentId:e,refs:n,link:s,kind:r,replaces:o=0}){const i=r==="pending"?gC(n.length):r==="given"?`Started with: ${el(n.length)}`:r==="read"?`Read: ${el(n.length)}`:`Learned ${el(n.length)}`,c=n.map(h=>h.name).join(", "),d=r==="given"||r==="read",u=d?Nf:r==="pending"?Hx:Yx,f=t.jsxs(ke,{tone:r==="pending"?"warning":void 0,className:ie(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!==pC),b=`${i}${c?`: ${c}`:""}${o?` (replaces ${o===1?"1 older note":`${o} 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))}),o>0&&t.jsxs("span",{className:"mt-1 block text-muted-foreground",children:["Replaces ",o===1?"1 older note":`${o} older notes`,"."]}),t.jsx("span",{className:"mt-1.5 block text-label text-muted-foreground",children:"Open in Learning"})]});return t.jsx(E5,{tip:x,children:t.jsx("a",{href:Vm(e,g.map(h=>h.file)),"aria-label":b,className:"inline-flex",children:f})})}function LD({n:e,className:n}){return e<=0?null:t.jsx("span",{"aria-label":sy(e),className:ie("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 ID=["pi","claude-agent","codex","opencode"];function zD(e){const n=new Set,s=r=>{if(Array.isArray(r)){r.forEach(s);return}if(!r||typeof r!="object")return;const o=r;o.node==="call"&&typeof o.tool=="string"&&n.add(o.tool),Object.values(o).forEach(s)};return s(e),[...n].sort()}function DD(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 FD(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 ay="Refused on this server for every agent, whatever the agent's own setting or Never ask.",UD="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.",TC=(e,n,s,r)=>{var d;const o=s==null?void 0:s.find(u=>u.name===e);if(o)return o.permission==="deny"&&o.permission_from==="server";const i=Go(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 WD(e){return(e??[]).map(({name:n,permission:s,default_permission:r,permissions:o,ask_needs:i})=>({name:n,permission:s,default_permission:r,permissions:o,...i==="password"?{ask_needs:i}:{}}))}const HD={auto:"auto",native:"native",kernel:"kernel fetch","exa-keyless":"Exa keyless",parallel:"Parallel"},RC={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."}}},Qf=(e,n)=>{var s;return(n&&((s=RC[n])==null?void 0:s.label[e]))??HD[e]??e},BD={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."},g0=(e,n)=>{var s;return(n&&((s=RC[n])==null?void 0:s.help[e]))??BD[e]};function AC(e,n){return e?e.startsWith("unavailable")?{text:e,unavailable:!0}:{text:Qf(e,n),unavailable:!1}:{text:"not known",unavailable:!1}}function OC(e,n,s,r,o){const{[n]:i,...c}=e,{[s]:d,...u}=i??{},f=r===void 0||r===o?u:{...u,[s]:r};return Object.keys(f).length?{...c,[n]:f}:c}const GD=(e,n,s,r)=>OC(e,n,"provider",s,r),qD=(e,n,s,r)=>OC(e,n,"permission",s,r);function gx(e,n){const s=new Map(n.map(r=>[r.name,r.default_provider]));return Object.fromEntries(Object.entries(e).flatMap(([r,o])=>{if(!o||typeof o!="object")return[];const{provider:i,...c}=o,d=i!==void 0&&!(s.has(r)&&i===s.get(r))?{...c,provider:i}:c;return Object.keys(d).length?[[r,d]]:[]}))}function MC(e,n,s){const r={},o=[];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):o.push(c)}return{byTool:r,rest:o}}const KD=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),VD=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))]},YD=e=>typeof e=="string"?e:JSON.stringify(e);function QD(e){return Object.keys(e).sort().map(n=>{const s=e[n];if(KD(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=VD(s),o=r[0]===null,i=(o?r.slice(1):r).map(d=>YD(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 ${o?`left out or ${c}`:c}`}).join("; ")}const JD="Calls outside it are refused before they run or ask.",XD="This pin doesn't read, so every call to this tool is refused. Set the pin again, or remove the tool's setting.",ZD=[{id:"runs",label:"Runs",shows:()=>!0,Body:rF},{id:"versions",label:"Versions",shows:()=>!0,Body:cP},{id:"workflow",label:"Workflow",shows:e=>e.kind==="workflow",Body:oF},{id:"learning",label:"Learning",shows:(e,n)=>e.kind==="agentic"&&n.learning!==!1,Body:e=>t.jsx(xD,{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:PP}],dn=(e,n)=>`#/agents/${encodeURIComponent(e)}${n?`/${n}`:e==="new"||e==="connect"?"/runs":""}`;function eF({v2:e,agentId:n,routePrefix:s,harnesses:r,go:o,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(z=>{P&&g(z.agent)},z=>{P&&x({cause:z})}),e.statsOver({from:Rv(N2),agent:n}).then(z=>{P&&j(z)},()=>{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,z=!P)=>{const U=++k.current;return z&&(S.current=U),e.getAgent(n).then(q=>(U>E.current&&U>=S.current&&(E.current=U,g(H=>H&&H.agent_id===q.agent.agent_id?q.agent:H),$(!1)),E.current>=U),()=>(U===k.current&&!P&&$(!0),E.current>=U))},M=P=>{g(z=>({...P,tools:(z==null?void 0:z.tools)??P.tools})),_()},O=()=>void _(),L=()=>void _(!0,!1),R=()=>_(!0,!0),A=y===void 0?void 0:y!==null;return b?b.cause instanceof ze&&b.cause.status===404?t.jsx(i2,{what:"agent",id:n,list:{href:"#/agents",label:"Open the agents list"}}):t.jsx(Jt,{problem:Ht(b.cause,"the agent"),onRetry:()=>v(P=>P+1)}):f?t.jsx(tF,{agent:f,onAgent:M,onSignInsAgent:g,reread:_,onChanged:O,poll:L,afterForget:R,stale:N,v2:e,go:o,stats:y,analytics:A,places:u,routePrefix:s,harnesses:r,tab:i,learning:c,notes:d},f.agent_id):t.jsx(rP,{})}function tF({agent:e,onAgent:n,onSignInsAgent:s,reread:r,onChanged:o,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 te,he,ge,be;const E=sF(e,u,r,()=>r(!1,!1)),[S,N]=p.useState(!1),$=qf(e),_=e.definition,M=es(_),{native:O,refresh:L}=gL(e,u),R=e.kind==="workflow",A=R?Xa:Ux,P=Q2(_.harness??"pi",h),z=_.model?ml(_.model,x):P?(({text:xe,title:fe})=>({text:`${xe} (default)`,title:fe}))(ml(P,x)):{text:DI},U=R||O||M||h==null?void 0:h.find(xe=>xe.id===(_.harness??"pi")&&xe.available===!1),q=U?`${U.id} doesn't run on this server${U.reason?`: ${U.reason}`:"."}`:void 0,H=A2(e,k),K=`${XP(H==null?void 0:H.place)}${H!=null&&H.byDefault?" (server default)":""}`,W=!M&&!O&&!R&&!U&&!_.model&&!P&&(h==null?void 0:h.some(xe=>xe.id===(_.harness??"pi")&&xe.default_model===null)),G=[...M?[["Runtime",Yo(M.runtime)],["Model","Reported per run"],["Execution","Your backend"]]:O?[["Runtime",O.runtime],["Model",O.model??"Native default"],["Selector",O.selector.kind==="project"?"Project default":O.selector.name??O.selector.kind],["Machine",O.machine_id]]:R?[]:[["Harness",_.harness??"pi"],["Model",z.text,z.title],["Thinking",_.thinking??"default"],["Runs",K]],["Revision",`rev ${_.version} of ${e.revisions}`]],F=ZD.filter(xe=>xe.shows(e,{analytics:b===!0,learning:y===void 0?v==="learning"?void 0:!1:!!y})),D=F.find(xe=>xe.id===v)??F[0],Y=v==="analytics"&&b===void 0,se=((te=E.runs)==null?void 0:te.filter(nF))??[],Q=((he=e.runs)==null?void 0:he.live)??(E.runs?`${se.length}${E.cursor?"+":""}`:"—"),re=[["Status",e.archived_at?"Archived":O?bd(O):"Active"],["Live jobs",String(Q)],...G];return t.jsx(xL,{native:O,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(An,{"aria-hidden":!0})}),t.jsx(A,{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(Jo,{className:ie(E.reading&&"animate-spin"),"aria-hidden":!0})}),!O&&!M&&t.jsx(B,{size:"sm",onClick:()=>f(dn(e.agent_id,"edit")),children:"Detailed editor"}),t.jsx(sn,{label:"Edit agent",prompt:Bo(location.origin,e.agent_id,!!O,M==null?void 0:M.runtime),playgroundHref:O||M?void 0:`#/playground?operation=edit-agent&agent=${encodeURIComponent(e.agent_id)}`}),!e.archived_at&&t.jsx(sn,{variant:"primary",label:"Run agent",disabled:!!O&&(!O.connected||O.state!=="ready"||!O.capabilities.launch),prompt:Lv(location.origin,e.agent_id,M==null?void 0:M.runtime),playgroundHref:M?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(ke,{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:ie("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(xe=>!xe),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(Es,{className:ie("size-3.5 shrink-0 transition-transform",S&&"rotate-90"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:re.map(([,xe])=>xe).join(" · ")})]}),t.jsxs("dl",{id:"agent-facts",className:ie("grid grid-cols-2 gap-3",!S&&"max-sm:hidden"),"aria-label":"Current revision",children:[re.map(([xe,fe,De])=>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:xe}),t.jsx("dd",{className:"break-words text-body font-semibold",title:De,children:fe})]},xe)),!R&&!O&&!M&&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:!R&&e.tools?e.tools.length?t.jsx("ul",{className:"space-y-2","aria-label":"Tools",children:e.tools.map(xe=>t.jsxs("li",{children:[t.jsx("span",{title:xe.blurb,children:xe.name}),xe.provider?` · ${Qf(xe.provider,xe.name)}`:"",xe.permission?` · ${xe.permission}`:"",AC(xe.resolved,xe.name).unavailable&&t.jsx("span",{"data-unavailable":!0,className:"text-warning-text",title:xe.resolved,children:" · unavailable"})]},xe.name))}):"none":_.tools.join(", ")||"None configured"})]})]}),q&&t.jsx(vt,{tone:"warning","aria-label":"Harness not available",children:q}),!e.archived_at&&W&&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"})]}),(ge=e.warnings)!=null&&ge.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((xe,fe)=>t.jsxs("li",{children:[t.jsx("span",{className:"text-muted-foreground",children:xe.field})," ",xe.message]},`${xe.field}:${fe}`))})]}):null,t.jsx(wL,{agent:e,v2:u,onAgent:s,poll:i,refresh:c}),O&&t.jsx(vL,{agent:e,v2:u,learning:y,onAgent:n,onChanged:async()=>{L(),await r()}}),!O&&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:M?"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"}),se.length?t.jsx("ul",{className:"space-y-3",children:se.map(xe=>t.jsx("li",{children:t.jsxs("a",{href:`#/runs/${encodeURIComponent(xe.run_id)}`,className:"flex items-center gap-2 text-small hover:text-primary-text",children:[t.jsx($l,{run:xe}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:Cn(xe)}),t.jsx(fr,{className:"size-3 shrink-0","aria-hidden":!0})]})},xe.run_id))}):t.jsx("p",{className:"text-small leading-relaxed text-muted-foreground",children:E.runs?(be=e.runs)!=null&&be.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(OS,{id:"agent-views",label:"Agent views",value:D.id,onChange:xe=>f(dn(e.agent_id,xe)),tabs:F.map(xe=>({id:xe.id,label:t.jsxs(t.Fragment,{children:[xe.label,xe.id==="learning"&&t.jsx(LD,{n:$,className:"ml-1.5"})]})})),className:"mb-5 overflow-x-auto px-0 md:px-0"}),t.jsx("div",{...C5("agent-views",D.id),"aria-label":Y?void 0:D.label,children:Y?t.jsx(Un,{label:"Loading the tab",rows:4}):t.jsx(D.Body,{agent:e,v2:u,go:f,stats:g,history:E,focus:j,learning:y,onAgent:n,onChanged:o,places:k})})]})]})]})})}const nF=e=>!e.imported_from&&["queued","working","paused","input_required"].includes(e.status);function sF(e,n,s,r){const[o,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,M=!1,O=!1)=>{if(S.current)return;S.current=!0;const L=++j.current;f(!0),b(!!$);const R=_?O?r():s():Promise.resolve();try{let A=$,P=[];const z=$||M?void 0:k.current.at(-1),U=z?Date.parse(z.created_at):NaN,q=E.current+1;let H=!1;const K=new Set;do{if(K.size>=q){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(K.has(A))throw new Error("The runs list repeated a page. Refresh to try again.");K.add(A);const W=await n.listAgentRuns(e.agent_id,50,A,!!e.archived_at);if(L!==j.current)return;P=hx(P,W.runs),A=W.next_cursor,H||(H=W.runs.some(G=>G.run_id===(z==null?void 0:z.run_id)||Date.parse(G.created_at)<U))}while(!$&&A&&z&&!H);L===j.current&&(k.current=$?hx(k.current,P):P,E.current=$?E.current+1:K.size,i(k.current),d(A),h(null),y(!1))}catch(A){L===j.current&&h(Ht(A,$?"more runs":"the runs"))}finally{await R,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:o,cursor:c,reading:u,more:g,error:x,refresh:()=>{N(null,!0)},loadMore:()=>{c&&N(c)},reloadLatest:v?()=>{N(null,!0,!0)}:null}}function rF({agent:e,history:n}){const[s,r]=p.useState(""),{runs:o,cursor:i,reading:c,more:d,error:u,refresh:f,loadMore:g,reloadLatest:b}=n;if(u&&!o)return t.jsx(Jt,{problem:u,onRetry:f,className:""});if(!o)return t.jsx(Un,{label:"Loading the runs",rows:5});const x=o.filter(h=>`${Cn(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(pm,{className:"size-3.5 text-muted-foreground","aria-hidden":!0}),t.jsx(Me,{"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:[o.length,i?"+":""," ",o.length===1&&!i?"run":"runs"]}),t.jsx("div",{className:"ml-auto",children:t.jsx(sn,{label:"Query",prompt:`${zm(location.origin,e.agent_id)}
|
|
651
|
+
Current view: all statuses; ${e.archived_at?"archived runs":"non-archived runs"}.`,playgroundHref:_v(e.agent_id,{archived:!!e.archived_at})})})]}),o.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($l,{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:Cn(h)}),t.jsx(fr,{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(oy,{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:ul(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||Sl(h.cost))?no(h.cost,{ended:Ga(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(Jt,{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 oF({agent:e}){const n=e.definition.workflow,s=p.useMemo(()=>cl(n),[n]),r=p.useMemo(()=>({meta:gd(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:[Gm(ty(s))," · rev ",e.definition.version]}),t.jsx("span",{className:"flex-1"}),t.jsx(sn,{label:"Edit workflow",prompt:Bo(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(Nd,{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(Sd,{})})]})}function PC({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 aF=20,iF=100,lF=4,Li=(e,n)=>(e==null?void 0:e.filter(s=>s.status===n).length)??0,LC=e=>`#/agents/${encodeURIComponent(e.agent_id)}/learning`,xx=e=>e.toLocaleString("en-US"),IC=[{label:"Active notes",of:e=>e.view?{value:Li(e.notes,"active"),exact:!!e.complete}:null},{label:"Learned skills",of:e=>{var n;return(n=e.view)!=null&&n.skills?{value:Li(e.view.skills,"active"),exact:!0}:null}},{label:"Workflow drafts",of:e=>{var n;return(n=e.view)!=null&&n.workflows?{value:Li(e.view.workflows,"active"),exact:!0}:null}},{label:"Pending review",of:e=>e.view?{value:Li(e.notes,"pending")+Li(e.view.skills,"pending")+Li(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 zC(e,n){if(!e.length)return"0";const s=e.map(n);return s.every(r=>r===null)?"—":`${xx(s.reduce((r,o)=>r+((o==null?void 0:o.value)??0),0))}${e.some(r=>r.stale)?" (last read)":s.every(r=>r==null?void 0:r.exact)?"":"+"}`}function cF({v2:e,server:n}){const[s,r]=p.useState(null),[o,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 Vr(async R=>{if(!E())throw new Error("Read superseded");if(R&&N.has(R))throw new Error("The agent list repeated a page. Refresh to try again.");R&&N.add(R);const A=await e.listAgents({cursor:R});return S=A.next_cursor,A},R=>R.agents,iF);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(R=>[R.agent_id,R])).values()].map(R=>({agent:R}));r(R=>{const A=new Map(R==null?void 0:R.map(P=>[P.agent.agent_id,P]));return _.map(({agent:P})=>{const z=A.get(P.agent_id);return P.kind==="agentic"&&(z==null?void 0:z.agent.kind)==="agentic"&&z.view?{...z,agent:P,stale:!0,error:void 0,unavailable:void 0}:{agent:P}})});const M=_.filter(R=>R.agent.kind==="agentic");let O=0;const L=async()=>{for(;E()&&O<M.length;){const{agent:R}=M[O++];let A;try{const P=await e.agentLearning(R.agent_id);if(!E())return;const z=new Map(P.notes.items.map(K=>[K.file,K]));let U=P.notes.next_cursor,q;const H=new Set;for(let K=0;U&&K<aF&&E();K++){if(H.has(U)){q="The note list repeated a page.";break}H.add(U);try{const W=await e.learningNotes(R.agent_id,U);W.items.forEach(G=>z.set(G.file,G)),U=W.next_cursor}catch(W){q=Ht(W,"more notes").why;break}}A={agent:R,view:P,notes:[...z.values()],complete:!U,...U?{noteIssue:q??"More note pages are available in the agent's Learning tab."}:{}}}catch(P){A={agent:R,error:Ht(P,"Learning"),unavailable:P instanceof ze&&P.status===404}}if(!E())return;r(P=>(P==null?void 0:P.map(z=>z.agent.agent_id!==R.agent_id?z:A.error&&!A.unavailable&&z.view?{...z,...A,stale:!0}:A))??null)}};await Promise.all(Array.from({length:Math.min(lF,M.length)},L)),E()&&f(new Date().toISOString())}catch(S){E()&&i(Ht(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(PC,{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(Jo,{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."}),o&&t.jsxs(t.Fragment,{children:[t.jsx(Jt,{problem:o,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&&!o?t.jsx(Un,{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:IC.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:zC(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(dF,{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)}`:LC(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(fr,{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 dF({row:e,server:n}){const{agent:s,view:r,error:o}=e,i=s.kind==="agentic",c=fl(s.definition.learning);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(ke,{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:[o&&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.":o.title}),t.jsxs("p",{className:"mt-1",children:[o.why," ",o.said]})]}),r?t.jsxs(t.Fragment,{children:[t.jsx("dl",{className:"mt-5 grid grid-cols-2 gap-x-4 gap-y-3",children:IC.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:zC([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:[xx(r.counts.merged)," runs kept learning · ",xx(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."})]}):!o&&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?LC(s):dn(s.agent_id),children:[i?"Open learning":"View agent",t.jsx(fr,{className:"size-3.5","aria-hidden":!0})]})]})}const uF=140,fF=32,mF=40,hF=60;function iy({value:e,name:n,note:s,blurb:r,description:o,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=tf(v,"width",x,n),S=tf(y,"height",x,o),N=tf(j,"width",x,i),$=tf(k,"width",x,d),_=E??n.length>fF,M=!!o&&(S??o.length>uF),O=!!i&&(N??i.length>mF),L=!!d&&($??d.length>hF),R=!!c&&(c!==i||O),A=!!o&&(!!r||M)||R||L||_,P=(U,q)=>!x&&U&&q?U:void 0,z=U=>{U.preventDefault(),U.stopPropagation(),h(q=>!q)};return t.jsxs("label",{"data-tool-card":e,className:ie("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:ie("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}):o&&!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(o,M),children:o}):null,i&&t.jsx("span",{ref:j,"data-tag":!0,title:P(c,R),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:[o&&t.jsx("span",{className:"block whitespace-pre-wrap [overflow-wrap:anywhere]",children:o}),c&&c!==o&&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})]}),A&&t.jsx("button",{type:"button",onClick:z,"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 tf(e,n,s,r){const[o,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]),o}function pF({servers:e,tools:n,harness:s,harnesses:r,onChange:o,onRetry:i}){const c=h=>o(n.includes(h)?n.filter(v=>v!==h):[...n,h]),d=n.filter(h=>Go(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(iy,{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=bI(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(q2(h.name,v.name),v.name,[v.title,v.description].filter(Boolean).join(": ")||void 0,void 0,yI(v,s)??(v.permission==="deny"?ay: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 gF="[a-z][a-z0-9-]{0,31}",DC="[A-Za-z0-9_-]{1,64}",xF="[a-z0-9][a-z0-9.-]{0,63}",vF="[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}",yF=`[a-z][a-z0-9_-]{0,63}(?:\\.${DC})?`,bF="mcp:",wF="monid:",x0="*",jF=new RegExp(`^mcp:(${gF})/(\\*|${DC})$`),kF=new RegExp(`^monid:(${xF})/(\\*|${vF})$`),NF=new RegExp(`^${yF}$`);function SF(e){if(hl(e)){const s=kF.exec(e);return s?s[2]===x0?{kind:"monid-provider",provider:s[1]}:{kind:"monid",provider:s[1],endpoint:s[2]}:void 0}if(!EF(e))return NF.test(e)?{kind:"plain",name:e}:void 0;const n=jF.exec(e);if(n)return n[2]===x0?{kind:"mcp-server",server:n[1]}:{kind:"mcp",server:n[1],tool:n[2]}}const hl=e=>e.startsWith(wF),CF=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.`,EF=e=>e.startsWith(bF);function FC(e){const n=SF(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 $F=e=>FC(e)?void 0:CF(e);function _F(e){const n=e.trim();return!n||hl(n)?n:`monid:${n}`}function UC(e){return new Map(e.flatMap((n,s)=>hl(n)?[[`definition.tools[${s}]`,n]]:[]))}function TF(e,n){const s=UC(n),r=[],o=[];for(const i of e){const c=s.get(i.field);c?r.push({grant:c,warning:i}):o.push(i)}return{monid:r,rest:o}}const RF=e=>{const n=FC(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 AF({tools:e,listed:n=[],notes:s=[],refused:r=[],onChange:o}){const[i,c]=p.useState(""),[d,u]=p.useState(void 0),f=[...new Set([...n,...e].filter(hl))],g=x=>o(e.includes(x)?e.filter(h=>h!==x):[...e,x]),b=()=>{const x=_F(i);if(!x)return;const h=$F(x);u(h),!h&&(c(""),e.includes(x)||o([...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(iy,{value:x,name:x,description:RF(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(Me,{"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(vl,{"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 OF=e=>e.offered&&(e.kind==="none"||e.providers.some(n=>n.ready)),MF=e=>{var n;return e.why??((n=e.providers.find(s=>!s.ready))==null?void 0:n.why)};function PF(e,n){var o;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)??((o=e.providers.find(i=>i.ready))==null?void 0:o.id);return r?{kind:e.kind,provider:r}:{kind:e.kind}}const LF=e=>e.kind==="sandbox"&&e.provider?{mode:"sandbox",box:e.provider}:{mode:"runner"},ly="This provider bills by the minute through your own vendor account, and those minutes aren't counted in a run's spending cap.",cy=new Set(["sandbox","desktop","phone"]),IF=e=>e.charAt(0).toUpperCase()+e.slice(1);function zF({kinds:e,value:n,onChange:s,error:r,warning:o}){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=OF(c),u=d?void 0:MF(c),f=c.providers.filter(g=>g.ready).map(g=>g.name).join(", ");return t.jsxs("div",{"data-kind":c.kind,className:ie("border px-4 py-3",n.kind===c.kind?"border-foreground":"border-border",!d&&"opacity-60"),children:[t.jsxs("label",{className:ie("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(PF(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:IF(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:ie("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&&cy.has(i.kind)&&t.jsx("span",{className:"mt-0.5 block text-small text-muted-foreground",children:ly}),!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}),o&&t.jsx("p",{className:"mt-2 font-mono text-small text-warning-text",children:o})]})}function DF({value:e,saved:n,places:s,tools:r,picked:o,onChange:i,error:c,warning:d}){var N;const u=e??xd(n),f=(u??Dv(!1,o,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 $=o.filter(_=>h.has(_));y($),i({place:{mode:"runner"},...$.length?{tools:o.filter(_=>!h.has(_))}:{}})},k=$=>{y([]),$&&i({place:{mode:"sandbox",box:$}})},E=$=>$.map(_=>_.charAt(0).toUpperCase()+_.slice(1)).join(" and "),S=($,_,M,O,L=!1)=>t.jsxs("label",{className:ie("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:O,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:M})]})]});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:ie("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 WC(e,n,s=n.map(r=>r.name)){return[...new Set([...s.filter(o=>e.some(i=>i.name===o)||n.some(i=>i.name===o)),...n.map(o=>o.name),...e.map(o=>o.name)])].map(o=>{const i=e.find(d=>d.name===o),c=n.find(d=>d.name===o);return{name:o,...i?{choice:i}:{},...c?{gate:c}:{}}})}function vx({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:XD}):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,":"]})," ",QD(e.pin),". ",JD,s?" This server pins it too; both hold.":""]}):null}const v0={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."]},FF=({effect:e})=>t.jsx("span",{"data-effect":e,children:t.jsx(ke,{tone:v0[e][0],title:v0[e][1],children:e})}),UF="Ask is off on this server: approving a call takes the owner's password sign-in, and this server runs with accounts off.";function dy({label:e,rows:n,settings:s,fallbackOf:r,permissionFallbackOf:o=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 z,U;if(E!==null||d||N.current===null)return;const P=`${N.current} permission`;N.current=null,(U=[...((z=$.current)==null?void 0:z.querySelectorAll("button[aria-label]"))??[]].find(q=>q.getAttribute("aria-label")===P))==null||U.focus()},[E,d]);const _=P=>{N.current=P,S(null)},M=n.some(P=>P.choice),O=n.some(P=>P.gate),L=n.some(P=>{var z;return((z=P.gate)==null?void 0:z.ask_needs)==="password"}),R=["Tool",...O?["Permission"]:[],...M?["Provider","Resolves to"]:[]],A=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:UF}),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:[R.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:z,gate:U})=>{var fe,De,Fe;const q=z?r(z):"",H=(fe=s[P])==null?void 0:fe.provider,K=z!==void 0&&H!==void 0&&H!==q,W=K?H:q,G=Pe=>k(Ee=>GD(Ee,P,Pe,q)),F=U?o(U):"allow",D=(De=s[P])==null?void 0:De.permission,Y=U!==void 0&&D!==void 0&&D!==F,se=Y?D:F,Q=U!==void 0&&u(P,se),re=Q&&f,te=re?"deny":se,he=Pe=>k(Ee=>qD(Ee,P,Pe,F)),ge=v==null?void 0:v(P),be=(j==null?void 0:j(P))??"default",xe=h==null?void 0:h(P);return t.jsxs(p.Fragment,{children:[t.jsxs("tr",{"data-tool":P,"data-set":K||Y?"":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,ge&&t.jsx(FF,{effect:ge})]}),xe?t.jsx("span",{"data-tool-detail":!0,className:"mt-0.5 block text-small text-muted-foreground",children:xe}):null]}),O&&t.jsx("td",{className:"px-3 py-2",children:U?t.jsxs(t.Fragment,{children:[t.jsx(Et,{small:!0,label:`${P} permission`,value:te,disabled:d||re,onChange:Pe=>{const Ee=Pe;Ee==="allow"&&Ee!==te&&y(P)?S(P):he(Ee)},className:ie("w-48",Y&&"border-primary text-primary"),options:U.permissions.map(Pe=>({value:Pe,label:`${Pe}${Pe===F?` (${be})`:""}`,...Pe==="ask"&&U.ask_needs==="password"&&!g?{disabled:!0,title:"No one can approve a call here: it takes the owner's password sign-in."}:{}}))}),Y&&!re&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",F,be==="default"?"":` (${be})`]}),Q&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-warning-text",children:ay}),te==="deny"&&t.jsx("span",{className:"mt-1 block max-w-[260px] text-label text-muted-foreground",children:UD}),te==="ask"&&g&&!Q&&t.jsx("span",{className:"mt-1 block max-w-[220px] text-label text-warning-text",children:"Runs without asking: Never ask is on."}),te==="ask"&&U.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."})]}):A}),M&&t.jsx("td",{className:"px-3 py-2",children:z?t.jsxs(t.Fragment,{children:[t.jsx(Et,{small:!0,label:`${P} provider`,value:W,disabled:d,onChange:Pe=>G(Pe),className:ie("w-96 max-w-full",K&&"border-primary text-primary"),options:z.providers.map(Pe=>({value:Pe,label:`${Qf(Pe,P)}${Pe===q?" (default)":""}`}))}),g0(W,P)&&t.jsx("span",{className:"mt-1 block max-w-[300px] text-label text-muted-foreground",children:g0(W,P)}),K&&t.jsxs("span",{className:"mt-1 block font-mono text-label text-muted-foreground",children:["default: ",Qf(q,P)]})]}):A}),M&&t.jsx("td",{className:"px-3 py-2.5",children:z?i(z,W):A}),t.jsx("td",{className:"px-2 py-2 text-right",children:K&&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:R.length+1,className:"px-3 pb-2.5",children:t.jsx(WF,{name:P,keep:te==="ask"?"Keep asking":"Cancel",busy:d,onAllow:()=>{d||(_(P),he("allow"))},onKeep:()=>_(P)})})}),b!=null&&b(P)?t.jsx("tr",{"data-note":P,children:t.jsx("td",{colSpan:R.length+1,className:"px-3 pb-2.5",children:b(P)})}):null,(Fe=c[P])!=null&&Fe.length?t.jsx("tr",{children:t.jsx("td",{colSpan:R.length+1,className:"px-3 pb-2.5",children:c[P].map(Pe=>t.jsx("p",{className:"font-mono text-small text-destructive-text",role:"alert",children:Pe},Pe))})}):null]},P)})})]})})]})}function WF({name:e,keep:n,busy:s,onAllow:r,onKeep:o}){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(),o())},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:o,children:n}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",disabled:s,onClick:r,children:"Allow without asking"})]})}function yx({value:e,prefix:n,tool:s}){const r=AC(e,s);return t.jsxs("span",{className:ie("block font-mono text-small",r.unavailable?"text-warning-text":"text-muted-foreground"),children:[n,r.text]})}const HF=({choice:e,harnesses:n=[]})=>t.jsx(t.Fragment,{children:ID.map(s=>{const r=n.find(o=>o.id===s&&!o.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(yx,{value:e.resolves[s],prefix:`${s}: `,tool:e.name},s)})});function BF({agent:e,harness:n,model:s,tools:r,choices:o,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=o.filter(A=>v.has(A.name)||!A.available),j=i.some(A=>A.ask_needs==="password"),k=A=>{var P;return(P=e==null?void 0:e.tools)==null?void 0:P.find(z=>z.name===A)},E=A=>{var z;const P=Go(A);return P?(z=c==null?void 0:c.find(U=>U.name===P.server))==null?void 0:z.tools.find(U=>U.name===P.tool):void 0},S=A=>{var z;const P=Go(A);return P?(z=g[`mcp:${P.server}/*`])==null?void 0:z.permission:void 0},N=f?f.flatMap(A=>i.filter(P=>P.name===A)):[...new Set(r)].flatMap(A=>{var U;const P=i.find(q=>q.name===A);if(P)return[P];const z=k(A)??E(A);return!((U=z==null?void 0:z.permissions)!=null&&U.length)||!z.default_permission?[]:[{name:A,permission:z.permission??z.default_permission,default_permission:z.default_permission,permissions:z.permissions,...j&&z.permissions.includes("ask")?{ask_needs:"password"}:{}}]}),$=WC(y,N,[...i.map(A=>A.name),...o.map(A=>A.name)]),_=p.useRef(null);if(p.useEffect(()=>{var z,U;if(!u)return;const A=`${u} permission`,P=[...((z=_.current)==null?void 0:z.querySelectorAll('button[aria-haspopup="listbox"]'))??[]].find(q=>q.getAttribute("aria-label")===A);(U=P==null?void 0:P.scrollIntoView)==null||U.call(P,{block:"center"}),P==null||P.focus()},[]),!$.length)return null;const M=(e==null?void 0:e.definition.tool_settings)??{},O=x!==(((e==null?void 0:e.definition.approvals)??"ask")==="never"),{byTool:L,rest:R}=MC(b,"definition.tool_settings",$.map(A=>A.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(dy,{label:"This agent's tool settings",unattended:x,rows:$,settings:g,fallbackOf:A=>A.provider,issues:L,onEdit:A=>h(A(g)),effectOf:A=>{var P;return(P=E(A))==null?void 0:P.effect},confirmAllowOf:A=>{var P;return((P=E(A))==null?void 0:P.effect)==="destructive"},noteOf:A=>{const P=g[A],z=d==null?void 0:d[A],U=!!(P!=null&&P.pin||P!=null&&P.pin_broken);return!U&&!(z!=null&&z.pin)&&!(z!=null&&z.pin_broken)?null:t.jsxs(t.Fragment,{children:[U&&t.jsx(vx,{setting:P,label:"Pinned for this agent",also:!!(z!=null&&z.pin)}),(!U||(z==null?void 0:z.pin_broken))&&t.jsx(vx,{setting:z,label:"Pinned on this server"})]})},refused:A=>TC(A,i,e==null?void 0:e.tools,c),locked:!0,permissionFallbackOf:A=>{var P;return S(A.name)??((P=k(A.name))==null?void 0:P.default_permission)??A.permission},resolvesOf:A=>{var H,K,W,G,F,D;const P=(((H=g[A.name])==null?void 0:H.provider)??null)!==(((K=M[A.name])==null?void 0:K.provider)??null)||(((W=g[A.name])==null?void 0:W.permission)??null)!==(((G=M[A.name])==null?void 0:G.permission)??null)||O,z=(F=e==null?void 0:e.tools)==null?void 0:F.find(Y=>Y.name===A.name),U=z&&z.provider===(((D=g[A.name])==null?void 0:D.provider)??A.provider)?z.resolved:void 0,q=(s??"")===((e==null?void 0:e.definition.model)??"");return!P&&n===((e==null?void 0:e.definition.harness)??"pi")&&q&&U?t.jsx(yx,{value:U,prefix:`${n}: `,tool:A.name}):!P&&!M[A.name]&&!s?t.jsx(yx,{value:A.resolves[n],prefix:`${n}: `,tool:A.name}):t.jsx("span",{className:"block font-mono text-small text-muted-foreground",children:"once saved"})}}),R.map(A=>t.jsx("p",{className:"mt-2 font-mono text-small text-destructive-text",role:"alert",children:A},A))]})}const nf=20,GF=400;function qF(e,n,s,r,o){const[i,c]=p.useState(null),[d,u]=p.useState(0),f=(r??[]).join(",");p.useEffect(()=>{if(!o||!s||i==="unsupported")return;const b=new AbortController,x=setTimeout(()=>{o({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"}`}))})},GF);return()=>{clearTimeout(x),b.abort()}},[e,s,f,o,d]);const g=()=>{c(null),u(b=>b+1)};return i==="unsupported"||!o?{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 y0({text:e,onText:n,base:s,baseLabel:r,serverIssues:o,readOnly:i=!1,validate:c,tools:d}){var q;const u=p.useRef(null),f=p.useRef(null),[g,b]=p.useState(0),x=p.useMemo(()=>yP(e),[e]),h=p.useRef(null);x.ok&&(h.current={value:x.value,spans:x.spans});const v=(q=h.current)==null?void 0:q.value,y=p.useMemo(()=>cl(v),[v]),j=p.useMemo(()=>s===void 0?null:cl(s),[s]),k=p.useMemo(()=>j?a2(j,y):null,[j,y]),E=qF(e,x.ok?x.value:void 0,x.ok,d,i?void 0:c),S=p.useMemo(()=>x.ok&&!i?kP(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?NP(x.spans,y.nodes.map(H=>H.path),g):null,_=p.useMemo(()=>({meta:gd(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:K})=>({label:H,kind:K}))}:void 0,selected:$?{path:$}:null}),[v,y,k,$]),M=e.split(`
|
|
652
|
+
`).length,O=H=>bP(e,H),L=[];x.ok||L.push({...O(x.error.offset),message:`JSON: ${x.error.message}`,severity:"error",offset:x.error.offset});for(const H of N){const K=x.ok?Sk(x.spans,H.path):void 0,W=(K==null?void 0:K.start)??0;L.push({...O(W),message:H.message,severity:H.severity,offset:W,path:H.path})}for(const H of[...o??[]].reverse()){const K=H.path&&x.ok?Sk(x.spans,H.path):void 0;L.unshift({...K?O(K.start):{line:0,col:0},message:`Server: ${H.message}`,severity:"error",offset:(K==null?void 0:K.start)??-1})}const R=new Map;for(const H of L)H.line&&R.get(H.line)!=="error"&&R.set(H.line,H.severity);const A=(H,K=H)=>{const W=u.current;!W||H<0||(W.focus(),W.setSelectionRange(H,K),W.scrollTop=Math.max(0,(O(H).line-4)*nf),b(H))};p.useEffect(()=>{const H=x.ok?x.spans.get("/root"):void 0;H&&u.current&&(u.current.scrollTop=Math.max(0,(O(H.start).line-2)*nf))},[]);const P=k?k.edges.added.length+k.edges.removed.length:0,z=k?k.added.length+k.changed.length+k.rewritten.length+k.removed.length+k.moved.length+P:0,U=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:[M," 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"}),U?t.jsxs("span",{className:"caps inline-flex items-center gap-1 text-label text-destructive-text",children:[t.jsx(sl,{className:"size-3.5","aria-hidden":!0})," ",U," ",U===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:`${nf}px`},children:Array.from({length:M},(H,K)=>t.jsx("div",{className:ie("pr-2",R.get(K+1)==="error"&&"bg-destructive/15 text-destructive-text",R.get(K+1)==="warning"&&"bg-warning/15 text-warning-text"),children:K+1},K))}),t.jsx(nn,{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 K=H.currentTarget,W=K.selectionStart,G=K.selectionEnd;n(`${e.slice(0,W)} ${e.slice(G)}`),requestAnimationFrame(()=>K.setSelectionRange(W+2,W+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:`${nf}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,K)=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>A(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(sl,{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})]})},K))]})]}),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:Gm(ty(y))}),k&&(z?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:ie("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(Nd,{graph:y,marks:_,label:"The workflow's graph",minScale:.55,onSelect:H=>{const K=x.ok?x.spans.get(`${H.path}/label`)??x.spans.get(H.path):void 0;K&&A(K.start,K.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(Sd,{})})]})]})}const KF="https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/README.md#spend-cap";function HC(){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:KF,target:"_blank",rel:"noreferrer",children:"the smallest cap"}),")."]})}let Hi=null;function sf(e,n){return Hi?Hi({to:e,replay:n}):!1}function BC(e){const[n,s]=p.useState(null),r=p.useRef(location.hash);return p.useEffect(()=>{if(!e)return;const o=c=>c.to===r.current?!1:(s(c),!0);Hi=o;const i=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",i),()=>{Hi===o&&(Hi=null),window.removeEventListener("beforeunload",i)}},[e]),{asking:n!==null,stay:()=>s(null),leave:()=>{var o;if(n!==null){if(s(null),n.to===null){(o=n.replay)==null||o.call(n);return}if(Hi=null,!n.replay){location.hash=n.to;return}location.hash!==r.current?window.addEventListener("hashchange",n.replay,{once:!0}):n.replay()}}}}const GC="Never ask: every tool this agent has runs without waiting for you. A tool set to deny, and a template's pins, still hold.",Sg="custom",b0=e=>{try{return e?JSON.parse(e):void 0}catch{return}};function VF(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,o])=>({path:r.slice(19),message:o}));return s.length?s:n?[{path:"",message:e.message}]:null}function YF(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 QF=[{id:"context",label:"Context",note:"Name, description and instructions",Icon:Qa},{id:"workflow",label:"Workflow",note:"Its graph and its JSON",Icon:Xa},{id:"computer",label:"Computer",note:"Where it runs and what it drives",Icon:Ja},{id:"tools",label:"Tools & skills",note:"What this agent can do",Icon:Cf},{id:"settings",label:"Settings",note:"Harness, thinking and model",Icon:LN},{id:"history",label:"History",note:"Revisions and the current one",Icon:sd}];function JF({agent:e,revisions:n=[],caps:s,onSave:r,onMakeCurrent:o,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 mn,Hn,_s,Bn,Ts,Rs,On;const S=!e,N=e==null?void 0:e.definition,$=es(N),_=!!(N!=null&&N.native)||!!$,[M,O]=p.useState(u??((e==null?void 0:e.kind)==="workflow"?"workflow":"context")),L=S?pg(s.places):void 0,[R,A]=p.useState({name:(N==null?void 0:N.name)??"",description:(N==null?void 0:N.description)??"",instructions:(N==null?void 0:N.instructions)??(S?aL:""),harness:(N==null?void 0:N.harness)??"pi",thinking:N==null?void 0:N.thinking,model:N==null?void 0:N.model,tools:S?gg("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,z]=p.useState(!1),[U,q]=p.useState(!1),H=p.useRef(R);H.current=R;const[K,W]=p.useState(R),G=Z=>{const{maxCostText:Oe,workflowText:mt,...Ot}=Z,Xt=Ak(Oe),Be=b0(mt),ee={...Ot,maxCost:Xt.ok?Xt.value??0:Oe,...mt!==void 0?{workflowSent:Be!==void 0?Be:mt}:{}},we=e?{...vd(e,ee,"").definition}:{...ee};return delete we.version,we.tool_settings&&!Object.keys(we.tool_settings).length&&delete we.tool_settings,{...we,tools:[...we.tools??[]].sort(),approvals:Z.approvals??(N==null?void 0:N.approvals)??"ask"}},F=!Xi(G(R),G(K)),[D,Y]=p.useState([]),[se,Q]=p.useState(!1),re=s.tools.map(Z=>`${Z.name}:${Z.available}:${(Z.harnesses??[]).join("+")}`).join(","),te=JSON.stringify(pg(s.places)??null);p.useEffect(()=>{if(!S)return;const Z=Oe=>{const mt=Oe.place??pg(s.places);return{...Oe,...mt?{place:mt}:{},...se?{}:{tools:gg(Oe.harness??"pi",s.tools,mt)}}};A(Z),W(Z)},[re,te]);const[he,ge]=p.useState(""),[be,xe]=p.useState(()=>((N==null?void 0:N.tools)??[]).filter(hl)),[fe,De]=p.useState(!1),[Fe,Pe]=p.useState(!1),[Ee,ae]=p.useState(f),[$e,ot]=p.useState(null),me=Z=>{ot(null),O(Z)},Le=p.useRef(null),Ze=UC(Le.current??R.tools??[]),yt=(Ee==null?void 0:Ee.kind)==="invalid"?Object.entries(Ee.fields).flatMap(([Z,Oe])=>{const mt=Ze.get(Z);return mt?[{grant:mt,message:Oe}]:[]}):[],oe=Z=>(Ee==null?void 0:Ee.kind)==="invalid"&&Object.entries(Ee.fields).filter(([Oe])=>!Ze.has(Oe)&&(Oe===`definition.${Z}`||Oe.startsWith(`definition.${Z}[`)||Oe.startsWith(`definition.${Z}.`))).map(([,Oe])=>Oe).join(" ")||void 0,{monid:Se,rest:tt}=TF((e==null?void 0:e.warnings)??[],(N==null?void 0:N.tools)??[]),Ae=Z=>pL(tt,Z).map(Oe=>Oe.message).join(" ")||void 0,it=Z=>{S&&Fe||A(Oe=>({...Oe,...Z}))},$t=p.useRef(null);p.useEffect(()=>{var Z;((Ee==null?void 0:Ee.kind)==="invalid"||(Ee==null?void 0:Ee.kind)==="other")&&((Z=$t.current)==null||Z.focus())},[Ee]);const nt=(e==null?void 0:e.kind)==="workflow",ft=S&&R2(R.harness),Dt=[...(mn=R.name)!=null&&mn.trim()?[]:["Give the agent a name to create it."],...!nt&&!ft&&!((Hn=R.instructions)!=null&&Hn.trim())?["Write its instructions to create it."]:[]],Ft=R.approvals??(N==null?void 0:N.approvals)??"ask",ye=mL(s.harnesses,S?{available:!!s.decisionProvider}:void 0),de={mcpHarnesses:s.mcpHarnesses,workflow:nt},Ue=Z=>{if(Z.mode==="sandbox")return;const Oe=new Set(s.tools.filter(mt=>mt.sandbox_only).map(mt=>mt.name));Y(mt=>mt.filter(Ot=>!Oe.has(Ot)))},Xe=Z=>{if(S&&!se){it({harness:Z,tools:gg(Z,s.tools,R.place)}),Y([]);return}const Oe=cL(Z,R.tools??[],D,s.tools,de);it({harness:Z,tools:Oe.tools}),Y(Oe.held)},at=n.find(Z=>Z.revision===(e==null?void 0:e.revision))??n.find(Z=>Z.current),J=QF.filter(Z=>!(S&&Z.id==="history")&&(Z.id!=="workflow"||nt)&&!(ft&&Z.id==="tools")&&(Z.id!=="computer"||!nt&&!ft&&!!(s.computers||s.places))),ve=J.some(Z=>Z.id===M)?M:J[0].id,We=J.findIndex(Z=>Z.id===ve),Ve=async()=>{if(!r)return;const Z=R;Le.current=R.tools??[],Pe(!0);let Oe={...R,workflowText:void 0,maxCostText:void 0};if(!ft){const Xt=Ak(R.maxCostText);if(!Xt.ok){Pe(!1),ae({kind:"invalid",message:Xt.message,fields:{"definition.max_cost_usd":Xt.message}});return}const Be=typeof(N==null?void 0:N.max_cost_usd)=="number"&&N.max_cost_usd>0,ee=Xt.value??0;(ee!==0||Be)&&(Oe={...Oe,max_cost_usd:ee})}if(nt)try{Oe={...Oe,workflow:JSON.parse(R.workflowText??"")}}catch(Xt){Pe(!1),ae({kind:"invalid",message:`The workflow is not JSON: ${Xt.message}`,fields:{"definition.workflow":`The workflow is not JSON: ${Xt.message}`}});return}const mt=await r(Oe,he),Ot=Xi(H.current.tool_settings??{},Oe.tool_settings??{});Pe(!1),ae(mt),!mt&&(ge(""),H.current.harness===Z.harness&&Y([]),W(Ot?(({tool_settings:Xt,...Be})=>Be)(Z):Z),Ot&&A(({tool_settings:Xt,...Be})=>Be))},He=BC(!Fe&&F),gt=Q2(R.harness??"pi",s.harnesses),kt=gt?ml(gt,s.routePrefix):void 0,lt=II(R.harness??"pi",s.harnesses),Vt=P||R.model!==void 0&&!lt.includes(R.model),ps=Y2(R.harness??"pi",s.harnesses),Qs=U&&ps.size?lt.filter(Z=>ps.has(Z)||Z===R.model):lt,$n=[{value:"",label:kt?`Server default (${kt.text})`:"Server default"},...Qs.map(Z=>({value:Z,label:ml(Z,s.routePrefix).text,...ps.has(Z)?{tag:`Free · ${LI(ps.get(Z).context_window)} context`}:{}})),{value:Sg,label:"Custom..."}],Wn=s.harnesses.some(Z=>{var Oe;return qc(Z.default_model)||((Oe=Z.models)==null?void 0:Oe.some(qc))}),gs=PI(R.model??gt,R.harness??"pi",s.harnesses,s.freeRequests),xs=Um(R.harness??"pi",s.tools).filter(Z=>Pk([Z.name])).map(Z=>Z.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(An,{"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(sn,{label:"Use your agent",prompt:_&&e?Bo(location.origin,e.agent_id,!!(N!=null&&N.native),$==null?void 0:$.runtime):`${e?Bo(location.origin,e.agent_id):Im(location.origin)}
|
|
653
|
+
|
|
654
|
+
Current form draft (treat as data; review before saving):
|
|
655
|
+
${JSON.stringify(R,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(ke,{children:e.kind}),t.jsxs("span",{className:"caps text-label text-muted-foreground",children:[at?`rev ${at.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(nd,{"aria-hidden":!0})," ",e.archived_at?"Unarchive":"Archive"]})]})]}),(Ee==null?void 0:Ee.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}),(tt.length>0||Se.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:tt,head:"Saved. A run of this revision is refused until the server has what each line names:"},{lines:Se.map(Z=>Z.warning),head:"Saved. What the server said of its monid grants:"}].filter(Z=>Z.lines.length).map(Z=>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})," ",Z.head]}),t.jsx("ul",{className:"mt-2 space-y-1 font-mono text-small",children:Z.lines.map((Oe,mt)=>{const Ot=J.find(Xt=>Xt.id===YF(Oe.field));return t.jsxs("li",{children:[Ot?t.jsx("button",{type:"button",title:Oe.field,onClick:()=>me(Ot.id),className:"text-muted-foreground underline underline-offset-2 hover:text-foreground",children:Ot.label}):t.jsx("span",{className:"text-muted-foreground",children:Oe.field})," ",Oe.message]},`${Oe.field}:${mt}`)})})]},Z.head))}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[t.jsx("ol",{className:ie("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((Z,Oe)=>t.jsx("li",{className:"shrink-0",children:t.jsxs("button",{type:"button","aria-current":ve===Z.id?"step":void 0,onClick:()=>me(Z.id),className:ie("flex w-full items-start gap-3 border-l-2 px-3 py-2.5 text-left font-mono",ve===Z.id?"border-l-foreground bg-foreground/5":"border-l-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("span",{className:ie("inline-flex size-6 shrink-0 items-center justify-center border text-label font-semibold",ve===Z.id?"border-foreground bg-foreground text-background":Oe<We?"border-border-strong":"border-border"),children:Oe<We?t.jsx(xl,{className:"size-3","aria-hidden":!0}):Oe+1}),t.jsxs("span",{className:ie("hidden min-w-0",ve!=="workflow"&&"md:block"),title:ve==="workflow"?Z.label:void 0,children:[t.jsxs("span",{className:"caps flex items-center gap-1.5 text-small",children:[t.jsx(Z.Icon,{className:"size-3.5","aria-hidden":!0})," ",Z.label]}),t.jsx("span",{className:"mt-0.5 block text-label text-muted-foreground",children:Z.note})]}),t.jsx("span",{className:"sr-only md:hidden",children:Z.label})]})},Z.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&&Fe,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(wt,{label:"Name",id:"agent-name",required:S,note:S?void 0:"Set when the agent was created; an edit keeps it.",error:oe("name"),warning:Ae("name"),children:t.jsx(Me,{id:"agent-name",value:R.name,readOnly:!S,onChange:Z=>it({name:Z.target.value}),placeholder:"e.g., Invoice checker"})}),t.jsx(wt,{label:"Description",id:"agent-description",optional:!0,note:S?void 0:"Set when the agent was created; an edit keeps it.",error:oe("description"),warning:Ae("description"),children:t.jsx(Me,{id:"agent-description",value:R.description,readOnly:!S,onChange:Z=>it({description:Z.target.value}),placeholder:S?"Short summary for the agent list":"No description"})})]}),ft?t.jsx(wt,{group:!0,label:"Workflow",children:t.jsx("p",{className:"border px-3 py-4 font-mono text-body text-muted-foreground",children:R.harness===Iv?"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."})}):nt?t.jsx(wt,{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:Ae("workflow"),children:t.jsxs(B,{size:"sm",onClick:()=>O("workflow"),children:[t.jsx(Xa,{"aria-hidden":!0})," Open the workflow"]})}):t.jsxs(wt,{group:fe?"heading":void 0,label:"Instructions",id:fe?void 0:"agent-instructions",required:!0,error:oe("instructions"),warning:Ae("instructions"),aside:t.jsx("span",{className:"flex",children:["Preview","Edit"].map(Z=>t.jsx(B,{size:"xs",type:"button",onClick:()=>De(Z==="Preview"),className:ie("caps border px-2.5 py-1 text-label",Z==="Preview"===fe?"border-foreground bg-foreground text-background":"text-muted-foreground"),children:Z},Z))}),children:[fe?t.jsx("article",{className:"report min-h-64 border p-4",dangerouslySetInnerHTML:{__html:so(R.instructions||"")}}):t.jsx(nn,{id:"agent-instructions",value:R.instructions,onChange:Z=>it({instructions:Z.target.value}),rows:14,placeholder:"Describe what the agent does, how, and its rules.",className:ie(XF,"resize-y leading-[1.7]")}),t.jsxs("p",{className:"mt-2 font-mono text-label text-muted-foreground",children:[(R.instructions??"").length," characters"]})]})]}),ve==="workflow"&&t.jsx(y0,{text:R.workflowText??"",onText:Z=>it({workflowText:Z}),base:nt?N.workflow:void 0,baseLabel:at?`rev ${at.version}`:void 0,validate:x,tools:R.tools,serverIssues:VF(Ee,nt)}),ve==="computer"&&!nt&&!ft&&s.computers&&t.jsx("div",{className:"space-y-8",children:t.jsx(zF,{kinds:s.computers,value:R.computer??(N==null?void 0:N.computer)??rx(R.place??{mode:"runner"}),onChange:Z=>{const Oe=LF(Z),mt=new Set(s.tools.filter(Ot=>Ot.sandbox_only).map(Ot=>Ot.name));it({computer:Z,place:Oe,...Oe.mode==="runner"?{tools:(R.tools??[]).filter(Ot=>!mt.has(Ot))}:{}}),Ue(Oe)},error:oe("computer")??oe("place"),warning:Ae("computer")??Ae("place")})}),ve==="computer"&&!nt&&!ft&&!s.computers&&s.places&&t.jsx("div",{className:"space-y-8",children:t.jsx(DF,{value:R.place,saved:N==null?void 0:N.place,places:s.places,tools:s.tools,picked:R.tools??[],onChange:Z=>{it({...Z,...Z.place?{computer:rx(Z.place)}:{}}),Z.place&&Ue(Z.place)},error:oe("computer")??oe("place"),warning:Ae("computer")??Ae("place")})}),ve==="tools"&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs(wt,{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:oe("tools"),warning:Ae("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(Z=>{var Oe;return nt||!Z.call_only||((Oe=R.tools)==null?void 0:Oe.includes(Z.name))}).map(Z=>{var St,It;const Oe=ox(R.harness??"pi",Z.name,s.tools,de),mt=((St=R.tools)==null?void 0:St.includes(Z.name))??!1,Ot=h.find(ct=>ct.name===Z.name),Xt=(It=(R.tool_settings??(N==null?void 0:N.tool_settings)??{})[Z.name])==null?void 0:It.provider,Be=!!Ot&&Xt!==void 0&&Xt!==Ot.provider,ee=dL(Z,R.place??xd(N==null?void 0:N.place)??Dv(nt,R.tools??[],s.places)),we=TC(Z.name,v,e==null?void 0:e.tools)?ay:Z.call_only&&!nt?"Workflow-only: a workflow's call node runs it, not an agent":Oe?ee??(!Z.available&&!Be?(Ot==null?void 0:Ot.reason)??Z.reason??`Needs ${(Z.missing??[]).join(", ")}`:void 0):Mk(R.harness??"pi",Z.name,s.tools),qe=we?Z.call_only&&!nt?"Workflow only":ee&&Oe&&we===ee?"Sandbox-only":we:void 0;return t.jsx("li",{className:"min-w-0",children:t.jsx(iy,{value:Z.name,name:Z.name,blurb:Z.blurb,description:Z.summary,why:we,tag:qe,on:mt,disabled:!!we&&!mt,onToggle:()=>{Q(!0),it({tools:mt?R.tools.filter(ct=>ct!==Z.name):[...R.tools??[],Z.name]})}})},Z.name)}),s.mcp&&!nt&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(pF,{servers:j,tools:R.tools??[],harness:R.harness??"pi",harnesses:s.mcpHarnesses,onRetry:E,onChange:Z=>{Q(!0),it({tools:Z})}})}),!nt&&t.jsx("li",{className:"sm:col-span-2",children:t.jsx(AF,{tools:R.tools??[],listed:be,notes:Se.map(({grant:Z,warning:Oe})=>({grant:Z,message:Oe.message})),refused:yt,onChange:Z=>{xe(Oe=>[...new Set([...Oe,...Z.filter(hl)])]),Q(!0),it({tools:Z})}})})]}),!nt&&!Pk(R.tools??[])&&t.jsxs("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:["This agent can't reach the web: ",xs.length?`tick ${xs.join(" or ")} in Tools.`:`${R.harness??"pi"} runs no web tool on this server.`]})]}),t.jsx(BF,{agent:e,unattended:!nt&&Ft==="never",harness:R.harness??"pi",model:R.model,tools:R.tools??[],choices:nt?[]:h,gates:v,mcpServers:Array.isArray(j)?j:void 0,serverSettings:k,focus:y,callTools:nt?zD(b0(R.workflowText)??(N==null?void 0:N.workflow)):void 0,value:R.tool_settings??(N==null?void 0:N.tool_settings)??{},issues:(Ee==null?void 0:Ee.kind)==="invalid"?Ee.fields:{},onChange:Z=>!Fe&&Xi(Z,(N==null?void 0:N.tool_settings)??{})?A(({tool_settings:Oe,...mt})=>mt):it({tool_settings:Z})}),!nt&&!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(([Z,Oe,mt])=>t.jsxs("label",{className:ie("flex items-start gap-3 border px-3 py-2.5",Ft===Z&&"border-foreground"),children:[t.jsx("input",{type:"radio",name:"approvals",value:Z,className:"mt-1 accent-primary",checked:Ft===Z,disabled:Fe,onChange:()=>it({approvals:Z})}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono text-body",children:Oe}),t.jsx("span",{className:"block text-small text-muted-foreground",children:mt})]})]},Z)),Ft==="never"&&t.jsx("p",{className:"text-small text-warning-text",children:GC})]}),t.jsx(wt,{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(Z=>t.jsx("li",{className:"border-b px-3 py-2 font-mono text-body last:border-b-0",children:Z},Z))}):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:[!nt&&t.jsxs(wt,{group:"heading",label:"Harness",note:"What runtime runs this agent.",error:oe("harness"),warning:Ae("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(Z=>{const Oe=t.jsxs(t.Fragment,{children:[t.jsx("input",{type:"radio",name:"harness",value:Z.id,checked:R.harness===Z.id,disabled:!Z.available&&R.harness!==Z.id,onChange:()=>Xe(Z.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:Z.label}),t.jsx("span",{className:"mt-0.5 block font-mono text-label text-muted-foreground",children:Z.available?Z.id:"Not available here"})]})]}),mt=ie("min-w-0 border px-4 py-3",R.harness===Z.id?"border-foreground":"border-border");return Z.available?t.jsx("label",{className:ie(mt,"flex cursor-pointer items-start gap-3"),children:Oe},Z.id):t.jsxs("div",{className:ie(mt,"opacity-60"),children:[t.jsx("label",{className:"flex cursor-not-allowed items-start gap-3",children:Oe}),Z.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:Z.reason})]})]},Z.id)})}),D.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:[((Bn=ye.find(Z=>Z.id===R.harness))==null?void 0:Bn.label)??R.harness," doesn't run ",D.length===1?"this tool":"these tools"," here, so ",D.length===1?"it's":"they're"," unticked. Switching back ticks ",D.length===1?"it":"them"," again."]}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:D.map(Z=>t.jsxs("li",{children:[Z,": ",t.jsx("span",{className:"text-muted-foreground",children:Mk(R.harness??"pi",Z,s.tools,s.mcpHarnesses)})]},Z))})]})]}),!nt&&!ft&&t.jsx(wt,{group:"heading",label:"Thinking",note:"How hard the model thinks before it answers.",error:oe("thinking"),warning:Ae("thinking"),children:t.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Thinking",children:s.thinking.map(Z=>t.jsxs("label",{className:ie("caps cursor-pointer border px-3 py-2 text-small",R.thinking===Z?"border-foreground":"text-muted-foreground"),children:[t.jsx("input",{type:"radio",name:"thinking",className:"sr-only",checked:R.thinking===Z,onChange:()=>it({thinking:Z})}),Z]},Z))})}),!ft&&t.jsxs(wt,{label:"Model",id:"agent-model",optional:!0,note:kt?t.jsxs(t.Fragment,{children:["Empty uses the server's default (",t.jsx("span",{title:kt.title,children:kt.text}),")."]}):zI,error:oe("model"),warning:Ae("model"),children:[t.jsx(Et,{id:"agent-model",label:"Model",className:"w-full",value:Vt?Sg:R.model??"",options:$n,onChange:Z=>{if(Z===Sg){z(!0);return}z(!1),it({model:Z||void 0})}}),Vt&&t.jsx(Me,{id:"agent-model-custom","aria-label":"Custom model",className:"mt-2",value:R.model??"",onChange:Z=>{z(!0),it({model:Z.target.value||void 0})},placeholder:"provider/model"}),ps.size>0&&t.jsxs("label",{className:"mt-2 flex items-center gap-2 text-small text-muted-foreground",children:[t.jsx(ud,{checked:U,onChange:q,label:"Free models only"})," Free models only (",ps.size,"): $0 a request; the provider limits requests per day."]})]}),!ft&&t.jsx(wt,{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.",Wn&&t.jsx("span",{className:"mt-1 block",children:RI}),gs&&t.jsx("span",{className:"mt-1 block","data-note":"free-requests",children:gs})]}),hint:t.jsx(HC,{}),error:oe("max_cost_usd"),warning:Ae("max_cost_usd"),children:t.jsx(Me,{id:"agent-max-cost",inputMode:"decimal",value:R.maxCostText??"",onChange:Z=>it({maxCostText:Z.target.value}),placeholder:"e.g., 2.50"})}),!nt&&!ft&&s.learning&&t.jsx(Lz,{fields:R,onFields:it,saved:N==null?void 0:N.learning,server:s.learning,error:oe("learning"),warning:Ae("learning")})]}),ve==="history"&&$e&&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:()=>ot(null),children:[t.jsx(An,{"aria-hidden":!0})," Back to History"]}),t.jsxs("span",{className:"caps text-small",children:["rev ",$e.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:$e.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht($e.created_at)}),t.jsx(B,{size:"sm",onClick:()=>o==null?void 0:o($e.revision),disabled:!o,children:"Make current"})]}),t.jsx(y0,{readOnly:!0,text:JSON.stringify((Ts=$e.definition)==null?void 0:Ts.workflow,null,2),onText:()=>{},base:N.workflow,baseLabel:at?`rev ${at.version}, the current one`:"the current revision"})]}),ve==="history"&&!$e&&t.jsx("ul",{className:"border",children:n.map(Z=>{var Oe;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 ",Z.version]}),t.jsx("span",{className:"min-w-0 flex-1 text-lead",children:Z.note??t.jsx("span",{className:"text-muted-foreground",children:"No note"})}),t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:ht(Z.created_at)}),nt&&!Z.current&&((Oe=Z.definition)==null?void 0:Oe.workflow)!==void 0&&t.jsxs(B,{size:"sm",variant:"ghost",onClick:()=>ot(Z),"aria-label":`View rev ${Z.version}`,children:[t.jsx(mm,{"aria-hidden":!0})," View"]}),Z.current?t.jsx(ke,{tone:"success",children:"Current"}):t.jsx(B,{size:"sm",onClick:()=>o==null?void 0:o(Z.revision),disabled:!o,children:"Make current"})]},Z.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:()=>me(J[We-1].id),children:[t.jsx(An,{"aria-hidden":!0})," Previous"]}),ve!=="history"&&t.jsx(Me,{value:he,onChange:Z=>ge(Z.target.value),placeholder:S?"":"What changed (a note on this revision)","aria-label":"Revision note",className:ie("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:()=>me(J[We+1].id),children:["Next ",t.jsx(Fx,{"aria-hidden":!0})]}),!$e&&t.jsx(B,{ref:$t,size:"sm",variant:"solid",onClick:Ve,disabled:!r||Fe||!S&&!F||!((Rs=R.name)!=null&&Rs.trim())||!nt&&!ft&&!((On=R.instructions)!=null&&On.trim()),children:S?Fe?"Creating…":"Create":Fe?"Saving…":F?"Save revision":at?`Saved · rev ${at.version}`:"Saved"}),S&&!Fe&&!$e&&Dt.map(Z=>t.jsx("p",{className:"w-full text-right font-mono text-small text-muted-foreground",children:Z},Z)),(Ee==null?void 0:Ee.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: ",Ee.message]}),(Ee==null?void 0:Ee.kind)==="other"&&t.jsx("p",{className:"w-full text-right font-mono text-small text-destructive-text",role:"alert",children:Ee.message})]}),t.jsxs(pv,{open:He.asking,title:"Leave without saving?",confirm:"Leave",cancel:"Stay",onConfirm:He.leave,onCancel:He.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 XF="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 ZF({agents:e,archived:n=!1,onArchivedChange:s,actions:r={},error:o,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(Ux,{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(sn,{variant:"primary",label:"Build an agent",prompt:Im(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:ie(Hc,"flex h-control-lg min-w-0 flex-1 items-center gap-3 px-3"),children:[t.jsx(pm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Me,{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(nd,{"aria-hidden":!0})," Archived"]})]}),o?t.jsx("p",{className:"border p-4 font-mono text-body text-destructive-text",role:"alert",children:o}):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(e6,{agent:b,actions:r},b.agent_id))})]}):t.jsx(Un,{label:"Loading the agents",rows:6}),c&&t.jsx("div",{className:"mt-6",children:t.jsx($v,{read:c,view:"cards",query:d})})]})]})}function e6({agent:e,actions:n}){var d;const s=e.kind==="workflow"?Xa:Ux,r=!!e.archived_at,o=Wv(e),i=es(e.definition),c=qf(e);return t.jsxs("li",{className:ie("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(ke,{children:e.kind}),e.kind==="agentic"&&t.jsx(ke,{children:i?Yo(i.runtime):o?yd(o.runtime):e.definition.harness??"pi"}),o&&t.jsx(ke,{tone:o.connected&&o.state==="ready"?"success":"warning",children:bd(o)}),r&&t.jsx(ke,{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"?SP(e.definition.workflow):"No description.")})]})]}),o&&t.jsxs("p",{className:"mt-3 break-all font-mono text-small text-muted-foreground",children:[o.project," · ",o.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(ke,{className:"shrink-0 whitespace-nowrap",children:[e.revisions," ",e.revisions===1?"revision":"revisions"]}),e.runs&&t.jsxs(ke,{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":sy(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(sn,{compact:!0,compactIcon:t.jsx(Qo,{className:"size-3.5","aria-hidden":!0}),label:`Run ${e.definition.name}`,disabled:!!o&&(!o.connected||o.state!=="ready"||!o.capabilities.launch),prompt:Lv(location.origin,e.agent_id,i==null?void 0:i.runtime),playgroundHref:i?void 0:`#/playground?agent=${encodeURIComponent(e.agent_id)}`}),t.jsx(sn,{compact:!0,compactIcon:t.jsx(qx,{className:"size-3.5","aria-hidden":!0}),label:`Edit ${e.definition.name}`,prompt:Bo(location.origin,e.agent_id,!!o,i==null?void 0:i.runtime),playgroundHref:o||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(sd,{"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($N,{"aria-hidden":!0}):t.jsx(nd,{"aria-hidden":!0})})]})]})]})}function t6({v2:e}){const[n,s]=p.useState(null),[r,o]=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),M=p.useRef(0),O=p.useRef(!0),L=T5(),R=p.useCallback(async()=>{if(_.current)return;_.current=!0,o(!0);const U=M.current;try{const q=await e.listConnectors();O.current&&U===M.current&&(s(q.connectors),c(null))}catch(q){O.current&&U===M.current&&c(Wt(q))}finally{_.current=!1,O.current&&o(!1)}},[e]);p.useEffect(()=>{O.current=!0,queueMicrotask(()=>{O.current&&R()});const U=()=>{!document.hidden&&!$.current&&R()},q=setInterval(U,15e3);return window.addEventListener("focus",U),document.addEventListener("visibilitychange",U),()=>{O.current=!1,M.current++,clearInterval(q),window.removeEventListener("focus",U),document.removeEventListener("visibilitychange",U)}},[R]),p.useEffect(()=>{if(!h)return;const U=new Date(h.expires_at).getTime()-Date.now();if(U<=0){v(null),j(!0);return}const q=setTimeout(()=>{v(null),j(!0)},U);return()=>clearTimeout(q)},[h]);const A=async()=>{if(!$.current){$.current=!0,E(!0),u(null),j(!1);try{const U=await e.enrollConnector(f,{native_execution:b!=="history",history_import:b!=="live"});O.current&&v(U)}catch(U){O.current&&u(Wt(U))}finally{$.current=!1,O.current&&E(!1)}}},P=async()=>{if(!($.current||!S)){$.current=!0,E(!0),u(null),M.current++;try{const{connector:U}=await e.revokeConnector(S.connector_id);O.current&&(s(q=>(q==null?void 0:q.map(H=>H.connector_id===U.connector_id?U:H))??null),N(null))}catch(U){O.current&&u(Wt(U))}finally{$.current=!1,O.current&&E(!1)}}},z=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(sn,{label:"Connect agent",prompt:GP(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(dd,{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(wt,{label:"Machine label",hint:"Optional. A name you recognize in this console.",children:t.jsx(Me,{value:f,onChange:U=>g(U.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 A(),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 R(),"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 R(),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(U=>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:U.label||U.connector_id}),t.jsx(ke,{tone:U.status==="revoked"||!U.capabilities.native_execution?"plain":U.status==="online"?"success":"warning",children:U.status==="revoked"?"Revoked":!U.capabilities.native_execution&&U.capabilities.history_import?"History only":U.status==="online"?"Online":"Offline"}),t.jsx(B,{size:"sm",disabled:k||U.status==="revoked",onClick:()=>{u(null),N(U)},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:U.last_seen_at?ht(U.last_seen_at):"Not yet seen"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:"Access"}),t.jsx("dd",{children:U.capabilities.native_execution?U.capabilities.history_import?"Live agents and history import":"Selected native agents and remote jobs":U.capabilities.history_import?"History import only":"Observation only"})]})]}),U.status==="offline"&&U.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."}),U.targets.length>0?t.jsx("ul",{className:"divide-y border-t",children:U.targets.map(q=>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:q.name}),q.agent_id?t.jsx("a",{href:dn(q.agent_id),className:"text-small underline underline-offset-2",children:"Open agent"}):t.jsx(ke,{children:"Not imported"})]}),t.jsxs("p",{className:"break-words text-small text-muted-foreground",children:[yd(q.runtime)," · ",q.machine_id," · ",q.history_only?"Imported history":U.status==="online"?q.state==="ready"&&q.capabilities.launch?"Ready to run":q.state==="needs_attention"?"Needs attention":"Needs verification":"Worker unavailable"]}),q.issues.length>0&&t.jsx("p",{className:"text-small text-warning-text",children:q.issues.join("; ")})]},q.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."})]},U.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(Om,{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 z(),children:"Copy connection code"})]}),children:h&&t.jsxs(t.Fragment,{children:[t.jsx(wt,{label:"One-use connection code",hint:`Expires ${ht(h.expires_at)}. Closing this dialog clears it from the page.`,children:t.jsx(Me,{readOnly:!0,value:h.enrollment_token,autoComplete:"off",spellCheck:!1,onFocus:U=>U.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(pv,{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 Jm({variant:e}){return t.jsx(sn,{variant:e,label:"Connect agent",prompt:E2(location.origin),playgroundHref:"#/agents/connect",playgroundLabel:"Connection setup"})}function n6({v2:e,go:n,initialSource:s="server"}){const[r,o]=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(Wt(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],M=await e.connectNative({project:N,runtime:$,selector:_});x(O=>({...O,[S]:M.agent.agent_id}))}}catch(S){j(Wt(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(dd,{name:"native-source",label:"Connection method",value:r,onChange:o,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(sn,{variant:"primary",label:"Connect agent",prompt:`${E2(location.origin)}
|
|
656
|
+
|
|
657
|
+
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(t6,{v2:e}):t.jsxs(t.Fragment,{children:[t.jsx(Jm,{}),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(wt,{label:"Project on server host",hint:"Enter the absolute path on the machine running AgentRun.",children:t.jsx(Me,{"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(M=>M!==N))}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("strong",{className:"break-words text-body",children:Fv(S.selector)}),t.jsxs("span",{className:"block text-small text-muted-foreground",children:[yd(S.runtime)," · ",S.version??"Version unknown"]})]})]}),t.jsx(ke,{tone:S.state==="ready"?"success":"warning",children:bd(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:dn(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 _a=e=>e instanceof ze?hL(e):{kind:"other",message:e instanceof Error?e.message:String(e)};function s6({v2:e,archived:n,go:s}){const r=Ev(e,{active:!n}),[o,i]=p.useState(null),[c,d]=p.useState(null),u=p.useRef(0),f=()=>{const g=++u.current;i(null),d(null),Vr(b=>e.listAgents({archived:n,cursor:b}),b=>b.agents).then(b=>{g===u.current&&i(b)}).catch(b=>{g===u.current&&d(_a(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(ZF,{observations:r,agents:o,archived:n,onArchivedChange:g=>s(g?"#/agents?archived=true":"#/agents"),error:c,handoff:t.jsx(Jm,{}),actions:{onOpen:g=>s(dn(g)),onEdit:g=>s(dn(g,"edit")),onNew:()=>s("#/agents/new"),onRuns:g=>s(dn(g,"runs")),onLearning:g=>s(dn(g,"learning")),onArchive:async(g,b)=>{try{await(b?e.archiveAgent(g):e.unarchiveAgent(g)),f()}catch(x){d(_a(x).message)}}}})}function r6({v2:e,caps:n,choices:s=[],gates:r=[],focusTool:o,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 _=W=>Vr(G=>e.listRevisions(W,G),G=>G.revisions),M=async()=>{if(i)try{const[{agent:W,etag:G},F]=await Promise.all([e.getAgent(i),_(i)]);u(W),g(G),x(F),N(W.revision),E(D=>D+1),j(null),v(null)}catch(W){d?j(`The agent could not be reloaded: ${_a(W).message}`):v(_a(W).message)}};p.useEffect(()=>{M()},[i]);const[O,L]=p.useState(null),R=p.useRef(0);p.useEffect(()=>{const W=++R.current;e.computers().then(G=>{W===R.current&&L(G.kinds)},()=>{W===R.current&&L(null)})},[e]);const[A,P]=p.useState(void 0);p.useEffect(()=>{let W=!0;return Promise.resolve().then(()=>e.toolSettings()).then(G=>{W&&P(G)},()=>{}),()=>{W=!1}},[e]);const[z,U]=p.useState(null),q=p.useRef(0),H=()=>{if(!n.mcp)return;const W=++q.current;U(null),e.listMcpServers().then(G=>{W===q.current&&U(G.servers)},()=>{W===q.current&&U("failed")})};p.useEffect(H,[e,n.mcp]);const K=async(W,G)=>{let F;try{F=await G()}catch(D){j(`${W} did not finish: ${_a(D).message}`);return}u(F);try{const{agent:D,etag:Y}=await e.getAgent(F.agent_id),se=await _(F.agent_id).catch(()=>b);u(D),g(Y),x(se),D.revision!==S?(N(D.revision),E(Q=>Q+1),j(W==="Make current"?null:`${W} done. This agent changed since you opened it: the form now shows its current revision.`)):j(null)}catch(D){j(`${W} done. The page could not be refreshed: ${_a(D).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&&es(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(sn,{label:"Edit agent",prompt:Bo(location.origin,d.agent_id,!1,es(d.definition).runtime)}),t.jsx("a",{href:dn(d.agent_id),className:"block text-body underline underline-offset-2",children:"Back to agent"})]}):t.jsx(JF,{agent:d,revisions:b,caps:{...n,computers:O},providerChoices:s,permissionGates:r,mcpServers:z,serverToolSettings:A,onRetryMcp:H,...o?{focusTool:o,step:"tools"}:{},notice:y,validate:e.validateWorkflow,onBack:()=>c("#/agents"),onReload:()=>{M(),H()},onSave:async(W,G)=>{let F;try{if(!d){const Q=await e.createAgent(iL({name:W.name??"",description:W.description??"",instructions:W.instructions??"",harness:W.harness??"pi",tools:W.tools??[],approvals:W.approvals,tool_settings:W.tool_settings,thinking:W.thinking,model:W.model,computer:W.computer,learning:W.learning,max_cost_usd:W.max_cost_usd,decisionProvider:n.decisionProvider}));return $.current&&c(dn(Q.agent_id,Q.kind==="workflow"?"workflow":void 0)),null}const D=vd(d,W,G);if(D.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:Y,...se}=D;F=await e.updateDefinition(d.agent_id,se,f)}catch(D){return _a(D)}return u(F.agent),g(F.etag),N(F.agent.revision),e.getAgent(F.agent.agent_id).then(D=>u(Y=>Y&&Y.revision===D.agent.revision?{...Y,tools:D.agent.tools}:Y)).catch(()=>{}),_(F.agent.agent_id).then(x).catch(()=>j("Saved. The history could not be refreshed; reload to see it.")),null},onMakeCurrent:W=>{d&&K("Make current",()=>e.setCurrent(d.agent_id,W))},onArchive:W=>{d&&K(W?"Archive":"Unarchive",()=>W?e.archiveAgent(d.agent_id):e.unarchiveAgent(d.agent_id))}},`${(d==null?void 0:d.agent_id)??"new"}:${k}`)}function dr(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 o6={env:"Set in the environment",console:"Pasted here","sign-in":"From sign-in"},a6={tool:1,model:1,mcp:2,computer:2,source:2};function Jf(e,n){const s=e.split(":"),r=a6[s[0]];return(r===void 0?"":s.slice(r).join(":"))||n||s.slice(1).join(":")}const i6="Sign in with your password to change secrets.",l6="This server has no accounts: set secrets in its environment, or turn accounts on to change them here.",c6="Open the console from the server's link to change secrets.",ni={sign_in:i6,no_accounts:l6,token:c6},qC=e=>e.status===200&&e.body&&typeof e.body=="object"?e.body:null,d6=e=>{var n;return((n=qC(e))==null?void 0:n.secrets_writable)===!0};function u6(e){const n=qC(e);return n!=null&&n.secrets_reason?n.secrets_reason:(n==null?void 0:n.accounts)===!1?"no_accounts":"sign_in"}function f6(e){const[n,s]=p.useState({writable:!1,whyNot:"sign_in"});return p.useEffect(()=>{let r=!0;return e.session().then(o=>{r&&s({writable:d6(o),whyNot:u6(o)})},()=>{}),()=>{r=!1}},[e]),n}const m6=2e3,bx=e=>e instanceof ze||e instanceof Error?e.message:String(e),uy=({children:e="Manage usage"})=>t.jsx("a",{href:SI,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:e});function h6(){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(uy,{})," in your ChatGPT settings."]}),t.jsx("p",{children:EI})]})}function wx({v2:e,view:n,onView:s,writable:r=!0,whyNot:o="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 R=()=>{if(L||document.visibilityState!=="visible")return;L=!0;const z=++k.current;e.chatGPT().then(U=>{const q=Hf(U);z===k.current&&q&&q.state!=="pending"&&E(q)},()=>{}).finally(()=>{L=!1})},A=setInterval(R,m6),P=()=>{document.visibilityState==="visible"&&R()};return document.addEventListener("visibilitychange",P),()=>{clearInterval(A),document.removeEventListener("visibilitychange",P)}},[e,S]);const N=async()=>{f(null),b(!0);const L=window.open("","_blank");k.current++;try{const R=await e.startChatGPT();L&&(L.opener=null,L.location.href=R.authorize_url),E({state:"pending",authorize_url:R.authorize_url,expires_at:R.expires_at})}catch(R){L==null||L.close(),f(bx(R))}finally{b(!1)}},$=async L=>{var P;L.preventDefault();const R=(P=j.current)==null?void 0:P.value.trim();if(!R)return;f(null),b(!0),h(!0),k.current++;const A=z=>{j.current&&(j.current.value=""),y(!1),E(z)};try{A(await e.finishChatGPT(R))}catch(z){const U=await e.chatGPT().then(Hf,()=>null);(U==null?void 0:U.state)==="signed_in"?A(U):f(bx(z))}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:MI(c)}),t.jsx(h6,{})]});if(!r)return t.jsx("p",{className:"text-body",role:"status",children:ni[o]});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 M=dr(c.authorize_url),O=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:CI}),t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:[M&&t.jsxs(t.Fragment,{children:[t.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",className:"text-primary-text underline underline-offset-2",children:"Open the sign-in page"})," (a new tab)"]}),M&&O&&" · ",O&&`Waits until ${md(O)}`]}),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(Me,{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 p6={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 g6({v2:e,writable:n,whyNot:s,onChange:r}){var y;const[o,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(Hf(k))},()=>{j&&i(null)}),()=>{j=!1}},[e]),!o)return null;const x=async()=>{b(null);let j;try{j=await e.signOutChatGPT()}catch(k){b(bx(k));return}d(!1),i({state:"signed_out"}),f(typeof j=="object"&&(j==null?void 0:j.revoked)===!1?{words:j.message||_I,settings:!0}:{words:$I}),r==null||r()},h=j=>{i(j),j.state!=="pending"&&f(null),j.state==="signed_in"&&(r==null||r())},v=p6[o.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(ke,{tone:v.tone,children:v.words})]}),t.jsx("p",{className:"mt-1.5 font-mono text-small text-muted-foreground",children:K2}),t.jsxs("div",{className:"mt-3 space-y-3",children:[o.state==="expired"&&t.jsx("p",{className:"text-body text-warning-text",children:TI}),o.state==="signed_in"&&((y=o.models)!=null&&y.length)?t.jsxs("p",{className:"font-mono text-small text-muted-foreground",children:["Models: ",o.models.join(" · ")]}):null,t.jsx(wx,{v2:e,view:o,onView:h,writable:n,whyNot:s}),o.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(uy,{children:"ChatGPT settings"})]})]})]})]})}function x6(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 KC({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 o;const r=x6(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:Uf(s.id)}),t.jsx(ke,{tone:r.tone,children:r.text}),s.available&&!((o=s.needs)!=null&&o.length)?s.default_model&&t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:ml(s.default_model,n).text}):s.reason&&t.jsx("span",{className:"text-small text-muted-foreground",children:s.reason})]},s.id)})})]}):null}const rf=(e,n,s)=>{if(!/^\d{1,2}$/.test(e))return null;const r=Number(e);return r>=n&&r<=s?r:null};function v6(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const[s,r,o,i,c]=n,d=rf(s,0,59);if(d===null||i!=="*")return null;if(r==="*")return o==="*"&&c==="*"?{kind:"hourly",minute:d}:null;const u=rf(r,0,23);if(u===null)return null;const f={hour:u,minute:d};if(o==="*"&&c==="*")return{kind:"daily",at:f};if(o==="*"&&c==="1-5")return{kind:"weekdays",at:f};if(o==="*"){const g=rf(c,0,6);return g===null?null:{kind:"weekly",day:g,at:f}}if(c==="*"){const g=rf(o,1,31);return g===null?null:{kind:"monthly",date:g,at:f}}return null}function y6(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 b6(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 w0=e=>String(e).padStart(2,"0"),w6=e=>`${w0(e.hour)}:${w0(e.minute)}`;function j6(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 Cg={exports:{}},j0;function k6(){return j0||(j0=1,(function(e,n){(function(r,o){e.exports=o()})(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 M=_.replace(/\D/,""),O=M;return h.dayOfWeekStartIndexZero?M=="7"&&(O="0"):O=(parseInt(M)-1).toString(),_.replace(M,O)}),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 M=_.replace(/\D/,""),O=M;return h.monthStartIndexZero&&(O=(parseInt(M)+1).toString()),_.replace(M,O)});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,M=_===void 0?!1:_,O=y.use24HourTimeFormat,L=y.trimHoursLeadingZero,R=L===void 0?!1:L,A=y.locale,P=A===void 0?null:A,z=y.logicalAndDayFields,U=z===void 0?!1:z,q={throwExceptionOnParseError:k,verbose:S,dayOfWeekStartIndexZero:$,monthStartIndexZero:M,use24HourTimeFormat:O,trimHoursLeadingZero:R,locale:P,logicalAndDayFields:U};q.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var H=new x(h,q);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),M=j.substring(0,j.indexOf("#"));switch(_){case"1":$=h.i18n.first(M);break;case"2":$=h.i18n.second(M);break;case"3":$=h.i18n.third(M);break;case"4":$=h.i18n.fourth(M);break;case"5":$=h.i18n.fifth(M);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()),M=N[4];M?N[3]=="-"?E=f.StringUtilities.format(((y=(v=this.i18n).commaDaysBeforeTheX0OfTheMonth)===null||y===void 0?void 0:y.call(v,M))||", %s days before the %s of the month",M,_):E=f.StringUtilities.format(((k=(j=this.i18n).commaDaysAfterTheX0OfTheMonth)===null||k===void 0?void 0:k.call(j,M))||", %s days after the %s of the month",M,_):E=f.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),_);break}else{var O=S.match(/L-(\d{1,2})/);if(O){var L=O[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(R){return R=="L"?h.i18n.lastDay():h.i18n.dayX0?f.StringUtilities.format(h.i18n.dayX0(),R):R},function(R){return R=="1"?h.i18n.commaEveryDay():h.i18n.commaEveryX0Days(R)},function(R){return h.i18n.commaBetweenDayX0AndX1OfTheMonth(R)},function(R){return h.i18n.commaOnDayX0OfTheMonth(R)})}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,M=h.indexOf(",")>-1;if(!h)N="";else if(h==="*")N=v;else if(!$&&!_&&!M)N=f.StringUtilities.format(E(h),y(h));else if(M){for(var O=h.split(","),L="",R=this.i18n.spaceAnd(),A=0;A<O.length;A++)if(A>0&&O.length>2&&(L+=",",A<O.length-1&&(L+=" ")),A>0&&O.length>1&&(A==O.length-1||O.length==2)&&(L+=R==","&&O.length>2?" ":"".concat(R," ")),O[A].indexOf("/")>-1||O[A].indexOf("-")>-1){var P=O[A].indexOf("-")>-1&&O[A].indexOf("/")==-1,z=this.getSegmentDescription(O[A],v,y,j,P?this.i18n.commaX0ThroughX1:k,E);P?z=z.replace(", ",""):A>0&&z.startsWith(", ")&&(z=z.substring(2)),L+=z}else if(!$)L+=y(O[A]);else{var U=this.getSegmentDescription(O[A],v,y,j,k,E);A>0&&U&&U.startsWith(", ")&&(U=U.substring(2)),L+=U}$?N=L:N=f.StringUtilities.format(E(h),L)}else if($){var O=h.split("/");if(N=f.StringUtilities.format(j(O[1]),O[1]),O[0].indexOf("-")>-1){var q=this.generateRangeSegmentDescription(O[0],k,y);q.indexOf(", ")!=0&&(N+=", "),N+=q}else if(O[0].indexOf("*")==-1){var H=f.StringUtilities.format(E(O[0]),y(O[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],M=parseInt(_),O=v.max-v.min+1,L=$==="*",R=Number.isInteger(M)&&M>1,A=R&&O%M===0;if(!L||!R||A)return"";for(var P=[],z=v.min;z<=v.max;z+=M)P.push(z);if(P.length<2)return"";var U=this.getSegmentDescription(P.join(","),y,j,k,E,S);return U?", ".concat(U):""},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 M=E.toString(),O=("00"+M).substring(M.length),L=S.toString(),R=("00"+L).substring(L.length),A=this.options.trimHoursLeadingZero?M:O;return"".concat($?N:"").concat(A,":").concat(R).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 o(c){var d=r[c];if(d!==void 0)return d.exports;var u=r[c]={exports:{}};return s[c](u,u.exports,o),u.exports}var i={};return(()=>{var c=i;Object.defineProperty(c,"__esModule",{value:!0}),c.toString=void 0;var d=o(8333),u=o(3747);d.ExpressionDescriptor.initialize(new u.enLocaleLoader),c.default=d.ExpressionDescriptor;var f=d.ExpressionDescriptor.toString;c.toString=f})(),i})())})(Cg)),Cg.exports}var N6=k6();const S6=SN(N6),$d={rules:20,conditions:20,list:20,pointer:512,text:200,value:1024},Sn=$d,VC={in:"is one of",prefix:"starts with",exists:"exists",missing:"is missing"},C6=Object.keys(VC);let E6=0;const Xm=()=>`r${++E6}`,$6=()=>({key:Xm(),pointer:"",op:"in",value:""}),YC=()=>({key:Xm(),event:"",actions:"",where:[]});function QC(e){const n=e.trim();try{return JSON.parse(n)}catch{return n}}function JC(e){return typeof e!="string"?JSON.stringify(e):e!==""&&e===e.trim()&&!/[,\r\n]/.test(e)&&QC(e)===e?e:JSON.stringify(e)}const _6=e=>"in"in e?`${e.pointer} is one of ${e.in.map(JC).join(", ")}`:"exists"in e?`${e.pointer} ${e.exists?"exists":"is missing"}`:`${e.pointer} starts with ${JSON.stringify(e.prefix)}`,Uo=(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(_6).join(" and ")}`:""}`};function XC(e){return"in"in e?{pointer:e.pointer,op:"in",value:e.in.map(JC).join(`
|
|
658
|
+
`)}:"exists"in e?{pointer:e.pointer,op:e.exists?"exists":"missing",value:""}:{pointer:e.pointer,op:"prefix",value:e.prefix}}const ZC=e=>({key:Xm(),...XC(e),was:e}),eE=e=>{if(!e.was)return!1;const n=XC(e.was);return n.pointer===e.pointer&&n.op===e.op&&n.value===e.value},tE=e=>(e??[]).join(", "),Xf=e=>({key:Xm(),event:e.event,actions:tE(e.actions),where:(e.where??[]).map(ZC),was:e}),T6=(e,n)=>e.length===n.length&&e.every((s,r)=>s===n[r]),R6=e=>e.split(/[\s,]+/).filter(Boolean),k0=/^[!-~]+$/,Pc=e=>[...e].length,A6=/^(\/([^~]|~[01])*)?$/;function O6(e,n,s){return e.length>Sn.conditions&&(s[`${n}.where`]=`At most ${Sn.conditions} conditions a rule.`),e.map((r,o)=>{if(eE(r))return r.was;const i=`${n}.where[${o}]`,c=r.pointer;if(c?c.startsWith("/")?A6.test(c)?Pc(c)>Sn.pointer&&(s[`${i}.pointer`]=`At most ${Sn.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?Pc(u)>Sn.text&&(s[`${i}.prefix`]=`At most ${Sn.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(QC);return d.length?d.length>Sn.list?s[`${i}.in`]=`At most ${Sn.list} values.`:d.some(u=>Pc(JSON.stringify(u))>Sn.value)&&(s[`${i}.in`]=`Each value is at most ${Sn.value} characters.`):s[`${i}.in`]="Give at least one value, one a line.",{pointer:c,in:d}})}function M6(e,n,s){var g;const r=`source.accept[${n}]`,o=e.was,i=o&&e.event===o.event?o.event:e.event.trim();i?i!==(o==null?void 0:o.event)&&(!k0.test(i)||Pc(i)>Sn.text)&&(s[`${r}.event`]=`An event's name has no spaces: printable characters only, at most ${Sn.text}.`):s[`${r}.event`]="Name the event.";const c=o&&(typeof e.actions=="string"?e.actions===tE(o.actions):T6(e.actions,o.actions??[])),d=c?[...o.actions??[]]:typeof e.actions=="string"?R6(e.actions):e.actions;if(o&&c&&i===o.event&&e.where.length===(((g=o.where)==null?void 0:g.length)??0)&&e.where.every((b,x)=>eE(b)&&b.was===o.where[x]))return o;d.length>Sn.list?s[`${r}.actions`]=`At most ${Sn.list} actions.`:d.some(b=>!k0.test(b)||Pc(b)>Sn.text)&&(s[`${r}.actions`]=`An action's name is printable characters, at most ${Sn.text}.`);const f=O6(e.where,r,s);return{event:i,...d.length?{actions:d}:{},...f.length?{where:f}:{}}}function fy(e){const n={};return e.length>Sn.rules&&(n["source.accept"]=`At most ${Sn.rules} rules.`),{accept:e.map((s,r)=>M6(s,r,n)),issues:n}}function _d(e){const n=new Set(["source.accept"]);return e.forEach((s,r)=>{const o=`source.accept[${r}]`;for(const i of["",".event",".actions",".where"])n.add(`${o}${i}`);for(let i=0;i<s;i++)for(const c of["",".pointer",".in",".prefix",".exists"])n.add(`${o}.where[${i}]${c}`)}),n}const Bi=(e,n)=>n&&e===kx(n)?n:G6(e),_l=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",nE=(e="")=>({name:"",kind:"cron",cron:"",timezone:_l(),at:"",every:"",everyUnit:"minutes",startAt:"",agentId:e,content:"",maxCost:"",enabled:!0}),Zm={seconds:1,minutes:60,hours:3600};function my(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 sE(e){try{return S6.toString(e,{use24HourTimeFormat:!0,throwExceptionOnParseError:!0,verbose:!1})}catch{return`Cron ${e}`}}const Ta=e=>String(e).padStart(2,"0"),Zf=(e,n)=>e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:n});function rE(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 o=s("en-GB");return/^GMT[+-]/.test(o)?r:o}const N0=(e,n)=>{const s=new Date(e);return`${s.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:n}).replace(",","")}, ${Zf(s,n)} ${rE(s,n)}`};function S0(e,{zone:n=_l(),now:s=Date.now()}={}){const r=new Date(e),o=c=>c.toLocaleDateString("en-US",{year:"numeric",month:"numeric",day:"numeric",timeZone:n});return`Pick a time in the future: ${o(r)===o(new Date(s))?`${Zf(r,n)} today`:`${r.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:n})}, ${Zf(r,n)} ${rE(r,n)}`} has already passed.`}function em(e,n){const s={};for(const{type:r,value:o}of new Intl.DateTimeFormat("en-US",{timeZone:n,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric"}).formatToParts(e))s[r]=o;return Date.UTC(Number(s.year),Number(s.month)-1,Number(s.day),Number(s.hour),Number(s.minute))}function P6(e,n,s,r){const o=new Date(em(e,n)),i=Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),s,r);let c=i;for(let d=0;d<2;d++)c+=i-em(new Date(c),n);return new Date(c)}const L6=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 I6(e,n,s,r,o){const i=sE(e),c=n!==s,d=L6(e),u=d&&`At ${Ta(d.hour)}:${Ta(d.minute)}`;if(d&&u&&i.startsWith(u))try{const f=r??P6(o,n,d.hour,d.minute),g=d.days?Math.floor(em(f,s)/864e5)-Math.floor(em(f,n)/864e5):0,b=g>0?" the next day":g<0?" the day before":"";return`At ${Zf(f,s)} your time${b}${c?` (${u.slice(3)} ${n})`:""}${i.slice(u.length)}`}catch{}return`${i}${c?` (${n})`:""}`}function hy(e,n,{zone:s=_l(),instead:r,now:o=Date.now()}={}){const i=r?` · ${r}`:n?` · next ${N0(n,s)}`:" · no next time";return"cron"in e?`${I6(e.cron,e.timezone,s,n?new Date(n):null,new Date(o))}${i}`:"at"in e?`Once, ${N0(e.at,s)}${!r&&n&&Date.parse(n)===Date.parse(e.at)?"":i}`:`Every ${my(e.every_s)}${i}`}const ra=e=>`$${Number.isInteger(Math.round(e*1e6)/1e4)?e.toFixed(2):String(e)}`,z6=e=>`${ra(e)} a run`,D6=(e,n)=>typeof e=="number"?z6(e):typeof n=="number"&&n>0?`Agent's default (${ra(n)})`:"Agent's default";function py(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 o=[e.last_firing,...s].find(i=>i&&i.status==="started"&&Date.parse(i.nominal_at)===r);return o?{ran:o}:{passed:e.source.at}}const gy=e=>e.source.kind==="schedule"&&e.target.kind==="start_run",xy=e=>e.source.kind==="webhook"&&e.target.kind==="start_run",oE=e=>e.source.kind==="github"&&e.target.kind==="start_run",eh=[{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"}],Qc=e=>`${location.origin}/v2/hooks/${encodeURIComponent(e.id)}`,vy="This server's address as this page sees it: behind a proxy, use its public address.",jx={standard:"Standard Webhooks (webhook-signature)",github:"GitHub's (X-Hub-Signature-256)"},aE=e=>{var n;return(n=e.accept)!=null&&n.length?`Only signed requests for ${e.accept.map(s=>Uo(s,!1)).join(" or ")}`:"On each signed request"},F6={schedule:"On schedule",manual:"Run now",webhook:"On a request",github:"On a GitHub event",composio:"On an app event",email:"On an email",feed:"On a feed item"},iE=e=>`On ${e.event} from ${e.server}`,U6=e=>{var n;return(n=e.accept)!=null&&n.length?`On email in ${e.mailbox} for ${e.accept.map(s=>Uo(s,!1)).join(" or ")}`:`On each email in ${e.mailbox}`},lE=e=>{var s;const n=e.urls.length===1?W6(e.urls[0]):`${e.urls.length} feeds`;return(s=e.accept)!=null&&s.length?`On items in ${n} for ${e.accept.map(r=>Uo(r,!1)).join(" or ")}`:`On each new item in ${n}`},W6=e=>{try{return new URL(e).host}catch{return e}},cE=e=>`On GitHub ${e.accept.map(n=>Uo(n,!1)).join(" or ")}`;function tm(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 dE(e){var s;const n=(r,o)=>o?`${r}: ${o}`: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 ${md(e.retry_at)}`:"Due";case"sent":return"Sent";default:return String(e.status)}}const H6={due:"Due",started:"Started",sent:"Sent",skipped:"Skipped",failed:"Failed",missed:"Missed"},B6=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?$/;function G6(e){if(!B6.test(e))return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toISOString().replace(/\.\d{3}Z$/,"Z")}function kx(e){const n=new Date(e);return`${n.getFullYear()}-${Ta(n.getMonth()+1)}-${Ta(n.getDate())}T${Ta(n.getHours())}:${Ta(n.getMinutes())}${n.getSeconds()?`:${Ta(n.getSeconds())}`:""}`}const C0=e=>`${new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:"UTC"})} UTC`;function yy(e){const n=my(e);return/^\d/.test(n)?`At least ${n}.`:`At least ${n==="hour"?"an":"a"} ${n}.`}const Jc="A number is needed.",Xc=e=>e.trim()!==""&&Number.isFinite(Number(e))?Number(e):void 0;function E0(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()||_l()};else if(e.kind==="at"){const d=Bi(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=Xc(e.every);e.every.trim()?d===void 0&&(s["source.every_s"]=Jc):s["source.every_s"]="A number is needed.";const u=e.startAt?Bi(e.startAt,(c=e.read)==null?void 0:c.startAt):null;r={kind:"schedule",every_s:Math.round((d??0)*Zm[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 o=Xc(e.maxCost);return e.maxCost.trim()?o===void 0&&(s["target.max_cost_usd"]=Jc):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},...o!==void 0?{max_cost_usd:o}:{}}}}}const q6=()=>({name:"",signature:"standard",accept:[],agentId:"",content:"",maxCost:""});function uE(e,n){const{accept:s,issues:r}=fy(n);return{source:{kind:"webhook",...e.signature!==void 0?{signature:e.signature}:{},...s.length?{accept:s}:{}},issues:r}}function K6(e,n=!1){const{source:s,issues:r}=uE({signature:e.signature},e.accept);return nh(e,s,r,n,"a webhook")}const V6=()=>({name:"",events:["pull_request:opened"],where:{},other:[],agentId:"",content:"",maxCost:""}),fE=[...new Set(eh.map(e=>e.event))],Y6=(e,n)=>e.length===n.length&&e.every(s=>n.includes(s));function th(e){var i;const s=[...fE.flatMap(c=>{var f;const d=eh.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&&Y6(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)??[],o=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)=>o(c.r)-o(d.r)||c.i-d.i).map(({r:c})=>c)}function mE(e){const{accept:n,issues:s}=fy(th(e));return n.length||(s["source.accept"]="Pick at least one event."),{source:{kind:"github",accept:n},issues:s}}function Q6(e){var s;const n={events:[],where:{},other:[],read:{order:[],rules:{}}};for(const r of e){const o=eh.filter(c=>c.event===r.event).map(c=>c.action);if(!(!!((s=r.actions)!=null&&s.length)&&r.actions.every(c=>o.includes(c))&&new Set(r.actions).size===r.actions.length&&!(r.event in n.where))){const c=Xf(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(ZC),n.read.order.push(`event:${r.event}`),n.read.rules[r.event]=r}return n}const by=e=>e.source.kind==="composio"&&e.target.kind==="start_run";function J6(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,o])=>{const i=(Array.isArray(o.type)?o.type:[o.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(o.enum)&&o.enum.every(f=>typeof f=="string")?o.enum:void 0,u=o.default===void 0?c==="boolean"?"false":"":c==="json"?JSON.stringify(o.default):String(o.default);return{name:r,title:typeof o.title=="string"&&o.title.trim()?o.title:r,...typeof o.description=="string"&&o.description.trim()?{description:o.description}:{},required:s.has(r),type:c,...d?{options:d}:{},initial:u}})}function X6(e,n,s){const r={};for(const o of e){const i=(n[o.name]??o.initial).trim(),c=`source.config.${o.name}`;if(!i){o.required&&(s[c]=`${o.title} is required.`);continue}if(o.type==="boolean")r[o.name]=i==="true";else if(o.type==="number"||o.type==="integer"){const d=Xc(i);d===void 0||o.type==="integer"&&!Number.isInteger(d)?s[c]=o.type==="integer"?"A whole number is needed.":Jc:r[o.name]=d}else if(o.type==="json")try{r[o.name]=JSON.parse(i)}catch{s[c]="Give it as JSON."}else r[o.name]=i}return r}const Z6=()=>({name:"",server:"",event:"",config:{},where:[],agentId:"",content:"",maxCost:""});function wy(e,n,s=[],r){var i;const o=n.length||r&&!((i=r.where)!=null&&i.length)?[{event:e,actions:"",where:n,...r?{was:r}:{}}]:[];return fy([...o,...s])}function e8(e,n,s=[],r){const{accept:o,...i}=e,{accept:c,issues:d}=wy(e.event,n,s,r);return{source:{...i,...c.length?{accept:c}:{}},issues:d}}function t8(e,n,s=!1){const r={};e.server||(r["source.server"]="Pick a Composio server."),e.event||(r["source.event"]="Pick an event.");const o=e.event?X6(n,e.config,r):{},{accept:i,issues:c}=wy(e.event,e.where);Object.assign(r,c);const d={kind:"composio",server:e.server,event:e.event,config:o,...i.length?{accept:i}:{}};return nh(e,d,r,s,"a trigger")}const hE=e=>e.source.kind==="feed"&&e.target.kind==="start_run",Nx=20,pE=900,n8="item",gE=()=>({name:"",urls:"",every:"15",everyUnit:"minutes",items:"",id:"",where:[],others:[],agentId:"",content:"",maxCost:""});function s8(e){const n=e.source,s=n.every_s??pE,r=s%3600===0?"hours":s%60===0?"minutes":"seconds",o=(n.accept??[]).map(Xf),i=o[0]&&!o[0].actions.trim()?o[0]:null;return{...gE(),urls:n.urls.join(`
|
|
659
|
+
`),every:String(s/Zm[r]),everyUnit:r,items:n.items??"",id:n.id??"",where:(i==null?void 0:i.where)??[],others:o.slice(i?1:0),read:n}}const r8=e=>{try{return new URL(e)}catch{return null}};function xE(e){const n=e.split(/\r\n|\r|\n/).map(r=>r.trim()).filter(Boolean),s={};return n.length?n.length>Nx?s["source.urls"]=`${Nx} feeds at most: this has ${n.length}.`:n.forEach((r,o)=>{const i=r8(r);!i||i.protocol!=="http:"&&i.protocol!=="https:"||!i.hostname?s[`source.urls[${o}]`]=`${r} isn't an http or https URL.`:i.username||i.password?s[`source.urls[${o}]`]=`${i.host}'s URL holds a user or password: leave it out.`:n.indexOf(r)<o&&(s[`source.urls[${o}]`]=`${r} is here twice: each feed is read once.`)}):s["source.urls"]="Add a feed's URL, one a line.",{urls:n,issues:s}}function vE(e,n){var f,g,b,x,h;const{urls:s,issues:r}=xE(e.urls),o=Xc(e.every),i=Math.round((o??0)*Zm[e.everyUnit]);o===void 0?r["source.every_s"]=Jc:n&&i<n&&(r["source.every_s"]=yy(n));const c=v=>{var j;const y=e[v];return y||((j=e.read)==null?void 0:j[v])===""?{[v]:y}:{}},{accept:d,issues:u}=wy(n8,e.where,e.others,(g=(f=e.read)==null?void 0:f.accept)!=null&&g[0]&&!((b=e.read.accept[0].actions)!=null&&b.length)?e.read.accept[0]:void 0);return Object.assign(r,u),{source:{kind:"feed",urls:s,every_s:i,...c("items"),...c("id"),...((x=e.read)==null?void 0:x.updated)!==void 0?{updated:e.read.updated}:{},...(h=e.read)!=null&&h.fields?{fields:e.read.fields}:{},...d.length?{accept:d}:{}},issues:r}}function o8(e,n,s=!1){const{source:r,issues:o}=vE(e,n);return nh(e,r,o,s,"a feed trigger")}function a8(e,n){return new Set(["name","source.urls",...Array.from({length:e},(s,r)=>`source.urls[${r}]`),"source.every_s","source.items","source.id","target.agent_id","target.input","target.max_cost_usd",..._d(n)])}function i8(e,n=!1){const{source:s,issues:r}=mE(e);return nh(e,s,r,n,"a GitHub trigger")}function nh(e,n,s,r,o){e.agentId||(s["target.agent_id"]="Pick an agent."),e.content.trim()||(s["target.input"]="Say what each run is asked.");const i=Xc(e.maxCost);return e.maxCost.trim()?i===void 0&&(s["target.max_cost_usd"]=Jc):r||(s["target.max_cost_usd"]=`A cost cap is needed: every run ${o} 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 l8(e){const n=e.source,s="cron"in n?n.timezone:_l(),r={...nE(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:kx(n.at),read:{at:n.at}};const o=n.every_s%3600===0?"hours":n.every_s%60===0?"minutes":"seconds";return{...r,kind:"every",every:String(n.every_s/Zm[o]),everyUnit:o,startAt:kx(n.start_at),read:{startAt:n.start_at}}}const Zc=(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(o=>Zc(e[o],n[o]))};function $0(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&&!Zc(s,e.source)?{source:s}:{},...r&&!Zc(r,e.target)?{target:r}:{}}}const c8=["name","enabled","source.cron","source.timezone","source.at","source.every_s","source.start_at","target.agent_id","target.input","target.max_cost_usd"];function Tl(e){var r;if(!(e instanceof ze))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 o of e.fields){const i=o.field.startsWith("target.input")?"target.input":o.field;(c8.includes(i)||i.startsWith("source.accept")||i==="source.server"||i==="source.event"||i==="source.config"||i.startsWith("source.config.")||/^source\.urls(\[\d+\])?$/.test(i)||i==="source.items"||i==="source.id")&&!n[i]?n[i]=o.message:s.push(o.message)}return{fields:n,rest:s}}const d8=[{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"}],u8=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e]})),f8=Array.from({length:31},(e,n)=>({value:String(n+1),label:String(n+1)})),m8=Array.from({length:60},(e,n)=>({value:String(n),label:`:${String(n).padStart(2,"0")}`}));function yE({value:e,onChange:n,label:s,name:r}){const o=v6(e),[i,c]=p.useState(()=>e.trim()!==""&&!o),d=p.useId(),u=i||e.trim()!==""&&!o,f=x=>n(y6(x)),g=x=>{if(x==="custom"){c(!0);return}c(!1),f(b6(x,o))},b=o&&"at"in o?o.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(Et,{label:s,className:"min-w-56 flex-1",value:u?"custom":(o==null?void 0:o.kind)??"",onChange:g,placeholder:"Pick when it runs",options:d8}),!u&&(o==null?void 0:o.kind)==="weekly"&&t.jsx(Et,{id:`${d}-day`,label:"Day of the week",className:"w-40",value:String(o.day),onChange:x=>f({...o,day:Number(x)}),options:u8}),!u&&(o==null?void 0:o.kind)==="monthly"&&t.jsx(Et,{id:`${d}-date`,label:"Day of the month",className:"w-24",value:String(o.date),onChange:x=>f({...o,date:Number(x)}),options:f8}),!u&&(o==null?void 0:o.kind)==="hourly"&&t.jsx(Et,{id:`${d}-minute`,label:"Minutes past the hour",className:"w-24",value:String(o.minute),onChange:x=>f({...o,minute:Number(x)}),options:m8}),!u&&o&&b&&t.jsx(Me,{id:`${d}-at`,type:"time","aria-label":"At",className:"w-32",value:w6(b),onChange:x=>{const h=j6(x.target.value);h&&f({...o,at:h})}})]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(Me,{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()?sE(e.trim()):"Minute, hour, day of month, month, day of week."})]})]})}const _0=Intl.supportedValuesOf,of=typeof _0=="function"?_0("timeZone"):[],af=of.length&&!of.includes("UTC")?["UTC",...of]:of;function bE({value:e,onChange:n,label:s,name:r,id:o,className:i}){if(!af.length)return t.jsx(Me,{id:o,name:r,"aria-label":s,className:i,value:e,onChange:d=>n(d.target.value),placeholder:"Europe/Madrid"});const c=e&&!af.includes(e)?[e,...af]:af;return t.jsx(Et,{id:o,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 h8(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 o=e==="agentic"?(d=n.repo)==null?void 0:d.trim():void 0;if(o){if(!/^[^/\s]+\/[^/\s]+$/.test(o))return{ok:!1,field:"repo",message:"A repository is owner/name, like Parcha-ai/agentrun."};r.repo=o}return{ok:!0,body:r}}function p8(e,n){return s=>{var o,i,c,d;const r=new Set;for(;s!=null&&s.$ref&&!r.has(s.$ref);){r.add(s.$ref);const u=(i=(o=/^#\/(?:definitions|\$defs)\/(.+)$/.exec(s.$ref))==null?void 0:o[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 g8(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 x8(e){var r,o;const n=e,s=(r=n==null?void 0:n.input)!=null&&r.schemaId?(o=n.schemas)==null?void 0:o[n.input.schemaId]:void 0;return s?wE(s,(n==null?void 0:n.schemas)??{}):null}function wE(e,n={}){var u;const s=p8(e,n),r=s(e),o=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:o,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:o,optional:o.map(f=>f.name).filter(f=>!d.has(f))}}const Eg=e=>`'${e.replace(/'/g,"'\\''")}'`;function v8(e,n,s,r){return[`curl -X POST ${Eg(`${e}/v2/agents/${n?encodeURIComponent(n):"{agent_id}"}/runs`)} \\`,' -H "Authorization: Bearer $AGENTRUN_API_KEY" \\'," -H 'Content-Type: application/json' \\",` -H ${Eg(`Idempotency-Key: ${r}`)} \\`,` -d ${Eg(JSON.stringify(s))}`].join(`
|
|
660
|
+
`)}const y8=e=>e>=200&&e<300;async function b8(e,n,s,r){const o=await r(n,s,e.keyFor(n,s));return y8(o.status)&&e.done(),o}const Wo=(e,n={})=>(e.display_name||e.name).replace(/\$\{parameters\.([A-Za-z0-9_]+)\}/g,(s,r)=>(Object.hasOwn(n,r)?ky(n[r]).join(", "):"")||"…"),jE=e=>`#/templates/${encodeURIComponent(e)}`;function tl(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 w8(e,n){var r,o;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"||!((o=(r=n.model)==null?void 0:r.choices)!=null&&o.map(x=>x.id).includes(d.overrides.choice))))return s;const f=sh(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(`
|
|
661
|
+
`):String(h),j=oh({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 j8=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function jy(e,{secrets:n=!0,mcp:s=!0}={}){var o,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} (${wd[c.source]}${c.required?"":", optional"})`).join(", ")]),e.triggers.length&&r.push(["Triggers",j8(e.triggers.length,"trigger")]),(o=e.budget)!=null&&o.per_run_usd&&r.push(["Budget",`${to(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 Td(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 k8(e){return Object.fromEntries(Object.entries(e).flatMap(([n,s])=>s.array?[]:s.type==="boolean"?typeof s.default=="boolean"?[[n,String(s.default)]]:[]:Td(s)?[]:s.format==="timezone"?[[n,_l()]]:s.format==="cron"?typeof s.default=="string"?[[n,s.default]]:[]:[]))}const N8=(e,n)=>n.filter(s=>s.source===e.source&&s.toolkit===e.toolkit).map(s=>s.name).sort();function S8(e){const n=encodeURIComponent(e.toolkit);if(e.source==="composio")return`#/settings/mcp?add=${n}&preset=composio&toolkit=${n}&tools=${e.tools.map(r=>encodeURIComponent(r.name)).join(",")}`;if(e.source==="github")return"#/settings/mcp?add=github&auth=github_app";const s=Yv.find(r=>r.name===e.toolkit);return`#/settings/mcp?add=${n}${s?`&preset=${s.id}`:""}`}const nm=e=>e.mcp.length===0&&e.secrets.length===0,C8=e=>{const n=e.source;return typeof n=="object"&&n!==null&&"kind"in n?n.kind:void 0},T0=[{id:"email",what:"the email account",needs:e=>(e.tools??[]).some(n=>n.startsWith("email_"))||e.triggers.some(n=>C8(n)==="email"),met:async e=>(await e.emailAccount()).configured,unmet:{before:"Connect your mailbox under ",link:"Settings → Email",href:"#/settings/email",after:" first."}}],E8=(e,n)=>e.mcp.flatMap(s=>s.tools.map(r=>r.tool)).filter(s=>n.has(s)),$8=(e,n)=>e.filter(s=>s.field===n);function sm(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 _8(e){const n=Td(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 T8(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: ${kE(s).join(", ")}.`;case"bad_format":return`${r} isn't in the form its description asks for.`;default:return e.message}}const kE=e=>{var n;return(n=e.enum)!=null&&n.length?e.enum.map(String):Td(e)??[]};function NE(e,n){var c;if(e.array){const d=ky(n);return d.length?d.every(u=>NE({...e,array:!1,required:!0},u)):!e.required}if(n==="")return!e.required;const s=Td(e);if(s)return s.includes(n);const r=Number(n),o=(e.minimum===void 0||r>=e.minimum)&&(e.maximum===void 0||r<=e.maximum);if(e.type==="integer")return n.trim()!==""&&Number.isSafeInteger(r)&&o;if(e.type==="number")return n.trim()!==""&&Number.isFinite(r)&&o;if(e.type==="boolean")return(n==="true"||n==="false")&&(!((c=e.enum)!=null&&c.length)||kE(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 ky=e=>(e??"").split(`
|
|
662
|
+
`).map(n=>n.trim()).filter(n=>n!==""),SE=NE,La=e=>!!e&&typeof e=="object"&&!Array.isArray(e),R8=new Set(["string","number","integer","boolean"]),A8=["oneOf","anyOf","allOf","not","if","$ref","const"],Sx=e=>A8.some(n=>n in e),lf=e=>typeof e=="string"?e:void 0,cf=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,O8=e=>Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0));function M8(e,n){if(!La(e)||Sx(e))return null;const s=e.type==="array",r=s?e.items:e;if(!La(r)||Sx(r)||typeof r.type!="string"||!R8.has(r.type))return null;const o=Array.isArray(r.enum)&&r.enum.every(i=>["string","number","boolean"].includes(typeof i))?r.enum:void 0;return O8({type:r.type,...s?{array:!0}:{},required:n,title:lf(e.title),description:lf(e.description),examples:Array.isArray(e.examples)?e.examples:void 0,default:e.default,enum:o,pattern:lf(r.pattern),format:lf(r.format),minimum:cf(r.minimum),maximum:cf(r.maximum),minLength:cf(r.minLength),maxLength:cf(r.maxLength)})}function sh(e,n){const s=La(e)&&La(e.properties)?e.properties:{},r=La(e)&&Array.isArray(e.required)?e.required:[],o=[];for(const[i,c]of Object.entries(s)){if(i===n)continue;const d=M8(c,r.includes(i));if(!d)return null;o.push([i,d])}return o}function P8(e){if(!La(e))return{kind:"message"};const n=()=>({kind:"json",example:wE(e)});if(Sx(e))return n();const s=La(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 o=sh(e,"content");return o?o.length?{kind:"fields",form:{fields:o,contentRequired:r.includes("content")||!r.some(i=>i!=="content")}}:{kind:"message"}:n()}const rh=(e,n)=>n.title||e;function L8(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(`
|
|
663
|
+
`):typeof n=="object"?JSON.stringify(n):String(n)}function I8(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=ky(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 CE(e){const n=k8(Object.fromEntries(e.fields));for(const[s,r]of e.fields){const o=r.array?null:Td(r);o&&r.default!==void 0&&o.includes(String(r.default))&&(n[s]=String(r.default))}return n}function oh(e,n){const s={};for(const[r,o]of e.fields){const i=I8(o,n[r]);i!==void 0&&(s[r]=i)}return s}const z8=(e,n,s)=>({...n.trim()?{content:n}:{},...oh(e,s)}),Cx=(e,n="input")=>e.startsWith(`${n}.`)?e.slice(n.length+1).split(".")[0]:null,EE=e=>e.type==="integer"?"a whole number":e.type==="number"?"a number":e.type==="boolean"?"true or false":"text",D8={string:"text",integer:"whole numbers",number:"numbers",boolean:"true or false"},F8=e=>e.array?`a list of ${D8[e.type]}`:EE(e);function $E(e,n,s){var o;const r=rh(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 ${EE(s)}.`:s.array&&e.reason==="not_an_option"&&((o=s.enum)!=null&&o.length)?`Each line of ${r} is one of: ${s.enum.map(String).join(", ")}.`:T8(e,n,s,r)}const U8={date:"date",email:"email",uri:"url"};function _E({field:e,label:n,help:s,value:r,onChange:o}){const i=L8(e),c=_8(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(Et,{label:n,className:"w-full",value:r,onChange:o,options:c}):e.array?t.jsx(nn,{rows:3,value:r,required:e.required,placeholder:i,onChange:d=>o(d.target.value),className:"resize-y leading-[1.6]"}):e.format==="cron"&&e.type==="string"?t.jsx(yE,{label:n,value:r,onChange:o}):e.format==="timezone"&&e.type==="string"?t.jsx(bE,{label:n,className:"w-full",value:r,onChange:o}):e.type==="boolean"?t.jsx("input",{type:"checkbox",className:"size-4 accent-primary",checked:r==="true",onChange:d=>o(d.target.checked?"true":"false")}):t.jsx(Me,{type:e.type==="string"?U8[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=>o(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,o)=>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}:${o}`))}):null}const TE={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."},W8='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.',Lc=(e,n)=>e[n]?t.jsx("span",{"data-issue":n,children:e[n]}):void 0,ur=({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 ah({name:e,at:n,where:s,onChange:r,issues:o,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>=$d.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(ur,{issues:o,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(wt,{label:"Field",className:"min-w-40 flex-1",error:Lc(o,`${b}.pointer`),children:t.jsx(Me,{name:`${x}-pointer`,value:f.pointer,onChange:h=>c(g,{pointer:h.target.value}),placeholder:"/title",autoComplete:"off",spellCheck:!1})}),t.jsx(dd,{name:`${x}-op`,label:`Condition ${g+1}'s test`,value:f.op,onChange:h=>d(g,h),options:C6.map(h=>({value:h,label:VC[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(Xo,{"aria-hidden":!0})})]}),f.op==="in"&&t.jsx(wt,{label:"Values",hint:W8,error:Lc(o,`${b}.in`),children:t.jsx(nn,{name:`${x}-value`,rows:3,value:f.value,onChange:h=>c(g,{value:h.target.value}),spellCheck:!1})}),f.op==="prefix"&&t.jsx(wt,{label:"Text",hint:"Its first line, trimmed, starts with this, in any case.",error:Lc(o,`${b}.prefix`),children:t.jsx(Me,{name:`${x}-value`,value:f.value,onChange:h=>c(g,{value:h.target.value}),autoComplete:"off",spellCheck:!1})}),t.jsx(ur,{issues:o,field:b}),t.jsx(ur,{issues:o,field:`${b}.exists`})]},f.key)}),t.jsxs(B,{type:"button",size:"sm",onClick:()=>r([...s,$6()]),disabled:u,children:[t.jsx(vl,{"aria-hidden":!0})," Add a condition"]})]})}function RE({name:e,rules:n,onChange:s,issues:r,indexOf:o=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[${o(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(DN,{"aria-hidden":!0})," Remove"]})]}),t.jsx(ur,{issues:r,field:h}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(wt,{label:"Event",hint:c,error:Lc(r,`${h}.event`),children:t.jsx(Me,{name:`${v}-event`,value:b.event,onChange:y=>g(x,{event:y.target.value}),placeholder:d,autoComplete:"off",spellCheck:!1})}),t.jsx(wt,{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:Lc(r,`${h}.actions`),children:t.jsx(Me,{name:`${v}-actions`,value:b.actions,onChange:y=>g(x,{actions:y.target.value}),placeholder:"opened, edited",autoComplete:"off",spellCheck:!1})})]}),t.jsx(ah,{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,YC()]),disabled:i<=0,children:[t.jsx(vl,{"aria-hidden":!0})," ",u]}),i<=0&&t.jsxs("span",{className:"text-small text-muted-foreground",children:[$d.rules," rules, the most a trigger takes."]})]})]})}const Dn=e=>`#/triggers/${encodeURIComponent(e)}`,pl=e=>ht(e),H8={started:"success",sent:"success",skipped:"muted",missed:"warning",failed:"error",due:"active"};function B8({v2:e,view:n,go:s,agentName:r,minEvery:o,failuresToPause:i,publicUrl:c,refreshMs:d=15e3,now:u=Date.now}){const f=c===!1;return n.trigger===void 0?t.jsx(V8,{v2:e,go:s,agentName:r,every:d*2,now:u,failuresToPause:i,noAddress:f}):n.trigger===null?n.kind==="webhook"?t.jsx(nU,{v2:e,go:s}):n.kind==="github"?t.jsx(sU,{v2:e,go:s}):n.kind==="composio"?t.jsx(rU,{v2:e,go:s,noAddress:f}):n.kind==="feed"?t.jsx(WE,{v2:e,go:s,minEvery:o}):t.jsx(IE,{v2:e,go:s,minEvery:o,now:u}):n.edit?t.jsx(eU,{v2:e,go:s,id:n.trigger,minEvery:o,now:u},n.trigger):t.jsx(Z8,{v2:e,go:s,agentName:r,id:n.trigger,every:d,now:u,failuresToPause:i},n.trigger)}function AE(e,n,s){const r=p.useRef(e);r.current=e,p.useEffect(()=>{const o=()=>document.visibilityState!=="hidden",i=setInterval(()=>{o()&&r.current()},n),c=()=>{o()&&r.current()};return document.addEventListener("visibilitychange",c),()=>{clearInterval(i),document.removeEventListener("visibilitychange",c)}},[n,...s])}const OE=e=>e?"ran"in e?`Done · ran ${pl(e.ran.nominal_at)}`:`Its time passed · ${pl(e.passed)}`:null,G8=/has already passed\.?$/;function ME({trigger:e}){return e.disabled?t.jsx(ke,{tone:"warning",children:"Turned off"}):t.jsx(ke,{tone:"muted",children:"Paused"})}const q8=e=>e.last_firing?`${dE(e.last_firing)}${e.last_firing.catch_up?" · caught up late":""} · ${pl(e.last_firing.nominal_at)}`:"Not fired yet",K8=e=>`${e.ok?"Checked":"Check failed"} ${pl(e.at)}: ${e.message}`,Ny="App triggers need this server's public address: set AGENTRUN_PUBLIC_URL and restart.";function V8({v2:e,go:n,agentName:s,every:r,now:o,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(Ht(j,"the triggers"))}).finally(()=>{h.current=!1}))};return p.useEffect(y,[e,b]),AE(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(dm,{"aria-hidden":!0})," New app trigger"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-github"),children:[t.jsx(hm,{"aria-hidden":!0})," New GitHub trigger"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-webhook"),children:[t.jsx(ol,{"aria-hidden":!0})," New webhook"]}),t.jsxs(B,{size:"lg",onClick:()=>n("#/triggers/new-feed"),children:[t.jsx(Vx,{"aria-hidden":!0})," New feed trigger"]}),t.jsxs(B,{size:"lg",variant:"solid",onClick:()=>n("#/triggers/new"),children:[t.jsx(vl,{"aria-hidden":!0})," New schedule"]})]})]}),c&&d&&d.length>0&&t.jsx("p",{className:"-mt-2 mb-4 text-small text-muted-foreground",children:Ny}),f&&!d?t.jsx(Jt,{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:Dn(j.id),className:"min-w-0 break-words text-prose font-semibold hover:underline",children:j.name}),t.jsx(ke,{children:Q8[j.source.kind]}),!j.enabled&&!py(j,o())&&t.jsx(ME,{trigger:j})]}),t.jsx("p",{className:"mt-1 break-words font-mono text-small text-muted-foreground",title:PE(j),children:J8(j,s,o())}),tm(j,i)&&t.jsx("p",{className:"mt-1 break-words text-small text-warning-text",children:tm(j,i)})]}),t.jsxs("div",{className:"min-w-0 font-mono text-small text-muted-foreground md:text-right",children:[t.jsx("p",{className:"break-words",children:q8(j)}),j.last_check&&t.jsx("p",{"data-last-check":j.last_check.ok?"ok":"failed",className:`mt-1 break-words ${j.last_check.ok?"":"text-warning-text"}`,children:K8(j.last_check)})]})]},j.id))}):t.jsx(Y8,{go:n,noAddress:c}):t.jsx(Un,{label:"Loading the triggers",rows:4}),d&&f&&t.jsx(Jt,{problem:f,className:"mt-4"})]})}function Y8({go:e,noAddress:n}){const s=[{Icon:um,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:ol,name:"Webhook",what:"On each signed request another system sends to its URL.",action:"New webhook",to:"#/triggers/new-webhook"},{Icon:hm,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:dm,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"},{Icon:Vx,name:"Feed",what:"On each new item in the feeds you name, read every few minutes: a status page's incidents, a blog, or an API's JSON list such as a repository's pull requests.",action:"New feed trigger",to:"#/triggers/new-feed"}];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-3",children:s.map(({Icon:r,name:o,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}),o]}),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:Ny}),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})]},o))})]})}const Q8={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email",feed:"Feed"},PE=e=>e.source.kind==="schedule"&&"cron"in e.source?e.source.cron:void 0;function J8(e,n,s){return`${e.source.kind==="schedule"?hy(e.source,e.next_at,{instead:OE(py(e,s)),now:s}):e.source.kind==="github"?cE(e.source):e.source.kind==="composio"?iE(e.source):e.source.kind==="email"?U6(e.source):e.source.kind==="feed"?lE(e.source):aE(e.source)} · ${e.target.kind==="start_run"?n(e.target.agent_id)||e.target.agent_id:`messages run ${na(e.target.run_id)}`}`}const X8={on:"On",off:"Off",missing:"Composio no longer has it: delete this trigger and make it again.",unknown:"Composio didn't say"};function LE(){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(An,{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 Z8({v2:e,go:n,agentName:s,id:r,every:o,now:i,failuresToPause:c}){var ot,me,Le,Ze,yt;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),M=p.useRef(!1),[O,L]=p.useState(!1),[R,A]=p.useState(null),[P,z]=p.useState(null),[U,q]=p.useState(null),[H,K]=p.useState(0),W=p.useRef(!1),G=p.useRef(!1),F=p.useRef(0),D=()=>{G.current=!0;const oe=F.current;return Promise.all([e.getTrigger(r),e.triggerFirings(r)]).then(([Se,tt])=>{oe===F.current&&(u(Se),g(tt.firings),x(null))}).finally(()=>{G.current=!1})};p.useEffect(()=>{D().catch(oe=>x(Ht(oe,"the trigger")))},[e,r,H]),AE(()=>{!G.current&&!W.current&&U===null&&D().catch(()=>{})},o,[e,r]);const[Y,se]=p.useState(void 0),Q=d&&d.target.kind==="start_run"&&typeof d.target.max_cost_usd!="number"?d.target.agent_id:null;p.useEffect(()=>{if(!Q)return;let oe=!0;return e.getAgent(Q).then(Se=>{oe&&se(typeof Se.agent.definition.max_cost_usd=="number"?Se.agent.definition.max_cost_usd:void 0)},()=>{}),()=>{oe=!1}},[e,Q]);const re=(d==null?void 0:d.source.kind)==="composio"?d.source.server:null;if(p.useEffect(()=>{if(!re)return;let oe=!0;return e.composioTriggers(re).then(Se=>{var tt;oe&&A(((tt=Se.triggers.find(Ae=>Ae.id===r))==null?void 0:tt.on_composio)??"unknown")},()=>{oe&&A(null)}),()=>{oe=!1}},[e,re,r,d==null?void 0:d.enabled]),U!==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(An,{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:U}),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(Jt,{problem:b,onRetry:()=>K(oe=>oe+1),link:{href:"#/triggers",label:"All triggers"}}):t.jsx(Un,{label:"Loading the trigger",rows:4});const te=xy(d)?d:null,he=oE(d)?d:null,ge=by(d)?d:null,be=hE(d)?d:null;if(!te&&!he&&!ge&&!be&&!gy(d))return t.jsx(LE,{});const xe=d,fe=py(d,i(),f),De=async(oe,Se,tt)=>{j(oe),v(null);try{await Se()}catch(Ae){v(Ht(Ae,tt))}finally{j(null)}},Fe=()=>De("pause",async()=>{F.current++,z(null);const{composio:oe,...Se}=await e.updateTrigger(r,{enabled:!d.enabled});F.current++,u(Se),z((oe==null?void 0:oe.note)??null)},d.enabled?"the pause":"the resume"),Pe=()=>De("delete",async()=>{const oe=await e.deleteTrigger(r);oe!=null&&oe.composio?q(oe.composio.note):n("#/triggers")},"the delete"),Ee=async()=>{if(!M.current){M.current=!0,L(!0),v(null),_(null);try{_((await e.rotateTriggerSecret(r)).signing_secret??null)}catch(oe){v(Ht(oe,"the new secret"))}finally{M.current=!1,L(!1)}}},ae=async()=>{if(!W.current){W.current=!0,j("fire"),v(null),F.current++;try{const oe=await e.fireTrigger(r,Ed());F.current++,g(Se=>[oe,...Se.filter(tt=>tt.key!==oe.key)]),await D().catch(()=>{})}catch(oe){v(Ht(oe,"the run now"))}finally{W.current=!1,j(null)}}},$e=typeof xe.target.input.content=="string"?xe.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(An,{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&&!fe&&t.jsx(ME,{trigger:d})]}),t.jsx("p",{className:"mt-2 break-words font-mono text-small text-muted-foreground",children:te?`Webhook · ${aE(te.source)}`:he?`GitHub · ${cE(he.source)}`:ge?`App · ${iE(ge.source)}`:be?`Feed · ${lE(be.source)}`:t.jsx("span",{title:PE(d),children:hy(xe.source,d.next_at,{instead:OE(fe),now:i()})})})]}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 self-stretch sm:self-auto",children:[!(fe&&"ran"in fe)&&t.jsx(B,{size:"sm",onClick:()=>void Fe(),disabled:y!==null,children:d.enabled?t.jsxs(t.Fragment,{children:[t.jsx(rl,{"aria-hidden":!0})," Pause"]}):t.jsxs(t.Fragment,{children:[t.jsx(Qo,{"aria-hidden":!0})," Resume"]})}),t.jsxs(B,{size:"sm",onClick:()=>n(`${Dn(r)}/edit`),children:[t.jsx(qx,{"aria-hidden":!0})," ",te||he||ge?"Edit filter":be?"Edit feed":"Edit"]}),te&&(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),Ee()},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||O,children:[t.jsx(Ia,{"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),Pe()},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(DN,{"aria-hidden":!0})," Delete"]}),t.jsxs(B,{size:"sm",variant:"solid",onClick:()=>void ae(),disabled:y==="fire",children:[t.jsx(eR,{"aria-hidden":!0})," ",y==="fire"?"Starting":"Run now"]})]})]}),tm(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:[tm(d,c)," ",((ot=d.disabled)==null?void 0:ot.reason)==="source_unreadable"?be?"Edit its feeds, then Resume.":"Edit its when, then Resume.":((me=d.disabled)==null?void 0:me.reason)==="auto_paused"?fe&&"passed"in fe?"Its time has passed: edit its time first, then Resume.":fe?"":"Resume turns it on again.":""]}),h&&t.jsx(Jt,{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}),te&&$&&t.jsx(Sy,{label:"The webhook's new secret",secret:$}),be&&t.jsx(lU,{check:be.last_check??null,newest:f[0]}),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:dn(xe.target.agent_id),className:"hover:underline",children:s(xe.target.agent_id)||xe.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:$e??JSON.stringify(xe.target.input)}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Cost cap"}),t.jsx("dd",{className:"font-mono",children:D6(xe.target.max_cost_usd,Y)}),te?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:Qc(te)}),t.jsx(zE,{text:Qc(te),label:"Copy URL"}),t.jsx("span",{className:"basis-full text-small text-muted-foreground",children:vy})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Signature"}),t.jsx("dd",{children:jx[te.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:(Le=te.source.accept)!=null&&Le.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:te.source.accept.map((oe,Se)=>t.jsx("li",{children:Uo(oe)},Se))}):"Every signed request"})]}):ge?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:ge.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:ge.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(ge.source.config).length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:Object.entries(ge.source.config).map(([oe,Se])=>t.jsxs("li",{children:[oe,": ",typeof Se=="string"?Se:JSON.stringify(Se)]},oe))}):"None"}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(Ze=ge.source.accept)!=null&&Ze.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:ge.source.accept.map((oe,Se)=>t.jsx("li",{children:Uo(oe)},Se))}):"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:R?t.jsx("span",{"data-on-composio":R,className:R==="missing"?"text-warning-text":void 0,children:X8[R]}):t.jsx("span",{className:"text-muted-foreground",children:"Not read"})})]}):he?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:he.source.accept.map((oe,Se)=>t.jsx("li",{children:Uo(oe)},Se))}),t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:"From this server's GitHub App (Settings → GitHub)."})]})]}):be?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Feeds"}),t.jsx("dd",{className:"min-w-0 break-words",children:t.jsx("ul",{className:"space-y-1 font-mono text-small",children:be.source.urls.map(oe=>t.jsx("li",{className:"break-all",children:dr(oe)?t.jsx("a",{href:dr(oe),target:"_blank",rel:"noreferrer",className:"hover:underline",children:oe}):oe},oe))})}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Read"}),t.jsxs("dd",{children:["Every ",my(be.source.every_s??pE)]}),(be.source.items!==void 0||be.source.id!==void 0)&&t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"JSON list"}),t.jsxs("dd",{className:"min-w-0 break-words font-mono text-small",children:["Items at ",be.source.items?be.source.items:"the whole document"," · Id at ",be.source.id??"/id"]})]}),t.jsx("dt",{className:"caps text-label text-muted-foreground",children:"Accepts"}),t.jsx("dd",{className:"min-w-0 break-words",children:(yt=be.source.accept)!=null&&yt.length?t.jsx("ul",{className:"space-y-1 font-mono text-small",children:be.source.accept.map((oe,Se)=>t.jsx("li",{children:Uo(oe)},Se))}):"Every new or updated item"})]}):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(oe=>t.jsxs("li",{"data-firing":oe.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(ke,{tone:H8[oe.status],children:H6[oe.status]}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:pl(oe.nominal_at)})]}),t.jsx("span",{className:"min-w-0 flex-1 break-words",children:oe.status==="started"?`${F6[oe.by]}${oe.catch_up?", caught up late":""}`:`${dE(oe)}${oe.catch_up?" · caught up late":""}${oe.by==="manual"?" · Run now":""}`}),oe.run_id&&t.jsxs("a",{href:`#/runs/${encodeURIComponent(oe.run_id)}`,className:"shrink-0 font-mono text-small underline-offset-2 hover:underline",children:["Run ",na(oe.run_id)]})]},oe.key))}):t.jsx("p",{className:"mt-2 font-mono text-small text-muted-foreground",children:"Not fired yet."})]})]})}function eU({v2:e,go:n,id:s,minEvery:r,now:o}){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(Ht(b,"the trigger")))},[e,s,f]),i?xy(i)||oE(i)||by(i)?t.jsx(iU,{v2:e,go:n,trigger:i}):hE(i)?t.jsx(WE,{v2:e,go:n,trigger:i,minEvery:r}):gy(i)?t.jsx(IE,{v2:e,go:n,trigger:i,minEvery:r,now:o}):t.jsx(LE,{}):d?t.jsx(Jt,{problem:d,onRetry:()=>g(b=>b+1)}):t.jsx(Un,{label:"Loading the trigger",rows:4})}function Pt({label:e,field:n,issue:s,hint:r,children:o}){return t.jsx(wt,{className:"min-w-0",label:e,hint:r,error:s?t.jsx("span",{"data-issue":n,children:s}):void 0,children:o})}const Rd=e=>e!==void 0?`${ra(e)}, the agent's default`:void 0;async function Ad(e){const n=[];let s=null;for(let r=0;r<20;r++){const o=await e.listAgents({cursor:s});if(n.push(...o.agents),s=o.next_cursor,!s)break}return n}function IE({v2:e,go:n,trigger:s,minEvery:r,now:o=Date.now}){var z,U,q;const[i,c]=p.useState(()=>s?l8(s):nE()),[d,u]=p.useState(null),[f,g]=p.useState({}),[b,x]=p.useState([]),[h,v]=p.useState(!1),y=p.useRef(Ys()).current;p.useEffect(()=>{Ad(e).then(u,()=>u([]))},[e]);const j=H=>K=>c(W=>({...W,[H]:K})),k=H=>{var W;j("at")(H);const K=Bi(H,(W=i.read)==null?void 0:W.at);K!==null&&Date.parse(K)>o()?g(({"source.at":G,...F})=>F):K!==null&&g(G=>G["source.at"]?{...G,"source.at":S0(K,{now:o()})}: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=(z=(d??[]).find(H=>H.agent_id===i.agentId))==null?void 0:z.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:K,issues:W}=E0(i,$);if(x([]),!K){g(W??{});return}g({}),v(!0);try{if(s){const F=$0(s,K);Object.keys(F).length&&await e.updateTrigger(s.id,F),n(Dn(s.id))}else{const F=await e.createTrigger(K,y.keyFor("createTrigger",K));n(Dn(F.id))}}catch(F){const D=Tl(F),Y=i.kind==="at"?Bi(i.at,(G=i.read)==null?void 0:G.at):null,se=D.fields["source.at"];se&&Y!==null&&(Date.parse(Y)<=o()||G8.test(se))&&(D.fields["source.at"]=S0(Y,{now:o()})),g(Object.fromEntries(Object.entries(D.fields).filter(([Q])=>E.has(Q)))),x([...D.rest,...Object.entries(D.fields).filter(([Q])=>!E.has(Q)).map(([,Q])=>Q)]),v(!1)}},M=s?E0(i,$).body:void 0,O=!!(s&&M&&$0(s,M).source),L=i.kind==="at"?Bi(i.at,(U=i.read)==null?void 0:U.at):null,R=i.startAt?Bi(i.startAt,(q=i.read)==null?void 0:q.startAt):null,A=Cl((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?Dn(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(An,{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(um,{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,K)=>t.jsx("p",{children:H},K))}),t.jsxs("div",{className:`mt-5 ${cd}`,children:[t.jsx(Pt,{label:"Name",field:"name",issue:f.name,children:t.jsx(Me,{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:K})=>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"}),K]},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(Pt,{label:"Runs",field:"source.cron",issue:f["source.cron"],children:t.jsx(yE,{label:"Runs",name:"cron",value:i.cron,onChange:j("cron")})}),i.kind==="at"&&t.jsx(Pt,{label:"At, your time",field:"source.at",issue:f["source.at"],hint:L?`= ${C0(L)}`:void 0,children:t.jsx(Me,{name:"at",type:"datetime-local",step:60,value:i.at,onChange:H=>k(H.target.value)})}),i.kind==="every"&&t.jsx(Pt,{label:"Every",field:"source.every_s",issue:f["source.every_s"],hint:r?yy(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(Me,{name:"every",inputMode:"decimal",value:i.every,onChange:H=>j("every")(H.target.value),placeholder:"5"}),t.jsx(Et,{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(Pt,{label:"Time zone",field:"source.timezone",issue:f["source.timezone"],hint:"The time zone this schedule runs in.",children:t.jsx(bE,{name:"timezone",label:"Time zone",className:"w-full",value:i.timezone,onChange:j("timezone")})}),i.kind==="every"&&t.jsx(Pt,{label:"Starting, your time (optional)",field:"source.start_at",issue:f["source.start_at"],hint:R?`= ${C0(R)}`:void 0,children:t.jsx(Me,{name:"startAt",type:"datetime-local",step:60,value:i.startAt,onChange:H=>j("startAt")(H.target.value)})})]}),O&&t.jsx("p",{className:"mt-3 text-small text-warning-text",role:"note",children:"Changing when restarts the schedule from now."})]}),t.jsx(Pt,{label:"Agent",field:"target.agent_id",issue:f["target.agent_id"],children:t.jsx(Et,{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"},...A.map(H=>({value:H.agent_id,label:`${H.definition.name||H.agent_id}${H.kind==="workflow"?" (workflow)":""}`})),...i.agentId&&d&&!A.some(H=>H.agent_id===i.agentId)?[{value:i.agentId,label:i.agentId}]:[]]})}),t.jsx(Pt,{label:"Each run is asked",field:"target.input",issue:f["target.input"],children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:i.content,onChange:H=>j("content")(H.target.value)})}),t.jsx(Pt,{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 (${ra(N)}) if empty.`:$?"Uses the agent's default if empty.":"Required: each run this schedule starts stops at this spend.",children:t.jsx(Me,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:i.maxCost,onChange:H=>j("maxCost")(H.target.value),placeholder:Rd(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?Dn(s.id):"#/triggers"),children:"Cancel"})]})]})}function zE({text:e,label:n}){const[s,r]=p.useState(null),o="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(o);return}c.writeText(e).then(()=>r("Copied"),()=>r(o))};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(Ya,{"aria-hidden":!0})," ",n]}),s&&t.jsx("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:s})]})}function Sy({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(Ex,{title:"URL",text:s,label:"Copy URL",hint:vy}),t.jsx(Ex,{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 Ex({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(zE,{text:n,label:s})]}),r&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:r})]})}const tU=["standard","github"];function nU({v2:e,go:n}){var $;const[s,r]=p.useState(q6),[o,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(Ys()).current;p.useEffect(()=>{Ad(e).then(i,()=>i([]))},[e]);const y=_=>M=>r(O=>({...O,[_]:M})),j=($=(o??[]).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 M=new Set(["name","source.signature","target.agent_id","target.input","target.max_cost_usd",..._d(s.accept.map(R=>R.where.length))]),{body:O,issues:L}=K6(s,k!==void 0);if(f([]),!O){d(L??{});return}d({}),b(!0);try{h(await e.createTrigger(O,v.keyFor("createTrigger",O)))}catch(R){const A=Tl(R);d(Object.fromEntries(Object.entries(A.fields).filter(([P])=>M.has(P)))),f([...A.rest,...Object.entries(A.fields).filter(([P])=>!M.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(An,{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(ol,{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 (${jx[x.source.kind==="webhook"?x.source.signature??"standard":"standard"]}). Each one starts a run.`}),x.signing_secret?t.jsx(Sy,{label:"The webhook's URL and secret",url:Qc(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(Ex,{title:"URL",text:Qc(x),label:"Copy URL",hint:vy}),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(Dn(x.id)),children:"Done"})})]});const N=Cl((o??[]).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(ol,{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((_,M)=>t.jsx("p",{children:_},M))}),t.jsxs("div",{className:`mt-5 ${cd}`,children:[t.jsx(Pt,{label:"Name",field:"name",issue:c.name,children:t.jsx(Me,{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:tU.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"}),jx[_]]},_))}),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(DE,{signature:s.signature,rules:s.accept,onChange:y("accept"),issues:c,cap:null}),t.jsx(Pt,{label:"Agent",field:"target.agent_id",issue:c["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:s.agentId,onChange:_=>y("agentId")(_),options:[{value:"",label:o?"Pick an agent":"Loading the agents"},...N.map(_=>({value:_.agent_id,label:`${_.definition.name||_.agent_id}${_.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Pt,{label:"Each run is asked",field:"target.input",issue:c["target.input"],children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:s.content,onChange:_=>y("content")(_.target.value)})}),t.jsx(Pt,{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 (${ra(k)}) if empty.`:"Required: each run this webhook starts stops at this spend.",children:t.jsx(Me,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:s.maxCost,onChange:_=>y("maxCost")(_.target.value),placeholder:Rd(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 sU({v2:e,go:n}){var A;const[s,r]=p.useState(null),[o,i]=p.useState(null),[c,d]=p.useState(0),[u,f]=p.useState(V6),[g,b]=p.useState(null),[x,h]=p.useState({}),[v,y]=p.useState([]),[j,k]=p.useState(!1),E=p.useRef(Ys()).current,S=p.useRef(!0);p.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]),p.useEffect(()=>{let P=!0;return i(null),e.githubConnection().then(z=>{P&&r(!!z&&"app_id"in z&&!!z.app_id)},z=>{P&&(z instanceof ze&&z.status===404?r(!1):i(Ht(z,"GitHub's connection")))}),()=>{P=!1}},[e,c]),p.useEffect(()=>{Ad(e).then(b,()=>b([]))},[e]);const N=P=>z=>f(U=>({...U,[P]:z})),$=(A=(g??[]).find(P=>P.agent_id===u.agentId))==null?void 0:A.definition.max_cost_usd,_=typeof $=="number"&&$>0?$:void 0,M=async P=>{P.preventDefault();const z=new Set(["name","target.agent_id","target.input","target.max_cost_usd",..._d(th(u).map(H=>H.where.length))]),{body:U,issues:q}=i8(u,_!==void 0);if(y([]),!U){h(q??{});return}h({}),k(!0);try{const H=await e.createTrigger(U,E.keyFor("createTrigger",U));S.current&&n(Dn(H.id))}catch(H){const K=Tl(H);h(Object.fromEntries(Object.entries(K.fields).filter(([W])=>z.has(W)))),y([...K.rest,...Object.entries(K.fields).filter(([W])=>!z.has(W)).map(([,W])=>W)]),k(!1)}},O=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(An,{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(hm,{className:"size-5 text-primary-text","aria-hidden":!0}),"New GitHub trigger"]});if(o)return t.jsxs("div",{className:"p-5 md:p-8",children:[O,L,t.jsx(Jt,{problem:o,onRetry:()=>d(P=>P+1),className:"mt-4"})]});if(s===null)return t.jsx(Un,{label:"Reading GitHub's connection",rows:3});if(!s)return t.jsxs("div",{className:"p-5 md:p-8",children:[O,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 R=Cl((g??[]).filter(P=>!P.archived_at));return t.jsxs("form",{onSubmit:P=>void M(P),className:"p-5 md:p-8",noValidate:!0,children:[O,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,z)=>t.jsx("p",{children:P},z))}),t.jsxs("div",{className:`mt-5 ${cd}`,children:[t.jsx(Pt,{label:"Name",field:"name",issue:x.name,children:t.jsx(Me,{name:"name",value:u.name,onChange:P=>N("name")(P.target.value),placeholder:"review PRs"})}),t.jsx(FE,{picks:u,onChange:P=>f(z=>({...z,...P})),issues:x}),t.jsx(Pt,{label:"Agent",field:"target.agent_id",issue:x["target.agent_id"],children:t.jsx(Et,{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"},...R.map(P=>({value:P.agent_id,label:`${P.definition.name||P.agent_id}${P.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Pt,{label:"Each run is asked",field:"target.input",issue:x["target.input"],hint:"The event's payload comes with it.",children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:u.content,onChange:P=>N("content")(P.target.value)})}),t.jsx(Pt,{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 (${ra(_)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(Me,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:u.maxCost,onChange:P=>N("maxCost")(P.target.value),placeholder:Rd(_)})})]}),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 rU({v2:e,go:n,noAddress:s}){var xe;const[r,o]=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(Z6),[k,E]=p.useState(null),[S,N]=p.useState({}),[$,_]=p.useState([]),[M,O]=p.useState(null),[L,R]=p.useState(null),[A,P]=p.useState(!1),z=p.useRef(Ys()).current,U=p.useRef(!0);p.useEffect(()=>(U.current=!0,()=>{U.current=!1}),[]),p.useEffect(()=>{let fe=!0;return c(null),e.listMcpServers().then(De=>{if(!fe)return;const Fe=De.servers.filter(Pe=>Pe.source==="composio");o(Fe),Fe.length===1&&j(Pe=>Pe.server?Pe:{...Pe,server:Fe[0].name})},De=>{fe&&c(Ht(De,"the saved MCP servers"))}),()=>{fe=!1}},[e,d]),p.useEffect(()=>{if(!y.server)return;let fe=!0;const De=y.server;return g(null),x(null),e.composioEvents(De).then(Fe=>{fe&&g({server:De,events:Fe.events})},Fe=>{fe&&x(Ht(Fe,`${De}'s events`))}),()=>{fe=!1}},[e,y.server,h]),p.useEffect(()=>{Ad(e).then(E,()=>E([]))},[e]);const q=fe=>{R(null),j(fe)},H=fe=>De=>q(Fe=>({...Fe,[fe]:De})),K=fe=>q(De=>De.server===fe?De:{...De,server:fe,event:"",config:{},where:[]}),W=fe=>{q(De=>De.event===fe?De:{...De,event:fe,config:{},where:[]}),N({})},G=(f==null?void 0:f.server)===y.server?f.events.find(fe=>fe.slug===y.event):void 0,F=J6(G==null?void 0:G.config),D=(xe=(k??[]).find(fe=>fe.agent_id===y.agentId))==null?void 0:xe.definition.max_cost_usd,Y=typeof D=="number"&&D>0?D:void 0,se=async fe=>{var Fe,Pe;const De=new Set(["name","source.server","source.event","source.config",...F.map(Ee=>`source.config.${Ee.name}`),"target.agent_id","target.input","target.max_cost_usd",...y.where.length?_d([y.where.length]):[]]);N({}),_([]),O(null),R(null),P(!0);try{const Ee=await e.createTrigger(fe,z.keyFor("createTrigger",fe));U.current&&n(Dn(Ee.id));return}catch(Ee){if(Ee instanceof ze&&Ee.code==="composio_subscription_elsewhere")R({url:typeof((Fe=Ee.details)==null?void 0:Fe.webhook_url)=="string"?Ee.details.webhook_url:"another address",body:fe});else if(Ee instanceof ze&&Ee.code.startsWith("composio_"))_([Ee.message]),Ee.code==="composio_not_connected"&&O(dr(typeof((Pe=Ee.details)==null?void 0:Pe.connect_url)=="string"?Ee.details.connect_url:null)??null);else{const ae=Tl(Ee);N(Object.fromEntries(Object.entries(ae.fields).filter(([$e])=>De.has($e)))),_([...ae.rest,...Object.entries(ae.fields).filter(([$e])=>!De.has($e)).map(([,$e])=>$e)])}}P(!1)},Q=()=>t8(y,F,Y!==void 0),re=fe=>{fe.preventDefault();const{body:De,issues:Fe}=Q();if(_([]),O(null),!De){N(Fe??{});return}se(De)},te=()=>{const fe=L;R(null),fe&&se({...fe.body,source:{...fe.body.source,move_subscription:!0}})},he=t.jsxs("a",{href:"#/triggers",className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(An,{className:"size-3.5","aria-hidden":!0})," Triggers"]}),ge=t.jsxs("h1",{className:"mt-3 flex items-center gap-2 text-2xl font-semibold",children:[t.jsx(dm,{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:[he,ge,t.jsx(Jt,{problem:i,onRetry:()=>u(fe=>fe+1),className:"mt-4"})]});if(r===null)return t.jsx(Un,{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:[he,ge,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 be=Cl((k??[]).filter(fe=>!fe.archived_at));return t.jsxs("form",{onSubmit:re,className:"max-w-2xl p-5 md:p-8",noValidate:!0,children:[he,ge,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:Ny}),$.length>0&&t.jsxs("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:[$.map((fe,De)=>t.jsx("p",{className:"break-words",children:fe},De)),M&&t.jsx("a",{href:M,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(Pt,{label:"Name",field:"name",issue:S.name,children:t.jsx(Me,{name:"name",value:y.name,onChange:fe=>H("name")(fe.target.value),placeholder:"new issues"})}),t.jsx(Pt,{label:"Composio server",field:"source.server",issue:S["source.server"],children:t.jsx(Et,{name:"server",label:"Composio server",className:"w-full",value:y.server,onChange:K,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(Jt,{problem:b,onRetry:()=>v(fe=>fe+1),className:""}):t.jsx(Pt,{label:"Event",field:"source.event",issue:S["source.event"],hint:G==null?void 0:G.description,children:t.jsx(Et,{name:"event",label:"Event",className:"w-full",value:y.event,onChange:W,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(ur,{issues:S,field:"source.config"}),F.length?t.jsx("div",{className:"space-y-4",children:F.map(fe=>t.jsx(oU,{field:fe,value:y.config[fe.name]??fe.initial,issue:S[`source.config.${fe.name}`],onChange:De=>q(Fe=>({...Fe,config:{...Fe.config,[fe.name]:De}}))},`${G.slug}:${fe.name}`))}):t.jsx("p",{className:"text-small text-muted-foreground",children:"This event takes no config."})]}),t.jsx(UE,{where:y.where,onChange:H("where"),issues:S})]}),t.jsx(Pt,{label:"Agent",field:"target.agent_id",issue:S["target.agent_id"],children:t.jsx(Et,{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"},...be.map(fe=>({value:fe.agent_id,label:`${fe.definition.name||fe.agent_id}${fe.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Pt,{label:"Each run is asked",field:"target.input",issue:S["target.input"],hint:"What Composio delivered comes with it.",children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:y.content,onChange:fe=>H("content")(fe.target.value)})}),t.jsx(Pt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:S["target.max_cost_usd"],hint:Y!==void 0?`Uses the agent's default (${ra(Y)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(Me,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:y.maxCost,onChange:fe=>H("maxCost")(fe.target.value),placeholder:Rd(Y)})})]}),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:te,children:"Move it here"}),t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>R(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:A||!!L||s,children:A?"Creating":"Create app trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n("#/triggers"),children:"Cancel"})]})]})}function oU({field:e,value:n,issue:s,onChange:r}){const o=`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:o,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(wt,{className:"min-w-0",label:e.title,required:e.required,optional:!e.required,hint:e.description,error:i,children:e.options?t.jsx(Et,{name:o,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(nn,{name:o,rows:3,className:"p-3 font-mono",value:n,onChange:c=>r(c.target.value),spellCheck:!1}):t.jsx(Me,{name:o,inputMode:e.type==="string"?void 0:"decimal",value:n,onChange:c=>r(c.target.value),autoComplete:"off",spellCheck:!1})})})}function aU(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 DE({signature:e,rules:n,onChange:s,issues:r,cap:o}){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(ur,{issues:r,field:"source.accept"}),t.jsx(RE,{name:"accept",rules:n,onChange:s,issues:r,room:$d.rules-n.length,eventHint:TE[e],eventPlaceholder:e==="github"?"issues":"issue.opened"}),t.jsx("p",{className:"text-small text-muted-foreground",role:"note",children:aU(n.length>0,o)})]})]})}function FE({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]}),o=th(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:fE.map(i=>{const c=o.indexOf(`event:${i}`),d=`source.accept[${c}]`;return t.jsxs("div",{"data-github-event":i,className:"space-y-1",children:[eh.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(ur,{issues:s,field:u},u)),t.jsx(ah,{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(RE,{name:"other",rules:e.other,onChange:i=>n({...e,other:i}),issues:s,indexOf:i=>{var c;return o.indexOf(`other:${(c=e.other[i])==null?void 0:c.key}`)},room:$d.rules-o.length,eventHint:TE.github,eventPlaceholder:"issues",addLabel:"Add another event"})]})]})}function iU({v2:e,go:n,trigger:s}){const r=xy(s)?s:null,o=by(s)?s:null,[i,c]=p.useState(()=>r?(r.source.accept??[]).map(Xf):o?(o.source.accept??[]).map(Xf):[]),[d,u]=p.useState(()=>r||o?{events:[],where:{},other:[]}:Q6(s.source.accept)),f=o&&i[0]&&!i[0].actions.trim()?i[0]:null,g=o?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:M}=r?uE(r.source,i):o?e8(o.source,(f==null?void 0:f.where)??[],g,f==null?void 0:f.was):mE(d);if(v([]),Object.keys(M).length){x(M);return}x({}),j(!0);try{Zc(_,s.source)||await e.updateTrigger(s.id,{source:_}),k.current&&n(Dn(s.id))}catch(O){if(!k.current)return;const L=Tl(O),R=_d(r||o?i.map(A=>A.where.length):th(d).map(A=>A.where.length));x(Object.fromEntries(Object.entries(L.fields).filter(([A])=>R.has(A)))),v([...L.rest,...Object.entries(L.fields).filter(([A])=>!R.has(A)).map(([,A])=>A)]),j(!1)}},S=r?ol:o?dm:hm,N=$=>c(f?$.length?[{...f,where:$},...g]:g:$.length?[{...YC(),event:o.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:Dn(s.id),className:"caps flex items-center gap-2 text-label text-muted-foreground hover:text-foreground",children:[t.jsx(An,{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.":o?`Which ${o.source.event} events from ${o.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(DE,{signature:r.source.signature??"standard",rules:i,onChange:c,issues:b,cap:s.max_active_runs??null}):o?t.jsx(UE,{where:(f==null?void 0:f.where)??[],onChange:N,issues:b,others:g.map($=>$.event+($.actions.trim()?` (${$.actions.trim()})`:""))}):t.jsx(FE,{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(Dn(s.id)),children:"Cancel"})]})]})}function UE({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(ur,{issues:s,field:"source.accept"}),t.jsx(ur,{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(ah,{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(", "),"."]})]})]})}function lU({check:e,newest:n}){const s=n&&n.by==="feed"&&n.status==="skipped"&&!n.run_id&&n.reason?n.reason:null;return t.jsxs("section",{"aria-label":"Last check","data-last-check":e?e.ok?"ok":"failed":"none",className:`mt-4 border px-4 py-3 text-body ${e&&!e.ok?"border-warning/50 bg-warning/10":"border-primary/50 bg-primary/5"}`,children:[t.jsx("p",{className:"caps text-label text-muted-foreground",children:e?`${e.ok?"Last check":"Last check failed"} · ${pl(e.at)}`:"Not checked yet"}),e&&t.jsx("p",{className:`mt-1 break-words ${e.ok?"":"text-warning-text"}`,children:e.message}),s&&t.jsx("p",{className:"mt-1 break-words","data-note":!0,children:s})]})}function WE({v2:e,go:n,trigger:s,minEvery:r}){var L;const[o,i]=p.useState(()=>s?s8(s):gE()),[c,d]=p.useState(null),[u,f]=p.useState({}),[g,b]=p.useState([]),[x,h]=p.useState(!1),[v,y]=p.useState(()=>!!s&&(s.source.items!==void 0||s.source.id!==void 0));p.useEffect(()=>{(u["source.items"]||u["source.id"])&&y(!0)},[u]);const j=p.useRef(Ys()).current,k=p.useRef(!0);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]),p.useEffect(()=>{s||Ad(e).then(d,()=>d([]))},[e,s]);const E=R=>A=>i(P=>({...P,[R]:A})),S=(L=(c??[]).find(R=>R.agent_id===o.agentId))==null?void 0:L.definition.max_cost_usd,N=typeof S=="number"&&S>0?S:void 0,$=async R=>{R.preventDefault();const A=a8(xE(o.urls).urls.length,[o.where.length,...o.others.map(q=>q.where.length)]);b([]);const P=q=>{if(!k.current)return;const H=Tl(q);f(Object.fromEntries(Object.entries(H.fields).filter(([K])=>A.has(K)))),b([...H.rest,...Object.entries(H.fields).filter(([K])=>!A.has(K)).map(([,K])=>K)]),h(!1)};if(s){const{source:q,issues:H}=vE(o,r);if(Object.keys(H).length){f(H);return}f({}),h(!0);try{Zc(q,s.source)||await e.updateTrigger(s.id,{source:q}),k.current&&n(Dn(s.id))}catch(K){P(K)}return}const{body:z,issues:U}=o8(o,r,N!==void 0);if(!z){f(U??{});return}f({}),h(!0);try{const q=await e.createTrigger(z,j.keyFor("createTrigger",z));k.current&&n(Dn(q.id))}catch(q){P(q)}},_=Object.entries(u).filter(([R])=>/^source\.urls(\[\d+\])?$/.test(R)),M=Cl((c??[]).filter(R=>!R.archived_at)),O=o.others.map(R=>R.event+(R.actions.trim()?` (${R.actions.trim()})`:""));return t.jsxs("form",{onSubmit:R=>void $(R),className:"p-5 md:p-8",noValidate:!0,children:[t.jsxs("a",{href:s?Dn(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(An,{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(Vx,{className:"size-5 text-primary-text","aria-hidden":!0}),s?"Edit feed":"New feed trigger"]}),t.jsx("p",{className:"mt-2 text-body text-muted-foreground",children:s?"The feeds it reads, how often, and which items start a run. Its name, its agent and what each run is asked stay as they are.":"Each new or updated item in its feeds starts a capped run of the agent. The items already there when it is made start none: its first check, on its page once it is made, says how many."}),g.length>0&&t.jsx("div",{className:"mt-4 border border-destructive/50 p-3 text-body text-destructive-text",role:"alert",children:g.map((R,A)=>t.jsx("p",{children:R},A))}),t.jsxs("div",{className:`mt-5 ${cd}`,children:[!s&&t.jsx(Pt,{label:"Name",field:"name",issue:u.name,children:t.jsx(Me,{name:"name",value:o.name,onChange:R=>E("name")(R.target.value),placeholder:"vendor outages"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(wt,{className:"min-w-0",label:"Feed URLs",hint:`One a line, 1 to ${Nx}: RSS, Atom, JSON Feed, or an API's JSON list. Plain http is read on a public address alone.`,error:_.length?t.jsx(t.Fragment,{children:_.map(([R,A])=>t.jsx("span",{"data-issue":R,className:"block",children:A},R))}):void 0,children:t.jsx(nn,{name:"urls",rows:4,className:"p-3 font-mono text-small",value:o.urls,onChange:R=>E("urls")(R.target.value),placeholder:"https://www.githubstatus.com/history.atom",spellCheck:!1})}),s&&t.jsx("p",{className:"mt-2 text-small text-warning-text",role:"note",children:"A feed you add starts from now: what's in it already won't start runs."})]}),t.jsx(Pt,{label:"Every",field:"source.every_s",issue:u["source.every_s"],hint:r?yy(r):void 0,children:t.jsxs("span",{className:"flex gap-2",children:[t.jsx(Me,{name:"every",inputMode:"decimal",value:o.every,onChange:R=>E("every")(R.target.value),placeholder:"15"}),t.jsx(Et,{id:"feed-every-unit",name:"everyUnit",label:"Unit",className:"w-32 shrink-0",value:o.everyUnit,onChange:R=>E("everyUnit")(R),options:["seconds","minutes","hours"].map(R=>({value:R,label:R}))})]})}),t.jsxs("details",{"data-json-list":!0,open:v,onToggle:R=>y(R.currentTarget.open),className:"min-w-0 border p-3",children:[t.jsxs("summary",{className:"cursor-pointer text-body font-semibold",children:["JSON list ",t.jsx("span",{className:"font-normal text-small text-muted-foreground",children:"(optional: a feed that is an API's JSON, such as GitHub's pull requests)"})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[t.jsx(Pt,{label:"Items at",field:"source.items",issue:u["source.items"],hint:"A JSON Pointer to the array of items: empty for the whole document, /data/items for one inside it.",children:t.jsx(Me,{name:"items",value:o.items,onChange:R=>E("items")(R.target.value),placeholder:"/data/items",autoComplete:"off",spellCheck:!1})}),t.jsx(Pt,{label:"Each item's id at",field:"source.id",issue:u["source.id"],hint:"A JSON Pointer into an item to what names it: empty for /id, /number for a pull request.",children:t.jsx(Me,{name:"id",value:o.id,onChange:R=>E("id")(R.target.value),placeholder:"/id",autoComplete:"off",spellCheck:!1})})]})]}),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(ur,{issues:u,field:"source.accept"}),t.jsx(ur,{issues:u,field:"source.accept[0]"}),t.jsx("p",{className:"text-small text-muted-foreground",children:"A condition reads the item: /title, /link, /summary, /author, /categories, /feed/url, and /update (true for an item seen before that was updated). A JSON list's item is under /item."}),t.jsx(ah,{name:"feed",at:"source.accept[0]",where:o.where,onChange:E("where"),issues:u,label:"Only when"}),O.length>0&&t.jsxs("p",{className:"text-small text-muted-foreground",role:"note",children:[O.length===1?"One more rule, made through the API, is kept as it is":`${O.length} more rules, made through the API, are kept as they are`,": ",O.join(", "),"."]})]})]}),!s&&t.jsxs(t.Fragment,{children:[t.jsx(Pt,{label:"Agent",field:"target.agent_id",issue:u["target.agent_id"],children:t.jsx(Et,{name:"agent",label:"Agent",className:"w-full",value:o.agentId,onChange:R=>E("agentId")(R),options:[{value:"",label:c?"Pick an agent":"Loading the agents"},...M.map(R=>({value:R.agent_id,label:`${R.definition.name||R.agent_id}${R.kind==="workflow"?" (workflow)":""}`}))]})}),t.jsx(Pt,{label:"Each run is asked",field:"target.input",issue:u["target.input"],hint:"The item comes with it: its title, link, summary and feed.",children:t.jsx(nn,{name:"content",rows:4,className:"p-3 font-sans",value:o.content,onChange:R=>E("content")(R.target.value)})}),t.jsx(Pt,{label:"Cost cap, US dollars a run",field:"target.max_cost_usd",issue:u["target.max_cost_usd"],hint:N!==void 0?`Uses the agent's default (${ra(N)}) if empty.`:"Required: each run this trigger starts stops at this spend.",children:t.jsx(Me,{name:"maxCost",inputMode:"decimal",className:"max-w-64",value:o.maxCost,onChange:R=>E("maxCost")(R.target.value),placeholder:Rd(N)})})]})]}),t.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[t.jsx(B,{type:"submit",size:"lg",variant:"solid",disabled:x,children:x?s?"Saving":"Creating":s?"Save feed":"Create feed trigger"}),t.jsx(B,{type:"button",size:"lg",variant:"ghost",onClick:()=>n(s?Dn(s.id):"#/triggers"),children:"Cancel"})]})]})}const HE=e=>e?"#/playground?operation=apply-template":"#/templates";function R0({v2:e,name:n,install:s,go:r,playground:o=!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(Ht(v,"the templates"))}),()=>{h=!1}},[e,g,s]),s!==void 0)return t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(dU,{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(Jt,{problem:u,onRetry:()=>b(h=>h+1),className:""}):c?n===void 0?t.jsx(cU,{v2:e,templates:c,go:r,playground:o,onRemoved:()=>b(h=>h+1)}):x?t.jsx(hU,{v2:e,template:x,go:r,playground:o,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:HE(o),className:"underline",children:"See its templates"}),"."]}):t.jsx(Un,{label:"Loading the templates",rows:3})})}function Cy({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 cU({v2:e,templates:n,go:s,playground:r,onRemoved:o}){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),o()}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(uU(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(Me,{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":Wo(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(Bx,{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:Wo(v)}),t.jsx("span",{className:"font-mono text-small text-muted-foreground",children:v.version}),v.category&&t.jsx(ke,{tone:"muted",children:v.category}),!v.bundled&&t.jsx(ke,{tone:"muted",children:"Imported"})]}),t.jsx(Cy,{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:jy(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(tl(v)),children:"Configure"}):t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:nm(v)?"primary":"outline",onClick:()=>s(jE(v.id)),children:"Configure"}),t.jsx(sn,{variant:nm(v)?"outline":"primary",label:"Run",prompt:sx(location.origin,v),playgroundHref:tl(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 dU({v2:e,source:n,go:s}){var E;const[r,o]=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&&o(N)},N=>{S&&c(A0(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(jE(S.template.id))}catch(S){x(A0(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(An,{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(Un,{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:[Wo(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(cr,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:jy(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(cr,{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(BE,{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(GE,{t:y}),t.jsx(qE,{t:y}),t.jsx(cr,{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(cr,{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(cr,{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 A0(e){var n;return e instanceof ze&&((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 uU=e=>`#/templates/install?src=${encodeURIComponent(e)}`,fU=3e3;function mU(e,n){let s;const r=new Promise(o=>s=setTimeout(()=>o(void 0),n));return Promise.race([e,r]).finally(()=>clearTimeout(s))}function hU({v2:e,template:n,go:s,playground:r=!1,draft:o}){var $t,nt,ft,Dt,Ft,ye,de,Ue,Xe,at;const i=r?"h2":"h1",c={fields:sh(n.parameters)??[]},d=w8(o,n),[u,f]=p.useState(()=>{var J;return{...Object.fromEntries(c.fields.filter(([,ve])=>ve.type==="boolean"&&!ve.array).map(([ve])=>[ve,"false"])),...CE(c),...Object.fromEntries(Object.entries(((J=d.body)==null?void 0:J.parameters)??{}).map(([ve,We])=>[ve,Array.isArray(We)?We.map(String).join(`
|
|
664
|
+
`):String(We)]))}}),[g,b]=p.useState(()=>{var J;return new Set(((J=d.body)==null?void 0:J.grants)??[])}),[x,h]=p.useState(((nt=($t=d.body)==null?void 0:$t.overrides)==null?void 0:nt.approvals)??n.approvals_default??"ask"),[v,y]=p.useState(((Dt=(ft=d.body)==null?void 0:ft.overrides)==null?void 0:Dt.choice)??""),[j,k]=p.useState(null),[E,S]=p.useState(null),[N,$]=p.useState(0),[_,M]=p.useState(()=>{var J;return((J=d.body)==null?void 0:J.servers)??{}}),[O,L]=p.useState(!1),[R,A]=p.useState([]),[P,z]=p.useState(null),[U,q]=p.useState(null),[H,K]=p.useState([]),[W,G]=p.useState({}),F=p.useRef(Ys()).current,D=p.useRef(!0);p.useEffect(()=>(D.current=!0,()=>{D.current=!1}),[]),p.useEffect(()=>{let J=!0;return S(null),e.listMcpServers().then(ve=>{J&&k(ve.servers)},ve=>{J&&S(Ht(ve,"the saved MCP servers"))}),()=>{J=!1}},[e,N]);const Y=E8(n,g),se=n.mcp.map(J=>{const ve=j?N8(J,j):[];return{m:J,matches:ve,uses:ve.length===1?ve[0]:ve.includes(_[J.toolkit]??"")?_[J.toolkit]:void 0}}),Q=Object.fromEntries(se.flatMap(({m:J,uses:ve})=>ve?[[J.toolkit,ve]]:[])),re=se.filter(({matches:J,uses:ve})=>J.length>1&&!ve).map(({m:J})=>J.toolkit),te=n.mcp.length>0&&j===null,he=j&&se.some(({m:J,matches:ve})=>{var We,Ve;return((Ve=(We=d.body)==null?void 0:We.servers)==null?void 0:Ve[J.toolkit])!==void 0&&!ve.includes(d.body.servers[J.toolkit])}),ge=d.error??(he?"This prepared server choice no longer matches the saved MCP servers. Open a fresh request to review the current accounts.":void 0),be=!!ge||te||re.length>0,xe=r||nm(n),fe=!r&&nm(n)?T0.filter(J=>J.needs(n)):[],[De,Fe]=p.useState({}),[Pe,Ee]=p.useState(0),ae=fe.map(J=>J.id).join(" ");p.useEffect(()=>{let J=!0;for(const ve of T0.filter(We=>ae.split(" ").includes(We.id)))ve.met(e).then(We=>{J&&Fe(Ve=>({...Ve,[ve.id]:We?"met":"unmet"}))},()=>{J&&Fe(We=>({...We,[ve.id]:"unread"}))});return()=>{J=!1}},[e,ae,Pe]);const $e=fe.filter(J=>De[J.id]!=="met"),ot=$e.find(J=>De[J.id]===void 0),me=$e.length>0;p.useEffect(()=>{if(!me)return;const J=()=>Ee(ve=>ve+1);return window.addEventListener("focus",J),()=>window.removeEventListener("focus",J)},[me]);const Le={parameters:oh(c,u),...Y.length?{grants:Y}:{},...Object.keys(Q).length?{servers:Q}:{},overrides:{approvals:x,...v?{choice:v}:{}}},Ze=J=>$8(R,J),yt=(J,ve,We)=>{f(Ve=>({...Ve,[J]:We})),SE(ve,We)&&A(Ve=>Ve.filter(He=>Cx(He.field,"parameters")!==J))},oe=async()=>{var ve,We;if(!xe||be||$e.length)return;L(!0),A([]),z(null);const J=u;try{const Ve=await e.applyTemplate(n.id,Le,F.keyFor(n.id,Le));F.done();const He=async()=>(await Promise.all(Ve.trigger_ids.map(lt=>mU(e.getTrigger(lt),fU).catch(()=>null)))).filter(lt=>lt!=null&&gy(lt));if(Ve.warnings.length||(ve=Ve.webhook_secrets)!=null&&ve.length){G(J),q(Ve),He().then(K,()=>{});return}const gt=Ve.trigger_ids.length?await He():[];if(!D.current)return;if(!gt.length){s(dn(Ve.agent_id));return}G(J),K(gt),q(Ve)}catch(Ve){Ve instanceof ze&&((We=Ve.fields)!=null&&We.length)?(A(Ve.fields),z({text:Ve.message,withIssues:!0}),Ve.fields.some(He=>He.field.startsWith("servers.")||He.field.startsWith("mcp."))&&$(He=>He+1)):z({text:Ve instanceof Error?Ve.message:String(Ve),withIssues:!1})}finally{L(!1)}},Se=c.fields,tt=J=>J.filter(ve=>!n.secrets.includes(ve)),Ae=(ye=(Ft=n.model)==null?void 0:Ft.choices)==null?void 0:ye.find(J=>J.id===v),it=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,...tt((Ae==null?void 0:Ae.secrets)??[])].includes(J.field.slice(8))};return U?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(xl,{className:"size-5 text-success-text","aria-hidden":!0})," ",Wo(n,W)," applied"]}),U.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:U.warnings.map((J,ve)=>{var gt,kt;const We=/^triggers\.(\d+)\.secret$/.exec(J.field),Ve=We?U.trigger_ids[Number(We[1])]:void 0,He=We?(gt=n.triggers[Number(We[1])])==null?void 0:gt.name:void 0;return Ve&&((kt=U.webhook_secrets)!=null&&kt.some(lt=>lt.trigger_id===Ve))?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,Ve&&t.jsxs("a",{href:`#/triggers/${encodeURIComponent(Ve)}`,className:"mt-1 block font-mono text-small text-primary-text underline-offset-2 hover:underline",children:["Open ",typeof He=="string"&&He?He:Ve," to get its signing secret (Rotate)"]})]},`${J.field}:${ve}`)})})]}),(de=U.webhook_secrets)==null?void 0:de.map(J=>{var He;const ve=U.trigger_ids.indexOf(J.trigger_id),We=ve>=0?(He=n.triggers[ve])==null?void 0:He.name:void 0,Ve=typeof We=="string"&&We?We:J.trigger_id;return J.signing_secret?t.jsx(Sy,{label:`The webhook's URL and secret (${Ve})`,url:Qc({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 ",Ve," 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:hy(J.source,J.next_at)})]},J.id))}),t.jsx("div",{className:"mt-5"}),t.jsx("a",{href:dn(U.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:HE(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(An,{className:"size-3.5","aria-hidden":!0})," Templates"]}),t.jsxs(i,{className:"text-2xl font-semibold",children:[Wo(n,u)," ",t.jsx("span",{className:"text-lead font-normal text-muted-foreground",children:n.version})]}),t.jsx(Cy,{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.":xe?"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."}),ge&&t.jsxs("p",{className:"mt-3 text-body text-destructive-text",role:"alert",children:[ge," ",t.jsx("a",{href:tl(n),className:"underline",children:"Open a fresh request"}),"."]}),t.jsxs("div",{className:`mt-6 ${cd}`,children:[Se.length>0&&t.jsx(cr,{title:"Parameters",children:Se.map(([J,ve])=>t.jsxs("div",{"data-field":`parameters.${J}`,className:"px-4 py-3",children:[t.jsx(_E,{field:ve,label:rh(J,ve),help:sm(ve),value:u[J]??"",onChange:We=>yt(J,ve,We)}),t.jsx(Po,{issues:R.filter(We=>Cx(We.field,"parameters")===J),words:We=>$E(We,J,ve)})]},J))}),n.mcp.length>0&&t.jsxs(cr,{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(Jt,{problem:E,onRetry:()=>$(J=>J+1),className:""})}),se.map(({m:J,matches:ve,uses:We})=>t.jsxs("div",{"data-mcp":J.toolkit,className:"px-4 py-3",children:[t.jsx(BE,{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(Et,{small:!0,label:`Server for ${J.toolkit}`,value:We??"",placeholder:"Pick one",onChange:Ve=>M(He=>({...He,[J.toolkit]:Ve})),options:ve.map(Ve=>({value:Ve,label:Ve}))}),!We&&t.jsxs("span",{"data-unpicked":J.toolkit,children:[ve.length," saved servers are ",wd[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(Ve=>Ve.name).join(", ")}).`," ",t.jsx("a",{href:S8(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:[...Ze(`mcp.${J.toolkit}`),...Ze(`servers.${J.toolkit}`)]}),t.jsx("ul",{className:"mt-2 space-y-2",children:J.tools.map(Ve=>{const He=Y.indexOf(Ve.tool);return t.jsxs("li",{"data-tool":Ve.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(Ve.tool),onChange:()=>b(gt=>{const kt=new Set(gt);return kt.has(Ve.tool)?kt.delete(Ve.tool):kt.add(Ve.tool),kt})}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-mono text-body",children:Ve.name})," ",t.jsx("span",{className:"font-mono text-label text-muted-foreground",children:Ve.tool}),t.jsx("span",{className:"block text-small text-muted-foreground",children:Ve.asks==="allow"?"The template asks you to grant this.":"The template does not ask for this; unticked, the agent doesn't get it."})]})]}),He>=0&&t.jsx(Po,{issues:Ze(`grants.${He}`)})]},Ve.tool)})})]},J.toolkit))]}),n.secrets.length>0&&t.jsx(cr,{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:Ze(`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 ${(at=n.harness)!=null&&at.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),A(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:tt(J.secrets).flatMap(ve=>Ze(`secrets.${ve}`))})})]})]},J.id||"(default)"))}),t.jsx(Po,{issues:Ze("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:GC})]}),t.jsx(GE,{t:n}),t.jsx(qE,{t:n}),t.jsx(cr,{title:"What it makes",children:t.jsx("dl",{className:"space-y-1 px-4 py-3 font-mono text-small",children:jy(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:[xe?t.jsxs(t.Fragment,{children:[t.jsx(B,{size:"sm",variant:"primary",onClick:()=>void oe(),disabled:O||be||$e.length>0,title:te?E?"The saved MCP servers couldn't be read: try again first":"Reading the saved MCP servers…":re.length?`Pick the server for ${re.join(", ")} first`:ot?`Reading ${ot.what}…`:void 0,children:O?"Applying…":"Apply"}),!r&&t.jsx(sn,{variant:"outline",label:"Set it up with an agent",disabled:be,prompt:sx(location.origin,n,Le),playgroundHref:tl(n,Le)}),$e.map(J=>De[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):De[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:()=>Ee(ve=>ve+1),children:"Try again"})]},J.id):null)]}):t.jsx(sn,{variant:"primary",label:"Run",disabled:be,prompt:sx(location.origin,n,Le),playgroundHref:tl(n,Le)}),P&&(!P.withIssues||R.length>0)&&t.jsx("p",{className:"min-w-0 flex-1 text-body text-destructive-text",role:"alert",children:P.text})]}),R.filter(J=>!it(J)).length>0&&t.jsx("div",{className:"mt-2",children:t.jsx(Po,{issues:R.filter(J=>!it(J)),named:!0})})]})}function BE({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(ke,{tone:"muted",children:wd[e.source]}),t.jsx(ke,{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 GE({t:e}){if(!e.input_schema)return null;const n=sh(e.input_schema,"content");return n&&!n.length?null:t.jsx(cr,{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:rh(s,r)}),r.title&&t.jsx("span",{className:"text-small text-muted-foreground",children:s}),t.jsx(ke,{tone:"muted",children:F8(r)}),t.jsx(ke,{tone:r.required?"plain":"muted",children:r.required?"Required":"Optional"})]}),sm(r)&&t.jsx("p",{className:"mt-1 text-small text-muted-foreground",children:sm(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 qE({t:e}){const n=e.evals.length;return t.jsx(cr,{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 cr({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 rm(e){return{definition:{version:1,name:"New agent",instructions:e.trim(),harness:"pi",tools:[],skills:[]}}}function O0(e){return`#/playground?${new URLSearchParams({operation:"create-agent",draft:JSON.stringify(e)})}`}function pU(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(o=>typeof o=="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 gU={"code-review":fm,"inbound-lead":pm,kyb:QT,"market-monitor":VT,"release-notes":Qa};function xU({origin:e,v2:n}){const[s,r]=p.useState(""),[o,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=Im(e,s),j=rm(s);p.useEffect(()=>{let S=!0;return b(null),n.listTemplates().then(N=>{S&&f(N.templates)},N=>{S&&b(Ht(N,"the template catalog"))}),()=>{S=!1}},[n,x]);const k=c.trim().toLocaleLowerCase(),E=(u??[]).filter(S=>`${Wo(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:ie(Hc,"!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(nn,{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(sn,{variant:"primary",label:"Build an agent",prompt:y,playgroundHref:O0(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(nn,{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:ie(Hc,"flex w-full items-center gap-2 px-3 sm:w-72"),children:[t.jsx(pm,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Me,{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(Jt,{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=o===S.id,$=gU[S.name]??Bx,_=`${v}-${encodeURIComponent(S.id)}-actions`,M=[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 ${Wo(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:Wo(S)}),t.jsx(Cy,{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}),M,t.jsx(Fx,{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(sn,{variant:"primary",label:"Use this template",prompt:HP(e,S,s),playgroundHref:tl(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:O0(rm("")),children:"start from a blank agent"}),"."]})]})}const KE=p.createContext(new Map),vU={schedule:"Schedule",webhook:"Webhook",github:"GitHub",composio:"App",email:"Email",feed:"Feed"};function VE({run:e}){const n=p.useContext(KE);if(!e.trigger)return null;const{id:s}=e.trigger,r=n.get(s),o=r?`${vU[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:o,children:t.jsxs(ke,{className:"max-w-full",children:[t.jsx(um,{className:"size-3 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"truncate",children:o})]})})}const om=["queued","working","paused","input_required","completed","failed","cancelled"],yU={queued:"Queued",working:"Working",paused:"Paused",input_required:"Input required",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function bU({runs:e,agentName:n,onOpen:s,error:r,onRetry:o,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(sd,{className:"size-4","aria-hidden":!0}),b?"Archived runs":"Runs"]}),u&&t.jsxs(t.Fragment,{children:[t.jsx(Et,{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"},...om.map(v=>({value:v,label:yU[v]}))]}),t.jsxs(B,{size:"sm",variant:b?"primary":"outline","aria-pressed":b,onClick:()=>u({...d,archived:!b}),children:[t.jsx(nd,{"aria-hidden":!0})," Archived"]})]}),t.jsx(sn,{label:"Query",prompt:`${zm(location.origin,f)}
|
|
665
|
+
Current view: ${d.status?`status ${d.status}`:"all statuses"}; ${b?"archived runs":"non-archived runs"}.`,playgroundHref:_v(f,d)})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[r&&!e?t.jsx(Jt,{problem:r,onRetry:o,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(wU,{})}):!e.length&&((h=g==null?void 0:g.data)!=null&&h.sessions.length)?null:e.length?t.jsx(jU,{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(Un,{label:"Loading the runs"}),g&&t.jsx("div",{className:"p-5 md:p-8",children:t.jsx($v,{read:g})}),e&&r&&t.jsx(Jt,{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 wU(){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:al({variant:"solid",size:"lg"}),children:[t.jsx(Qo,{"aria-hidden":!0})," Start a run"]}),t.jsx("a",{href:"#/templates",className:al({variant:"outline",size:"lg"}),children:"Browse templates"})]})]})}function jU({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($l,{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:o=>{o.stopPropagation(),s(r.run_id)},children:[t.jsx("span",{className:"line-clamp-2",children:Cn(r)}),t.jsx(fr,{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(VE,{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:no(r.cost,{ended:Ga(r.status)})})]},r.run_id))})]})}function kU({agentId:e,details:n}){const{denied:s,asks:r}=DD(n),o=[...new Set([...s,...r])];return o.length?t.jsxs("p",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1",children:[o.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 NU(e,{base:n="/v2",onProgress:s,signal:r,request:o=()=>new XMLHttpRequest}={}){return new Promise((i,c)=>{if(r!=null&&r.aborted)return c(new ze(0,"aborted","The upload was stopped."));const d=o();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 ze(d.status,"bad_answer","The server's answer named no file."))}const f=u==null?void 0:u.error,g=new ze(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 ze(0,"network","The upload did not reach the server.")),d.onabort=()=>c(new ze(0,"aborted","The upload was stopped.")),r==null||r.addEventListener("abort",()=>d.abort(),{once:!0}),d.send(e)})}const SU=(e,n,s)=>NU(e,{onProgress:n,signal:s});function $g(e){if(!(e instanceof ze))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 CU({upload:e,remove:n,limits:s,frozen:r=!1}){const[o,i]=p.useState([]),[c,d]=p.useState([]),u=p.useRef(new Map),f=p.useRef(0),g=p.useRef(0);g.current=o.length;const b=p.useRef({items:o,frozen:r,remove:n});b.current={items:o,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 M of k)N!==null&&M.size>N?E.push({text:`${M.name} is ${Ba(M.size)}: this server takes files up to ${Ba(N)}.`}):$.length>=S?E.push({text:`${M.name} is not added: a run names at most ${s==null?void 0:s.max_files_per_run} files here.`}):$.push(M);d(E);const _=$.map(M=>({key:`f${f.current++}`,name:M.name,size:M.size,progress:0}));g.current+=_.length,i(M=>[...M,..._]),_.forEach((M,O)=>{const L=new AbortController;u.current.set(M.key,L);const R=A=>{x.current&&i(P=>P.map(z=>z.key===M.key?{...z,...A}:z))};e($[O],A=>R({progress:A}),L.signal).then(A=>{var P,z,U;if(u.current.delete(M.key),L.signal.aborted){(U=(z=(P=b.current).remove)==null?void 0:z.call(P,A.file_id))==null||U.catch(q=>{x.current&&d(H=>[...H,{text:`${M.name} was sent before it was stopped, and was not removed: ${$g(q)}`}])});return}R({file:A,progress:1})},A=>{u.current.delete(M.key),!(L.signal.aborted||!x.current)&&(i(P=>P.filter(z=>z.key!==M.key)),d(P=>[...P,{text:`${M.name}: ${$g(A)}`}]))})})},[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(M=>M.key===k);if(!(S||!$||$.removing)){if(!$.file||!N){(_=u.current.get(k))==null||_.abort(),u.current.delete(k),i(M=>M.filter(O=>O.key!==k));return}i(M=>M.map(O=>O.key===k?{...O,removing:!0}:O)),d(M=>M.filter(O=>O.about!==k)),N($.file.file_id).then(()=>{x.current&&i(M=>M.filter(O=>O.key!==k))},M=>{x.current&&(i(O=>O.map(L=>L.key===k?{...L,removing:!1}:L)),d(O=>[...O,{about:k,text:`${$.name} was not removed: ${$g(M)}`}]))})}},[]),y=p.useCallback(()=>{b.current={...b.current,items:[]},i([]),d([])},[]),j=o.flatMap(k=>k.file&&!k.removing?[k.file.file_id]:[]);return{items:o,refusals:c.map(k=>k.text),add:h,drop:v,clear:y,fileIds:j,frozen:r,busy:o.some(k=>!k.file||k.removing)}}function M0({attachments:e,limits:n,disabled:s,compact:r=!1}){const o=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?[`${Ba(n.max_upload_bytes)} each`]:[]].join(", "):"";return t.jsxs("div",{className:ie("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=o.current)==null?void 0:h.click()},disabled:b,title:r?`Attach files${x?` (${x})`:""}`:void 0,className:ie(r&&"max-sm:h-10 max-sm:w-10 max-sm:px-0"),children:[t.jsx(qT,{"aria-hidden":!0})," ",t.jsx("span",{className:ie(r&&"max-sm:sr-only"),children:"Attach files"})]}),t.jsxs("span",{className:ie("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:o,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:Ba(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(Xo,{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 df={"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."},Ey=(e,n)=>e instanceof ze?{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 EU({agents:e,revisions:n=[],efforts:s,origin:r,agentId:o,onAgent:i,onSend:c,onOpenRun:d,result:u=null,live:f,limits:g,upload:b=SU,removeUpload:x}){var Dt,Ft,ye;const[h,v]=p.useState(o??((Dt=e[0])==null?void 0:Dt.agent_id)??"");p.useEffect(()=>{var de;o&&o!==h&&e.some(Ue=>Ue.agent_id===o)?v(o):e.some(Ue=>Ue.agent_id===h)||v(((de=e[0])==null?void 0:de.agent_id)??"")},[e,o]);const y=e.find(de=>de.agent_id===h),j=Wv(y),k=es(y==null?void 0:y.definition),E=(y==null?void 0:y.kind)??"agentic",[S,N]=p.useState(""),[$,_]=p.useState(""),M=$?(Ft=n.find(de=>de.revision===$))==null?void 0:Ft.definition:void 0,O=E==="agentic"?JSON.stringify(((ye=M??(y==null?void 0:y.definition))==null?void 0:ye.input_schema)??null):"null",L=p.useMemo(()=>E==="agentic"?P8(JSON.parse(O)):null,[E,O]),R=(L==null?void 0:L.kind)==="fields"?L.form:null,A=E==="workflow"||(L==null?void 0:L.kind)==="json",[P,z]=p.useState({});p.useEffect(()=>{z(R?CE(R):{})},[h,O]);const U=E==="workflow"?x8(y==null?void 0:y.definition.workflow):(L==null?void 0:L.kind)==="json"?L.example:null,q=p.useRef("");p.useEffect(()=>{if(S.trim()&&S!==q.current)return;const de=(U==null?void 0:U.text)??"";q.current=de,N(de)},[h,U==null?void 0:U.text]);const[H,K]=p.useState(""),[W,G]=p.useState(""),[F,D]=p.useState(""),[Y,se]=p.useState("form"),[Q,re]=p.useState(u?"response":"code"),[te,he]=p.useState("curl"),[ge,be]=p.useState(()=>!(typeof window<"u"&&typeof window.matchMedia=="function")||window.matchMedia("(min-width: 1024px) and (min-height: 501px)").matches),xe=p.useId(),[fe,De]=p.useState(u),Fe=new Set((R==null?void 0:R.fields.map(([de])=>de))??[]),Pe=de=>{const Ue=Cx(de);return Ue!==null&&Fe.has(Ue)?Ue:null},Ee=p.useMemo(()=>{var at,J;const de=fe&&fe.status>=400?(at=fe.body)==null?void 0:at.error:void 0;if(!de||typeof de.message!="string")return;const Ue=Array.isArray(de.fields)?de.fields.filter(ve=>!!ve&&typeof ve.field=="string"&&typeof ve.message=="string"):[],Xe=Ue.filter(ve=>ve.message!==de.message&&Pe(ve.field)===null);return{message:de.message,more:Xe,issues:Ue,box:typeof((J=de.details)==null?void 0:J.box)=="string"?de.details.box:void 0,details:de.code==="agent_not_runnable"?de.details:void 0}},[fe,O]),[ae,$e]=p.useState(new Set);p.useEffect(()=>{$e(new Set)},[fe]);const ot=(de,Ue,Xe)=>{z(at=>({...at,[de]:Xe})),$e(at=>{const J=new Set(at);return SE(Ue,Xe)?J.add(de):J.delete(de),J})},me=de=>ae.has(de)?[]:((Ee==null?void 0:Ee.issues)??[]).filter(Ue=>Pe(Ue.field)===de),[Le,Ze]=p.useState(!1),yt=p.useMemo(()=>Ys(),[]),oe=CU({upload:b,remove:x,limits:g,frozen:Le}),Se=h8(E,{text:S,revision:$,effort:H,maxCostUsd:W,fileIds:oe.fileIds,repo:F,...R?{typed:{fields:oh(R,P),contentRequired:R.contentRequired}}:{},...(L==null?void 0:L.kind)==="json"?{json:!0}:{}}),tt=Se.ok?Se.body:{input:A?S:R?z8(R,S,P):{content:S},...oe.fileIds.length?{file_ids:oe.fileIds}:{}},Ae=h?yt.keyFor(h,tt):"",it=te==="curl"?v8(r,h,tt,Ae):`const res = await fetch(${JSON.stringify(`${r}/v2/agents/${h||"{agent_id}"}/runs`)}, {
|
|
666
|
+
method: "POST",
|
|
667
|
+
headers: {
|
|
668
|
+
Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
|
|
669
|
+
"Content-Type": "application/json",
|
|
670
|
+
"Idempotency-Key": ${JSON.stringify(Ae)},
|
|
671
|
+
},
|
|
672
|
+
body: JSON.stringify(${JSON.stringify(tt,null,2).replace(/\n/g,`
|
|
673
|
+
`)}),
|
|
674
|
+
});
|
|
675
|
+
console.log(res.status, await res.json());`,$t=!!j&&(!j.connected||j.state!=="ready"||!j.capabilities.launch||!!W.trim()||!!H||!!F.trim()||oe.fileIds.length>0||oe.busy),nt=async()=>{if(k||$t||!Se.ok||!c||oe.busy)return;Ze(!0);const de=await b8(yt,h,Se.body,c);Ze(!1),De(de),re("response"),be(!0),de.status>=200&&de.status<300&&oe.clear()},ft=A?E==="workflow"?'{ "subject": "...", "body": "..." }':"The agent's input, as JSON":`The run's ${R?"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(Et,{id:"playground-agent",label:"Agent",value:h,onChange:de=>{v(de),_(""),i==null||i(de)},options:Cl(e).map(de=>({value:de.agent_id,label:de.definition.name})),className:"w-56 max-w-[60vw]"})]}),k?t.jsxs("span",{className:"font-mono text-small",children:[Yo(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(sn,{variant:"primary",label:"Run agent",prompt:Lv(r,h,k.runtime)})]}):t.jsxs("div",{className:ie("relative grid min-h-0 flex-1 grid-cols-1",ge?"lg:[@media(min-height:501px)]:grid-cols-2":"grid-rows-[minmax(0,1fr)_auto]"),children:[t.jsxs("section",{"aria-label":"Request",className:ie("flex min-h-0 flex-col border-b",ge?"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:ie("flex items-center justify-between border-b px-5 py-3 md:px-6",!ge&&"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(de=>t.jsx("button",{type:"button","aria-pressed":Y===de,onClick:()=>se(de),className:ie("min-h-6 border-b pb-1 capitalize",Y===de?"border-primary":"border-transparent text-muted-foreground"),children:de==="json"?"JSON":"Form"},de))})]}),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:F.trim()?"This request selects a repository. Native execution uses its source project.":W.trim()?"This request has a spend cap. Native execution cannot enforce it.":H||oe.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."}),!!F.trim()&&t.jsx(B,{size:"sm",onClick:()=>D(""),children:"Use native source repository"}),!!H&&t.jsx(B,{size:"sm",onClick:()=>K(""),children:"Use native configured effort"}),oe.fileIds.length>0&&t.jsx(B,{size:"sm",onClick:()=>oe.clear(),children:"Remove uploaded attachments"}),!!W.trim()&&t.jsx(B,{size:"sm",onClick:()=>G(""),children:"Remove cap for native execution"}),t.jsx("a",{href:dn(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."]})]}),Y==="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(tt,null,2)}),!j&&t.jsx(Na,{name:"file_ids",note:df.file_ids,children:t.jsx(M0,{attachments:oe,limits:g})})]}):t.jsxs(t.Fragment,{children:[t.jsxs(Na,{htmlFor:"playground-input",name:A?"input":"input.content",required:!R||R.contentRequired,optional:!!R&&!R.contentRequired,error:!Se.ok&&Se.field==="input"&&S?Se.message:void 0,children:[t.jsx(nn,{id:"playground-input",value:S,onChange:de=>N(de.target.value),rows:A?7:4,placeholder:ft,className:P0}),U&&t.jsxs("p",{className:"mt-1 font-mono text-label text-muted-foreground",children:[g8(U,"start",E==="workflow"?"workflow":"agent"),U.fields.length>0&&t.jsxs(t.Fragment,{children:[" Fields: ",U.fields.map((de,Ue)=>t.jsxs("span",{title:de.note,children:[Ue?", ":"",t.jsx("span",{className:"text-foreground",children:de.name})]},de.name)),"."]})]})]}),R==null?void 0:R.fields.map(([de,Ue])=>t.jsxs("div",{"data-field":`input.${de}`,children:[t.jsx(_E,{field:Ue,label:rh(de,Ue),help:sm(Ue),value:P[de]??"",onChange:Xe=>ot(de,Ue,Xe)}),t.jsx(Po,{issues:me(de),words:Xe=>$E(Xe,de,Ue)})]},de)),!j&&t.jsx(Na,{name:"file_ids",note:df.file_ids,children:t.jsx(M0,{attachments:oe,limits:g})}),t.jsx(Na,{name:"revision",note:"Empty runs the current revision.",children:t.jsx(Et,{label:"Revision",value:$,onChange:_,className:"w-full",options:[{value:"",label:"The current revision"},...n.map(de=>({value:de.revision,label:`rev ${de.version}${de.current?" (current)":""}${de.note?`: ${de.note}`:""}`}))]})}),!j&&t.jsx(Na,{name:"effort",note:"How hard the model thinks. Empty uses the agent's own.",children:t.jsx(Et,{label:"Effort",value:H,onChange:K,className:"w-full",options:["",...s].map(de=>({value:de,label:de||"Agent default"}))})}),E==="agentic"&&!j&&t.jsx(Na,{htmlFor:"playground-repo",name:"repo",note:df.repo,error:!Se.ok&&Se.field==="repo"?Se.message:void 0,children:t.jsx(Me,{id:"playground-repo",value:F,onChange:de=>D(de.target.value),placeholder:"owner/name"})}),E==="agentic"&&!j&&t.jsxs(Na,{htmlFor:"playground-cap",name:"max_cost_usd",note:"A spend cap in dollars; empty means none.",error:!Se.ok&&Se.field==="max_cost_usd"?Se.message:void 0,children:[t.jsx(Me,{id:"playground-cap",value:W,onChange:de=>G(de.target.value),inputMode:"decimal",placeholder:"e.g. 0.50",className:P0}),t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:t.jsx(HC,{})})]})]})]}),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(sn,{label:"Use your agent",prompt:BP(r,h,tt),disabled:$t||!Se.ok||!h||oe.busy}),t.jsxs(B,{variant:"primary",size:"lg",onClick:nt,disabled:$t||!Se.ok||!c||Le||!h||oe.busy,title:oe.busy?"Waiting for the files to be sent":void 0,children:[t.jsx(Qo,{"aria-hidden":!0})," ",Le?"Sending":"Send request"]})]})]})]}),t.jsxs("section",{"aria-label":"Code and response",className:ie("flex min-h-0 flex-col",!ge&&"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:ie("flex flex-wrap items-center justify-between gap-x-3 gap-y-2 px-5 md:px-6",ge?"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:ie("flex gap-4 text-body",!ge&&"hidden"),children:[t.jsx("button",{type:"button","aria-pressed":Q==="code",onClick:()=>re("code"),className:ie("border-b pb-1",Q==="code"?"border-primary":"border-transparent text-muted-foreground"),children:"Code"}),t.jsxs("button",{type:"button","aria-pressed":Q==="response",onClick:()=>re("response"),disabled:!fe,className:ie("border-b pb-1 disabled:opacity-45",Q==="response"?"border-primary":"border-transparent text-muted-foreground"),children:["Response",fe&&t.jsx("span",{className:ie("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":ge,"aria-controls":xe,onClick:()=>be(de=>!de),children:[ge?t.jsx(TT,{"aria-hidden":!0}):t.jsx(mm,{"aria-hidden":!0})," ",ge?"Hide code and response":"Show code and response"]})})]}),t.jsx("div",{id:xe,className:ie("flex min-h-0 flex-1 flex-col",!ge&&"hidden"),children:Q==="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(de=>t.jsx("button",{type:"button","aria-pressed":te===de,onClick:()=>he(de),className:ie("-mb-px border-b-2 py-2.5",te===de?"border-primary":"border-transparent text-muted-foreground"),children:de==="curl"?"cURL":"JavaScript"},de))}),t.jsx(B,{size:"icon",variant:"outline","aria-label":"Copy code",onClick:()=>{var de;return void((de=navigator.clipboard)==null?void 0:de.writeText(it))},children:t.jsx(Ya,{"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:it}),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"]})]}),Ee&&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: ",Ee.message,Ee.box?t.jsxs("span",{className:"text-muted-foreground",children:[" (box: ",Ee.box,")"]}):null,t.jsx(kU,{agentId:h,details:Ee.details}),Ee.more.length>0&&t.jsx("span",{className:"mt-1 block",children:Ee.more.map(de=>t.jsxs("span",{className:"block",children:[de.field,": ",de.message]},`${de.field}:${de.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(Fx,{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(df).map(([de,Ue])=>t.jsxs("div",{children:[t.jsx("dt",{className:"font-mono text-body",children:de}),t.jsx("dd",{className:"text-small text-muted-foreground",children:Ue})]},de))}),t.jsxs("code",{className:"text-small",children:["/v2/agents/","{agent_id}","/runs"]})]})}const P0="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 Na({name:e,htmlFor:n,required:s,optional:r,note:o,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,o&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:o}),i&&t.jsx("p",{className:"mt-1.5 font-mono text-small text-destructive-text",role:"alert",children:i})]})}const L0="h-11 w-full border bg-card px-3 text-lead outline-none focus:border-primary",$U=e=>`'${e.replaceAll("'","'\\''")}'`;function _U({v2:e,origin:n,agentId:s,filter:r={}}){const[o,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),[_,M]=p.useState(!1),O=p.useRef(0);p.useEffect(()=>(O.current++,i(r.status??""),d(!!r.archived),b(""),S(null),k(null),$(!1),()=>{O.current++}),[s,r.status,r.archived]);const L={...o?{status:o}:{},...c?{archived:!0}:{}},R=s?`/v2/agents/${encodeURIComponent(s)}/runs`:"/v2/runs",A=new URLSearchParams({limit:String(u)});g&&A.set("cursor",g),o&&A.set("status",o),c&&A.set("archived","true");const P=`${n}${R}?${A}`,z=v==="curl"?`curl -X GET ${$U(P)} \\
|
|
676
|
+
-H "Authorization: Bearer $AGENTRUN_API_KEY"`:`const response = await fetch(${JSON.stringify(P)}, {
|
|
677
|
+
method: "GET",
|
|
678
|
+
headers: { Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\` },
|
|
679
|
+
});
|
|
680
|
+
console.log(response.status, await response.json());`,U=`${zm(n,s)}
|
|
681
|
+
|
|
682
|
+
Prepared read-only request: GET ${P}
|
|
683
|
+
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.`,q=()=>{O.current++,b(""),S(null),k(null),M(!1)},H=async(K=g)=>{if(N)return;const W=++O.current;$(!0),S(null),k(null),b(K),M(!1);const G=performance.now();try{const F=s?await e.listAgentRuns(s,u,K||void 0,L):await e.listRuns(u,K||void 0,L);if(O.current!==W)return;S(F),k({status:200,ms:performance.now()-G,body:F})}catch(F){if(O.current!==W)return;k(Ey(F,performance.now()-G))}finally{O.current===W&&($(!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(Me,{className:L0,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(Et,{label:"Run status",value:o,disabled:N,onChange:K=>{i(K),q()},options:[{value:"",label:"All statuses"},...om.map(K=>({value:K,label:K.replaceAll("_"," ")}))]})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Archive"}),t.jsx(Et,{label:"Archived runs",value:String(c),disabled:N,onChange:K=>{d(K==="true"),q()},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(Et,{label:"Page size",value:String(u),disabled:N,onChange:K=>{f(Number(K)),q()},options:[10,25,50,100].map(K=>({value:String(K),label:String(K)}))})]}),t.jsxs("label",{className:"block space-y-2",children:[t.jsx("span",{className:"text-lead",children:"Cursor"}),t.jsx(Me,{"aria-label":"Cursor",className:`${L0} font-mono text-small`,value:g,disabled:N,placeholder:"First page",onChange:K=>{O.current++,b(K.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(sn,{label:"Use your agent",prompt:U}),t.jsxs(B,{variant:"primary",disabled:N,onClick:()=>void H(),children:[t.jsx(Qo,{"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(K=>t.jsx("button",{onClick:()=>h(K),className:ie("h-12 border-b text-small capitalize",x===K?"border-primary":"border-transparent text-muted-foreground"),children:K},K)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{var K;(K=navigator.clipboard)==null||K.writeText(z).then(()=>M(!0),()=>M(!1))},children:t.jsx(Ya,{"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(K=>t.jsx("button",{onClick:()=>y(K),className:ie("border-b text-small",v===K?"border-primary":"border-transparent text-muted-foreground"),children:K==="curl"?"cURL":"JavaScript"},K))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:z})]}):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(K=>t.jsx("li",{children:t.jsxs("a",{className:"flex items-center gap-3 p-3 text-lead hover:bg-accent",href:`#/runs/${encodeURIComponent(K.run_id)}`,children:[t.jsx($l,{run:K}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:K.title||K.run_id}),t.jsx(fr,{className:"size-3.5 shrink-0","aria-hidden":!0})]})},K.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 wc=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Ii="w-full border bg-card px-3 py-3 text-lead outline-none focus:border-primary";function TU({v2:e,origin:n,operation:s,agentId:r,draft:o,harnesses:i=[]}){const c=s==="edit-agent",d=pU(o??null),[u,f]=p.useState(null),[g,b]=p.useState(null),[x,h]=p.useState(void 0),[v,y]=p.useState(d??rm("")),[j,k]=p.useState(JSON.stringify(d??rm(""),null,2)),[E,S]=p.useState(j),N=BC(j!==E),[$,_]=p.useState("form"),[M,O]=p.useState("code"),[L,R]=p.useState("curl"),[A,P]=p.useState(null),[z,U]=p.useState(null),[q,H]=p.useState(null),[K,W]=p.useState(!1),[G,F]=p.useState(!1),[D,Y]=p.useState(0),[se,Q]=p.useState(!1);p.useEffect(()=>{if(!c)return;if(!r){P("Choose an agent from Connected agents to edit its definition.");return}let oe=!0;return f(null),h(void 0),P(null),e.getAgent(r).then(({agent:Se,etag:tt})=>{if(!oe)return;f(Se),b(tt);const Ae={definition:{...Se.definition,version:Se.revisions+1}},it=JSON.stringify(Ae,null,2);y(Ae),k(it),S(it),U(null),F(!1)}).catch(Se=>{oe&&P(String(Se instanceof Error?Se.message:Se))}),()=>{oe=!1}},[e,c,r,D]);const re=(oe,Se)=>{const tt={...v.definition,[oe]:oe==="model"?Se.trim():Se};oe==="model"&&!Se.trim()&&!c&&delete tt.model;const Ae={...v,definition:tt};y(Ae),k(JSON.stringify(Ae,null,2))};let te=v,he=null;if($==="json")try{const oe=JSON.parse(j);!wc(oe)||!wc(oe.definition)?he="Include a definition object in the request.":te=oe}catch{he="Enter valid JSON before sending the request."}!he&&te.note!==void 0&&typeof te.note!="string"&&(he="note must be a string.");for(const oe of["description","instructions","harness","model"])!he&&te.definition[oe]!==void 0&&typeof te.definition[oe]!="string"&&(he=`definition.${oe} must be a string.`);!he&&typeof te.definition.name!="string"&&(he="Give this agent a name.");const ge=!he;!he&&!te.definition.name.trim()&&(he="Give this agent a name."),!he&&!te.definition.workflow&&(typeof te.definition.instructions!="string"||!te.definition.instructions.trim())&&(he="Add instructions for this agent.");const be=te;if(!he&&c&&u){const oe=wc(te.definition.workflow),Se=Object.keys(u.definition).filter(Ae=>!Object.hasOwn(te.definition,Ae));for(const Ae of["id","name","description"])!he&&te.definition[Ae]!==u.definition[Ae]&&(he=`definition.${Ae} is fixed when the agent is created. Restore its current value.`);for(const Ae of["native","sdk"])!he&&u.definition[Ae]!==void 0&&Se.includes(Ae)&&(he=`Cannot remove definition.${Ae} here. Edit the original source configuration with your agent.`);if(!he&&!oe)for(const Ae of["input_schema","output_schema"])Se.includes(Ae)&&(he=`Cannot remove definition.${Ae}: the API keeps an omitted schema. Restore it or supply a replacement schema.`);!he&&Se.includes("harness")&&(he='Cannot remove definition.harness: the API keeps it. Select an explicit harness, such as "pi" for the default.'),!he&&(u.definition.computer!==void 0||u.definition.place!==void 0)&&!Object.hasOwn(te.definition,"computer")&&!Object.hasOwn(te.definition,"place")&&(he='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 tt=wc(te.skills)&&Object.keys(te.skills).length===0;if(!he&&!Object.hasOwn(te.definition,"skills")&&!tt&&(u.definition.skills.length>0||wc(te.skills)&&Object.keys(te.skills).length>0)&&(he="Cannot remove definition.skills while skill files are retained or supplied. Give their skill names, or use definition.skills: [] with skills: {} to clear them."),!he){const Ae=Object.fromEntries(Se.map(ft=>[ft,ft==="learning"?oe?void 0:!1:ft==="max_cost_usd"?0:ft==="checkout"?oe?void 0:"none":ft==="tools"||ft==="skills"?[]:void 0])),{unchanged:it,...$t}=vd(u,{...Ae,...te.definition},te.note??""),nt=te.skills!==void 0&&!Xi(te.skills,x);it&&!nt&&(he="Change the definition before saving a revision."),nt&&($t.definition.version=u.revisions+1),te={...te,...$t}}}c&&u&&!g&&(he="This server did not provide a revision ETag. Reload the current revision before editing.");const xe=c?"PUT":"POST",fe=c?`/v2/agents/${encodeURIComponent(r??"")}/definition`:"/v2/agents",De=`${n}${fe}`,Fe=JSON.stringify(te,null,2),Pe=oe=>`'${oe.replaceAll("'","'\\''")}'`,Ee={"Content-Type":"application/json",...c&&g?{"If-Match":g}:{}},ae=L==="curl"?`curl -X ${xe} ${Pe(De)} \\
|
|
684
|
+
-H "Authorization: Bearer $AGENTRUN_API_KEY" \\
|
|
685
|
+
${Object.entries(Ee).map(([oe,Se])=>` -H ${Pe(`${oe}: ${Se}`)} \\
|
|
686
|
+
`).join("")} -d ${Pe(Fe)}`:`const response = await fetch(${JSON.stringify(De)}, {
|
|
687
|
+
method: ${JSON.stringify(xe)},
|
|
688
|
+
headers: {
|
|
689
|
+
Authorization: \`Bearer \${process.env.AGENTRUN_API_KEY}\`,
|
|
690
|
+
${Object.entries(Ee).map(([oe,Se])=>` ${JSON.stringify(oe)}: ${JSON.stringify(Se)},`).join(`
|
|
691
|
+
`)}
|
|
692
|
+
},
|
|
693
|
+
body: JSON.stringify(${Fe}),
|
|
694
|
+
});
|
|
695
|
+
console.log(response.status, await response.json());`,$e=es(u==null?void 0:u.definition),ot=c&&(!!(u!=null&&u.definition.native)||!!$e),me=ot&&u?Bo(n,u.agent_id,!!u.definition.native,$e==null?void 0:$e.runtime):`${c?Bo(n,r??""):Im(n)}
|
|
696
|
+
|
|
697
|
+
Prepared request: ${xe} ${De}${c&&g?`
|
|
698
|
+
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.
|
|
699
|
+
|
|
700
|
+
${Fe}`,Le=!he&&!A&&(!c||!!u)&&!K&&!G,Ze=async()=>{if(!Le)return;W(!0),H(null);const oe=performance.now();try{const Se=c?await e.updateDefinition(r,te,g):{agent:await e.createAgent(te),etag:null};H(Se.agent.agent_id),S(j),U({status:c?200:201,ms:performance.now()-oe,body:Se.agent}),c?(f(Se.agent),b(Se.etag),te.skills!==void 0&&h(te.skills)):F(!0)}catch(Se){const tt=Ey(Se,performance.now()-oe);U(tt),!c&&(tt.status===0||tt.status>=500)&&F(!0)}finally{W(!1),O("response")}},yt=t.jsxs(pv,{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 A?t.jsxs(t.Fragment,{children:[yt,t.jsxs("div",{className:"m-6 border p-5",role:"alert",children:[t.jsx("p",{children:A}),r&&t.jsx(B,{className:"mt-3",onClick:()=>Y(oe=>oe+1),children:"Reload agent"})]})]}):c&&!u?t.jsxs(t.Fragment,{children:[yt,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(oe=>t.jsx("button",{onClick:()=>{if(oe==="form"&&$==="json"){if(!ge)return;y(be)}_(oe)},className:ie("h-12 border-b text-small",$===oe?"border-primary":"border-transparent text-muted-foreground"),children:oe==="json"?"JSON":"Form"},oe))})]}),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."})]}),o&&!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(nn,{value:j,onChange:oe=>k(oe.target.value),className:`${Ii} min-h-[360px] font-mono text-small`,spellCheck:!1})]}):t.jsxs(t.Fragment,{children:[t.jsx(zi,{name:"Name",children:t.jsx(Me,{value:v.definition.name,readOnly:c,onChange:oe=>re("name",oe.target.value),className:Ii})}),t.jsx(zi,{name:"Description",children:t.jsx(Me,{value:v.definition.description??"",readOnly:c,onChange:oe=>re("description",oe.target.value),className:Ii})}),v.definition.workflow?t.jsx(zi,{name:"Workflow",children:t.jsx("pre",{className:`${Ii} overflow-auto font-mono text-small`,children:JSON.stringify(v.definition.workflow,null,2)})}):t.jsxs(t.Fragment,{children:[t.jsx(zi,{name:"Instructions",children:t.jsx(nn,{value:v.definition.instructions??"",rows:5,onChange:oe=>re("instructions",oe.target.value),className:Ii})}),t.jsx(zi,{name:"Harness",children:t.jsx(Et,{label:"Harness",value:v.definition.harness??"pi",onChange:oe=>re("harness",oe),options:[...new Set([v.definition.harness??"pi",...i.map(oe=>oe.id)])].map(oe=>{var Se;return{value:oe,label:`${oe}${((Se=i.find(tt=>tt.id===oe))==null?void 0:Se.available)===!1?" (not set up)":""}`}})})}),t.jsx(zi,{name:"Model",children:t.jsx(Me,{value:v.definition.model??"",onChange:oe=>re("model",oe.target.value),placeholder:"Server default",className:Ii})})]}),t.jsx("button",{className:"text-lead text-primary-text",onClick:()=>_("json"),children:"Edit all fields in JSON →"})]}),he&&t.jsx("p",{className:"text-small text-muted-foreground",role:"status",children:he}),c&&u&&!g&&t.jsx(B,{size:"sm",onClick:()=>Y(oe=>oe+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(sn,{label:"Use your agent",prompt:me,disabled:!ot&&!!he}),t.jsxs(B,{variant:"primary",onClick:()=>void Ze(),disabled:!Le,children:[t.jsx(Qo,{"aria-hidden":!0}),K?"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(oe=>t.jsx("button",{onClick:()=>O(oe),className:ie("h-12 border-b text-small capitalize",M===oe?"border-primary":"border-transparent text-muted-foreground"),children:oe},oe)),t.jsx(B,{size:"icon",className:"ml-auto","aria-label":"Copy code",onClick:()=>{navigator.clipboard.writeText(ae).then(()=>Q(!0),()=>Q(!1))},children:t.jsx(Ya,{"aria-hidden":!0})}),t.jsx("span",{role:"status",className:"sr-only",children:se?"Code copied":""})]}),M==="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(oe=>t.jsx("button",{onClick:()=>R(oe),className:ie("border-b text-small",L===oe?"border-primary":"border-transparent text-muted-foreground"),children:oe==="curl"?"cURL":"JavaScript"},oe))}),t.jsx("pre",{className:"min-h-0 flex-1 overflow-auto p-6 font-mono text-small leading-6",children:ae})]}):t.jsx("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-6",children:z?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"font-mono text-small",children:[z.status||"Network error"," · ",Math.round(z.ms)," ms"]}),t.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words font-mono text-small leading-6",children:JSON.stringify(z.body,null,2)}),q&&t.jsxs("a",{className:"inline-flex items-center gap-2 text-lead text-primary-text",href:dn(q),children:["Open agent",t.jsx(fr,{className:"size-4"})]}),z.status===412&&t.jsx(B,{onClick:()=>Y(oe=>oe+1),children:"Reload current revision"}),G&&!q&&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."})})]}),yt]})}function zi({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 RU=[{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"}],Ko="p-5 md:p-8",si="mb-6 max-w-prose",ri="[&>:not(section)]:mb-6";function Rr({title:e,titleId:n,note:s,aside:r,label:o,children:i}){const c=p.useId(),d=n??c;return t.jsxs("section",{"aria-label":o,"aria-labelledby":o?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 AU({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:RS,children:RU.filter(r=>n.includes(r.id)).map(r=>t.jsx("a",{href:`#/settings/${r.id}`,"aria-current":e===r.id?"page":void 0,className:AS(e===r.id),children:r.label},r.id))}),t.jsx("div",{className:"min-h-0 flex-1",children:s})]})}async function ih(e,n){var d;let s;try{s=((d=navigator.clipboard)==null?void 0:d.readText().catch(()=>""))??Promise.resolve("")}catch{s=Promise.resolve("")}Ns.flushSync(e);const r=n();if(!r||r.disabled||r.readOnly)return;r.focus();const o=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!==o||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 oa({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 OU={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"},PU=e=>`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`;function LU({id:e,className:n}){const[s,r]=p.useState(!1),o=OU[e],i=MU[e];return o&&!s?t.jsx("img",{"data-provider-icon":e,src:PU(o),alt:"",width:16,height:16,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(!0),className:ie("size-4 shrink-0 object-contain",n)}):i?t.jsx("svg",{"data-provider-mark":e,viewBox:"0 0 24 24",fill:"currentColor",className:ie("size-4 shrink-0",n),"aria-hidden":!0,children:t.jsx("path",{d:i})}):t.jsx(Ia,{className:ie("size-4 shrink-0 text-muted-foreground",n),"aria-hidden":!0})}const IU=/^(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,zU=40;function DU(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&&IU.test(r))return[];const o=r.split(/,?\s+or\s+|,\s+/i).map(c=>c.trim()).filter(Boolean);if(o.length<2||o.length>4||!/\bor\b/i.test(r))return[];const i=o.map(c=>c.replace(/^(the|a|an)\s+/i,"").replace(/\s+instead$/i,""));return i.some(c=>!c||c.length>zU)?[]:i.map(c=>/\s/.test(c)?c[0].toUpperCase()+c.slice(1):c)}function FU(e){var r,o;const n=new Map;for(const i of e){if(i.imported_from)continue;const c=((o=(r=i.error)==null?void 0:r.message)==null?void 0:o.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 YE=e=>e.filter(n=>!n.imported_from).length,UU=864e5;function WU(e,n){return e.some(s=>!s.imported_from)||n.some(s=>s.source==="live"&&s.runs>0)}function Od(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 HU(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 BU(e,n){let s=!1,r;const o=()=>{s||e().catch(()=>{}).finally(()=>{s||(r=setTimeout(o,n))})};return o(),()=>{s=!0,clearTimeout(r)}}const QE=e=>e.pending!=null&&e.pending.kind!=="stopped",GU=e=>e.status==="input_required"&&e.state!=="waiting"&&!QE(e),qU=[["asking","The runs asking a question"],["failed","The failed runs"],["live","The running runs"]];function I0(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 qU.forEach(([o,i],c)=>{const d=n[c];(d==null?void 0:d.status)==="fulfilled"?s[o]=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 lh({field:e,label:n,writable:s,required:r=!0,stateSaid:o=!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:ie("relative flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-small",f&&"opacity-60"),children:[t.jsxs("span",{children:[Jf(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:o?"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:o6[e.source]}),e.changed_at&&t.jsxs("span",{className:"text-muted-foreground",children:["Changed ",Od(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 z0={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-…"}},KU=e=>Object.prototype.hasOwnProperty.call(z0,e)?z0[e]:void 0,VU={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."},D0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function F0(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 YU="can't be opened: paste it again",QU=[{kind:"model",label:"Model keys"},{kind:"tool",label:"Tool keys"}],$x="We recommend an OpenRouter key with a dollar cap and an expiration date. Do not share this key with anyone.";function JU({v2:e,onChange:n,writable:s,whyNot:r="sign_in",plan:o,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(M=>{_===v.current&&(d(M),f(null))}).catch(M=>{_===v.current&&f(D0(M))})};p.useEffect(y,[e]);const j=_=>b(M=>M===_?null:M),k=_=>{j(_),y(),n==null||n()},E=(_,M,O,L)=>{h({id:_,title:M,error:D0(O)}),O instanceof ze&&O.code==="key_set_by_server"&&(j(L),y())};if(!c)return u?t.jsx(U0,{error:u,onRetry:y}):t.jsx("div",{className:"p-5 md:p-8",children:t.jsx(Un,{label:"Loading the tool keys",rows:3})});const S=c.reenter,N=QU.map(_=>({..._,keys:c.keys.filter(M=>M.kind==="model"==(_.kind==="model"))})).filter(_=>_.keys.length),$=_=>t.jsx(XU,{tool:_,writable:s,again:!!S&&_.fields.some(M=>M.stored_unreadable||S.fields.includes(M.name)),open:(g==null?void 0:g.id)===_.id?g.mode:null,problem:(x==null?void 0:x.id)===_.id?x:null,onOpen:M=>{b(M?{id:_.id,mode:M}:null),h(null)},onSave:async M=>{const O=g;try{await e.saveToolKey(_.id,M)}catch(L){return L instanceof ze&&L.status===422?L:(E(_.id,"The key was not saved",L,O),null)}return k(O),null},onRemove:async()=>{const M=g;try{await e.removeToolKey(_.id)}catch(O){E(_.id,"The key was not removed",O,M);return}k(M)}},_.id);return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:si,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:ri,children:[!s&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:ni[r]}),u&&t.jsx(U0,{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:VU[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(Rr,{label:_.label,title:_.label,note:_.kind==="model"?t.jsx("p",{children:$x}):void 0,children:t.jsxs("ul",{className:"border",children:[_.kind==="model"&&o,_.keys.map($)]})},_.label)),i&&t.jsx(KC,{harnesses:i})]})]})})}function U0({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 XU({tool:e,writable:n,again:s,open:r,problem:o,onOpen:i,onSave:c,onRemove:d}){var h;const u=p.useRef(null),f=v=>e.secrets.find(y=>Jf(y.name)===v.name),g=v=>e.fields.find(y=>y.name===Jf(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(LU,{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(ke,{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(ke,{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(", ")}`]}),F0(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:F0(e.label,e.check)}),t.jsx("ul",{className:"mt-3 space-y-1.5",children:e.secrets.map(v=>{var y;return t.jsx(lh,{field:v,stateSaid:e.secrets.length===1,writable:n&&r===null,note:(y=g(v))!=null&&y.stored_unreadable?YU:void 0,onPaste:()=>void ih(()=>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(JE,{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"})]}),o&&t.jsx("div",{className:"mt-4 border",children:t.jsx(oa,{error:o.error,title:o.title})})]})}function JE({tool:e,fields:n,onSave:s,onCancel:r}){const o=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=o.current)==null?void 0:j.elements.namedItem(y.name))==null?void 0:k.value}),x=()=>{var y;(y=o.current)==null||y.reset(),c(!1)},h=async y=>{var N,$;y.preventDefault();const j={};for(const _ of n){const M=($=(N=o.current)==null?void 0:N.elements.namedItem(_.name))==null?void 0:$.value;M&&(j[_.name]=M)}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 M=_.field.startsWith("values.")?_.field.slice(7):null;M&&n.some(O=>O.name===M)?E[M]=_.message:S.push(_.message)}g({fields:E,message:S.length?S.join(" "):Object.keys(E).length?null:k.message})},v=KU(e.id);return t.jsxs("form",{ref:o,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(Me,{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 Md=p.createContext(null);function W0({connection:e,children:n}){return t.jsx(Md.Provider,{value:e,children:n})}const ZU={state:"online"},eW=()=>()=>{},H0=()=>ZU;function $y(){const e=p.useContext(Md);return p.useSyncExternalStore(e?e.subscribe:eW,e?e.link:H0,H0)}function XE(e){const n=p.useContext(Md),s=p.useRef(e);s.current=e,p.useEffect(()=>n==null?void 0:n.onResume(()=>s.current()),[n])}function ZE(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 tW(){const e=p.useContext(Md),n=$y(),s=ZE(n.state==="offline"?n.retryAt:null);return!e||n.state==="online"?null:n.state==="resumed"?t.jsxs(vt,{bar:!0,tone:"success",icon:Jo,"data-connection":"resumed",children:[t.jsx("span",{className:"font-semibold",children:"Resumed."})," agentrun-serve is back."]}):t.jsxs(vt,{bar:!0,tone:"warning",icon:FN,"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 nW(){const e=p.useContext(Md),n=$y(),s=ZE(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(FN,{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 sW=(e,n)=>e.flatMap(s=>s.tools.flatMap(r=>{var o;return(o=r.permissions)!=null&&o.length&&r.default_permission?[{name:q2(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"}:{}}]:[]})),B0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function rW({v2:e,choices:n,gates:s=[],harnesses:r,mcp:o=!1,onSaved:i,onOpen:c}){const[d,u]=p.useState(null),[f,g]=p.useState(null),b=()=>{o&&(g(null),e.listMcpServers().then(G=>g(G.servers),()=>g("failed")))};p.useEffect(b,[e,o]);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(F=>{G===N.current&&(u(F),h(null))},F=>{G===N.current&&h(B0(F))})};p.useEffect($,[e]);const[_,M]=p.useState("reading"),O=()=>{M("reading"),Promise.resolve(c==null?void 0:c()).then(G=>M(G===!1?"failed":"landed"))},L=()=>{$(),O()};if(p.useEffect(O,[]),!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 R=gx(d,n),A=E?E(R):R,P=WC(n,[...s,...Array.isArray(f)?sW(f,s.some(G=>G.ask_needs==="password")):[]]),z=G=>{var D;const F=Go(G);return F?(D=A[`mcp:${F.server}/*`])==null?void 0:D.permission:void 0},U=Object.entries(A).filter(([,G])=>(G==null?void 0:G.pin)||(G==null?void 0:G.pin_broken)),q=G=>{var D;const F=s.find(Y=>Y.name===G);return!F||(((D=A[G])==null?void 0:D.permission)??F.default_permission)===F.permission},{byTool:H,rest:K}=MC((v==null?void 0:v.fields)??{},"",P.map(G=>G.name)),W=async G=>{var se;const F=E?Q=>G(E(Q)):G;k(!0),y(null);const D=++N.current;let Y;try{Y=await e.toolSettings()}catch{S(()=>F),y({fields:{},error:null,unread:!0}),k(!1);return}try{const Q=await e.saveToolSettings(F(gx(Y,n)));S(null),D===N.current&&(u(Q),h(null)),i()}catch(Q){y(Q instanceof ze&&Q.status===422&&((se=Q.fields)!=null&&se.length)?{fields:Object.fromEntries(Q.fields.map(re=>[re.field,re.message])),error:null}:{fields:{},error:B0(Q)})}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(dy,{label:"This server's tool settings",rows:P,settings:A,fallbackOf:G=>G.default_provider,issues:H,busy:j,onEdit:G=>void W(G),permissionFallbackOf:G=>z(G.name)??G.default_permission,refused:(G,F)=>F==="deny",resolvesOf:(G,F)=>F===G.provider&&q(G.name)?t.jsx(HF,{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"})]}),K.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(oa,{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 W(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"})]})]}),U.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:U.map(([G,F])=>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(vx,{setting:F})]},G))})]})]})]})})}function oW(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 G0={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."},aW=e=>e.ok?"Connected. The App is installed.":e.reason&&Object.hasOwn(G0,e.reason)?G0[e.reason]:"The connection didn't finish. Try again.";function iW(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 lW({note:e}){const n=e.lastIndexOf(": "),s=n>=0?e.slice(n+2).trim():"",r=s?dr(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 cW({v2:e,returned:n}){const[s,r]=p.useState(void 0),[o,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 R=await e.githubConnection();r(R.connected?R:null),i(null)}catch(R){i(R instanceof Error?R.message:String(R))}},[e]);p.useEffect(()=>{_()},[_]),p.useEffect(()=>{n&&history.replaceState(null,"",`${location.pathname}${location.search}#/settings/github`)},[]),p.useEffect(()=>{var R;g&&((R=$.current)==null||R.submit())},[g]);const M=async()=>{var R;if(!N.current){N.current=!0,f(!0),h(null),y(null),S(null);try{const A=await e.connectGitHub(c.trim()||void 0),P=iW(A.action,dr);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(A.manifest)})}catch(A){if(N.current=!1,f(!1),h(A instanceof Error?A.message:String(A)),A instanceof ze&&A.code==="github_wrong_origin"){const P=(R=A.details)==null?void 0:R.public_url;y(typeof P=="string"&&dr(P)||null)}A instanceof ze&&A.code==="github_already_connected"&&_()}}},O=async()=>{k(!1),f(!0),h(null),y(null);try{S(await e.disconnectGitHub()),r(null)}catch(R){R instanceof ze&&(R.status===404||R.code==="github_not_connected")?await _():h(R instanceof Error?R.message:String(R))}finally{f(!1)}},L=s?dr(`https://github.com/apps/${encodeURIComponent(s.slug)}`):void 0;return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:si,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:ri,children:[n&&t.jsx("p",{"aria-label":"From GitHub",role:"status",className:ie("border p-4 text-lead",n.ok?"border-success/50 bg-success/5":"border-warning/50 bg-warning/5 text-warning-text"),children:aW(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(lW,{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."})]}),o&&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: ",o]})}),t.jsxs(Rr,{title:"Connection",children:[s===void 0&&!o&&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(Me,{name:"org",value:c,onChange:R=>d(R.target.value),disabled:u,placeholder:"your-org",className:"h-9 w-auto"})]}),t.jsxs(B,{type:"button",variant:"solid",onClick:()=>void M(),disabled:u,children:[t.jsx(ij,{"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(ij,{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(R=>t.jsx("li",{children:R.account},R.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 O(),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 dW=8,uW={sealed:["sealed","success"],expired:["sign-in expired","warning"],unreadable:["can't be opened: enter it again","warning"]};function fW({v2:e,signIn:n,add:s,writable:r,whyNot:o="sign_in",open:i=d=>location.assign(d),choices:c=[]}){var G,F,D,Y,se;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),[_,M]=p.useState(null),O=s?JSON.stringify(s):"",L=p.useRef(O);p.useEffect(()=>{if(O===L.current)return;L.current=O;const Q=O?JSON.parse(O):void 0;S(Q&&Q.preset!=="composio"?{add:Q}:null),$((Q==null?void 0:Q.preset)==="composio"&&r?Q:!1)},[O]);const R=p.useRef(0),A=p.useRef(null),P=()=>{const Q=++R.current;e.listMcpServers().then(re=>{Q===R.current&&(u(re.servers),j(null))},re=>{Q===R.current&&j(oo(re))})};p.useEffect(P,[e]),p.useEffect(()=>{e.toolSettings().then(g,()=>g(null))},[e]);const z=p.useRef(!1),U=async(Q,re)=>{if(!z.current){z.current=!0,x(!0),v(null);try{const te=await e.toolSettings();g(await e.saveToolSettings(re(gx(te,c)))),P()}catch(te){v({server:Q,problem:oo(te)})}z.current=!1,x(!1)}},q=p.useRef(null);s&&d&&((G=q.current)==null?void 0:G.key)!==O&&(q.current={key:O,name:e$(s.name,d)});const H=Q=>{var re;return((re=q.current)==null?void 0:re.key)===JSON.stringify(Q)&&q.current.name!==Q.name?{...Q,toolkit:Q.toolkit??Q.name,name:q.current.name}:Q},K=d!==null||y!==null;p.useEffect(()=>{n&&location.hash.includes("sign_in=")&&history.replaceState(null,"","#/settings/mcp")},[n]);const W=async(Q,re)=>i((await e.startMcpSignIn(Q,re)).authorization_url);return t.jsx("div",{ref:A,className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:si,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:ri,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: ${jI(n.error)}.`}),!r&&t.jsx("p",{className:"border bg-card p-4 text-body",role:"status",children:ni[o]}),_&&t.jsx("p",{className:`border p-4 text-body ${_.removed?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:_.note}),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(Rr,{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||K)&&t.jsx(SW,{v2:e,saved:E.saved,add:E.add&&H(E.add),given:E.problem,writable:r,taken:d,signIn:W,onCancel:()=>S(null),onSaved:(Q=>re=>{re&&M(re),S(te=>te===Q?null:te),P()})(E)},`${((F=E.saved)==null?void 0:F.name)??"new"}|${((D=E.add)==null?void 0:D.name)??""}|${((Y=E.add)==null?void 0:Y.auth)??""}|${((se=E.add)==null?void 0:se.preset)??""}`),N&&(typeof N!="object"||K)&&t.jsx(wW,{v2:e,add:typeof N=="object"?H(N):void 0,onClose:()=>$(!1),onSaved:P},typeof N=="object"?O:"new"),d&&(d.length?t.jsx("ul",{className:"border",children:d.map(Q=>t.jsx(hW,{v2:e,server:Q,settings:f,settingsBusy:b,settingsProblem:(h==null?void 0:h.server)===Q.name?h.problem:null,onSettings:re=>void U(Q.name,re),writable:r&&!E,signIn:W,onChange:re=>S({saved:Q,...re?{problem:re}:{}}),onPaste:()=>void ih(()=>S({saved:Q}),()=>{var re;return((re=A.current)==null?void 0:re.querySelector('input[name="mcp-token"], input[name="mcp-header-value-0"]'))??null}),onChanged:P,onDeleted:re=>{M(re??null),P()}},Q.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(yW,{v2:e})]})]})})}const gl=({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})]}),$c=(e,n)=>`mcp:${e}/${n}`,mW=["allow","ask","deny"];function hW({v2:e,server:n,settings:s,settingsBusy:r,settingsProblem:o,onSettings:i,writable:c,signIn:d,onChange:u,onPaste:f,onChanged:g,onDeleted:b}){var L,R;const[x,h]=p.useState(!1),[v,y]=p.useState(!1),[j,k]=p.useState(null),[E,S]=p.useState(null),N=async A=>{h(!0),S(null);try{await A()}catch(P){S(oo(P))}h(!1)},[$,_]=n.credential?uW[n.credential]??[n.credential,"plain"]:["no credential","plain"],M=n.auth.type==="oauth",O=j&&[["Added",j.added],["Removed",j.removed],["Changed",j.changed]].filter(([,A])=>A.length).map(([A,P])=>`${A} ${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(KT,{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(ke,{tone:_,children:$}),!!((L=n.not_metered)!=null&&L.length)&&t.jsx(ke,{tone:"plain",children:"not metered"}),n.source&&t.jsxs(t.Fragment,{children:[t.jsx(ke,{tone:"muted",children:wd[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",(R=n.auth.headers)!=null&&R.length?` · headers ${n.auth.headers.join(", ")}`:""]}),M&&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(xW,{server:n,settings:s,busy:r,onSettings:i}),o&&t.jsx("div",{className:"mt-2",children:t.jsx(gl,{problem:o})}),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(vW,{server:n,settings:s,busy:r,onSettings:i})})]}),n.secret&&t.jsx("ul",{className:"mt-2",children:t.jsx(lh,{field:n.secret,label:NW[n.auth.type],writable:c,onPaste:M?void 0:f})}),n.source==="composio"&&t.jsx(gW,{v2:e,server:n.name,writable:c}),O&&t.jsx("p",{className:"mt-2 font-mono text-small",role:"status",children:O.length?O.join(" · "):"No change: it lists the same tools."})]}),!v&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[M&&n.credential!=="sealed"&&c&&t.jsx(B,{size:"sm",variant:"primary",disabled:x,onClick:()=>void N(()=>{var A;return d(n.name,{url:n.url,...(A=n.oauth)!=null&&A.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 A;b((A=await e.deleteMcpServer(n.name))==null?void 0:A.composio)}),children:"Delete"}),t.jsx(B,{size:"sm",onClick:()=>y(!1),children:"Keep"})]}),E&&t.jsxs("div",{className:"mt-3",children:[t.jsx(gl,{problem:E}),E.needsClient&&c&&t.jsx(B,{className:"mt-2",size:"sm",variant:"primary",onClick:()=>u(E),children:"Enter a Client ID"})]})]})}const pW={on:"on at Composio",off:"off at Composio",missing:"Composio no longer has it",unknown:"Composio didn't say"};function gW({v2:e,server:n,writable:s}){const[r,o]=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&&o(E)},E=>{k&&(E instanceof ze&&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:["· ",pW[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(gl,{problem:i})})]})}function xW({server:e,settings:n,busy:s,onSettings:r}){var g;const o=$c(e.name,"*"),i=((g=n[o])==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{[o]:h,...v}=x,{allow_reads:y,...j}=h??{},k=b?{...j,allow_reads:!0}:j;return Object.keys(k).length?{...v,[o]:k}:v});return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ud,{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 vW({server:e,settings:n,busy:s,onSettings:r}){const o=n==null?void 0:n[$c(e.name,"*")],i=new Map(e.tools.map(u=>[$c(e.name,u.name),u])),c=e.tools.map(u=>{var f;return{name:$c(e.name,u.name),...n?{gate:{name:$c(e.name,u.name),permission:u.permission??"ask",default_permission:u.default_permission??"ask",permissions:(f=u.permissions)!=null&&f.length?u.permissions:mW}}:{}}}),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(dy,{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":(o==null?void 0:o.permission)??u.default_permission}})}function yW({v2:e}){const[n,s]=p.useState(null),[r,o]=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),o(null)},v=>o(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(Rr,{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(Me,{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(gl,{problem:i})]})}const bW=32;function e$(e,n){const s=new Set(n.map(r=>r.name));if(!s.has(e))return e;for(let r=2;;r++){const o=`-${r}`,i=`${e.slice(0,bW-o.length).replace(/-+$/,"")}${o}`;if(!s.has(i))return i}}function wW({v2:e,add:n,onClose:s,onSaved:r}){var R;const o=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 A,P;return(((P=(A=o.current)==null?void 0:A.elements.namedItem("composio-key"))==null?void 0:P.value)??"").trim()},N=async A=>{E(!0),j(null);try{await A()}catch(P){j(oo(P))}E(!1)},$=p.useRef(0),_=()=>{$.current++,g(null)},M=()=>N(async()=>{const A=++$.current;g(null),x([]);const P=await e.composioTools(S(),i.trim().toLowerCase());A===$.current&&(g(P),n!=null&&n.tools&&P.toolkit===n.toolkit&&x(P.tools.map(z=>z.slug).filter(z=>n.tools.includes(z))))}),O=()=>N(async()=>{var P,z;const A=await e.saveComposioServer(d.trim(),S(),f.toolkit,b);(P=o.current)==null||P.reset(),r(),A.connect_url||(z=A.not_served)!=null&&z.length||A.composio?v({connect:A.connect_url,notServed:A.not_served,composio:A.composio}):s()}),L=A=>x(P=>P.includes(A)?P.filter(z=>z!==A):[...P,A]);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"]})}),(R=h.notServed)!=null&&R.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,h.composio&&t.jsx("p",{className:`border p-4 text-body ${h.composio.removed?"border-success/50 text-success-text":"border-warning/50 text-warning-text"}`,role:"status",children:h.composio.note}),t.jsx(B,{size:"sm",onClick:s,children:"Done"})]}):t.jsxs("form",{ref:o,autoComplete:"off",onSubmit:A=>{A.preventDefault(),f&&b.length&&d.trim()&&O()},"aria-label":"Add from Composio",className:"space-y-4 border bg-card p-4",onInput:A=>{A.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(Me,{name:"composio-key",...kf})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Toolkit"}),t.jsx(Me,{name:"composio-toolkit",value:i,onChange:A=>{c(A.target.value),_()},placeholder:"github",spellCheck:!1})]}),y&&t.jsx(gl,{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(A=>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:A.slug,checked:b.includes(A.slug),onChange:()=>L(A.slug),className:"mt-1 accent-primary"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono",children:A.name}),t.jsx("span",{className:"ml-2 font-mono text-small text-muted-foreground",children:A.slug}),A.description&&t.jsx("span",{className:"block text-small text-muted-foreground",children:A.description})]})]})},A.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(Me,{name:"composio-name",value:d,onChange:A=>u(A.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 M(),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 A;(A=o.current)==null||A.reset(),s()},children:"Cancel"})]})]})}const jW=/^mcp-(token|scopes|client-id|client-secret|header-(name|value)-\d+)$/,kf={type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"},kW=[["none","None"],["bearer","Bearer token"],["headers","Headers"],["oauth","Sign in with OAuth"],["github_app","GitHub App"]],NW={none:"Credential",bearer:"Bearer token",headers:"Headers",oauth:"OAuth sign-in",github_app:"Headers"};function SW({v2:e,saved:n,add:s,given:r,writable:o,taken:i,signIn:c,onCancel:d,onSaved:u}){var Pe,Ee,ae,$e,ot;const f=p.useRef(null),g=n?void 0:G2(s==null?void 0:s.preset),[b,x]=p.useState(g),[h,v]=p.useState((n==null?void 0:n.name)??(s==null?void 0:s.name)??""),[y,j]=p.useState((n==null?void 0:n.url)??((s==null?void 0:s.auth)==="github_app"?Wf:(g==null?void 0:g.url)??"")),[k,E]=p.useState((n==null?void 0:n.auth.type)??(s==null?void 0:s.auth)??(g==null?void 0:g.auth)??"none"),[S,N]=p.useState(Math.max(1,((Pe=n==null?void 0:n.auth.headers)==null?void 0:Pe.length)??0)),$=k==="github_app"?"github":(n==null?void 0:n.source)==="composio"?"composio":"url",[_,M]=p.useState((n==null?void 0:n.toolkit)??(g?g.name:s&&!s.auth?s.toolkit??s.name:"")),O=$==="github"?"github":_.trim(),L=()=>{if(k==="github_app")return{};const me=O||null;return n?me!==n.toolkit?{toolkit:me}:{}:me?{toolkit:me}:{}},R=!n&&!!(i!=null&&i.some(me=>me.name===h.trim())),A=!!n||!!i&&!R,[P,z]=p.useState(null),[U,q]=p.useState(r??null),[H,K]=p.useState(!1),W=p.useRef(0),G=()=>{W.current++,z(null)},F=me=>{var Le,Ze;return(((Ze=(Le=f.current)==null?void 0:Le.elements.namedItem(me))==null?void 0:Ze.value)??"").trim()},[D,Y]=p.useState(!1),se=me=>{try{return new URL(me).origin}catch{return me}},Q=(me=k)=>{var Le;return Y(!!n&&me==="oauth"&&(n.auth.type!=="oauth"||F("mcp-scopes")!==(((Le=n.oauth)==null?void 0:Le.scopes.join(" "))??"")||!!F("mcp-client-id")||!!F("mcp-client-secret")||se(F("mcp-url"))!==se(n.url)))};p.useEffect(()=>Q(),[k]);const re=()=>{if(k==="bearer")return F("mcp-token")?{type:k,token:F("mcp-token")}:{type:k};if(k!=="headers"&&k!=="github_app")return{type:k};const me=Object.fromEntries(Array.from({length:S},(Le,Ze)=>[F(`mcp-header-name-${Ze}`),F(`mcp-header-value-${Ze}`)]).filter(([Le,Ze])=>Le&&Ze));return Object.keys(me).length?{type:k,headers:me}:{type:k}},te=async me=>{K(!0),q(null);try{await me()}catch(Le){q(oo(Le))}K(!1)},he=!!(U!=null&&U.needsClient);p.useEffect(()=>{he&&E("oauth")},[he]),p.useEffect(()=>{var me,Le;he&&k==="oauth"&&((Le=(me=f.current)==null?void 0:me.elements.namedItem("mcp-client-id"))==null||Le.focus())},[he,k]);const ge=()=>A&&te(()=>{const me=F("mcp-scopes").split(/\s+/).filter(Boolean),Le=F("mcp-client-id");return c(h.trim(),{url:y.trim(),...me.length?{scopes:me}:{},...Le?{client_id:Le,...F("mcp-client-secret")?{client_secret:F("mcp-client-secret")}:{}}:{},...L()})}),be=()=>{const me=W.current;te(async()=>{try{const Le=await e.previewMcpServer(y.trim(),re(),n==null?void 0:n.name);me===W.current&&z(Le)}catch(Le){if(me===W.current)throw Le}})},xe=me=>{if(me.preventDefault(),!!A){if(k==="oauth"&&(!n||D))return void ge();te(async()=>{var Ze;const Le=await e.saveMcpServer(h.trim(),y.trim(),re(),L());(Ze=f.current)==null||Ze.reset(),u(Le.composio)})}},fe=!H&&A&&!!h.trim()&&!!y.trim()&&(!!n||!!P),De=me=>{var Le;if(i){for(const Ze of Array.from(((Le=f.current)==null?void 0:Le.elements)??[]))Ze instanceof HTMLInputElement&&jW.test(Ze.name)&&(Ze.value="");N(1),x(me),v(e$(me.name,i)),j(me.url),E(me.auth),M(me.name),q(null),G()}},Fe=me=>(n==null?void 0:n.credential)==="sealed"&&n.auth.type===k&&t.jsxs("span",{className:"-mt-1 mb-2 block text-small text-muted-foreground",children:["Saved. ",me]});return t.jsxs("form",{ref:f,autoComplete:"off",onSubmit:xe,"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)||G(),Q()},children:[!n&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("span",{className:"caps block text-small font-semibold",children:"Presets"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:Yv.map(me=>t.jsx(B,{type:"button",size:"sm",variant:(b==null?void 0:b.id)===me.id?"solid":"outline","aria-pressed":(b==null?void 0:b.id)===me.id,disabled:H||!i||!o&&me.auth!=="none",onClick:()=>De(me),children:me.label},me.id))}),!i&&t.jsx("p",{className:"text-small text-muted-foreground",children:"The presets wait for the saved servers to be read, so the name one picks is free."}),b&&t.jsx("p",{role:"note","data-mcp-preset":b.id,className:"text-small text-muted-foreground",children:b.note}),(b==null?void 0:b.readOnly)&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ud,{checked:y===b.readOnly,label:"Read-only",disabled:H,onChange:me=>{j(me?b.readOnly:b.url),G()}}),t.jsx("span",{className:"text-small text-muted-foreground",children:"Read-only: its address that lists only the read tools."})]}),t.jsx("p",{className:"caps pt-2 text-small font-semibold",children:"Or any MCP URL"})]}),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:",h.trim()||"<name>","/<tool>."]}),t.jsx(Me,{name:"mcp-name",value:h,readOnly:!!n,onChange:me=>v(me.target.value),spellCheck:!1}),R&&t.jsxs("span",{role:"alert",className:"mt-1 block text-small text-destructive-text",children:[h.trim()," is saved already: saving would replace it. Change it from its row, or choose another name."]})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Address"}),t.jsx(Me,{name:"mcp-url",value:y,onChange:me=>{j(me.target.value),U!=null&&U.needsClient&&q(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":$,className:"font-mono text-body",children:wd[$]})]}),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:",O||"<toolkit>","/<tool>): applying one uses this server for them."]}),t.jsx(Me,{name:"mcp-toolkit",value:$==="github"?"github":_,readOnly:$==="github",onChange:me=>M(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:kW.map(([me,Le])=>t.jsxs("label",{className:"flex items-center gap-2 text-body",children:[t.jsx("input",{type:"radio",name:"mcp-auth",value:me,checked:k===me,disabled:!o&&me!=="none",onChange:()=>{E(me),me==="github_app"&&!y.trim()&&j(Wf),G()},className:"accent-primary"}),Le]},me))})]}),k==="bearer"&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:"Token"}),Fe("A new token replaces it; leave this empty to keep it."),t.jsx(Me,{name:"mcp-token",...kf})]}),k==="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."}),(k==="headers"||k==="github_app")&&t.jsxs("div",{className:"space-y-2",children:[Fe(`Its headers: ${(Ee=n==null?void 0:n.auth.headers)==null?void 0:Ee.join(", ")}. New ones replace them all; leave the values empty to keep them.`),Array.from({length:S},(me,Le)=>{var Ze;return t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Me,{name:`mcp-header-name-${Le}`,"aria-label":`Header ${Le+1} name`,placeholder:"X-Api-Key",defaultValue:(Ze=n==null?void 0:n.auth.headers)==null?void 0:Ze[Le],spellCheck:!1}),t.jsx(Me,{name:`mcp-header-value-${Le}`,"aria-label":`Header ${Le+1} value`,...kf})]},Le)}),S<dW&&t.jsx(B,{type:"button",size:"sm",variant:"ghost",onClick:()=>N(me=>me+1),children:"Add header"})]}),k==="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."}),((ae=n==null?void 0:n.oauth)==null?void 0:ae.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(Me,{name:"mcp-scopes",placeholder:"read write",defaultValue:($e=n==null?void 0:n.oauth)==null?void 0:$e.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:he?"Client ID (this server needs one)":"Client ID (optional)"}),t.jsx(Me,{name:"mcp-client-id",spellCheck:!1})]}),o&&t.jsxs("label",{className:"block flex-1",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:he?"Client secret (if its app has one)":"Client secret (optional)"}),t.jsx(Me,{name:"mcp-client-secret",...kf})]})]})]}),U&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(gl,{problem:U}),U.signIn&&k!=="oauth"&&o&&t.jsx(B,{type:"button",size:"sm",variant:"primary",disabled:H||!A||!h.trim(),onClick:()=>void ge(),children:"Sign in"})]}),P&&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 ",P.protocol,(ot=P.server_info)!=null&&ot.name?` · ${P.server_info.name}${P.server_info.version?` ${P.server_info.version}`:""}`:""," · ",P.tools.length," tool",P.tools.length===1?"":"s"]}),P.instructions&&t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-small",children:P.instructions}),t.jsx("p",{className:"mt-2 text-small text-muted-foreground",children:vI}),t.jsx("ul",{"aria-label":"Tools it lists",className:"mt-2 divide-y border",children:P.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:[k==="oauth"&&!o?null:k==="oauth"&&D?t.jsx(B,{type:"submit",size:"sm",variant:"primary",disabled:H||!y.trim(),children:"Sign in again with these settings"}):k==="oauth"?t.jsx(B,{type:"button",size:"sm",variant:n?"outline":"primary",disabled:H||!A||!h.trim()||!y.trim(),onClick:()=>void ge(),children:n?"Sign in again":"Sign in"}):t.jsx(B,{type:"button",size:"sm",disabled:H||!y.trim(),onClick:be,children:"Preview"}),(k!=="oauth"||n&&!D)&&t.jsx(B,{type:"submit",size:"sm",variant:U!=null&&U.signIn&&k!=="oauth"&&o?"outline":"primary",disabled:!fe,children:H?"Working":"Save"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>{var me;(me=f.current)==null||me.reset(),d()},children:"Cancel"})]})]})}const q0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function CW({v2:e,needs:n,model:s,onSaved:r,writable:o,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),M=()=>{const K=++_.current;e.listToolKeys().then(W=>{K===_.current&&(b(W.keys.filter(G=>G.kind==="model")),h(null))}).catch(W=>{K===_.current&&h(q0(W))})};p.useEffect(()=>{n!=="model"&&M()},[e,n]);const O=s!=null&&s.includes("/")&&!qc(s)?s.slice(0,s.indexOf("/")):void 0,L=g==null?void 0:g.find(K=>K.id===O),R=L?[L]:g,A=g==null?void 0:g.find(K=>K.id===v),P=(A==null?void 0:A.fields.filter(K=>{var W;return((W=A.secrets.find(G=>Jf(G.name)===K.name))==null?void 0:W.source)!=="env"}))??[],z=!!E&&n!=="model"&&!O,U=n!=="model"&&(!z||N),q=K=>{S(K),d==null||d(K)},H=f&&t.jsx(KC,{harnesses:f});return z&&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(Ia,{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(wx,{v2:e,view:E,onView:q}),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(Ia,{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":z?"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."]}):z?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(wx,{v2:e,view:E,onView:q,writable:o,whyNot:i,beside:t.jsx(B,{type:"button",size:"sm","aria-expanded":N,onClick:()=>$(K=>!K),children:"Add a key"})}),t.jsx("p",{className:"text-body text-muted-foreground",children:K2}),N&&t.jsx("p",{className:"text-body text-muted-foreground",children:$x})]}):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:$x})]}),U&&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:M,size:"sm",className:"mt-2",children:"Try again"})]}),U&&g&&!o&&t.jsx("p",{className:"text-body",role:"status",children:ni[i]}),U&&g&&o&&t.jsx("div",{className:"flex flex-wrap gap-2",role:"group","aria-label":"Provider",children:R.map(K=>t.jsx(B,{size:"sm",variant:v===K.id?"solid":"primary","aria-pressed":v===K.id,onClick:()=>{y(v===K.id?null:K.id),k(null)},children:K.label},K.id))}),U&&A&&o&&(P.length?t.jsx(JE,{tool:A,fields:P,onCancel:()=>y(null),onSave:async K=>{k(null);try{await e.saveToolKey(A.id,K)}catch(W){return W instanceof ze&&W.status===422?W:(k(q0(W)),null)}return y(null),M(),r==null||r(),null}},A.id):t.jsxs("p",{className:"text-body text-muted-foreground",children:["The server sets the ",A.label," key when it starts: change it there."]})),j&&t.jsx("div",{className:"border",children:t.jsx(oa,{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 EW({needs:e,settings:n,model:s,source:r,chatgpt:o=!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.`:o&&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 K0=[{value:"gmail",label:"Gmail"},{value:"fastmail",label:"Fastmail"},{value:"icloud",label:"iCloud"},{value:"other",label:"Other"}],$W={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."})},_W="Outlook needs Microsoft sign-in, which this server doesn't do yet.";function TW(e){return e==="other"?"Password":"App password"}const RW={configured:!1,preset:null,address:null,user:null,imap:null,smtp:null,password_unreadable:!1},V0=e=>{var n,s,r,o;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(((o=e.smtp)==null?void 0:o.port)??""):"465"}},Y0=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},AW=e=>Object.fromEntries((e instanceof ze?e.fields??[]:[]).map(n=>[n.field,n.message]));function OW({v2:e,writable:n,whyNot:s="sign_in"}){var G;const[r,o]=p.useState(null),[i,c]=p.useState(null),[d,u]=p.useState(V0(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),_=F=>{o(F),u(V0(F))},M=()=>{const F=++$.current;e.emailAccount().then(D=>{F===$.current&&(_(D),c(null))}).catch(D=>{F===$.current&&c(Y0(D))})};p.useEffect(()=>{n&&M()},[e,n]);const O=F=>{u(F),j(null)},L=F=>D=>O(Y=>({...Y,[F]:D.target.value})),R=()=>{const F=d.user.trim(),D=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(),...F?{user:F}:{},...f?{password:f}:{},...d.preset==="other"?{imap:{host:d.imapHost.trim(),port:Number(d.imapPort)},smtp:{host:d.smtpHost.trim(),port:Number(d.smtpPort)}}:D}},A=async(F,D)=>{x(null),v({}),N(!0);try{await D()}catch(Y){const se=AW(Y);Object.keys(se).length?v(se):x({title:F,error:Y0(Y)})}finally{N(!1)}},P=F=>{F.preventDefault(),A("The account was not saved",async()=>{_(await e.saveEmailAccount(R())),g(""),j(null)})},z=()=>A("The account was not tested",async()=>{j(null),j(await e.testEmailAccount(R()))}),U=()=>A("The account was not removed",async()=>{E(!1),await e.removeEmailAccount(),_(RW),g(""),j(null)}),q=t.jsxs("div",{className:si,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:Ko,children:[q,t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:ni[s]})]})});if(!r)return i?t.jsx(vt,{tone:"error",className:"m-8",actions:t.jsx(B,{type:"button",size:"xs",onClick:M,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,K=d.preset==="other",W=(F,D,Y)=>t.jsxs("div",{className:"grid grid-cols-[1fr_7rem] gap-2",children:[t.jsx(wt,{label:`${D} server`,error:h[`${F}.host`],children:t.jsx(Me,{name:`${F}_host`,value:F==="imap"?d.imapHost:d.smtpHost,onChange:L(F==="imap"?"imapHost":"smtpHost"),placeholder:Y,spellCheck:!1,autoCapitalize:"off"})}),t.jsx(wt,{label:"Port",error:h[`${F}.port`],children:t.jsx(Me,{name:`${F}_port`,inputMode:"numeric",value:F==="imap"?d.imapPort:d.smtpPort,onChange:L(F==="imap"?"imapPort":"smtpPort")})})]});return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[q,t.jsxs("div",{className:ri,children:[b&&t.jsx(oa,{error:b.error,title:b.title}),i&&t.jsx(vt,{tone:"error",actions:t.jsx(B,{type:"button",size:"xs",onClick:M,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(Rr,{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(DT,{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(ke,{tone:"success",children:"saved"}),H&&r.preset&&t.jsx(ke,{children:((G=K0.find(F=>F.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(wt,{label:"Provider",group:"heading",note:_W,error:h.preset,children:t.jsx(dd,{name:"email-preset",label:"Provider",value:d.preset,onChange:F=>O(D=>({...D,preset:F})),options:K0})}),t.jsx("p",{className:"text-small text-muted-foreground",children:$W[d.preset]}),t.jsx(wt,{label:"Address",error:h.address,children:t.jsx(Me,{name:"address",inputMode:"email",autoComplete:"username",spellCheck:!1,autoCapitalize:"off",placeholder:"you@example.com",value:d.address,onChange:L("address")})}),t.jsx(wt,{label:"Sign-in name",optional:!0,note:"When the server's sign-in isn't the address.",error:h.user,children:t.jsx(Me,{name:"user",spellCheck:!1,autoCapitalize:"off",value:d.user,onChange:L("user")})}),t.jsx(wt,{label:TW(d.preset),error:h.password,children:t.jsx(Me,{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:F=>{g(F.target.value),j(null)}})}),K&&W("imap","IMAP","imap.example.com"),K&&W("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 z(),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 U(),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(F=>t.jsxs("p",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(ke,{tone:y[F].ok?"success":"error",children:F==="imap"?"IMAP":"SMTP"}),t.jsx("span",{className:y[F].ok?"":"text-destructive-text",children:y[F].message})]},F)),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 Q0=e=>e instanceof ze?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 PW({v2:e}){const[n,s]=p.useState(null),[r,o]=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 M=++S.current;Promise.all([e.webhook(),e.webhookDeliveries()]).then(([O,L])=>{M===S.current&&(s(O),o(L.attempts),c(null))}).catch(O=>{M===S.current&&c(Q0(O))})};p.useEffect(N,[e]);const $=async(M,O)=>{g(null),j(!0);try{await O()}catch(L){g({title:M,error:Q0(L)})}finally{j(!1)}N()},_=M=>{M.preventDefault(),$("The webhook was not saved",async()=>{const O=await e.saveWebhook(k.trim());O.signing_secret&&u(O.signing_secret);const{signing_secret:L,...R}=O;s(R)})};return n?t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:si,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:ri,children:[f&&t.jsx(oa,{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(Rr,{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(ol,{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(ke,{tone:"error",children:"off"}):n.signing==="sealed"?t.jsx(ke,{tone:"success",children:"on"}):t.jsx(ke,{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(Me,{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:M=>E(M.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: ",J0(b)]})]})}),t.jsx(Rr,{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((M,O)=>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(M.at)}),t.jsx("span",{className:"w-[130px] shrink-0 font-mono",children:M.type}),t.jsx("span",{className:M.error?"min-w-0 flex-1 font-mono text-destructive-text":"min-w-0 flex-1 font-mono",children:J0(M)}),M.redelivery&&t.jsx(ke,{children:"redelivery"}),t.jsxs("span",{className:"font-mono text-small text-muted-foreground",title:M.webhook_id,children:[M.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(M.webhook_id)),children:"Redeliver"})]},`${M.webhook_id}:${M.at}:${O}`))})})]})]})}):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 J0(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 LW={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."}},_x=e=>LW[e]??{label:e,gives:""},IW=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1},Tx=e=>e.slice(e.lastIndexOf(":")+1),zW=2e3;function DW({v2:e,writable:n,whyNot:s="sign_in"}){const[r,o]=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&&o(_)},_=>{$===y.current&&c(IW(_))})},[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(Un,{label:"Loading the computers",rows:3})});const k=new Set(r.paired.map($=>$.id)),E=$=>r.kinds.filter(_=>_.providers.some(M=>M.id===$)).map(_=>_.kind),S=async($,_,M)=>{g(null);try{await e.saveComputerKeys(_.id,M)}catch(O){return O instanceof ze&&O.status===422?O:(g({at:$,words:Wt(O)}),null)}return u(null),j(),null},N=async $=>{v(M=>new Set(M).add($.id));let _;try{const M=await e.testComputer($.id);_=M.ok?{ok:!0,words:M.detail,at:new Date().toISOString()}:{ok:!1,words:M.why,at:new Date().toISOString()}}catch(M){_={ok:!1,words:Wt(M),at:new Date().toISOString()}}x(M=>({...M,[$.id]:_})),v(M=>{const O=new Set(M);return O.delete($.id),O})};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:si,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:ri,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:ni[s]}),r.kinds.map($=>t.jsx(HW,{kind:$,providers:$.providers.filter(_=>!k.has(_.id)),own:$.providers.filter(_=>k.has(_.id)).map(_=>_.name),children:$.providers.filter(_=>!k.has(_.id)).map(_=>{const M=`${$.kind}/${_.id}`;return t.jsx(BW,{v2:e,kind:$.kind,provider:_,writable:n,serves:E(_.id),tested:b[_.id],testing:h.has(_.id),open:(d==null?void 0:d.at)===M?d.mode:null,problem:(f==null?void 0:f.at)===M?f.words:null,onOpen:O=>{u(O?{at:M,mode:O}:null),g(null)},onSave:O=>S(M,_,O),onRemove:async O=>{var R;const L=await S(M,_,{[O]:null});L&&g({at:M,words:((R=L.fields)==null?void 0:R.map(A=>A.message).join(" "))||L.message})},onTest:()=>void N(_)},_.id)})},$.kind))]})]})})}function FW(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(o=>_x(o).label).join(", ")||_x(e.kind).label,n,s,e.arch,r].filter(Boolean).join(" · ")}function UW(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,o]=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,zW);return()=>{clearInterval(N),clearInterval($)}},[j,s]),p.useEffect(()=>{if(!r)return;const N=n.find($=>$.pairing===r.code.id);N&&(g(N.name),o(null))},[n,r]);const k=async()=>{c(!0),v(null),g(null);try{const N=await e.createPairing();u(Date.now()),o({code:N})}catch(N){v(Wt(N))}c(!1)},E=async N=>{v(null);try{await e.removeComputer(N)}catch($){v(Wt($));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(Rr,{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:()=>o(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(zN,{className:"mt-1 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}):t.jsx(Ja,{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(ke,{tone:"success",children:"Online"}):t.jsx(ke,{tone:"muted",children:"Offline"}),N.held_by_run&&t.jsxs(ke,{tone:"active",children:["In use by run ",na(N.held_by_run)]}),N.unserved&&t.jsx(ke,{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:FW(N)}),N.groups.length>0&&t.jsx("p",{"data-offers":!0,className:"mt-1 text-small text-muted-foreground",children:UW(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 HW({kind:e,providers:n,own:s,children:r}){const{label:o,gives:i}=_x(e.kind);return t.jsx(Rr,{label:o,title:o,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(ke,{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 BW({v2:e,kind:n,provider:s,writable:r,serves:o,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(Ja,{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(ke,{tone:"success",children:"Ready"}):t.jsx(ke,{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&&cy.has(n)&&t.jsx("p",{className:"mt-1.5 text-small text-muted-foreground",children:ly}),s.secrets.length>0&&t.jsx("ul",{className:"mt-3 space-y-1.5",children:s.secrets.map(j=>{var S;const k=Tx(j.name),E=((S=s.picked)==null?void 0:S.includes(j.name))??!1;return t.jsx(lh,{field:j,required:s.required.includes(j.name),writable:r&&!d,onPaste:E?void 0:()=>void ih(()=>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(GW,{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"} · ${md(i.at)} · ${i.words}`}),t.jsxs("p",{className:"mt-2 text-small text-muted-foreground",children:[s.secrets.length?"":"No key. ","Serves: ",o.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(qW,{provider:s.name,name:v,set:s.secrets.some(j=>Tx(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 GW({v2:e,provider:n,writable:s,onSave:r}){const[o,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(Wt(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&&!o?t.jsx("p",{role:"alert",className:"mt-3 font-mono text-small text-destructive-text",children:`The choices could not be read: ${c}`}):o?t.jsxs("div",{className:"mt-3 space-y-3",children:[o.choices.map(x=>{const h=n.secrets.find(y=>Tx(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(Et,{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 qW({provider:e,name:n,set:s,onSave:r,onCancel:o}){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(Me,{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(),o()},children:"Cancel"})]})]})}const KW="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.",X0=[{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)"}],VW=e=>({region:e.region??"",s3Url:e.s3Url??"",image:e.image??""}),wr="ARCHIL_API_KEY",YW=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!1};function QW({v2:e,writable:n,whyNot:s="sign_in"}){const[r,o]=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),[M,O]=p.useState(!1),L=p.useRef(null),R=p.useRef(0),A=p.useCallback(W=>{o(W),u(VW(W))},[]),P=p.useCallback(()=>{const W=++R.current;c(null),e.archil().then(G=>{W===R.current&&A(G)},G=>{W===R.current&&c(YW(G))})},[e,A]);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(Un,{label:"Loading Archil's settings",rows:2})});const z=()=>{var W,G;return((G=(W=L.current)==null?void 0:W.elements.namedItem(wr))==null?void 0:G.value)??""},U=async W=>{const G={region:d.region,s3Url:d.s3Url,...d.image?{image:d.image}:{},...W!==void 0?{keys:{[wr]:W}}:{}};v(!0),g(null),x(null);try{const F=await e.saveArchil(G);_(!1),O(!1),A(F)}catch(F){if(F instanceof ze&&F.status===422){const D={},Y=[];for(const se of F.fields??[]){const Q=se.field.startsWith("keys.")?se.field.slice(5):se.field;X0.some(re=>re.name===Q)||Q===wr?D[Q]=se.message:Y.push(se.message)}g({fields:D,message:Y.length?Y.join(" "):Object.keys(D).length?null:F.message})}else x(Wt(F))}finally{v(!1)}},q=W=>{W.preventDefault(),U($&&z()?z():void 0)},H=async()=>{E(!0);try{const W=await e.testArchil();j(W.ok?{ok:!0,words:W.detail,at:new Date().toISOString()}:{ok:!1,words:W.why,at:new Date().toISOString()})}catch(W){j({ok:!1,words:Wt(W),at:new Date().toISOString()})}finally{E(!1)}},K=async()=>{x(null);try{A(await e.archilOff()),N(!1)}catch(W){x(Wt(W))}};return t.jsx("div",{className:"h-full overflow-auto",children:t.jsxs("div",{className:Ko,children:[t.jsxs("div",{className:si,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:KW})]}),t.jsxs("div",{className:ri,children:[!n&&t.jsx("p",{role:"status",className:"border bg-card p-4 text-body",children:ni[s]}),t.jsx(Rr,{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(OT,{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(ke,{tone:"success",children:"On"}):t.jsx(ke,{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"} · ${md(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 K(),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:q,className:"mt-5 space-y-4","aria-label":"Archil settings",children:[X0.map(W=>t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:W.label}),t.jsx(Me,{name:W.name,value:d[W.name],placeholder:W.placeholder,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onChange:G=>{const F=G.currentTarget.value;u(D=>({...D,[W.name]:F}))}}),(f==null?void 0:f.fields[W.name])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[W.name]})]},W.name)),t.jsx("ul",{children:t.jsx(lh,{field:r.secret,label:wr,writable:n&&!$&&!M,onPaste:()=>void ih(()=>_(!0),()=>{var W;return(W=L.current)==null?void 0:W.elements.namedItem(wr)}),onRemove:()=>O(!0)})}),n&&M&&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 ",wr," saved on this server?"]}),t.jsx(B,{type:"button",size:"sm",variant:"destructive",onClick:()=>void U(null),children:"Remove"}),t.jsx(B,{type:"button",size:"sm",onClick:()=>O(!1),children:"Cancel"})]}),n&&$&&t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"caps mb-2 block text-small font-semibold",children:wr}),t.jsx(Me,{type:"password",name:wr,autoComplete:"new-password",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","data-1p-ignore":!0,"data-lpignore":"true"}),(f==null?void 0:f.fields[wr])&&t.jsx("span",{className:"mt-2 block font-mono text-small text-destructive-text",role:"alert",children:f.fields[wr]})]}),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 t$="tool_approval_requested";function JW(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 XW(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 ${to(e)} per call`:null}function ZW(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(`
|
|
701
|
+
`)}const e9={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 n$(e){var n;if(e instanceof ze){const s=((n=e.details)==null?void 0:n.reason)==="already_answered"&&typeof e.details.decision=="string"?e9[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 Wt(e)}const t9=2e3;function s$({pending:e,onAnswer:n,compact:s=!1,heading:r}){const[o,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=XW(e.price),S=async(N,$)=>{if(y.current)return;y.current=!0,d(!0),f(null),h(!1);const _=o.trim(),M=await($?n(N,void 0,$):n(N,N==="deny"&&_?_:void 0));y.current=!1,d(!1),M?f(M):b(N)};return t.jsxs("section",{"aria-label":"Approval required",className:ie("min-w-0 border border-warning/50 bg-warning/5",s?"p-4":"p-4 md:p-5"),children:[r,t.jsxs("p",{className:ie("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-2"),children:[t.jsx(IN,{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(ke,{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:ie("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:ZW(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(nn,{value:o,onChange:N=>i(N.target.value),maxLength:t9,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(n9,{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 n9({tool:e,onAllow:n,onBack:s}){const r=p.useRef(null);return p.useEffect(()=>{var o;(o=r.current)==null||o.focus()},[]),t.jsxs("div",{role:"alertdialog","aria-label":`Allow ${e}?`,onKeyDown:o=>{o.key==="Escape"&&(o.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 s9={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 r9({mode:e,onSend:n,sending:s,sent:r,purpose:o}){const i=o??s9[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(nn,{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(ET,{"aria-hidden":!0})]})]})]})}function Jr(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 r$=e=>`Paused at its ${typeof e.cap_usd=="number"&&Number.isFinite(e.cap_usd)?`${Jr(e.cap_usd)} `:""}spend cap`;function o9({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(Wx,{className:"size-3.5","aria-hidden":!0})," ",r$(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 o$=e=>typeof(e==null?void 0:e.suggested_cap_usd)=="number"&&Number.isFinite(e.suggested_cap_usd)?e.suggested_cap_usd:null,a$=e=>typeof(e==null?void 0:e.least_cap_usd)=="number"&&Number.isFinite(e.least_cap_usd)?e.least_cap_usd:null;function a9(e){var n,s;return e instanceof ze?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 i$({cap:e,suggested:n,least:s=null,paused:r,onRaise:o}){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 o(v);E.note&&x(E.note)}catch(E){g(a9(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(Me,{"aria-label":"New cap in dollars",inputMode:"decimal",value:i,onChange:k=>c(k.target.value),disabled:d,placeholder:`more than ${Jr(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: ",Jr(s)]}),n!==null&&t.jsxs("li",{"data-cap-figure":"suggested",children:["Suggested: ",Jr(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 i9({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(Gx,{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(rl,{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 nl=0;const Rx=()=>{var n;const e=(n=history.state)==null?void 0:n.console_at;return typeof e=="number"?e:void 0},Z0=e=>{nl=e,history.replaceState({...history.state??{},console_at:e},"")};function l9(){const e=Rx();e===void 0?Z0(0):nl=e;const n=()=>{const s=Rx();s===void 0?Z0(nl+1):nl=s};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)}function c9(){const e=Rx();return e===void 0?-1:nl-e}function d9(e){nl>0?history.back():location.hash=e}const u9=(e,n)=>{const s=Sl(e),r=hd(e)?V2:void 0;return s?r?`${hk(s,{ended:n})} ${r}`:hk(s,{ended:n}):e&&e.usd!==null&&JS(e)?r?`A local estimate, not a bill. ${r}`:"A local estimate, not a bill":r};function f9({run:e,agentName:n,actions:s={},costText:r}){var E,S,N;const o=es(e),i=o?"your backend":ZP(e.place),c=Fm(e.status,e.state,e.kind,Dm,!0,e.error,e.review,e.computer),d=o?{...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=!o&&!!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=!!hd(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:()=>d9(dn(e.agent_id)),className:"-m-1.5 shrink-0 p-1.5 hover:text-foreground",children:t.jsx(An,{className:"size-3.5","aria-hidden":!0})}),t.jsx("a",{href:dn(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 ",na(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:Cn(e),children:e.kind==="workflow"&&/^[[{]/.test(e.title.trim())?n:Cn(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($l,{run:e}),g&&t.jsx(ke,{tone:"muted",children:"Archived"}),e.approvals==="never"&&t.jsx(ke,{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}`]}),o&&t.jsxs("span",{className:"font-mono",children:[Yo(o.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:pk(e.cost,b,{text:r})}):t.jsxs("span",{className:"font-mono",title:u9(e.cost,Ga(e.status)),children:[pk(e.cost,b,{ended:Ga(e.status)}),k&&t.jsxs(t.Fragment,{children:[" · ",t.jsx(uy,{})]})]}),t.jsx(oy,{run:e,link:!0}),t.jsx(VE,{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 ${Jr(b)} spend cap.`,children:[t.jsx(Wx,{"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(JT,{"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(_N,{"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($N,{"aria-hidden":!0}):t.jsx(nd,{"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(i$,{cap:b,suggested:o$(j),least:a$(j),paused:!!j,onRaise:s.onRaiseCap},j?`${e.run_id}:${j.at}`:`${e.run_id}:working`)})]})}const m9=[{id:"rendered",label:"Rendered"},{id:"raw",label:"Raw"}];function h9({view:e,onView:n}){return t.jsx("div",{className:"flex",role:"radiogroup","aria-label":"View",children:m9.map(s=>t.jsxs("label",{className:ie("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 l$=(e,n)=>n?e:e.filter(s=>!w2(s.path));function p9({files:e,onOpen:n,showHidden:s,onShowHidden:r}){const o=e.filter(d=>w2(d.path)).length,i=l$(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(RT,{className:"size-3.5","aria-hidden":!0})," Files · ",i.length," ",i.length===1?"file":"files"," (",Ba(c),")"]}),o>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"," ",o," hidden"]})]}),i.length===0?t.jsx("p",{className:"border px-4 py-8 text-center font-mono text-body text-muted-foreground",children:o?`Only files in hidden folders (${o}).`:"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(Qa,{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:Ba(d.size_bytes)})]})},d.path))})]})}function g9({file:e,text:n,onClose:s,files:r=[],onOpen:o}){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=AP(e),[b,x]=p.useState(g==="markdown"?"rendered":"raw");p.useEffect(()=>x(g==="markdown"?"rendered":"raw"),[e.path]);const h=Cv(y=>{const j=r.find(k=>k.path===y);j&&(o==null||o(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(Xo,{"aria-hidden":!0})}),t.jsx(Qa,{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(h9,{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(Ya,{"aria-hidden":!0})," ",i?"Copied":"Copy"]}),t.jsxs(B,{size:"sm",disabled:n===null,onClick:v,children:[t.jsx(AN,{"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:so(n,o&&{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 x9(e){const n=e.replace(/\r\n?/g,`
|
|
702
|
+
`).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(`
|
|
703
|
+
`);let o;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();o=b==="json"||b===""?{open:c,end:g}:void 0,c=g}if(o&&o.end===r.length-1){const c=s(r.slice(o.open+1,o.end).join(`
|
|
704
|
+
`));return c?{words:r.slice(0,o.open).join(`
|
|
705
|
+
`).trim(),record:c}:null}const i=s(n);if(i)return{words:"",record:i};for(let c=n.lastIndexOf(`
|
|
706
|
+
{`);c>=0;c=n.lastIndexOf(`
|
|
707
|
+
{`,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 v9=e=>e.replace(/[_-]+/g," ").trim()||e,jc=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;function am(e,n){let s=jc(e);for(let r=0;s&&typeof s.$ref=="string"&&s.$ref.startsWith("#")&&r<8;r++){const o=s.$ref.slice(1).split("/").filter(Boolean).map(f=>decodeURIComponent(f).replaceAll("~1","/").replaceAll("~0","~")),{$ref:i,...c}=s,d=jc(o.reduce((f,g)=>{var b;return(b=jc(f))==null?void 0:b[g]},n))??{},u=d.properties||c.properties?{...jc(d.properties),...jc(c.properties)}:void 0;s={...d,...c,...u?{properties:u}:{}}}return s}const y9=(e,n)=>{var s;return((s=am(e,n))==null?void 0:s.contentMediaType)==="text/markdown"};function _y({value:e,schema:n,root:s,linked:r}){var o;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=(o=am(n,s))==null?void 0:o.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(_y,{value:c,schema:i,root:s,linked:r})},d))})}return typeof e=="object"?t.jsx(c$,{record:e,schema:n,root:s,linked:r}):typeof e=="string"&&y9(n,s)?t.jsx("article",{"data-json-markdown":!0,className:"report max-w-none",dangerouslySetInnerHTML:{__html:so(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 c$({record:e,schema:n,root:s,linked:r}){var i;const o=(i=am(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=o==null?void 0:o[c],f=(g=am(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:v9(c)}),t.jsx("dd",{className:"mt-1 min-w-0 text-prose leading-relaxed",children:t.jsx(_y,{value:d,schema:u,root:s,linked:r})})]},c)})})}function eN({record:e,schema:n,linked:s}){const[r,o]=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:()=>o(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(c$,{record:e,schema:n,root:n,linked:s})})]})}function b9({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(_y,{value:e,schema:n,root:n,linked:s})})}function w9({run:e,rows:n,files:s=[],onOpen:r,schema:o}){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=Cv(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(eN,{record:u,schema:o,linked:c}):t.jsx(b9,{value:u,schema:o,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=x9(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:so(j.words,c)}}),t.jsx(eN,{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:so(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(`
|
|
708
|
+
`)&&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:so(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 j9({native:e,agentId:n}){const s=[{label:"Task usage",usage:e.usage.task},...e.usage.reflection.length?e.usage.reflection.map((r,o)=>({label:`Reflection usage · turn ${o+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",yd(e.runtime)],["Project",e.project],["Selector",Fv(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,o])=>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:o})]},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:o})=>{const i=e.runtime==="codex"?(o==null?void 0:o.input_tokens)==null||o.cache_read_tokens==null||o.cache_write_tokens==null?null:Math.max(0,o.input_tokens-o.cache_read_tokens-o.cache_write_tokens):o==null?void 0:o.input_tokens;return t.jsxs("tr",{children:[t.jsx("th",{className:"whitespace-nowrap px-2 py-2 font-normal",children:r}),[i,o==null?void 0:o.output_tokens,o==null?void 0:o.cache_read_tokens,o==null?void 0:o.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:(o==null?void 0:o.cost_usd)==null?"Unknown":to(o.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 k9={seeded:"Prepared",reflecting:"Reflecting",proposed:"Under review",merged:"Saved",dropped:"Not saved",pending:"Awaiting approval"},uf=e=>typeof e=="number"&&Number.isFinite(e)?e.toLocaleString("en-US"):"Not reported";function N9({run:e,read:n,onViewChanges:s}){var y,j,k,E,S,N,$,_,M,O,L;const[r,o]=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 R=!0;if(!u){o({data:void 0,reading:!1});return}return o(A=>({...A,error:void 0,reading:!0})),Promise.resolve().then(()=>d.current()).then(A=>{if(A&&A.run!==f)throw new Error("The learning result belongs to a different run. Refresh to try again.");R&&o({data:A,reading:!1})}).catch(A=>{R&&o(P=>({...P,error:A??new Error("The learning result could not be read."),reading:!1}))}),()=>{R=!1}},[f,g,b,u,i]),p.useEffect(()=>{const R=()=>{document.hidden||c(A=>A+1)};return window.addEventListener("focus",R),document.addEventListener("visibilitychange",R),()=>{window.removeEventListener("focus",R),document.removeEventListener("visibilitychange",R)}},[]);const x=r.data,h=()=>c(R=>R+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(ke,{children:k9[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(fr,{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(Jo,{"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(Jt,{problem:Ht(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(R=>!R.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((R,A)=>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:R.file}),t.jsx(ke,{tone:R.pending?"warning":R.keep?"success":"muted",children:R.pending?"Needs approval":R.keep?"Keep":"Do not keep"})]}),t.jsx("p",{className:"break-words text-body leading-relaxed text-muted-foreground",children:R.why}),R.question&&t.jsx("p",{className:"text-small",children:R.question}),R.origin&&t.jsx("p",{className:"text-label text-muted-foreground",children:R.origin==="you"?"From your instruction":`Origin: ${R.origin}`})]},`${R.file}-${A}`))}):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:Km(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(R=>R.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:[(M=x.problems)==null?void 0:M.map((R,A)=>t.jsxs("li",{className:"border p-3",children:[t.jsx("p",{className:"text-body",children:R.detail}),t.jsx("p",{className:"mt-1 break-all font-mono text-label text-muted-foreground",children:[R.rule,R.path].filter(Boolean).join(" · ")})]},`problem-${A}`)),(O=x.draft_errors)==null?void 0:O.map((R,A)=>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:R})]},`draft-${A}`))]}):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"?Pa(x.cost_usd.grade):"Not reported"],["Input",uf(v==null?void 0:v.input)],["Output",uf(v==null?void 0:v.output)],["Cache reads",uf(v==null?void 0:v.cache_read)],["Cache writes",uf(v==null?void 0:v.cache_write)]].map(([R,A])=>t.jsxs("div",{className:"border p-3",children:[t.jsx("dt",{className:"mb-1 text-label text-muted-foreground",children:R}),t.jsx("dd",{className:"font-mono text-body",children:A})]},R))}),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(fr,{"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 tN=32,S9=360,C9=.7;function E9(e,n){const s=e.getBoundingClientRect().top;if(!n)return window.innerHeight-(s+window.scrollY)-tN;const r=s-n.getBoundingClientRect().top+n.scrollTop;return n.clientHeight-r-tN}const $9=(e,n)=>Math.round(Math.max(S9,Math.min(e,n*C9)));function _9(e,n,s=3e3,r=Math.min(s,T9),o=!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(o);y.current=o,p.useEffect(()=>{o&&(v.current=null)},[o]);const j=!!e;p.useEffect(()=>{if(!j||d)return;if(n||(v.current=null),!n&&g.current&&!b.current){c(M=>M&&nN(M));return}let E=!0,S;const N=M=>{clearTimeout(S),S=setTimeout(()=>{h.current=null,_()},M),h.current=()=>N(r)};let $=!1;const _=async()=>{try{const M=await f.current();if(!E)return;g.current=!0,M.state==="live"&&!y.current&&(v.current=M.kind);const O=M.state==="none"&&M.session==="opening"&&M.kind!=="browser"&&M.kind===v.current?{...M,session:"closed"}:M;b.current=O.state==="none"&&O.session==="unopened",$=O.state==="none"&&O.session==="opening"||O.state==="live"&&O.hold==="pending",O.state==="off"?c(null):c(n?L=>A9(L,O)?L:O:nN(O))}catch(M){if(!E)return;if(M instanceof ze&&M.status===401){u(!0),c(O=>O?{state:"signed_out"}:null);return}if(M instanceof ze&&M.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()+R9,(S=h.current)==null||S.call(h)},[]);return{view:i,held:k}}const T9=400,R9=4e3,A9=(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))},nN=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"},O9={browser:MN,desktop:Ja,phone:zN,sandbox:ZT},M9={browser:"Browser",desktop:"Desktop",phone:"Phone",sandbox:"Sandbox"},P9={agent:"The agent drives",pending:"Yours after the agent's step",person:"You drive"};function L9({runId:e,screen:n,machine:s,opens:r,followUp:o,metered:i,waitsFor:c,keptUntil:d,onTake:u,onHand:f,recordings:g=[],fileUrl:b}){const x=p.useRef({viewer:"",n:0});(n==null?void 0:n.state)==="live"&&n.viewer!==x.current.viewer&&(x.current={viewer:n.viewer,n:x.current.n+1});const h=n&&n.state!=="signed_out"?n.kind:(s==null?void 0:s.kind)??"browser",v=(n==null?void 0:n.state)==="live"?U9(n.viewer,e):void 0,y=v&&h!=="browser"?`${v}${v.includes("#")?"&":"#"}hands=page`:v,j=O9[h],k=(n==null?void 0:n.state)==="live"?n:null,[E,S]=p.useState(!1),[N,$]=p.useState(null),_=async F=>{if(!(!F||E)){S(!0),$(null);try{$(await F())}finally{S(!1)}}},M=k&&y&&h!=="browser"?k:null,[O,L]=p.useState(!1),R=p.useRef(null),A=p.useRef(null),P=p.useRef(null),z=p.useRef(!1),U=!!(k&&y);p.useEffect(()=>{U||L(!1)},[U]);const[q,H]=p.useState(void 0);p.useLayoutEffect(()=>{const F=R.current;if(h!=="phone"||O||!U||!F)return;const D=F.closest("[data-scroll-pane]"),Y=()=>H($9(E9(F,D),window.innerHeight));Y();const se=typeof ResizeObserver=="function"&&D?new ResizeObserver(Y):void 0;if(D)for(const Q of[D,...D.children])se==null||se.observe(Q);return window.addEventListener("resize",Y),()=>{se==null||se.disconnect(),window.removeEventListener("resize",Y)}},[h,O,U,N,i,x.current.n]),p.useEffect(()=>{var F,D,Y;if(O){z.current=!0,(D=(F=A.current)==null?void 0:F.querySelector("button"))==null||D.focus();return}z.current&&(z.current=!1,(Y=P.current)==null||Y.focus())},[O]),p.useEffect(()=>{if(!O)return;const F=re=>{if(re.key==="Escape"){L(!1);return}if(re.key!=="Tab"||!A.current)return;const te=[...A.current.querySelectorAll("button:not([disabled]), iframe")];if(!te.length)return;const he=te[0],ge=te[te.length-1],be=document.activeElement;A.current.contains(be)?re.shiftKey&&be===he?(re.preventDefault(),ge.focus()):!re.shiftKey&&be===ge&&(re.preventDefault(),he.focus()):(re.preventDefault(),he.focus())},D=re=>{re.key==="Escape"&&L(!1)};document.addEventListener("keydown",F);const Y=R.current;let se=null;const Q=()=>{try{se==null||se.removeEventListener("keydown",D,!0)}catch{}try{se=(Y==null?void 0:Y.contentWindow)??null,se==null||se.addEventListener("keydown",D,!0)}catch{se=null}};return Q(),Y==null||Y.addEventListener("load",Q),()=>{document.removeEventListener("keydown",F),Y==null||Y.removeEventListener("load",Q);try{se==null||se.removeEventListener("keydown",D,!0)}catch{}}},[O,x.current.n]);const K=k?h==="browser"?"browser · take over in the view below":`${P9[k.hold]} · ${h}`:"",W=M&&(M.hold==="person"?t.jsx(B,{size:"sm",variant:"solid",disabled:E,onClick:()=>void _(f),children:"Hand back"}):t.jsx(B,{size:"sm",variant:"solid",disabled:E||M.hold==="pending",onClick:()=>void _(u),children:M.hold==="pending"?"Taking over":"Take over"})),G=U&&t.jsx(B,{ref:O?void 0:P,size:"sm",variant:"ghost",onClick:()=>L(F=>!F),"aria-label":O?"Exit full window (Esc)":"Fill the window",title:O?"Exit full window (Esc)":"Fill the window","aria-pressed":O,children:O?t.jsx(HT,{className:"size-4","aria-hidden":!0}):t.jsx(FT,{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(j,{className:"size-4 text-muted-foreground","aria-hidden":!0}),t.jsx("span",{className:"caps text-small font-semibold",children:k?"Live":M9[h]}),t.jsx("span",{className:"flex-1 font-mono text-small text-muted-foreground",children:K}),g.some(F=>!F.finished)&&t.jsx(ke,{tone:"active",title:"A video of this screen is being recorded",children:"Recording"}),b&&g.filter(F=>F.finished).map((F,D,Y)=>t.jsxs("a",{href:`${b(F.path)}?download=1`,download:!0,className:al({variant:"ghost",size:"sm"}),"aria-label":`Export ${F.path} (${Ba(F.bytes)})`,children:[t.jsx(AN,{"aria-hidden":!0})," Export",Y.length>1?` ${D+1}`:""]},F.path)),!O&&G,!O&&W]}),i&&h!=="browser"&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-muted-foreground",children:ly}),!O&&N&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:N}),k&&y?t.jsxs("div",{ref:A,"data-testid":"screen-frame",className:O?"fixed inset-0 z-dialog flex flex-col bg-background":void 0,role:O?"dialog":void 0,"aria-modal":O?!0:void 0,"aria-label":O?"The run's screen, filling the window":void 0,children:[O&&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:K}),G,W]}),O&&N&&t.jsx("p",{className:"border-b px-4 py-2 text-small text-warning-text",role:"alert",children:N}),t.jsx("iframe",{ref:R,src:y,title:"The run's screen",referrerPolicy:"no-referrer",sandbox:"allow-forms allow-scripts allow-same-origin",className:O?"block min-h-0 w-full flex-1 bg-background":h==="phone"?ie("mx-auto block aspect-[9/19] max-w-full bg-background",q===void 0&&"h-[70vh]"):"block aspect-[16/10] w-full bg-background",style:!O&&h==="phone"&&q!==void 0?{height:`${q}px`}:void 0},x.current.n)]}):t.jsx("p",{className:"px-4 py-12 text-center font-mono text-body text-muted-foreground",children:F9(h,n,s,r,o,c,d)})]})}const I9={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."},z9=/^The (desktop|phone) is kept for (\d+) minutes while you decide\.$/;function D9(e,n){for(let s=e.length-1;s>=0;s-=1){const r=e[s];if(r.kind!=="phase")continue;const o=r.summary??r.text??"";if(o.startsWith(`The ${n} is ready`))return;const i=z9.exec(o);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 F9(e,n,s,r,o,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`${I9[i]} The ${e} is kept until ${sN(c).replace(/^at /,"")}.`;if(r&&(n==null?void 0:n.state)==="none"&&n.ended)return e==="browser"?`${n.ended.why} (${sN(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}.${o?" 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.${o?" A follow-up opens a new one if the agent needs it.":""}`}function sN(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:`at ${n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function U9(e,n){let s;try{s=new URL(e,location.origin).href}catch{return}const r=dr(s);if(!r)return;const o=new URL(r);return o.origin===location.origin&&o.pathname.startsWith(`/v2/runs/${encodeURIComponent(n)}/computer/live/`)?r:void 0}const Gi=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},d$=e=>e.kind==="computer"?e.computer:"browser";function Ax(e,n){var s;if(e instanceof ze&&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 ze&&e.code==="computer_not_live"?e.message:e instanceof ze&&e.status===404?n==="hand"?"The agent isn't asking for you now.":"This run has no screen to take over.":e instanceof ze&&e.status===403?"Sign in with your password to do this from here.":`${n==="hand"?"Not answered":"Not taken"}: ${Wt(e)}`}function u$({ask:e,onAnswer:n,open:s,heading:r,compact:o=!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:o?"px-4 py-3":"border border-warning/50 bg-warning/5 p-4",children:[r,t.jsxs("p",{className:ie("caps flex items-center gap-2 text-label text-warning-text",r&&"mt-1"),children:[t.jsx(Ja,{className:"size-3.5","aria-hidden":!0})," Waiting for you · ",d$(e)]}),t.jsxs("div",{"data-agent-request":!0,className:ie("border-l-2 border-warning/60 pl-3",o?"mt-1":"mt-2"),children:[t.jsxs("p",{className:o?"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&&Vc(e.learning).length>0,[r,o]=p.useState({state:"reading"}),[i,c]=p.useState(0);return p.useEffect(()=>{if(!s)return;let d=!0;return o({state:"reading"}),Promise.resolve().then(()=>n()).then(u=>{d&&o({state:"read",changes:uD(u,e.learning)})},u=>{d&&o({state:"failed",error:u??new Error("unknown")})}),()=>{d=!1}},[e.run_id,s,i]),s?{got:r,retry:()=>c(d=>d+1)}:null}function H9({got:e,retry:n}){if(e.state==="read"&&!e.changes.length)return null;const s=e.state==="failed"?Ht(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(B9,{change:r})},r.file))})]})}function B9({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(Es,{className:ie("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(rN,{name:"before",lines:e.before,none:"Not there before."}),t.jsx(rN,{name:"after",lines:e.after,none:"Not there after."})]}))]})}function rN({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,o)=>t.jsxs("span",{className:ie("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:ie("min-w-0 whitespace-pre-wrap break-words",r.mark==="gap"&&"text-muted-foreground"),children:r.text})]},o))})]})}const G9=4e3,q9=e=>!!e.learning&&e.learning.reason!=="use",K9="The agent looks back on your words: what was wrong, and what a right answer does.",V9="A look-back needs words. Without them the grade is still kept.",Y9='A JSON object of the fields a right answer holds, like {"total": 42}. Replays of a learned workflow are scored against it.',oN='Write it as a JSON object, like {"total": 42}, or leave it empty.';function Q9(e){if(!e.trim())return{};try{const n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{value:n}:{error:oN}}catch{return{error:oN}}}function J9(e){const n=Ht(e,"the grade");return e instanceof ze&&e.status<500&&n.said?n.said:`${n.why} ${n.next}`}const X9="The review could not run.";function Z9(e,n){return e.feedback&&e.feedback_status==="not_run"?X9:e.feedback==="look_back"?n?"The agent is looking back on your words.":"The agent looked back on your words.":"Kept for this agent."}function eH({run:e,graded:n,onGrade:s,onOpenTimeline:r}){const[o,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=Ga(e.status),E=n!=null&&n.feedback?n.feedback_status:null,S=E==="running"||E==="ended"&&Km(e.learning??void 0);if(!q9(e)||!k&&!n)return null;const N=o==="auto"?n?"closed":"choose":o,$=k&&!S,_=Q9(u),M=n?Z9(n,S):null,O=async L=>{if(j.current||!s)return;const R=L?"":c.trim();if(!L&&_.error){b(!0);return}j.current=!0,h(!0),y(null);try{await s({correct:L,...R?{label:R}:{},...!L&&_.value?{expected:_.value}:{}}),i("auto"),d(""),f(""),b(!1)}catch(A){y(J9(A))}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(ke,{tone:n.correct?"success":"error",children:["Graded ",n.correct?"right":"wrong"]}),S&&t.jsx(ke,{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:[M&&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:M}),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 O(!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(),O(!1)},children:[t.jsx(wt,{label:"What was wrong?",note:K9,warning:c.trim()?void 0:V9,children:t.jsx(nn,{value:c,onChange:L=>d(L.target.value),maxLength:G9,rows:3,disabled:x,className:"resize-y font-sans text-lead"})}),t.jsx(wt,{label:"Correct answer",optional:!0,note:Y9,error:g?_.error:void 0,children:t.jsx(nn,{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 tH=(e,n)=>n&&(!e||Date.parse(n.graded_at)>Date.parse(e.graded_at))?n:e;function nH(e,n,s){const r=!!s&&!!e.learning,[o,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?o:null,v=tH((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>sH)return;const j=setTimeout(()=>b(k=>k+1),tx(u-1));return()=>clearTimeout(j)},[y,u]),{read:h,grade:v,graded:x}}const sH=8,rH=e=>e===1?"once":e===2?"twice":`${e} times`;function oH({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:Vm(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(Nf,{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(ke,{tone:"success",children:"Read"}):t.jsx(ke,{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(Xa,{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 ",rH(s.calls)]}),s.failed>0&&t.jsxs(ke,{tone:"error",children:[s.failed," failed"]})]},`workflow:${s.name}`))]})]})}const Di=(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}),Ar=(e,n=[])=>({type:"object",additionalProperties:!1,properties:e,...n.length?{required:n}:{}}),aH={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:Ar({includeIframes:{type:"boolean",default:!0}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},iH=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."}),lH=e=>`Browse and automate websites in the persistent browser. ${iH.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"}]}.`,cH={name:"run",label:"Browser: run",description:lH(),parameters:Ar({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},Di("click"),Di("hover"),Di("fill",{value:{type:"string"}}),Di("type",{text:{type:"string"},delay:{type:"number",minimum:0}}),Di("press",{key:{type:"string"}}),Di("select",{values:{oneOf:[{type:"string"},{type:"array",items:{type:"string"},minItems:1}]}})]},minItems:1}}),effect:"effect",replay:"unsafe",executionMode:"sequential",evidence:"none",listedWhen:"always"},dH={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:Ar({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:{...Ar({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"},uH={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:Ar({what:{type:"string",enum:["markdown","text","html","url","title"],description:"Default markdown."}}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"receipt",listedWhen:"always"},fH={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:Ar({}),effect:"custody",replay:"safe",executionMode:"sequential",evidence:"none",listedWhen:"always"},mH={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:Ar({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"},hH={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:Ar({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"},pH={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:Ar({}),effect:"read",replay:"safe",executionMode:"sequential",evidence:"files",listedWhen:"downloads"},gH={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:Ar({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"},xH=Object.freeze([aH,cH,dH,uH,fH,mH,hH,pH,gH]),vH=Object.freeze(xH.map(e=>e.name)),yH={"com.apple.systempreferences":"System Settings","com.apple.iCal":"Calendar","com.apple.finder":"Finder","com.android.settings":"Settings","com.android.chrome":"Chrome","com.android.deskclock":"Clock","com.android.contacts":"Contacts","com.android.documentsui":"Files","org.wikipedia":"Wikipedia","xfce4-terminal":"Terminal","org.xfce.terminal":"Terminal",xterm:"XTerm","firefox-esr":"Firefox","google-chrome":"Chrome"};function bH(e){const n=e.split(".").at(-1)||e;return yH[e]??(n?n[0].toUpperCase()+n.slice(1):e)}const wH=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"]),jH=new Set(["ctrl","alt","super"]);function kH(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=>jH.has(r))||s.every(r=>wH.has(r))?e:void 0}const NH=["press","set","perform","click","type","key","nav","scroll","drag"];function SH(e,n){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=NH.find(u=>u in s)??"step",o=r==="type"?s.into:s[r],i=typeof o=="string"?n(o):void 0,c=r==="key"?kH(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 CH={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"},EH=new Set(["button","link","menuitem","tab","listitem","row","cell","radio","generic","text","heading"]);function $H(e){if(!e)return;const n=CH[e.role]??(e.role==="generic"?"element":e.role);return e.name?EH.has(e.role)?`“${e.name}”`:`the ${n} “${e.name}”`:`the ${n}`}const _H={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"]},TH={super:"⌘",shift:"⇧",alt:"⌥",ctrl:"⌃"},_g={enter:"Return",escape:"Esc",tab:"Tab",space:"Space",backspace:"Delete",delete:"Forward Delete",up:"↑",down:"↓",left:"←",right:"→"},pn=(e,n,s="")=>({did:`${e}${s}`,tried:`${n}${s}`});function RH(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()),o=n.length===1&&_g[s.toLowerCase()]?_g[s.toLowerCase()]:`${r.map(c=>TH[c]??`${c}+`).join("")}${_g[s.toLowerCase()]??(s.length===1?s.toUpperCase():s)}`,i=r.length===1&&r[0]==="super"?_H[s.toLowerCase()]:void 0;return i?pn(i[0],i[1],` (${o})`):pn("Pressed","press",` ${o}`)}const AH={back:["Went","go"," back"],home:["Went","go"," home"],app_switch:["Opened","open"," the recent apps"]};function OH(e){const n=$H(e.on),s=r=>` ${n??r}`;switch(e.do){case"press":return pn("Pressed","press",s("an element"));case"click":return pn("Clicked","click",n?` ${n}`:" at a point");case"set":return pn("Set","set",s("an element"));case"perform":return pn("Acted on","act on",s("an element"));case"type":return n?pn("Typed into","type into",` ${n}`):pn("Typed text","type text");case"key":return e.keys?RH(e.keys):pn("Pressed a key","press a key");case"nav":{const[r,o,i]=e.nav&&AH[e.nav]||["Navigated","navigate",""];return pn(r,o,i)}case"scroll":return n?pn("Scrolled","scroll",` ${n}`):pn("Scrolled","scroll");case"drag":return pn("Dragged","drag"," across the screen");default:return pn("Acted","act")}}function aN(e){const n=OH(e);return e.error===void 0?n.did:`Could not ${n.tried}`}const iN=3,Ox=e=>e[0].toLowerCase()+e.slice(1);function MH(e){const n=e.slice(0,iN).map(aN),s=e.slice(iN),r=s.findIndex(i=>i.error!==void 0),o=r<0?s.length:s.length-1;return[n[0],...n.slice(1).map(Ox),...o>0?[`+${o} more`]:[],...r<0?[]:[Ox(aN(s[r]))]].join(", ")}const PH={"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 $r(e){const n=e.app?bH(e.app):void 0,s=(()=>{var r;switch(e.method){case"apps.launch":return pn("Opened","open",` ${n??"an app"}`);case"apps.terminate":return pn("Quit","quit",` ${n??"an app"}`);case"ui.observe":return pn("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?pn("Waited for","wait for",` ${n??"the window"}${e.expect==="unmet"?" (not seen)":""}`):pn("Acted on","act on",` ${n??"the computer"}`);default:{const[o,i]=PH[e.method]??[e.method,e.method];return pn(o,i)}}})();return e.ok?s.did:`Could not ${s.tried}`}const LH=e=>e.map((n,s)=>s===0?$r(n):Ox($r(n))).join(", "),f$='\\s"`<>\\\\',IH=new RegExp(`https?://[^${f$}|]+`,"gi"),zH=new RegExp(`https?://[^${f$}]+`,"gi"),DH=".,;:!?*)]}'",FH={")":"(","]":"[","}":"{"};function UH(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&&DH.includes(e[s-1]);s--){const r=e[s-1],o=FH[r];if(o&&n[o]>=n[r])break;o&&(n[r]-=1)}return e.slice(0,s)}new RegExp(`\\]\\(|${IH.source}`,"gi");const Vo=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,un=e=>typeof e=="string"?e:void 0,Va=(e,n)=>e.length>n?`${e.slice(0,n-3)}...`:e,m$=e=>e.split(`
|
|
709
|
+
`).map(n=>n.trim()).find(Boolean)??"";function im(e){try{return Vo(JSON.parse(e))}catch{return}}const WH=/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/?#]*@)?([^/?#]+)([^?#]*)/i;function ed(e){const n=WH.exec(e.trim());return Va(n?`${n[1]}${n[2]==="/"?"":n[2]}`:e.split(/[?#]/)[0]??"",80)}const HH="…",BH=/https?:\/\//gi,GH=/^(https?:\/\/)(?:[^@/?#]*@)?([^/?#]*)([^?#]*)(?:\?([^#]*))?/i,qH=/(https?:\/\/)[^@/?#\s]*@/gi,KH=/[A-Za-z0-9]/;function Ty(e){return e.replace(zH,n=>{const s=[0];let[r,o]=[0,!1];for(const i of n.matchAll(BH)){if(i.index===0)continue;for(;r<i.index;r++)o||(o=n[r]==="?"||n[r]==="#");if(o)continue;let c=!1;for(let d=i.index-1;d>s.at(-1)&&!KH.test(n[d]);d--)c||(c=n[d]==="'");c&&s.push(i.index)}return s.map((i,c)=>VH(n.slice(i,s[c+1]??n.length))).join("")})}function VH(e){const n=UH(e).length,s=GH.exec(e.slice(0,n));if(!s)return e;const r=i=>i.replace(qH,"$1"),o=[...new Set((s[4]??"").split("&").map(i=>r(i.split("=")[0])).filter(Boolean))];return`${s[1]}${r(`${s[2]}${s[3]}`)}${o.length?`?${o.map(i=>`${i}=${HH}`).join("&")}`:""}${e.slice(n)}`}const YH=e=>e.length>2?`${e.slice(0,2).join(", ")}, +${e.length-2} more`:e.join(", "),QH=new Map,JH=new Map,h$=new Map,XH=new Set;function fn(e,n,s,{name:r,saysFailure:o}={}){QH.set(e,n),s&&JH.set(e,s),r&&h$.set(e,r),o&&XH.add(e)}const ZH=/^mcp__([a-z][a-z0-9-]{0,31})__([A-Za-z0-9_-]{1,64})$/,e7=/^mcp:([a-z][a-z0-9-]{0,31})\/([A-Za-z0-9_-]{1,64})$/,t7=e=>{const n=e7.exec(e)??ZH.exec(e);return n&&n[1]!=="hands"?`${n[1]} · ${n[2]}`:void 0},n7=e=>h$.get(e)??t7(e)??e,s7=new Map;function Ry(e,n){s7.set(e,n)}const r7=new Set(["snapshot","run","screenshot","browser_read","browser_downloads"]);[...r7];const Ay=e=>un(e.path)??un(e.file_path),o7=/page\.goto\(\s*["'`]([^"'`]+)/;fn("read",e=>`Read ${Ay(e)??"a file"}`,{many:e=>`Read ${e} files`,subject:e=>e??void 0,path:!0},{name:"Read files"});fn("write",e=>`Wrote ${Ay(e)??"a file"}`,{many:e=>`Wrote ${e} files`,subject:e=>e??void 0,path:!0},{name:"Write files"});fn("edit",e=>`Edited ${Ay(e)??"a file"}`,{many:e=>`Edited ${e} files`,subject:e=>e??void 0,path:!0},{name:"Edit files"});fn("bash",e=>`Ran \`${Va(Ty(m$(un(e.command)??"")),60)}\``,{many:e=>`Ran ${e} commands`},{name:"Run commands"});const p$=e=>{const n=e&&Vo(im(e.text)??im(m$(e.text)));if((n==null?void 0:n.ok)!==!1)return;const s=un(n.refused);return s!==void 0?{refused:!0,detail:s.replace(/^refused:\s*/,"")}:{refused:!1,detail:un(n.error)??un(n.message)??"no detail"}},a7=(e,n)=>`${p$(n)?"Tried to fetch":"Fetched"} ${ed(un(e.url)??"a page")}`,i7={many:e=>`Fetched ${e} pages`,subject:e=>e?ed(e):void 0},l7=e=>{const n=p$(e);return n&&{failed:!0,text:`${n.refused?"refused":"failed"}: ${n.detail}`}};fn("web_fetch",a7,i7,{name:"Fetch web pages"});Ry("web_fetch",l7);fn("web_search",e=>{const n=un(e.query);return n?`Searched the web for "${Va(Ty(n),60)}"`:"Searched the web"},{many:e=>`Searched the web ${e} times`,subject:e=>e?`"${Va(e,40)}"`:void 0},{name:"Search the web"});Ry("web_search",e=>{var s;const n=un((s=Vo(im(e.text)))==null?void 0:s.error);return n!==void 0?{failed:!0,text:`failed: ${n}`}:void 0});fn("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 "${Va(Ty(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?ed(s):void 0}},{name:"Read the browser's page"});fn("snapshot",()=>"Looked at the page structure",{many:e=>`Looked at the page structure ${e} times`},{name:"Look at the page structure"});fn("screenshot",()=>"Took a screenshot",{many:e=>`Took ${e} screenshots`},{name:"Take screenshots"});fn("run",(e,n)=>{var i,c;const s=(i=o7.exec(un(e.code)??""))==null?void 0:i[1];if(s)return`Opened ${ed(s)}`;const r=(c=Vo(n==null?void 0:n.details))==null?void 0:c.sent,o=Array.isArray(r)?r.flatMap(d=>{const u=Vo(d),[f,g]=[un(u==null?void 0:u.method),un(u==null?void 0:u.url)];return f&&g?`${f} ${ed(g)}`:[]}):[];return o.length?`Acted on the page (${o.length} request${o.length===1?"":"s"} sent: ${YH(o)})`:"Acted on the page"},{many:e=>`Acted on the page ${e} times`},{name:"Open or act on a page in the browser"});fn("browser_downloads",(e,n)=>{var o;const s=n&&((o=im(n.text))==null?void 0:o.fetched),r=Array.isArray(s)?s.flatMap(i=>{var c;return un((c=Vo(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"});fn("browser_release",()=>"Released the browser session",void 0,{name:"Release the browser session"});fn("browser_relaunch",()=>"Started a fresh browser session",void 0,{name:"Start a fresh browser session"});fn("submit",()=>"Submitted the answer",void 0,{name:"Submit the answer"});fn("codemode",()=>"Ran a script",{many:e=>`Ran ${e} scripts`},{name:"Run scripts"});fn("request_sign_in",()=>"Asked you to sign in",void 0,{name:"Ask you to sign in"});const c7=/^(\d+)\. [a-z_.]+(?: into)?(?: @\S+ ([a-z]+)(?: ("(?:[^"\\]|\\.)*"))?)?(?: \[secure\])?: (.*)$/,d7=e=>{if(e!==void 0)try{return un(JSON.parse(e))}catch{return}};function g$(e){var s;const n=new Map;for(const r of(e??"").split(`
|
|
710
|
+
`)){const o=c7.exec(r);if(!o)continue;const i=d7(o[3]),c=(s=/^refused \([^)]*\): (.*)$/.exec(o[4]))==null?void 0:s[1],d=o[2]===void 0?void 0:{role:o[2],...i?{name:i}:{}};n.set(Number(o[1]),{...d?{on:d}:{},...c!==void 0?{refused:c}:{}})}return n}function u7(e,n){return{...SH(e,()=>n==null?void 0:n.on),...(n==null?void 0:n.refused)!==void 0?{error:"refused"}:{}}}fn("computer_act",(e,n)=>{var d;const s=Array.isArray(e.steps)?e.steps.flatMap(u=>{const f=Vo(u);return f?[f]:[]}):[],r={method:"ui.act",started_at:"",ms:0,...un(e.app)?{app:un(e.app)}:{}};if(n!=null&&n.isError)return $r({...r,ok:!1});const o=n===void 0?void 0:g$(n.text),i=o===void 0?s:s.filter((u,f)=>o.has(f+1));if(s.length>0&&i.length===0)return $r({...r,ok:!1});const c=n&&((d=/^expect: (met|unmet)$/m.exec(n.text))==null?void 0:d[1]);return $r({...r,ok:!0,steps:i.map((u,f)=>u7(u,o==null?void 0:o.get(f+1))),...c==="met"||c==="unmet"?{expect:c}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Act on the computer",saysFailure:!0});Ry("computer_act",e=>{for(const[n,s]of g$(e.text))if(s.refused!==void 0)return{failed:!0,text:`step ${n} refused: ${s.refused}`}});const lN=/^state \S+ · (\S+)/,f7=/^screen \S+ px · (?:\S+ in front|no app in front)/;fn("computer_observe",(e,n)=>{var r;if(n&&!n.isError&&!lN.test(n.text)){const o=f7.test(n.text),i=(d,u)=>({method:d,started_at:"",ms:0,ok:!0,...u?{app:u}:{}}),c=o?un(e.app):void 0;return LH([...c?[i("apps.launch",c)]:[],i("screen.shot"),...o?[i("apps.list")]:[]])}const s=un(e.app)??(n&&((r=lN.exec(n.text))==null?void 0:r[1]));return $r({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});fn("computer_screenshot",(e,n)=>$r({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 cN={"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"};fn("computer_op",(e,n)=>{var i;const s=un(e.op),r=s!==void 0&&Object.hasOwn(cN,s)?cN[s]:void 0;if(!r)return n!=null&&n.isError?"Could not act on the computer":"Acted on the computer";const o=r==="apps.launch"?un((i=Vo(e.args))==null?void 0:i.id):void 0;return $r({method:r,ok:(n==null?void 0:n.isError)!==!0,...o?{app:o}:{}})},{many:e=>`Acted on the computer ${e} times`},{name:"Use the computer's apps, shell and files",saysFailure:!0});fn("computer_script",(e,n)=>{var r;const s=(r=un(e.title))==null?void 0:r.replace(/\s+/g," ").trim();return n!=null&&n.isError?s?`Could not run the script “${Va(s,120)}”`:"Could not run a script on the computer":s?Va(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 m7=["schedule","webhook","slack","github","composio","email","feed"];new Set(m7);const h7=":feedback",p7=e=>{var n;return e.kind==="user_message"&&((n=e.id)==null?void 0:n.endsWith(h7))===!0},g7={user_message:Qx,thinking:Sf,tool_use:Cf,tool_result:Cf,waiting:Gx,usage:Wx,final_answer:Qa,phase:ON,error:sl,decision:YT,text_block:WT,tool_approval_requested:IN},dN=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},uN=e=>e.kind==="tool_approval_requested"&&(e.summary??"").startsWith("Waiting for your approval"),Oy=e=>e.origin==="server",x$=e=>e.origin==="trigger",v$=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 o=/^([^:]+):\s*/.exec(n);return o?{who:o[1],said:n.slice(o[0].length)}:{who:null,said:n}};function y$(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:y$(s.slice(2,-2))},r))}const x7=e=>{var r;const n=x$(e)?v$(e).said:(e.summary??"").replace(Oy(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(([o,i])=>`${o}: ${typeof i=="string"?i:JSON.stringify(i)}`).join(" · ")}catch{}const s=(e.text??"").split(`
|
|
711
|
+
`).filter(o=>o.trim()).length>1?"…":"";return e.kind==="final_answer"?!n.trim()&&!((r=e.text)!=null&&r.trim())?j2:`${n.replace(/^\s*(#{1,6}\s+|>\s+|[-*+]\s+)/,"")}${s}`:e.kind==="user_message"?`${n}${s}`:n},td=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`,v7=new Set(vH),y7=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 b7(e){const n=y7.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 fN=e=>e&&(NI(e)??(v7.has(e)?n7(e):b7(e))),mN=e=>Oy(e)?"AgentRun":x$(e)?v$(e).who??"Trigger":p7(e)?"Your grade":{user_message:"You",thinking:"Thinking",tool_use:fN(e.tool_name)??"Tool",tool_result:fN(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,w7={budget:"Paused at cap"};function j7({step:e,last:n,ended:s,waitingChip:r,files:o,onOpen:i}){var y,j;const c=e.row,[d,u]=p.useState(!1),g=BM(c)?RN:g7[c.kind]??ON,b=e.above?c.kind==="tool_approval_requested"?"Waits for your approval above.":"Asked you the question above.":x7(c),x=e.above?null:e.detail??t2(c),h=x&&x.trim()!==b.trim()?x:null,v=s2(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:ie("mt-3 flex size-7 items-center justify-center border bg-background",(c.kind==="waiting"||uN(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:mN(c),children:mN(c)}),(c.kind==="tool_use"||c.kind==="tool_result")&&c.usage&&t.jsxs("span",{className:"font-mono text-label",children:["· ",zM(c.usage,{ended:s})]}),c.kind==="waiting"&&t.jsx(ke,{tone:"warning",children:r??"Input required"}),uN(c)&&t.jsx(ke,{tone:"warning",children:"Approval required"}),v&&t.jsx(ke,{tone:"error",children:"Error"}),n2(c)&&t.jsx(ke,{tone:"muted",title:"Not run: refused before it ran",children:"Refused"}),c.agent_label&&t.jsx(ke,{label:!0,title:c.agent_label,children:c.agent_label}),e.ms!==void 0&&t.jsx("span",{className:"font-mono text-label",children:td(e.ms)}),e.times&&t.jsxs("span",{className:"font-mono text-label",children:[e.times," times",e.until?` over ${td(Math.max(0,Date.parse(e.until)-Date.parse(c.timestamp)))}`:""]})]}),t.jsx("span",{className:ie("mt-0.5 block break-words text-prose leading-snug",Oy(c)&&"text-muted-foreground"),children:y$(b)}),e.saved&&t.jsxs("span",{className:"mt-0.5 block font-mono text-small text-muted-foreground",children:["saved ",e.saved]}),dN(c)&&t.jsx("span",{className:"mt-0.5 block break-words text-body text-muted-foreground",children:dN(c)})]}),t.jsx("span",{className:"caps shrink-0 pt-0.5 text-label text-muted-foreground",children:md(c.timestamp)}),h&&t.jsx(Es,{className:ie("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:Cv(k=>{const E=o==null?void 0:o.find(S=>S.path===k);E&&(i==null||i(E))}),dangerouslySetInnerHTML:{__html:so(h,i&&o?{paths:o.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(S7,{nodes:c.learned_nodes}):null,(j=c.computer_calls)!=null&&j.length?t.jsx(k7,{calls:c.computer_calls,dropped:c.computer_calls_dropped??0}):null]})]})}function k7({calls:e,dropped:n}){const[s,r]=p.useState(!1),o=e.filter(u=>!u.ok).length,i=e.length+n,c=[`${i} computer ${i===1?"call":"calls"}`,...o?[`${o} 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(Es,{className:ie("size-3 transition-transform",s&&"rotate-90"),"aria-hidden":!0}),t.jsx(Ja,{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:["+",td(Math.max(0,Date.parse(u.started_at)-d))]}),t.jsx("span",{className:ie("min-w-0 flex-1 truncate text-body",!u.ok&&"text-destructive-text"),title:$r(u),children:$r(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:td(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 N7={ok:"success",failed:"error",escalated:"warning"};function S7({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"),o=[`${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(Es,{className:ie("size-3 transition-transform",n&&"rotate-90"),"aria-hidden":!0}),t.jsx(Xa,{className:"size-3","aria-hidden":!0}),o]}),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(ke,{tone:N7[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:X2(i)||void 0,children:Qv(i.kind,i)}),t.jsx("span",{className:"w-14 text-right font-mono text-label text-muted-foreground",children:td(i.duration_ms)})]},c))})]})}function C7({rows:e,live:n,fold:s=6,asking:r,waitingOn:o,files:i,onOpen:c,ended:d=!1}){var y;const u=o==="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=GM(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(Es,{className:"size-3","aria-hidden":!0})," ",h," earlier ",h===1?"step":"steps"]}),t.jsx("ol",{children:v.map((j,k)=>t.jsx(j7,{step:j,last:k===v.length-1&&!n,ended:d,waitingChip:j.row.id===f&&o?w7[o]:void 0,files:i,onOpen:c},j.row.id))}),n&&t.jsx(Mx,{title:"Working",note:"Steps appear as the agent takes them.",spin:!0})]}):t.jsx(Mx,{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 Mx({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(S5,{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 E7={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."},$7={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 _7(e,n){var r,o;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 ${Jr(d)} for steps still running`:"";return{title:"Paused at its spend cap",note:`${u&&typeof c=="number"?`It has spent ${Jr(c)} of its ${Jr(i)} cap${f}.`:u?`Its ${Jr(i)} cap is reached.`:"Its spend cap is reached."} Raise the cap above to continue.`,spin:!1}}if(e.status==="input_required"&&((o=e.pending)==null?void 0:o.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=Gi(e);return s?{title:`Waiting for you at the ${d$(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 T7({run:e,agentName:n,messages:s,harnessSteers:r,rows:o,files:i,outputSchema:c,readFile:d,fileUrl:u,openFile:f=null,actions:g,onMessage:b,onApprove:x,tab:h,graphView:v,costText:y,readLearningDiff:j,readLearning:k,readLearningResult:E,readComputer:S,computerEvery:N,onTakeOver:$,onHandBack:_,readComputers:M,onGrade:O}){var Ue,Xe,at,J,ve,We,Ve;const L=e.native,R=es(e),A=((Ue=e.pending)==null?void 0:Ue.kind)==="budget"?e.pending:null,P=Gi(e),z=!R&&!L&&P?r&&s.steer?"steer":s.follow_up?"follow_up":null:null,U=Fm(e.status,e.state,e.kind,s,r,e.error,e.review,e.computer),q=R||L||A?{...U,canMessage:!1,messageMode:null}:P?{...U,canMessage:z!==null,messageMode:z}:U,H=v?"graph":q.final&&e.status==="completed"?"report":"timeline",[K,W]=p.useState(h??H),G=K==="graph"&&!v?H:K,[F,D]=p.useState(!1),[Y,se]=p.useState(f?{file:f,text:null}:null),Q=JW(e),re=Q||P?null:RP(e.status,e.state,o),te=Q?o.findLast(He=>He.kind===t$&&He.tool_use_id===Q.call_id):void 0,[he,ge]=p.useState(null),be=async(He,gt,kt,lt)=>{const Vt=x?await(lt?x(He,gt,kt,lt):x(He,gt,kt)):"This page can't answer an approval.";return ge(Vt?{id:He,text:Vt}:null),Vt},xe=p.useRef(k2()).current,fe=async He=>{const gt=xe.begin();if(se({file:He,text:null}),!d)return;const kt=await d(He);xe.current(gt)&&se({file:He,text:kt})},De=()=>{xe.cancel(),se(null)},Fe=W9(e,j),{read:Pe,grade:Ee,graded:ae}=nH(e,q.final,k),$e=O&&(async He=>{const gt=await O(He);return ae(gt),gt}),ot=q.live||e.status==="input_required"&&e.state==="waiting"||e.status==="paused",me=e.computer,Le=me?D9(o,me.kind):void 0,{view:Ze,held:yt}=_9(S,!q.final,N,void 0,e.status==="queued"||Le!==void 0),oe=!!Ze||!!me||!!P,Se=p.useRef(!1);p.useEffect(()=>{if(oe){Se.current=!0;return}Se.current&&G==="screen"&&W(H),Se.current=!1},[oe,G,H]);const[tt,Ae]=p.useState(!1);p.useEffect(()=>{if(!me||!cy.has(me.kind)||!M)return;let He=!0;return M().then(gt=>{var kt,lt;He&&Ae(!!((lt=(kt=gt.kinds.find(Vt=>Vt.kind===me.kind))==null?void 0:kt.providers.find(Vt=>Vt.id===me.provider))!=null&<.metered))}).catch(()=>{}),()=>{He=!1}},[me==null?void 0:me.kind,me==null?void 0:me.provider]);const it=P?`${P.kind}:${P.asked_at}`:null,$t=p.useRef(null);p.useEffect(()=>{!it||$t.current===it||!oe||($t.current=it,W("screen"))},[it,oe]);const nt=async()=>{if(!$)return"This page can't take the computer over.";try{return yt((await $()).hold),null}catch(He){return Ax(He,"take")}},ft=async He=>{if(!_)return"This page can't hand the computer back.";try{return yt((await _(He)).hold),null}catch(gt){return Ax(gt,"hand")}},[Dt,Ft]=p.useState(null),ye=async He=>{const gt=(P==null?void 0:P.asked_at)??"",kt=await ft(He);return Ft(kt?{at:gt,text:kt}:null),kt};p.useEffect(()=>{f&&d&&fe(f)},[f]);const de=[...v?[["graph","Graph"]]:[],["report","Report"],["timeline","Timeline"],...e.learning?[["learning","Learning"]]:[],["files",`Files ${l$(i,F).length}`],...oe?[["screen","Screen"]]:[]];return t.jsxs("div",{className:"flex h-full min-h-0 flex-col short:h-auto",children:[t.jsx(f9,{run:e,agentName:n,actions:g,costText:y}),t.jsx(OS,{id:"run-views",label:"Run views",value:G,onChange:He=>W(He),tabs:de.map(([He,gt])=>({id:He,label:gt}))}),G==="graph"?t.jsx("div",{className:"min-h-0 flex-1 short:min-h-96",children:v}):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:[L&&t.jsx(j9,{native:L,agentId:e.agent_id}),e.status==="failed"&&e.error&&t.jsx(oa,{error:e.error,title:$2(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."]})]}),he&&he.id!==(Q==null?void 0:Q.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: ",he.text]}),Dt&&Dt.at!==(P==null?void 0:P.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: ",Dt.text]}),Q?t.jsx(s$,{pending:Q,onAnswer:(He,gt,kt)=>kt?be(Q.id,He,gt,kt):be(Q.id,He,gt)},Q.id):P?t.jsx(u$,{ask:P,onAnswer:_?ye:void 0,open:G!=="screen"?t.jsx(B,{size:"sm",variant:"primary",onClick:()=>W("screen"),children:"Open the screen"}):null},it):!L&&q.needsYou&&(A?t.jsx(o9,{pending:A}):t.jsx(i9,{waiting:re})),q.needsYou&&A&&typeof A.cap_usd=="number"&&(g==null?void 0:g.onRaiseCap)&&t.jsx(i$,{cap:A.cap_usd,suggested:o$(A),least:a$(A),paused:!0,onRaise:g.onRaiseCap},`${e.run_id}:${A.at}`),G==="report"&&t.jsx(w9,{run:e,rows:o,files:i,onOpen:fe,schema:c}),G==="report"&&!e.result&&!q.final&&t.jsx(Mx,{..._7(e,q)}),G==="report"&&q.final&&!((at=(Xe=e.result)==null?void 0:Xe.final_answer)!=null&&at.trim())&&!((J=e.result)!=null&&J.output)&&!o.some(He=>{var gt;return He.kind==="final_answer"&&((gt=He.text)==null?void 0:gt.trim())})&&e.status!=="failed"&&e.status!=="cancelled"&&!e.review&&t.jsxs("p",{className:"font-mono text-body text-muted-foreground",children:[j2,q.canMessage?" Send a follow-up below to ask for one.":""]}),G==="timeline"&&t.jsx(C7,{rows:lD(o,e.learning),live:q.live,ended:Ga(e.status),asking:(te==null?void 0:te.id)??(q.needsYou&&!A?re==null?void 0:re.id:void 0),waitingOn:e.status==="input_required"?(ve=e.pending)==null?void 0:ve.kind:void 0,files:i,onOpen:fe}),(G==="report"||G==="timeline")&&t.jsx(eH,{run:e,graded:Ee,onGrade:$e,onOpenTimeline:G==="timeline"?void 0:()=>W("timeline")}),(G==="report"||G==="timeline")&&t.jsx(oH,{used:(Pe==null?void 0:Pe.used)??null,agentId:e.agent_id}),(G==="report"||G==="timeline")&&Fe&&t.jsx(H9,{got:Fe.got,retry:Fe.retry}),G==="learning"&&t.jsx(N9,{run:e,read:E,onViewChanges:Fe?()=>W("report"):void 0},e.run_id),G==="files"&&t.jsx(p9,{files:i,onOpen:fe,showHidden:F,onShowHidden:D}),G==="screen"&&oe&&t.jsx(L9,{runId:e.run_id,screen:Ze,machine:me,opens:ot,followUp:q.canMessage&&q.messageMode==="follow_up",metered:tt,waitsFor:e.status==="input_required"&&((We=e.pending)==null?void 0:We.kind)!=="stopped"?(Ve=e.pending)==null?void 0:Ve.kind:void 0,keptUntil:e.status==="input_required"?Le:void 0,onTake:$?nt:void 0,onHand:_?()=>ft():void 0,recordings:e.recordings,fileUrl:u})]})}),L&&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."]}),R&&t.jsxs("p",{className:"border-t px-5 py-4 text-small text-muted-foreground md:px-8",children:[Yo(R.runtime)," runs in your backend. Start, stop and follow up through that application's controls. AgentRun records the result and checked learning."]}),q.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(r9,{mode:q.messageMode,onSend:b,purpose:Q?E7:P&&z?$7[z]:void 0})})}),Y&&t.jsx(g9,{file:Y.file,text:Y.text,onClose:De,files:i,onOpen:fe})]})}const b$=new Set(["chain","parallel","route","map","loop","workflow"]),R7={done:"success",working:"active",failed:"error",review:"warning",escalated:"warning",stopped:"muted","not-run":"muted",pending:"plain"},A7=e=>e==="review"?"needs review":e.replace("-"," ");function My({state:e}){const n=Ff(e)??"pending";return t.jsx(ke,{tone:R7[n]??"plain",className:"whitespace-nowrap",children:A7(n)})}function Py({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 w$={good:"text-success-text",warn:"text-warning-text",bad:"text-destructive-text"},Ly=(e,n)=>e&&n?Date.parse(n)-Date.parse(e):void 0;function O7({data:e,selected:n,onSelect:s,onClose:r,fileUrl:o}){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=Ov(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=Ly(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:Qv(i.kind,u),f.tool?` · ${N$(f.tool)}`:i.via?` · ${i.via}`:"",f.tool&&jd(f.tool)&&t.jsx(S$,{}),b&&t.jsxs(t.Fragment,{children:[t.jsx(Es,{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?Bc(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(My,{state:b?b.status:u==null?void 0:u.status}),b&&(()=>{const _=Mv(e,g,b);return _.outcome?t.jsxs("span",{className:"font-mono text-label",title:_.pNote,children:["outcome ",t.jsx("b",{className:w$[_.tone??""],children:_.outcome}),_.p!==void 0&&t.jsxs("span",{className:"text-muted-foreground",children:[" · ",Bs(_.p)]})]}):null})(),f.decision&&t.jsx(Py,{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:Ji(y)})]})]}),t.jsx(B,{size:"icon",variant:"ghost","aria-label":"Close details",onClick:r,children:t.jsx(Xo,{"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(I7,{data:e,mapPath:g,index:b.index,status:b.status,fileUrl:o,zoom:d}):i.kind==="map"?t.jsx(M7,{data:e,mapPath:i.path,onSelect:s}):v&&(x.length||h.length)?t.jsx(P7,{data:e,path:i.path,mapPath:g,onSelect:s}):t.jsxs(t.Fragment,{children:[i.kind==="parallel"&&t.jsx(L7,{data:e,path:i.path,onSelect:s}),x.map((_,M)=>t.jsx(k$,{d:_,fileUrl:o,zoom:d},_.id??M)),h.map((_,M)=>t.jsx(C$,{e:_,fileUrl:o,zoom:d},M)),!x.length&&!h.length&&i.kind!=="parallel"&&t.jsx(j$,{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(H7,{src:c,onClose:()=>d(null)})]})}function j$({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.":b$.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)??[],o=y2(r);return t.jsxs("section",{children:[t.jsx("div",{className:"mb-3 grid grid-cols-5 border",children:[["Items",o.total],["Done",o.done],["Working",o.working],["Review",o.review],["Failed",o.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=Mv(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:Bc(e,n,c.index),children:Bc(e,n,c.index)??"—"}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:t.jsx(My,{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=>dl(g))].filter(Boolean).join(", "),children:u.outcome?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:ie("font-semibold",w$[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=>dl(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:"—"}):El(f)})]},c.index)})})]})]})}function P7({data:e,path:n,mapPath:s,onSelect:r}){var g;const o=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:o.find(x=>x.item===b.index),e:i.find(x=>x.item===b.index)})).filter(b=>b.d||b.e),d=o.filter(b=>b.cost_usd!==null),u=o.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:[o.length>0&&t.jsxs("p",{className:"mb-3 font-mono text-small text-muted-foreground",children:[o.length," asked · ",El(d.reduce((b,x)=>b+(x.cost_usd??0),0)),d.length<o.length?` + ${o.length-d.length} unknown`:""," · mean ",Ji(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:Bc(e,s,b.index)}),t.jsx("td",{className:"border-b py-1.5 pr-2",children:x?dl(x):h?t.jsx(My,{state:h.status}):null}),t.jsx("td",{className:"border-b py-1.5 text-right tabular-nums text-muted-foreground",children:x?Ji(x.latency_ms):h?Ji(Ly(h.startedAt,h.endedAt)):""})]},b.index))})})]})}function L7({data:e,path:n,onSelect:s}){var x,h;const r=`${n}/branches/`,o=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(o.flatMap(v=>Object.keys(v.answers??{}))),[c]=[...i],d=o.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(j$,{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=o[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(Py,{provider:v.provider})}),t.jsx("span",{className:"w-[132px] shrink-0 truncate",title:v.model??"",children:v.model??b(v)}),t.jsx(Px,{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:ie("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:El(d.some(v=>v.d.cost_usd===null)?null:d.reduce((v,y)=>v+(y.d.cost_usd??0),0))})]})]})]})}function I7({data:e,mapPath:n,index:s,status:r,fileUrl:o,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=>!b$.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(C$,{e:b,fileUrl:o,zoom:i,compact:!0},x)),f.map((b,x)=>t.jsx(k$,{d:b,fileUrl:o,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 hN=e=>`${Math.round(e*100)}%`,Bs=e=>e.toFixed(2);function Px({p:e,strong:n,tick:s,tone:r="fg"}){const o={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:ie("absolute inset-y-0 left-0 transition-[width] duration-slow",n?o:"bg-muted-foreground/45"),style:{width:hN(Math.max(0,Math.min(1,e)))}}),s!==void 0&&t.jsx("span",{className:"absolute -inset-y-1 w-px bg-primary",style:{left:hN(s)},title:`threshold ${Bs(s)}`})]})}function z7({id:e,q:n,a:s,rule:r}){const o=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:ie("w-8 font-semibold",s.noul>=.5?"text-foreground":"text-muted-foreground"),children:s.noul>=.5?"YES":"NO"}),t.jsx(Px,{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:ie("truncate",(r==null?void 0:r.kind)==="pick"?"w-48":"w-28",f?"font-semibold":"text-muted-foreground"),title:o(d),children:s.type==="score"?`${d} ${s.legend[d]??""}`:o(d)}),t.jsx(Px,{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 D7(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 F7(e){var s,r,o,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=((o=(r=e.answers)==null?void 0:r.branch)==null?void 0:o.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?`"${x2(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 k$({d:e,fileUrl:n,zoom:s}){var i,c,d;const r=Array.from(new Set([...Object.keys(e.questions??{}),...Object.keys(e.answers??{})])),o=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(Py,{provider:e.provider}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-small",children:e.model??"default model"}),t.jsx(ke,{tone:o,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:dl(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:El(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:Ji(e.latency_ms)})]})]}),e.error&&t.jsx("p",{className:ie("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)||dr(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(z7,{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:D7(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:F7(e)})]})]}),!!((d=e.evidence)!=null&&d.length)&&t.jsx(U7,{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(Es,{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(lm,{value:e.state})]})]})}function U7({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 o=dr(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:[o?t.jsxs("a",{href:o,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(_T,{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 N$=e=>{const n=jd(e);return n?`${n.tool} on ${n.server}`:e},S$=()=>t.jsx(ke,{tone:"muted",title:"An MCP server's tool",children:t.jsx("span",{"data-mcp":!0,children:"MCP"})});function C$({e,fileUrl:n,zoom:s,compact:r=!1}){var g;const o=e.output,i=o!=null,c=o&&typeof o=="object"?o: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:N$(e.tool)}),jd(e.tool)&&t.jsx(S$,{}),t.jsx("span",{className:"font-mono text-label tabular-nums text-muted-foreground",children:e.endedAt?Ji(Ly(e.startedAt,e.endedAt)):""}),t.jsx(ke,{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(lm,{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(Es,{className:"size-3 transition-transform group-open:rotate-90","aria-hidden":!0})," Output"]}),t.jsx(lm,{value:o,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=p2(e,n);if(!r)return null;const o=Object.fromEntries(Object.entries(r).map(([i,c])=>[i,(i==="steps"||i==="branches"&&s==="parallel")&&Array.isArray(c)?`… ${Gm(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(Es,{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(lm,{value:o})]})}function lm({value:e,small:n}){return t.jsx("pre",{className:ie("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 H7({src:e,onClose:n}){return t.jsx(Om,{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 E$=e=>[400,401,403,404,405,410,422].includes((e==null?void 0:e.status)??0);function B7(e,{everyMs:n=1e3,key:s="",enabled:r=!0}={}){const[o,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),pd(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(E$(j))return}v=setTimeout(y,n)};return y(),()=>{h.abort(),clearTimeout(v)}},[s,n,g,r]),{data:o,error:c,readAt:u,reload:()=>b(h=>h+1)}}function G7({data:e,actions:n={},fileUrl:s,initial:r=null,lastRead:o}){const[i,c]=p.useState(r),d=p.useMemo(()=>EP(e,i),[e,i]),u=pd(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(q7,{data:e,readAt:b,now:f,actions:n,stale:!u&&o&&f-o>5e3?Math.max(1e3,f-o):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(Nd,{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(O7,{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(Sd,{run:!0})})]})}function q7({data:e,readAt:n,now:s,actions:r,stale:o}){const i=pd(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?y2(e.nodes[c.path].items):null,{usd:u,unknown:f}=b2(e),g=[["Elapsed",ul(TP(e,n,s))],["Cost",t.jsxs(t.Fragment,{children:[El(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",V7(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(ke,{tone:"warning",children:[t.jsx(rl,{className:"size-3","aria-hidden":!0})," Paused"]})}),g.map(([b,x,h],v)=>t.jsxs("div",{className:ie("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:[o>0&&t.jsxs("span",{className:"font-mono text-label text-muted-foreground",role:"status",children:["Last read ",ul(o)," 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(Qo,{"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(rl,{"aria-hidden":!0})," ",r.busy==="pause"?"Pausing":"Pause"]}))]})]})}const K7=new Set(["agent","decide","extract","report","artifact"]),V7=e=>e.graph.nodes.filter(n=>{var s;return K7.has(n.kind)&&!["pending","not_run"].includes(((s=e.nodes[n.path])==null?void 0:s.status)??"pending")}).length;function Y7({error:e}){const n=e==null?void 0:e.status;return t.jsx("p",{className:ie("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 Q7(e,n){return!n||e.state==="loading"?{messages:Dm,steers:!1}:e.state==="failed"?{messages:n.features.messages,steers:!1}:{messages:n.features.messages,steers:qP(e.id,n.harnesses)}}async function J7(e,n){try{let s=null;do{const r=await e.listRevisions(n.agent_id,s),o=r.revisions.find(c=>c.revision===n.revision),i=o==null?void 0:o.definition.output_schema;if(o)return{state:"read",id:o.definition.harness,...i?{outputSchema:i}:{}};s=r.next_cursor}while(s)}catch{}return{state:"failed"}}const pN=new Set(["completed","failed","cancelled"]),X7={firstMs:2e3,maxMs:16e3,totalMs:12e4};function Z7(e,n,s,r=X7){var g;const o=!!e&&pN.has(e.status)&&Km(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&&pN.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(!o)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)}},[o])}const gN=new Set(["completed","failed","cancelled"]),eB=e=>{const n=b2(e);return`${El(n.usd)}${n.unknown?` + ${n.unknown} unknown`:""}`},tB=e=>e instanceof ze?e.toApiError():{code:"network",message:e instanceof Error?e.message:String(e),retryable:!0},Fi=e=>({api:tB(e),title:lP(e),cause:e}),nB=3e3;function xN({v2:e,runId:n,caps:s,agentName:r}){var se;const[o,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(k2()).current,N=p.useRef(Ys()).current,$=p.useRef(0),_=p.useRef(""),[M,O]=p.useState({state:"loading"});p.useEffect(()=>{o&&M.state==="loading"&&J7(e,o).then(O)},[o==null?void 0:o.revision]);const L=Q7(M,s);Z7(o,()=>R(),()=>k(Q=>Q+1));const R=async()=>{const Q=S.begin();try{const[re,te]=await Promise.all([e.getRun(n),e.listFiles(n)]);S.current(Q)&&(i(re),b(te.files))}catch(re){S.current(Q)&&h(Fi(re))}};p.useEffect(()=>{R()},[n]),XE(()=>{R()});const A=((se=o==null?void 0:o.recordings)==null?void 0:se.some(Q=>!Q.finished))===!0;p.useEffect(()=>{if(!A)return;const Q=setInterval(()=>{R()},nB);return()=>clearInterval(Q)},[A,n]),p.useEffect(()=>{const Q=new AbortController;return d(null),r2(e,n,{signal:Q.signal,onRows:re=>{f(re);const te=re.filter(ge=>ge.kind===t$).map(ge=>`${ge.id}\0${ge.summary}`).join("");te!==_.current&&(_.current=te,R());const he=re.filter(ge=>ge.kind==="tool_result").length;he>$.current&&($.current=he,R())},onPage:re=>{re.cost&&d(re.cost);const te=`${re.status}/${re.state}`;(te!==E.current||re.status==="input_required"&&!re.unchanged)&&(E.current=te,R())}}).catch(re=>{Q.signal.aborted||h(Fi(re))}),()=>Q.abort()},[n,j]);const P=async Q=>{y(Q);try{await e[Q](n),h(null)}catch(re){h(Fi(re))}y(null),await R(),k(re=>re+1)},z=async()=>{if(o){y("archive");try{const Q=await(o.archived_at?e.unarchiveRun(n):e.archiveRun(n));i(re=>re?{...re,archived_at:Q.archived_at}:Q),h(null)}catch(Q){h(Fi(Q))}y(null),R()}},U=async Q=>{const re=await Q();return await R(),k(te=>te+1),re},q=Q=>U(()=>e.raiseCap(n,Q)),H=Q=>U(()=>e.gradeRun(n,Q)),K=async Q=>{let re=!0;try{await wC(N,n,Q,e.sendMessage),h(null)}catch(te){h(Fi(te)),re=!1}return await R(),k(te=>te+1),re},W=async(Q,re,te,he)=>{let ge=null;try{await e.answerApproval(n,Q,re,te,he)}catch(be){ge=n$(be)}return await R(),k(be=>be+1),ge},G=async Q=>{try{return await Q()}finally{R(),k(re=>re+1)}},F=B7(Q=>e.getRunGraph(n,Q),{key:n,enabled:(o==null?void 0:o.kind)==="workflow"}),D=!F.data&&E$(F.error);if(!o)return x?x.cause instanceof ze&&x.cause.status===404?t.jsx(i2,{what:"run",id:n,list:{href:"#/runs",label:"Open the runs list"}}):t.jsx(Jt,{problem:Ht(x.cause,"the run"),onRetry:()=>{h(null),R(),k(Q=>Q+1)}}):t.jsx(sP,{});const Y=c&&!gN.has(o.status)?{...o,cost:c}:o;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(oa,{title:x.title,error:x.api})}),t.jsx(T7,{run:Y,agentName:r(o.agent_id),messages:L.messages,harnessSteers:L.steers,graphView:o.kind==="workflow"&&!D?t.jsx(sB,{v2:e,runId:n,graph:F,onMoved:()=>{R()}}):void 0,costText:o.kind==="workflow"&&!gN.has(o.status)&&F.data?eB(F.data):void 0,outputSchema:M.state==="read"?M.outputSchema:void 0,rows:u,files:g,readFile:Q=>e.readFile(n,Q.path),fileUrl:Q=>e.fileUrl(n,Q),readLearningDiff:()=>e.runLearningDiff(n),readLearning:()=>e.runLearning(n),readLearningResult:()=>e.runLearningResult(n),readComputer:()=>e.runComputer(n),onTakeOver:()=>G(()=>e.takeOverComputer(n)),onHandBack:Q=>G(()=>e.handBackComputer(n,Q)),readComputers:()=>e.computers(),onMessage:K,onApprove:W,onGrade:H,actions:{onStop:()=>void P("stop"),onCancel:()=>void P("cancel"),onArchive:()=>void z(),onRaiseCap:q,busy:v}},o.run_id)]})}function sB({v2:e,runId:n,graph:s,onMoved:r}){const{data:o,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(Fi(k))}f(null),d(),r()},y=o&&x&&c<x.at?{...o,run:{...o.run,paused:x.paused,...x.status?{status:x.status}:{}}}:o;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(oa,{title:g.title,error:g.api})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(G7,{data:y,lastRead:c,fileUrl:j=>e.fileUrl(n,j),actions:{onPause:()=>void v("pause"),onResume:()=>void v("resume"),busy:u}})})]}):t.jsx(Y7,{error:i})}function vN({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(Kx,{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 rB({view:e,error:n,onRetry:s,scope:r,needsYou:o,asking:i,failed:c,live:d,startHere:u,actions:f,observations:g,hasObservedSessions:b=!1}){if(!e)return t.jsx(vN,{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(Jt,{problem:n,onRetry:s}):t.jsx(nP,{}),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,yN(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}`,yN(e.runs.needsReview)??""].filter(Boolean).join(" · ")]];return t.jsx(vN,{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(Jt,{problem:n,onRetry:s,className:""}),u,o,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:ie("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:oB(e)})]}),r&&t.jsx(f2,{range:r.range,onRange:r.onRange,agent:r.agent,agents:e.perAgent,onAgent:r.onAgent})]}),t.jsx(m2,{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(Sf,{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:dn(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(sd,{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($l,{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:Cn(y)}),t.jsx(oy,{run:y,className:"hidden sm:inline-flex"}),GU(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:ul(Date.parse(y.ended_at)-Date.parse(y.created_at))}),y.cost&&(y.cost.usd!==null||Sl(y.cost))&&t.jsx("span",{className:"hidden font-mono text-small text-muted-foreground sm:inline",children:no(y.cost,{ended:Ga(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 yN=e=>e?`${e} ${e===1?"needs":"need"} review`:void 0;function oB(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,o=s.from?Tv.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?`${o}, of ${((i=e.perAgent.find(c=>c.agentId===s.agent))==null?void 0:i.name)??s.agent}`:o}const hs=e=>`#/runs/${encodeURIComponent(e)}`;function aB({asking:e,failed:n,failedAll:s,live:r,learning:o=[],agentName:i,onAnswer:c,onApprove:d,onHandBack:u,onRunAgain:f,onStop:g,problem:b,now:x=Date.now}){const h=FU(n.filter(A=>!es(A))),v=n.filter(A=>!A.imported_from&&es(A)),[,y]=p.useState(0);p.useEffect(()=>{if(!r.length)return;const A=setInterval(()=>y(P=>P+1),1e3);return()=>clearInterval(A)},[r.length]);const[j,k]=p.useState([]),E=(A,P,z)=>{const U=e.find(H=>H.run_id===A),q=U?Cn(U):A;k(H=>[...H.filter(K=>K.runId!==A),...z?[{runId:A,what:P,title:q,text:z}]:[]])},S=d&&(async(A,P,z,U,q)=>{const H=await(q?d(A,P,z,U,q):d(A,P,z,U));return E(A,P,H),H}),N=u&&(async(A,P,z)=>{const U=await u(A,z);return E(A,`ask:${P.asked_at}`,U),U}),$=A=>{var z;const P=Gi(A);return((z=A.pending)==null?void 0:z.kind)==="approval"?A.pending.id:P?`ask:${P.asked_at}`:null},_=YE(n),M=o.filter(A=>A.pending>0),O=M.reduce((A,P)=>A+P.pending,0),L=e.length+_+O;if(!L&&!r.length&&!b&&!j.length)return null;const R=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(A=>!e.some(P=>P.run_id===A.runId&&$(P)===A.what)).map(A=>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:hs(A.runId),className:"underline-offset-4 hover:underline",children:A.title}),": your answer wasn't taken. ",A.text]}),t.jsx("button",{type:"button",className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",onClick:()=>k(P=>P.filter(z=>z.runId!==A.runId)),children:"Dismiss"})]},A.runId)),e.length>0&&t.jsx("ul",{className:"grid grid-cols-1 gap-3 xl:grid-cols-2",children:e.map(A=>{var P,z,U;return A.native?t.jsxs("li",{className:"space-y-2 border p-4",children:[t.jsx("a",{href:hs(A.run_id),className:"text-body underline underline-offset-2",children:Cn(A)}),t.jsxs("p",{className:"text-small text-muted-foreground",children:["Native sessions cannot receive another message. ",t.jsx("a",{href:`#/playground?agent=${encodeURIComponent(A.agent_id)}`,className:"underline underline-offset-2",children:"Start a new native run"})," to continue."]})]},A.run_id):((P=A.pending)==null?void 0:P.kind)==="approval"?t.jsx(iB,{run:A,pending:A.pending,agentName:i(A.agent_id),at:R,onApprove:S},`${A.run_id}:${A.pending.id}`):Gi(A)?t.jsx(lB,{run:A,ask:Gi(A),agentName:i(A.agent_id),at:R,onHandBack:N},`${A.run_id}:${Gi(A).asked_at}`):t.jsx(cB,{run:A,agentName:i(A.agent_id),at:R,onAnswer:c},`${A.run_id}:${((z=A.pending)==null?void 0:z.kind)==="question"?A.pending.asked_at:((U=A.pending)==null?void 0:U.kind)==="budget"?A.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(A=>t.jsx(fB,{message:A.message,runs:A.runs,agentName:i,at:R,onRunAgain:f},A.message)),v.map(A=>t.jsx(bN,{run:A,agentName:i(A.agent_id)},A.run_id))]})]}),M.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 · ",O]}),t.jsx("ul",{children:M.map(A=>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:A.name}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-muted-foreground",children:sy(A.pending)}),t.jsx("a",{href:`#/agents/${encodeURIComponent(A.agent_id)}/learning`,className:"caps shrink-0 text-label text-muted-foreground hover:text-foreground",children:"Review →"})]},A.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(A=>es(A)?t.jsx(bN,{run:A,agentName:i(A.agent_id)},A.run_id):t.jsx(mB,{run:A,agentName:i(A.agent_id),at:R,onStop:g},A.run_id))})]})]})}function iB({run:e,pending:n,agentName:s,at:r,onApprove:o}){return t.jsx("li",{"data-run":e.run_id,className:"min-w-0",children:t.jsx(s$,{compact:!0,pending:n,heading:t.jsx(Iy,{run:e,agentName:s,since:`asked ${Od(n.requested_at,r)} ago`}),onAnswer:(i,c,d)=>o?d?o(e.run_id,n.id,i,c,d):o(e.run_id,n.id,i,c):Promise.resolve("Open the run to answer it.")})})}function lB({run:e,ask:n,agentName:s,at:r,onHandBack:o}){return t.jsx("li",{"data-run":e.run_id,className:"min-w-0 border border-warning/50 bg-warning/5",children:t.jsx(u$,{compact:!0,ask:n,heading:t.jsx(Iy,{run:e,agentName:s,since:`asked ${Od(n.asked_at,r)} ago`}),open:t.jsx("a",{href:hs(e.run_id),className:"text-body underline underline-offset-2",children:"Open its screen"}),onAnswer:o&&(i=>o(e.run_id,n,i))})})}function cB(e){var n;return((n=e.run.pending)==null?void 0:n.kind)==="budget"?t.jsx(dB,{run:e.run,pending:e.run.pending,agentName:e.agentName}):t.jsx(uB,{...e})}function dB({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:hs(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:Cn(e)})]}),t.jsx("p",{className:"caps mt-2 text-label text-warning-text",children:r$(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:hs(e.run_id),className:"underline-offset-4 hover:underline",children:"open the run"})})]})}function Iy({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:hs(e.run_id),className:"-my-1 min-w-0 truncate py-1 text-muted-foreground hover:text-foreground",children:Cn(e)}),s&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-small text-muted-foreground",children:s})]})}function uB({run:e,agentName:n,at:s,onAnswer:r}){var j;const o=((j=e.pending)==null?void 0:j.kind)==="question"?e.pending:null,i=(o==null?void 0:o.question)??"",c=DU(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(Iy,{run:e,agentName:n,since:o!=null&&o.asked_at?`asked ${Od(o.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:hs(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:ie("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(Me,{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 fB({message:e,runs:n,agentName:s,at:r,onRunAgain:o}){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 o(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:hs(y.run_id),className:"min-w-0 truncate hover:underline",children:Cn(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:hs(k.run_id),className:"hover:underline",children:Cn(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:[Od(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 bN({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," · ",Yo(es(e).runtime)]}),t.jsx("a",{href:hs(e.run_id),className:"text-lead hover:underline",children:Cn(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:hs(e.run_id),className:"caps shrink-0 text-small text-muted-foreground hover:text-foreground",children:"Open"})]})}function mB({run:e,agentName:n,at:s,onStop:r}){var g;const[o,i]=p.useState(!1),[c,d]=p.useState(null),u=(g=e.cost)==null?void 0:g.usd,f=hd(e.cost)?`${no(e.cost)} so far`:u===0?"nothing spent yet":typeof u=="number"?`${no(e.cost)} so far`:Sl(e.cost)?no(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:hs(e.run_id),className:"min-w-0 flex-1 truncate text-lead hover:underline",children:Cn(e)}),t.jsxs("span",{className:"font-mono text-body text-run-active",children:["working · ",ul(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:hs(e.run_id),className:"caps inline-flex h-8 items-center border px-3 text-small hover:bg-accent",children:"Steer"}),Fm(e.status,e.state,e.kind,Dm,!0,e.error,e.review).canStop?t.jsx(B,{type:"button",size:"sm",disabled:o,onClick:async()=>{i(!0),d(await r(e.run_id)),i(!1)},children:"Stop"}):t.jsx("a",{href:hs(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 hB=[{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 $$(e){var r;const n=["pi","claude-agent","codex"],s=e.filter(o=>o.available&&o.default_model);return s.sort((o,i)=>(n.indexOf(o.id)+1||99)-(n.indexOf(i.id)+1||99)),((r=s[0])==null?void 0:r.id)??null}function pB(e,n,s){const r=Um(n,[...s]).filter(i=>i.available).map(i=>i.name),o=e.tools.find(i=>!r.includes(i));return o?{ok:!1,reason:`${o} can't run on this server yet`}:{ok:!0}}async function gB(e,n,s,r=Ys()){const i=(await Vr(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 _$="agentrun.console.start-here.dismissed",xB={hello:Qa,web:MN,plan:LT};function vB(){try{return localStorage.getItem(_$)==="true"}catch{return!1}}function yB({harnesses:e,tools:n,onTry:s,imported:r=0,keySettings:o=!1,importAction:i,modelSetup:c}){const[d,u]=p.useState(vB),[f,g]=p.useState(!1),[b,x]=p.useState(!1),[h,v]=p.useState(null),[y,j]=p.useState(null),k=$$(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(_$,"true")}catch{}},children:t.jsx(Xo,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[t.jsx(Jm,{}),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(Or,{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:hB.map(S=>{const N=pB(S,k,n),$=xB[S.id]??Qa;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. ",o?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 bB=["system","light","dark"],Lx="agentrun.theme",wB="(prefers-color-scheme: dark)",ch=()=>{try{return globalThis.localStorage??null}catch{return null}},T$=()=>typeof globalThis.matchMedia=="function"?globalThis.matchMedia(wB):null;let Ix=null;function jB(e=ch()){try{const n=e==null?void 0:e.getItem(Lx);return n==="light"||n==="dark"?n:"system"}catch{return"system"}}const zx=(e=ch())=>Ix??jB(e);function kB(e,n=ch()){Ix=null;try{e==="system"?n==null||n.removeItem(Lx):n==null||n.setItem(Lx,e)}catch{Ix=e}}function Dx(e,n=document.documentElement,s=T$()){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=T$(),s=ch()){Dx(zx(s),e,n);const r=()=>{zx(s)==="system"&&Dx("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"},CB={mission:"#/",playground:"#/playground",agents:"#/agents",runs:"#/runs",dojo:"#/dojo",templates:"#/templates",triggers:"#/triggers",settings:"#/settings/keys"},EB={system:["System",Ja],light:["Light",XT],dark:["Dark",BT]};function $B(){const[e,n]=p.useState(()=>zx()),s=r=>{kB(r),Dx(r),n(r)};return t.jsx("div",{role:"group","aria-label":"Theme",className:"flex gap-1 border p-1",children:bB.map(r=>{const[o,i]=EB[r];return t.jsx(B,{variant:"ghost",size:"sm","aria-label":o,title:o,"aria-pressed":e===r,onClick:()=>s(r),className:ie("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 wN(){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 _B({active:e,settings:n=!1,triggers:s=!1,banners:r,building:o=!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,R;x?(L=y.current)==null||L.focus():j.current&&((R=v.current)==null||R.focus())},[x]);const k=()=>{j.current=!0,h(!1)},[E,S]=p.useState(!0),N=e==="agents"||e==="runs"||e==="templates";p.useEffect(()=>{(N||o)&&S(!0)},[e,o]);const $=L=>{c?c(L):location.hash=CB[L],b(!1)},_=()=>{i?i():location.hash="#/agents/new",b(!1)},M=SB[e];p.useEffect(()=>{document.title=M?`${M} · AgentRun`:"AgentRun"},[M]);const O=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=O.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(wN,{})}),t.jsx(B,{size:"icon","aria-label":"Navigation","aria-expanded":g,onClick:()=>b(L=>!L),children:t.jsx(UT,{className:"size-4","aria-hidden":!0})})]}),t.jsxs("aside",{className:ie("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(wN,{})})}),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(yr,{className:"w-full",active:e==="mission",onClick:()=>$("mission"),children:[t.jsx(PT,{className:"size-4 shrink-0","aria-hidden":!0}),"Mission Control"]}),t.jsxs(yr,{className:"w-full",active:e==="playground",onClick:()=>$("playground"),children:[t.jsx(fm,{className:"size-4 shrink-0","aria-hidden":!0}),"API playground"]}),t.jsxs("div",{children:[t.jsxs(yr,{className:ie("w-full",N&&"text-primary-text"),"aria-expanded":E,"aria-controls":"agent-navigation",onClick:()=>S(L=>!L),children:[t.jsx(Sf,{className:"size-4 shrink-0","aria-hidden":!0}),t.jsx("span",{className:"flex-1",children:"Agents"}),t.jsx(Or,{className:ie("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(yr,{className:"w-full pl-8",active:o,onClick:_,children:[t.jsx(AT,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Build"]}),t.jsxs(yr,{className:"w-full pl-8",active:e==="agents"&&!o,onClick:()=>$("agents"),children:[t.jsx(Sf,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Connected agents"]}),t.jsxs(yr,{className:"w-full pl-8",active:e==="templates",onClick:()=>$("templates"),children:[t.jsx(Bx,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Templates"]}),t.jsxs(yr,{className:"w-full pl-8",active:e==="runs",onClick:()=>$("runs"),children:[t.jsx(sd,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Runs"]})]})]}),s&&t.jsxs(yr,{className:"w-full",active:e==="triggers",onClick:()=>$("triggers"),children:[t.jsx(um,{className:"size-4 shrink-0","aria-hidden":!0}),"Triggers"]}),t.jsxs(yr,{className:"w-full",active:e==="dojo",onClick:()=>$("dojo"),children:[t.jsx(PC,{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(yr,{className:"w-full",active:e==="settings",onClick:()=>$("settings"),children:[t.jsx(LN,{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($B,{}),t.jsxs(B,{onClick:d,className:"w-full justify-start",children:[t.jsx(zT,{"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(tW,{}),r,t.jsx("main",{ref:O,tabIndex:-1,className:"relative min-h-0 min-w-0 flex-1 overflow-auto outline-none",children:f})]})]})}const Tg={setup:{label:"New password",autocomplete:"new-password"},sign_in:{label:"Password",autocomplete:"current-password"}},jN={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 TB({mode:e,code:n=null,codeNeeded:s=!1,onSubmit:r,problem:o=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(o),[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 M=await r(c,N&&x.trim()?x.trim():void 0,E&&S&&u);k(!1),y(M)};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(Es,{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:jN[e].title}),t.jsx("p",{className:"mb-6 text-prose leading-relaxed text-muted-foreground",children:jN[e].body}),e!=="token_link"&&t.jsxs("form",{className:"space-y-5",onSubmit:M=>{M.preventDefault(),_()},children:[N&&t.jsx(wt,{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(Me,{name:"setup-code",value:x,onChange:M=>h(M.target.value),autoComplete:"one-time-code",spellCheck:!1,className:"text-lead"})}),t.jsx(wt,{label:Tg[e].label,note:E?"12 characters or more.":void 0,children:t.jsxs("span",{className:ie(Hc,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Ia,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Me,{bare:!0,type:"password",value:c,onChange:M=>d(M.target.value),autoComplete:Tg[e].autocomplete,autoFocus:!0,"aria-label":Tg[e].label,className:"h-10 min-w-0 flex-1 bg-transparent font-mono text-lead"})]})}),E&&t.jsx(wt,{label:"Again",note:g&&g!==c?"The two passwords differ.":void 0,children:t.jsxs("span",{className:ie(Hc,"flex items-center gap-3 bg-card px-3"),children:[t.jsx(Ia,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),t.jsx(Me,{bare:!0,type:"password",value:g,onChange:M=>b(M.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:M=>f(M.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:RB(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 kN=(e,n)=>`${e.toLocaleString("en-US")} ${n}${e===1?"":"s"}`,Rg="Each project becomes an agent, each session a run you can read.";function RB(e){return"counting"in e?`Counting sessions… ${Rg}`:e.sessions===null||e.projects===null?`The count isn't known. ${Rg}`:`${kN(e.sessions,"session")} in ${kN(e.projects,"project")}. ${Rg}`}function AB({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(Es,{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 R$=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.accounts)===!1};function OB(e,n){if(R$(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 MB=e=>{var n;return e.status===200&&((n=e.body)==null?void 0:n.setup_code)===!0};function PB(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 A$(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 LB=1e4;function NN(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"&&om.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(e==="#/triggers/new-feed")return{section:"triggers",trigger:null,kind:"feed"};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=xI(s[1]);return{section:"settings",settings:"mcp",signIn:kI(s[1]),...c?{add:c}:{}}}if(s=e.match(/^#\/settings\/github(?:\?(.*))?$/),s){const c=oW(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)),o=r.get("agent"),i=r.get("status");return{section:"runs",...o?{runsOf:o}:{},...i&&om.includes(i)?{status:i}:{},...r.get("archived")==="true"?{archived:!0}:{}}}function IB({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 Ag;function zB(){if(!Ag){const{code:e,rest:n}=A$(location.hash);e!==null&&history.replaceState(null,"",`${location.pathname}${location.search}${n}`),Ag={code:e}}return Ag.code}const DB=e=>Math.min(1e3*2**e,3e4),O$=1e3,FB=30;function UB(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 WB(){const[e]=p.useState(aP),[n,s]=p.useState(null),[r,o]=p.useState(!1),i=p.useRef(null);i.current=n;const c=p.useRef(!1),d=p.useRef(async()=>{}),u=p.useMemo(()=>KM({fetch:e.fetch,onSignedOut:()=>void d.current()}),[e]),[f,g]=p.useState(zB);p.useEffect(()=>{if(n!=="setup")return;const _=()=>{const{code:M,rest:O}=A$(location.hash);M!==null&&(history.replaceState(null,"",`${location.pathname}${location.search}${O}`),g(M))};return window.addEventListener("hashchange",_),_(),()=>window.removeEventListener("hashchange",_)},[n]);const[b,x]=p.useState(!1),h=async()=>{const _=await u.session(),M=R$(_)?await u.listAgents().then(()=>200,O=>O instanceof ze?O.status:0):void 0;return{mode:OB(_,M),codeNeeded:MB(_)}},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"&&(o(!0),s(_))}catch{}finally{c.current=!1}}};const[j,k]=p.useState(null),[E,S]=p.useState(0);p.useEffect(()=>{let _=!0,M;return h().then(O=>{!_||i.current!==null||(x(O.codeNeeded),s(O.mode),k(null))},O=>{if(!_||i.current!==null)return;const L=DB(E),R=O instanceof ze?O:null,A=(R==null?void 0:R.code)==="http_error",P=A&&[502,503,504].includes(R.status);k({problem:R===null?Wt(O):P?`Its address answered ${R.status}, not the server.`:`GET /v2/auth/session answered ${R.status}${A?", not as this server answers":`: ${R.message}`}`,starting:P}),M=setTimeout(()=>S(z=>z+1),L)}),()=>{_=!1,clearTimeout(M)}},[u,E]);const[N,$]=p.useState(null);return p.useEffect(()=>{if(n!=="setup")return;let _=!0;return(async()=>{for(let M=!1;_;){const O=await u.setupImport().then(L=>L,()=>{});if(!_)return;if(O===void 0&&M)return void $({projects:null,sessions:null});if(O!==void 0&&(!O||!("counting"in O||"sessions"in O)||($(O),M=!0,!("counting"in O))))return;await new Promise(L=>setTimeout(L,O$))}})(),()=>{_=!1}},[u,n]),n===null&&j!==null?t.jsx(AB,{problem:j.problem,starting:j.starting,onRetry:()=>S(_=>_+1)}):n===null?t.jsx(W0,{connection:e,children:t.jsx(HB,{})}):n!=="signed_in"?t.jsx(TB,{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(_,M,O)=>{try{return await(n==="setup"?u.setup(_,M,O):u.signIn(_)),o(!1),s("signed_in"),null}catch(L){return L instanceof ze&&L.status===403&&n==="setup"&&await y().catch(()=>{}),L instanceof ze?PB(L):L instanceof Error?L.message:String(L)}}},n):t.jsx(W0,{connection:e,children:t.jsx(BB,{v2:u,onSignedOut:()=>{o(!1),s("sign_in")}})})}function HB(){return $y().state==="offline"?t.jsx(nW,{}):t.jsx("p",{className:"p-8 text-center font-mono text-body text-muted-foreground",role:"status",children:"Connecting…"})}function BB(e){const n=p.useMemo(Ed,[e.v2]);return t.jsx(GB,{...e},n)}function GB({v2:e,onSignedOut:n}){var aa,vs,Pd,rs,Ld,Id,zd,ia,la,lo,ca,Dd,Fd,ai,Rl,ii,co,Ud,li,_t,Al,Ol,ci,Ml,Pl,Ll,di,da,Js,Xs,Zs;const{writable:s,whyNot:r}=f6(e),[o,i]=p.useState(null),[c,d]=p.useState(()=>NN()),[u,f]=p.useState(null),g=((vs=(aa=u==null?void 0:u.features)==null?void 0:aa.triggers)==null?void 0:vs.routes)===!0,[b,x]=p.useState(new Map);p.useEffect(()=>{if(!g)return;let pe=!0;return e.listTriggers().then(_e=>{pe&&x(new Map(_e.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,_=Ev(e,{active:c.section==="mission"||c.section==="runs"&&!c.run&&!c.runsOf&&!c.archived&&!c.status,days:$}),[M,O]=p.useState(null),[L,R]=p.useState(!1),A=p.useRef(!1),[P,z]=p.useState(null),[U,q]=p.useState(null),[H,K]=p.useState(null),[W,G]=p.useState(0),F=p.useRef(null),[D,Y]=p.useState(!1),[se,Q]=p.useState(!1),[re,te]=p.useState(!1),[he,ge]=p.useState(null),[be,xe]=p.useState(null),[fe,De]=p.useState(!1),[Fe,Pe]=p.useState({}),[Ee,ae]=p.useState(!1),$e=p.useRef(0),[ot,me]=p.useState([]),Le=p.useRef(-1),[Ze,yt]=p.useState(null),[oe,Se]=p.useState(0),tt=p.useRef(0),Ae=pe=>{sf(pe)||(location.hash=pe)},[it,$t]=p.useState(null),[nt,ft]=p.useState(0);p.useEffect(()=>{let pe=!0;return(async()=>{let _e=!1;for(let Ie=0;pe&&Ie<FB;){const Tt=await e.setupImport().then(Nt=>Nt,()=>{});if(!pe)return;if(Tt===void 0)Ie+=1;else{if(Ie=0,!Tt||!("state"in Tt))return;if($t(Tt),Tt.state!=="running")return void(_e&&ft(Nt=>Nt+1));_e=!0}await new Promise(Nt=>setTimeout(Nt,O$))}})(),()=>{pe=!1}},[e]),p.useEffect(()=>{const pe=()=>{const _e=c9();sf(location.hash,()=>{_e&&history.go(-_e)})?_e&&history.go(_e):d(NN())};return window.addEventListener("hashchange",pe),()=>window.removeEventListener("hashchange",pe)},[]),p.useEffect(()=>l9(),[]);const Dt=p.useRef(0),Ft=p.useRef(!1),ye=()=>{const pe=++Dt.current;return e.capabilities().then(_e=>(pe===Dt.current&&f(_e),!0),()=>!1)};p.useEffect(()=>{ye()},[e]),p.useEffect(()=>{if($e.current&&c.section!=="runs"&&c.section!=="mission"&&Le.current===nt)return;Le.current=nt;const pe=++$e.current;ae(!1),Promise.allSettled([!1,!0].map(_e=>Vr(Ie=>e.listAgents({archived:_e,cursor:Ie}),Ie=>Ie.agents))).then(_e=>{if(pe!==$e.current)return;const Ie=Object.fromEntries(_e.flatMap(Nt=>Nt.status==="fulfilled"?Nt.value:[]).map(Nt=>[Nt.agent_id,Nt.definition.name??Nt.agent_id])),Tt=_e.every(Nt=>Nt.status==="fulfilled");Pe(Nt=>Tt?Ie:{...Nt,...Ie}),ae(Tt)})},[e,c,nt]);const de={status:c.status,archived:c.archived};p.useEffect(()=>{if(c.section!=="runs"||c.run)return;const pe=++tt.current;ge(null),yt(null),(c.runsOf?e.listAgentRuns(c.runsOf,50,null,de):e.listRuns(50,null,de)).then(_e=>{pe===tt.current&&(ge(_e.runs),xe(_e.next_cursor))}).catch(_e=>{pe===tt.current&&yt(Ht(_e,"the runs"))})},[e,c,nt,oe]);const Ue=pe=>{var _e;return Fe[pe]??((_e=lt==null?void 0:lt.find(Ie=>Ie.agent_id===pe))==null?void 0:_e.definition.name)??(Ee?pe:"")},Xe=u,at={harnesses:(Xe==null?void 0:Xe.harnesses)??[],tools:lL(Xe==null?void 0:Xe.tools),thinking:((Pd=Xe==null?void 0:Xe.features)==null?void 0:Pd.thinking)??[],...typeof((rs=u==null?void 0:u.limits)==null?void 0:rs.free_model_requests)=="number"?{freeRequests:u.limits.free_model_requests}:{}},J=FD(Xe==null?void 0:Xe.tools),ve=WD(Xe==null?void 0:Xe.tools),We=[...(Id=(Ld=u==null?void 0:u.features)==null?void 0:Ld.tool_keys)!=null&&Id.routes?["keys"]:[],...J.length||ve.length?["tools"]:[],"mcp","github","email","computers","workspace",...(ia=(zd=u==null?void 0:u.features)==null?void 0:zd.webhooks)!=null&&ia.routes?["webhook"]:[]],Ve=pe=>Ae({runs:"#/runs",agents:"#/agents",playground:"#/playground",dojo:"#/dojo",mission:"#/",triggers:"#/triggers",templates:"#/templates",settings:`#/settings/${We[0]??"keys"}`}[pe]),He=p.useRef(Ys()).current,gt=async pe=>{const _e=$$(at.harnesses);if(!_e)return"This server has no model to run it on yet.";try{const Ie=await gB(e,pe,_e,He);return Ae(`#/runs/${encodeURIComponent(Ie)}`),null}catch(Ie){return Wt(Ie)}},kt=((h==null?void 0:h.analytics.by_source)??[]).filter(pe=>pe.source!=="live").reduce((pe,_e)=>pe+_e.runs,0),[lt,Vt]=p.useState(null),[ps,Qs]=p.useState([]),[$n,Wn]=p.useState(null),gs=p.useRef($n);gs.current=$n;const[xs,mn]=p.useState(null),[Hn,_s]=p.useState(0),Bn=p.useRef(0);p.useEffect(()=>{Vt(null),mn(null),Wn(null),gs.current=null},[e,c.section,c.operation,c.playgroundAgent]),p.useEffect(()=>{if(c.section!=="playground"||c.operation)return;mn(null);const pe=++Bn.current;return Vr(_e=>e.listAgents({cursor:_e}),_e=>_e.agents).then(_e=>{var Nt;if(pe!==Bn.current)return;const Ie=_e.filter(os=>!os.archived_at),Tt=gs.current??c.playgroundAgent;if(Tt&&!Ie.some(os=>os.agent_id===Tt)){Vt(null),Wn(null),mn("The selected agent is unavailable or archived. Choose another agent from Agents.");return}Vt(_e),Wn(Tt??((Nt=Ie[0])==null?void 0:Nt.agent_id)??null)}).catch(_e=>{if(pe===Bn.current){const Ie=Ht(_e,"the agents");mn(`${Ie.why} ${Ie.next}${Ie.said?` (${Ie.said})`:""}`)}}),()=>{Bn.current++}},[e,c.section,c.operation,c.playgroundAgent,Hn,nt]),p.useEffect(()=>{if(c.section!=="mission")return;let pe=!0;A.current=!0,j(null),R(!0);const _e=Rv(S);return Promise.all([e.statsOver({..._e?{from:_e}:{},...M?{agent:M}:{}}),M?e.listAgentRuns(M,10):e.listRuns(10)]).then(([Ie,Tt])=>{pe&&(v(hP(Ie,Tt.runs)),M||K(Nt=>Nt||WU(Tt.runs,Ie.analytics.by_source)))}).catch(Ie=>{pe&&j(Ht(Ie,"Mission Control"))}).finally(()=>{pe&&(A.current=!1,R(!1))}),()=>{pe=!1,A.current=!1}},[e,c.section,k,S,M,nt]),XE(()=>E(pe=>pe+1)),p.useEffect(()=>{if(c.section!=="mission")return;const pe=()=>{!document.hidden&&!A.current&&E(Ie=>Ie+1)};window.addEventListener("focus",pe),document.addEventListener("visibilitychange",pe);const _e=setInterval(pe,15e3);return()=>{window.removeEventListener("focus",pe),document.removeEventListener("visibilitychange",pe),clearInterval(_e)}},[c.section]),p.useEffect(()=>{if(c.section!=="mission"){F.current=null;return}let pe=!0;const _e=F,Ie=Gn=>Vr(qn=>e.listRuns(50,qn,{status:Gn}),qn=>qn.runs,2),Tt=()=>Vr(Gn=>e.listAgents({archived:!1,cursor:Gn}),Gn=>Gn.agents).then(Gn=>{pe&&me(Gn.filter(qn=>qf(qn)>0).map(qn=>({agent_id:qn.agent_id,name:qn.definition.name??qn.agent_id,pending:qf(qn)})))},()=>{}),os=BU(()=>Promise.allSettled([Ie("input_required"),Ie("failed"),Ie("working"),Tt()]).then(([Gn,qn,ui])=>{var uo,fo,Pr;if(!pe)return;const Mr=[Gn,qn,ui],dh=Date.now()-UU;if(q(I0(null,Mr).problem),((uo=Mr[0])==null?void 0:uo.status)==="fulfilled"&&Y(!0),((fo=Mr[1])==null?void 0:fo.status)==="fulfilled"){Q(!0);const Lr=Mr[1].value.map(hr=>hr.run_id),mo=_e.current;mo&&Lr.some(hr=>!mo.has(hr))&&E(hr=>hr+1),_e.current=new Set(Lr)}((Pr=Mr[2])==null?void 0:Pr.status)==="fulfilled"&&te(!0),z(Lr=>{const{needs:mo}=I0(Lr,Mr);return{asking:mo.asking.filter(QE),failed:mo.failed.filter(hr=>Date.parse(hr.ended_at??hr.created_at)>dh),live:mo.live}})}),1e4);return()=>{pe=!1,os()}},[e,c.section,W]);const Ts=p.useRef(mD()).current,Rs=()=>setTimeout(()=>G(pe=>pe+1),2500),On=async(pe,_e)=>{try{return await wC(Ts(pe),pe,_e,e.sendMessage),Rs(),null}catch(Ie){return Wt(Ie)}},Z=p.useRef(new Map).current,Oe=async pe=>{const _e=[];try{for(const Ie of pe){const Tt=HU(Ie.kind==="workflow"?Ie:await e.getRun(Ie.run_id));if("refusal"in Tt)throw new Error(Tt.refusal);const Nt=Z.get(Ie.run_id)??Ed();Z.set(Ie.run_id,Nt),await e.startRun(Ie.agent_id,Tt.body,Nt),_e.push(Ie.run_id)}return Rs(),{started:_e,problem:null}}catch(Ie){return _e.length&&Rs(),{started:_e,problem:Wt(Ie)}}},mt=async pe=>{try{return await e.stop(pe),Rs(),null}catch(_e){return Wt(_e)}},Ot=async(pe,_e,Ie,Tt,Nt)=>{let os=null;try{await e.answerApproval(pe,_e,Ie,Tt,Nt)}catch(Gn){os=n$(Gn)}return G(Gn=>Gn+1),os},Xt=async(pe,_e)=>{let Ie=null;try{await e.handBackComputer(pe,_e)}catch(Tt){Ie=Ax(Tt,"hand")}return G(Tt=>Tt+1),Ie},Be=p.useRef(0);p.useEffect(()=>{const pe=++Be.current;Qs([]),$n&&Vr(_e=>e.listRevisions($n,_e),_e=>_e.revisions).then(_e=>{pe===Be.current&&Qs(_e)}).catch(()=>{})},[e,$n]);const ee=async(pe,_e,Ie)=>{const Tt=performance.now();try{const Nt=await e.startRun(pe,_e,Ie);return{status:Nt.status,ms:Math.round(performance.now()-Tt),body:Nt.run,runId:Nt.run.run_id}}catch(Nt){return Ey(Nt,Math.round(performance.now()-Tt))}},we=((la=u==null?void 0:u.features)==null?void 0:la.efforts)??[],qe=u?((lo=u.features)==null?void 0:lo.learning)??null:void 0;at.learning=qe??void 0;const St=(ca=u==null?void 0:u.models)==null?void 0:ca.ready;p.useEffect(()=>{if(St!==!1)return;const pe=()=>{Ft.current||(Ft.current=!0,ye().finally(()=>{Ft.current=!1}))},_e=()=>ye(),Ie=setInterval(pe,LB);return window.addEventListener("focus",_e),()=>{clearInterval(Ie),window.removeEventListener("focus",_e)}},[e,St]);const[It,ct]=p.useState(null);p.useEffect(()=>{if(St!==!1)return;let pe=!0;return e.chatGPT().then(_e=>{pe&&ct(Hf(_e))},()=>{pe&&ct(null)}),()=>{pe=!1}},[e,St]);const[wn,_n]=p.useState(!1),mr=pe=>{ct(pe),(pe.state==="pending"||pe.state==="signed_in")&&_n(!0),pe.state==="signed_in"&&ye()},Bt=(Dd=lt==null?void 0:lt.find(pe=>pe.agent_id===$n))==null?void 0:Dd.definition,oi=(Bt==null?void 0:Bt.native)||es(Bt),io=c.operation?c.playgroundAgent:$n??c.playgroundAgent;return t.jsx(KE.Provider,{value:b,children:t.jsx(_B,{active:c.section,building:c.section==="agents"&&c.agent===null,onBuild:()=>Ae("#/agents/new"),settings:We.length>0,triggers:g,onNavigate:Ve,onSignOut:()=>{const pe=()=>void e.signOut().then(n,_e=>i(_e instanceof ze?_e.message:"The sign-out did not reach the server. Try again."));sf(null,pe)||pe()},onSignOutEverywhere:()=>{const pe=()=>void e.signOutEverywhere().then(n,_e=>i(_e instanceof ze?_e.message:"The sign-out did not reach the server. Try again."));sf(null,pe)||pe()},banners:t.jsxs(t.Fragment,{children:[o&&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: ",o]}),it&&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:UB(it)}),it.state!=="running"&&t.jsx(B,{size:"xs",type:"button",onClick:()=>$t(null),children:"Dismiss"})]})]}),children:c.section==="settings"?t.jsx(AU,{active:c.settings??"keys",offered:We,children:c.settings==="tools"?t.jsx(rW,{v2:e,choices:J,gates:ve,harnesses:at.harnesses,mcp:!!((Fd=u==null?void 0:u.features)!=null&&Fd.mcp_client),onSaved:ye,onOpen:ye}):c.settings==="mcp"?t.jsx(fW,{v2:e,signIn:c.signIn,add:c.add,writable:s,whyNot:r,choices:J}):c.settings==="github"?t.jsx(cW,{v2:e,returned:c.github}):c.settings==="email"?t.jsx(OW,{v2:e,writable:s,whyNot:r}):c.settings==="computers"?t.jsx(DW,{v2:e,writable:s,whyNot:r}):c.settings==="workspace"?t.jsx(QW,{v2:e,writable:s,whyNot:r}):c.settings==="webhook"?t.jsx(PW,{v2:e}):t.jsx(JU,{v2:e,onChange:ye,writable:s,whyNot:r,harnesses:at.harnesses,plan:t.jsx(g6,{v2:e,writable:s,whyNot:r,onChange:()=>void ye()})})}):c.section==="dojo"?t.jsx(cF,{v2:e,server:qe},nt):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(rB,{hasObservedSessions:!!((ai=_.data)!=null&&ai.sessions.length),observations:t.jsx($v,{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(Jo,{className:"size-4","aria-hidden":!0})}),t.jsx(sn,{label:"Query",prompt:zm(location.origin,M??void 0),playgroundHref:_v(M??void 0)}),t.jsx(Jm,{variant:"primary"})]}),scope:{range:S,onRange:N,agent:M,onAgent:O,refreshing:L&&h!==null},asking:P&&D?P.asking.length:null,failed:P&&se?YE(P.failed):null,live:P&&re?P.live.length:null,needsYou:P&&t.jsx(aB,{asking:P.asking,failed:P.failed,failedAll:h==null?void 0:h.runs.failed,live:P.live,learning:ot,problem:U,agentName:Ue,onAnswer:On,onApprove:Ot,onHandBack:Xt,onRunAgain:Oe,onStop:mt}),startHere:H===!1&&!((Rl=_.data)!=null&&Rl.sessions.length)?t.jsx(yB,{harnesses:at.harnesses,tools:at.tools,onTry:gt,imported:kt,keySettings:((co=(ii=u==null?void 0:u.features)==null?void 0:ii.tool_keys)==null?void 0:co.routes)===!0&&u.features.tool_keys.at_rest==="sealed",modelSetup:u&&(u.models.ready===!1||wn)?t.jsx(CW,{v2:e,needs:u.models.needs,model:u.models.default,onSaved:ye,writable:s,whyNot:r,plan:It,harnesses:at.harnesses,onPlan:mr,onDone:()=>_n(!1)}):void 0}):void 0})})}):c.section==="templates"?t.jsx(R0,{v2:e,name:c.template,install:c.install,go:Ae},c.install!==void 0?`install:${c.install}`:c.template??""):c.section==="triggers"?t.jsx(B8,{v2:e,view:{trigger:c.trigger,kind:c.kind,edit:c.edit},go:Ae,agentName:Ue,minEvery:(li=(Ud=u==null?void 0:u.features)==null?void 0:Ud.triggers)==null?void 0:li.min_every_s,failuresToPause:(Al=(_t=u==null?void 0:u.features)==null?void 0:_t.triggers)==null?void 0:Al.failures_to_pause,publicUrl:(ci=(Ol=u==null?void 0:u.features)==null?void 0:Ol.triggers)==null?void 0:ci.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(fm,{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(Et,{id:"api-operation",label:"API operation",value:c.operation??"run",onChange:pe=>{const _e=io,Ie=new URLSearchParams;pe!=="run"&&Ie.set("operation",pe),pe!=="create-agent"&&pe!=="apply-template"&&_e&&Ie.set("agent",_e),Ae(`#/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(R0,{v2:e,name:c.template,go:Ae,playground:!0,draft:c.draft},c.template??"")}):c.operation==="list-runs"?t.jsx(_U,{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(TU,{v2:e,operation:c.operation,origin:location.origin,agentId:c.playgroundAgent,draft:c.draft,harnesses:at.harnesses},`${c.operation}:${c.playgroundAgent??""}:${c.draft??""}`):t.jsxs(t.Fragment,{children:[!oi&&((Ml=u==null?void 0:u.models)==null?void 0:Ml.ready)===!1&&t.jsx(EW,{needs:u.models.needs,source:u.models.source,model:u.models.default,settings:((Ll=(Pl=u.features)==null?void 0:Pl.tool_keys)==null?void 0:Ll.routes)===!0&&u.features.tool_keys.at_rest==="sealed",chatgpt:(It==null?void 0:It.state)==="signed_out"||(It==null?void 0:It.state)==="expired"}),xs&&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: ",xs]}),t.jsx(B,{size:"sm",className:"mt-3",type:"button",onClick:()=>_s(pe=>pe+1),children:"Try again"})]}),lt&&t.jsx(EU,{agents:lt.filter(pe=>!pe.archived_at),revisions:ps,efforts:we,origin:location.origin,agentId:$n??void 0,onAgent:Wn,onSend:ee,limits:u==null?void 0:u.limits,removeUpload:e.deleteUpload,onOpenRun:pe=>Ae(`#/runs/${encodeURIComponent(pe)}`),live:pe=>t.jsx(xN,{v2:e,runId:pe,caps:u,agentName:Ue},pe)})]})]}):c.section==="agents"?c.observation?t.jsx(YM,{v2:e,sessionId:c.observation,go:Ae}):c.nativeConnect?t.jsx(n6,{v2:e,go:Ae,initialSource:c.connectionSource}):c.agent===void 0?t.jsx(s6,{v2:e,archived:!!c.archived,go:Ae},nt):c.agent===null?t.jsx(xU,{origin:location.origin,v2:e}):c.agent!==null&&!c.edit?t.jsx(eF,{v2:e,agentId:c.agent,tab:c.tab,notes:c.notes,learning:qe,routePrefix:(di=Xe==null?void 0:Xe.models)==null?void 0:di.route_prefix,harnesses:at.harnesses,efforts:we,limits:u==null?void 0:u.limits,places:Rk(u),go:Ae},c.agent):t.jsx(r6,{v2:e,choices:J,gates:ve,focusTool:c.tool,caps:{...at,routePrefix:(da=Xe==null?void 0:Xe.models)==null?void 0:da.route_prefix,decisionProvider:oL(u==null?void 0:u.workflows),places:Rk(u),mcp:!!((Js=u==null?void 0:u.features)!=null&&Js.mcp_client),mcpHarnesses:(Zs=(Xs=u==null?void 0:u.features)==null?void 0:Xs.mcp_client)==null?void 0:Zs.harnesses},agentId:c.agent,go:Ae},`${c.agent??"new"}:${c.tool??""}`):c.run?t.jsx(xN,{v2:e,runId:c.run,caps:u,agentName:Ue},c.run):t.jsx(bU,{observations:!c.runsOf&&!c.archived&&!c.status?_:void 0,runs:he,agentName:Ue,agentId:c.runsOf,error:Ze,onRetry:()=>Se(pe=>pe+1),onOpen:pe=>Ae(`#/runs/${encodeURIComponent(pe)}`),loadingMore:fe,filter:de,onFilter:pe=>Ae(IB({runsOf:c.runsOf,...pe})),onMore:be?()=>{const pe=tt.current;De(!0),(c.runsOf?e.listAgentRuns(c.runsOf,50,be,de):e.listRuns(50,be,de)).then(_e=>{pe===tt.current&&(ge(Ie=>hx(Ie??[],_e.runs)),xe(_e.next_cursor),yt(null))}).catch(_e=>yt(Ht(_e,"more runs"))).finally(()=>De(!1))}:void 0})})})}NB();xT.createRoot(document.getElementById("root")).render(t.jsx(p.StrictMode,{children:t.jsx(O5,{children:t.jsx(WB,{})})}));
|